1
0
Fork 0
mirror of synced 2024-07-05 22:40:39 +12:00

recomitting trigger another automation work

This commit is contained in:
Peter Clement 2023-12-30 18:51:08 +00:00
parent 90d52ce9b7
commit 49676f2cae
4 changed files with 80 additions and 1 deletions

View file

@ -23,7 +23,6 @@
let selectedAction
let actionVal
let actions = Object.entries($automationStore.blockDefinitions.ACTION)
$: collectBlockExists = checkForCollectStep($selectedAutomation)
const disabled = () => {

View file

@ -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]
}

View file

@ -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,
}
}
}

View file

@ -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",