From ddc360a3da3a1c3c31a5e7b6cb7daebdbd7caaba Mon Sep 17 00:00:00 2001 From: mikesealey Date: Fri, 20 Sep 2024 11:54:26 +0100 Subject: [PATCH 01/14] tweaks sizing of multi-attachment preview in compact setting --- packages/bbui/src/Form/Core/Dropzone.svelte | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/bbui/src/Form/Core/Dropzone.svelte b/packages/bbui/src/Form/Core/Dropzone.svelte index c69bf0d6bb..e223d789a1 100644 --- a/packages/bbui/src/Form/Core/Dropzone.svelte +++ b/packages/bbui/src/Form/Core/Dropzone.svelte @@ -396,6 +396,10 @@ padding: 6px 10px; margin-bottom: 8px; } + + .compact .gallery > * { + max-height: 25px; + } .title { display: flex; flex-direction: row; From 4975ae7fef1b2bcac717a3706194743d51f0cf8b Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Fri, 20 Sep 2024 16:58:06 +0100 Subject: [PATCH 02/14] Extra test logging. --- .github/workflows/budibase_ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 4b9ebf1e5d..388f2000ed 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -186,6 +186,8 @@ jobs: - run: yarn --frozen-lockfile - name: Test server + env: + DEBUG: "testcontainers*" run: | if ${{ env.ONLY_AFFECTED_TASKS }}; then node scripts/run-affected.js --task=test --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} From da805b10ae576f23fd6d8d823d655a3d20382a49 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Fri, 20 Sep 2024 17:31:44 +0100 Subject: [PATCH 03/14] Set mssql SHA back to 2019. --- packages/server/datasource-sha.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/datasource-sha.env b/packages/server/datasource-sha.env index 61249d530c..9b935ed8eb 100644 --- a/packages/server/datasource-sha.env +++ b/packages/server/datasource-sha.env @@ -1,4 +1,4 @@ -MSSQL_SHA=sha256:3b913841850a4d57fcfcb798be06acc88ea0f2acc5418bc0c140a43e91c4a545 +MSSQL_SHA=sha256:c4369c38385eba011c10906dc8892425831275bb035d5ce69656da8e29de50d8 MYSQL_SHA=sha256:9de9d54fecee6253130e65154b930978b1fcc336bcc86dfd06e89b72a2588ebe POSTGRES_SHA=sha256:bd0d8e485d1aca439d39e5ea99b931160bd28d862e74c786f7508e9d0053090e MONGODB_SHA=sha256:afa36bca12295b5f9dae68a493c706113922bdab520e901bd5d6c9d7247a1d8d From 028d15911ee1d02d17382c7b127d2bbf61935114 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 23 Sep 2024 11:47:08 +0100 Subject: [PATCH 04/14] Revert "Set mssql SHA back to 2019." This reverts commit da805b10ae576f23fd6d8d823d655a3d20382a49. --- packages/server/datasource-sha.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/datasource-sha.env b/packages/server/datasource-sha.env index 9b935ed8eb..61249d530c 100644 --- a/packages/server/datasource-sha.env +++ b/packages/server/datasource-sha.env @@ -1,4 +1,4 @@ -MSSQL_SHA=sha256:c4369c38385eba011c10906dc8892425831275bb035d5ce69656da8e29de50d8 +MSSQL_SHA=sha256:3b913841850a4d57fcfcb798be06acc88ea0f2acc5418bc0c140a43e91c4a545 MYSQL_SHA=sha256:9de9d54fecee6253130e65154b930978b1fcc336bcc86dfd06e89b72a2588ebe POSTGRES_SHA=sha256:bd0d8e485d1aca439d39e5ea99b931160bd28d862e74c786f7508e9d0053090e MONGODB_SHA=sha256:afa36bca12295b5f9dae68a493c706113922bdab520e901bd5d6c9d7247a1d8d From 8a5a94338ad7b63d83288b73b24358f2a2a420de Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 23 Sep 2024 14:18:34 +0100 Subject: [PATCH 05/14] Remove extra logging. --- .github/workflows/budibase_ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 388f2000ed..4b9ebf1e5d 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -186,8 +186,6 @@ jobs: - run: yarn --frozen-lockfile - name: Test server - env: - DEBUG: "testcontainers*" run: | if ${{ env.ONLY_AFFECTED_TASKS }}; then node scripts/run-affected.js --task=test --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }} From 3e9ca562c598a7099ba9c18669b8d6cda8f37013 Mon Sep 17 00:00:00 2001 From: mikesealey Date: Tue, 24 Sep 2024 12:12:46 +0100 Subject: [PATCH 06/14] reworks changes based on feedback --- packages/bbui/src/Form/Core/Dropzone.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/bbui/src/Form/Core/Dropzone.svelte b/packages/bbui/src/Form/Core/Dropzone.svelte index e223d789a1..2922d88e7a 100644 --- a/packages/bbui/src/Form/Core/Dropzone.svelte +++ b/packages/bbui/src/Form/Core/Dropzone.svelte @@ -397,9 +397,10 @@ margin-bottom: 8px; } - .compact .gallery > * { - max-height: 25px; + .compact .placeholder { + height: fit-content; } + .title { display: flex; flex-direction: row; From d7d8284caf06b512b915c58c1e5d52cd56ebf6bc Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 24 Sep 2024 17:42:25 +0200 Subject: [PATCH 07/14] Add test --- .../src/api/routes/tests/viewV2.spec.ts | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index c4a39ae8a9..c34f4fb3ac 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -22,6 +22,7 @@ import { TableSchema, ViewFieldMetadata, RenameColumn, + FeatureFlag, } from "@budibase/types" import { generator, mocks } from "@budibase/backend-core/tests" import { DatabaseName, getDatasource } from "../../../integrations/tests/utils" @@ -2213,6 +2214,100 @@ describe.each([ }) ) }) + + describe("foreign relationship columns", () => { + const createMainTable = async ( + links: { + name: string + tableId: string + fk: string + }[] + ) => { + const table = await config.api.table.save( + saveTableRequest({ + schema: { title: { name: "title", type: FieldType.STRING } }, + }) + ) + await config.api.table.save({ + ...table, + schema: { + ...table.schema, + ...links.reduce((acc, c) => { + acc[c.name] = { + name: c.name, + relationshipType: RelationshipType.ONE_TO_MANY, + type: FieldType.LINK, + tableId: c.tableId, + fieldName: c.fk, + constraints: { type: "array" }, + } + return acc + }, {}), + }, + }) + return table + } + const createAuxTable = (schema: TableSchema) => + config.api.table.save( + saveTableRequest({ + primaryDisplay: "name", + schema: { + ...schema, + name: { name: "name", type: FieldType.STRING }, + }, + }) + ) + + it("returns squashed fields respecting the view config", async () => { + const auxTable = await createAuxTable({ + age: { name: "age", type: FieldType.NUMBER }, + }) + const table = await createMainTable([ + { name: "aux", tableId: auxTable._id!, fk: "fk_aux" }, + ]) + + const auxRow = await config.api.row.save(auxTable._id!, { + name: generator.name(), + age: generator.age(), + }) + const row = await config.api.row.save(table._id!, { + title: generator.word(), + aux: [auxRow], + }) + + const view = await config.api.viewV2.create({ + tableId: table._id!, + name: generator.guid(), + schema: { + title: { visible: true }, + aux: { + visible: true, + columns: { + name: { visible: false, readonly: false }, + age: { visible: true, readonly: true }, + }, + }, + }, + }) + + const response = await withCoreEnv( + { TENANT_FEATURE_FLAGS: `*:${FeatureFlag.ENRICHED_RELATIONSHIPS}` }, + () => config.api.viewV2.search(view.id) + ) + + expect(response.rows).toEqual([ + expect.objectContaining({ + aux: [ + { + _id: auxRow._id, + primaryDisplay: auxRow.name, + age: auxRow.age, + }, + ], + }), + ]) + }) + }) }) describe("permissions", () => { From 53b4634cffb48d254c7d4e1b5a91f4a61f017880 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 24 Sep 2024 17:51:05 +0200 Subject: [PATCH 08/14] Add enrichment tests --- .../src/api/routes/tests/viewV2.spec.ts | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index c34f4fb3ac..a2af95bee3 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -23,6 +23,7 @@ import { ViewFieldMetadata, RenameColumn, FeatureFlag, + BBReferenceFieldSubType, } from "@budibase/types" import { generator, mocks } from "@budibase/backend-core/tests" import { DatabaseName, getDatasource } from "../../../integrations/tests/utils" @@ -2270,7 +2271,7 @@ describe.each([ name: generator.name(), age: generator.age(), }) - const row = await config.api.row.save(table._id!, { + await config.api.row.save(table._id!, { title: generator.word(), aux: [auxRow], }) @@ -2307,6 +2308,69 @@ describe.each([ }), ]) }) + + it("enriches squashed fields", async () => { + const auxTable = await createAuxTable({ + user: { + name: "user", + type: FieldType.BB_REFERENCE_SINGLE, + subtype: BBReferenceFieldSubType.USER, + constraints: { presence: true }, + }, + }) + const table = await createMainTable([ + { name: "aux", tableId: auxTable._id!, fk: "fk_aux" }, + ]) + + const user = config.getUser() + const auxRow = await config.api.row.save(auxTable._id!, { + name: generator.name(), + user: user._id, + }) + await config.api.row.save(table._id!, { + title: generator.word(), + aux: [auxRow], + }) + + const view = await config.api.viewV2.create({ + tableId: table._id!, + name: generator.guid(), + schema: { + title: { visible: true }, + aux: { + visible: true, + columns: { + name: { visible: true, readonly: true }, + user: { visible: true, readonly: true }, + }, + }, + }, + }) + + const response = await withCoreEnv( + { TENANT_FEATURE_FLAGS: `*:${FeatureFlag.ENRICHED_RELATIONSHIPS}` }, + () => config.api.viewV2.search(view.id) + ) + + expect(response.rows).toEqual([ + expect.objectContaining({ + aux: [ + { + _id: auxRow._id, + primaryDisplay: auxRow.name, + name: auxRow.name, + user: { + _id: user._id, + email: user.email, + firstName: user.firstName, + lastName: user.lastName, + primaryDisplay: user.email, + }, + }, + ], + }), + ]) + }) }) }) From 7a7ce3dc629ed365a67cbdbae4d812d80ffc7440 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 24 Sep 2024 17:56:07 +0200 Subject: [PATCH 09/14] Fix --- packages/server/src/db/linkedRows/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/server/src/db/linkedRows/index.ts b/packages/server/src/db/linkedRows/index.ts index 2c8d1f77ac..c2b043785f 100644 --- a/packages/server/src/db/linkedRows/index.ts +++ b/packages/server/src/db/linkedRows/index.ts @@ -10,7 +10,7 @@ import flatten from "lodash/flatten" import { USER_METDATA_PREFIX } from "../utils" import partition from "lodash/partition" import { getGlobalUsersFromMetadata } from "../../utilities/global" -import { processFormulas } from "../../utilities/rowProcessor" +import { outputProcessing, processFormulas } from "../../utilities/rowProcessor" import { context, features } from "@budibase/backend-core" import { ContextUser, @@ -275,7 +275,7 @@ export async function squashLinks( // will populate this as we find them const linkedTables = [table] const isArray = Array.isArray(enriched) - const enrichedArray = !isArray ? [enriched] : enriched + const enrichedArray = !isArray ? [enriched as Row] : (enriched as Row[]) for (const row of enrichedArray) { // this only fetches the table if its not already in array const rowTable = await getLinkedTable(row.tableId!, linkedTables) @@ -292,6 +292,9 @@ export async function squashLinks( obj.primaryDisplay = getPrimaryDisplayValue(link, linkedTable) if (viewSchema[column]?.columns) { + const enrichedLink = await outputProcessing(linkedTable, link, { + squash: false, + }) const squashFields = Object.entries(viewSchema[column].columns) .filter(([columnName, viewColumnConfig]) => { const tableColumn = linkedTable.schema[columnName] @@ -312,7 +315,7 @@ export async function squashLinks( .map(([columnName]) => columnName) for (const relField of squashFields) { - obj[relField] = link[relField] + obj[relField] = enrichedLink[relField] } } @@ -321,5 +324,5 @@ export async function squashLinks( row[column] = newLinks } } - return isArray ? enrichedArray : enrichedArray[0] + return (isArray ? enrichedArray : enrichedArray[0]) as T } From 9ecb64a99229abc626012be597af55f54eba2e0a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 25 Sep 2024 10:32:58 +0200 Subject: [PATCH 10/14] Use sqs flag correctly on test --- packages/server/src/api/routes/tests/viewV2.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index a2af95bee3..a47d6dd828 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -2291,8 +2291,17 @@ describe.each([ }, }) + const flags = [`*:${FeatureFlag.ENRICHED_RELATIONSHIPS}`] + if (isLucene) { + flags.push("*:!SQS") + } else if (isSqs) { + flags.push("*:SQS") + } + const response = await withCoreEnv( - { TENANT_FEATURE_FLAGS: `*:${FeatureFlag.ENRICHED_RELATIONSHIPS}` }, + { + TENANT_FEATURE_FLAGS: flags.join(","), + }, () => config.api.viewV2.search(view.id) ) From 7072244f31a165a0b3af80bae55922b725e6d13a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 25 Sep 2024 12:44:30 +0200 Subject: [PATCH 11/14] Fix --- .../src/api/routes/tests/viewV2.spec.ts | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index a47d6dd828..e38e4c2ed5 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -34,6 +34,7 @@ import { roles, withEnv as withCoreEnv, setEnv as setCoreEnv, + env, } from "@budibase/backend-core" import sdk from "../../../sdk" @@ -696,22 +697,23 @@ describe.each([ ) }) - it("cannot update views v1", async () => { - const viewV1 = await config.api.legacyView.save({ - tableId: table._id!, - name: generator.guid(), - filters: [], - schema: {}, - }) + isInternal && + it("cannot update views v1", async () => { + const viewV1 = await config.api.legacyView.save({ + tableId: table._id!, + name: generator.guid(), + filters: [], + schema: {}, + }) - await config.api.viewV2.update(viewV1 as unknown as ViewV2, { - status: 400, - body: { - message: "Only views V2 can be updated", + await config.api.viewV2.update(viewV1 as unknown as ViewV2, { status: 400, - }, + body: { + message: "Only views V2 can be updated", + status: 400, + }, + }) }) - }) it("cannot update the a view with unmatching ids between url and body", async () => { const anotherView = await config.api.viewV2.create({ @@ -2217,6 +2219,21 @@ describe.each([ }) describe("foreign relationship columns", () => { + let envCleanup: () => void + beforeAll(() => { + const flags = [`*:${FeatureFlag.ENRICHED_RELATIONSHIPS}`] + if (env.TENANT_FEATURE_FLAGS) { + flags.push(...env.TENANT_FEATURE_FLAGS.split(",")) + } + envCleanup = setCoreEnv({ + TENANT_FEATURE_FLAGS: flags.join(","), + }) + }) + + afterAll(() => { + envCleanup?.() + }) + const createMainTable = async ( links: { name: string @@ -2263,14 +2280,14 @@ describe.each([ const auxTable = await createAuxTable({ age: { name: "age", type: FieldType.NUMBER }, }) - const table = await createMainTable([ - { name: "aux", tableId: auxTable._id!, fk: "fk_aux" }, - ]) - const auxRow = await config.api.row.save(auxTable._id!, { name: generator.name(), age: generator.age(), }) + + const table = await createMainTable([ + { name: "aux", tableId: auxTable._id!, fk: "fk_aux" }, + ]) await config.api.row.save(table._id!, { title: generator.word(), aux: [auxRow], @@ -2291,20 +2308,7 @@ describe.each([ }, }) - const flags = [`*:${FeatureFlag.ENRICHED_RELATIONSHIPS}`] - if (isLucene) { - flags.push("*:!SQS") - } else if (isSqs) { - flags.push("*:SQS") - } - - const response = await withCoreEnv( - { - TENANT_FEATURE_FLAGS: flags.join(","), - }, - () => config.api.viewV2.search(view.id) - ) - + const response = await config.api.viewV2.search(view.id) expect(response.rows).toEqual([ expect.objectContaining({ aux: [ @@ -2356,10 +2360,7 @@ describe.each([ }, }) - const response = await withCoreEnv( - { TENANT_FEATURE_FLAGS: `*:${FeatureFlag.ENRICHED_RELATIONSHIPS}` }, - () => config.api.viewV2.search(view.id) - ) + const response = await config.api.viewV2.search(view.id) expect(response.rows).toEqual([ expect.objectContaining({ From 40d1d48ddf18af0364f2ec0a284591051e26c8a3 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 25 Sep 2024 14:46:16 +0100 Subject: [PATCH 12/14] Increase PostHog flag polling interval to 3 minutes. --- packages/backend-core/src/features/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/backend-core/src/features/index.ts b/packages/backend-core/src/features/index.ts index 0765d09036..6ac9749b27 100644 --- a/packages/backend-core/src/features/index.ts +++ b/packages/backend-core/src/features/index.ts @@ -3,6 +3,7 @@ import * as context from "../context" import { PostHog, PostHogOptions } from "posthog-node" import { FeatureFlag, IdentityType, UserCtx } from "@budibase/types" import tracer from "dd-trace" +import { Duration } from "../utils" let posthog: PostHog | undefined export function init(opts?: PostHogOptions) { @@ -16,6 +17,7 @@ export function init(opts?: PostHogOptions) { posthog = new PostHog(env.POSTHOG_TOKEN, { host: env.POSTHOG_API_HOST, personalApiKey: env.POSTHOG_PERSONAL_TOKEN, + featureFlagsPollingInterval: Duration.fromMinutes(3).toMs(), ...opts, }) } else { From f737aa9826300d424d73f4b9b250a35e7a6f75d7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 25 Sep 2024 16:12:17 +0100 Subject: [PATCH 13/14] Updating account portal submodule. --- packages/account-portal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account-portal b/packages/account-portal index 905773d708..558a32dfd1 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit 905773d70854a43c6ef2461c7a49671bff56fedc +Subproject commit 558a32dfd1f55bd894804a503e7e1090937df88c From 075be10f44d3b80bb0c31441c6eb6b100233209b Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 25 Sep 2024 15:33:38 +0000 Subject: [PATCH 14/14] Bump version to 2.32.8 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 272a1dd0c6..10d36c9eaf 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.32.7", + "version": "2.32.8", "npmClient": "yarn", "packages": [ "packages/*",