@budibase/server 2.6.19-alpha.3 → 2.6.19-alpha.31
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/.dockerignore +7 -6
- package/Dockerfile +16 -8
- package/builder/assets/{index.71388c79.js → index.3dd3d237.js} +435 -428
- package/builder/assets/{index.07382a47.css → index.8469b14c.css} +2 -2
- package/builder/index.html +2 -2
- package/client/manifest.json +5229 -0
- package/dist/automation.js +32436 -0
- package/dist/automation.js.map +7 -0
- package/dist/index.js +44735 -13
- package/dist/index.js.map +7 -0
- package/dist/query.js +24367 -0
- package/dist/query.js.map +7 -0
- package/jest.config.ts +3 -0
- package/nodemon.json +1 -1
- package/package.json +32 -13
- package/pm2.config.js +1 -1
- package/scripts/build.js +48 -0
- package/src/api/controllers/application.ts +21 -22
- package/src/api/controllers/automation.ts +37 -9
- package/src/api/controllers/datasource.ts +20 -0
- package/src/api/controllers/row/index.ts +15 -22
- package/src/api/controllers/row/internal.ts +1 -1
- package/src/api/controllers/row/utils.ts +12 -0
- package/src/api/controllers/static/index.ts +3 -3
- package/src/api/controllers/table/index.ts +3 -0
- package/src/api/controllers/table/internal.ts +2 -6
- package/src/api/controllers/table/utils.ts +32 -1
- package/src/api/controllers/view/index.ts +5 -5
- package/src/api/controllers/webhook.ts +33 -9
- package/src/api/routes/application.ts +5 -0
- package/src/api/routes/automation.ts +0 -1
- package/src/api/routes/datasource.ts +5 -0
- package/src/api/routes/static.ts +3 -1
- package/src/api/routes/tests/{automation.spec.js → automation.spec.ts} +106 -31
- package/src/api/routes/tests/datasource.spec.ts +1 -1
- package/src/api/routes/tests/{webhook.spec.js → webhook.spec.ts} +33 -11
- package/src/app.ts +0 -1
- package/src/automations/actions.ts +8 -0
- package/src/automations/logging/index.ts +21 -0
- package/src/automations/steps/bash.ts +4 -0
- package/src/automations/steps/collect.ts +58 -0
- package/src/automations/steps/createRow.ts +4 -0
- package/src/automations/steps/delay.ts +1 -0
- package/src/automations/steps/deleteRow.ts +4 -0
- package/src/automations/steps/discord.ts +4 -0
- package/src/automations/steps/executeQuery.ts +4 -0
- package/src/automations/steps/executeScript.ts +4 -0
- package/src/automations/steps/filter.ts +1 -0
- package/src/automations/steps/loop.ts +1 -0
- package/src/automations/steps/make.ts +4 -0
- package/src/automations/steps/openai.ts +106 -0
- package/src/automations/steps/outgoingWebhook.ts +4 -0
- package/src/automations/steps/queryRows.ts +4 -0
- package/src/automations/steps/sendSmtpEmail.ts +4 -0
- package/src/automations/steps/serverLog.ts +4 -0
- package/src/automations/steps/slack.ts +4 -0
- package/src/automations/steps/updateRow.ts +4 -0
- package/src/automations/steps/zapier.ts +4 -0
- package/src/automations/tests/openai.spec.ts +86 -0
- package/src/automations/triggers.ts +3 -2
- package/src/constants/index.ts +17 -16
- package/src/db/inMemoryView.ts +1 -0
- package/src/environment.ts +3 -0
- package/src/integration-test/postgres.spec.ts +47 -4
- package/src/integrations/airtable.ts +3 -1
- package/src/integrations/arangodb.ts +3 -1
- package/src/integrations/base/sqlTable.ts +0 -1
- package/src/integrations/couchdb.ts +3 -1
- package/src/integrations/dynamodb.ts +3 -1
- package/src/integrations/elasticsearch.ts +3 -1
- package/src/integrations/firebase.ts +3 -1
- package/src/integrations/googlesheets.ts +11 -3
- package/src/integrations/microsoftSqlServer.ts +18 -2
- package/src/integrations/mongodb.ts +3 -1
- package/src/integrations/mysql.ts +27 -11
- package/src/integrations/oracle.ts +11 -1
- package/src/integrations/postgres.ts +15 -1
- package/src/integrations/redis.ts +3 -1
- package/src/integrations/s3.ts +3 -1
- package/src/integrations/snowflake.ts +3 -1
- package/src/integrations/tests/googlesheets.spec.ts +41 -9
- package/src/middleware/builder.ts +4 -5
- package/src/sdk/app/automations/index.ts +2 -0
- package/src/sdk/app/automations/utils.ts +7 -0
- package/src/startup.ts +2 -0
- package/src/tests/utilities/TestConfiguration.ts +4 -2
- package/src/tests/utilities/structures.ts +42 -0
- package/src/threads/automation.ts +78 -22
- package/src/threads/index.ts +9 -3
- package/src/threads/utils.ts +2 -0
- package/src/utilities/fileSystem/app.ts +1 -1
- package/src/utilities/fileSystem/clientLibrary.ts +8 -3
- package/src/utilities/fileSystem/filesystem.ts +3 -1
- package/src/utilities/redis.ts +19 -2
- package/src/websockets/builder.ts +69 -0
- package/src/websockets/grid.ts +25 -7
- package/src/websockets/index.ts +5 -2
- package/src/websockets/websocket.ts +20 -4
- package/tsconfig.build.json +9 -1
- package/tsconfig.json +1 -14
- package/dist/api/controllers/analytics.js +0 -46
- package/dist/api/controllers/apikeys.js +0 -72
- package/dist/api/controllers/application.js +0 -574
- package/dist/api/controllers/auth.js +0 -80
- package/dist/api/controllers/automation.js +0 -303
- package/dist/api/controllers/backup.js +0 -37
- package/dist/api/controllers/component.js +0 -59
- package/dist/api/controllers/datasource.js +0 -337
- package/dist/api/controllers/deploy/Deployment.js +0 -53
- package/dist/api/controllers/deploy/index.js +0 -198
- package/dist/api/controllers/dev.js +0 -146
- package/dist/api/controllers/integration.js +0 -28
- package/dist/api/controllers/layout.js +0 -49
- package/dist/api/controllers/metadata.js +0 -63
- package/dist/api/controllers/migrations.js +0 -29
- package/dist/api/controllers/ops.js +0 -40
- package/dist/api/controllers/permission.js +0 -162
- package/dist/api/controllers/plugin/file.js +0 -24
- package/dist/api/controllers/plugin/github.js +0 -69
- package/dist/api/controllers/plugin/index.js +0 -112
- package/dist/api/controllers/plugin/npm.js +0 -58
- package/dist/api/controllers/plugin/uploaders.js +0 -11
- package/dist/api/controllers/plugin/url.js +0 -24
- package/dist/api/controllers/plugin/utils.js +0 -27
- package/dist/api/controllers/public/applications.js +0 -146
- 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/metrics.js +0 -113
- package/dist/api/controllers/public/queries.js +0 -58
- package/dist/api/controllers/public/rows.js +0 -120
- package/dist/api/controllers/public/tables.js +0 -95
- package/dist/api/controllers/public/users.js +0 -93
- package/dist/api/controllers/public/utils.js +0 -56
- package/dist/api/controllers/query/import/index.js +0 -87
- package/dist/api/controllers/query/import/sources/base/index.js +0 -75
- package/dist/api/controllers/query/import/sources/base/openapi.js +0 -42
- package/dist/api/controllers/query/import/sources/curl.js +0 -99
- package/dist/api/controllers/query/import/sources/openapi2.js +0 -145
- package/dist/api/controllers/query/import/sources/openapi3.js +0 -177
- package/dist/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +0 -253
- package/dist/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +0 -1054
- package/dist/api/controllers/query/import/sources/tests/openapi3/data/crud/crud.json +0 -253
- package/dist/api/controllers/query/import/sources/tests/openapi3/data/petstore/petstore.json +0 -1225
- package/dist/api/controllers/query/index.js +0 -299
- package/dist/api/controllers/query/validation.js +0 -53
- package/dist/api/controllers/role.js +0 -109
- package/dist/api/controllers/routing.js +0 -105
- package/dist/api/controllers/row/ExternalRequest.js +0 -683
- package/dist/api/controllers/row/external.js +0 -339
- package/dist/api/controllers/row/index.js +0 -203
- package/dist/api/controllers/row/internal.js +0 -509
- package/dist/api/controllers/row/internalSearch.js +0 -28
- package/dist/api/controllers/row/staticFormula.js +0 -165
- package/dist/api/controllers/row/utils.js +0 -183
- package/dist/api/controllers/screen.js +0 -110
- package/dist/api/controllers/script.js +0 -30
- package/dist/api/controllers/static/index.js +0 -268
- package/dist/api/controllers/table/bulkFormula.js +0 -173
- package/dist/api/controllers/table/external.js +0 -279
- package/dist/api/controllers/table/index.js +0 -179
- package/dist/api/controllers/table/internal.js +0 -197
- package/dist/api/controllers/table/utils.js +0 -379
- package/dist/api/controllers/templates.js +0 -56
- package/dist/api/controllers/user.js +0 -124
- package/dist/api/controllers/view/exporters.js +0 -46
- package/dist/api/controllers/view/index.js +0 -193
- package/dist/api/controllers/view/utils.js +0 -177
- package/dist/api/controllers/view/viewBuilder.js +0 -158
- package/dist/api/controllers/webhook.js +0 -134
- package/dist/api/index.js +0 -55
- package/dist/api/routes/analytics.js +0 -34
- package/dist/api/routes/apikeys.js +0 -37
- package/dist/api/routes/application.js +0 -48
- package/dist/api/routes/auth.js +0 -33
- package/dist/api/routes/automation.js +0 -50
- package/dist/api/routes/backup.js +0 -35
- package/dist/api/routes/component.js +0 -35
- package/dist/api/routes/datasource.js +0 -44
- package/dist/api/routes/deploy.js +0 -37
- package/dist/api/routes/dev.js +0 -49
- package/dist/api/routes/index.js +0 -75
- package/dist/api/routes/integration.js +0 -37
- package/dist/api/routes/layout.js +0 -37
- package/dist/api/routes/metadata.js +0 -40
- package/dist/api/routes/migrations.js +0 -36
- package/dist/api/routes/ops.js +0 -52
- package/dist/api/routes/permission.js +0 -44
- package/dist/api/routes/plugin.js +0 -39
- package/dist/api/routes/public/applications.js +0 -174
- package/dist/api/routes/public/index.js +0 -140
- package/dist/api/routes/public/metrics.js +0 -30
- package/dist/api/routes/public/middleware/mapper.js +0 -97
- package/dist/api/routes/public/queries.js +0 -72
- package/dist/api/routes/public/rows.js +0 -158
- package/dist/api/routes/public/tables.js +0 -152
- package/dist/api/routes/public/users.js +0 -135
- package/dist/api/routes/public/utils/Endpoint.js +0 -36
- package/dist/api/routes/query.js +0 -47
- package/dist/api/routes/role.js +0 -40
- package/dist/api/routes/routing.js +0 -39
- package/dist/api/routes/row.js +0 -239
- package/dist/api/routes/screen.js +0 -39
- package/dist/api/routes/script.js +0 -35
- package/dist/api/routes/static.js +0 -80
- package/dist/api/routes/table.js +0 -163
- package/dist/api/routes/templates.js +0 -37
- package/dist/api/routes/user.js +0 -43
- package/dist/api/routes/utils/validators.js +0 -238
- package/dist/api/routes/view.js +0 -42
- package/dist/api/routes/webhook.js +0 -43
- package/dist/app.js +0 -132
- package/dist/automations/actions.js +0 -137
- package/dist/automations/automationUtils.js +0 -173
- package/dist/automations/bullboard.js +0 -71
- package/dist/automations/index.js +0 -43
- package/dist/automations/logging/index.js +0 -53
- package/dist/automations/steps/bash.js +0 -111
- package/dist/automations/steps/createRow.js +0 -108
- package/dist/automations/steps/delay.js +0 -53
- package/dist/automations/steps/deleteRow.js +0 -96
- package/dist/automations/steps/discord.js +0 -116
- package/dist/automations/steps/executeQuery.js +0 -134
- package/dist/automations/steps/executeScript.js +0 -106
- package/dist/automations/steps/filter.js +0 -112
- package/dist/automations/steps/loop.js +0 -54
- package/dist/automations/steps/make.js +0 -134
- package/dist/automations/steps/outgoingWebhook.js +0 -166
- package/dist/automations/steps/queryRows.js +0 -216
- package/dist/automations/steps/sendSmtpEmail.js +0 -115
- package/dist/automations/steps/serverLog.js +0 -65
- package/dist/automations/steps/slack.js +0 -98
- package/dist/automations/steps/updateRow.js +0 -144
- package/dist/automations/steps/utils.js +0 -56
- package/dist/automations/steps/zapier.js +0 -130
- package/dist/automations/triggerInfo/app.js +0 -36
- package/dist/automations/triggerInfo/cron.js +0 -35
- package/dist/automations/triggerInfo/index.js +0 -40
- package/dist/automations/triggerInfo/rowDeleted.js +0 -36
- package/dist/automations/triggerInfo/rowSaved.js +0 -44
- package/dist/automations/triggerInfo/rowUpdated.js +0 -44
- package/dist/automations/triggerInfo/webhook.js +0 -40
- package/dist/automations/triggers.js +0 -181
- package/dist/automations/utils.js +0 -275
- package/dist/constants/definitions.js +0 -2
- package/dist/constants/index.js +0 -181
- package/dist/constants/layouts.js +0 -148
- package/dist/constants/screens.js +0 -51
- package/dist/db/defaultData/datasource_bb_default.js +0 -574
- package/dist/db/defaultData/employeeImport.js +0 -155
- package/dist/db/defaultData/expensesImport.js +0 -117
- package/dist/db/defaultData/inventoryImport.js +0 -109
- package/dist/db/defaultData/jobsImport.js +0 -152
- package/dist/db/dynamoClient.js +0 -124
- package/dist/db/inMemoryView.js +0 -62
- package/dist/db/index.js +0 -43
- package/dist/db/linkedRows/LinkController.js +0 -392
- package/dist/db/linkedRows/LinkDocument.js +0 -33
- package/dist/db/linkedRows/index.js +0 -206
- package/dist/db/linkedRows/linkUtils.js +0 -131
- package/dist/db/newid.js +0 -7
- package/dist/db/utils.js +0 -248
- package/dist/db/views/staticViews.js +0 -144
- package/dist/ddApm.js +0 -11
- package/dist/definitions/automations.js +0 -8
- package/dist/definitions/common.js +0 -2
- package/dist/definitions/datasource.js +0 -7
- package/dist/definitions/openapi.js +0 -6
- package/dist/environment.js +0 -109
- package/dist/events/AutomationEmitter.js +0 -53
- package/dist/events/BudibaseEmitter.js +0 -25
- package/dist/events/docUpdates/index.js +0 -17
- package/dist/events/docUpdates/processors.js +0 -18
- package/dist/events/docUpdates/syncUsers.js +0 -49
- package/dist/events/index.js +0 -11
- package/dist/events/utils.js +0 -43
- package/dist/integrations/airtable.js +0 -173
- package/dist/integrations/arangodb.js +0 -119
- package/dist/integrations/base/query.js +0 -32
- package/dist/integrations/base/sql.js +0 -600
- package/dist/integrations/base/sqlTable.js +0 -167
- package/dist/integrations/base/types.js +0 -2
- package/dist/integrations/couchdb.js +0 -140
- package/dist/integrations/dynamodb.js +0 -210
- package/dist/integrations/elasticsearch.js +0 -201
- package/dist/integrations/firebase.js +0 -189
- package/dist/integrations/googlesheets.js +0 -484
- package/dist/integrations/index.js +0 -138
- package/dist/integrations/microsoftSqlServer.js +0 -289
- package/dist/integrations/mongodb.js +0 -630
- package/dist/integrations/mysql.js +0 -272
- package/dist/integrations/oracle.js +0 -404
- package/dist/integrations/postgres.js +0 -320
- package/dist/integrations/queries/sql.js +0 -84
- package/dist/integrations/redis.js +0 -187
- package/dist/integrations/rest.js +0 -400
- package/dist/integrations/s3.js +0 -256
- package/dist/integrations/snowflake.js +0 -114
- package/dist/integrations/utils.js +0 -295
- package/dist/middleware/appInfo.js +0 -22
- package/dist/middleware/authorized.js +0 -112
- package/dist/middleware/builder.js +0 -93
- package/dist/middleware/currentapp.js +0 -103
- package/dist/middleware/joi-validator.js +0 -43
- package/dist/middleware/publicApi.js +0 -25
- package/dist/middleware/resourceId.js +0 -59
- package/dist/middleware/selfhost.js +0 -24
- package/dist/middleware/utils.js +0 -8
- package/dist/migrations/functions/appUrls.js +0 -42
- package/dist/migrations/functions/backfill/app/automations.js +0 -31
- package/dist/migrations/functions/backfill/app/datasources.js +0 -28
- package/dist/migrations/functions/backfill/app/layouts.js +0 -33
- package/dist/migrations/functions/backfill/app/queries.js +0 -49
- package/dist/migrations/functions/backfill/app/roles.js +0 -28
- package/dist/migrations/functions/backfill/app/screens.js +0 -28
- package/dist/migrations/functions/backfill/app/tables.js +0 -37
- package/dist/migrations/functions/backfill/app.js +0 -176
- package/dist/migrations/functions/backfill/global/configs.js +0 -67
- package/dist/migrations/functions/backfill/global/quotas.js +0 -60
- package/dist/migrations/functions/backfill/global/users.js +0 -50
- package/dist/migrations/functions/backfill/global.js +0 -205
- package/dist/migrations/functions/backfill/index.js +0 -32
- package/dist/migrations/functions/backfill/installation.js +0 -80
- package/dist/migrations/functions/syncQuotas.js +0 -52
- package/dist/migrations/functions/tableSettings.js +0 -130
- package/dist/migrations/functions/usageQuotas/index.js +0 -16
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -24
- package/dist/migrations/functions/usageQuotas/syncPlugins.js +0 -23
- package/dist/migrations/functions/usageQuotas/syncRows.js +0 -33
- package/dist/migrations/functions/usageQuotas/syncUsers.js +0 -21
- package/dist/migrations/functions/userEmailViewCasing.js +0 -24
- package/dist/migrations/index.js +0 -111
- package/dist/migrations/tests/helpers.js +0 -72
- package/dist/migrations/tests/structures.js +0 -37
- package/dist/sdk/app/applications/index.js +0 -28
- package/dist/sdk/app/applications/sync.js +0 -164
- package/dist/sdk/app/applications/utils.js +0 -21
- package/dist/sdk/app/automations/index.js +0 -29
- package/dist/sdk/app/automations/webhook.js +0 -54
- package/dist/sdk/app/backups/constants.js +0 -6
- package/dist/sdk/app/backups/exports.js +0 -160
- package/dist/sdk/app/backups/imports.js +0 -170
- package/dist/sdk/app/backups/index.js +0 -29
- package/dist/sdk/app/backups/statistics.js +0 -73
- package/dist/sdk/app/datasources/datasources.js +0 -173
- package/dist/sdk/app/datasources/index.js +0 -27
- package/dist/sdk/app/queries/index.js +0 -27
- package/dist/sdk/app/queries/queries.js +0 -60
- package/dist/sdk/app/rows/attachments.js +0 -61
- package/dist/sdk/app/rows/index.js +0 -28
- package/dist/sdk/app/rows/rows.js +0 -30
- package/dist/sdk/app/tables/index.js +0 -65
- package/dist/sdk/index.js +0 -27
- package/dist/sdk/plugins/index.js +0 -27
- package/dist/sdk/plugins/plugins.js +0 -53
- package/dist/sdk/users/index.js +0 -27
- package/dist/sdk/users/utils.js +0 -87
- package/dist/sdk/utils/index.js +0 -29
- package/dist/startup.js +0 -158
- package/dist/threads/automation.js +0 -450
- package/dist/threads/definitions.js +0 -2
- package/dist/threads/index.js +0 -140
- package/dist/threads/query.js +0 -265
- package/dist/threads/utils.js +0 -120
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/utilities/appDirectoryTemplate/package.json +0 -10
- package/dist/utilities/budibaseDir.js +0 -5
- package/dist/utilities/centralPath.js +0 -27
- package/dist/utilities/csv.js +0 -33
- package/dist/utilities/fileSystem/app.js +0 -88
- package/dist/utilities/fileSystem/clientLibrary.js +0 -138
- package/dist/utilities/fileSystem/filesystem.js +0 -180
- package/dist/utilities/fileSystem/index.js +0 -21
- package/dist/utilities/fileSystem/plugin.js +0 -76
- package/dist/utilities/fileSystem/processor.js +0 -34
- package/dist/utilities/fileSystem/template.js +0 -47
- package/dist/utilities/global.js +0 -149
- package/dist/utilities/index.js +0 -143
- package/dist/utilities/redis.js +0 -117
- package/dist/utilities/retry.js +0 -30
- package/dist/utilities/routing/index.js +0 -39
- package/dist/utilities/rowProcessor/index.js +0 -282
- package/dist/utilities/rowProcessor/map.js +0 -116
- package/dist/utilities/rowProcessor/utils.js +0 -87
- package/dist/utilities/schema.js +0 -112
- package/dist/utilities/scriptRunner.js +0 -26
- package/dist/utilities/security.js +0 -57
- package/dist/utilities/statusCodes.js +0 -9
- package/dist/utilities/usageQuota/rows.js +0 -88
- package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
- package/dist/utilities/users.js +0 -57
- package/dist/utilities/workerRequests.js +0 -171
- package/dist/watch.js +0 -53
- package/dist/websockets/client.js +0 -14
- package/dist/websockets/grid.js +0 -60
- package/dist/websockets/index.js +0 -17
- package/dist/websockets/websocket.js +0 -78
- /package/dist/{api/controllers/static/templates/BudibaseApp.svelte → BudibaseApp-Y5NZEDTC.svelte} +0 -0
- /package/dist/{api/controllers/static/templates/app.hbs → app.hbs} +0 -0
- /package/dist/{api/controllers/static/templates/preview.hbs → preview.hbs} +0 -0
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const router_1 = __importDefault(require("@koa/router"));
|
|
30
|
-
const controller = __importStar(require("../controllers/metadata"));
|
|
31
|
-
const appInfo_1 = require("../../middleware/appInfo");
|
|
32
|
-
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
33
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
34
|
-
const router = new router_1.default();
|
|
35
|
-
router
|
|
36
|
-
.post("/api/metadata/:type/:entityId", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), (0, appInfo_1.middleware)({ appType: appInfo_1.AppType.DEV }), controller.saveMetadata)
|
|
37
|
-
.delete("/api/metadata/:type/:entityId", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), (0, appInfo_1.middleware)({ appType: appInfo_1.AppType.DEV }), controller.deleteMetadata)
|
|
38
|
-
.get("/api/metadata/type", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), (0, appInfo_1.middleware)({ appType: appInfo_1.AppType.DEV }), controller.getTypes)
|
|
39
|
-
.get("/api/metadata/:type/:entityId", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), (0, appInfo_1.middleware)({ appType: appInfo_1.AppType.DEV }), controller.getMetadata);
|
|
40
|
-
exports.default = router;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const router_1 = __importDefault(require("@koa/router"));
|
|
30
|
-
const migrationsController = __importStar(require("../controllers/migrations"));
|
|
31
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
32
|
-
const router = new router_1.default();
|
|
33
|
-
router
|
|
34
|
-
.post("/api/migrations/run", backend_core_1.auth.internalApi, migrationsController.migrate)
|
|
35
|
-
.get("/api/migrations/definitions", backend_core_1.auth.internalApi, migrationsController.fetchDefinitions);
|
|
36
|
-
exports.default = router;
|
package/dist/api/routes/ops.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.errorValidator = exports.logsValidator = void 0;
|
|
30
|
-
const router_1 = __importDefault(require("@koa/router"));
|
|
31
|
-
const controller = __importStar(require("../controllers/ops"));
|
|
32
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
33
|
-
const joi_1 = __importDefault(require("joi"));
|
|
34
|
-
function logsValidator() {
|
|
35
|
-
return backend_core_1.middleware.joiValidator.body(joi_1.default.object({
|
|
36
|
-
message: joi_1.default.string().required(),
|
|
37
|
-
data: joi_1.default.object(),
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
exports.logsValidator = logsValidator;
|
|
41
|
-
function errorValidator() {
|
|
42
|
-
return backend_core_1.middleware.joiValidator.body(joi_1.default.object({
|
|
43
|
-
message: joi_1.default.string().required(),
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
exports.errorValidator = errorValidator;
|
|
47
|
-
const router = new router_1.default();
|
|
48
|
-
router
|
|
49
|
-
.post("/api/ops/log", logsValidator(), controller.log)
|
|
50
|
-
.post("/api/ops/error", errorValidator(), controller.error)
|
|
51
|
-
.post("/api/ops/alert", errorValidator(), controller.alert);
|
|
52
|
-
exports.default = router;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const router_1 = __importDefault(require("@koa/router"));
|
|
30
|
-
const controller = __importStar(require("../controllers/permission"));
|
|
31
|
-
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
32
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
33
|
-
const validators_1 = require("./utils/validators");
|
|
34
|
-
const router = new router_1.default();
|
|
35
|
-
router
|
|
36
|
-
.get("/api/permission/builtin", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.fetchBuiltin)
|
|
37
|
-
.get("/api/permission/levels", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.fetchLevels)
|
|
38
|
-
.get("/api/permission", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.fetch)
|
|
39
|
-
.get("/api/permission/:resourceId", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.getResourcePerms)
|
|
40
|
-
// adding a specific role/level for the resource overrides the underlying access control
|
|
41
|
-
.post("/api/permission/:roleId/:resourceId/:level", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), (0, validators_1.permissionValidator)(), controller.addPermission)
|
|
42
|
-
// deleting the level defaults it back the underlying access control for the resource
|
|
43
|
-
.delete("/api/permission/:roleId/:resourceId/:level", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), (0, validators_1.permissionValidator)(), controller.removePermission);
|
|
44
|
-
exports.default = router;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const router_1 = __importDefault(require("@koa/router"));
|
|
30
|
-
const controller = __importStar(require("../controllers/plugin"));
|
|
31
|
-
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
32
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
33
|
-
const router = new router_1.default();
|
|
34
|
-
router
|
|
35
|
-
.post("/api/plugin/upload", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.upload)
|
|
36
|
-
.post("/api/plugin", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.create)
|
|
37
|
-
.get("/api/plugin", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.fetch)
|
|
38
|
-
.delete("/api/plugin/:pluginId", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.destroy);
|
|
39
|
-
exports.default = router;
|
|
@@ -1,174 +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 applications_1 = __importDefault(require("../../controllers/public/applications"));
|
|
7
|
-
const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
|
|
8
|
-
const { nameValidator, applicationValidator } = require("../utils/validators");
|
|
9
|
-
const read = [], write = [];
|
|
10
|
-
/**
|
|
11
|
-
* @openapi
|
|
12
|
-
* /applications:
|
|
13
|
-
* post:
|
|
14
|
-
* operationId: appCreate
|
|
15
|
-
* summary: Create an application
|
|
16
|
-
* tags:
|
|
17
|
-
* - applications
|
|
18
|
-
* parameters:
|
|
19
|
-
* - $ref: '#/components/parameters/appId'
|
|
20
|
-
* requestBody:
|
|
21
|
-
* required: true
|
|
22
|
-
* content:
|
|
23
|
-
* application/json:
|
|
24
|
-
* schema:
|
|
25
|
-
* $ref: '#/components/schemas/application'
|
|
26
|
-
* responses:
|
|
27
|
-
* 200:
|
|
28
|
-
* description: Returns the created application.
|
|
29
|
-
* content:
|
|
30
|
-
* application/json:
|
|
31
|
-
* schema:
|
|
32
|
-
* $ref: '#/components/schemas/applicationOutput'
|
|
33
|
-
* examples:
|
|
34
|
-
* application:
|
|
35
|
-
* $ref: '#/components/examples/application'
|
|
36
|
-
*/
|
|
37
|
-
write.push(new Endpoint_1.default("post", "/applications", applications_1.default.create).addMiddleware(applicationValidator()));
|
|
38
|
-
/**
|
|
39
|
-
* @openapi
|
|
40
|
-
* /applications/{appId}:
|
|
41
|
-
* put:
|
|
42
|
-
* operationId: appUpdate
|
|
43
|
-
* summary: Update an application
|
|
44
|
-
* tags:
|
|
45
|
-
* - applications
|
|
46
|
-
* parameters:
|
|
47
|
-
* - $ref: '#/components/parameters/appIdUrl'
|
|
48
|
-
* requestBody:
|
|
49
|
-
* required: true
|
|
50
|
-
* content:
|
|
51
|
-
* application/json:
|
|
52
|
-
* schema:
|
|
53
|
-
* $ref: '#/components/schemas/application'
|
|
54
|
-
* responses:
|
|
55
|
-
* 200:
|
|
56
|
-
* description: Returns the updated application.
|
|
57
|
-
* content:
|
|
58
|
-
* application/json:
|
|
59
|
-
* schema:
|
|
60
|
-
* $ref: '#/components/schemas/applicationOutput'
|
|
61
|
-
* examples:
|
|
62
|
-
* application:
|
|
63
|
-
* $ref: '#/components/examples/application'
|
|
64
|
-
*/
|
|
65
|
-
write.push(new Endpoint_1.default("put", "/applications/:appId", applications_1.default.update).addMiddleware(applicationValidator()));
|
|
66
|
-
/**
|
|
67
|
-
* @openapi
|
|
68
|
-
* /applications/{appId}:
|
|
69
|
-
* delete:
|
|
70
|
-
* operationId: appDestroy
|
|
71
|
-
* summary: Delete an application
|
|
72
|
-
* tags:
|
|
73
|
-
* - applications
|
|
74
|
-
* parameters:
|
|
75
|
-
* - $ref: '#/components/parameters/appIdUrl'
|
|
76
|
-
* responses:
|
|
77
|
-
* 200:
|
|
78
|
-
* description: Returns the deleted application.
|
|
79
|
-
* content:
|
|
80
|
-
* application/json:
|
|
81
|
-
* schema:
|
|
82
|
-
* $ref: '#/components/schemas/applicationOutput'
|
|
83
|
-
* examples:
|
|
84
|
-
* application:
|
|
85
|
-
* $ref: '#/components/examples/application'
|
|
86
|
-
*/
|
|
87
|
-
write.push(new Endpoint_1.default("delete", "/applications/:appId", applications_1.default.destroy));
|
|
88
|
-
/**
|
|
89
|
-
* @openapi
|
|
90
|
-
* /applications/{appId}/unpublish:
|
|
91
|
-
* post:
|
|
92
|
-
* operationId: appUnpublish
|
|
93
|
-
* summary: Unpublish an application
|
|
94
|
-
* tags:
|
|
95
|
-
* - applications
|
|
96
|
-
* parameters:
|
|
97
|
-
* - $ref: '#/components/parameters/appIdUrl'
|
|
98
|
-
* responses:
|
|
99
|
-
* 204:
|
|
100
|
-
* description: The app was published successfully.
|
|
101
|
-
*/
|
|
102
|
-
write.push(new Endpoint_1.default("post", "/applications/:appId/unpublish", applications_1.default.unpublish));
|
|
103
|
-
/**
|
|
104
|
-
* @openapi
|
|
105
|
-
* /applications/{appId}/publish:
|
|
106
|
-
* post:
|
|
107
|
-
* operationId: appPublish
|
|
108
|
-
* summary: Unpublish an application
|
|
109
|
-
* tags:
|
|
110
|
-
* - applications
|
|
111
|
-
* parameters:
|
|
112
|
-
* - $ref: '#/components/parameters/appIdUrl'
|
|
113
|
-
* responses:
|
|
114
|
-
* 200:
|
|
115
|
-
* description: Returns the deployment object.
|
|
116
|
-
* content:
|
|
117
|
-
* application/json:
|
|
118
|
-
* schema:
|
|
119
|
-
* $ref: '#/components/schemas/deploymentOutput'
|
|
120
|
-
* examples:
|
|
121
|
-
* deployment:
|
|
122
|
-
* $ref: '#/components/examples/deploymentOutput'
|
|
123
|
-
*/
|
|
124
|
-
write.push(new Endpoint_1.default("post", "/applications/:appId/publish", applications_1.default.publish));
|
|
125
|
-
/**
|
|
126
|
-
* @openapi
|
|
127
|
-
* /applications/{appId}:
|
|
128
|
-
* get:
|
|
129
|
-
* operationId: appGetById
|
|
130
|
-
* summary: Retrieve an application
|
|
131
|
-
* tags:
|
|
132
|
-
* - applications
|
|
133
|
-
* parameters:
|
|
134
|
-
* - $ref: '#/components/parameters/appIdUrl'
|
|
135
|
-
* responses:
|
|
136
|
-
* 200:
|
|
137
|
-
* description: Returns the retrieved application.
|
|
138
|
-
* content:
|
|
139
|
-
* application/json:
|
|
140
|
-
* schema:
|
|
141
|
-
* $ref: '#/components/schemas/applicationOutput'
|
|
142
|
-
* examples:
|
|
143
|
-
* application:
|
|
144
|
-
* $ref: '#/components/examples/application'
|
|
145
|
-
*/
|
|
146
|
-
read.push(new Endpoint_1.default("get", "/applications/:appId", applications_1.default.read));
|
|
147
|
-
/**
|
|
148
|
-
* @openapi
|
|
149
|
-
* /applications/search:
|
|
150
|
-
* post:
|
|
151
|
-
* operationId: appSearch
|
|
152
|
-
* summary: Search for applications
|
|
153
|
-
* description: Based on application properties (currently only name) search for applications.
|
|
154
|
-
* tags:
|
|
155
|
-
* - applications
|
|
156
|
-
* requestBody:
|
|
157
|
-
* required: true
|
|
158
|
-
* content:
|
|
159
|
-
* application/json:
|
|
160
|
-
* schema:
|
|
161
|
-
* $ref: '#/components/schemas/nameSearch'
|
|
162
|
-
* responses:
|
|
163
|
-
* 200:
|
|
164
|
-
* description: Returns the applications that were found based on the search parameters.
|
|
165
|
-
* content:
|
|
166
|
-
* application/json:
|
|
167
|
-
* schema:
|
|
168
|
-
* $ref: '#/components/schemas/applicationSearch'
|
|
169
|
-
* examples:
|
|
170
|
-
* applications:
|
|
171
|
-
* $ref: '#/components/examples/applications'
|
|
172
|
-
*/
|
|
173
|
-
read.push(new Endpoint_1.default("post", "/applications/search", applications_1.default.search).addMiddleware(nameValidator()));
|
|
174
|
-
exports.default = { read, write };
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a, _b;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.shutdown = void 0;
|
|
8
|
-
const applications_1 = __importDefault(require("./applications"));
|
|
9
|
-
const metrics_1 = __importDefault(require("./metrics"));
|
|
10
|
-
const queries_1 = __importDefault(require("./queries"));
|
|
11
|
-
const tables_1 = __importDefault(require("./tables"));
|
|
12
|
-
const rows_1 = __importDefault(require("./rows"));
|
|
13
|
-
const users_1 = __importDefault(require("./users"));
|
|
14
|
-
const authorized_1 = __importDefault(require("../../../middleware/authorized"));
|
|
15
|
-
const publicApi_1 = __importDefault(require("../../../middleware/publicApi"));
|
|
16
|
-
const resourceId_1 = require("../../../middleware/resourceId");
|
|
17
|
-
const mapper_1 = __importDefault(require("./middleware/mapper"));
|
|
18
|
-
const environment_1 = __importDefault(require("../../../environment"));
|
|
19
|
-
// below imports don't have declaration files
|
|
20
|
-
const Router = require("@koa/router");
|
|
21
|
-
const { RateLimit, Stores } = require("koa2-ratelimit");
|
|
22
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
23
|
-
const { PermissionType, PermissionLevel } = backend_core_1.permissions;
|
|
24
|
-
const PREFIX = "/api/public/v1";
|
|
25
|
-
// allow a lot more requests when in test
|
|
26
|
-
const DEFAULT_API_REQ_LIMIT_PER_SEC = environment_1.default.isTest() ? 100 : 10;
|
|
27
|
-
function getApiLimitPerSecond() {
|
|
28
|
-
if (!environment_1.default.API_REQ_LIMIT_PER_SEC) {
|
|
29
|
-
return DEFAULT_API_REQ_LIMIT_PER_SEC;
|
|
30
|
-
}
|
|
31
|
-
return parseInt(environment_1.default.API_REQ_LIMIT_PER_SEC);
|
|
32
|
-
}
|
|
33
|
-
let rateLimitStore = null;
|
|
34
|
-
if (!environment_1.default.isTest()) {
|
|
35
|
-
const REDIS_OPTS = backend_core_1.redis.utils.getRedisOptions();
|
|
36
|
-
let options;
|
|
37
|
-
if (REDIS_OPTS.redisProtocolUrl) {
|
|
38
|
-
// fully qualified redis URL
|
|
39
|
-
options = {
|
|
40
|
-
url: REDIS_OPTS.redisProtocolUrl,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
options = {
|
|
45
|
-
socket: {
|
|
46
|
-
host: REDIS_OPTS.host,
|
|
47
|
-
port: REDIS_OPTS.port,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
if (((_a = REDIS_OPTS.opts) === null || _a === void 0 ? void 0 : _a.password) || ((_b = REDIS_OPTS.opts.redisOptions) === null || _b === void 0 ? void 0 : _b.password)) {
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
options.password =
|
|
53
|
-
REDIS_OPTS.opts.password || REDIS_OPTS.opts.redisOptions.password;
|
|
54
|
-
}
|
|
55
|
-
if (!environment_1.default.REDIS_CLUSTERED) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
// Can't set direct redis db in clustered env
|
|
58
|
-
options.database = 1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
rateLimitStore = new Stores.Redis(options);
|
|
62
|
-
RateLimit.defaultOptions({
|
|
63
|
-
store: rateLimitStore,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
// rate limiting, allows for 2 requests per second
|
|
67
|
-
const limiter = RateLimit.middleware({
|
|
68
|
-
interval: { sec: 1 },
|
|
69
|
-
// per ip, per interval
|
|
70
|
-
max: getApiLimitPerSecond(),
|
|
71
|
-
});
|
|
72
|
-
const publicRouter = new Router({
|
|
73
|
-
prefix: PREFIX,
|
|
74
|
-
});
|
|
75
|
-
publicRouter.use(limiter);
|
|
76
|
-
function addMiddleware(endpoints, middleware, opts = { output: false }) {
|
|
77
|
-
if (!endpoints) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (!Array.isArray(endpoints)) {
|
|
81
|
-
endpoints = [endpoints];
|
|
82
|
-
}
|
|
83
|
-
for (let endpoint of endpoints) {
|
|
84
|
-
if (opts === null || opts === void 0 ? void 0 : opts.output) {
|
|
85
|
-
endpoint.addOutputMiddleware(middleware);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
endpoint.addMiddleware(middleware);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function addToRouter(endpoints) {
|
|
93
|
-
if (endpoints) {
|
|
94
|
-
for (let endpoint of endpoints) {
|
|
95
|
-
endpoint.apply(publicRouter);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function applyAdminRoutes(endpoints) {
|
|
100
|
-
addMiddleware(endpoints.read, backend_core_1.middleware.builderOrAdmin);
|
|
101
|
-
addMiddleware(endpoints.write, backend_core_1.middleware.builderOrAdmin);
|
|
102
|
-
addToRouter(endpoints.read);
|
|
103
|
-
addToRouter(endpoints.write);
|
|
104
|
-
}
|
|
105
|
-
function applyRoutes(endpoints, permType, resource, subResource) {
|
|
106
|
-
const paramMiddleware = subResource
|
|
107
|
-
? (0, resourceId_1.paramSubResource)(resource, subResource)
|
|
108
|
-
: (0, resourceId_1.paramResource)(resource);
|
|
109
|
-
const publicApiMiddleware = (0, publicApi_1.default)({
|
|
110
|
-
requiresAppId: permType !== PermissionType.APP && permType !== PermissionType.USER,
|
|
111
|
-
});
|
|
112
|
-
addMiddleware(endpoints.read, publicApiMiddleware);
|
|
113
|
-
addMiddleware(endpoints.write, publicApiMiddleware);
|
|
114
|
-
// add the parameter capture middleware
|
|
115
|
-
addMiddleware(endpoints.read, paramMiddleware);
|
|
116
|
-
addMiddleware(endpoints.write, paramMiddleware);
|
|
117
|
-
// add the authorization middleware, using the correct perm type
|
|
118
|
-
addMiddleware(endpoints.read, (0, authorized_1.default)(permType, PermissionLevel.READ));
|
|
119
|
-
addMiddleware(endpoints.write, (0, authorized_1.default)(permType, PermissionLevel.WRITE));
|
|
120
|
-
// add the output mapper middleware
|
|
121
|
-
addMiddleware(endpoints.read, mapper_1.default, { output: true });
|
|
122
|
-
addMiddleware(endpoints.write, mapper_1.default, { output: true });
|
|
123
|
-
addToRouter(endpoints.read);
|
|
124
|
-
addToRouter(endpoints.write);
|
|
125
|
-
}
|
|
126
|
-
applyAdminRoutes(metrics_1.default);
|
|
127
|
-
applyRoutes(applications_1.default, PermissionType.APP, "appId");
|
|
128
|
-
applyRoutes(tables_1.default, PermissionType.TABLE, "tableId");
|
|
129
|
-
applyRoutes(users_1.default, PermissionType.USER, "userId");
|
|
130
|
-
applyRoutes(queries_1.default, PermissionType.QUERY, "queryId");
|
|
131
|
-
// needs to be applied last for routing purposes, don't override other endpoints
|
|
132
|
-
applyRoutes(rows_1.default, PermissionType.TABLE, "tableId", "rowId");
|
|
133
|
-
exports.default = publicRouter;
|
|
134
|
-
const shutdown = () => {
|
|
135
|
-
if (rateLimitStore) {
|
|
136
|
-
rateLimitStore.client.disconnect();
|
|
137
|
-
rateLimitStore = null;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
exports.shutdown = shutdown;
|
|
@@ -1,30 +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 metrics_1 = __importDefault(require("../../controllers/public/metrics"));
|
|
7
|
-
const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
|
|
8
|
-
const read = [];
|
|
9
|
-
/**
|
|
10
|
-
* @openapi
|
|
11
|
-
* /metrics:
|
|
12
|
-
* get:
|
|
13
|
-
* operationId: metricsGet
|
|
14
|
-
* summary: Retrieve Budibase tenant metrics
|
|
15
|
-
* description: Output metrics in OpenMetrics format compatible with Prometheus
|
|
16
|
-
* tags:
|
|
17
|
-
* - metrics
|
|
18
|
-
* responses:
|
|
19
|
-
* 200:
|
|
20
|
-
* description: Returns tenant metrics.
|
|
21
|
-
* content:
|
|
22
|
-
* text/plain:
|
|
23
|
-
* schema:
|
|
24
|
-
* type: string
|
|
25
|
-
* examples:
|
|
26
|
-
* metrics:
|
|
27
|
-
* $ref: '#/components/examples/metrics'
|
|
28
|
-
*/
|
|
29
|
-
read.push(new Endpoint_1.default("get", "/metrics", metrics_1.default.fetch));
|
|
30
|
-
exports.default = { read };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const mapping_1 = __importDefault(require("../../../controllers/public/mapping"));
|
|
16
|
-
var Resources;
|
|
17
|
-
(function (Resources) {
|
|
18
|
-
Resources["APPLICATION"] = "applications";
|
|
19
|
-
Resources["TABLES"] = "tables";
|
|
20
|
-
Resources["ROWS"] = "rows";
|
|
21
|
-
Resources["USERS"] = "users";
|
|
22
|
-
Resources["QUERIES"] = "queries";
|
|
23
|
-
Resources["SEARCH"] = "search";
|
|
24
|
-
})(Resources || (Resources = {}));
|
|
25
|
-
function isArrayResponse(ctx) {
|
|
26
|
-
return ctx.url.endsWith(Resources.SEARCH) || Array.isArray(ctx.body);
|
|
27
|
-
}
|
|
28
|
-
function processApplications(ctx) {
|
|
29
|
-
if (isArrayResponse(ctx)) {
|
|
30
|
-
return mapping_1.default.mapApplications(ctx);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return mapping_1.default.mapApplication(ctx);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function processTables(ctx) {
|
|
37
|
-
if (isArrayResponse(ctx)) {
|
|
38
|
-
return mapping_1.default.mapTables(ctx);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return mapping_1.default.mapTable(ctx);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function processRows(ctx) {
|
|
45
|
-
if (isArrayResponse(ctx)) {
|
|
46
|
-
return mapping_1.default.mapRowSearch(ctx);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return mapping_1.default.mapRow(ctx);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function processUsers(ctx) {
|
|
53
|
-
if (isArrayResponse(ctx)) {
|
|
54
|
-
return mapping_1.default.mapUsers(ctx);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
return mapping_1.default.mapUser(ctx);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function processQueries(ctx) {
|
|
61
|
-
if (isArrayResponse(ctx)) {
|
|
62
|
-
return mapping_1.default.mapQueries(ctx);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
return mapping_1.default.mapQueryExecution(ctx);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.default = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
if (!ctx.body) {
|
|
70
|
-
return yield next();
|
|
71
|
-
}
|
|
72
|
-
let urlParts = ctx.url.split("/");
|
|
73
|
-
urlParts = urlParts.slice(4, urlParts.length);
|
|
74
|
-
let body = {};
|
|
75
|
-
switch (urlParts[0]) {
|
|
76
|
-
case Resources.APPLICATION:
|
|
77
|
-
body = processApplications(ctx);
|
|
78
|
-
break;
|
|
79
|
-
case Resources.TABLES:
|
|
80
|
-
if (urlParts[2] === Resources.ROWS) {
|
|
81
|
-
body = processRows(ctx);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
body = processTables(ctx);
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
case Resources.USERS:
|
|
88
|
-
body = processUsers(ctx);
|
|
89
|
-
break;
|
|
90
|
-
case Resources.QUERIES:
|
|
91
|
-
body = processQueries(ctx);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
// update the body based on what has occurred in the mapper
|
|
95
|
-
ctx.body = body;
|
|
96
|
-
yield next();
|
|
97
|
-
});
|