From 0912720f1966c321dbe9ab3e19ed103c6b800dd1 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 2 Oct 2023 15:43:32 +0100 Subject: [PATCH 01/63] Quick fix for built PKG CLI version, make sure prebuilds are loaded correctly. --- packages/cli/src/prebuilds.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/prebuilds.ts b/packages/cli/src/prebuilds.ts index 21f3042274..561f9be474 100644 --- a/packages/cli/src/prebuilds.ts +++ b/packages/cli/src/prebuilds.ts @@ -12,6 +12,10 @@ if (!process.argv[0].includes("node")) { checkForBinaries() } +function localPrebuildPath() { + return join(process.execPath, "..", PREBUILDS) +} + function checkForBinaries() { const readDir = join(__filename, "..", "..", "..", "cli", PREBUILDS, ARCH) if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) { @@ -19,17 +23,21 @@ function checkForBinaries() { } const natives = fs.readdirSync(readDir) if (fs.existsSync(readDir)) { - const writePath = join(process.execPath, PREBUILDS, ARCH) + const writePath = join(localPrebuildPath(), ARCH) fs.mkdirSync(writePath, { recursive: true }) for (let native of natives) { const filename = `${native.split(".fake")[0]}.node` fs.cpSync(join(readDir, native), join(writePath, filename)) } - console.log("copied something") } } function cleanup(evt?: number) { + // cleanup prebuilds first + const path = localPrebuildPath() + if (fs.existsSync(path)) { + fs.rmSync(path, { recursive: true }) + } if (evt && !isNaN(evt)) { return } @@ -41,10 +49,6 @@ function cleanup(evt?: number) { ) console.error(error(evt)) } - const path = join(process.execPath, PREBUILDS) - if (fs.existsSync(path)) { - fs.rmSync(path, { recursive: true }) - } } const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"] From b291633c79ab0ab1b1a032f39449c62eb4f693f4 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Tue, 3 Oct 2023 10:19:19 +0100 Subject: [PATCH 02/63] Don't use DrawerBindableSlot in test modal (#11959) --- .../automation/SetupPanel/RowSelector.svelte | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index c3097f3072..289f2e20be 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -110,20 +110,7 @@
{#each schemaFields as [field, schema]} {#if !schema.autocolumn && schema.type !== "attachment"} - onChange(e, field)} - {bindings} - allowJS={true} - updateOnChange={false} - drawerLeft="260px" - > + {#if isTestModal} - + {:else} + onChange(e, field)} + {bindings} + allowJS={true} + updateOnChange={false} + drawerLeft="260px" + > + + + {/if} {/if} {#if isUpdateRow && schema.type === "link"}
From f15ae4a69e635219c29979592e505a1f807b6e3d Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 3 Oct 2023 09:19:40 +0000 Subject: [PATCH 03/63] Bump version to 2.11.5 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 9f8538dfb0..9db24b9056 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.11.4", + "version": "2.11.5", "npmClient": "yarn", "packages": [ "packages/*" From af924ae4a26490d268c6a80bccd4888c6264a93b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 12:01:15 +0200 Subject: [PATCH 04/63] Use types --- packages/shared-core/src/filters.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 2cd6fa8c13..ce03503882 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -44,21 +44,21 @@ export const getValidOperatorsForType = ( value: string label: string }[] = [] - if (type === "string") { + if (type === FieldType.STRING) { ops = stringOps - } else if (type === "number" || type === "bigint") { + } else if (type === FieldType.NUMBER || type === FieldType.BIGINT) { ops = numOps - } else if (type === "options") { + } else if (type === FieldType.OPTIONS) { ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In] - } else if (type === "array") { + } else if (type === FieldType.ARRAY) { ops = [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty, Op.ContainsAny] - } else if (type === "boolean") { + } else if (type === FieldType.BOOLEAN) { ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty] - } else if (type === "longform") { + } else if (type === FieldType.LONGFORM) { ops = stringOps - } else if (type === "datetime") { + } else if (type === FieldType.DATETIME) { ops = numOps - } else if (type === "formula") { + } else if (type === FieldType.FORMULA) { ops = stringOps.concat([Op.MoreThan, Op.LessThan]) } From 8a8cc7773db5cc351609a19f89d8876ff45b9d3c Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 3 Oct 2023 10:35:05 +0000 Subject: [PATCH 05/63] Bump version to 2.11.6 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 9db24b9056..ff74792a2d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.11.5", + "version": "2.11.6", "npmClient": "yarn", "packages": [ "packages/*" From 3b937483766cf95503bdad8069154f2524aeac8b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 12:46:06 +0200 Subject: [PATCH 06/63] Filter user (single) UI --- .../controls/FilterEditor/FilterDrawer.svelte | 4 +++ .../controls/FilterEditor/FilterUsers.svelte | 28 +++++++++++++++++++ packages/shared-core/src/filters.ts | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index ef8699824e..513450b7ae 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -17,7 +17,9 @@ import { generate } from "shortid" import { LuceneUtils, Constants } from "@budibase/frontend-core" import { getFields } from "helpers/searchFields" + import { FieldType } from "@budibase/types" import { createEventDispatcher, onMount } from "svelte" + import FilterUsers from "./FilterUsers.svelte" export let schemaFields export let filters = [] @@ -285,6 +287,8 @@ timeOnly={getSchema(filter)?.timeOnly} bind:value={filter.value} /> + {:else if filter.type === FieldType.BB_REFERENCE} + {:else} {/if} diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte new file mode 100644 index 0000000000..56f23b9bef --- /dev/null +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte @@ -0,0 +1,28 @@ + + + option.email} getOptionValue={option => option._id} From 0702bc6c336758ad95ff0c5f49027c533f426aca Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 13:10:53 +0200 Subject: [PATCH 08/63] Sanity filter on change --- .../controls/FilterEditor/FilterUsers.svelte | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte index e776d87d56..ef3046eaf3 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte @@ -5,6 +5,7 @@ import { API } from "api" export let value = null + export let multiple = false $: fetch = fetchData({ API, @@ -17,11 +18,21 @@ }) $: options = $fetch.rows + + function onChange(e) { + const val = e.detail + if (!val) { + value = val + } else { + value = Array.isArray(val) ? val : [val] + } + } Date: Tue, 3 Oct 2023 13:19:28 +0200 Subject: [PATCH 10/63] Change filters --- packages/shared-core/src/filters.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 6ab8ce623e..57add48ebd 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -61,7 +61,15 @@ export const getValidOperatorsForType = ( } else if (type === FieldType.FORMULA) { ops = stringOps.concat([Op.MoreThan, Op.LessThan]) } else if (type === FieldType.BB_REFERENCE) { - ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In] + ops = [ + Op.Equals, + Op.NotEquals, + Op.Empty, + Op.NotEmpty, + Op.Contains, + Op.NotContains, + Op.ContainsAny, + ] } // Only allow equal/not equal for _id in SQL tables From 2367ceeb8749d3392e080ad6f8313d8b4234961b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 13:25:56 +0200 Subject: [PATCH 11/63] Disable when noValue --- .../settings/controls/FilterEditor/FilterDrawer.svelte | 5 ++++- .../design/settings/controls/FilterEditor/FilterUsers.svelte | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index c73c916a4f..48e8e504c2 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -288,7 +288,10 @@ bind:value={filter.value} /> {:else if filter.type === FieldType.BB_REFERENCE} - + {:else} {/if} diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte index 2d363add41..2d804ce189 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterUsers.svelte @@ -5,6 +5,7 @@ import { API } from "api" export let value = null + export let disabled export let multiple = false $: fetch = fetchData({ @@ -38,4 +39,5 @@ {options} getOptionLabel={option => option.email} getOptionValue={option => option._id} + {disabled} /> From 0834d33f9a990288447e471241e1f291aba5c431 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 13:43:42 +0200 Subject: [PATCH 12/63] Remove none array operators --- .../controls/FilterEditor/FilterDrawer.svelte | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index 48e8e504c2..bc2511779c 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -20,6 +20,7 @@ import { FieldType } from "@budibase/types" import { createEventDispatcher, onMount } from "svelte" import FilterUsers from "./FilterUsers.svelte" + import { RelationshipType } from "constants/backend" export let schemaFields export let filters = [] @@ -31,7 +32,6 @@ const dispatch = createEventDispatcher() const { OperatorOptions } = Constants - const { getValidOperatorsForType } = LuceneUtils const KeyedFieldRegex = /\d[0-9]*:/g const behaviourOptions = [ { value: "and", label: "Match all filters" }, @@ -133,11 +133,7 @@ const santizeOperator = filter => { // Ensure a valid operator is selected - const operators = getValidOperatorsForType( - filter.type, - filter.field, - datasource - ).map(x => x.value) + const operators = getValidOperatorsForType(filter).map(x => x.value) if (!operators.includes(filter.operator)) { filter.operator = operators[0] ?? OperatorOptions.Equals.value } @@ -186,6 +182,30 @@ const schema = enrichedSchemaFields.find(x => x.name === field) return schema?.constraints?.inclusion || [] } + + const getValidOperatorsForType = filter => { + let operators = LuceneUtils.getValidOperatorsForType( + filter.type, + filter.field, + datasource + ) + + const fieldSchema = getSchema(filter) + if ( + fieldSchema.type === FieldType.BB_REFERENCE && + fieldSchema.relationshipType !== RelationshipType.MANY_TO_MANY + ) { + operators = operators.filter( + o => + ![ + OperatorOptions.Contains.value, + OperatorOptions.NotContains.value, + ].includes(o.value) + ) + } + + return operators + } @@ -230,11 +250,7 @@ /> Date: Tue, 3 Oct 2023 14:05:25 +0200 Subject: [PATCH 14/63] Allow selecting many for many-to-many --- .../settings/controls/FilterEditor/FilterDrawer.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index 7ed7252af0..dca6cd9294 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -306,8 +306,9 @@ {:else if filter.type === FieldType.BB_REFERENCE} {:else} From c84d2449f2f306e7859bf868f0eda5178518f367 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 14:26:12 +0200 Subject: [PATCH 15/63] Smarter getValidOperatorsForType --- .../controls/FilterEditor/FilterDrawer.svelte | 26 ++++++++--------- packages/shared-core/src/filters.ts | 28 +++++++++++-------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index dca6cd9294..5d56b131b0 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -184,26 +184,22 @@ } const getValidOperatorsForType = filter => { + const fieldSchema = getSchema(filter) + const type = + fieldSchema.type !== FieldType.BB_REFERENCE + ? field.type + : { + type: fieldSchema.type, + multiple: + fieldSchema.relationshipType === RelationshipType.MANY_TO_MANY, + } + let operators = LuceneUtils.getValidOperatorsForType( - filter.type, + type, filter.field, datasource ) - const fieldSchema = getSchema(filter) - if ( - fieldSchema.type === FieldType.BB_REFERENCE && - fieldSchema.relationshipType !== RelationshipType.MANY_TO_MANY - ) { - operators = operators.filter( - o => - ![ - OperatorOptions.Contains.value, - OperatorOptions.NotContains.value, - ].includes(o.value) - ) - } - return operators } diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 57add48ebd..7ed2a9f49a 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -12,12 +12,22 @@ import { deepGet } from "./helpers" const HBS_REGEX = /{{([^{].*?)}}/g +type RequestedFieldType = + | Exclude + | { type: FieldType.BB_REFERENCE; multiple: boolean } + +export function isFieldType( + r: RequestedFieldType +): r is Exclude { + return typeof r === "string" && Object.values(FieldType).includes(r) +} + /** * Returns the valid operator options for a certain data type * @param type the data type */ export const getValidOperatorsForType = ( - type: FieldType, + type: RequestedFieldType, field: string, datasource: Datasource & { tableId: any } // TODO: is this table id ever populated? ) => { @@ -60,16 +70,12 @@ export const getValidOperatorsForType = ( ops = numOps } else if (type === FieldType.FORMULA) { ops = stringOps.concat([Op.MoreThan, Op.LessThan]) - } else if (type === FieldType.BB_REFERENCE) { - ops = [ - Op.Equals, - Op.NotEquals, - Op.Empty, - Op.NotEmpty, - Op.Contains, - Op.NotContains, - Op.ContainsAny, - ] + } else if (!isFieldType(type) && type.type === FieldType.BB_REFERENCE) { + if (type.multiple) { + ops = [Op.Contains, Op.NotContains, Op.ContainsAny, Op.Empty, Op.NotEmpty] + } else { + ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.ContainsAny] + } } // Only allow equal/not equal for _id in SQL tables From 28d5fe37deebcc47b32a8f1a5d9d909e736b7d56 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 15:26:41 +0200 Subject: [PATCH 16/63] Fix postgres docker-compose integration to 15 --- .../server/scripts/integrations/postgres/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/scripts/integrations/postgres/docker-compose.yml b/packages/server/scripts/integrations/postgres/docker-compose.yml index d682ad7361..88efd0301d 100644 --- a/packages/server/scripts/integrations/postgres/docker-compose.yml +++ b/packages/server/scripts/integrations/postgres/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: db: container_name: postgres - image: postgres + image: postgres:15 restart: unless-stopped environment: POSTGRES_USER: root @@ -25,4 +25,4 @@ services: - "5050:80" volumes: - pg_data: + pg_data: From 0053103974e56416b8809ddb2285e40594ae5426 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 15:41:00 +0200 Subject: [PATCH 17/63] Fix external --- .../design/settings/controls/FilterEditor/FilterDrawer.svelte | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index 5d56b131b0..32409844be 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -185,6 +185,10 @@ const getValidOperatorsForType = filter => { const fieldSchema = getSchema(filter) + if (!fieldSchema) { + return [] + } + const type = fieldSchema.type !== FieldType.BB_REFERENCE ? field.type From dbd5f7a134eea3e2c95271fcc9e9ecb3de9a1262 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 16:58:39 +0200 Subject: [PATCH 18/63] In instead of ContainsAny --- packages/shared-core/src/filters.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 7ed2a9f49a..c851d11079 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -74,7 +74,7 @@ export const getValidOperatorsForType = ( if (type.multiple) { ops = [Op.Contains, Op.NotContains, Op.ContainsAny, Op.Empty, Op.NotEmpty] } else { - ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.ContainsAny] + ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In] } } From 8ebf473ab211800adb353cbd730c2ceecf07dc38 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 3 Oct 2023 16:58:49 +0200 Subject: [PATCH 19/63] Disable multiple users for now --- .../backend/DataTable/modals/CreateEditColumn.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index c67ce67d57..8233278e58 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -660,7 +660,8 @@ >Open schema editor {:else if editableColumn.type === USER_REFRENCE_TYPE} - + {/if} {#if editableColumn.type === AUTO_TYPE || editableColumn.autocolumn}