Spread in parent and requires FlatEntity.__universal (#17753)

# Introduction
Requiring the spreaded `__universal` record that aggregates all the
universal identifier ( relations fk and aggregators ) of an entity to
its root

It's blockin for https://github.com/twentyhq/twenty/pull/17687 to be
finalized because if we don't we would have to migrated all related
entities at once in order for them to always have the universal
properties

## `resolveEntityRelationUniversalIdentifiers`
Introduced `resolveEntityRelationUniversalIdentifiers` a centralized
utility that resolves foreign key IDs to universal identifiers using
ALL_METADATA_RELATIONS metadata. It provides strict typing for both
input (foreign keys) and output (universal identifiers), with
nullability dynamically inferred from entity relation types.
Strictly and dynamically typed for both output and input

To do so added a new type and const/runtime grain to
ALL_METADATA_RELATIONS `isNullable`to many-to-one entries, derived from
the entity relation property types. And fixed incorrectly typed typeorm
entities

### Usage
```ts
  const {
    availabilityObjectMetadataUniversalIdentifier,
    frontComponentUniversalIdentifier,
  } = resolveEntityRelationUniversalIdentifiers({
    metadataName: 'commandMenuItem',
    foreignKeyValues: {
      availabilityObjectMetadataId:
        createCommandMenuItemInput.availabilityObjectMetadataId,
      frontComponentId: createCommandMenuItemInput.frontComponentId,
    },
    flatEntityMaps: { flatObjectMetadataMaps, flatFrontComponentMaps },
  });
```
This commit is contained in:
Paul Rastoin
2026-02-06 18:02:02 +01:00
committed by GitHub
parent a494a7a902
commit 3dc5b162c7
133 changed files with 2141 additions and 1166 deletions
@@ -78,9 +78,6 @@ export const fromCreateLogicFunctionInputToFlatLogicFunction = ({
? DEFAULT_TOOL_INPUT_SCHEMA
: null,
isTool: rawCreateLogicFunctionInput?.isTool ?? false,
__universal: {
applicationUniversalIdentifier: ownerFlatApplication.universalIdentifier,
universalIdentifier,
},
applicationUniversalIdentifier: ownerFlatApplication.universalIdentifier,
};
};
@@ -34,9 +34,6 @@ export const fromLogicFunctionEntityToFlatLogicFunction = ({
createdAt: logicFunctionEntity.createdAt.toISOString(),
updatedAt: logicFunctionEntity.updatedAt.toISOString(),
deletedAt: logicFunctionEntity.deletedAt?.toISOString() ?? null,
__universal: {
universalIdentifier: logicFunctionEntity.universalIdentifier,
applicationUniversalIdentifier,
},
applicationUniversalIdentifier,
};
};