@kubb/ast 5.0.0-beta.65 → 5.0.0-beta.66

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 (38) hide show
  1. package/dist/{defineMacro-CEZHaCXE.cjs → defineMacro-BxfaP1iL.cjs} +3 -4
  2. package/dist/{defineMacro-CEZHaCXE.cjs.map → defineMacro-BxfaP1iL.cjs.map} +1 -1
  3. package/dist/{defineMacro-B76LsJwO.js → defineMacro-D2vgAdoH.js} +2 -3
  4. package/dist/{defineMacro-B76LsJwO.js.map → defineMacro-D2vgAdoH.js.map} +1 -1
  5. package/dist/index.cjs +114 -63
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +51 -32
  8. package/dist/index.js +57 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/macros.cjs +5 -6
  11. package/dist/macros.cjs.map +1 -1
  12. package/dist/macros.js +2 -3
  13. package/dist/macros.js.map +1 -1
  14. package/dist/{schema-YNbOtTCM.js → refs-CXp6uOHL.js} +502 -2
  15. package/dist/refs-CXp6uOHL.js.map +1 -0
  16. package/dist/{schema-BkvrrOAr.cjs → refs-DDIY_Tpn.cjs} +597 -7
  17. package/dist/refs-DDIY_Tpn.cjs.map +1 -0
  18. package/dist/{types-B6thixAv.d.ts → types-DpeAMnq5.d.ts} +5 -5
  19. package/dist/types.d.ts +3 -3
  20. package/dist/{utils-BJi0y-xg.js → utils-C2kwfetT.js} +2 -3
  21. package/dist/{utils-BJi0y-xg.js.map → utils-C2kwfetT.js.map} +1 -1
  22. package/dist/{utils-CEepwqmb.cjs → utils-DYhjlv0E.cjs} +13 -14
  23. package/dist/{utils-CEepwqmb.cjs.map → utils-DYhjlv0E.cjs.map} +1 -1
  24. package/dist/utils.cjs +3 -4
  25. package/dist/utils.js +2 -3
  26. package/package.json +1 -5
  27. package/dist/factory-B_qPwA1b.d.ts +0 -27
  28. package/dist/factory.cjs +0 -89
  29. package/dist/factory.cjs.map +0 -1
  30. package/dist/factory.d.ts +0 -3
  31. package/dist/factory.js +0 -58
  32. package/dist/factory.js.map +0 -1
  33. package/dist/refs-Dx6U5LoE.js +0 -505
  34. package/dist/refs-Dx6U5LoE.js.map +0 -1
  35. package/dist/refs-u5SDdyV7.cjs +0 -599
  36. package/dist/refs-u5SDdyV7.cjs.map +0 -1
  37. package/dist/schema-BkvrrOAr.cjs.map +0 -1
  38. package/dist/schema-YNbOtTCM.js.map +0 -1
@@ -1,599 +0,0 @@
1
- const require_schema = require("./schema-BkvrrOAr.cjs");
2
- //#region src/constants.ts
3
- const visitorDepths = {
4
- shallow: "shallow",
5
- deep: "deep"
6
- };
7
- /**
8
- * Schema type discriminators used by all AST schema nodes.
9
- *
10
- * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).
11
- */
12
- const schemaTypes = {
13
- /**
14
- * Text value.
15
- */
16
- string: "string",
17
- /**
18
- * Floating-point number (`float`, `double`).
19
- */
20
- number: "number",
21
- /**
22
- * Whole number (`int32`). Use `bigint` for `int64`.
23
- */
24
- integer: "integer",
25
- /**
26
- * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
27
- */
28
- bigint: "bigint",
29
- /**
30
- * Boolean value.
31
- */
32
- boolean: "boolean",
33
- /**
34
- * Explicit null value.
35
- */
36
- null: "null",
37
- /**
38
- * Any value (no type restriction).
39
- */
40
- any: "any",
41
- /**
42
- * Unknown value (must be narrowed before usage).
43
- */
44
- unknown: "unknown",
45
- /**
46
- * No return value (`void`).
47
- */
48
- void: "void",
49
- /**
50
- * Object with named properties.
51
- */
52
- object: "object",
53
- /**
54
- * Sequential list of items.
55
- */
56
- array: "array",
57
- /**
58
- * Fixed-length list with position-specific items.
59
- */
60
- tuple: "tuple",
61
- /**
62
- * "One of" multiple schema members.
63
- */
64
- union: "union",
65
- /**
66
- * "All of" multiple schema members.
67
- */
68
- intersection: "intersection",
69
- /**
70
- * Enum schema.
71
- */
72
- enum: "enum",
73
- /**
74
- * Reference to another schema.
75
- */
76
- ref: "ref",
77
- /**
78
- * Calendar date (for example `2026-03-24`).
79
- */
80
- date: "date",
81
- /**
82
- * Date-time value (for example `2026-03-24T09:00:00Z`).
83
- */
84
- datetime: "datetime",
85
- /**
86
- * Time-only value (for example `09:00:00`).
87
- */
88
- time: "time",
89
- /**
90
- * UUID value.
91
- */
92
- uuid: "uuid",
93
- /**
94
- * Email address value.
95
- */
96
- email: "email",
97
- /**
98
- * URL value.
99
- */
100
- url: "url",
101
- /**
102
- * IPv4 address value.
103
- */
104
- ipv4: "ipv4",
105
- /**
106
- * IPv6 address value.
107
- */
108
- ipv6: "ipv6",
109
- /**
110
- * Binary/blob value.
111
- */
112
- blob: "blob",
113
- /**
114
- * Impossible value (`never`).
115
- */
116
- never: "never"
117
- };
118
- /**
119
- * One indentation level, derived from {@link INDENT_SIZE}.
120
- */
121
- const INDENT = Array.from({ length: 2 }, () => " ").join("");
122
- //#endregion
123
- //#region src/guards.ts
124
- /**
125
- * Narrows a `SchemaNode` to the variant that matches `type`.
126
- *
127
- * @example
128
- * ```ts
129
- * const schema = createSchema({ type: 'string' })
130
- * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null
131
- * ```
132
- */
133
- function narrowSchema(node, type) {
134
- return node?.type === type ? node : null;
135
- }
136
- /**
137
- * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.
138
- *
139
- * @example
140
- * ```ts
141
- * if (isHttpOperationNode(node)) {
142
- * console.log(node.method, node.path)
143
- * }
144
- * ```
145
- */
146
- function isHttpOperationNode(node) {
147
- return node.protocol === "http" || node.method !== void 0 && node.path !== void 0;
148
- }
149
- //#endregion
150
- //#region src/registry.ts
151
- /**
152
- * Every node definition. Adding a node means adding its `defineNode` to one
153
- * `nodes/*.ts` file and listing it here. The visitor tables in `visitor.ts` derive from it.
154
- */
155
- const nodeDefs = [
156
- require_schema.inputDef,
157
- require_schema.outputDef,
158
- require_schema.operationDef,
159
- require_schema.requestBodyDef,
160
- require_schema.contentDef,
161
- require_schema.responseDef,
162
- require_schema.schemaDef,
163
- require_schema.propertyDef,
164
- require_schema.parameterDef,
165
- require_schema.functionParameterDef,
166
- require_schema.functionParametersDef,
167
- require_schema.typeLiteralDef,
168
- require_schema.indexedAccessTypeDef,
169
- require_schema.objectBindingPatternDef,
170
- require_schema.constDef,
171
- require_schema.typeDef,
172
- require_schema.functionDef,
173
- require_schema.arrowFunctionDef,
174
- require_schema.textDef,
175
- require_schema.breakDef,
176
- require_schema.jsxDef,
177
- require_schema.importDef,
178
- require_schema.exportDef,
179
- require_schema.sourceDef,
180
- require_schema.fileDef
181
- ];
182
- //#endregion
183
- //#region src/visitor.ts
184
- /**
185
- * Child node fields per node kind, in traversal order (Babel's `VISITOR_KEYS`).
186
- * Derived from each definition's `children`.
187
- */
188
- const VISITOR_KEYS = Object.fromEntries(nodeDefs.flatMap((def) => def.children ? [[def.kind, def.children]] : []));
189
- /**
190
- * Maps a node kind to the matching visitor callback name. Derived from each
191
- * definition's `visitorKey`.
192
- */
193
- const VISITOR_KEY_BY_KIND = Object.fromEntries(nodeDefs.flatMap((def) => def.visitorKey ? [[def.kind, def.visitorKey]] : []));
194
- /**
195
- * Creates a small async concurrency limiter.
196
- *
197
- * At most `concurrency` tasks are in flight at once. Extra tasks are queued.
198
- *
199
- * @example
200
- * ```ts
201
- * const limit = createLimit(2)
202
- * for (const task of [taskA, taskB, taskC]) {
203
- * await limit(() => task())
204
- * }
205
- * // only 2 tasks run at the same time
206
- * ```
207
- */
208
- function createLimit(concurrency) {
209
- let active = 0;
210
- const queue = [];
211
- function next() {
212
- if (active < concurrency && queue.length > 0) {
213
- active++;
214
- queue.shift()();
215
- }
216
- }
217
- return function limit(fn) {
218
- return new Promise((resolve, reject) => {
219
- queue.push(() => {
220
- Promise.resolve(fn()).then(resolve, reject).finally(() => {
221
- active--;
222
- next();
223
- });
224
- });
225
- next();
226
- });
227
- };
228
- }
229
- const visitorKeysByKind = VISITOR_KEYS;
230
- /**
231
- * Returns `true` when `value` is an AST node (an object carrying a `kind`).
232
- */
233
- function isNode(value) {
234
- return typeof value === "object" && value !== null && "kind" in value;
235
- }
236
- /**
237
- * Returns the immediate traversable children of `node` based on {@link VISITOR_KEYS}.
238
- *
239
- * `Schema` children are only included when `recurse` is `true`. Shallow mode skips them.
240
- *
241
- * @example
242
- * ```ts
243
- * const children = getChildren(operationNode, true)
244
- * // returns parameters, the request body, and responses
245
- * ```
246
- */
247
- function* getChildren(node, recurse) {
248
- if (node.kind === "Schema" && !recurse) return;
249
- const keys = visitorKeysByKind[node.kind];
250
- if (!keys) return;
251
- const record = node;
252
- for (const key of keys) {
253
- const value = record[key];
254
- if (Array.isArray(value)) {
255
- for (const item of value) if (isNode(item)) yield item;
256
- } else if (isNode(value)) yield value;
257
- }
258
- }
259
- /**
260
- * Runs the visitor callback that matches `node.kind` with the traversal
261
- * context. The result is a replacement node, a collected value, or `undefined`
262
- * when no callback is registered for the kind.
263
- *
264
- * Shared by `walk`, `transform`, and `collectLazy` so node-kind dispatch lives
265
- * in one place. `TResult` is the caller's expected return: the same node type
266
- * for `transform`, the collected value type for `collectLazy`, ignored for `walk`.
267
- */
268
- function applyVisitor(node, visitor, parent) {
269
- const key = VISITOR_KEY_BY_KIND[node.kind];
270
- if (!key) return void 0;
271
- const fn = visitor[key];
272
- return fn?.(node, { parent });
273
- }
274
- /**
275
- * Async depth-first traversal for side effects. Visitor return values are
276
- * ignored. Use `transform` when you want to rewrite nodes.
277
- *
278
- * Sibling nodes at each depth run concurrently up to `options.concurrency`
279
- * (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor
280
- * work. Lower values reduce memory pressure.
281
- *
282
- * @example Log every operation
283
- * ```ts
284
- * await walk(root, {
285
- * operation(node) {
286
- * console.log(node.operationId)
287
- * },
288
- * })
289
- * ```
290
- *
291
- * @example Only visit the root node
292
- * ```ts
293
- * await walk(root, { depth: 'shallow', input: () => {} })
294
- * ```
295
- */
296
- async function walk(node, options) {
297
- return _walk(node, options, (options.depth ?? visitorDepths.deep) === visitorDepths.deep, createLimit(options.concurrency ?? 30), void 0);
298
- }
299
- async function _walk(node, visitor, recurse, limit, parent) {
300
- await limit(() => applyVisitor(node, visitor, parent));
301
- const children = Array.from(getChildren(node, recurse));
302
- if (children.length === 0) return;
303
- await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit, node)));
304
- }
305
- function transform(node, options) {
306
- const { depth, parent, ...visitor } = options;
307
- const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep;
308
- return transformChildren(applyVisitor(node, visitor, parent) ?? node, options, recurse);
309
- }
310
- /**
311
- * Immutably rebuilds a node's children using {@link VISITOR_KEYS}, transforming
312
- * each child node and leaving non-node values (e.g. `additionalProperties: true`) intact.
313
- * `Schema` children are skipped in shallow mode.
314
- */
315
- function transformChildren(node, options, recurse) {
316
- if (node.kind === "Schema" && !recurse) return node;
317
- const keys = visitorKeysByKind[node.kind];
318
- if (!keys) return node;
319
- const record = node;
320
- const childOptions = {
321
- ...options,
322
- parent: node
323
- };
324
- let updates;
325
- for (const key of keys) {
326
- if (!(key in record)) continue;
327
- const value = record[key];
328
- if (Array.isArray(value)) {
329
- let changed = false;
330
- const mapped = value.map((item) => {
331
- if (!isNode(item)) return item;
332
- const next = transform(item, childOptions);
333
- if (next !== item) changed = true;
334
- return next;
335
- });
336
- if (changed) (updates ??= {})[key] = mapped;
337
- } else if (isNode(value)) {
338
- const next = transform(value, childOptions);
339
- if (next !== value) (updates ??= {})[key] = next;
340
- }
341
- }
342
- return updates ? {
343
- ...node,
344
- ...updates
345
- } : node;
346
- }
347
- /**
348
- * Lazy depth-first collection pass. Yields every non-null value returned by
349
- * the visitor callbacks. Use `collect` for the eager array form.
350
- *
351
- * @example Collect every operationId
352
- * ```ts
353
- * const ids: string[] = []
354
- * for (const id of collectLazy<string>(root, {
355
- * operation(node) {
356
- * return node.operationId
357
- * },
358
- * })) {
359
- * ids.push(id)
360
- * }
361
- * ```
362
- */
363
- function* collectLazy(node, options) {
364
- const { depth, parent, ...visitor } = options;
365
- const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep;
366
- const v = applyVisitor(node, visitor, parent);
367
- if (v != null) yield v;
368
- for (const child of getChildren(node, recurse)) yield* collectLazy(child, {
369
- ...options,
370
- parent: node
371
- });
372
- }
373
- /**
374
- * Eager depth-first collection pass. Gathers every non-null value the visitor
375
- * callbacks return into an array.
376
- *
377
- * @example Collect every operationId
378
- * ```ts
379
- * const ids = collect<string>(root, {
380
- * operation(node) {
381
- * return node.operationId
382
- * },
383
- * })
384
- * ```
385
- */
386
- function collect(node, options) {
387
- return Array.from(collectLazy(node, options));
388
- }
389
- //#endregion
390
- //#region src/utils/refs.ts
391
- const plainStringTypes = new Set([
392
- "string",
393
- "uuid",
394
- "email",
395
- "url",
396
- "datetime"
397
- ]);
398
- /**
399
- * Returns the last path segment of a reference string.
400
- *
401
- * @example
402
- * `extractRefName('#/components/schemas/Pet') // 'Pet'`
403
- */
404
- function extractRefName(ref) {
405
- return ref.split("/").at(-1) ?? ref;
406
- }
407
- /**
408
- * Resolves the schema name of a ref node. Uses the last segment of `ref` when set, otherwise falls
409
- * back to `name` then nested `schema.name`.
410
- *
411
- * Returns `null` for non-ref nodes or when no name resolves.
412
- *
413
- * @example
414
- * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`
415
- */
416
- function resolveRefName(node) {
417
- if (!node || node.type !== "ref") return null;
418
- if (node.ref) return extractRefName(node.ref) ?? node.name ?? node.schema?.name ?? null;
419
- return node.name ?? node.schema?.name ?? null;
420
- }
421
- /**
422
- * Builds a PascalCase child schema name by joining a parent name and property name.
423
- * Returns `null` when there is no parent to nest under.
424
- *
425
- * @example Nested under a parent
426
- * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
427
- *
428
- * @example No parent
429
- * `childName(undefined, 'params') // null`
430
- */
431
- function childName(parentName, propName) {
432
- return parentName ? require_schema.pascalCase([parentName, propName].join(" ")) : null;
433
- }
434
- /**
435
- * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
436
- * empty parts.
437
- *
438
- * @example
439
- * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
440
- */
441
- function enumPropName(parentName, propName, enumSuffix) {
442
- return require_schema.pascalCase([
443
- parentName,
444
- propName,
445
- enumSuffix
446
- ].filter(Boolean).join(" "));
447
- }
448
- /**
449
- * Merges a ref node with its resolved schema, giving usage-site fields precedence.
450
- *
451
- * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
452
- * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
453
- * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
454
- * nodes and refs without a resolved `schema` are returned unchanged.
455
- *
456
- * @example
457
- * ```ts
458
- * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
459
- * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
460
- * ```
461
- */
462
- function syncSchemaRef(node) {
463
- const ref = narrowSchema(node, "ref");
464
- if (!ref) return node;
465
- if (!ref.schema) return node;
466
- const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref;
467
- const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
468
- return require_schema.createSchema({
469
- ...ref.schema,
470
- ...definedOverrides
471
- });
472
- }
473
- /**
474
- * Type guard that returns `true` when a schema emits as a plain `string` type.
475
- *
476
- * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
477
- * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
478
- */
479
- function isStringType(node) {
480
- if (plainStringTypes.has(node.type)) return true;
481
- const temporal = narrowSchema(node, "date") ?? narrowSchema(node, "time");
482
- if (temporal) return temporal.representation !== "date";
483
- return false;
484
- }
485
- /**
486
- * Derives a {@link ParamGroupType} for a query or header group from the resolver.
487
- *
488
- * Returns `null` when there is no resolver, no params, or the group name equals the
489
- * individual param name (so there is no real group to emit).
490
- */
491
- function resolveGroupType({ node, params, group, resolver }) {
492
- if (!resolver || !params.length) return null;
493
- const firstParam = params[0];
494
- const groupName = (group === "query" ? resolver.resolveQueryParamsName : resolver.resolveHeaderParamsName).call(resolver, node, firstParam);
495
- if (groupName === resolver.resolveParamName(node, firstParam)) return null;
496
- return {
497
- type: groupName,
498
- optional: params.every((p) => !p.required)
499
- };
500
- }
501
- //#endregion
502
- Object.defineProperty(exports, "INDENT", {
503
- enumerable: true,
504
- get: function() {
505
- return INDENT;
506
- }
507
- });
508
- Object.defineProperty(exports, "childName", {
509
- enumerable: true,
510
- get: function() {
511
- return childName;
512
- }
513
- });
514
- Object.defineProperty(exports, "collect", {
515
- enumerable: true,
516
- get: function() {
517
- return collect;
518
- }
519
- });
520
- Object.defineProperty(exports, "collectLazy", {
521
- enumerable: true,
522
- get: function() {
523
- return collectLazy;
524
- }
525
- });
526
- Object.defineProperty(exports, "enumPropName", {
527
- enumerable: true,
528
- get: function() {
529
- return enumPropName;
530
- }
531
- });
532
- Object.defineProperty(exports, "extractRefName", {
533
- enumerable: true,
534
- get: function() {
535
- return extractRefName;
536
- }
537
- });
538
- Object.defineProperty(exports, "isHttpOperationNode", {
539
- enumerable: true,
540
- get: function() {
541
- return isHttpOperationNode;
542
- }
543
- });
544
- Object.defineProperty(exports, "isStringType", {
545
- enumerable: true,
546
- get: function() {
547
- return isStringType;
548
- }
549
- });
550
- Object.defineProperty(exports, "narrowSchema", {
551
- enumerable: true,
552
- get: function() {
553
- return narrowSchema;
554
- }
555
- });
556
- Object.defineProperty(exports, "nodeDefs", {
557
- enumerable: true,
558
- get: function() {
559
- return nodeDefs;
560
- }
561
- });
562
- Object.defineProperty(exports, "resolveGroupType", {
563
- enumerable: true,
564
- get: function() {
565
- return resolveGroupType;
566
- }
567
- });
568
- Object.defineProperty(exports, "resolveRefName", {
569
- enumerable: true,
570
- get: function() {
571
- return resolveRefName;
572
- }
573
- });
574
- Object.defineProperty(exports, "schemaTypes", {
575
- enumerable: true,
576
- get: function() {
577
- return schemaTypes;
578
- }
579
- });
580
- Object.defineProperty(exports, "syncSchemaRef", {
581
- enumerable: true,
582
- get: function() {
583
- return syncSchemaRef;
584
- }
585
- });
586
- Object.defineProperty(exports, "transform", {
587
- enumerable: true,
588
- get: function() {
589
- return transform;
590
- }
591
- });
592
- Object.defineProperty(exports, "walk", {
593
- enumerable: true,
594
- get: function() {
595
- return walk;
596
- }
597
- });
598
-
599
- //# sourceMappingURL=refs-u5SDdyV7.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"refs-u5SDdyV7.cjs","names":["inputDef","outputDef","operationDef","requestBodyDef","contentDef","responseDef","schemaDef","propertyDef","parameterDef","functionParameterDef","functionParametersDef","typeLiteralDef","indexedAccessTypeDef","objectBindingPatternDef","constDef","typeDef","functionDef","arrowFunctionDef","textDef","breakDef","jsxDef","importDef","exportDef","sourceDef","fileDef","pascalCase","createSchema"],"sources":["../src/constants.ts","../src/guards.ts","../src/registry.ts","../src/visitor.ts","../src/utils/refs.ts"],"sourcesContent":["import type { SchemaType } from './nodes/schema.ts'\n\n/**\n * Traversal depth for AST visitor utilities.\n *\n * - `'shallow'` visits only the immediate node, skipping children.\n * - `'deep'` recursively visits all descendant nodes.\n */\nexport type VisitorDepth = 'shallow' | 'deep'\n\nexport const visitorDepths = {\n shallow: 'shallow',\n deep: 'deep',\n} as const satisfies Record<VisitorDepth, VisitorDepth>\n\n/**\n * Schema type discriminators used by all AST schema nodes.\n *\n * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).\n */\nexport const schemaTypes = {\n /**\n * Text value.\n */\n string: 'string',\n /**\n * Floating-point number (`float`, `double`).\n */\n number: 'number',\n /**\n * Whole number (`int32`). Use `bigint` for `int64`.\n */\n integer: 'integer',\n /**\n * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.\n */\n bigint: 'bigint',\n /**\n * Boolean value.\n */\n boolean: 'boolean',\n /**\n * Explicit null value.\n */\n null: 'null',\n /**\n * Any value (no type restriction).\n */\n any: 'any',\n /**\n * Unknown value (must be narrowed before usage).\n */\n unknown: 'unknown',\n /**\n * No return value (`void`).\n */\n void: 'void',\n /**\n * Object with named properties.\n */\n object: 'object',\n /**\n * Sequential list of items.\n */\n array: 'array',\n /**\n * Fixed-length list with position-specific items.\n */\n tuple: 'tuple',\n /**\n * \"One of\" multiple schema members.\n */\n union: 'union',\n /**\n * \"All of\" multiple schema members.\n */\n intersection: 'intersection',\n /**\n * Enum schema.\n */\n enum: 'enum',\n /**\n * Reference to another schema.\n */\n ref: 'ref',\n /**\n * Calendar date (for example `2026-03-24`).\n */\n date: 'date',\n /**\n * Date-time value (for example `2026-03-24T09:00:00Z`).\n */\n datetime: 'datetime',\n /**\n * Time-only value (for example `09:00:00`).\n */\n time: 'time',\n /**\n * UUID value.\n */\n uuid: 'uuid',\n /**\n * Email address value.\n */\n email: 'email',\n /**\n * URL value.\n */\n url: 'url',\n /**\n * IPv4 address value.\n */\n ipv4: 'ipv4',\n /**\n * IPv6 address value.\n */\n ipv6: 'ipv6',\n /**\n * Binary/blob value.\n */\n blob: 'blob',\n /**\n * Impossible value (`never`).\n */\n never: 'never',\n} as const satisfies Record<SchemaType, SchemaType>\n\n/**\n * Default sibling concurrency for `walk()`. Higher values overlap I/O-bound visitor work,\n * lower values reduce memory pressure. Pass `concurrency` to `walk()` to override it.\n *\n * @example\n * ```ts\n * import { walk, WALK_CONCURRENCY } from '@kubb/ast'\n *\n * walk(root, { concurrency: WALK_CONCURRENCY, operation: () => {} })\n * ```\n */\nexport const WALK_CONCURRENCY = 30\n\n/**\n * Number of spaces in one indentation level when assembling multi-line code as strings.\n * Set to 2, 3, … to change the indent width used by `buildObject`/`buildList`.\n */\nconst INDENT_SIZE = 2\n\n/**\n * One indentation level, derived from {@link INDENT_SIZE}.\n */\nexport const INDENT = Array.from({ length: INDENT_SIZE }, () => ' ').join('')\n","import type { HttpOperationNode, OperationNode, SchemaNode, SchemaNodeByType } from './nodes/index.ts'\n\n/**\n * Narrows a `SchemaNode` to the variant that matches `type`.\n *\n * @example\n * ```ts\n * const schema = createSchema({ type: 'string' })\n * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null\n * ```\n */\nexport function narrowSchema<T extends SchemaNode['type']>(node: SchemaNode | undefined, type: T): SchemaNodeByType[T] | null {\n return node?.type === type ? (node as SchemaNodeByType[T]) : null\n}\n\n/**\n * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.\n *\n * @example\n * ```ts\n * if (isHttpOperationNode(node)) {\n * console.log(node.method, node.path)\n * }\n * ```\n */\nexport function isHttpOperationNode(node: OperationNode): node is HttpOperationNode {\n return node.protocol === 'http' || (node.method !== undefined && node.path !== undefined)\n}\n","import type { NodeDef } from './defineNode.ts'\nimport { arrowFunctionDef, breakDef, constDef, functionDef, jsxDef, textDef, typeDef } from './nodes/code.ts'\nimport { contentDef } from './nodes/content.ts'\nimport { exportDef, fileDef, importDef, sourceDef } from './nodes/file.ts'\nimport { functionParameterDef, functionParametersDef, indexedAccessTypeDef, objectBindingPatternDef, typeLiteralDef } from './nodes/function.ts'\nimport { inputDef } from './nodes/input.ts'\nimport { operationDef } from './nodes/operation.ts'\nimport { outputDef } from './nodes/output.ts'\nimport { parameterDef } from './nodes/parameter.ts'\nimport { propertyDef } from './nodes/property.ts'\nimport { requestBodyDef } from './nodes/requestBody.ts'\nimport { responseDef } from './nodes/response.ts'\nimport { schemaDef } from './nodes/schema.ts'\n\n// Surface every def from one place so the package barrel re-exports them with `export * from './registry.ts'`.\n// Adding a node means adding its `defineNode` to a `nodes/*.ts` file and listing it in `nodeDefs` below, nothing else.\nexport {\n arrowFunctionDef,\n breakDef,\n constDef,\n contentDef,\n exportDef,\n fileDef,\n functionDef,\n functionParameterDef,\n functionParametersDef,\n importDef,\n indexedAccessTypeDef,\n inputDef,\n jsxDef,\n objectBindingPatternDef,\n operationDef,\n outputDef,\n parameterDef,\n propertyDef,\n requestBodyDef,\n responseDef,\n schemaDef,\n sourceDef,\n textDef,\n typeDef,\n typeLiteralDef,\n}\n\n/**\n * Every node definition. Adding a node means adding its `defineNode` to one\n * `nodes/*.ts` file and listing it here. The visitor tables in `visitor.ts` derive from it.\n */\nexport const nodeDefs = [\n inputDef,\n outputDef,\n operationDef,\n requestBodyDef,\n contentDef,\n responseDef,\n schemaDef,\n propertyDef,\n parameterDef,\n functionParameterDef,\n functionParametersDef,\n typeLiteralDef,\n indexedAccessTypeDef,\n objectBindingPatternDef,\n constDef,\n typeDef,\n functionDef,\n arrowFunctionDef,\n textDef,\n breakDef,\n jsxDef,\n importDef,\n exportDef,\n sourceDef,\n fileDef,\n] satisfies ReadonlyArray<NodeDef>\n","import type { VisitorDepth } from './constants.ts'\nimport { visitorDepths, WALK_CONCURRENCY } from './constants.ts'\nimport type { NodeDef } from './defineNode.ts'\nimport type {\n ContentNode,\n InputNode,\n Node,\n NodeKind,\n OperationNode,\n OutputNode,\n ParameterNode,\n PropertyNode,\n RequestBodyNode,\n ResponseNode,\n SchemaNode,\n} from './nodes/index.ts'\nimport { nodeDefs } from './registry.ts'\n\n/**\n * Child node fields per node kind, in traversal order (Babel's `VISITOR_KEYS`).\n * Derived from each definition's `children`.\n */\nconst VISITOR_KEYS = Object.fromEntries(nodeDefs.flatMap((def) => (def.children ? [[def.kind, def.children] as const] : []))) as Partial<\n Record<NodeKind, ReadonlyArray<string>>\n>\n\n/**\n * Maps a node kind to the matching visitor callback name. Derived from each\n * definition's `visitorKey`.\n */\nconst VISITOR_KEY_BY_KIND = Object.fromEntries(nodeDefs.flatMap((def) => (def.visitorKey ? [[def.kind, def.visitorKey] as const] : []))) as Partial<\n Record<NodeKind, NonNullable<NodeDef['visitorKey']>>\n>\n\n/**\n * Creates a small async concurrency limiter.\n *\n * At most `concurrency` tasks are in flight at once. Extra tasks are queued.\n *\n * @example\n * ```ts\n * const limit = createLimit(2)\n * for (const task of [taskA, taskB, taskC]) {\n * await limit(() => task())\n * }\n * // only 2 tasks run at the same time\n * ```\n */\nfunction createLimit(concurrency: number) {\n let active = 0\n const queue: Array<() => void> = []\n\n function next() {\n if (active < concurrency && queue.length > 0) {\n active++\n queue.shift()!()\n }\n }\n\n return function limit<T>(fn: () => Promise<T> | T): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n queue.push(() => {\n Promise.resolve(fn())\n .then(resolve, reject)\n .finally(() => {\n active--\n next()\n })\n })\n next()\n })\n }\n}\n\ntype LimitFn = ReturnType<typeof createLimit>\n\n/**\n * Ordered mapping of `[NodeType, ParentType]` pairs.\n *\n * `ParentOf` uses this map to find parent types.\n */\ntype ParentNodeMap = [\n [InputNode, undefined],\n [OutputNode, undefined],\n [OperationNode, InputNode],\n [RequestBodyNode, OperationNode],\n [ContentNode, RequestBodyNode | ResponseNode],\n [SchemaNode, InputNode | ContentNode | SchemaNode | PropertyNode | ParameterNode],\n [PropertyNode, SchemaNode],\n [ParameterNode, OperationNode],\n [ResponseNode, OperationNode],\n]\n\n/**\n * Resolves the parent node type for a given AST node type.\n *\n * Visitor context relies on this so `ctx.parent` is typed for each callback.\n *\n * @example\n * ```ts\n * type InputParent = ParentOf<InputNode>\n * // undefined\n * ```\n *\n * @example\n * ```ts\n * type PropertyParent = ParentOf<PropertyNode>\n * // SchemaNode\n * ```\n *\n * @example\n * ```ts\n * type SchemaParent = ParentOf<SchemaNode>\n * // InputNode | ContentNode | SchemaNode | PropertyNode | ParameterNode\n * ```\n */\nexport type ParentOf<T extends Node, TEntries extends ReadonlyArray<[Node, unknown]> = ParentNodeMap> = TEntries extends [\n infer TEntry extends [Node, unknown],\n ...infer TRest extends ReadonlyArray<[Node, unknown]>,\n]\n ? T extends TEntry[0]\n ? TEntry[1]\n : ParentOf<T, TRest>\n : Node\n\n/**\n * Traversal context passed as the second argument to every visitor callback.\n * `parent` is typed from the current node type.\n *\n * @example\n * ```ts\n * const visitor: Visitor = {\n * schema(node, { parent }) {\n * // parent type is narrowed by node kind\n * },\n * }\n * ```\n */\nexport type VisitorContext<T extends Node = Node> = {\n /**\n * Parent node of the currently visited node.\n * For `InputNode`, this is `undefined`.\n */\n parent?: ParentOf<T>\n}\n\n/**\n * Synchronous visitor consumed by `transform`. Each optional callback runs\n * for the matching node type. Return a new node to replace it, or `undefined`\n * to leave it untouched.\n *\n * Plugins typically expose `transformer` so users can supply a `Visitor` that\n * rewrites the AST before printing.\n *\n * @example Prefix every operationId\n * ```ts\n * const visitor: Visitor = {\n * operation(node) {\n * return { ...node, operationId: `api_${node.operationId}` }\n * },\n * }\n * ```\n *\n * @example Strip schema descriptions\n * ```ts\n * const visitor: Visitor = {\n * schema(node) {\n * return { ...node, description: undefined }\n * },\n * }\n * ```\n */\nexport type Visitor = {\n input?(node: InputNode, context: VisitorContext<InputNode>): undefined | null | InputNode\n output?(node: OutputNode, context: VisitorContext<OutputNode>): undefined | null | OutputNode\n operation?(node: OperationNode, context: VisitorContext<OperationNode>): undefined | null | OperationNode\n schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): undefined | null | SchemaNode\n property?(node: PropertyNode, context: VisitorContext<PropertyNode>): undefined | null | PropertyNode\n parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): undefined | null | ParameterNode\n response?(node: ResponseNode, context: VisitorContext<ResponseNode>): undefined | null | ResponseNode\n}\n\n/**\n * A visitor callback result that may be sync or async.\n */\ntype MaybePromise<T> = T | Promise<T>\n\n/**\n * Async visitor for `walk`. Synchronous `Visitor` objects are compatible.\n *\n * @example\n * ```ts\n * const visitor: AsyncVisitor = {\n * async operation(node) {\n * await Promise.resolve(node.operationId)\n * },\n * }\n * ```\n */\ntype AsyncVisitor = {\n input?(node: InputNode, context: VisitorContext<InputNode>): MaybePromise<undefined | null | InputNode>\n output?(node: OutputNode, context: VisitorContext<OutputNode>): MaybePromise<undefined | null | OutputNode>\n operation?(node: OperationNode, context: VisitorContext<OperationNode>): MaybePromise<undefined | null | OperationNode>\n schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): MaybePromise<undefined | null | SchemaNode>\n property?(node: PropertyNode, context: VisitorContext<PropertyNode>): MaybePromise<undefined | null | PropertyNode>\n parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): MaybePromise<undefined | null | ParameterNode>\n response?(node: ResponseNode, context: VisitorContext<ResponseNode>): MaybePromise<undefined | null | ResponseNode>\n}\n\n/**\n * Visitor used by `collect`.\n *\n * @example\n * ```ts\n * const visitor: CollectVisitor<string> = {\n * operation(node) {\n * return node.operationId\n * },\n * }\n * ```\n */\ntype CollectVisitor<T> = {\n input?(node: InputNode, context: VisitorContext<InputNode>): T | null | undefined\n output?(node: OutputNode, context: VisitorContext<OutputNode>): T | null | undefined\n operation?(node: OperationNode, context: VisitorContext<OperationNode>): T | null | undefined\n schema?(node: SchemaNode, context: VisitorContext<SchemaNode>): T | null | undefined\n property?(node: PropertyNode, context: VisitorContext<PropertyNode>): T | null | undefined\n parameter?(node: ParameterNode, context: VisitorContext<ParameterNode>): T | null | undefined\n response?(node: ResponseNode, context: VisitorContext<ResponseNode>): T | null | undefined\n}\n\n/**\n * Options for `transform`.\n *\n * @example\n * ```ts\n * const options: TransformOptions = { depth: 'deep', schema: (node) => node }\n * ```\n *\n * @example\n * ```ts\n * // Only transform the current node, not nested children\n * const options: TransformOptions = { depth: 'shallow', schema: (node) => node }\n * ```\n */\nexport type TransformOptions = Visitor & {\n /**\n * Traversal depth.\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Internal parent override used during recursion.\n */\n parent?: Node\n}\n\n/**\n * Options for `walk`.\n *\n * @example\n * ```ts\n * const options: WalkOptions = { depth: 'deep', concurrency: 10, root: () => {} }\n * ```\n */\nexport type WalkOptions = AsyncVisitor & {\n /**\n * Traversal depth.\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Maximum number of sibling nodes visited concurrently.\n * @default 30\n */\n concurrency?: number\n}\n\n/**\n * Options for `collect`.\n *\n * @example\n * ```ts\n * const options: CollectOptions<string> = { depth: 'shallow', schema: () => undefined }\n * ```\n */\nexport type CollectOptions<T> = CollectVisitor<T> & {\n /**\n * Traversal depth.\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Internal parent override used during recursion.\n */\n parent?: Node\n}\n\nconst visitorKeysByKind = VISITOR_KEYS as Record<string, ReadonlyArray<string> | undefined>\n\n/**\n * Returns `true` when `value` is an AST node (an object carrying a `kind`).\n */\nfunction isNode(value: unknown): value is Node {\n return typeof value === 'object' && value !== null && 'kind' in value\n}\n\n/**\n * Returns the immediate traversable children of `node` based on {@link VISITOR_KEYS}.\n *\n * `Schema` children are only included when `recurse` is `true`. Shallow mode skips them.\n *\n * @example\n * ```ts\n * const children = getChildren(operationNode, true)\n * // returns parameters, the request body, and responses\n * ```\n */\nfunction* getChildren(node: Node, recurse: boolean): Generator<Node, void, undefined> {\n if (node.kind === 'Schema' && !recurse) return\n\n const keys = visitorKeysByKind[node.kind]\n if (!keys) return\n\n const record = node as unknown as Record<string, unknown>\n for (const key of keys) {\n const value = record[key]\n if (Array.isArray(value)) {\n for (const item of value) if (isNode(item)) yield item\n } else if (isNode(value)) {\n yield value\n }\n }\n}\n\n/**\n * Runs the visitor callback that matches `node.kind` with the traversal\n * context. The result is a replacement node, a collected value, or `undefined`\n * when no callback is registered for the kind.\n *\n * Shared by `walk`, `transform`, and `collectLazy` so node-kind dispatch lives\n * in one place. `TResult` is the caller's expected return: the same node type\n * for `transform`, the collected value type for `collectLazy`, ignored for `walk`.\n */\nfunction applyVisitor<TResult>(node: Node, visitor: Visitor | AsyncVisitor | CollectVisitor<unknown>, parent: Node | undefined): TResult | null | undefined {\n const key = VISITOR_KEY_BY_KIND[node.kind]\n if (!key) return undefined\n\n const fn = visitor[key] as ((node: Node, context: VisitorContext) => TResult | null | undefined) | undefined\n\n return fn?.(node, { parent })\n}\n\n/**\n * Async depth-first traversal for side effects. Visitor return values are\n * ignored. Use `transform` when you want to rewrite nodes.\n *\n * Sibling nodes at each depth run concurrently up to `options.concurrency`\n * (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor\n * work. Lower values reduce memory pressure.\n *\n * @example Log every operation\n * ```ts\n * await walk(root, {\n * operation(node) {\n * console.log(node.operationId)\n * },\n * })\n * ```\n *\n * @example Only visit the root node\n * ```ts\n * await walk(root, { depth: 'shallow', input: () => {} })\n * ```\n */\nexport async function walk(node: Node, options: WalkOptions): Promise<void> {\n const recurse = (options.depth ?? visitorDepths.deep) === visitorDepths.deep\n const limit = createLimit(options.concurrency ?? WALK_CONCURRENCY)\n\n return _walk(node, options, recurse, limit, undefined)\n}\n\nasync function _walk(node: Node, visitor: AsyncVisitor, recurse: boolean, limit: LimitFn, parent: Node | undefined): Promise<void> {\n await limit(() => applyVisitor(node, visitor, parent))\n\n // Visit siblings concurrently and let the shared `limit` cap how many callbacks\n // run at once. Awaiting each child sequentially here would serialize the whole\n // traversal and make `concurrency` inert. Every visitor callback would run one\n // at a time regardless of the limit.\n const children = Array.from(getChildren(node, recurse))\n if (children.length === 0) return\n\n await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit, node)))\n}\n\n/**\n * Synchronous depth-first transform. Each visitor callback can return a\n * replacement node. Returning `undefined` keeps the original.\n *\n * The original tree is never mutated, a new tree is returned. Pass\n * `depth: 'shallow'` to skip recursion into children.\n *\n * @example Prefix every operationId\n * ```ts\n * const next = transform(root, {\n * operation(node) {\n * return { ...node, operationId: `prefixed_${node.operationId}` }\n * },\n * })\n * ```\n *\n * @example Replace only the root node\n * ```ts\n * const next = transform(root, {\n * depth: 'shallow',\n * input: (node) => ({ ...node, meta: { ...node.meta, title: 'Rewritten' } }),\n * })\n * ```\n */\nexport function transform(node: InputNode, options: TransformOptions): InputNode\nexport function transform(node: OutputNode, options: TransformOptions): OutputNode\nexport function transform(node: OperationNode, options: TransformOptions): OperationNode\nexport function transform(node: SchemaNode, options: TransformOptions): SchemaNode\nexport function transform(node: PropertyNode, options: TransformOptions): PropertyNode\nexport function transform(node: ParameterNode, options: TransformOptions): ParameterNode\nexport function transform(node: ResponseNode, options: TransformOptions): ResponseNode\nexport function transform(node: Node, options: TransformOptions): Node\nexport function transform(node: Node, options: TransformOptions): Node {\n const { depth, parent, ...visitor } = options\n const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep\n\n const visited = applyVisitor<Node>(node, visitor, parent) ?? node\n const rebuilt = transformChildren(visited, options, recurse)\n\n // Structural sharing: when the visitor and child rebuild both left this node\n // untouched, return the original reference so callers can detect \"nothing\n // changed\" by identity and ancestors can avoid reallocating.\n return rebuilt\n}\n\n/**\n * Immutably rebuilds a node's children using {@link VISITOR_KEYS}, transforming\n * each child node and leaving non-node values (e.g. `additionalProperties: true`) intact.\n * `Schema` children are skipped in shallow mode.\n */\nfunction transformChildren(node: Node, options: TransformOptions, recurse: boolean): Node {\n if (node.kind === 'Schema' && !recurse) return node\n\n const keys = visitorKeysByKind[node.kind]\n if (!keys) return node\n\n const record = node as unknown as Record<string, unknown>\n const childOptions = { ...options, parent: node }\n let updates: Record<string, unknown> | undefined\n\n for (const key of keys) {\n if (!(key in record)) continue\n const value = record[key]\n if (Array.isArray(value)) {\n let changed = false\n const mapped = value.map((item) => {\n if (!isNode(item)) return item\n const next = transform(item, childOptions)\n if (next !== item) changed = true\n return next\n })\n if (changed) (updates ??= {})[key] = mapped\n } else if (isNode(value)) {\n const next = transform(value, childOptions)\n if (next !== value) (updates ??= {})[key] = next\n }\n }\n\n return updates ? ({ ...node, ...updates } as Node) : node\n}\n/**\n * Lazy depth-first collection pass. Yields every non-null value returned by\n * the visitor callbacks. Use `collect` for the eager array form.\n *\n * @example Collect every operationId\n * ```ts\n * const ids: string[] = []\n * for (const id of collectLazy<string>(root, {\n * operation(node) {\n * return node.operationId\n * },\n * })) {\n * ids.push(id)\n * }\n * ```\n */\nexport function* collectLazy<T>(node: Node, options: CollectOptions<T>): Generator<T, void, undefined> {\n const { depth, parent, ...visitor } = options\n const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep\n\n const v = applyVisitor<T>(node, visitor, parent)\n if (v != null) yield v\n\n for (const child of getChildren(node, recurse)) {\n yield* collectLazy(child, { ...options, parent: node })\n }\n}\n\n/**\n * Eager depth-first collection pass. Gathers every non-null value the visitor\n * callbacks return into an array.\n *\n * @example Collect every operationId\n * ```ts\n * const ids = collect<string>(root, {\n * operation(node) {\n * return node.operationId\n * },\n * })\n * ```\n */\nexport function collect<T>(node: Node, options: CollectOptions<T>): Array<T> {\n return Array.from(collectLazy(node, options))\n}\n","import { pascalCase } from '@internals/utils'\nimport { narrowSchema } from '../guards.ts'\nimport type { OperationNode, ParameterNode, SchemaNode } from '../nodes/index.ts'\nimport { createSchema, type SchemaType } from '../nodes/schema.ts'\nimport type { OperationParamsResolver, ParamGroupType } from './operationParams.ts'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)\n\n/**\n * Returns the last path segment of a reference string.\n *\n * @example\n * `extractRefName('#/components/schemas/Pet') // 'Pet'`\n */\nexport function extractRefName(ref: string): string {\n return ref.split('/').at(-1) ?? ref\n}\n\n/**\n * Resolves the schema name of a ref node. Uses the last segment of `ref` when set, otherwise falls\n * back to `name` then nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n */\nexport function resolveRefName(node: SchemaNode | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.ref) return extractRefName(node.ref) ?? node.name ?? node.schema?.name ?? null\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Builds a PascalCase child schema name by joining a parent name and property name.\n * Returns `null` when there is no parent to nest under.\n *\n * @example Nested under a parent\n * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`\n *\n * @example No parent\n * `childName(undefined, 'params') // null`\n */\nexport function childName(parentName: string | null | undefined, propName: string): string | null {\n return parentName ? pascalCase([parentName, propName].join(' ')) : null\n}\n\n/**\n * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any\n * empty parts.\n *\n * @example\n * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`\n */\nexport function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string {\n return pascalCase([parentName, propName, enumSuffix].filter(Boolean).join(' '))\n}\n\n/**\n * Merges a ref node with its resolved schema, giving usage-site fields precedence.\n *\n * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the\n * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,\n * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref\n * nodes and refs without a resolved `schema` are returned unchanged.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })\n * const merged = syncSchemaRef(ref) // merges with resolved Pet schema\n * ```\n */\nexport function syncSchemaRef(node: SchemaNode): SchemaNode {\n const ref = narrowSchema(node, 'ref')\n\n if (!ref) return node\n if (!ref.schema) return node\n\n const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref\n\n // Filter out undefined override values so they don't shadow the resolved schema's fields.\n const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== undefined))\n\n return createSchema({ ...ref.schema, ...definedOverrides })\n}\n\n/**\n * Type guard that returns `true` when a schema emits as a plain `string` type.\n *\n * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`\n * types, returns `true` only when `representation` is `'string'` rather than `'date'`.\n */\nexport function isStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n\n/**\n * Derives a {@link ParamGroupType} for a query or header group from the resolver.\n *\n * Returns `null` when there is no resolver, no params, or the group name equals the\n * individual param name (so there is no real group to emit).\n */\nexport function resolveGroupType({\n node,\n params,\n group,\n resolver,\n}: {\n node: OperationNode\n params: Array<ParameterNode>\n group: 'query' | 'header'\n resolver: OperationParamsResolver | undefined\n}): ParamGroupType | null {\n if (!resolver || !params.length) {\n return null\n }\n const firstParam = params[0]!\n const groupMethod = group === 'query' ? resolver.resolveQueryParamsName : resolver.resolveHeaderParamsName\n const groupName = groupMethod.call(resolver, node, firstParam)\n if (groupName === resolver.resolveParamName(node, firstParam)) {\n return null\n }\n return { type: groupName, optional: params.every((p) => !p.required) }\n}\n"],"mappings":";;AAUA,MAAa,gBAAgB;CAC3B,SAAS;CACT,MAAM;AACR;;;;;;AAOA,MAAa,cAAc;;;;CAIzB,QAAQ;;;;CAIR,QAAQ;;;;CAIR,SAAS;;;;CAIT,QAAQ;;;;CAIR,SAAS;;;;CAIT,MAAM;;;;CAIN,KAAK;;;;CAIL,SAAS;;;;CAIT,MAAM;;;;CAIN,QAAQ;;;;CAIR,OAAO;;;;CAIP,OAAO;;;;CAIP,OAAO;;;;CAIP,cAAc;;;;CAId,MAAM;;;;CAIN,KAAK;;;;CAIL,MAAM;;;;CAIN,UAAU;;;;CAIV,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;;;;CAIP,KAAK;;;;CAIL,MAAM;;;;CAIN,MAAM;;;;CAIN,MAAM;;;;CAIN,OAAO;AACT;;;;AAwBA,MAAa,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAY,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE;;;;;;;;;;;;AC1I5E,SAAgB,aAA2C,MAA8B,MAAqC;CAC5H,OAAO,MAAM,SAAS,OAAQ,OAA+B;AAC/D;;;;;;;;;;;AAYA,SAAgB,oBAAoB,MAAgD;CAClF,OAAO,KAAK,aAAa,UAAW,KAAK,WAAW,KAAA,KAAa,KAAK,SAAS,KAAA;AACjF;;;;;;;ACqBA,MAAa,WAAW;CACtBA,eAAAA;CACAC,eAAAA;CACAC,eAAAA;CACAC,eAAAA;CACAC,eAAAA;CACAC,eAAAA;CACAC,eAAAA;CACAC,eA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