1- import type { Refs , Symbol } from '@hey-api/codegen-core' ;
1+ import type { Symbol } from '@hey-api/codegen-core' ;
22import type { IR , Plugin , SchemaVisitorContext , SchemaWithType , Walker } from '@hey-api/shared' ;
33
4- import type { MaybeBigInt , ShouldCoerceToBigInt } from '../../../ plugins/shared/utils/coerce' ;
5- import type { GetIntegerLimit } from '../../../ plugins/shared/utils/formats' ;
6- import type { $ , DollarTsDsl } from '../../../ ts-dsl' ;
7- import type { Pipe , PipeResult , Pipes , PipesUtils } from '.. /shared/pipes' ;
8- import type { Ast , IrSchemaToAstOptions , PluginState , ValibotSchemaResult } from '. ./shared/types' ;
9- import type { ValibotPlugin } from '.. /types' ;
4+ import type { MaybeBigInt , ShouldCoerceToBigInt } from '../../plugins/shared/utils/coerce' ;
5+ import type { GetIntegerLimit } from '../../plugins/shared/utils/formats' ;
6+ import type { $ , DollarTsDsl } from '../../ts-dsl' ;
7+ import type { Pipe , PipeResult , Pipes , PipesUtils } from './shared/pipes' ;
8+ import type { ValibotFinal , ValibotResult } from './shared/types' ;
9+ import type { ValibotPlugin } from './types' ;
1010
1111export type Resolvers = Plugin . Resolvers < {
1212 /**
@@ -16,31 +16,31 @@ export type Resolvers = Plugin.Resolvers<{
1616 *
1717 * Returning `undefined` will execute the default resolver logic.
1818 */
19- enum ?: ( ctx : EnumResolverContext ) => PipeResult | undefined ;
19+ enum ?: ( ctx : EnumResolverContext ) => PipeResult ;
2020 /**
2121 * Resolver for number schemas.
2222 *
2323 * Allows customization of how number types are rendered.
2424 *
2525 * Returning `undefined` will execute the default resolver logic.
2626 */
27- number ?: ( ctx : NumberResolverContext ) => PipeResult | undefined ;
27+ number ?: ( ctx : NumberResolverContext ) => PipeResult ;
2828 /**
2929 * Resolver for object schemas.
3030 *
3131 * Allows customization of how object types are rendered.
3232 *
3333 * Returning `undefined` will execute the default resolver logic.
3434 */
35- object ?: ( ctx : ObjectResolverContext ) => PipeResult | undefined ;
35+ object ?: ( ctx : ObjectResolverContext ) => PipeResult ;
3636 /**
3737 * Resolver for string schemas.
3838 *
3939 * Allows customization of how string types are rendered.
4040 *
4141 * Returning `undefined` will execute the default resolver logic.
4242 */
43- string ?: ( ctx : StringResolverContext ) => PipeResult | undefined ;
43+ string ?: ( ctx : StringResolverContext ) => PipeResult ;
4444 /**
4545 * Resolvers for request and response validators.
4646 *
@@ -70,34 +70,35 @@ export type Resolvers = Plugin.Resolvers<{
7070
7171type ValidatorResolver = ( ctx : ValidatorResolverContext ) => PipeResult | null | undefined ;
7272
73- type BaseContext = DollarTsDsl &
74- Pick < IrSchemaToAstOptions , 'plugin' > & {
75- /**
76- * Functions for working with pipes.
77- */
78- pipes : PipesUtils & {
79- /**
80- * The current pipe.
81- *
82- * In Valibot, this represents a list of call expressions ("pipes")
83- * being assembled to form a schema definition.
84- *
85- * Each pipe can be extended, modified, or replaced to customize
86- * the resulting schema.
87- */
88- current : Pipes ;
89- } ;
73+ interface BaseContext extends DollarTsDsl {
74+ /**
75+ * Functions for working with pipes.
76+ */
77+ pipes : PipesUtils & {
9078 /**
91- * Provides access to commonly used symbols within the plugin.
79+ * The current pipe.
80+ *
81+ * In Valibot, this represents a list of call expressions ("pipes")
82+ * being assembled to form a schema definition.
83+ *
84+ * Each pipe can be extended, modified, or replaced to customize
85+ * the resulting schema.
9286 */
93- symbols : {
94- v : Symbol ;
95- } ;
87+ current : Pipes ;
9688 } ;
89+ /** The plugin instance. */
90+ plugin : ValibotPlugin [ 'Instance' ] ;
91+ /**
92+ * Provides access to commonly used symbols within the plugin.
93+ */
94+ symbols : {
95+ v : Symbol ;
96+ } ;
97+ }
9798
9899export interface EnumResolverContext extends BaseContext {
99100 /**
100- * Nodes used to build different parts of the enum schema.
101+ * Nodes used to build different parts of the schema.
101102 */
102103 nodes : {
103104 /**
@@ -119,23 +120,17 @@ export interface EnumResolverContext extends BaseContext {
119120 } ;
120121 } ;
121122 schema : SchemaWithType < 'enum' > ;
122- /**
123- * Utility functions for enum schema processing.
124- */
125- utils : {
126- state : Refs < PluginState > ;
127- } ;
128123}
129124
130125export interface NumberResolverContext extends BaseContext {
131126 /**
132- * Nodes used to build different parts of the number schema.
127+ * Nodes used to build different parts of the schema.
133128 */
134129 nodes : {
135130 base : ( ctx : NumberResolverContext ) => PipeResult ;
136- const : ( ctx : NumberResolverContext ) => PipeResult | undefined ;
137- max : ( ctx : NumberResolverContext ) => PipeResult | undefined ;
138- min : ( ctx : NumberResolverContext ) => PipeResult | undefined ;
131+ const : ( ctx : NumberResolverContext ) => PipeResult ;
132+ max : ( ctx : NumberResolverContext ) => PipeResult ;
133+ min : ( ctx : NumberResolverContext ) => PipeResult ;
139134 } ;
140135 schema : SchemaWithType < 'integer' | 'number' > ;
141136 /**
@@ -149,43 +144,39 @@ export interface NumberResolverContext extends BaseContext {
149144}
150145
151146export interface ObjectResolverContext extends BaseContext {
152- applyModifiers : ( result : ValibotSchemaResult , opts : { optional ?: boolean } ) => Ast ;
147+ _childResults : Array < ValibotResult > ;
148+ applyModifiers : ( result : ValibotResult , opts : { optional ?: boolean } ) => ValibotFinal ;
153149 /**
154- * Nodes used to build different parts of the object schema.
150+ * Nodes used to build different parts of the schema.
155151 */
156152 nodes : {
157- /**
158- * If `additionalProperties` is `false` or `{ type: 'never' }`, returns `null`
159- * to indicate no additional properties are allowed.
160- */
161153 additionalProperties : ( ctx : ObjectResolverContext ) => Pipe | null | undefined ;
162- base : ( ctx : ObjectResolverContext ) => PipeResult ;
154+ base : ( ctx : ObjectResolverContext ) => Pipes | Pipe ;
163155 shape : ( ctx : ObjectResolverContext ) => ReturnType < typeof $ . object > ;
164156 } ;
165157 schema : SchemaWithType < 'object' > ;
166158 /**
167159 * Utility functions for object schema processing.
168160 */
169161 utils : {
170- ast : Partial < Omit < Ast , 'typeName' > > ;
171- state : Refs < PluginState > ;
162+ ast : Partial < { hasLazy : boolean } > ;
172163 } ;
173- walk : Walker < ValibotSchemaResult , ValibotPlugin [ 'Instance' ] > ;
164+ walk : Walker < ValibotResult , ValibotPlugin [ 'Instance' ] > ;
174165 walkerCtx : SchemaVisitorContext < ValibotPlugin [ 'Instance' ] > ;
175166}
176167
177168export interface StringResolverContext extends BaseContext {
178169 /**
179- * Nodes used to build different parts of the string schema.
170+ * Nodes used to build different parts of the schema.
180171 */
181172 nodes : {
182173 base : ( ctx : StringResolverContext ) => PipeResult ;
183- const : ( ctx : StringResolverContext ) => PipeResult | undefined ;
184- format : ( ctx : StringResolverContext ) => PipeResult | undefined ;
185- length : ( ctx : StringResolverContext ) => PipeResult | undefined ;
186- maxLength : ( ctx : StringResolverContext ) => PipeResult | undefined ;
187- minLength : ( ctx : StringResolverContext ) => PipeResult | undefined ;
188- pattern : ( ctx : StringResolverContext ) => PipeResult | undefined ;
174+ const : ( ctx : StringResolverContext ) => PipeResult ;
175+ format : ( ctx : StringResolverContext ) => PipeResult ;
176+ length : ( ctx : StringResolverContext ) => PipeResult ;
177+ maxLength : ( ctx : StringResolverContext ) => PipeResult ;
178+ minLength : ( ctx : StringResolverContext ) => PipeResult ;
179+ pattern : ( ctx : StringResolverContext ) => PipeResult ;
189180 } ;
190181 schema : SchemaWithType < 'string' > ;
191182}
0 commit comments