@kubb/ast 5.18.4 → 5.18.6

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,7 +1,11 @@
1
+ /**
2
+ * Union of the values of an object type, such as `ValueOf<typeof nodeKinds>` for an `as const` table.
3
+ */
4
+ type ValueOf<T> = T[keyof T];
1
5
  /**
2
6
  * Node kind discriminators used by every AST node (for example `node.kind === nodeKinds.text`).
3
7
  */
4
- export declare const nodeKinds: {
8
+ declare const nodeKinds$1: {
5
9
  readonly input: 'Input';
6
10
  readonly operation: 'Operation';
7
11
  readonly schema: 'Schema';
@@ -27,7 +31,7 @@ export declare const nodeKinds: {
27
31
  *
28
32
  * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).
29
33
  */
30
- export declare const schemaTypes: {
34
+ declare const schemaTypes$1: {
31
35
  /**
32
36
  * Text value.
33
37
  */
@@ -135,10 +139,6 @@ export declare const schemaTypes: {
135
139
  */
136
140
  readonly never: 'never';
137
141
  };
138
- /**
139
- * Union of the values of an object type, such as `ValueOf<typeof nodeKinds>` for an `as const` table.
140
- */
141
- type ValueOf<T> = T[keyof T];
142
142
  /**
143
143
  * `kind` values used by AST nodes.
144
144
  *
@@ -147,7 +147,7 @@ type ValueOf<T> = T[keyof T];
147
147
  * const kind: NodeKind = 'Schema'
148
148
  * ```
149
149
  */
150
- type NodeKind = ValueOf<typeof nodeKinds>;
150
+ type NodeKind = ValueOf<typeof nodeKinds$1>;
151
151
  /**
152
152
  * Base shape shared by all AST nodes.
153
153
  *
@@ -171,835 +171,668 @@ type BaseNode = {
171
171
  /** `Omit` applied to each member of a union, so the union survives. */
172
172
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
173
173
  /**
174
- * AST node representing one named object property.
175
- *
176
- * @example
177
- * ```ts
178
- * const property: PropertyNode = {
179
- * kind: 'Property',
180
- * name: 'id',
181
- * schema: createSchema({ type: 'integer' }),
182
- * required: true,
183
- * }
184
- * ```
174
+ * JSDoc documentation metadata attached to code declarations.
185
175
  */
186
- type PropertyNode = BaseNode & {
187
- kind: 'Property';
188
- /**
189
- * Property key.
190
- */
191
- name: string;
192
- /**
193
- * Property schema.
194
- */
195
- schema: SchemaNode;
176
+ type JSDocNode = {
196
177
  /**
197
- * Whether the property is required.
178
+ * JSDoc comment lines. `undefined` entries are filtered out during rendering.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * ['@description A pet resource', '@deprecated']
183
+ * ```
198
184
  */
199
- required: boolean;
185
+ comments?: Array<string | undefined>;
200
186
  };
201
187
  /**
202
- * Loosely-typed property accepted by `createProperty`, with `required` optional.
203
- */
204
- type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>;
205
- /**
206
- * Creates a `PropertyNode`. `required` defaults to `false`, and the schema's
207
- * `optional`/`nullish` flags are derived from it.
188
+ * AST node representing a TypeScript `const` declaration.
189
+ *
190
+ * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
191
+ * The `children` prop of the component is represented as `nodes`.
208
192
  *
209
193
  * @example
210
194
  * ```ts
211
- * const property = createProperty({
212
- * name: 'status',
213
- * required: true,
214
- * schema: createSchema({ type: 'string', nullable: true }),
215
- * })
216
- * // required=true, no optional/nullish
195
+ * createConst({ name: 'pet', export: true, asConst: true })
196
+ * // export const pet = ... as const
217
197
  * ```
218
198
  */
219
- declare function createProperty(input: UserPropertyNode): PropertyNode;
220
- /**
221
- * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.
222
- */
223
- type PrimitiveSchemaType = 'string' | 'number' | 'integer' | 'bigint' | 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'object' | 'array' | 'date';
224
- /**
225
- * All schema type strings, one per key of {@link SchemaNodeByType}.
226
- */
227
- type SchemaType = keyof SchemaNodeByType;
228
- /**
229
- * Scalar schema types without extra object/array/ref structure or constraints.
230
- */
231
- type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6';
232
- /**
233
- * Fields shared by all schema nodes.
234
- */
235
- type SchemaNodeBase = BaseNode & {
236
- /**
237
- * Node kind.
238
- */
239
- kind: 'Schema';
240
- /**
241
- * Schema name for named definitions (for example, `"Pet"`).
242
- * Inline schemas omit this field.
243
- * `null` means Kubb has processed this and determined there is no applicable name.
244
- * `undefined` means the name has not been set yet.
245
- */
246
- name?: string | null;
247
- /**
248
- * Short schema title.
249
- */
250
- title?: string;
251
- /**
252
- * Schema description text.
253
- */
254
- description?: string;
255
- /**
256
- * Whether `null` is allowed.
257
- */
258
- nullable?: boolean;
199
+ type ConstNode = BaseNode & {
200
+ kind: 'Const';
259
201
  /**
260
- * Whether the field is optional.
202
+ * Name of the constant declaration.
261
203
  */
262
- optional?: boolean;
204
+ name: string;
263
205
  /**
264
- * Both optional and nullable (`optional` + `nullable`).
206
+ * Whether the declaration should be exported.
265
207
  */
266
- nullish?: boolean;
208
+ export?: boolean | null;
267
209
  /**
268
- * Whether the schema is deprecated.
210
+ * Explicit type annotation.
211
+ *
212
+ * @example Type reference
213
+ * `'Pet'`
269
214
  */
270
- deprecated?: boolean;
215
+ type?: string | null;
271
216
  /**
272
- * Whether the schema is read-only.
217
+ * JSDoc documentation metadata.
273
218
  */
274
- readOnly?: boolean;
219
+ JSDoc?: JSDocNode | null;
275
220
  /**
276
- * Whether the schema is write-only.
221
+ * Whether to append `as const` to the declaration.
277
222
  */
278
- writeOnly?: boolean;
223
+ asConst?: boolean | null;
279
224
  /**
280
- * Default value.
225
+ * Child nodes representing the value of the constant (children of the `Const` component).
226
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
281
227
  */
282
- default?: unknown;
228
+ nodes?: Array<CodeNode>;
229
+ };
230
+ /**
231
+ * AST node representing a TypeScript `type` alias declaration.
232
+ *
233
+ * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
234
+ * The `children` prop of the component is represented as `nodes`.
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * createType({ name: 'Pet', export: true })
239
+ * // export type Pet = ...
240
+ * ```
241
+ */
242
+ type TypeNode = BaseNode & {
243
+ kind: 'Type';
283
244
  /**
284
- * Example values from an `examples` array.
245
+ * Name of the type alias.
285
246
  */
286
- examples?: Array<unknown>;
247
+ name: string;
287
248
  /**
288
- * Base primitive type.
289
- * For example, this is `'string'` for a `uuid` schema.
249
+ * Whether the declaration should be exported.
290
250
  */
291
- primitive?: PrimitiveSchemaType;
251
+ export?: boolean | null;
292
252
  /**
293
- * Schema `format` value.
253
+ * JSDoc documentation metadata.
294
254
  */
295
- format?: string;
296
- externalDocs?: ExternalDocs;
255
+ JSDoc?: JSDocNode | null;
297
256
  /**
298
- * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means "key is present".
299
- * Visitors do not walk it.
257
+ * Child nodes representing the type body (children of the `Type` component).
258
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
300
259
  */
301
- conditionals?: Array<{
302
- if: SchemaNode;
303
- then?: SchemaNode;
304
- else?: SchemaNode;
305
- }>;
260
+ nodes?: Array<CodeNode>;
306
261
  };
307
262
  /**
308
- * Object schema with ordered properties.
263
+ * AST node representing a TypeScript `function` declaration.
264
+ *
265
+ * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
266
+ * The `children` prop of the component is represented as `nodes`.
309
267
  *
310
268
  * @example
311
269
  * ```ts
312
- * const objectSchema: ObjectSchemaNode = {
313
- * kind: 'Schema',
314
- * type: 'object',
315
- * properties: [],
316
- * }
270
+ * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
271
+ * // export async function getPet(): Promise<Pet> { ... }
317
272
  * ```
318
273
  */
319
- type ObjectSchemaNode = SchemaNodeBase & {
274
+ type FunctionNode = BaseNode & {
275
+ kind: 'Function';
320
276
  /**
321
- * Schema type discriminator.
277
+ * Name of the function.
322
278
  */
323
- type: 'object';
279
+ name: string;
324
280
  /**
325
- * Primitive type, always `'object'` for object schemas.
281
+ * Whether the function is a default export.
326
282
  */
327
- primitive: 'object';
283
+ default?: boolean | null;
328
284
  /**
329
- * Ordered object properties.
285
+ * Function parameter list as a pre-rendered string, written verbatim between the parentheses.
286
+ *
287
+ * @example
288
+ * `'id: string, config: Config = {}'`
330
289
  */
331
- properties: Array<PropertyNode>;
290
+ params?: string | null;
332
291
  /**
333
- * Additional object properties behavior:
334
- * - `true`: allow any value
335
- * - `false`: reject unknown properties
336
- * - `SchemaNode`: allow values that match that schema
337
- * - `undefined`: no additional properties constraint (open object)
292
+ * Whether the function should be exported.
338
293
  */
339
- additionalProperties?: SchemaNode | boolean;
294
+ export?: boolean | null;
340
295
  /**
341
- * Pattern-based property schemas.
296
+ * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
342
297
  */
343
- patternProperties?: Record<string, SchemaNode>;
298
+ async?: boolean | null;
344
299
  /**
345
- * Schema that each property name must match.
300
+ * TypeScript generic type parameters.
346
301
  *
347
- * @example
348
- * ```ts
349
- * const objectSchema: ObjectSchemaNode = {
350
- * kind: 'Schema',
351
- * type: 'object',
352
- * primitive: 'object',
353
- * properties: [],
354
- * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },
355
- * }
356
- * ```
357
- */
358
- propertyNames?: SchemaNode;
359
- /**
360
- * Minimum number of properties allowed.
302
+ * @example Constrained generics
303
+ * `['T', 'U extends string']`
361
304
  */
362
- min?: number;
305
+ generics?: string | Array<string> | null;
363
306
  /**
364
- * Maximum number of properties allowed.
307
+ * Return type annotation.
308
+ *
309
+ * @example Type reference
310
+ * `'Pet'`
365
311
  */
366
- max?: number;
312
+ returnType?: string | null;
367
313
  /**
368
- * @deprecated Use `min`. Removed in Kubb v6.
314
+ * JSDoc documentation metadata.
369
315
  */
370
- minProperties?: number;
316
+ JSDoc?: JSDocNode | null;
371
317
  /**
372
- * @deprecated Use `max`. Removed in Kubb v6.
318
+ * Child nodes representing the function body (children of the `Function` component).
319
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
373
320
  */
374
- maxProperties?: number;
321
+ nodes?: Array<CodeNode>;
375
322
  };
376
323
  /**
377
- * Array-like schema (`array` or `tuple`).
324
+ * AST node representing a TypeScript arrow function (`const name = () => { ... }`).
325
+ *
326
+ * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
327
+ * The `children` prop of the component is represented as `nodes`.
378
328
  *
379
329
  * @example
380
330
  * ```ts
381
- * const arraySchema: ArraySchemaNode = {
382
- * kind: 'Schema',
383
- * type: 'array',
384
- * items: [],
385
- * }
331
+ * createArrowFunction({ name: 'getPet', export: true, singleLine: true })
332
+ * // export const getPet = () => ...
386
333
  * ```
387
334
  */
388
- type ArraySchemaNode = SchemaNodeBase & {
389
- /**
390
- * Schema type discriminator (`array` or `tuple`).
391
- */
392
- type: 'array' | 'tuple';
393
- /**
394
- * Item schemas.
395
- */
396
- items?: Array<SchemaNode>;
397
- /**
398
- * Tuple rest-item schema for elements beyond positional `items`.
399
- */
400
- rest?: SchemaNode;
401
- /**
402
- * Minimum item count (or tuple length).
403
- */
404
- min?: number;
405
- /**
406
- * Maximum item count (or tuple length).
407
- */
408
- max?: number;
409
- /**
410
- * Whether all items must be unique.
411
- */
412
- unique?: boolean;
335
+ type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {
336
+ kind: 'ArrowFunction';
413
337
  /**
414
- * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.
338
+ * Render the arrow function body as a single-line expression.
415
339
  */
416
- contains?: {
417
- schema: SchemaNode;
418
- min?: number;
419
- max?: number;
420
- };
340
+ singleLine?: boolean | null;
421
341
  };
422
342
  /**
423
- * Shared shape for union and intersection schemas.
343
+ * AST node representing a raw text/string fragment in the source output.
344
+ *
345
+ * Used instead of bare `string` values so that all entries in `nodes` arrays
346
+ * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
347
+ *
348
+ * @example
349
+ * ```ts
350
+ * createText('return fetch(id)')
351
+ * // { kind: 'Text', value: 'return fetch(id)' }
352
+ * ```
424
353
  */
425
- type CompositeSchemaNodeBase = SchemaNodeBase & {
354
+ type TextNode = BaseNode & {
355
+ kind: 'Text';
426
356
  /**
427
- * Member schemas.
357
+ * The raw string content.
428
358
  */
429
- members?: Array<SchemaNode>;
359
+ value: string;
430
360
  };
431
361
  /**
432
- * Union schema, often from `oneOf` or `anyOf`.
362
+ * AST node representing a blank line in the source output.
363
+ *
364
+ * Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two
365
+ * statements into one blank line. Consecutive breaks, and breaks at the start or end of
366
+ * the list, are folded away, so a `Break` never produces more than one blank line.
433
367
  *
434
368
  * @example
435
369
  * ```ts
436
- * const unionSchema: UnionSchemaNode = {
437
- * kind: 'Schema',
438
- * type: 'union',
439
- * members: [],
440
- * }
370
+ * createBreak()
371
+ * // { kind: 'Break' }
441
372
  * ```
442
373
  */
443
- type UnionSchemaNode = CompositeSchemaNodeBase & {
444
- /**
445
- * Schema type discriminator.
446
- */
447
- type: 'union';
448
- /**
449
- * Discriminator property name for a polymorphic union.
450
- */
451
- discriminatorPropertyName?: string;
452
- /**
453
- * How many union members must be valid.
454
- * - `'one'`: exactly one member, from `oneOf`
455
- * - `'any'`: any number of members, from `anyOf`
456
- */
457
- strategy?: 'one' | 'any';
374
+ type BreakNode = BaseNode & {
375
+ kind: 'Break';
458
376
  };
459
377
  /**
460
- * Intersection schema, often from `allOf`.
378
+ * AST node representing a raw JSX fragment in the source output.
379
+ *
380
+ * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup
381
+ * (including fragments `<>…</>`) directly in generated code.
461
382
  *
462
383
  * @example
463
384
  * ```ts
464
- * const intersectionSchema: IntersectionSchemaNode = {
465
- * kind: 'Schema',
466
- * type: 'intersection',
467
- * members: [],
468
- * }
385
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
386
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
469
387
  * ```
470
388
  */
471
- type IntersectionSchemaNode = CompositeSchemaNodeBase & {
389
+ type JsxNode = BaseNode & {
390
+ kind: 'Jsx';
472
391
  /**
473
- * Schema type discriminator.
392
+ * The raw JSX string content.
474
393
  */
475
- type: 'intersection';
476
- };
477
- /** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */
478
- type NotSchemaNode = CompositeSchemaNodeBase & {
479
- /** Schema type discriminator. */
480
- type: 'not';
394
+ value: string;
481
395
  };
482
396
  /**
483
- * One named enum item.
397
+ * Union of all code-generation AST nodes.
398
+ *
399
+ * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
400
+ * structured children in {@link SourceNode.nodes}.
484
401
  */
485
- type EnumValueNode = {
486
- /**
487
- * Enum item name.
488
- */
489
- name: string;
490
- /**
491
- * Enum item value.
492
- */
493
- value: string | number | boolean;
494
- /**
495
- * Primitive type of the enum value.
496
- */
497
- primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>;
498
- /**
499
- * Label for the enum item, taken from the `x-enumDescriptions` or
500
- * `x-enum-descriptions` vendor extension. `@kubb/plugin-ts` renders it as
501
- * JSDoc on the matching enum member.
502
- */
503
- description?: string;
504
- };
402
+ type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
505
403
  /**
506
- * Enum schema node.
404
+ * Creates a `ConstNode` representing a TypeScript `const` declaration.
507
405
  *
508
- * @example
406
+ * @example Exported constant with type and `as const`
509
407
  * ```ts
510
- * const enumSchema: EnumSchemaNode = {
511
- * kind: 'Schema',
512
- * type: 'enum',
513
- * enumValues: ['a', 'b'],
514
- * }
408
+ * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
409
+ * // export const pets: Pet[] = ... as const
515
410
  * ```
516
411
  */
517
- type EnumSchemaNode = SchemaNodeBase & {
518
- /**
519
- * Schema type discriminator.
520
- */
521
- type: 'enum';
522
- /**
523
- * Enum values in simple form.
524
- */
525
- enumValues?: Array<string | number | boolean | null>;
526
- /**
527
- * Enum values in named form.
528
- * If present, this is used instead of `enumValues`.
529
- */
530
- namedEnumValues?: Array<EnumValueNode>;
531
- };
412
+ declare const createConst: (input: Omit<ConstNode, "kind">) => ConstNode;
532
413
  /**
533
- * Reference schema that points to another schema definition.
414
+ * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
534
415
  *
535
416
  * @example
536
417
  * ```ts
537
- * const refSchema: RefSchemaNode = {
538
- * kind: 'Schema',
539
- * type: 'ref',
540
- * ref: '#/components/schemas/Pet',
541
- * }
418
+ * createType({ name: 'Pet', export: true })
419
+ * // export type Pet = ...
542
420
  * ```
543
421
  */
544
- type RefSchemaNode = SchemaNodeBase & {
545
- /**
546
- * Schema type discriminator.
547
- */
548
- type: 'ref';
549
- /**
550
- * Referenced schema name.
551
- * `null` means Kubb has processed this and determined there is no applicable name.
552
- */
553
- name?: string | null;
554
- /**
555
- * Original `$ref` path, for example, `#/components/schemas/Order`.
556
- * Used to resolve names later.
557
- */
558
- ref?: string;
559
- /**
560
- * Emitted name of the referenced schema when it differs from the pointer's last segment,
561
- * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.
562
- * Resolve display and import names through `resolveRefName`, which prefers this field and
563
- * falls back to the pointer segment, then `name`.
564
- */
565
- targetName?: string;
566
- /**
567
- * Pattern copied from a sibling `pattern` field.
568
- */
569
- pattern?: string;
570
- /**
571
- * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)
572
- * can be read without following the reference. Populated during parsing when the
573
- * definition resolves, `null` when it can't or the ref is circular, and `undefined` when
574
- * resolution has not been attempted.
575
- */
576
- schema?: SchemaNode | null;
577
- };
422
+ declare const createType: (input: Omit<TypeNode, "kind">) => TypeNode;
578
423
  /**
579
- * Datetime schema.
424
+ * Creates a `FunctionNode` representing a TypeScript `function` declaration.
580
425
  *
581
426
  * @example
582
427
  * ```ts
583
- * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }
428
+ * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
429
+ * // export async function fetchPet(): Promise<Pet> { ... }
584
430
  * ```
585
431
  */
586
- type DatetimeSchemaNode = SchemaNodeBase & {
587
- /**
588
- * Schema type discriminator.
589
- */
590
- type: 'datetime';
591
- /**
592
- * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).
593
- */
594
- offset?: boolean;
595
- /**
596
- * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).
597
- */
598
- local?: boolean;
599
- };
600
- /**
601
- * Shared base for `date` and `time` schemas.
602
- */
603
- type TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {
604
- /**
605
- * Schema type discriminator.
606
- */
607
- type: T;
608
- /**
609
- * Output representation in generated code.
610
- */
611
- representation: 'date' | 'string';
612
- };
432
+ declare const createFunction: (input: Omit<FunctionNode, "kind">) => FunctionNode;
613
433
  /**
614
- * Date schema node.
434
+ * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
615
435
  *
616
436
  * @example
617
437
  * ```ts
618
- * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }
438
+ * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
439
+ * // export const double = (n: number) => ...
619
440
  * ```
620
441
  */
621
- type DateSchemaNode = TemporalSchemaNodeBase<'date'>;
442
+ declare const createArrowFunction: (input: Omit<ArrowFunctionNode, "kind">) => ArrowFunctionNode;
622
443
  /**
623
- * Time schema node.
444
+ * Creates a {@link TextNode} representing a raw string fragment in the source output.
624
445
  *
625
446
  * @example
626
447
  * ```ts
627
- * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }
448
+ * createText('return fetch(id)')
449
+ * // { kind: 'Text', value: 'return fetch(id)' }
628
450
  * ```
629
451
  */
630
- type TimeSchemaNode = TemporalSchemaNodeBase<'time'>;
452
+ declare function createText(value: string): TextNode;
631
453
  /**
632
- * String schema node.
454
+ * Creates a {@link BreakNode} representing a line break in the source output.
633
455
  *
634
456
  * @example
635
457
  * ```ts
636
- * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }
458
+ * createBreak()
459
+ * // { kind: 'Break' }
637
460
  * ```
638
461
  */
639
- type StringSchemaNode = SchemaNodeBase & {
462
+ declare function createBreak(): BreakNode;
463
+ /**
464
+ * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
469
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
470
+ * ```
471
+ */
472
+ declare function createJsx(value: string): JsxNode;
473
+ /**
474
+ * Supported file extensions.
475
+ */
476
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
477
+ type ImportName = string | Array<string | {
478
+ propertyName: string;
479
+ name?: string;
480
+ }>;
481
+ /**
482
+ * Represents a language-agnostic import/dependency declaration.
483
+ *
484
+ * @example Named import (TypeScript: `import { useState } from 'react'`)
485
+ * ```ts
486
+ * createImport({ name: ['useState'], path: 'react' })
487
+ * ```
488
+ *
489
+ * @example Default import (TypeScript: `import React from 'react'`)
490
+ * ```ts
491
+ * createImport({ name: 'React', path: 'react' })
492
+ * ```
493
+ *
494
+ * @example Type-only import (TypeScript: `import type { FC } from 'react'`)
495
+ * ```ts
496
+ * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
497
+ * ```
498
+ *
499
+ * @example Namespace import (TypeScript: `import * as React from 'react'`)
500
+ * ```ts
501
+ * createImport({ name: 'React', path: 'react', isNameSpace: true })
502
+ * ```
503
+ */
504
+ type ImportNode = BaseNode & {
505
+ kind: 'Import';
640
506
  /**
641
- * Schema type discriminator.
507
+ * Import name(s) to be used.
508
+ *
509
+ * @example Named imports
510
+ * `['useState']`
511
+ *
512
+ * @example Default import
513
+ * `'React'`
642
514
  */
643
- type: 'string';
515
+ name: ImportName;
644
516
  /**
645
- * Minimum string length.
517
+ * Path for the import.
518
+ *
519
+ * @example
520
+ * `'@kubb/core'`
646
521
  */
647
- min?: number;
522
+ path: string;
648
523
  /**
649
- * Maximum string length.
524
+ * Add a type-only import prefix.
525
+ * - `true` generates `import type { Type } from './path'`
526
+ * - `false` generates `import { Type } from './path'`
650
527
  */
651
- max?: number;
528
+ isTypeOnly?: boolean | null;
652
529
  /**
653
- * Regex pattern.
530
+ * Import the entire module as a namespace.
531
+ * - `true` generates `import * as Name from './path'`
532
+ * - `false` generates a standard import
654
533
  */
655
- pattern?: string;
534
+ isNameSpace?: boolean | null;
656
535
  /**
657
- * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.
536
+ * When set, the import path is resolved relative to this root.
658
537
  */
659
- content?: {
660
- mediaType?: string;
661
- encoding?: string;
662
- schema?: SchemaNode;
663
- };
538
+ root?: string | null;
664
539
  };
665
540
  /**
666
- * Numeric schema (`number`, `integer`, or `bigint`).
541
+ * Represents a language-agnostic export/public API declaration.
667
542
  *
668
- * @example
543
+ * @example Named export (TypeScript: `export { Pets } from './Pets'`)
669
544
  * ```ts
670
- * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }
545
+ * createExport({ name: ['Pets'], path: './Pets' })
546
+ * ```
547
+ *
548
+ * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
549
+ * ```ts
550
+ * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
551
+ * ```
552
+ *
553
+ * @example Wildcard export (TypeScript: `export * from './utils'`)
554
+ * ```ts
555
+ * createExport({ path: './utils' })
556
+ * ```
557
+ *
558
+ * @example Namespace alias (TypeScript: `export * as utils from './utils'`)
559
+ * ```ts
560
+ * createExport({ name: 'utils', path: './utils', asAlias: true })
671
561
  * ```
672
562
  */
673
- type NumberSchemaNode = SchemaNodeBase & {
674
- /**
675
- * Schema type discriminator.
676
- */
677
- type: 'number' | 'integer' | 'bigint';
678
- /**
679
- * Minimum value.
680
- */
681
- min?: number;
682
- /**
683
- * Maximum value.
684
- */
685
- max?: number;
563
+ type ExportNode = BaseNode & {
564
+ kind: 'Export';
686
565
  /**
687
- * Bounds the value may not equal: it must be greater than `min` and less than `max`.
566
+ * Export name(s) to be used. When omitted, generates a wildcard export.
567
+ *
568
+ * @example Named exports
569
+ * `['useState']`
570
+ *
571
+ * @example Single export
572
+ * `'React'`
688
573
  */
689
- exclusive?: {
690
- min?: number;
691
- max?: number;
692
- };
574
+ name?: string | Array<string> | null;
693
575
  /**
694
- * @deprecated Use `exclusive.min`. Removed in Kubb v6.
576
+ * Path for the export.
577
+ *
578
+ * @example
579
+ * `'@kubb/core'`
695
580
  */
696
- exclusiveMinimum?: number;
581
+ path: string;
697
582
  /**
698
- * @deprecated Use `exclusive.max`. Removed in Kubb v6.
583
+ * Add a type-only export prefix.
584
+ * - `true` generates `export type { Type } from './path'`
585
+ * - `false` generates `export { Type } from './path'`
699
586
  */
700
- exclusiveMaximum?: number;
587
+ isTypeOnly?: boolean | null;
701
588
  /**
702
- * The value must be a multiple of this number.
589
+ * Export as an aliased namespace.
590
+ * - `true` generates `export * as aliasName from './path'`
591
+ * - `false` generates a standard export
703
592
  */
704
- multipleOf?: number;
593
+ asAlias?: boolean | null;
705
594
  };
706
595
  /**
707
- * Scalar schema with no extra constraints.
596
+ * Represents a fragment of source code within a file.
708
597
  *
709
- * @example
598
+ * @example Named exportable source
710
599
  * ```ts
711
- * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }
600
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
712
601
  * ```
713
- */
714
- type ScalarSchemaNode = SchemaNodeBase & {
715
- /**
716
- * Schema type discriminator.
717
- */
718
- type: ScalarSchemaType;
719
- };
720
- /**
721
- * URL schema node.
722
- * Can include a path template for template literal types.
723
602
  *
724
- * @example
603
+ * @example Inline unnamed code block
725
604
  * ```ts
726
- * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }
605
+ * createSource({ nodes: [createText('const x = 1')] })
727
606
  * ```
728
607
  */
729
- type UrlSchemaNode = SchemaNodeBase & {
608
+ type SourceNode = BaseNode & {
609
+ kind: 'Source';
730
610
  /**
731
- * Schema type discriminator.
611
+ * Optional name identifying this source (used for deduplication and barrel generation).
732
612
  */
733
- type: 'url';
613
+ name?: string | null;
734
614
  /**
735
- * Path template, for example, `'/pets/{petId}'`.
615
+ * Mark this source as a type-only export.
736
616
  */
737
- path?: string;
617
+ isTypeOnly?: boolean | null;
738
618
  /**
739
- * Minimum string length.
619
+ * Include the `export` keyword in the generated source.
740
620
  */
741
- min?: number;
621
+ isExportable?: boolean | null;
742
622
  /**
743
- * Maximum string length.
623
+ * Include this source in barrel/index file generation.
744
624
  */
745
- max?: number;
625
+ isIndexable?: boolean | null;
626
+ /**
627
+ * Marks the source as a definition that importing files absorb instead of import. `expression` is
628
+ * the declaration's right-hand side, such as `{ body: Pet }`.
629
+ */
630
+ inline?: {
631
+ expression: string;
632
+ } | null;
633
+ /**
634
+ * Child nodes that make up this source fragment, in DOM order.
635
+ * Use a {@link TextNode} for raw string content.
636
+ */
637
+ nodes?: Array<CodeNode>;
746
638
  };
747
639
  /**
748
- * Format-string schema for string-based formats that support length constraints.
640
+ * Represents a fully resolved file in the AST.
641
+ *
642
+ * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
643
+ * and deduplicates `imports`, `exports`, and `sources`.
749
644
  *
750
645
  * @example
751
646
  * ```ts
752
- * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }
647
+ * const file = createFile({
648
+ * baseName: 'petStore.ts',
649
+ * path: 'src/models/petStore.ts',
650
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
651
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
652
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
653
+ * })
654
+ * // file.id = SHA256 hash of the path
655
+ * // file.name = 'petStore'
656
+ * // file.extname = '.ts'
753
657
  * ```
754
658
  */
755
- type FormatStringSchemaNode = SchemaNodeBase & {
659
+ type FileNode<TMeta extends object = object> = BaseNode & {
660
+ kind: 'File';
756
661
  /**
757
- * Schema type discriminator.
662
+ * Unique identifier derived from a SHA256 hash of the file path. `createFile`
663
+ * computes it, so callers do not need to provide it.
758
664
  */
759
- type: 'uuid' | 'email';
665
+ id: string;
760
666
  /**
761
- * Minimum string length.
667
+ * File name without extension, derived from `baseName`.
668
+ *
669
+ * @see https://nodejs.org/api/path.html#pathformatpathobject
762
670
  */
763
- min?: number;
671
+ name: string;
764
672
  /**
765
- * Maximum string length.
673
+ * File base name, including extension, shaped like `${name}${extname}`.
674
+ *
675
+ * @see https://nodejs.org/api/path.html#pathbasenamepath-suffix
766
676
  */
767
- max?: number;
768
- };
769
- /**
770
- * Mapping from schema type literals to concrete schema node types.
771
- * Used by `narrowSchema`.
772
- */
773
- type SchemaNodeByType = {
774
- object: ObjectSchemaNode;
775
- array: ArraySchemaNode;
776
- tuple: ArraySchemaNode;
777
- union: UnionSchemaNode;
778
- intersection: IntersectionSchemaNode;
779
- not: NotSchemaNode;
780
- enum: EnumSchemaNode;
781
- ref: RefSchemaNode;
782
- datetime: DatetimeSchemaNode;
783
- date: DateSchemaNode;
784
- time: TimeSchemaNode;
785
- string: StringSchemaNode;
786
- number: NumberSchemaNode;
787
- integer: NumberSchemaNode;
788
- bigint: NumberSchemaNode;
789
- boolean: ScalarSchemaNode;
790
- null: ScalarSchemaNode;
791
- any: ScalarSchemaNode;
792
- unknown: ScalarSchemaNode;
793
- void: ScalarSchemaNode;
794
- never: ScalarSchemaNode;
795
- uuid: FormatStringSchemaNode;
796
- email: FormatStringSchemaNode;
797
- url: UrlSchemaNode;
798
- ipv4: ScalarSchemaNode;
799
- ipv6: ScalarSchemaNode;
800
- blob: ScalarSchemaNode;
677
+ baseName: `${string}.${string}`;
678
+ /**
679
+ * Full qualified path to the file.
680
+ */
681
+ path: string;
682
+ /**
683
+ * File extension extracted from `baseName`.
684
+ */
685
+ extname: Extname;
686
+ /**
687
+ * Deduplicated list of source code fragments.
688
+ */
689
+ sources: Array<SourceNode>;
690
+ /**
691
+ * Deduplicated list of import declarations.
692
+ */
693
+ imports: Array<ImportNode>;
694
+ /**
695
+ * Deduplicated list of export declarations.
696
+ */
697
+ exports: Array<ExportNode>;
698
+ /**
699
+ * Optional metadata attached to this file, read by plugins during barrel generation.
700
+ */
701
+ meta?: TMeta;
702
+ /**
703
+ * Optional banner prepended to the generated file content.
704
+ * Accepts `null` so `resolver.default.banner()` results can be passed directly.
705
+ */
706
+ banner?: string | null;
707
+ /**
708
+ * Optional footer appended to the generated file content.
709
+ * Accepts `null` so `resolver.default.footer()` results can be passed directly.
710
+ */
711
+ footer?: string | null;
712
+ /**
713
+ * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.
714
+ *
715
+ * Use to emit a real source file shipped inside a package (a template) into the generated
716
+ * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for
717
+ * output; `sources` may still carry `name`/`isExportable`/`isIndexable` so barrel generation
718
+ * treats the file the same as a rendered one.
719
+ */
720
+ copy?: string | null;
801
721
  };
802
722
  /**
803
- * Union of all schema node types.
723
+ * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
724
+ *
725
+ * @example Named import
726
+ * ```ts
727
+ * createImport({ name: ['useState'], path: 'react' })
728
+ * // import { useState } from 'react'
729
+ * ```
804
730
  */
805
- type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | NotSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | ScalarSchemaNode;
806
- type CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & {
807
- properties?: Array<PropertyNode>;
808
- primitive?: 'object';
809
- };
810
- type CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>;
811
- type CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & {
812
- kind: 'Schema';
813
- };
731
+ declare const createImport: (input: Omit<ImportNode, "kind">) => ImportNode;
814
732
  /**
815
- * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default
816
- * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.
733
+ * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
817
734
  *
818
- * @example
735
+ * @example Named export
819
736
  * ```ts
820
- * const scalar = createSchema({ type: 'string' })
821
- * // { kind: 'Schema', type: 'string', primitive: 'string' }
737
+ * createExport({ name: ['Pet'], path: './Pet' })
738
+ * // export { Pet } from './Pet'
822
739
  * ```
740
+ */
741
+ declare const createExport: (input: Omit<ExportNode, "kind">) => ExportNode;
742
+ /**
743
+ * Creates a `SourceNode` representing a fragment of source code within a file.
823
744
  *
824
745
  * @example
825
746
  * ```ts
826
- * const object = createSchema({ type: 'object' })
827
- * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }
747
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
828
748
  * ```
829
749
  */
830
- declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
831
- declare function createSchema(props: CreateSchemaInput): SchemaNode;
832
- /**
833
- * A variable declared by a server URL template.
834
- */
835
- type InputServerVariable = {
836
- default?: string;
837
- enum?: Array<string>;
838
- description?: string;
839
- };
840
- /**
841
- * A server from the source document, with `{variable}` placeholders filled from their defaults.
842
- */
843
- type InputServer = {
844
- url: string;
845
- name?: string;
846
- description?: string;
847
- /**
848
- * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
849
- * this tells a templated server apart from a literal one. Absent when the server declares none.
850
- */
851
- variables?: Record<string, InputServerVariable>;
852
- };
853
- type ExternalDocs = {
854
- url: string;
855
- description?: string;
856
- };
857
- type InputTag = {
858
- name: string;
859
- summary?: string;
860
- description?: string;
861
- /**
862
- * Name of the tag this tag nests under. `group: { type: 'tag' }` places its files in the parent's folder.
863
- */
864
- parent?: string;
865
- kind?: string;
866
- externalDocs?: ExternalDocs;
867
- };
868
- type OAuthFlow = {
869
- authorizationUrl?: string;
870
- deviceAuthorizationUrl?: string;
871
- tokenUrl?: string;
872
- refreshUrl?: string;
873
- scopes?: Record<string, string>;
874
- };
875
- /**
876
- * How a client sends a credential, in the same shape as the `Auth` object the generated clients pass to `auth`.
877
- */
878
- type AuthCredential = {
879
- type: 'http';
880
- scheme: 'bearer' | 'basic' | (string & {});
881
- bearerFormat?: string;
882
- } | {
883
- type: 'apiKey';
884
- in: 'header' | 'query' | 'cookie';
885
- name: string;
886
- } | {
887
- type: 'oauth2';
888
- flows: Record<string, OAuthFlow>;
889
- metadataUrl?: string;
890
- } | {
891
- type: 'openIdConnect';
892
- url?: string;
893
- } | {
894
- type: 'mutualTLS';
895
- };
896
- /**
897
- * One way to authenticate, keyed by `name`, which operations refer to in `auth`.
898
- */
899
- type AuthScheme = {
900
- name: string;
901
- description?: string;
902
- deprecated?: boolean;
903
- credential: AuthCredential;
904
- };
750
+ declare const createSource: (input: Omit<SourceNode, "kind">) => SourceNode;
905
751
  /**
906
- * One way to meet an operation's auth. Every scheme in it applies together. `scopes` are the OAuth2 or OpenID
907
- * Connect scopes the call needs. An empty list means the call may be sent without credentials.
752
+ * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed
753
+ * and `imports`/`exports`/`sources` are deduplicated.
908
754
  */
909
- type AuthRequirement = Array<{
910
- scheme: string;
911
- scopes?: Array<string>;
912
- }>;
755
+ type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> & Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>;
913
756
  /**
914
- * Metadata for an API document, populated by the adapter and available to every generator.
915
- * Every field is a plain JSON value.
757
+ * Creates a fully resolved `FileNode` from a file input descriptor.
758
+ *
759
+ * Computes:
760
+ * - `id` SHA256 hash of the file path
761
+ * - `name` `baseName` without extension
762
+ * - `extname` extension extracted from `baseName`
763
+ *
764
+ * Deduplicates:
765
+ * - `sources` via `combineSources`
766
+ * - `exports` via `combineExports`
767
+ * - `imports` via `combineImports` (also filters unused imports)
768
+ *
769
+ * @throws {Error} when `baseName` has no extension.
916
770
  *
917
771
  * @example
918
772
  * ```ts
919
- * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }
773
+ * const file = createFile({
774
+ * baseName: 'petStore.ts',
775
+ * path: 'src/models/petStore.ts',
776
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
777
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
778
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
779
+ * })
780
+ * // file.id = SHA256 hash of 'src/models/petStore.ts'
781
+ * // file.name = 'petStore'
782
+ * // file.extname = '.ts'
783
+ * ```
784
+ *
785
+ * @example Copy a real file into the output
786
+ * ```ts
787
+ * const file = createFile({
788
+ * baseName: 'client.ts',
789
+ * path: 'src/gen/client.ts',
790
+ * copy: '/abs/path/to/templates/client.ts',
791
+ * })
920
792
  * ```
921
793
  */
922
- type InputMeta = {
923
- /**
924
- * API title from `info.title` in the source document.
925
- */
926
- title?: string;
927
- /**
928
- * API description from `info.description` in the source document.
929
- */
930
- description?: string;
794
+ declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
795
+ type InlineFilesResult = {
931
796
  /**
932
- * API version string from `info.version` in the source document.
797
+ * Files that imported an inline name, rewritten to hold its definition.
933
798
  */
934
- version?: string;
935
- summary?: string;
936
- termsOfService?: string;
937
- contact?: {
938
- name?: string;
939
- url?: string;
940
- email?: string;
941
- };
942
- license?: {
943
- name: string;
944
- identifier?: string;
945
- url?: string;
946
- };
947
- externalDocs?: ExternalDocs;
799
+ files: Array<FileNode>;
948
800
  /**
949
- * Resolved base URL from the first matching server entry in the source document.
801
+ * Paths of the virtual files, which are not written.
950
802
  */
951
- baseURL?: string | null;
952
- servers?: Array<InputServer>;
953
- tags?: Array<InputTag>;
954
- auth?: Array<AuthScheme>;
803
+ virtualPaths: Array<string>;
955
804
  /**
956
- * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
805
+ * One message per name that could not be inlined.
957
806
  */
958
- extensions?: Record<string, unknown>;
807
+ problems: Array<{
808
+ path: string;
809
+ message: string;
810
+ }>;
959
811
  };
960
812
  /**
961
- * Input AST node that contains all schemas and operations for one API document.
962
- * Produced by the adapter and consumed by all Kubb plugins.
963
- *
964
- * @example
965
- * ```ts
966
- * const input: InputNode = {
967
- * kind: 'Input',
968
- * schemas: [],
969
- * operations: [],
970
- * meta: {},
971
- * }
972
- * ```
813
+ * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.
973
814
  */
974
- type InputNode = BaseNode & {
975
- /**
976
- * Node kind.
977
- */
978
- kind: 'Input';
815
+ type InlineLanguage = {
979
816
  /**
980
- * All schema nodes in the document.
817
+ * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.
981
818
  */
982
- schemas: Array<SchemaNode>;
819
+ replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string;
983
820
  /**
984
- * All operation nodes in the document.
821
+ * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.
985
822
  */
986
- operations: Array<OperationNode>;
823
+ wrap(expression: string): string;
824
+ };
825
+ type InlineFilesOptions = {
987
826
  /**
988
- * Document metadata populated by the adapter.
827
+ * The inline support for a file's language, or `undefined` when it has none.
989
828
  */
990
- meta: InputMeta;
829
+ language: (file: FileNode) => InlineLanguage | undefined;
991
830
  };
992
831
  /**
993
- * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
994
- * object. Every call allocates fresh defaults so no two inputs share them.
995
- *
996
- * @example
997
- * ```ts
998
- * const input = createInput()
999
- * // { kind: 'Input', schemas: [], operations: [] }
1000
- * ```
832
+ * Replaces every name a file imports from a virtual file (one whose sources are all inline, so it is never written) with that name's
833
+ * `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
1001
834
  */
1002
- declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
835
+ declare function inlineFiles$1(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
1003
836
  /**
1004
837
  * How one body property is serialized, from the `encoding` entry of its media type.
1005
838
  */
@@ -1420,7 +1253,7 @@ type GenericOperationNode = OperationNodeBase & {
1420
1253
  *
1421
1254
  * Discriminated on `protocol`: an {@link HttpOperationNode} (`protocol: 'http'`) guarantees
1422
1255
  * `method` and `path`, while a {@link GenericOperationNode} omits them. Narrow with
1423
- * `isHttpOperationNode(node)` or `node.protocol === 'http'` before reading `method`/`path`.
1256
+ * `ast.http.isOperation(node)` or `node.protocol === 'http'` before reading `method`/`path`.
1424
1257
  */
1425
1258
  type OperationNode = HttpOperationNode | GenericOperationNode;
1426
1259
  /**
@@ -1441,649 +1274,1007 @@ declare function createOperation(props: Pick<GenericOperationNode, 'operationId'
1441
1274
  requestBody?: Omit<RequestBodyNode, 'kind'>;
1442
1275
  }): GenericOperationNode;
1443
1276
  /**
1444
- * Narrows a `SchemaNode` to the variant that matches `type`.
1277
+ * A variable declared by a server URL template.
1278
+ */
1279
+ type InputServerVariable = {
1280
+ default?: string;
1281
+ enum?: Array<string>;
1282
+ description?: string;
1283
+ };
1284
+ /**
1285
+ * A server from the source document, with `{variable}` placeholders filled from their defaults.
1286
+ */
1287
+ type InputServer = {
1288
+ url: string;
1289
+ name?: string;
1290
+ description?: string;
1291
+ /**
1292
+ * Variables of the source URL template, copied as-is. `url` already has their defaults filled in, so
1293
+ * this tells a templated server apart from a literal one. Absent when the server declares none.
1294
+ */
1295
+ variables?: Record<string, InputServerVariable>;
1296
+ };
1297
+ type ExternalDocs = {
1298
+ url: string;
1299
+ description?: string;
1300
+ };
1301
+ type InputTag = {
1302
+ name: string;
1303
+ summary?: string;
1304
+ description?: string;
1305
+ /**
1306
+ * Name of the tag this tag nests under. `group: { type: 'tag' }` places its files in the parent's folder.
1307
+ */
1308
+ parent?: string;
1309
+ kind?: string;
1310
+ externalDocs?: ExternalDocs;
1311
+ };
1312
+ type OAuthFlow = {
1313
+ authorizationUrl?: string;
1314
+ deviceAuthorizationUrl?: string;
1315
+ tokenUrl?: string;
1316
+ refreshUrl?: string;
1317
+ scopes?: Record<string, string>;
1318
+ };
1319
+ /**
1320
+ * How a client sends a credential, in the same shape as the `Auth` object the generated clients pass to `auth`.
1321
+ */
1322
+ type AuthCredential = {
1323
+ type: 'http';
1324
+ scheme: 'bearer' | 'basic' | (string & {});
1325
+ bearerFormat?: string;
1326
+ } | {
1327
+ type: 'apiKey';
1328
+ in: 'header' | 'query' | 'cookie';
1329
+ name: string;
1330
+ } | {
1331
+ type: 'oauth2';
1332
+ flows: Record<string, OAuthFlow>;
1333
+ metadataUrl?: string;
1334
+ } | {
1335
+ type: 'openIdConnect';
1336
+ url?: string;
1337
+ } | {
1338
+ type: 'mutualTLS';
1339
+ };
1340
+ /**
1341
+ * One way to authenticate, keyed by `name`, which operations refer to in `auth`.
1342
+ */
1343
+ type AuthScheme = {
1344
+ name: string;
1345
+ description?: string;
1346
+ deprecated?: boolean;
1347
+ credential: AuthCredential;
1348
+ };
1349
+ /**
1350
+ * One way to meet an operation's auth. Every scheme in it applies together. `scopes` are the OAuth2 or OpenID
1351
+ * Connect scopes the call needs. An empty list means the call may be sent without credentials.
1352
+ */
1353
+ type AuthRequirement = Array<{
1354
+ scheme: string;
1355
+ scopes?: Array<string>;
1356
+ }>;
1357
+ /**
1358
+ * Metadata for an API document, populated by the adapter and available to every generator.
1359
+ * Every field is a plain JSON value.
1445
1360
  *
1446
1361
  * @example
1447
1362
  * ```ts
1448
- * const schema = createSchema({ type: 'string' })
1449
- * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null
1363
+ * const meta: InputMeta = { title: 'Pet Store', version: '1.0.0', baseURL: 'https://api.example.com/v2' }
1450
1364
  * ```
1451
1365
  */
1452
- export declare function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | null;
1366
+ type InputMeta = {
1367
+ /**
1368
+ * API title from `info.title` in the source document.
1369
+ */
1370
+ title?: string;
1371
+ /**
1372
+ * API description from `info.description` in the source document.
1373
+ */
1374
+ description?: string;
1375
+ /**
1376
+ * API version string from `info.version` in the source document.
1377
+ */
1378
+ version?: string;
1379
+ summary?: string;
1380
+ termsOfService?: string;
1381
+ contact?: {
1382
+ name?: string;
1383
+ url?: string;
1384
+ email?: string;
1385
+ };
1386
+ license?: {
1387
+ name: string;
1388
+ identifier?: string;
1389
+ url?: string;
1390
+ };
1391
+ externalDocs?: ExternalDocs;
1392
+ /**
1393
+ * Resolved base URL from the first matching server entry in the source document.
1394
+ */
1395
+ baseURL?: string | null;
1396
+ servers?: Array<InputServer>;
1397
+ tags?: Array<InputTag>;
1398
+ auth?: Array<AuthScheme>;
1399
+ /**
1400
+ * Vendor extensions (`x-*` keys) from the document root, copied as-is. Absent when the root has none.
1401
+ */
1402
+ extensions?: Record<string, unknown>;
1403
+ };
1453
1404
  /**
1454
- * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.
1405
+ * Input AST node that contains all schemas and operations for one API document.
1406
+ * Produced by the adapter and consumed by all Kubb plugins.
1455
1407
  *
1456
1408
  * @example
1457
1409
  * ```ts
1458
- * if (isHttpOperationNode(node)) {
1459
- * console.log(node.method, node.path)
1410
+ * const input: InputNode = {
1411
+ * kind: 'Input',
1412
+ * schemas: [],
1413
+ * operations: [],
1414
+ * meta: {},
1460
1415
  * }
1461
1416
  * ```
1462
1417
  */
1463
- export declare function isHttpOperationNode(node: OperationNode): node is HttpOperationNode;
1418
+ type InputNode = BaseNode & {
1419
+ /**
1420
+ * Node kind.
1421
+ */
1422
+ kind: 'Input';
1423
+ /**
1424
+ * All schema nodes in the document.
1425
+ */
1426
+ schemas: Array<SchemaNode>;
1427
+ /**
1428
+ * All operation nodes in the document.
1429
+ */
1430
+ operations: Array<OperationNode>;
1431
+ /**
1432
+ * Document metadata populated by the adapter.
1433
+ */
1434
+ meta: InputMeta;
1435
+ };
1464
1436
  /**
1465
- * JSDoc documentation metadata attached to code declarations.
1437
+ * Creates an `InputNode`, defaulting `schemas`/`operations` to empty arrays and `meta` to an empty
1438
+ * object. Every call allocates fresh defaults so no two inputs share them.
1439
+ *
1440
+ * @example
1441
+ * ```ts
1442
+ * const input = createInput()
1443
+ * // { kind: 'Input', schemas: [], operations: [] }
1444
+ * ```
1466
1445
  */
1467
- type JSDocNode = {
1446
+ declare function createInput(overrides?: Partial<Omit<InputNode, 'kind'>>): InputNode;
1447
+ /**
1448
+ * AST node representing one named object property.
1449
+ *
1450
+ * @example
1451
+ * ```ts
1452
+ * const property: PropertyNode = {
1453
+ * kind: 'Property',
1454
+ * name: 'id',
1455
+ * schema: createSchema({ type: 'integer' }),
1456
+ * required: true,
1457
+ * }
1458
+ * ```
1459
+ */
1460
+ type PropertyNode = BaseNode & {
1461
+ kind: 'Property';
1468
1462
  /**
1469
- * JSDoc comment lines. `undefined` entries are filtered out during rendering.
1470
- *
1471
- * @example
1472
- * ```ts
1473
- * ['@description A pet resource', '@deprecated']
1474
- * ```
1463
+ * Property key.
1475
1464
  */
1476
- comments?: Array<string | undefined>;
1465
+ name: string;
1466
+ /**
1467
+ * Property schema.
1468
+ */
1469
+ schema: SchemaNode;
1470
+ /**
1471
+ * Whether the property is required.
1472
+ */
1473
+ required: boolean;
1477
1474
  };
1478
1475
  /**
1479
- * AST node representing a TypeScript `const` declaration.
1480
- *
1481
- * Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
1482
- * The `children` prop of the component is represented as `nodes`.
1483
- *
1484
- * @example
1485
- * ```ts
1486
- * createConst({ name: 'pet', export: true, asConst: true })
1487
- * // export const pet = ... as const
1488
- * ```
1476
+ * Loosely-typed property accepted by `createProperty`, with `required` optional.
1477
+ */
1478
+ type UserPropertyNode = Pick<PropertyNode, 'name' | 'schema'> & Partial<Omit<PropertyNode, 'kind' | 'name' | 'schema'>>;
1479
+ /**
1480
+ * Creates a `PropertyNode`. `required` defaults to `false`, and the schema's
1481
+ * `optional`/`nullish` flags are derived from it.
1482
+ *
1483
+ * @example
1484
+ * ```ts
1485
+ * const property = createProperty({
1486
+ * name: 'status',
1487
+ * required: true,
1488
+ * schema: createSchema({ type: 'string', nullable: true }),
1489
+ * })
1490
+ * // required=true, no optional/nullish
1491
+ * ```
1492
+ */
1493
+ declare function createProperty(input: UserPropertyNode): PropertyNode;
1494
+ /**
1495
+ * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.
1496
+ */
1497
+ type PrimitiveSchemaType = 'string' | 'number' | 'integer' | 'bigint' | 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'object' | 'array' | 'date';
1498
+ /**
1499
+ * All schema type strings, one per key of {@link SchemaNodeByType}.
1500
+ */
1501
+ type SchemaType = keyof SchemaNodeByType;
1502
+ /**
1503
+ * Scalar schema types without extra object/array/ref structure or constraints.
1504
+ */
1505
+ type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6';
1506
+ /**
1507
+ * Fields shared by all schema nodes.
1489
1508
  */
1490
- type ConstNode = BaseNode & {
1491
- kind: 'Const';
1509
+ type SchemaNodeBase = BaseNode & {
1492
1510
  /**
1493
- * Name of the constant declaration.
1511
+ * Node kind.
1494
1512
  */
1495
- name: string;
1513
+ kind: 'Schema';
1496
1514
  /**
1497
- * Whether the declaration should be exported.
1515
+ * Schema name for named definitions (for example, `"Pet"`).
1516
+ * Inline schemas omit this field.
1517
+ * `null` means Kubb has processed this and determined there is no applicable name.
1518
+ * `undefined` means the name has not been set yet.
1498
1519
  */
1499
- export?: boolean | null;
1520
+ name?: string | null;
1500
1521
  /**
1501
- * Explicit type annotation.
1502
- *
1503
- * @example Type reference
1504
- * `'Pet'`
1522
+ * Short schema title.
1505
1523
  */
1506
- type?: string | null;
1524
+ title?: string;
1507
1525
  /**
1508
- * JSDoc documentation metadata.
1526
+ * Schema description text.
1509
1527
  */
1510
- JSDoc?: JSDocNode | null;
1528
+ description?: string;
1511
1529
  /**
1512
- * Whether to append `as const` to the declaration.
1530
+ * Whether `null` is allowed.
1513
1531
  */
1514
- asConst?: boolean | null;
1532
+ nullable?: boolean;
1515
1533
  /**
1516
- * Child nodes representing the value of the constant (children of the `Const` component).
1517
- * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
1534
+ * Whether the field is optional.
1518
1535
  */
1519
- nodes?: Array<CodeNode>;
1520
- };
1521
- /**
1522
- * AST node representing a TypeScript `type` alias declaration.
1523
- *
1524
- * Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
1525
- * The `children` prop of the component is represented as `nodes`.
1526
- *
1527
- * @example
1528
- * ```ts
1529
- * createType({ name: 'Pet', export: true })
1530
- * // export type Pet = ...
1531
- * ```
1532
- */
1533
- type TypeNode = BaseNode & {
1534
- kind: 'Type';
1536
+ optional?: boolean;
1535
1537
  /**
1536
- * Name of the type alias.
1538
+ * Both optional and nullable (`optional` + `nullable`).
1537
1539
  */
1538
- name: string;
1540
+ nullish?: boolean;
1539
1541
  /**
1540
- * Whether the declaration should be exported.
1542
+ * Whether the schema is deprecated.
1541
1543
  */
1542
- export?: boolean | null;
1544
+ deprecated?: boolean;
1543
1545
  /**
1544
- * JSDoc documentation metadata.
1546
+ * Whether the schema is read-only.
1545
1547
  */
1546
- JSDoc?: JSDocNode | null;
1548
+ readOnly?: boolean;
1547
1549
  /**
1548
- * Child nodes representing the type body (children of the `Type` component).
1549
- * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
1550
+ * Whether the schema is write-only.
1550
1551
  */
1551
- nodes?: Array<CodeNode>;
1552
+ writeOnly?: boolean;
1553
+ /**
1554
+ * Default value.
1555
+ */
1556
+ default?: unknown;
1557
+ /**
1558
+ * Example values from an `examples` array.
1559
+ */
1560
+ examples?: Array<unknown>;
1561
+ /**
1562
+ * Base primitive type.
1563
+ * For example, this is `'string'` for a `uuid` schema.
1564
+ */
1565
+ primitive?: PrimitiveSchemaType;
1566
+ /**
1567
+ * Schema `format` value.
1568
+ */
1569
+ format?: string;
1570
+ externalDocs?: ExternalDocs;
1571
+ /**
1572
+ * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means "key is present".
1573
+ * Visitors do not walk it.
1574
+ */
1575
+ conditionals?: Array<{
1576
+ if: SchemaNode;
1577
+ then?: SchemaNode;
1578
+ else?: SchemaNode;
1579
+ }>;
1552
1580
  };
1553
1581
  /**
1554
- * AST node representing a TypeScript `function` declaration.
1555
- *
1556
- * Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
1557
- * The `children` prop of the component is represented as `nodes`.
1582
+ * Object schema with ordered properties.
1558
1583
  *
1559
1584
  * @example
1560
1585
  * ```ts
1561
- * createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
1562
- * // export async function getPet(): Promise<Pet> { ... }
1586
+ * const objectSchema: ObjectSchemaNode = {
1587
+ * kind: 'Schema',
1588
+ * type: 'object',
1589
+ * properties: [],
1590
+ * }
1563
1591
  * ```
1564
1592
  */
1565
- type FunctionNode = BaseNode & {
1566
- kind: 'Function';
1593
+ type ObjectSchemaNode = SchemaNodeBase & {
1567
1594
  /**
1568
- * Name of the function.
1595
+ * Schema type discriminator.
1569
1596
  */
1570
- name: string;
1597
+ type: 'object';
1571
1598
  /**
1572
- * Whether the function is a default export.
1599
+ * Primitive type, always `'object'` for object schemas.
1573
1600
  */
1574
- default?: boolean | null;
1601
+ primitive: 'object';
1575
1602
  /**
1576
- * Function parameter list as a pre-rendered string, written verbatim between the parentheses.
1577
- *
1578
- * @example
1579
- * `'id: string, config: Config = {}'`
1603
+ * Ordered object properties.
1580
1604
  */
1581
- params?: string | null;
1605
+ properties: Array<PropertyNode>;
1582
1606
  /**
1583
- * Whether the function should be exported.
1607
+ * Additional object properties behavior:
1608
+ * - `true`: allow any value
1609
+ * - `false`: reject unknown properties
1610
+ * - `SchemaNode`: allow values that match that schema
1611
+ * - `undefined`: no additional properties constraint (open object)
1584
1612
  */
1585
- export?: boolean | null;
1613
+ additionalProperties?: SchemaNode | boolean;
1586
1614
  /**
1587
- * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
1615
+ * Pattern-based property schemas.
1588
1616
  */
1589
- async?: boolean | null;
1617
+ patternProperties?: Record<string, SchemaNode>;
1590
1618
  /**
1591
- * TypeScript generic type parameters.
1619
+ * Schema that each property name must match.
1592
1620
  *
1593
- * @example Constrained generics
1594
- * `['T', 'U extends string']`
1621
+ * @example
1622
+ * ```ts
1623
+ * const objectSchema: ObjectSchemaNode = {
1624
+ * kind: 'Schema',
1625
+ * type: 'object',
1626
+ * primitive: 'object',
1627
+ * properties: [],
1628
+ * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },
1629
+ * }
1630
+ * ```
1595
1631
  */
1596
- generics?: string | Array<string> | null;
1632
+ propertyNames?: SchemaNode;
1597
1633
  /**
1598
- * Return type annotation.
1599
- *
1600
- * @example Type reference
1601
- * `'Pet'`
1634
+ * Minimum number of properties allowed.
1602
1635
  */
1603
- returnType?: string | null;
1636
+ min?: number;
1604
1637
  /**
1605
- * JSDoc documentation metadata.
1638
+ * Maximum number of properties allowed.
1606
1639
  */
1607
- JSDoc?: JSDocNode | null;
1640
+ max?: number;
1608
1641
  /**
1609
- * Child nodes representing the function body (children of the `Function` component).
1610
- * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
1642
+ * @deprecated Use `min`. Removed in Kubb v6.
1611
1643
  */
1612
- nodes?: Array<CodeNode>;
1613
- };
1614
- /**
1615
- * AST node representing a TypeScript arrow function (`const name = () => { ... }`).
1616
- *
1617
- * Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
1618
- * The `children` prop of the component is represented as `nodes`.
1619
- *
1620
- * @example
1621
- * ```ts
1622
- * createArrowFunction({ name: 'getPet', export: true, singleLine: true })
1623
- * // export const getPet = () => ...
1624
- * ```
1625
- */
1626
- type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {
1627
- kind: 'ArrowFunction';
1644
+ minProperties?: number;
1628
1645
  /**
1629
- * Render the arrow function body as a single-line expression.
1646
+ * @deprecated Use `max`. Removed in Kubb v6.
1630
1647
  */
1631
- singleLine?: boolean | null;
1648
+ maxProperties?: number;
1632
1649
  };
1633
1650
  /**
1634
- * AST node representing a raw text/string fragment in the source output.
1635
- *
1636
- * Used instead of bare `string` values so that all entries in `nodes` arrays
1637
- * are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
1651
+ * Array-like schema (`array` or `tuple`).
1638
1652
  *
1639
1653
  * @example
1640
1654
  * ```ts
1641
- * createText('return fetch(id)')
1642
- * // { kind: 'Text', value: 'return fetch(id)' }
1655
+ * const arraySchema: ArraySchemaNode = {
1656
+ * kind: 'Schema',
1657
+ * type: 'array',
1658
+ * items: [],
1659
+ * }
1643
1660
  * ```
1644
1661
  */
1645
- type TextNode = BaseNode & {
1646
- kind: 'Text';
1662
+ type ArraySchemaNode = SchemaNodeBase & {
1647
1663
  /**
1648
- * The raw string content.
1664
+ * Schema type discriminator (`array` or `tuple`).
1649
1665
  */
1650
- value: string;
1651
- };
1652
- /**
1653
- * AST node representing a blank line in the source output.
1654
- *
1655
- * Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two
1656
- * statements into one blank line. Consecutive breaks, and breaks at the start or end of
1657
- * the list, are folded away, so a `Break` never produces more than one blank line.
1658
- *
1659
- * @example
1660
- * ```ts
1661
- * createBreak()
1662
- * // { kind: 'Break' }
1663
- * ```
1664
- */
1665
- type BreakNode = BaseNode & {
1666
- kind: 'Break';
1666
+ type: 'array' | 'tuple';
1667
+ /**
1668
+ * Item schemas.
1669
+ */
1670
+ items?: Array<SchemaNode>;
1671
+ /**
1672
+ * Tuple rest-item schema for elements beyond positional `items`.
1673
+ */
1674
+ rest?: SchemaNode;
1675
+ /**
1676
+ * Minimum item count (or tuple length).
1677
+ */
1678
+ min?: number;
1679
+ /**
1680
+ * Maximum item count (or tuple length).
1681
+ */
1682
+ max?: number;
1683
+ /**
1684
+ * Whether all items must be unique.
1685
+ */
1686
+ unique?: boolean;
1687
+ /**
1688
+ * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.
1689
+ */
1690
+ contains?: {
1691
+ schema: SchemaNode;
1692
+ min?: number;
1693
+ max?: number;
1694
+ };
1667
1695
  };
1668
1696
  /**
1669
- * AST node representing a raw JSX fragment in the source output.
1670
- *
1671
- * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup
1672
- * (including fragments `<>…</>`) directly in generated code.
1673
- *
1674
- * @example
1675
- * ```ts
1676
- * createJsx('<>\n <a href={href}>Open</a>\n</>')
1677
- * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
1678
- * ```
1697
+ * Shared shape for union and intersection schemas.
1679
1698
  */
1680
- type JsxNode = BaseNode & {
1681
- kind: 'Jsx';
1699
+ type CompositeSchemaNodeBase = SchemaNodeBase & {
1682
1700
  /**
1683
- * The raw JSX string content.
1701
+ * Member schemas.
1684
1702
  */
1685
- value: string;
1703
+ members?: Array<SchemaNode>;
1686
1704
  };
1687
1705
  /**
1688
- * Union of all code-generation AST nodes.
1689
- *
1690
- * These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
1691
- * structured children in {@link SourceNode.nodes}.
1692
- */
1693
- type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
1694
- /**
1695
- * Creates a `ConstNode` representing a TypeScript `const` declaration.
1696
- *
1697
- * @example Exported constant with type and `as const`
1698
- * ```ts
1699
- * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
1700
- * // export const pets: Pet[] = ... as const
1701
- * ```
1702
- */
1703
- declare const createConst: (input: Omit<ConstNode, "kind">) => ConstNode;
1704
- /**
1705
- * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
1706
+ * Union schema, often from `oneOf` or `anyOf`.
1706
1707
  *
1707
1708
  * @example
1708
1709
  * ```ts
1709
- * createType({ name: 'Pet', export: true })
1710
- * // export type Pet = ...
1710
+ * const unionSchema: UnionSchemaNode = {
1711
+ * kind: 'Schema',
1712
+ * type: 'union',
1713
+ * members: [],
1714
+ * }
1711
1715
  * ```
1712
1716
  */
1713
- declare const createType: (input: Omit<TypeNode, "kind">) => TypeNode;
1717
+ type UnionSchemaNode = CompositeSchemaNodeBase & {
1718
+ /**
1719
+ * Schema type discriminator.
1720
+ */
1721
+ type: 'union';
1722
+ /**
1723
+ * Discriminator property name for a polymorphic union.
1724
+ */
1725
+ discriminatorPropertyName?: string;
1726
+ /**
1727
+ * How many union members must be valid.
1728
+ * - `'one'`: exactly one member, from `oneOf`
1729
+ * - `'any'`: any number of members, from `anyOf`
1730
+ */
1731
+ strategy?: 'one' | 'any';
1732
+ };
1714
1733
  /**
1715
- * Creates a `FunctionNode` representing a TypeScript `function` declaration.
1734
+ * Intersection schema, often from `allOf`.
1716
1735
  *
1717
1736
  * @example
1718
1737
  * ```ts
1719
- * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
1720
- * // export async function fetchPet(): Promise<Pet> { ... }
1738
+ * const intersectionSchema: IntersectionSchemaNode = {
1739
+ * kind: 'Schema',
1740
+ * type: 'intersection',
1741
+ * members: [],
1742
+ * }
1721
1743
  * ```
1722
1744
  */
1723
- declare const createFunction: (input: Omit<FunctionNode, "kind">) => FunctionNode;
1745
+ type IntersectionSchemaNode = CompositeSchemaNodeBase & {
1746
+ /**
1747
+ * Schema type discriminator.
1748
+ */
1749
+ type: 'intersection';
1750
+ };
1751
+ /** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */
1752
+ type NotSchemaNode = CompositeSchemaNodeBase & {
1753
+ /** Schema type discriminator. */
1754
+ type: 'not';
1755
+ };
1724
1756
  /**
1725
- * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
1726
- *
1727
- * @example
1728
- * ```ts
1729
- * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
1730
- * // export const double = (n: number) => ...
1731
- * ```
1757
+ * One named enum item.
1732
1758
  */
1733
- declare const createArrowFunction: (input: Omit<ArrowFunctionNode, "kind">) => ArrowFunctionNode;
1759
+ type EnumValueNode = {
1760
+ /**
1761
+ * Enum item name.
1762
+ */
1763
+ name: string;
1764
+ /**
1765
+ * Enum item value.
1766
+ */
1767
+ value: string | number | boolean;
1768
+ /**
1769
+ * Primitive type of the enum value.
1770
+ */
1771
+ primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>;
1772
+ /**
1773
+ * Label for the enum item, taken from the `x-enumDescriptions` or
1774
+ * `x-enum-descriptions` vendor extension. `@kubb/plugin-ts` renders it as
1775
+ * JSDoc on the matching enum member.
1776
+ */
1777
+ description?: string;
1778
+ };
1734
1779
  /**
1735
- * Creates a {@link TextNode} representing a raw string fragment in the source output.
1780
+ * Enum schema node.
1736
1781
  *
1737
1782
  * @example
1738
1783
  * ```ts
1739
- * createText('return fetch(id)')
1740
- * // { kind: 'Text', value: 'return fetch(id)' }
1784
+ * const enumSchema: EnumSchemaNode = {
1785
+ * kind: 'Schema',
1786
+ * type: 'enum',
1787
+ * enumValues: ['a', 'b'],
1788
+ * }
1741
1789
  * ```
1742
1790
  */
1743
- declare function createText(value: string): TextNode;
1791
+ type EnumSchemaNode = SchemaNodeBase & {
1792
+ /**
1793
+ * Schema type discriminator.
1794
+ */
1795
+ type: 'enum';
1796
+ /**
1797
+ * Enum values in simple form.
1798
+ */
1799
+ enumValues?: Array<string | number | boolean | null>;
1800
+ /**
1801
+ * Enum values in named form.
1802
+ * If present, this is used instead of `enumValues`.
1803
+ */
1804
+ namedEnumValues?: Array<EnumValueNode>;
1805
+ };
1744
1806
  /**
1745
- * Creates a {@link BreakNode} representing a line break in the source output.
1807
+ * Reference schema that points to another schema definition.
1746
1808
  *
1747
1809
  * @example
1748
1810
  * ```ts
1749
- * createBreak()
1750
- * // { kind: 'Break' }
1811
+ * const refSchema: RefSchemaNode = {
1812
+ * kind: 'Schema',
1813
+ * type: 'ref',
1814
+ * ref: '#/components/schemas/Pet',
1815
+ * }
1751
1816
  * ```
1752
1817
  */
1753
- declare function createBreak(): BreakNode;
1818
+ type RefSchemaNode = SchemaNodeBase & {
1819
+ /**
1820
+ * Schema type discriminator.
1821
+ */
1822
+ type: 'ref';
1823
+ /**
1824
+ * Referenced schema name.
1825
+ * `null` means Kubb has processed this and determined there is no applicable name.
1826
+ */
1827
+ name?: string | null;
1828
+ /**
1829
+ * Original `$ref` path, for example, `#/components/schemas/Order`.
1830
+ * Used to resolve names later.
1831
+ */
1832
+ ref?: string;
1833
+ /**
1834
+ * Emitted name of the referenced schema when it differs from the pointer's last segment,
1835
+ * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.
1836
+ * Resolve display and import names through `ast.ref.getName`, which prefers this field and
1837
+ * falls back to the pointer segment, then `name`.
1838
+ */
1839
+ targetName?: string;
1840
+ /**
1841
+ * Pattern copied from a sibling `pattern` field.
1842
+ */
1843
+ pattern?: string;
1844
+ /**
1845
+ * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)
1846
+ * can be read without following the reference. Populated during parsing when the
1847
+ * definition resolves, `null` when it can't or the ref is circular, and `undefined` when
1848
+ * resolution has not been attempted.
1849
+ */
1850
+ schema?: SchemaNode | null;
1851
+ };
1754
1852
  /**
1755
- * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
1853
+ * Datetime schema.
1756
1854
  *
1757
1855
  * @example
1758
1856
  * ```ts
1759
- * createJsx('<>\n <a href={href}>Open</a>\n</>')
1760
- * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
1761
- * ```
1762
- */
1763
- declare function createJsx(value: string): JsxNode;
1764
- /**
1765
- * Supported file extensions.
1766
- */
1767
- type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
1768
- type ImportName = string | Array<string | {
1769
- propertyName: string;
1770
- name?: string;
1771
- }>;
1772
- /**
1773
- * Represents a language-agnostic import/dependency declaration.
1774
- *
1775
- * @example Named import (TypeScript: `import { useState } from 'react'`)
1776
- * ```ts
1777
- * createImport({ name: ['useState'], path: 'react' })
1778
- * ```
1779
- *
1780
- * @example Default import (TypeScript: `import React from 'react'`)
1781
- * ```ts
1782
- * createImport({ name: 'React', path: 'react' })
1783
- * ```
1784
- *
1785
- * @example Type-only import (TypeScript: `import type { FC } from 'react'`)
1786
- * ```ts
1787
- * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
1788
- * ```
1789
- *
1790
- * @example Namespace import (TypeScript: `import * as React from 'react'`)
1791
- * ```ts
1792
- * createImport({ name: 'React', path: 'react', isNameSpace: true })
1857
+ * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }
1793
1858
  * ```
1794
1859
  */
1795
- type ImportNode = BaseNode & {
1796
- kind: 'Import';
1860
+ type DatetimeSchemaNode = SchemaNodeBase & {
1797
1861
  /**
1798
- * Import name(s) to be used.
1799
- *
1800
- * @example Named imports
1801
- * `['useState']`
1802
- *
1803
- * @example Default import
1804
- * `'React'`
1862
+ * Schema type discriminator.
1805
1863
  */
1806
- name: ImportName;
1864
+ type: 'datetime';
1807
1865
  /**
1808
- * Path for the import.
1809
- *
1810
- * @example
1811
- * `'@kubb/core'`
1866
+ * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).
1812
1867
  */
1813
- path: string;
1868
+ offset?: boolean;
1814
1869
  /**
1815
- * Add a type-only import prefix.
1816
- * - `true` generates `import type { Type } from './path'`
1817
- * - `false` generates `import { Type } from './path'`
1870
+ * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).
1818
1871
  */
1819
- isTypeOnly?: boolean | null;
1872
+ local?: boolean;
1873
+ };
1874
+ /**
1875
+ * Shared base for `date` and `time` schemas.
1876
+ */
1877
+ type TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {
1820
1878
  /**
1821
- * Import the entire module as a namespace.
1822
- * - `true` generates `import * as Name from './path'`
1823
- * - `false` generates a standard import
1879
+ * Schema type discriminator.
1824
1880
  */
1825
- isNameSpace?: boolean | null;
1881
+ type: T;
1826
1882
  /**
1827
- * When set, the import path is resolved relative to this root.
1883
+ * Output representation in generated code.
1828
1884
  */
1829
- root?: string | null;
1885
+ representation: 'date' | 'string';
1830
1886
  };
1831
1887
  /**
1832
- * Represents a language-agnostic export/public API declaration.
1833
- *
1834
- * @example Named export (TypeScript: `export { Pets } from './Pets'`)
1835
- * ```ts
1836
- * createExport({ name: ['Pets'], path: './Pets' })
1837
- * ```
1888
+ * Date schema node.
1838
1889
  *
1839
- * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
1890
+ * @example
1840
1891
  * ```ts
1841
- * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
1892
+ * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }
1842
1893
  * ```
1894
+ */
1895
+ type DateSchemaNode = TemporalSchemaNodeBase<'date'>;
1896
+ /**
1897
+ * Time schema node.
1843
1898
  *
1844
- * @example Wildcard export (TypeScript: `export * from './utils'`)
1899
+ * @example
1845
1900
  * ```ts
1846
- * createExport({ path: './utils' })
1901
+ * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }
1847
1902
  * ```
1903
+ */
1904
+ type TimeSchemaNode = TemporalSchemaNodeBase<'time'>;
1905
+ /**
1906
+ * String schema node.
1848
1907
  *
1849
- * @example Namespace alias (TypeScript: `export * as utils from './utils'`)
1908
+ * @example
1850
1909
  * ```ts
1851
- * createExport({ name: 'utils', path: './utils', asAlias: true })
1910
+ * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }
1852
1911
  * ```
1853
1912
  */
1854
- type ExportNode = BaseNode & {
1855
- kind: 'Export';
1913
+ type StringSchemaNode = SchemaNodeBase & {
1856
1914
  /**
1857
- * Export name(s) to be used. When omitted, generates a wildcard export.
1858
- *
1859
- * @example Named exports
1860
- * `['useState']`
1861
- *
1862
- * @example Single export
1863
- * `'React'`
1915
+ * Schema type discriminator.
1864
1916
  */
1865
- name?: string | Array<string> | null;
1917
+ type: 'string';
1866
1918
  /**
1867
- * Path for the export.
1868
- *
1869
- * @example
1870
- * `'@kubb/core'`
1919
+ * Minimum string length.
1871
1920
  */
1872
- path: string;
1921
+ min?: number;
1873
1922
  /**
1874
- * Add a type-only export prefix.
1875
- * - `true` generates `export type { Type } from './path'`
1876
- * - `false` generates `export { Type } from './path'`
1923
+ * Maximum string length.
1877
1924
  */
1878
- isTypeOnly?: boolean | null;
1925
+ max?: number;
1879
1926
  /**
1880
- * Export as an aliased namespace.
1881
- * - `true` generates `export * as aliasName from './path'`
1882
- * - `false` generates a standard export
1927
+ * Regex pattern.
1883
1928
  */
1884
- asAlias?: boolean | null;
1929
+ pattern?: string;
1930
+ /**
1931
+ * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.
1932
+ */
1933
+ content?: {
1934
+ mediaType?: string;
1935
+ encoding?: string;
1936
+ schema?: SchemaNode;
1937
+ };
1885
1938
  };
1886
1939
  /**
1887
- * Represents a fragment of source code within a file.
1888
- *
1889
- * @example Named exportable source
1890
- * ```ts
1891
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
1892
- * ```
1940
+ * Numeric schema (`number`, `integer`, or `bigint`).
1893
1941
  *
1894
- * @example Inline unnamed code block
1942
+ * @example
1895
1943
  * ```ts
1896
- * createSource({ nodes: [createText('const x = 1')] })
1944
+ * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }
1897
1945
  * ```
1898
1946
  */
1899
- type SourceNode = BaseNode & {
1900
- kind: 'Source';
1947
+ type NumberSchemaNode = SchemaNodeBase & {
1901
1948
  /**
1902
- * Optional name identifying this source (used for deduplication and barrel generation).
1949
+ * Schema type discriminator.
1903
1950
  */
1904
- name?: string | null;
1951
+ type: 'number' | 'integer' | 'bigint';
1905
1952
  /**
1906
- * Mark this source as a type-only export.
1953
+ * Minimum value.
1907
1954
  */
1908
- isTypeOnly?: boolean | null;
1955
+ min?: number;
1909
1956
  /**
1910
- * Include the `export` keyword in the generated source.
1957
+ * Maximum value.
1911
1958
  */
1912
- isExportable?: boolean | null;
1959
+ max?: number;
1913
1960
  /**
1914
- * Include this source in barrel/index file generation.
1961
+ * Bounds the value may not equal: it must be greater than `min` and less than `max`.
1915
1962
  */
1916
- isIndexable?: boolean | null;
1963
+ exclusive?: {
1964
+ min?: number;
1965
+ max?: number;
1966
+ };
1917
1967
  /**
1918
- * Marks the source as a definition that importing files absorb instead of import. `expression` is
1919
- * the declaration's right-hand side, such as `{ body: Pet }`.
1968
+ * @deprecated Use `exclusive.min`. Removed in Kubb v6.
1920
1969
  */
1921
- inline?: {
1922
- expression: string;
1923
- } | null;
1970
+ exclusiveMinimum?: number;
1924
1971
  /**
1925
- * Child nodes that make up this source fragment, in DOM order.
1926
- * Use a {@link TextNode} for raw string content.
1972
+ * @deprecated Use `exclusive.max`. Removed in Kubb v6.
1927
1973
  */
1928
- nodes?: Array<CodeNode>;
1974
+ exclusiveMaximum?: number;
1975
+ /**
1976
+ * The value must be a multiple of this number.
1977
+ */
1978
+ multipleOf?: number;
1929
1979
  };
1930
1980
  /**
1931
- * Represents a fully resolved file in the AST.
1932
- *
1933
- * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
1934
- * and deduplicates `imports`, `exports`, and `sources`.
1981
+ * Scalar schema with no extra constraints.
1935
1982
  *
1936
1983
  * @example
1937
1984
  * ```ts
1938
- * const file = createFile({
1939
- * baseName: 'petStore.ts',
1940
- * path: 'src/models/petStore.ts',
1941
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
1942
- * imports: [createImport({ name: ['z'], path: 'zod' })],
1943
- * exports: [createExport({ name: ['Pet'], path: './petStore' })],
1944
- * })
1945
- * // file.id = SHA256 hash of the path
1946
- * // file.name = 'petStore'
1947
- * // file.extname = '.ts'
1985
+ * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }
1948
1986
  * ```
1949
1987
  */
1950
- type FileNode<TMeta extends object = object> = BaseNode & {
1951
- kind: 'File';
1952
- /**
1953
- * Unique identifier derived from a SHA256 hash of the file path. `createFile`
1954
- * computes it, so callers do not need to provide it.
1955
- */
1956
- id: string;
1957
- /**
1958
- * File name without extension, derived from `baseName`.
1959
- *
1960
- * @see https://nodejs.org/api/path.html#pathformatpathobject
1961
- */
1962
- name: string;
1963
- /**
1964
- * File base name, including extension, shaped like `${name}${extname}`.
1965
- *
1966
- * @see https://nodejs.org/api/path.html#pathbasenamepath-suffix
1967
- */
1968
- baseName: `${string}.${string}`;
1969
- /**
1970
- * Full qualified path to the file.
1971
- */
1972
- path: string;
1988
+ type ScalarSchemaNode = SchemaNodeBase & {
1973
1989
  /**
1974
- * File extension extracted from `baseName`.
1990
+ * Schema type discriminator.
1975
1991
  */
1976
- extname: Extname;
1992
+ type: ScalarSchemaType;
1993
+ };
1994
+ /**
1995
+ * URL schema node.
1996
+ * Can include a path template for template literal types.
1997
+ *
1998
+ * @example
1999
+ * ```ts
2000
+ * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }
2001
+ * ```
2002
+ */
2003
+ type UrlSchemaNode = SchemaNodeBase & {
1977
2004
  /**
1978
- * Deduplicated list of source code fragments.
2005
+ * Schema type discriminator.
1979
2006
  */
1980
- sources: Array<SourceNode>;
2007
+ type: 'url';
1981
2008
  /**
1982
- * Deduplicated list of import declarations.
2009
+ * Path template, for example, `'/pets/{petId}'`.
1983
2010
  */
1984
- imports: Array<ImportNode>;
2011
+ path?: string;
1985
2012
  /**
1986
- * Deduplicated list of export declarations.
2013
+ * Minimum string length.
1987
2014
  */
1988
- exports: Array<ExportNode>;
2015
+ min?: number;
1989
2016
  /**
1990
- * Optional metadata attached to this file, read by plugins during barrel generation.
2017
+ * Maximum string length.
1991
2018
  */
1992
- meta?: TMeta;
2019
+ max?: number;
2020
+ };
2021
+ /**
2022
+ * Format-string schema for string-based formats that support length constraints.
2023
+ *
2024
+ * @example
2025
+ * ```ts
2026
+ * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }
2027
+ * ```
2028
+ */
2029
+ type FormatStringSchemaNode = SchemaNodeBase & {
1993
2030
  /**
1994
- * Optional banner prepended to the generated file content.
1995
- * Accepts `null` so `resolver.default.banner()` results can be passed directly.
2031
+ * Schema type discriminator.
1996
2032
  */
1997
- banner?: string | null;
2033
+ type: 'uuid' | 'email';
1998
2034
  /**
1999
- * Optional footer appended to the generated file content.
2000
- * Accepts `null` so `resolver.default.footer()` results can be passed directly.
2035
+ * Minimum string length.
2001
2036
  */
2002
- footer?: string | null;
2037
+ min?: number;
2003
2038
  /**
2004
- * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.
2005
- *
2006
- * Use to emit a real source file shipped inside a package (a template) into the generated
2007
- * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for
2008
- * output; `sources` may still carry `name`/`isExportable`/`isIndexable` so barrel generation
2009
- * treats the file the same as a rendered one.
2039
+ * Maximum string length.
2010
2040
  */
2011
- copy?: string | null;
2041
+ max?: number;
2042
+ };
2043
+ /**
2044
+ * Mapping from schema type literals to concrete schema node types.
2045
+ * Used by `narrowSchema`.
2046
+ */
2047
+ type SchemaNodeByType = {
2048
+ object: ObjectSchemaNode;
2049
+ array: ArraySchemaNode;
2050
+ tuple: ArraySchemaNode;
2051
+ union: UnionSchemaNode;
2052
+ intersection: IntersectionSchemaNode;
2053
+ not: NotSchemaNode;
2054
+ enum: EnumSchemaNode;
2055
+ ref: RefSchemaNode;
2056
+ datetime: DatetimeSchemaNode;
2057
+ date: DateSchemaNode;
2058
+ time: TimeSchemaNode;
2059
+ string: StringSchemaNode;
2060
+ number: NumberSchemaNode;
2061
+ integer: NumberSchemaNode;
2062
+ bigint: NumberSchemaNode;
2063
+ boolean: ScalarSchemaNode;
2064
+ null: ScalarSchemaNode;
2065
+ any: ScalarSchemaNode;
2066
+ unknown: ScalarSchemaNode;
2067
+ void: ScalarSchemaNode;
2068
+ never: ScalarSchemaNode;
2069
+ uuid: FormatStringSchemaNode;
2070
+ email: FormatStringSchemaNode;
2071
+ url: UrlSchemaNode;
2072
+ ipv4: ScalarSchemaNode;
2073
+ ipv6: ScalarSchemaNode;
2074
+ blob: ScalarSchemaNode;
2012
2075
  };
2013
2076
  /**
2014
- * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
2077
+ * Union of all schema node types.
2078
+ */
2079
+ type SchemaNode = ObjectSchemaNode | ArraySchemaNode | UnionSchemaNode | IntersectionSchemaNode | NotSchemaNode | EnumSchemaNode | RefSchemaNode | DatetimeSchemaNode | DateSchemaNode | TimeSchemaNode | StringSchemaNode | NumberSchemaNode | UrlSchemaNode | FormatStringSchemaNode | ScalarSchemaNode;
2080
+ type CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & {
2081
+ properties?: Array<PropertyNode>;
2082
+ primitive?: 'object';
2083
+ };
2084
+ type CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>;
2085
+ type CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & {
2086
+ kind: 'Schema';
2087
+ };
2088
+ /**
2089
+ * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default
2090
+ * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.
2015
2091
  *
2016
- * @example Named import
2092
+ * @example
2017
2093
  * ```ts
2018
- * createImport({ name: ['useState'], path: 'react' })
2019
- * // import { useState } from 'react'
2094
+ * const scalar = createSchema({ type: 'string' })
2095
+ * // { kind: 'Schema', type: 'string', primitive: 'string' }
2096
+ * ```
2097
+ *
2098
+ * @example
2099
+ * ```ts
2100
+ * const object = createSchema({ type: 'object' })
2101
+ * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }
2020
2102
  * ```
2021
2103
  */
2022
- declare const createImport: (input: Omit<ImportNode, "kind">) => ImportNode;
2104
+ declare function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>;
2105
+ declare function createSchema(props: CreateSchemaInput): SchemaNode;
2023
2106
  /**
2024
- * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
2107
+ * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.
2108
+ * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
2109
+ * node identity, which lets `findCircularSchemas` and `ast.graph.containsCircular` share one scan per schema.
2025
2110
  *
2026
- * @example Named export
2111
+ * @example
2027
2112
  * ```ts
2028
- * createExport({ name: ['Pet'], path: './Pet' })
2029
- * // export { Pet } from './Pet'
2113
+ * collectSchemaRefs(petSchema)
2114
+ * // Set { 'Category', 'Tag' }
2030
2115
  * ```
2031
2116
  */
2032
- declare const createExport: (input: Omit<ExportNode, "kind">) => ExportNode;
2117
+ declare function collectSchemaRefs$1(node: SchemaNode): ReadonlySet<string>;
2033
2118
  /**
2034
- * Creates a `SourceNode` representing a fragment of source code within a file.
2119
+ * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in
2120
+ * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result
2121
+ * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.
2122
+ *
2123
+ * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the
2124
+ * same file (a union member created by name) is left out. That leaves exactly the set
2125
+ * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with
2126
+ * `checks: true`, for a plugin that prints those checks.
2035
2127
  *
2036
2128
  * @example
2037
2129
  * ```ts
2038
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
2130
+ * collectImportedRefNames(petSchema)
2131
+ * // ['Category', 'Tag']
2039
2132
  * ```
2040
2133
  */
2041
- declare const createSource: (input: Omit<SourceNode, "kind">) => SourceNode;
2134
+ declare function collectImportedRefNames$1(node: SchemaNode, { checks }?: {
2135
+ checks?: boolean;
2136
+ }): ReadonlyArray<string>;
2042
2137
  /**
2043
- * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed
2044
- * and `imports`/`exports`/`sources` are deduplicated.
2138
+ * Collects the names of all top-level schemas transitively used by a set of operations.
2139
+ *
2140
+ * An operation uses a schema when its parameters, request body, or responses reference it, directly
2141
+ * or through other named schemas. Once a name is added to the result it is not revisited, so
2142
+ * reference cycles terminate.
2143
+ *
2144
+ * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.
2145
+ *
2146
+ * @example Only generate schemas referenced by included operations
2147
+ * ```ts
2148
+ * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)
2149
+ * const allowed = collectUsedSchemaNames(includedOps, schemas)
2150
+ *
2151
+ * for (const schema of schemas) {
2152
+ * if (schema.name && !allowed.has(schema.name)) continue
2153
+ * // generate schema
2154
+ * }
2155
+ * ```
2045
2156
  */
2046
- type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> & Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>;
2157
+ declare function collectUsedSchemaNames$1(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
2047
2158
  /**
2048
- * Creates a fully resolved `FileNode` from a file input descriptor.
2159
+ * Finds every schema that takes part in a circular dependency chain, including direct self-loops.
2049
2160
  *
2050
- * Computes:
2051
- * - `id` SHA256 hash of the file path
2052
- * - `name` `baseName` without extension
2053
- * - `extname` extension extracted from `baseName`
2161
+ * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so
2162
+ * the generated code does not recurse forever. Refs are followed by name only, so the walk stays
2163
+ * linear in the size of the schema graph.
2054
2164
  *
2055
- * Deduplicates:
2056
- * - `sources` via `combineSources`
2057
- * - `exports` via `combineExports`
2058
- * - `imports` via `combineImports` (also filters unused imports)
2165
+ * @note Call this once on the full graph, then check individual schemas with `ast.graph.containsCircular()`.
2166
+ */
2167
+ declare function findCircularSchemas$1(schemas: ReadonlyArray<SchemaNode>): Set<string>;
2168
+ declare namespace index_d_exports$4 {
2169
+ export { containsCircular, findCircularSchemas$1 as getCircularNames, collectImportedRefNames$1 as getImportedNames, collectSchemaRefs$1 as getRefNames, collectUsedSchemaNames$1 as getUsedNames };
2170
+ }
2171
+ /** Whether a schema, or anything inside it, refers to one of `circularSchemas`, other than `excludeName`. */
2172
+ declare function containsCircular(node: SchemaNode | undefined, { circularSchemas, excludeName }: {
2173
+ circularSchemas: ReadonlySet<string>;
2174
+ excludeName?: string;
2175
+ }): boolean;
2176
+ /**
2177
+ * Narrows a `SchemaNode` to the variant that matches `type`.
2059
2178
  *
2060
- * @throws {Error} when `baseName` has no extension.
2179
+ * @example
2180
+ * ```ts
2181
+ * const schema = createSchema({ type: 'string' })
2182
+ * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null
2183
+ * ```
2184
+ */
2185
+ declare function narrowSchema$1<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | null;
2186
+ /**
2187
+ * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.
2061
2188
  *
2062
2189
  * @example
2063
2190
  * ```ts
2064
- * const file = createFile({
2065
- * baseName: 'petStore.ts',
2066
- * path: 'src/models/petStore.ts',
2067
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
2068
- * imports: [createImport({ name: ['z'], path: 'zod' })],
2069
- * exports: [createExport({ name: ['Pet'], path: './petStore' })],
2070
- * })
2071
- * // file.id = SHA256 hash of 'src/models/petStore.ts'
2072
- * // file.name = 'petStore'
2073
- * // file.extname = '.ts'
2191
+ * if (ast.http.isOperation(node)) {
2192
+ * console.log(node.method, node.path)
2193
+ * }
2074
2194
  * ```
2195
+ */
2196
+ declare function isHttpOperationNode$1(node: OperationNode): node is HttpOperationNode;
2197
+ declare namespace requestBody_d_exports {
2198
+ export { getSchema };
2199
+ }
2200
+ /** The schema of the first request body entry, else `undefined` when the operation takes no body. */
2201
+ declare function getSchema(node: Pick<OperationNode, 'requestBody'>): SchemaNode | undefined;
2202
+ declare namespace responses_d_exports {
2203
+ export { filterError, filterSuccess, findPrimary, getImportedNames };
2204
+ }
2205
+ /** The `4xx` and `5xx` responses, ranges included. */
2206
+ declare function filterError(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode>;
2207
+ /** The ref names the response bodies import, in order, with repeats. */
2208
+ declare function getImportedNames(responses: ReadonlyArray<ResponseNode>): Array<string>;
2209
+ declare function filterSuccess(node: Pick<HttpOperationNode, 'responses'>): Array<ResponseNode>;
2210
+ /** The success response a client returns: one with a body first, then an exact code over a `2xx` range. */
2211
+ declare function findPrimary(node: Pick<HttpOperationNode, 'responses'>): ResponseNode | null;
2212
+ declare namespace status_d_exports {
2213
+ export { statusClass as getClass, isError, isSuccess, toCode };
2214
+ }
2215
+ type StatusInput = StatusCode | number | (string & {}) | Pick<ResponseNode, 'statusCode'>;
2216
+ /** The class digit of a status code or range: `2` for `201` and `2xx`, `null` for `default`. */
2217
+ declare function statusClass(input: StatusInput): number | null;
2218
+ declare function isSuccess(statusCode: StatusInput): boolean;
2219
+ declare function isError(statusCode: StatusInput): boolean;
2220
+ /** One concrete code for a status or range: `200` for `2xx` and `default`, the code itself otherwise. */
2221
+ declare function toCode(input: StatusInput): number;
2222
+ declare namespace index_d_exports$5 {
2223
+ export { getBaseURL, groupParameters, isHttpOperationNode$1 as isOperation, requestBody_d_exports as requestBody, responses_d_exports as responses, status_d_exports as status };
2224
+ }
2225
+ /** The server's URL when it is absolute and has no template variables, else `undefined`. */
2226
+ declare function getBaseURL(server: InputServer | undefined): string | undefined;
2227
+ type ParameterGroups = Record<'path' | 'query' | 'header' | 'cookie', Array<ParameterNode>>;
2228
+ /** The operation's parameters by location, with a `querystring` parameter in `query`. A repeated name keeps its first parameter. */
2229
+ declare function groupParameters(node: Pick<HttpOperationNode, 'parameters'>): ParameterGroups;
2230
+ /**
2231
+ * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
2075
2232
  *
2076
- * @example Copy a real file into the output
2233
+ * @example
2077
2234
  * ```ts
2078
- * const file = createFile({
2079
- * baseName: 'client.ts',
2080
- * path: 'src/gen/client.ts',
2081
- * copy: '/abs/path/to/templates/client.ts',
2082
- * })
2235
+ * const target = resolveRef(refSchema)
2083
2236
  * ```
2084
2237
  */
2085
- declare function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta>;
2086
- declare namespace index_d_exports$1 {
2238
+ declare function resolveRef$1(node: SchemaNode): SchemaNode;
2239
+ /**
2240
+ * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.
2241
+ *
2242
+ * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field
2243
+ * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields
2244
+ * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`
2245
+ * is returned as is.
2246
+ *
2247
+ * @example
2248
+ * ```ts
2249
+ * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })
2250
+ * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'
2251
+ * ```
2252
+ */
2253
+ declare function mergeRefWithSchema$1(node: RefSchemaNode): SchemaNode;
2254
+ /**
2255
+ * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
2256
+ *
2257
+ * Modifiers inherited from the resolved schema are included in the check because a ref emits the
2258
+ * referenced schema variable with those modifiers already applied.
2259
+ */
2260
+ declare function isBareRef$1(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
2261
+ declare namespace index_d_exports$9 {
2262
+ export { getName, resolveRef$1 as getSchema, isBareRef$1 as isAlias, mergeSchema };
2263
+ }
2264
+ /** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */
2265
+ declare function mergeSchema(node: SchemaNode): SchemaNode;
2266
+ /**
2267
+ * The name a ref points at. A `$ref` string gives its last segment: `'#/components/schemas/Pet'` gives `'Pet'`.
2268
+ * A ref node gives its `targetName` first, so pass the node, not `node.ref`, to respect a renamed target. Other nodes give `null`.
2269
+ */
2270
+ declare function getName(ref: string): string;
2271
+ declare function getName(node: SchemaNode | null | undefined): string | null;
2272
+ /**
2273
+ * Generic JSON Schema optionality: a non-required field is optional, and a
2274
+ * non-required nullable field is nullish.
2275
+ */
2276
+ declare function applyOptionality(schema: SchemaNode, required: boolean): SchemaNode;
2277
+ declare namespace index_d_exports$2 {
2087
2278
  export { Node, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
2088
2279
  }
2089
2280
  /**
@@ -2223,7 +2414,7 @@ type CollectOptions<T> = VisitorOf<T> & TraversalOptions;
2223
2414
  * })
2224
2415
  * ```
2225
2416
  */
2226
- export declare function findSchema(node: Node, { predicate, followRefs }: {
2417
+ declare function findSchema$1(node: Node, { predicate, followRefs }: {
2227
2418
  predicate: (schema: SchemaNode) => boolean;
2228
2419
  followRefs?: boolean;
2229
2420
  }): SchemaNode | undefined;
@@ -2251,111 +2442,91 @@ export declare function findSchema(node: Node, { predicate, followRefs }: {
2251
2442
  * })
2252
2443
  * ```
2253
2444
  */
2254
- export declare function transform<T extends Node>(node: T, options: TransformOptions): T;
2445
+ declare function transform$1<T extends Node>(node: T, options: TransformOptions): T;
2255
2446
  /**
2256
- * Lazy depth-first collection pass. Yields every non-null value returned by
2257
- * the visitor callbacks. Use `collectSync` for the eager array form.
2447
+ * Depth-first collection pass. Gathers every non-null value the visitor
2448
+ * callbacks return into an array.
2258
2449
  *
2259
2450
  * @example Collect every operationId
2260
2451
  * ```ts
2261
- * const ids: string[] = []
2262
- * for (const id of collect<string>(root, {
2452
+ * const ids = collect<string>(root, {
2263
2453
  * operation(node) {
2264
2454
  * return node.operationId
2265
2455
  * },
2266
- * })) {
2267
- * ids.push(id)
2268
- * }
2456
+ * })
2269
2457
  * ```
2270
2458
  */
2271
- export declare function collect<T>(node: Node, options: CollectOptions<T>): Generator<T, void, undefined>;
2459
+ declare function collect$1<T>(node: Node, options: CollectOptions<T>): Array<T>;
2272
2460
  /**
2273
- * Eager depth-first collection pass. Gathers every non-null value the visitor
2274
- * callbacks return into an array.
2461
+ * Finds every matching property exposed by an object, resolved reference, or intersection.
2275
2462
  *
2276
- * @example Collect every operationId
2463
+ * References are followed through their parsed `schema`. Circular references terminate without
2464
+ * revisiting a node. Unions are not traversed because a property on one branch does not describe
2465
+ * every branch.
2466
+ *
2467
+ * @example Faker discriminator narrowing
2277
2468
  * ```ts
2278
- * const ids = collectSync<string>(root, {
2279
- * operation(node) {
2280
- * return node.operationId
2281
- * },
2282
- * })
2469
+ * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>
2470
+ * getSchemaLiteralValues(schema),
2471
+ * )
2472
+ * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`
2283
2473
  * ```
2284
- */
2285
- export declare function collectSync<T>(node: Node, options: CollectOptions<T>): Array<T>;
2286
- /**
2287
- * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
2288
- * and `undefined` keeps declaration order.
2289
- */
2290
- type Enforce = 'pre' | 'post';
2291
- /**
2292
- * Compares two `enforce` hints for `Array.prototype.sort`: `pre` first, unmarked next, `post`
2293
- * last. Equal hints compare as `0`, so a stable sort keeps authored order within a bucket.
2294
2474
  *
2295
- * @example
2296
- * `plugins.sort((a, b) => compareEnforce(a.enforce, b.enforce))`
2297
- */
2298
- export declare function compareEnforce(a?: Enforce, b?: Enforce): number;
2299
- /**
2300
- * A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
2301
- * {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
2302
- * optional `match` predicate. Macros run on the shared AST, so the same macro works across every
2303
- * adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
2304
- */
2305
- type Macro = Visitor & {
2306
- /**
2307
- * Macro identifier used to tell macros apart, for example `'dedupe-union'`.
2308
- */
2309
- name: string;
2310
- /**
2311
- * Ordering hint. `pre` macros run before unmarked macros, `post` macros run after.
2312
- * Ordering within a bucket follows list order.
2313
- */
2314
- enforce?: Enforce;
2315
- /**
2316
- * Predicate checked against the current node before any callback runs. Returning `false`
2317
- * skips the macro for that node.
2318
- */
2319
- match?: (node: Node) => boolean;
2320
- };
2321
- /**
2322
- * Types a macro for inference and a single construction site, mirroring `defineExtension`.
2323
- * Adds no runtime behavior.
2475
+ * @example Zod discriminated unions
2476
+ * ```ts
2477
+ * const canDiscriminate = union.members?.every(
2478
+ * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,
2479
+ * )
2480
+ * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`
2481
+ * ```
2324
2482
  *
2325
- * @example
2483
+ * @example TypeScript property lookup
2326
2484
  * ```ts
2327
- * const macroUntagged = defineMacro({
2328
- * name: 'untagged',
2329
- * operation(node) {
2330
- * return node.tags?.length ? undefined : { ...node, tags: ['untagged'] }
2331
- * },
2332
- * })
2485
+ * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })
2486
+ * const statusSchemas = properties.map((property) => print(property.schema))
2333
2487
  * ```
2334
2488
  */
2335
- export declare function defineMacro(macro: Macro): Macro;
2489
+ declare function resolveSchemaProperties$1({ node, propertyName }: {
2490
+ node: SchemaNode;
2491
+ propertyName: string;
2492
+ }): ReadonlyArray<PropertyNode>;
2336
2493
  /**
2337
- * Runs a list of macros over a node tree and returns the rewritten tree. Keeps `transform`'s
2338
- * structural sharing, so an empty or no-op macro list returns the same reference. Pass
2339
- * `depth: 'shallow'` to rewrite the root node only.
2494
+ * Reads the unique literal values represented by an enum, resolved reference, or union.
2340
2495
  *
2341
- * @example
2342
- * ```ts
2343
- * const next = applyMacros(root, [macroIntegerToString])
2344
- * ```
2496
+ * Named enum values take precedence over simple enum values, matching how renderers consume
2497
+ * `EnumSchemaNode`.
2345
2498
  *
2346
- * @example Apply to the root node only
2499
+ * @example
2347
2500
  * ```ts
2348
- * const named = applyMacros(node, [macroEnumName({ parentName, propName, enumSuffix })], { depth: 'shallow' })
2501
+ * const values = getSchemaLiteralValues(enumNode)
2502
+ * // ['cat', 'dog']
2349
2503
  * ```
2350
2504
  */
2351
- export declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
2352
- depth?: VisitorDepth;
2353
- }): TNode;
2505
+ declare function getSchemaLiteralValues$1(node: SchemaNode): ReadonlyArray<string | number | boolean | null>;
2354
2506
  /**
2355
- * Generic JSON Schema optionality: a non-required field is optional, and a
2356
- * non-required nullable field is nullish.
2507
+ * Infers an implicit discriminator: a property every member exposes with a distinct single
2508
+ * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.
2357
2509
  */
2358
- export declare function optionality(schema: SchemaNode, required: boolean): SchemaNode;
2510
+ declare function inferDiscriminatorPropertyName$1(members: ReadonlyArray<SchemaNode>): string | undefined;
2511
+ declare namespace index_d_exports$10 {
2512
+ export { applyOptionality, findSchema$1 as find, resolveSchemaProperties$1 as findProperties, getEmbeddedJson, getSchemaLiteralValues$1 as getLiterals, getNumberBounds, inferDiscriminatorPropertyName$1 as inferDiscriminator, isString, narrowSchema$1 as narrow, schemaTypes$1 as types };
2513
+ }
2514
+ /** The schema of the JSON document a string holds (`contentMediaType` with `contentSchema`), else `undefined`. */
2515
+ declare function getEmbeddedJson({ content }: Pick<StringSchemaNode, 'content'>): SchemaNode | undefined;
2516
+ /** Whether a schema prints as a plain `string`: string-like types, and `date` or `time` with a `'string'` representation. */
2517
+ declare function isString(node: SchemaNode): boolean;
2518
+ /**
2519
+ * The tightest inclusive bounds of a number schema. An exclusive bound moves to the next point of `step` (`1` for an
2520
+ * integer), an integer bound rounds inward, and an integer bound past `Number.MAX_SAFE_INTEGER` is left out, since it
2521
+ * prints as a rounded or invalid literal.
2522
+ */
2523
+ declare function getNumberBounds({ min, max, exclusive, integer, step }: Pick<NumberSchemaNode, 'min' | 'max' | 'exclusive'> & {
2524
+ integer?: boolean;
2525
+ step?: number;
2526
+ }): {
2527
+ min?: number;
2528
+ max?: number;
2529
+ };
2359
2530
  /**
2360
2531
  * Runtime context passed as `this` to printer handlers.
2361
2532
  *
@@ -2531,9 +2702,9 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
2531
2702
  *
2532
2703
  * @example Tiny Zod printer
2533
2704
  * ```ts
2534
- * import { createPrinter, type PrinterFactoryOptions } from '@kubb/ast'
2705
+ * import { ast, createPrinter } from '@kubb/kit'
2535
2706
  *
2536
- * type PrinterZod = PrinterFactoryOptions<'zod', { strict?: boolean }, string>
2707
+ * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>
2537
2708
  *
2538
2709
  * export const zodPrinter = createPrinter<PrinterZod>((options) => ({
2539
2710
  * name: 'zod',
@@ -2550,218 +2721,227 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
2550
2721
  * }))
2551
2722
  * ```
2552
2723
  */
2553
- export declare function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
2724
+ declare function createPrinter$1<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T>;
2554
2725
  /**
2555
- * Extracts all string content from a `CodeNode` tree recursively.
2726
+ * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
2727
+ * and `undefined` keeps declaration order.
2728
+ */
2729
+ type Enforce = 'pre' | 'post';
2730
+ /**
2731
+ * Compares two `enforce` hints for `Array.prototype.sort`: `pre` first, unmarked next, `post`
2732
+ * last. Equal hints compare as `0`, so a stable sort keeps authored order within a bucket.
2556
2733
  *
2557
- * Collects the text fields and nested node content, to build the source string for import filtering.
2734
+ * @example
2735
+ * `plugins.sort((a, b) => compareMacroOrder(a.enforce, b.enforce))`
2558
2736
  */
2559
- export declare function extractStringsFromNodes(nodes: Array<CodeNode> | undefined): string;
2560
- type InlineFilesResult = {
2561
- /**
2562
- * Files that imported an inline name, rewritten to hold its definition.
2563
- */
2564
- files: Array<FileNode>;
2565
- /**
2566
- * Paths of the virtual files, which are not written.
2567
- */
2568
- virtualPaths: Array<string>;
2569
- /**
2570
- * One message per name that could not be inlined.
2571
- */
2572
- problems: Array<{
2573
- path: string;
2574
- message: string;
2575
- }>;
2576
- };
2737
+ declare function compareMacroOrder(a?: Enforce, b?: Enforce): number;
2577
2738
  /**
2578
- * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.
2739
+ * A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
2740
+ * {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
2741
+ * optional `match` predicate. Macros run on the shared AST, so the same macro works across every
2742
+ * adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
2579
2743
  */
2580
- type InlineLanguage = {
2744
+ type Macro = Visitor & {
2581
2745
  /**
2582
- * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.
2746
+ * Macro identifier used to tell macros apart, for example `'dedupe-union'`.
2583
2747
  */
2584
- replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string;
2748
+ name: string;
2585
2749
  /**
2586
- * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.
2750
+ * Ordering hint. `pre` macros run before unmarked macros, `post` macros run after.
2751
+ * Ordering within a bucket follows list order.
2587
2752
  */
2588
- wrap(expression: string): string;
2589
- };
2590
- type InlineFilesOptions = {
2753
+ enforce?: Enforce;
2591
2754
  /**
2592
- * The inline support for a file's language, or `undefined` when it has none.
2755
+ * Predicate checked against the current node before any callback runs. Returning `false`
2756
+ * skips the macro for that node.
2593
2757
  */
2594
- language: (file: FileNode) => InlineLanguage | undefined;
2758
+ match?: (node: Node) => boolean;
2595
2759
  };
2596
2760
  /**
2597
- * Replaces every name a file imports from a virtual file (one whose sources are all inline, so it is never written) with that name's
2598
- * `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
2599
- */
2600
- export declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
2601
- /**
2602
- * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
2603
- * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
2604
- * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
2605
- */
2606
- export declare function refName(ref: string): string;
2607
- /**
2608
- * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when
2609
- * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,
2610
- * then `name`, then the nested `schema.name`.
2611
- *
2612
- * Returns `null` for non-ref nodes or when no name resolves.
2613
- *
2614
- * @example
2615
- * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`
2616
- *
2617
- * @example Collision-renamed target
2618
- * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`
2619
- */
2620
- export declare function resolveRefName(node: SchemaNode | null | undefined): string | null;
2621
- /**
2622
- * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
2623
- *
2624
- * @example
2625
- * ```ts
2626
- * const target = resolveRef(refSchema)
2627
- * ```
2628
- */
2629
- export declare function resolveRef(node: SchemaNode): SchemaNode;
2630
- /**
2631
- * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.
2632
- *
2633
- * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field
2634
- * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields
2635
- * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`
2636
- * is returned as is.
2637
- *
2638
- * @example
2639
- * ```ts
2640
- * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })
2641
- * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'
2642
- * ```
2643
- */
2644
- export declare function mergeRefWithSchema(node: RefSchemaNode): SchemaNode;
2645
- /**
2646
- * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
2647
- *
2648
- * Modifiers inherited from the resolved schema are included in the check because a ref emits the
2649
- * referenced schema variable with those modifiers already applied.
2650
- */
2651
- export declare function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
2652
- /**
2653
- * Collects the names of every schema a node's subtree references, resolved with `resolveRefName`.
2654
- * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
2655
- * node identity, which lets `findCircularSchemas` and `containsCircularRef` share one scan per schema.
2761
+ * Types a macro for inference and a single construction site, mirroring `defineExtension`.
2762
+ * Adds no runtime behavior.
2656
2763
  *
2657
2764
  * @example
2658
2765
  * ```ts
2659
- * collectSchemaRefs(petSchema)
2660
- * // Set { 'Category', 'Tag' }
2766
+ * const macroUntagged = defineMacro({
2767
+ * name: 'untagged',
2768
+ * operation(node) {
2769
+ * return node.tags?.length ? undefined : { ...node, tags: ['untagged'] }
2770
+ * },
2771
+ * })
2661
2772
  * ```
2662
2773
  */
2663
- export declare function collectSchemaRefs(node: SchemaNode): ReadonlySet<string>;
2774
+ declare function defineMacro$1(macro: Macro): Macro;
2664
2775
  /**
2665
- * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in
2666
- * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result
2667
- * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.
2668
- *
2669
- * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the
2670
- * same file (a union member created by name) is left out. That leaves exactly the set
2671
- * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with
2672
- * `checks: true`, for a plugin that prints those checks.
2776
+ * Runs a list of macros over a node tree and returns the rewritten tree. Keeps `transform`'s
2777
+ * structural sharing, so an empty or no-op macro list returns the same reference. Pass
2778
+ * `depth: 'shallow'` to rewrite the root node only.
2673
2779
  *
2674
2780
  * @example
2675
2781
  * ```ts
2676
- * collectImportedRefNames(petSchema)
2677
- * // ['Category', 'Tag']
2678
- * ```
2679
- */
2680
- export declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
2681
- checks?: boolean;
2682
- }): ReadonlyArray<string>;
2683
- /**
2684
- * Collects the names of all top-level schemas transitively used by a set of operations.
2685
- *
2686
- * An operation uses a schema when its parameters, request body, or responses reference it, directly
2687
- * or through other named schemas. Once a name is added to the result it is not revisited, so
2688
- * reference cycles terminate.
2689
- *
2690
- * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.
2691
- *
2692
- * @example Only generate schemas referenced by included operations
2693
- * ```ts
2694
- * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)
2695
- * const allowed = collectUsedSchemaNames(includedOps, schemas)
2696
- *
2697
- * for (const schema of schemas) {
2698
- * if (schema.name && !allowed.has(schema.name)) continue
2699
- * // generate schema
2700
- * }
2701
- * ```
2702
- */
2703
- export declare function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
2704
- /**
2705
- * Finds every schema that takes part in a circular dependency chain, including direct self-loops.
2706
- *
2707
- * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so
2708
- * the generated code does not recurse forever. Refs are followed by name only, so the walk stays
2709
- * linear in the size of the schema graph.
2710
- *
2711
- * @note Call this once on the full graph, then check individual schemas with `containsCircularRef()`.
2712
- */
2713
- export declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
2714
- /**
2715
- * Finds every matching property exposed by an object, resolved reference, or intersection.
2716
- *
2717
- * References are followed through their parsed `schema`. Circular references terminate without
2718
- * revisiting a node. Unions are not traversed because a property on one branch does not describe
2719
- * every branch.
2720
- *
2721
- * @example Faker discriminator narrowing
2722
- * ```ts
2723
- * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>
2724
- * getSchemaLiteralValues(schema),
2725
- * )
2726
- * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`
2727
- * ```
2728
- *
2729
- * @example Zod discriminated unions
2730
- * ```ts
2731
- * const canDiscriminate = union.members?.every(
2732
- * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,
2733
- * )
2734
- * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`
2735
- * ```
2736
- *
2737
- * @example TypeScript property lookup
2738
- * ```ts
2739
- * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })
2740
- * const statusSchemas = properties.map((property) => print(property.schema))
2782
+ * const next = applyMacros(root, [macroIntegerToString])
2741
2783
  * ```
2742
- */
2743
- export declare function resolveSchemaProperties({ node, propertyName }: {
2744
- node: SchemaNode;
2745
- propertyName: string;
2746
- }): ReadonlyArray<PropertyNode>;
2747
- /**
2748
- * Reads the unique literal values represented by an enum, resolved reference, or union.
2749
- *
2750
- * Named enum values take precedence over simple enum values, matching how renderers consume
2751
- * `EnumSchemaNode`.
2752
2784
  *
2753
- * @example
2785
+ * @example Apply to the root node only
2754
2786
  * ```ts
2755
- * const values = getSchemaLiteralValues(enumNode)
2756
- * // ['cat', 'dog']
2787
+ * const named = applyMacros(node, [macroEnumName({ parentName, propName, enumSuffix })], { depth: 'shallow' })
2757
2788
  * ```
2758
2789
  */
2759
- export declare function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<string | number | boolean | null>;
2790
+ declare function applyMacros$1<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
2791
+ depth?: VisitorDepth;
2792
+ }): TNode;
2793
+ declare namespace index_d_exports$6 {
2794
+ export { applyMacros$1 as apply, compareMacroOrder as compareOrder };
2795
+ }
2760
2796
  /**
2761
- * Infers an implicit discriminator: a property every member exposes with a distinct single
2762
- * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.
2797
+ * Extracts all string content from a `CodeNode` tree recursively.
2798
+ * Collects the text fields and nested node content, to build the source string for import filtering.
2763
2799
  */
2764
- export declare function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined;
2800
+ declare function getNodeText(nodes: Array<CodeNode> | undefined): string;
2801
+ declare namespace index_d_exports$8 {
2802
+ export { collect$1 as collect, getNodeText as getText, nodeKinds$1 as kinds, transform$1 as transform };
2803
+ }
2804
+ declare namespace index_d_exports$3 {
2805
+ export { inlineFiles$1 as inline };
2806
+ }
2807
+ /** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */
2808
+ export declare const isBareRef: typeof isBareRef$1;
2809
+ /** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */
2810
+ export declare const mergeRefWithSchema: typeof mergeRefWithSchema$1;
2811
+ /** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */
2812
+ export declare const refName: typeof getName;
2813
+ /** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */
2814
+ export declare const resolveRef: typeof resolveRef$1;
2815
+ /** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */
2816
+ export declare const resolveRefName: typeof getName;
2817
+ /** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */
2818
+ export declare const collectImportedRefNames: typeof collectImportedRefNames$1;
2819
+ /** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */
2820
+ export declare const collectSchemaRefs: typeof collectSchemaRefs$1;
2821
+ /** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */
2822
+ export declare const collectUsedSchemaNames: typeof collectUsedSchemaNames$1;
2823
+ /** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */
2824
+ export declare const findCircularSchemas: typeof findCircularSchemas$1;
2825
+ /** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */
2826
+ export declare const getSchemaLiteralValues: typeof getSchemaLiteralValues$1;
2827
+ /** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */
2828
+ export declare const inferDiscriminatorPropertyName: typeof inferDiscriminatorPropertyName$1;
2829
+ /** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */
2830
+ export declare const resolveSchemaProperties: typeof resolveSchemaProperties$1;
2831
+ /** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */
2832
+ export declare const isHttpOperationNode: typeof isHttpOperationNode$1;
2833
+ /** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */
2834
+ export declare const collectSync: typeof collect$1;
2835
+ /** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */
2836
+ export declare const optionality: typeof applyOptionality;
2837
+ /** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */
2838
+ export declare const extractStringsFromNodes: typeof getNodeText;
2839
+ /** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */
2840
+ export declare const compareEnforce: typeof compareMacroOrder;
2841
+ /** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */
2842
+ export declare const createPrinter: typeof createPrinter$1;
2843
+ /** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */
2844
+ export declare const defineMacro: typeof defineMacro$1;
2845
+ /** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */
2846
+ export declare const applyMacros: typeof applyMacros$1;
2847
+ /** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */
2848
+ export declare const nodeKinds: {
2849
+ readonly input: 'Input';
2850
+ readonly operation: 'Operation';
2851
+ readonly schema: 'Schema';
2852
+ readonly property: 'Property';
2853
+ readonly parameter: 'Parameter';
2854
+ readonly response: 'Response';
2855
+ readonly requestBody: 'RequestBody';
2856
+ readonly content: 'Content';
2857
+ readonly type: 'Type';
2858
+ readonly file: 'File';
2859
+ readonly import: 'Import';
2860
+ readonly export: 'Export';
2861
+ readonly source: 'Source';
2862
+ readonly const: 'Const';
2863
+ readonly function: 'Function';
2864
+ readonly arrowFunction: 'ArrowFunction';
2865
+ readonly text: 'Text';
2866
+ readonly break: 'Break';
2867
+ readonly jsx: 'Jsx';
2868
+ };
2869
+ /** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */
2870
+ export declare const schemaTypes: {
2871
+ readonly string: 'string';
2872
+ readonly number: 'number';
2873
+ readonly integer: 'integer';
2874
+ readonly bigint: 'bigint';
2875
+ readonly boolean: 'boolean';
2876
+ readonly null: 'null';
2877
+ readonly any: 'any';
2878
+ readonly unknown: 'unknown';
2879
+ readonly void: 'void';
2880
+ readonly object: 'object';
2881
+ readonly array: 'array';
2882
+ readonly tuple: 'tuple';
2883
+ readonly union: 'union';
2884
+ readonly intersection: 'intersection';
2885
+ readonly not: 'not';
2886
+ readonly enum: 'enum';
2887
+ readonly ref: 'ref';
2888
+ readonly date: 'date';
2889
+ readonly datetime: 'datetime';
2890
+ readonly time: 'time';
2891
+ readonly uuid: 'uuid';
2892
+ readonly email: 'email';
2893
+ readonly url: 'url';
2894
+ readonly ipv4: 'ipv4';
2895
+ readonly ipv6: 'ipv6';
2896
+ readonly blob: 'blob';
2897
+ readonly never: 'never';
2898
+ };
2899
+ /** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */
2900
+ export declare const findSchema: typeof findSchema$1;
2901
+ /** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */
2902
+ export declare const narrowSchema: typeof narrowSchema$1;
2903
+ /** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */
2904
+ export declare const transform: typeof transform$1;
2905
+ /** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */
2906
+ export declare const collect: typeof collect$1;
2907
+ /** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */
2908
+ export declare const inlineFiles: typeof inlineFiles$1;
2909
+ declare namespace index_d_exports$1 {
2910
+ export { ResolvedScheme, getRequirements };
2911
+ }
2912
+ /** One scheme of a resolved requirement, with the scopes the requirement asks for. */
2913
+ type ResolvedScheme = {
2914
+ name: string;
2915
+ credential: AuthCredential;
2916
+ scopes: Array<string>;
2917
+ };
2918
+ /** Joins each requirement with its schemes. Drops undeclared and repeated requirements, and keeps an empty one (no auth needed). */
2919
+ declare function getRequirements({ auth, schemes }: {
2920
+ auth: ReadonlyArray<AuthRequirement> | undefined;
2921
+ schemes: ReadonlyArray<AuthScheme> | undefined;
2922
+ }): Array<Array<ResolvedScheme>>;
2923
+ declare namespace index_d_exports$7 {
2924
+ export { getBase, isJson, isStream };
2925
+ }
2926
+ type MediaTypeInput = string | {
2927
+ contentType: string;
2928
+ };
2929
+ /** The media type without its parameters, in lower case: `Text/Plain; charset=utf-8` gives `text/plain`. */
2930
+ declare function getBase(mediaType: MediaTypeInput): string;
2931
+ /** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
2932
+ declare function isJson(mediaType: MediaTypeInput): boolean;
2933
+ /** Whether the media type is a stream of items: SSE, JSON Lines, or a `+json-seq` sequence. */
2934
+ declare function isStream(mediaType: MediaTypeInput): boolean;
2935
+ declare namespace index_d_exports$11 {
2936
+ export { get, groupByName };
2937
+ }
2938
+ /** The server at `index`, else the first one. */
2939
+ declare function get({ servers, index }: {
2940
+ servers: ReadonlyArray<InputServer> | undefined;
2941
+ index?: number;
2942
+ }): InputServer | undefined;
2943
+ /** Named servers by name. The first server with a name wins. */
2944
+ declare function groupByName(servers: ReadonlyArray<InputServer> | undefined): Map<string, InputServer>;
2765
2945
  /**
2766
2946
  * How `format: 'date-time'` schemas are represented downstream.
2767
2947
  * - `false` falls through to a plain `string` (no validation).
@@ -2829,7 +3009,7 @@ type ParserOptions = {
2829
3009
  enumSuffix: 'enum' | (string & {});
2830
3010
  };
2831
3011
  declare namespace index_d_exports {
2832
- export { ArraySchemaNode, ArrowFunctionNode, AuthCredential, AuthRequirement, AuthScheme, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, EncodingNode, Enforce, EnumSchemaNode, ExampleNode, ExportNode, ExternalDocs, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InlineLanguage, InputMeta, InputNode, InputServer, InputTag, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeKind, NotSchemaNode, NumberSchemaNode, OAuthFlow, ObjectSchemaNode, OperationNode, ParameterLocation, ParameterNode, ParameterStyle, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseLink, 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, compareEnforce, createPrinter, defineMacro, extractStringsFromNodes, index_d_exports$1 as factory, findCircularSchemas, findSchema, getSchemaLiteralValues, inferDiscriminatorPropertyName, inlineFiles, isBareRef, isHttpOperationNode, mergeRefWithSchema, narrowSchema, nodeKinds, optionality, refName, resolveRef, resolveRefName, resolveSchemaProperties, schemaTypes, transform };
3012
+ export { ArraySchemaNode, ArrowFunctionNode, AuthCredential, AuthRequirement, AuthScheme, BreakNode, CodeNode, ConstNode, ContentNode, DateOnlyTypeValue, DateSchemaNode, DateTimeTypeValue, DateTypeOptions, DatetimeSchemaNode, DistributiveOmit, EncodingNode, Enforce, EnumSchemaNode, ExampleNode, ExportNode, ExternalDocs, FileNode, FunctionNode, GenericOperationNode, HttpMethod, HttpOperationNode, ImportNode, InlineLanguage, InputMeta, InputNode, InputServer, InputTag, IntersectionSchemaNode, JSDocNode, JsxNode, Macro, Node, NodeKind, NotSchemaNode, NumberSchemaNode, OAuthFlow, ObjectSchemaNode, OperationNode, ParameterLocation, ParameterNode, ParameterStyle, ParserOptions, PrimitiveSchemaType, Printer, PrinterFactoryOptions, PrinterPartial, PropertyNode, RefSchemaNode, RequestBodyNode, ResponseLink, ResponseNode, ScalarSchemaNode, ScalarSchemaType, SchemaNode, SchemaNodeByType, SchemaType, SourceNode, StatusCode, StringSchemaNode, TextNode, TimeSchemaNode, TypeNode, UnionSchemaNode, UrlSchemaNode, UserFileNode, Visitor, VisitorContext, applyMacros, index_d_exports as ast, index_d_exports$1 as auth, collect, collectImportedRefNames, collectSchemaRefs, collectSync, collectUsedSchemaNames, compareEnforce, createPrinter, defineMacro, extractStringsFromNodes, index_d_exports$2 as factory, index_d_exports$3 as file, findCircularSchemas, findSchema, getSchemaLiteralValues, index_d_exports$4 as graph, index_d_exports$5 as http, inferDiscriminatorPropertyName, inlineFiles, isBareRef, isHttpOperationNode, index_d_exports$6 as macro, index_d_exports$7 as mediaType, mergeRefWithSchema, narrowSchema, index_d_exports$8 as node, nodeKinds, optionality, index_d_exports$9 as ref, refName, resolveRef, resolveRefName, resolveSchemaProperties, index_d_exports$10 as schema, schemaTypes, index_d_exports$11 as server, transform };
2833
3013
  }
2834
- export { type ArraySchemaNode, type ArrowFunctionNode, type AuthCredential, type AuthRequirement, type AuthScheme, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateOnlyTypeValue, type DateSchemaNode, type DateTimeTypeValue, type DateTypeOptions, type DatetimeSchemaNode, type DistributiveOmit, type EncodingNode, type Enforce, type EnumSchemaNode, type ExampleNode, type ExportNode, type ExternalDocs, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InlineLanguage, type InputMeta, type InputNode, type InputServer, type InputTag, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeKind, type NotSchemaNode, type NumberSchemaNode, type OAuthFlow, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseLink, 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 };
3014
+ export { type ArraySchemaNode, type ArrowFunctionNode, type AuthCredential, type AuthRequirement, type AuthScheme, type BreakNode, type CodeNode, type ConstNode, type ContentNode, type DateOnlyTypeValue, type DateSchemaNode, type DateTimeTypeValue, type DateTypeOptions, type DatetimeSchemaNode, type DistributiveOmit, type EncodingNode, type Enforce, type EnumSchemaNode, type ExampleNode, type ExportNode, type ExternalDocs, type FileNode, type FunctionNode, type GenericOperationNode, type HttpMethod, type HttpOperationNode, type ImportNode, type InlineLanguage, type InputMeta, type InputNode, type InputServer, type InputTag, type IntersectionSchemaNode, type JSDocNode, type JsxNode, type Macro, type Node, type NodeKind, type NotSchemaNode, type NumberSchemaNode, type OAuthFlow, type ObjectSchemaNode, type OperationNode, type ParameterLocation, type ParameterNode, type ParameterStyle, type ParserOptions, type PrimitiveSchemaType, type Printer, type PrinterFactoryOptions, type PrinterPartial, type PropertyNode, type RefSchemaNode, type RequestBodyNode, type ResponseLink, 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 auth, index_d_exports$2 as factory, index_d_exports$3 as file, index_d_exports$4 as graph, index_d_exports$5 as http, index_d_exports$6 as macro, index_d_exports$7 as mediaType, index_d_exports$8 as node, index_d_exports$9 as ref, index_d_exports$10 as schema, index_d_exports$11 as server };
2835
3015
  //# sourceMappingURL=index.d.ts.map