UNPKG

@rudderstack/workflow-engine

Version:
28 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConditionalStepExecutor = void 0; const composable_1 = require("./composable"); class ConditionalStepExecutor extends composable_1.ComposableStepExecutor { constructor(conditionExecutor, thenExecutor, elseExecutor) { super(thenExecutor); this.conditionExecutor = conditionExecutor; this.thenExecutor = thenExecutor; this.elseExecutor = elseExecutor; } async shouldExecuteStep(input, executionBindings) { const result = await this.conditionExecutor.execute(input, executionBindings); return result.output; } async execute(input, executionBindings) { const shouldExecuteStep = await this.shouldExecuteStep(input, executionBindings); if (shouldExecuteStep) { return this.thenExecutor.execute(input, executionBindings); } if (this.elseExecutor) { return this.elseExecutor.execute(input, executionBindings); } return { skipped: true }; } } exports.ConditionalStepExecutor = ConditionalStepExecutor; //# sourceMappingURL=conditional.js.map