@graffy/core 0.16.20-alpha.2 → 0.16.20-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/types/index.d.ts +34 -36
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/core",
|
|
3
3
|
"description": "The main module for Graffy, a library for intuitive real-time data APIs.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.16.20-alpha.
|
|
5
|
+
"version": "0.16.20-alpha.3",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/common": "0.16.20-alpha.
|
|
20
|
-
"@graffy/stream": "0.16.20-alpha.
|
|
19
|
+
"@graffy/common": "0.16.20-alpha.3",
|
|
20
|
+
"@graffy/stream": "0.16.20-alpha.3",
|
|
21
21
|
"debug": "^4.3.7"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// biome-ignore lint/suspicious/noExplicitAny: This is used to match concrete types in "extends" expressions.
|
|
2
|
+
export type AnyObject = Record<string, any>;
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
// biome-ignore lint/suspicious/noExplicitAny: Function for which types are not yet defined.
|
|
5
|
+
type AnyFunction = (...args: any[]) => any;
|
|
4
6
|
|
|
5
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
6
|
-
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: Keys can be anything.
|
|
8
|
+
type Key = any;
|
|
9
|
+
|
|
10
|
+
export type GraffyCollection<CollectionSchema extends AnyObject> = {
|
|
7
11
|
[name: string]: CollectionSchema;
|
|
8
12
|
} & { __brand: 'GraffyCollection' };
|
|
9
13
|
|
|
@@ -21,55 +25,49 @@ export default class Graffy<S> {
|
|
|
21
25
|
options?: GraffyReadOptions,
|
|
22
26
|
): Promise<ReadResult<S, Q>>;
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO: add typings
|
|
33
|
-
onWrite: (...any) => any;
|
|
34
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO: add typings
|
|
35
|
-
onWatch: (...any) => any;
|
|
36
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO: add typings
|
|
37
|
-
write: (...any) => any;
|
|
38
|
-
// biome-ignore lint/suspicious/noExplicitAny: TODO: add typings
|
|
39
|
-
watch: (...any) => any;
|
|
28
|
+
on: AnyFunction;
|
|
29
|
+
call: AnyFunction;
|
|
30
|
+
use: AnyFunction;
|
|
31
|
+
onRead: AnyFunction;
|
|
32
|
+
onWrite: AnyFunction;
|
|
33
|
+
onWatch: AnyFunction;
|
|
34
|
+
write: AnyFunction;
|
|
35
|
+
watch: AnyFunction;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
export type PathOf<S> = S extends GraffyCollection<
|
|
43
|
-
?
|
|
44
|
-
: S extends
|
|
38
|
+
export type PathOf<S> = S extends GraffyCollection<AnyObject>
|
|
39
|
+
? Key
|
|
40
|
+
: S extends AnyObject
|
|
45
41
|
? keyof S | [keyof S, ...PathOf<S[keyof S]>[]]
|
|
46
42
|
: never;
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
type Get<S, K> = S extends GraffyCollection<AnyObject>
|
|
49
45
|
? S[string]
|
|
50
|
-
:
|
|
51
|
-
? S[
|
|
52
|
-
:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
: K extends keyof S
|
|
47
|
+
? S[K]
|
|
48
|
+
: never;
|
|
49
|
+
|
|
50
|
+
export type Descend<S, P> = P extends [Key]
|
|
51
|
+
? Get<S, P[0]>
|
|
52
|
+
: P extends [Key, ...infer R]
|
|
53
|
+
? Descend<Get<S, P[0]>, R>
|
|
54
|
+
: Get<S, P>;
|
|
57
55
|
|
|
58
|
-
export type Project<S> = S extends GraffyCollection<
|
|
56
|
+
export type Project<S> = S extends GraffyCollection<AnyObject>
|
|
59
57
|
?
|
|
60
58
|
| (Project<S[string]> & { $key: Key })
|
|
61
59
|
| (Project<S[string]> & { $key: Key })[]
|
|
62
|
-
: S extends
|
|
60
|
+
: S extends AnyObject
|
|
63
61
|
? Partial<{ [K in keyof S]: Project<S[K]> }>
|
|
64
62
|
: boolean;
|
|
65
63
|
|
|
66
64
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
67
65
|
type ResultArray<R> = R[] & { $page: any; $next: any; $prev: any };
|
|
68
66
|
|
|
69
|
-
type ReadResult<S, Q> = S extends GraffyCollection<
|
|
67
|
+
type ReadResult<S, Q> = S extends GraffyCollection<AnyObject>
|
|
70
68
|
? (S[string] & { $key: Key }) | ResultArray<S[string] & { $key: Key }>
|
|
71
|
-
: S extends
|
|
69
|
+
: S extends AnyObject
|
|
72
70
|
? { [K in keyof S & keyof Q]: ReadResult<S[K], Q[K]> }
|
|
73
71
|
: S;
|
|
74
72
|
|
|
75
|
-
type GraffyReadOptions =
|
|
73
|
+
type GraffyReadOptions = AnyObject;
|