@@ -38,6 +38,7 @@ import type {
3838 NullableIf ,
3939 Optional ,
4040 OrArray ,
41+ PartialIf ,
4142 Simplify ,
4243 ValueOfPotentialTuple ,
4344 WrapType ,
@@ -246,17 +247,31 @@ export type SimplifiedModelResult<
246247 Array = false ,
247248> = Simplify < ModelResult < Schema , Model , Options , Args , Optional , Array > > ;
248249
249- export type TypeDefResult < Schema extends SchemaDef , TypeDef extends GetTypeDefs < Schema > > = Optional <
250- {
251- [ Key in GetTypeDefFields < Schema , TypeDef > ] : MapTypeDefFieldType < Schema , TypeDef , Key > ;
252- } ,
253- // optionality
254- keyof {
255- [ Key in GetTypeDefFields < Schema , TypeDef > as TypeDefFieldIsOptional < Schema , TypeDef , Key > extends true
256- ? Key
257- : never ] : true ;
258- }
259- > ;
250+ export type TypeDefResult <
251+ Schema extends SchemaDef ,
252+ TypeDef extends GetTypeDefs < Schema > ,
253+ Partial extends boolean = false ,
254+ > = PartialIf <
255+ Optional <
256+ {
257+ [ Key in GetTypeDefFields < Schema , TypeDef > ] : MapFieldDefType <
258+ Schema ,
259+ GetTypeDefField < Schema , TypeDef , Key > ,
260+ Partial
261+ > ;
262+ } ,
263+ // optionality
264+ Partial extends true
265+ ? never
266+ : keyof {
267+ [ Key in GetTypeDefFields < Schema , TypeDef > as TypeDefFieldIsOptional < Schema , TypeDef , Key > extends true
268+ ? Key
269+ : never ] : true ;
270+ }
271+ > ,
272+ Partial
273+ > &
274+ Record < string , unknown > ;
260275
261276export type BatchResult = { count : number } ;
262277
@@ -617,17 +632,15 @@ type MapModelFieldType<
617632 Field extends GetModelFields < Schema , Model > ,
618633> = MapFieldDefType < Schema , GetModelField < Schema , Model , Field > > ;
619634
620- type MapTypeDefFieldType <
635+ type MapFieldDefType <
621636 Schema extends SchemaDef ,
622- TypeDef extends GetTypeDefs < Schema > ,
623- Field extends GetTypeDefFields < Schema , TypeDef > ,
624- > = MapFieldDefType < Schema , GetTypeDefField < Schema , TypeDef , Field > > ;
625-
626- type MapFieldDefType < Schema extends SchemaDef , T extends Pick < FieldDef , 'type' | 'optional' | 'array' > > = WrapType <
637+ T extends Pick < FieldDef , 'type' | 'optional' | 'array' > ,
638+ Partial extends boolean = false ,
639+ > = WrapType <
627640 T [ 'type' ] extends GetEnums < Schema >
628641 ? keyof GetEnum < Schema , T [ 'type' ] >
629642 : T [ 'type' ] extends GetTypeDefs < Schema >
630- ? TypeDefResult < Schema , T [ 'type' ] > & Record < string , unknown >
643+ ? TypeDefResult < Schema , T [ 'type' ] , Partial > & Record < string , unknown >
631644 : MapBaseType < T [ 'type' ] > ,
632645 T [ 'optional' ] ,
633646 T [ 'array' ]
0 commit comments