Start implementing row action trigger

This commit is contained in:
Adria Navarro 2024-07-23 13:34:30 +02:00
parent cf4f463da4
commit 7bad3ad39c
2 changed files with 21 additions and 5 deletions

View File

@ -1,3 +1,14 @@
export function run() {
throw new Error("Function not implemented.")
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 { rowId } = ctx.request.body
console.warn({ rowId })
ctx.status = 200
}

View File

@ -1,9 +1,13 @@
import Router from "@koa/router"
import Joi from "joi"
import { middleware, permissions } from "@budibase/backend-core"
import * as rowActionController from "../controllers/rowAction"
import { authorizedResource } from "../../middleware/authorized"
import { middleware, permissions } from "@budibase/backend-core"
import Joi from "joi"
import {
middleware as appInfoMiddleware,
AppType,
} from "../../middleware/appInfo"
const { PermissionLevel, PermissionType } = permissions
@ -45,7 +49,8 @@ router
// Other endpoints
.post(
"/api/tables/:tableId/actions/:actionId/run",
"/api/tables/:tableId/actions/:actionId/trigger",
appInfoMiddleware({ appType: AppType.PROD }),
authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"),
rowActionController.run
)