refactor check for collect step into sdk
This commit is contained in:
parent
16ace6bf27
commit
d43fc819c7
|
@ -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,
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import * as webhook from "./webhook"
|
||||
import * as utils from "./utils"
|
||||
|
||||
export default {
|
||||
webhook,
|
||||
utils,
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue