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:
ian
2023-05-26 18:32:46 +08:00
committed by GitHub
parent 1e8dd2c928
commit 4c919bd8f8
2 changed files with 9 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"@directus/api": patch
---
Updated handler response format for manual flows

View File

@@ -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) };
}
};