@kubb/ast 5.0.0-beta.58 → 5.0.0-beta.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +10 -0
  2. package/dist/casing-BE2R1RXg.cjs +88 -0
  3. package/dist/casing-BE2R1RXg.cjs.map +1 -0
  4. package/dist/extractStringsFromNodes-WMYJ8nQL.d.ts +82 -0
  5. package/dist/factory-BmcGBdeg.cjs +1251 -0
  6. package/dist/factory-BmcGBdeg.cjs.map +1 -0
  7. package/dist/factory-Du7nEP4B.js +282 -0
  8. package/dist/factory-Du7nEP4B.js.map +1 -0
  9. package/dist/factory.cjs +25 -28
  10. package/dist/factory.d.ts +3 -3
  11. package/dist/factory.js +3 -3
  12. package/dist/{ast-ClnJg9BN.d.ts → index-BzjwdK2M.d.ts} +74 -372
  13. package/dist/index.cjs +445 -46
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.ts +94 -59
  16. package/dist/index.js +7 -113
  17. package/dist/index.js.map +1 -1
  18. package/dist/operationParams-BZ07xDm0.d.ts +204 -0
  19. package/dist/response-DKxTr522.js +683 -0
  20. package/dist/response-DKxTr522.js.map +1 -0
  21. package/dist/{types-CB2oY8Dw.d.ts → types-olVl9v5p.d.ts} +222 -227
  22. package/dist/types.d.ts +4 -3
  23. package/dist/utils-BCtRXfhI.cjs +275 -0
  24. package/dist/utils-BCtRXfhI.cjs.map +1 -0
  25. package/dist/{utils-DN4XLVqz.js → utils-SdZU0F3H.js} +472 -1235
  26. package/dist/utils-SdZU0F3H.js.map +1 -0
  27. package/dist/utils.cjs +127 -22
  28. package/dist/utils.d.ts +112 -80
  29. package/dist/utils.js +3 -2
  30. package/package.json +1 -1
  31. package/src/constants.ts +8 -14
  32. package/src/dedupe.ts +8 -0
  33. package/src/factory.ts +1 -2
  34. package/src/guards.ts +1 -1
  35. package/src/index.ts +4 -13
  36. package/src/nodes/code.ts +29 -47
  37. package/src/nodes/content.ts +2 -2
  38. package/src/nodes/file.ts +28 -23
  39. package/src/nodes/function.ts +0 -15
  40. package/src/nodes/input.ts +6 -6
  41. package/src/nodes/operation.ts +1 -1
  42. package/src/nodes/parameter.ts +0 -3
  43. package/src/nodes/property.ts +0 -3
  44. package/src/nodes/requestBody.ts +3 -6
  45. package/src/nodes/schema.ts +3 -2
  46. package/src/printer.ts +1 -1
  47. package/src/registry.ts +31 -26
  48. package/src/signature.ts +3 -3
  49. package/src/transformers.ts +28 -1
  50. package/src/types.ts +2 -53
  51. package/src/utils/codegen.ts +104 -0
  52. package/src/utils/fileMerge.ts +184 -0
  53. package/src/utils/index.ts +7 -339
  54. package/src/utils/operationParams.ts +353 -0
  55. package/src/utils/refs.ts +112 -0
  56. package/src/utils/schemaGraph.ts +169 -0
  57. package/src/utils/strings.ts +139 -0
  58. package/src/visitor.ts +43 -19
  59. package/dist/extractStringsFromNodes-Bn9cOos9.d.ts +0 -14
  60. package/dist/factory-C5gHvtLU.js +0 -138
  61. package/dist/factory-C5gHvtLU.js.map +0 -1
  62. package/dist/factory-JN-Ylfl6.cjs +0 -155
  63. package/dist/factory-JN-Ylfl6.cjs.map +0 -1
  64. package/dist/utils-C8bWAzhv.cjs +0 -2696
  65. package/dist/utils-C8bWAzhv.cjs.map +0 -1
  66. package/dist/utils-DN4XLVqz.js.map +0 -1
  67. package/src/utils/ast.ts +0 -816
@@ -128,7 +128,11 @@ declare function defineNode<TNode extends BaseNode, TInput = Omit<TNode, 'kind'>
128
128
  type JSDocNode = {
129
129
  /**
130
130
  * JSDoc comment lines. `undefined` entries are filtered out during rendering.
131
- * @example ['@description A pet resource', '@deprecated']
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * ['@description A pet resource', '@deprecated']
135
+ * ```
132
136
  */
133
137
  comments?: Array<string | undefined>;
134
138
  };
@@ -145,9 +149,6 @@ type JSDocNode = {
145
149
  * ```
146
150
  */
147
151
  type ConstNode = BaseNode & {
148
- /**
149
- * Node kind.
150
- */
151
152
  kind: 'Const';
152
153
  /**
153
154
  * Name of the constant declaration.
@@ -155,12 +156,13 @@ type ConstNode = BaseNode & {
155
156
  name: string;
156
157
  /**
157
158
  * Whether the declaration should be exported.
158
- * @default false
159
159
  */
160
160
  export?: boolean | null;
161
161
  /**
162
- * Optional explicit type annotation.
163
- * @example 'Pet'
162
+ * Explicit type annotation.
163
+ *
164
+ * @example Type reference
165
+ * `'Pet'`
164
166
  */
165
167
  type?: string | null;
166
168
  /**
@@ -169,12 +171,11 @@ type ConstNode = BaseNode & {
169
171
  JSDoc?: JSDocNode | null;
170
172
  /**
171
173
  * Whether to append `as const` to the declaration.
172
- * @default false
173
174
  */
174
175
  asConst?: boolean | null;
175
176
  /**
176
177
  * Child nodes representing the value of the constant (children of the `Const` component).
177
- * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
178
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
178
179
  */
179
180
  nodes?: Array<CodeNode>;
180
181
  };
@@ -191,9 +192,6 @@ type ConstNode = BaseNode & {
191
192
  * ```
192
193
  */
193
194
  type TypeNode = BaseNode & {
194
- /**
195
- * Node kind.
196
- */
197
195
  kind: 'Type';
198
196
  /**
199
197
  * Name of the type alias.
@@ -201,7 +199,6 @@ type TypeNode = BaseNode & {
201
199
  name: string;
202
200
  /**
203
201
  * Whether the declaration should be exported.
204
- * @default false
205
202
  */
206
203
  export?: boolean | null;
207
204
  /**
@@ -210,7 +207,7 @@ type TypeNode = BaseNode & {
210
207
  JSDoc?: JSDocNode | null;
211
208
  /**
212
209
  * Child nodes representing the type body (children of the `Type` component).
213
- * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
210
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
214
211
  */
215
212
  nodes?: Array<CodeNode>;
216
213
  };
@@ -227,9 +224,6 @@ type TypeNode = BaseNode & {
227
224
  * ```
228
225
  */
229
226
  type FunctionNode = BaseNode & {
230
- /**
231
- * Node kind.
232
- */
233
227
  kind: 'Function';
234
228
  /**
235
229
  * Name of the function.
@@ -237,7 +231,6 @@ type FunctionNode = BaseNode & {
237
231
  name: string;
238
232
  /**
239
233
  * Whether the function is a default export.
240
- * @default false
241
234
  */
242
235
  default?: boolean | null;
243
236
  /**
@@ -246,22 +239,24 @@ type FunctionNode = BaseNode & {
246
239
  params?: string | null;
247
240
  /**
248
241
  * Whether the function should be exported.
249
- * @default false
250
242
  */
251
243
  export?: boolean | null;
252
244
  /**
253
245
  * Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
254
- * @default false
255
246
  */
256
247
  async?: boolean | null;
257
248
  /**
258
249
  * TypeScript generic type parameters.
259
- * @example ['T', 'U extends string']
250
+ *
251
+ * @example Constrained generics
252
+ * `['T', 'U extends string']`
260
253
  */
261
254
  generics?: string | Array<string> | null;
262
255
  /**
263
256
  * Return type annotation.
264
- * @example 'Pet'
257
+ *
258
+ * @example Type reference
259
+ * `'Pet'`
265
260
  */
266
261
  returnType?: string | null;
267
262
  /**
@@ -270,7 +265,7 @@ type FunctionNode = BaseNode & {
270
265
  JSDoc?: JSDocNode | null;
271
266
  /**
272
267
  * Child nodes representing the function body (children of the `Function` component).
273
- * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
268
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
274
269
  */
275
270
  nodes?: Array<CodeNode>;
276
271
  };
@@ -287,9 +282,6 @@ type FunctionNode = BaseNode & {
287
282
  * ```
288
283
  */
289
284
  type ArrowFunctionNode = BaseNode & {
290
- /**
291
- * Node kind.
292
- */
293
285
  kind: 'ArrowFunction';
294
286
  /**
295
287
  * Name of the arrow function (used as the `const` variable name).
@@ -297,7 +289,6 @@ type ArrowFunctionNode = BaseNode & {
297
289
  name: string;
298
290
  /**
299
291
  * Whether the function is a default export.
300
- * @default false
301
292
  */
302
293
  default?: boolean | null;
303
294
  /**
@@ -306,22 +297,24 @@ type ArrowFunctionNode = BaseNode & {
306
297
  params?: string | null;
307
298
  /**
308
299
  * Whether the arrow function should be exported.
309
- * @default false
310
300
  */
311
301
  export?: boolean | null;
312
302
  /**
313
303
  * Whether the arrow function is async. When `true`, the return type is wrapped in `Promise<>`.
314
- * @default false
315
304
  */
316
305
  async?: boolean | null;
317
306
  /**
318
307
  * TypeScript generic type parameters.
319
- * @example ['T', 'U extends string']
308
+ *
309
+ * @example Constrained generics
310
+ * `['T', 'U extends string']`
320
311
  */
321
312
  generics?: string | Array<string> | null;
322
313
  /**
323
314
  * Return type annotation.
324
- * @example 'Pet'
315
+ *
316
+ * @example Type reference
317
+ * `'Pet'`
325
318
  */
326
319
  returnType?: string | null;
327
320
  /**
@@ -330,12 +323,11 @@ type ArrowFunctionNode = BaseNode & {
330
323
  JSDoc?: JSDocNode | null;
331
324
  /**
332
325
  * Render the arrow function body as a single-line expression.
333
- * @default false
334
326
  */
335
327
  singleLine?: boolean | null;
336
328
  /**
337
329
  * Child nodes representing the function body (children of the `Function.Arrow` component).
338
- * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
330
+ * Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
339
331
  */
340
332
  nodes?: Array<CodeNode>;
341
333
  };
@@ -352,9 +344,6 @@ type ArrowFunctionNode = BaseNode & {
352
344
  * ```
353
345
  */
354
346
  type TextNode = BaseNode & {
355
- /**
356
- * Node kind.
357
- */
358
347
  kind: 'Text';
359
348
  /**
360
349
  * The raw string content.
@@ -364,9 +353,8 @@ type TextNode = BaseNode & {
364
353
  /**
365
354
  * AST node representing a line break in the source output.
366
355
  *
367
- * Corresponds to `<br/>` in JSX components. When printed, produces an empty
368
- * string that, joined with `\n` by `printNodes` creates a blank line
369
- * between surrounding code nodes.
356
+ * Corresponds to `<br/>` in JSX components. When printed it produces an empty string,
357
+ * so joining nodes with `\n` in `printNodes` leaves a blank line between the surrounding code.
370
358
  *
371
359
  * @example
372
360
  * ```ts
@@ -376,16 +364,13 @@ type TextNode = BaseNode & {
376
364
  * ```
377
365
  */
378
366
  type BreakNode = BaseNode & {
379
- /**
380
- * Node kind.
381
- */
382
367
  kind: 'Break';
383
368
  };
384
369
  /**
385
370
  * AST node representing a raw JSX fragment in the source output.
386
371
  *
387
- * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Use this to embed raw
388
- * JSX/TSX markup (including fragments `<>…</>`) directly in generated code.
372
+ * Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup
373
+ * (including fragments `<>…</>`) directly in generated code.
389
374
  *
390
375
  * @example
391
376
  * ```ts
@@ -394,9 +379,6 @@ type BreakNode = BaseNode & {
394
379
  * ```
395
380
  */
396
381
  type JsxNode = BaseNode & {
397
- /**
398
- * Node kind.
399
- */
400
382
  kind: 'Jsx';
401
383
  /**
402
384
  * The raw JSX string content.
@@ -672,9 +654,6 @@ type InferSchemaNode<TSchema extends object, TDateType extends ParserOptions['da
672
654
  * ```
673
655
  */
674
656
  type PropertyNode = BaseNode & {
675
- /**
676
- * Node kind.
677
- */
678
657
  kind: 'Property';
679
658
  /**
680
659
  * Property key.
@@ -963,8 +942,9 @@ type UnionSchemaNode = CompositeSchemaNodeBase & {
963
942
  */
964
943
  discriminatorPropertyName?: string;
965
944
  /**
966
- * Logical strategy applied to union members: 'one' means exactly one member must be valid (from `oneOf`),
967
- * 'any' means any number of members can be valid (from `anyOf`).
945
+ * How many union members must be valid.
946
+ * - `'one'`: exactly one member, from `oneOf`
947
+ * - `'any'`: any number of members, from `anyOf`
968
948
  */
969
949
  strategy?: 'one' | 'any';
970
950
  };
@@ -1344,8 +1324,8 @@ declare function createSchema(props: CreateSchemaInput): SchemaNode;
1344
1324
  /**
1345
1325
  * AST node representing one content-type entry of a request body or response.
1346
1326
  *
1347
- * One entry per content type declared in the spec (e.g. `application/json`,
1348
- * `multipart/form-data`), each carrying its own body schema.
1327
+ * There is one entry per content type declared in the spec (e.g. `application/json`,
1328
+ * `multipart/form-data`), and each entry holds its own body schema.
1349
1329
  *
1350
1330
  * @example
1351
1331
  * ```ts
@@ -1424,27 +1404,31 @@ type ImportNode = BaseNode & {
1424
1404
  kind: 'Import';
1425
1405
  /**
1426
1406
  * Import name(s) to be used.
1427
- * @example ['useState']
1428
- * @example 'React'
1407
+ *
1408
+ * @example Named imports
1409
+ * `['useState']`
1410
+ *
1411
+ * @example Default import
1412
+ * `'React'`
1429
1413
  */
1430
1414
  name: ImportName;
1431
1415
  /**
1432
1416
  * Path for the import.
1433
- * @example '@kubb/core'
1417
+ *
1418
+ * @example
1419
+ * `'@kubb/core'`
1434
1420
  */
1435
1421
  path: string;
1436
1422
  /**
1437
- * Add type-only import prefix.
1423
+ * Add a type-only import prefix.
1438
1424
  * - `true` generates `import type { Type } from './path'`
1439
1425
  * - `false` generates `import { Type } from './path'`
1440
- * @default false
1441
1426
  */
1442
1427
  isTypeOnly?: boolean | null;
1443
1428
  /**
1444
- * Import entire module as namespace.
1429
+ * Import the entire module as a namespace.
1445
1430
  * - `true` generates `import * as Name from './path'`
1446
- * - `false` generates standard import
1447
- * @default false
1431
+ * - `false` generates a standard import
1448
1432
  */
1449
1433
  isNameSpace?: boolean | null;
1450
1434
  /**
@@ -1479,27 +1463,31 @@ type ExportNode = BaseNode & {
1479
1463
  kind: 'Export';
1480
1464
  /**
1481
1465
  * Export name(s) to be used. When omitted, generates a wildcard export.
1482
- * @example ['useState']
1483
- * @example 'React'
1466
+ *
1467
+ * @example Named exports
1468
+ * `['useState']`
1469
+ *
1470
+ * @example Single export
1471
+ * `'React'`
1484
1472
  */
1485
1473
  name?: string | Array<string> | null;
1486
1474
  /**
1487
1475
  * Path for the export.
1488
- * @example '@kubb/core'
1476
+ *
1477
+ * @example
1478
+ * `'@kubb/core'`
1489
1479
  */
1490
1480
  path: string;
1491
1481
  /**
1492
- * Add type-only export prefix.
1482
+ * Add a type-only export prefix.
1493
1483
  * - `true` generates `export type { Type } from './path'`
1494
1484
  * - `false` generates `export { Type } from './path'`
1495
- * @default false
1496
1485
  */
1497
1486
  isTypeOnly?: boolean | null;
1498
1487
  /**
1499
1488
  * Export as an aliased namespace.
1500
1489
  * - `true` generates `export * as aliasName from './path'`
1501
1490
  * - `false` generates a standard export
1502
- * @default false
1503
1491
  */
1504
1492
  asAlias?: boolean | null;
1505
1493
  };
@@ -1524,22 +1512,19 @@ type SourceNode = BaseNode & {
1524
1512
  name?: string | null;
1525
1513
  /**
1526
1514
  * Mark this source as a type-only export.
1527
- * @default false
1528
1515
  */
1529
1516
  isTypeOnly?: boolean | null;
1530
1517
  /**
1531
- * Include `export` keyword in the generated source.
1532
- * @default false
1518
+ * Include the `export` keyword in the generated source.
1533
1519
  */
1534
1520
  isExportable?: boolean | null;
1535
1521
  /**
1536
1522
  * Include this source in barrel/index file generation.
1537
- * @default false
1538
1523
  */
1539
1524
  isIndexable?: boolean | null;
1540
1525
  /**
1541
- * Structured child nodes representing the content of this source fragment, in DOM order.
1542
- * Each entry is a {@link CodeNode}; use {@link TextNode} for raw string content.
1526
+ * Child nodes that make up this source fragment, in DOM order.
1527
+ * Use a {@link TextNode} for raw string content.
1543
1528
  */
1544
1529
  nodes?: Array<CodeNode>;
1545
1530
  };
@@ -1566,8 +1551,8 @@ type SourceNode = BaseNode & {
1566
1551
  type FileNode<TMeta extends object = object> = BaseNode & {
1567
1552
  kind: 'File';
1568
1553
  /**
1569
- * Unique identifier derived from a SHA256 hash of the file path. Computed
1570
- * by `createFile`; callers do not need to provide it.
1554
+ * Unique identifier derived from a SHA256 hash of the file path. `createFile`
1555
+ * computes it, so callers do not need to provide it.
1571
1556
  */
1572
1557
  id: string;
1573
1558
  /**
@@ -1602,7 +1587,7 @@ type FileNode<TMeta extends object = object> = BaseNode & {
1602
1587
  */
1603
1588
  exports: Array<ExportNode>;
1604
1589
  /**
1605
- * Optional metadata attached to this file (used by plugins for barrel generation etc.).
1590
+ * Optional metadata attached to this file, read by plugins during barrel generation.
1606
1591
  */
1607
1592
  meta?: TMeta;
1608
1593
  /**
@@ -1683,9 +1668,6 @@ type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode;
1683
1668
  * ```
1684
1669
  */
1685
1670
  type TypeLiteralNode = BaseNode & {
1686
- /**
1687
- * Node kind.
1688
- */
1689
1671
  kind: 'TypeLiteral';
1690
1672
  /**
1691
1673
  * Members of the object type, rendered in order.
@@ -1716,9 +1698,6 @@ type TypeLiteralNode = BaseNode & {
1716
1698
  * ```
1717
1699
  */
1718
1700
  type IndexedAccessTypeNode = BaseNode & {
1719
- /**
1720
- * Node kind.
1721
- */
1722
1701
  kind: 'IndexedAccessType';
1723
1702
  /**
1724
1703
  * Name of the type being indexed, e.g. `'GetPetPathParams'`.
@@ -1740,9 +1719,6 @@ type IndexedAccessTypeNode = BaseNode & {
1740
1719
  * ```
1741
1720
  */
1742
1721
  type ObjectBindingPatternNode = BaseNode & {
1743
- /**
1744
- * Node kind.
1745
- */
1746
1722
  kind: 'ObjectBindingPattern';
1747
1723
  /**
1748
1724
  * Bound elements, rendered in order.
@@ -1780,9 +1756,6 @@ type ObjectBindingPatternNode = BaseNode & {
1780
1756
  * `{ id, name? }: { id: string; name?: string } = {}`
1781
1757
  */
1782
1758
  type FunctionParameterNode = BaseNode & {
1783
- /**
1784
- * Node kind.
1785
- */
1786
1759
  kind: 'FunctionParameter';
1787
1760
  /**
1788
1761
  * Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.
@@ -1816,9 +1789,6 @@ type FunctionParameterNode = BaseNode & {
1816
1789
  * - `call` → `(id, { method, url })` function call arguments
1817
1790
  */
1818
1791
  type FunctionParametersNode = BaseNode & {
1819
- /**
1820
- * Node kind.
1821
- */
1822
1792
  kind: 'FunctionParameters';
1823
1793
  /**
1824
1794
  * Ordered parameter nodes.
@@ -1964,9 +1934,6 @@ type ParameterLocation = 'path' | 'query' | 'header' | 'cookie';
1964
1934
  * ```
1965
1935
  */
1966
1936
  type ParameterNode = BaseNode & {
1967
- /**
1968
- * Node kind.
1969
- */
1970
1937
  kind: 'Parameter';
1971
1938
  /**
1972
1939
  * Parameter name.
@@ -2023,12 +1990,9 @@ declare const createParameter: (input: UserParameterNode) => ParameterNode;
2023
1990
  * ```
2024
1991
  */
2025
1992
  type RequestBodyNode = BaseNode & {
2026
- /**
2027
- * Node kind.
2028
- */
2029
1993
  kind: 'RequestBody';
2030
1994
  /**
2031
- * Human-readable request body description.
1995
+ * Request body description carried over from the spec.
2032
1996
  */
2033
1997
  description?: string;
2034
1998
  /**
@@ -2037,11 +2001,11 @@ type RequestBodyNode = BaseNode & {
2037
2001
  */
2038
2002
  required?: boolean;
2039
2003
  /**
2040
- * All available content type entries for this request body.
2004
+ * Content type entries for this request body.
2041
2005
  *
2042
2006
  * When the adapter `contentType` option is set, this array contains exactly one entry for
2043
2007
  * that content type. Otherwise it contains one entry per content type declared in the spec,
2044
- * so that plugins can generate code for every variant (e.g. separate hooks for
2008
+ * so plugins can generate code for every variant (for example, separate hooks for
2045
2009
  * `application/json` and `multipart/form-data`).
2046
2010
  */
2047
2011
  content?: Array<ContentNode>;
@@ -2187,7 +2151,7 @@ type OperationNodeBase = BaseNode & {
2187
2151
  */
2188
2152
  deprecated?: boolean;
2189
2153
  /**
2190
- * Parameters that could be used, we have QueryParams, PathParams, HeaderParams and CookieParams
2154
+ * Query, path, header, and cookie parameters for the operation.
2191
2155
  */
2192
2156
  parameters: Array<ParameterNode>;
2193
2157
  /**
@@ -2310,11 +2274,11 @@ type InputMeta = {
2310
2274
  baseURL?: string | null;
2311
2275
  /**
2312
2276
  * Names of schemas that participate in a circular reference chain.
2313
- * Computed once during the adapter pre-scan, use this instead of calling
2314
- * `findCircularSchemas` per generator call.
2277
+ * Computed once during the adapter pre-scan, so a generator never has to
2278
+ * call `findCircularSchemas` itself.
2315
2279
  *
2316
2280
  * Convert to a `Set` once at the start of a generator, not per-schema,
2317
- * to keep lookup O(1) without repeated allocations.
2281
+ * so lookups stay O(1) without repeated allocations.
2318
2282
  *
2319
2283
  * @example Wrap a circular schema in z.lazy()
2320
2284
  * ```ts
@@ -2325,11 +2289,11 @@ type InputMeta = {
2325
2289
  circularNames: ReadonlyArray<string>;
2326
2290
  /**
2327
2291
  * Names of schemas whose type is `enum`.
2328
- * Computed once during the adapter pre-scan, use this instead of filtering
2329
- * schemas per generator call.
2292
+ * Computed once during the adapter pre-scan, so a generator never has to
2293
+ * filter the schema list itself.
2330
2294
  *
2331
2295
  * Convert to a `Set` once at the start of a generator when you need repeated
2332
- * membership checks, rather than calling `.includes()` per schema.
2296
+ * membership checks, so each check stays O(1) instead of an array scan.
2333
2297
  *
2334
2298
  * @example Check if a referenced schema is an enum
2335
2299
  * `const enums = new Set(meta.enumNames)`
@@ -2465,267 +2429,5 @@ declare function createOutput(overrides?: Partial<Omit<OutputNode, 'kind'>>): Ou
2465
2429
  */
2466
2430
  type Node = InputNode | OutputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FunctionParamNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode;
2467
2431
  //#endregion
2468
- //#region src/utils/ast.d.ts
2469
- /**
2470
- * Merges a ref node with its resolved schema, giving usage-site fields precedence.
2471
- *
2472
- * Usage-site fields (`description`, `readOnly`, `nullable`, `deprecated`) on the ref node
2473
- * override the same fields in the resolved `node.schema`. Non-ref nodes are returned unchanged.
2474
- *
2475
- * @example
2476
- * ```ts
2477
- * // Ref with description override
2478
- * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
2479
- * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
2480
- * ```
2481
- */
2482
- declare function syncSchemaRef(node: SchemaNode): SchemaNode;
2483
- /**
2484
- * Type guard that returns `true` when a schema emits as a plain `string` type.
2485
- *
2486
- * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
2487
- * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
2488
- */
2489
- declare function isStringType(node: SchemaNode): boolean;
2490
- declare function caseParams(params: Array<ParameterNode>, casing: 'camelcase' | undefined): Array<ParameterNode>;
2491
- /**
2492
- * Creates a single-property object schema used as a discriminator literal.
2493
- *
2494
- * @example
2495
- * ```ts
2496
- * createDiscriminantNode({ propertyName: 'type', value: 'dog' })
2497
- * // -> { type: 'object', properties: [{ name: 'type', required: true, schema: enum('dog') }] }
2498
- * ```
2499
- */
2500
- declare function createDiscriminantNode({
2501
- propertyName,
2502
- value
2503
- }: {
2504
- propertyName: string;
2505
- value: string;
2506
- }): SchemaNode;
2507
- /**
2508
- * Named type for a group of parameters (query or header) emitted as a single typed parameter.
2509
- */
2510
- type ParamGroupType = {
2511
- /**
2512
- * Type expression for the group, a plain group-name reference.
2513
- */
2514
- type: TypeExpression;
2515
- /**
2516
- * Whether the parameter group is optional.
2517
- */
2518
- optional: boolean;
2519
- };
2520
- /**
2521
- * Resolver interface for {@link createOperationParams}.
2522
- *
2523
- * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
2524
- */
2525
- type OperationParamsResolver = {
2526
- /**
2527
- * Resolves the type name for an individual parameter.
2528
- *
2529
- * @example Individual path parameter name
2530
- * `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
2531
- */
2532
- resolveParamName(node: OperationNode, param: ParameterNode): string;
2533
- /**
2534
- * Resolves the request body type name.
2535
- *
2536
- * @example Request body type name
2537
- * `resolver.resolveDataName(node) // → 'CreatePetData'`
2538
- */
2539
- resolveDataName(node: OperationNode): string;
2540
- /**
2541
- * Resolves the grouped path parameters type name.
2542
- * When the return value equals `resolveParamName`, no indexed access is emitted.
2543
- *
2544
- * @example Grouped path params type name
2545
- * `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
2546
- */
2547
- resolvePathParamsName(node: OperationNode, param: ParameterNode): string;
2548
- /**
2549
- * Resolves the grouped query parameters type name.
2550
- * When the return value equals `resolveParamName`, an inline struct type is emitted instead.
2551
- *
2552
- * @example Grouped query params type name
2553
- * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
2554
- */
2555
- resolveQueryParamsName(node: OperationNode, param: ParameterNode): string;
2556
- /**
2557
- * Resolves the grouped header parameters type name.
2558
- * When the return value equals `resolveParamName`, an inline struct type is emitted instead.
2559
- *
2560
- * @example Grouped header params type name
2561
- * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
2562
- */
2563
- resolveHeaderParamsName(node: OperationNode, param: ParameterNode): string;
2564
- };
2565
- /**
2566
- * Options for {@link createOperationParams}.
2567
- */
2568
- type CreateOperationParamsOptions = {
2569
- /**
2570
- * How all operation parameters are grouped in the function signature.
2571
- * - `'object'` wraps all params into a single destructured object `{ petId, data, params }`
2572
- * - `'inline'` emits each param category as a separate top-level parameter
2573
- */
2574
- paramsType: 'object' | 'inline';
2575
- /**
2576
- * How path parameters are emitted when `paramsType` is `'inline'`.
2577
- * - `'object'` groups them as `{ petId, storeId }: PathParams`
2578
- * - `'inline'` spreads them as individual parameters `petId: string, storeId: string`
2579
- * - `'inlineSpread'` emits a single rest parameter `...pathParams: PathParams`
2580
- */
2581
- pathParamsType: 'object' | 'inline' | 'inlineSpread';
2582
- /**
2583
- * Converts parameter names to camelCase before output.
2584
- */
2585
- paramsCasing?: 'camelcase';
2586
- /**
2587
- * Resolver for parameter and request body type names.
2588
- * Pass `ResolverTs` from `@kubb/plugin-ts` directly.
2589
- * When omitted, falls back to the schema primitive or `'unknown'`.
2590
- */
2591
- resolver?: OperationParamsResolver;
2592
- /**
2593
- * Default value for the path parameters binding when `pathParamsType` is `'object'`.
2594
- * Falls back to `'{}'` when all path params are optional.
2595
- */
2596
- pathParamsDefault?: string;
2597
- /**
2598
- * Extra parameters appended after the standard operation parameters.
2599
- *
2600
- * @example Plugin-specific trailing parameter
2601
- * ```ts
2602
- * extraParams: [createFunctionParameter({ name: 'options', type: 'Partial<RequestOptions>', default: '{}' })]
2603
- * ```
2604
- */
2605
- extraParams?: Array<FunctionParameterNode>;
2606
- /**
2607
- * Override the default parameter names used for body, query, header, and rest-path groups.
2608
- *
2609
- * Useful when targeting languages or frameworks with different naming conventions.
2610
- *
2611
- * @default { data: 'data', params: 'params', headers: 'headers', path: 'pathParams' }
2612
- */
2613
- paramNames?: {
2614
- /**
2615
- * Name for the request body parameter.
2616
- * @default 'data'
2617
- */
2618
- data?: string;
2619
- /**
2620
- * Name for the query parameters group parameter.
2621
- * @default 'params'
2622
- */
2623
- params?: string;
2624
- /**
2625
- * Name for the header parameters group parameter.
2626
- * @default 'headers'
2627
- */
2628
- headers?: string;
2629
- /**
2630
- * Name for the rest path-parameters parameter when `pathParamsType` is `'inlineSpread'`.
2631
- * @default 'pathParams'
2632
- */
2633
- path?: string;
2634
- };
2635
- /**
2636
- * Applies a uniform transformation to every resolved type name before it is used
2637
- * in a parameter node. Use this for framework-level type wrappers.
2638
- *
2639
- * @example Vue Query, wrap every parameter type with `MaybeRefOrGetter`
2640
- * `typeWrapper: (t) => \`MaybeRefOrGetter<${t}>\``
2641
- */
2642
- typeWrapper?: (type: string) => string;
2643
- };
2644
- /**
2645
- * Resolves the {@link TypeExpression} for an individual parameter.
2646
- *
2647
- * Without a resolver, falls back to the schema primitive (a plain type-name string).
2648
- * When the parameter belongs to a named group, emits an {@link IndexedAccessTypeNode}
2649
- * (`GroupParams['petId']`); otherwise the resolved individual name as a plain string.
2650
- */
2651
- declare function resolveParamType({
2652
- node,
2653
- param,
2654
- resolver
2655
- }: {
2656
- node: OperationNode;
2657
- param: ParameterNode;
2658
- resolver: OperationParamsResolver | undefined;
2659
- }): TypeExpression;
2660
- /**
2661
- * Converts an `OperationNode` into function parameters for code generation.
2662
- *
2663
- * Centralizes parameter grouping logic for all plugins. `paramsType` chooses between one
2664
- * destructured object parameter (`object`) and separate top-level parameters (`inline`), while
2665
- * `pathParamsType` controls how path params render in inline mode. Provide a `resolver` for type
2666
- * name resolution and `extraParams` for plugin-specific trailing parameters such as an `options` object.
2667
- */
2668
- declare function createOperationParams(node: OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode;
2669
- /**
2670
- * Shared arguments for building a query or header parameter group.
2671
- */
2672
- type BuildGroupArgs = {
2673
- name: string;
2674
- node: OperationNode;
2675
- params: Array<ParameterNode>;
2676
- groupType: ParamGroupType | null;
2677
- resolver: OperationParamsResolver | undefined;
2678
- wrapType: (type: string) => string;
2679
- };
2680
- /**
2681
- * Builds a single {@link FunctionParameterNode} for a query or header group.
2682
- * Returns an empty array when there are no params to emit.
2683
- *
2684
- * A pre-resolved `groupType` emits `name: GroupType`. Otherwise it builds an inline
2685
- * {@link TypeLiteralNode} from the individual params.
2686
- */
2687
- declare function buildGroupParam(args: BuildGroupArgs): Array<FunctionParameterNode>;
2688
- /**
2689
- * Builds a {@link TypeLiteralNode} for an inline anonymous type grouping named fields.
2690
- *
2691
- * Used when query or header parameters have no dedicated group type name.
2692
- * Each language printer renders this appropriately (TypeScript: `{ petId: string; name?: string }`).
2693
- */
2694
- declare function buildTypeLiteral({
2695
- node,
2696
- params,
2697
- resolver
2698
- }: {
2699
- node: OperationNode;
2700
- params: Array<ParameterNode>;
2701
- resolver: OperationParamsResolver | undefined;
2702
- }): TypeLiteralNode;
2703
- declare function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
2704
- /**
2705
- * Identifies all schemas that participate in circular dependency chains, including direct self-loops.
2706
- *
2707
- * Returns a Set of schema names with circular dependencies. Use this to wrap recursive schema positions
2708
- * in deferred constructs (lazy getter, `z.lazy(() => …)`) to prevent infinite recursion when generated code runs.
2709
- * Refs are followed by name only, keeping the algorithm linear in the schema graph size.
2710
- *
2711
- * @note Call this once on the full schema graph, then use `containsCircularRef()` to check individual schemas.
2712
- */
2713
- declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
2714
- /**
2715
- * Type guard returning `true` when a schema or anything nested within it contains a ref to a circular schema.
2716
- *
2717
- * Use `excludeName` to ignore refs to specific schemas (useful when self-references are handled separately).
2718
- * Commonly used with `findCircularSchemas()` to detect where lazy wrappers are needed in code generation.
2719
- *
2720
- * @note Returns `true` for the first matching circular ref found. Use for fast dependency checks.
2721
- */
2722
- declare function containsCircularRef(node: SchemaNode | undefined, {
2723
- circularSchemas,
2724
- excludeName
2725
- }: {
2726
- circularSchemas: ReadonlySet<string>;
2727
- excludeName?: string;
2728
- }): boolean;
2729
- //#endregion
2730
- export { functionParametersDef as $, createBreak as $t, responseDef as A, StringSchemaNode as At, FunctionParamNode as B, ParserOptions as Bt, HttpMethod as C, ObjectSchemaNode as Ct, operationDef as D, SchemaNode as Dt, createOperation as E, ScalarSchemaType as Et, ParameterLocation as F, schemaDef as Ft, TypeExpression as G, JSDocNode as Gt, FunctionParametersNode as H, CodeNode as Ht, ParameterNode as I, PropertyNode as It, createFunctionParameters as J, TypeNode as Jt, TypeLiteralNode as K, JsxNode as Kt, createParameter as L, createProperty as Lt, RequestBodyNode as M, UnionSchemaNode as Mt, createRequestBody as N, UrlSchemaNode as Nt, ResponseNode as O, SchemaNodeByType as Ot, requestBodyDef as P, createSchema as Pt, functionParameterDef as Q, createArrowFunction as Qt, parameterDef as R, propertyDef as Rt, inputDef as S, NumberSchemaNode as St, OperationNode as T, RefSchemaNode as Tt, IndexedAccessTypeNode as U, ConstNode as Ut, FunctionParameterNode as V, ArrowFunctionNode as Vt, ObjectBindingPatternNode as W, FunctionNode as Wt, createObjectBindingPattern as X, breakDef as Xt, createIndexedAccessType as Y, arrowFunctionDef as Yt, createTypeLiteral as Z, constDef as Zt, createOutput as _, ArraySchemaNode as _t, buildTypeLiteral as a, functionDef as an, ImportNode as at, InputNode as b, EnumSchemaNode as bt, containsCircularRef as c, typeDef as cn, createImport as ct, findCircularSchemas as d, defineNode as dn, fileDef as dt, createConst as en, indexedAccessTypeDef as et, isStringType as f, syncOptionality as fn, importDef as ft, OutputNode as g, createContent as gt, Node as h, contentDef as ht, buildGroupParam as i, createType as in, FileNode as it, StatusCode as j, TimeSchemaNode as jt, createResponse as k, SchemaType as kt, createDiscriminantNode as l, DistributiveOmit as ln, createSource as lt, syncSchemaRef as m, ContentNode as mt, OperationParamsResolver as n, createJsx as nn, typeLiteralDef as nt, caseParams as o, jsxDef as on, SourceNode as ot, resolveParamType as p, NodeKind as pn, sourceDef as pt, createFunctionParameter as q, TextNode as qt, ParamGroupType as r, createText as rn, ExportNode as rt, collectUsedSchemaNames as s, textDef as sn, createExport as st, BuildGroupArgs as t, createFunction as tn, objectBindingPatternDef as tt, createOperationParams as u, NodeDef as un, exportDef as ut, outputDef as v, DateSchemaNode as vt, HttpOperationNode as w, PrimitiveSchemaType as wt, createInput as x, IntersectionSchemaNode as xt, InputMeta as y, DatetimeSchemaNode as yt, FunctionParamKind as z, InferSchemaNode as zt };
2731
- //# sourceMappingURL=ast-ClnJg9BN.d.ts.map
2432
+ export { fileDef as $, textDef as $t, FunctionParametersNode as A, InferSchemaNode as At, functionParameterDef as B, TypeNode as Bt, ParameterLocation as C, UrlSchemaNode as Ct, FunctionParamKind as D, UserPropertyNode as Dt, parameterDef as E, PropertyNode as Et, createFunctionParameter as F, ConstNode as Ft, ExportNode as G, createBreak as Gt, indexedAccessTypeDef as H, breakDef as Ht, createFunctionParameters as I, FunctionNode as It, SourceNode as J, createJsx as Jt, FileNode as K, createConst as Kt, createIndexedAccessType as L, JSDocNode as Lt, ObjectBindingPatternNode as M, ArrowFunctionNode as Mt, TypeExpression as N, BreakNode as Nt, FunctionParamNode as O, createProperty as Ot, TypeLiteralNode as P, CodeNode as Pt, exportDef as Q, jsxDef as Qt, createObjectBindingPattern as R, JsxNode as Rt, requestBodyDef as S, UnionSchemaNode as St, createParameter as T, schemaDef as Tt, objectBindingPatternDef as U, constDef as Ut, functionParametersDef as V, arrowFunctionDef as Vt, typeLiteralDef as W, createArrowFunction as Wt, createImport as X, createType as Xt, createExport as Y, createText as Yt, createSource as Z, functionDef as Zt, responseDef as _, SchemaNode as _t, InputMeta as a, BaseNode as an, createContent as at, UserRequestBody as b, StringSchemaNode as bt, inputDef as c, DatetimeSchemaNode as ct, HttpOperationNode as d, NumberSchemaNode as dt, typeDef as en, importDef as et, OperationNode as f, ObjectSchemaNode as ft, createResponse as g, ScalarSchemaType as gt, ResponseNode as h, ScalarSchemaNode as ht, outputDef as i, syncOptionality as in, contentDef as it, IndexedAccessTypeNode as j, ParserOptions as jt, FunctionParameterNode as k, propertyDef as kt, GenericOperationNode as l, EnumSchemaNode as lt, operationDef as m, RefSchemaNode as mt, OutputNode as n, NodeDef as nn, ContentNode as nt, InputNode as o, NodeKind as on, ArraySchemaNode as ot, createOperation as p, PrimitiveSchemaType as pt, ImportNode as q, createFunction as qt, createOutput as r, defineNode as rn, UserContent as rt, createInput as s, DateSchemaNode as st, Node as t, DistributiveOmit as tn, sourceDef as tt, HttpMethod as u, IntersectionSchemaNode as ut, StatusCode as v, SchemaNodeByType as vt, ParameterNode as w, createSchema as wt, createRequestBody as x, TimeSchemaNode as xt, RequestBodyNode as y, SchemaType as yt, createTypeLiteral as z, TextNode as zt };
2433
+ //# sourceMappingURL=index-BzjwdK2M.d.ts.map