@budibase/server 2.5.5 → 2.5.6-alpha.10

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 (156) hide show
  1. package/builder/assets/index.5c1a6913.js +1776 -0
  2. package/builder/assets/index.c0265b74.css +6 -0
  3. package/builder/index.html +2 -2
  4. package/dist/api/controllers/automation.js +13 -7
  5. package/dist/api/controllers/ops.js +40 -0
  6. package/dist/api/controllers/plugin/index.js +6 -37
  7. package/dist/api/controllers/table/utils.js +2 -1
  8. package/dist/api/controllers/user.js +1 -83
  9. package/dist/api/routes/index.js +2 -0
  10. package/dist/api/routes/ops.js +52 -0
  11. package/dist/api/routes/user.js +0 -1
  12. package/dist/app.js +4 -13
  13. package/dist/automations/actions.js +32 -6
  14. package/dist/automations/index.js +3 -2
  15. package/dist/automations/steps/bash.js +6 -6
  16. package/dist/automations/steps/createRow.js +11 -11
  17. package/dist/automations/steps/delay.js +3 -3
  18. package/dist/automations/steps/deleteRow.js +8 -8
  19. package/dist/automations/steps/discord.js +8 -8
  20. package/dist/automations/steps/executeQuery.js +9 -9
  21. package/dist/automations/steps/executeScript.js +6 -6
  22. package/dist/automations/steps/filter.js +6 -6
  23. package/dist/automations/steps/integromat.js +10 -10
  24. package/dist/automations/steps/loop.js +9 -9
  25. package/dist/automations/steps/outgoingWebhook.js +10 -10
  26. package/dist/automations/steps/queryRows.js +14 -14
  27. package/dist/automations/steps/sendSmtpEmail.js +9 -9
  28. package/dist/automations/steps/serverLog.js +4 -4
  29. package/dist/automations/steps/slack.js +6 -6
  30. package/dist/automations/steps/updateRow.js +11 -11
  31. package/dist/automations/steps/zapier.js +9 -9
  32. package/dist/automations/triggerInfo/app.js +5 -5
  33. package/dist/automations/triggerInfo/cron.js +4 -4
  34. package/dist/automations/triggerInfo/rowDeleted.js +5 -5
  35. package/dist/automations/triggerInfo/rowSaved.js +7 -7
  36. package/dist/automations/triggerInfo/rowUpdated.js +7 -7
  37. package/dist/automations/triggerInfo/webhook.js +6 -6
  38. package/dist/environment.js +0 -1
  39. package/dist/events/docUpdates/index.js +17 -0
  40. package/dist/events/docUpdates/processors.js +18 -0
  41. package/dist/events/docUpdates/syncUsers.js +49 -0
  42. package/dist/events/index.js +3 -0
  43. package/dist/integrations/index.js +3 -3
  44. package/dist/integrations/microsoftSqlServer.js +5 -2
  45. package/dist/integrations/mysql.js +5 -3
  46. package/dist/integrations/postgres.js +7 -5
  47. package/dist/integrations/redis.js +7 -0
  48. package/dist/integrations/rest.js +4 -0
  49. package/dist/migrations/functions/usageQuotas/syncApps.js +1 -1
  50. package/dist/migrations/functions/usageQuotas/syncRows.js +1 -2
  51. package/dist/package.json +15 -15
  52. package/dist/sdk/app/applications/sync.js +117 -23
  53. package/dist/sdk/index.js +2 -0
  54. package/dist/sdk/plugins/index.js +27 -0
  55. package/dist/sdk/plugins/plugins.js +53 -0
  56. package/dist/sdk/users/utils.js +21 -4
  57. package/dist/startup.js +31 -28
  58. package/dist/threads/automation.js +16 -5
  59. package/dist/tsconfig.build.tsbuildinfo +1 -1
  60. package/dist/utilities/fileSystem/plugin.js +33 -23
  61. package/dist/utilities/global.js +17 -12
  62. package/dist/watch.js +2 -2
  63. package/dist/websockets/client.js +14 -0
  64. package/dist/websockets/grid.js +60 -0
  65. package/dist/websockets/index.js +17 -0
  66. package/dist/websockets/websocket.js +78 -0
  67. package/jest.config.ts +3 -3
  68. package/nodemon.json +7 -3
  69. package/package.json +16 -16
  70. package/scripts/dev/manage.js +2 -0
  71. package/scripts/integrations/mssql/data/entrypoint.sh +1 -0
  72. package/scripts/integrations/mssql/data/setup.sql +17 -17
  73. package/scripts/integrations/mysql/init.sql +1 -1
  74. package/scripts/integrations/postgres/init.sql +1 -0
  75. package/src/api/controllers/automation.ts +12 -6
  76. package/src/api/controllers/ops.ts +32 -0
  77. package/src/api/controllers/plugin/index.ts +8 -45
  78. package/src/api/controllers/row/internal.ts +9 -10
  79. package/src/api/controllers/row/utils.ts +2 -2
  80. package/src/api/controllers/table/utils.ts +2 -1
  81. package/src/api/controllers/user.ts +10 -96
  82. package/src/api/routes/index.ts +2 -0
  83. package/src/api/routes/ops.ts +30 -0
  84. package/src/api/routes/tests/automation.spec.js +7 -4
  85. package/src/api/routes/tests/user.spec.js +48 -37
  86. package/src/api/routes/user.ts +0 -5
  87. package/src/app.ts +4 -15
  88. package/src/automations/actions.ts +56 -24
  89. package/src/automations/index.ts +1 -1
  90. package/src/automations/steps/bash.ts +10 -7
  91. package/src/automations/steps/createRow.ts +15 -12
  92. package/src/automations/steps/delay.ts +6 -4
  93. package/src/automations/steps/deleteRow.ts +12 -9
  94. package/src/automations/steps/discord.ts +10 -8
  95. package/src/automations/steps/executeQuery.ts +13 -10
  96. package/src/automations/steps/executeScript.ts +10 -7
  97. package/src/automations/steps/filter.ts +8 -6
  98. package/src/automations/steps/integromat.ts +12 -10
  99. package/src/automations/steps/loop.ts +16 -10
  100. package/src/automations/steps/outgoingWebhook.ts +14 -11
  101. package/src/automations/steps/queryRows.ts +18 -15
  102. package/src/automations/steps/sendSmtpEmail.ts +11 -9
  103. package/src/automations/steps/serverLog.ts +6 -4
  104. package/src/automations/steps/slack.ts +8 -6
  105. package/src/automations/steps/updateRow.ts +15 -12
  106. package/src/automations/steps/zapier.ts +11 -9
  107. package/src/automations/tests/utilities/index.ts +2 -2
  108. package/src/automations/triggerInfo/app.ts +8 -5
  109. package/src/automations/triggerInfo/cron.ts +7 -4
  110. package/src/automations/triggerInfo/rowDeleted.ts +8 -5
  111. package/src/automations/triggerInfo/rowSaved.ts +10 -7
  112. package/src/automations/triggerInfo/rowUpdated.ts +10 -7
  113. package/src/automations/triggerInfo/webhook.ts +9 -6
  114. package/src/environment.ts +0 -1
  115. package/src/events/docUpdates/index.ts +1 -0
  116. package/src/events/docUpdates/processors.ts +14 -0
  117. package/src/events/docUpdates/syncUsers.ts +35 -0
  118. package/src/events/index.ts +1 -0
  119. package/src/integrations/index.ts +3 -3
  120. package/src/integrations/microsoftSqlServer.ts +5 -2
  121. package/src/integrations/mysql.ts +5 -3
  122. package/src/integrations/postgres.ts +7 -5
  123. package/src/integrations/redis.ts +8 -0
  124. package/src/integrations/rest.ts +3 -0
  125. package/src/migrations/functions/usageQuotas/syncApps.ts +1 -1
  126. package/src/migrations/functions/usageQuotas/syncRows.ts +2 -3
  127. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
  128. package/src/sdk/app/applications/sync.ts +129 -22
  129. package/src/sdk/app/applications/tests/sync.spec.ts +137 -0
  130. package/src/sdk/index.ts +2 -0
  131. package/src/sdk/plugins/index.ts +5 -0
  132. package/src/sdk/plugins/plugins.ts +41 -0
  133. package/src/sdk/users/tests/utils.spec.ts +1 -32
  134. package/src/sdk/users/utils.ts +23 -5
  135. package/src/startup.ts +36 -34
  136. package/src/tests/jestEnv.ts +0 -1
  137. package/src/tests/jestSetup.ts +0 -1
  138. package/src/tests/utilities/TestConfiguration.ts +28 -0
  139. package/src/tests/utilities/structures.ts +25 -17
  140. package/src/threads/automation.ts +18 -6
  141. package/src/utilities/fileSystem/plugin.ts +13 -4
  142. package/src/utilities/global.ts +21 -16
  143. package/src/watch.ts +2 -2
  144. package/src/websockets/client.ts +11 -0
  145. package/src/websockets/grid.ts +55 -0
  146. package/src/websockets/index.ts +14 -0
  147. package/src/websockets/websocket.ts +83 -0
  148. package/tsconfig.json +1 -7
  149. package/builder/assets/index.7f9a008b.css +0 -6
  150. package/builder/assets/index.f493a2b3.js +0 -1817
  151. package/dist/elasticApm.js +0 -14
  152. package/dist/websocket.js +0 -22
  153. package/scripts/likeCypress.ts +0 -35
  154. package/src/elasticApm.ts +0 -10
  155. package/src/tests/logging.ts +0 -34
  156. package/src/websocket.ts +0 -26
@@ -19,7 +19,7 @@ const types_1 = require("@budibase/types");
19
19
  exports.definition = {
20
20
  name: "Zapier Webhook",
21
21
  stepId: types_1.AutomationActionStepId.zapier,
22
- type: "ACTION",
22
+ type: types_1.AutomationStepType.ACTION,
23
23
  internal: false,
24
24
  description: "Trigger a Zapier Zap via webhooks",
25
25
  tagline: "Trigger a Zapier Zap",
@@ -29,27 +29,27 @@ exports.definition = {
29
29
  inputs: {
30
30
  properties: {
31
31
  url: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  title: "Webhook URL",
34
34
  },
35
35
  value1: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  title: "Payload Value 1",
38
38
  },
39
39
  value2: {
40
- type: "string",
40
+ type: types_1.AutomationIOType.STRING,
41
41
  title: "Payload Value 2",
42
42
  },
43
43
  value3: {
44
- type: "string",
44
+ type: types_1.AutomationIOType.STRING,
45
45
  title: "Payload Value 3",
46
46
  },
47
47
  value4: {
48
- type: "string",
48
+ type: types_1.AutomationIOType.STRING,
49
49
  title: "Payload Value 4",
50
50
  },
51
51
  value5: {
52
- type: "string",
52
+ type: types_1.AutomationIOType.STRING,
53
53
  title: "Payload Value 5",
54
54
  },
55
55
  },
@@ -58,11 +58,11 @@ exports.definition = {
58
58
  outputs: {
59
59
  properties: {
60
60
  httpStatus: {
61
- type: "number",
61
+ type: types_1.AutomationIOType.NUMBER,
62
62
  description: "The HTTP status code of the request",
63
63
  },
64
64
  response: {
65
- type: "string",
65
+ type: types_1.AutomationIOType.STRING,
66
66
  description: "The response from Zapier",
67
67
  },
68
68
  },
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  fields: {
17
- type: "object",
18
- customType: "triggerSchema",
17
+ type: types_1.AutomationIOType.OBJECT,
18
+ customType: types_1.AutomationCustomIOType.TRIGGER_SCHEMA,
19
19
  title: "Fields",
20
20
  },
21
21
  },
@@ -24,13 +24,13 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  fields: {
27
- type: "object",
27
+ type: types_1.AutomationIOType.OBJECT,
28
28
  description: "Fields submitted from the app frontend",
29
- customType: "triggerSchema",
29
+ customType: types_1.AutomationCustomIOType.TRIGGER_SCHEMA,
30
30
  },
31
31
  },
32
32
  required: ["fields"],
33
33
  },
34
34
  },
35
- type: "TRIGGER",
35
+ type: types_1.AutomationStepType.TRIGGER,
36
36
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  cron: {
17
- type: "string",
18
- customType: "cron",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.CRON,
19
19
  title: "Expression",
20
20
  },
21
21
  },
@@ -24,12 +24,12 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  timestamp: {
27
- type: "number",
27
+ type: types_1.AutomationIOType.NUMBER,
28
28
  description: "Timestamp the cron was executed",
29
29
  },
30
30
  },
31
31
  required: ["timestamp"],
32
32
  },
33
33
  },
34
- type: "TRIGGER",
34
+ type: types_1.AutomationStepType.TRIGGER,
35
35
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  tableId: {
17
- type: "string",
18
- customType: "table",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.TABLE,
19
19
  title: "Table",
20
20
  },
21
21
  },
@@ -24,13 +24,13 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  row: {
27
- type: "object",
28
- customType: "row",
27
+ type: types_1.AutomationIOType.OBJECT,
28
+ customType: types_1.AutomationCustomIOType.ROW,
29
29
  description: "The row that was deleted",
30
30
  },
31
31
  },
32
32
  required: ["row"],
33
33
  },
34
34
  },
35
- type: "TRIGGER",
35
+ type: types_1.AutomationStepType.TRIGGER,
36
36
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  tableId: {
17
- type: "string",
18
- customType: "table",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.TABLE,
19
19
  title: "Table",
20
20
  },
21
21
  },
@@ -24,21 +24,21 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  row: {
27
- type: "object",
28
- customType: "row",
27
+ type: types_1.AutomationIOType.OBJECT,
28
+ customType: types_1.AutomationCustomIOType.ROW,
29
29
  description: "The new row that was created",
30
30
  },
31
31
  id: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  description: "Row ID - can be used for updating",
34
34
  },
35
35
  revision: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  description: "Revision of row",
38
38
  },
39
39
  },
40
40
  required: ["row", "id"],
41
41
  },
42
42
  },
43
- type: "TRIGGER",
43
+ type: types_1.AutomationStepType.TRIGGER,
44
44
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  tableId: {
17
- type: "string",
18
- customType: "table",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.TABLE,
19
19
  title: "Table",
20
20
  },
21
21
  },
@@ -24,21 +24,21 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  row: {
27
- type: "object",
28
- customType: "row",
27
+ type: types_1.AutomationIOType.OBJECT,
28
+ customType: types_1.AutomationCustomIOType.ROW,
29
29
  description: "The row that was updated",
30
30
  },
31
31
  id: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  description: "Row ID - can be used for updating",
34
34
  },
35
35
  revision: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  description: "Revision of row",
38
38
  },
39
39
  },
40
40
  required: ["row", "id"],
41
41
  },
42
42
  },
43
- type: "TRIGGER",
43
+ type: types_1.AutomationStepType.TRIGGER,
44
44
  };
@@ -14,13 +14,13 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  schemaUrl: {
17
- type: "string",
18
- customType: "webhookUrl",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.WEBHOOK_URL,
19
19
  title: "Schema URL",
20
20
  },
21
21
  triggerUrl: {
22
- type: "string",
23
- customType: "webhookUrl",
22
+ type: types_1.AutomationIOType.STRING,
23
+ customType: types_1.AutomationCustomIOType.WEBHOOK_URL,
24
24
  title: "Trigger URL",
25
25
  },
26
26
  },
@@ -29,12 +29,12 @@ exports.definition = {
29
29
  outputs: {
30
30
  properties: {
31
31
  body: {
32
- type: "object",
32
+ type: types_1.AutomationIOType.OBJECT,
33
33
  description: "Body of the request which hit the webhook",
34
34
  },
35
35
  },
36
36
  required: ["body"],
37
37
  },
38
38
  },
39
- type: "TRIGGER",
39
+ type: types_1.AutomationStepType.TRIGGER,
40
40
  };
@@ -54,7 +54,6 @@ const environment = {
54
54
  // minor
55
55
  SALT_ROUNDS: process.env.SALT_ROUNDS,
56
56
  LOGGER: process.env.LOGGER,
57
- LOG_LEVEL: process.env.LOG_LEVEL,
58
57
  ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
59
58
  AUTOMATION_MAX_ITERATIONS: parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200,
60
59
  SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./processors"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = void 0;
7
+ const syncUsers_1 = __importDefault(require("./syncUsers"));
8
+ const backend_core_1 = require("@budibase/backend-core");
9
+ let started = false;
10
+ function init(updateCb) {
11
+ if (started) {
12
+ return;
13
+ }
14
+ const processors = [(0, syncUsers_1.default)(updateCb)];
15
+ backend_core_1.docUpdates.init(processors);
16
+ started = true;
17
+ }
18
+ exports.init = init;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const backend_core_1 = require("@budibase/backend-core");
13
+ const pro_1 = require("@budibase/pro");
14
+ const types_1 = require("@budibase/types");
15
+ const sync_1 = require("../../sdk/app/applications/sync");
16
+ function process(updateCb) {
17
+ const processor = (update) => __awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
+ try {
20
+ const docId = update.id;
21
+ const isGroup = docId.startsWith(backend_core_1.constants.DocumentType.GROUP);
22
+ let userIds;
23
+ if (isGroup) {
24
+ const group = yield pro_1.sdk.groups.get(docId);
25
+ userIds = ((_a = group.users) === null || _a === void 0 ? void 0 : _a.map(user => user._id)) || [];
26
+ }
27
+ else {
28
+ userIds = [docId];
29
+ }
30
+ if (userIds.length > 0) {
31
+ yield (0, sync_1.syncUsersToAllApps)(userIds);
32
+ }
33
+ if (updateCb) {
34
+ updateCb(docId);
35
+ }
36
+ }
37
+ catch (err) {
38
+ // if something not found - no changes to perform
39
+ if ((err === null || err === void 0 ? void 0 : err.status) === 404) {
40
+ return;
41
+ }
42
+ else {
43
+ backend_core_1.logging.logAlert("Failed to perform user/group app sync", err);
44
+ }
45
+ }
46
+ });
47
+ return { events: types_1.UserGroupSyncEvents, processor };
48
+ }
49
+ exports.default = process;
@@ -3,6 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = void 0;
6
7
  const BudibaseEmitter_1 = __importDefault(require("./BudibaseEmitter"));
7
8
  const emitter = new BudibaseEmitter_1.default();
9
+ var docUpdates_1 = require("./docUpdates");
10
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return docUpdates_1.init; } });
8
11
  exports.default = emitter;
@@ -29,11 +29,11 @@ const firebase_1 = __importDefault(require("./firebase"));
29
29
  const redis_1 = __importDefault(require("./redis"));
30
30
  const snowflake_1 = __importDefault(require("./snowflake"));
31
31
  const oracle_1 = __importDefault(require("./oracle"));
32
- const plugin_1 = require("../api/controllers/plugin");
33
32
  const types_1 = require("@budibase/types");
34
33
  const fileSystem_1 = require("../utilities/fileSystem");
35
34
  const environment_1 = __importDefault(require("../environment"));
36
35
  const lodash_1 = require("lodash");
36
+ const sdk_1 = __importDefault(require("../sdk"));
37
37
  const DEFINITIONS = {
38
38
  [types_1.SourceName.POSTGRES]: postgres_1.default.schema,
39
39
  [types_1.SourceName.DYNAMODB]: dynamodb_1.default.schema,
@@ -91,7 +91,7 @@ function getDefinitions() {
91
91
  return __awaiter(this, void 0, void 0, function* () {
92
92
  const pluginSchemas = {};
93
93
  if (environment_1.default.SELF_HOSTED) {
94
- const plugins = yield (0, plugin_1.getPlugins)(types_1.PluginType.DATASOURCE);
94
+ const plugins = yield sdk_1.default.plugins.fetch(types_1.PluginType.DATASOURCE);
95
95
  // extract the actual schema from each custom
96
96
  for (let plugin of plugins) {
97
97
  const sourceId = plugin.name;
@@ -111,7 +111,7 @@ function getIntegration(integration) {
111
111
  return INTEGRATIONS[integration];
112
112
  }
113
113
  if (environment_1.default.SELF_HOSTED) {
114
- const plugins = yield (0, plugin_1.getPlugins)(types_1.PluginType.DATASOURCE);
114
+ const plugins = yield sdk_1.default.plugins.fetch(types_1.PluginType.DATASOURCE);
115
115
  for (let plugin of plugins) {
116
116
  if (plugin.name === integration) {
117
117
  // need to use commonJS require due to its dynamic runtime nature
@@ -206,8 +206,11 @@ class SqlServerIntegration extends sql_1.default {
206
206
  if (typeof name !== "string") {
207
207
  continue;
208
208
  }
209
- schema[name] = Object.assign(Object.assign({ autocolumn: !!autoColumns.find(col => col === name), name: name, constraints: {
210
- presence: requiredColumns.find(col => col === name),
209
+ const hasDefault = def.COLUMN_DEFAULT;
210
+ const isAuto = !!autoColumns.find(col => col === name);
211
+ const required = !!requiredColumns.find(col => col === name);
212
+ schema[name] = Object.assign(Object.assign({ autocolumn: isAuto, name: name, constraints: {
213
+ presence: required && !isAuto && !hasDefault,
211
214
  } }, (0, utils_1.convertSqlType)(def.DATA_TYPE)), { externalType: def.DATA_TYPE });
212
215
  }
213
216
  tables[tableName] = {
@@ -186,12 +186,14 @@ class MySQLIntegration extends sql_1.default {
186
186
  if (column.Key === "PRI" && primaryKeys.indexOf(column.Key) === -1) {
187
187
  primaryKeys.push(columnName);
188
188
  }
189
- const constraints = {
190
- presence: column.Null !== "YES",
191
- };
189
+ const hasDefault = column.Default != null;
192
190
  const isAuto = typeof column.Extra === "string" &&
193
191
  (column.Extra === "auto_increment" ||
194
192
  column.Extra.toLowerCase().includes("generated"));
193
+ const required = column.Null !== "YES";
194
+ const constraints = {
195
+ presence: required && !isAuto && !hasDefault,
196
+ };
195
197
  schema[columnName] = Object.assign(Object.assign({ name: columnName, autocolumn: isAuto, constraints }, (0, utils_1.convertSqlType)(column.Type)), { externalType: column.Type });
196
198
  }
197
199
  if (!tables[tableName]) {
@@ -227,13 +227,15 @@ class PostgresIntegration extends sql_1.default {
227
227
  const identity = !!(column.identity_generation ||
228
228
  column.identity_start ||
229
229
  column.identity_increment);
230
- const constraints = {
231
- presence: column.is_nullable === "NO",
232
- };
233
- const hasDefault = typeof column.column_default === "string" &&
230
+ const hasDefault = column.column_default != null;
231
+ const hasNextVal = typeof column.column_default === "string" &&
234
232
  column.column_default.startsWith("nextval");
235
233
  const isGenerated = column.is_generated && column.is_generated !== "NEVER";
236
- const isAuto = hasDefault || identity || isGenerated;
234
+ const isAuto = hasNextVal || identity || isGenerated;
235
+ const required = column.is_nullable === "NO";
236
+ const constraints = {
237
+ presence: required && !hasDefault && !isGenerated,
238
+ };
237
239
  tables[tableName].schema[columnName] = Object.assign(Object.assign({ autocolumn: isAuto, name: columnName, constraints }, (0, utils_1.convertSqlType)(column.data_type)), { externalType: column.data_type });
238
240
  }
239
241
  const final = (0, utils_1.finaliseExternalTables)(tables, entities);
@@ -38,6 +38,12 @@ const SCHEMA = {
38
38
  type: "password",
39
39
  required: false,
40
40
  },
41
+ db: {
42
+ type: "number",
43
+ required: false,
44
+ display: "DB",
45
+ default: 0,
46
+ },
41
47
  },
42
48
  query: {
43
49
  create: {
@@ -90,6 +96,7 @@ class RedisIntegration {
90
96
  port: this.config.port,
91
97
  username: this.config.username,
92
98
  password: this.config.password,
99
+ db: this.config.db,
93
100
  });
94
101
  }
95
102
  disconnect() {
@@ -166,6 +166,10 @@ class RestIntegration {
166
166
  }
167
167
  raw = rawXml;
168
168
  }
169
+ else if (contentType.includes("application/pdf")) {
170
+ data = yield response.arrayBuffer(); // Save PDF as ArrayBuffer
171
+ raw = Buffer.from(data);
172
+ }
169
173
  else {
170
174
  data = yield response.text();
171
175
  raw = data;
@@ -19,7 +19,7 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
19
19
  const appCount = devApps ? devApps.length : 0;
20
20
  // sync app count
21
21
  const tenantId = backend_core_1.tenancy.getTenantId();
22
- console.log(`[Tenant: ${tenantId}] Syncing app count: ${appCount}`);
22
+ console.log(`Syncing app count: ${appCount}`);
23
23
  yield pro_1.quotas.setUsage(appCount, types_1.StaticQuotaName.APPS, types_1.QuotaUsageType.STATIC);
24
24
  });
25
25
  exports.run = run;
@@ -27,8 +27,7 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
27
27
  rowCount += rows.length;
28
28
  });
29
29
  // sync row count
30
- const tenantId = backend_core_1.tenancy.getTenantId();
31
- console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`);
30
+ console.log(`Syncing row count: ${rowCount}`);
32
31
  yield pro_1.quotas.setUsagePerApp(counts, types_1.StaticQuotaName.ROWS, types_1.QuotaUsageType.STATIC);
33
32
  });
34
33
  exports.run = run;
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.5.4",
4
+ "version": "2.5.6-alpha.6",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -26,6 +26,7 @@
26
26
  "dev:stack:down": "node scripts/dev/manage.js down",
27
27
  "dev:stack:nuke": "node scripts/dev/manage.js nuke",
28
28
  "dev:builder": "yarn run dev:stack:up && nodemon",
29
+ "dev:built": "yarn run dev:stack:up && yarn run run:docker",
29
30
  "specs": "ts-node specs/generate.ts && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
30
31
  "initialise": "node scripts/initialise.js",
31
32
  "env:multi:enable": "node scripts/multiTenancy.js enable",
@@ -44,12 +45,12 @@
44
45
  "license": "GPL-3.0",
45
46
  "dependencies": {
46
47
  "@apidevtools/swagger-parser": "10.0.3",
47
- "@budibase/backend-core": "^2.5.4",
48
- "@budibase/client": "^2.5.4",
49
- "@budibase/pro": "2.5.4",
50
- "@budibase/shared-core": "^2.5.4",
51
- "@budibase/string-templates": "^2.5.4",
52
- "@budibase/types": "^2.5.4",
48
+ "@budibase/backend-core": "2.5.6-alpha.6",
49
+ "@budibase/client": "2.5.6-alpha.6",
50
+ "@budibase/pro": "2.5.6-alpha.6",
51
+ "@budibase/shared-core": "2.5.6-alpha.6",
52
+ "@budibase/string-templates": "2.5.6-alpha.6",
53
+ "@budibase/types": "2.5.6-alpha.6",
53
54
  "@bull-board/api": "3.7.0",
54
55
  "@bull-board/koa": "3.9.4",
55
56
  "@elastic/elasticsearch": "7.10.0",
@@ -64,6 +65,7 @@
64
65
  "bull": "4.10.1",
65
66
  "chmodr": "1.2.0",
66
67
  "chokidar": "3.5.3",
68
+ "cookies": "0.8.0",
67
69
  "csvtojson": "2.0.10",
68
70
  "curlconverter": "3.21.0",
69
71
  "dd-trace": "3.13.2",
@@ -85,7 +87,6 @@
85
87
  "koa-body": "4.2.0",
86
88
  "koa-compress": "4.0.1",
87
89
  "koa-connect": "2.1.0",
88
- "koa-pino-logger": "3.0.0",
89
90
  "koa-send": "5.0.0",
90
91
  "koa-session": "5.12.0",
91
92
  "koa-static": "5.0.0",
@@ -99,7 +100,6 @@
99
100
  "node-fetch": "2.6.7",
100
101
  "open": "8.4.0",
101
102
  "pg": "8.5.1",
102
- "pino-pretty": "4.0.0",
103
103
  "posthog-node": "1.3.0",
104
104
  "pouchdb": "7.3.0",
105
105
  "pouchdb-adapter-memory": "7.2.2",
@@ -109,18 +109,17 @@
109
109
  "redis": "4",
110
110
  "server-destroy": "1.0.1",
111
111
  "snowflake-promise": "^4.5.0",
112
- "socket.io": "^4.5.1",
112
+ "socket.io": "4.6.1",
113
113
  "svelte": "3.49.0",
114
114
  "swagger-parser": "10.0.3",
115
115
  "tar": "6.1.11",
116
116
  "to-json-schema": "0.2.5",
117
117
  "uuid": "3.3.2",
118
118
  "validate.js": "0.13.1",
119
- "vm2": "^3.9.15",
119
+ "vm2": "3.9.16",
120
120
  "worker-farm": "1.7.0",
121
- "xml2js": "0.4.23",
122
- "yargs": "13.2.4",
123
- "zlib": "1.0.5"
121
+ "xml2js": "0.5.0",
122
+ "yargs": "13.2.4"
124
123
  },
125
124
  "devDependencies": {
126
125
  "@babel/core": "7.17.4",
@@ -149,7 +148,7 @@
149
148
  "@types/tar": "6.1.3",
150
149
  "@typescript-eslint/parser": "5.45.0",
151
150
  "apidoc": "0.50.4",
152
- "babel-jest": "27.5.1",
151
+ "babel-jest": "29.5.0",
153
152
  "copyfiles": "2.4.1",
154
153
  "docker-compose": "0.23.17",
155
154
  "eslint": "6.8.0",
@@ -157,6 +156,7 @@
157
156
  "is-wsl": "2.2.0",
158
157
  "jest": "29.5.0",
159
158
  "jest-openapi": "0.14.2",
159
+ "jest-runner": "29.5.0",
160
160
  "jest-serial-runner": "^1.2.1",
161
161
  "nodemon": "2.0.15",
162
162
  "openapi-types": "9.3.1",