@kubb/plugin-zod 5.0.0-alpha.3 → 5.0.0-alpha.30
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 +1619 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +418 -4
- package/dist/index.js +1614 -100
- package/dist/index.js.map +1 -1
- package/package.json +6 -34
- package/src/components/Operations.tsx +22 -15
- package/src/components/Zod.tsx +20 -119
- package/src/constants.ts +5 -0
- package/src/generators/zodGenerator.tsx +129 -159
- package/src/generators/zodGeneratorLegacy.tsx +365 -0
- package/src/index.ts +12 -1
- package/src/plugin.ts +102 -148
- package/src/presets.ts +30 -0
- package/src/printers/printerZod.ts +298 -0
- package/src/printers/printerZodMini.ts +273 -0
- package/src/resolvers/resolverZod.ts +61 -0
- package/src/resolvers/resolverZodLegacy.ts +60 -0
- package/src/types.ts +172 -93
- package/src/utils.ts +248 -0
- package/dist/components-B7zUFnAm.cjs +0 -890
- package/dist/components-B7zUFnAm.cjs.map +0 -1
- package/dist/components-eECfXVou.js +0 -842
- package/dist/components-eECfXVou.js.map +0 -1
- package/dist/components.cjs +0 -4
- package/dist/components.d.ts +0 -56
- package/dist/components.js +0 -2
- package/dist/generators-CRKtFRi1.js +0 -290
- package/dist/generators-CRKtFRi1.js.map +0 -1
- package/dist/generators-CzSLRVqQ.cjs +0 -301
- package/dist/generators-CzSLRVqQ.cjs.map +0 -1
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -503
- package/dist/generators.js +0 -2
- package/dist/templates/ToZod.source.cjs +0 -7
- package/dist/templates/ToZod.source.cjs.map +0 -1
- package/dist/templates/ToZod.source.d.ts +0 -7
- package/dist/templates/ToZod.source.js +0 -6
- package/dist/templates/ToZod.source.js.map +0 -1
- package/dist/types-D0wsPC6Y.d.ts +0 -172
- package/src/components/index.ts +0 -2
- package/src/generators/index.ts +0 -2
- package/src/generators/operationsGenerator.tsx +0 -50
- package/src/parser.ts +0 -909
- package/src/templates/ToZod.source.ts +0 -4
- package/templates/ToZod.ts +0 -61
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,424 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as _$_kubb_ast0 from "@kubb/ast";
|
|
3
|
+
import { OperationParamsResolver } from "@kubb/ast";
|
|
4
|
+
import * as _$_kubb_core0 from "@kubb/core";
|
|
5
|
+
import { CompatibilityPreset, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, PrinterFactoryOptions, PrinterPartial, ResolvePathOptions, Resolver, UserGroup } from "@kubb/core";
|
|
6
|
+
import { OperationNode, ParameterNode, SchemaNode, StatusCode, Visitor } from "@kubb/ast/types";
|
|
4
7
|
|
|
8
|
+
//#region src/printers/printerZod.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Partial map of node-type overrides for the Zod printer.
|
|
11
|
+
*
|
|
12
|
+
* Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function
|
|
13
|
+
* replaces the built-in handler for that node type. Use `this.transform` to
|
|
14
|
+
* recurse into nested schema nodes, and `this.options` to read printer options.
|
|
15
|
+
*
|
|
16
|
+
* @example Override the `date` handler
|
|
17
|
+
* ```ts
|
|
18
|
+
* pluginZod({
|
|
19
|
+
* printer: {
|
|
20
|
+
* nodes: {
|
|
21
|
+
* date(node) {
|
|
22
|
+
* return 'z.string().date()'
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
type PrinterZodNodes = PrinterPartial<string, PrinterZodOptions>;
|
|
30
|
+
type PrinterZodOptions = {
|
|
31
|
+
coercion?: PluginZod['resolvedOptions']['coercion'];
|
|
32
|
+
guidType?: PluginZod['resolvedOptions']['guidType'];
|
|
33
|
+
wrapOutput?: PluginZod['resolvedOptions']['wrapOutput'];
|
|
34
|
+
resolver?: ResolverZod;
|
|
35
|
+
schemaName?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Property keys to exclude from the generated object schema via `.omit({ key: true })`.
|
|
38
|
+
*/
|
|
39
|
+
keysToOmit?: Array<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Partial map of node-type overrides. Each entry replaces the built-in handler for that node type.
|
|
42
|
+
*/
|
|
43
|
+
nodes?: PrinterZodNodes;
|
|
44
|
+
};
|
|
45
|
+
type PrinterZodFactory = PrinterFactoryOptions<'zod', PrinterZodOptions, string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Zod v4 printer built with `definePrinter`.
|
|
48
|
+
*
|
|
49
|
+
* Converts a `SchemaNode` AST into a **standard** Zod v4 code string
|
|
50
|
+
* using the chainable method API (`.optional()`, `.nullable()`, etc.).
|
|
51
|
+
*
|
|
52
|
+
* For the `zod/mini` functional API, see {@link printerZodMini}.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const printer = printerZod({ coercion: false })
|
|
57
|
+
* const code = printer.print(stringSchemaNode) // "z.string()"
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare const printerZod: (options?: PrinterZodOptions | undefined) => _$_kubb_ast0.Printer<PrinterZodFactory>;
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/printers/printerZodMini.d.ts
|
|
63
|
+
/**
|
|
64
|
+
* Partial map of node-type overrides for the Zod Mini printer.
|
|
65
|
+
*
|
|
66
|
+
* Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function
|
|
67
|
+
* replaces the built-in handler for that node type. Use `this.transform` to
|
|
68
|
+
* recurse into nested schema nodes, and `this.options` to read printer options.
|
|
69
|
+
*
|
|
70
|
+
* @example Override the `date` handler
|
|
71
|
+
* ```ts
|
|
72
|
+
* pluginZod({
|
|
73
|
+
* mini: true,
|
|
74
|
+
* printer: {
|
|
75
|
+
* nodes: {
|
|
76
|
+
* date(node) {
|
|
77
|
+
* return 'z.iso.date()'
|
|
78
|
+
* },
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
type PrinterZodMiniNodes = PrinterPartial<string, PrinterZodMiniOptions>;
|
|
85
|
+
type PrinterZodMiniOptions = {
|
|
86
|
+
guidType?: PluginZod['resolvedOptions']['guidType'];
|
|
87
|
+
wrapOutput?: PluginZod['resolvedOptions']['wrapOutput'];
|
|
88
|
+
resolver?: ResolverZod;
|
|
89
|
+
schemaName?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Property keys to exclude from the generated object schema via `.omit({ key: true })`.
|
|
92
|
+
*/
|
|
93
|
+
keysToOmit?: Array<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Partial map of node-type overrides. Each entry replaces the built-in handler for that node type.
|
|
96
|
+
*/
|
|
97
|
+
nodes?: PrinterZodMiniNodes;
|
|
98
|
+
};
|
|
99
|
+
type PrinterZodMiniFactory = PrinterFactoryOptions<'zod-mini', PrinterZodMiniOptions, string, string>;
|
|
100
|
+
/**
|
|
101
|
+
* Zod v4 **Mini** printer built with `definePrinter`.
|
|
102
|
+
*
|
|
103
|
+
* Converts a `SchemaNode` AST into a Zod v4 Mini code string using the
|
|
104
|
+
* functional API (`z.optional(z.string())`) for better tree-shaking.
|
|
105
|
+
*
|
|
106
|
+
* For the standard chainable API, see {@link printerZod}.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const printer = printerZodMini({})
|
|
111
|
+
* const code = printer.print(optionalStringNode) // "z.optional(z.string())"
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare const printerZodMini: (options?: PrinterZodMiniOptions | undefined) => _$_kubb_ast0.Printer<PrinterZodMiniFactory>;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/types.d.ts
|
|
117
|
+
/**
|
|
118
|
+
* The concrete resolver type for `@kubb/plugin-zod`.
|
|
119
|
+
* Extends the base `Resolver` with zod-specific naming helpers.
|
|
120
|
+
*/
|
|
121
|
+
type ResolverZod = Resolver & OperationParamsResolver & {
|
|
122
|
+
/**
|
|
123
|
+
* Resolves a camelCase schema function name with a `Schema` suffix.
|
|
124
|
+
*/
|
|
125
|
+
resolveSchemaName(this: ResolverZod, name: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Resolves the name for a `z.infer<typeof ...>` type export.
|
|
128
|
+
* Strips the trailing `Schema` suffix (added by `resolveSchemaName`) before PascalCasing.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* resolver.resolveSchemaTypeName('pet) // → 'PetSchema'
|
|
132
|
+
* resolver.resolveSchemaTypeName('addPet200') // → 'AddPet200Schema'
|
|
133
|
+
* resolver.resolveSchemaTypeName('PetName') // → 'PetNameSchema'
|
|
134
|
+
*/
|
|
135
|
+
resolveSchemaTypeName(this: ResolverZod, name: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* Resolves the name for a `z.infer<typeof ...>` type export.
|
|
138
|
+
* Strips the trailing `Schema` suffix (added by `resolveSchemaName`) before PascalCasing.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* resolver.resolveTypeName('pet') // → 'Pet'
|
|
142
|
+
* resolver.resolveTypeName('addPet200') // → 'AddPet200'
|
|
143
|
+
* resolver.resolveTypeName('PetName') // → 'PetName'
|
|
144
|
+
*/
|
|
145
|
+
resolveTypeName(this: ResolverZod, name: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* Resolves a PascalCase path/file name for the generated output.
|
|
148
|
+
*/
|
|
149
|
+
resolvePathName(this: ResolverZod, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
150
|
+
/**
|
|
151
|
+
* Resolves the name for an operation response by status code.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* resolver.resolveResponseStatusName(node, 200) // → 'listPetsStatus200Schema'
|
|
155
|
+
*/
|
|
156
|
+
resolveResponseStatusName(this: ResolverZod, node: OperationNode, statusCode: StatusCode): string;
|
|
157
|
+
/**
|
|
158
|
+
* Resolves the name for the collection of all operation responses.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* resolver.resolveResponsesName(node) // → 'listPetsResponsesSchema'
|
|
162
|
+
*/
|
|
163
|
+
resolveResponsesName(this: ResolverZod, node: OperationNode): string;
|
|
164
|
+
/**
|
|
165
|
+
* Resolves the name for the union of all operation responses.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* resolver.resolveResponseName(node) // → 'listPetsResponseSchema'
|
|
169
|
+
*/
|
|
170
|
+
resolveResponseName(this: ResolverZod, node: OperationNode): string;
|
|
171
|
+
/**
|
|
172
|
+
* Resolves the name for an operation's grouped path parameters type.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* resolver.resolvePathParamsName(node, param) // → 'deletePetPathPetIdSchema'
|
|
176
|
+
*/
|
|
177
|
+
resolvePathParamsName(this: ResolverZod, node: OperationNode, param: ParameterNode): string;
|
|
178
|
+
/**
|
|
179
|
+
* Resolves the name for an operation's grouped query parameters type.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* resolver.resolveQueryParamsName(node, param) // → 'findPetsByStatusQueryStatusSchema'
|
|
183
|
+
*/
|
|
184
|
+
resolveQueryParamsName(this: ResolverZod, node: OperationNode, param: ParameterNode): string;
|
|
185
|
+
/**
|
|
186
|
+
* Resolves the name for an operation's grouped header parameters type.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* resolver.resolveHeaderParamsName(node, param) // → 'deletePetHeaderApiKeySchema'
|
|
190
|
+
*/
|
|
191
|
+
resolveHeaderParamsName(this: ResolverZod, node: OperationNode, param: ParameterNode): string;
|
|
192
|
+
};
|
|
193
|
+
type Options = {
|
|
194
|
+
/**
|
|
195
|
+
* @default 'zod'
|
|
196
|
+
*/
|
|
197
|
+
output?: Output;
|
|
198
|
+
/**
|
|
199
|
+
* Group the Zod schemas based on the provided name.
|
|
200
|
+
*/
|
|
201
|
+
group?: UserGroup;
|
|
202
|
+
/**
|
|
203
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
204
|
+
*/
|
|
205
|
+
exclude?: Array<Exclude>;
|
|
206
|
+
/**
|
|
207
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
208
|
+
*/
|
|
209
|
+
include?: Array<Include>;
|
|
210
|
+
/**
|
|
211
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
212
|
+
*/
|
|
213
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
214
|
+
/**
|
|
215
|
+
* Path to Zod
|
|
216
|
+
* It used as `import { z } from '${importPath}'`.
|
|
217
|
+
* Accepts relative and absolute paths.
|
|
218
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
219
|
+
* @default 'zod'
|
|
220
|
+
*/
|
|
221
|
+
importPath?: 'zod' | 'zod/mini' | (string & {});
|
|
222
|
+
/**
|
|
223
|
+
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
224
|
+
* - false falls back to a simple z.string() format.
|
|
225
|
+
* - 'string' uses z.string().datetime() for datetime validation.
|
|
226
|
+
* - 'stringOffset' uses z.string().datetime({ offset: true }) for datetime with timezone offset validation.
|
|
227
|
+
* - 'stringLocal' uses z.string().datetime({ local: true }) for local datetime validation.
|
|
228
|
+
* - 'date' uses z.date() for JavaScript Date objects.
|
|
229
|
+
* @default 'string'
|
|
230
|
+
*/
|
|
231
|
+
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
232
|
+
/**
|
|
233
|
+
* Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
|
|
234
|
+
*/
|
|
235
|
+
typed?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Return Zod generated schema as type with z.infer<TYPE>
|
|
238
|
+
*/
|
|
239
|
+
inferred?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Use of z.coerce.string() instead of z.string().
|
|
242
|
+
* Can also be an object to enable coercion for dates, strings, and numbers.
|
|
243
|
+
*/
|
|
244
|
+
coercion?: boolean | {
|
|
245
|
+
dates?: boolean;
|
|
246
|
+
strings?: boolean;
|
|
247
|
+
numbers?: boolean;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Generate operation-level schemas (grouped by operationId).
|
|
251
|
+
*/
|
|
252
|
+
operations?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Which Zod GUID validator to use for OpenAPI `format: uuid`.
|
|
255
|
+
* - 'uuid' uses UUID validation.
|
|
256
|
+
* - 'guid' uses GUID validation.
|
|
257
|
+
* @default 'uuid'
|
|
258
|
+
*/
|
|
259
|
+
guidType?: 'uuid' | 'guid';
|
|
260
|
+
/**
|
|
261
|
+
* Use Zod Mini's functional API for better tree-shaking support.
|
|
262
|
+
* When enabled, generates functional syntax (e.g., `z.optional(z.string())`)
|
|
263
|
+
* instead of chainable methods (e.g., `z.string().optional()`).
|
|
264
|
+
* When `mini: true`, `importPath` will default to 'zod/mini'.
|
|
265
|
+
* @default false
|
|
266
|
+
*/
|
|
267
|
+
mini?: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Callback function to wrap the output of the generated zod schema.
|
|
270
|
+
*
|
|
271
|
+
* Useful for edge cases like adding `.openapi()` metadata or wrapping
|
|
272
|
+
* schemas with extension helpers (openapi -> zod -> openapi round-trips).
|
|
273
|
+
*/
|
|
274
|
+
wrapOutput?: (arg: {
|
|
275
|
+
output: string;
|
|
276
|
+
schema: SchemaNode;
|
|
277
|
+
}) => string | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* How to style your params, by default no casing is applied
|
|
280
|
+
* - 'camelcase' uses camelCase for pathParams, queryParams and headerParams property names
|
|
281
|
+
* @default undefined
|
|
282
|
+
*/
|
|
283
|
+
paramsCasing?: 'camelcase';
|
|
284
|
+
/**
|
|
285
|
+
* Define additional generators next to the zod generators.
|
|
286
|
+
*/
|
|
287
|
+
generators?: Array<Generator<PluginZod>>;
|
|
288
|
+
/**
|
|
289
|
+
* Compatibility preset to ease migration from previous Kubb versions.
|
|
290
|
+
*/
|
|
291
|
+
compatibilityPreset?: CompatibilityPreset;
|
|
292
|
+
/**
|
|
293
|
+
* A single resolver whose methods override the default resolver's naming conventions.
|
|
294
|
+
* When a method returns `null` or `undefined`, the default resolver's result is used instead.
|
|
295
|
+
*/
|
|
296
|
+
resolver?: Partial<ResolverZod> & ThisType<ResolverZod>;
|
|
297
|
+
/**
|
|
298
|
+
* Override individual printer node handlers to customize rendering of specific schema types.
|
|
299
|
+
*
|
|
300
|
+
* Each key is a `SchemaType` (e.g. `'date'`, `'string'`). The function replaces the
|
|
301
|
+
* built-in handler for that type. Use `this.transform` to recurse into nested schema nodes.
|
|
302
|
+
* When `mini: true`, the overrides apply to the Zod Mini printer.
|
|
303
|
+
*
|
|
304
|
+
* @example Override the `date` node to use `z.string().date()`
|
|
305
|
+
* ```ts
|
|
306
|
+
* pluginZod({
|
|
307
|
+
* printer: {
|
|
308
|
+
* nodes: {
|
|
309
|
+
* date(node) {
|
|
310
|
+
* return 'z.string().date()'
|
|
311
|
+
* },
|
|
312
|
+
* },
|
|
313
|
+
* },
|
|
314
|
+
* })
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
printer?: {
|
|
318
|
+
nodes?: PrinterZodNodes | PrinterZodMiniNodes;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* A single AST visitor applied to each SchemaNode/OperationNode before printing.
|
|
322
|
+
* When a visitor method returns `null` or `undefined`, the preset transformer's result is used instead.
|
|
323
|
+
*/
|
|
324
|
+
transformer?: Visitor;
|
|
325
|
+
};
|
|
326
|
+
type ResolvedOptions = {
|
|
327
|
+
output: Output;
|
|
328
|
+
exclude: Array<Exclude>;
|
|
329
|
+
include: Array<Include> | undefined;
|
|
330
|
+
override: Array<Override<ResolvedOptions>>;
|
|
331
|
+
group: Group | undefined;
|
|
332
|
+
dateType: NonNullable<Options['dateType']>;
|
|
333
|
+
typed: NonNullable<Options['typed']>;
|
|
334
|
+
inferred: NonNullable<Options['inferred']>;
|
|
335
|
+
importPath: NonNullable<Options['importPath']>;
|
|
336
|
+
coercion: NonNullable<Options['coercion']>;
|
|
337
|
+
operations: NonNullable<Options['operations']>;
|
|
338
|
+
guidType: NonNullable<Options['guidType']>;
|
|
339
|
+
mini: NonNullable<Options['mini']>;
|
|
340
|
+
wrapOutput: Options['wrapOutput'];
|
|
341
|
+
paramsCasing: Options['paramsCasing'];
|
|
342
|
+
printer: Options['printer'];
|
|
343
|
+
};
|
|
344
|
+
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions, ResolverZod>;
|
|
345
|
+
declare global {
|
|
346
|
+
namespace Kubb {
|
|
347
|
+
interface PluginRegistry {
|
|
348
|
+
'plugin-zod': PluginZod;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/generators/zodGenerator.d.ts
|
|
354
|
+
declare const zodGenerator: _$_kubb_core0.Generator<PluginZod>;
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/generators/zodGeneratorLegacy.d.ts
|
|
357
|
+
declare const zodGeneratorLegacy: _$_kubb_core0.Generator<PluginZod>;
|
|
358
|
+
//#endregion
|
|
5
359
|
//#region src/plugin.d.ts
|
|
360
|
+
/**
|
|
361
|
+
* Canonical plugin name for `@kubb/plugin-zod`, used to identify the plugin in driver lookups and warnings.
|
|
362
|
+
*/
|
|
6
363
|
declare const pluginZodName = "plugin-zod";
|
|
7
|
-
|
|
364
|
+
/**
|
|
365
|
+
* The `@kubb/plugin-zod` plugin factory.
|
|
366
|
+
*
|
|
367
|
+
* Generates Zod validation schemas from an OpenAPI/AST `RootNode`.
|
|
368
|
+
* Walks schemas and operations, delegates rendering to the active generators,
|
|
369
|
+
* and writes barrel files based on `output.barrelType`.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* import { pluginZod } from '@kubb/plugin-zod'
|
|
374
|
+
*
|
|
375
|
+
* export default defineConfig({
|
|
376
|
+
* plugins: [pluginZod({ output: { path: 'zod' } })],
|
|
377
|
+
* })
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare const pluginZod: (options?: Options | undefined) => _$_kubb_core0.UserPluginWithLifeCycle<PluginZod>;
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/resolvers/resolverZod.d.ts
|
|
383
|
+
/**
|
|
384
|
+
* Default resolver for `@kubb/plugin-zod`.
|
|
385
|
+
*
|
|
386
|
+
* Uses `camelCase` naming with a `Schema` suffix for function/type/const names.
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```ts
|
|
390
|
+
* resolverZod.default('list pets', 'function') // → 'listPetsSchema'
|
|
391
|
+
* resolverZod.default('Pet', 'file') // → 'pet'
|
|
392
|
+
* resolverZod.resolveName('list pets') // → 'listPetsSchema'
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
declare const resolverZod: ResolverZod;
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/resolvers/resolverZodLegacy.d.ts
|
|
398
|
+
/**
|
|
399
|
+
* Legacy resolver for `@kubb/plugin-zod` that reproduces the naming conventions
|
|
400
|
+
* used in Kubb v4. Enable via `compatibilityPreset: 'kubbV4'`
|
|
401
|
+
* (or by composing this resolver manually).
|
|
402
|
+
*
|
|
403
|
+
* Key differences from the default resolver:
|
|
404
|
+
* - Response status types: `<operationId><StatusCode>Schema` (e.g. `createPets201Schema`) instead of `<operationId>Status201Schema`
|
|
405
|
+
* - Default/error responses: `<operationId>ErrorSchema` instead of `<operationId>StatusDefaultSchema`
|
|
406
|
+
* - Request body: `<operationId>MutationRequestSchema` (non-GET) / `<operationId>QueryRequestSchema` (GET)
|
|
407
|
+
* - Combined responses type: `<operationId>MutationSchema` / `<operationId>QuerySchema`
|
|
408
|
+
* - Response union: `<operationId>MutationResponseSchema` / `<operationId>QueryResponseSchema`
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* import { resolverZodLegacy } from '@kubb/plugin-zod'
|
|
413
|
+
*
|
|
414
|
+
* resolverZodLegacy.resolveResponseStatusName(node, 201) // → 'createPets201Schema'
|
|
415
|
+
* resolverZodLegacy.resolveResponseStatusName(node, 'default') // → 'createPetsErrorSchema'
|
|
416
|
+
* resolverZodLegacy.resolveDataName(node) // → 'createPetsMutationRequestSchema' (POST)
|
|
417
|
+
* resolverZodLegacy.resolveResponsesName(node) // → 'createPetsMutationSchema' (POST)
|
|
418
|
+
* resolverZodLegacy.resolveResponseName(node) // → 'createPetsMutationResponseSchema' (POST)
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
declare const resolverZodLegacy: ResolverZod;
|
|
8
422
|
//#endregion
|
|
9
|
-
export { type PluginZod, pluginZod, pluginZodName };
|
|
423
|
+
export { type PluginZod, type PrinterZodFactory, type PrinterZodMiniFactory, type PrinterZodMiniNodes, type PrinterZodMiniOptions, type PrinterZodNodes, type PrinterZodOptions, type ResolverZod, pluginZod, pluginZodName, printerZod, printerZodMini, resolverZod, resolverZodLegacy, zodGenerator, zodGeneratorLegacy };
|
|
10
424
|
//# sourceMappingURL=index.d.ts.map
|