@budibase/server 1.0.220-alpha.2 → 1.0.221

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 (174) hide show
  1. package/builder/assets/index.4e12347e.js +977 -0
  2. package/builder/assets/index.58a51c8a.css +6 -0
  3. package/builder/assets/{vendor.001dcf8c.js → vendor.7f11b0ca.js} +74 -74
  4. package/builder/index.html +3 -3
  5. package/coverage/clover.xml +77 -76
  6. package/coverage/coverage-final.json +3 -3
  7. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +15 -15
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +18 -39
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  45. package/coverage/lcov-report/api/index.html +1 -1
  46. package/coverage/lcov-report/api/index.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/index.html +1 -1
  58. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/utils/index.html +5 -5
  72. package/coverage/lcov-report/api/routes/utils/validators.js.html +16 -4
  73. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  75. package/coverage/lcov-report/automations/actions.js.html +1 -1
  76. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  77. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  78. package/coverage/lcov-report/automations/index.html +1 -1
  79. package/coverage/lcov-report/automations/index.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/index.html +1 -1
  87. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  106. package/coverage/lcov-report/constants/index.html +1 -1
  107. package/coverage/lcov-report/constants/index.js.html +1 -1
  108. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  109. package/coverage/lcov-report/constants/screens.js.html +1 -1
  110. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  111. package/coverage/lcov-report/db/index.html +1 -1
  112. package/coverage/lcov-report/db/index.js.html +1 -1
  113. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  116. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  117. package/coverage/lcov-report/db/newid.js.html +1 -1
  118. package/coverage/lcov-report/db/utils.js.html +1 -1
  119. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  120. package/coverage/lcov-report/events/index.html +1 -1
  121. package/coverage/lcov-report/events/index.js.html +1 -1
  122. package/coverage/lcov-report/events/utils.js.html +1 -1
  123. package/coverage/lcov-report/index.html +21 -21
  124. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  125. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  126. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  127. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  128. package/coverage/lcov-report/middleware/currentapp.js.html +18 -6
  129. package/coverage/lcov-report/middleware/index.html +11 -11
  130. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  131. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  132. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  133. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  134. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  135. package/coverage/lcov-report/threads/automation.js.html +1 -1
  136. package/coverage/lcov-report/threads/index.html +1 -1
  137. package/coverage/lcov-report/threads/query.js.html +1 -1
  138. package/coverage/lcov-report/threads/utils.js.html +1 -1
  139. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  140. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  141. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  142. package/coverage/lcov-report/utilities/global.js.html +1 -1
  143. package/coverage/lcov-report/utilities/index.html +1 -1
  144. package/coverage/lcov-report/utilities/index.js.html +1 -1
  145. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  146. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  147. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  149. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  152. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  153. package/coverage/lcov-report/utilities/security.js.html +1 -1
  154. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  155. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  156. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  158. package/coverage/lcov-report/utilities/users.js.html +1 -1
  159. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  160. package/coverage/lcov.info +117 -118
  161. package/dist/api/controllers/application.js +16 -16
  162. package/dist/api/controllers/layout.js +6 -11
  163. package/dist/api/routes/utils/validators.js +4 -0
  164. package/dist/middleware/currentapp.js +3 -0
  165. package/dist/package.json +6 -6
  166. package/dist/tsconfig.build.tsbuildinfo +1 -1
  167. package/package.json +7 -7
  168. package/src/api/controllers/application.ts +16 -18
  169. package/src/api/controllers/layout.js +10 -17
  170. package/src/api/routes/tests/application.spec.js +5 -7
  171. package/src/api/routes/utils/validators.js +4 -0
  172. package/src/middleware/currentapp.js +4 -0
  173. package/builder/assets/index.7786f497.css +0 -6
  174. package/builder/assets/index.e1885c5f.js +0 -974
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.220-alpha.2",
4
+ "version": "1.0.221",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -77,10 +77,10 @@
77
77
  "license": "GPL-3.0",
78
78
  "dependencies": {
79
79
  "@apidevtools/swagger-parser": "10.0.3",
80
- "@budibase/backend-core": "^1.0.220-alpha.2",
81
- "@budibase/client": "^1.0.220-alpha.2",
82
- "@budibase/pro": "1.0.220-alpha.1",
83
- "@budibase/string-templates": "^1.0.220-alpha.2",
80
+ "@budibase/backend-core": "^1.0.221",
81
+ "@budibase/client": "^1.0.221",
82
+ "@budibase/pro": "1.0.220",
83
+ "@budibase/string-templates": "^1.0.221",
84
84
  "@bull-board/api": "3.7.0",
85
85
  "@bull-board/koa": "3.9.4",
86
86
  "@elastic/elasticsearch": "7.10.0",
@@ -151,7 +151,7 @@
151
151
  "@babel/core": "7.17.4",
152
152
  "@babel/preset-env": "7.16.11",
153
153
  "@budibase/standard-components": "^0.9.139",
154
- "@budibase/types": "^1.0.220-alpha.2",
154
+ "@budibase/types": "^1.0.221",
155
155
  "@jest/test-sequencer": "24.9.0",
156
156
  "@types/apidoc": "0.50.0",
157
157
  "@types/bson": "4.2.0",
@@ -195,5 +195,5 @@
195
195
  "optionalDependencies": {
196
196
  "oracledb": "5.3.0"
197
197
  },
198
- "gitHead": "80b7a2da2fba39ff25622873c95598fa931ea6ed"
198
+ "gitHead": "4e1904bba3bbec3d6f36827ecd012827b5e76cd8"
199
199
  }
@@ -276,16 +276,26 @@ const performAppCreate = async (ctx: any) => {
276
276
  updatedAt: new Date().toISOString(),
277
277
  createdAt: new Date().toISOString(),
278
278
  status: AppStatus.DEV,
279
+ navigation: {
280
+ navigation: "Top",
281
+ title: name,
282
+ navWidth: "Large",
283
+ navBackground: "var(--spectrum-global-color-gray-100)",
284
+ links: [
285
+ {
286
+ url: "/home",
287
+ text: "Home",
288
+ },
289
+ ],
290
+ },
291
+ theme: "spectrum--light",
292
+ customTheme: {
293
+ buttonBorderRadius: "16px",
294
+ },
279
295
  }
280
296
  const response = await db.put(newApplication, { force: true })
281
297
  newApplication._rev = response.rev
282
298
 
283
- // Only create the default home screens and layout if we aren't importing
284
- // an app
285
- if (useTemplate !== "true") {
286
- await createEmptyAppPackage(ctx, newApplication)
287
- }
288
-
289
299
  /* istanbul ignore next */
290
300
  if (!env.isTest()) {
291
301
  await createApp(appId)
@@ -565,15 +575,3 @@ const updateAppPackage = async (appPackage: any, appId: any) => {
565
575
  return newAppPackage
566
576
  })
567
577
  }
568
-
569
- const createEmptyAppPackage = async (ctx: any, app: any) => {
570
- const db = getAppDB()
571
-
572
- let screensAndLayouts = []
573
- for (let layout of BASE_LAYOUTS) {
574
- const cloned = cloneDeep(layout)
575
- screensAndLayouts.push(await processObject(cloned, app))
576
- }
577
-
578
- await db.bulkDocs(screensAndLayouts)
579
- }
@@ -1,7 +1,4 @@
1
- const {
2
- EMPTY_LAYOUT,
3
- BASE_LAYOUT_PROP_IDS,
4
- } = require("../../constants/layouts")
1
+ const { EMPTY_LAYOUT } = require("../../constants/layouts")
5
2
  const { generateLayoutID, getScreenParams } = require("../../db/utils")
6
3
  const { getAppDB } = require("@budibase/backend-core/context")
7
4
  const { events } = require("@budibase/backend-core")
@@ -32,19 +29,15 @@ exports.destroy = async function (ctx) {
32
29
  const layoutId = ctx.params.layoutId,
33
30
  layoutRev = ctx.params.layoutRev
34
31
 
35
- if (Object.values(BASE_LAYOUT_PROP_IDS).includes(layoutId)) {
36
- ctx.throw(400, "Cannot delete a built-in layout")
37
- } else {
38
- const layoutsUsedByScreens = (
39
- await db.allDocs(
40
- getScreenParams(null, {
41
- include_docs: true,
42
- })
43
- )
44
- ).rows.map(element => element.doc.layoutId)
45
- if (layoutsUsedByScreens.includes(layoutId)) {
46
- ctx.throw(400, "Cannot delete a layout that's being used by a screen")
47
- }
32
+ const layoutsUsedByScreens = (
33
+ await db.allDocs(
34
+ getScreenParams(null, {
35
+ include_docs: true,
36
+ })
37
+ )
38
+ ).rows.map(element => element.doc.layoutId)
39
+ if (layoutsUsedByScreens.includes(layoutId)) {
40
+ ctx.throw(400, "Cannot delete a layout that's being used by a screen")
48
41
  }
49
42
 
50
43
  await db.remove(layoutId, layoutRev)
@@ -59,14 +59,13 @@ describe("/applications", () => {
59
59
  expect(events.app.templateImported).toBeCalledTimes(1)
60
60
  })
61
61
 
62
-
63
62
  it("creates app from file", async () => {
64
63
  const res = await request
65
64
  .post("/api/applications")
66
65
  .field("name", "My App")
67
66
  .field("useTemplate", "true")
68
67
  .set(config.defaultHeaders())
69
- .attach('templateFile', 'src/api/routes/tests/data/export.txt')
68
+ .attach("templateFile", "src/api/routes/tests/data/export.txt")
70
69
  .expect("Content-Type", /json/)
71
70
  .expect(200)
72
71
  expect(res.body._id).toBeDefined()
@@ -107,8 +106,7 @@ describe("/applications", () => {
107
106
  .set(config.defaultHeaders())
108
107
  .expect("Content-Type", /json/)
109
108
  .expect(200)
110
- // should have empty packages
111
- expect(res.body.layouts.length).toEqual(2)
109
+ expect(res.body.libraries.length).toEqual(1)
112
110
  })
113
111
  })
114
112
 
@@ -120,7 +118,7 @@ describe("/applications", () => {
120
118
  .expect("Content-Type", /json/)
121
119
  .expect(200)
122
120
  expect(res.body.application).toBeDefined()
123
- expect(res.body.layouts.length).toEqual(2)
121
+ expect(res.body.application.appId).toEqual(config.getAppId())
124
122
  })
125
123
  })
126
124
 
@@ -171,7 +169,7 @@ describe("/applications", () => {
171
169
  .set(config.defaultHeaders())
172
170
  .expect("Content-Type", /json/)
173
171
  .expect(200)
174
- expect(events.app.versionUpdated).toBeCalledTimes(1)
172
+ expect(events.app.versionUpdated).toBeCalledTimes(1)
175
173
  })
176
174
  it("should be able to revert the app client library version", async () => {
177
175
  // We need to first update the version so that we can then revert
@@ -185,7 +183,7 @@ describe("/applications", () => {
185
183
  .set(config.defaultHeaders())
186
184
  .expect("Content-Type", /json/)
187
185
  .expect(200)
188
- expect(events.app.versionReverted).toBeCalledTimes(1)
186
+ expect(events.app.versionReverted).toBeCalledTimes(1)
189
187
  })
190
188
  })
191
189
 
@@ -9,6 +9,7 @@ const Joi = require("joi")
9
9
 
10
10
  const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("")
11
11
  const OPTIONAL_NUMBER = Joi.number().optional().allow(null)
12
+ const OPTIONAL_BOOLEAN = Joi.boolean().optional().allow(null)
12
13
 
13
14
  exports.tableValidator = () => {
14
15
  // prettier-ignore
@@ -160,9 +161,12 @@ exports.screenValidator = () => {
160
161
  // prettier-ignore
161
162
  return joiValidator.body(Joi.object({
162
163
  name: Joi.string().required(),
164
+ showNavigation: OPTIONAL_BOOLEAN,
165
+ width: OPTIONAL_STRING,
163
166
  routing: Joi.object({
164
167
  route: Joi.string().required(),
165
168
  roleId: Joi.string().required().allow(""),
169
+ homeScreen: OPTIONAL_BOOLEAN,
166
170
  }).required().unknown(true),
167
171
  props: Joi.object({
168
172
  _id: Joi.string().required(),
@@ -74,6 +74,10 @@ module.exports = async (ctx, next) => {
74
74
  try {
75
75
  await getRole(roleHeader)
76
76
  roleId = roleHeader
77
+
78
+ // Delete admin and builder flags so that the specified role is honoured
79
+ delete ctx.user.builder
80
+ delete ctx.user.admin
77
81
  } catch (error) {
78
82
  // Swallow error and do nothing
79
83
  }