@budibase/server 1.0.78 → 1.0.79-alpha.10
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.1a081633.js +1288 -0
- package/builder/assets/{index.c8d1e8f0.css → index.c57242d4.css} +2 -2
- package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2399 -2336
- 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 +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +27 -27
- package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
- package/coverage/lcov-report/api/controllers/row/internal.js.html +94 -82
- 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 +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +11 -11
- 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 +17 -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 +89 -74
- 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 +3323 -3224
- 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/internal.js +4 -1
- 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 +68 -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 +3 -4
- 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/integrations/googlesheets.js +3 -0
- package/dist/integrations/microsoftSqlServer.js +35 -29
- package/dist/integrations/mysql.js +30 -26
- package/dist/integrations/oracle.js +14 -19
- package/dist/integrations/postgres.js +34 -28
- package/dist/package.json +8 -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 +9 -8
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +5 -3
- package/scripts/likeCypress.ts +9 -6
- package/specs/generate.js +83 -0
- package/specs/openapi.json +2222 -0
- package/specs/openapi.yaml +1530 -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/internal.js +4 -0
- 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 +82 -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 +3 -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/openapi.ts +943 -0
- package/src/integrations/base/datasourcePlus.ts +3 -0
- package/src/integrations/googlesheets.ts +5 -2
- package/src/integrations/microsoftSqlServer.ts +38 -33
- package/src/integrations/mysql.ts +38 -36
- package/src/integrations/oracle.ts +27 -35
- package/src/integrations/postgres.ts +33 -26
- 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.ab059cf2.js +0 -1352
- package/scripts/proxy/generateProxyConfig.js +0 -70
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import controller from "../../controllers/public/users"
|
|
2
|
+
import Endpoint from "./utils/Endpoint"
|
|
3
|
+
import { nameValidator } from "../utils/validators"
|
|
4
|
+
|
|
5
|
+
const read = [],
|
|
6
|
+
write = []
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @openapi
|
|
10
|
+
* /users:
|
|
11
|
+
* post:
|
|
12
|
+
* summary: Create a user
|
|
13
|
+
* tags:
|
|
14
|
+
* - users
|
|
15
|
+
* requestBody:
|
|
16
|
+
* required: true
|
|
17
|
+
* content:
|
|
18
|
+
* application/json:
|
|
19
|
+
* schema:
|
|
20
|
+
* $ref: '#/components/schemas/user'
|
|
21
|
+
* responses:
|
|
22
|
+
* 200:
|
|
23
|
+
* description: Returns the created user.
|
|
24
|
+
* content:
|
|
25
|
+
* application/json:
|
|
26
|
+
* schema:
|
|
27
|
+
* $ref: '#/components/schemas/userOutput'
|
|
28
|
+
* examples:
|
|
29
|
+
* user:
|
|
30
|
+
* $ref: '#/components/examples/user'
|
|
31
|
+
*/
|
|
32
|
+
write.push(new Endpoint("post", "/users", controller.create))
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @openapi
|
|
36
|
+
* /users/{userId}:
|
|
37
|
+
* put:
|
|
38
|
+
* summary: Update a user
|
|
39
|
+
* tags:
|
|
40
|
+
* - users
|
|
41
|
+
* parameters:
|
|
42
|
+
* - $ref: '#/components/parameters/userId'
|
|
43
|
+
* requestBody:
|
|
44
|
+
* required: true
|
|
45
|
+
* content:
|
|
46
|
+
* application/json:
|
|
47
|
+
* schema:
|
|
48
|
+
* $ref: '#/components/schemas/user'
|
|
49
|
+
* responses:
|
|
50
|
+
* 200:
|
|
51
|
+
* description: Returns the updated user.
|
|
52
|
+
* content:
|
|
53
|
+
* application/json:
|
|
54
|
+
* schema:
|
|
55
|
+
* $ref: '#/components/schemas/userOutput'
|
|
56
|
+
* examples:
|
|
57
|
+
* user:
|
|
58
|
+
* $ref: '#/components/examples/user'
|
|
59
|
+
*/
|
|
60
|
+
write.push(new Endpoint("put", "/users/:userId", controller.update))
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @openapi
|
|
64
|
+
* /users/{userId}:
|
|
65
|
+
* delete:
|
|
66
|
+
* summary: Delete a user
|
|
67
|
+
* tags:
|
|
68
|
+
* - users
|
|
69
|
+
* parameters:
|
|
70
|
+
* - $ref: '#/components/parameters/userId'
|
|
71
|
+
* responses:
|
|
72
|
+
* 200:
|
|
73
|
+
* description: Returns the deleted user.
|
|
74
|
+
* content:
|
|
75
|
+
* application/json:
|
|
76
|
+
* schema:
|
|
77
|
+
* $ref: '#/components/schemas/userOutput'
|
|
78
|
+
* examples:
|
|
79
|
+
* user:
|
|
80
|
+
* $ref: '#/components/examples/user'
|
|
81
|
+
*/
|
|
82
|
+
write.push(new Endpoint("delete", "/users/:userId", controller.destroy))
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @openapi
|
|
86
|
+
* /users/{userId}:
|
|
87
|
+
* get:
|
|
88
|
+
* summary: Retrieve a user
|
|
89
|
+
* tags:
|
|
90
|
+
* - users
|
|
91
|
+
* parameters:
|
|
92
|
+
* - $ref: '#/components/parameters/userId'
|
|
93
|
+
* responses:
|
|
94
|
+
* 200:
|
|
95
|
+
* description: Returns the retrieved user.
|
|
96
|
+
* content:
|
|
97
|
+
* application/json:
|
|
98
|
+
* schema:
|
|
99
|
+
* $ref: '#/components/schemas/userOutput'
|
|
100
|
+
* examples:
|
|
101
|
+
* user:
|
|
102
|
+
* $ref: '#/components/examples/user'
|
|
103
|
+
*/
|
|
104
|
+
read.push(new Endpoint("get", "/users/:userId", controller.read))
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @openapi
|
|
108
|
+
* /users/search:
|
|
109
|
+
* post:
|
|
110
|
+
* summary: Search for users
|
|
111
|
+
* description: Based on user properties (currently only name) search for users.
|
|
112
|
+
* tags:
|
|
113
|
+
* - users
|
|
114
|
+
* requestBody:
|
|
115
|
+
* required: true
|
|
116
|
+
* content:
|
|
117
|
+
* application/json:
|
|
118
|
+
* schema:
|
|
119
|
+
* $ref: '#/components/schemas/nameSearch'
|
|
120
|
+
* responses:
|
|
121
|
+
* 200:
|
|
122
|
+
* description: Returns the found users based on search parameters.
|
|
123
|
+
* content:
|
|
124
|
+
* application/json:
|
|
125
|
+
* schema:
|
|
126
|
+
* type: object
|
|
127
|
+
* required:
|
|
128
|
+
* - data
|
|
129
|
+
* properties:
|
|
130
|
+
* data:
|
|
131
|
+
* type: array
|
|
132
|
+
* items:
|
|
133
|
+
* $ref: '#/components/schemas/user'
|
|
134
|
+
* examples:
|
|
135
|
+
* users:
|
|
136
|
+
* $ref: '#/components/examples/users'
|
|
137
|
+
*/
|
|
138
|
+
read.push(
|
|
139
|
+
new Endpoint("post", "/users/search", controller.search).addMiddleware(
|
|
140
|
+
nameValidator()
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
export default { read, write }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Router from "koa-router"
|
|
2
|
+
|
|
3
|
+
export type CtxFn = (ctx: any, next?: any) => void | Promise<any>
|
|
4
|
+
|
|
5
|
+
class Endpoint {
|
|
6
|
+
method: string
|
|
7
|
+
url: string
|
|
8
|
+
controller: CtxFn
|
|
9
|
+
middlewares: CtxFn[]
|
|
10
|
+
outputMiddlewares: CtxFn[]
|
|
11
|
+
|
|
12
|
+
constructor(method: string, url: string, controller: CtxFn) {
|
|
13
|
+
this.method = method
|
|
14
|
+
this.url = url
|
|
15
|
+
this.controller = controller
|
|
16
|
+
this.middlewares = []
|
|
17
|
+
this.outputMiddlewares = []
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
addMiddleware(middleware: CtxFn) {
|
|
21
|
+
this.middlewares.push(middleware)
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
addOutputMiddleware(middleware: CtxFn) {
|
|
26
|
+
this.outputMiddlewares.push(middleware)
|
|
27
|
+
return this
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
apply(router: Router) {
|
|
31
|
+
const method = this.method,
|
|
32
|
+
url = this.url
|
|
33
|
+
const middlewares = this.middlewares,
|
|
34
|
+
controller = this.controller,
|
|
35
|
+
outputMiddlewares = this.outputMiddlewares
|
|
36
|
+
// need a function to do nothing to stop the execution at the end
|
|
37
|
+
// middlewares are circular so if they always keep calling next, it'll just keep looping
|
|
38
|
+
const complete = () => {}
|
|
39
|
+
const params = [
|
|
40
|
+
url,
|
|
41
|
+
...middlewares,
|
|
42
|
+
controller,
|
|
43
|
+
...outputMiddlewares,
|
|
44
|
+
complete,
|
|
45
|
+
]
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
router[method](...params)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default Endpoint
|
package/src/api/routes/role.js
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
const Router = require("@koa/router")
|
|
2
2
|
const controller = require("../controllers/role")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const {
|
|
7
|
-
BUILTIN_PERMISSION_IDS,
|
|
8
|
-
BUILDER,
|
|
9
|
-
PermissionLevels,
|
|
10
|
-
} = require("@budibase/backend-core/permissions")
|
|
4
|
+
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
5
|
+
const { roleValidator } = require("./utils/validators")
|
|
11
6
|
|
|
12
7
|
const router = Router()
|
|
13
8
|
|
|
14
|
-
function generateValidator() {
|
|
15
|
-
const permLevelArray = Object.values(PermissionLevels)
|
|
16
|
-
// prettier-ignore
|
|
17
|
-
return joiValidator.body(Joi.object({
|
|
18
|
-
_id: Joi.string().optional(),
|
|
19
|
-
_rev: Joi.string().optional(),
|
|
20
|
-
name: Joi.string().required(),
|
|
21
|
-
// this is the base permission ID (for now a built in)
|
|
22
|
-
permissionId: Joi.string().valid(...Object.values(BUILTIN_PERMISSION_IDS)).required(),
|
|
23
|
-
permissions: Joi.object()
|
|
24
|
-
.pattern(/.*/, [Joi.string().valid(...permLevelArray)])
|
|
25
|
-
.optional(),
|
|
26
|
-
inherits: Joi.string().optional(),
|
|
27
|
-
}).unknown(true))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
9
|
router
|
|
31
|
-
.post("/api/roles", authorized(BUILDER),
|
|
10
|
+
.post("/api/roles", authorized(BUILDER), roleValidator(), controller.save)
|
|
32
11
|
.get("/api/roles", authorized(BUILDER), controller.fetch)
|
|
33
12
|
.get("/api/roles/:roleId", authorized(BUILDER), controller.find)
|
|
34
13
|
.delete("/api/roles/:roleId/:rev", authorized(BUILDER), controller.destroy)
|
package/src/api/routes/row.js
CHANGED
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
PermissionLevels,
|
|
11
11
|
PermissionTypes,
|
|
12
12
|
} = require("@budibase/backend-core/permissions")
|
|
13
|
+
const { internalSearchValidator } = require("./utils/validators")
|
|
13
14
|
|
|
14
15
|
const router = Router()
|
|
15
16
|
|
|
@@ -119,8 +120,6 @@ router
|
|
|
119
120
|
* "notEqual": {},
|
|
120
121
|
* "empty": {},
|
|
121
122
|
* "notEmpty": {},
|
|
122
|
-
* "contains": {},
|
|
123
|
-
* "notContains": {}
|
|
124
123
|
* "oneOf": {
|
|
125
124
|
* "columnName": ["value"]
|
|
126
125
|
* }
|
|
@@ -140,6 +139,7 @@ router
|
|
|
140
139
|
*/
|
|
141
140
|
.post(
|
|
142
141
|
"/api/:tableId/search",
|
|
142
|
+
internalSearchValidator(),
|
|
143
143
|
paramResource("tableId"),
|
|
144
144
|
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
|
145
145
|
rowController.search
|
|
@@ -195,6 +195,7 @@ router
|
|
|
195
195
|
"/api/:tableId/rows",
|
|
196
196
|
paramResource("tableId"),
|
|
197
197
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
198
|
+
usage,
|
|
198
199
|
rowController.patch
|
|
199
200
|
)
|
|
200
201
|
/**
|
package/src/api/routes/screen.js
CHANGED
|
@@ -2,40 +2,13 @@ const Router = require("@koa/router")
|
|
|
2
2
|
const controller = require("../controllers/screen")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
4
|
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
5
|
-
const
|
|
6
|
-
const Joi = require("joi")
|
|
5
|
+
const { screenValidator } = require("./utils/validators")
|
|
7
6
|
|
|
8
7
|
const router = Router()
|
|
9
8
|
|
|
10
|
-
function generateSaveValidation() {
|
|
11
|
-
// prettier-ignore
|
|
12
|
-
return joiValidator.body(Joi.object({
|
|
13
|
-
name: Joi.string().required(),
|
|
14
|
-
routing: Joi.object({
|
|
15
|
-
route: Joi.string().required(),
|
|
16
|
-
roleId: Joi.string().required().allow(""),
|
|
17
|
-
}).required().unknown(true),
|
|
18
|
-
props: Joi.object({
|
|
19
|
-
_id: Joi.string().required(),
|
|
20
|
-
_component: Joi.string().required(),
|
|
21
|
-
_children: Joi.array().required(),
|
|
22
|
-
_instanceName: Joi.string().required(),
|
|
23
|
-
_styles: Joi.object().required(),
|
|
24
|
-
type: Joi.string().optional(),
|
|
25
|
-
table: Joi.string().optional(),
|
|
26
|
-
layoutId: Joi.string().optional(),
|
|
27
|
-
}).required().unknown(true),
|
|
28
|
-
}).unknown(true))
|
|
29
|
-
}
|
|
30
|
-
|
|
31
9
|
router
|
|
32
10
|
.get("/api/screens", authorized(BUILDER), controller.fetch)
|
|
33
|
-
.post(
|
|
34
|
-
"/api/screens",
|
|
35
|
-
authorized(BUILDER),
|
|
36
|
-
generateSaveValidation(),
|
|
37
|
-
controller.save
|
|
38
|
-
)
|
|
11
|
+
.post("/api/screens", authorized(BUILDER), screenValidator(), controller.save)
|
|
39
12
|
.delete(
|
|
40
13
|
"/api/screens/:screenId/:screenRev",
|
|
41
14
|
authorized(BUILDER),
|
package/src/api/routes/table.js
CHANGED
|
@@ -7,25 +7,10 @@ const {
|
|
|
7
7
|
PermissionLevels,
|
|
8
8
|
PermissionTypes,
|
|
9
9
|
} = require("@budibase/backend-core/permissions")
|
|
10
|
-
const
|
|
11
|
-
const Joi = require("joi")
|
|
10
|
+
const { tableValidator } = require("./utils/validators")
|
|
12
11
|
|
|
13
12
|
const router = Router()
|
|
14
13
|
|
|
15
|
-
function generateSaveValidator() {
|
|
16
|
-
// prettier-ignore
|
|
17
|
-
return joiValidator.body(Joi.object({
|
|
18
|
-
_id: Joi.string(),
|
|
19
|
-
_rev: Joi.string(),
|
|
20
|
-
type: Joi.string().valid("table", "internal", "external"),
|
|
21
|
-
primaryDisplay: Joi.string(),
|
|
22
|
-
schema: Joi.object().required(),
|
|
23
|
-
name: Joi.string().required(),
|
|
24
|
-
views: Joi.object(),
|
|
25
|
-
dataImport: Joi.object(),
|
|
26
|
-
}).unknown(true))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
14
|
router
|
|
30
15
|
/**
|
|
31
16
|
* @api {get} /api/tables Fetch all tables
|
|
@@ -53,8 +38,8 @@ router
|
|
|
53
38
|
* @apiSuccess {object[]} body The response body will be the table that was found.
|
|
54
39
|
*/
|
|
55
40
|
.get(
|
|
56
|
-
"/api/tables/:
|
|
57
|
-
paramResource("
|
|
41
|
+
"/api/tables/:tableId",
|
|
42
|
+
paramResource("tableId"),
|
|
58
43
|
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
|
59
44
|
tableController.find
|
|
60
45
|
)
|
|
@@ -136,7 +121,7 @@ router
|
|
|
136
121
|
// allows control over updating a table
|
|
137
122
|
bodyResource("_id"),
|
|
138
123
|
authorized(BUILDER),
|
|
139
|
-
|
|
124
|
+
tableValidator(),
|
|
140
125
|
tableController.save
|
|
141
126
|
)
|
|
142
127
|
/**
|
|
@@ -2,6 +2,18 @@ const TestConfig = require("../../../../tests/utilities/TestConfiguration")
|
|
|
2
2
|
const structures = require("../../../../tests/utilities/structures")
|
|
3
3
|
const env = require("../../../../environment")
|
|
4
4
|
|
|
5
|
+
function user() {
|
|
6
|
+
return {
|
|
7
|
+
_id: "user",
|
|
8
|
+
_rev: "rev",
|
|
9
|
+
createdAt: Date.now(),
|
|
10
|
+
email: "test@test.com",
|
|
11
|
+
roles: {},
|
|
12
|
+
tenantId: "default",
|
|
13
|
+
status: "active",
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
jest.mock("../../../../utilities/workerRequests", () => ({
|
|
6
18
|
getGlobalUsers: jest.fn(() => {
|
|
7
19
|
return {
|
|
@@ -13,6 +25,18 @@ jest.mock("../../../../utilities/workerRequests", () => ({
|
|
|
13
25
|
_id: "us_uuid1",
|
|
14
26
|
}
|
|
15
27
|
}),
|
|
28
|
+
allGlobalUsers: jest.fn(() => {
|
|
29
|
+
return [user()]
|
|
30
|
+
}),
|
|
31
|
+
readGlobalUser: jest.fn(() => {
|
|
32
|
+
return user()
|
|
33
|
+
}),
|
|
34
|
+
saveGlobalUser: jest.fn(() => {
|
|
35
|
+
return { _id: "user", _rev: "rev" }
|
|
36
|
+
}),
|
|
37
|
+
deleteGlobalUser: jest.fn(() => {
|
|
38
|
+
return { message: "deleted user" }
|
|
39
|
+
}),
|
|
16
40
|
removeAppFromUserRoles: jest.fn(),
|
|
17
41
|
}))
|
|
18
42
|
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const joiValidator = require("../../../middleware/joi-validator")
|
|
2
|
+
const { DataSourceOperation } = require("../../../constants")
|
|
3
|
+
const { WebhookType } = require("../../../constants")
|
|
4
|
+
const {
|
|
5
|
+
BUILTIN_PERMISSION_IDS,
|
|
6
|
+
PermissionLevels,
|
|
7
|
+
} = require("@budibase/backend-core/permissions")
|
|
8
|
+
const Joi = require("joi")
|
|
9
|
+
|
|
10
|
+
const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("")
|
|
11
|
+
const OPTIONAL_NUMBER = Joi.number().optional().allow(null)
|
|
12
|
+
|
|
13
|
+
exports.tableValidator = () => {
|
|
14
|
+
// prettier-ignore
|
|
15
|
+
return joiValidator.body(Joi.object({
|
|
16
|
+
_id: OPTIONAL_STRING,
|
|
17
|
+
_rev: OPTIONAL_STRING,
|
|
18
|
+
type: OPTIONAL_STRING.valid("table", "internal", "external"),
|
|
19
|
+
primaryDisplay: OPTIONAL_STRING,
|
|
20
|
+
schema: Joi.object().required(),
|
|
21
|
+
name: Joi.string().required(),
|
|
22
|
+
views: Joi.object(),
|
|
23
|
+
dataImport: Joi.object(),
|
|
24
|
+
}).unknown(true))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.nameValidator = () => {
|
|
28
|
+
// prettier-ignore
|
|
29
|
+
return joiValidator.body(Joi.object({
|
|
30
|
+
name: OPTIONAL_STRING,
|
|
31
|
+
}))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.datasourceValidator = () => {
|
|
35
|
+
// prettier-ignore
|
|
36
|
+
return joiValidator.body(Joi.object({
|
|
37
|
+
_id: Joi.string(),
|
|
38
|
+
_rev: Joi.string(),
|
|
39
|
+
type: OPTIONAL_STRING.allow("datasource_plus"),
|
|
40
|
+
relationships: Joi.array().items(Joi.object({
|
|
41
|
+
from: Joi.string().required(),
|
|
42
|
+
to: Joi.string().required(),
|
|
43
|
+
cardinality: Joi.valid("1:N", "1:1", "N:N").required()
|
|
44
|
+
})),
|
|
45
|
+
}).unknown(true))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function filterObject() {
|
|
49
|
+
// prettier-ignore
|
|
50
|
+
return Joi.object({
|
|
51
|
+
string: Joi.object().optional(),
|
|
52
|
+
fuzzy: Joi.object().optional(),
|
|
53
|
+
range: Joi.object().optional(),
|
|
54
|
+
equal: Joi.object().optional(),
|
|
55
|
+
notEqual: Joi.object().optional(),
|
|
56
|
+
empty: Joi.object().optional(),
|
|
57
|
+
notEmpty: Joi.object().optional(),
|
|
58
|
+
oneOf: Joi.object().optional(),
|
|
59
|
+
contains: Joi.object().optional(),
|
|
60
|
+
notContains: Joi.object().optional(),
|
|
61
|
+
}).unknown(true)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.internalSearchValidator = () => {
|
|
65
|
+
// prettier-ignore
|
|
66
|
+
return joiValidator.body(Joi.object({
|
|
67
|
+
tableId: OPTIONAL_STRING,
|
|
68
|
+
query: filterObject(),
|
|
69
|
+
limit: OPTIONAL_NUMBER,
|
|
70
|
+
sort: OPTIONAL_STRING,
|
|
71
|
+
sortOrder: OPTIONAL_STRING,
|
|
72
|
+
sortType: OPTIONAL_STRING,
|
|
73
|
+
paginate: Joi.boolean(),
|
|
74
|
+
bookmark: Joi.alternatives().try(OPTIONAL_STRING, OPTIONAL_NUMBER).optional(),
|
|
75
|
+
}))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
exports.externalSearchValidator = () => {
|
|
79
|
+
return joiValidator.body(
|
|
80
|
+
Joi.object({
|
|
81
|
+
query: filterObject(),
|
|
82
|
+
paginate: Joi.boolean().optional(),
|
|
83
|
+
bookmark: Joi.alternatives()
|
|
84
|
+
.try(OPTIONAL_STRING, OPTIONAL_NUMBER)
|
|
85
|
+
.optional(),
|
|
86
|
+
limit: OPTIONAL_NUMBER,
|
|
87
|
+
sort: Joi.object({
|
|
88
|
+
column: Joi.string(),
|
|
89
|
+
order: OPTIONAL_STRING.valid("ascending", "descending"),
|
|
90
|
+
type: OPTIONAL_STRING.valid("string", "number"),
|
|
91
|
+
}).optional(),
|
|
92
|
+
})
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exports.datasourceQueryValidator = () => {
|
|
97
|
+
// prettier-ignore
|
|
98
|
+
return joiValidator.body(Joi.object({
|
|
99
|
+
endpoint: Joi.object({
|
|
100
|
+
datasourceId: Joi.string().required(),
|
|
101
|
+
operation: Joi.string().required().valid(...Object.values(DataSourceOperation)),
|
|
102
|
+
entityId: Joi.string().required(),
|
|
103
|
+
}).required(),
|
|
104
|
+
resource: Joi.object({
|
|
105
|
+
fields: Joi.array().items(Joi.string()).optional(),
|
|
106
|
+
}).optional(),
|
|
107
|
+
body: Joi.object().optional(),
|
|
108
|
+
sort: Joi.object().optional(),
|
|
109
|
+
filters: filterObject().optional(),
|
|
110
|
+
paginate: Joi.object({
|
|
111
|
+
page: Joi.string().alphanum().optional(),
|
|
112
|
+
limit: Joi.number().optional(),
|
|
113
|
+
}).optional(),
|
|
114
|
+
}))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.webhookValidator = () => {
|
|
118
|
+
// prettier-ignore
|
|
119
|
+
return joiValidator.body(Joi.object({
|
|
120
|
+
live: Joi.bool(),
|
|
121
|
+
_id: OPTIONAL_STRING,
|
|
122
|
+
_rev: OPTIONAL_STRING,
|
|
123
|
+
name: Joi.string().required(),
|
|
124
|
+
bodySchema: Joi.object().optional(),
|
|
125
|
+
action: Joi.object({
|
|
126
|
+
type: Joi.string().required().valid(WebhookType.AUTOMATION),
|
|
127
|
+
target: Joi.string().required(),
|
|
128
|
+
}).required(),
|
|
129
|
+
}).unknown(true))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exports.roleValidator = () => {
|
|
133
|
+
const permLevelArray = Object.values(PermissionLevels)
|
|
134
|
+
// prettier-ignore
|
|
135
|
+
return joiValidator.body(Joi.object({
|
|
136
|
+
_id: OPTIONAL_STRING,
|
|
137
|
+
_rev: OPTIONAL_STRING,
|
|
138
|
+
name: Joi.string().required(),
|
|
139
|
+
// this is the base permission ID (for now a built in)
|
|
140
|
+
permissionId: Joi.string().valid(...Object.values(BUILTIN_PERMISSION_IDS)).required(),
|
|
141
|
+
permissions: Joi.object()
|
|
142
|
+
.pattern(/.*/, [Joi.string().valid(...permLevelArray)])
|
|
143
|
+
.optional(),
|
|
144
|
+
inherits: OPTIONAL_STRING,
|
|
145
|
+
}).unknown(true))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
exports.permissionValidator = () => {
|
|
149
|
+
const permLevelArray = Object.values(PermissionLevels)
|
|
150
|
+
// prettier-ignore
|
|
151
|
+
return joiValidator.params(Joi.object({
|
|
152
|
+
level: Joi.string().valid(...permLevelArray).required(),
|
|
153
|
+
resourceId: Joi.string(),
|
|
154
|
+
roleId: Joi.string(),
|
|
155
|
+
}).unknown(true))
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
exports.screenValidator = () => {
|
|
159
|
+
// prettier-ignore
|
|
160
|
+
return joiValidator.body(Joi.object({
|
|
161
|
+
name: Joi.string().required(),
|
|
162
|
+
routing: Joi.object({
|
|
163
|
+
route: Joi.string().required(),
|
|
164
|
+
roleId: Joi.string().required().allow(""),
|
|
165
|
+
}).required().unknown(true),
|
|
166
|
+
props: Joi.object({
|
|
167
|
+
_id: Joi.string().required(),
|
|
168
|
+
_component: Joi.string().required(),
|
|
169
|
+
_children: Joi.array().required(),
|
|
170
|
+
_instanceName: Joi.string().required(),
|
|
171
|
+
_styles: Joi.object().required(),
|
|
172
|
+
type: OPTIONAL_STRING,
|
|
173
|
+
table: OPTIONAL_STRING,
|
|
174
|
+
layoutId: OPTIONAL_STRING,
|
|
175
|
+
}).required().unknown(true),
|
|
176
|
+
}).unknown(true))
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function generateStepSchema(allowStepTypes) {
|
|
180
|
+
// prettier-ignore
|
|
181
|
+
return Joi.object({
|
|
182
|
+
stepId: Joi.string().required(),
|
|
183
|
+
id: Joi.string().required(),
|
|
184
|
+
description: Joi.string().required(),
|
|
185
|
+
name: Joi.string().required(),
|
|
186
|
+
tagline: Joi.string().required(),
|
|
187
|
+
icon: Joi.string().required(),
|
|
188
|
+
params: Joi.object(),
|
|
189
|
+
args: Joi.object(),
|
|
190
|
+
type: Joi.string().required().valid(...allowStepTypes),
|
|
191
|
+
}).unknown(true)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
exports.automationValidator = (existing = false) => {
|
|
195
|
+
// prettier-ignore
|
|
196
|
+
return joiValidator.body(Joi.object({
|
|
197
|
+
_id: existing ? Joi.string().required() : OPTIONAL_STRING,
|
|
198
|
+
_rev: existing ? Joi.string().required() : OPTIONAL_STRING,
|
|
199
|
+
name: Joi.string().required(),
|
|
200
|
+
type: Joi.string().valid("automation").required(),
|
|
201
|
+
definition: Joi.object({
|
|
202
|
+
steps: Joi.array().required().items(generateStepSchema(["ACTION", "LOGIC"])),
|
|
203
|
+
trigger: generateStepSchema(["TRIGGER"]).allow(null),
|
|
204
|
+
}).required().unknown(true),
|
|
205
|
+
}).unknown(true))
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
exports.applicationValidator = () => {
|
|
209
|
+
// prettier-ignore
|
|
210
|
+
return joiValidator.body(Joi.object({
|
|
211
|
+
_id: OPTIONAL_STRING,
|
|
212
|
+
_rev: OPTIONAL_STRING,
|
|
213
|
+
name: Joi.string().required(),
|
|
214
|
+
url: OPTIONAL_STRING,
|
|
215
|
+
template: Joi.object({
|
|
216
|
+
templateString: OPTIONAL_STRING,
|
|
217
|
+
}).unknown(true),
|
|
218
|
+
}).unknown(true))
|
|
219
|
+
}
|
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
const Router = require("@koa/router")
|
|
2
2
|
const controller = require("../controllers/webhook")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
|
-
const joiValidator = require("../../middleware/joi-validator")
|
|
5
4
|
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
6
|
-
const
|
|
5
|
+
const { webhookValidator } = require("./utils/validators")
|
|
7
6
|
|
|
8
7
|
const router = Router()
|
|
9
8
|
|
|
10
|
-
function generateSaveValidator() {
|
|
11
|
-
// prettier-ignore
|
|
12
|
-
return joiValidator.body(Joi.object({
|
|
13
|
-
live: Joi.bool(),
|
|
14
|
-
_id: Joi.string().optional(),
|
|
15
|
-
_rev: Joi.string().optional(),
|
|
16
|
-
name: Joi.string().required(),
|
|
17
|
-
bodySchema: Joi.object().optional(),
|
|
18
|
-
action: Joi.object({
|
|
19
|
-
type: Joi.string().required().valid(controller.WebhookType.AUTOMATION),
|
|
20
|
-
target: Joi.string().required(),
|
|
21
|
-
}).required(),
|
|
22
|
-
}).unknown(true))
|
|
23
|
-
}
|
|
24
|
-
|
|
25
9
|
router
|
|
26
10
|
.get("/api/webhooks", authorized(BUILDER), controller.fetch)
|
|
27
11
|
.put(
|
|
28
12
|
"/api/webhooks",
|
|
29
13
|
authorized(BUILDER),
|
|
30
|
-
|
|
14
|
+
webhookValidator(),
|
|
31
15
|
controller.save
|
|
32
16
|
)
|
|
33
17
|
.delete("/api/webhooks/:id/:rev", authorized(BUILDER), controller.destroy)
|
|
@@ -16,10 +16,11 @@ exports.FilterConditions = FilterConditions
|
|
|
16
16
|
exports.PrettyFilterConditions = PrettyFilterConditions
|
|
17
17
|
|
|
18
18
|
exports.definition = {
|
|
19
|
-
name: "
|
|
19
|
+
name: "Condition",
|
|
20
20
|
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
|
|
21
21
|
icon: "Branch2",
|
|
22
|
-
description:
|
|
22
|
+
description:
|
|
23
|
+
"Conditionally halt automations which do not meet certain conditions",
|
|
23
24
|
type: "LOGIC",
|
|
24
25
|
internal: true,
|
|
25
26
|
stepId: "FILTER",
|
package/src/automations/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const CouchDB = require("../db")
|
|
|
5
5
|
const { queue } = require("./bullboard")
|
|
6
6
|
const newid = require("../db/newid")
|
|
7
7
|
const { updateEntityMetadata } = require("../utilities")
|
|
8
|
-
const { MetadataTypes } = require("../constants")
|
|
8
|
+
const { MetadataTypes, WebhookType } = require("../constants")
|
|
9
9
|
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
10
10
|
const { cloneDeep } = require("lodash/fp")
|
|
11
11
|
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
|
|
@@ -159,7 +159,7 @@ exports.checkForWebhooks = async ({ oldAuto, newAuto }) => {
|
|
|
159
159
|
request: {
|
|
160
160
|
body: new webhooks.Webhook(
|
|
161
161
|
"Automation webhook",
|
|
162
|
-
|
|
162
|
+
WebhookType.AUTOMATION,
|
|
163
163
|
newAuto._id
|
|
164
164
|
),
|
|
165
165
|
},
|