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

Update last value when triggering nested flows with array values #16180

Merged
merged 8 commits into from Nov 9, 2022
1 change: 1 addition & 0 deletions api/src/operations/exec/index.test.ts
Expand Up @@ -111,6 +111,7 @@ test('Allows modules that are whitelisted', () => {

expect(
config.handler({ code: testCode }, {
data: {},
env: {
FLOWS_EXEC_ALLOWED_MODULES: 'bytes',
},
Expand Down
9 changes: 7 additions & 2 deletions api/src/operations/trigger/index.ts
@@ -1,4 +1,5 @@
import { defineOperationApi, optionToObject } from '@directus/shared/utils';
import { omit } from 'lodash';
import { getFlowManager } from '../../flows';

type Options = {
Expand All @@ -17,9 +18,13 @@ export default defineOperationApi<Options>({
let result: unknown | unknown[];

if (Array.isArray(payloadObject)) {
result = await Promise.all(payloadObject.map((payload) => flowManager.runOperationFlow(flow, payload, context)));
result = await Promise.all(
payloadObject.map((payload) => {
return flowManager.runOperationFlow(flow, payload, omit(context, 'data'));
})
);
} else {
result = await flowManager.runOperationFlow(flow, payloadObject, context);
result = await flowManager.runOperationFlow(flow, payloadObject, omit(context, 'data'));
}

return result;
Expand Down