@kubb/plugin-zod 3.16.2 → 3.16.4
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-CJ6RN1R2.js +414 -0
- package/dist/components-CJ6RN1R2.js.map +1 -0
- package/dist/components-GvkeO2ig.cjs +454 -0
- package/dist/components-GvkeO2ig.cjs.map +1 -0
- package/dist/components.cjs +3 -15
- package/dist/components.d.cts +56 -26
- package/dist/components.d.ts +56 -26
- package/dist/components.js +3 -3
- package/dist/generators-C3ALr3ph.js +254 -0
- package/dist/generators-C3ALr3ph.js.map +1 -0
- package/dist/generators-D3uH7-vO.cjs +265 -0
- package/dist/generators-D3uH7-vO.cjs.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +8 -8
- package/dist/generators.d.ts +8 -8
- package/dist/generators.js +4 -4
- package/dist/index.cjs +103 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +103 -131
- package/dist/index.js.map +1 -1
- package/dist/types-B0UqdcbG.d.cts +1237 -0
- package/dist/types-YpNWeJUW.d.ts +1237 -0
- package/dist/utils/v4.cjs +0 -0
- package/dist/utils/v4.d.cts +38 -0
- package/dist/utils/v4.d.ts +38 -0
- package/dist/utils/v4.js +1 -0
- package/dist/utils.cjs +0 -4
- package/dist/utils.d.cts +18 -24
- package/dist/utils.d.ts +18 -24
- package/dist/utils.js +1 -3
- package/package.json +32 -31
- package/src/generators/zodGenerator.tsx +2 -2
- package/src/plugin.ts +2 -3
- package/src/utils/v4/ToZod.ts +61 -0
- package/src/utils/v4/index.ts +1 -0
- package/dist/chunk-4QMHDKCS.js +0 -453
- package/dist/chunk-4QMHDKCS.js.map +0 -1
- package/dist/chunk-6LDDO2JJ.cjs +0 -184
- package/dist/chunk-6LDDO2JJ.cjs.map +0 -1
- package/dist/chunk-FYI4GRXP.cjs +0 -460
- package/dist/chunk-FYI4GRXP.cjs.map +0 -1
- package/dist/chunk-I74P26CO.js +0 -181
- package/dist/chunk-I74P26CO.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-BOF1ntMm.d.cts +0 -130
- package/dist/types-BOF1ntMm.d.ts +0 -130
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
require('./components-GvkeO2ig.cjs');
|
|
2
|
+
const require_generators = require('./generators-D3uH7-vO.cjs');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "operationsGenerator", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return chunk6LDDO2JJ_cjs.operationsGenerator; }
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "zodGenerator", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return chunk6LDDO2JJ_cjs.zodGenerator; }
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=generators.cjs.map
|
|
17
|
-
//# sourceMappingURL=generators.cjs.map
|
|
4
|
+
exports.operationsGenerator = require_generators.operationsGenerator;
|
|
5
|
+
exports.zodGenerator = require_generators.zodGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { P as PluginZod } from './types-BOF1ntMm.cjs';
|
|
3
|
-
import '@kubb/core';
|
|
4
|
-
import '@kubb/oas';
|
|
5
|
-
|
|
6
|
-
declare const zodGenerator: _kubb_plugin_oas.Generator<PluginZod>;
|
|
7
|
-
|
|
8
|
-
declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginZod>;
|
|
1
|
+
import { Generator, PluginZod } from "./types-B0UqdcbG.cjs";
|
|
9
2
|
|
|
3
|
+
//#region src/generators/zodGenerator.d.ts
|
|
4
|
+
declare const zodGenerator: Generator<PluginZod>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/generators/operationsGenerator.d.ts
|
|
7
|
+
declare const operationsGenerator: Generator<PluginZod>;
|
|
8
|
+
//#endregion
|
|
10
9
|
export { operationsGenerator, zodGenerator };
|
|
10
|
+
//# sourceMappingURL=generators.d.cts.map
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { P as PluginZod } from './types-BOF1ntMm.js';
|
|
3
|
-
import '@kubb/core';
|
|
4
|
-
import '@kubb/oas';
|
|
5
|
-
|
|
6
|
-
declare const zodGenerator: _kubb_plugin_oas.Generator<PluginZod>;
|
|
7
|
-
|
|
8
|
-
declare const operationsGenerator: _kubb_plugin_oas.Generator<PluginZod>;
|
|
1
|
+
import { Generator, PluginZod } from "./types-YpNWeJUW.js";
|
|
9
2
|
|
|
3
|
+
//#region src/generators/zodGenerator.d.ts
|
|
4
|
+
declare const zodGenerator: Generator<PluginZod>;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/generators/operationsGenerator.d.ts
|
|
7
|
+
declare const operationsGenerator: Generator<PluginZod>;
|
|
8
|
+
//#endregion
|
|
10
9
|
export { operationsGenerator, zodGenerator };
|
|
10
|
+
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import "./components-CJ6RN1R2.js";
|
|
2
|
+
import { operationsGenerator, zodGenerator } from "./generators-C3ALr3ph.js";
|
|
3
|
+
|
|
4
|
+
export { operationsGenerator, zodGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,143 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
const require_components = require('./components-GvkeO2ig.cjs');
|
|
2
|
+
const require_generators = require('./generators-D3uH7-vO.cjs');
|
|
3
|
+
const node_path = require_components.__toESM(require("node:path"));
|
|
4
|
+
const __kubb_core = require_components.__toESM(require("@kubb/core"));
|
|
5
|
+
const __kubb_core_transformers = require_components.__toESM(require("@kubb/core/transformers"));
|
|
6
|
+
const __kubb_plugin_oas = require_components.__toESM(require("@kubb/plugin-oas"));
|
|
7
|
+
const __kubb_plugin_ts = require_components.__toESM(require("@kubb/plugin-ts"));
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
|
|
99
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
100
|
-
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
101
|
-
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
102
|
-
const schemaGenerator = new pluginOas.SchemaGenerator(this.plugin.options, {
|
|
103
|
-
oas,
|
|
104
|
-
pluginManager: this.pluginManager,
|
|
105
|
-
plugin: this.plugin,
|
|
106
|
-
contentType,
|
|
107
|
-
include: void 0,
|
|
108
|
-
override,
|
|
109
|
-
mode,
|
|
110
|
-
output: output.path
|
|
111
|
-
});
|
|
112
|
-
const schemaFiles = await schemaGenerator.build(...generators);
|
|
113
|
-
await this.addFile(...schemaFiles);
|
|
114
|
-
const operationGenerator = new pluginOas.OperationGenerator(this.plugin.options, {
|
|
115
|
-
oas,
|
|
116
|
-
pluginManager: this.pluginManager,
|
|
117
|
-
plugin: this.plugin,
|
|
118
|
-
contentType,
|
|
119
|
-
exclude,
|
|
120
|
-
include,
|
|
121
|
-
override,
|
|
122
|
-
mode
|
|
123
|
-
});
|
|
124
|
-
const operationFiles = await operationGenerator.build(...generators);
|
|
125
|
-
await this.addFile(...operationFiles);
|
|
126
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
127
|
-
type: output.barrelType ?? "named",
|
|
128
|
-
root,
|
|
129
|
-
output,
|
|
130
|
-
meta: {
|
|
131
|
-
pluginKey: this.plugin.key
|
|
132
|
-
},
|
|
133
|
-
logger: this.logger
|
|
134
|
-
});
|
|
135
|
-
await this.addFile(...barrelFiles);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
9
|
+
//#region src/plugin.ts
|
|
10
|
+
const pluginZodName = "plugin-zod";
|
|
11
|
+
const pluginZod = (0, __kubb_core.createPlugin)((options) => {
|
|
12
|
+
const { output = {
|
|
13
|
+
path: "zod",
|
|
14
|
+
barrelType: "named"
|
|
15
|
+
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, typed = false, mapper = {}, operations = false, version = new __kubb_core.PackageManager().isValidSync("zod", ">=4") ? "4" : "3", importPath = version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [require_generators.zodGenerator, operations ? require_generators.operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
16
|
+
return {
|
|
17
|
+
name: pluginZodName,
|
|
18
|
+
options: {
|
|
19
|
+
output,
|
|
20
|
+
transformers,
|
|
21
|
+
include,
|
|
22
|
+
exclude,
|
|
23
|
+
override,
|
|
24
|
+
typed,
|
|
25
|
+
dateType,
|
|
26
|
+
unknownType,
|
|
27
|
+
emptySchemaType,
|
|
28
|
+
mapper,
|
|
29
|
+
importPath,
|
|
30
|
+
coercion,
|
|
31
|
+
operations,
|
|
32
|
+
inferred,
|
|
33
|
+
group,
|
|
34
|
+
wrapOutput,
|
|
35
|
+
version
|
|
36
|
+
},
|
|
37
|
+
pre: [__kubb_plugin_oas.pluginOasName, typed ? __kubb_plugin_ts.pluginTsName : void 0].filter(Boolean),
|
|
38
|
+
resolvePath(baseName, pathMode, options$1) {
|
|
39
|
+
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
40
|
+
const mode = pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
|
|
41
|
+
if (mode === "single")
|
|
42
|
+
/**
|
|
43
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
44
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
45
|
+
*/
|
|
46
|
+
return node_path.default.resolve(root, output.path);
|
|
47
|
+
if (group && (options$1?.group?.path || options$1?.group?.tag)) {
|
|
48
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
49
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
50
|
+
return `${(0, __kubb_core_transformers.camelCase)(ctx.group)}Controller`;
|
|
51
|
+
};
|
|
52
|
+
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
|
|
53
|
+
}
|
|
54
|
+
return node_path.default.resolve(root, output.path, baseName);
|
|
55
|
+
},
|
|
56
|
+
resolveName(name, type) {
|
|
57
|
+
let resolvedName = (0, __kubb_core_transformers.camelCase)(name, {
|
|
58
|
+
suffix: type ? "schema" : void 0,
|
|
59
|
+
isFile: type === "file"
|
|
60
|
+
});
|
|
61
|
+
if (type === "type") resolvedName = (0, __kubb_core_transformers.pascalCase)(resolvedName);
|
|
62
|
+
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
63
|
+
return resolvedName;
|
|
64
|
+
},
|
|
65
|
+
async buildStart() {
|
|
66
|
+
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
67
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
68
|
+
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
69
|
+
const mode = __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
|
|
70
|
+
const schemaGenerator = new __kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
|
|
71
|
+
oas,
|
|
72
|
+
pluginManager: this.pluginManager,
|
|
73
|
+
plugin: this.plugin,
|
|
74
|
+
contentType,
|
|
75
|
+
include: void 0,
|
|
76
|
+
override,
|
|
77
|
+
mode,
|
|
78
|
+
output: output.path
|
|
79
|
+
});
|
|
80
|
+
const schemaFiles = await schemaGenerator.build(...generators);
|
|
81
|
+
await this.addFile(...schemaFiles);
|
|
82
|
+
const operationGenerator = new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
83
|
+
oas,
|
|
84
|
+
pluginManager: this.pluginManager,
|
|
85
|
+
plugin: this.plugin,
|
|
86
|
+
contentType,
|
|
87
|
+
exclude,
|
|
88
|
+
include,
|
|
89
|
+
override,
|
|
90
|
+
mode
|
|
91
|
+
});
|
|
92
|
+
const operationFiles = await operationGenerator.build(...generators);
|
|
93
|
+
await this.addFile(...operationFiles);
|
|
94
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
95
|
+
type: output.barrelType ?? "named",
|
|
96
|
+
root,
|
|
97
|
+
output,
|
|
98
|
+
meta: { pluginKey: this.plugin.key },
|
|
99
|
+
logger: this.logger
|
|
100
|
+
});
|
|
101
|
+
await this.addFile(...barrelFiles);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
138
104
|
});
|
|
139
105
|
|
|
106
|
+
//#endregion
|
|
140
107
|
exports.pluginZod = pluginZod;
|
|
141
108
|
exports.pluginZodName = pluginZodName;
|
|
142
|
-
//# sourceMappingURL=index.cjs.map
|
|
143
109
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","options","path","FileManager","groupName: Group['name']","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, FileManager, type Group, PackageManager, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\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', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n version = new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\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,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,0CAAoC,CAAC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;CAAS,GAC7C,OACA,UAAU,CAAE,GACZ,SACA,WAAW,CAAE,GACb,eAAe,CAAE,GACjB,WAAW,UACX,cAAc,OACd,kBAAkB,aAClB,QAAQ,OACR,SAAS,CAAE,GACX,aAAa,OACb,UAAU,IAAIA,6BAAiB,YAAY,OAAO,MAAM,GAAG,MAAM,KACjE,aAAa,YAAY,MAAM,WAAW,OAC1C,WAAW,OACX,WAAW,OACX,aAAa,CAACC,iCAAc,aAAaC,yCAAsB,MAAU,EAAC,OAAO,QAAQ,EACzF,aAAa,QACb,aACD,GAAG;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD;EACD,KAAK,CAACC,iCAAe,QAAQC,gCAAe,MAAU,EAAC,OAAO,QAAQ;EACtE,YAAY,UAAU,UAAUC,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,YAAYC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;AAE7E,OAAI,SAAS;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUD,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMG,YAA2B,OAAO,OACpC,MAAM,OACN,CAAC,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC,IAAI;AAErC,YAAO,2CAAa,IAAI,MAAM,CAAC,UAAU,CAAC;IAC3C;AAEL,WAAOF,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,IACpE,EAAC,EACF,SACD;GACF;AAED,UAAOC,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;EACjD;EACD,YAAY,MAAM,MAAM;GACtB,IAAI,uDAAyB,MAAM;IACjC,QAAQ,OAAO,WAAW;IAC1B,QAAQ,SAAS;GAClB,EAAC;AAEF,OAAI,SAAS,QACX,wDAA0B,aAAa;AAGzC,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;EACR;EACD,MAAM,aAAa;GACjB,MAAM,CAAC,cAA8C,GAAGG,0BAAc,mBAAyC,KAAK,SAAS,CAACN,+BAAc,EAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOG,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAOC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAEjE,MAAM,kBAAkB,IAAII,kCAAgB,KAAK,OAAO,SAAS;IAC/D;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;GAChB;GAED,MAAM,cAAc,MAAM,gBAAgB,MAAM,GAAG,WAAW;GAC9D,MAAM,KAAK,QAAQ,GAAG,YAAY;GAElC,MAAM,qBAAqB,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;GACD;GAED,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG,WAAW;GACpE,MAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,IACxB;IACD,QAAQ,KAAK;GACd,EAAC;GAEF,MAAM,KAAK,QAAQ,GAAG,YAAY;EACnC;CACF;AACF,EAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { O as Options, P as PluginZod } from './types-BOF1ntMm.cjs';
|
|
3
|
-
import '@kubb/oas';
|
|
4
|
-
import '@kubb/plugin-oas';
|
|
1
|
+
import { Options, PluginZod, UserPluginWithLifeCycle } from "./types-B0UqdcbG.cjs";
|
|
5
2
|
|
|
3
|
+
//#region src/plugin.d.ts
|
|
6
4
|
declare const pluginZodName = "plugin-zod";
|
|
7
|
-
declare const pluginZod: (options?: Options | undefined) =>
|
|
8
|
-
|
|
9
|
-
export { PluginZod, pluginZod, pluginZodName };
|
|
5
|
+
declare const pluginZod: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginZod>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type PluginZod, pluginZod, pluginZodName };
|
|
8
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { O as Options, P as PluginZod } from './types-BOF1ntMm.js';
|
|
3
|
-
import '@kubb/oas';
|
|
4
|
-
import '@kubb/plugin-oas';
|
|
1
|
+
import { Options, PluginZod, UserPluginWithLifeCycle } from "./types-YpNWeJUW.js";
|
|
5
2
|
|
|
3
|
+
//#region src/plugin.d.ts
|
|
6
4
|
declare const pluginZodName = "plugin-zod";
|
|
7
|
-
declare const pluginZod: (options?: Options | undefined) =>
|
|
8
|
-
|
|
9
|
-
export { PluginZod, pluginZod, pluginZodName };
|
|
5
|
+
declare const pluginZod: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginZod>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type PluginZod, pluginZod, pluginZodName };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,136 +1,108 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import path from
|
|
4
|
-
import {
|
|
5
|
-
import { camelCase, pascalCase } from
|
|
6
|
-
import {
|
|
7
|
-
import { pluginTsName } from
|
|
1
|
+
import "./components-CJ6RN1R2.js";
|
|
2
|
+
import { operationsGenerator, zodGenerator } from "./generators-C3ALr3ph.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { FileManager, PackageManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
|
+
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
6
|
+
import { OperationGenerator, SchemaGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
output: output.path
|
|
105
|
-
});
|
|
106
|
-
const schemaFiles = await schemaGenerator.build(...generators);
|
|
107
|
-
await this.addFile(...schemaFiles);
|
|
108
|
-
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
109
|
-
oas,
|
|
110
|
-
pluginManager: this.pluginManager,
|
|
111
|
-
plugin: this.plugin,
|
|
112
|
-
contentType,
|
|
113
|
-
exclude,
|
|
114
|
-
include,
|
|
115
|
-
override,
|
|
116
|
-
mode
|
|
117
|
-
});
|
|
118
|
-
const operationFiles = await operationGenerator.build(...generators);
|
|
119
|
-
await this.addFile(...operationFiles);
|
|
120
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
121
|
-
type: output.barrelType ?? "named",
|
|
122
|
-
root,
|
|
123
|
-
output,
|
|
124
|
-
meta: {
|
|
125
|
-
pluginKey: this.plugin.key
|
|
126
|
-
},
|
|
127
|
-
logger: this.logger
|
|
128
|
-
});
|
|
129
|
-
await this.addFile(...barrelFiles);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
9
|
+
//#region src/plugin.ts
|
|
10
|
+
const pluginZodName = "plugin-zod";
|
|
11
|
+
const pluginZod = createPlugin((options) => {
|
|
12
|
+
const { output = {
|
|
13
|
+
path: "zod",
|
|
14
|
+
barrelType: "named"
|
|
15
|
+
}, group, exclude = [], include, override = [], transformers: transformers$1 = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, typed = false, mapper = {}, operations = false, version = new PackageManager().isValidSync("zod", ">=4") ? "4" : "3", importPath = version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
16
|
+
return {
|
|
17
|
+
name: pluginZodName,
|
|
18
|
+
options: {
|
|
19
|
+
output,
|
|
20
|
+
transformers: transformers$1,
|
|
21
|
+
include,
|
|
22
|
+
exclude,
|
|
23
|
+
override,
|
|
24
|
+
typed,
|
|
25
|
+
dateType,
|
|
26
|
+
unknownType,
|
|
27
|
+
emptySchemaType,
|
|
28
|
+
mapper,
|
|
29
|
+
importPath,
|
|
30
|
+
coercion,
|
|
31
|
+
operations,
|
|
32
|
+
inferred,
|
|
33
|
+
group,
|
|
34
|
+
wrapOutput,
|
|
35
|
+
version
|
|
36
|
+
},
|
|
37
|
+
pre: [pluginOasName, typed ? pluginTsName : void 0].filter(Boolean),
|
|
38
|
+
resolvePath(baseName, pathMode, options$1) {
|
|
39
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
40
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
41
|
+
if (mode === "single")
|
|
42
|
+
/**
|
|
43
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
44
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
45
|
+
*/
|
|
46
|
+
return path.resolve(root, output.path);
|
|
47
|
+
if (group && (options$1?.group?.path || options$1?.group?.tag)) {
|
|
48
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
49
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
50
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
51
|
+
};
|
|
52
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
|
|
53
|
+
}
|
|
54
|
+
return path.resolve(root, output.path, baseName);
|
|
55
|
+
},
|
|
56
|
+
resolveName(name, type) {
|
|
57
|
+
let resolvedName = camelCase(name, {
|
|
58
|
+
suffix: type ? "schema" : void 0,
|
|
59
|
+
isFile: type === "file"
|
|
60
|
+
});
|
|
61
|
+
if (type === "type") resolvedName = pascalCase(resolvedName);
|
|
62
|
+
if (type) return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
63
|
+
return resolvedName;
|
|
64
|
+
},
|
|
65
|
+
async buildStart() {
|
|
66
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
67
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
68
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
69
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
70
|
+
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|
|
71
|
+
oas,
|
|
72
|
+
pluginManager: this.pluginManager,
|
|
73
|
+
plugin: this.plugin,
|
|
74
|
+
contentType,
|
|
75
|
+
include: void 0,
|
|
76
|
+
override,
|
|
77
|
+
mode,
|
|
78
|
+
output: output.path
|
|
79
|
+
});
|
|
80
|
+
const schemaFiles = await schemaGenerator.build(...generators);
|
|
81
|
+
await this.addFile(...schemaFiles);
|
|
82
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
83
|
+
oas,
|
|
84
|
+
pluginManager: this.pluginManager,
|
|
85
|
+
plugin: this.plugin,
|
|
86
|
+
contentType,
|
|
87
|
+
exclude,
|
|
88
|
+
include,
|
|
89
|
+
override,
|
|
90
|
+
mode
|
|
91
|
+
});
|
|
92
|
+
const operationFiles = await operationGenerator.build(...generators);
|
|
93
|
+
await this.addFile(...operationFiles);
|
|
94
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
95
|
+
type: output.barrelType ?? "named",
|
|
96
|
+
root,
|
|
97
|
+
output,
|
|
98
|
+
meta: { pluginKey: this.plugin.key },
|
|
99
|
+
logger: this.logger
|
|
100
|
+
});
|
|
101
|
+
await this.addFile(...barrelFiles);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
132
104
|
});
|
|
133
105
|
|
|
106
|
+
//#endregion
|
|
134
107
|
export { pluginZod, pluginZodName };
|
|
135
|
-
//# sourceMappingURL=index.js.map
|
|
136
108
|
//# sourceMappingURL=index.js.map
|