@budibase/server 2.5.9 → 2.5.10-alpha.0
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.24635afb.js +1794 -0
- package/builder/assets/index.4eae16b2.css +6 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/application.js +3 -4
- package/dist/api/controllers/automation.js +13 -7
- package/dist/api/controllers/datasource.js +1 -1
- package/dist/api/controllers/dev.js +1 -1
- package/dist/api/controllers/ops.js +40 -0
- package/dist/api/controllers/plugin/index.js +6 -37
- package/dist/api/controllers/query/index.js +2 -2
- package/dist/api/controllers/row/ExternalRequest.js +21 -14
- package/dist/api/controllers/table/utils.js +9 -3
- package/dist/api/controllers/user.js +1 -83
- package/dist/api/index.js +1 -2
- package/dist/api/routes/index.js +2 -2
- package/dist/api/routes/{cloud.js → ops.js} +19 -6
- package/dist/api/routes/user.js +0 -1
- package/dist/app.js +4 -13
- package/dist/automations/actions.js +32 -6
- package/dist/automations/index.js +3 -2
- 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/db/utils.js +3 -2
- package/dist/environment.js +0 -1
- package/dist/events/docUpdates/index.js +17 -0
- package/dist/events/docUpdates/processors.js +18 -0
- package/dist/events/docUpdates/syncUsers.js +49 -0
- package/dist/events/index.js +3 -0
- package/dist/integrations/base/sqlTable.js +9 -2
- package/dist/integrations/index.js +3 -3
- package/dist/integrations/microsoftSqlServer.js +5 -2
- package/dist/integrations/mysql.js +5 -3
- package/dist/integrations/postgres.js +7 -5
- package/dist/integrations/redis.js +7 -0
- package/dist/integrations/rest.js +4 -0
- package/dist/migrations/functions/syncQuotas.js +2 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +1 -2
- package/dist/migrations/functions/usageQuotas/syncRows.js +1 -2
- package/dist/migrations/functions/usageQuotas/syncUsers.js +21 -0
- package/dist/sdk/app/applications/sync.js +117 -23
- package/dist/sdk/app/backups/exports.js +14 -38
- package/dist/sdk/index.js +2 -0
- package/dist/sdk/plugins/index.js +27 -0
- package/dist/sdk/plugins/plugins.js +53 -0
- package/dist/sdk/users/utils.js +21 -4
- package/dist/startup.js +31 -28
- package/dist/threads/automation.js +16 -5
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/plugin.js +33 -23
- package/dist/utilities/global.js +17 -12
- package/dist/utilities/rowProcessor/utils.js +4 -5
- package/dist/watch.js +2 -2
- package/dist/websockets/client.js +14 -0
- package/dist/websockets/grid.js +60 -0
- package/dist/websockets/index.js +17 -0
- package/dist/websockets/websocket.js +78 -0
- package/package.json +16 -16
- package/scripts/dev/manage.js +2 -0
- package/scripts/integrations/mssql/data/entrypoint.sh +1 -0
- package/scripts/integrations/mssql/data/setup.sql +17 -17
- package/scripts/integrations/mysql/init.sql +1 -1
- package/scripts/integrations/postgres/init.sql +1 -0
- package/src/api/controllers/application.ts +4 -4
- package/src/api/controllers/automation.ts +12 -6
- package/src/api/controllers/datasource.ts +15 -5
- package/src/api/controllers/dev.ts +2 -2
- package/src/api/controllers/ops.ts +32 -0
- package/src/api/controllers/plugin/index.ts +8 -45
- package/src/api/controllers/query/index.ts +2 -2
- package/src/api/controllers/row/ExternalRequest.ts +21 -12
- package/src/api/controllers/row/internal.ts +9 -10
- package/src/api/controllers/row/utils.ts +2 -2
- package/src/api/controllers/table/utils.ts +10 -3
- package/src/api/controllers/user.ts +10 -96
- package/src/api/index.ts +2 -4
- package/src/api/routes/index.ts +2 -2
- package/src/api/routes/ops.ts +30 -0
- package/src/api/routes/tests/automation.spec.js +7 -4
- package/src/api/routes/tests/user.spec.js +48 -37
- package/src/api/routes/user.ts +0 -5
- package/src/app.ts +4 -15
- package/src/automations/actions.ts +56 -24
- package/src/automations/index.ts +1 -1
- package/src/automations/steps/bash.ts +10 -7
- package/src/automations/steps/createRow.ts +15 -12
- package/src/automations/steps/delay.ts +6 -4
- package/src/automations/steps/deleteRow.ts +12 -9
- package/src/automations/steps/discord.ts +10 -8
- package/src/automations/steps/executeQuery.ts +13 -10
- package/src/automations/steps/executeScript.ts +10 -7
- package/src/automations/steps/filter.ts +8 -6
- package/src/automations/steps/integromat.ts +12 -10
- package/src/automations/steps/loop.ts +16 -10
- package/src/automations/steps/outgoingWebhook.ts +14 -11
- package/src/automations/steps/queryRows.ts +18 -15
- package/src/automations/steps/sendSmtpEmail.ts +11 -9
- package/src/automations/steps/serverLog.ts +6 -4
- package/src/automations/steps/slack.ts +8 -6
- package/src/automations/steps/updateRow.ts +15 -12
- package/src/automations/steps/zapier.ts +11 -9
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/triggerInfo/app.ts +8 -5
- package/src/automations/triggerInfo/cron.ts +7 -4
- package/src/automations/triggerInfo/rowDeleted.ts +8 -5
- package/src/automations/triggerInfo/rowSaved.ts +10 -7
- package/src/automations/triggerInfo/rowUpdated.ts +10 -7
- package/src/automations/triggerInfo/webhook.ts +9 -6
- package/src/db/utils.ts +1 -0
- package/src/environment.ts +0 -1
- package/src/events/docUpdates/index.ts +1 -0
- package/src/events/docUpdates/processors.ts +14 -0
- package/src/events/docUpdates/syncUsers.ts +35 -0
- package/src/events/index.ts +1 -0
- package/src/integration-test/postgres.spec.ts +3 -1
- package/src/integrations/base/sqlTable.ts +9 -2
- package/src/integrations/index.ts +3 -3
- package/src/integrations/microsoftSqlServer.ts +5 -2
- package/src/integrations/mysql.ts +5 -3
- package/src/integrations/postgres.ts +7 -5
- package/src/integrations/redis.ts +8 -0
- package/src/integrations/rest.ts +3 -0
- package/src/migrations/functions/syncQuotas.ts +2 -0
- package/src/migrations/functions/usageQuotas/syncApps.ts +2 -3
- package/src/migrations/functions/usageQuotas/syncRows.ts +2 -3
- package/src/migrations/functions/usageQuotas/syncUsers.ts +9 -0
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
- package/src/migrations/functions/usageQuotas/tests/syncUsers.spec.ts +26 -0
- package/src/migrations/index.ts +1 -0
- package/src/sdk/app/applications/sync.ts +129 -22
- package/src/sdk/app/applications/tests/sync.spec.ts +137 -0
- package/src/sdk/app/backups/exports.ts +17 -41
- package/src/sdk/index.ts +2 -0
- package/src/sdk/plugins/index.ts +5 -0
- package/src/sdk/plugins/plugins.ts +41 -0
- package/src/sdk/users/tests/utils.spec.ts +1 -32
- package/src/sdk/users/utils.ts +23 -5
- package/src/startup.ts +36 -34
- package/src/tests/jestEnv.ts +0 -1
- package/src/tests/jestSetup.ts +0 -1
- package/src/tests/utilities/TestConfiguration.ts +28 -0
- package/src/tests/utilities/structures.ts +25 -17
- package/src/threads/automation.ts +18 -6
- package/src/utilities/fileSystem/plugin.ts +13 -4
- package/src/utilities/global.ts +21 -16
- package/src/utilities/rowProcessor/utils.ts +9 -10
- package/src/watch.ts +2 -2
- package/src/websockets/client.ts +11 -0
- package/src/websockets/grid.ts +55 -0
- package/src/websockets/index.ts +14 -0
- package/src/websockets/websocket.ts +83 -0
- package/tsconfig.build.json +3 -5
- package/tsconfig.json +2 -1
- package/builder/assets/index.0b358332.js +0 -1817
- package/builder/assets/index.7f9a008b.css +0 -6
- package/dist/api/controllers/cloud.js +0 -130
- package/dist/elasticApm.js +0 -14
- package/dist/package.json +0 -180
- package/dist/websocket.js +0 -22
- package/scripts/likeCypress.ts +0 -35
- package/src/api/controllers/cloud.ts +0 -119
- package/src/api/routes/cloud.ts +0 -18
- package/src/api/routes/tests/cloud.spec.ts +0 -54
- package/src/elasticApm.ts +0 -10
- package/src/migrations/functions/tests/syncQuotas.spec.js +0 -26
- package/src/tests/logging.ts +0 -34
- package/src/websocket.ts +0 -26
package/dist/startup.js
CHANGED
|
@@ -44,17 +44,15 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
44
44
|
const watch_1 = require("./watch");
|
|
45
45
|
const automations = __importStar(require("./automations"));
|
|
46
46
|
const fileSystem = __importStar(require("./utilities/fileSystem"));
|
|
47
|
-
const events_1 =
|
|
47
|
+
const events_1 = __importStar(require("./events"));
|
|
48
48
|
const migrations = __importStar(require("./migrations"));
|
|
49
49
|
const bullboard = __importStar(require("./automations/bullboard"));
|
|
50
50
|
const pro = __importStar(require("@budibase/pro"));
|
|
51
51
|
const api = __importStar(require("./api"));
|
|
52
52
|
const sdk_1 = __importDefault(require("./sdk"));
|
|
53
|
-
const pino = require("koa-pino-logger");
|
|
54
53
|
let STARTUP_RAN = false;
|
|
55
54
|
function initRoutes(app) {
|
|
56
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
app.use(pino(backend_core_1.logging.pinoSettings()));
|
|
58
56
|
if (!environment_1.default.isTest()) {
|
|
59
57
|
const plugin = yield bullboard.init();
|
|
60
58
|
app.use(plugin);
|
|
@@ -79,8 +77,10 @@ function initPro() {
|
|
|
79
77
|
});
|
|
80
78
|
}
|
|
81
79
|
function shutdown(server) {
|
|
82
|
-
server
|
|
83
|
-
|
|
80
|
+
if (server) {
|
|
81
|
+
server.close();
|
|
82
|
+
server.destroy();
|
|
83
|
+
}
|
|
84
84
|
}
|
|
85
85
|
function startup(app, server) {
|
|
86
86
|
var _a;
|
|
@@ -96,6 +96,7 @@ function startup(app, server) {
|
|
|
96
96
|
events_1.default.emitPort(environment_1.default.PORT);
|
|
97
97
|
fileSystem.init();
|
|
98
98
|
yield redis.init();
|
|
99
|
+
(0, events_1.init)();
|
|
99
100
|
// run migrations on startup if not done via http
|
|
100
101
|
// not recommended in a clustered environment
|
|
101
102
|
if (!environment_1.default.HTTP_MIGRATIONS && !environment_1.default.isTest()) {
|
|
@@ -104,29 +105,7 @@ function startup(app, server) {
|
|
|
104
105
|
}
|
|
105
106
|
catch (e) {
|
|
106
107
|
backend_core_1.logging.logAlert("Error performing migrations. Exiting.", e);
|
|
107
|
-
shutdown();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// check and create admin user if required
|
|
111
|
-
if (environment_1.default.SELF_HOSTED &&
|
|
112
|
-
!environment_1.default.MULTI_TENANCY &&
|
|
113
|
-
environment_1.default.BB_ADMIN_USER_EMAIL &&
|
|
114
|
-
environment_1.default.BB_ADMIN_USER_PASSWORD) {
|
|
115
|
-
const checklist = yield (0, workerRequests_1.getChecklist)();
|
|
116
|
-
if (!((_a = checklist === null || checklist === void 0 ? void 0 : checklist.adminUser) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
117
|
-
try {
|
|
118
|
-
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
119
|
-
const user = yield (0, workerRequests_1.createAdminUser)(environment_1.default.BB_ADMIN_USER_EMAIL, environment_1.default.BB_ADMIN_USER_PASSWORD, tenantId);
|
|
120
|
-
// Need to set up an API key for automated integration tests
|
|
121
|
-
if (environment_1.default.isTest()) {
|
|
122
|
-
yield (0, workerRequests_1.generateApiKey)(user._id);
|
|
123
|
-
}
|
|
124
|
-
console.log("Admin account automatically created for", environment_1.default.BB_ADMIN_USER_EMAIL);
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
backend_core_1.logging.logAlert("Error creating initial admin user. Exiting.", e);
|
|
128
|
-
shutdown();
|
|
129
|
-
}
|
|
108
|
+
shutdown(server);
|
|
130
109
|
}
|
|
131
110
|
}
|
|
132
111
|
// monitor plugin directory if required
|
|
@@ -150,6 +129,30 @@ function startup(app, server) {
|
|
|
150
129
|
// bring routes online as final step once everything ready
|
|
151
130
|
yield initRoutes(app);
|
|
152
131
|
}
|
|
132
|
+
// check and create admin user if required
|
|
133
|
+
// this must be run after the api has been initialised due to
|
|
134
|
+
// the app user sync
|
|
135
|
+
if (environment_1.default.SELF_HOSTED &&
|
|
136
|
+
!environment_1.default.MULTI_TENANCY &&
|
|
137
|
+
environment_1.default.BB_ADMIN_USER_EMAIL &&
|
|
138
|
+
environment_1.default.BB_ADMIN_USER_PASSWORD) {
|
|
139
|
+
const checklist = yield (0, workerRequests_1.getChecklist)();
|
|
140
|
+
if (!((_a = checklist === null || checklist === void 0 ? void 0 : checklist.adminUser) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
141
|
+
try {
|
|
142
|
+
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
143
|
+
const user = yield (0, workerRequests_1.createAdminUser)(environment_1.default.BB_ADMIN_USER_EMAIL, environment_1.default.BB_ADMIN_USER_PASSWORD, tenantId);
|
|
144
|
+
// Need to set up an API key for automated integration tests
|
|
145
|
+
if (environment_1.default.isTest()) {
|
|
146
|
+
yield (0, workerRequests_1.generateApiKey)(user._id);
|
|
147
|
+
}
|
|
148
|
+
console.log("Admin account automatically created for", environment_1.default.BB_ADMIN_USER_EMAIL);
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
backend_core_1.logging.logAlert("Error creating initial admin user. Exiting.", e);
|
|
152
|
+
shutdown(server);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
153
156
|
});
|
|
154
157
|
}
|
|
155
158
|
exports.startup = startup;
|
|
@@ -52,14 +52,14 @@ const string_templates_1 = require("@budibase/string-templates");
|
|
|
52
52
|
const fp_1 = require("lodash/fp");
|
|
53
53
|
const sdkUtils = __importStar(require("../sdk/utils"));
|
|
54
54
|
const environment_1 = __importDefault(require("../environment"));
|
|
55
|
-
const FILTER_STEP_ID = actions.
|
|
56
|
-
const LOOP_STEP_ID = actions.
|
|
55
|
+
const FILTER_STEP_ID = actions.BUILTIN_ACTION_DEFINITIONS.FILTER.stepId;
|
|
56
|
+
const LOOP_STEP_ID = actions.BUILTIN_ACTION_DEFINITIONS.LOOP.stepId;
|
|
57
57
|
const CRON_STEP_ID = triggerInfo_1.definitions.CRON.stepId;
|
|
58
58
|
const STOPPED_STATUS = { success: true, status: types_1.AutomationStatus.STOPPED };
|
|
59
59
|
function getLoopIterations(loopStep, input) {
|
|
60
60
|
const binding = automationUtils.typecastForLooping(loopStep, input);
|
|
61
|
-
if (!
|
|
62
|
-
return
|
|
61
|
+
if (!binding) {
|
|
62
|
+
return 0;
|
|
63
63
|
}
|
|
64
64
|
if (Array.isArray(binding)) {
|
|
65
65
|
return binding.length;
|
|
@@ -67,7 +67,7 @@ function getLoopIterations(loopStep, input) {
|
|
|
67
67
|
if (typeof binding === "string") {
|
|
68
68
|
return automationUtils.stringSplit(binding).length;
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return 0;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* The automation orchestrator is a class responsible for executing automations.
|
|
@@ -372,6 +372,17 @@ class Orchestrator {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
+
if (loopStep && iterations === 0) {
|
|
376
|
+
loopStep = undefined;
|
|
377
|
+
this.executionOutput.steps.splice(loopStepNumber + 1, 0, {
|
|
378
|
+
id: step.id,
|
|
379
|
+
stepId: step.stepId,
|
|
380
|
+
outputs: { status: types_1.AutomationStatus.NO_ITERATIONS, success: true },
|
|
381
|
+
inputs: {},
|
|
382
|
+
});
|
|
383
|
+
this._context.steps.splice(loopStepNumber, 1);
|
|
384
|
+
iterations = 1;
|
|
385
|
+
}
|
|
375
386
|
// Delete the step after the loop step as it's irrelevant, since information is included
|
|
376
387
|
// in the loop step
|
|
377
388
|
if (wasLoopStep && !loopStep) {
|