@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
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
cron: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: "string",
|
|
18
|
+
customType: "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:
|
|
27
|
+
type: "number",
|
|
28
28
|
description: "Timestamp the cron was executed",
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
required: ["timestamp"],
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
-
type:
|
|
34
|
+
type: "TRIGGER",
|
|
35
35
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
tableId: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: "string",
|
|
18
|
+
customType: "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:
|
|
28
|
-
customType:
|
|
27
|
+
type: "object",
|
|
28
|
+
customType: "row",
|
|
29
29
|
description: "The row that was deleted",
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
required: ["row"],
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
-
type:
|
|
35
|
+
type: "TRIGGER",
|
|
36
36
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
tableId: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: "string",
|
|
18
|
+
customType: "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:
|
|
28
|
-
customType:
|
|
27
|
+
type: "object",
|
|
28
|
+
customType: "row",
|
|
29
29
|
description: "The new row that was created",
|
|
30
30
|
},
|
|
31
31
|
id: {
|
|
32
|
-
type:
|
|
32
|
+
type: "string",
|
|
33
33
|
description: "Row ID - can be used for updating",
|
|
34
34
|
},
|
|
35
35
|
revision: {
|
|
36
|
-
type:
|
|
36
|
+
type: "string",
|
|
37
37
|
description: "Revision of row",
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
required: ["row", "id"],
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
type:
|
|
43
|
+
type: "TRIGGER",
|
|
44
44
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
tableId: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: "string",
|
|
18
|
+
customType: "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:
|
|
28
|
-
customType:
|
|
27
|
+
type: "object",
|
|
28
|
+
customType: "row",
|
|
29
29
|
description: "The row that was updated",
|
|
30
30
|
},
|
|
31
31
|
id: {
|
|
32
|
-
type:
|
|
32
|
+
type: "string",
|
|
33
33
|
description: "Row ID - can be used for updating",
|
|
34
34
|
},
|
|
35
35
|
revision: {
|
|
36
|
-
type:
|
|
36
|
+
type: "string",
|
|
37
37
|
description: "Revision of row",
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
required: ["row", "id"],
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
type:
|
|
43
|
+
type: "TRIGGER",
|
|
44
44
|
};
|
|
@@ -14,13 +14,13 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
schemaUrl: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: "string",
|
|
18
|
+
customType: "webhookUrl",
|
|
19
19
|
title: "Schema URL",
|
|
20
20
|
},
|
|
21
21
|
triggerUrl: {
|
|
22
|
-
type:
|
|
23
|
-
customType:
|
|
22
|
+
type: "string",
|
|
23
|
+
customType: "webhookUrl",
|
|
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:
|
|
32
|
+
type: "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:
|
|
39
|
+
type: "TRIGGER",
|
|
40
40
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
const elastic_apm_node_1 = __importDefault(require("elastic-apm-node"));
|
|
7
|
+
// enable APM if configured
|
|
8
|
+
if (process.env.ELASTIC_APM_ENABLED) {
|
|
9
|
+
console.log("Starting elastic-apm-node");
|
|
10
|
+
elastic_apm_node_1.default.start({
|
|
11
|
+
serviceName: process.env.SERVICE,
|
|
12
|
+
environment: process.env.BUDIBASE_ENVIRONMENT,
|
|
13
|
+
});
|
|
14
|
+
}
|
package/dist/environment.js
CHANGED
|
@@ -54,6 +54,7 @@ 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,
|
|
57
58
|
ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
|
|
58
59
|
AUTOMATION_MAX_ITERATIONS: parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200,
|
|
59
60
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
package/dist/events/index.js
CHANGED
|
@@ -3,9 +3,6 @@ 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;
|
|
7
6
|
const BudibaseEmitter_1 = __importDefault(require("./BudibaseEmitter"));
|
|
8
7
|
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; } });
|
|
11
8
|
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");
|
|
32
33
|
const types_1 = require("@budibase/types");
|
|
33
34
|
const fileSystem_1 = require("../utilities/fileSystem");
|
|
34
35
|
const environment_1 = __importDefault(require("../environment"));
|
|
35
36
|
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
|
|
94
|
+
const plugins = yield (0, plugin_1.getPlugins)(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
|
|
114
|
+
const plugins = yield (0, plugin_1.getPlugins)(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,11 +206,8 @@ class SqlServerIntegration extends sql_1.default {
|
|
|
206
206
|
if (typeof name !== "string") {
|
|
207
207
|
continue;
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
|
|
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,
|
|
209
|
+
schema[name] = Object.assign(Object.assign({ autocolumn: !!autoColumns.find(col => col === name), name: name, constraints: {
|
|
210
|
+
presence: requiredColumns.find(col => col === name),
|
|
214
211
|
} }, (0, utils_1.convertSqlType)(def.DATA_TYPE)), { externalType: def.DATA_TYPE });
|
|
215
212
|
}
|
|
216
213
|
tables[tableName] = {
|
|
@@ -186,14 +186,12 @@ 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
|
|
189
|
+
const constraints = {
|
|
190
|
+
presence: column.Null !== "YES",
|
|
191
|
+
};
|
|
190
192
|
const isAuto = typeof column.Extra === "string" &&
|
|
191
193
|
(column.Extra === "auto_increment" ||
|
|
192
194
|
column.Extra.toLowerCase().includes("generated"));
|
|
193
|
-
const required = column.Null !== "YES";
|
|
194
|
-
const constraints = {
|
|
195
|
-
presence: required && !isAuto && !hasDefault,
|
|
196
|
-
};
|
|
197
195
|
schema[columnName] = Object.assign(Object.assign({ name: columnName, autocolumn: isAuto, constraints }, (0, utils_1.convertSqlType)(column.Type)), { externalType: column.Type });
|
|
198
196
|
}
|
|
199
197
|
if (!tables[tableName]) {
|
|
@@ -227,15 +227,13 @@ 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 hasDefault = column.column_default != null;
|
|
231
|
-
const hasNextVal = typeof column.column_default === "string" &&
|
|
232
|
-
column.column_default.startsWith("nextval");
|
|
233
|
-
const isGenerated = column.is_generated && column.is_generated !== "NEVER";
|
|
234
|
-
const isAuto = hasNextVal || identity || isGenerated;
|
|
235
|
-
const required = column.is_nullable === "NO";
|
|
236
230
|
const constraints = {
|
|
237
|
-
presence:
|
|
231
|
+
presence: column.is_nullable === "NO",
|
|
238
232
|
};
|
|
233
|
+
const hasDefault = typeof column.column_default === "string" &&
|
|
234
|
+
column.column_default.startsWith("nextval");
|
|
235
|
+
const isGenerated = column.is_generated && column.is_generated !== "NEVER";
|
|
236
|
+
const isAuto = hasDefault || identity || isGenerated;
|
|
239
237
|
tables[tableName].schema[columnName] = Object.assign(Object.assign({ autocolumn: isAuto, name: columnName, constraints }, (0, utils_1.convertSqlType)(column.data_type)), { externalType: column.data_type });
|
|
240
238
|
}
|
|
241
239
|
const final = (0, utils_1.finaliseExternalTables)(tables, entities);
|
|
@@ -38,12 +38,6 @@ 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
|
-
},
|
|
47
41
|
},
|
|
48
42
|
query: {
|
|
49
43
|
create: {
|
|
@@ -96,7 +90,6 @@ class RedisIntegration {
|
|
|
96
90
|
port: this.config.port,
|
|
97
91
|
username: this.config.username,
|
|
98
92
|
password: this.config.password,
|
|
99
|
-
db: this.config.db,
|
|
100
93
|
});
|
|
101
94
|
}
|
|
102
95
|
disconnect() {
|
|
@@ -166,10 +166,6 @@ 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
|
-
}
|
|
173
169
|
else {
|
|
174
170
|
data = yield response.text();
|
|
175
171
|
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(`Syncing app count: ${appCount}`);
|
|
22
|
+
console.log(`[Tenant: ${tenantId}] 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,7 +27,8 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
27
27
|
rowCount += rows.length;
|
|
28
28
|
});
|
|
29
29
|
// sync row count
|
|
30
|
-
|
|
30
|
+
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
31
|
+
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`);
|
|
31
32
|
yield pro_1.quotas.setUsagePerApp(counts, types_1.StaticQuotaName.ROWS, types_1.QuotaUsageType.STATIC);
|
|
32
33
|
});
|
|
33
34
|
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
|
+
"version": "2.5.5",
|
|
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.
|
|
49
|
-
"@budibase/client": "2.5.
|
|
50
|
-
"@budibase/pro": "2.5.
|
|
51
|
-
"@budibase/shared-core": "2.5.
|
|
52
|
-
"@budibase/string-templates": "2.5.
|
|
53
|
-
"@budibase/types": "2.5.
|
|
47
|
+
"@budibase/backend-core": "^2.5.5",
|
|
48
|
+
"@budibase/client": "^2.5.5",
|
|
49
|
+
"@budibase/pro": "2.5.5",
|
|
50
|
+
"@budibase/shared-core": "^2.5.5",
|
|
51
|
+
"@budibase/string-templates": "^2.5.5",
|
|
52
|
+
"@budibase/types": "^2.5.5",
|
|
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",
|
|
@@ -12,108 +12,10 @@ 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.syncApp =
|
|
15
|
+
exports.syncApp = void 0;
|
|
16
16
|
const environment_1 = __importDefault(require("../../../environment"));
|
|
17
17
|
const backend_core_1 = require("@budibase/backend-core");
|
|
18
|
-
const pro_1 = require("@budibase/pro");
|
|
19
18
|
const __1 = __importDefault(require("../../"));
|
|
20
|
-
const global_1 = require("../../../utilities/global");
|
|
21
|
-
const utils_1 = require("../../../db/utils");
|
|
22
|
-
function syncUsersToApp(appId, users, groups) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (!(yield backend_core_1.db.dbExists(appId))) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
yield backend_core_1.context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const db = backend_core_1.context.getAppDB();
|
|
29
|
-
for (let user of users) {
|
|
30
|
-
let ctxUser = user;
|
|
31
|
-
let deletedUser = false;
|
|
32
|
-
const metadataId = (0, utils_1.generateUserMetadataID)(user._id);
|
|
33
|
-
if (user.deleted) {
|
|
34
|
-
deletedUser = true;
|
|
35
|
-
}
|
|
36
|
-
// make sure role is correct
|
|
37
|
-
if (!deletedUser) {
|
|
38
|
-
ctxUser = yield (0, global_1.processUser)(ctxUser, { appId, groups });
|
|
39
|
-
}
|
|
40
|
-
let roleId = ctxUser.roleId;
|
|
41
|
-
if (roleId === backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
42
|
-
roleId = undefined;
|
|
43
|
-
}
|
|
44
|
-
let metadata;
|
|
45
|
-
try {
|
|
46
|
-
metadata = yield db.get(metadataId);
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
if (err.status !== 404) {
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
// no metadata and user is to be deleted, can skip
|
|
53
|
-
// no role - user isn't in app anyway
|
|
54
|
-
if (!roleId) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
else if (!deletedUser) {
|
|
58
|
-
// doesn't exist yet, creating it
|
|
59
|
-
metadata = {
|
|
60
|
-
tableId: utils_1.InternalTables.USER_METADATA,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// the user doesn't exist, or doesn't have a role anymore
|
|
65
|
-
// get rid of their metadata
|
|
66
|
-
if (deletedUser || !roleId) {
|
|
67
|
-
yield db.remove(metadata);
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
// assign the roleId for the metadata doc
|
|
71
|
-
if (roleId) {
|
|
72
|
-
metadata.roleId = roleId;
|
|
73
|
-
}
|
|
74
|
-
let combined = __1.default.users.combineMetadataAndUser(ctxUser, metadata);
|
|
75
|
-
// if no combined returned, there are no updates to make
|
|
76
|
-
if (combined) {
|
|
77
|
-
yield db.put(combined);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}));
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function syncUsersToAllApps(userIds) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
// list of users, if one has been deleted it will be undefined in array
|
|
86
|
-
const users = (yield (0, global_1.getGlobalUsers)(userIds, {
|
|
87
|
-
noProcessing: true,
|
|
88
|
-
}));
|
|
89
|
-
const groups = yield pro_1.sdk.groups.fetch();
|
|
90
|
-
const finalUsers = [];
|
|
91
|
-
for (let userId of userIds) {
|
|
92
|
-
const user = users.find(user => user._id === userId);
|
|
93
|
-
if (!user) {
|
|
94
|
-
finalUsers.push({ _id: userId, deleted: true });
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
finalUsers.push(user);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const devAppIds = yield backend_core_1.db.getDevAppIDs();
|
|
101
|
-
let promises = [];
|
|
102
|
-
for (let devAppId of devAppIds) {
|
|
103
|
-
const prodAppId = backend_core_1.db.getProdAppID(devAppId);
|
|
104
|
-
for (let appId of [prodAppId, devAppId]) {
|
|
105
|
-
promises.push(syncUsersToApp(appId, finalUsers, groups));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const resp = yield Promise.allSettled(promises);
|
|
109
|
-
const failed = resp.filter(promise => promise.status === "rejected");
|
|
110
|
-
if (failed.length > 0) {
|
|
111
|
-
const reasons = failed.map(fail => fail.reason);
|
|
112
|
-
backend_core_1.logging.logAlert("Failed to sync users to apps", reasons);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
exports.syncUsersToAllApps = syncUsersToAllApps;
|
|
117
19
|
function syncApp(appId, opts) {
|
|
118
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
21
|
if (environment_1.default.DISABLE_AUTO_PROD_APP_SYNC) {
|
|
@@ -129,27 +31,31 @@ function syncApp(appId, opts) {
|
|
|
129
31
|
// specific case, want to make sure setup is skipped
|
|
130
32
|
const prodDb = backend_core_1.context.getProdAppDB({ skip_setup: true });
|
|
131
33
|
const exists = yield prodDb.exists();
|
|
34
|
+
if (!exists) {
|
|
35
|
+
// the database doesn't exist. Don't replicate
|
|
36
|
+
return {
|
|
37
|
+
message: "App sync not required, app not deployed.",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const replication = new backend_core_1.db.Replication({
|
|
41
|
+
source: prodAppId,
|
|
42
|
+
target: appId,
|
|
43
|
+
});
|
|
132
44
|
let error;
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
try {
|
|
139
|
-
const replOpts = replication.appReplicateOpts();
|
|
140
|
-
if (opts === null || opts === void 0 ? void 0 : opts.automationOnly) {
|
|
141
|
-
replOpts.filter = (doc) => doc._id.startsWith(backend_core_1.db.DocumentType.AUTOMATION);
|
|
142
|
-
}
|
|
143
|
-
yield replication.replicate(replOpts);
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
error = err;
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
yield replication.close();
|
|
45
|
+
try {
|
|
46
|
+
const replOpts = replication.appReplicateOpts();
|
|
47
|
+
if (opts === null || opts === void 0 ? void 0 : opts.automationOnly) {
|
|
48
|
+
replOpts.filter = (doc) => doc._id.startsWith(backend_core_1.db.DocumentType.AUTOMATION);
|
|
150
49
|
}
|
|
50
|
+
yield replication.replicate(replOpts);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
error = err;
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
yield replication.close();
|
|
151
57
|
}
|
|
152
|
-
// sync the users
|
|
58
|
+
// sync the users
|
|
153
59
|
yield __1.default.users.syncGlobalUsers();
|
|
154
60
|
if (error) {
|
|
155
61
|
throw error;
|
package/dist/sdk/index.js
CHANGED
|
@@ -11,7 +11,6 @@ const datasources_1 = __importDefault(require("./app/datasources"));
|
|
|
11
11
|
const queries_1 = __importDefault(require("./app/queries"));
|
|
12
12
|
const rows_1 = __importDefault(require("./app/rows"));
|
|
13
13
|
const users_1 = __importDefault(require("./users"));
|
|
14
|
-
const plugins_1 = __importDefault(require("./plugins"));
|
|
15
14
|
const sdk = {
|
|
16
15
|
backups: backups_1.default,
|
|
17
16
|
tables: tables_1.default,
|
|
@@ -21,7 +20,6 @@ const sdk = {
|
|
|
21
20
|
users: users_1.default,
|
|
22
21
|
datasources: datasources_1.default,
|
|
23
22
|
queries: queries_1.default,
|
|
24
|
-
plugins: plugins_1.default,
|
|
25
23
|
};
|
|
26
24
|
// default export for TS
|
|
27
25
|
exports.default = sdk;
|