From 769c37a11d6f53ed2026ee60c5c2a5cac369901a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 16 Aug 2021 15:58:04 +0100 Subject: [PATCH 01/58] couchdb direct auth --- packages/auth/src/db/utils.js | 8 +++++++- packages/server/scripts/dev/manage.js | 2 +- packages/server/src/db/client.js | 4 ++++ packages/server/src/environment.js | 2 ++ packages/worker/scripts/dev/manage.js | 2 +- packages/worker/src/db/index.js | 4 ++++ packages/worker/src/environment.js | 3 +-- 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 1fc78f4182..e3a86f8ae8 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -168,7 +168,13 @@ exports.getAllDbs = async () => { if (env.isTest()) { return getCouch().allDbs() } - const response = await fetch(`${env.COUCH_DB_URL}/_all_dbs`) + const response = await fetch(`${env.COUCH_DB_URL}/_all_dbs`, { + method: "POST", + body: JSON.stringify({ + name: env.COUCH_DB_USERNAME, + password: env.COUCH_DB_PASSWORD, + }), + }) if (response.status === 200) { return response.json() } else { diff --git a/packages/server/scripts/dev/manage.js b/packages/server/scripts/dev/manage.js index ffd8c6b9e3..7e9d7f6a07 100644 --- a/packages/server/scripts/dev/manage.js +++ b/packages/server/scripts/dev/manage.js @@ -36,7 +36,7 @@ async function init() { const envFileJson = { PORT: 4001, MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", + COUCH_DB_URL: "http://localhost:10000/db/", REDIS_URL: "localhost:6379", WORKER_URL: "http://localhost:4002", INTERNAL_API_KEY: "budibase", diff --git a/packages/server/src/db/client.js b/packages/server/src/db/client.js index d50d72b18d..887b287c84 100644 --- a/packages/server/src/db/client.js +++ b/packages/server/src/db/client.js @@ -12,6 +12,10 @@ PouchDB.adapter("writableStream", replicationStream.adapters.writableStream) let POUCH_DB_DEFAULTS = { prefix: COUCH_DB_URL, + auth: { + username: env.COUCH_DB_USERNAME, + password: env.COUCH_DB_PASSWORD, + } } if (env.isTest()) { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 52c680f65a..45c7673851 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -23,6 +23,8 @@ module.exports = { // important PORT: process.env.PORT, JWT_SECRET: process.env.JWT_SECRET, + COUCH_DB_USERNAME: process.env.COUCH_DB_USER, + COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, COUCH_DB_URL: process.env.COUCH_DB_URL, MINIO_URL: process.env.MINIO_URL, WORKER_URL: process.env.WORKER_URL, diff --git a/packages/worker/scripts/dev/manage.js b/packages/worker/scripts/dev/manage.js index b9d28b6278..d7eb76fc74 100644 --- a/packages/worker/scripts/dev/manage.js +++ b/packages/worker/scripts/dev/manage.js @@ -17,7 +17,7 @@ async function init() { REDIS_URL: "localhost:6379", REDIS_PASSWORD: "budibase", MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", + COUCH_DB_URL: "http://localhost:10000/db/", } let envFile = "" Object.keys(envFileJson).forEach(key => { diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index d6d035cff1..d09ddf0652 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -7,6 +7,10 @@ const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/" let POUCH_DB_DEFAULTS = { prefix: COUCH_DB_URL, + auth: { + username: env.COUCH_DB_USERNAME, + password: env.COUCH_DB_PASSWORD, + } } if (env.isTest()) { diff --git a/packages/worker/src/environment.js b/packages/worker/src/environment.js index 384230b9b3..e8666e6b87 100644 --- a/packages/worker/src/environment.js +++ b/packages/worker/src/environment.js @@ -23,7 +23,6 @@ module.exports = { MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY, MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY, MINIO_URL: process.env.MINIO_URL, - COUCH_DB_URL: process.env.COUCH_DB_URL, LOG_LEVEL: process.env.LOG_LEVEL, JWT_SECRET: process.env.JWT_SECRET, SALT_ROUNDS: process.env.SALT_ROUNDS, @@ -31,7 +30,7 @@ module.exports = { REDIS_PASSWORD: process.env.REDIS_PASSWORD, INTERNAL_API_KEY: process.env.INTERNAL_API_KEY, /* TODO: to remove - once deployment removed */ - COUCH_DB_USERNAME: process.env.COUCH_DB_USERNAME, + COUCH_DB_USERNAME: process.env.COUCH_DB_USER, COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, _set(key, value) { process.env[key] = value From beb16a733e70ceb5394fb2a7759d3d4acb39dce5 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 16 Aug 2021 16:38:00 +0100 Subject: [PATCH 02/58] utility helper for determining correct couchDB URL --- packages/auth/src/db/utils.js | 21 ++++++++++++------- packages/auth/src/environment.js | 2 ++ .../src/api/controllers/row/internalSearch.js | 3 ++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index e3a86f8ae8..7c44664a68 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -159,6 +159,17 @@ exports.getDeployedAppID = appId => { return appId } +exports.getCouchUrl = () => { + // username and password already exist in URL + if (env.COUCH_DB_URL.includes("@")) { + return env.COUCH_DB_URL + } + + const [protocol, ...rest] = env.COUCH_DB_URL.split("://") + + return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}` +} + /** * if in production this will use the CouchDB _all_dbs call to retrieve a list of databases. If testing * when using Pouch it will use the pouchdb-all-dbs package. @@ -168,13 +179,7 @@ exports.getAllDbs = async () => { if (env.isTest()) { return getCouch().allDbs() } - const response = await fetch(`${env.COUCH_DB_URL}/_all_dbs`, { - method: "POST", - body: JSON.stringify({ - name: env.COUCH_DB_USERNAME, - password: env.COUCH_DB_PASSWORD, - }), - }) + const response = await fetch(`${exports.getCouchUrl()}/_all_dbs`) if (response.status === 200) { return response.json() } else { @@ -309,4 +314,4 @@ exports.Replication = Replication exports.getScopedConfig = getScopedConfig exports.generateConfigID = generateConfigID exports.getConfigParams = getConfigParams -exports.getScopedFullConfig = getScopedFullConfig +exports.getScopedFullConfig = getScopedFullConfig \ No newline at end of file diff --git a/packages/auth/src/environment.js b/packages/auth/src/environment.js index 355843d02d..e64a1c75f0 100644 --- a/packages/auth/src/environment.js +++ b/packages/auth/src/environment.js @@ -9,6 +9,8 @@ function isTest() { module.exports = { JWT_SECRET: process.env.JWT_SECRET, COUCH_DB_URL: process.env.COUCH_DB_URL, + COUCH_DB_USERNAME: process.env.COUCH_DB_USER, + COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, SALT_ROUNDS: process.env.SALT_ROUNDS, REDIS_URL: process.env.REDIS_URL, REDIS_PASSWORD: process.env.REDIS_PASSWORD, diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index c13091d6e8..20147a7857 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -1,6 +1,7 @@ const { SearchIndexes } = require("../../../db/utils") const env = require("../../../environment") const fetch = require("node-fetch") +const { getCouchUrl } = require("@budibase/auth/db") /** * Class to build lucene query URLs. @@ -233,7 +234,7 @@ class QueryBuilder { } async run() { - const url = `${env.COUCH_DB_URL}/${this.appId}/_design/database/_search/${SearchIndexes.ROWS}` + const url = `${getCouchUrl()}/${this.appId}/_design/database/_search/${SearchIndexes.ROWS}` const body = this.buildSearchBody() return await runQuery(url, body) } From a06325cace97b2889f2bc2bc869ade8ff69a39f4 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 16 Aug 2021 16:39:10 +0100 Subject: [PATCH 03/58] readd couchDB url to env --- packages/worker/src/environment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/worker/src/environment.js b/packages/worker/src/environment.js index e8666e6b87..1fc68ccc71 100644 --- a/packages/worker/src/environment.js +++ b/packages/worker/src/environment.js @@ -23,6 +23,7 @@ module.exports = { MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY, MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY, MINIO_URL: process.env.MINIO_URL, + COUCH_DB_URL: process.env.COUCH_DB_URL, LOG_LEVEL: process.env.LOG_LEVEL, JWT_SECRET: process.env.JWT_SECRET, SALT_ROUNDS: process.env.SALT_ROUNDS, From cedc78e4902d7624fa7ae210288cbfd5dfb56f85 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 16 Aug 2021 16:44:46 +0100 Subject: [PATCH 04/58] match up env var in worker --- packages/worker/src/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker/src/environment.js b/packages/worker/src/environment.js index 1fc68ccc71..384230b9b3 100644 --- a/packages/worker/src/environment.js +++ b/packages/worker/src/environment.js @@ -31,7 +31,7 @@ module.exports = { REDIS_PASSWORD: process.env.REDIS_PASSWORD, INTERNAL_API_KEY: process.env.INTERNAL_API_KEY, /* TODO: to remove - once deployment removed */ - COUCH_DB_USERNAME: process.env.COUCH_DB_USER, + COUCH_DB_USERNAME: process.env.COUCH_DB_USERNAME, COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, _set(key, value) { process.env[key] = value From 0bfbedac80288de6ec820e596a7c870fdfcdfd23 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 16 Aug 2021 16:47:26 +0100 Subject: [PATCH 05/58] lint --- packages/server/src/api/controllers/row/internalSearch.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index 20147a7857..c5bd01b383 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -1,5 +1,4 @@ const { SearchIndexes } = require("../../../db/utils") -const env = require("../../../environment") const fetch = require("node-fetch") const { getCouchUrl } = require("@budibase/auth/db") From 2661d1c0b4edb5020299353b451070064fbe58e1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 16 Aug 2021 17:17:48 +0100 Subject: [PATCH 06/58] lint :sparkles: --- packages/auth/src/db/utils.js | 2 +- packages/server/src/api/controllers/row/internalSearch.js | 4 +++- packages/server/src/db/client.js | 2 +- packages/worker/src/db/index.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 7c44664a68..2ac23d02a5 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -314,4 +314,4 @@ exports.Replication = Replication exports.getScopedConfig = getScopedConfig exports.generateConfigID = generateConfigID exports.getConfigParams = getConfigParams -exports.getScopedFullConfig = getScopedFullConfig \ No newline at end of file +exports.getScopedFullConfig = getScopedFullConfig diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index c5bd01b383..cc35da40ec 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -233,7 +233,9 @@ class QueryBuilder { } async run() { - const url = `${getCouchUrl()}/${this.appId}/_design/database/_search/${SearchIndexes.ROWS}` + const url = `${getCouchUrl()}/${this.appId}/_design/database/_search/${ + SearchIndexes.ROWS + }` const body = this.buildSearchBody() return await runQuery(url, body) } diff --git a/packages/server/src/db/client.js b/packages/server/src/db/client.js index 887b287c84..9a244fee17 100644 --- a/packages/server/src/db/client.js +++ b/packages/server/src/db/client.js @@ -15,7 +15,7 @@ let POUCH_DB_DEFAULTS = { auth: { username: env.COUCH_DB_USERNAME, password: env.COUCH_DB_PASSWORD, - } + }, } if (env.isTest()) { diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index d09ddf0652..c0676634f7 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -10,7 +10,7 @@ let POUCH_DB_DEFAULTS = { auth: { username: env.COUCH_DB_USERNAME, password: env.COUCH_DB_PASSWORD, - } + }, } if (env.isTest()) { From 0cc16ee5c299d038c0a8272a34285321fae2491a Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 16 Aug 2021 16:35:51 +0000 Subject: [PATCH 07/58] v0.9.106 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 825ab2f1f1..30b42fc1ec 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.105", + "version": "0.9.106", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index ea638f859f..db542205ff 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.105", + "version": "0.9.106", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index c8f93c9dfb..b1951d9874 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.105", + "version": "0.9.106", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index a7ed98b639..9595ad6035 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.105", + "version": "0.9.106", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.105", - "@budibase/client": "^0.9.105", + "@budibase/bbui": "^0.9.106", + "@budibase/client": "^0.9.106", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.105", + "@budibase/string-templates": "^0.9.106", "@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 0dc653a296..aa5b558bd5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.105", + "version": "0.9.106", "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 6fe0e6b3bf..4fe16bc42a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.105", + "version": "0.9.106", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.105", - "@budibase/standard-components": "^0.9.105", - "@budibase/string-templates": "^0.9.105", + "@budibase/bbui": "^0.9.106", + "@budibase/standard-components": "^0.9.106", + "@budibase/string-templates": "^0.9.106", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 7ca5437433..ad9a146828 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.105", + "version": "0.9.106", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.105", - "@budibase/client": "^0.9.105", - "@budibase/string-templates": "^0.9.105", + "@budibase/auth": "^0.9.106", + "@budibase/client": "^0.9.106", + "@budibase/string-templates": "^0.9.106", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.105", + "@budibase/standard-components": "^0.9.106", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index a9bdbf6428..2b017c90ae 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.105", + "version": "0.9.106", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.105", + "@budibase/bbui": "^0.9.106", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index d980f2b361..f124d57643 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.105", + "version": "0.9.106", "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 9e33e6ac64..8b504aa44b 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.105", + "version": "0.9.106", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.105", - "@budibase/string-templates": "^0.9.105", + "@budibase/auth": "^0.9.106", + "@budibase/string-templates": "^0.9.106", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 8e1e016c66fe9192dbf5416260b5013dfd46a003 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 17 Aug 2021 07:16:43 +0100 Subject: [PATCH 08/58] Revert "Feature/couchdb auth" --- packages/auth/src/db/utils.js | 13 +------------ packages/auth/src/environment.js | 2 -- packages/server/scripts/dev/manage.js | 2 +- .../src/api/controllers/row/internalSearch.js | 6 ++---- packages/server/src/db/client.js | 4 ---- packages/server/src/environment.js | 2 -- packages/worker/scripts/dev/manage.js | 2 +- packages/worker/src/db/index.js | 4 ---- 8 files changed, 5 insertions(+), 30 deletions(-) diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 2ac23d02a5..1fc78f4182 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -159,17 +159,6 @@ exports.getDeployedAppID = appId => { return appId } -exports.getCouchUrl = () => { - // username and password already exist in URL - if (env.COUCH_DB_URL.includes("@")) { - return env.COUCH_DB_URL - } - - const [protocol, ...rest] = env.COUCH_DB_URL.split("://") - - return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}` -} - /** * if in production this will use the CouchDB _all_dbs call to retrieve a list of databases. If testing * when using Pouch it will use the pouchdb-all-dbs package. @@ -179,7 +168,7 @@ exports.getAllDbs = async () => { if (env.isTest()) { return getCouch().allDbs() } - const response = await fetch(`${exports.getCouchUrl()}/_all_dbs`) + const response = await fetch(`${env.COUCH_DB_URL}/_all_dbs`) if (response.status === 200) { return response.json() } else { diff --git a/packages/auth/src/environment.js b/packages/auth/src/environment.js index e64a1c75f0..355843d02d 100644 --- a/packages/auth/src/environment.js +++ b/packages/auth/src/environment.js @@ -9,8 +9,6 @@ function isTest() { module.exports = { JWT_SECRET: process.env.JWT_SECRET, COUCH_DB_URL: process.env.COUCH_DB_URL, - COUCH_DB_USERNAME: process.env.COUCH_DB_USER, - COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, SALT_ROUNDS: process.env.SALT_ROUNDS, REDIS_URL: process.env.REDIS_URL, REDIS_PASSWORD: process.env.REDIS_PASSWORD, diff --git a/packages/server/scripts/dev/manage.js b/packages/server/scripts/dev/manage.js index 7e9d7f6a07..ffd8c6b9e3 100644 --- a/packages/server/scripts/dev/manage.js +++ b/packages/server/scripts/dev/manage.js @@ -36,7 +36,7 @@ async function init() { const envFileJson = { PORT: 4001, MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://localhost:10000/db/", + COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", REDIS_URL: "localhost:6379", WORKER_URL: "http://localhost:4002", INTERNAL_API_KEY: "budibase", diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index cc35da40ec..c13091d6e8 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -1,6 +1,6 @@ const { SearchIndexes } = require("../../../db/utils") +const env = require("../../../environment") const fetch = require("node-fetch") -const { getCouchUrl } = require("@budibase/auth/db") /** * Class to build lucene query URLs. @@ -233,9 +233,7 @@ class QueryBuilder { } async run() { - const url = `${getCouchUrl()}/${this.appId}/_design/database/_search/${ - SearchIndexes.ROWS - }` + const url = `${env.COUCH_DB_URL}/${this.appId}/_design/database/_search/${SearchIndexes.ROWS}` const body = this.buildSearchBody() return await runQuery(url, body) } diff --git a/packages/server/src/db/client.js b/packages/server/src/db/client.js index 9a244fee17..d50d72b18d 100644 --- a/packages/server/src/db/client.js +++ b/packages/server/src/db/client.js @@ -12,10 +12,6 @@ PouchDB.adapter("writableStream", replicationStream.adapters.writableStream) let POUCH_DB_DEFAULTS = { prefix: COUCH_DB_URL, - auth: { - username: env.COUCH_DB_USERNAME, - password: env.COUCH_DB_PASSWORD, - }, } if (env.isTest()) { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 45c7673851..52c680f65a 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -23,8 +23,6 @@ module.exports = { // important PORT: process.env.PORT, JWT_SECRET: process.env.JWT_SECRET, - COUCH_DB_USERNAME: process.env.COUCH_DB_USER, - COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD, COUCH_DB_URL: process.env.COUCH_DB_URL, MINIO_URL: process.env.MINIO_URL, WORKER_URL: process.env.WORKER_URL, diff --git a/packages/worker/scripts/dev/manage.js b/packages/worker/scripts/dev/manage.js index d7eb76fc74..b9d28b6278 100644 --- a/packages/worker/scripts/dev/manage.js +++ b/packages/worker/scripts/dev/manage.js @@ -17,7 +17,7 @@ async function init() { REDIS_URL: "localhost:6379", REDIS_PASSWORD: "budibase", MINIO_URL: "http://localhost:10000/", - COUCH_DB_URL: "http://localhost:10000/db/", + COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/", } let envFile = "" Object.keys(envFileJson).forEach(key => { diff --git a/packages/worker/src/db/index.js b/packages/worker/src/db/index.js index c0676634f7..d6d035cff1 100644 --- a/packages/worker/src/db/index.js +++ b/packages/worker/src/db/index.js @@ -7,10 +7,6 @@ const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/" let POUCH_DB_DEFAULTS = { prefix: COUCH_DB_URL, - auth: { - username: env.COUCH_DB_USERNAME, - password: env.COUCH_DB_PASSWORD, - }, } if (env.isTest()) { From a2efbb13380d08a2ffd2c08378cd16ca774c0e2a Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Tue, 17 Aug 2021 06:25:14 +0000 Subject: [PATCH 09/58] v0.9.107 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 30b42fc1ec..1b2dfb6bbd 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.106", + "version": "0.9.107", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index db542205ff..8e8395b21e 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.106", + "version": "0.9.107", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index b1951d9874..7ea6d15a59 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.106", + "version": "0.9.107", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 9595ad6035..2aa61c79ba 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.106", + "version": "0.9.107", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.106", - "@budibase/client": "^0.9.106", + "@budibase/bbui": "^0.9.107", + "@budibase/client": "^0.9.107", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.106", + "@budibase/string-templates": "^0.9.107", "@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 aa5b558bd5..c328df69c0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.106", + "version": "0.9.107", "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 4fe16bc42a..8972171863 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.106", + "version": "0.9.107", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.106", - "@budibase/standard-components": "^0.9.106", - "@budibase/string-templates": "^0.9.106", + "@budibase/bbui": "^0.9.107", + "@budibase/standard-components": "^0.9.107", + "@budibase/string-templates": "^0.9.107", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index ad9a146828..5daca5d40f 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.106", + "version": "0.9.107", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.106", - "@budibase/client": "^0.9.106", - "@budibase/string-templates": "^0.9.106", + "@budibase/auth": "^0.9.107", + "@budibase/client": "^0.9.107", + "@budibase/string-templates": "^0.9.107", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.106", + "@budibase/standard-components": "^0.9.107", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 2b017c90ae..96b2deff04 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.106", + "version": "0.9.107", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.106", + "@budibase/bbui": "^0.9.107", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index f124d57643..b64b19bb97 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.106", + "version": "0.9.107", "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 8b504aa44b..9d6b98aa6d 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.106", + "version": "0.9.107", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.106", - "@budibase/string-templates": "^0.9.106", + "@budibase/auth": "^0.9.107", + "@budibase/string-templates": "^0.9.107", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 17438372d08315c193c6c1ec14f6dbbb59501288 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 19 Aug 2021 16:54:44 +0100 Subject: [PATCH 10/58] Add ability for user to select 'List' data type for a column --- packages/bbui/src/Table/ArrayRenderer.svelte | 17 +++++++++++++++++ packages/bbui/src/Table/CellRenderer.svelte | 3 ++- .../backend/DataTable/RowFieldControl.svelte | 14 +++++++++++++- .../DataTable/modals/CreateEditColumn.svelte | 13 +++++++++++++ .../TableNavigator/TableDataImport.svelte | 4 ++++ packages/builder/src/constants/backend/index.js | 9 +++++++++ .../server/src/api/controllers/row/utils.js | 16 ++++++++++++++-- packages/server/src/constants/index.js | 1 + packages/server/src/utilities/rowProcessor.js | 5 +++++ 9 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 packages/bbui/src/Table/ArrayRenderer.svelte diff --git a/packages/bbui/src/Table/ArrayRenderer.svelte b/packages/bbui/src/Table/ArrayRenderer.svelte new file mode 100644 index 0000000000..8281fce78c --- /dev/null +++ b/packages/bbui/src/Table/ArrayRenderer.svelte @@ -0,0 +1,17 @@ + + +{#each badges as badge} + {badge} +{/each} +{#if leftover} +
+{leftover} more
+{/if} diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte index 2d073b7782..d6a2f3196d 100644 --- a/packages/bbui/src/Table/CellRenderer.svelte +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -4,7 +4,7 @@ import DateTimeRenderer from "./DateTimeRenderer.svelte" import RelationshipRenderer from "./RelationshipRenderer.svelte" import AttachmentRenderer from "./AttachmentRenderer.svelte" - + import ArrayRenderer from "./ArrayRenderer.svelte" export let row export let schema export let value @@ -19,6 +19,7 @@ options: StringRenderer, number: StringRenderer, longform: StringRenderer, + array: ArrayRenderer, } $: type = schema?.type ?? "string" $: customRenderer = customRenderers?.find(x => x.column === schema?.name) diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index 078dbf25b2..66879b83cf 100644 --- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -1,5 +1,12 @@ diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 88152deb0f..2ce88c9648 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -26,6 +26,15 @@ export const FIELDS = { inclusion: [], }, }, + ARRAY: { + name: "List", + type: "array", + constraints: { + type: "array", + presence: false, + inclusion: [], + }, + }, NUMBER: { name: "Number", type: "number", diff --git a/packages/server/src/api/controllers/row/utils.js b/packages/server/src/api/controllers/row/utils.js index 16c48181d1..bdb7e03785 100644 --- a/packages/server/src/api/controllers/row/utils.js +++ b/packages/server/src/api/controllers/row/utils.js @@ -58,12 +58,24 @@ exports.validate = async ({ appId, tableId, row, table }) => { const constraints = cloneDeep(table.schema[fieldName].constraints) // special case for options, need to always allow unselected (null) if ( - table.schema[fieldName].type === FieldTypes.OPTIONS && + table.schema[fieldName].type === + (FieldTypes.OPTIONS || FieldTypes.ARRAY) && constraints.inclusion ) { constraints.inclusion.push(null) } - const res = validateJs.single(row[fieldName], constraints) + let res + + // Validate.js doesn't seem to handle array of array very well + if (table.schema[fieldName].type === FieldTypes.ARRAY) { + row[fieldName].map(val => { + if (constraints.inclusion.includes(val)) { + errors[fieldName] = "Field not in list" + } + }) + } else { + res = validateJs.single(row[fieldName], constraints) + } if (res) errors[fieldName] = res } return { valid: Object.keys(errors).length === 0, errors } diff --git a/packages/server/src/constants/index.js b/packages/server/src/constants/index.js index 703b33deb1..bc7b5b368f 100644 --- a/packages/server/src/constants/index.js +++ b/packages/server/src/constants/index.js @@ -12,6 +12,7 @@ exports.FieldTypes = { OPTIONS: "options", NUMBER: "number", BOOLEAN: "boolean", + ARRAY: "array", DATETIME: "datetime", ATTACHMENT: "attachment", LINK: "link", diff --git a/packages/server/src/utilities/rowProcessor.js b/packages/server/src/utilities/rowProcessor.js index c067d4de87..3c43a20409 100644 --- a/packages/server/src/utilities/rowProcessor.js +++ b/packages/server/src/utilities/rowProcessor.js @@ -29,6 +29,11 @@ const TYPE_TRANSFORM_MAP = { [null]: null, [undefined]: undefined, }, + [FieldTypes.ARRAY]: { + "": [], + [null]: [], + [undefined]: undefined, + }, [FieldTypes.STRING]: { "": "", [null]: "", From 29c33d7ed45dd12efc3c5d4d4daea4b3550fd1a4 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 19 Aug 2021 17:18:41 +0100 Subject: [PATCH 11/58] Remove schema validation when inheriting initial values in forms --- packages/standard-components/src/forms/Form.svelte | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/standard-components/src/forms/Form.svelte b/packages/standard-components/src/forms/Form.svelte index 2514232ebc..b08a853437 100644 --- a/packages/standard-components/src/forms/Form.svelte +++ b/packages/standard-components/src/forms/Form.svelte @@ -24,12 +24,9 @@ if (["user", "url"].includes(context.closestComponentId)) { return {} } - // Only inherit values if the table ID matches + // Always inherit the closest data source const closestContext = context[`${context.closestComponentId}`] || {} - if (dataSource.tableId !== closestContext?.tableId) { - return {} - } - return closestContext + return closestContext || {} } $: initialValues = getInitialValues(actionType, dataSource, $context) From 73ea7a803261b2f530866499f57d3d7209d3db3c Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Thu, 19 Aug 2021 16:28:01 +0000 Subject: [PATCH 12/58] v0.9.108 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 1b2dfb6bbd..f77edaab18 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.107", + "version": "0.9.108", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 8e8395b21e..1ef8877eb7 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.107", + "version": "0.9.108", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 7ea6d15a59..9fc53e0f58 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.107", + "version": "0.9.108", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 2aa61c79ba..07ad4c935c 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.107", + "version": "0.9.108", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.107", - "@budibase/client": "^0.9.107", + "@budibase/bbui": "^0.9.108", + "@budibase/client": "^0.9.108", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.107", + "@budibase/string-templates": "^0.9.108", "@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 c328df69c0..68934a0c71 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.107", + "version": "0.9.108", "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 8972171863..08d98ac4b7 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.107", + "version": "0.9.108", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.107", - "@budibase/standard-components": "^0.9.107", - "@budibase/string-templates": "^0.9.107", + "@budibase/bbui": "^0.9.108", + "@budibase/standard-components": "^0.9.108", + "@budibase/string-templates": "^0.9.108", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 5daca5d40f..a2cf814e14 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.107", + "version": "0.9.108", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.107", - "@budibase/client": "^0.9.107", - "@budibase/string-templates": "^0.9.107", + "@budibase/auth": "^0.9.108", + "@budibase/client": "^0.9.108", + "@budibase/string-templates": "^0.9.108", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.107", + "@budibase/standard-components": "^0.9.108", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 96b2deff04..cb29853a38 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.107", + "version": "0.9.108", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.107", + "@budibase/bbui": "^0.9.108", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index b64b19bb97..13626d1b99 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.107", + "version": "0.9.108", "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 9d6b98aa6d..5be0d4f920 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.107", + "version": "0.9.108", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.107", - "@budibase/string-templates": "^0.9.107", + "@budibase/auth": "^0.9.108", + "@budibase/string-templates": "^0.9.108", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 0fb566a3dd7503c8279867ccb4dc98cbf7bd3159 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 20 Aug 2021 09:47:08 +0100 Subject: [PATCH 13/58] allow users to override watchtower port --- hosting/docker-compose.yaml | 2 ++ hosting/hosting.properties | 1 + packages/cli/src/hosting/makeEnv.js | 1 + 3 files changed, 4 insertions(+) diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml index 9cdf2b2114..fffadae24b 100644 --- a/hosting/docker-compose.yaml +++ b/hosting/docker-compose.yaml @@ -119,6 +119,8 @@ services: watchtower-service: image: containrrr/watchtower + ports: + - "${WATCHTOWER_PORT}:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock command: --debug --http-api-update bbapps bbworker diff --git a/hosting/hosting.properties b/hosting/hosting.properties index d11972bc4b..6382bf2f07 100644 --- a/hosting/hosting.properties +++ b/hosting/hosting.properties @@ -17,4 +17,5 @@ WORKER_PORT=4003 MINIO_PORT=4004 COUCH_DB_PORT=4005 REDIS_PORT=6379 +WATCHTOWER_PORT=8080 BUDIBASE_ENVIRONMENT=PRODUCTION diff --git a/packages/cli/src/hosting/makeEnv.js b/packages/cli/src/hosting/makeEnv.js index 8806c2e1e6..ff59e60579 100644 --- a/packages/cli/src/hosting/makeEnv.js +++ b/packages/cli/src/hosting/makeEnv.js @@ -26,6 +26,7 @@ WORKER_PORT=4003 MINIO_PORT=4004 COUCH_DB_PORT=4005 REDIS_PORT=6379 +WATCHTOWER_PORT=8080 BUDIBASE_ENVIRONMENT=PRODUCTION` } From c3a6e13103062fff1e2e199b938bde065efff6c8 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 16 Aug 2021 09:44:15 +0100 Subject: [PATCH 14/58] Bug fix for unable to navigate from sql screen --- .../[selectedDatasource]/index.svelte | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte index b0377d2f27..0cd667a82e 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte @@ -9,7 +9,6 @@ import ICONS from "components/backend/DatasourceNavigator/icons" import { capitalise } from "helpers" - let unsaved = false let relationshipModal let displayColumnModal let selectedFromRelationship, selectedToRelationship @@ -71,7 +70,6 @@ // Create datasource await datasources.save(datasource) notifications.success(`Datasource ${name} updated successfully.`) - unsaved = false } catch (err) { notifications.error(`Error saving datasource: ${err}`) } @@ -81,7 +79,6 @@ try { await datasources.updateSchema(datasource) notifications.success(`Datasource ${name} tables updated successfully.`) - unsaved = false await tables.fetch() } catch (err) { notifications.error(`Error updating datasource schema: ${err}`) @@ -98,10 +95,6 @@ $goto(`../../table/${table._id}`) } - function setUnsaved() { - unsaved = true - } - function openRelationshipModal(fromRelationship, toRelationship) { selectedFromRelationship = fromRelationship || {} selectedToRelationship = toRelationship || {} @@ -111,16 +104,6 @@ function openDisplayColumnModal() { displayColumnModal.show() } - - $beforeUrlChange(() => { - if (unsaved) { - notifications.error( - "Unsaved changes. Please save your datasource configuration before leaving." - ) - return false - } - return true - }) @@ -164,7 +147,6 @@ {#if datasource.plus} From 461311bb06edca4d702e052732ab545f6b44c9b8 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 18 Aug 2021 00:02:17 +0100 Subject: [PATCH 15/58] fixes organisation logo not showing --- .../data/datasource/[selectedDatasource]/index.svelte | 2 +- .../src/pages/builder/portal/settings/organisation.svelte | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte index 0cd667a82e..fc82e3a11c 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/index.svelte @@ -1,5 +1,5 @@ + + + + diff --git a/packages/standard-components/src/forms/index.js b/packages/standard-components/src/forms/index.js index fed371278b..cbc278aa03 100644 --- a/packages/standard-components/src/forms/index.js +++ b/packages/standard-components/src/forms/index.js @@ -3,6 +3,7 @@ export { default as fieldgroup } from "./FieldGroup.svelte" export { default as stringfield } from "./StringField.svelte" export { default as numberfield } from "./NumberField.svelte" export { default as optionsfield } from "./OptionsField.svelte" +export { default as multifieldselect } from "./MultiFieldSelect.svelte" export { default as booleanfield } from "./BooleanField.svelte" export { default as longformfield } from "./LongFormField.svelte" export { default as datetimefield } from "./DateTimeField.svelte" From 2ff9e337734cf3418550c222546bcbb1cb53133a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 20 Aug 2021 16:21:08 +0100 Subject: [PATCH 20/58] fix test --- packages/server/src/api/routes/tests/datasource.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/datasource.spec.js b/packages/server/src/api/routes/tests/datasource.spec.js index 7387dd3c46..98a99717fd 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.js +++ b/packages/server/src/api/routes/tests/datasource.spec.js @@ -94,7 +94,7 @@ describe("/datasources", () => { .expect(200) // this is mock data, can't test it expect(res.body).toBeDefined() - expect(pg.queryMock).toHaveBeenCalledWith(`select "users"."name" as "users.name", "users"."age" as "users.age" from "users" where "users"."name" like $1 limit $2`, ["John%", 5000]) + expect(pg.queryMock).toHaveBeenCalledWith(`select "users"."name" as "users.name", "users"."age" as "users.age" from "users" where "users"."name" ilike $1 limit $2`, ["John%", 5000]) }) }) From 694e735a874eb08251a4444f1952df6c74380ca4 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Fri, 20 Aug 2021 16:43:42 +0000 Subject: [PATCH 21/58] v0.9.111 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index a92ad5f707..d818043b3e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.110", + "version": "0.9.111", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 7ddaae5129..5105213846 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.110", + "version": "0.9.111", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 26b0f890cc..16a4106a51 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.110", + "version": "0.9.111", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 24a6375e32..1631a98ae6 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.110", + "version": "0.9.111", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.110", - "@budibase/client": "^0.9.110", + "@budibase/bbui": "^0.9.111", + "@budibase/client": "^0.9.111", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.110", + "@budibase/string-templates": "^0.9.111", "@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 e7ed900719..9f8e91d8b3 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.110", + "version": "0.9.111", "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 5a4ba95a25..1023dbc869 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.110", + "version": "0.9.111", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.110", - "@budibase/standard-components": "^0.9.110", - "@budibase/string-templates": "^0.9.110", + "@budibase/bbui": "^0.9.111", + "@budibase/standard-components": "^0.9.111", + "@budibase/string-templates": "^0.9.111", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 95bd90eb68..f25cb470aa 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.110", + "version": "0.9.111", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.110", - "@budibase/client": "^0.9.110", - "@budibase/string-templates": "^0.9.110", + "@budibase/auth": "^0.9.111", + "@budibase/client": "^0.9.111", + "@budibase/string-templates": "^0.9.111", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.110", + "@budibase/standard-components": "^0.9.111", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 840a17cda0..b90276c852 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.110", + "version": "0.9.111", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.110", + "@budibase/bbui": "^0.9.111", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index eae217553e..a587d88397 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.110", + "version": "0.9.111", "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 dce64c1a84..602487e4ed 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.110", + "version": "0.9.111", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.110", - "@budibase/string-templates": "^0.9.110", + "@budibase/auth": "^0.9.111", + "@budibase/string-templates": "^0.9.111", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 4dff1a34acaaf9b55b4bf6dbd3f83816ba814580 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 23 Aug 2021 15:42:00 +0100 Subject: [PATCH 22/58] posthog cloud config --- packages/cli/src/constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/constants.js b/packages/cli/src/constants.js index fe7c61f4fa..8b9cad88a8 100644 --- a/packages/cli/src/constants.js +++ b/packages/cli/src/constants.js @@ -15,5 +15,5 @@ exports.AnalyticsEvents = { SelfHostInit: "hosting_init", } -exports.BUDIBASE_POSTHOG_URL = "https://posthog.budi.live" -exports.BUDIBASE_POSTHOG_TOKEN = "Oeq9KzIpZYaNsXIvHw5QTZWNpfiG_EOjAOpjTyAiitY" +exports.BUDIBASE_POSTHOG_URL = "https://app.posthog.com" +exports.BUDIBASE_POSTHOG_TOKEN = "phc_yGOn4i7jWKaCTapdGR6lfA4AvmuEQ2ijn5zAVSFYPlS" From 52b51e9873665acbc38adfec4b07579886c4c6af Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 23 Aug 2021 15:56:54 +0100 Subject: [PATCH 23/58] spacing in analytics --- packages/builder/src/analytics.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/analytics.js b/packages/builder/src/analytics.js index bcc59eb311..7442816aa5 100644 --- a/packages/builder/src/analytics.js +++ b/packages/builder/src/analytics.js @@ -79,6 +79,7 @@ const isFeedbackTimeElapsed = sinceDateStr => { const feedbackMilliseconds = feedbackHours * 60 * 60 * 1000 return Date.now() > sinceDate + feedbackMilliseconds } + function submitFeedback(values) { if (!analyticsEnabled || !process.env.POSTHOG_TOKEN) return localStorage.setItem(FEEDBACK_SUBMITTED_KEY, Date.now()) From 342e3a218e919bfbb9eddf76313a7569ba450f11 Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Mon, 23 Aug 2021 17:32:27 +0200 Subject: [PATCH 24/58] limit the width of the preview component --- packages/builder/src/components/integration/QueryViewer.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/components/integration/QueryViewer.svelte b/packages/builder/src/components/integration/QueryViewer.svelte index 5c2523d519..e642494ce2 100644 --- a/packages/builder/src/components/integration/QueryViewer.svelte +++ b/packages/builder/src/components/integration/QueryViewer.svelte @@ -218,6 +218,7 @@ .viewer { min-height: 200px; + width: 640px; } .preview { From 324f64c79016a360ebdb70fe2f1d6f776cb3e02a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 23 Aug 2021 16:38:09 +0100 Subject: [PATCH 25/58] lint --- packages/cli/src/constants.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/constants.js b/packages/cli/src/constants.js index 8b9cad88a8..7a3b1463ca 100644 --- a/packages/cli/src/constants.js +++ b/packages/cli/src/constants.js @@ -16,4 +16,5 @@ exports.AnalyticsEvents = { } exports.BUDIBASE_POSTHOG_URL = "https://app.posthog.com" -exports.BUDIBASE_POSTHOG_TOKEN = "phc_yGOn4i7jWKaCTapdGR6lfA4AvmuEQ2ijn5zAVSFYPlS" +exports.BUDIBASE_POSTHOG_TOKEN = + "phc_yGOn4i7jWKaCTapdGR6lfA4AvmuEQ2ijn5zAVSFYPlS" From c5da2a59cba8030464e1140a55b744799a626d6a Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 23 Aug 2021 16:29:12 +0000 Subject: [PATCH 26/58] v0.9.112 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index d818043b3e..3431f5ff37 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.111", + "version": "0.9.112", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 5105213846..dd0690afc3 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.111", + "version": "0.9.112", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 16a4106a51..16c79e8c73 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.111", + "version": "0.9.112", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 1631a98ae6..59b7f3d3ec 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.111", + "version": "0.9.112", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.111", - "@budibase/client": "^0.9.111", + "@budibase/bbui": "^0.9.112", + "@budibase/client": "^0.9.112", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.111", + "@budibase/string-templates": "^0.9.112", "@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 9f8e91d8b3..008aa4ea51 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.111", + "version": "0.9.112", "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 1023dbc869..a158d42167 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.111", + "version": "0.9.112", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.111", - "@budibase/standard-components": "^0.9.111", - "@budibase/string-templates": "^0.9.111", + "@budibase/bbui": "^0.9.112", + "@budibase/standard-components": "^0.9.112", + "@budibase/string-templates": "^0.9.112", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index f25cb470aa..5c6e31562b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.111", + "version": "0.9.112", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.111", - "@budibase/client": "^0.9.111", - "@budibase/string-templates": "^0.9.111", + "@budibase/auth": "^0.9.112", + "@budibase/client": "^0.9.112", + "@budibase/string-templates": "^0.9.112", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.111", + "@budibase/standard-components": "^0.9.112", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index b90276c852..3605eee30f 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.111", + "version": "0.9.112", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.111", + "@budibase/bbui": "^0.9.112", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index a587d88397..8769d0e339 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.111", + "version": "0.9.112", "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 602487e4ed..fdb5f27925 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.111", + "version": "0.9.112", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.111", - "@budibase/string-templates": "^0.9.111", + "@budibase/auth": "^0.9.112", + "@budibase/string-templates": "^0.9.112", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From b841b41e290eb393bfafb5b87905823c126ab84c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 23 Aug 2021 21:48:03 +0100 Subject: [PATCH 27/58] update watchtower port to 6161 --- hosting/docker-compose.yaml | 2 -- hosting/hosting.properties | 2 +- packages/cli/src/hosting/makeEnv.js | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml index fffadae24b..560b273668 100644 --- a/hosting/docker-compose.yaml +++ b/hosting/docker-compose.yaml @@ -130,8 +130,6 @@ services: - WATCHTOWER_CLEANUP=true labels: - "com.centurylinklabs.watchtower.enable=false" - ports: - - 6161:8080 volumes: diff --git a/hosting/hosting.properties b/hosting/hosting.properties index 6382bf2f07..c8e2f5c606 100644 --- a/hosting/hosting.properties +++ b/hosting/hosting.properties @@ -17,5 +17,5 @@ WORKER_PORT=4003 MINIO_PORT=4004 COUCH_DB_PORT=4005 REDIS_PORT=6379 -WATCHTOWER_PORT=8080 +WATCHTOWER_PORT=6161 BUDIBASE_ENVIRONMENT=PRODUCTION diff --git a/packages/cli/src/hosting/makeEnv.js b/packages/cli/src/hosting/makeEnv.js index ff59e60579..d1d23999f8 100644 --- a/packages/cli/src/hosting/makeEnv.js +++ b/packages/cli/src/hosting/makeEnv.js @@ -26,7 +26,7 @@ WORKER_PORT=4003 MINIO_PORT=4004 COUCH_DB_PORT=4005 REDIS_PORT=6379 -WATCHTOWER_PORT=8080 +WATCHTOWER_PORT=6161 BUDIBASE_ENVIRONMENT=PRODUCTION` } From 234769a83b672fb9bc3fd76a42204dda29402558 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 23 Aug 2021 20:59:56 +0000 Subject: [PATCH 28/58] v0.9.113 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 3431f5ff37..1754992fc9 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.112", + "version": "0.9.113", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index dd0690afc3..43379c6eda 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.112", + "version": "0.9.113", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 16c79e8c73..e90c6c8216 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.112", + "version": "0.9.113", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 59b7f3d3ec..b703aeef20 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.112", + "version": "0.9.113", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.112", - "@budibase/client": "^0.9.112", + "@budibase/bbui": "^0.9.113", + "@budibase/client": "^0.9.113", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.112", + "@budibase/string-templates": "^0.9.113", "@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 008aa4ea51..6f64ce69cc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.112", + "version": "0.9.113", "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 a158d42167..120afdc5a8 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.112", + "version": "0.9.113", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.112", - "@budibase/standard-components": "^0.9.112", - "@budibase/string-templates": "^0.9.112", + "@budibase/bbui": "^0.9.113", + "@budibase/standard-components": "^0.9.113", + "@budibase/string-templates": "^0.9.113", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 5c6e31562b..4b8b383773 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.112", + "version": "0.9.113", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.112", - "@budibase/client": "^0.9.112", - "@budibase/string-templates": "^0.9.112", + "@budibase/auth": "^0.9.113", + "@budibase/client": "^0.9.113", + "@budibase/string-templates": "^0.9.113", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.112", + "@budibase/standard-components": "^0.9.113", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 3605eee30f..17ccf0aecc 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.112", + "version": "0.9.113", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.112", + "@budibase/bbui": "^0.9.113", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 8769d0e339..28c921610f 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.112", + "version": "0.9.113", "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 fdb5f27925..cac8ec7d3e 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.112", + "version": "0.9.113", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.112", - "@budibase/string-templates": "^0.9.112", + "@budibase/auth": "^0.9.113", + "@budibase/string-templates": "^0.9.113", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 9f99f7c36d9f9172729162a585065318ddc4ad4d Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 24 Aug 2021 10:42:22 +0100 Subject: [PATCH 29/58] remove pageviews from PH --- packages/builder/src/analytics.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/analytics.js b/packages/builder/src/analytics.js index 7442816aa5..5b130a8e6b 100644 --- a/packages/builder/src/analytics.js +++ b/packages/builder/src/analytics.js @@ -23,6 +23,7 @@ async function activate() { if (posthogConfigured) { posthog.init(process.env.POSTHOG_TOKEN, { autocapture: false, + capture_pageview: false, api_host: process.env.POSTHOG_URL, }) posthog.set_config({ persistence: "cookie" }) From 6e03449906a8e341c61991018a74234e87fca4b6 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Tue, 24 Aug 2021 09:55:51 +0000 Subject: [PATCH 30/58] v0.9.114 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 1754992fc9..d190a75cf4 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.113", + "version": "0.9.114", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 43379c6eda..8b6b3434b7 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.113", + "version": "0.9.114", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index e90c6c8216..e41d95563a 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.113", + "version": "0.9.114", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index b703aeef20..d0a765f209 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.113", + "version": "0.9.114", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.113", - "@budibase/client": "^0.9.113", + "@budibase/bbui": "^0.9.114", + "@budibase/client": "^0.9.114", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.113", + "@budibase/string-templates": "^0.9.114", "@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 6f64ce69cc..8676c915bc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.113", + "version": "0.9.114", "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 120afdc5a8..c7976cc9cf 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.113", + "version": "0.9.114", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.113", - "@budibase/standard-components": "^0.9.113", - "@budibase/string-templates": "^0.9.113", + "@budibase/bbui": "^0.9.114", + "@budibase/standard-components": "^0.9.114", + "@budibase/string-templates": "^0.9.114", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 4b8b383773..dacbbbc108 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.113", + "version": "0.9.114", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.113", - "@budibase/client": "^0.9.113", - "@budibase/string-templates": "^0.9.113", + "@budibase/auth": "^0.9.114", + "@budibase/client": "^0.9.114", + "@budibase/string-templates": "^0.9.114", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.113", + "@budibase/standard-components": "^0.9.114", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 17ccf0aecc..d586988f56 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.113", + "version": "0.9.114", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.113", + "@budibase/bbui": "^0.9.114", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 28c921610f..a3b6920231 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.113", + "version": "0.9.114", "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 cac8ec7d3e..65fb92ecc6 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.113", + "version": "0.9.114", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.113", - "@budibase/string-templates": "^0.9.113", + "@budibase/auth": "^0.9.114", + "@budibase/string-templates": "^0.9.114", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From f000d44e39732a6bdc3c8cfe09593c370bffe761 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 24 Aug 2021 16:14:38 +0100 Subject: [PATCH 31/58] Add contains option to lucene query builder --- .../screenTemplates/utils/commonComponents.js | 7 +++ .../FilterEditor/FilterDrawer.svelte | 24 ++++++++- packages/builder/src/helpers/lucene.js | 7 +++ .../src/api/controllers/row/internalSearch.js | 23 +++++++- packages/server/src/db/views/staticViews.js | 10 +++- packages/standard-components/manifest.json | 6 +-- .../src/forms/MultiFieldSelect.svelte | 48 +++++------------ .../src/forms/OptionsField.svelte | 38 ++------------ .../src/forms/optionsParser.js | 52 +++++++++++++++++++ packages/standard-components/src/lucene.js | 1 + 10 files changed, 136 insertions(+), 80 deletions(-) create mode 100644 packages/standard-components/src/forms/optionsParser.js diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js index 7d40995925..5b3bc041ff 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js @@ -168,6 +168,13 @@ export function makeDatasourceFormComponents(datasource) { optionsSource: "schema", }) } + if (fieldType === "array") { + component.customProps({ + placeholder: "Choose an option", + optionsSource: "schema", + }) + } + if (fieldType === "link") { let placeholder = fieldSchema.relationshipType === "one-to-many" diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte index d41d28e4e3..cd5cc1661c 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte @@ -9,6 +9,7 @@ DrawerContent, Layout, Body, + Multiselect, } from "@budibase/bbui" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" import { generate } from "shortid" @@ -59,6 +60,14 @@ expression.operator = validOperators[0] ?? OperatorOptions.Equals.value onOperatorChange(expression, expression.operator) } + + // if changed to an array, change default value to empty array + const idx = filters.findIndex(x => (x.field = field)) + if (expression.type === "array") { + filters[idx].value = [] + } else { + filters[idx].value = null + } } const onOperatorChange = (expression, operator) => { @@ -74,7 +83,12 @@ const getFieldOptions = field => { const schema = schemaFields.find(x => x.name === field) - return schema?.constraints?.inclusion || [] + const opt = + schema.type == "array" + ? schema?.constraints?.inclusion[0] + : schema?.constraints?.inclusion || [] + + return opt } @@ -128,6 +142,14 @@ options={getFieldOptions(filter.field)} bind:value={filter.value} /> + {:else if filter.type === "array"} + x} + getOptionValue={x => x} + /> {:else if filter.type === "boolean"} { @@ -55,6 +60,8 @@ export const getValidOperatorsForType = type => { ] } else if (type === "options") { return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty] + } else if (type === "array") { + return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.Contains] } else if (type === "boolean") { return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty] } else if (type === "longform") { diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index cc35da40ec..e2e7beee27 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -17,6 +17,7 @@ class QueryBuilder { notEqual: {}, empty: {}, notEmpty: {}, + contains: {}, ...base, } this.limit = 50 @@ -104,6 +105,12 @@ class QueryBuilder { return this } + addContains(key, value) { + this.query.contains[key] = value + return this + } + + /** * Preprocesses a value before going into a lucene search. * Transforms strings to lowercase and wraps strings and bools in quotes. @@ -121,7 +128,7 @@ class QueryBuilder { } // Escape characters if (escape && originalType === "string") { - value = `${value}`.replace(/[ #+\-&|!(){}\]^"~*?:\\]/g, "\\$&") + value = `${value}`.replace(/[ #+\-&|!{}\]^"~*?:\\]/g, "\\$&") } // Wrap in quotes if (hasVersion && wrap) { @@ -212,6 +219,19 @@ class QueryBuilder { build(this.query.notEmpty, key => `${key}:["" TO *]`) } + if (this.query.contains) { + build(this.query.contains, (key, value) => { + if (!value) { + return null + } + let opts = [] + value.forEach(val => opts.push(`${key}.${val}:${builder.preprocess(val, allPreProcessingOpts)}`)) + const joined = opts.join(' AND ') + return joined + }) + + } + return query } @@ -253,6 +273,7 @@ const runQuery = async (url, body) => { method: "POST", }) const json = await response.json() + console.log(json) let output = { rows: [], } diff --git a/packages/server/src/db/views/staticViews.js b/packages/server/src/db/views/staticViews.js index 23f320d7eb..35ccbd21b2 100644 --- a/packages/server/src/db/views/staticViews.js +++ b/packages/server/src/db/views/staticViews.js @@ -94,12 +94,18 @@ exports.createAllSearchIndex = async appId => { await searchIndex( appId, SearchIndexes.ROWS, - function (doc) { + function (doc) { function idx(input, prev) { for (let key of Object.keys(input)) { let idxKey = prev != null ? `${prev}.${key}` : key idxKey = idxKey.replace(/ /, "_") - if (key === "_id" || key === "_rev" || input[key] == null) { + + + if (Array.isArray(input[key])) { + for (val in input[key]) { + index(`${idxKey}.${input[key][v]}`, input[key][v], { store: true }); + } + } else if (key === "_id" || key === "_rev" || input[key] == null) { continue } if (typeof input[key] === "string") { diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 8b2bb863a5..948ebc91d8 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -2036,11 +2036,7 @@ "type": "boolean", "label": "Autocomplete", "key": "autocomplete", - "defaultValue": false, - "dependsOn": { - "setting": "optionsType", - "value": "select" - } + "defaultValue": false }, { "type": "boolean", diff --git a/packages/standard-components/src/forms/MultiFieldSelect.svelte b/packages/standard-components/src/forms/MultiFieldSelect.svelte index d44f471304..4e6777d96c 100644 --- a/packages/standard-components/src/forms/MultiFieldSelect.svelte +++ b/packages/standard-components/src/forms/MultiFieldSelect.svelte @@ -1,7 +1,7 @@ - + x : x => x.label} + getOptionValue={flatOptions ? x => x : x => x.value} + {placeholder} + {options} + /> diff --git a/packages/standard-components/src/forms/OptionsField.svelte b/packages/standard-components/src/forms/OptionsField.svelte index b43ddb9f36..e240c8f23d 100644 --- a/packages/standard-components/src/forms/OptionsField.svelte +++ b/packages/standard-components/src/forms/OptionsField.svelte @@ -1,7 +1,7 @@ { + const isArray = fieldSchema?.type === "array" + // Take options from schema + if (optionsSource == null || optionsSource === "schema") { + if (isArray) { + return fieldSchema?.constraints?.inclusion[0] ?? [] + } + return fieldSchema?.constraints?.inclusion ?? [] + } + + if (optionsSource === "provider" && isArray) { + let optionsSet = {} + + dataProvider?.rows?.forEach(row => { + const value = row?.[valueColumn] + if (value) { + const label = row[labelColumn] || value + optionsSet[value] = { value, label } + } + }) + return Object.values(optionsSet) + } + + + + // Extract options from data provider + if (optionsSource === "provider" && valueColumn) { + let optionsSet = {} + dataProvider?.rows?.forEach(row => { + const value = row?.[valueColumn] + if (value) { + const label = row[labelColumn] || value + optionsSet[value] = { value, label } + } + }) + return Object.values(optionsSet) + } + + // Extract custom options + if (optionsSource === "custom" && customOptions) { + return customOptions + } + + return [] + } diff --git a/packages/standard-components/src/lucene.js b/packages/standard-components/src/lucene.js index 50aae1f32c..f132086aa2 100644 --- a/packages/standard-components/src/lucene.js +++ b/packages/standard-components/src/lucene.js @@ -11,6 +11,7 @@ export const buildLuceneQuery = filter => { notEqual: {}, empty: {}, notEmpty: {}, + contains: {} } if (Array.isArray(filter)) { filter.forEach(expression => { From 700caa7e347c5424bc259b99f6eee148196c7602 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 24 Aug 2021 20:04:28 +0100 Subject: [PATCH 32/58] making sure relationships for autocolumns are created when uploading a CSV --- packages/server/src/api/controllers/table/utils.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/server/src/api/controllers/table/utils.js b/packages/server/src/api/controllers/table/utils.js index 78dae60ab1..70e423ca82 100644 --- a/packages/server/src/api/controllers/table/utils.js +++ b/packages/server/src/api/controllers/table/utils.js @@ -1,4 +1,5 @@ const CouchDB = require("../../../db") +const linkRows = require("../../../db/linkedRows") const csvParser = require("../../../utilities/csvParser") const { getRowParams, @@ -74,6 +75,15 @@ exports.handleDataImport = async (appId, user, table, dataImport) => { const processed = inputProcessing(user, table, row) table = processed.table row = processed.row + // make sure link rows are up to date + row = await linkRows.updateLinks({ + appId, + eventType: linkRows.EventType.ROW_SAVE, + row, + tableId: row.tableId, + table, + }) + for (let [fieldName, schema] of Object.entries(table.schema)) { // check whether the options need to be updated for inclusion as part of the data import if ( From 8d4f3c810006a2893a88e1b01eae4e63f792d025 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 25 Aug 2021 09:53:43 +0100 Subject: [PATCH 33/58] Add size option back to forms --- packages/standard-components/manifest.json | 15 +++++++++++++++ .../src/forms/InnerForm.svelte | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index 95f41a85ef..f6eb99a02d 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -1725,6 +1725,21 @@ "label": "Custom" } }, + { + "type": "select", + "label": "Size", + "key": "size", + "options": [ + { + "label": "Medium", + "value": "spectrum--medium" + }, { + "label": "Large", + "value": "spectrum--large" + } + ], + "defaultValue": "spectrum--medium" + }, { "type": "boolean", "label": "Disabled", diff --git a/packages/standard-components/src/forms/InnerForm.svelte b/packages/standard-components/src/forms/InnerForm.svelte index eea2e6ebf0..b35b5bfcfa 100644 --- a/packages/standard-components/src/forms/InnerForm.svelte +++ b/packages/standard-components/src/forms/InnerForm.svelte @@ -7,6 +7,7 @@ export let dataSource export let disabled = false export let initialValues + export let size const component = getContext("component") const { styleable, API, Provider, ActionTypes } = getContext("sdk") @@ -231,7 +232,7 @@ {actions} data={{ ...$formState.values, tableId: dataSource?.tableId }} > -
+
{#if loaded} {/if} From c6140152e6c23c7a51b13547cffab3f77dc46d4e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 25 Aug 2021 09:56:42 +0100 Subject: [PATCH 34/58] Add size setting back to table --- packages/standard-components/manifest.json | 16 ++++++++++++++++ .../standard-components/src/table/Table.svelte | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index f6eb99a02d..1a8bbf5f90 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -2325,6 +2325,22 @@ "dependsOn": "dataProvider", "placeholder": "All columns" }, + { + "type": "select", + "label": "Size", + "key": "size", + "defaultValue": "spectrum--medium", + "options": [ + { + "label": "Medium", + "value": "spectrum--medium" + }, + { + "label": "Large", + "value": "spectrum--large" + } + ] + }, { "type": "boolean", "label": "Quiet", diff --git a/packages/standard-components/src/table/Table.svelte b/packages/standard-components/src/table/Table.svelte index 3620146ced..ba9f3aae97 100644 --- a/packages/standard-components/src/table/Table.svelte +++ b/packages/standard-components/src/table/Table.svelte @@ -8,6 +8,7 @@ export let showAutoColumns export let rowCount export let quiet + export let size const component = getContext("component") const { styleable } = getContext("sdk") @@ -71,7 +72,7 @@ } -
+
Date: Wed, 25 Aug 2021 09:57:53 +0100 Subject: [PATCH 35/58] Update autoscreens to have size settings again --- .../src/builderStore/store/screenTemplates/newRowScreen.js | 1 + .../src/builderStore/store/screenTemplates/rowDetailScreen.js | 1 - .../src/builderStore/store/screenTemplates/rowListScreen.js | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js b/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js index b890d42d54..c2dffef4b6 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/newRowScreen.js @@ -43,6 +43,7 @@ const createScreen = table => { tableId: table._id, type: "table", }, + size: "spectrum--medium", }) const fieldGroup = new Component("@budibase/standard-components/fieldgroup") diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js index a1a1e17fd5..6065d938f1 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js @@ -100,7 +100,6 @@ const createScreen = table => { .instanceName("Form") .customProps({ actionType: "Update", - theme: "spectrum--lightest", size: "spectrum--medium", dataSource: { label: table.name, diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js index ccf1fceb29..188682ed3f 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js @@ -65,6 +65,7 @@ const createScreen = table => { tableId: table._id, type: "table", }, + size: "spectrum--medium", paginate: true, limit: 8, }) From 890dca13a946a988587d0412f210a8bab2644ac5 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Wed, 25 Aug 2021 12:05:49 +0000 Subject: [PATCH 36/58] v0.9.115 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index d190a75cf4..b00fa15ba4 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.114", + "version": "0.9.115", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 8b6b3434b7..fa56e927f1 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.114", + "version": "0.9.115", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index e41d95563a..c80e7ed349 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.114", + "version": "0.9.115", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index d0a765f209..fc2a50e8d8 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.114", + "version": "0.9.115", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.114", - "@budibase/client": "^0.9.114", + "@budibase/bbui": "^0.9.115", + "@budibase/client": "^0.9.115", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.114", + "@budibase/string-templates": "^0.9.115", "@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 8676c915bc..49473b8d8e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.114", + "version": "0.9.115", "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 c7976cc9cf..37c562368d 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.114", + "version": "0.9.115", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.114", - "@budibase/standard-components": "^0.9.114", - "@budibase/string-templates": "^0.9.114", + "@budibase/bbui": "^0.9.115", + "@budibase/standard-components": "^0.9.115", + "@budibase/string-templates": "^0.9.115", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index dacbbbc108..cd92eaabfa 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.114", + "version": "0.9.115", "description": "Budibase Web Server", "main": "src/index.js", "repository": { @@ -60,9 +60,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.114", - "@budibase/client": "^0.9.114", - "@budibase/string-templates": "^0.9.114", + "@budibase/auth": "^0.9.115", + "@budibase/client": "^0.9.115", + "@budibase/string-templates": "^0.9.115", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -115,7 +115,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.114", + "@budibase/standard-components": "^0.9.115", "@jest/test-sequencer": "^24.8.0", "@types/bull": "^3.15.1", "@types/jest": "^26.0.23", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index d586988f56..7f3780e127 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.114", + "version": "0.9.115", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.114", + "@budibase/bbui": "^0.9.115", "@spectrum-css/card": "^3.0.3", "@spectrum-css/link": "^3.1.3", "@spectrum-css/page": "^3.0.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index a3b6920231..7685401b77 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.114", + "version": "0.9.115", "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 65fb92ecc6..720ceb30a4 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.114", + "version": "0.9.115", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.114", - "@budibase/string-templates": "^0.9.114", + "@budibase/auth": "^0.9.115", + "@budibase/string-templates": "^0.9.115", "@koa/router": "^8.0.0", "@techpass/passport-openidconnect": "^0.3.0", "aws-sdk": "^2.811.0", From 05568295b5fb3086be03d01968b446f32490c272 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 25 Aug 2021 14:05:00 +0100 Subject: [PATCH 37/58] Add not contains option to lucene query builder --- .../DataTable/modals/CreateEditColumn.svelte | 1 - packages/builder/src/helpers/lucene.js | 7 +++++-- .../src/api/controllers/row/internalSearch.js | 21 ++++++++++++++++++- packages/standard-components/src/lucene.js | 3 ++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 3f3d28bf81..92edca2a08 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -86,7 +86,6 @@ let arr = field.constraints.inclusion let newArr = [] newArr.push(arr) - console.log(newArr) field.constraints.inclusion = newArr } tables.saveField({ diff --git a/packages/builder/src/helpers/lucene.js b/packages/builder/src/helpers/lucene.js index c9890d8d70..5488919c6d 100644 --- a/packages/builder/src/helpers/lucene.js +++ b/packages/builder/src/helpers/lucene.js @@ -35,7 +35,10 @@ export const OperatorOptions = { value: "contains", label: "Contains", }, - + NotContains: { + value: "notContains", + label: "Does Not Contain", + } } export const getValidOperatorsForType = type => { @@ -61,7 +64,7 @@ export const getValidOperatorsForType = type => { } else if (type === "options") { return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty] } else if (type === "array") { - return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.Contains] + return [Op.Contains, Op.NotContains] } else if (type === "boolean") { return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty] } else if (type === "longform") { diff --git a/packages/server/src/api/controllers/row/internalSearch.js b/packages/server/src/api/controllers/row/internalSearch.js index e2e7beee27..e4552ccaba 100644 --- a/packages/server/src/api/controllers/row/internalSearch.js +++ b/packages/server/src/api/controllers/row/internalSearch.js @@ -18,6 +18,7 @@ class QueryBuilder { empty: {}, notEmpty: {}, contains: {}, + notContains: {}, ...base, } this.limit = 50 @@ -110,6 +111,10 @@ class QueryBuilder { return this } + addNotContains(key, value) { + this.query.notContains[key] = value + return this + } /** * Preprocesses a value before going into a lucene search. @@ -232,6 +237,20 @@ class QueryBuilder { } + if (this.query.notContains) { + build(this.query.notContains, (key, value) => { + if (!value) { + return null + } + let opts = [] + value.forEach(val => opts.push(`!${key}.${val}:${builder.preprocess(val, allPreProcessingOpts)}`)) + const joined = opts.join(' AND ') + return joined + }) + + } + + return query } @@ -273,7 +292,7 @@ const runQuery = async (url, body) => { method: "POST", }) const json = await response.json() - console.log(json) + let output = { rows: [], } diff --git a/packages/standard-components/src/lucene.js b/packages/standard-components/src/lucene.js index f132086aa2..36f6026a06 100644 --- a/packages/standard-components/src/lucene.js +++ b/packages/standard-components/src/lucene.js @@ -11,7 +11,8 @@ export const buildLuceneQuery = filter => { notEqual: {}, empty: {}, notEmpty: {}, - contains: {} + contains: {}, + notContains: {}, } if (Array.isArray(filter)) { filter.forEach(expression => { From 12f56744c3836757fb69700424b77738f40662f4 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 25 Aug 2021 14:05:23 +0100 Subject: [PATCH 38/58] Add validation for array field --- .../ValidationEditor/ValidationDrawer.svelte | 9 +++++-- .../PropertyControls/componentSettings.js | 1 + packages/standard-components/manifest.json | 2 +- .../src/forms/MultiFieldSelect.svelte | 17 +++++++----- .../src/forms/validation.js | 27 ++++++++++++++++--- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte index b4da2e8e6e..e24a779b62 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte @@ -9,6 +9,7 @@ Body, Input, DatePicker, + Multiselect, } from "@budibase/bbui" import { currentAsset, selectedComponent } from "builderStore" import { findClosestMatchingComponent } from "builderStore/storeUtils" @@ -102,6 +103,11 @@ Constraints.MinLength, Constraints.MaxLength, ], + ["array"]: [ + Constraints.Required, + Constraints.MinLength, + Constraints.MaxLength, + ], } $: dataSourceSchema = getDataSourceSchema($currentAsset, $selectedComponent) @@ -109,7 +115,6 @@ $: schemaRules = parseRulesFromSchema(field, dataSourceSchema || {}) $: fieldType = type?.split("/")[1] || "string" $: constraintOptions = getConstraintsForType(fieldType) - const getConstraintsForType = type => { return ConstraintMap[type] } @@ -283,7 +288,7 @@ /> {:else} - {#if ["string", "number", "options", "longform"].includes(rule.type)} + {#if ["string", "number", "options", "longform", "array"].includes(rule.type)} - x : x => x.label} - getOptionValue={flatOptions ? x => x : x => x.value} - {placeholder} - {options} - /> + {#if fieldState} + x : x => x.label} + getOptionValue={flatOptions ? x => x : x => x.value} + id={$fieldState.fieldId} + disabled={$fieldState.disabled} + on:change={e => fieldApi.setValue(e.detail)} + {placeholder} + {options} + /> + {/if} diff --git a/packages/standard-components/src/forms/validation.js b/packages/standard-components/src/forms/validation.js index 30b6fd7ca7..6109d7e2cb 100644 --- a/packages/standard-components/src/forms/validation.js +++ b/packages/standard-components/src/forms/validation.js @@ -25,7 +25,7 @@ export const createValidatorFromConstraints = ( schemaConstraints.presence?.allowEmpty === false ) { rules.push({ - type: "string", + type: schemaConstraints.type == "array" ? "array" : "string", constraint: "required", error: "Required", }) @@ -63,7 +63,7 @@ export const createValidatorFromConstraints = ( } // Inclusion constraint - if (exists(schemaConstraints.inclusion)) { + if (!schemaConstraints.type == "array" ? exists(schemaConstraints.inclusion) : false) { const options = schemaConstraints.inclusion || [] rules.push({ type: "string", @@ -73,6 +73,18 @@ export const createValidatorFromConstraints = ( }) } + // Inclusion constraint + if (schemaConstraints.type == "array" ? exists(schemaConstraints.inclusion[0]) : false ) { + const options = schemaConstraints.inclusion[0] || [] + rules.push({ + type: "array", + constraint: "inclusion", + value: options, + error: "Invalid value", + }) + } + + // Date constraint if (exists(schemaConstraints.datetime?.earliest)) { const limit = schemaConstraints.datetime.earliest @@ -142,7 +154,7 @@ const evaluateRule = (rule, value) => { * in the same format. * @param value the value to parse * @param type the type to parse - * @returns {boolean|string|*|number|null} the parsed value, or null if invalid + * @returns {boolean|string|*|number|null|array} the parsed value, or null if invalid */ const parseType = (value, type) => { // Treat nulls or empty strings as null @@ -202,6 +214,13 @@ const parseType = (value, type) => { return value } + if (type === "array") { + if (!Array.isArray(value) || !value.length) { + return null + } + return value + } + // If some unknown type, treat as null to avoid breaking validators return null } @@ -239,7 +258,7 @@ const maxValueHandler = (value, rule) => { // Evaluates an inclusion constraint const inclusionHandler = (value, rule) => { - return value == null || rule.value.includes(value) + return value == null || rule.type == "array" ? rule.value.map(val => val === value) : rule.value.includes(value) } // Evaluates an equal constraint From 725b9bb6e2e30f72ceca60a1f67581f075e6f7f4 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 25 Aug 2021 15:49:04 +0100 Subject: [PATCH 39/58] Add more validation options for array field --- .../ValidationEditor/ValidationDrawer.svelte | 35 +++++-- packages/builder/src/helpers/lucene.js | 2 +- .../src/api/controllers/row/internalSearch.js | 19 ++-- packages/server/src/db/views/staticViews.js | 11 ++- .../src/forms/MultiFieldSelect.svelte | 8 +- .../src/forms/optionsParser.js | 96 +++++++++---------- .../src/forms/validation.js | 39 ++++++-- 7 files changed, 131 insertions(+), 79 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte index e24a779b62..64938fe75b 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ValidationEditor/ValidationDrawer.svelte @@ -9,13 +9,13 @@ Body, Input, DatePicker, - Multiselect, } from "@budibase/bbui" import { currentAsset, selectedComponent } from "builderStore" import { findClosestMatchingComponent } from "builderStore/storeUtils" import { getSchemaForDatasource } from "builderStore/dataBinding" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" import { generate } from "shortid" + import Multiselect from "../../../../../../../bbui/src/Form/Core/Multiselect.svelte" export let rules = [] export let bindings = [] @@ -58,14 +58,22 @@ label: "Must not match regex", value: "notRegex", }, - Contains: { + ContainsRowID: { label: "Must contain row ID", value: "contains", }, - NotContains: { + NotContainsRowID: { label: "Must not contain row ID", value: "notContains", }, + Contains: { + label: "Must contain one of", + value: "contains", + }, + NotContains: { + label: "Must not contain one of", + value: "notContains", + }, } const ConstraintMap = { ["string"]: [ @@ -98,8 +106,8 @@ ["attachment"]: [Constraints.Required], ["link"]: [ Constraints.Required, - Constraints.Contains, - Constraints.NotContains, + Constraints.ContainsRowID, + Constraints.NotContainsRowID, Constraints.MinLength, Constraints.MaxLength, ], @@ -107,6 +115,8 @@ Constraints.Required, Constraints.MinLength, Constraints.MaxLength, + Constraints.Contains, + Constraints.NotContains, ], } @@ -195,6 +205,7 @@ valueType: "Binding", type: fieldType, id: generate(), + value: fieldType == "array" ? [] : null, }, ] } @@ -280,7 +291,7 @@ disabled={rule.constraint === "required"} on:change={e => (rule.value = e.detail)} /> - {:else if ["maxLength", "minLength", "regex", "notRegex", "contains", "notContains"].includes(rule.constraint)} + {:else if ["maxLength", "minLength", "regex", "notRegex", "containsRowID", "notContainsRowID"].includes(rule.constraint)} {:else} - {#if ["string", "number", "options", "longform", "array"].includes(rule.type)} + {#if ["string", "number", "options", "longform"].includes(rule.type)} + {:else if rule.type === "array" && ["contains", "notContains"].includes(rule.constraint)} + x} + getOptionValue={x => x} + on:change={e => (rule.value = e.detail)} + bind:value={rule.value} + /> {:else if rule.type === "boolean"}