|
|
|
@ -117,15 +117,17 @@ class Orchestrator { |
|
|
|
if (loopStep) { |
|
|
|
input = await processObject(loopStep.inputs, this._context) |
|
|
|
} |
|
|
|
let iterations = loopStep ? input.binding.length : 1 |
|
|
|
let iterations = loopStep |
|
|
|
? Array.isArray(input.binding) |
|
|
|
? input.binding.length |
|
|
|
: automationUtils.stringSplit(input.binding).length |
|
|
|
: 1 |
|
|
|
let iterationCount = 0 |
|
|
|
for (let index = 0; index < iterations; index++) { |
|
|
|
let originalStepInput = cloneDeep(step.inputs) |
|
|
|
|
|
|
|
// Handle if the user has set a max iteration count or if it reaches the max limit set by us
|
|
|
|
if (loopStep) { |
|
|
|
// lets first of all handle the input
|
|
|
|
// if the input is array then use it, if it is a string then split it on every new line
|
|
|
|
let newInput = await processObject( |
|
|
|
loopStep.inputs, |
|
|
|
cloneDeep(this._context) |
|
|
|
@ -134,9 +136,6 @@ class Orchestrator { |
|
|
|
newInput, |
|
|
|
loopStep.schema.inputs |
|
|
|
) |
|
|
|
this._context.steps[loopStepNumber] = { |
|
|
|
currentItem: newInput.binding[index], |
|
|
|
} |
|
|
|
|
|
|
|
let tempOutput = { items: loopSteps, iterations: iterationCount } |
|
|
|
if ( |
|
|
|
@ -154,6 +153,20 @@ class Orchestrator { |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
let item |
|
|
|
if ( |
|
|
|
typeof loopStep.inputs.binding === "string" && |
|
|
|
loopStep.inputs.option === "String" |
|
|
|
) { |
|
|
|
item = automationUtils.stringSplit(newInput.binding) |
|
|
|
} else { |
|
|
|
item = loopStep.inputs.binding |
|
|
|
} |
|
|
|
|
|
|
|
this._context.steps[loopStepNumber] = { |
|
|
|
currentItem: item[index], |
|
|
|
} |
|
|
|
|
|
|
|
// The "Loop" binding in the front end is "fake", so replace it here so the context can understand it
|
|
|
|
// Pretty hacky because we need to account for the row object
|
|
|
|
for (let [key, value] of Object.entries(originalStepInput)) { |
|
|
|
|