@kubb/ast 5.0.0-beta.5 → 5.0.0-beta.51

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.
Files changed (48) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +28 -19
  3. package/dist/index.cjs +878 -788
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +33 -3326
  6. package/dist/index.js +863 -750
  7. package/dist/index.js.map +1 -1
  8. package/dist/types-BaaNZbSi.d.ts +3581 -0
  9. package/dist/types.cjs +0 -0
  10. package/dist/types.d.ts +2 -0
  11. package/dist/types.js +1 -0
  12. package/dist/utils-BIcKgbbc.js +626 -0
  13. package/dist/utils-BIcKgbbc.js.map +1 -0
  14. package/dist/utils-CMRZrT-w.cjs +794 -0
  15. package/dist/utils-CMRZrT-w.cjs.map +1 -0
  16. package/dist/utils.cjs +18 -0
  17. package/dist/utils.d.ts +205 -0
  18. package/dist/utils.js +2 -0
  19. package/package.json +13 -5
  20. package/src/constants.ts +10 -49
  21. package/src/dedupe.ts +200 -0
  22. package/src/dialect.ts +58 -0
  23. package/src/dispatch.ts +53 -0
  24. package/src/factory.ts +154 -21
  25. package/src/guards.ts +18 -48
  26. package/src/index.ts +11 -8
  27. package/src/infer.ts +16 -14
  28. package/src/nodes/base.ts +2 -0
  29. package/src/nodes/code.ts +22 -28
  30. package/src/nodes/content.ts +37 -0
  31. package/src/nodes/file.ts +17 -15
  32. package/src/nodes/function.ts +11 -11
  33. package/src/nodes/http.ts +1 -35
  34. package/src/nodes/index.ts +10 -12
  35. package/src/nodes/operation.ts +98 -62
  36. package/src/nodes/response.ts +21 -14
  37. package/src/nodes/root.ts +72 -10
  38. package/src/nodes/schema.ts +18 -15
  39. package/src/printer.ts +44 -38
  40. package/src/resolvers.ts +5 -19
  41. package/src/signature.ts +232 -0
  42. package/src/transformers.ts +21 -16
  43. package/src/types.ts +8 -18
  44. package/src/{utils.ts → utils/ast.ts} +125 -84
  45. package/src/utils/index.ts +295 -0
  46. package/src/visitor.ts +239 -281
  47. package/src/refs.ts +0 -67
  48. /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
@@ -0,0 +1,3581 @@
1
+ import { t as __name } from "./chunk-C0LytTxp.js";
2
+
3
+ //#region src/constants.d.ts
4
+ /**
5
+ * Traversal depth for AST visitor utilities.
6
+ *
7
+ * - `'shallow'` visits only the immediate node, skipping children.
8
+ * - `'deep'` recursively visits all descendant nodes.
9
+ */
10
+ type VisitorDepth = 'shallow' | 'deep';
11
+ /**
12
+ * Schema type discriminators used by all AST schema nodes.
13
+ *
14
+ * These values serve as stable discriminators across the AST (e.g., `schema.type === schemaTypes.object`).
15
+ * Grouped by category: primitives (`string`, `number`, `boolean`), structural types (`object`, `array`, `union`),
16
+ * and format-specific types (`date`, `uuid`, `email`). Use `isScalarPrimitive()` to check for scalar types.
17
+ */
18
+ declare const schemaTypes: {
19
+ /**
20
+ * Text value.
21
+ */
22
+ readonly string: "string";
23
+ /**
24
+ * Floating-point number (`float`, `double`).
25
+ */
26
+ readonly number: "number";
27
+ /**
28
+ * Whole number (`int32`). Use `bigint` for `int64`.
29
+ */
30
+ readonly integer: "integer";
31
+ /**
32
+ * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
33
+ */
34
+ readonly bigint: "bigint";
35
+ /**
36
+ * Boolean value
37
+ */
38
+ readonly boolean: "boolean";
39
+ /**
40
+ * Explicit null value.
41
+ */
42
+ readonly null: "null";
43
+ /**
44
+ * Any value (no type restriction).
45
+ */
46
+ readonly any: "any";
47
+ /**
48
+ * Unknown value (must be narrowed before usage).
49
+ */
50
+ readonly unknown: "unknown";
51
+ /**
52
+ * No return value (`void`).
53
+ */
54
+ readonly void: "void";
55
+ /**
56
+ * Object with named properties.
57
+ */
58
+ readonly object: "object";
59
+ /**
60
+ * Sequential list of items.
61
+ */
62
+ readonly array: "array";
63
+ /**
64
+ * Fixed-length list with position-specific items.
65
+ */
66
+ readonly tuple: "tuple";
67
+ /**
68
+ * "One of" multiple schema members.
69
+ */
70
+ readonly union: "union";
71
+ /**
72
+ * "All of" multiple schema members.
73
+ */
74
+ readonly intersection: "intersection";
75
+ /**
76
+ * Enum schema.
77
+ */
78
+ readonly enum: "enum";
79
+ /**
80
+ * Reference to another schema.
81
+ */
82
+ readonly ref: "ref";
83
+ /**
84
+ * Calendar date (for example `2026-03-24`).
85
+ */
86
+ readonly date: "date";
87
+ /**
88
+ * Date-time value (for example `2026-03-24T09:00:00Z`).
89
+ */
90
+ readonly datetime: "datetime";
91
+ /**
92
+ * Time-only value (for example `09:00:00`).
93
+ */
94
+ readonly time: "time";
95
+ /**
96
+ * UUID value.
97
+ */
98
+ readonly uuid: "uuid";
99
+ /**
100
+ * Email address value.
101
+ */
102
+ readonly email: "email";
103
+ /**
104
+ * URL value.
105
+ */
106
+ readonly url: "url";
107
+ /**
108
+ * IPv4 address value.
109
+ */
110
+ readonly ipv4: "ipv4";
111
+ /**
112
+ * IPv6 address value.
113
+ */
114
+ readonly ipv6: "ipv6";
115
+ /**
116
+ * Binary/blob value.
117
+ */
118
+ readonly blob: "blob";
119
+ /**
120
+ * Impossible value (`never`).
121
+ */
122
+ readonly never: "never";
123
+ };
124
+ /**
125
+ * HTTP method identifiers used by operation nodes.
126
+ *
127
+ * Includes all standard HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE).
128
+ */
129
+ declare const httpMethods: {
130
+ readonly get: "GET";
131
+ readonly post: "POST";
132
+ readonly put: "PUT";
133
+ readonly patch: "PATCH";
134
+ readonly delete: "DELETE";
135
+ readonly head: "HEAD";
136
+ readonly options: "OPTIONS";
137
+ readonly trace: "TRACE";
138
+ };
139
+ //#endregion
140
+ //#region src/nodes/base.d.ts
141
+ /**
142
+ * `kind` values used by AST nodes.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * const kind: NodeKind = 'Schema'
147
+ * ```
148
+ */
149
+ type NodeKind = 'Input' | 'Output' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response' | 'RequestBody' | 'Content' | 'FunctionParameter' | 'ParameterGroup' | 'FunctionParameters' | 'Type' | 'ParamsType' | 'File' | 'Import' | 'Export' | 'Source' | 'Const' | 'Function' | 'ArrowFunction' | 'Text' | 'Break' | 'Jsx';
150
+ /**
151
+ * Base shape shared by all AST nodes.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * const base: BaseNode = { kind: 'Input' }
156
+ * ```
157
+ */
158
+ type BaseNode = {
159
+ /**
160
+ * Node discriminator.
161
+ */
162
+ kind: NodeKind;
163
+ };
164
+ //#endregion
165
+ //#region src/nodes/code.d.ts
166
+ /**
167
+ * JSDoc documentation metadata attached to code declarations.
168
+ */
169
+ type JSDocNode = {
170
+ /**
171
+ * JSDoc comment lines. `undefined` entries are filtered out during rendering.
172
+ * @example ['@description A pet resource', '@deprecated']
173
+ */
174
+ comments?: Array<string | undefined>;
175
+ };
176
+ /**
177
+ * AST node representing a TypeScript `const` declaration.
178
+ *
179
+ * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
180
+ * The `children` prop of the component is represented as `nodes`.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * createConst({ name: 'pet', export: true, asConst: true })
185
+ * // export const pet = ... as const
186
+ * ```
187
+ */
188
+ type ConstNode = BaseNode & {
189
+ /**
190
+ * Node kind.
191
+ */
192
+ kind: 'Const';
193
+ /**
194
+ * Name of the constant declaration.
195
+ */
196
+ name: string;
197
+ /**
198
+ * Whether the declaration should be exported.
199
+ * @default false
200
+ */
201
+ export?: boolean | null;
202
+ /**
203
+ * Optional explicit type annotation.
204
+ * @example 'Pet'
205
+ */
206
+ type?: string | null;
207
+ /**
208
+ * JSDoc documentation metadata.
209
+ */
210
+ JSDoc?: JSDocNode | null;
211
+ /**
212
+ * Whether to append `as const` to the declaration.
213
+ * @default false
214
+ */
215
+ asConst?: boolean | null;
216
+ /**
217
+ * Child nodes representing the value of the constant (children of the `Const` component).
218
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
219
+ */
220
+ nodes?: Array<CodeNode>;
221
+ };
222
+ /**
223
+ * AST node representing a TypeScript `type` alias declaration.
224
+ *
225
+ * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
226
+ * The `children` prop of the component is represented as `nodes`.
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * createType({ name: 'Pet', export: true })
231
+ * // export type Pet = ...
232
+ * ```
233
+ */
234
+ type TypeNode = BaseNode & {
235
+ /**
236
+ * Node kind.
237
+ */
238
+ kind: 'Type';
239
+ /**
240
+ * Name of the type alias.
241
+ */
242
+ name: string;
243
+ /**
244
+ * Whether the declaration should be exported.
245
+ * @default false
246
+ */
247
+ export?: boolean | null;
248
+ /**
249
+ * JSDoc documentation metadata.
250
+ */
251
+ JSDoc?: JSDocNode | null;
252
+ /**
253
+ * Child nodes representing the type body (children of the `Type` component).
254
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
255
+ */
256
+ nodes?: Array<CodeNode>;
257
+ };
258
+ /**
259
+ * AST node representing a TypeScript `function` declaration.
260
+ *
261
+ * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
262
+ * The `children` prop of the component is represented as `nodes`.
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * createFunctionDeclaration({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
267
+ * // export async function getPet(): Promise<Pet> { ... }
268
+ * ```
269
+ */
270
+ type FunctionNode = BaseNode & {
271
+ /**
272
+ * Node kind.
273
+ */
274
+ kind: 'Function';
275
+ /**
276
+ * Name of the function.
277
+ */
278
+ name: string;
279
+ /**
280
+ * Whether the function is a default export.
281
+ * @default false
282
+ */
283
+ default?: boolean | null;
284
+ /**
285
+ * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
286
+ */
287
+ params?: string | null;
288
+ /**
289
+ * Whether the function should be exported.
290
+ * @default false
291
+ */
292
+ export?: boolean | null;
293
+ /**
294
+ * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
295
+ * @default false
296
+ */
297
+ async?: boolean | null;
298
+ /**
299
+ * TypeScript generic type parameters.
300
+ * @example ['T', 'U extends string']
301
+ */
302
+ generics?: string | Array<string> | null;
303
+ /**
304
+ * Return type annotation.
305
+ * @example 'Pet'
306
+ */
307
+ returnType?: string | null;
308
+ /**
309
+ * JSDoc documentation metadata.
310
+ */
311
+ JSDoc?: JSDocNode | null;
312
+ /**
313
+ * Child nodes representing the function body (children of the `Function` component).
314
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
315
+ */
316
+ nodes?: Array<CodeNode>;
317
+ };
318
+ /**
319
+ * AST node representing a TypeScript arrow function (`const name = () => { ... }`).
320
+ *
321
+ * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
322
+ * The `children` prop of the component is represented as `nodes`.
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * createArrowFunctionDeclaration({ name: 'getPet', export: true, singleLine: true })
327
+ * // export const getPet = () => ...
328
+ * ```
329
+ */
330
+ type ArrowFunctionNode = BaseNode & {
331
+ /**
332
+ * Node kind.
333
+ */
334
+ kind: 'ArrowFunction';
335
+ /**
336
+ * Name of the arrow function (used as the `const` variable name).
337
+ */
338
+ name: string;
339
+ /**
340
+ * Whether the function is a default export.
341
+ * @default false
342
+ */
343
+ default?: boolean | null;
344
+ /**
345
+ * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
346
+ */
347
+ params?: string | null;
348
+ /**
349
+ * Whether the arrow function should be exported.
350
+ * @default false
351
+ */
352
+ export?: boolean | null;
353
+ /**
354
+ * Whether the arrow function is async. When `true`, the return type is wrapped in `Promise<>`.
355
+ * @default false
356
+ */
357
+ async?: boolean | null;
358
+ /**
359
+ * TypeScript generic type parameters.
360
+ * @example ['T', 'U extends string']
361
+ */
362
+ generics?: string | Array<string> | null;
363
+ /**
364
+ * Return type annotation.
365
+ * @example 'Pet'
366
+ */
367
+ returnType?: string | null;
368
+ /**
369
+ * JSDoc documentation metadata.
370
+ */
371
+ JSDoc?: JSDocNode | null;
372
+ /**
373
+ * Render the arrow function body as a single-line expression.
374
+ * @default false
375
+ */
376
+ singleLine?: boolean | null;
377
+ /**
378
+ * Child nodes representing the function body (children of the `Function.Arrow` component).
379
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
380
+ */
381
+ nodes?: Array<CodeNode>;
382
+ };
383
+ /**
384
+ * AST node representing a raw text/string fragment in the source output.
385
+ *
386
+ * Used instead of bare `string` values so that all entries in `nodes` arrays
387
+ * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * createText('return fetch(id)')
392
+ * // { kind: 'Text', value: 'return fetch(id)' }
393
+ * ```
394
+ */
395
+ type TextNode = BaseNode & {
396
+ /**
397
+ * Node kind.
398
+ */
399
+ kind: 'Text';
400
+ /**
401
+ * The raw string content.
402
+ */
403
+ value: string;
404
+ };
405
+ /**
406
+ * AST node representing a line break in the source output.
407
+ *
408
+ * Corresponds to `<br/>` in JSX components. When printed, produces an empty
409
+ * string that, joined with `\n` by `printNodes` creates a blank line
410
+ * between surrounding code nodes.
411
+ *
412
+ * @example
413
+ * ```ts
414
+ * createBreak()
415
+ * // { kind: 'Break' }
416
+ * // prints as '' → blank line when surrounded by other nodes
417
+ * ```
418
+ */
419
+ type BreakNode = BaseNode & {
420
+ /**
421
+ * Node kind.
422
+ */
423
+ kind: 'Break';
424
+ };
425
+ /**
426
+ * AST node representing a raw JSX fragment in the source output.
427
+ *
428
+ * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Use this to embed raw
429
+ * JSX/TSX markup (including fragments `<>…</>`) directly in generated code.
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
434
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
435
+ * ```
436
+ */
437
+ type JsxNode = BaseNode & {
438
+ /**
439
+ * Node kind.
440
+ */
441
+ kind: 'Jsx';
442
+ /**
443
+ * The raw JSX string content.
444
+ */
445
+ value: string;
446
+ };
447
+ /**
448
+ * Union of all code-generation AST nodes.
449
+ *
450
+ * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
451
+ * structured children in {@link SourceNode.nodes}.
452
+ */
453
+ type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
454
+ //#endregion
455
+ //#region src/nodes/property.d.ts
456
+ /**
457
+ * AST node representing one named object property.
458
+ *
459
+ * @example
460
+ * ```ts
461
+ * const property: PropertyNode = {
462
+ * kind: 'Property',
463
+ * name: 'id',
464
+ * schema: createSchema({ type: 'integer' }),
465
+ * required: true,
466
+ * }
467
+ * ```
468
+ */
469
+ type PropertyNode = BaseNode & {
470
+ /**
471
+ * Node kind.
472
+ */
473
+ kind: 'Property';
474
+ /**
475
+ * Property key.
476
+ */
477
+ name: string;
478
+ /**
479
+ * Property schema.
480
+ */
481
+ schema: SchemaNode;
482
+ /**
483
+ * Whether the property is required.
484
+ */
485
+ required: boolean;
486
+ };
487
+ //#endregion
488
+ //#region src/nodes/schema.d.ts
489
+ type PrimitiveSchemaType =
490
+ /**
491
+ * Text value.
492
+ */
493
+ 'string'
494
+ /**
495
+ * Floating-point number.
496
+ */
497
+ | 'number'
498
+ /**
499
+ * Integer number.
500
+ */
501
+ | 'integer'
502
+ /**
503
+ * Big integer number.
504
+ */
505
+ | 'bigint'
506
+ /**
507
+ * Boolean value.
508
+ */
509
+ | 'boolean'
510
+ /**
511
+ * Null value.
512
+ */
513
+ | 'null'
514
+ /**
515
+ * Any value.
516
+ */
517
+ | 'any'
518
+ /**
519
+ * Unknown value.
520
+ */
521
+ | 'unknown'
522
+ /**
523
+ * No value (`void`).
524
+ */
525
+ | 'void'
526
+ /**
527
+ * Never value.
528
+ */
529
+ | 'never'
530
+ /**
531
+ * Object value.
532
+ */
533
+ | 'object'
534
+ /**
535
+ * Array value.
536
+ */
537
+ | 'array'
538
+ /**
539
+ * Date value.
540
+ */
541
+ | 'date';
542
+ /**
543
+ * Composite schema types.
544
+ */
545
+ type ComplexSchemaType = 'tuple' | 'union' | 'intersection' | 'enum';
546
+ /**
547
+ * Schema types that need special handling in generators.
548
+ */
549
+ type SpecialSchemaType = 'ref' | 'datetime' | 'time' | 'uuid' | 'email' | 'url' | 'ipv4' | 'ipv6' | 'blob';
550
+ /**
551
+ * All schema type strings.
552
+ */
553
+ type SchemaType = PrimitiveSchemaType | ComplexSchemaType | SpecialSchemaType;
554
+ /**
555
+ * Scalar schema types without extra object/array/ref structure.
556
+ */
557
+ type ScalarSchemaType = Exclude<SchemaType, 'object' | 'array' | 'tuple' | 'union' | 'intersection' | 'enum' | 'ref' | 'datetime' | 'date' | 'time' | 'string' | 'number' | 'integer' | 'bigint' | 'url' | 'uuid' | 'email'>;
558
+ /**
559
+ * Fields shared by all schema nodes.
560
+ */
561
+ type SchemaNodeBase = BaseNode & {
562
+ /**
563
+ * Node kind.
564
+ */
565
+ kind: 'Schema';
566
+ /**
567
+ * Schema name for named definitions (for example, `"Pet"`).
568
+ * Inline schemas omit this field.
569
+ * `null` means kubb has processed this and determined there is no applicable name.
570
+ * `undefined` means the name has not been set yet.
571
+ */
572
+ name?: string | null;
573
+ /**
574
+ * Short schema title.
575
+ */
576
+ title?: string;
577
+ /**
578
+ * Schema description text.
579
+ */
580
+ description?: string;
581
+ /**
582
+ * Whether `null` is allowed.
583
+ */
584
+ nullable?: boolean;
585
+ /**
586
+ * Whether the field is optional.
587
+ */
588
+ optional?: boolean;
589
+ /**
590
+ * Both optional and nullable (`optional` + `nullable`).
591
+ */
592
+ nullish?: boolean;
593
+ /**
594
+ * Whether the schema is deprecated.
595
+ */
596
+ deprecated?: boolean;
597
+ /**
598
+ * Whether the schema is read-only.
599
+ */
600
+ readOnly?: boolean;
601
+ /**
602
+ * Whether the schema is write-only.
603
+ */
604
+ writeOnly?: boolean;
605
+ /**
606
+ * Default value.
607
+ */
608
+ default?: unknown;
609
+ /**
610
+ * Example value.
611
+ */
612
+ example?: unknown;
613
+ /**
614
+ * Base primitive type.
615
+ * For example, this is `'string'` for a `uuid` schema.
616
+ */
617
+ primitive?: PrimitiveSchemaType;
618
+ /**
619
+ * Schema `format` value.
620
+ */
621
+ format?: string;
622
+ };
623
+ /**
624
+ * Object schema with ordered properties.
625
+ *
626
+ * @example
627
+ * ```ts
628
+ * const objectSchema: ObjectSchemaNode = {
629
+ * kind: 'Schema',
630
+ * type: 'object',
631
+ * properties: [],
632
+ * }
633
+ * ```
634
+ */
635
+ type ObjectSchemaNode = SchemaNodeBase & {
636
+ /**
637
+ * Schema type discriminator.
638
+ */
639
+ type: 'object';
640
+ /**
641
+ * Primitive type, always `'object'` for object schemas.
642
+ */
643
+ primitive: 'object';
644
+ /**
645
+ * Ordered object properties.
646
+ */
647
+ properties: Array<PropertyNode>;
648
+ /**
649
+ * Additional object properties behavior:
650
+ * - `true`: allow any value
651
+ * - `false`: reject unknown properties (maps to `.strict()` in Zod)
652
+ * - `SchemaNode`: allow values that match that schema
653
+ * - `undefined`: no additional properties constraint (open object)
654
+ */
655
+ additionalProperties?: SchemaNode | boolean;
656
+ /**
657
+ * Pattern-based property schemas.
658
+ */
659
+ patternProperties?: Record<string, SchemaNode>;
660
+ /**
661
+ * Minimum number of properties allowed.
662
+ */
663
+ minProperties?: number;
664
+ /**
665
+ * Maximum number of properties allowed.
666
+ */
667
+ maxProperties?: number;
668
+ };
669
+ /**
670
+ * Array-like schema (`array` or `tuple`).
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * const arraySchema: ArraySchemaNode = {
675
+ * kind: 'Schema',
676
+ * type: 'array',
677
+ * items: [],
678
+ * }
679
+ * ```
680
+ */
681
+ type ArraySchemaNode = SchemaNodeBase & {
682
+ /**
683
+ * Schema type discriminator (`array` or `tuple`).
684
+ */
685
+ type: 'array' | 'tuple';
686
+ /**
687
+ * Item schemas.
688
+ */
689
+ items?: Array<SchemaNode>;
690
+ /**
691
+ * Tuple rest-item schema for elements beyond positional `items`.
692
+ */
693
+ rest?: SchemaNode;
694
+ /**
695
+ * Minimum item count (or tuple length).
696
+ */
697
+ min?: number;
698
+ /**
699
+ * Maximum item count (or tuple length).
700
+ */
701
+ max?: number;
702
+ /**
703
+ * Whether all items must be unique.
704
+ */
705
+ unique?: boolean;
706
+ };
707
+ /**
708
+ * Shared shape for union and intersection schemas.
709
+ */
710
+ type CompositeSchemaNodeBase = SchemaNodeBase & {
711
+ /**
712
+ * Member schemas.
713
+ */
714
+ members?: Array<SchemaNode>;
715
+ };
716
+ /**
717
+ * Union schema, often from `oneOf` or `anyOf`.
718
+ *
719
+ * @example
720
+ * ```ts
721
+ * const unionSchema: UnionSchemaNode = {
722
+ * kind: 'Schema',
723
+ * type: 'union',
724
+ * members: [],
725
+ * }
726
+ * ```
727
+ */
728
+ type UnionSchemaNode = CompositeSchemaNodeBase & {
729
+ /**
730
+ * Schema type discriminator.
731
+ */
732
+ type: 'union';
733
+ /**
734
+ * Discriminator property name from OpenAPI `discriminator.propertyName`.
735
+ */
736
+ discriminatorPropertyName?: string;
737
+ /**
738
+ * Logical strategy applied to union members: 'one' means exactly one member must be valid (from `oneOf`),
739
+ * 'any' means any number of members can be valid (from `anyOf`).
740
+ */
741
+ strategy?: 'one' | 'any';
742
+ };
743
+ /**
744
+ * Intersection schema, often from `allOf`.
745
+ *
746
+ * @example
747
+ * ```ts
748
+ * const intersectionSchema: IntersectionSchemaNode = {
749
+ * kind: 'Schema',
750
+ * type: 'intersection',
751
+ * members: [],
752
+ * }
753
+ * ```
754
+ */
755
+ type IntersectionSchemaNode = CompositeSchemaNodeBase & {
756
+ /**
757
+ * Schema type discriminator.
758
+ */
759
+ type: 'intersection';
760
+ };
761
+ /**
762
+ * One named enum item.
763
+ */
764
+ type EnumValueNode = {
765
+ /**
766
+ * Enum item name.
767
+ */
768
+ name: string;
769
+ /**
770
+ * Enum item value.
771
+ */
772
+ value: string | number | boolean;
773
+ /**
774
+ * Primitive type of the enum value.
775
+ */
776
+ primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>;
777
+ };
778
+ /**
779
+ * Enum schema node.
780
+ *
781
+ * @example
782
+ * ```ts
783
+ * const enumSchema: EnumSchemaNode = {
784
+ * kind: 'Schema',
785
+ * type: 'enum',
786
+ * enumValues: ['a', 'b'],
787
+ * }
788
+ * ```
789
+ */
790
+ type EnumSchemaNode = SchemaNodeBase & {
791
+ /**
792
+ * Schema type discriminator.
793
+ */
794
+ type: 'enum';
795
+ /**
796
+ * Enum values in simple form.
797
+ */
798
+ enumValues?: Array<string | number | boolean | null>;
799
+ /**
800
+ * Enum values in named form.
801
+ * If present, this is used instead of `enumValues`.
802
+ */
803
+ namedEnumValues?: Array<EnumValueNode>;
804
+ };
805
+ /**
806
+ * Reference schema that points to another schema definition.
807
+ *
808
+ * @example
809
+ * ```ts
810
+ * const refSchema: RefSchemaNode = {
811
+ * kind: 'Schema',
812
+ * type: 'ref',
813
+ * ref: '#/components/schemas/Pet',
814
+ * }
815
+ * ```
816
+ */
817
+ type RefSchemaNode = SchemaNodeBase & {
818
+ /**
819
+ * Schema type discriminator.
820
+ */
821
+ type: 'ref';
822
+ /**
823
+ * Referenced schema name.
824
+ * `null` means Kubb has processed this and determined there is no applicable name.
825
+ */
826
+ name?: string | null;
827
+ /**
828
+ * Original `$ref` path, for example, `#/components/schemas/Order`.
829
+ * Used to resolve names later.
830
+ */
831
+ ref?: string;
832
+ /**
833
+ * Pattern copied from a sibling `pattern` field.
834
+ */
835
+ pattern?: string;
836
+ /**
837
+ * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)
838
+ * can be read without following the reference. Populated during OAS parsing when the
839
+ * definition resolves, `null` when it can't or the ref is circular, and `undefined` when
840
+ * resolution has not been attempted.
841
+ */
842
+ schema?: SchemaNode | null;
843
+ };
844
+ /**
845
+ * Datetime schema.
846
+ *
847
+ * @example
848
+ * ```ts
849
+ * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }
850
+ * ```
851
+ */
852
+ type DatetimeSchemaNode = SchemaNodeBase & {
853
+ /**
854
+ * Schema type discriminator.
855
+ */
856
+ type: 'datetime';
857
+ /**
858
+ * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).
859
+ */
860
+ offset?: boolean;
861
+ /**
862
+ * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).
863
+ */
864
+ local?: boolean;
865
+ };
866
+ /**
867
+ * Shared base for `date` and `time` schemas.
868
+ */
869
+ type TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {
870
+ /**
871
+ * Schema type discriminator.
872
+ */
873
+ type: T;
874
+ /**
875
+ * Output representation in generated code.
876
+ */
877
+ representation: 'date' | 'string';
878
+ };
879
+ /**
880
+ * Date schema node.
881
+ *
882
+ * @example
883
+ * ```ts
884
+ * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }
885
+ * ```
886
+ */
887
+ type DateSchemaNode = TemporalSchemaNodeBase<'date'>;
888
+ /**
889
+ * Time schema node.
890
+ *
891
+ * @example
892
+ * ```ts
893
+ * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }
894
+ * ```
895
+ */
896
+ type TimeSchemaNode = TemporalSchemaNodeBase<'time'>;
897
+ /**
898
+ * String schema node.
899
+ *
900
+ * @example
901
+ * ```ts
902
+ * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }
903
+ * ```
904
+ */
905
+ type StringSchemaNode = SchemaNodeBase & {
906
+ /**
907
+ * Schema type discriminator.
908
+ */
909
+ type: 'string';
910
+ /**
911
+ * Minimum string length.
912
+ */
913
+ min?: number;
914
+ /**
915
+ * Maximum string length.
916
+ */
917
+ max?: number;
918
+ /**
919
+ * Regex pattern.
920
+ */
921
+ pattern?: string;
922
+ };
923
+ /**
924
+ * Numeric schema (`number`, `integer`, or `bigint`).
925
+ *
926
+ * @example
927
+ * ```ts
928
+ * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }
929
+ * ```
930
+ */
931
+ type NumberSchemaNode = SchemaNodeBase & {
932
+ /**
933
+ * Schema type discriminator.
934
+ */
935
+ type: 'number' | 'integer' | 'bigint';
936
+ /**
937
+ * Minimum value.
938
+ */
939
+ min?: number;
940
+ /**
941
+ * Maximum value.
942
+ */
943
+ max?: number;
944
+ /**
945
+ * Exclusive minimum value.
946
+ */
947
+ exclusiveMinimum?: number;
948
+ /**
949
+ * Exclusive maximum value.
950
+ */
951
+ exclusiveMaximum?: number;
952
+ /**
953
+ * The value must be a multiple of this number.
954
+ */
955
+ multipleOf?: number;
956
+ };
957
+ /**
958
+ * Scalar schema with no extra constraints.
959
+ *
960
+ * @example
961
+ * ```ts
962
+ * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }
963
+ * ```
964
+ */
965
+ type ScalarSchemaNode = SchemaNodeBase & {
966
+ /**
967
+ * Schema type discriminator.
968
+ */
969
+ type: ScalarSchemaType;
970
+ };
971
+ /**
972
+ * URL schema node.
973
+ * Can include an OpenAPI-style path template for template literal types.
974
+ *
975
+ * @example
976
+ * ```ts
977
+ * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }
978
+ * ```
979
+ */
980
+ type UrlSchemaNode = SchemaNodeBase & {
981
+ /**
982
+ * Schema type discriminator.
983
+ */
984
+ type: 'url';
985
+ /**
986
+ * OpenAPI-style path template, for example, `'/pets/{petId}'`.
987
+ */
988
+ path?: string;
989
+ /**
990
+ * Minimum string length.
991
+ */
992
+ min?: number;
993
+ /**
994
+ * Maximum string length.
995
+ */
996
+ max?: number;
997
+ };
998
+ /**
999
+ * Format-string schema for string-based formats that support length constraints.
1000
+ *
1001
+ * @example
1002
+ * ```ts
1003
+ * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }
1004
+ * ```
1005
+ */
1006
+ type FormatStringSchemaNode = SchemaNodeBase & {
1007
+ /**
1008
+ * Schema type discriminator.
1009
+ */
1010
+ type: 'uuid' | 'email';
1011
+ /**
1012
+ * Minimum string length.
1013
+ */
1014
+ min?: number;
1015
+ /**
1016
+ * Maximum string length.
1017
+ */
1018
+ max?: number;
1019
+ };
1020
+ /**
1021
+ * IPv4 address schema node.
1022
+ *
1023
+ * @example
1024
+ * ```ts
1025
+ * const ipv4Schema: Ipv4SchemaNode = { kind: 'Schema', type: 'ipv4' }
1026
+ * ```
1027
+ */
1028
+ type Ipv4SchemaNode = SchemaNodeBase & {
1029
+ /**
1030
+ * Schema type discriminator.
1031
+ */
1032
+ type: 'ipv4';
1033
+ };
1034
+ /**
1035
+ * IPv6 address schema node.
1036
+ *
1037
+ * @example
1038
+ * ```ts
1039
+ * const ipv6Schema: Ipv6SchemaNode = { kind: 'Schema', type: 'ipv6' }
1040
+ * ```
1041
+ */
1042
+ type Ipv6SchemaNode = SchemaNodeBase & {
1043
+ /**
1044
+ * Schema type discriminator.
1045
+ */
1046
+ type: 'ipv6';
1047
+ };
1048
+ /**
1049
+ * Mapping from schema type literals to concrete schema node types.
1050
+ * Used by `narrowSchema`.
1051
+ */
1052
+ type SchemaNodeByType = {
1053
+ object: ObjectSchemaNode;
1054
+ array: ArraySchemaNode;
1055
+ tuple: ArraySchemaNode;
1056
+ union: UnionSchemaNode;
1057
+ intersection: IntersectionSchemaNode;
1058
+ enum: EnumSchemaNode;
1059
+ ref: RefSchemaNode;
1060
+ datetime: DatetimeSchemaNode;
1061
+ date: DateSchemaNode;
1062
+ time: TimeSchemaNode;
1063
+ string: StringSchemaNode;
1064
+ number: NumberSchemaNode;
1065
+ integer: NumberSchemaNode;
1066
+ bigint: NumberSchemaNode;
1067
+ boolean: ScalarSchemaNode;
1068
+ null: ScalarSchemaNode;
1069
+ any: ScalarSchemaNode;
1070
+ unknown: ScalarSchemaNode;
1071
+ void: ScalarSchemaNode;
1072
+ never: ScalarSchemaNode;
1073
+ uuid: FormatStringSchemaNode;
1074
+ email: FormatStringSchemaNode;
1075
+ url: UrlSchemaNode;
1076
+ ipv4: Ipv4SchemaNode;
1077
+ ipv6: Ipv6SchemaNode;
1078
+ blob: ScalarSchemaNode;
1079
+ };
1080
+ /**
1081
+ * Union of all schema node types.
1082
+ */
1083
+ type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | Ipv4SchemaNode | Ipv6SchemaNode | ScalarSchemaNode;
1084
+ //#endregion
1085
+ //#region src/nodes/content.d.ts
1086
+ /**
1087
+ * AST node representing one content-type entry of a request body or response.
1088
+ *
1089
+ * One entry per content type declared in the spec (e.g. `application/json`,
1090
+ * `multipart/form-data`), each carrying its own body schema.
1091
+ *
1092
+ * @example
1093
+ * ```ts
1094
+ * const content: ContentNode = {
1095
+ * kind: 'Content',
1096
+ * contentType: 'application/json',
1097
+ * schema: createSchema({ type: 'string' }),
1098
+ * }
1099
+ * ```
1100
+ */
1101
+ type ContentNode = BaseNode & {
1102
+ /**
1103
+ * Node kind.
1104
+ */
1105
+ kind: 'Content';
1106
+ /**
1107
+ * The content type for this entry (e.g. `'application/json'`).
1108
+ */
1109
+ contentType: string;
1110
+ /**
1111
+ * Body schema for this content type.
1112
+ */
1113
+ schema?: SchemaNode;
1114
+ /**
1115
+ * Property keys to exclude from the generated type via `Omit<Type, Keys>`.
1116
+ * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.
1117
+ */
1118
+ keysToOmit?: Array<string> | null;
1119
+ };
1120
+ //#endregion
1121
+ //#region src/nodes/file.d.ts
1122
+ /**
1123
+ * Supported file extensions.
1124
+ */
1125
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
1126
+ type ImportName = string | Array<string | {
1127
+ propertyName: string;
1128
+ name?: string;
1129
+ }>;
1130
+ /**
1131
+ * Represents a language-agnostic import/dependency declaration.
1132
+ *
1133
+ * @example Named import (TypeScript: `import { useState } from 'react'`)
1134
+ * ```ts
1135
+ * createImport({ name: ['useState'], path: 'react' })
1136
+ * ```
1137
+ *
1138
+ * @example Default import (TypeScript: `import React from 'react'`)
1139
+ * ```ts
1140
+ * createImport({ name: 'React', path: 'react' })
1141
+ * ```
1142
+ *
1143
+ * @example Type-only import (TypeScript: `import type { FC } from 'react'`)
1144
+ * ```ts
1145
+ * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
1146
+ * ```
1147
+ *
1148
+ * @example Namespace import (TypeScript: `import * as React from 'react'`)
1149
+ * ```ts
1150
+ * createImport({ name: 'React', path: 'react', isNameSpace: true })
1151
+ * ```
1152
+ */
1153
+ type ImportNode = BaseNode & {
1154
+ kind: 'Import';
1155
+ /**
1156
+ * Import name(s) to be used.
1157
+ * @example ['useState']
1158
+ * @example 'React'
1159
+ */
1160
+ name: ImportName;
1161
+ /**
1162
+ * Path for the import.
1163
+ * @example '@kubb/core'
1164
+ */
1165
+ path: string;
1166
+ /**
1167
+ * Add type-only import prefix.
1168
+ * - `true` generates `import type { Type } from './path'`
1169
+ * - `false` generates `import { Type } from './path'`
1170
+ * @default false
1171
+ */
1172
+ isTypeOnly?: boolean | null;
1173
+ /**
1174
+ * Import entire module as namespace.
1175
+ * - `true` generates `import * as Name from './path'`
1176
+ * - `false` generates standard import
1177
+ * @default false
1178
+ */
1179
+ isNameSpace?: boolean | null;
1180
+ /**
1181
+ * When set, the import path is resolved relative to this root.
1182
+ */
1183
+ root?: string | null;
1184
+ };
1185
+ /**
1186
+ * Represents a language-agnostic export/public API declaration.
1187
+ *
1188
+ * @example Named export (TypeScript: `export { Pets } from './Pets'`)
1189
+ * ```ts
1190
+ * createExport({ name: ['Pets'], path: './Pets' })
1191
+ * ```
1192
+ *
1193
+ * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
1194
+ * ```ts
1195
+ * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
1196
+ * ```
1197
+ *
1198
+ * @example Wildcard export (TypeScript: `export * from './utils'`)
1199
+ * ```ts
1200
+ * createExport({ path: './utils' })
1201
+ * ```
1202
+ *
1203
+ * @example Namespace alias (TypeScript: `export * as utils from './utils'`)
1204
+ * ```ts
1205
+ * createExport({ name: 'utils', path: './utils', asAlias: true })
1206
+ * ```
1207
+ */
1208
+ type ExportNode = BaseNode & {
1209
+ kind: 'Export';
1210
+ /**
1211
+ * Export name(s) to be used. When omitted, generates a wildcard export.
1212
+ * @example ['useState']
1213
+ * @example 'React'
1214
+ */
1215
+ name?: string | Array<string> | null;
1216
+ /**
1217
+ * Path for the export.
1218
+ * @example '@kubb/core'
1219
+ */
1220
+ path: string;
1221
+ /**
1222
+ * Add type-only export prefix.
1223
+ * - `true` generates `export type { Type } from './path'`
1224
+ * - `false` generates `export { Type } from './path'`
1225
+ * @default false
1226
+ */
1227
+ isTypeOnly?: boolean | null;
1228
+ /**
1229
+ * Export as an aliased namespace.
1230
+ * - `true` generates `export * as aliasName from './path'`
1231
+ * - `false` generates a standard export
1232
+ * @default false
1233
+ */
1234
+ asAlias?: boolean | null;
1235
+ };
1236
+ /**
1237
+ * Represents a fragment of source code within a file.
1238
+ *
1239
+ * @example Named exportable source
1240
+ * ```ts
1241
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
1242
+ * ```
1243
+ *
1244
+ * @example Inline unnamed code block
1245
+ * ```ts
1246
+ * createSource({ nodes: [createText('const x = 1')] })
1247
+ * ```
1248
+ */
1249
+ type SourceNode = BaseNode & {
1250
+ kind: 'Source';
1251
+ /**
1252
+ * Optional name identifying this source (used for deduplication and barrel generation).
1253
+ */
1254
+ name?: string | null;
1255
+ /**
1256
+ * Mark this source as a type-only export.
1257
+ * @default false
1258
+ */
1259
+ isTypeOnly?: boolean | null;
1260
+ /**
1261
+ * Include `export` keyword in the generated source.
1262
+ * @default false
1263
+ */
1264
+ isExportable?: boolean | null;
1265
+ /**
1266
+ * Include this source in barrel/index file generation.
1267
+ * @default false
1268
+ */
1269
+ isIndexable?: boolean | null;
1270
+ /**
1271
+ * Structured child nodes representing the content of this source fragment, in DOM order.
1272
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
1273
+ */
1274
+ nodes?: Array<CodeNode>;
1275
+ };
1276
+ /**
1277
+ * Represents a fully resolved file in the AST.
1278
+ *
1279
+ * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
1280
+ * and deduplicates `imports`, `exports`, and `sources`.
1281
+ *
1282
+ * @example
1283
+ * ```ts
1284
+ * const file = createFile({
1285
+ * baseName: 'petStore.ts',
1286
+ * path: 'src/models/petStore.ts',
1287
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
1288
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
1289
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
1290
+ * })
1291
+ * // file.id = SHA256 hash of the path
1292
+ * // file.name = 'petStore'
1293
+ * // file.extname = '.ts'
1294
+ * ```
1295
+ */
1296
+ type FileNode<TMeta extends object = object> = BaseNode & {
1297
+ kind: 'File';
1298
+ /**
1299
+ * Unique identifier derived from a SHA256 hash of the file path. Computed
1300
+ * by `createFile`; callers do not need to provide it.
1301
+ */
1302
+ id: string;
1303
+ /**
1304
+ * File name without extension, derived from `baseName`.
1305
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
1306
+ */
1307
+ name: string;
1308
+ /**
1309
+ * File base name, including extension.
1310
+ * Based on UNIX basename: `${name}${extname}`
1311
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
1312
+ */
1313
+ baseName: `${string}.${string}`;
1314
+ /**
1315
+ * Full qualified path to the file.
1316
+ */
1317
+ path: string;
1318
+ /**
1319
+ * File extension extracted from `baseName`.
1320
+ */
1321
+ extname: Extname;
1322
+ /**
1323
+ * Deduplicated list of source code fragments.
1324
+ */
1325
+ sources: Array<SourceNode>;
1326
+ /**
1327
+ * Deduplicated list of import declarations.
1328
+ */
1329
+ imports: Array<ImportNode>;
1330
+ /**
1331
+ * Deduplicated list of export declarations.
1332
+ */
1333
+ exports: Array<ExportNode>;
1334
+ /**
1335
+ * Optional metadata attached to this file (used by plugins for barrel generation etc.).
1336
+ */
1337
+ meta?: TMeta;
1338
+ /**
1339
+ * Optional banner prepended to the generated file content.
1340
+ * Accepts `null` so `resolver.resolveBanner()` results can be passed directly.
1341
+ */
1342
+ banner?: string | null;
1343
+ /**
1344
+ * Optional footer appended to the generated file content.
1345
+ * Accepts `null` so `resolver.resolveFooter()` results can be passed directly.
1346
+ */
1347
+ footer?: string | null;
1348
+ };
1349
+ //#endregion
1350
+ //#region src/nodes/function.d.ts
1351
+ /**
1352
+ * AST node representing a language-agnostic type expression used as a function parameter
1353
+ * type annotation. Each language printer renders the variant into its own syntax.
1354
+ *
1355
+ * - `struct` an inline anonymous type grouping named fields.
1356
+ * TypeScript renders as `{ petId: string; name?: string }`.
1357
+ * - `member` a single named field accessed from a named group type.
1358
+ * TypeScript renders as `PathParams['petId']`.
1359
+ *
1360
+ * @example Reference variant
1361
+ * ```ts
1362
+ * createParamsType({ variant: 'reference', name: 'QueryParams' })
1363
+ * // QueryParams
1364
+ * ```
1365
+ *
1366
+ * @example Struct variant
1367
+ * ```ts
1368
+ * createParamsType({ variant: 'struct', properties: [{ name: 'petId', optional: false, type: createParamsType({ variant: 'reference', name: 'string' }) }] })
1369
+ * // { petId: string }
1370
+ * ```
1371
+ *
1372
+ * @example Member variant
1373
+ * ```ts
1374
+ * createParamsType({ variant: 'member', base: 'PathParams', key: 'petId' })
1375
+ * // PathParams['petId']
1376
+ * ```
1377
+ */
1378
+ type ParamsTypeNode = BaseNode & {
1379
+ /**
1380
+ * Node kind.
1381
+ */
1382
+ kind: 'ParamsType';
1383
+ } & ({
1384
+ /**
1385
+ * Reference variant, a plain type name or identifier.
1386
+ * TypeScript renders as-is, e.g. `string`, `QueryParams`, `Partial<Config>`.
1387
+ */
1388
+ variant: 'reference';
1389
+ /**
1390
+ * The full type name string, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`.
1391
+ */
1392
+ name: string;
1393
+ } | {
1394
+ /**
1395
+ * Struct variant, an inline anonymous type grouping named fields.
1396
+ * TypeScript renders as `{ key: Type; other?: OtherType }`.
1397
+ */
1398
+ variant: 'struct';
1399
+ /**
1400
+ * Properties of the struct type.
1401
+ */
1402
+ properties: Array<{
1403
+ name: string;
1404
+ optional: boolean;
1405
+ type: ParamsTypeNode;
1406
+ }>;
1407
+ } | {
1408
+ /**
1409
+ * Member variant, a single named field accessed from a group type.
1410
+ * TypeScript renders as `Base['key']`.
1411
+ */
1412
+ variant: 'member';
1413
+ /**
1414
+ * Base type name, e.g. `'DeletePetPathParams'`.
1415
+ */
1416
+ base: string;
1417
+ /**
1418
+ * The field name to access, e.g. `'petId'`.
1419
+ */
1420
+ key: string;
1421
+ });
1422
+ /**
1423
+ * AST node for one function parameter.
1424
+ *
1425
+ * @example Required parameter
1426
+ * `name: Type`
1427
+ *
1428
+ * @example Optional parameter
1429
+ * `name?: Type`
1430
+ *
1431
+ * @example Parameter with default value
1432
+ * `name: Type = defaultValue`
1433
+ *
1434
+ * @example Rest parameter
1435
+ * `...name: Type[]`
1436
+ */
1437
+ type FunctionParameterNode = BaseNode & {
1438
+ /**
1439
+ * Node kind.
1440
+ */
1441
+ kind: 'FunctionParameter';
1442
+ /**
1443
+ * Parameter name in the generated signature.
1444
+ */
1445
+ name: string;
1446
+ /**
1447
+ * Type annotation as a structured {@link ParamsTypeNode}.
1448
+ * Omit for untyped output.
1449
+ *
1450
+ * @example Reference type node
1451
+ * `{ kind: 'ParamsType', variant: 'reference', name: 'string' }` → `petId: string`
1452
+ *
1453
+ * @example Struct type node
1454
+ * `{ kind: 'ParamsType', variant: 'struct', properties: [...] }` → `{ key: Type; other?: OtherType }`
1455
+ *
1456
+ * @example Member type node
1457
+ * `{ kind: 'ParamsType', variant: 'member', base: 'PathParams', key: 'petId' }` → `PathParams['petId']`
1458
+ */
1459
+ type?: ParamsTypeNode;
1460
+ /**
1461
+ * When `true` the parameter is emitted as a rest parameter.
1462
+ *
1463
+ * @example Rest parameter
1464
+ * `...name: Type[]`
1465
+ */
1466
+ rest?: boolean;
1467
+ }
1468
+ /**
1469
+ * Optional parameter, rendered with `?` and may be omitted by the caller.
1470
+ * Cannot be combined with `default` because a defaulted parameter is already optional.
1471
+ */
1472
+ & ({
1473
+ optional: true;
1474
+ default?: never;
1475
+ }
1476
+ /**
1477
+ * Required parameter, or a parameter with a default value.
1478
+ *
1479
+ * @example Required
1480
+ * `name: Type`
1481
+ *
1482
+ * @example With default
1483
+ * `name: Type = default`
1484
+ */
1485
+ | {
1486
+ optional?: false;
1487
+ default?: string;
1488
+ });
1489
+ /**
1490
+ * AST node for a group of related function parameters treated as a single unit.
1491
+ *
1492
+ * Each language printer decides how to render this group:
1493
+ * - TypeScript/JS: destructured object `{ key1, key2 }: { key1: Type1; key2: Type2 } = {}`
1494
+ * - Python: keyword-only args or a typed dict parameter
1495
+ * - C# / Kotlin: named record / data-class parameter
1496
+ *
1497
+ * When `inline` is `true`, the group is spread as individual top-level parameters
1498
+ * rather than wrapped in a single grouped construct.
1499
+ *
1500
+ * @example Grouped destructuring
1501
+ * `{ id, name }: { id: string; name: string } = {}`
1502
+ *
1503
+ * @example Inline (spread as individual parameters)
1504
+ * `id: string, name: string`
1505
+ */
1506
+ type ParameterGroupNode = BaseNode & {
1507
+ /**
1508
+ * Node kind.
1509
+ */
1510
+ kind: 'ParameterGroup';
1511
+ /**
1512
+ * The individual parameters that form the group.
1513
+ * Rendered as a destructured object or spread inline when `inline` is `true`.
1514
+ */
1515
+ properties: Array<FunctionParameterNode>;
1516
+ /**
1517
+ * Optional explicit type annotation for the whole group.
1518
+ * When absent, printers auto-compute it from `properties`.
1519
+ */
1520
+ type?: ParamsTypeNode;
1521
+ /**
1522
+ * When `true`, `properties` are emitted as individual top-level parameters instead of
1523
+ * being wrapped in a single grouped construct.
1524
+ *
1525
+ * @default false
1526
+ */
1527
+ inline?: boolean;
1528
+ /**
1529
+ * Whether the group as a whole is optional.
1530
+ * If omitted, printers infer this from child properties.
1531
+ */
1532
+ optional?: boolean;
1533
+ /**
1534
+ * Default value for the group, written verbatim after `=`.
1535
+ * Commonly `'{}'` to allow omitting the argument entirely.
1536
+ */
1537
+ default?: string;
1538
+ };
1539
+ /**
1540
+ * AST node for a complete function parameter list.
1541
+ *
1542
+ * Printers are responsible for sorting (`required` → `optional` → `defaulted`).
1543
+ * Nodes are plain immutable data.
1544
+ *
1545
+ * Renders differently depending on the output mode:
1546
+ * - `declaration` → `(id: string, config: Config = {})` function declaration parameters
1547
+ * - `call` → `(id, { method, url })` function call arguments
1548
+ * - `keys` → `{ id, config }` key names only (for destructuring)
1549
+ * - `values` → `{ id: id, config: config }` key → value pairs
1550
+ */
1551
+ type FunctionParametersNode = BaseNode & {
1552
+ /**
1553
+ * Node kind.
1554
+ */
1555
+ kind: 'FunctionParameters';
1556
+ /**
1557
+ * Ordered parameter nodes.
1558
+ */
1559
+ params: ReadonlyArray<FunctionParameterNode | ParameterGroupNode>;
1560
+ };
1561
+ /**
1562
+ * Union of all function-parameter AST node variants used by the function-parameter printer.
1563
+ */
1564
+ type FunctionParamNode = FunctionParameterNode | ParameterGroupNode | FunctionParametersNode | ParamsTypeNode;
1565
+ /**
1566
+ * Handler map keys, one per `FunctionParamNode` kind.
1567
+ */
1568
+ type FunctionNodeType = 'functionParameter' | 'parameterGroup' | 'functionParameters' | 'paramsType';
1569
+ //#endregion
1570
+ //#region src/nodes/parameter.d.ts
1571
+ type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
1572
+ /**
1573
+ * AST node representing one operation parameter.
1574
+ *
1575
+ * @example
1576
+ * ```ts
1577
+ * const param: ParameterNode = {
1578
+ * kind: 'Parameter',
1579
+ * name: 'petId',
1580
+ * in: 'path',
1581
+ * schema: createSchema({ type: 'string' }),
1582
+ * required: true,
1583
+ * }
1584
+ * ```
1585
+ */
1586
+ type ParameterNode = BaseNode & {
1587
+ /**
1588
+ * Node kind.
1589
+ */
1590
+ kind: 'Parameter';
1591
+ /**
1592
+ * Parameter name.
1593
+ */
1594
+ name: string;
1595
+ /**
1596
+ * Parameter location (`path`, `query`, `header`, or `cookie`).
1597
+ */
1598
+ in: ParameterLocation;
1599
+ /**
1600
+ * Parameter schema.
1601
+ */
1602
+ schema: SchemaNode;
1603
+ /**
1604
+ * Whether the parameter is required.
1605
+ */
1606
+ required: boolean;
1607
+ };
1608
+ //#endregion
1609
+ //#region src/nodes/http.d.ts
1610
+ /**
1611
+ * All supported HTTP status code literals as strings, as used in API specs
1612
+ * (for example, `"200"` and `"404"`).
1613
+ */
1614
+ type HttpStatusCode = '100' | '101' | '102' | '103' | '200' | '201' | '202' | '203' | '204' | '205' | '206' | '207' | '208' | '226' | '300' | '301' | '302' | '303' | '304' | '305' | '307' | '308' | '400' | '401' | '402' | '403' | '404' | '405' | '406' | '407' | '408' | '409' | '410' | '411' | '412' | '413' | '414' | '415' | '416' | '417' | '418' | '421' | '422' | '423' | '424' | '425' | '426' | '428' | '429' | '431' | '451' | '500' | '501' | '502' | '503' | '504' | '505' | '506' | '507' | '508' | '510' | '511';
1615
+ /**
1616
+ * Response status code literal used by operations.
1617
+ *
1618
+ * Includes specific HTTP status code strings and `"default"` for catch-all responses.
1619
+ *
1620
+ * @example
1621
+ * ```ts
1622
+ * const status: StatusCode = '200'
1623
+ * const fallback: StatusCode = 'default'
1624
+ * ```
1625
+ */
1626
+ type StatusCode = HttpStatusCode | 'default';
1627
+ //#endregion
1628
+ //#region src/nodes/response.d.ts
1629
+ /**
1630
+ * AST node representing one operation response variant.
1631
+ *
1632
+ * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside
1633
+ * the `content` array (one entry per content type), so the same schema is never duplicated at the
1634
+ * node root and inside `content`.
1635
+ *
1636
+ * @example
1637
+ * ```ts
1638
+ * const response: ResponseNode = {
1639
+ * kind: 'Response',
1640
+ * statusCode: '200',
1641
+ * content: [{ contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
1642
+ * }
1643
+ * ```
1644
+ */
1645
+ type ResponseNode = BaseNode & {
1646
+ /**
1647
+ * Node kind.
1648
+ */
1649
+ kind: 'Response';
1650
+ /**
1651
+ * HTTP status code or `'default'` for a fallback response.
1652
+ */
1653
+ statusCode: StatusCode;
1654
+ /**
1655
+ * Optional response description.
1656
+ */
1657
+ description?: string;
1658
+ /**
1659
+ * All available content type entries for this response.
1660
+ *
1661
+ * When the adapter `contentType` option is set, this array contains exactly one entry for that
1662
+ * content type. Otherwise it contains one entry per content type declared in the spec, so that
1663
+ * plugins can generate a union of response types (e.g. `application/json` and `application/xml`).
1664
+ * Body-less responses keep a single entry whose `schema` is the empty/`void` placeholder.
1665
+ *
1666
+ * @example
1667
+ * ```ts
1668
+ * // spec response declares both application/json and application/xml
1669
+ * response.content[0].contentType // 'application/json'
1670
+ * response.content[1].contentType // 'application/xml'
1671
+ * ```
1672
+ */
1673
+ content?: Array<ContentNode>;
1674
+ };
1675
+ //#endregion
1676
+ //#region src/nodes/operation.d.ts
1677
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE';
1678
+ /**
1679
+ * Transport an operation belongs to.
1680
+ */
1681
+ type OperationProtocol = 'http';
1682
+ /**
1683
+ * AST node representing an operation request body.
1684
+ *
1685
+ * Body schemas live exclusively inside the `content` array (one entry per content type),
1686
+ * mirroring {@link ResponseNode}.
1687
+ *
1688
+ * @example
1689
+ * ```ts
1690
+ * const requestBody: RequestBodyNode = {
1691
+ * kind: 'RequestBody',
1692
+ * required: true,
1693
+ * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
1694
+ * }
1695
+ * ```
1696
+ */
1697
+ type RequestBodyNode = BaseNode & {
1698
+ /**
1699
+ * Node kind.
1700
+ */
1701
+ kind: 'RequestBody';
1702
+ /**
1703
+ * Human-readable request body description.
1704
+ */
1705
+ description?: string;
1706
+ /**
1707
+ * Whether the request body is required (`requestBody.required: true` in the spec).
1708
+ * When `false` or absent, the generated `data` parameter should be optional.
1709
+ */
1710
+ required?: boolean;
1711
+ /**
1712
+ * All available content type entries for this request body.
1713
+ *
1714
+ * When the adapter `contentType` option is set, this array contains exactly one entry for
1715
+ * that content type. Otherwise it contains one entry per content type declared in the spec,
1716
+ * so that plugins can generate code for every variant (e.g. separate hooks for
1717
+ * `application/json` and `multipart/form-data`).
1718
+ */
1719
+ content?: Array<ContentNode>;
1720
+ };
1721
+ /**
1722
+ * Fields shared by every operation, regardless of transport.
1723
+ */
1724
+ type OperationNodeBase = BaseNode & {
1725
+ /**
1726
+ * Node kind.
1727
+ */
1728
+ kind: 'Operation';
1729
+ /**
1730
+ * Operation identifier, usually from OpenAPI `operationId`.
1731
+ */
1732
+ operationId: string;
1733
+ /**
1734
+ * Group labels for the operation.
1735
+ * Usually copied from OpenAPI `tags`.
1736
+ */
1737
+ tags: Array<string>;
1738
+ /**
1739
+ * Short one-line operation summary.
1740
+ */
1741
+ summary?: string;
1742
+ /**
1743
+ * Full operation description.
1744
+ */
1745
+ description?: string;
1746
+ /**
1747
+ * Marks the operation as deprecated.
1748
+ */
1749
+ deprecated?: boolean;
1750
+ /**
1751
+ * Parameters that could be used, we have QueryParams, PathParams, HeaderParams and CookieParams
1752
+ */
1753
+ parameters: Array<ParameterNode>;
1754
+ /**
1755
+ * Request body for the operation.
1756
+ */
1757
+ requestBody?: RequestBodyNode;
1758
+ /**
1759
+ * Operation responses.
1760
+ */
1761
+ responses: Array<ResponseNode>;
1762
+ };
1763
+ /**
1764
+ * Operation served over HTTP/REST (OpenAPI). `method` and `path` are guaranteed.
1765
+ *
1766
+ * @example
1767
+ * ```ts
1768
+ * const operation: HttpOperationNode = {
1769
+ * kind: 'Operation',
1770
+ * operationId: 'listPets',
1771
+ * protocol: 'http',
1772
+ * method: 'GET',
1773
+ * path: '/pets',
1774
+ * tags: [],
1775
+ * parameters: [],
1776
+ * responses: [],
1777
+ * }
1778
+ * ```
1779
+ */
1780
+ type HttpOperationNode = OperationNodeBase & {
1781
+ /**
1782
+ * Transport the operation belongs to.
1783
+ */
1784
+ protocol?: 'http';
1785
+ /**
1786
+ * HTTP method like `'GET'`.
1787
+ */
1788
+ method: HttpMethod;
1789
+ /**
1790
+ * OpenAPI-style path string, for example `/pets/{petId}`, with `{param}` notation preserved.
1791
+ */
1792
+ path: string;
1793
+ };
1794
+ /**
1795
+ * Operation for a non-HTTP transport. HTTP-only fields are forbidden.
1796
+ */
1797
+ type GenericOperationNode = OperationNodeBase & {
1798
+ /**
1799
+ * Transport the operation belongs to.
1800
+ */
1801
+ protocol?: Exclude<OperationProtocol, 'http'>;
1802
+ method?: never;
1803
+ path?: never;
1804
+ };
1805
+ /**
1806
+ * AST node representing one API operation.
1807
+ *
1808
+ * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees
1809
+ * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with
1810
+ * `isHttpOperationNode(node)` or `node.protocol === 'http'` before reading `method`/`path`.
1811
+ */
1812
+ type OperationNode = HttpOperationNode | GenericOperationNode;
1813
+ //#endregion
1814
+ //#region src/nodes/output.d.ts
1815
+ /**
1816
+ * Output AST node that groups all generated file output for one API document.
1817
+ *
1818
+ * Produced by generators and consumed by the build pipeline to write files.
1819
+ *
1820
+ * @example
1821
+ * ```ts
1822
+ * const output: OutputNode = {
1823
+ * kind: 'Output',
1824
+ * files: [],
1825
+ * }
1826
+ * ```
1827
+ */
1828
+ type OutputNode = BaseNode & {
1829
+ /**
1830
+ * Node kind.
1831
+ */
1832
+ kind: 'Output';
1833
+ /**
1834
+ * Generated file nodes.
1835
+ */
1836
+ files: Array<FileNode>;
1837
+ };
1838
+ //#endregion
1839
+ //#region src/nodes/root.d.ts
1840
+ /**
1841
+ * Metadata for an API document, populated by the adapter and available to every generator.
1842
+ *
1843
+ * All fields are plain JSON-serializable values, no `Set`, no `Map`, no class instances.
1844
+ * Computed fields (`circularNames`, `enumNames`) are pre-calculated once during the adapter
1845
+ * pre-scan so generators never need to iterate the full schema list themselves.
1846
+ *
1847
+ * @example
1848
+ * ```ts
1849
+ * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://petstore.swagger.io/v2', circularNames: [], enumNames: [] }
1850
+ * ```
1851
+ */
1852
+ type InputMeta = {
1853
+ /**
1854
+ * API title from `info.title` in the source document.
1855
+ */
1856
+ title?: string;
1857
+ /**
1858
+ * API description from `info.description` in the source document.
1859
+ */
1860
+ description?: string;
1861
+ /**
1862
+ * API version string from `info.version` in the source document.
1863
+ */
1864
+ version?: string;
1865
+ /**
1866
+ * Resolved base URL from the first matching server entry in the source document.
1867
+ */
1868
+ baseURL?: string | null;
1869
+ /**
1870
+ * Names of schemas that participate in a circular reference chain.
1871
+ * Computed once during the adapter pre-scan, use this instead of calling
1872
+ * `findCircularSchemas` per generator call.
1873
+ *
1874
+ * Convert to a `Set` once at the start of a generator, not per-schema,
1875
+ * to keep lookup O(1) without repeated allocations.
1876
+ *
1877
+ * @example Wrap a circular schema in z.lazy()
1878
+ * ```ts
1879
+ * const circular = new Set(meta.circularNames)
1880
+ * if (circular.has(schema.name)) { ... }
1881
+ * ```
1882
+ */
1883
+ circularNames: ReadonlyArray<string>;
1884
+ /**
1885
+ * Names of schemas whose type is `enum`.
1886
+ * Computed once during the adapter pre-scan, use this instead of filtering
1887
+ * schemas per generator call.
1888
+ *
1889
+ * Convert to a `Set` once at the start of a generator when you need repeated
1890
+ * membership checks, rather than calling `.includes()` per schema.
1891
+ *
1892
+ * @example Check if a referenced schema is an enum
1893
+ * `const enums = new Set(meta.enumNames)`
1894
+ * `const isEnum = enums.has(schemaName)`
1895
+ */
1896
+ enumNames: ReadonlyArray<string>;
1897
+ };
1898
+ /**
1899
+ * Input AST node that contains all schemas and operations for one API document.
1900
+ * Produced by the adapter and consumed by all Kubb plugins.
1901
+ *
1902
+ * @example
1903
+ * ```ts
1904
+ * const input: InputNode = {
1905
+ * kind: 'Input',
1906
+ * schemas: [],
1907
+ * operations: [],
1908
+ * }
1909
+ * ```
1910
+ */
1911
+ type InputNode = BaseNode & {
1912
+ /**
1913
+ * Node kind.
1914
+ */
1915
+ kind: 'Input';
1916
+ /**
1917
+ * All schema nodes in the document.
1918
+ */
1919
+ schemas: Array<SchemaNode>;
1920
+ /**
1921
+ * All operation nodes in the document.
1922
+ */
1923
+ operations: Array<OperationNode>;
1924
+ /**
1925
+ * Document metadata populated by the adapter.
1926
+ */
1927
+ meta: InputMeta;
1928
+ };
1929
+ /**
1930
+ * Streaming variant of `InputNode` for memory-efficient processing of large API specs.
1931
+ *
1932
+ * `schemas` and `operations` are `AsyncIterable` rather than arrays, each `for await`
1933
+ * loop creates a fresh parse pass from the cached in-memory document, so multiple
1934
+ * consumers (plugins) can iterate independently without keeping all nodes in memory.
1935
+ *
1936
+ * @example
1937
+ * ```ts
1938
+ * for await (const schema of inputStreamNode.schemas) {
1939
+ * // only this one SchemaNode is live here. Previous ones are GC-eligible
1940
+ * }
1941
+ * ```
1942
+ */
1943
+ type InputStreamNode = {
1944
+ kind: 'Input';
1945
+ /**
1946
+ * Lazily parsed schema nodes. Each `for await` creates a fresh parse pass, so
1947
+ * multiple plugins can iterate independently without sharing state.
1948
+ */
1949
+ schemas: AsyncIterable<SchemaNode>;
1950
+ /**
1951
+ * Lazily parsed operation nodes. Each `for await` creates a fresh parse pass, so
1952
+ * multiple plugins can iterate independently without sharing state.
1953
+ */
1954
+ operations: AsyncIterable<OperationNode>;
1955
+ /**
1956
+ * Document metadata available immediately, before the first yielded node.
1957
+ */
1958
+ meta?: InputMeta;
1959
+ };
1960
+ //#endregion
1961
+ //#region src/nodes/index.d.ts
1962
+ /**
1963
+ * Union of all AST node types.
1964
+ *
1965
+ * This lets TypeScript narrow types in `switch (node.kind)` blocks.
1966
+ *
1967
+ * @example
1968
+ * ```ts
1969
+ * function getKind(node: Node): string {
1970
+ * switch (node.kind) {
1971
+ * case 'Input':
1972
+ * return 'input'
1973
+ * case 'Output':
1974
+ * return 'output'
1975
+ * default:
1976
+ * return 'other'
1977
+ * }
1978
+ * }
1979
+ * ```
1980
+ */
1981
+ type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FunctionParamNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | ParamsTypeNode | FunctionNode | ArrowFunctionNode;
1982
+ //#endregion
1983
+ //#region src/dedupe.d.ts
1984
+ /**
1985
+ * A canonical destination for a deduplicated shape: the shared schema name and
1986
+ * the synthetic `$ref` path that points at it.
1987
+ */
1988
+ type DedupeCanonical = {
1989
+ /**
1990
+ * Canonical schema name every duplicate occurrence refers to.
1991
+ */
1992
+ name: string;
1993
+ /**
1994
+ * `$ref` path stored on the generated `ref` nodes (for example `#/components/schemas/Status`).
1995
+ */
1996
+ ref: string;
1997
+ };
1998
+ /**
1999
+ * The result of {@link buildDedupePlan}: a lookup from structural signature to its
2000
+ * canonical target, plus the freshly hoisted definitions that must be added to
2001
+ * the schema list.
2002
+ */
2003
+ type DedupePlan = {
2004
+ /**
2005
+ * Maps a structural signature to the canonical schema that represents it.
2006
+ */
2007
+ canonicalBySignature: Map<string, DedupeCanonical>;
2008
+ /**
2009
+ * New top-level schema definitions created for inline shapes that had no existing
2010
+ * named component. Nested duplicates inside each definition are already collapsed.
2011
+ */
2012
+ hoisted: Array<SchemaNode>;
2013
+ };
2014
+ /**
2015
+ * Options that inject the naming and candidate policy into {@link buildDedupePlan}.
2016
+ * The mechanics (grouping, counting, rewriting) live here. The policy lives in the caller.
2017
+ */
2018
+ type BuildDedupePlanOptions = {
2019
+ /**
2020
+ * Returns `true` when a node should be deduplicated. This is the only gate, so it must
2021
+ * reject both ineligible kinds (return `false` for anything other than, say, enums and
2022
+ * objects) and unsafe shapes (e.g. nodes that reference a circular schema).
2023
+ */
2024
+ isCandidate: (node: SchemaNode) => boolean;
2025
+ /**
2026
+ * Produces the canonical name for an inline shape with no existing named component.
2027
+ * Return `null` to leave the shape inline (for example when no contextual name exists).
2028
+ */
2029
+ nameFor: (node: SchemaNode, signature: string) => string | null;
2030
+ /**
2031
+ * Builds the `$ref` path for a canonical name.
2032
+ */
2033
+ refFor: (name: string) => string;
2034
+ /**
2035
+ * Minimum number of occurrences before a shape is deduplicated.
2036
+ *
2037
+ * @default 2
2038
+ */
2039
+ minOccurrences?: number;
2040
+ };
2041
+ /**
2042
+ * Rewrites a node, replacing every candidate sub-schema whose signature has a canonical
2043
+ * target with a `ref` to that target. Replacing a node with a `ref` prunes its subtree,
2044
+ * so nested duplicates inside a replaced shape are not visited again.
2045
+ *
2046
+ * Pass `skipRootMatch` when rewriting a canonical definition so its own root is not
2047
+ * turned into a reference to itself. Nested duplicates are still collapsed.
2048
+ *
2049
+ * @example
2050
+ * ```ts
2051
+ * const next = applyDedupe(operationNode, plan.canonicalBySignature)
2052
+ * ```
2053
+ */
2054
+ declare function applyDedupe(node: SchemaNode, canonicalBySignature: ReadonlyMap<string, DedupeCanonical>, skipRootMatch?: boolean): SchemaNode;
2055
+ declare function applyDedupe(node: OperationNode, canonicalBySignature: ReadonlyMap<string, DedupeCanonical>, skipRootMatch?: boolean): OperationNode;
2056
+ /**
2057
+ * Scans a forest of schema and operation nodes and produces a {@link DedupePlan}.
2058
+ *
2059
+ * A shape that occurs at least `minOccurrences` times is deduplicated: if any occurrence
2060
+ * is a named top-level schema, that name becomes the canonical (so other top-level duplicates
2061
+ * and inline copies turn into references to it). Otherwise a new definition is hoisted using
2062
+ * `nameFor`. The plan is then applied per node with {@link applyDedupe}.
2063
+ *
2064
+ * @example
2065
+ * ```ts
2066
+ * const plan = buildDedupePlan([...schemaNodes, ...operationNodes], {
2067
+ * isCandidate: (node) => node.type === 'enum' || node.type === 'object',
2068
+ * nameFor: (node) => node.name ?? null,
2069
+ * refFor: (name) => `#/components/schemas/${name}`,
2070
+ * })
2071
+ * ```
2072
+ */
2073
+ declare function buildDedupePlan(roots: ReadonlyArray<Node>, options: BuildDedupePlanOptions): DedupePlan;
2074
+ //#endregion
2075
+ //#region src/dialect.d.ts
2076
+ /**
2077
+ * The spec-specific decisions a schema parser makes when converting a source document's schemas
2078
+ * into Kubb AST nodes. Everything else in an adapter's schema pipeline is generic JSON Schema,
2079
+ * shared across specs, so the dialect is the one seam where specs differ, like a database driver
2080
+ * targeting Postgres vs MySQL. Pair it with {@link dispatch}: the rule table picks which converter
2081
+ * runs, the dialect answers the spec-specific questions inside it.
2082
+ *
2083
+ * The guards (`isReference`, `isDiscriminator`) are type predicates, so converters narrow the
2084
+ * schema after a check and the type parameters carry the narrowed types through.
2085
+ *
2086
+ * This is the seam for the JSON Schema family: OpenAPI, AsyncAPI, and plain JSON Schema share
2087
+ * `$ref`, `allOf`/`oneOf`, `enum`, and `format` and differ only in these few decisions. A spec on
2088
+ * a different type system (GraphQL, with non-null wrappers and named-type references instead of
2089
+ * `$ref`) skips `SchemaDialect` and reuses the universal layer directly: the `Adapter` port, the
2090
+ * AST factories, and {@link dispatch} with its own rule table.
2091
+ *
2092
+ * @typeParam TSchema - The adapter's schema object type (e.g. an OpenAPI `SchemaObject`).
2093
+ * @typeParam TRef - The narrowed `$ref` pointer type `isReference` proves.
2094
+ * @typeParam TDiscriminated - The narrowed discriminated-schema type `isDiscriminator` proves.
2095
+ * @typeParam TDocument - The source document `resolveRef` resolves against.
2096
+ */
2097
+ type SchemaDialect<TSchema = unknown, TRef = TSchema, TDiscriminated = TSchema, TDocument = unknown> = {
2098
+ /** Identifies the dialect in logs and while debugging dispatch. */name: string; /** Whether a schema should be treated as nullable. */
2099
+ isNullable: (schema?: TSchema) => boolean; /** Whether a value is a `$ref` pointer object. */
2100
+ isReference: (value?: unknown) => value is TRef; /** Whether a schema carries a structured discriminator (polymorphism). */
2101
+ isDiscriminator: (value?: unknown) => value is TDiscriminated; /** Whether a schema represents binary data (converted to a `blob` node). */
2102
+ isBinary: (schema: TSchema) => boolean; /** Resolves a local `$ref` pointer against the document, or nullish when it cannot. */
2103
+ resolveRef: <TResolved>(document: TDocument, ref: string) => TResolved | null | undefined;
2104
+ };
2105
+ /**
2106
+ * Identity helper that types a {@link SchemaDialect} for an adapter. Like
2107
+ * `defineParser`, it adds no runtime behavior, it pins the dialect's type for
2108
+ * inference and gives adapter authors a discoverable anchor.
2109
+ *
2110
+ * @example
2111
+ * ```ts
2112
+ * export const oasDialect = defineSchemaDialect({
2113
+ * name: 'oas',
2114
+ * isNullable,
2115
+ * isReference,
2116
+ * isDiscriminator,
2117
+ * isBinary: (schema) => schema.type === 'string' && schema.contentMediaType === 'application/octet-stream',
2118
+ * resolveRef,
2119
+ * })
2120
+ * ```
2121
+ */
2122
+ declare function defineSchemaDialect<TSchema, TRef, TDiscriminated, TDocument>(dialect: SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>): SchemaDialect<TSchema, TRef, TDiscriminated, TDocument>;
2123
+ //#endregion
2124
+ //#region src/dispatch.d.ts
2125
+ /**
2126
+ * One entry in an ordered dispatch table: a predicate paired with a converter.
2127
+ *
2128
+ * @typeParam TContext - Per-input context handed to every rule. A spec adapter typically
2129
+ * pre-computes this once per node (the source spec node plus derived fields like a
2130
+ * normalized type or resolved options) so individual rules stay cheap predicates.
2131
+ * @typeParam TNode - The node a rule produces, e.g. a Kubb AST `SchemaNode`.
2132
+ */
2133
+ type DispatchRule<TContext, TNode> = {
2134
+ /** Identifies the rule when reading the table or debugging which branch ran. */name: string; /** Returns `true` when this rule is responsible for the given context. */
2135
+ match: (context: TContext) => boolean;
2136
+ /**
2137
+ * Produces a node for the context, or `null` to fall through to the next rule.
2138
+ *
2139
+ * Returning `null` lets a broad `match` defer: e.g. "has a `format`" matches many schemas,
2140
+ * but only some formats are convertible, the rest fall through to plain `type` handling.
2141
+ */
2142
+ convert: (context: TContext) => TNode | null;
2143
+ };
2144
+ /**
2145
+ * Walks an ordered list of {@link DispatchRule}s and returns the first node produced.
2146
+ *
2147
+ * This is the shared backbone for spec adapters (OpenAPI today, AsyncAPI and others later).
2148
+ * The contract an adapter follows is intentionally minimal:
2149
+ *
2150
+ * context → [rule.match → rule.convert] → node
2151
+ *
2152
+ * An adapter derives a context from a source spec node, then declares an ordered table of
2153
+ * rules mapping spec shapes onto Kubb AST nodes. To add support for a new spec, write a new
2154
+ * context type and a new rules table, the traversal here is reused unchanged.
2155
+ *
2156
+ * Order is significant: earlier rules win, so list higher-precedence or more specific shapes
2157
+ * first (e.g. composition keywords before plain `type`). A rule whose `match` returns `true`
2158
+ * may still `convert` to `null` to defer to later rules. When no rule produces a node this
2159
+ * returns `null`, leaving the caller to apply its own fallback.
2160
+ *
2161
+ * @example
2162
+ * ```ts
2163
+ * const node = dispatch(schemaRules, schemaContext) ?? createSchema({ type: fallbackType })
2164
+ * ```
2165
+ */
2166
+ declare function dispatch<TContext, TNode>(rules: ReadonlyArray<DispatchRule<TContext, TNode>>, context: TContext): TNode | null;
2167
+ //#endregion
2168
+ //#region src/infer.d.ts
2169
+ /**
2170
+ * Shared parser options used by OAS-to-AST inference and parser flows.
2171
+ */
2172
+ type ParserOptions = {
2173
+ /**
2174
+ * How `format: 'date-time'` schemas are represented downstream.
2175
+ * - `false` falls through to a plain `string` (no validation).
2176
+ * - `'string'` emits a datetime string node.
2177
+ * - `'stringOffset'` emits a datetime node with timezone offset.
2178
+ * - `'stringLocal'` emits a local datetime node.
2179
+ * - `'date'` emits a `date` node (JavaScript `Date` object).
2180
+ */
2181
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
2182
+ /**
2183
+ * How `type: 'integer'` (and `format: 'int64'`) maps to TypeScript.
2184
+ * - `'bigint'` is exact for 64-bit IDs, but does not round-trip through JSON.
2185
+ * - `'number'` fits most JSON APIs. Loses precision above `Number.MAX_SAFE_INTEGER`.
2186
+ *
2187
+ * @default 'bigint'
2188
+ */
2189
+ integerType?: 'number' | 'bigint';
2190
+ /**
2191
+ * AST type used when a schema's type cannot be inferred from the spec
2192
+ * (`additionalProperties: true`, missing `type`, ...).
2193
+ */
2194
+ unknownType: 'any' | 'unknown' | 'void';
2195
+ /**
2196
+ * AST type used for completely empty schemas (`{}`).
2197
+ */
2198
+ emptySchemaType: 'any' | 'unknown' | 'void';
2199
+ /**
2200
+ * Suffix appended to derived enum names when Kubb has to invent one
2201
+ * (typically for inline enums on object properties).
2202
+ */
2203
+ enumSuffix: 'enum' | (string & {});
2204
+ };
2205
+ /**
2206
+ * Maps each `dateType` option value to the AST node produced by `format: 'date-time'`.
2207
+ */
2208
+ type DateTimeNodeByDateType = {
2209
+ date: DateSchemaNode;
2210
+ string: DatetimeSchemaNode;
2211
+ stringOffset: DatetimeSchemaNode;
2212
+ stringLocal: DatetimeSchemaNode;
2213
+ false: StringSchemaNode;
2214
+ };
2215
+ /**
2216
+ * Resolves the AST node produced by `format: 'date-time'` based on the `dateType` option.
2217
+ */
2218
+ type ResolveDateTimeNode<TDateType extends ParserOptions['dateType']> = DateTimeNodeByDateType[TDateType extends keyof DateTimeNodeByDateType ? TDateType : 'string'];
2219
+ /**
2220
+ * Ordered list of `[schema-shape, SchemaNode]` pairs.
2221
+ * `InferSchemaNode` walks this tuple in order and returns the first matching node type.
2222
+ */
2223
+ type SchemaNodeMap<TDateType extends ParserOptions['dateType'] = 'string'> = [[{
2224
+ $ref: string;
2225
+ }, RefSchemaNode], [{
2226
+ allOf: ReadonlyArray<unknown>;
2227
+ properties: object;
2228
+ }, IntersectionSchemaNode], [{
2229
+ allOf: readonly [unknown, unknown, ...Array<unknown>];
2230
+ }, IntersectionSchemaNode], [{
2231
+ allOf: ReadonlyArray<unknown>;
2232
+ }, SchemaNode], [{
2233
+ oneOf: ReadonlyArray<unknown>;
2234
+ }, UnionSchemaNode], [{
2235
+ anyOf: ReadonlyArray<unknown>;
2236
+ }, UnionSchemaNode], [{
2237
+ const: null;
2238
+ }, ScalarSchemaNode], [{
2239
+ const: string | number | boolean;
2240
+ }, EnumSchemaNode], [{
2241
+ type: ReadonlyArray<string>;
2242
+ }, UnionSchemaNode], [{
2243
+ type: 'array';
2244
+ enum: ReadonlyArray<unknown>;
2245
+ }, ArraySchemaNode], [{
2246
+ enum: ReadonlyArray<unknown>;
2247
+ }, EnumSchemaNode], [{
2248
+ type: 'enum';
2249
+ }, EnumSchemaNode], [{
2250
+ type: 'union';
2251
+ }, UnionSchemaNode], [{
2252
+ type: 'intersection';
2253
+ }, IntersectionSchemaNode], [{
2254
+ type: 'tuple';
2255
+ }, ArraySchemaNode], [{
2256
+ type: 'ref';
2257
+ }, RefSchemaNode], [{
2258
+ type: 'datetime';
2259
+ }, DatetimeSchemaNode], [{
2260
+ type: 'date';
2261
+ }, DateSchemaNode], [{
2262
+ type: 'time';
2263
+ }, TimeSchemaNode], [{
2264
+ type: 'url';
2265
+ }, UrlSchemaNode], [{
2266
+ type: 'object';
2267
+ }, ObjectSchemaNode], [{
2268
+ additionalProperties: boolean | {};
2269
+ }, ObjectSchemaNode], [{
2270
+ type: 'array';
2271
+ }, ArraySchemaNode], [{
2272
+ items: object;
2273
+ }, ArraySchemaNode], [{
2274
+ prefixItems: ReadonlyArray<unknown>;
2275
+ }, ArraySchemaNode], [{
2276
+ type: string;
2277
+ format: 'date-time';
2278
+ }, ResolveDateTimeNode<TDateType>], [{
2279
+ type: string;
2280
+ format: 'date';
2281
+ }, DateSchemaNode], [{
2282
+ type: string;
2283
+ format: 'time';
2284
+ }, TimeSchemaNode], [{
2285
+ format: 'date-time';
2286
+ }, ResolveDateTimeNode<TDateType>], [{
2287
+ format: 'date';
2288
+ }, DateSchemaNode], [{
2289
+ format: 'time';
2290
+ }, TimeSchemaNode], [{
2291
+ type: 'string';
2292
+ }, StringSchemaNode], [{
2293
+ type: 'number';
2294
+ }, NumberSchemaNode], [{
2295
+ type: 'integer';
2296
+ }, NumberSchemaNode], [{
2297
+ type: 'bigint';
2298
+ }, NumberSchemaNode], [{
2299
+ type: string;
2300
+ }, ScalarSchemaNode], [{
2301
+ minLength: number;
2302
+ }, StringSchemaNode], [{
2303
+ maxLength: number;
2304
+ }, StringSchemaNode], [{
2305
+ pattern: string;
2306
+ }, StringSchemaNode], [{
2307
+ minimum: number;
2308
+ }, NumberSchemaNode], [{
2309
+ maximum: number;
2310
+ }, NumberSchemaNode]];
2311
+ /**
2312
+ * Infers the matching AST `SchemaNode` type from an input schema shape.
2313
+ */
2314
+ type InferSchemaNode<TSchema extends object, TDateType extends ParserOptions['dateType'] = 'string', TEntries extends ReadonlyArray<[object, SchemaNode]> = SchemaNodeMap<TDateType>> = TEntries extends [infer TEntry extends [object, SchemaNode], ...infer TRest extends ReadonlyArray<[object, SchemaNode]>] ? TSchema extends TEntry[0] ? TEntry[1] : InferSchemaNode<TSchema, TDateType, TRest> : SchemaNode;
2315
+ //#endregion
2316
+ //#region src/factory.d.ts
2317
+ /**
2318
+ * Updates a schema's `optional` and `nullish` flags from a parent's `required`
2319
+ * value and the schema's own `nullable`. Mirrors how OpenAPI parameters and
2320
+ * object properties combine "required" and "nullable" into a single AST.
2321
+ *
2322
+ * - Non-required + non-nullable → `optional: true`.
2323
+ * - Non-required + nullable → `nullish: true`.
2324
+ * - Required → both flags cleared.
2325
+ */
2326
+ declare function syncOptionality(schema: SchemaNode, required: boolean): SchemaNode;
2327
+ /**
2328
+ * Distributive `Omit` that preserves each member of a union.
2329
+ *
2330
+ * @example
2331
+ * ```ts
2332
+ * type A = { kind: 'a'; keep: string; drop: number }
2333
+ * type B = { kind: 'b'; keep: boolean; drop: number }
2334
+ * type Result = DistributiveOmit<A | B, 'drop'>
2335
+ * // -> { kind: 'a'; keep: string } | { kind: 'b'; keep: boolean }
2336
+ * ```
2337
+ */
2338
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
2339
+ /**
2340
+ * Identity-preserving node update: returns `node` unchanged when every field in
2341
+ * `changes` already equals (by reference) the current value, otherwise a new node
2342
+ * with the changes applied.
2343
+ *
2344
+ * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the
2345
+ * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and
2346
+ * downstream passes can detect "nothing changed" by identity. Comparison is
2347
+ * shallow: a structurally-equal but newly-allocated array/object counts as a change.
2348
+ *
2349
+ * @example
2350
+ * ```ts
2351
+ * update(node, { name: node.name }) // -> same `node` reference
2352
+ * update(node, { name: 'renamed' }) // -> new node, `name` replaced
2353
+ * ```
2354
+ */
2355
+ declare function update<T extends Node>(node: T, changes: Partial<T>): T;
2356
+ type CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & {
2357
+ properties?: Array<PropertyNode>;
2358
+ primitive?: 'object';
2359
+ };
2360
+ type CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>;
2361
+ type CreateSchemaOutput<T extends CreateSchemaInput> = InferSchemaNode<T> & {
2362
+ kind: 'Schema';
2363
+ };
2364
+ /**
2365
+ * Creates an `InputNode` with stable defaults for `schemas` and `operations`.
2366
+ *
2367
+ * @example
2368
+ * ```ts
2369
+ * const input = createInput()
2370
+ * // { kind: 'Input', schemas: [], operations: [] }
2371
+ * ```
2372
+ *
2373
+ * @example
2374
+ * ```ts
2375
+ * const input = createInput({ schemas: [petSchema] })
2376
+ * // keeps default operations: []
2377
+ * ```
2378
+ */
2379
+ declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
2380
+ /**
2381
+ * Creates an `InputStreamNode` from pre-built `AsyncIterable` sources.
2382
+ *
2383
+ * @example
2384
+ * ```ts
2385
+ * const node = createStreamInput(schemasIterable, operationsIterable, { title: 'My API' })
2386
+ * ```
2387
+ */
2388
+ declare function createStreamInput(schemas: AsyncIterable<SchemaNode>, operations: AsyncIterable<OperationNode>, meta?: InputMeta): InputStreamNode;
2389
+ /**
2390
+ * Creates an `OutputNode` with a stable default for `files`.
2391
+ *
2392
+ * @example
2393
+ * ```ts
2394
+ * const output = createOutput()
2395
+ * // { kind: 'Output', files: [] }
2396
+ * ```
2397
+ *
2398
+ * @example
2399
+ * ```ts
2400
+ * const output = createOutput({ files: [petFile] })
2401
+ * ```
2402
+ */
2403
+ declare function createOutput(overrides?: Partial<Omit<OutputNode, 'kind'>>): OutputNode;
2404
+ /**
2405
+ * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.
2406
+ *
2407
+ * @example
2408
+ * ```ts
2409
+ * const operation = createOperation({
2410
+ * operationId: 'getPetById',
2411
+ * method: 'GET',
2412
+ * path: '/pet/{petId}',
2413
+ * })
2414
+ * // tags, parameters, and responses are []
2415
+ * ```
2416
+ *
2417
+ * @example
2418
+ * ```ts
2419
+ * const operation = createOperation({
2420
+ * operationId: 'findPets',
2421
+ * method: 'GET',
2422
+ * path: '/pet/findByStatus',
2423
+ * tags: ['pet'],
2424
+ * })
2425
+ * ```
2426
+ */
2427
+ /**
2428
+ * Loosely-typed content entry accepted by the builders, normalized into a {@link ContentNode}.
2429
+ */
2430
+ type UserContent = Omit<ContentNode, 'kind'>;
2431
+ /**
2432
+ * Creates a `ContentNode` for a single request-body or response content type.
2433
+ */
2434
+ /**
2435
+ * Loosely-typed request body accepted by `createOperation`, normalized into a {@link RequestBodyNode}.
2436
+ */
2437
+ type UserRequestBody = Omit<RequestBodyNode, 'kind' | 'content'> & {
2438
+ content?: Array<UserContent>;
2439
+ };
2440
+ /**
2441
+ * Creates a `RequestBodyNode`, normalizing each content entry into a `ContentNode`.
2442
+ */
2443
+ declare function createOperation(props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> & Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {
2444
+ requestBody?: UserRequestBody;
2445
+ }): HttpOperationNode;
2446
+ declare function createOperation(props: Pick<GenericOperationNode, 'operationId'> & Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {
2447
+ requestBody?: UserRequestBody;
2448
+ }): GenericOperationNode;
2449
+ /**
2450
+ * Creates a `SchemaNode`, narrowed to the variant of `props.type`.
2451
+ * For object schemas, `properties` defaults to an empty array.
2452
+ * `primitive` is automatically inferred from `type` when not explicitly provided.
2453
+ *
2454
+ * @example
2455
+ * ```ts
2456
+ * const scalar = createSchema({ type: 'string' })
2457
+ * // { kind: 'Schema', type: 'string', primitive: 'string' }
2458
+ * ```
2459
+ *
2460
+ * @example
2461
+ * ```ts
2462
+ * const uuid = createSchema({ type: 'uuid' })
2463
+ * // { kind: 'Schema', type: 'uuid', primitive: 'string' }
2464
+ * ```
2465
+ *
2466
+ * @example
2467
+ * ```ts
2468
+ * const object = createSchema({ type: 'object' })
2469
+ * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }
2470
+ * ```
2471
+ *
2472
+ * @example
2473
+ * ```ts
2474
+ * const enumSchema = createSchema({
2475
+ * type: 'enum',
2476
+ * primitive: 'string',
2477
+ * enumValues: ['available', 'pending'],
2478
+ * })
2479
+ * ```
2480
+ */
2481
+ declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
2482
+ declare function createSchema(props: CreateSchemaInput): SchemaNode;
2483
+ type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>;
2484
+ /**
2485
+ * Creates a `PropertyNode`.
2486
+ *
2487
+ * `required` defaults to `false`.
2488
+ * `schema.optional` and `schema.nullish` are derived from `required` and `schema.nullable`.
2489
+ *
2490
+ * @example
2491
+ * ```ts
2492
+ * const property = createProperty({
2493
+ * name: 'status',
2494
+ * schema: createSchema({ type: 'string' }),
2495
+ * })
2496
+ * // required=false, schema.optional=true
2497
+ * ```
2498
+ *
2499
+ * @example
2500
+ * ```ts
2501
+ * const property = createProperty({
2502
+ * name: 'status',
2503
+ * required: true,
2504
+ * schema: createSchema({ type: 'string', nullable: true }),
2505
+ * })
2506
+ * // required=true, no optional/nullish
2507
+ * ```
2508
+ */
2509
+ declare function createProperty(props: UserPropertyNode): PropertyNode;
2510
+ /**
2511
+ * Creates a `ParameterNode`.
2512
+ *
2513
+ * `required` defaults to `false`.
2514
+ * Nested schema flags are set from `required` and `schema.nullable`.
2515
+ *
2516
+ * @example
2517
+ * ```ts
2518
+ * const param = createParameter({
2519
+ * name: 'petId',
2520
+ * in: 'path',
2521
+ * required: true,
2522
+ * schema: createSchema({ type: 'string' }),
2523
+ * })
2524
+ * ```
2525
+ *
2526
+ * @example
2527
+ * ```ts
2528
+ * const param = createParameter({
2529
+ * name: 'status',
2530
+ * in: 'query',
2531
+ * schema: createSchema({ type: 'string', nullable: true }),
2532
+ * })
2533
+ * // required=false, schema.nullish=true
2534
+ * ```
2535
+ */
2536
+ declare function createParameter(props: Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>): ParameterNode;
2537
+ /**
2538
+ * Creates a `ResponseNode`.
2539
+ *
2540
+ * Response body schemas live inside `content`. For convenience a single legacy `schema`
2541
+ * (with optional `mediaType`/`keysToOmit`) is normalized into one `content` entry, so the same
2542
+ * schema is never stored both at the node root and inside `content`.
2543
+ *
2544
+ * @example
2545
+ * ```ts
2546
+ * const response = createResponse({
2547
+ * statusCode: '200',
2548
+ * content: [{ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) }],
2549
+ * })
2550
+ * ```
2551
+ */
2552
+ declare function createResponse(props: Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {
2553
+ content?: Array<UserContent>;
2554
+ schema?: SchemaNode;
2555
+ mediaType?: string | null;
2556
+ keysToOmit?: Array<string> | null;
2557
+ }): ResponseNode;
2558
+ /**
2559
+ * Creates a `FunctionParameterNode`.
2560
+ *
2561
+ * `optional` defaults to `false`.
2562
+ *
2563
+ * @example Required typed param
2564
+ * ```ts
2565
+ * createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }) })
2566
+ * // → petId: string
2567
+ * ```
2568
+ *
2569
+ * @example Optional param
2570
+ * ```ts
2571
+ * createFunctionParameter({ name: 'params', type: createParamsType({ variant: 'reference', name: 'QueryParams' }), optional: true })
2572
+ * // → params?: QueryParams
2573
+ * ```
2574
+ *
2575
+ * @example Param with default (implicitly optional. Cannot combine with `optional: true`)
2576
+ * ```ts
2577
+ * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), default: '{}' })
2578
+ * // → config: RequestConfig = {}
2579
+ * ```
2580
+ */
2581
+ declare function createFunctionParameter(props: {
2582
+ name: string;
2583
+ type?: ParamsTypeNode;
2584
+ rest?: boolean;
2585
+ } & ({
2586
+ optional: true;
2587
+ default?: never;
2588
+ } | {
2589
+ optional?: false;
2590
+ default?: string;
2591
+ })): FunctionParameterNode;
2592
+ /**
2593
+ * Creates a {@link TypeNode} representing a language-agnostic structured type expression.
2594
+ *
2595
+ * Use `variant: 'struct'` for inline anonymous types and `variant: 'member'` for a single
2596
+ * named field accessed from a group type. Each language's printer renders the variant
2597
+ * into its own syntax (TypeScript, Python, C#, Kotlin, …).
2598
+ *
2599
+ * @example Reference type (TypeScript: `QueryParams`)
2600
+ * ```ts
2601
+ * createParamsType({ variant: 'reference', name: 'QueryParams' })
2602
+ * ```
2603
+ *
2604
+ * @example Struct type (TypeScript: `{ petId: string }`)
2605
+ * ```ts
2606
+ * createParamsType({ variant: 'struct', properties: [{ name: 'petId', optional: false, type: createParamsType({ variant: 'reference', name: 'string' }) }] })
2607
+ * ```
2608
+ *
2609
+ * @example Member type (TypeScript: `DeletePetPathParams['petId']`)
2610
+ * ```ts
2611
+ * createParamsType({ variant: 'member', base: 'DeletePetPathParams', key: 'petId' })
2612
+ * ```
2613
+ */
2614
+ declare function createParamsType(props: {
2615
+ variant: 'reference';
2616
+ name: string;
2617
+ } | {
2618
+ variant: 'struct';
2619
+ properties: Array<{
2620
+ name: string;
2621
+ optional: boolean;
2622
+ type: ParamsTypeNode;
2623
+ }>;
2624
+ } | {
2625
+ variant: 'member';
2626
+ base: string;
2627
+ key: string;
2628
+ }): ParamsTypeNode;
2629
+ /**
2630
+ * Creates a `ParameterGroupNode` representing a group of related parameters treated as a unit.
2631
+ *
2632
+ * @example Grouped param (TypeScript declaration)
2633
+ * ```ts
2634
+ * createParameterGroup({
2635
+ * properties: [
2636
+ * createFunctionParameter({ name: 'id', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false }),
2637
+ * createFunctionParameter({ name: 'name', type: createParamsType({ variant: 'reference', name: 'string' }), optional: true }),
2638
+ * ],
2639
+ * default: '{}',
2640
+ * })
2641
+ * // declaration → { id, name? }: { id: string; name?: string } = {}
2642
+ * // call → { id, name }
2643
+ * ```
2644
+ *
2645
+ * @example Inline (spread), children emitted as individual top-level parameters
2646
+ * ```ts
2647
+ * createParameterGroup({
2648
+ * properties: [createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false })],
2649
+ * inline: true,
2650
+ * })
2651
+ * // declaration → petId: string
2652
+ * // call → petId
2653
+ * ```
2654
+ */
2655
+ declare function createParameterGroup(props: Pick<ParameterGroupNode, 'properties'> & Partial<Omit<ParameterGroupNode, 'kind' | 'properties'>>): ParameterGroupNode;
2656
+ /**
2657
+ * Creates a `FunctionParametersNode` from an ordered list of parameters.
2658
+ *
2659
+ * @example
2660
+ * ```ts
2661
+ * createFunctionParameters({
2662
+ * params: [
2663
+ * createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false }),
2664
+ * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), optional: false, default: '{}' }),
2665
+ * ],
2666
+ * })
2667
+ * ```
2668
+ *
2669
+ * @example
2670
+ * ```ts
2671
+ * const empty = createFunctionParameters()
2672
+ * // { kind: 'FunctionParameters', params: [] }
2673
+ * ```
2674
+ */
2675
+ declare function createFunctionParameters(props?: Partial<Omit<FunctionParametersNode, 'kind'>>): FunctionParametersNode;
2676
+ /**
2677
+ * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
2678
+ *
2679
+ * @example Named import
2680
+ * ```ts
2681
+ * createImport({ name: ['useState'], path: 'react' })
2682
+ * // import { useState } from 'react'
2683
+ * ```
2684
+ *
2685
+ * @example Type-only import
2686
+ * ```ts
2687
+ * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
2688
+ * // import type { FC } from 'react'
2689
+ * ```
2690
+ */
2691
+ declare function createImport(props: Omit<ImportNode, 'kind'>): ImportNode;
2692
+ /**
2693
+ * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
2694
+ *
2695
+ * @example Named export
2696
+ * ```ts
2697
+ * createExport({ name: ['Pet'], path: './Pet' })
2698
+ * // export { Pet } from './Pet'
2699
+ * ```
2700
+ *
2701
+ * @example Wildcard export
2702
+ * ```ts
2703
+ * createExport({ path: './utils' })
2704
+ * // export * from './utils'
2705
+ * ```
2706
+ */
2707
+ declare function createExport(props: Omit<ExportNode, 'kind'>): ExportNode;
2708
+ /**
2709
+ * Creates a `SourceNode` representing a fragment of source code within a file.
2710
+ *
2711
+ * @example
2712
+ * ```ts
2713
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
2714
+ * ```
2715
+ */
2716
+ declare function createSource(props: Omit<SourceNode, 'kind'>): SourceNode;
2717
+ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> & Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>;
2718
+ /**
2719
+ * Creates a fully resolved `FileNode` from a file input descriptor.
2720
+ *
2721
+ * Computes:
2722
+ * - `id` SHA256 hash of the file path
2723
+ * - `name` `baseName` without extension
2724
+ * - `extname` extension extracted from `baseName`
2725
+ *
2726
+ * Deduplicates:
2727
+ * - `sources` via `combineSources`
2728
+ * - `exports` via `combineExports`
2729
+ * - `imports` via `combineImports` (also filters unused imports)
2730
+ *
2731
+ * @throws {Error} when `baseName` has no extension.
2732
+ *
2733
+ * @example
2734
+ * ```ts
2735
+ * const file = createFile({
2736
+ * baseName: 'petStore.ts',
2737
+ * path: 'src/models/petStore.ts',
2738
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
2739
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
2740
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
2741
+ * })
2742
+ * // file.id = SHA256 hash of 'src/models/petStore.ts'
2743
+ * // file.name = 'petStore'
2744
+ * // file.extname = '.ts'
2745
+ * ```
2746
+ */
2747
+ declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
2748
+ /**
2749
+ * Creates a `ConstNode` representing a TypeScript `const` declaration.
2750
+ *
2751
+ * Mirrors the `Const` component from `@kubb/renderer-jsx`.
2752
+ * The component's `children` are represented as `nodes`.
2753
+ *
2754
+ * @example Simple constant
2755
+ * ```ts
2756
+ * createConst({ name: 'pet' })
2757
+ * // const pet = ...
2758
+ * ```
2759
+ *
2760
+ * @example Exported constant with type and `as const`
2761
+ * ```ts
2762
+ * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
2763
+ * // export const pets: Pet[] = ... as const
2764
+ * ```
2765
+ *
2766
+ * @example With JSDoc and child nodes
2767
+ * ```ts
2768
+ * createConst({
2769
+ * name: 'config',
2770
+ * export: true,
2771
+ * JSDoc: { comments: ['@description App configuration'] },
2772
+ * nodes: [],
2773
+ * })
2774
+ * ```
2775
+ */
2776
+ declare function createConst(props: Omit<ConstNode, 'kind'>): ConstNode;
2777
+ /**
2778
+ * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
2779
+ *
2780
+ * Mirrors the `Type` component from `@kubb/renderer-jsx`.
2781
+ * The component's `children` are represented as `nodes`.
2782
+ *
2783
+ * @example Simple type alias
2784
+ * ```ts
2785
+ * createType({ name: 'Pet' })
2786
+ * // type Pet = ...
2787
+ * ```
2788
+ *
2789
+ * @example Exported type with JSDoc
2790
+ * ```ts
2791
+ * createType({
2792
+ * name: 'PetStatus',
2793
+ * export: true,
2794
+ * JSDoc: { comments: ['@description Status of a pet'] },
2795
+ * })
2796
+ * // export type PetStatus = ...
2797
+ * ```
2798
+ */
2799
+ declare function createType(props: Omit<TypeNode, 'kind'>): TypeNode;
2800
+ /**
2801
+ * Creates a `FunctionNode` representing a TypeScript `function` declaration.
2802
+ *
2803
+ * Mirrors the `Function` component from `@kubb/renderer-jsx`.
2804
+ * The component's `children` are represented as `nodes`.
2805
+ *
2806
+ * @example Simple function
2807
+ * ```ts
2808
+ * createFunction({ name: 'getPet' })
2809
+ * // function getPet() { ... }
2810
+ * ```
2811
+ *
2812
+ * @example Exported async function with return type
2813
+ * ```ts
2814
+ * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
2815
+ * // export async function fetchPet(): Promise<Pet> { ... }
2816
+ * ```
2817
+ *
2818
+ * @example Function with generics and params
2819
+ * ```ts
2820
+ * createFunction({
2821
+ * name: 'identity',
2822
+ * export: true,
2823
+ * generics: ['T'],
2824
+ * params: 'value: T',
2825
+ * returnType: 'T',
2826
+ * })
2827
+ * // export function identity<T>(value: T): T { ... }
2828
+ * ```
2829
+ */
2830
+ declare function createFunction(props: Omit<FunctionNode, 'kind'>): FunctionNode;
2831
+ /**
2832
+ * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
2833
+ *
2834
+ * Mirrors the `Function.Arrow` component from `@kubb/renderer-jsx`.
2835
+ * The component's `children` are represented as `nodes`.
2836
+ *
2837
+ * @example Simple arrow function
2838
+ * ```ts
2839
+ * createArrowFunction({ name: 'getPet' })
2840
+ * // const getPet = () => { ... }
2841
+ * ```
2842
+ *
2843
+ * @example Single-line exported arrow function
2844
+ * ```ts
2845
+ * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
2846
+ * // export const double = (n: number) => ...
2847
+ * ```
2848
+ *
2849
+ * @example Async arrow function with generics
2850
+ * ```ts
2851
+ * createArrowFunction({
2852
+ * name: 'fetchPet',
2853
+ * export: true,
2854
+ * async: true,
2855
+ * generics: ['T'],
2856
+ * params: 'id: string',
2857
+ * returnType: 'T',
2858
+ * })
2859
+ * // export const fetchPet = async <T>(id: string): Promise<T> => { ... }
2860
+ * ```
2861
+ */
2862
+ declare function createArrowFunction(props: Omit<ArrowFunctionNode, 'kind'>): ArrowFunctionNode;
2863
+ /**
2864
+ * Creates a {@link TextNode} representing a raw string fragment in the source output.
2865
+ *
2866
+ * Use this instead of bare strings when building `nodes` arrays so that every
2867
+ * entry in the array is a typed {@link CodeNode}.
2868
+ *
2869
+ * @example
2870
+ * ```ts
2871
+ * createText('return fetch(id)')
2872
+ * // { kind: 'Text', value: 'return fetch(id)' }
2873
+ * ```
2874
+ */
2875
+ declare function createText(value: string): TextNode;
2876
+ /**
2877
+ * Creates a {@link BreakNode} representing a line break in the source output.
2878
+ *
2879
+ * Corresponds to `<br/>` in JSX components. Prints as an empty string which,
2880
+ * when joined with `\n` by `printNodes`, produces a blank line.
2881
+ *
2882
+ * @example
2883
+ * ```ts
2884
+ * createBreak()
2885
+ * // { kind: 'Break' }
2886
+ * ```
2887
+ */
2888
+ declare function createBreak(): BreakNode;
2889
+ /**
2890
+ * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
2891
+ *
2892
+ * Use this to embed JSX markup (including fragments `<>…</>`) directly in generated code.
2893
+ *
2894
+ * @example
2895
+ * ```ts
2896
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
2897
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
2898
+ * ```
2899
+ */
2900
+ declare function createJsx(value: string): JsxNode;
2901
+ //#endregion
2902
+ //#region src/printer.d.ts
2903
+ /**
2904
+ * Runtime context passed as `this` to printer handlers.
2905
+ *
2906
+ * `this.transform` dispatches to node-level handlers from `nodes`.
2907
+ *
2908
+ * @example
2909
+ * ```ts
2910
+ * const context: PrinterHandlerContext<string, {}> = {
2911
+ * options: {},
2912
+ * transform: () => 'value',
2913
+ * }
2914
+ * ```
2915
+ */
2916
+ type PrinterHandlerContext<TOutput, TOptions extends object> = {
2917
+ /**
2918
+ * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.
2919
+ * Use `this.transform` inside `nodes` handlers and inside the `print` override.
2920
+ */
2921
+ transform: (node: SchemaNode) => TOutput | null;
2922
+ /**
2923
+ * Options for this printer instance.
2924
+ */
2925
+ options: TOptions;
2926
+ };
2927
+ /**
2928
+ * Handler for one schema node type.
2929
+ *
2930
+ * Use a regular function (not an arrow function) if you need `this`.
2931
+ *
2932
+ * @example
2933
+ * ```ts
2934
+ * const handler: PrinterHandler<string, {}, 'string'> = function () {
2935
+ * return 'string'
2936
+ * }
2937
+ * ```
2938
+ */
2939
+ type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (this: PrinterHandlerContext<TOutput, TOptions>, node: SchemaNodeByType[T]) => TOutput | null;
2940
+ /**
2941
+ * Partial map of per-node-type handler overrides for a printer.
2942
+ *
2943
+ * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).
2944
+ * Supply only the handlers you want to replace. The printer's built-in
2945
+ * defaults fill in the rest.
2946
+ *
2947
+ * @example
2948
+ * ```ts
2949
+ * pluginZod({
2950
+ * printer: {
2951
+ * nodes: {
2952
+ * date(): string {
2953
+ * return 'z.string().date()'
2954
+ * },
2955
+ * } satisfies PrinterPartial<string, PrinterZodOptions>,
2956
+ * },
2957
+ * })
2958
+ * ```
2959
+ */
2960
+ type PrinterPartial<TOutput, TOptions extends object> = Partial<{ [K in SchemaType]: PrinterHandler<TOutput, TOptions, K> }>;
2961
+ /**
2962
+ * Generic shape used by `definePrinter`.
2963
+ *
2964
+ * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)
2965
+ * - `TOptions` options passed to and stored on the printer instance
2966
+ * - `TOutput` the type emitted by node handlers
2967
+ * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)
2968
+ *
2969
+ * @example
2970
+ * ```ts
2971
+ * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>
2972
+ * ```
2973
+ */
2974
+ type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {
2975
+ name: TName;
2976
+ options: TOptions;
2977
+ output: TOutput;
2978
+ printOutput: TPrintOutput;
2979
+ };
2980
+ /**
2981
+ * Printer instance returned by a printer factory.
2982
+ *
2983
+ * @example
2984
+ * ```ts
2985
+ * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})
2986
+ * ```
2987
+ */
2988
+ type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {
2989
+ /**
2990
+ * Unique identifier supplied at creation time.
2991
+ */
2992
+ name: T['name'];
2993
+ /**
2994
+ * Options for this printer instance.
2995
+ */
2996
+ options: T['options'];
2997
+ /**
2998
+ * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.
2999
+ * Always dispatches through the `nodes` map. Never calls the `print` override.
3000
+ * Use this when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.
3001
+ */
3002
+ transform: (node: SchemaNode) => T['output'] | null;
3003
+ /**
3004
+ * Public printer. If the builder provides a root-level `print`, this calls that
3005
+ * higher-level function (which may produce full declarations).
3006
+ * Otherwise, falls back to the node-level dispatcher.
3007
+ */
3008
+ print: (node: SchemaNode) => T['printOutput'] | null;
3009
+ };
3010
+ /**
3011
+ * Builder function passed to `definePrinter`.
3012
+ *
3013
+ * It receives resolved options and returns:
3014
+ * - `name`
3015
+ * - `options`
3016
+ * - `nodes` handlers
3017
+ * - optional top-level `print` override
3018
+ *
3019
+ * @example
3020
+ * ```ts
3021
+ * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })
3022
+ * ```
3023
+ */
3024
+ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {
3025
+ name: T['name'];
3026
+ /**
3027
+ * Options to store on the printer.
3028
+ */
3029
+ options: T['options'];
3030
+ nodes: Partial<{ [K in SchemaType]: PrinterHandler<T['output'], T['options'], K> }>;
3031
+ /**
3032
+ * Optional root-level print override. When provided, becomes the public `printer.print`.
3033
+ * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),
3034
+ * not the override itself, so recursion is safe.
3035
+ */
3036
+ print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null;
3037
+ };
3038
+ /**
3039
+ * Defines a schema printer: a function that takes a `SchemaNode` and emits
3040
+ * code in your target language. Each plugin that produces code from schemas
3041
+ * (TypeScript types, Zod schemas, Faker factories) ships a printer built
3042
+ * with this helper.
3043
+ *
3044
+ * The builder receives resolved options and returns:
3045
+ *
3046
+ * - `name` unique identifier for the printer.
3047
+ * - `options` stored on the returned printer instance.
3048
+ * - `nodes` map of `SchemaType` → handler. Handlers return the rendered
3049
+ * output (a string, a TypeScript AST node, ...) for that schema type.
3050
+ * - `print` (optional), top-level override exposed as `printer.print`.
3051
+ * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.
3052
+ *
3053
+ * Without a `print` override, `printer.print` falls back to `printer.transform`
3054
+ * (the node-level dispatcher).
3055
+ *
3056
+ * @example Tiny Zod printer
3057
+ * ```ts
3058
+ * import { definePrinter, type PrinterFactoryOptions } from '@kubb/ast'
3059
+ *
3060
+ * type PrinterZod = PrinterFactoryOptions<'zod', { strict?: boolean }, string>
3061
+ *
3062
+ * export const zodPrinter = definePrinter<PrinterZod>((options) => ({
3063
+ * name: 'zod',
3064
+ * options: { strict: options.strict ?? true },
3065
+ * nodes: {
3066
+ * string: () => 'z.string()',
3067
+ * object(node) {
3068
+ * const props = node.properties
3069
+ * .map((p) => `${p.name}: ${this.transform(p.schema)}`)
3070
+ * .join(', ')
3071
+ * return `z.object({ ${props} })`
3072
+ * },
3073
+ * },
3074
+ * }))
3075
+ * ```
3076
+ */
3077
+ declare function definePrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
3078
+ /**
3079
+ * Generic printer-factory function used by `definePrinter` and `defineFunctionPrinter`.
3080
+ **
3081
+ * @example
3082
+ * ```ts
3083
+ * export const defineFunctionPrinter = createPrinterFactory<FunctionNode, FunctionNodeType, FunctionNodeByType>(
3084
+ * (node) => kindToHandlerKey[node.kind],
3085
+ * )
3086
+ * ```
3087
+ */
3088
+ declare function createPrinterFactory<TNode, TKey extends string, TNodeByKey extends Partial<Record<TKey, TNode>>>(getKey: (node: TNode) => TKey | null): <T extends PrinterFactoryOptions>(build: (options: T["options"]) => {
3089
+ name: T["name"];
3090
+ options: T["options"];
3091
+ nodes: Partial<{ [K in TKey]: (this: {
3092
+ transform: (node: TNode) => T["output"] | null;
3093
+ options: T["options"];
3094
+ }, node: TNodeByKey[K]) => T["output"] | null }>;
3095
+ print?: (this: {
3096
+ transform: (node: TNode) => T["output"] | null;
3097
+ options: T["options"];
3098
+ }, node: TNode) => T["printOutput"] | null;
3099
+ }) => (options?: T["options"]) => {
3100
+ name: T["name"];
3101
+ options: T["options"];
3102
+ transform: (node: TNode) => T["output"] | null;
3103
+ print: (node: TNode) => T["printOutput"] | null;
3104
+ };
3105
+ //#endregion
3106
+ //#region src/visitor.d.ts
3107
+ /**
3108
+ * Ordered mapping of `[NodeType, ParentType]` pairs.
3109
+ *
3110
+ * `ParentOf` uses this map to find parent types.
3111
+ */
3112
+ type ParentNodeMap = [[InputNode, undefined], [OutputNode, undefined], [OperationNode, InputNode], [RequestBodyNode, OperationNode], [ContentNode, RequestBodyNode | ResponseNode], [SchemaNode, InputNode | ContentNode | SchemaNode | PropertyNode | ParameterNode], [PropertyNode, SchemaNode], [ParameterNode, OperationNode], [ResponseNode, OperationNode]];
3113
+ /**
3114
+ * Resolves the parent node type for a given AST node type.
3115
+ *
3116
+ * This is used by visitor context so `ctx.parent` is correctly typed
3117
+ * for each callback.
3118
+ *
3119
+ * @example
3120
+ * ```ts
3121
+ * type InputParent = ParentOf<InputNode>
3122
+ * // undefined
3123
+ * ```
3124
+ *
3125
+ * @example
3126
+ * ```ts
3127
+ * type PropertyParent = ParentOf<PropertyNode>
3128
+ * // SchemaNode
3129
+ * ```
3130
+ *
3131
+ * @example
3132
+ * ```ts
3133
+ * type SchemaParent = ParentOf<SchemaNode>
3134
+ * // InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode
3135
+ * ```
3136
+ */
3137
+ type ParentOf<T extends Node, TEntries extends ReadonlyArray<[Node, unknown]> = ParentNodeMap> = TEntries extends [infer TEntry extends [Node, unknown], ...infer TRest extends ReadonlyArray<[Node, unknown]>] ? T extends TEntry[0] ? TEntry[1] : ParentOf<T, TRest> : Node;
3138
+ /**
3139
+ * Traversal context passed as the second argument to every visitor callback.
3140
+ * `parent` is typed from the current node type.
3141
+ *
3142
+ * @example
3143
+ * ```ts
3144
+ * const visitor: Visitor = {
3145
+ * schema(node, { parent }) {
3146
+ * // parent type is narrowed by node kind
3147
+ * },
3148
+ * }
3149
+ * ```
3150
+ */
3151
+ type VisitorContext<T extends Node = Node> = {
3152
+ /**
3153
+ * Parent node of the currently visited node.
3154
+ * For `InputNode`, this is `undefined`.
3155
+ */
3156
+ parent?: ParentOf<T>;
3157
+ };
3158
+ /**
3159
+ * Synchronous visitor consumed by `transform`. Each optional callback runs
3160
+ * for the matching node type. Return a new node to replace it, or `undefined`
3161
+ * to leave it untouched.
3162
+ *
3163
+ * Plugins typically expose `transformer` so users can supply a `Visitor` that
3164
+ * rewrites operation IDs, drops descriptions, or otherwise tweaks the AST
3165
+ * before printing.
3166
+ *
3167
+ * @example Prefix every operationId
3168
+ * ```ts
3169
+ * const visitor: Visitor = {
3170
+ * operation(node) {
3171
+ * return { ...node, operationId: `api_${node.operationId}` }
3172
+ * },
3173
+ * }
3174
+ * ```
3175
+ *
3176
+ * @example Strip schema descriptions
3177
+ * ```ts
3178
+ * const visitor: Visitor = {
3179
+ * schema(node) {
3180
+ * return { ...node, description: undefined }
3181
+ * },
3182
+ * }
3183
+ * ```
3184
+ */
3185
+ type Visitor = {
3186
+ input?(node: InputNode, context: VisitorContext<InputNode>): undefined | null | InputNode;
3187
+ output?(node: OutputNode, context: VisitorContext<OutputNode>): undefined | null | OutputNode;
3188
+ operation?(node: OperationNode, context: VisitorContext<OperationNode>): undefined | null | OperationNode;
3189
+ schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): undefined | null | SchemaNode;
3190
+ property?(node: PropertyNode, context: VisitorContext<PropertyNode>): undefined | null | PropertyNode;
3191
+ parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): undefined | null | ParameterNode;
3192
+ response?(node: ResponseNode, context: VisitorContext<ResponseNode>): undefined | null | ResponseNode;
3193
+ };
3194
+ /**
3195
+ * Utility type for values that can be returned directly or asynchronously.
3196
+ */
3197
+ type MaybePromise<T> = T | Promise<T>;
3198
+ /**
3199
+ * Async visitor for `walk`. Synchronous `Visitor` objects are compatible.
3200
+ *
3201
+ * @example
3202
+ * ```ts
3203
+ * const visitor: AsyncVisitor = {
3204
+ * async operation(node) {
3205
+ * await Promise.resolve(node.operationId)
3206
+ * },
3207
+ * }
3208
+ * ```
3209
+ */
3210
+ type AsyncVisitor = {
3211
+ input?(node: InputNode, context: VisitorContext<InputNode>): MaybePromise<undefined | null | InputNode>;
3212
+ output?(node: OutputNode, context: VisitorContext<OutputNode>): MaybePromise<undefined | null | OutputNode>;
3213
+ operation?(node: OperationNode, context: VisitorContext<OperationNode>): MaybePromise<undefined | null | OperationNode>;
3214
+ schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): MaybePromise<undefined | null | SchemaNode>;
3215
+ property?(node: PropertyNode, context: VisitorContext<PropertyNode>): MaybePromise<undefined | null | PropertyNode>;
3216
+ parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): MaybePromise<undefined | null | ParameterNode>;
3217
+ response?(node: ResponseNode, context: VisitorContext<ResponseNode>): MaybePromise<undefined | null | ResponseNode>;
3218
+ };
3219
+ /**
3220
+ * Visitor used by `collect`.
3221
+ *
3222
+ * @example
3223
+ * ```ts
3224
+ * const visitor: CollectVisitor<string> = {
3225
+ * operation(node) {
3226
+ * return node.operationId
3227
+ * },
3228
+ * }
3229
+ * ```
3230
+ */
3231
+ type CollectVisitor<T> = {
3232
+ input?(node: InputNode, context: VisitorContext<InputNode>): T | null | undefined;
3233
+ output?(node: OutputNode, context: VisitorContext<OutputNode>): T | null | undefined;
3234
+ operation?(node: OperationNode, context: VisitorContext<OperationNode>): T | null | undefined;
3235
+ schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): T | null | undefined;
3236
+ property?(node: PropertyNode, context: VisitorContext<PropertyNode>): T | null | undefined;
3237
+ parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): T | null | undefined;
3238
+ response?(node: ResponseNode, context: VisitorContext<ResponseNode>): T | null | undefined;
3239
+ };
3240
+ /**
3241
+ * Options for `transform`.
3242
+ *
3243
+ * @example
3244
+ * ```ts
3245
+ * const options: TransformOptions = { depth: 'deep', schema: (node) => node }
3246
+ * ```
3247
+ *
3248
+ * @example
3249
+ * ```ts
3250
+ * // Only transform the current node, not nested children
3251
+ * const options: TransformOptions = { depth: 'shallow', schema: (node) => node }
3252
+ * ```
3253
+ */
3254
+ type TransformOptions = Visitor & {
3255
+ /**
3256
+ * Traversal depth (`'deep'` by default).
3257
+ * @default 'deep'
3258
+ */
3259
+ depth?: VisitorDepth;
3260
+ /**
3261
+ * Internal parent override used during recursion.
3262
+ */
3263
+ parent?: Node;
3264
+ };
3265
+ /**
3266
+ * Options for `walk`.
3267
+ *
3268
+ * @example
3269
+ * ```ts
3270
+ * const options: WalkOptions = { depth: 'deep', concurrency: 10, root: () => {} }
3271
+ * ```
3272
+ */
3273
+ type WalkOptions = AsyncVisitor & {
3274
+ /**
3275
+ * Traversal depth (`'deep'` by default).
3276
+ * @default 'deep'
3277
+ */
3278
+ depth?: VisitorDepth;
3279
+ /**
3280
+ * Maximum number of sibling nodes visited concurrently.
3281
+ * @default 30
3282
+ */
3283
+ concurrency?: number;
3284
+ };
3285
+ /**
3286
+ * Options for `collect`.
3287
+ *
3288
+ * @example
3289
+ * ```ts
3290
+ * const options: CollectOptions<string> = { depth: 'shallow', schema: () => undefined }
3291
+ * ```
3292
+ */
3293
+ type CollectOptions<T> = CollectVisitor<T> & {
3294
+ /**
3295
+ * Traversal depth (`'deep'` by default).
3296
+ * @default 'deep'
3297
+ */
3298
+ depth?: VisitorDepth;
3299
+ /**
3300
+ * Internal parent override used during recursion.
3301
+ */
3302
+ parent?: Node;
3303
+ };
3304
+ /**
3305
+ * Async depth-first traversal for side effects. Visitor return values are
3306
+ * ignored. Use `transform` when you want to rewrite nodes.
3307
+ *
3308
+ * Sibling nodes at each depth run concurrently up to `options.concurrency`
3309
+ * (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor
3310
+ * work. Lower values reduce memory pressure.
3311
+ *
3312
+ * @example Log every operation
3313
+ * ```ts
3314
+ * await walk(root, {
3315
+ * operation(node) {
3316
+ * console.log(node.operationId)
3317
+ * },
3318
+ * })
3319
+ * ```
3320
+ *
3321
+ * @example Only visit the root node
3322
+ * ```ts
3323
+ * await walk(root, { depth: 'shallow', input: () => {} })
3324
+ * ```
3325
+ */
3326
+ declare function walk(node: Node, options: WalkOptions): Promise<void>;
3327
+ /**
3328
+ * Synchronous depth-first transform. Each visitor callback gets a chance to
3329
+ * return a replacement node; `undefined` keeps the original.
3330
+ *
3331
+ * The transform is immutable. The original tree is not mutated. A new tree
3332
+ * is returned. Use `depth: 'shallow'` to skip recursion into children.
3333
+ *
3334
+ * @example Prefix every operationId
3335
+ * ```ts
3336
+ * const next = transform(root, {
3337
+ * operation(node) {
3338
+ * return { ...node, operationId: `prefixed_${node.operationId}` }
3339
+ * },
3340
+ * })
3341
+ * ```
3342
+ *
3343
+ * @example Replace only the root node
3344
+ * ```ts
3345
+ * const next = transform(root, {
3346
+ * depth: 'shallow',
3347
+ * input: (node) => ({ ...node, meta: { ...node.meta, title: 'Rewritten' } }),
3348
+ * })
3349
+ * ```
3350
+ */
3351
+ declare function transform(node: InputNode, options: TransformOptions): InputNode;
3352
+ declare function transform(node: OutputNode, options: TransformOptions): OutputNode;
3353
+ declare function transform(node: OperationNode, options: TransformOptions): OperationNode;
3354
+ declare function transform(node: SchemaNode, options: TransformOptions): SchemaNode;
3355
+ declare function transform(node: PropertyNode, options: TransformOptions): PropertyNode;
3356
+ declare function transform(node: ParameterNode, options: TransformOptions): ParameterNode;
3357
+ declare function transform(node: ResponseNode, options: TransformOptions): ResponseNode;
3358
+ declare function transform(node: Node, options: TransformOptions): Node;
3359
+ /**
3360
+ * Eager depth-first collection pass. Returns an array of every non-null value
3361
+ * the visitor callbacks return.
3362
+ *
3363
+ * @example Collect every operationId
3364
+ * ```ts
3365
+ * const ids = collect<string>(root, {
3366
+ * operation(node) {
3367
+ * return node.operationId
3368
+ * },
3369
+ * })
3370
+ * ```
3371
+ */
3372
+ declare function collect<T>(node: Node, options: CollectOptions<T>): Array<T>;
3373
+ //#endregion
3374
+ //#region src/utils/ast.d.ts
3375
+ /**
3376
+ * Merges a ref node with its resolved schema, giving usage-site fields precedence.
3377
+ *
3378
+ * Usage-site fields (`description`, `readOnly`, `nullable`, `deprecated`) on the ref node
3379
+ * override the same fields in the resolved `node.schema`. Non-ref nodes are returned unchanged.
3380
+ *
3381
+ * @example
3382
+ * ```ts
3383
+ * // Ref with description override
3384
+ * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
3385
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
3386
+ * ```
3387
+ */
3388
+ declare function syncSchemaRef(node: SchemaNode): SchemaNode;
3389
+ /**
3390
+ * Type guard that returns `true` when a schema emits as a plain `string` type.
3391
+ *
3392
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
3393
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
3394
+ */
3395
+ declare function isStringType(node: SchemaNode): boolean;
3396
+ declare function caseParams(params: Array<ParameterNode>, casing: 'camelcase' | undefined): Array<ParameterNode>;
3397
+ /**
3398
+ * Creates a single-property object schema used as a discriminator literal.
3399
+ *
3400
+ * @example
3401
+ * ```ts
3402
+ * createDiscriminantNode({ propertyName: 'type', value: 'dog' })
3403
+ * // -> { type: 'object', properties: [{ name: 'type', required: true, schema: enum('dog') }] }
3404
+ * ```
3405
+ */
3406
+ declare function createDiscriminantNode({
3407
+ propertyName,
3408
+ value
3409
+ }: {
3410
+ propertyName: string;
3411
+ value: string;
3412
+ }): SchemaNode;
3413
+ /**
3414
+ * Resolver interface for {@link createOperationParams}.
3415
+ *
3416
+ * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
3417
+ */
3418
+ type OperationParamsResolver = {
3419
+ /**
3420
+ * Resolves the type name for an individual parameter.
3421
+ *
3422
+ * @example Individual path parameter name
3423
+ * `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
3424
+ */
3425
+ resolveParamName(node: OperationNode, param: ParameterNode): string;
3426
+ /**
3427
+ * Resolves the request body type name.
3428
+ *
3429
+ * @example Request body type name
3430
+ * `resolver.resolveDataName(node) // → 'CreatePetData'`
3431
+ */
3432
+ resolveDataName(node: OperationNode): string;
3433
+ /**
3434
+ * Resolves the grouped path parameters type name.
3435
+ * When the return value equals `resolveParamName`, no indexed access is emitted.
3436
+ *
3437
+ * @example Grouped path params type name
3438
+ * `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
3439
+ */
3440
+ resolvePathParamsName(node: OperationNode, param: ParameterNode): string;
3441
+ /**
3442
+ * Resolves the grouped query parameters type name.
3443
+ * When the return value equals `resolveParamName`, an inline struct type is emitted instead.
3444
+ *
3445
+ * @example Grouped query params type name
3446
+ * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
3447
+ */
3448
+ resolveQueryParamsName(node: OperationNode, param: ParameterNode): string;
3449
+ /**
3450
+ * Resolves the grouped header parameters type name.
3451
+ * When the return value equals `resolveParamName`, an inline struct type is emitted instead.
3452
+ *
3453
+ * @example Grouped header params type name
3454
+ * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
3455
+ */
3456
+ resolveHeaderParamsName(node: OperationNode, param: ParameterNode): string;
3457
+ };
3458
+ /**
3459
+ * Options for {@link createOperationParams}.
3460
+ */
3461
+ type CreateOperationParamsOptions = {
3462
+ /**
3463
+ * How all operation parameters are grouped in the function signature.
3464
+ * - `'object'` wraps all params into a single destructured object `{ petId, data, params }`
3465
+ * - `'inline'` emits each param category as a separate top-level parameter
3466
+ */
3467
+ paramsType: 'object' | 'inline';
3468
+ /**
3469
+ * How path parameters are emitted when `paramsType` is `'inline'`.
3470
+ * - `'object'` groups them as `{ petId, storeId }: PathParams`
3471
+ * - `'inline'` spreads them as individual parameters `petId: string, storeId: string`
3472
+ * - `'inlineSpread'` emits a single rest parameter `...pathParams: PathParams`
3473
+ */
3474
+ pathParamsType: 'object' | 'inline' | 'inlineSpread';
3475
+ /**
3476
+ * Converts parameter names to camelCase before output.
3477
+ */
3478
+ paramsCasing?: 'camelcase';
3479
+ /**
3480
+ * Resolver for parameter and request body type names.
3481
+ * Pass `ResolverTs` from `@kubb/plugin-ts` directly.
3482
+ * When omitted, falls back to the schema primitive or `'unknown'`.
3483
+ */
3484
+ resolver?: OperationParamsResolver;
3485
+ /**
3486
+ * Default value for the path parameters binding when `pathParamsType` is `'object'`.
3487
+ * Falls back to `'{}'` when all path params are optional.
3488
+ */
3489
+ pathParamsDefault?: string;
3490
+ /**
3491
+ * Extra parameters appended after the standard operation parameters.
3492
+ *
3493
+ * @example Plugin-specific trailing parameter
3494
+ * ```ts
3495
+ * extraParams: [createFunctionParameter({ name: 'options', type: 'Partial<RequestOptions>', default: '{}' })]
3496
+ * ```
3497
+ */
3498
+ extraParams?: Array<FunctionParameterNode | ParameterGroupNode>;
3499
+ /**
3500
+ * Override the default parameter names used for body, query, header, and rest-path groups.
3501
+ *
3502
+ * Useful when targeting languages or frameworks with different naming conventions.
3503
+ *
3504
+ * @default { data: 'data', params: 'params', headers: 'headers', path: 'pathParams' }
3505
+ */
3506
+ paramNames?: {
3507
+ /**
3508
+ * Name for the request body parameter.
3509
+ * @default 'data'
3510
+ */
3511
+ data?: string;
3512
+ /**
3513
+ * Name for the query parameters group parameter.
3514
+ * @default 'params'
3515
+ */
3516
+ params?: string;
3517
+ /**
3518
+ * Name for the header parameters group parameter.
3519
+ * @default 'headers'
3520
+ */
3521
+ headers?: string;
3522
+ /**
3523
+ * Name for the rest path-parameters parameter when `pathParamsType` is `'inlineSpread'`.
3524
+ * @default 'pathParams'
3525
+ */
3526
+ path?: string;
3527
+ };
3528
+ /**
3529
+ * Applies a uniform transformation to every resolved type name before it is used
3530
+ * in a parameter node. Use this for framework-level type wrappers.
3531
+ *
3532
+ * @example Vue Query, wrap every parameter type with `MaybeRefOrGetter`
3533
+ * `typeWrapper: (t) => \`MaybeRefOrGetter<${t}>\``
3534
+ */
3535
+ typeWrapper?: (type: string) => string;
3536
+ };
3537
+ /**
3538
+ * Converts an `OperationNode` into function parameters for code generation.
3539
+ *
3540
+ * Centralizes parameter grouping logic for all plugins. Provide a `resolver` for type name resolution
3541
+ * and `extraParams` for plugin-specific trailing parameters (e.g., `options` objects).
3542
+ * Supports three grouping modes: `object` (single destructured param), `inline` (separate params),
3543
+ * and `inlineSpread` (rest parameter). Use `CreateOperationParamsOptions` to fine-tune output.
3544
+ */
3545
+ declare function createOperationParams(node: OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode;
3546
+ /**
3547
+ * Extracts all string content from a `CodeNode` tree recursively.
3548
+ *
3549
+ * Collects text node values, identifier references in string fields (`params`, `generics`, `returnType`, `type`),
3550
+ * and nested node content. Used internally to build the full source string for import filtering.
3551
+ */
3552
+ declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string;
3553
+ declare function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
3554
+ /**
3555
+ * Identifies all schemas that participate in circular dependency chains, including direct self-loops.
3556
+ *
3557
+ * Returns a Set of schema names with circular dependencies. Use this to wrap recursive schema positions
3558
+ * in deferred constructs (lazy getter, `z.lazy(() => …)`) to prevent infinite recursion when generated code runs.
3559
+ * Refs are followed by name only, keeping the algorithm linear in the schema graph size.
3560
+ *
3561
+ * @note Call this once on the full schema graph, then use `containsCircularRef()` to check individual schemas.
3562
+ */
3563
+ declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
3564
+ /**
3565
+ * Type guard returning `true` when a schema or anything nested within it contains a ref to a circular schema.
3566
+ *
3567
+ * Use `excludeName` to ignore refs to specific schemas (useful when self-references are handled separately).
3568
+ * Commonly used with `findCircularSchemas()` to detect where lazy wrappers are needed in code generation.
3569
+ *
3570
+ * @note Returns `true` for the first matching circular ref found. Use for fast dependency checks.
3571
+ */
3572
+ declare function containsCircularRef(node: SchemaNode | undefined, {
3573
+ circularSchemas,
3574
+ excludeName
3575
+ }: {
3576
+ circularSchemas: ReadonlySet<string>;
3577
+ excludeName?: string;
3578
+ }): boolean;
3579
+ //#endregion
3580
+ export { SchemaDialect as $, httpMethods as $t, createFunctionParameter as A, IntersectionSchemaNode as At, createProperty as B, TimeSchemaNode as Bt, UserFileNode as C, FileNode as Ct, createExport as D, DateSchemaNode as Dt, createConst as E, ArraySchemaNode as Et, createOperation as F, ScalarSchemaType as Ft, createText as G, CodeNode as Gt, createSchema as H, UrlSchemaNode as Ht, createOutput as I, SchemaNode as It, update as J, JSDocNode as Jt, createType as K, ConstNode as Kt, createParameter as L, SchemaNodeByType as Lt, createImport as M, ObjectSchemaNode as Mt, createInput as N, PrimitiveSchemaType as Nt, createFile as O, DatetimeSchemaNode as Ot, createJsx as P, RefSchemaNode as Pt, dispatch as Q, NodeKind as Qt, createParameterGroup as R, SchemaType as Rt, DistributiveOmit as S, ExportNode as St, createBreak as T, SourceNode as Tt, createSource as U, PropertyNode as Ut, createResponse as V, UnionSchemaNode as Vt, createStreamInput as W, ArrowFunctionNode as Wt, ParserOptions as X, TextNode as Xt, InferSchemaNode as Y, JsxNode as Yt, DispatchRule as Z, TypeNode as Zt, Printer as _, FunctionParamNode as _t, createDiscriminantNode as a, InputMeta as at, createPrinterFactory as b, ParameterGroupNode as bt, findCircularSchemas as c, OutputNode as ct, ParentOf as d, OperationNode as dt, schemaTypes as en, defineSchemaDialect as et, Visitor as f, ResponseNode as ft, walk as g, FunctionNodeType as gt, transform as h, ParameterNode as ht, containsCircularRef as i, Node as it, createFunctionParameters as j, NumberSchemaNode as jt, createFunction as k, EnumSchemaNode as kt, isStringType as l, HttpMethod as lt, collect as m, ParameterLocation as mt, caseParams as n, applyDedupe as nt, createOperationParams as o, InputNode as ot, VisitorContext as p, StatusCode as pt, syncOptionality as q, FunctionNode as qt, collectUsedSchemaNames as r, buildDedupePlan as rt, extractStringsFromNodes as s, InputStreamNode as st, OperationParamsResolver as t, DedupePlan as tt, syncSchemaRef as u, HttpOperationNode as ut, PrinterFactoryOptions as v, FunctionParameterNode as vt, createArrowFunction as w, ImportNode as wt, definePrinter as x, ParamsTypeNode as xt, PrinterPartial as y, FunctionParametersNode as yt, createParamsType as z, StringSchemaNode as zt };
3581
+ //# sourceMappingURL=types-BaaNZbSi.d.ts.map