From ae73efaabead0e2c8f351981d667465638ca7f4a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 6 Sep 2021 13:36:41 +0100 Subject: [PATCH 1/9] Fixing an issue in prod where the /builder endpoint wasn't being allowed past without tenancy. --- packages/server/src/api/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/server/src/api/index.js b/packages/server/src/api/index.js index c473bf619b..fc86058d08 100644 --- a/packages/server/src/api/index.js +++ b/packages/server/src/api/index.js @@ -15,6 +15,20 @@ const NO_TENANCY_ENDPOINTS = [ route: "/api/analytics", method: "GET", }, + { + route: "/builder", + method: "GET", + }, + // when using this locally there can be pass through, need + // to allow all pass through endpoints to go without tenancy + { + route: "/api/global", + method: "ALL", + }, + { + route: "/api/system", + method: "ALL", + }, ] router From 16167a1f3a5c665e233987a9a679d65c501d61d3 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 6 Sep 2021 13:13:46 +0000 Subject: [PATCH 2/9] v0.9.120 --- 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 | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index c1b6f3860d..e80426a948 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.119", + "version": "0.9.120", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 233e5d7d67..8b1d0f5274 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.119", + "version": "0.9.120", "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 660ecd2a1d..77ede82df2 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": "0.9.119", + "version": "0.9.120", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 7f728b1941..e30dcac5c8 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.119", + "version": "0.9.120", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.119", - "@budibase/client": "^0.9.119", + "@budibase/bbui": "^0.9.120", + "@budibase/client": "^0.9.120", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.119", + "@budibase/string-templates": "^0.9.120", "@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 2d04cb7061..c3003cde68 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.119", + "version": "0.9.120", "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 204b2ef1f4..7cb7ffe0c4 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.119", + "version": "0.9.120", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.119", - "@budibase/standard-components": "^0.9.119", - "@budibase/string-templates": "^0.9.119", + "@budibase/bbui": "^0.9.120", + "@budibase/standard-components": "^0.9.120", + "@budibase/string-templates": "^0.9.120", "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 12dd9208ac..ba787a324a 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.119", + "version": "0.9.120", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -62,9 +62,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.119", - "@budibase/client": "^0.9.119", - "@budibase/string-templates": "^0.9.119", + "@budibase/auth": "^0.9.120", + "@budibase/client": "^0.9.120", + "@budibase/string-templates": "^0.9.120", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -117,7 +117,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.119", + "@budibase/standard-components": "^0.9.120", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 6b248c7694..19b1a6f7ad 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.119", + "version": "0.9.120", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.119", + "@budibase/bbui": "^0.9.120", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 7b6a158a98..f27ab89f42 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.119", + "version": "0.9.120", "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 a0dfa3e98d..d4edbd20b0 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.119", + "version": "0.9.120", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -23,8 +23,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.119", - "@budibase/string-templates": "^0.9.119", + "@budibase/auth": "^0.9.120", + "@budibase/string-templates": "^0.9.120", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From b3655bbee14a7d819293ab62348b4f320349ac62 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 6 Sep 2021 15:14:46 +0100 Subject: [PATCH 3/9] Quick fix for backwards compat, enabling multi-tenancy on a previously single tenancy environment. --- packages/auth/src/cache/user.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/auth/src/cache/user.js b/packages/auth/src/cache/user.js index 4a19da489f..e0936182a7 100644 --- a/packages/auth/src/cache/user.js +++ b/packages/auth/src/cache/user.js @@ -18,6 +18,10 @@ exports.getUser = async (userId, tenantId = null) => { user = await getGlobalDB(tenantId).get(userId) client.store(userId, user, EXPIRY_SECONDS) } + if (user && !user.tenantId && tenantId) { + // make sure the tenant ID is always correct/set + user.tenantId = tenantId + } return user } From 6668e994b29351b8292d3a8180520b0d3c5ab10a Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 6 Sep 2021 14:26:46 +0000 Subject: [PATCH 4/9] v0.9.121 --- 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 | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index e80426a948..644b6a6dca 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.120", + "version": "0.9.121", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 8b1d0f5274..c1f0237343 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.120", + "version": "0.9.121", "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 77ede82df2..6f152c5f1c 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": "0.9.120", + "version": "0.9.121", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index e30dcac5c8..2e8c55c7e2 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.120", + "version": "0.9.121", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.120", - "@budibase/client": "^0.9.120", + "@budibase/bbui": "^0.9.121", + "@budibase/client": "^0.9.121", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.120", + "@budibase/string-templates": "^0.9.121", "@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 c3003cde68..f491ede88e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.120", + "version": "0.9.121", "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 7cb7ffe0c4..e26f2a3202 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.120", + "version": "0.9.121", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.120", - "@budibase/standard-components": "^0.9.120", - "@budibase/string-templates": "^0.9.120", + "@budibase/bbui": "^0.9.121", + "@budibase/standard-components": "^0.9.121", + "@budibase/string-templates": "^0.9.121", "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 ba787a324a..83f457ebb0 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.120", + "version": "0.9.121", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -62,9 +62,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.120", - "@budibase/client": "^0.9.120", - "@budibase/string-templates": "^0.9.120", + "@budibase/auth": "^0.9.121", + "@budibase/client": "^0.9.121", + "@budibase/string-templates": "^0.9.121", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -117,7 +117,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.120", + "@budibase/standard-components": "^0.9.121", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 19b1a6f7ad..90c4ffa5a0 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.120", + "version": "0.9.121", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.120", + "@budibase/bbui": "^0.9.121", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index f27ab89f42..664505adf6 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.120", + "version": "0.9.121", "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 d4edbd20b0..4ec96d4854 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.120", + "version": "0.9.121", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -23,8 +23,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.120", - "@budibase/string-templates": "^0.9.120", + "@budibase/auth": "^0.9.121", + "@budibase/string-templates": "^0.9.121", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 033bd521cf5c0e406de67068539350755ef11cd7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 6 Sep 2021 15:48:46 +0100 Subject: [PATCH 5/9] Fixing an issue with redirect having the middleware applied before the redirection --- packages/server/src/api/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/index.js b/packages/server/src/api/index.js index fc86058d08..6b81fb229b 100644 --- a/packages/server/src/api/index.js +++ b/packages/server/src/api/index.js @@ -53,6 +53,8 @@ router }) .use("/health", ctx => (ctx.status = 200)) .use("/version", ctx => (ctx.body = pkg.version)) + // re-direct before any middlewares occur + .redirect("/", "/builder") .use( buildAuthMiddleware(null, { publicAllowed: true, @@ -93,7 +95,4 @@ for (let route of mainRoutes) { router.use(staticRoutes.routes()) router.use(staticRoutes.allowedMethods()) -// add a redirect for when hitting server directly -router.redirect("/", "/builder") - module.exports = router From a0e0843363fba06134849e32f8d6e6faf5e42d0e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 6 Sep 2021 16:01:45 +0100 Subject: [PATCH 6/9] Allowing all server endpoints to run without tenant information, as most endpoints in server can be public. --- packages/auth/src/middleware/tenancy.js | 8 +++++-- packages/server/src/api/index.js | 29 ++++++------------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/packages/auth/src/middleware/tenancy.js b/packages/auth/src/middleware/tenancy.js index b80b9a6763..68d5051895 100644 --- a/packages/auth/src/middleware/tenancy.js +++ b/packages/auth/src/middleware/tenancy.js @@ -2,12 +2,16 @@ const { setTenantId } = require("../tenancy") const ContextFactory = require("../tenancy/FunctionContext") const { buildMatcherRegex, matches } = require("./matchers") -module.exports = (allowQueryStringPatterns, noTenancyPatterns) => { +module.exports = ( + allowQueryStringPatterns, + noTenancyPatterns, + { noTenancyRequired } +) => { const allowQsOptions = buildMatcherRegex(allowQueryStringPatterns) const noTenancyOptions = buildMatcherRegex(noTenancyPatterns) return ContextFactory.getMiddleware(ctx => { - const allowNoTenant = !!matches(ctx, noTenancyOptions) + const allowNoTenant = noTenancyRequired || !!matches(ctx, noTenancyOptions) const allowQs = !!matches(ctx, allowQsOptions) setTenantId(ctx, { allowQs, allowNoTenant }) }) diff --git a/packages/server/src/api/index.js b/packages/server/src/api/index.js index 6b81fb229b..24567b54a6 100644 --- a/packages/server/src/api/index.js +++ b/packages/server/src/api/index.js @@ -10,27 +10,6 @@ const env = require("../environment") const router = new Router() -const NO_TENANCY_ENDPOINTS = [ - { - route: "/api/analytics", - method: "GET", - }, - { - route: "/builder", - method: "GET", - }, - // when using this locally there can be pass through, need - // to allow all pass through endpoints to go without tenancy - { - route: "/api/global", - method: "ALL", - }, - { - route: "/api/system", - method: "ALL", - }, -] - router .use( compress({ @@ -61,7 +40,13 @@ router }) ) // nothing in the server should allow query string tenants - .use(buildTenancyMiddleware(null, NO_TENANCY_ENDPOINTS)) + // the server can be public anywhere, so nowhere should throw errors + // if the tenancy has not been set, it'll have to be discovered at application layer + .use( + buildTenancyMiddleware(null, null, { + noTenancyRequired: true, + }) + ) .use(currentApp) .use(auditLog) From c1c4fe968f71aabd908fa2048d31a597fe329bca Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 6 Sep 2021 16:18:50 +0100 Subject: [PATCH 7/9] fix test failure --- packages/auth/src/middleware/tenancy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/src/middleware/tenancy.js b/packages/auth/src/middleware/tenancy.js index 68d5051895..c8b24d12e0 100644 --- a/packages/auth/src/middleware/tenancy.js +++ b/packages/auth/src/middleware/tenancy.js @@ -5,13 +5,13 @@ const { buildMatcherRegex, matches } = require("./matchers") module.exports = ( allowQueryStringPatterns, noTenancyPatterns, - { noTenancyRequired } + opts = {} ) => { const allowQsOptions = buildMatcherRegex(allowQueryStringPatterns) const noTenancyOptions = buildMatcherRegex(noTenancyPatterns) return ContextFactory.getMiddleware(ctx => { - const allowNoTenant = noTenancyRequired || !!matches(ctx, noTenancyOptions) + const allowNoTenant = opts.noTenancyRequired || !!matches(ctx, noTenancyOptions) const allowQs = !!matches(ctx, allowQsOptions) setTenantId(ctx, { allowQs, allowNoTenant }) }) From f7718ecae9ecb8e40a7ba973616907b43e1c4de7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 6 Sep 2021 16:24:51 +0100 Subject: [PATCH 8/9] lint --- packages/auth/src/middleware/tenancy.js | 9 ++-- .../api/controllers/row/ExternalRequest.ts | 44 ++++++++++++++----- packages/server/src/definitions/datasource.ts | 2 +- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/packages/auth/src/middleware/tenancy.js b/packages/auth/src/middleware/tenancy.js index c8b24d12e0..19cce82273 100644 --- a/packages/auth/src/middleware/tenancy.js +++ b/packages/auth/src/middleware/tenancy.js @@ -2,16 +2,13 @@ const { setTenantId } = require("../tenancy") const ContextFactory = require("../tenancy/FunctionContext") const { buildMatcherRegex, matches } = require("./matchers") -module.exports = ( - allowQueryStringPatterns, - noTenancyPatterns, - opts = {} -) => { +module.exports = (allowQueryStringPatterns, noTenancyPatterns, opts = {}) => { const allowQsOptions = buildMatcherRegex(allowQueryStringPatterns) const noTenancyOptions = buildMatcherRegex(noTenancyPatterns) return ContextFactory.getMiddleware(ctx => { - const allowNoTenant = opts.noTenancyRequired || !!matches(ctx, noTenancyOptions) + const allowNoTenant = + opts.noTenancyRequired || !!matches(ctx, noTenancyOptions) const allowQs = !!matches(ctx, allowQsOptions) setTenantId(ctx, { allowQs, allowNoTenant }) }) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 648c94bff5..b87e27c067 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -6,8 +6,16 @@ import { SearchFilters, SortJson, } from "../../../definitions/datasource" -import {Datasource, FieldSchema, Row, Table} from "../../../definitions/common" -import {breakRowIdField, generateRowIdField} from "../../../integrations/utils" +import { + Datasource, + FieldSchema, + Row, + Table, +} from "../../../definitions/common" +import { + breakRowIdField, + generateRowIdField, +} from "../../../integrations/utils" import { RelationshipTypes } from "../../../constants" interface ManyRelationship { @@ -348,7 +356,7 @@ module External { * information. */ async lookupRelations(tableId: string, row: Row) { - const related: {[key: string]: any} = {} + const related: { [key: string]: any } = {} const { tableName } = breakExternalTableId(tableId) const table = this.tables[tableName] // @ts-ignore @@ -387,7 +395,11 @@ module External { * isn't supposed to exist anymore and delete those. This is better than the usual method of delete them * all and then re-create, as theres no chance of losing data (e.g. delete succeed, but write fail). */ - async handleManyRelationships(mainTableId: string, row: Row, relationships: ManyRelationship[]) { + async handleManyRelationships( + mainTableId: string, + row: Row, + relationships: ManyRelationship[] + ) { const { appId } = this // if we're creating (in a through table) need to wipe the existing ones first const promises = [] @@ -399,8 +411,10 @@ module External { // @ts-ignore const linkPrimary = linkTable.primary[0] const rows = related[key].rows || [] - const found = rows.find((row: { [key: string]: any }) => - row[linkPrimary] === relationship.id || row[linkPrimary] === body[linkPrimary] + const found = rows.find( + (row: { [key: string]: any }) => + row[linkPrimary] === relationship.id || + row[linkPrimary] === body[linkPrimary] ) const operation = isUpdate ? DataSourceOperation.UPDATE @@ -420,13 +434,17 @@ module External { } } // finally cleanup anything that needs to be removed - for (let [colName, {isMany, rows, tableId}] of Object.entries(related)) { + for (let [colName, { isMany, rows, tableId }] of Object.entries( + related + )) { const table = this.getTable(tableId) for (let row of rows) { const filters = buildFilters(generateIdForRow(row, table), {}, table) // safety check, if there are no filters on deletion bad things happen if (Object.keys(filters).length !== 0) { - const op = isMany ? DataSourceOperation.DELETE : DataSourceOperation.UPDATE + const op = isMany + ? DataSourceOperation.DELETE + : DataSourceOperation.UPDATE const body = isMany ? null : { [colName]: null } promises.push( makeExternalQuery(this.appId, { @@ -448,7 +466,10 @@ module External { * Creating the specific list of fields that we desire, and excluding the ones that are no use to us * is more performant and has the added benefit of protecting against this scenario. */ - buildFields(table: Table, includeRelations: IncludeRelationships = IncludeRelationships.INCLUDE) { + buildFields( + table: Table, + includeRelations: IncludeRelationships = IncludeRelationships.INCLUDE + ) { function extractNonLinkFieldNames(table: Table, existing: string[] = []) { return Object.entries(table.schema) .filter( @@ -523,7 +544,10 @@ module External { // can't really use response right now const response = await makeExternalQuery(appId, json) // handle many to many relationships now if we know the ID (could be auto increment) - if (operation !== DataSourceOperation.READ && processed.manyRelationships) { + if ( + operation !== DataSourceOperation.READ && + processed.manyRelationships + ) { await this.handleManyRelationships( table._id || "", response[0], diff --git a/packages/server/src/definitions/datasource.ts b/packages/server/src/definitions/datasource.ts index a43573ecf7..48fd24e1cf 100644 --- a/packages/server/src/definitions/datasource.ts +++ b/packages/server/src/definitions/datasource.ts @@ -42,7 +42,7 @@ export enum SourceNames { export enum IncludeRelationships { INCLUDE = 1, - EXCLUDE = 0 + EXCLUDE = 0, } export interface QueryDefinition { From ed2f4c78dc9a98c6ae898f97f4fff921eeddd7ea Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 6 Sep 2021 15:45:10 +0000 Subject: [PATCH 9/9] v0.9.122 --- 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 | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 644b6a6dca..5bbd1fee4e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.121", + "version": "0.9.122", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index c1f0237343..487dfe8061 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.121", + "version": "0.9.122", "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 6f152c5f1c..3a841ba064 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": "0.9.121", + "version": "0.9.122", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 2e8c55c7e2..dd31322643 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.121", + "version": "0.9.122", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.121", - "@budibase/client": "^0.9.121", + "@budibase/bbui": "^0.9.122", + "@budibase/client": "^0.9.122", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.121", + "@budibase/string-templates": "^0.9.122", "@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 f491ede88e..8bf22987d8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.121", + "version": "0.9.122", "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 e26f2a3202..a164c7bb87 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.121", + "version": "0.9.122", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.121", - "@budibase/standard-components": "^0.9.121", - "@budibase/string-templates": "^0.9.121", + "@budibase/bbui": "^0.9.122", + "@budibase/standard-components": "^0.9.122", + "@budibase/string-templates": "^0.9.122", "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 83f457ebb0..b8b85a5e85 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.121", + "version": "0.9.122", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -62,9 +62,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.121", - "@budibase/client": "^0.9.121", - "@budibase/string-templates": "^0.9.121", + "@budibase/auth": "^0.9.122", + "@budibase/client": "^0.9.122", + "@budibase/string-templates": "^0.9.122", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -117,7 +117,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.121", + "@budibase/standard-components": "^0.9.122", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 90c4ffa5a0..69b4ed9151 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.121", + "version": "0.9.122", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.121", + "@budibase/bbui": "^0.9.122", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 664505adf6..aaa2f1bfe7 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.121", + "version": "0.9.122", "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 4ec96d4854..816118b1c0 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.121", + "version": "0.9.122", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -23,8 +23,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.121", - "@budibase/string-templates": "^0.9.121", + "@budibase/auth": "^0.9.122", + "@budibase/string-templates": "^0.9.122", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0",