-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
constraints.types.ts
47 lines (42 loc) · 1.26 KB
/
constraints.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {
$endAt,
$endBefore,
$equalTo,
$limit,
$limitToFirst,
$limitToLast,
$orderBy,
$orderByChild,
$orderByKey,
$orderByValue,
$startAfter,
$startAt,
$where,
FirestoreQueryConstraints,
RealtimeQueryConstraints,
} from "./firebase.constraints";
export type RealtimeConstraintsUnion = `${RealtimeQueryConstraints}`;
export type FirestoreConstraintsUnion = `${FirestoreQueryConstraints}`;
export type RealtimePermittedMethods =
| ReturnType<typeof $startAt>
| ReturnType<typeof $startAfter>
| ReturnType<typeof $endAt>
| ReturnType<typeof $endBefore>
| ReturnType<typeof $orderByChild>
| ReturnType<typeof $orderByValue>
| ReturnType<typeof $orderByKey>
| ReturnType<typeof $limitToFirst>
| ReturnType<typeof $limitToLast>
| ReturnType<typeof $equalTo>;
export type FirestorePermittedMethods =
| ReturnType<typeof $where>
| ReturnType<typeof $orderBy>
| ReturnType<typeof $limit>
| ReturnType<typeof $startAt>
| ReturnType<typeof $startAfter>
| ReturnType<typeof $endAt>
| ReturnType<typeof $endBefore>;
type ExtractConstraintType<T> = T extends { toString: () => string; type: infer ThisType; values: any }
? ThisType
: never;
export type PermittedConstraints<T, U> = ExtractConstraintType<T> extends U ? T : never;