@rudderstack/workflow-engine
Version:
A generic workflow execution engine
43 lines • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseStepExecutorFactory = void 0;
const common_1 = require("../../common");
const errors_1 = require("../../errors");
const factory_1 = require("./batch/factory");
const factory_2 = require("./custom/factory");
const workflow_step_1 = require("./executors/workflow_step");
const simple_1 = require("./simple");
const utils_1 = require("./utils");
const factory_3 = require("../factory");
class BaseStepExecutorFactory {
static create(step, options) {
switch (step.type) {
case common_1.StepType.Simple:
return simple_1.SimpleStepExecutorFactory.create(step, options);
case common_1.StepType.Workflow:
return this.createWorkflowStepExecutor(step, options);
case common_1.StepType.Batch:
return factory_1.BatchStepExecutorFactory.create(step, options);
case common_1.StepType.Custom:
return factory_2.CustomStepExecutorFactory.create(step, options);
default:
throw new errors_1.StepCreationError(`Unknown step type: ${step.type}`);
}
}
static async createWorkflowStepExecutor(step, options) {
try {
const newStep = await utils_1.BaseStepUtils.prepareWorkflowStep(step, options);
const simpleStepExecutors = await this.createSimpleStepExecutors(newStep, options);
return new workflow_step_1.WorkflowStepExecutor(newStep, simpleStepExecutors);
}
catch (error) {
throw new errors_1.StepCreationError(error.message, step.name, error.stepName);
}
}
static async createSimpleStepExecutors(workflowStep, options) {
const steps = workflowStep.steps;
return Promise.all(steps.map((step) => factory_3.StepExecutorFactory.create(step, options)));
}
}
exports.BaseStepExecutorFactory = BaseStepExecutorFactory;
//# sourceMappingURL=factory.js.map