Merge pull request #14238 from Budibase/BUDI-8441/expose-rowaction-definition
Expose row action definition
This commit is contained in:
commit
dad27a3399
|
@ -1,15 +1,24 @@
|
||||||
|
import {
|
||||||
|
AutomationTriggerSchema,
|
||||||
|
AutomationTriggerStepId,
|
||||||
|
} from "@budibase/types"
|
||||||
import * as app from "./app"
|
import * as app from "./app"
|
||||||
import * as cron from "./cron"
|
import * as cron from "./cron"
|
||||||
import * as rowDeleted from "./rowDeleted"
|
import * as rowDeleted from "./rowDeleted"
|
||||||
import * as rowSaved from "./rowSaved"
|
import * as rowSaved from "./rowSaved"
|
||||||
import * as rowUpdated from "./rowUpdated"
|
import * as rowUpdated from "./rowUpdated"
|
||||||
import * as webhook from "./webhook"
|
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_SAVED: rowSaved.definition,
|
||||||
ROW_UPDATED: rowUpdated.definition,
|
ROW_UPDATED: rowUpdated.definition,
|
||||||
ROW_DELETED: rowDeleted.definition,
|
ROW_DELETED: rowDeleted.definition,
|
||||||
WEBHOOK: webhook.definition,
|
WEBHOOK: webhook.definition,
|
||||||
APP: app.definition,
|
APP: app.definition,
|
||||||
CRON: cron.definition,
|
CRON: cron.definition,
|
||||||
|
ROW_ACTION: rowAction.definition,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
}
|
|
@ -2,15 +2,12 @@ import { context, HTTPError, utils } from "@budibase/backend-core"
|
||||||
|
|
||||||
import { generateRowActionsID } from "../../db/utils"
|
import { generateRowActionsID } from "../../db/utils"
|
||||||
import {
|
import {
|
||||||
AutomationCustomIOType,
|
|
||||||
AutomationIOType,
|
|
||||||
AutomationStepType,
|
|
||||||
AutomationTriggerStepId,
|
|
||||||
SEPARATOR,
|
SEPARATOR,
|
||||||
TableRowActions,
|
TableRowActions,
|
||||||
VirtualDocumentType,
|
VirtualDocumentType,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import automations from "./automations"
|
import automations from "./automations"
|
||||||
|
import { definitions as TRIGGER_DEFINITIONS } from "../../automations/triggerInfo"
|
||||||
|
|
||||||
function ensureUniqueAndThrow(
|
function ensureUniqueAndThrow(
|
||||||
doc: TableRowActions,
|
doc: TableRowActions,
|
||||||
|
@ -60,31 +57,12 @@ export async function create(tableId: string, rowAction: { name: string }) {
|
||||||
appId,
|
appId,
|
||||||
definition: {
|
definition: {
|
||||||
trigger: {
|
trigger: {
|
||||||
type: AutomationStepType.TRIGGER,
|
|
||||||
id: "trigger",
|
id: "trigger",
|
||||||
tagline: "TODO tagline",
|
...TRIGGER_DEFINITIONS.ROW_ACTION,
|
||||||
name: "Row Action",
|
|
||||||
description: "TODO description",
|
|
||||||
icon: "Workflow",
|
|
||||||
stepId: AutomationTriggerStepId.ROW_ACTION,
|
|
||||||
inputs: {
|
inputs: {
|
||||||
tableId,
|
tableId,
|
||||||
rowActionId: newRowActionId,
|
rowActionId: newRowActionId,
|
||||||
},
|
},
|
||||||
schema: {
|
|
||||||
inputs: {
|
|
||||||
properties: {
|
|
||||||
tableId: {
|
|
||||||
type: AutomationIOType.STRING,
|
|
||||||
customType: AutomationCustomIOType.TABLE,
|
|
||||||
title: "Table",
|
|
||||||
readonly: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ["tableId"],
|
|
||||||
},
|
|
||||||
outputs: { properties: {} },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
steps: [],
|
steps: [],
|
||||||
},
|
},
|
||||||
|
|
|
@ -194,6 +194,7 @@ export interface AutomationStep extends AutomationStepSchema {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AutomationTriggerSchema extends AutomationStepSchema {
|
export interface AutomationTriggerSchema extends AutomationStepSchema {
|
||||||
|
type: AutomationStepType.TRIGGER
|
||||||
event?: string
|
event?: string
|
||||||
cronJobId?: string
|
cronJobId?: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue