@pothos/core
Advanced tools
Comparing version 3.33.0 to 3.33.1
# Change Log | ||
## 3.33.1 | ||
### Patch Changes | ||
- 6f155d82: Improve normalization of input types so that objects with functions are not normalized | ||
## 3.33.0 | ||
@@ -4,0 +10,0 @@ |
@@ -32,6 +32,11 @@ export type MaybePromise<T> = Promise<T> | T; | ||
}; | ||
export type RecursivelyNormalizeNullableFields<T> = T extends null | undefined ? null | undefined : T extends (infer L)[] ? RecursivelyNormalizeNullableFields<L>[] : T extends (...args: any[]) => unknown ? T : keyof T extends string ? T extends object ? Normalize<{ | ||
[K in OptionalKeys<T>]?: K extends string ? RecursivelyNormalizeNullableFields<NonNullable<T[K]>> | null | undefined : T[K]; | ||
export type IsSimpleRecord<T> = ([ | ||
T | ||
] extends [Record<string, any>] ? keyof T extends infer K ? K extends string ? T[K] extends (...args: any[]) => unknown ? [ | ||
1 | ||
] extends [T[K]] ? never : false : never : never : false : false) extends never ? true : false; | ||
export type RecursivelyNormalizeNullableFields<T> = T extends null | undefined ? null | undefined : T extends (infer L)[] ? RecursivelyNormalizeNullableFields<L>[] : T extends (...args: any[]) => unknown ? T : keyof T extends string ? IsSimpleRecord<T> extends true ? Normalize<{ | ||
[K in OptionalKeys<T & object>]?: K extends string ? RecursivelyNormalizeNullableFields<NonNullable<T[K]>> | null | undefined : T[K]; | ||
} & { | ||
[K in RequiredKeys<T>]: RecursivelyNormalizeNullableFields<NonNullable<T[K]>>; | ||
[K in RequiredKeys<T & object>]: RecursivelyNormalizeNullableFields<NonNullable<T[K]>>; | ||
}> : T : T; | ||
@@ -38,0 +43,0 @@ export type RemoveNeverKeys<T extends {}> = { |
@@ -32,6 +32,15 @@ export type MaybePromise<T> = Promise<T> | T; | ||
}; | ||
export type RecursivelyNormalizeNullableFields<T> = T extends null | undefined ? null | undefined : T extends (infer L)[] ? RecursivelyNormalizeNullableFields<L>[] : T extends (...args: any[]) => unknown ? T : keyof T extends string ? T extends object ? Normalize<{ | ||
[K in OptionalKeys<T>]?: K extends string ? RecursivelyNormalizeNullableFields<NonNullable<T[K]>> | null | undefined : T[K]; | ||
export type IsSimpleRecord<T> = ([ | ||
T | ||
] extends [ | ||
Record<string, any> | ||
] ? keyof T extends infer K ? K extends string ? T[K] extends (...args: any[]) => unknown ? [ | ||
1 | ||
] extends [ | ||
T[K] | ||
] ? never : false : never : never : false : false) extends never ? true : false; | ||
export type RecursivelyNormalizeNullableFields<T> = T extends null | undefined ? null | undefined : T extends (infer L)[] ? RecursivelyNormalizeNullableFields<L>[] : T extends (...args: any[]) => unknown ? T : keyof T extends string ? IsSimpleRecord<T> extends true ? Normalize<{ | ||
[K in OptionalKeys<T & object>]?: K extends string ? RecursivelyNormalizeNullableFields<NonNullable<T[K]>> | null | undefined : T[K]; | ||
} & { | ||
[K in RequiredKeys<T>]: RecursivelyNormalizeNullableFields<NonNullable<T[K]>>; | ||
[K in RequiredKeys<T & object>]: RecursivelyNormalizeNullableFields<NonNullable<T[K]>>; | ||
}> : T : T; | ||
@@ -38,0 +47,0 @@ export type RemoveNeverKeys<T extends {}> = { |
{ | ||
"name": "@pothos/core", | ||
"version": "3.33.0", | ||
"version": "3.33.1", | ||
"description": "Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -49,2 +49,20 @@ export type MaybePromise<T> = Promise<T> | T; | ||
// Check if T is a Record of string keys who's values are not functions | ||
export type IsSimpleRecord<T> = ( | ||
[T] extends [Record<string, any>] // eslint-disable-line @typescript-eslint/no-explicit-any | ||
? keyof T extends infer K | ||
? K extends string | ||
? T[K] extends (...args: any[]) => unknown | ||
? // check if T[K] is any (T[K] is distributed, so it can't also be a number unless its any) | ||
[1] extends [T[K]] | ||
? never | ||
: false | ||
: never | ||
: never | ||
: false | ||
: false | ||
) extends never | ||
? true | ||
: false; | ||
export type RecursivelyNormalizeNullableFields<T> = T extends null | undefined | ||
@@ -57,10 +75,10 @@ ? null | undefined | ||
: keyof T extends string | ||
? T extends object | ||
? IsSimpleRecord<T> extends true | ||
? Normalize< | ||
{ | ||
[K in OptionalKeys<T>]?: K extends string | ||
[K in OptionalKeys<T & object>]?: K extends string | ||
? RecursivelyNormalizeNullableFields<NonNullable<T[K]>> | null | undefined | ||
: T[K]; | ||
} & { | ||
[K in RequiredKeys<T>]: RecursivelyNormalizeNullableFields<NonNullable<T[K]>>; | ||
[K in RequiredKeys<T & object>]: RecursivelyNormalizeNullableFields<NonNullable<T[K]>>; | ||
} | ||
@@ -67,0 +85,0 @@ > |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1050318
15709