zenko 0.1.12 → 0.1.13
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/chunk-7VP5JZCL.cjs +8 -0
- package/dist/chunk-NZMYX32P.mjs +8 -0
- package/dist/cli.cjs +1 -1741
- package/dist/cli.mjs +1 -1718
- package/dist/index.cjs +1 -1535
- package/dist/index.mjs +1 -1508
- package/package.json +12 -4
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/topological-sort.ts","../src/utils/property-name.ts","../src/utils/string-utils.ts","../src/utils/tree-shaking.ts","../src/utils/schema-utils.ts","../src/utils/collect-referenced-schemas.ts","../src/core/schema-generator.ts","../src/utils/http-status.ts","../src/core/operation-parser.ts","../src/utils/collect-inline-types.ts","../src/generator/inline-types.ts","../src/utils/generate-helper-file.ts","../src/zenko.ts"],"sourcesContent":["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","/**\n * Converts a string with hyphens to camelCase.\n * Example: \"Links-Self\" -> \"LinksSelf\"\n */\nexport function toCamelCase(str: string): string {\n return str\n .replace(/-([a-zA-Z])/g, (_, letter) => letter.toUpperCase())\n .replace(/-+$/, \"\") // Remove trailing hyphens\n}\n\n/**\n * Capitalizes the first letter of a string.\n * Example: \"linksSelf\" -> \"LinksSelf\"\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n","import type { Operation, OperationErrorGroup } from \"../types/operation\"\n\nexport type ZenkoUsage = {\n usesHeaderFn: boolean\n usesOperationDefinition: boolean\n usesOperationErrors: boolean\n}\n\n/**\n * Analyzes operations to determine which Zenko types are actually used\n */\nexport function analyzeZenkoUsage(operations: Operation[]): ZenkoUsage {\n const usage: ZenkoUsage = {\n usesHeaderFn: false,\n usesOperationDefinition: false,\n usesOperationErrors: false,\n }\n\n // If there are any operations, OperationDefinition is always used\n if (operations.length > 0) {\n usage.usesOperationDefinition = true\n }\n\n for (const op of operations) {\n // PathFn is never used in package/file mode - only in inline helpers\n // So we never set usesPathFn to true here\n\n // HeaderFn is never used in package/file mode - the generated code uses\n // `typeof headers.xxx` which TypeScript can infer without needing HeaderFn\n // So we never set usesHeaderFn to true here\n\n // OperationErrors is used if there are any error responses\n // Note: Even if there are no explicit errors, the type might still be used\n // as a default in OperationDefinition, so we need to check if it's actually needed\n if (op.errors && hasAnyErrors(op.errors)) {\n usage.usesOperationErrors = true\n }\n }\n\n // Special case: if there are operations but no errors, OperationErrors is still used\n // as the default type in OperationDefinition\n if (operations.length > 0 && !usage.usesOperationErrors) {\n // Check if any operation has the default OperationErrors type\n const hasDefaultErrors = operations.some(\n (op) => !op.errors || !hasAnyErrors(op.errors)\n )\n if (hasDefaultErrors) {\n usage.usesOperationErrors = true\n }\n }\n\n return usage\n}\n\n/**\n * Generates the import statement based on usage analysis\n */\nexport function generateZenkoImport(\n usage: ZenkoUsage,\n mode: \"package\" | \"file\",\n helpersOutput?: string\n): string {\n const types: string[] = []\n\n // PathFn is never used in package/file mode - only in inline helpers\n if (usage.usesHeaderFn) types.push(\"HeaderFn\")\n if (usage.usesOperationDefinition) types.push(\"OperationDefinition\")\n if (usage.usesOperationErrors) types.push(\"OperationErrors\")\n\n // If no types are used, return empty string\n if (types.length === 0) {\n return \"\"\n }\n\n const importSource = mode === \"package\" ? '\"zenko\"' : `\"${helpersOutput}\"`\n return `import type { ${types.join(\", \")} } from ${importSource};`\n}\n\nfunction hasAnyErrors(errors: OperationErrorGroup): boolean {\n return Boolean(errors && Object.keys(errors).length > 0)\n}\n","import { extractRefName } from \"./topological-sort\"\nimport type { OpenAPISpec } from \"../zenko\"\n\n/**\n * Content-type priority mapping for response type inference.\n */\nexport const 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 *\n * @param content - Record of content types to their schemas\n * @returns The selected content type string\n */\nexport function 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 * Resolves a parameter reference to its actual definition.\n * If the parameter has a $ref, looks it up in components.parameters and merges any overrides.\n *\n * @param parameter - The parameter object (may contain $ref)\n * @param spec - The OpenAPI specification\n * @returns The resolved parameter or undefined if not found\n */\nexport function 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","import { extractRefName, extractDependencies } from \"./topological-sort\"\nimport { findContentType, resolveParameter } from \"./schema-utils\"\nimport type { Operation } from \"../types/operation\"\nimport type { OpenAPISpec } from \"../zenko\"\n\n/**\n * Collects all component schema names referenced by the given operations.\n * Traverses request/response types, parameters, headers, and errors, following $ref chains.\n *\n * @param operations - Processed operations to analyze\n * @param spec - The OpenAPI specification\n * @returns Set of original schema names that are referenced\n */\nexport function collectReferencedSchemas(\n operations: Operation[],\n spec: OpenAPISpec\n): Set<string> {\n const referenced = new Set<string>()\n\n // Build operation lookup from raw spec\n const operationLookup = new Map<string, any>()\n for (const [, pathItem] of Object.entries(spec.paths || {})) {\n for (const [, operation] of Object.entries(pathItem)) {\n const op = operation as any\n if (op.operationId) {\n operationLookup.set(op.operationId, op)\n }\n }\n }\n for (const [, pathItem] of Object.entries(spec.webhooks || {})) {\n for (const [, operation] of Object.entries(pathItem)) {\n const op = operation as any\n if (op.operationId) {\n operationLookup.set(op.operationId, op)\n }\n }\n }\n\n // Collect from operations and raw spec\n for (const op of operations) {\n const rawOperation = operationLookup.get(op.operationId)\n if (!rawOperation) continue\n\n // Request body schema\n const requestBody =\n rawOperation.requestBody?.content?.[\"application/json\"]?.schema\n if (requestBody?.$ref) {\n const refName = extractRefName(requestBody.$ref)\n referenced.add(refName)\n } else if (requestBody) {\n // Inline schema - extract dependencies\n const deps = extractDependencies(requestBody)\n for (const dep of deps) {\n if (spec.components?.schemas?.[dep]) {\n referenced.add(dep)\n }\n }\n }\n\n // Response schemas\n const responses = rawOperation.responses || {}\n for (const [, response] of Object.entries(responses)) {\n const content = (response as any)?.content\n if (!content) continue\n\n const contentType = findContentType(content)\n const responseSchema = content[contentType]?.schema\n if (responseSchema?.$ref) {\n const refName = extractRefName(responseSchema.$ref)\n referenced.add(refName)\n } else if (responseSchema) {\n // Inline schema - extract dependencies\n const deps = extractDependencies(responseSchema)\n for (const dep of deps) {\n if (spec.components?.schemas?.[dep]) {\n referenced.add(dep)\n }\n }\n }\n }\n\n // Query params (from processed operation)\n for (const param of op.queryParams) {\n if (param.schema?.$ref) {\n const refName = extractRefName(param.schema.$ref)\n referenced.add(refName)\n }\n // Also check array items\n if (param.schema?.items?.$ref) {\n const refName = extractRefName(param.schema.items.$ref)\n referenced.add(refName)\n }\n }\n\n // Request headers (from processed operation)\n for (const header of op.requestHeaders || []) {\n if (header.schema?.$ref) {\n const refName = extractRefName(header.schema.$ref)\n referenced.add(refName)\n }\n if (header.schema?.items?.$ref) {\n const refName = extractRefName(header.schema.items.$ref)\n referenced.add(refName)\n }\n }\n\n // Parameters from raw operation (path/query/header)\n const parameters = rawOperation.parameters || []\n for (const param of parameters) {\n const resolvedParam = resolveParameter(param, spec)\n if (resolvedParam?.schema?.$ref) {\n const refName = extractRefName(resolvedParam.schema.$ref)\n referenced.add(refName)\n }\n if (resolvedParam?.schema?.items?.$ref) {\n const refName = extractRefName(resolvedParam.schema.items.$ref)\n referenced.add(refName)\n }\n }\n }\n\n // Build closure: follow $ref chains in components/schemas\n const visited = new Set<string>()\n const toVisit = Array.from(referenced)\n\n while (toVisit.length > 0) {\n const schemaName = toVisit.pop()!\n if (visited.has(schemaName)) continue\n visited.add(schemaName)\n\n const schema = spec.components?.schemas?.[schemaName]\n if (!schema) continue\n\n // Extract dependencies from this schema\n const dependencies = extractDependencies(schema)\n for (const dep of dependencies) {\n if (spec.components?.schemas?.[dep] && !visited.has(dep)) {\n referenced.add(dep)\n toVisit.push(dep)\n }\n }\n }\n\n return referenced\n}\n","import { extractRefName } from \"../utils/topological-sort\"\nimport { formatPropertyName } from \"../utils/property-name\"\n\nexport type SchemaOptions = {\n strictDates: boolean\n strictNumeric: boolean\n optionalType: \"optional\" | \"nullable\" | \"nullish\"\n}\n\n/**\n * Applies the appropriate optional modifier to a Zod type based on the optionalType option.\n */\nexport function applyOptionalModifier(\n zodType: string,\n optionalType: \"optional\" | \"nullable\" | \"nullish\"\n): string {\n switch (optionalType) {\n case \"optional\":\n return `${zodType}.optional()`\n case \"nullable\":\n return `${zodType}.nullable()`\n case \"nullish\":\n return `${zodType}.nullish()`\n }\n}\n\n/**\n * Generates a complete Zod schema export statement for a named schema.\n * Handles enums, allOf, objects, and arrays.\n */\nexport function generateZodSchema(\n name: string,\n schema: any,\n generatedTypes: Set<string>,\n options: SchemaOptions,\n nameMap?: Map<string, string>\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 // Handle allOf schemas\n if (schema.allOf && Array.isArray(schema.allOf)) {\n const allOfParts = schema.allOf.map((part: any) =>\n getZodTypeFromSchema(part, options, nameMap)\n )\n if (allOfParts.length === 0) return `export const ${name} = z.object({});`\n if (allOfParts.length === 1)\n return `export const ${name} = ${allOfParts[0]};`\n const first = allOfParts[0]\n const rest = allOfParts\n .slice(1)\n .map((part: string) => `.and(${part})`)\n .join(\"\")\n return `export const ${name} = ${first}${rest};`\n }\n\n if (schema.type === \"object\" || schema.properties) {\n return `export const ${name} = ${buildZodObject(schema, options, nameMap)};`\n }\n\n if (schema.type === \"array\") {\n const itemSchema = schema.items ?? { type: \"unknown\" }\n const itemType = getZodTypeFromSchema(itemSchema, options, nameMap)\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, nameMap)};`\n}\n\n/**\n * Converts an OpenAPI schema to a Zod type expression.\n * Recursively handles nested schemas, references, and all OpenAPI schema types.\n */\nexport function getZodTypeFromSchema(\n schema: any,\n options: SchemaOptions,\n nameMap?: Map<string, string>\n): string {\n if (schema.$ref) {\n const refName = extractRefName(schema.$ref)\n return nameMap?.get(refName) || refName\n }\n\n if (schema.enum) {\n const enumValues = schema.enum.map((v: string) => `\"${v}\"`).join(\", \")\n return `z.enum([${enumValues}])`\n }\n\n // Handle allOf schemas\n if (schema.allOf && Array.isArray(schema.allOf)) {\n const allOfParts = schema.allOf.map((part: any) =>\n getZodTypeFromSchema(part, options, nameMap)\n )\n if (allOfParts.length === 0) return \"z.object({})\"\n if (allOfParts.length === 1) return allOfParts[0]\n const first = allOfParts[0]\n const rest = allOfParts\n .slice(1)\n .map((part: string) => `.and(${part})`)\n .join(\"\")\n return `${first}${rest}`\n }\n\n // Check for object with properties (including those without explicit type)\n if (\n schema.type === \"object\" ||\n schema.properties ||\n schema.allOf ||\n schema.oneOf ||\n schema.anyOf\n ) {\n return buildZodObject(schema, options, nameMap)\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 nameMap\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\n/**\n * Constructs a Zod object schema expression from an OpenAPI object schema.\n *\n * For each property in `schema.properties` the function:\n * - Keeps required properties as required in the resulting Zod schema.\n * - Applies the optional modifier based on `options.optionalType` for non-required properties.\n * - Applies the property's OpenAPI `default` value as a `.default(...)` on non-required properties except when `options.optionalType` is `\"nullable\"`.\n *\n * @param schema - The OpenAPI object schema to convert into a Zod object expression.\n * @param options - Schema generation options that control optional/null/default handling.\n * @param nameMap - Optional map translating referenced schema names to target type names.\n * @returns A string containing the Zod object schema expression (for example: `z.object({...})`).\n */\nexport function buildZodObject(\n schema: any,\n options: SchemaOptions,\n nameMap?: Map<string, string>\n): 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 baseType = getZodTypeFromSchema(propSchema as any, options, nameMap)\n // Only apply .default() to non-required properties with \"optional\" or\n // \"nullish\" optionalType. When optionalType is \"nullable\", the field must\n // be present (but may be null), so .default() would break those semantics\n // by accepting undefined input.\n const withOptional = applyOptionalModifier(baseType, options.optionalType)\n const withDefault =\n options.optionalType !== \"nullable\"\n ? applyDefaultModifier(withOptional, propSchema as any)\n : withOptional\n const finalType = isRequired ? baseType : withDefault\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\n/**\n * Builds a Zod schema expression for an OpenAPI string schema.\n *\n * Constructs an appropriate Zod string validator based on the schema's `format`, length and pattern constraints, and generation options.\n *\n * @param schema - OpenAPI schema object describing the string (may include `format`, `minLength`, `maxLength`, `pattern`, etc.)\n * @param options - Generation options that control date-related format handling and application of length/pattern constraints\n * @returns A string containing the Zod schema expression corresponding to `schema`\n */\nexport function buildString(schema: any, options: SchemaOptions): string {\n // OpenAPI binary (multipart uploads) - keep runtime-safe across Node/Bun/Browser\n if (schema.format === \"binary\") {\n return `(typeof Blob === \"undefined\" ? z.unknown() : z.instanceof(Blob))`\n }\n\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\n/**\n * Appends a default value to a Zod type expression when the OpenAPI schema defines one.\n *\n * @param zodType - The Zod type expression to modify (as a string)\n * @param schema - The OpenAPI schema object that may contain a `default` value\n * @returns The original `zodType` with `.default(<value>)` appended if `schema.default` is defined, otherwise the unmodified `zodType`\n */\nfunction applyDefaultModifier(zodType: string, schema: any): string {\n if (!schema || schema.default === undefined) return zodType\n return `${zodType}.default(${JSON.stringify(schema.default)})`\n}\n\n/**\n * Builds a Zod number schema with numeric constraints.\n */\nexport function 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\n/**\n * Builds a Zod integer schema (number with int validator).\n */\nexport function buildInteger(schema: any, options: SchemaOptions): string {\n let builder = buildNumber(schema, options)\n builder += \".int()\"\n return builder\n}\n\n/**\n * Applies minItems, maxItems, and uniqueItems constraints to array schemas.\n */\nexport function 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\n/**\n * Checks if a schema represents a primitive type (safe for uniqueness checks).\n */\nexport function 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\n/**\n * Applies min/max numeric bounds with exclusive variants.\n */\nexport function 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","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 { extractRefName } from \"../utils/topological-sort\"\nimport { toCamelCase, capitalize } from \"../utils/string-utils\"\nimport { isErrorStatus, mapStatusToIdentifier } from \"../utils/http-status\"\nimport {\n findContentType,\n resolveParameter,\n CONTENT_TYPE_MAP,\n} from \"../utils/schema-utils\"\nimport type { RequestMethod } from \"../types\"\nimport type {\n Operation,\n OperationErrorGroup,\n PathParam,\n QueryParam,\n RequestHeader,\n} from \"../types/operation\"\nimport type { OpenAPISpec } from \"../zenko\"\n\n/**\n * Converts an OpenAPI spec into a flat list of Operation objects describing each path, method, and webhook operation.\n *\n * @param spec - The OpenAPI document to parse\n * @param nameMap - Optional map from internal reference names to public type names used when resolving referenced request/response schemas\n * @returns An array of Operation objects containing operationId, path, HTTP method, extracted path/query/header parameters, request type (if any), resolved success response type (if any), and grouped error types\n */\nexport function parseOperations(\n spec: OpenAPISpec,\n nameMap?: Map<string, string>\n): Operation[] {\n const operations: Operation[] = []\n\n if (spec.paths) {\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 { operationId?: string }).operationId) continue\n\n const pathParams = extractPathParams(path)\n const requestType = getRequestType(operation, nameMap)\n const { successResponse, errors } = getResponseTypes(\n operation,\n (operation as { operationId: string }).operationId,\n nameMap\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 { operationId: string }).operationId,\n path,\n method: normalizedMethod,\n pathParams,\n queryParams,\n requestType,\n responseType: successResponse,\n requestHeaders,\n errors,\n })\n }\n }\n }\n\n if (spec.webhooks) {\n for (const [webhookName, webhookItem] of Object.entries(spec.webhooks)) {\n for (const [method, operation] of Object.entries(webhookItem)) {\n const normalizedMethod = method.toLowerCase()\n if (!isRequestMethod(normalizedMethod)) continue\n if (!(operation as { operationId?: string }).operationId) continue\n\n const path = webhookName\n const pathParams = extractPathParams(path)\n const requestType = getRequestType(operation, nameMap)\n const { successResponse, errors } = getResponseTypes(\n operation,\n (operation as { operationId: string }).operationId,\n nameMap\n )\n const resolvedParameters = collectParameters(\n webhookItem,\n operation,\n spec\n )\n const requestHeaders = getRequestHeaders(resolvedParameters)\n const queryParams = getQueryParams(resolvedParameters)\n\n operations.push({\n operationId: (operation as { operationId: string }).operationId,\n path,\n method: normalizedMethod,\n pathParams,\n queryParams,\n requestType,\n responseType: successResponse,\n requestHeaders,\n errors,\n })\n }\n }\n }\n\n return operations\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\n/**\n * Extracts path parameter descriptors from a path template.\n *\n * @param path - URL path template containing parameters in `{name}` braces\n * @returns An array of PathParam objects for each `{name}` occurrence; each entry contains `name` and `type` (\"string\")\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\",\n })\n }\n }\n\n return params\n}\n\n/**\n * Resolve the TypeScript type name for an operation's request body.\n *\n * @param operation - The OpenAPI OperationObject to inspect for a request body\n * @param nameMap - Optional map from internal `$ref` names to public type names; used when the request schema is a `$ref`\n * @returns The resolved request type name, or `undefined` when the operation has no request body\n */\nfunction getRequestType(\n operation: any,\n nameMap?: Map<string, string>\n): string | undefined {\n const requestBodySchema = getRequestBodySchema(operation)\n if (!requestBodySchema) return undefined\n\n if (requestBodySchema.$ref) {\n const refName = extractRefName(requestBodySchema.$ref)\n return nameMap?.get(refName) || refName\n }\n\n const typeName = `${capitalize(toCamelCase(operation.operationId))}Request`\n return typeName\n}\n\n/**\n * Selects the preferred request body schema from an OpenAPI Operation's content.\n *\n * @param operation - OpenAPI Operation object to inspect for a `requestBody`\n * @returns The first available schema for content types `application/json`, `multipart/form-data`, or `application/x-www-form-urlencoded`, or `undefined` if none is present\n */\nfunction getRequestBodySchema(operation: any): any | undefined {\n const content: Record<string, any> | undefined =\n operation?.requestBody?.content\n if (!content || Object.keys(content).length === 0) return undefined\n\n const preferredTypes = [\n \"application/json\",\n \"multipart/form-data\",\n \"application/x-www-form-urlencoded\",\n ]\n\n for (const t of preferredTypes) {\n const schema = content[t]?.schema\n if (schema) return schema\n }\n\n return undefined\n}\n\n/**\n * Determines the primary success response type and grouped error types for an operation.\n *\n * @param operation - The OpenAPI operation object to analyze (operation.responses is inspected).\n * @param operationId - Identifier used to derive fallback type names when a schema cannot be resolved.\n * @param nameMap - Optional map from internal reference names to public type names used to resolve referenced schemas.\n * @returns An object containing `successResponse`, the chosen success response type name (if any), and `errors`, a mapping of error identifiers to error type names (if any).\n */\nfunction getResponseTypes(\n operation: any,\n operationId: string,\n nameMap?: Map<string, 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 const content = (response as any)?.content\n if (!content || Object.keys(content).length === 0) {\n if (statusCode === \"204\" || /^3\\d\\d$/.test(statusCode)) {\n successCodes.set(statusCode, \"undefined\")\n } else if (isErrorStatus(statusCode)) {\n errorEntries.push({\n code: statusCode,\n schema: \"undefined\",\n })\n }\n continue\n }\n\n const contentType = findContentType(content)\n const resolvedSchema = content[contentType]?.schema\n\n if (!resolvedSchema) {\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(\n successCodes,\n operationId,\n nameMap\n )\n const errors = buildErrorGroups(errorEntries, operationId, nameMap)\n\n return { successResponse, errors }\n}\n\nfunction selectSuccessResponse(\n responses: Map<string, any>,\n operationId: string,\n nameMap?: Map<string, 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 return schema\n }\n return resolveResponseType(\n schema,\n `${capitalize(toCamelCase(operationId))}Response`,\n nameMap\n )\n }\n }\n\n const [, 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(toCamelCase(operationId))}Response`,\n nameMap\n )\n}\n\nfunction buildErrorGroups(\n errors: Array<{ code: string; schema: any }> = [],\n operationId: string,\n nameMap?: Map<string, 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 identifier = mapStatusToIdentifier(code)\n const typeName = resolveResponseType(\n schema,\n `${capitalize(toCamelCase(operationId))}${capitalize(identifier)}`,\n nameMap\n )\n\n group[identifier] = typeName\n }\n\n return group\n}\n\nfunction resolveResponseType(\n schema: any,\n fallbackName: string,\n nameMap?: Map<string, string>\n): string {\n if (typeof schema === \"string\") {\n return schema\n }\n if (schema.$ref) {\n const refName = extractRefName(schema.$ref)\n return nameMap?.get(refName) || refName\n }\n if (schema.type === \"array\" && schema.items?.$ref) {\n const itemRef = extractRefName(schema.items.$ref)\n const sanitizedItemRef = nameMap?.get(itemRef) || itemRef\n return `z.array(${sanitizedItemRef})`\n }\n if (schema.allOf && Array.isArray(schema.allOf)) {\n return fallbackName\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 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\nfunction inferResponseType(\n contentType: string,\n statusCode: string\n): string | undefined {\n if (statusCode === \"204\" || /^3\\d\\d$/.test(statusCode)) {\n return \"undefined\"\n }\n\n if (contentType in CONTENT_TYPE_MAP) {\n return CONTENT_TYPE_MAP[contentType]\n }\n\n return \"unknown\"\n}\n","import { toCamelCase, capitalize } from \"./string-utils\"\nimport type { Operation } from \"../types/operation\"\nimport type { OpenAPISpec as FullOpenAPISpec } from \"../zenko\"\n/**\n * Minimal OpenAPI types for the properties we access\n */\ntype OpenAPIOperation = {\n operationId?: string\n requestBody?: {\n content?: Record<string, { schema?: OpenAPISchema }>\n }\n responses?: Record<\n string,\n { content?: Record<string, { schema?: OpenAPISchema }> }\n >\n}\n\ntype OpenAPISchema = {\n $ref?: string\n allOf?: OpenAPISchema[]\n oneOf?: OpenAPISchema[]\n anyOf?: OpenAPISchema[]\n [key: string]: any // Allow arbitrary properties\n}\n\ntype OpenAPISpec = {\n paths?: FullOpenAPISpec[\"paths\"]\n webhooks?: FullOpenAPISpec[\"webhooks\"]\n}\n\n/**\n * Collects all inline request types that need to be generated.\n *\n * @param operations - Processed operations with metadata\n * @param spec - Raw OpenAPI specification\n * @returns Map of type names to their schemas\n */\nexport function collectInlineRequestTypes(\n operations: Operation[],\n spec: OpenAPISpec\n): Map<string, any> {\n const requestTypesToGenerate = new Map<string, any>()\n\n // Build a lookup map of operationId -> operation for O(1) access\n const operationLookup = new Map<string, OpenAPIOperation>()\n\n // Process paths\n for (const [, pathItem] of Object.entries(spec.paths || {})) {\n for (const [, operation] of Object.entries(pathItem)) {\n const op = operation as OpenAPIOperation\n if (op.operationId) {\n operationLookup.set(op.operationId, op)\n }\n }\n }\n\n // Process webhooks\n for (const [, pathItem] of Object.entries(spec.webhooks || {})) {\n for (const [, operation] of Object.entries(pathItem)) {\n const op = operation as OpenAPIOperation\n if (op.operationId) {\n operationLookup.set(op.operationId, op)\n }\n }\n }\n\n for (const op of operations) {\n const operation = operationLookup.get(op.operationId)\n if (!operation) continue\n\n const requestBody = operation.requestBody\n if (requestBody && requestBody.content) {\n const content = requestBody.content\n const schema = findRequestBodySchema(content)\n if (!schema) continue\n\n const typeName = `${capitalize(toCamelCase(op.operationId))}Request`\n\n // Generate if it's not a simple $ref (those are already handled)\n // This includes allOf, oneOf, anyOf, and complex inline schemas\n if (!schema.$ref || schema.allOf || schema.oneOf || schema.anyOf) {\n requestTypesToGenerate.set(typeName, schema)\n }\n }\n }\n\n return requestTypesToGenerate\n}\n\n/**\n * Selects the preferred request body schema from a media-type-to-content mapping.\n *\n * @param content - A mapping from media type (e.g. \"application/json\") to an object that may contain a `schema` property\n * @returns The first found schema for a preferred media type (`application/json`, `multipart/form-data`, `application/x-www-form-urlencoded`) or `undefined` if none is present\n */\nfunction findRequestBodySchema(\n content: Record<string, { schema?: OpenAPISchema }>\n): OpenAPISchema | undefined {\n const preferredTypes = [\n \"application/json\",\n \"multipart/form-data\",\n \"application/x-www-form-urlencoded\",\n ]\n\n for (const t of preferredTypes) {\n const schema = content[t]?.schema\n if (schema) return schema\n }\n\n return undefined\n}\n\n/**\n * Collects all inline response types that need to be generated.\n *\n * @param operations - Processed operations with metadata\n * @param spec - Raw OpenAPI specification\n * @returns Map of type names to their schemas\n */\nexport function collectInlineResponseTypes(\n operations: Operation[],\n spec: OpenAPISpec\n): Map<string, any> {\n const responseTypesToGenerate = new Map<string, any>()\n\n // Build a lookup map of operationId -> operation for O(1) access\n const operationLookup = new Map<string, OpenAPIOperation>()\n\n // Process paths\n for (const [, pathItem] of Object.entries(spec.paths || {})) {\n for (const [, operation] of Object.entries(pathItem)) {\n const op = operation as OpenAPIOperation\n if (op.operationId) {\n operationLookup.set(op.operationId, op)\n }\n }\n }\n\n // Process webhooks\n for (const [, pathItem] of Object.entries(spec.webhooks || {})) {\n for (const [, operation] of Object.entries(pathItem)) {\n const op = operation as OpenAPIOperation\n if (op.operationId) {\n operationLookup.set(op.operationId, op)\n }\n }\n }\n\n for (const op of operations) {\n const operation = operationLookup.get(op.operationId)\n if (!operation) continue\n\n const responses = operation.responses || {}\n for (const [statusCode, response] of Object.entries(responses)) {\n if (/^2\\d\\d$/.test(statusCode) && (response as any).content) {\n const content = (response as any).content\n const jsonContent = content[\"application/json\"]\n\n if (jsonContent && jsonContent.schema) {\n const schema = jsonContent.schema\n const typeName = `${capitalize(toCamelCase(op.operationId))}Response`\n\n // Generate if it's not a simple $ref (those are already handled)\n // This includes allOf, oneOf, anyOf, and complex inline schemas\n if (!schema.$ref || schema.allOf || schema.oneOf || schema.anyOf) {\n responseTypesToGenerate.set(typeName, schema)\n }\n }\n }\n }\n }\n\n return responseTypesToGenerate\n}\n","import {\n collectInlineRequestTypes,\n collectInlineResponseTypes,\n} from \"../utils/collect-inline-types\"\nimport { generateZodSchema } from \"../core/schema-generator\"\nimport type { SchemaOptions } from \"../core/schema-generator\"\nimport type { Operation } from \"../types/operation\"\nimport type { OpenAPISpec } from \"../zenko\"\n\nexport function generateRequestTypes(\n output: string[],\n operations: Operation[],\n spec: OpenAPISpec,\n nameMap: Map<string, string>,\n schemaOptions: SchemaOptions\n) {\n const requestTypesToGenerate = collectInlineRequestTypes(operations, spec)\n\n if (requestTypesToGenerate.size > 0) {\n output.push(\"// Generated Request Types\")\n output.push(\"\")\n\n for (const [typeName, schema] of requestTypesToGenerate) {\n const generatedSchema = generateZodSchema(\n typeName,\n schema,\n new Set(),\n schemaOptions,\n nameMap\n )\n output.push(generatedSchema)\n output.push(\"\")\n output.push(`export type ${typeName} = z.infer<typeof ${typeName}>;`)\n output.push(\"\")\n }\n }\n}\n\nexport function generateResponseTypes(\n output: string[],\n operations: Operation[],\n spec: OpenAPISpec,\n nameMap: Map<string, string>,\n schemaOptions: SchemaOptions\n) {\n const responseTypesToGenerate = collectInlineResponseTypes(operations, spec)\n\n if (responseTypesToGenerate.size > 0) {\n output.push(\"// Generated Response Types\")\n output.push(\"\")\n\n for (const [typeName, schema] of responseTypesToGenerate) {\n const generatedSchema = generateZodSchema(\n typeName,\n schema,\n new Set(),\n schemaOptions,\n nameMap\n )\n output.push(generatedSchema)\n output.push(\"\")\n output.push(`export type ${typeName} = z.infer<typeof ${typeName}>;`)\n output.push(\"\")\n }\n }\n}\n","/**\n * Generate a standalone helper types file for use with `helpers: \"file\"` mode.\n *\n * @returns TypeScript source containing PathFn, RequestMethod, HeaderFn, AnyHeaderFn, OperationErrors, and OperationDefinition 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<TError = unknown> = TError extends Record<string, unknown> ? TError : Record<string, TError>;\"\n )\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","import { topologicalSort } from \"./utils/topological-sort\"\nimport { formatPropertyName, isValidJSIdentifier } from \"./utils/property-name\"\nimport { toCamelCase, capitalize } from \"./utils/string-utils\"\nimport { analyzeZenkoUsage, generateZenkoImport } from \"./utils/tree-shaking\"\nimport { collectReferencedSchemas } from \"./utils/collect-referenced-schemas\"\nimport {\n type SchemaOptions,\n generateZodSchema,\n applyOptionalModifier,\n} from \"./core/schema-generator\"\nimport { parseOperations } from \"./core/operation-parser\"\nimport {\n generateRequestTypes,\n generateResponseTypes,\n} from \"./generator/inline-types\"\nimport type {\n QueryParam,\n RequestHeader,\n Operation,\n OperationErrorGroup,\n OperationErrorMap,\n} from \"./types/operation\"\nimport { generateHelperFile } from \"./utils/generate-helper-file\"\n\nexport type OpenAPISpec = {\n openapi: string\n info: unknown\n paths: Record<string, Record<string, unknown>>\n webhooks?: 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 treeShake?: boolean\n optionalType?: \"optional\" | \"nullable\" | \"nullish\"\n}\n\nexport type GenerateOptions = {\n strictDates?: boolean\n strictNumeric?: boolean\n types?: TypesConfig\n operationIds?: string[]\n}\n\nexport type GenerateResult = {\n output: string\n helperFile?: {\n path: string\n content: string\n }\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, operationIds } = options\n const typesConfig = normalizeTypesConfig(options.types)\n const schemaOptions: SchemaOptions = {\n strictDates,\n strictNumeric,\n optionalType: typesConfig.optionalType,\n }\n\n output.push('import { z } from \"zod\";')\n\n // Create mapping from original names to sanitized names\n const nameMap = new Map<string, string>()\n if (spec.components?.schemas) {\n for (const name of Object.keys(spec.components.schemas)) {\n nameMap.set(name, toCamelCase(name))\n }\n }\n\n // Parse all operations early for tree-shaking\n let operations = parseOperations(spec, nameMap)\n\n // Filter operations if operationIds is provided\n if (operationIds && operationIds.length > 0) {\n const selectedIds = new Set(operationIds)\n operations = operations.filter((op) => selectedIds.has(op.operationId))\n }\n\n // Generate helper types import right after Zod import\n appendHelperTypesImport(output, typesConfig, operations)\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 // Determine which schemas to generate\n let schemasToGenerate: string[]\n if (operationIds && operationIds.length > 0) {\n // Only generate schemas referenced by selected operations\n const referencedSchemas = collectReferencedSchemas(operations, spec)\n schemasToGenerate = Array.from(referencedSchemas)\n } else {\n // Generate all schemas\n schemasToGenerate = Object.keys(spec.components.schemas)\n }\n\n // Sort schemas by dependencies (topological sort)\n const sortedSchemas = topologicalSort(spec.components.schemas).filter(\n (name) => schemasToGenerate.includes(name)\n )\n\n for (const name of sortedSchemas) {\n const schema = spec.components.schemas[name]\n const sanitizedName = nameMap.get(name)!\n output.push(\n generateZodSchema(\n sanitizedName,\n schema,\n generatedTypes,\n schemaOptions,\n nameMap\n )\n )\n output.push(\"\")\n // Export inferred type\n output.push(\n `export type ${sanitizedName} = z.infer<typeof ${sanitizedName}>;`\n )\n output.push(\"\")\n }\n }\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 alias = (n: string) => {\n if (isValidJSIdentifier(n)) return n\n let aliased = toCamelCase(n)\n // If still not valid (e.g., starts with number), prefix with underscore\n if (!isValidJSIdentifier(aliased)) {\n aliased = `_${aliased}`\n }\n return aliased\n }\n const destructPieces: string[] = []\n const typePieces: string[] = []\n for (const param of op.pathParams) {\n destructPieces.push(\n isValidJSIdentifier(param.name)\n ? param.name\n : `${formatPropertyName(param.name)}: ${alias(param.name)}`\n )\n typePieces.push(`${formatPropertyName(param.name)}: string`)\n }\n for (const param of op.queryParams) {\n destructPieces.push(\n isValidJSIdentifier(param.name)\n ? param.name\n : `${formatPropertyName(param.name)}: ${alias(param.name)}`\n )\n typePieces.push(\n `${formatPropertyName(param.name)}${param.required ? \"\" : \"?\"}: ${mapQueryType(param)}`\n )\n }\n const needsDefaultObject =\n !hasPathParams &&\n hasQueryParams &&\n op.queryParams.every((param) => !param.required)\n const signatureArgs = destructPieces.length\n ? `{ ${destructPieces.join(\", \")} }`\n : \"{}\"\n const signature = `${signatureArgs}: { ${typePieces.join(\", \")} }${\n needsDefaultObject ? \" = {}\" : \"\"\n }`\n\n const pathWithParams = op.path.replace(\n /{([^}]+)}/g,\n (_m, n) => `\\${${alias(n)}}`\n )\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 accessor = isValidJSIdentifier(param.name)\n ? param.name\n : alias(toCamelCase(param.name))\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 finalType = header.required\n ? zodType\n : applyOptionalModifier(zodType, schemaOptions.optionalType)\n return ` ${formatPropertyName(header.name)}: ${finalType},`\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 request and response types before operation types\n generateRequestTypes(output, operations, spec, nameMap, schemaOptions)\n generateResponseTypes(output, operations, spec, nameMap, schemaOptions)\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 appendErrorGroup(output, \"errors\", op.errors)\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 * Generates TypeScript client code from an OpenAPI specification.\n *\n * @param spec - The OpenAPI specification object.\n * @param options - Configuration options controlling code generation behavior.\n * @returns Generated TypeScript code as a 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 Boolean(group && Object.keys(group).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 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 treeShake: config?.treeShake ?? true,\n optionalType: config?.optionalType ?? \"optional\",\n }\n}\n\ntype NormalizedTypesConfig = {\n emit: boolean\n helpers: TypesHelperMode\n helpersOutput: string\n treeShake: boolean\n optionalType: \"optional\" | \"nullable\" | \"nullish\"\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 operations: Operation[]\n) {\n if (!config.emit) return\n\n switch (config.helpers) {\n case \"package\":\n if (config.treeShake) {\n const usage = analyzeZenkoUsage(operations)\n const importStatement = generateZenkoImport(usage, \"package\")\n if (importStatement) {\n buffer.push(importStatement)\n }\n } else {\n buffer.push(\n 'import type { PathFn, HeaderFn, OperationDefinition, OperationErrors } from \"zenko\";'\n )\n }\n return\n case \"file\":\n if (config.treeShake) {\n const usage = analyzeZenkoUsage(operations)\n const importStatement = generateZenkoImport(\n usage,\n \"file\",\n config.helpersOutput\n )\n if (importStatement) {\n buffer.push(importStatement)\n }\n } else {\n buffer.push(\n `import type { PathFn, HeaderFn, OperationDefinition, OperationErrors } from \"${config.helpersOutput}\";`\n )\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<TError = unknown> = TError extends Record<string, unknown> ? TError : Record<string, TError>;\"\n )\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 buffer.push(\"\")\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 errorBucket = buildErrorBucket(errors)\n\n return `OperationErrors<${errorBucket}>`\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 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"],"mappings":";AAAO,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;AAC9B,UAAI,QAAQ,GAAG,GAAG;AAChB,cAAM,GAAG;AAAA,MACX;AAAA,IACF;AAEA,aAAS,OAAO,IAAI;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