From b67162baa518e4bdeedfaddcc490e63f93b3b02d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 18 Nov 2024 10:44:50 +0100 Subject: [PATCH 1/6] Clean tests --- .../server/src/api/routes/tests/row.spec.ts | 80 +------------------ .../src/api/routes/tests/viewV2.spec.ts | 11 --- 2 files changed, 1 insertion(+), 90 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index f2d2b73055..6cb7def670 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -9,13 +9,7 @@ import { import tk from "timekeeper" import emitter from "../../../../src/events" import { outputProcessing } from "../../../utilities/rowProcessor" -import { - context, - InternalTable, - tenancy, - features, - utils, -} from "@budibase/backend-core" +import { context, InternalTable, tenancy, utils } from "@budibase/backend-core" import { quotas } from "@budibase/pro" import { AIOperationEnum, @@ -2864,13 +2858,7 @@ describe.each([ let auxData: Row[] = [] - let flagCleanup: (() => void) | undefined - beforeAll(async () => { - flagCleanup = features.testutils.setFeatureFlags("*", { - ENRICHED_RELATIONSHIPS: true, - }) - const aux2Table = await config.api.table.save(saveTableRequest()) const aux2Data = await config.api.row.save(aux2Table._id!, {}) @@ -3017,10 +3005,6 @@ describe.each([ viewId = view.id }) - afterAll(() => { - flagCleanup?.() - }) - const testScenarios: [string, (row: Row) => Promise | Row][] = [ ["get row", (row: Row) => config.api.row.get(viewId, row._id!)], [ @@ -3093,68 +3077,6 @@ describe.each([ } ) - it.each(testScenarios)( - "does not enrich relationships when not enabled (via %s)", - async (__, retrieveDelegate) => { - await features.testutils.withFeatureFlags( - "*", - { - ENRICHED_RELATIONSHIPS: false, - }, - async () => { - const otherRows = _.sampleSize(auxData, 5) - - const row = await config.api.row.save(viewId, { - title: generator.word(), - relWithNoSchema: [otherRows[0]], - relWithEmptySchema: [otherRows[1]], - relWithFullSchema: [otherRows[2]], - relWithHalfSchema: [otherRows[3]], - relWithIllegalSchema: [otherRows[4]], - }) - - const retrieved = await retrieveDelegate(row) - - expect(retrieved).toEqual( - expect.objectContaining({ - title: row.title, - relWithNoSchema: [ - { - _id: otherRows[0]._id, - primaryDisplay: otherRows[0].name, - }, - ], - relWithEmptySchema: [ - { - _id: otherRows[1]._id, - primaryDisplay: otherRows[1].name, - }, - ], - relWithFullSchema: [ - { - _id: otherRows[2]._id, - primaryDisplay: otherRows[2].name, - }, - ], - relWithHalfSchema: [ - { - _id: otherRows[3]._id, - primaryDisplay: otherRows[3].name, - }, - ], - relWithIllegalSchema: [ - { - _id: otherRows[4]._id, - primaryDisplay: otherRows[4].name, - }, - ], - }) - ) - } - ) - } - ) - it.each([ [ "from table fetch", diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 908a924623..7b9f85ac74 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -3265,17 +3265,6 @@ describe.each([ }) describe("foreign relationship columns", () => { - let envCleanup: () => void - beforeAll(() => { - envCleanup = features.testutils.setFeatureFlags("*", { - ENRICHED_RELATIONSHIPS: true, - }) - }) - - afterAll(() => { - envCleanup?.() - }) - const createMainTable = async ( links: { name: string From f859441efeedc12583ff5fc2b5157130dd5e1aee Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 18 Nov 2024 10:45:04 +0100 Subject: [PATCH 2/6] Clean usages from frontend --- .../DataTable/buttons/grid/GridColumnsSettingButton.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte index 7ab84ba039..b36e896e27 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte @@ -48,7 +48,7 @@ From f1483473d1432f927017d0c217d6198de562f761 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 18 Nov 2024 10:45:45 +0100 Subject: [PATCH 3/6] Cleanups --- packages/backend-core/src/features/features.ts | 1 - packages/server/src/api/routes/tests/viewV2.spec.ts | 2 +- packages/server/src/db/linkedRows/index.ts | 11 ++--------- packages/types/src/sdk/featureFlag.ts | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/backend-core/src/features/features.ts b/packages/backend-core/src/features/features.ts index cd84cf7653..b3f016e88a 100644 --- a/packages/backend-core/src/features/features.ts +++ b/packages/backend-core/src/features/features.ts @@ -269,7 +269,6 @@ export class FlagSet, T extends { [key: string]: V }> { export const flags = new FlagSet({ [FeatureFlag.DEFAULT_VALUES]: Flag.boolean(true), [FeatureFlag.AUTOMATION_BRANCHING]: Flag.boolean(true), - [FeatureFlag.ENRICHED_RELATIONSHIPS]: Flag.boolean(true), [FeatureFlag.AI_CUSTOM_CONFIGS]: Flag.boolean(true), [FeatureFlag.BUDIBASE_AI]: Flag.boolean(true), }) diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 7b9f85ac74..652fb92b6f 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -40,7 +40,7 @@ import { generator, mocks } from "@budibase/backend-core/tests" import { DatabaseName, getDatasource } from "../../../integrations/tests/utils" import merge from "lodash/merge" import { quotas } from "@budibase/pro" -import { db, roles, features, context } from "@budibase/backend-core" +import { db, roles, context } from "@budibase/backend-core" describe.each([ ["sqs", undefined], diff --git a/packages/server/src/db/linkedRows/index.ts b/packages/server/src/db/linkedRows/index.ts index 73ac695878..06a4005061 100644 --- a/packages/server/src/db/linkedRows/index.ts +++ b/packages/server/src/db/linkedRows/index.ts @@ -14,11 +14,10 @@ import { coreOutputProcessing, processFormulas, } from "../../utilities/rowProcessor" -import { context, features } from "@budibase/backend-core" +import { context } from "@budibase/backend-core" import { ContextUser, EventType, - FeatureFlag, FieldType, LinkDocumentValue, Row, @@ -251,19 +250,13 @@ export async function squashLinks( source: Table | ViewV2, enriched: T ): Promise { - const allowRelationshipSchemas = await features.flags.isEnabled( - FeatureFlag.ENRICHED_RELATIONSHIPS - ) - let viewSchema: ViewV2Schema = {} if (sdk.views.isView(source)) { if (helpers.views.isCalculationView(source)) { return enriched } - if (allowRelationshipSchemas) { - viewSchema = source.schema || {} - } + viewSchema = source.schema || {} } let table: Table diff --git a/packages/types/src/sdk/featureFlag.ts b/packages/types/src/sdk/featureFlag.ts index 18dfd98319..64a7362e9f 100644 --- a/packages/types/src/sdk/featureFlag.ts +++ b/packages/types/src/sdk/featureFlag.ts @@ -4,7 +4,7 @@ export enum FeatureFlag { AUTOMATION_BRANCHING = "AUTOMATION_BRANCHING", AI_CUSTOM_CONFIGS = "AI_CUSTOM_CONFIGS", DEFAULT_VALUES = "DEFAULT_VALUES", - ENRICHED_RELATIONSHIPS = "ENRICHED_RELATIONSHIPS", + BUDIBASE_AI = "BUDIBASE_AI", } From 325dc8e703d7cb311a0881415dd806e6a65b437d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 18 Nov 2024 10:49:16 +0100 Subject: [PATCH 4/6] Lint --- .../DataTable/buttons/grid/GridColumnsSettingButton.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte index b36e896e27..6c387bfaec 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte @@ -10,8 +10,6 @@ import { getContext } from "svelte" import { ActionButton } from "@budibase/bbui" import ColumnsSettingContent from "./ColumnsSettingContent.svelte" - import { isEnabled } from "helpers/featureFlags" - import { FeatureFlag } from "@budibase/types" import DetailPopover from "components/common/DetailPopover.svelte" const { tableColumns, datasource } = getContext("grid") From 92609661886da25cc5b3a10a59aa77a5e202c573 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 18 Nov 2024 11:07:29 +0100 Subject: [PATCH 5/6] Remove canSetRelationshipSchemas flag from frontend --- .../DataTable/buttons/grid/ColumnsSettingContent.svelte | 7 ++++--- .../DataTable/buttons/grid/GridColumnsSettingButton.svelte | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/ColumnsSettingContent.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/ColumnsSettingContent.svelte index 85af8596a0..2cda43dda0 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/ColumnsSettingContent.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/ColumnsSettingContent.svelte @@ -11,7 +11,6 @@ export let disabledPermissions = [] export let columns export let fromRelationshipField - export let canSetRelationshipSchemas const { datasource, dispatch } = getContext("grid") @@ -129,6 +128,8 @@ } }) + $: hasLinkColumns = columns.some(c => c.schema.type === FieldType.LINK) + async function toggleColumn(column, permission) { const visible = permission !== FieldPermissions.HIDDEN const readonly = permission === FieldPermissions.READONLY @@ -184,7 +185,7 @@ value={columnToPermissionOptions(column)} options={column.options} /> - {#if canSetRelationshipSchemas && column.schema.type === FieldType.LINK && columnToPermissionOptions(column) !== FieldPermissions.HIDDEN} + {#if column.schema.type === FieldType.LINK && columnToPermissionOptions(column) !== FieldPermissions.HIDDEN}
{ @@ -203,7 +204,7 @@
-{#if canSetRelationshipSchemas} +{#if hasLinkColumns} (relationshipFieldName = null)} open={relationshipFieldName} diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte index 6c387bfaec..801abeaf9f 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte @@ -44,9 +44,5 @@ {text} - + From 120be557f4f5841078adf4b05436b5d078234a6d Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 18 Nov 2024 10:09:38 +0000 Subject: [PATCH 6/6] remove CSP from dev --- hosting/nginx.dev.conf | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/hosting/nginx.dev.conf b/hosting/nginx.dev.conf index e3d6d47287..f0a58a9a98 100644 --- a/hosting/nginx.dev.conf +++ b/hosting/nginx.dev.conf @@ -45,20 +45,6 @@ http { client_max_body_size 50000m; ignore_invalid_headers off; proxy_buffering off; - set $csp_default "default-src 'self'"; - set $csp_script "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.budibase.net https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io https://d2l5prqdbvm3op.cloudfront.net https://us-assets.i.posthog.com"; - set $csp_style "style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me https://maxcdn.bootstrapcdn.com"; - set $csp_object "object-src 'none'"; - set $csp_base_uri "base-uri 'self'"; - set $csp_connect "connect-src 'self' https://*.budibase.app https://*.budibaseqa.app https://*.budibase.net https://api-iam.intercom.io https://api-iam.intercom.io https://api-ping.intercom.io https://app.posthog.com https://us.i.posthog.com wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io https://uploads.intercomcdn.com https://uploads.intercomusercontent.com https://*.amazonaws.com https://*.s3.amazonaws.com https://*.s3.us-east-2.amazonaws.com https://*.s3.us-east-1.amazonaws.com https://*.s3.us-west-1.amazonaws.com https://*.s3.us-west-2.amazonaws.com https://*.s3.af-south-1.amazonaws.com https://*.s3.ap-east-1.amazonaws.com https://*.s3.ap-southeast-3.amazonaws.com https://*.s3.ap-south-1.amazonaws.com https://*.s3.ap-northeast-3.amazonaws.com https://*.s3.ap-northeast-2.amazonaws.com https://*.s3.ap-southeast-1.amazonaws.com https://*.s3.ap-southeast-2.amazonaws.com https://*.s3.ap-northeast-1.amazonaws.com https://*.s3.ca-central-1.amazonaws.com https://*.s3.cn-north-1.amazonaws.com https://*.s3.cn-northwest-1.amazonaws.com https://*.s3.eu-central-1.amazonaws.com https://*.s3.eu-west-1.amazonaws.com https://*.s3.eu-west-2.amazonaws.com https://*.s3.eu-south-1.amazonaws.com https://*.s3.eu-west-3.amazonaws.com https://*.s3.eu-north-1.amazonaws.com https://*.s3.sa-east-1.amazonaws.com https://*.s3.me-south-1.amazonaws.com https://*.s3.us-gov-east-1.amazonaws.com https://*.s3.us-gov-west-1.amazonaws.com https://api.github.com"; - set $csp_font "font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me https://maxcdn.bootstrapcdn.com https://js.intercomcdn.com https://fonts.intercomcdn.com"; - set $csp_frame "frame-src 'self' https:"; - set $csp_img "img-src http: https: data: blob:"; - set $csp_manifest "manifest-src 'self'"; - set $csp_media "media-src 'self' https://js.intercomcdn.com https://cdn.budi.live"; - set $csp_worker "worker-src blob:"; - - add_header Content-Security-Policy "${csp_default}; ${csp_style}; ${csp_object}; ${csp_base_uri}; ${csp_connect}; ${csp_font}; ${csp_frame}; ${csp_img}; ${csp_manifest}; ${csp_media}; ${csp_worker};" always; error_page 502 503 504 /error.html; location = /error.html {