|
|
@ -3,6 +3,7 @@ const actions = require("./actions") |
|
|
const logic = require("./logic") |
|
|
const logic = require("./logic") |
|
|
const automationUtils = require("./automationUtils") |
|
|
const automationUtils = require("./automationUtils") |
|
|
const AutomationEmitter = require("../events/AutomationEmitter") |
|
|
const AutomationEmitter = require("../events/AutomationEmitter") |
|
|
|
|
|
const { recurseMustache } = require("../utilities/mustache") |
|
|
|
|
|
|
|
|
handlebars.registerHelper("object", value => { |
|
|
handlebars.registerHelper("object", value => { |
|
|
return new handlebars.SafeString(JSON.stringify(value)) |
|
|
return new handlebars.SafeString(JSON.stringify(value)) |
|
|
@ -10,22 +11,6 @@ handlebars.registerHelper("object", value => { |
|
|
|
|
|
|
|
|
const FILTER_STEP_ID = logic.BUILTIN_DEFINITIONS.FILTER.stepId |
|
|
const FILTER_STEP_ID = logic.BUILTIN_DEFINITIONS.FILTER.stepId |
|
|
|
|
|
|
|
|
function recurseMustache(inputs, context) { |
|
|
|
|
|
for (let key of Object.keys(inputs)) { |
|
|
|
|
|
let val = inputs[key] |
|
|
|
|
|
if (typeof val === "string") { |
|
|
|
|
|
val = automationUtils.cleanMustache(inputs[key]) |
|
|
|
|
|
const template = handlebars.compile(val) |
|
|
|
|
|
inputs[key] = template(context) |
|
|
|
|
|
} |
|
|
|
|
|
// this covers objects and arrays
|
|
|
|
|
|
else if (typeof val === "object") { |
|
|
|
|
|
inputs[key] = recurseMustache(inputs[key], context) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return inputs |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The automation orchestrator is a class responsible for executing automations. |
|
|
* The automation orchestrator is a class responsible for executing automations. |
|
|
* It handles the context of the automation and makes sure each step gets the correct |
|
|
* It handles the context of the automation and makes sure each step gets the correct |
|
|
|