From b489ec1b5206c2776c9ca63a6dac9501ea7908b7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 10 Dec 2021 11:04:19 +0000 Subject: [PATCH 1/6] Fixing symlink to env file for development. --- hosting/.env | 1 + 1 file changed, 1 insertion(+) create mode 120000 hosting/.env diff --git a/hosting/.env b/hosting/.env new file mode 120000 index 0000000000..bb1b54ad77 --- /dev/null +++ b/hosting/.env @@ -0,0 +1 @@ +hosting.properties \ No newline at end of file From dc92cbeac012da6d2d2dc68c07ccc4516472cff2 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 10 Dec 2021 11:12:06 +0000 Subject: [PATCH 2/6] v1.0.13 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 07bbf908e6..cf8ebab2af 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.12", + "version": "1.0.13", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index c0599f6bc0..7053ddab67 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "1.0.12", + "version": "1.0.13", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 3ffb11667b..edc16608cb 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.12", + "version": "1.0.13", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index df91d83c98..f9a4cf2407 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.12", + "version": "1.0.13", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.12", - "@budibase/client": "^1.0.12", + "@budibase/bbui": "^1.0.13", + "@budibase/client": "^1.0.13", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.12", + "@budibase/string-templates": "^1.0.13", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 6adda8617a..6e5d4760c8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.12", + "version": "1.0.13", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index d85a297e73..66bc2f4da0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.12", + "version": "1.0.13", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.12", + "@budibase/bbui": "^1.0.13", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.12", + "@budibase/string-templates": "^1.0.13", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index f0e01676fd..87610747af 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.12", + "version": "1.0.13", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -69,9 +69,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.12", - "@budibase/client": "^1.0.12", - "@budibase/string-templates": "^1.0.12", + "@budibase/auth": "^1.0.13", + "@budibase/client": "^1.0.13", + "@budibase/string-templates": "^1.0.13", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 22b167c8af..ad7928f062 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.12", + "version": "1.0.13", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index fa7117cd09..7bba900ee7 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.12", + "version": "1.0.13", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.12", - "@budibase/string-templates": "^1.0.12", + "@budibase/auth": "^1.0.13", + "@budibase/string-templates": "^1.0.13", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", From 312db6182d34bc947ab6e12f0d3a039278ce02ca Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 10 Dec 2021 15:10:45 +0000 Subject: [PATCH 3/6] Reducing the load on DB caused by CouchDB all_db when working with a large number of couch databases. --- packages/auth/src/db/utils.js | 45 +++++++++++++++++++++++++++++------ packages/auth/src/helpers.js | 9 +++++++ 2 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 packages/auth/src/helpers.js diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index d23d407dab..7ced405c82 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -3,10 +3,15 @@ const Replication = require("./Replication") const { DEFAULT_TENANT_ID, Configs } = require("../constants") const env = require("../environment") const { StaticDatabases, SEPARATOR, DocumentTypes } = require("./constants") -const { getTenantId, getTenantIDFromAppID } = require("../tenancy") +const { + getTenantId, + getTenantIDFromAppID, + getGlobalDBName, +} = require("../tenancy") const fetch = require("node-fetch") const { getCouch } = require("./index") const { getAppMetadata } = require("../cache/appMetadata") +const { checkSlashesInUrl } = require("../helpers") const NO_APP_ERROR = "No app provided" @@ -194,6 +199,10 @@ exports.getCouchUrl = () => { return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}` } +exports.getStartEndKeyURL = (base, baseKey, tenantId = "") => { + return `${base}?startkey="${baseKey}${SEPARATOR}${tenantId}"&endkey="${baseKey}${SEPARATOR}${tenantId}${UNICODE_MAX}"` +} + /** * if in production this will use the CouchDB _all_dbs call to retrieve a list of databases. If testing * when using Pouch it will use the pouchdb-all-dbs package. @@ -203,12 +212,34 @@ exports.getAllDbs = async () => { if (env.isTest()) { return getCouch().allDbs() } - const response = await fetch(`${exports.getCouchUrl()}/_all_dbs`) - if (response.status === 200) { - return response.json() - } else { - throw "Cannot connect to CouchDB instance" + let dbs = [] + async function addDbs(url) { + const response = await fetch(checkSlashesInUrl(encodeURI(url))) + if (response.status === 200) { + let json = await response.json() + dbs = dbs.concat(json) + } else { + throw "Cannot connect to CouchDB instance" + } } + let couchUrl = `${exports.getCouchUrl()}_all_dbs` + if (env.MULTI_TENANCY) { + let tenantId = getTenantId() + // get prod apps + await addDbs( + exports.getStartEndKeyURL(couchUrl, DocumentTypes.APP, tenantId) + ) + // get dev apps + await addDbs( + exports.getStartEndKeyURL(couchUrl, DocumentTypes.APP_DEV, tenantId) + ) + // add global db name + dbs.push(getGlobalDBName(tenantId)) + } else { + // just get all DBs in self host + await addDbs(couchUrl) + } + return dbs } /** @@ -389,7 +420,7 @@ const getScopedFullConfig = async function (db, { type, user, workspace }) { } const getPlatformUrl = async settings => { - let platformUrl = env.PLATFORM_URL + let platformUrl = env.PLATFORM_URL || "http://localhost:10000" if (!env.SELF_HOSTED && env.MULTI_TENANCY) { // cloud and multi tenant - add the tenant to the default platform url diff --git a/packages/auth/src/helpers.js b/packages/auth/src/helpers.js new file mode 100644 index 0000000000..b402a82cf3 --- /dev/null +++ b/packages/auth/src/helpers.js @@ -0,0 +1,9 @@ +/** + * Makes sure that a URL has the correct number of slashes, while maintaining the + * http(s):// double slashes. + * @param {string} url The URL to test and remove any extra double slashes. + * @return {string} The updated url. + */ +exports.checkSlashesInUrl = url => { + return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2") +} From ce3d7df39de7f224aa3ef25b9dee01979f5478c1 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 10 Dec 2021 15:17:18 +0000 Subject: [PATCH 4/6] Allowing start end key syntax to be used outside of tenancy if we need to. --- packages/auth/src/db/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 7ced405c82..a091896342 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -199,8 +199,9 @@ exports.getCouchUrl = () => { return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}` } -exports.getStartEndKeyURL = (base, baseKey, tenantId = "") => { - return `${base}?startkey="${baseKey}${SEPARATOR}${tenantId}"&endkey="${baseKey}${SEPARATOR}${tenantId}${UNICODE_MAX}"` +exports.getStartEndKeyURL = (base, baseKey, tenantId = null) => { + const tenancy = tenantId ? `${SEPARATOR}${tenantId}` : "" + return `${base}?startkey="${baseKey}${tenancy}"&endkey="${baseKey}${tenancy}${UNICODE_MAX}"` } /** From 7567c778c8b46b3a4630be6d37567a32d56d682c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 10 Dec 2021 15:18:57 +0000 Subject: [PATCH 5/6] Removing repeated line. --- packages/auth/src/db/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index a091896342..03c6e8e145 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -436,7 +436,7 @@ const getPlatformUrl = async settings => { } } - return platformUrl ? platformUrl : "http://localhost:10000" + return platformUrl } async function getScopedConfig(db, params) { From e1a527a4bbc086c926154cc81c59e25679ba6a8b Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 10 Dec 2021 15:45:07 +0000 Subject: [PATCH 6/6] v1.0.14 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index cf8ebab2af..77d9f56696 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.13", + "version": "1.0.14", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 7053ddab67..9770f84c25 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "1.0.13", + "version": "1.0.14", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index edc16608cb..0a62ba22b3 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.13", + "version": "1.0.14", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index f9a4cf2407..5e64f3a427 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.13", + "version": "1.0.14", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.13", - "@budibase/client": "^1.0.13", + "@budibase/bbui": "^1.0.14", + "@budibase/client": "^1.0.14", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.13", + "@budibase/string-templates": "^1.0.14", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 6e5d4760c8..a04ed0b907 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.13", + "version": "1.0.14", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 66bc2f4da0..8b708c0794 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.13", + "version": "1.0.14", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.13", + "@budibase/bbui": "^1.0.14", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.13", + "@budibase/string-templates": "^1.0.14", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 87610747af..bbd6248efd 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.13", + "version": "1.0.14", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -69,9 +69,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.13", - "@budibase/client": "^1.0.13", - "@budibase/string-templates": "^1.0.13", + "@budibase/auth": "^1.0.14", + "@budibase/client": "^1.0.14", + "@budibase/string-templates": "^1.0.14", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index ad7928f062..f8b298196f 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.13", + "version": "1.0.14", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 7bba900ee7..0dabee0e97 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.13", + "version": "1.0.14", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/auth": "^1.0.13", - "@budibase/string-templates": "^1.0.13", + "@budibase/auth": "^1.0.14", + "@budibase/string-templates": "^1.0.14", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0",