@kubb/plugin-zod 5.0.0-beta.81 → 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.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/core";
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 & OperationParamsResolver & {
246
- /**
247
- * Resolves a camelCase schema function name with a `Schema` suffix.
248
- */
249
- resolveSchemaName(this: ResolverZod, name: string): string;
250
- /**
251
- * Resolves the schema type name (inferred type from schema).
252
- *
253
- * @example Schema type names
254
- * `resolver.resolveSchemaTypeName('pet') // 'PetSchemaType'`
255
- */
256
- resolveSchemaTypeName(this: ResolverZod, name: string): string;
257
- /**
258
- * Resolves the schema function name for the request (input) direction of a
259
- * date-bearing component, where `Date` is encoded back to a wire `string`.
260
- *
261
- * @example Input schema names
262
- * `resolver.resolveInputSchemaName('order') // → 'orderInputSchema'`
263
- */
264
- resolveInputSchemaName(this: ResolverZod, name: string): string;
265
- /**
266
- * Resolves the inferred type name for the request (input) direction variant.
267
- *
268
- * @example Input schema type names
269
- * `resolver.resolveInputSchemaTypeName('order') // 'OrderInputSchemaType'`
270
- */
271
- resolveInputSchemaTypeName(this: ResolverZod, name: string): string;
272
- /**
273
- * Resolves the generated type name from the schema.
274
- *
275
- * @example Type names
276
- * `resolver.resolveTypeName('petSchema') // 'PetSchemaType'`
277
- */
278
- resolveTypeName(this: ResolverZod, name: string): string;
279
- /**
280
- * Resolves the output file name for a schema.
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
- * Resolves the name for an operation's grouped query parameters type.
321
- *
322
- * @example Query parameters names
323
- * `resolver.resolveQueryParamsName(node, param) // → 'findPetsByStatusQueryStatusSchema'`
324
- */
325
- resolveQueryParamsName(this: ResolverZod, node: ast.OperationNode, param: ast.ParameterNode): string;
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
- * Resolves the name for an operation's grouped header parameters type.
328
- *
329
- * @example Header parameters names
330
- * `resolver.resolveHeaderParamsName(node, param) // → 'deletePetHeaderApiKeySchema'`
331
- */
332
- resolveHeaderParamsName(this: ResolverZod, node: ast.OperationNode, param: ast.ParameterNode): string;
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?: Partial<ResolverZod> & ThisType<ResolverZod>;
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.
@@ -451,7 +432,7 @@ declare global {
451
432
  * When `mini: true`, schemas use the Zod Mini functional API instead of
452
433
  * chainable methods.
453
434
  */
454
- declare const zodGenerator: import("@kubb/core").Generator<PluginZod, unknown>;
435
+ declare const zodGenerator: import("kubb/kit").Generator<PluginZod, unknown>;
455
436
  //#endregion
456
437
  //#region src/plugin.d.ts
457
438
  /**
@@ -468,7 +449,7 @@ declare const pluginZodName = "plugin-zod";
468
449
  *
469
450
  * @example
470
451
  * ```ts
471
- * import { defineConfig } from 'kubb'
452
+ * import { defineConfig } from 'kubb/config'
472
453
  * import { pluginTs } from '@kubb/plugin-ts'
473
454
  * import { pluginZod } from '@kubb/plugin-zod'
474
455
  *
@@ -485,7 +466,7 @@ declare const pluginZodName = "plugin-zod";
485
466
  * })
486
467
  * ```
487
468
  */
488
- declare const pluginZod: (options?: Options | undefined) => import("@kubb/core").Plugin<PluginZod>;
469
+ declare const pluginZod: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginZod>;
489
470
  //#endregion
490
471
  //#region src/resolvers/resolverZod.d.ts
491
472
  /**
@@ -499,8 +480,8 @@ declare const pluginZod: (options?: Options | undefined) => import("@kubb/core")
499
480
  * ```ts
500
481
  * import { resolverZod } from '@kubb/plugin-zod'
501
482
  *
502
- * resolverZod.default('list pets', 'function') // 'listPetsSchema'
503
- * resolverZod.resolveSchemaTypeName('pet') // 'PetSchemaType'
483
+ * resolverZod.name('list pets') // 'listPetsSchema'
484
+ * resolverZod.schema.typeName('pet') // 'PetSchemaType'
504
485
  * ```
505
486
  */
506
487
  declare const resolverZod: ResolverZod;