From ebe02a3836399446430018cd59f147c2d44cea3f Mon Sep 17 00:00:00 2001 From: Pedro Guzman Date: Wed, 18 Jun 2025 13:31:56 +0200 Subject: [PATCH] simplify RemoteQueryFilterOperators --- .../types/src/modules-sdk/to-remote-query.ts | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/packages/core/types/src/modules-sdk/to-remote-query.ts b/packages/core/types/src/modules-sdk/to-remote-query.ts index a95a7d6912..fb63cc4ed2 100644 --- a/packages/core/types/src/modules-sdk/to-remote-query.ts +++ b/packages/core/types/src/modules-sdk/to-remote-query.ts @@ -45,36 +45,21 @@ type ExtractFiltersOperators< : never } -type OperatorsOnlyFilters< - TEntry extends string, - RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints, - Exclusion extends string[] = [], - Lim extends number = Depth[3] -> = { - $or?: RemoteQueryFilters< - TEntry, - RemoteQueryEntryPointsLevel, - Exclusion, - Lim - >[] - $and?: RemoteQueryFilters< - TEntry, - RemoteQueryEntryPointsLevel, - Exclusion, - Lim - >[] - $not?: RemoteQueryFilters +type RemoteQueryFilterOperators = { + $or?: T[] + $and?: T[] + $not?: T } /** * Extract all available filters from a remote entry point deeply */ -export type RemoteQueryFilters< +export type InternalRemoteQueryFilters< TEntry extends string, RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints, Exclusion extends string[] = [], Lim extends number = Depth[3] -> = (Lim extends number +> = Lim extends number ? TEntry extends keyof RemoteQueryEntryPointsLevel ? TypeOnly extends Array ? Prettify< @@ -90,5 +75,24 @@ export type RemoteQueryFilters< > > : Record - : never) & - OperatorsOnlyFilters + : never + +export type RemoteQueryFilters< + TEntry extends string, + RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints, + Exclusion extends string[] = [], + Lim extends number = Depth[3] +> = RemoteQueryFilterOperators< + InternalRemoteQueryFilters< + TEntry, + RemoteQueryEntryPointsLevel, + Exclusion, + Lim + > +> & + InternalRemoteQueryFilters< + TEntry, + RemoteQueryEntryPointsLevel, + Exclusion, + Lim + >