@rudderstack/workflow-engine
Version:
A generic workflow execution engine
30 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomStepExecutorFactory = void 0;
const errors_1 = require("../../../errors");
const step_executor_1 = require("./step_executor");
class CustomStepExecutorFactory {
static async create(step, options) {
const executor = await this.getExecutor(step, options);
return new step_executor_1.BaseCustomStepExecutor(step, executor);
}
static async getExecutor(step, options) {
if (step.provider) {
return this.getExecutorFromProvider(step, options);
}
const executor = options.currentBindings[step.executor];
if (typeof executor?.execute !== 'function') {
throw new errors_1.StepCreationError(`Invalid custom step executor: ${step.executor}`, step.name);
}
return executor;
}
static getExecutorFromProvider(step, options) {
const provider = options.currentBindings[step.provider];
if (typeof provider?.provide !== 'function') {
throw new errors_1.StepCreationError(`Invalid custom step provider: ${step.provider}`, step.name);
}
return provider.provide(step);
}
}
exports.CustomStepExecutorFactory = CustomStepExecutorFactory;
//# sourceMappingURL=factory.js.map