@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
@@ -37,10 +37,6 @@ const init = () => {
37
37
  }
38
38
  }
39
39
  }
40
- const clientLibPath = (0, path_1.join)((0, budibaseDir_1.budibaseTempDir)(), "budibase-client.js");
41
- if (environment_1.default.isTest() && !fs_1.default.existsSync(clientLibPath)) {
42
- fs_1.default.copyFileSync(require.resolve("@budibase/client"), clientLibPath);
43
- }
44
40
  };
45
41
  exports.init = init;
46
42
  /**
@@ -45,33 +45,26 @@ function updateAppRole(user, { appId } = {}) {
45
45
  return user;
46
46
  }
47
47
  exports.updateAppRole = updateAppRole;
48
- function checkGroupRoles(user, opts = {}) {
48
+ function checkGroupRoles(user, { appId } = {}) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
50
  if (user.roleId && user.roleId !== backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC) {
51
51
  return user;
52
52
  }
53
- if (opts.appId) {
54
- user.roleId = yield pro_1.groups.getGroupRoleId(user, opts.appId, {
55
- groups: opts.groups,
56
- });
57
- }
58
- // final fallback, simply couldn't find a role - user must be public
59
- if (!user.roleId) {
60
- user.roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC;
53
+ if (appId) {
54
+ user.roleId = yield pro_1.groups.getGroupRoleId(user, appId);
61
55
  }
62
56
  return user;
63
57
  });
64
58
  }
65
- function processUser(user, opts = {}) {
59
+ function processUser(user, { appId } = {}) {
66
60
  var _a;
67
61
  return __awaiter(this, void 0, void 0, function* () {
68
62
  if (user) {
69
63
  delete user.password;
70
64
  }
71
- const appId = opts.appId || backend_core_1.context.getAppId();
72
- user = updateAppRole(user, { appId });
65
+ user = yield updateAppRole(user, { appId });
73
66
  if (!user.roleId && ((_a = user === null || user === void 0 ? void 0 : user.userGroups) === null || _a === void 0 ? void 0 : _a.length)) {
74
- user = yield checkGroupRoles(user, { appId, groups: opts === null || opts === void 0 ? void 0 : opts.groups });
67
+ user = yield checkGroupRoles(user, { appId });
75
68
  }
76
69
  return user;
77
70
  });
@@ -105,7 +98,6 @@ function getGlobalUsers(users) {
105
98
  return __awaiter(this, void 0, void 0, function* () {
106
99
  const appId = backend_core_1.context.getAppId();
107
100
  const db = backend_core_1.tenancy.getGlobalDB();
108
- const allGroups = yield pro_1.groups.fetch();
109
101
  let globalUsers;
110
102
  if (users) {
111
103
  const globalIds = users.map(user => (0, utils_1.getGlobalIDFromUserMetadataID)(user._id));
@@ -126,9 +118,7 @@ function getGlobalUsers(users) {
126
118
  if (!appId) {
127
119
  return globalUsers;
128
120
  }
129
- // pass in the groups, meaning we don't actually need to retrieve them for
130
- // each user individually
131
- return Promise.all(globalUsers.map(user => processUser(user, { groups: allGroups })));
121
+ return globalUsers.map(user => updateAppRole(user));
132
122
  });
133
123
  }
134
124
  exports.getGlobalUsers = getGlobalUsers;
package/jest.config.ts CHANGED
@@ -43,7 +43,7 @@ const config: Config.InitialOptions = {
43
43
  "../backend-core/src/**/*.{js,ts}",
44
44
  // The use of coverage with couchdb view functions breaks tests
45
45
  "!src/db/views/staticViews.*",
46
- "!src/**/*.spec.{js,ts}",
46
+ "!src/tests/**/*.{js,ts}",
47
47
  ],
48
48
  coverageReporters: ["lcov", "json", "clover"],
49
49
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.42-alpha.8",
4
+ "version": "2.4.43",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -14,8 +14,7 @@
14
14
  "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
15
15
  "debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",
16
16
  "postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/",
17
- "test": "NODE_OPTIONS=\"--max-old-space-size=4096\" bash scripts/test.sh",
18
- "test:memory": "jest --maxWorkers=2 --logHeapUsage --forceExit",
17
+ "test": "bash scripts/test.sh",
19
18
  "test:watch": "jest --watch",
20
19
  "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client",
21
20
  "build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
@@ -44,12 +43,12 @@
44
43
  "license": "GPL-3.0",
45
44
  "dependencies": {
46
45
  "@apidevtools/swagger-parser": "10.0.3",
47
- "@budibase/backend-core": "2.4.42-alpha.8",
48
- "@budibase/client": "2.4.42-alpha.8",
49
- "@budibase/pro": "2.4.42-alpha.7",
50
- "@budibase/shared-core": "2.4.42-alpha.8",
51
- "@budibase/string-templates": "2.4.42-alpha.8",
52
- "@budibase/types": "2.4.42-alpha.8",
46
+ "@budibase/backend-core": "^2.4.43",
47
+ "@budibase/client": "^2.4.43",
48
+ "@budibase/pro": "2.4.42",
49
+ "@budibase/shared-core": "^2.4.43",
50
+ "@budibase/string-templates": "^2.4.43",
51
+ "@budibase/types": "^2.4.43",
53
52
  "@bull-board/api": "3.7.0",
54
53
  "@bull-board/koa": "3.9.4",
55
54
  "@elastic/elasticsearch": "7.10.0",
@@ -126,7 +125,7 @@
126
125
  "@babel/core": "7.17.4",
127
126
  "@babel/preset-env": "7.16.11",
128
127
  "@budibase/standard-components": "^0.9.139",
129
- "@jest/test-sequencer": "29.5.0",
128
+ "@jest/test-sequencer": "24.9.0",
130
129
  "@swc/core": "^1.3.25",
131
130
  "@swc/jest": "^0.2.24",
132
131
  "@trendyol/jest-testcontainers": "^2.1.1",
@@ -135,7 +134,7 @@
135
134
  "@types/global-agent": "2.1.1",
136
135
  "@types/google-spreadsheet": "3.1.5",
137
136
  "@types/ioredis": "4.28.10",
138
- "@types/jest": "29.5.0",
137
+ "@types/jest": "27.5.1",
139
138
  "@types/koa": "2.13.4",
140
139
  "@types/koa__router": "8.0.8",
141
140
  "@types/lodash": "4.14.180",
@@ -155,7 +154,7 @@
155
154
  "eslint": "6.8.0",
156
155
  "ioredis-mock": "7.2.0",
157
156
  "is-wsl": "2.2.0",
158
- "jest": "29.5.0",
157
+ "jest": "28.1.1",
159
158
  "jest-openapi": "0.14.2",
160
159
  "jest-serial-runner": "^1.2.1",
161
160
  "nodemon": "2.0.15",
@@ -167,7 +166,7 @@
167
166
  "supertest": "6.2.2",
168
167
  "swagger-jsdoc": "6.1.0",
169
168
  "timekeeper": "2.2.0",
170
- "ts-jest": "29.0.5",
169
+ "ts-jest": "28.0.4",
171
170
  "ts-node": "10.8.1",
172
171
  "tsconfig-paths": "4.0.0",
173
172
  "typescript": "4.7.3",
@@ -176,5 +175,5 @@
176
175
  "optionalDependencies": {
177
176
  "oracledb": "5.3.0"
178
177
  },
179
- "gitHead": "41669d5513e4c0c199aae0d1d85bdca3ecceaaf6"
178
+ "gitHead": "0648b19ecff921f3444e1677904846a5b470c329"
180
179
  }
package/scripts/test.sh CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/bin/bash
2
+ set -e
2
3
 
3
4
  if [[ -n $CI ]]
4
5
  then
5
6
  # --runInBand performs better in ci where resources are limited
7
+ export NODE_OPTIONS="--max-old-space-size=4096"
6
8
  echo "jest --coverage --runInBand --forceExit"
7
9
  jest --coverage --runInBand --forceExit
8
10
  else
9
11
  # --maxWorkers performs better in development
10
- echo "jest --coverage --maxWorkers=2"
11
- jest --coverage --maxWorkers=2
12
- fi
12
+ echo "jest --coverage --maxWorkers=2 --forceExit"
13
+ jest --coverage --maxWorkers=2 --forceExit
14
+ fi
@@ -115,15 +115,6 @@
115
115
  ]
116
116
  }
117
117
  },
118
- "deploymentOutput": {
119
- "value": {
120
- "data": {
121
- "_id": "ef12381f934b4f129675cdbb76eff3c2",
122
- "status": "SUCCESS",
123
- "appUrl": "/app-url"
124
- }
125
- }
126
- },
127
118
  "inputRow": {
128
119
  "value": {
129
120
  "_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
@@ -422,9 +413,6 @@
422
413
  }
423
414
  ]
424
415
  }
425
- },
426
- "metrics": {
427
- "value": "# HELP budibase_os_uptime Time in seconds that the host operating system has been up.\n# TYPE budibase_os_uptime counter\nbudibase_os_uptime 54958\n# HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.\n# TYPE budibase_os_free_mem gauge\nbudibase_os_free_mem 804507648\n# HELP budibase_os_total_mem Total bytes of memory on the host operating system.\n# TYPE budibase_os_total_mem gauge\nbudibase_os_total_mem 16742404096\n# HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.\n# TYPE budibase_os_used_mem gauge\nbudibase_os_used_mem 15937896448\n# HELP budibase_os_load1 Host operating system load average.\n# TYPE budibase_os_load1 gauge\nbudibase_os_load1 1.91\n# HELP budibase_os_load5 Host operating system load average.\n# TYPE budibase_os_load5 gauge\nbudibase_os_load5 1.75\n# HELP budibase_os_load15 Host operating system load average.\n# TYPE budibase_os_load15 gauge\nbudibase_os_load15 1.56\n# HELP budibase_tenant_user_count The number of users created.\n# TYPE budibase_tenant_user_count gauge\nbudibase_tenant_user_count 1\n# HELP budibase_tenant_app_count The number of apps created by a user.\n# TYPE budibase_tenant_app_count gauge\nbudibase_tenant_app_count 2\n# HELP budibase_tenant_production_app_count The number of apps a user has published.\n# TYPE budibase_tenant_production_app_count gauge\nbudibase_tenant_production_app_count 1\n# HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.\n# TYPE budibase_tenant_dev_app_count gauge\nbudibase_tenant_dev_app_count 1\n# HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.\n# TYPE budibase_tenant_db_count gauge\nbudibase_tenant_db_count 3\n# HELP budibase_quota_usage_apps The number of apps created.\n# TYPE budibase_quota_usage_apps gauge\nbudibase_quota_usage_apps 1\n# HELP budibase_quota_limit_apps The limit on the number of apps that can be created.\n# TYPE budibase_quota_limit_apps gauge\nbudibase_quota_limit_apps 9007199254740991\n# HELP budibase_quota_usage_rows The number of database rows used from the quota.\n# TYPE budibase_quota_usage_rows gauge\nbudibase_quota_usage_rows 0\n# HELP budibase_quota_limit_rows The limit on the number of rows that can be created.\n# TYPE budibase_quota_limit_rows gauge\nbudibase_quota_limit_rows 9007199254740991\n# HELP budibase_quota_usage_plugins The number of plugins in use.\n# TYPE budibase_quota_usage_plugins gauge\nbudibase_quota_usage_plugins 0\n# HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.\n# TYPE budibase_quota_limit_plugins gauge\nbudibase_quota_limit_plugins 9007199254740991\n# HELP budibase_quota_usage_user_groups The number of user groups created.\n# TYPE budibase_quota_usage_user_groups gauge\nbudibase_quota_usage_user_groups 0\n# HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.\n# TYPE budibase_quota_limit_user_groups gauge\nbudibase_quota_limit_user_groups 9007199254740991\n# HELP budibase_quota_usage_queries The number of queries used in the current month.\n# TYPE budibase_quota_usage_queries gauge\nbudibase_quota_usage_queries 0\n# HELP budibase_quota_limit_queries The limit on the number of queries for the current month.\n# TYPE budibase_quota_limit_queries gauge\nbudibase_quota_limit_queries 9007199254740991\n# HELP budibase_quota_usage_automations The number of automations used in the current month.\n# TYPE budibase_quota_usage_automations gauge\nbudibase_quota_usage_automations 0\n# HELP budibase_quota_limit_automations The limit on the number of automations that can be created.\n# TYPE budibase_quota_limit_automations gauge\nbudibase_quota_limit_automations 9007199254740991\n"
428
416
  }
429
417
  },
430
418
  "securitySchemes": {
@@ -2066,33 +2054,6 @@
2066
2054
  }
2067
2055
  }
2068
2056
  },
2069
- "/metrics": {
2070
- "get": {
2071
- "operationId": "metricsGet",
2072
- "summary": "Retrieve Budibase tenant metrics",
2073
- "description": "Output metrics in OpenMetrics format compatible with Prometheus",
2074
- "tags": [
2075
- "metrics"
2076
- ],
2077
- "responses": {
2078
- "200": {
2079
- "description": "Returns tenant metrics.",
2080
- "content": {
2081
- "text/plain": {
2082
- "schema": {
2083
- "type": "string"
2084
- },
2085
- "examples": {
2086
- "metrics": {
2087
- "$ref": "#/components/examples/metrics"
2088
- }
2089
- }
2090
- }
2091
- }
2092
- }
2093
- }
2094
- }
2095
- },
2096
2057
  "/queries/{queryId}": {
2097
2058
  "post": {
2098
2059
  "operationId": "queryExecute",
@@ -85,12 +85,6 @@ components:
85
85
  updatedAt: 2022-02-22T13:00:54.035Z
86
86
  createdAt: 2022-02-11T18:02:26.961Z
87
87
  status: development
88
- deploymentOutput:
89
- value:
90
- data:
91
- _id: ef12381f934b4f129675cdbb76eff3c2
92
- status: SUCCESS
93
- appUrl: /app-url
94
88
  inputRow:
95
89
  value:
96
90
  _id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
@@ -296,152 +290,6 @@ components:
296
290
  name: Admin
297
291
  permissionId: admin
298
292
  inherits: POWER
299
- metrics:
300
- value: >
301
- # HELP budibase_os_uptime Time in seconds that the host operating system
302
- has been up.
303
-
304
- # TYPE budibase_os_uptime counter
305
-
306
- budibase_os_uptime 54958
307
-
308
- # HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.
309
-
310
- # TYPE budibase_os_free_mem gauge
311
-
312
- budibase_os_free_mem 804507648
313
-
314
- # HELP budibase_os_total_mem Total bytes of memory on the host operating system.
315
-
316
- # TYPE budibase_os_total_mem gauge
317
-
318
- budibase_os_total_mem 16742404096
319
-
320
- # HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.
321
-
322
- # TYPE budibase_os_used_mem gauge
323
-
324
- budibase_os_used_mem 15937896448
325
-
326
- # HELP budibase_os_load1 Host operating system load average.
327
-
328
- # TYPE budibase_os_load1 gauge
329
-
330
- budibase_os_load1 1.91
331
-
332
- # HELP budibase_os_load5 Host operating system load average.
333
-
334
- # TYPE budibase_os_load5 gauge
335
-
336
- budibase_os_load5 1.75
337
-
338
- # HELP budibase_os_load15 Host operating system load average.
339
-
340
- # TYPE budibase_os_load15 gauge
341
-
342
- budibase_os_load15 1.56
343
-
344
- # HELP budibase_tenant_user_count The number of users created.
345
-
346
- # TYPE budibase_tenant_user_count gauge
347
-
348
- budibase_tenant_user_count 1
349
-
350
- # HELP budibase_tenant_app_count The number of apps created by a user.
351
-
352
- # TYPE budibase_tenant_app_count gauge
353
-
354
- budibase_tenant_app_count 2
355
-
356
- # HELP budibase_tenant_production_app_count The number of apps a user has published.
357
-
358
- # TYPE budibase_tenant_production_app_count gauge
359
-
360
- budibase_tenant_production_app_count 1
361
-
362
- # HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.
363
-
364
- # TYPE budibase_tenant_dev_app_count gauge
365
-
366
- budibase_tenant_dev_app_count 1
367
-
368
- # HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.
369
-
370
- # TYPE budibase_tenant_db_count gauge
371
-
372
- budibase_tenant_db_count 3
373
-
374
- # HELP budibase_quota_usage_apps The number of apps created.
375
-
376
- # TYPE budibase_quota_usage_apps gauge
377
-
378
- budibase_quota_usage_apps 1
379
-
380
- # HELP budibase_quota_limit_apps The limit on the number of apps that can be created.
381
-
382
- # TYPE budibase_quota_limit_apps gauge
383
-
384
- budibase_quota_limit_apps 9007199254740991
385
-
386
- # HELP budibase_quota_usage_rows The number of database rows used from the quota.
387
-
388
- # TYPE budibase_quota_usage_rows gauge
389
-
390
- budibase_quota_usage_rows 0
391
-
392
- # HELP budibase_quota_limit_rows The limit on the number of rows that can be created.
393
-
394
- # TYPE budibase_quota_limit_rows gauge
395
-
396
- budibase_quota_limit_rows 9007199254740991
397
-
398
- # HELP budibase_quota_usage_plugins The number of plugins in use.
399
-
400
- # TYPE budibase_quota_usage_plugins gauge
401
-
402
- budibase_quota_usage_plugins 0
403
-
404
- # HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.
405
-
406
- # TYPE budibase_quota_limit_plugins gauge
407
-
408
- budibase_quota_limit_plugins 9007199254740991
409
-
410
- # HELP budibase_quota_usage_user_groups The number of user groups created.
411
-
412
- # TYPE budibase_quota_usage_user_groups gauge
413
-
414
- budibase_quota_usage_user_groups 0
415
-
416
- # HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.
417
-
418
- # TYPE budibase_quota_limit_user_groups gauge
419
-
420
- budibase_quota_limit_user_groups 9007199254740991
421
-
422
- # HELP budibase_quota_usage_queries The number of queries used in the current month.
423
-
424
- # TYPE budibase_quota_usage_queries gauge
425
-
426
- budibase_quota_usage_queries 0
427
-
428
- # HELP budibase_quota_limit_queries The limit on the number of queries for the current month.
429
-
430
- # TYPE budibase_quota_limit_queries gauge
431
-
432
- budibase_quota_limit_queries 9007199254740991
433
-
434
- # HELP budibase_quota_usage_automations The number of automations used in the current month.
435
-
436
- # TYPE budibase_quota_usage_automations gauge
437
-
438
- budibase_quota_usage_automations 0
439
-
440
- # HELP budibase_quota_limit_automations The limit on the number of automations that can be created.
441
-
442
- # TYPE budibase_quota_limit_automations gauge
443
-
444
- budibase_quota_limit_automations 9007199254740991
445
293
  securitySchemes:
446
294
  ApiKeyAuth:
447
295
  type: apiKey
@@ -1683,23 +1531,6 @@ paths:
1683
1531
  examples:
1684
1532
  applications:
1685
1533
  $ref: "#/components/examples/applications"
1686
- /metrics:
1687
- get:
1688
- operationId: metricsGet
1689
- summary: Retrieve Budibase tenant metrics
1690
- description: Output metrics in OpenMetrics format compatible with Prometheus
1691
- tags:
1692
- - metrics
1693
- responses:
1694
- "200":
1695
- description: Returns tenant metrics.
1696
- content:
1697
- text/plain:
1698
- schema:
1699
- type: string
1700
- examples:
1701
- metrics:
1702
- $ref: "#/components/examples/metrics"
1703
1534
  "/queries/{queryId}":
1704
1535
  post:
1705
1536
  operationId: queryExecute
@@ -15,12 +15,6 @@ const application = {
15
15
  lockedBy: userResource.getExamples().user.value.user,
16
16
  }
17
17
 
18
- const deployment = {
19
- _id: "ef12381f934b4f129675cdbb76eff3c2",
20
- status: "SUCCESS",
21
- appUrl: "/app-url",
22
- }
23
-
24
18
  const base = {
25
19
  name: {
26
20
  description: "The name of the app.",
@@ -114,11 +108,6 @@ export default new Resource()
114
108
  data: [application],
115
109
  },
116
110
  },
117
- deploymentOutput: {
118
- value: {
119
- data: deployment,
120
- },
121
- },
122
111
  })
123
112
  .setSchemas({
124
113
  application: applicationSchema,
@@ -3,7 +3,6 @@ import row from "./row"
3
3
  import table from "./table"
4
4
  import query from "./query"
5
5
  import user from "./user"
6
- import metrics from "./metrics"
7
6
  import misc from "./misc"
8
7
 
9
8
  export const examples = {
@@ -13,7 +12,6 @@ export const examples = {
13
12
  ...query.getExamples(),
14
13
  ...user.getExamples(),
15
14
  ...misc.getExamples(),
16
- ...metrics.getExamples(),
17
15
  }
18
16
 
19
17
  export const schemas = {
@@ -20,10 +20,10 @@ import {
20
20
  cache,
21
21
  tenancy,
22
22
  context,
23
+ errors,
23
24
  events,
24
25
  migrations,
25
26
  objectStore,
26
- ErrorCode,
27
27
  } from "@budibase/backend-core"
28
28
  import { USERS_TABLE_SCHEMA } from "../../constants"
29
29
  import { buildDefaultDocs } from "../../db/defaultData/datasource_bb_default"
@@ -44,6 +44,7 @@ import {
44
44
  Layout,
45
45
  Screen,
46
46
  MigrationType,
47
+ BBContext,
47
48
  Database,
48
49
  UserCtx,
49
50
  } from "@budibase/types"
@@ -73,14 +74,14 @@ async function getScreens() {
73
74
  ).rows.map((row: any) => row.doc)
74
75
  }
75
76
 
76
- function getUserRoleId(ctx: UserCtx) {
77
+ function getUserRoleId(ctx: BBContext) {
77
78
  return !ctx.user?.role || !ctx.user.role._id
78
79
  ? roles.BUILTIN_ROLE_IDS.PUBLIC
79
80
  : ctx.user.role._id
80
81
  }
81
82
 
82
83
  function checkAppUrl(
83
- ctx: UserCtx,
84
+ ctx: BBContext,
84
85
  apps: App[],
85
86
  url: string,
86
87
  currentAppId?: string
@@ -94,7 +95,7 @@ function checkAppUrl(
94
95
  }
95
96
 
96
97
  function checkAppName(
97
- ctx: UserCtx,
98
+ ctx: BBContext,
98
99
  apps: App[],
99
100
  name: string,
100
101
  currentAppId?: string
@@ -159,7 +160,7 @@ async function addDefaultTables(db: Database) {
159
160
  await db.bulkDocs([...defaultDbDocs])
160
161
  }
161
162
 
162
- export async function fetch(ctx: UserCtx) {
163
+ export async function fetch(ctx: BBContext) {
163
164
  const dev = ctx.query && ctx.query.status === AppStatus.DEV
164
165
  const all = ctx.query && ctx.query.status === AppStatus.ALL
165
166
  const apps = (await dbCore.getAllApps({ dev, all })) as App[]
@@ -184,7 +185,7 @@ export async function fetch(ctx: UserCtx) {
184
185
  ctx.body = await checkAppMetadata(apps)
185
186
  }
186
187
 
187
- export async function fetchAppDefinition(ctx: UserCtx) {
188
+ export async function fetchAppDefinition(ctx: BBContext) {
188
189
  const layouts = await getLayouts()
189
190
  const userRoleId = getUserRoleId(ctx)
190
191
  const accessController = new roles.AccessController()
@@ -230,7 +231,7 @@ export async function fetchAppPackage(ctx: UserCtx) {
230
231
  }
231
232
  }
232
233
 
233
- async function performAppCreate(ctx: UserCtx) {
234
+ async function performAppCreate(ctx: BBContext) {
234
235
  const apps = (await dbCore.getAllApps({ dev: true })) as App[]
235
236
  const name = ctx.request.body.name,
236
237
  possibleUrl = ctx.request.body.url
@@ -359,7 +360,7 @@ async function creationEvents(request: any, app: App) {
359
360
  }
360
361
  }
361
362
 
362
- async function appPostCreate(ctx: UserCtx, app: App) {
363
+ async function appPostCreate(ctx: BBContext, app: App) {
363
364
  const tenantId = tenancy.getTenantId()
364
365
  await migrations.backPopulateMigrations({
365
366
  type: MigrationType.APP,
@@ -377,7 +378,7 @@ async function appPostCreate(ctx: UserCtx, app: App) {
377
378
  return quotas.addRows(rowCount)
378
379
  })
379
380
  } catch (err: any) {
380
- if (err.code && err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) {
381
+ if (err.code && err.code === errors.codes.USAGE_LIMIT_EXCEEDED) {
381
382
  // this import resulted in row usage exceeding the quota
382
383
  // delete the app
383
384
  // skip pre and post-steps as no rows have been added to quotas yet
@@ -390,7 +391,7 @@ async function appPostCreate(ctx: UserCtx, app: App) {
390
391
  }
391
392
  }
392
393
 
393
- export async function create(ctx: UserCtx) {
394
+ export async function create(ctx: BBContext) {
394
395
  const newApplication = await quotas.addApp(() => performAppCreate(ctx))
395
396
  await appPostCreate(ctx, newApplication)
396
397
  await cache.bustCache(cache.CacheKey.CHECKLIST)
@@ -400,7 +401,7 @@ export async function create(ctx: UserCtx) {
400
401
 
401
402
  // This endpoint currently operates as a PATCH rather than a PUT
402
403
  // Thus name and url fields are handled only if present
403
- export async function update(ctx: UserCtx) {
404
+ export async function update(ctx: BBContext) {
404
405
  const apps = (await dbCore.getAllApps({ dev: true })) as App[]
405
406
  // validation
406
407
  const name = ctx.request.body.name,
@@ -420,7 +421,7 @@ export async function update(ctx: UserCtx) {
420
421
  ctx.body = app
421
422
  }
422
423
 
423
- export async function updateClient(ctx: UserCtx) {
424
+ export async function updateClient(ctx: BBContext) {
424
425
  // Get current app version
425
426
  const db = context.getAppDB()
426
427
  const application = await db.get(DocumentType.APP_METADATA)
@@ -444,7 +445,7 @@ export async function updateClient(ctx: UserCtx) {
444
445
  ctx.body = app
445
446
  }
446
447
 
447
- export async function revertClient(ctx: UserCtx) {
448
+ export async function revertClient(ctx: BBContext) {
448
449
  // Check app can be reverted
449
450
  const db = context.getAppDB()
450
451
  const application = await db.get(DocumentType.APP_METADATA)
@@ -470,7 +471,7 @@ export async function revertClient(ctx: UserCtx) {
470
471
  ctx.body = app
471
472
  }
472
473
 
473
- async function unpublishApp(ctx: UserCtx) {
474
+ const unpublishApp = async (ctx: any) => {
474
475
  let appId = ctx.params.appId
475
476
  appId = dbCore.getProdAppID(appId)
476
477
 
@@ -486,7 +487,7 @@ async function unpublishApp(ctx: UserCtx) {
486
487
  return result
487
488
  }
488
489
 
489
- async function destroyApp(ctx: UserCtx) {
490
+ async function destroyApp(ctx: BBContext) {
490
491
  let appId = ctx.params.appId
491
492
  appId = dbCore.getProdAppID(appId)
492
493
  const devAppId = dbCore.getDevAppID(appId)
@@ -514,12 +515,12 @@ async function destroyApp(ctx: UserCtx) {
514
515
  return result
515
516
  }
516
517
 
517
- async function preDestroyApp(ctx: UserCtx) {
518
+ async function preDestroyApp(ctx: BBContext) {
518
519
  const { rows } = await getUniqueRows([ctx.params.appId])
519
520
  ctx.rowCount = rows.length
520
521
  }
521
522
 
522
- async function postDestroyApp(ctx: UserCtx) {
523
+ async function postDestroyApp(ctx: BBContext) {
523
524
  const rowCount = ctx.rowCount
524
525
  await groups.cleanupApp(ctx.params.appId)
525
526
  if (rowCount) {
@@ -527,7 +528,7 @@ async function postDestroyApp(ctx: UserCtx) {
527
528
  }
528
529
  }
529
530
 
530
- export async function destroy(ctx: UserCtx) {
531
+ export async function destroy(ctx: BBContext) {
531
532
  await preDestroyApp(ctx)
532
533
  const result = await destroyApp(ctx)
533
534
  await postDestroyApp(ctx)
@@ -535,7 +536,7 @@ export async function destroy(ctx: UserCtx) {
535
536
  ctx.body = result
536
537
  }
537
538
 
538
- export async function unpublish(ctx: UserCtx) {
539
+ export const unpublish = async (ctx: BBContext) => {
539
540
  const prodAppId = dbCore.getProdAppID(ctx.params.appId)
540
541
  const dbExists = await dbCore.dbExists(prodAppId)
541
542
 
@@ -550,7 +551,7 @@ export async function unpublish(ctx: UserCtx) {
550
551
  ctx.status = 204
551
552
  }
552
553
 
553
- export async function sync(ctx: UserCtx) {
554
+ export async function sync(ctx: BBContext) {
554
555
  const appId = ctx.params.appId
555
556
  try {
556
557
  ctx.body = await sdk.applications.syncApp(appId)
@@ -56,13 +56,6 @@ export async function patch(ctx: UserCtx) {
56
56
  const id = inputs._id
57
57
  // don't save the ID to db
58
58
  delete inputs._id
59
- const validateResult = await utils.validate({
60
- row: inputs,
61
- tableId,
62
- })
63
- if (!validateResult.valid) {
64
- throw { validation: validateResult.errors }
65
- }
66
59
  return handleRequest(Operation.UPDATE, tableId, {
67
60
  id: breakRowIdField(id),
68
61
  row: inputs,
@@ -73,13 +66,6 @@ export async function patch(ctx: UserCtx) {
73
66
  export async function save(ctx: UserCtx) {
74
67
  const inputs = ctx.request.body
75
68
  const tableId = ctx.params.tableId
76
- const validateResult = await utils.validate({
77
- row: inputs,
78
- tableId,
79
- })
80
- if (!validateResult.valid) {
81
- throw { validation: validateResult.errors }
82
- }
83
69
  return handleRequest(Operation.CREATE, tableId, {
84
70
  row: inputs,
85
71
  includeSqlRelationships: IncludeRelationship.EXCLUDE,