refactor: Implement test run helper to work with services
This commit is contained in:
24
packages/backend/src/services/flow.ts
Normal file
24
packages/backend/src/services/flow.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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($);
|
||||
};
|
Reference in New Issue
Block a user