more parsing of output bindings
This commit is contained in:
parent
73151722ec
commit
006bf368bb
|
@ -98,7 +98,6 @@ const automationActions = store => ({
|
||||||
automationId: automation?._id,
|
automationId: automation?._id,
|
||||||
testData,
|
testData,
|
||||||
})
|
})
|
||||||
console.log(result)
|
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.selectedAutomation.testResults = result
|
state.selectedAutomation.testResults = result
|
||||||
return state
|
return state
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
$: testResult = $automationStore.selectedAutomation.testResults?.steps.filter(
|
$: testResult = $automationStore.selectedAutomation.testResults?.steps.filter(
|
||||||
step => (block.id ? step.id === block.id : step.stepId === block.stepId)
|
step => (block.id ? step.id === block.id : step.stepId === block.stepId)
|
||||||
)
|
)
|
||||||
$: console.log(testResult)
|
|
||||||
$: isTrigger = block.type === "TRIGGER"
|
$: isTrigger = block.type === "TRIGGER"
|
||||||
|
|
||||||
$: selected = $automationStore.selectedBlock?.id === block.id
|
$: selected = $automationStore.selectedBlock?.id === block.id
|
||||||
|
@ -57,6 +56,7 @@
|
||||||
x => x.blockToLoop === block.id
|
x => x.blockToLoop === block.id
|
||||||
)
|
)
|
||||||
$: showLooping = false
|
$: showLooping = false
|
||||||
|
|
||||||
async function deleteStep() {
|
async function deleteStep() {
|
||||||
try {
|
try {
|
||||||
automationStore.actions.deleteAutomationBlock(block)
|
automationStore.actions.deleteAutomationBlock(block)
|
||||||
|
@ -81,18 +81,6 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeLooping() {
|
|
||||||
loopingSelected = false
|
|
||||||
const loopToDelete =
|
|
||||||
$automationStore.selectedAutomation.automation.definition.steps.findIndex(
|
|
||||||
x => x.blockToLoop === block.id
|
|
||||||
)
|
|
||||||
|
|
||||||
automationStore.actions.deleteAutomationBlock(loopToDelete)
|
|
||||||
await automationStore.actions.save(
|
|
||||||
$automationStore.selectedAutomation?.automation
|
|
||||||
)
|
|
||||||
}
|
|
||||||
async function addLooping() {
|
async function addLooping() {
|
||||||
loopingSelected = true
|
loopingSelected = true
|
||||||
const loopDefinition = $automationStore.blockDefinitions.ACTION.LOOP
|
const loopDefinition = $automationStore.blockDefinitions.ACTION.LOOP
|
||||||
|
@ -103,6 +91,7 @@
|
||||||
loopDefinition
|
loopDefinition
|
||||||
)
|
)
|
||||||
loopBlock.blockToLoop = block.id
|
loopBlock.blockToLoop = block.id
|
||||||
|
block.loopBlock = loopBlock.id
|
||||||
automationStore.actions.addBlockToAutomation(loopBlock, blockIdx - 1)
|
automationStore.actions.addBlockToAutomation(loopBlock, blockIdx - 1)
|
||||||
await automationStore.actions.save(
|
await automationStore.actions.save(
|
||||||
$automationStore.selectedAutomation?.automation
|
$automationStore.selectedAutomation?.automation
|
||||||
|
@ -142,6 +131,16 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="blockTitle">
|
<div class="blockTitle">
|
||||||
|
{#if testResult && testResult[0]}
|
||||||
|
<div style="float: right;" on:click={() => resultsModal.show()}>
|
||||||
|
<StatusLight
|
||||||
|
positive={isTrigger || testResult[0].outputs?.success}
|
||||||
|
negative={!testResult[0].outputs?.success}
|
||||||
|
><Body size="XS">View response</Body></StatusLight
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
style="margin-left: 10px;"
|
style="margin-left: 10px;"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
|
@ -104,7 +104,13 @@
|
||||||
)
|
)
|
||||||
bindings = bindings.concat(
|
bindings = bindings.concat(
|
||||||
outputs.map(([name, value]) => {
|
outputs.map(([name, value]) => {
|
||||||
const runtime = idx === 0 ? `trigger.${name}` : `steps.${idx}.${name}`
|
let runtimeName =
|
||||||
|
$automationStore.selectedAutomation.automation.definition.steps.find(
|
||||||
|
x => block.id === x.blockToLoop
|
||||||
|
)
|
||||||
|
? `loop.${name}`
|
||||||
|
: `steps.${idx}.${name}`
|
||||||
|
const runtime = idx === 0 ? `trigger.${name}` : runtimeName
|
||||||
return {
|
return {
|
||||||
label: runtime,
|
label: runtime,
|
||||||
type: value.type,
|
type: value.type,
|
||||||
|
@ -115,6 +121,7 @@
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ exports.definition = {
|
||||||
},
|
},
|
||||||
success: {
|
success: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
description: "Whether the message sent successfully",
|
description: "Whether the message loop was successfully",
|
||||||
},
|
},
|
||||||
iterations: {
|
iterations: {
|
||||||
type: "number",
|
type: "number",
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue