added ui store types
This commit is contained in:
parent
28f02cc41d
commit
de8c8f5d68
|
@ -26,6 +26,9 @@ import {
|
||||||
UILogicalOperator,
|
UILogicalOperator,
|
||||||
EmptyFilterOption,
|
EmptyFilterOption,
|
||||||
AutomationIOType,
|
AutomationIOType,
|
||||||
|
AutomationStepSchema,
|
||||||
|
AutomationTriggerSchema,
|
||||||
|
BranchPath,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { ActionStepID } from "constants/backend/automations"
|
import { ActionStepID } from "constants/backend/automations"
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
|
@ -165,7 +168,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
* @param {*} automation the automation to alter.
|
* @param {*} automation the automation to alter.
|
||||||
* @returns {Object} contains the deleted nodes and new updated automation
|
* @returns {Object} contains the deleted nodes and new updated automation
|
||||||
*/
|
*/
|
||||||
deleteBlock: (pathTo: Array<any>, automation: Automation) => {
|
deleteBlock: (pathTo: Array<BranchPath>, automation: Automation) => {
|
||||||
let newAutomation = cloneDeep(automation)
|
let newAutomation = cloneDeep(automation)
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
|
@ -253,7 +256,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
registerBlock: (
|
registerBlock: (
|
||||||
blocks: Record<string, any>,
|
blocks: Record<string, any>,
|
||||||
block: AutomationStep | AutomationTrigger,
|
block: AutomationStep | AutomationTrigger,
|
||||||
pathTo: Array<any>,
|
pathTo: Array<BranchPath>,
|
||||||
terminating: boolean
|
terminating: boolean
|
||||||
) => {
|
) => {
|
||||||
blocks[block.id] = {
|
blocks[block.id] = {
|
||||||
|
@ -278,7 +281,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
* @param {Array<Object>} pathWay e.g. [{stepIdx:2},{branchIdx:0, stepIdx:2},...]
|
* @param {Array<Object>} pathWay e.g. [{stepIdx:2},{branchIdx:0, stepIdx:2},...]
|
||||||
* @returns {Array<Object>} all steps encountered on the provided path
|
* @returns {Array<Object>} all steps encountered on the provided path
|
||||||
*/
|
*/
|
||||||
getPathSteps: (pathWay: Array<any>, automation: Automation) => {
|
getPathSteps: (pathWay: Array<BranchPath>, automation: Automation) => {
|
||||||
// Base Steps, including trigger
|
// Base Steps, including trigger
|
||||||
const steps = [
|
const steps = [
|
||||||
automation.definition.trigger,
|
automation.definition.trigger,
|
||||||
|
@ -319,7 +322,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
updateStep: (
|
updateStep: (
|
||||||
pathWay: Array<any>,
|
pathWay: Array<BranchPath>,
|
||||||
automation: Automation,
|
automation: Automation,
|
||||||
update: AutomationStep | AutomationTrigger,
|
update: AutomationStep | AutomationTrigger,
|
||||||
insert = false
|
insert = false
|
||||||
|
@ -474,7 +477,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
|
|
||||||
branches.forEach((branch, bIdx) => {
|
branches.forEach((branch, bIdx) => {
|
||||||
block.inputs?.children[branch.id].forEach(
|
block.inputs?.children[branch.id].forEach(
|
||||||
(bBlock: any, sIdx: any, array: any) => {
|
(bBlock: AutomationStep, sIdx: number, array: AutomationStep[]) => {
|
||||||
const ended =
|
const ended =
|
||||||
array.length - 1 === sIdx && !bBlock.inputs?.branches?.length
|
array.length - 1 === sIdx && !bBlock.inputs?.branches?.length
|
||||||
treeTraverse(bBlock, pathToCurrentNode, sIdx, bIdx, ended)
|
treeTraverse(bBlock, pathToCurrentNode, sIdx, bIdx, ended)
|
||||||
|
@ -569,7 +572,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
|
|
||||||
const isLoopBlock =
|
const isLoopBlock =
|
||||||
pathBlock.stepId === ActionStepID.LOOP &&
|
pathBlock.stepId === ActionStepID.LOOP &&
|
||||||
pathBlock.blockToLoop in blocks
|
pathBlock.blockToLoop! in blocks
|
||||||
|
|
||||||
const isTrigger = pathBlock.type === AutomationStepType.TRIGGER
|
const isTrigger = pathBlock.type === AutomationStepType.TRIGGER
|
||||||
|
|
||||||
|
@ -910,7 +913,10 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
...newAutomation.definition.steps,
|
...newAutomation.definition.steps,
|
||||||
]
|
]
|
||||||
|
|
||||||
let cache: any
|
let cache:
|
||||||
|
| AutomationStepSchema<AutomationActionStepId>
|
||||||
|
| AutomationTriggerSchema<AutomationTriggerStepId>
|
||||||
|
|
||||||
pathWay.forEach((path, pathIdx, array) => {
|
pathWay.forEach((path, pathIdx, array) => {
|
||||||
const { stepIdx, branchIdx } = path
|
const { stepIdx, branchIdx } = path
|
||||||
const final = pathIdx === array.length - 1
|
const final = pathIdx === array.length - 1
|
||||||
|
@ -931,7 +937,6 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number.isInteger(branchIdx)) {
|
if (Number.isInteger(branchIdx)) {
|
||||||
const branchId = cache.inputs.branches[branchIdx].id
|
const branchId = cache.inputs.branches[branchIdx].id
|
||||||
const children = cache.inputs.children[branchId]
|
const children = cache.inputs.children[branchId]
|
||||||
|
@ -982,7 +987,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
branchAutomation: async (path: Array<any>, automation: Automation) => {
|
branchAutomation: async (path: Array<any>, automation: Automation) => {
|
||||||
const insertPoint = path.at(-1)
|
const insertPoint = path.at(-1)
|
||||||
let newAutomation = cloneDeep(automation)
|
let newAutomation = cloneDeep(automation)
|
||||||
let cache: any = null
|
let cache: any
|
||||||
let atRoot = false
|
let atRoot = false
|
||||||
|
|
||||||
// Generate a default empty branch
|
// Generate a default empty branch
|
||||||
|
@ -1105,7 +1110,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
* @param {Object} block
|
* @param {Object} block
|
||||||
*/
|
*/
|
||||||
branchRight: async (
|
branchRight: async (
|
||||||
pathTo: Array<any>,
|
pathTo: Array<BranchPath>,
|
||||||
automation: Automation,
|
automation: Automation,
|
||||||
block: AutomationStep
|
block: AutomationStep
|
||||||
) => {
|
) => {
|
||||||
|
@ -1254,7 +1259,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
*
|
*
|
||||||
* @param {Array<Object>} pathTo the path to the target node
|
* @param {Array<Object>} pathTo the path to the target node
|
||||||
*/
|
*/
|
||||||
deleteAutomationBlock: async (pathTo: Array<any>) => {
|
deleteAutomationBlock: async (pathTo: Array<BranchPath>) => {
|
||||||
const automation = get(selectedAutomation)?.data
|
const automation = get(selectedAutomation)?.data
|
||||||
if (!automation) {
|
if (!automation) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -193,7 +193,7 @@ export enum AutomationStoppedReason {
|
||||||
export interface AutomationResults {
|
export interface AutomationResults {
|
||||||
automationId?: string
|
automationId?: string
|
||||||
status?: AutomationStatus
|
status?: AutomationStatus
|
||||||
trigger?: any
|
trigger?: AutomationTrigger
|
||||||
steps: {
|
steps: {
|
||||||
stepId: AutomationTriggerStepId | AutomationActionStepId
|
stepId: AutomationTriggerStepId | AutomationActionStepId
|
||||||
inputs: {
|
inputs: {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface BranchPath {
|
||||||
|
stepIdx: number
|
||||||
|
branchIdx: number
|
||||||
|
branchStepId: string
|
||||||
|
}
|
|
@ -1 +1,2 @@
|
||||||
export * from "./integration"
|
export * from "./integration"
|
||||||
|
export * from "./automations"
|
||||||
|
|
Loading…
Reference in New Issue