Skip to content

Commit ee5cf3f

Browse files
committed
refactor: export types for DotNotation, GetType, FlatQuery, FieldValue, FlatQueryValue, and Query
1 parent 82fde4e commit ee5cf3f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/base/core/src/types/Selector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface FieldExpression<T> {
3333
}
3434

3535
// Recursive type to generate dot-notation keys
36-
type DotNotation<T> = {
36+
export type DotNotation<T> = {
3737
[K in keyof T & string]: T[K] extends Array<infer U>
3838
// If it's an array, include both the index and the $ wildcard
3939
? `${K}` | `${K}.$` | `${K}.${DotNotation<U>}`
@@ -43,7 +43,7 @@ type DotNotation<T> = {
4343
: `${K}` // Base case: Just return the key
4444
}[keyof T & string]
4545

46-
type GetType<T, P extends string> =
46+
export type GetType<T, P extends string> =
4747
P extends `${infer H}.${infer R}`
4848
? H extends keyof T
4949
? T[H] extends Array<infer U>
@@ -58,21 +58,21 @@ type GetType<T, P extends string> =
5858
? T[P]
5959
: never
6060

61-
type FlatQuery<T> = {
61+
export type FlatQuery<T> = {
6262
[P in DotNotation<T>]?: FlatQueryValue<T, P>
6363
}
6464

65-
type FieldValue<U> = U extends string
65+
export type FieldValue<U> = U extends string
6666
? string | RegExp | FieldExpression<string>
6767
: U | FieldExpression<U>
6868

69-
type FlatQueryValue<T, P extends string> = GetType<T, P> extends never
69+
export type FlatQueryValue<T, P extends string> = GetType<T, P> extends never
7070
? never
7171
: GetType<T, P> extends Array<infer U>
7272
? FieldValue<U> | FieldValue<U[]>
7373
: FieldValue<GetType<T, P>>
7474

75-
type Query<T> = FlatQuery<T> & {
75+
export type Query<T> = FlatQuery<T> & {
7676
$or?: Query<T>[],
7777
$and?: Query<T>[],
7878
$nor?: Query<T>[],

0 commit comments

Comments
 (0)