/** * JavaScript primitive types */ export type Primitive = void | undefined | null | boolean | number | string | bigint | symbol /** * Keep only the primitive properties of an object type */ export type OnlyPrimitiveProps = Pick< E, { [Prop in keyof E]: E[Prop] extends Primitive ? Prop : never }[keyof E] > /** * Remove the ID property from an object type */ export type WithoutID = Omit /** * Keep only the primitive properties of an entity object, ID excluded */ export type EntityPrimDTO = OnlyPrimitiveProps> /** * Keep only the primitive properties of an entity object and convert its relations to arrays of identifiers */ export type EntityDTO = { [Prop in keyof EntityPrimDTO]: EntityPrimDTO[Prop] extends Array<{ id: string }> ? string[] : EntityPrimDTO[Prop] } /** * Get the default sort DTO for a given entity */ export type SortEntityDTO = { [K in keyof OnlyPrimitiveProps]: 'ASC' | 'DESC' | 1 | -1 }