UNPKG

@rudderstack/workflow-engine

Version:
41 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WorkflowStepExecutor = void 0; const types_1 = require("../../../common/types"); const errors_1 = require("../../../errors"); const base_1 = require("./base"); class WorkflowStepExecutor extends base_1.BaseStepExecutor { constructor(step, stepExecutors) { super(step); this.stepExecutors = stepExecutors; } async executeChildStep(childExector, input, executionBindings) { try { return await childExector.execute(input, executionBindings); } catch (error) { throw errors_1.ErrorUtils.createStepExecutionError(error, this.getStepName(), childExector.getStepName()); } } async execute(input, executionBindings) { const workflowStepName = this.getStepName(); const newExecutionBindings = executionBindings; newExecutionBindings.outputs[workflowStepName] = {}; let finalOutput; for (const childExecutor of this.stepExecutors) { const childStep = childExecutor.getStep(); // eslint-disable-next-line no-await-in-loop const { skipped, output } = await this.executeChildStep(childExecutor, input, executionBindings); if (!skipped) { newExecutionBindings.outputs[workflowStepName][childExecutor.getStepName()] = output; finalOutput = output; if (childStep.onComplete === types_1.StepExitAction.Return) { break; } } } return { outputs: executionBindings.outputs[workflowStepName], output: finalOutput }; } } exports.WorkflowStepExecutor = WorkflowStepExecutor; //# sourceMappingURL=workflow_step.js.map