@kubb/plugin-zod 3.0.0-alpha.19 → 3.0.0-alpha.20

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,241 @@
1
+ import { Zod, Operations } from './chunk-KGKZCQKF.js';
2
+ import { createReactGenerator, SchemaGenerator, pluginOasName, OperationGenerator, schemaKeywords } from '@kubb/plugin-oas';
3
+ import { Oas } from '@kubb/plugin-oas/components';
4
+ import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks';
5
+ import { pluginTsName } from '@kubb/plugin-ts';
6
+ import { useApp, File } from '@kubb/react';
7
+ import { jsxs, jsx } from '@kubb/react/jsx-runtime';
8
+ import path from 'node:path';
9
+ import { createPlugin, FileManager, PluginManager } from '@kubb/core';
10
+ import { camelCase, pascalCase } from '@kubb/core/transformers';
11
+ import { renderTemplate } from '@kubb/core/utils';
12
+
13
+ var zodGenerator = createReactGenerator({
14
+ name: "zod",
15
+ Operation({ operation, options }) {
16
+ const { coercion, inferred, typed, mapper } = options;
17
+ const { plugin, pluginManager, mode } = useApp();
18
+ const oas = useOas();
19
+ const { getSchemas, getFile } = useOperationManager();
20
+ const schemaManager = useSchemaManager();
21
+ const file = getFile(operation);
22
+ const schemas = getSchemas(operation);
23
+ const schemaGenerator = new SchemaGenerator(options, {
24
+ oas,
25
+ plugin,
26
+ pluginManager,
27
+ mode,
28
+ override: options.override
29
+ });
30
+ const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response].flat().filter(Boolean);
31
+ const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options2 }, i) => {
32
+ const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required;
33
+ const optional = !required && !!name.includes("Params");
34
+ const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : void 0].filter(Boolean);
35
+ const imports = schemaManager.getImports(tree);
36
+ const zod = {
37
+ name: schemaManager.getName(name, { type: "function" }),
38
+ inferTypeName: schemaManager.getName(name, { type: "type" }),
39
+ file: schemaManager.getFile(name)
40
+ };
41
+ const type = {
42
+ name: schemaManager.getName(name, { type: "type", pluginKey: [pluginTsName] }),
43
+ file: schemaManager.getFile(options2.operationName || name, { pluginKey: [pluginTsName], tag: options2.operation?.getTags()[0]?.name })
44
+ };
45
+ return /* @__PURE__ */ jsxs(Oas.Schema, { name, value: schema, tree, children: [
46
+ typed && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: file.path, path: type.file.path, name: [type.name] }),
47
+ imports.map((imp, index) => /* @__PURE__ */ jsx(File.Import, { root: file.path, path: imp.path, name: imp.name }, index)),
48
+ /* @__PURE__ */ jsx(
49
+ Zod,
50
+ {
51
+ name: zod.name,
52
+ typeName: typed ? type.name : void 0,
53
+ inferTypeName: inferred ? zod.inferTypeName : void 0,
54
+ description,
55
+ tree,
56
+ mapper,
57
+ coercion,
58
+ keysToOmit
59
+ }
60
+ )
61
+ ] }, i);
62
+ };
63
+ return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: plugin.options.output?.banner, footer: plugin.options.output?.footer, children: [
64
+ /* @__PURE__ */ jsx(File.Import, { name: ["z"], path: plugin.options.importPath }),
65
+ operationSchemas.map(mapOperationSchema)
66
+ ] });
67
+ },
68
+ Schema({ schema, options }) {
69
+ const { coercion, inferred, typed, mapper, importPath } = options;
70
+ const { getName, getFile, getImports } = useSchemaManager();
71
+ const {
72
+ plugin: {
73
+ options: { output }
74
+ }
75
+ } = useApp();
76
+ const imports = getImports(schema.tree);
77
+ const zod = {
78
+ name: getName(schema.name, { type: "function" }),
79
+ inferTypeName: getName(schema.name, { type: "type" }),
80
+ file: getFile(schema.name)
81
+ };
82
+ const type = {
83
+ name: getName(schema.name, { type: "type", pluginKey: [pluginTsName] }),
84
+ file: getFile(schema.name, { pluginKey: [pluginTsName] })
85
+ };
86
+ return /* @__PURE__ */ jsxs(File, { baseName: zod.file.baseName, path: zod.file.path, meta: zod.file.meta, banner: output?.banner, footer: output?.footer, children: [
87
+ /* @__PURE__ */ jsx(File.Import, { name: ["z"], path: importPath }),
88
+ typed && /* @__PURE__ */ jsx(File.Import, { isTypeOnly: true, root: zod.file.path, path: type.file.path, name: [type.name] }),
89
+ imports.map((imp, index) => /* @__PURE__ */ jsx(File.Import, { root: zod.file.path, path: imp.path, name: imp.name }, index)),
90
+ /* @__PURE__ */ jsx(
91
+ Zod,
92
+ {
93
+ name: zod.name,
94
+ typeName: typed ? type.name : void 0,
95
+ inferTypeName: inferred ? zod.inferTypeName : void 0,
96
+ description: schema.value.description,
97
+ tree: schema.tree,
98
+ mapper,
99
+ coercion
100
+ }
101
+ )
102
+ ] });
103
+ }
104
+ });
105
+ var pluginZodName = "plugin-zod";
106
+ var pluginZod = createPlugin((options) => {
107
+ const {
108
+ output = { path: "zod" },
109
+ group,
110
+ exclude = [],
111
+ include,
112
+ override = [],
113
+ transformers = {},
114
+ dateType = "string",
115
+ unknownType = "any",
116
+ typed = false,
117
+ mapper = {},
118
+ operations = false,
119
+ importPath = "zod",
120
+ coercion = false,
121
+ inferred = false
122
+ } = options;
123
+ const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
124
+ return {
125
+ name: pluginZodName,
126
+ options: {
127
+ output: {
128
+ exportType: "barrelNamed",
129
+ ...output
130
+ },
131
+ extName: output.extName,
132
+ transformers,
133
+ include,
134
+ exclude,
135
+ override,
136
+ typed,
137
+ dateType,
138
+ unknownType,
139
+ mapper,
140
+ importPath,
141
+ coercion,
142
+ operations,
143
+ inferred
144
+ },
145
+ pre: [pluginOasName, typed ? pluginTsName : void 0].filter(Boolean),
146
+ resolvePath(baseName, pathMode, options2) {
147
+ const root = path.resolve(this.config.root, this.config.output.path);
148
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
149
+ if (mode === "single") {
150
+ return path.resolve(root, output.path);
151
+ }
152
+ if (options2?.tag && group?.type === "tag") {
153
+ const tag = camelCase(options2.tag);
154
+ return path.resolve(root, renderTemplate(template, { tag }), baseName);
155
+ }
156
+ return path.resolve(root, output.path, baseName);
157
+ },
158
+ resolveName(name, type) {
159
+ let resolvedName = camelCase(name, {
160
+ suffix: type ? "schema" : void 0,
161
+ isFile: type === "file"
162
+ });
163
+ if (type === "type") {
164
+ resolvedName = pascalCase(resolvedName);
165
+ }
166
+ if (type) {
167
+ return transformers?.name?.(resolvedName, type) || resolvedName;
168
+ }
169
+ return resolvedName;
170
+ },
171
+ async buildStart() {
172
+ const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
173
+ const oas = await swaggerPlugin.context.getOas();
174
+ const root = path.resolve(this.config.root, this.config.output.path);
175
+ const mode = FileManager.getMode(path.resolve(root, output.path));
176
+ const schemaGenerator = new SchemaGenerator(this.plugin.options, {
177
+ oas,
178
+ pluginManager: this.pluginManager,
179
+ plugin: this.plugin,
180
+ contentType: swaggerPlugin.context.contentType,
181
+ include: void 0,
182
+ override,
183
+ mode,
184
+ output: output.path
185
+ });
186
+ const schemaFiles = await schemaGenerator.build(...[zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
187
+ await this.addFile(...schemaFiles);
188
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
189
+ oas,
190
+ pluginManager: this.pluginManager,
191
+ plugin: this.plugin,
192
+ contentType: swaggerPlugin.context.contentType,
193
+ exclude,
194
+ include,
195
+ override,
196
+ mode
197
+ });
198
+ const operationFiles = await operationGenerator.build(...[zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean));
199
+ await this.addFile(...operationFiles);
200
+ if (this.config.output.exportType) {
201
+ const barrelFiles = await this.fileManager.getBarrelFiles({
202
+ root,
203
+ output,
204
+ files: this.fileManager.files,
205
+ meta: {
206
+ pluginKey: this.plugin.key
207
+ },
208
+ logger: this.logger
209
+ });
210
+ await this.addFile(...barrelFiles);
211
+ }
212
+ }
213
+ };
214
+ });
215
+ var operationsGenerator = createReactGenerator({
216
+ name: "operations",
217
+ Operations({ operations }) {
218
+ const {
219
+ pluginManager,
220
+ plugin: {
221
+ options: { output }
222
+ }
223
+ } = useApp();
224
+ const { getFile, groupSchemasByName } = useOperationManager();
225
+ const name = "operations";
226
+ const file = pluginManager.getFile({ name, extName: ".ts", pluginKey: [pluginZodName] });
227
+ const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: "function" }) }));
228
+ const imports = Object.entries(transformedOperations).map(([key, { data, operation }]) => {
229
+ const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean);
230
+ return /* @__PURE__ */ jsx(File.Import, { name: names, root: file.path, path: getFile(operation).path }, key);
231
+ }).filter(Boolean);
232
+ return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: [
233
+ imports,
234
+ /* @__PURE__ */ jsx(Operations, { name, operations: transformedOperations })
235
+ ] });
236
+ }
237
+ });
238
+
239
+ export { operationsGenerator, pluginZod, pluginZodName, zodGenerator };
240
+ //# sourceMappingURL=chunk-WIOP5MTW.js.map
241
+ //# sourceMappingURL=chunk-WIOP5MTW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generators/zodGenerator.tsx","../src/plugin.ts","../src/generators/operationsGenerator.tsx"],"names":["options","pluginTsName","SchemaGenerator","createReactGenerator","useApp","useOperationManager","jsx","File","jsxs"],"mappings":";;;;;;;;;;;;AAQO,IAAM,eAAe,oBAAgC,CAAA;AAAA,EAC1D,IAAM,EAAA,KAAA;AAAA,EACN,SAAU,CAAA,EAAE,SAAW,EAAA,OAAA,EAAW,EAAA;AAChC,IAAA,MAAM,EAAE,QAAA,EAAU,QAAU,EAAA,KAAA,EAAO,QAAW,GAAA,OAAA,CAAA;AAE9C,IAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,IAAA,KAAS,MAAkB,EAAA,CAAA;AAC1D,IAAA,MAAM,MAAM,MAAO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AAG,EAAA,GAAG,OAAO,MAAO,CAAA,IAAA,CAAK,UAAU,CAAC,CAAA,CAAE,OAAO,OAAO,CAAA,CAAA;AAEhH,MAAA,uBAAOC,GAAAA,CAACC,IAAK,CAAA,MAAA,EAAL,EAAsB,IAAM,EAAA,KAAA,EAAO,IAAM,EAAA,IAAA,CAAK,MAAM,IAAM,EAAA,OAAA,CAAQ,SAAS,CAAA,CAAE,QAA5D,GAAkE,CAAA,CAAA;AAAA,KAC5F,CACA,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAEjB,IAAA,uBACEC,IAACD,CAAAA,IAAAA,EAAA,EAAK,QAAU,EAAA,IAAA,CAAK,UAAU,IAAM,EAAA,IAAA,CAAK,IAAM,EAAA,IAAA,EAAM,KAAK,IAAM,EAAA,MAAA,EAAQ,QAAQ,MAAQ,EAAA,MAAA,EAAQ,QAAQ,MACtG,EAAA,QAAA,EAAA;AAAA,MAAA,OAAA;AAAA,sBACDD,GAAAA,CAAC,UAAW,EAAA,EAAA,IAAA,EAAY,YAAY,qBAAuB,EAAA,CAAA;AAAA,KAC7D,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-WIOP5MTW.js","sourcesContent":["import { type OperationSchema as OperationSchemaType, SchemaGenerator, createReactGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion, inferred, typed, mapper } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\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\n const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required\n const optional = !required && !!name.includes('Params')\n const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\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, { type: 'type', pluginKey: [pluginTsName] }),\n file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], tag: options.operation?.getTags()[0]?.name }),\n }\n\n return (\n <Oas.Schema key={i} name={name} value={schema} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp, index) => (\n <File.Import key={index} 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 mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta} banner={plugin.options.output?.banner} footer={plugin.options.output?.footer}>\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginZod>()\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', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File baseName={zod.file.baseName} path={zod.file.path} meta={zod.file.meta} banner={output?.banner} footer={output?.footer}>\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {imports.map((imp, index) => (\n <File.Import key={index} 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 mapper={mapper}\n coercion={coercion}\n />\n </File>\n )\n },\n})\n","import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n typed = false,\n mapper = {},\n operations = false,\n importPath = 'zod',\n coercion = false,\n inferred = false,\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginZodName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n extName: output.extName,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...[zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean))\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...[zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean))\n await this.addFile(...operationFiles)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport { pluginZodName } from '../plugin.ts'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n options: { output },\n },\n } = useApp<PluginZod>()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extName: '.ts', pluginKey: [pluginZodName] })\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 return (\n <File baseName={file.baseName} path={file.path} meta={file.meta} banner={output?.banner} footer={output?.footer}>\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"]}
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkIFCC7VQX_cjs = require('./chunk-IFCC7VQX.cjs');
3
+ var chunkRPZWETTK_cjs = require('./chunk-RPZWETTK.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Operations", {
8
8
  enumerable: true,
9
- get: function () { return chunkIFCC7VQX_cjs.Operations; }
9
+ get: function () { return chunkRPZWETTK_cjs.Operations; }
10
10
  });
11
11
  Object.defineProperty(exports, "Zod", {
12
12
  enumerable: true,
13
- get: function () { return chunkIFCC7VQX_cjs.Zod; }
13
+ get: function () { return chunkRPZWETTK_cjs.Zod; }
14
14
  });
15
15
  //# sourceMappingURL=components.cjs.map
16
16
  //# sourceMappingURL=components.cjs.map
@@ -2,7 +2,7 @@ import { SchemaNames } from '@kubb/plugin-oas/hooks';
2
2
  import { Operation } from '@kubb/oas';
3
3
  import { KubbNode } from '@kubb/react/types';
4
4
  import { Schema } from '@kubb/plugin-oas';
5
- import { P as PluginZod } from './types-D7_wds1i.cjs';
5
+ import { P as PluginZod } from './types-BRWHhUnI.cjs';
6
6
  import '@kubb/core';
7
7
 
8
8
  type Props$1 = {
@@ -2,7 +2,7 @@ import { SchemaNames } from '@kubb/plugin-oas/hooks';
2
2
  import { Operation } from '@kubb/oas';
3
3
  import { KubbNode } from '@kubb/react/types';
4
4
  import { Schema } from '@kubb/plugin-oas';
5
- import { P as PluginZod } from './types-D7_wds1i.js';
5
+ import { P as PluginZod } from './types-BRWHhUnI.js';
6
6
  import '@kubb/core';
7
7
 
8
8
  type Props$1 = {
@@ -1,3 +1,3 @@
1
- export { Operations, Zod } from './chunk-LOZEOT4J.js';
1
+ export { Operations, Zod } from './chunk-KGKZCQKF.js';
2
2
  //# sourceMappingURL=components.js.map
3
3
  //# sourceMappingURL=components.js.map
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkEZIBUHZO_cjs = require('./chunk-EZIBUHZO.cjs');
4
- require('./chunk-IFCC7VQX.cjs');
3
+ var chunkGILKYHDS_cjs = require('./chunk-GILKYHDS.cjs');
4
+ require('./chunk-RPZWETTK.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "operationsGenerator", {
9
9
  enumerable: true,
10
- get: function () { return chunkEZIBUHZO_cjs.operationsGenerator; }
10
+ get: function () { return chunkGILKYHDS_cjs.operationsGenerator; }
11
11
  });
12
12
  Object.defineProperty(exports, "zodGenerator", {
13
13
  enumerable: true,
14
- get: function () { return chunkEZIBUHZO_cjs.zodGenerator; }
14
+ get: function () { return chunkGILKYHDS_cjs.zodGenerator; }
15
15
  });
16
16
  //# sourceMappingURL=generators.cjs.map
17
17
  //# sourceMappingURL=generators.cjs.map
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginZod } from './types-D7_wds1i.cjs';
2
+ import { P as PluginZod } from './types-BRWHhUnI.cjs';
3
3
  import '@kubb/core';
4
4
  import '@kubb/oas';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginZod } from './types-D7_wds1i.js';
2
+ import { P as PluginZod } from './types-BRWHhUnI.js';
3
3
  import '@kubb/core';
4
4
  import '@kubb/oas';
5
5
 
@@ -1,4 +1,4 @@
1
- export { operationsGenerator, zodGenerator } from './chunk-GZX3ETVC.js';
2
- import './chunk-LOZEOT4J.js';
1
+ export { operationsGenerator, zodGenerator } from './chunk-WIOP5MTW.js';
2
+ import './chunk-KGKZCQKF.js';
3
3
  //# sourceMappingURL=generators.js.map
4
4
  //# sourceMappingURL=generators.js.map
package/dist/index.cjs CHANGED
@@ -1,18 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkEZIBUHZO_cjs = require('./chunk-EZIBUHZO.cjs');
4
- var chunkIFCC7VQX_cjs = require('./chunk-IFCC7VQX.cjs');
3
+ var chunkGILKYHDS_cjs = require('./chunk-GILKYHDS.cjs');
4
+ require('./chunk-RPZWETTK.cjs');
5
+
5
6
 
6
- // src/index.ts
7
- chunkIFCC7VQX_cjs.init_cjs_shims();
8
7
 
9
8
  Object.defineProperty(exports, "pluginZod", {
10
9
  enumerable: true,
11
- get: function () { return chunkEZIBUHZO_cjs.pluginZod; }
10
+ get: function () { return chunkGILKYHDS_cjs.pluginZod; }
12
11
  });
13
12
  Object.defineProperty(exports, "pluginZodName", {
14
13
  enumerable: true,
15
- get: function () { return chunkEZIBUHZO_cjs.pluginZodName; }
14
+ get: function () { return chunkGILKYHDS_cjs.pluginZodName; }
16
15
  });
17
16
  //# sourceMappingURL=index.cjs.map
18
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["init_cjs_shims"],"mappings":";;;;;;AAAAA,gCAAA,EAAA","file":"index.cjs","sourcesContent":["export { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginZod } from './types-D7_wds1i.cjs';
2
+ import { O as Options, P as PluginZod } from './types-BRWHhUnI.cjs';
3
3
  import '@kubb/oas';
4
4
  import '@kubb/plugin-oas';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginZod } from './types-D7_wds1i.js';
2
+ import { O as Options, P as PluginZod } from './types-BRWHhUnI.js';
3
3
  import '@kubb/oas';
4
4
  import '@kubb/plugin-oas';
5
5
 
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
- export { pluginZod, pluginZodName } from './chunk-GZX3ETVC.js';
2
- import { init_esm_shims } from './chunk-LOZEOT4J.js';
3
-
4
- // src/index.ts
5
- init_esm_shims();
1
+ export { pluginZod, pluginZodName } from './chunk-WIOP5MTW.js';
2
+ import './chunk-KGKZCQKF.js';
6
3
  //# sourceMappingURL=index.js.map
7
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,cAAA,EAAA","file":"index.js","sourcesContent":["export { pluginZod, pluginZodName } from './plugin.ts'\nexport type { PluginZod } from './types.ts'\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -92,6 +92,7 @@ type Options = {
92
92
  };
93
93
  };
94
94
  type ResolvedOptions = {
95
+ output: Output;
95
96
  override: NonNullable<Options['override']>;
96
97
  transformers: NonNullable<Options['transformers']>;
97
98
  dateType: NonNullable<Options['dateType']>;
@@ -92,6 +92,7 @@ type Options = {
92
92
  };
93
93
  };
94
94
  type ResolvedOptions = {
95
+ output: Output;
95
96
  override: NonNullable<Options['override']>;
96
97
  transformers: NonNullable<Options['transformers']>;
97
98
  dateType: NonNullable<Options['dateType']>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "3.0.0-alpha.19",
3
+ "version": "3.0.0-alpha.20",
4
4
  "description": "Generator plugin-zod",
5
5
  "keywords": [
6
6
  "typescript",
@@ -58,20 +58,21 @@
58
58
  "!/**/__tests__/**"
59
59
  ],
60
60
  "dependencies": {
61
- "@kubb/core": "3.0.0-alpha.19",
62
- "@kubb/fs": "3.0.0-alpha.19",
63
- "@kubb/oas": "3.0.0-alpha.19",
64
- "@kubb/parser-ts": "3.0.0-alpha.19",
65
- "@kubb/plugin-oas": "3.0.0-alpha.19",
66
- "@kubb/react": "3.0.0-alpha.19"
61
+ "@kubb/core": "3.0.0-alpha.20",
62
+ "@kubb/fs": "3.0.0-alpha.20",
63
+ "@kubb/plugin-ts": "3.0.0-alpha.20",
64
+ "@kubb/oas": "3.0.0-alpha.20",
65
+ "@kubb/parser-ts": "3.0.0-alpha.20",
66
+ "@kubb/plugin-oas": "3.0.0-alpha.20",
67
+ "@kubb/react": "3.0.0-alpha.20"
67
68
  },
68
69
  "devDependencies": {
69
70
  "tsup": "^8.2.4",
70
- "@kubb/config-ts": "3.0.0-alpha.19",
71
- "@kubb/config-tsup": "3.0.0-alpha.19"
71
+ "@kubb/config-ts": "3.0.0-alpha.20",
72
+ "@kubb/config-tsup": "3.0.0-alpha.20"
72
73
  },
73
74
  "peerDependencies": {
74
- "@kubb/react": "3.0.0-alpha.19"
75
+ "@kubb/react": "3.0.0-alpha.20"
75
76
  },
76
77
  "engines": {
77
78
  "node": ">=20"
@@ -10,7 +10,9 @@ export const operationsGenerator = createReactGenerator<PluginZod>({
10
10
  Operations({ operations }) {
11
11
  const {
12
12
  pluginManager,
13
- plugin: { output },
13
+ plugin: {
14
+ options: { output },
15
+ },
14
16
  } = useApp<PluginZod>()
15
17
  const { getFile, groupSchemasByName } = useOperationManager()
16
18
 
@@ -69,7 +69,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
69
69
  }
70
70
 
71
71
  return (
72
- <File baseName={file.baseName} path={file.path} meta={file.meta} banner={plugin.output?.banner} footer={plugin.output?.footer}>
72
+ <File baseName={file.baseName} path={file.path} meta={file.meta} banner={plugin.options.output?.banner} footer={plugin.options.output?.footer}>
73
73
  <File.Import name={['z']} path={plugin.options.importPath} />
74
74
  {operationSchemas.map(mapOperationSchema)}
75
75
  </File>
@@ -80,7 +80,9 @@ export const zodGenerator = createReactGenerator<PluginZod>({
80
80
 
81
81
  const { getName, getFile, getImports } = useSchemaManager()
82
82
  const {
83
- plugin: { output },
83
+ plugin: {
84
+ options: { output },
85
+ },
84
86
  } = useApp<PluginZod>()
85
87
 
86
88
  const imports = getImports(schema.tree)
package/src/plugin.ts CHANGED
@@ -36,11 +36,11 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
36
36
 
37
37
  return {
38
38
  name: pluginZodName,
39
- output: {
40
- exportType: 'barrelNamed',
41
- ...output,
42
- },
43
39
  options: {
40
+ output: {
41
+ exportType: 'barrelNamed',
42
+ ...output,
43
+ },
44
44
  extName: output.extName,
45
45
  transformers,
46
46
  include,
package/src/types.ts CHANGED
@@ -97,8 +97,8 @@ export type Options = {
97
97
  }
98
98
 
99
99
  type ResolvedOptions = {
100
+ output: Output
100
101
  override: NonNullable<Options['override']>
101
-
102
102
  transformers: NonNullable<Options['transformers']>
103
103
  dateType: NonNullable<Options['dateType']>
104
104
  unknownType: NonNullable<Options['unknownType']>