Merge pull request #14238 from Budibase/BUDI-8441/expose-rowaction-definition

Expose row action definition
This commit is contained in:
Adria Navarro 2024-07-25 11:12:53 +02:00 committed by GitHub
commit dad27a3399
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 25 deletions

View File

@ -1,15 +1,24 @@
import {
AutomationTriggerSchema,
AutomationTriggerStepId,
} from "@budibase/types"
import * as app from "./app"
import * as cron from "./cron"
import * as rowDeleted from "./rowDeleted"
import * as rowSaved from "./rowSaved"
import * as rowUpdated from "./rowUpdated"
import * as webhook from "./webhook"
import * as rowAction from "./rowAction"
export const definitions = {
export const definitions: Record<
keyof typeof AutomationTriggerStepId,
AutomationTriggerSchema
> = {
ROW_SAVED: rowSaved.definition,
ROW_UPDATED: rowUpdated.definition,
ROW_DELETED: rowDeleted.definition,
WEBHOOK: webhook.definition,
APP: app.definition,
CRON: cron.definition,
ROW_ACTION: rowAction.definition,
}

View File

@ -0,0 +1,35 @@
import {
AutomationCustomIOType,
AutomationIOType,
AutomationStepType,
AutomationTriggerSchema,
AutomationTriggerStepId,
AutomationEventType,
} from "@budibase/types"
export const definition: AutomationTriggerSchema = {
type: AutomationStepType.TRIGGER,
tagline:
"Row action triggered in {{inputs.enriched.table.name}} by {{inputs.enriched.row._id}}",
name: "Row Action",
description: "TODO description",
icon: "Workflow",
stepId: AutomationTriggerStepId.ROW_ACTION,
inputs: {},
schema: {
inputs: {
properties: {
tableId: {
type: AutomationIOType.STRING,
customType: AutomationCustomIOType.TABLE,
title: "Table",
readonly: true,
},
},
required: ["tableId"],
},
outputs: { properties: {} },
},
event: AutomationEventType.ROW_SAVE,
}

View File

@ -2,15 +2,12 @@ import { context, HTTPError, utils } from "@budibase/backend-core"
import { generateRowActionsID } from "../../db/utils"
import {
AutomationCustomIOType,
AutomationIOType,
AutomationStepType,
AutomationTriggerStepId,
SEPARATOR,
TableRowActions,
VirtualDocumentType,
} from "@budibase/types"
import automations from "./automations"
import { definitions as TRIGGER_DEFINITIONS } from "../../automations/triggerInfo"
function ensureUniqueAndThrow(
doc: TableRowActions,
@ -60,31 +57,12 @@ export async function create(tableId: string, rowAction: { name: string }) {
appId,
definition: {
trigger: {
type: AutomationStepType.TRIGGER,
id: "trigger",
tagline: "TODO tagline",
name: "Row Action",
description: "TODO description",
icon: "Workflow",
stepId: AutomationTriggerStepId.ROW_ACTION,
...TRIGGER_DEFINITIONS.ROW_ACTION,
inputs: {
tableId,
rowActionId: newRowActionId,
},
schema: {
inputs: {
properties: {
tableId: {
type: AutomationIOType.STRING,
customType: AutomationCustomIOType.TABLE,
title: "Table",
readonly: true,
},
},
required: ["tableId"],
},
outputs: { properties: {} },
},
},
steps: [],
},

View File

@ -194,6 +194,7 @@ export interface AutomationStep extends AutomationStepSchema {
}
export interface AutomationTriggerSchema extends AutomationStepSchema {
type: AutomationStepType.TRIGGER
event?: string
cronJobId?: string
}