@graffy/core
Advanced tools
Comparing version 0.16.20-alpha.5 to 0.16.20-alpha.6
@@ -5,3 +5,3 @@ { | ||
"author": "aravind (https://github.com/aravindet)", | ||
"version": "0.16.20-alpha.5", | ||
"version": "0.16.20-alpha.6", | ||
"main": "./index.cjs", | ||
@@ -20,6 +20,6 @@ "exports": { | ||
"dependencies": { | ||
"@graffy/common": "0.16.20-alpha.5", | ||
"@graffy/stream": "0.16.20-alpha.5", | ||
"@graffy/common": "0.16.20-alpha.6", | ||
"@graffy/stream": "0.16.20-alpha.6", | ||
"debug": "^4.3.7" | ||
} | ||
} |
@@ -12,2 +12,11 @@ export type AnyLeaf = string | number | boolean | null; | ||
// biome-ignore lint/suspicious/noExplicitAny: Any value is for results. | ||
type AnyValue = any; | ||
type AnyProjection = | ||
| boolean | ||
| { $key: Key } | ||
| Record<string, AnyProjection> | ||
| AnyProjection[]; | ||
export type GraffyCollection<CollectionSchema extends AnyObject> = { | ||
@@ -31,2 +40,9 @@ [name: string]: CollectionSchema; | ||
// Generic one, when the path is not known at compile time. | ||
read<Q extends AnyProjection>( | ||
path: string | Key[], | ||
projection: Q, | ||
options?: GraffyReadOptions, | ||
): Promise<BlindReadResult<Q>>; | ||
on: AnyFunction; | ||
@@ -68,4 +84,5 @@ call: AnyFunction; | ||
? | ||
| (Project<S[string]> & { $key: Key }) | ||
| (Project<S[string]> & { $key: Key })[] | ||
| { [key: string]: Project<S[string]> } // Object form | ||
| (Project<S[string]> & { $key: Key }) // Single $key | ||
| (Project<S[string]> & { $key: Key })[] // Array $key | ||
: S extends AnyObject | ||
@@ -79,9 +96,26 @@ ? Partial<{ [K in keyof S]: Project<S[K]> }> | boolean | ||
type ReadResult<S, Q> = S extends GraffyCollection<AnyObject> | ||
? Q extends Array<AnyObject> | { $key: Key } | ||
? ResultArray<S[string] & { $key: Key }> | ||
: S[string] & { $key: Key } | ||
: Q extends AnyObject | ||
? { [K in keyof S & keyof Q]: ReadResult<S[K], Q[K]> } | ||
: S; | ||
? Q extends Array<infer QItem> | ||
? ResultArray<PlainReadResult<S[string], QItem> & { $key: Key }> // Array $key | ||
: Q extends { $key: Key } | ||
? ResultArray<PlainReadResult<S[string], Q> & { $key: Key }> // Single $key | ||
: { [K in keyof Q]: PlainReadResult<S[string], Q[K]> } // Object form | ||
: PlainReadResult<S, Q>; | ||
// Ignore $key in Q | ||
type PlainReadResult<S, Q> = Q extends AnyObject | ||
? { [K in keyof S & keyof Q]: ReadResult<S[K], Q[K]> } | ||
: S; | ||
// What can we tell about ReadResult when schema isn’t known? | ||
type BlindReadResult<Q> = Q extends Array<infer QItem> | ||
? ResultArray<BlindPlainReadResult<QItem>> | ||
: Q extends { $key: Key } | ||
? ResultArray<BlindPlainReadResult<Q>> | ||
: BlindPlainReadResult<Q>; | ||
// Ignore $key in Q | ||
type BlindPlainReadResult<Q> = Q extends AnyObject | ||
? { [K in keyof Q]: BlindReadResult<Q[K]> } | ||
: AnyValue; | ||
type GraffyReadOptions = AnyObject; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23970
613
+ Added@graffy/common@0.16.20-alpha.6(transitive)
+ Added@graffy/stream@0.16.20-alpha.6(transitive)
- Removed@graffy/common@0.16.20-alpha.5(transitive)
- Removed@graffy/stream@0.16.20-alpha.5(transitive)