@kubb/plugin-zod 4.29.0 → 4.29.1
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.ts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/templates/ToZod.source.d.ts +1 -1
- package/dist/{types-36d5YOmB.d.ts → types-B-1DRHH9.d.ts} +10 -1
- package/dist/{types-Di6cBRev.d.ts → types-Cfvq128m.d.ts} +10 -1
- package/package.json +5 -5
- package/src/generators/__snapshots__/coercion.ts +1 -1
- package/src/generators/__snapshots__/coercionDates.ts +1 -1
- package/src/generators/__snapshots__/coercionNumbers.ts +1 -1
- package/src/generators/__snapshots__/coercionStrings.ts +1 -1
- package/src/generators/__snapshots__/deletePet.ts +1 -1
- package/src/generators/__snapshots__/deletePet_wrapOutput.ts +1 -1
- package/src/generators/__snapshots__/optionalPetInfer.ts +1 -1
- package/src/generators/__snapshots__/optionalPetTyped.ts +1 -1
- package/src/generators/__snapshots__/order.ts +2 -2
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +2 -2
- package/src/generators/__snapshots__/orderDateTypeString.ts +2 -2
- package/src/generators/__snapshots__/pet.ts +1 -1
- package/src/generators/__snapshots__/petCoercion.ts +1 -1
- package/src/generators/__snapshots__/petV4.ts +1 -1
- package/src/generators/__snapshots__/petV4Guid.ts +1 -1
- package/src/generators/__snapshots__/petWithMapper.ts +1 -1
- package/src/generators/__snapshots__/pets.ts +1 -1
- package/src/plugin.ts +2 -0
- package/src/types.ts +9 -0
package/dist/components.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginZod } from "./types-
|
|
3
|
-
import { Schema } from "@kubb/plugin-oas";
|
|
4
|
-
import { SchemaNames } from "@kubb/plugin-oas/hooks";
|
|
1
|
+
import { t as __name } from "./chunk-cy2TeOE5.cjs";
|
|
2
|
+
import { n as PluginZod } from "./types-Cfvq128m.js";
|
|
5
3
|
import { Operation, SchemaObject } from "@kubb/oas";
|
|
4
|
+
import { SchemaNames } from "@kubb/plugin-oas/hooks";
|
|
6
5
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
6
|
+
import { Schema } from "@kubb/plugin-oas";
|
|
7
7
|
|
|
8
8
|
//#region src/components/Operations.d.ts
|
|
9
9
|
type Props$1 = {
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginZod } from "./types-
|
|
3
|
-
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
4
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
1
|
+
import { t as __name } from "./chunk-cy2TeOE5.cjs";
|
|
2
|
+
import { n as PluginZod } from "./types-Cfvq128m.js";
|
|
5
3
|
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
6
4
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
5
|
+
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
7
6
|
import { AsyncEventEmitter } from "@kubb/core/utils";
|
|
8
7
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
9
9
|
|
|
10
10
|
//#region ../plugin-oas/src/types.d.ts
|
|
11
11
|
type GetOasOptions = {
|
package/dist/index.cjs
CHANGED
|
@@ -15,7 +15,7 @@ const pluginZod = (0, _kubb_core.definePlugin)((options) => {
|
|
|
15
15
|
const { output = {
|
|
16
16
|
path: "zod",
|
|
17
17
|
barrelType: "named"
|
|
18
|
-
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" : new _kubb_core.PackageManager().isValidSync("zod", ">=4") ? "4" : "3", guidType = "uuid", importPath = mini ? "zod/mini" : version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [require_zodGenerator.zodGenerator, operations ? require_zodGenerator.operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
18
|
+
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, integerType = "number", typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" : new _kubb_core.PackageManager().isValidSync("zod", ">=4") ? "4" : "3", guidType = "uuid", importPath = mini ? "zod/mini" : version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [require_zodGenerator.zodGenerator, operations ? require_zodGenerator.operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
19
19
|
return {
|
|
20
20
|
name: pluginZodName,
|
|
21
21
|
options: {
|
|
@@ -28,6 +28,7 @@ const pluginZod = (0, _kubb_core.definePlugin)((options) => {
|
|
|
28
28
|
dateType,
|
|
29
29
|
unknownType,
|
|
30
30
|
emptySchemaType,
|
|
31
|
+
integerType,
|
|
31
32
|
mapper,
|
|
32
33
|
importPath,
|
|
33
34
|
coercion,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","toZodSource","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode, PackageManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { source as toZodSource } from './templates/ToZod.source.ts'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = definePlugin<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 mini = false,\n version = mini ? '4' : new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n guidType = 'uuid',\n importPath = mini ? 'zod/mini' : 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 // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\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 guidType,\n mini,\n usedEnumNames,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: toZodSource,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,0CAAqC,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,OAAO,OACP,UAAU,OAAO,MAAM,IAAIA,2BAAgB,CAAC,YAAY,OAAO,MAAM,GAAG,MAAM,KAC9E,WAAW,QACX,aAAa,OAAO,aAAa,YAAY,MAAM,WAAW,OAC9D,WAAW,OACX,WAAW,OACX,aAAa,CAACC,mCAAc,aAAaC,2CAAsB,OAAU,CAAC,OAAO,QAAQ,EACzF,aAAa,QACb,gBACE;AAKJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","toZodSource","SchemaGenerator","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode, PackageManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { source as toZodSource } from './templates/ToZod.source.ts'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = definePlugin<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 integerType = 'number',\n typed = false,\n mapper = {},\n operations = false,\n mini = false,\n version = mini ? '4' : new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n guidType = 'uuid',\n importPath = mini ? 'zod/mini' : 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 // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\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 integerType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n guidType,\n mini,\n usedEnumNames,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: toZodSource,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginZod, t as Options } from "./types-
|
|
1
|
+
import { t as __name } from "./chunk-cy2TeOE5.cjs";
|
|
2
|
+
import { n as PluginZod, t as Options } from "./types-Cfvq128m.js";
|
|
3
3
|
import * as _kubb_core0 from "@kubb/core";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const pluginZod = definePlugin((options) => {
|
|
|
13
13
|
const { output = {
|
|
14
14
|
path: "zod",
|
|
15
15
|
barrelType: "named"
|
|
16
|
-
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" : new PackageManager().isValidSync("zod", ">=4") ? "4" : "3", guidType = "uuid", importPath = mini ? "zod/mini" : version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
16
|
+
}, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, integerType = "number", typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" : new PackageManager().isValidSync("zod", ">=4") ? "4" : "3", guidType = "uuid", importPath = mini ? "zod/mini" : version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
|
|
17
17
|
return {
|
|
18
18
|
name: pluginZodName,
|
|
19
19
|
options: {
|
|
@@ -26,6 +26,7 @@ const pluginZod = definePlugin((options) => {
|
|
|
26
26
|
dateType,
|
|
27
27
|
unknownType,
|
|
28
28
|
emptySchemaType,
|
|
29
|
+
integerType,
|
|
29
30
|
mapper,
|
|
30
31
|
importPath,
|
|
31
32
|
coercion,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["toZodSource"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode, PackageManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { source as toZodSource } from './templates/ToZod.source.ts'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = definePlugin<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 mini = false,\n version = mini ? '4' : new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n guidType = 'uuid',\n importPath = mini ? 'zod/mini' : 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 // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\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 guidType,\n mini,\n usedEnumNames,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: toZodSource,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,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,OAAO,OACP,UAAU,OAAO,MAAM,IAAI,gBAAgB,CAAC,YAAY,OAAO,MAAM,GAAG,MAAM,KAC9E,WAAW,QACX,aAAa,OAAO,aAAa,YAAY,MAAM,WAAW,OAC9D,WAAW,OACX,WAAW,OACX,aAAa,CAAC,cAAc,aAAa,sBAAsB,OAAU,CAAC,OAAO,QAAQ,EACzF,aAAa,QACb,gBACE;AAKJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["toZodSource"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode, PackageManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { source as toZodSource } from './templates/ToZod.source.ts'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = definePlugin<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 integerType = 'number',\n typed = false,\n mapper = {},\n operations = false,\n mini = false,\n version = mini ? '4' : new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n guidType = 'uuid',\n importPath = mini ? 'zod/mini' : 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 // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\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 integerType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n guidType,\n mini,\n usedEnumNames,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: toZodSource,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\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.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"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"}
|
|
@@ -50,6 +50,14 @@ type Options = {
|
|
|
50
50
|
* @note 'stringOffset' will become the default in Kubb v3.
|
|
51
51
|
*/
|
|
52
52
|
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
53
|
+
/**
|
|
54
|
+
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
55
|
+
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
56
|
+
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
57
|
+
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
58
|
+
* @default 'number'
|
|
59
|
+
*/
|
|
60
|
+
integerType?: 'number' | 'bigint';
|
|
53
61
|
/**
|
|
54
62
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
55
63
|
* - 'any' allows any value.
|
|
@@ -144,6 +152,7 @@ type ResolvedOptions = {
|
|
|
144
152
|
override: NonNullable<Options['override']>;
|
|
145
153
|
transformers: NonNullable<Options['transformers']>;
|
|
146
154
|
dateType: NonNullable<Options['dateType']>;
|
|
155
|
+
integerType: NonNullable<Options['integerType']>;
|
|
147
156
|
unknownType: NonNullable<Options['unknownType']>;
|
|
148
157
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
149
158
|
typed: NonNullable<Options['typed']>;
|
|
@@ -160,4 +169,4 @@ type ResolvedOptions = {
|
|
|
160
169
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
161
170
|
//#endregion
|
|
162
171
|
export { PluginZod as n, Options as t };
|
|
163
|
-
//# sourceMappingURL=types-
|
|
172
|
+
//# sourceMappingURL=types-B-1DRHH9.d.ts.map
|
|
@@ -50,6 +50,14 @@ type Options = {
|
|
|
50
50
|
* @note 'stringOffset' will become the default in Kubb v3.
|
|
51
51
|
*/
|
|
52
52
|
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
53
|
+
/**
|
|
54
|
+
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
55
|
+
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
56
|
+
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
57
|
+
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
58
|
+
* @default 'number'
|
|
59
|
+
*/
|
|
60
|
+
integerType?: 'number' | 'bigint';
|
|
53
61
|
/**
|
|
54
62
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
55
63
|
* - 'any' allows any value.
|
|
@@ -144,6 +152,7 @@ type ResolvedOptions = {
|
|
|
144
152
|
override: NonNullable<Options['override']>;
|
|
145
153
|
transformers: NonNullable<Options['transformers']>;
|
|
146
154
|
dateType: NonNullable<Options['dateType']>;
|
|
155
|
+
integerType: NonNullable<Options['integerType']>;
|
|
147
156
|
unknownType: NonNullable<Options['unknownType']>;
|
|
148
157
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
149
158
|
typed: NonNullable<Options['typed']>;
|
|
@@ -160,4 +169,4 @@ type ResolvedOptions = {
|
|
|
160
169
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
161
170
|
//#endregion
|
|
162
171
|
export { PluginZod as n, Options as t };
|
|
163
|
-
//# sourceMappingURL=types-
|
|
172
|
+
//# sourceMappingURL=types-Cfvq128m.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.1",
|
|
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",
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@kubb/react-fabric": "0.13.1",
|
|
80
80
|
"remeda": "^2.33.6",
|
|
81
|
-
"@kubb/
|
|
82
|
-
"@kubb/
|
|
83
|
-
"@kubb/
|
|
84
|
-
"@kubb/plugin-ts": "4.29.
|
|
81
|
+
"@kubb/core": "4.29.1",
|
|
82
|
+
"@kubb/oas": "4.29.1",
|
|
83
|
+
"@kubb/plugin-oas": "4.29.1",
|
|
84
|
+
"@kubb/plugin-ts": "4.29.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@asteasolutions/zod-to-openapi": "^8.4.1",
|
|
@@ -6,7 +6,7 @@ import * as z from 'zod'
|
|
|
6
6
|
import { ToZod } from './test/.kubb/ToZod'
|
|
7
7
|
|
|
8
8
|
export const optionalPet = z.object({
|
|
9
|
-
id: z.optional(z.
|
|
9
|
+
id: z.optional(z.number().int()),
|
|
10
10
|
name: z.optional(z.string()),
|
|
11
11
|
tag: z.optional(z.string()),
|
|
12
12
|
}) as unknown as ToZod<OptionalPet>
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as z from 'zod'
|
|
6
6
|
|
|
7
7
|
export const order = z.object({
|
|
8
|
-
id: z.optional(z.
|
|
9
|
-
petId: z.optional(z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
petId: z.optional(z.number().int()),
|
|
10
10
|
quantity: z.optional(z.number().int()),
|
|
11
11
|
shipDate: z.optional(z.date()),
|
|
12
12
|
status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as z from 'zod'
|
|
6
6
|
|
|
7
7
|
export const order = z.object({
|
|
8
|
-
id: z.optional(z.
|
|
9
|
-
petId: z.optional(z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
petId: z.optional(z.number().int()),
|
|
10
10
|
quantity: z.optional(z.number().int()),
|
|
11
11
|
shipDate: z.optional(z.string()),
|
|
12
12
|
status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as z from 'zod'
|
|
6
6
|
|
|
7
7
|
export const order = z.object({
|
|
8
|
-
id: z.optional(z.
|
|
9
|
-
petId: z.optional(z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
petId: z.optional(z.number().int()),
|
|
10
10
|
quantity: z.optional(z.number().int()),
|
|
11
11
|
shipDate: z.optional(z.string().datetime()),
|
|
12
12
|
status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
|
package/src/plugin.ts
CHANGED
|
@@ -21,6 +21,7 @@ export const pluginZod = definePlugin<PluginZod>((options) => {
|
|
|
21
21
|
dateType = 'string',
|
|
22
22
|
unknownType = 'any',
|
|
23
23
|
emptySchemaType = unknownType,
|
|
24
|
+
integerType = 'number',
|
|
24
25
|
typed = false,
|
|
25
26
|
mapper = {},
|
|
26
27
|
operations = false,
|
|
@@ -50,6 +51,7 @@ export const pluginZod = definePlugin<PluginZod>((options) => {
|
|
|
50
51
|
dateType,
|
|
51
52
|
unknownType,
|
|
52
53
|
emptySchemaType,
|
|
54
|
+
integerType,
|
|
53
55
|
mapper,
|
|
54
56
|
importPath,
|
|
55
57
|
coercion,
|
package/src/types.ts
CHANGED
|
@@ -49,6 +49,14 @@ export type Options = {
|
|
|
49
49
|
* @note 'stringOffset' will become the default in Kubb v3.
|
|
50
50
|
*/
|
|
51
51
|
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date'
|
|
52
|
+
/**
|
|
53
|
+
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
54
|
+
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
55
|
+
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
56
|
+
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
57
|
+
* @default 'number'
|
|
58
|
+
*/
|
|
59
|
+
integerType?: 'number' | 'bigint'
|
|
52
60
|
/**
|
|
53
61
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
54
62
|
* - 'any' allows any value.
|
|
@@ -146,6 +154,7 @@ type ResolvedOptions = {
|
|
|
146
154
|
override: NonNullable<Options['override']>
|
|
147
155
|
transformers: NonNullable<Options['transformers']>
|
|
148
156
|
dateType: NonNullable<Options['dateType']>
|
|
157
|
+
integerType: NonNullable<Options['integerType']>
|
|
149
158
|
unknownType: NonNullable<Options['unknownType']>
|
|
150
159
|
emptySchemaType: NonNullable<Options['emptySchemaType']>
|
|
151
160
|
typed: NonNullable<Options['typed']>
|