Files
automatisch/packages/backend/src/services/flow.ts

25 lines
673 B
TypeScript

import Flow from '../models/flow';
import globalVariable from '../helpers/global-variable';
type ProcessFlowOptions = {
flowId: string;
testRun?: boolean;
};
export const processFlow = async (options: ProcessFlowOptions) => {
const flow = await Flow.query().findById(options.flowId).throwIfNotFound();
const triggerStep = await flow.getTriggerStep();
const triggerCommand = await triggerStep.getTriggerCommand();
const $ = await globalVariable({
flow,
connection: await triggerStep.$relatedQuery('connection'),
app: await triggerStep.getApp(),
step: triggerStep,
testRun: options.testRun,
});
return await triggerCommand.run($);
};