Merge branch 'master' into chore/save_autofields_on_bulksaves
This commit is contained in:
commit
ff15b84429
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||||
"version": "2.29.25",
|
"version": "2.29.26",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
.map(automation => ({
|
.map(automation => ({
|
||||||
...automation,
|
...automation,
|
||||||
displayName:
|
displayName:
|
||||||
$automationStore.automationDisplayData[automation._id].displayName ||
|
$automationStore.automationDisplayData[automation._id]?.displayName ||
|
||||||
automation.name,
|
automation.name,
|
||||||
}))
|
}))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
|
|
||||||
$: nameError =
|
$: nameError =
|
||||||
nameTouched && !name ? "Please specify a name for the automation." : null
|
nameTouched && !name ? "Please specify a name for the automation." : null
|
||||||
$: triggers = Object.entries($automationStore.blockDefinitions.TRIGGER)
|
$: triggers = Object.entries(
|
||||||
|
$automationStore.blockDefinitions.CREATABLE_TRIGGER
|
||||||
|
)
|
||||||
|
|
||||||
async function createAutomation() {
|
async function createAutomation() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
const { datasource } = getContext("grid")
|
const { datasource } = getContext("grid")
|
||||||
|
|
||||||
$: triggers = $automationStore.blockDefinitions.TRIGGER
|
$: triggers = $automationStore.blockDefinitions.CREATABLE_TRIGGER
|
||||||
|
|
||||||
$: table = $tables.list.find(table => table._id === $datasource.tableId)
|
$: table = $tables.list.find(table => table._id === $datasource.tableId)
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,16 @@ import { generate } from "shortid"
|
||||||
import { createHistoryStore } from "stores/builder/history"
|
import { createHistoryStore } from "stores/builder/history"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { updateReferencesInObject } from "dataBinding"
|
import { updateReferencesInObject } from "dataBinding"
|
||||||
|
import { AutomationTriggerStepId } from "@budibase/types"
|
||||||
|
|
||||||
const initialAutomationState = {
|
const initialAutomationState = {
|
||||||
automations: [],
|
automations: [],
|
||||||
testResults: null,
|
testResults: null,
|
||||||
showTestPanel: false,
|
showTestPanel: false,
|
||||||
blockDefinitions: {
|
blockDefinitions: {
|
||||||
TRIGGER: [],
|
TRIGGER: {},
|
||||||
ACTION: [],
|
CREATABLE_TRIGGER: {},
|
||||||
|
ACTION: {},
|
||||||
},
|
},
|
||||||
selectedAutomationId: null,
|
selectedAutomationId: null,
|
||||||
automationDisplayData: {},
|
automationDisplayData: {},
|
||||||
|
@ -46,14 +48,29 @@ const updateStepReferences = (steps, modifiedIndex, action) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getFinalDefinitions = (triggers, actions) => {
|
||||||
|
const creatable = {}
|
||||||
|
Object.entries(triggers).forEach(entry => {
|
||||||
|
if (entry[0] === AutomationTriggerStepId.ROW_ACTION) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
creatable[entry[0]] = entry[1]
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
TRIGGER: triggers,
|
||||||
|
CREATABLE_TRIGGER: creatable,
|
||||||
|
ACTION: actions,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const automationActions = store => ({
|
const automationActions = store => ({
|
||||||
definitions: async () => {
|
definitions: async () => {
|
||||||
const response = await API.getAutomationDefinitions()
|
const response = await API.getAutomationDefinitions()
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.blockDefinitions = {
|
state.blockDefinitions = getFinalDefinitions(
|
||||||
TRIGGER: response.trigger,
|
response.trigger,
|
||||||
ACTION: response.action,
|
response.action
|
||||||
}
|
)
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
return response
|
return response
|
||||||
|
@ -69,10 +86,10 @@ const automationActions = store => ({
|
||||||
return a.name < b.name ? -1 : 1
|
return a.name < b.name ? -1 : 1
|
||||||
})
|
})
|
||||||
state.automationDisplayData = automationResponse.builderData
|
state.automationDisplayData = automationResponse.builderData
|
||||||
state.blockDefinitions = {
|
state.blockDefinitions = getFinalDefinitions(
|
||||||
TRIGGER: definitions.trigger,
|
definitions.trigger,
|
||||||
ACTION: definitions.action,
|
definitions.action
|
||||||
}
|
)
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,6 +14,7 @@ import sdk from "../../../sdk"
|
||||||
import { Automation, FieldType, Table } from "@budibase/types"
|
import { Automation, FieldType, Table } from "@budibase/types"
|
||||||
import { mocks } from "@budibase/backend-core/tests"
|
import { mocks } from "@budibase/backend-core/tests"
|
||||||
import { FilterConditions } from "../../../automations/steps/filter"
|
import { FilterConditions } from "../../../automations/steps/filter"
|
||||||
|
import { removeDeprecated } from "../../../automations/utils"
|
||||||
|
|
||||||
const MAX_RETRIES = 4
|
const MAX_RETRIES = 4
|
||||||
let {
|
let {
|
||||||
|
@ -69,14 +70,15 @@ describe("/automations", () => {
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
|
||||||
let definitionsLength = Object.keys(BUILTIN_ACTION_DEFINITIONS).length
|
let definitionsLength = Object.keys(
|
||||||
definitionsLength-- // OUTGOING_WEBHOOK is deprecated
|
removeDeprecated(BUILTIN_ACTION_DEFINITIONS)
|
||||||
|
).length
|
||||||
|
|
||||||
expect(Object.keys(res.body.action).length).toBeGreaterThanOrEqual(
|
expect(Object.keys(res.body.action).length).toBeGreaterThanOrEqual(
|
||||||
definitionsLength
|
definitionsLength
|
||||||
)
|
)
|
||||||
expect(Object.keys(res.body.trigger).length).toEqual(
|
expect(Object.keys(res.body.trigger).length).toEqual(
|
||||||
Object.keys(TRIGGER_DEFINITIONS).length
|
Object.keys(removeDeprecated(TRIGGER_DEFINITIONS)).length
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,11 +3,15 @@ import { definitions } from "./triggerInfo"
|
||||||
import { automationQueue } from "./bullboard"
|
import { automationQueue } from "./bullboard"
|
||||||
import { updateEntityMetadata } from "../utilities"
|
import { updateEntityMetadata } from "../utilities"
|
||||||
import { MetadataTypes } from "../constants"
|
import { MetadataTypes } from "../constants"
|
||||||
import { db as dbCore, context, utils } from "@budibase/backend-core"
|
import { context, db as dbCore, utils } from "@budibase/backend-core"
|
||||||
import { getAutomationMetadataParams } from "../db/utils"
|
import { getAutomationMetadataParams } from "../db/utils"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { quotas } from "@budibase/pro"
|
import { quotas } from "@budibase/pro"
|
||||||
import { Automation, AutomationJob } from "@budibase/types"
|
import {
|
||||||
|
Automation,
|
||||||
|
AutomationJob,
|
||||||
|
AutomationStepSchema,
|
||||||
|
} from "@budibase/types"
|
||||||
import { automationsEnabled } from "../features"
|
import { automationsEnabled } from "../features"
|
||||||
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
import { helpers, REBOOT_CRON } from "@budibase/shared-core"
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
|
@ -111,7 +115,9 @@ export async function updateTestHistory(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeDeprecated(definitions: any) {
|
export function removeDeprecated(
|
||||||
|
definitions: Record<string, AutomationStepSchema>
|
||||||
|
) {
|
||||||
const base = cloneDeep(definitions)
|
const base = cloneDeep(definitions)
|
||||||
for (let key of Object.keys(base)) {
|
for (let key of Object.keys(base)) {
|
||||||
if (base[key].deprecated) {
|
if (base[key].deprecated) {
|
||||||
|
|
|
@ -87,10 +87,10 @@ export async function fetch() {
|
||||||
include_docs: true,
|
include_docs: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
return response.rows
|
const automations: PersistedAutomation[] = response.rows
|
||||||
.map(row => row.doc)
|
.filter(row => !!row.doc)
|
||||||
.filter(doc => !!doc)
|
.map(row => row.doc!)
|
||||||
.map(trimUnexpectedObjectFields)
|
return automations.map(trimUnexpectedObjectFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get(automationId: string) {
|
export async function get(automationId: string) {
|
||||||
|
|
|
@ -29,8 +29,7 @@ export async function getBuilderData(
|
||||||
const rowActionNameCache: Record<string, TableRowActions> = {}
|
const rowActionNameCache: Record<string, TableRowActions> = {}
|
||||||
async function getRowActionName(tableId: string, rowActionId: string) {
|
async function getRowActionName(tableId: string, rowActionId: string) {
|
||||||
if (!rowActionNameCache[tableId]) {
|
if (!rowActionNameCache[tableId]) {
|
||||||
const rowActions = await sdk.rowActions.get(tableId)
|
rowActionNameCache[tableId] = await sdk.rowActions.get(tableId)
|
||||||
rowActionNameCache[tableId] = rowActions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rowActionNameCache[tableId].actions[rowActionId]?.name
|
return rowActionNameCache[tableId].actions[rowActionId]?.name
|
||||||
|
@ -45,9 +44,11 @@ export async function getBuilderData(
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
const { tableId, rowActionId } = automation.definition.trigger.inputs
|
||||||
|
if (!tableId || !rowActionId) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const tableName = await getTableName(tableId)
|
const tableName = await getTableName(tableId)
|
||||||
|
|
||||||
const rowActionName = await getRowActionName(tableId, rowActionId)
|
const rowActionName = await getRowActionName(tableId, rowActionId)
|
||||||
|
|
||||||
result[automation._id!] = {
|
result[automation._id!] = {
|
||||||
|
|
|
@ -174,9 +174,7 @@ export interface AutomationStepSchema {
|
||||||
deprecated?: boolean
|
deprecated?: boolean
|
||||||
stepId: AutomationTriggerStepId | AutomationActionStepId
|
stepId: AutomationTriggerStepId | AutomationActionStepId
|
||||||
blockToLoop?: string
|
blockToLoop?: string
|
||||||
inputs: {
|
inputs: Record<string, any>
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
schema: {
|
schema: {
|
||||||
inputs: InputOutputBlock
|
inputs: InputOutputBlock
|
||||||
outputs: InputOutputBlock
|
outputs: InputOutputBlock
|
||||||
|
|
Loading…
Reference in New Issue