1- import type { Plugin , SchemaVisitorContext , SchemaWithType , Walker } from '@hey-api/shared' ;
1+ import type { IR , Plugin , SchemaVisitorContext , SchemaWithType , Walker } from '@hey-api/shared' ;
22
33import type { DollarPyDsl } from '../../py-dsl' ;
44import type { PydanticField , PydanticFinal , PydanticResult , PydanticType } from './shared/types' ;
55import type { PydanticPlugin } from './types' ;
66
77export type Resolvers = Plugin . Resolvers < {
8+ /**
9+ * Resolver for array schemas.
10+ *
11+ * Allows customization of how array types are rendered.
12+ *
13+ * Returning `undefined` will execute the default resolver logic.
14+ */
15+ array ?: ( ctx : ArrayResolverContext ) => PydanticType | undefined ;
16+ /**
17+ * Resolver for boolean schemas.
18+ *
19+ * Allows customization of how boolean types are rendered.
20+ *
21+ * Returning `undefined` will execute the default resolver logic.
22+ */
23+ boolean ?: ( ctx : BooleanResolverContext ) => PydanticType | undefined ;
824 /**
925 * Resolver for enum schemas.
1026 *
@@ -13,6 +29,30 @@ export type Resolvers = Plugin.Resolvers<{
1329 * Returning `undefined` will execute the default resolver logic.
1430 */
1531 enum ?: ( ctx : EnumResolverContext ) => PydanticType | undefined ;
32+ /**
33+ * Resolver for intersection schemas.
34+ *
35+ * Allows customization of how intersection types are rendered.
36+ *
37+ * Returning `undefined` will execute the default resolver logic.
38+ */
39+ intersection ?: ( ctx : IntersectionResolverContext ) => PydanticType | undefined ;
40+ /**
41+ * Resolver for never schemas.
42+ *
43+ * Allows customization of how never types are rendered.
44+ *
45+ * Returning `undefined` will execute the default resolver logic.
46+ */
47+ never ?: ( ctx : NeverResolverContext ) => PydanticType | undefined ;
48+ /**
49+ * Resolver for null schemas.
50+ *
51+ * Allows customization of how null types are rendered.
52+ *
53+ * Returning `undefined` will execute the default resolver logic.
54+ */
55+ null ?: ( ctx : NullResolverContext ) => PydanticType | undefined ;
1656 /**
1757 * Resolver for number schemas.
1858 *
@@ -39,13 +79,80 @@ export type Resolvers = Plugin.Resolvers<{
3979 * Returning `undefined` will execute the default resolver logic.
4080 */
4181 string ?: ( ctx : StringResolverContext ) => PydanticType | undefined ;
82+ /**
83+ * Resolver for tuple schemas.
84+ *
85+ * Allows customization of how tuple types are rendered.
86+ *
87+ * Returning `undefined` will execute the default resolver logic.
88+ */
89+ tuple ?: ( ctx : TupleResolverContext ) => PydanticType | undefined ;
90+ /**
91+ * Resolver for undefined schemas.
92+ *
93+ * Allows customization of how undefined types are rendered.
94+ *
95+ * Returning `undefined` will execute the default resolver logic.
96+ */
97+ undefined ?: ( ctx : UndefinedResolverContext ) => PydanticType | undefined ;
98+ /**
99+ * Resolver for union schemas.
100+ *
101+ * Allows customization of how union types are rendered.
102+ *
103+ * Returning `undefined` will execute the default resolver logic.
104+ */
105+ union ?: ( ctx : UnionResolverContext ) => PydanticType | undefined ;
106+ /**
107+ * Resolver for unknown schemas.
108+ *
109+ * Allows customization of how unknown types are rendered.
110+ *
111+ * Returning `undefined` will execute the default resolver logic.
112+ */
113+ unknown ?: ( ctx : UnknownResolverContext ) => PydanticType | undefined ;
114+ /**
115+ * Resolver for void schemas.
116+ *
117+ * Allows customization of how void types are rendered.
118+ *
119+ * Returning `undefined` will execute the default resolver logic.
120+ */
121+ void ?: ( ctx : VoidResolverContext ) => PydanticType | undefined ;
42122} > ;
43123
44124interface BaseContext extends DollarPyDsl {
45125 /** The plugin instance. */
46126 plugin : PydanticPlugin [ 'Instance' ] ;
47127}
48128
129+ export interface ArrayResolverContext extends BaseContext {
130+ applyModifiers : ( result : PydanticResult , opts ?: { optional ?: boolean } ) => PydanticFinal ;
131+ childResults : Array < PydanticResult > ;
132+ /**
133+ * Nodes used to build different parts of the result.
134+ */
135+ nodes : {
136+ base : ( ctx : ArrayResolverContext ) => PydanticType ;
137+ maxLength : ( ctx : ArrayResolverContext ) => PydanticType | undefined ;
138+ minLength : ( ctx : ArrayResolverContext ) => PydanticType | undefined ;
139+ } ;
140+ schema : SchemaWithType < 'array' > ;
141+ walk : Walker < PydanticResult , PydanticPlugin [ 'Instance' ] > ;
142+ walkerCtx : SchemaVisitorContext < PydanticPlugin [ 'Instance' ] > ;
143+ }
144+
145+ export interface BooleanResolverContext extends BaseContext {
146+ /**
147+ * Nodes used to build different parts of the result.
148+ */
149+ nodes : {
150+ base : ( ctx : BooleanResolverContext ) => PydanticType ;
151+ const : ( ctx : BooleanResolverContext ) => PydanticType | undefined ;
152+ } ;
153+ schema : SchemaWithType < 'boolean' > ;
154+ }
155+
49156export interface EnumResolverContext extends BaseContext {
50157 /**
51158 * Nodes used to build different parts of the result.
@@ -60,6 +167,39 @@ export interface EnumResolverContext extends BaseContext {
60167 schema : SchemaWithType < 'enum' > ;
61168}
62169
170+ export interface IntersectionResolverContext extends BaseContext {
171+ applyModifiers : ( result : PydanticResult , opts ?: { optional ?: boolean } ) => PydanticFinal ;
172+ childResults : Array < PydanticResult > ;
173+ /**
174+ * Nodes used to build different parts of the result.
175+ */
176+ nodes : {
177+ base : ( ctx : IntersectionResolverContext ) => PydanticType ;
178+ } ;
179+ parentSchema : IR . SchemaObject ;
180+ schema : IR . SchemaObject ;
181+ }
182+
183+ export interface NeverResolverContext extends BaseContext {
184+ /**
185+ * Nodes used to build different parts of the result.
186+ */
187+ nodes : {
188+ base : ( ctx : NeverResolverContext ) => PydanticType ;
189+ } ;
190+ schema : SchemaWithType < 'never' > ;
191+ }
192+
193+ export interface NullResolverContext extends BaseContext {
194+ /**
195+ * Nodes used to build different parts of the result.
196+ */
197+ nodes : {
198+ base : ( ctx : NullResolverContext ) => PydanticType ;
199+ } ;
200+ schema : SchemaWithType < 'null' > ;
201+ }
202+
63203export interface NumberResolverContext extends BaseContext {
64204 /**
65205 * Nodes used to build different parts of the result.
@@ -97,3 +237,62 @@ export interface StringResolverContext extends BaseContext {
97237 } ;
98238 schema : SchemaWithType < 'string' > ;
99239}
240+
241+ export interface TupleResolverContext extends BaseContext {
242+ applyModifiers : ( result : PydanticResult , opts ?: { optional ?: boolean } ) => PydanticFinal ;
243+ childResults : Array < PydanticResult > ;
244+ /**
245+ * Nodes used to build different parts of the result.
246+ */
247+ nodes : {
248+ base : ( ctx : TupleResolverContext ) => PydanticType ;
249+ const : ( ctx : TupleResolverContext ) => PydanticType | undefined ;
250+ } ;
251+ schema : SchemaWithType < 'tuple' > ;
252+ walk : Walker < PydanticResult , PydanticPlugin [ 'Instance' ] > ;
253+ walkerCtx : SchemaVisitorContext < PydanticPlugin [ 'Instance' ] > ;
254+ }
255+
256+ export interface UndefinedResolverContext extends BaseContext {
257+ /**
258+ * Nodes used to build different parts of the result.
259+ */
260+ nodes : {
261+ base : ( ctx : UndefinedResolverContext ) => PydanticType ;
262+ } ;
263+ schema : SchemaWithType < 'undefined' > ;
264+ }
265+
266+ export interface UnionResolverContext extends BaseContext {
267+ applyModifiers : ( result : PydanticResult , opts ?: { optional ?: boolean } ) => PydanticFinal ;
268+ childResults : Array < PydanticResult > ;
269+ /**
270+ * Nodes used to build different parts of the result.
271+ */
272+ nodes : {
273+ base : ( ctx : UnionResolverContext ) => PydanticType ;
274+ } ;
275+ parentSchema : IR . SchemaObject ;
276+ schema : IR . SchemaObject ;
277+ schemas : ReadonlyArray < IR . SchemaObject > ;
278+ }
279+
280+ export interface UnknownResolverContext extends BaseContext {
281+ /**
282+ * Nodes used to build different parts of the result.
283+ */
284+ nodes : {
285+ base : ( ctx : UnknownResolverContext ) => PydanticType ;
286+ } ;
287+ schema : SchemaWithType < 'unknown' > ;
288+ }
289+
290+ export interface VoidResolverContext extends BaseContext {
291+ /**
292+ * Nodes used to build different parts of the result.
293+ */
294+ nodes : {
295+ base : ( ctx : VoidResolverContext ) => PydanticType ;
296+ } ;
297+ schema : SchemaWithType < 'void' > ;
298+ }
0 commit comments