@kubb/ast 5.0.0-beta.59 → 5.0.0-beta.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory-BmcGBdeg.cjs","names":["path"],"sources":["../src/node.ts","../src/nodes/schema.ts","../../../internals/utils/src/fs.ts","../src/nodes/code.ts","../src/nodes/content.ts","../src/nodes/file.ts","../src/nodes/function.ts","../src/nodes/input.ts","../src/nodes/requestBody.ts","../src/nodes/operation.ts","../src/nodes/output.ts","../src/nodes/parameter.ts","../src/nodes/property.ts","../src/nodes/response.ts","../src/utils/extractStringsFromNodes.ts","../src/utils/fileMerge.ts","../src/factory.ts"],"sourcesContent":["import type { BaseNode, NodeKind } from './nodes/base.ts'\nimport type { SchemaNode } from './nodes/index.ts'\n\n/**\n * Visitor callback names, one per traversable node kind. Kept in sync with the\n * keys of `Visitor` in `visitor.ts`.\n */\ntype VisitorKey = 'input' | 'output' | 'operation' | 'schema' | 'property' | 'parameter' | 'response'\n\n/**\n * Distributive `Omit` that preserves each member of a union.\n *\n * @example\n * ```ts\n * type A = { kind: 'a'; keep: string; drop: number }\n * type B = { kind: 'b'; keep: boolean; drop: number }\n * type Result = DistributiveOmit<A | B, 'drop'>\n * // -> { kind: 'a'; keep: string } | { kind: 'b'; keep: boolean }\n * ```\n */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/**\n * Builds a type guard that matches nodes of the given `kind`.\n */\nfunction isKind<T extends BaseNode>(kind: NodeKind) {\n return (node: unknown): node is T => (node as BaseNode).kind === kind\n}\n\n/**\n * Updates a schema's `optional` and `nullish` flags from a parent's `required`\n * value and the schema's own `nullable`. Mirrors how OpenAPI parameters and\n * object properties combine \"required\" and \"nullable\" into a single AST.\n *\n * - Non-required + non-nullable → `optional: true`.\n * - Non-required + nullable → `nullish: true`.\n * - Required → both flags cleared.\n */\nexport function syncOptionality(schema: SchemaNode, required: boolean): SchemaNode {\n const nullable = schema.nullable ?? false\n\n return {\n ...schema,\n optional: !required && !nullable ? true : undefined,\n nullish: !required && nullable ? true : undefined,\n }\n}\n\n/**\n * The single definition derived from one {@link defineNode} call: the node's\n * `create` builder, its `is` guard, and the traversal metadata the registry\n * collects into the visitor tables.\n */\nexport type NodeDef<TNode extends BaseNode = BaseNode, TInput = never> = {\n /**\n * Node discriminator this definition owns.\n */\n kind: NodeKind\n /**\n * Builds a node from its input, applying `defaults` and the optional `build` hook.\n */\n create: (input: TInput) => TNode\n /**\n * Type guard matching this node kind.\n */\n is: (node: unknown) => node is TNode\n /**\n * Child node fields in traversal order. Feeds `VISITOR_KEYS`.\n */\n children?: ReadonlyArray<string>\n /**\n * Visitor callback name. Feeds `VISITOR_KEY_BY_KIND`.\n */\n visitorKey?: VisitorKey\n /**\n * When `true`, `create` is rerun after children are rebuilt so computed fields\n * stay in sync. Feeds `nodeRebuilders`.\n */\n rebuild?: boolean\n}\n\ntype DefineNodeConfig<TNode extends BaseNode, TInput, TBuilt extends object> = {\n kind: TNode['kind']\n defaults?: Partial<TNode>\n build?: (input: TInput) => TBuilt\n children?: ReadonlyArray<string>\n visitorKey?: VisitorKey\n rebuild?: boolean\n}\n\n/**\n * Defines a node once and derives its `create` builder, `is` guard, and traversal\n * metadata. `create` merges `defaults`, the `build` hook (or the raw input), and the\n * `kind`, so node construction lives in one place without scattered `as` casts.\n *\n * Set `rebuild: true` when the `build` hook derives fields from children. After a\n * transform rewrites those children, the registry reruns `create` so the derived\n * fields stay correct.\n *\n * @example Simple node\n * ```ts\n * const importDef = defineNode<ImportNode>({ kind: 'Import' })\n * const createImport = importDef.create\n * ```\n *\n * @example Node with a build hook that is rerun on transform\n * ```ts\n * const propertyDef = defineNode<PropertyNode, UserPropertyNode>({\n * kind: 'Property',\n * build: (props) => ({ ...props, required: props.required ?? false }),\n * children: ['schema'],\n * visitorKey: 'property',\n * rebuild: true,\n * })\n * ```\n */\nexport function defineNode<TNode extends BaseNode, TInput = Omit<TNode, 'kind'>, TBuilt extends object = Omit<TNode, 'kind'>>(\n config: DefineNodeConfig<TNode, TInput, TBuilt>,\n): NodeDef<TNode, TInput> {\n const { kind, defaults, build, children, visitorKey, rebuild } = config\n\n function create(input: TInput): TNode {\n const base = build ? build(input) : input\n return { ...defaults, ...(base as object), kind } as TNode\n }\n\n return { kind, create, is: isKind<TNode>(kind), children, visitorKey, rebuild }\n}\n","import type { InferSchemaNode } from '../infer.ts'\nimport { defineNode, type DistributiveOmit } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { PropertyNode } from './property.ts'\n\nexport type PrimitiveSchemaType =\n /**\n * Text value.\n */\n | 'string'\n /**\n * Floating-point number.\n */\n | 'number'\n /**\n * Integer number.\n */\n | 'integer'\n /**\n * Big integer number.\n */\n | 'bigint'\n /**\n * Boolean value.\n */\n | 'boolean'\n /**\n * Null value.\n */\n | 'null'\n /**\n * Any value.\n */\n | 'any'\n /**\n * Unknown value.\n */\n | 'unknown'\n /**\n * No value (`void`).\n */\n | 'void'\n /**\n * Never value.\n */\n | 'never'\n /**\n * Object value.\n */\n | 'object'\n /**\n * Array value.\n */\n | 'array'\n /**\n * Date value.\n */\n | 'date'\n\n/**\n * Composite schema types.\n */\ntype ComplexSchemaType = 'tuple' | 'union' | 'intersection' | 'enum'\n\n/**\n * Schema types that need special handling in generators.\n */\ntype SpecialSchemaType = 'ref' | 'datetime' | 'time' | 'uuid' | 'email' | 'url' | 'ipv4' | 'ipv6' | 'blob'\n\n/**\n * All schema type strings.\n */\nexport type SchemaType = PrimitiveSchemaType | ComplexSchemaType | SpecialSchemaType\n\n/**\n * Scalar schema types without extra object/array/ref structure.\n */\nexport type ScalarSchemaType = Exclude<\n SchemaType,\n | 'object'\n | 'array'\n | 'tuple'\n | 'union'\n | 'intersection'\n | 'enum'\n | 'ref'\n | 'datetime'\n | 'date'\n | 'time'\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'url'\n | 'uuid'\n | 'email'\n>\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example value.\n */\n example?: unknown\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties (maps to `.strict()` in Zod)\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Minimum number of properties allowed.\n */\n minProperties?: number\n /**\n * Maximum number of properties allowed.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name from OpenAPI `discriminator.propertyName`.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during OAS parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Exclusive minimum value.\n */\n exclusiveMinimum?: number\n /**\n * Exclusive maximum value.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include an OpenAPI-style path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * OpenAPI-style path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * IPv4 address schema node.\n *\n * @example\n * ```ts\n * const ipv4Schema: Ipv4SchemaNode = { kind: 'Schema', type: 'ipv4' }\n * ```\n */\ntype Ipv4SchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ipv4'\n}\n\n/**\n * IPv6 address schema node.\n *\n * @example\n * ```ts\n * const ipv6Schema: Ipv6SchemaNode = { kind: 'Schema', type: 'ipv6' }\n * ```\n */\ntype Ipv6SchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ipv6'\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: Ipv4SchemaNode\n ipv6: Ipv6SchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | Ipv4SchemaNode\n | Ipv6SchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = InferSchemaNode<T> & {\n kind: 'Schema'\n}\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves. Special string formats map to `'string'`.\n * Complex types (`ref`, `enum`, `union`, `intersection`, `tuple`, `blob`) are left unset.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Definition for the {@link SchemaNode}. Object schemas default `properties` to an\n * empty array, and `primitive` is inferred from `type` when not explicitly provided.\n */\nexport const schemaDef = defineNode<SchemaNode, CreateSchemaInput>({\n kind: 'Schema',\n build: (props) => {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object' as const, ...props }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type as keyof typeof TYPE_TO_PRIMITIVE], ...props }\n },\n children: ['properties', 'items', 'members', 'additionalProperties'],\n visitorKey: 'schema',\n})\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n return schemaDef.create(props)\n}\n","import { existsSync } from 'node:fs'\nimport { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, join, posix, resolve } from 'node:path'\nimport { camelCase } from './casing.ts'\nimport { runtime } from './runtime.ts'\n\n/**\n * Walks up the directory tree from `cwd` (defaults to `process.cwd()`) and\n * returns the absolute path of the nearest `package.json`, or `null` when none\n * is found before reaching the filesystem root.\n *\n * @example\n * ```ts\n * const pkgPath = findPackageJSON('/home/user/project/src') // '/home/user/project/package.json'\n * ```\n */\nexport function findPackageJSON(cwd?: string): string | null {\n let dir = cwd ? resolve(cwd) : process.cwd()\n while (true) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) return pkgPath\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n/**\n * Converts all backslashes to forward slashes.\n * Extended-length Windows paths (`\\\\?\\...`) are left unchanged.\n */\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\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 *\n * @example\n * ```ts\n * if (await exists('./kubb.config.ts')) {\n * const content = await read('./kubb.config.ts')\n * }\n * ```\n */\nexport async function exists(path: string): Promise<boolean> {\n if (runtime.isBun) {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\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 *\n * @example\n * ```ts\n * const source = await read('./src/Pet.ts')\n * ```\n */\nexport async function read(path: string): Promise<string> {\n if (runtime.isBun) {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\ntype WriteOptions = {\n /**\n * When `true`, re-reads the file immediately after writing and throws if the\n * content does not match — useful for catching write failures on unreliable file systems.\n */\n sanity?: boolean\n}\n\n/**\n * Writes `data` to `path`, trimming leading/trailing whitespace before saving.\n * Skips the write when the trimmed content is empty or 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 content does not match.\n *\n * @example\n * ```ts\n * await write('./src/Pet.ts', source) // writes and returns trimmed content\n * await write('./src/Pet.ts', source) // null — file unchanged\n * await write('./src/Pet.ts', ' ') // null — empty content skipped\n * ```\n */\nexport async function write(path: string, data: string, options: WriteOptions = {}): Promise<string | null> {\n const trimmed = data.trim()\n if (trimmed === '') return null\n\n const resolved = resolve(path)\n\n if (runtime.isBun) {\n const file = Bun.file(resolved)\n const oldContent = (await file.exists()) ? await file.text() : null\n if (oldContent === trimmed) return null\n await Bun.write(resolved, trimmed)\n return trimmed\n }\n\n try {\n const oldContent = await readFile(resolved, { encoding: 'utf-8' })\n if (oldContent === trimmed) return null\n } catch {\n /* file doesn't exist yet */\n }\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, trimmed, { encoding: 'utf-8' })\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n if (savedData !== trimmed) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n return savedData\n }\n\n return trimmed\n}\n\n/**\n * Recursively removes `path`. Silently succeeds when `path` does not exist.\n *\n * @example\n * ```ts\n * await clean('./dist')\n * ```\n */\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n\n/**\n * Converts a filesystem path to use POSIX (`/`) separators.\n *\n * Most of the codebase compares and composes paths as strings (prefix matching, joining for\n * import specifiers, splitting on `/`). On POSIX `path.resolve` already returns `/`-separated\n * paths, but on Windows it returns `\\`-separated paths, which breaks every such comparison.\n *\n * Routing every path that crosses a module boundary through `toPosixPath` keeps the rest of the\n * code platform-agnostic. The conversion runs unconditionally so Windows-specific behavior is\n * exercisable from POSIX CI.\n *\n * @example\n * toPosixPath('C:\\\\repo\\\\src\\\\pet.ts') // 'C:/repo/src/pet.ts'\n */\nexport function toPosixPath(filePath: string): string {\n return filePath.replaceAll('\\\\', '/')\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\n\n/**\n * JSDoc documentation metadata attached to code declarations.\n */\nexport type JSDocNode = {\n /**\n * JSDoc comment lines. `undefined` entries are filtered out during rendering.\n *\n * @example\n * ```ts\n * ['@description A pet resource', '@deprecated']\n * ```\n */\n comments?: Array<string | undefined>\n}\n\n/**\n * AST node representing a TypeScript `const` declaration.\n *\n * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createConst({ name: 'pet', export: true, asConst: true })\n * // export const pet = ... as const\n * ```\n */\nexport type ConstNode = BaseNode & {\n kind: 'Const'\n /**\n * Name of the constant declaration.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * Explicit type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n type?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Whether to append `as const` to the declaration.\n */\n asConst?: boolean | null\n /**\n * Child nodes representing the value of the constant (children of the `Const` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `type` alias declaration.\n *\n * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport type TypeNode = BaseNode & {\n kind: 'Type'\n /**\n * Name of the type alias.\n */\n name: string\n /**\n * Whether the declaration should be exported.\n */\n export?: boolean | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the type body (children of the `Type` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript `function` declaration.\n *\n * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createFunctionDeclaration({ name: 'getPet', export: true, async: true, returnType: 'Pet' })\n * // export async function getPet(): Promise<Pet> { ... }\n * ```\n */\nexport type FunctionNode = BaseNode & {\n kind: 'Function'\n /**\n * Name of the function.\n */\n name: string\n /**\n * Whether the function is a default export.\n */\n default?: boolean | null\n /**\n * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).\n */\n params?: string | null\n /**\n * Whether the function should be exported.\n */\n export?: boolean | null\n /**\n * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.\n */\n async?: boolean | null\n /**\n * TypeScript generic type parameters.\n *\n * @example Constrained generics\n * `['T', 'U extends string']`\n */\n generics?: string | Array<string> | null\n /**\n * Return type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n returnType?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Child nodes representing the function body (children of the `Function` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a TypeScript arrow function (`const name = () => { ... }`).\n *\n * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.\n * The `children` prop of the component is represented as `nodes`.\n *\n * @example\n * ```ts\n * createArrowFunctionDeclaration({ name: 'getPet', export: true, singleLine: true })\n * // export const getPet = () => ...\n * ```\n */\nexport type ArrowFunctionNode = BaseNode & {\n kind: 'ArrowFunction'\n /**\n * Name of the arrow function (used as the `const` variable name).\n */\n name: string\n /**\n * Whether the function is a default export.\n */\n default?: boolean | null\n /**\n * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).\n */\n params?: string | null\n /**\n * Whether the arrow function should be exported.\n */\n export?: boolean | null\n /**\n * Whether the arrow function is async. When `true`, the return type is wrapped in `Promise<>`.\n */\n async?: boolean | null\n /**\n * TypeScript generic type parameters.\n *\n * @example Constrained generics\n * `['T', 'U extends string']`\n */\n generics?: string | Array<string> | null\n /**\n * Return type annotation.\n *\n * @example Type reference\n * `'Pet'`\n */\n returnType?: string | null\n /**\n * JSDoc documentation metadata.\n */\n JSDoc?: JSDocNode | null\n /**\n * Render the arrow function body as a single-line expression.\n */\n singleLine?: boolean | null\n /**\n * Child nodes representing the function body (children of the `Function.Arrow` component).\n * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * AST node representing a raw text/string fragment in the source output.\n *\n * Used instead of bare `string` values so that all entries in `nodes` arrays\n * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport type TextNode = BaseNode & {\n kind: 'Text'\n /**\n * The raw string content.\n */\n value: string\n}\n\n/**\n * AST node representing a line break in the source output.\n *\n * Corresponds to `<br/>` in JSX components. When printed it produces an empty string,\n * so joining nodes with `\\n` in `printNodes` leaves a blank line between the surrounding code.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * // prints as '' → blank line when surrounded by other nodes\n * ```\n */\nexport type BreakNode = BaseNode & {\n kind: 'Break'\n}\n\n/**\n * AST node representing a raw JSX fragment in the source output.\n *\n * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup\n * (including fragments `<>…</>`) directly in generated code.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport type JsxNode = BaseNode & {\n kind: 'Jsx'\n /**\n * The raw JSX string content.\n */\n value: string\n}\n\n/**\n * Union of all code-generation AST nodes.\n *\n * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as\n * structured children in {@link SourceNode.nodes}.\n */\nexport type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode\n\n/**\n * Definition for the {@link ConstNode}.\n */\nexport const constDef = defineNode<ConstNode>({ kind: 'Const' })\n\n/**\n * Creates a `ConstNode` representing a TypeScript `const` declaration.\n *\n * @example Exported constant with type and `as const`\n * ```ts\n * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })\n * // export const pets: Pet[] = ... as const\n * ```\n */\nexport const createConst = constDef.create\n\n/**\n * Definition for the {@link TypeNode}.\n */\nexport const typeDef = defineNode<TypeNode>({ kind: 'Type' })\n\n/**\n * Creates a `TypeNode` representing a TypeScript `type` alias declaration.\n *\n * @example\n * ```ts\n * createType({ name: 'Pet', export: true })\n * // export type Pet = ...\n * ```\n */\nexport const createType = typeDef.create\n\n/**\n * Definition for the {@link FunctionNode}.\n */\nexport const functionDef = defineNode<FunctionNode>({ kind: 'Function' })\n\n/**\n * Creates a `FunctionNode` representing a TypeScript `function` declaration.\n *\n * @example\n * ```ts\n * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })\n * // export async function fetchPet(): Promise<Pet> { ... }\n * ```\n */\nexport const createFunction = functionDef.create\n\n/**\n * Definition for the {@link ArrowFunctionNode}.\n */\nexport const arrowFunctionDef = defineNode<ArrowFunctionNode>({ kind: 'ArrowFunction' })\n\n/**\n * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.\n *\n * @example\n * ```ts\n * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })\n * // export const double = (n: number) => ...\n * ```\n */\nexport const createArrowFunction = arrowFunctionDef.create\n\n/**\n * Definition for the {@link TextNode}.\n */\nexport const textDef = defineNode<TextNode, string>({ kind: 'Text', build: (value) => ({ value }) })\n\n/**\n * Creates a {@link TextNode} representing a raw string fragment in the source output.\n *\n * @example\n * ```ts\n * createText('return fetch(id)')\n * // { kind: 'Text', value: 'return fetch(id)' }\n * ```\n */\nexport const createText = textDef.create\n\n/**\n * Definition for the {@link BreakNode}.\n */\nexport const breakDef = defineNode<BreakNode, void>({ kind: 'Break', build: () => ({}) })\n\n/**\n * Creates a {@link BreakNode} representing a line break in the source output.\n *\n * @example\n * ```ts\n * createBreak()\n * // { kind: 'Break' }\n * ```\n */\nexport function createBreak(): BreakNode {\n return breakDef.create()\n}\n\n/**\n * Definition for the {@link JsxNode}.\n */\nexport const jsxDef = defineNode<JsxNode, string>({ kind: 'Jsx', build: (value) => ({ value }) })\n\n/**\n * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.\n *\n * @example\n * ```ts\n * createJsx('<>\\n <a href={href}>Open</a>\\n</>')\n * // { kind: 'Jsx', value: '<>\\n <a href={href}>Open</a>\\n</>' }\n * ```\n */\nexport const createJsx = jsxDef.create\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one content-type entry of a request body or response.\n *\n * There is one entry per content type declared in the spec (e.g. `application/json`,\n * `multipart/form-data`), and each entry holds its own body schema.\n *\n * @example\n * ```ts\n * const content: ContentNode = {\n * kind: 'Content',\n * contentType: 'application/json',\n * schema: createSchema({ type: 'string' }),\n * }\n * ```\n */\nexport type ContentNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Content'\n /**\n * The content type for this entry (e.g. `'application/json'`).\n */\n contentType: string\n /**\n * Body schema for this content type.\n */\n schema?: SchemaNode\n /**\n * Property keys to exclude from the generated type via `Omit<Type, Keys>`.\n * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.\n */\n keysToOmit?: Array<string> | null\n}\n\n/**\n * Loosely-typed content entry accepted by the builders, normalized into a {@link ContentNode}.\n */\nexport type UserContent = Omit<ContentNode, 'kind'>\n\n/**\n * Definition for the {@link ContentNode}.\n */\nexport const contentDef = defineNode<ContentNode, UserContent>({\n kind: 'Content',\n children: ['schema'],\n})\n\n/**\n * Creates a `ContentNode` for a single request-body or response content type.\n */\nexport const createContent = contentDef.create\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { CodeNode } from './code.ts'\n\n/**\n * Supported file extensions.\n */\ntype Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\ntype ImportName = string | Array<string | { propertyName: string; name?: string }>\n\n/**\n * Represents a language-agnostic import/dependency declaration.\n *\n * @example Named import (TypeScript: `import { useState } from 'react'`)\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * ```\n *\n * @example Default import (TypeScript: `import React from 'react'`)\n * ```ts\n * createImport({ name: 'React', path: 'react' })\n * ```\n *\n * @example Type-only import (TypeScript: `import type { FC } from 'react'`)\n * ```ts\n * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })\n * ```\n *\n * @example Namespace import (TypeScript: `import * as React from 'react'`)\n * ```ts\n * createImport({ name: 'React', path: 'react', isNameSpace: true })\n * ```\n */\nexport type ImportNode = BaseNode & {\n kind: 'Import'\n /**\n * Import name(s) to be used.\n *\n * @example Named imports\n * `['useState']`\n *\n * @example Default import\n * `'React'`\n */\n name: ImportName\n /**\n * Path for the import.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n */\n isTypeOnly?: boolean | null\n /**\n * Import the entire module as a namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates a standard import\n */\n isNameSpace?: boolean | null\n /**\n * When set, the import path is resolved relative to this root.\n */\n root?: string | null\n}\n\n/**\n * Represents a language-agnostic export/public API declaration.\n *\n * @example Named export (TypeScript: `export { Pets } from './Pets'`)\n * ```ts\n * createExport({ name: ['Pets'], path: './Pets' })\n * ```\n *\n * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })\n * ```\n *\n * @example Wildcard export (TypeScript: `export * from './utils'`)\n * ```ts\n * createExport({ path: './utils' })\n * ```\n *\n * @example Namespace alias (TypeScript: `export * as utils from './utils'`)\n * ```ts\n * createExport({ name: 'utils', path: './utils', asAlias: true })\n * ```\n */\nexport type ExportNode = BaseNode & {\n kind: 'Export'\n /**\n * Export name(s) to be used. When omitted, generates a wildcard export.\n *\n * @example Named exports\n * `['useState']`\n *\n * @example Single export\n * `'React'`\n */\n name?: string | Array<string> | null\n /**\n * Path for the export.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n */\n isTypeOnly?: boolean | null\n /**\n * Export as an aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates a standard export\n */\n asAlias?: boolean | null\n}\n\n/**\n * Represents a fragment of source code within a file.\n *\n * @example Named exportable source\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })\n * ```\n *\n * @example Inline unnamed code block\n * ```ts\n * createSource({ nodes: [createText('const x = 1')] })\n * ```\n */\nexport type SourceNode = BaseNode & {\n kind: 'Source'\n /**\n * Optional name identifying this source (used for deduplication and barrel generation).\n */\n name?: string | null\n /**\n * Mark this source as a type-only export.\n */\n isTypeOnly?: boolean | null\n /**\n * Include the `export` keyword in the generated source.\n */\n isExportable?: boolean | null\n /**\n * Include this source in barrel/index file generation.\n */\n isIndexable?: boolean | null\n /**\n * Child nodes that make up this source fragment, in DOM order.\n * Use a {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * Represents a fully resolved file in the AST.\n *\n * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input\n * and deduplicates `imports`, `exports`, and `sources`.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of the path\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport type FileNode<TMeta extends object = object> = BaseNode & {\n kind: 'File'\n /**\n * Unique identifier derived from a SHA256 hash of the file path. `createFile`\n * computes it, so callers do not need to provide it.\n */\n id: string\n /**\n * File name without extension, derived from `baseName`.\n * @link https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n /**\n * File base name, including extension.\n * Based on UNIX basename: `${name}${extname}`\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: `${string}.${string}`\n /**\n * Full qualified path to the file.\n */\n path: string\n /**\n * File extension extracted from `baseName`.\n */\n extname: Extname\n /**\n * Deduplicated list of source code fragments.\n */\n sources: Array<SourceNode>\n /**\n * Deduplicated list of import declarations.\n */\n imports: Array<ImportNode>\n /**\n * Deduplicated list of export declarations.\n */\n exports: Array<ExportNode>\n /**\n * Optional metadata attached to this file, read by plugins during barrel generation.\n */\n meta?: TMeta\n /**\n * Optional banner prepended to the generated file content.\n * Accepts `null` so `resolver.resolveBanner()` results can be passed directly.\n */\n banner?: string | null\n /**\n * Optional footer appended to the generated file content.\n * Accepts `null` so `resolver.resolveFooter()` results can be passed directly.\n */\n footer?: string | null\n}\n\n/**\n * Definition for the {@link ImportNode}.\n */\nexport const importDef = defineNode<ImportNode>({ kind: 'Import' })\n\n/**\n * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.\n *\n * @example Named import\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * // import { useState } from 'react'\n * ```\n */\nexport const createImport = importDef.create\n\n/**\n * Definition for the {@link ExportNode}.\n */\nexport const exportDef = defineNode<ExportNode>({ kind: 'Export' })\n\n/**\n * Creates an `ExportNode` representing a language-agnostic export/public API declaration.\n *\n * @example Named export\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet' })\n * // export { Pet } from './Pet'\n * ```\n */\nexport const createExport = exportDef.create\n\n/**\n * Definition for the {@link SourceNode}.\n */\nexport const sourceDef = defineNode<SourceNode>({ kind: 'Source' })\n\n/**\n * Creates a `SourceNode` representing a fragment of source code within a file.\n *\n * @example\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })\n * ```\n */\nexport const createSource = sourceDef.create\n\n/**\n * Definition for the {@link FileNode}. The fully resolved builder lives in\n * `createFile`, so this definition only supplies the guard.\n */\nexport const fileDef = defineNode<FileNode>({ kind: 'File' })\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\n\n/**\n * A language-agnostic type expression used as a function parameter type annotation.\n *\n * - a plain `string` is a type reference rendered as-is, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`\n * - a {@link TypeLiteralNode} is an inline anonymous type, e.g. `{ petId: string; name?: string }`\n * - an {@link IndexedAccessTypeNode} is a single field accessed from a named type, e.g. `PathParams['petId']`\n */\nexport type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode\n\n/**\n * AST node for an inline anonymous object type grouping named fields.\n * TypeScript renders as `{ key: Type; other?: OtherType }`.\n *\n * @example\n * ```ts\n * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })\n * // { petId: string }\n * ```\n */\nexport type TypeLiteralNode = BaseNode & {\n kind: 'TypeLiteral'\n /**\n * Members of the object type, rendered in order.\n */\n members: Array<{\n /**\n * Member key.\n */\n name: string\n /**\n * Member type expression.\n */\n type: TypeExpression\n /**\n * Whether the member is optional, rendered with `?`.\n */\n optional?: boolean\n }>\n}\n\n/**\n * AST node for a single field accessed from a named group type.\n * TypeScript renders as `objectType['indexType']`.\n *\n * @example\n * ```ts\n * createIndexedAccessType({ objectType: 'GetPetPathParams', indexType: 'petId' })\n * // GetPetPathParams['petId']\n * ```\n */\nexport type IndexedAccessTypeNode = BaseNode & {\n kind: 'IndexedAccessType'\n /**\n * Name of the type being indexed, e.g. `'GetPetPathParams'`.\n */\n objectType: string\n /**\n * Field key to access, e.g. `'petId'`.\n */\n indexType: string\n}\n\n/**\n * AST node for an object destructuring binding, used as the name of a grouped function parameter.\n * TypeScript renders as `{ id, name }` or `{ id: renamed }` when `propertyName` differs.\n *\n * @example\n * ```ts\n * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })\n * // { id, name }\n * ```\n */\nexport type ObjectBindingPatternNode = BaseNode & {\n kind: 'ObjectBindingPattern'\n /**\n * Bound elements, rendered in order.\n */\n elements: Array<{\n /**\n * Local binding name.\n */\n name: string\n /**\n * Source key when it differs from the binding name, rendered as `propertyName: name`.\n */\n propertyName?: string\n }>\n}\n\n/**\n * AST node for one function parameter.\n *\n * A simple parameter has a `string` name. A destructured group has an\n * {@link ObjectBindingPatternNode} name paired with a {@link TypeLiteralNode} type.\n *\n * @example Required parameter\n * `name: Type`\n *\n * @example Optional parameter\n * `name?: Type`\n *\n * @example Parameter with default value\n * `name: Type = defaultValue`\n *\n * @example Rest parameter\n * `...name: Type[]`\n *\n * @example Destructured group\n * `{ id, name? }: { id: string; name?: string } = {}`\n */\nexport type FunctionParameterNode = BaseNode & {\n kind: 'FunctionParameter'\n /**\n * Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.\n */\n name: string | ObjectBindingPatternNode\n /**\n * Type annotation as a {@link TypeExpression}. Omit for untyped output.\n */\n type?: TypeExpression\n /**\n * Whether the parameter is optional, rendered with `?`.\n */\n optional?: boolean\n /**\n * Default value, written verbatim after `=`. Commonly `'{}'` for a destructured group.\n */\n default?: string\n /**\n * When `true` the parameter is emitted as a rest parameter, e.g. `...name: Type[]`.\n */\n rest?: boolean\n}\n\n/**\n * AST node for a complete function parameter list.\n *\n * Printers are responsible for sorting (`required` → `optional` → `defaulted`).\n * Nodes are plain immutable data.\n *\n * Renders differently depending on the output mode:\n * - `declaration` → `(id: string, config: Config = {})` function declaration parameters\n * - `call` → `(id, { method, url })` function call arguments\n */\nexport type FunctionParametersNode = BaseNode & {\n kind: 'FunctionParameters'\n /**\n * Ordered parameter nodes.\n */\n params: ReadonlyArray<FunctionParameterNode>\n}\n\n/**\n * Union of all function-parameter AST node variants used by the function-parameter printer.\n */\nexport type FunctionParamNode = FunctionParameterNode | FunctionParametersNode | TypeLiteralNode | IndexedAccessTypeNode | ObjectBindingPatternNode\n\n/**\n * Handler-map keys for the function-parameter printer, one per {@link FunctionParamNode} kind.\n */\nexport type FunctionParamKind = FunctionParamNode['kind']\n\n/**\n * Definition for the {@link TypeLiteralNode}.\n */\nexport const typeLiteralDef = defineNode<TypeLiteralNode, Pick<TypeLiteralNode, 'members'>>({ kind: 'TypeLiteral' })\n\n/**\n * Creates a {@link TypeLiteralNode} representing an inline anonymous object type.\n *\n * @example\n * ```ts\n * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })\n * // { petId: string }\n * ```\n */\nexport const createTypeLiteral = typeLiteralDef.create\n\n/**\n * Definition for the {@link IndexedAccessTypeNode}.\n */\nexport const indexedAccessTypeDef = defineNode<IndexedAccessTypeNode, Omit<IndexedAccessTypeNode, 'kind'>>({ kind: 'IndexedAccessType' })\n\n/**\n * Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.\n *\n * @example\n * ```ts\n * createIndexedAccessType({ objectType: 'DeletePetPathParams', indexType: 'petId' })\n * // DeletePetPathParams['petId']\n * ```\n */\nexport const createIndexedAccessType = indexedAccessTypeDef.create\n\n/**\n * Definition for the {@link ObjectBindingPatternNode}.\n */\nexport const objectBindingPatternDef = defineNode<ObjectBindingPatternNode, Pick<ObjectBindingPatternNode, 'elements'>>({ kind: 'ObjectBindingPattern' })\n\n/**\n * Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.\n *\n * @example\n * ```ts\n * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })\n * // { id, name }\n * ```\n */\nexport const createObjectBindingPattern = objectBindingPatternDef.create\n\n/**\n * Plain property descriptor for a destructured group built by {@link createFunctionParameter}.\n */\ntype FunctionParameterProperty = {\n name: string\n type: TypeExpression\n optional?: boolean\n}\n\ntype FunctionParameterInput =\n | { name: string; type?: TypeExpression; optional?: boolean; default?: string; rest?: boolean }\n | { properties: Array<FunctionParameterProperty>; optional?: boolean; default?: string }\n\n/**\n * Definition for the {@link FunctionParameterNode}. `optional` defaults to `false`.\n * Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name\n * paired with a {@link TypeLiteralNode} type.\n */\nexport const functionParameterDef = defineNode<FunctionParameterNode, FunctionParameterInput>({\n kind: 'FunctionParameter',\n build: (input) => {\n if ('properties' in input) {\n return {\n name: createObjectBindingPattern({ elements: input.properties.map((p) => ({ name: p.name })) }),\n type: createTypeLiteral({ members: input.properties.map((p) => ({ name: p.name, type: p.type, optional: p.optional ?? false })) }),\n optional: input.optional ?? false,\n ...(input.default !== undefined ? { default: input.default } : {}),\n }\n }\n return { optional: false, ...input }\n },\n})\n\n/**\n * Creates a `FunctionParameterNode`. `optional` defaults to `false`.\n *\n * @example Optional param\n * ```ts\n * createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })\n * // → params?: QueryParams\n * ```\n *\n * @example Destructured group\n * ```ts\n * createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })\n * // → { id, name }: { id: string; name?: string } = {}\n * ```\n */\nexport const createFunctionParameter = functionParameterDef.create\n\n/**\n * Definition for the {@link FunctionParametersNode}.\n */\nexport const functionParametersDef = defineNode<FunctionParametersNode, Partial<Omit<FunctionParametersNode, 'kind'>>>({\n kind: 'FunctionParameters',\n defaults: { params: [] },\n})\n\n/**\n * Creates a `FunctionParametersNode` from an ordered list of parameters.\n *\n * @example\n * ```ts\n * const empty = createFunctionParameters()\n * // { kind: 'FunctionParameters', params: [] }\n * ```\n */\nexport function createFunctionParameters(props: Partial<Omit<FunctionParametersNode, 'kind'>> = {}): FunctionParametersNode {\n return functionParametersDef.create(props)\n}\n","import type { Streamable } from '@internals/utils'\nimport { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { OperationNode } from './operation.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * Metadata for an API document, populated by the adapter and available to every generator.\n *\n * All fields are plain JSON-serializable values, no `Set`, no `Map`, no class instances.\n * Computed fields (`circularNames`, `enumNames`) are pre-calculated once during the adapter\n * pre-scan so generators never need to iterate the full schema list themselves.\n *\n * @example\n * ```ts\n * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://petstore.swagger.io/v2', circularNames: [], enumNames: [] }\n * ```\n */\nexport type InputMeta = {\n /**\n * API title from `info.title` in the source document.\n */\n title?: string\n /**\n * API description from `info.description` in the source document.\n */\n description?: string\n /**\n * API version string from `info.version` in the source document.\n */\n version?: string\n /**\n * Resolved base URL from the first matching server entry in the source document.\n */\n baseURL?: string | null\n /**\n * Names of schemas that participate in a circular reference chain.\n * Computed once during the adapter pre-scan, so a generator never has to\n * call `findCircularSchemas` itself.\n *\n * Convert to a `Set` once at the start of a generator, not per-schema,\n * so lookups stay O(1) without repeated allocations.\n *\n * @example Wrap a circular schema in z.lazy()\n * ```ts\n * const circular = new Set(meta.circularNames)\n * if (circular.has(schema.name)) { ... }\n * ```\n */\n circularNames: ReadonlyArray<string>\n /**\n * Names of schemas whose type is `enum`.\n * Computed once during the adapter pre-scan, so a generator never has to\n * filter the schema list itself.\n *\n * Convert to a `Set` once at the start of a generator when you need repeated\n * membership checks, so each check stays O(1) instead of an array scan.\n *\n * @example Check if a referenced schema is an enum\n * `const enums = new Set(meta.enumNames)`\n * `const isEnum = enums.has(schemaName)`\n */\n enumNames: ReadonlyArray<string>\n}\n\n/**\n * Input AST node that contains all schemas and operations for one API document.\n * Produced by the adapter and consumed by all Kubb plugins.\n *\n * `Stream` switches `schemas` and `operations` between eager `Array`s (the default) and lazy\n * `AsyncIterable`s. The streaming variant `InputNode<true>` yields nodes one at a time and makes\n * `meta` optional, since the adapter can emit metadata before the first node is parsed.\n *\n * @example\n * ```ts\n * const input: InputNode = {\n * kind: 'Input',\n * schemas: [],\n * operations: [],\n * meta: { circularNames: [], enumNames: [] },\n * }\n * ```\n *\n * @example Streaming variant for large specs\n * ```ts\n * for await (const schema of inputNode.schemas) {\n * // only this one SchemaNode is live here. Previous ones are GC-eligible\n * }\n * ```\n */\nexport type InputNode<Stream extends boolean = false> = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Input'\n /**\n * All schema nodes in the document.\n */\n schemas: Streamable<SchemaNode, Stream>\n /**\n * All operation nodes in the document.\n */\n operations: Streamable<OperationNode, Stream>\n} & (Stream extends true ? { meta?: InputMeta } : { meta: InputMeta })\n\n/**\n * Definition for the {@link InputNode}.\n */\nexport const inputDef = defineNode<InputNode, Partial<Omit<InputNode, 'kind'>>>({\n kind: 'Input',\n defaults: { schemas: [], operations: [], meta: { circularNames: [], enumNames: [] } },\n children: ['schemas', 'operations'],\n visitorKey: 'input',\n})\n\n/**\n * Creates an `InputNode`. Pass `stream: true` for the streaming variant whose `schemas` and\n * `operations` are `AsyncIterable` sources and whose `meta` is optional. Otherwise it builds the\n * eager variant with array `schemas`/`operations` and the defaulted `meta`.\n *\n * @example Eager\n * ```ts\n * const input = createInput()\n * // { kind: 'Input', schemas: [], operations: [] }\n * ```\n *\n * @example Streaming\n * ```ts\n * const node = createInput({ stream: true, schemas: schemasIterable, operations: operationsIterable, meta: { title: 'My API' } })\n * ```\n */\nexport function createInput<Stream extends boolean = false>(options: Partial<Omit<InputNode<Stream>, 'kind'>> & { stream?: Stream } = {}): InputNode<Stream> {\n const { stream, ...overrides } = options\n // Streaming inputs carry AsyncIterable sources, so skip the array/meta defaults that\n // inputDef.create applies for the eager variant.\n if (stream) {\n return { kind: 'Input', ...overrides } as InputNode<Stream>\n }\n return inputDef.create(overrides as Partial<Omit<InputNode, 'kind'>>) as InputNode<Stream>\n}\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport { type ContentNode, createContent, type UserContent } from './content.ts'\n\n/**\n * AST node representing an operation request body.\n *\n * Body schemas live exclusively inside the `content` array (one entry per content type),\n * mirroring {@link ResponseNode}.\n *\n * @example\n * ```ts\n * const requestBody: RequestBodyNode = {\n * kind: 'RequestBody',\n * required: true,\n * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type RequestBodyNode = BaseNode & {\n kind: 'RequestBody'\n /**\n * Request body description carried over from the spec.\n */\n description?: string\n /**\n * Whether the request body is required (`requestBody.required: true` in the spec).\n * When `false` or absent, the generated `data` parameter should be optional.\n */\n required?: boolean\n /**\n * Content type entries for this request body.\n *\n * When the adapter `contentType` option is set, this array contains exactly one entry for\n * that content type. Otherwise it contains one entry per content type declared in the spec,\n * so plugins can generate code for every variant (for example, separate hooks for\n * `application/json` and `multipart/form-data`).\n */\n content?: Array<ContentNode>\n}\n\n/**\n * Loosely-typed request body accepted by `createOperation`, normalized into a {@link RequestBodyNode}.\n */\nexport type UserRequestBody = Omit<RequestBodyNode, 'kind' | 'content'> & {\n content?: Array<UserContent>\n}\n\n/**\n * Definition for the {@link RequestBodyNode}, normalizing each content entry into a `ContentNode`.\n */\nexport const requestBodyDef = defineNode<RequestBodyNode, UserRequestBody>({\n kind: 'RequestBody',\n build: (props) => ({ ...props, content: props.content?.map(createContent) }),\n children: ['content'],\n})\n\n/**\n * Creates a `RequestBodyNode`, normalizing each content entry into a `ContentNode`.\n */\nexport const createRequestBody = requestBodyDef.create\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { ParameterNode } from './parameter.ts'\nimport { createRequestBody, type RequestBodyNode, type UserRequestBody } from './requestBody.ts'\nimport type { ResponseNode } from './response.ts'\n\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE'\n\n/**\n * Transport an operation belongs to.\n */\ntype OperationProtocol = 'http'\n\n/**\n * Fields shared by every operation, regardless of transport.\n */\ntype OperationNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Operation'\n /**\n * Operation identifier, usually from OpenAPI `operationId`.\n */\n operationId: string\n /**\n * Group labels for the operation.\n * Usually copied from OpenAPI `tags`.\n */\n tags: Array<string>\n /**\n * Short one-line operation summary.\n */\n summary?: string\n /**\n * Full operation description.\n */\n description?: string\n /**\n * Marks the operation as deprecated.\n */\n deprecated?: boolean\n /**\n * Query, path, header, and cookie parameters for the operation.\n */\n parameters: Array<ParameterNode>\n /**\n * Request body for the operation.\n */\n requestBody?: RequestBodyNode\n /**\n * Operation responses.\n */\n responses: Array<ResponseNode>\n}\n\n/**\n * Operation served over HTTP/REST (OpenAPI). `method` and `path` are guaranteed.\n *\n * @example\n * ```ts\n * const operation: HttpOperationNode = {\n * kind: 'Operation',\n * operationId: 'listPets',\n * protocol: 'http',\n * method: 'GET',\n * path: '/pets',\n * tags: [],\n * parameters: [],\n * responses: [],\n * }\n * ```\n */\nexport type HttpOperationNode = OperationNodeBase & {\n /**\n * Transport the operation belongs to.\n */\n protocol?: 'http'\n /**\n * HTTP method like `'GET'`.\n */\n method: HttpMethod\n /**\n * OpenAPI-style path string, for example `/pets/{petId}`, with `{param}` notation preserved.\n */\n path: string\n}\n\n/**\n * Operation for a non-HTTP transport. HTTP-only fields are forbidden.\n */\nexport type GenericOperationNode = OperationNodeBase & {\n /**\n * Transport the operation belongs to.\n */\n protocol?: Exclude<OperationProtocol, 'http'>\n method?: never\n path?: never\n}\n\n/**\n * AST node representing one API operation.\n *\n * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees\n * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with\n * `isHttpOperationNode(node)` or `node.protocol === 'http'` before reading `method`/`path`.\n */\nexport type OperationNode = HttpOperationNode | GenericOperationNode\n\ntype OperationInput = {\n operationId: string\n method?: HttpOperationNode['method']\n path?: HttpOperationNode['path']\n requestBody?: UserRequestBody\n [key: string]: unknown\n}\n\n/**\n * Definition for the {@link OperationNode}. HTTP operations (those carrying both\n * `method` and `path`) are tagged with `protocol: 'http'`, and the request body is\n * normalized into a `RequestBodyNode`.\n */\nexport const operationDef = defineNode<OperationNode, OperationInput>({\n kind: 'Operation',\n build: (props) => {\n const { requestBody, ...rest } = props\n const isHttp = rest.method !== undefined && rest.path !== undefined\n\n return {\n tags: [],\n parameters: [],\n responses: [],\n ...rest,\n ...(isHttp ? { protocol: 'http' as const } : {}),\n requestBody: requestBody ? createRequestBody(requestBody) : undefined,\n }\n },\n children: ['parameters', 'requestBody', 'responses'],\n visitorKey: 'operation',\n})\n\n/**\n * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.\n *\n * @example\n * ```ts\n * const operation = createOperation({ operationId: 'getPetById', method: 'GET', path: '/pet/{petId}' })\n * // tags, parameters, and responses are []\n * ```\n */\nexport function createOperation(\n props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> &\n Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {\n requestBody?: UserRequestBody\n },\n): HttpOperationNode\nexport function createOperation(\n props: Pick<GenericOperationNode, 'operationId'> &\n Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {\n requestBody?: UserRequestBody\n },\n): GenericOperationNode\nexport function createOperation(props: OperationInput): OperationNode {\n return operationDef.create(props)\n}\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { FileNode } from './file.ts'\n\n/**\n * Output AST node that groups all generated file output for one API document.\n *\n * Produced by generators and consumed by the build pipeline to write files.\n *\n * @example\n * ```ts\n * const output: OutputNode = {\n * kind: 'Output',\n * files: [],\n * }\n * ```\n */\nexport type OutputNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Output'\n /**\n * Generated file nodes.\n */\n files: Array<FileNode>\n}\n\n/**\n * Definition for the {@link OutputNode}.\n */\nexport const outputDef = defineNode<OutputNode, Partial<Omit<OutputNode, 'kind'>>>({\n kind: 'Output',\n defaults: { files: [] },\n visitorKey: 'output',\n})\n\n/**\n * Creates an `OutputNode` with a stable default for `files`.\n *\n * @example\n * ```ts\n * const output = createOutput()\n * // { kind: 'Output', files: [] }\n * ```\n */\nexport function createOutput(overrides: Partial<Omit<OutputNode, 'kind'>> = {}): OutputNode {\n return outputDef.create(overrides)\n}\n","import { defineNode, syncOptionality } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\nexport type ParameterLocation = 'path' | 'query' | 'header' | 'cookie'\n\n/**\n * AST node representing one operation parameter.\n *\n * @example\n * ```ts\n * const param: ParameterNode = {\n * kind: 'Parameter',\n * name: 'petId',\n * in: 'path',\n * schema: createSchema({ type: 'string' }),\n * required: true,\n * }\n * ```\n */\nexport type ParameterNode = BaseNode & {\n kind: 'Parameter'\n /**\n * Parameter name.\n */\n name: string\n /**\n * Parameter location (`path`, `query`, `header`, or `cookie`).\n */\n in: ParameterLocation\n /**\n * Parameter schema.\n */\n schema: SchemaNode\n /**\n * Whether the parameter is required.\n */\n required: boolean\n}\n\ntype UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>\n\n/**\n * Definition for the {@link ParameterNode}. `required` defaults to `false` and the\n * schema's `optional`/`nullish` flags are kept in sync with it.\n */\nexport const parameterDef = defineNode<ParameterNode, UserParameterNode>({\n kind: 'Parameter',\n build: (props) => {\n const required = props.required ?? false\n return { ...props, required, schema: syncOptionality(props.schema, required) }\n },\n children: ['schema'],\n visitorKey: 'parameter',\n rebuild: true,\n})\n\n/**\n * Creates a `ParameterNode`.\n *\n * @example\n * ```ts\n * const param = createParameter({\n * name: 'petId',\n * in: 'path',\n * required: true,\n * schema: createSchema({ type: 'string' }),\n * })\n * ```\n */\nexport const createParameter = parameterDef.create\n","import { defineNode, syncOptionality } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one named object property.\n *\n * @example\n * ```ts\n * const property: PropertyNode = {\n * kind: 'Property',\n * name: 'id',\n * schema: createSchema({ type: 'integer' }),\n * required: true,\n * }\n * ```\n */\nexport type PropertyNode = BaseNode & {\n kind: 'Property'\n /**\n * Property key.\n */\n name: string\n /**\n * Property schema.\n */\n schema: SchemaNode\n /**\n * Whether the property is required.\n */\n required: boolean\n}\n\n/**\n * Loosely-typed property accepted by `createProperty`, with `required` optional.\n */\nexport type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>\n\n/**\n * Definition for the {@link PropertyNode}. `required` defaults to `false` and the\n * schema's `optional`/`nullish` flags are kept in sync with it.\n */\nexport const propertyDef = defineNode<PropertyNode, UserPropertyNode>({\n kind: 'Property',\n build: (props) => {\n const required = props.required ?? false\n return { ...props, required, schema: syncOptionality(props.schema, required) }\n },\n children: ['schema'],\n visitorKey: 'property',\n rebuild: true,\n})\n\n/**\n * Creates a `PropertyNode`.\n *\n * @example\n * ```ts\n * const property = createProperty({\n * name: 'status',\n * required: true,\n * schema: createSchema({ type: 'string', nullable: true }),\n * })\n * // required=true, no optional/nullish\n * ```\n */\nexport const createProperty = propertyDef.create\n","import { defineNode } from '../node.ts'\nimport type { BaseNode } from './base.ts'\nimport { type ContentNode, createContent, type UserContent } from './content.ts'\nimport type { StatusCode } from './http.ts'\nimport type { SchemaNode } from './schema.ts'\n\n/**\n * AST node representing one operation response variant.\n *\n * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside\n * the `content` array (one entry per content type), so the same schema is never duplicated at the\n * node root and inside `content`.\n *\n * @example\n * ```ts\n * const response: ResponseNode = {\n * kind: 'Response',\n * statusCode: '200',\n * content: [{ contentType: 'application/json', schema: createSchema({ type: 'string' }) }],\n * }\n * ```\n */\nexport type ResponseNode = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Response'\n /**\n * HTTP status code or `'default'` for a fallback response.\n */\n statusCode: StatusCode\n /**\n * Optional response description.\n */\n description?: string\n /**\n * All available content type entries for this response.\n *\n * When the adapter `contentType` option is set, this array contains exactly one entry for that\n * content type. Otherwise it contains one entry per content type declared in the spec, so that\n * plugins can generate a union of response types (e.g. `application/json` and `application/xml`).\n * Body-less responses keep a single entry whose `schema` is the empty/`void` placeholder.\n *\n * @example\n * ```ts\n * // spec response declares both application/json and application/xml\n * response.content[0].contentType // 'application/json'\n * response.content[1].contentType // 'application/xml'\n * ```\n */\n content?: Array<ContentNode>\n}\n\ntype ResponseInput = Pick<ResponseNode, 'statusCode'> &\n Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {\n content?: Array<UserContent>\n schema?: SchemaNode\n mediaType?: string | null\n keysToOmit?: Array<string> | null\n }\n\n/**\n * Definition for the {@link ResponseNode}. A single legacy `schema` (with optional\n * `mediaType`/`keysToOmit`) is normalized into one `content` entry.\n */\nexport const responseDef = defineNode<ResponseNode, ResponseInput>({\n kind: 'Response',\n build: (props) => {\n const { schema, mediaType, keysToOmit, content, ...rest } = props\n const entries = content ?? (schema ? [{ contentType: mediaType ?? 'application/json', schema, keysToOmit: keysToOmit ?? null }] : undefined)\n return { ...rest, content: entries?.map(createContent) }\n },\n children: ['content'],\n visitorKey: 'response',\n})\n\n/**\n * Creates a `ResponseNode`.\n *\n * @example\n * ```ts\n * const response = createResponse({\n * statusCode: '200',\n * content: [{ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) }],\n * })\n * ```\n */\nexport const createResponse = responseDef.create\n","import type { CodeNode } from '../nodes/code.ts'\n\n/**\n * Extracts all string content from a `CodeNode` tree recursively.\n *\n * Collects text node values, identifier references in string fields (`params`, `generics`, `returnType`, `type`),\n * and nested node content. Used to build the full source string for import filtering.\n */\nexport function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string {\n if (!nodes?.length) return ''\n return nodes\n .map((node) => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return node as string\n if (node.kind === 'Text') return node.value\n if (node.kind === 'Break') return ''\n if (node.kind === 'Jsx') return node.value\n\n const parts: Array<string> = []\n\n if ('params' in node && node.params) parts.push(node.params)\n if ('generics' in node && node.generics) parts.push(Array.isArray(node.generics) ? node.generics.join(', ') : node.generics)\n if ('returnType' in node && node.returnType) parts.push(node.returnType)\n if ('type' in node && typeof node.type === 'string') parts.push(node.type)\n\n const nested = extractStringsFromNodes(node.nodes)\n\n if (nested) parts.push(nested)\n\n return parts.join('\\n')\n })\n .filter(Boolean)\n .join('\\n')\n}\n","/**\n * File-member merging. `combineImports`, `combineExports`, and `combineSources` deduplicate and sort\n * the import, export, and source entries of one file, and drop imports nothing references. This works\n * on a file's members, not on schema content.\n *\n * For collapsing duplicate schema shapes by structural signature, see `dedupe.ts`.\n */\nimport type { ExportNode, ImportNode, SourceNode } from '../nodes/index.ts'\nimport { extractStringsFromNodes } from './extractStringsFromNodes.ts'\n\nfunction sourceKey(source: SourceNode): string {\n const nameKey = source.name ?? extractStringsFromNodes(source.nodes)\n return `${nameKey}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}`\n}\n\nfunction pathTypeKey(path: string, isTypeOnly: boolean | null | undefined): string {\n return `${path}:${isTypeOnly ?? false}`\n}\n\nfunction exportKey(path: string, name: string | null | undefined, isTypeOnly: boolean | null | undefined, asAlias: boolean | null | undefined): string {\n return `${path}:${name ?? ''}:${isTypeOnly ?? false}:${asAlias ?? ''}`\n}\n\nfunction importKey(path: string, name: string | null | undefined, isTypeOnly: boolean | null | undefined): string {\n return `${path}:${name ?? ''}:${isTypeOnly ?? false}`\n}\n\n/**\n * Computes a multi-level sort key for exports and imports:\n * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical path. Unnamed before named.\n */\nfunction sortKey(node: { name?: string | Array<unknown> | null; isTypeOnly?: boolean | null; path: string }): string {\n const isArray = Array.isArray(node.name) ? '1' : '0'\n const typeOnly = node.isTypeOnly ? '0' : '1'\n const hasName = node.name != null ? '1' : '0'\n const name = Array.isArray(node.name) ? node.name.toSorted().join('\\0') : (node.name ?? '')\n return `${isArray}:${typeOnly}:${node.path}:${hasName}:${name}`\n}\n\n/**\n * Deduplicates and merges `SourceNode` objects by `name + isExportable + isTypeOnly`.\n *\n * Unnamed sources are deduplicated by object reference. Returns a deduplicated array in original order.\n */\nexport function combineSources(sources: Array<SourceNode>): Array<SourceNode> {\n const seen = new Map<string, SourceNode>()\n for (const source of sources) {\n const key = sourceKey(source)\n if (!seen.has(key)) seen.set(key, source)\n }\n return [...seen.values()]\n}\n\n/**\n * Merges `incoming` names into `existing`, preserving order and dropping duplicates.\n *\n * Shared by `combineExports` and `combineImports` for the same-path name-merge case.\n */\nfunction mergeNameArrays<TName>(existing: Array<TName>, incoming: Array<TName>): Array<TName> {\n const merged = new Set(existing)\n for (const name of incoming) merged.add(name)\n return [...merged]\n}\n\n/**\n * Deduplicates and merges `ExportNode` objects by path and type.\n *\n * Named exports with the same path and `isTypeOnly` flag have their names merged into a single export.\n * Non-array exports are deduplicated by exact identity. Returns a sorted, deduplicated array.\n */\nexport function combineExports(exports: Array<ExportNode>): Array<ExportNode> {\n const result: Array<ExportNode> = []\n // Accumulates array-named exports keyed by `path:isTypeOnly` for name-merging\n const namedByPath = new Map<string, ExportNode>()\n // Deduplicates non-array exports by their exact identity\n const seen = new Set<string>()\n\n // Precompute sort keys once, avoids recomputing per comparison.\n const keyed = exports.map((node) => ({ node, key: sortKey(node) }))\n keyed.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n\n for (const { node: curr } of keyed) {\n const { name, path, isTypeOnly, asAlias } = curr\n\n if (Array.isArray(name)) {\n if (!name.length) continue\n\n const key = pathTypeKey(path, isTypeOnly)\n const existing = namedByPath.get(key)\n\n if (existing && Array.isArray(existing.name)) {\n existing.name = mergeNameArrays(existing.name, name)\n } else {\n const newItem: ExportNode = { ...curr, name: [...new Set(name)] }\n result.push(newItem)\n namedByPath.set(key, newItem)\n }\n } else {\n const key = exportKey(path, name, isTypeOnly, asAlias)\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n }\n\n return result\n}\n\n/**\n * Deduplicates and merges `ImportNode` objects, filtering out unused imports.\n *\n * Retains imports that are referenced in `source` or re-exported. Imports with the same path and\n * `isTypeOnly` flag have their names merged. Returns a sorted, deduplicated, filtered array.\n */\nexport function combineImports(imports: Array<ImportNode>, exports: Array<ExportNode>, source?: string): Array<ImportNode> {\n // Build a lookup of all exported names to retain imports that are re-exported\n const exportedNames = new Set(exports.flatMap((e) => (Array.isArray(e.name) ? e.name : e.name ? [e.name] : [])))\n const isUsed = (importName: string): boolean => !source || source.includes(importName) || exportedNames.has(importName)\n\n // Memoize object import names so the same logical (propertyName, name) pair always\n // reuses the same object reference. Set-based deduplication then works correctly.\n const importNameMemo = new Map<string, { propertyName: string; name?: string }>()\n const canonicalizeName = (n: string | { propertyName: string; name?: string }): string | { propertyName: string; name?: string } => {\n if (typeof n === 'string') return n\n const key = `${n.propertyName}:${n.name ?? ''}`\n if (!importNameMemo.has(key)) importNameMemo.set(key, n)\n return importNameMemo.get(key)!\n }\n\n // Paths that keep at least one used named import. A default import from such a path is retained\n // even when its binding can't be found in `source` e.g. a generated `client` default import\n // alongside `import type { Client } from <same path>`, where merged grouped output omits the body.\n const pathsWithUsedNamedImport = new Set<string>()\n for (const node of imports) {\n if (!Array.isArray(node.name)) continue\n if (node.name.some((item) => (typeof item === 'string' ? isUsed(item) : isUsed(item.name ?? item.propertyName)))) {\n pathsWithUsedNamedImport.add(node.path)\n }\n }\n\n const result: Array<ImportNode> = []\n // Accumulates array-named imports keyed by `path:isTypeOnly` for name-merging\n const namedByPath = new Map<string, ImportNode>()\n // Deduplicates non-array imports by their exact identity\n const seen = new Set<string>()\n\n // Precompute sort keys once, avoids recomputing per comparison.\n const keyed = imports.map((node) => ({ node, key: sortKey(node) }))\n keyed.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n\n for (const { node: curr } of keyed) {\n if (curr.path === curr.root) continue\n\n const { path, isTypeOnly } = curr\n let { name } = curr\n\n if (Array.isArray(name)) {\n name = [...new Set(name.map(canonicalizeName))].filter((item) => (typeof item === 'string' ? isUsed(item) : isUsed(item.name ?? item.propertyName)))\n if (!name.length) continue\n\n const key = pathTypeKey(path, isTypeOnly)\n const existing = namedByPath.get(key)\n\n if (existing && Array.isArray(existing.name)) {\n existing.name = mergeNameArrays(existing.name, name)\n } else {\n const newItem: ImportNode = { ...curr, name }\n result.push(newItem)\n namedByPath.set(key, newItem)\n }\n } else {\n if (name && !isUsed(name) && !pathsWithUsedNamedImport.has(path)) continue\n\n const key = importKey(path, name, isTypeOnly)\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n }\n\n return result\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { trimExtName } from '@internals/utils'\nimport type { FileNode, Node } from './nodes/index.ts'\nimport { extractStringsFromNodes } from './utils/extractStringsFromNodes.ts'\nimport { combineExports, combineImports, combineSources } from './utils/fileMerge.ts'\n\n// Node constructors, grouped under the `factory` namespace the way the TypeScript compiler exposes\n// `ts.factory.createX`. Aggregating them here lets `export * as factory from './factory.ts'` in the\n// barrel surface every `createX` alongside the `createFile`/`update` helpers from a single module.\nexport { createArrowFunction, createBreak, createConst, createFunction, createJsx, createText, createType } from './nodes/code.ts'\nexport { createContent } from './nodes/content.ts'\nexport { createExport, createImport, createSource } from './nodes/file.ts'\nexport { createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createTypeLiteral } from './nodes/function.ts'\nexport { createInput } from './nodes/input.ts'\nexport { createOperation } from './nodes/operation.ts'\nexport { createOutput } from './nodes/output.ts'\nexport { createParameter } from './nodes/parameter.ts'\nexport { createProperty } from './nodes/property.ts'\nexport { createRequestBody } from './nodes/requestBody.ts'\nexport { createResponse } from './nodes/response.ts'\nexport { createSchema } from './nodes/schema.ts'\n\n/**\n * Identity-preserving node update: returns `node` unchanged when every field in\n * `changes` already equals (by reference) the current value, otherwise a new node\n * with the changes applied.\n *\n * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the\n * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and\n * downstream passes can detect \"nothing changed\" by identity. Comparison is\n * shallow: a structurally-equal but newly-allocated array/object counts as a change.\n *\n * @example\n * ```ts\n * update(node, { name: node.name }) // -> same `node` reference\n * update(node, { name: 'renamed' }) // -> new node, `name` replaced\n * ```\n */\nexport function update<T extends Node>(node: T, changes: Partial<T>): T {\n for (const key in changes) {\n if (changes[key] !== node[key as keyof T]) {\n return { ...node, ...changes }\n }\n }\n\n return node\n}\n\n/**\n * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed\n * and `imports`/`exports`/`sources` are deduplicated.\n */\nexport type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> &\n Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>\n\n/**\n * Creates a fully resolved `FileNode` from a file input descriptor.\n *\n * Computes:\n * - `id` SHA256 hash of the file path\n * - `name` `baseName` without extension\n * - `extname` extension extracted from `baseName`\n *\n * Deduplicates:\n * - `sources` via `combineSources`\n * - `exports` via `combineExports`\n * - `imports` via `combineImports` (also filters unused imports)\n *\n * @throws {Error} when `baseName` has no extension.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of 'src/models/petStore.ts'\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const rawExtname = path.extname(input.baseName)\n // Handle dotfile basename like '.ts' where path.extname returns ''\n const extname = (rawExtname || (input.baseName.startsWith('.') ? input.baseName : '')) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const source = (input.sources ?? [])\n .flatMap((item) => item.nodes ?? [])\n .map((node) => extractStringsFromNodes([node]))\n .filter(Boolean)\n .join('\\n\\n')\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const combinedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || undefined) : []\n const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name): name is string => Boolean(name)))\n const nameOf = (item: string | { propertyName: string; name?: string }): string => (typeof item === 'string' ? item : (item.name ?? item.propertyName))\n // Drop self-imports. Consolidating output (`mode: 'file'`) can place a symbol's\n // definition and a cross-file import of it in the same file. The first pass catches imports that\n // resolve to this file's own path. The second drops imports of names the file already defines,\n // the case consolidation produces when the import path no longer matches `input.path`. Sources\n // stay intact, so the local definition remains. Bare specifiers like `'zod'` never match a path.\n const resolvedImports = combinedImports\n .filter((imp) => imp.path !== input.path)\n .flatMap((imp) => {\n if (!Array.isArray(imp.name)) {\n return typeof imp.name === 'string' && localNames.has(imp.name) ? [] : [imp]\n }\n const kept = imp.name.filter((item) => !localNames.has(nameOf(item)))\n if (!kept.length) return []\n return [kept.length === imp.name.length ? imp : { ...imp, name: kept }]\n })\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n return {\n kind: 'File',\n ...input,\n id: hash('sha256', input.path, 'hex'),\n name: trimExtName(input.baseName),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,\n sources: resolvedSources,\n meta: input.meta ?? ({} as TMeta),\n }\n}\n"],"mappings":";;;;;;;;AAyBA,SAAS,OAA2B,MAAgB;CAClD,QAAQ,SAA8B,KAAkB,SAAS;AACnE;;;;;;;;;;AAWA,SAAgB,gBAAgB,QAAoB,UAA+B;CACjF,MAAM,WAAW,OAAO,YAAY;CAEpC,OAAO;EACL,GAAG;EACH,UAAU,CAAC,YAAY,CAAC,WAAW,OAAO,KAAA;EAC1C,SAAS,CAAC,YAAY,WAAW,OAAO,KAAA;CAC1C;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SAAgB,WACd,QACwB;CACxB,MAAM,EAAE,MAAM,UAAU,OAAO,UAAU,YAAY,YAAY;CAEjE,SAAS,OAAO,OAAsB;EACpC,MAAM,OAAO,QAAQ,MAAM,KAAK,IAAI;EACpC,OAAO;GAAE,GAAG;GAAU,GAAI;GAAiB;EAAK;CAClD;CAEA,OAAO;EAAE;EAAM;EAAQ,IAAI,OAAc,IAAI;EAAG;EAAU;EAAY;CAAQ;AAChF;;;;;;;;ACmiBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;;;;;AAMA,MAAa,YAAY,WAA0C;CACjE,MAAM;CACN,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SAAS,CAAC,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC;EACpE,IAAI,CAAC,KAAK,QAAQ,OAAO,CAAC;EAC1B,OAAO,CAAC,KAAK,WAAW,IAAI,KAAK,SAAS,MAAM;GAAE,GAAG;GAAK,MAAM;EAAK,CAAC;CACxE,CAAC;CACH,MAAM,kBAAkB,MAAM,SAAS,SAAS,eAAe,MAAM,OAAO,IAAI,CAAC;CAEjF,OAAO;EACL,MAAM;EACN,GAAG;EACH,KAAA,GAAA,YAAA,KAAA,CAAS,UAAU,MAAM,MAAM,KAAK;EACpC,MAAM,YAAY,MAAM,QAAQ;EAChC;EACA,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAM,MAAM,QAAS,CAAC;CACxB;AACF"}
@@ -1,275 +0,0 @@
1
- const require_casing = require("./casing-BE2R1RXg.cjs");
2
- //#region src/guards.ts
3
- /**
4
- * Narrows a `SchemaNode` to the variant that matches `type`.
5
- *
6
- * @example
7
- * ```ts
8
- * const schema = createSchema({ type: 'string' })
9
- * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null
10
- * ```
11
- */
12
- function narrowSchema(node, type) {
13
- return node?.type === type ? node : null;
14
- }
15
- /**
16
- * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.
17
- *
18
- * @example
19
- * ```ts
20
- * if (isHttpOperationNode(node)) {
21
- * console.log(node.method, node.path)
22
- * }
23
- * ```
24
- */
25
- function isHttpOperationNode(node) {
26
- return node.protocol === "http" || node.method !== void 0 && node.path !== void 0;
27
- }
28
- //#endregion
29
- //#region src/utils/refs.ts
30
- const plainStringTypes = new Set([
31
- "string",
32
- "uuid",
33
- "email",
34
- "url",
35
- "datetime"
36
- ]);
37
- /**
38
- * Returns the last path segment of a reference string.
39
- *
40
- * @example
41
- * ```ts
42
- * extractRefName('#/components/schemas/Pet') // 'Pet'
43
- * ```
44
- */
45
- function extractRefName(ref) {
46
- return ref.split("/").at(-1) ?? ref;
47
- }
48
- /**
49
- * Builds a PascalCase child schema name by joining a parent name and property name.
50
- * Returns `null` when there is no parent to nest under.
51
- *
52
- * @example
53
- * ```ts
54
- * childName('Order', 'shipping_address') // 'OrderShippingAddress'
55
- * childName(undefined, 'params') // null
56
- * ```
57
- */
58
- function childName(parentName, propName) {
59
- return parentName ? require_casing.pascalCase([parentName, propName].join(" ")) : null;
60
- }
61
- /**
62
- * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
63
- * empty parts.
64
- *
65
- * @example
66
- * ```ts
67
- * enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'
68
- * ```
69
- */
70
- function enumPropName(parentName, propName, enumSuffix) {
71
- return require_casing.pascalCase([
72
- parentName,
73
- propName,
74
- enumSuffix
75
- ].filter(Boolean).join(" "));
76
- }
77
- /**
78
- * Type guard that returns `true` when a schema emits as a plain `string` type.
79
- *
80
- * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
81
- * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
82
- */
83
- function isStringType(node) {
84
- if (plainStringTypes.has(node.type)) return true;
85
- const temporal = narrowSchema(node, "date") ?? narrowSchema(node, "time");
86
- if (temporal) return temporal.representation !== "date";
87
- return false;
88
- }
89
- /**
90
- * Derives a {@link ParamGroupType} for a query or header group from the resolver.
91
- *
92
- * Returns `null` when there is no resolver, no params, or the group name equals the
93
- * individual param name (so there is no real group to emit).
94
- */
95
- function resolveGroupType({ node, params, group, resolver }) {
96
- if (!resolver || !params.length) return null;
97
- const firstParam = params[0];
98
- const groupName = (group === "query" ? resolver.resolveQueryParamsName : resolver.resolveHeaderParamsName).call(resolver, node, firstParam);
99
- if (groupName === resolver.resolveParamName(node, firstParam)) return null;
100
- return {
101
- type: groupName,
102
- optional: params.every((p) => !p.required)
103
- };
104
- }
105
- //#endregion
106
- Object.defineProperty(exports, "buildGroupParam", {
107
- enumerable: true,
108
- get: function() {
109
- return buildGroupParam;
110
- }
111
- });
112
- Object.defineProperty(exports, "buildJSDoc", {
113
- enumerable: true,
114
- get: function() {
115
- return buildJSDoc;
116
- }
117
- });
118
- Object.defineProperty(exports, "buildList", {
119
- enumerable: true,
120
- get: function() {
121
- return buildList;
122
- }
123
- });
124
- Object.defineProperty(exports, "buildObject", {
125
- enumerable: true,
126
- get: function() {
127
- return buildObject;
128
- }
129
- });
130
- Object.defineProperty(exports, "buildTypeLiteral", {
131
- enumerable: true,
132
- get: function() {
133
- return buildTypeLiteral;
134
- }
135
- });
136
- Object.defineProperty(exports, "caseParams", {
137
- enumerable: true,
138
- get: function() {
139
- return caseParams;
140
- }
141
- });
142
- Object.defineProperty(exports, "childName", {
143
- enumerable: true,
144
- get: function() {
145
- return childName;
146
- }
147
- });
148
- Object.defineProperty(exports, "collectUsedSchemaNames", {
149
- enumerable: true,
150
- get: function() {
151
- return collectUsedSchemaNames;
152
- }
153
- });
154
- Object.defineProperty(exports, "containsCircularRef", {
155
- enumerable: true,
156
- get: function() {
157
- return containsCircularRef;
158
- }
159
- });
160
- Object.defineProperty(exports, "createOperationParams", {
161
- enumerable: true,
162
- get: function() {
163
- return createOperationParams;
164
- }
165
- });
166
- Object.defineProperty(exports, "enumPropName", {
167
- enumerable: true,
168
- get: function() {
169
- return enumPropName;
170
- }
171
- });
172
- Object.defineProperty(exports, "extractRefName", {
173
- enumerable: true,
174
- get: function() {
175
- return extractRefName;
176
- }
177
- });
178
- Object.defineProperty(exports, "extractStringsFromNodes", {
179
- enumerable: true,
180
- get: function() {
181
- return extractStringsFromNodes;
182
- }
183
- });
184
- Object.defineProperty(exports, "findCircularSchemas", {
185
- enumerable: true,
186
- get: function() {
187
- return findCircularSchemas;
188
- }
189
- });
190
- Object.defineProperty(exports, "getNestedAccessor", {
191
- enumerable: true,
192
- get: function() {
193
- return getNestedAccessor;
194
- }
195
- });
196
- Object.defineProperty(exports, "isHttpOperationNode", {
197
- enumerable: true,
198
- get: function() {
199
- return isHttpOperationNode;
200
- }
201
- });
202
- Object.defineProperty(exports, "isStringType", {
203
- enumerable: true,
204
- get: function() {
205
- return isStringType;
206
- }
207
- });
208
- Object.defineProperty(exports, "isValidVarName", {
209
- enumerable: true,
210
- get: function() {
211
- return isValidVarName;
212
- }
213
- });
214
- Object.defineProperty(exports, "jsStringEscape", {
215
- enumerable: true,
216
- get: function() {
217
- return jsStringEscape;
218
- }
219
- });
220
- Object.defineProperty(exports, "narrowSchema", {
221
- enumerable: true,
222
- get: function() {
223
- return narrowSchema;
224
- }
225
- });
226
- Object.defineProperty(exports, "objectKey", {
227
- enumerable: true,
228
- get: function() {
229
- return objectKey;
230
- }
231
- });
232
- Object.defineProperty(exports, "resolveGroupType", {
233
- enumerable: true,
234
- get: function() {
235
- return resolveGroupType;
236
- }
237
- });
238
- Object.defineProperty(exports, "resolveParamType", {
239
- enumerable: true,
240
- get: function() {
241
- return resolveParamType;
242
- }
243
- });
244
- Object.defineProperty(exports, "stringify", {
245
- enumerable: true,
246
- get: function() {
247
- return stringify;
248
- }
249
- });
250
- Object.defineProperty(exports, "stringifyObject", {
251
- enumerable: true,
252
- get: function() {
253
- return stringifyObject;
254
- }
255
- });
256
- Object.defineProperty(exports, "syncSchemaRef", {
257
- enumerable: true,
258
- get: function() {
259
- return syncSchemaRef;
260
- }
261
- });
262
- Object.defineProperty(exports, "toRegExpString", {
263
- enumerable: true,
264
- get: function() {
265
- return toRegExpString;
266
- }
267
- });
268
- Object.defineProperty(exports, "trimQuotes", {
269
- enumerable: true,
270
- get: function() {
271
- return trimQuotes;
272
- }
273
- });
274
-
275
- //# sourceMappingURL=utils-BCtRXfhI.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-BCtRXfhI.cjs","names":["pascalCase"],"sources":["../src/guards.ts","../src/utils/refs.ts"],"sourcesContent":["import type { HttpOperationNode, OperationNode, SchemaNode, SchemaNodeByType } from './nodes/index.ts'\n\n/**\n * Narrows a `SchemaNode` to the variant that matches `type`.\n *\n * @example\n * ```ts\n * const schema = createSchema({ type: 'string' })\n * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null\n * ```\n */\nexport function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | null {\n return node?.type === type ? (node as SchemaNodeByType[T]) : null\n}\n\n/**\n * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.\n *\n * @example\n * ```ts\n * if (isHttpOperationNode(node)) {\n * console.log(node.method, node.path)\n * }\n * ```\n */\nexport function isHttpOperationNode(node: OperationNode): node is HttpOperationNode {\n return node.protocol === 'http' || (node.method !== undefined && node.path !== undefined)\n}\n","import { pascalCase } from '@internals/utils'\nimport { narrowSchema } from '../guards.ts'\nimport type { OperationNode, ParameterNode, SchemaNode } from '../nodes/index.ts'\nimport type { SchemaType } from '../nodes/schema.ts'\nimport type { OperationParamsResolver, ParamGroupType } from './operationParams.ts'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)\n\n/**\n * Returns the last path segment of a reference string.\n *\n * @example\n * ```ts\n * extractRefName('#/components/schemas/Pet') // 'Pet'\n * ```\n */\nexport function extractRefName(ref: string): string {\n return ref.split('/').at(-1) ?? ref\n}\n\n/**\n * Resolves the schema name of a ref node, falling back through `ref` → `name` → nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * ```ts\n * resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' })\n * // => 'Pet'\n * ```\n */\nexport function resolveRefName(node: SchemaNode | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.ref) return extractRefName(node.ref) ?? node.name ?? node.schema?.name ?? null\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Builds a PascalCase child schema name by joining a parent name and property name.\n * Returns `null` when there is no parent to nest under.\n *\n * @example\n * ```ts\n * childName('Order', 'shipping_address') // 'OrderShippingAddress'\n * childName(undefined, 'params') // null\n * ```\n */\nexport function childName(parentName: string | null | undefined, propName: string): string | null {\n return parentName ? pascalCase([parentName, propName].join(' ')) : null\n}\n\n/**\n * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any\n * empty parts.\n *\n * @example\n * ```ts\n * enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'\n * ```\n */\nexport function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string {\n return pascalCase([parentName, propName, enumSuffix].filter(Boolean).join(' '))\n}\n\n/**\n * Type guard that returns `true` when a schema emits as a plain `string` type.\n *\n * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`\n * types, returns `true` only when `representation` is `'string'` rather than `'date'`.\n */\nexport function isStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n\n/**\n * Derives a {@link ParamGroupType} for a query or header group from the resolver.\n *\n * Returns `null` when there is no resolver, no params, or the group name equals the\n * individual param name (so there is no real group to emit).\n */\nexport function resolveGroupType({\n node,\n params,\n group,\n resolver,\n}: {\n node: OperationNode\n params: Array<ParameterNode>\n group: 'query' | 'header'\n resolver: OperationParamsResolver | undefined\n}): ParamGroupType | null {\n if (!resolver || !params.length) {\n return null\n }\n const firstParam = params[0]!\n const groupMethod = group === 'query' ? resolver.resolveQueryParamsName : resolver.resolveHeaderParamsName\n const groupName = groupMethod.call(resolver, node, firstParam)\n if (groupName === resolver.resolveParamName(node, firstParam)) {\n return null\n }\n return { type: groupName, optional: params.every((p) => !p.required) }\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,aAA2C,MAA8B,MAAqC;CAC5H,OAAO,MAAM,SAAS,OAAQ,OAA+B;AAC/D;;;;;;;;;;;AAYA,SAAgB,oBAAoB,MAAgD;CAClF,OAAO,KAAK,aAAa,UAAW,KAAK,WAAW,KAAA,KAAa,KAAK,SAAS,KAAA;AACjF;;;ACrBA,MAAM,mBAAmB,IAAI,IAAgB;CAA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