From db9bc1f373ad006a80905959a732767fcb17f8b9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 25 Jul 2024 16:08:51 +0200 Subject: [PATCH] Fix types --- packages/server/src/automations/triggers.ts | 7 +++++-- packages/server/src/sdk/app/rowActions.ts | 6 ++++-- packages/shared-core/src/sdk/documents/automations.ts | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/server/src/automations/triggers.ts b/packages/server/src/automations/triggers.ts index e8f30830a0..87fb1a957b 100644 --- a/packages/server/src/automations/triggers.ts +++ b/packages/server/src/automations/triggers.ts @@ -20,7 +20,7 @@ import { AutomationStatus, } from "@budibase/types" import { executeInThread } from "../threads/automation" -import { dataFilters } from "@budibase/shared-core" +import { dataFilters, sdk } from "@budibase/shared-core" export const TRIGGER_DEFINITIONS = definitions const JOB_OPTS = { @@ -127,8 +127,9 @@ export async function externalTrigger( if (automation.disabled) { throw new Error("Automation is disabled") } + if ( - automation.definition?.trigger?.stepId === definitions.APP.stepId && + sdk.automations.isAppAction(automation) && !(await checkTestFlag(automation._id!)) ) { // values are likely to be submitted as strings, so we shall convert to correct type @@ -138,6 +139,8 @@ export async function externalTrigger( coercedFields[key] = coerce(params.fields[key], fields[key]) } params.fields = coercedFields + } else if (sdk.automations.isRowAction(automation)) { + params = { ...params, ...params.fields } } const data: AutomationData = { automation, event: params } diff --git a/packages/server/src/sdk/app/rowActions.ts b/packages/server/src/sdk/app/rowActions.ts index ba5007f68f..36d2ed7b92 100644 --- a/packages/server/src/sdk/app/rowActions.ts +++ b/packages/server/src/sdk/app/rowActions.ts @@ -163,8 +163,10 @@ export async function run(tableId: any, rowActionId: any, rowId: string) { const row = await sdk.rows.find(tableId, rowId) await triggers.externalTrigger(automation, { - row, - table, + fields: { + row, + table, + }, appId: context.getAppId(), }) } diff --git a/packages/shared-core/src/sdk/documents/automations.ts b/packages/shared-core/src/sdk/documents/automations.ts index 93e08c86e0..3663f7ae46 100644 --- a/packages/shared-core/src/sdk/documents/automations.ts +++ b/packages/shared-core/src/sdk/documents/automations.ts @@ -5,3 +5,9 @@ export function isRowAction(automation: Automation) { automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION return result } + +export function isAppAction(automation: Automation) { + const result = + automation.definition.trigger.stepId === AutomationTriggerStepId.APP + return result +}