@budibase/server 2.5.6-alpha.9 → 2.5.6
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.
- package/builder/assets/index.56bca6f6.js +1817 -0
- package/builder/assets/index.7f9a008b.css +6 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/automation.js +7 -13
- package/dist/api/controllers/plugin/index.js +37 -6
- package/dist/api/controllers/table/utils.js +1 -2
- package/dist/api/controllers/user.js +83 -1
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/user.js +1 -0
- package/dist/app.js +13 -4
- package/dist/automations/actions.js +6 -32
- package/dist/automations/index.js +2 -3
- package/dist/automations/steps/bash.js +6 -6
- package/dist/automations/steps/createRow.js +11 -11
- package/dist/automations/steps/delay.js +3 -3
- package/dist/automations/steps/deleteRow.js +8 -8
- package/dist/automations/steps/discord.js +8 -8
- package/dist/automations/steps/executeQuery.js +9 -9
- package/dist/automations/steps/executeScript.js +6 -6
- package/dist/automations/steps/filter.js +6 -6
- package/dist/automations/steps/integromat.js +10 -10
- package/dist/automations/steps/loop.js +9 -9
- package/dist/automations/steps/outgoingWebhook.js +10 -10
- package/dist/automations/steps/queryRows.js +14 -14
- package/dist/automations/steps/sendSmtpEmail.js +9 -9
- package/dist/automations/steps/serverLog.js +4 -4
- package/dist/automations/steps/slack.js +6 -6
- package/dist/automations/steps/updateRow.js +11 -11
- package/dist/automations/steps/zapier.js +9 -9
- package/dist/automations/triggerInfo/app.js +5 -5
- package/dist/automations/triggerInfo/cron.js +4 -4
- package/dist/automations/triggerInfo/rowDeleted.js +5 -5
- package/dist/automations/triggerInfo/rowSaved.js +7 -7
- package/dist/automations/triggerInfo/rowUpdated.js +7 -7
- package/dist/automations/triggerInfo/webhook.js +6 -6
- package/dist/elasticApm.js +14 -0
- package/dist/environment.js +1 -0
- package/dist/events/index.js +0 -3
- package/dist/integrations/index.js +3 -3
- package/dist/integrations/microsoftSqlServer.js +2 -5
- package/dist/integrations/mysql.js +3 -5
- package/dist/integrations/postgres.js +5 -7
- package/dist/integrations/redis.js +0 -7
- package/dist/integrations/rest.js +0 -4
- package/dist/migrations/functions/usageQuotas/syncApps.js +1 -1
- package/dist/migrations/functions/usageQuotas/syncRows.js +2 -1
- package/dist/package.json +15 -15
- package/dist/sdk/app/applications/sync.js +23 -117
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/users/utils.js +4 -21
- package/dist/startup.js +28 -31
- package/dist/threads/automation.js +5 -16
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/plugin.js +23 -33
- package/dist/utilities/global.js +12 -17
- package/dist/watch.js +2 -2
- package/dist/websocket.js +22 -0
- package/jest.config.ts +3 -3
- package/nodemon.json +3 -7
- package/package.json +16 -16
- package/scripts/dev/manage.js +0 -2
- package/scripts/integrations/mssql/data/entrypoint.sh +0 -1
- package/scripts/integrations/mssql/data/setup.sql +17 -17
- package/scripts/integrations/mysql/init.sql +1 -1
- package/scripts/integrations/postgres/init.sql +0 -1
- package/scripts/likeCypress.ts +35 -0
- package/src/api/controllers/automation.ts +6 -12
- package/src/api/controllers/plugin/index.ts +45 -8
- package/src/api/controllers/row/internal.ts +10 -9
- package/src/api/controllers/row/utils.ts +2 -2
- package/src/api/controllers/table/utils.ts +1 -2
- package/src/api/controllers/user.ts +96 -10
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/tests/automation.spec.js +4 -7
- package/src/api/routes/tests/user.spec.js +37 -48
- package/src/api/routes/user.ts +5 -0
- package/src/app.ts +15 -4
- package/src/automations/actions.ts +24 -56
- package/src/automations/index.ts +1 -1
- package/src/automations/steps/bash.ts +7 -10
- package/src/automations/steps/createRow.ts +12 -15
- package/src/automations/steps/delay.ts +4 -6
- package/src/automations/steps/deleteRow.ts +9 -12
- package/src/automations/steps/discord.ts +8 -10
- package/src/automations/steps/executeQuery.ts +10 -13
- package/src/automations/steps/executeScript.ts +7 -10
- package/src/automations/steps/filter.ts +6 -8
- package/src/automations/steps/integromat.ts +10 -12
- package/src/automations/steps/loop.ts +10 -16
- package/src/automations/steps/outgoingWebhook.ts +11 -14
- package/src/automations/steps/queryRows.ts +15 -18
- package/src/automations/steps/sendSmtpEmail.ts +9 -11
- package/src/automations/steps/serverLog.ts +4 -6
- package/src/automations/steps/slack.ts +6 -8
- package/src/automations/steps/updateRow.ts +12 -15
- package/src/automations/steps/zapier.ts +9 -11
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/triggerInfo/app.ts +5 -8
- package/src/automations/triggerInfo/cron.ts +4 -7
- package/src/automations/triggerInfo/rowDeleted.ts +5 -8
- package/src/automations/triggerInfo/rowSaved.ts +7 -10
- package/src/automations/triggerInfo/rowUpdated.ts +7 -10
- package/src/automations/triggerInfo/webhook.ts +6 -9
- package/src/elasticApm.ts +10 -0
- package/src/environment.ts +1 -0
- package/src/events/index.ts +0 -1
- package/src/integrations/index.ts +3 -3
- package/src/integrations/microsoftSqlServer.ts +2 -5
- package/src/integrations/mysql.ts +3 -5
- package/src/integrations/postgres.ts +5 -7
- package/src/integrations/redis.ts +0 -8
- package/src/integrations/rest.ts +0 -3
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -1
- package/src/migrations/functions/usageQuotas/syncRows.ts +3 -2
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
- package/src/sdk/app/applications/sync.ts +22 -129
- package/src/sdk/index.ts +0 -2
- package/src/sdk/users/tests/utils.spec.ts +32 -1
- package/src/sdk/users/utils.ts +5 -23
- package/src/startup.ts +34 -36
- package/src/tests/jestEnv.ts +1 -0
- package/src/tests/jestSetup.ts +1 -0
- package/src/tests/logging.ts +34 -0
- package/src/tests/utilities/TestConfiguration.ts +0 -28
- package/src/tests/utilities/structures.ts +17 -25
- package/src/threads/automation.ts +6 -18
- package/src/utilities/fileSystem/plugin.ts +4 -13
- package/src/utilities/global.ts +16 -21
- package/src/watch.ts +2 -2
- package/src/websocket.ts +26 -0
- package/tsconfig.json +7 -1
- package/builder/assets/index.5c1a6913.js +0 -1776
- package/builder/assets/index.c0265b74.css +0 -6
- package/dist/api/controllers/ops.js +0 -40
- package/dist/api/routes/ops.js +0 -52
- package/dist/events/docUpdates/index.js +0 -17
- package/dist/events/docUpdates/processors.js +0 -18
- package/dist/events/docUpdates/syncUsers.js +0 -49
- package/dist/sdk/plugins/index.js +0 -27
- package/dist/sdk/plugins/plugins.js +0 -53
- package/dist/websockets/client.js +0 -14
- package/dist/websockets/grid.js +0 -60
- package/dist/websockets/index.js +0 -17
- package/dist/websockets/websocket.js +0 -78
- package/src/api/controllers/ops.ts +0 -32
- package/src/api/routes/ops.ts +0 -30
- package/src/events/docUpdates/index.ts +0 -1
- package/src/events/docUpdates/processors.ts +0 -14
- package/src/events/docUpdates/syncUsers.ts +0 -35
- package/src/sdk/app/applications/tests/sync.spec.ts +0 -137
- package/src/sdk/plugins/index.ts +0 -5
- package/src/sdk/plugins/plugins.ts +0 -41
- package/src/websockets/client.ts +0 -11
- package/src/websockets/grid.ts +0 -55
- package/src/websockets/index.ts +0 -14
- 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.
|
|
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
|
-
|
|
40
|
+
const getDatasourcePlugin = (plugin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
41
|
var _a;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
package/dist/utilities/global.js
CHANGED
|
@@ -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.
|
|
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 ||
|
|
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
|
|
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(
|
|
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 (
|
|
111
|
-
|
|
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
|
-
|
|
129
|
-
|
|
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
|
|
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
|
|
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
|
|
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("
|
|
24
|
-
baseConfig.moduleNameMapper
|
|
25
|
-
"<rootDir
|
|
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", "
|
|
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
|
|
4
|
+
"version": "2.5.6",
|
|
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
|
|
49
|
-
"@budibase/client": "2.5.6
|
|
50
|
-
"@budibase/pro": "2.5.
|
|
51
|
-
"@budibase/shared-core": "2.5.6
|
|
52
|
-
"@budibase/string-templates": "2.5.6
|
|
53
|
-
"@budibase/types": "2.5.6
|
|
47
|
+
"@budibase/backend-core": "^2.5.6",
|
|
48
|
+
"@budibase/client": "^2.5.6",
|
|
49
|
+
"@budibase/pro": "2.5.5",
|
|
50
|
+
"@budibase/shared-core": "^2.5.6",
|
|
51
|
+
"@budibase/string-templates": "^2.5.6",
|
|
52
|
+
"@budibase/types": "^2.5.6",
|
|
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.
|
|
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.
|
|
119
|
+
"vm2": "^3.9.15",
|
|
120
120
|
"worker-farm": "1.7.0",
|
|
121
|
-
"xml2js": "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": "
|
|
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": "
|
|
179
|
+
"gitHead": "529df8b8206e547b2c942a142b9730facbbf117c"
|
|
180
180
|
}
|
package/scripts/dev/manage.js
CHANGED
|
@@ -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 => {
|
|
@@ -34,7 +34,7 @@ GO
|
|
|
34
34
|
CREATE TABLE people
|
|
35
35
|
(
|
|
36
36
|
name varchar(30) NOT NULL,
|
|
37
|
-
age
|
|
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
|
|
@@ -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
|
-
|
|
22
|
-
|
|
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 =
|
|
231
|
+
ctx.body = ACTION_DEFS
|
|
238
232
|
}
|
|
239
233
|
|
|
240
234
|
export async function getTriggerList(ctx: BBContext) {
|
|
241
|
-
ctx.body =
|
|
235
|
+
ctx.body = TRIGGER_DEFS
|
|
242
236
|
}
|
|
243
237
|
|
|
244
238
|
export async function getDefinitionList(ctx: BBContext) {
|
|
245
239
|
ctx.body = {
|
|
246
|
-
trigger:
|
|
247
|
-
action:
|
|
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 {
|
|
3
|
-
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
+
}
|