Fixes based on server build so far.
This commit is contained in:
parent
ea66f7ac38
commit
4868083208
|
@ -19,7 +19,7 @@ export async function created(
|
|||
const properties: AutomationCreatedEvent = {
|
||||
appId: automation.appId,
|
||||
automationId: automation._id as string,
|
||||
triggerId: automation.definition?.trigger?.id!,
|
||||
triggerId: automation.definition?.trigger?.id,
|
||||
triggerType: automation.definition?.trigger?.stepId,
|
||||
}
|
||||
await publishEvent(Event.AUTOMATION_CREATED, properties, timestamp)
|
||||
|
@ -29,7 +29,7 @@ export async function triggerUpdated(automation: Automation) {
|
|||
const properties: AutomationTriggerUpdatedEvent = {
|
||||
appId: automation.appId,
|
||||
automationId: automation._id as string,
|
||||
triggerId: automation.definition?.trigger?.id!,
|
||||
triggerId: automation.definition?.trigger?.id,
|
||||
triggerType: automation.definition?.trigger?.stepId,
|
||||
}
|
||||
await publishEvent(Event.AUTOMATION_TRIGGER_UPDATED, properties)
|
||||
|
@ -39,7 +39,7 @@ export async function deleted(automation: Automation) {
|
|||
const properties: AutomationDeletedEvent = {
|
||||
appId: automation.appId,
|
||||
automationId: automation._id as string,
|
||||
triggerId: automation.definition?.trigger?.id!,
|
||||
triggerId: automation.definition?.trigger?.id,
|
||||
triggerType: automation.definition?.trigger?.stepId,
|
||||
}
|
||||
await publishEvent(Event.AUTOMATION_DELETED, properties)
|
||||
|
@ -49,7 +49,7 @@ export async function tested(automation: Automation) {
|
|||
const properties: AutomationTestedEvent = {
|
||||
appId: automation.appId,
|
||||
automationId: automation._id as string,
|
||||
triggerId: automation.definition?.trigger?.id!,
|
||||
triggerId: automation.definition?.trigger?.id,
|
||||
triggerType: automation.definition?.trigger?.stepId,
|
||||
}
|
||||
await publishEvent(Event.AUTOMATION_TESTED, properties)
|
||||
|
@ -70,7 +70,7 @@ export async function stepCreated(
|
|||
const properties: AutomationStepCreatedEvent = {
|
||||
appId: automation.appId,
|
||||
automationId: automation._id as string,
|
||||
triggerId: automation.definition?.trigger?.id!,
|
||||
triggerId: automation.definition?.trigger?.id,
|
||||
triggerType: automation.definition?.trigger?.stepId,
|
||||
stepId: step.id!,
|
||||
stepType: step.stepId,
|
||||
|
@ -85,7 +85,7 @@ export async function stepDeleted(
|
|||
const properties: AutomationStepDeletedEvent = {
|
||||
appId: automation.appId,
|
||||
automationId: automation._id as string,
|
||||
triggerId: automation.definition?.trigger?.id!,
|
||||
triggerId: automation.definition?.trigger?.id,
|
||||
triggerType: automation.definition?.trigger?.stepId,
|
||||
stepId: step.id!,
|
||||
stepType: step.stepId,
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
const { getDefinitions } = require("../../integrations")
|
||||
|
||||
exports.fetch = async function (ctx) {
|
||||
ctx.status = 200
|
||||
const defs = await getDefinitions()
|
||||
|
||||
ctx.body = defs
|
||||
}
|
||||
|
||||
exports.find = async function (ctx) {
|
||||
const defs = await getDefinitions()
|
||||
ctx.status = 200
|
||||
ctx.body = defs[ctx.params.type]
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
import { getDefinitions } from "../../integrations"
|
||||
import { BBContext } from "@budibase/types"
|
||||
|
||||
export async function fetch(ctx: BBContext) {
|
||||
ctx.status = 200
|
||||
ctx.body = await getDefinitions()
|
||||
}
|
||||
|
||||
export async function find(ctx: BBContext) {
|
||||
const defs = await getDefinitions()
|
||||
ctx.status = 200
|
||||
ctx.body = defs[ctx.params.type]
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
const { migrate, MIGRATIONS } = require("../../migrations")
|
||||
|
||||
exports.migrate = async ctx => {
|
||||
const options = ctx.request.body
|
||||
// don't await as can take a while, just return
|
||||
migrate(options)
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
exports.fetchDefinitions = async ctx => {
|
||||
ctx.body = MIGRATIONS
|
||||
ctx.status = 200
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { migrate as migrationImpl, MIGRATIONS } from "../../migrations"
|
||||
import { BBContext } from "@budibase/types"
|
||||
|
||||
export async function migrate(ctx: BBContext) {
|
||||
const options = ctx.request.body
|
||||
// don't await as can take a while, just return
|
||||
migrationImpl(options)
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
export async function fetchDefinitions(ctx: BBContext) {
|
||||
ctx.body = MIGRATIONS
|
||||
ctx.status = 200
|
||||
}
|
|
@ -209,12 +209,16 @@ module External {
|
|||
}
|
||||
|
||||
class ExternalRequest {
|
||||
private operation: Operation
|
||||
private operation: DataSourceOperation
|
||||
private tableId: string
|
||||
private datasource: Datasource
|
||||
private tables: { [key: string]: Table } = {}
|
||||
|
||||
constructor(operation: Operation, tableId: string, datasource: Datasource) {
|
||||
constructor(
|
||||
operation: DataSourceOperation,
|
||||
tableId: string,
|
||||
datasource: Datasource
|
||||
) {
|
||||
this.operation = operation
|
||||
this.tableId = tableId
|
||||
this.datasource = datasource
|
||||
|
|
|
@ -122,9 +122,9 @@ export async function finaliseRow(
|
|||
const db = context.getAppDB()
|
||||
row.type = "row"
|
||||
// process the row before return, to include relationships
|
||||
let enrichedRow = await outputProcessing(table, cloneDeep(row), {
|
||||
let enrichedRow = (await outputProcessing(table, cloneDeep(row), {
|
||||
squash: false,
|
||||
})
|
||||
})) as Row
|
||||
// use enriched row to generate formulas for saving, specifically only use as context
|
||||
row = processFormulas(table, row, {
|
||||
dynamic: false,
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
RelationshipTypes,
|
||||
} from "../../../constants"
|
||||
import { makeExternalQuery } from "../../../integrations/base/query"
|
||||
import csvParser from "../../../utilities/csvParser"
|
||||
import * as csvParser from "../../../utilities/csvParser"
|
||||
import { handleRequest } from "../row/external"
|
||||
import { events, context } from "@budibase/backend-core"
|
||||
import {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as internal from "./internal"
|
||||
import * as external from "./external"
|
||||
import csvParser from "../../../utilities/csvParser"
|
||||
import * as csvParser from "../../../utilities/csvParser"
|
||||
import { isExternalTable, isSQL } from "../../../integrations/utils"
|
||||
import { getDatasourceParams } from "../../../db/utils"
|
||||
import { context, events } from "@budibase/backend-core"
|
||||
|
@ -103,7 +103,10 @@ export async function validateCSVSchema(ctx: BBContext) {
|
|||
if (tableId) {
|
||||
existingTable = await sdk.tables.getTable(tableId)
|
||||
}
|
||||
let result = await csvParser.parse(csvString, schema)
|
||||
let result: Record<string, any> | undefined = await csvParser.parse(
|
||||
csvString,
|
||||
schema
|
||||
)
|
||||
if (existingTable) {
|
||||
result = csvParser.updateSchema({ schema: result, existingTable })
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { getWebhookParams } from "../../db/utils"
|
||||
import triggers from "../../automations/triggers"
|
||||
import * as triggers from "../../automations/triggers"
|
||||
import { db as dbCore, context } from "@budibase/backend-core"
|
||||
import {
|
||||
Webhook,
|
||||
|
|
|
@ -37,7 +37,7 @@ router
|
|||
// re-direct before any middlewares occur
|
||||
.redirect("/", "/builder")
|
||||
.use(
|
||||
auth.buildAuthMiddleware(null, {
|
||||
auth.buildAuthMiddleware([], {
|
||||
publicAllowed: true,
|
||||
})
|
||||
)
|
||||
|
@ -45,7 +45,7 @@ router
|
|||
// the server can be public anywhere, so nowhere should throw errors
|
||||
// if the tenancy has not been set, it'll have to be discovered at application layer
|
||||
.use(
|
||||
auth.buildTenancyMiddleware(null, null, {
|
||||
auth.buildTenancyMiddleware([], [], {
|
||||
noTenancyRequired: true,
|
||||
})
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Router from "@koa/router"
|
||||
import controller from "../controllers/integration"
|
||||
import * as controller from "../controllers/integration"
|
||||
import authorized from "../../middleware/authorized"
|
||||
import { permissions } from "@budibase/backend-core"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ if (process.env.ELASTIC_APM_ENABLED) {
|
|||
}
|
||||
|
||||
import { ExtendableContext } from "koa"
|
||||
import db from "./db"
|
||||
import * as db from "./db"
|
||||
db.init()
|
||||
const Koa = require("koa")
|
||||
const destroyable = require("server-destroy")
|
||||
|
|
|
@ -15,7 +15,7 @@ import * as delay from "./steps/delay"
|
|||
import * as queryRow from "./steps/queryRows"
|
||||
import * as loop from "./steps/loop"
|
||||
import env from "../environment"
|
||||
import { AutomationStep, AutomationStepInput } from "@budibase/types"
|
||||
import { AutomationStepSchema, AutomationStepInput } from "@budibase/types"
|
||||
|
||||
const ACTION_IMPLS: Record<
|
||||
string,
|
||||
|
@ -38,7 +38,7 @@ const ACTION_IMPLS: Record<
|
|||
zapier: zapier.run,
|
||||
integromat: integromat.run,
|
||||
}
|
||||
export const ACTION_DEFINITIONS: Record<string, AutomationStep> = {
|
||||
export const ACTION_DEFINITIONS: Record<string, AutomationStepSchema> = {
|
||||
SEND_EMAIL_SMTP: sendSmtpEmail.definition,
|
||||
CREATE_ROW: createRow.definition,
|
||||
UPDATE_ROW: updateRow.definition,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { execSync } from "child_process"
|
||||
import { processStringSync } from "@budibase/string-templates"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import environment from "../../environment"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Bash Scripting",
|
||||
tagline: "Execute a bash command",
|
||||
icon: "JourneyEvent",
|
||||
|
|
|
@ -3,11 +3,11 @@ import { cleanUpRow, getError } from "../automationUtils"
|
|||
import { buildCtx } from "./utils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Create Row",
|
||||
tagline: "Create a {{inputs.enriched.table.name}} row",
|
||||
icon: "TableRowAddBottom",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { wait } from "../../utilities"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Delay",
|
||||
icon: "Clock",
|
||||
tagline: "Delay for {{inputs.time}} milliseconds",
|
||||
|
|
|
@ -3,11 +3,11 @@ import { buildCtx } from "./utils"
|
|||
import { getError } from "../automationUtils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
description: "Delete a row from your database",
|
||||
icon: "TableRowRemoveCenter",
|
||||
name: "Delete Row",
|
||||
|
|
|
@ -2,14 +2,14 @@ import fetch from "node-fetch"
|
|||
import { getFetchResponse } from "./utils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
const DEFAULT_USERNAME = "Budibase Automate"
|
||||
const DEFAULT_AVATAR_URL = "https://i.imgur.com/a1cmTKM.png"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Discord Message",
|
||||
tagline: "Send a message to a Discord server",
|
||||
description: "Send a message to a Discord server",
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as queryController from "../../api/controllers/query"
|
||||
import { buildCtx } from "./utils"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "External Data Connector",
|
||||
tagline: "Execute Data Connector",
|
||||
icon: "Data",
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as scriptController from "../../api/controllers/script"
|
||||
import { buildCtx } from "./utils"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "JS Scripting",
|
||||
tagline: "Execute JavaScript Code",
|
||||
icon: "Code",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
|
@ -18,7 +18,7 @@ export const PrettyFilterConditions = {
|
|||
[FilterConditions.LESS_THAN]: "Less than",
|
||||
}
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Condition",
|
||||
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
|
||||
icon: "Branch2",
|
||||
|
|
|
@ -2,11 +2,11 @@ import fetch from "node-fetch"
|
|||
import { getFetchResponse } from "./utils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Integromat Integration",
|
||||
tagline: "Trigger an Integromat scenario",
|
||||
description:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { AutomationActionStepId, AutomationStep } from "@budibase/types"
|
||||
import { AutomationActionStepId, AutomationStepSchema } from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Looping",
|
||||
icon: "Reuse",
|
||||
tagline: "Loop the block",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import fetch from "node-fetch"
|
||||
import { getFetchResponse } from "./utils"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
|
@ -21,7 +21,7 @@ const BODY_REQUESTS = [RequestType.POST, RequestType.PUT, RequestType.PATCH]
|
|||
* NOTE: this functionality is deprecated - it no longer should be used.
|
||||
*/
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
deprecated: true,
|
||||
name: "Outgoing webhook",
|
||||
tagline: "Send a {{inputs.requestMethod}} request",
|
||||
|
|
|
@ -2,10 +2,10 @@ import * as rowController from "../../api/controllers/row"
|
|||
import * as tableController from "../../api/controllers/table"
|
||||
import { FieldTypes } from "../../constants"
|
||||
import { buildCtx } from "./utils"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
SearchFilters,
|
||||
Table,
|
||||
|
@ -31,7 +31,7 @@ const EmptyFilterOptionPretty = {
|
|||
[EmptyFilterOption.RETURN_NONE]: "Return no rows",
|
||||
}
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
description: "Query rows from the database",
|
||||
icon: "Search",
|
||||
name: "Query rows",
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { sendSmtpEmail } from "../../utilities/workerRequests"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
description: "Send an email using SMTP",
|
||||
tagline: "Send SMTP email to {{inputs.to}}",
|
||||
icon: "Email",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
|
@ -10,7 +10,7 @@ import {
|
|||
* GET/DELETE requests cannot handle body elements so they will not be sent if configured.
|
||||
*/
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Backend log",
|
||||
tagline: "Console log a value in the backend",
|
||||
icon: "Monitoring",
|
||||
|
|
|
@ -2,11 +2,11 @@ import fetch from "node-fetch"
|
|||
import { getFetchResponse } from "./utils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Slack Message",
|
||||
tagline: "Send a message to Slack",
|
||||
description: "Send a message to Slack",
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import * as rowController from "../../api/controllers/row"
|
||||
import automationUtils from "../automationUtils"
|
||||
import * as automationUtils from "../automationUtils"
|
||||
import { buildCtx } from "./utils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Update Row",
|
||||
tagline: "Update a {{inputs.enriched.table.name}} row",
|
||||
icon: "Refresh",
|
||||
|
|
|
@ -2,11 +2,11 @@ import fetch from "node-fetch"
|
|||
import { getFetchResponse } from "./utils"
|
||||
import {
|
||||
AutomationActionStepId,
|
||||
AutomationStep,
|
||||
AutomationStepSchema,
|
||||
AutomationStepInput,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStep = {
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "Zapier Webhook",
|
||||
stepId: AutomationActionStepId.zapier,
|
||||
type: "ACTION",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { AutomationTrigger, AutomationTriggerStepId } from "@budibase/types"
|
||||
import {
|
||||
AutomationTriggerSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationTrigger = {
|
||||
export const definition: AutomationTriggerSchema = {
|
||||
name: "App Action",
|
||||
event: "app:trigger",
|
||||
icon: "Apps",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { AutomationTrigger, AutomationTriggerStepId } from "@budibase/types"
|
||||
import {
|
||||
AutomationTriggerSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationTrigger = {
|
||||
export const definition: AutomationTriggerSchema = {
|
||||
name: "Cron Trigger",
|
||||
event: "cron:trigger",
|
||||
icon: "Clock",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import app from "./app"
|
||||
import cron from "./cron"
|
||||
import rowDeleted from "./rowDeleted"
|
||||
import rowSaved from "./rowSaved"
|
||||
import rowUpdated from "./rowUpdated"
|
||||
import webhook from "./webhook"
|
||||
import * as app from "./app"
|
||||
import * as cron from "./cron"
|
||||
import * as rowDeleted from "./rowDeleted"
|
||||
import * as rowSaved from "./rowSaved"
|
||||
import * as rowUpdated from "./rowUpdated"
|
||||
import * as webhook from "./webhook"
|
||||
|
||||
export const definitions = {
|
||||
ROW_SAVED: rowSaved.definition,
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { AutomationTrigger, AutomationTriggerStepId } from "@budibase/types"
|
||||
import {
|
||||
AutomationTriggerSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationTrigger = {
|
||||
export const definition: AutomationTriggerSchema = {
|
||||
name: "Row Deleted",
|
||||
event: "row:delete",
|
||||
icon: "TableRowRemoveCenter",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { AutomationTrigger, AutomationTriggerStepId } from "@budibase/types"
|
||||
import {
|
||||
AutomationTriggerSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationTrigger = {
|
||||
export const definition: AutomationTriggerSchema = {
|
||||
name: "Row Created",
|
||||
event: "row:save",
|
||||
icon: "TableRowAddBottom",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { AutomationTrigger, AutomationTriggerStepId } from "@budibase/types"
|
||||
import {
|
||||
AutomationTriggerSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationTrigger = {
|
||||
export const definition: AutomationTriggerSchema = {
|
||||
name: "Row Updated",
|
||||
event: "row:update",
|
||||
icon: "Refresh",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { AutomationTrigger, AutomationTriggerStepId } from "@budibase/types"
|
||||
import {
|
||||
AutomationTriggerSchema,
|
||||
AutomationTriggerStepId,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationTrigger = {
|
||||
export const definition: AutomationTriggerSchema = {
|
||||
name: "Webhook",
|
||||
event: "web:trigger",
|
||||
icon: "Send",
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from "@budibase/types"
|
||||
|
||||
type LinkControllerOpts = {
|
||||
tableId: string
|
||||
tableId?: string
|
||||
row?: Row
|
||||
table?: Table
|
||||
oldTable?: Table
|
||||
|
@ -21,7 +21,7 @@ type LinkControllerOpts = {
|
|||
|
||||
class LinkController {
|
||||
_db: Database
|
||||
_tableId: string
|
||||
_tableId?: string
|
||||
_row?: Row
|
||||
_table?: Table
|
||||
_oldTable?: Table
|
||||
|
|
|
@ -100,7 +100,7 @@ async function getFullLinkedDocs(links: LinkDocumentValue[]) {
|
|||
* row operations and the table for table operations.
|
||||
*/
|
||||
export async function updateLinks(args: {
|
||||
tableId: string
|
||||
tableId?: string
|
||||
eventType: string
|
||||
row?: Row
|
||||
table?: Table
|
||||
|
|
|
@ -21,7 +21,7 @@ class BudibaseEmitter extends EventEmitter {
|
|||
tableEmission({ emitter: this, eventName, appId, table })
|
||||
}
|
||||
|
||||
emitPort(portNumber: number) {
|
||||
emitPort(portNumber?: number | string) {
|
||||
this.emit("internal:port", portNumber)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,6 +266,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
this.deleteTable(json?.table?.name),
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const internalQueryMethod = handlers[json.endpoint.operation]
|
||||
|
||||
return await internalQueryMethod()
|
||||
|
|
|
@ -230,7 +230,7 @@ function shouldCopySpecialColumn(
|
|||
const fetchedIsNumber =
|
||||
!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER
|
||||
return (
|
||||
specialTypes.indexOf(column.type) !== -1 ||
|
||||
specialTypes.indexOf(column.type as FieldTypes) !== -1 ||
|
||||
(fetchedIsNumber && column.type === FieldTypes.BOOLEAN)
|
||||
)
|
||||
}
|
||||
|
@ -292,7 +292,11 @@ export function finaliseExternalTables(
|
|||
if (table.primary == null || table.primary.length === 0) {
|
||||
errors[name] = BuildSchemaErrors.NO_KEY
|
||||
continue
|
||||
} else if (schemaFields.find(field => invalidColumns.includes(field))) {
|
||||
} else if (
|
||||
schemaFields.find(field =>
|
||||
invalidColumns.includes(field as InvalidColumns)
|
||||
)
|
||||
) {
|
||||
errors[name] = BuildSchemaErrors.INVALID_COLUMN
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ import {
|
|||
} from "@budibase/backend-core"
|
||||
import fs from "fs"
|
||||
import { watch } from "./watch"
|
||||
import automations from "./automations"
|
||||
import fileSystem from "./utilities/fileSystem"
|
||||
import * as automations from "./automations"
|
||||
import * as fileSystem from "./utilities/fileSystem"
|
||||
import eventEmitter from "./events"
|
||||
import * as migrations from "./migrations"
|
||||
import bullboard from "./automations/bullboard"
|
||||
import * as bullboard from "./automations/bullboard"
|
||||
import * as pro from "@budibase/pro"
|
||||
import * as api from "./api"
|
||||
import sdk from "./sdk"
|
||||
|
|
|
@ -6,8 +6,8 @@ import {
|
|||
disableCronById,
|
||||
isErrorInOutput,
|
||||
} from "../automations/utils"
|
||||
import { default as actions } from "../automations/actions"
|
||||
import { default as automationUtils } from "../automations/automationUtils"
|
||||
import * as actions from "../automations/actions"
|
||||
import * as automationUtils from "../automations/automationUtils"
|
||||
import { default as AutomationEmitter } from "../events/AutomationEmitter"
|
||||
import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
|
||||
import { definitions as triggerDefs } from "../automations/triggerInfo"
|
||||
|
@ -335,7 +335,7 @@ class Orchestrator {
|
|||
)) {
|
||||
originalStepInput[key][innerKey][innerObject] =
|
||||
automationUtils.substituteLoopStep(
|
||||
innerValue,
|
||||
innerValue as string,
|
||||
`steps.${loopStepNumber}`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { QueryVariable } from "./definitions"
|
||||
import env from "../environment"
|
||||
import db from "../db"
|
||||
import * as db from "../db"
|
||||
import { redis, db as dbCore } from "@budibase/backend-core"
|
||||
|
||||
const VARIABLE_TTL_SECONDS = 3600
|
||||
|
|
|
@ -8,7 +8,7 @@ type CsvParseOpts = {
|
|||
csvString?: string
|
||||
}
|
||||
|
||||
const VALIDATORS = {
|
||||
const VALIDATORS: any = {
|
||||
[FieldTypes.STRING]: () => true,
|
||||
[FieldTypes.OPTIONS]: () => true,
|
||||
[FieldTypes.BARCODEQR]: () => true,
|
||||
|
@ -28,7 +28,7 @@ const VALIDATORS = {
|
|||
},
|
||||
}
|
||||
|
||||
const PARSERS = {
|
||||
const PARSERS: any = {
|
||||
[FieldTypes.NUMBER]: (attribute?: string) => {
|
||||
if (!attribute) {
|
||||
return attribute
|
||||
|
@ -43,7 +43,7 @@ const PARSERS = {
|
|||
},
|
||||
}
|
||||
|
||||
export function parse(csvString: string, parsers: any) {
|
||||
export function parse(csvString: string, parsers: any): Record<string, any> {
|
||||
const result = csv().fromString(csvString)
|
||||
|
||||
const schema: Record<string, any> = {}
|
||||
|
@ -89,7 +89,7 @@ export function updateSchema({
|
|||
existingTable,
|
||||
}: {
|
||||
schema?: Record<string, any>
|
||||
existingTable: Table
|
||||
existingTable?: Table
|
||||
}) {
|
||||
if (!schema) {
|
||||
return schema
|
||||
|
@ -97,7 +97,7 @@ export function updateSchema({
|
|||
const finalSchema: Record<string, FieldSchema> = {}
|
||||
const schemaKeyMap: Record<string, any> = {}
|
||||
Object.keys(schema).forEach(key => (schemaKeyMap[key.toLowerCase()] = key))
|
||||
for (let [key, field] of Object.entries(existingTable.schema)) {
|
||||
for (let [key, field] of Object.entries(existingTable?.schema || {})) {
|
||||
const lcKey = key.toLowerCase()
|
||||
const foundKey: string = schemaKeyMap[lcKey]
|
||||
if (foundKey) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import linkRows from "../../db/linkedRows"
|
||||
import * as linkRows from "../../db/linkedRows"
|
||||
import { FieldTypes, AutoFieldSubTypes } from "../../constants"
|
||||
import { attachmentsRelativeURL } from "../index"
|
||||
import { processFormulas, fixAutoColumnSubType } from "./utils"
|
||||
|
@ -189,10 +189,10 @@ export async function outputProcessing(
|
|||
wasArray = false
|
||||
}
|
||||
// attach any linked row information
|
||||
let enriched = await linkRows.attachFullLinkedDocs(table, rows)
|
||||
let enriched = await linkRows.attachFullLinkedDocs(table, rows as Row[])
|
||||
|
||||
// process formulas
|
||||
enriched = processFormulas(table, enriched, { dynamic: true })
|
||||
enriched = processFormulas(table, enriched, { dynamic: true }) as Row[]
|
||||
|
||||
// update the attachments URL depending on hosting
|
||||
for (let [property, column] of Object.entries(table.schema)) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { FieldTypes } from "../../constants"
|
|||
/**
|
||||
* A map of how we convert various properties in rows to each other based on the row type.
|
||||
*/
|
||||
exports.TYPE_TRANSFORM_MAP = {
|
||||
export const TYPE_TRANSFORM_MAP: any = {
|
||||
[FieldTypes.LINK]: {
|
||||
"": [],
|
||||
[null]: [],
|
||||
|
|
|
@ -41,8 +41,7 @@ export interface Automation extends Document {
|
|||
name: string
|
||||
}
|
||||
|
||||
export interface AutomationStep {
|
||||
id?: string
|
||||
export interface AutomationStepSchema {
|
||||
name: string
|
||||
tagline: string
|
||||
icon: string
|
||||
|
@ -65,11 +64,19 @@ export interface AutomationStep {
|
|||
}
|
||||
}
|
||||
|
||||
export interface AutomationTrigger extends AutomationStep {
|
||||
export interface AutomationStep extends AutomationStepSchema {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface AutomationTriggerSchema extends AutomationStepSchema {
|
||||
event?: string
|
||||
cronJobId?: string
|
||||
}
|
||||
|
||||
export interface AutomationTrigger extends AutomationTriggerSchema {
|
||||
id: string
|
||||
}
|
||||
|
||||
export enum AutomationStatus {
|
||||
SUCCESS = "success",
|
||||
ERROR = "error",
|
||||
|
|
Loading…
Reference in New Issue