@kubb/plugin-zod 5.0.0-alpha.3 → 5.0.0-alpha.31

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.
Files changed (46) hide show
  1. package/dist/index.cjs +1619 -100
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +418 -4
  4. package/dist/index.js +1614 -100
  5. package/dist/index.js.map +1 -1
  6. package/package.json +6 -34
  7. package/src/components/Operations.tsx +22 -15
  8. package/src/components/Zod.tsx +20 -119
  9. package/src/constants.ts +5 -0
  10. package/src/generators/zodGenerator.tsx +129 -159
  11. package/src/generators/zodGeneratorLegacy.tsx +365 -0
  12. package/src/index.ts +12 -1
  13. package/src/plugin.ts +102 -148
  14. package/src/presets.ts +30 -0
  15. package/src/printers/printerZod.ts +298 -0
  16. package/src/printers/printerZodMini.ts +273 -0
  17. package/src/resolvers/resolverZod.ts +61 -0
  18. package/src/resolvers/resolverZodLegacy.ts +60 -0
  19. package/src/types.ts +172 -93
  20. package/src/utils.ts +248 -0
  21. package/dist/components-B7zUFnAm.cjs +0 -890
  22. package/dist/components-B7zUFnAm.cjs.map +0 -1
  23. package/dist/components-eECfXVou.js +0 -842
  24. package/dist/components-eECfXVou.js.map +0 -1
  25. package/dist/components.cjs +0 -4
  26. package/dist/components.d.ts +0 -56
  27. package/dist/components.js +0 -2
  28. package/dist/generators-CRKtFRi1.js +0 -290
  29. package/dist/generators-CRKtFRi1.js.map +0 -1
  30. package/dist/generators-CzSLRVqQ.cjs +0 -301
  31. package/dist/generators-CzSLRVqQ.cjs.map +0 -1
  32. package/dist/generators.cjs +0 -4
  33. package/dist/generators.d.ts +0 -503
  34. package/dist/generators.js +0 -2
  35. package/dist/templates/ToZod.source.cjs +0 -7
  36. package/dist/templates/ToZod.source.cjs.map +0 -1
  37. package/dist/templates/ToZod.source.d.ts +0 -7
  38. package/dist/templates/ToZod.source.js +0 -6
  39. package/dist/templates/ToZod.source.js.map +0 -1
  40. package/dist/types-D0wsPC6Y.d.ts +0 -172
  41. package/src/components/index.ts +0 -2
  42. package/src/generators/index.ts +0 -2
  43. package/src/generators/operationsGenerator.tsx +0 -50
  44. package/src/parser.ts +0 -909
  45. package/src/templates/ToZod.source.ts +0 -4
  46. package/templates/ToZod.ts +0 -61
@@ -1,301 +0,0 @@
1
- const require_components = require("./components-B7zUFnAm.cjs");
2
- let node_path = require("node:path");
3
- node_path = require_components.__toESM(node_path);
4
- let _kubb_plugin_oas = require("@kubb/plugin-oas");
5
- let _kubb_plugin_ts = require("@kubb/plugin-ts");
6
- let _kubb_core_hooks = require("@kubb/core/hooks");
7
- let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
8
- let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
9
- let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
10
- let _kubb_react_fabric = require("@kubb/react-fabric");
11
- let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
12
- //#region src/generators/operationsGenerator.tsx
13
- const operationsGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
14
- name: "operations",
15
- Operations({ operations, generator, plugin }) {
16
- const { name: pluginName, options: { output, importPath } } = plugin;
17
- const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
18
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
19
- const { getFile, groupSchemasByName } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
20
- const name = "operations";
21
- const file = pluginManager.getFile({
22
- name,
23
- extname: ".ts",
24
- pluginName
25
- });
26
- const transformedOperations = operations.map((operation) => ({
27
- operation,
28
- data: groupSchemasByName(operation, { type: "function" })
29
- }));
30
- const imports = Object.entries(transformedOperations).map(([key, { data, operation }]) => {
31
- const names = [
32
- data.request,
33
- ...Object.values(data.responses),
34
- ...Object.values(data.parameters)
35
- ].filter(Boolean);
36
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
37
- name: names,
38
- root: file.path,
39
- path: getFile(operation).path
40
- }, key);
41
- }).filter(Boolean);
42
- const isZodImport = importPath === "zod" || importPath === "zod/mini";
43
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
44
- baseName: file.baseName,
45
- path: file.path,
46
- meta: file.meta,
47
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
48
- oas,
49
- output,
50
- config: pluginManager.config
51
- }),
52
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
53
- oas,
54
- output
55
- }),
56
- children: [
57
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
58
- isTypeOnly: true,
59
- name: isZodImport ? "z" : ["z"],
60
- path: importPath,
61
- isNameSpace: isZodImport
62
- }),
63
- imports,
64
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Operations, {
65
- name,
66
- operations: transformedOperations
67
- })
68
- ]
69
- });
70
- }
71
- });
72
- //#endregion
73
- //#region src/generators/zodGenerator.tsx
74
- const zodGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
75
- name: "zod",
76
- Operation({ config, operation, generator, plugin }) {
77
- const { options, options: { coercion: globalCoercion, inferred, typed, mapper, wrapOutput, version, guidType, mini } } = plugin;
78
- const mode = (0, _kubb_core_hooks.useMode)();
79
- const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
80
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
81
- const { getSchemas, getFile, getGroup } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
82
- const schemaManager = (0, _kubb_plugin_oas_hooks.useSchemaManager)();
83
- const file = getFile(operation);
84
- const schemas = getSchemas(operation);
85
- const schemaGenerator = new _kubb_plugin_oas.SchemaGenerator(options, {
86
- fabric: generator.context.fabric,
87
- oas,
88
- plugin,
89
- pluginManager,
90
- events: generator.context.events,
91
- mode,
92
- override: options.override
93
- });
94
- const operationSchemas = [
95
- schemas.pathParams,
96
- schemas.queryParams,
97
- schemas.headerParams,
98
- schemas.statusCodes,
99
- schemas.request,
100
- schemas.response
101
- ].flat().filter(Boolean);
102
- const toZodPath = node_path.default.resolve(config.root, config.output.path, ".kubb/ToZod.ts");
103
- const mapOperationSchema = ({ name, schema: schemaOriginal, description, keysToOmit: keysToOmitOriginal, ...options }) => {
104
- let schemaObject = schemaOriginal;
105
- let keysToOmit = keysToOmitOriginal;
106
- if ((schemaOriginal.anyOf || schemaOriginal.oneOf) && keysToOmitOriginal && keysToOmitOriginal.length > 0) {
107
- schemaObject = structuredClone(schemaOriginal);
108
- delete schemaObject.$ref;
109
- for (const key of keysToOmitOriginal) delete schemaObject.properties?.[key];
110
- if (Array.isArray(schemaObject.required)) schemaObject.required = schemaObject.required.filter((key) => !keysToOmitOriginal.includes(key));
111
- keysToOmit = void 0;
112
- }
113
- const hasProperties = Object.keys(schemaObject || {}).length > 0;
114
- const hasDefaults = Object.values(schemaObject.properties || {}).some((prop) => prop && Object.hasOwn(prop, "default"));
115
- const optional = !(Array.isArray(schemaObject?.required) ? schemaObject.required.length > 0 : !!schemaObject?.required) && !hasDefaults && hasProperties && name.includes("Params");
116
- if (!optional && Array.isArray(schemaObject.required) && !schemaObject.required.length) schemaObject.required = Object.entries(schemaObject.properties || {}).filter(([_key, value]) => value && Object.hasOwn(value, "default")).map(([key]) => key);
117
- const tree = [...schemaGenerator.parse({
118
- schema: schemaObject,
119
- name,
120
- parentName: null
121
- }), optional ? { keyword: _kubb_plugin_oas.schemaKeywords.optional } : void 0].filter(Boolean);
122
- const imports = (0, _kubb_plugin_oas_utils.getImports)(tree);
123
- const group = options.operation ? getGroup(options.operation) : void 0;
124
- const coercion = name.includes("Params") ? {
125
- numbers: true,
126
- strings: false,
127
- dates: true
128
- } : globalCoercion;
129
- const zod = {
130
- name: schemaManager.getName(name, { type: "function" }),
131
- inferTypeName: schemaManager.getName(name, { type: "type" }),
132
- file: schemaManager.getFile(name)
133
- };
134
- const type = {
135
- name: schemaManager.getName(name, {
136
- type: "type",
137
- pluginName: _kubb_plugin_ts.pluginTsName
138
- }),
139
- file: schemaManager.getFile(options.operationName || name, {
140
- pluginName: _kubb_plugin_ts.pluginTsName,
141
- group
142
- })
143
- };
144
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
145
- typed && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
146
- isTypeOnly: true,
147
- root: file.path,
148
- path: type.file.path,
149
- name: [type.name]
150
- }),
151
- imports.map((imp) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
152
- root: file.path,
153
- path: imp.path,
154
- name: imp.name
155
- }, [
156
- imp.path,
157
- imp.name,
158
- imp.isTypeOnly
159
- ].join("-"))),
160
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Zod, {
161
- name: zod.name,
162
- typeName: typed ? type.name : void 0,
163
- inferTypeName: inferred ? zod.inferTypeName : void 0,
164
- description,
165
- tree,
166
- schema: schemaObject,
167
- mapper,
168
- coercion,
169
- keysToOmit,
170
- wrapOutput,
171
- version: plugin.options.version,
172
- guidType,
173
- emptySchemaType: plugin.options.emptySchemaType,
174
- mini
175
- })
176
- ] });
177
- };
178
- const isZodImport = plugin.options.importPath === "zod" || plugin.options.importPath === "zod/mini";
179
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
180
- baseName: file.baseName,
181
- path: file.path,
182
- meta: file.meta,
183
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
184
- oas,
185
- output: plugin.options.output,
186
- config: pluginManager.config
187
- }),
188
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
189
- oas,
190
- output: plugin.options.output
191
- }),
192
- children: [
193
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
194
- name: isZodImport ? "z" : ["z"],
195
- path: plugin.options.importPath,
196
- isNameSpace: isZodImport
197
- }),
198
- typed && version === "3" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
199
- name: ["ToZod"],
200
- isTypeOnly: true,
201
- root: file.path,
202
- path: toZodPath
203
- }),
204
- operationSchemas.map(mapOperationSchema)
205
- ]
206
- });
207
- },
208
- Schema({ config, schema, plugin }) {
209
- const { getName, getFile } = (0, _kubb_plugin_oas_hooks.useSchemaManager)();
210
- const { options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version, guidType, mini } } = plugin;
211
- const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
212
- const oas = (0, _kubb_plugin_oas_hooks.useOas)();
213
- const imports = (0, _kubb_plugin_oas_utils.getImports)(schema.tree);
214
- const zod = {
215
- name: getName(schema.name, { type: "function" }),
216
- inferTypeName: getName(schema.name, { type: "type" }),
217
- file: getFile(schema.name)
218
- };
219
- const type = {
220
- name: getName(schema.name, {
221
- type: "type",
222
- pluginName: _kubb_plugin_ts.pluginTsName
223
- }),
224
- file: getFile(schema.name, { pluginName: _kubb_plugin_ts.pluginTsName })
225
- };
226
- const isZodImport = importPath === "zod" || importPath === "zod/mini";
227
- const toZodPath = node_path.default.resolve(config.root, config.output.path, ".kubb/ToZod.ts");
228
- return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
229
- baseName: zod.file.baseName,
230
- path: zod.file.path,
231
- meta: zod.file.meta,
232
- banner: (0, _kubb_plugin_oas_utils.getBanner)({
233
- oas,
234
- output,
235
- config: pluginManager.config
236
- }),
237
- footer: (0, _kubb_plugin_oas_utils.getFooter)({
238
- oas,
239
- output
240
- }),
241
- children: [
242
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
243
- name: isZodImport ? "z" : ["z"],
244
- path: importPath,
245
- isNameSpace: isZodImport
246
- }),
247
- typed && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
248
- isTypeOnly: true,
249
- root: zod.file.path,
250
- path: type.file.path,
251
- name: [type.name]
252
- }),
253
- typed && version === "3" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
254
- name: ["ToZod"],
255
- isTypeOnly: true,
256
- root: zod.file.path,
257
- path: toZodPath
258
- }),
259
- imports.map((imp) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
260
- root: zod.file.path,
261
- path: imp.path,
262
- name: imp.name
263
- }, [
264
- imp.path,
265
- imp.name,
266
- imp.isTypeOnly
267
- ].join("-"))),
268
- /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Zod, {
269
- name: zod.name,
270
- typeName: typed ? type.name : void 0,
271
- inferTypeName: inferred ? zod.inferTypeName : void 0,
272
- description: schema.value.description,
273
- tree: schema.tree,
274
- schema: schema.value,
275
- mapper,
276
- coercion,
277
- wrapOutput,
278
- version,
279
- guidType,
280
- emptySchemaType,
281
- mini
282
- })
283
- ]
284
- });
285
- }
286
- });
287
- //#endregion
288
- Object.defineProperty(exports, "operationsGenerator", {
289
- enumerable: true,
290
- get: function() {
291
- return operationsGenerator;
292
- }
293
- });
294
- Object.defineProperty(exports, "zodGenerator", {
295
- enumerable: true,
296
- get: function() {
297
- return zodGenerator;
298
- }
299
- });
300
-
301
- //# sourceMappingURL=generators-CzSLRVqQ.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-CzSLRVqQ.cjs","names":["File","Operations","SchemaGenerator","path","schemaKeywords","pluginTsName","File","Zod"],"sources":["../src/generators/operationsGenerator.tsx","../src/generators/zodGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Operations } from '../components/Operations.tsx'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const {\n name: pluginName,\n options: { output, importPath },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager(generator)\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginName })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import isTypeOnly name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter, getImports } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { coercion: globalCoercion, inferred, typed, mapper, wrapOutput, version, guidType, mini },\n } = plugin\n\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n pluginManager,\n events: generator.context.events,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n const toZodPath = path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')\n\n const mapOperationSchema = ({ name, schema: schemaOriginal, description, keysToOmit: keysToOmitOriginal, ...options }: OperationSchemaType) => {\n let schemaObject = schemaOriginal\n let keysToOmit = keysToOmitOriginal\n\n if ((schemaOriginal.anyOf || schemaOriginal.oneOf) && keysToOmitOriginal && keysToOmitOriginal.length > 0) {\n schemaObject = structuredClone(schemaOriginal)\n\n // Remove $ref so the schema parser generates inline schema instead of a reference\n delete schemaObject.$ref\n\n for (const key of keysToOmitOriginal) {\n delete schemaObject.properties?.[key]\n }\n\n if (Array.isArray(schemaObject.required)) {\n schemaObject.required = schemaObject.required.filter((key) => !keysToOmitOriginal.includes(key))\n }\n\n keysToOmit = undefined\n }\n\n const hasProperties = Object.keys(schemaObject || {}).length > 0\n const hasDefaults = Object.values(schemaObject.properties || {}).some((prop) => prop && Object.hasOwn(prop, 'default'))\n\n const required = Array.isArray(schemaObject?.required) ? schemaObject.required.length > 0 : !!schemaObject?.required\n const optional = !required && !hasDefaults && hasProperties && name.includes('Params')\n\n if (!optional && Array.isArray(schemaObject.required) && !schemaObject.required.length) {\n schemaObject.required = Object.entries(schemaObject.properties || {})\n .filter(([_key, value]) => value && Object.hasOwn(value, 'default'))\n .map(([key]) => key)\n }\n\n const tree = [\n ...schemaGenerator.parse({ schema: schemaObject, name, parentName: null }),\n optional ? { keyword: schemaKeywords.optional } : undefined,\n ].filter(Boolean)\n const imports = getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginName: pluginTsName,\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginName: pluginTsName,\n group,\n }),\n }\n\n return (\n <>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n schema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n guidType={guidType}\n emptySchemaType={plugin.options.emptySchemaType}\n mini={mini}\n />\n </>\n )\n }\n\n const isZodImport = plugin.options.importPath === 'zod' || plugin.options.importPath === 'zod/mini'\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={isZodImport ? 'z' : ['z']} path={plugin.options.importPath} isNameSpace={isZodImport} />\n {typed && version === '3' && <File.Import name={['ToZod']} isTypeOnly root={file.path} path={toZodPath} />}\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ config, schema, plugin }) {\n const { getName, getFile } = useSchemaManager()\n const {\n options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version, guidType, mini },\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginName: pluginTsName }),\n file: getFile(schema.name, { pluginName: pluginTsName }),\n }\n\n const isZodImport = importPath === 'zod' || importPath === 'zod/mini'\n const toZodPath = path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={isZodImport ? 'z' : ['z']} path={importPath} isNameSpace={isZodImport} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && version === '3' && <File.Import name={['ToZod']} isTypeOnly root={zod.file.path} path={toZodPath} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n guidType={guidType}\n emptySchemaType={emptySchemaType}\n mini={mini}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AAQA,MAAa,uBAAA,GAAA,4BAAA,sBAAsD;CACjE,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,EACJ,MAAM,YACN,SAAS,EAAE,QAAQ,iBACjB;EACJ,MAAM,iBAAA,GAAA,iBAAA,mBAAkC;EAExC,MAAM,OAAA,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,mBAAAA,KAAK,QAAN;KAAa,MAAM,cAAc,MAAM,CAAC,IAAI;KAAE,MAAM;KAAY,aAAa;KAAe,CAAA;IAC3F,SAAS,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,YAAA;KAAW,MAAM,IAAI,KAAK;KAAM,MAAM,KAAK,KAAK;KAAM,MAAM,CAAC,KAAK,KAAK;KAAI,CAAA;IACjG,SAAS,YAAY,OAAO,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,QAAQ;KAAE,YAAA;KAAW,MAAM,IAAI,KAAK;KAAM,MAAM;KAAa,CAAA;IAC7G,QAAQ,KAAK,QACZ,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAkE,MAAM,IAAI,KAAK;KAAM,MAAM,IAAI;KAAM,MAAM,IAAI;KAAQ,EAAvG;KAAC,IAAI;KAAM,IAAI;KAAM,IAAI;KAAW,CAAC,KAAK,IAAI,CAAyD,CACzH;IAEF,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,KAAD;KACE,MAAM,IAAI;KACV,UAAU,QAAQ,KAAK,OAAO,KAAA;KAC9B,eAAe,WAAW,IAAI,gBAAgB,KAAA;KAC9C,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACb,QAAQ,OAAO;KACP;KACE;KACE;KACH;KACC;KACO;KACX;KACN,CAAA;IACG;;;CAGZ,CAAC"}
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generators = require("./generators-CzSLRVqQ.cjs");
3
- exports.operationsGenerator = require_generators.operationsGenerator;
4
- exports.zodGenerator = require_generators.zodGenerator;