@budibase/server 2.6.19-alpha.0 → 2.6.20

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 (64) hide show
  1. package/builder/assets/{index.b9eeb2a8.js → index.69c5c1ea.js} +318 -310
  2. package/builder/assets/{index.07382a47.css → index.86c992bf.css} +2 -2
  3. package/builder/index.html +2 -2
  4. package/dist/api/controllers/datasource.js +39 -70
  5. package/dist/api/controllers/integration.js +2 -2
  6. package/dist/api/routes/datasource.js +0 -1
  7. package/dist/automations/steps/make.js +5 -19
  8. package/dist/automations/steps/zapier.js +6 -19
  9. package/dist/db/dynamoClient.js +1 -1
  10. package/dist/integrations/airtable.js +2 -28
  11. package/dist/integrations/arangodb.js +3 -19
  12. package/dist/integrations/couchdb.js +1 -16
  13. package/dist/integrations/dynamodb.js +0 -16
  14. package/dist/integrations/elasticsearch.js +0 -15
  15. package/dist/integrations/firebase.js +0 -15
  16. package/dist/integrations/googlesheets.js +1 -30
  17. package/dist/integrations/index.js +2 -5
  18. package/dist/integrations/microsoftSqlServer.js +0 -16
  19. package/dist/integrations/mongodb.js +0 -16
  20. package/dist/integrations/mysql.js +5 -21
  21. package/dist/integrations/oracle.js +0 -29
  22. package/dist/integrations/postgres.js +7 -26
  23. package/dist/integrations/redis.js +1 -20
  24. package/dist/integrations/s3.js +4 -23
  25. package/dist/integrations/snowflake.js +0 -15
  26. package/dist/migrations/functions/backfill/app/queries.js +2 -1
  27. package/dist/sdk/app/datasources/datasources.js +3 -10
  28. package/dist/sdk/users/utils.js +30 -23
  29. package/dist/tsconfig.build.tsbuildinfo +1 -1
  30. package/dist/utilities/global.js +1 -4
  31. package/jest.config.ts +3 -3
  32. package/nodemon.json +3 -7
  33. package/package.json +9 -10
  34. package/src/api/controllers/datasource.ts +49 -88
  35. package/src/api/controllers/integration.ts +3 -3
  36. package/src/api/routes/datasource.ts +0 -5
  37. package/src/automations/steps/make.ts +1 -18
  38. package/src/automations/steps/zapier.ts +1 -18
  39. package/src/automations/tests/zapier.spec.js +27 -0
  40. package/src/db/dynamoClient.ts +1 -1
  41. package/src/integration-test/postgres.spec.ts +1 -0
  42. package/src/integrations/airtable.ts +4 -31
  43. package/src/integrations/arangodb.ts +2 -18
  44. package/src/integrations/couchdb.ts +4 -18
  45. package/src/integrations/dynamodb.ts +5 -34
  46. package/src/integrations/elasticsearch.ts +1 -16
  47. package/src/integrations/firebase.ts +0 -15
  48. package/src/integrations/googlesheets.ts +2 -31
  49. package/src/integrations/index.ts +7 -12
  50. package/src/integrations/microsoftSqlServer.ts +0 -16
  51. package/src/integrations/mongodb.ts +0 -16
  52. package/src/integrations/mysql.ts +16 -27
  53. package/src/integrations/oracle.ts +6 -28
  54. package/src/integrations/postgres.ts +3 -21
  55. package/src/integrations/redis.ts +3 -26
  56. package/src/integrations/s3.ts +3 -19
  57. package/src/integrations/snowflake.ts +1 -20
  58. package/src/migrations/functions/backfill/app/queries.ts +1 -1
  59. package/src/sdk/app/datasources/datasources.ts +1 -7
  60. package/src/sdk/users/utils.ts +32 -24
  61. package/src/utilities/global.ts +1 -4
  62. package/tsconfig.json +1 -1
  63. package/src/automations/tests/make.spec.ts +0 -54
  64. package/src/automations/tests/zapier.spec.ts +0 -56
@@ -13,7 +13,6 @@ import {
13
13
  import { cloneDeep } from "lodash/fp"
14
14
  import { getEnvironmentVariables } from "../../utils"
15
15
  import { getDefinitions, getDefinition } from "../../../integrations"
16
- import _ from "lodash"
17
16
 
18
17
  const ENV_VAR_PREFIX = "env."
19
18
 
@@ -42,7 +41,7 @@ async function enrichDatasourceWithValues(datasource: Datasource) {
42
41
  { onlyFound: true }
43
42
  ) as Datasource
44
43
  const definition = await getDefinition(processed.source)
45
- processed.config = checkDatasourceTypes(definition!, processed.config)
44
+ processed.config = checkDatasourceTypes(definition, processed.config)
46
45
  return {
47
46
  datasource: processed,
48
47
  envVars: env as Record<string, string>,
@@ -148,11 +147,6 @@ export function mergeConfigs(update: Datasource, old: Datasource) {
148
147
  }
149
148
  }
150
149
  }
151
-
152
- if (old.config?.auth) {
153
- update.config = _.merge(old.config, update.config)
154
- }
155
-
156
150
  // update back to actual passwords for everything else
157
151
  for (let [key, value] of Object.entries(update.config)) {
158
152
  if (value !== PASSWORD_REPLACEMENT) {
@@ -7,7 +7,7 @@ import {
7
7
  InternalTables,
8
8
  } from "../../db/utils"
9
9
  import { isEqual } from "lodash"
10
- import { ContextUser, UserMetadata, User } from "@budibase/types"
10
+ import { ContextUser, UserMetadata, User, Database } from "@budibase/types"
11
11
 
12
12
  export function combineMetadataAndUser(
13
13
  user: ContextUser,
@@ -51,8 +51,10 @@ export function combineMetadataAndUser(
51
51
  return null
52
52
  }
53
53
 
54
- export async function rawUserMetadata() {
55
- const db = context.getAppDB()
54
+ export async function rawUserMetadata(db?: Database) {
55
+ if (!db) {
56
+ db = context.getAppDB()
57
+ }
56
58
  return (
57
59
  await db.allDocs(
58
60
  getUserMetadataParams(null, {
@@ -64,30 +66,36 @@ export async function rawUserMetadata() {
64
66
 
65
67
  export async function syncGlobalUsers() {
66
68
  // sync user metadata
67
- const db = context.getAppDB()
68
- const resp = await Promise.all([getGlobalUsers(), rawUserMetadata()])
69
- const users = resp[0] as User[]
70
- const metadata = resp[1] as UserMetadata[]
71
- const toWrite = []
72
- for (let user of users) {
73
- const combined = combineMetadataAndUser(user, metadata)
74
- if (combined) {
75
- toWrite.push(combined)
76
- }
77
- }
78
- let foundEmails: string[] = []
79
- for (let data of metadata) {
80
- if (!data._id) {
69
+ const dbs = [context.getDevAppDB(), context.getProdAppDB()]
70
+ for (let db of dbs) {
71
+ if (!(await db.exists())) {
81
72
  continue
82
73
  }
83
- const alreadyExisting = data.email && foundEmails.indexOf(data.email) !== -1
84
- const globalId = getGlobalIDFromUserMetadataID(data._id)
85
- if (!users.find(user => user._id === globalId) || alreadyExisting) {
86
- toWrite.push({ ...data, _deleted: true })
74
+ const resp = await Promise.all([getGlobalUsers(), rawUserMetadata(db)])
75
+ const users = resp[0] as User[]
76
+ const metadata = resp[1] as UserMetadata[]
77
+ const toWrite = []
78
+ for (let user of users) {
79
+ const combined = combineMetadataAndUser(user, metadata)
80
+ if (combined) {
81
+ toWrite.push(combined)
82
+ }
87
83
  }
88
- if (data.email) {
89
- foundEmails.push(data.email)
84
+ let foundEmails: string[] = []
85
+ for (let data of metadata) {
86
+ if (!data._id) {
87
+ continue
88
+ }
89
+ const alreadyExisting =
90
+ data.email && foundEmails.indexOf(data.email) !== -1
91
+ const globalId = getGlobalIDFromUserMetadataID(data._id)
92
+ if (!users.find(user => user._id === globalId) || alreadyExisting) {
93
+ toWrite.push({ ...data, _deleted: true })
94
+ }
95
+ if (data.email) {
96
+ foundEmails.push(data.email)
97
+ }
90
98
  }
99
+ await db.bulkDocs(toWrite)
91
100
  }
92
- await db.bulkDocs(toWrite)
93
101
  }
@@ -122,11 +122,8 @@ export async function getGlobalUsers(
122
122
  delete user.forceResetPassword
123
123
  return user
124
124
  })
125
- if (!appId) {
126
- return globalUsers
127
- }
128
125
 
129
- if (opts?.noProcessing) {
126
+ if (opts?.noProcessing || !appId) {
130
127
  return globalUsers
131
128
  } else {
132
129
  // pass in the groups, meaning we don't actually need to retrieve them for
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@budibase/backend-core": ["../backend-core/src"],
12
12
  "@budibase/backend-core/*": ["../backend-core/*"],
13
13
  "@budibase/shared-core": ["../shared-core/src"],
14
- "@budibase/pro": ["../pro/packages/pro/src"]
14
+ "@budibase/pro": ["../../../budibase-pro/packages/pro/src"]
15
15
  }
16
16
  },
17
17
  "ts-node": {
@@ -1,54 +0,0 @@
1
- import { getConfig, afterAll, runStep, actions } from "./utilities"
2
-
3
- describe("test the outgoing webhook action", () => {
4
- let config = getConfig()
5
-
6
- beforeAll(async () => {
7
- await config.init()
8
- })
9
-
10
- afterAll()
11
-
12
- it("should be able to run the action", async () => {
13
- const res = await runStep(actions.integromat.stepId, {
14
- value1: "test",
15
- url: "http://www.test.com",
16
- })
17
- expect(res.response.url).toEqual("http://www.test.com")
18
- expect(res.response.method).toEqual("post")
19
- expect(res.success).toEqual(true)
20
- })
21
-
22
- it("should add the payload props when a JSON string is provided", async () => {
23
- const payload = `{"value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
24
- const res = await runStep(actions.integromat.stepId, {
25
- value1: "ONE",
26
- value2: "TWO",
27
- value3: "THREE",
28
- value4: "FOUR",
29
- value5: "FIVE",
30
- body: {
31
- value: payload,
32
- },
33
- url: "http://www.test.com",
34
- })
35
- expect(res.response.url).toEqual("http://www.test.com")
36
- expect(res.response.method).toEqual("post")
37
- expect(res.response.body).toEqual(payload)
38
- expect(res.success).toEqual(true)
39
- })
40
-
41
- it("should return a 400 if the JSON payload string is malformed", async () => {
42
- const payload = `{ value1 1 }`
43
- const res = await runStep(actions.integromat.stepId, {
44
- value1: "ONE",
45
- body: {
46
- value: payload,
47
- },
48
- url: "http://www.test.com",
49
- })
50
- expect(res.httpStatus).toEqual(400)
51
- expect(res.response).toEqual("Invalid payload JSON")
52
- expect(res.success).toEqual(false)
53
- })
54
- })
@@ -1,56 +0,0 @@
1
- import { getConfig, afterAll, runStep, actions } from "./utilities"
2
-
3
- describe("test the outgoing webhook action", () => {
4
- let config = getConfig()
5
-
6
- beforeAll(async () => {
7
- await config.init()
8
- })
9
-
10
- afterAll()
11
-
12
- it("should be able to run the action", async () => {
13
- const res = await runStep(actions.zapier.stepId, {
14
- value1: "test",
15
- url: "http://www.test.com",
16
- })
17
- expect(res.response.url).toEqual("http://www.test.com")
18
- expect(res.response.method).toEqual("post")
19
- expect(res.success).toEqual(true)
20
- })
21
-
22
- it("should add the payload props when a JSON string is provided", async () => {
23
- const payload = `{ "value1": 1, "value2": 2, "value3": 3, "value4": 4, "value5": 5, "name": "Adam", "age": 9 }`
24
- const res = await runStep(actions.zapier.stepId, {
25
- value1: "ONE",
26
- value2: "TWO",
27
- value3: "THREE",
28
- value4: "FOUR",
29
- value5: "FIVE",
30
- body: {
31
- value: payload,
32
- },
33
- url: "http://www.test.com",
34
- })
35
- expect(res.response.url).toEqual("http://www.test.com")
36
- expect(res.response.method).toEqual("post")
37
- expect(res.response.body).toEqual(
38
- `{"platform":"budibase","value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
39
- )
40
- expect(res.success).toEqual(true)
41
- })
42
-
43
- it("should return a 400 if the JSON payload string is malformed", async () => {
44
- const payload = `{ value1 1 }`
45
- const res = await runStep(actions.zapier.stepId, {
46
- value1: "ONE",
47
- body: {
48
- value: payload,
49
- },
50
- url: "http://www.test.com",
51
- })
52
- expect(res.httpStatus).toEqual(400)
53
- expect(res.response).toEqual("Invalid payload JSON")
54
- expect(res.success).toEqual(false)
55
- })
56
- })