@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const { join } = require("./centralPath");
|
|
3
3
|
const { homedir } = require("os");
|
|
4
4
|
const env = require("../environment");
|
|
5
|
-
const { budibaseTempDir } = require("@budibase/
|
|
5
|
+
const { budibaseTempDir } = require("@budibase/backend-core/objectStore");
|
|
6
6
|
module.exports.budibaseAppsDir = function () {
|
|
7
7
|
return env.BUDIBASE_DIR || join(homedir(), ".budibase");
|
|
8
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { ObjectStore, makeSureBucketExists, upload, streamUpload, retrieve, retrieveToTmp, deleteFolder, uploadDirectory, downloadTarball, } = require("@budibase/
|
|
2
|
+
const { ObjectStore, makeSureBucketExists, upload, deleteFiles, streamUpload, retrieve, retrieveToTmp, deleteFolder, uploadDirectory, downloadTarball, } = require("@budibase/backend-core/objectStore");
|
|
3
3
|
/***********************************
|
|
4
4
|
* NOTE *
|
|
5
5
|
* This file purely exists so that *
|
|
@@ -17,3 +17,4 @@ exports.retrieveToTmp = retrieveToTmp;
|
|
|
17
17
|
exports.deleteFolder = deleteFolder;
|
|
18
18
|
exports.uploadDirectory = uploadDirectory;
|
|
19
19
|
exports.downloadTarball = downloadTarball;
|
|
20
|
+
exports.deleteFiles = deleteFiles;
|
package/dist/utilities/global.js
CHANGED
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const { getMultiIDParams, getGlobalIDFromUserMetadataID, } = require("../db/utils");
|
|
12
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
13
|
-
const { getDeployedAppID } = require("@budibase/
|
|
14
|
-
const { getGlobalUserParams } = require("@budibase/
|
|
15
|
-
const { user: userCache } = require("@budibase/
|
|
16
|
-
const { getGlobalDB, isUserInAppTenant } = require("@budibase/
|
|
12
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
13
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db");
|
|
14
|
+
const { getGlobalUserParams } = require("@budibase/backend-core/db");
|
|
15
|
+
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
16
|
+
const { getGlobalDB, isUserInAppTenant, } = require("@budibase/backend-core/tenancy");
|
|
17
17
|
const env = require("../environment");
|
|
18
18
|
exports.updateAppRole = (appId, user) => {
|
|
19
19
|
if (!user || !user.roles) {
|
package/dist/utilities/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const env = require("../environment");
|
|
12
12
|
const { OBJ_STORE_DIRECTORY } = require("../constants");
|
|
13
|
-
const { sanitizeKey } = require("@budibase/
|
|
13
|
+
const { sanitizeKey } = require("@budibase/backend-core/objectStore");
|
|
14
14
|
const CouchDB = require("../db");
|
|
15
15
|
const { generateMetadataID } = require("../db/utils");
|
|
16
16
|
const Readable = require("stream").Readable;
|
package/dist/utilities/redis.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { Client, utils } = require("@budibase/
|
|
11
|
+
const { Client, utils } = require("@budibase/backend-core/redis");
|
|
12
12
|
const { getGlobalIDFromUserMetadataID } = require("../db/utils");
|
|
13
13
|
const APP_DEV_LOCK_SECONDS = 600;
|
|
14
14
|
const AUTOMATION_TEST_FLAG_SECONDS = 60;
|
|
@@ -13,6 +13,10 @@ const { cloneDeep } = require("lodash/fp");
|
|
|
13
13
|
const { FieldTypes, AutoFieldSubTypes } = require("../../constants");
|
|
14
14
|
const { attachmentsRelativeURL } = require("../index");
|
|
15
15
|
const { processFormulas } = require("./utils");
|
|
16
|
+
const { deleteFiles } = require("../../utilities/fileSystem/utilities");
|
|
17
|
+
const { ObjectStoreBuckets } = require("../../constants");
|
|
18
|
+
const { isProdAppID, getDeployedAppID, dbExists, } = require("@budibase/backend-core/db");
|
|
19
|
+
const CouchDB = require("../../db");
|
|
16
20
|
const BASE_AUTO_ID = 1;
|
|
17
21
|
/**
|
|
18
22
|
* A map of how we convert various properties in rows to each other based on the row type.
|
|
@@ -89,7 +93,36 @@ const TYPE_TRANSFORM_MAP = {
|
|
|
89
93
|
[FieldTypes.AUTO]: {
|
|
90
94
|
parse: () => undefined,
|
|
91
95
|
},
|
|
96
|
+
[FieldTypes.JSON]: {
|
|
97
|
+
parse: input => {
|
|
98
|
+
try {
|
|
99
|
+
if (input === "") {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
return JSON.parse(input);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return input;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
},
|
|
92
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Given the old state of the row and the new one after an update, this will
|
|
112
|
+
* find the keys that have been removed in the updated row.
|
|
113
|
+
*/
|
|
114
|
+
function getRemovedAttachmentKeys(oldRow, row, attachmentKey) {
|
|
115
|
+
if (!oldRow[attachmentKey]) {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
const oldKeys = oldRow[attachmentKey].map(attachment => attachment.key);
|
|
119
|
+
// no attachments in new row, all removed
|
|
120
|
+
if (!row[attachmentKey]) {
|
|
121
|
+
return oldKeys;
|
|
122
|
+
}
|
|
123
|
+
const newKeys = row[attachmentKey].map(attachment => attachment.key);
|
|
124
|
+
return oldKeys.filter(key => newKeys.indexOf(key) === -1);
|
|
125
|
+
}
|
|
93
126
|
/**
|
|
94
127
|
* This will update any auto columns that are found on the row/table with the correct information based on
|
|
95
128
|
* time now and the current logged in user making the request.
|
|
@@ -240,3 +273,46 @@ exports.outputProcessing = (ctx, table, rows, opts = { squash: true }) => __awai
|
|
|
240
273
|
}
|
|
241
274
|
return wasArray ? enriched : enriched[0];
|
|
242
275
|
});
|
|
276
|
+
/**
|
|
277
|
+
* Clean up any attachments that were attached to a row.
|
|
278
|
+
* @param {string} appId The ID of the app from which a row is being deleted.
|
|
279
|
+
* @param {object} table The table from which a row is being removed.
|
|
280
|
+
* @param {any} row optional - the row being removed.
|
|
281
|
+
* @param {any} rows optional - if multiple rows being deleted can do this in bulk.
|
|
282
|
+
* @param {any} oldRow optional - if updating a row this will determine the difference.
|
|
283
|
+
* @return {Promise<void>} When all attachments have been removed this will return.
|
|
284
|
+
*/
|
|
285
|
+
exports.cleanupAttachments = (appId, table, { row, rows, oldRow }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
286
|
+
if (!isProdAppID(appId)) {
|
|
287
|
+
const prodAppId = getDeployedAppID(appId);
|
|
288
|
+
// if prod exists, then don't allow deleting
|
|
289
|
+
const exists = yield dbExists(CouchDB, prodAppId);
|
|
290
|
+
if (exists) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
let files = [];
|
|
295
|
+
function addFiles(row, key) {
|
|
296
|
+
if (row[key]) {
|
|
297
|
+
files = files.concat(row[key].map(attachment => attachment.key));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
for (let [key, schema] of Object.entries(table.schema)) {
|
|
301
|
+
if (schema.type !== FieldTypes.ATTACHMENT) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
// if updating, need to manage the differences
|
|
305
|
+
if (oldRow && row) {
|
|
306
|
+
files = files.concat(getRemovedAttachmentKeys(oldRow, row, key));
|
|
307
|
+
}
|
|
308
|
+
else if (row) {
|
|
309
|
+
addFiles(row, key);
|
|
310
|
+
}
|
|
311
|
+
else if (rows) {
|
|
312
|
+
rows.forEach(row => addFiles(row, key));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (files.length > 0) {
|
|
316
|
+
return deleteFiles(ObjectStoreBuckets.APPS, files);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { PermissionLevels, PermissionTypes, getBuiltinPermissionByID, isPermissionLevelHigherThanRead, } = require("@budibase/
|
|
3
|
-
const { lowerBuiltinRoleID, getBuiltinRoles } = require("@budibase/
|
|
2
|
+
const { PermissionLevels, PermissionTypes, getBuiltinPermissionByID, isPermissionLevelHigherThanRead, } = require("@budibase/backend-core/permissions");
|
|
3
|
+
const { lowerBuiltinRoleID, getBuiltinRoles, } = require("@budibase/backend-core/roles");
|
|
4
4
|
const { DocumentTypes } = require("../db/utils");
|
|
5
5
|
const CURRENTLY_SUPPORTED_LEVELS = [
|
|
6
6
|
PermissionLevels.WRITE,
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const env = require("../environment");
|
|
12
|
-
const { getGlobalDB } = require("@budibase/
|
|
13
|
-
const { StaticDatabases, generateNewUsageQuotaDoc, } = require("@budibase/
|
|
12
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
13
|
+
const { StaticDatabases, generateNewUsageQuotaDoc, } = require("@budibase/backend-core/db");
|
|
14
14
|
function getNewQuotaReset() {
|
|
15
15
|
return Date.now() + 2592000000;
|
|
16
16
|
}
|
|
@@ -11,10 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const fetch = require("node-fetch");
|
|
12
12
|
const env = require("../environment");
|
|
13
13
|
const { checkSlashesInUrl } = require("./index");
|
|
14
|
-
const { getDeployedAppID } = require("@budibase/
|
|
14
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db");
|
|
15
15
|
const { updateAppRole } = require("./global");
|
|
16
|
-
const { Headers } = require("@budibase/
|
|
17
|
-
const { getTenantId, isTenantIdSet } = require("@budibase/
|
|
16
|
+
const { Headers } = require("@budibase/backend-core/constants");
|
|
17
|
+
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy");
|
|
18
18
|
function request(ctx, request) {
|
|
19
19
|
if (!request.headers) {
|
|
20
20
|
request.headers = {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.27-alpha.
|
|
4
|
+
"version": "1.0.27-alpha.13",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/
|
|
74
|
-
"@budibase/client": "^1.0.27-alpha.
|
|
75
|
-
"@budibase/string-templates": "^1.0.27-alpha.
|
|
73
|
+
"@budibase/backend-core": "^1.0.27-alpha.13",
|
|
74
|
+
"@budibase/client": "^1.0.27-alpha.13",
|
|
75
|
+
"@budibase/string-templates": "^1.0.27-alpha.13",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"pouchdb-replication-stream": "1.2.9",
|
|
123
123
|
"server-destroy": "1.0.1",
|
|
124
124
|
"svelte": "^3.38.2",
|
|
125
|
+
"swagger-parser": "^10.0.3",
|
|
125
126
|
"to-json-schema": "0.2.5",
|
|
126
127
|
"uuid": "3.3.2",
|
|
127
128
|
"validate.js": "0.13.1",
|
|
@@ -164,5 +165,5 @@
|
|
|
164
165
|
"optionalDependencies": {
|
|
165
166
|
"oracledb": "^5.3.0"
|
|
166
167
|
},
|
|
167
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "e48e21ffb846288ce46883674626b79755617445"
|
|
168
169
|
}
|
package/scripts/replicateApp.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const CouchDB = require("../src/db")
|
|
9
9
|
const { DocumentTypes } = require("../src/db/utils")
|
|
10
|
-
const { getAllDbs } = require("@budibase/
|
|
10
|
+
const { getAllDbs } = require("@budibase/backend-core/db")
|
|
11
11
|
|
|
12
12
|
const appName = process.argv[2].toLowerCase()
|
|
13
13
|
const remoteUrl = process.argv[3]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { StaticDatabases } = require("@budibase/
|
|
2
|
-
const { getGlobalDB } = require("@budibase/
|
|
1
|
+
const { StaticDatabases } = require("@budibase/backend-core/db")
|
|
2
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
3
3
|
|
|
4
4
|
const KEYS_DOC = StaticDatabases.GLOBAL.docs.apiKeys
|
|
5
5
|
|
|
@@ -19,7 +19,10 @@ const {
|
|
|
19
19
|
DocumentTypes,
|
|
20
20
|
AppStatus,
|
|
21
21
|
} = require("../../db/utils")
|
|
22
|
-
const {
|
|
22
|
+
const {
|
|
23
|
+
BUILTIN_ROLE_IDS,
|
|
24
|
+
AccessController,
|
|
25
|
+
} = require("@budibase/backend-core/roles")
|
|
23
26
|
const { BASE_LAYOUTS } = require("../../constants/layouts")
|
|
24
27
|
const { cloneDeep } = require("lodash/fp")
|
|
25
28
|
const { processObject } = require("@budibase/string-templates")
|
|
@@ -28,7 +31,7 @@ const {
|
|
|
28
31
|
isDevAppID,
|
|
29
32
|
getDeployedAppID,
|
|
30
33
|
Replication,
|
|
31
|
-
} = require("@budibase/
|
|
34
|
+
} = require("@budibase/backend-core/db")
|
|
32
35
|
const { USERS_TABLE_SCHEMA } = require("../../constants")
|
|
33
36
|
const {
|
|
34
37
|
getDeployedApps,
|
|
@@ -41,9 +44,9 @@ const {
|
|
|
41
44
|
backupClientLibrary,
|
|
42
45
|
revertClientLibrary,
|
|
43
46
|
} = require("../../utilities/fileSystem/clientLibrary")
|
|
44
|
-
const { getTenantId, isMultiTenant } = require("@budibase/
|
|
47
|
+
const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
45
48
|
const { syncGlobalUsers } = require("./user")
|
|
46
|
-
const { app: appCache } = require("@budibase/
|
|
49
|
+
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
47
50
|
const { cleanupAutomations } = require("../../automations/utils")
|
|
48
51
|
|
|
49
52
|
const URL_REGEX_SLASH = /\/|\\/g
|
|
@@ -2,7 +2,7 @@ const CouchDB = require("../../db")
|
|
|
2
2
|
const { outputProcessing } = require("../../utilities/rowProcessor")
|
|
3
3
|
const { InternalTables } = require("../../db/utils")
|
|
4
4
|
const { getFullUser } = require("../../utilities/users")
|
|
5
|
-
const { BUILTIN_ROLE_IDS } = require("@budibase/
|
|
5
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
6
6
|
|
|
7
7
|
exports.fetchSelf = async ctx => {
|
|
8
8
|
const appId = ctx.appId
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const env = require("../../environment")
|
|
2
|
-
const { getAllApps } = require("@budibase/
|
|
2
|
+
const { getAllApps } = require("@budibase/backend-core/db")
|
|
3
3
|
const CouchDB = require("../../db")
|
|
4
4
|
const {
|
|
5
5
|
exportDB,
|
|
@@ -7,7 +7,10 @@ const {
|
|
|
7
7
|
readFileSync,
|
|
8
8
|
} = require("../../utilities/fileSystem")
|
|
9
9
|
const { stringToReadStream } = require("../../utilities")
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
getGlobalDBName,
|
|
12
|
+
getGlobalDB,
|
|
13
|
+
} = require("@budibase/backend-core/tenancy")
|
|
11
14
|
const { create } = require("./application")
|
|
12
15
|
const { getDocParams, DocumentTypes, isDevAppID } = require("../../db/utils")
|
|
13
16
|
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
const { BuildSchemaErrors, InvalidColumns } = require("../../constants")
|
|
11
11
|
const { integrations } = require("../../integrations")
|
|
12
12
|
const { getDatasourceAndQuery } = require("./row/utils")
|
|
13
|
+
const { invalidateDynamicVariables } = require("../../threads/utils")
|
|
13
14
|
|
|
14
15
|
exports.fetch = async function (ctx) {
|
|
15
16
|
const database = new CouchDB(ctx.appId)
|
|
@@ -57,10 +58,43 @@ exports.buildSchemaFromDb = async function (ctx) {
|
|
|
57
58
|
ctx.body = response
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Check for variables that have been updated or removed and invalidate them.
|
|
63
|
+
*/
|
|
64
|
+
const invalidateVariables = async (existingDatasource, updatedDatasource) => {
|
|
65
|
+
const existingVariables = existingDatasource.config.dynamicVariables
|
|
66
|
+
const updatedVariables = updatedDatasource.config.dynamicVariables
|
|
67
|
+
const toInvalidate = []
|
|
68
|
+
|
|
69
|
+
if (!existingVariables) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!updatedVariables) {
|
|
74
|
+
// invalidate all
|
|
75
|
+
toInvalidate.push(...existingVariables)
|
|
76
|
+
} else {
|
|
77
|
+
// invaldate changed / removed
|
|
78
|
+
existingVariables.forEach(existing => {
|
|
79
|
+
const unchanged = updatedVariables.find(
|
|
80
|
+
updated =>
|
|
81
|
+
existing.name === updated.name &&
|
|
82
|
+
existing.queryId === updated.queryId &&
|
|
83
|
+
existing.value === updated.value
|
|
84
|
+
)
|
|
85
|
+
if (!unchanged) {
|
|
86
|
+
toInvalidate.push(existing)
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
await invalidateDynamicVariables(toInvalidate)
|
|
91
|
+
}
|
|
92
|
+
|
|
60
93
|
exports.update = async function (ctx) {
|
|
61
94
|
const db = new CouchDB(ctx.appId)
|
|
62
95
|
const datasourceId = ctx.params.datasourceId
|
|
63
96
|
let datasource = await db.get(datasourceId)
|
|
97
|
+
await invalidateVariables(datasource, ctx.request.body)
|
|
64
98
|
datasource = { ...datasource, ...ctx.request.body }
|
|
65
99
|
|
|
66
100
|
const response = await db.put(datasource)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const CouchDB = require("../../../db")
|
|
2
2
|
const Deployment = require("./Deployment")
|
|
3
|
-
const { Replication, getDeployedAppID } = require("@budibase/
|
|
3
|
+
const { Replication, getDeployedAppID } = require("@budibase/backend-core/db")
|
|
4
4
|
const { DocumentTypes, getAutomationParams } = require("../../../db/utils")
|
|
5
5
|
const {
|
|
6
6
|
disableAllCrons,
|
|
7
7
|
enableCronTrigger,
|
|
8
8
|
} = require("../../../automations/utils")
|
|
9
|
-
const { app: appCache } = require("@budibase/
|
|
9
|
+
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
10
10
|
|
|
11
11
|
// the max time we can wait for an invalidation to complete before considering it failed
|
|
12
12
|
const MAX_PENDING_TIME_MS = 30 * 60000
|
|
@@ -4,9 +4,9 @@ const env = require("../../environment")
|
|
|
4
4
|
const { checkSlashesInUrl } = require("../../utilities")
|
|
5
5
|
const { request } = require("../../utilities/workerRequests")
|
|
6
6
|
const { clearLock } = require("../../utilities/redis")
|
|
7
|
-
const { Replication } = require("@budibase/
|
|
7
|
+
const { Replication } = require("@budibase/backend-core/db")
|
|
8
8
|
const { DocumentTypes } = require("../../db/utils")
|
|
9
|
-
const { app: appCache } = require("@budibase/
|
|
9
|
+
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
10
10
|
|
|
11
11
|
async function redirect(ctx, method, path = "global") {
|
|
12
12
|
const { devPath } = ctx.params
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const CouchDB = require("../../db")
|
|
2
2
|
const { getDeployedApps } = require("../../utilities/workerRequests")
|
|
3
|
-
const { getScopedConfig } = require("@budibase/
|
|
4
|
-
const { Configs } = require("@budibase/
|
|
3
|
+
const { getScopedConfig } = require("@budibase/backend-core/db")
|
|
4
|
+
const { Configs } = require("@budibase/backend-core/constants")
|
|
5
5
|
const { checkSlashesInUrl } = require("../../utilities")
|
|
6
6
|
|
|
7
7
|
exports.fetchUrls = async ctx => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const { getBuiltinPermissions } = require("@budibase/
|
|
1
|
+
const { getBuiltinPermissions } = require("@budibase/backend-core/permissions")
|
|
2
2
|
const {
|
|
3
3
|
isBuiltin,
|
|
4
4
|
getDBRoleID,
|
|
5
5
|
getExternalRoleID,
|
|
6
6
|
getBuiltinRoles,
|
|
7
|
-
} = require("@budibase/
|
|
7
|
+
} = require("@budibase/backend-core/roles")
|
|
8
8
|
const { getRoleParams } = require("../../db/utils")
|
|
9
9
|
const CouchDB = require("../../db")
|
|
10
10
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Query, QueryParameter } from "../../../../../../definitions/datasource"
|
|
2
|
+
import { URL } from "url"
|
|
2
3
|
|
|
3
4
|
export interface ImportInfo {
|
|
4
|
-
url: string
|
|
5
5
|
name: string
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -23,6 +23,7 @@ export abstract class ImportSource {
|
|
|
23
23
|
name: string,
|
|
24
24
|
method: string,
|
|
25
25
|
path: string,
|
|
26
|
+
url: URL,
|
|
26
27
|
queryString: string,
|
|
27
28
|
headers: object = {},
|
|
28
29
|
parameters: QueryParameter[] = [],
|
|
@@ -33,6 +34,7 @@ export abstract class ImportSource {
|
|
|
33
34
|
const transformer = "return data"
|
|
34
35
|
const schema = {}
|
|
35
36
|
path = this.processPath(path)
|
|
37
|
+
path = `${url.origin}/${path}`
|
|
36
38
|
queryString = this.processQuery(queryString)
|
|
37
39
|
const requestBody = JSON.stringify(body, null, 2)
|
|
38
40
|
|
|
@@ -17,8 +17,12 @@ const parseBody = (curl: any) => {
|
|
|
17
17
|
if (curl.data) {
|
|
18
18
|
const keys = Object.keys(curl.data)
|
|
19
19
|
if (keys.length) {
|
|
20
|
-
|
|
20
|
+
let key = keys[0]
|
|
21
21
|
try {
|
|
22
|
+
// filter out the dollar syntax used by curl for shell support
|
|
23
|
+
if (key.startsWith("$")) {
|
|
24
|
+
key = key.substring(1)
|
|
25
|
+
}
|
|
22
26
|
return JSON.parse(key)
|
|
23
27
|
} catch (e) {
|
|
24
28
|
// do nothing
|
|
@@ -56,16 +60,19 @@ export class Curl extends ImportSource {
|
|
|
56
60
|
return true
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
getUrl = (): URL => {
|
|
64
|
+
return new URL(this.curl.raw_url)
|
|
65
|
+
}
|
|
66
|
+
|
|
59
67
|
getInfo = async (): Promise<ImportInfo> => {
|
|
60
|
-
const url =
|
|
68
|
+
const url = this.getUrl()
|
|
61
69
|
return {
|
|
62
|
-
url: url.origin,
|
|
63
70
|
name: url.hostname,
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
getQueries = async (datasourceId: string): Promise<Query[]> => {
|
|
68
|
-
const url =
|
|
75
|
+
const url = this.getUrl()
|
|
69
76
|
const name = url.pathname
|
|
70
77
|
const path = url.pathname
|
|
71
78
|
const method = this.curl.method
|
|
@@ -83,6 +90,7 @@ export class Curl extends ImportSource {
|
|
|
83
90
|
name,
|
|
84
91
|
method,
|
|
85
92
|
path,
|
|
93
|
+
url,
|
|
86
94
|
queryString,
|
|
87
95
|
headers,
|
|
88
96
|
[],
|
|
@@ -2,6 +2,7 @@ import { ImportInfo } from "./base"
|
|
|
2
2
|
import { Query, QueryParameter } from "../../../../../definitions/datasource"
|
|
3
3
|
import { OpenAPIV2 } from "openapi-types"
|
|
4
4
|
import { OpenAPISource } from "./base/openapi"
|
|
5
|
+
import { URL } from "url"
|
|
5
6
|
|
|
6
7
|
const parameterNotRef = (
|
|
7
8
|
param: OpenAPIV2.Parameter | OpenAPIV2.ReferenceObject
|
|
@@ -55,20 +56,22 @@ export class OpenAPI2 extends OpenAPISource {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
getUrl = (): URL => {
|
|
59
60
|
const scheme = this.document.schemes?.includes("https") ? "https" : "http"
|
|
60
61
|
const basePath = this.document.basePath || ""
|
|
61
62
|
const host = this.document.host || "<host>"
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
return new URL(`${scheme}://${host}${basePath}`)
|
|
64
|
+
}
|
|
64
65
|
|
|
66
|
+
getInfo = async (): Promise<ImportInfo> => {
|
|
67
|
+
const name = this.document.info.title || "Swagger Import"
|
|
65
68
|
return {
|
|
66
|
-
|
|
67
|
-
name: name,
|
|
69
|
+
name,
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
getQueries = async (datasourceId: string): Promise<Query[]> => {
|
|
74
|
+
const url = this.getUrl()
|
|
72
75
|
const queries = []
|
|
73
76
|
|
|
74
77
|
for (let [path, pathItem] of Object.entries(this.document.paths)) {
|
|
@@ -145,6 +148,7 @@ export class OpenAPI2 extends OpenAPISource {
|
|
|
145
148
|
name,
|
|
146
149
|
methodName,
|
|
147
150
|
path,
|
|
151
|
+
url,
|
|
148
152
|
queryString,
|
|
149
153
|
headers,
|
|
150
154
|
parameters,
|
|
@@ -35,7 +35,6 @@ describe("Curl Import", () => {
|
|
|
35
35
|
it("returns import info", async () => {
|
|
36
36
|
await init("get")
|
|
37
37
|
const info = await curl.getInfo()
|
|
38
|
-
expect(info.url).toBe("http://example.com")
|
|
39
38
|
expect(info.name).toBe("example.com")
|
|
40
39
|
})
|
|
41
40
|
|
|
@@ -67,8 +66,8 @@ describe("Curl Import", () => {
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
it("populates path", async () => {
|
|
70
|
-
await testPath("get", "")
|
|
71
|
-
await testPath("path", "paths/abc")
|
|
69
|
+
await testPath("get", "http://example.com/")
|
|
70
|
+
await testPath("path", "http://example.com/paths/abc")
|
|
72
71
|
})
|
|
73
72
|
|
|
74
73
|
const testHeaders = async (file, headers) => {
|
|
@@ -41,7 +41,6 @@ describe("OpenAPI2 Import", () => {
|
|
|
41
41
|
const testImportInfo = async (file, extension) => {
|
|
42
42
|
await init(file, extension)
|
|
43
43
|
const info = await openapi2.getInfo()
|
|
44
|
-
expect(info.url).toBe("https://petstore.swagger.io/v2")
|
|
45
44
|
expect(info.name).toBe("Swagger Petstore")
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -92,12 +91,12 @@ describe("OpenAPI2 Import", () => {
|
|
|
92
91
|
|
|
93
92
|
it("populates path", async () => {
|
|
94
93
|
const assertions = {
|
|
95
|
-
"createEntity" : "entities",
|
|
96
|
-
"getEntities" : "entities",
|
|
97
|
-
"getEntity" : "entities/{{entityId}}",
|
|
98
|
-
"updateEntity" : "entities/{{entityId}}",
|
|
99
|
-
"patchEntity" : "entities/{{entityId}}",
|
|
100
|
-
"deleteEntity" : "entities/{{entityId}}"
|
|
94
|
+
"createEntity" : "http://example.com/entities",
|
|
95
|
+
"getEntities" : "http://example.com/entities",
|
|
96
|
+
"getEntity" : "http://example.com/entities/{{entityId}}",
|
|
97
|
+
"updateEntity" : "http://example.com/entities/{{entityId}}",
|
|
98
|
+
"patchEntity" : "http://example.com/entities/{{entityId}}",
|
|
99
|
+
"deleteEntity" : "http://example.com/entities/{{entityId}}"
|
|
101
100
|
}
|
|
102
101
|
await runTests("crud", testPath, assertions)
|
|
103
102
|
})
|
|
@@ -51,30 +51,24 @@ describe("Rest Importer", () => {
|
|
|
51
51
|
await init(data)
|
|
52
52
|
const info = await restImporter.getInfo()
|
|
53
53
|
expect(info.name).toBe(assertions[key].name)
|
|
54
|
-
expect(info.url).toBe(assertions[key].url)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
it("gets info", async () => {
|
|
58
57
|
const assertions = {
|
|
59
58
|
"oapi2CrudJson" : {
|
|
60
59
|
name: "CRUD",
|
|
61
|
-
url: "http://example.com"
|
|
62
60
|
},
|
|
63
61
|
"oapi2CrudYaml" : {
|
|
64
62
|
name: "CRUD",
|
|
65
|
-
url: "http://example.com"
|
|
66
63
|
},
|
|
67
64
|
"oapi2PetstoreJson" : {
|
|
68
65
|
name: "Swagger Petstore",
|
|
69
|
-
url: "https://petstore.swagger.io/v2"
|
|
70
66
|
},
|
|
71
67
|
"oapi2PetstoreYaml" :{
|
|
72
68
|
name: "Swagger Petstore",
|
|
73
|
-
url: "https://petstore.swagger.io/v2"
|
|
74
69
|
},
|
|
75
70
|
"curl": {
|
|
76
71
|
name: "example.com",
|
|
77
|
-
url: "http://example.com"
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
74
|
await runTest(testGetInfo, assertions)
|