From fedcc2dfd97c42b312185093eb8d57c4ba048efb Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Wed, 13 Jul 2022 21:50:19 +0100 Subject: [PATCH 1/4] Adding a mechanism to deprecate a view and replace it with a new one. --- packages/backend-core/src/db/constants.ts | 9 +++++- packages/backend-core/src/db/views.js | 35 +++++++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/packages/backend-core/src/db/constants.ts b/packages/backend-core/src/db/constants.ts index be0e824e61..716762dd45 100644 --- a/packages/backend-core/src/db/constants.ts +++ b/packages/backend-core/src/db/constants.ts @@ -11,7 +11,7 @@ export enum AutomationViewModes { } export enum ViewNames { - USER_BY_EMAIL = "by_email", + USER_BY_EMAIL = "by_email2", BY_API_KEY = "by_api_key", USER_BY_BUILDERS = "by_builders", LINK = "by_link", @@ -19,6 +19,13 @@ export enum ViewNames { AUTOMATION_LOGS = "automation_logs", } +export const DeprecatedViews = { + [ViewNames.USER_BY_EMAIL]: [ + // removed due to inaccuracy in view doc filter logic + "by_email", + ], +} + export enum DocumentTypes { USER = "us", WORKSPACE = "workspace", diff --git a/packages/backend-core/src/db/views.js b/packages/backend-core/src/db/views.js index e0281c6584..1e8dd7ee77 100644 --- a/packages/backend-core/src/db/views.js +++ b/packages/backend-core/src/db/views.js @@ -1,20 +1,42 @@ -const { DocumentTypes, ViewNames } = require("./utils") +const { + DocumentTypes, + ViewNames, + DeprecatedViews, + SEPARATOR, +} = require("./utils") const { getGlobalDB } = require("../tenancy") +const DESIGN_DB = "_design/database" + function DesignDoc() { return { - _id: "_design/database", + _id: DESIGN_DB, // view collation information, read before writing any complex views: // https://docs.couchdb.org/en/master/ddocs/views/collation.html#collation-specification views: {}, } } -exports.createUserEmailView = async () => { +async function removeDeprecated(db, viewName) { + if (!DeprecatedViews[viewName]) { + return + } + try { + const designDoc = await db.get(DESIGN_DB) + for (let deprecatedNames of DeprecatedViews[viewName]) { + delete designDoc.views[deprecatedNames] + } + await db.put(designDoc) + } catch (err) { + // doesn't exist, ignore + } +} + +exports.createNewUserEmailView = async () => { const db = getGlobalDB() let designDoc try { - designDoc = await db.get("_design/database") + designDoc = await db.get(DESIGN_DB) } catch (err) { // no design doc, make one designDoc = DesignDoc() @@ -22,7 +44,7 @@ exports.createUserEmailView = async () => { const view = { // if using variables in a map function need to inject them before use map: `function(doc) { - if (doc._id.startsWith("${DocumentTypes.USER}")) { + if (doc._id.startsWith("${DocumentTypes.USER}${SEPARATOR}")) { emit(doc.email.toLowerCase(), doc._id) } }`, @@ -81,7 +103,7 @@ exports.createUserBuildersView = async () => { exports.queryGlobalView = async (viewName, params, db = null) => { const CreateFuncByName = { - [ViewNames.USER_BY_EMAIL]: exports.createUserEmailView, + [ViewNames.USER_BY_EMAIL]: exports.createNewUserEmailView, [ViewNames.BY_API_KEY]: exports.createApiKeyView, [ViewNames.USER_BY_BUILDERS]: exports.createUserBuildersView, } @@ -98,6 +120,7 @@ exports.queryGlobalView = async (viewName, params, db = null) => { } catch (err) { if (err != null && err.name === "not_found") { const createFunc = CreateFuncByName[viewName] + await removeDeprecated(db, viewName) await createFunc() return exports.queryGlobalView(viewName, params) } else { From a4bf973141d94029927c9acbec96ceee9254c939 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Thu, 14 Jul 2022 17:18:06 +0000 Subject: [PATCH 2/4] v1.1.8 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lerna.json b/lerna.json index 27628c9c8c..675336e038 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.1.7", + "version": "1.1.8", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 37d322cdb7..d298d5c864 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.1.7", + "version": "1.1.8", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "^1.1.7", + "@budibase/types": "^1.1.8", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", "bcrypt": "5.0.1", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index f2c1b97cfa..bf5517f5b5 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.1.7", + "version": "1.1.8", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "^1.1.7", + "@budibase/string-templates": "^1.1.8", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 7948b63f4d..75d5da075e 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.1.7", + "version": "1.1.8", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.1.7", - "@budibase/client": "^1.1.7", - "@budibase/frontend-core": "^1.1.7", - "@budibase/string-templates": "^1.1.7", + "@budibase/bbui": "^1.1.8", + "@budibase/client": "^1.1.8", + "@budibase/frontend-core": "^1.1.8", + "@budibase/string-templates": "^1.1.8", "@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 0c510a0e5d..9a6c43ca4f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.1.7", + "version": "1.1.8", "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 89d7c6a168..193bddf374 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.1.7", + "version": "1.1.8", "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.1.7", - "@budibase/frontend-core": "^1.1.7", - "@budibase/string-templates": "^1.1.7", + "@budibase/bbui": "^1.1.8", + "@budibase/frontend-core": "^1.1.8", + "@budibase/string-templates": "^1.1.8", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index d2948d497c..0b05465357 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.1.7", + "version": "1.1.8", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.1.7", + "@budibase/bbui": "^1.1.8", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index f1f48d799d..55be2b2016 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.1.7", + "version": "1.1.8", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,10 +77,10 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^1.1.7", - "@budibase/client": "^1.1.7", + "@budibase/backend-core": "^1.1.8", + "@budibase/client": "^1.1.8", "@budibase/pro": "1.1.7", - "@budibase/string-templates": "^1.1.7", + "@budibase/string-templates": "^1.1.8", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", @@ -151,7 +151,7 @@ "@babel/core": "7.17.4", "@babel/preset-env": "7.16.11", "@budibase/standard-components": "^0.9.139", - "@budibase/types": "^1.1.7", + "@budibase/types": "^1.1.8", "@jest/test-sequencer": "24.9.0", "@types/apidoc": "0.50.0", "@types/bson": "4.2.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 49b0757ecb..dfaf82ce52 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.1.7", + "version": "1.1.8", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index b0922b5bf8..bd8a7b02f6 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.1.7", + "version": "1.1.8", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 5eed396674..ddbdf27cb1 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.1.7", + "version": "1.1.8", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -34,9 +34,9 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.1.7", + "@budibase/backend-core": "^1.1.8", "@budibase/pro": "1.1.7", - "@budibase/string-templates": "^1.1.7", + "@budibase/string-templates": "^1.1.8", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", @@ -66,7 +66,7 @@ "server-destroy": "1.0.1" }, "devDependencies": { - "@budibase/types": "^1.1.7", + "@budibase/types": "^1.1.8", "@types/jest": "26.0.23", "@types/koa": "2.13.4", "@types/koa-router": "7.4.4", From 3afbc58b4bd9bed7f6d6823da7b69e76708c6af9 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Thu, 14 Jul 2022 17:19:49 +0000 Subject: [PATCH 3/4] Update pro version to 1.1.8 --- packages/server/package.json | 2 +- packages/worker/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 55be2b2016..9dd8efffaa 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "^1.1.8", "@budibase/client": "^1.1.8", - "@budibase/pro": "1.1.7", + "@budibase/pro": "1.1.8", "@budibase/string-templates": "^1.1.8", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", diff --git a/packages/worker/package.json b/packages/worker/package.json index ddbdf27cb1..26b2eaffdf 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -35,7 +35,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "^1.1.8", - "@budibase/pro": "1.1.7", + "@budibase/pro": "1.1.8", "@budibase/string-templates": "^1.1.8", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", From 2f16e229576a5248e68bd98a564e3855980beb30 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 14 Jul 2022 18:50:09 +0100 Subject: [PATCH 4/4] Switching single image build to workflow dispatch. --- .github/workflows/deploy-single-image.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-single-image.yml b/.github/workflows/deploy-single-image.yml index 7829c5417b..0bd5c71a40 100644 --- a/.github/workflows/deploy-single-image.yml +++ b/.github/workflows/deploy-single-image.yml @@ -1,11 +1,8 @@ name: Deploy Budibase Single Container Image to DockerHub + on: - push: - branches: - - "omnibus-action" - - "develop" - - "master" - - "main" + workflow_dispatch: + env: BASE_BRANCH: ${{ github.event.pull_request.base.ref}} BRANCH: ${{ github.event.pull_request.head.ref }}