Merge branch 'master' into remove-mocks-1
This commit is contained in:
commit
83640e9d22
|
@ -63,6 +63,11 @@ http {
|
|||
proxy_send_timeout 120s;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# Enable buffering for potentially large OIDC configs
|
||||
proxy_buffering on;
|
||||
proxy_buffer_size 16k;
|
||||
proxy_buffers 4 32k;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"version": "3.4.11",
|
||||
"version": "3.4.13",
|
||||
"npmClient": "yarn",
|
||||
"concurrency": 20,
|
||||
"command": {
|
||||
|
|
|
@ -266,9 +266,9 @@ export const getProdAppId = () => {
|
|||
return conversions.getProdAppID(appId)
|
||||
}
|
||||
|
||||
export function doInEnvironmentContext(
|
||||
export function doInEnvironmentContext<T>(
|
||||
values: Record<string, string>,
|
||||
task: any
|
||||
task: () => T
|
||||
) {
|
||||
if (!values) {
|
||||
throw new Error("Must supply environment variables.")
|
||||
|
|
|
@ -15,23 +15,27 @@ const conversion: Record<DurationType, number> = {
|
|||
}
|
||||
|
||||
export class Duration {
|
||||
constructor(public ms: number) {}
|
||||
|
||||
to(type: DurationType) {
|
||||
return this.ms / conversion[type]
|
||||
}
|
||||
|
||||
toMs() {
|
||||
return this.ms
|
||||
}
|
||||
|
||||
toSeconds() {
|
||||
return this.to(DurationType.SECONDS)
|
||||
}
|
||||
|
||||
static convert(from: DurationType, to: DurationType, duration: number) {
|
||||
const milliseconds = duration * conversion[from]
|
||||
return milliseconds / conversion[to]
|
||||
}
|
||||
|
||||
static from(from: DurationType, duration: number) {
|
||||
return {
|
||||
to: (to: DurationType) => {
|
||||
return Duration.convert(from, to, duration)
|
||||
},
|
||||
toMs: () => {
|
||||
return Duration.convert(from, DurationType.MILLISECONDS, duration)
|
||||
},
|
||||
toSeconds: () => {
|
||||
return Duration.convert(from, DurationType.SECONDS, duration)
|
||||
},
|
||||
}
|
||||
return new Duration(duration * conversion[from])
|
||||
}
|
||||
|
||||
static fromSeconds(duration: number) {
|
||||
|
|
|
@ -2,3 +2,4 @@ export * from "./hashing"
|
|||
export * from "./utils"
|
||||
export * from "./stringUtils"
|
||||
export * from "./Duration"
|
||||
export * from "./time"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import { Duration } from "./Duration"
|
||||
|
||||
export async function time<T>(f: () => Promise<T>): Promise<[T, Duration]> {
|
||||
const start = performance.now()
|
||||
const result = await f()
|
||||
return [result, Duration.fromMilliseconds(performance.now() - start)]
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
import { onMount } from "svelte"
|
||||
import { Input, Label } from "@budibase/bbui"
|
||||
import { previewStore, selectedScreen } from "@/stores/builder"
|
||||
import type { ComponentContext } from "@budibase/types"
|
||||
import type { AppContext } from "@budibase/types"
|
||||
|
||||
export let baseRoute = ""
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
// This function is needed to repopulate the test value from componentContext
|
||||
// when a user navigates to another component and then back again
|
||||
const updateTestValueFromContext = (context: ComponentContext | null) => {
|
||||
const updateTestValueFromContext = (context: AppContext | null) => {
|
||||
if (context?.url && !testValue) {
|
||||
const { wild, ...urlParams } = context.url
|
||||
const queryParams = context.query
|
||||
|
|
|
@ -8,27 +8,32 @@ import {
|
|||
} from "@budibase/string-templates"
|
||||
import { capitalise } from "@/helpers"
|
||||
import { Constants } from "@budibase/frontend-core"
|
||||
import { Component, ComponentContext } from "@budibase/types"
|
||||
|
||||
const { ContextScopes } = Constants
|
||||
|
||||
/**
|
||||
* Recursively searches for a specific component ID
|
||||
*/
|
||||
export const findComponent = (rootComponent, id) => {
|
||||
export const findComponent = (rootComponent: Component, id: string) => {
|
||||
return searchComponentTree(rootComponent, comp => comp._id === id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively searches for a specific component type
|
||||
*/
|
||||
export const findComponentType = (rootComponent, type) => {
|
||||
export const findComponentType = (rootComponent: Component, type: string) => {
|
||||
return searchComponentTree(rootComponent, comp => comp._component === type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively searches for the parent component of a specific component ID
|
||||
*/
|
||||
export const findComponentParent = (rootComponent, id, parentComponent) => {
|
||||
export const findComponentParent = (
|
||||
rootComponent: Component | undefined,
|
||||
id: string | undefined,
|
||||
parentComponent: Component | null = null
|
||||
): Component | null => {
|
||||
if (!rootComponent || !id) {
|
||||
return null
|
||||
}
|
||||
|
@ -51,7 +56,11 @@ export const findComponentParent = (rootComponent, id, parentComponent) => {
|
|||
* Recursively searches for a specific component ID and records the component
|
||||
* path to this component
|
||||
*/
|
||||
export const findComponentPath = (rootComponent, id, path = []) => {
|
||||
export const findComponentPath = (
|
||||
rootComponent: Component,
|
||||
id: string | undefined,
|
||||
path: Component[] = []
|
||||
): Component[] => {
|
||||
if (!rootComponent || !id) {
|
||||
return []
|
||||
}
|
||||
|
@ -75,11 +84,14 @@ export const findComponentPath = (rootComponent, id, path = []) => {
|
|||
* Recurses through the component tree and finds all components which match
|
||||
* a certain selector
|
||||
*/
|
||||
export const findAllMatchingComponents = (rootComponent, selector) => {
|
||||
export const findAllMatchingComponents = (
|
||||
rootComponent: Component | null,
|
||||
selector: (component: Component) => boolean
|
||||
) => {
|
||||
if (!rootComponent || !selector) {
|
||||
return []
|
||||
}
|
||||
let components = []
|
||||
let components: Component[] = []
|
||||
if (rootComponent._children) {
|
||||
rootComponent._children.forEach(child => {
|
||||
components = [
|
||||
|
@ -97,7 +109,7 @@ export const findAllMatchingComponents = (rootComponent, selector) => {
|
|||
/**
|
||||
* Recurses through the component tree and finds all components.
|
||||
*/
|
||||
export const findAllComponents = rootComponent => {
|
||||
export const findAllComponents = (rootComponent: Component) => {
|
||||
return findAllMatchingComponents(rootComponent, () => true)
|
||||
}
|
||||
|
||||
|
@ -105,9 +117,9 @@ export const findAllComponents = rootComponent => {
|
|||
* Finds the closest parent component which matches certain criteria
|
||||
*/
|
||||
export const findClosestMatchingComponent = (
|
||||
rootComponent,
|
||||
componentId,
|
||||
selector
|
||||
rootComponent: Component,
|
||||
componentId: string | undefined,
|
||||
selector: (component: Component) => boolean
|
||||
) => {
|
||||
if (!selector) {
|
||||
return null
|
||||
|
@ -125,7 +137,10 @@ export const findClosestMatchingComponent = (
|
|||
* Recurses through a component tree evaluating a matching function against
|
||||
* components until a match is found
|
||||
*/
|
||||
const searchComponentTree = (rootComponent, matchComponent) => {
|
||||
const searchComponentTree = (
|
||||
rootComponent: Component,
|
||||
matchComponent: (component: Component) => boolean
|
||||
): Component | null => {
|
||||
if (!rootComponent || !matchComponent) {
|
||||
return null
|
||||
}
|
||||
|
@ -150,15 +165,18 @@ const searchComponentTree = (rootComponent, matchComponent) => {
|
|||
* This mutates the object in place.
|
||||
* @param component the component to randomise
|
||||
*/
|
||||
export const makeComponentUnique = component => {
|
||||
export const makeComponentUnique = (component: Component) => {
|
||||
if (!component) {
|
||||
return
|
||||
}
|
||||
|
||||
// Generate a full set of component ID replacements in this tree
|
||||
const idReplacements = []
|
||||
const generateIdReplacements = (component, replacements) => {
|
||||
const oldId = component._id
|
||||
const idReplacements: [string, string][] = []
|
||||
const generateIdReplacements = (
|
||||
component: Component,
|
||||
replacements: [string, string][]
|
||||
) => {
|
||||
const oldId = component._id!
|
||||
const newId = Helpers.uuid()
|
||||
replacements.push([oldId, newId])
|
||||
component._children?.forEach(x => generateIdReplacements(x, replacements))
|
||||
|
@ -182,9 +200,9 @@ export const makeComponentUnique = component => {
|
|||
let js = decodeJSBinding(sanitizedBinding)
|
||||
if (js != null) {
|
||||
// Replace ID inside JS binding
|
||||
idReplacements.forEach(([oldId, newId]) => {
|
||||
for (const [oldId, newId] of idReplacements) {
|
||||
js = js.replace(new RegExp(oldId, "g"), newId)
|
||||
})
|
||||
}
|
||||
|
||||
// Create new valid JS binding
|
||||
let newBinding = encodeJSBinding(js)
|
||||
|
@ -204,7 +222,7 @@ export const makeComponentUnique = component => {
|
|||
return JSON.parse(definition)
|
||||
}
|
||||
|
||||
export const getComponentText = component => {
|
||||
export const getComponentText = (component: Component) => {
|
||||
if (component == null) {
|
||||
return ""
|
||||
}
|
||||
|
@ -218,7 +236,7 @@ export const getComponentText = component => {
|
|||
return capitalise(type)
|
||||
}
|
||||
|
||||
export const getComponentName = component => {
|
||||
export const getComponentName = (component: Component) => {
|
||||
if (component == null) {
|
||||
return ""
|
||||
}
|
||||
|
@ -229,9 +247,9 @@ export const getComponentName = component => {
|
|||
}
|
||||
|
||||
// Gets all contexts exposed by a certain component type, including actions
|
||||
export const getComponentContexts = component => {
|
||||
export const getComponentContexts = (component: string) => {
|
||||
const def = componentStore.getDefinition(component)
|
||||
let contexts = []
|
||||
let contexts: ComponentContext[] = []
|
||||
if (def?.context) {
|
||||
contexts = Array.isArray(def.context) ? [...def.context] : [def.context]
|
||||
}
|
||||
|
@ -251,9 +269,9 @@ export const getComponentContexts = component => {
|
|||
* Recurses through the component tree and builds a tree of contexts provided
|
||||
* by components.
|
||||
*/
|
||||
export const buildContextTree = (
|
||||
rootComponent,
|
||||
tree = { root: [] },
|
||||
const buildContextTree = (
|
||||
rootComponent: Component,
|
||||
tree: Record<string, string[]> = { root: [] },
|
||||
currentBranch = "root"
|
||||
) => {
|
||||
// Sanity check
|
||||
|
@ -264,12 +282,12 @@ export const buildContextTree = (
|
|||
// Process this component's contexts
|
||||
const contexts = getComponentContexts(rootComponent._component)
|
||||
if (contexts.length) {
|
||||
tree[currentBranch].push(rootComponent._id)
|
||||
tree[currentBranch].push(rootComponent._id!)
|
||||
|
||||
// If we provide local context, start a new branch for our children
|
||||
if (contexts.some(context => context.scope === ContextScopes.Local)) {
|
||||
currentBranch = rootComponent._id
|
||||
tree[rootComponent._id] = []
|
||||
currentBranch = rootComponent._id!
|
||||
tree[rootComponent._id!] = []
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,9 +305,9 @@ export const buildContextTree = (
|
|||
* Generates a lookup map of which context branch all components in a component
|
||||
* tree are inside.
|
||||
*/
|
||||
export const buildContextTreeLookupMap = rootComponent => {
|
||||
export const buildContextTreeLookupMap = (rootComponent: Component) => {
|
||||
const tree = buildContextTree(rootComponent)
|
||||
let map = {}
|
||||
const map: Record<string, string> = {}
|
||||
Object.entries(tree).forEach(([branch, ids]) => {
|
||||
ids.forEach(id => {
|
||||
map[id] = branch
|
||||
|
@ -299,9 +317,9 @@ export const buildContextTreeLookupMap = rootComponent => {
|
|||
}
|
||||
|
||||
// Get a flat list of ids for all descendants of a component
|
||||
export const getChildIdsForComponent = component => {
|
||||
export const getChildIdsForComponent = (component: Component): string[] => {
|
||||
return [
|
||||
component._id,
|
||||
component._id!,
|
||||
...(component?._children ?? []).map(getChildIdsForComponent).flat(1),
|
||||
]
|
||||
}
|
|
@ -15,7 +15,6 @@ import {
|
|||
import {
|
||||
AutomationTriggerStepId,
|
||||
AutomationEventType,
|
||||
AutomationStepType,
|
||||
AutomationActionStepId,
|
||||
Automation,
|
||||
AutomationStep,
|
||||
|
@ -26,10 +25,14 @@ import {
|
|||
UILogicalOperator,
|
||||
EmptyFilterOption,
|
||||
AutomationIOType,
|
||||
AutomationStepSchema,
|
||||
AutomationTriggerSchema,
|
||||
BranchPath,
|
||||
BlockDefinitions,
|
||||
isBranchStep,
|
||||
isTrigger,
|
||||
isRowUpdateTrigger,
|
||||
isRowSaveTrigger,
|
||||
isAppTrigger,
|
||||
BranchStep,
|
||||
} from "@budibase/types"
|
||||
import { ActionStepID } from "@/constants/backend/automations"
|
||||
import { FIELDS } from "@/constants/backend"
|
||||
|
@ -291,16 +294,16 @@ const automationActions = (store: AutomationStore) => ({
|
|||
let result: (AutomationStep | AutomationTrigger)[] = []
|
||||
pathWay.forEach(path => {
|
||||
const { stepIdx, branchIdx } = path
|
||||
let last = result.length ? result[result.length - 1] : []
|
||||
if (!result.length) {
|
||||
// Preceeding steps.
|
||||
result = steps.slice(0, stepIdx + 1)
|
||||
return
|
||||
}
|
||||
if (last && "inputs" in last) {
|
||||
let last = result[result.length - 1]
|
||||
if (isBranchStep(last)) {
|
||||
if (Number.isInteger(branchIdx)) {
|
||||
const branchId = last.inputs.branches[branchIdx].id
|
||||
const children = last.inputs.children[branchId]
|
||||
const children = last.inputs.children?.[branchId] || []
|
||||
const stepChildren = children.slice(0, stepIdx + 1)
|
||||
// Preceeding steps.
|
||||
result = result.concat(stepChildren)
|
||||
|
@ -473,23 +476,28 @@ const automationActions = (store: AutomationStore) => ({
|
|||
id: block.id,
|
||||
},
|
||||
]
|
||||
const branches: Branch[] = block.inputs?.branches || []
|
||||
|
||||
branches.forEach((branch, bIdx) => {
|
||||
block.inputs?.children[branch.id].forEach(
|
||||
(bBlock: AutomationStep, sIdx: number, array: AutomationStep[]) => {
|
||||
const ended =
|
||||
array.length - 1 === sIdx && !bBlock.inputs?.branches?.length
|
||||
treeTraverse(bBlock, pathToCurrentNode, sIdx, bIdx, ended)
|
||||
}
|
||||
)
|
||||
})
|
||||
if (isBranchStep(block)) {
|
||||
const branches = block.inputs?.branches || []
|
||||
const children = block.inputs?.children || {}
|
||||
|
||||
branches.forEach((branch, bIdx) => {
|
||||
children[branch.id].forEach(
|
||||
(bBlock: AutomationStep, sIdx: number, array: AutomationStep[]) => {
|
||||
const ended = array.length - 1 === sIdx && !branches.length
|
||||
treeTraverse(bBlock, pathToCurrentNode, sIdx, bIdx, ended)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
terminating = terminating && !branches.length
|
||||
}
|
||||
|
||||
store.actions.registerBlock(
|
||||
blockRefs,
|
||||
block,
|
||||
pathToCurrentNode,
|
||||
terminating && !branches.length
|
||||
terminating
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -575,7 +583,6 @@ const automationActions = (store: AutomationStore) => ({
|
|||
pathBlock.stepId === ActionStepID.LOOP &&
|
||||
pathBlock.blockToLoop in blocks
|
||||
}
|
||||
const isTrigger = pathBlock.type === AutomationStepType.TRIGGER
|
||||
|
||||
if (isLoopBlock && loopBlockCount == 0) {
|
||||
schema = {
|
||||
|
@ -586,17 +593,14 @@ const automationActions = (store: AutomationStore) => ({
|
|||
}
|
||||
}
|
||||
|
||||
const icon = isTrigger
|
||||
const icon = isTrigger(pathBlock)
|
||||
? pathBlock.icon
|
||||
: isLoopBlock
|
||||
? "Reuse"
|
||||
: pathBlock.icon
|
||||
|
||||
if (blockIdx === 0 && isTrigger) {
|
||||
if (
|
||||
pathBlock.event === AutomationEventType.ROW_UPDATE ||
|
||||
pathBlock.event === AutomationEventType.ROW_SAVE
|
||||
) {
|
||||
if (blockIdx === 0 && isTrigger(pathBlock)) {
|
||||
if (isRowUpdateTrigger(pathBlock) || isRowSaveTrigger(pathBlock)) {
|
||||
let table: any = get(tables).list.find(
|
||||
(table: Table) => table._id === pathBlock.inputs.tableId
|
||||
)
|
||||
|
@ -608,7 +612,7 @@ const automationActions = (store: AutomationStore) => ({
|
|||
}
|
||||
}
|
||||
delete schema.row
|
||||
} else if (pathBlock.event === AutomationEventType.APP_TRIGGER) {
|
||||
} else if (isAppTrigger(pathBlock)) {
|
||||
schema = Object.fromEntries(
|
||||
Object.keys(pathBlock.inputs.fields || []).map(key => [
|
||||
key,
|
||||
|
@ -915,8 +919,10 @@ const automationActions = (store: AutomationStore) => ({
|
|||
]
|
||||
|
||||
let cache:
|
||||
| AutomationStepSchema<AutomationActionStepId>
|
||||
| AutomationTriggerSchema<AutomationTriggerStepId>
|
||||
| AutomationStep
|
||||
| AutomationTrigger
|
||||
| AutomationStep[]
|
||||
| undefined = undefined
|
||||
|
||||
pathWay.forEach((path, pathIdx, array) => {
|
||||
const { stepIdx, branchIdx } = path
|
||||
|
@ -938,9 +944,13 @@ const automationActions = (store: AutomationStore) => ({
|
|||
}
|
||||
return
|
||||
}
|
||||
if (Number.isInteger(branchIdx)) {
|
||||
if (
|
||||
Number.isInteger(branchIdx) &&
|
||||
!Array.isArray(cache) &&
|
||||
isBranchStep(cache)
|
||||
) {
|
||||
const branchId = cache.inputs.branches[branchIdx].id
|
||||
const children = cache.inputs.children[branchId]
|
||||
const children = cache.inputs.children?.[branchId] || []
|
||||
|
||||
if (final) {
|
||||
insertBlock(children, stepIdx)
|
||||
|
@ -1090,7 +1100,7 @@ const automationActions = (store: AutomationStore) => ({
|
|||
branchLeft: async (
|
||||
pathTo: Array<any>,
|
||||
automation: Automation,
|
||||
block: AutomationStep
|
||||
block: BranchStep
|
||||
) => {
|
||||
const update = store.actions.shiftBranch(pathTo, block)
|
||||
if (update) {
|
||||
|
@ -1113,7 +1123,7 @@ const automationActions = (store: AutomationStore) => ({
|
|||
branchRight: async (
|
||||
pathTo: Array<BranchPath>,
|
||||
automation: Automation,
|
||||
block: AutomationStep
|
||||
block: BranchStep
|
||||
) => {
|
||||
const update = store.actions.shiftBranch(pathTo, block, 1)
|
||||
if (update) {
|
||||
|
@ -1133,7 +1143,7 @@ const automationActions = (store: AutomationStore) => ({
|
|||
* @param {Number} direction - the direction of the swap. Defaults to -1 for left, add 1 for right
|
||||
* @returns
|
||||
*/
|
||||
shiftBranch: (pathTo: Array<any>, block: AutomationStep, direction = -1) => {
|
||||
shiftBranch: (pathTo: Array<any>, block: BranchStep, direction = -1) => {
|
||||
let newBlock = cloneDeep(block)
|
||||
const branchPath = pathTo.at(-1)
|
||||
const targetIdx = branchPath.branchIdx
|
||||
|
|
|
@ -58,7 +58,7 @@ export class ComponentTreeNodesStore extends BudiStore<OpenNodesState> {
|
|||
|
||||
const path = findComponentPath(selectedScreen.props, componentId)
|
||||
|
||||
const componentIds = path.map((component: Component) => component._id)
|
||||
const componentIds = path.map((component: Component) => component._id!)
|
||||
|
||||
this.update((openNodes: OpenNodesState) => {
|
||||
const newNodes = Object.fromEntries(
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// TODO: analise and fix all the undefined ! and ?
|
||||
|
||||
import { get, derived } from "svelte/store"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import { API } from "@/api"
|
||||
|
@ -36,7 +38,7 @@ import { Utils } from "@budibase/frontend-core"
|
|||
import {
|
||||
ComponentDefinition,
|
||||
ComponentSetting,
|
||||
Component as ComponentType,
|
||||
Component,
|
||||
ComponentCondition,
|
||||
FieldType,
|
||||
Screen,
|
||||
|
@ -45,10 +47,6 @@ import {
|
|||
import { utils } from "@budibase/shared-core"
|
||||
import { getSequentialName } from "@/helpers/duplicate"
|
||||
|
||||
interface Component extends ComponentType {
|
||||
_id: string
|
||||
}
|
||||
|
||||
export interface ComponentState {
|
||||
components: Record<string, ComponentDefinition>
|
||||
customComponents: string[]
|
||||
|
@ -182,7 +180,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
* Takes an enriched component instance and applies any required migration
|
||||
* logic
|
||||
*/
|
||||
migrateSettings(enrichedComponent: Component) {
|
||||
migrateSettings(enrichedComponent: Component | null) {
|
||||
const componentPrefix = "@budibase/standard-components"
|
||||
let migrated = false
|
||||
|
||||
|
@ -232,7 +230,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
|
||||
enrichEmptySettings(
|
||||
component: Component,
|
||||
opts: { screen?: Screen; parent?: Component; useDefaultValues?: boolean }
|
||||
opts: { screen?: Screen; parent?: string; useDefaultValues?: boolean }
|
||||
) {
|
||||
if (!component?._component) {
|
||||
return
|
||||
|
@ -240,7 +238,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
const defaultDS = this.getDefaultDatasource()
|
||||
const settings = this.getComponentSettings(component._component)
|
||||
const { parent, screen, useDefaultValues } = opts || {}
|
||||
const treeId = parent?._id || component._id
|
||||
const treeId = parent || component._id
|
||||
if (!screen) {
|
||||
return
|
||||
}
|
||||
|
@ -425,7 +423,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
createInstance(
|
||||
componentType: string,
|
||||
presetProps?: Record<string, any>,
|
||||
parent?: Component
|
||||
parent?: string
|
||||
): Component | null {
|
||||
const screen = get(selectedScreen)
|
||||
if (!screen) {
|
||||
|
@ -503,7 +501,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
async create(
|
||||
componentType: string,
|
||||
presetProps?: Record<string, any>,
|
||||
parent?: Component,
|
||||
parent?: string,
|
||||
index?: number
|
||||
) {
|
||||
const state = get(this.store)
|
||||
|
@ -519,7 +517,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
// Insert in position if specified
|
||||
if (parent && index != null) {
|
||||
await screenStore.patch((screen: Screen) => {
|
||||
let parentComponent = findComponent(screen.props, parent)
|
||||
let parentComponent = findComponent(screen.props, parent)!
|
||||
if (!parentComponent._children?.length) {
|
||||
parentComponent._children = [componentInstance]
|
||||
} else {
|
||||
|
@ -538,7 +536,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
}
|
||||
const currentComponent = findComponent(
|
||||
screen.props,
|
||||
selectedComponentId
|
||||
selectedComponentId!
|
||||
)
|
||||
if (!currentComponent) {
|
||||
return false
|
||||
|
@ -581,7 +579,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
return state
|
||||
})
|
||||
|
||||
componentTreeNodesStore.makeNodeVisible(componentInstance._id)
|
||||
componentTreeNodesStore.makeNodeVisible(componentInstance._id!)
|
||||
|
||||
// Log event
|
||||
analytics.captureEvent(Events.COMPONENT_CREATED, {
|
||||
|
@ -633,7 +631,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
// Determine the next component to select, and select it before deletion
|
||||
// to avoid an intermediate state of no component selection
|
||||
const state = get(this.store)
|
||||
let nextId = ""
|
||||
let nextId: string | null = ""
|
||||
if (state.selectedComponentId === component._id) {
|
||||
nextId = this.getNext()
|
||||
if (!nextId) {
|
||||
|
@ -646,7 +644,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
nextId = nextId.replace("-navigation", "-screen")
|
||||
}
|
||||
this.update(state => {
|
||||
state.selectedComponentId = nextId
|
||||
state.selectedComponentId = nextId ?? undefined
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
@ -654,18 +652,18 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
// Patch screen
|
||||
await screenStore.patch((screen: Screen) => {
|
||||
// Check component exists
|
||||
component = findComponent(screen.props, component._id)
|
||||
if (!component) {
|
||||
const updatedComponent = findComponent(screen.props, component._id!)
|
||||
if (!updatedComponent) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check component has a valid parent
|
||||
const parent = findComponentParent(screen.props, component._id)
|
||||
const parent = findComponentParent(screen.props, updatedComponent._id)
|
||||
if (!parent) {
|
||||
return false
|
||||
}
|
||||
parent._children = parent._children.filter(
|
||||
(child: Component) => child._id !== component._id
|
||||
parent._children = parent._children!.filter(
|
||||
(child: Component) => child._id !== updatedComponent._id
|
||||
)
|
||||
}, null)
|
||||
}
|
||||
|
@ -729,7 +727,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
// Patch screen
|
||||
const patch = (screen: Screen) => {
|
||||
// Get up to date ref to target
|
||||
targetComponent = findComponent(screen.props, targetComponent._id)
|
||||
targetComponent = findComponent(screen.props, targetComponent!._id!)!
|
||||
if (!targetComponent) {
|
||||
return false
|
||||
}
|
||||
|
@ -743,7 +741,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
if (!cut) {
|
||||
componentToPaste = makeComponentUnique(componentToPaste)
|
||||
}
|
||||
newComponentId = componentToPaste._id
|
||||
newComponentId = componentToPaste._id!
|
||||
|
||||
// Strip grid position metadata if pasting into a new screen, but keep
|
||||
// alignment metadata
|
||||
|
@ -820,8 +818,8 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
if (!screen) {
|
||||
throw "A valid screen must be selected"
|
||||
}
|
||||
const parent = findComponentParent(screen.props, componentId)
|
||||
const index = parent?._children.findIndex(
|
||||
const parent = findComponentParent(screen.props, componentId)!
|
||||
const index = parent?._children?.findIndex(
|
||||
(x: Component) => x._id === componentId
|
||||
)
|
||||
|
||||
|
@ -839,29 +837,29 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
}
|
||||
|
||||
// If we have siblings above us, choose the sibling or a descendant
|
||||
if (index > 0) {
|
||||
if (index !== undefined && index > 0) {
|
||||
// If sibling before us accepts children, and is not collapsed, select a descendant
|
||||
const previousSibling = parent._children[index - 1]
|
||||
const previousSibling = parent._children![index - 1]
|
||||
if (
|
||||
previousSibling._children?.length &&
|
||||
componentTreeNodesStore.isNodeExpanded(previousSibling._id)
|
||||
componentTreeNodesStore.isNodeExpanded(previousSibling._id!)
|
||||
) {
|
||||
let target = previousSibling
|
||||
while (
|
||||
target._children?.length &&
|
||||
componentTreeNodesStore.isNodeExpanded(target._id)
|
||||
componentTreeNodesStore.isNodeExpanded(target._id!)
|
||||
) {
|
||||
target = target._children[target._children.length - 1]
|
||||
}
|
||||
return target._id
|
||||
return target._id!
|
||||
}
|
||||
|
||||
// Otherwise just select sibling
|
||||
return previousSibling._id
|
||||
return previousSibling._id!
|
||||
}
|
||||
|
||||
// If no siblings above us, select the parent
|
||||
return parent._id
|
||||
return parent._id!
|
||||
}
|
||||
|
||||
getNext() {
|
||||
|
@ -873,9 +871,9 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
throw "A valid screen must be selected"
|
||||
}
|
||||
const parent = findComponentParent(screen.props, componentId)
|
||||
const index = parent?._children.findIndex(
|
||||
const index = parent?._children?.findIndex(
|
||||
(x: Component) => x._id === componentId
|
||||
)
|
||||
)!
|
||||
|
||||
// Check for screen and navigation component edge cases
|
||||
const screenComponentId = `${screen._id}-screen`
|
||||
|
@ -888,37 +886,38 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
if (
|
||||
component?._children?.length &&
|
||||
(state.selectedComponentId === navComponentId ||
|
||||
componentTreeNodesStore.isNodeExpanded(component._id))
|
||||
componentTreeNodesStore.isNodeExpanded(component._id!))
|
||||
) {
|
||||
return component._children[0]._id
|
||||
return component._children[0]._id!
|
||||
} else if (!parent) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Otherwise select the next sibling if we have one
|
||||
if (index < parent._children.length - 1) {
|
||||
const nextSibling = parent._children[index + 1]
|
||||
return nextSibling._id
|
||||
if (index < parent._children!.length - 1) {
|
||||
const nextSibling = parent._children![index + 1]
|
||||
return nextSibling._id!
|
||||
}
|
||||
|
||||
// Last child, select our parents next sibling
|
||||
let target = parent
|
||||
let targetParent = findComponentParent(screen.props, target._id)
|
||||
let targetIndex = targetParent?._children.findIndex(
|
||||
let targetIndex = targetParent?._children?.findIndex(
|
||||
(child: Component) => child._id === target._id
|
||||
)
|
||||
)!
|
||||
while (
|
||||
targetParent != null &&
|
||||
targetIndex === targetParent._children?.length - 1
|
||||
targetParent._children &&
|
||||
targetIndex === targetParent._children.length - 1
|
||||
) {
|
||||
target = targetParent
|
||||
targetParent = findComponentParent(screen.props, target._id)
|
||||
targetIndex = targetParent?._children.findIndex(
|
||||
targetIndex = targetParent?._children!.findIndex(
|
||||
(child: Component) => child._id === target._id
|
||||
)
|
||||
)!
|
||||
}
|
||||
if (targetParent) {
|
||||
return targetParent._children[targetIndex + 1]._id
|
||||
return targetParent._children![targetIndex + 1]._id!
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
@ -950,16 +949,16 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
const parent = findComponentParent(screen.props, componentId)
|
||||
|
||||
// Check we aren't right at the top of the tree
|
||||
const index = parent?._children.findIndex(
|
||||
const index = parent?._children?.findIndex(
|
||||
(x: Component) => x._id === componentId
|
||||
)
|
||||
)!
|
||||
if (!parent || (index === 0 && parent._id === screen.props._id)) {
|
||||
return
|
||||
}
|
||||
|
||||
// Copy original component and remove it from the parent
|
||||
const originalComponent = cloneDeep(parent._children[index])
|
||||
parent._children = parent._children.filter(
|
||||
const originalComponent = cloneDeep(parent._children![index])
|
||||
parent._children = parent._children!.filter(
|
||||
(component: Component) => component._id !== componentId
|
||||
)
|
||||
|
||||
|
@ -971,9 +970,9 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
const definition = this.getDefinition(previousSibling._component)
|
||||
if (
|
||||
definition?.hasChildren &&
|
||||
componentTreeNodesStore.isNodeExpanded(previousSibling._id)
|
||||
componentTreeNodesStore.isNodeExpanded(previousSibling._id!)
|
||||
) {
|
||||
previousSibling._children.push(originalComponent)
|
||||
previousSibling._children!.push(originalComponent)
|
||||
}
|
||||
|
||||
// Otherwise just move component above sibling
|
||||
|
@ -985,11 +984,11 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
// If no siblings above us, go above the parent as long as it isn't
|
||||
// the screen
|
||||
else if (parent._id !== screen.props._id) {
|
||||
const grandParent = findComponentParent(screen.props, parent._id)
|
||||
const parentIndex = grandParent._children.findIndex(
|
||||
const grandParent = findComponentParent(screen.props, parent._id)!
|
||||
const parentIndex = grandParent._children!.findIndex(
|
||||
(child: Component) => child._id === parent._id
|
||||
)
|
||||
grandParent._children.splice(parentIndex, 0, originalComponent)
|
||||
grandParent._children!.splice(parentIndex, 0, originalComponent)
|
||||
}
|
||||
}, null)
|
||||
}
|
||||
|
@ -1028,9 +1027,9 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
const definition = this.getDefinition(nextSibling._component)
|
||||
if (
|
||||
definition?.hasChildren &&
|
||||
componentTreeNodesStore.isNodeExpanded(nextSibling._id)
|
||||
componentTreeNodesStore.isNodeExpanded(nextSibling._id!)
|
||||
) {
|
||||
nextSibling._children.splice(0, 0, originalComponent)
|
||||
nextSibling._children!.splice(0, 0, originalComponent)
|
||||
}
|
||||
|
||||
// Otherwise move below next sibling
|
||||
|
@ -1041,11 +1040,11 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
|
||||
// Last child, so move below our parent
|
||||
else {
|
||||
const grandParent = findComponentParent(screen.props, parent._id)
|
||||
const parentIndex = grandParent._children.findIndex(
|
||||
const grandParent = findComponentParent(screen.props, parent._id)!
|
||||
const parentIndex = grandParent._children!.findIndex(
|
||||
(child: Component) => child._id === parent._id
|
||||
)
|
||||
grandParent._children.splice(parentIndex + 1, 0, originalComponent)
|
||||
grandParent._children!.splice(parentIndex + 1, 0, originalComponent)
|
||||
}
|
||||
}, null)
|
||||
}
|
||||
|
@ -1208,13 +1207,13 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
|||
}
|
||||
|
||||
// Replace component with parent
|
||||
const index = oldParentDefinition._children.findIndex(
|
||||
const index = oldParentDefinition._children!.findIndex(
|
||||
(component: Component) => component._id === componentId
|
||||
)
|
||||
if (index === -1) {
|
||||
return false
|
||||
}
|
||||
oldParentDefinition._children[index] = {
|
||||
oldParentDefinition._children![index] = {
|
||||
...newParentDefinition,
|
||||
_children: [definition],
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { get } from "svelte/store"
|
||||
import { BudiStore } from "../BudiStore"
|
||||
import { PreviewDevice, ComponentContext } from "@budibase/types"
|
||||
import { PreviewDevice, ComponentContext, AppContext } from "@budibase/types"
|
||||
|
||||
type PreviewEventHandler = (name: string, payload?: any) => void
|
||||
|
||||
|
@ -8,7 +8,7 @@ interface PreviewState {
|
|||
previewDevice: PreviewDevice
|
||||
previewEventHandler: PreviewEventHandler | null
|
||||
showPreview: boolean
|
||||
selectedComponentContext: ComponentContext | null
|
||||
selectedComponentContext: AppContext | null
|
||||
}
|
||||
|
||||
const INITIAL_PREVIEW_STATE: PreviewState = {
|
||||
|
|
|
@ -490,7 +490,7 @@ export class ScreenStore extends BudiStore<ScreenState> {
|
|||
// Flatten the recursive component tree
|
||||
const components = findAllMatchingComponents(
|
||||
screen.props,
|
||||
(x: Component) => x
|
||||
(x: Component) => !!x
|
||||
)
|
||||
|
||||
// Iterate over all components and run checks
|
||||
|
|
|
@ -112,10 +112,7 @@ export const EventPublishType = {
|
|||
ENV_VAR_UPGRADE_PANEL_OPENED: "environment_variable_upgrade_panel_opened",
|
||||
}
|
||||
|
||||
export const ContextScopes = {
|
||||
Local: "local",
|
||||
Global: "global",
|
||||
}
|
||||
export { ComponentContextScopes as ContextScopes } from "@budibase/types"
|
||||
|
||||
export const TypeIconMap = {
|
||||
[FieldType.STRING]: "Text",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit eb96d8b2f2029033b0f758078ed30c888e8fb249
|
||||
Subproject commit 45f5673d5e5ab3c22deb6663cea2e31a628aa133
|
|
@ -13,6 +13,7 @@ import sdk from "../../../sdk"
|
|||
import {
|
||||
ConfigType,
|
||||
FieldType,
|
||||
FilterCondition,
|
||||
isDidNotTriggerResponse,
|
||||
SettingsConfig,
|
||||
Table,
|
||||
|
@ -20,12 +21,9 @@ import {
|
|||
import { mocks } from "@budibase/backend-core/tests"
|
||||
import { removeDeprecated } from "../../../automations/utils"
|
||||
import { createAutomationBuilder } from "../../../automations/tests/utilities/AutomationTestBuilder"
|
||||
import { automations } from "@budibase/shared-core"
|
||||
import { basicTable } from "../../../tests/utilities/structures"
|
||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||
|
||||
const FilterConditions = automations.steps.filter.FilterConditions
|
||||
|
||||
const MAX_RETRIES = 4
|
||||
const {
|
||||
basicAutomation,
|
||||
|
@ -487,15 +485,40 @@ describe("/automations", () => {
|
|||
expect(events.automation.created).not.toHaveBeenCalled()
|
||||
expect(events.automation.triggerUpdated).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("can update an input field", async () => {
|
||||
const { automation } = await createAutomationBuilder(config)
|
||||
.onRowDeleted({ tableId: "tableId" })
|
||||
.serverLog({ text: "test" })
|
||||
.save()
|
||||
|
||||
automation.definition.trigger.inputs.tableId = "newTableId"
|
||||
const { automation: updatedAutomation } =
|
||||
await config.api.automation.update(automation)
|
||||
|
||||
expect(updatedAutomation.definition.trigger.inputs.tableId).toEqual(
|
||||
"newTableId"
|
||||
)
|
||||
})
|
||||
|
||||
it("cannot update a readonly field", async () => {
|
||||
const { automation } = await createAutomationBuilder(config)
|
||||
.onRowAction({ tableId: "tableId" })
|
||||
.serverLog({ text: "test" })
|
||||
.save()
|
||||
|
||||
automation.definition.trigger.inputs.tableId = "newTableId"
|
||||
await config.api.automation.update(automation, {
|
||||
status: 400,
|
||||
body: {
|
||||
message: "Field tableId is readonly and it cannot be modified",
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("fetch", () => {
|
||||
it("return all the automations for an instance", async () => {
|
||||
const fetchResponse = await config.api.automation.fetch()
|
||||
for (const auto of fetchResponse.automations) {
|
||||
await config.api.automation.delete(auto)
|
||||
}
|
||||
|
||||
const { automation: automation1 } = await config.api.automation.post(
|
||||
newAutomation()
|
||||
)
|
||||
|
@ -594,7 +617,7 @@ describe("/automations", () => {
|
|||
steps: [
|
||||
{
|
||||
inputs: {
|
||||
condition: FilterConditions.EQUAL,
|
||||
condition: FilterCondition.EQUAL,
|
||||
field: "{{ trigger.row.City }}",
|
||||
value: "{{ trigger.oldRow.City }}",
|
||||
},
|
||||
|
|
|
@ -27,6 +27,8 @@ import {
|
|||
Hosting,
|
||||
ActionImplementation,
|
||||
AutomationStepDefinition,
|
||||
AutomationStepInputs,
|
||||
AutomationStepOutputs,
|
||||
} from "@budibase/types"
|
||||
import sdk from "../sdk"
|
||||
import { getAutomationPlugin } from "../utilities/fileSystem"
|
||||
|
@ -120,11 +122,15 @@ export async function getActionDefinitions(): Promise<
|
|||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
export async function getAction(
|
||||
stepId: AutomationActionStepId
|
||||
): Promise<ActionImplementation<any, any> | undefined> {
|
||||
export async function getAction<
|
||||
TStep extends AutomationActionStepId,
|
||||
TInputs = AutomationStepInputs<TStep>,
|
||||
TOutputs = AutomationStepOutputs<TStep>
|
||||
>(stepId: TStep): Promise<ActionImplementation<TInputs, TOutputs> | undefined> {
|
||||
if (ACTION_IMPLS[stepId as keyof ActionImplType] != null) {
|
||||
return ACTION_IMPLS[stepId as keyof ActionImplType]
|
||||
return ACTION_IMPLS[
|
||||
stepId as keyof ActionImplType
|
||||
] as unknown as ActionImplementation<TInputs, TOutputs>
|
||||
}
|
||||
|
||||
// must be a plugin
|
||||
|
|
|
@ -6,10 +6,10 @@ import {
|
|||
import sdk from "../sdk"
|
||||
import {
|
||||
AutomationAttachment,
|
||||
BaseIOStructure,
|
||||
FieldSchema,
|
||||
FieldType,
|
||||
Row,
|
||||
LoopStepType,
|
||||
LoopStepInputs,
|
||||
} from "@budibase/types"
|
||||
import { objectStore, context } from "@budibase/backend-core"
|
||||
import * as uuid from "uuid"
|
||||
|
@ -32,33 +32,34 @@ import path from "path"
|
|||
* primitive types.
|
||||
*/
|
||||
export function cleanInputValues<T extends Record<string, any>>(
|
||||
inputs: any,
|
||||
schema?: any
|
||||
inputs: T,
|
||||
schema?: Partial<Record<keyof T, FieldSchema | BaseIOStructure>>
|
||||
): T {
|
||||
if (schema == null) {
|
||||
return inputs
|
||||
}
|
||||
for (let inputKey of Object.keys(inputs)) {
|
||||
const keys = Object.keys(inputs) as (keyof T)[]
|
||||
for (let inputKey of keys) {
|
||||
let input = inputs[inputKey]
|
||||
if (typeof input !== "string") {
|
||||
continue
|
||||
}
|
||||
let propSchema = schema.properties[inputKey]
|
||||
let propSchema = schema?.[inputKey]
|
||||
if (!propSchema) {
|
||||
continue
|
||||
}
|
||||
if (propSchema.type === "boolean") {
|
||||
let lcInput = input.toLowerCase()
|
||||
if (lcInput === "true") {
|
||||
// @ts-expect-error - indexing a generic on purpose
|
||||
inputs[inputKey] = true
|
||||
}
|
||||
if (lcInput === "false") {
|
||||
// @ts-expect-error - indexing a generic on purpose
|
||||
inputs[inputKey] = false
|
||||
}
|
||||
}
|
||||
if (propSchema.type === "number") {
|
||||
let floatInput = parseFloat(input)
|
||||
if (!isNaN(floatInput)) {
|
||||
// @ts-expect-error - indexing a generic on purpose
|
||||
inputs[inputKey] = floatInput
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +94,7 @@ export function cleanInputValues<T extends Record<string, any>>(
|
|||
*/
|
||||
export async function cleanUpRow(tableId: string, row: Row) {
|
||||
let table = await sdk.tables.getTable(tableId)
|
||||
return cleanInputValues(row, { properties: table.schema })
|
||||
return cleanInputValues(row, table.schema)
|
||||
}
|
||||
|
||||
export function getError(err: any) {
|
||||
|
@ -271,36 +272,3 @@ export function stringSplit(value: string | string[]) {
|
|||
}
|
||||
return value.split(",")
|
||||
}
|
||||
|
||||
export function typecastForLooping(input: LoopStepInputs) {
|
||||
if (!input || !input.binding) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
switch (input.option) {
|
||||
case LoopStepType.ARRAY:
|
||||
if (typeof input.binding === "string") {
|
||||
return JSON.parse(input.binding)
|
||||
}
|
||||
break
|
||||
case LoopStepType.STRING:
|
||||
if (Array.isArray(input.binding)) {
|
||||
return input.binding.join(",")
|
||||
}
|
||||
break
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error("Unable to cast to correct type")
|
||||
}
|
||||
return input.binding
|
||||
}
|
||||
|
||||
export function ensureMaxIterationsAsNumber(
|
||||
value: number | string | undefined
|
||||
): number | undefined {
|
||||
if (typeof value === "number") return value
|
||||
if (typeof value === "string") {
|
||||
return parseInt(value)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
import * as automationUtils from "./automationUtils"
|
||||
import { isPlainObject } from "lodash"
|
||||
|
||||
type ObjValue = {
|
||||
[key: string]: string | ObjValue
|
||||
}
|
||||
|
||||
export function replaceFakeBindings<T extends Record<string, any>>(
|
||||
originalStepInput: T,
|
||||
loopStepNumber: number
|
||||
): T {
|
||||
const result: Record<string, any> = {}
|
||||
for (const [key, value] of Object.entries(originalStepInput)) {
|
||||
result[key] = replaceBindingsRecursive(value, loopStepNumber)
|
||||
}
|
||||
return result as T
|
||||
}
|
||||
|
||||
function replaceBindingsRecursive(
|
||||
value: string | ObjValue,
|
||||
loopStepNumber: number
|
||||
) {
|
||||
if (value === null || value === undefined) {
|
||||
return value
|
||||
}
|
||||
|
||||
if (typeof value === "object") {
|
||||
for (const [innerKey, innerValue] of Object.entries(value)) {
|
||||
if (typeof innerValue === "string") {
|
||||
value[innerKey] = automationUtils.substituteLoopStep(
|
||||
innerValue,
|
||||
`steps.${loopStepNumber}`
|
||||
)
|
||||
} else if (
|
||||
innerValue &&
|
||||
isPlainObject(innerValue) &&
|
||||
Object.keys(innerValue).length > 0
|
||||
) {
|
||||
value[innerKey] = replaceBindingsRecursive(innerValue, loopStepNumber)
|
||||
}
|
||||
}
|
||||
} else if (typeof value === "string") {
|
||||
value = automationUtils.substituteLoopStep(value, `steps.${loopStepNumber}`)
|
||||
}
|
||||
return value
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
import { FilterStepInputs, FilterStepOutputs } from "@budibase/types"
|
||||
import { automations } from "@budibase/shared-core"
|
||||
|
||||
const FilterConditions = automations.steps.filter.FilterConditions
|
||||
import {
|
||||
FilterCondition,
|
||||
FilterStepInputs,
|
||||
FilterStepOutputs,
|
||||
} from "@budibase/types"
|
||||
|
||||
export async function run({
|
||||
inputs,
|
||||
|
@ -26,16 +27,16 @@ export async function run({
|
|||
let result = false
|
||||
if (typeof field !== "object" && typeof value !== "object") {
|
||||
switch (condition) {
|
||||
case FilterConditions.EQUAL:
|
||||
case FilterCondition.EQUAL:
|
||||
result = field === value
|
||||
break
|
||||
case FilterConditions.NOT_EQUAL:
|
||||
case FilterCondition.NOT_EQUAL:
|
||||
result = field !== value
|
||||
break
|
||||
case FilterConditions.GREATER_THAN:
|
||||
case FilterCondition.GREATER_THAN:
|
||||
result = field > value
|
||||
break
|
||||
case FilterConditions.LESS_THAN:
|
||||
case FilterCondition.LESS_THAN:
|
||||
result = field < value
|
||||
break
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {
|
||||
typecastForLooping,
|
||||
cleanInputValues,
|
||||
substituteLoopStep,
|
||||
} from "../automationUtils"
|
||||
import { LoopStepType } from "@budibase/types"
|
||||
import { AutomationIOType } from "@budibase/types"
|
||||
import { cleanInputValues, substituteLoopStep } from "../automationUtils"
|
||||
|
||||
describe("automationUtils", () => {
|
||||
describe("substituteLoopStep", () => {
|
||||
|
@ -30,29 +26,6 @@ describe("automationUtils", () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe("typeCastForLooping", () => {
|
||||
it("should parse to correct type", () => {
|
||||
expect(
|
||||
typecastForLooping({ option: LoopStepType.ARRAY, binding: [1, 2, 3] })
|
||||
).toEqual([1, 2, 3])
|
||||
expect(
|
||||
typecastForLooping({ option: LoopStepType.ARRAY, binding: "[1,2,3]" })
|
||||
).toEqual([1, 2, 3])
|
||||
expect(
|
||||
typecastForLooping({ option: LoopStepType.STRING, binding: [1, 2, 3] })
|
||||
).toEqual("1,2,3")
|
||||
})
|
||||
it("should handle null values", () => {
|
||||
// expect it to handle where the binding is null
|
||||
expect(
|
||||
typecastForLooping({ option: LoopStepType.ARRAY, binding: null })
|
||||
).toEqual(null)
|
||||
expect(() =>
|
||||
typecastForLooping({ option: LoopStepType.ARRAY, binding: "test" })
|
||||
).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe("cleanInputValues", () => {
|
||||
it("should handle array relationship fields from read binding", () => {
|
||||
const schema = {
|
||||
|
@ -70,15 +43,12 @@ describe("automationUtils", () => {
|
|||
},
|
||||
}
|
||||
expect(
|
||||
cleanInputValues(
|
||||
{
|
||||
row: {
|
||||
relationship: `[{"_id": "ro_ta_users_us_3"}]`,
|
||||
},
|
||||
schema,
|
||||
cleanInputValues({
|
||||
row: {
|
||||
relationship: `[{"_id": "ro_ta_users_us_3"}]`,
|
||||
},
|
||||
schema
|
||||
)
|
||||
schema,
|
||||
})
|
||||
).toEqual({
|
||||
row: {
|
||||
relationship: [{ _id: "ro_ta_users_us_3" }],
|
||||
|
@ -103,15 +73,12 @@ describe("automationUtils", () => {
|
|||
},
|
||||
}
|
||||
expect(
|
||||
cleanInputValues(
|
||||
{
|
||||
row: {
|
||||
relationship: `ro_ta_users_us_3`,
|
||||
},
|
||||
schema,
|
||||
cleanInputValues({
|
||||
row: {
|
||||
relationship: `ro_ta_users_us_3`,
|
||||
},
|
||||
schema
|
||||
)
|
||||
schema,
|
||||
})
|
||||
).toEqual({
|
||||
row: {
|
||||
relationship: "ro_ta_users_us_3",
|
||||
|
@ -122,28 +89,27 @@ describe("automationUtils", () => {
|
|||
|
||||
it("should be able to clean inputs with the utilities", () => {
|
||||
// can't clean without a schema
|
||||
let output = cleanInputValues({ a: "1" })
|
||||
expect(output.a).toBe("1")
|
||||
output = cleanInputValues(
|
||||
const one = cleanInputValues({ a: "1" })
|
||||
expect(one.a).toBe("1")
|
||||
|
||||
const two = cleanInputValues(
|
||||
{ a: "1", b: "true", c: "false", d: 1, e: "help" },
|
||||
{
|
||||
properties: {
|
||||
a: {
|
||||
type: "number",
|
||||
},
|
||||
b: {
|
||||
type: "boolean",
|
||||
},
|
||||
c: {
|
||||
type: "boolean",
|
||||
},
|
||||
a: {
|
||||
type: AutomationIOType.NUMBER,
|
||||
},
|
||||
b: {
|
||||
type: AutomationIOType.BOOLEAN,
|
||||
},
|
||||
c: {
|
||||
type: AutomationIOType.BOOLEAN,
|
||||
},
|
||||
}
|
||||
)
|
||||
expect(output.a).toBe(1)
|
||||
expect(output.b).toBe(true)
|
||||
expect(output.c).toBe(false)
|
||||
expect(output.d).toBe(1)
|
||||
expect(two.a).toBe(1)
|
||||
expect(two.b).toBe(true)
|
||||
expect(two.c).toBe(false)
|
||||
expect(two.d).toBe(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import * as automation from "../index"
|
||||
import { LoopStepType, FieldType, Table, Datasource } from "@budibase/types"
|
||||
import {
|
||||
LoopStepType,
|
||||
FieldType,
|
||||
Table,
|
||||
Datasource,
|
||||
FilterCondition,
|
||||
} from "@budibase/types"
|
||||
import { createAutomationBuilder } from "./utilities/AutomationTestBuilder"
|
||||
import {
|
||||
DatabaseName,
|
||||
|
@ -7,12 +13,9 @@ import {
|
|||
} from "../../integrations/tests/utils"
|
||||
import { Knex } from "knex"
|
||||
import { generator } from "@budibase/backend-core/tests"
|
||||
import { automations } from "@budibase/shared-core"
|
||||
import TestConfiguration from "../../tests/utilities/TestConfiguration"
|
||||
import { basicTable } from "../../tests/utilities/structures"
|
||||
|
||||
const FilterConditions = automations.steps.filter.FilterConditions
|
||||
|
||||
describe("Automation Scenarios", () => {
|
||||
const config = new TestConfiguration()
|
||||
|
||||
|
@ -256,7 +259,7 @@ describe("Automation Scenarios", () => {
|
|||
})
|
||||
.filter({
|
||||
field: "{{ steps.2.rows.0.value }}",
|
||||
condition: FilterConditions.EQUAL,
|
||||
condition: FilterCondition.EQUAL,
|
||||
value: 20,
|
||||
})
|
||||
.serverLog({ text: "Equal condition met" })
|
||||
|
@ -282,7 +285,7 @@ describe("Automation Scenarios", () => {
|
|||
})
|
||||
.filter({
|
||||
field: "{{ steps.2.rows.0.value }}",
|
||||
condition: FilterConditions.NOT_EQUAL,
|
||||
condition: FilterCondition.NOT_EQUAL,
|
||||
value: 20,
|
||||
})
|
||||
.serverLog({ text: "Not Equal condition met" })
|
||||
|
@ -295,37 +298,37 @@ describe("Automation Scenarios", () => {
|
|||
|
||||
const testCases = [
|
||||
{
|
||||
condition: FilterConditions.EQUAL,
|
||||
condition: FilterCondition.EQUAL,
|
||||
value: 10,
|
||||
rowValue: 10,
|
||||
expectPass: true,
|
||||
},
|
||||
{
|
||||
condition: FilterConditions.NOT_EQUAL,
|
||||
condition: FilterCondition.NOT_EQUAL,
|
||||
value: 10,
|
||||
rowValue: 20,
|
||||
expectPass: true,
|
||||
},
|
||||
{
|
||||
condition: FilterConditions.GREATER_THAN,
|
||||
condition: FilterCondition.GREATER_THAN,
|
||||
value: 10,
|
||||
rowValue: 15,
|
||||
expectPass: true,
|
||||
},
|
||||
{
|
||||
condition: FilterConditions.LESS_THAN,
|
||||
condition: FilterCondition.LESS_THAN,
|
||||
value: 10,
|
||||
rowValue: 5,
|
||||
expectPass: true,
|
||||
},
|
||||
{
|
||||
condition: FilterConditions.GREATER_THAN,
|
||||
condition: FilterCondition.GREATER_THAN,
|
||||
value: 10,
|
||||
rowValue: 5,
|
||||
expectPass: false,
|
||||
},
|
||||
{
|
||||
condition: FilterConditions.LESS_THAN,
|
||||
condition: FilterCondition.LESS_THAN,
|
||||
value: 10,
|
||||
rowValue: 15,
|
||||
expectPass: false,
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
} from "../../../tests/utilities/structures"
|
||||
import { objectStore } from "@budibase/backend-core"
|
||||
import { createAutomationBuilder } from "../utilities/AutomationTestBuilder"
|
||||
import { Row, Table } from "@budibase/types"
|
||||
import { FilterCondition, Row, Table } from "@budibase/types"
|
||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||
|
||||
async function uploadTestFile(filename: string) {
|
||||
|
@ -90,7 +90,7 @@ describe("test the create row action", () => {
|
|||
.createRow({ row: {} }, { stepName: "CreateRow" })
|
||||
.filter({
|
||||
field: "{{ stepsByName.CreateRow.success }}",
|
||||
condition: "equal",
|
||||
condition: FilterCondition.EQUAL,
|
||||
value: true,
|
||||
})
|
||||
.serverLog(
|
||||
|
@ -131,7 +131,7 @@ describe("test the create row action", () => {
|
|||
.createRow({ row: attachmentRow }, { stepName: "CreateRow" })
|
||||
.filter({
|
||||
field: "{{ stepsByName.CreateRow.success }}",
|
||||
condition: "equal",
|
||||
condition: FilterCondition.EQUAL,
|
||||
value: true,
|
||||
})
|
||||
.serverLog(
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
import { automations } from "@budibase/shared-core"
|
||||
import { createAutomationBuilder } from "../utilities/AutomationTestBuilder"
|
||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||
import { FilterCondition } from "@budibase/types"
|
||||
|
||||
const FilterConditions = automations.steps.filter.FilterConditions
|
||||
|
||||
function stringToFilterCondition(condition: "==" | "!=" | ">" | "<"): string {
|
||||
function stringToFilterCondition(
|
||||
condition: "==" | "!=" | ">" | "<"
|
||||
): FilterCondition {
|
||||
switch (condition) {
|
||||
case "==":
|
||||
return FilterConditions.EQUAL
|
||||
return FilterCondition.EQUAL
|
||||
case "!=":
|
||||
return FilterConditions.NOT_EQUAL
|
||||
return FilterCondition.NOT_EQUAL
|
||||
case ">":
|
||||
return FilterConditions.GREATER_THAN
|
||||
return FilterCondition.GREATER_THAN
|
||||
case "<":
|
||||
return FilterConditions.LESS_THAN
|
||||
return FilterCondition.LESS_THAN
|
||||
default:
|
||||
throw new Error(`Unsupported condition: ${condition}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import {
|
|||
ServerLogStepOutputs,
|
||||
CreateRowStepOutputs,
|
||||
FieldType,
|
||||
FilterCondition,
|
||||
} from "@budibase/types"
|
||||
import * as loopUtils from "../../loopUtils"
|
||||
import { createAutomationBuilder } from "../utilities/AutomationTestBuilder"
|
||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||
|
||||
|
@ -30,8 +30,8 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
await config.api.row.save(table._id!, {})
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
automation.shutdown()
|
||||
afterAll(async () => {
|
||||
await automation.shutdown()
|
||||
config.end()
|
||||
})
|
||||
|
||||
|
@ -535,97 +535,30 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
expect(results.steps[2].outputs.rows).toHaveLength(0)
|
||||
})
|
||||
|
||||
describe("replaceFakeBindings", () => {
|
||||
it("should replace loop bindings in nested objects", () => {
|
||||
const originalStepInput = {
|
||||
schema: {
|
||||
name: {
|
||||
type: "string",
|
||||
constraints: {
|
||||
type: "string",
|
||||
length: { maximum: null },
|
||||
presence: false,
|
||||
},
|
||||
name: "name",
|
||||
display: { type: "Text" },
|
||||
},
|
||||
},
|
||||
row: {
|
||||
tableId: "ta_aaad4296e9f74b12b1b90ef7a84afcad",
|
||||
name: "{{ loop.currentItem.pokemon }}",
|
||||
},
|
||||
}
|
||||
describe("loop output", () => {
|
||||
it("should not output anything if a filter stops the automation", async () => {
|
||||
const results = await createAutomationBuilder(config)
|
||||
.onAppAction()
|
||||
.filter({
|
||||
condition: FilterCondition.EQUAL,
|
||||
field: "1",
|
||||
value: "2",
|
||||
})
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: [1, 2, 3],
|
||||
})
|
||||
.serverLog({ text: "Message {{loop.currentItem}}" })
|
||||
.test({ fields: {} })
|
||||
|
||||
const loopStepNumber = 3
|
||||
|
||||
const result = loopUtils.replaceFakeBindings(
|
||||
originalStepInput,
|
||||
loopStepNumber
|
||||
)
|
||||
|
||||
expect(result).toEqual({
|
||||
schema: {
|
||||
name: {
|
||||
type: "string",
|
||||
constraints: {
|
||||
type: "string",
|
||||
length: { maximum: null },
|
||||
presence: false,
|
||||
},
|
||||
name: "name",
|
||||
display: { type: "Text" },
|
||||
},
|
||||
},
|
||||
row: {
|
||||
tableId: "ta_aaad4296e9f74b12b1b90ef7a84afcad",
|
||||
name: "{{ steps.3.currentItem.pokemon }}",
|
||||
},
|
||||
expect(results.steps.length).toBe(1)
|
||||
expect(results.steps[0].outputs).toEqual({
|
||||
comparisonValue: 2,
|
||||
refValue: 1,
|
||||
result: false,
|
||||
success: true,
|
||||
status: "stopped",
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle null values in nested objects", () => {
|
||||
const originalStepInput = {
|
||||
nullValue: null,
|
||||
nestedNull: {
|
||||
someKey: null,
|
||||
},
|
||||
validValue: "{{ loop.someValue }}",
|
||||
}
|
||||
|
||||
const loopStepNumber = 2
|
||||
|
||||
const result = loopUtils.replaceFakeBindings(
|
||||
originalStepInput,
|
||||
loopStepNumber
|
||||
)
|
||||
|
||||
expect(result).toEqual({
|
||||
nullValue: null,
|
||||
nestedNull: {
|
||||
someKey: null,
|
||||
},
|
||||
validValue: "{{ steps.2.someValue }}",
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle empty objects and arrays", () => {
|
||||
const originalStepInput = {
|
||||
emptyObject: {},
|
||||
emptyArray: [],
|
||||
nestedEmpty: {
|
||||
emptyObj: {},
|
||||
emptyArr: [],
|
||||
},
|
||||
}
|
||||
|
||||
const loopStepNumber = 1
|
||||
|
||||
const result = loopUtils.replaceFakeBindings(
|
||||
originalStepInput,
|
||||
loopStepNumber
|
||||
)
|
||||
|
||||
expect(result).toEqual(originalStepInput)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -66,7 +66,7 @@ describe("cron trigger", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("should stop if the job fails more than 3 times", async () => {
|
||||
it("should stop if the job fails more than N times", async () => {
|
||||
const { automation } = await createAutomationBuilder(config)
|
||||
.onCron({ cron: "* * * * *" })
|
||||
.queryRows({
|
||||
|
|
|
@ -5,7 +5,7 @@ import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
|||
|
||||
mocks.licenses.useSyncAutomations()
|
||||
|
||||
describe("Branching automations", () => {
|
||||
describe("Webhook trigger test", () => {
|
||||
const config = new TestConfiguration()
|
||||
let table: Table
|
||||
let webhook: Webhook
|
||||
|
|
|
@ -63,6 +63,7 @@ class TriggerBuilder {
|
|||
onRowDeleted = this.trigger(AutomationTriggerStepId.ROW_DELETED)
|
||||
onWebhook = this.trigger(AutomationTriggerStepId.WEBHOOK)
|
||||
onCron = this.trigger(AutomationTriggerStepId.CRON)
|
||||
onRowAction = this.trigger(AutomationTriggerStepId.ROW_ACTION)
|
||||
}
|
||||
|
||||
class BranchStepBuilder<TStep extends AutomationTriggerStepId> {
|
||||
|
|
|
@ -182,11 +182,12 @@ export async function externalTrigger(
|
|||
// values are likely to be submitted as strings, so we shall convert to correct type
|
||||
const coercedFields: any = {}
|
||||
const fields = automation.definition.trigger.inputs.fields
|
||||
for (let key of Object.keys(fields || {})) {
|
||||
for (const key of Object.keys(fields || {})) {
|
||||
coercedFields[key] = coerce(params.fields[key], fields[key])
|
||||
}
|
||||
params.fields = coercedFields
|
||||
}
|
||||
|
||||
// row actions and webhooks flatten the fields down
|
||||
else if (
|
||||
sdk.automations.isRowAction(automation) ||
|
||||
|
@ -198,6 +199,7 @@ export async function externalTrigger(
|
|||
fields: {},
|
||||
}
|
||||
}
|
||||
|
||||
const data: AutomationData = { automation, event: params }
|
||||
|
||||
const shouldTrigger = await checkTriggerFilters(automation, {
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
import { automationsEnabled } from "../features"
|
||||
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
||||
import tracer from "dd-trace"
|
||||
import { JobId } from "bull"
|
||||
|
||||
const CRON_STEP_ID = automations.triggers.definitions.CRON.stepId
|
||||
let Runner: Thread
|
||||
|
@ -155,11 +156,11 @@ export async function disableAllCrons(appId: any) {
|
|||
return { count: results.length / 2 }
|
||||
}
|
||||
|
||||
export async function disableCronById(jobId: number | string) {
|
||||
const repeatJobs = await automationQueue.getRepeatableJobs()
|
||||
for (let repeatJob of repeatJobs) {
|
||||
if (repeatJob.id === jobId) {
|
||||
await automationQueue.removeRepeatableByKey(repeatJob.key)
|
||||
export async function disableCronById(jobId: JobId) {
|
||||
const jobs = await automationQueue.getRepeatableJobs()
|
||||
for (const job of jobs) {
|
||||
if (job.id === jobId) {
|
||||
await automationQueue.removeRepeatableByKey(job.key)
|
||||
}
|
||||
}
|
||||
console.log(`jobId=${jobId} disabled`)
|
||||
|
@ -248,33 +249,3 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
|
|||
export async function cleanupAutomations(appId: any) {
|
||||
await disableAllCrons(appId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the supplied automation is of a recurring type.
|
||||
* @param automation The automation to check.
|
||||
* @return if it is recurring (cron).
|
||||
*/
|
||||
export function isRecurring(automation: Automation) {
|
||||
return (
|
||||
automation.definition.trigger.stepId ===
|
||||
automations.triggers.definitions.CRON.stepId
|
||||
)
|
||||
}
|
||||
|
||||
export function isErrorInOutput(output: {
|
||||
steps: { outputs?: { success: boolean } }[]
|
||||
}) {
|
||||
let first = true,
|
||||
error = false
|
||||
for (let step of output.steps) {
|
||||
// skip the trigger, its always successful if automation ran
|
||||
if (first) {
|
||||
first = false
|
||||
continue
|
||||
}
|
||||
if (!step.outputs?.success) {
|
||||
error = true
|
||||
}
|
||||
}
|
||||
return error
|
||||
}
|
||||
|
|
|
@ -130,11 +130,6 @@ export enum InvalidColumns {
|
|||
TABLE_ID = "tableId",
|
||||
}
|
||||
|
||||
export enum AutomationErrors {
|
||||
INCORRECT_TYPE = "INCORRECT_TYPE",
|
||||
FAILURE_CONDITION = "FAILURE_CONDITION_MET",
|
||||
}
|
||||
|
||||
// pass through the list from the auth/core lib
|
||||
export const ObjectStoreBuckets = objectStore.ObjectStoreBuckets
|
||||
export const MAX_AUTOMATION_RECURRING_ERRORS = 5
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { AutomationResults, LoopStepType, UserBindings } from "@budibase/types"
|
||||
import {
|
||||
AutomationStepResultOutputs,
|
||||
AutomationTriggerResultOutputs,
|
||||
LoopStepType,
|
||||
UserBindings,
|
||||
} from "@budibase/types"
|
||||
|
||||
export interface LoopInput {
|
||||
option: LoopStepType
|
||||
|
@ -13,19 +18,17 @@ export interface TriggerOutput {
|
|||
timestamp?: number
|
||||
}
|
||||
|
||||
export interface AutomationContext extends AutomationResults {
|
||||
steps: any[]
|
||||
stepsById: Record<string, any>
|
||||
stepsByName: Record<string, any>
|
||||
export interface AutomationContext {
|
||||
trigger: AutomationTriggerResultOutputs
|
||||
steps: [AutomationTriggerResultOutputs, ...AutomationStepResultOutputs[]]
|
||||
stepsById: Record<string, AutomationStepResultOutputs>
|
||||
stepsByName: Record<string, AutomationStepResultOutputs>
|
||||
env?: Record<string, string>
|
||||
user?: UserBindings
|
||||
trigger: any
|
||||
settings?: {
|
||||
url?: string
|
||||
logo?: string
|
||||
company?: string
|
||||
}
|
||||
loop?: { currentItem: any }
|
||||
}
|
||||
|
||||
export interface AutomationResponse
|
||||
extends Omit<AutomationContext, "stepsByName" | "stepsById"> {}
|
||||
|
|
|
@ -40,7 +40,8 @@ function cleanAutomationInputs(automation: Automation) {
|
|||
if (step == null) {
|
||||
continue
|
||||
}
|
||||
for (let inputName of Object.keys(step.inputs)) {
|
||||
for (const key of Object.keys(step.inputs)) {
|
||||
const inputName = key as keyof typeof step.inputs
|
||||
if (!step.inputs[inputName] || step.inputs[inputName] === "") {
|
||||
delete step.inputs[inputName]
|
||||
}
|
||||
|
@ -281,7 +282,8 @@ function guardInvalidUpdatesAndThrow(
|
|||
const readonlyFields = Object.keys(
|
||||
step.schema.inputs.properties || {}
|
||||
).filter(k => step.schema.inputs.properties[k].readonly)
|
||||
readonlyFields.forEach(readonlyField => {
|
||||
readonlyFields.forEach(key => {
|
||||
const readonlyField = key as keyof typeof step.inputs
|
||||
const oldStep = oldStepDefinitions.find(i => i.id === step.id)
|
||||
if (step.inputs[readonlyField] !== oldStep?.inputs[readonlyField]) {
|
||||
throw new HTTPError(
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
import { sample } from "lodash/fp"
|
||||
import { Automation } from "@budibase/types"
|
||||
import { generator } from "@budibase/backend-core/tests"
|
||||
import TestConfiguration from "../../../../tests/utilities/TestConfiguration"
|
||||
import automationSdk from "../"
|
||||
import { structures } from "../../../../api/routes/tests/utilities"
|
||||
|
||||
describe("automation sdk", () => {
|
||||
const config = new TestConfiguration()
|
||||
|
||||
beforeAll(async () => {
|
||||
await config.init()
|
||||
})
|
||||
|
||||
describe("update", () => {
|
||||
it("can rename existing automations", async () => {
|
||||
await config.doInContext(config.getAppId(), async () => {
|
||||
const automation = structures.newAutomation()
|
||||
|
||||
const response = await automationSdk.create(automation)
|
||||
|
||||
const newName = generator.guid()
|
||||
const update = { ...response, name: newName }
|
||||
const result = await automationSdk.update(update)
|
||||
expect(result.name).toEqual(newName)
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
["trigger", (a: Automation) => a.definition.trigger],
|
||||
["step", (a: Automation) => a.definition.steps[0]],
|
||||
])("can update input fields (for a %s)", async (_, getStep) => {
|
||||
await config.doInContext(config.getAppId(), async () => {
|
||||
const automation = structures.newAutomation()
|
||||
|
||||
const keyToUse = sample(Object.keys(getStep(automation).inputs))!
|
||||
getStep(automation).inputs[keyToUse] = "anyValue"
|
||||
|
||||
const response = await automationSdk.create(automation)
|
||||
|
||||
const update = { ...response }
|
||||
getStep(update).inputs[keyToUse] = "anyUpdatedValue"
|
||||
const result = await automationSdk.update(update)
|
||||
expect(getStep(result).inputs[keyToUse]).toEqual("anyUpdatedValue")
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
["trigger", (a: Automation) => a.definition.trigger],
|
||||
["step", (a: Automation) => a.definition.steps[0]],
|
||||
])("cannot update readonly fields (for a %s)", async (_, getStep) => {
|
||||
await config.doInContext(config.getAppId(), async () => {
|
||||
const automation = structures.newAutomation()
|
||||
getStep(automation).schema.inputs.properties["readonlyProperty"] = {
|
||||
readonly: true,
|
||||
}
|
||||
getStep(automation).inputs["readonlyProperty"] = "anyValue"
|
||||
|
||||
const response = await automationSdk.create(automation)
|
||||
|
||||
const update = { ...response }
|
||||
getStep(update).inputs["readonlyProperty"] = "anyUpdatedValue"
|
||||
await expect(automationSdk.update(update)).rejects.toThrow(
|
||||
"Field readonlyProperty is readonly and it cannot be modified"
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -35,6 +35,8 @@ import {
|
|||
WebhookActionType,
|
||||
BuiltinPermissionID,
|
||||
DeepPartial,
|
||||
FilterCondition,
|
||||
AutomationTriggerResult,
|
||||
} from "@budibase/types"
|
||||
import { LoopInput } from "../../definitions/automations"
|
||||
import { merge } from "lodash"
|
||||
|
@ -372,7 +374,11 @@ export function filterAutomation(opts?: DeepPartial<Automation>): Automation {
|
|||
type: AutomationStepType.ACTION,
|
||||
internal: true,
|
||||
stepId: AutomationActionStepId.FILTER,
|
||||
inputs: { field: "name", value: "test", condition: "EQ" },
|
||||
inputs: {
|
||||
field: "name",
|
||||
value: "test",
|
||||
condition: FilterCondition.EQUAL,
|
||||
},
|
||||
schema: BUILTIN_ACTION_DEFINITIONS.EXECUTE_SCRIPT.schema,
|
||||
},
|
||||
],
|
||||
|
@ -437,15 +443,24 @@ export function updateRowAutomationWithFilters(
|
|||
export function basicAutomationResults(
|
||||
automationId: string
|
||||
): AutomationResults {
|
||||
const trigger: AutomationTriggerResult = {
|
||||
id: "trigger",
|
||||
stepId: AutomationTriggerStepId.APP,
|
||||
outputs: {},
|
||||
}
|
||||
return {
|
||||
automationId,
|
||||
status: AutomationStatus.SUCCESS,
|
||||
trigger: "trigger" as any,
|
||||
trigger,
|
||||
steps: [
|
||||
trigger,
|
||||
{
|
||||
id: "step1",
|
||||
stepId: AutomationActionStepId.SERVER_LOG,
|
||||
inputs: {},
|
||||
outputs: {},
|
||||
outputs: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,20 +3,14 @@ import {
|
|||
AutomationStepDefinition,
|
||||
AutomationStepType,
|
||||
AutomationIOType,
|
||||
FilterCondition,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const FilterConditions = {
|
||||
EQUAL: "EQUAL",
|
||||
NOT_EQUAL: "NOT_EQUAL",
|
||||
GREATER_THAN: "GREATER_THAN",
|
||||
LESS_THAN: "LESS_THAN",
|
||||
}
|
||||
|
||||
export const PrettyFilterConditions = {
|
||||
[FilterConditions.EQUAL]: "Equals",
|
||||
[FilterConditions.NOT_EQUAL]: "Not equals",
|
||||
[FilterConditions.GREATER_THAN]: "Greater than",
|
||||
[FilterConditions.LESS_THAN]: "Less than",
|
||||
[FilterCondition.EQUAL]: "Equals",
|
||||
[FilterCondition.NOT_EQUAL]: "Not equals",
|
||||
[FilterCondition.GREATER_THAN]: "Greater than",
|
||||
[FilterCondition.LESS_THAN]: "Less than",
|
||||
}
|
||||
|
||||
export const definition: AutomationStepDefinition = {
|
||||
|
@ -30,7 +24,7 @@ export const definition: AutomationStepDefinition = {
|
|||
features: {},
|
||||
stepId: AutomationActionStepId.FILTER,
|
||||
inputs: {
|
||||
condition: FilterConditions.EQUAL,
|
||||
condition: FilterCondition.EQUAL,
|
||||
},
|
||||
schema: {
|
||||
inputs: {
|
||||
|
@ -42,7 +36,7 @@ export const definition: AutomationStepDefinition = {
|
|||
condition: {
|
||||
type: AutomationIOType.STRING,
|
||||
title: "Condition",
|
||||
enum: Object.values(FilterConditions),
|
||||
enum: Object.values(FilterCondition),
|
||||
pretty: Object.values(PrettyFilterConditions),
|
||||
},
|
||||
value: {
|
||||
|
|
|
@ -105,10 +105,10 @@ export function cancelableTimeout(
|
|||
|
||||
export async function withTimeout<T>(
|
||||
timeout: number,
|
||||
promise: Promise<T>
|
||||
promise: () => Promise<T>
|
||||
): Promise<T> {
|
||||
const [timeoutPromise, cancel] = cancelableTimeout(timeout)
|
||||
const result = (await Promise.race([promise, timeoutPromise])) as T
|
||||
const result = (await Promise.race([promise(), timeoutPromise])) as T
|
||||
cancel()
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -7,8 +7,20 @@ import {
|
|||
} from "../../../sdk"
|
||||
import { HttpMethod } from "../query"
|
||||
import { Row } from "../row"
|
||||
import { LoopStepType, EmailAttachment, AutomationResults } from "./automation"
|
||||
import { AutomationStep, AutomationStepOutputs } from "./schema"
|
||||
import {
|
||||
LoopStepType,
|
||||
EmailAttachment,
|
||||
AutomationResults,
|
||||
AutomationStepResult,
|
||||
} from "./automation"
|
||||
import { AutomationStep } from "./schema"
|
||||
|
||||
export enum FilterCondition {
|
||||
EQUAL = "EQUAL",
|
||||
NOT_EQUAL = "NOT_EQUAL",
|
||||
GREATER_THAN = "GREATER_THAN",
|
||||
LESS_THAN = "LESS_THAN",
|
||||
}
|
||||
|
||||
export type BaseAutomationOutputs = {
|
||||
success?: boolean
|
||||
|
@ -92,7 +104,7 @@ export type ExecuteScriptStepOutputs = BaseAutomationOutputs & {
|
|||
|
||||
export type FilterStepInputs = {
|
||||
field: any
|
||||
condition: string
|
||||
condition: FilterCondition
|
||||
value: any
|
||||
}
|
||||
|
||||
|
@ -110,7 +122,7 @@ export type LoopStepInputs = {
|
|||
}
|
||||
|
||||
export type LoopStepOutputs = {
|
||||
items: AutomationStepOutputs[]
|
||||
items: AutomationStepResult[]
|
||||
success: boolean
|
||||
iterations: number
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ export interface Automation extends Document {
|
|||
}
|
||||
}
|
||||
|
||||
interface BaseIOStructure {
|
||||
export interface BaseIOStructure {
|
||||
type?: AutomationIOType
|
||||
subtype?: AutomationIOType
|
||||
customType?: AutomationCustomIOType
|
||||
|
@ -176,6 +176,8 @@ export enum AutomationFeature {
|
|||
export enum AutomationStepStatus {
|
||||
NO_ITERATIONS = "no_iterations",
|
||||
MAX_ITERATIONS = "max_iterations_reached",
|
||||
FAILURE_CONDITION = "FAILURE_CONDITION_MET",
|
||||
INCORRECT_TYPE = "INCORRECT_TYPE",
|
||||
}
|
||||
|
||||
export enum AutomationStatus {
|
||||
|
@ -190,19 +192,37 @@ export enum AutomationStoppedReason {
|
|||
TRIGGER_FILTER_NOT_MET = "Automation did not run. Filter conditions in trigger were not met.",
|
||||
}
|
||||
|
||||
export interface AutomationStepResultOutputs {
|
||||
success: boolean
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface AutomationStepResultInputs {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface AutomationStepResult {
|
||||
id: string
|
||||
stepId: AutomationActionStepId
|
||||
inputs: AutomationStepResultInputs
|
||||
outputs: AutomationStepResultOutputs
|
||||
}
|
||||
|
||||
export type AutomationTriggerResultInputs = Record<string, any>
|
||||
export type AutomationTriggerResultOutputs = Record<string, any>
|
||||
|
||||
export interface AutomationTriggerResult {
|
||||
id: string
|
||||
stepId: AutomationTriggerStepId
|
||||
inputs?: AutomationTriggerResultInputs | null
|
||||
outputs: AutomationTriggerResultOutputs
|
||||
}
|
||||
|
||||
export interface AutomationResults {
|
||||
automationId?: string
|
||||
status?: AutomationStatus
|
||||
trigger?: AutomationTrigger
|
||||
steps: {
|
||||
stepId: AutomationTriggerStepId | AutomationActionStepId
|
||||
inputs: {
|
||||
[key: string]: any
|
||||
}
|
||||
outputs: {
|
||||
[key: string]: any
|
||||
}
|
||||
}[]
|
||||
trigger: AutomationTriggerResult
|
||||
steps: [AutomationTriggerResult, ...AutomationStepResult[]]
|
||||
}
|
||||
|
||||
export interface DidNotTriggerResponse {
|
||||
|
@ -236,6 +256,7 @@ export type ActionImplementation<TInputs, TOutputs> = (
|
|||
inputs: TInputs
|
||||
} & AutomationStepInputBase
|
||||
) => Promise<TOutputs>
|
||||
|
||||
export interface AutomationMetadata extends Document {
|
||||
errorCount?: number
|
||||
automationChainCount?: number
|
||||
|
|
|
@ -164,24 +164,6 @@ export interface AutomationStepSchemaBase {
|
|||
features?: Partial<Record<AutomationFeature, boolean>>
|
||||
}
|
||||
|
||||
export type AutomationStepOutputs =
|
||||
| CollectStepOutputs
|
||||
| CreateRowStepOutputs
|
||||
| DelayStepOutputs
|
||||
| DeleteRowStepOutputs
|
||||
| ExecuteQueryStepOutputs
|
||||
| ExecuteScriptStepOutputs
|
||||
| FilterStepOutputs
|
||||
| QueryRowsStepOutputs
|
||||
| BaseAutomationOutputs
|
||||
| BashStepOutputs
|
||||
| ExternalAppStepOutputs
|
||||
| OpenAIStepOutputs
|
||||
| ServerLogStepOutputs
|
||||
| TriggerAutomationStepOutputs
|
||||
| UpdateRowStepOutputs
|
||||
| ZapierStepOutputs
|
||||
|
||||
export type AutomationStepInputs<T extends AutomationActionStepId> =
|
||||
T extends AutomationActionStepId.COLLECT
|
||||
? CollectStepInputs
|
||||
|
@ -229,11 +211,56 @@ export type AutomationStepInputs<T extends AutomationActionStepId> =
|
|||
? BranchStepInputs
|
||||
: never
|
||||
|
||||
export type AutomationStepOutputs<T extends AutomationActionStepId> =
|
||||
T extends AutomationActionStepId.COLLECT
|
||||
? CollectStepOutputs
|
||||
: T extends AutomationActionStepId.CREATE_ROW
|
||||
? CreateRowStepOutputs
|
||||
: T extends AutomationActionStepId.DELAY
|
||||
? DelayStepOutputs
|
||||
: T extends AutomationActionStepId.DELETE_ROW
|
||||
? DeleteRowStepOutputs
|
||||
: T extends AutomationActionStepId.EXECUTE_QUERY
|
||||
? ExecuteQueryStepOutputs
|
||||
: T extends AutomationActionStepId.EXECUTE_SCRIPT
|
||||
? ExecuteScriptStepOutputs
|
||||
: T extends AutomationActionStepId.FILTER
|
||||
? FilterStepOutputs
|
||||
: T extends AutomationActionStepId.QUERY_ROWS
|
||||
? QueryRowsStepOutputs
|
||||
: T extends AutomationActionStepId.SEND_EMAIL_SMTP
|
||||
? BaseAutomationOutputs
|
||||
: T extends AutomationActionStepId.SERVER_LOG
|
||||
? ServerLogStepOutputs
|
||||
: T extends AutomationActionStepId.TRIGGER_AUTOMATION_RUN
|
||||
? TriggerAutomationStepOutputs
|
||||
: T extends AutomationActionStepId.UPDATE_ROW
|
||||
? UpdateRowStepOutputs
|
||||
: T extends AutomationActionStepId.OUTGOING_WEBHOOK
|
||||
? ExternalAppStepOutputs
|
||||
: T extends AutomationActionStepId.discord
|
||||
? ExternalAppStepOutputs
|
||||
: T extends AutomationActionStepId.slack
|
||||
? ExternalAppStepOutputs
|
||||
: T extends AutomationActionStepId.zapier
|
||||
? ZapierStepOutputs
|
||||
: T extends AutomationActionStepId.integromat
|
||||
? ExternalAppStepOutputs
|
||||
: T extends AutomationActionStepId.n8n
|
||||
? ExternalAppStepOutputs
|
||||
: T extends AutomationActionStepId.EXECUTE_BASH
|
||||
? BashStepOutputs
|
||||
: T extends AutomationActionStepId.OPENAI
|
||||
? OpenAIStepOutputs
|
||||
: T extends AutomationActionStepId.LOOP
|
||||
? BaseAutomationOutputs
|
||||
: never
|
||||
|
||||
export interface AutomationStepSchema<TStep extends AutomationActionStepId>
|
||||
extends AutomationStepSchemaBase {
|
||||
id: string
|
||||
stepId: TStep
|
||||
inputs: AutomationStepInputs<TStep> & Record<string, any> // The record union to be removed once the types are fixed
|
||||
inputs: AutomationStepInputs<TStep>
|
||||
}
|
||||
|
||||
export type CollectStep = AutomationStepSchema<AutomationActionStepId.COLLECT>
|
||||
|
@ -315,6 +342,36 @@ export type AutomationStep =
|
|||
| OpenAIStep
|
||||
| BranchStep
|
||||
|
||||
export function isBranchStep(
|
||||
step: AutomationStep | AutomationTrigger
|
||||
): step is BranchStep {
|
||||
return step.stepId === AutomationActionStepId.BRANCH
|
||||
}
|
||||
|
||||
export function isTrigger(
|
||||
step: AutomationStep | AutomationTrigger
|
||||
): step is AutomationTrigger {
|
||||
return step.type === AutomationStepType.TRIGGER
|
||||
}
|
||||
|
||||
export function isRowUpdateTrigger(
|
||||
step: AutomationStep | AutomationTrigger
|
||||
): step is RowUpdatedTrigger {
|
||||
return step.stepId === AutomationTriggerStepId.ROW_UPDATED
|
||||
}
|
||||
|
||||
export function isRowSaveTrigger(
|
||||
step: AutomationStep | AutomationTrigger
|
||||
): step is RowSavedTrigger {
|
||||
return step.stepId === AutomationTriggerStepId.ROW_SAVED
|
||||
}
|
||||
|
||||
export function isAppTrigger(
|
||||
step: AutomationStep | AutomationTrigger
|
||||
): step is AppActionTrigger {
|
||||
return step.stepId === AutomationTriggerStepId.APP
|
||||
}
|
||||
|
||||
type EmptyInputs = {}
|
||||
export type AutomationStepDefinition = Omit<AutomationStep, "id" | "inputs"> & {
|
||||
inputs: EmptyInputs
|
||||
|
|
|
@ -82,6 +82,10 @@ type RangeFilter = Record<
|
|||
|
||||
type LogicalFilter = { conditions: SearchFilters[] }
|
||||
|
||||
export function isLogicalFilter(filter: any): filter is LogicalFilter {
|
||||
return "conditions" in filter
|
||||
}
|
||||
|
||||
export type AnySearchFilter = BasicFilter | ArrayFilter | RangeFilter
|
||||
|
||||
export interface SearchFilters {
|
||||
|
|
|
@ -28,6 +28,8 @@ export interface ComponentDefinition {
|
|||
width: number
|
||||
height: number
|
||||
}
|
||||
context?: ComponentContext | ComponentContext[]
|
||||
actions?: (string | any)[]
|
||||
}
|
||||
|
||||
export type DependsOnComponentSetting =
|
||||
|
@ -56,3 +58,28 @@ export interface ComponentSetting {
|
|||
self: boolean
|
||||
}
|
||||
}
|
||||
interface ComponentAction {
|
||||
type: string
|
||||
suffix?: string
|
||||
}
|
||||
|
||||
interface ComponentStaticContextValue {
|
||||
label: string
|
||||
key: string
|
||||
type: string // technically this is a long list of options but there are too many to enumerate
|
||||
}
|
||||
|
||||
export interface ComponentContext {
|
||||
type: ComponentContextType
|
||||
scope?: ComponentContextScopes
|
||||
actions?: ComponentAction[]
|
||||
suffix?: string
|
||||
values?: ComponentStaticContextValue[]
|
||||
}
|
||||
|
||||
export type ComponentContextType = "action" | "static" | "schema" | "form"
|
||||
|
||||
export const enum ComponentContextScopes {
|
||||
Local = "local",
|
||||
Global = "global",
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
export type PreviewDevice = "desktop" | "tablet" | "mobile"
|
||||
export type ComponentContext = Record<string, any>
|
||||
|
||||
export type AppContext = Record<string, any>
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
"koa-body": "4.2.0",
|
||||
"koa-compress": "4.0.1",
|
||||
"koa-passport": "4.1.4",
|
||||
"koa-redis": "^4.0.1",
|
||||
"koa-send": "5.0.1",
|
||||
"koa-session": "5.13.1",
|
||||
"koa-static": "5.0.0",
|
||||
|
@ -82,7 +83,6 @@
|
|||
"@swc/jest": "0.2.27",
|
||||
"@types/jest": "29.5.5",
|
||||
"@types/jsonwebtoken": "9.0.3",
|
||||
"@types/koa": "2.13.4",
|
||||
"@types/koa__router": "12.0.4",
|
||||
"@types/lodash": "4.14.200",
|
||||
"@types/node-fetch": "2.6.4",
|
||||
|
|
|
@ -311,7 +311,7 @@ describe("/api/global/auth", () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe("GET /api/global/auth/:tenantId/oidc/callback", () => {
|
||||
describe.skip("GET /api/global/auth/:tenantId/oidc/callback", () => {
|
||||
it("logs in", async () => {
|
||||
const email = `${generator.guid()}@example.com`
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ describe("/api/global/email", () => {
|
|||
) {
|
||||
let response, text
|
||||
try {
|
||||
await helpers.withTimeout(20000, config.saveEtherealSmtpConfig())
|
||||
await helpers.withTimeout(20000, config.saveSettingsConfig())
|
||||
await helpers.withTimeout(20000, () => config.saveEtherealSmtpConfig())
|
||||
await helpers.withTimeout(20000, () => config.saveSettingsConfig())
|
||||
let res
|
||||
if (attachments) {
|
||||
res = await config.api.emails
|
||||
|
|
|
@ -4,7 +4,7 @@ if (process.env.DD_APM_ENABLED) {
|
|||
|
||||
// need to load environment first
|
||||
import env from "./environment"
|
||||
import Application from "koa"
|
||||
import Application, { Middleware } from "koa"
|
||||
import { bootstrap } from "global-agent"
|
||||
import * as db from "./db"
|
||||
import { sdk as proSdk } from "@budibase/pro"
|
||||
|
@ -20,6 +20,7 @@ import {
|
|||
cache,
|
||||
features,
|
||||
} from "@budibase/backend-core"
|
||||
import RedisStore from "koa-redis"
|
||||
|
||||
db.init()
|
||||
import koaBody from "koa-body"
|
||||
|
@ -52,7 +53,28 @@ app.proxy = true
|
|||
app.use(handleScimBody)
|
||||
app.use(koaBody({ multipart: true }))
|
||||
|
||||
app.use(koaSession(app))
|
||||
const sessionMiddleware: Middleware = async (ctx: any, next: any) => {
|
||||
const redisClient = await new redis.Client(
|
||||
redis.utils.Databases.SESSIONS
|
||||
).init()
|
||||
return koaSession(
|
||||
{
|
||||
// @ts-ignore
|
||||
store: new RedisStore({ client: redisClient.getClient() }),
|
||||
key: "koa:sess",
|
||||
maxAge: 86400000, // one day
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "strict",
|
||||
rolling: true,
|
||||
renew: true,
|
||||
},
|
||||
app
|
||||
)(ctx, next)
|
||||
}
|
||||
|
||||
app.use(sessionMiddleware)
|
||||
|
||||
app.use(middleware.correlation)
|
||||
app.use(middleware.pino)
|
||||
app.use(middleware.ip)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
declare module "koa-redis" {}
|
34
yarn.lock
34
yarn.lock
|
@ -2695,6 +2695,13 @@
|
|||
dependencies:
|
||||
regenerator-runtime "^0.14.0"
|
||||
|
||||
"@babel/runtime@^7.8.3":
|
||||
version "7.26.9"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.9.tgz#aa4c6facc65b9cb3f87d75125ffd47781b475433"
|
||||
integrity sha512-aA63XwOkcl4xxQa3HjPMqOP6LiK0ZDv3mUPYEFXkpHbaFjtGggE1A61FjFzJnB+p7/oy2gA8E+rcBNl/zC1tMg==
|
||||
dependencies:
|
||||
regenerator-runtime "^0.14.0"
|
||||
|
||||
"@babel/template@^7.22.15", "@babel/template@^7.22.5", "@babel/template@^7.25.9", "@babel/template@^7.3.3":
|
||||
version "7.25.9"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.9.tgz#ecb62d81a8a6f5dc5fe8abfc3901fc52ddf15016"
|
||||
|
@ -2778,9 +2785,9 @@
|
|||
through2 "^2.0.0"
|
||||
|
||||
"@budibase/pro@npm:@budibase/pro@latest":
|
||||
version "3.4.6"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-3.4.6.tgz#62b6ee13a015b98d4768dc7821f468f8177da3e9"
|
||||
integrity sha512-MC3P5SMokmqbjejZMlNM6z7NB9o5H6hZ++yVvbyThniBPYfuDc2ssa1HNwwcuNE3uRLhcxcKe8CY/0SbFgn51g==
|
||||
version "3.4.12"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-3.4.12.tgz#60e630944de4e2de970a04179d8f0f57d48ce75e"
|
||||
integrity sha512-msUBmcWxRDg+ugjZvd27XudERQqtQRdiARsO8MaDVTcp5ejIXgshEIVVshHOCj3hcbRblw9pXvBIMI53iTMUsA==
|
||||
dependencies:
|
||||
"@anthropic-ai/sdk" "^0.27.3"
|
||||
"@budibase/backend-core" "*"
|
||||
|
@ -9041,7 +9048,14 @@ co-body@^5.1.1:
|
|||
raw-body "^2.2.0"
|
||||
type-is "^1.6.14"
|
||||
|
||||
co@^4.6.0:
|
||||
co-wrap-all@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/co-wrap-all/-/co-wrap-all-1.0.0.tgz#370ae3e8333510a53f6b2f7fdfbe4568a11b7ecf"
|
||||
integrity sha512-aru6gLi2vTUazr+MxVm3Rv6ST7/EKtFj9BrfkcOrbCO2Qv6LqJdE71m88HhHiBEviKw/ucVrwoGLrq2xHpOsJA==
|
||||
dependencies:
|
||||
co "^4.0.0"
|
||||
|
||||
co@^4.0.0, co@^4.6.0:
|
||||
version "4.6.0"
|
||||
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
|
||||
integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==
|
||||
|
@ -13177,7 +13191,7 @@ ioredis@5.3.2:
|
|||
redis-parser "^3.0.0"
|
||||
standard-as-callback "^2.1.0"
|
||||
|
||||
ioredis@^4.28.5:
|
||||
ioredis@^4.14.1, ioredis@^4.28.5:
|
||||
version "4.28.5"
|
||||
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f"
|
||||
integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A==
|
||||
|
@ -14677,6 +14691,16 @@ koa-pino-logger@4.0.0:
|
|||
dependencies:
|
||||
pino-http "^6.5.0"
|
||||
|
||||
koa-redis@^4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/koa-redis/-/koa-redis-4.0.1.tgz#57ac1b46d9ab851221a9f4952c1e8d4bf289db40"
|
||||
integrity sha512-o2eTVNo1NBnloeUGhHed5Q2ZvJSLpUEj/+E1/7oH5EmH8WuQ+QLdl/VawkshxdFQ47W1p6V09lM3hCTu7D0YnQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.8.3"
|
||||
co-wrap-all "^1.0.0"
|
||||
debug "^4.1.1"
|
||||
ioredis "^4.14.1"
|
||||
|
||||
koa-router@^10.0.0:
|
||||
version "10.1.1"
|
||||
resolved "https://registry.yarnpkg.com/koa-router/-/koa-router-10.1.1.tgz#20809f82648518b84726cd445037813cd99f17ff"
|
||||
|
|
Loading…
Reference in New Issue