Merge pull request #1752 from automatisch/fix-step-factory
fix: Adjust step factory to use objection instead of knex
This commit is contained in:
@@ -136,7 +136,7 @@ describe('graphQL getFlow query', () => {
|
|||||||
id: actionStep.id,
|
id: actionStep.id,
|
||||||
key: 'translateText',
|
key: 'translateText',
|
||||||
parameters: {},
|
parameters: {},
|
||||||
position: 1,
|
position: 2,
|
||||||
status: actionStep.status,
|
status: actionStep.status,
|
||||||
type: 'action',
|
type: 'action',
|
||||||
webhookUrl: 'http://localhost:3000/null',
|
webhookUrl: 'http://localhost:3000/null',
|
||||||
@@ -223,7 +223,7 @@ describe('graphQL getFlow query', () => {
|
|||||||
id: actionStep.id,
|
id: actionStep.id,
|
||||||
key: 'translateText',
|
key: 'translateText',
|
||||||
parameters: {},
|
parameters: {},
|
||||||
position: 1,
|
position: 2,
|
||||||
status: actionStep.status,
|
status: actionStep.status,
|
||||||
type: 'action',
|
type: 'action',
|
||||||
webhookUrl: 'http://localhost:3000/null',
|
webhookUrl: 'http://localhost:3000/null',
|
||||||
|
@@ -5,19 +5,21 @@ export const createStep = async (params = {}) => {
|
|||||||
params.flowId = params?.flowId || (await createFlow()).id;
|
params.flowId = params?.flowId || (await createFlow()).id;
|
||||||
params.type = params?.type || 'action';
|
params.type = params?.type || 'action';
|
||||||
|
|
||||||
const lastStep = await global.knex
|
const lastStep = await Step.query()
|
||||||
.table('steps')
|
.where('flow_id', params.flowId)
|
||||||
.where('flowId', params.flowId)
|
.andWhere('deleted_at', null)
|
||||||
.andWhere('deletedAt', '!=', null)
|
.orderBy('position', 'desc')
|
||||||
.orderBy('createdAt', 'desc')
|
.limit(1)
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
params.position = params?.position || (lastStep?.position || 0) + 1;
|
params.position =
|
||||||
|
params?.position || (lastStep?.position ? lastStep.position + 1 : 1);
|
||||||
|
|
||||||
params.status = params?.status || 'completed';
|
params.status = params?.status || 'completed';
|
||||||
params.appKey =
|
params.appKey =
|
||||||
params?.appKey || (params.type === 'action' ? 'deepl' : 'webhook');
|
params?.appKey || (params.type === 'action' ? 'deepl' : 'webhook');
|
||||||
|
|
||||||
const step = await Step.query().insert(params).returning('*');
|
const step = await Step.query().insertAndFetch(params);
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user