Implement run
This commit is contained in:
parent
890d573cac
commit
f7a460a1ea
|
@ -2,13 +2,9 @@ import { RowActionTriggerRequest, Ctx } from "@budibase/types"
|
|||
import sdk from "../../../sdk"
|
||||
|
||||
export async function run(ctx: Ctx<RowActionTriggerRequest, void>) {
|
||||
const { tableId } = ctx.params
|
||||
const table = await sdk.tables.getTable(tableId)
|
||||
if (!table) {
|
||||
ctx.throw(404)
|
||||
}
|
||||
|
||||
const { tableId, actionId } = ctx.params
|
||||
const { rowId } = ctx.request.body
|
||||
console.warn({ rowId })
|
||||
|
||||
await sdk.rowActions.run(tableId, actionId, rowId)
|
||||
ctx.status = 200
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ function rowPassesFilters(row: Row, filters: SearchFilters) {
|
|||
|
||||
export async function externalTrigger(
|
||||
automation: Automation,
|
||||
params: { fields: Record<string, any>; timeout?: number },
|
||||
params: { fields: Record<string, any>; timeout?: number; appId?: string },
|
||||
{ getResponses }: { getResponses?: boolean } = {}
|
||||
): Promise<any> {
|
||||
if (automation.disabled) {
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { context, HTTPError, utils } from "@budibase/backend-core"
|
||||
|
||||
import { generateRowActionsID } from "../../db/utils"
|
||||
import {
|
||||
SEPARATOR,
|
||||
TableRowActions,
|
||||
VirtualDocumentType,
|
||||
} from "@budibase/types"
|
||||
import { generateRowActionsID } from "../../db/utils"
|
||||
import automations from "./automations"
|
||||
import { definitions as TRIGGER_DEFINITIONS } from "../../automations/triggerInfo"
|
||||
import * as triggers from "../../automations/triggers"
|
||||
import sdk from ".."
|
||||
|
||||
function ensureUniqueAndThrow(
|
||||
doc: TableRowActions,
|
||||
|
@ -143,3 +145,25 @@ export async function remove(tableId: string, rowActionId: string) {
|
|||
const db = context.getAppDB()
|
||||
await db.put(actionsDoc)
|
||||
}
|
||||
|
||||
export async function run(tableId: any, rowActionId: any, rowId: string) {
|
||||
const table = await sdk.tables.getTable(tableId)
|
||||
if (!table) {
|
||||
throw new HTTPError("Table not found", 404)
|
||||
}
|
||||
|
||||
const { actions } = await get(tableId)
|
||||
|
||||
const rowAction = actions[rowActionId]
|
||||
if (!rowAction) {
|
||||
throw new HTTPError("Row action not found", 404)
|
||||
}
|
||||
|
||||
const automation = await sdk.automations.get(rowAction.automationId)
|
||||
|
||||
const row = await sdk.rows.find(tableId, rowId)
|
||||
await triggers.externalTrigger(automation, {
|
||||
fields: { row, table },
|
||||
appId: context.getAppId(),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue