From f77b596a075fd2b3c6c484b6d8f63c982fe54807 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 11 Feb 2022 14:04:23 +0000 Subject: [PATCH 01/21] Fix for #4431 - converting SQL joins back to left joins, syntax specifying join type as string is old which doesn't work in latest versions of knex. --- .../api/controllers/row/ExternalRequest.ts | 2 +- packages/server/src/integrations/base/sql.ts | 68 ++++++++----------- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 6aa51fb36b..c1181dd6d5 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -541,7 +541,7 @@ module External { if (!linkTable || !linkPrimary) { return } - const rows = related[key].rows || [] + const rows = related[key]?.rows || [] const found = rows.find( (row: { [key: string]: any }) => row[linkPrimary] === relationship.id || diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index a4220565cf..ce06624107 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -210,49 +210,37 @@ class InternalBuilder { const { toTable, throughTable } = JSON.parse(key) if (!throughTable) { // @ts-ignore - query = query.join( - toTable, - function () { - for (let relationship of relationships) { - const from = relationship.from, - to = relationship.to - // @ts-ignore - this.orOn(`${fromTable}.${from}`, "=", `${toTable}.${to}`) - } - }, - "left" - ) + query = query.leftJoin(toTable, function () { + for (let relationship of relationships) { + const from = relationship.from, + to = relationship.to + // @ts-ignore + this.orOn(`${fromTable}.${from}`, "=", `${toTable}.${to}`) + } + }) } else { query = query // @ts-ignore - .join( - throughTable, - function () { - for (let relationship of relationships) { - const fromPrimary = relationship.fromPrimary - const from = relationship.from - // @ts-ignore - this.orOn( - `${fromTable}.${fromPrimary}`, - "=", - `${throughTable}.${from}` - ) - } - }, - "left" - ) - .join( - toTable, - function () { - for (let relationship of relationships) { - const toPrimary = relationship.toPrimary - const to = relationship.to - // @ts-ignore - this.orOn(`${toTable}.${toPrimary}`, `${throughTable}.${to}`) - } - }, - "left" - ) + .leftJoin(throughTable, function () { + for (let relationship of relationships) { + const fromPrimary = relationship.fromPrimary + const from = relationship.from + // @ts-ignore + this.orOn( + `${fromTable}.${fromPrimary}`, + "=", + `${throughTable}.${from}` + ) + } + }) + .leftJoin(toTable, function () { + for (let relationship of relationships) { + const toPrimary = relationship.toPrimary + const to = relationship.to + // @ts-ignore + this.orOn(`${toTable}.${toPrimary}`, `${throughTable}.${to}`) + } + }) } } return query.limit(BASE_LIMIT) From 93336bf798021589215320026c2e9aa682dcb21b Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 11 Feb 2022 18:25:35 +0000 Subject: [PATCH 02/21] v1.0.59 --- lerna.json | 2 +- packages/backend-core/package.json | 2 +- packages/bbui/package.json | 2 +- 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 | 8 ++++---- 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 60a6d08176..74caf62230 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.58", + "version": "1.0.59", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 84d239e18c..934ca1466a 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.58", + "version": "1.0.59", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 228b93ee22..7ee39039b6 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.58", + "version": "1.0.59", "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 f1b5f1ef81..7fbb49267f 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.58", + "version": "1.0.59", "license": "GPL-3.0", "private": true, "scripts": { @@ -64,10 +64,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.58", - "@budibase/client": "^1.0.58", - "@budibase/frontend-core": "^1.0.58", - "@budibase/string-templates": "^1.0.58", + "@budibase/bbui": "^1.0.59", + "@budibase/client": "^1.0.59", + "@budibase/frontend-core": "^1.0.59", + "@budibase/string-templates": "^1.0.59", "@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 47f20bd0ae..5321235569 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.58", + "version": "1.0.59", "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 ed8ced31af..a5e03eef6e 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.58", + "version": "1.0.59", "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.58", - "@budibase/frontend-core": "^1.0.58", - "@budibase/string-templates": "^1.0.58", + "@budibase/bbui": "^1.0.59", + "@budibase/frontend-core": "^1.0.59", + "@budibase/string-templates": "^1.0.59", "regexparam": "^1.3.0", "rollup-plugin-polyfill-node": "^0.8.0", "shortid": "^2.2.15", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index ca2742550a..9b231d0c66 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.0.58", + "version": "1.0.59", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.0.58", + "@budibase/bbui": "^1.0.59", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index b06a939f59..a9dd5ed280 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.58", + "version": "1.0.59", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.58", - "@budibase/client": "^1.0.58", - "@budibase/string-templates": "^1.0.58", + "@budibase/backend-core": "^1.0.59", + "@budibase/client": "^1.0.59", + "@budibase/string-templates": "^1.0.59", "@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 9fb3669b19..2c1d8fff13 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.58", + "version": "1.0.59", "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 044ddc2a53..d060c04460 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.58", + "version": "1.0.59", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -34,8 +34,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.58", - "@budibase/string-templates": "^1.0.58", + "@budibase/backend-core": "^1.0.59", + "@budibase/string-templates": "^1.0.59", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", From 1cc7109551bba0fe1a88337617a380716b03f666 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 11 Feb 2022 19:40:28 +0100 Subject: [PATCH 03/21] Update release-selfhost.yml --- .github/workflows/release-selfhost.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-selfhost.yml b/.github/workflows/release-selfhost.yml index e842da9d7c..f76ae530c2 100644 --- a/.github/workflows/release-selfhost.yml +++ b/.github/workflows/release-selfhost.yml @@ -29,10 +29,12 @@ jobs: # Tag apps and worker images docker tag budibase/apps:$release_tag budibase/apps:$SELFHOST_TAG docker tag budibase/worker:$release_tag budibase/worker:$SELFHOST_TAG + docker tag budibase/proxy:$release_tag budibase/proxy:$SELFHOST_TAG # Push images docker push budibase/apps:$SELFHOST_TAG docker push budibase/worker:$SELFHOST_TAG + docker push budibase/proxy:$SELFHOST_TAG env: DOCKER_USER: ${{ secrets.DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.DOCKER_API_KEY }} @@ -73,4 +75,4 @@ jobs: files: | packages/cli/build/cli-win.exe packages/cli/build/cli-linux - packages/cli/build/cli-macos \ No newline at end of file + packages/cli/build/cli-macos From c27a552d8805eea76640619c73bb9d87741b2aec Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 11 Feb 2022 18:47:34 +0000 Subject: [PATCH 04/21] v1.0.60 --- lerna.json | 2 +- packages/backend-core/package.json | 2 +- packages/bbui/package.json | 2 +- 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 | 8 ++++---- 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 74caf62230..3e18ded921 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.59", + "version": "1.0.60", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 934ca1466a..c8322eb6f7 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.59", + "version": "1.0.60", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 7ee39039b6..2e29022247 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.59", + "version": "1.0.60", "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 7fbb49267f..5e04ac75dd 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.59", + "version": "1.0.60", "license": "GPL-3.0", "private": true, "scripts": { @@ -64,10 +64,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.59", - "@budibase/client": "^1.0.59", - "@budibase/frontend-core": "^1.0.59", - "@budibase/string-templates": "^1.0.59", + "@budibase/bbui": "^1.0.60", + "@budibase/client": "^1.0.60", + "@budibase/frontend-core": "^1.0.60", + "@budibase/string-templates": "^1.0.60", "@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 5321235569..7da657a4d2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.59", + "version": "1.0.60", "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 a5e03eef6e..dc15ef081a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.59", + "version": "1.0.60", "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.59", - "@budibase/frontend-core": "^1.0.59", - "@budibase/string-templates": "^1.0.59", + "@budibase/bbui": "^1.0.60", + "@budibase/frontend-core": "^1.0.60", + "@budibase/string-templates": "^1.0.60", "regexparam": "^1.3.0", "rollup-plugin-polyfill-node": "^0.8.0", "shortid": "^2.2.15", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 9b231d0c66..014679f2e8 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.0.59", + "version": "1.0.60", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.0.59", + "@budibase/bbui": "^1.0.60", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index a9dd5ed280..8861a9920f 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.59", + "version": "1.0.60", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.59", - "@budibase/client": "^1.0.59", - "@budibase/string-templates": "^1.0.59", + "@budibase/backend-core": "^1.0.60", + "@budibase/client": "^1.0.60", + "@budibase/string-templates": "^1.0.60", "@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 2c1d8fff13..6d354b9b6f 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.59", + "version": "1.0.60", "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 d060c04460..bccbd992b1 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.59", + "version": "1.0.60", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -34,8 +34,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.59", - "@budibase/string-templates": "^1.0.59", + "@budibase/backend-core": "^1.0.60", + "@budibase/string-templates": "^1.0.60", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", From f86222a98d06ba76ebd3a45d11a5d7c6148da14c Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Thu, 10 Feb 2022 09:25:13 +0100 Subject: [PATCH 05/21] Fix validation for query preview endpoint --- packages/server/src/api/controllers/query/validation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/src/api/controllers/query/validation.js b/packages/server/src/api/controllers/query/validation.js index 4958433849..4486ff2307 100644 --- a/packages/server/src/api/controllers/query/validation.js +++ b/packages/server/src/api/controllers/query/validation.js @@ -33,6 +33,9 @@ exports.generateQueryPreviewValidation = () => { return joiValidator.body(Joi.object({ fields: Joi.object().required(), queryVerb: Joi.string().allow().required(), + name: Joi.string().required(), + flags: Joi.object().optional(), + schema: Joi.object().optional(), extra: Joi.object().optional(), datasourceId: Joi.string().required(), transformer: Joi.string().optional(), From 88383eabf144b23541edaf4a7498b58c20cdc87a Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Thu, 10 Feb 2022 10:22:57 +0100 Subject: [PATCH 06/21] add properties which are present when previewing an existing query --- packages/server/src/api/controllers/query/validation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/src/api/controllers/query/validation.js b/packages/server/src/api/controllers/query/validation.js index 4486ff2307..515c7b591e 100644 --- a/packages/server/src/api/controllers/query/validation.js +++ b/packages/server/src/api/controllers/query/validation.js @@ -31,6 +31,9 @@ exports.generateQueryValidation = () => { exports.generateQueryPreviewValidation = () => { // prettier-ignore return joiValidator.body(Joi.object({ + _id: Joi.string().optional(), + _rev: Joi.string().optional(), + readable: Joi.boolean().optional(), fields: Joi.object().required(), queryVerb: Joi.string().allow().required(), name: Joi.string().required(), From 8ca38cf1358a8996a2986e3300f5ed2ade64130e Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Fri, 11 Feb 2022 17:28:19 +0100 Subject: [PATCH 07/21] fix tests --- .../server/src/api/routes/tests/query.spec.js | 17 +++++++++++++---- .../src/tests/utilities/TestConfiguration.js | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/routes/tests/query.spec.js b/packages/server/src/api/routes/tests/query.spec.js index dac576836e..48e3181d10 100644 --- a/packages/server/src/api/routes/tests/query.spec.js +++ b/packages/server/src/api/routes/tests/query.spec.js @@ -169,6 +169,7 @@ describe("/queries", () => { parameters: {}, fields: {}, queryVerb: "read", + name: datasource.name, }) .set(config.defaultHeaders()) .expect("Content-Type", /json/) @@ -261,9 +262,13 @@ describe("/queries", () => { }) it("check that it automatically retries on fail with cached dynamics", async () => { - const { datasource, query: base } = await config.dynamicVariableDatasource() + const { datasource, query: base } = + await config.dynamicVariableDatasource() // preview once to cache - await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" }) + await preview(datasource, { + path: "www.google.com", + queryString: "test={{ variable3 }}", + }) // check its in cache const contents = await checkCacheForDynamicVariable(base._id, "variable3") expect(contents.rows.length).toEqual(1) @@ -276,9 +281,13 @@ describe("/queries", () => { }) it("deletes variables when linked query is deleted", async () => { - const { datasource, query: base } = await config.dynamicVariableDatasource() + const { datasource, query: base } = + await config.dynamicVariableDatasource() // preview once to cache - await preview(datasource, { path: "www.google.com", queryString: "test={{ variable3 }}" }) + await preview(datasource, { + path: "www.google.com", + queryString: "test={{ variable3 }}", + }) // check its in cache let contents = await checkCacheForDynamicVariable(base._id, "variable3") expect(contents.rows.length).toEqual(1) diff --git a/packages/server/src/tests/utilities/TestConfiguration.js b/packages/server/src/tests/utilities/TestConfiguration.js index 6c2b7d4f98..1b3a91ceab 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.js +++ b/packages/server/src/tests/utilities/TestConfiguration.js @@ -393,6 +393,7 @@ class TestConfiguration { parameters: {}, fields, queryVerb: "read", + name: datasource.name, }) .set(config.defaultHeaders()) .expect("Content-Type", /json/) From 126499f38390a99081acc51e21b34adc225e0ad2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Sat, 12 Feb 2022 10:35:10 +0000 Subject: [PATCH 08/21] Fix for #4440, fixing validation of API endpoints. --- packages/bbui/src/ButtonGroup/ButtonGroup.svelte | 11 +++++++++++ .../components/integration/QueryViewer.svelte | 4 ++-- .../src/api/controllers/query/validation.js | 16 +++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/bbui/src/ButtonGroup/ButtonGroup.svelte b/packages/bbui/src/ButtonGroup/ButtonGroup.svelte index b845a770e1..50d0073a25 100644 --- a/packages/bbui/src/ButtonGroup/ButtonGroup.svelte +++ b/packages/bbui/src/ButtonGroup/ButtonGroup.svelte @@ -1,6 +1,16 @@