@budibase/server 1.0.78 → 1.0.79-alpha.10
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__/node-fetch.ts +1 -0
- package/builder/assets/index.1a081633.js +1288 -0
- package/builder/assets/{index.c8d1e8f0.css → index.c57242d4.css} +2 -2
- package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2399 -2336
- package/coverage/coverage-final.json +138 -137
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +152 -149
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +16 -16
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +27 -27
- package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
- package/coverage/lcov-report/api/controllers/row/internal.js.html +94 -82
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +11 -11
- package/coverage/lcov-report/api/controllers/table/index.js.html +47 -44
- package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
- package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +18 -27
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +37 -28
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +19 -109
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +18 -156
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +35 -35
- package/coverage/lcov-report/api/routes/index.js.html +38 -32
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +16 -58
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +15 -78
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +17 -14
- package/coverage/lcov-report/api/routes/screen.js.html +14 -95
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +17 -62
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +111 -0
- package/coverage/lcov-report/api/routes/utils/validators.js.html +737 -0
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +14 -62
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +12 -9
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +26 -26
- package/coverage/lcov-report/automations/utils.js.html +35 -35
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +40 -28
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +123 -87
- 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 +8 -8
- package/coverage/lcov-report/events/utils.js.html +18 -18
- package/coverage/lcov-report/index.html +89 -74
- 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 +5 -5
- package/coverage/lcov-report/middleware/authorized.js.html +29 -29
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +19 -19
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +123 -39
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +18 -18
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- 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 +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- 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/index.js.html +12 -12
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +200 -53
- package/coverage/lcov.info +3323 -3224
- package/dist/api/controllers/application.js +1 -0
- package/dist/api/controllers/public/applications.js +94 -0
- package/dist/api/controllers/public/mapping/applications.js +29 -0
- package/dist/api/controllers/public/mapping/index.js +11 -0
- package/dist/api/controllers/public/mapping/queries.js +36 -0
- package/dist/api/controllers/public/mapping/rows.js +24 -0
- package/dist/api/controllers/public/mapping/tables.js +23 -0
- package/dist/api/controllers/public/mapping/types.js +2 -0
- package/dist/api/controllers/public/mapping/users.js +29 -0
- package/dist/api/controllers/public/queries.js +38 -0
- package/dist/api/controllers/public/rows.js +97 -0
- package/dist/api/controllers/public/tables.js +75 -0
- package/dist/api/controllers/public/users.js +95 -0
- package/dist/api/controllers/public/utils.js +49 -0
- package/dist/api/controllers/row/internal.js +4 -1
- package/dist/api/controllers/table/index.js +2 -1
- package/dist/api/controllers/webhook.js +3 -5
- package/dist/api/index.js +3 -1
- package/dist/api/routes/automation.js +3 -31
- package/dist/api/routes/datasource.js +3 -50
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/permission.js +4 -14
- package/dist/api/routes/public/applications.js +141 -0
- package/dist/api/routes/public/index.js +68 -0
- package/dist/api/routes/public/middleware/mapper.js +94 -0
- package/dist/api/routes/public/queries.js +77 -0
- package/dist/api/routes/public/rows.js +229 -0
- package/dist/api/routes/public/tables.js +154 -0
- package/dist/api/routes/public/users.js +137 -0
- package/dist/api/routes/public/utils/Endpoint.js +36 -0
- package/dist/api/routes/role.js +3 -19
- package/dist/api/routes/row.js +3 -4
- package/dist/api/routes/screen.js +2 -23
- package/dist/api/routes/table.js +3 -17
- package/dist/api/routes/tests/utilities/index.js +23 -0
- package/dist/api/routes/utils/validators.js +200 -0
- package/dist/api/routes/webhook.js +2 -17
- package/dist/automations/steps/filter.js +2 -2
- package/dist/automations/steps/queryRows.js +1 -1
- package/dist/automations/utils.js +2 -2
- package/dist/constants/index.js +3 -0
- package/dist/db/utils.js +11 -0
- package/dist/definitions/openapi.js +6 -0
- package/dist/integrations/googlesheets.js +3 -0
- package/dist/integrations/microsoftSqlServer.js +35 -29
- package/dist/integrations/mysql.js +30 -26
- package/dist/integrations/oracle.js +14 -19
- package/dist/integrations/postgres.js +34 -28
- package/dist/package.json +8 -7
- package/dist/tests/utilities/TestConfiguration.js +25 -8
- package/dist/threads/query.js +33 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +50 -15
- package/package.json +9 -8
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +5 -3
- package/scripts/likeCypress.ts +9 -6
- package/specs/generate.js +83 -0
- package/specs/openapi.json +2222 -0
- package/specs/openapi.yaml +1530 -0
- package/specs/parameters.js +59 -0
- package/specs/resources/application.js +101 -0
- package/specs/resources/index.js +24 -0
- package/specs/resources/misc.js +12 -0
- package/specs/resources/query.js +189 -0
- package/specs/resources/row.js +125 -0
- package/specs/resources/table.js +191 -0
- package/specs/resources/user.js +126 -0
- package/specs/resources/utils/Resource.js +26 -0
- package/specs/resources/utils/index.js +11 -0
- package/specs/security.js +7 -0
- package/src/api/controllers/application.js +1 -0
- package/src/api/controllers/public/applications.ts +74 -0
- package/src/api/controllers/public/mapping/applications.ts +32 -0
- package/src/api/controllers/public/mapping/index.ts +13 -0
- package/src/api/controllers/public/mapping/queries.ts +39 -0
- package/src/api/controllers/public/mapping/rows.ts +31 -0
- package/src/api/controllers/public/mapping/tables.ts +26 -0
- package/src/api/controllers/public/mapping/types.ts +13 -0
- package/src/api/controllers/public/mapping/users.ts +32 -0
- package/src/api/controllers/public/queries.ts +20 -0
- package/src/api/controllers/public/rows.ts +77 -0
- package/src/api/controllers/public/tables.ts +56 -0
- package/src/api/controllers/public/users.ts +82 -0
- package/src/api/controllers/public/utils.ts +38 -0
- package/src/api/controllers/row/internal.js +4 -0
- package/src/api/controllers/table/index.js +2 -1
- package/src/api/controllers/webhook.js +3 -6
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +3 -33
- package/src/api/routes/datasource.js +6 -52
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/permission.js +4 -18
- package/src/api/routes/public/applications.ts +156 -0
- package/src/api/routes/public/index.ts +82 -0
- package/src/api/routes/public/middleware/mapper.ts +81 -0
- package/src/api/routes/public/queries.ts +81 -0
- package/src/api/routes/public/rows.ts +242 -0
- package/src/api/routes/public/tables.ts +169 -0
- package/src/api/routes/public/tests/compare.spec.js +184 -0
- package/src/api/routes/public/users.ts +144 -0
- package/src/api/routes/public/utils/Endpoint.ts +51 -0
- package/src/api/routes/role.js +3 -24
- package/src/api/routes/row.js +3 -2
- package/src/api/routes/screen.js +2 -29
- package/src/api/routes/table.js +4 -19
- package/src/api/routes/tests/utilities/index.js +24 -0
- package/src/api/routes/utils/validators.js +219 -0
- package/src/api/routes/webhook.js +2 -18
- package/src/automations/steps/filter.js +3 -2
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +4 -0
- package/src/db/utils.js +12 -0
- package/src/definitions/common.ts +4 -0
- package/src/definitions/openapi.ts +943 -0
- package/src/integrations/base/datasourcePlus.ts +3 -0
- package/src/integrations/googlesheets.ts +5 -2
- package/src/integrations/microsoftSqlServer.ts +38 -33
- package/src/integrations/mysql.ts +38 -36
- package/src/integrations/oracle.ts +27 -35
- package/src/integrations/postgres.ts +33 -26
- package/src/tests/utilities/TestConfiguration.js +23 -2
- package/src/threads/query.js +37 -9
- package/src/utilities/workerRequests.js +65 -16
- package/builder/assets/index.ab059cf2.js +0 -1352
- package/scripts/proxy/generateProxyConfig.js +0 -70
|
@@ -220,6 +220,7 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
220
220
|
tenantId: getTenantId(),
|
|
221
221
|
updatedAt: new Date().toISOString(),
|
|
222
222
|
createdAt: new Date().toISOString(),
|
|
223
|
+
status: AppStatus.DEV,
|
|
223
224
|
};
|
|
224
225
|
const response = yield db.put(newApplication, { force: true });
|
|
225
226
|
newApplication._rev = response.rev;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.destroy = exports.update = exports.read = exports.create = exports.search = void 0;
|
|
16
|
+
const { getAllApps } = require("@budibase/backend-core/db");
|
|
17
|
+
const { updateAppId } = require("@budibase/backend-core/context");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
const application_1 = __importDefault(require("../application"));
|
|
20
|
+
function fixAppID(app, params) {
|
|
21
|
+
if (!params) {
|
|
22
|
+
return app;
|
|
23
|
+
}
|
|
24
|
+
if (!app._id && params.appId) {
|
|
25
|
+
app._id = params.appId;
|
|
26
|
+
}
|
|
27
|
+
return app;
|
|
28
|
+
}
|
|
29
|
+
function setResponseApp(ctx) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (ctx.body && ctx.body.appId && (!ctx.params || !ctx.params.appId)) {
|
|
32
|
+
ctx.params = { appId: ctx.body.appId };
|
|
33
|
+
}
|
|
34
|
+
yield application_1.default.fetchAppPackage(ctx);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function search(ctx, next) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { name } = ctx.request.body;
|
|
40
|
+
const apps = yield getAllApps({ all: true });
|
|
41
|
+
ctx.body = utils_1.search(apps, name);
|
|
42
|
+
yield next();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.search = search;
|
|
46
|
+
function create(ctx, next) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
if (!ctx.request.body || !ctx.request.body.useTemplate) {
|
|
49
|
+
ctx.request.body = Object.assign({ useTemplate: false }, ctx.request.body);
|
|
50
|
+
}
|
|
51
|
+
yield application_1.default.create(ctx);
|
|
52
|
+
yield setResponseApp(ctx);
|
|
53
|
+
yield next();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.create = create;
|
|
57
|
+
function read(ctx, next) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
updateAppId(ctx.params.appId);
|
|
60
|
+
yield setResponseApp(ctx);
|
|
61
|
+
yield next();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.read = read;
|
|
65
|
+
function update(ctx, next) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
ctx.request.body = fixAppID(ctx.request.body, ctx.params);
|
|
68
|
+
updateAppId(ctx.params.appId);
|
|
69
|
+
yield application_1.default.update(ctx);
|
|
70
|
+
yield setResponseApp(ctx);
|
|
71
|
+
yield next();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.update = update;
|
|
75
|
+
function destroy(ctx, next) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
updateAppId(ctx.params.appId);
|
|
78
|
+
// get the app before deleting it
|
|
79
|
+
yield setResponseApp(ctx);
|
|
80
|
+
const body = ctx.body;
|
|
81
|
+
yield application_1.default.delete(ctx);
|
|
82
|
+
// overwrite the body again
|
|
83
|
+
ctx.body = body;
|
|
84
|
+
yield next();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.destroy = destroy;
|
|
88
|
+
exports.default = {
|
|
89
|
+
create,
|
|
90
|
+
update,
|
|
91
|
+
read,
|
|
92
|
+
destroy,
|
|
93
|
+
search,
|
|
94
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function application(body) {
|
|
4
|
+
let app = (body === null || body === void 0 ? void 0 : body.application) ? body.application : body;
|
|
5
|
+
return {
|
|
6
|
+
_id: app.appId,
|
|
7
|
+
name: app.name,
|
|
8
|
+
url: app.url,
|
|
9
|
+
status: app.status,
|
|
10
|
+
createdAt: app.createdAt,
|
|
11
|
+
updatedAt: app.updatedAt,
|
|
12
|
+
version: app.version,
|
|
13
|
+
tenantId: app.tenantId,
|
|
14
|
+
lockedBy: app.lockedBy,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function mapApplication(ctx) {
|
|
18
|
+
return {
|
|
19
|
+
data: application(ctx.body),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function mapApplications(ctx) {
|
|
23
|
+
const apps = ctx.body.map((body) => application(body));
|
|
24
|
+
return { data: apps };
|
|
25
|
+
}
|
|
26
|
+
exports.default = {
|
|
27
|
+
mapApplication,
|
|
28
|
+
mapApplications,
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tables_1 = __importDefault(require("./tables"));
|
|
7
|
+
const applications_1 = __importDefault(require("./applications"));
|
|
8
|
+
const users_1 = __importDefault(require("./users"));
|
|
9
|
+
const rows_1 = __importDefault(require("./rows"));
|
|
10
|
+
const queries_1 = __importDefault(require("./queries"));
|
|
11
|
+
exports.default = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, tables_1.default), applications_1.default), users_1.default), rows_1.default), queries_1.default);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function query(body) {
|
|
4
|
+
return {
|
|
5
|
+
_id: body._id,
|
|
6
|
+
datasourceId: body.datasourceId,
|
|
7
|
+
parameters: body.parameters,
|
|
8
|
+
fields: body.fields,
|
|
9
|
+
queryVerb: body.queryVerb,
|
|
10
|
+
name: body.name,
|
|
11
|
+
schema: body.schema,
|
|
12
|
+
transformer: body.transformer,
|
|
13
|
+
readable: body.readable,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function mapQueries(ctx) {
|
|
17
|
+
const queries = ctx.body.map((body) => query(body));
|
|
18
|
+
return {
|
|
19
|
+
data: queries,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function mapQueryExecution(ctx) {
|
|
23
|
+
// very little we can map here, structure mostly unknown
|
|
24
|
+
return {
|
|
25
|
+
data: ctx.body.data,
|
|
26
|
+
pagination: ctx.body.pagination,
|
|
27
|
+
extra: {
|
|
28
|
+
raw: ctx.body.raw,
|
|
29
|
+
headers: ctx.body.headers,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.default = {
|
|
34
|
+
mapQueries,
|
|
35
|
+
mapQueryExecution,
|
|
36
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function row(body) {
|
|
4
|
+
delete body._rev;
|
|
5
|
+
// have to input everything, since structure unknown
|
|
6
|
+
return Object.assign(Object.assign({}, body), { _id: body._id, tableId: body.tableId });
|
|
7
|
+
}
|
|
8
|
+
function mapRowSearch(ctx) {
|
|
9
|
+
const rows = ctx.body.rows.map((body) => row(body));
|
|
10
|
+
return {
|
|
11
|
+
data: rows,
|
|
12
|
+
hasNextPage: ctx.body.hasNextPage,
|
|
13
|
+
bookmark: ctx.body.bookmark,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function mapRow(ctx) {
|
|
17
|
+
return {
|
|
18
|
+
data: row(ctx.body),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.default = {
|
|
22
|
+
mapRowSearch,
|
|
23
|
+
mapRow,
|
|
24
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function table(body) {
|
|
4
|
+
return {
|
|
5
|
+
_id: body._id,
|
|
6
|
+
name: body.name,
|
|
7
|
+
schema: body.schema,
|
|
8
|
+
primaryDisplay: body.primaryDisplay,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function mapTable(ctx) {
|
|
12
|
+
return {
|
|
13
|
+
data: table(ctx.body),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function mapTables(ctx) {
|
|
17
|
+
const tables = ctx.body.map((body) => table(body));
|
|
18
|
+
return { data: tables };
|
|
19
|
+
}
|
|
20
|
+
exports.default = {
|
|
21
|
+
mapTable,
|
|
22
|
+
mapTables,
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function user(body) {
|
|
4
|
+
return {
|
|
5
|
+
_id: body._id,
|
|
6
|
+
email: body.email,
|
|
7
|
+
password: body.password,
|
|
8
|
+
status: body.status,
|
|
9
|
+
firstName: body.firstName,
|
|
10
|
+
lastName: body.lastName,
|
|
11
|
+
forceResetPassword: body.forceResetPassword,
|
|
12
|
+
builder: body.builder,
|
|
13
|
+
admin: body.admin,
|
|
14
|
+
roles: body.roles,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function mapUser(ctx) {
|
|
18
|
+
return {
|
|
19
|
+
data: user(ctx.body),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function mapUsers(ctx) {
|
|
23
|
+
const users = ctx.body.map((body) => user(body));
|
|
24
|
+
return { data: users };
|
|
25
|
+
}
|
|
26
|
+
exports.default = {
|
|
27
|
+
mapUser,
|
|
28
|
+
mapUsers,
|
|
29
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.execute = exports.search = void 0;
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const query_1 = __importDefault(require("../query"));
|
|
18
|
+
function search(ctx, next) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield query_1.default.fetch(ctx);
|
|
21
|
+
const { name } = ctx.request.body;
|
|
22
|
+
ctx.body = utils_1.search(ctx.body, name);
|
|
23
|
+
yield next();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.search = search;
|
|
27
|
+
function execute(ctx, next) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
// don't wrap this, already returns "data"
|
|
30
|
+
yield query_1.default.executeV2(ctx);
|
|
31
|
+
yield next();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.execute = execute;
|
|
35
|
+
exports.default = {
|
|
36
|
+
search,
|
|
37
|
+
execute,
|
|
38
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.destroy = exports.update = exports.read = exports.create = exports.search = void 0;
|
|
16
|
+
const row_1 = __importDefault(require("../row"));
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
|
|
19
|
+
// the call to be correct
|
|
20
|
+
function fixRow(row, params) {
|
|
21
|
+
if (!params || !row) {
|
|
22
|
+
return row;
|
|
23
|
+
}
|
|
24
|
+
if (params.rowId) {
|
|
25
|
+
row._id = params.rowId;
|
|
26
|
+
}
|
|
27
|
+
if (params.tableId) {
|
|
28
|
+
row.tableId = params.tableId;
|
|
29
|
+
}
|
|
30
|
+
if (!row.type) {
|
|
31
|
+
row.type = "row";
|
|
32
|
+
}
|
|
33
|
+
return row;
|
|
34
|
+
}
|
|
35
|
+
function search(ctx, next) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
let { sort, paginate, bookmark, limit, query } = ctx.request.body;
|
|
38
|
+
// update the body to the correct format of the internal search
|
|
39
|
+
if (!sort) {
|
|
40
|
+
sort = {};
|
|
41
|
+
}
|
|
42
|
+
ctx.request.body = {
|
|
43
|
+
sort: sort.column,
|
|
44
|
+
sortType: sort.type,
|
|
45
|
+
sortOrder: sort.order,
|
|
46
|
+
bookmark,
|
|
47
|
+
paginate,
|
|
48
|
+
limit,
|
|
49
|
+
query,
|
|
50
|
+
};
|
|
51
|
+
yield row_1.default.search(ctx);
|
|
52
|
+
yield next();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.search = search;
|
|
56
|
+
function create(ctx, next) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
ctx.request.body = fixRow(ctx.request.body, ctx.params);
|
|
59
|
+
yield row_1.default.save(ctx);
|
|
60
|
+
yield next();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.create = create;
|
|
64
|
+
function read(ctx, next) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
yield row_1.default.fetchEnrichedRow(ctx);
|
|
67
|
+
yield next();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.read = read;
|
|
71
|
+
function update(ctx, next) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
ctx.request.body = yield utils_1.addRev(fixRow(ctx.request.body, ctx.params.tableId));
|
|
74
|
+
yield row_1.default.save(ctx);
|
|
75
|
+
yield next();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.update = update;
|
|
79
|
+
function destroy(ctx, next) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
// set the body as expected, with the _id and _rev fields
|
|
82
|
+
ctx.request.body = yield utils_1.addRev(fixRow({ _id: ctx.params.rowId }, ctx.params.tableId));
|
|
83
|
+
yield row_1.default.destroy(ctx);
|
|
84
|
+
// destroy controller doesn't currently return the row as the body, need to adjust this
|
|
85
|
+
// in the public API to be correct
|
|
86
|
+
ctx.body = ctx.row;
|
|
87
|
+
yield next();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.destroy = destroy;
|
|
91
|
+
exports.default = {
|
|
92
|
+
create,
|
|
93
|
+
read,
|
|
94
|
+
update,
|
|
95
|
+
destroy,
|
|
96
|
+
search,
|
|
97
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.destroy = exports.update = exports.read = exports.create = exports.search = void 0;
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const table_1 = __importDefault(require("../table"));
|
|
18
|
+
function fixTable(table, params) {
|
|
19
|
+
if (!params || !table) {
|
|
20
|
+
return table;
|
|
21
|
+
}
|
|
22
|
+
if (params.tableId) {
|
|
23
|
+
table._id = params.tableId;
|
|
24
|
+
}
|
|
25
|
+
if (!table.type) {
|
|
26
|
+
table.type = "table";
|
|
27
|
+
}
|
|
28
|
+
return table;
|
|
29
|
+
}
|
|
30
|
+
function search(ctx, next) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { name } = ctx.request.body;
|
|
33
|
+
yield table_1.default.fetch(ctx);
|
|
34
|
+
ctx.body = utils_1.search(ctx.body, name);
|
|
35
|
+
yield next();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.search = search;
|
|
39
|
+
function create(ctx, next) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
yield table_1.default.save(ctx);
|
|
42
|
+
yield next();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.create = create;
|
|
46
|
+
function read(ctx, next) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
yield table_1.default.find(ctx);
|
|
49
|
+
yield next();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.read = read;
|
|
53
|
+
function update(ctx, next) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
ctx.request.body = yield utils_1.addRev(fixTable(ctx.request.body, ctx.params), ctx.params.tableId);
|
|
56
|
+
yield table_1.default.save(ctx);
|
|
57
|
+
yield next();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.update = update;
|
|
61
|
+
function destroy(ctx, next) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield table_1.default.destroy(ctx);
|
|
64
|
+
ctx.body = ctx.table;
|
|
65
|
+
yield next();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.destroy = destroy;
|
|
69
|
+
exports.default = {
|
|
70
|
+
create,
|
|
71
|
+
read,
|
|
72
|
+
update,
|
|
73
|
+
destroy,
|
|
74
|
+
search,
|
|
75
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.destroy = exports.update = exports.read = exports.create = exports.search = void 0;
|
|
13
|
+
const workerRequests_1 = require("../../../utilities/workerRequests");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
const { getProdAppID } = require("@budibase/backend-core/db");
|
|
16
|
+
function fixUser(ctx) {
|
|
17
|
+
if (!ctx.request.body) {
|
|
18
|
+
return ctx;
|
|
19
|
+
}
|
|
20
|
+
if (!ctx.request.body._id && ctx.params.userId) {
|
|
21
|
+
ctx.request.body._id = ctx.params.userId;
|
|
22
|
+
}
|
|
23
|
+
if (!ctx.request.body.roles) {
|
|
24
|
+
ctx.request.body.roles = {};
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const newRoles = {};
|
|
28
|
+
for (let [appId, role] of Object.entries(ctx.request.body.roles)) {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
newRoles[getProdAppID(appId)] = role;
|
|
31
|
+
}
|
|
32
|
+
ctx.request.body.roles = newRoles;
|
|
33
|
+
}
|
|
34
|
+
return ctx;
|
|
35
|
+
}
|
|
36
|
+
function getUser(ctx, userId) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (userId) {
|
|
39
|
+
ctx.params = { userId };
|
|
40
|
+
}
|
|
41
|
+
else if (!((_a = ctx.params) === null || _a === void 0 ? void 0 : _a.userId)) {
|
|
42
|
+
throw "No user ID provided for getting";
|
|
43
|
+
}
|
|
44
|
+
return workerRequests_1.readGlobalUser(ctx);
|
|
45
|
+
}
|
|
46
|
+
function search(ctx, next) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const { name } = ctx.request.body;
|
|
49
|
+
const users = yield workerRequests_1.allGlobalUsers(ctx);
|
|
50
|
+
ctx.body = utils_1.search(users, name, "email");
|
|
51
|
+
yield next();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.search = search;
|
|
55
|
+
function create(ctx, next) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const response = yield workerRequests_1.saveGlobalUser(fixUser(ctx));
|
|
58
|
+
ctx.body = yield getUser(ctx, response._id);
|
|
59
|
+
yield next();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.create = create;
|
|
63
|
+
function read(ctx, next) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
ctx.body = yield workerRequests_1.readGlobalUser(ctx);
|
|
66
|
+
yield next();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
exports.read = read;
|
|
70
|
+
function update(ctx, next) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const user = yield workerRequests_1.readGlobalUser(ctx);
|
|
73
|
+
ctx.request.body = Object.assign(Object.assign({}, ctx.request.body), { _rev: user._rev });
|
|
74
|
+
const response = yield workerRequests_1.saveGlobalUser(fixUser(ctx));
|
|
75
|
+
ctx.body = yield getUser(ctx, response._id);
|
|
76
|
+
yield next();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.update = update;
|
|
80
|
+
function destroy(ctx, next) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const user = yield getUser(ctx);
|
|
83
|
+
yield workerRequests_1.deleteGlobalUser(ctx);
|
|
84
|
+
ctx.body = user;
|
|
85
|
+
yield next();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
exports.destroy = destroy;
|
|
89
|
+
exports.default = {
|
|
90
|
+
create,
|
|
91
|
+
read,
|
|
92
|
+
update,
|
|
93
|
+
destroy,
|
|
94
|
+
search,
|
|
95
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.search = exports.addRev = void 0;
|
|
13
|
+
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
|
+
const utils_1 = require("../../../integrations/utils");
|
|
15
|
+
function addRev(body, tableId) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (!body._id || (tableId && utils_1.isExternalTable(tableId))) {
|
|
18
|
+
return body;
|
|
19
|
+
}
|
|
20
|
+
const db = getAppDB();
|
|
21
|
+
const dbDoc = yield db.get(body._id);
|
|
22
|
+
body._rev = dbDoc._rev;
|
|
23
|
+
return body;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.addRev = addRev;
|
|
27
|
+
/**
|
|
28
|
+
* Performs a case insensitive search on the provided documents, using the
|
|
29
|
+
* provided key and value. This will be a string based search, using the
|
|
30
|
+
* startsWith function.
|
|
31
|
+
*/
|
|
32
|
+
function search(docs, value, key = "name") {
|
|
33
|
+
if (!value || typeof value !== "string") {
|
|
34
|
+
return docs;
|
|
35
|
+
}
|
|
36
|
+
value = value.toLowerCase();
|
|
37
|
+
const filtered = [];
|
|
38
|
+
for (let doc of docs) {
|
|
39
|
+
if (typeof doc[key] !== "string") {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const toTest = doc[key].toLowerCase();
|
|
43
|
+
if (toTest.startsWith(value)) {
|
|
44
|
+
filtered.push(doc);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return filtered;
|
|
48
|
+
}
|
|
49
|
+
exports.search = search;
|
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
const linkRows = require("../../../db/linkedRows");
|
|
23
|
-
const { generateRowID, getRowParams, DocumentTypes, InternalTables, } = require("../../../db/utils");
|
|
23
|
+
const { generateRowID, getRowParams, getTableIDFromRowID, DocumentTypes, InternalTables, } = require("../../../db/utils");
|
|
24
24
|
const userController = require("../user");
|
|
25
25
|
const { inputProcessing, outputProcessing, cleanupAttachments, } = require("../../../utilities/rowProcessor");
|
|
26
26
|
const { FieldTypes } = require("../../../constants");
|
|
@@ -358,6 +358,9 @@ exports.fetchEnrichedRow = (ctx) => __awaiter(void 0, void 0, void 0, function*
|
|
|
358
358
|
// group responses by table
|
|
359
359
|
let groups = {}, tables = {};
|
|
360
360
|
for (let row of response) {
|
|
361
|
+
if (!row.tableId) {
|
|
362
|
+
row.tableId = getTableIDFromRowID(row._id);
|
|
363
|
+
}
|
|
361
364
|
const linkedTableId = row.tableId;
|
|
362
365
|
if (groups[linkedTableId] == null) {
|
|
363
366
|
groups[linkedTableId] = [row];
|
|
@@ -49,7 +49,7 @@ exports.fetch = function (ctx) {
|
|
|
49
49
|
};
|
|
50
50
|
exports.find = function (ctx) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const tableId = ctx.params.
|
|
52
|
+
const tableId = ctx.params.tableId;
|
|
53
53
|
ctx.body = yield getTable(tableId);
|
|
54
54
|
});
|
|
55
55
|
};
|
|
@@ -73,6 +73,7 @@ exports.destroy = function (ctx) {
|
|
|
73
73
|
ctx.eventEmitter &&
|
|
74
74
|
ctx.eventEmitter.emitTable(`table:delete`, appId, deletedTable);
|
|
75
75
|
ctx.status = 200;
|
|
76
|
+
ctx.table = deletedTable;
|
|
76
77
|
ctx.body = { message: `Table ${tableId} deleted.` };
|
|
77
78
|
});
|
|
78
79
|
};
|