Fix flat field metadata date type (#16445)

# Introduction
Following https://github.com/twentyhq/twenty/pull/16420
This commit is contained in:
Paul Rastoin
2025-12-09 19:53:36 +01:00
committed by GitHub
parent 83fc434c5d
commit 7b98804ec1
22 changed files with 75 additions and 90 deletions
@@ -0,0 +1,9 @@
export type CastRecordTypeOrmDatePropertiesToString<T> = {
[P in keyof T as [T[P]] extends [never]
? never
: [NonNullable<T[P]>] extends [never]
? never
: NonNullable<T[P]> extends Date
? P
: never]: null extends T[P] ? string | null : string;
};
@@ -1,7 +1,6 @@
import { type SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface';
import { type ExtractRecordTypeOrmNonNullableDateProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-non-nullable-date-properties.type';
import { type ExtractRecordTypeOrmNullableDateProperties } from 'src/engine/workspace-manager/workspace-migration-v2/types/extract-record-typeorm-nullable-date-properties.type';
import { type CastRecordTypeOrmDatePropertiesToString } from 'src/engine/metadata-modules/flat-entity/types/cast-record-typeorm-date-properties-to-string.type';
import { type NonNullableProperties } from 'src/types/non-nullable-properties.type';
export type SyncableFlatEntity = NonNullableProperties<
@@ -11,23 +10,13 @@ export type SyncableFlatEntity = NonNullableProperties<
applicationId: string | null;
};
export type EntityNullableDateProperties<TEntity> =
ExtractRecordTypeOrmNullableDateProperties<TEntity>;
export type EntityNonNullableDateProperties<TEntity> =
ExtractRecordTypeOrmNonNullableDateProperties<TEntity>;
export type FlatEntityFrom<
TEntity,
TEntityRelationProperties extends keyof TEntity,
> = Omit<
TEntity,
| TEntityRelationProperties
| EntityNonNullableDateProperties<TEntity>
| EntityNullableDateProperties<TEntity>
| 'application'
> & {
[P in EntityNonNullableDateProperties<TEntity>]: string;
} & {
[P in EntityNullableDateProperties<TEntity>]: string | null;
};
| keyof CastRecordTypeOrmDatePropertiesToString<TEntity>
> &
CastRecordTypeOrmDatePropertiesToString<TEntity>;