@kubb/ast 5.0.0-alpha.8 → 5.0.0-beta.75
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/README.md +24 -10
- package/dist/index.cjs +1975 -531
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3379 -24
- package/dist/index.js +1911 -519
- package/dist/index.js.map +1 -1
- package/package.json +23 -34
- package/src/constants.ts +133 -15
- package/src/factory.ts +680 -22
- package/src/guards.ts +77 -9
- package/src/index.ts +44 -6
- package/src/infer.ts +130 -0
- package/src/mocks.ts +101 -25
- package/src/nodes/base.ts +44 -4
- package/src/nodes/code.ts +304 -0
- package/src/nodes/file.ts +230 -0
- package/src/nodes/function.ts +223 -0
- package/src/nodes/http.ts +17 -5
- package/src/nodes/index.ts +47 -7
- package/src/nodes/operation.ts +84 -6
- package/src/nodes/output.ts +26 -0
- package/src/nodes/parameter.ts +27 -1
- package/src/nodes/property.ts +23 -1
- package/src/nodes/response.ts +29 -3
- package/src/nodes/root.ts +34 -12
- package/src/nodes/schema.ts +419 -42
- package/src/printer.ts +152 -59
- package/src/refs.ts +39 -7
- package/src/resolvers.ts +45 -0
- package/src/transformers.ts +159 -0
- package/src/types.ts +32 -4
- package/src/utils.ts +799 -14
- package/src/visitor.ts +411 -96
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +0 -2
- package/dist/types.js +0 -1
- package/dist/visitor-CrkOJoGa.d.ts +0 -702
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/constants.ts","../src/factory.ts","../src/guards.ts","../src/printer.ts","../src/refs.ts","../../../internals/utils/dist/index.js","../src/utils.ts","../src/visitor.ts"],"sourcesContent":["import type { NodeKind } from './nodes/base.ts'\nimport type { MediaType } from './nodes/http.ts'\nimport type { HttpMethod } from './nodes/operation.ts'\nimport type { ParameterLocation } from './nodes/parameter.ts'\nimport type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Depth for schema traversal in visitor functions.\n */\nexport type VisitorDepth = 'shallow' | 'deep'\n\nexport const visitorDepths = {\n shallow: 'shallow',\n deep: 'deep',\n} as const satisfies Record<VisitorDepth, VisitorDepth>\n\nexport const nodeKinds = {\n root: 'Root',\n operation: 'Operation',\n schema: 'Schema',\n property: 'Property',\n parameter: 'Parameter',\n response: 'Response',\n} as const satisfies Record<Lowercase<NodeKind>, NodeKind>\n\nexport const schemaTypes = {\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n object: 'object',\n array: 'array',\n tuple: 'tuple',\n union: 'union',\n intersection: 'intersection',\n enum: 'enum',\n ref: 'ref',\n date: 'date',\n datetime: 'datetime',\n time: 'time',\n uuid: 'uuid',\n email: 'email',\n url: 'url',\n blob: 'blob',\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n\nexport const httpMethods = {\n get: 'GET',\n post: 'POST',\n put: 'PUT',\n patch: 'PATCH',\n delete: 'DELETE',\n head: 'HEAD',\n options: 'OPTIONS',\n trace: 'TRACE',\n} as const satisfies Record<Lowercase<HttpMethod>, HttpMethod>\n\nexport const parameterLocations = {\n path: 'path',\n query: 'query',\n header: 'header',\n cookie: 'cookie',\n} as const satisfies Record<ParameterLocation, ParameterLocation>\n\n/**\n * Default max concurrent visitor calls in `walk`.\n */\nexport const WALK_CONCURRENCY = 30\n\n/**\n * Fallback status code string for API spec responses.\n */\nexport const DEFAULT_STATUS_CODE = 'default' as const\n\nexport const mediaTypes = {\n applicationJson: 'application/json',\n applicationXml: 'application/xml',\n applicationFormUrlEncoded: 'application/x-www-form-urlencoded',\n applicationOctetStream: 'application/octet-stream',\n applicationPdf: 'application/pdf',\n applicationZip: 'application/zip',\n applicationGraphql: 'application/graphql',\n multipartFormData: 'multipart/form-data',\n textPlain: 'text/plain',\n textHtml: 'text/html',\n textCsv: 'text/csv',\n textXml: 'text/xml',\n imagePng: 'image/png',\n imageJpeg: 'image/jpeg',\n imageGif: 'image/gif',\n imageWebp: 'image/webp',\n imageSvgXml: 'image/svg+xml',\n audioMpeg: 'audio/mpeg',\n videoMp4: 'video/mp4',\n} as const satisfies Record<string, MediaType>\n","import type { ObjectSchemaNode, OperationNode, ParameterNode, PropertyNode, ResponseNode, RootNode, SchemaNode } from './nodes/index.ts'\n\n/**\n * Distributive variant of `Omit` that preserves union members.\n */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/**\n * Creates a `RootNode`.\n */\nexport function createRoot(overrides: Partial<Omit<RootNode, 'kind'>> = {}): RootNode {\n return {\n schemas: [],\n operations: [],\n ...overrides,\n kind: 'Root',\n }\n}\n\n/**\n * Creates an `OperationNode`.\n */\nexport function createOperation(\n props: Pick<OperationNode, 'operationId' | 'method' | 'path'> & Partial<Omit<OperationNode, 'kind' | 'operationId' | 'method' | 'path'>>,\n): OperationNode {\n return {\n tags: [],\n parameters: [],\n responses: [],\n ...props,\n kind: 'Operation',\n }\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`.\n * For object schemas, `properties` defaults to `[]` when not provided.\n */\nexport function createSchema<T extends Omit<ObjectSchemaNode, 'kind' | 'properties'> & { properties?: Array<PropertyNode> }>(\n props: T,\n): Omit<T, 'properties'> & { properties: Array<PropertyNode>; kind: 'Schema' }\nexport function createSchema<T extends DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>>(props: T): T & { kind: 'Schema' }\nexport function createSchema(props: DistributiveOmit<SchemaNode, 'kind'>): SchemaNode\nexport function createSchema(props: Record<string, unknown>): Record<string, unknown> {\n if (props['type'] === 'object') {\n return { properties: [], ...props, kind: 'Schema' }\n }\n\n return { ...props, kind: 'Schema' }\n}\n\n/**\n * Creates a `PropertyNode`. `required` defaults to `false`.\n */\nexport function createProperty(props: Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>): PropertyNode {\n return {\n required: false,\n ...props,\n kind: 'Property',\n }\n}\n\n/**\n * Creates a `ParameterNode`. `required` defaults to `false`.\n */\nexport function createParameter(\n props: Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>,\n): ParameterNode {\n return {\n required: false,\n ...props,\n kind: 'Parameter',\n }\n}\n\n/**\n * Creates a `ResponseNode`.\n */\nexport function createResponse(props: Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode'>>): ResponseNode {\n return {\n ...props,\n kind: 'Response',\n }\n}\n","import type { Node, NodeKind, OperationNode, ParameterNode, PropertyNode, ResponseNode, RootNode, SchemaNode, SchemaNodeByType } from './nodes/index.ts'\n\n/**\n * Narrows a `SchemaNode` to the specific variant matching `type`.\n */\nexport function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | undefined {\n return node?.type === type ? (node as SchemaNodeByType[T]) : undefined\n}\n\nfunction isKind<T extends Node>(kind: NodeKind) {\n return (node: unknown): node is T => (node as Node).kind === kind\n}\n\n/**\n * Type guard for `RootNode`.\n */\nexport const isRootNode = isKind<RootNode>('Root')\n\n/**\n * Type guard for `OperationNode`.\n */\nexport const isOperationNode = isKind<OperationNode>('Operation')\n\n/**\n * Type guard for `SchemaNode`.\n */\nexport const isSchemaNode = isKind<SchemaNode>('Schema')\n\n/**\n * Type guard for `PropertyNode`.\n */\nexport const isPropertyNode = isKind<PropertyNode>('Property')\n\n/**\n * Type guard for `ParameterNode`.\n */\nexport const isParameterNode = isKind<ParameterNode>('Parameter')\n\n/**\n * Type guard for `ResponseNode`.\n */\nexport const isResponseNode = isKind<ResponseNode>('Response')\n","import type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/index.ts'\n\n/**\n * Handler context for `definePrinter` — mirrors `PluginContext` from `@kubb/core`.\n * Available as `this` inside each node handler and the optional root-level `print`.\n * `this.print` always dispatches to the `nodes` handlers (node-level printer).\n */\nexport type PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively print a nested `SchemaNode` using the node-level handlers.\n */\n print: (node: SchemaNode) => TOutput | null | undefined\n /**\n * Options for this printer instance.\n */\n options: TOptions\n}\n\n/**\n * Handler for a specific `SchemaNode` variant identified by `SchemaType` key `T`.\n * Use a regular function (not an arrow function) so that `this` is available.\n */\nexport type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n) => TOutput | null | undefined\n\n/**\n * Shape of the type parameter passed to `definePrinter`.\n * Mirrors `AdapterFactoryOptions` / `PluginFactoryOptions` from `@kubb/core`.\n *\n * - `TName` — unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` — options passed to and stored on the printer\n * - `TOutput` — the type emitted by node handlers\n * - `TPrintOutput` — the type emitted by the public `print` override (defaults to `TOutput`)\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * The object returned by calling a `definePrinter` instance.\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations). Otherwise falls back\n * to the node-level dispatcher\n */\n print: (node: SchemaNode) => T['printOutput'] | null | undefined\n}\n\n/**\n * Builder function passed to `definePrinter`. Receives the resolved options and returns the\n * printer configuration: a unique `name`, the stored `options`, node-level `nodes` handlers,\n * and an optional root-level `print` override.\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: Partial<{\n [K in SchemaType]: PrinterHandler<T['output'], T['options'], K>\n }>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * `this.print(node)` inside this function calls the node-level dispatcher (`nodes` handlers),\n * not the override itself — so recursion is safe.\n */\n print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null | undefined\n}\n\n/**\n * Creates a named printer factory. Mirrors the `createPlugin` / `createAdapter` pattern\n * from `@kubb/core` — wraps a builder to make options optional and separates raw options\n * from resolved options.\n *\n * The builder receives resolved options and returns:\n * - `name` — a unique identifier for the printer\n * - `options` — options stored on the returned printer instance\n * - `nodes` — a map of `SchemaType` → handler functions that convert a `SchemaNode` to `TOutput`\n * - `print` _(optional)_ — a root-level override that becomes the public `printer.print`.\n * Inside it, `this.print(node)` still dispatches to the `nodes` map — safe recursion, no infinite loop.\n *\n * When no `print` override is provided, `printer.print` is the node-level dispatcher directly.\n *\n * @example Basic usage — Zod schema printer\n * ```ts\n * type ZodPrinter = PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = definePrinter<ZodPrinter>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties.map(p => `${p.name}: ${this.print(p.schema)}`).join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n *\n * @example With a root-level `print` override to wrap output in a full declaration\n * ```ts\n * type TsPrinter = PrinterFactoryOptions<'ts', { typeName?: string }, ts.TypeNode, ts.Node>\n *\n * export const printerTs = definePrinter<TsPrinter>((options) => ({\n * name: 'ts',\n * options,\n * nodes: { string: () => factory.keywordTypeNodes.string },\n * print(node) {\n * const type = this.print(node) // calls the node-level dispatcher\n * if (!type || !this.options.typeName) return type\n * return factory.createTypeAliasDeclaration(this.options.typeName, type)\n * },\n * }))\n * ```\n */\nexport function definePrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, print: printOverride } = build(options ?? ({} as T['options']))\n\n const context: PrinterHandlerContext<T['output'], T['options']> = {\n options: resolvedOptions,\n print: (node: SchemaNode) => {\n const schemaType = node.type\n const handler = nodes[schemaType]\n\n if (!handler) return undefined\n\n const typedHandler = handler as PrinterHandler<T['output'], T['options']>\n\n return typedHandler.call(context, node as SchemaNodeByType[SchemaType])\n },\n }\n\n return {\n name,\n options: resolvedOptions,\n print: (printOverride ? printOverride.bind(context) : context.print) as Printer<T>['print'],\n }\n }\n}\n","import type { RootNode } from './nodes/root.ts'\nimport type { SchemaNode } from './nodes/schema.ts'\n\n/**\n * Schema name to `SchemaNode` mapping.\n */\nexport type RefMap = Map<string, SchemaNode>\n\n/**\n * Indexes named schemas from `root.schemas` by name. Unnamed schemas are skipped.\n */\nexport function buildRefMap(root: RootNode): RefMap {\n const map: RefMap = new Map()\n\n for (const schema of root.schemas) {\n if (schema.name) {\n map.set(schema.name, schema)\n }\n }\n return map\n}\n\n/**\n * Looks up a schema by name. Prefer over `RefMap.get()` to keep the resolution strategy swappable.\n */\nexport function resolveRef(refMap: RefMap, ref: string): SchemaNode | undefined {\n return refMap.get(ref)\n}\n\n/**\n * Converts a `RefMap` to a plain object.\n */\nexport function refMapToObject(refMap: RefMap): Record<string, SchemaNode> {\n return Object.fromEntries(refMap)\n}\n","import \"./chunk--u3MIqq1.js\";\nimport { EventEmitter } from \"node:events\";\nimport { parseArgs, styleText } from \"node:util\";\nimport { createHash, randomBytes } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { access, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, join, posix, resolve } from \"node:path\";\nimport { promises } from \"node:dns\";\nimport { spawn } from \"node:child_process\";\n//#region src/errors.ts\n/** Thrown when a plugin's configuration or input fails validation. */\nvar ValidationPluginError = class extends Error {};\n/**\n* Thrown when one or more errors occur during a Kubb build.\n* Carries the full list of underlying errors on `errors`.\n*/\nvar BuildError = class extends Error {\n\terrors;\n\tconstructor(message, options) {\n\t\tsuper(message, { cause: options.cause });\n\t\tthis.name = \"BuildError\";\n\t\tthis.errors = options.errors;\n\t}\n};\n/**\n* Coerces an unknown thrown value to an `Error` instance.\n* When the value is already an `Error` it is returned as-is;\n* otherwise a new `Error` is created whose message is `String(value)`.\n*/\nfunction toError(value) {\n\treturn value instanceof Error ? value : new Error(String(value));\n}\n/**\n* Safely extracts a human-readable message from any thrown value.\n*/\nfunction getErrorMessage(value) {\n\treturn value instanceof Error ? value.message : String(value);\n}\n/**\n* Extracts the `.cause` of an `Error` as an `Error | undefined`.\n* Returns `undefined` when the cause is absent or is not an `Error`.\n*/\nfunction toCause(error) {\n\treturn error.cause instanceof Error ? error.cause : void 0;\n}\n//#endregion\n//#region src/asyncEventEmitter.ts\n/**\n* A typed EventEmitter that awaits all async listeners before resolving.\n* Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n*/\nvar AsyncEventEmitter = class {\n\t/**\n\t* `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.\n\t* @default 10\n\t*/\n\tconstructor(maxListener = 10) {\n\t\tthis.#emitter.setMaxListeners(maxListener);\n\t}\n\t#emitter = new EventEmitter();\n\t/**\n\t* Emits an event and awaits all registered listeners in parallel.\n\t* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n\t*/\n\tasync emit(eventName, ...eventArgs) {\n\t\tconst listeners = this.#emitter.listeners(eventName);\n\t\tif (listeners.length === 0) return;\n\t\tawait Promise.all(listeners.map(async (listener) => {\n\t\t\ttry {\n\t\t\t\treturn await listener(...eventArgs);\n\t\t\t} catch (err) {\n\t\t\t\tlet serializedArgs;\n\t\t\t\ttry {\n\t\t\t\t\tserializedArgs = JSON.stringify(eventArgs);\n\t\t\t\t} catch {\n\t\t\t\t\tserializedArgs = String(eventArgs);\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) });\n\t\t\t}\n\t\t}));\n\t}\n\t/** Registers a persistent listener for the given event. */\n\ton(eventName, handler) {\n\t\tthis.#emitter.on(eventName, handler);\n\t}\n\t/** Registers a one-shot listener that removes itself after the first invocation. */\n\tonOnce(eventName, handler) {\n\t\tconst wrapper = (...args) => {\n\t\t\tthis.off(eventName, wrapper);\n\t\t\treturn handler(...args);\n\t\t};\n\t\tthis.on(eventName, wrapper);\n\t}\n\t/** Removes a previously registered listener. */\n\toff(eventName, handler) {\n\t\tthis.#emitter.off(eventName, handler);\n\t}\n\t/** Removes all listeners from every event channel. */\n\tremoveAll() {\n\t\tthis.#emitter.removeAllListeners();\n\t}\n};\n//#endregion\n//#region src/casing.ts\n/**\n* Shared implementation for camelCase and PascalCase conversion.\n* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n* and capitalizes each word according to `pascal`.\n*\n* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n*/\nfunction toCamelOrPascal(text, pascal) {\n\treturn text.trim().replace(/([a-z\\d])([A-Z])/g, \"$1 $2\").replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\").replace(/(\\d)([a-z])/g, \"$1 $2\").split(/[\\s\\-_./\\\\:]+/).filter(Boolean).map((word, i) => {\n\t\tif (word.length > 1 && word === word.toUpperCase()) return word;\n\t\tif (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);\n\t\treturn word.charAt(0).toUpperCase() + word.slice(1);\n\t}).join(\"\").replace(/[^a-zA-Z0-9]/g, \"\");\n}\n/**\n* Splits `text` on `.` and applies `transformPart` to each segment.\n* The last segment receives `isLast = true`, all earlier segments receive `false`.\n* Segments are joined with `/` to form a file path.\n*/\nfunction applyToFileParts(text, transformPart) {\n\tconst parts = text.split(\".\");\n\treturn parts.map((part, i) => transformPart(part, i === parts.length - 1)).join(\"/\");\n}\n/**\n* Converts `text` to camelCase.\n* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n*\n* @example\n* camelCase('hello-world') // 'helloWorld'\n* camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n*/\nfunction camelCase(text, { isFile, prefix = \"\", suffix = \"\" } = {}) {\n\tif (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {\n\t\tprefix,\n\t\tsuffix\n\t} : {}));\n\treturn toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);\n}\n/**\n* Converts `text` to PascalCase.\n* When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n*\n* @example\n* pascalCase('hello-world') // 'HelloWorld'\n* pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n*/\nfunction pascalCase(text, { isFile, prefix = \"\", suffix = \"\" } = {}) {\n\tif (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {\n\t\tprefix,\n\t\tsuffix\n\t}) : camelCase(part));\n\treturn toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);\n}\n/**\n* Converts `text` to snake_case.\n*\n* @example\n* snakeCase('helloWorld') // 'hello_world'\n* snakeCase('Hello-World') // 'hello_world'\n*/\nfunction snakeCase(text, { prefix = \"\", suffix = \"\" } = {}) {\n\treturn `${prefix} ${text} ${suffix}`.trim().replace(/([a-z])([A-Z])/g, \"$1_$2\").replace(/[\\s\\-.]+/g, \"_\").replace(/[^a-zA-Z0-9_]/g, \"\").toLowerCase().split(\"_\").filter(Boolean).join(\"_\");\n}\n/**\n* Converts `text` to SCREAMING_SNAKE_CASE.\n*\n* @example\n* screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n*/\nfunction screamingSnakeCase(text, { prefix = \"\", suffix = \"\" } = {}) {\n\treturn snakeCase(text, {\n\t\tprefix,\n\t\tsuffix\n\t}).toUpperCase();\n}\n//#endregion\n//#region src/cli/define.ts\n/** Returns a `CLIAdapter` with type inference. Pass a different adapter to `createCLI` to swap the CLI engine. */\nfunction defineCLIAdapter(adapter) {\n\treturn adapter;\n}\n/**\n* Returns a `CommandDefinition` with typed `values` in `run()`.\n* The callback receives `values` typed from the declared options — no casts needed.\n*/\nfunction defineCommand(def) {\n\tconst { run, ...rest } = def;\n\tif (!run) return rest;\n\treturn {\n\t\t...rest,\n\t\trun: (args) => run({\n\t\t\tvalues: args.values,\n\t\t\tpositionals: args.positionals\n\t\t})\n\t};\n}\n//#endregion\n//#region src/cli/schema.ts\n/**\n* Serializes `CommandDefinition[]` to a plain, JSON-serializable structure.\n* Use to expose CLI capabilities to AI agents or MCP tools.\n*/\nfunction getCommandSchema(defs) {\n\treturn defs.map(serializeCommand);\n}\nfunction serializeCommand(def) {\n\treturn {\n\t\tname: def.name,\n\t\tdescription: def.description,\n\t\targuments: def.arguments,\n\t\toptions: serializeOptions(def.options ?? {}),\n\t\tsubCommands: def.subCommands ? def.subCommands.map(serializeCommand) : []\n\t};\n}\nfunction serializeOptions(options) {\n\treturn Object.entries(options).map(([name, opt]) => {\n\t\treturn {\n\t\t\tname,\n\t\t\tflags: `${opt.short ? `-${opt.short}, ` : \"\"}--${name}${opt.type === \"string\" ? ` <${opt.hint ?? name}>` : \"\"}`,\n\t\t\ttype: opt.type,\n\t\t\tdescription: opt.description,\n\t\t\t...opt.default !== void 0 ? { default: opt.default } : {},\n\t\t\t...opt.hint ? { hint: opt.hint } : {},\n\t\t\t...opt.enum ? { enum: opt.enum } : {},\n\t\t\t...opt.required ? { required: opt.required } : {}\n\t\t};\n\t});\n}\n//#endregion\n//#region src/cli/help.ts\n/** Prints formatted help output for a command using its `CommandDefinition`. */\nfunction renderHelp(def, parentName) {\n\tconst schema = getCommandSchema([def])[0];\n\tconst programName = parentName ? `${parentName} ${schema.name}` : schema.name;\n\tconst argsPart = schema.arguments?.length ? ` ${schema.arguments.join(\" \")}` : \"\";\n\tconst subCmdPart = schema.subCommands.length ? \" <command>\" : \"\";\n\tconsole.log(`\\n${styleText(\"bold\", \"Usage:\")} ${programName}${argsPart}${subCmdPart} [options]\\n`);\n\tif (schema.description) console.log(` ${schema.description}\\n`);\n\tif (schema.subCommands.length) {\n\t\tconsole.log(styleText(\"bold\", \"Commands:\"));\n\t\tfor (const sub of schema.subCommands) console.log(` ${styleText(\"cyan\", sub.name.padEnd(16))}${sub.description}`);\n\t\tconsole.log();\n\t}\n\tconst options = [...schema.options, {\n\t\tname: \"help\",\n\t\tflags: \"-h, --help\",\n\t\ttype: \"boolean\",\n\t\tdescription: \"Show help\"\n\t}];\n\tconsole.log(styleText(\"bold\", \"Options:\"));\n\tfor (const opt of options) {\n\t\tconst flags = styleText(\"cyan\", opt.flags.padEnd(30));\n\t\tconst defaultPart = opt.default !== void 0 ? styleText(\"dim\", ` (default: ${opt.default})`) : \"\";\n\t\tconsole.log(` ${flags}${opt.description}${defaultPart}`);\n\t}\n\tconsole.log();\n}\n//#endregion\n//#region src/cli/adapters/nodeAdapter.ts\nfunction buildParseOptions(def) {\n\tconst result = { help: {\n\t\ttype: \"boolean\",\n\t\tshort: \"h\"\n\t} };\n\tfor (const [name, opt] of Object.entries(def.options ?? {})) result[name] = {\n\t\ttype: opt.type,\n\t\t...opt.short ? { short: opt.short } : {},\n\t\t...opt.default !== void 0 ? { default: opt.default } : {}\n\t};\n\treturn result;\n}\nasync function runCommand(def, argv, parentName) {\n\tconst parseOptions = buildParseOptions(def);\n\tlet parsed;\n\ttry {\n\t\tconst result = parseArgs({\n\t\t\targs: argv,\n\t\t\toptions: parseOptions,\n\t\t\tallowPositionals: true,\n\t\t\tstrict: false\n\t\t});\n\t\tparsed = {\n\t\t\tvalues: result.values,\n\t\t\tpositionals: result.positionals\n\t\t};\n\t} catch {\n\t\trenderHelp(def, parentName);\n\t\tprocess.exit(1);\n\t}\n\tif (parsed.values[\"help\"]) {\n\t\trenderHelp(def, parentName);\n\t\tprocess.exit(0);\n\t}\n\tfor (const [name, opt] of Object.entries(def.options ?? {})) if (opt.required && parsed.values[name] === void 0) {\n\t\tconsole.error(styleText(\"red\", `Error: --${name} is required`));\n\t\trenderHelp(def, parentName);\n\t\tprocess.exit(1);\n\t}\n\tif (!def.run) {\n\t\trenderHelp(def, parentName);\n\t\tprocess.exit(0);\n\t}\n\ttry {\n\t\tawait def.run(parsed);\n\t} catch (err) {\n\t\tconsole.error(styleText(\"red\", `Error: ${err instanceof Error ? err.message : String(err)}`));\n\t\trenderHelp(def, parentName);\n\t\tprocess.exit(1);\n\t}\n}\nfunction printRootHelp(programName, version, defs) {\n\tconsole.log(`\\n${styleText(\"bold\", \"Usage:\")} ${programName} <command> [options]\\n`);\n\tconsole.log(` Kubb generation — v${version}\\n`);\n\tconsole.log(styleText(\"bold\", \"Commands:\"));\n\tfor (const def of defs) console.log(` ${styleText(\"cyan\", def.name.padEnd(16))}${def.description}`);\n\tconsole.log();\n\tconsole.log(styleText(\"bold\", \"Options:\"));\n\tconsole.log(` ${styleText(\"cyan\", \"-v, --version\".padEnd(30))}Show version number`);\n\tconsole.log(` ${styleText(\"cyan\", \"-h, --help\".padEnd(30))}Show help`);\n\tconsole.log();\n\tconsole.log(`Run ${styleText(\"cyan\", `${programName} <command> --help`)} for command-specific help.\\n`);\n}\n/** CLI adapter using `node:util parseArgs`. No external dependencies. */\nconst nodeAdapter = defineCLIAdapter({\n\trenderHelp(def, parentName) {\n\t\trenderHelp(def, parentName);\n\t},\n\tasync run(defs, argv, opts) {\n\t\tconst { programName, defaultCommandName, version } = opts;\n\t\tconst args = argv.length >= 2 && argv[0]?.includes(\"node\") ? argv.slice(2) : argv;\n\t\tif (args[0] === \"--version\" || args[0] === \"-v\") {\n\t\t\tconsole.log(version);\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tif (args[0] === \"--help\" || args[0] === \"-h\") {\n\t\t\tprintRootHelp(programName, version, defs);\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tif (args.length === 0) {\n\t\t\tconst defaultDef = defs.find((d) => d.name === defaultCommandName);\n\t\t\tif (defaultDef?.run) await runCommand(defaultDef, [], programName);\n\t\t\telse printRootHelp(programName, version, defs);\n\t\t\treturn;\n\t\t}\n\t\tconst [first, ...rest] = args;\n\t\tconst isKnownSubcommand = defs.some((d) => d.name === first);\n\t\tlet def;\n\t\tlet commandArgv;\n\t\tlet parentName;\n\t\tif (isKnownSubcommand) {\n\t\t\tdef = defs.find((d) => d.name === first);\n\t\t\tcommandArgv = rest;\n\t\t\tparentName = programName;\n\t\t} else {\n\t\t\tdef = defs.find((d) => d.name === defaultCommandName);\n\t\t\tcommandArgv = args;\n\t\t\tparentName = programName;\n\t\t}\n\t\tif (!def) {\n\t\t\tconsole.error(`Unknown command: ${first}`);\n\t\t\tprintRootHelp(programName, version, defs);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (def.subCommands?.length) {\n\t\t\tconst [subName, ...subRest] = commandArgv;\n\t\t\tconst subDef = def.subCommands.find((s) => s.name === subName);\n\t\t\tif (subName === \"--help\" || subName === \"-h\") {\n\t\t\t\trenderHelp(def, parentName);\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t\tif (!subDef) {\n\t\t\t\trenderHelp(def, parentName);\n\t\t\t\tprocess.exit(subName ? 1 : 0);\n\t\t\t}\n\t\t\tawait runCommand(subDef, subRest, `${parentName} ${def.name}`);\n\t\t\treturn;\n\t\t}\n\t\tawait runCommand(def, commandArgv, parentName);\n\t}\n});\n//#endregion\n//#region src/cli/parse.ts\n/**\n* Create a CLI runner bound to a specific adapter.\n* Defaults to the built-in `nodeAdapter` (Node.js `node:util parseArgs`).\n*/\nfunction createCLI(options) {\n\tconst adapter = options?.adapter ?? nodeAdapter;\n\treturn { run(commands, argv, opts) {\n\t\treturn adapter.run(commands, argv, opts);\n\t} };\n}\n//#endregion\n//#region src/time.ts\n/**\n* Calculates elapsed time in milliseconds from a high-resolution start time.\n* Rounds to 2 decimal places to provide sub-millisecond precision without noise.\n*/\nfunction getElapsedMs(hrStart) {\n\tconst [seconds, nanoseconds] = process.hrtime(hrStart);\n\tconst ms = seconds * 1e3 + nanoseconds / 1e6;\n\treturn Math.round(ms * 100) / 100;\n}\n/**\n* Converts a millisecond duration into a human-readable string.\n* Adjusts units (ms, s, m s) based on the magnitude of the duration.\n*/\nfunction formatMs(ms) {\n\tif (ms >= 6e4) return `${Math.floor(ms / 6e4)}m ${(ms % 6e4 / 1e3).toFixed(1)}s`;\n\tif (ms >= 1e3) return `${(ms / 1e3).toFixed(2)}s`;\n\treturn `${Math.round(ms)}ms`;\n}\n/**\n* Convenience helper: formats the elapsed time since `hrStart` in one step.\n*/\nfunction formatHrtime(hrStart) {\n\treturn formatMs(getElapsedMs(hrStart));\n}\n//#endregion\n//#region src/colors.ts\n/**\n* Parses a CSS hex color string (`#RGB`) into its RGB channels.\n* Falls back to `255` for any channel that cannot be parsed.\n*/\nfunction parseHex(color) {\n\tconst int = Number.parseInt(color.replace(\"#\", \"\"), 16);\n\treturn Number.isNaN(int) ? {\n\t\tr: 255,\n\t\tg: 255,\n\t\tb: 255\n\t} : {\n\t\tr: int >> 16 & 255,\n\t\tg: int >> 8 & 255,\n\t\tb: int & 255\n\t};\n}\n/**\n* Returns a function that wraps a string in a 24-bit ANSI true-color escape sequence\n* for the given hex color.\n*/\nfunction hex(color) {\n\tconst { r, g, b } = parseHex(color);\n\treturn (text) => `\\x1b[38;2;${r};${g};${b}m${text}\\x1b[0m`;\n}\nfunction gradient(colorStops, text) {\n\tconst chars = text.split(\"\");\n\treturn chars.map((char, i) => {\n\t\tconst t = chars.length <= 1 ? 0 : i / (chars.length - 1);\n\t\tconst seg = Math.min(Math.floor(t * (colorStops.length - 1)), colorStops.length - 2);\n\t\tconst lt = t * (colorStops.length - 1) - seg;\n\t\tconst from = parseHex(colorStops[seg]);\n\t\tconst to = parseHex(colorStops[seg + 1]);\n\t\treturn `\\x1b[38;2;${Math.round(from.r + (to.r - from.r) * lt)};${Math.round(from.g + (to.g - from.g) * lt)};${Math.round(from.b + (to.b - from.b) * lt)}m${char}\\x1b[0m`;\n\t}).join(\"\");\n}\n/** ANSI color functions for each part of the Kubb mascot illustration. */\nconst palette = {\n\tlid: hex(\"#F55A17\"),\n\twoodTop: hex(\"#F5A217\"),\n\twoodMid: hex(\"#F58517\"),\n\twoodBase: hex(\"#B45309\"),\n\teye: hex(\"#FFFFFF\"),\n\thighlight: hex(\"#adadc6\"),\n\tblush: hex(\"#FDA4AF\")\n};\n/**\n* Generates the Kubb mascot welcome banner.\n*/\nfunction getIntro({ title, description, version, areEyesOpen }) {\n\tconst kubbVersion = gradient([\n\t\t\"#F58517\",\n\t\t\"#F5A217\",\n\t\t\"#F55A17\"\n\t], `KUBB v${version}`);\n\tconst eyeTop = areEyesOpen ? palette.eye(\"█▀█\") : palette.eye(\"───\");\n\tconst eyeBottom = areEyesOpen ? palette.eye(\"▀▀▀\") : palette.eye(\"───\");\n\treturn `\n ${palette.lid(\"▄▄▄▄▄▄▄▄▄▄▄▄▄\")}\n ${palette.woodTop(\"█ \")}${palette.highlight(\"▄▄\")}${palette.woodTop(\" \")}${palette.highlight(\"▄▄\")}${palette.woodTop(\" █\")} ${kubbVersion}\n ${palette.woodMid(\"█ \")}${eyeTop}${palette.woodMid(\" \")}${eyeTop}${palette.woodMid(\" █\")} ${styleText(\"gray\", title)}\n ${palette.woodMid(\"█ \")}${eyeBottom}${palette.woodMid(\" \")}${palette.blush(\"◡\")}${palette.woodMid(\" \")}${eyeBottom}${palette.woodMid(\" █\")} ${styleText(\"yellow\", \"➜\")} ${styleText(\"white\", description)}\n ${palette.woodBase(\"▀▀▀▀▀▀▀▀▀▀▀▀▀\")}\n`;\n}\n/** ANSI color names available for terminal output. */\nconst randomColors = [\n\t\"black\",\n\t\"red\",\n\t\"green\",\n\t\"yellow\",\n\t\"blue\",\n\t\"white\",\n\t\"magenta\",\n\t\"cyan\",\n\t\"gray\"\n];\n/**\n* Returns the text wrapped in a deterministic ANSI color derived from the text's SHA-256 hash.\n*/\nfunction randomCliColor(text) {\n\tif (!text) return \"\";\n\treturn styleText(randomColors[createHash(\"sha256\").update(text).digest().readUInt32BE(0) % randomColors.length] ?? \"white\", text);\n}\n/**\n* Formats a millisecond duration with an ANSI color based on thresholds:\n* green ≤ 500 ms · yellow ≤ 1 000 ms · red > 1 000 ms\n*/\nfunction formatMsWithColor(ms) {\n\tconst formatted = formatMs(ms);\n\tif (ms <= 500) return styleText(\"green\", formatted);\n\tif (ms <= 1e3) return styleText(\"yellow\", formatted);\n\treturn styleText(\"red\", formatted);\n}\n//#endregion\n//#region src/env.ts\n/**\n* Returns `true` when running inside a GitHub Actions workflow.\n*/\nfunction isGitHubActions() {\n\treturn !!process.env.GITHUB_ACTIONS;\n}\n/**\n* Returns `true` when the process is running in a CI environment.\n* Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n* TeamCity, Buildkite, and Azure Pipelines.\n*/\nfunction isCIEnvironment() {\n\treturn !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BITBUCKET_BUILD_NUMBER || process.env.JENKINS_URL || process.env.CIRCLECI || process.env.TRAVIS || process.env.TEAMCITY_VERSION || process.env.BUILDKITE || process.env.TF_BUILD);\n}\n/**\n* Returns `true` when the process has an interactive TTY and is not running in CI.\n*/\nfunction canUseTTY() {\n\treturn !!process.stdout.isTTY && !isCIEnvironment();\n}\n//#endregion\n//#region src/fs.ts\n/**\n* Converts all backslashes to forward slashes.\n* Extended-length Windows paths (`\\\\?\\...`) are left unchanged.\n*/\nfunction toSlash(p) {\n\tif (p.startsWith(\"\\\\\\\\?\\\\\")) return p;\n\treturn p.replaceAll(\"\\\\\", \"/\");\n}\n/**\n* Returns the relative path from `rootDir` to `filePath`, always using\n* forward slashes and prefixed with `./` when not already traversing upward.\n*/\nfunction getRelativePath(rootDir, filePath) {\n\tif (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || \"\"} ${filePath || \"\"}`);\n\tconst relativePath = posix.relative(toSlash(rootDir), toSlash(filePath));\n\treturn relativePath.startsWith(\"../\") ? relativePath : `./${relativePath}`;\n}\n/**\n* Resolves to `true` when the file or directory at `path` exists.\n* Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.\n*/\nasync function exists(path) {\n\tif (typeof Bun !== \"undefined\") return Bun.file(path).exists();\n\treturn access(path).then(() => true, () => false);\n}\n/**\n* Reads the file at `path` as a UTF-8 string.\n* Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.\n*/\nasync function read(path) {\n\tif (typeof Bun !== \"undefined\") return Bun.file(path).text();\n\treturn readFile(path, { encoding: \"utf8\" });\n}\n/** Synchronous counterpart of `read`. */\nfunction readSync(path) {\n\treturn readFileSync(path, { encoding: \"utf8\" });\n}\n/**\n* Writes `data` to `path`, trimming leading/trailing whitespace before saving.\n* Skips the write and returns `undefined` when the trimmed content is empty or\n* identical to what is already on disk.\n* Creates any missing parent directories automatically.\n* When `sanity` is `true`, re-reads the file after writing and throws if the\n* content does not match.\n*/\nasync function write(path, data, options = {}) {\n\tconst trimmed = data.trim();\n\tif (trimmed === \"\") return void 0;\n\tconst resolved = resolve(path);\n\tif (typeof Bun !== \"undefined\") {\n\t\tconst file = Bun.file(resolved);\n\t\tif ((await file.exists() ? await file.text() : null) === trimmed) return void 0;\n\t\tawait Bun.write(resolved, trimmed);\n\t\treturn trimmed;\n\t}\n\ttry {\n\t\tif (await readFile(resolved, { encoding: \"utf-8\" }) === trimmed) return void 0;\n\t} catch {}\n\tawait mkdir(dirname(resolved), { recursive: true });\n\tawait writeFile(resolved, trimmed, { encoding: \"utf-8\" });\n\tif (options.sanity) {\n\t\tconst savedData = await readFile(resolved, { encoding: \"utf-8\" });\n\t\tif (savedData !== trimmed) throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`);\n\t\treturn savedData;\n\t}\n\treturn trimmed;\n}\n/** Recursively removes `path`. Silently succeeds when `path` does not exist. */\nasync function clean(path) {\n\treturn rm(path, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n}\n//#endregion\n//#region src/jsdoc.ts\n/**\n* Builds a JSDoc comment block from an array of lines.\n* Returns `fallback` when `comments` is empty so callers always get a usable string.\n*/\nfunction buildJSDoc(comments, options = {}) {\n\tconst { indent = \" * \", suffix = \"\\n \", fallback = \" \" } = options;\n\tif (comments.length === 0) return fallback;\n\treturn `/**\\n${comments.map((c) => `${indent}${c}`).join(\"\\n\")}\\n */${suffix}`;\n}\n//#endregion\n//#region src/names.ts\n/**\n* Returns a unique name by appending an incrementing numeric suffix when the name has already been used.\n* Mutates `data` in-place as a usage counter so subsequent calls remain consistent.\n*\n* @example\n* const seen: Record<string, number> = {}\n* getUniqueName('Foo', seen) // 'Foo'\n* getUniqueName('Foo', seen) // 'Foo2'\n* getUniqueName('Foo', seen) // 'Foo3'\n*/\nfunction getUniqueName(originalName, data) {\n\tlet used = data[originalName] || 0;\n\tif (used) {\n\t\tdata[originalName] = ++used;\n\t\toriginalName += used;\n\t}\n\tdata[originalName] = 1;\n\treturn originalName;\n}\n/**\n* Registers `originalName` in `data` without altering the returned name.\n* Use this when you need to track usage frequency but always emit the original identifier.\n*/\nfunction setUniqueName(originalName, data) {\n\tlet used = data[originalName] || 0;\n\tif (used) {\n\t\tdata[originalName] = ++used;\n\t\treturn originalName;\n\t}\n\tdata[originalName] = 1;\n\treturn originalName;\n}\n//#endregion\n//#region src/network.ts\n/** Well-known stable domains used as DNS probes to check internet connectivity. */\nconst TEST_DOMAINS = [\n\t\"dns.google.com\",\n\t\"cloudflare.com\",\n\t\"one.one.one.one\"\n];\n/**\n* Returns `true` when the system has internet connectivity.\n* Uses DNS resolution against well-known stable domains as a lightweight probe.\n*/\nasync function isOnline() {\n\tfor (const domain of TEST_DOMAINS) try {\n\t\tawait promises.resolve(domain);\n\t\treturn true;\n\t} catch {}\n\treturn false;\n}\n/**\n* Executes `fn` only when the system is online. Returns `null` when offline or on error.\n*/\nasync function executeIfOnline(fn) {\n\tif (!await isOnline()) return null;\n\ttry {\n\t\treturn await fn();\n\t} catch {\n\t\treturn null;\n\t}\n}\n//#endregion\n//#region src/string.ts\n/**\n* Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n* Returns the string unchanged when no balanced quote pair is found.\n*\n* @example\n* trimQuotes('\"hello\"') // 'hello'\n* trimQuotes('hello') // 'hello'\n*/\nfunction trimQuotes(text) {\n\tif (text.length >= 2) {\n\t\tconst first = text[0];\n\t\tconst last = text[text.length - 1];\n\t\tif (first === \"\\\"\" && last === \"\\\"\" || first === \"'\" && last === \"'\" || first === \"`\" && last === \"`\") return text.slice(1, -1);\n\t}\n\treturn text;\n}\n/**\n* Escapes characters that are not allowed inside JS string literals.\n* Handles quotes, backslashes, and Unicode line terminators (U+2028 / U+2029).\n*\n* @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n*/\nfunction jsStringEscape(input) {\n\treturn `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n\t\tswitch (character) {\n\t\t\tcase \"\\\"\":\n\t\t\tcase \"'\":\n\t\t\tcase \"\\\\\": return `\\\\${character}`;\n\t\t\tcase \"\\n\": return \"\\\\n\";\n\t\t\tcase \"\\r\": return \"\\\\r\";\n\t\t\tcase \"\\u2028\": return \"\\\\u2028\";\n\t\t\tcase \"\\u2029\": return \"\\\\u2029\";\n\t\t\tdefault: return \"\";\n\t\t}\n\t});\n}\n/**\n* Returns a masked version of a string, showing only the first and last few characters.\n* Useful for logging sensitive values (tokens, keys) without exposing the full value.\n*\n* @example\n* maskString('KUBB_STUDIO-abc123-xyz789') // 'KUBB_STUDIO-…789'\n*/\nfunction maskString(value, start = 8, end = 4) {\n\tif (value.length <= start + end) return value;\n\treturn `${value.slice(0, start)}…${value.slice(-end)}`;\n}\n//#endregion\n//#region src/object.ts\n/**\n* Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.\n*\n* @example\n* stringify('hello') // '\"hello\"'\n* stringify('\"hello\"') // '\"hello\"'\n*/\nfunction stringify(value) {\n\tif (value === void 0 || value === null) return \"\\\"\\\"\";\n\treturn JSON.stringify(trimQuotes(value.toString()));\n}\n/**\n* Converts a plain object into a multiline key-value string suitable for embedding in generated code.\n* Nested objects are recursively stringified with indentation.\n*\n* @example\n* stringifyObject({ foo: 'bar', nested: { a: 1 } })\n* // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n*/\nfunction stringifyObject(value) {\n\treturn Object.entries(value).map(([key, val]) => {\n\t\tif (val !== null && typeof val === \"object\") return `${key}: {\\n ${stringifyObject(val)}\\n }`;\n\t\treturn `${key}: ${val}`;\n\t}).filter(Boolean).join(\",\\n\");\n}\n/**\n* Serializes plugin options for safe JSON transport.\n* Strips functions, symbols, and `undefined` values recursively.\n*/\nfunction serializePluginOptions(options) {\n\tif (options === null || options === void 0) return {};\n\tif (typeof options !== \"object\") return options;\n\tif (Array.isArray(options)) return options.map(serializePluginOptions);\n\tconst serialized = {};\n\tfor (const [key, value] of Object.entries(options)) {\n\t\tif (typeof value === \"function\" || typeof value === \"symbol\" || value === void 0) continue;\n\t\tserialized[key] = value !== null && typeof value === \"object\" ? serializePluginOptions(value) : value;\n\t}\n\treturn serialized;\n}\n/**\n* Converts a dot-notation path or string array into an optional-chaining accessor expression.\n*\n* @example\n* getNestedAccessor('pagination.next.id', 'lastPage')\n* // → \"lastPage?.['pagination']?.['next']?.['id']\"\n*/\nfunction getNestedAccessor(param, accessor) {\n\tconst parts = Array.isArray(param) ? param : param.split(\".\");\n\tif (parts.length === 0 || parts.length === 1 && parts[0] === \"\") return void 0;\n\treturn `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`;\n}\n//#endregion\n//#region src/packageManager.ts\nconst packageManagers = {\n\tpnpm: {\n\t\tname: \"pnpm\",\n\t\tlockFile: \"pnpm-lock.yaml\",\n\t\tinstallCommand: [\"add\", \"-D\"]\n\t},\n\tyarn: {\n\t\tname: \"yarn\",\n\t\tlockFile: \"yarn.lock\",\n\t\tinstallCommand: [\"add\", \"-D\"]\n\t},\n\tbun: {\n\t\tname: \"bun\",\n\t\tlockFile: \"bun.lockb\",\n\t\tinstallCommand: [\"add\", \"-d\"]\n\t},\n\tnpm: {\n\t\tname: \"npm\",\n\t\tlockFile: \"package-lock.json\",\n\t\tinstallCommand: [\"install\", \"--save-dev\"]\n\t}\n};\n/**\n* Detects the active package manager for the given directory.\n* Resolution order: `packageManager` field in `package.json`, then presence of a lock file.\n* Falls back to npm when no signal is found.\n*/\nfunction detectPackageManager(cwd = process.cwd()) {\n\tconst packageJsonPath = join(cwd, \"package.json\");\n\tif (existsSync(packageJsonPath)) try {\n\t\tconst pmField = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")).packageManager;\n\t\tif (typeof pmField === \"string\") {\n\t\t\tconst name = pmField.split(\"@\")[0];\n\t\t\tif (name && name in packageManagers) return packageManagers[name];\n\t\t}\n\t} catch {}\n\tfor (const pm of Object.values(packageManagers)) if (existsSync(join(cwd, pm.lockFile))) return pm;\n\treturn packageManagers.npm;\n}\n//#endregion\n//#region src/promise.ts\n/** Returns `true` when `result` is a thenable `Promise`. */\nfunction isPromise(result) {\n\treturn result !== null && result !== void 0 && typeof result[\"then\"] === \"function\";\n}\n/** Type guard for a rejected `Promise.allSettled` result with a typed `reason`. */\nfunction isPromiseRejectedResult(result) {\n\treturn result.status === \"rejected\";\n}\n//#endregion\n//#region src/regexp.ts\n/**\n* Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.\n* Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.\n* Pass `null` as the second argument to emit a `/pattern/flags` literal instead.\n*\n* @example\n* toRegExpString('^(?im)foo') // → 'new RegExp(\"foo\", \"im\")'\n* toRegExpString('^(?im)foo', null) // → '/foo/im'\n*/\nfunction toRegExpString(text, func = \"RegExp\") {\n\tconst raw = trimQuotes(text);\n\tconst match = raw.match(/^\\^(\\(\\?([igmsuy]+)\\))/i);\n\tconst replacementTarget = match?.[1] ?? \"\";\n\tconst matchedFlags = match?.[2];\n\tconst cleaned = raw.replace(/^\\\\?\\//, \"\").replace(/\\\\?\\/$/, \"\").replace(replacementTarget, \"\");\n\tconst { source, flags } = new RegExp(cleaned, matchedFlags);\n\tif (func === null) return `/${source}/${flags}`;\n\treturn `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : \"\"})`;\n}\n//#endregion\n//#region src/reserved.ts\n/**\n* JavaScript and Java reserved words.\n* @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n*/\nconst reservedWords = [\n\t\"abstract\",\n\t\"arguments\",\n\t\"boolean\",\n\t\"break\",\n\t\"byte\",\n\t\"case\",\n\t\"catch\",\n\t\"char\",\n\t\"class\",\n\t\"const\",\n\t\"continue\",\n\t\"debugger\",\n\t\"default\",\n\t\"delete\",\n\t\"do\",\n\t\"double\",\n\t\"else\",\n\t\"enum\",\n\t\"eval\",\n\t\"export\",\n\t\"extends\",\n\t\"false\",\n\t\"final\",\n\t\"finally\",\n\t\"float\",\n\t\"for\",\n\t\"function\",\n\t\"goto\",\n\t\"if\",\n\t\"implements\",\n\t\"import\",\n\t\"in\",\n\t\"instanceof\",\n\t\"int\",\n\t\"interface\",\n\t\"let\",\n\t\"long\",\n\t\"native\",\n\t\"new\",\n\t\"null\",\n\t\"package\",\n\t\"private\",\n\t\"protected\",\n\t\"public\",\n\t\"return\",\n\t\"short\",\n\t\"static\",\n\t\"super\",\n\t\"switch\",\n\t\"synchronized\",\n\t\"this\",\n\t\"throw\",\n\t\"throws\",\n\t\"transient\",\n\t\"true\",\n\t\"try\",\n\t\"typeof\",\n\t\"var\",\n\t\"void\",\n\t\"volatile\",\n\t\"while\",\n\t\"with\",\n\t\"yield\",\n\t\"Array\",\n\t\"Date\",\n\t\"hasOwnProperty\",\n\t\"Infinity\",\n\t\"isFinite\",\n\t\"isNaN\",\n\t\"isPrototypeOf\",\n\t\"length\",\n\t\"Math\",\n\t\"name\",\n\t\"NaN\",\n\t\"Number\",\n\t\"Object\",\n\t\"prototype\",\n\t\"String\",\n\t\"toString\",\n\t\"undefined\",\n\t\"valueOf\"\n];\n/**\n* Prefixes a word with `_` when it is a reserved JavaScript/Java identifier\n* or starts with a digit.\n*/\nfunction transformReservedWord(word) {\n\tconst firstChar = word.charCodeAt(0);\n\tif (word && (reservedWords.includes(word) || firstChar >= 48 && firstChar <= 57)) return `_${word}`;\n\treturn word;\n}\n/**\n* Returns `true` when `name` is a syntactically valid JavaScript variable name.\n*/\nfunction isValidVarName(name) {\n\ttry {\n\t\tnew Function(`var ${name}`);\n\t} catch {\n\t\treturn false;\n\t}\n\treturn true;\n}\n//#endregion\n//#region src/shell.ts\n/**\n* Tokenizes a shell command string, respecting single and double quotes.\n*\n* @example\n* tokenize('git commit -m \"initial commit\"')\n* // → ['git', 'commit', '-m', 'initial commit']\n*/\nfunction tokenize(command) {\n\treturn (command.match(/[^\\s\"']+|\"([^\"]*)\"|'([^']*)'/g) ?? []).map((token) => token.replace(/^[\"']|[\"']$/g, \"\"));\n}\n/**\n* Spawns `cmd` with `args` and returns a promise that settles when the child process finishes.\n*\n* Foreground mode (default) inherits the parent's stdio and rejects on non-zero exit or signal.\n* Detached mode spawns the child in its own process group, unref's it, and resolves immediately —\n* the parent can exit without waiting for the child.\n*/\nfunction spawnAsync(cmd, args, options = {}) {\n\tconst { cwd = process.cwd(), env, detached = false } = options;\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = spawn(cmd, args, {\n\t\t\tstdio: detached ? \"ignore\" : \"inherit\",\n\t\t\tcwd,\n\t\t\tenv,\n\t\t\tdetached\n\t\t});\n\t\tif (detached) {\n\t\t\tchild.unref();\n\t\t\tresolve();\n\t\t\treturn;\n\t\t}\n\t\tchild.on(\"close\", (code, signal) => {\n\t\t\tif (code === 0) resolve();\n\t\t\telse if (signal !== null) reject(/* @__PURE__ */ new Error(`\"${cmd} ${args.join(\" \")}\" was terminated by signal ${signal}`));\n\t\t\telse reject(/* @__PURE__ */ new Error(`\"${cmd} ${args.join(\" \")}\" exited with code ${code}`));\n\t\t});\n\t\tchild.on(\"error\", reject);\n\t});\n}\n//#endregion\n//#region src/token.ts\n/** Generates a cryptographically random 32-byte token encoded as a hex string. */\nfunction generateToken() {\n\treturn randomBytes(32).toString(\"hex\");\n}\n/** Returns the SHA-256 hex digest of `input`. Useful for deterministically hashing a token before storage. */\nfunction hashToken(input) {\n\treturn createHash(\"sha256\").update(input).digest(\"hex\");\n}\n//#endregion\n//#region src/urlPath.ts\n/**\n* Parses and transforms an OpenAPI/Swagger path string into various URL formats.\n*\n* @example\n* const p = new URLPath('/pet/{petId}')\n* p.URL // '/pet/:petId'\n* p.template // '`/pet/${petId}`'\n*/\nvar URLPath = class {\n\t/** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */\n\tpath;\n\t#options;\n\tconstructor(path, options = {}) {\n\t\tthis.path = path;\n\t\tthis.#options = options;\n\t}\n\t/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */\n\tget URL() {\n\t\treturn this.toURLPath();\n\t}\n\t/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */\n\tget isURL() {\n\t\ttry {\n\t\t\treturn !!new URL(this.path).href;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\t/**\n\t* Converts the OpenAPI path to a TypeScript template literal string.\n\t*\n\t* @example\n\t* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'\n\t* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'\n\t*/\n\tget template() {\n\t\treturn this.toTemplateString();\n\t}\n\t/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */\n\tget object() {\n\t\treturn this.toObject();\n\t}\n\t/** Returns a map of path parameter names, or `undefined` when the path has no parameters. */\n\tget params() {\n\t\treturn this.getParams();\n\t}\n\t#transformParam(raw) {\n\t\tconst param = isValidVarName(raw) ? raw : camelCase(raw);\n\t\treturn this.#options.casing === \"camelcase\" ? camelCase(param) : param;\n\t}\n\t/** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */\n\t#eachParam(fn) {\n\t\tfor (const match of this.path.matchAll(/\\{([^}]+)\\}/g)) {\n\t\t\tconst raw = match[1];\n\t\t\tfn(raw, this.#transformParam(raw));\n\t\t}\n\t}\n\ttoObject({ type = \"path\", replacer, stringify } = {}) {\n\t\tconst object = {\n\t\t\turl: type === \"path\" ? this.toURLPath() : this.toTemplateString({ replacer }),\n\t\t\tparams: this.getParams()\n\t\t};\n\t\tif (stringify) {\n\t\t\tif (type === \"template\") return JSON.stringify(object).replaceAll(\"'\", \"\").replaceAll(`\"`, \"\");\n\t\t\tif (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", \"\").replaceAll(`\"`, \"\")} }`;\n\t\t\treturn `{ url: '${object.url}' }`;\n\t\t}\n\t\treturn object;\n\t}\n\t/**\n\t* Converts the OpenAPI path to a TypeScript template literal string.\n\t* An optional `replacer` can transform each extracted parameter name before interpolation.\n\t*\n\t* @example\n\t* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'\n\t*/\n\ttoTemplateString({ prefix = \"\", replacer } = {}) {\n\t\treturn `\\`${prefix}${this.path.split(/\\{([^}]+)\\}/).map((part, i) => {\n\t\t\tif (i % 2 === 0) return part;\n\t\t\tconst param = this.#transformParam(part);\n\t\t\treturn `\\${${replacer ? replacer(param) : param}}`;\n\t\t}).join(\"\")}\\``;\n\t}\n\t/**\n\t* Extracts all `{param}` segments from the path and returns them as a key-value map.\n\t* An optional `replacer` transforms each parameter name in both key and value positions.\n\t* Returns `undefined` when no path parameters are found.\n\t*/\n\tgetParams(replacer) {\n\t\tconst params = {};\n\t\tthis.#eachParam((_raw, param) => {\n\t\t\tconst key = replacer ? replacer(param) : param;\n\t\t\tparams[key] = key;\n\t\t});\n\t\treturn Object.keys(params).length > 0 ? params : void 0;\n\t}\n\t/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */\n\ttoURLPath() {\n\t\treturn this.path.replace(/\\{([^}]+)\\}/g, \":$1\");\n\t}\n};\n//#endregion\nexport { AsyncEventEmitter, BuildError, URLPath, ValidationPluginError, buildJSDoc, camelCase, canUseTTY, clean, createCLI, defineCommand, detectPackageManager, executeIfOnline, exists, formatHrtime, formatMs, formatMsWithColor, generateToken, getElapsedMs, getErrorMessage, getIntro, getNestedAccessor, getRelativePath, getUniqueName, hashToken, isCIEnvironment, isGitHubActions, isPromise, isPromiseRejectedResult, isValidVarName, jsStringEscape, maskString, packageManagers, pascalCase, randomCliColor, read, readSync, screamingSnakeCase, serializePluginOptions, setUniqueName, snakeCase, spawnAsync, stringify, stringifyObject, toCause, toError, toRegExpString, tokenize, transformReservedWord, trimQuotes, write };\n\n//# sourceMappingURL=index.js.map","import { camelCase, isValidVarName } from '@internals/utils'\n\nimport { narrowSchema } from './guards.ts'\nimport type { ParameterNode, SchemaNode } from './nodes/index.ts'\nimport type { SchemaType } from './nodes/schema.ts'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'])\n\n/**\n * Returns `true` when a schema node will be represented as a plain string in generated code.\n *\n * - `string`, `uuid`, `email`, `url`, `datetime` are always plain strings.\n * - `date` and `time` are plain strings when their `representation` is `'string'` rather than `'date'`.\n */\nexport function isPlainStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n\n/**\n * Transforms the `name` field of each parameter node according to the given casing strategy.\n *\n * The original `params` array is never mutated — a new array of cloned nodes is returned.\n * When no `casing` is provided the original array is returned as-is.\n *\n * Use this before passing parameters to schema builders so that property keys\n * in the generated output match the desired casing while the original\n * `OperationNode.parameters` array remains untouched for other consumers.\n */\nexport function applyParamsCasing(params: Array<ParameterNode>, casing: 'camelcase' | undefined): Array<ParameterNode> {\n if (!casing) {\n return params\n }\n\n return params.map((param) => {\n const transformed = casing === 'camelcase' || !isValidVarName(param.name) ? camelCase(param.name) : param.name\n\n return { ...param, name: transformed }\n })\n}\n","import type { VisitorDepth } from './constants.ts'\nimport { visitorDepths, WALK_CONCURRENCY } from './constants.ts'\nimport type { Node, OperationNode, ParameterNode, PropertyNode, ResponseNode, RootNode, SchemaNode } from './nodes/index.ts'\n\n/**\n * Creates a concurrency-limiting wrapper. At most `concurrency` promises may be\n * in-flight simultaneously; additional calls are queued and dispatched as slots free.\n */\nfunction createLimit(concurrency: number) {\n let active = 0\n const queue: Array<() => void> = []\n\n function next() {\n if (active < concurrency && queue.length > 0) {\n active++\n queue.shift()!()\n }\n }\n\n return function limit<T>(fn: () => Promise<T> | T): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n queue.push(() => {\n Promise.resolve(fn())\n .then(resolve, reject)\n .finally(() => {\n active--\n next()\n })\n })\n next()\n })\n }\n}\n\ntype LimitFn = ReturnType<typeof createLimit>\n\n/**\n * Shared options for `walk`, `transform`, and `collect`.\n */\nexport type VisitorOptions = {\n depth?: VisitorDepth\n /**\n * Maximum number of sibling nodes visited concurrently inside `walk`.\n * @default 30\n */\n concurrency?: number\n}\n\n/**\n * Synchronous visitor for `transform` and `walk`.\n */\nexport type Visitor = {\n root?(node: RootNode): void | RootNode\n operation?(node: OperationNode): void | OperationNode\n schema?(node: SchemaNode): void | SchemaNode\n property?(node: PropertyNode): void | PropertyNode\n parameter?(node: ParameterNode): void | ParameterNode\n response?(node: ResponseNode): void | ResponseNode\n}\n\ntype MaybePromise<T> = T | Promise<T>\n\n/**\n * Async visitor for `walk`. Synchronous `Visitor` objects are compatible.\n */\nexport type AsyncVisitor = {\n root?(node: RootNode): MaybePromise<void | RootNode>\n operation?(node: OperationNode): MaybePromise<void | OperationNode>\n schema?(node: SchemaNode): MaybePromise<void | SchemaNode>\n property?(node: PropertyNode): MaybePromise<void | PropertyNode>\n parameter?(node: ParameterNode): MaybePromise<void | ParameterNode>\n response?(node: ResponseNode): MaybePromise<void | ResponseNode>\n}\n\n/**\n * Visitor for `collect`.\n */\nexport type CollectVisitor<T> = {\n root?(node: RootNode): T | undefined\n operation?(node: OperationNode): T | undefined\n schema?(node: SchemaNode): T | undefined\n property?(node: PropertyNode): T | undefined\n parameter?(node: ParameterNode): T | undefined\n response?(node: ResponseNode): T | undefined\n}\n\n/**\n * Returns the immediate traversable children of `node`.\n *\n * For `Schema` nodes, children (properties, items, members) are only included\n * when `recurse` is `true`; shallow traversal omits them entirely.\n */\nfunction getChildren(node: Node, recurse: boolean): Array<Node> {\n switch (node.kind) {\n case 'Root':\n return [...node.schemas, ...node.operations]\n case 'Operation':\n return [...node.parameters, ...(node.requestBody ? [node.requestBody] : []), ...node.responses]\n case 'Schema': {\n const children: Array<Node> = []\n\n if (!recurse) return []\n\n if ('properties' in node && node.properties.length > 0) children.push(...node.properties)\n if ('items' in node && node.items) children.push(...node.items)\n if ('members' in node && node.members) children.push(...node.members)\n\n return children\n }\n case 'Property':\n return [node.schema]\n case 'Parameter':\n return [node.schema]\n case 'Response':\n return node.schema ? [node.schema] : []\n }\n}\n\n/**\n * Depth-first traversal for side effects. Visitor return values are ignored.\n * Sibling nodes at each level are visited concurrently up to `options.concurrency` (default: 30).\n */\nexport async function walk(node: Node, visitor: AsyncVisitor, options: VisitorOptions = {}): Promise<void> {\n const recurse = (options.depth ?? visitorDepths.deep) === visitorDepths.deep\n const limit = createLimit(options.concurrency ?? WALK_CONCURRENCY)\n return _walk(node, visitor, recurse, limit)\n}\n\n/**\n * Internal recursive walk implementation — calls visitor then recurses into children.\n */\nasync function _walk(node: Node, visitor: AsyncVisitor, recurse: boolean, limit: LimitFn): Promise<void> {\n switch (node.kind) {\n case 'Root':\n await limit(() => visitor.root?.(node))\n break\n case 'Operation':\n await limit(() => visitor.operation?.(node))\n break\n case 'Schema':\n await limit(() => visitor.schema?.(node))\n break\n case 'Property':\n await limit(() => visitor.property?.(node))\n break\n case 'Parameter':\n await limit(() => visitor.parameter?.(node))\n break\n case 'Response':\n await limit(() => visitor.response?.(node))\n break\n }\n\n const children = getChildren(node, recurse)\n await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit)))\n}\n\n/**\n * Depth-first immutable transformation. Visitor return values replace nodes; `undefined` keeps the original.\n */\nexport function transform(node: RootNode, visitor: Visitor, options?: VisitorOptions): RootNode\nexport function transform(node: OperationNode, visitor: Visitor, options?: VisitorOptions): OperationNode\nexport function transform(node: SchemaNode, visitor: Visitor, options?: VisitorOptions): SchemaNode\nexport function transform(node: PropertyNode, visitor: Visitor, options?: VisitorOptions): PropertyNode\nexport function transform(node: ParameterNode, visitor: Visitor, options?: VisitorOptions): ParameterNode\nexport function transform(node: ResponseNode, visitor: Visitor, options?: VisitorOptions): ResponseNode\nexport function transform(node: Node, visitor: Visitor, options?: VisitorOptions): Node\nexport function transform(node: Node, visitor: Visitor, options: VisitorOptions = {}): Node {\n const recurse = (options.depth ?? visitorDepths.deep) === visitorDepths.deep\n\n switch (node.kind) {\n case 'Root': {\n let root = node\n const replaced = visitor.root?.(root)\n if (replaced) root = replaced\n\n return {\n ...root,\n schemas: root.schemas.map((s) => transform(s, visitor, options)),\n operations: root.operations.map((op) => transform(op, visitor, options)),\n }\n }\n case 'Operation': {\n let op = node\n const replaced = visitor.operation?.(op)\n if (replaced) op = replaced\n\n return {\n ...op,\n parameters: op.parameters.map((p) => transform(p, visitor, options)),\n requestBody: op.requestBody ? transform(op.requestBody, visitor, options) : undefined,\n responses: op.responses.map((r) => transform(r, visitor, options)),\n }\n }\n case 'Schema': {\n let schema = node\n const replaced = visitor.schema?.(schema)\n if (replaced) schema = replaced\n\n return {\n ...schema,\n ...('properties' in schema && recurse ? { properties: schema.properties.map((p) => transform(p, visitor, options)) } : {}),\n ...('items' in schema && recurse ? { items: schema.items?.map((i) => transform(i, visitor, options)) } : {}),\n ...('members' in schema && recurse ? { members: schema.members?.map((m) => transform(m, visitor, options)) } : {}),\n }\n }\n case 'Property': {\n let prop = node\n const replaced = visitor.property?.(prop)\n if (replaced) prop = replaced\n\n return {\n ...prop,\n schema: transform(prop.schema, visitor, options),\n }\n }\n case 'Parameter': {\n let param = node\n const replaced = visitor.parameter?.(param)\n if (replaced) param = replaced\n\n return {\n ...param,\n schema: transform(param.schema, visitor, options),\n }\n }\n case 'Response': {\n let response = node\n const replaced = visitor.response?.(response)\n if (replaced) response = replaced\n\n return {\n ...response,\n schema: response.schema ? transform(response.schema, visitor, options) : undefined,\n }\n }\n }\n}\n\n/**\n * Depth-first synchronous reduction. Collects non-`undefined` visitor return values into an array.\n */\nexport function collect<T>(node: Node, visitor: CollectVisitor<T>, options: VisitorOptions = {}): Array<T> {\n const recurse = (options.depth ?? visitorDepths.deep) === visitorDepths.deep\n const results: Array<T> = []\n\n let v: T | undefined\n switch (node.kind) {\n case 'Root':\n v = visitor.root?.(node)\n break\n case 'Operation':\n v = visitor.operation?.(node)\n break\n case 'Schema':\n v = visitor.schema?.(node)\n break\n case 'Property':\n v = visitor.property?.(node)\n break\n case 'Parameter':\n v = visitor.parameter?.(node)\n break\n case 'Response':\n v = visitor.response?.(node)\n break\n }\n if (v !== undefined) results.push(v)\n\n for (const child of getChildren(node, recurse)) {\n for (const item of collect(child, visitor, options)) {\n results.push(item)\n }\n }\n\n return results\n}\n"],"mappings":";;;;;AAWA,MAAa,gBAAgB;CAC3B,SAAS;CACT,MAAM;CACP;AAED,MAAa,YAAY;CACvB,MAAM;CACN,WAAW;CACX,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;CACX;AAED,MAAa,cAAc;CACzB,QAAQ;CAIR,QAAQ;CAIR,SAAS;CAIT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,QAAQ;CACR,OAAO;CACP,OAAO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,QAAQ,SAAS,KAAK;AAC1B;EACF,KAAK;AACH,OAAI,QAAQ,WAAW,KAAK;AAC5B;EACF,KAAK;AACH,OAAI,QAAQ,YAAY,KAAK;AAC7B;EACF,KAAK;AACH,OAAI,QAAQ,WAAW,KAAK;AAC5B;;AAEJ,KAAI,MAAM,KAAA,EAAW,SAAQ,KAAK,EAAE;AAEpC,MAAK,MAAM,SAAS,YAAY,MAAM,QAAQ,CAC5C,MAAK,MAAM,QAAQ,QAAQ,OAAO,SAAS,QAAQ,CACjD,SAAQ,KAAK,KAAK;AAItB,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["path"],"sources":["../src/constants.ts","../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/string.ts","../src/guards.ts","../src/refs.ts","../src/visitor.ts","../src/utils.ts","../src/factory.ts","../src/printer.ts","../src/resolvers.ts","../src/transformers.ts"],"sourcesContent":["import type { NodeKind } from './nodes/base.ts'\nimport type { MediaType } from './nodes/http.ts'\nimport type { HttpMethod } from './nodes/operation.ts'\nimport type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Traversal depth for AST visitor utilities.\n *\n * - `'shallow'` — visits only the immediate node, skipping children.\n * - `'deep'` — recursively visits all descendant nodes.\n */\nexport type VisitorDepth = 'shallow' | 'deep'\n\nexport const visitorDepths = {\n shallow: 'shallow',\n deep: 'deep',\n} as const satisfies Record<VisitorDepth, VisitorDepth>\n\nexport const nodeKinds = {\n input: 'Input',\n output: 'Output',\n operation: 'Operation',\n schema: 'Schema',\n property: 'Property',\n parameter: 'Parameter',\n response: 'Response',\n functionParameter: 'FunctionParameter',\n parameterGroup: 'ParameterGroup',\n functionParameters: 'FunctionParameters',\n type: 'Type',\n file: 'File',\n import: 'Import',\n export: 'Export',\n source: 'Source',\n text: 'Text',\n break: 'Break',\n} as const satisfies Record<string, NodeKind>\n\n/**\n * Schema type discriminators used by all AST schema nodes.\n *\n * These values serve as stable discriminators across the AST (e.g., `schema.type === schemaTypes.object`).\n * Grouped by category: primitives (`string`, `number`, `boolean`), structural types (`object`, `array`, `union`),\n * and format-specific types (`date`, `uuid`, `email`). Use `isScalarPrimitive()` to check for scalar types.\n */\nexport const schemaTypes = {\n /**\n * Text value.\n */\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n /**\n * Boolean value\n */\n boolean: 'boolean',\n /**\n * Explicit null value.\n */\n null: 'null',\n /**\n * Any value (no type restriction).\n */\n any: 'any',\n /**\n * Unknown value (must be narrowed before usage).\n */\n unknown: 'unknown',\n /**\n * No return value (`void`).\n */\n void: 'void',\n /**\n * Object with named properties.\n */\n object: 'object',\n /**\n * Sequential list of items.\n */\n array: 'array',\n /**\n * Fixed-length list with position-specific items.\n */\n tuple: 'tuple',\n /**\n * \"One of\" multiple schema members.\n */\n union: 'union',\n /**\n * \"All of\" multiple schema members.\n */\n intersection: 'intersection',\n /**\n * Enum schema.\n */\n enum: 'enum',\n /**\n * Reference to another schema.\n */\n ref: 'ref',\n /**\n * Calendar date (for example `2026-03-24`).\n */\n date: 'date',\n /**\n * Date-time value (for example `2026-03-24T09:00:00Z`).\n */\n datetime: 'datetime',\n /**\n * Time-only value (for example `09:00:00`).\n */\n time: 'time',\n /**\n * UUID value.\n */\n uuid: 'uuid',\n /**\n * Email address value.\n */\n email: 'email',\n /**\n * URL value.\n */\n url: 'url',\n /**\n * IPv4 address value.\n */\n ipv4: 'ipv4',\n /**\n * IPv6 address value.\n */\n ipv6: 'ipv6',\n /**\n * Binary/blob value.\n */\n blob: 'blob',\n /**\n * Impossible value (`never`).\n */\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n\nexport type ScalarPrimitive = 'string' | 'number' | 'integer' | 'bigint' | 'boolean'\n\n/**\n * Scalar primitive schema types used for union simplification and type narrowing.\n *\n * Use `isScalarPrimitive()` to safely check whether a type is a scalar primitive.\n */\nexport const SCALAR_PRIMITIVE_TYPES = new Set<ScalarPrimitive>(['string', 'number', 'integer', 'bigint', 'boolean'])\n\n/**\n * Type guard that returns `true` when `type` is a scalar primitive schema type.\n *\n * Use this to check if a schema type can be directly assigned without wrapping (e.g., `string | number | boolean`).\n */\nexport function isScalarPrimitive(type: string): type is ScalarPrimitive {\n return SCALAR_PRIMITIVE_TYPES.has(type as ScalarPrimitive)\n}\n\n/**\n * HTTP method identifiers used by operation nodes.\n *\n * Includes all standard HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE).\n */\nexport const httpMethods = {\n get: 'GET',\n post: 'POST',\n put: 'PUT',\n patch: 'PATCH',\n delete: 'DELETE',\n head: 'HEAD',\n options: 'OPTIONS',\n trace: 'TRACE',\n} as const satisfies Record<Lowercase<HttpMethod>, HttpMethod>\n\n/**\n * Default concurrency limit for `walk()` traversal utility.\n *\n * Set to 30 to balance I/O-bound resolver parallelism against event loop pressure and memory usage during large spec traversals.\n * Use `WALK_CONCURRENCY` when calling `walk()` or override for different hardware constraints.\n *\n * @example\n * ```ts\n * import { walk, WALK_CONCURRENCY } from '@kubb/ast'\n *\n * walk(root, { concurrency: WALK_CONCURRENCY, root: () => {} })\n * ```\n */\nexport const WALK_CONCURRENCY = 30\n\n/**\n * Common MIME types used in request/response content negotiation.\n *\n * Covers JSON, XML, form data, PDFs, images, audio, and video formats.\n * Use these as keys when serializing request/response bodies.\n */\nexport const mediaTypes = {\n applicationJson: 'application/json',\n applicationXml: 'application/xml',\n applicationFormUrlEncoded: 'application/x-www-form-urlencoded',\n applicationOctetStream: 'application/octet-stream',\n applicationPdf: 'application/pdf',\n applicationZip: 'application/zip',\n applicationGraphql: 'application/graphql',\n multipartFormData: 'multipart/form-data',\n textPlain: 'text/plain',\n textHtml: 'text/html',\n textCsv: 'text/csv',\n textXml: 'text/xml',\n imagePng: 'image/png',\n imageJpeg: 'image/jpeg',\n imageGif: 'image/gif',\n imageWebp: 'image/webp',\n imageSvgXml: 'image/svg+xml',\n audioMpeg: 'audio/mpeg',\n videoMp4: 'video/mp4',\n} as const satisfies Record<string, MediaType>\n","type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n *\n * Empty segments are filtered before joining. They arise when the text starts with\n * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`\n * and `'..'` transforms to an empty string). Without this filter the join would produce\n * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing\n * generated files to escape the configured output directory.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => transformPart(part, i === parts.length - 1))\n .filter(Boolean)\n .join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\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 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","/**\n * Returns a masked version of a string, showing only the first and last few characters.\n * Useful for logging sensitive values (tokens, keys) without exposing the full value.\n *\n * @example\n * maskString('KUBB_STUDIO-abc123-xyz789') // 'KUBB_STUDIO-…789'\n */\nexport function maskString(value: string, start = 8, end = 4): string {\n if (value.length <= start + end) return value\n return `${value.slice(0, start)}…${value.slice(-end)}`\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n","import type {\n FunctionParameterNode,\n FunctionParametersNode,\n InputNode,\n Node,\n NodeKind,\n OperationNode,\n OutputNode,\n ParameterGroupNode,\n ParameterNode,\n PropertyNode,\n ResponseNode,\n SchemaNode,\n SchemaNodeByType,\n} from './nodes/index.ts'\n\n/**\n * Narrows a `SchemaNode` to the variant that matches `type`.\n *\n * @example\n * ```ts\n * const schema = createSchema({ type: 'string' })\n * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | undefined\n * ```\n */\nexport function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | undefined {\n return node?.type === type ? (node as SchemaNodeByType[T]) : undefined\n}\n\nfunction isKind<T extends Node>(kind: NodeKind) {\n return (node: unknown): node is T => (node as Node).kind === kind\n}\n\n/**\n * Returns `true` when the input is an `InputNode`.\n *\n * @example\n * ```ts\n * if (isInputNode(node)) {\n * console.log(node.schemas.length)\n * }\n * ```\n */\nexport const isInputNode = isKind<InputNode>('Input')\n\n/**\n * Returns `true` when the input is an `OutputNode`.\n *\n * @example\n * ```ts\n * if (isOutputNode(node)) {\n * console.log(node.files.length)\n * }\n * ```\n */\nexport const isOutputNode = isKind<OutputNode>('Output')\n\n/**\n * Returns `true` when the input is an `OperationNode`.\n *\n * @example\n * ```ts\n * if (isOperationNode(node)) {\n * console.log(node.operationId)\n * }\n * ```\n */\nexport const isOperationNode = isKind<OperationNode>('Operation')\n\n/**\n * Returns `true` when the input is a `SchemaNode`.\n *\n * @example\n * ```ts\n * if (isSchemaNode(node)) {\n * console.log(node.type)\n * }\n * ```\n */\nexport const isSchemaNode = isKind<SchemaNode>('Schema')\n\n/**\n * Returns `true` when the input is a `PropertyNode`.\n */\nexport const isPropertyNode = isKind<PropertyNode>('Property')\n\n/**\n * Returns `true` when the input is a `ParameterNode`.\n */\nexport const isParameterNode = isKind<ParameterNode>('Parameter')\n\n/**\n * Returns `true` when the input is a `ResponseNode`.\n */\nexport const isResponseNode = isKind<ResponseNode>('Response')\n\n/**\n * Returns `true` when the input is a `FunctionParameterNode`.\n */\nexport const isFunctionParameterNode = isKind<FunctionParameterNode>('FunctionParameter')\n\n/**\n * Returns `true` when the input is a `ParameterGroupNode`.\n */\nexport const isParameterGroupNode = isKind<ParameterGroupNode>('ParameterGroup')\n\n/**\n * Returns `true` when the input is a `FunctionParametersNode`.\n */\nexport const isFunctionParametersNode = isKind<FunctionParametersNode>('FunctionParameters')\n","import type { InputNode } from './nodes/root.ts'\nimport type { SchemaNode } from './nodes/schema.ts'\n\n/**\n * Lookup map from schema name to `SchemaNode`.\n */\nexport type RefMap = Map<string, SchemaNode>\n\n/**\n * Returns the last path segment of a reference string.\n *\n * Example: `#/components/schemas/Pet` becomes `Pet`.\n *\n * @example\n * ```ts\n * extractRefName('#/components/schemas/Pet') // 'Pet'\n * ```\n */\nexport function extractRefName(ref: string): string {\n return ref.split('/').at(-1) ?? ref\n}\n\n/**\n * Builds a `RefMap` from `input.schemas` using each schema's `name`.\n *\n * Unnamed schemas are skipped.\n *\n * @example\n * ```ts\n * const refMap = buildRefMap(input)\n * const pet = refMap.get('Pet')\n * ```\n */\nexport function buildRefMap(input: InputNode): RefMap {\n const map: RefMap = new Map()\n\n for (const schema of input.schemas) {\n if (schema.name) {\n map.set(schema.name, schema)\n }\n }\n return map\n}\n\n/**\n * Resolves a schema by name from a `RefMap`.\n *\n * @example\n * ```ts\n * const petSchema = resolveRef(refMap, 'Pet')\n * ```\n */\nexport function resolveRef(refMap: RefMap, ref: string): SchemaNode | undefined {\n return refMap.get(ref)\n}\n\n/**\n * Converts a `RefMap` into a plain object.\n *\n * @example\n * ```ts\n * const refsObject = refMapToObject(refMap)\n * ```\n */\nexport function refMapToObject(refMap: RefMap): Record<string, SchemaNode> {\n return Object.fromEntries(refMap)\n}\n","import type { VisitorDepth } from './constants.ts'\nimport { visitorDepths, WALK_CONCURRENCY } from './constants.ts'\nimport { createParameter, createProperty } from './factory.ts'\nimport type { InputNode, Node, OperationNode, OutputNode, ParameterNode, PropertyNode, ResponseNode, SchemaNode } from './nodes/index.ts'\n\n/**\n * Creates a small async concurrency limiter.\n *\n * At most `concurrency` tasks are in flight at once. Extra tasks are queued.\n *\n * @example\n * ```ts\n * const limit = createLimit(2)\n * for (const task of [taskA, taskB, taskC]) {\n * await limit(() => task())\n * }\n * // only 2 tasks run at the same time\n * ```\n */\nfunction createLimit(concurrency: number) {\n let active = 0\n const queue: Array<() => void> = []\n\n function next() {\n if (active < concurrency && queue.length > 0) {\n active++\n queue.shift()!()\n }\n }\n\n return function limit<T>(fn: () => Promise<T> | T): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n queue.push(() => {\n Promise.resolve(fn())\n .then(resolve, reject)\n .finally(() => {\n active--\n next()\n })\n })\n next()\n })\n }\n}\n\ntype LimitFn = ReturnType<typeof createLimit>\n\n/**\n * Ordered mapping of `[NodeType, ParentType]` pairs.\n *\n * `ParentOf` uses this map to find parent types.\n */\ntype ParentNodeMap = [\n [InputNode, undefined],\n [OutputNode, undefined],\n [OperationNode, InputNode],\n [SchemaNode, InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode],\n [PropertyNode, SchemaNode],\n [ParameterNode, OperationNode],\n [ResponseNode, OperationNode],\n]\n\n/**\n * Resolves the parent node type for a given AST node type.\n *\n * This is used by visitor context so `ctx.parent` is correctly typed\n * for each callback.\n *\n * @example\n * ```ts\n * type InputParent = ParentOf<InputNode>\n * // undefined\n * ```\n *\n * @example\n * ```ts\n * type PropertyParent = ParentOf<PropertyNode>\n * // SchemaNode\n * ```\n *\n * @example\n * ```ts\n * type SchemaParent = ParentOf<SchemaNode>\n * // InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode\n * ```\n */\nexport type ParentOf<T extends Node, TEntries extends ReadonlyArray<[Node, unknown]> = ParentNodeMap> = TEntries extends [\n infer TEntry extends [Node, unknown],\n ...infer TRest extends ReadonlyArray<[Node, unknown]>,\n]\n ? T extends TEntry[0]\n ? TEntry[1]\n : ParentOf<T, TRest>\n : Node\n\n/**\n * Traversal context passed as the second argument to every visitor callback.\n * `parent` is typed from the current node type.\n *\n * @example\n * ```ts\n * const visitor: Visitor = {\n * schema(node, { parent }) {\n * // parent type is narrowed by node kind\n * },\n * }\n * ```\n */\nexport type VisitorContext<T extends Node = Node> = {\n /**\n * Parent node of the currently visited node.\n * For `InputNode`, this is `undefined`.\n */\n parent?: ParentOf<T>\n}\n\n/**\n * Synchronous visitor used by `transform`.\n *\n * @example\n * ```ts\n * const visitor: Visitor = {\n * operation(node) {\n * return { ...node, operationId: `x_${node.operationId}` }\n * },\n * }\n * ```\n */\nexport type Visitor = {\n input?(node: InputNode, context: VisitorContext<InputNode>): void | InputNode\n output?(node: OutputNode, context: VisitorContext<OutputNode>): void | OutputNode\n operation?(node: OperationNode, context: VisitorContext<OperationNode>): void | OperationNode\n schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): void | SchemaNode\n property?(node: PropertyNode, context: VisitorContext<PropertyNode>): void | PropertyNode\n parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): void | ParameterNode\n response?(node: ResponseNode, context: VisitorContext<ResponseNode>): void | ResponseNode\n}\n\n/**\n * Utility type for values that can be returned directly or asynchronously.\n */\ntype MaybePromise<T> = T | Promise<T>\n\n/**\n * Async visitor for `walk`. Synchronous `Visitor` objects are compatible.\n *\n * @example\n * ```ts\n * const visitor: AsyncVisitor = {\n * async operation(node) {\n * await Promise.resolve(node.operationId)\n * },\n * }\n * ```\n */\nexport type AsyncVisitor = {\n input?(node: InputNode, context: VisitorContext<InputNode>): MaybePromise<void | InputNode>\n output?(node: OutputNode, context: VisitorContext<OutputNode>): MaybePromise<void | OutputNode>\n operation?(node: OperationNode, context: VisitorContext<OperationNode>): MaybePromise<void | OperationNode>\n schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): MaybePromise<void | SchemaNode>\n property?(node: PropertyNode, context: VisitorContext<PropertyNode>): MaybePromise<void | PropertyNode>\n parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): MaybePromise<void | ParameterNode>\n response?(node: ResponseNode, context: VisitorContext<ResponseNode>): MaybePromise<void | ResponseNode>\n}\n\n/**\n * Visitor used by `collect`.\n *\n * @example\n * ```ts\n * const visitor: CollectVisitor<string> = {\n * operation(node) {\n * return node.operationId\n * },\n * }\n * ```\n */\nexport type CollectVisitor<T> = {\n input?(node: InputNode, context: VisitorContext<InputNode>): T | undefined\n output?(node: OutputNode, context: VisitorContext<OutputNode>): T | undefined\n operation?(node: OperationNode, context: VisitorContext<OperationNode>): T | undefined\n schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): T | undefined\n property?(node: PropertyNode, context: VisitorContext<PropertyNode>): T | undefined\n parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): T | undefined\n response?(node: ResponseNode, context: VisitorContext<ResponseNode>): T | undefined\n}\n\n/**\n * Options for `transform`.\n *\n * @example\n * ```ts\n * const options: TransformOptions = { depth: 'deep', schema: (node) => node }\n * ```\n *\n * @example\n * ```ts\n * // Only transform the current node, not nested children\n * const options: TransformOptions = { depth: 'shallow', schema: (node) => node }\n * ```\n */\nexport type TransformOptions = Visitor & {\n /**\n * Traversal depth (`'deep'` by default).\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Internal parent override used during recursion.\n */\n parent?: Node\n}\n\n/**\n * Options for `walk`.\n *\n * @example\n * ```ts\n * const options: WalkOptions = { depth: 'deep', concurrency: 10, root: () => {} }\n * ```\n */\nexport type WalkOptions = AsyncVisitor & {\n /**\n * Traversal depth (`'deep'` by default).\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Maximum number of sibling nodes visited concurrently.\n * @default 30\n */\n concurrency?: number\n}\n\n/**\n * Options for `collect`.\n *\n * @example\n * ```ts\n * const options: CollectOptions<string> = { depth: 'shallow', schema: () => undefined }\n * ```\n */\nexport type CollectOptions<T> = CollectVisitor<T> & {\n /**\n * Traversal depth (`'deep'` by default).\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Internal parent override used during recursion.\n */\n parent?: Node\n}\n\n/**\n * Returns the immediate traversable children of `node`.\n *\n * For `Schema` nodes, children (`properties`, `items`, `members`, and non-boolean\n * `additionalProperties`) are only included\n * when `recurse` is `true`; shallow mode skips them.\n *\n * @example\n * ```ts\n * const children = getChildren(operationNode, true)\n * // returns parameters, requestBody schema (if present), and responses\n * ```\n */\nfunction getChildren(node: Node, recurse: boolean): Array<Node> {\n switch (node.kind) {\n case 'Input':\n return [...node.schemas, ...node.operations]\n case 'Output':\n return []\n case 'Operation':\n return [...node.parameters, ...(node.requestBody?.content?.flatMap((c) => (c.schema ? [c.schema] : [])) ?? []), ...node.responses]\n case 'Schema': {\n const children: Array<Node> = []\n\n if (!recurse) return []\n\n if ('properties' in node && node.properties.length > 0) children.push(...node.properties)\n if ('items' in node && node.items) children.push(...node.items)\n if ('members' in node && node.members) children.push(...node.members)\n if ('additionalProperties' in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties)\n\n return children\n }\n case 'Property':\n return [node.schema]\n case 'Parameter':\n return [node.schema]\n case 'Response':\n return node.schema ? [node.schema] : []\n case 'FunctionParameter':\n case 'ParameterGroup':\n case 'FunctionParameters':\n case 'Type':\n return []\n default:\n return []\n }\n}\n\n/**\n * Depth-first traversal for side effects. Visitor return values are ignored.\n * Sibling nodes at each level are visited concurrently up to `options.concurrency`\n * (default: `WALK_CONCURRENCY`).\n *\n * @example\n * ```ts\n * await walk(root, {\n * operation(node) {\n * console.log(node.operationId)\n * },\n * })\n * ```\n *\n * @example\n * ```ts\n * // Visit only the current node\n * await walk(root, { depth: 'shallow', root: () => {} })\n * ```\n */\nexport async function walk(node: Node, options: WalkOptions): Promise<void> {\n const recurse = (options.depth ?? visitorDepths.deep) === visitorDepths.deep\n const limit = createLimit(options.concurrency ?? WALK_CONCURRENCY)\n\n return _walk(node, options, recurse, limit, undefined)\n}\n\nasync function _walk(node: Node, visitor: AsyncVisitor, recurse: boolean, limit: LimitFn, parent: Node | undefined): Promise<void> {\n switch (node.kind) {\n case 'Input':\n await limit(() => visitor.input?.(node, { parent: parent as ParentOf<InputNode> }))\n break\n case 'Output':\n await limit(() => visitor.output?.(node, { parent: parent as ParentOf<OutputNode> }))\n break\n case 'Operation':\n await limit(() =>\n visitor.operation?.(node, {\n parent: parent as ParentOf<OperationNode>,\n }),\n )\n break\n case 'Schema':\n await limit(() => visitor.schema?.(node, { parent: parent as ParentOf<SchemaNode> }))\n break\n case 'Property':\n await limit(() => visitor.property?.(node, { parent: parent as ParentOf<PropertyNode> }))\n break\n case 'Parameter':\n await limit(() =>\n visitor.parameter?.(node, {\n parent: parent as ParentOf<ParameterNode>,\n }),\n )\n break\n case 'Response':\n await limit(() => visitor.response?.(node, { parent: parent as ParentOf<ResponseNode> }))\n break\n case 'FunctionParameter':\n case 'ParameterGroup':\n case 'FunctionParameters':\n break\n }\n\n const children = getChildren(node, recurse)\n for (const child of children) {\n await _walk(child, visitor, recurse, limit, node)\n }\n}\n\n/**\n * Runs a depth-first immutable transform.\n *\n * If a visitor returns a node, it replaces the current node.\n * If it returns `undefined`, the current node stays the same.\n *\n * @example\n * ```ts\n * const next = transform(root, {\n * operation(node) {\n * return { ...node, operationId: `prefixed_${node.operationId}` }\n * },\n * })\n * ```\n *\n * @example\n * ```ts\n * // Shallow mode: only transform the input node\n * const next = transform(root, { depth: 'shallow', root: (node) => node })\n * ```\n */\nexport function transform(node: InputNode, options: TransformOptions): InputNode\nexport function transform(node: OutputNode, options: TransformOptions): OutputNode\nexport function transform(node: OperationNode, options: TransformOptions): OperationNode\nexport function transform(node: SchemaNode, options: TransformOptions): SchemaNode\nexport function transform(node: PropertyNode, options: TransformOptions): PropertyNode\nexport function transform(node: ParameterNode, options: TransformOptions): ParameterNode\nexport function transform(node: ResponseNode, options: TransformOptions): ResponseNode\nexport function transform(node: Node, options: TransformOptions): Node\nexport function transform(node: Node, options: TransformOptions): Node {\n const { depth, parent, ...visitor } = options\n const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep\n\n switch (node.kind) {\n case 'Input': {\n let input = node\n const replaced = visitor.input?.(input, {\n parent: parent as ParentOf<InputNode>,\n })\n if (replaced) input = replaced\n\n return {\n ...input,\n schemas: input.schemas.map((s) => transform(s, { ...options, parent: input })),\n operations: input.operations.map((op) => transform(op, { ...options, parent: input })),\n }\n }\n case 'Output': {\n let output = node\n const replaced = visitor.output?.(output, {\n parent: parent as ParentOf<OutputNode>,\n })\n if (replaced) output = replaced\n\n return output\n }\n case 'Operation': {\n let op = node\n const replaced = visitor.operation?.(op, {\n parent: parent as ParentOf<OperationNode>,\n })\n if (replaced) op = replaced\n\n return {\n ...op,\n parameters: op.parameters.map((p) => transform(p, { ...options, parent: op })),\n requestBody: op.requestBody\n ? {\n ...op.requestBody,\n content: op.requestBody.content?.map((c) => ({\n ...c,\n schema: c.schema ? transform(c.schema, { ...options, parent: op }) : undefined,\n })),\n }\n : undefined,\n responses: op.responses.map((r) => transform(r, { ...options, parent: op })),\n }\n }\n case 'Schema': {\n let schema = node\n const replaced = visitor.schema?.(schema, {\n parent: parent as ParentOf<SchemaNode>,\n })\n if (replaced) schema = replaced\n\n const childOptions = { ...options, parent: schema }\n\n return {\n ...schema,\n ...('properties' in schema && recurse\n ? {\n properties: schema.properties.map((p) => transform(p, childOptions)),\n }\n : {}),\n ...('items' in schema && recurse ? { items: schema.items?.map((i) => transform(i, childOptions)) } : {}),\n ...('members' in schema && recurse ? { members: schema.members?.map((m) => transform(m, childOptions)) } : {}),\n ...('additionalProperties' in schema && recurse && schema.additionalProperties && schema.additionalProperties !== true\n ? {\n additionalProperties: transform(schema.additionalProperties, childOptions),\n }\n : {}),\n } as SchemaNode\n }\n case 'Property': {\n let prop = node\n const replaced = visitor.property?.(prop, {\n parent: parent as ParentOf<PropertyNode>,\n })\n if (replaced) prop = replaced\n\n return createProperty({\n ...prop,\n schema: transform(prop.schema, { ...options, parent: prop }),\n })\n }\n case 'Parameter': {\n let param = node\n const replaced = visitor.parameter?.(param, {\n parent: parent as ParentOf<ParameterNode>,\n })\n if (replaced) param = replaced\n\n return createParameter({\n ...param,\n schema: transform(param.schema, { ...options, parent: param }),\n })\n }\n case 'Response': {\n let response = node\n const replaced = visitor.response?.(response, {\n parent: parent as ParentOf<ResponseNode>,\n })\n if (replaced) response = replaced\n\n return {\n ...response,\n schema: transform(response.schema, { ...options, parent: response }),\n }\n }\n case 'FunctionParameter':\n case 'ParameterGroup':\n case 'FunctionParameters':\n case 'Type':\n return node\n default:\n return node\n }\n}\n/**\n * Runs a depth-first synchronous collection pass.\n *\n * Non-`undefined` values returned by visitor callbacks are appended to the result.\n *\n * @example\n * ```ts\n * const ids = collect(root, {\n * operation(node) {\n * return node.operationId\n * },\n * })\n * ```\n *\n * @example\n * ```ts\n * // Collect from only the current node\n * const values = collect(root, { depth: 'shallow', root: () => 'root' })\n * ```\n */\nexport function collect<T>(node: Node, options: CollectOptions<T>): Array<T> {\n const { depth, parent, ...visitor } = options\n const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep\n const results: Array<T> = []\n\n let v: T | undefined\n switch (node.kind) {\n case 'Input':\n v = visitor.input?.(node, { parent: parent as ParentOf<InputNode> })\n break\n case 'Output':\n v = visitor.output?.(node, { parent: parent as ParentOf<OutputNode> })\n break\n case 'Operation':\n v = visitor.operation?.(node, {\n parent: parent as ParentOf<OperationNode>,\n })\n break\n case 'Schema':\n v = visitor.schema?.(node, { parent: parent as ParentOf<SchemaNode> })\n break\n case 'Property':\n v = visitor.property?.(node, {\n parent: parent as ParentOf<PropertyNode>,\n })\n break\n case 'Parameter':\n v = visitor.parameter?.(node, {\n parent: parent as ParentOf<ParameterNode>,\n })\n break\n case 'Response':\n v = visitor.response?.(node, {\n parent: parent as ParentOf<ResponseNode>,\n })\n break\n case 'FunctionParameter':\n case 'ParameterGroup':\n case 'FunctionParameters':\n break\n }\n if (v !== undefined) results.push(v)\n\n for (const child of getChildren(node, recurse)) {\n for (const item of collect(child, { ...options, parent: node })) {\n results.push(item)\n }\n }\n\n return results\n}\n","import { camelCase, isValidVarName } from '@internals/utils'\n\nimport { createFunctionParameter, createFunctionParameters, createParameterGroup, createParamsType, createProperty, createSchema } from './factory.ts'\nimport { narrowSchema } from './guards.ts'\nimport type {\n CodeNode,\n ExportNode,\n FunctionParameterNode,\n FunctionParametersNode,\n ImportNode,\n OperationNode,\n ParameterGroupNode,\n ParameterNode,\n ParamsTypeNode,\n SchemaNode,\n SourceNode,\n} from './nodes/index.ts'\nimport type { SchemaType } from './nodes/schema.ts'\nimport { extractRefName } from './refs.ts'\nimport { collect } from './visitor.ts'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)\n\n/**\n * Merges a ref node with its resolved schema, giving usage-site fields precedence.\n *\n * Usage-site fields (`description`, `readOnly`, `nullable`, `deprecated`) on the ref node\n * override the same fields in the resolved `node.schema`. Non-ref nodes are returned unchanged.\n *\n * @example\n * ```ts\n * // Ref with description override\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })\n * const merged = syncSchemaRef(ref) // merges with resolved Pet schema\n * ```\n */\nexport function syncSchemaRef(node: SchemaNode): SchemaNode {\n const ref = narrowSchema(node, 'ref')\n\n if (!ref) return node\n if (!ref.schema) return node\n\n const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref\n\n // Filter out undefined override values so they don't shadow the resolved schema's fields.\n const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== undefined))\n\n return createSchema({ ...ref.schema, ...definedOverrides })\n}\n\n/**\n * Type guard that returns `true` when a schema emits as a plain `string` type.\n *\n * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`\n * types, returns `true` only when `representation` is `'string'` rather than `'date'`.\n */\nexport function isStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n\n/**\n * Applies casing rules to parameter names and returns a new parameter array.\n *\n * Use this before passing parameters to schema builders so output property keys match\n * the desired casing while preserving `OperationNode.parameters` for other consumers.\n * The input array is not mutated. When `casing` is not set, the original array is returned unchanged.\n */\nexport function caseParams(params: Array<ParameterNode>, casing: 'camelcase' | undefined): Array<ParameterNode> {\n if (!casing) {\n return params\n }\n\n return params.map((param) => {\n const transformed = casing === 'camelcase' || !isValidVarName(param.name) ? camelCase(param.name) : param.name\n\n return { ...param, name: transformed }\n })\n}\n\n/**\n * Creates a single-property object schema used as a discriminator literal.\n *\n * @example\n * ```ts\n * createDiscriminantNode({ propertyName: 'type', value: 'dog' })\n * // -> { type: 'object', properties: [{ name: 'type', required: true, schema: enum('dog') }] }\n * ```\n */\nexport function createDiscriminantNode({ propertyName, value }: { propertyName: string; value: string }): SchemaNode {\n return createSchema({\n type: 'object',\n primitive: 'object',\n properties: [\n createProperty({\n name: propertyName,\n schema: createSchema({\n type: 'enum',\n primitive: 'string',\n enumValues: [value],\n }),\n required: true,\n }),\n ],\n })\n}\n\n/**\n * Named type for a group of parameters (query or header) emitted as a single typed parameter.\n */\nexport type ParamGroupType = {\n /**\n * TypeNode for the group type.\n */\n type: ParamsTypeNode\n /**\n * Whether the parameter group is optional.\n */\n optional: boolean\n}\n\n/**\n * Resolver interface for {@link createOperationParams}.\n *\n * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.\n */\nexport type OperationParamsResolver = {\n /**\n * Resolves the type name for an individual parameter.\n *\n * @example Individual path parameter name\n * `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`\n */\n resolveParamName(node: OperationNode, param: ParameterNode): string\n /**\n * Resolves the request body type name.\n *\n * @example Request body type name\n * `resolver.resolveDataName(node) // → 'CreatePetData'`\n */\n resolveDataName(node: OperationNode): string\n /**\n * Resolves the grouped path parameters type name.\n * When the return value equals `resolveParamName`, no indexed access is emitted.\n *\n * @example Grouped path params type name\n * `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`\n */\n resolvePathParamsName(node: OperationNode, param: ParameterNode): string\n /**\n * Resolves the grouped query parameters type name.\n * When the return value equals `resolveParamName`, an inline struct type is emitted instead.\n *\n * @example Grouped query params type name\n * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`\n */\n resolveQueryParamsName(node: OperationNode, param: ParameterNode): string\n /**\n * Resolves the grouped header parameters type name.\n * When the return value equals `resolveParamName`, an inline struct type is emitted instead.\n *\n * @example Grouped header params type name\n * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`\n */\n resolveHeaderParamsName(node: OperationNode, param: ParameterNode): string\n}\n\n/**\n * Options for {@link createOperationParams}.\n */\nexport type CreateOperationParamsOptions = {\n /**\n * How all operation parameters are grouped in the function signature.\n * - `'object'` wraps all params into a single destructured object `{ petId, data, params }`\n * - `'inline'` emits each param category as a separate top-level parameter\n */\n paramsType: 'object' | 'inline'\n /**\n * How path parameters are emitted when `paramsType` is `'inline'`.\n * - `'object'` groups them as `{ petId, storeId }: PathParams`\n * - `'inline'` spreads them as individual parameters `petId: string, storeId: string`\n * - `'inlineSpread'` emits a single rest parameter `...pathParams: PathParams`\n */\n pathParamsType: 'object' | 'inline' | 'inlineSpread'\n /**\n * Converts parameter names to camelCase before output.\n */\n paramsCasing?: 'camelcase'\n /**\n * Resolver for parameter and request body type names.\n * Pass `ResolverTs` from `@kubb/plugin-ts` directly.\n * When omitted, falls back to the schema primitive or `'unknown'`.\n */\n resolver?: OperationParamsResolver\n /**\n * Default value for the path parameters binding when `pathParamsType` is `'object'`.\n * Falls back to `'{}'` when all path params are optional.\n */\n pathParamsDefault?: string\n /**\n * Extra parameters appended after the standard operation parameters.\n *\n * @example Plugin-specific trailing parameter\n * ```ts\n * extraParams: [createFunctionParameter({ name: 'options', type: 'Partial<RequestOptions>', default: '{}' })]\n * ```\n */\n extraParams?: Array<FunctionParameterNode | ParameterGroupNode>\n /**\n * Override the default parameter names used for body, query, header, and rest-path groups.\n *\n * Useful when targeting languages or frameworks with different naming conventions.\n *\n * @default { data: 'data', params: 'params', headers: 'headers', path: 'pathParams' }\n */\n paramNames?: {\n /**\n * Name for the request body parameter.\n * @default 'data'\n */\n data?: string\n /**\n * Name for the query parameters group parameter.\n * @default 'params'\n */\n params?: string\n /**\n * Name for the header parameters group parameter.\n * @default 'headers'\n */\n headers?: string\n /**\n * Name for the rest path-parameters parameter when `pathParamsType` is `'inlineSpread'`.\n * @default 'pathParams'\n */\n path?: string\n }\n /**\n * Applies a uniform transformation to every resolved type name before it is used\n * in a parameter node. Use this for framework-level type wrappers.\n *\n * @example Vue Query — wrap every parameter type with `MaybeRefOrGetter`\n * `typeWrapper: (t) => \\`MaybeRefOrGetter<${t}>\\``\n */\n typeWrapper?: (type: string) => string\n}\n\nfunction resolveParamsType({\n node,\n param,\n resolver,\n}: {\n node: OperationNode\n param: ParameterNode\n resolver: OperationParamsResolver | undefined\n}): ParamsTypeNode {\n if (!resolver) {\n return createParamsType({\n variant: 'reference',\n name: param.schema.primitive ?? 'unknown',\n })\n }\n\n const individualName = resolver.resolveParamName(node, param)\n\n const groupLocation = param.in === 'path' || param.in === 'query' || param.in === 'header' ? param.in : undefined\n\n const groupResolvers = {\n path: resolver.resolvePathParamsName,\n query: resolver.resolveQueryParamsName,\n header: resolver.resolveHeaderParamsName,\n } as const\n\n const groupName = groupLocation ? groupResolvers[groupLocation].call(resolver, node, param) : undefined\n\n if (groupName && groupName !== individualName) {\n return createParamsType({\n variant: 'member',\n base: groupName,\n key: param.name,\n })\n }\n\n return createParamsType({ variant: 'reference', name: individualName })\n}\n\n/**\n * Converts an `OperationNode` into function parameters for code generation.\n *\n * Centralizes parameter grouping logic for all plugins. Provide a `resolver` for type name resolution\n * and `extraParams` for plugin-specific trailing parameters (e.g., `options` objects).\n * Supports three grouping modes: `object` (single destructured param), `inline` (separate params),\n * and `inlineSpread` (rest parameter). Use `CreateOperationParamsOptions` to fine-tune output.\n */\nexport function createOperationParams(node: OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode {\n const { paramsType, pathParamsType, paramsCasing, resolver, pathParamsDefault, extraParams = [], paramNames, typeWrapper } = options\n\n const dataName = paramNames?.data ?? 'data'\n const paramsName = paramNames?.params ?? 'params'\n const headersName = paramNames?.headers ?? 'headers'\n const pathName = paramNames?.path ?? 'pathParams'\n\n const wrapType = (type: string): ParamsTypeNode =>\n createParamsType({\n variant: 'reference',\n name: typeWrapper ? typeWrapper(type) : type,\n })\n // Only reference-variant TypeNodes are wrapped — they hold a plain type name string that needs casing applied.\n // Member and struct TypeNodes are pre-resolved structured expressions and are passed through unchanged.\n const wrapTypeNode = (type: ParamsTypeNode): ParamsTypeNode => (type.kind === 'ParamsType' && type.variant === 'reference' ? wrapType(type.name) : type)\n\n const casedParams = caseParams(node.parameters, paramsCasing)\n const pathParams = casedParams.filter((p) => p.in === 'path')\n const queryParams = casedParams.filter((p) => p.in === 'query')\n const headerParams = casedParams.filter((p) => p.in === 'header')\n\n const bodyType = node.requestBody?.content?.[0]?.schema ? wrapType(resolver?.resolveDataName(node) ?? 'unknown') : undefined\n const bodyRequired = node.requestBody?.required ?? false\n\n const queryGroupType = resolver\n ? resolveGroupType({\n node,\n params: queryParams,\n groupMethod: resolver.resolveQueryParamsName,\n resolver,\n })\n : undefined\n const headerGroupType = resolver\n ? resolveGroupType({\n node,\n params: headerParams,\n groupMethod: resolver.resolveHeaderParamsName,\n resolver,\n })\n : undefined\n\n const params: Array<FunctionParameterNode | ParameterGroupNode> = []\n\n if (paramsType === 'object') {\n const children: Array<FunctionParameterNode> = [\n ...pathParams.map((p) => {\n const type = resolveParamsType({ node, param: p, resolver })\n return createFunctionParameter({\n name: p.name,\n type: wrapTypeNode(type),\n optional: !p.required,\n })\n }),\n ...(bodyType\n ? [\n createFunctionParameter({\n name: dataName,\n type: bodyType,\n optional: !bodyRequired,\n }),\n ]\n : []),\n ...buildGroupParam({\n name: paramsName,\n node,\n params: queryParams,\n groupType: queryGroupType,\n resolver,\n wrapType,\n }),\n ...buildGroupParam({\n name: headersName,\n node,\n params: headerParams,\n groupType: headerGroupType,\n resolver,\n wrapType,\n }),\n ]\n\n if (children.length) {\n params.push(\n createParameterGroup({\n properties: children,\n default: children.every((c) => c.optional) ? '{}' : undefined,\n }),\n )\n }\n } else {\n if (pathParams.length) {\n if (pathParamsType === 'inlineSpread') {\n const spreadType = resolver?.resolvePathParamsName(node, pathParams[0]!) ?? undefined\n params.push(\n createFunctionParameter({\n name: pathName,\n type: spreadType ? wrapType(spreadType) : undefined,\n rest: true,\n }),\n )\n } else {\n const pathChildren = pathParams.map((p) => {\n const type = resolveParamsType({ node, param: p, resolver })\n return createFunctionParameter({\n name: p.name,\n type: wrapTypeNode(type),\n optional: !p.required,\n })\n })\n params.push(\n createParameterGroup({\n properties: pathChildren,\n inline: pathParamsType === 'inline',\n default: pathParamsDefault ?? (pathChildren.every((c) => c.optional) ? '{}' : undefined),\n }),\n )\n }\n }\n\n if (bodyType) {\n params.push(\n createFunctionParameter({\n name: dataName,\n type: bodyType,\n optional: !bodyRequired,\n }),\n )\n }\n\n params.push(\n ...buildGroupParam({\n name: paramsName,\n node,\n params: queryParams,\n groupType: queryGroupType,\n resolver,\n wrapType,\n }),\n )\n params.push(\n ...buildGroupParam({\n name: headersName,\n node,\n params: headerParams,\n groupType: headerGroupType,\n resolver,\n wrapType,\n }),\n )\n }\n\n params.push(...extraParams)\n\n return createFunctionParameters({ params })\n}\n\n/**\n * Builds a single {@link FunctionParameterNode} for a query or header group.\n * Returns an empty array when there are no params to emit.\n *\n * If a pre-resolved `groupType` is provided it emits `name: GroupType`.\n * Otherwise, it builds an inline struct from the individual params.\n */\nfunction buildGroupParam({\n name,\n node,\n params,\n groupType,\n resolver,\n wrapType,\n}: {\n name: string\n node: OperationNode\n params: Array<ParameterNode>\n groupType: ParamGroupType | undefined\n resolver: OperationParamsResolver | undefined\n wrapType: (type: string) => ParamsTypeNode\n}): Array<FunctionParameterNode> {\n if (groupType) {\n const type = groupType.type.kind === 'ParamsType' && groupType.type.variant === 'reference' ? wrapType(groupType.type.name) : groupType.type\n return [createFunctionParameter({ name, type, optional: groupType.optional })]\n }\n if (params.length) {\n return [\n createFunctionParameter({\n name,\n type: toStructType({ node, params, resolver }),\n optional: params.every((p) => !p.required),\n }),\n ]\n }\n return []\n}\n\n/**\n * Derives a {@link ParamGroupType} from the resolver's group method.\n * Returns `undefined` when the group name equals the individual param name (no real group).\n */\nfunction resolveGroupType({\n node,\n params,\n groupMethod,\n resolver,\n}: {\n node: OperationNode\n params: Array<ParameterNode>\n groupMethod: (_node: OperationNode, _param: ParameterNode) => string\n resolver: OperationParamsResolver\n}): ParamGroupType | undefined {\n if (!params.length) {\n return undefined\n }\n const firstParam = params[0]!\n const groupName = groupMethod.call(resolver, node, firstParam)\n if (groupName === resolver.resolveParamName(node, firstParam)) {\n return undefined\n }\n const allOptional = params.every((p) => !p.required)\n return {\n type: createParamsType({ variant: 'reference', name: groupName }),\n optional: allOptional,\n }\n}\n\n/**\n * Builds a {@link TypeNode} with `variant: 'struct'` for an inline anonymous type grouping named fields.\n *\n * Used when query or header parameters have no dedicated group type name.\n * Each language printer renders this appropriately (TypeScript: `{ petId: string; name?: string }`).\n */\nfunction toStructType({\n node,\n params,\n resolver,\n}: {\n node: OperationNode\n params: Array<ParameterNode>\n resolver: OperationParamsResolver | undefined\n}): ParamsTypeNode {\n return createParamsType({\n variant: 'struct',\n properties: params.map((p) => ({\n name: p.name,\n optional: !p.required,\n type: resolveParamsType({ node, param: p, resolver }),\n })),\n })\n}\n\nfunction sourceKey(source: SourceNode): string {\n const nameKey = source.name ?? extractStringsFromNodes(source.nodes)\n return `${nameKey}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}`\n}\n\nfunction pathTypeKey(path: string, isTypeOnly: boolean | undefined): string {\n return `${path}:${isTypeOnly ?? false}`\n}\n\nfunction exportKey(path: string, name: string | undefined, isTypeOnly: boolean | undefined, asAlias: boolean | undefined): string {\n return `${path}:${name ?? ''}:${isTypeOnly ?? false}:${asAlias ?? ''}`\n}\n\nfunction importKey(path: string, name: string | undefined, isTypeOnly: boolean | undefined): string {\n return `${path}:${name ?? ''}:${isTypeOnly ?? false}`\n}\n\n/**\n * Computes a multi-level sort key for exports and imports:\n * non-array names first (wildcards/namespace aliases); type-only before value; alphabetical path; unnamed before named.\n */\nfunction sortKey(node: { name?: string | Array<unknown>; isTypeOnly?: boolean; path: string }): string {\n const isArray = Array.isArray(node.name) ? '1' : '0'\n const typeOnly = node.isTypeOnly ? '0' : '1'\n const hasName = node.name != null ? '1' : '0'\n const name = Array.isArray(node.name) ? [...node.name].sort().join('\\0') : (node.name ?? '')\n return `${isArray}:${typeOnly}:${node.path}:${hasName}:${name}`\n}\n\n/**\n * Deduplicates and merges `SourceNode` objects by `name + isExportable + isTypeOnly`.\n *\n * Unnamed sources are deduplicated by object reference. Returns a deduplicated array in original order.\n */\nexport function combineSources(sources: Array<SourceNode>): Array<SourceNode> {\n const seen = new Map<string, SourceNode>()\n for (const source of sources) {\n const key = sourceKey(source)\n if (!seen.has(key)) seen.set(key, source)\n }\n return [...seen.values()]\n}\n\n/**\n * Deduplicates and merges `ExportNode` objects by path and type.\n *\n * Named exports with the same path and `isTypeOnly` flag have their names merged into a single export.\n * Non-array exports are deduplicated by exact identity. Returns a sorted, deduplicated array.\n */\nexport function combineExports(exports: Array<ExportNode>): Array<ExportNode> {\n const result: Array<ExportNode> = []\n // Accumulates array-named exports keyed by `path:isTypeOnly` for name-merging\n const namedByPath = new Map<string, ExportNode>()\n // Deduplicates non-array exports by their exact identity\n const seen = new Set<string>()\n\n // Precompute sort keys once — avoids recomputing per comparison.\n const keyed = exports.map((node) => ({ node, key: sortKey(node) }))\n keyed.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n\n for (const { node: curr } of keyed) {\n const { name, path, isTypeOnly, asAlias } = curr\n\n if (Array.isArray(name)) {\n if (!name.length) continue\n\n const key = pathTypeKey(path, isTypeOnly)\n const existing = namedByPath.get(key)\n\n if (existing && Array.isArray(existing.name)) {\n const merged = new Set(existing.name)\n for (const n of name) merged.add(n)\n existing.name = [...merged]\n } else {\n const newItem: ExportNode = { ...curr, name: [...new Set(name)] }\n result.push(newItem)\n namedByPath.set(key, newItem)\n }\n } else {\n const key = exportKey(path, name, isTypeOnly, asAlias)\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n }\n\n return result\n}\n\n/**\n * Deduplicates and merges `ImportNode` objects, filtering out unused imports.\n *\n * Retains imports that are referenced in `source` or re-exported. Imports with the same path and\n * `isTypeOnly` flag have their names merged. Returns a sorted, deduplicated, filtered array.\n *\n * @note Use this when combining imports from multiple files to avoid duplicate declarations.\n */\nexport function combineImports(imports: Array<ImportNode>, exports: Array<ExportNode>, source?: string): Array<ImportNode> {\n // Build a lookup of all exported names to retain imports that are re-exported\n const exportedNames = new Set(exports.flatMap((e) => (Array.isArray(e.name) ? e.name : e.name ? [e.name] : [])))\n const isUsed = (importName: string): boolean => !source || source.includes(importName) || exportedNames.has(importName)\n\n const result: Array<ImportNode> = []\n // Accumulates array-named imports keyed by `path:isTypeOnly` for name-merging\n const namedByPath = new Map<string, ImportNode>()\n // Deduplicates non-array imports by their exact identity\n const seen = new Set<string>()\n\n // Precompute sort keys once — avoids recomputing per comparison.\n const keyed = imports.map((node) => ({ node, key: sortKey(node) }))\n keyed.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n\n for (const { node: curr } of keyed) {\n if (curr.path === curr.root) continue\n\n const { path, isTypeOnly } = curr\n let { name } = curr\n\n if (Array.isArray(name)) {\n name = [...new Set(name)].filter((item) => (typeof item === 'string' ? isUsed(item) : isUsed(item.propertyName)))\n if (!name.length) continue\n\n const key = pathTypeKey(path, isTypeOnly)\n const existing = namedByPath.get(key)\n\n if (existing && Array.isArray(existing.name)) {\n const merged = new Set(existing.name)\n for (const n of name) merged.add(n)\n existing.name = [...merged]\n } else {\n const newItem: ImportNode = { ...curr, name }\n result.push(newItem)\n namedByPath.set(key, newItem)\n }\n } else {\n if (name && !isUsed(name)) continue\n\n const key = importKey(path, name, isTypeOnly)\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n }\n\n return result\n}\n\n/**\n * Extracts all string content from a `CodeNode` tree recursively.\n *\n * Collects text node values, identifier references in string fields (`params`, `generics`, `returnType`, `type`),\n * and nested node content. Used internally to build the full source string for import filtering.\n */\nexport function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string {\n if (!nodes?.length) return ''\n return nodes\n .map((node) => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return node as string\n if (node.kind === 'Text') return node.value\n if (node.kind === 'Break') return ''\n if (node.kind === 'Jsx') return node.value\n const parts: string[] = []\n if ('params' in node && node.params) parts.push(node.params)\n if ('generics' in node && node.generics) parts.push(Array.isArray(node.generics) ? node.generics.join(', ') : node.generics)\n if ('returnType' in node && node.returnType) parts.push(node.returnType)\n if ('type' in node && typeof node.type === 'string') parts.push(node.type)\n const nested = extractStringsFromNodes(node.nodes)\n if (nested) parts.push(nested)\n return parts.join('\\n')\n })\n .filter(Boolean)\n .join('\\n')\n}\n\n/**\n * Resolves the schema name of a ref node, falling back through `ref` → `name` → nested `schema.name`.\n *\n * Returns `undefined` for non-ref nodes or when no name can be resolved. Use this to get a schema's\n * identifier for type definitions or error messages.\n *\n * @example\n * ```ts\n * resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' })\n * // => 'Pet'\n * ```\n */\nexport function resolveRefName(node: SchemaNode | undefined): string | undefined {\n if (!node || node.type !== 'ref') return undefined\n if (node.ref) return extractRefName(node.ref) ?? node.name ?? node.schema?.name ?? undefined\n\n return node.name ?? node.schema?.name ?? undefined\n}\n\n/**\n * Collects every named schema referenced (transitively) from a node via ref edges.\n *\n * Refs are followed by name only — the resolved `node.schema` is not traversed inline.\n * Use this to determine schema dependencies, build reference graphs, or detect what schemas need to be emitted.\n *\n * @note Returns a Set of schema names for efficient membership testing.\n */\nexport function collectReferencedSchemaNames(node: SchemaNode | undefined, out: Set<string> = new Set()): Set<string> {\n if (!node) return out\n collect<void>(node, {\n schema(child) {\n if (child.type === 'ref') {\n const name = resolveRefName(child)\n\n if (name) out.add(name)\n }\n return undefined\n },\n })\n return out\n}\n\n/**\n * Identifies all schemas that participate in circular dependency chains, including direct self-loops.\n *\n * Returns a Set of schema names with circular dependencies. Use this to wrap recursive schema positions\n * in deferred constructs (lazy getter, `z.lazy(() => …)`) to prevent infinite recursion when generated code runs.\n * Refs are followed by name only, keeping the algorithm linear in the schema graph size.\n *\n * @note Call this once on the full schema graph, then use `containsCircularRef()` to check individual schemas.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, Set<string>>()\n\n for (const schema of schemas) {\n if (!schema.name) continue\n graph.set(schema.name, collectReferencedSchemaNames(schema))\n }\n\n const circular = new Set<string>()\n for (const start of graph.keys()) {\n const visited = new Set<string>()\n const stack: string[] = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) {\n circular.add(start)\n break\n }\n if (visited.has(node)) continue\n visited.add(node)\n\n const next = graph.get(node)\n if (next) for (const r of next) stack.push(r)\n }\n }\n\n return circular\n}\n\n/**\n * Type guard returning `true` when a schema or anything nested within it contains a ref to a circular schema.\n *\n * Use `excludeName` to ignore refs to specific schemas (useful when self-references are handled separately).\n * Commonly used with `findCircularSchemas()` to detect where lazy wrappers are needed in code generation.\n *\n * @note Returns `true` for the first matching circular ref found; use for fast dependency checks.\n */\nexport function containsCircularRef(\n node: SchemaNode | undefined,\n { circularSchemas, excludeName }: { circularSchemas: ReadonlySet<string>; excludeName?: string },\n): boolean {\n if (!node || circularSchemas.size === 0) return false\n\n const matches = collect<true>(node, {\n schema(child) {\n if (child.type !== 'ref') return undefined\n const name = resolveRefName(child)\n\n return name && name !== excludeName && circularSchemas.has(name) ? true : undefined\n },\n })\n\n return matches.length > 0\n}\n","import { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { trimExtName } from '@internals/utils'\nimport type { InferSchemaNode } from './infer.ts'\nimport type {\n ArrowFunctionNode,\n BreakNode,\n ConstNode,\n ExportNode,\n FileNode,\n FunctionNode,\n FunctionParameterNode,\n FunctionParametersNode,\n ImportNode,\n InputNode,\n JsxNode,\n ObjectSchemaNode,\n OperationNode,\n OutputNode,\n ParameterGroupNode,\n ParameterNode,\n ParamsTypeNode,\n PrimitiveSchemaType,\n PropertyNode,\n ResponseNode,\n SchemaNode,\n SourceNode,\n TextNode,\n TypeNode,\n} from './nodes/index.ts'\nimport { combineExports, combineImports, combineSources, extractStringsFromNodes } from './utils.ts'\n\n/**\n * Syncs property/parameter schema optionality flags from `required` and `schema.nullable`.\n *\n * - `optional` is set for non-required, non-nullable schemas.\n * - `nullish` is set for non-required, nullable schemas.\n */\nexport function syncOptionality(schema: SchemaNode, required: boolean): SchemaNode {\n const nullable = schema.nullable ?? false\n\n return {\n ...schema,\n optional: !required && !nullable ? true : undefined,\n nullish: !required && nullable ? true : undefined,\n }\n}\n\n/**\n * Distributive `Omit` that preserves each member of a union.\n *\n * @example\n * ```ts\n * type A = { kind: 'a'; keep: string; drop: number }\n * type B = { kind: 'b'; keep: boolean; drop: number }\n * type Result = DistributiveOmit<A | B, 'drop'>\n * // -> { kind: 'a'; keep: string } | { kind: 'b'; keep: boolean }\n * ```\n */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = InferSchemaNode<T> & {\n kind: 'Schema'\n}\n\n/**\n * Creates an `InputNode` with stable defaults for `schemas` and `operations`.\n *\n * @example\n * ```ts\n * const input = createInput()\n * // { kind: 'Input', schemas: [], operations: [] }\n * ```\n *\n * @example\n * ```ts\n * const input = createInput({ schemas: [petSchema] })\n * // keeps default operations: []\n * ```\n */\nexport function createInput(overrides: Partial<Omit<InputNode, 'kind'>> = {}): InputNode {\n return {\n schemas: [],\n operations: [],\n ...overrides,\n kind: 'Input',\n }\n}\n\n/**\n * Creates an `OutputNode` with a stable default for `files`.\n *\n * @example\n * ```ts\n * const output = createOutput()\n * // { kind: 'Output', files: [] }\n * ```\n *\n * @example\n * ```ts\n * const output = createOutput({ files: [petFile] })\n * ```\n */\nexport function createOutput(overrides: Partial<Omit<OutputNode, 'kind'>> = {}): OutputNode {\n return {\n files: [],\n ...overrides,\n kind: 'Output',\n }\n}\n\n/**\n * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.\n *\n * @example\n * ```ts\n * const operation = createOperation({\n * operationId: 'getPetById',\n * method: 'GET',\n * path: '/pet/{petId}',\n * })\n * // tags, parameters, and responses are []\n * ```\n *\n * @example\n * ```ts\n * const operation = createOperation({\n * operationId: 'findPets',\n * method: 'GET',\n * path: '/pet/findByStatus',\n * tags: ['pet'],\n * })\n * ```\n */\nexport function createOperation(\n props: Pick<OperationNode, 'operationId' | 'method' | 'path'> & Partial<Omit<OperationNode, 'kind' | 'operationId' | 'method' | 'path'>>,\n): OperationNode {\n return {\n tags: [],\n parameters: [],\n responses: [],\n ...props,\n kind: 'Operation',\n }\n}\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves; special string formats map to `'string'`.\n * Complex types (`ref`, `enum`, `union`, `intersection`, `tuple`, `blob`) are left unset.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`.\n * For object schemas, `properties` defaults to an empty array.\n * `primitive` is automatically inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const uuid = createSchema({ type: 'uuid' })\n * // { kind: 'Schema', type: 'uuid', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n *\n * @example\n * ```ts\n * const enumSchema = createSchema({\n * type: 'enum',\n * primitive: 'string',\n * enumValues: ['available', 'pending'],\n * })\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n const inferredPrimitive = TYPE_TO_PRIMITIVE[props.type as keyof typeof TYPE_TO_PRIMITIVE]\n\n if (props['type'] === 'object') {\n return {\n properties: [],\n primitive: 'object',\n ...props,\n kind: 'Schema',\n } as CreateSchemaOutput<typeof props>\n }\n\n return {\n primitive: inferredPrimitive,\n ...props,\n kind: 'Schema',\n } as CreateSchemaOutput<typeof props>\n}\n\ntype UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>\n\n/**\n * Creates a `PropertyNode`.\n *\n * `required` defaults to `false`.\n * `schema.optional` and `schema.nullish` are derived from `required` and `schema.nullable`.\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * schema: createSchema({ type: 'string' }),\n * })\n * // required=false, schema.optional=true\n * ```\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * required: true,\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=true, no optional/nullish\n * ```\n */\nexport function createProperty(props: UserPropertyNode): PropertyNode {\n const required = props.required ?? false\n\n return {\n ...props,\n kind: 'Property',\n required,\n schema: syncOptionality(props.schema, required),\n }\n}\n\n/**\n * Creates a `ParameterNode`.\n *\n * `required` defaults to `false`.\n * Nested schema flags are set from `required` and `schema.nullable`.\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'petId',\n * in: 'path',\n * required: true,\n * schema: createSchema({ type: 'string' }),\n * })\n * ```\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'status',\n * in: 'query',\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=false, schema.nullish=true\n * ```\n */\nexport function createParameter(\n props: Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>,\n): ParameterNode {\n const required = props.required ?? false\n return {\n ...props,\n kind: 'Parameter',\n required,\n schema: syncOptionality(props.schema, required),\n }\n}\n\n/**\n * Creates a `ResponseNode`.\n *\n * @example\n * ```ts\n * const response = createResponse({\n * statusCode: '200',\n * description: 'Success',\n * schema: createSchema({ type: 'object', properties: [] }),\n * })\n * ```\n */\nexport function createResponse(\n props: Pick<ResponseNode, 'statusCode' | 'schema'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'schema'>>,\n): ResponseNode {\n return {\n ...props,\n kind: 'Response',\n }\n}\n\n/**\n * Creates a `FunctionParameterNode`.\n *\n * `optional` defaults to `false`.\n *\n * @example Required typed param\n * ```ts\n * createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }) })\n * // → petId: string\n * ```\n *\n * @example Optional param\n * ```ts\n * createFunctionParameter({ name: 'params', type: createParamsType({ variant: 'reference', name: 'QueryParams' }), optional: true })\n * // → params?: QueryParams\n * ```\n *\n * @example Param with default (implicitly optional; cannot combine with `optional: true`)\n * ```ts\n * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), default: '{}' })\n * // → config: RequestConfig = {}\n * ```\n */\nexport function createFunctionParameter(\n props: { name: string; type?: ParamsTypeNode; rest?: boolean } & ({ optional: true; default?: never } | { optional?: false; default?: string }),\n): FunctionParameterNode {\n return {\n optional: false,\n ...props,\n kind: 'FunctionParameter',\n } as FunctionParameterNode\n}\n\n/**\n * Creates a {@link TypeNode} representing a language-agnostic structured type expression.\n *\n * Use `variant: 'struct'` for inline anonymous types and `variant: 'member'` for a single\n * named field accessed from a group type. Each language's printer renders the variant\n * into its own syntax (TypeScript, Python, C#, Kotlin, …).\n *\n * @example Reference type (TypeScript: `QueryParams`)\n * ```ts\n * createParamsType({ variant: 'reference', name: 'QueryParams' })\n * ```\n *\n * @example Struct type (TypeScript: `{ petId: string }`)\n * ```ts\n * createParamsType({ variant: 'struct', properties: [{ name: 'petId', optional: false, type: createParamsType({ variant: 'reference', name: 'string' }) }] })\n * ```\n *\n * @example Member type (TypeScript: `DeletePetPathParams['petId']`)\n * ```ts\n * createParamsType({ variant: 'member', base: 'DeletePetPathParams', key: 'petId' })\n * ```\n */\nexport function createParamsType(\n props:\n | { variant: 'reference'; name: string }\n | {\n variant: 'struct'\n properties: Array<{\n name: string\n optional: boolean\n type: ParamsTypeNode\n }>\n }\n | { variant: 'member'; base: string; key: string },\n): ParamsTypeNode {\n return { ...props, kind: 'ParamsType' } as ParamsTypeNode\n}\n\n/**\n * Creates a `ParameterGroupNode` representing a group of related parameters treated as a unit.\n *\n * @example Grouped param (TypeScript declaration)\n * ```ts\n * createParameterGroup({\n * properties: [\n * createFunctionParameter({ name: 'id', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false }),\n * createFunctionParameter({ name: 'name', type: createParamsType({ variant: 'reference', name: 'string' }), optional: true }),\n * ],\n * default: '{}',\n * })\n * // declaration → { id, name? }: { id: string; name?: string } = {}\n * // call → { id, name }\n * ```\n *\n * @example Inline (spread) — children emitted as individual top-level parameters\n * ```ts\n * createParameterGroup({\n * properties: [createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false })],\n * inline: true,\n * })\n * // declaration → petId: string\n * // call → petId\n * ```\n */\nexport function createParameterGroup(\n props: Pick<ParameterGroupNode, 'properties'> & Partial<Omit<ParameterGroupNode, 'kind' | 'properties'>>,\n): ParameterGroupNode {\n return {\n ...props,\n kind: 'ParameterGroup',\n }\n}\n\n/**\n * Creates a `FunctionParametersNode` from an ordered list of parameters.\n *\n * @example\n * ```ts\n * createFunctionParameters({\n * params: [\n * createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false }),\n * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), optional: false, default: '{}' }),\n * ],\n * })\n * ```\n *\n * @example\n * ```ts\n * const empty = createFunctionParameters()\n * // { kind: 'FunctionParameters', params: [] }\n * ```\n */\nexport function createFunctionParameters(props: Partial<Omit<FunctionParametersNode, 'kind'>> = {}): FunctionParametersNode {\n return {\n params: [],\n ...props,\n kind: 'FunctionParameters',\n }\n}\n\n/**\n * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.\n *\n * @example Named import\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * // import { useState } from 'react'\n * ```\n *\n * @example Type-only import\n * ```ts\n * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })\n * // import type { FC } from 'react'\n * ```\n */\nexport function createImport(props: Omit<ImportNode, 'kind'>): ImportNode {\n return { ...props, kind: 'Import' }\n}\n\n/**\n * Creates an `ExportNode` representing a language-agnostic export/public API declaration.\n *\n * @example Named export\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet' })\n * // export { Pet } from './Pet'\n * ```\n *\n * @example Wildcard export\n * ```ts\n * createExport({ path: './utils' })\n * // export * from './utils'\n * ```\n */\nexport function createExport(props: Omit<ExportNode, 'kind'>): ExportNode {\n return { ...props, kind: 'Export' }\n}\n\n/**\n * Creates a `SourceNode` representing a fragment of source code within a file.\n *\n * @example\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })\n * ```\n */\nexport function createSource(props: Omit<SourceNode, 'kind'>): SourceNode {\n return { ...props, kind: 'Source' }\n}\n\nexport type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> &\n Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>\n\n/**\n * Creates a fully resolved `FileNode` from a file input descriptor.\n *\n * Computes:\n * - `id` — SHA256 hash of the file path\n * - `name` — `baseName` without extension\n * - `extname` — extension extracted from `baseName`\n *\n * Deduplicates:\n * - `sources` via `combineSources`\n * - `exports` via `combineExports`\n * - `imports` via `combineImports` (also filters unused imports)\n *\n * @throws {Error} when `baseName` has no extension.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of 'src/models/petStore.ts'\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const rawExtname = path.extname(input.baseName)\n // Handle dotfile basename like '.ts' where path.extname returns ''\n const extname = (rawExtname || (input.baseName.startsWith('.') ? input.baseName : '')) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const source = (input.sources ?? [])\n .flatMap((item) => item.nodes ?? [])\n .map((node) => extractStringsFromNodes([node]))\n .filter(Boolean)\n .join('\\n\\n')\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const resolvedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || undefined) : []\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n return {\n kind: 'File',\n ...input,\n id: createHash('sha256').update(input.path).digest('hex'),\n name: trimExtName(input.baseName),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: input.meta ?? ({} as TMeta),\n }\n}\n\n/**\n * Creates a `ConstNode` representing a TypeScript `const` declaration.\n *\n * Mirrors the `Const` component from `@kubb/renderer-jsx`.\n * The component's `children` are represented as `nodes`.\n *\n * @example Simple constant\n * ```ts\n * createConst({ name: 'pet' })\n * // const pet = ...\n * ```\n *\n * @example Exported constant with type and `as const`\n * ```ts\n * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })\n * // export const pets: Pet[] = ... as const\n * ```\n *\n * @example With JSDoc and child nodes\n * ```ts\n * createConst({\n * name: 'config',\n * export: true,\n * JSDoc: { comments: ['@description App configuration'] },\n * nodes: [],\n * })\n * ```\n */\nexport function createConst(props: Omit<ConstNode, 'kind'>): ConstNode {\n return { ...props, kind: 'Const' }\n}\n\n/**\n * Creates a `TypeNode` representing a TypeScript `type` alias declaration.\n *\n * Mirrors the `Type` component from `@kubb/renderer-jsx`.\n * The component's `children` are represented as `nodes`.\n *\n * @example Simple type alias\n * ```ts\n * createType({ name: 'Pet' })\n * // type Pet = ...\n * ```\n *\n * @example Exported type with JSDoc\n * ```ts\n * createType({\n * name: 'PetStatus',\n * export: true,\n * JSDoc: { comments: ['@description Status of a pet'] },\n * })\n * // export type PetStatus = ...\n * ```\n */\nexport function createType(props: Omit<TypeNode, 'kind'>): TypeNode {\n return { ...props, kind: 'Type' }\n}\n\n/**\n * Creates a `FunctionNode` representing a TypeScript `function` declaration.\n *\n * Mirrors the `Function` component from `@kubb/renderer-jsx`.\n * The component's `children` are represented as `nodes`.\n *\n * @example Simple function\n * ```ts\n * createFunction({ name: 'getPet' })\n * // function getPet() { ... }\n * ```\n *\n * @example Exported async function with return type\n * ```ts\n * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })\n * // export async function fetchPet(): Promise<Pet> { ... }\n * ```\n *\n * @example Function with generics and params\n * ```ts\n * createFunction({\n * name: 'identity',\n * export: true,\n * generics: ['T'],\n * params: 'value: T',\n * returnType: 'T',\n * })\n * // export function identity<T>(value: T): T { ... }\n * ```\n */\nexport function createFunction(props: Omit<FunctionNode, 'kind'>): FunctionNode {\n return { ...props, kind: 'Function' }\n}\n\n/**\n * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.\n *\n * Mirrors the `Function.Arrow` component from `@kubb/renderer-jsx`.\n * The component's `children` are represented as `nodes`.\n *\n * @example Simple arrow function\n * ```ts\n * createArrowFunction({ name: 'getPet' })\n * // const getPet = () => { ... }\n * ```\n *\n * @example Single-line exported arrow function\n * ```ts\n * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })\n * // export const double = (n: number) => ...\n * ```\n *\n * @example Async arrow function with generics\n * ```ts\n * createArrowFunction({\n * name: 'fetchPet',\n * export: true,\n * async: true,\n * generics: ['T'],\n * params: 'id: string',\n * returnType: 'T',\n * })\n * // export const fetchPet = async <T>(id: string): Promise<T> => { ... }\n * ```\n */\nexport function createArrowFunction(props: Omit<ArrowFunctionNode, 'kind'>): ArrowFunctionNode {\n return { ...props, kind: 'ArrowFunction' }\n}\n\n/**\n * Creates a {@link TextNode} representing a raw string fragment in the source output.\n *\n * Use this instead of bare strings when building `nodes` arrays so that every\n * entry in the array is a typed {@link CodeNode}.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport function createText(value: string): TextNode {\n return { value, kind: 'Text' }\n}\n\n/**\n * Creates a {@link BreakNode} representing a line break in the source output.\n *\n * Corresponds to `<br/>` in JSX components. Prints as an empty string which,\n * when joined with `\\n` by `printNodes`, produces a blank line.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport function createBreak(): BreakNode {\n return { kind: 'Break' }\n}\n\n/**\n * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.\n *\n * Use this to embed JSX markup (including fragments `<>…</>`) directly in generated code.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport function createJsx(value: string): JsxNode {\n return { value, kind: 'Jsx' }\n}\n","import type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/index.ts'\n\n/**\n * Runtime context passed as `this` to printer handlers.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * }\n * ```\n */\nexport type PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n */\n transform: (node: SchemaNode) => TOutput | null | undefined\n /**\n * Options for this printer instance.\n */\n options: TOptions\n}\n\n/**\n * Handler for one schema node type.\n *\n * Use a regular function (not an arrow function) if you need `this`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'string'> = function () {\n * return 'string'\n * }\n * ```\n */\nexport type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n) => TOutput | null | undefined\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace; the printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` — unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` — options passed to and stored on the printer instance\n * - `TOutput` — the type emitted by node handlers\n * - `TPrintOutput` — type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher — converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map; never calls the `print` override.\n * Use this when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null | undefined\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null | undefined\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: Partial<{\n [K in SchemaType]: PrinterHandler<T['output'], T['options'], K>\n }>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself — so recursion is safe.\n */\n print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null\n}\n\n/**\n * Creates a schema printer factory.\n *\n * This function wraps a builder and makes options optional at call sites.\n *\n * The builder receives resolved options and returns:\n * - `name` — a unique identifier for the printer\n * - `options` — options stored on the returned printer instance\n * - `nodes` — a map of `SchemaType` → handler functions that convert a `SchemaNode` to `TOutput`\n * - `print` _(optional)_ — top-level override exposed as `printer.print`\n * - Inside this function, use `this.transform(node)` to dispatch to the `nodes` map\n * - This keeps recursion safe and avoids self-calls\n *\n * When no `print` override is provided, `printer.print` falls back to `printer.transform` (the node-level dispatcher).\n *\n * @example Basic usage — Zod schema printer\n * ```ts\n * type PrinterZod = PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = definePrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties.map(p => `${p.name}: ${this.transform(p.schema)}`).join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function definePrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return createPrinterFactory<SchemaNode, SchemaType, SchemaNodeByType>((node) => node.type)(build) as (options?: T['options']) => Printer<T>\n}\n\n/**\n * Generic printer-factory function used by `definePrinter` and `defineFunctionPrinter`.\n **\n * @example\n * ```ts\n * export const defineFunctionPrinter = createPrinterFactory<FunctionNode, FunctionNodeType, FunctionNodeByType>(\n * (node) => kindToHandlerKey[node.kind],\n * )\n * ```\n */\nexport function createPrinterFactory<TNode, TKey extends string, TNodeByKey extends Partial<Record<TKey, TNode>>>(getKey: (node: TNode) => TKey | undefined) {\n return function <T extends PrinterFactoryOptions>(\n build: (options: T['options']) => {\n name: T['name']\n options: T['options']\n nodes: Partial<{\n [K in TKey]: (\n this: {\n transform: (node: TNode) => T['output'] | null | undefined\n options: T['options']\n },\n node: TNodeByKey[K],\n ) => T['output'] | null | undefined\n }>\n print?: (\n this: {\n transform: (node: TNode) => T['output'] | null | undefined\n options: T['options']\n },\n node: TNode,\n ) => T['printOutput'] | null | undefined\n },\n ): (options?: T['options']) => {\n name: T['name']\n options: T['options']\n transform: (node: TNode) => T['output'] | null | undefined\n print: (node: TNode) => T['printOutput'] | null | undefined\n } {\n return (options) => {\n const { name, options: resolvedOptions, nodes, print: printOverride } = build(options ?? ({} as T['options']))\n\n const context = {\n options: resolvedOptions,\n transform: (node: TNode): T['output'] | null | undefined => {\n const key = getKey(node)\n if (key === undefined) return null\n\n const handler = nodes[key]\n\n if (!handler) return null\n\n return (handler as (this: typeof context, node: TNode) => T['output'] | null | undefined).call(context, node)\n },\n }\n\n return {\n name,\n options: resolvedOptions,\n transform: context.transform,\n print: (printOverride ? printOverride.bind(context) : context.transform) as (node: TNode) => T['printOutput'] | null | undefined,\n }\n }\n }\n}\n","import { pascalCase } from '@internals/utils'\nimport { narrowSchema } from './guards.ts'\nimport type { SchemaNode } from './nodes/schema.ts'\nimport { extractRefName } from './refs.ts'\nimport { collect } from './visitor.ts'\n\nexport function findDiscriminator(mapping: Record<string, string> | undefined, ref: string | undefined): string | null {\n if (!mapping || !ref) return null\n return Object.entries(mapping).find(([, value]) => value === ref)?.[0] ?? null\n}\n\nexport function childName(parentName: string | null | undefined, propName: string): string | null {\n return parentName ? pascalCase([parentName, propName].join(' ')) : null\n}\n\nexport function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string {\n return pascalCase([parentName, propName, enumSuffix].filter(Boolean).join(' '))\n}\n\n/**\n * Collects import entries for all `ref` schema nodes in `node`.\n */\nexport function collectImports<TImport>({\n node,\n nameMapping,\n resolve,\n}: {\n node: SchemaNode\n nameMapping: Map<string, string>\n resolve: (schemaName: string) => TImport | undefined\n}): Array<TImport> {\n return collect<TImport>(node, {\n schema(schemaNode): TImport | undefined {\n const schemaRef = narrowSchema(schemaNode, 'ref')\n if (!schemaRef?.ref) return\n\n const rawName = extractRefName(schemaRef.ref)\n const schemaName = nameMapping.get(rawName) ?? rawName\n const result = resolve(schemaName)\n if (!result) return\n\n return result\n },\n })\n}\n","import { isScalarPrimitive } from './constants.ts'\nimport { createProperty, createSchema } from './factory.ts'\nimport { narrowSchema } from './guards.ts'\nimport type { SchemaNode } from './nodes/schema.ts'\nimport { enumPropName } from './resolvers.ts'\n\n/**\n * Replaces a discriminator property's schema with a string enum of allowed values.\n *\n * If `node` is not an object schema, or if the property does not exist, the input\n * node is returned as-is.\n *\n * @example\n * ```ts\n * const schema = createSchema({\n * type: 'object',\n * properties: [createProperty({ name: 'type', required: true, schema: createSchema({ type: 'string' }) })],\n * })\n * const result = setDiscriminatorEnum({ node: schema, propertyName: 'type', values: ['dog', 'cat'] })\n * ```\n */\nexport function setDiscriminatorEnum({\n node,\n propertyName,\n values,\n enumName,\n}: {\n node: SchemaNode\n propertyName: string\n values: Array<string>\n enumName?: string\n}): SchemaNode {\n const objectNode = narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) {\n return node\n }\n\n const hasProperty = objectNode.properties.some((prop) => prop.name === propertyName)\n if (!hasProperty) {\n return node\n }\n\n return createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) {\n return prop\n }\n\n return createProperty({\n ...prop,\n schema: createSchema({\n type: 'enum',\n primitive: 'string',\n enumValues: values,\n name: enumName,\n readOnly: prop.schema.readOnly,\n writeOnly: prop.schema.writeOnly,\n }),\n })\n }),\n })\n}\n\n/**\n * Merges adjacent anonymous object members into a single anonymous object member.\n *\n * @example\n * ```ts\n * const merged = mergeAdjacentObjects([\n * createSchema({ type: 'object', properties: [createProperty({ name: 'a', schema: createSchema({ type: 'string' }) })] }),\n * createSchema({ type: 'object', properties: [createProperty({ name: 'b', schema: createSchema({ type: 'number' }) })] }),\n * ])\n * ```\n */\nexport function mergeAdjacentObjects(members: Array<SchemaNode>): Array<SchemaNode> {\n return members.reduce<Array<SchemaNode>>((acc, member) => {\n const objectMember = narrowSchema(member, 'object')\n if (objectMember && !objectMember.name) {\n const previous = acc.at(-1)\n const previousObject = previous ? narrowSchema(previous, 'object') : undefined\n\n if (previousObject && !previousObject.name) {\n acc[acc.length - 1] = createSchema({\n ...previousObject,\n properties: [...(previousObject.properties ?? []), ...(objectMember.properties ?? [])],\n })\n return acc\n }\n }\n\n acc.push(member)\n return acc\n }, [])\n}\n\n/**\n * Removes enum members that are covered by broader scalar primitives in the same union.\n *\n * @example\n * ```ts\n * const simplified = simplifyUnion([\n * createSchema({ type: 'enum', primitive: 'string', enumValues: ['active'] }),\n * createSchema({ type: 'string' }),\n * ])\n * // keeps only string member\n * ```\n */\nexport function simplifyUnion(members: Array<SchemaNode>): Array<SchemaNode> {\n const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type))\n\n if (!scalarPrimitives.size) {\n return members\n }\n\n return members.filter((member) => {\n const enumNode = narrowSchema(member, 'enum')\n if (!enumNode) {\n return true\n }\n\n const primitive = enumNode.primitive\n if (!primitive) {\n return true\n }\n\n const enumValueCount = enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0\n if (enumValueCount <= 1) {\n return true\n }\n\n if (scalarPrimitives.has(primitive)) {\n return false\n }\n\n if ((primitive === 'integer' || primitive === 'number') && (scalarPrimitives.has('integer') || scalarPrimitives.has('number'))) {\n return false\n }\n\n return true\n })\n}\n\nexport function setEnumName(propNode: SchemaNode, parentName: string | null | undefined, propName: string, enumSuffix: string): SchemaNode {\n const enumNode = narrowSchema(propNode, 'enum')\n\n if (enumNode?.primitive === 'boolean') {\n return { ...propNode, name: undefined }\n }\n\n if (enumNode) {\n return {\n ...propNode,\n name: enumPropName(parentName, propName, enumSuffix),\n }\n }\n\n return propNode\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAa,gBAAgB;CAC3B,SAAS;CACT,MAAM;CACP;AAED,MAAa,YAAY;CACvB,OAAO;CACP,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,UAAU;CACV,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,gBAAgB;CAChB,oBAAoB;CACpB,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,OAAO;CACR;;;;;;;;AASD,MAAa,cAAc;;;;CAIzB,QAAQ;;;;CAIR,QAAQ;;;;CAIR,SAAS;;;;CAIT,QAAQ;;;;CAIR,SAAS;;;;CAIT,MAAM;;;;CAIN,KAAK;;;;CAIL,SAAS;;;;CAIT,MAAM;;;;CAIN,QAAQ;;;;CAIR,OAAO;;;;CAIP,OAAO;;;;CAIP,OAAO;;;;CAIP,cAAc;;;;CAId,MAAM;;;;CAIN,KAAK;;;;CAIL,MAAM;;;;CAIN,UAAU;;;;CAIV,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;;;;CAIP,KAAK;;;;CAIL,MAAM;;;;CAIN,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;CACR;;;;;;AASD,MAAa,yBAAyB,IAAI,IAAqB;CAAC;CAAU;CAAU;CAAW;CAAU;CAAU,CAAC;;;;;;AAOpH,SAAgB,kBAAkB,MAAuC;AACvE,QAAO,uBAAuB,IAAI,KAAwB;;;;;;;AAQ5D,MAAa,cAAc;CACzB,KAAK;CACL,MAAM;CACN,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,OAAO;CACR;;;;;;;AAuBD,MAAa,aAAa;CACxB,iBAAiB;CACjB,gBAAgB;CAChB,2BAA2B;CAC3B,wBAAwB;CACxB,gBAAgB;CAChB,gB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