MCPcopy
hub / github.com/automatisch/automatisch / createStep

Function createStep

packages/backend/test/factories/step.js:4–30  ·  view source on GitHub ↗
(params = {})

Source from the content-addressed store, hash-verified

2import { createFlow } from '@/factories/flow.js';
3
4export const createStep = async (params = {}) => {
5 params.flowId = params?.flowId || (await createFlow()).id;
6 params.type = params?.type || 'action';
7
8 const lastStep = await Step.query()
9 .where('flow_id', params.flowId)
10 .andWhere('deleted_at', null)
11 .orderBy('position', 'desc')
12 .limit(1)
13 .first();
14
15 params.position =
16 params?.position || (lastStep?.position ? lastStep.position + 1 : 1);
17
18 params.status = params?.status || 'completed';
19
20 if (params.appKey !== null) {
21 params.appKey =
22 params?.appKey || (params.type === 'action' ? 'deepl' : 'webhook');
23 }
24
25 params.parameters = params?.parameters || {};
26
27 const step = await Step.query().insertAndFetch(params);
28
29 return step;
30};

Calls 1

createFlowFunction · 0.90

Tested by

no test coverage detected