@rematter/genql
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -8,3 +8,3 @@ export declare type FieldsSelection<SRC extends Anify<DST> | undefined, DST> = { | ||
never: never; | ||
}[DST extends Nil ? 'never' : DST extends false | 0 ? 'never' : SRC extends Scalar ? 'scalar' : SRC extends any[] ? 'array' : SRC extends { | ||
}[Nil extends DST ? 'never' : DST extends false | 0 ? 'never' : SRC extends Scalar ? 'scalar' : SRC extends any[] ? 'array' : SRC extends { | ||
__isUnion?: any; | ||
@@ -15,3 +15,3 @@ } ? 'union' : DST extends { | ||
declare type HandleObject<SRC extends Anify<DST>, DST> = SRC extends Nil ? never : Pick<{ | ||
[Key in keyof SRC]: Key extends keyof DST ? SRC[Key] extends infer NON_NULL_SRC | null ? FieldsSelection<NON_NULL_SRC, NonNullable<DST[Key]>> | null : FieldsSelection<SRC[Key], NonNullable<DST[Key]>> : SRC[Key]; | ||
[Key in keyof SRC]: Key extends keyof DST ? null extends SRC[Key] ? FieldsSelection<NonNullable<SRC[Key]>, NonNullable<DST[Key]>> | null : FieldsSelection<SRC[Key], NonNullable<DST[Key]>> : SRC[Key]; | ||
}, Exclude<keyof DST, FieldsToRemove>>; | ||
@@ -18,0 +18,0 @@ declare type Handle__scalar<SRC extends Anify<DST>, DST> = SRC extends Nil ? never : Pick<{ |
{ | ||
"name": "@rematter/genql", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Generate a TypeScript SDK for any GraphQl API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -17,72 +17,75 @@ ////////////////////////////////////////////////// | ||
export type FieldsSelection<SRC extends Anify<DST> | undefined, DST> = { | ||
scalar: SRC | ||
union: Handle__isUnion<SRC, DST> | ||
object: HandleObject<SRC, DST> | ||
array: SRC extends Nil | ||
? never | ||
: SRC extends (infer T)[] | ||
? Array<FieldsSelection<T, DST>> | ||
: never | ||
__scalar: Handle__scalar<SRC, DST> | ||
never: never | ||
}[DST extends Nil | ||
scalar: SRC | ||
union: Handle__isUnion<SRC, DST> | ||
object: HandleObject<SRC, DST> | ||
array: SRC extends Nil | ||
? never | ||
: SRC extends (infer T)[] | ||
? Array<FieldsSelection<T, DST>> | ||
: never | ||
__scalar: Handle__scalar<SRC, DST> | ||
never: never | ||
}[Nil extends DST | ||
? 'never' | ||
: DST extends false | 0 | ||
? 'never' | ||
: DST extends false | 0 | ||
? 'never' | ||
: SRC extends Scalar | ||
? 'scalar' | ||
: SRC extends any[] | ||
? 'array' | ||
: SRC extends { __isUnion?: any } | ||
? 'union' | ||
: DST extends { __scalar?: any } | ||
? '__scalar' | ||
: DST extends {} | ||
? 'object' | ||
: 'never'] | ||
? 'scalar' | ||
: SRC extends any[] | ||
? 'array' | ||
: SRC extends { __isUnion?: any } | ||
? 'union' | ||
: DST extends { __scalar?: any } | ||
? '__scalar' | ||
: DST extends {} | ||
? 'object' | ||
: 'never'] | ||
type HandleObject<SRC extends Anify<DST>, DST> = SRC extends Nil | ||
? never | ||
: Pick< | ||
{ | ||
// using keyof SRC to maintain ?: relations of SRC type | ||
[Key in keyof SRC]: Key extends keyof DST | ||
? SRC[Key] extends infer NON_NULL_SRC | null | ||
? FieldsSelection<NON_NULL_SRC, NonNullable<DST[Key]>> | null | ||
: FieldsSelection<SRC[Key], NonNullable<DST[Key]>> | ||
: SRC[Key] | ||
}, | ||
Exclude<keyof DST, FieldsToRemove> | ||
// { | ||
// // remove falsy values | ||
// [Key in keyof DST]: DST[Key] extends false | 0 ? never : Key | ||
// }[keyof DST] | ||
> | ||
? never | ||
: Pick< | ||
{ | ||
// using keyof SRC to maintain ?: relations of SRC type | ||
[Key in keyof SRC]: Key extends keyof DST | ||
? null extends SRC[Key] | ||
? FieldsSelection< | ||
NonNullable<SRC[Key]>, | ||
NonNullable<DST[Key]> | ||
> | null | ||
: FieldsSelection<SRC[Key], NonNullable<DST[Key]>> | ||
: SRC[Key] | ||
}, | ||
Exclude<keyof DST, FieldsToRemove> | ||
// { | ||
// // remove falsy values | ||
// [Key in keyof DST]: DST[Key] extends false | 0 ? never : Key | ||
// }[keyof DST] | ||
> | ||
type Handle__scalar<SRC extends Anify<DST>, DST> = SRC extends Nil | ||
? never | ||
: Pick< | ||
// continue processing fields that are in DST, directly pass SRC type if not in DST | ||
{ | ||
[Key in keyof SRC]: Key extends keyof DST | ||
? FieldsSelection<SRC[Key], DST[Key]> | ||
: SRC[Key] | ||
}, | ||
// remove fields that are not scalars or are not in DST | ||
{ | ||
[Key in keyof SRC]: SRC[Key] extends Nil | ||
? never | ||
: Key extends FieldsToRemove | ||
? never | ||
: SRC[Key] extends Scalar | ||
? Key | ||
: Key extends keyof DST | ||
? Key | ||
: never | ||
}[keyof SRC] | ||
> | ||
? never | ||
: Pick< | ||
// continue processing fields that are in DST, directly pass SRC type if not in DST | ||
{ | ||
[Key in keyof SRC]: Key extends keyof DST | ||
? FieldsSelection<SRC[Key], DST[Key]> | ||
: SRC[Key] | ||
}, | ||
// remove fields that are not scalars or are not in DST | ||
{ | ||
[Key in keyof SRC]: SRC[Key] extends Nil | ||
? never | ||
: Key extends FieldsToRemove | ||
? never | ||
: SRC[Key] extends Scalar | ||
? Key | ||
: Key extends keyof DST | ||
? Key | ||
: never | ||
}[keyof SRC] | ||
> | ||
type Handle__isUnion<SRC extends Anify<DST>, DST> = SRC extends Nil | ||
? never | ||
: Omit<SRC, FieldsToRemove> // just return the union type | ||
? never | ||
: Omit<SRC, FieldsToRemove> // just return the union type | ||
@@ -89,0 +92,0 @@ type Scalar = string | number | Date | boolean | null | undefined |
Sorry, the diff of this file is not supported yet
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
7181
377103