@kubb/ast 5.0.0-alpha.31 → 5.0.0-alpha.33

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.
@@ -5,6 +5,25 @@ import { t as __name } from "./chunk--u3MIqq1.js";
5
5
  * Traversal depth used by AST visitor utilities.
6
6
  */
7
7
  type VisitorDepth = 'shallow' | 'deep';
8
+ declare const nodeKinds: {
9
+ readonly input: "Input";
10
+ readonly output: "Output";
11
+ readonly operation: "Operation";
12
+ readonly schema: "Schema";
13
+ readonly property: "Property";
14
+ readonly parameter: "Parameter";
15
+ readonly response: "Response";
16
+ readonly functionParameter: "FunctionParameter";
17
+ readonly parameterGroup: "ParameterGroup";
18
+ readonly functionParameters: "FunctionParameters";
19
+ readonly type: "Type";
20
+ readonly file: "File";
21
+ readonly import: "Import";
22
+ readonly export: "Export";
23
+ readonly source: "Source";
24
+ readonly text: "Text";
25
+ readonly break: "Break";
26
+ };
8
27
  /**
9
28
  * Canonical schema type strings used by AST schema nodes.
10
29
  *
@@ -168,13 +187,13 @@ declare const mediaTypes: {
168
187
  * const kind: NodeKind = 'Schema'
169
188
  * ```
170
189
  */
171
- type NodeKind = 'Root' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response' | 'FunctionParameter' | 'ParameterGroup' | 'FunctionParameters' | 'Type';
190
+ type NodeKind = 'Input' | 'Output' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response' | 'FunctionParameter' | 'ParameterGroup' | 'FunctionParameters' | 'Type' | 'ParamsType' | 'File' | 'Import' | 'Export' | 'Source' | 'Const' | 'Function' | 'ArrowFunction' | 'Text' | 'Break' | 'Jsx';
172
191
  /**
173
192
  * Base shape shared by all AST nodes.
174
193
  *
175
194
  * @example
176
195
  * ```ts
177
- * const base: BaseNode = { kind: 'Root' }
196
+ * const base: BaseNode = { kind: 'Input' }
178
197
  * ```
179
198
  */
180
199
  type BaseNode = {
@@ -184,21 +203,561 @@ type BaseNode = {
184
203
  kind: NodeKind;
185
204
  };
186
205
  //#endregion
206
+ //#region src/nodes/code.d.ts
207
+ /**
208
+ * JSDoc documentation metadata attached to code declarations.
209
+ */
210
+ type JSDocNode = {
211
+ /**
212
+ * JSDoc comment lines. `undefined` entries are filtered out during rendering.
213
+ * @example ['@description A pet resource', '@deprecated']
214
+ */
215
+ comments?: Array<string | undefined>;
216
+ };
217
+ /**
218
+ * AST node representing a TypeScript `const` declaration.
219
+ *
220
+ * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
221
+ * The `children` prop of the component is represented as `nodes`.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * createConst({ name: 'pet', export: true, asConst: true })
226
+ * // export const pet = ... as const
227
+ * ```
228
+ */
229
+ type ConstNode = BaseNode & {
230
+ /**
231
+ * Node kind.
232
+ */
233
+ kind: 'Const';
234
+ /**
235
+ * Name of the constant declaration.
236
+ */
237
+ name: string;
238
+ /**
239
+ * Whether the declaration should be exported.
240
+ * @default false
241
+ */
242
+ export?: boolean;
243
+ /**
244
+ * Optional explicit type annotation.
245
+ * @example 'Pet'
246
+ */
247
+ type?: string;
248
+ /**
249
+ * JSDoc documentation metadata.
250
+ */
251
+ JSDoc?: JSDocNode;
252
+ /**
253
+ * Whether to append `as const` to the declaration.
254
+ * @default false
255
+ */
256
+ asConst?: boolean;
257
+ /**
258
+ * Child nodes representing the value of the constant (children of the `Const` component).
259
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
260
+ */
261
+ nodes?: Array<CodeNode>;
262
+ };
263
+ /**
264
+ * AST node representing a TypeScript `type` alias declaration.
265
+ *
266
+ * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
267
+ * The `children` prop of the component is represented as `nodes`.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * createType({ name: 'Pet', export: true })
272
+ * // export type Pet = ...
273
+ * ```
274
+ */
275
+ type TypeNode = BaseNode & {
276
+ /**
277
+ * Node kind.
278
+ */
279
+ kind: 'Type';
280
+ /**
281
+ * Name of the type alias.
282
+ */
283
+ name: string;
284
+ /**
285
+ * Whether the declaration should be exported.
286
+ * @default false
287
+ */
288
+ export?: boolean;
289
+ /**
290
+ * JSDoc documentation metadata.
291
+ */
292
+ JSDoc?: JSDocNode;
293
+ /**
294
+ * Child nodes representing the type body (children of the `Type` component).
295
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
296
+ */
297
+ nodes?: Array<CodeNode>;
298
+ };
299
+ /**
300
+ * Convenience alias for {@link TypeNode}.
301
+ * @deprecated Use `TypeNode` directly.
302
+ */
303
+ type TypeDeclarationNode = TypeNode;
304
+ /**
305
+ * AST node representing a TypeScript `function` declaration.
306
+ *
307
+ * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
308
+ * The `children` prop of the component is represented as `nodes`.
309
+ *
310
+ * @example
311
+ * ```ts
312
+ * createFunctionDeclaration({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
313
+ * // export async function getPet(): Promise<Pet> { ... }
314
+ * ```
315
+ */
316
+ type FunctionNode = BaseNode & {
317
+ /**
318
+ * Node kind.
319
+ */
320
+ kind: 'Function';
321
+ /**
322
+ * Name of the function.
323
+ */
324
+ name: string;
325
+ /**
326
+ * Whether the function is a default export.
327
+ * @default false
328
+ */
329
+ default?: boolean;
330
+ /**
331
+ * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
332
+ */
333
+ params?: string;
334
+ /**
335
+ * Whether the function should be exported.
336
+ * @default false
337
+ */
338
+ export?: boolean;
339
+ /**
340
+ * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
341
+ * @default false
342
+ */
343
+ async?: boolean;
344
+ /**
345
+ * TypeScript generic type parameters.
346
+ * @example ['T', 'U extends string']
347
+ */
348
+ generics?: string | string[];
349
+ /**
350
+ * Return type annotation.
351
+ * @example 'Pet'
352
+ */
353
+ returnType?: string;
354
+ /**
355
+ * JSDoc documentation metadata.
356
+ */
357
+ JSDoc?: JSDocNode;
358
+ /**
359
+ * Child nodes representing the function body (children of the `Function` component).
360
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
361
+ */
362
+ nodes?: Array<CodeNode>;
363
+ };
364
+ /**
365
+ * AST node representing a TypeScript arrow function (`const name = () => { ... }`).
366
+ *
367
+ * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
368
+ * The `children` prop of the component is represented as `nodes`.
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * createArrowFunctionDeclaration({ name: 'getPet', export: true, singleLine: true })
373
+ * // export const getPet = () => ...
374
+ * ```
375
+ */
376
+ type ArrowFunctionNode = BaseNode & {
377
+ /**
378
+ * Node kind.
379
+ */
380
+ kind: 'ArrowFunction';
381
+ /**
382
+ * Name of the arrow function (used as the `const` variable name).
383
+ */
384
+ name: string;
385
+ /**
386
+ * Whether the function is a default export.
387
+ * @default false
388
+ */
389
+ default?: boolean;
390
+ /**
391
+ * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
392
+ */
393
+ params?: string;
394
+ /**
395
+ * Whether the arrow function should be exported.
396
+ * @default false
397
+ */
398
+ export?: boolean;
399
+ /**
400
+ * Whether the arrow function is async. When `true`, the return type is wrapped in `Promise<>`.
401
+ * @default false
402
+ */
403
+ async?: boolean;
404
+ /**
405
+ * TypeScript generic type parameters.
406
+ * @example ['T', 'U extends string']
407
+ */
408
+ generics?: string | string[];
409
+ /**
410
+ * Return type annotation.
411
+ * @example 'Pet'
412
+ */
413
+ returnType?: string;
414
+ /**
415
+ * JSDoc documentation metadata.
416
+ */
417
+ JSDoc?: JSDocNode;
418
+ /**
419
+ * Render the arrow function body as a single-line expression.
420
+ * @default false
421
+ */
422
+ singleLine?: boolean;
423
+ /**
424
+ * Child nodes representing the function body (children of the `Function.Arrow` component).
425
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
426
+ */
427
+ nodes?: Array<CodeNode>;
428
+ };
429
+ /**
430
+ * AST node representing a raw text/string fragment in the source output.
431
+ *
432
+ * Used instead of bare `string` values so that all entries in `nodes` arrays
433
+ * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * createText('return fetch(id)')
438
+ * // { kind: 'Text', value: 'return fetch(id)' }
439
+ * ```
440
+ */
441
+ type TextNode = BaseNode & {
442
+ /**
443
+ * Node kind.
444
+ */
445
+ kind: 'Text';
446
+ /**
447
+ * The raw string content.
448
+ */
449
+ value: string;
450
+ };
451
+ /**
452
+ * AST node representing a line break in the source output.
453
+ *
454
+ * Corresponds to `<br/>` in JSX components. When printed, produces an empty
455
+ * string that — joined with `\n` by `printNodes` — creates a blank line
456
+ * between surrounding code nodes.
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * createBreak()
461
+ * // { kind: 'Break' }
462
+ * // prints as '' → blank line when surrounded by other nodes
463
+ * ```
464
+ */
465
+ type BreakNode = BaseNode & {
466
+ /**
467
+ * Node kind.
468
+ */
469
+ kind: 'Break';
470
+ };
471
+ /**
472
+ * AST node representing a raw JSX fragment in the source output.
473
+ *
474
+ * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Use this to embed raw
475
+ * JSX/TSX markup (including fragments `<>…</>`) directly in generated code.
476
+ *
477
+ * @example
478
+ * ```ts
479
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
480
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
481
+ * ```
482
+ */
483
+ type JsxNode = BaseNode & {
484
+ /**
485
+ * Node kind.
486
+ */
487
+ kind: 'Jsx';
488
+ /**
489
+ * The raw JSX string content.
490
+ */
491
+ value: string;
492
+ };
493
+ /**
494
+ * Union of all code-generation AST nodes.
495
+ *
496
+ * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
497
+ * structured children in {@link SourceNode.nodes}.
498
+ */
499
+ type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
500
+ //#endregion
501
+ //#region src/nodes/file.d.ts
502
+ /**
503
+ * Supported file extensions.
504
+ */
505
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
506
+ type ImportName = string | Array<string | {
507
+ propertyName: string;
508
+ name?: string;
509
+ }>;
510
+ /**
511
+ * Represents a language-agnostic import/dependency declaration.
512
+ *
513
+ * @example Named import (TypeScript: `import { useState } from 'react'`)
514
+ * ```ts
515
+ * createImport({ name: ['useState'], path: 'react' })
516
+ * ```
517
+ *
518
+ * @example Default import (TypeScript: `import React from 'react'`)
519
+ * ```ts
520
+ * createImport({ name: 'React', path: 'react' })
521
+ * ```
522
+ *
523
+ * @example Type-only import (TypeScript: `import type { FC } from 'react'`)
524
+ * ```ts
525
+ * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
526
+ * ```
527
+ *
528
+ * @example Namespace import (TypeScript: `import * as React from 'react'`)
529
+ * ```ts
530
+ * createImport({ name: 'React', path: 'react', isNameSpace: true })
531
+ * ```
532
+ */
533
+ type ImportNode = BaseNode & {
534
+ kind: 'Import';
535
+ /**
536
+ * Import name(s) to be used.
537
+ * @example ['useState']
538
+ * @example 'React'
539
+ */
540
+ name: ImportName;
541
+ /**
542
+ * Path for the import.
543
+ * @example '@kubb/core'
544
+ */
545
+ path: string;
546
+ /**
547
+ * Add type-only import prefix.
548
+ * - `true` generates `import type { Type } from './path'`
549
+ * - `false` generates `import { Type } from './path'`
550
+ * @default false
551
+ */
552
+ isTypeOnly?: boolean;
553
+ /**
554
+ * Import entire module as namespace.
555
+ * - `true` generates `import * as Name from './path'`
556
+ * - `false` generates standard import
557
+ * @default false
558
+ */
559
+ isNameSpace?: boolean;
560
+ /**
561
+ * When set, the import path is resolved relative to this root.
562
+ */
563
+ root?: string;
564
+ };
565
+ /**
566
+ * Represents a language-agnostic export/public API declaration.
567
+ *
568
+ * @example Named export (TypeScript: `export { Pets } from './Pets'`)
569
+ * ```ts
570
+ * createExport({ name: ['Pets'], path: './Pets' })
571
+ * ```
572
+ *
573
+ * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
574
+ * ```ts
575
+ * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
576
+ * ```
577
+ *
578
+ * @example Wildcard export (TypeScript: `export * from './utils'`)
579
+ * ```ts
580
+ * createExport({ path: './utils' })
581
+ * ```
582
+ *
583
+ * @example Namespace alias (TypeScript: `export * as utils from './utils'`)
584
+ * ```ts
585
+ * createExport({ name: 'utils', path: './utils', asAlias: true })
586
+ * ```
587
+ */
588
+ type ExportNode = BaseNode & {
589
+ kind: 'Export';
590
+ /**
591
+ * Export name(s) to be used. When omitted, generates a wildcard export.
592
+ * @example ['useState']
593
+ * @example 'React'
594
+ */
595
+ name?: string | Array<string>;
596
+ /**
597
+ * Path for the export.
598
+ * @example '@kubb/core'
599
+ */
600
+ path: string;
601
+ /**
602
+ * Add type-only export prefix.
603
+ * - `true` generates `export type { Type } from './path'`
604
+ * - `false` generates `export { Type } from './path'`
605
+ * @default false
606
+ */
607
+ isTypeOnly?: boolean;
608
+ /**
609
+ * Export as an aliased namespace.
610
+ * - `true` generates `export * as aliasName from './path'`
611
+ * - `false` generates a standard export
612
+ * @default false
613
+ */
614
+ asAlias?: boolean;
615
+ };
616
+ /**
617
+ * Represents a fragment of source code within a file.
618
+ *
619
+ * @example Named exportable source
620
+ * ```ts
621
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
622
+ * ```
623
+ *
624
+ * @example Inline unnamed code block
625
+ * ```ts
626
+ * createSource({ nodes: [createText('const x = 1')] })
627
+ * ```
628
+ */
629
+ type SourceNode = BaseNode & {
630
+ kind: 'Source';
631
+ /**
632
+ * Optional name identifying this source (used for deduplication and barrel generation).
633
+ */
634
+ name?: string;
635
+ /**
636
+ * Mark this source as a type-only export.
637
+ * @default false
638
+ */
639
+ isTypeOnly?: boolean;
640
+ /**
641
+ * Include `export` keyword in the generated source.
642
+ * @default false
643
+ */
644
+ isExportable?: boolean;
645
+ /**
646
+ * Include this source in barrel/index file generation.
647
+ * @default false
648
+ */
649
+ isIndexable?: boolean;
650
+ /**
651
+ * Structured child nodes representing the content of this source fragment, in DOM order.
652
+ * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
653
+ */
654
+ nodes?: Array<CodeNode>;
655
+ };
656
+ /**
657
+ * Represents a fully resolved file in the AST.
658
+ *
659
+ * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
660
+ * and deduplicates `imports`, `exports`, and `sources`.
661
+ *
662
+ * @example
663
+ * ```ts
664
+ * const file = createFile({
665
+ * baseName: 'petStore.ts',
666
+ * path: 'src/models/petStore.ts',
667
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
668
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
669
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
670
+ * })
671
+ * // file.id = SHA256 hash of the path
672
+ * // file.name = 'petStore'
673
+ * // file.extname = '.ts'
674
+ * ```
675
+ */
676
+ type FileNode<TMeta extends object = object> = BaseNode & {
677
+ kind: 'File';
678
+ /**
679
+ * Unique identifier derived from a SHA256 hash of the file path.
680
+ * @default hash
681
+ */
682
+ id: string;
683
+ /**
684
+ * File name without extension, derived from `baseName`.
685
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
686
+ */
687
+ name: string;
688
+ /**
689
+ * File base name, including extension.
690
+ * Based on UNIX basename: `${name}${extname}`
691
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
692
+ */
693
+ baseName: `${string}.${string}`;
694
+ /**
695
+ * Full qualified path to the file.
696
+ */
697
+ path: string;
698
+ /**
699
+ * File extension extracted from `baseName`.
700
+ */
701
+ extname: Extname;
702
+ /**
703
+ * Deduplicated list of source code fragments.
704
+ */
705
+ sources: Array<SourceNode>;
706
+ /**
707
+ * Deduplicated list of import declarations.
708
+ */
709
+ imports: Array<ImportNode>;
710
+ /**
711
+ * Deduplicated list of export declarations.
712
+ */
713
+ exports: Array<ExportNode>;
714
+ /**
715
+ * Optional metadata attached to this file (used by plugins for barrel generation etc.).
716
+ */
717
+ meta?: TMeta;
718
+ /**
719
+ * Optional banner prepended to the generated file content.
720
+ */
721
+ banner?: string;
722
+ /**
723
+ * Optional footer appended to the generated file content.
724
+ */
725
+ footer?: string;
726
+ };
727
+ //#endregion
187
728
  //#region src/nodes/function.d.ts
188
729
  /**
189
- * AST node representing a language-agnostic type expression produced during parameter resolution.
190
- * Each language printer renders the variant into its own syntax.
730
+ * AST node representing a language-agnostic type expression used as a function parameter
731
+ * type annotation. Each language printer renders the variant into its own syntax.
191
732
  *
192
733
  * - `struct` — an inline anonymous type grouping named fields.
193
- * TypeScript renders as `{ petId: string; name?: string }`, Python as a `TypedDict` reference.
734
+ * TypeScript renders as `{ petId: string; name?: string }`.
194
735
  * - `member` — a single named field accessed from a named group type.
195
- * TypeScript renders as `PathParams['petId']`, C# as `PathParams.PetId`.
736
+ * TypeScript renders as `PathParams['petId']`.
737
+ *
738
+ * @example Reference variant
739
+ * ```ts
740
+ * createParamsType({ variant: 'reference', name: 'QueryParams' })
741
+ * // QueryParams
742
+ * ```
743
+ *
744
+ * @example Struct variant
745
+ * ```ts
746
+ * createParamsType({ variant: 'struct', properties: [{ name: 'petId', optional: false, type: createParamsType({ variant: 'reference', name: 'string' }) }] })
747
+ * // { petId: string }
748
+ * ```
749
+ *
750
+ * @example Member variant
751
+ * ```ts
752
+ * createParamsType({ variant: 'member', base: 'PathParams', key: 'petId' })
753
+ * // PathParams['petId']
754
+ * ```
196
755
  */
197
- type TypeNode = BaseNode & {
756
+ type ParamsTypeNode = BaseNode & {
198
757
  /**
199
758
  * Node kind.
200
759
  */
201
- kind: 'Type';
760
+ kind: 'ParamsType';
202
761
  } & ({
203
762
  /**
204
763
  * Reference variant — a plain type name or identifier.
@@ -221,7 +780,7 @@ type TypeNode = BaseNode & {
221
780
  properties: Array<{
222
781
  name: string;
223
782
  optional: boolean;
224
- type: TypeNode;
783
+ type: ParamsTypeNode;
225
784
  }>;
226
785
  } | {
227
786
  /**
@@ -263,19 +822,19 @@ type FunctionParameterNode = BaseNode & {
263
822
  */
264
823
  name: string;
265
824
  /**
266
- * Type annotation as a structured {@link TypeNode}.
825
+ * Type annotation as a structured {@link ParamsTypeNode}.
267
826
  * Omit for untyped output.
268
827
  *
269
828
  * @example Reference type node
270
- * `{ kind: 'Type', variant: 'reference', name: 'string' }` → `petId: string`
829
+ * `{ kind: 'ParamsType', variant: 'reference', name: 'string' }` → `petId: string`
271
830
  *
272
831
  * @example Struct type node
273
- * `{ kind: 'Type', variant: 'struct', properties: [...] }` → `{ key: Type; other?: OtherType }`
832
+ * `{ kind: 'ParamsType', variant: 'struct', properties: [...] }` → `{ key: Type; other?: OtherType }`
274
833
  *
275
834
  * @example Member type node
276
- * `{ kind: 'Type', variant: 'member', base: 'PathParams', key: 'petId' }` → `PathParams['petId']`
835
+ * `{ kind: 'ParamsType', variant: 'member', base: 'PathParams', key: 'petId' }` → `PathParams['petId']`
277
836
  */
278
- type?: TypeNode;
837
+ type?: ParamsTypeNode;
279
838
  /**
280
839
  * When `true` the parameter is emitted as a rest parameter.
281
840
  *
@@ -336,7 +895,7 @@ type ParameterGroupNode = BaseNode & {
336
895
  * Optional explicit type annotation for the whole group.
337
896
  * When absent, printers auto-compute it from `properties`.
338
897
  */
339
- type?: TypeNode;
898
+ type?: ParamsTypeNode;
340
899
  /**
341
900
  * When `true`, `properties` are emitted as individual top-level parameters instead of
342
901
  * being wrapped in a single grouped construct.
@@ -378,13 +937,13 @@ type FunctionParametersNode = BaseNode & {
378
937
  params: ReadonlyArray<FunctionParameterNode | ParameterGroupNode>;
379
938
  };
380
939
  /**
381
- * The four function-signature AST node variants.
940
+ * Union of all function-parameter AST node variants used by the function-parameter printer.
382
941
  */
383
- type FunctionNode = FunctionParameterNode | ParameterGroupNode | FunctionParametersNode | TypeNode;
942
+ type FunctionParamNode = FunctionParameterNode | ParameterGroupNode | FunctionParametersNode | ParamsTypeNode;
384
943
  /**
385
- * Handler map keys — one per `FunctionNode` kind.
944
+ * Handler map keys — one per `FunctionParamNode` kind.
386
945
  */
387
- type FunctionNodeType = 'functionParameter' | 'parameterGroup' | 'functionParameters' | 'type';
946
+ type FunctionNodeType = 'functionParameter' | 'parameterGroup' | 'functionParameters' | 'paramsType';
388
947
  //#endregion
389
948
  //#region src/nodes/property.d.ts
390
949
  /**
@@ -1208,6 +1767,31 @@ type OperationNode = BaseNode & {
1208
1767
  responses: Array<ResponseNode>;
1209
1768
  };
1210
1769
  //#endregion
1770
+ //#region src/nodes/output.d.ts
1771
+ /**
1772
+ * Output AST node that groups all generated file output for one API document.
1773
+ *
1774
+ * Produced by generators and consumed by the build pipeline to write files.
1775
+ *
1776
+ * @example
1777
+ * ```ts
1778
+ * const output: OutputNode = {
1779
+ * kind: 'Output',
1780
+ * files: [],
1781
+ * }
1782
+ * ```
1783
+ */
1784
+ type OutputNode = BaseNode & {
1785
+ /**
1786
+ * Node kind.
1787
+ */
1788
+ kind: 'Output';
1789
+ /**
1790
+ * Generated file nodes.
1791
+ */
1792
+ files: Array<FileNode>;
1793
+ };
1794
+ //#endregion
1211
1795
  //#region src/nodes/root.d.ts
1212
1796
  /**
1213
1797
  * Basic metadata for an API document.
@@ -1215,10 +1799,10 @@ type OperationNode = BaseNode & {
1215
1799
  *
1216
1800
  * @example
1217
1801
  * ```ts
1218
- * const meta: RootMeta = { title: 'Pet API', version: '1.0.0' }
1802
+ * const meta: InputMeta = { title: 'Pet API', version: '1.0.0' }
1219
1803
  * ```
1220
1804
  */
1221
- type RootMeta = {
1805
+ type InputMeta = {
1222
1806
  /**
1223
1807
  * API title (from `info.title` in OAS/AsyncAPI).
1224
1808
  */
@@ -1238,22 +1822,23 @@ type RootMeta = {
1238
1822
  baseURL?: string;
1239
1823
  };
1240
1824
  /**
1241
- * Root AST node that contains all schemas and operations for one API document.
1825
+ * Input AST node that contains all schemas and operations for one API document.
1826
+ * Produced by the adapter and consumed by all Kubb plugins.
1242
1827
  *
1243
1828
  * @example
1244
1829
  * ```ts
1245
- * const root: RootNode = {
1246
- * kind: 'Root',
1830
+ * const input: InputNode = {
1831
+ * kind: 'Input',
1247
1832
  * schemas: [],
1248
1833
  * operations: [],
1249
1834
  * }
1250
1835
  * ```
1251
1836
  */
1252
- type RootNode = BaseNode & {
1837
+ type InputNode = BaseNode & {
1253
1838
  /**
1254
1839
  * Node kind.
1255
1840
  */
1256
- kind: 'Root';
1841
+ kind: 'Input';
1257
1842
  /**
1258
1843
  * All schema nodes in the document.
1259
1844
  */
@@ -1265,7 +1850,7 @@ type RootNode = BaseNode & {
1265
1850
  /**
1266
1851
  * Optional document metadata populated by the adapter.
1267
1852
  */
1268
- meta?: RootMeta;
1853
+ meta?: InputMeta;
1269
1854
  };
1270
1855
  //#endregion
1271
1856
  //#region src/nodes/index.d.ts
@@ -1278,15 +1863,17 @@ type RootNode = BaseNode & {
1278
1863
  * ```ts
1279
1864
  * function getKind(node: Node): string {
1280
1865
  * switch (node.kind) {
1281
- * case 'Root':
1282
- * return 'root'
1866
+ * case 'Input':
1867
+ * return 'input'
1868
+ * case 'Output':
1869
+ * return 'output'
1283
1870
  * default:
1284
1871
  * return 'other'
1285
1872
  * }
1286
1873
  * }
1287
1874
  * ```
1288
1875
  */
1289
- type Node = RootNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | FunctionNode;
1876
+ type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | FunctionParamNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | ParamsTypeNode | FunctionNode | ArrowFunctionNode;
1290
1877
  //#endregion
1291
1878
  //#region src/infer.d.ts
1292
1879
  /**
@@ -1458,21 +2045,36 @@ type CreateSchemaOutput<T extends CreateSchemaInput> = InferSchemaNode<T> & {
1458
2045
  kind: 'Schema';
1459
2046
  };
1460
2047
  /**
1461
- * Creates a `RootNode` with stable defaults for `schemas` and `operations`.
2048
+ * Creates an `InputNode` with stable defaults for `schemas` and `operations`.
1462
2049
  *
1463
2050
  * @example
1464
2051
  * ```ts
1465
- * const root = createRoot()
1466
- * // { kind: 'Root', schemas: [], operations: [] }
2052
+ * const input = createInput()
2053
+ * // { kind: 'Input', schemas: [], operations: [] }
1467
2054
  * ```
1468
2055
  *
1469
2056
  * @example
1470
2057
  * ```ts
1471
- * const root = createRoot({ schemas: [petSchema] })
2058
+ * const input = createInput({ schemas: [petSchema] })
1472
2059
  * // keeps default operations: []
1473
2060
  * ```
1474
2061
  */
1475
- declare function createRoot(overrides?: Partial<Omit<RootNode, 'kind'>>): RootNode;
2062
+ declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
2063
+ /**
2064
+ * Creates an `OutputNode` with a stable default for `files`.
2065
+ *
2066
+ * @example
2067
+ * ```ts
2068
+ * const output = createOutput()
2069
+ * // { kind: 'Output', files: [] }
2070
+ * ```
2071
+ *
2072
+ * @example
2073
+ * ```ts
2074
+ * const output = createOutput({ files: [petFile] })
2075
+ * ```
2076
+ */
2077
+ declare function createOutput(overrides?: Partial<Omit<OutputNode, 'kind'>>): OutputNode;
1476
2078
  /**
1477
2079
  * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.
1478
2080
  *
@@ -1531,6 +2133,7 @@ declare function createOperation(props: Pick<OperationNode, 'operationId' | 'met
1531
2133
  */
1532
2134
  declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
1533
2135
  declare function createSchema(props: CreateSchemaInput): SchemaNode;
2136
+ type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>;
1534
2137
  /**
1535
2138
  * Creates a `PropertyNode`.
1536
2139
  *
@@ -1556,7 +2159,7 @@ declare function createSchema(props: CreateSchemaInput): SchemaNode;
1556
2159
  * // required=true, no optional/nullish
1557
2160
  * ```
1558
2161
  */
1559
- declare function createProperty(props: Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>): PropertyNode;
2162
+ declare function createProperty(props: UserPropertyNode): PropertyNode;
1560
2163
  /**
1561
2164
  * Creates a `ParameterNode`.
1562
2165
  *
@@ -1604,25 +2207,25 @@ declare function createResponse(props: Pick<ResponseNode, 'statusCode' | 'schema
1604
2207
  *
1605
2208
  * @example Required typed param
1606
2209
  * ```ts
1607
- * createFunctionParameter({ name: 'petId', type: createTypeNode({ variant: 'reference', name: 'string' }) })
2210
+ * createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }) })
1608
2211
  * // → petId: string
1609
2212
  * ```
1610
2213
  *
1611
2214
  * @example Optional param
1612
2215
  * ```ts
1613
- * createFunctionParameter({ name: 'params', type: createTypeNode({ variant: 'reference', name: 'QueryParams' }), optional: true })
2216
+ * createFunctionParameter({ name: 'params', type: createParamsType({ variant: 'reference', name: 'QueryParams' }), optional: true })
1614
2217
  * // → params?: QueryParams
1615
2218
  * ```
1616
2219
  *
1617
2220
  * @example Param with default (implicitly optional; cannot combine with `optional: true`)
1618
2221
  * ```ts
1619
- * createFunctionParameter({ name: 'config', type: createTypeNode({ variant: 'reference', name: 'RequestConfig' }), default: '{}' })
2222
+ * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), default: '{}' })
1620
2223
  * // → config: RequestConfig = {}
1621
2224
  * ```
1622
2225
  */
1623
2226
  declare function createFunctionParameter(props: {
1624
2227
  name: string;
1625
- type?: TypeNode;
2228
+ type?: ParamsTypeNode;
1626
2229
  rest?: boolean;
1627
2230
  } & ({
1628
2231
  optional: true;
@@ -1640,20 +2243,20 @@ declare function createFunctionParameter(props: {
1640
2243
  *
1641
2244
  * @example Reference type (TypeScript: `QueryParams`)
1642
2245
  * ```ts
1643
- * createTypeNode({ variant: 'reference', name: 'QueryParams' })
2246
+ * createParamsType({ variant: 'reference', name: 'QueryParams' })
1644
2247
  * ```
1645
2248
  *
1646
2249
  * @example Struct type (TypeScript: `{ petId: string }`)
1647
2250
  * ```ts
1648
- * createTypeNode({ variant: 'struct', properties: [{ name: 'petId', optional: false, type: createTypeNode({ variant: 'reference', name: 'string' }) }] })
2251
+ * createParamsType({ variant: 'struct', properties: [{ name: 'petId', optional: false, type: createParamsType({ variant: 'reference', name: 'string' }) }] })
1649
2252
  * ```
1650
2253
  *
1651
2254
  * @example Member type (TypeScript: `DeletePetPathParams['petId']`)
1652
2255
  * ```ts
1653
- * createTypeNode({ variant: 'member', base: 'DeletePetPathParams', key: 'petId' })
2256
+ * createParamsType({ variant: 'member', base: 'DeletePetPathParams', key: 'petId' })
1654
2257
  * ```
1655
2258
  */
1656
- declare function createTypeNode(props: {
2259
+ declare function createParamsType(props: {
1657
2260
  variant: 'reference';
1658
2261
  name: string;
1659
2262
  } | {
@@ -1661,13 +2264,13 @@ declare function createTypeNode(props: {
1661
2264
  properties: Array<{
1662
2265
  name: string;
1663
2266
  optional: boolean;
1664
- type: TypeNode;
2267
+ type: ParamsTypeNode;
1665
2268
  }>;
1666
2269
  } | {
1667
2270
  variant: 'member';
1668
2271
  base: string;
1669
2272
  key: string;
1670
- }): TypeNode;
2273
+ }): ParamsTypeNode;
1671
2274
  /**
1672
2275
  * Creates a `ParameterGroupNode` representing a group of related parameters treated as a unit.
1673
2276
  *
@@ -1675,8 +2278,8 @@ declare function createTypeNode(props: {
1675
2278
  * ```ts
1676
2279
  * createParameterGroup({
1677
2280
  * properties: [
1678
- * createFunctionParameter({ name: 'id', type: createTypeNode({ variant: 'reference', name: 'string' }), optional: false }),
1679
- * createFunctionParameter({ name: 'name', type: createTypeNode({ variant: 'reference', name: 'string' }), optional: true }),
2281
+ * createFunctionParameter({ name: 'id', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false }),
2282
+ * createFunctionParameter({ name: 'name', type: createParamsType({ variant: 'reference', name: 'string' }), optional: true }),
1680
2283
  * ],
1681
2284
  * default: '{}',
1682
2285
  * })
@@ -1687,7 +2290,7 @@ declare function createTypeNode(props: {
1687
2290
  * @example Inline (spread) — children emitted as individual top-level parameters
1688
2291
  * ```ts
1689
2292
  * createParameterGroup({
1690
- * properties: [createFunctionParameter({ name: 'petId', type: createTypeNode({ variant: 'reference', name: 'string' }), optional: false })],
2293
+ * properties: [createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false })],
1691
2294
  * inline: true,
1692
2295
  * })
1693
2296
  * // declaration → petId: string
@@ -1702,8 +2305,8 @@ declare function createParameterGroup(props: Pick<ParameterGroupNode, 'propertie
1702
2305
  * ```ts
1703
2306
  * createFunctionParameters({
1704
2307
  * params: [
1705
- * createFunctionParameter({ name: 'petId', type: createTypeNode({ variant: 'reference', name: 'string' }), optional: false }),
1706
- * createFunctionParameter({ name: 'config', type: createTypeNode({ variant: 'reference', name: 'RequestConfig' }), optional: false, default: '{}' }),
2308
+ * createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false }),
2309
+ * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), optional: false, default: '{}' }),
1707
2310
  * ],
1708
2311
  * })
1709
2312
  * ```
@@ -1715,6 +2318,231 @@ declare function createParameterGroup(props: Pick<ParameterGroupNode, 'propertie
1715
2318
  * ```
1716
2319
  */
1717
2320
  declare function createFunctionParameters(props?: Partial<Omit<FunctionParametersNode, 'kind'>>): FunctionParametersNode;
2321
+ /**
2322
+ * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
2323
+ *
2324
+ * @example Named import
2325
+ * ```ts
2326
+ * createImport({ name: ['useState'], path: 'react' })
2327
+ * // import { useState } from 'react'
2328
+ * ```
2329
+ *
2330
+ * @example Type-only import
2331
+ * ```ts
2332
+ * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
2333
+ * // import type { FC } from 'react'
2334
+ * ```
2335
+ */
2336
+ declare function createImport(props: Omit<ImportNode, 'kind'>): ImportNode;
2337
+ /**
2338
+ * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
2339
+ *
2340
+ * @example Named export
2341
+ * ```ts
2342
+ * createExport({ name: ['Pet'], path: './Pet' })
2343
+ * // export { Pet } from './Pet'
2344
+ * ```
2345
+ *
2346
+ * @example Wildcard export
2347
+ * ```ts
2348
+ * createExport({ path: './utils' })
2349
+ * // export * from './utils'
2350
+ * ```
2351
+ */
2352
+ declare function createExport(props: Omit<ExportNode, 'kind'>): ExportNode;
2353
+ /**
2354
+ * Creates a `SourceNode` representing a fragment of source code within a file.
2355
+ *
2356
+ * @example
2357
+ * ```ts
2358
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
2359
+ * ```
2360
+ */
2361
+ declare function createSource(props: Omit<SourceNode, 'kind'>): SourceNode;
2362
+ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> & Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>;
2363
+ /**
2364
+ * Creates a fully resolved `FileNode` from a file input descriptor.
2365
+ *
2366
+ * Computes:
2367
+ * - `id` — SHA256 hash of the file path
2368
+ * - `name` — `baseName` without extension
2369
+ * - `extname` — extension extracted from `baseName`
2370
+ *
2371
+ * Deduplicates:
2372
+ * - `sources` via `combineSources`
2373
+ * - `exports` via `combineExports`
2374
+ * - `imports` via `combineImports` (also filters unused imports)
2375
+ *
2376
+ * @throws {Error} when `baseName` has no extension.
2377
+ *
2378
+ * @example
2379
+ * ```ts
2380
+ * const file = createFile({
2381
+ * baseName: 'petStore.ts',
2382
+ * path: 'src/models/petStore.ts',
2383
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
2384
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
2385
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
2386
+ * })
2387
+ * // file.id = SHA256 hash of 'src/models/petStore.ts'
2388
+ * // file.name = 'petStore'
2389
+ * // file.extname = '.ts'
2390
+ * ```
2391
+ */
2392
+ declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
2393
+ /**
2394
+ * Creates a `ConstNode` representing a TypeScript `const` declaration.
2395
+ *
2396
+ * Mirrors the `Const` component from `@kubb/renderer-jsx`.
2397
+ * The component's `children` are represented as `nodes`.
2398
+ *
2399
+ * @example Simple constant
2400
+ * ```ts
2401
+ * createConst({ name: 'pet' })
2402
+ * // const pet = ...
2403
+ * ```
2404
+ *
2405
+ * @example Exported constant with type and `as const`
2406
+ * ```ts
2407
+ * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
2408
+ * // export const pets: Pet[] = ... as const
2409
+ * ```
2410
+ *
2411
+ * @example With JSDoc and child nodes
2412
+ * ```ts
2413
+ * createConst({
2414
+ * name: 'config',
2415
+ * export: true,
2416
+ * JSDoc: { comments: ['@description App configuration'] },
2417
+ * nodes: [],
2418
+ * })
2419
+ * ```
2420
+ */
2421
+ declare function createConst(props: Omit<ConstNode, 'kind'>): ConstNode;
2422
+ /**
2423
+ * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
2424
+ *
2425
+ * Mirrors the `Type` component from `@kubb/renderer-jsx`.
2426
+ * The component's `children` are represented as `nodes`.
2427
+ *
2428
+ * @example Simple type alias
2429
+ * ```ts
2430
+ * createType({ name: 'Pet' })
2431
+ * // type Pet = ...
2432
+ * ```
2433
+ *
2434
+ * @example Exported type with JSDoc
2435
+ * ```ts
2436
+ * createType({
2437
+ * name: 'PetStatus',
2438
+ * export: true,
2439
+ * JSDoc: { comments: ['@description Status of a pet'] },
2440
+ * })
2441
+ * // export type PetStatus = ...
2442
+ * ```
2443
+ */
2444
+ declare function createType(props: Omit<TypeNode, 'kind'>): TypeNode;
2445
+ /**
2446
+ * Creates a `FunctionNode` representing a TypeScript `function` declaration.
2447
+ *
2448
+ * Mirrors the `Function` component from `@kubb/renderer-jsx`.
2449
+ * The component's `children` are represented as `nodes`.
2450
+ *
2451
+ * @example Simple function
2452
+ * ```ts
2453
+ * createFunction({ name: 'getPet' })
2454
+ * // function getPet() { ... }
2455
+ * ```
2456
+ *
2457
+ * @example Exported async function with return type
2458
+ * ```ts
2459
+ * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
2460
+ * // export async function fetchPet(): Promise<Pet> { ... }
2461
+ * ```
2462
+ *
2463
+ * @example Function with generics and params
2464
+ * ```ts
2465
+ * createFunction({
2466
+ * name: 'identity',
2467
+ * export: true,
2468
+ * generics: ['T'],
2469
+ * params: 'value: T',
2470
+ * returnType: 'T',
2471
+ * })
2472
+ * // export function identity<T>(value: T): T { ... }
2473
+ * ```
2474
+ */
2475
+ declare function createFunction(props: Omit<FunctionNode, 'kind'>): FunctionNode;
2476
+ /**
2477
+ * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
2478
+ *
2479
+ * Mirrors the `Function.Arrow` component from `@kubb/renderer-jsx`.
2480
+ * The component's `children` are represented as `nodes`.
2481
+ *
2482
+ * @example Simple arrow function
2483
+ * ```ts
2484
+ * createArrowFunction({ name: 'getPet' })
2485
+ * // const getPet = () => { ... }
2486
+ * ```
2487
+ *
2488
+ * @example Single-line exported arrow function
2489
+ * ```ts
2490
+ * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
2491
+ * // export const double = (n: number) => ...
2492
+ * ```
2493
+ *
2494
+ * @example Async arrow function with generics
2495
+ * ```ts
2496
+ * createArrowFunction({
2497
+ * name: 'fetchPet',
2498
+ * export: true,
2499
+ * async: true,
2500
+ * generics: ['T'],
2501
+ * params: 'id: string',
2502
+ * returnType: 'T',
2503
+ * })
2504
+ * // export const fetchPet = async <T>(id: string): Promise<T> => { ... }
2505
+ * ```
2506
+ */
2507
+ declare function createArrowFunction(props: Omit<ArrowFunctionNode, 'kind'>): ArrowFunctionNode;
2508
+ /**
2509
+ * Creates a {@link TextNode} representing a raw string fragment in the source output.
2510
+ *
2511
+ * Use this instead of bare strings when building `nodes` arrays so that every
2512
+ * entry in the array is a typed {@link CodeNode}.
2513
+ *
2514
+ * @example
2515
+ * ```ts
2516
+ * createText('return fetch(id)')
2517
+ * // { kind: 'Text', value: 'return fetch(id)' }
2518
+ * ```
2519
+ */
2520
+ declare function createText(value: string): TextNode;
2521
+ /**
2522
+ * Creates a {@link BreakNode} representing a line break in the source output.
2523
+ *
2524
+ * Corresponds to `<br/>` in JSX components. Prints as an empty string which,
2525
+ * when joined with `\n` by `printNodes`, produces a blank line.
2526
+ *
2527
+ * @example
2528
+ * ```ts
2529
+ * createBreak()
2530
+ * // { kind: 'Break' }
2531
+ * ```
2532
+ */
2533
+ declare function createBreak(): BreakNode;
2534
+ /**
2535
+ * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
2536
+ *
2537
+ * Use this to embed JSX markup (including fragments `<>…</>`) directly in generated code.
2538
+ *
2539
+ * @example
2540
+ * ```ts
2541
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
2542
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
2543
+ * ```
2544
+ */
2545
+ declare function createJsx(value: string): JsxNode;
1718
2546
  //#endregion
1719
2547
  //#region src/printer.d.ts
1720
2548
  /**
@@ -1936,7 +2764,7 @@ declare function extractRefName(ref: string): string;
1936
2764
  *
1937
2765
  * `ParentOf` uses this map to find parent types.
1938
2766
  */
1939
- type ParentNodeMap = [[RootNode, undefined], [OperationNode, RootNode], [SchemaNode, RootNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode], [PropertyNode, SchemaNode], [ParameterNode, OperationNode], [ResponseNode, OperationNode]];
2767
+ type ParentNodeMap = [[InputNode, undefined], [OutputNode, undefined], [OperationNode, InputNode], [SchemaNode, InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode], [PropertyNode, SchemaNode], [ParameterNode, OperationNode], [ResponseNode, OperationNode]];
1940
2768
  /**
1941
2769
  * Resolves the parent node type for a given AST node type.
1942
2770
  *
@@ -1945,7 +2773,7 @@ type ParentNodeMap = [[RootNode, undefined], [OperationNode, RootNode], [SchemaN
1945
2773
  *
1946
2774
  * @example
1947
2775
  * ```ts
1948
- * type RootParent = ParentOf<RootNode>
2776
+ * type InputParent = ParentOf<InputNode>
1949
2777
  * // undefined
1950
2778
  * ```
1951
2779
  *
@@ -1958,7 +2786,7 @@ type ParentNodeMap = [[RootNode, undefined], [OperationNode, RootNode], [SchemaN
1958
2786
  * @example
1959
2787
  * ```ts
1960
2788
  * type SchemaParent = ParentOf<SchemaNode>
1961
- * // RootNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode
2789
+ * // InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode
1962
2790
  * ```
1963
2791
  */
1964
2792
  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;
@@ -1978,7 +2806,7 @@ type ParentOf<T extends Node, TEntries extends ReadonlyArray<[Node, unknown]> =
1978
2806
  type VisitorContext<T extends Node = Node> = {
1979
2807
  /**
1980
2808
  * Parent node of the currently visited node.
1981
- * For `RootNode`, this is `undefined`.
2809
+ * For `InputNode`, this is `undefined`.
1982
2810
  */
1983
2811
  parent?: ParentOf<T>;
1984
2812
  };
@@ -1995,7 +2823,8 @@ type VisitorContext<T extends Node = Node> = {
1995
2823
  * ```
1996
2824
  */
1997
2825
  type Visitor = {
1998
- root?(node: RootNode, context: VisitorContext<RootNode>): void | RootNode;
2826
+ input?(node: InputNode, context: VisitorContext<InputNode>): void | InputNode;
2827
+ output?(node: OutputNode, context: VisitorContext<OutputNode>): void | OutputNode;
1999
2828
  operation?(node: OperationNode, context: VisitorContext<OperationNode>): void | OperationNode;
2000
2829
  schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): void | SchemaNode;
2001
2830
  property?(node: PropertyNode, context: VisitorContext<PropertyNode>): void | PropertyNode;
@@ -2019,7 +2848,8 @@ type MaybePromise<T> = T | Promise<T>;
2019
2848
  * ```
2020
2849
  */
2021
2850
  type AsyncVisitor = {
2022
- root?(node: RootNode, context: VisitorContext<RootNode>): MaybePromise<void | RootNode>;
2851
+ input?(node: InputNode, context: VisitorContext<InputNode>): MaybePromise<void | InputNode>;
2852
+ output?(node: OutputNode, context: VisitorContext<OutputNode>): MaybePromise<void | OutputNode>;
2023
2853
  operation?(node: OperationNode, context: VisitorContext<OperationNode>): MaybePromise<void | OperationNode>;
2024
2854
  schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): MaybePromise<void | SchemaNode>;
2025
2855
  property?(node: PropertyNode, context: VisitorContext<PropertyNode>): MaybePromise<void | PropertyNode>;
@@ -2039,7 +2869,8 @@ type AsyncVisitor = {
2039
2869
  * ```
2040
2870
  */
2041
2871
  type CollectVisitor<T> = {
2042
- root?(node: RootNode, context: VisitorContext<RootNode>): T | undefined;
2872
+ input?(node: InputNode, context: VisitorContext<InputNode>): T | undefined;
2873
+ output?(node: OutputNode, context: VisitorContext<OutputNode>): T | undefined;
2043
2874
  operation?(node: OperationNode, context: VisitorContext<OperationNode>): T | undefined;
2044
2875
  schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): T | undefined;
2045
2876
  property?(node: PropertyNode, context: VisitorContext<PropertyNode>): T | undefined;
@@ -2152,7 +2983,8 @@ declare function walk(node: Node, options: WalkOptions): Promise<void>;
2152
2983
  * const next = transform(root, { depth: 'shallow', root: (node) => node })
2153
2984
  * ```
2154
2985
  */
2155
- declare function transform(node: RootNode, options: TransformOptions): RootNode;
2986
+ declare function transform(node: InputNode, options: TransformOptions): InputNode;
2987
+ declare function transform(node: OutputNode, options: TransformOptions): OutputNode;
2156
2988
  declare function transform(node: OperationNode, options: TransformOptions): OperationNode;
2157
2989
  declare function transform(node: SchemaNode, options: TransformOptions): SchemaNode;
2158
2990
  declare function transform(node: PropertyNode, options: TransformOptions): PropertyNode;
@@ -2196,5 +3028,5 @@ declare function composeTransformers(...visitors: Array<Visitor>): Visitor;
2196
3028
  */
2197
3029
  declare function collect<T>(node: Node, options: CollectOptions<T>): Array<T>;
2198
3030
  //#endregion
2199
- export { IntersectionSchemaNode as $, createTypeNode as A, schemaTypes as At, ResponseNode as B, createOperation as C, BaseNode as Ct, createResponse as D, httpMethods as Dt, createProperty as E, VisitorDepth as Et, Node as F, ParameterNode as G, MediaType as H, RootMeta as I, DateSchemaNode as J, ArraySchemaNode as K, RootNode as L, InferSchema as M, InferSchemaNode as N, createRoot as O, isScalarPrimitive as Ot, ParserOptions as P, FormatStringSchemaNode as Q, HttpMethod as R, createFunctionParameters as S, TypeNode as St, createParameterGroup as T, ScalarPrimitive as Tt, StatusCode as U, HttpStatusCode as V, ParameterLocation as W, EnumSchemaNode as X, DatetimeSchemaNode as Y, EnumValueNode as Z, PrinterPartial as _, FunctionNode as _t, TransformOptions as a, RefSchemaNode as at, DistributiveOmit as b, FunctionParametersNode as bt, WalkOptions as c, SchemaNode as ct, transform as d, SpecialSchemaType as dt, Ipv4SchemaNode as et, walk as f, StringSchemaNode as ft, PrinterFactoryOptions as g, PropertyNode as gt, Printer as h, UrlSchemaNode as ht, ParentOf as i, PrimitiveSchemaType as it, syncOptionality as j, createSchema as k, mediaTypes as kt, collect as l, SchemaNodeByType as lt, extractRefName as m, UnionSchemaNode as mt, CollectOptions as n, NumberSchemaNode as nt, Visitor as o, ScalarSchemaNode as ot, RefMap as p, TimeSchemaNode as pt, ComplexSchemaType as q, CollectVisitor as r, ObjectSchemaNode as rt, VisitorContext as s, ScalarSchemaType as st, AsyncVisitor as t, Ipv6SchemaNode as tt, composeTransformers as u, SchemaType as ut, createPrinterFactory as v, FunctionNodeType as vt, createParameter as w, NodeKind as wt, createFunctionParameter as x, ParameterGroupNode as xt, definePrinter as y, FunctionParameterNode as yt, OperationNode as z };
2200
- //# sourceMappingURL=visitor-z-5U8NoF.d.ts.map
3031
+ export { ResponseNode as $, VisitorDepth as $t, createInput as A, FunctionNodeType as At, createSource as B, ArrowFunctionNode as Bt, createConst as C, SchemaType as Ct, createFunctionParameter as D, UnionSchemaNode as Dt, createFunction as E, TimeSchemaNode as Et, createParameterGroup as F, ParamsTypeNode as Ft, InferSchemaNode as G, JSDocNode as Gt, createType as H, CodeNode as Ht, createParamsType as I, ExportNode as It, InputMeta as J, TypeDeclarationNode as Jt, ParserOptions as K, JsxNode as Kt, createProperty as L, FileNode as Lt, createOperation as M, FunctionParameterNode as Mt, createOutput as N, FunctionParametersNode as Nt, createFunctionParameters as O, UrlSchemaNode as Ot, createParameter as P, ParameterGroupNode as Pt, OperationNode as Q, ScalarPrimitive as Qt, createResponse as R, ImportNode as Rt, createBreak as S, SchemaNodeByType as St, createFile as T, StringSchemaNode as Tt, syncOptionality as U, ConstNode as Ut, createText as V, BreakNode as Vt, InferSchema as W, FunctionNode as Wt, OutputNode as X, BaseNode as Xt, InputNode as Y, TypeNode as Yt, HttpMethod as Z, NodeKind as Zt, PrinterPartial as _, PrimitiveSchemaType as _t, TransformOptions as a, ArraySchemaNode as at, DistributiveOmit as b, ScalarSchemaType as bt, WalkOptions as c, DatetimeSchemaNode as ct, transform as d, FormatStringSchemaNode as dt, httpMethods as en, HttpStatusCode as et, walk as f, IntersectionSchemaNode as ft, PrinterFactoryOptions as g, ObjectSchemaNode as gt, Printer as h, NumberSchemaNode as ht, ParentOf as i, schemaTypes as in, ParameterNode as it, createJsx as j, FunctionParamNode as jt, createImport as k, PropertyNode as kt, collect as l, EnumSchemaNode as lt, extractRefName as m, Ipv6SchemaNode as mt, CollectOptions as n, mediaTypes as nn, StatusCode as nt, Visitor as o, ComplexSchemaType as ot, RefMap as p, Ipv4SchemaNode as pt, Node as q, TextNode as qt, CollectVisitor as r, nodeKinds as rn, ParameterLocation as rt, VisitorContext as s, DateSchemaNode as st, AsyncVisitor as t, isScalarPrimitive as tn, MediaType as tt, composeTransformers as u, EnumValueNode as ut, createPrinterFactory as v, RefSchemaNode as vt, createExport as w, SpecialSchemaType as wt, createArrowFunction as x, SchemaNode as xt, definePrinter as y, ScalarSchemaNode as yt, createSchema as z, SourceNode as zt };
3032
+ //# sourceMappingURL=visitor-CJMIoAE3.d.ts.map