@budibase/server 1.3.21 → 1.3.22-alpha.1
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.96c69636.js +1008 -0
- package/builder/assets/index.c167b5c3.css +6 -0
- package/builder/index.html +2 -4
- package/coverage/clover.xml +308 -338
- package/coverage/coverage-final.json +19 -21
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +41 -8
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +73 -34
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +27 -57
- 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 +2 -2
- 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/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 +13 -13
- 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 +2 -2
- 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 +9 -9
- package/coverage/lcov-report/api/routes/utils/validators.js.html +75 -12
- 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 +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- 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 +1 -1
- 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 +14 -14
- 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 +30 -18
- package/coverage/lcov-report/events/AutomationEmitter.js.html +3 -3
- 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 +44 -44
- 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 +46 -40
- package/coverage/lcov-report/middleware/index.html +15 -15
- 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 +15 -15
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- 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 +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- 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 +1 -1
- 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 +32 -8
- package/coverage/lcov.info +521 -558
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +9 -0
- package/dist/api/controllers/component.js +19 -6
- package/dist/api/controllers/datasource.js +21 -8
- package/dist/api/controllers/deploy/index.js +1 -8
- package/dist/api/controllers/integration.js +4 -4
- package/dist/{migrations/functions/usageQuotas/syncDevelopers.js → api/controllers/plugin/file.js} +13 -13
- package/dist/api/controllers/plugin/github.js +69 -0
- package/dist/api/controllers/plugin/index.js +144 -0
- package/dist/api/controllers/plugin/npm.js +58 -0
- package/dist/api/controllers/plugin/uploaders.js +11 -0
- package/dist/{migrations/functions/usageQuotas/syncPublishedApps.js → api/controllers/plugin/url.js} +13 -15
- package/dist/api/controllers/plugin/utils.js +26 -0
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +62 -14
- package/dist/api/controllers/static/index.js +1 -0
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/dist/api/controllers/static/templates/preview.hbs +5 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +3 -2
- package/dist/api/routes/index.js +2 -0
- package/dist/{migrations/functions/publishedAppsQuota.js → api/routes/plugin.js} +13 -21
- package/dist/api/routes/public/rows.js +1 -82
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +20 -2
- package/dist/app.js +16 -1
- package/dist/db/utils.js +3 -0
- package/dist/environment.js +1 -0
- package/dist/integrations/airtable.js +126 -129
- package/dist/integrations/arangodb.js +86 -89
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +3 -1
- package/dist/integrations/couchdb.js +80 -83
- package/dist/integrations/dynamodb.js +161 -164
- package/dist/integrations/elasticsearch.js +135 -138
- package/dist/integrations/firebase.js +154 -157
- package/dist/integrations/googlesheets.js +323 -327
- package/dist/integrations/index.js +99 -51
- package/dist/integrations/microsoftSqlServer.js +240 -243
- package/dist/integrations/mongodb.js +239 -242
- package/dist/integrations/mysql.js +215 -219
- package/dist/integrations/oracle.js +318 -322
- package/dist/integrations/postgres.js +262 -265
- package/dist/integrations/redis.js +134 -139
- package/dist/integrations/rest.js +289 -292
- package/dist/integrations/s3.js +61 -64
- package/dist/integrations/snowflake.js +83 -86
- package/dist/middleware/currentapp.js +2 -0
- package/dist/migrations/functions/backfill/global.js +0 -3
- package/dist/migrations/index.js +0 -10
- package/dist/package.json +9 -6
- package/dist/tests/utilities/TestConfiguration.js +1 -1
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +105 -1
- package/dist/utilities/workerRequests.js +4 -0
- package/dist/watch.js +77 -0
- package/dist/websocket.js +22 -0
- package/package.json +10 -7
- package/scripts/dev/manage.js +4 -0
- package/scripts/localdomain.js +3 -1
- package/specs/openapi.json +115 -112
- package/specs/openapi.yaml +96 -94
- package/specs/resources/misc.js +116 -0
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +1 -2
- package/src/api/controllers/auth.js +11 -0
- package/src/api/controllers/component.ts +57 -0
- package/src/api/controllers/datasource.js +21 -8
- package/src/api/controllers/deploy/index.ts +1 -6
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/plugin/file.ts +15 -0
- package/src/api/controllers/plugin/github.ts +75 -0
- package/src/api/controllers/plugin/index.ts +134 -0
- package/src/api/controllers/plugin/npm.ts +56 -0
- package/src/api/controllers/plugin/uploaders.ts +4 -0
- package/src/api/controllers/plugin/url.ts +12 -0
- package/src/api/controllers/plugin/utils.ts +19 -0
- package/src/api/controllers/public/mapping/types.ts +8 -0
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.ts +122 -0
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/src/api/controllers/static/templates/preview.hbs +5 -1
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +13 -2
- package/src/api/routes/index.ts +2 -0
- package/src/api/routes/plugin.ts +14 -0
- package/src/api/routes/public/rows.ts +1 -82
- package/src/api/routes/public/tables.ts +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/tests/query.spec.js +8 -25
- package/src/api/routes/tests/user.spec.js +0 -2
- package/src/api/routes/utils/validators.js +26 -5
- package/src/app.ts +25 -2
- package/src/db/utils.js +4 -0
- package/src/definitions/openapi.ts +56 -55
- package/src/environment.js +1 -0
- package/src/integrations/airtable.ts +116 -118
- package/src/integrations/arangodb.ts +87 -89
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +3 -1
- package/src/integrations/couchdb.ts +83 -89
- package/src/integrations/dynamodb.ts +173 -175
- package/src/integrations/elasticsearch.ts +120 -122
- package/src/integrations/firebase.ts +157 -159
- package/src/integrations/googlesheets.ts +328 -338
- package/src/integrations/index.ts +64 -21
- package/src/integrations/microsoftSqlServer.ts +249 -251
- package/src/integrations/mongodb.ts +261 -258
- package/src/integrations/mysql.ts +229 -234
- package/src/integrations/oracle.ts +373 -380
- package/src/integrations/postgres.ts +264 -268
- package/src/integrations/redis.ts +128 -132
- package/src/integrations/rest.ts +324 -329
- package/src/integrations/s3.ts +68 -71
- package/src/integrations/snowflake.ts +80 -82
- package/src/integrations/tests/{airtable.spec.js → airtable.spec.ts} +21 -18
- package/src/integrations/tests/{arangodb.spec.js → arangodb.spec.ts} +12 -9
- package/src/integrations/tests/{couchdb.spec.js → couchdb.spec.ts} +33 -27
- package/src/integrations/tests/{dynamodb.spec.js → dynamodb.spec.ts} +45 -41
- package/src/integrations/tests/{elasticsearch.spec.js → elasticsearch.spec.ts} +22 -21
- package/src/integrations/tests/{firebase.spec.js → firebase.spec.ts} +33 -28
- package/src/integrations/tests/{microsoftSqlServer.spec.js → microsoftSqlServer.spec.ts} +12 -11
- package/src/integrations/tests/{mongo.spec.js → mongo.spec.ts} +46 -35
- package/src/integrations/tests/{mysql.spec.js → mysql.spec.ts} +17 -15
- package/src/integrations/tests/{oracle.spec.js → oracle.spec.ts} +19 -17
- package/src/integrations/tests/{postgres.spec.js → postgres.spec.ts} +19 -17
- package/src/integrations/tests/{redis.spec.js → redis.spec.ts} +27 -18
- package/src/integrations/tests/{rest.spec.js → rest.spec.ts} +22 -14
- package/src/integrations/tests/{s3.spec.js → s3.spec.ts} +10 -8
- package/src/integrations/tests/{sql.spec.js → sql.spec.ts} +228 -177
- package/src/middleware/currentapp.js +2 -0
- package/src/migrations/functions/backfill/global.ts +0 -3
- package/src/migrations/index.ts +0 -16
- package/src/module.d.ts +2 -0
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +123 -0
- package/src/utilities/workerRequests.js +8 -0
- package/src/watch.ts +38 -0
- package/src/websocket.ts +26 -0
- package/builder/assets/index.8d12d461.css +0 -6
- package/builder/assets/index.d354271c.js +0 -879
- package/builder/assets/vendor.5e1fe644.css +0 -1
- package/builder/assets/vendor.67dbd8fa.js +0 -248
- package/coverage/lcov-report/api/controllers/component.js.html +0 -199
- package/coverage/lcov-report/api/controllers/screen.js.html +0 -259
- package/dist/migrations/functions/developerQuota.js +0 -49
- package/src/api/controllers/component.js +0 -38
- package/src/api/controllers/screen.js +0 -58
- package/src/migrations/functions/developerQuota.ts +0 -15
- package/src/migrations/functions/publishedAppsQuota.ts +0 -13
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +0 -19
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +0 -21
|
@@ -8,40 +8,88 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const utils_1 = require("../../db/utils");
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const application_1 = require("./application");
|
|
15
15
|
exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const db = getAppDB();
|
|
17
|
-
const screens = (yield db.allDocs(getScreenParams(null, {
|
|
16
|
+
const db = backend_core_1.context.getAppDB();
|
|
17
|
+
const screens = (yield db.allDocs((0, utils_1.getScreenParams)(null, {
|
|
18
18
|
include_docs: true,
|
|
19
|
-
}))).rows.map(
|
|
20
|
-
ctx.body = yield new AccessController().checkScreensAccess(screens, ctx.user.role._id);
|
|
19
|
+
}))).rows.map((el) => el.doc);
|
|
20
|
+
ctx.body = yield new backend_core_1.roles.AccessController().checkScreensAccess(screens, ctx.user.role._id);
|
|
21
21
|
});
|
|
22
22
|
exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const db = getAppDB();
|
|
23
|
+
const db = backend_core_1.context.getAppDB();
|
|
24
24
|
let screen = ctx.request.body;
|
|
25
25
|
let eventFn;
|
|
26
26
|
if (!screen._id) {
|
|
27
|
-
screen._id = generateScreenID();
|
|
28
|
-
eventFn = events.screen.created;
|
|
27
|
+
screen._id = (0, utils_1.generateScreenID)();
|
|
28
|
+
eventFn = backend_core_1.events.screen.created;
|
|
29
29
|
}
|
|
30
30
|
const response = yield db.put(screen);
|
|
31
|
+
// Find any custom components being used
|
|
32
|
+
let pluginNames = [];
|
|
33
|
+
let pluginAdded = false;
|
|
34
|
+
findPlugins(screen.props, pluginNames);
|
|
35
|
+
if (pluginNames.length) {
|
|
36
|
+
const globalDB = backend_core_1.tenancy.getGlobalDB();
|
|
37
|
+
const pluginsResponse = yield globalDB.allDocs(backend_core_1.db.getPluginParams(null, {
|
|
38
|
+
include_docs: true,
|
|
39
|
+
}));
|
|
40
|
+
const requiredPlugins = pluginsResponse.rows
|
|
41
|
+
.map((row) => row.doc)
|
|
42
|
+
.filter((plugin) => {
|
|
43
|
+
return (plugin.schema.type === "component" &&
|
|
44
|
+
pluginNames.includes(`plugin/${plugin.name}`));
|
|
45
|
+
});
|
|
46
|
+
// Update the app metadata
|
|
47
|
+
const application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
48
|
+
let usedPlugins = application.usedPlugins || [];
|
|
49
|
+
requiredPlugins.forEach((plugin) => {
|
|
50
|
+
if (!usedPlugins.find((x) => x._id === plugin._id)) {
|
|
51
|
+
pluginAdded = true;
|
|
52
|
+
usedPlugins.push({
|
|
53
|
+
_id: plugin._id,
|
|
54
|
+
name: plugin.name,
|
|
55
|
+
version: plugin.version,
|
|
56
|
+
jsUrl: plugin.jsUrl,
|
|
57
|
+
hash: plugin.hash,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (pluginAdded) {
|
|
62
|
+
yield (0, application_1.updateAppPackage)({ usedPlugins }, ctx.appId);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
31
65
|
if (eventFn) {
|
|
32
66
|
yield eventFn(screen);
|
|
33
67
|
}
|
|
34
68
|
ctx.message = `Screen ${screen.name} saved.`;
|
|
35
|
-
ctx.body = Object.assign(Object.assign({}, screen), { _id: response.id, _rev: response.rev });
|
|
69
|
+
ctx.body = Object.assign(Object.assign({}, screen), { _id: response.id, _rev: response.rev, pluginAdded });
|
|
36
70
|
});
|
|
37
71
|
exports.destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
const db = getAppDB();
|
|
72
|
+
const db = backend_core_1.context.getAppDB();
|
|
39
73
|
const id = ctx.params.screenId;
|
|
40
74
|
const screen = yield db.get(id);
|
|
41
75
|
yield db.remove(id, ctx.params.screenRev);
|
|
42
|
-
yield events.screen.deleted(screen);
|
|
76
|
+
yield backend_core_1.events.screen.deleted(screen);
|
|
43
77
|
ctx.body = {
|
|
44
78
|
message: "Screen deleted successfully",
|
|
45
79
|
};
|
|
46
80
|
ctx.status = 200;
|
|
47
81
|
});
|
|
82
|
+
const findPlugins = (component, foundPlugins) => {
|
|
83
|
+
if (!component) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (component._component.startsWith("plugin")) {
|
|
87
|
+
if (!foundPlugins.includes(component._component)) {
|
|
88
|
+
foundPlugins.push(component._component);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!component._children || !component._children.length) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
component._children.forEach(child => findPlugins(child, foundPlugins));
|
|
95
|
+
};
|
|
@@ -113,6 +113,7 @@ const serveApp = function (ctx) {
|
|
|
113
113
|
production: env.isProd(),
|
|
114
114
|
appId,
|
|
115
115
|
clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
|
|
116
|
+
usedPlugins: appInfo.usedPlugins,
|
|
116
117
|
});
|
|
117
118
|
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`);
|
|
118
119
|
ctx.body = yield processString(appHbs, {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export let favicon = ""
|
|
4
4
|
|
|
5
5
|
export let clientLibPath
|
|
6
|
+
export let usedPlugins
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
9
|
<svelte:head>
|
|
@@ -83,6 +84,15 @@
|
|
|
83
84
|
</script>
|
|
84
85
|
<script type="application/javascript" src={clientLibPath}>
|
|
85
86
|
</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}
|
|
86
96
|
<script type="application/javascript">
|
|
87
97
|
if (window.loadBudibase) {
|
|
88
98
|
window.loadBudibase()
|
|
@@ -66,7 +66,9 @@
|
|
|
66
66
|
customTheme,
|
|
67
67
|
previewDevice,
|
|
68
68
|
navigation,
|
|
69
|
-
hiddenComponentIds
|
|
69
|
+
hiddenComponentIds,
|
|
70
|
+
usedPlugins,
|
|
71
|
+
location
|
|
70
72
|
} = parsed
|
|
71
73
|
|
|
72
74
|
// Set some flags so the app knows we're in the builder
|
|
@@ -81,6 +83,8 @@
|
|
|
81
83
|
window["##BUDIBASE_PREVIEW_DEVICE##"] = previewDevice
|
|
82
84
|
window["##BUDIBASE_PREVIEW_NAVIGATION##"] = navigation
|
|
83
85
|
window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"] = hiddenComponentIds
|
|
86
|
+
window["##BUDIBASE_USED_PLUGINS##"] = usedPlugins
|
|
87
|
+
window["##BUDIBASE_LOCATION##"] = location
|
|
84
88
|
|
|
85
89
|
// Initialise app
|
|
86
90
|
try {
|
package/dist/api/index.js
CHANGED
|
@@ -51,8 +51,8 @@ router
|
|
|
51
51
|
.use(buildTenancyMiddleware(null, null, {
|
|
52
52
|
noTenancyRequired: true,
|
|
53
53
|
}))
|
|
54
|
-
.use(currentApp)
|
|
55
54
|
.use(pro.licensing())
|
|
55
|
+
.use(currentApp)
|
|
56
56
|
.use(auditLog);
|
|
57
57
|
// error handling middleware
|
|
58
58
|
router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -30,14 +30,15 @@ const router_1 = __importDefault(require("@koa/router"));
|
|
|
30
30
|
const controller = __importStar(require("../controllers/application"));
|
|
31
31
|
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
32
32
|
const permissions_1 = require("@budibase/backend-core/permissions");
|
|
33
|
+
const validators_1 = require("./utils/validators");
|
|
33
34
|
const router = new router_1.default();
|
|
34
35
|
router
|
|
35
36
|
.post("/api/applications/:appId/sync", (0, authorized_1.default)(permissions_1.BUILDER), controller.sync)
|
|
36
|
-
.post("/api/applications", (0, authorized_1.default)(permissions_1.BUILDER), controller.create)
|
|
37
|
+
.post("/api/applications", (0, authorized_1.default)(permissions_1.BUILDER), (0, validators_1.applicationValidator)(), controller.create)
|
|
37
38
|
.get("/api/applications/:appId/definition", controller.fetchAppDefinition)
|
|
38
39
|
.get("/api/applications", controller.fetch)
|
|
39
40
|
.get("/api/applications/:appId/appPackage", controller.fetchAppPackage)
|
|
40
|
-
.put("/api/applications/:appId", (0, authorized_1.default)(permissions_1.BUILDER), controller.update)
|
|
41
|
+
.put("/api/applications/:appId", (0, authorized_1.default)(permissions_1.BUILDER), (0, validators_1.applicationValidator)({ isCreate: false }), controller.update)
|
|
41
42
|
.post("/api/applications/:appId/client/update", (0, authorized_1.default)(permissions_1.BUILDER), controller.updateClient)
|
|
42
43
|
.post("/api/applications/:appId/client/revert", (0, authorized_1.default)(permissions_1.BUILDER), controller.revertClient)
|
|
43
44
|
.delete("/api/applications/:appId", (0, authorized_1.default)(permissions_1.BUILDER), controller.destroy);
|
package/dist/api/routes/index.js
CHANGED
|
@@ -30,6 +30,7 @@ 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"));
|
|
33
34
|
var static_1 = require("./static");
|
|
34
35
|
Object.defineProperty(exports, "staticRoutes", { enumerable: true, get: function () { return __importDefault(static_1).default; } });
|
|
35
36
|
var public_1 = require("./public");
|
|
@@ -63,4 +64,5 @@ exports.mainRoutes = [
|
|
|
63
64
|
table_1.default,
|
|
64
65
|
row_1.default,
|
|
65
66
|
migrations_1.default,
|
|
67
|
+
plugin_1.default,
|
|
66
68
|
];
|
|
@@ -22,26 +22,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
27
|
};
|
|
34
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
exports.run = run;
|
|
29
|
+
const router_1 = __importDefault(require("@koa/router"));
|
|
30
|
+
const controller = __importStar(require("../controllers/plugin"));
|
|
31
|
+
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
32
|
+
const permissions_1 = require("@budibase/backend-core/permissions");
|
|
33
|
+
const router = new router_1.default();
|
|
34
|
+
router
|
|
35
|
+
.post("/api/plugin/upload", (0, authorized_1.default)(permissions_1.BUILDER), controller.upload)
|
|
36
|
+
.post("/api/plugin", (0, authorized_1.default)(permissions_1.BUILDER), controller.create)
|
|
37
|
+
.get("/api/plugin", (0, authorized_1.default)(permissions_1.BUILDER), controller.fetch)
|
|
38
|
+
.delete("/api/plugin/:pluginId", (0, authorized_1.default)(permissions_1.BUILDER), controller.destroy);
|
|
39
|
+
exports.default = router;
|
|
@@ -137,88 +137,7 @@ read.push(new Endpoint_1.default("get", "/tables/:tableId/rows/:rowId", rows_1.d
|
|
|
137
137
|
* content:
|
|
138
138
|
* application/json:
|
|
139
139
|
* schema:
|
|
140
|
-
*
|
|
141
|
-
* required:
|
|
142
|
-
* - query
|
|
143
|
-
* properties:
|
|
144
|
-
* query:
|
|
145
|
-
* type: object
|
|
146
|
-
* properties:
|
|
147
|
-
* allOr:
|
|
148
|
-
* type: boolean
|
|
149
|
-
* description: Specifies that a row should be returned if it satisfies
|
|
150
|
-
* any of the specified options, rather than requiring it to fulfill all
|
|
151
|
-
* the search parameters. This defaults to false, meaning AND logic will be used.
|
|
152
|
-
* string:
|
|
153
|
-
* type: object
|
|
154
|
-
* example:
|
|
155
|
-
* columnName1: value
|
|
156
|
-
* columnName2: value
|
|
157
|
-
* description: A map of field name to the string to search for,
|
|
158
|
-
* this will look for rows that have a value starting with the
|
|
159
|
-
* string value.
|
|
160
|
-
* additionalProperties:
|
|
161
|
-
* type: string
|
|
162
|
-
* description: The value to search for in the column.
|
|
163
|
-
* fuzzy:
|
|
164
|
-
* type: object
|
|
165
|
-
* description: A fuzzy search, only supported by internal tables.
|
|
166
|
-
* range:
|
|
167
|
-
* type: object
|
|
168
|
-
* description: Searches within a range, the format of this must be
|
|
169
|
-
* in the format of an object with a "low" and "high" property.
|
|
170
|
-
* example:
|
|
171
|
-
* columnName1: { low: 10, high: 20 }
|
|
172
|
-
* equal:
|
|
173
|
-
* type: object
|
|
174
|
-
* description: Searches for rows that have a column value that is
|
|
175
|
-
* exactly the value set.
|
|
176
|
-
* notEqual:
|
|
177
|
-
* type: object
|
|
178
|
-
* description: Searches for any row which does not contain the specified
|
|
179
|
-
* column value.
|
|
180
|
-
* empty:
|
|
181
|
-
* type: object
|
|
182
|
-
* description: Searches for rows which do not contain the specified column.
|
|
183
|
-
* The object should simply contain keys of the column names, these
|
|
184
|
-
* can map to any value.
|
|
185
|
-
* example:
|
|
186
|
-
* columnName1: ""
|
|
187
|
-
* notEmpty:
|
|
188
|
-
* type: object
|
|
189
|
-
* description: Searches for rows which have the specified column.
|
|
190
|
-
* oneOf:
|
|
191
|
-
* type: object
|
|
192
|
-
* description: Searches for rows which have a column value that is any
|
|
193
|
-
* of the specified values. The format of this must be columnName -> [value1, value2].
|
|
194
|
-
* paginate:
|
|
195
|
-
* type: boolean
|
|
196
|
-
* description: Enables pagination, by default this is disabled.
|
|
197
|
-
* bookmark:
|
|
198
|
-
* oneOf:
|
|
199
|
-
* - type: string
|
|
200
|
-
* - type: integer
|
|
201
|
-
* description: If retrieving another page, the bookmark from the previous request must be supplied.
|
|
202
|
-
* limit:
|
|
203
|
-
* type: integer
|
|
204
|
-
* description: The maximum number of rows to return, useful when paginating, for internal tables this
|
|
205
|
-
* will be limited to 1000, for SQL tables it will be 5000.
|
|
206
|
-
* sort:
|
|
207
|
-
* type: object
|
|
208
|
-
* description: A set of parameters describing the sort behaviour of the search.
|
|
209
|
-
* properties:
|
|
210
|
-
* order:
|
|
211
|
-
* type: string
|
|
212
|
-
* enum: [ascending, descending]
|
|
213
|
-
* description: The order of the sort, by default this is ascending.
|
|
214
|
-
* column:
|
|
215
|
-
* type: string
|
|
216
|
-
* description: The name of the column by which the rows will be sorted.
|
|
217
|
-
* type:
|
|
218
|
-
* type: string
|
|
219
|
-
* enum: [string, number]
|
|
220
|
-
* description: Defines whether the column should be treated as a string
|
|
221
|
-
* or as numbers when sorting.
|
|
140
|
+
* $ref: '#/components/schemas/rowSearch'
|
|
222
141
|
* responses:
|
|
223
142
|
* 200:
|
|
224
143
|
* description: The response will contain an array of rows that match the search parameters.
|
|
@@ -28,7 +28,7 @@ const read = [], write = [];
|
|
|
28
28
|
* responses:
|
|
29
29
|
* 200:
|
|
30
30
|
* description: Returns the created table, including the ID which has been generated for it. This can be
|
|
31
|
-
* internal or external
|
|
31
|
+
* internal or external datasources.
|
|
32
32
|
* content:
|
|
33
33
|
* application/json:
|
|
34
34
|
* schema:
|
package/dist/api/routes/table.js
CHANGED
|
@@ -45,7 +45,7 @@ router
|
|
|
45
45
|
* @apiParam (Body) {string} [_rev] If updating an existing internal table then the revision must also be specified.
|
|
46
46
|
* @apiParam (Body) {string} type] This should either be "internal" or "external" depending on the table type -
|
|
47
47
|
* this will default to internal.
|
|
48
|
-
* @apiParam (Body) {string} [sourceId] If creating an external table then this should be set to the
|
|
48
|
+
* @apiParam (Body) {string} [sourceId] If creating an external table then this should be set to the datasource ID. If
|
|
49
49
|
* building an internal table this does not need to be set, although it will be returned as "bb_internal".
|
|
50
50
|
* @apiParam (Body) {string} name The name of the table, this will be used in the UI. To rename the table simply
|
|
51
51
|
* supply the table structure to this endpoint with the name changed.
|
|
@@ -7,6 +7,7 @@ const Joi = require("joi");
|
|
|
7
7
|
const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("");
|
|
8
8
|
const OPTIONAL_NUMBER = Joi.number().optional().allow(null);
|
|
9
9
|
const OPTIONAL_BOOLEAN = Joi.boolean().optional().allow(null);
|
|
10
|
+
const APP_NAME_REGEX = /^[\w\s]+$/;
|
|
10
11
|
exports.tableValidator = () => {
|
|
11
12
|
// prettier-ignore
|
|
12
13
|
return joiValidator.body(Joi.object({
|
|
@@ -190,12 +191,29 @@ exports.automationValidator = (existing = false) => {
|
|
|
190
191
|
}).required().unknown(true),
|
|
191
192
|
}).unknown(true));
|
|
192
193
|
};
|
|
193
|
-
exports.applicationValidator = () => {
|
|
194
|
+
exports.applicationValidator = (opts = { isCreate: true }) => {
|
|
194
195
|
// prettier-ignore
|
|
196
|
+
const base = {
|
|
197
|
+
_id: OPTIONAL_STRING,
|
|
198
|
+
_rev: OPTIONAL_STRING,
|
|
199
|
+
url: OPTIONAL_STRING,
|
|
200
|
+
template: Joi.object({
|
|
201
|
+
templateString: OPTIONAL_STRING,
|
|
202
|
+
})
|
|
203
|
+
};
|
|
204
|
+
const appNameValidator = Joi.string()
|
|
205
|
+
.pattern(new RegExp(APP_NAME_REGEX))
|
|
206
|
+
.error(new Error("App name must be letters, numbers and spaces only"));
|
|
207
|
+
if (opts.isCreate) {
|
|
208
|
+
base.name = appNameValidator.required();
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
base.name = appNameValidator.optional();
|
|
212
|
+
}
|
|
195
213
|
return joiValidator.body(Joi.object({
|
|
196
214
|
_id: OPTIONAL_STRING,
|
|
197
215
|
_rev: OPTIONAL_STRING,
|
|
198
|
-
name:
|
|
216
|
+
name: appNameValidator,
|
|
199
217
|
url: OPTIONAL_STRING,
|
|
200
218
|
template: Joi.object({
|
|
201
219
|
templateString: OPTIONAL_STRING,
|
package/dist/app.js
CHANGED
|
@@ -60,10 +60,13 @@ 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");
|
|
63
64
|
const redis_1 = __importDefault(require("./utilities/redis"));
|
|
64
65
|
const migrations = __importStar(require("./migrations"));
|
|
65
66
|
const backend_core_1 = require("@budibase/backend-core");
|
|
66
67
|
const workerRequests_1 = require("./utilities/workerRequests");
|
|
68
|
+
const watch_1 = require("./watch");
|
|
69
|
+
const websocket_1 = require("./websocket");
|
|
67
70
|
const app = new Koa();
|
|
68
71
|
// set up top level koa middleware
|
|
69
72
|
app.use(koaBody({
|
|
@@ -97,6 +100,7 @@ if (env.isProd()) {
|
|
|
97
100
|
}
|
|
98
101
|
const server = http.createServer(app.callback());
|
|
99
102
|
destroyable(server);
|
|
103
|
+
(0, websocket_1.initialise)(server);
|
|
100
104
|
let shuttingDown = false, errCode = 0;
|
|
101
105
|
server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
106
|
// already in process
|
|
@@ -141,7 +145,11 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
141
145
|
if (!((_a = checklist === null || checklist === void 0 ? void 0 : checklist.adminUser) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
142
146
|
try {
|
|
143
147
|
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
144
|
-
yield (0, workerRequests_1.createAdminUser)(env.BB_ADMIN_USER_EMAIL, env.BB_ADMIN_USER_PASSWORD, tenantId);
|
|
148
|
+
const user = yield (0, workerRequests_1.createAdminUser)(env.BB_ADMIN_USER_EMAIL, env.BB_ADMIN_USER_PASSWORD, tenantId);
|
|
149
|
+
// Need to set up an API key for automated integration tests
|
|
150
|
+
if (env.isTest()) {
|
|
151
|
+
yield (0, workerRequests_1.generateApiKey)(user._id);
|
|
152
|
+
}
|
|
145
153
|
console.log("Admin account automatically created for", env.BB_ADMIN_USER_EMAIL);
|
|
146
154
|
}
|
|
147
155
|
catch (e) {
|
|
@@ -150,6 +158,13 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
160
|
}
|
|
161
|
+
// monitor plugin directory if required
|
|
162
|
+
if (env.SELF_HOSTED &&
|
|
163
|
+
!env.MULTI_TENANCY &&
|
|
164
|
+
env.PLUGINS_DIR &&
|
|
165
|
+
fs.existsSync(env.PLUGINS_DIR)) {
|
|
166
|
+
(0, watch_1.watch)();
|
|
167
|
+
}
|
|
153
168
|
// check for version updates
|
|
154
169
|
yield backend_core_1.installation.checkInstallVersion();
|
|
155
170
|
// done last - this will never complete
|
package/dist/db/utils.js
CHANGED
|
@@ -274,6 +274,9 @@ 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
|
+
};
|
|
277
280
|
/**
|
|
278
281
|
* This can be used with the db.allDocs to get a list of IDs
|
|
279
282
|
*/
|
package/dist/environment.js
CHANGED
|
@@ -64,6 +64,7 @@ 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",
|
|
67
68
|
// flags
|
|
68
69
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
69
70
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|