Centralize metadata relations constant + simplification (#16901)

# Introduction
As we introduced a new grain on relation extraction thanks to low level
`SyncableEntity` and `WorkspaceRelatedEntity` we're able to strictly
typesafe extract metadata entity

The new constant centralizes both many to one and one to many constants
metadata entity constants in a more strictly typesafe way. Remains only
the flatEntityForeignKey aggregator which has to be chosen manually
across all available targeted flat entity ids properties
This commit is contained in:
Paul Rastoin
2026-01-02 16:49:06 +01:00
committed by GitHub
parent 3cab1bf80b
commit 42c9ae1ebc
30 changed files with 569 additions and 409 deletions
@@ -1,15 +1,13 @@
import { removePropertiesFromRecord } from 'twenty-shared/utils';
import { ALL_METADATA_RELATION_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-metadata-relations-properties.constant';
import { getMetadataEntityRelationProperties } from 'src/engine/metadata-modules/flat-entity/utils/get-metadata-entity-relation-properties.util';
import { type FlatView } from 'src/engine/metadata-modules/flat-view/types/flat-view.type';
import { type ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity';
export const fromViewEntityToFlatView = (viewEntity: ViewEntity): FlatView => {
const viewEntityWithoutRelations = removePropertiesFromRecord(
viewEntity,
Object.keys(
ALL_METADATA_RELATION_PROPERTIES.view,
) as (keyof typeof ALL_METADATA_RELATION_PROPERTIES.view)[],
getMetadataEntityRelationProperties('view'),
);
return {