1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

refactor check for collect step into sdk

This commit is contained in:
Peter Clement 2023-05-16 09:29:40 +01:00
parent 16ace6bf27
commit d43fc819c7
4 changed files with 15 additions and 9 deletions

View file

@ -23,6 +23,7 @@ import {
BBContext,
} from "@budibase/types"
import { getActionDefinitions as actionDefs } from "../../automations/actions"
import sdk from "src/sdk"
async function getActionDefinitions() {
return removeDeprecated(await actionDefs())
@ -264,10 +265,9 @@ export async function trigger(ctx: BBContext) {
const db = context.getAppDB()
let automation = await db.get(ctx.params.id)
let hasCollectBlock = automation.definition.steps.some(
(step: any) => step.stepId === AutomationActionStepId.COLLECT
)
if (hasCollectBlock) {
let hasCollectStep = sdk.automations.utils.checkForCollectStep(automation)
if (hasCollectStep) {
const response: AutomationResults = await triggers.externalTrigger(
automation,
{

View file

@ -81,12 +81,9 @@ export async function trigger(ctx: BBContext) {
if (webhook.action.type === WebhookActionType.AUTOMATION) {
// trigger with both the pure request and then expand it
// incase the user has produced a schema to bind to
let hasCollectStep = sdk.automations.utils.checkForCollectStep(target)
let hasCollectBlock = target.definition.steps.some(
(step: any) => step.stepId === AutomationActionStepId.COLLECT
)
if (hasCollectBlock && (await pro.features.isSyncWebhookEnabled())) {
if (hasCollectStep && (await pro.features.isSyncWebhookEnabled())) {
const response = await triggers.externalTrigger(
target,
{

View file

@ -1,5 +1,7 @@
import * as webhook from "./webhook"
import * as utils from "./utils"
export default {
webhook,
utils,
}

View file

@ -0,0 +1,7 @@
import { Automation, AutomationActionStepId } from "@budibase/types"
export function checkForCollectStep(automation: Automation) {
return automation.definition.steps.some(
(step: any) => step.stepId === AutomationActionStepId.COLLECT
)
}