UNPKG

@rudderstack/workflow-engine

Version:
36 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JsonTemplateStepExecutor = void 0; const json_template_engine_1 = require("@rudderstack/json-template-engine"); const base_1 = require("../../../executors/base"); class JsonTemplateStepExecutor extends base_1.BaseStepExecutor { static parse(template, mappings, bindings) { if (mappings) { try { const mappingPaths = JSON.parse(template); return json_template_engine_1.JsonTemplateEngine.parse(mappingPaths, { defaultPathType: json_template_engine_1.PathType.JSON }); } catch (e) { // parse as template } } return json_template_engine_1.JsonTemplateEngine.parse(template, { defaultPathType: json_template_engine_1.PathType.SIMPLE, compileTimeBindings: bindings, }); } constructor(step, template, bindings) { super(step); const expression = JsonTemplateStepExecutor.parse(template, step.mappings, bindings); this.templateEngine = json_template_engine_1.JsonTemplateEngine.create(expression, { compileTimeBindings: bindings, defaultPathType: json_template_engine_1.PathType.SIMPLE, }); } async execute(input, executionBindings) { const output = await this.templateEngine.evaluate(input, executionBindings); return { output }; } } exports.JsonTemplateStepExecutor = JsonTemplateStepExecutor; //# sourceMappingURL=jsontemplate.js.map