From 98963c1505105f2aaf122a25695fe46803de23c5 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 May 2023 11:21:24 +0100 Subject: [PATCH 01/31] Fix for inclusion parsing for arrays and options. View table fix to hide edit button --- .../components/backend/DataTable/Table.svelte | 2 ++ .../backend/DataTable/ViewDataTable.svelte | 1 + .../server/src/api/controllers/table/utils.ts | 16 ++++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 4df6e9a306..bf14bdfc0c 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -22,6 +22,7 @@ export let rowCount export let disableSorting = false export let customPlaceholder = false + export let allowEditing = true const dispatch = createEventDispatcher() @@ -109,6 +110,7 @@ {rowCount} {disableSorting} {customPlaceholder} + allowEditRows={allowEditing} showAutoColumns={!hideAutocolumns} on:clickrelationship={e => selectRelationship(e.detail)} on:sort diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte index 056bc33994..d239cabd59 100644 --- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte @@ -58,6 +58,7 @@ {loading} {type} rowCount={10} + allowEditing={false} bind:hideAutocolumns > diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index 1a3eda683b..e57da7ae2d 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -129,17 +129,21 @@ export function importToRows( // the real schema of the table passed in, not the clone used for // incrementing auto IDs for (const [fieldName, schema] of Object.entries(originalTable.schema)) { + const rowVal = Array.isArray(row[fieldName]) ? row[fieldName] : [row[fieldName]] if ( (schema.type === FieldTypes.OPTIONS || - schema.type === FieldTypes.ARRAY) && - row[fieldName] && - (!schema.constraints!.inclusion || - schema.constraints!.inclusion.indexOf(row[fieldName]) === -1) + schema.type === FieldTypes.ARRAY) && + row[fieldName] ) { - schema.constraints!.inclusion = [ + + let merged = [ ...schema.constraints!.inclusion!, - row[fieldName], + ...rowVal ] + + let superSet = new Set(merged); + schema.constraints!.inclusion = Array.from(superSet); + schema.constraints!.inclusion.sort() } } From f8da7a9f2853c2b40cd95c1b59595ba82a8d5225 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 May 2023 12:12:47 +0100 Subject: [PATCH 02/31] Linting --- .../server/src/api/controllers/table/utils.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index e57da7ae2d..5681095df7 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -129,20 +129,18 @@ export function importToRows( // the real schema of the table passed in, not the clone used for // incrementing auto IDs for (const [fieldName, schema] of Object.entries(originalTable.schema)) { - const rowVal = Array.isArray(row[fieldName]) ? row[fieldName] : [row[fieldName]] + const rowVal = Array.isArray(row[fieldName]) + ? row[fieldName] + : [row[fieldName]] if ( (schema.type === FieldTypes.OPTIONS || - schema.type === FieldTypes.ARRAY) && + schema.type === FieldTypes.ARRAY) && row[fieldName] ) { - - let merged = [ - ...schema.constraints!.inclusion!, - ...rowVal - ] - - let superSet = new Set(merged); - schema.constraints!.inclusion = Array.from(superSet); + let merged = [...schema.constraints!.inclusion!, ...rowVal] + + let superSet = new Set(merged) + schema.constraints!.inclusion = Array.from(superSet) schema.constraints!.inclusion.sort() } From 0aeb06bb2b4da2eaaa97b24bab712eb05fad63d1 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 5 May 2023 13:39:59 +0100 Subject: [PATCH 03/31] Merge commit --- packages/server/src/api/controllers/table/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/src/api/controllers/table/index.ts b/packages/server/src/api/controllers/table/index.ts index bc967a90f4..8e248d57ea 100644 --- a/packages/server/src/api/controllers/table/index.ts +++ b/packages/server/src/api/controllers/table/index.ts @@ -97,6 +97,9 @@ export async function bulkImport(ctx: UserCtx) { // right now we don't trigger anything for bulk import because it // can only be done in the builder, but in the future we may need to // think about events for bulk items + + //const resp = pickApi({ tableId }).save(ctx) + ctx.status = 200 ctx.body = { message: `Bulk rows created.` } } From b387f969d92c7e60cb0902124c56d8591b3f7155 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 8 May 2023 15:59:12 +0100 Subject: [PATCH 04/31] allow passwordless redis --- packages/backend-core/src/environment.ts | 2 +- packages/server/src/api/routes/public/index.ts | 9 ++++++--- yarn.lock | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 155f09e6d9..72cd1a4af0 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -95,7 +95,7 @@ const environment = { GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET, SALT_ROUNDS: process.env.SALT_ROUNDS, REDIS_URL: process.env.REDIS_URL || "localhost:6379", - REDIS_PASSWORD: process.env.REDIS_PASSWORD || "budibase", + REDIS_PASSWORD: process.env.REDIS_PASSWORD, REDIS_CLUSTERED: process.env.REDIS_CLUSTERED, MOCK_REDIS: process.env.MOCK_REDIS, MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY, diff --git a/packages/server/src/api/routes/public/index.ts b/packages/server/src/api/routes/public/index.ts index bed798f75b..287f6c11de 100644 --- a/packages/server/src/api/routes/public/index.ts +++ b/packages/server/src/api/routes/public/index.ts @@ -42,13 +42,16 @@ if (!env.isTest()) { host: REDIS_OPTS.host, port: REDIS_OPTS.port, }, - password: - REDIS_OPTS.opts.password || REDIS_OPTS.opts.redisOptions.password, + } + + if (REDIS_OPTS.opts?.password || REDIS_OPTS.opts.redisOptions?.password) { + // @ts-ignore + options.password = REDIS_OPTS.opts.password || REDIS_OPTS.opts.redisOptions.password } if (!env.REDIS_CLUSTERED) { - // Can't set direct redis db in clustered env // @ts-ignore + // Can't set direct redis db in clustered env options.database = 1 } } diff --git a/yarn.lock b/yarn.lock index d293366bb3..4b2bab4ec2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,15 +1486,15 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" -"@budibase/pro@2.6.6": - version "2.6.6" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.6.6.tgz#337027168d17a44717c2648b3209a0e2daddcf7d" - integrity sha512-RldUn/WjN7eaYRxL4KBufK1yhVIycJOzoncD+BPgRKstuuuYzPultGZcpNsQQiJkAhNR6QXhG+ovvCUiA+AX6g== +"@budibase/pro@2.6.7": + version "2.6.7" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.6.7.tgz#884b33f3a3e3f2e548fd7519d32b40dc98803400" + integrity sha512-f7g+0So7hr7tHHEF28cz550imYpq/CqRNzhMQpUwmzgbdTlOdVej3PWPNK9+MuBlNea3J9b2WQsjS9TkGZfTlA== dependencies: - "@budibase/backend-core" "2.6.6" + "@budibase/backend-core" "2.6.7" "@budibase/shared-core" "2.5.9" "@budibase/string-templates" "2.5.9" - "@budibase/types" "2.6.6" + "@budibase/types" "2.6.7" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" From eb37dacc733642a4b59bdfaafde5abfeeb01ef94 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 8 May 2023 16:23:49 +0100 Subject: [PATCH 05/31] lint --- packages/server/src/api/routes/public/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/public/index.ts b/packages/server/src/api/routes/public/index.ts index 287f6c11de..6852778e68 100644 --- a/packages/server/src/api/routes/public/index.ts +++ b/packages/server/src/api/routes/public/index.ts @@ -46,7 +46,8 @@ if (!env.isTest()) { if (REDIS_OPTS.opts?.password || REDIS_OPTS.opts.redisOptions?.password) { // @ts-ignore - options.password = REDIS_OPTS.opts.password || REDIS_OPTS.opts.redisOptions.password + options.password = + REDIS_OPTS.opts.password || REDIS_OPTS.opts.redisOptions.password } if (!env.REDIS_CLUSTERED) { From 86f0cd8353aefc899f8acdf5f961cd9f6c8315b7 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 8 May 2023 15:52:34 +0000 Subject: [PATCH 06/31] v2.6.8 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 6 +++--- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 12 ++++++------ packages/frontend-core/package.json | 6 +++--- packages/sdk/package.json | 2 +- packages/server/package.json | 12 ++++++------ packages/shared-core/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lerna.json b/lerna.json index 85c77624b8..202e1c6f49 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.6.7", + "version": "2.6.8", "npmClient": "yarn", "useWorkspaces": true, "packages": ["packages/*"], diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 4e186dd705..03dae9feca 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -24,7 +24,7 @@ "dependencies": { "@budibase/nano": "10.1.2", "@budibase/pouchdb-replication-stream": "1.2.10", - "@budibase/types": "^2.6.7", + "@budibase/types": "^2.6.8", "@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 23a145e7c5..f0fe559705 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.6.7", + "version": "2.6.8", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,8 +38,8 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "1.2.1", - "@budibase/shared-core": "^2.6.7", - "@budibase/string-templates": "^2.6.7", + "@budibase/shared-core": "^2.6.8", + "@budibase/string-templates": "^2.6.8", "@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 b32d660471..1b69c7aaac 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "2.6.7", + "version": "2.6.8", "license": "GPL-3.0", "private": true, "scripts": { @@ -58,10 +58,10 @@ } }, "dependencies": { - "@budibase/bbui": "^2.6.7", - "@budibase/frontend-core": "^2.6.7", - "@budibase/shared-core": "^2.6.7", - "@budibase/string-templates": "^2.6.7", + "@budibase/bbui": "^2.6.8", + "@budibase/frontend-core": "^2.6.8", + "@budibase/shared-core": "^2.6.8", + "@budibase/string-templates": "^2.6.8", "@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/free-brands-svg-icons": "^6.2.1", "@fortawesome/free-solid-svg-icons": "^6.2.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index c80530f716..a28c66fe65 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "dist/index.js", "bin": { @@ -29,9 +29,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "^2.6.7", - "@budibase/string-templates": "^2.6.7", - "@budibase/types": "^2.6.7", + "@budibase/backend-core": "^2.6.8", + "@budibase/string-templates": "^2.6.8", + "@budibase/types": "^2.6.8", "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 c4d3c1b13b..46f365de5d 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "2.6.7", + "version": "2.6.8", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,11 +19,11 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^2.6.7", - "@budibase/frontend-core": "^2.6.7", - "@budibase/shared-core": "^2.6.7", - "@budibase/string-templates": "^2.6.7", - "@budibase/types": "^2.6.7", + "@budibase/bbui": "^2.6.8", + "@budibase/frontend-core": "^2.6.8", + "@budibase/shared-core": "^2.6.8", + "@budibase/string-templates": "^2.6.8", + "@budibase/types": "^2.6.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 6d917cb863..e701687d10 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,13 +1,13 @@ { "name": "@budibase/frontend-core", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^2.6.7", - "@budibase/shared-core": "^2.6.7", + "@budibase/bbui": "^2.6.8", + "@budibase/shared-core": "^2.6.8", "dayjs": "^1.11.7", "lodash": "^4.17.21", "socket.io-client": "^4.6.1", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 3df72d79fb..5b528a145a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/sdk", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase Public API SDK", "author": "Budibase", "license": "MPL-2.0", diff --git a/packages/server/package.json b/packages/server/package.json index a8c04bf14e..4e47134947 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -45,12 +45,12 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^2.6.7", - "@budibase/client": "^2.6.7", + "@budibase/backend-core": "^2.6.8", + "@budibase/client": "^2.6.8", "@budibase/pro": "2.6.7", - "@budibase/shared-core": "^2.6.7", - "@budibase/string-templates": "^2.6.7", - "@budibase/types": "^2.6.7", + "@budibase/shared-core": "^2.6.8", + "@budibase/string-templates": "^2.6.8", + "@budibase/types": "^2.6.8", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index e1e4a01f52..68d9824126 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/shared-core", - "version": "2.6.7", + "version": "2.6.8", "description": "Shared data utils", "main": "dist/cjs/src/index.js", "types": "dist/mjs/src/index.d.ts", @@ -20,7 +20,7 @@ "dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\"" }, "dependencies": { - "@budibase/types": "^2.6.7" + "@budibase/types": "^2.6.8" }, "devDependencies": { "concurrently": "^7.6.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index a02d13b3b6..105cb98472 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "2.6.7", + "version": "2.6.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 a39114a76d..1e8e46c44d 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase types", "main": "dist/cjs/index.js", "types": "dist/mjs/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 59e7f18d76..6e44e82649 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "2.6.7", + "version": "2.6.8", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -37,10 +37,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^2.6.7", + "@budibase/backend-core": "^2.6.8", "@budibase/pro": "2.6.7", - "@budibase/string-templates": "^2.6.7", - "@budibase/types": "^2.6.7", + "@budibase/string-templates": "^2.6.8", + "@budibase/types": "^2.6.8", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From bd13a2d186819e4159b076c92e23b9852a5e49db Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 8 May 2023 15:54:09 +0000 Subject: [PATCH 07/31] Update pro version to 2.6.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 4e47134947..7be437535e 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -47,7 +47,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "^2.6.8", "@budibase/client": "^2.6.8", - "@budibase/pro": "2.6.7", + "@budibase/pro": "2.6.8", "@budibase/shared-core": "^2.6.8", "@budibase/string-templates": "^2.6.8", "@budibase/types": "^2.6.8", diff --git a/packages/worker/package.json b/packages/worker/package.json index 6e44e82649..ebbe5d62bd 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -38,7 +38,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "^2.6.8", - "@budibase/pro": "2.6.7", + "@budibase/pro": "2.6.8", "@budibase/string-templates": "^2.6.8", "@budibase/types": "^2.6.8", "@koa/router": "8.0.8", From bbf271961f95cf1d7997eb9d13bb84a8a4d00b23 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 9 May 2023 11:48:49 +0100 Subject: [PATCH 08/31] adding healthcheck to proxy service --- hosting/proxy/nginx.prod.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hosting/proxy/nginx.prod.conf b/hosting/proxy/nginx.prod.conf index dce1a71918..1a4415395b 100644 --- a/hosting/proxy/nginx.prod.conf +++ b/hosting/proxy/nginx.prod.conf @@ -82,6 +82,12 @@ http { set $couchdb ${COUCHDB_UPSTREAM_URL}; set $watchtower ${WATCHTOWER_UPSTREAM_URL}; + location /health { + access_log off; + add_header 'Content-Type' 'application/json'; + return 200 '{ "status": "OK" }'; + } + location /app { proxy_pass $apps; } From 1e6652dc396a341fa836e18b7c3cea4ccd672cee Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 10 May 2023 12:36:01 +0100 Subject: [PATCH 09/31] Fix for importing exported array/option fields. Fix to ensure lastid and inclusion updates persisted as a result of an import. Test updates for array and option fields --- .../server/src/api/controllers/table/index.ts | 2 - .../src/api/controllers/table/internal.ts | 5 ++ .../server/src/api/controllers/table/utils.ts | 2 - .../server/src/api/routes/tests/misc.spec.js | 89 +++++++++++++++++-- .../server/src/api/routes/tests/row.spec.js | 67 ++++++++++++-- .../src/utilities/rowProcessor/index.ts | 5 +- .../server/src/utilities/rowProcessor/map.ts | 34 +++---- 7 files changed, 167 insertions(+), 37 deletions(-) diff --git a/packages/server/src/api/controllers/table/index.ts b/packages/server/src/api/controllers/table/index.ts index 8e248d57ea..cbbda7b930 100644 --- a/packages/server/src/api/controllers/table/index.ts +++ b/packages/server/src/api/controllers/table/index.ts @@ -98,8 +98,6 @@ export async function bulkImport(ctx: UserCtx) { // can only be done in the builder, but in the future we may need to // think about events for bulk items - //const resp = pickApi({ tableId }).save(ctx) - ctx.status = 200 ctx.body = { message: `Bulk rows created.` } } diff --git a/packages/server/src/api/controllers/table/internal.ts b/packages/server/src/api/controllers/table/internal.ts index 628932bba1..d2a4de575e 100644 --- a/packages/server/src/api/controllers/table/internal.ts +++ b/packages/server/src/api/controllers/table/internal.ts @@ -184,8 +184,13 @@ export async function destroy(ctx: any) { } export async function bulkImport(ctx: any) { + const db = context.getAppDB() const table = await sdk.tables.getTable(ctx.params.tableId) const { rows } = ctx.request.body await handleDataImport(ctx.user, table, rows) + + // Ensure auto id and other table updates are persisted + await db.put(table) + return table } diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index 5681095df7..f088dbaa8e 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -138,10 +138,8 @@ export function importToRows( row[fieldName] ) { let merged = [...schema.constraints!.inclusion!, ...rowVal] - let superSet = new Set(merged) schema.constraints!.inclusion = Array.from(superSet) - schema.constraints!.inclusion.sort() } } diff --git a/packages/server/src/api/routes/tests/misc.spec.js b/packages/server/src/api/routes/tests/misc.spec.js index 6dd82df496..21ebea637f 100644 --- a/packages/server/src/api/routes/tests/misc.spec.js +++ b/packages/server/src/api/routes/tests/misc.spec.js @@ -73,18 +73,97 @@ describe("run misc tests", () => { type: "string", }, }, + e: { + name: "Auto ID", + type: "number", + subtype: "autoID", + icon: "ri-magic-line", + autocolumn: true, + constraints: { + type: "number", + presence: false, + numericality: { + greaterThanOrEqualTo: "", + lessThanOrEqualTo: "", + }, + }, + }, + f: { + type: "array", + constraints: { + type: "array", + presence: { + "allowEmpty": true + }, + inclusion: [ + "One", + "Two", + "Three", + ] + }, + name: "Sample Tags", + sortable: false + }, + g: { + type: "options", + constraints: { + type: "string", + presence: false, + inclusion: [ + "Alpha", + "Beta", + "Gamma" + ] + }, + name: "Sample Opts" + } }, }) - + + // Shift specific row tests to the row spec await tableUtils.handleDataImport( { userId: "test" }, table, - [{ a: '1', b: '2', c: '3', d: '4'}] + [ + { a: '1', b: '2', c: '3', d: '4', f: "['One']", g: "Alpha" }, + { a: '5', b: '6', c: '7', d: '8', f: "[]", g: undefined}, + { a: '9', b: '10', c: '11', d: '12', f: "['Two','Four']", g: ""}, + { a: '13', b: '14', c: '15', d: '16', g: "Omega"} + ] ) + + // 4 rows imported, the auto ID starts at 1 + // We expect the handleDataImport function to update the lastID + expect(table.schema.e.lastID).toEqual(4); + + // Array/Multi - should have added a new value to the inclusion. + expect(table.schema.f.constraints.inclusion).toEqual(['Four','One','Three','Two']); + + // Options - should have a new value in the inclusion + expect(table.schema.g.constraints.inclusion).toEqual(['Alpha','Beta','Gamma','Omega']); + const rows = await config.getRows() - expect(rows[0].a).toEqual("1") - expect(rows[0].b).toEqual("2") - expect(rows[0].c).toEqual("3") + expect(rows.length).toEqual(4); + + const rowOne = rows.find(row => row.e === 1) + expect(rowOne.a).toEqual("1") + expect(rowOne.f).toEqual(['One']) + expect(rowOne.g).toEqual('Alpha') + + const rowTwo = rows.find(row => row.e === 2) + expect(rowTwo.a).toEqual("5") + expect(rowTwo.f).toEqual([]) + expect(rowTwo.g).toEqual(undefined) + + const rowThree = rows.find(row => row.e === 3) + expect(rowThree.a).toEqual("9") + expect(rowThree.f).toEqual(['Two','Four']) + expect(rowThree.g).toEqual(null) + + const rowFour = rows.find(row => row.e === 4) + expect(rowFour.a).toEqual("13") + expect(rowFour.f).toEqual(undefined) + expect(rowFour.g).toEqual('Omega') }) }) }) diff --git a/packages/server/src/api/routes/tests/row.spec.js b/packages/server/src/api/routes/tests/row.spec.js index 4b835a1fb5..105dd21ae0 100644 --- a/packages/server/src/api/routes/tests/row.spec.js +++ b/packages/server/src/api/routes/tests/row.spec.js @@ -34,9 +34,9 @@ describe("/rows", () => { row = basicRow(table._id) }) - const loadRow = async (id, status = 200) => + const loadRow = async (id, tbl_Id, status = 200) => await request - .get(`/api/${table._id}/rows/${id}`) + .get(`/api/${tbl_Id}/rows/${id}`) .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(status) @@ -182,8 +182,32 @@ describe("/rows", () => { type: "string", presence: false, datetime: { earliest: "", latest: "" }, - }, + } } + const arrayField = { + type: "array", + constraints: { + type: "array", + presence: false, + inclusion: [ + "One", + "Two", + "Three", + ] + }, + name: "Sample Tags", + sortable: false + } + const optsField = { + fieldName: "Sample Opts", + name: "Sample Opts", + type: "options", + constraints: { + type: "string", + presence: false, + inclusion: [ "Alpha", "Beta", "Gamma" ] + }, + }, table = await config.createTable({ name: "TestTable2", @@ -212,7 +236,15 @@ describe("/rows", () => { attachmentNull: attachment, attachmentUndefined: attachment, attachmentEmpty: attachment, - attachmentEmptyArrayStr: attachment + attachmentEmptyArrayStr: attachment, + arrayFieldEmptyArrayStr: arrayField, + arrayFieldArrayStrKnown: arrayField, + arrayFieldNull: arrayField, + arrayFieldUndefined: arrayField, + optsFieldEmptyStr: optsField, + optsFieldUndefined: optsField, + optsFieldNull: optsField, + optsFieldStrKnown: optsField }, }) @@ -241,11 +273,20 @@ describe("/rows", () => { attachmentUndefined: undefined, attachmentEmpty: "", attachmentEmptyArrayStr: "[]", + arrayFieldEmptyArrayStr: "[]", + arrayFieldUndefined: undefined, + arrayFieldNull: null, + arrayFieldArrayStrKnown: "['One']", + optsFieldEmptyStr: "", + optsFieldUndefined: undefined, + optsFieldNull: null, + optsFieldStrKnown: 'Alpha' } - const id = (await config.createRow(row))._id + const createdRow = await config.createRow(row); + const id = createdRow._id - const saved = (await loadRow(id)).body + const saved = (await loadRow(id, table._id)).body expect(saved.stringUndefined).toBe(undefined) expect(saved.stringNull).toBe("") @@ -270,7 +311,15 @@ describe("/rows", () => { expect(saved.attachmentNull).toEqual([]) expect(saved.attachmentUndefined).toBe(undefined) expect(saved.attachmentEmpty).toEqual([]) - expect(saved.attachmentEmptyArrayStr).toEqual([]) + expect(saved.attachmentEmptyArrayStr).toEqual([]) + expect(saved.arrayFieldEmptyArrayStr).toEqual([]) + expect(saved.arrayFieldNull).toEqual([]) + expect(saved.arrayFieldUndefined).toEqual(undefined) + expect(saved.optsFieldEmptyStr).toEqual(null) + expect(saved.optsFieldUndefined).toEqual(undefined) + expect(saved.optsFieldNull).toEqual(null) + expect(saved.arrayFieldArrayStrKnown).toEqual(['One']) + expect(saved.optsFieldStrKnown).toEqual('Alpha') }) }) @@ -299,7 +348,7 @@ describe("/rows", () => { expect(res.body.name).toEqual("Updated Name") expect(res.body.description).toEqual(existing.description) - const savedRow = await loadRow(res.body._id) + const savedRow = await loadRow(res.body._id, table._id) expect(savedRow.body.description).toEqual(existing.description) expect(savedRow.body.name).toEqual("Updated Name") @@ -401,7 +450,7 @@ describe("/rows", () => { .expect(200) expect(res.body.length).toEqual(2) - await loadRow(row1._id, 404) + await loadRow(row1._id, table._id, 404) await assertRowUsage(rowUsage - 2) await assertQueryUsage(queryUsage + 1) }) diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index a5bb352eeb..44cab4d18b 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -137,8 +137,7 @@ export function inputProcessing( opts?: AutoColumnProcessingOpts ) { let clonedRow = cloneDeep(row) - // need to copy the table so it can be differenced on way out - const copiedTable = cloneDeep(table) + const dontCleanseKeys = ["type", "_id", "_rev", "tableId"] for (let [key, value] of Object.entries(clonedRow)) { const field = table.schema[key] @@ -175,7 +174,7 @@ export function inputProcessing( } // handle auto columns - this returns an object like {table, row} - return processAutoColumn(user, copiedTable, clonedRow, opts) + return processAutoColumn(user, table, clonedRow, opts) } /** diff --git a/packages/server/src/utilities/rowProcessor/map.ts b/packages/server/src/utilities/rowProcessor/map.ts index 808b16178d..cf6823856c 100644 --- a/packages/server/src/utilities/rowProcessor/map.ts +++ b/packages/server/src/utilities/rowProcessor/map.ts @@ -2,6 +2,22 @@ import { FieldTypes } from "../../constants" import { logging } from "@budibase/backend-core" +const parseArrayString = value => { + if (typeof value === "string") { + if (value === "") { + return [] + } + let result + try { + result = JSON.parse(value.replace(/'/g, '"')) + return result + } catch (e) { + logging.logAlert("Could not parse row value", e) + } + } + return value +} + /** * A map of how we convert various properties in rows to each other based on the row type. */ @@ -26,9 +42,9 @@ export const TYPE_TRANSFORM_MAP: any = { [undefined]: undefined, }, [FieldTypes.ARRAY]: { - "": [], [null]: [], [undefined]: undefined, + parse: parseArrayString, }, [FieldTypes.STRING]: { "": "", @@ -70,21 +86,7 @@ export const TYPE_TRANSFORM_MAP: any = { [FieldTypes.ATTACHMENT]: { [null]: [], [undefined]: undefined, - parse: attachments => { - if (typeof attachments === "string") { - if (attachments === "") { - return [] - } - let result - try { - result = JSON.parse(attachments) - } catch (e) { - logging.logAlert("Could not parse attachments", e) - } - return result - } - return attachments - }, + parse: parseArrayString, }, [FieldTypes.BOOLEAN]: { "": null, From 77d1f9250c64164f898915ad33d1584e0c5813c1 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 10 May 2023 12:52:54 +0100 Subject: [PATCH 10/31] Updated import row test to evaluate the name and _id fields on the table instead of the entire object. --- packages/server/src/api/routes/tests/table.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/table.spec.js b/packages/server/src/api/routes/tests/table.spec.js index d28f2232ee..9c6980c1d7 100644 --- a/packages/server/src/api/routes/tests/table.spec.js +++ b/packages/server/src/api/routes/tests/table.spec.js @@ -167,7 +167,10 @@ describe("/tables", () => { expect(events.table.created).not.toHaveBeenCalled() expect(events.rows.imported).toBeCalledTimes(1) - expect(events.rows.imported).toBeCalledWith(table, 1) + expect(events.rows.imported).toBeCalledWith(expect.objectContaining({ + name: "TestTable", + _id: table._id + }), 1) }) }) From 530c8ce8d77159e1663590362964cd66f199033e Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Wed, 10 May 2023 13:43:51 +0000 Subject: [PATCH 11/31] v2.6.9 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 6 +++--- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 12 ++++++------ packages/frontend-core/package.json | 6 +++--- packages/sdk/package.json | 2 +- packages/server/package.json | 12 ++++++------ packages/shared-core/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lerna.json b/lerna.json index 202e1c6f49..bb1246fb5e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.6.8", + "version": "2.6.9", "npmClient": "yarn", "useWorkspaces": true, "packages": ["packages/*"], diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 03dae9feca..2ed8f8914c 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -24,7 +24,7 @@ "dependencies": { "@budibase/nano": "10.1.2", "@budibase/pouchdb-replication-stream": "1.2.10", - "@budibase/types": "^2.6.8", + "@budibase/types": "^2.6.9", "@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 f0fe559705..96e7bc9dc8 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.6.8", + "version": "2.6.9", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,8 +38,8 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "1.2.1", - "@budibase/shared-core": "^2.6.8", - "@budibase/string-templates": "^2.6.8", + "@budibase/shared-core": "^2.6.9", + "@budibase/string-templates": "^2.6.9", "@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 1b69c7aaac..7ac642f560 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "2.6.8", + "version": "2.6.9", "license": "GPL-3.0", "private": true, "scripts": { @@ -58,10 +58,10 @@ } }, "dependencies": { - "@budibase/bbui": "^2.6.8", - "@budibase/frontend-core": "^2.6.8", - "@budibase/shared-core": "^2.6.8", - "@budibase/string-templates": "^2.6.8", + "@budibase/bbui": "^2.6.9", + "@budibase/frontend-core": "^2.6.9", + "@budibase/shared-core": "^2.6.9", + "@budibase/string-templates": "^2.6.9", "@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/free-brands-svg-icons": "^6.2.1", "@fortawesome/free-solid-svg-icons": "^6.2.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index a28c66fe65..4a964821de 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "dist/index.js", "bin": { @@ -29,9 +29,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "^2.6.8", - "@budibase/string-templates": "^2.6.8", - "@budibase/types": "^2.6.8", + "@budibase/backend-core": "^2.6.9", + "@budibase/string-templates": "^2.6.9", + "@budibase/types": "^2.6.9", "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 46f365de5d..9bc4194095 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "2.6.8", + "version": "2.6.9", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,11 +19,11 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^2.6.8", - "@budibase/frontend-core": "^2.6.8", - "@budibase/shared-core": "^2.6.8", - "@budibase/string-templates": "^2.6.8", - "@budibase/types": "^2.6.8", + "@budibase/bbui": "^2.6.9", + "@budibase/frontend-core": "^2.6.9", + "@budibase/shared-core": "^2.6.9", + "@budibase/string-templates": "^2.6.9", + "@budibase/types": "^2.6.9", "@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 e701687d10..c322f0a84d 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,13 +1,13 @@ { "name": "@budibase/frontend-core", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^2.6.8", - "@budibase/shared-core": "^2.6.8", + "@budibase/bbui": "^2.6.9", + "@budibase/shared-core": "^2.6.9", "dayjs": "^1.11.7", "lodash": "^4.17.21", "socket.io-client": "^4.6.1", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5b528a145a..3e96f57328 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/sdk", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase Public API SDK", "author": "Budibase", "license": "MPL-2.0", diff --git a/packages/server/package.json b/packages/server/package.json index 7be437535e..352feb6ac8 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -45,12 +45,12 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^2.6.8", - "@budibase/client": "^2.6.8", + "@budibase/backend-core": "^2.6.9", + "@budibase/client": "^2.6.9", "@budibase/pro": "2.6.8", - "@budibase/shared-core": "^2.6.8", - "@budibase/string-templates": "^2.6.8", - "@budibase/types": "^2.6.8", + "@budibase/shared-core": "^2.6.9", + "@budibase/string-templates": "^2.6.9", + "@budibase/types": "^2.6.9", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 68d9824126..f659aaea9d 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/shared-core", - "version": "2.6.8", + "version": "2.6.9", "description": "Shared data utils", "main": "dist/cjs/src/index.js", "types": "dist/mjs/src/index.d.ts", @@ -20,7 +20,7 @@ "dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\"" }, "dependencies": { - "@budibase/types": "^2.6.8" + "@budibase/types": "^2.6.9" }, "devDependencies": { "concurrently": "^7.6.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 105cb98472..c97b5f8fe3 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "2.6.8", + "version": "2.6.9", "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 1e8e46c44d..034f6562c7 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase types", "main": "dist/cjs/index.js", "types": "dist/mjs/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index ebbe5d62bd..1a12ceb889 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "2.6.8", + "version": "2.6.9", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -37,10 +37,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^2.6.8", + "@budibase/backend-core": "^2.6.9", "@budibase/pro": "2.6.8", - "@budibase/string-templates": "^2.6.8", - "@budibase/types": "^2.6.8", + "@budibase/string-templates": "^2.6.9", + "@budibase/types": "^2.6.9", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 70705a8519d490b1b613dd2a36fc2e824b29055c Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Wed, 10 May 2023 13:45:43 +0000 Subject: [PATCH 12/31] Update pro version to 2.6.9 --- packages/server/package.json | 2 +- packages/worker/package.json | 2 +- yarn.lock | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 352feb6ac8..ca8d00311b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -47,7 +47,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "^2.6.9", "@budibase/client": "^2.6.9", - "@budibase/pro": "2.6.8", + "@budibase/pro": "2.6.9", "@budibase/shared-core": "^2.6.9", "@budibase/string-templates": "^2.6.9", "@budibase/types": "^2.6.9", diff --git a/packages/worker/package.json b/packages/worker/package.json index 1a12ceb889..86804e5326 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -38,7 +38,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "^2.6.9", - "@budibase/pro": "2.6.8", + "@budibase/pro": "2.6.9", "@budibase/string-templates": "^2.6.9", "@budibase/types": "^2.6.9", "@koa/router": "8.0.8", diff --git a/yarn.lock b/yarn.lock index 4b2bab4ec2..3792431ed0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,15 +1486,15 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" -"@budibase/pro@2.6.7": - version "2.6.7" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.6.7.tgz#884b33f3a3e3f2e548fd7519d32b40dc98803400" - integrity sha512-f7g+0So7hr7tHHEF28cz550imYpq/CqRNzhMQpUwmzgbdTlOdVej3PWPNK9+MuBlNea3J9b2WQsjS9TkGZfTlA== +"@budibase/pro@2.6.8": + version "2.6.8" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.6.8.tgz#739938cdee6afa138383708401d20eadd3a15555" + integrity sha512-nYpD+B9wGLonzOzeOs1Ym9PLgPsQrzui56TmkPPBJpFOAfCo8GLb8fwqDHGuZiEo5e+M96BgcJTAfpOzFQ7wgw== dependencies: - "@budibase/backend-core" "2.6.7" + "@budibase/backend-core" "2.6.8" "@budibase/shared-core" "2.5.9" "@budibase/string-templates" "2.5.9" - "@budibase/types" "2.6.7" + "@budibase/types" "2.6.8" "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" From f7fbce344461145d795302343320dd670d281b0c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 11 May 2023 17:11:13 +0100 Subject: [PATCH 13/31] Fix multiple issues with first app onboarding --- .../portal/apps/onboarding/index.svelte | 147 ++++++++++-------- 1 file changed, 83 insertions(+), 64 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/apps/onboarding/index.svelte b/packages/builder/src/pages/builder/portal/apps/onboarding/index.svelte index 8e018ae907..546f5f57ba 100644 --- a/packages/builder/src/pages/builder/portal/apps/onboarding/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/onboarding/index.svelte @@ -107,8 +107,9 @@ useSampleData, isGoogle, }) => { + let app try { - const app = await createApp(useSampleData) + app = await createApp(useSampleData) let datasource if (datasourceConfig) { @@ -134,6 +135,17 @@ console.log(e) creationLoading = false notifications.error("There was a problem creating your app") + + // Reset the store so that we don't send up stale headers + store.actions.reset() + + // If we successfully created an app, delete it again so that we + // can try again once the error has been corrected. + // This also ensures onboarding can't be skipped by entering invalid + // data credentials. + if (app?.appId) { + await API.deleteApp(app.appId) + } } } @@ -146,80 +158,87 @@ /> - - {#if stage === "name"} - (stage = "data")} /> - {:else if googleComplete} -
- Please login to your Google account in the new tab which as opened to - continue. -
- {:else if integrationsLoading || creationLoading} -
- -
- {:else if stage === "data"} - (stage = "name")}> -
- handleCreateApp({ useSampleData: true })}> -
-
- -
- Budibase Sample data -
-
+
+ + {#if stage === "name"} + (stage = "data")} /> + {:else if googleComplete} +
+ Please login to your Google account in the new tab which as opened to + continue.
-
- -
-
- -
- Upload data (CSV or JSON) -
-
+ {:else if integrationsLoading || creationLoading} +
+
- {#each Object.entries(plusIntegrations) as [integrationType, schema]} + {:else if stage === "data"} + (stage = "name")}>
- (stage = integrationType)}> + handleCreateApp({ useSampleData: true })} + >
- +
- {schema.friendlyName} + Budibase Sample data
- {/each} -
- {:else if stage in plusIntegrations} - (stage = "data")} - onNext={data => { - const isGoogle = data.isGoogle - delete data.isGoogle - return handleCreateApp({ datasourceConfig: data, isGoogle }) - }} - /> - {:else} -

There was an problem. Please refresh the page and try again.

- {/if} -
- -
- +
+ +
+
+ +
+ Upload data (CSV or JSON) +
+
+
+ {#each Object.entries(plusIntegrations) as [integrationType, schema]} +
+ (stage = integrationType)}> +
+
+ +
+ {schema.friendlyName} +
+
+
+ {/each} + + {:else if stage in plusIntegrations} + (stage = "data")} + onNext={data => { + const isGoogle = data.isGoogle + delete data.isGoogle + return handleCreateApp({ datasourceConfig: data, isGoogle }) + }} + /> + {:else} +

There was an problem. Please refresh the page and try again.

+ {/if} +
+ +
+ +