@kubb/plugin-zod 3.18.0 → 3.18.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.
@@ -1 +1 @@
1
- {"version":3,"file":"components-CJ6RN1R2.js","names":["order: string[]","name","value"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;AAWA,SAAgB,WAAW,EAA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AC3E,UAAS;CAIb,MAAM,mBACJ;EACE,QAAQ;EACR,SAAS,EACP,SAAS,eAAe,kBACzB;EACD,UAAU,EAAE;EACb,EACD;EAAE;EAAM;EAAY;EAAU;EAAa;EAAQ;EAAU;EAAY;EAAW;EAAS;CAG/F,MAAM,mBACJ,CAAC,QAAQ,YAAY,SAAS,GAAG,OAAO,UAAU,WAAW,KAAK,QAAQ,GAAG,IAAI,SAAS,KAAK,KAAK,OAAO,OAAU,CAAC,OAAO,SAAS,KAAK,OAC3I,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;EAAW,KAAK,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,uBAAuB,SAAS,KAAK;AAE3F,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgB,aAAa,eAAe,iBAAiB,OAAU,CAAC,OAAO,UACzG;aAEA;;KAGJ,iBACC,qBAAC,KAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,oBAAC;GAAK;GAAO,MAAM;aAChB;MAGJ,CAAC,YACA,oBAAC;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK;;;AAOrC"}
1
+ {"version":3,"file":"components-CJ6RN1R2.js","names":["order: string[]","name","value"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;AAWA,SAAgB,WAAW,EAAE,MAAM,cAAqB;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,iBAAiB,MAAM,IAAI;AAElD,SAAO;IAET;CAGF,MAAM,YAAY,WAAW,QAC1B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,KAAK,MAAM;GAChC,GAAI,KAAK,IAAI,IAAI,UAAU,KAAK,OAAQ;IACvC,IAAI,UAAU,SAAS,eAAe,IAAI,UAAU,iBAAiB;;AAGxE,SAAO;IAET;AAGF,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAM;GAAa;GAAM;aACvB,IAAI,aAAa,gBAAgB,gBAAgB;;KAGtD,oBAAC,KAAK;EAAO,MAAM;EAAS;EAAa;YACvC,oBAAC;GAAM;GAAO,MAAM;GAAS;aAC1B,IAAI,aAAa,gB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IACtC;EAAE;EAAM;EAAY;EAAU;EAAa;EAAQ;EAAU;EAAY;EAAW;KAGvF,OAAO,SACP,KAAK;CAER,IAAI,SAAS;CACb,MAAM,cAAc,QAAQ,GAAG;CAC/B,MAAM,aAAa,QAAQ,GAAG;AAE9B,KAAI,cAAc,UAAU,YAAY,eAAe,UACrD,KAAI,eAAe,UAAU,aAAa,eAAe,KACvD,KAAI,YAAY,IACd,UAAS;KAET,UAAS;KAGX,UAAS;UAGP,eAAe,UAAU,aAAa,eAAe,QAAQ,YAAY,IAC3E,UAAS;CAIb,MAAM,mBACJ;EACE,QAAQ;EACR,SAAS,EACP,SAAS,eAAe;EAE1B,UAAU;IAEZ;EAAE;EAAM;EAAY;EAAU;EAAa;EAAQ;EAAU;EAAY;EAAW;;CAGtF,MAAM,mBACJ,CAAC,QAAQ,YAAY,SAAS,GAAG,OAAO,UAAU,WAAW,KAAK,QAAQ,GAAG,IAAI,SAAS,KAAK,KAAK,OAAO,QAAW,OAAO,SAAS,KAAK,OAC3I,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;OAAgB,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,uBAAuB,SAAS,KAAK;AAE3F,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgB,aAAa,eAAe,iBAAiB,QAAW,OAAO;aAGzG;;KAGJ,iBACC,qBAAC,KAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,oBAAC;GAAK;GAAO,MAAM;aAChB;MAGJ,CAAC,YACA,oBAAC;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"components-GvkeO2ig.cjs","names":["File","Const","transformers","order: string[]","schemaKeywords","transformers","name","SchemaGenerator","value","SchemaGenerator","schemaKeywords","File","Const","transformers","Type"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAgB,WAAW,EAAE,MAAM,YAAmB,EAAE;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,iBAAiB,MAAM,IAAI;AAElD,SAAO;CACR,GACD,EAAE;CAGJ,M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EAAS;CAG/F,MAAM,mBACJ,CAAC,QAAQ,YAAY,SAAS,GAAG,OAAO,UAAU,WAAW,KAAK,QAAQ,GAAG,IAAI,SAAS,KAAK,KAAK,OAAO,OAAU,CAAC,OAAO,SAAS,KAAK,OAC3I,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;EAAW,KAAK,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,uBAAuB,SAAS,KAAK;AAE3F,QACE,mGACE,kDAACC,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgBC,iCAAa,eAAe,iBAAiB,OAAU,CAAC,OAAO,UACzG;aAEA;;KAGJ,iBACC,mDAACF,kBAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,kDAACG;GAAK;GAAO,MAAM;aAChB;MAGJ,CAAC,YACA,kDAACA;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK;;;AAOrC"}
1
+ {"version":3,"file":"components-GvkeO2ig.cjs","names":["File","Const","transformers","order: string[]","schemaKeywords","transformers","name","SchemaGenerator","value","SchemaGenerator","schemaKeywords","File","Const","transformers","Type"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAgB,WAAW,EAAE,MAAM,cAAqB;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,iBAAiB,MAAM,IAAI;AAElD,SAAO;IAET;CAGF,MAAM,YAAY,WAAW,QAC1B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,KAAK,MAAM;GAChC,GAAI,KAAK,IAAI,IAAI,UAAU,KAAK,OAAQ;IACvC,IAAI,UAAU,SAAS,eAAe,IAAI,UAAU,iBAAiB;;AAGxE,SAAO;IAET;AAGF,QACE,mGACE,kDAACA,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GAAM;GAAa;GAAM;aACvB,IAAIC,iCAAa,gBAAgB,gBAAgB;;KAGtD,kDAACF,kBAAK;EAAO,MAAM;EAAS;EAAa;YACvC,kDAACC;GAAM;GAAO,MAAM;GAAS;aAC1B,IAAIC,iCAAa,gBAAgB,WAAW;;;;;;;ACpCvD,MAAM,mBAAmB;CACvB,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W;KAGvF,OAAO,SACP,KAAK;CAER,IAAI,SAAS;CACb,MAAM,cAAc,QAAQ,GAAG;CAC/B,MAAM,aAAa,QAAQ,GAAG;AAE9B,KAAI,+CAAwB,YAAYA,iCAAe,UACrD,KAAI,gDAAyB,aAAaA,iCAAe,KACvD,KAAI,YAAY,IACd,UAAS;KAET,UAAS;KAGX,UAAS;UAGP,gDAAyB,aAAaA,iCAAe,QAAQ,YAAY,IAC3E,UAAS;CAIb,MAAM,mBACJ;EACE,QAAQ;EACR,SAAS,EACP,SAASA,iCAAe;EAE1B,UAAU;IAEZ;EAAE;EAAM;EAAY;EAAU;EAAa;EAAQ;EAAU;EAAY;EAAW;;CAGtF,MAAM,mBACJ,CAAC,QAAQ,YAAY,SAAS,GAAG,OAAO,UAAU,WAAW,KAAK,QAAQ,GAAG,IAAI,SAAS,KAAK,KAAK,OAAO,QAAW,OAAO,SAAS,KAAK,OAC3I,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;OAAgB,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,uBAAuB,SAAS,KAAK;AAE3F,QACE,mGACE,kDAACC,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgBC,iCAAa,eAAe,iBAAiB,QAAW,OAAO;aAGzG;;KAGJ,iBACC,mDAACF,kBAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,kDAACG;GAAK;GAAO,MAAM;aAChB;MAGJ,CAAC,YACA,kDAACA;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"generators-C3ALr3ph.js","names":["options"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion: globalCoercion, inferred, typed, mapper, wrapOutput } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={plugin.options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },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eAAe,WAAW,IAAI,gBAAgB;KAC9C,aAAa,OAAO,MAAM;KAC1B,MAAM,OAAO;KACb,WAAW,OAAO;KACV;KACE;KACE;KACH;KACQ;;;;CAIxB;CACF;;;;ACrJD,MAAa,sBAAsB,qBAAgC;CACjE,MAAM;CACN,WAAW,EAAE,YAAY,EAAE;EACzB,MAAM,EACJ,eACA,QAAQ,EACN,KAAK,WACL,SAAS,EAAE,QAAQ,EACpB,EACF,GAAG;EACJ,MAAM,MAAM;EACZ,MAAM,EAAE,SAAS,oBAAoB,GAAG;EAExC,MAAM,OAAO;EACb,MAAM,OAAO,cAAc,QAAQ;GAAE;GAAM,SAAS;GAAO;GAAW;EAEtE,MAAM,wBAAwB,WAAW,KAAK,eAAe;GAAE;GAAW,MAAM,mBAAmB,WAAW,EAAE,MAAM,YAAY;GAAG;EAErI,MAAM,UAAU,OAAO,QAAQ,uBAC5B,KAAK,CAAC,KAAK,EAAE,MAAM,WAAW,CAAC,KAAK;GACnC,MAAM,QAAQ;IAAC,KAAK;IAAS,GAAG,OAAO,OAAO,KAAK;IAAY,GAAG,OAAO,OAAO,KAAK;IAAY,CAAC,OAAO;AAEzG,UAAO,oBAAC,KAAK;IAAiB,MAAM;IAAO,MAAM,KAAK;IAAM,MAAM,QAAQ,WAAW;MAA5D;EAC1B,GACA,OAAO;AAEV,SACE,qBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ;GAC/D,QAAQ,UAAU;IAAE;IAAK;IAAQ;cAEhC,SACD,oBAAC;IAAiB;IAAM,YAAY;;;CAGzC;CACF"}
1
+ {"version":3,"file":"generators-C3ALr3ph.js","names":["options"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion: globalCoercion, inferred, typed, mapper, wrapOutput } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={plugin.options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n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Z,MAAM,EAAE,SAAS,uBAAuB;EAExC,MAAM,OAAO;EACb,MAAM,OAAO,cAAc,QAAQ;GAAE;GAAM,SAAS;GAAO;;EAE3D,MAAM,wBAAwB,WAAW,KAAK,eAAe;GAAE;GAAW,MAAM,mBAAmB,WAAW,EAAE,MAAM;;EAEtH,MAAM,UAAU,OAAO,QAAQ,uBAC5B,KAAK,CAAC,KAAK,EAAE,MAAM,iBAAiB;GACnC,MAAM,QAAQ;IAAC,KAAK;IAAS,GAAG,OAAO,OAAO,KAAK;IAAY,GAAG,OAAO,OAAO,KAAK;KAAa,OAAO;AAEzG,UAAO,oBAAC,KAAK;IAAiB,MAAM;IAAO,MAAM,KAAK;IAAM,MAAM,QAAQ,WAAW;MAA5D;KAE1B,OAAO;AAEV,SACE,qBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;;GACvD,QAAQ,UAAU;IAAE;IAAK;;cAExB,SACD,oBAAC;IAAiB;IAAM,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"generators-D3uH7-vO.cjs","names":["SchemaGenerator","options","schemaKeywords","pluginTsName","Oas","File","Zod","File","Operations"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion: globalCoercion, inferred, typed, mapper, wrapOutput } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={plugin.options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,SAAS,EAAE;EAChC,MAAM,EAAE,UAAU,gBAAgB,UAAU,OAAO,QAAQ,YAAY,GAAG;EAE1E,MAAM,EAAE,QAAQ,eAAe,MAAM;EACrC,MAAM;EACN,MAAM,EAAE,YAAY,SAAS,UAAU;EACvC,MAAM;EAEN,MAAM,OAAO,QAAQ;EACrB,MAAM,UAAU,WAAW;EAC3B,MAAM,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AS;GAAO;GAAW;EAEtE,MAAM,wBAAwB,WAAW,KAAK,eAAe;GAAE;GAAW,MAAM,mBAAmB,WAAW,EAAE,MAAM,YAAY;GAAG;EAErI,MAAM,UAAU,OAAO,QAAQ,uBAC5B,KAAK,CAAC,KAAK,EAAE,MAAM,WAAW,CAAC,KAAK;GACnC,MAAM,QAAQ;IAAC,KAAK;IAAS,GAAG,OAAO,OAAO,KAAK;IAAY,GAAG,OAAO,OAAO,KAAK;IAAY,CAAC,OAAO;AAEzG,UAAO,kDAACC,kBAAK;IAAiB,MAAM;IAAO,MAAM,KAAK;IAAM,MAAM,QAAQ,WAAW;MAA5D;EAC1B,GACA,OAAO;AAEV,SACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ;GAC/D,+CAAkB;IAAE;IAAK;IAAQ;cAEhC,SACD,kDAACC;IAAiB;IAAM,YAAY;;;CAGzC;CACF"}
1
+ {"version":3,"file":"generators-D3uH7-vO.cjs","names":["SchemaGenerator","options","schemaKeywords","pluginTsName","Oas","File","Zod","File","Operations"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion: globalCoercion, inferred, typed, mapper, wrapOutput } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={plugin.options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW;EAChC,MAAM,EAAE,UAAU,gBAAgB,UAAU,OAAO,QAAQ,eAAe;EAE1E,MAAM,EAAE,QAAQ,eAAe;EAC/B,MAAM;EACN,MAAM,EAAE,YAAY,SAAS;EAC7B,MAAM;EAEN,MAAM,OAAO,QAAQ;EACrB,MAAM,UAAU,WAAW;EAC3B,MAAM,kBAAkB,IAAIA,kCAAgB,SAAS;GACnD;GACA;GACA;GACA;GACA,UAAU,QAAQ;;EA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WAAW;MAA5D;KAE1B,OAAO;AAEV,SACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;;GACvD,+CAAkB;IAAE;IAAK;;cAExB,SACD,kDAACC;IAAiB;IAAM,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","FileManager","options","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,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,6BAAiB,YAAY,OAAO,SAAS,MAAM,KACjE,aAAa,YAAY,MAAM,WAAW,OAC1C,WAAW,OACX,WAAW,OACX,aAAa,CAACC,iCAAc,aAAaC,yCAAsB,OAAU,CAAC,OAAO,UACjF,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;GACD;EACD,KAAK,CAACC,iCAAe,QAAQC,gCAAe,OAAU,CAAC,OAAO;EAC9D,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAO,YAAYC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO;AAEvE,OAAI,SAAS;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO;AAGnC,OAAI,UAAUE,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,KAAK;AAEjC,YAAO,2CAAa,IAAI,OAAO;IAChC;AAEL,WAAOH,kBAAK,QACV,MACA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3,"file":"index.cjs","names":["PackageManager","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","path","FileManager","options","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,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;E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O,cAAc,OAAO,cAAc,SAAS;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiDI,0BAAc,mBAAyC,KAAK,SAAS,CAACN;GAE9H,MAAM,MAAM,MAAM,cAAc,QAAQ;GACxC,MAAM,OAAOE,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAOC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO;GAE3D,MAAM,kBAAkB,IAAIK,kCAAgB,KAAK,OAAO,SAAS;IAC/D;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;;GAGjB,MAAM,cAAc,MAAM,gBAAgB,MAAM,GAAG;AACnD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,qBAAqB,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;;GAGF,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG;AACzD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO;IAEzB,QAAQ,KAAK;;AAGf,SAAM,KAAK,QAAQ,GAAG"}
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, 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,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,+BAAe,EAAE,EACjB,WAAW,UACX,cAAc,OACd,kBAAkB,aAClB,QAAQ,OACR,SAAS,EAAE,EACX,aAAa,OACb,UAAU,IAAI,iBAAiB,YAAY,OAAO,SAAS,MAAM,KACjE,aAAa,YAAY,MAAM,WAAW,OAC1C,WAAW,OACX,WAAW,OACX,aAAa,CAAC,cAAc,aAAa,sBAAsB,OAAU,CAAC,OAAO,UACjF,aAAa,QACb,aACD,GAAG;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;G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,IAAI,gBAAgB,KAAK,OAAO,SAAS;IAC/D;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB;GAED,MAAM,cAAc,MAAM,gBAAgB,MAAM,GAAG;AACnD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,qBAAqB,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD;GAED,MAAM,iBAAiB,MAAM,mBAAmB,MAAM,GAAG;AACzD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd;AAED,SAAM,KAAK,QAAQ,GAAG;EACvB;EACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"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,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;IACpC,OACA,UAAU,IACV,SACA,WAAW,IACX,+BAAe,IACf,WAAW,UACX,cAAc,OACd,kBAAkB,aAClB,QAAQ,OACR,SAAS,IACT,aAAa,OACb,UAAU,IAAI,iBAAiB,YAAY,OAAO,SAAS,MAAM,KACjE,aAAa,YAAY,MAAM,WAAW,OAC1C,WAAW,OACX,WAAW,OACX,aAAa,CAAC,cAAc,aAAa,sBAAsB,QAAW,OAAO,UACjF,aAAa,QACb,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;;EAEF,KAAK,CAAC,eAAe,QAAQ,eAAe,QAAW,OAAO;EAC9D,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAO,YAAY,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO;AAEvE,OAAI,SAAS;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO;AAGnC,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EtB,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO;IAEzB,QAAQ,KAAK;;AAGf,SAAM,KAAK,QAAQ,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "3.18.0",
3
+ "version": "3.18.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",
@@ -73,20 +73,20 @@
73
73
  "!/**/__tests__/**"
74
74
  ],
75
75
  "dependencies": {
76
- "@kubb/core": "3.18.0",
77
- "@kubb/oas": "3.18.0",
78
- "@kubb/parser-ts": "3.18.0",
79
- "@kubb/plugin-oas": "3.18.0",
80
- "@kubb/plugin-ts": "3.18.0",
81
- "@kubb/react": "3.18.0"
76
+ "@kubb/core": "3.18.2",
77
+ "@kubb/oas": "3.18.2",
78
+ "@kubb/parser-ts": "3.18.2",
79
+ "@kubb/plugin-oas": "3.18.2",
80
+ "@kubb/react": "3.18.2",
81
+ "@kubb/plugin-ts": "3.18.2"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@asteasolutions/zod-to-openapi": "^7.3.4",
85
85
  "@hono/zod-openapi": "0.19.2",
86
- "tsdown": "^0.14.1",
86
+ "tsdown": "^0.14.2",
87
87
  "zod": "^3.25.76",
88
- "@kubb/config-ts": "3.18.0",
89
- "@kubb/plugin-oas": "3.18.0"
88
+ "@kubb/config-ts": "3.18.2",
89
+ "@kubb/plugin-oas": "3.18.2"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@kubb/react": "^3.0.0"