Merge pull request #15475 from Budibase/automation-tests
Move trigger definitions to shared-core.
This commit is contained in:
commit
7b13b54b52
|
@ -1,7 +1,7 @@
|
||||||
import emitter from "../events/index"
|
import emitter from "../events/index"
|
||||||
import { getAutomationParams, isDevAppID } from "../db/utils"
|
import { getAutomationParams, isDevAppID } from "../db/utils"
|
||||||
import { coerce } from "../utilities/rowProcessor"
|
import { coerce } from "../utilities/rowProcessor"
|
||||||
import { definitions } from "./triggerInfo"
|
import { automations } from "@budibase/shared-core"
|
||||||
// need this to call directly, so we can get a response
|
// need this to call directly, so we can get a response
|
||||||
import { automationQueue } from "./bullboard"
|
import { automationQueue } from "./bullboard"
|
||||||
import { checkTestFlag } from "../utilities/redis"
|
import { checkTestFlag } from "../utilities/redis"
|
||||||
|
@ -26,7 +26,7 @@ import {
|
||||||
import { executeInThread } from "../threads/automation"
|
import { executeInThread } from "../threads/automation"
|
||||||
import { dataFilters, sdk } from "@budibase/shared-core"
|
import { dataFilters, sdk } from "@budibase/shared-core"
|
||||||
|
|
||||||
export const TRIGGER_DEFINITIONS = definitions
|
export const TRIGGER_DEFINITIONS = automations.triggers.definitions
|
||||||
const JOB_OPTS = {
|
const JOB_OPTS = {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -273,8 +273,8 @@ async function checkTriggerFilters(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
trigger.stepId === definitions.ROW_UPDATED.stepId ||
|
trigger.stepId === automations.triggers.definitions.ROW_UPDATED.stepId ||
|
||||||
trigger.stepId === definitions.ROW_SAVED.stepId
|
trigger.stepId === automations.triggers.definitions.ROW_SAVED.stepId
|
||||||
) {
|
) {
|
||||||
const newRow = await automationUtils.cleanUpRow(tableId, event.row)
|
const newRow = await automationUtils.cleanUpRow(tableId, event.row)
|
||||||
return rowPassesFilters(newRow, filters)
|
return rowPassesFilters(newRow, filters)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Thread, ThreadType } from "../threads"
|
import { Thread, ThreadType } from "../threads"
|
||||||
import { definitions } from "./triggerInfo"
|
import { automations } from "@budibase/shared-core"
|
||||||
import { automationQueue } from "./bullboard"
|
import { automationQueue } from "./bullboard"
|
||||||
import { updateEntityMetadata } from "../utilities"
|
import { updateEntityMetadata } from "../utilities"
|
||||||
import { context, db as dbCore, utils } from "@budibase/backend-core"
|
import { context, db as dbCore, utils } from "@budibase/backend-core"
|
||||||
|
@ -19,7 +19,7 @@ import { automationsEnabled } from "../features"
|
||||||
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
|
|
||||||
const CRON_STEP_ID = definitions.CRON.stepId
|
const CRON_STEP_ID = automations.triggers.definitions.CRON.stepId
|
||||||
let Runner: Thread
|
let Runner: Thread
|
||||||
if (automationsEnabled()) {
|
if (automationsEnabled()) {
|
||||||
Runner = new Thread(ThreadType.AUTOMATION)
|
Runner = new Thread(ThreadType.AUTOMATION)
|
||||||
|
@ -255,7 +255,10 @@ export async function cleanupAutomations(appId: any) {
|
||||||
* @return if it is recurring (cron).
|
* @return if it is recurring (cron).
|
||||||
*/
|
*/
|
||||||
export function isRecurring(automation: Automation) {
|
export function isRecurring(automation: Automation) {
|
||||||
return automation.definition.trigger.stepId === definitions.CRON.stepId
|
return (
|
||||||
|
automation.definition.trigger.stepId ===
|
||||||
|
automations.triggers.definitions.CRON.stepId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isErrorInOutput(output: {
|
export function isErrorInOutput(output: {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
HTTPError,
|
HTTPError,
|
||||||
db as dbCore,
|
db as dbCore,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { definitions } from "../../../automations/triggerInfo"
|
import { automations as sharedAutomations } from "@budibase/shared-core"
|
||||||
import automations from "."
|
import automations from "."
|
||||||
|
|
||||||
export interface PersistedAutomation extends Automation {
|
export interface PersistedAutomation extends Automation {
|
||||||
|
@ -202,7 +202,7 @@ export async function remove(automationId: string, rev: string) {
|
||||||
* written to DB (this does not write to DB as it would be wasteful to repeat).
|
* written to DB (this does not write to DB as it would be wasteful to repeat).
|
||||||
*/
|
*/
|
||||||
async function checkForWebhooks({ oldAuto, newAuto }: any) {
|
async function checkForWebhooks({ oldAuto, newAuto }: any) {
|
||||||
const WH_STEP_ID = definitions.WEBHOOK.stepId
|
const WH_STEP_ID = sharedAutomations.triggers.definitions.WEBHOOK.stepId
|
||||||
|
|
||||||
const appId = context.getAppId()
|
const appId = context.getAppId()
|
||||||
if (!appId) {
|
if (!appId) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { generateRowActionsID } from "../../../db/utils"
|
import { generateRowActionsID } from "../../../db/utils"
|
||||||
import automations from "../automations"
|
import automations from "../automations"
|
||||||
import { definitions as TRIGGER_DEFINITIONS } from "../../../automations/triggerInfo"
|
import { automations as sharedAutomations } from "@budibase/shared-core"
|
||||||
import * as triggers from "../../../automations/triggers"
|
import * as triggers from "../../../automations/triggers"
|
||||||
import sdk from "../.."
|
import sdk from "../.."
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ export async function create(tableId: string, rowAction: { name: string }) {
|
||||||
definition: {
|
definition: {
|
||||||
trigger: {
|
trigger: {
|
||||||
id: "trigger",
|
id: "trigger",
|
||||||
...TRIGGER_DEFINITIONS.ROW_ACTION,
|
...sharedAutomations.triggers.definitions.ROW_ACTION,
|
||||||
stepId: AutomationTriggerStepId.ROW_ACTION,
|
stepId: AutomationTriggerStepId.ROW_ACTION,
|
||||||
inputs: {
|
inputs: {
|
||||||
tableId,
|
tableId,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { replaceFakeBindings } from "../automations/loopUtils"
|
||||||
import { dataFilters, helpers, utils } from "@budibase/shared-core"
|
import { dataFilters, helpers, utils } from "@budibase/shared-core"
|
||||||
import { default as AutomationEmitter } from "../events/AutomationEmitter"
|
import { default as AutomationEmitter } from "../events/AutomationEmitter"
|
||||||
import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
|
import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
|
||||||
import { definitions as triggerDefs } from "../automations/triggerInfo"
|
import { automations } from "@budibase/shared-core"
|
||||||
import { AutomationErrors, MAX_AUTOMATION_RECURRING_ERRORS } from "../constants"
|
import { AutomationErrors, MAX_AUTOMATION_RECURRING_ERRORS } from "../constants"
|
||||||
import { storeLog } from "../automations/logging"
|
import { storeLog } from "../automations/logging"
|
||||||
import {
|
import {
|
||||||
|
@ -50,7 +50,7 @@ import env from "../environment"
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
|
|
||||||
threadUtils.threadSetup()
|
threadUtils.threadSetup()
|
||||||
const CRON_STEP_ID = triggerDefs.CRON.stepId
|
const CRON_STEP_ID = automations.triggers.definitions.CRON.stepId
|
||||||
const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
|
const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
|
||||||
|
|
||||||
function getLoopIterations(loopStep: LoopStep) {
|
function getLoopIterations(loopStep: LoopStep) {
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
export * as steps from "./steps/index"
|
export * as steps from "./steps/index"
|
||||||
|
export * as triggers from "./triggers/index"
|
||||||
|
|
Loading…
Reference in New Issue