@budibase/server 1.0.79-alpha.9 → 1.0.79
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__/mysql2/promise.ts +17 -0
- package/__mocks__/node-fetch.ts +0 -1
- package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
- package/builder/assets/index.f28c5d54.js +1352 -0
- package/builder/assets/{vendor.6b00a24f.js → vendor.20f80cec.js} +216 -190
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2327 -2390
- package/coverage/coverage-final.json +137 -138
- 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 +149 -152
- 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 +82 -94
- 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 +44 -47
- 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 +27 -18
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +28 -37
- 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 +109 -19
- 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 +156 -18
- 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 +32 -38
- 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 +58 -16
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +78 -15
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +14 -17
- package/coverage/lcov-report/api/routes/screen.js.html +95 -14
- 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 +62 -17
- 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/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +62 -14
- 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 +9 -12
- 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 +28 -40
- 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 +87 -123
- 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 +74 -89
- 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 +39 -123
- 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 +53 -200
- package/coverage/lcov.info +3233 -3332
- package/dist/api/controllers/application.js +0 -1
- package/dist/api/controllers/row/internal.js +1 -4
- package/dist/api/controllers/table/index.js +1 -2
- package/dist/api/controllers/webhook.js +5 -3
- package/dist/api/index.js +1 -3
- package/dist/api/routes/automation.js +31 -3
- package/dist/api/routes/datasource.js +50 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/permission.js +14 -4
- package/dist/api/routes/role.js +19 -3
- package/dist/api/routes/row.js +4 -3
- package/dist/api/routes/screen.js +23 -2
- package/dist/api/routes/table.js +17 -3
- package/dist/api/routes/tests/utilities/index.js +0 -23
- package/dist/api/routes/webhook.js +17 -2
- 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 +0 -3
- package/dist/db/utils.js +0 -11
- package/dist/integrations/googlesheets.js +0 -3
- package/dist/integrations/microsoftSqlServer.js +29 -35
- package/dist/integrations/mysql.js +70 -58
- package/dist/integrations/oracle.js +19 -14
- package/dist/integrations/postgres.js +28 -34
- package/dist/integrations/utils.js +1 -1
- package/dist/package.json +7 -8
- package/dist/tests/utilities/TestConfiguration.js +8 -25
- package/dist/threads/query.js +8 -33
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +15 -50
- package/package.json +8 -9
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +3 -5
- package/scripts/likeCypress.ts +6 -9
- package/scripts/proxy/generateProxyConfig.js +70 -0
- package/src/api/controllers/application.js +0 -1
- package/src/api/controllers/row/internal.js +0 -4
- package/src/api/controllers/table/index.js +1 -2
- package/src/api/controllers/webhook.js +6 -3
- package/src/api/index.js +1 -4
- package/src/api/routes/automation.js +33 -3
- package/src/api/routes/datasource.js +52 -6
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/permission.js +18 -4
- package/src/api/routes/role.js +24 -3
- package/src/api/routes/row.js +2 -3
- package/src/api/routes/screen.js +29 -2
- package/src/api/routes/table.js +19 -4
- package/src/api/routes/tests/utilities/index.js +0 -24
- package/src/api/routes/webhook.js +18 -2
- package/src/automations/steps/filter.js +2 -3
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +0 -4
- package/src/db/utils.js +0 -12
- package/src/definitions/common.ts +0 -4
- package/src/integrations/base/datasourcePlus.ts +0 -3
- package/src/integrations/googlesheets.ts +2 -5
- package/src/integrations/microsoftSqlServer.ts +33 -38
- package/src/integrations/mysql.ts +77 -72
- package/src/integrations/oracle.ts +35 -27
- package/src/integrations/postgres.ts +26 -33
- package/src/integrations/tests/mysql.spec.js +4 -4
- package/src/integrations/utils.ts +1 -1
- package/src/tests/utilities/TestConfiguration.js +2 -23
- package/src/threads/query.js +9 -37
- package/src/utilities/workerRequests.js +16 -65
- package/builder/assets/index.e6e92f4f.js +0 -1288
- package/coverage/lcov-report/api/routes/utils/index.html +0 -111
- package/coverage/lcov-report/api/routes/utils/validators.js.html +0 -737
- package/dist/api/controllers/public/applications.js +0 -94
- package/dist/api/controllers/public/mapping/applications.js +0 -29
- package/dist/api/controllers/public/mapping/index.js +0 -11
- package/dist/api/controllers/public/mapping/queries.js +0 -36
- package/dist/api/controllers/public/mapping/rows.js +0 -24
- package/dist/api/controllers/public/mapping/tables.js +0 -23
- package/dist/api/controllers/public/mapping/types.js +0 -2
- package/dist/api/controllers/public/mapping/users.js +0 -29
- package/dist/api/controllers/public/queries.js +0 -38
- package/dist/api/controllers/public/rows.js +0 -97
- package/dist/api/controllers/public/tables.js +0 -75
- package/dist/api/controllers/public/users.js +0 -95
- package/dist/api/controllers/public/utils.js +0 -49
- package/dist/api/routes/public/applications.js +0 -141
- package/dist/api/routes/public/index.js +0 -68
- package/dist/api/routes/public/middleware/mapper.js +0 -94
- package/dist/api/routes/public/queries.js +0 -77
- package/dist/api/routes/public/rows.js +0 -229
- package/dist/api/routes/public/tables.js +0 -154
- package/dist/api/routes/public/users.js +0 -137
- package/dist/api/routes/public/utils/Endpoint.js +0 -36
- package/dist/api/routes/utils/validators.js +0 -200
- package/dist/definitions/openapi.js +0 -6
- package/specs/generate.js +0 -83
- package/specs/openapi.json +0 -2222
- package/specs/openapi.yaml +0 -1530
- package/specs/parameters.js +0 -59
- package/specs/resources/application.js +0 -101
- package/specs/resources/index.js +0 -24
- package/specs/resources/misc.js +0 -12
- package/specs/resources/query.js +0 -189
- package/specs/resources/row.js +0 -125
- package/specs/resources/table.js +0 -191
- package/specs/resources/user.js +0 -126
- package/specs/resources/utils/Resource.js +0 -26
- package/specs/resources/utils/index.js +0 -11
- package/specs/security.js +0 -7
- package/src/api/controllers/public/applications.ts +0 -74
- package/src/api/controllers/public/mapping/applications.ts +0 -32
- package/src/api/controllers/public/mapping/index.ts +0 -13
- package/src/api/controllers/public/mapping/queries.ts +0 -39
- package/src/api/controllers/public/mapping/rows.ts +0 -31
- package/src/api/controllers/public/mapping/tables.ts +0 -26
- package/src/api/controllers/public/mapping/types.ts +0 -13
- package/src/api/controllers/public/mapping/users.ts +0 -32
- package/src/api/controllers/public/queries.ts +0 -20
- package/src/api/controllers/public/rows.ts +0 -77
- package/src/api/controllers/public/tables.ts +0 -56
- package/src/api/controllers/public/users.ts +0 -82
- package/src/api/controllers/public/utils.ts +0 -38
- package/src/api/routes/public/applications.ts +0 -156
- package/src/api/routes/public/index.ts +0 -82
- package/src/api/routes/public/middleware/mapper.ts +0 -81
- package/src/api/routes/public/queries.ts +0 -81
- package/src/api/routes/public/rows.ts +0 -242
- package/src/api/routes/public/tables.ts +0 -169
- package/src/api/routes/public/tests/compare.spec.js +0 -184
- package/src/api/routes/public/users.ts +0 -144
- package/src/api/routes/public/utils/Endpoint.ts +0 -51
- package/src/api/routes/utils/validators.js +0 -219
- package/src/definitions/openapi.ts +0 -943
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import controller from "../../controllers/public/tables"
|
|
2
|
-
import Endpoint from "./utils/Endpoint"
|
|
3
|
-
import { tableValidator, nameValidator } from "../utils/validators"
|
|
4
|
-
|
|
5
|
-
const read = [],
|
|
6
|
-
write = []
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @openapi
|
|
10
|
-
* /tables:
|
|
11
|
-
* post:
|
|
12
|
-
* summary: Create a table
|
|
13
|
-
* description: Create a table, this could be internal or external.
|
|
14
|
-
* tags:
|
|
15
|
-
* - tables
|
|
16
|
-
* parameters:
|
|
17
|
-
* - $ref: '#/components/parameters/appId'
|
|
18
|
-
* requestBody:
|
|
19
|
-
* content:
|
|
20
|
-
* application/json:
|
|
21
|
-
* schema:
|
|
22
|
-
* $ref: '#/components/schemas/table'
|
|
23
|
-
* examples:
|
|
24
|
-
* table:
|
|
25
|
-
* $ref: '#/components/examples/table'
|
|
26
|
-
* responses:
|
|
27
|
-
* 200:
|
|
28
|
-
* description: Returns the created table, including the ID which has been generated for it. This can be
|
|
29
|
-
* internal or external data sources.
|
|
30
|
-
* content:
|
|
31
|
-
* application/json:
|
|
32
|
-
* schema:
|
|
33
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
34
|
-
* examples:
|
|
35
|
-
* table:
|
|
36
|
-
* $ref: '#/components/examples/table'
|
|
37
|
-
*/
|
|
38
|
-
write.push(
|
|
39
|
-
new Endpoint("post", "/tables", controller.create).addMiddleware(
|
|
40
|
-
tableValidator()
|
|
41
|
-
)
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @openapi
|
|
46
|
-
* /tables/{tableId}:
|
|
47
|
-
* put:
|
|
48
|
-
* summary: Update a table
|
|
49
|
-
* description: Update a table, this could be internal or external.
|
|
50
|
-
* tags:
|
|
51
|
-
* - tables
|
|
52
|
-
* parameters:
|
|
53
|
-
* - $ref: '#/components/parameters/tableId'
|
|
54
|
-
* - $ref: '#/components/parameters/appId'
|
|
55
|
-
* requestBody:
|
|
56
|
-
* content:
|
|
57
|
-
* application/json:
|
|
58
|
-
* schema:
|
|
59
|
-
* $ref: '#/components/schemas/table'
|
|
60
|
-
* examples:
|
|
61
|
-
* table:
|
|
62
|
-
* $ref: '#/components/examples/table'
|
|
63
|
-
* responses:
|
|
64
|
-
* 200:
|
|
65
|
-
* description: Returns the updated table.
|
|
66
|
-
* content:
|
|
67
|
-
* application/json:
|
|
68
|
-
* schema:
|
|
69
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
70
|
-
* examples:
|
|
71
|
-
* table:
|
|
72
|
-
* $ref: '#/components/examples/table'
|
|
73
|
-
*/
|
|
74
|
-
write.push(
|
|
75
|
-
new Endpoint("put", "/tables/:tableId", controller.update).addMiddleware(
|
|
76
|
-
tableValidator()
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @openapi
|
|
82
|
-
* /tables/{tableId}:
|
|
83
|
-
* delete:
|
|
84
|
-
* summary: Delete a table
|
|
85
|
-
* description: Delete a table, this could be internal or external.
|
|
86
|
-
* tags:
|
|
87
|
-
* - tables
|
|
88
|
-
* parameters:
|
|
89
|
-
* - $ref: '#/components/parameters/tableId'
|
|
90
|
-
* - $ref: '#/components/parameters/appId'
|
|
91
|
-
* responses:
|
|
92
|
-
* 200:
|
|
93
|
-
* description: Returns the deleted table.
|
|
94
|
-
* content:
|
|
95
|
-
* application/json:
|
|
96
|
-
* schema:
|
|
97
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
98
|
-
* examples:
|
|
99
|
-
* table:
|
|
100
|
-
* $ref: '#/components/examples/table'
|
|
101
|
-
*/
|
|
102
|
-
write.push(new Endpoint("delete", "/tables/:tableId", controller.destroy))
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @openapi
|
|
106
|
-
* /tables/{tableId}:
|
|
107
|
-
* get:
|
|
108
|
-
* summary: Retrieve a table
|
|
109
|
-
* description: Lookup a table, this could be internal or external.
|
|
110
|
-
* tags:
|
|
111
|
-
* - tables
|
|
112
|
-
* parameters:
|
|
113
|
-
* - $ref: '#/components/parameters/tableId'
|
|
114
|
-
* - $ref: '#/components/parameters/appId'
|
|
115
|
-
* responses:
|
|
116
|
-
* 200:
|
|
117
|
-
* description: Returns the retrieved table.
|
|
118
|
-
* content:
|
|
119
|
-
* application/json:
|
|
120
|
-
* schema:
|
|
121
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
122
|
-
* examples:
|
|
123
|
-
* table:
|
|
124
|
-
* $ref: '#/components/examples/table'
|
|
125
|
-
*/
|
|
126
|
-
read.push(new Endpoint("get", "/tables/:tableId", controller.read))
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @openapi
|
|
130
|
-
* /tables/search:
|
|
131
|
-
* post:
|
|
132
|
-
* summary: Search for tables
|
|
133
|
-
* description: Based on table properties (currently only name) search for tables. This could be
|
|
134
|
-
* an internal or an external table.
|
|
135
|
-
* tags:
|
|
136
|
-
* - tables
|
|
137
|
-
* parameters:
|
|
138
|
-
* - $ref: '#/components/parameters/appId'
|
|
139
|
-
* requestBody:
|
|
140
|
-
* required: true
|
|
141
|
-
* content:
|
|
142
|
-
* application/json:
|
|
143
|
-
* schema:
|
|
144
|
-
* $ref: '#/components/schemas/nameSearch'
|
|
145
|
-
* responses:
|
|
146
|
-
* 200:
|
|
147
|
-
* description: Returns the found tables, based on the search parameters.
|
|
148
|
-
* content:
|
|
149
|
-
* application/json:
|
|
150
|
-
* schema:
|
|
151
|
-
* type: object
|
|
152
|
-
* required:
|
|
153
|
-
* - data
|
|
154
|
-
* properties:
|
|
155
|
-
* data:
|
|
156
|
-
* type: array
|
|
157
|
-
* items:
|
|
158
|
-
* $ref: '#/components/schemas/table'
|
|
159
|
-
* examples:
|
|
160
|
-
* tables:
|
|
161
|
-
* $ref: '#/components/examples/tables'
|
|
162
|
-
*/
|
|
163
|
-
read.push(
|
|
164
|
-
new Endpoint("post", "/tables/search", controller.search).addMiddleware(
|
|
165
|
-
nameValidator()
|
|
166
|
-
)
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
export default { read, write }
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
const jestOpenAPI = require("jest-openapi").default
|
|
2
|
-
const generateSchema = require("../../../../../specs/generate")
|
|
3
|
-
const setup = require("../../tests/utilities")
|
|
4
|
-
const { checkSlashesInUrl } = require("../../../../utilities")
|
|
5
|
-
|
|
6
|
-
const yamlPath = generateSchema()
|
|
7
|
-
jestOpenAPI(yamlPath)
|
|
8
|
-
|
|
9
|
-
let request = setup.getRequest()
|
|
10
|
-
let config = setup.getConfig()
|
|
11
|
-
let apiKey, table, app
|
|
12
|
-
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
app = await config.init()
|
|
15
|
-
table = await config.updateTable()
|
|
16
|
-
apiKey = await config.generateApiKey()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
afterAll(setup.afterAll)
|
|
20
|
-
|
|
21
|
-
async function makeRequest(method, endpoint, body, appId = config.getAppId()) {
|
|
22
|
-
const extraHeaders = {
|
|
23
|
-
"x-budibase-api-key": apiKey,
|
|
24
|
-
}
|
|
25
|
-
if (appId) {
|
|
26
|
-
extraHeaders["x-budibase-app-id"] = appId
|
|
27
|
-
}
|
|
28
|
-
const req = request
|
|
29
|
-
[method](checkSlashesInUrl(`/api/public/v1/${endpoint}`))
|
|
30
|
-
.set(config.defaultHeaders(extraHeaders))
|
|
31
|
-
if (body) {
|
|
32
|
-
req.send(body)
|
|
33
|
-
}
|
|
34
|
-
const res = await req.expect("Content-Type", /json/).expect(200)
|
|
35
|
-
expect(res.body).toBeDefined()
|
|
36
|
-
return res
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
describe("check the applications endpoints", () => {
|
|
40
|
-
it("should allow retrieving applications through search", async () => {
|
|
41
|
-
const res = await makeRequest("post", "/applications/search")
|
|
42
|
-
expect(res).toSatisfyApiSpec()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it("should allow creating an application", async () => {
|
|
46
|
-
const res = await makeRequest("post", "/applications", {
|
|
47
|
-
name: "new App"
|
|
48
|
-
}, null)
|
|
49
|
-
expect(res).toSatisfyApiSpec()
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it("should allow updating an application", async () => {
|
|
53
|
-
const app = config.getApp()
|
|
54
|
-
const appId = config.getAppId()
|
|
55
|
-
const res = await makeRequest("put", `/applications/${appId}`, {
|
|
56
|
-
...app,
|
|
57
|
-
name: "updated app name",
|
|
58
|
-
}, appId)
|
|
59
|
-
expect(res).toSatisfyApiSpec()
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it("should allow retrieving an application", async () => {
|
|
63
|
-
const res = await makeRequest("get", `/applications/${config.getAppId()}`)
|
|
64
|
-
expect(res).toSatisfyApiSpec()
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it("should allow deleting an application", async () => {
|
|
68
|
-
const res = await makeRequest("delete", `/applications/${config.getAppId()}`)
|
|
69
|
-
expect(res).toSatisfyApiSpec()
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
describe("check the tables endpoints", () => {
|
|
74
|
-
it("should allow retrieving tables through search", async () => {
|
|
75
|
-
await config.createApp("new app 1")
|
|
76
|
-
table = await config.updateTable()
|
|
77
|
-
const res = await makeRequest("post", "/tables/search")
|
|
78
|
-
expect(res).toSatisfyApiSpec()
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it("should allow creating a table", async () => {
|
|
82
|
-
const res = await makeRequest("post", "/tables", {
|
|
83
|
-
name: "table name",
|
|
84
|
-
primaryDisplay: "column1",
|
|
85
|
-
schema: {
|
|
86
|
-
column1: {
|
|
87
|
-
type: "string",
|
|
88
|
-
constraints: {},
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
expect(res).toSatisfyApiSpec()
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it("should allow updating a table", async () => {
|
|
96
|
-
const updated = { ...table, _rev: undefined, name: "new name" }
|
|
97
|
-
const res = await makeRequest("put", `/tables/${table._id}`, updated)
|
|
98
|
-
expect(res).toSatisfyApiSpec()
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it("should allow retrieving a table", async () => {
|
|
102
|
-
const res = await makeRequest("get", `/tables/${table._id}`)
|
|
103
|
-
expect(res).toSatisfyApiSpec()
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it("should allow deleting a table", async () => {
|
|
107
|
-
const res = await makeRequest("delete", `/tables/${table._id}`)
|
|
108
|
-
expect(res).toSatisfyApiSpec()
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
describe("check the rows endpoints", () => {
|
|
113
|
-
let row
|
|
114
|
-
it("should allow retrieving rows through search", async () => {
|
|
115
|
-
table = await config.updateTable()
|
|
116
|
-
const res = await makeRequest("post", `/tables/${table._id}/rows/search`, {
|
|
117
|
-
query: {
|
|
118
|
-
},
|
|
119
|
-
})
|
|
120
|
-
expect(res).toSatisfyApiSpec()
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it("should allow creating a row", async () => {
|
|
124
|
-
const res = await makeRequest("post", `/tables/${table._id}/rows`, {
|
|
125
|
-
name: "test row",
|
|
126
|
-
})
|
|
127
|
-
expect(res).toSatisfyApiSpec()
|
|
128
|
-
row = res.body.data
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it("should allow updating a row", async () => {
|
|
132
|
-
const res = await makeRequest("put", `/tables/${table._id}/rows/${row._id}`, {
|
|
133
|
-
name: "test row updated",
|
|
134
|
-
})
|
|
135
|
-
expect(res).toSatisfyApiSpec()
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it("should allow retrieving a row", async () => {
|
|
139
|
-
const res = await makeRequest("get", `/tables/${table._id}/rows/${row._id}`)
|
|
140
|
-
expect(res).toSatisfyApiSpec()
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
it("should allow deleting a row", async () => {
|
|
144
|
-
const res = await makeRequest("delete", `/tables/${table._id}/rows/${row._id}`)
|
|
145
|
-
expect(res).toSatisfyApiSpec()
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
describe("check the users endpoints", () => {
|
|
150
|
-
let user
|
|
151
|
-
it("should allow retrieving users through search", async () => {
|
|
152
|
-
user = await config.createUser()
|
|
153
|
-
const res = await makeRequest("post", "/users/search")
|
|
154
|
-
expect(res).toSatisfyApiSpec()
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
it("should allow creating a user", async () => {
|
|
158
|
-
const res = await makeRequest("post", "/users")
|
|
159
|
-
expect(res).toSatisfyApiSpec()
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it("should allow updating a user", async () => {
|
|
163
|
-
const res = await makeRequest("put", `/users/${user._id}`)
|
|
164
|
-
expect(res).toSatisfyApiSpec()
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
it("should allow retrieving a user", async () => {
|
|
168
|
-
const res = await makeRequest("get", `/users/${user._id}`)
|
|
169
|
-
expect(res).toSatisfyApiSpec()
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
it("should allow deleting a user", async () => {
|
|
173
|
-
const res = await makeRequest("delete", `/users/${user._id}`)
|
|
174
|
-
expect(res).toSatisfyApiSpec()
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
describe("check the queries endpoints", () => {
|
|
179
|
-
it("should allow retrieving queries through search", async () => {
|
|
180
|
-
const res = await makeRequest("post", "/queries/search")
|
|
181
|
-
expect(res).toSatisfyApiSpec()
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
|
|
@@ -1,144 +0,0 @@
|
|
|
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 }
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|