@budibase/server 2.4.27-alpha.7 → 2.4.27-alpha.8

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 (36) hide show
  1. package/__mocks__/node-fetch.ts +6 -1
  2. package/builder/assets/{index.ae75974f.js → index.7f87e580.js} +212 -212
  3. package/builder/index.html +1 -1
  4. package/dist/api/controllers/application.js +27 -23
  5. package/dist/api/controllers/row/utils.js +4 -3
  6. package/dist/app.js +1 -0
  7. package/dist/integrations/redis.js +1 -1
  8. package/dist/package.json +13 -12
  9. package/dist/sdk/users/utils.js +2 -1
  10. package/dist/tsconfig.build.tsbuildinfo +1 -1
  11. package/dist/utilities/global.js +17 -7
  12. package/jest.config.ts +1 -0
  13. package/package.json +14 -13
  14. package/scripts/test.sh +3 -3
  15. package/src/api/controllers/application.ts +18 -19
  16. package/src/api/controllers/row/utils.ts +4 -3
  17. package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +48 -48
  18. package/src/api/routes/tests/__snapshots__/datasource.spec.ts.snap +22 -22
  19. package/src/api/routes/tests/__snapshots__/view.spec.js.snap +5 -5
  20. package/src/api/routes/tests/appSync.spec.ts +31 -0
  21. package/src/api/routes/tests/internalSearch.spec.js +8 -7
  22. package/src/app.ts +2 -1
  23. package/src/automations/automationUtils.ts +1 -1
  24. package/src/automations/tests/automation.spec.ts +99 -0
  25. package/src/integration-test/postgres.spec.ts +46 -52
  26. package/src/integrations/redis.ts +1 -1
  27. package/src/integrations/tests/googlesheets.spec.ts +13 -13
  28. package/src/integrations/tests/redis.spec.ts +9 -5
  29. package/src/middleware/currentapp.ts +2 -2
  30. package/src/sdk/users/utils.ts +4 -1
  31. package/src/tests/jestEnv.ts +1 -0
  32. package/src/tests/jestSetup.ts +5 -1
  33. package/src/tests/utilities/TestConfiguration.ts +13 -0
  34. package/src/tests/utilities/structures.ts +13 -1
  35. package/src/utilities/global.ts +21 -9
  36. package/src/automations/tests/automation.spec.js +0 -84
@@ -10,7 +10,7 @@
10
10
  href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
11
11
  rel="stylesheet"
12
12
  />
13
- <script type="module" crossorigin src="/builder/assets/index.ae75974f.js"></script>
13
+ <script type="module" crossorigin src="/builder/assets/index.7f87e580.js"></script>
14
14
  <link rel="stylesheet" href="/builder/assets/index.de2f79b4.css">
15
15
  </head>
16
16
  <body id="app">
@@ -415,17 +415,19 @@ function revertClient(ctx) {
415
415
  });
416
416
  }
417
417
  exports.revertClient = revertClient;
418
- const unpublishApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
419
- let appId = ctx.params.appId;
420
- appId = backend_core_1.db.getProdAppID(appId);
421
- const db = backend_core_1.context.getProdAppDB();
422
- const result = yield db.destroy();
423
- yield backend_core_1.events.app.unpublished({ appId });
424
- // automations only in production
425
- yield (0, utils_2.cleanupAutomations)(appId);
426
- yield backend_core_1.cache.app.invalidateAppMetadata(appId);
427
- return result;
428
- });
418
+ function unpublishApp(ctx) {
419
+ return __awaiter(this, void 0, void 0, function* () {
420
+ let appId = ctx.params.appId;
421
+ appId = backend_core_1.db.getProdAppID(appId);
422
+ const db = backend_core_1.context.getProdAppDB();
423
+ const result = yield db.destroy();
424
+ yield backend_core_1.events.app.unpublished({ appId });
425
+ // automations only in production
426
+ yield (0, utils_2.cleanupAutomations)(appId);
427
+ yield backend_core_1.cache.app.invalidateAppMetadata(appId);
428
+ return result;
429
+ });
430
+ }
429
431
  function destroyApp(ctx) {
430
432
  return __awaiter(this, void 0, void 0, function* () {
431
433
  let appId = ctx.params.appId;
@@ -476,18 +478,20 @@ function destroy(ctx) {
476
478
  });
477
479
  }
478
480
  exports.destroy = destroy;
479
- const unpublish = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
480
- const prodAppId = backend_core_1.db.getProdAppID(ctx.params.appId);
481
- const dbExists = yield backend_core_1.db.dbExists(prodAppId);
482
- // check app has been published
483
- if (!dbExists) {
484
- return ctx.throw(400, "App has not been published.");
485
- }
486
- yield preDestroyApp(ctx);
487
- yield unpublishApp(ctx);
488
- yield postDestroyApp(ctx);
489
- ctx.status = 204;
490
- });
481
+ function unpublish(ctx) {
482
+ return __awaiter(this, void 0, void 0, function* () {
483
+ const prodAppId = backend_core_1.db.getProdAppID(ctx.params.appId);
484
+ const dbExists = yield backend_core_1.db.dbExists(prodAppId);
485
+ // check app has been published
486
+ if (!dbExists) {
487
+ return ctx.throw(400, "App has not been published.");
488
+ }
489
+ yield preDestroyApp(ctx);
490
+ yield unpublishApp(ctx);
491
+ yield postDestroyApp(ctx);
492
+ ctx.status = 204;
493
+ });
494
+ }
491
495
  exports.unpublish = unpublish;
492
496
  function sync(ctx) {
493
497
  return __awaiter(this, void 0, void 0, function* () {
@@ -95,10 +95,11 @@ function validate({ tableId, row, table, }) {
95
95
  }
96
96
  const errors = {};
97
97
  for (let fieldName of Object.keys(fetchedTable.schema)) {
98
- const constraints = cloneDeep(fetchedTable.schema[fieldName].constraints);
99
- const type = fetchedTable.schema[fieldName].type;
98
+ const column = fetchedTable.schema[fieldName];
99
+ const constraints = cloneDeep(column.constraints);
100
+ const type = column.type;
100
101
  // formulas shouldn't validated, data will be deleted anyway
101
- if (type === constants_1.FieldTypes.FORMULA) {
102
+ if (type === constants_1.FieldTypes.FORMULA || column.autocolumn) {
102
103
  continue;
103
104
  }
104
105
  // special case for options, need to always allow unselected (null)
package/dist/app.js CHANGED
@@ -105,6 +105,7 @@ server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
105
105
  }
106
106
  shuttingDown = true;
107
107
  console.log("Server Closed");
108
+ backend_core_1.timers.cleanup();
108
109
  yield automations.shutdown();
109
110
  yield redis.shutdown();
110
111
  backend_core_1.events.shutdown();
@@ -94,7 +94,7 @@ class RedisIntegration {
94
94
  }
95
95
  disconnect() {
96
96
  return __awaiter(this, void 0, void 0, function* () {
97
- return this.client.disconnect();
97
+ return this.client.quit();
98
98
  });
99
99
  }
100
100
  redisContext(query) {
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.27-alpha.6",
4
+ "version": "2.4.27-alpha.7",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -14,7 +14,8 @@
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": "bash scripts/test.sh",
17
+ "test": "NODE_OPTIONS=\"--max-old-space-size=4096\" bash scripts/test.sh",
18
+ "test:memory": "jest --maxWorkers=2 --logHeapUsage --forceExit",
18
19
  "test:watch": "jest --watch",
19
20
  "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client",
20
21
  "build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
@@ -43,12 +44,12 @@
43
44
  "license": "GPL-3.0",
44
45
  "dependencies": {
45
46
  "@apidevtools/swagger-parser": "10.0.3",
46
- "@budibase/backend-core": "2.4.27-alpha.6",
47
- "@budibase/client": "2.4.27-alpha.6",
48
- "@budibase/pro": "2.4.27-alpha.6",
49
- "@budibase/shared-core": "2.4.27-alpha.6",
50
- "@budibase/string-templates": "2.4.27-alpha.6",
51
- "@budibase/types": "2.4.27-alpha.6",
47
+ "@budibase/backend-core": "2.4.27-alpha.7",
48
+ "@budibase/client": "2.4.27-alpha.7",
49
+ "@budibase/pro": "2.4.27-alpha.7",
50
+ "@budibase/shared-core": "2.4.27-alpha.7",
51
+ "@budibase/string-templates": "2.4.27-alpha.7",
52
+ "@budibase/types": "2.4.27-alpha.7",
52
53
  "@bull-board/api": "3.7.0",
53
54
  "@bull-board/koa": "3.9.4",
54
55
  "@elastic/elasticsearch": "7.10.0",
@@ -125,7 +126,7 @@
125
126
  "@babel/core": "7.17.4",
126
127
  "@babel/preset-env": "7.16.11",
127
128
  "@budibase/standard-components": "^0.9.139",
128
- "@jest/test-sequencer": "24.9.0",
129
+ "@jest/test-sequencer": "29.5.0",
129
130
  "@swc/core": "^1.3.25",
130
131
  "@swc/jest": "^0.2.24",
131
132
  "@trendyol/jest-testcontainers": "^2.1.1",
@@ -134,7 +135,7 @@
134
135
  "@types/global-agent": "2.1.1",
135
136
  "@types/google-spreadsheet": "3.1.5",
136
137
  "@types/ioredis": "4.28.10",
137
- "@types/jest": "27.5.1",
138
+ "@types/jest": "29.5.0",
138
139
  "@types/koa": "2.13.4",
139
140
  "@types/koa__router": "8.0.8",
140
141
  "@types/lodash": "4.14.180",
@@ -154,7 +155,7 @@
154
155
  "eslint": "6.8.0",
155
156
  "ioredis-mock": "7.2.0",
156
157
  "is-wsl": "2.2.0",
157
- "jest": "28.1.1",
158
+ "jest": "29.5.0",
158
159
  "jest-openapi": "0.14.2",
159
160
  "jest-serial-runner": "^1.2.1",
160
161
  "nodemon": "2.0.15",
@@ -166,7 +167,7 @@
166
167
  "supertest": "6.2.2",
167
168
  "swagger-jsdoc": "6.1.0",
168
169
  "timekeeper": "2.2.0",
169
- "ts-jest": "28.0.4",
170
+ "ts-jest": "29.0.5",
170
171
  "ts-node": "10.8.1",
171
172
  "tsconfig-paths": "4.0.0",
172
173
  "typescript": "4.7.3",
@@ -16,7 +16,8 @@ const utils_1 = require("../../db/utils");
16
16
  const lodash_1 = require("lodash");
17
17
  function combineMetadataAndUser(user, metadata) {
18
18
  // skip users with no access
19
- if (user.roleId === backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC) {
19
+ if (user.roleId == null ||
20
+ user.roleId === backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC) {
20
21
  return null;
21
22
  }
22
23
  delete user._rev;