@graffy/core 0.16.20-alpha.8 → 0.16.20-alpha.9

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/types/index.d.ts +15 -11
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.8",
5
+ "version": "0.16.20-alpha.9",
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.8",
20
- "@graffy/stream": "0.16.20-alpha.8",
19
+ "@graffy/common": "0.16.20-alpha.9",
20
+ "@graffy/stream": "0.16.20-alpha.9",
21
21
  "debug": "^4.3.7"
22
22
  }
23
23
  }
package/types/index.d.ts CHANGED
@@ -103,7 +103,9 @@ type ReadResult<S, Q> = S extends GraffyCollection<AnyObject>
103
103
  ? Q extends Array<infer QItem>
104
104
  ? ResultArray<PlainReadResult<S[string], QItem> & { $key: Key }> // Array $key
105
105
  : Q extends { $key: Key }
106
- ? ResultArray<PlainReadResult<S[string], Q> & { $key: Key }> // Single $key
106
+ ? Q extends { $key: string }
107
+ ? { [key in Q['$key']]: PlainReadResult<S, Q> }
108
+ : ResultArray<PlainReadResult<S[string], Q> & { $key: Key }> // Single $key
107
109
  : { [K in keyof Q]: PlainReadResult<S[string], Q[K]> } // Object form
108
110
  : PlainReadResult<S, Q>;
109
111
 
@@ -113,15 +115,17 @@ type PlainReadResult<S, Q> = Q extends AnyObject
113
115
  : S;
114
116
 
115
117
  // What can we tell about ReadResult when schema isn’t known?
116
- // type BlindReadResult<Q> = Q extends Array<infer QItem>
117
- // ? ResultArray<BlindPlainReadResult<QItem>>
118
- // : Q extends { $key: Key }
119
- // ? ResultArray<BlindPlainReadResult<Q>>
120
- // : BlindPlainReadResult<Q>;
121
-
122
- // // Ignore $key in Q
123
- // type BlindPlainReadResult<Q> = Q extends AnyObject
124
- // ? { [K in keyof Q]: BlindReadResult<Q[K]> }
125
- // : AnyValue;
118
+ type BlindReadResult<Q> = Q extends Array<infer QItem>
119
+ ? ResultArray<BlindPlainReadResult<QItem>>
120
+ : Q extends { $key: Key }
121
+ ? Q extends { $key: string }
122
+ ? { [key in Q['$key']]: BlindPlainReadResult<Q> }
123
+ : ResultArray<BlindPlainReadResult<Q>>
124
+ : BlindPlainReadResult<Q>;
125
+
126
+ // Ignore $key in Q
127
+ type BlindPlainReadResult<Q> = Q extends AnyObject
128
+ ? { [K in keyof Q]: BlindReadResult<Q[K]> }
129
+ : AnyValue;
126
130
 
127
131
  type GraffyReadOptions = AnyObject;