@budibase/server 1.0.27-alpha.1 → 1.0.27-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/node-fetch.ts +18 -0
- package/builder/assets/{index.4a13c4cb.css → index.176f00e0.css} +1 -1
- package/builder/assets/index.5776ef20.js +1348 -0
- package/builder/index.html +2 -2
- package/coverage/clover.xml +1193 -1027
- package/coverage/coverage-final.json +72 -72
- 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 +73 -64
- 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 +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +150 -48
- 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 +20 -20
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +3 -3
- package/coverage/lcov-report/api/controllers/query/index.html +21 -21
- package/coverage/lcov-report/api/controllers/query/index.js.html +101 -122
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -3
- 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 +22 -22
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +38 -11
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -5
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -20
- 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 +25 -4
- 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 +32 -8
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +11 -11
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/automations/utils.js.html +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 +64 -64
- 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 +12 -12
- 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 +18 -18
- 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 +31 -31
- package/coverage/lcov-report/threads/index.js.html +12 -12
- package/coverage/lcov-report/threads/query.js.html +369 -93
- package/coverage/lcov-report/threads/utils.js.html +359 -14
- 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 +28 -19
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +11 -11
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +19 -19
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +247 -10
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +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 +2027 -1725
- 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/import/sources/base/index.js +2 -1
- package/dist/api/controllers/query/import/sources/curl.js +11 -5
- package/dist/api/controllers/query/import/sources/openapi2.js +8 -5
- package/dist/api/controllers/query/index.js +45 -47
- package/dist/api/controllers/query/validation.js +2 -1
- package/dist/api/controllers/role.js +1 -1
- package/dist/api/controllers/routing.js +1 -1
- package/dist/api/controllers/row/internal.js +14 -6
- package/dist/api/controllers/row/internalSearch.js +3 -2
- package/dist/api/controllers/row/utils.js +13 -6
- 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 +4 -2
- 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 +9 -2
- 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/integrations/base/sqlTable.js +1 -1
- package/dist/integrations/rest.js +3 -3
- 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 +5 -4
- package/dist/tests/utilities/TestConfiguration.js +55 -8
- package/dist/tests/utilities/structures.js +2 -2
- package/dist/threads/automation.js +2 -2
- package/dist/threads/query.js +148 -52
- package/dist/threads/utils.js +106 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +1 -1
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/dist/utilities/global.js +5 -5
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/redis.js +1 -1
- package/dist/utilities/rowProcessor/index.js +76 -0
- package/dist/utilities/security.js +2 -2
- package/dist/utilities/usageQuota.js +2 -2
- package/dist/utilities/workerRequests.js +3 -3
- package/package.json +6 -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/import/sources/base/index.ts +3 -1
- package/src/api/controllers/query/import/sources/curl.ts +12 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +9 -5
- package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +2 -3
- package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +6 -7
- package/src/api/controllers/query/import/tests/index.spec.js +0 -6
- package/src/api/controllers/query/index.js +48 -55
- package/src/api/controllers/query/validation.js +2 -1
- package/src/api/controllers/role.js +1 -1
- package/src/api/controllers/routing.js +1 -1
- package/src/api/controllers/row/internal.js +14 -5
- package/src/api/controllers/row/internalSearch.js +3 -2
- package/src/api/controllers/row/utils.js +11 -8
- 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 +9 -2
- 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 +70 -1
- 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 +10 -2
- 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 +10 -0
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/rest.ts +6 -3
- 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 +65 -8
- package/src/tests/utilities/structures.js +2 -2
- package/src/threads/automation.js +2 -2
- package/src/threads/query.js +148 -56
- package/src/threads/utils.js +116 -1
- package/src/utilities/budibaseDir.js +1 -1
- package/src/utilities/fileSystem/utilities.js +3 -1
- package/src/utilities/global.js +8 -5
- package/src/utilities/index.js +1 -1
- package/src/utilities/redis.js +1 -1
- package/src/utilities/rowProcessor/index.js +79 -0
- package/src/utilities/security.js +5 -2
- package/src/utilities/usageQuota.js +2 -2
- package/src/utilities/workerRequests.js +3 -3
- package/builder/assets/index.00c4135e.js +0 -1320
|
@@ -4,6 +4,7 @@ let setup = require("./utilities")
|
|
|
4
4
|
let { basicDatasource } = setup.structures
|
|
5
5
|
let { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
6
6
|
const pg = require("pg")
|
|
7
|
+
const { checkCacheForDynamicVariable } = require("../../../threads/utils")
|
|
7
8
|
|
|
8
9
|
describe("/datasources", () => {
|
|
9
10
|
let request = setup.getRequest()
|
|
@@ -31,6 +32,50 @@ describe("/datasources", () => {
|
|
|
31
32
|
})
|
|
32
33
|
})
|
|
33
34
|
|
|
35
|
+
describe("update", () => {
|
|
36
|
+
it("should update an existing datasource", async () => {
|
|
37
|
+
datasource.name = "Updated Test"
|
|
38
|
+
const res = await request
|
|
39
|
+
.put(`/api/datasources/${datasource._id}`)
|
|
40
|
+
.send(datasource)
|
|
41
|
+
.set(config.defaultHeaders())
|
|
42
|
+
.expect('Content-Type', /json/)
|
|
43
|
+
.expect(200)
|
|
44
|
+
|
|
45
|
+
expect(res.body.datasource.name).toEqual("Updated Test")
|
|
46
|
+
expect(res.body.errors).toBeUndefined()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
describe("dynamic variables", () => {
|
|
50
|
+
async function preview(datasource, fields) {
|
|
51
|
+
return config.previewQuery(request, config, datasource, fields)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
it("should invalidate changed or removed variables", async () => {
|
|
55
|
+
const { datasource, query } = await config.dynamicVariableDatasource()
|
|
56
|
+
// preview once to cache variables
|
|
57
|
+
await preview(datasource, { path: "www.test.com", queryString: "test={{ variable3 }}" })
|
|
58
|
+
// check variables in cache
|
|
59
|
+
let contents = await checkCacheForDynamicVariable(query._id, "variable3")
|
|
60
|
+
expect(contents.rows.length).toEqual(1)
|
|
61
|
+
|
|
62
|
+
// update the datasource to remove the variables
|
|
63
|
+
datasource.config.dynamicVariables = []
|
|
64
|
+
const res = await request
|
|
65
|
+
.put(`/api/datasources/${datasource._id}`)
|
|
66
|
+
.send(datasource)
|
|
67
|
+
.set(config.defaultHeaders())
|
|
68
|
+
.expect('Content-Type', /json/)
|
|
69
|
+
.expect(200)
|
|
70
|
+
expect(res.body.errors).toBeUndefined()
|
|
71
|
+
|
|
72
|
+
// check variables no longer in cache
|
|
73
|
+
contents = await checkCacheForDynamicVariable(query._id, "variable3")
|
|
74
|
+
expect(contents).toBe(null)
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
34
79
|
describe("fetch", () => {
|
|
35
80
|
it("returns all the datasources from the server", async () => {
|
|
36
81
|
const res = await request
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// Mock out postgres for this
|
|
2
2
|
jest.mock("pg")
|
|
3
|
+
jest.mock("node-fetch")
|
|
3
4
|
|
|
4
5
|
// Mock isProdAppID to we can later mock the implementation and pretend we are
|
|
5
6
|
// using prod app IDs
|
|
6
|
-
const authDb = require("@budibase/
|
|
7
|
+
const authDb = require("@budibase/backend-core/db")
|
|
7
8
|
const { isProdAppID } = authDb
|
|
8
9
|
const mockIsProdAppID = jest.fn(isProdAppID)
|
|
9
10
|
authDb.isProdAppID = mockIsProdAppID
|
|
10
11
|
|
|
11
12
|
const setup = require("./utilities")
|
|
12
13
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
14
|
+
const { checkCacheForDynamicVariable } = require("../../../threads/utils")
|
|
13
15
|
const { basicQuery, basicDatasource } = setup.structures
|
|
14
16
|
|
|
15
17
|
describe("/queries", () => {
|
|
@@ -226,4 +228,71 @@ describe("/queries", () => {
|
|
|
226
228
|
.expect(400)
|
|
227
229
|
})
|
|
228
230
|
})
|
|
231
|
+
|
|
232
|
+
describe("variables", () => {
|
|
233
|
+
|
|
234
|
+
async function preview(datasource, fields) {
|
|
235
|
+
return config.previewQuery(request, config, datasource, fields)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
it("should work with static variables", async () => {
|
|
239
|
+
const datasource = await config.restDatasource({
|
|
240
|
+
staticVariables: {
|
|
241
|
+
variable: "google",
|
|
242
|
+
variable2: "1",
|
|
243
|
+
},
|
|
244
|
+
})
|
|
245
|
+
const res = await preview(datasource, {
|
|
246
|
+
path: "www.{{ variable }}.com",
|
|
247
|
+
queryString: "test={{ variable2 }}",
|
|
248
|
+
})
|
|
249
|
+
// these responses come from the mock
|
|
250
|
+
expect(res.body.schemaFields).toEqual(["url", "opts", "value"])
|
|
251
|
+
expect(res.body.rows[0].url).toEqual("http://www.google.com?test=1")
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
it("should work with dynamic variables", async () => {
|
|
255
|
+
const { datasource } = await config.dynamicVariableDatasource()
|
|
256
|
+
const res = await preview(datasource, {
|
|
257
|
+
path: "www.google.com",
|
|
258
|
+
queryString: "test={{ variable3 }}",
|
|
259
|
+
})
|
|
260
|
+
expect(res.body.schemaFields).toEqual(["url", "opts", "value"])
|
|
261
|
+
expect(res.body.rows[0].url).toContain("doctype html")
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
it("check that it automatically retries on fail with cached dynamics", async () => {
|
|
265
|
+
const { datasource, query: base } = await config.dynamicVariableDatasource()
|
|
266
|
+
// preview once to cache
|
|
267
|
+
await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" })
|
|
268
|
+
// check its in cache
|
|
269
|
+
const contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
|
270
|
+
expect(contents.rows.length).toEqual(1)
|
|
271
|
+
const res = await preview(datasource, {
|
|
272
|
+
path: "www.failonce.com",
|
|
273
|
+
queryString: "test={{ variable3 }}",
|
|
274
|
+
})
|
|
275
|
+
expect(res.body.schemaFields).toEqual(["fails", "url", "opts"])
|
|
276
|
+
expect(res.body.rows[0].fails).toEqual(1)
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
it("deletes variables when linked query is deleted", async () => {
|
|
280
|
+
const { datasource, query: base } = await config.dynamicVariableDatasource()
|
|
281
|
+
// preview once to cache
|
|
282
|
+
await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" })
|
|
283
|
+
// check its in cache
|
|
284
|
+
let contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
|
285
|
+
expect(contents.rows.length).toEqual(1)
|
|
286
|
+
|
|
287
|
+
// delete the query
|
|
288
|
+
await request
|
|
289
|
+
.delete(`/api/queries/${base._id}/${base._rev}`)
|
|
290
|
+
.set(config.defaultHeaders())
|
|
291
|
+
.expect(200)
|
|
292
|
+
|
|
293
|
+
// check variables no longer in cache
|
|
294
|
+
contents = await checkCacheForDynamicVariable(base._id, "variable3")
|
|
295
|
+
expect(contents).toBe(null)
|
|
296
|
+
})
|
|
297
|
+
})
|
|
229
298
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
1
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
2
|
const {
|
|
3
3
|
BUILTIN_PERMISSION_IDS,
|
|
4
|
-
} = require("@budibase/
|
|
4
|
+
} = require("@budibase/backend-core/permissions")
|
|
5
5
|
const setup = require("./utilities")
|
|
6
6
|
const { basicRole } = setup.structures
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const setup = require("./utilities")
|
|
2
2
|
const { basicScreen } = setup.structures
|
|
3
3
|
const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
|
|
4
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
4
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
5
5
|
|
|
6
6
|
const route = "/test"
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ const rowController = require("../../../controllers/row")
|
|
|
2
2
|
const appController = require("../../../controllers/application")
|
|
3
3
|
const CouchDB = require("../../../../db")
|
|
4
4
|
const { AppStatus } = require("../../../../db/utils")
|
|
5
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
5
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
6
6
|
const { TENANT_ID } = require("../../../../tests/utilities/structures")
|
|
7
7
|
|
|
8
8
|
function Request(appId, params) {
|
package/src/api/routes/user.js
CHANGED
package/src/api/routes/view.js
CHANGED
|
@@ -2,7 +2,7 @@ const Router = require("@koa/router")
|
|
|
2
2
|
const controller = require("../controllers/webhook")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
4
|
const joiValidator = require("../../middleware/joi-validator")
|
|
5
|
-
const { BUILDER } = require("@budibase/
|
|
5
|
+
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
6
6
|
const Joi = require("joi")
|
|
7
7
|
|
|
8
8
|
const router = Router()
|
package/src/app.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ExtendableContext } from "koa"
|
|
|
3
3
|
|
|
4
4
|
const env = require("./environment")
|
|
5
5
|
const CouchDB = require("./db")
|
|
6
|
-
require("@budibase/
|
|
6
|
+
require("@budibase/backend-core").init(CouchDB)
|
|
7
7
|
const Koa = require("koa")
|
|
8
8
|
const destroyable = require("server-destroy")
|
|
9
9
|
const koaBody = require("koa-body")
|
|
@@ -6,7 +6,7 @@ const Queue = env.isTest()
|
|
|
6
6
|
? require("../utilities/queue/inMemoryQueue")
|
|
7
7
|
: require("bull")
|
|
8
8
|
const { JobQueues } = require("../constants")
|
|
9
|
-
const { utils } = require("@budibase/
|
|
9
|
+
const { utils } = require("@budibase/backend-core/redis")
|
|
10
10
|
const { opts, redisProtocolUrl } = utils.getRedisOptions()
|
|
11
11
|
|
|
12
12
|
const CLEANUP_PERIOD_MS = 60 * 1000
|
|
@@ -35,6 +35,11 @@ exports.definition = {
|
|
|
35
35
|
type: "object",
|
|
36
36
|
description: "The response from the datasource execution",
|
|
37
37
|
},
|
|
38
|
+
info: {
|
|
39
|
+
type: "object",
|
|
40
|
+
description:
|
|
41
|
+
"Some query types may return extra data, like headers from a REST query",
|
|
42
|
+
},
|
|
38
43
|
success: {
|
|
39
44
|
type: "boolean",
|
|
40
45
|
description: "Whether the action was successful",
|
|
@@ -67,14 +72,17 @@ exports.run = async function ({ inputs, appId, emitter }) {
|
|
|
67
72
|
})
|
|
68
73
|
|
|
69
74
|
try {
|
|
70
|
-
await queryController.
|
|
75
|
+
await queryController.executeV1(ctx)
|
|
76
|
+
const { data, ...rest } = ctx.body
|
|
71
77
|
return {
|
|
72
|
-
response:
|
|
78
|
+
response: data,
|
|
79
|
+
info: rest,
|
|
73
80
|
success: true,
|
|
74
81
|
}
|
|
75
82
|
} catch (err) {
|
|
76
83
|
return {
|
|
77
84
|
success: false,
|
|
85
|
+
info: {},
|
|
78
86
|
response: automationUtils.getError(err),
|
|
79
87
|
}
|
|
80
88
|
}
|
package/src/automations/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ const { queue } = require("./bullboard")
|
|
|
6
6
|
const newid = require("../db/newid")
|
|
7
7
|
const { updateEntityMetadata } = require("../utilities")
|
|
8
8
|
const { MetadataTypes } = require("../constants")
|
|
9
|
-
const { getDeployedAppID } = require("@budibase/
|
|
9
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db")
|
|
10
10
|
const { cloneDeep } = require("lodash/fp")
|
|
11
11
|
|
|
12
12
|
const WH_STEP_ID = definitions.WEBHOOK.stepId
|
package/src/constants/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
2
|
-
const { UserStatus } = require("@budibase/
|
|
3
|
-
const { ObjectStoreBuckets } = require("@budibase/
|
|
1
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
|
+
const { UserStatus } = require("@budibase/backend-core/constants")
|
|
3
|
+
const { ObjectStoreBuckets } = require("@budibase/backend-core/objectStore")
|
|
4
4
|
|
|
5
5
|
exports.JobQueues = {
|
|
6
6
|
AUTOMATIONS: "automationQueue",
|
package/src/constants/screens.js
CHANGED
package/src/db/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PouchDB = require("pouchdb")
|
|
2
|
-
const { getCouchUrl } = require("@budibase/
|
|
2
|
+
const { getCouchUrl } = require("@budibase/backend-core/db")
|
|
3
3
|
const replicationStream = require("pouchdb-replication-stream")
|
|
4
4
|
const allDbs = require("pouchdb-all-dbs")
|
|
5
5
|
const find = require("pouchdb-find")
|
package/src/db/utils.js
CHANGED
|
@@ -240,6 +240,16 @@ export interface RestConfig {
|
|
|
240
240
|
[key: string]: any
|
|
241
241
|
}
|
|
242
242
|
authConfigs: AuthConfig[]
|
|
243
|
+
staticVariables: {
|
|
244
|
+
[key: string]: string
|
|
245
|
+
}
|
|
246
|
+
dynamicVariables: [
|
|
247
|
+
{
|
|
248
|
+
name: string
|
|
249
|
+
queryId: string
|
|
250
|
+
value: string
|
|
251
|
+
}
|
|
252
|
+
]
|
|
243
253
|
}
|
|
244
254
|
|
|
245
255
|
export interface Query {
|
package/src/integrations/rest.ts
CHANGED
|
@@ -48,7 +48,10 @@ module RestModule {
|
|
|
48
48
|
const { performance } = require("perf_hooks")
|
|
49
49
|
const FormData = require("form-data")
|
|
50
50
|
const { URLSearchParams } = require("url")
|
|
51
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
parseStringPromise: xmlParser,
|
|
53
|
+
Builder: XmlBuilder,
|
|
54
|
+
} = require("xml2js")
|
|
52
55
|
|
|
53
56
|
const SCHEMA: Integration = {
|
|
54
57
|
docs: "https://github.com/node-fetch/node-fetch",
|
|
@@ -168,7 +171,7 @@ module RestModule {
|
|
|
168
171
|
getUrl(path: string, queryString: string): string {
|
|
169
172
|
const main = `${path}?${queryString}`
|
|
170
173
|
let complete = main
|
|
171
|
-
if (this.config.url && !main.startsWith(
|
|
174
|
+
if (this.config.url && !main.startsWith("http")) {
|
|
172
175
|
complete = !this.config.url ? main : `${this.config.url}/${main}`
|
|
173
176
|
}
|
|
174
177
|
if (!complete.startsWith("http")) {
|
|
@@ -211,7 +214,7 @@ module RestModule {
|
|
|
211
214
|
break
|
|
212
215
|
case BodyTypes.XML:
|
|
213
216
|
if (object != null) {
|
|
214
|
-
string =
|
|
217
|
+
string = new XmlBuilder().buildObject(object)
|
|
215
218
|
}
|
|
216
219
|
input.body = string
|
|
217
220
|
input.headers["Content-Type"] = "application/xml"
|
|
@@ -2,11 +2,11 @@ const {
|
|
|
2
2
|
getUserRoleHierarchy,
|
|
3
3
|
getRequiredResourceRole,
|
|
4
4
|
BUILTIN_ROLE_IDS,
|
|
5
|
-
} = require("@budibase/
|
|
5
|
+
} = require("@budibase/backend-core/roles")
|
|
6
6
|
const {
|
|
7
7
|
PermissionTypes,
|
|
8
8
|
doesHaveBasePermission,
|
|
9
|
-
} = require("@budibase/
|
|
9
|
+
} = require("@budibase/backend-core/permissions")
|
|
10
10
|
const builderMiddleware = require("./builder")
|
|
11
11
|
const { isWebhookEndpoint } = require("./utils")
|
|
12
12
|
|
|
@@ -7,8 +7,8 @@ const {
|
|
|
7
7
|
} = require("../utilities/redis")
|
|
8
8
|
const CouchDB = require("../db")
|
|
9
9
|
const { DocumentTypes } = require("../db/utils")
|
|
10
|
-
const { PermissionTypes } = require("@budibase/
|
|
11
|
-
const { app: appCache } = require("@budibase/
|
|
10
|
+
const { PermissionTypes } = require("@budibase/backend-core/permissions")
|
|
11
|
+
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
12
12
|
|
|
13
13
|
const DEBOUNCE_TIME_SEC = 30
|
|
14
14
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const {
|
|
2
|
+
getAppId,
|
|
3
|
+
setCookie,
|
|
4
|
+
getCookie,
|
|
5
|
+
clearCookie,
|
|
6
|
+
} = require("@budibase/backend-core/utils")
|
|
7
|
+
const { Cookies } = require("@budibase/backend-core/constants")
|
|
8
|
+
const { getRole } = require("@budibase/backend-core/roles")
|
|
9
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
6
10
|
const { generateUserMetadataID, isDevAppID } = require("../db/utils")
|
|
7
|
-
const { dbExists } = require("@budibase/
|
|
8
|
-
const { isUserInAppTenant } = require("@budibase/
|
|
11
|
+
const { dbExists } = require("@budibase/backend-core/db")
|
|
12
|
+
const { isUserInAppTenant } = require("@budibase/backend-core/tenancy")
|
|
9
13
|
const { getCachedSelf } = require("../utilities/global")
|
|
10
14
|
const CouchDB = require("../db")
|
|
11
15
|
const env = require("../environment")
|
|
@@ -9,8 +9,8 @@ jest.mock("../../environment", () => ({
|
|
|
9
9
|
)
|
|
10
10
|
const authorizedMiddleware = require("../authorized")
|
|
11
11
|
const env = require("../../environment")
|
|
12
|
-
const { PermissionTypes, PermissionLevels } = require("@budibase/
|
|
13
|
-
require("@budibase/
|
|
12
|
+
const { PermissionTypes, PermissionLevels } = require("@budibase/backend-core/permissions")
|
|
13
|
+
require("@budibase/backend-core").init(require("../../db"))
|
|
14
14
|
|
|
15
15
|
class TestConfiguration {
|
|
16
16
|
constructor(role) {
|
|
@@ -23,7 +23,7 @@ function mockReset() {
|
|
|
23
23
|
function mockAuthWithNoCookie() {
|
|
24
24
|
jest.resetModules()
|
|
25
25
|
mockWorker()
|
|
26
|
-
jest.mock("@budibase/
|
|
26
|
+
jest.mock("@budibase/backend-core/cache", () => ({
|
|
27
27
|
user: {
|
|
28
28
|
getUser: () => {
|
|
29
29
|
return {
|
|
@@ -32,34 +32,30 @@ function mockAuthWithNoCookie() {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
}))
|
|
35
|
-
jest.mock("@budibase/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Cookies: {},
|
|
43
|
-
},
|
|
35
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
36
|
+
getAppId: jest.fn(),
|
|
37
|
+
setCookie: jest.fn(),
|
|
38
|
+
getCookie: jest.fn(),
|
|
39
|
+
}))
|
|
40
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
41
|
+
Cookies: {},
|
|
44
42
|
}))
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
function mockAuthWithCookie() {
|
|
48
46
|
jest.resetModules()
|
|
49
47
|
mockWorker()
|
|
50
|
-
jest.mock("@budibase/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return "app_test"
|
|
54
|
-
},
|
|
55
|
-
setCookie: jest.fn(),
|
|
56
|
-
getCookie: () => ({appId: "app_different", roleId: "PUBLIC"}),
|
|
48
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
49
|
+
getAppId: () => {
|
|
50
|
+
return "app_test"
|
|
57
51
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
setCookie: jest.fn(),
|
|
53
|
+
getCookie: () => ({appId: "app_different", roleId: "PUBLIC"}),
|
|
54
|
+
}))
|
|
55
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
56
|
+
Cookies: {
|
|
57
|
+
Auth: "auth",
|
|
58
|
+
CurrentApp: "currentapp",
|
|
63
59
|
},
|
|
64
60
|
}))
|
|
65
61
|
}
|
|
@@ -121,7 +117,7 @@ describe("Current app middleware", () => {
|
|
|
121
117
|
async function checkExpected(setCookie) {
|
|
122
118
|
config.setUser()
|
|
123
119
|
await config.executeMiddleware()
|
|
124
|
-
|
|
120
|
+
let { setCookie: cookieFn } = require("@budibase/backend-core/utils")
|
|
125
121
|
if (setCookie) {
|
|
126
122
|
expect(cookieFn).toHaveBeenCalled()
|
|
127
123
|
} else {
|
|
@@ -140,32 +136,30 @@ describe("Current app middleware", () => {
|
|
|
140
136
|
|
|
141
137
|
it("should perform correct when no cookie exists", async () => {
|
|
142
138
|
mockReset()
|
|
143
|
-
jest.mock("@budibase/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return "app_test"
|
|
147
|
-
},
|
|
148
|
-
setCookie: jest.fn(),
|
|
149
|
-
getCookie: jest.fn(),
|
|
150
|
-
},
|
|
151
|
-
constants: {
|
|
152
|
-
Cookies: {},
|
|
139
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
140
|
+
getAppId: () => {
|
|
141
|
+
return "app_test"
|
|
153
142
|
},
|
|
143
|
+
setCookie: jest.fn(),
|
|
144
|
+
getCookie: jest.fn(),
|
|
145
|
+
}))
|
|
146
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
147
|
+
Cookies: {},
|
|
154
148
|
}))
|
|
155
149
|
await checkExpected(true)
|
|
156
150
|
})
|
|
157
151
|
|
|
158
152
|
it("lastly check what occurs when cookie doesn't need updated", async () => {
|
|
159
153
|
mockReset()
|
|
160
|
-
jest.mock("@budibase/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return "app_test"
|
|
164
|
-
},
|
|
165
|
-
setCookie: jest.fn(),
|
|
166
|
-
getCookie: () => ({appId: "app_test", roleId: "PUBLIC"}),
|
|
154
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
155
|
+
getAppId: () => {
|
|
156
|
+
return "app_test"
|
|
167
157
|
},
|
|
168
|
-
|
|
158
|
+
setCookie: jest.fn(),
|
|
159
|
+
getCookie: () => ({appId: "app_test", roleId: "PUBLIC"}),
|
|
160
|
+
}))
|
|
161
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
162
|
+
Cookies: {},
|
|
169
163
|
}))
|
|
170
164
|
await checkExpected(false)
|
|
171
165
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const CouchDB = require("../db")
|
|
2
2
|
const usageQuota = require("../utilities/usageQuota")
|
|
3
3
|
const env = require("../environment")
|
|
4
|
-
const { getTenantId } = require("@budibase/
|
|
4
|
+
const { getTenantId } = require("@budibase/backend-core/tenancy")
|
|
5
5
|
const {
|
|
6
6
|
isExternalTable,
|
|
7
7
|
isRowId: isExternalRowId,
|