@kubb/plugin-zod 4.21.2 → 4.22.1

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.
@@ -0,0 +1,156 @@
1
+ import { Oas, SchemaObject, contentType } from "@kubb/oas";
2
+ import { Exclude, Include, Override, ResolvePathOptions, Schema } from "@kubb/plugin-oas";
3
+ import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
4
+ import { Generator } from "@kubb/plugin-oas/generators";
5
+
6
+ //#region rolldown:runtime
7
+ //#endregion
8
+ //#region src/types.d.ts
9
+ type Options = {
10
+ /**
11
+ * @default 'zod'
12
+ */
13
+ output?: Output<Oas>;
14
+ /**
15
+ * Define which contentType should be used.
16
+ * By default, the first JSON valid mediaType is used
17
+ */
18
+ contentType?: contentType;
19
+ /**
20
+ * Group the Zod schemas based on the provided name.
21
+ */
22
+ group?: Group;
23
+ /**
24
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
25
+ */
26
+ exclude?: Array<Exclude>;
27
+ /**
28
+ * Array containing include parameters to include tags/operations/methods/paths.
29
+ */
30
+ include?: Array<Include>;
31
+ /**
32
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
33
+ */
34
+ override?: Array<Override<ResolvedOptions>>;
35
+ /**
36
+ * Path to Zod
37
+ * It used as `import { z } from '${importPath}'`.
38
+ * Accepts relative and absolute paths.
39
+ * Path is used as-is; relative paths are based on the generated file location.
40
+ * @default 'zod'
41
+ */
42
+ importPath?: string;
43
+ /**
44
+ * Choose to use date or datetime as JavaScript Date instead of string.
45
+ * - false falls back to a simple z.string() format.
46
+ * - 'string' uses z.string().datetime() for datetime validation.
47
+ * - 'stringOffset' uses z.string().datetime({ offset: true }) for datetime with timezone offset validation.
48
+ * - 'stringLocal' uses z.string().datetime({ local: true }) for local datetime validation.
49
+ * - 'date' uses z.date() for JavaScript Date objects.
50
+ * @default 'string'
51
+ * @note 'stringOffset' will become the default in Kubb v3.
52
+ */
53
+ dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
54
+ /**
55
+ * Which type to use when the Swagger/OpenAPI file is not providing more information.
56
+ * - 'any' allows any value.
57
+ * - 'unknown' requires type narrowing before use.
58
+ * - 'void' represents no value.
59
+ * @default 'any'
60
+ */
61
+ unknownType?: 'any' | 'unknown' | 'void';
62
+ /**
63
+ * Which type to use for empty schema values.
64
+ * - 'any' allows any value.
65
+ * - 'unknown' requires type narrowing before use.
66
+ * - 'void' represents no value.
67
+ * @default `unknownType`
68
+ */
69
+ emptySchemaType?: 'any' | 'unknown' | 'void';
70
+ /**
71
+ * Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
72
+ */
73
+ typed?: boolean;
74
+ /**
75
+ * Return Zod generated schema as type with z.infer<TYPE>
76
+ */
77
+ inferred?: boolean;
78
+ /**
79
+ * Use of z.coerce.string() instead of z.string()
80
+ * can also be an object to enable coercion for dates, strings, and numbers
81
+ */
82
+ coercion?: boolean | {
83
+ dates?: boolean;
84
+ strings?: boolean;
85
+ numbers?: boolean;
86
+ };
87
+ operations?: boolean;
88
+ mapper?: Record<string, string>;
89
+ transformers?: {
90
+ /**
91
+ * Customize the names based on the type that is provided by the plugin.
92
+ */
93
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
94
+ /**
95
+ * Receive schema and baseName(propertyName) and return FakerMeta array
96
+ * TODO TODO add docs
97
+ * @beta
98
+ */
99
+ schema?: (props: {
100
+ schema: SchemaObject | null;
101
+ name: string | null;
102
+ parentName: string | null;
103
+ }, defaultSchemas: Schema[]) => Schema[] | undefined;
104
+ };
105
+ /**
106
+ * Which version of Zod should be used.
107
+ * - '3' uses Zod v3.x syntax and features.
108
+ * - '4' uses Zod v4.x syntax and features.
109
+ * @default '3'
110
+ */
111
+ version?: '3' | '4';
112
+ /**
113
+ * Use Zod Mini's functional API for better tree-shaking support.
114
+ * When enabled, generates functional syntax (e.g., `z.optional(z.string())`) instead of chainable methods (e.g., `z.string().optional()`).
115
+ * Requires Zod v4 or later. When `mini: true`, `version` is set to '4' and `importPath` will default to 'zod/mini'.
116
+ * @default false
117
+ */
118
+ mini?: boolean;
119
+ /**
120
+ * Callback function to wrap the output of the generated zod schema
121
+ *
122
+ * This is useful for edge case scenarios where you might leverage something like `z.object({ ... }).openapi({ example: { some: "complex-example" }})`
123
+ * or `extendApi(z.object({ ... }), { example: { some: "complex-example", ...otherOpenApiProperties }})`
124
+ * while going from openapi -> zod -> openapi
125
+ */
126
+ wrapOutput?: (arg: {
127
+ output: string;
128
+ schema: SchemaObject;
129
+ }) => string | undefined;
130
+ /**
131
+ * Define some generators next to the zod generators
132
+ */
133
+ generators?: Array<Generator<PluginZod>>;
134
+ };
135
+ type ResolvedOptions = {
136
+ output: Output<Oas>;
137
+ group: Options['group'];
138
+ override: NonNullable<Options['override']>;
139
+ transformers: NonNullable<Options['transformers']>;
140
+ dateType: NonNullable<Options['dateType']>;
141
+ unknownType: NonNullable<Options['unknownType']>;
142
+ emptySchemaType: NonNullable<Options['emptySchemaType']>;
143
+ typed: NonNullable<Options['typed']>;
144
+ inferred: NonNullable<Options['inferred']>;
145
+ mapper: NonNullable<Options['mapper']>;
146
+ importPath: NonNullable<Options['importPath']>;
147
+ coercion: NonNullable<Options['coercion']>;
148
+ operations: NonNullable<Options['operations']>;
149
+ wrapOutput: Options['wrapOutput'];
150
+ version: NonNullable<Options['version']>;
151
+ mini: NonNullable<Options['mini']>;
152
+ };
153
+ type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
154
+ //#endregion
155
+ export { PluginZod as n, __name as r, Options as t };
156
+ //# sourceMappingURL=types-DCdzW-cw.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "4.21.2",
3
+ "version": "4.22.1",
4
4
  "description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
5
5
  "keywords": [
6
6
  "zod",
@@ -73,10 +73,10 @@
73
73
  ],
74
74
  "dependencies": {
75
75
  "@kubb/react-fabric": "0.12.11",
76
- "@kubb/core": "4.21.2",
77
- "@kubb/oas": "4.21.2",
78
- "@kubb/plugin-oas": "4.21.2",
79
- "@kubb/plugin-ts": "4.21.2"
76
+ "@kubb/core": "4.22.1",
77
+ "@kubb/oas": "4.22.1",
78
+ "@kubb/plugin-oas": "4.22.1",
79
+ "@kubb/plugin-ts": "4.22.1"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@asteasolutions/zod-to-openapi": "^8.4.0",