@budibase/server 1.0.49-alpha.2 → 1.0.49-alpha.6
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 +4 -5
- package/__mocks__/mssql.ts +3 -3
- package/__mocks__/node-fetch.ts +2 -1
- package/__mocks__/pg.ts +3 -5
- package/builder/assets/{index.82e12602.js → index.1b905242.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1917 -1929
- package/coverage/coverage-final.json +54 -54
- 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 +58 -37
- package/coverage/lcov-report/api/controllers/auth.js.html +11 -14
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -51
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +8 -11
- package/coverage/lcov-report/api/controllers/component.js.html +10 -13
- package/coverage/lcov-report/api/controllers/datasource.js.html +17 -23
- package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
- package/coverage/lcov-report/api/controllers/index.html +52 -52
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +4 -4
- package/coverage/lcov-report/api/controllers/metadata.js.html +6 -21
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +6 -6
- package/coverage/lcov-report/api/controllers/query/index.html +10 -10
- package/coverage/lcov-report/api/controllers/query/index.js.html +21 -18
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +7 -10
- package/coverage/lcov-report/api/controllers/row/external.js.html +6 -12
- package/coverage/lcov-report/api/controllers/row/index.html +22 -22
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +37 -82
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +19 -25
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +14 -17
- package/coverage/lcov-report/api/controllers/row/utils.js.html +15 -12
- package/coverage/lcov-report/api/controllers/screen.js.html +10 -16
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +20 -50
- package/coverage/lcov-report/api/controllers/table/external.js.html +15 -24
- package/coverage/lcov-report/api/controllers/table/index.html +37 -37
- package/coverage/lcov-report/api/controllers/table/index.js.html +7 -7
- package/coverage/lcov-report/api/controllers/table/internal.js.html +36 -45
- package/coverage/lcov-report/api/controllers/table/utils.js.html +40 -76
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +26 -35
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +16 -16
- package/coverage/lcov-report/api/controllers/view/index.js.html +15 -21
- package/coverage/lcov-report/api/controllers/view/utils.js.html +25 -10
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +21 -15
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- 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/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- 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/migrations.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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +4 -7
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +2 -5
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +2 -2
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +46 -40
- package/coverage/lcov-report/automations/utils.js.html +24 -12
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -23
- package/coverage/lcov-report/db/linkedRows/index.html +27 -27
- package/coverage/lcov-report/db/linkedRows/index.js.html +24 -66
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +28 -28
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +5 -5
- 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 +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +88 -88
- 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 +21 -15
- package/coverage/lcov-report/middleware/builder.js.html +3 -3
- package/coverage/lcov-report/middleware/currentapp.js.html +72 -60
- package/coverage/lcov-report/middleware/index.html +28 -28
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- 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 +29 -29
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +30 -24
- package/coverage/lcov-report/threads/index.html +16 -16
- package/coverage/lcov-report/threads/index.js.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +17 -17
- package/coverage/lcov-report/threads/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +44 -35
- package/coverage/lcov-report/utilities/index.html +27 -27
- package/coverage/lcov-report/utilities/index.js.html +40 -70
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +11 -11
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +16 -58
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +5 -2
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +5 -2
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +5 -5
- package/coverage/lcov.info +3189 -3198
- package/dist/api/controllers/application.js +31 -28
- package/dist/api/controllers/auth.js +4 -5
- package/dist/api/controllers/automation.js +14 -19
- package/dist/api/controllers/cloud.js +2 -3
- package/dist/api/controllers/component.js +3 -4
- package/dist/api/controllers/datasource.js +9 -10
- package/dist/api/controllers/deploy/Deployment.js +3 -6
- package/dist/api/controllers/deploy/index.js +12 -13
- package/dist/api/controllers/dev.js +5 -5
- 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 +4 -6
- package/dist/api/controllers/query/index.js +11 -10
- package/dist/api/controllers/role.js +5 -5
- package/dist/api/controllers/routing.js +5 -6
- package/dist/api/controllers/row/ExternalRequest.js +76 -63
- package/dist/api/controllers/row/external.js +4 -4
- package/dist/api/controllers/row/internal.js +29 -44
- package/dist/api/controllers/row/internalSearch.js +11 -13
- package/dist/api/controllers/row/staticFormula.js +11 -11
- package/dist/api/controllers/row/utils.js +7 -6
- package/dist/api/controllers/screen.js +5 -7
- package/dist/api/controllers/static/index.js +4 -4
- package/dist/api/controllers/table/bulkFormula.js +14 -15
- package/dist/api/controllers/table/external.js +7 -10
- package/dist/api/controllers/table/index.js +5 -5
- package/dist/api/controllers/table/internal.js +16 -19
- package/dist/api/controllers/table/utils.js +29 -31
- package/dist/api/controllers/user.js +16 -20
- package/dist/api/controllers/view/index.js +8 -10
- package/dist/api/controllers/view/utils.js +9 -4
- package/dist/api/controllers/webhook.js +10 -8
- package/dist/api/routes/tests/utilities/TestFunctions.js +37 -17
- package/dist/automations/automationUtils.js +2 -3
- package/dist/automations/steps/createRow.js +1 -1
- package/dist/automations/steps/updateRow.js +1 -1
- package/dist/automations/triggers.js +27 -25
- package/dist/automations/utils.js +10 -5
- package/dist/db/linkedRows/LinkController.js +3 -7
- package/dist/db/linkedRows/index.js +16 -26
- package/dist/db/linkedRows/linkUtils.js +6 -6
- package/dist/db/views/staticViews.js +9 -10
- package/dist/environment.js +2 -1
- package/dist/integrations/utils.js +3 -0
- package/dist/middleware/authorized.js +5 -3
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +41 -37
- package/dist/middleware/usageQuota.js +2 -2
- package/dist/migrations/functions/appUrls.js +11 -2
- package/dist/migrations/functions/usageQuotas/syncApps.js +7 -9
- package/dist/migrations/functions/usageQuotas/syncRows.js +7 -9
- package/dist/package.json +4 -4
- package/dist/tests/utilities/TestConfiguration.js +67 -44
- package/dist/threads/automation.js +13 -11
- package/dist/threads/query.js +11 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +4 -3
- package/dist/utilities/global.js +15 -12
- package/dist/utilities/index.js +7 -17
- package/dist/utilities/routing/index.js +5 -5
- package/dist/utilities/rowProcessor/index.js +9 -10
- package/dist/utilities/usageQuota/index.js +1 -0
- package/dist/utilities/usageQuota/rows.js +1 -0
- package/dist/utilities/users.js +3 -3
- package/dist/utilities/workerRequests.js +4 -4
- package/package.json +5 -5
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/application.js +35 -28
- package/src/api/controllers/auth.js +4 -5
- package/src/api/controllers/automation.js +13 -23
- package/src/api/controllers/cloud.js +2 -3
- package/src/api/controllers/component.js +3 -4
- package/src/api/controllers/datasource.js +9 -11
- package/src/api/controllers/deploy/Deployment.js +3 -7
- package/src/api/controllers/deploy/index.js +20 -13
- package/src/api/controllers/dev.js +5 -5
- package/src/api/controllers/layout.js +3 -3
- package/src/api/controllers/metadata.js +4 -9
- package/src/api/controllers/permission.js +4 -4
- package/src/api/controllers/query/import/index.ts +4 -6
- package/src/api/controllers/query/import/tests/index.spec.js +2 -1
- package/src/api/controllers/query/index.js +11 -10
- package/src/api/controllers/role.js +5 -5
- package/src/api/controllers/routing.js +5 -6
- package/src/api/controllers/row/ExternalRequest.ts +53 -42
- package/src/api/controllers/row/external.js +4 -6
- package/src/api/controllers/row/internal.js +29 -44
- package/src/api/controllers/row/internalSearch.js +11 -13
- package/src/api/controllers/row/staticFormula.js +10 -11
- package/src/api/controllers/row/utils.js +7 -6
- package/src/api/controllers/screen.js +5 -7
- package/src/api/controllers/static/index.js +4 -4
- package/src/api/controllers/table/bulkFormula.js +13 -23
- package/src/api/controllers/table/external.js +7 -10
- package/src/api/controllers/table/index.js +5 -5
- package/src/api/controllers/table/internal.js +18 -21
- package/src/api/controllers/table/utils.js +29 -41
- package/src/api/controllers/user.js +17 -20
- package/src/api/controllers/view/index.js +8 -10
- package/src/api/controllers/view/utils.js +9 -4
- package/src/api/controllers/webhook.js +10 -8
- package/src/api/routes/tests/automation.spec.js +1 -0
- package/src/api/routes/tests/misc.spec.js +0 -1
- package/src/api/routes/tests/routing.spec.js +21 -12
- package/src/api/routes/tests/row.spec.js +7 -4
- package/src/api/routes/tests/utilities/TestFunctions.js +39 -17
- package/src/automations/automationUtils.js +2 -3
- package/src/automations/steps/createRow.js +0 -1
- package/src/automations/steps/updateRow.js +1 -1
- package/src/automations/triggers.js +33 -31
- package/src/automations/utils.js +9 -5
- package/src/db/linkedRows/LinkController.js +3 -7
- package/src/db/linkedRows/index.js +16 -30
- package/src/db/linkedRows/linkUtils.js +6 -6
- package/src/db/tests/linkController.spec.js +0 -1
- package/src/db/tests/linkTests.spec.js +5 -6
- package/src/db/views/staticViews.js +8 -10
- package/src/environment.js +2 -1
- package/src/integrations/utils.ts +4 -1
- package/src/middleware/authorized.js +5 -3
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +50 -46
- package/src/middleware/tests/authorized.spec.js +7 -2
- package/src/middleware/tests/currentapp.spec.js +6 -0
- package/src/middleware/usageQuota.js +2 -2
- package/src/migrations/functions/appUrls.ts +11 -2
- package/src/migrations/functions/usageQuotas/syncApps.ts +5 -4
- package/src/migrations/functions/usageQuotas/syncRows.ts +5 -4
- package/src/tests/utilities/TestConfiguration.js +69 -50
- package/src/threads/automation.js +17 -15
- package/src/threads/query.js +12 -12
- package/src/utilities/fileSystem/index.js +4 -3
- package/src/utilities/global.js +15 -12
- package/src/utilities/index.js +7 -17
- package/src/utilities/routing/index.js +5 -5
- package/src/utilities/rowProcessor/index.js +9 -23
- package/src/utilities/usageQuota/index.js +1 -0
- package/src/utilities/usageQuota/rows.js +1 -0
- package/src/utilities/users.js +3 -3
- package/src/utilities/workerRequests.js +4 -4
package/src/utilities/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const env = require("../environment")
|
|
2
2
|
const { OBJ_STORE_DIRECTORY } = require("../constants")
|
|
3
3
|
const { sanitizeKey } = require("@budibase/backend-core/objectStore")
|
|
4
|
-
const CouchDB = require("../db")
|
|
5
4
|
const { generateMetadataID } = require("../db/utils")
|
|
6
5
|
const Readable = require("stream").Readable
|
|
6
|
+
const { getAppDB } = require("@budibase/backend-core/context")
|
|
7
7
|
|
|
8
8
|
const BB_CDN = "https://cdn.budi.live"
|
|
9
9
|
|
|
@@ -73,8 +73,8 @@ exports.attachmentsRelativeURL = attachmentKey => {
|
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
exports.updateEntityMetadata = async (
|
|
77
|
-
const db =
|
|
76
|
+
exports.updateEntityMetadata = async (type, entityId, updateFn) => {
|
|
77
|
+
const db = getAppDB()
|
|
78
78
|
const id = generateMetadataID(type, entityId)
|
|
79
79
|
// read it to see if it exists, we'll overwrite it no matter what
|
|
80
80
|
let rev,
|
|
@@ -99,14 +99,14 @@ exports.updateEntityMetadata = async (appId, type, entityId, updateFn) => {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
exports.saveEntityMetadata = async (
|
|
103
|
-
return exports.updateEntityMetadata(
|
|
102
|
+
exports.saveEntityMetadata = async (type, entityId, metadata) => {
|
|
103
|
+
return exports.updateEntityMetadata(type, entityId, () => {
|
|
104
104
|
return metadata
|
|
105
105
|
})
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
exports.deleteEntityMetadata = async (
|
|
109
|
-
const db =
|
|
108
|
+
exports.deleteEntityMetadata = async (type, entityId) => {
|
|
109
|
+
const db = getAppDB()
|
|
110
110
|
const id = generateMetadataID(type, entityId)
|
|
111
111
|
let rev
|
|
112
112
|
try {
|
|
@@ -141,16 +141,6 @@ exports.stringToReadStream = string => {
|
|
|
141
141
|
})
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
exports.doesDatabaseExist = async dbName => {
|
|
145
|
-
try {
|
|
146
|
-
const db = new CouchDB(dbName, { skip_setup: true })
|
|
147
|
-
const info = await db.info()
|
|
148
|
-
return info && !info.error
|
|
149
|
-
} catch (err) {
|
|
150
|
-
return false
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
144
|
exports.formatBytes = bytes => {
|
|
155
145
|
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
|
156
146
|
const byteIncrements = 1024
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const CouchDB = require("../../db")
|
|
2
1
|
const { createRoutingView } = require("../../db/views/staticViews")
|
|
3
2
|
const { ViewNames, getQueryIndex, UNICODE_MAX } = require("../../db/utils")
|
|
3
|
+
const { getAppDB } = require("@budibase/backend-core/context")
|
|
4
4
|
|
|
5
|
-
exports.getRoutingInfo = async
|
|
6
|
-
const db =
|
|
5
|
+
exports.getRoutingInfo = async () => {
|
|
6
|
+
const db = getAppDB()
|
|
7
7
|
try {
|
|
8
8
|
const allRouting = await db.query(getQueryIndex(ViewNames.ROUTING), {
|
|
9
9
|
startKey: "",
|
|
@@ -14,8 +14,8 @@ exports.getRoutingInfo = async appId => {
|
|
|
14
14
|
// check if the view doesn't exist, it should for all new instances
|
|
15
15
|
/* istanbul ignore next */
|
|
16
16
|
if (err != null && err.name === "not_found") {
|
|
17
|
-
await createRoutingView(
|
|
18
|
-
return exports.getRoutingInfo(
|
|
17
|
+
await createRoutingView()
|
|
18
|
+
return exports.getRoutingInfo()
|
|
19
19
|
} else {
|
|
20
20
|
throw err
|
|
21
21
|
}
|
|
@@ -7,10 +7,10 @@ const { deleteFiles } = require("../../utilities/fileSystem/utilities")
|
|
|
7
7
|
const { ObjectStoreBuckets } = require("../../constants")
|
|
8
8
|
const {
|
|
9
9
|
isProdAppID,
|
|
10
|
-
|
|
10
|
+
getProdAppID,
|
|
11
11
|
dbExists,
|
|
12
12
|
} = require("@budibase/backend-core/db")
|
|
13
|
-
const
|
|
13
|
+
const { getAppId } = require("@budibase/backend-core/context")
|
|
14
14
|
|
|
15
15
|
const BASE_AUTO_ID = 1
|
|
16
16
|
|
|
@@ -253,26 +253,20 @@ exports.inputProcessing = (
|
|
|
253
253
|
/**
|
|
254
254
|
* This function enriches the input rows with anything they are supposed to contain, for example
|
|
255
255
|
* link records or attachment links.
|
|
256
|
-
* @param {string} appId the app in which the request is looking for enriched rows.
|
|
257
256
|
* @param {object} table the table from which these rows came from originally, this is used to determine
|
|
258
257
|
* the schema of the rows and then enrich.
|
|
259
258
|
* @param {object[]|object} rows the rows which are to be enriched.
|
|
260
259
|
* @param {object} opts used to set some options for the output, such as disabling relationship squashing.
|
|
261
260
|
* @returns {object[]|object} the enriched rows will be returned.
|
|
262
261
|
*/
|
|
263
|
-
exports.outputProcessing = async (
|
|
264
|
-
{ appId },
|
|
265
|
-
table,
|
|
266
|
-
rows,
|
|
267
|
-
opts = { squash: true }
|
|
268
|
-
) => {
|
|
262
|
+
exports.outputProcessing = async (table, rows, opts = { squash: true }) => {
|
|
269
263
|
let wasArray = true
|
|
270
264
|
if (!(rows instanceof Array)) {
|
|
271
265
|
rows = [rows]
|
|
272
266
|
wasArray = false
|
|
273
267
|
}
|
|
274
268
|
// attach any linked row information
|
|
275
|
-
let enriched = await linkRows.attachFullLinkedDocs(
|
|
269
|
+
let enriched = await linkRows.attachFullLinkedDocs(table, rows)
|
|
276
270
|
|
|
277
271
|
// process formulas
|
|
278
272
|
enriched = processFormulas(table, enriched, { dynamic: true })
|
|
@@ -291,18 +285,13 @@ exports.outputProcessing = async (
|
|
|
291
285
|
}
|
|
292
286
|
}
|
|
293
287
|
if (opts.squash) {
|
|
294
|
-
enriched = await linkRows.squashLinksToPrimaryDisplay(
|
|
295
|
-
appId,
|
|
296
|
-
table,
|
|
297
|
-
enriched
|
|
298
|
-
)
|
|
288
|
+
enriched = await linkRows.squashLinksToPrimaryDisplay(table, enriched)
|
|
299
289
|
}
|
|
300
290
|
return wasArray ? enriched : enriched[0]
|
|
301
291
|
}
|
|
302
292
|
|
|
303
293
|
/**
|
|
304
294
|
* Clean up any attachments that were attached to a row.
|
|
305
|
-
* @param {string} appId The ID of the app from which a row is being deleted.
|
|
306
295
|
* @param {object} table The table from which a row is being removed.
|
|
307
296
|
* @param {any} row optional - the row being removed.
|
|
308
297
|
* @param {any} rows optional - if multiple rows being deleted can do this in bulk.
|
|
@@ -311,15 +300,12 @@ exports.outputProcessing = async (
|
|
|
311
300
|
* deleted attachment columns.
|
|
312
301
|
* @return {Promise<void>} When all attachments have been removed this will return.
|
|
313
302
|
*/
|
|
314
|
-
exports.cleanupAttachments = async (
|
|
315
|
-
appId
|
|
316
|
-
table,
|
|
317
|
-
{ row, rows, oldRow, oldTable }
|
|
318
|
-
) => {
|
|
303
|
+
exports.cleanupAttachments = async (table, { row, rows, oldRow, oldTable }) => {
|
|
304
|
+
const appId = getAppId()
|
|
319
305
|
if (!isProdAppID(appId)) {
|
|
320
|
-
const prodAppId =
|
|
306
|
+
const prodAppId = getProdAppID(appId)
|
|
321
307
|
// if prod exists, then don't allow deleting
|
|
322
|
-
const exists = await dbExists(
|
|
308
|
+
const exists = await dbExists(prodAppId)
|
|
323
309
|
if (exists) {
|
|
324
310
|
return
|
|
325
311
|
}
|
|
@@ -52,6 +52,7 @@ exports.getUsageQuotaDoc = async db => {
|
|
|
52
52
|
* Given a specified tenantId this will add to the usage object for the specified property.
|
|
53
53
|
* @param {string} property The property which is to be added to (within the nested usageQuota object).
|
|
54
54
|
* @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.
|
|
55
56
|
* @returns {Promise<void>} When this completes the API key will now be up to date - the quota period may have
|
|
56
57
|
* also been reset after this call.
|
|
57
58
|
*/
|
|
@@ -23,6 +23,7 @@ const getAppPairs = appIds => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const getAppRows = async appId => {
|
|
26
|
+
// need to specify the app ID, as this is used for different apps in one call
|
|
26
27
|
const appDb = new CouchDB(appId)
|
|
27
28
|
const response = await appDb.allDocs(
|
|
28
29
|
getRowParams(null, null, {
|
package/src/utilities/users.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const CouchDB = require("../db")
|
|
2
1
|
const { InternalTables } = require("../db/utils")
|
|
3
2
|
const { getGlobalUser } = require("../utilities/global")
|
|
3
|
+
const { getAppDB } = require("@budibase/backend-core/context")
|
|
4
4
|
|
|
5
5
|
exports.getFullUser = async (ctx, userId) => {
|
|
6
|
-
const global = await getGlobalUser(
|
|
6
|
+
const global = await getGlobalUser(userId)
|
|
7
7
|
let metadata
|
|
8
8
|
try {
|
|
9
9
|
// this will throw an error if the db doesn't exist, or there is no appId
|
|
10
|
-
const db =
|
|
10
|
+
const db = getAppDB()
|
|
11
11
|
metadata = await db.get(userId)
|
|
12
12
|
} catch (err) {
|
|
13
13
|
// it is fine if there is no user metadata, just remove global db info
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fetch = require("node-fetch")
|
|
2
2
|
const env = require("../environment")
|
|
3
3
|
const { checkSlashesInUrl } = require("./index")
|
|
4
|
-
const {
|
|
4
|
+
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
5
5
|
const { updateAppRole } = require("./global")
|
|
6
6
|
const { Headers } = require("@budibase/backend-core/constants")
|
|
7
7
|
const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy")
|
|
@@ -70,15 +70,15 @@ exports.getGlobalSelf = async (ctx, appId = null) => {
|
|
|
70
70
|
}
|
|
71
71
|
let json = await response.json()
|
|
72
72
|
if (appId) {
|
|
73
|
-
json = updateAppRole(
|
|
73
|
+
json = updateAppRole(json)
|
|
74
74
|
}
|
|
75
75
|
return json
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
exports.removeAppFromUserRoles = async (ctx, appId) => {
|
|
79
|
-
const
|
|
79
|
+
const prodAppId = getProdAppID(appId)
|
|
80
80
|
const response = await fetch(
|
|
81
|
-
checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${
|
|
81
|
+
checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${prodAppId}`),
|
|
82
82
|
request(ctx, {
|
|
83
83
|
method: "DELETE",
|
|
84
84
|
})
|