@kubb/ast 5.0.0-beta.8 → 5.0.0-beta.80

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