Fix types

This commit is contained in:
Adria Navarro 2024-07-25 16:08:51 +02:00
parent beaabdd64a
commit db9bc1f373
3 changed files with 15 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import {
AutomationStatus, AutomationStatus,
} from "@budibase/types" } from "@budibase/types"
import { executeInThread } from "../threads/automation" import { executeInThread } from "../threads/automation"
import { dataFilters } from "@budibase/shared-core" import { dataFilters, sdk } from "@budibase/shared-core"
export const TRIGGER_DEFINITIONS = definitions export const TRIGGER_DEFINITIONS = definitions
const JOB_OPTS = { const JOB_OPTS = {
@ -127,8 +127,9 @@ export async function externalTrigger(
if (automation.disabled) { if (automation.disabled) {
throw new Error("Automation is disabled") throw new Error("Automation is disabled")
} }
if ( if (
automation.definition?.trigger?.stepId === definitions.APP.stepId && sdk.automations.isAppAction(automation) &&
!(await checkTestFlag(automation._id!)) !(await checkTestFlag(automation._id!))
) { ) {
// values are likely to be submitted as strings, so we shall convert to correct type // 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]) coercedFields[key] = coerce(params.fields[key], fields[key])
} }
params.fields = coercedFields params.fields = coercedFields
} else if (sdk.automations.isRowAction(automation)) {
params = { ...params, ...params.fields }
} }
const data: AutomationData = { automation, event: params } const data: AutomationData = { automation, event: params }

View File

@ -163,8 +163,10 @@ export async function run(tableId: any, rowActionId: any, rowId: string) {
const row = await sdk.rows.find(tableId, rowId) const row = await sdk.rows.find(tableId, rowId)
await triggers.externalTrigger(automation, { await triggers.externalTrigger(automation, {
row, fields: {
table, row,
table,
},
appId: context.getAppId(), appId: context.getAppId(),
}) })
} }

View File

@ -5,3 +5,9 @@ export function isRowAction(automation: Automation) {
automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION
return result return result
} }
export function isAppAction(automation: Automation) {
const result =
automation.definition.trigger.stepId === AutomationTriggerStepId.APP
return result
}