zenko 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +3 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +3 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/cli.cjs
CHANGED
|
@@ -385,10 +385,12 @@ function generateWithMetadata(spec, options = {}) {
|
|
|
385
385
|
}
|
|
386
386
|
output.push("} as const;");
|
|
387
387
|
output.push("");
|
|
388
|
+
generateOperationTypes(output, operations, typesConfig);
|
|
388
389
|
output.push("// Operation Objects");
|
|
389
390
|
for (const op of operations) {
|
|
390
391
|
const camelCaseOperationId = toCamelCase(op.operationId);
|
|
391
|
-
|
|
392
|
+
const typeAnnotation = typesConfig.emit ? `: ${capitalize(camelCaseOperationId)}Operation` : "";
|
|
393
|
+
output.push(`export const ${camelCaseOperationId}${typeAnnotation} = {`);
|
|
392
394
|
output.push(` method: "${op.method}",`);
|
|
393
395
|
output.push(` path: paths.${camelCaseOperationId},`);
|
|
394
396
|
appendOperationField(output, "request", op.requestType);
|
|
@@ -407,7 +409,6 @@ function generateWithMetadata(spec, options = {}) {
|
|
|
407
409
|
output.push("} as const;");
|
|
408
410
|
output.push("");
|
|
409
411
|
}
|
|
410
|
-
generateOperationTypes(output, operations, typesConfig);
|
|
411
412
|
const result = {
|
|
412
413
|
output: output.join("\n")
|
|
413
414
|
};
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/utils/topological-sort.ts","../src/utils/property-name.ts","../src/utils/http-status.ts","../src/zenko.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as fs from \"fs\"\nimport * as path from \"path\"\nimport { pathToFileURL } from \"url\"\nimport { load } from \"js-yaml\"\nimport {\n generateWithMetadata,\n type OpenAPISpec,\n type TypesConfig,\n} from \"./zenko.js\"\n\ntype CliConfigEntry = {\n input: string\n output: string\n strictDates?: boolean\n strictNumeric?: boolean\n types?: TypesConfig\n}\n\ntype CliConfigFile = {\n schemas: CliConfigEntry[]\n types?: TypesConfig\n}\n\ntype ParsedArgs = {\n showHelp: boolean\n strictDates: boolean\n strictNumeric: boolean\n configPath?: string\n positional: string[]\n}\n\nasync function main() {\n const args = process.argv.slice(2)\n const parsed = parseArgs(args)\n\n if (\n parsed.showHelp ||\n (!parsed.configPath && parsed.positional.length === 0)\n ) {\n printHelp()\n process.exit(parsed.showHelp ? 0 : 1)\n return\n }\n\n try {\n if (parsed.configPath) {\n await runFromConfig(parsed)\n } else {\n if (parsed.positional.length !== 2) {\n printHelp()\n process.exit(1)\n return\n }\n\n const [inputFile, outputFile] = parsed.positional\n if (!inputFile || !outputFile) {\n printHelp()\n process.exit(1)\n return\n }\n await generateSingle({\n inputFile,\n outputFile,\n strictDates: parsed.strictDates,\n strictNumeric: parsed.strictNumeric,\n })\n }\n } catch (error) {\n console.error(\"❌ Error:\", error)\n process.exit(1)\n }\n}\n\nfunction parseArgs(args: string[]): ParsedArgs {\n const parsed: ParsedArgs = {\n showHelp: false,\n strictDates: false,\n strictNumeric: false,\n positional: [],\n }\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!\n\n if (arg === \"-h\" || arg === \"--help\") {\n parsed.showHelp = true\n continue\n }\n\n if (arg === \"--strict-dates\") {\n parsed.strictDates = true\n continue\n }\n\n if (arg === \"--strict-numeric\") {\n parsed.strictNumeric = true\n continue\n }\n\n if (arg === \"--config\" || arg === \"-c\") {\n const next = args[index + 1]\n if (!next) {\n throw new Error(\"--config flag requires a file path\")\n }\n parsed.configPath = next\n index += 1\n continue\n }\n\n parsed.positional.push(arg)\n }\n\n return parsed\n}\n\nfunction printHelp() {\n console.log(\"Usage:\")\n console.log(\" zenko <input-file> <output-file> [options]\")\n console.log(\" zenko --config <config-file> [options]\")\n console.log(\"\")\n console.log(\"Options:\")\n console.log(\" -h, --help Show this help message\")\n console.log(\n \" --strict-dates Use ISO datetime parsing (can be set per config entry)\"\n )\n console.log(\n \" --strict-numeric Preserve numeric min/max bounds (can be set per config entry)\"\n )\n console.log(\n \" -c, --config Path to config file (JSON, YAML, or JS module)\"\n )\n console.log(\"\")\n console.log(\"Config file format:\")\n console.log(\n ' {\"types\"?: { emit?, helpers?, helpersOutput? }, \"schemas\": [{ input, output, strictDates?, strictNumeric?, types? }] }'\n )\n}\n\nasync function runFromConfig(parsed: ParsedArgs) {\n const configPath = parsed.configPath!\n const resolvedConfigPath = path.resolve(configPath)\n const config = await loadConfig(resolvedConfigPath)\n validateConfig(config)\n\n const baseDir = path.dirname(resolvedConfigPath)\n const baseTypesConfig = config.types\n\n for (const entry of config.schemas) {\n const inputFile = resolvePath(entry.input, baseDir)\n const outputFile = resolvePath(entry.output, baseDir)\n const typesConfig = resolveTypesConfig(baseTypesConfig, entry.types)\n await generateSingle({\n inputFile,\n outputFile,\n strictDates: entry.strictDates ?? parsed.strictDates,\n strictNumeric: entry.strictNumeric ?? parsed.strictNumeric,\n typesConfig,\n })\n }\n}\n\nasync function loadConfig(filePath: string): Promise<unknown> {\n const extension = path.extname(filePath).toLowerCase()\n\n if (extension === \".json\") {\n const content = fs.readFileSync(filePath, \"utf8\")\n return JSON.parse(content)\n }\n\n if (extension === \".yaml\" || extension === \".yml\") {\n const content = fs.readFileSync(filePath, \"utf8\")\n return load(content)\n }\n\n const fileUrl = pathToFileURL(filePath).href\n const module = await import(fileUrl)\n return module.default ?? module.config ?? module\n}\n\nfunction validateConfig(config: unknown): asserts config is CliConfigFile {\n if (!config || typeof config !== \"object\") {\n throw new Error(\"Config file must export an object\")\n }\n\n if (!Array.isArray((config as CliConfigFile).schemas)) {\n throw new Error(\"Config file must contain a 'schemas' array\")\n }\n\n for (const entry of (config as CliConfigFile).schemas) {\n if (!entry || typeof entry !== \"object\") {\n throw new Error(\"Each schema entry must be an object\")\n }\n if (typeof entry.input !== \"string\" || typeof entry.output !== \"string\") {\n throw new Error(\"Each schema entry requires 'input' and 'output' paths\")\n }\n }\n}\n\nfunction resolvePath(filePath: string, baseDir: string): string {\n return path.isAbsolute(filePath) ? filePath : path.join(baseDir, filePath)\n}\n\nfunction resolveTypesConfig(\n baseConfig: TypesConfig | undefined,\n entryConfig: TypesConfig | undefined\n): TypesConfig | undefined {\n if (!baseConfig && !entryConfig) return undefined\n return {\n ...baseConfig,\n ...entryConfig,\n }\n}\n\nasync function generateSingle(options: {\n inputFile: string\n outputFile: string\n strictDates: boolean\n strictNumeric: boolean\n typesConfig?: TypesConfig\n}) {\n const { inputFile, outputFile, strictDates, strictNumeric, typesConfig } =\n options\n const resolvedInput = path.resolve(inputFile)\n const resolvedOutput = path.resolve(outputFile)\n\n const spec = readSpec(resolvedInput)\n const result = generateWithMetadata(spec, {\n strictDates,\n strictNumeric,\n types: typesConfig,\n })\n\n fs.mkdirSync(path.dirname(resolvedOutput), { recursive: true })\n fs.writeFileSync(resolvedOutput, result.output)\n\n console.log(`✅ Generated TypeScript types in ${resolvedOutput}`)\n console.log(`📄 Processed ${Object.keys(spec.paths).length} paths`)\n\n // Write helper file if needed\n if (result.helperFile) {\n const helperPath = path.isAbsolute(result.helperFile.path)\n ? result.helperFile.path\n : path.resolve(path.dirname(resolvedOutput), result.helperFile.path)\n\n // Resolve both paths to absolute paths for comparison\n const absoluteResolvedOutput = path.resolve(resolvedOutput)\n const absoluteHelperPath = path.resolve(helperPath)\n\n // Check if helper file would overwrite the main output\n if (absoluteResolvedOutput === absoluteHelperPath) {\n console.warn(\n `⚠️ Skipping helper file generation: would overwrite main output at ${absoluteResolvedOutput}`\n )\n return\n }\n\n fs.mkdirSync(path.dirname(helperPath), { recursive: true })\n fs.writeFileSync(helperPath, result.helperFile.content, {\n encoding: \"utf8\",\n })\n\n console.log(`📦 Generated helper types in ${helperPath}`)\n }\n}\n\nfunction readSpec(filePath: string): OpenAPISpec {\n if (!fs.existsSync(filePath)) {\n throw new Error(`Input file not found: ${filePath}`)\n }\n\n const content = fs.readFileSync(filePath, \"utf8\")\n\n if (filePath.endsWith(\".yaml\") || filePath.endsWith(\".yml\")) {\n return load(content) as OpenAPISpec\n }\n\n return JSON.parse(content) as OpenAPISpec\n}\n\nmain().catch((error) => {\n console.error(\"❌ Error:\", error)\n process.exit(1)\n})\n","export function topologicalSort(schemas: Record<string, any>): string[] {\n const visited = new Set<string>()\n const visiting = new Set<string>()\n const result: string[] = []\n\n const visit = (name: string): void => {\n if (visited.has(name)) return\n if (visiting.has(name)) {\n // Circular dependency detected, just add it anyway\n return\n }\n\n visiting.add(name)\n\n // Find dependencies of this schema\n const schema = schemas[name]\n const dependencies = extractDependencies(schema)\n\n // Visit dependencies first\n for (const dep of dependencies) {\n if (schemas[dep]) {\n visit(dep)\n }\n }\n\n visiting.delete(name)\n visited.add(name)\n result.push(name)\n }\n\n // Visit all schemas\n for (const name of Object.keys(schemas)) {\n visit(name)\n }\n\n return result\n}\n\nexport function extractDependencies(schema: any): string[] {\n const dependencies: string[] = []\n\n const traverse = (obj: any): void => {\n if (typeof obj !== \"object\" || obj === null) return\n\n if (obj.$ref && typeof obj.$ref === \"string\") {\n const refName = extractRefName(obj.$ref)\n dependencies.push(refName)\n return\n }\n\n if (Array.isArray(obj)) {\n obj.forEach(traverse)\n } else {\n Object.values(obj).forEach(traverse)\n }\n }\n\n traverse(schema)\n return [...new Set(dependencies)] // Remove duplicates\n}\n\nexport function extractRefName(ref: string): string {\n return ref.split(\"/\").pop() || \"Unknown\"\n}\n","/**\n * Checks if a string is a valid JavaScript identifier\n */\nexport function isValidJSIdentifier(name: string): boolean {\n // Check if name is empty\n if (!name) return false\n\n // Check if first character is valid (letter, underscore, or $)\n const firstChar = name.at(0)\n if (firstChar === undefined) return false\n if (!/[a-zA-Z_$]/.test(firstChar)) return false\n\n if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) return false\n\n // Check if it's a reserved word\n const reservedWords = new Set([\n \"abstract\",\n \"arguments\",\n \"await\",\n \"boolean\",\n \"break\",\n \"byte\",\n \"case\",\n \"catch\",\n \"char\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"double\",\n \"else\",\n \"enum\",\n \"eval\",\n \"export\",\n \"extends\",\n \"false\",\n \"final\",\n \"finally\",\n \"float\",\n \"for\",\n \"function\",\n \"goto\",\n \"if\",\n \"implements\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"int\",\n \"interface\",\n \"let\",\n \"long\",\n \"native\",\n \"new\",\n \"null\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"return\",\n \"short\",\n \"static\",\n \"super\",\n \"switch\",\n \"synchronized\",\n \"this\",\n \"throw\",\n \"throws\",\n \"transient\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"volatile\",\n \"while\",\n \"with\",\n \"yield\",\n \"async\",\n ])\n\n return !reservedWords.has(name)\n}\n\n/**\n * Formats a property name for use in JavaScript/TypeScript object literals\n * Quotes the name if it's not a valid JavaScript identifier\n */\nexport function formatPropertyName(name: string): string {\n return isValidJSIdentifier(name) ? name : `\"${name}\"`\n}\n","const statusNameMap: Record<string, string> = {\n \"400\": \"badRequest\",\n \"401\": \"unauthorized\",\n \"402\": \"paymentRequired\",\n \"403\": \"forbidden\",\n \"404\": \"notFound\",\n \"405\": \"methodNotAllowed\",\n \"406\": \"notAcceptable\",\n \"407\": \"proxyAuthenticationRequired\",\n \"408\": \"requestTimeout\",\n \"409\": \"conflict\",\n \"410\": \"gone\",\n \"411\": \"lengthRequired\",\n \"412\": \"preconditionFailed\",\n \"413\": \"payloadTooLarge\",\n \"414\": \"uriTooLong\",\n \"415\": \"unsupportedMediaType\",\n \"416\": \"rangeNotSatisfiable\",\n \"417\": \"expectationFailed\",\n \"418\": \"imATeapot\",\n \"421\": \"misdirectedRequest\",\n \"422\": \"unprocessableEntity\",\n \"423\": \"locked\",\n \"424\": \"failedDependency\",\n \"425\": \"tooEarly\",\n \"426\": \"upgradeRequired\",\n \"428\": \"preconditionRequired\",\n \"429\": \"tooManyRequests\",\n \"431\": \"requestHeaderFieldsTooLarge\",\n \"451\": \"unavailableForLegalReasons\",\n \"500\": \"internalServerError\",\n \"501\": \"notImplemented\",\n \"502\": \"badGateway\",\n \"503\": \"serviceUnavailable\",\n \"504\": \"gatewayTimeout\",\n \"505\": \"httpVersionNotSupported\",\n \"506\": \"variantAlsoNegotiates\",\n \"507\": \"insufficientStorage\",\n \"508\": \"loopDetected\",\n \"510\": \"notExtended\",\n \"511\": \"networkAuthenticationRequired\",\n} as const\n\nexport type StatusCategory = \"client\" | \"server\" | \"default\" | \"unknown\"\n\nexport function mapStatusToIdentifier(status: string): string {\n if (status === \"default\") return \"defaultError\"\n\n const trimmed = status.trim()\n const mapped = statusNameMap[trimmed]\n if (mapped) return mapped\n\n if (/^\\d{3}$/.test(trimmed)) {\n return `status${trimmed}`\n }\n\n const sanitized = trimmed\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \" \")\n .trim()\n\n if (!sanitized) return \"unknownError\"\n\n const parts = sanitized.split(/\\s+/)\n const [first, ...rest] = parts\n const candidate =\n first +\n rest\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join(\"\")\n\n if (!candidate) return \"unknownError\"\n\n return /^[a-zA-Z_$]/.test(candidate)\n ? candidate\n : `status${candidate.charAt(0).toUpperCase()}${candidate.slice(1)}`\n}\n\nexport function getStatusCategory(status: string): StatusCategory {\n if (status === \"default\") return \"default\"\n\n const code = Number(status)\n if (!Number.isInteger(code)) return \"unknown\"\n\n if (code >= 400 && code <= 499) return \"client\"\n if (code >= 500 && code <= 599) return \"server\"\n\n return \"unknown\"\n}\n\nexport function isErrorStatus(status: string): boolean {\n if (status === \"default\") return true\n const code = Number(status)\n if (!Number.isInteger(code)) return false\n return code >= 400\n}\n","import { topologicalSort, extractRefName } from \"./utils/topological-sort\"\nimport { formatPropertyName, isValidJSIdentifier } from \"./utils/property-name\"\nimport {\n getStatusCategory,\n isErrorStatus,\n mapStatusToIdentifier,\n} from \"./utils/http-status\"\nimport type { RequestMethod } from \"./types\"\n\nexport type OpenAPISpec = {\n openapi: string\n info: unknown\n paths: Record<string, Record<string, unknown>>\n components?: {\n schemas?: Record<string, unknown>\n parameters?: Record<string, unknown>\n }\n}\n\nexport type TypesHelperMode = \"package\" | \"inline\" | \"file\"\n\nexport type TypesConfig = {\n emit?: boolean\n helpers?: TypesHelperMode\n helpersOutput?: string\n}\n\nexport type GenerateOptions = {\n strictDates?: boolean\n strictNumeric?: boolean\n types?: TypesConfig\n}\n\nexport type GenerateResult = {\n output: string\n helperFile?: {\n path: string\n content: string\n }\n}\n\ntype PathParam = {\n name: string\n type: string\n}\n\ntype QueryParam = {\n name: string\n description?: string\n schema?: any\n required?: boolean\n}\n\ntype Operation = {\n operationId: string\n path: string\n method: RequestMethod\n pathParams: PathParam[]\n queryParams: QueryParam[]\n requestType?: string\n responseType?: string\n requestHeaders?: RequestHeader[]\n errors?: OperationErrorGroup\n}\ntype OperationErrorGroup = {\n clientErrors?: OperationErrorMap\n serverErrors?: OperationErrorMap\n defaultErrors?: OperationErrorMap\n otherErrors?: OperationErrorMap\n}\ntype OperationErrorMap = Record<string, string>\n\ntype RequestHeader = {\n name: string\n description?: string\n schema?: any\n required?: boolean\n}\n\n/**\n * Generate TypeScript source with additional metadata about helper files.\n *\n * @param spec - The OpenAPI specification to generate code from.\n * @param options - Generation options (e.g., strictDates, strictNumeric, types) that adjust emitted schemas and helper types.\n * @returns Object containing the generated output and optional helper file information.\n */\nexport function generateWithMetadata(\n spec: OpenAPISpec,\n options: GenerateOptions = {}\n): GenerateResult {\n const output: string[] = []\n const generatedTypes = new Set<string>()\n const { strictDates = false, strictNumeric = false } = options\n const typesConfig = normalizeTypesConfig(options.types)\n const schemaOptions: SchemaOptions = {\n strictDates,\n strictNumeric,\n }\n\n output.push('import { z } from \"zod\";')\n appendHelperTypesImport(output, typesConfig)\n output.push(\"\")\n\n // Generate Zod schemas from components/schemas\n if (spec.components?.schemas) {\n output.push(\"// Generated Zod Schemas\")\n output.push(\"\")\n\n // Sort schemas by dependencies (topological sort)\n const sortedSchemas = topologicalSort(spec.components.schemas)\n\n for (const name of sortedSchemas) {\n const schema = spec.components.schemas[name]\n output.push(\n generateZodSchema(name, schema, generatedTypes, schemaOptions)\n )\n output.push(\"\")\n // Export inferred type\n output.push(`export type ${name} = z.infer<typeof ${name}>;`)\n output.push(\"\")\n }\n }\n\n // Parse all operations\n const operations = parseOperations(spec)\n\n // Generate path functions\n output.push(\"// Path Functions\")\n output.push(\"export const paths = {\")\n\n for (const op of operations) {\n const pathParamNames = op.pathParams.map((p) => p.name)\n const hasPathParams = pathParamNames.length > 0\n const hasQueryParams = op.queryParams.length > 0\n const camelCaseOperationId = toCamelCase(op.operationId)\n\n if (!hasPathParams && !hasQueryParams) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: () => \"${op.path}\",`\n )\n continue\n }\n\n const allParamNames = [\n ...pathParamNames,\n ...op.queryParams.map((p) => p.name),\n ]\n const signaturePieces: string[] = []\n for (const param of op.pathParams) {\n signaturePieces.push(`${param.name}: string`)\n }\n for (const param of op.queryParams) {\n signaturePieces.push(\n `${param.name}${param.required ? \"\" : \"?\"}: ${mapQueryType(param)}`\n )\n }\n const signatureParams = signaturePieces.join(\", \")\n const needsDefaultObject =\n !hasPathParams &&\n hasQueryParams &&\n op.queryParams.every((param) => !param.required)\n const signatureArgs = allParamNames.length\n ? `{ ${allParamNames.join(\", \")} }`\n : \"{}\"\n const signature = `${signatureArgs}: { ${signatureParams} }${\n needsDefaultObject ? \" = {}\" : \"\"\n }`\n\n const pathWithParams = op.path.replace(/{([^}]+)}/g, \"${$1}\")\n\n if (!hasQueryParams) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: (${signature}) => \\`${pathWithParams}\\`,`\n )\n continue\n }\n\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: (${signature}) => {`\n )\n\n output.push(\" const params = new URLSearchParams()\")\n for (const param of op.queryParams) {\n const propertyKey = formatPropertyName(param.name)\n const accessor = isValidJSIdentifier(param.name)\n ? param.name\n : propertyKey\n const schema = param.schema ?? {}\n\n if (schema?.type === \"array\") {\n const itemValueExpression = convertQueryParamValue(\n schema.items ?? {},\n \"value\"\n )\n\n if (param.required) {\n output.push(` for (const value of ${accessor}) {`)\n output.push(\n ` params.append(\"${param.name}\", ${itemValueExpression})`\n )\n output.push(\" }\")\n } else {\n output.push(` if (${accessor} !== undefined) {`)\n output.push(` for (const value of ${accessor}) {`)\n output.push(\n ` params.append(\"${param.name}\", ${itemValueExpression})`\n )\n output.push(\" }\")\n output.push(\" }\")\n }\n\n continue\n }\n\n const valueExpression = convertQueryParamValue(schema, accessor)\n if (param.required) {\n output.push(` params.set(\"${param.name}\", ${valueExpression})`)\n } else {\n output.push(` if (${accessor} !== undefined) {`)\n output.push(` params.set(\"${param.name}\", ${valueExpression})`)\n output.push(\" }\")\n }\n }\n\n output.push(\" const _searchParams = params.toString()\")\n output.push(\n ` return \\`${pathWithParams}\\${_searchParams ? \\`?\\${_searchParams}\\` : \"\"}\\``\n )\n output.push(\" },\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n\n // Generate header schemas\n output.push(\"// Header Schemas\")\n output.push(\"export const headerSchemas = {\")\n\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n if (!op.requestHeaders || op.requestHeaders.length === 0) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: z.object({}),`\n )\n continue\n }\n\n const schemaFields = op.requestHeaders\n .map((header) => {\n const zodType = mapHeaderToZodType(header)\n const optional = header.required ? \"\" : \".optional()\"\n return ` ${formatPropertyName(header.name)}: ${zodType}${optional},`\n })\n .join(\"\\n\")\n\n output.push(` ${formatPropertyName(camelCaseOperationId)}: z.object({`)\n output.push(schemaFields)\n output.push(\" }),\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n\n // Generate header functions using Zod schemas\n output.push(\"// Header Functions\")\n output.push(\"export const headers = {\")\n\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n if (!op.requestHeaders || op.requestHeaders.length === 0) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: () => ${\n isValidJSIdentifier(camelCaseOperationId)\n ? `headerSchemas.${camelCaseOperationId}`\n : `headerSchemas[${formatPropertyName(camelCaseOperationId)}]`\n }.parse({}),`\n )\n continue\n }\n\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: (params: z.input<${\n isValidJSIdentifier(camelCaseOperationId)\n ? `typeof headerSchemas.${camelCaseOperationId}`\n : `(typeof headerSchemas)[${formatPropertyName(camelCaseOperationId)}]`\n }>) => {`\n )\n output.push(\n ` return ${\n isValidJSIdentifier(camelCaseOperationId)\n ? `headerSchemas.${camelCaseOperationId}`\n : `headerSchemas[${formatPropertyName(camelCaseOperationId)}]`\n }.parse(params)`\n )\n output.push(\" },\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n\n // Generate operation objects\n output.push(\"// Operation Objects\")\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n output.push(`export const ${camelCaseOperationId} = {`)\n output.push(` method: \"${op.method}\",`)\n output.push(` path: paths.${camelCaseOperationId},`)\n\n appendOperationField(output, \"request\", op.requestType)\n appendOperationField(output, \"response\", op.responseType)\n\n if (op.requestHeaders && op.requestHeaders.length > 0) {\n output.push(` headers: headers.${camelCaseOperationId},`)\n }\n\n if (op.errors && hasAnyErrors(op.errors)) {\n output.push(\" errors: {\")\n appendErrorGroup(output, \"clientErrors\", op.errors.clientErrors)\n appendErrorGroup(output, \"serverErrors\", op.errors.serverErrors)\n appendErrorGroup(output, \"defaultErrors\", op.errors.defaultErrors)\n appendErrorGroup(output, \"otherErrors\", op.errors.otherErrors)\n output.push(\" },\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n }\n\n generateOperationTypes(output, operations, typesConfig)\n\n const result: GenerateResult = {\n output: output.join(\"\\n\"),\n }\n\n // If using file-based helpers, include helper file information\n if (\n typesConfig.emit &&\n typesConfig.helpers === \"file\" &&\n typesConfig.helpersOutput\n ) {\n result.helperFile = {\n path: typesConfig.helpersOutput,\n content: generateHelperFile(),\n }\n }\n\n return result\n}\n\n/**\n * Generate TypeScript source that contains Zod schemas, path/header helpers, and operation objects/types from an OpenAPI spec.\n *\n * @param spec - The OpenAPI specification to generate code from.\n * @param options - Generation options (e.g., strictDates, strictNumeric, types) that adjust emitted schemas and helper types.\n * @returns The complete generated TypeScript source as a single string.\n */\nexport function generate(\n spec: OpenAPISpec,\n options: GenerateOptions = {}\n): string {\n return generateWithMetadata(spec, options).output\n}\n\nfunction appendOperationField(\n buffer: string[],\n key: string,\n value?: string\n): void {\n if (!value) return\n buffer.push(` ${key}: ${value},`)\n}\n\nfunction appendErrorGroup(\n buffer: string[],\n label: string,\n errors?: OperationErrorMap\n): void {\n if (!errors || Object.keys(errors).length === 0) return\n buffer.push(` ${label}: {`)\n for (const [name, typeName] of Object.entries(errors)) {\n buffer.push(` ${formatPropertyName(name)}: ${typeName},`)\n }\n buffer.push(\" },\")\n}\n\n/**\n * Determines whether any error bucket in an operation error group contains entries.\n *\n * @param group - The operation error group to inspect (client, server, default, other buckets)\n * @returns `true` if at least one bucket has one or more entries, `false` otherwise.\n */\nfunction hasAnyErrors(group: OperationErrorGroup): boolean {\n return [\n group.clientErrors,\n group.serverErrors,\n group.defaultErrors,\n group.otherErrors,\n ].some((bucket) => bucket && Object.keys(bucket).length > 0)\n}\n\n/**\n * Determines whether a given string is one of the supported HTTP request methods.\n *\n * @param method - The HTTP method name to check (expected in lowercase).\n * @returns `true` if `method` is one of `\"get\"`, `\"put\"`, `\"post\"`, `\"delete\"`, `\"options\"`, `\"head\"`, `\"patch\"`, or `\"trace\"`, `false` otherwise.\n */\nfunction isRequestMethod(method: string): method is RequestMethod {\n switch (method) {\n case \"get\":\n case \"put\":\n case \"post\":\n case \"delete\":\n case \"options\":\n case \"head\":\n case \"patch\":\n case \"trace\":\n return true\n default:\n return false\n }\n}\n\n/**\n * Content-type priority mapping for response type inference.\n */\nconst CONTENT_TYPE_MAP: Record<string, string> = {\n \"application/json\": \"unknown\", // Will use schema when available\n \"text/csv\": \"string\",\n \"text/plain\": \"string\",\n // Binary/ambiguous types default to unknown for cross-platform compatibility\n \"application/octet-stream\": \"unknown\",\n \"application/pdf\": \"unknown\",\n}\n\n/**\n * Finds the most appropriate content type from available options.\n * Prefers JSON first, then uses content-type mapping, otherwise takes first available.\n */\nfunction findContentType(content: Record<string, any>): string {\n const contentTypes = Object.keys(content)\n\n // Prefer JSON\n if (contentTypes.includes(\"application/json\")) {\n return \"application/json\"\n }\n\n // Use first content type that has a mapping\n for (const contentType of contentTypes) {\n if (contentType in CONTENT_TYPE_MAP) {\n return contentType\n }\n }\n\n // Default to first available\n return contentTypes[0] || \"\"\n}\n\n/**\n * Infers the TypeScript type for a response based on content type and status code.\n */\nfunction inferResponseType(\n contentType: string,\n statusCode: string\n): string | undefined {\n // Handle NoContent and redirects\n if (statusCode === \"204\" || /^3\\d\\d$/.test(statusCode)) {\n return \"undefined\"\n }\n\n // Use content-type mapping\n if (contentType in CONTENT_TYPE_MAP) {\n return CONTENT_TYPE_MAP[contentType]\n }\n\n // Default to unknown for unrecognized types\n return \"unknown\"\n}\n\n/**\n * Collects operation metadata from an OpenAPI spec for operations that declare an `operationId` and use a supported HTTP method.\n *\n * @param spec - The OpenAPI specification to parse.\n * @returns An array of Operation objects describing each discovered operation (operationId, path, lowercase `method`, path and query parameters, request/response type names, request headers, and categorized errors).\n */\nfunction parseOperations(spec: OpenAPISpec): Operation[] {\n const operations: Operation[] = []\n\n for (const [path, pathItem] of Object.entries(spec.paths)) {\n for (const [method, operation] of Object.entries(pathItem)) {\n const normalizedMethod = method.toLowerCase()\n if (!isRequestMethod(normalizedMethod)) continue\n if (!(operation as any).operationId) continue\n\n const pathParams = extractPathParams(path)\n const requestType = getRequestType(operation)\n const { successResponse, errors } = getResponseTypes(\n operation,\n (operation as any).operationId\n )\n const resolvedParameters = collectParameters(pathItem, operation, spec)\n const requestHeaders = getRequestHeaders(resolvedParameters)\n const queryParams = getQueryParams(resolvedParameters)\n\n operations.push({\n operationId: (operation as any).operationId,\n path,\n method: normalizedMethod,\n pathParams,\n queryParams,\n requestType,\n responseType: successResponse,\n requestHeaders,\n errors,\n })\n }\n }\n\n return operations\n}\n\nfunction normalizeTypesConfig(\n config: TypesConfig | undefined\n): NormalizedTypesConfig {\n return {\n emit: config?.emit ?? true,\n helpers: config?.helpers ?? \"package\",\n helpersOutput: config?.helpersOutput ?? \"./zenko-types\",\n }\n}\n\ntype NormalizedTypesConfig = {\n emit: boolean\n helpers: TypesHelperMode\n helpersOutput: string\n}\n\n/**\n * Appends helper type import or inline type declarations to the output buffer according to the types configuration.\n *\n * @param buffer - The output string buffer to which import lines or inline type declarations will be appended.\n * @param config - Normalized types configuration that controls whether to emit helpers and which helper mode to use (`package`, `file`, or `inline`). When `config.emit` is false no content is appended.\n */\nfunction appendHelperTypesImport(\n buffer: string[],\n config: NormalizedTypesConfig\n) {\n if (!config.emit) return\n\n switch (config.helpers) {\n case \"package\":\n buffer.push(\n 'import type { PathFn, HeaderFn, OperationDefinition, OperationErrors } from \"zenko\";'\n )\n return\n case \"file\":\n buffer.push(\n `import type { PathFn, HeaderFn, OperationDefinition, OperationErrors } from \"${config.helpersOutput}\";`\n )\n return\n case \"inline\":\n buffer.push(\n \"type PathFn<TArgs extends unknown[] = []> = (...args: TArgs) => string;\"\n )\n buffer.push(\n 'type RequestMethod = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\";'\n )\n buffer.push(\n \"type HeaderFn<TArgs extends unknown[] = [], TResult = Record<string, unknown> | Record<string, never>> = (...args: TArgs) => TResult;\"\n )\n buffer.push(\n \"type AnyHeaderFn = HeaderFn<any, unknown> | (() => unknown);\"\n )\n buffer.push(\n \"type OperationErrors<TClient = unknown, TServer = unknown, TDefault = unknown, TOther = unknown> = {\"\n )\n buffer.push(\" clientErrors?: TClient;\")\n buffer.push(\" serverErrors?: TServer;\")\n buffer.push(\" defaultErrors?: TDefault;\")\n buffer.push(\" otherErrors?: TOther;\")\n buffer.push(\"};\")\n buffer.push(\n \"type OperationDefinition<TMethod extends RequestMethod, TPath extends (...args: any[]) => string, TRequest = undefined, TResponse = undefined, THeaders extends AnyHeaderFn | undefined = undefined, TErrors extends OperationErrors | undefined = undefined> = {\"\n )\n buffer.push(\" method: TMethod;\")\n buffer.push(\" path: TPath;\")\n buffer.push(\" request?: TRequest;\")\n buffer.push(\" response?: TResponse;\")\n buffer.push(\" headers?: THeaders;\")\n buffer.push(\" errors?: TErrors;\")\n buffer.push(\"};\")\n return\n }\n}\n\n/**\n * Appends TypeScript operation type definitions to the output buffer.\n *\n * For each operation, emits an `export type <OperationId>Operation = OperationDefinition<...>` declaration\n * (including the HTTP method literal, path fn, request/response types, headers type, and errors type)\n * into the provided `buffer` when `config.emit` is true.\n *\n * @param buffer - Mutable array of output lines to append the generated type declarations to\n * @param operations - Array of operations to generate operation-type exports for\n * @param config - Normalized types configuration; generation is skipped when `config.emit` is false\n */\nfunction generateOperationTypes(\n buffer: string[],\n operations: Operation[],\n config: NormalizedTypesConfig\n) {\n if (!config.emit) return\n\n buffer.push(\"// Operation Types\")\n\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n const headerType = op.requestHeaders?.length\n ? isValidJSIdentifier(camelCaseOperationId)\n ? `typeof headers.${camelCaseOperationId}`\n : `(typeof headers)[${formatPropertyName(camelCaseOperationId)}]`\n : \"undefined\"\n const requestType = wrapTypeReference(op.requestType)\n const responseType = wrapTypeReference(op.responseType)\n const errorsType = buildOperationErrorsType(op.errors)\n\n buffer.push(\n `export type ${capitalize(camelCaseOperationId)}Operation = OperationDefinition<`\n )\n buffer.push(` \"${op.method}\",`)\n buffer.push(\n ` ${isValidJSIdentifier(camelCaseOperationId) ? `typeof paths.${camelCaseOperationId}` : `(typeof paths)[${formatPropertyName(camelCaseOperationId)}]`},`\n )\n buffer.push(` ${requestType},`)\n buffer.push(` ${responseType},`)\n buffer.push(` ${headerType},`)\n buffer.push(` ${errorsType}`)\n buffer.push(`>;`)\n buffer.push(\"\")\n }\n}\n\nfunction buildOperationErrorsType(errors?: OperationErrorGroup): string {\n if (!errors || !hasAnyErrors(errors)) {\n return \"OperationErrors\"\n }\n\n const client = buildErrorBucket(errors.clientErrors)\n const server = buildErrorBucket(errors.serverErrors)\n const fallback = buildErrorBucket(errors.defaultErrors)\n const other = buildErrorBucket(errors.otherErrors)\n\n return `OperationErrors<${client}, ${server}, ${fallback}, ${other}>`\n}\n\nfunction buildErrorBucket(bucket?: OperationErrorMap): string {\n if (!bucket || Object.keys(bucket).length === 0) {\n return \"unknown\"\n }\n\n const entries = Object.entries(bucket)\n const accessibleEntries = entries.map(([name, type]) => {\n const propertyKey = formatPropertyName(name)\n const valueType = wrapErrorValueType(type)\n return `${propertyKey}: ${valueType}`\n })\n\n return `{ ${accessibleEntries.join(\"; \")} }`\n}\n\nconst TYPE_KEYWORDS = new Set([\n \"any\",\n \"unknown\",\n \"never\",\n \"void\",\n \"null\",\n \"undefined\",\n \"string\",\n \"number\",\n \"boolean\",\n \"bigint\",\n \"symbol\",\n])\nconst IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/\n\nfunction wrapTypeReference(typeName?: string): string {\n if (!typeName) return \"undefined\"\n const normalized = typeName.trim()\n if (normalized === \"undefined\") return \"undefined\"\n if (TYPE_KEYWORDS.has(normalized)) return normalized\n if (normalized.startsWith(\"typeof \")) return normalized\n\n const arrayMatch = normalized.match(/^z\\.array\\((.+)\\)$/)\n if (arrayMatch) {\n return `z.ZodArray<${wrapTypeReference(arrayMatch[1])}>`\n }\n\n if (IDENTIFIER_PATTERN.test(normalized)) {\n return `typeof ${normalized}`\n }\n\n return normalized\n}\n\nfunction wrapErrorValueType(typeName?: string): string {\n if (!typeName) return \"unknown\"\n const normalized = typeName.trim()\n if (TYPE_KEYWORDS.has(normalized)) return normalized\n if (normalized.startsWith(\"typeof \")) return normalized\n\n const arrayMatch = normalized.match(/^z\\.array\\((.+)\\)$/)\n if (arrayMatch) {\n return `z.ZodArray<${wrapErrorValueType(arrayMatch[1])}>`\n }\n\n if (IDENTIFIER_PATTERN.test(normalized)) {\n return `typeof ${normalized}`\n }\n return normalized\n}\n\nfunction collectParameters(\n pathItem: Record<string, unknown>,\n operation: unknown,\n spec: OpenAPISpec\n): any[] {\n const parametersMap = new Map<string, any>()\n\n const addParameters = (params: unknown) => {\n if (!Array.isArray(params)) return\n\n for (const param of params) {\n const resolved = resolveParameter(param, spec)\n if (!resolved) continue\n const key = `${resolved.in}:${resolved.name}`\n parametersMap.set(key, resolved)\n }\n }\n\n addParameters((pathItem as any).parameters)\n addParameters((operation as any).parameters)\n\n return Array.from(parametersMap.values())\n}\n\nfunction resolveParameter(parameter: any, spec: OpenAPISpec) {\n if (!parameter) return undefined\n\n if (parameter.$ref) {\n const refName = extractRefName(parameter.$ref)\n const resolved = spec.components?.parameters?.[refName]\n if (!resolved) return undefined\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $ref, ...overrides } = parameter\n return {\n ...resolved,\n ...overrides,\n }\n }\n\n return parameter\n}\n\nfunction extractPathParams(path: string): PathParam[] {\n const params: PathParam[] = []\n const matches = path.match(/{([^}]+)}/g)\n\n if (matches) {\n for (const match of matches) {\n const paramName = match.slice(1, -1)\n params.push({\n name: paramName,\n type: \"string\", // OpenAPI path params are always strings\n })\n }\n }\n\n return params\n}\n\nfunction getRequestType(operation: any): string | undefined {\n const requestBody =\n operation.requestBody?.content?.[\"application/json\"]?.schema\n if (!requestBody) return undefined\n\n if (requestBody.$ref) {\n return extractRefName(requestBody.$ref)\n }\n\n // Generate inline type if needed\n const typeName = `${capitalize(operation.operationId)}Request`\n return typeName\n}\n\n/**\n * Resolves success and error response typings for an operation.\n *\n * @param operation - The OpenAPI operation node to inspect.\n * @param operationId - The operation identifier used for synthesized names.\n * @returns The preferred success response type and categorized error groups.\n */\nfunction getResponseTypes(\n operation: any,\n operationId: string\n): {\n successResponse?: string\n errors?: OperationErrorGroup\n} {\n const responses = operation.responses ?? {}\n const successCodes = new Map<string, string>()\n const errorEntries: Array<{ code: string; schema: any }> = []\n\n for (const [statusCode, response] of Object.entries(responses)) {\n // Handle content types\n const content = (response as any)?.content\n if (!content || Object.keys(content).length === 0) {\n // No content - handle based on status code\n if (statusCode === \"204\" || /^3\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, \"undefined\")\n } else if (isErrorStatus(statusCode)) {\n // Include error responses even without content\n errorEntries.push({\n code: statusCode,\n schema: \"undefined\",\n })\n }\n continue\n }\n\n // Find the appropriate content type\n const contentType = findContentType(content)\n const resolvedSchema = content[contentType]?.schema\n\n if (!resolvedSchema) {\n // No schema - infer from content type\n const inferredType = inferResponseType(contentType, statusCode)\n if (inferredType) {\n if (isErrorStatus(statusCode)) {\n errorEntries.push({\n code: statusCode,\n schema: inferredType,\n })\n } else if (/^2\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, inferredType)\n }\n }\n continue\n }\n\n if (isErrorStatus(statusCode)) {\n errorEntries.push({ code: statusCode, schema: resolvedSchema })\n continue\n }\n\n if (/^2\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, resolvedSchema)\n }\n }\n\n const successResponse = selectSuccessResponse(successCodes, operationId)\n const errors = buildErrorGroups(errorEntries, operationId)\n\n return { successResponse, errors }\n}\n\n/**\n * Picks the most representative success response type from available candidates.\n *\n * Prefers 200/201/204 responses, falling back to the first declared status code.\n * When a schema is provided as a literal type string the literal is returned\n * directly; otherwise a synthetic type name is generated via `resolveResponseType`.\n *\n * @param responses - Map of status codes to resolved schemas or inferred literals.\n * @param operationId - Operation identifier used to construct synthetic names.\n * @returns The chosen TypeScript type name, or `undefined` when no success response exists.\n */\nfunction selectSuccessResponse(\n responses: Map<string, any>,\n operationId: string\n): string | undefined {\n if (responses.size === 0) return undefined\n\n const preferredOrder = [\"200\", \"201\", \"204\"]\n for (const code of preferredOrder) {\n const schema = responses.get(code)\n if (schema) {\n if (typeof schema === \"string\") {\n // Direct type (e.g., \"undefined\", \"string\", \"unknown\")\n return schema\n }\n return resolveResponseType(\n schema,\n `${capitalize(operationId)}Response${code}`\n )\n }\n }\n\n const [firstCode, firstSchema] = responses.entries().next().value ?? []\n if (!firstSchema) return undefined\n\n if (typeof firstSchema === \"string\") {\n return firstSchema\n }\n\n return resolveResponseType(\n firstSchema,\n `${capitalize(operationId)}Response${firstCode ?? \"Default\"}`\n )\n}\n\n/**\n * Buckets error responses by status-class and maps them to concrete type names.\n *\n * @param errors - Collection of HTTP status codes paired with schemas or literals.\n * @param operationId - Operation identifier used when synthesizing fallback names.\n * @returns Structured error groups keyed by client/server/default/other categories.\n */\nfunction buildErrorGroups(\n errors: Array<{ code: string; schema: any }> = [],\n operationId: string\n): OperationErrorGroup | undefined {\n if (!errors.length) return undefined\n\n const group: OperationErrorGroup = {}\n\n for (const { code, schema } of errors) {\n const category = getStatusCategory(code)\n const identifier = mapStatusToIdentifier(code)\n const typeName = resolveResponseType(\n schema,\n `${capitalize(operationId)}${capitalize(identifier)}`\n )\n\n switch (category) {\n case \"client\":\n group.clientErrors ??= {}\n group.clientErrors[identifier] = typeName\n break\n case \"server\":\n group.serverErrors ??= {}\n group.serverErrors[identifier] = typeName\n break\n case \"default\":\n group.defaultErrors ??= {}\n group.defaultErrors[identifier] = typeName\n break\n default:\n group.otherErrors ??= {}\n group.otherErrors[identifier] = typeName\n break\n }\n }\n\n return group\n}\n\n/**\n * Resolves the emitted TypeScript identifier for a response schema.\n *\n * @param schema - Schema object or inferred literal type returned by inference.\n * @param fallbackName - Synthetic name to use when the schema lacks a `$ref`.\n * @returns Reference name, literal type, or the provided fallback.\n */\nfunction resolveResponseType(schema: any, fallbackName: string): string {\n if (typeof schema === \"string\") {\n return schema\n }\n if (schema.$ref) {\n return extractRefName(schema.$ref)\n }\n // Handle array schemas with $ref items\n if (schema.type === \"array\" && schema.items?.$ref) {\n const itemRef = extractRefName(schema.items.$ref)\n return `z.array(${itemRef})`\n }\n return fallbackName\n}\n\nfunction getRequestHeaders(parameters: any[]): RequestHeader[] {\n const headers: RequestHeader[] = []\n\n for (const param of parameters ?? []) {\n if ((param as any).in === \"header\") {\n headers.push({\n name: (param as any).name,\n description: (param as any).description,\n schema: (param as any).schema,\n required: (param as any).required,\n })\n }\n }\n\n return headers\n}\n\nfunction getQueryParams(parameters: any[]): QueryParam[] {\n const queryParams: QueryParam[] = []\n\n for (const param of parameters ?? []) {\n if ((param as any).in === \"query\") {\n queryParams.push({\n name: (param as any).name,\n description: (param as any).description,\n schema: (param as any).schema,\n required: (param as any).required,\n })\n }\n }\n\n return queryParams\n}\n\nfunction mapHeaderToZodType(header: RequestHeader): string {\n const schema = header.schema ?? {}\n const schemaType = schema.type\n switch (schemaType) {\n case \"integer\":\n case \"number\":\n // Accept numeric header values provided as strings\n return \"z.coerce.number()\"\n case \"boolean\":\n // Accept boolean header values provided as strings\n return \"z.coerce.boolean()\"\n case \"array\": {\n const items = schema.items ?? { type: \"string\" }\n const itemType =\n items.type === \"integer\" || items.type === \"number\"\n ? \"z.coerce.number()\"\n : items.type === \"boolean\"\n ? \"z.coerce.boolean()\"\n : \"z.string()\"\n return `z.array(${itemType})`\n }\n default:\n return \"z.string()\"\n }\n}\n\nfunction mapQueryType(param: QueryParam): string {\n return mapQuerySchemaType(param.schema)\n}\n\nfunction mapQuerySchemaType(schema: any): string {\n if (!schema) return \"string\"\n\n if (schema.type === \"array\") {\n const itemType = mapQuerySchemaType(schema.items)\n return `Array<${itemType}>`\n }\n\n switch (schema.type) {\n case \"integer\":\n case \"number\":\n return \"number\"\n case \"boolean\":\n return \"boolean\"\n default:\n return \"string\"\n }\n}\n\nfunction convertQueryParamValue(schema: any, accessor: string): string {\n if (!schema) {\n return `String(${accessor})`\n }\n\n switch (schema.type) {\n case \"integer\":\n case \"number\":\n return `String(${accessor})`\n case \"boolean\":\n return `${accessor} ? \"true\" : \"false\"`\n default:\n return `String(${accessor})`\n }\n}\n\ntype SchemaOptions = {\n strictDates: boolean\n strictNumeric: boolean\n}\n\nfunction generateZodSchema(\n name: string,\n schema: any,\n generatedTypes: Set<string>,\n options: SchemaOptions\n): string {\n if (generatedTypes.has(name)) return \"\"\n generatedTypes.add(name)\n\n if (schema.enum) {\n const enumValues = schema.enum.map((v: string) => `\"${v}\"`).join(\", \")\n return `export const ${name} = z.enum([${enumValues}]);`\n }\n\n if (schema.type === \"object\" || schema.properties) {\n return `export const ${name} = ${buildZodObject(schema, options)};`\n }\n\n if (schema.type === \"array\") {\n const itemSchema = schema.items ?? { type: \"unknown\" }\n const itemType = getZodTypeFromSchema(itemSchema, options)\n const builder = applyStrictArrayBounds(\n schema,\n `z.array(${itemType})`,\n itemSchema,\n options.strictNumeric\n )\n return `export const ${name} = ${builder};`\n }\n\n return `export const ${name} = ${getZodTypeFromSchema(schema, options)};`\n}\n\nfunction getZodTypeFromSchema(schema: any, options: SchemaOptions): string {\n if (schema.$ref) {\n return extractRefName(schema.$ref)\n }\n\n if (schema.enum) {\n const enumValues = schema.enum.map((v: string) => `\"${v}\"`).join(\", \")\n return `z.enum([${enumValues}])`\n }\n\n if (schema.type === \"object\" || schema.properties) {\n return buildZodObject(schema, options)\n }\n\n switch (schema.type) {\n case \"string\":\n return buildString(schema, options)\n case \"boolean\":\n return \"z.boolean()\"\n case \"array\":\n return `z.array(${getZodTypeFromSchema(\n schema.items ?? { type: \"unknown\" },\n options\n )})`\n case \"null\":\n return \"z.null()\"\n case \"number\":\n return buildNumber(schema, options)\n case \"integer\":\n return buildInteger(schema, options)\n default:\n return \"z.unknown()\"\n }\n}\n\nfunction buildZodObject(schema: any, options: SchemaOptions): string {\n const properties: string[] = []\n\n for (const [propName, propSchema] of Object.entries(\n schema.properties || {}\n )) {\n const isRequired = schema.required?.includes(propName) ?? false\n const zodType = getZodTypeFromSchema(propSchema as any, options)\n const finalType = isRequired ? zodType : `${zodType}.optional()`\n properties.push(` ${formatPropertyName(propName)}: ${finalType},`)\n }\n\n if (properties.length === 0) {\n return \"z.object({})\"\n }\n\n return `z.object({\\n${properties.join(\"\\n\")}\\n})`\n}\n\nfunction buildString(schema: any, options: SchemaOptions): string {\n if (options.strictDates) {\n switch (schema.format) {\n case \"date-time\":\n return \"z.string().datetime()\"\n case \"date\":\n return \"z.string().date()\"\n case \"time\":\n return \"z.string().time()\"\n case \"duration\":\n return \"z.string().duration()\"\n }\n }\n\n let builder = \"z.string()\"\n\n if (options.strictNumeric) {\n if (typeof schema.minLength === \"number\") {\n builder += `.min(${schema.minLength})`\n }\n\n if (typeof schema.maxLength === \"number\") {\n builder += `.max(${schema.maxLength})`\n }\n\n if (schema.pattern) {\n builder += `.regex(new RegExp(${JSON.stringify(schema.pattern)}))`\n }\n }\n\n switch (schema.format) {\n case \"uuid\":\n return `${builder}.uuid()`\n case \"email\":\n return `${builder}.email()`\n case \"uri\":\n case \"url\":\n return `${builder}.url()`\n case \"ipv4\":\n return `${builder}.ip({ version: \"v4\" })`\n case \"ipv6\":\n return `${builder}.ip({ version: \"v6\" })`\n default:\n return builder\n }\n}\n\nfunction buildNumber(schema: any, options: SchemaOptions): string {\n let builder = \"z.number()\"\n\n if (options.strictNumeric) {\n builder = applyNumericBounds(schema, builder)\n\n if (typeof schema.multipleOf === \"number\" && schema.multipleOf !== 0) {\n builder += `.refine((value) => Math.abs(value / ${schema.multipleOf} - Math.round(value / ${schema.multipleOf})) < Number.EPSILON, { message: \"Must be a multiple of ${schema.multipleOf}\" })`\n }\n }\n\n return builder\n}\n\nfunction buildInteger(schema: any, options: SchemaOptions): string {\n let builder = buildNumber(schema, options)\n builder += \".int()\"\n return builder\n}\n\nfunction applyStrictArrayBounds(\n schema: any,\n builder: string,\n itemSchema: any,\n enforceBounds: boolean\n): string {\n if (!enforceBounds) {\n return builder\n }\n\n if (typeof schema.minItems === \"number\") {\n builder += `.min(${schema.minItems})`\n }\n\n if (typeof schema.maxItems === \"number\") {\n builder += `.max(${schema.maxItems})`\n }\n\n if (schema.uniqueItems && isPrimitiveLike(itemSchema)) {\n builder +=\n '.refine((items) => new Set(items).size === items.length, { message: \"Items must be unique\" })'\n }\n\n return builder\n}\n\nfunction isPrimitiveLike(schema: any): boolean {\n if (schema?.$ref) return false\n\n const primitiveTypes = new Set([\"string\", \"number\", \"integer\", \"boolean\"])\n return primitiveTypes.has(schema?.type)\n}\n\nfunction applyNumericBounds(schema: any, builder: string): string {\n if (typeof schema.minimum === \"number\") {\n if (schema.exclusiveMinimum === true) {\n builder += `.gt(${schema.minimum})`\n } else {\n builder += `.min(${schema.minimum})`\n }\n } else if (typeof schema.exclusiveMinimum === \"number\") {\n builder += `.gt(${schema.exclusiveMinimum})`\n }\n\n if (typeof schema.maximum === \"number\") {\n if (schema.exclusiveMaximum === true) {\n builder += `.lt(${schema.maximum})`\n } else {\n builder += `.max(${schema.maximum})`\n }\n } else if (typeof schema.exclusiveMaximum === \"number\") {\n builder += `.lt(${schema.exclusiveMaximum})`\n }\n\n return builder\n}\n\n/**\n * Generate a standalone helper types file for use with `helpers: \"file\"` mode.\n *\n * @returns TypeScript source containing PathFn, HeaderFn, OperationDefinition, and OperationErrors type definitions.\n */\nexport function generateHelperFile(): string {\n const output: string[] = []\n\n output.push(\"// Generated helper types for Zenko\")\n output.push(\n \"// This file provides type definitions for operation objects and path functions\"\n )\n output.push(\"\")\n output.push(\n \"export type PathFn<TArgs extends unknown[] = []> = (...args: TArgs) => string\"\n )\n output.push(\"\")\n output.push(\n 'export type RequestMethod = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"'\n )\n output.push(\"\")\n output.push(\n \"export type HeaderFn<TArgs extends unknown[] = [], TResult = Record<string, unknown> | Record<string, never>> = (...args: TArgs) => TResult\"\n )\n output.push(\"\")\n output.push(\n \"export type AnyHeaderFn = HeaderFn<any, unknown> | (() => unknown)\"\n )\n output.push(\"\")\n output.push(\n \"export type OperationErrors<TClient = unknown, TServer = unknown, TDefault = unknown, TOther = unknown> = {\"\n )\n output.push(\" clientErrors?: TClient\")\n output.push(\" serverErrors?: TServer\")\n output.push(\" defaultErrors?: TDefault\")\n output.push(\" otherErrors?: TOther\")\n output.push(\"}\")\n output.push(\"\")\n output.push(\n \"export type OperationDefinition<TMethod extends RequestMethod, TPath extends (...args: any[]) => string, TRequest = undefined, TResponse = undefined, THeaders extends AnyHeaderFn | undefined = undefined, TErrors extends OperationErrors | undefined = undefined> = {\"\n )\n output.push(\" method: TMethod\")\n output.push(\" path: TPath\")\n output.push(\" request?: TRequest\")\n output.push(\" response?: TResponse\")\n output.push(\" headers?: THeaders\")\n output.push(\" errors?: TErrors\")\n output.push(\"}\")\n output.push(\"\")\n\n return output.join(\"\\n\")\n}\n\nfunction toCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAoB;AACpB,WAAsB;AACtB,iBAA8B;AAC9B,qBAAqB;;;ACLd,SAAS,gBAAgB,SAAwC;AACtE,QAAM,UAAU,oBAAI,IAAY;AAChC,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,SAAmB,CAAC;AAE1B,QAAM,QAAQ,CAAC,SAAuB;AACpC,QAAI,QAAQ,IAAI,IAAI,EAAG;AACvB,QAAI,SAAS,IAAI,IAAI,GAAG;AAEtB;AAAA,IACF;AAEA,aAAS,IAAI,IAAI;AAGjB,UAAM,SAAS,QAAQ,IAAI;AAC3B,UAAM,eAAe,oBAAoB,MAAM;AAG/C,eAAW,OAAO,cAAc;AAC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AAK,KAAK,KAAK,EAAE,MAAM,QAAQ;AAGlE,MAAI,OAAO,YAAY;AACrB,UAAM,aAAkB,gBAAW,OAAO,WAAW,IAAI,IACrD,OAAO,WAAW,OACb,aAAa,aAAQ,cAAc,GAAG,OAAO,WAAW,IAAI;AAGrE,UAAM,yBAA8B,aAAQ,cAAc;AAC1D,UAAM,qBAA0B,aAAQ,UAAU;AAGlD,QAAI,2BAA2B,oBAAoB;AACjD,cAAQ;AAAA,QACN,iFAAuE,sBAAsB;AAAA,MAC/F;AACA;AAAA,IACF;AAEA,IAAG,aAAe,aAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AAC1D,IAAG,iBAAc,YAAY,OAAO,WAAW,SAAS;AAAA,MACtD,UAAU;AAAA,IACZ,CAAC;AAED,YAAQ,IAAI,uCAAgC,UAAU,EAAE;AAAA,EAC1D;AACF;AAEA,SAAS,SAAS,UAA+B;AAC/C,MAAI,CAAI,cAAW,QAAQ,GAAG;AAC5B,UAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AAAA,EACrD;AAEA,QAAM,UAAa,gBAAa,UAAU,MAAM;AAEhD,MAAI,SAAS,SAAS,OAAO,KAAK,SAAS,SAAS,MAAM,GAAG;AAC3D,eAAO,qBAAK,OAAO;AAAA,EACrB;AAEA,SAAO,KAAK,MAAM,OAAO;AAC3B;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,iBAAY,KAAK;AAC/B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["path","module"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/utils/topological-sort.ts","../src/utils/property-name.ts","../src/utils/http-status.ts","../src/zenko.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as fs from \"fs\"\nimport * as path from \"path\"\nimport { pathToFileURL } from \"url\"\nimport { load } from \"js-yaml\"\nimport {\n generateWithMetadata,\n type OpenAPISpec,\n type TypesConfig,\n} from \"./zenko.js\"\n\ntype CliConfigEntry = {\n input: string\n output: string\n strictDates?: boolean\n strictNumeric?: boolean\n types?: TypesConfig\n}\n\ntype CliConfigFile = {\n schemas: CliConfigEntry[]\n types?: TypesConfig\n}\n\ntype ParsedArgs = {\n showHelp: boolean\n strictDates: boolean\n strictNumeric: boolean\n configPath?: string\n positional: string[]\n}\n\nasync function main() {\n const args = process.argv.slice(2)\n const parsed = parseArgs(args)\n\n if (\n parsed.showHelp ||\n (!parsed.configPath && parsed.positional.length === 0)\n ) {\n printHelp()\n process.exit(parsed.showHelp ? 0 : 1)\n return\n }\n\n try {\n if (parsed.configPath) {\n await runFromConfig(parsed)\n } else {\n if (parsed.positional.length !== 2) {\n printHelp()\n process.exit(1)\n return\n }\n\n const [inputFile, outputFile] = parsed.positional\n if (!inputFile || !outputFile) {\n printHelp()\n process.exit(1)\n return\n }\n await generateSingle({\n inputFile,\n outputFile,\n strictDates: parsed.strictDates,\n strictNumeric: parsed.strictNumeric,\n })\n }\n } catch (error) {\n console.error(\"❌ Error:\", error)\n process.exit(1)\n }\n}\n\nfunction parseArgs(args: string[]): ParsedArgs {\n const parsed: ParsedArgs = {\n showHelp: false,\n strictDates: false,\n strictNumeric: false,\n positional: [],\n }\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!\n\n if (arg === \"-h\" || arg === \"--help\") {\n parsed.showHelp = true\n continue\n }\n\n if (arg === \"--strict-dates\") {\n parsed.strictDates = true\n continue\n }\n\n if (arg === \"--strict-numeric\") {\n parsed.strictNumeric = true\n continue\n }\n\n if (arg === \"--config\" || arg === \"-c\") {\n const next = args[index + 1]\n if (!next) {\n throw new Error(\"--config flag requires a file path\")\n }\n parsed.configPath = next\n index += 1\n continue\n }\n\n parsed.positional.push(arg)\n }\n\n return parsed\n}\n\nfunction printHelp() {\n console.log(\"Usage:\")\n console.log(\" zenko <input-file> <output-file> [options]\")\n console.log(\" zenko --config <config-file> [options]\")\n console.log(\"\")\n console.log(\"Options:\")\n console.log(\" -h, --help Show this help message\")\n console.log(\n \" --strict-dates Use ISO datetime parsing (can be set per config entry)\"\n )\n console.log(\n \" --strict-numeric Preserve numeric min/max bounds (can be set per config entry)\"\n )\n console.log(\n \" -c, --config Path to config file (JSON, YAML, or JS module)\"\n )\n console.log(\"\")\n console.log(\"Config file format:\")\n console.log(\n ' {\"types\"?: { emit?, helpers?, helpersOutput? }, \"schemas\": [{ input, output, strictDates?, strictNumeric?, types? }] }'\n )\n}\n\nasync function runFromConfig(parsed: ParsedArgs) {\n const configPath = parsed.configPath!\n const resolvedConfigPath = path.resolve(configPath)\n const config = await loadConfig(resolvedConfigPath)\n validateConfig(config)\n\n const baseDir = path.dirname(resolvedConfigPath)\n const baseTypesConfig = config.types\n\n for (const entry of config.schemas) {\n const inputFile = resolvePath(entry.input, baseDir)\n const outputFile = resolvePath(entry.output, baseDir)\n const typesConfig = resolveTypesConfig(baseTypesConfig, entry.types)\n await generateSingle({\n inputFile,\n outputFile,\n strictDates: entry.strictDates ?? parsed.strictDates,\n strictNumeric: entry.strictNumeric ?? parsed.strictNumeric,\n typesConfig,\n })\n }\n}\n\nasync function loadConfig(filePath: string): Promise<unknown> {\n const extension = path.extname(filePath).toLowerCase()\n\n if (extension === \".json\") {\n const content = fs.readFileSync(filePath, \"utf8\")\n return JSON.parse(content)\n }\n\n if (extension === \".yaml\" || extension === \".yml\") {\n const content = fs.readFileSync(filePath, \"utf8\")\n return load(content)\n }\n\n const fileUrl = pathToFileURL(filePath).href\n const module = await import(fileUrl)\n return module.default ?? module.config ?? module\n}\n\nfunction validateConfig(config: unknown): asserts config is CliConfigFile {\n if (!config || typeof config !== \"object\") {\n throw new Error(\"Config file must export an object\")\n }\n\n if (!Array.isArray((config as CliConfigFile).schemas)) {\n throw new Error(\"Config file must contain a 'schemas' array\")\n }\n\n for (const entry of (config as CliConfigFile).schemas) {\n if (!entry || typeof entry !== \"object\") {\n throw new Error(\"Each schema entry must be an object\")\n }\n if (typeof entry.input !== \"string\" || typeof entry.output !== \"string\") {\n throw new Error(\"Each schema entry requires 'input' and 'output' paths\")\n }\n }\n}\n\nfunction resolvePath(filePath: string, baseDir: string): string {\n return path.isAbsolute(filePath) ? filePath : path.join(baseDir, filePath)\n}\n\nfunction resolveTypesConfig(\n baseConfig: TypesConfig | undefined,\n entryConfig: TypesConfig | undefined\n): TypesConfig | undefined {\n if (!baseConfig && !entryConfig) return undefined\n return {\n ...baseConfig,\n ...entryConfig,\n }\n}\n\nasync function generateSingle(options: {\n inputFile: string\n outputFile: string\n strictDates: boolean\n strictNumeric: boolean\n typesConfig?: TypesConfig\n}) {\n const { inputFile, outputFile, strictDates, strictNumeric, typesConfig } =\n options\n const resolvedInput = path.resolve(inputFile)\n const resolvedOutput = path.resolve(outputFile)\n\n const spec = readSpec(resolvedInput)\n const result = generateWithMetadata(spec, {\n strictDates,\n strictNumeric,\n types: typesConfig,\n })\n\n fs.mkdirSync(path.dirname(resolvedOutput), { recursive: true })\n fs.writeFileSync(resolvedOutput, result.output)\n\n console.log(`✅ Generated TypeScript types in ${resolvedOutput}`)\n console.log(`📄 Processed ${Object.keys(spec.paths).length} paths`)\n\n // Write helper file if needed\n if (result.helperFile) {\n const helperPath = path.isAbsolute(result.helperFile.path)\n ? result.helperFile.path\n : path.resolve(path.dirname(resolvedOutput), result.helperFile.path)\n\n // Resolve both paths to absolute paths for comparison\n const absoluteResolvedOutput = path.resolve(resolvedOutput)\n const absoluteHelperPath = path.resolve(helperPath)\n\n // Check if helper file would overwrite the main output\n if (absoluteResolvedOutput === absoluteHelperPath) {\n console.warn(\n `⚠️ Skipping helper file generation: would overwrite main output at ${absoluteResolvedOutput}`\n )\n return\n }\n\n fs.mkdirSync(path.dirname(helperPath), { recursive: true })\n fs.writeFileSync(helperPath, result.helperFile.content, {\n encoding: \"utf8\",\n })\n\n console.log(`📦 Generated helper types in ${helperPath}`)\n }\n}\n\nfunction readSpec(filePath: string): OpenAPISpec {\n if (!fs.existsSync(filePath)) {\n throw new Error(`Input file not found: ${filePath}`)\n }\n\n const content = fs.readFileSync(filePath, \"utf8\")\n\n if (filePath.endsWith(\".yaml\") || filePath.endsWith(\".yml\")) {\n return load(content) as OpenAPISpec\n }\n\n return JSON.parse(content) as OpenAPISpec\n}\n\nmain().catch((error) => {\n console.error(\"❌ Error:\", error)\n process.exit(1)\n})\n","export function topologicalSort(schemas: Record<string, any>): string[] {\n const visited = new Set<string>()\n const visiting = new Set<string>()\n const result: string[] = []\n\n const visit = (name: string): void => {\n if (visited.has(name)) return\n if (visiting.has(name)) {\n // Circular dependency detected, just add it anyway\n return\n }\n\n visiting.add(name)\n\n // Find dependencies of this schema\n const schema = schemas[name]\n const dependencies = extractDependencies(schema)\n\n // Visit dependencies first\n for (const dep of dependencies) {\n if (schemas[dep]) {\n visit(dep)\n }\n }\n\n visiting.delete(name)\n visited.add(name)\n result.push(name)\n }\n\n // Visit all schemas\n for (const name of Object.keys(schemas)) {\n visit(name)\n }\n\n return result\n}\n\nexport function extractDependencies(schema: any): string[] {\n const dependencies: string[] = []\n\n const traverse = (obj: any): void => {\n if (typeof obj !== \"object\" || obj === null) return\n\n if (obj.$ref && typeof obj.$ref === \"string\") {\n const refName = extractRefName(obj.$ref)\n dependencies.push(refName)\n return\n }\n\n if (Array.isArray(obj)) {\n obj.forEach(traverse)\n } else {\n Object.values(obj).forEach(traverse)\n }\n }\n\n traverse(schema)\n return [...new Set(dependencies)] // Remove duplicates\n}\n\nexport function extractRefName(ref: string): string {\n return ref.split(\"/\").pop() || \"Unknown\"\n}\n","/**\n * Checks if a string is a valid JavaScript identifier\n */\nexport function isValidJSIdentifier(name: string): boolean {\n // Check if name is empty\n if (!name) return false\n\n // Check if first character is valid (letter, underscore, or $)\n const firstChar = name.at(0)\n if (firstChar === undefined) return false\n if (!/[a-zA-Z_$]/.test(firstChar)) return false\n\n if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) return false\n\n // Check if it's a reserved word\n const reservedWords = new Set([\n \"abstract\",\n \"arguments\",\n \"await\",\n \"boolean\",\n \"break\",\n \"byte\",\n \"case\",\n \"catch\",\n \"char\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"double\",\n \"else\",\n \"enum\",\n \"eval\",\n \"export\",\n \"extends\",\n \"false\",\n \"final\",\n \"finally\",\n \"float\",\n \"for\",\n \"function\",\n \"goto\",\n \"if\",\n \"implements\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"int\",\n \"interface\",\n \"let\",\n \"long\",\n \"native\",\n \"new\",\n \"null\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"return\",\n \"short\",\n \"static\",\n \"super\",\n \"switch\",\n \"synchronized\",\n \"this\",\n \"throw\",\n \"throws\",\n \"transient\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"volatile\",\n \"while\",\n \"with\",\n \"yield\",\n \"async\",\n ])\n\n return !reservedWords.has(name)\n}\n\n/**\n * Formats a property name for use in JavaScript/TypeScript object literals\n * Quotes the name if it's not a valid JavaScript identifier\n */\nexport function formatPropertyName(name: string): string {\n return isValidJSIdentifier(name) ? name : `\"${name}\"`\n}\n","const statusNameMap: Record<string, string> = {\n \"400\": \"badRequest\",\n \"401\": \"unauthorized\",\n \"402\": \"paymentRequired\",\n \"403\": \"forbidden\",\n \"404\": \"notFound\",\n \"405\": \"methodNotAllowed\",\n \"406\": \"notAcceptable\",\n \"407\": \"proxyAuthenticationRequired\",\n \"408\": \"requestTimeout\",\n \"409\": \"conflict\",\n \"410\": \"gone\",\n \"411\": \"lengthRequired\",\n \"412\": \"preconditionFailed\",\n \"413\": \"payloadTooLarge\",\n \"414\": \"uriTooLong\",\n \"415\": \"unsupportedMediaType\",\n \"416\": \"rangeNotSatisfiable\",\n \"417\": \"expectationFailed\",\n \"418\": \"imATeapot\",\n \"421\": \"misdirectedRequest\",\n \"422\": \"unprocessableEntity\",\n \"423\": \"locked\",\n \"424\": \"failedDependency\",\n \"425\": \"tooEarly\",\n \"426\": \"upgradeRequired\",\n \"428\": \"preconditionRequired\",\n \"429\": \"tooManyRequests\",\n \"431\": \"requestHeaderFieldsTooLarge\",\n \"451\": \"unavailableForLegalReasons\",\n \"500\": \"internalServerError\",\n \"501\": \"notImplemented\",\n \"502\": \"badGateway\",\n \"503\": \"serviceUnavailable\",\n \"504\": \"gatewayTimeout\",\n \"505\": \"httpVersionNotSupported\",\n \"506\": \"variantAlsoNegotiates\",\n \"507\": \"insufficientStorage\",\n \"508\": \"loopDetected\",\n \"510\": \"notExtended\",\n \"511\": \"networkAuthenticationRequired\",\n} as const\n\nexport type StatusCategory = \"client\" | \"server\" | \"default\" | \"unknown\"\n\nexport function mapStatusToIdentifier(status: string): string {\n if (status === \"default\") return \"defaultError\"\n\n const trimmed = status.trim()\n const mapped = statusNameMap[trimmed]\n if (mapped) return mapped\n\n if (/^\\d{3}$/.test(trimmed)) {\n return `status${trimmed}`\n }\n\n const sanitized = trimmed\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \" \")\n .trim()\n\n if (!sanitized) return \"unknownError\"\n\n const parts = sanitized.split(/\\s+/)\n const [first, ...rest] = parts\n const candidate =\n first +\n rest\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join(\"\")\n\n if (!candidate) return \"unknownError\"\n\n return /^[a-zA-Z_$]/.test(candidate)\n ? candidate\n : `status${candidate.charAt(0).toUpperCase()}${candidate.slice(1)}`\n}\n\nexport function getStatusCategory(status: string): StatusCategory {\n if (status === \"default\") return \"default\"\n\n const code = Number(status)\n if (!Number.isInteger(code)) return \"unknown\"\n\n if (code >= 400 && code <= 499) return \"client\"\n if (code >= 500 && code <= 599) return \"server\"\n\n return \"unknown\"\n}\n\nexport function isErrorStatus(status: string): boolean {\n if (status === \"default\") return true\n const code = Number(status)\n if (!Number.isInteger(code)) return false\n return code >= 400\n}\n","import { topologicalSort, extractRefName } from \"./utils/topological-sort\"\nimport { formatPropertyName, isValidJSIdentifier } from \"./utils/property-name\"\nimport {\n getStatusCategory,\n isErrorStatus,\n mapStatusToIdentifier,\n} from \"./utils/http-status\"\nimport type { RequestMethod } from \"./types\"\n\nexport type OpenAPISpec = {\n openapi: string\n info: unknown\n paths: Record<string, Record<string, unknown>>\n components?: {\n schemas?: Record<string, unknown>\n parameters?: Record<string, unknown>\n }\n}\n\nexport type TypesHelperMode = \"package\" | \"inline\" | \"file\"\n\nexport type TypesConfig = {\n emit?: boolean\n helpers?: TypesHelperMode\n helpersOutput?: string\n}\n\nexport type GenerateOptions = {\n strictDates?: boolean\n strictNumeric?: boolean\n types?: TypesConfig\n}\n\nexport type GenerateResult = {\n output: string\n helperFile?: {\n path: string\n content: string\n }\n}\n\ntype PathParam = {\n name: string\n type: string\n}\n\ntype QueryParam = {\n name: string\n description?: string\n schema?: any\n required?: boolean\n}\n\ntype Operation = {\n operationId: string\n path: string\n method: RequestMethod\n pathParams: PathParam[]\n queryParams: QueryParam[]\n requestType?: string\n responseType?: string\n requestHeaders?: RequestHeader[]\n errors?: OperationErrorGroup\n}\ntype OperationErrorGroup = {\n clientErrors?: OperationErrorMap\n serverErrors?: OperationErrorMap\n defaultErrors?: OperationErrorMap\n otherErrors?: OperationErrorMap\n}\ntype OperationErrorMap = Record<string, string>\n\ntype RequestHeader = {\n name: string\n description?: string\n schema?: any\n required?: boolean\n}\n\n/**\n * Generate TypeScript source with additional metadata about helper files.\n *\n * @param spec - The OpenAPI specification to generate code from.\n * @param options - Generation options (e.g., strictDates, strictNumeric, types) that adjust emitted schemas and helper types.\n * @returns Object containing the generated output and optional helper file information.\n */\nexport function generateWithMetadata(\n spec: OpenAPISpec,\n options: GenerateOptions = {}\n): GenerateResult {\n const output: string[] = []\n const generatedTypes = new Set<string>()\n const { strictDates = false, strictNumeric = false } = options\n const typesConfig = normalizeTypesConfig(options.types)\n const schemaOptions: SchemaOptions = {\n strictDates,\n strictNumeric,\n }\n\n output.push('import { z } from \"zod\";')\n appendHelperTypesImport(output, typesConfig)\n output.push(\"\")\n\n // Generate Zod schemas from components/schemas\n if (spec.components?.schemas) {\n output.push(\"// Generated Zod Schemas\")\n output.push(\"\")\n\n // Sort schemas by dependencies (topological sort)\n const sortedSchemas = topologicalSort(spec.components.schemas)\n\n for (const name of sortedSchemas) {\n const schema = spec.components.schemas[name]\n output.push(\n generateZodSchema(name, schema, generatedTypes, schemaOptions)\n )\n output.push(\"\")\n // Export inferred type\n output.push(`export type ${name} = z.infer<typeof ${name}>;`)\n output.push(\"\")\n }\n }\n\n // Parse all operations\n const operations = parseOperations(spec)\n\n // Generate path functions\n output.push(\"// Path Functions\")\n output.push(\"export const paths = {\")\n\n for (const op of operations) {\n const pathParamNames = op.pathParams.map((p) => p.name)\n const hasPathParams = pathParamNames.length > 0\n const hasQueryParams = op.queryParams.length > 0\n const camelCaseOperationId = toCamelCase(op.operationId)\n\n if (!hasPathParams && !hasQueryParams) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: () => \"${op.path}\",`\n )\n continue\n }\n\n const allParamNames = [\n ...pathParamNames,\n ...op.queryParams.map((p) => p.name),\n ]\n const signaturePieces: string[] = []\n for (const param of op.pathParams) {\n signaturePieces.push(`${param.name}: string`)\n }\n for (const param of op.queryParams) {\n signaturePieces.push(\n `${param.name}${param.required ? \"\" : \"?\"}: ${mapQueryType(param)}`\n )\n }\n const signatureParams = signaturePieces.join(\", \")\n const needsDefaultObject =\n !hasPathParams &&\n hasQueryParams &&\n op.queryParams.every((param) => !param.required)\n const signatureArgs = allParamNames.length\n ? `{ ${allParamNames.join(\", \")} }`\n : \"{}\"\n const signature = `${signatureArgs}: { ${signatureParams} }${\n needsDefaultObject ? \" = {}\" : \"\"\n }`\n\n const pathWithParams = op.path.replace(/{([^}]+)}/g, \"${$1}\")\n\n if (!hasQueryParams) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: (${signature}) => \\`${pathWithParams}\\`,`\n )\n continue\n }\n\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: (${signature}) => {`\n )\n\n output.push(\" const params = new URLSearchParams()\")\n for (const param of op.queryParams) {\n const propertyKey = formatPropertyName(param.name)\n const accessor = isValidJSIdentifier(param.name)\n ? param.name\n : propertyKey\n const schema = param.schema ?? {}\n\n if (schema?.type === \"array\") {\n const itemValueExpression = convertQueryParamValue(\n schema.items ?? {},\n \"value\"\n )\n\n if (param.required) {\n output.push(` for (const value of ${accessor}) {`)\n output.push(\n ` params.append(\"${param.name}\", ${itemValueExpression})`\n )\n output.push(\" }\")\n } else {\n output.push(` if (${accessor} !== undefined) {`)\n output.push(` for (const value of ${accessor}) {`)\n output.push(\n ` params.append(\"${param.name}\", ${itemValueExpression})`\n )\n output.push(\" }\")\n output.push(\" }\")\n }\n\n continue\n }\n\n const valueExpression = convertQueryParamValue(schema, accessor)\n if (param.required) {\n output.push(` params.set(\"${param.name}\", ${valueExpression})`)\n } else {\n output.push(` if (${accessor} !== undefined) {`)\n output.push(` params.set(\"${param.name}\", ${valueExpression})`)\n output.push(\" }\")\n }\n }\n\n output.push(\" const _searchParams = params.toString()\")\n output.push(\n ` return \\`${pathWithParams}\\${_searchParams ? \\`?\\${_searchParams}\\` : \"\"}\\``\n )\n output.push(\" },\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n\n // Generate header schemas\n output.push(\"// Header Schemas\")\n output.push(\"export const headerSchemas = {\")\n\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n if (!op.requestHeaders || op.requestHeaders.length === 0) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: z.object({}),`\n )\n continue\n }\n\n const schemaFields = op.requestHeaders\n .map((header) => {\n const zodType = mapHeaderToZodType(header)\n const optional = header.required ? \"\" : \".optional()\"\n return ` ${formatPropertyName(header.name)}: ${zodType}${optional},`\n })\n .join(\"\\n\")\n\n output.push(` ${formatPropertyName(camelCaseOperationId)}: z.object({`)\n output.push(schemaFields)\n output.push(\" }),\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n\n // Generate header functions using Zod schemas\n output.push(\"// Header Functions\")\n output.push(\"export const headers = {\")\n\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n if (!op.requestHeaders || op.requestHeaders.length === 0) {\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: () => ${\n isValidJSIdentifier(camelCaseOperationId)\n ? `headerSchemas.${camelCaseOperationId}`\n : `headerSchemas[${formatPropertyName(camelCaseOperationId)}]`\n }.parse({}),`\n )\n continue\n }\n\n output.push(\n ` ${formatPropertyName(camelCaseOperationId)}: (params: z.input<${\n isValidJSIdentifier(camelCaseOperationId)\n ? `typeof headerSchemas.${camelCaseOperationId}`\n : `(typeof headerSchemas)[${formatPropertyName(camelCaseOperationId)}]`\n }>) => {`\n )\n output.push(\n ` return ${\n isValidJSIdentifier(camelCaseOperationId)\n ? `headerSchemas.${camelCaseOperationId}`\n : `headerSchemas[${formatPropertyName(camelCaseOperationId)}]`\n }.parse(params)`\n )\n output.push(\" },\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n\n // Generate operation types first (needed for type annotations)\n generateOperationTypes(output, operations, typesConfig)\n\n // Generate operation objects\n output.push(\"// Operation Objects\")\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n const typeAnnotation = typesConfig.emit\n ? `: ${capitalize(camelCaseOperationId)}Operation`\n : \"\"\n output.push(`export const ${camelCaseOperationId}${typeAnnotation} = {`)\n output.push(` method: \"${op.method}\",`)\n output.push(` path: paths.${camelCaseOperationId},`)\n\n appendOperationField(output, \"request\", op.requestType)\n appendOperationField(output, \"response\", op.responseType)\n\n if (op.requestHeaders && op.requestHeaders.length > 0) {\n output.push(` headers: headers.${camelCaseOperationId},`)\n }\n\n if (op.errors && hasAnyErrors(op.errors)) {\n output.push(\" errors: {\")\n appendErrorGroup(output, \"clientErrors\", op.errors.clientErrors)\n appendErrorGroup(output, \"serverErrors\", op.errors.serverErrors)\n appendErrorGroup(output, \"defaultErrors\", op.errors.defaultErrors)\n appendErrorGroup(output, \"otherErrors\", op.errors.otherErrors)\n output.push(\" },\")\n }\n\n output.push(\"} as const;\")\n output.push(\"\")\n }\n\n const result: GenerateResult = {\n output: output.join(\"\\n\"),\n }\n\n // If using file-based helpers, include helper file information\n if (\n typesConfig.emit &&\n typesConfig.helpers === \"file\" &&\n typesConfig.helpersOutput\n ) {\n result.helperFile = {\n path: typesConfig.helpersOutput,\n content: generateHelperFile(),\n }\n }\n\n return result\n}\n\n/**\n * Generate TypeScript source that contains Zod schemas, path/header helpers, and operation objects/types from an OpenAPI spec.\n *\n * @param spec - The OpenAPI specification to generate code from.\n * @param options - Generation options (e.g., strictDates, strictNumeric, types) that adjust emitted schemas and helper types.\n * @returns The complete generated TypeScript source as a single string.\n */\nexport function generate(\n spec: OpenAPISpec,\n options: GenerateOptions = {}\n): string {\n return generateWithMetadata(spec, options).output\n}\n\nfunction appendOperationField(\n buffer: string[],\n key: string,\n value?: string\n): void {\n if (!value) return\n buffer.push(` ${key}: ${value},`)\n}\n\nfunction appendErrorGroup(\n buffer: string[],\n label: string,\n errors?: OperationErrorMap\n): void {\n if (!errors || Object.keys(errors).length === 0) return\n buffer.push(` ${label}: {`)\n for (const [name, typeName] of Object.entries(errors)) {\n buffer.push(` ${formatPropertyName(name)}: ${typeName},`)\n }\n buffer.push(\" },\")\n}\n\n/**\n * Determines whether any error bucket in an operation error group contains entries.\n *\n * @param group - The operation error group to inspect (client, server, default, other buckets)\n * @returns `true` if at least one bucket has one or more entries, `false` otherwise.\n */\nfunction hasAnyErrors(group: OperationErrorGroup): boolean {\n return [\n group.clientErrors,\n group.serverErrors,\n group.defaultErrors,\n group.otherErrors,\n ].some((bucket) => bucket && Object.keys(bucket).length > 0)\n}\n\n/**\n * Determines whether a given string is one of the supported HTTP request methods.\n *\n * @param method - The HTTP method name to check (expected in lowercase).\n * @returns `true` if `method` is one of `\"get\"`, `\"put\"`, `\"post\"`, `\"delete\"`, `\"options\"`, `\"head\"`, `\"patch\"`, or `\"trace\"`, `false` otherwise.\n */\nfunction isRequestMethod(method: string): method is RequestMethod {\n switch (method) {\n case \"get\":\n case \"put\":\n case \"post\":\n case \"delete\":\n case \"options\":\n case \"head\":\n case \"patch\":\n case \"trace\":\n return true\n default:\n return false\n }\n}\n\n/**\n * Content-type priority mapping for response type inference.\n */\nconst CONTENT_TYPE_MAP: Record<string, string> = {\n \"application/json\": \"unknown\", // Will use schema when available\n \"text/csv\": \"string\",\n \"text/plain\": \"string\",\n // Binary/ambiguous types default to unknown for cross-platform compatibility\n \"application/octet-stream\": \"unknown\",\n \"application/pdf\": \"unknown\",\n}\n\n/**\n * Finds the most appropriate content type from available options.\n * Prefers JSON first, then uses content-type mapping, otherwise takes first available.\n */\nfunction findContentType(content: Record<string, any>): string {\n const contentTypes = Object.keys(content)\n\n // Prefer JSON\n if (contentTypes.includes(\"application/json\")) {\n return \"application/json\"\n }\n\n // Use first content type that has a mapping\n for (const contentType of contentTypes) {\n if (contentType in CONTENT_TYPE_MAP) {\n return contentType\n }\n }\n\n // Default to first available\n return contentTypes[0] || \"\"\n}\n\n/**\n * Infers the TypeScript type for a response based on content type and status code.\n */\nfunction inferResponseType(\n contentType: string,\n statusCode: string\n): string | undefined {\n // Handle NoContent and redirects\n if (statusCode === \"204\" || /^3\\d\\d$/.test(statusCode)) {\n return \"undefined\"\n }\n\n // Use content-type mapping\n if (contentType in CONTENT_TYPE_MAP) {\n return CONTENT_TYPE_MAP[contentType]\n }\n\n // Default to unknown for unrecognized types\n return \"unknown\"\n}\n\n/**\n * Collects operation metadata from an OpenAPI spec for operations that declare an `operationId` and use a supported HTTP method.\n *\n * @param spec - The OpenAPI specification to parse.\n * @returns An array of Operation objects describing each discovered operation (operationId, path, lowercase `method`, path and query parameters, request/response type names, request headers, and categorized errors).\n */\nfunction parseOperations(spec: OpenAPISpec): Operation[] {\n const operations: Operation[] = []\n\n for (const [path, pathItem] of Object.entries(spec.paths)) {\n for (const [method, operation] of Object.entries(pathItem)) {\n const normalizedMethod = method.toLowerCase()\n if (!isRequestMethod(normalizedMethod)) continue\n if (!(operation as any).operationId) continue\n\n const pathParams = extractPathParams(path)\n const requestType = getRequestType(operation)\n const { successResponse, errors } = getResponseTypes(\n operation,\n (operation as any).operationId\n )\n const resolvedParameters = collectParameters(pathItem, operation, spec)\n const requestHeaders = getRequestHeaders(resolvedParameters)\n const queryParams = getQueryParams(resolvedParameters)\n\n operations.push({\n operationId: (operation as any).operationId,\n path,\n method: normalizedMethod,\n pathParams,\n queryParams,\n requestType,\n responseType: successResponse,\n requestHeaders,\n errors,\n })\n }\n }\n\n return operations\n}\n\nfunction normalizeTypesConfig(\n config: TypesConfig | undefined\n): NormalizedTypesConfig {\n return {\n emit: config?.emit ?? true,\n helpers: config?.helpers ?? \"package\",\n helpersOutput: config?.helpersOutput ?? \"./zenko-types\",\n }\n}\n\ntype NormalizedTypesConfig = {\n emit: boolean\n helpers: TypesHelperMode\n helpersOutput: string\n}\n\n/**\n * Appends helper type import or inline type declarations to the output buffer according to the types configuration.\n *\n * @param buffer - The output string buffer to which import lines or inline type declarations will be appended.\n * @param config - Normalized types configuration that controls whether to emit helpers and which helper mode to use (`package`, `file`, or `inline`). When `config.emit` is false no content is appended.\n */\nfunction appendHelperTypesImport(\n buffer: string[],\n config: NormalizedTypesConfig\n) {\n if (!config.emit) return\n\n switch (config.helpers) {\n case \"package\":\n buffer.push(\n 'import type { PathFn, HeaderFn, OperationDefinition, OperationErrors } from \"zenko\";'\n )\n return\n case \"file\":\n buffer.push(\n `import type { PathFn, HeaderFn, OperationDefinition, OperationErrors } from \"${config.helpersOutput}\";`\n )\n return\n case \"inline\":\n buffer.push(\n \"type PathFn<TArgs extends unknown[] = []> = (...args: TArgs) => string;\"\n )\n buffer.push(\n 'type RequestMethod = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\";'\n )\n buffer.push(\n \"type HeaderFn<TArgs extends unknown[] = [], TResult = Record<string, unknown> | Record<string, never>> = (...args: TArgs) => TResult;\"\n )\n buffer.push(\n \"type AnyHeaderFn = HeaderFn<any, unknown> | (() => unknown);\"\n )\n buffer.push(\n \"type OperationErrors<TClient = unknown, TServer = unknown, TDefault = unknown, TOther = unknown> = {\"\n )\n buffer.push(\" clientErrors?: TClient;\")\n buffer.push(\" serverErrors?: TServer;\")\n buffer.push(\" defaultErrors?: TDefault;\")\n buffer.push(\" otherErrors?: TOther;\")\n buffer.push(\"};\")\n buffer.push(\n \"type OperationDefinition<TMethod extends RequestMethod, TPath extends (...args: any[]) => string, TRequest = undefined, TResponse = undefined, THeaders extends AnyHeaderFn | undefined = undefined, TErrors extends OperationErrors | undefined = undefined> = {\"\n )\n buffer.push(\" method: TMethod;\")\n buffer.push(\" path: TPath;\")\n buffer.push(\" request?: TRequest;\")\n buffer.push(\" response?: TResponse;\")\n buffer.push(\" headers?: THeaders;\")\n buffer.push(\" errors?: TErrors;\")\n buffer.push(\"};\")\n return\n }\n}\n\n/**\n * Appends TypeScript operation type definitions to the output buffer.\n *\n * For each operation, emits an `export type <OperationId>Operation = OperationDefinition<...>` declaration\n * (including the HTTP method literal, path fn, request/response types, headers type, and errors type)\n * into the provided `buffer` when `config.emit` is true.\n *\n * @param buffer - Mutable array of output lines to append the generated type declarations to\n * @param operations - Array of operations to generate operation-type exports for\n * @param config - Normalized types configuration; generation is skipped when `config.emit` is false\n */\nfunction generateOperationTypes(\n buffer: string[],\n operations: Operation[],\n config: NormalizedTypesConfig\n) {\n if (!config.emit) return\n\n buffer.push(\"// Operation Types\")\n\n for (const op of operations) {\n const camelCaseOperationId = toCamelCase(op.operationId)\n const headerType = op.requestHeaders?.length\n ? isValidJSIdentifier(camelCaseOperationId)\n ? `typeof headers.${camelCaseOperationId}`\n : `(typeof headers)[${formatPropertyName(camelCaseOperationId)}]`\n : \"undefined\"\n const requestType = wrapTypeReference(op.requestType)\n const responseType = wrapTypeReference(op.responseType)\n const errorsType = buildOperationErrorsType(op.errors)\n\n buffer.push(\n `export type ${capitalize(camelCaseOperationId)}Operation = OperationDefinition<`\n )\n buffer.push(` \"${op.method}\",`)\n buffer.push(\n ` ${isValidJSIdentifier(camelCaseOperationId) ? `typeof paths.${camelCaseOperationId}` : `(typeof paths)[${formatPropertyName(camelCaseOperationId)}]`},`\n )\n buffer.push(` ${requestType},`)\n buffer.push(` ${responseType},`)\n buffer.push(` ${headerType},`)\n buffer.push(` ${errorsType}`)\n buffer.push(`>;`)\n buffer.push(\"\")\n }\n}\n\nfunction buildOperationErrorsType(errors?: OperationErrorGroup): string {\n if (!errors || !hasAnyErrors(errors)) {\n return \"OperationErrors\"\n }\n\n const client = buildErrorBucket(errors.clientErrors)\n const server = buildErrorBucket(errors.serverErrors)\n const fallback = buildErrorBucket(errors.defaultErrors)\n const other = buildErrorBucket(errors.otherErrors)\n\n return `OperationErrors<${client}, ${server}, ${fallback}, ${other}>`\n}\n\nfunction buildErrorBucket(bucket?: OperationErrorMap): string {\n if (!bucket || Object.keys(bucket).length === 0) {\n return \"unknown\"\n }\n\n const entries = Object.entries(bucket)\n const accessibleEntries = entries.map(([name, type]) => {\n const propertyKey = formatPropertyName(name)\n const valueType = wrapErrorValueType(type)\n return `${propertyKey}: ${valueType}`\n })\n\n return `{ ${accessibleEntries.join(\"; \")} }`\n}\n\nconst TYPE_KEYWORDS = new Set([\n \"any\",\n \"unknown\",\n \"never\",\n \"void\",\n \"null\",\n \"undefined\",\n \"string\",\n \"number\",\n \"boolean\",\n \"bigint\",\n \"symbol\",\n])\nconst IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/\n\nfunction wrapTypeReference(typeName?: string): string {\n if (!typeName) return \"undefined\"\n const normalized = typeName.trim()\n if (normalized === \"undefined\") return \"undefined\"\n if (TYPE_KEYWORDS.has(normalized)) return normalized\n if (normalized.startsWith(\"typeof \")) return normalized\n\n const arrayMatch = normalized.match(/^z\\.array\\((.+)\\)$/)\n if (arrayMatch) {\n return `z.ZodArray<${wrapTypeReference(arrayMatch[1])}>`\n }\n\n if (IDENTIFIER_PATTERN.test(normalized)) {\n return `typeof ${normalized}`\n }\n\n return normalized\n}\n\nfunction wrapErrorValueType(typeName?: string): string {\n if (!typeName) return \"unknown\"\n const normalized = typeName.trim()\n if (TYPE_KEYWORDS.has(normalized)) return normalized\n if (normalized.startsWith(\"typeof \")) return normalized\n\n const arrayMatch = normalized.match(/^z\\.array\\((.+)\\)$/)\n if (arrayMatch) {\n return `z.ZodArray<${wrapErrorValueType(arrayMatch[1])}>`\n }\n\n if (IDENTIFIER_PATTERN.test(normalized)) {\n return `typeof ${normalized}`\n }\n return normalized\n}\n\nfunction collectParameters(\n pathItem: Record<string, unknown>,\n operation: unknown,\n spec: OpenAPISpec\n): any[] {\n const parametersMap = new Map<string, any>()\n\n const addParameters = (params: unknown) => {\n if (!Array.isArray(params)) return\n\n for (const param of params) {\n const resolved = resolveParameter(param, spec)\n if (!resolved) continue\n const key = `${resolved.in}:${resolved.name}`\n parametersMap.set(key, resolved)\n }\n }\n\n addParameters((pathItem as any).parameters)\n addParameters((operation as any).parameters)\n\n return Array.from(parametersMap.values())\n}\n\nfunction resolveParameter(parameter: any, spec: OpenAPISpec) {\n if (!parameter) return undefined\n\n if (parameter.$ref) {\n const refName = extractRefName(parameter.$ref)\n const resolved = spec.components?.parameters?.[refName]\n if (!resolved) return undefined\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $ref, ...overrides } = parameter\n return {\n ...resolved,\n ...overrides,\n }\n }\n\n return parameter\n}\n\nfunction extractPathParams(path: string): PathParam[] {\n const params: PathParam[] = []\n const matches = path.match(/{([^}]+)}/g)\n\n if (matches) {\n for (const match of matches) {\n const paramName = match.slice(1, -1)\n params.push({\n name: paramName,\n type: \"string\", // OpenAPI path params are always strings\n })\n }\n }\n\n return params\n}\n\nfunction getRequestType(operation: any): string | undefined {\n const requestBody =\n operation.requestBody?.content?.[\"application/json\"]?.schema\n if (!requestBody) return undefined\n\n if (requestBody.$ref) {\n return extractRefName(requestBody.$ref)\n }\n\n // Generate inline type if needed\n const typeName = `${capitalize(operation.operationId)}Request`\n return typeName\n}\n\n/**\n * Resolves success and error response typings for an operation.\n *\n * @param operation - The OpenAPI operation node to inspect.\n * @param operationId - The operation identifier used for synthesized names.\n * @returns The preferred success response type and categorized error groups.\n */\nfunction getResponseTypes(\n operation: any,\n operationId: string\n): {\n successResponse?: string\n errors?: OperationErrorGroup\n} {\n const responses = operation.responses ?? {}\n const successCodes = new Map<string, string>()\n const errorEntries: Array<{ code: string; schema: any }> = []\n\n for (const [statusCode, response] of Object.entries(responses)) {\n // Handle content types\n const content = (response as any)?.content\n if (!content || Object.keys(content).length === 0) {\n // No content - handle based on status code\n if (statusCode === \"204\" || /^3\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, \"undefined\")\n } else if (isErrorStatus(statusCode)) {\n // Include error responses even without content\n errorEntries.push({\n code: statusCode,\n schema: \"undefined\",\n })\n }\n continue\n }\n\n // Find the appropriate content type\n const contentType = findContentType(content)\n const resolvedSchema = content[contentType]?.schema\n\n if (!resolvedSchema) {\n // No schema - infer from content type\n const inferredType = inferResponseType(contentType, statusCode)\n if (inferredType) {\n if (isErrorStatus(statusCode)) {\n errorEntries.push({\n code: statusCode,\n schema: inferredType,\n })\n } else if (/^2\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, inferredType)\n }\n }\n continue\n }\n\n if (isErrorStatus(statusCode)) {\n errorEntries.push({ code: statusCode, schema: resolvedSchema })\n continue\n }\n\n if (/^2\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, resolvedSchema)\n }\n }\n\n const successResponse = selectSuccessResponse(successCodes, operationId)\n const errors = buildErrorGroups(errorEntries, operationId)\n\n return { successResponse, errors }\n}\n\n/**\n * Picks the most representative success response type from available candidates.\n *\n * Prefers 200/201/204 responses, falling back to the first declared status code.\n * When a schema is provided as a literal type string the literal is returned\n * directly; otherwise a synthetic type name is generated via `resolveResponseType`.\n *\n * @param responses - Map of status codes to resolved schemas or inferred literals.\n * @param operationId - Operation identifier used to construct synthetic names.\n * @returns The chosen TypeScript type name, or `undefined` when no success response exists.\n */\nfunction selectSuccessResponse(\n responses: Map<string, any>,\n operationId: string\n): string | undefined {\n if (responses.size === 0) return undefined\n\n const preferredOrder = [\"200\", \"201\", \"204\"]\n for (const code of preferredOrder) {\n const schema = responses.get(code)\n if (schema) {\n if (typeof schema === \"string\") {\n // Direct type (e.g., \"undefined\", \"string\", \"unknown\")\n return schema\n }\n return resolveResponseType(\n schema,\n `${capitalize(operationId)}Response${code}`\n )\n }\n }\n\n const [firstCode, firstSchema] = responses.entries().next().value ?? []\n if (!firstSchema) return undefined\n\n if (typeof firstSchema === \"string\") {\n return firstSchema\n }\n\n return resolveResponseType(\n firstSchema,\n `${capitalize(operationId)}Response${firstCode ?? \"Default\"}`\n )\n}\n\n/**\n * Buckets error responses by status-class and maps them to concrete type names.\n *\n * @param errors - Collection of HTTP status codes paired with schemas or literals.\n * @param operationId - Operation identifier used when synthesizing fallback names.\n * @returns Structured error groups keyed by client/server/default/other categories.\n */\nfunction buildErrorGroups(\n errors: Array<{ code: string; schema: any }> = [],\n operationId: string\n): OperationErrorGroup | undefined {\n if (!errors.length) return undefined\n\n const group: OperationErrorGroup = {}\n\n for (const { code, schema } of errors) {\n const category = getStatusCategory(code)\n const identifier = mapStatusToIdentifier(code)\n const typeName = resolveResponseType(\n schema,\n `${capitalize(operationId)}${capitalize(identifier)}`\n )\n\n switch (category) {\n case \"client\":\n group.clientErrors ??= {}\n group.clientErrors[identifier] = typeName\n break\n case \"server\":\n group.serverErrors ??= {}\n group.serverErrors[identifier] = typeName\n break\n case \"default\":\n group.defaultErrors ??= {}\n group.defaultErrors[identifier] = typeName\n break\n default:\n group.otherErrors ??= {}\n group.otherErrors[identifier] = typeName\n break\n }\n }\n\n return group\n}\n\n/**\n * Resolves the emitted TypeScript identifier for a response schema.\n *\n * @param schema - Schema object or inferred literal type returned by inference.\n * @param fallbackName - Synthetic name to use when the schema lacks a `$ref`.\n * @returns Reference name, literal type, or the provided fallback.\n */\nfunction resolveResponseType(schema: any, fallbackName: string): string {\n if (typeof schema === \"string\") {\n return schema\n }\n if (schema.$ref) {\n return extractRefName(schema.$ref)\n }\n // Handle array schemas with $ref items\n if (schema.type === \"array\" && schema.items?.$ref) {\n const itemRef = extractRefName(schema.items.$ref)\n return `z.array(${itemRef})`\n }\n return fallbackName\n}\n\nfunction getRequestHeaders(parameters: any[]): RequestHeader[] {\n const headers: RequestHeader[] = []\n\n for (const param of parameters ?? []) {\n if ((param as any).in === \"header\") {\n headers.push({\n name: (param as any).name,\n description: (param as any).description,\n schema: (param as any).schema,\n required: (param as any).required,\n })\n }\n }\n\n return headers\n}\n\nfunction getQueryParams(parameters: any[]): QueryParam[] {\n const queryParams: QueryParam[] = []\n\n for (const param of parameters ?? []) {\n if ((param as any).in === \"query\") {\n queryParams.push({\n name: (param as any).name,\n description: (param as any).description,\n schema: (param as any).schema,\n required: (param as any).required,\n })\n }\n }\n\n return queryParams\n}\n\nfunction mapHeaderToZodType(header: RequestHeader): string {\n const schema = header.schema ?? {}\n const schemaType = schema.type\n switch (schemaType) {\n case \"integer\":\n case \"number\":\n // Accept numeric header values provided as strings\n return \"z.coerce.number()\"\n case \"boolean\":\n // Accept boolean header values provided as strings\n return \"z.coerce.boolean()\"\n case \"array\": {\n const items = schema.items ?? { type: \"string\" }\n const itemType =\n items.type === \"integer\" || items.type === \"number\"\n ? \"z.coerce.number()\"\n : items.type === \"boolean\"\n ? \"z.coerce.boolean()\"\n : \"z.string()\"\n return `z.array(${itemType})`\n }\n default:\n return \"z.string()\"\n }\n}\n\nfunction mapQueryType(param: QueryParam): string {\n return mapQuerySchemaType(param.schema)\n}\n\nfunction mapQuerySchemaType(schema: any): string {\n if (!schema) return \"string\"\n\n if (schema.type === \"array\") {\n const itemType = mapQuerySchemaType(schema.items)\n return `Array<${itemType}>`\n }\n\n switch (schema.type) {\n case \"integer\":\n case \"number\":\n return \"number\"\n case \"boolean\":\n return \"boolean\"\n default:\n return \"string\"\n }\n}\n\nfunction convertQueryParamValue(schema: any, accessor: string): string {\n if (!schema) {\n return `String(${accessor})`\n }\n\n switch (schema.type) {\n case \"integer\":\n case \"number\":\n return `String(${accessor})`\n case \"boolean\":\n return `${accessor} ? \"true\" : \"false\"`\n default:\n return `String(${accessor})`\n }\n}\n\ntype SchemaOptions = {\n strictDates: boolean\n strictNumeric: boolean\n}\n\nfunction generateZodSchema(\n name: string,\n schema: any,\n generatedTypes: Set<string>,\n options: SchemaOptions\n): string {\n if (generatedTypes.has(name)) return \"\"\n generatedTypes.add(name)\n\n if (schema.enum) {\n const enumValues = schema.enum.map((v: string) => `\"${v}\"`).join(\", \")\n return `export const ${name} = z.enum([${enumValues}]);`\n }\n\n if (schema.type === \"object\" || schema.properties) {\n return `export const ${name} = ${buildZodObject(schema, options)};`\n }\n\n if (schema.type === \"array\") {\n const itemSchema = schema.items ?? { type: \"unknown\" }\n const itemType = getZodTypeFromSchema(itemSchema, options)\n const builder = applyStrictArrayBounds(\n schema,\n `z.array(${itemType})`,\n itemSchema,\n options.strictNumeric\n )\n return `export const ${name} = ${builder};`\n }\n\n return `export const ${name} = ${getZodTypeFromSchema(schema, options)};`\n}\n\nfunction getZodTypeFromSchema(schema: any, options: SchemaOptions): string {\n if (schema.$ref) {\n return extractRefName(schema.$ref)\n }\n\n if (schema.enum) {\n const enumValues = schema.enum.map((v: string) => `\"${v}\"`).join(\", \")\n return `z.enum([${enumValues}])`\n }\n\n if (schema.type === \"object\" || schema.properties) {\n return buildZodObject(schema, options)\n }\n\n switch (schema.type) {\n case \"string\":\n return buildString(schema, options)\n case \"boolean\":\n return \"z.boolean()\"\n case \"array\":\n return `z.array(${getZodTypeFromSchema(\n schema.items ?? { type: \"unknown\" },\n options\n )})`\n case \"null\":\n return \"z.null()\"\n case \"number\":\n return buildNumber(schema, options)\n case \"integer\":\n return buildInteger(schema, options)\n default:\n return \"z.unknown()\"\n }\n}\n\nfunction buildZodObject(schema: any, options: SchemaOptions): string {\n const properties: string[] = []\n\n for (const [propName, propSchema] of Object.entries(\n schema.properties || {}\n )) {\n const isRequired = schema.required?.includes(propName) ?? false\n const zodType = getZodTypeFromSchema(propSchema as any, options)\n const finalType = isRequired ? zodType : `${zodType}.optional()`\n properties.push(` ${formatPropertyName(propName)}: ${finalType},`)\n }\n\n if (properties.length === 0) {\n return \"z.object({})\"\n }\n\n return `z.object({\\n${properties.join(\"\\n\")}\\n})`\n}\n\nfunction buildString(schema: any, options: SchemaOptions): string {\n if (options.strictDates) {\n switch (schema.format) {\n case \"date-time\":\n return \"z.string().datetime()\"\n case \"date\":\n return \"z.string().date()\"\n case \"time\":\n return \"z.string().time()\"\n case \"duration\":\n return \"z.string().duration()\"\n }\n }\n\n let builder = \"z.string()\"\n\n if (options.strictNumeric) {\n if (typeof schema.minLength === \"number\") {\n builder += `.min(${schema.minLength})`\n }\n\n if (typeof schema.maxLength === \"number\") {\n builder += `.max(${schema.maxLength})`\n }\n\n if (schema.pattern) {\n builder += `.regex(new RegExp(${JSON.stringify(schema.pattern)}))`\n }\n }\n\n switch (schema.format) {\n case \"uuid\":\n return `${builder}.uuid()`\n case \"email\":\n return `${builder}.email()`\n case \"uri\":\n case \"url\":\n return `${builder}.url()`\n case \"ipv4\":\n return `${builder}.ip({ version: \"v4\" })`\n case \"ipv6\":\n return `${builder}.ip({ version: \"v6\" })`\n default:\n return builder\n }\n}\n\nfunction buildNumber(schema: any, options: SchemaOptions): string {\n let builder = \"z.number()\"\n\n if (options.strictNumeric) {\n builder = applyNumericBounds(schema, builder)\n\n if (typeof schema.multipleOf === \"number\" && schema.multipleOf !== 0) {\n builder += `.refine((value) => Math.abs(value / ${schema.multipleOf} - Math.round(value / ${schema.multipleOf})) < Number.EPSILON, { message: \"Must be a multiple of ${schema.multipleOf}\" })`\n }\n }\n\n return builder\n}\n\nfunction buildInteger(schema: any, options: SchemaOptions): string {\n let builder = buildNumber(schema, options)\n builder += \".int()\"\n return builder\n}\n\nfunction applyStrictArrayBounds(\n schema: any,\n builder: string,\n itemSchema: any,\n enforceBounds: boolean\n): string {\n if (!enforceBounds) {\n return builder\n }\n\n if (typeof schema.minItems === \"number\") {\n builder += `.min(${schema.minItems})`\n }\n\n if (typeof schema.maxItems === \"number\") {\n builder += `.max(${schema.maxItems})`\n }\n\n if (schema.uniqueItems && isPrimitiveLike(itemSchema)) {\n builder +=\n '.refine((items) => new Set(items).size === items.length, { message: \"Items must be unique\" })'\n }\n\n return builder\n}\n\nfunction isPrimitiveLike(schema: any): boolean {\n if (schema?.$ref) return false\n\n const primitiveTypes = new Set([\"string\", \"number\", \"integer\", \"boolean\"])\n return primitiveTypes.has(schema?.type)\n}\n\nfunction applyNumericBounds(schema: any, builder: string): string {\n if (typeof schema.minimum === \"number\") {\n if (schema.exclusiveMinimum === true) {\n builder += `.gt(${schema.minimum})`\n } else {\n builder += `.min(${schema.minimum})`\n }\n } else if (typeof schema.exclusiveMinimum === \"number\") {\n builder += `.gt(${schema.exclusiveMinimum})`\n }\n\n if (typeof schema.maximum === \"number\") {\n if (schema.exclusiveMaximum === true) {\n builder += `.lt(${schema.maximum})`\n } else {\n builder += `.max(${schema.maximum})`\n }\n } else if (typeof schema.exclusiveMaximum === \"number\") {\n builder += `.lt(${schema.exclusiveMaximum})`\n }\n\n return builder\n}\n\n/**\n * Generate a standalone helper types file for use with `helpers: \"file\"` mode.\n *\n * @returns TypeScript source containing PathFn, HeaderFn, OperationDefinition, and OperationErrors type definitions.\n */\nexport function generateHelperFile(): string {\n const output: string[] = []\n\n output.push(\"// Generated helper types for Zenko\")\n output.push(\n \"// This file provides type definitions for operation objects and path functions\"\n )\n output.push(\"\")\n output.push(\n \"export type PathFn<TArgs extends unknown[] = []> = (...args: TArgs) => string\"\n )\n output.push(\"\")\n output.push(\n 'export type RequestMethod = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"'\n )\n output.push(\"\")\n output.push(\n \"export type HeaderFn<TArgs extends unknown[] = [], TResult = Record<string, unknown> | Record<string, never>> = (...args: TArgs) => TResult\"\n )\n output.push(\"\")\n output.push(\n \"export type AnyHeaderFn = HeaderFn<any, unknown> | (() => unknown)\"\n )\n output.push(\"\")\n output.push(\n \"export type OperationErrors<TClient = unknown, TServer = unknown, TDefault = unknown, TOther = unknown> = {\"\n )\n output.push(\" clientErrors?: TClient\")\n output.push(\" serverErrors?: TServer\")\n output.push(\" defaultErrors?: TDefault\")\n output.push(\" otherErrors?: TOther\")\n output.push(\"}\")\n output.push(\"\")\n output.push(\n \"export type OperationDefinition<TMethod extends RequestMethod, TPath extends (...args: any[]) => string, TRequest = undefined, TResponse = undefined, THeaders extends AnyHeaderFn | undefined = undefined, TErrors extends OperationErrors | undefined = undefined> = {\"\n )\n output.push(\" method: TMethod\")\n output.push(\" path: TPath\")\n output.push(\" request?: TRequest\")\n output.push(\" response?: TResponse\")\n output.push(\" headers?: THeaders\")\n output.push(\" errors?: TErrors\")\n output.push(\"}\")\n output.push(\"\")\n\n return output.join(\"\\n\")\n}\n\nfunction toCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\nfunction capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAoB;AACpB,WAAsB;AACtB,iBAA8B;AAC9B,qBAAqB;;;ACLd,SAAS,gBAAgB,SAAwC;AACtE,QAAM,UAAU,oBAAI,IAAY;AAChC,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,SAAmB,CAAC;AAE1B,QAAM,QAAQ,CAAC,SAAuB;AACpC,QAAI,QAAQ,IAAI,IAAI,EAAG;AACvB,QAAI,SAAS,IAAI,IAAI,GAAG;AAEtB;AAAA,IACF;AAEA,aAAS,IAAI,IAAI;AAGjB,UAAM,SAAS,QAAQ,IAAI;AAC3B,UAAM,eAAe,oBAAoB,MAAM;AAG/C,eAAW,OAA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B,OAAO,MAAM;AAE9C,UAAQ,IAAI,wCAAmC,cAAc,EAAE;AAC/D,UAAQ,IAAI,uBAAgB,OAAO,KAAK,KAAK,KAAK,EAAE,MAAM,QAAQ;AAGlE,MAAI,OAAO,YAAY;AACrB,UAAM,aAAkB,gBAAW,OAAO,WAAW,IAAI,IACrD,OAAO,WAAW,OACb,aAAa,aAAQ,cAAc,GAAG,OAAO,WAAW,IAAI;AAGrE,UAAM,yBAA8B,aAAQ,cAAc;AAC1D,UAAM,qBAA0B,aAAQ,UAAU;AAGlD,QAAI,2BAA2B,oBAAoB;AACjD,cAAQ;AAAA,QACN,iFAAuE,sBAAsB;AAAA,MAC/F;AACA;AAAA,IACF;AAEA,IAAG,aAAe,aAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AAC1D,IAAG,iBAAc,YAAY,OAAO,WAAW,SAAS;AAAA,MACtD,UAAU;AAAA,IACZ,CAAC;AAED,YAAQ,IAAI,uCAAgC,UAAU,EAAE;AAAA,EAC1D;AACF;AAEA,SAAS,SAAS,UAA+B;AAC/C,MAAI,CAAI,cAAW,QAAQ,GAAG;AAC5B,UAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AAAA,EACrD;AAEA,QAAM,UAAa,gBAAa,UAAU,MAAM;AAEhD,MAAI,SAAS,SAAS,OAAO,KAAK,SAAS,SAAS,MAAM,GAAG;AAC3D,eAAO,qBAAK,OAAO;AAAA,EACrB;AAEA,SAAO,KAAK,MAAM,OAAO;AAC3B;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,iBAAY,KAAK;AAC/B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["path","module"]}
|
package/dist/cli.mjs
CHANGED
|
@@ -362,10 +362,12 @@ function generateWithMetadata(spec, options = {}) {
|
|
|
362
362
|
}
|
|
363
363
|
output.push("} as const;");
|
|
364
364
|
output.push("");
|
|
365
|
+
generateOperationTypes(output, operations, typesConfig);
|
|
365
366
|
output.push("// Operation Objects");
|
|
366
367
|
for (const op of operations) {
|
|
367
368
|
const camelCaseOperationId = toCamelCase(op.operationId);
|
|
368
|
-
|
|
369
|
+
const typeAnnotation = typesConfig.emit ? `: ${capitalize(camelCaseOperationId)}Operation` : "";
|
|
370
|
+
output.push(`export const ${camelCaseOperationId}${typeAnnotation} = {`);
|
|
369
371
|
output.push(` method: "${op.method}",`);
|
|
370
372
|
output.push(` path: paths.${camelCaseOperationId},`);
|
|
371
373
|
appendOperationField(output, "request", op.requestType);
|
|
@@ -384,7 +386,6 @@ function generateWithMetadata(spec, options = {}) {
|
|
|
384
386
|
output.push("} as const;");
|
|
385
387
|
output.push("");
|
|
386
388
|
}
|
|
387
|
-
generateOperationTypes(output, operations, typesConfig);
|
|
388
389
|
const result = {
|
|
389
390
|
output: output.join("\n")
|
|
390
391
|
};
|