@budibase/server 2.1.45 → 2.1.46-alpha.1
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__/aws-sdk.ts +14 -0
- package/__mocks__/node-fetch.ts +5 -1
- package/builder/assets/index.156490b5.js +1020 -0
- package/builder/assets/index.538092be.css +6 -0
- package/builder/index.html +2 -2
- package/coverage/clover.xml +11101 -3980
- package/coverage/coverage-final.json +273 -118
- package/coverage/lcov-report/index.html +727 -187
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +190 -0
- package/coverage/lcov-report/{api/controllers/apikeys.js.html → src/api/controllers/apikeys.ts.html} +30 -30
- package/coverage/lcov-report/src/api/controllers/application.ts.html +1891 -0
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +301 -0
- package/coverage/lcov-report/{api/controllers/automation.js.html → src/api/controllers/automation.ts.html} +99 -99
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +148 -0
- package/coverage/lcov-report/{api/controllers/cloud.js.html → src/api/controllers/cloud.ts.html} +61 -58
- package/coverage/lcov-report/src/api/controllers/component.ts.html +259 -0
- package/coverage/lcov-report/{api/controllers/datasource.js.html → src/api/controllers/datasource.ts.html} +287 -107
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +259 -0
- package/coverage/lcov-report/{utilities/rowProcessor → src/api/controllers/deploy}/index.html +40 -40
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +748 -0
- package/coverage/lcov-report/{api/controllers/dev.js.html → src/api/controllers/dev.ts.html} +69 -87
- package/coverage/lcov-report/src/api/controllers/index.html +431 -0
- package/coverage/lcov-report/src/api/controllers/integration.ts.html +124 -0
- package/coverage/lcov-report/{api/controllers/layout.js.html → src/api/controllers/layout.ts.html} +31 -31
- package/coverage/lcov-report/{api/controllers/metadata.js.html → src/api/controllers/metadata.ts.html} +33 -30
- package/coverage/lcov-report/{api/controllers/migrations.js.html → src/api/controllers/migrations.ts.html} +20 -17
- package/coverage/lcov-report/{api/controllers/permission.js.html → src/api/controllers/permission.ts.html} +88 -79
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +130 -0
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +310 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +206 -0
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +484 -0
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +97 -0
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +121 -0
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +136 -0
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +334 -0
- package/coverage/lcov-report/src/api/controllers/public/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +202 -0
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +178 -0
- package/coverage/lcov-report/{utilities/routing/index.js.html → src/api/controllers/public/mapping/tables.ts.html} +46 -43
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +181 -0
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +145 -0
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +328 -0
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +253 -0
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +325 -0
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +220 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +373 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +379 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +157 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +403 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +146 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +586 -0
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +712 -0
- package/coverage/lcov-report/src/api/controllers/query/index.html +131 -0
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +976 -0
- package/coverage/lcov-report/{api/controllers/query/validation.js.html → src/api/controllers/query/validation.ts.html} +26 -26
- package/coverage/lcov-report/{api/controllers/role.js.html → src/api/controllers/role.ts.html} +51 -63
- package/coverage/lcov-report/{api/controllers/routing.js.html → src/api/controllers/routing.ts.html} +67 -58
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +2269 -0
- package/coverage/lcov-report/{api/controllers/row/external.js.html → src/api/controllers/row/external.ts.html} +162 -111
- package/coverage/lcov-report/{api → src/api}/controllers/row/index.html +82 -52
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +541 -0
- package/coverage/lcov-report/{api/controllers/row/internal.js.html → src/api/controllers/row/internal.ts.html} +163 -121
- package/coverage/lcov-report/{api/controllers/row/internalSearch.js.html → src/api/controllers/row/internalSearch.ts.html} +189 -117
- package/coverage/lcov-report/{api/controllers/row/staticFormula.js.html → src/api/controllers/row/staticFormula.ts.html} +73 -58
- package/coverage/lcov-report/{api/controllers/row/utils.js.html → src/api/controllers/row/utils.ts.html} +88 -58
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +463 -0
- package/coverage/lcov-report/{api/controllers/script.js.html → src/api/controllers/script.ts.html} +19 -16
- package/coverage/lcov-report/src/api/controllers/static/index.html +116 -0
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +694 -0
- package/coverage/lcov-report/{api/controllers/table/bulkFormula.js.html → src/api/controllers/table/bulkFormula.ts.html} +104 -62
- package/coverage/lcov-report/{api/controllers/table/external.js.html → src/api/controllers/table/external.ts.html} +204 -111
- package/coverage/lcov-report/src/api/controllers/table/index.html +176 -0
- package/coverage/lcov-report/{api/controllers/table/index.js.html → src/api/controllers/table/index.ts.html} +58 -49
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +661 -0
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1255 -0
- package/coverage/lcov-report/{api/controllers/templates.js.html → src/api/controllers/templates.ts.html} +38 -29
- package/coverage/lcov-report/{api/controllers/user.js.html → src/api/controllers/user.ts.html} +78 -255
- package/coverage/lcov-report/{api/controllers/view/exporters.js.html → src/api/controllers/view/exporters.ts.html} +22 -16
- package/coverage/lcov-report/{api → src/api}/controllers/view/index.html +36 -36
- package/coverage/lcov-report/{api/controllers/view/index.js.html → src/api/controllers/view/index.ts.html} +91 -64
- package/coverage/lcov-report/{api/controllers/view/utils.js.html → src/api/controllers/view/utils.ts.html} +72 -54
- package/coverage/lcov-report/{api/controllers/view/viewBuilder.js.html → src/api/controllers/view/viewBuilder.ts.html} +78 -36
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +379 -0
- package/coverage/lcov-report/{api → src/api}/index.html +23 -23
- package/coverage/lcov-report/{api/index.js.html → src/api/index.ts.html} +63 -84
- package/coverage/lcov-report/src/api/routes/analytics.ts.html +112 -0
- package/coverage/lcov-report/{api/routes/integration.js.html → src/api/routes/apikeys.ts.html} +25 -25
- package/coverage/lcov-report/src/api/routes/application.ts.html +223 -0
- package/coverage/lcov-report/src/api/routes/auth.ts.html +109 -0
- package/coverage/lcov-report/{api/routes/automation.js.html → src/api/routes/automation.ts.html} +53 -47
- package/coverage/lcov-report/{api/routes/cloud.js.html → src/api/routes/backup.ts.html} +28 -28
- package/coverage/lcov-report/{api/routes/deploy.js.html → src/api/routes/cloud.ts.html} +31 -28
- package/coverage/lcov-report/{api/routes/component.js.html → src/api/routes/component.ts.html} +24 -24
- package/coverage/lcov-report/src/api/routes/datasource.ts.html +265 -0
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +148 -0
- package/coverage/lcov-report/src/api/routes/dev.ts.html +199 -0
- package/coverage/lcov-report/{api → src/api}/routes/index.html +167 -47
- package/coverage/lcov-report/src/api/routes/index.ts.html +289 -0
- package/coverage/lcov-report/src/api/routes/integration.ts.html +133 -0
- package/coverage/lcov-report/src/api/routes/layout.ts.html +133 -0
- package/coverage/lcov-report/{api/routes/metadata.js.html → src/api/routes/metadata.ts.html} +31 -31
- package/coverage/lcov-report/{api/routes/migrations.js.html → src/api/routes/migrations.ts.html} +24 -24
- package/coverage/lcov-report/{api/routes/permission.js.html → src/api/routes/permission.ts.html} +55 -31
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +151 -0
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +541 -0
- package/coverage/lcov-report/src/api/routes/public/index.html +191 -0
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +493 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +328 -0
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +313 -0
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +598 -0
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +586 -0
- package/coverage/lcov-report/src/api/routes/public/tests/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/public/tests/utils.ts.html +169 -0
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +511 -0
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +238 -0
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +116 -0
- package/coverage/lcov-report/{api/routes/query.js.html → src/api/routes/query.ts.html} +41 -50
- package/coverage/lcov-report/src/api/routes/role.ts.html +157 -0
- package/coverage/lcov-report/{api/routes/routing.js.html → src/api/routes/routing.ts.html} +24 -24
- package/coverage/lcov-report/src/api/routes/row.ts.html +883 -0
- package/coverage/lcov-report/{api/routes/screen.js.html → src/api/routes/screen.ts.html} +43 -28
- package/coverage/lcov-report/{api/routes/script.js.html → src/api/routes/script.ts.html} +17 -17
- package/coverage/lcov-report/src/api/routes/static.ts.html +280 -0
- package/coverage/lcov-report/{api/routes/table.js.html → src/api/routes/table.ts.html} +32 -41
- package/coverage/lcov-report/src/api/routes/templates.ts.html +133 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +550 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +131 -0
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.ts.html +367 -0
- package/coverage/lcov-report/{api/routes/user.js.html → src/api/routes/user.ts.html} +35 -41
- package/coverage/lcov-report/{api → src/api}/routes/utils/index.html +15 -15
- package/coverage/lcov-report/{api/routes/utils/validators.js.html → src/api/routes/utils/validators.ts.html} +86 -98
- package/coverage/lcov-report/{api/routes/view.js.html → src/api/routes/view.ts.html} +45 -36
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +166 -0
- package/coverage/lcov-report/src/app.ts.html +406 -0
- package/coverage/lcov-report/{automations/actions.js.html → src/automations/actions.ts.html} +69 -60
- package/coverage/lcov-report/{automations/automationUtils.js.html → src/automations/automationUtils.ts.html} +36 -33
- package/coverage/lcov-report/{automations/bullboard.js.html → src/automations/bullboard.ts.html} +39 -42
- package/coverage/lcov-report/{automations → src/automations}/index.html +63 -48
- package/coverage/lcov-report/{api/routes/dev.js.html → src/automations/index.ts.html} +46 -46
- package/coverage/lcov-report/src/automations/logging/index.html +116 -0
- package/coverage/lcov-report/src/automations/logging/index.ts.html +199 -0
- package/coverage/lcov-report/{automations/steps/bash.js.html → src/automations/steps/bash.ts.html} +45 -30
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +382 -0
- package/coverage/lcov-report/{automations/steps/delay.js.html → src/automations/steps/delay.ts.html} +34 -19
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +349 -0
- package/coverage/lcov-report/{automations/steps/discord.js.html → src/automations/steps/discord.ts.html} +43 -28
- package/coverage/lcov-report/{automations/steps/executeQuery.js.html → src/automations/steps/executeQuery.ts.html} +45 -30
- package/coverage/lcov-report/{automations/steps/executeScript.js.html → src/automations/steps/executeScript.ts.html} +58 -28
- package/coverage/lcov-report/{automations/steps/filter.js.html → src/automations/steps/filter.ts.html} +39 -30
- package/coverage/lcov-report/src/automations/steps/index.html +371 -0
- package/coverage/lcov-report/{automations/steps/integromat.js.html → src/automations/steps/integromat.ts.html} +38 -23
- package/coverage/lcov-report/{automations/steps/loop.js.html → src/automations/steps/loop.ts.html} +21 -15
- package/coverage/lcov-report/{automations/steps/outgoingWebhook.js.html → src/automations/steps/outgoingWebhook.ts.html} +54 -39
- package/coverage/lcov-report/{automations/steps/queryRows.js.html → src/automations/steps/queryRows.ts.html} +102 -66
- package/coverage/lcov-report/{automations/steps/sendSmtpEmail.js.html → src/automations/steps/sendSmtpEmail.ts.html} +40 -25
- package/coverage/lcov-report/{automations/steps/serverLog.js.html → src/automations/steps/serverLog.ts.html} +40 -22
- package/coverage/lcov-report/{automations/steps/slack.js.html → src/automations/steps/slack.ts.html} +38 -23
- package/coverage/lcov-report/{automations/steps/updateRow.js.html → src/automations/steps/updateRow.ts.html} +40 -25
- package/coverage/lcov-report/{automations/steps/utils.js.html → src/automations/steps/utils.ts.html} +45 -27
- package/coverage/lcov-report/{automations/steps/zapier.js.html → src/automations/steps/zapier.ts.html} +41 -23
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +116 -0
- package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +265 -0
- package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +196 -0
- package/coverage/lcov-report/{automations/triggerInfo/cron.js.html → src/automations/triggerInfo/cron.ts.html} +30 -15
- package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.html +31 -31
- package/coverage/lcov-report/{automations/triggerInfo/index.js.html → src/automations/triggerInfo/index.ts.html} +24 -24
- package/coverage/lcov-report/{automations/triggerInfo/rowDeleted.js.html → src/automations/triggerInfo/rowDeleted.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggerInfo/rowSaved.js.html → src/automations/triggerInfo/rowSaved.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggerInfo/rowUpdated.js.html → src/automations/triggerInfo/rowUpdated.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggerInfo/webhook.js.html → src/automations/triggerInfo/webhook.ts.html} +30 -15
- package/coverage/lcov-report/{automations/triggers.js.html → src/automations/triggers.ts.html} +78 -66
- package/coverage/lcov-report/src/automations/utils.ts.html +886 -0
- package/coverage/lcov-report/{constants → src/constants}/index.html +26 -26
- package/coverage/lcov-report/src/constants/index.ts.html +697 -0
- package/coverage/lcov-report/{constants/layouts.js.html → src/constants/layouts.ts.html} +18 -36
- package/coverage/lcov-report/{constants/screens.js.html → src/constants/screens.ts.html} +64 -58
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +2059 -0
- package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +541 -0
- package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +427 -0
- package/coverage/lcov-report/src/db/defaultData/index.html +176 -0
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +403 -0
- package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +559 -0
- package/coverage/lcov-report/src/db/dynamoClient.ts.html +526 -0
- package/coverage/lcov-report/{db/inMemoryView.js.html → src/db/inMemoryView.ts.html} +47 -29
- package/coverage/lcov-report/{db → src/db}/index.html +48 -33
- package/coverage/lcov-report/{api/routes/templates.js.html → src/db/index.ts.html} +28 -28
- package/coverage/lcov-report/{db/linkedRows/LinkController.js.html → src/db/linkedRows/LinkController.ts.html} +97 -160
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +265 -0
- package/coverage/lcov-report/src/db/linkedRows/index.html +161 -0
- package/coverage/lcov-report/{db/linkedRows/index.js.html → src/db/linkedRows/index.ts.html} +93 -78
- package/coverage/lcov-report/{db/linkedRows/linkUtils.js.html → src/db/linkedRows/linkUtils.ts.html} +83 -56
- package/coverage/lcov-report/{db/newid.js.html → src/db/newid.ts.html} +14 -14
- package/coverage/lcov-report/{db/utils.js.html → src/db/utils.ts.html} +163 -211
- package/coverage/lcov-report/{automations/triggerInfo/app.js.html → src/definitions/automations.ts.html} +42 -42
- package/coverage/lcov-report/{api/routes/datasource.js.html → src/definitions/datasource.ts.html} +61 -64
- package/coverage/lcov-report/src/definitions/index.html +131 -0
- package/coverage/lcov-report/src/environment.ts.html +457 -0
- package/coverage/lcov-report/{events/AutomationEmitter.js.html → src/events/AutomationEmitter.ts.html} +40 -25
- package/coverage/lcov-report/{events/index.js.html → src/events/BudibaseEmitter.ts.html} +26 -29
- package/coverage/lcov-report/{events → src/events}/index.html +48 -33
- package/coverage/lcov-report/src/events/index.ts.html +100 -0
- package/coverage/lcov-report/src/events/utils.ts.html +319 -0
- package/coverage/lcov-report/src/index.html +191 -0
- package/coverage/lcov-report/{db/index.js.html → src/index.ts.html} +35 -35
- package/coverage/lcov-report/{utilities/queue/inMemoryQueue.js.html → src/integrations/airtable.ts.html} +213 -135
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +415 -0
- package/coverage/lcov-report/src/integrations/base/index.html +161 -0
- package/coverage/lcov-report/src/integrations/base/query.ts.html +133 -0
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +1951 -0
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +691 -0
- package/coverage/lcov-report/{api/routes/apikeys.js.html → src/integrations/base/utils.ts.html} +30 -30
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +406 -0
- package/coverage/lcov-report/{constants/index.js.html → src/integrations/dynamodb.ts.html} +263 -227
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +634 -0
- package/coverage/lcov-report/src/integrations/firebase.ts.html +646 -0
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1315 -0
- package/coverage/lcov-report/src/integrations/index.html +371 -0
- package/coverage/lcov-report/src/integrations/index.ts.html +445 -0
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1012 -0
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +1867 -0
- package/coverage/lcov-report/src/integrations/mysql.ts.html +967 -0
- package/coverage/lcov-report/src/integrations/oracle.ts.html +1387 -0
- package/coverage/lcov-report/src/integrations/postgres.ts.html +1087 -0
- package/coverage/lcov-report/src/integrations/queries/index.html +116 -0
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +463 -0
- package/coverage/lcov-report/src/integrations/redis.ts.html +550 -0
- package/coverage/lcov-report/src/integrations/rest.ts.html +1381 -0
- package/coverage/lcov-report/src/integrations/s3.ts.html +862 -0
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +376 -0
- package/coverage/lcov-report/{integrations → src/integrations}/tests/TestConfiguration.js.html +10 -10
- package/coverage/lcov-report/{integrations → src/integrations}/tests/index.html +10 -10
- package/coverage/lcov-report/src/integrations/utils.ts.html +1018 -0
- package/coverage/lcov-report/{middleware/appInfo.js.html → src/middleware/appInfo.ts.html} +33 -30
- package/coverage/lcov-report/src/middleware/authorized.ts.html +460 -0
- package/coverage/lcov-report/{middleware/builder.js.html → src/middleware/builder.ts.html} +57 -51
- package/coverage/lcov-report/{middleware/currentapp.js.html → src/middleware/currentapp.ts.html} +116 -107
- package/coverage/lcov-report/{middleware → src/middleware}/index.html +78 -63
- package/coverage/lcov-report/{middleware/joi-validator.js.html → src/middleware/joi-validator.ts.html} +25 -22
- package/coverage/lcov-report/{middleware/publicApi.js.html → src/middleware/publicApi.ts.html} +31 -31
- package/coverage/lcov-report/{middleware/resourceId.js.html → src/middleware/resourceId.ts.html} +66 -51
- package/coverage/lcov-report/{api/controllers/integration.js.html → src/middleware/selfhost.ts.html} +22 -28
- package/coverage/lcov-report/{api/routes/analytics.js.html → src/middleware/utils.ts.html} +19 -19
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +166 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +163 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +206 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +172 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +226 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +151 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +166 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +532 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +283 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +146 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +265 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +232 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +724 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +106 -0
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +235 -0
- package/coverage/lcov-report/src/migrations/functions/index.html +161 -0
- package/coverage/lcov-report/{api/routes/role.js.html → src/migrations/functions/syncQuotas.ts.html} +36 -36
- package/coverage/lcov-report/src/migrations/functions/tableSettings.ts.html +520 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +161 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +94 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +127 -0
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +115 -0
- package/coverage/lcov-report/{automations/index.js.html → src/migrations/functions/usageQuotas/syncRows.ts.html} +58 -61
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +124 -0
- package/coverage/lcov-report/{utilities/queue → src/migrations}/index.html +23 -23
- package/coverage/lcov-report/src/migrations/index.ts.html +430 -0
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +205 -0
- package/coverage/lcov-report/src/migrations/tests/index.html +131 -0
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +283 -0
- package/coverage/lcov-report/src/sdk/app/applications/index.html +146 -0
- package/coverage/lcov-report/{middleware/utils.js.html → src/sdk/app/applications/index.ts.html} +19 -19
- package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +268 -0
- package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +136 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.html +131 -0
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +214 -0
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +91 -0
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +604 -0
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +682 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.html +176 -0
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +112 -0
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +292 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.html +116 -0
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +265 -0
- package/coverage/lcov-report/{utilities/routing → src/sdk}/index.html +10 -10
- package/coverage/lcov-report/{api/routes/layout.js.html → src/sdk/index.ts.html} +24 -24
- package/coverage/lcov-report/src/sdk/users/index.html +131 -0
- package/coverage/lcov-report/src/sdk/users/index.ts.html +100 -0
- package/coverage/lcov-report/src/sdk/users/utils.ts.html +277 -0
- package/coverage/lcov-report/src/startup.ts.html +499 -0
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +1966 -0
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +127 -0
- package/coverage/lcov-report/src/tests/utilities/index.html +161 -0
- package/coverage/lcov-report/{middleware/selfhost.js.html → src/tests/utilities/index.ts.html} +33 -30
- package/coverage/lcov-report/src/tests/utilities/structures.ts.html +667 -0
- package/coverage/lcov-report/src/threads/automation.ts.html +1594 -0
- package/coverage/lcov-report/src/threads/index.html +161 -0
- package/coverage/lcov-report/src/threads/index.ts.html +418 -0
- package/coverage/lcov-report/src/threads/query.ts.html +961 -0
- package/coverage/lcov-report/src/threads/utils.ts.html +373 -0
- package/coverage/lcov-report/{utilities/budibaseDir.js.html → src/utilities/budibaseDir.ts.html} +14 -14
- package/coverage/lcov-report/{utilities/centralPath.js.html → src/utilities/centralPath.ts.html} +16 -16
- package/coverage/lcov-report/{utilities/csvParser.js.html → src/utilities/csvParser.ts.html} +107 -59
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +547 -0
- package/coverage/lcov-report/{api/controllers/table → src/utilities/fileSystem}/index.html +44 -44
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +1129 -0
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +142 -0
- package/coverage/lcov-report/{utilities/global.js.html → src/utilities/global.ts.html} +144 -111
- package/coverage/lcov-report/{utilities → src/utilities}/index.html +92 -77
- package/coverage/lcov-report/{utilities/index.js.html → src/utilities/index.ts.html} +98 -74
- package/coverage/lcov-report/{utilities/plugins.js.html → src/utilities/plugins.ts.html} +25 -22
- package/coverage/lcov-report/src/utilities/redis.ts.html +343 -0
- package/coverage/lcov-report/{api/controllers/query → src/utilities/routing}/index.html +8 -8
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +181 -0
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +146 -0
- package/coverage/lcov-report/{utilities/rowProcessor/index.js.html → src/utilities/rowProcessor/index.ts.html} +128 -359
- package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +373 -0
- package/coverage/lcov-report/{utilities/rowProcessor/utils.js.html → src/utilities/rowProcessor/utils.ts.html} +54 -42
- package/coverage/lcov-report/{utilities/scriptRunner.js.html → src/utilities/scriptRunner.ts.html} +31 -19
- package/coverage/lcov-report/{utilities/security.js.html → src/utilities/security.ts.html} +60 -78
- package/coverage/lcov-report/{utilities/statusCodes.js.html → src/utilities/statusCodes.ts.html} +11 -11
- package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/index.html +30 -30
- package/coverage/lcov-report/{utilities/usageQuota/rows.js.html → src/utilities/usageQuota/rows.ts.html} +42 -54
- package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → src/utilities/usageQuota/usageQuoteReset.ts.html} +13 -13
- package/coverage/lcov-report/{utilities/users.js.html → src/utilities/users.ts.html} +44 -50
- package/coverage/lcov-report/{utilities/workerRequests.js.html → src/utilities/workerRequests.ts.html} +127 -112
- package/coverage/lcov-report/{events/utils.js.html → src/watch.ts.html} +68 -71
- package/coverage/lcov-report/src/websocket.ts.html +163 -0
- package/coverage/lcov.info +19994 -7196
- package/dist/api/controllers/apikeys.js +12 -9
- package/dist/api/controllers/application.js +430 -446
- package/dist/api/controllers/automation.js +122 -82
- package/dist/api/controllers/cloud.js +85 -71
- package/dist/api/controllers/component.js +4 -2
- package/dist/api/controllers/datasource.js +151 -94
- package/dist/api/controllers/deploy/Deployment.js +10 -6
- package/dist/api/controllers/deploy/index.js +19 -16
- package/dist/api/controllers/dev.js +96 -81
- package/dist/api/controllers/integration.js +11 -8
- package/dist/api/controllers/layout.js +18 -15
- package/dist/api/controllers/metadata.js +51 -37
- package/dist/api/controllers/migrations.js +19 -11
- package/dist/api/controllers/permission.js +52 -43
- package/dist/api/controllers/plugin/index.js +6 -7
- package/dist/api/controllers/plugin/utils.js +2 -1
- package/dist/api/controllers/public/applications.js +17 -9
- package/dist/api/controllers/public/tables.js +29 -9
- package/dist/api/controllers/public/users.js +18 -0
- package/dist/api/controllers/public/utils.js +2 -2
- package/dist/api/controllers/query/import/index.js +1 -2
- package/dist/api/controllers/query/index.js +10 -13
- package/dist/api/controllers/query/validation.js +41 -33
- package/dist/api/controllers/role.js +29 -27
- package/dist/api/controllers/routing.js +71 -58
- package/dist/api/controllers/row/ExternalRequest.js +539 -542
- package/dist/api/controllers/row/external.js +258 -190
- package/dist/api/controllers/row/index.js +43 -14
- package/dist/api/controllers/row/internal.js +354 -295
- package/dist/api/controllers/row/internalSearch.js +95 -80
- package/dist/api/controllers/row/staticFormula.js +125 -112
- package/dist/api/controllers/row/utils.js +122 -84
- package/dist/api/controllers/screen.js +81 -66
- package/dist/api/controllers/script.js +13 -6
- package/dist/api/controllers/static/index.js +11 -14
- package/dist/api/controllers/table/bulkFormula.js +47 -35
- package/dist/api/controllers/table/external.js +89 -53
- package/dist/api/controllers/table/index.js +64 -31
- package/dist/api/controllers/table/internal.js +5 -6
- package/dist/api/controllers/table/utils.js +39 -35
- package/dist/api/controllers/templates.js +17 -10
- package/dist/api/controllers/user.js +65 -94
- package/dist/api/controllers/view/exporters.js +8 -4
- package/dist/api/controllers/view/index.js +201 -153
- package/dist/api/controllers/view/utils.js +151 -121
- package/dist/api/controllers/view/viewBuilder.js +4 -16
- package/dist/api/controllers/webhook.js +25 -2
- package/dist/api/index.js +38 -34
- package/dist/api/routes/analytics.js +29 -3
- package/dist/api/routes/apikeys.js +33 -7
- package/dist/api/routes/application.js +8 -9
- package/dist/api/routes/auth.js +1 -2
- package/dist/api/routes/automation.js +46 -20
- package/dist/api/routes/backup.js +3 -4
- package/dist/api/routes/cloud.js +32 -6
- package/dist/api/routes/component.js +32 -6
- package/dist/api/routes/datasource.js +39 -13
- package/dist/api/routes/deploy.js +34 -8
- package/dist/api/routes/dev.js +36 -10
- package/dist/api/routes/integration.js +33 -7
- package/dist/api/routes/layout.js +33 -7
- package/dist/api/routes/metadata.js +36 -10
- package/dist/api/routes/migrations.js +32 -6
- package/dist/api/routes/permission.js +38 -12
- package/dist/api/routes/plugin.js +5 -5
- package/dist/api/routes/public/index.js +11 -11
- package/dist/api/routes/public/tests/utils.js +33 -0
- package/dist/api/routes/query.js +42 -15
- package/dist/api/routes/role.js +36 -10
- package/dist/api/routes/routing.js +32 -6
- package/dist/api/routes/row.js +12 -11
- package/dist/api/routes/screen.js +35 -9
- package/dist/api/routes/script.js +32 -6
- package/dist/api/routes/static.js +9 -9
- package/dist/api/routes/table.js +40 -13
- package/dist/api/routes/templates.js +33 -7
- package/dist/api/routes/tests/utilities/TestFunctions.js +6 -8
- package/dist/api/routes/tests/utilities/index.js +69 -32
- package/dist/api/routes/user.js +40 -13
- package/dist/api/routes/utils/validators.js +142 -126
- package/dist/api/routes/view.js +38 -12
- package/dist/api/routes/webhook.js +1 -2
- package/dist/app.js +22 -22
- package/dist/automations/actions.js +53 -24
- package/dist/automations/automationUtils.js +31 -19
- package/dist/automations/bullboard.js +59 -29
- package/dist/automations/index.js +23 -18
- package/dist/automations/steps/bash.js +40 -10
- package/dist/automations/steps/createRow.js +2 -1
- package/dist/automations/steps/delay.js +9 -5
- package/dist/automations/steps/deleteRow.js +2 -1
- package/dist/automations/steps/discord.js +14 -7
- package/dist/automations/steps/executeQuery.js +34 -7
- package/dist/automations/steps/executeScript.js +34 -7
- package/dist/automations/steps/filter.js +20 -18
- package/dist/automations/steps/integromat.js +14 -7
- package/dist/automations/steps/loop.js +4 -1
- package/dist/automations/steps/outgoingWebhook.js +45 -14
- package/dist/automations/steps/queryRows.js +71 -38
- package/dist/automations/steps/sendSmtpEmail.js +33 -6
- package/dist/automations/steps/serverLog.js +12 -8
- package/dist/automations/steps/slack.js +14 -7
- package/dist/automations/steps/updateRow.js +34 -7
- package/dist/automations/steps/utils.js +22 -16
- package/dist/automations/steps/zapier.js +15 -7
- package/dist/automations/tests/utilities/index.js +62 -38
- package/dist/automations/triggerInfo/app.js +4 -1
- package/dist/automations/triggerInfo/cron.js +4 -1
- package/dist/automations/triggerInfo/index.js +31 -6
- package/dist/automations/triggerInfo/rowDeleted.js +4 -1
- package/dist/automations/triggerInfo/rowSaved.js +4 -1
- package/dist/automations/triggerInfo/rowUpdated.js +4 -1
- package/dist/automations/triggerInfo/webhook.js +4 -1
- package/dist/automations/triggers.js +90 -57
- package/dist/automations/utils.js +9 -8
- package/dist/constants/index.js +118 -104
- package/dist/constants/layouts.js +7 -10
- package/dist/constants/screens.js +49 -44
- package/dist/db/defaultData/datasource_bb_default.js +573 -0
- package/dist/db/defaultData/employeeImport.js +155 -0
- package/dist/db/defaultData/expensesImport.js +117 -0
- package/dist/db/defaultData/inventoryImport.js +109 -0
- package/dist/db/defaultData/jobsImport.js +152 -0
- package/dist/db/dynamoClient.js +20 -20
- package/dist/db/inMemoryView.js +47 -38
- package/dist/db/index.js +7 -4
- package/dist/db/linkedRows/LinkController.js +51 -70
- package/dist/db/linkedRows/LinkDocument.js +32 -0
- package/dist/db/linkedRows/index.js +93 -81
- package/dist/db/linkedRows/linkUtils.js +42 -32
- package/dist/db/utils.js +146 -119
- package/dist/db/views/staticViews.js +91 -74
- package/dist/environment.js +9 -6
- package/dist/events/AutomationEmitter.js +13 -10
- package/dist/events/BudibaseEmitter.js +24 -0
- package/dist/events/index.js +5 -23
- package/dist/events/utils.js +18 -10
- package/dist/integrations/base/types.js +2 -0
- package/dist/integrations/elasticsearch.js +26 -2
- package/dist/integrations/googlesheets.js +5 -6
- package/dist/integrations/index.js +15 -6
- package/dist/integrations/microsoftSqlServer.js +8 -3
- package/dist/integrations/oracle.js +8 -1
- package/dist/integrations/postgres.js +6 -3
- package/dist/integrations/s3.js +157 -1
- package/dist/middleware/appInfo.js +14 -9
- package/dist/middleware/authorized.js +22 -21
- package/dist/middleware/builder.js +41 -40
- package/dist/middleware/currentapp.js +39 -37
- package/dist/middleware/joi-validator.js +17 -10
- package/dist/middleware/publicApi.js +5 -6
- package/dist/middleware/resourceId.js +16 -9
- package/dist/middleware/selfhost.js +5 -4
- package/dist/middleware/utils.js +5 -2
- package/dist/migrations/functions/appUrls.js +7 -11
- package/dist/migrations/functions/backfill/global.js +1 -1
- package/dist/migrations/functions/tableSettings.js +130 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +3 -4
- package/dist/migrations/functions/usageQuotas/syncRows.js +3 -4
- package/dist/migrations/functions/userEmailViewCasing.js +3 -3
- package/dist/migrations/index.js +5 -0
- package/dist/package.json +11 -45
- package/dist/sdk/app/applications/index.js +28 -0
- package/dist/sdk/app/applications/sync.js +70 -0
- package/dist/sdk/app/applications/utils.js +21 -0
- package/dist/sdk/app/backups/exports.js +1 -2
- package/dist/sdk/app/backups/imports.js +2 -3
- package/dist/sdk/app/tables/index.js +5 -5
- package/dist/sdk/index.js +4 -2
- package/dist/sdk/users/index.js +27 -0
- package/dist/sdk/users/utils.js +65 -0
- package/dist/startup.js +10 -10
- package/dist/tests/utilities/TestConfiguration.js +111 -87
- package/dist/tests/utilities/controllers.js +38 -15
- package/dist/tests/utilities/structures.js +72 -53
- package/dist/threads/automation.js +49 -27
- package/dist/threads/query.js +17 -19
- package/dist/threads/utils.js +33 -8
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +4 -2
- package/dist/utilities/centralPath.js +14 -7
- package/dist/utilities/csvParser.js +27 -21
- package/dist/utilities/fileSystem/clientLibrary.js +87 -73
- package/dist/utilities/fileSystem/index.js +203 -175
- package/dist/utilities/fileSystem/processor.js +8 -3
- package/dist/utilities/global.js +87 -66
- package/dist/utilities/index.js +102 -75
- package/dist/utilities/plugins.js +15 -9
- package/dist/utilities/redis.js +100 -65
- package/dist/utilities/routing/index.js +27 -23
- package/dist/utilities/rowProcessor/index.js +133 -191
- package/dist/utilities/rowProcessor/map.js +99 -0
- package/dist/utilities/rowProcessor/utils.js +35 -26
- package/dist/utilities/scriptRunner.js +8 -5
- package/dist/utilities/security.js +39 -35
- package/dist/utilities/usageQuota/rows.js +56 -49
- package/dist/utilities/users.js +31 -28
- package/dist/utilities/workerRequests.js +115 -82
- package/dist/watch.js +1 -2
- package/jest.config.ts +33 -0
- package/package.json +12 -46
- package/scripts/exportAppTemplate.js +2 -2
- package/scripts/integrations/mssql/data/setup.sql +3 -3
- package/scripts/integrations/postgres/emp-skill.sql +46 -0
- package/scripts/localdomain.js +34 -6
- package/src/api/controllers/{apikeys.js → apikeys.ts} +10 -10
- package/src/api/controllers/application.ts +100 -135
- package/src/api/controllers/auth.ts +4 -3
- package/src/api/controllers/{automation.js → automation.ts} +48 -48
- package/src/api/controllers/{cloud.js → cloud.ts} +25 -24
- package/src/api/controllers/component.ts +2 -1
- package/src/api/controllers/{datasource.js → datasource.ts} +109 -49
- package/src/api/controllers/deploy/{Deployment.js → Deployment.ts} +13 -10
- package/src/api/controllers/deploy/index.ts +19 -25
- package/src/api/controllers/{dev.js → dev.ts} +31 -37
- package/src/api/controllers/integration.ts +13 -0
- package/src/api/controllers/{layout.js → layout.ts} +8 -8
- package/src/api/controllers/{metadata.js → metadata.ts} +11 -10
- package/src/api/controllers/migrations.ts +14 -0
- package/src/api/controllers/{permission.js → permission.ts} +49 -46
- package/src/api/controllers/plugin/index.ts +4 -5
- package/src/api/controllers/plugin/utils.ts +3 -5
- package/src/api/controllers/public/applications.ts +15 -9
- package/src/api/controllers/public/rows.ts +1 -1
- package/src/api/controllers/public/tables.ts +2 -2
- package/src/api/controllers/public/users.ts +25 -6
- package/src/api/controllers/public/utils.ts +2 -2
- package/src/api/controllers/query/import/index.ts +2 -3
- package/src/api/controllers/query/index.ts +11 -14
- package/src/api/controllers/query/{validation.js → validation.ts} +7 -7
- package/src/api/controllers/{role.js → role.ts} +21 -25
- package/src/api/controllers/{routing.js → routing.ts} +37 -34
- package/src/api/controllers/row/ExternalRequest.ts +605 -624
- package/src/api/controllers/row/{external.js → external.ts} +79 -62
- package/src/api/controllers/row/index.ts +19 -11
- package/src/api/controllers/row/{internal.js → internal.ts} +87 -73
- package/src/api/controllers/row/{internalSearch.js → internalSearch.ts} +92 -68
- package/src/api/controllers/row/{staticFormula.js → staticFormula.ts} +30 -25
- package/src/api/controllers/row/{utils.js → utils.ts} +32 -22
- package/src/api/controllers/screen.ts +10 -6
- package/src/api/controllers/script.ts +12 -0
- package/src/api/controllers/static/index.ts +14 -16
- package/src/api/controllers/table/{bulkFormula.js → bulkFormula.ts} +39 -25
- package/src/api/controllers/table/{external.js → external.ts} +86 -55
- package/src/api/controllers/table/{index.js → index.ts} +21 -18
- package/src/api/controllers/table/internal.ts +5 -6
- package/src/api/controllers/table/utils.ts +26 -21
- package/src/api/controllers/{templates.js → templates.ts} +10 -7
- package/src/api/controllers/{user.js → user.ts} +42 -101
- package/src/api/controllers/view/{exporters.js → exporters.ts} +5 -3
- package/src/api/controllers/view/{index.js → index.ts} +36 -27
- package/src/api/controllers/view/{utils.js → utils.ts} +26 -20
- package/src/api/controllers/view/{viewBuilder.js → viewBuilder.ts} +25 -11
- package/src/api/controllers/webhook.ts +1 -1
- package/src/api/{index.js → index.ts} +15 -22
- package/src/api/routes/analytics.ts +9 -0
- package/src/api/routes/apikeys.ts +12 -0
- package/src/api/routes/application.ts +17 -9
- package/src/api/routes/auth.ts +2 -2
- package/src/api/routes/automation.ts +87 -0
- package/src/api/routes/backup.ts +8 -4
- package/src/api/routes/cloud.ts +18 -0
- package/src/api/routes/component.ts +14 -0
- package/src/api/routes/datasource.ts +60 -0
- package/src/api/routes/deploy.ts +21 -0
- package/src/api/routes/dev.ts +38 -0
- package/src/api/routes/integration.ts +16 -0
- package/src/api/routes/layout.ts +16 -0
- package/src/api/routes/{metadata.js → metadata.ts} +13 -13
- package/src/api/routes/migrations.ts +14 -0
- package/src/api/routes/permission.ts +41 -0
- package/src/api/routes/plugin.ts +14 -6
- package/src/api/routes/public/index.ts +11 -14
- package/src/api/routes/public/tests/compare.spec.js +3 -21
- package/src/api/routes/public/tests/users.spec.js +38 -0
- package/src/api/routes/public/tests/utils.ts +28 -0
- package/src/api/routes/{query.js → query.ts} +19 -22
- package/src/api/routes/role.ts +24 -0
- package/src/api/routes/routing.ts +14 -0
- package/src/api/routes/row.ts +13 -15
- package/src/api/routes/screen.ts +23 -0
- package/src/api/routes/script.ts +10 -0
- package/src/api/routes/static.ts +7 -10
- package/src/api/routes/{table.js → table.ts} +10 -13
- package/src/api/routes/templates.ts +16 -0
- package/src/api/routes/tests/analytics.spec.js +1 -1
- package/src/api/routes/tests/application.spec.js +0 -1
- package/src/api/routes/tests/backup.spec.js +9 -1
- package/src/api/routes/tests/deployment.spec.ts +1 -1
- package/src/api/routes/tests/permissions.spec.js +2 -1
- package/src/api/routes/tests/query.spec.js +15 -10
- package/src/api/routes/tests/role.spec.js +7 -9
- package/src/api/routes/tests/routing.spec.js +2 -1
- package/src/api/routes/tests/row.spec.js +3 -4
- package/src/api/routes/tests/static.spec.js +2 -2
- package/src/api/routes/tests/table.spec.js +40 -36
- package/src/api/routes/tests/user.spec.js +2 -1
- package/src/api/routes/tests/utilities/TestFunctions.ts +6 -8
- package/src/api/routes/tests/utilities/{index.js → index.ts} +12 -12
- package/src/api/routes/tests/view.spec.js +3 -3
- package/src/api/routes/user.ts +51 -0
- package/src/api/routes/utils/{validators.js → validators.ts} +33 -37
- package/src/api/routes/view.ts +34 -0
- package/src/api/routes/webhook.ts +2 -2
- package/src/app.ts +15 -14
- package/src/automations/{actions.js → actions.ts} +26 -23
- package/src/automations/{automationUtils.js → automationUtils.ts} +13 -12
- package/src/automations/bullboard.ts +38 -0
- package/src/automations/index.ts +26 -0
- package/src/automations/steps/{bash.js → bash.ts} +13 -8
- package/src/automations/steps/createRow.ts +8 -3
- package/src/automations/steps/{delay.js → delay.ts} +9 -4
- package/src/automations/steps/deleteRow.ts +8 -3
- package/src/automations/steps/{discord.js → discord.ts} +10 -5
- package/src/automations/steps/{executeQuery.js → executeQuery.ts} +12 -7
- package/src/automations/steps/{executeScript.js → executeScript.ts} +17 -7
- package/src/automations/steps/{filter.js → filter.ts} +12 -9
- package/src/automations/steps/{integromat.js → integromat.ts} +10 -5
- package/src/automations/steps/{loop.js → loop.ts} +4 -2
- package/src/automations/steps/{outgoingWebhook.js → outgoingWebhook.ts} +18 -13
- package/src/automations/steps/{queryRows.js → queryRows.ts} +48 -36
- package/src/automations/steps/{sendSmtpEmail.js → sendSmtpEmail.ts} +10 -5
- package/src/automations/steps/{serverLog.js → serverLog.ts} +9 -3
- package/src/automations/steps/{slack.js → slack.ts} +10 -5
- package/src/automations/steps/{updateRow.js → updateRow.ts} +12 -7
- package/src/automations/steps/{utils.js → utils.ts} +10 -4
- package/src/automations/steps/{zapier.js → zapier.ts} +11 -5
- package/src/automations/tests/updateRow.spec.js +0 -1
- package/src/automations/tests/utilities/index.ts +60 -0
- package/src/automations/triggerInfo/{app.js → app.ts} +7 -2
- package/src/automations/triggerInfo/{cron.js → cron.ts} +7 -2
- package/src/automations/triggerInfo/index.ts +15 -0
- package/src/automations/triggerInfo/{rowDeleted.js → rowDeleted.ts} +7 -2
- package/src/automations/triggerInfo/{rowSaved.js → rowSaved.ts} +7 -2
- package/src/automations/triggerInfo/{rowUpdated.js → rowUpdated.ts} +7 -2
- package/src/automations/triggerInfo/{webhook.js → webhook.ts} +7 -2
- package/src/automations/{triggers.js → triggers.ts} +30 -26
- package/src/automations/utils.ts +9 -12
- package/src/constants/index.ts +204 -0
- package/src/constants/{layouts.js → layouts.ts} +3 -9
- package/src/constants/screens.ts +48 -0
- package/src/db/defaultData/datasource_bb_default.ts +658 -0
- package/src/db/defaultData/employeeImport.ts +152 -0
- package/src/db/defaultData/expensesImport.ts +114 -0
- package/src/db/defaultData/inventoryImport.ts +106 -0
- package/src/db/defaultData/jobsImport.ts +158 -0
- package/src/db/{dynamoClient.js → dynamoClient.ts} +39 -19
- package/src/db/{inMemoryView.js → inMemoryView.ts} +15 -9
- package/src/db/index.ts +16 -0
- package/src/db/linkedRows/{LinkController.js → LinkController.ts} +64 -85
- package/src/db/linkedRows/LinkDocument.ts +60 -0
- package/src/db/linkedRows/{index.js → index.ts} +43 -38
- package/src/db/linkedRows/{linkUtils.js → linkUtils.ts} +33 -24
- package/src/db/{newid.js → newid.ts} +1 -1
- package/src/db/tests/linkController.spec.js +73 -57
- package/src/db/tests/linkTests.spec.js +17 -14
- package/src/db/{utils.js → utils.ts} +77 -93
- package/src/db/views/{staticViews.js → staticViews.ts} +20 -13
- package/src/{environment.js → environment.ts} +11 -7
- package/src/events/{AutomationEmitter.js → AutomationEmitter.ts} +12 -7
- package/src/events/{index.js → BudibaseEmitter.ts} +7 -8
- package/src/events/index.ts +5 -0
- package/src/events/utils.ts +78 -0
- package/src/integrations/base/sql.ts +1 -1
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/base/types.ts +134 -0
- package/src/integrations/elasticsearch.ts +32 -2
- package/src/integrations/googlesheets.ts +5 -7
- package/src/integrations/index.ts +45 -41
- package/src/integrations/microsoftSqlServer.ts +14 -12
- package/src/integrations/mysql.ts +4 -3
- package/src/integrations/oracle.ts +17 -46
- package/src/integrations/postgres.ts +8 -2
- package/src/integrations/s3.ts +179 -3
- package/src/integrations/tests/s3.spec.ts +85 -1
- package/src/integrations/utils.ts +6 -2
- package/src/middleware/appInfo.ts +20 -0
- package/src/middleware/authorized.ts +21 -28
- package/src/middleware/{builder.js → builder.ts} +17 -15
- package/src/middleware/{currentapp.js → currentapp.ts} +42 -39
- package/src/middleware/{joi-validator.js → joi-validator.ts} +9 -8
- package/src/middleware/publicApi.ts +21 -0
- package/src/middleware/{resourceId.js → resourceId.ts} +16 -11
- package/src/middleware/{selfhost.js → selfhost.ts} +4 -2
- package/src/middleware/tests/authorized.spec.js +5 -6
- package/src/middleware/tests/currentapp.spec.js +118 -63
- package/src/middleware/{utils.js → utils.ts} +3 -1
- package/src/migrations/functions/appUrls.ts +4 -11
- package/src/migrations/functions/backfill/app/tables.ts +2 -5
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/tableSettings.ts +145 -0
- package/src/migrations/functions/tests/appUrls.spec.js +4 -4
- package/src/migrations/functions/tests/tableSettings.spec.ts +144 -0
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +14 -9
- package/src/migrations/functions/usageQuotas/syncApps.ts +3 -4
- package/src/migrations/functions/usageQuotas/syncRows.ts +4 -5
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +7 -7
- package/src/migrations/functions/userEmailViewCasing.ts +3 -3
- package/src/migrations/index.ts +9 -0
- package/src/migrations/tests/index.spec.ts +1 -1
- package/src/sdk/app/applications/index.ts +7 -0
- package/src/sdk/app/applications/sync.ts +61 -0
- package/src/sdk/app/applications/utils.ts +17 -0
- package/src/sdk/app/backups/exports.ts +5 -3
- package/src/sdk/app/backups/imports.ts +7 -14
- package/src/sdk/app/backups/statistics.ts +9 -18
- package/src/sdk/app/tables/index.ts +7 -8
- package/src/sdk/index.ts +4 -3
- package/src/sdk/users/index.ts +5 -0
- package/src/sdk/users/utils.ts +64 -0
- package/src/startup.ts +5 -5
- package/{scripts/jestSetup.js → src/tests/jestSetup.ts} +11 -2
- package/src/tests/utilities/{TestConfiguration.js → TestConfiguration.ts} +111 -78
- package/src/tests/utilities/controllers.ts +14 -0
- package/src/tests/utilities/{index.js → index.ts} +2 -2
- package/src/tests/utilities/{structures.js → structures.ts} +41 -36
- package/src/threads/automation.ts +18 -19
- package/src/threads/query.ts +11 -16
- package/src/threads/utils.ts +4 -5
- package/src/utilities/budibaseDir.ts +3 -0
- package/src/utilities/{centralPath.js → centralPath.ts} +3 -3
- package/src/utilities/{csvParser.js → csvParser.ts} +42 -26
- package/src/utilities/fileSystem/{clientLibrary.js → clientLibrary.ts} +20 -20
- package/src/utilities/fileSystem/{index.js → index.ts} +61 -65
- package/src/utilities/fileSystem/{processor.js → processor.ts} +3 -5
- package/src/utilities/global.ts +138 -0
- package/src/utilities/{index.js → index.ts} +40 -32
- package/src/utilities/{plugins.js → plugins.ts} +5 -4
- package/src/utilities/{redis.js → redis.ts} +21 -20
- package/src/utilities/routing/index.ts +32 -0
- package/src/utilities/rowProcessor/{index.js → index.ts} +67 -144
- package/src/utilities/rowProcessor/map.ts +96 -0
- package/src/utilities/rowProcessor/{utils.js → utils.ts} +19 -15
- package/src/utilities/{scriptRunner.js → scriptRunner.ts} +8 -4
- package/src/utilities/security.ts +65 -0
- package/src/utilities/{statusCodes.js → statusCodes.ts} +1 -1
- package/src/utilities/usageQuota/{rows.js → rows.ts} +14 -18
- package/src/utilities/usageQuota/{usageQuoteReset.js → usageQuoteReset.ts} +1 -1
- package/src/utilities/{users.js → users.ts} +11 -13
- package/src/utilities/{workerRequests.js → workerRequests.ts} +43 -38
- package/src/watch.ts +2 -3
- package/tsconfig.build.json +1 -2
- package/tsconfig.json +3 -1
- package/builder/assets/index.534f6c29.css +0 -6
- package/builder/assets/index.f1f9afd2.js +0 -1021
- package/coverage/lcov-report/api/controllers/index.html +0 -326
- package/coverage/lcov-report/automations/steps/index.html +0 -341
- package/coverage/lcov-report/db/linkedRows/index.html +0 -146
- package/dist/integrations/tests/TestConfiguration.js +0 -1
- package/dist/utilities/fileSystem/utilities.js +0 -22
- package/dist/utilities/queue/inMemoryQueue.js +0 -126
- package/src/api/controllers/integration.js +0 -14
- package/src/api/controllers/migrations.js +0 -13
- package/src/api/controllers/script.js +0 -11
- package/src/api/routes/analytics.js +0 -9
- package/src/api/routes/apikeys.js +0 -12
- package/src/api/routes/automation.js +0 -85
- package/src/api/routes/cloud.js +0 -14
- package/src/api/routes/component.js +0 -14
- package/src/api/routes/datasource.js +0 -51
- package/src/api/routes/deploy.js +0 -17
- package/src/api/routes/dev.js +0 -26
- package/src/api/routes/integration.js +0 -12
- package/src/api/routes/layout.js +0 -16
- package/src/api/routes/migrations.js +0 -14
- package/src/api/routes/permission.js +0 -33
- package/src/api/routes/role.js +0 -15
- package/src/api/routes/routing.js +0 -14
- package/src/api/routes/screen.js +0 -18
- package/src/api/routes/script.js +0 -10
- package/src/api/routes/templates.js +0 -16
- package/src/api/routes/user.js +0 -53
- package/src/api/routes/view.js +0 -31
- package/src/automations/bullboard.js +0 -39
- package/src/automations/index.js +0 -29
- package/src/automations/tests/utilities/index.js +0 -51
- package/src/automations/triggerInfo/index.js +0 -15
- package/src/constants/index.js +0 -208
- package/src/constants/screens.js +0 -46
- package/src/db/index.js +0 -16
- package/src/events/utils.js +0 -38
- package/src/middleware/appInfo.js +0 -19
- package/src/middleware/publicApi.js +0 -21
- package/src/module.d.ts +0 -14
- package/src/tests/utilities/controllers.js +0 -16
- package/src/utilities/budibaseDir.js +0 -3
- package/src/utilities/fileSystem/utilities.js +0 -36
- package/src/utilities/global.js +0 -127
- package/src/utilities/queue/inMemoryQueue.js +0 -122
- package/src/utilities/routing/index.js +0 -25
- package/src/utilities/security.js +0 -71
|
@@ -12,34 +12,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.updateAppPackage = exports.sync = exports.destroy = exports.revertClient = exports.updateClient = exports.update = exports.create = exports.fetchAppPackage = exports.fetchAppDefinition = exports.fetch =
|
|
15
|
+
exports.updateAppPackage = exports.sync = exports.destroy = exports.revertClient = exports.updateClient = exports.update = exports.create = exports.fetchAppPackage = exports.fetchAppDefinition = exports.fetch = void 0;
|
|
16
16
|
const environment_1 = __importDefault(require("../../environment"));
|
|
17
17
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
18
18
|
const staticViews_1 = require("../../db/views/staticViews");
|
|
19
19
|
const fileSystem_1 = require("../../utilities/fileSystem");
|
|
20
20
|
const utils_1 = require("../../db/utils");
|
|
21
|
-
const
|
|
22
|
-
const { CacheKeys, bustCache } = require("@budibase/backend-core/cache");
|
|
23
|
-
const { getAllApps, isDevAppID, getProdAppID, Replication, } = require("@budibase/backend-core/db");
|
|
21
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
24
22
|
const constants_1 = require("../../constants");
|
|
23
|
+
const datasource_bb_default_1 = require("../../db/defaultData/datasource_bb_default");
|
|
25
24
|
const workerRequests_1 = require("../../utilities/workerRequests");
|
|
26
25
|
const utilities_1 = require("../../utilities");
|
|
27
26
|
const redis_1 = require("../../utilities/redis");
|
|
28
27
|
const clientLibrary_1 = require("../../utilities/fileSystem/clientLibrary");
|
|
29
|
-
const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy");
|
|
30
|
-
const user_1 = require("./user");
|
|
31
|
-
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
32
28
|
const utils_2 = require("../../automations/utils");
|
|
33
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
34
29
|
const logging_1 = require("../../automations/logging");
|
|
35
30
|
const rows_1 = require("../../utilities/usageQuota/rows");
|
|
36
31
|
const pro_1 = require("@budibase/pro");
|
|
37
|
-
const backend_core_2 = require("@budibase/backend-core");
|
|
38
32
|
const types_1 = require("@budibase/types");
|
|
39
33
|
const layouts_1 = require("../../constants/layouts");
|
|
40
34
|
const plugins_1 = require("../../utilities/plugins");
|
|
41
35
|
const sdk_1 = __importDefault(require("../../sdk"));
|
|
42
|
-
const URL_REGEX_SLASH = /\/|\\/g;
|
|
43
36
|
// utility function, need to do away with this
|
|
44
37
|
function getLayouts() {
|
|
45
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -58,36 +51,20 @@ function getScreens() {
|
|
|
58
51
|
});
|
|
59
52
|
}
|
|
60
53
|
function getUserRoleId(ctx) {
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
var _a;
|
|
55
|
+
return !((_a = ctx.user) === null || _a === void 0 ? void 0 : _a.role) || !ctx.user.role._id
|
|
56
|
+
? backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
63
57
|
: ctx.user.role._id;
|
|
64
58
|
}
|
|
65
|
-
|
|
66
|
-
// construct the url
|
|
67
|
-
let url;
|
|
68
|
-
if (ctx.request.body.url) {
|
|
69
|
-
// if the url is provided, use that
|
|
70
|
-
url = encodeURI(ctx.request.body.url);
|
|
71
|
-
}
|
|
72
|
-
else if (ctx.request.body.name) {
|
|
73
|
-
// otherwise use the name
|
|
74
|
-
url = encodeURI(`${ctx.request.body.name}`);
|
|
75
|
-
}
|
|
76
|
-
if (url) {
|
|
77
|
-
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase();
|
|
78
|
-
}
|
|
79
|
-
return url;
|
|
80
|
-
};
|
|
81
|
-
exports.getAppUrl = getAppUrl;
|
|
82
|
-
const checkAppUrl = (ctx, apps, url, currentAppId) => {
|
|
59
|
+
function checkAppUrl(ctx, apps, url, currentAppId) {
|
|
83
60
|
if (currentAppId) {
|
|
84
61
|
apps = apps.filter((app) => app.appId !== currentAppId);
|
|
85
62
|
}
|
|
86
63
|
if (apps.some((app) => app.url === url)) {
|
|
87
64
|
ctx.throw(400, "App URL is already in use.");
|
|
88
65
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
66
|
+
}
|
|
67
|
+
function checkAppName(ctx, apps, name, currentAppId) {
|
|
91
68
|
// TODO: Replace with Joi
|
|
92
69
|
if (!name) {
|
|
93
70
|
ctx.throw(400, "Name is required");
|
|
@@ -98,10 +75,10 @@ const checkAppName = (ctx, apps, name, currentAppId) => {
|
|
|
98
75
|
if (apps.some((app) => app.name === name)) {
|
|
99
76
|
ctx.throw(400, "App name is already in use.");
|
|
100
77
|
}
|
|
101
|
-
}
|
|
102
|
-
function createInstance(template) {
|
|
78
|
+
}
|
|
79
|
+
function createInstance(template, includeSampleData) {
|
|
103
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const tenantId = isMultiTenant() ? getTenantId() : null;
|
|
81
|
+
const tenantId = backend_core_1.tenancy.isMultiTenant() ? backend_core_1.tenancy.getTenantId() : null;
|
|
105
82
|
const baseAppId = (0, utils_1.generateAppID)(tenantId);
|
|
106
83
|
const appId = (0, utils_1.generateDevAppID)(baseAppId);
|
|
107
84
|
yield backend_core_1.context.updateAppId(appId);
|
|
@@ -131,446 +108,453 @@ function createInstance(template) {
|
|
|
131
108
|
else {
|
|
132
109
|
// create the users table
|
|
133
110
|
yield db.put(constants_1.USERS_TABLE_SCHEMA);
|
|
111
|
+
if (includeSampleData) {
|
|
112
|
+
// create ootb stock db
|
|
113
|
+
yield addDefaultTables(db);
|
|
114
|
+
}
|
|
134
115
|
}
|
|
135
116
|
return { _id: appId };
|
|
136
117
|
});
|
|
137
118
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
119
|
+
function addDefaultTables(db) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
const defaultDbDocs = (0, datasource_bb_default_1.buildDefaultDocs)();
|
|
122
|
+
// add in the default db data docs - tables, datasource, rows and links
|
|
123
|
+
yield db.bulkDocs([...defaultDbDocs]);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function fetch(ctx) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const dev = ctx.query && ctx.query.status === utils_1.AppStatus.DEV;
|
|
129
|
+
const all = ctx.query && ctx.query.status === utils_1.AppStatus.ALL;
|
|
130
|
+
const apps = (yield backend_core_1.db.getAllApps({ dev, all }));
|
|
131
|
+
const appIds = apps
|
|
132
|
+
.filter((app) => app.status === "development")
|
|
133
|
+
.map((app) => app.appId);
|
|
134
|
+
// get the locks for all the dev apps
|
|
135
|
+
if (dev || all) {
|
|
136
|
+
const locks = yield (0, redis_1.getLocksById)(appIds);
|
|
137
|
+
for (let app of apps) {
|
|
138
|
+
const lock = locks[app.appId];
|
|
139
|
+
if (lock) {
|
|
140
|
+
app.lockedBy = lock;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// make sure its definitely not present
|
|
144
|
+
delete app.lockedBy;
|
|
145
|
+
}
|
|
156
146
|
}
|
|
157
147
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
148
|
+
ctx.body = yield (0, logging_1.checkAppMetadata)(apps);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
161
151
|
exports.fetch = fetch;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const accessController = new AccessController();
|
|
166
|
-
const screens = yield accessController.checkScreensAccess(yield getScreens(), userRoleId);
|
|
167
|
-
ctx.body = {
|
|
168
|
-
layouts,
|
|
169
|
-
screens,
|
|
170
|
-
libraries: ["@budibase/standard-components"],
|
|
171
|
-
};
|
|
172
|
-
});
|
|
173
|
-
exports.fetchAppDefinition = fetchAppDefinition;
|
|
174
|
-
const fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
-
const db = backend_core_1.context.getAppDB();
|
|
176
|
-
let application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
177
|
-
const layouts = yield getLayouts();
|
|
178
|
-
let screens = yield getScreens();
|
|
179
|
-
// Enrich plugin URLs
|
|
180
|
-
application.usedPlugins = (0, plugins_1.enrichPluginURLs)(application.usedPlugins);
|
|
181
|
-
// Only filter screens if the user is not a builder
|
|
182
|
-
if (!(ctx.user.builder && ctx.user.builder.global)) {
|
|
152
|
+
function fetchAppDefinition(ctx) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const layouts = yield getLayouts();
|
|
183
155
|
const userRoleId = getUserRoleId(ctx);
|
|
184
|
-
const accessController = new AccessController();
|
|
185
|
-
screens = yield accessController.checkScreensAccess(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
156
|
+
const accessController = new backend_core_1.roles.AccessController();
|
|
157
|
+
const screens = yield accessController.checkScreensAccess(yield getScreens(), userRoleId);
|
|
158
|
+
ctx.body = {
|
|
159
|
+
layouts,
|
|
160
|
+
screens,
|
|
161
|
+
libraries: ["@budibase/standard-components"],
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
exports.fetchAppDefinition = fetchAppDefinition;
|
|
166
|
+
function fetchAppPackage(ctx) {
|
|
167
|
+
var _a;
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const db = backend_core_1.context.getAppDB();
|
|
170
|
+
let application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
171
|
+
const layouts = yield getLayouts();
|
|
172
|
+
let screens = yield getScreens();
|
|
173
|
+
// Enrich plugin URLs
|
|
174
|
+
application.usedPlugins = (0, plugins_1.enrichPluginURLs)(application.usedPlugins);
|
|
175
|
+
// Only filter screens if the user is not a builder
|
|
176
|
+
if (!(((_a = ctx.user) === null || _a === void 0 ? void 0 : _a.builder) && ctx.user.builder.global)) {
|
|
177
|
+
const userRoleId = getUserRoleId(ctx);
|
|
178
|
+
const accessController = new backend_core_1.roles.AccessController();
|
|
179
|
+
screens = yield accessController.checkScreensAccess(screens, userRoleId);
|
|
180
|
+
}
|
|
181
|
+
ctx.body = {
|
|
182
|
+
application,
|
|
183
|
+
screens,
|
|
184
|
+
layouts,
|
|
185
|
+
clientLibPath: (0, utilities_1.clientLibraryPath)(ctx.params.appId, application.version),
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
}
|
|
194
189
|
exports.fetchAppPackage = fetchAppPackage;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const instance = yield createInstance(instanceConfig);
|
|
211
|
-
const appId = instance._id;
|
|
212
|
-
const db = backend_core_1.context.getAppDB();
|
|
213
|
-
let newApplication = {
|
|
214
|
-
_id: utils_1.DocumentType.APP_METADATA,
|
|
215
|
-
_rev: undefined,
|
|
216
|
-
appId,
|
|
217
|
-
type: "app",
|
|
218
|
-
version: package_json_1.default.version,
|
|
219
|
-
componentLibraries: ["@budibase/standard-components"],
|
|
220
|
-
name: name,
|
|
221
|
-
url: url,
|
|
222
|
-
template: templateKey,
|
|
223
|
-
instance,
|
|
224
|
-
tenantId: getTenantId(),
|
|
225
|
-
updatedAt: new Date().toISOString(),
|
|
226
|
-
createdAt: new Date().toISOString(),
|
|
227
|
-
status: utils_1.AppStatus.DEV,
|
|
228
|
-
navigation: {
|
|
229
|
-
navigation: "Top",
|
|
230
|
-
title: name,
|
|
231
|
-
navWidth: "Large",
|
|
232
|
-
navBackground: "var(--spectrum-global-color-gray-100)",
|
|
233
|
-
links: [
|
|
234
|
-
{
|
|
235
|
-
url: "/home",
|
|
236
|
-
text: "Home",
|
|
237
|
-
},
|
|
238
|
-
],
|
|
239
|
-
},
|
|
240
|
-
theme: "spectrum--light",
|
|
241
|
-
customTheme: {
|
|
242
|
-
buttonBorderRadius: "16px",
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
// If we used a template or imported an app there will be an existing doc.
|
|
246
|
-
// Fetch and migrate some metadata from the existing app.
|
|
247
|
-
try {
|
|
248
|
-
const existing = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
249
|
-
const keys = [
|
|
250
|
-
"_rev",
|
|
251
|
-
"navigation",
|
|
252
|
-
"theme",
|
|
253
|
-
"customTheme",
|
|
254
|
-
"icon",
|
|
255
|
-
];
|
|
256
|
-
keys.forEach(key => {
|
|
257
|
-
if (existing[key]) {
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
newApplication[key] = existing[key];
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
// Migrate navigation settings and screens if required
|
|
263
|
-
if (existing) {
|
|
264
|
-
const navigation = yield migrateAppNavigation();
|
|
265
|
-
if (navigation) {
|
|
266
|
-
newApplication.navigation = navigation;
|
|
267
|
-
}
|
|
190
|
+
function performAppCreate(ctx) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const apps = (yield backend_core_1.db.getAllApps({ dev: true }));
|
|
193
|
+
const name = ctx.request.body.name, possibleUrl = ctx.request.body.url;
|
|
194
|
+
checkAppName(ctx, apps, name);
|
|
195
|
+
const url = sdk_1.default.applications.getAppUrl({ name, url: possibleUrl });
|
|
196
|
+
checkAppUrl(ctx, apps, url);
|
|
197
|
+
const { useTemplate, templateKey, templateString } = ctx.request.body;
|
|
198
|
+
const instanceConfig = {
|
|
199
|
+
useTemplate,
|
|
200
|
+
key: templateKey,
|
|
201
|
+
templateString,
|
|
202
|
+
};
|
|
203
|
+
if (ctx.request.files && ctx.request.files.templateFile) {
|
|
204
|
+
instanceConfig.file = ctx.request.files.templateFile;
|
|
268
205
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
206
|
+
const includeSampleData = (0, utilities_1.isQsTrue)(ctx.request.body.sampleData);
|
|
207
|
+
const instance = yield createInstance(instanceConfig, includeSampleData);
|
|
208
|
+
const appId = instance._id;
|
|
209
|
+
const db = backend_core_1.context.getAppDB();
|
|
210
|
+
let newApplication = {
|
|
211
|
+
_id: utils_1.DocumentType.APP_METADATA,
|
|
212
|
+
_rev: undefined,
|
|
213
|
+
appId,
|
|
214
|
+
type: "app",
|
|
215
|
+
version: package_json_1.default.version,
|
|
216
|
+
componentLibraries: ["@budibase/standard-components"],
|
|
217
|
+
name: name,
|
|
218
|
+
url: url,
|
|
219
|
+
template: templateKey,
|
|
220
|
+
instance,
|
|
221
|
+
tenantId: backend_core_1.tenancy.getTenantId(),
|
|
222
|
+
updatedAt: new Date().toISOString(),
|
|
223
|
+
createdAt: new Date().toISOString(),
|
|
224
|
+
status: utils_1.AppStatus.DEV,
|
|
225
|
+
navigation: {
|
|
226
|
+
navigation: "Top",
|
|
227
|
+
title: name,
|
|
228
|
+
navWidth: "Large",
|
|
229
|
+
navBackground: "var(--spectrum-global-color-gray-100)",
|
|
230
|
+
links: [
|
|
231
|
+
{
|
|
232
|
+
url: "/home",
|
|
233
|
+
text: "Home",
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
theme: "spectrum--light",
|
|
238
|
+
customTheme: {
|
|
239
|
+
buttonBorderRadius: "16px",
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
// If we used a template or imported an app there will be an existing doc.
|
|
243
|
+
// Fetch and migrate some metadata from the existing app.
|
|
244
|
+
try {
|
|
245
|
+
const existing = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
246
|
+
const keys = [
|
|
247
|
+
"_rev",
|
|
248
|
+
"navigation",
|
|
249
|
+
"theme",
|
|
250
|
+
"customTheme",
|
|
251
|
+
"icon",
|
|
252
|
+
];
|
|
253
|
+
keys.forEach(key => {
|
|
254
|
+
if (existing[key]) {
|
|
255
|
+
// @ts-ignore
|
|
256
|
+
newApplication[key] = existing[key];
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
// Migrate navigation settings and screens if required
|
|
260
|
+
if (existing) {
|
|
261
|
+
const navigation = yield migrateAppNavigation();
|
|
262
|
+
if (navigation) {
|
|
263
|
+
newApplication.navigation = navigation;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
290
266
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
creationFns.push(a => backend_core_2.events.app.fileImported(a));
|
|
267
|
+
catch (err) {
|
|
268
|
+
// Nothing to do
|
|
294
269
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
270
|
+
const response = yield db.put(newApplication, { force: true });
|
|
271
|
+
newApplication._rev = response.rev;
|
|
272
|
+
/* istanbul ignore next */
|
|
273
|
+
if (!environment_1.default.isTest()) {
|
|
274
|
+
yield (0, fileSystem_1.createApp)(appId);
|
|
298
275
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
for (let fn of creationFns) {
|
|
302
|
-
yield fn(app);
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
const appPostCreate = (ctx, app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
306
|
-
const tenantId = getTenantId();
|
|
307
|
-
yield backend_core_2.migrations.backPopulateMigrations({
|
|
308
|
-
type: types_1.MigrationType.APP,
|
|
309
|
-
tenantId,
|
|
310
|
-
appId: app.appId,
|
|
276
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(appId, newApplication);
|
|
277
|
+
return newApplication;
|
|
311
278
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
279
|
+
}
|
|
280
|
+
function creationEvents(request, app) {
|
|
281
|
+
var _a;
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
let creationFns = [];
|
|
284
|
+
const body = request.body;
|
|
285
|
+
if (body.useTemplate === "true") {
|
|
286
|
+
// from template
|
|
287
|
+
if (body.templateKey && body.templateKey !== "undefined") {
|
|
288
|
+
creationFns.push(a => backend_core_1.events.app.templateImported(a, body.templateKey));
|
|
289
|
+
}
|
|
290
|
+
// from file
|
|
291
|
+
else if ((_a = request.files) === null || _a === void 0 ? void 0 : _a.templateFile) {
|
|
292
|
+
creationFns.push(a => backend_core_1.events.app.fileImported(a));
|
|
320
293
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
294
|
+
// unknown
|
|
295
|
+
else {
|
|
296
|
+
console.error("Could not determine template creation event");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
creationFns.push(a => backend_core_1.events.app.created(a));
|
|
300
|
+
for (let fn of creationFns) {
|
|
301
|
+
yield fn(app);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function appPostCreate(ctx, app) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
308
|
+
yield backend_core_1.migrations.backPopulateMigrations({
|
|
309
|
+
type: types_1.MigrationType.APP,
|
|
310
|
+
tenantId,
|
|
311
|
+
appId: app.appId,
|
|
312
|
+
});
|
|
313
|
+
yield creationEvents(ctx.request, app);
|
|
314
|
+
// app import & template creation
|
|
315
|
+
if (ctx.request.body.useTemplate === "true") {
|
|
316
|
+
const { rows } = yield (0, rows_1.getUniqueRows)([app.appId]);
|
|
317
|
+
const rowCount = rows ? rows.length : 0;
|
|
318
|
+
if (rowCount) {
|
|
319
|
+
try {
|
|
320
|
+
yield backend_core_1.context.doInAppContext(app.appId, () => {
|
|
321
|
+
return pro_1.quotas.addRows(rowCount);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
catch (err) {
|
|
325
|
+
if (err.code && err.code === backend_core_1.errors.codes.USAGE_LIMIT_EXCEEDED) {
|
|
326
|
+
// this import resulted in row usage exceeding the quota
|
|
327
|
+
// delete the app
|
|
328
|
+
// skip pre- and post-steps as no rows have been added to quotas yet
|
|
329
|
+
ctx.params.appId = app.appId;
|
|
330
|
+
yield destroyApp(ctx);
|
|
331
|
+
}
|
|
332
|
+
throw err;
|
|
328
333
|
}
|
|
329
|
-
throw err;
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function create(ctx) {
|
|
339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
340
|
+
const newApplication = yield pro_1.quotas.addApp(() => performAppCreate(ctx));
|
|
341
|
+
yield appPostCreate(ctx, newApplication);
|
|
342
|
+
yield backend_core_1.cache.bustCache(backend_core_1.cache.CacheKey.CHECKLIST);
|
|
343
|
+
ctx.body = newApplication;
|
|
344
|
+
ctx.status = 200;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
341
347
|
exports.create = create;
|
|
342
348
|
// This endpoint currently operates as a PATCH rather than a PUT
|
|
343
349
|
// Thus name and url fields are handled only if present
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
ctx.body = app;
|
|
360
|
-
});
|
|
361
|
-
exports.update = update;
|
|
362
|
-
const updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
363
|
-
// Get current app version
|
|
364
|
-
const db = backend_core_1.context.getAppDB();
|
|
365
|
-
const application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
366
|
-
const currentVersion = application.version;
|
|
367
|
-
// Update client library and manifest
|
|
368
|
-
if (!environment_1.default.isTest()) {
|
|
369
|
-
yield (0, clientLibrary_1.backupClientLibrary)(ctx.params.appId);
|
|
370
|
-
yield (0, clientLibrary_1.updateClientLibrary)(ctx.params.appId);
|
|
371
|
-
}
|
|
372
|
-
// Update versions in app package
|
|
373
|
-
const updatedToVersion = package_json_1.default.version;
|
|
374
|
-
const appPackageUpdates = {
|
|
375
|
-
version: updatedToVersion,
|
|
376
|
-
revertableVersion: currentVersion,
|
|
377
|
-
};
|
|
378
|
-
const app = yield (0, exports.updateAppPackage)(appPackageUpdates, ctx.params.appId);
|
|
379
|
-
yield backend_core_2.events.app.versionUpdated(app, currentVersion, updatedToVersion);
|
|
380
|
-
ctx.status = 200;
|
|
381
|
-
ctx.body = app;
|
|
382
|
-
});
|
|
383
|
-
exports.updateClient = updateClient;
|
|
384
|
-
const revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
385
|
-
// Check app can be reverted
|
|
386
|
-
const db = backend_core_1.context.getAppDB();
|
|
387
|
-
const application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
388
|
-
if (!application.revertableVersion) {
|
|
389
|
-
ctx.throw(400, "There is no version to revert to");
|
|
390
|
-
}
|
|
391
|
-
// Update client library and manifest
|
|
392
|
-
if (!environment_1.default.isTest()) {
|
|
393
|
-
yield (0, clientLibrary_1.revertClientLibrary)(ctx.params.appId);
|
|
394
|
-
}
|
|
395
|
-
// Update versions in app package
|
|
396
|
-
const currentVersion = application.version;
|
|
397
|
-
const revertedToVersion = application.revertableVersion;
|
|
398
|
-
const appPackageUpdates = {
|
|
399
|
-
version: revertedToVersion,
|
|
400
|
-
revertableVersion: null,
|
|
401
|
-
};
|
|
402
|
-
const app = yield (0, exports.updateAppPackage)(appPackageUpdates, ctx.params.appId);
|
|
403
|
-
yield backend_core_2.events.app.versionReverted(app, currentVersion, revertedToVersion);
|
|
404
|
-
ctx.status = 200;
|
|
405
|
-
ctx.body = app;
|
|
406
|
-
});
|
|
407
|
-
exports.revertClient = revertClient;
|
|
408
|
-
const destroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
409
|
-
let appId = ctx.params.appId;
|
|
410
|
-
let isUnpublish = ctx.query && ctx.query.unpublish;
|
|
411
|
-
if (isUnpublish) {
|
|
412
|
-
appId = getProdAppID(appId);
|
|
413
|
-
}
|
|
414
|
-
const db = isUnpublish ? backend_core_1.context.getProdAppDB() : backend_core_1.context.getAppDB();
|
|
415
|
-
const app = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
416
|
-
const result = yield db.destroy();
|
|
417
|
-
if (isUnpublish) {
|
|
418
|
-
yield backend_core_2.events.app.unpublished(app);
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
yield pro_1.quotas.removeApp();
|
|
422
|
-
yield backend_core_2.events.app.deleted(app);
|
|
423
|
-
}
|
|
424
|
-
/* istanbul ignore next */
|
|
425
|
-
if (!environment_1.default.isTest() && !isUnpublish) {
|
|
426
|
-
yield (0, fileSystem_1.deleteApp)(appId);
|
|
427
|
-
}
|
|
428
|
-
// automations only in production
|
|
429
|
-
if (isUnpublish) {
|
|
430
|
-
yield (0, utils_2.cleanupAutomations)(appId);
|
|
431
|
-
}
|
|
432
|
-
// remove app role when the dev app is deleted (no trace of app anymore)
|
|
433
|
-
else {
|
|
434
|
-
yield (0, workerRequests_1.removeAppFromUserRoles)(ctx, appId);
|
|
435
|
-
}
|
|
436
|
-
yield appCache.invalidateAppMetadata(appId);
|
|
437
|
-
return result;
|
|
438
|
-
});
|
|
439
|
-
const preDestroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
440
|
-
const { rows } = yield (0, rows_1.getUniqueRows)([ctx.params.appId]);
|
|
441
|
-
ctx.rowCount = rows.length;
|
|
442
|
-
});
|
|
443
|
-
const postDestroyApp = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
444
|
-
const rowCount = ctx.rowCount;
|
|
445
|
-
yield pro_1.groups.cleanupApp(ctx.params.appId);
|
|
446
|
-
if (rowCount) {
|
|
447
|
-
yield pro_1.quotas.removeRows(rowCount);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
const destroy = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
451
|
-
yield preDestroyApp(ctx);
|
|
452
|
-
const result = yield destroyApp(ctx);
|
|
453
|
-
yield postDestroyApp(ctx);
|
|
454
|
-
ctx.status = 200;
|
|
455
|
-
ctx.body = result;
|
|
456
|
-
});
|
|
457
|
-
exports.destroy = destroy;
|
|
458
|
-
const sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
459
|
-
if (environment_1.default.DISABLE_AUTO_PROD_APP_SYNC) {
|
|
350
|
+
function update(ctx) {
|
|
351
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
352
|
+
const apps = (yield backend_core_1.db.getAllApps({ dev: true }));
|
|
353
|
+
// validation
|
|
354
|
+
const name = ctx.request.body.name, possibleUrl = ctx.request.body.url;
|
|
355
|
+
if (name) {
|
|
356
|
+
checkAppName(ctx, apps, name, ctx.params.appId);
|
|
357
|
+
}
|
|
358
|
+
const url = sdk_1.default.applications.getAppUrl({ name, url: possibleUrl });
|
|
359
|
+
if (url) {
|
|
360
|
+
checkAppUrl(ctx, apps, url, ctx.params.appId);
|
|
361
|
+
ctx.request.body.url = url;
|
|
362
|
+
}
|
|
363
|
+
const app = yield updateAppPackage(ctx.request.body, ctx.params.appId);
|
|
364
|
+
yield backend_core_1.events.app.updated(app);
|
|
460
365
|
ctx.status = 200;
|
|
461
|
-
ctx.body =
|
|
462
|
-
|
|
366
|
+
ctx.body = app;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
exports.update = update;
|
|
370
|
+
function updateClient(ctx) {
|
|
371
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
372
|
+
// Get current app version
|
|
373
|
+
const db = backend_core_1.context.getAppDB();
|
|
374
|
+
const application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
375
|
+
const currentVersion = application.version;
|
|
376
|
+
// Update client library and manifest
|
|
377
|
+
if (!environment_1.default.isTest()) {
|
|
378
|
+
yield (0, clientLibrary_1.backupClientLibrary)(ctx.params.appId);
|
|
379
|
+
yield (0, clientLibrary_1.updateClientLibrary)(ctx.params.appId);
|
|
380
|
+
}
|
|
381
|
+
// Update versions in app package
|
|
382
|
+
const updatedToVersion = package_json_1.default.version;
|
|
383
|
+
const appPackageUpdates = {
|
|
384
|
+
version: updatedToVersion,
|
|
385
|
+
revertableVersion: currentVersion,
|
|
463
386
|
};
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const appId = ctx.params.appId;
|
|
467
|
-
if (!isDevAppID(appId)) {
|
|
468
|
-
ctx.throw(400, "This action cannot be performed for production apps");
|
|
469
|
-
}
|
|
470
|
-
// replicate prod to dev
|
|
471
|
-
const prodAppId = getProdAppID(appId);
|
|
472
|
-
try {
|
|
473
|
-
// specific case, want to make sure setup is skipped
|
|
474
|
-
const prodDb = backend_core_1.context.getProdAppDB({ skip_setup: true });
|
|
475
|
-
const info = yield prodDb.info();
|
|
476
|
-
if (info.error)
|
|
477
|
-
throw info.error;
|
|
478
|
-
}
|
|
479
|
-
catch (err) {
|
|
480
|
-
// the database doesn't exist. Don't replicate
|
|
387
|
+
const app = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
388
|
+
yield backend_core_1.events.app.versionUpdated(app, currentVersion, updatedToVersion);
|
|
481
389
|
ctx.status = 200;
|
|
482
|
-
ctx.body =
|
|
483
|
-
message: "App sync not required, app not deployed.",
|
|
484
|
-
};
|
|
485
|
-
return next();
|
|
486
|
-
}
|
|
487
|
-
const replication = new Replication({
|
|
488
|
-
source: prodAppId,
|
|
489
|
-
target: appId,
|
|
390
|
+
ctx.body = app;
|
|
490
391
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
error = err;
|
|
497
|
-
}
|
|
498
|
-
finally {
|
|
499
|
-
yield replication.close();
|
|
500
|
-
}
|
|
501
|
-
// sync the users
|
|
502
|
-
yield (0, user_1.syncGlobalUsers)();
|
|
503
|
-
if (error) {
|
|
504
|
-
ctx.throw(400, error);
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
ctx.body = {
|
|
508
|
-
message: "App sync completed successfully.",
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
exports.sync = sync;
|
|
513
|
-
const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
514
|
-
return backend_core_1.context.doInAppContext(appId, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
392
|
+
}
|
|
393
|
+
exports.updateClient = updateClient;
|
|
394
|
+
function revertClient(ctx) {
|
|
395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
396
|
+
// Check app can be reverted
|
|
515
397
|
const db = backend_core_1.context.getAppDB();
|
|
516
398
|
const application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
newAppPackage._rev = application._rev;
|
|
399
|
+
if (!application.revertableVersion) {
|
|
400
|
+
ctx.throw(400, "There is no version to revert to");
|
|
520
401
|
}
|
|
521
|
-
//
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
yield db.put(newAppPackage);
|
|
525
|
-
// remove any cached metadata, so that it will be updated
|
|
526
|
-
yield appCache.invalidateAppMetadata(appId);
|
|
527
|
-
return newAppPackage;
|
|
528
|
-
}));
|
|
529
|
-
});
|
|
530
|
-
exports.updateAppPackage = updateAppPackage;
|
|
531
|
-
const migrateAppNavigation = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
532
|
-
const db = backend_core_1.context.getAppDB();
|
|
533
|
-
const existing = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
534
|
-
const layouts = yield getLayouts();
|
|
535
|
-
const screens = yield getScreens();
|
|
536
|
-
// Migrate all screens, removing custom layouts
|
|
537
|
-
for (let screen of screens) {
|
|
538
|
-
if (!screen.layoutId) {
|
|
539
|
-
continue;
|
|
402
|
+
// Update client library and manifest
|
|
403
|
+
if (!environment_1.default.isTest()) {
|
|
404
|
+
yield (0, clientLibrary_1.revertClientLibrary)(ctx.params.appId);
|
|
540
405
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
// Migrate layout navigation settings
|
|
548
|
-
const { name, customTheme } = existing;
|
|
549
|
-
const layout = layouts === null || layouts === void 0 ? void 0 : layouts.find((layout) => layout._id === layouts_1.BASE_LAYOUT_PROP_IDS.PRIVATE);
|
|
550
|
-
if (layout && !existing.navigation) {
|
|
551
|
-
let navigationSettings = {
|
|
552
|
-
navigation: "Top",
|
|
553
|
-
title: name,
|
|
554
|
-
navWidth: "Large",
|
|
555
|
-
navBackground: (customTheme === null || customTheme === void 0 ? void 0 : customTheme.navBackground) || "var(--spectrum-global-color-gray-50)",
|
|
556
|
-
navTextColor: (customTheme === null || customTheme === void 0 ? void 0 : customTheme.navTextColor) || "var(--spectrum-global-color-gray-800)",
|
|
406
|
+
// Update versions in app package
|
|
407
|
+
const currentVersion = application.version;
|
|
408
|
+
const revertedToVersion = application.revertableVersion;
|
|
409
|
+
const appPackageUpdates = {
|
|
410
|
+
version: revertedToVersion,
|
|
411
|
+
revertableVersion: null,
|
|
557
412
|
};
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
413
|
+
const app = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
414
|
+
yield backend_core_1.events.app.versionReverted(app, currentVersion, revertedToVersion);
|
|
415
|
+
ctx.status = 200;
|
|
416
|
+
ctx.body = app;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
exports.revertClient = revertClient;
|
|
420
|
+
function destroyApp(ctx) {
|
|
421
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
422
|
+
let appId = ctx.params.appId;
|
|
423
|
+
let isUnpublish = ctx.query && ctx.query.unpublish;
|
|
424
|
+
if (isUnpublish) {
|
|
425
|
+
appId = backend_core_1.db.getProdAppID(appId);
|
|
426
|
+
const devAppId = backend_core_1.db.getDevAppID(appId);
|
|
427
|
+
// sync before removing the published app
|
|
428
|
+
yield sdk_1.default.applications.syncApp(devAppId);
|
|
429
|
+
}
|
|
430
|
+
const db = isUnpublish ? backend_core_1.context.getProdAppDB() : backend_core_1.context.getAppDB();
|
|
431
|
+
const app = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
432
|
+
const result = yield db.destroy();
|
|
433
|
+
if (isUnpublish) {
|
|
434
|
+
yield backend_core_1.events.app.unpublished(app);
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
yield pro_1.quotas.removeApp();
|
|
438
|
+
yield backend_core_1.events.app.deleted(app);
|
|
439
|
+
}
|
|
440
|
+
/* istanbul ignore next */
|
|
441
|
+
if (!environment_1.default.isTest() && !isUnpublish) {
|
|
442
|
+
yield (0, fileSystem_1.deleteApp)(appId);
|
|
443
|
+
}
|
|
444
|
+
// automations only in production
|
|
445
|
+
if (isUnpublish) {
|
|
446
|
+
yield (0, utils_2.cleanupAutomations)(appId);
|
|
447
|
+
}
|
|
448
|
+
// remove app role when the dev app is deleted (no trace of app anymore)
|
|
449
|
+
else {
|
|
450
|
+
yield (0, workerRequests_1.removeAppFromUserRoles)(ctx, appId);
|
|
451
|
+
}
|
|
452
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(appId);
|
|
453
|
+
return result;
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function preDestroyApp(ctx) {
|
|
457
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
458
|
+
const { rows } = yield (0, rows_1.getUniqueRows)([ctx.params.appId]);
|
|
459
|
+
ctx.rowCount = rows.length;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function postDestroyApp(ctx) {
|
|
463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
464
|
+
const rowCount = ctx.rowCount;
|
|
465
|
+
yield pro_1.groups.cleanupApp(ctx.params.appId);
|
|
466
|
+
if (rowCount) {
|
|
467
|
+
yield pro_1.quotas.removeRows(rowCount);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
function destroy(ctx) {
|
|
472
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
473
|
+
yield preDestroyApp(ctx);
|
|
474
|
+
const result = yield destroyApp(ctx);
|
|
475
|
+
yield postDestroyApp(ctx);
|
|
476
|
+
ctx.status = 200;
|
|
477
|
+
ctx.body = result;
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
exports.destroy = destroy;
|
|
481
|
+
function sync(ctx) {
|
|
482
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
483
|
+
const appId = ctx.params.appId;
|
|
484
|
+
try {
|
|
485
|
+
ctx.body = yield sdk_1.default.applications.syncApp(appId);
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
ctx.throw(err.status || 400, err.message);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
exports.sync = sync;
|
|
493
|
+
function updateAppPackage(appPackage, appId) {
|
|
494
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
495
|
+
return backend_core_1.context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
496
|
+
const db = backend_core_1.context.getAppDB();
|
|
497
|
+
const application = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
498
|
+
const newAppPackage = Object.assign(Object.assign({}, application), appPackage);
|
|
499
|
+
if (appPackage._rev !== application._rev) {
|
|
500
|
+
newAppPackage._rev = application._rev;
|
|
501
|
+
}
|
|
502
|
+
// the locked by property is attached by server but generated from
|
|
503
|
+
// Redis, shouldn't ever store it
|
|
504
|
+
delete newAppPackage.lockedBy;
|
|
505
|
+
yield db.put(newAppPackage);
|
|
506
|
+
// remove any cached metadata, so that it will be updated
|
|
507
|
+
yield backend_core_1.cache.app.invalidateAppMetadata(appId);
|
|
508
|
+
return newAppPackage;
|
|
509
|
+
}));
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
exports.updateAppPackage = updateAppPackage;
|
|
513
|
+
function migrateAppNavigation() {
|
|
514
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
515
|
+
const db = backend_core_1.context.getAppDB();
|
|
516
|
+
const existing = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
517
|
+
const layouts = yield getLayouts();
|
|
518
|
+
const screens = yield getScreens();
|
|
519
|
+
// Migrate all screens, removing custom layouts
|
|
520
|
+
for (let screen of screens) {
|
|
521
|
+
if (!screen.layoutId) {
|
|
522
|
+
continue;
|
|
569
523
|
}
|
|
524
|
+
const layout = layouts.find(layout => layout._id === screen.layoutId);
|
|
525
|
+
screen.layoutId = undefined;
|
|
526
|
+
screen.showNavigation = (layout === null || layout === void 0 ? void 0 : layout.props.navigation) !== "None";
|
|
527
|
+
screen.width = (layout === null || layout === void 0 ? void 0 : layout.props.width) || "Large";
|
|
528
|
+
yield db.put(screen);
|
|
570
529
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
530
|
+
// Migrate layout navigation settings
|
|
531
|
+
const { name, customTheme } = existing;
|
|
532
|
+
const layout = layouts === null || layouts === void 0 ? void 0 : layouts.find((layout) => layout._id === layouts_1.BASE_LAYOUT_PROP_IDS.PRIVATE);
|
|
533
|
+
if (layout && !existing.navigation) {
|
|
534
|
+
let navigationSettings = {
|
|
535
|
+
navigation: "Top",
|
|
536
|
+
title: name,
|
|
537
|
+
navWidth: "Large",
|
|
538
|
+
navBackground: (customTheme === null || customTheme === void 0 ? void 0 : customTheme.navBackground) || "var(--spectrum-global-color-gray-50)",
|
|
539
|
+
navTextColor: (customTheme === null || customTheme === void 0 ? void 0 : customTheme.navTextColor) || "var(--spectrum-global-color-gray-800)",
|
|
540
|
+
};
|
|
541
|
+
if (layout) {
|
|
542
|
+
navigationSettings.hideLogo = layout.props.hideLogo;
|
|
543
|
+
navigationSettings.hideTitle = layout.props.hideTitle;
|
|
544
|
+
navigationSettings.title = layout.props.title || name;
|
|
545
|
+
navigationSettings.logoUrl = layout.props.logoUrl;
|
|
546
|
+
navigationSettings.links = layout.props.links;
|
|
547
|
+
navigationSettings.navigation = layout.props.navigation || "Top";
|
|
548
|
+
navigationSettings.sticky = layout.props.sticky;
|
|
549
|
+
navigationSettings.navWidth = layout.props.width || "Large";
|
|
550
|
+
if (navigationSettings.navigation === "None") {
|
|
551
|
+
navigationSettings.navigation = "Top";
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return navigationSettings;
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|