@budibase/server 1.0.27-alpha.0 → 1.0.30
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 +0 -3
- package/builder/assets/{index.e2f56628.js → index.2ccab04a.js} +204 -208
- package/builder/assets/{index.4a13c4cb.css → index.4fb3f887.css} +1 -1
- package/builder/assets/{vendor.f9faf6ab.js → vendor.470042a4.js} +88 -88
- package/builder/index.html +3 -3
- package/coverage/clover.xml +512 -589
- package/coverage/coverage-final.json +19 -20
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +10 -22
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +14 -14
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +43 -28
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/{query/index.js.html → query.js.html} +27 -159
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- 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 +9 -108
- 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 +6 -18
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +9 -9
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +98 -11
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +2 -32
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/automations/index.html +20 -20
- 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 +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -5
- 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 +11 -44
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +22 -22
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- 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 +4 -4
- package/coverage/lcov-report/db/utils.js.html +64 -91
- 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 +60 -75
- 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 +2 -2
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +19 -19
- package/coverage/lcov-report/threads/index.js.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +12 -63
- package/coverage/lcov-report/threads/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/index.html +19 -19
- package/coverage/lcov-report/utilities/index.js.html +33 -66
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- 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 +2 -2
- 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 +1 -1
- package/coverage/lcov.info +851 -969
- package/dist/api/controllers/automation.js +5 -7
- package/dist/api/controllers/{query/index.js → query.js} +6 -42
- package/dist/api/controllers/user.js +1 -37
- package/dist/api/controllers/webhook.js +0 -4
- package/dist/api/routes/query.js +32 -2
- package/dist/api/routes/user.js +1 -3
- package/dist/automations/steps/outgoingWebhook.js +3 -2
- package/dist/automations/utils.js +0 -10
- package/dist/db/utils.js +0 -8
- package/dist/definitions/datasource.js +1 -6
- package/dist/integrations/rest.js +117 -207
- package/dist/package.json +4 -10
- package/dist/threads/query.js +2 -14
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/index.js +0 -10
- package/package.json +5 -11
- package/src/api/controllers/automation.js +4 -8
- package/src/api/controllers/{query/index.js → query.js} +6 -50
- package/src/api/controllers/user.js +0 -33
- package/src/api/controllers/webhook.js +0 -4
- package/src/api/routes/query.js +34 -5
- package/src/api/routes/user.js +0 -10
- package/src/automations/steps/outgoingWebhook.js +3 -2
- package/src/automations/utils.js +0 -11
- package/src/db/utils.js +0 -9
- package/src/definitions/common.ts +16 -2
- package/src/definitions/datasource.ts +1 -73
- package/src/integrations/base/IntegrationBase.ts +4 -4
- package/src/integrations/oracle.ts +1 -1
- package/src/integrations/rest.ts +137 -227
- package/src/integrations/tests/rest.spec.js +19 -167
- package/src/threads/query.js +2 -19
- package/src/utilities/index.js +0 -11
- package/builder/assets/bb-spaceship.8f6e81e1.svg +0 -227
- package/coverage/lcov-report/api/controllers/query/index.html +0 -126
- package/coverage/lcov-report/api/controllers/query/validation.js.html +0 -203
- package/dist/api/controllers/query/import/index.js +0 -79
- package/dist/api/controllers/query/import/sources/base/index.js +0 -63
- package/dist/api/controllers/query/import/sources/base/openapi.js +0 -42
- package/dist/api/controllers/query/import/sources/curl.js +0 -90
- package/dist/api/controllers/query/import/sources/openapi2.js +0 -139
- package/dist/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +0 -253
- package/dist/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +0 -1054
- package/dist/api/controllers/query/validation.js +0 -37
- package/src/api/controllers/query/import/index.ts +0 -85
- package/src/api/controllers/query/import/sources/base/index.ts +0 -85
- package/src/api/controllers/query/import/sources/base/openapi.ts +0 -24
- package/src/api/controllers/query/import/sources/curl.ts +0 -94
- package/src/api/controllers/query/import/sources/openapi2.ts +0 -159
- package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +0 -104
- package/src/api/controllers/query/import/sources/tests/curl/data/delete.txt +0 -1
- package/src/api/controllers/query/import/sources/tests/curl/data/empty-body.txt +0 -2
- package/src/api/controllers/query/import/sources/tests/curl/data/get.txt +0 -1
- package/src/api/controllers/query/import/sources/tests/curl/data/headers.txt +0 -3
- package/src/api/controllers/query/import/sources/tests/curl/data/patch.txt +0 -2
- package/src/api/controllers/query/import/sources/tests/curl/data/path.txt +0 -1
- package/src/api/controllers/query/import/sources/tests/curl/data/post.txt +0 -2
- package/src/api/controllers/query/import/sources/tests/curl/data/put.txt +0 -2
- package/src/api/controllers/query/import/sources/tests/curl/data/query.txt +0 -1
- package/src/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +0 -253
- package/src/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.yaml +0 -160
- package/src/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +0 -1054
- package/src/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.yaml +0 -711
- package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +0 -239
- package/src/api/controllers/query/import/tests/index.spec.js +0 -115
- package/src/api/controllers/query/validation.js +0 -41
|
@@ -10,54 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const datasource_1 = require("../definitions/datasource");
|
|
13
|
-
const BodyTypes = {
|
|
14
|
-
NONE: "none",
|
|
15
|
-
FORM_DATA: "form",
|
|
16
|
-
XML: "xml",
|
|
17
|
-
ENCODED: "encoded",
|
|
18
|
-
JSON: "json",
|
|
19
|
-
TEXT: "text",
|
|
20
|
-
};
|
|
21
|
-
const coreFields = {
|
|
22
|
-
path: {
|
|
23
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
24
|
-
display: "URL",
|
|
25
|
-
},
|
|
26
|
-
queryString: {
|
|
27
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
28
|
-
},
|
|
29
|
-
headers: {
|
|
30
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
31
|
-
},
|
|
32
|
-
enabledHeaders: {
|
|
33
|
-
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
34
|
-
},
|
|
35
|
-
requestBody: {
|
|
36
|
-
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
37
|
-
},
|
|
38
|
-
bodyType: {
|
|
39
|
-
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
40
|
-
enum: Object.values(BodyTypes),
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
13
|
var RestModule;
|
|
44
14
|
(function (RestModule) {
|
|
45
15
|
const fetch = require("node-fetch");
|
|
46
|
-
const { formatBytes } = require("../utilities");
|
|
47
|
-
const { performance } = require("perf_hooks");
|
|
48
|
-
const FormData = require("form-data");
|
|
49
|
-
const { URLSearchParams } = require("url");
|
|
50
|
-
const { parseStringPromise: xmlParser, Builder: XmlBuilder } = require("xml2js");
|
|
51
16
|
const SCHEMA = {
|
|
52
17
|
docs: "https://github.com/node-fetch/node-fetch",
|
|
53
|
-
description: "
|
|
18
|
+
description: "Representational state transfer (REST) is a de-facto standard for a software architecture for interactive applications that typically use multiple Web services. ",
|
|
54
19
|
friendlyName: "REST API",
|
|
55
20
|
datasource: {
|
|
56
21
|
url: {
|
|
57
22
|
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
58
|
-
default: "",
|
|
59
|
-
required:
|
|
60
|
-
deprecated: true,
|
|
23
|
+
default: "localhost",
|
|
24
|
+
required: true,
|
|
61
25
|
},
|
|
62
26
|
defaultHeaders: {
|
|
63
27
|
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
@@ -70,228 +34,174 @@ var RestModule;
|
|
|
70
34
|
readable: true,
|
|
71
35
|
displayName: "POST",
|
|
72
36
|
type: datasource_1.QueryTypes.FIELDS,
|
|
73
|
-
|
|
37
|
+
urlDisplay: true,
|
|
38
|
+
fields: {
|
|
39
|
+
path: {
|
|
40
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
41
|
+
},
|
|
42
|
+
queryString: {
|
|
43
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
44
|
+
},
|
|
45
|
+
headers: {
|
|
46
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
47
|
+
},
|
|
48
|
+
requestBody: {
|
|
49
|
+
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
74
52
|
},
|
|
75
53
|
read: {
|
|
76
54
|
displayName: "GET",
|
|
77
55
|
readable: true,
|
|
78
56
|
type: datasource_1.QueryTypes.FIELDS,
|
|
79
|
-
|
|
57
|
+
urlDisplay: true,
|
|
58
|
+
fields: {
|
|
59
|
+
path: {
|
|
60
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
61
|
+
},
|
|
62
|
+
queryString: {
|
|
63
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
64
|
+
},
|
|
65
|
+
headers: {
|
|
66
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
80
69
|
},
|
|
81
70
|
update: {
|
|
82
71
|
displayName: "PUT",
|
|
83
72
|
readable: true,
|
|
84
73
|
type: datasource_1.QueryTypes.FIELDS,
|
|
85
|
-
|
|
74
|
+
urlDisplay: true,
|
|
75
|
+
fields: {
|
|
76
|
+
path: {
|
|
77
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
78
|
+
},
|
|
79
|
+
queryString: {
|
|
80
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
81
|
+
},
|
|
82
|
+
headers: {
|
|
83
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
84
|
+
},
|
|
85
|
+
requestBody: {
|
|
86
|
+
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
86
89
|
},
|
|
87
90
|
patch: {
|
|
88
91
|
displayName: "PATCH",
|
|
89
92
|
readable: true,
|
|
90
93
|
type: datasource_1.QueryTypes.FIELDS,
|
|
91
|
-
|
|
94
|
+
urlDisplay: true,
|
|
95
|
+
fields: {
|
|
96
|
+
path: {
|
|
97
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
98
|
+
},
|
|
99
|
+
queryString: {
|
|
100
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
101
|
+
},
|
|
102
|
+
headers: {
|
|
103
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
104
|
+
},
|
|
105
|
+
requestBody: {
|
|
106
|
+
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
92
109
|
},
|
|
93
110
|
delete: {
|
|
94
111
|
displayName: "DELETE",
|
|
95
112
|
type: datasource_1.QueryTypes.FIELDS,
|
|
96
|
-
|
|
113
|
+
urlDisplay: true,
|
|
114
|
+
fields: {
|
|
115
|
+
path: {
|
|
116
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
117
|
+
},
|
|
118
|
+
queryString: {
|
|
119
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
120
|
+
},
|
|
121
|
+
headers: {
|
|
122
|
+
type: datasource_1.DatasourceFieldTypes.OBJECT,
|
|
123
|
+
},
|
|
124
|
+
requestBody: {
|
|
125
|
+
type: datasource_1.DatasourceFieldTypes.JSON,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
97
128
|
},
|
|
98
129
|
},
|
|
99
130
|
};
|
|
100
131
|
class RestIntegration {
|
|
101
132
|
constructor(config) {
|
|
102
133
|
this.headers = {};
|
|
103
|
-
this.startTimeMs = performance.now();
|
|
104
134
|
this.config = config;
|
|
105
135
|
}
|
|
106
136
|
parseResponse(response) {
|
|
107
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (contentType.includes("application/json")) {
|
|
112
|
-
data = yield response.json();
|
|
113
|
-
raw = JSON.stringify(data);
|
|
114
|
-
}
|
|
115
|
-
else if (contentType.includes("text/xml") ||
|
|
116
|
-
contentType.includes("application/xml")) {
|
|
117
|
-
const rawXml = yield response.text();
|
|
118
|
-
data =
|
|
119
|
-
(yield xmlParser(rawXml, {
|
|
120
|
-
explicitArray: false,
|
|
121
|
-
trim: true,
|
|
122
|
-
explicitRoot: false,
|
|
123
|
-
})) || {};
|
|
124
|
-
// there is only one structure, its an array, return the array so it appears as rows
|
|
125
|
-
const keys = Object.keys(data);
|
|
126
|
-
if (keys.length === 1 && Array.isArray(data[keys[0]])) {
|
|
127
|
-
data = data[keys[0]];
|
|
128
|
-
}
|
|
129
|
-
raw = rawXml;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
data = yield response.text();
|
|
133
|
-
raw = data;
|
|
134
|
-
}
|
|
138
|
+
const contentType = response.headers.get("content-type");
|
|
139
|
+
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
140
|
+
return yield response.json();
|
|
135
141
|
}
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
else {
|
|
143
|
+
return yield response.text();
|
|
138
144
|
}
|
|
139
|
-
const size = formatBytes(response.headers.get("content-length") || Buffer.byteLength(raw, "utf8"));
|
|
140
|
-
const time = `${Math.round(performance.now() - this.startTimeMs)}ms`;
|
|
141
|
-
headers = response.headers.raw();
|
|
142
|
-
for (let [key, value] of Object.entries(headers)) {
|
|
143
|
-
headers[key] = Array.isArray(value) ? value[0] : value;
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
data,
|
|
147
|
-
info: {
|
|
148
|
-
code: response.status,
|
|
149
|
-
size,
|
|
150
|
-
time,
|
|
151
|
-
},
|
|
152
|
-
extra: {
|
|
153
|
-
raw,
|
|
154
|
-
headers,
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
145
|
});
|
|
158
146
|
}
|
|
159
147
|
getUrl(path, queryString) {
|
|
160
|
-
|
|
161
|
-
let complete = main;
|
|
162
|
-
if (this.config.url && !main.startsWith(this.config.url)) {
|
|
163
|
-
complete = !this.config.url ? main : `${this.config.url}/${main}`;
|
|
164
|
-
}
|
|
165
|
-
if (!complete.startsWith("http")) {
|
|
166
|
-
complete = `http://${complete}`;
|
|
167
|
-
}
|
|
168
|
-
return complete;
|
|
169
|
-
}
|
|
170
|
-
addBody(bodyType, body, input) {
|
|
171
|
-
let error, object, string;
|
|
172
|
-
try {
|
|
173
|
-
string = typeof body !== "string" ? JSON.stringify(body) : body;
|
|
174
|
-
object = typeof body === "object" ? body : JSON.parse(body);
|
|
175
|
-
}
|
|
176
|
-
catch (err) {
|
|
177
|
-
error = err;
|
|
178
|
-
}
|
|
179
|
-
if (!input.headers) {
|
|
180
|
-
input.headers = {};
|
|
181
|
-
}
|
|
182
|
-
switch (bodyType) {
|
|
183
|
-
case BodyTypes.NONE:
|
|
184
|
-
break;
|
|
185
|
-
case BodyTypes.TEXT:
|
|
186
|
-
// content type defaults to plaintext
|
|
187
|
-
input.body = string;
|
|
188
|
-
break;
|
|
189
|
-
case BodyTypes.ENCODED:
|
|
190
|
-
const params = new URLSearchParams();
|
|
191
|
-
for (let [key, value] of Object.entries(object)) {
|
|
192
|
-
params.append(key, value);
|
|
193
|
-
}
|
|
194
|
-
input.body = params;
|
|
195
|
-
break;
|
|
196
|
-
case BodyTypes.FORM_DATA:
|
|
197
|
-
const form = new FormData();
|
|
198
|
-
for (let [key, value] of Object.entries(object)) {
|
|
199
|
-
form.append(key, value);
|
|
200
|
-
}
|
|
201
|
-
input.body = form;
|
|
202
|
-
break;
|
|
203
|
-
case BodyTypes.XML:
|
|
204
|
-
if (object != null) {
|
|
205
|
-
string = (new XmlBuilder()).buildObject(object);
|
|
206
|
-
}
|
|
207
|
-
input.body = string;
|
|
208
|
-
input.headers["Content-Type"] = "application/xml";
|
|
209
|
-
break;
|
|
210
|
-
default:
|
|
211
|
-
case BodyTypes.JSON:
|
|
212
|
-
// if JSON error, throw it
|
|
213
|
-
if (error) {
|
|
214
|
-
throw "Invalid JSON for request body";
|
|
215
|
-
}
|
|
216
|
-
input.body = string;
|
|
217
|
-
input.headers["Content-Type"] = "application/json";
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
return input;
|
|
221
|
-
}
|
|
222
|
-
getAuthHeaders(authConfigId) {
|
|
223
|
-
let headers = {};
|
|
224
|
-
if (this.config.authConfigs && authConfigId) {
|
|
225
|
-
const authConfig = this.config.authConfigs.filter(c => c._id === authConfigId)[0];
|
|
226
|
-
// check the config still exists before proceeding
|
|
227
|
-
// if not - do nothing
|
|
228
|
-
if (authConfig) {
|
|
229
|
-
let config;
|
|
230
|
-
switch (authConfig.type) {
|
|
231
|
-
case datasource_1.AuthType.BASIC:
|
|
232
|
-
config = authConfig.config;
|
|
233
|
-
headers.Authorization = `Basic ${Buffer.from(`${config.username}:${config.password}`).toString("base64")}`;
|
|
234
|
-
break;
|
|
235
|
-
case datasource_1.AuthType.BEARER:
|
|
236
|
-
config = authConfig.config;
|
|
237
|
-
headers.Authorization = `Bearer ${config.token}`;
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return headers;
|
|
148
|
+
return `${this.config.url}/${path}?${queryString}`;
|
|
243
149
|
}
|
|
244
|
-
|
|
150
|
+
create({ path = "", queryString = "", headers = {}, json = {} }) {
|
|
245
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
delete this.headers[headerKey];
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
let input = { method, headers: this.headers };
|
|
257
|
-
if (requestBody) {
|
|
258
|
-
input = this.addBody(bodyType, requestBody, input);
|
|
259
|
-
}
|
|
260
|
-
this.startTimeMs = performance.now();
|
|
261
|
-
const url = this.getUrl(path, queryString);
|
|
262
|
-
const response = yield fetch(url, input);
|
|
152
|
+
this.headers = Object.assign(Object.assign({}, this.config.defaultHeaders), headers);
|
|
153
|
+
const response = yield fetch(this.getUrl(path, queryString), {
|
|
154
|
+
method: "POST",
|
|
155
|
+
headers: this.headers,
|
|
156
|
+
body: JSON.stringify(json),
|
|
157
|
+
});
|
|
263
158
|
return yield this.parseResponse(response);
|
|
264
159
|
});
|
|
265
160
|
}
|
|
266
|
-
|
|
267
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
-
return this._req(Object.assign(Object.assign({}, opts), { method: "POST" }));
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
read(opts) {
|
|
161
|
+
read({ path = "", queryString = "", headers = {} }) {
|
|
272
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
-
|
|
163
|
+
this.headers = Object.assign(Object.assign({}, this.config.defaultHeaders), headers);
|
|
164
|
+
const response = yield fetch(this.getUrl(path, queryString), {
|
|
165
|
+
headers: this.headers,
|
|
166
|
+
});
|
|
167
|
+
return yield this.parseResponse(response);
|
|
274
168
|
});
|
|
275
169
|
}
|
|
276
|
-
update(
|
|
170
|
+
update({ path = "", queryString = "", headers = {}, json = {} }) {
|
|
277
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
|
|
172
|
+
this.headers = Object.assign(Object.assign({}, this.config.defaultHeaders), headers);
|
|
173
|
+
const response = yield fetch(this.getUrl(path, queryString), {
|
|
174
|
+
method: "PUT",
|
|
175
|
+
headers: this.headers,
|
|
176
|
+
body: JSON.stringify(json),
|
|
177
|
+
});
|
|
178
|
+
return yield this.parseResponse(response);
|
|
279
179
|
});
|
|
280
180
|
}
|
|
281
|
-
patch(
|
|
181
|
+
patch({ path = "", queryString = "", headers = {}, json = {} }) {
|
|
282
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
|
|
183
|
+
this.headers = Object.assign(Object.assign({}, this.config.defaultHeaders), headers);
|
|
184
|
+
const response = yield fetch(this.getUrl(path, queryString), {
|
|
185
|
+
method: "PATCH",
|
|
186
|
+
headers: this.headers,
|
|
187
|
+
body: JSON.stringify(json),
|
|
188
|
+
});
|
|
189
|
+
return yield this.parseResponse(response);
|
|
284
190
|
});
|
|
285
191
|
}
|
|
286
|
-
delete(
|
|
192
|
+
delete({ path = "", queryString = "", headers = {} }) {
|
|
287
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
-
|
|
194
|
+
this.headers = Object.assign(Object.assign({}, this.config.defaultHeaders), headers);
|
|
195
|
+
const response = yield fetch(this.getUrl(path, queryString), {
|
|
196
|
+
method: "DELETE",
|
|
197
|
+
headers: this.headers,
|
|
198
|
+
});
|
|
199
|
+
return yield this.parseResponse(response);
|
|
289
200
|
});
|
|
290
201
|
}
|
|
291
202
|
}
|
|
292
203
|
module.exports = {
|
|
293
204
|
schema: SCHEMA,
|
|
294
205
|
integration: RestIntegration,
|
|
295
|
-
AuthType: datasource_1.AuthType,
|
|
296
206
|
};
|
|
297
207
|
})(RestModule || (RestModule = {}));
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.29",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -69,10 +69,9 @@
|
|
|
69
69
|
"author": "Budibase",
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"@budibase/
|
|
74
|
-
"@budibase/
|
|
75
|
-
"@budibase/string-templates": "^1.0.26",
|
|
72
|
+
"@budibase/auth": "^1.0.29",
|
|
73
|
+
"@budibase/client": "^1.0.29",
|
|
74
|
+
"@budibase/string-templates": "^1.0.29",
|
|
76
75
|
"@bull-board/api": "^3.7.0",
|
|
77
76
|
"@bull-board/koa": "^3.7.0",
|
|
78
77
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -86,15 +85,12 @@
|
|
|
86
85
|
"bull": "^3.22.4",
|
|
87
86
|
"chmodr": "1.2.0",
|
|
88
87
|
"csvtojson": "2.0.10",
|
|
89
|
-
"curlconverter": "^3.21.0",
|
|
90
88
|
"dotenv": "8.2.0",
|
|
91
89
|
"download": "8.0.0",
|
|
92
90
|
"fix-path": "3.0.0",
|
|
93
|
-
"form-data": "^4.0.0",
|
|
94
91
|
"fs-extra": "8.1.0",
|
|
95
92
|
"jimp": "0.16.1",
|
|
96
93
|
"joi": "17.2.1",
|
|
97
|
-
"js-yaml": "^4.1.0",
|
|
98
94
|
"jsonschema": "1.4.0",
|
|
99
95
|
"knex": "^0.95.6",
|
|
100
96
|
"koa": "2.7.0",
|
|
@@ -127,7 +123,6 @@
|
|
|
127
123
|
"validate.js": "0.13.1",
|
|
128
124
|
"vm2": "^3.9.3",
|
|
129
125
|
"worker-farm": "^1.7.0",
|
|
130
|
-
"xml2js": "^0.4.23",
|
|
131
126
|
"yargs": "13.2.4",
|
|
132
127
|
"zlib": "1.0.5"
|
|
133
128
|
},
|
|
@@ -151,7 +146,6 @@
|
|
|
151
146
|
"eslint": "^6.8.0",
|
|
152
147
|
"jest": "^27.0.5",
|
|
153
148
|
"nodemon": "^2.0.4",
|
|
154
|
-
"openapi-types": "^9.3.1",
|
|
155
149
|
"path-to-regexp": "^6.2.0",
|
|
156
150
|
"prettier": "^2.3.1",
|
|
157
151
|
"rimraf": "^3.0.2",
|
package/dist/threads/query.js
CHANGED
|
@@ -22,12 +22,6 @@ function formatResponse(resp) {
|
|
|
22
22
|
}
|
|
23
23
|
return resp;
|
|
24
24
|
}
|
|
25
|
-
function hasExtraData(response) {
|
|
26
|
-
return (typeof response === "object" &&
|
|
27
|
-
!Array.isArray(response) &&
|
|
28
|
-
response.data != null &&
|
|
29
|
-
response.info != null);
|
|
30
|
-
}
|
|
31
25
|
function runAndTransform(datasource, queryVerb, query, transformer) {
|
|
32
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
27
|
const Integration = integrations[datasource.source];
|
|
@@ -35,13 +29,7 @@ function runAndTransform(datasource, queryVerb, query, transformer) {
|
|
|
35
29
|
throw "Integration type does not exist.";
|
|
36
30
|
}
|
|
37
31
|
const integration = new Integration(datasource.config);
|
|
38
|
-
let
|
|
39
|
-
let rows = output, info = undefined, extra = undefined;
|
|
40
|
-
if (hasExtraData(output)) {
|
|
41
|
-
rows = output.data;
|
|
42
|
-
info = output.info;
|
|
43
|
-
extra = output.extra;
|
|
44
|
-
}
|
|
32
|
+
let rows = formatResponse(yield integration[queryVerb](query));
|
|
45
33
|
// transform as required
|
|
46
34
|
if (transformer) {
|
|
47
35
|
const runner = new ScriptRunner(transformer, { data: rows });
|
|
@@ -60,7 +48,7 @@ function runAndTransform(datasource, queryVerb, query, transformer) {
|
|
|
60
48
|
if (integration.end) {
|
|
61
49
|
integration.end();
|
|
62
50
|
}
|
|
63
|
-
return { rows, keys
|
|
51
|
+
return { rows, keys };
|
|
64
52
|
});
|
|
65
53
|
}
|
|
66
54
|
module.exports = (input, callback) => {
|