@budibase/server 1.3.12-alpha.3 → 1.3.14
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/__mocks__/mongodb.ts +1 -1
- package/builder/assets/{index.7886c551.css → index.a70e216a.css} +2 -2
- package/builder/assets/index.d8428ac8.js +876 -0
- package/builder/assets/vendor.5e1fe644.css +1 -0
- package/builder/assets/vendor.67dbd8fa.js +248 -0
- package/builder/index.html +4 -2
- package/coverage/clover.xml +335 -355
- package/coverage/coverage-final.json +22 -22
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +8 -5
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +13 -82
- package/coverage/lcov-report/api/controllers/datasource.js.html +20 -20
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +32 -32
- package/coverage/lcov-report/api/controllers/integration.js.html +6 -6
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +12 -204
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +12 -12
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +24 -24
- package/coverage/lcov-report/automations/index.js.html +18 -9
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +126 -24
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +18 -18
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +20 -56
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +48 -48
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +19 -19
- package/coverage/lcov-report/utilities/index.js.html +66 -42
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +5 -5
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +4 -4
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +6 -3
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +604 -652
- package/dist/api/controllers/application.js +5 -10
- package/dist/api/controllers/backup.js +2 -1
- package/dist/api/controllers/component.js +1 -18
- package/dist/api/controllers/datasource.js +4 -4
- package/dist/api/controllers/deploy/index.js +17 -2
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/row/ExternalRequest.js +1 -1
- package/dist/api/controllers/screen.js +2 -51
- package/dist/api/controllers/static/index.js +0 -1
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/dist/api/controllers/static/templates/preview.hbs +1 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/static.js +1 -1
- package/dist/app.js +0 -9
- package/dist/automations/index.js +10 -5
- package/dist/automations/triggers.js +39 -5
- package/dist/automations/utils.js +16 -7
- package/dist/db/utils.js +1 -10
- package/dist/environment.js +0 -1
- package/dist/integrations/airtable.js +129 -126
- package/dist/integrations/arangodb.js +89 -86
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/couchdb.js +83 -80
- package/dist/integrations/dynamodb.js +164 -161
- package/dist/integrations/elasticsearch.js +138 -135
- package/dist/integrations/firebase.js +157 -154
- package/dist/integrations/googlesheets.js +327 -323
- package/dist/integrations/index.js +51 -93
- package/dist/integrations/microsoftSqlServer.js +243 -240
- package/dist/integrations/mongodb.js +242 -239
- package/dist/integrations/mysql.js +219 -215
- package/dist/integrations/oracle.js +322 -318
- package/dist/integrations/postgres.js +265 -262
- package/dist/integrations/redis.js +139 -134
- package/dist/integrations/rest.js +296 -278
- package/dist/integrations/s3.js +64 -61
- package/dist/integrations/snowflake.js +86 -83
- package/dist/package.json +6 -8
- package/dist/threads/automation.js +6 -0
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +6 -71
- package/dist/utilities/index.js +8 -0
- package/dist/utilities/rowProcessor/utils.js +1 -1
- package/dist/utilities/usageQuota/rows.js +2 -1
- package/package.json +7 -9
- package/scripts/dev/manage.js +0 -1
- package/src/api/controllers/application.ts +2 -6
- package/src/api/controllers/backup.js +2 -1
- package/src/api/controllers/component.js +2 -25
- package/src/api/controllers/datasource.js +4 -4
- package/src/api/controllers/deploy/index.ts +17 -4
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/screen.js +1 -65
- package/src/api/controllers/static/index.ts +0 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/src/api/controllers/static/templates/preview.hbs +1 -3
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/static.ts +1 -1
- package/src/api/routes/tests/query.spec.js +28 -11
- package/src/api/routes/tests/static.spec.js +2 -2
- package/src/app.ts +0 -12
- package/src/automations/index.js +6 -3
- package/src/automations/triggers.js +44 -10
- package/src/automations/utils.ts +21 -9
- package/src/db/utils.js +0 -12
- package/src/definitions/datasource.ts +1 -0
- package/src/environment.js +0 -1
- package/src/integrations/airtable.ts +118 -116
- package/src/integrations/arangodb.ts +89 -87
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/couchdb.ts +89 -83
- package/src/integrations/dynamodb.ts +175 -173
- package/src/integrations/elasticsearch.ts +122 -120
- package/src/integrations/firebase.ts +159 -157
- package/src/integrations/googlesheets.ts +338 -328
- package/src/integrations/index.ts +21 -59
- package/src/integrations/microsoftSqlServer.ts +251 -249
- package/src/integrations/mongodb.ts +258 -261
- package/src/integrations/mysql.ts +234 -229
- package/src/integrations/oracle.ts +380 -373
- package/src/integrations/postgres.ts +268 -264
- package/src/integrations/redis.ts +132 -128
- package/src/integrations/rest.ts +330 -312
- package/src/integrations/s3.ts +71 -68
- package/src/integrations/snowflake.ts +82 -80
- package/src/integrations/tests/{airtable.spec.ts → airtable.spec.js} +18 -21
- package/src/integrations/tests/{arangodb.spec.ts → arangodb.spec.js} +9 -12
- package/src/integrations/tests/{couchdb.spec.ts → couchdb.spec.js} +27 -33
- package/src/integrations/tests/{dynamodb.spec.ts → dynamodb.spec.js} +41 -45
- package/src/integrations/tests/{elasticsearch.spec.ts → elasticsearch.spec.js} +21 -22
- package/src/integrations/tests/{firebase.spec.ts → firebase.spec.js} +28 -33
- package/src/integrations/tests/{microsoftSqlServer.spec.ts → microsoftSqlServer.spec.js} +11 -12
- package/src/integrations/tests/{mongo.spec.ts → mongo.spec.js} +35 -46
- package/src/integrations/tests/{mysql.spec.ts → mysql.spec.js} +15 -17
- package/src/integrations/tests/{oracle.spec.ts → oracle.spec.js} +17 -19
- package/src/integrations/tests/{postgres.spec.ts → postgres.spec.js} +17 -19
- package/src/integrations/tests/{redis.spec.ts → redis.spec.js} +18 -27
- package/src/integrations/tests/{rest.spec.ts → rest.spec.js} +49 -22
- package/src/integrations/tests/{s3.spec.ts → s3.spec.js} +8 -10
- package/src/integrations/tests/{sql.spec.ts → sql.spec.js} +177 -228
- package/src/module.d.ts +0 -1
- package/src/threads/automation.ts +6 -0
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +6 -75
- package/src/utilities/index.js +8 -0
- package/src/utilities/rowProcessor/utils.js +1 -1
- package/src/utilities/usageQuota/rows.js +2 -1
- package/builder/assets/index.e759397f.js +0 -994
- package/dist/api/controllers/plugin.js +0 -119
- package/dist/api/routes/plugin.js +0 -38
- package/dist/watch.js +0 -77
- package/src/api/controllers/plugin.ts +0 -110
- package/src/api/routes/plugin.ts +0 -13
- package/src/watch.ts +0 -38
|
@@ -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.
|
|
15
|
+
exports.sync = exports.destroy = exports.revertClient = exports.updateClient = exports.update = exports.create = exports.fetchAppPackage = exports.fetchAppDefinition = exports.fetch = exports.getAppUrl = void 0;
|
|
16
16
|
const environment_1 = __importDefault(require("../../environment"));
|
|
17
17
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
18
18
|
const staticViews_1 = require("../../db/views/staticViews");
|
|
@@ -353,7 +353,7 @@ const update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
353
353
|
checkAppUrl(ctx, apps, url, ctx.params.appId);
|
|
354
354
|
ctx.request.body.url = url;
|
|
355
355
|
}
|
|
356
|
-
const app = yield
|
|
356
|
+
const app = yield updateAppPackage(ctx.request.body, ctx.params.appId);
|
|
357
357
|
yield backend_core_2.events.app.updated(app);
|
|
358
358
|
ctx.status = 200;
|
|
359
359
|
ctx.body = app;
|
|
@@ -375,7 +375,7 @@ const updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
375
375
|
version: updatedToVersion,
|
|
376
376
|
revertableVersion: currentVersion,
|
|
377
377
|
};
|
|
378
|
-
const app = yield
|
|
378
|
+
const app = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
379
379
|
yield backend_core_2.events.app.versionUpdated(app, currentVersion, updatedToVersion);
|
|
380
380
|
ctx.status = 200;
|
|
381
381
|
ctx.body = app;
|
|
@@ -399,7 +399,7 @@ const revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
399
399
|
version: revertedToVersion,
|
|
400
400
|
revertableVersion: null,
|
|
401
401
|
};
|
|
402
|
-
const app = yield
|
|
402
|
+
const app = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
403
403
|
yield backend_core_2.events.app.versionReverted(app, currentVersion, revertedToVersion);
|
|
404
404
|
ctx.status = 200;
|
|
405
405
|
ctx.body = app;
|
|
@@ -490,11 +490,7 @@ const sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
490
490
|
});
|
|
491
491
|
let error;
|
|
492
492
|
try {
|
|
493
|
-
yield replication.replicate(
|
|
494
|
-
filter: function (doc) {
|
|
495
|
-
return doc._id !== utils_1.DocumentType.APP_METADATA;
|
|
496
|
-
},
|
|
497
|
-
});
|
|
493
|
+
yield replication.replicate(replication.appReplicateOpts());
|
|
498
494
|
}
|
|
499
495
|
catch (err) {
|
|
500
496
|
error = err;
|
|
@@ -531,7 +527,6 @@ const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0
|
|
|
531
527
|
return newAppPackage;
|
|
532
528
|
}));
|
|
533
529
|
});
|
|
534
|
-
exports.updateAppPackage = updateAppPackage;
|
|
535
530
|
const migrateAppNavigation = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
536
531
|
const db = backend_core_1.context.getAppDB();
|
|
537
532
|
const existing = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
@@ -11,11 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const { streamBackup } = require("../../utilities/fileSystem");
|
|
12
12
|
const { events, context } = require("@budibase/backend-core");
|
|
13
13
|
const { DocumentType } = require("../../db/utils");
|
|
14
|
+
const { isQsTrue } = require("../../utilities");
|
|
14
15
|
exports.exportAppDump = function (ctx) {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
let { appId, excludeRows } = ctx.query;
|
|
17
18
|
const appName = decodeURI(ctx.query.appname);
|
|
18
|
-
excludeRows = excludeRows
|
|
19
|
+
excludeRows = isQsTrue(excludeRows);
|
|
19
20
|
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`;
|
|
20
21
|
ctx.attachment(backupIdentifier);
|
|
21
22
|
ctx.body = yield streamBackup(appId, excludeRows);
|
|
@@ -8,11 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { DocumentType
|
|
11
|
+
const { DocumentType } = require("../../db/utils");
|
|
12
12
|
const { getComponentLibraryManifest } = require("../../utilities/fileSystem");
|
|
13
13
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
|
-
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
15
|
-
const env = require("../../environment");
|
|
16
14
|
exports.fetchAppComponentDefinitions = function (ctx) {
|
|
17
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
16
|
try {
|
|
@@ -37,21 +35,6 @@ exports.fetchAppComponentDefinitions = function (ctx) {
|
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
|
-
// for now custom components only supported in self-host
|
|
41
|
-
if (env.SELF_HOSTED) {
|
|
42
|
-
// Add custom components
|
|
43
|
-
const globalDB = getGlobalDB();
|
|
44
|
-
const response = yield globalDB.allDocs(getPluginParams(null, {
|
|
45
|
-
include_docs: true,
|
|
46
|
-
}));
|
|
47
|
-
response.rows
|
|
48
|
-
.map(row => row.doc)
|
|
49
|
-
.filter(plugin => plugin.schema.type === "component")
|
|
50
|
-
.forEach(plugin => {
|
|
51
|
-
const fullComponentName = `plugin/${plugin.name}`;
|
|
52
|
-
definitions[fullComponentName] = Object.assign({ component: fullComponentName }, plugin.schema.schema);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
38
|
ctx.body = definitions;
|
|
56
39
|
}
|
|
57
40
|
catch (err) {
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const { generateDatasourceID, getDatasourceParams, getQueryParams, DocumentType, BudibaseInternalDB, getTableParams, } = require("../../db/utils");
|
|
12
12
|
const { BuildSchemaErrors, InvalidColumns } = require("../../constants");
|
|
13
|
-
const {
|
|
13
|
+
const { integrations } = require("../../integrations");
|
|
14
14
|
const { getDatasourceAndQuery } = require("./row/utils");
|
|
15
15
|
const { invalidateDynamicVariables } = require("../../threads/utils");
|
|
16
16
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
@@ -96,7 +96,7 @@ exports.update = function (ctx) {
|
|
|
96
96
|
datasource._rev = response.rev;
|
|
97
97
|
// Drain connection pools when configuration is changed
|
|
98
98
|
if (datasource.source) {
|
|
99
|
-
const source =
|
|
99
|
+
const source = integrations[datasource.source];
|
|
100
100
|
if (source && source.pool) {
|
|
101
101
|
yield source.pool.end();
|
|
102
102
|
}
|
|
@@ -123,7 +123,7 @@ exports.save = function (ctx) {
|
|
|
123
123
|
datasource._rev = dbResp.rev;
|
|
124
124
|
// Drain connection pools when configuration is changed
|
|
125
125
|
if (datasource.source) {
|
|
126
|
-
const source =
|
|
126
|
+
const source = integrations[datasource.source];
|
|
127
127
|
if (source && source.pool) {
|
|
128
128
|
yield source.pool.end();
|
|
129
129
|
}
|
|
@@ -188,7 +188,7 @@ function updateError(error, newError, tables) {
|
|
|
188
188
|
return error;
|
|
189
189
|
}
|
|
190
190
|
const buildSchemaHelper = (datasource) => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
-
const Connector =
|
|
191
|
+
const Connector = integrations[datasource.source];
|
|
192
192
|
// Connect to the DB and build the schema
|
|
193
193
|
const connector = new Connector(datasource.config);
|
|
194
194
|
yield connector.buildSchema(datasource._id, datasource.entities);
|
|
@@ -100,14 +100,29 @@ function deployApp(deployment) {
|
|
|
100
100
|
target: productionAppId,
|
|
101
101
|
};
|
|
102
102
|
replication = new db_1.Replication(config);
|
|
103
|
+
const devDb = (0, context_1.getDevAppDB)();
|
|
104
|
+
console.log("Compacting development DB");
|
|
105
|
+
yield devDb.compact();
|
|
103
106
|
console.log("Replication object created");
|
|
104
|
-
yield replication.replicate();
|
|
107
|
+
yield replication.replicate(replication.appReplicateOpts());
|
|
105
108
|
console.log("replication complete.. replacing app meta doc");
|
|
109
|
+
// app metadata is excluded as it is likely to be in conflict
|
|
110
|
+
// replicate the app metadata document manually
|
|
106
111
|
const db = (0, context_1.getProdAppDB)();
|
|
107
|
-
const appDoc = yield
|
|
112
|
+
const appDoc = yield devDb.get(utils_1.DocumentType.APP_METADATA);
|
|
113
|
+
try {
|
|
114
|
+
const prodAppDoc = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
115
|
+
appDoc._rev = prodAppDoc._rev;
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
delete appDoc._rev;
|
|
119
|
+
}
|
|
120
|
+
// switch to production app ID
|
|
108
121
|
deployment.appUrl = appDoc.url;
|
|
109
122
|
appDoc.appId = productionAppId;
|
|
110
123
|
appDoc.instance._id = productionAppId;
|
|
124
|
+
// remove automation errors if they exist
|
|
125
|
+
delete appDoc.automationErrors;
|
|
111
126
|
yield db.put(appDoc);
|
|
112
127
|
yield cache_1.app.invalidateAppMetadata(productionAppId);
|
|
113
128
|
console.log("New app doc written successfully.");
|
|
@@ -8,14 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const {
|
|
11
|
+
const { cloneDeep } = require("lodash");
|
|
12
|
+
const { definitions } = require("../../integrations");
|
|
12
13
|
const { SourceName } = require("@budibase/types");
|
|
13
14
|
const googlesheets = require("../../integrations/googlesheets");
|
|
14
15
|
const { featureFlags } = require("@budibase/backend-core");
|
|
15
16
|
exports.fetch = function (ctx) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
ctx.status = 200;
|
|
18
|
-
const defs =
|
|
19
|
+
const defs = cloneDeep(definitions);
|
|
19
20
|
// for google sheets integration google verification
|
|
20
21
|
if (featureFlags.isEnabled(featureFlags.FeatureFlag.GOOGLE_SHEETS)) {
|
|
21
22
|
defs[SourceName.GOOGLE_SHEETS] = googlesheets.schema;
|
|
@@ -25,8 +26,7 @@ exports.fetch = function (ctx) {
|
|
|
25
26
|
};
|
|
26
27
|
exports.find = function (ctx) {
|
|
27
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const defs = yield getDefinitions();
|
|
29
29
|
ctx.status = 200;
|
|
30
|
-
ctx.body =
|
|
30
|
+
ctx.body = definitions[ctx.params.type];
|
|
31
31
|
});
|
|
32
32
|
};
|
|
@@ -446,7 +446,7 @@ var External;
|
|
|
446
446
|
});
|
|
447
447
|
// this is the response from knex if no rows found
|
|
448
448
|
const rows = !response[0].read ? response : [];
|
|
449
|
-
const storeTo = isMany ? field.throughFrom || linkPrimaryKey :
|
|
449
|
+
const storeTo = isMany ? field.throughFrom || linkPrimaryKey : fieldName;
|
|
450
450
|
related[storeTo] = { rows, isMany, tableId };
|
|
451
451
|
}
|
|
452
452
|
return related;
|
|
@@ -8,12 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { getScreenParams, generateScreenID
|
|
11
|
+
const { getScreenParams, generateScreenID } = require("../../db/utils");
|
|
12
12
|
const { AccessController } = require("@budibase/backend-core/roles");
|
|
13
13
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
14
|
const { events } = require("@budibase/backend-core");
|
|
15
|
-
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
16
|
-
const { updateAppPackage } = require("./application");
|
|
17
15
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
16
|
const db = getAppDB();
|
|
19
17
|
const screens = (yield db.allDocs(getScreenParams(null, {
|
|
@@ -30,44 +28,11 @@ exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
30
28
|
eventFn = events.screen.created;
|
|
31
29
|
}
|
|
32
30
|
const response = yield db.put(screen);
|
|
33
|
-
// Find any custom components being used
|
|
34
|
-
let pluginNames = [];
|
|
35
|
-
let pluginAdded = false;
|
|
36
|
-
findPlugins(screen.props, pluginNames);
|
|
37
|
-
if (pluginNames.length) {
|
|
38
|
-
const globalDB = getGlobalDB();
|
|
39
|
-
const pluginsResponse = yield globalDB.allDocs(getPluginParams(null, {
|
|
40
|
-
include_docs: true,
|
|
41
|
-
}));
|
|
42
|
-
const requiredPlugins = pluginsResponse.rows
|
|
43
|
-
.map(row => row.doc)
|
|
44
|
-
.filter(plugin => {
|
|
45
|
-
return (plugin.schema.type === "component" &&
|
|
46
|
-
pluginNames.includes(`plugin/${plugin.name}`));
|
|
47
|
-
});
|
|
48
|
-
// Update the app metadata
|
|
49
|
-
const application = yield db.get(DocumentType.APP_METADATA);
|
|
50
|
-
let usedPlugins = application.usedPlugins || [];
|
|
51
|
-
requiredPlugins.forEach(plugin => {
|
|
52
|
-
if (!usedPlugins.find(x => x._id === plugin._id)) {
|
|
53
|
-
pluginAdded = true;
|
|
54
|
-
usedPlugins.push({
|
|
55
|
-
_id: plugin._id,
|
|
56
|
-
name: plugin.name,
|
|
57
|
-
version: plugin.version,
|
|
58
|
-
jsUrl: plugin.jsUrl,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
if (pluginAdded) {
|
|
63
|
-
yield updateAppPackage({ usedPlugins }, ctx.appId);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
31
|
if (eventFn) {
|
|
67
32
|
yield eventFn(screen);
|
|
68
33
|
}
|
|
69
34
|
ctx.message = `Screen ${screen.name} saved.`;
|
|
70
|
-
ctx.body = Object.assign(Object.assign({}, screen), { _id: response.id, _rev: response.rev
|
|
35
|
+
ctx.body = Object.assign(Object.assign({}, screen), { _id: response.id, _rev: response.rev });
|
|
71
36
|
});
|
|
72
37
|
exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
38
|
const db = getAppDB();
|
|
@@ -80,17 +45,3 @@ exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
80
45
|
};
|
|
81
46
|
ctx.status = 200;
|
|
82
47
|
});
|
|
83
|
-
const findPlugins = (component, foundPlugins) => {
|
|
84
|
-
if (!component) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (component._component.startsWith("plugin")) {
|
|
88
|
-
if (!foundPlugins.includes(component._component)) {
|
|
89
|
-
foundPlugins.push(component._component);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (!component._children || !component._children.length) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
component._children.forEach(child => findPlugins(child, foundPlugins));
|
|
96
|
-
};
|
|
@@ -113,7 +113,6 @@ const serveApp = function (ctx) {
|
|
|
113
113
|
production: env.isProd(),
|
|
114
114
|
appId,
|
|
115
115
|
clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
|
|
116
|
-
usedPlugins: appInfo.usedPlugins,
|
|
117
116
|
});
|
|
118
117
|
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`);
|
|
119
118
|
ctx.body = yield processString(appHbs, {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
export let favicon = ""
|
|
4
4
|
|
|
5
5
|
export let clientLibPath
|
|
6
|
-
export let usedPlugins
|
|
7
6
|
</script>
|
|
8
7
|
|
|
9
8
|
<svelte:head>
|
|
@@ -84,15 +83,6 @@
|
|
|
84
83
|
</script>
|
|
85
84
|
<script type="application/javascript" src={clientLibPath}>
|
|
86
85
|
</script>
|
|
87
|
-
<!-- Custom components need inserted after the core client library -->
|
|
88
|
-
<!-- But before loadBudibase is called -->
|
|
89
|
-
{#if usedPlugins?.length}
|
|
90
|
-
{#each usedPlugins as plugin}
|
|
91
|
-
<script
|
|
92
|
-
type="application/javascript"
|
|
93
|
-
src={`/plugins/${plugin.jsUrl}`}></script>
|
|
94
|
-
{/each}
|
|
95
|
-
{/if}
|
|
96
86
|
<script type="application/javascript">
|
|
97
87
|
if (window.loadBudibase) {
|
|
98
88
|
window.loadBudibase()
|
|
@@ -66,8 +66,7 @@
|
|
|
66
66
|
customTheme,
|
|
67
67
|
previewDevice,
|
|
68
68
|
navigation,
|
|
69
|
-
hiddenComponentIds
|
|
70
|
-
usedPlugins
|
|
69
|
+
hiddenComponentIds
|
|
71
70
|
} = parsed
|
|
72
71
|
|
|
73
72
|
// Set some flags so the app knows we're in the builder
|
|
@@ -82,7 +81,6 @@
|
|
|
82
81
|
window["##BUDIBASE_PREVIEW_DEVICE##"] = previewDevice
|
|
83
82
|
window["##BUDIBASE_PREVIEW_NAVIGATION##"] = navigation
|
|
84
83
|
window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"] = hiddenComponentIds
|
|
85
|
-
window["##BUDIBASE_USED_PLUGINS##"] = usedPlugins
|
|
86
84
|
|
|
87
85
|
// Initialise app
|
|
88
86
|
try {
|
package/dist/api/routes/index.js
CHANGED
|
@@ -30,7 +30,6 @@ const metadata_1 = __importDefault(require("./metadata"));
|
|
|
30
30
|
const dev_1 = __importDefault(require("./dev"));
|
|
31
31
|
const cloud_1 = __importDefault(require("./cloud"));
|
|
32
32
|
const migrations_1 = __importDefault(require("./migrations"));
|
|
33
|
-
const plugin_1 = __importDefault(require("./plugin"));
|
|
34
33
|
var static_1 = require("./static");
|
|
35
34
|
Object.defineProperty(exports, "staticRoutes", { enumerable: true, get: function () { return __importDefault(static_1).default; } });
|
|
36
35
|
var public_1 = require("./public");
|
|
@@ -64,5 +63,4 @@ exports.mainRoutes = [
|
|
|
64
63
|
table_1.default,
|
|
65
64
|
row_1.default,
|
|
66
65
|
migrations_1.default,
|
|
67
|
-
plugin_1.default,
|
|
68
66
|
];
|
|
@@ -72,7 +72,7 @@ router
|
|
|
72
72
|
.post("/api/beta/:feature", controller.toggleBetaUiFeature)
|
|
73
73
|
.post("/api/attachments/:tableId/upload", (0, resourceId_1.paramResource)("tableId"), (0, authorized_1.default)(permissions_1.PermissionTypes.TABLE, permissions_1.PermissionLevels.WRITE), controller.uploadFile)
|
|
74
74
|
.post("/api/attachments/:tableId/delete", (0, resourceId_1.paramResource)("tableId"), (0, authorized_1.default)(permissions_1.PermissionTypes.TABLE, permissions_1.PermissionLevels.WRITE), controller.deleteObjects)
|
|
75
|
-
.get("/preview", (0, authorized_1.default)(permissions_1.BUILDER), controller.serveBuilderPreview)
|
|
75
|
+
.get("/app/preview", (0, authorized_1.default)(permissions_1.BUILDER), controller.serveBuilderPreview)
|
|
76
76
|
.get("/:appId/:path*", controller.serveApp)
|
|
77
77
|
.get("/app/:appUrl/:path*", controller.serveApp)
|
|
78
78
|
.post("/api/attachments/:datasourceId/url", (0, authorized_1.default)(permissions_1.PermissionTypes.TABLE, permissions_1.PermissionLevels.READ), controller.getSignedUploadURL);
|
package/dist/app.js
CHANGED
|
@@ -60,12 +60,10 @@ const bullboard = require("./automations/bullboard");
|
|
|
60
60
|
const { logAlert } = require("@budibase/backend-core/logging");
|
|
61
61
|
const { pinoSettings } = require("@budibase/backend-core");
|
|
62
62
|
const { Thread } = require("./threads");
|
|
63
|
-
const fs = require("fs");
|
|
64
63
|
const redis_1 = __importDefault(require("./utilities/redis"));
|
|
65
64
|
const migrations = __importStar(require("./migrations"));
|
|
66
65
|
const backend_core_1 = require("@budibase/backend-core");
|
|
67
66
|
const workerRequests_1 = require("./utilities/workerRequests");
|
|
68
|
-
const watch_1 = require("./watch");
|
|
69
67
|
const app = new Koa();
|
|
70
68
|
// set up top level koa middleware
|
|
71
69
|
app.use(koaBody({
|
|
@@ -152,13 +150,6 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
|
-
// monitor plugin directory if required
|
|
156
|
-
if (env.SELF_HOSTED &&
|
|
157
|
-
!env.MULTI_TENANCY &&
|
|
158
|
-
env.PLUGINS_DIR &&
|
|
159
|
-
fs.existsSync(env.PLUGINS_DIR)) {
|
|
160
|
-
(0, watch_1.watch)();
|
|
161
|
-
}
|
|
162
153
|
// check for version updates
|
|
163
154
|
yield backend_core_1.installation.checkInstallVersion();
|
|
164
155
|
// done last - this will never complete
|
|
@@ -10,16 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const { processEvent } = require("./utils");
|
|
12
12
|
const { queue, shutdown } = require("./bullboard");
|
|
13
|
-
const { TRIGGER_DEFINITIONS } = require("./triggers");
|
|
13
|
+
const { TRIGGER_DEFINITIONS, rebootTrigger } = require("./triggers");
|
|
14
14
|
const { ACTION_DEFINITIONS } = require("./actions");
|
|
15
15
|
/**
|
|
16
16
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
17
17
|
*/
|
|
18
18
|
exports.init = function () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
// this promise will not complete
|
|
21
|
+
const promise = queue.process((job) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield processEvent(job);
|
|
23
|
+
}));
|
|
24
|
+
// on init we need to trigger any reboot automations
|
|
25
|
+
yield rebootTrigger();
|
|
26
|
+
return promise;
|
|
27
|
+
});
|
|
23
28
|
};
|
|
24
29
|
exports.getQueues = () => {
|
|
25
30
|
return [queue];
|
|
@@ -19,23 +19,28 @@ const { checkTestFlag } = require("../utilities/redis");
|
|
|
19
19
|
const utils = require("./utils");
|
|
20
20
|
const env = require("../environment");
|
|
21
21
|
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
22
|
+
const { getAllApps } = require("@budibase/backend-core/db");
|
|
22
23
|
const TRIGGER_DEFINITIONS = definitions;
|
|
23
24
|
const JOB_OPTS = {
|
|
24
25
|
removeOnComplete: true,
|
|
25
26
|
removeOnFail: true,
|
|
26
27
|
};
|
|
28
|
+
function getAllAutomations() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const db = getAppDB();
|
|
31
|
+
let automations = yield db.allDocs(getAutomationParams(null, { include_docs: true }));
|
|
32
|
+
return automations.rows.map(row => row.doc);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
27
35
|
function queueRelevantRowAutomations(event, eventType) {
|
|
28
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
37
|
if (event.appId == null) {
|
|
30
38
|
throw `No appId specified for ${eventType} - check event emitters.`;
|
|
31
39
|
}
|
|
32
40
|
doInAppContext(event.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
|
|
34
|
-
let automations = yield db.allDocs(getAutomationParams(null, { include_docs: true }));
|
|
41
|
+
let automations = yield getAllAutomations();
|
|
35
42
|
// filter down to the correct event type
|
|
36
|
-
automations = automations.
|
|
37
|
-
.map(automation => automation.doc)
|
|
38
|
-
.filter(automation => {
|
|
43
|
+
automations = automations.filter(automation => {
|
|
39
44
|
const trigger = automation.definition.trigger;
|
|
40
45
|
return trigger && trigger.event === eventType;
|
|
41
46
|
});
|
|
@@ -109,4 +114,33 @@ exports.externalTrigger = function (automation, params, { getResponses } = {}) {
|
|
|
109
114
|
}
|
|
110
115
|
});
|
|
111
116
|
};
|
|
117
|
+
exports.rebootTrigger = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
// reboot cron option is only available on the main thread at
|
|
119
|
+
// startup and only usable in self host
|
|
120
|
+
if (env.isInThread() || !env.SELF_HOSTED) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// iterate through all production apps, find the reboot crons
|
|
124
|
+
// and trigger events for them
|
|
125
|
+
const appIds = yield getAllApps({ dev: false, idsOnly: true });
|
|
126
|
+
for (let prodAppId of appIds) {
|
|
127
|
+
yield doInAppContext(prodAppId, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
let automations = yield getAllAutomations();
|
|
129
|
+
let rebootEvents = [];
|
|
130
|
+
for (let automation of automations) {
|
|
131
|
+
if (utils.isRebootTrigger(automation)) {
|
|
132
|
+
const job = {
|
|
133
|
+
automation,
|
|
134
|
+
event: {
|
|
135
|
+
appId: prodAppId,
|
|
136
|
+
timestamp: Date.now(),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
rebootEvents.push(queue.add(job, JOB_OPTS));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
yield Promise.all(rebootEvents);
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
112
146
|
exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS;
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.isErrorInOutput = exports.isRecurring = exports.cleanupAutomations = exports.checkForWebhooks = exports.enableCronTrigger = exports.clearMetadata = exports.disableCron = exports.disableAllCrons = exports.removeDeprecated = exports.updateTestHistory = exports.processEvent = void 0;
|
|
38
|
+
exports.isErrorInOutput = exports.isRecurring = exports.cleanupAutomations = exports.checkForWebhooks = exports.enableCronTrigger = exports.isRebootTrigger = exports.isCronTrigger = exports.clearMetadata = exports.disableCron = exports.disableAllCrons = exports.removeDeprecated = exports.updateTestHistory = exports.processEvent = void 0;
|
|
39
39
|
const threads_1 = require("../threads");
|
|
40
40
|
const triggerInfo_1 = require("./triggerInfo");
|
|
41
41
|
const webhooks = __importStar(require("../api/controllers/webhook"));
|
|
@@ -49,6 +49,7 @@ const fp_1 = require("lodash/fp");
|
|
|
49
49
|
const context_1 = require("@budibase/backend-core/context");
|
|
50
50
|
const backend_core_1 = require("@budibase/backend-core");
|
|
51
51
|
const pro_1 = require("@budibase/pro");
|
|
52
|
+
const REBOOT_CRON = "@reboot";
|
|
52
53
|
const WH_STEP_ID = triggerInfo_1.definitions.WEBHOOK.stepId;
|
|
53
54
|
const CRON_STEP_ID = triggerInfo_1.definitions.CRON.stepId;
|
|
54
55
|
const Runner = new threads_1.Thread(threads_1.ThreadType.AUTOMATION);
|
|
@@ -139,6 +140,17 @@ function clearMetadata() {
|
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
exports.clearMetadata = clearMetadata;
|
|
143
|
+
function isCronTrigger(auto) {
|
|
144
|
+
return (auto &&
|
|
145
|
+
auto.definition.trigger &&
|
|
146
|
+
auto.definition.trigger.stepId === CRON_STEP_ID);
|
|
147
|
+
}
|
|
148
|
+
exports.isCronTrigger = isCronTrigger;
|
|
149
|
+
function isRebootTrigger(auto) {
|
|
150
|
+
const trigger = auto ? auto.definition.trigger : null;
|
|
151
|
+
return isCronTrigger(auto) && (trigger === null || trigger === void 0 ? void 0 : trigger.inputs.cron) === REBOOT_CRON;
|
|
152
|
+
}
|
|
153
|
+
exports.isRebootTrigger = isRebootTrigger;
|
|
142
154
|
/**
|
|
143
155
|
* This function handles checking of any cron jobs that need to be enabled/updated.
|
|
144
156
|
* @param {string} appId The ID of the app in which we are checking for webhooks
|
|
@@ -147,13 +159,10 @@ exports.clearMetadata = clearMetadata;
|
|
|
147
159
|
function enableCronTrigger(appId, automation) {
|
|
148
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
161
|
const trigger = automation ? automation.definition.trigger : null;
|
|
150
|
-
function isCronTrigger(auto) {
|
|
151
|
-
return (auto &&
|
|
152
|
-
auto.definition.trigger &&
|
|
153
|
-
auto.definition.trigger.stepId === CRON_STEP_ID);
|
|
154
|
-
}
|
|
155
162
|
// need to create cron job
|
|
156
|
-
if (isCronTrigger(automation) &&
|
|
163
|
+
if (isCronTrigger(automation) &&
|
|
164
|
+
!isRebootTrigger(automation) &&
|
|
165
|
+
(trigger === null || trigger === void 0 ? void 0 : trigger.inputs.cron)) {
|
|
157
166
|
// make a job id rather than letting Bull decide, makes it easier to handle on way out
|
|
158
167
|
const jobId = `${appId}_cron_${(0, newid_1.default)()}`;
|
|
159
168
|
const job = yield bullboard_1.queue.add({
|
package/dist/db/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ const AppStatus = {
|
|
|
7
7
|
ALL: "all",
|
|
8
8
|
DEPLOYED: "published",
|
|
9
9
|
};
|
|
10
|
-
const DocumentType = Object.assign(Object.assign({}, CoreDocTypes), { TABLE: "ta", ROW: "ro", USER: "us", AUTOMATION: "au", LINK: "li", WEBHOOK: "wh", INSTANCE: "inst", LAYOUT: "layout", SCREEN: "screen", DATASOURCE: "datasource", DATASOURCE_PLUS: "datasource_plus", QUERY: "query", DEPLOYMENTS: "deployments", METADATA: "metadata", MEM_VIEW: "view", USER_FLAG: "flag", AUTOMATION_METADATA: "meta_au"
|
|
10
|
+
const DocumentType = Object.assign(Object.assign({}, CoreDocTypes), { TABLE: "ta", ROW: "ro", USER: "us", AUTOMATION: "au", LINK: "li", WEBHOOK: "wh", INSTANCE: "inst", LAYOUT: "layout", SCREEN: "screen", DATASOURCE: "datasource", DATASOURCE_PLUS: "datasource_plus", QUERY: "query", DEPLOYMENTS: "deployments", METADATA: "metadata", MEM_VIEW: "view", USER_FLAG: "flag", AUTOMATION_METADATA: "meta_au" });
|
|
11
11
|
const InternalTables = {
|
|
12
12
|
USER_METADATA: "ta_users",
|
|
13
13
|
};
|
|
@@ -274,9 +274,6 @@ exports.generateMemoryViewID = viewName => {
|
|
|
274
274
|
exports.getMemoryViewParams = (otherProps = {}) => {
|
|
275
275
|
return getDocParams(DocumentType.MEM_VIEW, null, otherProps);
|
|
276
276
|
};
|
|
277
|
-
exports.generatePluginID = name => {
|
|
278
|
-
return `${DocumentType.PLUGIN}${SEPARATOR}${name}`;
|
|
279
|
-
};
|
|
280
277
|
/**
|
|
281
278
|
* This can be used with the db.allDocs to get a list of IDs
|
|
282
279
|
*/
|
|
@@ -286,9 +283,3 @@ exports.getMultiIDParams = ids => {
|
|
|
286
283
|
include_docs: true,
|
|
287
284
|
};
|
|
288
285
|
};
|
|
289
|
-
/**
|
|
290
|
-
* Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
|
|
291
|
-
*/
|
|
292
|
-
exports.getPluginParams = (pluginId = null, otherProps = {}) => {
|
|
293
|
-
return getDocParams(DocumentType.PLUGIN, pluginId, otherProps);
|
|
294
|
-
};
|
package/dist/environment.js
CHANGED
|
@@ -64,7 +64,6 @@ module.exports = {
|
|
|
64
64
|
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
65
65
|
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
|
|
66
66
|
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
|
|
67
|
-
PLUGINS_DIR: process.env.PLUGINS_DIR || "/plugins",
|
|
68
67
|
// flags
|
|
69
68
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
70
69
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|