@budibase/server 1.0.27-alpha.2 → 1.0.27-alpha.23
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.5522fcd5.css → index.39e01193.css} +1 -1
- package/builder/assets/{index.e9e2c4d7.js → index.52b37e8a.js} +247 -242
- package/builder/assets/{vendor.f9faf6ab.js → vendor.10e2ad1b.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1128 -968
- package/coverage/coverage-final.json +70 -70
- 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 +1 -1
- 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 +102 -120
- 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 +11 -11
- 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 +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 +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 +69 -69
- 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 +79 -40
- package/coverage/lcov-report/middleware/index.html +10 -10
- 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 +531 -87
- package/coverage/lcov-report/threads/utils.js.html +210 -15
- 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 +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 +19 -19
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +211 -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 +1921 -1630
- 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 +46 -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 +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 +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/environment.js +1 -0
- package/dist/integrations/base/sqlTable.js +1 -1
- package/dist/integrations/dynamodb.js +19 -0
- package/dist/integrations/rest.js +71 -22
- package/dist/integrations/s3.js +17 -8
- package/dist/integrations/utils.js +40 -37
- package/dist/middleware/authorized.js +2 -2
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +15 -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 +195 -50
- package/dist/threads/utils.js +62 -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 +2 -2
- package/dist/utilities/redis.js +1 -1
- package/dist/utilities/rowProcessor/index.js +63 -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 +49 -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 +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 +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 +25 -0
- package/src/environment.js +1 -0
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/dynamodb.ts +18 -0
- package/src/integrations/rest.ts +103 -20
- package/src/integrations/s3.ts +18 -7
- package/src/integrations/tests/rest.spec.js +287 -24
- package/src/integrations/utils.ts +8 -7
- package/src/middleware/authorized.js +2 -2
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +20 -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 +203 -55
- package/src/threads/utils.js +66 -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 +2 -2
- package/src/utilities/redis.js +1 -1
- package/src/utilities/rowProcessor/index.js +67 -0
- package/src/utilities/security.js +5 -2
- package/src/utilities/usageQuota.js +2 -2
- package/src/utilities/workerRequests.js +3 -3
|
@@ -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
|
@@ -232,6 +232,8 @@ export interface RestQueryFields {
|
|
|
232
232
|
json: object
|
|
233
233
|
method: string
|
|
234
234
|
authConfigId: string
|
|
235
|
+
pagination: PaginationConfig | null
|
|
236
|
+
paginationValues: PaginationValues | null
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
export interface RestConfig {
|
|
@@ -240,6 +242,29 @@ export interface RestConfig {
|
|
|
240
242
|
[key: string]: any
|
|
241
243
|
}
|
|
242
244
|
authConfigs: AuthConfig[]
|
|
245
|
+
staticVariables: {
|
|
246
|
+
[key: string]: string
|
|
247
|
+
}
|
|
248
|
+
dynamicVariables: [
|
|
249
|
+
{
|
|
250
|
+
name: string
|
|
251
|
+
queryId: string
|
|
252
|
+
value: string
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface PaginationConfig {
|
|
258
|
+
type: string
|
|
259
|
+
location: string
|
|
260
|
+
pageParam: string
|
|
261
|
+
sizeParam: string | null
|
|
262
|
+
responseParam: string | null
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface PaginationValues {
|
|
266
|
+
page: string | number | null
|
|
267
|
+
limit: number | null
|
|
243
268
|
}
|
|
244
269
|
|
|
245
270
|
export interface Query {
|
package/src/environment.js
CHANGED
|
@@ -65,6 +65,7 @@ module.exports = {
|
|
|
65
65
|
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
|
|
66
66
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
67
67
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
|
68
|
+
QUERY_THREAD_TIMEOUT: process.env.QUERY_THREAD_TIMEOUT,
|
|
68
69
|
_set(key, value) {
|
|
69
70
|
process.env[key] = value
|
|
70
71
|
module.exports[key] = value
|
|
@@ -80,6 +80,17 @@ module DynamoModule {
|
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
|
+
describe: {
|
|
84
|
+
type: QueryTypes.FIELDS,
|
|
85
|
+
customisable: true,
|
|
86
|
+
readable: true,
|
|
87
|
+
fields: {
|
|
88
|
+
table: {
|
|
89
|
+
type: DatasourceFieldTypes.STRING,
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
83
94
|
get: {
|
|
84
95
|
type: QueryTypes.FIELDS,
|
|
85
96
|
customisable: true,
|
|
@@ -180,6 +191,13 @@ module DynamoModule {
|
|
|
180
191
|
return response
|
|
181
192
|
}
|
|
182
193
|
|
|
194
|
+
async describe(query: { table: string }) {
|
|
195
|
+
const params = {
|
|
196
|
+
TableName: query.table,
|
|
197
|
+
}
|
|
198
|
+
return new AWS.DynamoDB().describeTable(params).promise()
|
|
199
|
+
}
|
|
200
|
+
|
|
183
201
|
async get(query: { table: string; json: object }) {
|
|
184
202
|
const params = {
|
|
185
203
|
TableName: query.table,
|
package/src/integrations/rest.ts
CHANGED
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
QueryTypes,
|
|
5
5
|
RestConfig,
|
|
6
6
|
RestQueryFields as RestQuery,
|
|
7
|
+
PaginationConfig,
|
|
7
8
|
AuthType,
|
|
8
9
|
BasicAuthConfig,
|
|
9
10
|
BearerAuthConfig,
|
|
11
|
+
PaginationValues,
|
|
10
12
|
} from "../definitions/datasource"
|
|
11
13
|
import { IntegrationBase } from "./base/IntegrationBase"
|
|
12
14
|
|
|
@@ -40,6 +42,9 @@ const coreFields = {
|
|
|
40
42
|
type: DatasourceFieldTypes.STRING,
|
|
41
43
|
enum: Object.values(BodyTypes),
|
|
42
44
|
},
|
|
45
|
+
pagination: {
|
|
46
|
+
type: DatasourceFieldTypes.OBJECT,
|
|
47
|
+
},
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
module RestModule {
|
|
@@ -48,7 +53,10 @@ module RestModule {
|
|
|
48
53
|
const { performance } = require("perf_hooks")
|
|
49
54
|
const FormData = require("form-data")
|
|
50
55
|
const { URLSearchParams } = require("url")
|
|
51
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
parseStringPromise: xmlParser,
|
|
58
|
+
Builder: XmlBuilder,
|
|
59
|
+
} = require("xml2js")
|
|
52
60
|
|
|
53
61
|
const SCHEMA: Integration = {
|
|
54
62
|
docs: "https://github.com/node-fetch/node-fetch",
|
|
@@ -112,7 +120,7 @@ module RestModule {
|
|
|
112
120
|
this.config = config
|
|
113
121
|
}
|
|
114
122
|
|
|
115
|
-
async parseResponse(response: any) {
|
|
123
|
+
async parseResponse(response: any, pagination: PaginationConfig | null) {
|
|
116
124
|
let data, raw, headers
|
|
117
125
|
const contentType = response.headers.get("content-type") || ""
|
|
118
126
|
try {
|
|
@@ -151,6 +159,13 @@ module RestModule {
|
|
|
151
159
|
for (let [key, value] of Object.entries(headers)) {
|
|
152
160
|
headers[key] = Array.isArray(value) ? value[0] : value
|
|
153
161
|
}
|
|
162
|
+
|
|
163
|
+
// Check if a pagination cursor exists in the response
|
|
164
|
+
let nextCursor = null
|
|
165
|
+
if (pagination?.responseParam) {
|
|
166
|
+
nextCursor = data?.[pagination.responseParam]
|
|
167
|
+
}
|
|
168
|
+
|
|
154
169
|
return {
|
|
155
170
|
data,
|
|
156
171
|
info: {
|
|
@@ -162,13 +177,43 @@ module RestModule {
|
|
|
162
177
|
raw,
|
|
163
178
|
headers,
|
|
164
179
|
},
|
|
180
|
+
pagination: {
|
|
181
|
+
cursor: nextCursor,
|
|
182
|
+
},
|
|
165
183
|
}
|
|
166
184
|
}
|
|
167
185
|
|
|
168
|
-
getUrl(
|
|
186
|
+
getUrl(
|
|
187
|
+
path: string,
|
|
188
|
+
queryString: string,
|
|
189
|
+
pagination: PaginationConfig | null,
|
|
190
|
+
paginationValues: PaginationValues | null
|
|
191
|
+
): string {
|
|
192
|
+
// Add pagination params to query string if required
|
|
193
|
+
if (pagination?.location === "query" && paginationValues) {
|
|
194
|
+
const { pageParam, sizeParam } = pagination
|
|
195
|
+
const params = new URLSearchParams()
|
|
196
|
+
|
|
197
|
+
// Append page number or cursor param if configured
|
|
198
|
+
if (pageParam && paginationValues.page != null) {
|
|
199
|
+
params.append(pageParam, paginationValues.page)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Append page size param if configured
|
|
203
|
+
if (sizeParam && paginationValues.limit != null) {
|
|
204
|
+
params.append(sizeParam, paginationValues.limit)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Prepend query string with pagination params
|
|
208
|
+
let paginationString = params.toString()
|
|
209
|
+
if (paginationString) {
|
|
210
|
+
queryString = `${paginationString}&${queryString}`
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
169
214
|
const main = `${path}?${queryString}`
|
|
170
215
|
let complete = main
|
|
171
|
-
if (this.config.url && !main.startsWith(
|
|
216
|
+
if (this.config.url && !main.startsWith("http")) {
|
|
172
217
|
complete = !this.config.url ? main : `${this.config.url}/${main}`
|
|
173
218
|
}
|
|
174
219
|
if (!complete.startsWith("http")) {
|
|
@@ -177,20 +222,44 @@ module RestModule {
|
|
|
177
222
|
return complete
|
|
178
223
|
}
|
|
179
224
|
|
|
180
|
-
addBody(
|
|
181
|
-
|
|
225
|
+
addBody(
|
|
226
|
+
bodyType: string,
|
|
227
|
+
body: string | any,
|
|
228
|
+
input: any,
|
|
229
|
+
pagination: PaginationConfig | null,
|
|
230
|
+
paginationValues: PaginationValues | null
|
|
231
|
+
) {
|
|
232
|
+
if (!input.headers) {
|
|
233
|
+
input.headers = {}
|
|
234
|
+
}
|
|
235
|
+
if (bodyType === BodyTypes.NONE) {
|
|
236
|
+
return input
|
|
237
|
+
}
|
|
238
|
+
let error,
|
|
239
|
+
object: any = {},
|
|
240
|
+
string = ""
|
|
182
241
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
242
|
+
if (body) {
|
|
243
|
+
string = typeof body !== "string" ? JSON.stringify(body) : body
|
|
244
|
+
object = typeof body === "object" ? body : JSON.parse(body)
|
|
245
|
+
}
|
|
185
246
|
} catch (err) {
|
|
186
247
|
error = err
|
|
187
248
|
}
|
|
188
|
-
|
|
189
|
-
|
|
249
|
+
|
|
250
|
+
// Util to add pagination values to a certain body type
|
|
251
|
+
const addPaginationToBody = (insertFn: Function) => {
|
|
252
|
+
if (pagination?.location === "body") {
|
|
253
|
+
if (pagination?.pageParam && paginationValues?.page != null) {
|
|
254
|
+
insertFn(pagination.pageParam, paginationValues.page)
|
|
255
|
+
}
|
|
256
|
+
if (pagination?.sizeParam && paginationValues?.limit != null) {
|
|
257
|
+
insertFn(pagination.sizeParam, paginationValues.limit)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
190
260
|
}
|
|
261
|
+
|
|
191
262
|
switch (bodyType) {
|
|
192
|
-
case BodyTypes.NONE:
|
|
193
|
-
break
|
|
194
263
|
case BodyTypes.TEXT:
|
|
195
264
|
// content type defaults to plaintext
|
|
196
265
|
input.body = string
|
|
@@ -200,6 +269,9 @@ module RestModule {
|
|
|
200
269
|
for (let [key, value] of Object.entries(object)) {
|
|
201
270
|
params.append(key, value)
|
|
202
271
|
}
|
|
272
|
+
addPaginationToBody((key: string, value: any) => {
|
|
273
|
+
params.append(key, value)
|
|
274
|
+
})
|
|
203
275
|
input.body = params
|
|
204
276
|
break
|
|
205
277
|
case BodyTypes.FORM_DATA:
|
|
@@ -207,22 +279,27 @@ module RestModule {
|
|
|
207
279
|
for (let [key, value] of Object.entries(object)) {
|
|
208
280
|
form.append(key, value)
|
|
209
281
|
}
|
|
282
|
+
addPaginationToBody((key: string, value: any) => {
|
|
283
|
+
form.append(key, value)
|
|
284
|
+
})
|
|
210
285
|
input.body = form
|
|
211
286
|
break
|
|
212
287
|
case BodyTypes.XML:
|
|
213
288
|
if (object != null) {
|
|
214
|
-
string =
|
|
289
|
+
string = new XmlBuilder().buildObject(object)
|
|
215
290
|
}
|
|
216
291
|
input.body = string
|
|
217
292
|
input.headers["Content-Type"] = "application/xml"
|
|
218
293
|
break
|
|
219
|
-
default:
|
|
220
294
|
case BodyTypes.JSON:
|
|
221
295
|
// if JSON error, throw it
|
|
222
296
|
if (error) {
|
|
223
297
|
throw "Invalid JSON for request body"
|
|
224
298
|
}
|
|
225
|
-
|
|
299
|
+
addPaginationToBody((key: string, value: any) => {
|
|
300
|
+
object[key] = value
|
|
301
|
+
})
|
|
302
|
+
input.body = JSON.stringify(object)
|
|
226
303
|
input.headers["Content-Type"] = "application/json"
|
|
227
304
|
break
|
|
228
305
|
}
|
|
@@ -268,6 +345,8 @@ module RestModule {
|
|
|
268
345
|
bodyType,
|
|
269
346
|
requestBody,
|
|
270
347
|
authConfigId,
|
|
348
|
+
pagination,
|
|
349
|
+
paginationValues,
|
|
271
350
|
} = query
|
|
272
351
|
const authHeaders = this.getAuthHeaders(authConfigId)
|
|
273
352
|
|
|
@@ -286,14 +365,18 @@ module RestModule {
|
|
|
286
365
|
}
|
|
287
366
|
|
|
288
367
|
let input: any = { method, headers: this.headers }
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
368
|
+
input = this.addBody(
|
|
369
|
+
bodyType,
|
|
370
|
+
requestBody,
|
|
371
|
+
input,
|
|
372
|
+
pagination,
|
|
373
|
+
paginationValues
|
|
374
|
+
)
|
|
292
375
|
|
|
293
376
|
this.startTimeMs = performance.now()
|
|
294
|
-
const url = this.getUrl(path, queryString)
|
|
377
|
+
const url = this.getUrl(path, queryString, pagination, paginationValues)
|
|
295
378
|
const response = await fetch(url, input)
|
|
296
|
-
return await this.parseResponse(response)
|
|
379
|
+
return await this.parseResponse(response, pagination)
|
|
297
380
|
}
|
|
298
381
|
|
|
299
382
|
async create(opts: RestQuery) {
|
package/src/integrations/s3.ts
CHANGED
|
@@ -8,6 +8,8 @@ module S3Module {
|
|
|
8
8
|
region: string
|
|
9
9
|
accessKeyId: string
|
|
10
10
|
secretAccessKey: string
|
|
11
|
+
s3ForcePathStyle: boolean
|
|
12
|
+
endpoint?: string
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
const SCHEMA: Integration = {
|
|
@@ -18,7 +20,7 @@ module S3Module {
|
|
|
18
20
|
datasource: {
|
|
19
21
|
region: {
|
|
20
22
|
type: "string",
|
|
21
|
-
required:
|
|
23
|
+
required: false,
|
|
22
24
|
default: "us-east-1",
|
|
23
25
|
},
|
|
24
26
|
accessKeyId: {
|
|
@@ -29,6 +31,15 @@ module S3Module {
|
|
|
29
31
|
type: "password",
|
|
30
32
|
required: true,
|
|
31
33
|
},
|
|
34
|
+
endpoint: {
|
|
35
|
+
type: "string",
|
|
36
|
+
required: false,
|
|
37
|
+
},
|
|
38
|
+
signatureVersion: {
|
|
39
|
+
type: "string",
|
|
40
|
+
required: false,
|
|
41
|
+
default: "v4",
|
|
42
|
+
},
|
|
32
43
|
},
|
|
33
44
|
query: {
|
|
34
45
|
read: {
|
|
@@ -46,16 +57,16 @@ module S3Module {
|
|
|
46
57
|
class S3Integration implements IntegrationBase {
|
|
47
58
|
private readonly config: S3Config
|
|
48
59
|
private client: any
|
|
49
|
-
private connectionPromise: Promise<any>
|
|
50
60
|
|
|
51
61
|
constructor(config: S3Config) {
|
|
52
62
|
this.config = config
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
if (this.config.endpoint) {
|
|
64
|
+
this.config.s3ForcePathStyle = true
|
|
65
|
+
} else {
|
|
66
|
+
delete this.config.endpoint
|
|
67
|
+
}
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
AWS.config.update(this.config)
|
|
69
|
+
this.client = new AWS.S3(this.config)
|
|
59
70
|
}
|
|
60
71
|
|
|
61
72
|
async read(query: { bucket: string }) {
|