some pr comments

This commit is contained in:
Peter Clement 2024-09-13 12:25:39 +01:00
parent c980742081
commit 7e767e4089
4 changed files with 30 additions and 20 deletions

View File

@ -255,12 +255,15 @@ describe("Loop automations", () => {
option: LoopStepType.ARRAY, option: LoopStepType.ARRAY,
binding: [1, 2, 3], binding: [1, 2, 3],
}, },
"FirstLoopStep" { stepName: "FirstLoopStep" }
)
.serverLog(
{ text: "Message {{loop.currentItem}}" },
{ stepName: "FirstLoopLog" }
) )
.serverLog({ text: "Message {{loop.currentItem}}" }, "FirstLoopLog")
.serverLog( .serverLog(
{ text: "{{steps.FirstLoopLog.iterations}}" }, { text: "{{steps.FirstLoopLog.iterations}}" },
"FirstLoopIterationLog" { stepName: "FirstLoopIterationLog" }
) )
.run() .run()

View File

@ -217,7 +217,7 @@ describe("Automation Scenarios", () => {
{ {
tableId: table._id!, tableId: table._id!,
}, },
"InitialQueryStep" { stepName: "InitialQueryStep" }
) )
.deleteRow({ .deleteRow({
tableId: table._id!, tableId: table._id!,

View File

@ -105,74 +105,80 @@ class BaseStepBuilder {
} }
// STEPS // STEPS
createRow(inputs: CreateRowStepInputs, stepName?: string): this { createRow(inputs: CreateRowStepInputs, opts?: { stepName?: string }): this {
return this.step( return this.step(
AutomationActionStepId.CREATE_ROW, AutomationActionStepId.CREATE_ROW,
BUILTIN_ACTION_DEFINITIONS.CREATE_ROW, BUILTIN_ACTION_DEFINITIONS.CREATE_ROW,
inputs, inputs,
stepName opts?.stepName
) )
} }
updateRow(inputs: UpdateRowStepInputs, stepName?: string): this { updateRow(inputs: UpdateRowStepInputs, opts?: { stepName?: string }): this {
return this.step( return this.step(
AutomationActionStepId.UPDATE_ROW, AutomationActionStepId.UPDATE_ROW,
BUILTIN_ACTION_DEFINITIONS.UPDATE_ROW, BUILTIN_ACTION_DEFINITIONS.UPDATE_ROW,
inputs, inputs,
stepName opts?.stepName
) )
} }
deleteRow(inputs: DeleteRowStepInputs, stepName?: string): this { deleteRow(inputs: DeleteRowStepInputs, opts?: { stepName?: string }): this {
return this.step( return this.step(
AutomationActionStepId.DELETE_ROW, AutomationActionStepId.DELETE_ROW,
BUILTIN_ACTION_DEFINITIONS.DELETE_ROW, BUILTIN_ACTION_DEFINITIONS.DELETE_ROW,
inputs, inputs,
stepName opts?.stepName
) )
} }
sendSmtpEmail(inputs: SmtpEmailStepInputs, stepName?: string): this { sendSmtpEmail(
inputs: SmtpEmailStepInputs,
opts?: { stepName?: string }
): this {
return this.step( return this.step(
AutomationActionStepId.SEND_EMAIL_SMTP, AutomationActionStepId.SEND_EMAIL_SMTP,
BUILTIN_ACTION_DEFINITIONS.SEND_EMAIL_SMTP, BUILTIN_ACTION_DEFINITIONS.SEND_EMAIL_SMTP,
inputs, inputs,
stepName opts?.stepName
) )
} }
executeQuery(inputs: ExecuteQueryStepInputs, stepName?: string): this { executeQuery(
inputs: ExecuteQueryStepInputs,
opts?: { stepName?: string }
): this {
return this.step( return this.step(
AutomationActionStepId.EXECUTE_QUERY, AutomationActionStepId.EXECUTE_QUERY,
BUILTIN_ACTION_DEFINITIONS.EXECUTE_QUERY, BUILTIN_ACTION_DEFINITIONS.EXECUTE_QUERY,
inputs, inputs,
stepName opts?.stepName
) )
} }
queryRows(inputs: QueryRowsStepInputs, stepName?: string): this { queryRows(inputs: QueryRowsStepInputs, opts?: { stepName?: string }): this {
return this.step( return this.step(
AutomationActionStepId.QUERY_ROWS, AutomationActionStepId.QUERY_ROWS,
BUILTIN_ACTION_DEFINITIONS.QUERY_ROWS, BUILTIN_ACTION_DEFINITIONS.QUERY_ROWS,
inputs, inputs,
stepName opts?.stepName
) )
} }
loop(inputs: LoopStepInputs, stepName?: string): this { loop(inputs: LoopStepInputs, opts?: { stepName?: string }): this {
return this.step( return this.step(
AutomationActionStepId.LOOP, AutomationActionStepId.LOOP,
BUILTIN_ACTION_DEFINITIONS.LOOP, BUILTIN_ACTION_DEFINITIONS.LOOP,
inputs, inputs,
stepName opts?.stepName
) )
} }
serverLog(input: ServerLogStepInputs, stepName?: string): this { serverLog(input: ServerLogStepInputs, opts?: { stepName?: string }): this {
return this.step( return this.step(
AutomationActionStepId.SERVER_LOG, AutomationActionStepId.SERVER_LOG,
BUILTIN_ACTION_DEFINITIONS.SERVER_LOG, BUILTIN_ACTION_DEFINITIONS.SERVER_LOG,
input, input,
stepName opts?.stepName
) )
} }
} }

View File

@ -124,6 +124,7 @@ export interface Automation extends Document {
definition: { definition: {
steps: AutomationStep[] steps: AutomationStep[]
trigger: AutomationTrigger trigger: AutomationTrigger
// stepNames is used to lookup step names from their correspnding step ID.
stepNames?: Record<string, string> stepNames?: Record<string, string>
} }
screenId?: string screenId?: string