@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
1
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
2
|
const env = require("../../environment")
|
|
3
3
|
const {
|
|
4
4
|
basicTable,
|
|
@@ -15,14 +15,14 @@ const {
|
|
|
15
15
|
const controllers = require("./controllers")
|
|
16
16
|
const supertest = require("supertest")
|
|
17
17
|
const { cleanup } = require("../../utilities/fileSystem")
|
|
18
|
-
const { Cookies, Headers } = require("@budibase/
|
|
19
|
-
const { jwt } = require("@budibase/auth")
|
|
20
|
-
const
|
|
21
|
-
const { getGlobalDB } = require("@budibase/
|
|
22
|
-
const { createASession } = require("@budibase/
|
|
23
|
-
const { user: userCache } = require("@budibase/
|
|
18
|
+
const { Cookies, Headers } = require("@budibase/backend-core/constants")
|
|
19
|
+
const { jwt } = require("@budibase/backend-core/auth")
|
|
20
|
+
const core = require("@budibase/backend-core")
|
|
21
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
22
|
+
const { createASession } = require("@budibase/backend-core/sessions")
|
|
23
|
+
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
24
24
|
const CouchDB = require("../../db")
|
|
25
|
-
|
|
25
|
+
core.init(CouchDB)
|
|
26
26
|
|
|
27
27
|
const GLOBAL_USER_ID = "us_uuid1"
|
|
28
28
|
const EMAIL = "babs@babs.com"
|
|
@@ -326,6 +326,53 @@ class TestConfiguration {
|
|
|
326
326
|
return this.datasource
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
async restDatasource(cfg) {
|
|
330
|
+
return this.createDatasource({
|
|
331
|
+
datasource: {
|
|
332
|
+
...basicDatasource().datasource,
|
|
333
|
+
source: "REST",
|
|
334
|
+
config: cfg || {},
|
|
335
|
+
},
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async dynamicVariableDatasource() {
|
|
340
|
+
let datasource = await this.restDatasource()
|
|
341
|
+
const basedOnQuery = await this.createQuery({
|
|
342
|
+
...basicQuery(datasource._id),
|
|
343
|
+
fields: {
|
|
344
|
+
path: "www.google.com",
|
|
345
|
+
},
|
|
346
|
+
})
|
|
347
|
+
datasource = await this.updateDatasource({
|
|
348
|
+
...datasource,
|
|
349
|
+
config: {
|
|
350
|
+
dynamicVariables: [
|
|
351
|
+
{
|
|
352
|
+
queryId: basedOnQuery._id,
|
|
353
|
+
name: "variable3",
|
|
354
|
+
value: "{{ data.0.[value] }}",
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
})
|
|
359
|
+
return { datasource, query: basedOnQuery }
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async previewQuery(request, config, datasource, fields) {
|
|
363
|
+
return request
|
|
364
|
+
.post(`/api/queries/preview`)
|
|
365
|
+
.send({
|
|
366
|
+
datasourceId: datasource._id,
|
|
367
|
+
parameters: {},
|
|
368
|
+
fields,
|
|
369
|
+
queryVerb: "read",
|
|
370
|
+
})
|
|
371
|
+
.set(config.defaultHeaders())
|
|
372
|
+
.expect("Content-Type", /json/)
|
|
373
|
+
.expect(200)
|
|
374
|
+
}
|
|
375
|
+
|
|
329
376
|
async createQuery(config = null) {
|
|
330
377
|
if (!this.datasource && !config) {
|
|
331
378
|
throw "No data source created for query."
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
2
|
-
const { BUILTIN_PERMISSION_IDS } = require("@budibase/
|
|
1
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
|
+
const { BUILTIN_PERMISSION_IDS } = require("@budibase/backend-core/permissions")
|
|
3
3
|
const { createHomeScreen } = require("../../constants/screens")
|
|
4
4
|
const { EMPTY_LAYOUT } = require("../../constants/layouts")
|
|
5
5
|
const { cloneDeep } = require("lodash/fp")
|
|
@@ -4,10 +4,10 @@ const actions = require("../automations/actions")
|
|
|
4
4
|
const automationUtils = require("../automations/automationUtils")
|
|
5
5
|
const AutomationEmitter = require("../events/AutomationEmitter")
|
|
6
6
|
const { processObject } = require("@budibase/string-templates")
|
|
7
|
-
const { DEFAULT_TENANT_ID } = require("@budibase/
|
|
7
|
+
const { DEFAULT_TENANT_ID } = require("@budibase/backend-core/constants")
|
|
8
8
|
const CouchDB = require("../db")
|
|
9
9
|
const { DocumentTypes, isDevAppID } = require("../db/utils")
|
|
10
|
-
const { doInTenant } = require("@budibase/
|
|
10
|
+
const { doInTenant } = require("@budibase/backend-core/tenancy")
|
|
11
11
|
const usage = require("../utilities/usageQuota")
|
|
12
12
|
const { definitions: triggerDefs } = require("../automations/triggerInfo")
|
|
13
13
|
|
package/src/threads/query.js
CHANGED
|
@@ -5,6 +5,9 @@ const { integrations } = require("../integrations")
|
|
|
5
5
|
const { processStringSync } = require("@budibase/string-templates")
|
|
6
6
|
const CouchDB = require("../db")
|
|
7
7
|
|
|
8
|
+
const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/)
|
|
9
|
+
const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/)
|
|
10
|
+
|
|
8
11
|
class QueryRunner {
|
|
9
12
|
constructor(input, flags = { noRecursiveQuery: false }) {
|
|
10
13
|
this.appId = input.appId
|
|
@@ -12,6 +15,7 @@ class QueryRunner {
|
|
|
12
15
|
this.queryVerb = input.queryVerb
|
|
13
16
|
this.fields = input.fields
|
|
14
17
|
this.parameters = input.parameters
|
|
18
|
+
this.pagination = input.pagination
|
|
15
19
|
this.transformer = input.transformer
|
|
16
20
|
this.queryId = input.queryId
|
|
17
21
|
this.noRecursiveQuery = flags.noRecursiveQuery
|
|
@@ -27,7 +31,13 @@ class QueryRunner {
|
|
|
27
31
|
let { datasource, fields, queryVerb, transformer } = this
|
|
28
32
|
// pre-query, make sure datasource variables are added to parameters
|
|
29
33
|
const parameters = await this.addDatasourceVariables()
|
|
30
|
-
|
|
34
|
+
let query = this.enrichQueryFields(fields, parameters)
|
|
35
|
+
|
|
36
|
+
// Add pagination values for REST queries
|
|
37
|
+
if (this.pagination) {
|
|
38
|
+
query.paginationValues = this.pagination
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
const Integration = integrations[datasource.source]
|
|
32
42
|
if (!Integration) {
|
|
33
43
|
throw "Integration type does not exist."
|
|
@@ -37,11 +47,13 @@ class QueryRunner {
|
|
|
37
47
|
let output = threadUtils.formatResponse(await integration[queryVerb](query))
|
|
38
48
|
let rows = output,
|
|
39
49
|
info = undefined,
|
|
40
|
-
extra = undefined
|
|
50
|
+
extra = undefined,
|
|
51
|
+
pagination = undefined
|
|
41
52
|
if (threadUtils.hasExtraData(output)) {
|
|
42
53
|
rows = output.data
|
|
43
54
|
info = output.info
|
|
44
55
|
extra = output.extra
|
|
56
|
+
pagination = output.pagination
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
// transform as required
|
|
@@ -83,7 +95,7 @@ class QueryRunner {
|
|
|
83
95
|
integration.end()
|
|
84
96
|
}
|
|
85
97
|
|
|
86
|
-
return { rows, keys, info, extra }
|
|
98
|
+
return { rows, keys, info, extra, pagination }
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
async runAnotherQuery(queryId, parameters) {
|
|
@@ -159,6 +171,50 @@ class QueryRunner {
|
|
|
159
171
|
}
|
|
160
172
|
return parameters
|
|
161
173
|
}
|
|
174
|
+
|
|
175
|
+
enrichQueryFields(fields, parameters = {}) {
|
|
176
|
+
const enrichedQuery = {}
|
|
177
|
+
|
|
178
|
+
// enrich the fields with dynamic parameters
|
|
179
|
+
for (let key of Object.keys(fields)) {
|
|
180
|
+
if (fields[key] == null) {
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
if (typeof fields[key] === "object") {
|
|
184
|
+
// enrich nested fields object
|
|
185
|
+
enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters)
|
|
186
|
+
} else if (typeof fields[key] === "string") {
|
|
187
|
+
// enrich string value as normal
|
|
188
|
+
let value = fields[key]
|
|
189
|
+
// add triple brace to avoid escaping e.g. '=' in cookie header
|
|
190
|
+
if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
|
|
191
|
+
value = `{${value}}`
|
|
192
|
+
}
|
|
193
|
+
enrichedQuery[key] = processStringSync(value, parameters, {
|
|
194
|
+
noHelpers: true,
|
|
195
|
+
})
|
|
196
|
+
} else {
|
|
197
|
+
enrichedQuery[key] = fields[key]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (
|
|
201
|
+
enrichedQuery.json ||
|
|
202
|
+
enrichedQuery.customData ||
|
|
203
|
+
enrichedQuery.requestBody
|
|
204
|
+
) {
|
|
205
|
+
try {
|
|
206
|
+
enrichedQuery.json = JSON.parse(
|
|
207
|
+
enrichedQuery.json ||
|
|
208
|
+
enrichedQuery.customData ||
|
|
209
|
+
enrichedQuery.requestBody
|
|
210
|
+
)
|
|
211
|
+
} catch (err) {
|
|
212
|
+
// no json found, ignore
|
|
213
|
+
}
|
|
214
|
+
delete enrichedQuery.customData
|
|
215
|
+
}
|
|
216
|
+
return enrichedQuery
|
|
217
|
+
}
|
|
162
218
|
}
|
|
163
219
|
|
|
164
220
|
module.exports = (input, callback) => {
|
package/src/threads/utils.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
const env = require("../environment")
|
|
2
2
|
const CouchDB = require("../db")
|
|
3
|
-
const { init } = require("@budibase/
|
|
4
|
-
const redis = require("@budibase/
|
|
5
|
-
const { SEPARATOR } = require("@budibase/
|
|
6
|
-
const { processStringSync } = require("@budibase/string-templates")
|
|
3
|
+
const { init } = require("@budibase/backend-core")
|
|
4
|
+
const redis = require("@budibase/backend-core/redis")
|
|
5
|
+
const { SEPARATOR } = require("@budibase/backend-core/db")
|
|
7
6
|
|
|
8
7
|
const VARIABLE_TTL_SECONDS = 3600
|
|
9
8
|
let client
|
|
10
9
|
|
|
11
|
-
const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/)
|
|
12
|
-
const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/)
|
|
13
|
-
|
|
14
10
|
async function getClient() {
|
|
15
11
|
if (!client) {
|
|
16
12
|
client = await new redis.Client(redis.utils.Databases.QUERY_VARS).init()
|
|
@@ -80,49 +76,3 @@ exports.hasExtraData = response => {
|
|
|
80
76
|
response.info != null
|
|
81
77
|
)
|
|
82
78
|
}
|
|
83
|
-
|
|
84
|
-
exports.enrichQueryFields = (fields, parameters = {}) => {
|
|
85
|
-
const enrichedQuery = {}
|
|
86
|
-
|
|
87
|
-
// enrich the fields with dynamic parameters
|
|
88
|
-
for (let key of Object.keys(fields)) {
|
|
89
|
-
if (fields[key] == null) {
|
|
90
|
-
continue
|
|
91
|
-
}
|
|
92
|
-
if (typeof fields[key] === "object") {
|
|
93
|
-
// enrich nested fields object
|
|
94
|
-
enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters)
|
|
95
|
-
} else if (typeof fields[key] === "string") {
|
|
96
|
-
// enrich string value as normal
|
|
97
|
-
let value = fields[key]
|
|
98
|
-
// add triple brace to avoid escaping e.g. '=' in cookie header
|
|
99
|
-
if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
|
|
100
|
-
value = `{${value}}`
|
|
101
|
-
}
|
|
102
|
-
enrichedQuery[key] = processStringSync(value, parameters, {
|
|
103
|
-
noHelpers: true,
|
|
104
|
-
})
|
|
105
|
-
} else {
|
|
106
|
-
enrichedQuery[key] = fields[key]
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
enrichedQuery.json ||
|
|
112
|
-
enrichedQuery.customData ||
|
|
113
|
-
enrichedQuery.requestBody
|
|
114
|
-
) {
|
|
115
|
-
try {
|
|
116
|
-
enrichedQuery.json = JSON.parse(
|
|
117
|
-
enrichedQuery.json ||
|
|
118
|
-
enrichedQuery.customData ||
|
|
119
|
-
enrichedQuery.requestBody
|
|
120
|
-
)
|
|
121
|
-
} catch (err) {
|
|
122
|
-
// no json found, ignore
|
|
123
|
-
}
|
|
124
|
-
delete enrichedQuery.customData
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return enrichedQuery
|
|
128
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { join } = require("./centralPath")
|
|
2
2
|
const { homedir } = require("os")
|
|
3
3
|
const env = require("../environment")
|
|
4
|
-
const { budibaseTempDir } = require("@budibase/
|
|
4
|
+
const { budibaseTempDir } = require("@budibase/backend-core/objectStore")
|
|
5
5
|
|
|
6
6
|
module.exports.budibaseAppsDir = function () {
|
|
7
7
|
return env.BUDIBASE_DIR || join(homedir(), ".budibase")
|
package/src/utilities/global.js
CHANGED
|
@@ -2,11 +2,14 @@ const {
|
|
|
2
2
|
getMultiIDParams,
|
|
3
3
|
getGlobalIDFromUserMetadataID,
|
|
4
4
|
} = require("../db/utils")
|
|
5
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
6
|
-
const { getDeployedAppID } = require("@budibase/
|
|
7
|
-
const { getGlobalUserParams } = require("@budibase/
|
|
8
|
-
const { user: userCache } = require("@budibase/
|
|
9
|
-
const {
|
|
5
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
6
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db")
|
|
7
|
+
const { getGlobalUserParams } = require("@budibase/backend-core/db")
|
|
8
|
+
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
9
|
+
const {
|
|
10
|
+
getGlobalDB,
|
|
11
|
+
isUserInAppTenant,
|
|
12
|
+
} = require("@budibase/backend-core/tenancy")
|
|
10
13
|
const env = require("../environment")
|
|
11
14
|
|
|
12
15
|
exports.updateAppRole = (appId, user) => {
|
package/src/utilities/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const env = require("../environment")
|
|
2
2
|
const { OBJ_STORE_DIRECTORY } = require("../constants")
|
|
3
|
-
const { sanitizeKey } = require("@budibase/
|
|
3
|
+
const { sanitizeKey } = require("@budibase/backend-core/objectStore")
|
|
4
4
|
const CouchDB = require("../db")
|
|
5
5
|
const { generateMetadataID } = require("../db/utils")
|
|
6
6
|
const Readable = require("stream").Readable
|
|
@@ -34,7 +34,7 @@ exports.checkSlashesInUrl = url => {
|
|
|
34
34
|
* @return {string} The base URL of the object store (MinIO or S3).
|
|
35
35
|
*/
|
|
36
36
|
exports.objectStoreUrl = () => {
|
|
37
|
-
if (env.SELF_HOSTED) {
|
|
37
|
+
if (env.SELF_HOSTED || env.MINIO_URL) {
|
|
38
38
|
// can use a relative url for this as all goes through the proxy (this is hosted in minio)
|
|
39
39
|
return OBJ_STORE_DIRECTORY
|
|
40
40
|
} else {
|
package/src/utilities/redis.js
CHANGED
|
@@ -5,7 +5,11 @@ const { attachmentsRelativeURL } = require("../index")
|
|
|
5
5
|
const { processFormulas } = require("./utils")
|
|
6
6
|
const { deleteFiles } = require("../../utilities/fileSystem/utilities")
|
|
7
7
|
const { ObjectStoreBuckets } = require("../../constants")
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
isProdAppID,
|
|
10
|
+
getDeployedAppID,
|
|
11
|
+
dbExists,
|
|
12
|
+
} = require("@budibase/backend-core/db")
|
|
9
13
|
const CouchDB = require("../../db")
|
|
10
14
|
|
|
11
15
|
const BASE_AUTO_ID = 1
|
|
@@ -3,8 +3,11 @@ const {
|
|
|
3
3
|
PermissionTypes,
|
|
4
4
|
getBuiltinPermissionByID,
|
|
5
5
|
isPermissionLevelHigherThanRead,
|
|
6
|
-
} = require("@budibase/
|
|
7
|
-
const {
|
|
6
|
+
} = require("@budibase/backend-core/permissions")
|
|
7
|
+
const {
|
|
8
|
+
lowerBuiltinRoleID,
|
|
9
|
+
getBuiltinRoles,
|
|
10
|
+
} = require("@budibase/backend-core/roles")
|
|
8
11
|
const { DocumentTypes } = require("../db/utils")
|
|
9
12
|
|
|
10
13
|
const CURRENTLY_SUPPORTED_LEVELS = [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const env = require("../environment")
|
|
2
|
-
const { getGlobalDB } = require("@budibase/
|
|
2
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
3
3
|
const {
|
|
4
4
|
StaticDatabases,
|
|
5
5
|
generateNewUsageQuotaDoc,
|
|
6
|
-
} = require("@budibase/
|
|
6
|
+
} = require("@budibase/backend-core/db")
|
|
7
7
|
|
|
8
8
|
function getNewQuotaReset() {
|
|
9
9
|
return Date.now() + 2592000000
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const fetch = require("node-fetch")
|
|
2
2
|
const env = require("../environment")
|
|
3
3
|
const { checkSlashesInUrl } = require("./index")
|
|
4
|
-
const { getDeployedAppID } = require("@budibase/
|
|
4
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db")
|
|
5
5
|
const { updateAppRole } = require("./global")
|
|
6
|
-
const { Headers } = require("@budibase/
|
|
7
|
-
const { getTenantId, isTenantIdSet } = require("@budibase/
|
|
6
|
+
const { Headers } = require("@budibase/backend-core/constants")
|
|
7
|
+
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy")
|
|
8
8
|
|
|
9
9
|
function request(ctx, request) {
|
|
10
10
|
if (!request.headers) {
|