@budibase/server 1.0.27-alpha.10 → 1.0.27-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{index.0dce895b.css → index.39e01193.css} +1 -1
- package/builder/assets/{index.39751e34.js → index.411e6960.js} +239 -239
- package/builder/index.html +2 -2
- package/coverage/clover.xml +909 -890
- package/coverage/coverage-final.json +68 -68
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +3 -3
- package/coverage/lcov-report/api/controllers/application.js.html +71 -62
- package/coverage/lcov-report/api/controllers/auth.js.html +2 -2
- 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 +13 -4
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +138 -36
- package/coverage/lcov-report/api/controllers/dev.js.html +3 -3
- package/coverage/lcov-report/api/controllers/hosting.js.html +3 -3
- package/coverage/lcov-report/api/controllers/index.html +19 -19
- 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 +3 -3
- package/coverage/lcov-report/api/controllers/query/index.html +21 -21
- package/coverage/lcov-report/api/controllers/query/index.js.html +51 -48
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +2 -2
- package/coverage/lcov-report/api/controllers/routing.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +2 -2
- 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 +14 -5
- 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 +2 -2
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +6 -6
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +2 -2
- package/coverage/lcov-report/api/routes/application.js.html +2 -2
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +2 -2
- package/coverage/lcov-report/api/routes/backup.js.html +2 -2
- package/coverage/lcov-report/api/routes/cloud.js.html +2 -2
- package/coverage/lcov-report/api/routes/component.js.html +2 -2
- package/coverage/lcov-report/api/routes/datasource.js.html +2 -2
- package/coverage/lcov-report/api/routes/deploy.js.html +2 -2
- package/coverage/lcov-report/api/routes/dev.js.html +2 -2
- package/coverage/lcov-report/api/routes/hosting.js.html +2 -2
- 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 +2 -2
- package/coverage/lcov-report/api/routes/layout.js.html +2 -2
- package/coverage/lcov-report/api/routes/metadata.js.html +2 -2
- package/coverage/lcov-report/api/routes/permission.js.html +12 -3
- package/coverage/lcov-report/api/routes/query.js.html +2 -2
- package/coverage/lcov-report/api/routes/role.js.html +2 -2
- package/coverage/lcov-report/api/routes/routing.js.html +2 -2
- package/coverage/lcov-report/api/routes/row.js.html +2 -2
- package/coverage/lcov-report/api/routes/screen.js.html +2 -2
- package/coverage/lcov-report/api/routes/script.js.html +2 -2
- package/coverage/lcov-report/api/routes/static.js.html +2 -2
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +2 -2
- package/coverage/lcov-report/api/routes/user.js.html +2 -2
- package/coverage/lcov-report/api/routes/view.js.html +2 -2
- package/coverage/lcov-report/api/routes/webhook.js.html +2 -2
- 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 +2 -2
- 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 +2 -2
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/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 +6 -6
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +4 -4
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +2 -2
- package/coverage/lcov-report/db/client.js.html +2 -2
- 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 +19 -19
- 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 +38 -38
- 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 +11 -11
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +48 -36
- 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 +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +2 -2
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +3 -3
- package/coverage/lcov-report/threads/index.html +28 -28
- package/coverage/lcov-report/threads/index.js.html +12 -12
- package/coverage/lcov-report/threads/query.js.html +253 -85
- package/coverage/lcov-report/threads/utils.js.html +31 -181
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +2 -2
- 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 +27 -18
- package/coverage/lcov-report/utilities/index.html +4 -4
- package/coverage/lcov-report/utilities/index.js.html +13 -13
- 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 +15 -3
- 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 +13 -4
- 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 +22 -22
- package/coverage/lcov.info +1566 -1528
- package/dist/api/controllers/apikeys.js +2 -2
- package/dist/api/controllers/application.js +4 -4
- package/dist/api/controllers/auth.js +1 -1
- package/dist/api/controllers/cloud.js +2 -2
- package/dist/api/controllers/datasource.js +29 -0
- package/dist/api/controllers/deploy/index.js +2 -2
- package/dist/api/controllers/dev.js +2 -2
- package/dist/api/controllers/hosting.js +2 -2
- package/dist/api/controllers/permission.js +2 -2
- package/dist/api/controllers/query/index.js +3 -2
- package/dist/api/controllers/role.js +1 -1
- package/dist/api/controllers/routing.js +1 -1
- package/dist/api/controllers/row/internalSearch.js +1 -1
- package/dist/api/controllers/screen.js +1 -1
- package/dist/api/controllers/user.js +3 -3
- package/dist/api/controllers/webhook.js +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes/apikeys.js +1 -1
- package/dist/api/routes/application.js +1 -1
- package/dist/api/routes/automation.js +1 -1
- package/dist/api/routes/backup.js +1 -1
- package/dist/api/routes/cloud.js +1 -1
- package/dist/api/routes/component.js +1 -1
- package/dist/api/routes/datasource.js +1 -1
- package/dist/api/routes/deploy.js +1 -1
- package/dist/api/routes/dev.js +1 -1
- package/dist/api/routes/hosting.js +1 -1
- package/dist/api/routes/integration.js +1 -1
- package/dist/api/routes/layout.js +1 -1
- package/dist/api/routes/metadata.js +1 -1
- package/dist/api/routes/permission.js +1 -1
- package/dist/api/routes/query.js +1 -1
- package/dist/api/routes/role.js +1 -1
- package/dist/api/routes/routing.js +1 -1
- package/dist/api/routes/row.js +1 -1
- package/dist/api/routes/screen.js +1 -1
- package/dist/api/routes/script.js +1 -1
- package/dist/api/routes/static.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/templates.js +1 -1
- package/dist/api/routes/tests/utilities/TestFunctions.js +1 -1
- package/dist/api/routes/user.js +1 -1
- package/dist/api/routes/view.js +1 -1
- package/dist/api/routes/webhook.js +1 -1
- package/dist/app.js +1 -1
- package/dist/automations/bullboard.js +1 -1
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/automations/utils.js +1 -1
- package/dist/constants/index.js +3 -3
- package/dist/constants/screens.js +1 -1
- package/dist/db/client.js +1 -1
- package/dist/db/utils.js +1 -1
- package/dist/environment.js +1 -0
- package/dist/integrations/dynamodb.js +19 -0
- package/dist/integrations/rest.js +68 -19
- package/dist/integrations/s3.js +17 -8
- package/dist/middleware/authorized.js +2 -2
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +6 -6
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +4 -4
- package/dist/tests/utilities/TestConfiguration.js +48 -8
- package/dist/tests/utilities/structures.js +2 -2
- package/dist/threads/automation.js +2 -2
- package/dist/threads/query.js +52 -3
- package/dist/threads/utils.js +3 -47
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +1 -1
- package/dist/utilities/fileSystem/utilities.js +1 -1
- package/dist/utilities/global.js +5 -5
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/redis.js +1 -1
- package/dist/utilities/rowProcessor/index.js +1 -1
- package/dist/utilities/security.js +2 -2
- package/dist/utilities/usageQuota.js +2 -2
- package/dist/utilities/workerRequests.js +3 -3
- package/package.json +5 -5
- package/scripts/replicateApp.js +1 -1
- package/src/api/controllers/apikeys.js +2 -2
- package/src/api/controllers/application.js +7 -4
- package/src/api/controllers/auth.js +1 -1
- package/src/api/controllers/cloud.js +5 -2
- package/src/api/controllers/datasource.js +34 -0
- package/src/api/controllers/deploy/index.js +2 -2
- package/src/api/controllers/dev.js +2 -2
- package/src/api/controllers/hosting.js +2 -2
- package/src/api/controllers/permission.js +2 -2
- package/src/api/controllers/query/index.js +3 -2
- package/src/api/controllers/role.js +1 -1
- package/src/api/controllers/routing.js +1 -1
- package/src/api/controllers/row/internalSearch.js +1 -1
- package/src/api/controllers/screen.js +1 -1
- package/src/api/controllers/user.js +6 -3
- package/src/api/controllers/webhook.js +1 -1
- package/src/api/index.js +1 -1
- package/src/api/routes/apikeys.js +1 -1
- package/src/api/routes/application.js +1 -1
- package/src/api/routes/automation.js +1 -1
- package/src/api/routes/backup.js +1 -1
- package/src/api/routes/cloud.js +1 -1
- package/src/api/routes/component.js +1 -1
- package/src/api/routes/datasource.js +1 -1
- package/src/api/routes/deploy.js +1 -1
- package/src/api/routes/dev.js +1 -1
- package/src/api/routes/hosting.js +1 -1
- package/src/api/routes/integration.js +1 -1
- package/src/api/routes/layout.js +1 -1
- package/src/api/routes/metadata.js +1 -1
- package/src/api/routes/permission.js +4 -1
- package/src/api/routes/query.js +1 -1
- package/src/api/routes/role.js +1 -1
- package/src/api/routes/routing.js +1 -1
- package/src/api/routes/row.js +1 -1
- package/src/api/routes/screen.js +1 -1
- package/src/api/routes/script.js +1 -1
- package/src/api/routes/static.js +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/templates.js +1 -1
- package/src/api/routes/tests/datasource.spec.js +45 -0
- package/src/api/routes/tests/permissions.spec.js +1 -1
- package/src/api/routes/tests/query.spec.js +25 -44
- package/src/api/routes/tests/role.spec.js +2 -2
- package/src/api/routes/tests/routing.spec.js +1 -1
- package/src/api/routes/tests/user.spec.js +1 -1
- package/src/api/routes/tests/utilities/TestFunctions.js +1 -1
- package/src/api/routes/user.js +1 -1
- package/src/api/routes/view.js +1 -1
- package/src/api/routes/webhook.js +1 -1
- package/src/app.ts +1 -1
- package/src/automations/bullboard.js +1 -1
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/utils.js +1 -1
- package/src/constants/index.js +3 -3
- package/src/constants/screens.js +1 -1
- package/src/db/client.js +1 -1
- package/src/db/utils.js +1 -1
- package/src/definitions/datasource.ts +15 -0
- package/src/environment.js +1 -0
- package/src/integrations/dynamodb.ts +18 -0
- package/src/integrations/rest.ts +78 -17
- package/src/integrations/s3.ts +18 -7
- package/src/integrations/tests/rest.spec.js +287 -24
- package/src/middleware/authorized.js +2 -2
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +11 -7
- package/src/middleware/tests/authorized.spec.js +2 -2
- package/src/middleware/tests/currentapp.spec.js +35 -41
- package/src/middleware/tests/usageQuota.spec.js +1 -1
- package/src/middleware/usageQuota.js +1 -1
- package/src/tests/utilities/TestConfiguration.js +55 -8
- package/src/tests/utilities/structures.js +2 -2
- package/src/threads/automation.js +2 -2
- package/src/threads/query.js +59 -3
- package/src/threads/utils.js +3 -53
- package/src/utilities/budibaseDir.js +1 -1
- package/src/utilities/fileSystem/utilities.js +1 -1
- package/src/utilities/global.js +8 -5
- package/src/utilities/index.js +2 -2
- package/src/utilities/redis.js +1 -1
- package/src/utilities/rowProcessor/index.js +5 -1
- package/src/utilities/security.js +5 -2
- package/src/utilities/usageQuota.js +2 -2
- package/src/utilities/workerRequests.js +3 -3
package/dist/db/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const PouchDB = require("pouchdb");
|
|
3
|
-
const { getCouchUrl } = require("@budibase/
|
|
3
|
+
const { getCouchUrl } = require("@budibase/backend-core/db");
|
|
4
4
|
const replicationStream = require("pouchdb-replication-stream");
|
|
5
5
|
const allDbs = require("pouchdb-all-dbs");
|
|
6
6
|
const find = require("pouchdb-find");
|
package/dist/db/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const newid = require("./newid");
|
|
3
|
-
const { DocumentTypes: CoreDocTypes, getRoleParams, generateRoleID, APP_DEV_PREFIX, APP_PREFIX, SEPARATOR, StaticDatabases, isDevAppID, isProdAppID, } = require("@budibase/
|
|
3
|
+
const { DocumentTypes: CoreDocTypes, getRoleParams, generateRoleID, APP_DEV_PREFIX, APP_PREFIX, SEPARATOR, StaticDatabases, isDevAppID, isProdAppID, } = require("@budibase/backend-core/db");
|
|
4
4
|
const UNICODE_MAX = "\ufff0";
|
|
5
5
|
const AppStatus = {
|
|
6
6
|
DEV: "development",
|
package/dist/environment.js
CHANGED
|
@@ -57,6 +57,7 @@ module.exports = {
|
|
|
57
57
|
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
|
|
58
58
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
59
59
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
|
60
|
+
QUERY_THREAD_TIMEOUT: process.env.QUERY_THREAD_TIMEOUT,
|
|
60
61
|
_set(key, value) {
|
|
61
62
|
process.env[key] = value;
|
|
62
63
|
module.exports[key] = value;
|
|
@@ -77,6 +77,17 @@ var DynamoModule;
|
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
|
+
describe: {
|
|
81
|
+
type: datasource_1.QueryTypes.FIELDS,
|
|
82
|
+
customisable: true,
|
|
83
|
+
readable: true,
|
|
84
|
+
fields: {
|
|
85
|
+
table: {
|
|
86
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
87
|
+
required: true,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
80
91
|
get: {
|
|
81
92
|
type: datasource_1.QueryTypes.FIELDS,
|
|
82
93
|
customisable: true,
|
|
@@ -161,6 +172,14 @@ var DynamoModule;
|
|
|
161
172
|
return response;
|
|
162
173
|
});
|
|
163
174
|
}
|
|
175
|
+
describe(query) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
const params = {
|
|
178
|
+
TableName: query.table,
|
|
179
|
+
};
|
|
180
|
+
return new AWS.DynamoDB().describeTable(params).promise();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
164
183
|
get(query) {
|
|
165
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
185
|
const params = Object.assign({ TableName: query.table }, query.json);
|
|
@@ -39,6 +39,9 @@ const coreFields = {
|
|
|
39
39
|
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
40
40
|
enum: Object.values(BodyTypes),
|
|
41
41
|
},
|
|
42
|
+
pagination: {
|
|
43
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT
|
|
44
|
+
}
|
|
42
45
|
};
|
|
43
46
|
var RestModule;
|
|
44
47
|
(function (RestModule) {
|
|
@@ -103,7 +106,7 @@ var RestModule;
|
|
|
103
106
|
this.startTimeMs = performance.now();
|
|
104
107
|
this.config = config;
|
|
105
108
|
}
|
|
106
|
-
parseResponse(response) {
|
|
109
|
+
parseResponse(response, pagination) {
|
|
107
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
111
|
let data, raw, headers;
|
|
109
112
|
const contentType = response.headers.get("content-type") || "";
|
|
@@ -142,6 +145,11 @@ var RestModule;
|
|
|
142
145
|
for (let [key, value] of Object.entries(headers)) {
|
|
143
146
|
headers[key] = Array.isArray(value) ? value[0] : value;
|
|
144
147
|
}
|
|
148
|
+
// Check if a pagination cursor exists in the response
|
|
149
|
+
let nextCursor = null;
|
|
150
|
+
if (pagination === null || pagination === void 0 ? void 0 : pagination.responseParam) {
|
|
151
|
+
nextCursor = data === null || data === void 0 ? void 0 : data[pagination.responseParam];
|
|
152
|
+
}
|
|
145
153
|
return {
|
|
146
154
|
data,
|
|
147
155
|
info: {
|
|
@@ -153,10 +161,31 @@ var RestModule;
|
|
|
153
161
|
raw,
|
|
154
162
|
headers,
|
|
155
163
|
},
|
|
164
|
+
pagination: {
|
|
165
|
+
cursor: nextCursor
|
|
166
|
+
}
|
|
156
167
|
};
|
|
157
168
|
});
|
|
158
169
|
}
|
|
159
|
-
getUrl(path, queryString) {
|
|
170
|
+
getUrl(path, queryString, pagination, paginationValues) {
|
|
171
|
+
// Add pagination params to query string if required
|
|
172
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.location) === "query" && paginationValues) {
|
|
173
|
+
const { pageParam, sizeParam } = pagination;
|
|
174
|
+
const params = new URLSearchParams();
|
|
175
|
+
// Append page number or cursor param if configured
|
|
176
|
+
if (pageParam && paginationValues.page != null) {
|
|
177
|
+
params.append(pageParam, paginationValues.page);
|
|
178
|
+
}
|
|
179
|
+
// Append page size param if configured
|
|
180
|
+
if (sizeParam && paginationValues.limit != null) {
|
|
181
|
+
params.append(sizeParam, paginationValues.limit);
|
|
182
|
+
}
|
|
183
|
+
// Prepend query string with pagination params
|
|
184
|
+
let paginationString = params.toString();
|
|
185
|
+
if (paginationString) {
|
|
186
|
+
queryString = `${paginationString}&${queryString}`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
160
189
|
const main = `${path}?${queryString}`;
|
|
161
190
|
let complete = main;
|
|
162
191
|
if (this.config.url && !main.startsWith("http")) {
|
|
@@ -167,21 +196,35 @@ var RestModule;
|
|
|
167
196
|
}
|
|
168
197
|
return complete;
|
|
169
198
|
}
|
|
170
|
-
addBody(bodyType, body, input) {
|
|
171
|
-
|
|
199
|
+
addBody(bodyType, body, input, pagination, paginationValues) {
|
|
200
|
+
if (!input.headers) {
|
|
201
|
+
input.headers = {};
|
|
202
|
+
}
|
|
203
|
+
if (bodyType === BodyTypes.NONE) {
|
|
204
|
+
return input;
|
|
205
|
+
}
|
|
206
|
+
let error, object = {}, string = "";
|
|
172
207
|
try {
|
|
173
|
-
|
|
174
|
-
|
|
208
|
+
if (body) {
|
|
209
|
+
string = typeof body !== "string" ? JSON.stringify(body) : body;
|
|
210
|
+
object = typeof body === "object" ? body : JSON.parse(body);
|
|
211
|
+
}
|
|
175
212
|
}
|
|
176
213
|
catch (err) {
|
|
177
214
|
error = err;
|
|
178
215
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
216
|
+
// Util to add pagination values to a certain body type
|
|
217
|
+
const addPaginationToBody = (insertFn) => {
|
|
218
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.location) === "body") {
|
|
219
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.pageParam) && (paginationValues === null || paginationValues === void 0 ? void 0 : paginationValues.page) != null) {
|
|
220
|
+
insertFn(pagination.pageParam, paginationValues.page);
|
|
221
|
+
}
|
|
222
|
+
if ((pagination === null || pagination === void 0 ? void 0 : pagination.sizeParam) && (paginationValues === null || paginationValues === void 0 ? void 0 : paginationValues.limit) != null) {
|
|
223
|
+
insertFn(pagination.sizeParam, paginationValues.limit);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
182
227
|
switch (bodyType) {
|
|
183
|
-
case BodyTypes.NONE:
|
|
184
|
-
break;
|
|
185
228
|
case BodyTypes.TEXT:
|
|
186
229
|
// content type defaults to plaintext
|
|
187
230
|
input.body = string;
|
|
@@ -191,6 +234,9 @@ var RestModule;
|
|
|
191
234
|
for (let [key, value] of Object.entries(object)) {
|
|
192
235
|
params.append(key, value);
|
|
193
236
|
}
|
|
237
|
+
addPaginationToBody((key, value) => {
|
|
238
|
+
params.append(key, value);
|
|
239
|
+
});
|
|
194
240
|
input.body = params;
|
|
195
241
|
break;
|
|
196
242
|
case BodyTypes.FORM_DATA:
|
|
@@ -198,6 +244,9 @@ var RestModule;
|
|
|
198
244
|
for (let [key, value] of Object.entries(object)) {
|
|
199
245
|
form.append(key, value);
|
|
200
246
|
}
|
|
247
|
+
addPaginationToBody((key, value) => {
|
|
248
|
+
form.append(key, value);
|
|
249
|
+
});
|
|
201
250
|
input.body = form;
|
|
202
251
|
break;
|
|
203
252
|
case BodyTypes.XML:
|
|
@@ -207,13 +256,15 @@ var RestModule;
|
|
|
207
256
|
input.body = string;
|
|
208
257
|
input.headers["Content-Type"] = "application/xml";
|
|
209
258
|
break;
|
|
210
|
-
default:
|
|
211
259
|
case BodyTypes.JSON:
|
|
212
260
|
// if JSON error, throw it
|
|
213
261
|
if (error) {
|
|
214
262
|
throw "Invalid JSON for request body";
|
|
215
263
|
}
|
|
216
|
-
|
|
264
|
+
addPaginationToBody((key, value) => {
|
|
265
|
+
object[key] = value;
|
|
266
|
+
});
|
|
267
|
+
input.body = JSON.stringify(object);
|
|
217
268
|
input.headers["Content-Type"] = "application/json";
|
|
218
269
|
break;
|
|
219
270
|
}
|
|
@@ -243,7 +294,7 @@ var RestModule;
|
|
|
243
294
|
}
|
|
244
295
|
_req(query) {
|
|
245
296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
-
const { path = "", queryString = "", headers = {}, method = "GET", disabledHeaders, bodyType, requestBody, authConfigId, } = query;
|
|
297
|
+
const { path = "", queryString = "", headers = {}, method = "GET", disabledHeaders, bodyType, requestBody, authConfigId, pagination, paginationValues } = query;
|
|
247
298
|
const authHeaders = this.getAuthHeaders(authConfigId);
|
|
248
299
|
this.headers = Object.assign(Object.assign(Object.assign({}, this.config.defaultHeaders), headers), authHeaders);
|
|
249
300
|
if (disabledHeaders) {
|
|
@@ -254,13 +305,11 @@ var RestModule;
|
|
|
254
305
|
}
|
|
255
306
|
}
|
|
256
307
|
let input = { method, headers: this.headers };
|
|
257
|
-
|
|
258
|
-
input = this.addBody(bodyType, requestBody, input);
|
|
259
|
-
}
|
|
308
|
+
input = this.addBody(bodyType, requestBody, input, pagination, paginationValues);
|
|
260
309
|
this.startTimeMs = performance.now();
|
|
261
|
-
const url = this.getUrl(path, queryString);
|
|
310
|
+
const url = this.getUrl(path, queryString, pagination, paginationValues);
|
|
262
311
|
const response = yield fetch(url, input);
|
|
263
|
-
return yield this.parseResponse(response);
|
|
312
|
+
return yield this.parseResponse(response, pagination);
|
|
264
313
|
});
|
|
265
314
|
}
|
|
266
315
|
create(opts) {
|
package/dist/integrations/s3.js
CHANGED
|
@@ -20,7 +20,7 @@ var S3Module;
|
|
|
20
20
|
datasource: {
|
|
21
21
|
region: {
|
|
22
22
|
type: "string",
|
|
23
|
-
required:
|
|
23
|
+
required: false,
|
|
24
24
|
default: "us-east-1",
|
|
25
25
|
},
|
|
26
26
|
accessKeyId: {
|
|
@@ -31,6 +31,15 @@ var S3Module;
|
|
|
31
31
|
type: "password",
|
|
32
32
|
required: true,
|
|
33
33
|
},
|
|
34
|
+
endpoint: {
|
|
35
|
+
type: "string",
|
|
36
|
+
required: false,
|
|
37
|
+
},
|
|
38
|
+
signatureVersion: {
|
|
39
|
+
type: "string",
|
|
40
|
+
required: false,
|
|
41
|
+
default: "v4"
|
|
42
|
+
},
|
|
34
43
|
},
|
|
35
44
|
query: {
|
|
36
45
|
read: {
|
|
@@ -47,13 +56,13 @@ var S3Module;
|
|
|
47
56
|
class S3Integration {
|
|
48
57
|
constructor(config) {
|
|
49
58
|
this.config = config;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (this.config.endpoint) {
|
|
60
|
+
this.config.s3ForcePathStyle = true;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
delete this.config.endpoint;
|
|
64
|
+
}
|
|
65
|
+
this.client = new AWS.S3(this.config);
|
|
57
66
|
}
|
|
58
67
|
read(query) {
|
|
59
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { getUserRoleHierarchy, getRequiredResourceRole, BUILTIN_ROLE_IDS, } = require("@budibase/
|
|
12
|
-
const { PermissionTypes, doesHaveBasePermission, } = require("@budibase/
|
|
11
|
+
const { getUserRoleHierarchy, getRequiredResourceRole, BUILTIN_ROLE_IDS, } = require("@budibase/backend-core/roles");
|
|
12
|
+
const { PermissionTypes, doesHaveBasePermission, } = require("@budibase/backend-core/permissions");
|
|
13
13
|
const builderMiddleware = require("./builder");
|
|
14
14
|
const { isWebhookEndpoint } = require("./utils");
|
|
15
15
|
function hasResource(ctx) {
|
|
@@ -12,8 +12,8 @@ const { APP_DEV_PREFIX } = require("../db/utils");
|
|
|
12
12
|
const { doesUserHaveLock, updateLock, checkDebounce, setDebounce, } = require("../utilities/redis");
|
|
13
13
|
const CouchDB = require("../db");
|
|
14
14
|
const { DocumentTypes } = require("../db/utils");
|
|
15
|
-
const { PermissionTypes } = require("@budibase/
|
|
16
|
-
const { app: appCache } = require("@budibase/
|
|
15
|
+
const { PermissionTypes } = require("@budibase/backend-core/permissions");
|
|
16
|
+
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
17
17
|
const DEBOUNCE_TIME_SEC = 30;
|
|
18
18
|
/************************************************** *
|
|
19
19
|
* This middleware has been broken out of the *
|
|
@@ -8,13 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { getAppId, setCookie, getCookie, clearCookie } = require("@budibase/
|
|
12
|
-
const { Cookies } = require("@budibase/
|
|
13
|
-
const { getRole } = require("@budibase/
|
|
14
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
11
|
+
const { getAppId, setCookie, getCookie, clearCookie, } = require("@budibase/backend-core/utils");
|
|
12
|
+
const { Cookies } = require("@budibase/backend-core/constants");
|
|
13
|
+
const { getRole } = require("@budibase/backend-core/roles");
|
|
14
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
15
15
|
const { generateUserMetadataID, isDevAppID } = require("../db/utils");
|
|
16
|
-
const { dbExists } = require("@budibase/
|
|
17
|
-
const { isUserInAppTenant } = require("@budibase/
|
|
16
|
+
const { dbExists } = require("@budibase/backend-core/db");
|
|
17
|
+
const { isUserInAppTenant } = require("@budibase/backend-core/tenancy");
|
|
18
18
|
const { getCachedSelf } = require("../utilities/global");
|
|
19
19
|
const CouchDB = require("../db");
|
|
20
20
|
const env = require("../environment");
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const CouchDB = require("../db");
|
|
12
12
|
const usageQuota = require("../utilities/usageQuota");
|
|
13
13
|
const env = require("../environment");
|
|
14
|
-
const { getTenantId } = require("@budibase/
|
|
14
|
+
const { getTenantId } = require("@budibase/backend-core/tenancy");
|
|
15
15
|
const { isExternalTable, isRowId: isExternalRowId, } = require("../integrations/utils");
|
|
16
16
|
// tenants without limits
|
|
17
17
|
const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"];
|
package/dist/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.13",
|
|
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/
|
|
74
|
-
"@budibase/client": "^1.0.27-alpha.
|
|
75
|
-
"@budibase/string-templates": "^1.0.27-alpha.
|
|
73
|
+
"@budibase/backend-core": "^1.0.27-alpha.13",
|
|
74
|
+
"@budibase/client": "^1.0.27-alpha.13",
|
|
75
|
+
"@budibase/string-templates": "^1.0.27-alpha.13",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -8,20 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
11
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
12
12
|
const env = require("../../environment");
|
|
13
13
|
const { basicTable, basicRow, basicRole, basicAutomation, basicDatasource, basicQuery, basicScreen, basicLayout, basicWebhook, TENANT_ID, } = require("./structures");
|
|
14
14
|
const controllers = require("./controllers");
|
|
15
15
|
const supertest = require("supertest");
|
|
16
16
|
const { cleanup } = require("../../utilities/fileSystem");
|
|
17
|
-
const { Cookies, Headers } = require("@budibase/
|
|
18
|
-
const { jwt } = require("@budibase/auth")
|
|
19
|
-
const
|
|
20
|
-
const { getGlobalDB } = require("@budibase/
|
|
21
|
-
const { createASession } = require("@budibase/
|
|
22
|
-
const { user: userCache } = require("@budibase/
|
|
17
|
+
const { Cookies, Headers } = require("@budibase/backend-core/constants");
|
|
18
|
+
const { jwt } = require("@budibase/backend-core/auth");
|
|
19
|
+
const core = require("@budibase/backend-core");
|
|
20
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
21
|
+
const { createASession } = require("@budibase/backend-core/sessions");
|
|
22
|
+
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
23
23
|
const CouchDB = require("../../db");
|
|
24
|
-
|
|
24
|
+
core.init(CouchDB);
|
|
25
25
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
26
26
|
const EMAIL = "babs@babs.com";
|
|
27
27
|
class TestConfiguration {
|
|
@@ -301,6 +301,46 @@ class TestConfiguration {
|
|
|
301
301
|
return this.datasource;
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
|
+
restDatasource(cfg) {
|
|
305
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
return this.createDatasource({
|
|
307
|
+
datasource: Object.assign(Object.assign({}, basicDatasource().datasource), { source: "REST", config: cfg || {} }),
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
dynamicVariableDatasource() {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
let datasource = yield this.restDatasource();
|
|
314
|
+
const basedOnQuery = yield this.createQuery(Object.assign(Object.assign({}, basicQuery(datasource._id)), { fields: {
|
|
315
|
+
path: "www.google.com",
|
|
316
|
+
} }));
|
|
317
|
+
datasource = yield this.updateDatasource(Object.assign(Object.assign({}, datasource), { config: {
|
|
318
|
+
dynamicVariables: [
|
|
319
|
+
{
|
|
320
|
+
queryId: basedOnQuery._id,
|
|
321
|
+
name: "variable3",
|
|
322
|
+
value: "{{ data.0.[value] }}",
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
} }));
|
|
326
|
+
return { datasource, query: basedOnQuery };
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
previewQuery(request, config, datasource, fields) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
return request
|
|
332
|
+
.post(`/api/queries/preview`)
|
|
333
|
+
.send({
|
|
334
|
+
datasourceId: datasource._id,
|
|
335
|
+
parameters: {},
|
|
336
|
+
fields,
|
|
337
|
+
queryVerb: "read",
|
|
338
|
+
})
|
|
339
|
+
.set(config.defaultHeaders())
|
|
340
|
+
.expect("Content-Type", /json/)
|
|
341
|
+
.expect(200);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
304
344
|
createQuery(config = null) {
|
|
305
345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
346
|
if (!this.datasource && !config) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
3
|
-
const { BUILTIN_PERMISSION_IDS } = require("@budibase/
|
|
2
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
3
|
+
const { BUILTIN_PERMISSION_IDS } = require("@budibase/backend-core/permissions");
|
|
4
4
|
const { createHomeScreen } = require("../../constants/screens");
|
|
5
5
|
const { EMPTY_LAYOUT } = require("../../constants/layouts");
|
|
6
6
|
const { cloneDeep } = require("lodash/fp");
|
|
@@ -14,10 +14,10 @@ const actions = require("../automations/actions");
|
|
|
14
14
|
const automationUtils = require("../automations/automationUtils");
|
|
15
15
|
const AutomationEmitter = require("../events/AutomationEmitter");
|
|
16
16
|
const { processObject } = require("@budibase/string-templates");
|
|
17
|
-
const { DEFAULT_TENANT_ID } = require("@budibase/
|
|
17
|
+
const { DEFAULT_TENANT_ID } = require("@budibase/backend-core/constants");
|
|
18
18
|
const CouchDB = require("../db");
|
|
19
19
|
const { DocumentTypes, isDevAppID } = require("../db/utils");
|
|
20
|
-
const { doInTenant } = require("@budibase/
|
|
20
|
+
const { doInTenant } = require("@budibase/backend-core/tenancy");
|
|
21
21
|
const usage = require("../utilities/usageQuota");
|
|
22
22
|
const { definitions: triggerDefs } = require("../automations/triggerInfo");
|
|
23
23
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
package/dist/threads/query.js
CHANGED
|
@@ -14,6 +14,8 @@ const ScriptRunner = require("../utilities/scriptRunner");
|
|
|
14
14
|
const { integrations } = require("../integrations");
|
|
15
15
|
const { processStringSync } = require("@budibase/string-templates");
|
|
16
16
|
const CouchDB = require("../db");
|
|
17
|
+
const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/);
|
|
18
|
+
const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/);
|
|
17
19
|
class QueryRunner {
|
|
18
20
|
constructor(input, flags = { noRecursiveQuery: false }) {
|
|
19
21
|
this.appId = input.appId;
|
|
@@ -21,6 +23,7 @@ class QueryRunner {
|
|
|
21
23
|
this.queryVerb = input.queryVerb;
|
|
22
24
|
this.fields = input.fields;
|
|
23
25
|
this.parameters = input.parameters;
|
|
26
|
+
this.pagination = input.pagination;
|
|
24
27
|
this.transformer = input.transformer;
|
|
25
28
|
this.queryId = input.queryId;
|
|
26
29
|
this.noRecursiveQuery = flags.noRecursiveQuery;
|
|
@@ -36,18 +39,23 @@ class QueryRunner {
|
|
|
36
39
|
let { datasource, fields, queryVerb, transformer } = this;
|
|
37
40
|
// pre-query, make sure datasource variables are added to parameters
|
|
38
41
|
const parameters = yield this.addDatasourceVariables();
|
|
39
|
-
|
|
42
|
+
let query = this.enrichQueryFields(fields, parameters);
|
|
43
|
+
// Add pagination values for REST queries
|
|
44
|
+
if (this.pagination) {
|
|
45
|
+
query.paginationValues = this.pagination;
|
|
46
|
+
}
|
|
40
47
|
const Integration = integrations[datasource.source];
|
|
41
48
|
if (!Integration) {
|
|
42
49
|
throw "Integration type does not exist.";
|
|
43
50
|
}
|
|
44
51
|
const integration = new Integration(datasource.config);
|
|
45
52
|
let output = threadUtils.formatResponse(yield integration[queryVerb](query));
|
|
46
|
-
let rows = output, info = undefined, extra = undefined;
|
|
53
|
+
let rows = output, info = undefined, extra = undefined, pagination = undefined;
|
|
47
54
|
if (threadUtils.hasExtraData(output)) {
|
|
48
55
|
rows = output.data;
|
|
49
56
|
info = output.info;
|
|
50
57
|
extra = output.extra;
|
|
58
|
+
pagination = output.pagination;
|
|
51
59
|
}
|
|
52
60
|
// transform as required
|
|
53
61
|
if (transformer) {
|
|
@@ -80,7 +88,7 @@ class QueryRunner {
|
|
|
80
88
|
if (integration.end) {
|
|
81
89
|
integration.end();
|
|
82
90
|
}
|
|
83
|
-
return { rows, keys, info, extra };
|
|
91
|
+
return { rows, keys, info, extra, pagination };
|
|
84
92
|
});
|
|
85
93
|
}
|
|
86
94
|
runAnotherQuery(queryId, parameters) {
|
|
@@ -157,6 +165,47 @@ class QueryRunner {
|
|
|
157
165
|
return parameters;
|
|
158
166
|
});
|
|
159
167
|
}
|
|
168
|
+
enrichQueryFields(fields, parameters = {}) {
|
|
169
|
+
const enrichedQuery = {};
|
|
170
|
+
// enrich the fields with dynamic parameters
|
|
171
|
+
for (let key of Object.keys(fields)) {
|
|
172
|
+
if (fields[key] == null) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (typeof fields[key] === "object") {
|
|
176
|
+
// enrich nested fields object
|
|
177
|
+
enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters);
|
|
178
|
+
}
|
|
179
|
+
else if (typeof fields[key] === "string") {
|
|
180
|
+
// enrich string value as normal
|
|
181
|
+
let value = fields[key];
|
|
182
|
+
// add triple brace to avoid escaping e.g. '=' in cookie header
|
|
183
|
+
if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
|
|
184
|
+
value = `{${value}}`;
|
|
185
|
+
}
|
|
186
|
+
enrichedQuery[key] = processStringSync(value, parameters, {
|
|
187
|
+
noHelpers: true,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
enrichedQuery[key] = fields[key];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (enrichedQuery.json ||
|
|
195
|
+
enrichedQuery.customData ||
|
|
196
|
+
enrichedQuery.requestBody) {
|
|
197
|
+
try {
|
|
198
|
+
enrichedQuery.json = JSON.parse(enrichedQuery.json ||
|
|
199
|
+
enrichedQuery.customData ||
|
|
200
|
+
enrichedQuery.requestBody);
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
// no json found, ignore
|
|
204
|
+
}
|
|
205
|
+
delete enrichedQuery.customData;
|
|
206
|
+
}
|
|
207
|
+
return enrichedQuery;
|
|
208
|
+
}
|
|
160
209
|
}
|
|
161
210
|
module.exports = (input, callback) => {
|
|
162
211
|
const Runner = new QueryRunner(input);
|
package/dist/threads/utils.js
CHANGED
|
@@ -10,14 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const env = require("../environment");
|
|
12
12
|
const CouchDB = require("../db");
|
|
13
|
-
const { init } = require("@budibase/
|
|
14
|
-
const redis = require("@budibase/
|
|
15
|
-
const { SEPARATOR } = require("@budibase/
|
|
16
|
-
const { processStringSync } = require("@budibase/string-templates");
|
|
13
|
+
const { init } = require("@budibase/backend-core");
|
|
14
|
+
const redis = require("@budibase/backend-core/redis");
|
|
15
|
+
const { SEPARATOR } = require("@budibase/backend-core/db");
|
|
17
16
|
const VARIABLE_TTL_SECONDS = 3600;
|
|
18
17
|
let client;
|
|
19
|
-
const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/);
|
|
20
|
-
const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/);
|
|
21
18
|
function getClient() {
|
|
22
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
20
|
if (!client) {
|
|
@@ -75,44 +72,3 @@ exports.hasExtraData = response => {
|
|
|
75
72
|
response.data != null &&
|
|
76
73
|
response.info != null);
|
|
77
74
|
};
|
|
78
|
-
exports.enrichQueryFields = (fields, parameters = {}) => {
|
|
79
|
-
const enrichedQuery = {};
|
|
80
|
-
// enrich the fields with dynamic parameters
|
|
81
|
-
for (let key of Object.keys(fields)) {
|
|
82
|
-
if (fields[key] == null) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (typeof fields[key] === "object") {
|
|
86
|
-
// enrich nested fields object
|
|
87
|
-
enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters);
|
|
88
|
-
}
|
|
89
|
-
else if (typeof fields[key] === "string") {
|
|
90
|
-
// enrich string value as normal
|
|
91
|
-
let value = fields[key];
|
|
92
|
-
// add triple brace to avoid escaping e.g. '=' in cookie header
|
|
93
|
-
if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
|
|
94
|
-
value = `{${value}}`;
|
|
95
|
-
}
|
|
96
|
-
enrichedQuery[key] = processStringSync(value, parameters, {
|
|
97
|
-
noHelpers: true,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
enrichedQuery[key] = fields[key];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (enrichedQuery.json ||
|
|
105
|
-
enrichedQuery.customData ||
|
|
106
|
-
enrichedQuery.requestBody) {
|
|
107
|
-
try {
|
|
108
|
-
enrichedQuery.json = JSON.parse(enrichedQuery.json ||
|
|
109
|
-
enrichedQuery.customData ||
|
|
110
|
-
enrichedQuery.requestBody);
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
// no json found, ignore
|
|
114
|
-
}
|
|
115
|
-
delete enrichedQuery.customData;
|
|
116
|
-
}
|
|
117
|
-
return enrichedQuery;
|
|
118
|
-
};
|