@kubb/ast 5.0.0-alpha.7 → 5.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{visitor-DagMPgGo.d.ts → visitor-Ci6rmtT9.d.ts} +4 -4
- package/package.json +1 -1
- package/src/factory.ts +3 -1
- package/src/mocks.ts +7 -1
- package/src/nodes/response.ts +1 -1
- package/src/printer.ts +1 -1
- package/src/utils.ts +1 -1
- package/src/visitor.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -175,7 +175,7 @@ const isResponseNode = isKind("Response");
|
|
|
175
175
|
//#endregion
|
|
176
176
|
//#region src/printer.ts
|
|
177
177
|
/**
|
|
178
|
-
* Creates a named printer factory. Mirrors the `
|
|
178
|
+
* Creates a named printer factory. Mirrors the `createPlugin` / `createAdapter` pattern
|
|
179
179
|
* from `@kubb/core` — wraps a builder to make options optional and separates raw options
|
|
180
180
|
* from resolved options.
|
|
181
181
|
*
|
|
@@ -706,7 +706,7 @@ function transform(node, visitor, options = {}) {
|
|
|
706
706
|
if (replaced) response = replaced;
|
|
707
707
|
return {
|
|
708
708
|
...response,
|
|
709
|
-
schema:
|
|
709
|
+
schema: transform(response.schema, visitor, options)
|
|
710
710
|
};
|
|
711
711
|
}
|
|
712
712
|
}
|
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 `definePlugin` / `defineAdapter` 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,MA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Y,KAAK;AAC7B;EACF,KAAK;AACH,OAAI,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":[],"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(\n props: Pick<ResponseNode, 'statusCode' | 'schema'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'schema'>>,\n): 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 = new Set([\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.has(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'] as const)\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: transform(response.schema, visitor, options),\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;CACP,OAAO;CACP,cAAc;CACd,MAAM;CACN,KAAK;CACL,MAAM;CACN,UAAU;CACV,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,MAAM;CACN,OAAO;CACR;AAED,MAAa,cAAc;CACzB,KAAK;CACL,MAAM;CACN,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,OAAO;CACR;AAmBD,MAAa,aAAa;CACxB,iBAAiB;CACjB,gBAAgB;CAChB,2BAA2B;CAC3B,wBAAwB;CACxB,gBAAgB;CAChB,gBAAgB;CAChB,oBAAoB;CACpB,mBAAmB;CACnB,WAAW;CACX,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACV,WAAW;CACX,UAAU;CACV,WAAW;CACX,aAAa;CACb,WAAW;CACX,UAAU;CACX;;;;;;ACnGD,SAAgB,WAAW,YAA6C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AQ,SAAS,QAAQ;IACjD;;EAEH,KAAK,aAAa;GAChB,IAAI,QAAQ;GACZ,MAAM,WAAW,QAAQ,YAAY,MAAM;AAC3C,OAAI,SAAU,SAAQ;AAEtB,UAAO;IACL,GAAG;IACH,QAAQ,UAAU,MAAM,QAAQ,SAAS,QAAQ;IAClD;;EAEH,KAAK,YAAY;GACf,IAAI,WAAW;GACf,MAAM,WAAW,QAAQ,WAAW,SAAS;AAC7C,OAAI,SAAU,YAAW;AAEzB,UAAO;IACL,GAAG;IACH,QAAQ,UAAU,SAAS,QAAQ,SAAS,QAAQ;IACrD;;;;;;;AAQP,SAAgB,QAAW,MAAY,SAA4B,UAA0B,EAAE,EAAY;CACzG,MAAM,WAAW,QAAQ,SAAS,cAAc,UAAU,cAAc;CACxE,MAAM,UAAoB,EAAE;CAE5B,IAAI;AACJ,SAAQ,KAAK,MAAb;EACE,KAAK;AACH,OAAI,QAAQ,OAAO,KAAK;AACxB;EACF,KAAK;AACH,OAAI,QAAQ,YAAY,KAAK;AAC7B;EACF,KAAK;AACH,OAAI,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { D as OperationNode, J as SchemaNodeByType, N as ParameterNode, O as ResponseNode, S as createSchema, T as RootNode, _ as createOperation, a as transform, at as httpMethods, b as createResponse, c as buildRefMap, ct as schemaTypes, h as definePrinter, i as collect, l as refMapToObject, o as walk, ot as mediaTypes, q as SchemaNode, st as nodeKinds, tt as PropertyNode, u as resolveRef, v as createParameter, x as createRoot, y as createProperty } from "./visitor-
|
|
2
|
+
import { D as OperationNode, J as SchemaNodeByType, N as ParameterNode, O as ResponseNode, S as createSchema, T as RootNode, _ as createOperation, a as transform, at as httpMethods, b as createResponse, c as buildRefMap, ct as schemaTypes, h as definePrinter, i as collect, l as refMapToObject, o as walk, ot as mediaTypes, q as SchemaNode, st as nodeKinds, tt as PropertyNode, u as resolveRef, v as createParameter, x as createRoot, y as createProperty } from "./visitor-Ci6rmtT9.js";
|
|
3
3
|
|
|
4
4
|
//#region src/guards.d.ts
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -173,7 +173,7 @@ const isResponseNode = isKind("Response");
|
|
|
173
173
|
//#endregion
|
|
174
174
|
//#region src/printer.ts
|
|
175
175
|
/**
|
|
176
|
-
* Creates a named printer factory. Mirrors the `
|
|
176
|
+
* Creates a named printer factory. Mirrors the `createPlugin` / `createAdapter` pattern
|
|
177
177
|
* from `@kubb/core` — wraps a builder to make options optional and separates raw options
|
|
178
178
|
* from resolved options.
|
|
179
179
|
*
|
|
@@ -704,7 +704,7 @@ function transform(node, visitor, options = {}) {
|
|
|
704
704
|
if (replaced) response = replaced;
|
|
705
705
|
return {
|
|
706
706
|
...response,
|
|
707
|
-
schema:
|
|
707
|
+
schema: transform(response.schema, visitor, options)
|
|
708
708
|
};
|
|
709
709
|
}
|
|
710
710
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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 `definePlugin` / `defineAdapter` 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,SA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,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.js","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(\n props: Pick<ResponseNode, 'statusCode' | 'schema'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'schema'>>,\n): 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 = new Set([\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.has(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'] as const)\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: transform(response.schema, visitor, options),\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;CACP,OAAO;CACP,cAAc;CACd,MAAM;CACN,KAAK;CACL,MAAM;CACN,UAAU;CACV,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,MAAM;CACN,OAAO;CACR;AAED,MAAa,cAAc;CACzB,KAAK;CACL,MAAM;CACN,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,OAAO;CACR;AAmBD,MAAa,aAAa;CACxB,iBAAiB;CACjB,gBAAgB;CAChB,2BAA2B;CAC3B,wBAAwB;CACxB,gBAAgB;CAChB,gBAAgB;CAChB,oBAAoB;CACpB,mBAAmB;CACnB,WAAW;CACX,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACV,WAAW;CACX,UAAU;CACV,WAAW;CACX,aAAa;CACb,WAAW;CACX,UAAU;CACX;;;;;;ACnGD,SAAgB,WAAW,YAA6C,EAAE,EAAY;AACpF,QAAO;EACL,SAAS,EAAE;EACX,YAAY,EAAE;EACd,GAAG;EACH,MAAM;EACP;;;;;AAMH,SAAgB,gBACd,OACe;AACf,QAAO;EACL,MAAM,EAAE;EACR,YAAY,EAAE;EACd,WAAW,EAAE;EACb,GAAG;EACH,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AgB,QAAW,MAAY,SAA4B,UAA0B,EAAE,EAAY;CACzG,MAAM,WAAW,QAAQ,SAAS,cAAc,UAAU,cAAc;CACxE,MAAM,UAAoB,EAAE;CAE5B,IAAI;AACJ,SAAQ,KAAK,MAAb;EACE,KAAK;AACH,OAAI,QAAQ,OAAO,KAAK;AACxB;EACF,KAAK;AACH,OAAI,QAAQ,YAAY,KAAK;AAC7B;EACF,KAAK;AACH,OAAI,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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as UnionSchemaNode, A as MediaType, B as IntersectionSchemaNode, C as Node, D as OperationNode, E as HttpMethod, F as ComplexSchemaType, G as ScalarSchemaNode, H as ObjectSchemaNode, I as DateSchemaNode, J as SchemaNodeByType, K as ScalarSchemaType, L as DatetimeSchemaNode, M as ParameterLocation, N as ParameterNode, O as ResponseNode, P as ArraySchemaNode, Q as TimeSchemaNode, R as EnumSchemaNode, T as RootNode, U as PrimitiveSchemaType, V as NumberSchemaNode, W as RefSchemaNode, X as SpecialSchemaType, Y as SchemaType, Z as StringSchemaNode, d as Printer, et as UrlSchemaNode, f as PrinterFactoryOptions, g as DistributiveOmit, it as VisitorDepth, j as StatusCode, k as HttpStatusCode, m as PrinterHandlerContext, n as CollectVisitor, nt as BaseNode, p as PrinterHandler, q as SchemaNode, r as Visitor, rt as NodeKind, s as RefMap, t as AsyncVisitor, tt as PropertyNode, w as RootMeta, z as EnumValueNode } from "./visitor-
|
|
1
|
+
import { $ as UnionSchemaNode, A as MediaType, B as IntersectionSchemaNode, C as Node, D as OperationNode, E as HttpMethod, F as ComplexSchemaType, G as ScalarSchemaNode, H as ObjectSchemaNode, I as DateSchemaNode, J as SchemaNodeByType, K as ScalarSchemaType, L as DatetimeSchemaNode, M as ParameterLocation, N as ParameterNode, O as ResponseNode, P as ArraySchemaNode, Q as TimeSchemaNode, R as EnumSchemaNode, T as RootNode, U as PrimitiveSchemaType, V as NumberSchemaNode, W as RefSchemaNode, X as SpecialSchemaType, Y as SchemaType, Z as StringSchemaNode, d as Printer, et as UrlSchemaNode, f as PrinterFactoryOptions, g as DistributiveOmit, it as VisitorDepth, j as StatusCode, k as HttpStatusCode, m as PrinterHandlerContext, n as CollectVisitor, nt as BaseNode, p as PrinterHandler, q as SchemaNode, r as Visitor, rt as NodeKind, s as RefMap, t as AsyncVisitor, tt as PropertyNode, w as RootMeta, z as EnumValueNode } from "./visitor-Ci6rmtT9.js";
|
|
2
2
|
export { type ArraySchemaNode, type AsyncVisitor, type BaseNode, type CollectVisitor, type ComplexSchemaType, type DateSchemaNode, type DatetimeSchemaNode, type DistributiveOmit, type EnumSchemaNode, type EnumValueNode, type HttpMethod, type HttpStatusCode, type IntersectionSchemaNode, type MediaType, type Node, type NodeKind, type NumberSchemaNode, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterHandler, type PrinterHandlerContext, type PropertyNode, type RefMap, type RefSchemaNode, type ResponseNode, type RootMeta, type RootNode, type ScalarSchemaNode, type ScalarSchemaType, type SchemaNode, type SchemaNodeByType, type SchemaType, type SpecialSchemaType, type StatusCode, type StringSchemaNode, type TimeSchemaNode, type UnionSchemaNode, type UrlSchemaNode, type Visitor, type VisitorDepth };
|
|
@@ -369,7 +369,7 @@ type ResponseNode = BaseNode & {
|
|
|
369
369
|
*/
|
|
370
370
|
statusCode: StatusCode;
|
|
371
371
|
description?: string;
|
|
372
|
-
schema
|
|
372
|
+
schema: SchemaNode;
|
|
373
373
|
mediaType?: MediaType;
|
|
374
374
|
};
|
|
375
375
|
//#endregion
|
|
@@ -489,7 +489,7 @@ declare function createParameter(props: Pick<ParameterNode, 'name' | 'in' | 'sch
|
|
|
489
489
|
/**
|
|
490
490
|
* Creates a `ResponseNode`.
|
|
491
491
|
*/
|
|
492
|
-
declare function createResponse(props: Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode'>>): ResponseNode;
|
|
492
|
+
declare function createResponse(props: Pick<ResponseNode, 'statusCode' | 'schema'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'schema'>>): ResponseNode;
|
|
493
493
|
//#endregion
|
|
494
494
|
//#region src/printer.d.ts
|
|
495
495
|
/**
|
|
@@ -566,7 +566,7 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
|
|
|
566
566
|
print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null | undefined;
|
|
567
567
|
};
|
|
568
568
|
/**
|
|
569
|
-
* Creates a named printer factory. Mirrors the `
|
|
569
|
+
* Creates a named printer factory. Mirrors the `createPlugin` / `createAdapter` pattern
|
|
570
570
|
* from `@kubb/core` — wraps a builder to make options optional and separates raw options
|
|
571
571
|
* from resolved options.
|
|
572
572
|
*
|
|
@@ -699,4 +699,4 @@ declare function transform(node: Node, visitor: Visitor, options?: VisitorOption
|
|
|
699
699
|
declare function collect<T>(node: Node, visitor: CollectVisitor<T>, options?: VisitorOptions): Array<T>;
|
|
700
700
|
//#endregion
|
|
701
701
|
export { UnionSchemaNode as $, MediaType as A, IntersectionSchemaNode as B, Node as C, OperationNode as D, HttpMethod as E, ComplexSchemaType as F, ScalarSchemaNode as G, ObjectSchemaNode as H, DateSchemaNode as I, SchemaNodeByType as J, ScalarSchemaType as K, DatetimeSchemaNode as L, ParameterLocation as M, ParameterNode as N, ResponseNode as O, ArraySchemaNode as P, TimeSchemaNode as Q, EnumSchemaNode as R, createSchema as S, RootNode as T, PrimitiveSchemaType as U, NumberSchemaNode as V, RefSchemaNode as W, SpecialSchemaType as X, SchemaType as Y, StringSchemaNode as Z, createOperation as _, transform as a, httpMethods as at, createResponse as b, buildRefMap as c, schemaTypes as ct, Printer as d, UrlSchemaNode as et, PrinterFactoryOptions as f, DistributiveOmit as g, definePrinter as h, collect as i, VisitorDepth as it, StatusCode as j, HttpStatusCode as k, refMapToObject as l, PrinterHandlerContext as m, CollectVisitor as n, BaseNode as nt, walk as o, mediaTypes as ot, PrinterHandler as p, SchemaNode as q, Visitor as r, NodeKind as rt, RefMap as s, nodeKinds as st, AsyncVisitor as t, PropertyNode as tt, resolveRef as u, createParameter as v, RootMeta as w, createRoot as x, createProperty as y, EnumValueNode as z };
|
|
702
|
-
//# sourceMappingURL=visitor-
|
|
702
|
+
//# sourceMappingURL=visitor-Ci6rmtT9.d.ts.map
|
package/package.json
CHANGED
package/src/factory.ts
CHANGED
|
@@ -76,7 +76,9 @@ export function createParameter(
|
|
|
76
76
|
/**
|
|
77
77
|
* Creates a `ResponseNode`.
|
|
78
78
|
*/
|
|
79
|
-
export function createResponse(
|
|
79
|
+
export function createResponse(
|
|
80
|
+
props: Pick<ResponseNode, 'statusCode' | 'schema'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'schema'>>,
|
|
81
|
+
): ResponseNode {
|
|
80
82
|
return {
|
|
81
83
|
...props,
|
|
82
84
|
kind: 'Response',
|
package/src/mocks.ts
CHANGED
|
@@ -20,7 +20,13 @@ export function buildSampleTree(): RootNode {
|
|
|
20
20
|
path: '/pets/{petId}',
|
|
21
21
|
tags: ['pets'],
|
|
22
22
|
parameters: [createParameter({ name: 'petId', in: 'path', schema: createSchema({ type: 'integer' }), required: true })],
|
|
23
|
-
responses: [
|
|
23
|
+
responses: [
|
|
24
|
+
createResponse({ statusCode: '200', schema: createSchema({ type: 'ref', name: 'Pet' }) }),
|
|
25
|
+
createResponse({
|
|
26
|
+
statusCode: '404',
|
|
27
|
+
schema: createSchema({ type: 'ref', name: 'Error' }),
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
24
30
|
})
|
|
25
31
|
|
|
26
32
|
return createRoot({ schemas: [petSchema], operations: [operation] })
|
package/src/nodes/response.ts
CHANGED
package/src/printer.ts
CHANGED
|
@@ -84,7 +84,7 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Creates a named printer factory. Mirrors the `
|
|
87
|
+
* Creates a named printer factory. Mirrors the `createPlugin` / `createAdapter` pattern
|
|
88
88
|
* from `@kubb/core` — wraps a builder to make options optional and separates raw options
|
|
89
89
|
* from resolved options.
|
|
90
90
|
*
|
package/src/utils.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { narrowSchema } from './guards.ts'
|
|
|
4
4
|
import type { ParameterNode, SchemaNode } from './nodes/index.ts'
|
|
5
5
|
import type { SchemaType } from './nodes/schema.ts'
|
|
6
6
|
|
|
7
|
-
const plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'])
|
|
7
|
+
const plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Returns `true` when a schema node will be represented as a plain string in generated code.
|
package/src/visitor.ts
CHANGED
|
@@ -231,7 +231,7 @@ export function transform(node: Node, visitor: Visitor, options: VisitorOptions
|
|
|
231
231
|
|
|
232
232
|
return {
|
|
233
233
|
...response,
|
|
234
|
-
schema:
|
|
234
|
+
schema: transform(response.schema, visitor, options),
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
}
|