@kubb/ast 5.0.0-beta.6 → 5.0.0-beta.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +51 -27
  3. package/dist/chunk-CNktS9qV.js +17 -0
  4. package/dist/defineMacro-BLIR6k-j.d.ts +475 -0
  5. package/dist/defineMacro-BTXvS8nI.js +106 -0
  6. package/dist/defineMacro-BTXvS8nI.js.map +1 -0
  7. package/dist/defineMacro-Bv9R_9a2.cjs +123 -0
  8. package/dist/defineMacro-Bv9R_9a2.cjs.map +1 -0
  9. package/dist/extractStringsFromNodes-Cja-xxx5.js +29 -0
  10. package/dist/extractStringsFromNodes-Cja-xxx5.js.map +1 -0
  11. package/dist/extractStringsFromNodes-DKgDjFO0.cjs +34 -0
  12. package/dist/extractStringsFromNodes-DKgDjFO0.cjs.map +1 -0
  13. package/dist/extractStringsFromNodes-p4mX1TQD.d.ts +14 -0
  14. package/dist/factory-CZNOGI-N.js +283 -0
  15. package/dist/factory-CZNOGI-N.js.map +1 -0
  16. package/dist/factory-DG1CVkEb.cjs +300 -0
  17. package/dist/factory-DG1CVkEb.cjs.map +1 -0
  18. package/dist/factory.cjs +29 -0
  19. package/dist/factory.d.ts +62 -0
  20. package/dist/factory.js +3 -0
  21. package/dist/index-BzjwdK2M.d.ts +2433 -0
  22. package/dist/index.cjs +444 -2180
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +94 -3408
  25. package/dist/index.js +395 -2101
  26. package/dist/index.js.map +1 -1
  27. package/dist/macros.cjs +117 -0
  28. package/dist/macros.cjs.map +1 -0
  29. package/dist/macros.d.ts +59 -0
  30. package/dist/macros.js +115 -0
  31. package/dist/macros.js.map +1 -0
  32. package/dist/operationParams-BZ07xDm0.d.ts +204 -0
  33. package/dist/response-KUdWiDWw.js +658 -0
  34. package/dist/response-KUdWiDWw.js.map +1 -0
  35. package/dist/response-hnSw2NKE.cjs +1027 -0
  36. package/dist/response-hnSw2NKE.cjs.map +1 -0
  37. package/dist/types-DyDzizSf.d.ts +364 -0
  38. package/dist/types.cjs +0 -0
  39. package/dist/types.d.ts +6 -0
  40. package/dist/types.js +1 -0
  41. package/dist/utils-BLJwyza-.cjs +912 -0
  42. package/dist/utils-BLJwyza-.cjs.map +1 -0
  43. package/dist/utils-CF_-Pn_c.js +770 -0
  44. package/dist/utils-CF_-Pn_c.js.map +1 -0
  45. package/dist/utils.cjs +36 -0
  46. package/dist/utils.d.ts +358 -0
  47. package/dist/utils.js +4 -0
  48. package/dist/visitor-DJ6ZEJvq.js +548 -0
  49. package/dist/visitor-DJ6ZEJvq.js.map +1 -0
  50. package/dist/visitor-DpKZ9Tk0.cjs +654 -0
  51. package/dist/visitor-DpKZ9Tk0.cjs.map +1 -0
  52. package/package.json +21 -6
  53. package/src/constants.ts +19 -64
  54. package/src/dedupe.ts +239 -0
  55. package/src/defineMacro.ts +132 -0
  56. package/src/dialect.ts +53 -0
  57. package/src/factory.ts +67 -678
  58. package/src/guards.ts +10 -92
  59. package/src/index.ts +13 -44
  60. package/src/infer.ts +16 -14
  61. package/src/macros/index.ts +3 -0
  62. package/src/macros/macroDiscriminatorEnum.ts +44 -0
  63. package/src/macros/macroEnumName.ts +25 -0
  64. package/src/macros/macroSimplifyUnion.ts +50 -0
  65. package/src/mocks.ts +7 -127
  66. package/src/node.ts +128 -0
  67. package/src/nodes/base.ts +5 -12
  68. package/src/nodes/code.ts +165 -74
  69. package/src/nodes/content.ts +56 -0
  70. package/src/nodes/file.ts +97 -36
  71. package/src/nodes/function.ts +216 -156
  72. package/src/nodes/http.ts +1 -35
  73. package/src/nodes/index.ts +23 -15
  74. package/src/nodes/input.ts +140 -0
  75. package/src/nodes/operation.ts +122 -68
  76. package/src/nodes/output.ts +23 -0
  77. package/src/nodes/parameter.ts +33 -3
  78. package/src/nodes/property.ts +36 -3
  79. package/src/nodes/requestBody.ts +61 -0
  80. package/src/nodes/response.ts +58 -13
  81. package/src/nodes/schema.ts +93 -17
  82. package/src/printer.ts +48 -42
  83. package/src/registry.ts +75 -0
  84. package/src/signature.ts +207 -0
  85. package/src/types.ts +8 -68
  86. package/src/utils/codegen.ts +104 -0
  87. package/src/utils/extractStringsFromNodes.ts +34 -0
  88. package/src/utils/fileMerge.ts +184 -0
  89. package/src/utils/index.ts +11 -0
  90. package/src/utils/operationParams.ts +353 -0
  91. package/src/utils/refs.ts +138 -0
  92. package/src/utils/schemaGraph.ts +169 -0
  93. package/src/utils/schemaMerge.ts +34 -0
  94. package/src/utils/schemaTraversal.ts +86 -0
  95. package/src/utils/strings.ts +139 -0
  96. package/src/visitor.ts +227 -289
  97. package/dist/chunk--u3MIqq1.js +0 -8
  98. package/src/nodes/root.ts +0 -64
  99. package/src/refs.ts +0 -67
  100. package/src/resolvers.ts +0 -45
  101. package/src/transformers.ts +0 -159
  102. package/src/utils.ts +0 -915
@@ -0,0 +1,2433 @@
1
+ import { n as __name } from "./chunk-CNktS9qV.js";
2
+
3
+ //#region src/nodes/base.d.ts
4
+ /**
5
+ * `kind` values used by AST nodes.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const kind: NodeKind = 'Schema'
10
+ * ```
11
+ */
12
+ type NodeKind = 'Input' | 'Output' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response' | 'RequestBody' | 'Content' | 'FunctionParameter' | 'FunctionParameters' | 'TypeLiteral' | 'IndexedAccessType' | 'ObjectBindingPattern' | 'Type' | 'File' | 'Import' | 'Export' | 'Source' | 'Const' | 'Function' | 'ArrowFunction' | 'Text' | 'Break' | 'Jsx';
13
+ /**
14
+ * Base shape shared by all AST nodes.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const base: BaseNode = { kind: 'Input' }
19
+ * ```
20
+ */
21
+ type BaseNode = {
22
+ /**
23
+ * Node discriminator.
24
+ */
25
+ kind: NodeKind;
26
+ };
27
+ //#endregion
28
+ //#region src/node.d.ts
29
+ /**
30
+ * Visitor callback names, one per traversable node kind. Kept in sync with the
31
+ * keys of `Visitor` in `visitor.ts`.
32
+ */
33
+ type VisitorKey = 'input' | 'output' | 'operation' | 'schema' | 'property' | 'parameter' | 'response';
34
+ /**
35
+ * Distributive `Omit` that preserves each member of a union.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * type A = { kind: 'a'; keep: string; drop: number }
40
+ * type B = { kind: 'b'; keep: boolean; drop: number }
41
+ * type Result = DistributiveOmit<A | B, 'drop'>
42
+ * // -> { kind: 'a'; keep: string } | { kind: 'b'; keep: boolean }
43
+ * ```
44
+ */
45
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
46
+ /**
47
+ * Updates a schema's `optional` and `nullish` flags from a parent's `required`
48
+ * value and the schema's own `nullable`. Mirrors how OpenAPI parameters and
49
+ * object properties combine "required" and "nullable" into a single AST.
50
+ *
51
+ * - Non-required + non-nullable → `optional: true`.
52
+ * - Non-required + nullable → `nullish: true`.
53
+ * - Required → both flags cleared.
54
+ */
55
+ declare function syncOptionality(schema: SchemaNode, required: boolean): SchemaNode;
56
+ /**
57
+ * The single definition derived from one {@link defineNode} call: the node's
58
+ * `create` builder, its `is` guard, and the traversal metadata the registry
59
+ * collects into the visitor tables.
60
+ */
61
+ type NodeDef<TNode extends BaseNode = BaseNode, TInput = never> = {
62
+ /**
63
+ * Node discriminator this definition owns.
64
+ */
65
+ kind: NodeKind;
66
+ /**
67
+ * Builds a node from its input, applying `defaults` and the optional `build` hook.
68
+ */
69
+ create: (input: TInput) => TNode;
70
+ /**
71
+ * Type guard matching this node kind.
72
+ */
73
+ is: (node: unknown) => node is TNode;
74
+ /**
75
+ * Child node fields in traversal order. Feeds `VISITOR_KEYS`.
76
+ */
77
+ children?: ReadonlyArray<string>;
78
+ /**
79
+ * Visitor callback name. Feeds `VISITOR_KEY_BY_KIND`.
80
+ */
81
+ visitorKey?: VisitorKey;
82
+ /**
83
+ * When `true`, `create` is rerun after children are rebuilt so computed fields
84
+ * stay in sync. Feeds `nodeRebuilders`.
85
+ */
86
+ rebuild?: boolean;
87
+ };
88
+ type DefineNodeConfig<TNode extends BaseNode, TInput, TBuilt extends object> = {
89
+ kind: TNode['kind'];
90
+ defaults?: Partial<TNode>;
91
+ build?: (input: TInput) => TBuilt;
92
+ children?: ReadonlyArray<string>;
93
+ visitorKey?: VisitorKey;
94
+ rebuild?: boolean;
95
+ };
96
+ /**
97
+ * Defines a node once and derives its `create` builder, `is` guard, and traversal
98
+ * metadata. `create` merges `defaults`, the `build` hook (or the raw input), and the
99
+ * `kind`, so node construction lives in one place without scattered `as` casts.
100
+ *
101
+ * Set `rebuild: true` when the `build` hook derives fields from children. After a
102
+ * transform rewrites those children, the registry reruns `create` so the derived
103
+ * fields stay correct.
104
+ *
105
+ * @example Simple node
106
+ * ```ts
107
+ * const importDef = defineNode<ImportNode>({ kind: 'Import' })
108
+ * const createImport = importDef.create
109
+ * ```
110
+ *
111
+ * @example Node with a build hook that is rerun on transform
112
+ * ```ts
113
+ * const propertyDef = defineNode<PropertyNode, UserPropertyNode>({
114
+ * kind: 'Property',
115
+ * build: (props) => ({ ...props, required: props.required ?? false }),
116
+ * children: ['schema'],
117
+ * visitorKey: 'property',
118
+ * rebuild: true,
119
+ * })
120
+ * ```
121
+ */
122
+ declare function defineNode<TNode extends BaseNode, TInput = Omit<TNode, 'kind'>, TBuilt extends object = Omit<TNode, 'kind'>>(config: DefineNodeConfig<TNode, TInput, TBuilt>): NodeDef<TNode, TInput>;
123
+ //#endregion
124
+ //#region src/nodes/code.d.ts
125
+ /**
126
+ * JSDoc documentation metadata attached to code declarations.
127
+ */
128
+ type JSDocNode = {
129
+ /**
130
+ * JSDoc comment lines. `undefined` entries are filtered out during rendering.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * ['@description A pet resource', '@deprecated']
135
+ * ```
136
+ */
137
+ comments?: Array<string | undefined>;
138
+ };
139
+ /**
140
+ * AST node representing a TypeScript `const` declaration.
141
+ *
142
+ * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
143
+ * The `children` prop of the component is represented as `nodes`.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * createConst({ name: 'pet', export: true, asConst: true })
148
+ * // export const pet = ... as const
149
+ * ```
150
+ */
151
+ type ConstNode = BaseNode & {
152
+ kind: 'Const';
153
+ /**
154
+ * Name of the constant declaration.
155
+ */
156
+ name: string;
157
+ /**
158
+ * Whether the declaration should be exported.
159
+ */
160
+ export?: boolean | null;
161
+ /**
162
+ * Explicit type annotation.
163
+ *
164
+ * @example Type reference
165
+ * `'Pet'`
166
+ */
167
+ type?: string | null;
168
+ /**
169
+ * JSDoc documentation metadata.
170
+ */
171
+ JSDoc?: JSDocNode | null;
172
+ /**
173
+ * Whether to append `as const` to the declaration.
174
+ */
175
+ asConst?: boolean | null;
176
+ /**
177
+ * Child nodes representing the value of the constant (children of the `Const` component).
178
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
179
+ */
180
+ nodes?: Array<CodeNode>;
181
+ };
182
+ /**
183
+ * AST node representing a TypeScript `type` alias declaration.
184
+ *
185
+ * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
186
+ * The `children` prop of the component is represented as `nodes`.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * createType({ name: 'Pet', export: true })
191
+ * // export type Pet = ...
192
+ * ```
193
+ */
194
+ type TypeNode = BaseNode & {
195
+ kind: 'Type';
196
+ /**
197
+ * Name of the type alias.
198
+ */
199
+ name: string;
200
+ /**
201
+ * Whether the declaration should be exported.
202
+ */
203
+ export?: boolean | null;
204
+ /**
205
+ * JSDoc documentation metadata.
206
+ */
207
+ JSDoc?: JSDocNode | null;
208
+ /**
209
+ * Child nodes representing the type body (children of the `Type` component).
210
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
211
+ */
212
+ nodes?: Array<CodeNode>;
213
+ };
214
+ /**
215
+ * AST node representing a TypeScript `function` declaration.
216
+ *
217
+ * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
218
+ * The `children` prop of the component is represented as `nodes`.
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * createFunctionDeclaration({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
223
+ * // export async function getPet(): Promise<Pet> { ... }
224
+ * ```
225
+ */
226
+ type FunctionNode = BaseNode & {
227
+ kind: 'Function';
228
+ /**
229
+ * Name of the function.
230
+ */
231
+ name: string;
232
+ /**
233
+ * Whether the function is a default export.
234
+ */
235
+ default?: boolean | null;
236
+ /**
237
+ * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
238
+ */
239
+ params?: string | null;
240
+ /**
241
+ * Whether the function should be exported.
242
+ */
243
+ export?: boolean | null;
244
+ /**
245
+ * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
246
+ */
247
+ async?: boolean | null;
248
+ /**
249
+ * TypeScript generic type parameters.
250
+ *
251
+ * @example Constrained generics
252
+ * `['T', 'U extends string']`
253
+ */
254
+ generics?: string | Array<string> | null;
255
+ /**
256
+ * Return type annotation.
257
+ *
258
+ * @example Type reference
259
+ * `'Pet'`
260
+ */
261
+ returnType?: string | null;
262
+ /**
263
+ * JSDoc documentation metadata.
264
+ */
265
+ JSDoc?: JSDocNode | null;
266
+ /**
267
+ * Child nodes representing the function body (children of the `Function` component).
268
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
269
+ */
270
+ nodes?: Array<CodeNode>;
271
+ };
272
+ /**
273
+ * AST node representing a TypeScript arrow function (`const name = () => { ... }`).
274
+ *
275
+ * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
276
+ * The `children` prop of the component is represented as `nodes`.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * createArrowFunctionDeclaration({ name: 'getPet', export: true, singleLine: true })
281
+ * // export const getPet = () => ...
282
+ * ```
283
+ */
284
+ type ArrowFunctionNode = BaseNode & {
285
+ kind: 'ArrowFunction';
286
+ /**
287
+ * Name of the arrow function (used as the `const` variable name).
288
+ */
289
+ name: string;
290
+ /**
291
+ * Whether the function is a default export.
292
+ */
293
+ default?: boolean | null;
294
+ /**
295
+ * Function parameter list rendered as a string (e.g. from `FunctionParams.toConstructor()`).
296
+ */
297
+ params?: string | null;
298
+ /**
299
+ * Whether the arrow function should be exported.
300
+ */
301
+ export?: boolean | null;
302
+ /**
303
+ * Whether the arrow function is async. When `true`, the return type is wrapped in `Promise<>`.
304
+ */
305
+ async?: boolean | null;
306
+ /**
307
+ * TypeScript generic type parameters.
308
+ *
309
+ * @example Constrained generics
310
+ * `['T', 'U extends string']`
311
+ */
312
+ generics?: string | Array<string> | null;
313
+ /**
314
+ * Return type annotation.
315
+ *
316
+ * @example Type reference
317
+ * `'Pet'`
318
+ */
319
+ returnType?: string | null;
320
+ /**
321
+ * JSDoc documentation metadata.
322
+ */
323
+ JSDoc?: JSDocNode | null;
324
+ /**
325
+ * Render the arrow function body as a single-line expression.
326
+ */
327
+ singleLine?: boolean | null;
328
+ /**
329
+ * Child nodes representing the function body (children of the `Function.Arrow` component).
330
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
331
+ */
332
+ nodes?: Array<CodeNode>;
333
+ };
334
+ /**
335
+ * AST node representing a raw text/string fragment in the source output.
336
+ *
337
+ * Used instead of bare `string` values so that all entries in `nodes` arrays
338
+ * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
339
+ *
340
+ * @example
341
+ * ```ts
342
+ * createText('return fetch(id)')
343
+ * // { kind: 'Text', value: 'return fetch(id)' }
344
+ * ```
345
+ */
346
+ type TextNode = BaseNode & {
347
+ kind: 'Text';
348
+ /**
349
+ * The raw string content.
350
+ */
351
+ value: string;
352
+ };
353
+ /**
354
+ * AST node representing a line break in the source output.
355
+ *
356
+ * Corresponds to `<br/>` in JSX components. When printed it produces an empty string,
357
+ * so joining nodes with `\n` in `printNodes` leaves a blank line between the surrounding code.
358
+ *
359
+ * @example
360
+ * ```ts
361
+ * createBreak()
362
+ * // { kind: 'Break' }
363
+ * // prints as '' → blank line when surrounded by other nodes
364
+ * ```
365
+ */
366
+ type BreakNode = BaseNode & {
367
+ kind: 'Break';
368
+ };
369
+ /**
370
+ * AST node representing a raw JSX fragment in the source output.
371
+ *
372
+ * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup
373
+ * (including fragments `<>…</>`) directly in generated code.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
378
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
379
+ * ```
380
+ */
381
+ type JsxNode = BaseNode & {
382
+ kind: 'Jsx';
383
+ /**
384
+ * The raw JSX string content.
385
+ */
386
+ value: string;
387
+ };
388
+ /**
389
+ * Union of all code-generation AST nodes.
390
+ *
391
+ * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
392
+ * structured children in {@link SourceNode.nodes}.
393
+ */
394
+ type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
395
+ /**
396
+ * Definition for the {@link ConstNode}.
397
+ */
398
+ declare const constDef: NodeDef<ConstNode, Omit<ConstNode, "kind">>;
399
+ /**
400
+ * Creates a `ConstNode` representing a TypeScript `const` declaration.
401
+ *
402
+ * @example Exported constant with type and `as const`
403
+ * ```ts
404
+ * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
405
+ * // export const pets: Pet[] = ... as const
406
+ * ```
407
+ */
408
+ declare const createConst: (input: Omit<ConstNode, "kind">) => ConstNode;
409
+ /**
410
+ * Definition for the {@link TypeNode}.
411
+ */
412
+ declare const typeDef: NodeDef<TypeNode, Omit<TypeNode, "kind">>;
413
+ /**
414
+ * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
415
+ *
416
+ * @example
417
+ * ```ts
418
+ * createType({ name: 'Pet', export: true })
419
+ * // export type Pet = ...
420
+ * ```
421
+ */
422
+ declare const createType: (input: Omit<TypeNode, "kind">) => TypeNode;
423
+ /**
424
+ * Definition for the {@link FunctionNode}.
425
+ */
426
+ declare const functionDef: NodeDef<FunctionNode, Omit<FunctionNode, "kind">>;
427
+ /**
428
+ * Creates a `FunctionNode` representing a TypeScript `function` declaration.
429
+ *
430
+ * @example
431
+ * ```ts
432
+ * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
433
+ * // export async function fetchPet(): Promise<Pet> { ... }
434
+ * ```
435
+ */
436
+ declare const createFunction: (input: Omit<FunctionNode, "kind">) => FunctionNode;
437
+ /**
438
+ * Definition for the {@link ArrowFunctionNode}.
439
+ */
440
+ declare const arrowFunctionDef: NodeDef<ArrowFunctionNode, Omit<ArrowFunctionNode, "kind">>;
441
+ /**
442
+ * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
443
+ *
444
+ * @example
445
+ * ```ts
446
+ * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
447
+ * // export const double = (n: number) => ...
448
+ * ```
449
+ */
450
+ declare const createArrowFunction: (input: Omit<ArrowFunctionNode, "kind">) => ArrowFunctionNode;
451
+ /**
452
+ * Definition for the {@link TextNode}.
453
+ */
454
+ declare const textDef: NodeDef<TextNode, string>;
455
+ /**
456
+ * Creates a {@link TextNode} representing a raw string fragment in the source output.
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * createText('return fetch(id)')
461
+ * // { kind: 'Text', value: 'return fetch(id)' }
462
+ * ```
463
+ */
464
+ declare const createText: (input: string) => TextNode;
465
+ /**
466
+ * Definition for the {@link BreakNode}.
467
+ */
468
+ declare const breakDef: NodeDef<BreakNode, void>;
469
+ /**
470
+ * Creates a {@link BreakNode} representing a line break in the source output.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * createBreak()
475
+ * // { kind: 'Break' }
476
+ * ```
477
+ */
478
+ declare function createBreak(): BreakNode;
479
+ /**
480
+ * Definition for the {@link JsxNode}.
481
+ */
482
+ declare const jsxDef: NodeDef<JsxNode, string>;
483
+ /**
484
+ * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
485
+ *
486
+ * @example
487
+ * ```ts
488
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
489
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
490
+ * ```
491
+ */
492
+ declare const createJsx: (input: string) => JsxNode;
493
+ //#endregion
494
+ //#region src/infer.d.ts
495
+ /**
496
+ * Shared parser options used by OAS-to-AST inference and parser flows.
497
+ */
498
+ type ParserOptions = {
499
+ /**
500
+ * How `format: 'date-time'` schemas are represented downstream.
501
+ * - `false` falls through to a plain `string` (no validation).
502
+ * - `'string'` emits a datetime string node.
503
+ * - `'stringOffset'` emits a datetime node with timezone offset.
504
+ * - `'stringLocal'` emits a local datetime node.
505
+ * - `'date'` emits a `date` node (JavaScript `Date` object).
506
+ */
507
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
508
+ /**
509
+ * How `type: 'integer'` (and `format: 'int64'`) maps to TypeScript.
510
+ * - `'bigint'` is exact for 64-bit IDs, but does not round-trip through JSON.
511
+ * - `'number'` fits most JSON APIs. Loses precision above `Number.MAX_SAFE_INTEGER`.
512
+ *
513
+ * @default 'bigint'
514
+ */
515
+ integerType?: 'number' | 'bigint';
516
+ /**
517
+ * AST type used when a schema's type cannot be inferred from the spec
518
+ * (`additionalProperties: true`, missing `type`, ...).
519
+ */
520
+ unknownType: 'any' | 'unknown' | 'void';
521
+ /**
522
+ * AST type used for completely empty schemas (`{}`).
523
+ */
524
+ emptySchemaType: 'any' | 'unknown' | 'void';
525
+ /**
526
+ * Suffix appended to derived enum names when Kubb has to invent one
527
+ * (typically for inline enums on object properties).
528
+ */
529
+ enumSuffix: 'enum' | (string & {});
530
+ };
531
+ /**
532
+ * Maps each `dateType` option value to the AST node produced by `format: 'date-time'`.
533
+ */
534
+ type DateTimeNodeByDateType = {
535
+ date: DateSchemaNode;
536
+ string: DatetimeSchemaNode;
537
+ stringOffset: DatetimeSchemaNode;
538
+ stringLocal: DatetimeSchemaNode;
539
+ false: StringSchemaNode;
540
+ };
541
+ /**
542
+ * Resolves the AST node produced by `format: 'date-time'` based on the `dateType` option.
543
+ */
544
+ type ResolveDateTimeNode<TDateType extends ParserOptions['dateType']> = DateTimeNodeByDateType[TDateType extends keyof DateTimeNodeByDateType ? TDateType : 'string'];
545
+ /**
546
+ * Ordered list of `[schema-shape, SchemaNode]` pairs.
547
+ * `InferSchemaNode` walks this tuple in order and returns the first matching node type.
548
+ */
549
+ type SchemaNodeMap<TDateType extends ParserOptions['dateType'] = 'string'> = [[{
550
+ $ref: string;
551
+ }, RefSchemaNode], [{
552
+ allOf: ReadonlyArray<unknown>;
553
+ properties: object;
554
+ }, IntersectionSchemaNode], [{
555
+ allOf: readonly [unknown, unknown, ...Array<unknown>];
556
+ }, IntersectionSchemaNode], [{
557
+ allOf: ReadonlyArray<unknown>;
558
+ }, SchemaNode], [{
559
+ oneOf: ReadonlyArray<unknown>;
560
+ }, UnionSchemaNode], [{
561
+ anyOf: ReadonlyArray<unknown>;
562
+ }, UnionSchemaNode], [{
563
+ const: null;
564
+ }, ScalarSchemaNode], [{
565
+ const: string | number | boolean;
566
+ }, EnumSchemaNode], [{
567
+ type: ReadonlyArray<string>;
568
+ }, UnionSchemaNode], [{
569
+ type: 'array';
570
+ enum: ReadonlyArray<unknown>;
571
+ }, ArraySchemaNode], [{
572
+ enum: ReadonlyArray<unknown>;
573
+ }, EnumSchemaNode], [{
574
+ type: 'enum';
575
+ }, EnumSchemaNode], [{
576
+ type: 'union';
577
+ }, UnionSchemaNode], [{
578
+ type: 'intersection';
579
+ }, IntersectionSchemaNode], [{
580
+ type: 'tuple';
581
+ }, ArraySchemaNode], [{
582
+ type: 'ref';
583
+ }, RefSchemaNode], [{
584
+ type: 'datetime';
585
+ }, DatetimeSchemaNode], [{
586
+ type: 'date';
587
+ }, DateSchemaNode], [{
588
+ type: 'time';
589
+ }, TimeSchemaNode], [{
590
+ type: 'url';
591
+ }, UrlSchemaNode], [{
592
+ type: 'object';
593
+ }, ObjectSchemaNode], [{
594
+ additionalProperties: boolean | {};
595
+ }, ObjectSchemaNode], [{
596
+ type: 'array';
597
+ }, ArraySchemaNode], [{
598
+ items: object;
599
+ }, ArraySchemaNode], [{
600
+ prefixItems: ReadonlyArray<unknown>;
601
+ }, ArraySchemaNode], [{
602
+ type: string;
603
+ format: 'date-time';
604
+ }, ResolveDateTimeNode<TDateType>], [{
605
+ type: string;
606
+ format: 'date';
607
+ }, DateSchemaNode], [{
608
+ type: string;
609
+ format: 'time';
610
+ }, TimeSchemaNode], [{
611
+ format: 'date-time';
612
+ }, ResolveDateTimeNode<TDateType>], [{
613
+ format: 'date';
614
+ }, DateSchemaNode], [{
615
+ format: 'time';
616
+ }, TimeSchemaNode], [{
617
+ type: 'string';
618
+ }, StringSchemaNode], [{
619
+ type: 'number';
620
+ }, NumberSchemaNode], [{
621
+ type: 'integer';
622
+ }, NumberSchemaNode], [{
623
+ type: 'bigint';
624
+ }, NumberSchemaNode], [{
625
+ type: string;
626
+ }, ScalarSchemaNode], [{
627
+ minLength: number;
628
+ }, StringSchemaNode], [{
629
+ maxLength: number;
630
+ }, StringSchemaNode], [{
631
+ pattern: string;
632
+ }, StringSchemaNode], [{
633
+ minimum: number;
634
+ }, NumberSchemaNode], [{
635
+ maximum: number;
636
+ }, NumberSchemaNode]];
637
+ /**
638
+ * Infers the matching AST `SchemaNode` type from an input schema shape.
639
+ */
640
+ 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;
641
+ //#endregion
642
+ //#region src/nodes/property.d.ts
643
+ /**
644
+ * AST node representing one named object property.
645
+ *
646
+ * @example
647
+ * ```ts
648
+ * const property: PropertyNode = {
649
+ * kind: 'Property',
650
+ * name: 'id',
651
+ * schema: createSchema({ type: 'integer' }),
652
+ * required: true,
653
+ * }
654
+ * ```
655
+ */
656
+ type PropertyNode = BaseNode & {
657
+ kind: 'Property';
658
+ /**
659
+ * Property key.
660
+ */
661
+ name: string;
662
+ /**
663
+ * Property schema.
664
+ */
665
+ schema: SchemaNode;
666
+ /**
667
+ * Whether the property is required.
668
+ */
669
+ required: boolean;
670
+ };
671
+ /**
672
+ * Loosely-typed property accepted by `createProperty`, with `required` optional.
673
+ */
674
+ type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>;
675
+ /**
676
+ * Definition for the {@link PropertyNode}. `required` defaults to `false` and the
677
+ * schema's `optional`/`nullish` flags are kept in sync with it.
678
+ */
679
+ declare const propertyDef: NodeDef<PropertyNode, UserPropertyNode>;
680
+ /**
681
+ * Creates a `PropertyNode`.
682
+ *
683
+ * @example
684
+ * ```ts
685
+ * const property = createProperty({
686
+ * name: 'status',
687
+ * required: true,
688
+ * schema: createSchema({ type: 'string', nullable: true }),
689
+ * })
690
+ * // required=true, no optional/nullish
691
+ * ```
692
+ */
693
+ declare const createProperty: (input: UserPropertyNode) => PropertyNode;
694
+ //#endregion
695
+ //#region src/nodes/schema.d.ts
696
+ type PrimitiveSchemaType =
697
+ /**
698
+ * Text value.
699
+ */
700
+ 'string'
701
+ /**
702
+ * Floating-point number.
703
+ */
704
+ | 'number'
705
+ /**
706
+ * Integer number.
707
+ */
708
+ | 'integer'
709
+ /**
710
+ * Big integer number.
711
+ */
712
+ | 'bigint'
713
+ /**
714
+ * Boolean value.
715
+ */
716
+ | 'boolean'
717
+ /**
718
+ * Null value.
719
+ */
720
+ | 'null'
721
+ /**
722
+ * Any value.
723
+ */
724
+ | 'any'
725
+ /**
726
+ * Unknown value.
727
+ */
728
+ | 'unknown'
729
+ /**
730
+ * No value (`void`).
731
+ */
732
+ | 'void'
733
+ /**
734
+ * Never value.
735
+ */
736
+ | 'never'
737
+ /**
738
+ * Object value.
739
+ */
740
+ | 'object'
741
+ /**
742
+ * Array value.
743
+ */
744
+ | 'array'
745
+ /**
746
+ * Date value.
747
+ */
748
+ | 'date';
749
+ /**
750
+ * Composite schema types.
751
+ */
752
+ type ComplexSchemaType = 'tuple' | 'union' | 'intersection' | 'enum';
753
+ /**
754
+ * Schema types that need special handling in generators.
755
+ */
756
+ type SpecialSchemaType = 'ref' | 'datetime' | 'time' | 'uuid' | 'email' | 'url' | 'ipv4' | 'ipv6' | 'blob';
757
+ /**
758
+ * All schema type strings.
759
+ */
760
+ type SchemaType = PrimitiveSchemaType | ComplexSchemaType | SpecialSchemaType;
761
+ /**
762
+ * Scalar schema types without extra object/array/ref structure.
763
+ */
764
+ type ScalarSchemaType = Exclude<SchemaType, 'object' | 'array' | 'tuple' | 'union' | 'intersection' | 'enum' | 'ref' | 'datetime' | 'date' | 'time' | 'string' | 'number' | 'integer' | 'bigint' | 'url' | 'uuid' | 'email'>;
765
+ /**
766
+ * Fields shared by all schema nodes.
767
+ */
768
+ type SchemaNodeBase = BaseNode & {
769
+ /**
770
+ * Node kind.
771
+ */
772
+ kind: 'Schema';
773
+ /**
774
+ * Schema name for named definitions (for example, `"Pet"`).
775
+ * Inline schemas omit this field.
776
+ * `null` means kubb has processed this and determined there is no applicable name.
777
+ * `undefined` means the name has not been set yet.
778
+ */
779
+ name?: string | null;
780
+ /**
781
+ * Short schema title.
782
+ */
783
+ title?: string;
784
+ /**
785
+ * Schema description text.
786
+ */
787
+ description?: string;
788
+ /**
789
+ * Whether `null` is allowed.
790
+ */
791
+ nullable?: boolean;
792
+ /**
793
+ * Whether the field is optional.
794
+ */
795
+ optional?: boolean;
796
+ /**
797
+ * Both optional and nullable (`optional` + `nullable`).
798
+ */
799
+ nullish?: boolean;
800
+ /**
801
+ * Whether the schema is deprecated.
802
+ */
803
+ deprecated?: boolean;
804
+ /**
805
+ * Whether the schema is read-only.
806
+ */
807
+ readOnly?: boolean;
808
+ /**
809
+ * Whether the schema is write-only.
810
+ */
811
+ writeOnly?: boolean;
812
+ /**
813
+ * Default value.
814
+ */
815
+ default?: unknown;
816
+ /**
817
+ * Example value.
818
+ */
819
+ example?: unknown;
820
+ /**
821
+ * Base primitive type.
822
+ * For example, this is `'string'` for a `uuid` schema.
823
+ */
824
+ primitive?: PrimitiveSchemaType;
825
+ /**
826
+ * Schema `format` value.
827
+ */
828
+ format?: string;
829
+ };
830
+ /**
831
+ * Object schema with ordered properties.
832
+ *
833
+ * @example
834
+ * ```ts
835
+ * const objectSchema: ObjectSchemaNode = {
836
+ * kind: 'Schema',
837
+ * type: 'object',
838
+ * properties: [],
839
+ * }
840
+ * ```
841
+ */
842
+ type ObjectSchemaNode = SchemaNodeBase & {
843
+ /**
844
+ * Schema type discriminator.
845
+ */
846
+ type: 'object';
847
+ /**
848
+ * Primitive type, always `'object'` for object schemas.
849
+ */
850
+ primitive: 'object';
851
+ /**
852
+ * Ordered object properties.
853
+ */
854
+ properties: Array<PropertyNode>;
855
+ /**
856
+ * Additional object properties behavior:
857
+ * - `true`: allow any value
858
+ * - `false`: reject unknown properties (maps to `.strict()` in Zod)
859
+ * - `SchemaNode`: allow values that match that schema
860
+ * - `undefined`: no additional properties constraint (open object)
861
+ */
862
+ additionalProperties?: SchemaNode | boolean;
863
+ /**
864
+ * Pattern-based property schemas.
865
+ */
866
+ patternProperties?: Record<string, SchemaNode>;
867
+ /**
868
+ * Minimum number of properties allowed.
869
+ */
870
+ minProperties?: number;
871
+ /**
872
+ * Maximum number of properties allowed.
873
+ */
874
+ maxProperties?: number;
875
+ };
876
+ /**
877
+ * Array-like schema (`array` or `tuple`).
878
+ *
879
+ * @example
880
+ * ```ts
881
+ * const arraySchema: ArraySchemaNode = {
882
+ * kind: 'Schema',
883
+ * type: 'array',
884
+ * items: [],
885
+ * }
886
+ * ```
887
+ */
888
+ type ArraySchemaNode = SchemaNodeBase & {
889
+ /**
890
+ * Schema type discriminator (`array` or `tuple`).
891
+ */
892
+ type: 'array' | 'tuple';
893
+ /**
894
+ * Item schemas.
895
+ */
896
+ items?: Array<SchemaNode>;
897
+ /**
898
+ * Tuple rest-item schema for elements beyond positional `items`.
899
+ */
900
+ rest?: SchemaNode;
901
+ /**
902
+ * Minimum item count (or tuple length).
903
+ */
904
+ min?: number;
905
+ /**
906
+ * Maximum item count (or tuple length).
907
+ */
908
+ max?: number;
909
+ /**
910
+ * Whether all items must be unique.
911
+ */
912
+ unique?: boolean;
913
+ };
914
+ /**
915
+ * Shared shape for union and intersection schemas.
916
+ */
917
+ type CompositeSchemaNodeBase = SchemaNodeBase & {
918
+ /**
919
+ * Member schemas.
920
+ */
921
+ members?: Array<SchemaNode>;
922
+ };
923
+ /**
924
+ * Union schema, often from `oneOf` or `anyOf`.
925
+ *
926
+ * @example
927
+ * ```ts
928
+ * const unionSchema: UnionSchemaNode = {
929
+ * kind: 'Schema',
930
+ * type: 'union',
931
+ * members: [],
932
+ * }
933
+ * ```
934
+ */
935
+ type UnionSchemaNode = CompositeSchemaNodeBase & {
936
+ /**
937
+ * Schema type discriminator.
938
+ */
939
+ type: 'union';
940
+ /**
941
+ * Discriminator property name from OpenAPI `discriminator.propertyName`.
942
+ */
943
+ discriminatorPropertyName?: string;
944
+ /**
945
+ * How many union members must be valid.
946
+ * - `'one'`: exactly one member, from `oneOf`
947
+ * - `'any'`: any number of members, from `anyOf`
948
+ */
949
+ strategy?: 'one' | 'any';
950
+ };
951
+ /**
952
+ * Intersection schema, often from `allOf`.
953
+ *
954
+ * @example
955
+ * ```ts
956
+ * const intersectionSchema: IntersectionSchemaNode = {
957
+ * kind: 'Schema',
958
+ * type: 'intersection',
959
+ * members: [],
960
+ * }
961
+ * ```
962
+ */
963
+ type IntersectionSchemaNode = CompositeSchemaNodeBase & {
964
+ /**
965
+ * Schema type discriminator.
966
+ */
967
+ type: 'intersection';
968
+ };
969
+ /**
970
+ * One named enum item.
971
+ */
972
+ type EnumValueNode = {
973
+ /**
974
+ * Enum item name.
975
+ */
976
+ name: string;
977
+ /**
978
+ * Enum item value.
979
+ */
980
+ value: string | number | boolean;
981
+ /**
982
+ * Primitive type of the enum value.
983
+ */
984
+ primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>;
985
+ };
986
+ /**
987
+ * Enum schema node.
988
+ *
989
+ * @example
990
+ * ```ts
991
+ * const enumSchema: EnumSchemaNode = {
992
+ * kind: 'Schema',
993
+ * type: 'enum',
994
+ * enumValues: ['a', 'b'],
995
+ * }
996
+ * ```
997
+ */
998
+ type EnumSchemaNode = SchemaNodeBase & {
999
+ /**
1000
+ * Schema type discriminator.
1001
+ */
1002
+ type: 'enum';
1003
+ /**
1004
+ * Enum values in simple form.
1005
+ */
1006
+ enumValues?: Array<string | number | boolean | null>;
1007
+ /**
1008
+ * Enum values in named form.
1009
+ * If present, this is used instead of `enumValues`.
1010
+ */
1011
+ namedEnumValues?: Array<EnumValueNode>;
1012
+ };
1013
+ /**
1014
+ * Reference schema that points to another schema definition.
1015
+ *
1016
+ * @example
1017
+ * ```ts
1018
+ * const refSchema: RefSchemaNode = {
1019
+ * kind: 'Schema',
1020
+ * type: 'ref',
1021
+ * ref: '#/components/schemas/Pet',
1022
+ * }
1023
+ * ```
1024
+ */
1025
+ type RefSchemaNode = SchemaNodeBase & {
1026
+ /**
1027
+ * Schema type discriminator.
1028
+ */
1029
+ type: 'ref';
1030
+ /**
1031
+ * Referenced schema name.
1032
+ * `null` means Kubb has processed this and determined there is no applicable name.
1033
+ */
1034
+ name?: string | null;
1035
+ /**
1036
+ * Original `$ref` path, for example, `#/components/schemas/Order`.
1037
+ * Used to resolve names later.
1038
+ */
1039
+ ref?: string;
1040
+ /**
1041
+ * Pattern copied from a sibling `pattern` field.
1042
+ */
1043
+ pattern?: string;
1044
+ /**
1045
+ * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)
1046
+ * can be read without following the reference. Populated during OAS parsing when the
1047
+ * definition resolves, `null` when it can't or the ref is circular, and `undefined` when
1048
+ * resolution has not been attempted.
1049
+ */
1050
+ schema?: SchemaNode | null;
1051
+ };
1052
+ /**
1053
+ * Datetime schema.
1054
+ *
1055
+ * @example
1056
+ * ```ts
1057
+ * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }
1058
+ * ```
1059
+ */
1060
+ type DatetimeSchemaNode = SchemaNodeBase & {
1061
+ /**
1062
+ * Schema type discriminator.
1063
+ */
1064
+ type: 'datetime';
1065
+ /**
1066
+ * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).
1067
+ */
1068
+ offset?: boolean;
1069
+ /**
1070
+ * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).
1071
+ */
1072
+ local?: boolean;
1073
+ };
1074
+ /**
1075
+ * Shared base for `date` and `time` schemas.
1076
+ */
1077
+ type TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {
1078
+ /**
1079
+ * Schema type discriminator.
1080
+ */
1081
+ type: T;
1082
+ /**
1083
+ * Output representation in generated code.
1084
+ */
1085
+ representation: 'date' | 'string';
1086
+ };
1087
+ /**
1088
+ * Date schema node.
1089
+ *
1090
+ * @example
1091
+ * ```ts
1092
+ * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }
1093
+ * ```
1094
+ */
1095
+ type DateSchemaNode = TemporalSchemaNodeBase<'date'>;
1096
+ /**
1097
+ * Time schema node.
1098
+ *
1099
+ * @example
1100
+ * ```ts
1101
+ * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }
1102
+ * ```
1103
+ */
1104
+ type TimeSchemaNode = TemporalSchemaNodeBase<'time'>;
1105
+ /**
1106
+ * String schema node.
1107
+ *
1108
+ * @example
1109
+ * ```ts
1110
+ * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }
1111
+ * ```
1112
+ */
1113
+ type StringSchemaNode = SchemaNodeBase & {
1114
+ /**
1115
+ * Schema type discriminator.
1116
+ */
1117
+ type: 'string';
1118
+ /**
1119
+ * Minimum string length.
1120
+ */
1121
+ min?: number;
1122
+ /**
1123
+ * Maximum string length.
1124
+ */
1125
+ max?: number;
1126
+ /**
1127
+ * Regex pattern.
1128
+ */
1129
+ pattern?: string;
1130
+ };
1131
+ /**
1132
+ * Numeric schema (`number`, `integer`, or `bigint`).
1133
+ *
1134
+ * @example
1135
+ * ```ts
1136
+ * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }
1137
+ * ```
1138
+ */
1139
+ type NumberSchemaNode = SchemaNodeBase & {
1140
+ /**
1141
+ * Schema type discriminator.
1142
+ */
1143
+ type: 'number' | 'integer' | 'bigint';
1144
+ /**
1145
+ * Minimum value.
1146
+ */
1147
+ min?: number;
1148
+ /**
1149
+ * Maximum value.
1150
+ */
1151
+ max?: number;
1152
+ /**
1153
+ * Exclusive minimum value.
1154
+ */
1155
+ exclusiveMinimum?: number;
1156
+ /**
1157
+ * Exclusive maximum value.
1158
+ */
1159
+ exclusiveMaximum?: number;
1160
+ /**
1161
+ * The value must be a multiple of this number.
1162
+ */
1163
+ multipleOf?: number;
1164
+ };
1165
+ /**
1166
+ * Scalar schema with no extra constraints.
1167
+ *
1168
+ * @example
1169
+ * ```ts
1170
+ * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }
1171
+ * ```
1172
+ */
1173
+ type ScalarSchemaNode = SchemaNodeBase & {
1174
+ /**
1175
+ * Schema type discriminator.
1176
+ */
1177
+ type: ScalarSchemaType;
1178
+ };
1179
+ /**
1180
+ * URL schema node.
1181
+ * Can include an OpenAPI-style path template for template literal types.
1182
+ *
1183
+ * @example
1184
+ * ```ts
1185
+ * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }
1186
+ * ```
1187
+ */
1188
+ type UrlSchemaNode = SchemaNodeBase & {
1189
+ /**
1190
+ * Schema type discriminator.
1191
+ */
1192
+ type: 'url';
1193
+ /**
1194
+ * OpenAPI-style path template, for example, `'/pets/{petId}'`.
1195
+ */
1196
+ path?: string;
1197
+ /**
1198
+ * Minimum string length.
1199
+ */
1200
+ min?: number;
1201
+ /**
1202
+ * Maximum string length.
1203
+ */
1204
+ max?: number;
1205
+ };
1206
+ /**
1207
+ * Format-string schema for string-based formats that support length constraints.
1208
+ *
1209
+ * @example
1210
+ * ```ts
1211
+ * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }
1212
+ * ```
1213
+ */
1214
+ type FormatStringSchemaNode = SchemaNodeBase & {
1215
+ /**
1216
+ * Schema type discriminator.
1217
+ */
1218
+ type: 'uuid' | 'email';
1219
+ /**
1220
+ * Minimum string length.
1221
+ */
1222
+ min?: number;
1223
+ /**
1224
+ * Maximum string length.
1225
+ */
1226
+ max?: number;
1227
+ };
1228
+ /**
1229
+ * IPv4 address schema node.
1230
+ *
1231
+ * @example
1232
+ * ```ts
1233
+ * const ipv4Schema: Ipv4SchemaNode = { kind: 'Schema', type: 'ipv4' }
1234
+ * ```
1235
+ */
1236
+ type Ipv4SchemaNode = SchemaNodeBase & {
1237
+ /**
1238
+ * Schema type discriminator.
1239
+ */
1240
+ type: 'ipv4';
1241
+ };
1242
+ /**
1243
+ * IPv6 address schema node.
1244
+ *
1245
+ * @example
1246
+ * ```ts
1247
+ * const ipv6Schema: Ipv6SchemaNode = { kind: 'Schema', type: 'ipv6' }
1248
+ * ```
1249
+ */
1250
+ type Ipv6SchemaNode = SchemaNodeBase & {
1251
+ /**
1252
+ * Schema type discriminator.
1253
+ */
1254
+ type: 'ipv6';
1255
+ };
1256
+ /**
1257
+ * Mapping from schema type literals to concrete schema node types.
1258
+ * Used by `narrowSchema`.
1259
+ */
1260
+ type SchemaNodeByType = {
1261
+ object: ObjectSchemaNode;
1262
+ array: ArraySchemaNode;
1263
+ tuple: ArraySchemaNode;
1264
+ union: UnionSchemaNode;
1265
+ intersection: IntersectionSchemaNode;
1266
+ enum: EnumSchemaNode;
1267
+ ref: RefSchemaNode;
1268
+ datetime: DatetimeSchemaNode;
1269
+ date: DateSchemaNode;
1270
+ time: TimeSchemaNode;
1271
+ string: StringSchemaNode;
1272
+ number: NumberSchemaNode;
1273
+ integer: NumberSchemaNode;
1274
+ bigint: NumberSchemaNode;
1275
+ boolean: ScalarSchemaNode;
1276
+ null: ScalarSchemaNode;
1277
+ any: ScalarSchemaNode;
1278
+ unknown: ScalarSchemaNode;
1279
+ void: ScalarSchemaNode;
1280
+ never: ScalarSchemaNode;
1281
+ uuid: FormatStringSchemaNode;
1282
+ email: FormatStringSchemaNode;
1283
+ url: UrlSchemaNode;
1284
+ ipv4: Ipv4SchemaNode;
1285
+ ipv6: Ipv6SchemaNode;
1286
+ blob: ScalarSchemaNode;
1287
+ };
1288
+ /**
1289
+ * Union of all schema node types.
1290
+ */
1291
+ type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | Ipv4SchemaNode | Ipv6SchemaNode | ScalarSchemaNode;
1292
+ type CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & {
1293
+ properties?: Array<PropertyNode>;
1294
+ primitive?: 'object';
1295
+ };
1296
+ type CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>;
1297
+ type CreateSchemaOutput<T extends CreateSchemaInput> = InferSchemaNode<T> & {
1298
+ kind: 'Schema';
1299
+ };
1300
+ /**
1301
+ * Definition for the {@link SchemaNode}. Object schemas default `properties` to an
1302
+ * empty array, and `primitive` is inferred from `type` when not explicitly provided.
1303
+ */
1304
+ declare const schemaDef: NodeDef<SchemaNode, CreateSchemaInput>;
1305
+ /**
1306
+ * Creates a `SchemaNode`, narrowed to the variant of `props.type`.
1307
+ *
1308
+ * @example
1309
+ * ```ts
1310
+ * const scalar = createSchema({ type: 'string' })
1311
+ * // { kind: 'Schema', type: 'string', primitive: 'string' }
1312
+ * ```
1313
+ *
1314
+ * @example
1315
+ * ```ts
1316
+ * const object = createSchema({ type: 'object' })
1317
+ * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }
1318
+ * ```
1319
+ */
1320
+ declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
1321
+ declare function createSchema(props: CreateSchemaInput): SchemaNode;
1322
+ //#endregion
1323
+ //#region src/nodes/content.d.ts
1324
+ /**
1325
+ * AST node representing one content-type entry of a request body or response.
1326
+ *
1327
+ * There is one entry per content type declared in the spec (e.g. `application/json`,
1328
+ * `multipart/form-data`), and each entry holds its own body schema.
1329
+ *
1330
+ * @example
1331
+ * ```ts
1332
+ * const content: ContentNode = {
1333
+ * kind: 'Content',
1334
+ * contentType: 'application/json',
1335
+ * schema: createSchema({ type: 'string' }),
1336
+ * }
1337
+ * ```
1338
+ */
1339
+ type ContentNode = BaseNode & {
1340
+ /**
1341
+ * Node kind.
1342
+ */
1343
+ kind: 'Content';
1344
+ /**
1345
+ * The content type for this entry (e.g. `'application/json'`).
1346
+ */
1347
+ contentType: string;
1348
+ /**
1349
+ * Body schema for this content type.
1350
+ */
1351
+ schema?: SchemaNode;
1352
+ /**
1353
+ * Property keys to exclude from the generated type via `Omit<Type, Keys>`.
1354
+ * Set when a referenced schema has `readOnly`/`writeOnly` fields that should be omitted.
1355
+ */
1356
+ keysToOmit?: Array<string> | null;
1357
+ };
1358
+ /**
1359
+ * Loosely-typed content entry accepted by the builders, normalized into a {@link ContentNode}.
1360
+ */
1361
+ type UserContent = Omit<ContentNode, 'kind'>;
1362
+ /**
1363
+ * Definition for the {@link ContentNode}.
1364
+ */
1365
+ declare const contentDef: NodeDef<ContentNode, UserContent>;
1366
+ /**
1367
+ * Creates a `ContentNode` for a single request-body or response content type.
1368
+ */
1369
+ declare const createContent: (input: UserContent) => ContentNode;
1370
+ //#endregion
1371
+ //#region src/nodes/file.d.ts
1372
+ /**
1373
+ * Supported file extensions.
1374
+ */
1375
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
1376
+ type ImportName = string | Array<string | {
1377
+ propertyName: string;
1378
+ name?: string;
1379
+ }>;
1380
+ /**
1381
+ * Represents a language-agnostic import/dependency declaration.
1382
+ *
1383
+ * @example Named import (TypeScript: `import { useState } from 'react'`)
1384
+ * ```ts
1385
+ * createImport({ name: ['useState'], path: 'react' })
1386
+ * ```
1387
+ *
1388
+ * @example Default import (TypeScript: `import React from 'react'`)
1389
+ * ```ts
1390
+ * createImport({ name: 'React', path: 'react' })
1391
+ * ```
1392
+ *
1393
+ * @example Type-only import (TypeScript: `import type { FC } from 'react'`)
1394
+ * ```ts
1395
+ * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
1396
+ * ```
1397
+ *
1398
+ * @example Namespace import (TypeScript: `import * as React from 'react'`)
1399
+ * ```ts
1400
+ * createImport({ name: 'React', path: 'react', isNameSpace: true })
1401
+ * ```
1402
+ */
1403
+ type ImportNode = BaseNode & {
1404
+ kind: 'Import';
1405
+ /**
1406
+ * Import name(s) to be used.
1407
+ *
1408
+ * @example Named imports
1409
+ * `['useState']`
1410
+ *
1411
+ * @example Default import
1412
+ * `'React'`
1413
+ */
1414
+ name: ImportName;
1415
+ /**
1416
+ * Path for the import.
1417
+ *
1418
+ * @example
1419
+ * `'@kubb/core'`
1420
+ */
1421
+ path: string;
1422
+ /**
1423
+ * Add a type-only import prefix.
1424
+ * - `true` generates `import type { Type } from './path'`
1425
+ * - `false` generates `import { Type } from './path'`
1426
+ */
1427
+ isTypeOnly?: boolean | null;
1428
+ /**
1429
+ * Import the entire module as a namespace.
1430
+ * - `true` generates `import * as Name from './path'`
1431
+ * - `false` generates a standard import
1432
+ */
1433
+ isNameSpace?: boolean | null;
1434
+ /**
1435
+ * When set, the import path is resolved relative to this root.
1436
+ */
1437
+ root?: string | null;
1438
+ };
1439
+ /**
1440
+ * Represents a language-agnostic export/public API declaration.
1441
+ *
1442
+ * @example Named export (TypeScript: `export { Pets } from './Pets'`)
1443
+ * ```ts
1444
+ * createExport({ name: ['Pets'], path: './Pets' })
1445
+ * ```
1446
+ *
1447
+ * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
1448
+ * ```ts
1449
+ * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
1450
+ * ```
1451
+ *
1452
+ * @example Wildcard export (TypeScript: `export * from './utils'`)
1453
+ * ```ts
1454
+ * createExport({ path: './utils' })
1455
+ * ```
1456
+ *
1457
+ * @example Namespace alias (TypeScript: `export * as utils from './utils'`)
1458
+ * ```ts
1459
+ * createExport({ name: 'utils', path: './utils', asAlias: true })
1460
+ * ```
1461
+ */
1462
+ type ExportNode = BaseNode & {
1463
+ kind: 'Export';
1464
+ /**
1465
+ * Export name(s) to be used. When omitted, generates a wildcard export.
1466
+ *
1467
+ * @example Named exports
1468
+ * `['useState']`
1469
+ *
1470
+ * @example Single export
1471
+ * `'React'`
1472
+ */
1473
+ name?: string | Array<string> | null;
1474
+ /**
1475
+ * Path for the export.
1476
+ *
1477
+ * @example
1478
+ * `'@kubb/core'`
1479
+ */
1480
+ path: string;
1481
+ /**
1482
+ * Add a type-only export prefix.
1483
+ * - `true` generates `export type { Type } from './path'`
1484
+ * - `false` generates `export { Type } from './path'`
1485
+ */
1486
+ isTypeOnly?: boolean | null;
1487
+ /**
1488
+ * Export as an aliased namespace.
1489
+ * - `true` generates `export * as aliasName from './path'`
1490
+ * - `false` generates a standard export
1491
+ */
1492
+ asAlias?: boolean | null;
1493
+ };
1494
+ /**
1495
+ * Represents a fragment of source code within a file.
1496
+ *
1497
+ * @example Named exportable source
1498
+ * ```ts
1499
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
1500
+ * ```
1501
+ *
1502
+ * @example Inline unnamed code block
1503
+ * ```ts
1504
+ * createSource({ nodes: [createText('const x = 1')] })
1505
+ * ```
1506
+ */
1507
+ type SourceNode = BaseNode & {
1508
+ kind: 'Source';
1509
+ /**
1510
+ * Optional name identifying this source (used for deduplication and barrel generation).
1511
+ */
1512
+ name?: string | null;
1513
+ /**
1514
+ * Mark this source as a type-only export.
1515
+ */
1516
+ isTypeOnly?: boolean | null;
1517
+ /**
1518
+ * Include the `export` keyword in the generated source.
1519
+ */
1520
+ isExportable?: boolean | null;
1521
+ /**
1522
+ * Include this source in barrel/index file generation.
1523
+ */
1524
+ isIndexable?: boolean | null;
1525
+ /**
1526
+ * Child nodes that make up this source fragment, in DOM order.
1527
+ * Use a {@link TextNode} for raw string content.
1528
+ */
1529
+ nodes?: Array<CodeNode>;
1530
+ };
1531
+ /**
1532
+ * Represents a fully resolved file in the AST.
1533
+ *
1534
+ * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
1535
+ * and deduplicates `imports`, `exports`, and `sources`.
1536
+ *
1537
+ * @example
1538
+ * ```ts
1539
+ * const file = createFile({
1540
+ * baseName: 'petStore.ts',
1541
+ * path: 'src/models/petStore.ts',
1542
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
1543
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
1544
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
1545
+ * })
1546
+ * // file.id = SHA256 hash of the path
1547
+ * // file.name = 'petStore'
1548
+ * // file.extname = '.ts'
1549
+ * ```
1550
+ */
1551
+ type FileNode<TMeta extends object = object> = BaseNode & {
1552
+ kind: 'File';
1553
+ /**
1554
+ * Unique identifier derived from a SHA256 hash of the file path. `createFile`
1555
+ * computes it, so callers do not need to provide it.
1556
+ */
1557
+ id: string;
1558
+ /**
1559
+ * File name without extension, derived from `baseName`.
1560
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
1561
+ */
1562
+ name: string;
1563
+ /**
1564
+ * File base name, including extension.
1565
+ * Based on UNIX basename: `${name}${extname}`
1566
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
1567
+ */
1568
+ baseName: `${string}.${string}`;
1569
+ /**
1570
+ * Full qualified path to the file.
1571
+ */
1572
+ path: string;
1573
+ /**
1574
+ * File extension extracted from `baseName`.
1575
+ */
1576
+ extname: Extname;
1577
+ /**
1578
+ * Deduplicated list of source code fragments.
1579
+ */
1580
+ sources: Array<SourceNode>;
1581
+ /**
1582
+ * Deduplicated list of import declarations.
1583
+ */
1584
+ imports: Array<ImportNode>;
1585
+ /**
1586
+ * Deduplicated list of export declarations.
1587
+ */
1588
+ exports: Array<ExportNode>;
1589
+ /**
1590
+ * Optional metadata attached to this file, read by plugins during barrel generation.
1591
+ */
1592
+ meta?: TMeta;
1593
+ /**
1594
+ * Optional banner prepended to the generated file content.
1595
+ * Accepts `null` so `resolver.resolveBanner()` results can be passed directly.
1596
+ */
1597
+ banner?: string | null;
1598
+ /**
1599
+ * Optional footer appended to the generated file content.
1600
+ * Accepts `null` so `resolver.resolveFooter()` results can be passed directly.
1601
+ */
1602
+ footer?: string | null;
1603
+ };
1604
+ /**
1605
+ * Definition for the {@link ImportNode}.
1606
+ */
1607
+ declare const importDef: NodeDef<ImportNode, Omit<ImportNode, "kind">>;
1608
+ /**
1609
+ * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
1610
+ *
1611
+ * @example Named import
1612
+ * ```ts
1613
+ * createImport({ name: ['useState'], path: 'react' })
1614
+ * // import { useState } from 'react'
1615
+ * ```
1616
+ */
1617
+ declare const createImport: (input: Omit<ImportNode, "kind">) => ImportNode;
1618
+ /**
1619
+ * Definition for the {@link ExportNode}.
1620
+ */
1621
+ declare const exportDef: NodeDef<ExportNode, Omit<ExportNode, "kind">>;
1622
+ /**
1623
+ * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
1624
+ *
1625
+ * @example Named export
1626
+ * ```ts
1627
+ * createExport({ name: ['Pet'], path: './Pet' })
1628
+ * // export { Pet } from './Pet'
1629
+ * ```
1630
+ */
1631
+ declare const createExport: (input: Omit<ExportNode, "kind">) => ExportNode;
1632
+ /**
1633
+ * Definition for the {@link SourceNode}.
1634
+ */
1635
+ declare const sourceDef: NodeDef<SourceNode, Omit<SourceNode, "kind">>;
1636
+ /**
1637
+ * Creates a `SourceNode` representing a fragment of source code within a file.
1638
+ *
1639
+ * @example
1640
+ * ```ts
1641
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
1642
+ * ```
1643
+ */
1644
+ declare const createSource: (input: Omit<SourceNode, "kind">) => SourceNode;
1645
+ /**
1646
+ * Definition for the {@link FileNode}. The fully resolved builder lives in
1647
+ * `createFile`, so this definition only supplies the guard.
1648
+ */
1649
+ declare const fileDef: NodeDef<FileNode<object>, Omit<FileNode<object>, "kind">>;
1650
+ //#endregion
1651
+ //#region src/nodes/function.d.ts
1652
+ /**
1653
+ * A language-agnostic type expression used as a function parameter type annotation.
1654
+ *
1655
+ * - a plain `string` is a type reference rendered as-is, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`
1656
+ * - a {@link TypeLiteralNode} is an inline anonymous type, e.g. `{ petId: string; name?: string }`
1657
+ * - an {@link IndexedAccessTypeNode} is a single field accessed from a named type, e.g. `PathParams['petId']`
1658
+ */
1659
+ type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode;
1660
+ /**
1661
+ * AST node for an inline anonymous object type grouping named fields.
1662
+ * TypeScript renders as `{ key: Type; other?: OtherType }`.
1663
+ *
1664
+ * @example
1665
+ * ```ts
1666
+ * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
1667
+ * // { petId: string }
1668
+ * ```
1669
+ */
1670
+ type TypeLiteralNode = BaseNode & {
1671
+ kind: 'TypeLiteral';
1672
+ /**
1673
+ * Members of the object type, rendered in order.
1674
+ */
1675
+ members: Array<{
1676
+ /**
1677
+ * Member key.
1678
+ */
1679
+ name: string;
1680
+ /**
1681
+ * Member type expression.
1682
+ */
1683
+ type: TypeExpression;
1684
+ /**
1685
+ * Whether the member is optional, rendered with `?`.
1686
+ */
1687
+ optional?: boolean;
1688
+ }>;
1689
+ };
1690
+ /**
1691
+ * AST node for a single field accessed from a named group type.
1692
+ * TypeScript renders as `objectType['indexType']`.
1693
+ *
1694
+ * @example
1695
+ * ```ts
1696
+ * createIndexedAccessType({ objectType: 'GetPetPathParams', indexType: 'petId' })
1697
+ * // GetPetPathParams['petId']
1698
+ * ```
1699
+ */
1700
+ type IndexedAccessTypeNode = BaseNode & {
1701
+ kind: 'IndexedAccessType';
1702
+ /**
1703
+ * Name of the type being indexed, e.g. `'GetPetPathParams'`.
1704
+ */
1705
+ objectType: string;
1706
+ /**
1707
+ * Field key to access, e.g. `'petId'`.
1708
+ */
1709
+ indexType: string;
1710
+ };
1711
+ /**
1712
+ * AST node for an object destructuring binding, used as the name of a grouped function parameter.
1713
+ * TypeScript renders as `{ id, name }` or `{ id: renamed }` when `propertyName` differs.
1714
+ *
1715
+ * @example
1716
+ * ```ts
1717
+ * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
1718
+ * // { id, name }
1719
+ * ```
1720
+ */
1721
+ type ObjectBindingPatternNode = BaseNode & {
1722
+ kind: 'ObjectBindingPattern';
1723
+ /**
1724
+ * Bound elements, rendered in order.
1725
+ */
1726
+ elements: Array<{
1727
+ /**
1728
+ * Local binding name.
1729
+ */
1730
+ name: string;
1731
+ /**
1732
+ * Source key when it differs from the binding name, rendered as `propertyName: name`.
1733
+ */
1734
+ propertyName?: string;
1735
+ }>;
1736
+ };
1737
+ /**
1738
+ * AST node for one function parameter.
1739
+ *
1740
+ * A simple parameter has a `string` name. A destructured group has an
1741
+ * {@link ObjectBindingPatternNode} name paired with a {@link TypeLiteralNode} type.
1742
+ *
1743
+ * @example Required parameter
1744
+ * `name: Type`
1745
+ *
1746
+ * @example Optional parameter
1747
+ * `name?: Type`
1748
+ *
1749
+ * @example Parameter with default value
1750
+ * `name: Type = defaultValue`
1751
+ *
1752
+ * @example Rest parameter
1753
+ * `...name: Type[]`
1754
+ *
1755
+ * @example Destructured group
1756
+ * `{ id, name? }: { id: string; name?: string } = {}`
1757
+ */
1758
+ type FunctionParameterNode = BaseNode & {
1759
+ kind: 'FunctionParameter';
1760
+ /**
1761
+ * Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.
1762
+ */
1763
+ name: string | ObjectBindingPatternNode;
1764
+ /**
1765
+ * Type annotation as a {@link TypeExpression}. Omit for untyped output.
1766
+ */
1767
+ type?: TypeExpression;
1768
+ /**
1769
+ * Whether the parameter is optional, rendered with `?`.
1770
+ */
1771
+ optional?: boolean;
1772
+ /**
1773
+ * Default value, written verbatim after `=`. Commonly `'{}'` for a destructured group.
1774
+ */
1775
+ default?: string;
1776
+ /**
1777
+ * When `true` the parameter is emitted as a rest parameter, e.g. `...name: Type[]`.
1778
+ */
1779
+ rest?: boolean;
1780
+ };
1781
+ /**
1782
+ * AST node for a complete function parameter list.
1783
+ *
1784
+ * Printers are responsible for sorting (`required` → `optional` → `defaulted`).
1785
+ * Nodes are plain immutable data.
1786
+ *
1787
+ * Renders differently depending on the output mode:
1788
+ * - `declaration` → `(id: string, config: Config = {})` function declaration parameters
1789
+ * - `call` → `(id, { method, url })` function call arguments
1790
+ */
1791
+ type FunctionParametersNode = BaseNode & {
1792
+ kind: 'FunctionParameters';
1793
+ /**
1794
+ * Ordered parameter nodes.
1795
+ */
1796
+ params: ReadonlyArray<FunctionParameterNode>;
1797
+ };
1798
+ /**
1799
+ * Union of all function-parameter AST node variants used by the function-parameter printer.
1800
+ */
1801
+ type FunctionParamNode = FunctionParameterNode | FunctionParametersNode | TypeLiteralNode | IndexedAccessTypeNode | ObjectBindingPatternNode;
1802
+ /**
1803
+ * Handler-map keys for the function-parameter printer, one per {@link FunctionParamNode} kind.
1804
+ */
1805
+ type FunctionParamKind = FunctionParamNode['kind'];
1806
+ /**
1807
+ * Definition for the {@link TypeLiteralNode}.
1808
+ */
1809
+ declare const typeLiteralDef: NodeDef<TypeLiteralNode, Pick<TypeLiteralNode, "members">>;
1810
+ /**
1811
+ * Creates a {@link TypeLiteralNode} representing an inline anonymous object type.
1812
+ *
1813
+ * @example
1814
+ * ```ts
1815
+ * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
1816
+ * // { petId: string }
1817
+ * ```
1818
+ */
1819
+ declare const createTypeLiteral: (input: Pick<TypeLiteralNode, "members">) => TypeLiteralNode;
1820
+ /**
1821
+ * Definition for the {@link IndexedAccessTypeNode}.
1822
+ */
1823
+ declare const indexedAccessTypeDef: NodeDef<IndexedAccessTypeNode, Omit<IndexedAccessTypeNode, "kind">>;
1824
+ /**
1825
+ * Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.
1826
+ *
1827
+ * @example
1828
+ * ```ts
1829
+ * createIndexedAccessType({ objectType: 'DeletePetPathParams', indexType: 'petId' })
1830
+ * // DeletePetPathParams['petId']
1831
+ * ```
1832
+ */
1833
+ declare const createIndexedAccessType: (input: Omit<IndexedAccessTypeNode, "kind">) => IndexedAccessTypeNode;
1834
+ /**
1835
+ * Definition for the {@link ObjectBindingPatternNode}.
1836
+ */
1837
+ declare const objectBindingPatternDef: NodeDef<ObjectBindingPatternNode, Pick<ObjectBindingPatternNode, "elements">>;
1838
+ /**
1839
+ * Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.
1840
+ *
1841
+ * @example
1842
+ * ```ts
1843
+ * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
1844
+ * // { id, name }
1845
+ * ```
1846
+ */
1847
+ declare const createObjectBindingPattern: (input: Pick<ObjectBindingPatternNode, "elements">) => ObjectBindingPatternNode;
1848
+ /**
1849
+ * Plain property descriptor for a destructured group built by {@link createFunctionParameter}.
1850
+ */
1851
+ type FunctionParameterProperty = {
1852
+ name: string;
1853
+ type: TypeExpression;
1854
+ optional?: boolean;
1855
+ };
1856
+ type FunctionParameterInput = {
1857
+ name: string;
1858
+ type?: TypeExpression;
1859
+ optional?: boolean;
1860
+ default?: string;
1861
+ rest?: boolean;
1862
+ } | {
1863
+ properties: Array<FunctionParameterProperty>;
1864
+ optional?: boolean;
1865
+ default?: string;
1866
+ };
1867
+ /**
1868
+ * Definition for the {@link FunctionParameterNode}. `optional` defaults to `false`.
1869
+ * Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name
1870
+ * paired with a {@link TypeLiteralNode} type.
1871
+ */
1872
+ declare const functionParameterDef: NodeDef<FunctionParameterNode, FunctionParameterInput>;
1873
+ /**
1874
+ * Creates a `FunctionParameterNode`. `optional` defaults to `false`.
1875
+ *
1876
+ * @example Optional param
1877
+ * ```ts
1878
+ * createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })
1879
+ * // → params?: QueryParams
1880
+ * ```
1881
+ *
1882
+ * @example Destructured group
1883
+ * ```ts
1884
+ * createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })
1885
+ * // → { id, name }: { id: string; name?: string } = {}
1886
+ * ```
1887
+ */
1888
+ declare const createFunctionParameter: (input: FunctionParameterInput) => FunctionParameterNode;
1889
+ /**
1890
+ * Definition for the {@link FunctionParametersNode}.
1891
+ */
1892
+ declare const functionParametersDef: NodeDef<FunctionParametersNode, Partial<Omit<FunctionParametersNode, "kind">>>;
1893
+ /**
1894
+ * Creates a `FunctionParametersNode` from an ordered list of parameters.
1895
+ *
1896
+ * @example
1897
+ * ```ts
1898
+ * const empty = createFunctionParameters()
1899
+ * // { kind: 'FunctionParameters', params: [] }
1900
+ * ```
1901
+ */
1902
+ declare function createFunctionParameters(props?: Partial<Omit<FunctionParametersNode, 'kind'>>): FunctionParametersNode;
1903
+ //#endregion
1904
+ //#region ../../internals/utils/src/promise.d.ts
1905
+ /**
1906
+ * Container that switches between an eager `Array<T>` and a lazy `AsyncIterable<T>`.
1907
+ *
1908
+ * `Array<T>` by default. With `Stream` set to `true` it becomes `AsyncIterable<T>`, so large
1909
+ * collections can be produced lazily without holding every item in memory. Pairs with
1910
+ * {@link arrayToAsyncIterable}, which lifts a plain array into the streaming form.
1911
+ *
1912
+ * @example
1913
+ * ```ts
1914
+ * type Eager = Streamable<number> // Array<number>
1915
+ * type Lazy = Streamable<number, true> // AsyncIterable<number>
1916
+ * ```
1917
+ */
1918
+ type Streamable<T, Stream extends boolean = false> = Stream extends true ? AsyncIterable<T> : Array<T>;
1919
+ //#endregion
1920
+ //#region src/nodes/parameter.d.ts
1921
+ type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
1922
+ /**
1923
+ * AST node representing one operation parameter.
1924
+ *
1925
+ * @example
1926
+ * ```ts
1927
+ * const param: ParameterNode = {
1928
+ * kind: 'Parameter',
1929
+ * name: 'petId',
1930
+ * in: 'path',
1931
+ * schema: createSchema({ type: 'string' }),
1932
+ * required: true,
1933
+ * }
1934
+ * ```
1935
+ */
1936
+ type ParameterNode = BaseNode & {
1937
+ kind: 'Parameter';
1938
+ /**
1939
+ * Parameter name.
1940
+ */
1941
+ name: string;
1942
+ /**
1943
+ * Parameter location (`path`, `query`, `header`, or `cookie`).
1944
+ */
1945
+ in: ParameterLocation;
1946
+ /**
1947
+ * Parameter schema.
1948
+ */
1949
+ schema: SchemaNode;
1950
+ /**
1951
+ * Whether the parameter is required.
1952
+ */
1953
+ required: boolean;
1954
+ };
1955
+ type UserParameterNode = Pick<ParameterNode, 'name' | 'in' | 'schema'> & Partial<Omit<ParameterNode, 'kind' | 'name' | 'in' | 'schema'>>;
1956
+ /**
1957
+ * Definition for the {@link ParameterNode}. `required` defaults to `false` and the
1958
+ * schema's `optional`/`nullish` flags are kept in sync with it.
1959
+ */
1960
+ declare const parameterDef: NodeDef<ParameterNode, UserParameterNode>;
1961
+ /**
1962
+ * Creates a `ParameterNode`.
1963
+ *
1964
+ * @example
1965
+ * ```ts
1966
+ * const param = createParameter({
1967
+ * name: 'petId',
1968
+ * in: 'path',
1969
+ * required: true,
1970
+ * schema: createSchema({ type: 'string' }),
1971
+ * })
1972
+ * ```
1973
+ */
1974
+ declare const createParameter: (input: UserParameterNode) => ParameterNode;
1975
+ //#endregion
1976
+ //#region src/nodes/requestBody.d.ts
1977
+ /**
1978
+ * AST node representing an operation request body.
1979
+ *
1980
+ * Body schemas live exclusively inside the `content` array (one entry per content type),
1981
+ * mirroring {@link ResponseNode}.
1982
+ *
1983
+ * @example
1984
+ * ```ts
1985
+ * const requestBody: RequestBodyNode = {
1986
+ * kind: 'RequestBody',
1987
+ * required: true,
1988
+ * content: [{ kind: 'Content', contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
1989
+ * }
1990
+ * ```
1991
+ */
1992
+ type RequestBodyNode = BaseNode & {
1993
+ kind: 'RequestBody';
1994
+ /**
1995
+ * Request body description carried over from the spec.
1996
+ */
1997
+ description?: string;
1998
+ /**
1999
+ * Whether the request body is required (`requestBody.required: true` in the spec).
2000
+ * When `false` or absent, the generated `data` parameter should be optional.
2001
+ */
2002
+ required?: boolean;
2003
+ /**
2004
+ * Content type entries for this request body.
2005
+ *
2006
+ * When the adapter `contentType` option is set, this array contains exactly one entry for
2007
+ * that content type. Otherwise it contains one entry per content type declared in the spec,
2008
+ * so plugins can generate code for every variant (for example, separate hooks for
2009
+ * `application/json` and `multipart/form-data`).
2010
+ */
2011
+ content?: Array<ContentNode>;
2012
+ };
2013
+ /**
2014
+ * Loosely-typed request body accepted by `createOperation`, normalized into a {@link RequestBodyNode}.
2015
+ */
2016
+ type UserRequestBody = Omit<RequestBodyNode, 'kind' | 'content'> & {
2017
+ content?: Array<UserContent>;
2018
+ };
2019
+ /**
2020
+ * Definition for the {@link RequestBodyNode}, normalizing each content entry into a `ContentNode`.
2021
+ */
2022
+ declare const requestBodyDef: NodeDef<RequestBodyNode, UserRequestBody>;
2023
+ /**
2024
+ * Creates a `RequestBodyNode`, normalizing each content entry into a `ContentNode`.
2025
+ */
2026
+ declare const createRequestBody: (input: UserRequestBody) => RequestBodyNode;
2027
+ //#endregion
2028
+ //#region src/nodes/http.d.ts
2029
+ /**
2030
+ * All supported HTTP status code literals as strings, as used in API specs
2031
+ * (for example, `"200"` and `"404"`).
2032
+ */
2033
+ 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';
2034
+ /**
2035
+ * Response status code literal used by operations.
2036
+ *
2037
+ * Includes specific HTTP status code strings and `"default"` for catch-all responses.
2038
+ *
2039
+ * @example
2040
+ * ```ts
2041
+ * const status: StatusCode = '200'
2042
+ * const fallback: StatusCode = 'default'
2043
+ * ```
2044
+ */
2045
+ type StatusCode = HttpStatusCode | 'default';
2046
+ //#endregion
2047
+ //#region src/nodes/response.d.ts
2048
+ /**
2049
+ * AST node representing one operation response variant.
2050
+ *
2051
+ * Mirrors {@link OperationNode.requestBody}: the response body schemas live exclusively inside
2052
+ * the `content` array (one entry per content type), so the same schema is never duplicated at the
2053
+ * node root and inside `content`.
2054
+ *
2055
+ * @example
2056
+ * ```ts
2057
+ * const response: ResponseNode = {
2058
+ * kind: 'Response',
2059
+ * statusCode: '200',
2060
+ * content: [{ contentType: 'application/json', schema: createSchema({ type: 'string' }) }],
2061
+ * }
2062
+ * ```
2063
+ */
2064
+ type ResponseNode = BaseNode & {
2065
+ /**
2066
+ * Node kind.
2067
+ */
2068
+ kind: 'Response';
2069
+ /**
2070
+ * HTTP status code or `'default'` for a fallback response.
2071
+ */
2072
+ statusCode: StatusCode;
2073
+ /**
2074
+ * Optional response description.
2075
+ */
2076
+ description?: string;
2077
+ /**
2078
+ * All available content type entries for this response.
2079
+ *
2080
+ * When the adapter `contentType` option is set, this array contains exactly one entry for that
2081
+ * content type. Otherwise it contains one entry per content type declared in the spec, so that
2082
+ * plugins can generate a union of response types (e.g. `application/json` and `application/xml`).
2083
+ * Body-less responses keep a single entry whose `schema` is the empty/`void` placeholder.
2084
+ *
2085
+ * @example
2086
+ * ```ts
2087
+ * // spec response declares both application/json and application/xml
2088
+ * response.content[0].contentType // 'application/json'
2089
+ * response.content[1].contentType // 'application/xml'
2090
+ * ```
2091
+ */
2092
+ content?: Array<ContentNode>;
2093
+ };
2094
+ type ResponseInput = Pick<ResponseNode, 'statusCode'> & Partial<Omit<ResponseNode, 'kind' | 'statusCode' | 'content'>> & {
2095
+ content?: Array<UserContent>;
2096
+ schema?: SchemaNode;
2097
+ mediaType?: string | null;
2098
+ keysToOmit?: Array<string> | null;
2099
+ };
2100
+ /**
2101
+ * Definition for the {@link ResponseNode}. A single legacy `schema` (with optional
2102
+ * `mediaType`/`keysToOmit`) is normalized into one `content` entry.
2103
+ */
2104
+ declare const responseDef: NodeDef<ResponseNode, ResponseInput>;
2105
+ /**
2106
+ * Creates a `ResponseNode`.
2107
+ *
2108
+ * @example
2109
+ * ```ts
2110
+ * const response = createResponse({
2111
+ * statusCode: '200',
2112
+ * content: [{ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) }],
2113
+ * })
2114
+ * ```
2115
+ */
2116
+ declare const createResponse: (input: ResponseInput) => ResponseNode;
2117
+ //#endregion
2118
+ //#region src/nodes/operation.d.ts
2119
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE';
2120
+ /**
2121
+ * Transport an operation belongs to.
2122
+ */
2123
+ type OperationProtocol = 'http';
2124
+ /**
2125
+ * Fields shared by every operation, regardless of transport.
2126
+ */
2127
+ type OperationNodeBase = BaseNode & {
2128
+ /**
2129
+ * Node kind.
2130
+ */
2131
+ kind: 'Operation';
2132
+ /**
2133
+ * Operation identifier, usually from OpenAPI `operationId`.
2134
+ */
2135
+ operationId: string;
2136
+ /**
2137
+ * Group labels for the operation.
2138
+ * Usually copied from OpenAPI `tags`.
2139
+ */
2140
+ tags: Array<string>;
2141
+ /**
2142
+ * Short one-line operation summary.
2143
+ */
2144
+ summary?: string;
2145
+ /**
2146
+ * Full operation description.
2147
+ */
2148
+ description?: string;
2149
+ /**
2150
+ * Marks the operation as deprecated.
2151
+ */
2152
+ deprecated?: boolean;
2153
+ /**
2154
+ * Query, path, header, and cookie parameters for the operation.
2155
+ */
2156
+ parameters: Array<ParameterNode>;
2157
+ /**
2158
+ * Request body for the operation.
2159
+ */
2160
+ requestBody?: RequestBodyNode;
2161
+ /**
2162
+ * Operation responses.
2163
+ */
2164
+ responses: Array<ResponseNode>;
2165
+ };
2166
+ /**
2167
+ * Operation served over HTTP/REST (OpenAPI). `method` and `path` are guaranteed.
2168
+ *
2169
+ * @example
2170
+ * ```ts
2171
+ * const operation: HttpOperationNode = {
2172
+ * kind: 'Operation',
2173
+ * operationId: 'listPets',
2174
+ * protocol: 'http',
2175
+ * method: 'GET',
2176
+ * path: '/pets',
2177
+ * tags: [],
2178
+ * parameters: [],
2179
+ * responses: [],
2180
+ * }
2181
+ * ```
2182
+ */
2183
+ type HttpOperationNode = OperationNodeBase & {
2184
+ /**
2185
+ * Transport the operation belongs to.
2186
+ */
2187
+ protocol?: 'http';
2188
+ /**
2189
+ * HTTP method like `'GET'`.
2190
+ */
2191
+ method: HttpMethod;
2192
+ /**
2193
+ * OpenAPI-style path string, for example `/pets/{petId}`, with `{param}` notation preserved.
2194
+ */
2195
+ path: string;
2196
+ };
2197
+ /**
2198
+ * Operation for a non-HTTP transport. HTTP-only fields are forbidden.
2199
+ */
2200
+ type GenericOperationNode = OperationNodeBase & {
2201
+ /**
2202
+ * Transport the operation belongs to.
2203
+ */
2204
+ protocol?: Exclude<OperationProtocol, 'http'>;
2205
+ method?: never;
2206
+ path?: never;
2207
+ };
2208
+ /**
2209
+ * AST node representing one API operation.
2210
+ *
2211
+ * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees
2212
+ * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with
2213
+ * `isHttpOperationNode(node)` or `node.protocol === 'http'` before reading `method`/`path`.
2214
+ */
2215
+ type OperationNode = HttpOperationNode | GenericOperationNode;
2216
+ type OperationInput = {
2217
+ operationId: string;
2218
+ method?: HttpOperationNode['method'];
2219
+ path?: HttpOperationNode['path'];
2220
+ requestBody?: UserRequestBody;
2221
+ [key: string]: unknown;
2222
+ };
2223
+ /**
2224
+ * Definition for the {@link OperationNode}. HTTP operations (those carrying both
2225
+ * `method` and `path`) are tagged with `protocol: 'http'`, and the request body is
2226
+ * normalized into a `RequestBodyNode`.
2227
+ */
2228
+ declare const operationDef: NodeDef<OperationNode, OperationInput>;
2229
+ /**
2230
+ * Creates an `OperationNode` with default empty arrays for `tags`, `parameters`, and `responses`.
2231
+ *
2232
+ * @example
2233
+ * ```ts
2234
+ * const operation = createOperation({ operationId: 'getPetById', method: 'GET', path: '/pet/{petId}' })
2235
+ * // tags, parameters, and responses are []
2236
+ * ```
2237
+ */
2238
+ declare function createOperation(props: Pick<HttpOperationNode, 'operationId' | 'method' | 'path'> & Partial<Omit<HttpOperationNode, 'kind' | 'operationId' | 'method' | 'path' | 'requestBody'>> & {
2239
+ requestBody?: UserRequestBody;
2240
+ }): HttpOperationNode;
2241
+ declare function createOperation(props: Pick<GenericOperationNode, 'operationId'> & Partial<Omit<GenericOperationNode, 'kind' | 'operationId' | 'requestBody'>> & {
2242
+ requestBody?: UserRequestBody;
2243
+ }): GenericOperationNode;
2244
+ //#endregion
2245
+ //#region src/nodes/input.d.ts
2246
+ /**
2247
+ * Metadata for an API document, populated by the adapter and available to every generator.
2248
+ *
2249
+ * All fields are plain JSON-serializable values, no `Set`, no `Map`, no class instances.
2250
+ * Computed fields (`circularNames`, `enumNames`) are pre-calculated once during the adapter
2251
+ * pre-scan so generators never need to iterate the full schema list themselves.
2252
+ *
2253
+ * @example
2254
+ * ```ts
2255
+ * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://petstore.swagger.io/v2', circularNames: [], enumNames: [] }
2256
+ * ```
2257
+ */
2258
+ type InputMeta = {
2259
+ /**
2260
+ * API title from `info.title` in the source document.
2261
+ */
2262
+ title?: string;
2263
+ /**
2264
+ * API description from `info.description` in the source document.
2265
+ */
2266
+ description?: string;
2267
+ /**
2268
+ * API version string from `info.version` in the source document.
2269
+ */
2270
+ version?: string;
2271
+ /**
2272
+ * Resolved base URL from the first matching server entry in the source document.
2273
+ */
2274
+ baseURL?: string | null;
2275
+ /**
2276
+ * Names of schemas that participate in a circular reference chain.
2277
+ * Computed once during the adapter pre-scan, so a generator never has to
2278
+ * call `findCircularSchemas` itself.
2279
+ *
2280
+ * Convert to a `Set` once at the start of a generator, not per-schema,
2281
+ * so lookups stay O(1) without repeated allocations.
2282
+ *
2283
+ * @example Wrap a circular schema in z.lazy()
2284
+ * ```ts
2285
+ * const circular = new Set(meta.circularNames)
2286
+ * if (circular.has(schema.name)) { ... }
2287
+ * ```
2288
+ */
2289
+ circularNames: ReadonlyArray<string>;
2290
+ /**
2291
+ * Names of schemas whose type is `enum`.
2292
+ * Computed once during the adapter pre-scan, so a generator never has to
2293
+ * filter the schema list itself.
2294
+ *
2295
+ * Convert to a `Set` once at the start of a generator when you need repeated
2296
+ * membership checks, so each check stays O(1) instead of an array scan.
2297
+ *
2298
+ * @example Check if a referenced schema is an enum
2299
+ * `const enums = new Set(meta.enumNames)`
2300
+ * `const isEnum = enums.has(schemaName)`
2301
+ */
2302
+ enumNames: ReadonlyArray<string>;
2303
+ };
2304
+ /**
2305
+ * Input AST node that contains all schemas and operations for one API document.
2306
+ * Produced by the adapter and consumed by all Kubb plugins.
2307
+ *
2308
+ * `Stream` switches `schemas` and `operations` between eager `Array`s (the default) and lazy
2309
+ * `AsyncIterable`s. The streaming variant `InputNode<true>` yields nodes one at a time and makes
2310
+ * `meta` optional, since the adapter can emit metadata before the first node is parsed.
2311
+ *
2312
+ * @example
2313
+ * ```ts
2314
+ * const input: InputNode = {
2315
+ * kind: 'Input',
2316
+ * schemas: [],
2317
+ * operations: [],
2318
+ * meta: { circularNames: [], enumNames: [] },
2319
+ * }
2320
+ * ```
2321
+ *
2322
+ * @example Streaming variant for large specs
2323
+ * ```ts
2324
+ * for await (const schema of inputNode.schemas) {
2325
+ * // only this one SchemaNode is live here. Previous ones are GC-eligible
2326
+ * }
2327
+ * ```
2328
+ */
2329
+ type InputNode<Stream extends boolean = false> = BaseNode & {
2330
+ /**
2331
+ * Node kind.
2332
+ */
2333
+ kind: 'Input';
2334
+ /**
2335
+ * All schema nodes in the document.
2336
+ */
2337
+ schemas: Streamable<SchemaNode, Stream>;
2338
+ /**
2339
+ * All operation nodes in the document.
2340
+ */
2341
+ operations: Streamable<OperationNode, Stream>;
2342
+ } & (Stream extends true ? {
2343
+ meta?: InputMeta;
2344
+ } : {
2345
+ meta: InputMeta;
2346
+ });
2347
+ /**
2348
+ * Definition for the {@link InputNode}.
2349
+ */
2350
+ declare const inputDef: NodeDef<InputNode<false>, Partial<Omit<InputNode<false>, "kind">>>;
2351
+ /**
2352
+ * Creates an `InputNode`. Pass `stream: true` for the streaming variant whose `schemas` and
2353
+ * `operations` are `AsyncIterable` sources and whose `meta` is optional. Otherwise it builds the
2354
+ * eager variant with array `schemas`/`operations` and the defaulted `meta`.
2355
+ *
2356
+ * @example Eager
2357
+ * ```ts
2358
+ * const input = createInput()
2359
+ * // { kind: 'Input', schemas: [], operations: [] }
2360
+ * ```
2361
+ *
2362
+ * @example Streaming
2363
+ * ```ts
2364
+ * const node = createInput({ stream: true, schemas: schemasIterable, operations: operationsIterable, meta: { title: 'My API' } })
2365
+ * ```
2366
+ */
2367
+ declare function createInput<Stream extends boolean = false>(options?: Partial<Omit<InputNode<Stream>, 'kind'>> & {
2368
+ stream?: Stream;
2369
+ }): InputNode<Stream>;
2370
+ //#endregion
2371
+ //#region src/nodes/output.d.ts
2372
+ /**
2373
+ * Output AST node that groups all generated file output for one API document.
2374
+ *
2375
+ * Produced by generators and consumed by the build pipeline to write files.
2376
+ *
2377
+ * @example
2378
+ * ```ts
2379
+ * const output: OutputNode = {
2380
+ * kind: 'Output',
2381
+ * files: [],
2382
+ * }
2383
+ * ```
2384
+ */
2385
+ type OutputNode = BaseNode & {
2386
+ /**
2387
+ * Node kind.
2388
+ */
2389
+ kind: 'Output';
2390
+ /**
2391
+ * Generated file nodes.
2392
+ */
2393
+ files: Array<FileNode>;
2394
+ };
2395
+ /**
2396
+ * Definition for the {@link OutputNode}.
2397
+ */
2398
+ declare const outputDef: NodeDef<OutputNode, Partial<Omit<OutputNode, "kind">>>;
2399
+ /**
2400
+ * Creates an `OutputNode` with a stable default for `files`.
2401
+ *
2402
+ * @example
2403
+ * ```ts
2404
+ * const output = createOutput()
2405
+ * // { kind: 'Output', files: [] }
2406
+ * ```
2407
+ */
2408
+ declare function createOutput(overrides?: Partial<Omit<OutputNode, 'kind'>>): OutputNode;
2409
+ //#endregion
2410
+ //#region src/nodes/index.d.ts
2411
+ /**
2412
+ * Union of all AST node types.
2413
+ *
2414
+ * This lets TypeScript narrow types in `switch (node.kind)` blocks.
2415
+ *
2416
+ * @example
2417
+ * ```ts
2418
+ * function getKind(node: Node): string {
2419
+ * switch (node.kind) {
2420
+ * case 'Input':
2421
+ * return 'input'
2422
+ * case 'Output':
2423
+ * return 'output'
2424
+ * default:
2425
+ * return 'other'
2426
+ * }
2427
+ * }
2428
+ * ```
2429
+ */
2430
+ type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FunctionParamNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode;
2431
+ //#endregion
2432
+ export { fileDef as $, textDef as $t, FunctionParametersNode as A, InferSchemaNode as At, functionParameterDef as B, TypeNode as Bt, ParameterLocation as C, UrlSchemaNode as Ct, FunctionParamKind as D, UserPropertyNode as Dt, parameterDef as E, PropertyNode as Et, createFunctionParameter as F, ConstNode as Ft, ExportNode as G, createBreak as Gt, indexedAccessTypeDef as H, breakDef as Ht, createFunctionParameters as I, FunctionNode as It, SourceNode as J, createJsx as Jt, FileNode as K, createConst as Kt, createIndexedAccessType as L, JSDocNode as Lt, ObjectBindingPatternNode as M, ArrowFunctionNode as Mt, TypeExpression as N, BreakNode as Nt, FunctionParamNode as O, createProperty as Ot, TypeLiteralNode as P, CodeNode as Pt, exportDef as Q, jsxDef as Qt, createObjectBindingPattern as R, JsxNode as Rt, requestBodyDef as S, UnionSchemaNode as St, createParameter as T, schemaDef as Tt, objectBindingPatternDef as U, constDef as Ut, functionParametersDef as V, arrowFunctionDef as Vt, typeLiteralDef as W, createArrowFunction as Wt, createImport as X, createType as Xt, createExport as Y, createText as Yt, createSource as Z, functionDef as Zt, responseDef as _, SchemaNode as _t, InputMeta as a, BaseNode as an, createContent as at, UserRequestBody as b, StringSchemaNode as bt, inputDef as c, DatetimeSchemaNode as ct, HttpOperationNode as d, NumberSchemaNode as dt, typeDef as en, importDef as et, OperationNode as f, ObjectSchemaNode as ft, createResponse as g, ScalarSchemaType as gt, ResponseNode as h, ScalarSchemaNode as ht, outputDef as i, syncOptionality as in, contentDef as it, IndexedAccessTypeNode as j, ParserOptions as jt, FunctionParameterNode as k, propertyDef as kt, GenericOperationNode as l, EnumSchemaNode as lt, operationDef as m, RefSchemaNode as mt, OutputNode as n, NodeDef as nn, ContentNode as nt, InputNode as o, NodeKind as on, ArraySchemaNode as ot, createOperation as p, PrimitiveSchemaType as pt, ImportNode as q, createFunction as qt, createOutput as r, defineNode as rn, UserContent as rt, createInput as s, DateSchemaNode as st, Node as t, DistributiveOmit as tn, sourceDef as tt, HttpMethod as u, IntersectionSchemaNode as ut, StatusCode as v, SchemaNodeByType as vt, ParameterNode as w, createSchema as wt, createRequestBody as x, TimeSchemaNode as xt, RequestBodyNode as y, SchemaType as yt, createTypeLiteral as z, TextNode as zt };
2433
+ //# sourceMappingURL=index-BzjwdK2M.d.ts.map