@kubb/plugin-zod 4.2.0 → 4.2.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.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-CQb3A4Sz.d.ts → types-QZU4k-_1.d.ts} +13 -57
- package/dist/{types-w5zjJR8e.d.cts → types-vzmWp6Js.d.cts} +13 -57
- package/package.json +7 -7
- package/src/plugin.ts +4 -4
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Schema, n as PluginZod, o as Operation, s as SchemaObject } from "./types-
|
|
1
|
+
import { i as Schema, n as PluginZod, o as Operation, s as SchemaObject } from "./types-vzmWp6Js.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-oas/src/hooks/useOperationManager.d.ts
|
|
4
4
|
|
package/dist/components.d.ts
CHANGED
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ const pluginZod = (0, __kubb_core.createPlugin)((options) => {
|
|
|
42
42
|
pre: [__kubb_plugin_oas.pluginOasName, typed ? __kubb_plugin_ts.pluginTsName : void 0].filter(Boolean),
|
|
43
43
|
resolvePath(baseName, pathMode, options$1) {
|
|
44
44
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
45
|
-
if ((pathMode ?? __kubb_core.
|
|
45
|
+
if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
46
46
|
/**
|
|
47
47
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
48
48
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -70,7 +70,7 @@ const pluginZod = (0, __kubb_core.createPlugin)((options) => {
|
|
|
70
70
|
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
71
71
|
const oas = await swaggerPlugin.context.getOas();
|
|
72
72
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
73
|
-
const mode = __kubb_core.
|
|
73
|
+
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
74
74
|
const schemaFiles = await new __kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
|
|
75
75
|
oas,
|
|
76
76
|
pluginManager: this.pluginManager,
|
|
@@ -93,7 +93,7 @@ const pluginZod = (0, __kubb_core.createPlugin)((options) => {
|
|
|
93
93
|
mode
|
|
94
94
|
}).build(...generators);
|
|
95
95
|
await this.addFile(...operationFiles);
|
|
96
|
-
const barrelFiles = await this.fileManager.
|
|
96
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
|
|
97
97
|
type: output.barrelType ?? "named",
|
|
98
98
|
root,
|
|
99
99
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, 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 ?? 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 = 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 getBarrelFiles(this.fileManager.files, {\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,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,WAAW,UACX,cAAc,OACd,kBAAkB,aAClB,QAAQ,OACR,SAAS,EAAE,EACX,aAAa,OACb,UAAU,IAAIA,4BAAgB,CAAC,YAAY,OAAO,MAAM,GAAG,MAAM,KACjE,aAAa,YAAY,MAAM,WAAW,OAC1C,WAAW,OACX,WAAW,OACX,aAAa,CAACC,iCAAc,aAAaC,yCAAsB,OAAU,CAAC,OAAO,QAAQ,EACzF,aAAa,QACb,gBACE;AAE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O,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,cAAc,MAXI,IAAII,kCAAgB,KAAK,OAAO,SAAS;IAC/D;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAalC,MAAM,iBAAiB,MAXI,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,sCAAqB,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-vzmWp6Js.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginZodName = "plugin-zod";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-QZU4k-_1.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginZodName = "plugin-zod";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./components-8y_GG0Uf.js";
|
|
2
2
|
import { n as zodGenerator, t as operationsGenerator } from "./generators-bYDLojHd.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { PackageManager, PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
6
6
|
import { OperationGenerator, SchemaGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
7
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
@@ -37,7 +37,7 @@ const pluginZod = createPlugin((options) => {
|
|
|
37
37
|
pre: [pluginOasName, typed ? pluginTsName : void 0].filter(Boolean),
|
|
38
38
|
resolvePath(baseName, pathMode, options$1) {
|
|
39
39
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
40
|
-
if ((pathMode ??
|
|
40
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
41
41
|
/**
|
|
42
42
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
43
43
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -65,7 +65,7 @@ const pluginZod = createPlugin((options) => {
|
|
|
65
65
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
66
66
|
const oas = await swaggerPlugin.context.getOas();
|
|
67
67
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
68
|
-
const mode =
|
|
68
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
69
69
|
const schemaFiles = await new SchemaGenerator(this.plugin.options, {
|
|
70
70
|
oas,
|
|
71
71
|
pluginManager: this.pluginManager,
|
|
@@ -88,7 +88,7 @@ const pluginZod = createPlugin((options) => {
|
|
|
88
88
|
mode
|
|
89
89
|
}).build(...generators);
|
|
90
90
|
await this.addFile(...operationFiles);
|
|
91
|
-
const barrelFiles = await this.fileManager.
|
|
91
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
92
92
|
type: output.barrelType ?? "named",
|
|
93
93
|
root,
|
|
94
94
|
output,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin,
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, 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 ?? 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 = 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 getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: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}
|
|
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
8
9
|
|
|
9
10
|
//#region ../oas/src/types.d.ts
|
|
10
11
|
type contentType = 'application/json' | (string & {});
|
|
@@ -220,8 +221,6 @@ type Logger = {
|
|
|
220
221
|
//#endregion
|
|
221
222
|
//#region ../core/src/utils/types.d.ts
|
|
222
223
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
223
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
224
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
225
224
|
//#endregion
|
|
226
225
|
//#region ../core/src/types.d.ts
|
|
227
226
|
type InputPath = {
|
|
@@ -464,6 +463,9 @@ type ResolveNameParams = {
|
|
|
464
463
|
};
|
|
465
464
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
466
465
|
config: Config;
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated
|
|
468
|
+
*/
|
|
467
469
|
fileManager: FileManager;
|
|
468
470
|
pluginManager: PluginManager;
|
|
469
471
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -515,60 +517,6 @@ type Group = {
|
|
|
515
517
|
name?: (context: GroupContext) => string;
|
|
516
518
|
};
|
|
517
519
|
//#endregion
|
|
518
|
-
//#region ../core/src/FileManager.d.ts
|
|
519
|
-
type FileMetaBase = {
|
|
520
|
-
pluginKey?: Plugin['key'];
|
|
521
|
-
};
|
|
522
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
523
|
-
type AddIndexesProps = {
|
|
524
|
-
type: BarrelType | false | undefined;
|
|
525
|
-
/**
|
|
526
|
-
* Root based on root and output.path specified in the config
|
|
527
|
-
*/
|
|
528
|
-
root: string;
|
|
529
|
-
/**
|
|
530
|
-
* Output for plugin
|
|
531
|
-
*/
|
|
532
|
-
output: {
|
|
533
|
-
path: string;
|
|
534
|
-
};
|
|
535
|
-
group?: {
|
|
536
|
-
output: string;
|
|
537
|
-
exportAs: string;
|
|
538
|
-
};
|
|
539
|
-
logger?: Logger;
|
|
540
|
-
meta?: FileMetaBase;
|
|
541
|
-
};
|
|
542
|
-
type WriteFilesProps = {
|
|
543
|
-
root: Config['root'];
|
|
544
|
-
extension?: Record<Extname, Extname | ''>;
|
|
545
|
-
logger?: Logger;
|
|
546
|
-
dryRun?: boolean;
|
|
547
|
-
};
|
|
548
|
-
declare class FileManager {
|
|
549
|
-
#private;
|
|
550
|
-
constructor();
|
|
551
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
552
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
553
|
-
deleteByPath(path: Path): Promise<void>;
|
|
554
|
-
clear(): Promise<void>;
|
|
555
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
556
|
-
processFiles({
|
|
557
|
-
dryRun,
|
|
558
|
-
root,
|
|
559
|
-
extension,
|
|
560
|
-
logger
|
|
561
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
562
|
-
getBarrelFiles({
|
|
563
|
-
type,
|
|
564
|
-
meta,
|
|
565
|
-
root,
|
|
566
|
-
output,
|
|
567
|
-
logger
|
|
568
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
569
|
-
static getMode(path: string | undefined | null): Mode;
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
520
|
//#region ../core/src/PluginManager.d.ts
|
|
573
521
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
574
522
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -607,6 +555,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
607
555
|
declare class PluginManager {
|
|
608
556
|
#private;
|
|
609
557
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
558
|
+
/**
|
|
559
|
+
* @deprecated do not use from pluginManager
|
|
560
|
+
*/
|
|
610
561
|
readonly fileManager: FileManager;
|
|
611
562
|
readonly events: EventEmitter<Events>;
|
|
612
563
|
readonly config: Config;
|
|
@@ -715,6 +666,11 @@ declare class PluginManager {
|
|
|
715
666
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
716
667
|
}
|
|
717
668
|
//#endregion
|
|
669
|
+
//#region ../core/src/FileManager.d.ts
|
|
670
|
+
type FileMetaBase = {
|
|
671
|
+
pluginKey?: Plugin['key'];
|
|
672
|
+
};
|
|
673
|
+
//#endregion
|
|
718
674
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
719
675
|
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
720
676
|
oas: Oas;
|
|
@@ -1255,4 +1211,4 @@ type ResolvedOptions = {
|
|
|
1255
1211
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1256
1212
|
//#endregion
|
|
1257
1213
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, Generator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1258
|
-
//# sourceMappingURL=types-
|
|
1214
|
+
//# sourceMappingURL=types-QZU4k-_1.d.ts.map
|
|
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
8
9
|
|
|
9
10
|
//#region ../oas/src/types.d.ts
|
|
10
11
|
type contentType = 'application/json' | (string & {});
|
|
@@ -220,8 +221,6 @@ type Logger = {
|
|
|
220
221
|
//#endregion
|
|
221
222
|
//#region ../core/src/utils/types.d.ts
|
|
222
223
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
223
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
224
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
225
224
|
//#endregion
|
|
226
225
|
//#region ../core/src/types.d.ts
|
|
227
226
|
type InputPath = {
|
|
@@ -464,6 +463,9 @@ type ResolveNameParams = {
|
|
|
464
463
|
};
|
|
465
464
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
466
465
|
config: Config;
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated
|
|
468
|
+
*/
|
|
467
469
|
fileManager: FileManager;
|
|
468
470
|
pluginManager: PluginManager;
|
|
469
471
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -515,60 +517,6 @@ type Group = {
|
|
|
515
517
|
name?: (context: GroupContext) => string;
|
|
516
518
|
};
|
|
517
519
|
//#endregion
|
|
518
|
-
//#region ../core/src/FileManager.d.ts
|
|
519
|
-
type FileMetaBase = {
|
|
520
|
-
pluginKey?: Plugin['key'];
|
|
521
|
-
};
|
|
522
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
523
|
-
type AddIndexesProps = {
|
|
524
|
-
type: BarrelType | false | undefined;
|
|
525
|
-
/**
|
|
526
|
-
* Root based on root and output.path specified in the config
|
|
527
|
-
*/
|
|
528
|
-
root: string;
|
|
529
|
-
/**
|
|
530
|
-
* Output for plugin
|
|
531
|
-
*/
|
|
532
|
-
output: {
|
|
533
|
-
path: string;
|
|
534
|
-
};
|
|
535
|
-
group?: {
|
|
536
|
-
output: string;
|
|
537
|
-
exportAs: string;
|
|
538
|
-
};
|
|
539
|
-
logger?: Logger;
|
|
540
|
-
meta?: FileMetaBase;
|
|
541
|
-
};
|
|
542
|
-
type WriteFilesProps = {
|
|
543
|
-
root: Config['root'];
|
|
544
|
-
extension?: Record<Extname, Extname | ''>;
|
|
545
|
-
logger?: Logger;
|
|
546
|
-
dryRun?: boolean;
|
|
547
|
-
};
|
|
548
|
-
declare class FileManager {
|
|
549
|
-
#private;
|
|
550
|
-
constructor();
|
|
551
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
552
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
553
|
-
deleteByPath(path: Path): Promise<void>;
|
|
554
|
-
clear(): Promise<void>;
|
|
555
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
556
|
-
processFiles({
|
|
557
|
-
dryRun,
|
|
558
|
-
root,
|
|
559
|
-
extension,
|
|
560
|
-
logger
|
|
561
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
562
|
-
getBarrelFiles({
|
|
563
|
-
type,
|
|
564
|
-
meta,
|
|
565
|
-
root,
|
|
566
|
-
output,
|
|
567
|
-
logger
|
|
568
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
569
|
-
static getMode(path: string | undefined | null): Mode;
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
520
|
//#region ../core/src/PluginManager.d.ts
|
|
573
521
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
574
522
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -607,6 +555,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
607
555
|
declare class PluginManager {
|
|
608
556
|
#private;
|
|
609
557
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
558
|
+
/**
|
|
559
|
+
* @deprecated do not use from pluginManager
|
|
560
|
+
*/
|
|
610
561
|
readonly fileManager: FileManager;
|
|
611
562
|
readonly events: EventEmitter<Events>;
|
|
612
563
|
readonly config: Config;
|
|
@@ -715,6 +666,11 @@ declare class PluginManager {
|
|
|
715
666
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
716
667
|
}
|
|
717
668
|
//#endregion
|
|
669
|
+
//#region ../core/src/FileManager.d.ts
|
|
670
|
+
type FileMetaBase = {
|
|
671
|
+
pluginKey?: Plugin['key'];
|
|
672
|
+
};
|
|
673
|
+
//#endregion
|
|
718
674
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
719
675
|
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
720
676
|
oas: Oas;
|
|
@@ -1255,4 +1211,4 @@ type ResolvedOptions = {
|
|
|
1255
1211
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1256
1212
|
//#endregion
|
|
1257
1213
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, Generator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1258
|
-
//# sourceMappingURL=types-
|
|
1214
|
+
//# sourceMappingURL=types-vzmWp6Js.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -69,18 +69,18 @@
|
|
|
69
69
|
"!/**/__tests__/**"
|
|
70
70
|
],
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@kubb/core": "4.2.
|
|
73
|
-
"@kubb/oas": "4.2.
|
|
74
|
-
"@kubb/plugin-oas": "4.2.
|
|
75
|
-
"@kubb/plugin-ts": "4.2.
|
|
76
|
-
"@kubb/react": "4.2.
|
|
72
|
+
"@kubb/core": "4.2.2",
|
|
73
|
+
"@kubb/oas": "4.2.2",
|
|
74
|
+
"@kubb/plugin-oas": "4.2.2",
|
|
75
|
+
"@kubb/plugin-ts": "4.2.2",
|
|
76
|
+
"@kubb/react": "4.2.2"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@asteasolutions/zod-to-openapi": "^8.1.0",
|
|
80
80
|
"@hono/zod-openapi": "0.19.2",
|
|
81
81
|
"tsdown": "^0.15.9",
|
|
82
82
|
"zod": "^3.25.76",
|
|
83
|
-
"@kubb/plugin-oas": "4.2.
|
|
83
|
+
"@kubb/plugin-oas": "4.2.2"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@kubb/react": "^4.0.0"
|
package/src/plugin.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import { createPlugin,
|
|
2
|
+
import { createPlugin, type Group, getBarrelFiles, getMode, PackageManager, type Plugin, PluginManager } from '@kubb/core'
|
|
3
3
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
4
4
|
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
5
|
import { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
@@ -57,7 +57,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
57
57
|
pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),
|
|
58
58
|
resolvePath(baseName, pathMode, options) {
|
|
59
59
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
60
|
-
const mode = pathMode ??
|
|
60
|
+
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
61
61
|
|
|
62
62
|
if (mode === 'single') {
|
|
63
63
|
/**
|
|
@@ -110,7 +110,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
110
110
|
|
|
111
111
|
const oas = await swaggerPlugin.context.getOas()
|
|
112
112
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
113
|
-
const mode =
|
|
113
|
+
const mode = getMode(path.resolve(root, output.path))
|
|
114
114
|
|
|
115
115
|
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|
|
116
116
|
oas,
|
|
@@ -140,7 +140,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
140
140
|
const operationFiles = await operationGenerator.build(...generators)
|
|
141
141
|
await this.addFile(...operationFiles)
|
|
142
142
|
|
|
143
|
-
const barrelFiles = await this.fileManager.
|
|
143
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
144
144
|
type: output.barrelType ?? 'named',
|
|
145
145
|
root,
|
|
146
146
|
output,
|