Deprecate ObjectMetadataInterface and improve entity typing (#13310)

# Introduction
Following `FieldMetadataInterface` deprecation in
https://github.com/twentyhq/twenty/pull/13264
As for the previous PR will rename and remove all the file in a
secondary PR to avoid conflicts and over loading this one

## Improvements
Removed optional properties from the `objectMetadataEntity` model and
added utils to retrieve test data

## Notes
By touching to `ObjectMetadataDTO` I would have expected a twenty-front
codegenerated types mutation, but it does not seem to be granular enough
to null/undefined coercion
This commit is contained in:
Paul Rastoin
2025-07-21 17:53:17 +02:00
committed by GitHub
parent 79f3fbb016
commit 1536ed3434
23 changed files with 1031 additions and 909 deletions
@@ -51,16 +51,16 @@ export class ObjectMetadataDTO {
labelPlural: string;
@Field({ nullable: true })
description: string;
description?: string;
@Field({ nullable: true })
icon: string;
icon?: string;
@Field(() => ObjectStandardOverridesDTO, { nullable: true })
standardOverrides?: ObjectStandardOverridesDTO;
@Field({ nullable: true })
shortcut: string;
shortcut?: string;
@FilterableField()
isCustom: boolean;
@@ -195,7 +195,7 @@ export class BeforeUpdateOneObject<T extends UpdateObjectPayload>
update: StandardObjectUpdate;
overrideKey: 'labelSingular' | 'labelPlural' | 'description' | 'icon';
newValue: string;
originalValue: string;
originalValue: string | null;
locale?: keyof typeof APP_LOCALES | undefined;
}): boolean {
if (locale && locale !== SOURCE_LOCALE) {
@@ -224,7 +224,7 @@ export class BeforeUpdateOneObject<T extends UpdateObjectPayload>
update: StandardObjectUpdate,
overrideKey: 'labelSingular' | 'labelPlural' | 'description' | 'icon',
newValue: string,
originalValue: string,
originalValue: string | null,
locale: keyof typeof APP_LOCALES,
): boolean {
const messageId = generateMessageId(originalValue ?? '');
@@ -254,7 +254,7 @@ export class BeforeUpdateOneObject<T extends UpdateObjectPayload>
update: StandardObjectUpdate,
overrideKey: 'labelSingular' | 'labelPlural' | 'description' | 'icon',
newValue: string,
originalValue: string,
originalValue: string | null,
): boolean {
if (newValue !== originalValue) {
return false;
@@ -10,8 +10,6 @@ import {
UpdateDateColumn,
} from 'typeorm';
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
import { WorkspaceEntityDuplicateCriteria } from 'src/engine/api/graphql/workspace-query-builder/types/workspace-entity-duplicate-criteria.type';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
@@ -29,7 +27,7 @@ import { ObjectPermissionEntity } from 'src/engine/metadata-modules/object-permi
'namePlural',
'workspaceId',
])
export class ObjectMetadataEntity implements ObjectMetadataInterface {
export class ObjectMetadataEntity {
@PrimaryGeneratedColumn('uuid')
id: string;
@@ -52,14 +50,17 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
labelPlural: string;
@Column({ nullable: true, type: 'text' })
description: string;
description: string | null;
@Column({ nullable: true })
icon: string;
@Column({ nullable: true, type: 'varchar' })
icon: string | null;
@Column({ type: 'jsonb', nullable: true })
standardOverrides?: ObjectStandardOverridesDTO;
standardOverrides: ObjectStandardOverridesDTO | null;
/**
* @deprecated
*/
@Column({ nullable: false })
targetTableName: string;
@@ -82,16 +83,16 @@ export class ObjectMetadataEntity implements ObjectMetadataInterface {
isSearchable: boolean;
@Column({ type: 'jsonb', nullable: true })
duplicateCriteria?: WorkspaceEntityDuplicateCriteria[];
duplicateCriteria: WorkspaceEntityDuplicateCriteria[] | null;
@Column({ nullable: true })
shortcut: string;
@Column({ nullable: true, type: 'varchar' })
shortcut: string | null;
@Column({ nullable: true, type: 'uuid' })
labelIdentifierFieldMetadataId?: string | null;
labelIdentifierFieldMetadataId: string | null;
@Column({ nullable: true, type: 'uuid' })
imageIdentifierFieldMetadataId?: string | null;
imageIdentifierFieldMetadataId: string | null;
@Column({ default: false })
isLabelSyncedWithName: boolean;
@@ -1,5 +1,7 @@
import { Injectable } from '@nestjs/common';
import { isDefined } from 'twenty-shared/utils';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager';
import { FavoriteWorkspaceEntity } from 'src/modules/favorite/standard-objects/favorite.workspace-entity';
@@ -99,7 +101,9 @@ export class ObjectMetadataRelatedRecordsService {
{ objectMetadataId: updatedObjectMetadata.id, key: 'INDEX' },
{
name: `All ${updatedObjectMetadata.labelPlural}`,
icon: updatedObjectMetadata.icon,
...(isDefined(updatedObjectMetadata.icon)
? { icon: updatedObjectMetadata.icon }
: {}),
},
);
}