simplify RemoteQueryFilterOperators
This commit is contained in:
1 file changed
+27
-23
@@ -45,36 +45,21 @@ type ExtractFiltersOperators<
|
|||||||
: never
|
: never
|
||||||
}
|
}
|
||||||
|
|
||||||
type OperatorsOnlyFilters<
|
type RemoteQueryFilterOperators<T> = {
|
||||||
TEntry extends string,
|
$or?: T[]
|
||||||
RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints,
|
$and?: T[]
|
||||||
Exclusion extends string[] = [],
|
$not?: T
|
||||||
Lim extends number = Depth[3]
|
|
||||||
> = {
|
|
||||||
$or?: RemoteQueryFilters<
|
|
||||||
TEntry,
|
|
||||||
RemoteQueryEntryPointsLevel,
|
|
||||||
Exclusion,
|
|
||||||
Lim
|
|
||||||
>[]
|
|
||||||
$and?: RemoteQueryFilters<
|
|
||||||
TEntry,
|
|
||||||
RemoteQueryEntryPointsLevel,
|
|
||||||
Exclusion,
|
|
||||||
Lim
|
|
||||||
>[]
|
|
||||||
$not?: RemoteQueryFilters<TEntry, RemoteQueryEntryPointsLevel, Exclusion, Lim>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract all available filters from a remote entry point deeply
|
* Extract all available filters from a remote entry point deeply
|
||||||
*/
|
*/
|
||||||
export type RemoteQueryFilters<
|
export type InternalRemoteQueryFilters<
|
||||||
TEntry extends string,
|
TEntry extends string,
|
||||||
RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints,
|
RemoteQueryEntryPointsLevel = RemoteQueryEntryPoints,
|
||||||
Exclusion extends string[] = [],
|
Exclusion extends string[] = [],
|
||||||
Lim extends number = Depth[3]
|
Lim extends number = Depth[3]
|
||||||
> = (Lim extends number
|
> = Lim extends number
|
||||||
? TEntry extends keyof RemoteQueryEntryPointsLevel
|
? TEntry extends keyof RemoteQueryEntryPointsLevel
|
||||||
? TypeOnly<RemoteQueryEntryPointsLevel[TEntry]> extends Array<infer V>
|
? TypeOnly<RemoteQueryEntryPointsLevel[TEntry]> extends Array<infer V>
|
||||||
? Prettify<
|
? Prettify<
|
||||||
@@ -90,5 +75,24 @@ export type RemoteQueryFilters<
|
|||||||
>
|
>
|
||||||
>
|
>
|
||||||
: Record<string, any>
|
: Record<string, any>
|
||||||
: never) &
|
: never
|
||||||
OperatorsOnlyFilters<TEntry, RemoteQueryEntryPointsLevel, Exclusion, Lim>
|
|
||||||
|
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
|
||||||
|
>
|
||||||
Reference in new issue
Block a user