@budibase/server 1.0.49-alpha.9 → 1.0.49
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__/arangojs.ts +1 -1
- package/__mocks__/aws-sdk.ts +4 -4
- package/__mocks__/mongodb.ts +5 -4
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +1 -2
- package/__mocks__/pg.ts +5 -3
- package/builder/assets/{index.ad5370ae.js → index.2c37968e.js} +246 -249
- package/builder/assets/index.39e01193.css +1 -0
- package/builder/assets/{vendor.d526bfe8.js → vendor.f9faf6ab.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2827 -3117
- package/coverage/coverage-final.json +101 -106
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +152 -257
- package/coverage/lcov-report/api/controllers/auth.js.html +13 -22
- package/coverage/lcov-report/api/controllers/automation.js.html +69 -39
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -8
- package/coverage/lcov-report/api/controllers/component.js.html +16 -13
- package/coverage/lcov-report/api/controllers/datasource.js.html +51 -81
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → api/controllers/hosting.js.html} +48 -36
- package/coverage/lcov-report/api/controllers/index.html +76 -76
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
- package/coverage/lcov-report/api/controllers/metadata.js.html +21 -6
- package/coverage/lcov-report/api/controllers/permission.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.html +10 -10
- package/coverage/lcov-report/api/controllers/query/index.js.html +35 -38
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +16 -16
- package/coverage/lcov-report/api/controllers/routing.js.html +10 -7
- package/coverage/lcov-report/api/controllers/row/external.js.html +141 -48
- package/coverage/lcov-report/api/controllers/row/index.html +40 -55
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +226 -118
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +34 -52
- package/coverage/lcov-report/api/controllers/row/utils.js.html +62 -47
- package/coverage/lcov-report/api/controllers/screen.js.html +21 -15
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/external.js.html +34 -25
- package/coverage/lcov-report/api/controllers/table/index.html +43 -58
- package/coverage/lcov-report/api/controllers/table/index.js.html +82 -58
- package/coverage/lcov-report/api/controllers/table/internal.js.html +66 -81
- package/coverage/lcov-report/api/controllers/table/utils.js.html +110 -218
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +50 -47
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +16 -16
- package/coverage/lcov-report/api/controllers/view/index.js.html +33 -27
- package/coverage/lcov-report/api/controllers/view/utils.js.html +20 -35
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +28 -34
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +8 -8
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/{migrations.js.html → hosting.js.html} +14 -17
- package/coverage/lcov-report/api/routes/index.html +18 -18
- package/coverage/lcov-report/api/routes/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +2 -17
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +10 -7
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +22 -13
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +20 -11
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +13 -13
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +55 -61
- package/coverage/lcov-report/automations/utils.js.html +42 -54
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +26 -53
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +37 -25
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +96 -51
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +42 -42
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -87
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +120 -135
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +65 -173
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +83 -95
- package/coverage/lcov-report/middleware/index.html +38 -38
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +53 -281
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +24 -30
- package/coverage/lcov-report/threads/index.html +26 -26
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +24 -39
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +49 -58
- package/coverage/lcov-report/utilities/index.html +37 -37
- package/coverage/lcov-report/utilities/index.js.html +73 -43
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
- package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +103 -97
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +27 -75
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +9 -9
- package/coverage/lcov-report/utilities/workerRequests.js.html +112 -43
- package/coverage/lcov.info +4431 -5013
- package/dist/api/controllers/application.js +60 -90
- package/dist/api/controllers/auth.js +5 -8
- package/dist/api/controllers/automation.js +19 -14
- package/dist/api/controllers/cloud.js +3 -2
- package/dist/api/controllers/component.js +4 -3
- package/dist/api/controllers/datasource.js +10 -20
- package/dist/api/controllers/deploy/Deployment.js +6 -3
- package/dist/api/controllers/deploy/index.js +13 -12
- package/dist/api/controllers/dev.js +5 -5
- package/dist/api/controllers/hosting.js +30 -0
- package/dist/api/controllers/layout.js +3 -3
- package/dist/api/controllers/metadata.js +4 -4
- package/dist/api/controllers/permission.js +4 -4
- package/dist/api/controllers/query/import/index.js +6 -4
- package/dist/api/controllers/query/index.js +10 -11
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +6 -5
- package/dist/api/controllers/row/ExternalRequest.js +67 -90
- package/dist/api/controllers/row/external.js +22 -14
- package/dist/api/controllers/row/internal.js +93 -55
- package/dist/api/controllers/row/internalSearch.js +17 -23
- package/dist/api/controllers/row/utils.js +14 -13
- package/dist/api/controllers/screen.js +7 -5
- package/dist/api/controllers/static/index.js +12 -61
- package/dist/api/controllers/table/external.js +10 -7
- package/dist/api/controllers/table/index.js +13 -16
- package/dist/api/controllers/table/internal.js +16 -22
- package/dist/api/controllers/table/utils.js +35 -62
- package/dist/api/controllers/user.js +20 -18
- package/dist/api/controllers/view/index.js +10 -8
- package/dist/api/controllers/view/utils.js +4 -9
- package/dist/api/controllers/webhook.js +8 -10
- package/dist/api/routes/hosting.js +11 -0
- package/dist/api/routes/index.js +2 -2
- package/dist/api/routes/static.js +1 -2
- package/dist/api/routes/tests/utilities/TestFunctions.js +17 -37
- package/dist/app.js +5 -35
- package/dist/automations/automationUtils.js +3 -2
- package/dist/automations/steps/createRow.js +5 -3
- package/dist/automations/steps/deleteRow.js +4 -1
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +25 -27
- package/dist/automations/utils.js +5 -10
- package/dist/constants/index.js +0 -7
- package/dist/db/linkedRows/LinkController.js +7 -3
- package/dist/db/linkedRows/index.js +27 -16
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +10 -9
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +1 -4
- package/dist/integrations/base/sql.js +14 -56
- package/dist/integrations/index.js +0 -3
- package/dist/integrations/utils.js +9 -60
- package/dist/middleware/authorized.js +30 -57
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +37 -41
- package/dist/middleware/usageQuota.js +15 -82
- package/dist/package.json +5 -8
- package/dist/tests/utilities/TestConfiguration.js +50 -80
- package/dist/threads/automation.js +11 -13
- package/dist/threads/query.js +11 -15
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +3 -4
- package/dist/utilities/global.js +12 -15
- package/dist/utilities/index.js +17 -7
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +17 -23
- package/dist/utilities/rowProcessor/utils.js +4 -14
- package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -45
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +24 -4
- package/nodemon.json +1 -1
- package/package.json +6 -9
- package/scripts/integrations/postgres/init.sql +6 -11
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +50 -85
- package/src/api/controllers/auth.js +5 -8
- package/src/api/controllers/automation.js +23 -13
- package/src/api/controllers/cloud.js +3 -2
- package/src/api/controllers/component.js +4 -3
- package/src/api/controllers/datasource.js +11 -21
- package/src/api/controllers/deploy/Deployment.js +7 -3
- package/src/api/controllers/deploy/index.js +13 -20
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/hosting.js +22 -0
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +9 -4
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +6 -4
- package/src/api/controllers/query/import/tests/index.spec.js +1 -2
- package/src/api/controllers/query/index.js +10 -11
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +6 -5
- package/src/api/controllers/row/ExternalRequest.ts +43 -67
- package/src/api/controllers/row/external.js +58 -27
- package/src/api/controllers/row/internal.js +90 -54
- package/src/api/controllers/row/internalSearch.js +17 -23
- package/src/api/controllers/row/utils.js +18 -13
- package/src/api/controllers/screen.js +7 -5
- package/src/api/controllers/static/index.js +12 -65
- package/src/api/controllers/table/external.js +10 -7
- package/src/api/controllers/table/index.js +28 -20
- package/src/api/controllers/table/internal.js +19 -24
- package/src/api/controllers/table/utils.js +42 -78
- package/src/api/controllers/user.js +20 -19
- package/src/api/controllers/view/index.js +10 -8
- package/src/api/controllers/view/utils.js +4 -9
- package/src/api/controllers/webhook.js +8 -10
- package/src/api/routes/hosting.js +13 -0
- package/src/api/routes/index.js +2 -2
- package/src/api/routes/static.js +0 -5
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +2 -1
- package/src/api/routes/tests/automation.spec.js +0 -1
- package/src/api/routes/tests/hosting.spec.js +36 -0
- package/src/api/routes/tests/misc.spec.js +1 -0
- package/src/api/routes/tests/routing.spec.js +12 -21
- package/src/api/routes/tests/row.spec.js +4 -7
- package/src/api/routes/tests/utilities/TestFunctions.js +17 -39
- package/src/app.ts +5 -18
- package/src/automations/automationUtils.js +3 -2
- package/src/automations/steps/createRow.js +5 -2
- package/src/automations/steps/deleteRow.js +4 -1
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +31 -33
- package/src/automations/utils.js +5 -9
- package/src/constants/index.js +0 -9
- package/src/db/linkedRows/LinkController.js +7 -3
- package/src/db/linkedRows/index.js +31 -16
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +1 -0
- package/src/db/tests/linkTests.spec.js +6 -5
- package/src/db/views/staticViews.js +10 -8
- package/src/definitions/common.ts +0 -3
- package/src/definitions/datasource.ts +0 -3
- package/src/environment.js +1 -4
- package/src/integrations/base/sql.ts +21 -69
- package/src/integrations/index.ts +0 -3
- package/src/integrations/tests/sql.spec.js +0 -16
- package/src/integrations/utils.ts +12 -75
- package/src/middleware/authorized.js +30 -66
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +46 -50
- package/src/middleware/tests/authorized.spec.js +6 -13
- package/src/middleware/tests/currentapp.spec.js +0 -6
- package/src/middleware/tests/usageQuota.spec.js +24 -18
- package/src/middleware/usageQuota.js +17 -93
- package/src/tests/utilities/TestConfiguration.js +55 -82
- package/src/threads/automation.js +15 -17
- package/src/threads/query.js +12 -17
- package/src/utilities/fileSystem/index.js +3 -4
- package/src/utilities/global.js +12 -15
- package/src/utilities/index.js +17 -7
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +27 -25
- package/src/utilities/rowProcessor/utils.js +7 -23
- package/src/utilities/usageQuota.js +73 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +27 -4
- package/tsconfig.json +1 -2
- package/builder/assets/index.83c0944f.css +0 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +0 -119
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +0 -548
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +0 -599
- package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -359
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -305
- package/dist/api/controllers/migrations.js +0 -21
- package/dist/api/controllers/row/staticFormula.js +0 -147
- package/dist/api/controllers/table/bulkFormula.js +0 -159
- package/dist/api/routes/migrations.js +0 -9
- package/dist/integrations/googlesheets.js +0 -340
- package/dist/migrations/functions/appUrls.js +0 -46
- package/dist/migrations/functions/quotas1.js +0 -50
- package/dist/migrations/functions/usageQuotas/index.js +0 -20
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -29
- package/dist/migrations/functions/usageQuotas/syncRows.js +0 -33
- package/dist/migrations/functions/userEmailViewCasing.js +0 -24
- package/dist/migrations/index.js +0 -62
- package/dist/utilities/usageQuota/rows.js +0 -78
- package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
- package/src/api/controllers/migrations.js +0 -13
- package/src/api/controllers/row/staticFormula.js +0 -156
- package/src/api/controllers/table/bulkFormula.js +0 -173
- package/src/api/routes/migrations.js +0 -14
- package/src/api/routes/tests/static.spec.js +0 -98
- package/src/integrations/googlesheets.ts +0 -353
- package/src/migrations/functions/appUrls.ts +0 -34
- package/src/migrations/functions/quotas1.ts +0 -20
- package/src/migrations/functions/tests/appUrls.spec.js +0 -29
- package/src/migrations/functions/tests/quotas1.spec.js +0 -27
- package/src/migrations/functions/tests/userEmailViewCasing.spec.js +0 -25
- package/src/migrations/functions/usageQuotas/index.ts +0 -8
- package/src/migrations/functions/usageQuotas/syncApps.ts +0 -18
- package/src/migrations/functions/usageQuotas/syncRows.ts +0 -22
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +0 -37
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +0 -43
- package/src/migrations/functions/userEmailViewCasing.ts +0 -13
- package/src/migrations/index.ts +0 -56
- package/src/module.d.ts +0 -3
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
- package/src/utilities/usageQuota/index.js +0 -93
- package/src/utilities/usageQuota/rows.js +0 -75
- package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const { budibaseTempDir } = require("../budibaseDir");
|
|
12
|
+
const { isDev } = require("../index");
|
|
12
13
|
const fs = require("fs");
|
|
13
14
|
const { join } = require("path");
|
|
14
15
|
const uuid = require("uuid/v4");
|
|
@@ -19,7 +20,6 @@ const { updateClientLibrary } = require("./clientLibrary");
|
|
|
19
20
|
const env = require("../../environment");
|
|
20
21
|
const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, } = require("../../db/utils");
|
|
21
22
|
const MemoryStream = require("memorystream");
|
|
22
|
-
const { getAppId } = require("@budibase/backend-core/context");
|
|
23
23
|
const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..");
|
|
24
24
|
const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules");
|
|
25
25
|
/**
|
|
@@ -47,7 +47,7 @@ exports.init = () => {
|
|
|
47
47
|
* everything required to function is ready.
|
|
48
48
|
*/
|
|
49
49
|
exports.checkDevelopmentEnvironment = () => {
|
|
50
|
-
if (!
|
|
50
|
+
if (!isDev()) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
if (!fs.existsSync(budibaseTempDir())) {
|
|
@@ -218,8 +218,7 @@ exports.downloadTemplate = (type, name) => __awaiter(void 0, void 0, void 0, fun
|
|
|
218
218
|
/**
|
|
219
219
|
* Retrieves component libraries from object store (or tmp symlink if in local)
|
|
220
220
|
*/
|
|
221
|
-
exports.getComponentLibraryManifest = (library) => __awaiter(void 0, void 0, void 0, function* () {
|
|
222
|
-
const appId = getAppId();
|
|
221
|
+
exports.getComponentLibraryManifest = (appId, library) => __awaiter(void 0, void 0, void 0, function* () {
|
|
223
222
|
const filename = "manifest.json";
|
|
224
223
|
/* istanbul ignore next */
|
|
225
224
|
// when testing in cypress and so on we need to get the package
|
package/dist/utilities/global.js
CHANGED
|
@@ -10,14 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const { getMultiIDParams, getGlobalIDFromUserMetadataID, } = require("../db/utils");
|
|
12
12
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
|
|
13
|
-
const {
|
|
13
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db");
|
|
14
14
|
const { getGlobalUserParams } = require("@budibase/backend-core/db");
|
|
15
15
|
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
16
16
|
const { getGlobalDB, isUserInAppTenant, } = require("@budibase/backend-core/tenancy");
|
|
17
17
|
const env = require("../environment");
|
|
18
|
-
|
|
19
|
-
exports.updateAppRole = (user, { appId } = {}) => {
|
|
20
|
-
appId = appId || getAppId();
|
|
18
|
+
exports.updateAppRole = (appId, user) => {
|
|
21
19
|
if (!user || !user.roles) {
|
|
22
20
|
return user;
|
|
23
21
|
}
|
|
@@ -29,7 +27,7 @@ exports.updateAppRole = (user, { appId } = {}) => {
|
|
|
29
27
|
return user;
|
|
30
28
|
}
|
|
31
29
|
// always use the deployed app
|
|
32
|
-
user.roleId = user.roles[
|
|
30
|
+
user.roleId = user.roles[getDeployedAppID(appId)];
|
|
33
31
|
// if a role wasn't found then either set as admin (builder) or public (everyone else)
|
|
34
32
|
if (!user.roleId && user.builder && user.builder.global) {
|
|
35
33
|
user.roleId = BUILTIN_ROLE_IDS.ADMIN;
|
|
@@ -40,28 +38,27 @@ exports.updateAppRole = (user, { appId } = {}) => {
|
|
|
40
38
|
delete user.roles;
|
|
41
39
|
return user;
|
|
42
40
|
};
|
|
43
|
-
function processUser(
|
|
41
|
+
function processUser(appId, user) {
|
|
44
42
|
if (user) {
|
|
45
43
|
delete user.password;
|
|
46
44
|
}
|
|
47
|
-
return exports.updateAppRole(
|
|
45
|
+
return exports.updateAppRole(appId, user);
|
|
48
46
|
}
|
|
49
47
|
exports.getCachedSelf = (ctx, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
48
|
// this has to be tenant aware, can't depend on the context to find it out
|
|
51
49
|
// running some middlewares before the tenancy causes context to break
|
|
52
50
|
const user = yield userCache.getUser(ctx.user._id);
|
|
53
|
-
return processUser(
|
|
51
|
+
return processUser(appId, user);
|
|
54
52
|
});
|
|
55
53
|
exports.getRawGlobalUser = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
54
|
const db = getGlobalDB();
|
|
57
55
|
return db.get(getGlobalIDFromUserMetadataID(userId));
|
|
58
56
|
});
|
|
59
|
-
exports.getGlobalUser = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
exports.getGlobalUser = (appId, userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
58
|
let user = yield exports.getRawGlobalUser(userId);
|
|
61
|
-
return processUser(user);
|
|
59
|
+
return processUser(appId, user);
|
|
62
60
|
});
|
|
63
|
-
exports.getGlobalUsers = (users = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
const appId = getAppId();
|
|
61
|
+
exports.getGlobalUsers = (appId = null, users = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
62
|
const db = getGlobalDB();
|
|
66
63
|
let globalUsers;
|
|
67
64
|
if (users) {
|
|
@@ -83,10 +80,10 @@ exports.getGlobalUsers = (users = null) => __awaiter(void 0, void 0, void 0, fun
|
|
|
83
80
|
if (!appId) {
|
|
84
81
|
return globalUsers;
|
|
85
82
|
}
|
|
86
|
-
return globalUsers.map(user => exports.updateAppRole(user));
|
|
83
|
+
return globalUsers.map(user => exports.updateAppRole(appId, user));
|
|
87
84
|
});
|
|
88
|
-
exports.getGlobalUsersFromMetadata = (users) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
const globalUsers = yield exports.getGlobalUsers(users);
|
|
85
|
+
exports.getGlobalUsersFromMetadata = (appId, users) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
const globalUsers = yield exports.getGlobalUsers(appId, users);
|
|
90
87
|
return users.map(user => {
|
|
91
88
|
const globalUser = globalUsers.find(globalUser => globalUser && user._id.includes(globalUser._id));
|
|
92
89
|
return Object.assign(Object.assign({}, globalUser), user);
|
package/dist/utilities/index.js
CHANGED
|
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const env = require("../environment");
|
|
12
12
|
const { OBJ_STORE_DIRECTORY } = require("../constants");
|
|
13
13
|
const { sanitizeKey } = require("@budibase/backend-core/objectStore");
|
|
14
|
+
const CouchDB = require("../db");
|
|
14
15
|
const { generateMetadataID } = require("../db/utils");
|
|
15
16
|
const Readable = require("stream").Readable;
|
|
16
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
17
17
|
const BB_CDN = "https://cdn.budi.live";
|
|
18
18
|
exports.wait = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
19
19
|
exports.isDev = env.isDev;
|
|
@@ -72,8 +72,8 @@ exports.clientLibraryPath = (appId, version) => {
|
|
|
72
72
|
exports.attachmentsRelativeURL = attachmentKey => {
|
|
73
73
|
return exports.checkSlashesInUrl(`${exports.objectStoreUrl()}/${attachmentKey}`);
|
|
74
74
|
};
|
|
75
|
-
exports.updateEntityMetadata = (type, entityId, updateFn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
const db =
|
|
75
|
+
exports.updateEntityMetadata = (appId, type, entityId, updateFn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const db = new CouchDB(appId);
|
|
77
77
|
const id = generateMetadataID(type, entityId);
|
|
78
78
|
// read it to see if it exists, we'll overwrite it no matter what
|
|
79
79
|
let rev, metadata = {};
|
|
@@ -93,13 +93,13 @@ exports.updateEntityMetadata = (type, entityId, updateFn) => __awaiter(void 0, v
|
|
|
93
93
|
const response = yield db.put(metadata);
|
|
94
94
|
return Object.assign(Object.assign({}, metadata), { _id: id, _rev: response.rev });
|
|
95
95
|
});
|
|
96
|
-
exports.saveEntityMetadata = (type, entityId, metadata) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
return exports.updateEntityMetadata(type, entityId, () => {
|
|
96
|
+
exports.saveEntityMetadata = (appId, type, entityId, metadata) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
+
return exports.updateEntityMetadata(appId, type, entityId, () => {
|
|
98
98
|
return metadata;
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
|
-
exports.deleteEntityMetadata = (type, entityId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
-
const db =
|
|
101
|
+
exports.deleteEntityMetadata = (appId, type, entityId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const db = new CouchDB(appId);
|
|
103
103
|
const id = generateMetadataID(type, entityId);
|
|
104
104
|
let rev;
|
|
105
105
|
try {
|
|
@@ -132,6 +132,16 @@ exports.stringToReadStream = string => {
|
|
|
132
132
|
},
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
|
+
exports.doesDatabaseExist = (dbName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
try {
|
|
137
|
+
const db = new CouchDB(dbName, { skip_setup: true });
|
|
138
|
+
const info = yield db.info();
|
|
139
|
+
return info && !info.error;
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
135
145
|
exports.formatBytes = bytes => {
|
|
136
146
|
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
137
147
|
const byteIncrements = 1024;
|
|
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../../db");
|
|
11
12
|
const { createRoutingView } = require("../../db/views/staticViews");
|
|
12
13
|
const { ViewNames, getQueryIndex, UNICODE_MAX } = require("../../db/utils");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const db = getAppDB();
|
|
14
|
+
exports.getRoutingInfo = (appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const db = new CouchDB(appId);
|
|
16
16
|
try {
|
|
17
17
|
const allRouting = yield db.query(getQueryIndex(ViewNames.ROUTING), {
|
|
18
18
|
startKey: "",
|
|
@@ -24,8 +24,8 @@ exports.getRoutingInfo = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
24
24
|
// check if the view doesn't exist, it should for all new instances
|
|
25
25
|
/* istanbul ignore next */
|
|
26
26
|
if (err != null && err.name === "not_found") {
|
|
27
|
-
yield createRoutingView();
|
|
28
|
-
return exports.getRoutingInfo();
|
|
27
|
+
yield createRoutingView(appId);
|
|
28
|
+
return exports.getRoutingInfo(appId);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
throw err;
|
|
@@ -15,8 +15,8 @@ const { attachmentsRelativeURL } = require("../index");
|
|
|
15
15
|
const { processFormulas } = require("./utils");
|
|
16
16
|
const { deleteFiles } = require("../../utilities/fileSystem/utilities");
|
|
17
17
|
const { ObjectStoreBuckets } = require("../../constants");
|
|
18
|
-
const { isProdAppID,
|
|
19
|
-
const
|
|
18
|
+
const { isProdAppID, getDeployedAppID, dbExists, } = require("@budibase/backend-core/db");
|
|
19
|
+
const CouchDB = require("../../db");
|
|
20
20
|
const BASE_AUTO_ID = 1;
|
|
21
21
|
/**
|
|
22
22
|
* A map of how we convert various properties in rows to each other based on the row type.
|
|
@@ -175,7 +175,6 @@ function processAutoColumn(user, table, row, opts = { reprocessing: false, noAut
|
|
|
175
175
|
return { table, row };
|
|
176
176
|
}
|
|
177
177
|
exports.processAutoColumn = processAutoColumn;
|
|
178
|
-
exports.processFormulas = processFormulas;
|
|
179
178
|
/**
|
|
180
179
|
* This will coerce a value to the correct types based on the type transform map
|
|
181
180
|
* @param {object} row The value to coerce
|
|
@@ -219,11 +218,11 @@ exports.inputProcessing = (user = {}, table, row, opts = { noAutoRelationships:
|
|
|
219
218
|
}
|
|
220
219
|
continue;
|
|
221
220
|
}
|
|
222
|
-
//
|
|
221
|
+
// specific case to delete formula values if they get saved
|
|
222
|
+
// type coercion cannot completely remove the field, so have to do it here
|
|
223
223
|
if (field.type === FieldTypes.FORMULA) {
|
|
224
224
|
delete clonedRow[key];
|
|
225
225
|
}
|
|
226
|
-
// otherwise coerce what is there to correct types
|
|
227
226
|
else {
|
|
228
227
|
clonedRow[key] = exports.coerce(value, field.type);
|
|
229
228
|
}
|
|
@@ -238,22 +237,24 @@ exports.inputProcessing = (user = {}, table, row, opts = { noAutoRelationships:
|
|
|
238
237
|
/**
|
|
239
238
|
* This function enriches the input rows with anything they are supposed to contain, for example
|
|
240
239
|
* link records or attachment links.
|
|
240
|
+
* @param {object} ctx the request which is looking for enriched rows.
|
|
241
241
|
* @param {object} table the table from which these rows came from originally, this is used to determine
|
|
242
242
|
* the schema of the rows and then enrich.
|
|
243
243
|
* @param {object[]|object} rows the rows which are to be enriched.
|
|
244
244
|
* @param {object} opts used to set some options for the output, such as disabling relationship squashing.
|
|
245
245
|
* @returns {object[]|object} the enriched rows will be returned.
|
|
246
246
|
*/
|
|
247
|
-
exports.outputProcessing = (table, rows, opts = { squash: true }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
|
+
exports.outputProcessing = (ctx, table, rows, opts = { squash: true }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
+
const appId = ctx.appId;
|
|
248
249
|
let wasArray = true;
|
|
249
250
|
if (!(rows instanceof Array)) {
|
|
250
251
|
rows = [rows];
|
|
251
252
|
wasArray = false;
|
|
252
253
|
}
|
|
253
254
|
// attach any linked row information
|
|
254
|
-
let enriched = yield linkRows.attachFullLinkedDocs(table, rows);
|
|
255
|
+
let enriched = yield linkRows.attachFullLinkedDocs(ctx, table, rows);
|
|
255
256
|
// process formulas
|
|
256
|
-
enriched = processFormulas(table, enriched
|
|
257
|
+
enriched = processFormulas(table, enriched);
|
|
257
258
|
// update the attachments URL depending on hosting
|
|
258
259
|
for (let [property, column] of Object.entries(table.schema)) {
|
|
259
260
|
if (column.type === FieldTypes.ATTACHMENT) {
|
|
@@ -268,26 +269,24 @@ exports.outputProcessing = (table, rows, opts = { squash: true }) => __awaiter(v
|
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
if (opts.squash) {
|
|
271
|
-
enriched = yield linkRows.squashLinksToPrimaryDisplay(table, enriched);
|
|
272
|
+
enriched = yield linkRows.squashLinksToPrimaryDisplay(appId, table, enriched);
|
|
272
273
|
}
|
|
273
274
|
return wasArray ? enriched : enriched[0];
|
|
274
275
|
});
|
|
275
276
|
/**
|
|
276
277
|
* Clean up any attachments that were attached to a row.
|
|
278
|
+
* @param {string} appId The ID of the app from which a row is being deleted.
|
|
277
279
|
* @param {object} table The table from which a row is being removed.
|
|
278
280
|
* @param {any} row optional - the row being removed.
|
|
279
281
|
* @param {any} rows optional - if multiple rows being deleted can do this in bulk.
|
|
280
282
|
* @param {any} oldRow optional - if updating a row this will determine the difference.
|
|
281
|
-
* @param {any} oldTable optional - if updating a table, can supply the old table to look for
|
|
282
|
-
* deleted attachment columns.
|
|
283
283
|
* @return {Promise<void>} When all attachments have been removed this will return.
|
|
284
284
|
*/
|
|
285
|
-
exports.cleanupAttachments = (table, { row, rows, oldRow
|
|
286
|
-
const appId = getAppId();
|
|
285
|
+
exports.cleanupAttachments = (appId, table, { row, rows, oldRow }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
287
286
|
if (!isProdAppID(appId)) {
|
|
288
|
-
const prodAppId =
|
|
287
|
+
const prodAppId = getDeployedAppID(appId);
|
|
289
288
|
// if prod exists, then don't allow deleting
|
|
290
|
-
const exists = yield dbExists(prodAppId);
|
|
289
|
+
const exists = yield dbExists(CouchDB, prodAppId);
|
|
291
290
|
if (exists) {
|
|
292
291
|
return;
|
|
293
292
|
}
|
|
@@ -298,17 +297,12 @@ exports.cleanupAttachments = (table, { row, rows, oldRow, oldTable }) => __await
|
|
|
298
297
|
files = files.concat(row[key].map(attachment => attachment.key));
|
|
299
298
|
}
|
|
300
299
|
}
|
|
301
|
-
|
|
302
|
-
for (let [key, schema] of Object.entries(schemaToUse)) {
|
|
300
|
+
for (let [key, schema] of Object.entries(table.schema)) {
|
|
303
301
|
if (schema.type !== FieldTypes.ATTACHMENT) {
|
|
304
302
|
continue;
|
|
305
303
|
}
|
|
306
|
-
//
|
|
307
|
-
if (
|
|
308
|
-
rows.forEach(row => addFiles(row, key));
|
|
309
|
-
}
|
|
310
|
-
else if (oldRow && row) {
|
|
311
|
-
// if updating, need to manage the differences
|
|
304
|
+
// if updating, need to manage the differences
|
|
305
|
+
if (oldRow && row) {
|
|
312
306
|
files = files.concat(getRemovedAttachmentKeys(oldRow, row, key));
|
|
313
307
|
}
|
|
314
308
|
else if (row) {
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { FieldTypes
|
|
2
|
+
const { FieldTypes } = require("../../constants");
|
|
3
3
|
const { processStringSync } = require("@budibase/string-templates");
|
|
4
4
|
/**
|
|
5
5
|
* Looks through the rows provided and finds formulas - which it then processes.
|
|
6
6
|
*/
|
|
7
|
-
exports.processFormulas = (table, rows
|
|
7
|
+
exports.processFormulas = (table, rows) => {
|
|
8
8
|
const single = !Array.isArray(rows);
|
|
9
9
|
if (single) {
|
|
10
10
|
rows = [rows];
|
|
11
|
-
contextRows = contextRows ? [contextRows] : contextRows;
|
|
12
11
|
}
|
|
13
12
|
for (let [column, schema] of Object.entries(table.schema)) {
|
|
14
|
-
|
|
15
|
-
if (schema.type !== FieldTypes.FORMULA ||
|
|
16
|
-
(dynamic && isStatic) ||
|
|
17
|
-
(!dynamic && !isStatic)) {
|
|
13
|
+
if (schema.type !== FieldTypes.FORMULA) {
|
|
18
14
|
continue;
|
|
19
15
|
}
|
|
20
16
|
// iterate through rows and process formula
|
|
21
|
-
|
|
22
|
-
if (schema.formula) {
|
|
23
|
-
let row = rows[i];
|
|
24
|
-
let context = contextRows ? contextRows[i] : row;
|
|
25
|
-
rows[i] = Object.assign(Object.assign({}, row), { [column]: processStringSync(schema.formula, context) });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
17
|
+
rows = rows.map(row => (Object.assign(Object.assign({}, row), { [column]: processStringSync(schema.formula, row) })));
|
|
28
18
|
}
|
|
29
19
|
return single ? rows[0] : rows;
|
|
30
20
|
};
|
|
@@ -8,24 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const env = require("
|
|
12
|
-
const { getGlobalDB
|
|
11
|
+
const env = require("../environment");
|
|
12
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
13
13
|
const { StaticDatabases, generateNewUsageQuotaDoc, } = require("@budibase/backend-core/db");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// check if there are any tenants without limits
|
|
18
|
-
if (env.EXCLUDE_QUOTAS_TENANTS) {
|
|
19
|
-
const excludedTenants = env.EXCLUDE_QUOTAS_TENANTS.replace(/\s/g, "").split(",");
|
|
20
|
-
const tenantId = getTenantId();
|
|
21
|
-
if (excludedTenants.includes(tenantId)) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
};
|
|
14
|
+
function getNewQuotaReset() {
|
|
15
|
+
return Date.now() + 2592000000;
|
|
16
|
+
}
|
|
29
17
|
exports.Properties = {
|
|
30
18
|
ROW: "rows",
|
|
31
19
|
UPLOAD: "storage",
|
|
@@ -33,51 +21,49 @@ exports.Properties = {
|
|
|
33
21
|
USER: "users",
|
|
34
22
|
AUTOMATION: "automationRuns",
|
|
35
23
|
APPS: "apps",
|
|
36
|
-
EMAILS: "emails",
|
|
24
|
+
EMAILS: "emails",
|
|
37
25
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
26
|
+
function getUsageQuotaDoc(db) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
let quota;
|
|
29
|
+
try {
|
|
30
|
+
quota = yield db.get(StaticDatabases.PLATFORM_INFO.docs.usageQuota);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
// doc doesn't exist. Create it
|
|
34
|
+
quota = yield db.post(generateNewUsageQuotaDoc());
|
|
35
|
+
}
|
|
36
|
+
return quota;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
51
39
|
/**
|
|
52
40
|
* Given a specified tenantId this will add to the usage object for the specified property.
|
|
53
41
|
* @param {string} property The property which is to be added to (within the nested usageQuota object).
|
|
54
42
|
* @param {number} usage The amount (this can be negative) to adjust the number by.
|
|
55
|
-
* @param {object} opts optional - options such as dryRun, to check what update will do.
|
|
56
43
|
* @returns {Promise<void>} When this completes the API key will now be up to date - the quota period may have
|
|
57
44
|
* also been reset after this call.
|
|
58
45
|
*/
|
|
59
|
-
exports.update = (property, usage
|
|
60
|
-
if (!
|
|
46
|
+
exports.update = (property, usage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
if (!env.USE_QUOTAS) {
|
|
61
48
|
return;
|
|
62
49
|
}
|
|
63
50
|
try {
|
|
64
51
|
const db = getGlobalDB();
|
|
65
|
-
const quota = yield
|
|
52
|
+
const quota = yield getUsageQuotaDoc(db);
|
|
53
|
+
// Check if the quota needs reset
|
|
54
|
+
if (Date.now() >= quota.quotaReset) {
|
|
55
|
+
quota.quotaReset = getNewQuotaReset();
|
|
56
|
+
for (let prop of Object.keys(quota.usageQuota)) {
|
|
57
|
+
quota.usageQuota[prop] = 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
66
60
|
// increment the quota
|
|
67
61
|
quota.usageQuota[property] += usage;
|
|
68
|
-
if (quota.usageQuota[property] > quota.usageLimits[property]
|
|
69
|
-
usage > 0 // allow for decrementing usage when the quota is already exceeded
|
|
70
|
-
) {
|
|
62
|
+
if (quota.usageQuota[property] > quota.usageLimits[property]) {
|
|
71
63
|
throw new Error(`You have exceeded your usage quota of ${quota.usageLimits[property]} ${property}.`);
|
|
72
64
|
}
|
|
73
|
-
if (quota.usageQuota[property] < 0) {
|
|
74
|
-
// never go negative if the quota has previously been exceeded
|
|
75
|
-
quota.usageQuota[property] = 0;
|
|
76
|
-
}
|
|
77
65
|
// update the usage quotas
|
|
78
|
-
|
|
79
|
-
yield db.put(quota);
|
|
80
|
-
}
|
|
66
|
+
yield db.put(quota);
|
|
81
67
|
}
|
|
82
68
|
catch (err) {
|
|
83
69
|
console.error(`Error updating usage quotas for ${property}`, err);
|
package/dist/utilities/users.js
CHANGED
|
@@ -8,15 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
const CouchDB = require("../db");
|
|
11
12
|
const { InternalTables } = require("../db/utils");
|
|
12
13
|
const { getGlobalUser } = require("../utilities/global");
|
|
13
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
14
|
exports.getFullUser = (ctx, userId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const global = yield getGlobalUser(userId);
|
|
15
|
+
const global = yield getGlobalUser(ctx.appId, userId);
|
|
16
16
|
let metadata;
|
|
17
17
|
try {
|
|
18
18
|
// this will throw an error if the db doesn't exist, or there is no appId
|
|
19
|
-
const db =
|
|
19
|
+
const db = new CouchDB(ctx.appId);
|
|
20
20
|
metadata = yield db.get(userId);
|
|
21
21
|
}
|
|
22
22
|
catch (err) {
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
const fetch = require("node-fetch");
|
|
12
12
|
const env = require("../environment");
|
|
13
13
|
const { checkSlashesInUrl } = require("./index");
|
|
14
|
-
const {
|
|
14
|
+
const { getDeployedAppID } = require("@budibase/backend-core/db");
|
|
15
15
|
const { updateAppRole } = require("./global");
|
|
16
16
|
const { Headers } = require("@budibase/backend-core/constants");
|
|
17
17
|
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy");
|
|
@@ -61,6 +61,26 @@ exports.sendSmtpEmail = (to, from, subject, contents, automation) => __awaiter(v
|
|
|
61
61
|
}
|
|
62
62
|
return response.json();
|
|
63
63
|
});
|
|
64
|
+
exports.getDeployedApps = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
try {
|
|
66
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/apps`), request(null, {
|
|
67
|
+
method: "GET",
|
|
68
|
+
}));
|
|
69
|
+
const json = yield response.json();
|
|
70
|
+
const apps = {};
|
|
71
|
+
for (let [key, value] of Object.entries(json)) {
|
|
72
|
+
if (value.url) {
|
|
73
|
+
value.url = value.url.toLowerCase();
|
|
74
|
+
apps[key.toLowerCase()] = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return apps;
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
// error, cannot determine deployed apps, don't stop app creation - sort this later
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
64
84
|
exports.getGlobalSelf = (ctx, appId = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
85
|
const endpoint = `/api/global/users/self`;
|
|
66
86
|
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + endpoint),
|
|
@@ -71,13 +91,13 @@ exports.getGlobalSelf = (ctx, appId = null) => __awaiter(void 0, void 0, void 0,
|
|
|
71
91
|
}
|
|
72
92
|
let json = yield response.json();
|
|
73
93
|
if (appId) {
|
|
74
|
-
json = updateAppRole(json);
|
|
94
|
+
json = updateAppRole(appId, json);
|
|
75
95
|
}
|
|
76
96
|
return json;
|
|
77
97
|
});
|
|
78
98
|
exports.removeAppFromUserRoles = (ctx, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
const
|
|
80
|
-
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${
|
|
99
|
+
const deployedAppId = getDeployedAppID(appId);
|
|
100
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${deployedAppId}`), request(ctx, {
|
|
81
101
|
method: "DELETE",
|
|
82
102
|
}));
|
|
83
103
|
if (response.status !== 200) {
|
package/nodemon.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.49
|
|
4
|
+
"version": "1.0.49",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/backend-core": "^1.0.49
|
|
74
|
-
"@budibase/client": "^1.0.49
|
|
75
|
-
"@budibase/string-templates": "^1.0.49
|
|
73
|
+
"@budibase/backend-core": "^1.0.49",
|
|
74
|
+
"@budibase/client": "^1.0.49",
|
|
75
|
+
"@budibase/string-templates": "^1.0.49",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -92,8 +92,6 @@
|
|
|
92
92
|
"fix-path": "3.0.0",
|
|
93
93
|
"form-data": "^4.0.0",
|
|
94
94
|
"fs-extra": "8.1.0",
|
|
95
|
-
"google-auth-library": "^7.11.0",
|
|
96
|
-
"google-spreadsheet": "^3.2.0",
|
|
97
95
|
"jimp": "0.16.1",
|
|
98
96
|
"joi": "17.2.1",
|
|
99
97
|
"js-yaml": "^4.1.0",
|
|
@@ -112,7 +110,7 @@
|
|
|
112
110
|
"mongodb": "3.6.3",
|
|
113
111
|
"mssql": "6.2.3",
|
|
114
112
|
"mysql2": "^2.3.1",
|
|
115
|
-
"node-fetch": "2.6.
|
|
113
|
+
"node-fetch": "2.6.0",
|
|
116
114
|
"open": "^8.4.0",
|
|
117
115
|
"pg": "8.5.1",
|
|
118
116
|
"pino-pretty": "4.0.0",
|
|
@@ -141,7 +139,6 @@
|
|
|
141
139
|
"@jest/test-sequencer": "^24.8.0",
|
|
142
140
|
"@types/apidoc": "^0.50.0",
|
|
143
141
|
"@types/bull": "^3.15.1",
|
|
144
|
-
"@types/google-spreadsheet": "^3.1.5",
|
|
145
142
|
"@types/jest": "^26.0.23",
|
|
146
143
|
"@types/koa": "^2.13.3",
|
|
147
144
|
"@types/koa-router": "^7.4.2",
|
|
@@ -168,5 +165,5 @@
|
|
|
168
165
|
"optionalDependencies": {
|
|
169
166
|
"oracledb": "^5.3.0"
|
|
170
167
|
},
|
|
171
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "80ae9a30b112c1abf794bdad73da9257ba80d9d5"
|
|
172
169
|
}
|
|
@@ -9,16 +9,12 @@ CREATE TABLE Persons (
|
|
|
9
9
|
);
|
|
10
10
|
CREATE TABLE Tasks (
|
|
11
11
|
TaskID SERIAL PRIMARY KEY,
|
|
12
|
-
|
|
13
|
-
QaID INT,
|
|
12
|
+
PersonID INT,
|
|
14
13
|
Completed BOOLEAN,
|
|
15
14
|
TaskName varchar(255),
|
|
16
|
-
CONSTRAINT
|
|
17
|
-
FOREIGN KEY(
|
|
18
|
-
REFERENCES Persons(PersonID)
|
|
19
|
-
CONSTRAINT fkqa
|
|
20
|
-
FOREIGN KEY(QaID)
|
|
21
|
-
REFERENCES Persons(PersonID)
|
|
15
|
+
CONSTRAINT fkPersons
|
|
16
|
+
FOREIGN KEY(PersonID)
|
|
17
|
+
REFERENCES Persons(PersonID)
|
|
22
18
|
);
|
|
23
19
|
CREATE TABLE Products (
|
|
24
20
|
ProductID SERIAL PRIMARY KEY,
|
|
@@ -36,9 +32,8 @@ CREATE TABLE Products_Tasks (
|
|
|
36
32
|
PRIMARY KEY (ProductID, TaskID)
|
|
37
33
|
);
|
|
38
34
|
INSERT INTO Persons (FirstName, LastName, Address, City) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast');
|
|
39
|
-
INSERT INTO
|
|
40
|
-
INSERT INTO Tasks (
|
|
41
|
-
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (2, 1, 'processing', FALSE);
|
|
35
|
+
INSERT INTO Tasks (PersonID, TaskName, Completed) VALUES (1, 'assembling', TRUE);
|
|
36
|
+
INSERT INTO Tasks (PersonID, TaskName, Completed) VALUES (1, 'processing', FALSE);
|
|
42
37
|
INSERT INTO Products (ProductName) VALUES ('Computers');
|
|
43
38
|
INSERT INTO Products (ProductName) VALUES ('Laptops');
|
|
44
39
|
INSERT INTO Products (ProductName) VALUES ('Chairs');
|
package/scripts/likeCypress.ts
CHANGED