@budibase/server 1.0.27-alpha.1 → 1.0.27-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 +18 -0
- package/builder/assets/{index.4a13c4cb.css → index.0dce895b.css} +1 -1
- package/builder/assets/index.39751e34.js +1348 -0
- package/builder/index.html +2 -2
- package/coverage/clover.xml +787 -637
- package/coverage/coverage-final.json +27 -27
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +54 -54
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +49 -49
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +20 -20
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- 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/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.js.html +100 -121
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -3
- 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 +22 -22
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +38 -11
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +7 -4
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -20
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.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/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.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 +5 -5
- 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/application.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/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.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/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +24 -3
- 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/row.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/static.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/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/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +31 -7
- 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 +11 -11
- package/coverage/lcov-report/automations/steps/integromat.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/automations/utils.js.html +5 -5
- 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/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- 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 +18 -18
- 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 +63 -63
- 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/authorized.js.html +10 -10
- package/coverage/lcov-report/middleware/builder.js.html +8 -8
- package/coverage/lcov-report/middleware/currentapp.js.html +28 -28
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +9 -9
- package/coverage/lcov-report/middleware/resourceId.js.html +17 -17
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +31 -31
- package/coverage/lcov-report/threads/index.js.html +11 -11
- package/coverage/lcov-report/threads/query.js.html +367 -91
- package/coverage/lcov-report/threads/utils.js.html +356 -11
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +13 -13
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +9 -9
- 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 +19 -19
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +235 -10
- 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 +1 -1
- package/coverage/lcov-report/utilities/statusCodes.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 +1348 -1077
- package/dist/api/controllers/query/import/sources/base/index.js +2 -1
- package/dist/api/controllers/query/import/sources/curl.js +11 -5
- package/dist/api/controllers/query/import/sources/openapi2.js +8 -5
- package/dist/api/controllers/query/index.js +45 -47
- package/dist/api/controllers/query/validation.js +2 -1
- package/dist/api/controllers/row/internal.js +14 -6
- package/dist/api/controllers/row/internalSearch.js +2 -1
- package/dist/api/controllers/row/utils.js +13 -6
- package/dist/api/routes/query.js +3 -1
- package/dist/automations/steps/executeQuery.js +8 -1
- package/dist/integrations/base/sqlTable.js +1 -1
- package/dist/integrations/rest.js +3 -3
- package/dist/package.json +5 -4
- package/dist/tests/utilities/TestConfiguration.js +7 -0
- package/dist/threads/query.js +148 -52
- package/dist/threads/utils.js +105 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/dist/utilities/rowProcessor/index.js +76 -0
- package/package.json +6 -5
- package/src/api/controllers/query/import/sources/base/index.ts +3 -1
- package/src/api/controllers/query/import/sources/curl.ts +12 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +9 -5
- package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +2 -3
- package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +6 -7
- package/src/api/controllers/query/import/tests/index.spec.js +0 -6
- package/src/api/controllers/query/index.js +48 -55
- package/src/api/controllers/query/validation.js +2 -1
- package/src/api/controllers/row/internal.js +14 -5
- package/src/api/controllers/row/internalSearch.js +2 -1
- package/src/api/controllers/row/utils.js +11 -8
- package/src/api/routes/query.js +8 -1
- package/src/api/routes/tests/query.spec.js +88 -0
- package/src/automations/steps/executeQuery.js +9 -1
- package/src/definitions/datasource.ts +10 -0
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/rest.ts +6 -3
- package/src/tests/utilities/TestConfiguration.js +10 -0
- package/src/threads/query.js +148 -56
- package/src/threads/utils.js +115 -0
- package/src/utilities/fileSystem/utilities.js +2 -0
- package/src/utilities/rowProcessor/index.js +75 -0
- package/builder/assets/index.00c4135e.js +0 -1320
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { ObjectStore, makeSureBucketExists, upload, streamUpload, retrieve, retrieveToTmp, deleteFolder, uploadDirectory, downloadTarball, } = require("@budibase/auth").objectStore;
|
|
2
|
+
const { ObjectStore, makeSureBucketExists, upload, deleteFiles, streamUpload, retrieve, retrieveToTmp, deleteFolder, uploadDirectory, downloadTarball, } = require("@budibase/auth").objectStore;
|
|
3
3
|
/***********************************
|
|
4
4
|
* NOTE *
|
|
5
5
|
* This file purely exists so that *
|
|
@@ -17,3 +17,4 @@ exports.retrieveToTmp = retrieveToTmp;
|
|
|
17
17
|
exports.deleteFolder = deleteFolder;
|
|
18
18
|
exports.uploadDirectory = uploadDirectory;
|
|
19
19
|
exports.downloadTarball = downloadTarball;
|
|
20
|
+
exports.deleteFiles = deleteFiles;
|
|
@@ -13,6 +13,10 @@ const { cloneDeep } = require("lodash/fp");
|
|
|
13
13
|
const { FieldTypes, AutoFieldSubTypes } = require("../../constants");
|
|
14
14
|
const { attachmentsRelativeURL } = require("../index");
|
|
15
15
|
const { processFormulas } = require("./utils");
|
|
16
|
+
const { deleteFiles } = require("../../utilities/fileSystem/utilities");
|
|
17
|
+
const { ObjectStoreBuckets } = require("../../constants");
|
|
18
|
+
const { isProdAppID, getDeployedAppID, dbExists } = require("@budibase/auth/db");
|
|
19
|
+
const CouchDB = require("../../db");
|
|
16
20
|
const BASE_AUTO_ID = 1;
|
|
17
21
|
/**
|
|
18
22
|
* A map of how we convert various properties in rows to each other based on the row type.
|
|
@@ -89,7 +93,36 @@ const TYPE_TRANSFORM_MAP = {
|
|
|
89
93
|
[FieldTypes.AUTO]: {
|
|
90
94
|
parse: () => undefined,
|
|
91
95
|
},
|
|
96
|
+
[FieldTypes.JSON]: {
|
|
97
|
+
parse: input => {
|
|
98
|
+
try {
|
|
99
|
+
if (input === "") {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
return JSON.parse(input);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return input;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
},
|
|
92
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Given the old state of the row and the new one after an update, this will
|
|
112
|
+
* find the keys that have been removed in the updated row.
|
|
113
|
+
*/
|
|
114
|
+
function getRemovedAttachmentKeys(oldRow, row, attachmentKey) {
|
|
115
|
+
if (!oldRow[attachmentKey]) {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
const oldKeys = oldRow[attachmentKey].map(attachment => attachment.key);
|
|
119
|
+
// no attachments in new row, all removed
|
|
120
|
+
if (!row[attachmentKey]) {
|
|
121
|
+
return oldKeys;
|
|
122
|
+
}
|
|
123
|
+
const newKeys = row[attachmentKey].map(attachment => attachment.key);
|
|
124
|
+
return oldKeys.filter(key => newKeys.indexOf(key) === -1);
|
|
125
|
+
}
|
|
93
126
|
/**
|
|
94
127
|
* This will update any auto columns that are found on the row/table with the correct information based on
|
|
95
128
|
* time now and the current logged in user making the request.
|
|
@@ -240,3 +273,46 @@ exports.outputProcessing = (ctx, table, rows, opts = { squash: true }) => __awai
|
|
|
240
273
|
}
|
|
241
274
|
return wasArray ? enriched : enriched[0];
|
|
242
275
|
});
|
|
276
|
+
/**
|
|
277
|
+
* Clean up any attachments that were attached to a row.
|
|
278
|
+
* @param {string} appId The ID of the app from which a row is being deleted.
|
|
279
|
+
* @param {object} table The table from which a row is being removed.
|
|
280
|
+
* @param {any} row optional - the row being removed.
|
|
281
|
+
* @param {any} rows optional - if multiple rows being deleted can do this in bulk.
|
|
282
|
+
* @param {any} oldRow optional - if updating a row this will determine the difference.
|
|
283
|
+
* @return {Promise<void>} When all attachments have been removed this will return.
|
|
284
|
+
*/
|
|
285
|
+
exports.cleanupAttachments = (appId, table, { row, rows, oldRow }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
286
|
+
if (!isProdAppID(appId)) {
|
|
287
|
+
const prodAppId = getDeployedAppID(appId);
|
|
288
|
+
// if prod exists, then don't allow deleting
|
|
289
|
+
const exists = yield dbExists(CouchDB, prodAppId);
|
|
290
|
+
if (exists) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
let files = [];
|
|
295
|
+
function addFiles(row, key) {
|
|
296
|
+
if (row[key]) {
|
|
297
|
+
files = files.concat(row[key].map(attachment => attachment.key));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
for (let [key, schema] of Object.entries(table.schema)) {
|
|
301
|
+
if (schema.type !== FieldTypes.ATTACHMENT) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
// if updating, need to manage the differences
|
|
305
|
+
if (oldRow && row) {
|
|
306
|
+
files = files.concat(getRemovedAttachmentKeys(oldRow, row, key));
|
|
307
|
+
}
|
|
308
|
+
else if (row) {
|
|
309
|
+
addFiles(row, key);
|
|
310
|
+
}
|
|
311
|
+
else if (rows) {
|
|
312
|
+
rows.forEach(row => addFiles(row, key));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (files.length > 0) {
|
|
316
|
+
return deleteFiles(ObjectStoreBuckets.APPS, files);
|
|
317
|
+
}
|
|
318
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.27-alpha.
|
|
4
|
+
"version": "1.0.27-alpha.10",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/auth": "^1.0.27-alpha.
|
|
74
|
-
"@budibase/client": "^1.0.27-alpha.
|
|
75
|
-
"@budibase/string-templates": "^1.0.27-alpha.
|
|
73
|
+
"@budibase/auth": "^1.0.27-alpha.10",
|
|
74
|
+
"@budibase/client": "^1.0.27-alpha.10",
|
|
75
|
+
"@budibase/string-templates": "^1.0.27-alpha.10",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"pouchdb-replication-stream": "1.2.9",
|
|
123
123
|
"server-destroy": "1.0.1",
|
|
124
124
|
"svelte": "^3.38.2",
|
|
125
|
+
"swagger-parser": "^10.0.3",
|
|
125
126
|
"to-json-schema": "0.2.5",
|
|
126
127
|
"uuid": "3.3.2",
|
|
127
128
|
"validate.js": "0.13.1",
|
|
@@ -164,5 +165,5 @@
|
|
|
164
165
|
"optionalDependencies": {
|
|
165
166
|
"oracledb": "^5.3.0"
|
|
166
167
|
},
|
|
167
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "37b3e81a0d6f99566d3b753f79b91d5b05185106"
|
|
168
169
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Query, QueryParameter } from "../../../../../../definitions/datasource"
|
|
2
|
+
import { URL } from "url"
|
|
2
3
|
|
|
3
4
|
export interface ImportInfo {
|
|
4
|
-
url: string
|
|
5
5
|
name: string
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -23,6 +23,7 @@ export abstract class ImportSource {
|
|
|
23
23
|
name: string,
|
|
24
24
|
method: string,
|
|
25
25
|
path: string,
|
|
26
|
+
url: URL,
|
|
26
27
|
queryString: string,
|
|
27
28
|
headers: object = {},
|
|
28
29
|
parameters: QueryParameter[] = [],
|
|
@@ -33,6 +34,7 @@ export abstract class ImportSource {
|
|
|
33
34
|
const transformer = "return data"
|
|
34
35
|
const schema = {}
|
|
35
36
|
path = this.processPath(path)
|
|
37
|
+
path = `${url.origin}/${path}`
|
|
36
38
|
queryString = this.processQuery(queryString)
|
|
37
39
|
const requestBody = JSON.stringify(body, null, 2)
|
|
38
40
|
|
|
@@ -17,8 +17,12 @@ const parseBody = (curl: any) => {
|
|
|
17
17
|
if (curl.data) {
|
|
18
18
|
const keys = Object.keys(curl.data)
|
|
19
19
|
if (keys.length) {
|
|
20
|
-
|
|
20
|
+
let key = keys[0]
|
|
21
21
|
try {
|
|
22
|
+
// filter out the dollar syntax used by curl for shell support
|
|
23
|
+
if (key.startsWith("$")) {
|
|
24
|
+
key = key.substring(1)
|
|
25
|
+
}
|
|
22
26
|
return JSON.parse(key)
|
|
23
27
|
} catch (e) {
|
|
24
28
|
// do nothing
|
|
@@ -56,16 +60,19 @@ export class Curl extends ImportSource {
|
|
|
56
60
|
return true
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
getUrl = (): URL => {
|
|
64
|
+
return new URL(this.curl.raw_url)
|
|
65
|
+
}
|
|
66
|
+
|
|
59
67
|
getInfo = async (): Promise<ImportInfo> => {
|
|
60
|
-
const url =
|
|
68
|
+
const url = this.getUrl()
|
|
61
69
|
return {
|
|
62
|
-
url: url.origin,
|
|
63
70
|
name: url.hostname,
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
getQueries = async (datasourceId: string): Promise<Query[]> => {
|
|
68
|
-
const url =
|
|
75
|
+
const url = this.getUrl()
|
|
69
76
|
const name = url.pathname
|
|
70
77
|
const path = url.pathname
|
|
71
78
|
const method = this.curl.method
|
|
@@ -83,6 +90,7 @@ export class Curl extends ImportSource {
|
|
|
83
90
|
name,
|
|
84
91
|
method,
|
|
85
92
|
path,
|
|
93
|
+
url,
|
|
86
94
|
queryString,
|
|
87
95
|
headers,
|
|
88
96
|
[],
|
|
@@ -2,6 +2,7 @@ import { ImportInfo } from "./base"
|
|
|
2
2
|
import { Query, QueryParameter } from "../../../../../definitions/datasource"
|
|
3
3
|
import { OpenAPIV2 } from "openapi-types"
|
|
4
4
|
import { OpenAPISource } from "./base/openapi"
|
|
5
|
+
import { URL } from "url"
|
|
5
6
|
|
|
6
7
|
const parameterNotRef = (
|
|
7
8
|
param: OpenAPIV2.Parameter | OpenAPIV2.ReferenceObject
|
|
@@ -55,20 +56,22 @@ export class OpenAPI2 extends OpenAPISource {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
getUrl = (): URL => {
|
|
59
60
|
const scheme = this.document.schemes?.includes("https") ? "https" : "http"
|
|
60
61
|
const basePath = this.document.basePath || ""
|
|
61
62
|
const host = this.document.host || "<host>"
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
return new URL(`${scheme}://${host}${basePath}`)
|
|
64
|
+
}
|
|
64
65
|
|
|
66
|
+
getInfo = async (): Promise<ImportInfo> => {
|
|
67
|
+
const name = this.document.info.title || "Swagger Import"
|
|
65
68
|
return {
|
|
66
|
-
|
|
67
|
-
name: name,
|
|
69
|
+
name,
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
getQueries = async (datasourceId: string): Promise<Query[]> => {
|
|
74
|
+
const url = this.getUrl()
|
|
72
75
|
const queries = []
|
|
73
76
|
|
|
74
77
|
for (let [path, pathItem] of Object.entries(this.document.paths)) {
|
|
@@ -145,6 +148,7 @@ export class OpenAPI2 extends OpenAPISource {
|
|
|
145
148
|
name,
|
|
146
149
|
methodName,
|
|
147
150
|
path,
|
|
151
|
+
url,
|
|
148
152
|
queryString,
|
|
149
153
|
headers,
|
|
150
154
|
parameters,
|
|
@@ -35,7 +35,6 @@ describe("Curl Import", () => {
|
|
|
35
35
|
it("returns import info", async () => {
|
|
36
36
|
await init("get")
|
|
37
37
|
const info = await curl.getInfo()
|
|
38
|
-
expect(info.url).toBe("http://example.com")
|
|
39
38
|
expect(info.name).toBe("example.com")
|
|
40
39
|
})
|
|
41
40
|
|
|
@@ -67,8 +66,8 @@ describe("Curl Import", () => {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
it("populates path", async () => {
|
|
70
|
-
await testPath("get", "")
|
|
71
|
-
await testPath("path", "paths/abc")
|
|
69
|
+
await testPath("get", "http://example.com/")
|
|
70
|
+
await testPath("path", "http://example.com/paths/abc")
|
|
72
71
|
})
|
|
73
72
|
|
|
74
73
|
const testHeaders = async (file, headers) => {
|
|
@@ -41,7 +41,6 @@ describe("OpenAPI2 Import", () => {
|
|
|
41
41
|
const testImportInfo = async (file, extension) => {
|
|
42
42
|
await init(file, extension)
|
|
43
43
|
const info = await openapi2.getInfo()
|
|
44
|
-
expect(info.url).toBe("https://petstore.swagger.io/v2")
|
|
45
44
|
expect(info.name).toBe("Swagger Petstore")
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -92,12 +91,12 @@ describe("OpenAPI2 Import", () => {
|
|
|
92
91
|
|
|
93
92
|
it("populates path", async () => {
|
|
94
93
|
const assertions = {
|
|
95
|
-
"createEntity" : "entities",
|
|
96
|
-
"getEntities" : "entities",
|
|
97
|
-
"getEntity" : "entities/{{entityId}}",
|
|
98
|
-
"updateEntity" : "entities/{{entityId}}",
|
|
99
|
-
"patchEntity" : "entities/{{entityId}}",
|
|
100
|
-
"deleteEntity" : "entities/{{entityId}}"
|
|
94
|
+
"createEntity" : "http://example.com/entities",
|
|
95
|
+
"getEntities" : "http://example.com/entities",
|
|
96
|
+
"getEntity" : "http://example.com/entities/{{entityId}}",
|
|
97
|
+
"updateEntity" : "http://example.com/entities/{{entityId}}",
|
|
98
|
+
"patchEntity" : "http://example.com/entities/{{entityId}}",
|
|
99
|
+
"deleteEntity" : "http://example.com/entities/{{entityId}}"
|
|
101
100
|
}
|
|
102
101
|
await runTests("crud", testPath, assertions)
|
|
103
102
|
})
|
|
@@ -51,30 +51,24 @@ describe("Rest Importer", () => {
|
|
|
51
51
|
await init(data)
|
|
52
52
|
const info = await restImporter.getInfo()
|
|
53
53
|
expect(info.name).toBe(assertions[key].name)
|
|
54
|
-
expect(info.url).toBe(assertions[key].url)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
it("gets info", async () => {
|
|
58
57
|
const assertions = {
|
|
59
58
|
"oapi2CrudJson" : {
|
|
60
59
|
name: "CRUD",
|
|
61
|
-
url: "http://example.com"
|
|
62
60
|
},
|
|
63
61
|
"oapi2CrudYaml" : {
|
|
64
62
|
name: "CRUD",
|
|
65
|
-
url: "http://example.com"
|
|
66
63
|
},
|
|
67
64
|
"oapi2PetstoreJson" : {
|
|
68
65
|
name: "Swagger Petstore",
|
|
69
|
-
url: "https://petstore.swagger.io/v2"
|
|
70
66
|
},
|
|
71
67
|
"oapi2PetstoreYaml" :{
|
|
72
68
|
name: "Swagger Petstore",
|
|
73
|
-
url: "https://petstore.swagger.io/v2"
|
|
74
69
|
},
|
|
75
70
|
"curl": {
|
|
76
71
|
name: "example.com",
|
|
77
|
-
url: "http://example.com"
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
74
|
await runTest(testGetInfo, assertions)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { processString } = require("@budibase/string-templates")
|
|
2
1
|
const CouchDB = require("../../../db")
|
|
3
2
|
const {
|
|
4
3
|
generateQueryID,
|
|
@@ -9,6 +8,7 @@ const { BaseQueryVerbs } = require("../../../constants")
|
|
|
9
8
|
const { Thread, ThreadType } = require("../../../threads")
|
|
10
9
|
const { save: saveDatasource } = require("../datasource")
|
|
11
10
|
const { RestImporter } = require("./import")
|
|
11
|
+
const { invalidateDynamicVariables } = require("../../../threads/utils")
|
|
12
12
|
|
|
13
13
|
const Runner = new Thread(ThreadType.QUERY, { timeoutMs: 10000 })
|
|
14
14
|
|
|
@@ -90,47 +90,6 @@ exports.save = async function (ctx) {
|
|
|
90
90
|
ctx.message = `Query ${query.name} saved successfully.`
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
async function enrichQueryFields(fields, parameters = {}) {
|
|
94
|
-
const enrichedQuery = {}
|
|
95
|
-
|
|
96
|
-
// enrich the fields with dynamic parameters
|
|
97
|
-
for (let key of Object.keys(fields)) {
|
|
98
|
-
if (fields[key] == null) {
|
|
99
|
-
continue
|
|
100
|
-
}
|
|
101
|
-
if (typeof fields[key] === "object") {
|
|
102
|
-
// enrich nested fields object
|
|
103
|
-
enrichedQuery[key] = await enrichQueryFields(fields[key], parameters)
|
|
104
|
-
} else if (typeof fields[key] === "string") {
|
|
105
|
-
// enrich string value as normal
|
|
106
|
-
enrichedQuery[key] = await processString(fields[key], parameters, {
|
|
107
|
-
noHelpers: true,
|
|
108
|
-
})
|
|
109
|
-
} else {
|
|
110
|
-
enrichedQuery[key] = fields[key]
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
enrichedQuery.json ||
|
|
116
|
-
enrichedQuery.customData ||
|
|
117
|
-
enrichedQuery.requestBody
|
|
118
|
-
) {
|
|
119
|
-
try {
|
|
120
|
-
enrichedQuery.json = JSON.parse(
|
|
121
|
-
enrichedQuery.json ||
|
|
122
|
-
enrichedQuery.customData ||
|
|
123
|
-
enrichedQuery.requestBody
|
|
124
|
-
)
|
|
125
|
-
} catch (err) {
|
|
126
|
-
// no json found, ignore
|
|
127
|
-
}
|
|
128
|
-
delete enrichedQuery.customData
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return enrichedQuery
|
|
132
|
-
}
|
|
133
|
-
|
|
134
93
|
exports.find = async function (ctx) {
|
|
135
94
|
const db = new CouchDB(ctx.appId)
|
|
136
95
|
const query = enrichQueries(await db.get(ctx.params.queryId))
|
|
@@ -146,16 +105,20 @@ exports.preview = async function (ctx) {
|
|
|
146
105
|
const db = new CouchDB(ctx.appId)
|
|
147
106
|
|
|
148
107
|
const datasource = await db.get(ctx.request.body.datasourceId)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
108
|
+
// preview may not have a queryId as it hasn't been saved, but if it does
|
|
109
|
+
// this stops dynamic variables from calling the same query
|
|
110
|
+
const { fields, parameters, queryVerb, transformer, queryId } =
|
|
111
|
+
ctx.request.body
|
|
152
112
|
|
|
153
113
|
try {
|
|
154
114
|
const { rows, keys, info, extra } = await Runner.run({
|
|
115
|
+
appId: ctx.appId,
|
|
155
116
|
datasource,
|
|
156
117
|
queryVerb,
|
|
157
|
-
|
|
118
|
+
fields,
|
|
119
|
+
parameters,
|
|
158
120
|
transformer,
|
|
121
|
+
queryId,
|
|
159
122
|
})
|
|
160
123
|
|
|
161
124
|
ctx.body = {
|
|
@@ -169,33 +132,63 @@ exports.preview = async function (ctx) {
|
|
|
169
132
|
}
|
|
170
133
|
}
|
|
171
134
|
|
|
172
|
-
|
|
135
|
+
async function execute(ctx, opts = { rowsOnly: false }) {
|
|
173
136
|
const db = new CouchDB(ctx.appId)
|
|
174
137
|
|
|
175
138
|
const query = await db.get(ctx.params.queryId)
|
|
176
139
|
const datasource = await db.get(query.datasourceId)
|
|
177
140
|
|
|
178
|
-
const enrichedQuery = await enrichQueryFields(
|
|
179
|
-
query.fields,
|
|
180
|
-
ctx.request.body.parameters
|
|
181
|
-
)
|
|
182
|
-
|
|
183
141
|
// call the relevant CRUD method on the integration class
|
|
184
142
|
try {
|
|
185
|
-
const { rows } = await Runner.run({
|
|
143
|
+
const { rows, extra } = await Runner.run({
|
|
144
|
+
appId: ctx.appId,
|
|
186
145
|
datasource,
|
|
187
146
|
queryVerb: query.queryVerb,
|
|
188
|
-
|
|
147
|
+
fields: query.fields,
|
|
148
|
+
parameters: ctx.request.body.parameters,
|
|
189
149
|
transformer: query.transformer,
|
|
150
|
+
queryId: ctx.params.queryId,
|
|
190
151
|
})
|
|
191
|
-
|
|
152
|
+
if (opts && opts.rowsOnly) {
|
|
153
|
+
ctx.body = rows
|
|
154
|
+
} else {
|
|
155
|
+
ctx.body = { data: rows, ...extra }
|
|
156
|
+
}
|
|
192
157
|
} catch (err) {
|
|
193
158
|
ctx.throw(400, err)
|
|
194
159
|
}
|
|
195
160
|
}
|
|
196
161
|
|
|
162
|
+
exports.executeV1 = async function (ctx) {
|
|
163
|
+
return execute(ctx, { rowsOnly: true })
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
exports.executeV2 = async function (ctx) {
|
|
167
|
+
return execute(ctx, { rowsOnly: false })
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const removeDynamicVariables = async (db, queryId) => {
|
|
171
|
+
const query = await db.get(queryId)
|
|
172
|
+
const datasource = await db.get(query.datasourceId)
|
|
173
|
+
const dynamicVariables = datasource.config.dynamicVariables
|
|
174
|
+
|
|
175
|
+
if (dynamicVariables) {
|
|
176
|
+
// delete dynamic variables from the datasource
|
|
177
|
+
const newVariables = dynamicVariables.filter(dv => dv.queryId !== queryId)
|
|
178
|
+
datasource.config.dynamicVariables = newVariables
|
|
179
|
+
await db.put(datasource)
|
|
180
|
+
|
|
181
|
+
// invalidate the deleted variables
|
|
182
|
+
const variablesToDelete = dynamicVariables.filter(
|
|
183
|
+
dv => dv.queryId === queryId
|
|
184
|
+
)
|
|
185
|
+
await invalidateDynamicVariables(variablesToDelete)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
197
189
|
exports.destroy = async function (ctx) {
|
|
198
190
|
const db = new CouchDB(ctx.appId)
|
|
191
|
+
await removeDynamicVariables(db, ctx.params.queryId)
|
|
199
192
|
await db.remove(ctx.params.queryId, ctx.params.revId)
|
|
200
193
|
ctx.message = `Query deleted.`
|
|
201
194
|
ctx.status = 200
|
|
@@ -36,6 +36,7 @@ exports.generateQueryPreviewValidation = () => {
|
|
|
36
36
|
extra: Joi.object().optional(),
|
|
37
37
|
datasourceId: Joi.string().required(),
|
|
38
38
|
transformer: Joi.string().optional(),
|
|
39
|
-
parameters: Joi.object({}).required().unknown(true)
|
|
39
|
+
parameters: Joi.object({}).required().unknown(true),
|
|
40
|
+
queryId: Joi.string().optional(),
|
|
40
41
|
}))
|
|
41
42
|
}
|
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
inputProcessing,
|
|
12
12
|
outputProcessing,
|
|
13
13
|
processAutoColumn,
|
|
14
|
+
cleanupAttachments,
|
|
14
15
|
} = require("../../../utilities/rowProcessor")
|
|
15
16
|
const { FieldTypes } = require("../../../constants")
|
|
16
17
|
const { isEqual } = require("lodash")
|
|
@@ -25,6 +26,7 @@ const {
|
|
|
25
26
|
getFromDesignDoc,
|
|
26
27
|
getFromMemoryDoc,
|
|
27
28
|
} = require("../view/utils")
|
|
29
|
+
const { cloneDeep } = require("lodash/fp")
|
|
28
30
|
|
|
29
31
|
const CALCULATION_TYPES = {
|
|
30
32
|
SUM: "sum",
|
|
@@ -109,14 +111,14 @@ exports.patch = async ctx => {
|
|
|
109
111
|
const inputs = ctx.request.body
|
|
110
112
|
const tableId = inputs.tableId
|
|
111
113
|
const isUserTable = tableId === InternalTables.USER_METADATA
|
|
112
|
-
let
|
|
114
|
+
let oldRow
|
|
113
115
|
try {
|
|
114
|
-
|
|
116
|
+
oldRow = await db.get(inputs._id)
|
|
115
117
|
} catch (err) {
|
|
116
118
|
if (isUserTable) {
|
|
117
119
|
// don't include the rev, it'll be the global rev
|
|
118
120
|
// this time
|
|
119
|
-
|
|
121
|
+
oldRow = {
|
|
120
122
|
_id: inputs._id,
|
|
121
123
|
}
|
|
122
124
|
} else {
|
|
@@ -125,13 +127,14 @@ exports.patch = async ctx => {
|
|
|
125
127
|
}
|
|
126
128
|
let dbTable = await db.get(tableId)
|
|
127
129
|
// need to build up full patch fields before coerce
|
|
130
|
+
let combinedRow = cloneDeep(oldRow)
|
|
128
131
|
for (let key of Object.keys(inputs)) {
|
|
129
132
|
if (!dbTable.schema[key]) continue
|
|
130
|
-
|
|
133
|
+
combinedRow[key] = inputs[key]
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
// this returns the table and row incase they have been updated
|
|
134
|
-
let { table, row } = inputProcessing(ctx.user, dbTable,
|
|
137
|
+
let { table, row } = inputProcessing(ctx.user, dbTable, combinedRow)
|
|
135
138
|
const validateResult = await validate({
|
|
136
139
|
row,
|
|
137
140
|
table,
|
|
@@ -149,6 +152,8 @@ exports.patch = async ctx => {
|
|
|
149
152
|
tableId: row.tableId,
|
|
150
153
|
table,
|
|
151
154
|
})
|
|
155
|
+
// check if any attachments removed
|
|
156
|
+
await cleanupAttachments(appId, table, { oldRow, row })
|
|
152
157
|
|
|
153
158
|
if (isUserTable) {
|
|
154
159
|
// the row has been updated, need to put it into the ctx
|
|
@@ -295,6 +300,8 @@ exports.destroy = async function (ctx) {
|
|
|
295
300
|
row,
|
|
296
301
|
tableId: row.tableId,
|
|
297
302
|
})
|
|
303
|
+
// remove any attachments that were on the row from object storage
|
|
304
|
+
await cleanupAttachments(appId, table, { row })
|
|
298
305
|
|
|
299
306
|
let response
|
|
300
307
|
if (ctx.params.tableId === InternalTables.USER_METADATA) {
|
|
@@ -341,6 +348,8 @@ exports.bulkDestroy = async ctx => {
|
|
|
341
348
|
} else {
|
|
342
349
|
await db.bulkDocs(rows.map(row => ({ ...row, _deleted: true })))
|
|
343
350
|
}
|
|
351
|
+
// remove any attachments that were on the rows from object storage
|
|
352
|
+
await cleanupAttachments(appId, table, { rows })
|
|
344
353
|
await Promise.all(updates)
|
|
345
354
|
return { response: { ok: true }, rows }
|
|
346
355
|
}
|
|
@@ -191,7 +191,8 @@ class QueryBuilder {
|
|
|
191
191
|
}
|
|
192
192
|
if (this.query.equal) {
|
|
193
193
|
build(this.query.equal, (key, value) => {
|
|
194
|
-
if
|
|
194
|
+
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
195
|
+
if (!value && value !== 0) {
|
|
195
196
|
return null
|
|
196
197
|
}
|
|
197
198
|
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
|
|
@@ -50,10 +50,10 @@ exports.validate = async ({ appId, tableId, row, table }) => {
|
|
|
50
50
|
const errors = {}
|
|
51
51
|
for (let fieldName of Object.keys(table.schema)) {
|
|
52
52
|
const constraints = cloneDeep(table.schema[fieldName].constraints)
|
|
53
|
+
const type = table.schema[fieldName].type
|
|
53
54
|
// special case for options, need to always allow unselected (null)
|
|
54
55
|
if (
|
|
55
|
-
|
|
56
|
-
(FieldTypes.OPTIONS || FieldTypes.ARRAY) &&
|
|
56
|
+
(type === FieldTypes.OPTIONS || type === FieldTypes.ARRAY) &&
|
|
57
57
|
constraints.inclusion
|
|
58
58
|
) {
|
|
59
59
|
constraints.inclusion.push(null)
|
|
@@ -61,17 +61,20 @@ exports.validate = async ({ appId, tableId, row, table }) => {
|
|
|
61
61
|
let res
|
|
62
62
|
|
|
63
63
|
// Validate.js doesn't seem to handle array
|
|
64
|
-
if (
|
|
65
|
-
table.schema[fieldName].type === FieldTypes.ARRAY &&
|
|
66
|
-
row[fieldName] &&
|
|
67
|
-
row[fieldName].length
|
|
68
|
-
) {
|
|
64
|
+
if (type === FieldTypes.ARRAY && row[fieldName] && row[fieldName].length) {
|
|
69
65
|
row[fieldName].map(val => {
|
|
70
66
|
if (!constraints.inclusion.includes(val)) {
|
|
71
67
|
errors[fieldName] = "Field not in list"
|
|
72
68
|
}
|
|
73
69
|
})
|
|
74
|
-
} else if (
|
|
70
|
+
} else if (type === FieldTypes.JSON && typeof row[fieldName] === "string") {
|
|
71
|
+
// this should only happen if there is an error
|
|
72
|
+
try {
|
|
73
|
+
JSON.parse(row[fieldName])
|
|
74
|
+
} catch (err) {
|
|
75
|
+
errors[fieldName] = [`Contains invalid JSON`]
|
|
76
|
+
}
|
|
77
|
+
} else if (type === FieldTypes.FORMULA) {
|
|
75
78
|
res = validateJs.single(
|
|
76
79
|
processStringSync(table.schema[fieldName].formula, row),
|
|
77
80
|
constraints
|
package/src/api/routes/query.js
CHANGED
|
@@ -41,11 +41,18 @@ router
|
|
|
41
41
|
authorized(PermissionTypes.QUERY, PermissionLevels.READ),
|
|
42
42
|
queryController.find
|
|
43
43
|
)
|
|
44
|
+
// DEPRECATED - use new query endpoint for future work
|
|
44
45
|
.post(
|
|
45
46
|
"/api/queries/:queryId",
|
|
46
47
|
paramResource("queryId"),
|
|
47
48
|
authorized(PermissionTypes.QUERY, PermissionLevels.WRITE),
|
|
48
|
-
queryController.
|
|
49
|
+
queryController.executeV1
|
|
50
|
+
)
|
|
51
|
+
.post(
|
|
52
|
+
"/api/v2/queries/:queryId",
|
|
53
|
+
paramResource("queryId"),
|
|
54
|
+
authorized(PermissionTypes.QUERY, PermissionLevels.WRITE),
|
|
55
|
+
queryController.executeV2
|
|
49
56
|
)
|
|
50
57
|
.delete(
|
|
51
58
|
"/api/queries/:queryId/:revId",
|