|
|
@ -17,7 +17,6 @@ const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId |
|
|
const CRON_STEP_ID = triggerDefs.CRON.stepId |
|
|
const CRON_STEP_ID = triggerDefs.CRON.stepId |
|
|
const STOPPED_STATUS = { success: false, status: "STOPPED" } |
|
|
const STOPPED_STATUS = { success: false, status: "STOPPED" } |
|
|
const { cloneDeep } = require("lodash/fp") |
|
|
const { cloneDeep } = require("lodash/fp") |
|
|
const { loop } = require("svelte/internal") |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The automation orchestrator is a class responsible for executing automations. |
|
|
* The automation orchestrator is a class responsible for executing automations. |
|
|
@ -89,6 +88,7 @@ class Orchestrator { |
|
|
let stepCount = 0 |
|
|
let stepCount = 0 |
|
|
let loopStepNumber |
|
|
let loopStepNumber |
|
|
let loopSteps = [] |
|
|
let loopSteps = [] |
|
|
|
|
|
let lastLoopStep |
|
|
for (let step of automation.definition.steps) { |
|
|
for (let step of automation.definition.steps) { |
|
|
stepCount++ |
|
|
stepCount++ |
|
|
if (step.stepId === LOOP_STEP_ID) { |
|
|
if (step.stepId === LOOP_STEP_ID) { |
|
|
@ -145,13 +145,9 @@ class Orchestrator { |
|
|
}) |
|
|
}) |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
if (loopStep) { |
|
|
this._context.steps.splice(loopStepNumber, 1) |
|
|
loopSteps.push({ |
|
|
if (loopStep && loopSteps) { |
|
|
id: step.id, |
|
|
loopSteps.push(outputs) |
|
|
stepId: step.stepId, |
|
|
|
|
|
inputs: step.inputs, |
|
|
|
|
|
outputs, |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
this.updateExecutionOutput( |
|
|
this.updateExecutionOutput( |
|
|
step.id, |
|
|
step.id, |
|
|
@ -166,34 +162,30 @@ class Orchestrator { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (index === iterations - 1) { |
|
|
if (index === iterations - 1) { |
|
|
|
|
|
lastLoopStep = loopStep |
|
|
loopStep = null |
|
|
loopStep = null |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (loopSteps) { |
|
|
|
|
|
this.executionOutput.steps.splice(loopStepNumber, 0, { |
|
|
if (loopSteps && loopSteps.length) { |
|
|
id: step.id, |
|
|
let tempOutput = { success: true, outputs: loopSteps } |
|
|
stepId: step.stepId, |
|
|
this.executionOutput.steps.splice(loopStep, 0, { |
|
|
outputs: { |
|
|
id: lastLoopStep.id, |
|
|
success: true, |
|
|
stepId: lastLoopStep.stepId, |
|
|
outputs: loopSteps, |
|
|
outputs: tempOutput, |
|
|
iterations: iterations, |
|
|
inputs: step.inputs, |
|
|
}, |
|
|
|
|
|
}) |
|
|
|
|
|
this._context.steps.splice(loopStepNumber, 0, { |
|
|
|
|
|
id: step.id, |
|
|
|
|
|
stepId: step.stepId, |
|
|
|
|
|
steps: loopSteps, |
|
|
|
|
|
iterations, |
|
|
|
|
|
success: true, |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
this._context.steps.splice(loopStep, 0, tempOutput) |
|
|
loopSteps = null |
|
|
loopSteps = null |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Increment quota for automation runs
|
|
|
// Increment quota for automation runs
|
|
|
if (!env.SELF_HOSTED && !isDevAppID(this._appId)) { |
|
|
if (!env.SELF_HOSTED && !isDevAppID(this._appId)) { |
|
|
await usage.update(usage.Properties.AUTOMATION, 1) |
|
|
await usage.update(usage.Properties.AUTOMATION, 1) |
|
|
} |
|
|
} |
|
|
|
|
|
console.log(JSON.stringify(this._context, null, 2)) |
|
|
// make that we don't loop the next step if we have already been looping (loop block only has one step)
|
|
|
// make that we don't loop the next step if we have already been looping (loop block only has one step)
|
|
|
return this.executionOutput |
|
|
return this.executionOutput |
|
|
} |
|
|
} |
|
|
|