@kubb/plugin-zod 4.33.0 → 4.33.2
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/{components-C-rV8Ij4.cjs → components-B7zUFnAm.cjs} +96 -12
- package/dist/components-B7zUFnAm.cjs.map +1 -0
- package/dist/{components-CK7yDnVt.js → components-eECfXVou.js} +96 -11
- package/dist/components-eECfXVou.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-DEsJkwyB.cjs → generators-B7zVCbFq.cjs} +2 -2
- package/dist/{generators-DEsJkwyB.cjs.map → generators-B7zVCbFq.cjs.map} +1 -1
- package/dist/{generators-DfvfkbX5.js → generators-D1R6NNf2.js} +2 -2
- package/dist/{generators-DfvfkbX5.js.map → generators-D1R6NNf2.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +42 -6
- package/dist/generators.js +1 -1
- package/dist/index.cjs +60 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +56 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/components/Operations.tsx +3 -3
- package/src/components/Zod.tsx +2 -2
- package/src/parser.ts +7 -7
- package/src/plugin.ts +1 -1
- package/dist/components-C-rV8Ij4.cjs.map +0 -1
- package/dist/components-CK7yDnVt.js.map +0 -1
|
@@ -24,12 +24,96 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
|
-
let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
28
|
-
_kubb_core_transformers = __toESM(_kubb_core_transformers);
|
|
29
27
|
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
30
28
|
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
31
29
|
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
32
30
|
let remeda = require("remeda");
|
|
31
|
+
//#region ../../internals/utils/src/string.ts
|
|
32
|
+
/**
|
|
33
|
+
* Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
|
|
34
|
+
* Returns the string unchanged when no balanced quote pair is found.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* trimQuotes('"hello"') // 'hello'
|
|
38
|
+
* trimQuotes('hello') // 'hello'
|
|
39
|
+
*/
|
|
40
|
+
function trimQuotes(text) {
|
|
41
|
+
if (text.length >= 2) {
|
|
42
|
+
const first = text[0];
|
|
43
|
+
const last = text[text.length - 1];
|
|
44
|
+
if (first === "\"" && last === "\"" || first === "'" && last === "'" || first === "`" && last === "`") return text.slice(1, -1);
|
|
45
|
+
}
|
|
46
|
+
return text;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Escapes characters that are not allowed inside JS string literals.
|
|
50
|
+
* Handles quotes, backslashes, and Unicode line terminators (U+2028 / U+2029).
|
|
51
|
+
*
|
|
52
|
+
* @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
|
53
|
+
*/
|
|
54
|
+
function jsStringEscape(input) {
|
|
55
|
+
return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
|
|
56
|
+
switch (character) {
|
|
57
|
+
case "\"":
|
|
58
|
+
case "'":
|
|
59
|
+
case "\\": return `\\${character}`;
|
|
60
|
+
case "\n": return "\\n";
|
|
61
|
+
case "\r": return "\\r";
|
|
62
|
+
case "\u2028": return "\\u2028";
|
|
63
|
+
case "\u2029": return "\\u2029";
|
|
64
|
+
default: return "";
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region ../../internals/utils/src/object.ts
|
|
70
|
+
/**
|
|
71
|
+
* Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* stringify('hello') // '"hello"'
|
|
75
|
+
* stringify('"hello"') // '"hello"'
|
|
76
|
+
*/
|
|
77
|
+
function stringify(value) {
|
|
78
|
+
if (value === void 0 || value === null) return "\"\"";
|
|
79
|
+
return JSON.stringify(trimQuotes(value.toString()));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Converts a plain object into a multiline key-value string suitable for embedding in generated code.
|
|
83
|
+
* Nested objects are recursively stringified with indentation.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* stringifyObject({ foo: 'bar', nested: { a: 1 } })
|
|
87
|
+
* // 'foo: bar,\nnested: {\n a: 1\n }'
|
|
88
|
+
*/
|
|
89
|
+
function stringifyObject(value) {
|
|
90
|
+
return Object.entries(value).map(([key, val]) => {
|
|
91
|
+
if (val !== null && typeof val === "object") return `${key}: {\n ${stringifyObject(val)}\n }`;
|
|
92
|
+
return `${key}: ${val}`;
|
|
93
|
+
}).filter(Boolean).join(",\n");
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../../internals/utils/src/regexp.ts
|
|
97
|
+
/**
|
|
98
|
+
* Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.
|
|
99
|
+
* Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.
|
|
100
|
+
* Pass `null` as the second argument to emit a `/pattern/flags` literal instead.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* toRegExpString('^(?im)foo') // → 'new RegExp("foo", "im")'
|
|
104
|
+
* toRegExpString('^(?im)foo', null) // → '/foo/im'
|
|
105
|
+
*/
|
|
106
|
+
function toRegExpString(text, func = "RegExp") {
|
|
107
|
+
const raw = trimQuotes(text);
|
|
108
|
+
const match = raw.match(/^\^(\(\?([igmsuy]+)\))/i);
|
|
109
|
+
const replacementTarget = match?.[1] ?? "";
|
|
110
|
+
const matchedFlags = match?.[2];
|
|
111
|
+
const cleaned = raw.replace(/^\\?\//, "").replace(/\\?\/$/, "").replace(replacementTarget, "");
|
|
112
|
+
const { source, flags } = new RegExp(cleaned, matchedFlags);
|
|
113
|
+
if (func === null) return `/${source}/${flags}`;
|
|
114
|
+
return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ""})`;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
33
117
|
//#region src/components/Operations.tsx
|
|
34
118
|
function Operations({ name, operations }) {
|
|
35
119
|
const operationsJSON = operations.reduce((prev, acc) => {
|
|
@@ -86,7 +170,7 @@ function Operations({ name, operations }) {
|
|
|
86
170
|
export: true,
|
|
87
171
|
name,
|
|
88
172
|
asConst: true,
|
|
89
|
-
children: `{${
|
|
173
|
+
children: `{${stringifyObject(operationsJSON)}}`
|
|
90
174
|
})
|
|
91
175
|
}),
|
|
92
176
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
@@ -97,7 +181,7 @@ function Operations({ name, operations }) {
|
|
|
97
181
|
export: true,
|
|
98
182
|
name: "paths",
|
|
99
183
|
asConst: true,
|
|
100
|
-
children: `{${
|
|
184
|
+
children: `{${stringifyObject(pathsJSON)}}`
|
|
101
185
|
})
|
|
102
186
|
})
|
|
103
187
|
] });
|
|
@@ -513,9 +597,9 @@ const parse = (0, _kubb_plugin_oas.createParser)({
|
|
|
513
597
|
}).filter(Boolean));
|
|
514
598
|
}
|
|
515
599
|
return zodKeywordMapper.enum(current.args.items.map((schema) => {
|
|
516
|
-
if (schema.format === "boolean") return
|
|
517
|
-
if (schema.format === "number") return
|
|
518
|
-
return
|
|
600
|
+
if (schema.format === "boolean") return stringify(schema.value);
|
|
601
|
+
if (schema.format === "number") return stringify(schema.value);
|
|
602
|
+
return stringify(schema.value);
|
|
519
603
|
}));
|
|
520
604
|
},
|
|
521
605
|
ref(tree, options) {
|
|
@@ -612,14 +696,14 @@ const parse = (0, _kubb_plugin_oas.createParser)({
|
|
|
612
696
|
const { current } = tree;
|
|
613
697
|
if (current.args.format === "number" && current.args.value !== void 0) return zodKeywordMapper.const(Number(current.args.value));
|
|
614
698
|
if (current.args.format === "boolean" && current.args.value !== void 0) return zodKeywordMapper.const(typeof current.args.value === "boolean" ? current.args.value : void 0);
|
|
615
|
-
return zodKeywordMapper.const(
|
|
699
|
+
return zodKeywordMapper.const(stringify(current.args.value));
|
|
616
700
|
},
|
|
617
701
|
matches(tree, options) {
|
|
618
702
|
const { current, siblings } = tree;
|
|
619
703
|
if (siblings.some((it) => (0, _kubb_plugin_oas.isKeyword)(it, _kubb_plugin_oas.schemaKeywords.ref))) return;
|
|
620
704
|
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
621
705
|
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
622
|
-
if (current.args) return zodKeywordMapper.matches(
|
|
706
|
+
if (current.args) return zodKeywordMapper.matches(toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"), options.mini, minSchema?.args, maxSchema?.args);
|
|
623
707
|
},
|
|
624
708
|
default(tree, options) {
|
|
625
709
|
const { current, siblings } = tree;
|
|
@@ -630,7 +714,7 @@ const parse = (0, _kubb_plugin_oas.createParser)({
|
|
|
630
714
|
},
|
|
631
715
|
describe(tree, options) {
|
|
632
716
|
const { current } = tree;
|
|
633
|
-
if (current.args) return zodKeywordMapper.describe(
|
|
717
|
+
if (current.args) return zodKeywordMapper.describe(stringify(current.args.toString()), void 0, options.mini);
|
|
634
718
|
},
|
|
635
719
|
string(tree, options) {
|
|
636
720
|
const { siblings } = tree;
|
|
@@ -758,7 +842,7 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
758
842
|
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Const, {
|
|
759
843
|
export: true,
|
|
760
844
|
name,
|
|
761
|
-
JSDoc: { comments: [description ? `@description ${
|
|
845
|
+
JSDoc: { comments: [description ? `@description ${jsStringEscape(description)}` : void 0].filter(Boolean) },
|
|
762
846
|
children: finalOutput
|
|
763
847
|
})
|
|
764
848
|
}), inferTypeName && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File.Source, {
|
|
@@ -803,4 +887,4 @@ Object.defineProperty(exports, "__toESM", {
|
|
|
803
887
|
}
|
|
804
888
|
});
|
|
805
889
|
|
|
806
|
-
//# sourceMappingURL=components-
|
|
890
|
+
//# sourceMappingURL=components-B7zUFnAm.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-B7zUFnAm.cjs","names":["File","Type","Const","schemaKeywords","SchemaGenerator","SchemaGenerator","schemaKeywords","parserZod.sort","parserZod.filterMiniModifiers","parserZod.parse","parserZod.wrapWithMiniModifiers","parserZod.extractMiniModifiers","File","Const","Type"],"sources":["../../../internals/utils/src/string.ts","../../../internals/utils/src/object.ts","../../../internals/utils/src/regexp.ts","../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["/**\n * Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n * Returns the string unchanged when no balanced quote pair is found.\n *\n * @example\n * trimQuotes('\"hello\"') // 'hello'\n * trimQuotes('hello') // 'hello'\n */\nexport function trimQuotes(text: string): string {\n if (text.length >= 2) {\n const first = text[0]\n const last = text[text.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\") || (first === '`' && last === '`')) {\n return text.slice(1, -1)\n }\n }\n return text\n}\n\n/**\n * Escapes characters that are not allowed inside JS string literals.\n * Handles quotes, backslashes, and Unicode line terminators (U+2028 / U+2029).\n *\n * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n */\nexport function jsStringEscape(input: unknown): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return `\\\\${character}`\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n\n/**\n * Returns a masked version of a string, showing only the first and last few characters.\n * Useful for logging sensitive values (tokens, keys) without exposing the full value.\n *\n * @example\n * maskString('KUBB_STUDIO-abc123-xyz789') // 'KUBB_STUDIO-…789'\n */\nexport function maskString(value: string, start = 8, end = 4): string {\n if (value.length <= start + end) return value\n return `${value.slice(0, start)}…${value.slice(-end)}`\n}\n","import { trimQuotes } from './string.ts'\n\n/**\n * Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.\n *\n * @example\n * stringify('hello') // '\"hello\"'\n * stringify('\"hello\"') // '\"hello\"'\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return '\"\"'\n return JSON.stringify(trimQuotes(value.toString()))\n}\n\n/**\n * Converts a plain object into a multiline key-value string suitable for embedding in generated code.\n * Nested objects are recursively stringified with indentation.\n *\n * @example\n * stringifyObject({ foo: 'bar', nested: { a: 1 } })\n * // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n */\nexport function stringifyObject(value: Record<string, unknown>): string {\n const items = Object.entries(value)\n .map(([key, val]) => {\n if (val !== null && typeof val === 'object') {\n return `${key}: {\\n ${stringifyObject(val as Record<string, unknown>)}\\n }`\n }\n return `${key}: ${val}`\n })\n .filter(Boolean)\n return items.join(',\\n')\n}\n\n/**\n * Serializes plugin options for safe JSON transport.\n * Strips functions, symbols, and `undefined` values recursively.\n */\nexport function serializePluginOptions<TOptions extends object>(options: TOptions): TOptions {\n if (options === null || options === undefined) return {} as TOptions\n if (typeof options !== 'object') return options\n if (Array.isArray(options)) return options.map(serializePluginOptions) as unknown as TOptions\n\n const serialized: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(options)) {\n if (typeof value === 'function' || typeof value === 'symbol' || value === undefined) continue\n serialized[key] = value !== null && typeof value === 'object' ? serializePluginOptions(value as object) : value\n }\n return serialized as TOptions\n}\n\n/**\n * Converts a dot-notation path or string array into an optional-chaining accessor expression.\n *\n * @example\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // → \"lastPage?.['pagination']?.['next']?.['id']\"\n */\nexport function getNestedAccessor(param: string | string[], accessor: string): string | undefined {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return undefined\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import { trimQuotes } from './string.ts'\n\n/**\n * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n * Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.\n * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n *\n * @example\n * toRegExpString('^(?im)foo') // → 'new RegExp(\"foo\", \"im\")'\n * toRegExpString('^(?im)foo', null) // → '/foo/im'\n */\nexport function toRegExpString(text: string, func: string | null = 'RegExp'): string {\n const raw = trimQuotes(text)\n\n const match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i)\n const replacementTarget = match?.[1] ?? ''\n const matchedFlags = match?.[2]\n const cleaned = raw\n .replace(/^\\\\?\\//, '')\n .replace(/\\\\?\\/$/, '')\n .replace(replacementTarget, '')\n\n const { source, flags } = new RegExp(cleaned, matchedFlags)\n\n if (func === null) return `/${source}/${flags}`\n\n return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ''})`\n}\n","import { stringifyObject } from '@internals/utils'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File, Type } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props): FabricReactNode {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name=\"OperationSchema\" isExportable isIndexable>\n <Type name=\"OperationSchema\" export>{`{\n readonly request: z.ZodTypeAny | undefined;\n readonly parameters: {\n readonly path: z.ZodTypeAny | undefined;\n readonly query: z.ZodTypeAny | undefined;\n readonly header: z.ZodTypeAny | undefined;\n };\n readonly responses: {\n readonly [status: number]: z.ZodTypeAny;\n readonly default: z.ZodTypeAny;\n };\n readonly errors: {\n readonly [status: number]: z.ZodTypeAny;\n };\n}`}</Type>\n </File.Source>\n <File.Source name=\"OperationsMap\" isExportable isIndexable>\n <Type name=\"OperationsMap\" export>\n {'Record<string, OperationSchema>'}\n </Type>\n </File.Source>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import { stringify, toRegExpString } from '@internals/utils'\nimport type { Schema, SchemaMapper } from '@kubb/plugin-oas'\nimport { createParser, findSchemaKeyword, isKeyword, SchemaGenerator, type SchemaKeywordMapper, schemaKeywords } from '@kubb/plugin-oas'\nimport { sortBy } from 'remeda'\n\n//TODO add zodKeywordMapper as function that returns 3 versions: v3, v4 and v4 mini, this can also be used to have the custom mapping(see object type)\n// also include shouldCoerce\n\n/**\n * Helper to build string/array length constraint checks for Zod Mini mode\n */\nfunction buildLengthChecks(min?: number, max?: number): string[] {\n const checks: string[] = []\n if (min !== undefined) checks.push(`z.minLength(${min})`)\n if (max !== undefined) checks.push(`z.maxLength(${max})`)\n return checks\n}\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number, exclusiveMinimum?: number, exclusiveMaximum?: number, mini?: boolean) => {\n if (mini) {\n const checks: string[] = []\n if (min !== undefined) checks.push(`z.minimum(${min})`)\n if (max !== undefined) checks.push(`z.maximum(${max})`)\n if (exclusiveMinimum !== undefined) checks.push(`z.minimum(${exclusiveMinimum}, { exclusive: true })`)\n if (exclusiveMaximum !== undefined) checks.push(`z.maximum(${exclusiveMaximum}, { exclusive: true })`)\n if (checks.length > 0) {\n return `z.number().check(${checks.join(', ')})`\n }\n return 'z.number()'\n }\n return [\n coercion ? 'z.coerce.number()' : 'z.number()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n exclusiveMinimum !== undefined ? `.gt(${exclusiveMinimum})` : undefined,\n exclusiveMaximum !== undefined ? `.lt(${exclusiveMaximum})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3', exclusiveMinimum?: number, exclusiveMaximum?: number, mini?: boolean) => {\n if (mini) {\n const checks: string[] = []\n if (min !== undefined) checks.push(`z.minimum(${min})`)\n if (max !== undefined) checks.push(`z.maximum(${max})`)\n if (exclusiveMinimum !== undefined) checks.push(`z.minimum(${exclusiveMinimum}, { exclusive: true })`)\n if (exclusiveMaximum !== undefined) checks.push(`z.maximum(${exclusiveMaximum}, { exclusive: true })`)\n if (checks.length > 0) {\n return `z.int().check(${checks.join(', ')})`\n }\n return 'z.int()'\n }\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n exclusiveMinimum !== undefined ? `.gt(${exclusiveMinimum})` : undefined,\n exclusiveMaximum !== undefined ? `.lt(${exclusiveMaximum})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n bigint: (coercion?: boolean) => (coercion ? 'z.coerce.bigint()' : 'z.bigint()'),\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number, mini?: boolean) => {\n if (mini) {\n const checks = buildLengthChecks(min, max)\n if (checks.length > 0) {\n return `z.string().check(${checks.join(', ')})`\n }\n return 'z.string()'\n }\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: (value?: string) => {\n if (value) {\n return `z.nullable(${value})`\n }\n return '.nullable()'\n },\n null: () => 'z.null()',\n nullish: (value?: string) => {\n if (value) {\n return `z.nullish(${value})`\n }\n return '.nullish()'\n },\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean, mini?: boolean) => {\n if (mini) {\n const checks = buildLengthChecks(min, max)\n if (unique) checks.push(`z.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })`)\n if (checks.length > 0) {\n return `z.array(${items?.join('')}).check(${checks.join(', ')})`\n }\n return `z.array(${items?.join('')})`\n }\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3', mini?: boolean) => {\n // Zod Mini doesn't support .datetime() method, use plain string\n if (mini) {\n return 'z.string()'\n }\n\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return version === '4' ? 'z.iso.datetime()' : 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: ({\n coercion,\n version = '3',\n guidType = 'uuid',\n min,\n max,\n mini,\n }: {\n coercion?: boolean\n version?: '3' | '4'\n guidType?: 'uuid' | 'guid'\n min?: number\n max?: number\n mini?: boolean\n } = {}) => {\n const zodGuidType = version === '4' && guidType === 'guid' ? 'guid' : 'uuid'\n\n if (mini) {\n const checks = buildLengthChecks(min, max)\n if (checks.length > 0) {\n return `z.${zodGuidType}().check(${checks.join(', ')})`\n }\n return `z.${zodGuidType}()`\n }\n\n const zodV4UuidSchema = `z.${zodGuidType}()`\n\n return [\n coercion ? (version === '4' ? zodV4UuidSchema : 'z.coerce.string().uuid()') : version === '4' ? zodV4UuidSchema : 'z.string().uuid()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n url: (coercion?: boolean, version: '3' | '4' = '3', min?: number, max?: number, mini?: boolean) => {\n if (mini) {\n const checks = buildLengthChecks(min, max)\n if (checks.length > 0) {\n return `z.url().check(${checks.join(', ')})`\n }\n return 'z.url()'\n }\n return [\n coercion ? (version === '4' ? 'z.url()' : 'z.coerce.string().url()') : version === '4' ? 'z.url()' : 'z.string().url()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n default: (value?: string | number | boolean | object, innerSchema?: string, mini?: boolean, isBigInt?: boolean) => {\n if (mini && innerSchema) {\n // Wrap numeric values in BigInt() for bigint types in mini mode\n const defaultValue = isBigInt && typeof value === 'number' ? `BigInt(${value})` : typeof value === 'object' ? '{}' : (value ?? '')\n return `z._default(${innerSchema}, ${defaultValue})`\n }\n\n if (typeof value === 'object') {\n return '.default({})'\n }\n\n if (value === undefined) {\n return '.default()'\n }\n\n if (typeof value === 'string' && !value) {\n return `.default('')`\n }\n\n // Wrap numeric values in BigInt() for bigint types\n if (isBigInt && typeof value === 'number') {\n return `.default(BigInt(${value}))`\n }\n\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = [], mini?: boolean) => {\n // zod/mini doesn't support .and() method, so we can't use intersection types\n // In mini mode, we try to extract and append .check() calls instead\n if (mini && items.length > 0) {\n // Try to extract check calls from additional items\n const checks: string[] = []\n for (const item of items) {\n // Extract .check(...) from patterns like \"z.string().check(...)\"\n // Need to handle nested parentheses properly\n const checkStart = item.indexOf('.check(')\n if (checkStart !== -1) {\n // Find the matching closing parenthesis\n let depth = 0\n let i = checkStart + 7 // length of '.check('\n let checkContent = ''\n while (i < item.length) {\n const char = item[i]\n if (char === '(') depth++\n else if (char === ')') {\n if (depth === 0) break\n depth--\n }\n checkContent += char\n i++\n }\n if (checkContent) {\n checks.push(checkContent)\n }\n }\n }\n\n if (checks.length > 0) {\n // Append checks to the base schema\n return `.check(${checks.join(', ')})`\n }\n\n // If we can't extract checks, just use the first schema (limitation)\n return ''\n }\n return items?.map((item) => `.and(${item})`).join('')\n },\n describe: (value = '', innerSchema?: string, mini?: boolean) => {\n if (mini) {\n return undefined\n }\n\n if (innerSchema) {\n return `z.describe(${innerSchema}, ${value})`\n }\n return `.describe(${value})`\n },\n max: undefined,\n min: undefined,\n optional: (value?: string) => {\n if (value) {\n return `z.optional(${value})`\n }\n return '.optional()'\n },\n matches: (value = '', coercion?: boolean, mini?: boolean, min?: number, max?: number) => {\n if (mini) {\n const checks = buildLengthChecks(min, max)\n checks.push(`z.regex(${value})`)\n return `z.string().check(${checks.join(', ')})`\n }\n return [\n coercion ? 'z.coerce.string()' : 'z.string()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n `.regex(${value})`,\n ]\n .filter(Boolean)\n .join('')\n },\n email: (coercion?: boolean, version: '3' | '4' = '3', min?: number, max?: number, mini?: boolean) => {\n if (mini) {\n const checks = buildLengthChecks(min, max)\n if (checks.length > 0) {\n return `z.email().check(${checks.join(', ')})`\n }\n return 'z.email()'\n }\n return [\n coercion ? (version === '4' ? 'z.email()' : 'z.coerce.string().email()') : version === '4' ? 'z.email()' : 'z.string().email()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string) => {\n if (!value) {\n return undefined\n }\n\n return `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string, mini?: boolean) => {\n // Zod Mini doesn't support .catchall() method\n if (mini) {\n return undefined\n }\n return value ? `.catchall(${value})` : undefined\n },\n name: undefined,\n exclusiveMinimum: undefined,\n exclusiveMaximum: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return sortBy(items, [(v) => order.indexOf(v.keyword), 'asc'])\n}\n\ntype MiniModifiers = {\n hasOptional?: boolean\n hasNullable?: boolean\n hasNullish?: boolean\n defaultValue?: string | number | true | object\n isBigInt?: boolean\n}\n\n/**\n * Keywords that represent modifiers for mini mode\n * These are separated from the base schema and wrapped around it\n * Note: describe is included to filter it out, but won't be wrapped (Zod Mini doesn't support describe)\n */\nexport const miniModifierKeywords = [schemaKeywords.optional, schemaKeywords.nullable, schemaKeywords.nullish, schemaKeywords.default, schemaKeywords.describe]\n\n/**\n * Extracts mini mode modifiers from a schemas array\n * This can be reused by other parsers (e.g., valibot) that need similar functionality\n * Note: describe is not included as Zod Mini doesn't support it\n */\nexport function extractMiniModifiers(schemas: Schema[]): MiniModifiers {\n const defaultSchema = schemas.find((item) => isKeyword(item, schemaKeywords.default)) as { keyword: string; args: unknown } | undefined\n const isBigInt = schemas.some((item) => isKeyword(item, schemaKeywords.bigint))\n\n return {\n hasOptional: schemas.some((item) => isKeyword(item, schemaKeywords.optional)),\n hasNullable: schemas.some((item) => isKeyword(item, schemaKeywords.nullable)),\n hasNullish: schemas.some((item) => isKeyword(item, schemaKeywords.nullish)),\n defaultValue: defaultSchema?.args as string | number | true | object | undefined,\n isBigInt,\n }\n}\n\n/**\n * Filters out modifier keywords from schemas for mini mode base schema parsing\n * This can be reused by other parsers (e.g., valibot) that need similar functionality\n */\nexport function filterMiniModifiers(schemas: Schema[]): Schema[] {\n return schemas.filter((item) => !miniModifierKeywords.some((keyword) => isKeyword(item, keyword)))\n}\n\n/**\n * Wraps an output string with Zod Mini functional modifiers\n * Order: default (innermost) -> nullable -> optional (outermost)\n * OR: default -> nullish\n * Note: describe is not supported in Zod Mini and is skipped\n */\nexport function wrapWithMiniModifiers(output: string, modifiers: MiniModifiers): string {\n let result = output\n\n // Apply default first (innermost wrapper)\n if (modifiers.defaultValue !== undefined) {\n result = zodKeywordMapper.default(modifiers.defaultValue, result, true, modifiers.isBigInt)!\n }\n\n // Apply nullish, nullable, or optional (outer wrappers for optionality)\n if (modifiers.hasNullish) {\n result = zodKeywordMapper.nullish(result)!\n } else {\n if (modifiers.hasNullable) {\n result = zodKeywordMapper.nullable(result)!\n }\n if (modifiers.hasOptional) {\n result = zodKeywordMapper.optional(result)!\n }\n }\n\n return result\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n version: '3' | '4'\n guidType?: 'uuid' | 'guid'\n skipLazyForRefs?: boolean\n mini?: boolean\n}\n\n// Create the parser using createParser\nexport const parse = createParser<string, ParserOptions>({\n mapper: zodKeywordMapper,\n handlers: {\n union(tree, options) {\n const { current, schema, parent, name, siblings } = tree\n\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return this.parse({ schema, parent, name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((it, _index, siblings) => this.parse({ schema, parent: current, name, current: it, siblings }, options))\n .filter(Boolean),\n )\n },\n and(tree, options) {\n const { current, schema, name } = tree\n\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((it: Schema, _index, siblings) => this.parse({ schema, parent: current, name, current: it, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1), options.mini)}`\n },\n array(tree, options) {\n const { current, schema, name } = tree\n\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((it, _index, siblings) => {\n return this.parse({ schema, parent: current, name, current: it, siblings }, options)\n })\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n options.mini,\n )\n },\n enum(tree, options) {\n const { current, schema, name } = tree\n\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return this.parse({ schema, parent: current, name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((it, _index, siblings) => {\n return this.parse({ schema, parent: current, name, current: it, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return stringify(schema.value)\n }\n return stringify(schema.value)\n }),\n )\n },\n ref(tree, options) {\n const { current } = tree\n\n // Skip z.lazy wrapper if skipLazyForRefs is true (e.g., inside v4 getters)\n if (options.skipLazyForRefs) {\n return current.args?.name\n }\n return zodKeywordMapper.ref(current.args?.name)\n },\n object(tree, options) {\n const { current, schema, name } = tree\n\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([propertyName, schemas]) => {\n const nameSchema = schemas.find((it) => it.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable))\n const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish))\n const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional))\n const hasRef = !!SchemaGenerator.find(schemas, schemaKeywords.ref)\n\n const mappedName = nameSchema?.args || propertyName\n\n // custom mapper(pluginOptions)\n // Use Object.hasOwn to avoid matching inherited properties like 'toString', 'valueOf', etc.\n if (options.mapper && Object.hasOwn(options.mapper, mappedName)) {\n return `\"${propertyName}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .filter((schema) => {\n return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish)\n })\n .map((it) => {\n // For v4 with refs, skip z.lazy wrapper since the getter provides lazy evaluation\n const skipLazyForRefs = options.version === '4' && hasRef\n return this.parse({ schema, parent: current, name, current: it, siblings: schemas }, { ...options, skipLazyForRefs })\n })\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: schema?.properties?.[propertyName] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && hasRef) {\n // In mini mode, use functional wrappers instead of chainable methods\n if (options.mini) {\n // both optional and nullable\n if (isNullish) {\n return `get \"${propertyName}\"(){\n return ${zodKeywordMapper.nullish(objectValue)}\n }`\n }\n\n // undefined\n if (isOptional) {\n return `get \"${propertyName}\"(){\n return ${zodKeywordMapper.optional(objectValue)}\n }`\n }\n\n // null\n if (isNullable) {\n return `get \"${propertyName}\"(){\n return ${zodKeywordMapper.nullable(objectValue)}\n }`\n }\n\n return `get \"${propertyName}\"(){\n return ${objectValue}\n }`\n }\n\n // Non-mini mode uses chainable methods\n // both optional and nullable\n if (isNullish) {\n return `get \"${propertyName}\"(){\n return ${objectValue}${zodKeywordMapper.nullish()}\n }`\n }\n\n // undefined\n if (isOptional) {\n return `get \"${propertyName}\"(){\n return ${objectValue}${zodKeywordMapper.optional()}\n }`\n }\n\n // null\n if (isNullable) {\n return `get \"${propertyName}\"(){\n return ${objectValue}${zodKeywordMapper.nullable()}\n }`\n }\n\n return `get \"${propertyName}\"(){\n return ${objectValue}\n }`\n }\n\n // both optional and nullable\n if (isNullish && options.mini) {\n return `\"${propertyName}\": ${zodKeywordMapper.nullish(objectValue)}`\n }\n\n if (isNullish && !options.mini) {\n return `\"${propertyName}\": ${objectValue}${zodKeywordMapper.nullish()}`\n }\n\n // undefined\n if (isOptional) {\n return `\"${propertyName}\": ${zodKeywordMapper.optional(objectValue)}`\n }\n\n // null\n if (isNullable) {\n return `\"${propertyName}\": ${zodKeywordMapper.nullable(objectValue)}`\n }\n\n return `\"${propertyName}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((it, _index, siblings) => this.parse({ schema, parent: current, name, current: it, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties, options.mini) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n },\n tuple(tree, options) {\n const { current, schema, name } = tree\n\n return zodKeywordMapper.tuple(\n current.args.items.map((it, _index, siblings) => this.parse({ schema, parent: current, name, current: it, siblings }, options)).filter(Boolean),\n )\n },\n const(tree, _options) {\n const { current } = tree\n\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(typeof current.args.value === 'boolean' ? current.args.value : undefined)\n }\n return zodKeywordMapper.const(stringify(current.args.value))\n },\n matches(tree, options) {\n const { current, siblings } = tree\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n if (hasRef) {\n return undefined // strip matches\n }\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n\n if (current.args) {\n return zodKeywordMapper.matches(\n toRegExpString(current.args, null),\n shouldCoerce(options.coercion, 'strings'),\n options.mini,\n minSchema?.args,\n maxSchema?.args,\n )\n }\n return undefined\n },\n default(tree, options) {\n const { current, siblings } = tree\n\n // In mini mode, default is handled by wrapWithMiniModifiers\n if (options.mini) {\n return undefined\n }\n\n // Check if this is a bigint type by looking at siblings\n const isBigInt = siblings.some((it) => isKeyword(it, schemaKeywords.bigint))\n\n if (current.args !== undefined) {\n return zodKeywordMapper.default(current.args, undefined, undefined, isBigInt)\n }\n // When args is undefined, call the mapper without arguments\n return zodKeywordMapper.default()\n },\n describe(tree, options) {\n const { current } = tree\n\n if (current.args) {\n return zodKeywordMapper.describe(stringify(current.args.toString()), undefined, options.mini)\n }\n return undefined\n },\n string(tree, options) {\n const { siblings } = tree\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'), minSchema?.args, maxSchema?.args, options.mini)\n },\n uuid(tree, options) {\n const { siblings } = tree\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n\n return zodKeywordMapper.uuid({\n coercion: shouldCoerce(options.coercion, 'strings'),\n version: options.version,\n guidType: options.guidType,\n min: minSchema?.args,\n max: maxSchema?.args,\n mini: options.mini,\n })\n },\n email(tree, options) {\n const { siblings } = tree\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version, minSchema?.args, maxSchema?.args, options.mini)\n },\n url(tree, options) {\n const { siblings } = tree\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version, minSchema?.args, maxSchema?.args, options.mini)\n },\n number(tree, options) {\n const { siblings } = tree\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n const exclusiveMinimumSchema = findSchemaKeyword(siblings, 'exclusiveMinimum')\n const exclusiveMaximumSchema = findSchemaKeyword(siblings, 'exclusiveMaximum')\n\n return zodKeywordMapper.number(\n shouldCoerce(options.coercion, 'numbers'),\n minSchema?.args,\n maxSchema?.args,\n exclusiveMinimumSchema?.args,\n exclusiveMaximumSchema?.args,\n options.mini,\n )\n },\n integer(tree, options) {\n const { siblings } = tree\n\n const minSchema = findSchemaKeyword(siblings, 'min')\n const maxSchema = findSchemaKeyword(siblings, 'max')\n const exclusiveMinimumSchema = findSchemaKeyword(siblings, 'exclusiveMinimum')\n const exclusiveMaximumSchema = findSchemaKeyword(siblings, 'exclusiveMaximum')\n\n return zodKeywordMapper.integer(\n shouldCoerce(options.coercion, 'numbers'),\n minSchema?.args,\n maxSchema?.args,\n options.version,\n exclusiveMinimumSchema?.args,\n exclusiveMaximumSchema?.args,\n options.mini,\n )\n },\n bigint(_tree, options) {\n return zodKeywordMapper.bigint(shouldCoerce(options.coercion, 'numbers'))\n },\n datetime(tree, options) {\n const { current } = tree\n\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version, options.mini)\n },\n date(tree, options) {\n const { current } = tree\n\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n },\n time(tree, options) {\n const { current } = tree\n\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n },\n },\n})\n","import { jsStringEscape } from '@internals/utils'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n schema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n guidType: PluginZod['resolvedOptions']['guidType']\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n mini?: boolean\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n schema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n guidType,\n emptySchemaType,\n mini = false,\n}: Props): FabricReactNode {\n const hasTuple = !!SchemaGenerator.find(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n // In mini mode, filter out modifiers from the main schema parsing\n const baseSchemas = mini ? parserZod.filterMiniModifiers(schemas) : schemas\n\n const output = baseSchemas\n .map((schemaKeyword, index) => {\n const siblings = baseSchemas.filter((_, i) => i !== index)\n\n return parserZod.parse({ schema, parent: undefined, current: schemaKeyword, siblings, name }, { mapper, coercion, wrapOutput, version, guidType, mini })\n })\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (!mini && lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else if (!mini) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.schema'\n } else {\n suffix = '.unwrap()'\n }\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n schema,\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { mapper, coercion, wrapOutput, version, guidType, mini },\n )\n\n let baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `'${key}': true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n\n // For mini mode, wrap the output with modifiers using the parser function\n if (mini) {\n baseSchemaOutput = parserZod.wrapWithMiniModifiers(baseSchemaOutput, parserZod.extractMiniModifiers(schemas))\n }\n\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ${version === '4' ? 'z.ZodType' : 'ToZod'}<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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F,oBAAmBI,sBAAgC,kBAAkBC,qBAA+B,QAAQ,CAAC;CAG/G,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB;EAAQ,CAAC,IAAI,mBAAmB;CAChH,MAAM,cAAc,WAAW,GAAG,oBAAoB,iBAAiB,YAAY,MAAM,cAAc,QAAQ,GAAG,SAAS,KAAK;AAEhI,QACE,iBAAA,GAAA,+BAAA,MAAA,+BAAA,UAAA,EAAA,UAAA,CACE,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,KAAK,QAAN;EAAmB;EAAM,cAAA;EAAa,aAAA;YACpC,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,OAAD;GACE,QAAA;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgB,eAAe,YAAY,KAAK,KAAA,EAAU,CAAC,OAAO,QAAQ,EACpG;aAEA;GACK,CAAA;EACI,CAAA,EACb,iBACC,iBAAA,GAAA,+BAAA,MAACD,mBAAAA,KAAK,QAAN;EAAa,MAAM;EAAe,cAAA;EAAa,aAAA;EAAY,YAAA;YAA3D,CACG,YACC,iBAAA,GAAA,+BAAA,KAACE,mBAAAA,MAAD;GAAM,QAAA;GAAO,MAAM;aAChB;GACI,CAAA,EAER,CAAC,YACA,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,MAAD;GAAM,QAAA;GAAO,MAAM;aAChB,kBAAkB,KAAK;GACnB,CAAA,CAEG;IAEf,EAAA,CAAA"}
|
|
@@ -1,9 +1,94 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import transformers from "@kubb/core/transformers";
|
|
3
2
|
import { SchemaGenerator, createParser, findSchemaKeyword, isKeyword, schemaKeywords } from "@kubb/plugin-oas";
|
|
4
3
|
import { Const, File, Type } from "@kubb/react-fabric";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
6
5
|
import { sortBy } from "remeda";
|
|
6
|
+
//#region ../../internals/utils/src/string.ts
|
|
7
|
+
/**
|
|
8
|
+
* Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
|
|
9
|
+
* Returns the string unchanged when no balanced quote pair is found.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* trimQuotes('"hello"') // 'hello'
|
|
13
|
+
* trimQuotes('hello') // 'hello'
|
|
14
|
+
*/
|
|
15
|
+
function trimQuotes(text) {
|
|
16
|
+
if (text.length >= 2) {
|
|
17
|
+
const first = text[0];
|
|
18
|
+
const last = text[text.length - 1];
|
|
19
|
+
if (first === "\"" && last === "\"" || first === "'" && last === "'" || first === "`" && last === "`") return text.slice(1, -1);
|
|
20
|
+
}
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Escapes characters that are not allowed inside JS string literals.
|
|
25
|
+
* Handles quotes, backslashes, and Unicode line terminators (U+2028 / U+2029).
|
|
26
|
+
*
|
|
27
|
+
* @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
|
28
|
+
*/
|
|
29
|
+
function jsStringEscape(input) {
|
|
30
|
+
return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
|
|
31
|
+
switch (character) {
|
|
32
|
+
case "\"":
|
|
33
|
+
case "'":
|
|
34
|
+
case "\\": return `\\${character}`;
|
|
35
|
+
case "\n": return "\\n";
|
|
36
|
+
case "\r": return "\\r";
|
|
37
|
+
case "\u2028": return "\\u2028";
|
|
38
|
+
case "\u2029": return "\\u2029";
|
|
39
|
+
default: return "";
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region ../../internals/utils/src/object.ts
|
|
45
|
+
/**
|
|
46
|
+
* Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* stringify('hello') // '"hello"'
|
|
50
|
+
* stringify('"hello"') // '"hello"'
|
|
51
|
+
*/
|
|
52
|
+
function stringify(value) {
|
|
53
|
+
if (value === void 0 || value === null) return "\"\"";
|
|
54
|
+
return JSON.stringify(trimQuotes(value.toString()));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Converts a plain object into a multiline key-value string suitable for embedding in generated code.
|
|
58
|
+
* Nested objects are recursively stringified with indentation.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* stringifyObject({ foo: 'bar', nested: { a: 1 } })
|
|
62
|
+
* // 'foo: bar,\nnested: {\n a: 1\n }'
|
|
63
|
+
*/
|
|
64
|
+
function stringifyObject(value) {
|
|
65
|
+
return Object.entries(value).map(([key, val]) => {
|
|
66
|
+
if (val !== null && typeof val === "object") return `${key}: {\n ${stringifyObject(val)}\n }`;
|
|
67
|
+
return `${key}: ${val}`;
|
|
68
|
+
}).filter(Boolean).join(",\n");
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region ../../internals/utils/src/regexp.ts
|
|
72
|
+
/**
|
|
73
|
+
* Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.
|
|
74
|
+
* Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.
|
|
75
|
+
* Pass `null` as the second argument to emit a `/pattern/flags` literal instead.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* toRegExpString('^(?im)foo') // → 'new RegExp("foo", "im")'
|
|
79
|
+
* toRegExpString('^(?im)foo', null) // → '/foo/im'
|
|
80
|
+
*/
|
|
81
|
+
function toRegExpString(text, func = "RegExp") {
|
|
82
|
+
const raw = trimQuotes(text);
|
|
83
|
+
const match = raw.match(/^\^(\(\?([igmsuy]+)\))/i);
|
|
84
|
+
const replacementTarget = match?.[1] ?? "";
|
|
85
|
+
const matchedFlags = match?.[2];
|
|
86
|
+
const cleaned = raw.replace(/^\\?\//, "").replace(/\\?\/$/, "").replace(replacementTarget, "");
|
|
87
|
+
const { source, flags } = new RegExp(cleaned, matchedFlags);
|
|
88
|
+
if (func === null) return `/${source}/${flags}`;
|
|
89
|
+
return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ""})`;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
7
92
|
//#region src/components/Operations.tsx
|
|
8
93
|
function Operations({ name, operations }) {
|
|
9
94
|
const operationsJSON = operations.reduce((prev, acc) => {
|
|
@@ -60,7 +145,7 @@ function Operations({ name, operations }) {
|
|
|
60
145
|
export: true,
|
|
61
146
|
name,
|
|
62
147
|
asConst: true,
|
|
63
|
-
children: `{${
|
|
148
|
+
children: `{${stringifyObject(operationsJSON)}}`
|
|
64
149
|
})
|
|
65
150
|
}),
|
|
66
151
|
/* @__PURE__ */ jsx(File.Source, {
|
|
@@ -71,7 +156,7 @@ function Operations({ name, operations }) {
|
|
|
71
156
|
export: true,
|
|
72
157
|
name: "paths",
|
|
73
158
|
asConst: true,
|
|
74
|
-
children: `{${
|
|
159
|
+
children: `{${stringifyObject(pathsJSON)}}`
|
|
75
160
|
})
|
|
76
161
|
})
|
|
77
162
|
] });
|
|
@@ -487,9 +572,9 @@ const parse = createParser({
|
|
|
487
572
|
}).filter(Boolean));
|
|
488
573
|
}
|
|
489
574
|
return zodKeywordMapper.enum(current.args.items.map((schema) => {
|
|
490
|
-
if (schema.format === "boolean") return
|
|
491
|
-
if (schema.format === "number") return
|
|
492
|
-
return
|
|
575
|
+
if (schema.format === "boolean") return stringify(schema.value);
|
|
576
|
+
if (schema.format === "number") return stringify(schema.value);
|
|
577
|
+
return stringify(schema.value);
|
|
493
578
|
}));
|
|
494
579
|
},
|
|
495
580
|
ref(tree, options) {
|
|
@@ -586,14 +671,14 @@ const parse = createParser({
|
|
|
586
671
|
const { current } = tree;
|
|
587
672
|
if (current.args.format === "number" && current.args.value !== void 0) return zodKeywordMapper.const(Number(current.args.value));
|
|
588
673
|
if (current.args.format === "boolean" && current.args.value !== void 0) return zodKeywordMapper.const(typeof current.args.value === "boolean" ? current.args.value : void 0);
|
|
589
|
-
return zodKeywordMapper.const(
|
|
674
|
+
return zodKeywordMapper.const(stringify(current.args.value));
|
|
590
675
|
},
|
|
591
676
|
matches(tree, options) {
|
|
592
677
|
const { current, siblings } = tree;
|
|
593
678
|
if (siblings.some((it) => isKeyword(it, schemaKeywords.ref))) return;
|
|
594
679
|
const minSchema = findSchemaKeyword(siblings, "min");
|
|
595
680
|
const maxSchema = findSchemaKeyword(siblings, "max");
|
|
596
|
-
if (current.args) return zodKeywordMapper.matches(
|
|
681
|
+
if (current.args) return zodKeywordMapper.matches(toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"), options.mini, minSchema?.args, maxSchema?.args);
|
|
597
682
|
},
|
|
598
683
|
default(tree, options) {
|
|
599
684
|
const { current, siblings } = tree;
|
|
@@ -604,7 +689,7 @@ const parse = createParser({
|
|
|
604
689
|
},
|
|
605
690
|
describe(tree, options) {
|
|
606
691
|
const { current } = tree;
|
|
607
|
-
if (current.args) return zodKeywordMapper.describe(
|
|
692
|
+
if (current.args) return zodKeywordMapper.describe(stringify(current.args.toString()), void 0, options.mini);
|
|
608
693
|
},
|
|
609
694
|
string(tree, options) {
|
|
610
695
|
const { siblings } = tree;
|
|
@@ -732,7 +817,7 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
732
817
|
children: /* @__PURE__ */ jsx(Const, {
|
|
733
818
|
export: true,
|
|
734
819
|
name,
|
|
735
|
-
JSDoc: { comments: [description ? `@description ${
|
|
820
|
+
JSDoc: { comments: [description ? `@description ${jsStringEscape(description)}` : void 0].filter(Boolean) },
|
|
736
821
|
children: finalOutput
|
|
737
822
|
})
|
|
738
823
|
}), inferTypeName && /* @__PURE__ */ jsxs(File.Source, {
|
|
@@ -754,4 +839,4 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
754
839
|
//#endregion
|
|
755
840
|
export { Operations as n, Zod as t };
|
|
756
841
|
|
|
757
|
-
//# sourceMappingURL=components-
|
|
842
|
+
//# sourceMappingURL=components-eECfXVou.js.map
|