From fe7b632727904fbb0b6fb46b08837a4fdedf4278 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 24 Jan 2023 19:09:36 +0000 Subject: [PATCH 01/18] Quick updates for #8989 - this issue appeared to be fixed already but just adding a few extra bits of security to make sure that looping only occurs when valid data is found in the binding. --- packages/bbui/yarn.lock | 8 ++++---- packages/server/src/threads/automation.ts | 14 +++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/bbui/yarn.lock b/packages/bbui/yarn.lock index 3286c33e69..16f1feb920 100644 --- a/packages/bbui/yarn.lock +++ b/packages/bbui/yarn.lock @@ -114,10 +114,10 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/accordion/-/accordion-3.0.24.tgz#f89066c120c57b0cfc9aba66d60c39fc1cf69f74" integrity sha512-jNOmUsxmiT3lRLButnN5KKHM94fd+87fjiF8L0c4uRNgJl6ZsBuxPXrM15lV4y1f8D2IACAw01/ZkGRAeaCOFA== -"@spectrum-css/actionbutton@^1.0.1": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@spectrum-css/actionbutton/-/actionbutton-1.0.2.tgz#7753a94c64cebecfca6749ef20e37a5ea80c59be" - integrity sha512-laDWk7PCgy2I0AGsMjTmYKkiMVYVoF1B4tffJf4cIp66znTiqPHEbLDh5EDNU88JLTY2bWoCOY4cJxvXk5gERw== +"@spectrum-css/actionbutton@1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/actionbutton/-/actionbutton-1.0.1.tgz#9c75da37ea6915919fb574c74bd60dacc03b6577" + integrity sha512-AUqtyNabHF451Aj9i3xz82TxS5Z6k1dttA68/1hMeU9kbPCSS4P6Viw3vaRGs9CSspuR8xnnhDgrq+F+zMy2Hw== "@spectrum-css/actiongroup@1.0.1": version "1.0.1" diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 44951869f4..d765ef8472 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -37,9 +37,13 @@ function getLoopIterations(loopStep: LoopStep, input: LoopInput) { if (!loopStep || !binding) { return 1 } - return Array.isArray(binding) - ? binding.length - : automationUtils.stringSplit(binding).length + if (Array.isArray(binding)) { + return binding.length + } + if (typeof binding === "string") { + return automationUtils.stringSplit(binding).length + } + return 1 } /** @@ -280,13 +284,13 @@ class Orchestrator { break } - let item + let item = [] if ( typeof loopStep.inputs.binding === "string" && loopStep.inputs.option === "String" ) { item = automationUtils.stringSplit(newInput.binding) - } else { + } else if (Array.isArray(loopStep.inputs.binding)) { item = loopStep.inputs.binding } this._context.steps[loopStepNumber] = { From 767b7839234b93739d9efaf7acd6476b92f1750d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 25 Jan 2023 09:15:12 +0000 Subject: [PATCH 02/18] Fix upgrade button not working when account portal is an external URL --- .../src/pages/builder/portal/_components/UpgradeButton.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte b/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte index 7de6205a31..5b02bb1e84 100644 --- a/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte +++ b/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte @@ -10,7 +10,7 @@ size="S" on:click on:click={() => { - $goto($admin.accountPortalUrl + "/portal/upgrade") + window.open($admin.accountPortalUrl + "/portal/upgrade", "_blank") }} > Upgrade From e9b1c9e063f1d9e44399fa870fa0a510e0510373 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 25 Jan 2023 09:25:53 +0000 Subject: [PATCH 03/18] v2.2.12-alpha.36 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/sdk/package.json | 2 +- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lerna.json b/lerna.json index fa4cea6971..0b0801c9f6 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 2344dc27ae..ecfdaed67d 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -23,7 +23,7 @@ }, "dependencies": { "@budibase/nano": "10.1.1", - "@budibase/types": "2.2.12-alpha.35", + "@budibase/types": "2.2.12-alpha.36", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-cloudfront-sign": "2.2.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 7c6ccfcc38..3894241cac 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": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "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": "2.2.12-alpha.35", + "@budibase/string-templates": "2.2.12-alpha.36", "@spectrum-css/accordion": "3.0.24", "@spectrum-css/actionbutton": "1.0.1", "@spectrum-css/actiongroup": "1.0.1", diff --git a/packages/builder/package.json b/packages/builder/package.json index fca2f69bc6..59bcafbc58 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "license": "GPL-3.0", "private": true, "scripts": { @@ -71,10 +71,10 @@ } }, "dependencies": { - "@budibase/bbui": "2.2.12-alpha.35", - "@budibase/client": "2.2.12-alpha.35", - "@budibase/frontend-core": "2.2.12-alpha.35", - "@budibase/string-templates": "2.2.12-alpha.35", + "@budibase/bbui": "2.2.12-alpha.36", + "@budibase/client": "2.2.12-alpha.36", + "@budibase/frontend-core": "2.2.12-alpha.36", + "@budibase/string-templates": "2.2.12-alpha.36", "@sentry/browser": "5.19.1", "@spectrum-css/accordion": "^3.0.24", "@spectrum-css/page": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 408c76a762..78ab0eba82 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "2.2.12-alpha.35", - "@budibase/string-templates": "2.2.12-alpha.35", - "@budibase/types": "2.2.12-alpha.35", + "@budibase/backend-core": "2.2.12-alpha.36", + "@budibase/string-templates": "2.2.12-alpha.36", + "@budibase/types": "2.2.12-alpha.36", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 33b9aa82f4..3b37ac41e9 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "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": "2.2.12-alpha.35", - "@budibase/frontend-core": "2.2.12-alpha.35", - "@budibase/string-templates": "2.2.12-alpha.35", + "@budibase/bbui": "2.2.12-alpha.36", + "@budibase/frontend-core": "2.2.12-alpha.36", + "@budibase/string-templates": "2.2.12-alpha.36", "@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 dc45bb9a9a..3ca233c979 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "2.2.12-alpha.35", + "@budibase/bbui": "2.2.12-alpha.36", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 0a870d9b0e..6ff23b743a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/sdk", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "description": "Budibase Public API SDK", "author": "Budibase", "license": "MPL-2.0", diff --git a/packages/server/package.json b/packages/server/package.json index db493c2b8a..f9d27397cc 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -43,11 +43,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "2.2.12-alpha.35", - "@budibase/client": "2.2.12-alpha.35", + "@budibase/backend-core": "2.2.12-alpha.36", + "@budibase/client": "2.2.12-alpha.36", "@budibase/pro": "2.2.12-alpha.35", - "@budibase/string-templates": "2.2.12-alpha.35", - "@budibase/types": "2.2.12-alpha.35", + "@budibase/string-templates": "2.2.12-alpha.36", + "@budibase/types": "2.2.12-alpha.36", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index d0b72e9175..91e1dfe293 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "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 4f296c9e6b..35180f8835 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "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 f7702128b6..1062c8eb94 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "2.2.12-alpha.35", + "version": "2.2.12-alpha.36", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -36,10 +36,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "2.2.12-alpha.35", + "@budibase/backend-core": "2.2.12-alpha.36", "@budibase/pro": "2.2.12-alpha.35", - "@budibase/string-templates": "2.2.12-alpha.35", - "@budibase/types": "2.2.12-alpha.35", + "@budibase/string-templates": "2.2.12-alpha.36", + "@budibase/types": "2.2.12-alpha.36", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 8716581d9d768be2be38165e60d5cf632dc359a1 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 25 Jan 2023 09:29:18 +0000 Subject: [PATCH 04/18] Update pro version to 2.2.12-alpha.36 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index f9d27397cc..ea686b1349 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -45,7 +45,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "2.2.12-alpha.36", "@budibase/client": "2.2.12-alpha.36", - "@budibase/pro": "2.2.12-alpha.35", + "@budibase/pro": "2.2.12-alpha.36", "@budibase/string-templates": "2.2.12-alpha.36", "@budibase/types": "2.2.12-alpha.36", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 69a75c4166..8757525049 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1273,13 +1273,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@2.2.12-alpha.35": - version "2.2.12-alpha.35" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12-alpha.35.tgz#36045cdccee548d86a5d0951606d41d0de96bd5c" - integrity sha512-CdIioYKH6y8KQRMWJ2esiOeCOOs3RIGGAAY7DYw71ejjxtCcAZ8Fnez+xIgTFqI6Hee64HjMbX2Tc3OO4J/Kxg== +"@budibase/backend-core@2.2.12-alpha.36": + version "2.2.12-alpha.36" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12-alpha.36.tgz#cabf232b1ab99d932b5a76fe32cf7e0037da6a3f" + integrity sha512-/8uqdYDXTp+wP9+cURL54jlqbwZDoXr917Alw01qlXS00oxqSbaQA4YmLiONjk/V/O8HvYCJRiiCFMS5bz2q4w== dependencies: "@budibase/nano" "10.1.1" - "@budibase/types" "2.2.12-alpha.35" + "@budibase/types" "2.2.12-alpha.36" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-cloudfront-sign "2.2.0" @@ -1374,13 +1374,13 @@ qs "^6.11.0" tough-cookie "^4.1.2" -"@budibase/pro@2.2.12-alpha.35": - version "2.2.12-alpha.35" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12-alpha.35.tgz#6b0f3c2e616b9603b05292dede50d44d3e2d60fe" - integrity sha512-bFaPfocgEUDT3kZV/BWjui9kGr/hn5mfTlj/pPMGQnA/8E9sToJR5bjKjjFrZUr1YrclFDUkaEsixWBK1hWPaw== +"@budibase/pro@2.2.12-alpha.36": + version "2.2.12-alpha.36" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12-alpha.36.tgz#6869e676eb3a01eb9ecea5574eabb2cfdb9f57b2" + integrity sha512-IK+iShaGrJ0k3z9+JEjRHSFYZz2nlnQlQ/4juOoJn5hTaLxkJ9nDPQ2PbzynPLfPj817BmzHLJH272YoLr216Q== dependencies: - "@budibase/backend-core" "2.2.12-alpha.35" - "@budibase/types" "2.2.12-alpha.35" + "@budibase/backend-core" "2.2.12-alpha.36" + "@budibase/types" "2.2.12-alpha.36" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" @@ -1405,10 +1405,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@2.2.12-alpha.35": - version "2.2.12-alpha.35" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12-alpha.35.tgz#35c812289a3ca97c18629c4cf3607bf1aa3539da" - integrity sha512-mkGA/Ago7ckqPeoq70DLN2flbIYpaJgniwd7Tz6zlSrLlBC+fBUSdjzxeXE3FASr3NtC7qHyVS6ZMXEpou6/QQ== +"@budibase/types@2.2.12-alpha.36": + version "2.2.12-alpha.36" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12-alpha.36.tgz#cd51bd207df840e3f803c9397d1b4346037f17ec" + integrity sha512-v6l7JQCCVQ8eGV4npCUJKo+mgqt6+QKJjFYKXjuhLNVvxz1szxxOa1fLDey4yuIiL/gH/Q/SHWA28FlKF31L2w== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index 1062c8eb94..8e70dbd4d8 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -37,7 +37,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "2.2.12-alpha.36", - "@budibase/pro": "2.2.12-alpha.35", + "@budibase/pro": "2.2.12-alpha.36", "@budibase/string-templates": "2.2.12-alpha.36", "@budibase/types": "2.2.12-alpha.36", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 30ab4d4d0a..38a07998f6 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -470,13 +470,13 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@2.2.12-alpha.35": - version "2.2.12-alpha.35" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12-alpha.35.tgz#36045cdccee548d86a5d0951606d41d0de96bd5c" - integrity sha512-CdIioYKH6y8KQRMWJ2esiOeCOOs3RIGGAAY7DYw71ejjxtCcAZ8Fnez+xIgTFqI6Hee64HjMbX2Tc3OO4J/Kxg== +"@budibase/backend-core@2.2.12-alpha.36": + version "2.2.12-alpha.36" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.2.12-alpha.36.tgz#cabf232b1ab99d932b5a76fe32cf7e0037da6a3f" + integrity sha512-/8uqdYDXTp+wP9+cURL54jlqbwZDoXr917Alw01qlXS00oxqSbaQA4YmLiONjk/V/O8HvYCJRiiCFMS5bz2q4w== dependencies: "@budibase/nano" "10.1.1" - "@budibase/types" "2.2.12-alpha.35" + "@budibase/types" "2.2.12-alpha.36" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-cloudfront-sign "2.2.0" @@ -521,23 +521,23 @@ qs "^6.11.0" tough-cookie "^4.1.2" -"@budibase/pro@2.2.12-alpha.35": - version "2.2.12-alpha.35" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12-alpha.35.tgz#6b0f3c2e616b9603b05292dede50d44d3e2d60fe" - integrity sha512-bFaPfocgEUDT3kZV/BWjui9kGr/hn5mfTlj/pPMGQnA/8E9sToJR5bjKjjFrZUr1YrclFDUkaEsixWBK1hWPaw== +"@budibase/pro@2.2.12-alpha.36": + version "2.2.12-alpha.36" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.2.12-alpha.36.tgz#6869e676eb3a01eb9ecea5574eabb2cfdb9f57b2" + integrity sha512-IK+iShaGrJ0k3z9+JEjRHSFYZz2nlnQlQ/4juOoJn5hTaLxkJ9nDPQ2PbzynPLfPj817BmzHLJH272YoLr216Q== dependencies: - "@budibase/backend-core" "2.2.12-alpha.35" - "@budibase/types" "2.2.12-alpha.35" + "@budibase/backend-core" "2.2.12-alpha.36" + "@budibase/types" "2.2.12-alpha.36" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" jsonwebtoken "8.5.1" node-fetch "^2.6.1" -"@budibase/types@2.2.12-alpha.35": - version "2.2.12-alpha.35" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12-alpha.35.tgz#35c812289a3ca97c18629c4cf3607bf1aa3539da" - integrity sha512-mkGA/Ago7ckqPeoq70DLN2flbIYpaJgniwd7Tz6zlSrLlBC+fBUSdjzxeXE3FASr3NtC7qHyVS6ZMXEpou6/QQ== +"@budibase/types@2.2.12-alpha.36": + version "2.2.12-alpha.36" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.2.12-alpha.36.tgz#cd51bd207df840e3f803c9397d1b4346037f17ec" + integrity sha512-v6l7JQCCVQ8eGV4npCUJKo+mgqt6+QKJjFYKXjuhLNVvxz1szxxOa1fLDey4yuIiL/gH/Q/SHWA28FlKF31L2w== "@cspotcode/source-map-support@^0.8.0": version "0.8.1" From 49e79bfeec07f0e77826a62a3283d8e97210da52 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Wed, 25 Jan 2023 13:09:20 +0000 Subject: [PATCH 05/18] Prevent many-many relationships with same tables (#9421) * Prevent many-many relationships with same tables * Don't check relationship if original tables * Refactor --- .../Datasources/CreateEditRelationship.svelte | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte index e4cbbfc7aa..e43437d756 100644 --- a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte +++ b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte @@ -19,6 +19,8 @@ export let close const colNotSet = "Please specify a column name" + const relationshipAlreadyExists = + "A relationship between these tables already exists." const relationshipTypes = [ { label: "One to Many", @@ -154,6 +156,10 @@ if (!isMany && !fromPrimary) { errObj.fromPrimary = "Please pick the primary key" } + if (isMany && relationshipExists()) { + errObj.fromTable = relationshipAlreadyExists + errObj.toTable = relationshipAlreadyExists + } // currently don't support relationships back onto the table itself, needs to relate out const tableError = "From/to/through tables must be different" @@ -271,6 +277,35 @@ toRelationship = relateTo } + function relationshipExists() { + if ( + originalFromTable && + originalToTable && + originalFromTable === fromTable && + originalToTable === toTable + ) { + return false + } + let fromThroughLinks = Object.values( + datasource.entities[fromTable.name].schema + ).filter(value => value.through) + let toThroughLinks = Object.values( + datasource.entities[toTable.name].schema + ).filter(value => value.through) + + const matchAgainstUserInput = (fromTableId, toTableId) => + (fromTableId === fromId && toTableId === toId) || + (fromTableId === toId && toTableId === fromId) + + return !!fromThroughLinks.find(from => + toThroughLinks.find( + to => + from.through === to.through && + matchAgainstUserInput(from.tableId, to.tableId) + ) + ) + } + function removeExistingRelationship() { if (originalFromTable && originalFromColumnName) { delete datasource.entities[originalFromTable.name].schema[ @@ -332,8 +367,13 @@ bind:error={errors.fromTable} on:change={e => { fromColumn = tableOptions.find(opt => opt.value === e.detail)?.label || "" + if (errors.fromTable === relationshipAlreadyExists) { + errors.toColumn = null + } errors.fromTable = null errors.fromColumn = null + errors.toTable = null + errors.throughTable = null }} /> {#if isManyToOne && fromTable} @@ -352,8 +392,13 @@ bind:error={errors.toTable} on:change={e => { toColumn = tableOptions.find(opt => opt.value === e.detail)?.label || "" + if (errors.toTable === relationshipAlreadyExists) { + errors.fromColumn = null + } errors.toTable = null errors.toColumn = null + errors.fromTable = null + errors.throughTable = null }} /> {#if isManyToMany} @@ -362,6 +407,11 @@ options={tableOptions} bind:value={throughId} bind:error={errors.throughTable} + on:change={() => { + errors.fromTable = null + errors.toTable = null + errors.throughTable = null + }} /> {#if fromTable && toTable && throughTable}