recomitting trigger another automation work
This commit is contained in:
parent
90d52ce9b7
commit
49676f2cae
|
@ -23,7 +23,6 @@
|
|||
let selectedAction
|
||||
let actionVal
|
||||
let actions = Object.entries($automationStore.blockDefinitions.ACTION)
|
||||
|
||||
$: collectBlockExists = checkForCollectStep($selectedAutomation)
|
||||
|
||||
const disabled = () => {
|
||||
|
|
|
@ -15,6 +15,7 @@ import * as delay from "./steps/delay"
|
|||
import * as queryRow from "./steps/queryRows"
|
||||
import * as loop from "./steps/loop"
|
||||
import * as collect from "./steps/collect"
|
||||
import * as trigger from "./steps/trigger"
|
||||
import env from "../environment"
|
||||
import {
|
||||
AutomationStepSchema,
|
||||
|
@ -41,6 +42,7 @@ const ACTION_IMPLS: Record<
|
|||
FILTER: filter.run,
|
||||
QUERY_ROWS: queryRow.run,
|
||||
COLLECT: collect.run,
|
||||
TRIGGER_AUTOMATION: trigger.run,
|
||||
// these used to be lowercase step IDs, maintain for backwards compat
|
||||
discord: discord.run,
|
||||
slack: slack.run,
|
||||
|
@ -62,6 +64,7 @@ export const BUILTIN_ACTION_DEFINITIONS: Record<string, AutomationStepSchema> =
|
|||
QUERY_ROWS: queryRow.definition,
|
||||
LOOP: loop.definition,
|
||||
COLLECT: collect.definition,
|
||||
TRIGGER: trigger.definition,
|
||||
// these used to be lowercase step IDs, maintain for backwards compat
|
||||
discord: discord.definition,
|
||||
slack: slack.definition,
|
||||
|
@ -102,6 +105,7 @@ export async function getActionDefinitions() {
|
|||
|
||||
/* istanbul ignore next */
|
||||
export async function getAction(stepId: string) {
|
||||
console.log(stepId)
|
||||
if (ACTION_IMPLS[stepId] != null) {
|
||||
return ACTION_IMPLS[stepId]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
AutomationStepType,
|
||||
AutomationIOType,
|
||||
AutomationFeature,
|
||||
AutomationResults,
|
||||
Automation,
|
||||
} from "@budibase/types"
|
||||
import * as triggers from "../triggers"
|
||||
import { db as dbCore, context } from "@budibase/backend-core"
|
||||
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Trigger Automation",
|
||||
tagline: "Triggers an automation synchronously",
|
||||
icon: "Sync",
|
||||
description: "Triggers an automation synchronously",
|
||||
type: AutomationStepType.ACTION,
|
||||
internal: true,
|
||||
features: {},
|
||||
stepId: AutomationActionStepId.TRIGGER,
|
||||
inputs: {},
|
||||
schema: {
|
||||
inputs: {
|
||||
properties: {
|
||||
automationId: {
|
||||
type: AutomationIOType.STRING,
|
||||
title: "Automation ID to trigger",
|
||||
},
|
||||
},
|
||||
required: ["automationId"],
|
||||
},
|
||||
outputs: {
|
||||
properties: {
|
||||
success: {
|
||||
type: AutomationIOType.BOOLEAN,
|
||||
description: "Whether the automation was successful",
|
||||
},
|
||||
value: {
|
||||
type: AutomationIOType.OBJECT,
|
||||
description: "Automation Result",
|
||||
},
|
||||
},
|
||||
required: ["success", "value"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export async function run({ inputs }: AutomationStepInput) {
|
||||
console.log("??: " + inputs.automationId)
|
||||
console.log("???DSAASDFAFSDFDSFDS")
|
||||
if (!inputs.automationId) {
|
||||
return {
|
||||
success: false,
|
||||
}
|
||||
} else {
|
||||
const db = context.getAppDB()
|
||||
let automation = await db.get<Automation>(inputs.automationId)
|
||||
|
||||
const response: AutomationResults = await triggers.externalTrigger(
|
||||
automation,
|
||||
{
|
||||
fields: {},
|
||||
timeout: 120000,
|
||||
},
|
||||
{ getResponses: true }
|
||||
)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
value: response,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@ export enum AutomationActionStepId {
|
|||
LOOP = "LOOP",
|
||||
COLLECT = "COLLECT",
|
||||
OPENAI = "OPENAI",
|
||||
TRIGGER = "TRIGGER",
|
||||
// these used to be lowercase step IDs, maintain for backwards compat
|
||||
discord = "discord",
|
||||
slack = "slack",
|
||||
|
|
Loading…
Reference in New Issue