chore: Adjust untilStep logic for processor

This commit is contained in:
Faruk AYDIN
2022-02-20 20:24:16 +03:00
committed by Ömer Faruk Aydın
parent ba2b5afe2b
commit 98864ceadd

View File

@@ -24,25 +24,25 @@ class Processor {
}); });
let previousExecutionStep: ExecutionStep; let previousExecutionStep: ExecutionStep;
let fetchedActionData; let fetchedData;
for await (const step of steps) { for await (const step of steps) {
if (step.type.toString() === 'trigger') { if (step.type.toString() === 'trigger') {
const appClass = (await import(`../apps/${step.appKey}`)).default; const appClass = (await import(`../apps/${step.appKey}`)).default;
const appInstance = new appClass(step.connection.data); const appInstance = new appClass(step.connection.data);
const fetchedTriggerData = await appInstance.triggers[step.key].run(); fetchedData = await appInstance.triggers[step.key].run();
previousExecutionStep = await execution previousExecutionStep = await execution
.$relatedQuery('executionSteps') .$relatedQuery('executionSteps')
.insertAndFetch({ .insertAndFetch({
stepId: step.id, stepId: step.id,
status: 'success', status: 'success',
dataOut: fetchedTriggerData, dataOut: fetchedData,
}); });
} else { } else {
const appClass = (await import(`../apps/${step.appKey}`)).default; const appClass = (await import(`../apps/${step.appKey}`)).default;
const appInstance = new appClass(step.connection.data, step.parameters); const appInstance = new appClass(step.connection.data, step.parameters);
fetchedActionData = await appInstance.actions[step.key].run(); fetchedData = await appInstance.actions[step.key].run();
previousExecutionStep = await execution previousExecutionStep = await execution
.$relatedQuery('executionSteps') .$relatedQuery('executionSteps')
@@ -50,12 +50,16 @@ class Processor {
stepId: step.id, stepId: step.id,
status: 'success', status: 'success',
dataIn: previousExecutionStep.dataOut, dataIn: previousExecutionStep.dataOut,
dataOut: fetchedActionData, dataOut: fetchedData,
}); });
} }
if (step.id === this.untilStep.id) {
return fetchedData;
}
} }
return fetchedActionData; return fetchedData;
} }
} }