@budibase/server 1.0.98 → 1.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/index.cca3db8c.js +1291 -0
- package/builder/assets/{index.7c8961b4.css → index.ea3718aa.css} +2 -2
- package/builder/assets/{vendor.a7c6ad0a.js → vendor.8e34a169.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +354 -334
- package/coverage/coverage-final.json +15 -15
- 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 +1 -1
- 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 +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +18 -18
- package/coverage/lcov-report/api/controllers/integration.js.html +59 -11
- 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/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +7 -7
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +2 -2
- 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 +10 -10
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +19 -7
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +6 -6
- 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/bulkFormula.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 +1 -1
- 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 +1 -1
- 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 +3 -3
- 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/index.html +1 -1
- 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/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- 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 +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- 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 +12 -12
- 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 +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 +20 -8
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- 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 +1 -1
- 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 +10 -10
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +7 -7
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +2 -2
- 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 +31 -31
- 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 +75 -15
- 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 +15 -15
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/threads/index.js.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- 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 +12 -12
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +8 -8
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.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 +584 -546
- package/dist/api/controllers/integration.js +15 -1
- package/dist/api/controllers/permission.js +3 -4
- package/dist/api/controllers/query/import/index.js +2 -1
- package/dist/api/controllers/query/import/sources/base/index.js +12 -1
- package/dist/api/controllers/query/import/sources/curl.js +2 -2
- package/dist/api/controllers/query/import/sources/openapi3.js +174 -0
- package/dist/api/controllers/query/import/sources/tests/openapi3/data/crud/crud.json +253 -0
- package/dist/api/controllers/query/import/sources/tests/openapi3/data/petstore/petstore.json +1225 -0
- package/dist/api/controllers/row/internal.js +2 -1
- package/dist/api/routes/analytics.js +2 -2
- package/dist/api/routes/table.js +1 -1
- package/dist/automations/utils.js +3 -1
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +2 -0
- package/dist/integrations/base/sql.js +16 -9
- package/dist/integrations/dynamodb.js +3 -1
- package/dist/integrations/firebase.js +192 -0
- package/dist/integrations/googlesheets.js +17 -1
- package/dist/integrations/index.js +4 -1
- package/dist/integrations/mysql.js +14 -1
- package/dist/integrations/rest.js +2 -1
- package/dist/middleware/authorized.js +24 -7
- package/dist/package.json +7 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -5
- package/scripts/dev/manage.js +2 -1
- package/specs/openapi.json +23 -3
- package/specs/openapi.yaml +20 -4
- package/specs/resources/query.js +27 -5
- package/src/api/controllers/integration.js +17 -1
- package/src/api/controllers/permission.js +3 -3
- package/src/api/controllers/query/import/index.ts +2 -1
- package/src/api/controllers/query/import/sources/base/index.ts +12 -2
- package/src/api/controllers/query/import/sources/curl.ts +2 -2
- package/src/api/controllers/query/import/sources/openapi3.ts +205 -0
- package/src/api/controllers/query/import/sources/tests/openapi3/data/crud/crud.json +253 -0
- package/src/api/controllers/query/import/sources/tests/openapi3/data/crud/crud.yaml +153 -0
- package/src/api/controllers/query/import/sources/tests/openapi3/data/petstore/petstore.json +1225 -0
- package/src/api/controllers/query/import/sources/tests/openapi3/data/petstore/petstore.yaml +804 -0
- package/src/api/controllers/query/import/sources/tests/openapi3/openapi3.spec.js +240 -0
- package/src/api/controllers/query/import/tests/index.spec.js +43 -0
- package/src/api/controllers/row/internal.js +5 -1
- package/src/api/routes/analytics.js +2 -2
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/tests/misc.spec.js +2 -2
- package/src/automations/utils.js +5 -1
- package/src/definitions/datasource.ts +2 -5
- package/src/definitions/openapi.ts +480 -470
- package/src/environment.js +2 -0
- package/src/integrations/base/sql.ts +14 -9
- package/src/integrations/dynamodb.ts +3 -1
- package/src/integrations/firebase.ts +205 -0
- package/src/integrations/googlesheets.ts +16 -1
- package/src/integrations/index.ts +4 -1
- package/src/integrations/mysql.ts +15 -1
- package/src/integrations/rest.ts +2 -1
- package/src/integrations/tests/sql.spec.js +51 -0
- package/src/middleware/authorized.js +26 -6
- package/builder/assets/index.2dcb5072.js +0 -1291
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.
|
|
4
|
+
"version": "1.0.101",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -68,12 +68,13 @@
|
|
|
68
68
|
"license": "GPL-3.0",
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
71
|
-
"@budibase/backend-core": "^1.0.
|
|
72
|
-
"@budibase/client": "^1.0.
|
|
73
|
-
"@budibase/string-templates": "^1.0.
|
|
71
|
+
"@budibase/backend-core": "^1.0.101",
|
|
72
|
+
"@budibase/client": "^1.0.101",
|
|
73
|
+
"@budibase/string-templates": "^1.0.101",
|
|
74
74
|
"@bull-board/api": "^3.7.0",
|
|
75
75
|
"@bull-board/koa": "^3.7.0",
|
|
76
76
|
"@elastic/elasticsearch": "7.10.0",
|
|
77
|
+
"@google-cloud/firestore": "^5.0.2",
|
|
77
78
|
"@koa/router": "8.0.0",
|
|
78
79
|
"@sendgrid/mail": "7.1.1",
|
|
79
80
|
"@sentry/node": "^6.0.0",
|
|
@@ -145,6 +146,7 @@
|
|
|
145
146
|
"@types/jest": "^26.0.23",
|
|
146
147
|
"@types/koa": "^2.13.3",
|
|
147
148
|
"@types/koa-router": "^7.4.2",
|
|
149
|
+
"@types/lodash": "4.14.180",
|
|
148
150
|
"@types/node": "^15.12.4",
|
|
149
151
|
"@types/oracledb": "^5.2.1",
|
|
150
152
|
"@types/redis": "^4.0.11",
|
|
@@ -153,6 +155,7 @@
|
|
|
153
155
|
"copyfiles": "^2.4.1",
|
|
154
156
|
"docker-compose": "^0.23.6",
|
|
155
157
|
"eslint": "^6.8.0",
|
|
158
|
+
"is-wsl": "^2.2.0",
|
|
156
159
|
"jest": "^27.0.5",
|
|
157
160
|
"jest-openapi": "^0.14.2",
|
|
158
161
|
"nodemon": "^2.0.4",
|
|
@@ -171,5 +174,5 @@
|
|
|
171
174
|
"optionalDependencies": {
|
|
172
175
|
"oracledb": "^5.3.0"
|
|
173
176
|
},
|
|
174
|
-
"gitHead": "
|
|
177
|
+
"gitHead": "3862854f5b44c63494d6e5fc060c16a5e1890d1a"
|
|
175
178
|
}
|
package/scripts/dev/manage.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
const compose = require("docker-compose")
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const fs = require("fs")
|
|
5
|
+
const isWsl = require("is-wsl")
|
|
5
6
|
const { processStringSync } = require("@budibase/string-templates")
|
|
6
7
|
|
|
7
8
|
function isLinux() {
|
|
8
|
-
return process.platform !== "darwin" && process.platform !== "win32"
|
|
9
|
+
return !isWsl && process.platform !== "darwin" && process.platform !== "win32"
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
// This script wraps docker-compose allowing you to manage your dev infrastructure with simple commands.
|
package/specs/openapi.json
CHANGED
|
@@ -1260,10 +1260,30 @@
|
|
|
1260
1260
|
]
|
|
1261
1261
|
},
|
|
1262
1262
|
"executeQuery": {
|
|
1263
|
-
"description": "The
|
|
1263
|
+
"description": "The parameters required for executing a query.",
|
|
1264
1264
|
"type": "object",
|
|
1265
|
-
"
|
|
1266
|
-
"
|
|
1265
|
+
"properties": {
|
|
1266
|
+
"parameters": {
|
|
1267
|
+
"type": "object",
|
|
1268
|
+
"description": "This contains the required parameters for the query, this depends on query type, setup and bindings.",
|
|
1269
|
+
"additionalProperties": {
|
|
1270
|
+
"description": "Key value properties of any type, depending on the query output schema."
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
"pagination": {
|
|
1274
|
+
"type": "object",
|
|
1275
|
+
"description": "For supported query types (currently on REST) pagination can be performed using these properties.",
|
|
1276
|
+
"properties": {
|
|
1277
|
+
"page": {
|
|
1278
|
+
"type": "string",
|
|
1279
|
+
"description": "The page which has been returned from a previous query."
|
|
1280
|
+
},
|
|
1281
|
+
"limit": {
|
|
1282
|
+
"type": "number",
|
|
1283
|
+
"description": "The number of rows to return per page."
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1267
1287
|
}
|
|
1268
1288
|
},
|
|
1269
1289
|
"executeQueryOutput": {
|
package/specs/openapi.yaml
CHANGED
|
@@ -951,11 +951,27 @@ components:
|
|
|
951
951
|
required:
|
|
952
952
|
- data
|
|
953
953
|
executeQuery:
|
|
954
|
-
description: The
|
|
955
|
-
this depends on query type, setup and bindings.
|
|
954
|
+
description: The parameters required for executing a query.
|
|
956
955
|
type: object
|
|
957
|
-
|
|
958
|
-
|
|
956
|
+
properties:
|
|
957
|
+
parameters:
|
|
958
|
+
type: object
|
|
959
|
+
description: This contains the required parameters for the query, this depends
|
|
960
|
+
on query type, setup and bindings.
|
|
961
|
+
additionalProperties:
|
|
962
|
+
description: Key value properties of any type, depending on the query output
|
|
963
|
+
schema.
|
|
964
|
+
pagination:
|
|
965
|
+
type: object
|
|
966
|
+
description: For supported query types (currently on REST) pagination can be
|
|
967
|
+
performed using these properties.
|
|
968
|
+
properties:
|
|
969
|
+
page:
|
|
970
|
+
type: string
|
|
971
|
+
description: The page which has been returned from a previous query.
|
|
972
|
+
limit:
|
|
973
|
+
type: number
|
|
974
|
+
description: The number of rows to return per page.
|
|
959
975
|
executeQueryOutput:
|
|
960
976
|
type: object
|
|
961
977
|
properties:
|
package/specs/resources/query.js
CHANGED
|
@@ -124,12 +124,34 @@ const querySchema = object(
|
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
const executeQuerySchema = {
|
|
127
|
-
description:
|
|
128
|
-
"The query body must contain the required parameters for the query, this depends on query type, setup and bindings.",
|
|
127
|
+
description: "The parameters required for executing a query.",
|
|
129
128
|
type: "object",
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
properties: {
|
|
130
|
+
parameters: {
|
|
131
|
+
type: "object",
|
|
132
|
+
description:
|
|
133
|
+
"This contains the required parameters for the query, this depends on query type, setup and bindings.",
|
|
134
|
+
additionalProperties: {
|
|
135
|
+
description:
|
|
136
|
+
"Key value properties of any type, depending on the query output schema.",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
pagination: {
|
|
140
|
+
type: "object",
|
|
141
|
+
description:
|
|
142
|
+
"For supported query types (currently on REST) pagination can be performed using these properties.",
|
|
143
|
+
properties: {
|
|
144
|
+
page: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description:
|
|
147
|
+
"The page which has been returned from a previous query.",
|
|
148
|
+
},
|
|
149
|
+
limit: {
|
|
150
|
+
type: "number",
|
|
151
|
+
description: "The number of rows to return per page.",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
133
155
|
},
|
|
134
156
|
}
|
|
135
157
|
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
const { cloneDeep } = require("lodash")
|
|
1
2
|
const { definitions } = require("../../integrations")
|
|
3
|
+
const { getTenantId } = require("@budibase/backend-core/tenancy")
|
|
4
|
+
const { SourceNames } = require("../../definitions/datasource")
|
|
5
|
+
const googlesheets = require("../../integrations/googlesheets")
|
|
6
|
+
const env = require("../../environment")
|
|
2
7
|
|
|
3
8
|
exports.fetch = async function (ctx) {
|
|
4
9
|
ctx.status = 200
|
|
5
|
-
|
|
10
|
+
const defs = cloneDeep(definitions)
|
|
11
|
+
|
|
12
|
+
// for google sheets integration google verification
|
|
13
|
+
if (env.EXCLUDE_QUOTAS_TENANTS) {
|
|
14
|
+
const excludedTenants = env.EXCLUDE_QUOTAS_TENANTS.split(",")
|
|
15
|
+
const tenantId = getTenantId()
|
|
16
|
+
if (excludedTenants.includes(tenantId)) {
|
|
17
|
+
defs[SourceNames.GOOGLE_SHEETS] = googlesheets.schema
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ctx.body = defs
|
|
6
22
|
}
|
|
7
23
|
|
|
8
24
|
exports.find = async function (ctx) {
|
|
@@ -4,6 +4,7 @@ const {
|
|
|
4
4
|
getDBRoleID,
|
|
5
5
|
getExternalRoleID,
|
|
6
6
|
getBuiltinRoles,
|
|
7
|
+
checkForRoleResourceArray,
|
|
7
8
|
} = require("@budibase/backend-core/roles")
|
|
8
9
|
const { getRoleParams } = require("../../db/utils")
|
|
9
10
|
const {
|
|
@@ -144,12 +145,11 @@ exports.getResourcePerms = async function (ctx) {
|
|
|
144
145
|
for (let level of SUPPORTED_LEVELS) {
|
|
145
146
|
// update the various roleIds in the resource permissions
|
|
146
147
|
for (let role of roles) {
|
|
147
|
-
const rolePerms = role.permissions
|
|
148
|
+
const rolePerms = checkForRoleResourceArray(role.permissions, resourceId)
|
|
148
149
|
if (
|
|
149
150
|
rolePerms &&
|
|
150
151
|
rolePerms[resourceId] &&
|
|
151
|
-
|
|
152
|
-
rolePerms[resourceId].indexOf(level) !== -1)
|
|
152
|
+
rolePerms[resourceId].indexOf(level) !== -1
|
|
153
153
|
) {
|
|
154
154
|
permissions[level] = getExternalRoleID(role._id)
|
|
155
155
|
}
|
|
@@ -2,6 +2,7 @@ import { queryValidation } from "../validation"
|
|
|
2
2
|
import { generateQueryID } from "../../../../db/utils"
|
|
3
3
|
import { ImportInfo, ImportSource } from "./sources/base"
|
|
4
4
|
import { OpenAPI2 } from "./sources/openapi2"
|
|
5
|
+
import { OpenAPI3 } from "./sources/openapi3"
|
|
5
6
|
import { Query } from "./../../../../definitions/common"
|
|
6
7
|
import { Curl } from "./sources/curl"
|
|
7
8
|
// @ts-ignore
|
|
@@ -18,7 +19,7 @@ export class RestImporter {
|
|
|
18
19
|
|
|
19
20
|
constructor(data: string) {
|
|
20
21
|
this.data = data
|
|
21
|
-
this.sources = [new OpenAPI2(), new Curl()]
|
|
22
|
+
this.sources = [new OpenAPI2(), new OpenAPI3(), new Curl()]
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
init = async () => {
|
|
@@ -23,7 +23,7 @@ export abstract class ImportSource {
|
|
|
23
23
|
name: string,
|
|
24
24
|
method: string,
|
|
25
25
|
path: string,
|
|
26
|
-
url: URL,
|
|
26
|
+
url: URL | string | undefined,
|
|
27
27
|
queryString: string,
|
|
28
28
|
headers: object = {},
|
|
29
29
|
parameters: QueryParameter[] = [],
|
|
@@ -34,7 +34,17 @@ export abstract class ImportSource {
|
|
|
34
34
|
const transformer = "return data"
|
|
35
35
|
const schema = {}
|
|
36
36
|
path = this.processPath(path)
|
|
37
|
-
|
|
37
|
+
if (url) {
|
|
38
|
+
if (typeof url === "string") {
|
|
39
|
+
path = `${url}/${path}`
|
|
40
|
+
} else {
|
|
41
|
+
let href = url.href
|
|
42
|
+
if (href.endsWith("/")) {
|
|
43
|
+
href = href.slice(0, -1)
|
|
44
|
+
}
|
|
45
|
+
path = `${href}/${path}`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
38
48
|
queryString = this.processQuery(queryString)
|
|
39
49
|
const requestBody = JSON.stringify(body, null, 2)
|
|
40
50
|
|
|
@@ -74,7 +74,7 @@ export class Curl extends ImportSource {
|
|
|
74
74
|
getQueries = async (datasourceId: string): Promise<Query[]> => {
|
|
75
75
|
const url = this.getUrl()
|
|
76
76
|
const name = url.pathname
|
|
77
|
-
const path = url.pathname
|
|
77
|
+
const path = url.origin + url.pathname
|
|
78
78
|
const method = this.curl.method
|
|
79
79
|
const queryString = url.search
|
|
80
80
|
const headers = this.curl.headers
|
|
@@ -90,7 +90,7 @@ export class Curl extends ImportSource {
|
|
|
90
90
|
name,
|
|
91
91
|
method,
|
|
92
92
|
path,
|
|
93
|
-
|
|
93
|
+
undefined,
|
|
94
94
|
queryString,
|
|
95
95
|
headers,
|
|
96
96
|
[],
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ImportInfo } from "./base"
|
|
2
|
+
import { Query, QueryParameter } from "../../../../../definitions/datasource"
|
|
3
|
+
import { OpenAPIV3 } from "openapi-types"
|
|
4
|
+
import { OpenAPISource } from "./base/openapi"
|
|
5
|
+
import { URL } from "url"
|
|
6
|
+
|
|
7
|
+
const parameterNotRef = (
|
|
8
|
+
param: OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject
|
|
9
|
+
): param is OpenAPIV3.ParameterObject => {
|
|
10
|
+
// all refs are deferenced by parser library
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const requestBodyNotRef = (
|
|
15
|
+
param: OpenAPIV3.RequestBodyObject | OpenAPIV3.ReferenceObject | undefined
|
|
16
|
+
): param is OpenAPIV3.RequestBodyObject => {
|
|
17
|
+
// all refs are deferenced by parser library
|
|
18
|
+
return param !== undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const schemaNotRef = (
|
|
22
|
+
param: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined
|
|
23
|
+
): param is OpenAPIV3.SchemaObject => {
|
|
24
|
+
// all refs are deferenced by parser library
|
|
25
|
+
return param !== undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isOpenAPI3 = (document: any): document is OpenAPIV3.Document => {
|
|
29
|
+
return document.openapi.includes("3.0")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const methods: string[] = Object.values(OpenAPIV3.HttpMethods)
|
|
33
|
+
|
|
34
|
+
const isOperation = (
|
|
35
|
+
key: string,
|
|
36
|
+
pathItem: any
|
|
37
|
+
): pathItem is OpenAPIV3.OperationObject => {
|
|
38
|
+
return methods.includes(key)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const isParameter = (
|
|
42
|
+
key: string,
|
|
43
|
+
pathItem: any
|
|
44
|
+
): pathItem is OpenAPIV3.ParameterObject => {
|
|
45
|
+
return !isOperation(key, pathItem)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const getRequestBody = (operation: OpenAPIV3.OperationObject) => {
|
|
49
|
+
if (requestBodyNotRef(operation.requestBody)) {
|
|
50
|
+
const request: OpenAPIV3.RequestBodyObject = operation.requestBody
|
|
51
|
+
const supportedMimeTypes = getMimeTypes(operation)
|
|
52
|
+
if (supportedMimeTypes.length > 0) {
|
|
53
|
+
const mimeType = supportedMimeTypes[0]
|
|
54
|
+
|
|
55
|
+
// try get example from request
|
|
56
|
+
const content = request.content[mimeType]
|
|
57
|
+
if (content.example) {
|
|
58
|
+
return content.example
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// try get example from schema
|
|
62
|
+
if (schemaNotRef(content.schema)) {
|
|
63
|
+
const schema = content.schema
|
|
64
|
+
if (schema.example) {
|
|
65
|
+
return schema.example
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return undefined
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const getMimeTypes = (operation: OpenAPIV3.OperationObject): string[] => {
|
|
74
|
+
if (requestBodyNotRef(operation.requestBody)) {
|
|
75
|
+
const request: OpenAPIV3.RequestBodyObject = operation.requestBody
|
|
76
|
+
return Object.keys(request.content)
|
|
77
|
+
}
|
|
78
|
+
return []
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* OpenAPI Version 3.0
|
|
83
|
+
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md
|
|
84
|
+
*/
|
|
85
|
+
export class OpenAPI3 extends OpenAPISource {
|
|
86
|
+
document!: OpenAPIV3.Document
|
|
87
|
+
|
|
88
|
+
isSupported = async (data: string): Promise<boolean> => {
|
|
89
|
+
try {
|
|
90
|
+
const document: any = await this.parseData(data)
|
|
91
|
+
if (isOpenAPI3(document)) {
|
|
92
|
+
this.document = document
|
|
93
|
+
return true
|
|
94
|
+
} else {
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
getInfo = async (): Promise<ImportInfo> => {
|
|
103
|
+
const name = this.document.info.title || "OpenAPI Import"
|
|
104
|
+
return {
|
|
105
|
+
name,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getQueries = async (datasourceId: string): Promise<Query[]> => {
|
|
110
|
+
let url: string | URL | undefined
|
|
111
|
+
if (this.document.servers?.length) {
|
|
112
|
+
url = this.document.servers[0].url
|
|
113
|
+
try {
|
|
114
|
+
url = new URL(url)
|
|
115
|
+
} catch (err) {
|
|
116
|
+
// unable to construct url, e.g. with variables
|
|
117
|
+
// proceed with string form of url
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const queries: Query[] = []
|
|
122
|
+
|
|
123
|
+
for (let [path, pathItemObject] of Object.entries(this.document.paths)) {
|
|
124
|
+
// parameters that apply to every operation in the path
|
|
125
|
+
let pathParams: OpenAPIV3.ParameterObject[] = []
|
|
126
|
+
|
|
127
|
+
// pathItemObject can be undefined
|
|
128
|
+
if (!pathItemObject) {
|
|
129
|
+
continue
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
for (let [key, opOrParams] of Object.entries(pathItemObject)) {
|
|
133
|
+
if (isParameter(key, opOrParams)) {
|
|
134
|
+
const pathParameters = opOrParams as OpenAPIV3.ParameterObject[]
|
|
135
|
+
pathParams.push(...pathParameters)
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
138
|
+
// can not be a parameter, must be an operation
|
|
139
|
+
const operation = opOrParams as OpenAPIV3.OperationObject
|
|
140
|
+
|
|
141
|
+
const methodName = key
|
|
142
|
+
const name = operation.operationId || path
|
|
143
|
+
let queryString = ""
|
|
144
|
+
const headers: any = {}
|
|
145
|
+
let requestBody = getRequestBody(operation)
|
|
146
|
+
const parameters: QueryParameter[] = []
|
|
147
|
+
const mimeTypes = getMimeTypes(operation)
|
|
148
|
+
|
|
149
|
+
if (mimeTypes.length > 0) {
|
|
150
|
+
headers["Content-Type"] = mimeTypes[0]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// combine the path parameters with the operation parameters
|
|
154
|
+
const operationParams = operation.parameters || []
|
|
155
|
+
const allParams = [...pathParams, ...operationParams]
|
|
156
|
+
|
|
157
|
+
for (let param of allParams) {
|
|
158
|
+
if (parameterNotRef(param)) {
|
|
159
|
+
switch (param.in) {
|
|
160
|
+
case "query":
|
|
161
|
+
let prefix = ""
|
|
162
|
+
if (queryString) {
|
|
163
|
+
prefix = "&"
|
|
164
|
+
}
|
|
165
|
+
queryString = `${queryString}${prefix}${param.name}={{${param.name}}}`
|
|
166
|
+
break
|
|
167
|
+
case "header":
|
|
168
|
+
headers[param.name] = `{{${param.name}}}`
|
|
169
|
+
break
|
|
170
|
+
case "path":
|
|
171
|
+
// do nothing: param is already in the path
|
|
172
|
+
break
|
|
173
|
+
case "formData":
|
|
174
|
+
// future enhancement
|
|
175
|
+
break
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// add the parameter if it can be bound in our config
|
|
179
|
+
if (["query", "header", "path"].includes(param.in)) {
|
|
180
|
+
parameters.push({
|
|
181
|
+
name: param.name,
|
|
182
|
+
default: "",
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const query = this.constructQuery(
|
|
189
|
+
datasourceId,
|
|
190
|
+
name,
|
|
191
|
+
methodName,
|
|
192
|
+
path,
|
|
193
|
+
url,
|
|
194
|
+
queryString,
|
|
195
|
+
headers,
|
|
196
|
+
parameters,
|
|
197
|
+
requestBody
|
|
198
|
+
)
|
|
199
|
+
queries.push(query)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return queries
|
|
204
|
+
}
|
|
205
|
+
}
|