@budibase/server 2.5.6-alpha.1 → 2.5.6-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/builder/assets/{index.1fe52b59.js → index.5c1a6913.js} +361 -361
  2. package/builder/assets/index.c0265b74.css +6 -0
  3. package/builder/index.html +2 -2
  4. package/dist/api/controllers/automation.js +13 -7
  5. package/dist/api/controllers/plugin/index.js +6 -37
  6. package/dist/api/controllers/table/utils.js +2 -1
  7. package/dist/api/controllers/user.js +1 -83
  8. package/dist/api/routes/user.js +0 -1
  9. package/dist/app.js +2 -2
  10. package/dist/automations/actions.js +32 -6
  11. package/dist/automations/index.js +3 -2
  12. package/dist/automations/steps/bash.js +6 -6
  13. package/dist/automations/steps/createRow.js +11 -11
  14. package/dist/automations/steps/delay.js +3 -3
  15. package/dist/automations/steps/deleteRow.js +8 -8
  16. package/dist/automations/steps/discord.js +8 -8
  17. package/dist/automations/steps/executeQuery.js +9 -9
  18. package/dist/automations/steps/executeScript.js +6 -6
  19. package/dist/automations/steps/filter.js +6 -6
  20. package/dist/automations/steps/integromat.js +10 -10
  21. package/dist/automations/steps/loop.js +9 -9
  22. package/dist/automations/steps/outgoingWebhook.js +10 -10
  23. package/dist/automations/steps/queryRows.js +14 -14
  24. package/dist/automations/steps/sendSmtpEmail.js +9 -9
  25. package/dist/automations/steps/serverLog.js +4 -4
  26. package/dist/automations/steps/slack.js +6 -6
  27. package/dist/automations/steps/updateRow.js +11 -11
  28. package/dist/automations/steps/zapier.js +9 -9
  29. package/dist/automations/triggerInfo/app.js +5 -5
  30. package/dist/automations/triggerInfo/cron.js +4 -4
  31. package/dist/automations/triggerInfo/rowDeleted.js +5 -5
  32. package/dist/automations/triggerInfo/rowSaved.js +7 -7
  33. package/dist/automations/triggerInfo/rowUpdated.js +7 -7
  34. package/dist/automations/triggerInfo/webhook.js +6 -6
  35. package/dist/events/docUpdates/index.js +17 -0
  36. package/dist/events/docUpdates/processors.js +18 -0
  37. package/dist/events/docUpdates/syncUsers.js +49 -0
  38. package/dist/events/index.js +3 -0
  39. package/dist/integrations/index.js +3 -3
  40. package/dist/package.json +9 -8
  41. package/dist/sdk/app/applications/sync.js +117 -23
  42. package/dist/sdk/index.js +2 -0
  43. package/dist/sdk/plugins/index.js +27 -0
  44. package/dist/sdk/plugins/plugins.js +53 -0
  45. package/dist/sdk/users/utils.js +21 -4
  46. package/dist/startup.js +2 -1
  47. package/dist/threads/automation.js +2 -2
  48. package/dist/tsconfig.build.tsbuildinfo +1 -1
  49. package/dist/utilities/fileSystem/plugin.js +33 -23
  50. package/dist/utilities/global.js +17 -12
  51. package/dist/watch.js +2 -2
  52. package/dist/websockets/client.js +14 -0
  53. package/dist/websockets/grid.js +60 -0
  54. package/dist/websockets/index.js +17 -0
  55. package/dist/websockets/websocket.js +78 -0
  56. package/jest.config.ts +3 -3
  57. package/nodemon.json +7 -3
  58. package/package.json +10 -9
  59. package/src/api/controllers/automation.ts +12 -6
  60. package/src/api/controllers/plugin/index.ts +8 -45
  61. package/src/api/controllers/row/internal.ts +9 -10
  62. package/src/api/controllers/row/utils.ts +2 -2
  63. package/src/api/controllers/table/utils.ts +2 -1
  64. package/src/api/controllers/user.ts +10 -96
  65. package/src/api/routes/tests/automation.spec.js +2 -2
  66. package/src/api/routes/tests/user.spec.js +0 -37
  67. package/src/api/routes/user.ts +0 -5
  68. package/src/app.ts +2 -2
  69. package/src/automations/actions.ts +56 -24
  70. package/src/automations/index.ts +1 -1
  71. package/src/automations/steps/bash.ts +10 -7
  72. package/src/automations/steps/createRow.ts +15 -12
  73. package/src/automations/steps/delay.ts +6 -4
  74. package/src/automations/steps/deleteRow.ts +12 -9
  75. package/src/automations/steps/discord.ts +10 -8
  76. package/src/automations/steps/executeQuery.ts +13 -10
  77. package/src/automations/steps/executeScript.ts +10 -7
  78. package/src/automations/steps/filter.ts +8 -6
  79. package/src/automations/steps/integromat.ts +12 -10
  80. package/src/automations/steps/loop.ts +16 -10
  81. package/src/automations/steps/outgoingWebhook.ts +14 -11
  82. package/src/automations/steps/queryRows.ts +18 -15
  83. package/src/automations/steps/sendSmtpEmail.ts +11 -9
  84. package/src/automations/steps/serverLog.ts +6 -4
  85. package/src/automations/steps/slack.ts +8 -6
  86. package/src/automations/steps/updateRow.ts +15 -12
  87. package/src/automations/steps/zapier.ts +11 -9
  88. package/src/automations/tests/utilities/index.ts +2 -2
  89. package/src/automations/triggerInfo/app.ts +8 -5
  90. package/src/automations/triggerInfo/cron.ts +7 -4
  91. package/src/automations/triggerInfo/rowDeleted.ts +8 -5
  92. package/src/automations/triggerInfo/rowSaved.ts +10 -7
  93. package/src/automations/triggerInfo/rowUpdated.ts +10 -7
  94. package/src/automations/triggerInfo/webhook.ts +9 -6
  95. package/src/events/docUpdates/index.ts +1 -0
  96. package/src/events/docUpdates/processors.ts +14 -0
  97. package/src/events/docUpdates/syncUsers.ts +35 -0
  98. package/src/events/index.ts +1 -0
  99. package/src/integrations/index.ts +3 -3
  100. package/src/sdk/app/applications/sync.ts +129 -22
  101. package/src/sdk/app/applications/tests/sync.spec.ts +137 -0
  102. package/src/sdk/index.ts +2 -0
  103. package/src/sdk/plugins/index.ts +5 -0
  104. package/src/sdk/plugins/plugins.ts +41 -0
  105. package/src/sdk/users/tests/utils.spec.ts +1 -32
  106. package/src/sdk/users/utils.ts +23 -5
  107. package/src/startup.ts +2 -1
  108. package/src/tests/utilities/TestConfiguration.ts +28 -0
  109. package/src/tests/utilities/structures.ts +25 -17
  110. package/src/threads/automation.ts +2 -2
  111. package/src/utilities/fileSystem/plugin.ts +13 -4
  112. package/src/utilities/global.ts +21 -16
  113. package/src/watch.ts +2 -2
  114. package/src/websockets/client.ts +11 -0
  115. package/src/websockets/grid.ts +55 -0
  116. package/src/websockets/index.ts +14 -0
  117. package/src/websockets/websocket.ts +83 -0
  118. package/tsconfig.json +1 -7
  119. package/builder/assets/index.841e62d8.css +0 -6
  120. package/dist/websocket.js +0 -22
  121. package/src/websocket.ts +0 -26
@@ -124,7 +124,8 @@ export function importToRows(
124
124
  for (const [fieldName, schema] of Object.entries(table.schema)) {
125
125
  // check whether the options need to be updated for inclusion as part of the data import
126
126
  if (
127
- schema.type === FieldTypes.OPTIONS &&
127
+ (schema.type === FieldTypes.OPTIONS ||
128
+ schema.type === FieldTypes.ARRAY) &&
128
129
  row[fieldName] &&
129
130
  (!schema.constraints!.inclusion ||
130
131
  schema.constraints!.inclusion.indexOf(row[fieldName]) === -1)
@@ -1,98 +1,12 @@
1
1
  import { generateUserMetadataID, generateUserFlagID } from "../../db/utils"
2
2
  import { InternalTables } from "../../db/utils"
3
- import { getGlobalUsers, getRawGlobalUser } from "../../utilities/global"
3
+ import { getGlobalUsers } from "../../utilities/global"
4
4
  import { getFullUser } from "../../utilities/users"
5
- import {
6
- context,
7
- roles as rolesCore,
8
- db as dbCore,
9
- } from "@budibase/backend-core"
10
- import { BBContext, Ctx, SyncUserRequest, User } from "@budibase/types"
5
+ import { context } from "@budibase/backend-core"
6
+ import { UserCtx } from "@budibase/types"
11
7
  import sdk from "../../sdk"
12
8
 
13
- export async function syncUser(ctx: Ctx<SyncUserRequest>) {
14
- let deleting = false,
15
- user: User | any
16
- const userId = ctx.params.id
17
-
18
- const previousUser = ctx.request.body?.previousUser
19
-
20
- try {
21
- user = (await getRawGlobalUser(userId)) as User
22
- } catch (err: any) {
23
- if (err && err.status === 404) {
24
- user = {}
25
- deleting = true
26
- } else {
27
- throw err
28
- }
29
- }
30
-
31
- let previousApps = previousUser
32
- ? Object.keys(previousUser.roles).map(appId => appId)
33
- : []
34
-
35
- const roles = deleting ? {} : user.roles
36
- // remove props which aren't useful to metadata
37
- delete user.password
38
- delete user.forceResetPassword
39
- delete user.roles
40
- // run through all production appIDs in the users roles
41
- let prodAppIds
42
- // if they are a builder then get all production app IDs
43
- if ((user.builder && user.builder.global) || deleting) {
44
- prodAppIds = await dbCore.getProdAppIDs()
45
- } else {
46
- prodAppIds = Object.entries(roles)
47
- .filter(entry => entry[1] !== rolesCore.BUILTIN_ROLE_IDS.PUBLIC)
48
- .map(([appId]) => appId)
49
- }
50
- for (let prodAppId of new Set([...prodAppIds, ...previousApps])) {
51
- const roleId = roles[prodAppId]
52
- const deleteFromApp = !roleId
53
- const devAppId = dbCore.getDevelopmentAppID(prodAppId)
54
- for (let appId of [prodAppId, devAppId]) {
55
- if (!(await dbCore.dbExists(appId))) {
56
- continue
57
- }
58
- await context.doInAppContext(appId, async () => {
59
- const db = context.getAppDB()
60
- const metadataId = generateUserMetadataID(userId)
61
- let metadata
62
- try {
63
- metadata = await db.get(metadataId)
64
- } catch (err) {
65
- if (deleteFromApp) {
66
- return
67
- }
68
- metadata = {
69
- tableId: InternalTables.USER_METADATA,
70
- }
71
- }
72
-
73
- if (deleteFromApp) {
74
- await db.remove(metadata)
75
- return
76
- }
77
-
78
- // assign the roleId for the metadata doc
79
- if (roleId) {
80
- metadata.roleId = roleId
81
- }
82
- let combined = sdk.users.combineMetadataAndUser(user, metadata)
83
- // if its null then there was no updates required
84
- if (combined) {
85
- await db.put(combined)
86
- }
87
- })
88
- }
89
- }
90
- ctx.body = {
91
- message: "User synced.",
92
- }
93
- }
94
-
95
- export async function fetchMetadata(ctx: BBContext) {
9
+ export async function fetchMetadata(ctx: UserCtx) {
96
10
  const global = await getGlobalUsers()
97
11
  const metadata = await sdk.users.rawUserMetadata()
98
12
  const users = []
@@ -111,7 +25,7 @@ export async function fetchMetadata(ctx: BBContext) {
111
25
  ctx.body = users
112
26
  }
113
27
 
114
- export async function updateSelfMetadata(ctx: BBContext) {
28
+ export async function updateSelfMetadata(ctx: UserCtx) {
115
29
  // overwrite the ID with current users
116
30
  ctx.request.body._id = ctx.user?._id
117
31
  // make sure no stale rev
@@ -121,7 +35,7 @@ export async function updateSelfMetadata(ctx: BBContext) {
121
35
  await updateMetadata(ctx)
122
36
  }
123
37
 
124
- export async function updateMetadata(ctx: BBContext) {
38
+ export async function updateMetadata(ctx: UserCtx) {
125
39
  const db = context.getAppDB()
126
40
  const user = ctx.request.body
127
41
  // this isn't applicable to the user
@@ -133,7 +47,7 @@ export async function updateMetadata(ctx: BBContext) {
133
47
  ctx.body = await db.put(metadata)
134
48
  }
135
49
 
136
- export async function destroyMetadata(ctx: BBContext) {
50
+ export async function destroyMetadata(ctx: UserCtx) {
137
51
  const db = context.getAppDB()
138
52
  try {
139
53
  const dbUser = await db.get(ctx.params.id)
@@ -146,11 +60,11 @@ export async function destroyMetadata(ctx: BBContext) {
146
60
  }
147
61
  }
148
62
 
149
- export async function findMetadata(ctx: BBContext) {
63
+ export async function findMetadata(ctx: UserCtx) {
150
64
  ctx.body = await getFullUser(ctx, ctx.params.id)
151
65
  }
152
66
 
153
- export async function setFlag(ctx: BBContext) {
67
+ export async function setFlag(ctx: UserCtx) {
154
68
  const userId = ctx.user?._id
155
69
  const { flag, value } = ctx.request.body
156
70
  if (!flag) {
@@ -169,7 +83,7 @@ export async function setFlag(ctx: BBContext) {
169
83
  ctx.body = { message: "Flag set successfully" }
170
84
  }
171
85
 
172
- export async function getFlags(ctx: BBContext) {
86
+ export async function getFlags(ctx: UserCtx) {
173
87
  const userId = ctx.user?._id
174
88
  const docId = generateUserFlagID(userId!)
175
89
  const db = context.getAppDB()
@@ -7,7 +7,7 @@ const {
7
7
  const setup = require("./utilities")
8
8
  const { basicAutomation, newAutomation, automationTrigger, automationStep } = setup.structures
9
9
  const MAX_RETRIES = 4
10
- const { TRIGGER_DEFINITIONS, ACTION_DEFINITIONS } = require("../../../automations")
10
+ const { TRIGGER_DEFINITIONS, BUILTIN_ACTION_DEFINITIONS } = require("../../../automations")
11
11
  const { events } = require("@budibase/backend-core")
12
12
 
13
13
 
@@ -55,7 +55,7 @@ describe("/automations", () => {
55
55
  .expect('Content-Type', /json/)
56
56
  .expect(200)
57
57
 
58
- let definitionsLength = Object.keys(ACTION_DEFINITIONS).length
58
+ let definitionsLength = Object.keys(BUILTIN_ACTION_DEFINITIONS).length
59
59
  definitionsLength-- // OUTGOING_WEBHOOK is deprecated
60
60
 
61
61
  expect(Object.keys(res.body.action).length).toBeGreaterThanOrEqual(definitionsLength)
@@ -205,41 +205,4 @@ describe("/users", () => {
205
205
  expect(res.body.message).toEqual("Flag set successfully")
206
206
  })
207
207
  })
208
-
209
- describe("syncUser", () => {
210
- it("should sync the user", async () => {
211
- let user = await config.createUser()
212
- await config.createApp("New App")
213
- let res = await request
214
- .post(`/api/users/metadata/sync/${user._id}`)
215
- .set(config.defaultHeaders())
216
- .expect(200)
217
- .expect("Content-Type", /json/)
218
- expect(res.body.message).toEqual("User synced.")
219
- })
220
-
221
- it("should sync the user when a previous user is specified", async () => {
222
- const app1 = await config.createApp("App 1")
223
- const app2 = await config.createApp("App 2")
224
-
225
- let user = await config.createUser({
226
- builder: false,
227
- admin: true,
228
- roles: { [app1.appId]: "ADMIN" },
229
- })
230
- let res = await request
231
- .post(`/api/users/metadata/sync/${user._id}`)
232
- .set(config.defaultHeaders())
233
- .send({
234
- previousUser: {
235
- ...user,
236
- roles: { ...user.roles, [app2.appId]: "BASIC" },
237
- },
238
- })
239
- .expect(200)
240
- .expect("Content-Type", /json/)
241
-
242
- expect(res.body.message).toEqual("User synced.")
243
- })
244
- })
245
208
  })
@@ -32,11 +32,6 @@ router
32
32
  authorized(PermissionType.USER, PermissionLevel.WRITE),
33
33
  controller.destroyMetadata
34
34
  )
35
- .post(
36
- "/api/users/metadata/sync/:id",
37
- authorized(PermissionType.USER, PermissionLevel.WRITE),
38
- controller.syncUser
39
- )
40
35
  .post(
41
36
  "/api/users/flags",
42
37
  authorized(PermissionType.USER, PermissionLevel.WRITE),
package/src/app.ts CHANGED
@@ -15,8 +15,8 @@ import * as api from "./api"
15
15
  import * as automations from "./automations"
16
16
  import { Thread } from "./threads"
17
17
  import * as redis from "./utilities/redis"
18
+ import { initialise as initialiseWebsockets } from "./websockets"
18
19
  import { events, logging, middleware, timers } from "@budibase/backend-core"
19
- import { initialise as initialiseWebsockets } from "./websocket"
20
20
  import { startup } from "./startup"
21
21
  const Sentry = require("@sentry/node")
22
22
  const destroyable = require("server-destroy")
@@ -61,7 +61,7 @@ if (env.isProd()) {
61
61
 
62
62
  const server = http.createServer(app.callback())
63
63
  destroyable(server)
64
- initialiseWebsockets(server)
64
+ initialiseWebsockets(app, server)
65
65
 
66
66
  let shuttingDown = false,
67
67
  errCode = 0
@@ -15,7 +15,14 @@ import * as delay from "./steps/delay"
15
15
  import * as queryRow from "./steps/queryRows"
16
16
  import * as loop from "./steps/loop"
17
17
  import env from "../environment"
18
- import { AutomationStepSchema, AutomationStepInput } from "@budibase/types"
18
+ import {
19
+ AutomationStepSchema,
20
+ AutomationStepInput,
21
+ PluginType,
22
+ AutomationStep,
23
+ } from "@budibase/types"
24
+ import sdk from "../sdk"
25
+ import { getAutomationPlugin } from "../utilities/fileSystem"
19
26
 
20
27
  const ACTION_IMPLS: Record<
21
28
  string,
@@ -38,25 +45,26 @@ const ACTION_IMPLS: Record<
38
45
  zapier: zapier.run,
39
46
  integromat: integromat.run,
40
47
  }
41
- export const ACTION_DEFINITIONS: Record<string, AutomationStepSchema> = {
42
- SEND_EMAIL_SMTP: sendSmtpEmail.definition,
43
- CREATE_ROW: createRow.definition,
44
- UPDATE_ROW: updateRow.definition,
45
- DELETE_ROW: deleteRow.definition,
46
- OUTGOING_WEBHOOK: outgoingWebhook.definition,
47
- EXECUTE_SCRIPT: executeScript.definition,
48
- EXECUTE_QUERY: executeQuery.definition,
49
- SERVER_LOG: serverLog.definition,
50
- DELAY: delay.definition,
51
- FILTER: filter.definition,
52
- QUERY_ROWS: queryRow.definition,
53
- LOOP: loop.definition,
54
- // these used to be lowercase step IDs, maintain for backwards compat
55
- discord: discord.definition,
56
- slack: slack.definition,
57
- zapier: zapier.definition,
58
- integromat: integromat.definition,
59
- }
48
+ export const BUILTIN_ACTION_DEFINITIONS: Record<string, AutomationStepSchema> =
49
+ {
50
+ SEND_EMAIL_SMTP: sendSmtpEmail.definition,
51
+ CREATE_ROW: createRow.definition,
52
+ UPDATE_ROW: updateRow.definition,
53
+ DELETE_ROW: deleteRow.definition,
54
+ OUTGOING_WEBHOOK: outgoingWebhook.definition,
55
+ EXECUTE_SCRIPT: executeScript.definition,
56
+ EXECUTE_QUERY: executeQuery.definition,
57
+ SERVER_LOG: serverLog.definition,
58
+ DELAY: delay.definition,
59
+ FILTER: filter.definition,
60
+ QUERY_ROWS: queryRow.definition,
61
+ LOOP: loop.definition,
62
+ // these used to be lowercase step IDs, maintain for backwards compat
63
+ discord: discord.definition,
64
+ slack: slack.definition,
65
+ zapier: zapier.definition,
66
+ integromat: integromat.definition,
67
+ }
60
68
 
61
69
  // don't add the bash script/definitions unless in self host
62
70
  // the fact this isn't included in any definitions means it cannot be
@@ -66,12 +74,36 @@ if (env.SELF_HOSTED) {
66
74
  // @ts-ignore
67
75
  ACTION_IMPLS["EXECUTE_BASH"] = bash.run
68
76
  // @ts-ignore
69
- ACTION_DEFINITIONS["EXECUTE_BASH"] = bash.definition
77
+ BUILTIN_ACTION_DEFINITIONS["EXECUTE_BASH"] = bash.definition
78
+ }
79
+
80
+ export async function getActionDefinitions() {
81
+ const actionDefinitions = BUILTIN_ACTION_DEFINITIONS
82
+ if (env.SELF_HOSTED) {
83
+ const plugins = await sdk.plugins.fetch(PluginType.AUTOMATION)
84
+ for (let plugin of plugins) {
85
+ const schema = plugin.schema.schema as AutomationStep
86
+ actionDefinitions[schema.stepId] = {
87
+ ...schema,
88
+ custom: true,
89
+ }
90
+ }
91
+ }
92
+ return actionDefinitions
70
93
  }
71
94
 
72
95
  /* istanbul ignore next */
73
- export async function getAction(actionName: string) {
74
- if (ACTION_IMPLS[actionName] != null) {
75
- return ACTION_IMPLS[actionName]
96
+ export async function getAction(stepId: string) {
97
+ if (ACTION_IMPLS[stepId] != null) {
98
+ return ACTION_IMPLS[stepId]
99
+ }
100
+ // must be a plugin
101
+ if (env.SELF_HOSTED) {
102
+ const plugins = await sdk.plugins.fetch(PluginType.AUTOMATION)
103
+ const found = plugins.find(plugin => plugin.schema.schema.stepId === stepId)
104
+ if (!found) {
105
+ throw new Error(`Unable to find action implementation for "${stepId}"`)
106
+ }
107
+ return (await getAutomationPlugin(found)).action
76
108
  }
77
109
  }
@@ -6,7 +6,7 @@ import BullQueue from "bull"
6
6
  export { automationQueue } from "./bullboard"
7
7
  export { shutdown } from "./bullboard"
8
8
  export { TRIGGER_DEFINITIONS } from "./triggers"
9
- export { ACTION_DEFINITIONS } from "./actions"
9
+ export { BUILTIN_ACTION_DEFINITIONS, getActionDefinitions } from "./actions"
10
10
 
11
11
  /**
12
12
  * This module is built purely to kick off the worker farm and manage the inputs/outputs
@@ -4,8 +4,11 @@ import * as automationUtils from "../automationUtils"
4
4
  import environment from "../../environment"
5
5
  import {
6
6
  AutomationActionStepId,
7
- AutomationStepSchema,
7
+ AutomationCustomIOType,
8
+ AutomationIOType,
8
9
  AutomationStepInput,
10
+ AutomationStepSchema,
11
+ AutomationStepType,
9
12
  } from "@budibase/types"
10
13
 
11
14
  export const definition: AutomationStepSchema = {
@@ -13,7 +16,7 @@ export const definition: AutomationStepSchema = {
13
16
  tagline: "Execute a bash command",
14
17
  icon: "JourneyEvent",
15
18
  description: "Run a bash script",
16
- type: "ACTION",
19
+ type: AutomationStepType.ACTION,
17
20
  internal: true,
18
21
  stepId: AutomationActionStepId.EXECUTE_BASH,
19
22
  inputs: {},
@@ -21,8 +24,8 @@ export const definition: AutomationStepSchema = {
21
24
  inputs: {
22
25
  properties: {
23
26
  code: {
24
- type: "string",
25
- customType: "code",
27
+ type: AutomationIOType.STRING,
28
+ customType: AutomationCustomIOType.CODE,
26
29
  title: "Code",
27
30
  },
28
31
  },
@@ -31,16 +34,16 @@ export const definition: AutomationStepSchema = {
31
34
  outputs: {
32
35
  properties: {
33
36
  stdout: {
34
- type: "string",
37
+ type: AutomationIOType.STRING,
35
38
  description: "Standard output of your bash command or script",
36
39
  },
37
40
  success: {
38
- type: "boolean",
41
+ type: AutomationIOType.BOOLEAN,
39
42
  description: "Whether the command was successful",
40
43
  },
41
44
  },
45
+ required: ["stdout"],
42
46
  },
43
- required: ["stdout"],
44
47
  },
45
48
  }
46
49
 
@@ -3,8 +3,11 @@ import { cleanUpRow, getError } from "../automationUtils"
3
3
  import { buildCtx } from "./utils"
4
4
  import {
5
5
  AutomationActionStepId,
6
- AutomationStepSchema,
6
+ AutomationCustomIOType,
7
+ AutomationIOType,
7
8
  AutomationStepInput,
9
+ AutomationStepSchema,
10
+ AutomationStepType,
8
11
  } from "@budibase/types"
9
12
 
10
13
  export const definition: AutomationStepSchema = {
@@ -12,7 +15,7 @@ export const definition: AutomationStepSchema = {
12
15
  tagline: "Create a {{inputs.enriched.table.name}} row",
13
16
  icon: "TableRowAddBottom",
14
17
  description: "Add a row to your database",
15
- type: "ACTION",
18
+ type: AutomationStepType.ACTION,
16
19
  internal: true,
17
20
  stepId: AutomationActionStepId.CREATE_ROW,
18
21
  inputs: {},
@@ -20,14 +23,14 @@ export const definition: AutomationStepSchema = {
20
23
  inputs: {
21
24
  properties: {
22
25
  row: {
23
- type: "object",
26
+ type: AutomationIOType.OBJECT,
24
27
  properties: {
25
28
  tableId: {
26
- type: "string",
27
- customType: "table",
29
+ type: AutomationIOType.STRING,
30
+ customType: AutomationCustomIOType.TABLE,
28
31
  },
29
32
  },
30
- customType: "row",
33
+ customType: AutomationCustomIOType.ROW,
31
34
  title: "Table",
32
35
  required: ["tableId"],
33
36
  },
@@ -37,24 +40,24 @@ export const definition: AutomationStepSchema = {
37
40
  outputs: {
38
41
  properties: {
39
42
  row: {
40
- type: "object",
41
- customType: "row",
43
+ type: AutomationIOType.OBJECT,
44
+ customType: AutomationCustomIOType.ROW,
42
45
  description: "The new row",
43
46
  },
44
47
  response: {
45
- type: "object",
48
+ type: AutomationIOType.OBJECT,
46
49
  description: "The response from the table",
47
50
  },
48
51
  success: {
49
- type: "boolean",
52
+ type: AutomationIOType.BOOLEAN,
50
53
  description: "Whether the row creation was successful",
51
54
  },
52
55
  id: {
53
- type: "string",
56
+ type: AutomationIOType.STRING,
54
57
  description: "The identifier of the new row",
55
58
  },
56
59
  revision: {
57
- type: "string",
60
+ type: AutomationIOType.STRING,
58
61
  description: "The revision of the new row",
59
62
  },
60
63
  },
@@ -1,8 +1,10 @@
1
1
  import { wait } from "../../utilities"
2
2
  import {
3
3
  AutomationActionStepId,
4
- AutomationStepSchema,
4
+ AutomationIOType,
5
5
  AutomationStepInput,
6
+ AutomationStepSchema,
7
+ AutomationStepType,
6
8
  } from "@budibase/types"
7
9
 
8
10
  export const definition: AutomationStepSchema = {
@@ -17,7 +19,7 @@ export const definition: AutomationStepSchema = {
17
19
  inputs: {
18
20
  properties: {
19
21
  time: {
20
- type: "number",
22
+ type: AutomationIOType.NUMBER,
21
23
  title: "Delay in milliseconds",
22
24
  },
23
25
  },
@@ -26,14 +28,14 @@ export const definition: AutomationStepSchema = {
26
28
  outputs: {
27
29
  properties: {
28
30
  success: {
29
- type: "boolean",
31
+ type: AutomationIOType.BOOLEAN,
30
32
  description: "Whether the delay was successful",
31
33
  },
32
34
  },
33
35
  required: ["success"],
34
36
  },
35
37
  },
36
- type: "LOGIC",
38
+ type: AutomationStepType.LOGIC,
37
39
  }
38
40
 
39
41
  export async function run({ inputs }: AutomationStepInput) {
@@ -3,8 +3,11 @@ import { buildCtx } from "./utils"
3
3
  import { getError } from "../automationUtils"
4
4
  import {
5
5
  AutomationActionStepId,
6
- AutomationStepSchema,
7
6
  AutomationStepInput,
7
+ AutomationStepSchema,
8
+ AutomationStepType,
9
+ AutomationIOType,
10
+ AutomationCustomIOType,
8
11
  } from "@budibase/types"
9
12
 
10
13
  export const definition: AutomationStepSchema = {
@@ -12,7 +15,7 @@ export const definition: AutomationStepSchema = {
12
15
  icon: "TableRowRemoveCenter",
13
16
  name: "Delete Row",
14
17
  tagline: "Delete a {{inputs.enriched.table.name}} row",
15
- type: "ACTION",
18
+ type: AutomationStepType.ACTION,
16
19
  stepId: AutomationActionStepId.DELETE_ROW,
17
20
  internal: true,
18
21
  inputs: {},
@@ -20,12 +23,12 @@ export const definition: AutomationStepSchema = {
20
23
  inputs: {
21
24
  properties: {
22
25
  tableId: {
23
- type: "string",
24
- customType: "table",
26
+ type: AutomationIOType.STRING,
27
+ customType: AutomationCustomIOType.TABLE,
25
28
  title: "Table",
26
29
  },
27
30
  id: {
28
- type: "string",
31
+ type: AutomationIOType.STRING,
29
32
  title: "Row ID",
30
33
  },
31
34
  },
@@ -34,16 +37,16 @@ export const definition: AutomationStepSchema = {
34
37
  outputs: {
35
38
  properties: {
36
39
  row: {
37
- type: "object",
38
- customType: "row",
40
+ type: AutomationIOType.OBJECT,
41
+ customType: AutomationCustomIOType.ROW,
39
42
  description: "The deleted row",
40
43
  },
41
44
  response: {
42
- type: "object",
45
+ type: AutomationIOType.OBJECT,
43
46
  description: "The response from the table",
44
47
  },
45
48
  success: {
46
- type: "boolean",
49
+ type: AutomationIOType.BOOLEAN,
47
50
  description: "Whether the deletion was successful",
48
51
  },
49
52
  },
@@ -4,6 +4,8 @@ import {
4
4
  AutomationActionStepId,
5
5
  AutomationStepSchema,
6
6
  AutomationStepInput,
7
+ AutomationStepType,
8
+ AutomationIOType,
7
9
  } from "@budibase/types"
8
10
 
9
11
  const DEFAULT_USERNAME = "Budibase Automate"
@@ -15,26 +17,26 @@ export const definition: AutomationStepSchema = {
15
17
  description: "Send a message to a Discord server",
16
18
  icon: "ri-discord-line",
17
19
  stepId: AutomationActionStepId.discord,
18
- type: "ACTION",
20
+ type: AutomationStepType.ACTION,
19
21
  internal: false,
20
22
  inputs: {},
21
23
  schema: {
22
24
  inputs: {
23
25
  properties: {
24
26
  url: {
25
- type: "string",
27
+ type: AutomationIOType.STRING,
26
28
  title: "Discord Webhook URL",
27
29
  },
28
30
  username: {
29
- type: "string",
31
+ type: AutomationIOType.STRING,
30
32
  title: "Bot Name",
31
33
  },
32
34
  avatar_url: {
33
- type: "string",
35
+ type: AutomationIOType.STRING,
34
36
  title: "Bot Avatar URL",
35
37
  },
36
38
  content: {
37
- type: "string",
39
+ type: AutomationIOType.STRING,
38
40
  title: "Message",
39
41
  },
40
42
  },
@@ -43,15 +45,15 @@ export const definition: AutomationStepSchema = {
43
45
  outputs: {
44
46
  properties: {
45
47
  httpStatus: {
46
- type: "number",
48
+ type: AutomationIOType.NUMBER,
47
49
  description: "The HTTP status code of the request",
48
50
  },
49
51
  response: {
50
- type: "string",
52
+ type: AutomationIOType.STRING,
51
53
  description: "The response from the Discord Webhook",
52
54
  },
53
55
  success: {
54
- type: "boolean",
56
+ type: AutomationIOType.BOOLEAN,
55
57
  description: "Whether the message sent successfully",
56
58
  },
57
59
  },