@budibase/server 2.5.6-alpha.9 → 2.5.7

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.7f9a008b.css +6 -0
  2. package/builder/assets/index.f02eef32.js +1817 -0
  3. package/builder/index.html +2 -2
  4. package/dist/api/controllers/automation.js +7 -13
  5. package/dist/api/controllers/plugin/index.js +37 -6
  6. package/dist/api/controllers/table/utils.js +1 -2
  7. package/dist/api/controllers/user.js +83 -1
  8. package/dist/api/routes/index.js +0 -2
  9. package/dist/api/routes/user.js +1 -0
  10. package/dist/app.js +13 -4
  11. package/dist/automations/actions.js +6 -32
  12. package/dist/automations/index.js +2 -3
  13. package/dist/automations/steps/bash.js +6 -6
  14. package/dist/automations/steps/createRow.js +11 -11
  15. package/dist/automations/steps/delay.js +3 -3
  16. package/dist/automations/steps/deleteRow.js +8 -8
  17. package/dist/automations/steps/discord.js +8 -8
  18. package/dist/automations/steps/executeQuery.js +9 -9
  19. package/dist/automations/steps/executeScript.js +6 -6
  20. package/dist/automations/steps/filter.js +6 -6
  21. package/dist/automations/steps/integromat.js +10 -10
  22. package/dist/automations/steps/loop.js +9 -9
  23. package/dist/automations/steps/outgoingWebhook.js +10 -10
  24. package/dist/automations/steps/queryRows.js +14 -14
  25. package/dist/automations/steps/sendSmtpEmail.js +9 -9
  26. package/dist/automations/steps/serverLog.js +4 -4
  27. package/dist/automations/steps/slack.js +6 -6
  28. package/dist/automations/steps/updateRow.js +11 -11
  29. package/dist/automations/steps/zapier.js +9 -9
  30. package/dist/automations/triggerInfo/app.js +5 -5
  31. package/dist/automations/triggerInfo/cron.js +4 -4
  32. package/dist/automations/triggerInfo/rowDeleted.js +5 -5
  33. package/dist/automations/triggerInfo/rowSaved.js +7 -7
  34. package/dist/automations/triggerInfo/rowUpdated.js +7 -7
  35. package/dist/automations/triggerInfo/webhook.js +6 -6
  36. package/dist/elasticApm.js +14 -0
  37. package/dist/environment.js +1 -0
  38. package/dist/events/index.js +0 -3
  39. package/dist/integrations/index.js +3 -3
  40. package/dist/integrations/microsoftSqlServer.js +2 -5
  41. package/dist/integrations/mysql.js +3 -5
  42. package/dist/integrations/postgres.js +5 -7
  43. package/dist/integrations/redis.js +0 -7
  44. package/dist/integrations/rest.js +0 -4
  45. package/dist/migrations/functions/usageQuotas/syncApps.js +1 -1
  46. package/dist/migrations/functions/usageQuotas/syncRows.js +2 -1
  47. package/dist/package.json +15 -15
  48. package/dist/sdk/app/applications/sync.js +23 -117
  49. package/dist/sdk/index.js +0 -2
  50. package/dist/sdk/users/utils.js +4 -21
  51. package/dist/startup.js +28 -31
  52. package/dist/threads/automation.js +5 -16
  53. package/dist/tsconfig.build.tsbuildinfo +1 -1
  54. package/dist/utilities/fileSystem/plugin.js +23 -33
  55. package/dist/utilities/global.js +12 -17
  56. package/dist/watch.js +2 -2
  57. package/dist/websocket.js +22 -0
  58. package/jest.config.ts +3 -3
  59. package/nodemon.json +3 -7
  60. package/package.json +16 -16
  61. package/scripts/dev/manage.js +0 -2
  62. package/scripts/integrations/mssql/data/entrypoint.sh +0 -1
  63. package/scripts/integrations/mssql/data/setup.sql +17 -17
  64. package/scripts/integrations/mysql/init.sql +1 -1
  65. package/scripts/integrations/postgres/init.sql +0 -1
  66. package/scripts/likeCypress.ts +35 -0
  67. package/src/api/controllers/automation.ts +6 -12
  68. package/src/api/controllers/plugin/index.ts +45 -8
  69. package/src/api/controllers/row/internal.ts +10 -9
  70. package/src/api/controllers/row/utils.ts +2 -2
  71. package/src/api/controllers/table/utils.ts +1 -2
  72. package/src/api/controllers/user.ts +96 -10
  73. package/src/api/routes/index.ts +0 -2
  74. package/src/api/routes/tests/automation.spec.js +4 -7
  75. package/src/api/routes/tests/user.spec.js +37 -48
  76. package/src/api/routes/user.ts +5 -0
  77. package/src/app.ts +15 -4
  78. package/src/automations/actions.ts +24 -56
  79. package/src/automations/index.ts +1 -1
  80. package/src/automations/steps/bash.ts +7 -10
  81. package/src/automations/steps/createRow.ts +12 -15
  82. package/src/automations/steps/delay.ts +4 -6
  83. package/src/automations/steps/deleteRow.ts +9 -12
  84. package/src/automations/steps/discord.ts +8 -10
  85. package/src/automations/steps/executeQuery.ts +10 -13
  86. package/src/automations/steps/executeScript.ts +7 -10
  87. package/src/automations/steps/filter.ts +6 -8
  88. package/src/automations/steps/integromat.ts +10 -12
  89. package/src/automations/steps/loop.ts +10 -16
  90. package/src/automations/steps/outgoingWebhook.ts +11 -14
  91. package/src/automations/steps/queryRows.ts +15 -18
  92. package/src/automations/steps/sendSmtpEmail.ts +9 -11
  93. package/src/automations/steps/serverLog.ts +4 -6
  94. package/src/automations/steps/slack.ts +6 -8
  95. package/src/automations/steps/updateRow.ts +12 -15
  96. package/src/automations/steps/zapier.ts +9 -11
  97. package/src/automations/tests/utilities/index.ts +2 -2
  98. package/src/automations/triggerInfo/app.ts +5 -8
  99. package/src/automations/triggerInfo/cron.ts +4 -7
  100. package/src/automations/triggerInfo/rowDeleted.ts +5 -8
  101. package/src/automations/triggerInfo/rowSaved.ts +7 -10
  102. package/src/automations/triggerInfo/rowUpdated.ts +7 -10
  103. package/src/automations/triggerInfo/webhook.ts +6 -9
  104. package/src/elasticApm.ts +10 -0
  105. package/src/environment.ts +1 -0
  106. package/src/events/index.ts +0 -1
  107. package/src/integrations/index.ts +3 -3
  108. package/src/integrations/microsoftSqlServer.ts +2 -5
  109. package/src/integrations/mysql.ts +3 -5
  110. package/src/integrations/postgres.ts +5 -7
  111. package/src/integrations/redis.ts +0 -8
  112. package/src/integrations/rest.ts +0 -3
  113. package/src/migrations/functions/usageQuotas/syncApps.ts +1 -1
  114. package/src/migrations/functions/usageQuotas/syncRows.ts +3 -2
  115. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
  116. package/src/sdk/app/applications/sync.ts +22 -129
  117. package/src/sdk/index.ts +0 -2
  118. package/src/sdk/users/tests/utils.spec.ts +32 -1
  119. package/src/sdk/users/utils.ts +5 -23
  120. package/src/startup.ts +34 -36
  121. package/src/tests/jestEnv.ts +1 -0
  122. package/src/tests/jestSetup.ts +1 -0
  123. package/src/tests/logging.ts +34 -0
  124. package/src/tests/utilities/TestConfiguration.ts +0 -28
  125. package/src/tests/utilities/structures.ts +17 -25
  126. package/src/threads/automation.ts +6 -18
  127. package/src/utilities/fileSystem/plugin.ts +4 -13
  128. package/src/utilities/global.ts +16 -21
  129. package/src/watch.ts +2 -2
  130. package/src/websocket.ts +26 -0
  131. package/tsconfig.json +7 -1
  132. package/builder/assets/index.5c1a6913.js +0 -1776
  133. package/builder/assets/index.c0265b74.css +0 -6
  134. package/dist/api/controllers/ops.js +0 -40
  135. package/dist/api/routes/ops.js +0 -52
  136. package/dist/events/docUpdates/index.js +0 -17
  137. package/dist/events/docUpdates/processors.js +0 -18
  138. package/dist/events/docUpdates/syncUsers.js +0 -49
  139. package/dist/sdk/plugins/index.js +0 -27
  140. package/dist/sdk/plugins/plugins.js +0 -53
  141. package/dist/websockets/client.js +0 -14
  142. package/dist/websockets/grid.js +0 -60
  143. package/dist/websockets/index.js +0 -17
  144. package/dist/websockets/websocket.js +0 -78
  145. package/src/api/controllers/ops.ts +0 -32
  146. package/src/api/routes/ops.ts +0 -30
  147. package/src/events/docUpdates/index.ts +0 -1
  148. package/src/events/docUpdates/processors.ts +0 -14
  149. package/src/events/docUpdates/syncUsers.ts +0 -35
  150. package/src/sdk/app/applications/tests/sync.spec.ts +0 -137
  151. package/src/sdk/plugins/index.ts +0 -5
  152. package/src/sdk/plugins/plugins.ts +0 -41
  153. package/src/websockets/client.ts +0 -11
  154. package/src/websockets/grid.ts +0 -55
  155. package/src/websockets/index.ts +0 -14
  156. package/src/websockets/websocket.ts +0 -83
@@ -12,13 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getAutomationPlugin = exports.getDatasourcePlugin = exports.getPluginMetadata = void 0;
15
+ exports.getDatasourcePlugin = exports.getPluginMetadata = void 0;
16
16
  const budibaseDir_1 = require("../budibaseDir");
17
17
  const fs_1 = __importDefault(require("fs"));
18
18
  const path_1 = require("path");
19
19
  const backend_core_1 = require("@budibase/backend-core");
20
20
  const DATASOURCE_PATH = (0, path_1.join)((0, budibaseDir_1.budibaseTempDir)(), "datasource");
21
- const AUTOMATION_PATH = (0, path_1.join)((0, budibaseDir_1.budibaseTempDir)(), "automation");
22
21
  const getPluginMetadata = (path) => __awaiter(void 0, void 0, void 0, function* () {
23
22
  let metadata = {};
24
23
  try {
@@ -38,39 +37,30 @@ const getPluginMetadata = (path) => __awaiter(void 0, void 0, void 0, function*
38
37
  return { metadata, directory: path };
39
38
  });
40
39
  exports.getPluginMetadata = getPluginMetadata;
41
- function getPluginImpl(path, plugin) {
40
+ const getDatasourcePlugin = (plugin) => __awaiter(void 0, void 0, void 0, function* () {
42
41
  var _a;
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const hash = (_a = plugin.schema) === null || _a === void 0 ? void 0 : _a.hash;
45
- if (!fs_1.default.existsSync(path)) {
46
- fs_1.default.mkdirSync(path);
42
+ const hash = (_a = plugin.schema) === null || _a === void 0 ? void 0 : _a.hash;
43
+ if (!fs_1.default.existsSync(DATASOURCE_PATH)) {
44
+ fs_1.default.mkdirSync(DATASOURCE_PATH);
45
+ }
46
+ const filename = (0, path_1.join)(DATASOURCE_PATH, plugin.name);
47
+ const metadataName = `${filename}.bbmetadata`;
48
+ if (fs_1.default.existsSync(filename)) {
49
+ const currentHash = fs_1.default.readFileSync(metadataName, "utf8");
50
+ // if hash is the same return the file, otherwise remove it and re-download
51
+ if (currentHash === hash) {
52
+ return require(filename);
47
53
  }
48
- const filename = (0, path_1.join)(path, plugin.name);
49
- const metadataName = `${filename}.bbmetadata`;
50
- if (fs_1.default.existsSync(filename)) {
51
- const currentHash = fs_1.default.readFileSync(metadataName, "utf8");
52
- // if hash is the same return the file, otherwise remove it and re-download
53
- if (currentHash === hash) {
54
- return require(filename);
55
- }
56
- else {
57
- console.log(`Updating plugin: ${plugin.name}`);
58
- delete require.cache[require.resolve(filename)];
59
- fs_1.default.unlinkSync(filename);
60
- }
54
+ else {
55
+ console.log(`Updating plugin: ${plugin.name}`);
56
+ delete require.cache[require.resolve(filename)];
57
+ fs_1.default.unlinkSync(filename);
61
58
  }
62
- const pluginKey = backend_core_1.objectStore.getPluginJSKey(plugin);
63
- const pluginJs = yield backend_core_1.objectStore.retrieve(backend_core_1.objectStore.ObjectStoreBuckets.PLUGINS, pluginKey);
64
- fs_1.default.writeFileSync(filename, pluginJs);
65
- fs_1.default.writeFileSync(metadataName, hash);
66
- return require(filename);
67
- });
68
- }
69
- const getDatasourcePlugin = (plugin) => __awaiter(void 0, void 0, void 0, function* () {
70
- return getPluginImpl(DATASOURCE_PATH, plugin);
59
+ }
60
+ const pluginKey = backend_core_1.objectStore.getPluginJSKey(plugin);
61
+ const pluginJs = yield backend_core_1.objectStore.retrieve(backend_core_1.objectStore.ObjectStoreBuckets.PLUGINS, pluginKey);
62
+ fs_1.default.writeFileSync(filename, pluginJs);
63
+ fs_1.default.writeFileSync(metadataName, hash);
64
+ return require(filename);
71
65
  });
72
66
  exports.getDatasourcePlugin = getDatasourcePlugin;
73
- const getAutomationPlugin = (plugin) => __awaiter(void 0, void 0, void 0, function* () {
74
- return getPluginImpl(AUTOMATION_PATH, plugin);
75
- });
76
- exports.getAutomationPlugin = getAutomationPlugin;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getGlobalUsersFromMetadata = exports.getGlobalUsers = exports.getGlobalUser = exports.getRawGlobalUser = exports.getCachedSelf = exports.processUser = exports.updateAppRole = void 0;
15
+ exports.getGlobalUsersFromMetadata = exports.getGlobalUsers = exports.getGlobalUser = exports.getRawGlobalUser = exports.getCachedSelf = exports.updateAppRole = void 0;
16
16
  const utils_1 = require("../db/utils");
17
17
  const backend_core_1 = require("@budibase/backend-core");
18
18
  const environment_1 = __importDefault(require("../environment"));
@@ -20,7 +20,7 @@ const pro_1 = require("@budibase/pro");
20
20
  function updateAppRole(user, { appId } = {}) {
21
21
  var _a;
22
22
  appId = appId || backend_core_1.context.getAppId();
23
- if (!user || (!user.roles && !user.userGroups)) {
23
+ if (!user || !user.roles) {
24
24
  return user;
25
25
  }
26
26
  // if in an multi-tenancy environment make sure roles are never updated
@@ -31,7 +31,7 @@ function updateAppRole(user, { appId } = {}) {
31
31
  return user;
32
32
  }
33
33
  // always use the deployed app
34
- if (appId && user.roles) {
34
+ if (appId) {
35
35
  user.roleId = user.roles[backend_core_1.db.getProdAppID(appId)];
36
36
  }
37
37
  // if a role wasn't found then either set as admin (builder) or public (everyone else)
@@ -76,7 +76,6 @@ function processUser(user, opts = {}) {
76
76
  return user;
77
77
  });
78
78
  }
79
- exports.processUser = processUser;
80
79
  function getCachedSelf(ctx, appId) {
81
80
  var _a;
82
81
  return __awaiter(this, void 0, void 0, function* () {
@@ -102,13 +101,15 @@ function getGlobalUser(userId) {
102
101
  });
103
102
  }
104
103
  exports.getGlobalUser = getGlobalUser;
105
- function getGlobalUsers(userIds, opts) {
104
+ function getGlobalUsers(users) {
106
105
  return __awaiter(this, void 0, void 0, function* () {
107
106
  const appId = backend_core_1.context.getAppId();
108
107
  const db = backend_core_1.tenancy.getGlobalDB();
108
+ const allGroups = yield pro_1.groups.fetch();
109
109
  let globalUsers;
110
- if (userIds) {
111
- globalUsers = (yield db.allDocs((0, utils_1.getMultiIDParams)(userIds))).rows.map(row => row.doc);
110
+ if (users) {
111
+ const globalIds = users.map(user => (0, utils_1.getGlobalIDFromUserMetadataID)(user._id));
112
+ globalUsers = (yield db.allDocs((0, utils_1.getMultiIDParams)(globalIds))).rows.map(row => row.doc);
112
113
  }
113
114
  else {
114
115
  globalUsers = (yield db.allDocs(backend_core_1.db.getGlobalUserParams(null, {
@@ -125,21 +126,15 @@ function getGlobalUsers(userIds, opts) {
125
126
  if (!appId) {
126
127
  return globalUsers;
127
128
  }
128
- if (opts === null || opts === void 0 ? void 0 : opts.noProcessing) {
129
- return globalUsers;
130
- }
131
- else {
132
- // pass in the groups, meaning we don't actually need to retrieve them for
133
- // each user individually
134
- const allGroups = yield pro_1.groups.fetch();
135
- return Promise.all(globalUsers.map(user => processUser(user, { groups: allGroups })));
136
- }
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 })));
137
132
  });
138
133
  }
139
134
  exports.getGlobalUsers = getGlobalUsers;
140
135
  function getGlobalUsersFromMetadata(users) {
141
136
  return __awaiter(this, void 0, void 0, function* () {
142
- const globalUsers = yield getGlobalUsers(users.map(user => user._id));
137
+ const globalUsers = yield getGlobalUsers(users);
143
138
  return users.map(user => {
144
139
  const globalUser = globalUsers.find(globalUser => { var _a; return globalUser && ((_a = user._id) === null || _a === void 0 ? void 0 : _a.includes(globalUser._id)); });
145
140
  return Object.assign(Object.assign({}, globalUser), user);
package/dist/watch.js CHANGED
@@ -18,7 +18,7 @@ const environment_1 = __importDefault(require("./environment"));
18
18
  const chokidar_1 = __importDefault(require("chokidar"));
19
19
  const fs_1 = __importDefault(require("fs"));
20
20
  const backend_core_1 = require("@budibase/backend-core");
21
- const plugins_1 = __importDefault(require("./sdk/plugins"));
21
+ const plugin_1 = require("./api/controllers/plugin");
22
22
  function watch() {
23
23
  const watchPath = path_1.default.join(environment_1.default.PLUGINS_DIR, "./**/*.tar.gz");
24
24
  chokidar_1.default
@@ -41,7 +41,7 @@ function watch() {
41
41
  const split = path.split("/");
42
42
  const name = split[split.length - 1];
43
43
  console.log("Importing plugin:", path);
44
- yield plugins_1.default.processUploaded({ name, path });
44
+ yield (0, plugin_1.processUploadedPlugin)({ name, path });
45
45
  }
46
46
  catch (err) {
47
47
  const message = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientAppSocket = exports.initialise = void 0;
4
+ const socket_io_1 = require("socket.io");
5
+ class Websocket {
6
+ constructor(server, path) {
7
+ this.socketServer = new socket_io_1.Server(server, {
8
+ path,
9
+ });
10
+ }
11
+ // Emit an event to all sockets
12
+ emit(event, payload) {
13
+ this.socketServer.sockets.emit(event, payload);
14
+ }
15
+ }
16
+ // Likely to be more socket instances in future
17
+ let ClientAppSocket;
18
+ exports.ClientAppSocket = ClientAppSocket;
19
+ const initialise = (server) => {
20
+ exports.ClientAppSocket = ClientAppSocket = new Websocket(server, "/socket/client");
21
+ };
22
+ exports.initialise = initialise;
package/jest.config.ts CHANGED
@@ -20,9 +20,9 @@ const baseConfig: Config.InitialProjectOptions = {
20
20
  }
21
21
 
22
22
  // add pro sources if they exist
23
- if (fs.existsSync("../pro/packages")) {
24
- baseConfig.moduleNameMapper!["@budibase/pro"] =
25
- "<rootDir>/../pro/packages/pro/src"
23
+ if (fs.existsSync("../../../budibase-pro")) {
24
+ baseConfig.moduleNameMapper["@budibase/pro"] =
25
+ "<rootDir>/../../../budibase-pro/packages/pro/src"
26
26
  }
27
27
 
28
28
  const config: Config.InitialOptions = {
package/nodemon.json CHANGED
@@ -1,10 +1,6 @@
1
1
  {
2
- "watch": ["src", "../backend-core", "../pro/packages/pro"],
2
+ "watch": ["src", "../backend-core", "../../../budibase-pro/packages/pro"],
3
3
  "ext": "js,ts,json",
4
- "ignore": [
5
- "src/**/*.spec.ts",
6
- "src/**/*.spec.js",
7
- "../backend-core/dist/**/*"
8
- ],
4
+ "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../backend-core/dist/**/*"],
9
5
  "exec": "ts-node src/index.ts"
10
- }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.5.6-alpha.9",
4
+ "version": "2.5.7",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -26,7 +26,6 @@
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",
30
29
  "specs": "ts-node specs/generate.ts && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
31
30
  "initialise": "node scripts/initialise.js",
32
31
  "env:multi:enable": "node scripts/multiTenancy.js enable",
@@ -45,12 +44,12 @@
45
44
  "license": "GPL-3.0",
46
45
  "dependencies": {
47
46
  "@apidevtools/swagger-parser": "10.0.3",
48
- "@budibase/backend-core": "2.5.6-alpha.9",
49
- "@budibase/client": "2.5.6-alpha.9",
50
- "@budibase/pro": "2.5.6-alpha.6",
51
- "@budibase/shared-core": "2.5.6-alpha.9",
52
- "@budibase/string-templates": "2.5.6-alpha.9",
53
- "@budibase/types": "2.5.6-alpha.9",
47
+ "@budibase/backend-core": "^2.5.7",
48
+ "@budibase/client": "^2.5.7",
49
+ "@budibase/pro": "2.5.6",
50
+ "@budibase/shared-core": "^2.5.7",
51
+ "@budibase/string-templates": "^2.5.7",
52
+ "@budibase/types": "^2.5.7",
54
53
  "@bull-board/api": "3.7.0",
55
54
  "@bull-board/koa": "3.9.4",
56
55
  "@elastic/elasticsearch": "7.10.0",
@@ -65,7 +64,6 @@
65
64
  "bull": "4.10.1",
66
65
  "chmodr": "1.2.0",
67
66
  "chokidar": "3.5.3",
68
- "cookies": "0.8.0",
69
67
  "csvtojson": "2.0.10",
70
68
  "curlconverter": "3.21.0",
71
69
  "dd-trace": "3.13.2",
@@ -87,6 +85,7 @@
87
85
  "koa-body": "4.2.0",
88
86
  "koa-compress": "4.0.1",
89
87
  "koa-connect": "2.1.0",
88
+ "koa-pino-logger": "3.0.0",
90
89
  "koa-send": "5.0.0",
91
90
  "koa-session": "5.12.0",
92
91
  "koa-static": "5.0.0",
@@ -100,6 +99,7 @@
100
99
  "node-fetch": "2.6.7",
101
100
  "open": "8.4.0",
102
101
  "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,17 +109,18 @@
109
109
  "redis": "4",
110
110
  "server-destroy": "1.0.1",
111
111
  "snowflake-promise": "^4.5.0",
112
- "socket.io": "4.6.1",
112
+ "socket.io": "^4.5.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.16",
119
+ "vm2": "^3.9.15",
120
120
  "worker-farm": "1.7.0",
121
- "xml2js": "0.5.0",
122
- "yargs": "13.2.4"
121
+ "xml2js": "0.4.23",
122
+ "yargs": "13.2.4",
123
+ "zlib": "1.0.5"
123
124
  },
124
125
  "devDependencies": {
125
126
  "@babel/core": "7.17.4",
@@ -148,7 +149,7 @@
148
149
  "@types/tar": "6.1.3",
149
150
  "@typescript-eslint/parser": "5.45.0",
150
151
  "apidoc": "0.50.4",
151
- "babel-jest": "29.5.0",
152
+ "babel-jest": "27.5.1",
152
153
  "copyfiles": "2.4.1",
153
154
  "docker-compose": "0.23.17",
154
155
  "eslint": "6.8.0",
@@ -156,7 +157,6 @@
156
157
  "is-wsl": "2.2.0",
157
158
  "jest": "29.5.0",
158
159
  "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",
@@ -176,5 +176,5 @@
176
176
  "optionalDependencies": {
177
177
  "oracledb": "5.3.0"
178
178
  },
179
- "gitHead": "560204d82570bd22b987e6e35f8e659e9c047425"
179
+ "gitHead": "6c37b6a6c69a1da43a5c0930419e743cc18b5b42"
180
180
  }
@@ -45,8 +45,6 @@ async function init() {
45
45
  BB_ADMIN_USER_PASSWORD: "",
46
46
  PLUGINS_DIR: "",
47
47
  TENANT_FEATURE_FLAGS: "*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR",
48
- HTTP_MIGRATIONS: "0",
49
- HTTP_LOGGING: "0",
50
48
  }
51
49
  let envFile = ""
52
50
  Object.keys(envFileJson).forEach(key => {
@@ -11,7 +11,6 @@ if [ "$1" = '/opt/mssql/bin/sqlservr' ]; then
11
11
 
12
12
  echo "RUNNING BUDIBASE SETUP"
13
13
 
14
- cat setup.sql
15
14
  #run the setup script to create the DB and the schema in the DB
16
15
  /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Passw0rd -i setup.sql
17
16
 
@@ -34,7 +34,7 @@ GO
34
34
  CREATE TABLE people
35
35
  (
36
36
  name varchar(30) NOT NULL,
37
- age int default 20 NOT NULL,
37
+ age varchar(20),
38
38
  CONSTRAINT pk_people PRIMARY KEY NONCLUSTERED (name, age)
39
39
  );
40
40
 
@@ -50,22 +50,22 @@ VALUES
50
50
  ('Processing', 1);
51
51
 
52
52
  INSERT INTO people (name, age)
53
- VALUES ('Bob', 30),
54
- ('Bert', 10),
55
- ('Jack', 12),
56
- ('Mike', 31),
57
- ('Dave', 44),
58
- ('Jim', 43),
59
- ('Kerry', 32),
60
- ('Julie', 12),
61
- ('Kim', 55),
62
- ('Andy', 33),
63
- ('John', 22),
64
- ('Ruth', 66),
65
- ('Robert', 88),
66
- ('Bobert', 99),
67
- ('Jan', 22),
68
- ('Megan', 11);
53
+ VALUES ('Bob', '30'),
54
+ ('Bert', '10'),
55
+ ('Jack', '12'),
56
+ ('Mike', '31'),
57
+ ('Dave', '44'),
58
+ ('Jim', '43'),
59
+ ('Kerry', '32'),
60
+ ('Julie', '12'),
61
+ ('Kim', '55'),
62
+ ('Andy', '33'),
63
+ ('John', '22'),
64
+ ('Ruth', '66'),
65
+ ('Robert', '88'),
66
+ ('Bobert', '99'),
67
+ ('Jan', '22'),
68
+ ('Megan', '11');
69
69
 
70
70
 
71
71
  IF OBJECT_ID ('Chains.sizes', 'U') IS NOT NULL
@@ -3,7 +3,7 @@ USE main;
3
3
  CREATE TABLE Persons (
4
4
  PersonID int NOT NULL AUTO_INCREMENT,
5
5
  CreatedAt datetime,
6
- Age float DEFAULT 20 NOT NULL,
6
+ Age float,
7
7
  LastName varchar(255),
8
8
  FirstName varchar(255),
9
9
  Address varchar(255),
@@ -8,7 +8,6 @@ CREATE TABLE Persons (
8
8
  FirstName varchar(255),
9
9
  Address varchar(255),
10
10
  City varchar(255) DEFAULT 'Belfast',
11
- Age INTEGER DEFAULT 20 NOT NULL,
12
11
  Type person_job
13
12
  );
14
13
  CREATE TABLE Tasks (
@@ -0,0 +1,35 @@
1
+ /******************************************************
2
+ * This script just makes it easy to re-create *
3
+ * a cypress like environment for testing the backend *
4
+ ******************************************************/
5
+ import path from "path"
6
+ const tmpdir = path.join(require("os").tmpdir(), ".budibase")
7
+
8
+ const SERVER_PORT = "4100"
9
+ const WORKER_PORT = "4200"
10
+
11
+ // @ts-ignore
12
+ process.env.NODE_ENV = "cypress"
13
+ process.env.ENABLE_ANALYTICS = "0"
14
+ process.env.JWT_SECRET = "budibase"
15
+ process.env.COUCH_URL = `leveldb://${tmpdir}/.data/`
16
+ process.env.SELF_HOSTED = "1"
17
+ process.env.WORKER_URL = `http://localhost:${WORKER_PORT}/`
18
+ process.env.MINIO_URL = `http://localhost:4004`
19
+ process.env.MINIO_ACCESS_KEY = "budibase"
20
+ process.env.MINIO_SECRET_KEY = "budibase"
21
+ process.env.COUCH_DB_USER = "budibase"
22
+ process.env.COUCH_DB_PASSWORD = "budibase"
23
+ process.env.INTERNAL_API_KEY = "budibase"
24
+ process.env.ALLOW_DEV_AUTOMATIONS = "1"
25
+
26
+ // don't make this a variable or top level require
27
+ // it will cause environment module to be loaded prematurely
28
+
29
+ // override the port with the worker port temporarily
30
+ process.env.PORT = WORKER_PORT
31
+ const worker = require("../../worker/src/index")
32
+
33
+ // override the port with the server port
34
+ process.env.PORT = SERVER_PORT
35
+ const server = require("../src/app")
@@ -16,15 +16,9 @@ import { setTestFlag, clearTestFlag } from "../../utilities/redis"
16
16
  import { context, cache, events } from "@budibase/backend-core"
17
17
  import { automations } from "@budibase/pro"
18
18
  import { Automation, BBContext } from "@budibase/types"
19
- import { getActionDefinitions as actionDefs } from "../../automations/actions"
20
19
 
21
- async function getActionDefinitions() {
22
- return removeDeprecated(await actionDefs())
23
- }
24
-
25
- function getTriggerDefinitions() {
26
- return removeDeprecated(triggers.TRIGGER_DEFINITIONS)
27
- }
20
+ const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
21
+ const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
28
22
 
29
23
  /*************************
30
24
  * *
@@ -234,17 +228,17 @@ export async function clearLogError(ctx: BBContext) {
234
228
  }
235
229
 
236
230
  export async function getActionList(ctx: BBContext) {
237
- ctx.body = await getActionDefinitions()
231
+ ctx.body = ACTION_DEFS
238
232
  }
239
233
 
240
234
  export async function getTriggerList(ctx: BBContext) {
241
- ctx.body = getTriggerDefinitions()
235
+ ctx.body = TRIGGER_DEFS
242
236
  }
243
237
 
244
238
  export async function getDefinitionList(ctx: BBContext) {
245
239
  ctx.body = {
246
- trigger: getTriggerDefinitions(),
247
- action: await getActionDefinitions(),
240
+ trigger: TRIGGER_DEFS,
241
+ action: ACTION_DEFS,
248
242
  }
249
243
  }
250
244
 
@@ -1,11 +1,31 @@
1
- import { npmUpload, urlUpload, githubUpload } from "./uploaders"
2
- import { plugins as pluginCore } from "@budibase/backend-core"
3
- import { PluginType, FileType, PluginSource } from "@budibase/types"
1
+ import { npmUpload, urlUpload, githubUpload, fileUpload } from "./uploaders"
2
+ import {
3
+ plugins as pluginCore,
4
+ db as dbCore,
5
+ tenancy,
6
+ objectStore,
7
+ } from "@budibase/backend-core"
8
+ import { PluginType, FileType, PluginSource, Plugin } from "@budibase/types"
4
9
  import env from "../../../environment"
5
- import { clientAppSocket } from "../../../websockets"
6
- import sdk from "../../../sdk"
10
+ import { ClientAppSocket } from "../../../websocket"
7
11
  import { sdk as pro } from "@budibase/pro"
8
12
 
13
+ export async function getPlugins(type?: PluginType) {
14
+ const db = tenancy.getGlobalDB()
15
+ const response = await db.allDocs(
16
+ dbCore.getPluginParams(null, {
17
+ include_docs: true,
18
+ })
19
+ )
20
+ let plugins = response.rows.map((row: any) => row.doc) as Plugin[]
21
+ plugins = objectStore.enrichPluginURLs(plugins)
22
+ if (type) {
23
+ return plugins.filter((plugin: Plugin) => plugin.schema?.type === type)
24
+ } else {
25
+ return plugins
26
+ }
27
+ }
28
+
9
29
  export async function upload(ctx: any) {
10
30
  const plugins: FileType[] =
11
31
  ctx.request.files.file.length > 1
@@ -15,7 +35,7 @@ export async function upload(ctx: any) {
15
35
  let docs = []
16
36
  // can do single or multiple plugins
17
37
  for (let plugin of plugins) {
18
- const doc = await sdk.plugins.processUploaded(plugin, PluginSource.FILE)
38
+ const doc = await processUploadedPlugin(plugin, PluginSource.FILE)
19
39
  docs.push(doc)
20
40
  }
21
41
  ctx.body = {
@@ -71,7 +91,7 @@ export async function create(ctx: any) {
71
91
 
72
92
  const doc = await pro.plugins.storePlugin(metadata, directory, source)
73
93
 
74
- clientAppSocket.emit("plugins-update", { name, hash: doc.hash })
94
+ ClientAppSocket.emit("plugins-update", { name, hash: doc.hash })
75
95
  ctx.body = {
76
96
  message: "Plugin uploaded successfully",
77
97
  plugins: [doc],
@@ -85,7 +105,7 @@ export async function create(ctx: any) {
85
105
  }
86
106
 
87
107
  export async function fetch(ctx: any) {
88
- ctx.body = await sdk.plugins.fetch()
108
+ ctx.body = await getPlugins()
89
109
  }
90
110
 
91
111
  export async function destroy(ctx: any) {
@@ -99,3 +119,20 @@ export async function destroy(ctx: any) {
99
119
  ctx.throw(400, err.message)
100
120
  }
101
121
  }
122
+
123
+ export async function processUploadedPlugin(
124
+ plugin: FileType,
125
+ source?: PluginSource
126
+ ) {
127
+ const { metadata, directory } = await fileUpload(plugin)
128
+ pluginCore.validate(metadata?.schema)
129
+
130
+ // Only allow components in cloud
131
+ if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {
132
+ throw new Error("Only component plugins are supported outside of self-host")
133
+ }
134
+
135
+ const doc = await pro.plugins.storePlugin(metadata, directory, source)
136
+ ClientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash })
137
+ return doc
138
+ }