@budibase/server 1.0.80 → 1.0.81-alpha.2
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 +1 -0
- package/builder/assets/{index.c8d1e8f0.css → index.8b1dc06c.css} +2 -2
- package/builder/assets/index.e4d4c510.js +1291 -0
- package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2531 -2440
- package/coverage/coverage-final.json +138 -137
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +152 -149
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +16 -16
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +86 -23
- package/coverage/lcov-report/api/controllers/row/index.html +46 -46
- package/coverage/lcov-report/api/controllers/row/index.js.html +76 -49
- package/coverage/lcov-report/api/controllers/row/internal.js.html +144 -84
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +62 -20
- package/coverage/lcov-report/api/controllers/table/index.html +20 -20
- package/coverage/lcov-report/api/controllers/table/index.js.html +47 -44
- package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
- package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +18 -27
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +37 -28
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +19 -109
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +18 -156
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +35 -35
- package/coverage/lcov-report/api/routes/index.js.html +38 -32
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +16 -58
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +15 -78
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +80 -14
- package/coverage/lcov-report/api/routes/screen.js.html +14 -95
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +17 -62
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +111 -0
- package/coverage/lcov-report/api/routes/utils/validators.js.html +737 -0
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +14 -62
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +12 -9
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +26 -26
- package/coverage/lcov-report/automations/utils.js.html +35 -35
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +40 -28
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- 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 +21 -21
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +123 -87
- 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 +8 -8
- package/coverage/lcov-report/events/utils.js.html +18 -18
- package/coverage/lcov-report/index.html +91 -76
- 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 +5 -5
- package/coverage/lcov-report/middleware/authorized.js.html +29 -29
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- 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 +10 -10
- package/coverage/lcov-report/threads/query.js.html +123 -39
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +18 -18
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- 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 +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- 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 +12 -12
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +200 -53
- package/coverage/lcov.info +3555 -3411
- package/dist/api/controllers/application.js +1 -0
- package/dist/api/controllers/public/applications.js +94 -0
- package/dist/api/controllers/public/mapping/applications.js +29 -0
- package/dist/api/controllers/public/mapping/index.js +11 -0
- package/dist/api/controllers/public/mapping/queries.js +36 -0
- package/dist/api/controllers/public/mapping/rows.js +24 -0
- package/dist/api/controllers/public/mapping/tables.js +23 -0
- package/dist/api/controllers/public/mapping/types.js +2 -0
- package/dist/api/controllers/public/mapping/users.js +29 -0
- package/dist/api/controllers/public/queries.js +38 -0
- package/dist/api/controllers/public/rows.js +97 -0
- package/dist/api/controllers/public/tables.js +75 -0
- package/dist/api/controllers/public/users.js +95 -0
- package/dist/api/controllers/public/utils.js +49 -0
- package/dist/api/controllers/row/external.js +18 -0
- package/dist/api/controllers/row/index.js +11 -0
- package/dist/api/controllers/row/internal.js +15 -1
- package/dist/api/controllers/table/external.js +8 -2
- package/dist/api/controllers/table/index.js +2 -1
- package/dist/api/controllers/webhook.js +3 -5
- package/dist/api/index.js +3 -1
- package/dist/api/routes/automation.js +3 -31
- package/dist/api/routes/datasource.js +3 -50
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/permission.js +4 -14
- package/dist/api/routes/public/applications.js +141 -0
- package/dist/api/routes/public/index.js +101 -0
- package/dist/api/routes/public/middleware/mapper.js +94 -0
- package/dist/api/routes/public/queries.js +77 -0
- package/dist/api/routes/public/rows.js +229 -0
- package/dist/api/routes/public/tables.js +154 -0
- package/dist/api/routes/public/users.js +137 -0
- package/dist/api/routes/public/utils/Endpoint.js +36 -0
- package/dist/api/routes/role.js +3 -19
- package/dist/api/routes/row.js +18 -5
- package/dist/api/routes/screen.js +2 -23
- package/dist/api/routes/table.js +3 -17
- package/dist/api/routes/tests/utilities/index.js +23 -0
- package/dist/api/routes/utils/validators.js +200 -0
- package/dist/api/routes/webhook.js +2 -17
- package/dist/automations/steps/filter.js +2 -2
- package/dist/automations/steps/queryRows.js +1 -1
- package/dist/automations/utils.js +2 -2
- package/dist/constants/index.js +3 -0
- package/dist/db/utils.js +11 -0
- package/dist/definitions/openapi.js +6 -0
- package/dist/environment.js +1 -0
- package/dist/integrations/base/sql.js +16 -1
- package/dist/integrations/base/sqlTable.js +21 -9
- package/dist/integrations/googlesheets.js +3 -0
- package/dist/integrations/microsoftSqlServer.js +60 -43
- package/dist/integrations/mysql.js +3 -0
- package/dist/integrations/oracle.js +14 -19
- package/dist/integrations/postgres.js +34 -28
- package/dist/integrations/utils.js +32 -15
- package/dist/package.json +11 -7
- package/dist/tests/utilities/TestConfiguration.js +25 -8
- package/dist/threads/query.js +33 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +50 -15
- package/package.json +12 -8
- package/scripts/integrations/mssql/data/setup.sql +18 -1
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +11 -3
- package/scripts/likeCypress.ts +9 -6
- package/specs/generate.js +94 -0
- package/specs/openapi.json +2232 -0
- package/specs/openapi.yaml +1538 -0
- package/specs/parameters.js +59 -0
- package/specs/resources/application.js +101 -0
- package/specs/resources/index.js +24 -0
- package/specs/resources/misc.js +12 -0
- package/specs/resources/query.js +189 -0
- package/specs/resources/row.js +125 -0
- package/specs/resources/table.js +191 -0
- package/specs/resources/user.js +126 -0
- package/specs/resources/utils/Resource.js +26 -0
- package/specs/resources/utils/index.js +11 -0
- package/specs/security.js +7 -0
- package/src/api/controllers/application.js +1 -0
- package/src/api/controllers/public/applications.ts +74 -0
- package/src/api/controllers/public/mapping/applications.ts +32 -0
- package/src/api/controllers/public/mapping/index.ts +13 -0
- package/src/api/controllers/public/mapping/queries.ts +39 -0
- package/src/api/controllers/public/mapping/rows.ts +31 -0
- package/src/api/controllers/public/mapping/tables.ts +26 -0
- package/src/api/controllers/public/mapping/types.ts +13 -0
- package/src/api/controllers/public/mapping/users.ts +32 -0
- package/src/api/controllers/public/queries.ts +20 -0
- package/src/api/controllers/public/rows.ts +77 -0
- package/src/api/controllers/public/tables.ts +56 -0
- package/src/api/controllers/public/users.ts +82 -0
- package/src/api/controllers/public/utils.ts +38 -0
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/external.js +21 -0
- package/src/api/controllers/row/index.js +9 -0
- package/src/api/controllers/row/internal.js +20 -0
- package/src/api/controllers/table/external.js +16 -2
- package/src/api/controllers/table/index.js +2 -1
- package/src/api/controllers/webhook.js +3 -6
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +3 -33
- package/src/api/routes/datasource.js +6 -52
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/permission.js +4 -18
- package/src/api/routes/public/applications.ts +156 -0
- package/src/api/routes/public/index.ts +118 -0
- package/src/api/routes/public/middleware/mapper.ts +81 -0
- package/src/api/routes/public/queries.ts +81 -0
- package/src/api/routes/public/rows.ts +242 -0
- package/src/api/routes/public/tables.ts +169 -0
- package/src/api/routes/public/tests/compare.spec.js +184 -0
- package/src/api/routes/public/users.ts +144 -0
- package/src/api/routes/public/utils/Endpoint.ts +51 -0
- package/src/api/routes/role.js +3 -24
- package/src/api/routes/row.js +24 -2
- package/src/api/routes/screen.js +2 -29
- package/src/api/routes/table.js +4 -19
- package/src/api/routes/tests/utilities/index.js +24 -0
- package/src/api/routes/utils/validators.js +219 -0
- package/src/api/routes/webhook.js +2 -18
- package/src/automations/steps/filter.js +3 -2
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +4 -0
- package/src/db/utils.js +12 -0
- package/src/definitions/common.ts +4 -0
- package/src/definitions/datasource.ts +7 -0
- package/src/definitions/openapi.ts +943 -0
- package/src/environment.js +1 -0
- package/src/integrations/base/datasourcePlus.ts +3 -0
- package/src/integrations/base/sql.ts +16 -1
- package/src/integrations/base/sqlTable.ts +35 -13
- package/src/integrations/googlesheets.ts +5 -2
- package/src/integrations/microsoftSqlServer.ts +86 -61
- package/src/integrations/mysql.ts +4 -0
- package/src/integrations/oracle.ts +27 -35
- package/src/integrations/postgres.ts +33 -26
- package/src/integrations/utils.ts +43 -15
- package/src/tests/utilities/TestConfiguration.js +23 -2
- package/src/threads/query.js +37 -9
- package/src/utilities/workerRequests.js +65 -16
- package/builder/assets/index.22a39cc9.js +0 -1352
- package/scripts/proxy/generateProxyConfig.js +0 -70
package/dist/api/routes/row.js
CHANGED
|
@@ -5,6 +5,7 @@ const authorized = require("../../middleware/authorized");
|
|
|
5
5
|
const usage = require("../../middleware/usageQuota");
|
|
6
6
|
const { paramResource, paramSubResource, } = require("../../middleware/resourceId");
|
|
7
7
|
const { PermissionLevels, PermissionTypes, } = require("@budibase/backend-core/permissions");
|
|
8
|
+
const { internalSearchValidator } = require("./utils/validators");
|
|
8
9
|
const router = Router();
|
|
9
10
|
router
|
|
10
11
|
/**
|
|
@@ -97,8 +98,6 @@ router
|
|
|
97
98
|
* "notEqual": {},
|
|
98
99
|
* "empty": {},
|
|
99
100
|
* "notEmpty": {},
|
|
100
|
-
* "contains": {},
|
|
101
|
-
* "notContains": {}
|
|
102
101
|
* "oneOf": {
|
|
103
102
|
* "columnName": ["value"]
|
|
104
103
|
* }
|
|
@@ -116,7 +115,7 @@ router
|
|
|
116
115
|
* @apiSuccess {string} bookmark The bookmark to be sent with the next request to get the next
|
|
117
116
|
* page.
|
|
118
117
|
*/
|
|
119
|
-
.post("/api/:tableId/search", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
|
|
118
|
+
.post("/api/:tableId/search", internalSearchValidator(), paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
|
|
120
119
|
// DEPRECATED - this is an old API, but for backwards compat it needs to be
|
|
121
120
|
// supported still
|
|
122
121
|
.post("/api/search/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
|
|
@@ -153,7 +152,7 @@ router
|
|
|
153
152
|
* @apiDescription This endpoint is identical to the row creation endpoint but instead it will
|
|
154
153
|
* error if an _id isn't provided, it will only function for existing rows.
|
|
155
154
|
*/
|
|
156
|
-
.patch("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), rowController.patch)
|
|
155
|
+
.patch("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.patch)
|
|
157
156
|
/**
|
|
158
157
|
* @api {post} /api/:tableId/rows/validate Validate inputs for a row
|
|
159
158
|
* @apiName Validate inputs for a row
|
|
@@ -195,5 +194,19 @@ router
|
|
|
195
194
|
* of the deleted rows, if deleting a single row then the body will contain a "row" property which
|
|
196
195
|
* is the deleted row.
|
|
197
196
|
*/
|
|
198
|
-
.delete("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.destroy)
|
|
197
|
+
.delete("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.destroy)
|
|
198
|
+
/**
|
|
199
|
+
* @api {post} /api/:tableId/rows/exportRows Export Rows
|
|
200
|
+
* @apiName Export rows
|
|
201
|
+
* @apiGroup rows
|
|
202
|
+
* @apiPermission table write access
|
|
203
|
+
* @apiDescription This API can export a number of provided rows
|
|
204
|
+
*
|
|
205
|
+
* @apiParam {string} tableId The ID of the table the row is to be deleted from.
|
|
206
|
+
*
|
|
207
|
+
* @apiParam (Body) {object[]} [rows] The row IDs which are to be exported
|
|
208
|
+
*
|
|
209
|
+
* @apiSuccess {object[]|object}
|
|
210
|
+
*/
|
|
211
|
+
.post("/api/:tableId/rows/exportRows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.export);
|
|
199
212
|
module.exports = router;
|
|
@@ -3,31 +3,10 @@ const Router = require("@koa/router");
|
|
|
3
3
|
const controller = require("../controllers/screen");
|
|
4
4
|
const authorized = require("../../middleware/authorized");
|
|
5
5
|
const { BUILDER } = require("@budibase/backend-core/permissions");
|
|
6
|
-
const
|
|
7
|
-
const Joi = require("joi");
|
|
6
|
+
const { screenValidator } = require("./utils/validators");
|
|
8
7
|
const router = Router();
|
|
9
|
-
function generateSaveValidation() {
|
|
10
|
-
// prettier-ignore
|
|
11
|
-
return joiValidator.body(Joi.object({
|
|
12
|
-
name: Joi.string().required(),
|
|
13
|
-
routing: Joi.object({
|
|
14
|
-
route: Joi.string().required(),
|
|
15
|
-
roleId: Joi.string().required().allow(""),
|
|
16
|
-
}).required().unknown(true),
|
|
17
|
-
props: Joi.object({
|
|
18
|
-
_id: Joi.string().required(),
|
|
19
|
-
_component: Joi.string().required(),
|
|
20
|
-
_children: Joi.array().required(),
|
|
21
|
-
_instanceName: Joi.string().required(),
|
|
22
|
-
_styles: Joi.object().required(),
|
|
23
|
-
type: Joi.string().optional(),
|
|
24
|
-
table: Joi.string().optional(),
|
|
25
|
-
layoutId: Joi.string().optional(),
|
|
26
|
-
}).required().unknown(true),
|
|
27
|
-
}).unknown(true));
|
|
28
|
-
}
|
|
29
8
|
router
|
|
30
9
|
.get("/api/screens", authorized(BUILDER), controller.fetch)
|
|
31
|
-
.post("/api/screens", authorized(BUILDER),
|
|
10
|
+
.post("/api/screens", authorized(BUILDER), screenValidator(), controller.save)
|
|
32
11
|
.delete("/api/screens/:screenId/:screenRev", authorized(BUILDER), controller.destroy);
|
|
33
12
|
module.exports = router;
|
package/dist/api/routes/table.js
CHANGED
|
@@ -4,22 +4,8 @@ const tableController = require("../controllers/table");
|
|
|
4
4
|
const authorized = require("../../middleware/authorized");
|
|
5
5
|
const { paramResource, bodyResource } = require("../../middleware/resourceId");
|
|
6
6
|
const { BUILDER, PermissionLevels, PermissionTypes, } = require("@budibase/backend-core/permissions");
|
|
7
|
-
const
|
|
8
|
-
const Joi = require("joi");
|
|
7
|
+
const { tableValidator } = require("./utils/validators");
|
|
9
8
|
const router = Router();
|
|
10
|
-
function generateSaveValidator() {
|
|
11
|
-
// prettier-ignore
|
|
12
|
-
return joiValidator.body(Joi.object({
|
|
13
|
-
_id: Joi.string(),
|
|
14
|
-
_rev: Joi.string(),
|
|
15
|
-
type: Joi.string().valid("table", "internal", "external"),
|
|
16
|
-
primaryDisplay: Joi.string(),
|
|
17
|
-
schema: Joi.object().required(),
|
|
18
|
-
name: Joi.string().required(),
|
|
19
|
-
views: Joi.object(),
|
|
20
|
-
dataImport: Joi.object(),
|
|
21
|
-
}).unknown(true));
|
|
22
|
-
}
|
|
23
9
|
router
|
|
24
10
|
/**
|
|
25
11
|
* @api {get} /api/tables Fetch all tables
|
|
@@ -46,7 +32,7 @@ router
|
|
|
46
32
|
*
|
|
47
33
|
* @apiSuccess {object[]} body The response body will be the table that was found.
|
|
48
34
|
*/
|
|
49
|
-
.get("/api/tables/:
|
|
35
|
+
.get("/api/tables/:tableId", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), tableController.find)
|
|
50
36
|
/**
|
|
51
37
|
* @api {post} /api/tables Save a table
|
|
52
38
|
* @apiName Save a table
|
|
@@ -122,7 +108,7 @@ router
|
|
|
122
108
|
*/
|
|
123
109
|
.post("/api/tables",
|
|
124
110
|
// allows control over updating a table
|
|
125
|
-
bodyResource("_id"), authorized(BUILDER),
|
|
111
|
+
bodyResource("_id"), authorized(BUILDER), tableValidator(), tableController.save)
|
|
126
112
|
/**
|
|
127
113
|
* @api {post} /api/tables/csv/validate Validate a CSV for a table
|
|
128
114
|
* @apiName Validate a CSV for a table
|
|
@@ -11,6 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const TestConfig = require("../../../../tests/utilities/TestConfiguration");
|
|
12
12
|
const structures = require("../../../../tests/utilities/structures");
|
|
13
13
|
const env = require("../../../../environment");
|
|
14
|
+
function user() {
|
|
15
|
+
return {
|
|
16
|
+
_id: "user",
|
|
17
|
+
_rev: "rev",
|
|
18
|
+
createdAt: Date.now(),
|
|
19
|
+
email: "test@test.com",
|
|
20
|
+
roles: {},
|
|
21
|
+
tenantId: "default",
|
|
22
|
+
status: "active",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
14
25
|
jest.mock("../../../../utilities/workerRequests", () => ({
|
|
15
26
|
getGlobalUsers: jest.fn(() => {
|
|
16
27
|
return {
|
|
@@ -22,6 +33,18 @@ jest.mock("../../../../utilities/workerRequests", () => ({
|
|
|
22
33
|
_id: "us_uuid1",
|
|
23
34
|
};
|
|
24
35
|
}),
|
|
36
|
+
allGlobalUsers: jest.fn(() => {
|
|
37
|
+
return [user()];
|
|
38
|
+
}),
|
|
39
|
+
readGlobalUser: jest.fn(() => {
|
|
40
|
+
return user();
|
|
41
|
+
}),
|
|
42
|
+
saveGlobalUser: jest.fn(() => {
|
|
43
|
+
return { _id: "user", _rev: "rev" };
|
|
44
|
+
}),
|
|
45
|
+
deleteGlobalUser: jest.fn(() => {
|
|
46
|
+
return { message: "deleted user" };
|
|
47
|
+
}),
|
|
25
48
|
removeAppFromUserRoles: jest.fn(),
|
|
26
49
|
}));
|
|
27
50
|
exports.delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const joiValidator = require("../../../middleware/joi-validator");
|
|
3
|
+
const { DataSourceOperation } = require("../../../constants");
|
|
4
|
+
const { WebhookType } = require("../../../constants");
|
|
5
|
+
const { BUILTIN_PERMISSION_IDS, PermissionLevels, } = require("@budibase/backend-core/permissions");
|
|
6
|
+
const Joi = require("joi");
|
|
7
|
+
const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("");
|
|
8
|
+
const OPTIONAL_NUMBER = Joi.number().optional().allow(null);
|
|
9
|
+
exports.tableValidator = () => {
|
|
10
|
+
// prettier-ignore
|
|
11
|
+
return joiValidator.body(Joi.object({
|
|
12
|
+
_id: OPTIONAL_STRING,
|
|
13
|
+
_rev: OPTIONAL_STRING,
|
|
14
|
+
type: OPTIONAL_STRING.valid("table", "internal", "external"),
|
|
15
|
+
primaryDisplay: OPTIONAL_STRING,
|
|
16
|
+
schema: Joi.object().required(),
|
|
17
|
+
name: Joi.string().required(),
|
|
18
|
+
views: Joi.object(),
|
|
19
|
+
dataImport: Joi.object(),
|
|
20
|
+
}).unknown(true));
|
|
21
|
+
};
|
|
22
|
+
exports.nameValidator = () => {
|
|
23
|
+
// prettier-ignore
|
|
24
|
+
return joiValidator.body(Joi.object({
|
|
25
|
+
name: OPTIONAL_STRING,
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
exports.datasourceValidator = () => {
|
|
29
|
+
// prettier-ignore
|
|
30
|
+
return joiValidator.body(Joi.object({
|
|
31
|
+
_id: Joi.string(),
|
|
32
|
+
_rev: Joi.string(),
|
|
33
|
+
type: OPTIONAL_STRING.allow("datasource_plus"),
|
|
34
|
+
relationships: Joi.array().items(Joi.object({
|
|
35
|
+
from: Joi.string().required(),
|
|
36
|
+
to: Joi.string().required(),
|
|
37
|
+
cardinality: Joi.valid("1:N", "1:1", "N:N").required()
|
|
38
|
+
})),
|
|
39
|
+
}).unknown(true));
|
|
40
|
+
};
|
|
41
|
+
function filterObject() {
|
|
42
|
+
// prettier-ignore
|
|
43
|
+
return Joi.object({
|
|
44
|
+
string: Joi.object().optional(),
|
|
45
|
+
fuzzy: Joi.object().optional(),
|
|
46
|
+
range: Joi.object().optional(),
|
|
47
|
+
equal: Joi.object().optional(),
|
|
48
|
+
notEqual: Joi.object().optional(),
|
|
49
|
+
empty: Joi.object().optional(),
|
|
50
|
+
notEmpty: Joi.object().optional(),
|
|
51
|
+
oneOf: Joi.object().optional(),
|
|
52
|
+
contains: Joi.object().optional(),
|
|
53
|
+
notContains: Joi.object().optional(),
|
|
54
|
+
}).unknown(true);
|
|
55
|
+
}
|
|
56
|
+
exports.internalSearchValidator = () => {
|
|
57
|
+
// prettier-ignore
|
|
58
|
+
return joiValidator.body(Joi.object({
|
|
59
|
+
tableId: OPTIONAL_STRING,
|
|
60
|
+
query: filterObject(),
|
|
61
|
+
limit: OPTIONAL_NUMBER,
|
|
62
|
+
sort: OPTIONAL_STRING,
|
|
63
|
+
sortOrder: OPTIONAL_STRING,
|
|
64
|
+
sortType: OPTIONAL_STRING,
|
|
65
|
+
paginate: Joi.boolean(),
|
|
66
|
+
bookmark: Joi.alternatives().try(OPTIONAL_STRING, OPTIONAL_NUMBER).optional(),
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
exports.externalSearchValidator = () => {
|
|
70
|
+
return joiValidator.body(Joi.object({
|
|
71
|
+
query: filterObject(),
|
|
72
|
+
paginate: Joi.boolean().optional(),
|
|
73
|
+
bookmark: Joi.alternatives()
|
|
74
|
+
.try(OPTIONAL_STRING, OPTIONAL_NUMBER)
|
|
75
|
+
.optional(),
|
|
76
|
+
limit: OPTIONAL_NUMBER,
|
|
77
|
+
sort: Joi.object({
|
|
78
|
+
column: Joi.string(),
|
|
79
|
+
order: OPTIONAL_STRING.valid("ascending", "descending"),
|
|
80
|
+
type: OPTIONAL_STRING.valid("string", "number"),
|
|
81
|
+
}).optional(),
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
exports.datasourceQueryValidator = () => {
|
|
85
|
+
// prettier-ignore
|
|
86
|
+
return joiValidator.body(Joi.object({
|
|
87
|
+
endpoint: Joi.object({
|
|
88
|
+
datasourceId: Joi.string().required(),
|
|
89
|
+
operation: Joi.string().required().valid(...Object.values(DataSourceOperation)),
|
|
90
|
+
entityId: Joi.string().required(),
|
|
91
|
+
}).required(),
|
|
92
|
+
resource: Joi.object({
|
|
93
|
+
fields: Joi.array().items(Joi.string()).optional(),
|
|
94
|
+
}).optional(),
|
|
95
|
+
body: Joi.object().optional(),
|
|
96
|
+
sort: Joi.object().optional(),
|
|
97
|
+
filters: filterObject().optional(),
|
|
98
|
+
paginate: Joi.object({
|
|
99
|
+
page: Joi.string().alphanum().optional(),
|
|
100
|
+
limit: Joi.number().optional(),
|
|
101
|
+
}).optional(),
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
exports.webhookValidator = () => {
|
|
105
|
+
// prettier-ignore
|
|
106
|
+
return joiValidator.body(Joi.object({
|
|
107
|
+
live: Joi.bool(),
|
|
108
|
+
_id: OPTIONAL_STRING,
|
|
109
|
+
_rev: OPTIONAL_STRING,
|
|
110
|
+
name: Joi.string().required(),
|
|
111
|
+
bodySchema: Joi.object().optional(),
|
|
112
|
+
action: Joi.object({
|
|
113
|
+
type: Joi.string().required().valid(WebhookType.AUTOMATION),
|
|
114
|
+
target: Joi.string().required(),
|
|
115
|
+
}).required(),
|
|
116
|
+
}).unknown(true));
|
|
117
|
+
};
|
|
118
|
+
exports.roleValidator = () => {
|
|
119
|
+
const permLevelArray = Object.values(PermissionLevels);
|
|
120
|
+
// prettier-ignore
|
|
121
|
+
return joiValidator.body(Joi.object({
|
|
122
|
+
_id: OPTIONAL_STRING,
|
|
123
|
+
_rev: OPTIONAL_STRING,
|
|
124
|
+
name: Joi.string().required(),
|
|
125
|
+
// this is the base permission ID (for now a built in)
|
|
126
|
+
permissionId: Joi.string().valid(...Object.values(BUILTIN_PERMISSION_IDS)).required(),
|
|
127
|
+
permissions: Joi.object()
|
|
128
|
+
.pattern(/.*/, [Joi.string().valid(...permLevelArray)])
|
|
129
|
+
.optional(),
|
|
130
|
+
inherits: OPTIONAL_STRING,
|
|
131
|
+
}).unknown(true));
|
|
132
|
+
};
|
|
133
|
+
exports.permissionValidator = () => {
|
|
134
|
+
const permLevelArray = Object.values(PermissionLevels);
|
|
135
|
+
// prettier-ignore
|
|
136
|
+
return joiValidator.params(Joi.object({
|
|
137
|
+
level: Joi.string().valid(...permLevelArray).required(),
|
|
138
|
+
resourceId: Joi.string(),
|
|
139
|
+
roleId: Joi.string(),
|
|
140
|
+
}).unknown(true));
|
|
141
|
+
};
|
|
142
|
+
exports.screenValidator = () => {
|
|
143
|
+
// prettier-ignore
|
|
144
|
+
return joiValidator.body(Joi.object({
|
|
145
|
+
name: Joi.string().required(),
|
|
146
|
+
routing: Joi.object({
|
|
147
|
+
route: Joi.string().required(),
|
|
148
|
+
roleId: Joi.string().required().allow(""),
|
|
149
|
+
}).required().unknown(true),
|
|
150
|
+
props: Joi.object({
|
|
151
|
+
_id: Joi.string().required(),
|
|
152
|
+
_component: Joi.string().required(),
|
|
153
|
+
_children: Joi.array().required(),
|
|
154
|
+
_instanceName: Joi.string().required(),
|
|
155
|
+
_styles: Joi.object().required(),
|
|
156
|
+
type: OPTIONAL_STRING,
|
|
157
|
+
table: OPTIONAL_STRING,
|
|
158
|
+
layoutId: OPTIONAL_STRING,
|
|
159
|
+
}).required().unknown(true),
|
|
160
|
+
}).unknown(true));
|
|
161
|
+
};
|
|
162
|
+
function generateStepSchema(allowStepTypes) {
|
|
163
|
+
// prettier-ignore
|
|
164
|
+
return Joi.object({
|
|
165
|
+
stepId: Joi.string().required(),
|
|
166
|
+
id: Joi.string().required(),
|
|
167
|
+
description: Joi.string().required(),
|
|
168
|
+
name: Joi.string().required(),
|
|
169
|
+
tagline: Joi.string().required(),
|
|
170
|
+
icon: Joi.string().required(),
|
|
171
|
+
params: Joi.object(),
|
|
172
|
+
args: Joi.object(),
|
|
173
|
+
type: Joi.string().required().valid(...allowStepTypes),
|
|
174
|
+
}).unknown(true);
|
|
175
|
+
}
|
|
176
|
+
exports.automationValidator = (existing = false) => {
|
|
177
|
+
// prettier-ignore
|
|
178
|
+
return joiValidator.body(Joi.object({
|
|
179
|
+
_id: existing ? Joi.string().required() : OPTIONAL_STRING,
|
|
180
|
+
_rev: existing ? Joi.string().required() : OPTIONAL_STRING,
|
|
181
|
+
name: Joi.string().required(),
|
|
182
|
+
type: Joi.string().valid("automation").required(),
|
|
183
|
+
definition: Joi.object({
|
|
184
|
+
steps: Joi.array().required().items(generateStepSchema(["ACTION", "LOGIC"])),
|
|
185
|
+
trigger: generateStepSchema(["TRIGGER"]).allow(null),
|
|
186
|
+
}).required().unknown(true),
|
|
187
|
+
}).unknown(true));
|
|
188
|
+
};
|
|
189
|
+
exports.applicationValidator = () => {
|
|
190
|
+
// prettier-ignore
|
|
191
|
+
return joiValidator.body(Joi.object({
|
|
192
|
+
_id: OPTIONAL_STRING,
|
|
193
|
+
_rev: OPTIONAL_STRING,
|
|
194
|
+
name: Joi.string().required(),
|
|
195
|
+
url: OPTIONAL_STRING,
|
|
196
|
+
template: Joi.object({
|
|
197
|
+
templateString: OPTIONAL_STRING,
|
|
198
|
+
}).unknown(true),
|
|
199
|
+
}).unknown(true));
|
|
200
|
+
};
|
|
@@ -2,27 +2,12 @@
|
|
|
2
2
|
const Router = require("@koa/router");
|
|
3
3
|
const controller = require("../controllers/webhook");
|
|
4
4
|
const authorized = require("../../middleware/authorized");
|
|
5
|
-
const joiValidator = require("../../middleware/joi-validator");
|
|
6
5
|
const { BUILDER } = require("@budibase/backend-core/permissions");
|
|
7
|
-
const
|
|
6
|
+
const { webhookValidator } = require("./utils/validators");
|
|
8
7
|
const router = Router();
|
|
9
|
-
function generateSaveValidator() {
|
|
10
|
-
// prettier-ignore
|
|
11
|
-
return joiValidator.body(Joi.object({
|
|
12
|
-
live: Joi.bool(),
|
|
13
|
-
_id: Joi.string().optional(),
|
|
14
|
-
_rev: Joi.string().optional(),
|
|
15
|
-
name: Joi.string().required(),
|
|
16
|
-
bodySchema: Joi.object().optional(),
|
|
17
|
-
action: Joi.object({
|
|
18
|
-
type: Joi.string().required().valid(controller.WebhookType.AUTOMATION),
|
|
19
|
-
target: Joi.string().required(),
|
|
20
|
-
}).required(),
|
|
21
|
-
}).unknown(true));
|
|
22
|
-
}
|
|
23
8
|
router
|
|
24
9
|
.get("/api/webhooks", authorized(BUILDER), controller.fetch)
|
|
25
|
-
.put("/api/webhooks", authorized(BUILDER),
|
|
10
|
+
.put("/api/webhooks", authorized(BUILDER), webhookValidator(), controller.save)
|
|
26
11
|
.delete("/api/webhooks/:id/:rev", authorized(BUILDER), controller.destroy)
|
|
27
12
|
.post("/api/webhooks/schema/:instance/:id", authorized(BUILDER), controller.buildSchema)
|
|
28
13
|
// this shouldn't have authorisation, right now its always public
|
|
@@ -23,10 +23,10 @@ const PrettyFilterConditions = {
|
|
|
23
23
|
exports.FilterConditions = FilterConditions;
|
|
24
24
|
exports.PrettyFilterConditions = PrettyFilterConditions;
|
|
25
25
|
exports.definition = {
|
|
26
|
-
name: "
|
|
26
|
+
name: "Condition",
|
|
27
27
|
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
|
|
28
28
|
icon: "Branch2",
|
|
29
|
-
description: "
|
|
29
|
+
description: "Conditionally halt automations which do not meet certain conditions",
|
|
30
30
|
type: "LOGIC",
|
|
31
31
|
internal: true,
|
|
32
32
|
stepId: "FILTER",
|
|
@@ -15,7 +15,7 @@ const CouchDB = require("../db");
|
|
|
15
15
|
const { queue } = require("./bullboard");
|
|
16
16
|
const newid = require("../db/newid");
|
|
17
17
|
const { updateEntityMetadata } = require("../utilities");
|
|
18
|
-
const { MetadataTypes } = require("../constants");
|
|
18
|
+
const { MetadataTypes, WebhookType } = require("../constants");
|
|
19
19
|
const { getProdAppID } = require("@budibase/backend-core/db");
|
|
20
20
|
const { cloneDeep } = require("lodash/fp");
|
|
21
21
|
const { getAppDB, getAppId } = require("@budibase/backend-core/context");
|
|
@@ -145,7 +145,7 @@ exports.checkForWebhooks = ({ oldAuto, newAuto }) => __awaiter(void 0, void 0, v
|
|
|
145
145
|
const ctx = {
|
|
146
146
|
appId,
|
|
147
147
|
request: {
|
|
148
|
-
body: new webhooks.Webhook("Automation webhook",
|
|
148
|
+
body: new webhooks.Webhook("Automation webhook", WebhookType.AUTOMATION, newAuto._id),
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
151
|
yield webhooks.save(ctx);
|
package/dist/constants/index.js
CHANGED
|
@@ -166,5 +166,8 @@ exports.BuildSchemaErrors = {
|
|
|
166
166
|
NO_KEY: "no_key",
|
|
167
167
|
INVALID_COLUMN: "invalid_column",
|
|
168
168
|
};
|
|
169
|
+
exports.WebhookType = {
|
|
170
|
+
AUTOMATION: "automation",
|
|
171
|
+
};
|
|
169
172
|
// pass through the list from the auth/core lib
|
|
170
173
|
exports.ObjectStoreBuckets = ObjectStoreBuckets;
|
package/dist/db/utils.js
CHANGED
|
@@ -114,6 +114,17 @@ exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
|
|
114
114
|
const endOfKey = rowId == null ? `${tableId}${SEPARATOR}` : rowId;
|
|
115
115
|
return getDocParams(DocumentTypes.ROW, endOfKey, otherProps);
|
|
116
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* Given a row ID this will find the table ID within it (only works for internal tables).
|
|
119
|
+
* @param {string} rowId The ID of the row.
|
|
120
|
+
* @returns {string} The table ID.
|
|
121
|
+
*/
|
|
122
|
+
exports.getTableIDFromRowID = rowId => {
|
|
123
|
+
const components = rowId
|
|
124
|
+
.split(DocumentTypes.TABLE + SEPARATOR)[1]
|
|
125
|
+
.split(SEPARATOR);
|
|
126
|
+
return `${DocumentTypes.TABLE}${SEPARATOR}${components[0]}`;
|
|
127
|
+
};
|
|
117
128
|
/**
|
|
118
129
|
* Gets a new row ID for the specified table.
|
|
119
130
|
* @param {string} tableId The table which the row is being created for.
|
package/dist/environment.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = {
|
|
|
37
37
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
38
38
|
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
|
39
39
|
HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS,
|
|
40
|
+
API_REQ_LIMIT_PER_SEC: process.env.API_REQ_LIMIT_PER_SEC,
|
|
40
41
|
// environment
|
|
41
42
|
NODE_ENV: process.env.NODE_ENV,
|
|
42
43
|
JEST_WORKER_ID: process.env.JEST_WORKER_ID,
|
|
@@ -232,6 +232,9 @@ class InternalBuilder {
|
|
|
232
232
|
create(knex, json, opts) {
|
|
233
233
|
const { endpoint, body } = json;
|
|
234
234
|
let query = knex(endpoint.entityId);
|
|
235
|
+
if (endpoint.schema) {
|
|
236
|
+
query = query.withSchema(endpoint.schema);
|
|
237
|
+
}
|
|
235
238
|
const parsedBody = parseBody(body);
|
|
236
239
|
// make sure no null values in body for creation
|
|
237
240
|
for (let [key, value] of Object.entries(parsedBody)) {
|
|
@@ -250,6 +253,9 @@ class InternalBuilder {
|
|
|
250
253
|
bulkCreate(knex, json) {
|
|
251
254
|
const { endpoint, body } = json;
|
|
252
255
|
let query = knex(endpoint.entityId);
|
|
256
|
+
if (endpoint.schema) {
|
|
257
|
+
query = query.withSchema(endpoint.schema);
|
|
258
|
+
}
|
|
253
259
|
if (!Array.isArray(body)) {
|
|
254
260
|
return query;
|
|
255
261
|
}
|
|
@@ -257,7 +263,7 @@ class InternalBuilder {
|
|
|
257
263
|
return query.insert(parsedBody);
|
|
258
264
|
}
|
|
259
265
|
read(knex, json, limit) {
|
|
260
|
-
let { endpoint, resource, filters,
|
|
266
|
+
let { endpoint, resource, filters, paginate, relationships } = json;
|
|
261
267
|
const tableName = endpoint.entityId;
|
|
262
268
|
// select all if not specified
|
|
263
269
|
if (!resource) {
|
|
@@ -285,6 +291,9 @@ class InternalBuilder {
|
|
|
285
291
|
}
|
|
286
292
|
// start building the query
|
|
287
293
|
let query = knex(tableName).limit(foundLimit);
|
|
294
|
+
if (endpoint.schema) {
|
|
295
|
+
query = query.withSchema(endpoint.schema);
|
|
296
|
+
}
|
|
288
297
|
if (foundOffset) {
|
|
289
298
|
query = query.offset(foundOffset);
|
|
290
299
|
}
|
|
@@ -307,6 +316,9 @@ class InternalBuilder {
|
|
|
307
316
|
update(knex, json, opts) {
|
|
308
317
|
const { endpoint, body, filters } = json;
|
|
309
318
|
let query = knex(endpoint.entityId);
|
|
319
|
+
if (endpoint.schema) {
|
|
320
|
+
query = query.withSchema(endpoint.schema);
|
|
321
|
+
}
|
|
310
322
|
const parsedBody = parseBody(body);
|
|
311
323
|
query = this.addFilters(query, filters, { tableName: endpoint.entityId });
|
|
312
324
|
// mysql can't use returning
|
|
@@ -320,6 +332,9 @@ class InternalBuilder {
|
|
|
320
332
|
delete(knex, json, opts) {
|
|
321
333
|
const { endpoint, filters } = json;
|
|
322
334
|
let query = knex(endpoint.entityId);
|
|
335
|
+
if (endpoint.schema) {
|
|
336
|
+
query = query.withSchema(endpoint.schema);
|
|
337
|
+
}
|
|
323
338
|
query = this.addFilters(query, filters, { tableName: endpoint.entityId });
|
|
324
339
|
// mysql can't use returning
|
|
325
340
|
if (opts.disableReturning) {
|
|
@@ -4,7 +4,7 @@ const knex_1 = require("knex");
|
|
|
4
4
|
const datasource_1 = require("../../definitions/datasource");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const { FieldTypes, RelationshipTypes } = require("../../constants");
|
|
7
|
-
function generateSchema(schema, table, tables, oldTable = null) {
|
|
7
|
+
function generateSchema(schema, table, tables, oldTable = null, renamed) {
|
|
8
8
|
let primaryKey = table && table.primary ? table.primary[0] : null;
|
|
9
9
|
const columns = Object.values(table.schema);
|
|
10
10
|
// all columns in a junction table will be meta
|
|
@@ -22,7 +22,9 @@ function generateSchema(schema, table, tables, oldTable = null) {
|
|
|
22
22
|
for (let [key, column] of Object.entries(table.schema)) {
|
|
23
23
|
// skip things that are already correct
|
|
24
24
|
const oldColumn = oldTable ? oldTable.schema[key] : null;
|
|
25
|
-
if ((oldColumn && oldColumn.type) ||
|
|
25
|
+
if ((oldColumn && oldColumn.type) ||
|
|
26
|
+
(primaryKey === key && !isJunction) ||
|
|
27
|
+
(renamed === null || renamed === void 0 ? void 0 : renamed.updated) === key) {
|
|
26
28
|
continue;
|
|
27
29
|
}
|
|
28
30
|
switch (column.type) {
|
|
@@ -72,12 +74,18 @@ function generateSchema(schema, table, tables, oldTable = null) {
|
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
if (renamed) {
|
|
78
|
+
schema.renameColumn(renamed.old, renamed.updated);
|
|
79
|
+
}
|
|
75
80
|
// need to check if any columns have been deleted
|
|
76
81
|
if (oldTable) {
|
|
77
82
|
const deletedColumns = Object.entries(oldTable.schema)
|
|
78
83
|
.filter(([key, schema]) => schema.type !== FieldTypes.LINK && table.schema[key] == null)
|
|
79
84
|
.map(([key]) => key);
|
|
80
85
|
deletedColumns.forEach(key => {
|
|
86
|
+
if ((renamed === null || renamed === void 0 ? void 0 : renamed.old) === key) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
81
89
|
if (oldTable.constrained && oldTable.constrained.indexOf(key) !== -1) {
|
|
82
90
|
schema.dropForeign(key);
|
|
83
91
|
}
|
|
@@ -87,17 +95,17 @@ function generateSchema(schema, table, tables, oldTable = null) {
|
|
|
87
95
|
return schema;
|
|
88
96
|
}
|
|
89
97
|
function buildCreateTable(knex, table, tables) {
|
|
90
|
-
return knex.
|
|
98
|
+
return knex.createTable(table.name, schema => {
|
|
91
99
|
generateSchema(schema, table, tables);
|
|
92
100
|
});
|
|
93
101
|
}
|
|
94
|
-
function buildUpdateTable(knex, table, tables, oldTable) {
|
|
95
|
-
return knex.
|
|
96
|
-
generateSchema(schema, table, tables, oldTable);
|
|
102
|
+
function buildUpdateTable(knex, table, tables, oldTable, renamed) {
|
|
103
|
+
return knex.alterTable(table.name, schema => {
|
|
104
|
+
generateSchema(schema, table, tables, oldTable, renamed);
|
|
97
105
|
});
|
|
98
106
|
}
|
|
99
107
|
function buildDeleteTable(knex, table) {
|
|
100
|
-
return knex.
|
|
108
|
+
return knex.dropTable(table.name);
|
|
101
109
|
}
|
|
102
110
|
class SqlTableQueryBuilder {
|
|
103
111
|
// pass through client to get flavour of SQL
|
|
@@ -115,7 +123,11 @@ class SqlTableQueryBuilder {
|
|
|
115
123
|
return json.endpoint.operation;
|
|
116
124
|
}
|
|
117
125
|
_tableQuery(json) {
|
|
118
|
-
|
|
126
|
+
var _a;
|
|
127
|
+
let client = knex_1.knex({ client: this.sqlClient }).schema;
|
|
128
|
+
if ((_a = json === null || json === void 0 ? void 0 : json.endpoint) === null || _a === void 0 ? void 0 : _a.schema) {
|
|
129
|
+
client = client.withSchema(json.endpoint.schema);
|
|
130
|
+
}
|
|
119
131
|
let query;
|
|
120
132
|
if (!json.table || !json.meta || !json.meta.tables) {
|
|
121
133
|
throw "Cannot execute without table being specified";
|
|
@@ -128,7 +140,7 @@ class SqlTableQueryBuilder {
|
|
|
128
140
|
if (!json.meta || !json.meta.table) {
|
|
129
141
|
throw "Must specify old table for update";
|
|
130
142
|
}
|
|
131
|
-
query = buildUpdateTable(client, json.table, json.meta.tables, json.meta.table);
|
|
143
|
+
query = buildUpdateTable(client, json.table, json.meta.tables, json.meta.table, json.meta.renamed);
|
|
132
144
|
break;
|
|
133
145
|
case datasource_1.Operation.DELETE_TABLE:
|
|
134
146
|
query = buildDeleteTable(client, json.table);
|
|
@@ -97,6 +97,9 @@ var GoogleSheetsModule;
|
|
|
97
97
|
const spreadsheetId = this.cleanSpreadsheetUrl(this.config.spreadsheetId);
|
|
98
98
|
this.client = new google_spreadsheet_1.GoogleSpreadsheet(spreadsheetId);
|
|
99
99
|
}
|
|
100
|
+
getBindingIdentifier() {
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
100
103
|
/**
|
|
101
104
|
* Pull the spreadsheet ID out from a valid google sheets URL
|
|
102
105
|
* @param spreadsheetId - the URL or standard spreadsheetId of the google sheet
|