@kubb/plugin-zod 5.0.0-beta.84 → 5.0.0-beta.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +280 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +118 -137
- package/dist/index.js +281 -138
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "kubb/kit";
|
|
2
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
3
3
|
import { AdapterOas } from "@kubb/adapter-oas";
|
|
4
4
|
|
|
5
|
-
//#region ../../internals/shared/src/operation.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Resolver interface for building operation parameters.
|
|
8
|
-
*
|
|
9
|
-
* `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
|
|
10
|
-
*/
|
|
11
|
-
type OperationParamsResolver = {
|
|
12
|
-
/**
|
|
13
|
-
* Resolves the type name for an individual parameter.
|
|
14
|
-
*
|
|
15
|
-
* @example Individual path parameter name
|
|
16
|
-
* `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
|
|
17
|
-
*/
|
|
18
|
-
resolveParamName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
19
|
-
/**
|
|
20
|
-
* Resolves the request body type name.
|
|
21
|
-
*
|
|
22
|
-
* @example Request body type name
|
|
23
|
-
* `resolver.resolveDataName(node) // → 'CreatePetData'`
|
|
24
|
-
*/
|
|
25
|
-
resolveDataName(node: ast.OperationNode): string;
|
|
26
|
-
/**
|
|
27
|
-
* Resolves the grouped path parameters type name.
|
|
28
|
-
* When the return value equals `resolveParamName`, no indexed access is emitted.
|
|
29
|
-
*
|
|
30
|
-
* @example Grouped path params type name
|
|
31
|
-
* `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
|
|
32
|
-
*/
|
|
33
|
-
resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
34
|
-
/**
|
|
35
|
-
* Resolves the grouped query parameters type name.
|
|
36
|
-
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
37
|
-
*
|
|
38
|
-
* @example Grouped query params type name
|
|
39
|
-
* `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
|
|
40
|
-
*/
|
|
41
|
-
resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
42
|
-
/**
|
|
43
|
-
* Resolves the grouped header parameters type name.
|
|
44
|
-
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
45
|
-
*
|
|
46
|
-
* @example Grouped header params type name
|
|
47
|
-
* `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
|
|
48
|
-
*/
|
|
49
|
-
resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
50
|
-
};
|
|
51
|
-
//#endregion
|
|
52
5
|
//#region src/printers/printerZod.d.ts
|
|
53
6
|
/**
|
|
54
7
|
* Partial map of node-type overrides for the Zod printer.
|
|
@@ -241,95 +194,123 @@ declare const printerZodMini: (options?: PrinterZodMiniOptions | undefined) => a
|
|
|
241
194
|
//#region src/types.d.ts
|
|
242
195
|
/**
|
|
243
196
|
* Resolver for Zod that provides naming methods for schema types.
|
|
197
|
+
*
|
|
198
|
+
* The top-level `name` resolves a camelCase schema function name with a `Schema` suffix
|
|
199
|
+
* (`listPetsSchema`), and `file` casts generated file names the same way. Composite naming lives in
|
|
200
|
+
* the `schema`, `param`, and `response` namespaces.
|
|
244
201
|
*/
|
|
245
|
-
type ResolverZod = Resolver &
|
|
246
|
-
/**
|
|
247
|
-
*
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
*/
|
|
282
|
-
resolvePathName(this: ResolverZod, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
283
|
-
/**
|
|
284
|
-
* Resolves the name for an operation response by status code.
|
|
285
|
-
*
|
|
286
|
-
* @example Response status names
|
|
287
|
-
* `resolver.resolveResponseStatusName(node, 200) // → 'listPetsStatus200Schema'`
|
|
288
|
-
*/
|
|
289
|
-
resolveResponseStatusName(this: ResolverZod, node: ast.OperationNode, statusCode: ast.StatusCode): string;
|
|
290
|
-
/**
|
|
291
|
-
* Resolves the name for the collection of all operation responses.
|
|
292
|
-
*
|
|
293
|
-
* @example Responses collection names
|
|
294
|
-
* `resolver.resolveResponsesName(node) // → 'listPetsResponsesSchema'`
|
|
295
|
-
*/
|
|
296
|
-
resolveResponsesName(this: ResolverZod, node: ast.OperationNode): string;
|
|
297
|
-
/**
|
|
298
|
-
* Resolves the name for the union of all operation responses.
|
|
299
|
-
*
|
|
300
|
-
* @example Response union names
|
|
301
|
-
* `resolver.resolveResponseName(node) // → 'listPetsResponseSchema'`
|
|
302
|
-
*/
|
|
303
|
-
resolveResponseName(this: ResolverZod, node: ast.OperationNode): string;
|
|
304
|
-
/**
|
|
305
|
-
* Resolves the name for the union of an operation's error (non-2xx) responses. Generated clients
|
|
306
|
-
* validate the error body against this on the non-throw path.
|
|
307
|
-
*
|
|
308
|
-
* @example Error union names
|
|
309
|
-
* `resolver.resolveErrorName(node) // → 'listPetsErrorSchema'`
|
|
310
|
-
*/
|
|
311
|
-
resolveErrorName(this: ResolverZod, node: ast.OperationNode): string;
|
|
312
|
-
/**
|
|
313
|
-
* Resolves the name for an operation's grouped path parameters type.
|
|
314
|
-
*
|
|
315
|
-
* @example Path parameters names
|
|
316
|
-
* `resolver.resolvePathParamsName(node, param) // → 'deletePetPathPetIdSchema'`
|
|
317
|
-
*/
|
|
318
|
-
resolvePathParamsName(this: ResolverZod, node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
202
|
+
type ResolverZod = Resolver & {
|
|
203
|
+
/**
|
|
204
|
+
* Names derived from a component schema: its inferred types and the request (input) direction
|
|
205
|
+
* variant, where a date-bearing component encodes `Date` back to a wire `string`.
|
|
206
|
+
*/
|
|
207
|
+
schema: {
|
|
208
|
+
/**
|
|
209
|
+
* Resolves the schema type name (inferred type from schema).
|
|
210
|
+
*
|
|
211
|
+
* @example Schema type names
|
|
212
|
+
* `resolver.schema.typeName('pet') // → 'PetSchemaType'`
|
|
213
|
+
*/
|
|
214
|
+
typeName(name: string): string;
|
|
215
|
+
/**
|
|
216
|
+
* Resolves the generated type name from the schema.
|
|
217
|
+
*
|
|
218
|
+
* @example Type names
|
|
219
|
+
* `resolver.schema.type('petSchema') // → 'PetSchemaType'`
|
|
220
|
+
*/
|
|
221
|
+
type(name: string): string;
|
|
222
|
+
/**
|
|
223
|
+
* Resolves the schema function name for the request (input) direction of a
|
|
224
|
+
* date-bearing component, where `Date` is encoded back to a wire `string`.
|
|
225
|
+
*
|
|
226
|
+
* @example Input schema names
|
|
227
|
+
* `resolver.schema.inputName('order') // → 'orderInputSchema'`
|
|
228
|
+
*/
|
|
229
|
+
inputName(name: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Resolves the inferred type name for the request (input) direction variant.
|
|
232
|
+
*
|
|
233
|
+
* @example Input schema type names
|
|
234
|
+
* `resolver.schema.inputTypeName('order') // → 'OrderInputSchemaType'`
|
|
235
|
+
*/
|
|
236
|
+
inputTypeName(name: string): string;
|
|
237
|
+
};
|
|
319
238
|
/**
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
239
|
+
* Names for an operation's parameters: an individual parameter and the grouped path, query, and
|
|
240
|
+
* header schemas.
|
|
241
|
+
*/
|
|
242
|
+
param: {
|
|
243
|
+
/**
|
|
244
|
+
* Resolves the schema name for an individual parameter.
|
|
245
|
+
*
|
|
246
|
+
* @example Individual parameter name
|
|
247
|
+
* `resolver.param.name(node, param) // → 'deletePetPathPetIdSchema'`
|
|
248
|
+
*/
|
|
249
|
+
name(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
250
|
+
/**
|
|
251
|
+
* Resolves the name for an operation's grouped path parameters schema.
|
|
252
|
+
*
|
|
253
|
+
* @example Path parameters names
|
|
254
|
+
* `resolver.param.path(node, param) // → 'deletePetPathPetIdSchema'`
|
|
255
|
+
*/
|
|
256
|
+
path(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
257
|
+
/**
|
|
258
|
+
* Resolves the name for an operation's grouped query parameters schema.
|
|
259
|
+
*
|
|
260
|
+
* @example Query parameters names
|
|
261
|
+
* `resolver.param.query(node, param) // → 'findPetsByStatusQueryStatusSchema'`
|
|
262
|
+
*/
|
|
263
|
+
query(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
264
|
+
/**
|
|
265
|
+
* Resolves the name for an operation's grouped header parameters schema.
|
|
266
|
+
*
|
|
267
|
+
* @example Header parameters names
|
|
268
|
+
* `resolver.param.headers(node, param) // → 'deletePetHeaderApiKeySchema'`
|
|
269
|
+
*/
|
|
270
|
+
headers(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
271
|
+
};
|
|
326
272
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
273
|
+
* Names for an operation's responses: per-status schemas, the request body, and the combined,
|
|
274
|
+
* union, and error names.
|
|
275
|
+
*/
|
|
276
|
+
response: {
|
|
277
|
+
/**
|
|
278
|
+
* Resolves the name for an operation response by status code.
|
|
279
|
+
*
|
|
280
|
+
* @example Response status names
|
|
281
|
+
* `resolver.response.status(node, 200) // → 'listPetsStatus200Schema'`
|
|
282
|
+
*/
|
|
283
|
+
status(node: ast.OperationNode, statusCode: ast.StatusCode): string;
|
|
284
|
+
/**
|
|
285
|
+
* Resolves the request body schema name.
|
|
286
|
+
*
|
|
287
|
+
* @example Request body names
|
|
288
|
+
* `resolver.response.body(node) // → 'createPetBodySchema'`
|
|
289
|
+
*/
|
|
290
|
+
body(node: ast.OperationNode): string;
|
|
291
|
+
/**
|
|
292
|
+
* Resolves the name for the collection of all operation responses.
|
|
293
|
+
*
|
|
294
|
+
* @example Responses collection names
|
|
295
|
+
* `resolver.response.responses(node) // → 'listPetsResponsesSchema'`
|
|
296
|
+
*/
|
|
297
|
+
responses(node: ast.OperationNode): string;
|
|
298
|
+
/**
|
|
299
|
+
* Resolves the name for the union of all operation responses.
|
|
300
|
+
*
|
|
301
|
+
* @example Response union names
|
|
302
|
+
* `resolver.response.response(node) // → 'listPetsResponseSchema'`
|
|
303
|
+
*/
|
|
304
|
+
response(node: ast.OperationNode): string;
|
|
305
|
+
/**
|
|
306
|
+
* Resolves the name for the union of an operation's error (non-2xx) responses. Generated clients
|
|
307
|
+
* validate the error body against this on the non-throw path.
|
|
308
|
+
*
|
|
309
|
+
* @example Error union names
|
|
310
|
+
* `resolver.response.error(node) // → 'listPetsErrorSchema'`
|
|
311
|
+
*/
|
|
312
|
+
error(node: ast.OperationNode): string;
|
|
313
|
+
};
|
|
333
314
|
};
|
|
334
315
|
/**
|
|
335
316
|
* Where the generated Zod schemas are written and how they are exported, plus the optional
|
|
@@ -408,7 +389,7 @@ type Options = OutputOptions & {
|
|
|
408
389
|
* Override how schema and operation names are built. Methods you omit fall back
|
|
409
390
|
* to the default `resolverZod`.
|
|
410
391
|
*/
|
|
411
|
-
resolver?:
|
|
392
|
+
resolver?: ResolverPatch<ResolverZod>;
|
|
412
393
|
/**
|
|
413
394
|
* Replace the Zod handler for a specific schema type (`'integer'`, `'date'`, ...).
|
|
414
395
|
* When `mini: true`, overrides target the Zod Mini printer instead.
|
|
@@ -499,8 +480,8 @@ declare const pluginZod: (options?: Options | undefined) => import("kubb/kit").P
|
|
|
499
480
|
* ```ts
|
|
500
481
|
* import { resolverZod } from '@kubb/plugin-zod'
|
|
501
482
|
*
|
|
502
|
-
* resolverZod.
|
|
503
|
-
* resolverZod.
|
|
483
|
+
* resolverZod.name('list pets') // 'listPetsSchema'
|
|
484
|
+
* resolverZod.schema.typeName('pet') // 'PetSchemaType'
|
|
504
485
|
* ```
|
|
505
486
|
*/
|
|
506
487
|
declare const resolverZod: ResolverZod;
|