@kubb/plugin-zod 5.0.0-beta.56 → 5.0.0-beta.73

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,7 +1,54 @@
1
- import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
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
5
52
  //#region src/printers/printerZod.d.ts
6
53
  /**
7
54
  * Partial map of node-type overrides for the Zod printer.
@@ -35,6 +82,13 @@ type PrinterZodOptions = {
35
82
  * @default 'uuid'
36
83
  */
37
84
  guidType?: PluginZod['resolvedOptions']['guidType'];
85
+ /**
86
+ * Output form for an OpenAPI `pattern` inside `.regex(...)`: a regex literal
87
+ * (`'literal'`) or the `RegExp` constructor (`'constructor'`).
88
+ *
89
+ * @default 'literal'
90
+ */
91
+ regexType?: PluginZod['resolvedOptions']['regexType'];
38
92
  /**
39
93
  * Date format in the OpenAPI spec (`'date'` or `'date-time'`).
40
94
  */
@@ -118,6 +172,13 @@ type PrinterZodMiniOptions = {
118
172
  * @default 'uuid'
119
173
  */
120
174
  guidType?: PluginZod['resolvedOptions']['guidType'];
175
+ /**
176
+ * Output form for an OpenAPI `pattern` inside `z.regex(...)`: a regex literal
177
+ * (`'literal'`) or the `RegExp` constructor (`'constructor'`).
178
+ *
179
+ * @default 'literal'
180
+ */
181
+ regexType?: PluginZod['resolvedOptions']['regexType'];
121
182
  /**
122
183
  * Hook to transform generated Zod schema before output.
123
184
  */
@@ -162,7 +223,7 @@ declare const printerZodMini: (options?: PrinterZodMiniOptions | undefined) => a
162
223
  /**
163
224
  * Resolver for Zod that provides naming methods for schema types.
164
225
  */
165
- type ResolverZod = Resolver & ast.OperationParamsResolver & {
226
+ type ResolverZod = Resolver & OperationParamsResolver & {
166
227
  /**
167
228
  * Resolves a camelCase schema function name with a `Schema` suffix.
168
229
  */
@@ -307,6 +368,14 @@ type Options = OutputOptions & {
307
368
  * @default 'uuid'
308
369
  */
309
370
  guidType?: 'uuid' | 'guid';
371
+ /**
372
+ * Output form for an OpenAPI `pattern` inside `.regex(...)`.
373
+ * - `'literal'` — a regex literal: `.regex(/^[a-z]+$/)`.
374
+ * - `'constructor'` — the `RegExp` constructor: `.regex(new RegExp("^[a-z]+$"))`.
375
+ *
376
+ * @default 'literal'
377
+ */
378
+ regexType?: 'literal' | 'constructor';
310
379
  /**
311
380
  * Switch to Zod Mini's functional API for better tree-shaking. Also defaults
312
381
  * `importPath` to `'zod/mini'`.
@@ -324,16 +393,6 @@ type Options = OutputOptions & {
324
393
  output: string;
325
394
  schema: ast.SchemaNode;
326
395
  }) => string | undefined;
327
- /**
328
- * Rename properties inside path/query/header schemas. Body schemas are unaffected.
329
- *
330
- * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
331
- */
332
- paramsCasing?: 'camelcase';
333
- /**
334
- * Custom generators that run alongside the built-in Zod generators.
335
- */
336
- generators?: Array<Generator<PluginZod>>;
337
396
  /**
338
397
  * Override how schema and operation names are built. Methods you omit fall back
339
398
  * to the default `resolverZod`.
@@ -347,9 +406,9 @@ type Options = OutputOptions & {
347
406
  nodes?: PrinterZodNodes | PrinterZodMiniNodes;
348
407
  };
349
408
  /**
350
- * AST visitor applied to each schema or operation node before printing.
409
+ * Macros applied to each schema or operation node before printing.
351
410
  */
352
- transformer?: ast.Visitor;
411
+ macros?: Array<ast.Macro>;
353
412
  };
354
413
  type ResolvedOptions = {
355
414
  output: Output;
@@ -363,9 +422,9 @@ type ResolvedOptions = {
363
422
  coercion: NonNullable<Options['coercion']>;
364
423
  operations: NonNullable<Options['operations']>;
365
424
  guidType: NonNullable<Options['guidType']>;
425
+ regexType: NonNullable<Options['regexType']>;
366
426
  mini: NonNullable<Options['mini']>;
367
427
  wrapOutput: Options['wrapOutput'];
368
- paramsCasing: Options['paramsCasing'];
369
428
  printer: Options['printer'];
370
429
  };
371
430
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, ResolverZod>;
@@ -395,8 +454,9 @@ declare const pluginZodName = "plugin-zod";
395
454
  /**
396
455
  * Generates Zod v4 schemas from an OpenAPI spec. Use them to validate API
397
456
  * responses at runtime, build form schemas, or feed back into router libraries
398
- * that consume Zod (tRPC, Hono, Elysia). Pair with `@kubb/plugin-client` and
399
- * set the client's `parser: 'zod'` to validate every response automatically.
457
+ * that consume Zod (tRPC, Hono, Elysia). Pair with `@kubb/plugin-axios` or
458
+ * `@kubb/plugin-fetch` and set the client's `parser: 'zod'` to validate every response
459
+ * automatically.
400
460
  *
401
461
  * @example
402
462
  * ```ts