diff --git a/packages/core/types/src/modules/entity-service/params/sort.ts b/packages/core/types/src/modules/entity-service/params/sort.ts index f9df4b82c8..4d8f60171e 100644 --- a/packages/core/types/src/modules/entity-service/params/sort.ts +++ b/packages/core/types/src/modules/entity-service/params/sort.ts @@ -75,16 +75,24 @@ export type ArrayNotation = Any = { - // First level sort - [key in SingleAttribute]?: OrderKind.Any; -} & { - // Deep sort, only add populatable keys that have a - // target (remove dynamic zones and other polymorphic links) - [key in Attribute.GetKeysWithTarget]?: ObjectNotation< - Attribute.GetTarget - >; + [key in ObjectNotationKeys]?: key extends SingleAttribute + ? // First level sort (scalar attributes, id, ...) + OrderKind.Any + : // Deep sort (relations with a target, components, media, ...) + ObjectNotation>; }; +/** + * Represents the keys of an object notation for a sort + * - SingleAttribute represents a union of every non-populatable attribute based on the passed schema UID + * - Attribute.GetKeysWithTarget provides keys with a target from the passed schema UID. + * + * This means that every member of ObjectNotationKeys can represent either a single non-populatable attribute or an attribute with a target. + */ +type ObjectNotationKeys = + | SingleAttribute + | Attribute.GetKeysWithTarget; + /** * Represents any notation for a sort (string, array, object) *