@budibase/server 2.4.42-alpha.8 → 2.4.43

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 (65) hide show
  1. package/builder/assets/favicon.e7fc7733.png +0 -0
  2. package/builder/assets/{index.89bb7cf4.js → index.8b377b88.js} +384 -385
  3. package/builder/assets/index.b0e3aca6.css +6 -0
  4. package/builder/index.html +7 -7
  5. package/dist/api/controllers/application.js +24 -28
  6. package/dist/api/controllers/row/external.js +0 -15
  7. package/dist/api/controllers/static/index.js +24 -84
  8. package/dist/api/controllers/static/templates/BudibaseApp.svelte +11 -34
  9. package/dist/api/controllers/table/utils.js +4 -2
  10. package/dist/api/routes/public/index.js +0 -8
  11. package/dist/app.js +0 -1
  12. package/dist/integrations/googlesheets.js +0 -4
  13. package/dist/integrations/redis.js +1 -1
  14. package/dist/middleware/currentapp.js +27 -1
  15. package/dist/package.json +12 -13
  16. package/dist/sdk/users/utils.js +6 -11
  17. package/dist/tsconfig.build.tsbuildinfo +1 -1
  18. package/dist/utilities/fileSystem/filesystem.js +0 -4
  19. package/dist/utilities/global.js +7 -17
  20. package/jest.config.ts +1 -1
  21. package/package.json +13 -14
  22. package/scripts/test.sh +5 -3
  23. package/specs/openapi.json +0 -39
  24. package/specs/openapi.yaml +0 -169
  25. package/specs/resources/application.ts +0 -11
  26. package/specs/resources/index.ts +0 -2
  27. package/src/api/controllers/application.ts +21 -20
  28. package/src/api/controllers/row/external.ts +0 -14
  29. package/src/api/controllers/static/index.ts +26 -69
  30. package/src/api/controllers/static/templates/BudibaseApp.svelte +11 -34
  31. package/src/api/controllers/table/utils.ts +12 -20
  32. package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +48 -48
  33. package/src/api/routes/public/index.ts +1 -10
  34. package/src/api/routes/tests/__snapshots__/datasource.spec.ts.snap +22 -22
  35. package/src/api/routes/tests/__snapshots__/view.spec.js.snap +5 -5
  36. package/src/api/routes/tests/appSync.spec.ts +1 -1
  37. package/src/api/routes/tests/internalSearch.spec.js +6 -6
  38. package/src/app.ts +1 -2
  39. package/src/automations/automationUtils.ts +1 -1
  40. package/src/automations/tests/automation.spec.js +84 -0
  41. package/src/db/defaultData/datasource_bb_default.ts +1 -1
  42. package/src/definitions/openapi.ts +0 -15
  43. package/src/integrations/googlesheets.ts +0 -4
  44. package/src/integrations/redis.ts +1 -1
  45. package/src/integrations/tests/googlesheets.spec.ts +0 -4
  46. package/src/integrations/tests/redis.spec.ts +5 -9
  47. package/src/middleware/currentapp.ts +32 -3
  48. package/src/middleware/tests/currentapp.spec.js +42 -6
  49. package/src/sdk/users/utils.ts +7 -18
  50. package/src/tests/jestSetup.ts +1 -5
  51. package/src/tests/utilities/TestConfiguration.ts +19 -7
  52. package/src/tests/utilities/structures.ts +1 -13
  53. package/src/utilities/fileSystem/filesystem.ts +0 -4
  54. package/src/utilities/global.ts +9 -21
  55. package/src/utilities/rowProcessor/index.ts +1 -1
  56. package/builder/assets/index.7f9a008b.css +0 -6
  57. package/dist/api/controllers/public/metrics.js +0 -113
  58. package/dist/api/routes/public/metrics.js +0 -30
  59. package/specs/resources/metrics.ts +0 -81
  60. package/src/api/controllers/public/metrics.ts +0 -251
  61. package/src/api/controllers/table/tests/utils.spec.ts +0 -97
  62. package/src/api/routes/public/metrics.ts +0 -28
  63. package/src/api/routes/public/tests/metrics.spec.js +0 -34
  64. package/src/automations/tests/automation.spec.ts +0 -99
  65. package/src/sdk/users/tests/utils.spec.ts +0 -159
@@ -1,99 +0,0 @@
1
- jest.mock("../../threads/automation")
2
- jest.mock("../../utilities/redis", () => ({
3
- init: jest.fn(),
4
- checkTestFlag: () => {
5
- return false
6
- },
7
- }))
8
-
9
- jest.spyOn(global.console, "error")
10
-
11
- import "../../environment"
12
- import * as automation from "../index"
13
- import * as thread from "../../threads/automation"
14
- import * as triggers from "../triggers"
15
- import { basicAutomation } from "../../tests/utilities/structures"
16
- import { wait } from "../../utilities"
17
- import { makePartial } from "../../tests/utilities"
18
- import { cleanInputValues } from "../automationUtils"
19
- import * as setup from "./utilities"
20
- import { Automation } from "@budibase/types"
21
-
22
- describe("Run through some parts of the automations system", () => {
23
- let config = setup.getConfig()
24
-
25
- beforeAll(async () => {
26
- await automation.init()
27
- await config.init()
28
- })
29
-
30
- afterAll(async () => {
31
- await automation.shutdown()
32
- setup.afterAll()
33
- })
34
-
35
- it("should be able to init in builder", async () => {
36
- const automation: Automation = {
37
- ...basicAutomation(),
38
- appId: config.appId,
39
- }
40
- const fields: any = { a: 1, appId: config.appId }
41
- await triggers.externalTrigger(automation, fields)
42
- await wait(100)
43
- expect(thread.execute).toHaveBeenCalled()
44
- })
45
-
46
- it("should check coercion", async () => {
47
- const table = await config.createTable()
48
- const automation: any = basicAutomation()
49
- automation.definition.trigger.inputs.tableId = table._id
50
- automation.definition.trigger.stepId = "APP"
51
- automation.definition.trigger.inputs.fields = { a: "number" }
52
- const fields: any = {
53
- appId: config.getAppId(),
54
- fields: {
55
- a: "1",
56
- },
57
- }
58
- await triggers.externalTrigger(automation, fields)
59
- await wait(100)
60
- expect(thread.execute).toHaveBeenCalledWith(
61
- makePartial({
62
- data: {
63
- event: {
64
- fields: {
65
- a: 1,
66
- },
67
- },
68
- },
69
- }),
70
- expect.any(Function)
71
- )
72
- })
73
-
74
- it("should be able to clean inputs with the utilities", () => {
75
- // can't clean without a schema
76
- let output = cleanInputValues({ a: "1" })
77
- expect(output.a).toBe("1")
78
- output = cleanInputValues(
79
- { a: "1", b: "true", c: "false", d: 1, e: "help" },
80
- {
81
- properties: {
82
- a: {
83
- type: "number",
84
- },
85
- b: {
86
- type: "boolean",
87
- },
88
- c: {
89
- type: "boolean",
90
- },
91
- },
92
- }
93
- )
94
- expect(output.a).toBe(1)
95
- expect(output.b).toBe(true)
96
- expect(output.c).toBe(false)
97
- expect(output.d).toBe(1)
98
- })
99
- })
@@ -1,159 +0,0 @@
1
- import { db, roles } from "@budibase/backend-core"
2
- import { structures } from "@budibase/backend-core/tests"
3
- import { sdk as proSdk } from "@budibase/pro"
4
-
5
- import TestConfiguration from "../../../tests/utilities/TestConfiguration"
6
- import { rawUserMetadata, syncGlobalUsers } from "../utils"
7
-
8
- describe("syncGlobalUsers", () => {
9
- const config = new TestConfiguration()
10
-
11
- beforeEach(async () => {
12
- await config.init()
13
- })
14
-
15
- afterAll(config.end)
16
-
17
- it("the default user is synced", async () => {
18
- await config.doInContext(config.appId, async () => {
19
- await syncGlobalUsers()
20
-
21
- const metadata = await rawUserMetadata()
22
- expect(metadata).toHaveLength(1)
23
- expect(metadata).toEqual([
24
- expect.objectContaining({
25
- _id: db.generateUserMetadataID(config.user._id),
26
- }),
27
- ])
28
- })
29
- })
30
-
31
- it("admin and builders users are synced", async () => {
32
- const user1 = await config.createUser({ admin: true })
33
- const user2 = await config.createUser({ admin: false, builder: true })
34
- await config.doInContext(config.appId, async () => {
35
- expect(await rawUserMetadata()).toHaveLength(1)
36
- await syncGlobalUsers()
37
-
38
- const metadata = await rawUserMetadata()
39
- expect(metadata).toHaveLength(3)
40
- expect(metadata).toContainEqual(
41
- expect.objectContaining({
42
- _id: db.generateUserMetadataID(user1._id),
43
- })
44
- )
45
- expect(metadata).toContainEqual(
46
- expect.objectContaining({
47
- _id: db.generateUserMetadataID(user2._id),
48
- })
49
- )
50
- })
51
- })
52
-
53
- it("app users are not synced if not specified", async () => {
54
- const user = await config.createUser({ admin: false, builder: false })
55
- await config.doInContext(config.appId, async () => {
56
- await syncGlobalUsers()
57
-
58
- const metadata = await rawUserMetadata()
59
- expect(metadata).toHaveLength(1)
60
- expect(metadata).not.toContainEqual(
61
- expect.objectContaining({
62
- _id: db.generateUserMetadataID(user._id),
63
- })
64
- )
65
- })
66
- })
67
-
68
- it("app users are added when group is assigned to app", async () => {
69
- await config.doInTenant(async () => {
70
- const group = await proSdk.groups.save(structures.userGroups.userGroup())
71
- const user1 = await config.createUser({ admin: false, builder: false })
72
- const user2 = await config.createUser({ admin: false, builder: false })
73
- await proSdk.groups.addUsers(group.id, [user1._id, user2._id])
74
-
75
- await config.doInContext(config.appId, async () => {
76
- await syncGlobalUsers()
77
- expect(await rawUserMetadata()).toHaveLength(1)
78
-
79
- await proSdk.groups.updateGroupApps(group.id, {
80
- appsToAdd: [
81
- { appId: config.prodAppId!, roleId: roles.BUILTIN_ROLE_IDS.BASIC },
82
- ],
83
- })
84
- await syncGlobalUsers()
85
-
86
- const metadata = await rawUserMetadata()
87
- expect(metadata).toHaveLength(3)
88
- expect(metadata).toContainEqual(
89
- expect.objectContaining({
90
- _id: db.generateUserMetadataID(user1._id),
91
- })
92
- )
93
- expect(metadata).toContainEqual(
94
- expect.objectContaining({
95
- _id: db.generateUserMetadataID(user2._id),
96
- })
97
- )
98
- })
99
- })
100
- })
101
-
102
- it("app users are removed when app is removed from user group", async () => {
103
- await config.doInTenant(async () => {
104
- const group = await proSdk.groups.save(structures.userGroups.userGroup())
105
- const user1 = await config.createUser({ admin: false, builder: false })
106
- const user2 = await config.createUser({ admin: false, builder: false })
107
- await proSdk.groups.updateGroupApps(group.id, {
108
- appsToAdd: [
109
- { appId: config.prodAppId!, roleId: roles.BUILTIN_ROLE_IDS.BASIC },
110
- ],
111
- })
112
- await proSdk.groups.addUsers(group.id, [user1._id, user2._id])
113
-
114
- await config.doInContext(config.appId, async () => {
115
- await syncGlobalUsers()
116
- expect(await rawUserMetadata()).toHaveLength(3)
117
-
118
- await proSdk.groups.updateGroupApps(group.id, {
119
- appsToRemove: [{ appId: config.prodAppId! }],
120
- })
121
- await syncGlobalUsers()
122
-
123
- const metadata = await rawUserMetadata()
124
- expect(metadata).toHaveLength(1)
125
- })
126
- })
127
- })
128
-
129
- it("app users are removed when app is removed from user group", async () => {
130
- await config.doInTenant(async () => {
131
- const group = await proSdk.groups.save(structures.userGroups.userGroup())
132
- const user1 = await config.createUser({ admin: false, builder: false })
133
- const user2 = await config.createUser({ admin: false, builder: false })
134
- await proSdk.groups.updateGroupApps(group.id, {
135
- appsToAdd: [
136
- { appId: config.prodAppId!, roleId: roles.BUILTIN_ROLE_IDS.BASIC },
137
- ],
138
- })
139
- await proSdk.groups.addUsers(group.id, [user1._id, user2._id])
140
-
141
- await config.doInContext(config.appId, async () => {
142
- await syncGlobalUsers()
143
- expect(await rawUserMetadata()).toHaveLength(3)
144
-
145
- await proSdk.groups.removeUsers(group.id, [user1._id])
146
- await syncGlobalUsers()
147
-
148
- const metadata = await rawUserMetadata()
149
- expect(metadata).toHaveLength(2)
150
-
151
- expect(metadata).not.toContainEqual(
152
- expect.objectContaining({
153
- _id: db.generateUserMetadataID(user1._id),
154
- })
155
- )
156
- })
157
- })
158
- })
159
- })