@kubb/ast 5.0.0-beta.6 → 5.0.0-beta.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -10
- package/README.md +51 -27
- package/dist/chunk-CNktS9qV.js +17 -0
- package/dist/defineMacro-BLIR6k-j.d.ts +475 -0
- package/dist/defineMacro-BTXvS8nI.js +106 -0
- package/dist/defineMacro-BTXvS8nI.js.map +1 -0
- package/dist/defineMacro-Bv9R_9a2.cjs +123 -0
- package/dist/defineMacro-Bv9R_9a2.cjs.map +1 -0
- package/dist/extractStringsFromNodes-Cja-xxx5.js +29 -0
- package/dist/extractStringsFromNodes-Cja-xxx5.js.map +1 -0
- package/dist/extractStringsFromNodes-DKgDjFO0.cjs +34 -0
- package/dist/extractStringsFromNodes-DKgDjFO0.cjs.map +1 -0
- package/dist/extractStringsFromNodes-p4mX1TQD.d.ts +14 -0
- package/dist/factory-CZNOGI-N.js +283 -0
- package/dist/factory-CZNOGI-N.js.map +1 -0
- package/dist/factory-DG1CVkEb.cjs +300 -0
- package/dist/factory-DG1CVkEb.cjs.map +1 -0
- package/dist/factory.cjs +29 -0
- package/dist/factory.d.ts +62 -0
- package/dist/factory.js +3 -0
- package/dist/index-BzjwdK2M.d.ts +2433 -0
- package/dist/index.cjs +444 -2180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +94 -3408
- package/dist/index.js +395 -2101
- package/dist/index.js.map +1 -1
- package/dist/macros.cjs +117 -0
- package/dist/macros.cjs.map +1 -0
- package/dist/macros.d.ts +59 -0
- package/dist/macros.js +115 -0
- package/dist/macros.js.map +1 -0
- package/dist/operationParams-BZ07xDm0.d.ts +204 -0
- package/dist/response-KUdWiDWw.js +658 -0
- package/dist/response-KUdWiDWw.js.map +1 -0
- package/dist/response-hnSw2NKE.cjs +1027 -0
- package/dist/response-hnSw2NKE.cjs.map +1 -0
- package/dist/types-DyDzizSf.d.ts +364 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -0
- package/dist/utils-BLJwyza-.cjs +912 -0
- package/dist/utils-BLJwyza-.cjs.map +1 -0
- package/dist/utils-CF_-Pn_c.js +770 -0
- package/dist/utils-CF_-Pn_c.js.map +1 -0
- package/dist/utils.cjs +36 -0
- package/dist/utils.d.ts +358 -0
- package/dist/utils.js +4 -0
- package/dist/visitor-DJ6ZEJvq.js +548 -0
- package/dist/visitor-DJ6ZEJvq.js.map +1 -0
- package/dist/visitor-DpKZ9Tk0.cjs +654 -0
- package/dist/visitor-DpKZ9Tk0.cjs.map +1 -0
- package/package.json +21 -6
- package/src/constants.ts +19 -64
- package/src/dedupe.ts +239 -0
- package/src/defineMacro.ts +132 -0
- package/src/dialect.ts +53 -0
- package/src/factory.ts +67 -678
- package/src/guards.ts +10 -92
- package/src/index.ts +13 -44
- package/src/infer.ts +16 -14
- package/src/macros/index.ts +3 -0
- package/src/macros/macroDiscriminatorEnum.ts +44 -0
- package/src/macros/macroEnumName.ts +25 -0
- package/src/macros/macroSimplifyUnion.ts +50 -0
- package/src/mocks.ts +7 -127
- package/src/node.ts +128 -0
- package/src/nodes/base.ts +5 -12
- package/src/nodes/code.ts +165 -74
- package/src/nodes/content.ts +56 -0
- package/src/nodes/file.ts +97 -36
- package/src/nodes/function.ts +216 -156
- package/src/nodes/http.ts +1 -35
- package/src/nodes/index.ts +23 -15
- package/src/nodes/input.ts +140 -0
- package/src/nodes/operation.ts +122 -68
- package/src/nodes/output.ts +23 -0
- package/src/nodes/parameter.ts +33 -3
- package/src/nodes/property.ts +36 -3
- package/src/nodes/requestBody.ts +61 -0
- package/src/nodes/response.ts +58 -13
- package/src/nodes/schema.ts +93 -17
- package/src/printer.ts +48 -42
- package/src/registry.ts +75 -0
- package/src/signature.ts +207 -0
- package/src/types.ts +8 -68
- package/src/utils/codegen.ts +104 -0
- package/src/utils/extractStringsFromNodes.ts +34 -0
- package/src/utils/fileMerge.ts +184 -0
- package/src/utils/index.ts +11 -0
- package/src/utils/operationParams.ts +353 -0
- package/src/utils/refs.ts +138 -0
- package/src/utils/schemaGraph.ts +169 -0
- package/src/utils/schemaMerge.ts +34 -0
- package/src/utils/schemaTraversal.ts +86 -0
- package/src/utils/strings.ts +139 -0
- package/src/visitor.ts +227 -289
- package/dist/chunk--u3MIqq1.js +0 -8
- package/src/nodes/root.ts +0 -64
- package/src/refs.ts +0 -67
- package/src/resolvers.ts +0 -45
- package/src/transformers.ts +0 -159
- package/src/utils.ts +0 -915
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-KUdWiDWw.js","names":[],"sources":["../src/node.ts","../src/nodes/schema.ts","../../../internals/utils/src/casing.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"],"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","type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\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 *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