|
|
|
@ -30,6 +30,11 @@ class Orchestrator { |
|
|
|
// create an emitter which has the chain count for this automation run in it, so it can block
|
|
|
|
// excessive chaining if required
|
|
|
|
this._emitter = new AutomationEmitter(this._chainCount + 1) |
|
|
|
this.executionOutput = { trigger: {}, steps: [] } |
|
|
|
// setup the execution output
|
|
|
|
const triggerStepId = automation.definition.trigger.stepId |
|
|
|
const triggerId = automation.definition.trigger.id |
|
|
|
this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput) |
|
|
|
} |
|
|
|
|
|
|
|
async getStepFunctionality(type, stepId) { |
|
|
|
@ -55,6 +60,15 @@ class Orchestrator { |
|
|
|
return this._app |
|
|
|
} |
|
|
|
|
|
|
|
updateExecutionOutput(id, stepId, inputs, outputs) { |
|
|
|
const stepObj = { id, stepId, inputs, outputs } |
|
|
|
// first entry is always the trigger (constructor)
|
|
|
|
if (this.executionOutput.steps.length === 0) { |
|
|
|
this.executionOutput.trigger = stepObj |
|
|
|
} |
|
|
|
this.executionOutput.steps.push(stepObj) |
|
|
|
} |
|
|
|
|
|
|
|
async execute() { |
|
|
|
let automation = this._automation |
|
|
|
const app = await this.getApp() |
|
|
|
@ -81,12 +95,13 @@ class Orchestrator { |
|
|
|
break |
|
|
|
} |
|
|
|
this._context.steps.push(outputs) |
|
|
|
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs) |
|
|
|
} catch (err) { |
|
|
|
console.error(`Automation error - ${step.stepId} - ${err}`) |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
return this._context |
|
|
|
return this.executionOutput |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|