@kubb/ast 5.9.3 → 5.9.5

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