mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Update handler response format for manual flows (#18741)
* Update handler response format for manual flows * Create olive-ligers-tie.md
This commit is contained in:
5
.changeset/olive-ligers-tie.md
Normal file
5
.changeset/olive-ligers-tie.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@directus/api": patch
|
||||
---
|
||||
|
||||
Updated handler response format for manual flows
|
||||
@@ -119,7 +119,7 @@ class FlowManager {
|
||||
id: string,
|
||||
data: unknown,
|
||||
context: Record<string, unknown>
|
||||
): Promise<{ result: unknown; cacheEnabled: boolean }> {
|
||||
): Promise<{ result: unknown; cacheEnabled?: boolean }> {
|
||||
if (!(id in this.webhookFlowHandlers)) {
|
||||
logger.warn(`Couldn't find webhook or manual triggered flow with id "${id}"`);
|
||||
throw new exceptions.ForbiddenException();
|
||||
@@ -240,7 +240,7 @@ class FlowManager {
|
||||
|
||||
this.webhookFlowHandlers[`${method}-${flow.id}`] = handler;
|
||||
} else if (flow.trigger === 'manual') {
|
||||
const handler = (data: unknown, context: Record<string, unknown>) => {
|
||||
const handler = async (data: unknown, context: Record<string, unknown>) => {
|
||||
const enabledCollections = flow.options?.['collections'] ?? [];
|
||||
const targetCollection = (data as Record<string, any>)?.['body'].collection;
|
||||
|
||||
@@ -261,9 +261,9 @@ class FlowManager {
|
||||
|
||||
if (flow.options['async']) {
|
||||
this.executeFlow(flow, data, context);
|
||||
return undefined;
|
||||
return { result: undefined };
|
||||
} else {
|
||||
return this.executeFlow(flow, data, context);
|
||||
return { result: await this.executeFlow(flow, data, context) };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user