@@ -11,7 +11,7 @@ import {
11
11
type ZodNumber ,
12
12
ZodObject ,
13
13
type ZodRawShape ,
14
- type ZodReadonly ,
14
+ ZodReadonly ,
15
15
type ZodString ,
16
16
ZodTuple ,
17
17
type ZodTypeAny ,
@@ -66,14 +66,16 @@ function isWrappedFieldSchema(schema: FieldSchema): schema is WrappedFieldSchema
66
66
return false ;
67
67
}
68
68
69
- return schema instanceof ZodLazy || schema instanceof ZodEffects || schema instanceof ZodNullable ;
69
+ return schema instanceof ZodLazy || schema instanceof ZodEffects || schema instanceof ZodNullable ||
70
+ schema instanceof ZodReadonly ;
70
71
}
71
72
72
73
type UnwrappedChainResult = {
73
74
unwrappedSchema : NonWrappedFieldSchema ;
74
75
wrapperElements : WrappedFieldSchema [ ] ;
75
76
} ;
76
77
78
+ // eslint-disable-next-line max-statements,complexity -- no idea how to refactor for now
77
79
function recursiveUnwrapFieldSchemaChain (
78
80
parent : FieldSchema ,
79
81
currentChain : WrappedFieldSchema [ ]
@@ -93,6 +95,8 @@ function recursiveUnwrapFieldSchemaChain(
93
95
unwrapped = parent . innerType ( ) ;
94
96
} else if ( parent instanceof ZodNullable ) {
95
97
unwrapped = parent . unwrap ( ) ;
98
+ } else if ( parent instanceof ZodReadonly ) {
99
+ unwrapped = parent . unwrap ( ) ;
96
100
}
97
101
98
102
if ( isWrappedFieldSchema ( unwrapped ) ) {
@@ -115,7 +119,7 @@ export function unwrapFieldSchema(parent: FieldSchema): NonWrappedFieldSchema {
115
119
}
116
120
117
121
type QueryShape = Record < string , FieldSchema > ;
118
- export type QuerySchema = StrictObjectSchema < QueryShape > ;
122
+ export type QuerySchema = StrictObjectSchema < QueryShape > | ZodReadonly < StrictObjectSchema < QueryShape > > ;
119
123
120
124
export type FieldSchemaTuple < Schema extends FieldSchema > = ZodTuple < [ Schema , ...Schema [ ] ] , Schema | null > ;
121
125
0 commit comments