pr comments
This commit is contained in:
parent
5d31976835
commit
f00593ff26
|
@ -30,7 +30,7 @@ describe("Branching automations", () => {
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.serverLog(
|
.serverLog(
|
||||||
{ text: "Starting automation" },
|
{ text: "Starting automation" },
|
||||||
{ stepName: "FirstLog", id: firstLogId }
|
{ stepName: "FirstLog", stepId: firstLogId }
|
||||||
)
|
)
|
||||||
.branch({
|
.branch({
|
||||||
topLevelBranch1: {
|
topLevelBranch1: {
|
||||||
|
@ -38,14 +38,14 @@ describe("Branching automations", () => {
|
||||||
stepBuilder
|
stepBuilder
|
||||||
.serverLog(
|
.serverLog(
|
||||||
{ text: "Branch 1" },
|
{ text: "Branch 1" },
|
||||||
{ id: "66666666-6666-6666-6666-666666666666" }
|
{ stepId: "66666666-6666-6666-6666-666666666666" }
|
||||||
)
|
)
|
||||||
.branch({
|
.branch({
|
||||||
branch1: {
|
branch1: {
|
||||||
steps: stepBuilder =>
|
steps: stepBuilder =>
|
||||||
stepBuilder.serverLog(
|
stepBuilder.serverLog(
|
||||||
{ text: "Branch 1.1" },
|
{ text: "Branch 1.1" },
|
||||||
{ id: branch1LogId }
|
{ stepId: branch1LogId }
|
||||||
),
|
),
|
||||||
condition: {
|
condition: {
|
||||||
equal: { [`{{ steps.${firstLogId}.success }}`]: true },
|
equal: { [`{{ steps.${firstLogId}.success }}`]: true },
|
||||||
|
@ -55,7 +55,7 @@ describe("Branching automations", () => {
|
||||||
steps: stepBuilder =>
|
steps: stepBuilder =>
|
||||||
stepBuilder.serverLog(
|
stepBuilder.serverLog(
|
||||||
{ text: "Branch 1.2" },
|
{ text: "Branch 1.2" },
|
||||||
{ id: branch2LogId }
|
{ stepId: branch2LogId }
|
||||||
),
|
),
|
||||||
condition: {
|
condition: {
|
||||||
equal: { [`{{ steps.${firstLogId}.success }}`]: false },
|
equal: { [`{{ steps.${firstLogId}.success }}`]: false },
|
||||||
|
@ -68,7 +68,7 @@ describe("Branching automations", () => {
|
||||||
},
|
},
|
||||||
topLevelBranch2: {
|
topLevelBranch2: {
|
||||||
steps: stepBuilder =>
|
steps: stepBuilder =>
|
||||||
stepBuilder.serverLog({ text: "Branch 2" }, { id: branch2Id }),
|
stepBuilder.serverLog({ text: "Branch 2" }, { stepId: branch2Id }),
|
||||||
condition: {
|
condition: {
|
||||||
equal: { [`{{ steps.${firstLogId}.success }}`]: false },
|
equal: { [`{{ steps.${firstLogId}.success }}`]: false },
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,9 +64,9 @@ class BaseStepBuilder {
|
||||||
stepId: TStep,
|
stepId: TStep,
|
||||||
stepSchema: Omit<AutomationStep, "id" | "stepId" | "inputs">,
|
stepSchema: Omit<AutomationStep, "id" | "stepId" | "inputs">,
|
||||||
inputs: AutomationStepInputs<TStep>,
|
inputs: AutomationStepInputs<TStep>,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
const id = opts?.id || uuidv4()
|
const id = opts?.stepId || uuidv4()
|
||||||
this.steps.push({
|
this.steps.push({
|
||||||
...stepSchema,
|
...stepSchema,
|
||||||
inputs: inputs as any,
|
inputs: inputs as any,
|
||||||
|
@ -107,7 +107,7 @@ class BaseStepBuilder {
|
||||||
// STEPS
|
// STEPS
|
||||||
createRow(
|
createRow(
|
||||||
inputs: CreateRowStepInputs,
|
inputs: CreateRowStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.CREATE_ROW,
|
AutomationActionStepId.CREATE_ROW,
|
||||||
|
@ -119,7 +119,7 @@ class BaseStepBuilder {
|
||||||
|
|
||||||
updateRow(
|
updateRow(
|
||||||
inputs: UpdateRowStepInputs,
|
inputs: UpdateRowStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.UPDATE_ROW,
|
AutomationActionStepId.UPDATE_ROW,
|
||||||
|
@ -131,7 +131,7 @@ class BaseStepBuilder {
|
||||||
|
|
||||||
deleteRow(
|
deleteRow(
|
||||||
inputs: DeleteRowStepInputs,
|
inputs: DeleteRowStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.DELETE_ROW,
|
AutomationActionStepId.DELETE_ROW,
|
||||||
|
@ -143,7 +143,7 @@ class BaseStepBuilder {
|
||||||
|
|
||||||
sendSmtpEmail(
|
sendSmtpEmail(
|
||||||
inputs: SmtpEmailStepInputs,
|
inputs: SmtpEmailStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.SEND_EMAIL_SMTP,
|
AutomationActionStepId.SEND_EMAIL_SMTP,
|
||||||
|
@ -155,7 +155,7 @@ class BaseStepBuilder {
|
||||||
|
|
||||||
executeQuery(
|
executeQuery(
|
||||||
inputs: ExecuteQueryStepInputs,
|
inputs: ExecuteQueryStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.EXECUTE_QUERY,
|
AutomationActionStepId.EXECUTE_QUERY,
|
||||||
|
@ -167,7 +167,7 @@ class BaseStepBuilder {
|
||||||
|
|
||||||
queryRows(
|
queryRows(
|
||||||
inputs: QueryRowsStepInputs,
|
inputs: QueryRowsStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.QUERY_ROWS,
|
AutomationActionStepId.QUERY_ROWS,
|
||||||
|
@ -178,7 +178,7 @@ class BaseStepBuilder {
|
||||||
}
|
}
|
||||||
loop(
|
loop(
|
||||||
inputs: LoopStepInputs,
|
inputs: LoopStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.LOOP,
|
AutomationActionStepId.LOOP,
|
||||||
|
@ -190,7 +190,7 @@ class BaseStepBuilder {
|
||||||
|
|
||||||
serverLog(
|
serverLog(
|
||||||
input: ServerLogStepInputs,
|
input: ServerLogStepInputs,
|
||||||
opts?: { stepName?: string; id?: string }
|
opts?: { stepName?: string; stepId?: string }
|
||||||
): this {
|
): this {
|
||||||
return this.step(
|
return this.step(
|
||||||
AutomationActionStepId.SERVER_LOG,
|
AutomationActionStepId.SERVER_LOG,
|
||||||
|
|
|
@ -15,8 +15,8 @@ export interface TriggerOutput {
|
||||||
|
|
||||||
export interface AutomationContext extends AutomationResults {
|
export interface AutomationContext extends AutomationResults {
|
||||||
steps: any[]
|
steps: any[]
|
||||||
stepsById?: Record<string, any>
|
stepsById: Record<string, any>
|
||||||
stepsByName?: Record<string, any>
|
stepsByName: Record<string, any>
|
||||||
env?: Record<string, string>
|
env?: Record<string, string>
|
||||||
trigger: any
|
trigger: any
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Orchestrator {
|
||||||
private job: Job
|
private job: Job
|
||||||
private loopStepOutputs: LoopStep[]
|
private loopStepOutputs: LoopStep[]
|
||||||
private stopped: boolean
|
private stopped: boolean
|
||||||
private executionOutput: AutomationContext
|
private executionOutput: Omit<AutomationContext, "stepsByName" | "stepsById">
|
||||||
|
|
||||||
constructor(job: AutomationJob) {
|
constructor(job: AutomationJob) {
|
||||||
let automation = job.data.automation
|
let automation = job.data.automation
|
||||||
|
@ -458,9 +458,9 @@ class Orchestrator {
|
||||||
inputs: steps[stepToLoopIndex].inputs,
|
inputs: steps[stepToLoopIndex].inputs,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.context.stepsById![steps[stepToLoopIndex].id] = tempOutput
|
this.context.stepsById[steps[stepToLoopIndex].id] = tempOutput
|
||||||
const stepName = steps[stepToLoopIndex].name || steps[stepToLoopIndex].id
|
const stepName = steps[stepToLoopIndex].name || steps[stepToLoopIndex].id
|
||||||
this.context.stepsByName![stepName] = tempOutput
|
this.context.stepsByName[stepName] = tempOutput
|
||||||
this.context.steps[this.context.steps.length] = tempOutput
|
this.context.steps[this.context.steps.length] = tempOutput
|
||||||
this.context.steps = this.context.steps.filter(
|
this.context.steps = this.context.steps.filter(
|
||||||
item => !item.hasOwnProperty.call(item, "currentItem")
|
item => !item.hasOwnProperty.call(item, "currentItem")
|
||||||
|
|
Loading…
Reference in New Issue