@budibase/server 1.0.219 → 1.0.220-alpha.2
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/.yarnrc +1 -0
- package/__mocks__/node-fetch.ts +9 -0
- package/builder/assets/index.7786f497.css +6 -0
- package/builder/assets/index.e1885c5f.js +974 -0
- package/builder/assets/{vendor.9bf2fcb4.js → vendor.001dcf8c.js} +163 -163
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1018 -950
- package/coverage/coverage-final.json +31 -31
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +111 -12
- package/coverage/lcov-report/api/controllers/backup.js.html +9 -6
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +13 -166
- package/coverage/lcov-report/api/controllers/index.html +32 -32
- 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/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 +47 -17
- package/coverage/lcov-report/api/controllers/row/index.html +33 -33
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +159 -21
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -8
- 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/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 +15 -15
- package/coverage/lcov-report/api/index.js.html +22 -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 +32 -2
- 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 +2 -5
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +5 -2
- 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 +57 -12
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +17 -17
- 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 +2 -2
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +58 -34
- 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/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 +4 -4
- 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 +13 -13
- package/coverage/lcov-report/db/linkedRows/index.js.html +10 -7
- 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 +27 -51
- 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 +83 -83
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +10 -10
- 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/threads/automation.js.html +18 -9
- package/coverage/lcov-report/threads/index.html +25 -25
- package/coverage/lcov-report/threads/query.js.html +301 -79
- package/coverage/lcov-report/threads/utils.js.html +4 -4
- 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 +14 -14
- package/coverage/lcov-report/utilities/index.html +26 -26
- package/coverage/lcov-report/utilities/index.js.html +17 -32
- 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 +57 -9
- package/coverage/lcov.info +1789 -1665
- package/dist/api/controllers/application.js +19 -16
- package/dist/api/controllers/automation.js +28 -2
- package/dist/api/controllers/backup.js +3 -2
- package/dist/api/controllers/dev.js +2 -40
- package/dist/api/controllers/public/applications.js +1 -1
- package/dist/api/controllers/public/utils.js +8 -1
- package/dist/api/controllers/query/index.js +31 -3
- package/dist/api/controllers/row/external.js +19 -7
- package/dist/api/controllers/row/internalSearch.js +47 -10
- package/dist/api/controllers/row/utils.js +3 -0
- package/dist/api/controllers/static/index.js +1 -5
- package/dist/api/index.js +4 -1
- package/dist/api/routes/automation.js +2 -0
- package/dist/api/routes/dev.js +1 -2
- package/dist/api/routes/public/rows.js +7 -2
- package/dist/api/routes/utils/validators.js +1 -0
- package/dist/app.js +20 -0
- package/dist/automations/automationUtils.js +16 -4
- package/dist/automations/logging/index.js +70 -0
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/automations/steps/filter.js +38 -29
- package/dist/automations/triggers.js +1 -1
- package/dist/db/linkedRows/index.js +1 -0
- package/dist/db/utils.js +4 -31
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +3 -0
- package/dist/integrations/airtable.js +1 -0
- package/dist/integrations/arangodb.js +1 -0
- package/dist/integrations/base/sql.js +22 -3
- package/dist/integrations/couchdb.js +1 -0
- package/dist/integrations/dynamodb.js +1 -0
- package/dist/integrations/elasticsearch.js +1 -0
- package/dist/integrations/firebase.js +1 -0
- package/dist/integrations/googlesheets.js +1 -0
- package/dist/integrations/index.js +4 -0
- package/dist/integrations/microsoftSqlServer.js +2 -1
- package/dist/integrations/mongodb.js +1 -0
- package/dist/integrations/mysql.js +2 -1
- package/dist/integrations/oracle.js +1 -0
- package/dist/integrations/postgres.js +2 -1
- package/dist/integrations/queries/sql.js +3 -0
- package/dist/integrations/redis.js +1 -0
- package/dist/integrations/rest.js +2 -1
- package/dist/integrations/s3.js +1 -0
- package/dist/integrations/snowflake.js +102 -0
- package/dist/package.json +7 -6
- package/dist/tests/utilities/TestConfiguration.js +19 -6
- package/dist/threads/automation.js +6 -3
- package/dist/threads/index.js +15 -1
- package/dist/threads/query.js +65 -12
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +16 -6
- package/dist/utilities/index.js +1 -5
- package/dist/utilities/workerRequests.js +8 -0
- package/package.json +8 -7
- package/scripts/dev/manage.js +2 -0
- package/scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip +0 -0
- package/scripts/integrations/oracle/instantclient/linux/arm64/install.sh +23 -0
- package/scripts/integrations/oracle/instantclient/linux/install.sh +10 -0
- package/specs/openapi.json +9 -5
- package/specs/openapi.yaml +10 -4
- package/src/api/controllers/application.ts +19 -19
- package/src/api/controllers/automation.js +35 -2
- package/src/api/controllers/backup.js +3 -2
- package/src/api/controllers/dev.js +2 -53
- package/src/api/controllers/public/applications.ts +2 -2
- package/src/api/controllers/public/utils.ts +8 -1
- package/src/api/controllers/query/index.ts +40 -4
- package/src/api/controllers/row/external.js +19 -9
- package/src/api/controllers/row/internalSearch.js +55 -9
- package/src/api/controllers/row/utils.js +3 -0
- package/src/api/controllers/static/index.js +1 -6
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +10 -0
- package/src/api/routes/dev.js +0 -1
- package/src/api/routes/public/rows.ts +7 -2
- package/src/api/routes/tests/query.spec.js +166 -1
- package/src/api/routes/utils/validators.js +1 -0
- package/src/app.ts +30 -1
- package/src/automations/automationUtils.js +19 -4
- package/src/automations/logging/index.ts +35 -0
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/steps/filter.js +36 -28
- package/src/automations/tests/filter.spec.js +2 -1
- package/src/automations/triggers.js +1 -1
- package/src/db/linkedRows/index.js +1 -0
- package/src/db/utils.js +5 -13
- package/src/definitions/common.ts +1 -0
- package/src/definitions/datasource.ts +2 -0
- package/src/definitions/openapi.ts +471 -469
- package/src/environment.js +3 -0
- package/src/integrations/airtable.ts +1 -0
- package/src/integrations/arangodb.ts +1 -0
- package/src/integrations/base/sql.ts +29 -11
- package/src/integrations/couchdb.ts +1 -0
- package/src/integrations/dynamodb.ts +1 -0
- package/src/integrations/elasticsearch.ts +1 -0
- package/src/integrations/firebase.ts +1 -0
- package/src/integrations/googlesheets.ts +1 -0
- package/src/integrations/index.ts +4 -0
- package/src/integrations/microsoftSqlServer.ts +2 -0
- package/src/integrations/mongodb.ts +1 -0
- package/src/integrations/mysql.ts +2 -0
- package/src/integrations/oracle.ts +1 -0
- package/src/integrations/postgres.ts +2 -0
- package/src/integrations/queries/sql.ts +3 -1
- package/src/integrations/redis.ts +1 -0
- package/src/integrations/rest.ts +2 -1
- package/src/integrations/s3.ts +1 -0
- package/src/integrations/snowflake.ts +99 -0
- package/src/integrations/tests/rest.spec.js +16 -1
- package/src/migrations/tests/index.spec.ts +18 -2
- package/src/module.d.ts +2 -0
- package/src/tests/utilities/TestConfiguration.js +22 -3
- package/src/threads/automation.js +6 -3
- package/src/threads/index.ts +5 -1
- package/src/threads/query.js +88 -14
- package/src/utilities/fileSystem/index.js +22 -8
- package/src/utilities/index.js +1 -6
- package/src/utilities/workerRequests.js +16 -0
- package/builder/assets/index.1c640a53.js +0 -1316
- package/builder/assets/index.24307ca0.css +0 -6
|
@@ -17,7 +17,7 @@ const { ObjectStoreBuckets } = require("../../constants");
|
|
|
17
17
|
const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball, } = require("./utilities");
|
|
18
18
|
const { updateClientLibrary } = require("./clientLibrary");
|
|
19
19
|
const env = require("../../environment");
|
|
20
|
-
const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, } = require("../../db/utils");
|
|
20
|
+
const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, TABLE_ROW_PREFIX, } = require("../../db/utils");
|
|
21
21
|
const MemoryStream = require("memorystream");
|
|
22
22
|
const { getAppId } = require("@budibase/backend-core/context");
|
|
23
23
|
const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..");
|
|
@@ -98,6 +98,17 @@ exports.apiFileReturn = contents => {
|
|
|
98
98
|
fs.writeFileSync(path, contents);
|
|
99
99
|
return fs.createReadStream(path);
|
|
100
100
|
};
|
|
101
|
+
exports.defineFilter = excludeRows => {
|
|
102
|
+
if (excludeRows) {
|
|
103
|
+
return doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
|
|
104
|
+
doc._id.includes(LINK_USER_METADATA_PREFIX) ||
|
|
105
|
+
doc._id.includes(TABLE_ROW_PREFIX));
|
|
106
|
+
}
|
|
107
|
+
else if (!excludeRows) {
|
|
108
|
+
return doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
|
|
109
|
+
doc._id.includes(LINK_USER_METADATA_PREFIX));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
101
112
|
/**
|
|
102
113
|
* Local utility to back up the database state for an app, excluding global user
|
|
103
114
|
* data or user relationships.
|
|
@@ -105,9 +116,8 @@ exports.apiFileReturn = contents => {
|
|
|
105
116
|
* @param {object} config Config to send to export DB
|
|
106
117
|
* @returns {*} either a string or a stream of the backup
|
|
107
118
|
*/
|
|
108
|
-
const backupAppData = (appId, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
-
return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter:
|
|
110
|
-
doc._id.includes(LINK_USER_METADATA_PREFIX)) }));
|
|
119
|
+
const backupAppData = (appId, config, includeRows) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter: exports.defineFilter(includeRows) }));
|
|
111
121
|
});
|
|
112
122
|
/**
|
|
113
123
|
* Takes a copy of the database state for an app to the object store.
|
|
@@ -123,8 +133,8 @@ exports.performBackup = (appId, backupName) => __awaiter(void 0, void 0, void 0,
|
|
|
123
133
|
* @param {string} appId The ID of the app which is to be backed up.
|
|
124
134
|
* @returns {*} a readable stream of the backup which is written in real time
|
|
125
135
|
*/
|
|
126
|
-
exports.streamBackup = (appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
-
return yield backupAppData(appId, { stream: true });
|
|
136
|
+
exports.streamBackup = (appId, includeRows) => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
return yield backupAppData(appId, { stream: true }, includeRows);
|
|
128
138
|
});
|
|
129
139
|
/**
|
|
130
140
|
* Exports a DB to either file or a variable (memory).
|
package/dist/utilities/index.js
CHANGED
|
@@ -57,12 +57,8 @@ exports.objectStoreUrl = () => {
|
|
|
57
57
|
* @return {string} The URL to be inserted into appPackage response or server rendered
|
|
58
58
|
* app index file.
|
|
59
59
|
*/
|
|
60
|
-
exports.clientLibraryPath = (appId, version
|
|
60
|
+
exports.clientLibraryPath = (appId, version) => {
|
|
61
61
|
if (env.isProd()) {
|
|
62
|
-
// TODO: remove - for beta testing UI
|
|
63
|
-
if (ctx && ctx.cookies.get("beta:design_ui")) {
|
|
64
|
-
return "https://cdn.budi.live/beta:design_ui/budibase-client.js";
|
|
65
|
-
}
|
|
66
62
|
let url = `${exports.objectStoreUrl()}/${sanitizeKey(appId)}/budibase-client.js`;
|
|
67
63
|
// append app version to bust the cache
|
|
68
64
|
if (version) {
|
|
@@ -120,3 +120,11 @@ exports.readGlobalUser = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
120
120
|
request(ctx, { method: "GET" }));
|
|
121
121
|
return checkResponse(response, "get user", { ctx });
|
|
122
122
|
});
|
|
123
|
+
exports.createAdminUser = (email, password, tenantId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/users/init"), request(null, { method: "POST", body: { email, password, tenantId } }));
|
|
125
|
+
return checkResponse(response, "create admin user");
|
|
126
|
+
});
|
|
127
|
+
exports.getChecklist = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/configs/checklist"), request(null, { method: "GET" }));
|
|
129
|
+
return checkResponse(response, "get checklist");
|
|
130
|
+
});
|
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.
|
|
4
|
+
"version": "1.0.220-alpha.2",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "^1.0.
|
|
81
|
-
"@budibase/client": "^1.0.
|
|
82
|
-
"@budibase/pro": "1.0.
|
|
83
|
-
"@budibase/string-templates": "^1.0.
|
|
80
|
+
"@budibase/backend-core": "^1.0.220-alpha.2",
|
|
81
|
+
"@budibase/client": "^1.0.220-alpha.2",
|
|
82
|
+
"@budibase/pro": "1.0.220-alpha.1",
|
|
83
|
+
"@budibase/string-templates": "^1.0.220-alpha.2",
|
|
84
84
|
"@bull-board/api": "3.7.0",
|
|
85
85
|
"@bull-board/koa": "3.9.4",
|
|
86
86
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
"pouchdb-replication-stream": "1.2.9",
|
|
136
136
|
"redis": "4",
|
|
137
137
|
"server-destroy": "1.0.1",
|
|
138
|
+
"snowflake-promise": "^4.5.0",
|
|
138
139
|
"svelte": "3.44.1",
|
|
139
140
|
"swagger-parser": "10.0.3",
|
|
140
141
|
"to-json-schema": "0.2.5",
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
"@babel/core": "7.17.4",
|
|
151
152
|
"@babel/preset-env": "7.16.11",
|
|
152
153
|
"@budibase/standard-components": "^0.9.139",
|
|
153
|
-
"@budibase/types": "^1.0.
|
|
154
|
+
"@budibase/types": "^1.0.220-alpha.2",
|
|
154
155
|
"@jest/test-sequencer": "24.9.0",
|
|
155
156
|
"@types/apidoc": "0.50.0",
|
|
156
157
|
"@types/bson": "4.2.0",
|
|
@@ -194,5 +195,5 @@
|
|
|
194
195
|
"optionalDependencies": {
|
|
195
196
|
"oracledb": "5.3.0"
|
|
196
197
|
},
|
|
197
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "80b7a2da2fba39ff25622873c95598fa931ea6ed"
|
|
198
199
|
}
|
package/scripts/dev/manage.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Must be root to continue
|
|
4
|
+
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
|
|
5
|
+
|
|
6
|
+
# Allow for re-runs
|
|
7
|
+
rm -rf /opt/oracle
|
|
8
|
+
|
|
9
|
+
echo "Installing oracle instant client"
|
|
10
|
+
|
|
11
|
+
# copy and unzip package
|
|
12
|
+
mkdir -p /opt/oracle
|
|
13
|
+
cp scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip /opt/oracle
|
|
14
|
+
cd /opt/oracle
|
|
15
|
+
unzip -qq basiclite-19.10.zip -d .
|
|
16
|
+
rm *.zip
|
|
17
|
+
mv instantclient* instantclient
|
|
18
|
+
|
|
19
|
+
# update runtime link path
|
|
20
|
+
sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf"
|
|
21
|
+
ldconfig /etc/ld.so.conf.d
|
|
22
|
+
|
|
23
|
+
echo "Installation complete"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"
|
|
3
|
+
if [[ $TARGETARCH == arm* ]] ;
|
|
4
|
+
then
|
|
5
|
+
echo "Installing ARM Oracle instant client..."
|
|
6
|
+
$SCRIPT_DIR/arm64/install.sh
|
|
7
|
+
else
|
|
8
|
+
echo "Installing x86-64 Oracle instant client..."
|
|
9
|
+
$SCRIPT_DIR/x86-64/install.sh
|
|
10
|
+
fi
|
package/specs/openapi.json
CHANGED
|
@@ -2137,6 +2137,10 @@
|
|
|
2137
2137
|
"query": {
|
|
2138
2138
|
"type": "object",
|
|
2139
2139
|
"properties": {
|
|
2140
|
+
"allOr": {
|
|
2141
|
+
"type": "boolean",
|
|
2142
|
+
"description": "Specifies that a row should be returned if it satisfies any of the specified options, rather than requiring it to fulfill all the search parameters. This defaults to false, meaning AND logic will be used."
|
|
2143
|
+
},
|
|
2140
2144
|
"string": {
|
|
2141
2145
|
"type": "object",
|
|
2142
2146
|
"example": {
|
|
@@ -2155,12 +2159,12 @@
|
|
|
2155
2159
|
},
|
|
2156
2160
|
"range": {
|
|
2157
2161
|
"type": "object",
|
|
2158
|
-
"description": "Searches within a range, the format of this must be
|
|
2162
|
+
"description": "Searches within a range, the format of this must be in the format of an object with a \"low\" and \"high\" property.",
|
|
2159
2163
|
"example": {
|
|
2160
|
-
"columnName1":
|
|
2161
|
-
10,
|
|
2162
|
-
20
|
|
2163
|
-
|
|
2164
|
+
"columnName1": {
|
|
2165
|
+
"low": 10,
|
|
2166
|
+
"high": 20
|
|
2167
|
+
}
|
|
2164
2168
|
}
|
|
2165
2169
|
},
|
|
2166
2170
|
"equal": {
|
package/specs/openapi.yaml
CHANGED
|
@@ -1551,6 +1551,12 @@ paths:
|
|
|
1551
1551
|
query:
|
|
1552
1552
|
type: object
|
|
1553
1553
|
properties:
|
|
1554
|
+
allOr:
|
|
1555
|
+
type: boolean
|
|
1556
|
+
description: Specifies that a row should be returned if it satisfies any of the
|
|
1557
|
+
specified options, rather than requiring it to fulfill
|
|
1558
|
+
all the search parameters. This defaults to false,
|
|
1559
|
+
meaning AND logic will be used.
|
|
1554
1560
|
string:
|
|
1555
1561
|
type: object
|
|
1556
1562
|
example:
|
|
@@ -1566,12 +1572,12 @@ paths:
|
|
|
1566
1572
|
description: A fuzzy search, only supported by internal tables.
|
|
1567
1573
|
range:
|
|
1568
1574
|
type: object
|
|
1569
|
-
description: Searches within a range, the format of this must be
|
|
1570
|
-
|
|
1575
|
+
description: Searches within a range, the format of this must be in the format
|
|
1576
|
+
of an object with a "low" and "high" property.
|
|
1571
1577
|
example:
|
|
1572
1578
|
columnName1:
|
|
1573
|
-
|
|
1574
|
-
|
|
1579
|
+
low: 10
|
|
1580
|
+
high: 20
|
|
1575
1581
|
equal:
|
|
1576
1582
|
type: object
|
|
1577
1583
|
description: Searches for rows that have a column value that is exactly the
|
|
@@ -45,10 +45,12 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
|
45
45
|
import { syncGlobalUsers } from "./user"
|
|
46
46
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
47
47
|
import { cleanupAutomations } from "../../automations/utils"
|
|
48
|
+
import { checkAppMetadata } from "../../automations/logging"
|
|
48
49
|
const {
|
|
49
50
|
getAppDB,
|
|
50
51
|
getProdAppDB,
|
|
51
52
|
updateAppId,
|
|
53
|
+
doInAppContext,
|
|
52
54
|
} = require("@budibase/backend-core/context")
|
|
53
55
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
|
54
56
|
import { quotas } from "@budibase/pro"
|
|
@@ -192,7 +194,7 @@ export const fetch = async (ctx: any) => {
|
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
ctx.body = apps
|
|
197
|
+
ctx.body = await checkAppMetadata(apps)
|
|
196
198
|
}
|
|
197
199
|
|
|
198
200
|
export const fetchAppDefinition = async (ctx: any) => {
|
|
@@ -227,11 +229,7 @@ export const fetchAppPackage = async (ctx: any) => {
|
|
|
227
229
|
application,
|
|
228
230
|
screens,
|
|
229
231
|
layouts,
|
|
230
|
-
clientLibPath: clientLibraryPath(
|
|
231
|
-
ctx.params.appId,
|
|
232
|
-
application.version,
|
|
233
|
-
ctx
|
|
234
|
-
),
|
|
232
|
+
clientLibPath: clientLibraryPath(ctx.params.appId, application.version),
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
|
|
@@ -548,22 +546,24 @@ export const sync = async (ctx: any, next: any) => {
|
|
|
548
546
|
}
|
|
549
547
|
|
|
550
548
|
const updateAppPackage = async (appPackage: any, appId: any) => {
|
|
551
|
-
|
|
552
|
-
|
|
549
|
+
return doInAppContext(appId, async () => {
|
|
550
|
+
const db = getAppDB()
|
|
551
|
+
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
553
552
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
553
|
+
const newAppPackage = { ...application, ...appPackage }
|
|
554
|
+
if (appPackage._rev !== application._rev) {
|
|
555
|
+
newAppPackage._rev = application._rev
|
|
556
|
+
}
|
|
558
557
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
558
|
+
// the locked by property is attached by server but generated from
|
|
559
|
+
// Redis, shouldn't ever store it
|
|
560
|
+
delete newAppPackage.lockedBy
|
|
562
561
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
562
|
+
await db.put(newAppPackage)
|
|
563
|
+
// remove any cached metadata, so that it will be updated
|
|
564
|
+
await appCache.invalidateAppMetadata(appId)
|
|
565
|
+
return newAppPackage
|
|
566
|
+
})
|
|
567
567
|
}
|
|
568
568
|
|
|
569
569
|
const createEmptyAppPackage = async (ctx: any, app: any) => {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const actions = require("../../automations/actions")
|
|
2
2
|
const triggers = require("../../automations/triggers")
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
getAutomationParams,
|
|
5
|
+
generateAutomationID,
|
|
6
|
+
DocumentTypes,
|
|
7
|
+
} = require("../../db/utils")
|
|
4
8
|
const {
|
|
5
9
|
checkForWebhooks,
|
|
6
10
|
updateTestHistory,
|
|
@@ -9,8 +13,14 @@ const {
|
|
|
9
13
|
const { deleteEntityMetadata } = require("../../utilities")
|
|
10
14
|
const { MetadataTypes } = require("../../constants")
|
|
11
15
|
const { setTestFlag, clearTestFlag } = require("../../utilities/redis")
|
|
12
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
getAppDB,
|
|
18
|
+
getProdAppDB,
|
|
19
|
+
doInAppContext,
|
|
20
|
+
} = require("@budibase/backend-core/context")
|
|
13
21
|
const { events } = require("@budibase/backend-core")
|
|
22
|
+
const { app } = require("@budibase/backend-core/cache")
|
|
23
|
+
const { automations } = require("@budibase/pro")
|
|
14
24
|
|
|
15
25
|
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
|
|
16
26
|
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
|
@@ -183,6 +193,29 @@ exports.destroy = async function (ctx) {
|
|
|
183
193
|
await events.automation.deleted(oldAutomation)
|
|
184
194
|
}
|
|
185
195
|
|
|
196
|
+
exports.logSearch = async function (ctx) {
|
|
197
|
+
ctx.body = await automations.logs.logSearch(ctx.request.body)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
exports.clearLogError = async function (ctx) {
|
|
201
|
+
const { automationId, appId } = ctx.request.body
|
|
202
|
+
await doInAppContext(appId, async () => {
|
|
203
|
+
const db = getProdAppDB()
|
|
204
|
+
const metadata = await db.get(DocumentTypes.APP_METADATA)
|
|
205
|
+
if (!automationId) {
|
|
206
|
+
delete metadata.automationErrors
|
|
207
|
+
} else if (
|
|
208
|
+
metadata.automationErrors &&
|
|
209
|
+
metadata.automationErrors[automationId]
|
|
210
|
+
) {
|
|
211
|
+
delete metadata.automationErrors[automationId]
|
|
212
|
+
}
|
|
213
|
+
await db.put(metadata)
|
|
214
|
+
await app.invalidateAppMetadata(metadata.appId, metadata)
|
|
215
|
+
ctx.body = { message: `Error logs cleared.` }
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
186
219
|
exports.getActionList = async function (ctx) {
|
|
187
220
|
ctx.body = ACTION_DEFS
|
|
188
221
|
}
|
|
@@ -3,11 +3,12 @@ const { events, context } = require("@budibase/backend-core")
|
|
|
3
3
|
const { DocumentTypes } = require("../../db/utils")
|
|
4
4
|
|
|
5
5
|
exports.exportAppDump = async function (ctx) {
|
|
6
|
-
|
|
6
|
+
let { appId, excludeRows } = ctx.query
|
|
7
7
|
const appName = decodeURI(ctx.query.appname)
|
|
8
|
+
excludeRows = excludeRows === "true"
|
|
8
9
|
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
|
|
9
10
|
ctx.attachment(backupIdentifier)
|
|
10
|
-
ctx.body = await streamBackup(appId)
|
|
11
|
+
ctx.body = await streamBackup(appId, excludeRows)
|
|
11
12
|
|
|
12
13
|
await context.doInAppContext(appId, async () => {
|
|
13
14
|
const appDb = context.getAppDB()
|
|
@@ -3,12 +3,8 @@ const env = require("../../environment")
|
|
|
3
3
|
const { checkSlashesInUrl } = require("../../utilities")
|
|
4
4
|
const { request } = require("../../utilities/workerRequests")
|
|
5
5
|
const { clearLock } = require("../../utilities/redis")
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
getProdAppID,
|
|
9
|
-
dangerousGetDB,
|
|
10
|
-
} = require("@budibase/backend-core/db")
|
|
11
|
-
const { DocumentTypes, getRowParams } = require("../../db/utils")
|
|
6
|
+
const { Replication, getProdAppID } = require("@budibase/backend-core/db")
|
|
7
|
+
const { DocumentTypes } = require("../../db/utils")
|
|
12
8
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
13
9
|
const { getProdAppDB, getAppDB } = require("@budibase/backend-core/context")
|
|
14
10
|
const { events } = require("@budibase/backend-core")
|
|
@@ -137,50 +133,3 @@ exports.getBudibaseVersion = async ctx => {
|
|
|
137
133
|
}
|
|
138
134
|
await events.installation.versionChecked(version)
|
|
139
135
|
}
|
|
140
|
-
|
|
141
|
-
// TODO: remove as part of beta program
|
|
142
|
-
exports.checkBetaAccess = async ctx => {
|
|
143
|
-
// go to the cloud platform if running self hosted
|
|
144
|
-
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
145
|
-
let baseUrl = ""
|
|
146
|
-
if (env.ACCOUNT_PORTAL_URL) {
|
|
147
|
-
baseUrl = env.ACCOUNT_PORTAL_URL.replace("account.", "")
|
|
148
|
-
} else {
|
|
149
|
-
baseUrl = "https://budibase.app"
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const response = await fetch(
|
|
153
|
-
`${baseUrl}/api/beta/access?email=${ctx.query.email}`
|
|
154
|
-
)
|
|
155
|
-
const json = await response.json()
|
|
156
|
-
ctx.body = json
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const userToCheck = ctx.query.email
|
|
161
|
-
const BETA_USERS_DB = "app_bb_f9b77d06b9db4e3ca185476ab87a2364"
|
|
162
|
-
const BETA_USERS_TABLE = "ta_8c2c6df1c03f49cfb6340e85e066dd15"
|
|
163
|
-
|
|
164
|
-
try {
|
|
165
|
-
const db = dangerousGetDB(BETA_USERS_DB)
|
|
166
|
-
const betaUsers = (
|
|
167
|
-
await db.allDocs(
|
|
168
|
-
getRowParams(BETA_USERS_TABLE, null, {
|
|
169
|
-
include_docs: true,
|
|
170
|
-
})
|
|
171
|
-
)
|
|
172
|
-
).rows.map(row => row.doc)
|
|
173
|
-
|
|
174
|
-
let access = false
|
|
175
|
-
for (let betaUser of betaUsers) {
|
|
176
|
-
if (betaUser["Email address"].trim() === userToCheck) {
|
|
177
|
-
access = true
|
|
178
|
-
break
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
ctx.body = { access }
|
|
182
|
-
} catch (err) {
|
|
183
|
-
console.error(err)
|
|
184
|
-
ctx.body = { access: false }
|
|
185
|
-
}
|
|
186
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { getAllApps } = require("@budibase/backend-core/db")
|
|
2
2
|
const { updateAppId } = require("@budibase/backend-core/context")
|
|
3
|
-
import { search as stringSearch } from "./utils"
|
|
3
|
+
import { search as stringSearch, addRev } from "./utils"
|
|
4
4
|
import * as controller from "../application"
|
|
5
5
|
import { Application } from "../../../definitions/common"
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ export async function read(ctx: any, next: any) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export async function update(ctx: any, next: any) {
|
|
50
|
-
ctx.request.body = fixAppID(ctx.request.body, ctx.params)
|
|
50
|
+
ctx.request.body = await addRev(fixAppID(ctx.request.body, ctx.params))
|
|
51
51
|
updateAppId(ctx.params.appId)
|
|
52
52
|
await controller.update(ctx)
|
|
53
53
|
await setResponseApp(ctx)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
2
2
|
import { isExternalTable } from "../../../integrations/utils"
|
|
3
|
+
import { APP_PREFIX, DocumentTypes } from "../../../db/utils"
|
|
3
4
|
|
|
4
5
|
export async function addRev(
|
|
5
6
|
body: { _id?: string; _rev?: string },
|
|
@@ -8,9 +9,15 @@ export async function addRev(
|
|
|
8
9
|
if (!body._id || (tableId && isExternalTable(tableId))) {
|
|
9
10
|
return body
|
|
10
11
|
}
|
|
12
|
+
let id = body._id
|
|
13
|
+
if (body._id.startsWith(APP_PREFIX)) {
|
|
14
|
+
id = DocumentTypes.APP_METADATA
|
|
15
|
+
}
|
|
11
16
|
const db = getAppDB()
|
|
12
|
-
const dbDoc = await db.get(
|
|
17
|
+
const dbDoc = await db.get(id)
|
|
13
18
|
body._rev = dbDoc._rev
|
|
19
|
+
// update ID in case it is an app ID
|
|
20
|
+
body._id = id
|
|
14
21
|
return body
|
|
15
22
|
}
|
|
16
23
|
|
|
@@ -8,6 +8,8 @@ import { QUERY_THREAD_TIMEOUT } from "../../../environment"
|
|
|
8
8
|
import { getAppDB } from "@budibase/backend-core/context"
|
|
9
9
|
import { quotas } from "@budibase/pro"
|
|
10
10
|
import { events } from "@budibase/backend-core"
|
|
11
|
+
import { getCookie } from "@budibase/backend-core/utils"
|
|
12
|
+
import { Cookies, Configs } from "@budibase/backend-core/constants"
|
|
11
13
|
|
|
12
14
|
const Runner = new Thread(ThreadType.QUERY, {
|
|
13
15
|
timeoutMs: QUERY_THREAD_TIMEOUT || 10000,
|
|
@@ -110,6 +112,21 @@ export async function find(ctx: any) {
|
|
|
110
112
|
ctx.body = query
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
//Required to discern between OIDC OAuth config entries
|
|
116
|
+
function getOAuthConfigCookieId(ctx: any) {
|
|
117
|
+
if (ctx.user.providerType === Configs.OIDC) {
|
|
118
|
+
return getCookie(ctx, Cookies.OIDC_CONFIG)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getAuthConfig(ctx: any) {
|
|
123
|
+
const authCookie = getCookie(ctx, Cookies.Auth)
|
|
124
|
+
let authConfigCtx: any = {}
|
|
125
|
+
authConfigCtx["configId"] = getOAuthConfigCookieId(ctx)
|
|
126
|
+
authConfigCtx["sessionId"] = authCookie ? authCookie.sessionId : null
|
|
127
|
+
return authConfigCtx
|
|
128
|
+
}
|
|
129
|
+
|
|
113
130
|
export async function preview(ctx: any) {
|
|
114
131
|
const db = getAppDB()
|
|
115
132
|
|
|
@@ -119,6 +136,8 @@ export async function preview(ctx: any) {
|
|
|
119
136
|
// this stops dynamic variables from calling the same query
|
|
120
137
|
const { fields, parameters, queryVerb, transformer, queryId } = query
|
|
121
138
|
|
|
139
|
+
const authConfigCtx: any = getAuthConfig(ctx)
|
|
140
|
+
|
|
122
141
|
try {
|
|
123
142
|
const runFn = () =>
|
|
124
143
|
Runner.run({
|
|
@@ -129,8 +148,11 @@ export async function preview(ctx: any) {
|
|
|
129
148
|
parameters,
|
|
130
149
|
transformer,
|
|
131
150
|
queryId,
|
|
151
|
+
ctx: {
|
|
152
|
+
user: ctx.user,
|
|
153
|
+
auth: { ...authConfigCtx },
|
|
154
|
+
},
|
|
132
155
|
})
|
|
133
|
-
|
|
134
156
|
const { rows, keys, info, extra } = await quotas.addQuery(runFn)
|
|
135
157
|
await events.query.previewed(datasource, query)
|
|
136
158
|
ctx.body = {
|
|
@@ -144,12 +166,19 @@ export async function preview(ctx: any) {
|
|
|
144
166
|
}
|
|
145
167
|
}
|
|
146
168
|
|
|
147
|
-
async function execute(
|
|
169
|
+
async function execute(
|
|
170
|
+
ctx: any,
|
|
171
|
+
opts: any = { rowsOnly: false, isAutomation: false }
|
|
172
|
+
) {
|
|
148
173
|
const db = getAppDB()
|
|
149
174
|
|
|
150
175
|
const query = await db.get(ctx.params.queryId)
|
|
151
176
|
const datasource = await db.get(query.datasourceId)
|
|
152
177
|
|
|
178
|
+
let authConfigCtx: any = {}
|
|
179
|
+
if (!opts.isAutomation) {
|
|
180
|
+
authConfigCtx = getAuthConfig(ctx)
|
|
181
|
+
}
|
|
153
182
|
const enrichedParameters = ctx.request.body.parameters || {}
|
|
154
183
|
// make sure parameters are fully enriched with defaults
|
|
155
184
|
if (query && query.parameters) {
|
|
@@ -172,6 +201,10 @@ async function execute(ctx: any, opts = { rowsOnly: false }) {
|
|
|
172
201
|
parameters: enrichedParameters,
|
|
173
202
|
transformer: query.transformer,
|
|
174
203
|
queryId: ctx.params.queryId,
|
|
204
|
+
ctx: {
|
|
205
|
+
user: ctx.user,
|
|
206
|
+
auth: { ...authConfigCtx },
|
|
207
|
+
},
|
|
175
208
|
})
|
|
176
209
|
|
|
177
210
|
const { rows, pagination, extra } = await quotas.addQuery(runFn)
|
|
@@ -189,8 +222,11 @@ export async function executeV1(ctx: any) {
|
|
|
189
222
|
return execute(ctx, { rowsOnly: true })
|
|
190
223
|
}
|
|
191
224
|
|
|
192
|
-
export async function executeV2(
|
|
193
|
-
|
|
225
|
+
export async function executeV2(
|
|
226
|
+
ctx: any,
|
|
227
|
+
{ isAutomation }: { isAutomation?: boolean } = {}
|
|
228
|
+
) {
|
|
229
|
+
return execute(ctx, { rowsOnly: false, isAutomation })
|
|
194
230
|
}
|
|
195
231
|
|
|
196
232
|
const removeDynamicVariables = async (queryId: any) => {
|
|
@@ -155,34 +155,44 @@ exports.validate = async () => {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
exports.exportRows = async ctx => {
|
|
158
|
-
const { datasourceId
|
|
158
|
+
const { datasourceId } = breakExternalTableId(ctx.params.tableId)
|
|
159
159
|
const db = getAppDB()
|
|
160
|
-
|
|
160
|
+
const format = ctx.query.format
|
|
161
|
+
const { columns } = ctx.request.body
|
|
161
162
|
const datasource = await db.get(datasourceId)
|
|
162
163
|
if (!datasource || !datasource.entities) {
|
|
163
164
|
ctx.throw(400, "Datasource has not been configured for plus API.")
|
|
164
165
|
}
|
|
165
|
-
const tables = datasource.entities
|
|
166
|
-
const table = tables[tableName]
|
|
167
166
|
ctx.request.body = {
|
|
168
167
|
query: {
|
|
169
168
|
oneOf: {
|
|
170
|
-
|
|
171
|
-
id => breakRowIdField(id)[0]
|
|
172
|
-
),
|
|
169
|
+
_id: ctx.request.body.rows.map(row => JSON.parse(decodeURI(row))[0]),
|
|
173
170
|
},
|
|
174
171
|
},
|
|
175
172
|
}
|
|
176
173
|
|
|
177
174
|
let result = await exports.search(ctx)
|
|
175
|
+
let rows = []
|
|
176
|
+
|
|
177
|
+
// Filter data to only specified columns if required
|
|
178
|
+
if (columns && columns.length) {
|
|
179
|
+
for (let i = 0; i < result.rows.length; i++) {
|
|
180
|
+
rows[i] = {}
|
|
181
|
+
for (let column of columns) {
|
|
182
|
+
rows[i][column] = result.rows[i][column]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
rows = result.rows
|
|
187
|
+
}
|
|
178
188
|
|
|
179
|
-
let headers = Object.keys(
|
|
189
|
+
let headers = Object.keys(rows[0])
|
|
180
190
|
const exporter = exporters[format]
|
|
181
191
|
const filename = `export.${format}`
|
|
182
192
|
|
|
183
193
|
// send down the file
|
|
184
194
|
ctx.attachment(filename)
|
|
185
|
-
return apiFileReturn(exporter(headers,
|
|
195
|
+
return apiFileReturn(exporter(headers, rows))
|
|
186
196
|
}
|
|
187
197
|
|
|
188
198
|
exports.fetchEnrichedRow = async ctx => {
|