From e191c90385803118fa77a9e63cef7760b8f0ee1f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 10 Oct 2024 16:14:36 +0200 Subject: [PATCH] Simplify enriched column --- packages/server/src/sdk/app/views/index.ts | 15 +++++++++++---- packages/types/src/sdk/view.ts | 13 +++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 35f2a84b07..246922678d 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -1,4 +1,5 @@ import { + BBReferenceFieldSubType, CalculationType, canGroupBy, FeatureFlag, @@ -7,6 +8,7 @@ import { PermissionLevel, RelationSchemaField, RenameColumn, + RequiredKeys, Table, TableSchema, View, @@ -325,13 +327,18 @@ export async function enrichSchema( const viewFieldSchema = viewFields[relTableFieldName] const isVisible = !!viewFieldSchema?.visible const isReadonly = !!viewFieldSchema?.readonly - result[relTableFieldName] = { - ...relTableField, - ...viewFieldSchema, - name: relTableField.name, + const enrichedFieldSchema: RequiredKeys = { visible: isVisible, readonly: isReadonly, + order: viewFieldSchema?.order, + width: viewFieldSchema?.width, + + icon: relTableField.icon, + type: relTableField.type, + subtype: relTableField.subtype, } + } + result[relTableFieldName] = enrichedFieldSchema } return result } diff --git a/packages/types/src/sdk/view.ts b/packages/types/src/sdk/view.ts index 422207197d..4c555fbaa7 100644 --- a/packages/types/src/sdk/view.ts +++ b/packages/types/src/sdk/view.ts @@ -1,4 +1,10 @@ -import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents" +import { + FieldSchema, + FieldSubType, + FieldType, + RelationSchemaField, + ViewV2, +} from "../documents" export interface ViewV2Enriched extends ViewV2 { schema?: { @@ -8,4 +14,7 @@ export interface ViewV2Enriched extends ViewV2 { } } -export type ViewV2ColumnEnriched = RelationSchemaField & FieldSchema +export interface ViewV2ColumnEnriched extends RelationSchemaField { + type: FieldType + subtype?: FieldSubType +}