fix(update-flow-status): throw at incomplete trigger step

This commit is contained in:
Ali BARIN
2024-08-08 08:47:08 +00:00
parent 58cd2c522e
commit 47aabbe9c5
2 changed files with 13 additions and 4 deletions

View File

@@ -30,6 +30,11 @@ const updateFlowStatus = async (_parent, params, context) => {
} }
const triggerStep = await flow.getTriggerStep(); const triggerStep = await flow.getTriggerStep();
if (triggerStep.status === 'incomplete') {
throw flow.IncompleteStepsError;
}
const trigger = await triggerStep.getTriggerCommand(); const trigger = await triggerStep.getTriggerCommand();
const interval = trigger.getInterval?.(triggerStep.parameters); const interval = trigger.getInterval?.(triggerStep.parameters);
const repeatOptions = { const repeatOptions = {

View File

@@ -112,6 +112,13 @@ class Flow extends Base {
return lastExecutions.map((execution) => execution.internalId); return lastExecutions.map((execution) => execution.internalId);
} }
get IncompleteStepsError() {
return new ValidationError({
message: 'All steps should be completed before updating flow status!',
type: 'incompleteStepsError',
});
}
async $beforeUpdate(opt, queryContext) { async $beforeUpdate(opt, queryContext) {
await super.$beforeUpdate(opt, queryContext); await super.$beforeUpdate(opt, queryContext);
@@ -124,10 +131,7 @@ class Flow extends Base {
}); });
if (incompleteStep) { if (incompleteStep) {
throw new ValidationError({ throw this.IncompleteStepsError;
message: 'All steps should be completed before updating flow status!',
type: 'incompleteStepsError',
});
} }
const allSteps = await oldFlow.$relatedQuery('steps'); const allSteps = await oldFlow.$relatedQuery('steps');