Add checks to shared-core
This commit is contained in:
parent
35bbccec67
commit
b4767cea7c
|
@ -1,4 +1,5 @@
|
|||
import * as triggers from "../../automations/triggers"
|
||||
import { sdk as coreSdk } from "@budibase/shared-core"
|
||||
import { DocumentType } from "../../db/utils"
|
||||
import { updateTestHistory, removeDeprecated } from "../../automations/utils"
|
||||
import { setTestFlag, clearTestFlag } from "../../utilities/redis"
|
||||
|
@ -12,7 +13,6 @@ import {
|
|||
UserCtx,
|
||||
DeleteAutomationResponse,
|
||||
FetchAutomationResponse,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
import { getActionDefinitions as actionDefs } from "../../automations/actions"
|
||||
import sdk from "../../sdk"
|
||||
|
@ -96,9 +96,7 @@ export async function destroy(ctx: UserCtx<void, DeleteAutomationResponse>) {
|
|||
const automationId = ctx.params.id
|
||||
|
||||
const automation = await sdk.automations.get(ctx.params.id)
|
||||
if (
|
||||
automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION
|
||||
) {
|
||||
if (coreSdk.automations.isRowAction(automation)) {
|
||||
ctx.throw("Row actions cannot be deleted", 400)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {
|
||||
Automation,
|
||||
AutomationTriggerStepId,
|
||||
Webhook,
|
||||
WebhookActionType,
|
||||
} from "@budibase/types"
|
||||
import { Automation, Webhook, WebhookActionType } from "@budibase/types"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
import { generateAutomationID, getAutomationParams } from "../../../db/utils"
|
||||
import { deleteEntityMetadata } from "../../../utilities"
|
||||
import { MetadataTypes } from "../../../constants"
|
||||
|
@ -286,13 +282,10 @@ function guardInvalidUpdatesAndThrow(
|
|||
})
|
||||
}
|
||||
|
||||
if (isRowAction(automation) && automation.name !== oldAutomation.name) {
|
||||
if (
|
||||
sdk.automations.isRowAction(automation) &&
|
||||
automation.name !== oldAutomation.name
|
||||
) {
|
||||
throw new Error("Row actions cannot be renamed")
|
||||
}
|
||||
}
|
||||
|
||||
function isRowAction(automation: Automation) {
|
||||
const result =
|
||||
automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ import {
|
|||
Automation,
|
||||
AutomationActionStepId,
|
||||
AutomationBuilderData,
|
||||
AutomationTriggerStepId,
|
||||
TableRowActions,
|
||||
} from "@budibase/types"
|
||||
import { sdk as coreSdk } from "@budibase/shared-core"
|
||||
|
||||
export function checkForCollectStep(automation: Automation) {
|
||||
return automation.definition.steps.some(
|
||||
|
@ -39,14 +39,13 @@ export async function getBuilderData(
|
|||
|
||||
const result: Record<string, AutomationBuilderData> = {}
|
||||
for (const automation of automations) {
|
||||
const { trigger } = automation.definition
|
||||
const isRowAction = trigger.stepId === AutomationTriggerStepId.ROW_ACTION
|
||||
const isRowAction = coreSdk.automations.isRowAction(automation)
|
||||
if (!isRowAction) {
|
||||
result[automation._id!] = { displayName: automation.name }
|
||||
continue
|
||||
}
|
||||
|
||||
const { tableId, rowActionId } = trigger.inputs
|
||||
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
||||
|
||||
const tableName = await getTableName(tableId)
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import { Automation, AutomationTriggerStepId } from "@budibase/types"
|
||||
|
||||
export function isRowAction(automation: Automation) {
|
||||
const result =
|
||||
automation.definition.trigger.stepId === AutomationTriggerStepId.ROW_ACTION
|
||||
return result
|
||||
}
|
|
@ -1,2 +1,3 @@
|
|||
export * as applications from "./applications"
|
||||
export * as automations from "./automations"
|
||||
export * as users from "./users"
|
||||
|
|
Loading…
Reference in New Issue