Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(framework,api): add source when triggered from workflow #6504

Open
wants to merge 11 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,19 @@ export class ParseEventRequest {
if (environment) {
const discoveredWorkflow = await this.queryDiscoverWorkflow(command, environment);

const template = await this.getNotificationTemplateByTriggerIdentifier({
environmentId: command.environmentId,
triggerIdentifier: command.identifier,
});

if (!discoveredWorkflow) {
throw new UnprocessableEntityException('workflow_not_found');
}

if (!template && command.payload?.__source === 'framework-workflow-trigger') {
throw new UnprocessableEntityException('workflow_not_synced');
}

return await this.dispatchEvent(command, transactionId, discoveredWorkflow);
}

Expand Down
1 change: 1 addition & 0 deletions packages/framework/src/resources/workflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function workflow<
to: event.to,
payload: {
...validatedData,
__source: 'framework-workflow-trigger',
},
...(event.transactionId && { transactionId: event.transactionId }),
...(event.overrides && { overrides: event.overrides }),
Expand Down
2 changes: 2 additions & 0 deletions packages/framework/src/resources/workflow/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ describe('workflow function', () => {
to: '[email protected]',
payload: {
free: 'field',
__source: 'framework-workflow-trigger',
},
}),
headers: {
Expand Down Expand Up @@ -399,6 +400,7 @@ describe('workflow function', () => {
to: '[email protected]',
payload: {
foo: 'bar',
__source: 'framework-workflow-trigger',
},
}),
headers: {
Expand Down
Loading