@budibase/server 1.0.80-alpha.1 → 1.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/node-fetch.ts +0 -1
- package/builder/assets/index.22a39cc9.js +1352 -0
- package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
- package/builder/assets/{vendor.a7c6ad0a.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/environment.js +0 -1
- package/dist/integrations/googlesheets.js +0 -3
- package/dist/integrations/microsoftSqlServer.js +29 -35
- package/dist/integrations/mysql.js +0 -3
- package/dist/integrations/oracle.js +19 -14
- package/dist/integrations/postgres.js +28 -34
- package/dist/package.json +7 -11
- 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 -12
- 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/ExternalRequest.ts +1 -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/environment.js +0 -1
- 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 +0 -4
- package/src/integrations/oracle.ts +35 -27
- package/src/integrations/postgres.ts +26 -33
- 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.c0b657be.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 -101
- 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 -118
- 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,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const tables_1 = __importDefault(require("../../controllers/public/tables"));
|
|
7
|
-
const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
|
|
8
|
-
const validators_1 = require("../utils/validators");
|
|
9
|
-
const read = [], write = [];
|
|
10
|
-
/**
|
|
11
|
-
* @openapi
|
|
12
|
-
* /tables:
|
|
13
|
-
* post:
|
|
14
|
-
* summary: Create a table
|
|
15
|
-
* description: Create a table, this could be internal or external.
|
|
16
|
-
* tags:
|
|
17
|
-
* - tables
|
|
18
|
-
* parameters:
|
|
19
|
-
* - $ref: '#/components/parameters/appId'
|
|
20
|
-
* requestBody:
|
|
21
|
-
* content:
|
|
22
|
-
* application/json:
|
|
23
|
-
* schema:
|
|
24
|
-
* $ref: '#/components/schemas/table'
|
|
25
|
-
* examples:
|
|
26
|
-
* table:
|
|
27
|
-
* $ref: '#/components/examples/table'
|
|
28
|
-
* responses:
|
|
29
|
-
* 200:
|
|
30
|
-
* description: Returns the created table, including the ID which has been generated for it. This can be
|
|
31
|
-
* internal or external data sources.
|
|
32
|
-
* content:
|
|
33
|
-
* application/json:
|
|
34
|
-
* schema:
|
|
35
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
36
|
-
* examples:
|
|
37
|
-
* table:
|
|
38
|
-
* $ref: '#/components/examples/table'
|
|
39
|
-
*/
|
|
40
|
-
write.push(new Endpoint_1.default("post", "/tables", tables_1.default.create).addMiddleware(validators_1.tableValidator()));
|
|
41
|
-
/**
|
|
42
|
-
* @openapi
|
|
43
|
-
* /tables/{tableId}:
|
|
44
|
-
* put:
|
|
45
|
-
* summary: Update a table
|
|
46
|
-
* description: Update a table, this could be internal or external.
|
|
47
|
-
* tags:
|
|
48
|
-
* - tables
|
|
49
|
-
* parameters:
|
|
50
|
-
* - $ref: '#/components/parameters/tableId'
|
|
51
|
-
* - $ref: '#/components/parameters/appId'
|
|
52
|
-
* requestBody:
|
|
53
|
-
* content:
|
|
54
|
-
* application/json:
|
|
55
|
-
* schema:
|
|
56
|
-
* $ref: '#/components/schemas/table'
|
|
57
|
-
* examples:
|
|
58
|
-
* table:
|
|
59
|
-
* $ref: '#/components/examples/table'
|
|
60
|
-
* responses:
|
|
61
|
-
* 200:
|
|
62
|
-
* description: Returns the updated table.
|
|
63
|
-
* content:
|
|
64
|
-
* application/json:
|
|
65
|
-
* schema:
|
|
66
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
67
|
-
* examples:
|
|
68
|
-
* table:
|
|
69
|
-
* $ref: '#/components/examples/table'
|
|
70
|
-
*/
|
|
71
|
-
write.push(new Endpoint_1.default("put", "/tables/:tableId", tables_1.default.update).addMiddleware(validators_1.tableValidator()));
|
|
72
|
-
/**
|
|
73
|
-
* @openapi
|
|
74
|
-
* /tables/{tableId}:
|
|
75
|
-
* delete:
|
|
76
|
-
* summary: Delete a table
|
|
77
|
-
* description: Delete a table, this could be internal or external.
|
|
78
|
-
* tags:
|
|
79
|
-
* - tables
|
|
80
|
-
* parameters:
|
|
81
|
-
* - $ref: '#/components/parameters/tableId'
|
|
82
|
-
* - $ref: '#/components/parameters/appId'
|
|
83
|
-
* responses:
|
|
84
|
-
* 200:
|
|
85
|
-
* description: Returns the deleted table.
|
|
86
|
-
* content:
|
|
87
|
-
* application/json:
|
|
88
|
-
* schema:
|
|
89
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
90
|
-
* examples:
|
|
91
|
-
* table:
|
|
92
|
-
* $ref: '#/components/examples/table'
|
|
93
|
-
*/
|
|
94
|
-
write.push(new Endpoint_1.default("delete", "/tables/:tableId", tables_1.default.destroy));
|
|
95
|
-
/**
|
|
96
|
-
* @openapi
|
|
97
|
-
* /tables/{tableId}:
|
|
98
|
-
* get:
|
|
99
|
-
* summary: Retrieve a table
|
|
100
|
-
* description: Lookup a table, this could be internal or external.
|
|
101
|
-
* tags:
|
|
102
|
-
* - tables
|
|
103
|
-
* parameters:
|
|
104
|
-
* - $ref: '#/components/parameters/tableId'
|
|
105
|
-
* - $ref: '#/components/parameters/appId'
|
|
106
|
-
* responses:
|
|
107
|
-
* 200:
|
|
108
|
-
* description: Returns the retrieved table.
|
|
109
|
-
* content:
|
|
110
|
-
* application/json:
|
|
111
|
-
* schema:
|
|
112
|
-
* $ref: '#/components/schemas/tableOutput'
|
|
113
|
-
* examples:
|
|
114
|
-
* table:
|
|
115
|
-
* $ref: '#/components/examples/table'
|
|
116
|
-
*/
|
|
117
|
-
read.push(new Endpoint_1.default("get", "/tables/:tableId", tables_1.default.read));
|
|
118
|
-
/**
|
|
119
|
-
* @openapi
|
|
120
|
-
* /tables/search:
|
|
121
|
-
* post:
|
|
122
|
-
* summary: Search for tables
|
|
123
|
-
* description: Based on table properties (currently only name) search for tables. This could be
|
|
124
|
-
* an internal or an external table.
|
|
125
|
-
* tags:
|
|
126
|
-
* - tables
|
|
127
|
-
* parameters:
|
|
128
|
-
* - $ref: '#/components/parameters/appId'
|
|
129
|
-
* requestBody:
|
|
130
|
-
* required: true
|
|
131
|
-
* content:
|
|
132
|
-
* application/json:
|
|
133
|
-
* schema:
|
|
134
|
-
* $ref: '#/components/schemas/nameSearch'
|
|
135
|
-
* responses:
|
|
136
|
-
* 200:
|
|
137
|
-
* description: Returns the found tables, based on the search parameters.
|
|
138
|
-
* content:
|
|
139
|
-
* application/json:
|
|
140
|
-
* schema:
|
|
141
|
-
* type: object
|
|
142
|
-
* required:
|
|
143
|
-
* - data
|
|
144
|
-
* properties:
|
|
145
|
-
* data:
|
|
146
|
-
* type: array
|
|
147
|
-
* items:
|
|
148
|
-
* $ref: '#/components/schemas/table'
|
|
149
|
-
* examples:
|
|
150
|
-
* tables:
|
|
151
|
-
* $ref: '#/components/examples/tables'
|
|
152
|
-
*/
|
|
153
|
-
read.push(new Endpoint_1.default("post", "/tables/search", tables_1.default.search).addMiddleware(validators_1.nameValidator()));
|
|
154
|
-
exports.default = { read, write };
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const users_1 = __importDefault(require("../../controllers/public/users"));
|
|
7
|
-
const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
|
|
8
|
-
const validators_1 = require("../utils/validators");
|
|
9
|
-
const read = [], write = [];
|
|
10
|
-
/**
|
|
11
|
-
* @openapi
|
|
12
|
-
* /users:
|
|
13
|
-
* post:
|
|
14
|
-
* summary: Create a user
|
|
15
|
-
* tags:
|
|
16
|
-
* - users
|
|
17
|
-
* requestBody:
|
|
18
|
-
* required: true
|
|
19
|
-
* content:
|
|
20
|
-
* application/json:
|
|
21
|
-
* schema:
|
|
22
|
-
* $ref: '#/components/schemas/user'
|
|
23
|
-
* responses:
|
|
24
|
-
* 200:
|
|
25
|
-
* description: Returns the created user.
|
|
26
|
-
* content:
|
|
27
|
-
* application/json:
|
|
28
|
-
* schema:
|
|
29
|
-
* $ref: '#/components/schemas/userOutput'
|
|
30
|
-
* examples:
|
|
31
|
-
* user:
|
|
32
|
-
* $ref: '#/components/examples/user'
|
|
33
|
-
*/
|
|
34
|
-
write.push(new Endpoint_1.default("post", "/users", users_1.default.create));
|
|
35
|
-
/**
|
|
36
|
-
* @openapi
|
|
37
|
-
* /users/{userId}:
|
|
38
|
-
* put:
|
|
39
|
-
* summary: Update a user
|
|
40
|
-
* tags:
|
|
41
|
-
* - users
|
|
42
|
-
* parameters:
|
|
43
|
-
* - $ref: '#/components/parameters/userId'
|
|
44
|
-
* requestBody:
|
|
45
|
-
* required: true
|
|
46
|
-
* content:
|
|
47
|
-
* application/json:
|
|
48
|
-
* schema:
|
|
49
|
-
* $ref: '#/components/schemas/user'
|
|
50
|
-
* responses:
|
|
51
|
-
* 200:
|
|
52
|
-
* description: Returns the updated user.
|
|
53
|
-
* content:
|
|
54
|
-
* application/json:
|
|
55
|
-
* schema:
|
|
56
|
-
* $ref: '#/components/schemas/userOutput'
|
|
57
|
-
* examples:
|
|
58
|
-
* user:
|
|
59
|
-
* $ref: '#/components/examples/user'
|
|
60
|
-
*/
|
|
61
|
-
write.push(new Endpoint_1.default("put", "/users/:userId", users_1.default.update));
|
|
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_1.default("delete", "/users/:userId", users_1.default.destroy));
|
|
83
|
-
/**
|
|
84
|
-
* @openapi
|
|
85
|
-
* /users/{userId}:
|
|
86
|
-
* get:
|
|
87
|
-
* summary: Retrieve a user
|
|
88
|
-
* tags:
|
|
89
|
-
* - users
|
|
90
|
-
* parameters:
|
|
91
|
-
* - $ref: '#/components/parameters/userId'
|
|
92
|
-
* responses:
|
|
93
|
-
* 200:
|
|
94
|
-
* description: Returns the retrieved user.
|
|
95
|
-
* content:
|
|
96
|
-
* application/json:
|
|
97
|
-
* schema:
|
|
98
|
-
* $ref: '#/components/schemas/userOutput'
|
|
99
|
-
* examples:
|
|
100
|
-
* user:
|
|
101
|
-
* $ref: '#/components/examples/user'
|
|
102
|
-
*/
|
|
103
|
-
read.push(new Endpoint_1.default("get", "/users/:userId", users_1.default.read));
|
|
104
|
-
/**
|
|
105
|
-
* @openapi
|
|
106
|
-
* /users/search:
|
|
107
|
-
* post:
|
|
108
|
-
* summary: Search for users
|
|
109
|
-
* description: Based on user properties (currently only name) search for users.
|
|
110
|
-
* tags:
|
|
111
|
-
* - users
|
|
112
|
-
* requestBody:
|
|
113
|
-
* required: true
|
|
114
|
-
* content:
|
|
115
|
-
* application/json:
|
|
116
|
-
* schema:
|
|
117
|
-
* $ref: '#/components/schemas/nameSearch'
|
|
118
|
-
* responses:
|
|
119
|
-
* 200:
|
|
120
|
-
* description: Returns the found users based on search parameters.
|
|
121
|
-
* content:
|
|
122
|
-
* application/json:
|
|
123
|
-
* schema:
|
|
124
|
-
* type: object
|
|
125
|
-
* required:
|
|
126
|
-
* - data
|
|
127
|
-
* properties:
|
|
128
|
-
* data:
|
|
129
|
-
* type: array
|
|
130
|
-
* items:
|
|
131
|
-
* $ref: '#/components/schemas/user'
|
|
132
|
-
* examples:
|
|
133
|
-
* users:
|
|
134
|
-
* $ref: '#/components/examples/users'
|
|
135
|
-
*/
|
|
136
|
-
read.push(new Endpoint_1.default("post", "/users/search", users_1.default.search).addMiddleware(validators_1.nameValidator()));
|
|
137
|
-
exports.default = { read, write };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class Endpoint {
|
|
4
|
-
constructor(method, url, controller) {
|
|
5
|
-
this.method = method;
|
|
6
|
-
this.url = url;
|
|
7
|
-
this.controller = controller;
|
|
8
|
-
this.middlewares = [];
|
|
9
|
-
this.outputMiddlewares = [];
|
|
10
|
-
}
|
|
11
|
-
addMiddleware(middleware) {
|
|
12
|
-
this.middlewares.push(middleware);
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
addOutputMiddleware(middleware) {
|
|
16
|
-
this.outputMiddlewares.push(middleware);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
apply(router) {
|
|
20
|
-
const method = this.method, url = this.url;
|
|
21
|
-
const middlewares = this.middlewares, controller = this.controller, outputMiddlewares = this.outputMiddlewares;
|
|
22
|
-
// need a function to do nothing to stop the execution at the end
|
|
23
|
-
// middlewares are circular so if they always keep calling next, it'll just keep looping
|
|
24
|
-
const complete = () => { };
|
|
25
|
-
const params = [
|
|
26
|
-
url,
|
|
27
|
-
...middlewares,
|
|
28
|
-
controller,
|
|
29
|
-
...outputMiddlewares,
|
|
30
|
-
complete,
|
|
31
|
-
];
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
router[method](...params);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.default = Endpoint;
|
|
@@ -1,200 +0,0 @@
|
|
|
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
|
-
};
|
package/specs/generate.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const swaggerJsdoc = require("swagger-jsdoc")
|
|
2
|
-
const { join } = require("path")
|
|
3
|
-
const { writeFileSync } = require("fs")
|
|
4
|
-
const { examples, schemas } = require("./resources")
|
|
5
|
-
const parameters = require("./parameters")
|
|
6
|
-
const security = require("./security")
|
|
7
|
-
|
|
8
|
-
const VARIABLES = {}
|
|
9
|
-
|
|
10
|
-
const options = {
|
|
11
|
-
definition: {
|
|
12
|
-
openapi: "3.0.0",
|
|
13
|
-
info: {
|
|
14
|
-
title: "Budibase API",
|
|
15
|
-
description: "The public API for Budibase apps and its services.",
|
|
16
|
-
version: "1.0.0",
|
|
17
|
-
},
|
|
18
|
-
servers: [
|
|
19
|
-
{
|
|
20
|
-
url: "http://budibase.app/api/public/v1",
|
|
21
|
-
description: "Budibase Cloud API",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
url: "{protocol}://{hostname}:10000/api/public/v1",
|
|
25
|
-
description: "Budibase self hosted API",
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
components: {
|
|
29
|
-
parameters: {
|
|
30
|
-
...parameters,
|
|
31
|
-
},
|
|
32
|
-
examples: {
|
|
33
|
-
...examples,
|
|
34
|
-
},
|
|
35
|
-
securitySchemes: {
|
|
36
|
-
...security,
|
|
37
|
-
},
|
|
38
|
-
schemas: {
|
|
39
|
-
...schemas,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
security: [
|
|
43
|
-
{
|
|
44
|
-
ApiKeyAuth: [],
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
format: ".json",
|
|
49
|
-
apis: [join(__dirname, "..", "src", "api", "routes", "public", "*.ts")],
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function writeFile(output, filename) {
|
|
53
|
-
try {
|
|
54
|
-
const path = join(__dirname, filename)
|
|
55
|
-
let spec = output
|
|
56
|
-
if (filename.endsWith("json")) {
|
|
57
|
-
spec = JSON.stringify(output, null, 2)
|
|
58
|
-
}
|
|
59
|
-
// input the static variables
|
|
60
|
-
for (let [key, replacement] of Object.entries(VARIABLES)) {
|
|
61
|
-
spec = spec.replace(new RegExp(`{${key}}`, "g"), replacement)
|
|
62
|
-
}
|
|
63
|
-
writeFileSync(path, spec)
|
|
64
|
-
console.log(`Wrote spec to ${path}`)
|
|
65
|
-
return path
|
|
66
|
-
} catch (err) {
|
|
67
|
-
console.error(err)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function run() {
|
|
72
|
-
const outputJSON = swaggerJsdoc(options)
|
|
73
|
-
options.format = ".yaml"
|
|
74
|
-
const outputYAML = swaggerJsdoc(options)
|
|
75
|
-
writeFile(outputJSON, "openapi.json")
|
|
76
|
-
return writeFile(outputYAML, "openapi.yaml")
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (require.main === module) {
|
|
80
|
-
run()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
module.exports = run
|