@kubb/ast 5.0.0-beta.75 → 5.0.0-beta.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +53 -27
  3. package/dist/defineMacro-C58x6uaa.cjs +114 -0
  4. package/dist/defineMacro-C58x6uaa.cjs.map +1 -0
  5. package/dist/defineMacro-DzsACbFo.d.ts +466 -0
  6. package/dist/defineMacro-Zagno12u.js +98 -0
  7. package/dist/defineMacro-Zagno12u.js.map +1 -0
  8. package/dist/index-Cu2zmNxv.d.ts +2188 -0
  9. package/dist/index.cjs +183 -2179
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +88 -3364
  12. package/dist/index.js +139 -2101
  13. package/dist/index.js.map +1 -1
  14. package/dist/macros.cjs +130 -0
  15. package/dist/macros.cjs.map +1 -0
  16. package/dist/macros.d.ts +61 -0
  17. package/dist/macros.js +128 -0
  18. package/dist/macros.js.map +1 -0
  19. package/dist/refs-DhraOHHv.cjs +135 -0
  20. package/dist/refs-DhraOHHv.cjs.map +1 -0
  21. package/dist/refs-DliAPaUa.js +101 -0
  22. package/dist/refs-DliAPaUa.js.map +1 -0
  23. package/dist/rolldown-runtime-CNktS9qV.js +17 -0
  24. package/dist/types-Ctz5NB1o.d.ts +244 -0
  25. package/dist/types.cjs +0 -0
  26. package/dist/types.d.ts +4 -0
  27. package/dist/types.js +1 -0
  28. package/dist/utils.cjs +613 -0
  29. package/dist/utils.cjs.map +1 -0
  30. package/dist/utils.d.ts +353 -0
  31. package/dist/utils.js +589 -0
  32. package/dist/utils.js.map +1 -0
  33. package/dist/visitor-CDa9Cn6x.cjs +1547 -0
  34. package/dist/visitor-CDa9Cn6x.cjs.map +1 -0
  35. package/dist/visitor-Ns-njjbG.js +1183 -0
  36. package/dist/visitor-Ns-njjbG.js.map +1 -0
  37. package/package.json +18 -7
  38. package/dist/chunk--u3MIqq1.js +0 -8
  39. package/src/constants.ts +0 -228
  40. package/src/factory.ts +0 -742
  41. package/src/guards.ts +0 -110
  42. package/src/index.ts +0 -45
  43. package/src/infer.ts +0 -130
  44. package/src/mocks.ts +0 -176
  45. package/src/nodes/base.ts +0 -56
  46. package/src/nodes/code.ts +0 -304
  47. package/src/nodes/file.ts +0 -230
  48. package/src/nodes/function.ts +0 -223
  49. package/src/nodes/http.ts +0 -119
  50. package/src/nodes/index.ts +0 -86
  51. package/src/nodes/operation.ts +0 -111
  52. package/src/nodes/output.ts +0 -26
  53. package/src/nodes/parameter.ts +0 -41
  54. package/src/nodes/property.ts +0 -34
  55. package/src/nodes/response.ts +0 -43
  56. package/src/nodes/root.ts +0 -64
  57. package/src/nodes/schema.ts +0 -656
  58. package/src/printer.ts +0 -250
  59. package/src/refs.ts +0 -67
  60. package/src/resolvers.ts +0 -45
  61. package/src/transformers.ts +0 -159
  62. package/src/types.ts +0 -70
  63. package/src/utils.ts +0 -833
  64. package/src/visitor.ts +0 -592
@@ -0,0 +1,1547 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", {
5
+ value,
6
+ configurable: true
7
+ });
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __exportAll = (all, no_symbols) => {
13
+ let target = {};
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
+ value: mod,
33
+ enumerable: true
34
+ }) : target, mod));
35
+ //#endregion
36
+ let node_crypto = require("node:crypto");
37
+ let node_path = require("node:path");
38
+ node_path = __toESM(node_path, 1);
39
+ //#region src/constants.ts
40
+ const visitorDepths = {
41
+ shallow: "shallow",
42
+ deep: "deep"
43
+ };
44
+ /**
45
+ * Schema type discriminators used by all AST schema nodes.
46
+ *
47
+ * Each value is a stable discriminator across the AST (for example `schema.type === schemaTypes.object`).
48
+ */
49
+ const schemaTypes = {
50
+ /**
51
+ * Text value.
52
+ */
53
+ string: "string",
54
+ /**
55
+ * Floating-point number (`float`, `double`).
56
+ */
57
+ number: "number",
58
+ /**
59
+ * Whole number (`int32`). Use `bigint` for `int64`.
60
+ */
61
+ integer: "integer",
62
+ /**
63
+ * 64-bit integer (`int64`). Only used when `integerType` is set to `'bigint'`.
64
+ */
65
+ bigint: "bigint",
66
+ /**
67
+ * Boolean value.
68
+ */
69
+ boolean: "boolean",
70
+ /**
71
+ * Explicit null value.
72
+ */
73
+ null: "null",
74
+ /**
75
+ * Any value (no type restriction).
76
+ */
77
+ any: "any",
78
+ /**
79
+ * Unknown value (must be narrowed before usage).
80
+ */
81
+ unknown: "unknown",
82
+ /**
83
+ * No return value (`void`).
84
+ */
85
+ void: "void",
86
+ /**
87
+ * Object with named properties.
88
+ */
89
+ object: "object",
90
+ /**
91
+ * Sequential list of items.
92
+ */
93
+ array: "array",
94
+ /**
95
+ * Fixed-length list with position-specific items.
96
+ */
97
+ tuple: "tuple",
98
+ /**
99
+ * "One of" multiple schema members.
100
+ */
101
+ union: "union",
102
+ /**
103
+ * "All of" multiple schema members.
104
+ */
105
+ intersection: "intersection",
106
+ /**
107
+ * Enum schema.
108
+ */
109
+ enum: "enum",
110
+ /**
111
+ * Reference to another schema.
112
+ */
113
+ ref: "ref",
114
+ /**
115
+ * Calendar date (for example `2026-03-24`).
116
+ */
117
+ date: "date",
118
+ /**
119
+ * Date-time value (for example `2026-03-24T09:00:00Z`).
120
+ */
121
+ datetime: "datetime",
122
+ /**
123
+ * Time-only value (for example `09:00:00`).
124
+ */
125
+ time: "time",
126
+ /**
127
+ * UUID value.
128
+ */
129
+ uuid: "uuid",
130
+ /**
131
+ * Email address value.
132
+ */
133
+ email: "email",
134
+ /**
135
+ * URL value.
136
+ */
137
+ url: "url",
138
+ /**
139
+ * IPv4 address value.
140
+ */
141
+ ipv4: "ipv4",
142
+ /**
143
+ * IPv6 address value.
144
+ */
145
+ ipv6: "ipv6",
146
+ /**
147
+ * Binary/blob value.
148
+ */
149
+ blob: "blob",
150
+ /**
151
+ * Impossible value (`never`).
152
+ */
153
+ never: "never"
154
+ };
155
+ //#endregion
156
+ //#region src/guards.ts
157
+ /**
158
+ * Narrows a `SchemaNode` to the variant that matches `type`.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * const schema = createSchema({ type: 'string' })
163
+ * const stringNode = narrowSchema(schema, 'string') // StringSchemaNode | null
164
+ * ```
165
+ */
166
+ function narrowSchema(node, type) {
167
+ return node?.type === type ? node : null;
168
+ }
169
+ /**
170
+ * Narrows an `OperationNode` to an `HttpOperationNode` so `method` and `path` are present.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * if (isHttpOperationNode(node)) {
175
+ * console.log(node.method, node.path)
176
+ * }
177
+ * ```
178
+ */
179
+ function isHttpOperationNode(node) {
180
+ return node.protocol === "http" || node.method !== void 0 && node.path !== void 0;
181
+ }
182
+ //#endregion
183
+ //#region src/defineNode.ts
184
+ /**
185
+ * Visitor callback names, one per traversable node kind, in traversal order.
186
+ * Kept in sync with the keys of `Visitor` in `visitor.ts`.
187
+ */
188
+ const visitorKeys = [
189
+ "input",
190
+ "output",
191
+ "operation",
192
+ "schema",
193
+ "property",
194
+ "parameter",
195
+ "response"
196
+ ];
197
+ /**
198
+ * Builds a type guard that matches nodes of the given `kind`.
199
+ */
200
+ function isKind(kind) {
201
+ return (node) => node?.kind === kind;
202
+ }
203
+ /**
204
+ * Defines a node once and derives its `create` builder, `is` guard, and traversal
205
+ * metadata. `create` merges `defaults`, the `build` hook (or the raw input), and the
206
+ * `kind`, so node construction lives in one place without scattered `as` casts.
207
+ *
208
+ * @example Simple node
209
+ * ```ts
210
+ * const importDef = defineNode<ImportNode>({ kind: 'Import' })
211
+ * const createImport = importDef.create
212
+ * ```
213
+ *
214
+ * @example Node with a build hook
215
+ * ```ts
216
+ * const propertyDef = defineNode<PropertyNode, UserPropertyNode>({
217
+ * kind: 'Property',
218
+ * build: (props) => ({ ...props, required: props.required ?? false }),
219
+ * children: ['schema'],
220
+ * visitorKey: 'property',
221
+ * })
222
+ * ```
223
+ */
224
+ function defineNode(config) {
225
+ const { kind, defaults, build, children, visitorKey } = config;
226
+ function create(input) {
227
+ const base = build ? build(input) : input;
228
+ return {
229
+ ...defaults,
230
+ ...base,
231
+ kind
232
+ };
233
+ }
234
+ return {
235
+ kind,
236
+ create,
237
+ is: isKind(kind),
238
+ children,
239
+ visitorKey
240
+ };
241
+ }
242
+ //#endregion
243
+ //#region src/nodes/code.ts
244
+ /**
245
+ * Definition for the {@link ConstNode}.
246
+ */
247
+ const constDef = defineNode({ kind: "Const" });
248
+ /**
249
+ * Definition for the {@link TypeNode}.
250
+ */
251
+ const typeDef = defineNode({ kind: "Type" });
252
+ /**
253
+ * Definition for the {@link FunctionNode}.
254
+ */
255
+ const functionDef = defineNode({ kind: "Function" });
256
+ /**
257
+ * Definition for the {@link ArrowFunctionNode}.
258
+ */
259
+ const arrowFunctionDef = defineNode({ kind: "ArrowFunction" });
260
+ /**
261
+ * Definition for the {@link TextNode}.
262
+ */
263
+ const textDef = defineNode({
264
+ kind: "Text",
265
+ build: (value) => ({ value })
266
+ });
267
+ /**
268
+ * Definition for the {@link BreakNode}.
269
+ */
270
+ const breakDef = defineNode({
271
+ kind: "Break",
272
+ build: () => ({})
273
+ });
274
+ /**
275
+ * Definition for the {@link JsxNode}.
276
+ */
277
+ const jsxDef = defineNode({
278
+ kind: "Jsx",
279
+ build: (value) => ({ value })
280
+ });
281
+ /**
282
+ * Creates a `ConstNode` representing a TypeScript `const` declaration.
283
+ *
284
+ * @example Exported constant with type and `as const`
285
+ * ```ts
286
+ * createConst({ name: 'pets', export: true, type: 'Pet[]', asConst: true })
287
+ * // export const pets: Pet[] = ... as const
288
+ * ```
289
+ */
290
+ const createConst = constDef.create;
291
+ /**
292
+ * Creates a `TypeNode` representing a TypeScript `type` alias declaration.
293
+ *
294
+ * @example
295
+ * ```ts
296
+ * createType({ name: 'Pet', export: true })
297
+ * // export type Pet = ...
298
+ * ```
299
+ */
300
+ const createType = typeDef.create;
301
+ /**
302
+ * Creates a `FunctionNode` representing a TypeScript `function` declaration.
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * createFunction({ name: 'fetchPet', export: true, async: true, returnType: 'Pet' })
307
+ * // export async function fetchPet(): Promise<Pet> { ... }
308
+ * ```
309
+ */
310
+ const createFunction = functionDef.create;
311
+ /**
312
+ * Creates an `ArrowFunctionNode` representing a TypeScript arrow function.
313
+ *
314
+ * @example
315
+ * ```ts
316
+ * createArrowFunction({ name: 'double', export: true, params: 'n: number', singleLine: true })
317
+ * // export const double = (n: number) => ...
318
+ * ```
319
+ */
320
+ const createArrowFunction = arrowFunctionDef.create;
321
+ /**
322
+ * Creates a {@link TextNode} representing a raw string fragment in the source output.
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * createText('return fetch(id)')
327
+ * // { kind: 'Text', value: 'return fetch(id)' }
328
+ * ```
329
+ */
330
+ const createText = textDef.create;
331
+ /**
332
+ * Creates a {@link BreakNode} representing a line break in the source output.
333
+ *
334
+ * @example
335
+ * ```ts
336
+ * createBreak()
337
+ * // { kind: 'Break' }
338
+ * ```
339
+ */
340
+ function createBreak() {
341
+ return breakDef.create();
342
+ }
343
+ /**
344
+ * Creates a {@link JsxNode} representing a raw JSX fragment in the source output.
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * createJsx('<>\n <a href={href}>Open</a>\n</>')
349
+ * // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
350
+ * ```
351
+ */
352
+ const createJsx = jsxDef.create;
353
+ //#endregion
354
+ //#region src/nodes/content.ts
355
+ /**
356
+ * Definition for the {@link ContentNode}.
357
+ */
358
+ const contentDef = defineNode({
359
+ kind: "Content",
360
+ children: ["schema"]
361
+ });
362
+ /**
363
+ * Creates a `ContentNode` for a single request-body or response content type.
364
+ */
365
+ const createContent = contentDef.create;
366
+ //#endregion
367
+ //#region ../../internals/utils/src/casing.ts
368
+ /**
369
+ * Shared implementation for camelCase and PascalCase conversion.
370
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
371
+ * and capitalizes each word according to `pascal`.
372
+ *
373
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
374
+ */
375
+ function toCamelOrPascal(text, pascal) {
376
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
377
+ if (word.length > 1 && word === word.toUpperCase()) return word;
378
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
379
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
380
+ }
381
+ /**
382
+ * Converts `text` to PascalCase.
383
+ *
384
+ * @example Word boundaries
385
+ * `pascalCase('hello-world') // 'HelloWorld'`
386
+ *
387
+ * @example With a suffix
388
+ * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
389
+ */
390
+ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
391
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
392
+ }
393
+ //#endregion
394
+ //#region ../../internals/utils/src/fs.ts
395
+ /**
396
+ * Strips the file extension from a path or file name.
397
+ * Only removes the last `.ext` segment when the dot is not part of a directory name.
398
+ *
399
+ * @example
400
+ * trimExtName('petStore.ts') // 'petStore'
401
+ * trimExtName('/src/models/pet.ts') // '/src/models/pet'
402
+ * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'
403
+ * trimExtName('noExtension') // 'noExtension'
404
+ */
405
+ function trimExtName(text) {
406
+ const dotIndex = text.lastIndexOf(".");
407
+ if (dotIndex > 0 && !text.includes("/", dotIndex)) return text.slice(0, dotIndex);
408
+ return text;
409
+ }
410
+ //#endregion
411
+ //#region src/utils/extractStringsFromNodes.ts
412
+ /**
413
+ * Extracts all string content from a `CodeNode` tree recursively.
414
+ *
415
+ * Collects text node values, identifier references in string fields (`params`, `generics`, `returnType`, `type`),
416
+ * and nested node content. Used to build the full source string for import filtering.
417
+ */
418
+ function extractStringsFromNodes(nodes) {
419
+ if (!nodes?.length) return "";
420
+ return nodes.map((node) => {
421
+ if (typeof node === "string") return node;
422
+ if (node.kind === "Text") return node.value;
423
+ if (node.kind === "Break") return "";
424
+ if (node.kind === "Jsx") return node.value;
425
+ const parts = [];
426
+ if ("params" in node && node.params) parts.push(node.params);
427
+ if ("generics" in node && node.generics) parts.push(Array.isArray(node.generics) ? node.generics.join(", ") : node.generics);
428
+ if ("returnType" in node && node.returnType) parts.push(node.returnType);
429
+ if ("type" in node && typeof node.type === "string") parts.push(node.type);
430
+ const nested = extractStringsFromNodes(node.nodes);
431
+ if (nested) parts.push(nested);
432
+ return parts.join("\n");
433
+ }).filter(Boolean).join("\n");
434
+ }
435
+ //#endregion
436
+ //#region src/utils/fileMerge.ts
437
+ function sourceKey(source) {
438
+ return `${source.name ?? extractStringsFromNodes(source.nodes)}:${source.isExportable ?? false}:${source.isTypeOnly ?? false}`;
439
+ }
440
+ function pathTypeKey(path, isTypeOnly) {
441
+ return `${path}:${isTypeOnly ?? false}`;
442
+ }
443
+ function exportKey(path, name, isTypeOnly, asAlias) {
444
+ return `${path}:${name ?? ""}:${isTypeOnly ?? false}:${asAlias ?? ""}`;
445
+ }
446
+ function importKey(path, name, isTypeOnly) {
447
+ return `${path}:${name ?? ""}:${isTypeOnly ?? false}`;
448
+ }
449
+ /**
450
+ * Computes a multi-level sort key for exports and imports:
451
+ * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical path. Unnamed before named.
452
+ */
453
+ function sortKey(node) {
454
+ const isArray = Array.isArray(node.name) ? "1" : "0";
455
+ const typeOnly = node.isTypeOnly ? "0" : "1";
456
+ const hasName = node.name != null ? "1" : "0";
457
+ const name = Array.isArray(node.name) ? node.name.toSorted().join("\0") : node.name ?? "";
458
+ return `${isArray}:${typeOnly}:${node.path}:${hasName}:${name}`;
459
+ }
460
+ /**
461
+ * Deduplicates `SourceNode` objects by `name + isExportable + isTypeOnly`, keeping the first of each
462
+ * key. Unnamed sources fall back to their extracted node strings as the name part of the key. Returns
463
+ * the deduplicated array in original order.
464
+ */
465
+ function combineSources(sources) {
466
+ const seen = /* @__PURE__ */ new Map();
467
+ for (const source of sources) {
468
+ const key = sourceKey(source);
469
+ if (!seen.has(key)) seen.set(key, source);
470
+ }
471
+ return [...seen.values()];
472
+ }
473
+ /**
474
+ * Merges `incoming` names into `existing`, preserving order and dropping duplicates.
475
+ *
476
+ * Shared by `combineExports` and `combineImports` for the same-path name-merge case.
477
+ */
478
+ function mergeNameArrays(existing, incoming) {
479
+ const merged = new Set(existing);
480
+ for (const name of incoming) merged.add(name);
481
+ return [...merged];
482
+ }
483
+ /**
484
+ * Deduplicates and merges `ExportNode` objects by path and type.
485
+ *
486
+ * Named exports with the same path and `isTypeOnly` flag have their names merged into a single export.
487
+ * Non-array exports are deduplicated by exact identity. Returns a sorted, deduplicated array.
488
+ */
489
+ function combineExports(exports) {
490
+ const result = [];
491
+ const namedByPath = /* @__PURE__ */ new Map();
492
+ const seen = /* @__PURE__ */ new Set();
493
+ const keyed = exports.map((node) => ({
494
+ node,
495
+ key: sortKey(node)
496
+ }));
497
+ keyed.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
498
+ for (const { node: curr } of keyed) {
499
+ const { name, path, isTypeOnly, asAlias } = curr;
500
+ if (Array.isArray(name)) {
501
+ if (!name.length) continue;
502
+ const key = pathTypeKey(path, isTypeOnly);
503
+ const existing = namedByPath.get(key);
504
+ if (existing && Array.isArray(existing.name)) existing.name = mergeNameArrays(existing.name, name);
505
+ else {
506
+ const newItem = {
507
+ ...curr,
508
+ name: [...new Set(name)]
509
+ };
510
+ result.push(newItem);
511
+ namedByPath.set(key, newItem);
512
+ }
513
+ } else {
514
+ const key = exportKey(path, name, isTypeOnly, asAlias);
515
+ if (!seen.has(key)) {
516
+ result.push(curr);
517
+ seen.add(key);
518
+ }
519
+ }
520
+ }
521
+ return result;
522
+ }
523
+ /**
524
+ * Deduplicates and merges `ImportNode` objects, filtering out unused imports.
525
+ *
526
+ * Retains imports that are referenced in `source` or re-exported. Imports with the same path and
527
+ * `isTypeOnly` flag have their names merged. Returns a sorted, deduplicated, filtered array.
528
+ */
529
+ function combineImports(imports, exports, source) {
530
+ const exportedNames = new Set(exports.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
531
+ const isUsed = (importName) => !source || source.includes(importName) || exportedNames.has(importName);
532
+ const importNameMemo = /* @__PURE__ */ new Map();
533
+ const canonicalizeName = (n) => {
534
+ if (typeof n === "string") return n;
535
+ const key = `${n.propertyName}:${n.name ?? ""}`;
536
+ if (!importNameMemo.has(key)) importNameMemo.set(key, n);
537
+ return importNameMemo.get(key);
538
+ };
539
+ const pathsWithUsedNamedImport = /* @__PURE__ */ new Set();
540
+ for (const node of imports) {
541
+ if (!Array.isArray(node.name)) continue;
542
+ if (node.name.some((item) => typeof item === "string" ? isUsed(item) : isUsed(item.name ?? item.propertyName))) pathsWithUsedNamedImport.add(node.path);
543
+ }
544
+ const result = [];
545
+ const namedByPath = /* @__PURE__ */ new Map();
546
+ const seen = /* @__PURE__ */ new Set();
547
+ const keyed = imports.map((node) => ({
548
+ node,
549
+ key: sortKey(node)
550
+ }));
551
+ keyed.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
552
+ for (const { node: curr } of keyed) {
553
+ if (curr.path === curr.root) continue;
554
+ const { path, isTypeOnly } = curr;
555
+ let { name } = curr;
556
+ if (Array.isArray(name)) {
557
+ name = [...new Set(name.map(canonicalizeName))].filter((item) => typeof item === "string" ? isUsed(item) : isUsed(item.name ?? item.propertyName));
558
+ if (!name.length) continue;
559
+ const key = pathTypeKey(path, isTypeOnly);
560
+ const existing = namedByPath.get(key);
561
+ if (existing && Array.isArray(existing.name)) existing.name = mergeNameArrays(existing.name, name);
562
+ else {
563
+ const newItem = {
564
+ ...curr,
565
+ name
566
+ };
567
+ result.push(newItem);
568
+ namedByPath.set(key, newItem);
569
+ }
570
+ } else {
571
+ if (name && !isUsed(name) && !pathsWithUsedNamedImport.has(path)) continue;
572
+ const key = importKey(path, name, isTypeOnly);
573
+ if (!seen.has(key)) {
574
+ result.push(curr);
575
+ seen.add(key);
576
+ }
577
+ }
578
+ }
579
+ return result;
580
+ }
581
+ //#endregion
582
+ //#region src/nodes/file.ts
583
+ /**
584
+ * Definition for the {@link ImportNode}.
585
+ */
586
+ const importDef = defineNode({ kind: "Import" });
587
+ /**
588
+ * Definition for the {@link ExportNode}.
589
+ */
590
+ const exportDef = defineNode({ kind: "Export" });
591
+ /**
592
+ * Definition for the {@link SourceNode}.
593
+ */
594
+ const sourceDef = defineNode({ kind: "Source" });
595
+ /**
596
+ * Definition for the {@link FileNode}. The fully resolved builder lives in
597
+ * `createFile`, so this definition only supplies the guard.
598
+ */
599
+ const fileDef = defineNode({ kind: "File" });
600
+ /**
601
+ * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
602
+ *
603
+ * @example Named import
604
+ * ```ts
605
+ * createImport({ name: ['useState'], path: 'react' })
606
+ * // import { useState } from 'react'
607
+ * ```
608
+ */
609
+ const createImport = importDef.create;
610
+ /**
611
+ * Creates an `ExportNode` representing a language-agnostic export/public API declaration.
612
+ *
613
+ * @example Named export
614
+ * ```ts
615
+ * createExport({ name: ['Pet'], path: './Pet' })
616
+ * // export { Pet } from './Pet'
617
+ * ```
618
+ */
619
+ const createExport = exportDef.create;
620
+ /**
621
+ * Creates a `SourceNode` representing a fragment of source code within a file.
622
+ *
623
+ * @example
624
+ * ```ts
625
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
626
+ * ```
627
+ */
628
+ const createSource = sourceDef.create;
629
+ /**
630
+ * Creates a fully resolved `FileNode` from a file input descriptor.
631
+ *
632
+ * Computes:
633
+ * - `id` SHA256 hash of the file path
634
+ * - `name` `baseName` without extension
635
+ * - `extname` extension extracted from `baseName`
636
+ *
637
+ * Deduplicates:
638
+ * - `sources` via `combineSources`
639
+ * - `exports` via `combineExports`
640
+ * - `imports` via `combineImports` (also filters unused imports)
641
+ *
642
+ * @throws {Error} when `baseName` has no extension.
643
+ *
644
+ * @example
645
+ * ```ts
646
+ * const file = createFile({
647
+ * baseName: 'petStore.ts',
648
+ * path: 'src/models/petStore.ts',
649
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],
650
+ * imports: [createImport({ name: ['z'], path: 'zod' })],
651
+ * exports: [createExport({ name: ['Pet'], path: './petStore' })],
652
+ * })
653
+ * // file.id = SHA256 hash of 'src/models/petStore.ts'
654
+ * // file.name = 'petStore'
655
+ * // file.extname = '.ts'
656
+ * ```
657
+ *
658
+ * @example Copy a real file into the output verbatim
659
+ * ```ts
660
+ * const file = createFile({
661
+ * baseName: 'client.ts',
662
+ * path: 'src/gen/client.ts',
663
+ * copy: '/abs/path/to/templates/client.ts',
664
+ * })
665
+ * ```
666
+ */
667
+ function createFile(input) {
668
+ const extname = node_path.default.extname(input.baseName) || (input.baseName.startsWith(".") ? input.baseName : "");
669
+ if (!extname) throw new Error(`No extname found for ${input.baseName}`);
670
+ const source = (input.sources ?? []).flatMap((item) => item.nodes ?? []).map((node) => extractStringsFromNodes([node])).filter(Boolean).join("\n\n");
671
+ const resolvedExports = input.exports?.length ? combineExports(input.exports) : [];
672
+ const combinedImports = input.imports?.length ? combineImports(input.imports, resolvedExports, source || void 0) : [];
673
+ const localNames = new Set((input.sources ?? []).map((item) => item.name).filter((name) => Boolean(name)));
674
+ const nameOf = (item) => typeof item === "string" ? item : item.name ?? item.propertyName;
675
+ const resolvedImports = combinedImports.filter((imp) => imp.path !== input.path).flatMap((imp) => {
676
+ if (!Array.isArray(imp.name)) return typeof imp.name === "string" && localNames.has(imp.name) ? [] : [imp];
677
+ const kept = imp.name.filter((item) => !localNames.has(nameOf(item)));
678
+ if (!kept.length) return [];
679
+ return [kept.length === imp.name.length ? imp : {
680
+ ...imp,
681
+ name: kept
682
+ }];
683
+ });
684
+ const resolvedSources = input.sources?.length ? combineSources(input.sources) : [];
685
+ return {
686
+ kind: "File",
687
+ ...input,
688
+ id: (0, node_crypto.hash)("sha256", input.path, "hex"),
689
+ name: trimExtName(input.baseName),
690
+ extname,
691
+ imports: resolvedImports,
692
+ exports: resolvedExports,
693
+ sources: resolvedSources,
694
+ meta: input.meta ?? {}
695
+ };
696
+ }
697
+ //#endregion
698
+ //#region src/nodes/input.ts
699
+ /**
700
+ * Definition for the {@link InputNode}.
701
+ */
702
+ const inputDef = defineNode({
703
+ kind: "Input",
704
+ defaults: {
705
+ schemas: [],
706
+ operations: [],
707
+ meta: {
708
+ circularNames: [],
709
+ enumNames: []
710
+ }
711
+ },
712
+ children: ["schemas", "operations"],
713
+ visitorKey: "input"
714
+ });
715
+ /**
716
+ * Creates an `InputNode`. Pass `stream: true` for the streaming variant whose `schemas` and
717
+ * `operations` are `AsyncIterable` sources. Otherwise it builds the eager variant with array
718
+ * `schemas`/`operations`. Both variants get the defaulted `meta`.
719
+ *
720
+ * @example Eager
721
+ * ```ts
722
+ * const input = createInput()
723
+ * // { kind: 'Input', schemas: [], operations: [] }
724
+ * ```
725
+ *
726
+ * @example Streaming
727
+ * ```ts
728
+ * const node = createInput({ stream: true, schemas: schemasIterable, operations: operationsIterable, meta: { title: 'My API' } })
729
+ * ```
730
+ */
731
+ function createInput(options = {}) {
732
+ const { stream, ...overrides } = options;
733
+ if (stream) return {
734
+ kind: "Input",
735
+ meta: {
736
+ circularNames: [],
737
+ enumNames: []
738
+ },
739
+ ...overrides
740
+ };
741
+ return inputDef.create(overrides);
742
+ }
743
+ //#endregion
744
+ //#region src/nodes/requestBody.ts
745
+ /**
746
+ * Definition for the {@link RequestBodyNode}. Content entries are built upfront with
747
+ * {@link createContent}, mirroring how `parameters` and `responses` take prebuilt nodes.
748
+ */
749
+ const requestBodyDef = defineNode({
750
+ kind: "RequestBody",
751
+ children: ["content"]
752
+ });
753
+ /**
754
+ * Creates a `RequestBodyNode`.
755
+ */
756
+ const createRequestBody = requestBodyDef.create;
757
+ //#endregion
758
+ //#region src/nodes/operation.ts
759
+ /**
760
+ * Definition for the {@link OperationNode}. HTTP operations (those carrying both
761
+ * `method` and `path`) are tagged with `protocol: 'http'`, and the request body is
762
+ * normalized into a `RequestBodyNode`.
763
+ */
764
+ const operationDef = defineNode({
765
+ kind: "Operation",
766
+ build: (props) => {
767
+ const { requestBody, ...rest } = props;
768
+ const isHttp = rest.method !== void 0 && rest.path !== void 0;
769
+ return {
770
+ tags: [],
771
+ parameters: [],
772
+ responses: [],
773
+ ...rest,
774
+ ...isHttp ? { protocol: "http" } : {},
775
+ requestBody: requestBody ? createRequestBody(requestBody) : void 0
776
+ };
777
+ },
778
+ children: [
779
+ "parameters",
780
+ "requestBody",
781
+ "responses"
782
+ ],
783
+ visitorKey: "operation"
784
+ });
785
+ function createOperation(props) {
786
+ return operationDef.create(props);
787
+ }
788
+ //#endregion
789
+ //#region src/nodes/output.ts
790
+ /**
791
+ * Definition for the {@link OutputNode}.
792
+ */
793
+ const outputDef = defineNode({
794
+ kind: "Output",
795
+ defaults: { files: [] },
796
+ visitorKey: "output"
797
+ });
798
+ /**
799
+ * Creates an `OutputNode` with a stable default for `files`.
800
+ *
801
+ * @example
802
+ * ```ts
803
+ * const output = createOutput()
804
+ * // { kind: 'Output', files: [] }
805
+ * ```
806
+ */
807
+ function createOutput(overrides = {}) {
808
+ return outputDef.create(overrides);
809
+ }
810
+ //#endregion
811
+ //#region src/optionality.ts
812
+ /**
813
+ * Generic JSON Schema optionality: a non-required field is optional, and a
814
+ * non-required nullable field is nullish.
815
+ */
816
+ function optionality(schema, required) {
817
+ const nullable = schema.nullable ?? false;
818
+ return {
819
+ ...schema,
820
+ optional: !required && !nullable ? true : void 0,
821
+ nullish: !required && nullable ? true : void 0
822
+ };
823
+ }
824
+ //#endregion
825
+ //#region src/nodes/parameter.ts
826
+ /**
827
+ * Definition for the {@link ParameterNode}. `required` defaults to `false`, and the schema's
828
+ * `optional`/`nullish` flags are derived from it through {@link optionality}.
829
+ */
830
+ const parameterDef = defineNode({
831
+ kind: "Parameter",
832
+ build: (props) => {
833
+ const required = props.required ?? false;
834
+ return {
835
+ ...props,
836
+ required,
837
+ schema: optionality(props.schema, required)
838
+ };
839
+ },
840
+ children: ["schema"],
841
+ visitorKey: "parameter"
842
+ });
843
+ /**
844
+ * Creates a `ParameterNode`.
845
+ *
846
+ * @example
847
+ * ```ts
848
+ * const param = createParameter({
849
+ * name: 'petId',
850
+ * in: 'path',
851
+ * required: true,
852
+ * schema: createSchema({ type: 'string' }),
853
+ * })
854
+ * ```
855
+ */
856
+ const createParameter = parameterDef.create;
857
+ //#endregion
858
+ //#region src/nodes/property.ts
859
+ /**
860
+ * Definition for the {@link PropertyNode}. `required` defaults to `false`, and the schema's
861
+ * `optional`/`nullish` flags are derived from it through {@link optionality}.
862
+ */
863
+ const propertyDef = defineNode({
864
+ kind: "Property",
865
+ build: (props) => {
866
+ const required = props.required ?? false;
867
+ return {
868
+ ...props,
869
+ required,
870
+ schema: optionality(props.schema, required)
871
+ };
872
+ },
873
+ children: ["schema"],
874
+ visitorKey: "property"
875
+ });
876
+ /**
877
+ * Creates a `PropertyNode`.
878
+ *
879
+ * @example
880
+ * ```ts
881
+ * const property = createProperty({
882
+ * name: 'status',
883
+ * required: true,
884
+ * schema: createSchema({ type: 'string', nullable: true }),
885
+ * })
886
+ * // required=true, no optional/nullish
887
+ * ```
888
+ */
889
+ const createProperty = propertyDef.create;
890
+ //#endregion
891
+ //#region src/nodes/response.ts
892
+ /**
893
+ * Definition for the {@link ResponseNode}. A single legacy `schema` (with optional
894
+ * `mediaType`/`keysToOmit`) is normalized into one `content` entry.
895
+ */
896
+ const responseDef = defineNode({
897
+ kind: "Response",
898
+ build: (props) => {
899
+ const { schema, mediaType, keysToOmit, content, ...rest } = props;
900
+ const entries = content ?? (schema ? [createContent({
901
+ contentType: mediaType ?? "application/json",
902
+ schema,
903
+ keysToOmit: keysToOmit ?? null
904
+ })] : void 0);
905
+ return {
906
+ ...rest,
907
+ content: entries
908
+ };
909
+ },
910
+ children: ["content"],
911
+ visitorKey: "response"
912
+ });
913
+ /**
914
+ * Creates a `ResponseNode`.
915
+ *
916
+ * @example
917
+ * ```ts
918
+ * const response = createResponse({
919
+ * statusCode: '200',
920
+ * content: [createContent({ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) })],
921
+ * })
922
+ * ```
923
+ */
924
+ const createResponse = responseDef.create;
925
+ //#endregion
926
+ //#region src/nodes/schema.ts
927
+ /**
928
+ * Maps schema `type` to its underlying `primitive`.
929
+ * Primitive types map to themselves and special string formats map to `'string'`.
930
+ * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.
931
+ */
932
+ const TYPE_TO_PRIMITIVE = {
933
+ string: "string",
934
+ number: "number",
935
+ integer: "integer",
936
+ bigint: "bigint",
937
+ boolean: "boolean",
938
+ null: "null",
939
+ any: "any",
940
+ unknown: "unknown",
941
+ void: "void",
942
+ never: "never",
943
+ object: "object",
944
+ array: "array",
945
+ date: "date",
946
+ uuid: "string",
947
+ email: "string",
948
+ url: "string",
949
+ datetime: "string",
950
+ time: "string"
951
+ };
952
+ /**
953
+ * Definition for the {@link SchemaNode}. Object schemas default `properties` to an
954
+ * empty array, and `primitive` is inferred from `type` when not explicitly provided.
955
+ */
956
+ const schemaDef = defineNode({
957
+ kind: "Schema",
958
+ build: (props) => {
959
+ if (props.type === "object") return {
960
+ properties: [],
961
+ primitive: "object",
962
+ ...props
963
+ };
964
+ return {
965
+ primitive: TYPE_TO_PRIMITIVE[props.type],
966
+ ...props
967
+ };
968
+ },
969
+ children: [
970
+ "properties",
971
+ "items",
972
+ "members",
973
+ "additionalProperties"
974
+ ],
975
+ visitorKey: "schema"
976
+ });
977
+ function createSchema(props) {
978
+ return schemaDef.create(props);
979
+ }
980
+ //#endregion
981
+ //#region src/registry.ts
982
+ /**
983
+ * Every node definition. Adding a node means adding its `defineNode` to one
984
+ * `nodes/*.ts` file and listing it here. The visitor tables in `visitor.ts` derive from it.
985
+ */
986
+ const nodeDefs = [
987
+ inputDef,
988
+ outputDef,
989
+ operationDef,
990
+ requestBodyDef,
991
+ contentDef,
992
+ responseDef,
993
+ schemaDef,
994
+ propertyDef,
995
+ parameterDef,
996
+ constDef,
997
+ typeDef,
998
+ functionDef,
999
+ arrowFunctionDef,
1000
+ textDef,
1001
+ breakDef,
1002
+ jsxDef,
1003
+ importDef,
1004
+ exportDef,
1005
+ sourceDef,
1006
+ fileDef
1007
+ ];
1008
+ //#endregion
1009
+ //#region src/visitor.ts
1010
+ /**
1011
+ * Child node fields per node kind, in traversal order (Babel's `VISITOR_KEYS`).
1012
+ * Derived from each definition's `children`.
1013
+ */
1014
+ const VISITOR_KEYS = Object.fromEntries(nodeDefs.flatMap((def) => def.children ? [[def.kind, def.children]] : []));
1015
+ /**
1016
+ * Maps a node kind to the matching visitor callback name. Derived from each
1017
+ * definition's `visitorKey`.
1018
+ */
1019
+ const VISITOR_KEY_BY_KIND = Object.fromEntries(nodeDefs.flatMap((def) => def.visitorKey ? [[def.kind, def.visitorKey]] : []));
1020
+ /**
1021
+ * Creates a small async concurrency limiter.
1022
+ *
1023
+ * At most `concurrency` tasks are in flight at once. Extra tasks are queued.
1024
+ *
1025
+ * @example
1026
+ * ```ts
1027
+ * const limit = createLimit(2)
1028
+ * for (const task of [taskA, taskB, taskC]) {
1029
+ * await limit(() => task())
1030
+ * }
1031
+ * // only 2 tasks run at the same time
1032
+ * ```
1033
+ */
1034
+ function createLimit(concurrency) {
1035
+ let active = 0;
1036
+ const queue = [];
1037
+ function next() {
1038
+ if (active < concurrency && queue.length > 0) {
1039
+ active++;
1040
+ queue.shift()();
1041
+ }
1042
+ }
1043
+ return function limit(fn) {
1044
+ return new Promise((resolve, reject) => {
1045
+ queue.push(() => {
1046
+ Promise.resolve(fn()).then(resolve, reject).finally(() => {
1047
+ active--;
1048
+ next();
1049
+ });
1050
+ });
1051
+ next();
1052
+ });
1053
+ };
1054
+ }
1055
+ const visitorKeysByKind = VISITOR_KEYS;
1056
+ /**
1057
+ * Returns `true` when `value` is an AST node (an object carrying a `kind`).
1058
+ */
1059
+ function isNode(value) {
1060
+ return typeof value === "object" && value !== null && "kind" in value;
1061
+ }
1062
+ /**
1063
+ * Returns the immediate traversable children of `node` based on {@link VISITOR_KEYS}.
1064
+ *
1065
+ * `Schema` children are only included when `recurse` is `true`. Shallow mode skips them.
1066
+ *
1067
+ * @example
1068
+ * ```ts
1069
+ * const children = getChildren(operationNode, true)
1070
+ * // returns parameters, the request body, and responses
1071
+ * ```
1072
+ */
1073
+ function* getChildren(node, recurse) {
1074
+ if (node.kind === "Schema" && !recurse) return;
1075
+ const keys = visitorKeysByKind[node.kind];
1076
+ if (!keys) return;
1077
+ const record = node;
1078
+ for (const key of keys) {
1079
+ const value = record[key];
1080
+ if (Array.isArray(value)) {
1081
+ for (const item of value) if (isNode(item)) yield item;
1082
+ } else if (isNode(value)) yield value;
1083
+ }
1084
+ }
1085
+ /**
1086
+ * Runs the visitor callback that matches `node.kind` with the traversal
1087
+ * context. The result is a replacement node, a collected value, or `undefined`
1088
+ * when no callback is registered for the kind.
1089
+ *
1090
+ * Shared by `walk`, `transform`, and `collectLazy` so node-kind dispatch lives
1091
+ * in one place. `TResult` is the caller's expected return: the same node type
1092
+ * for `transform`, the collected value type for `collectLazy`, ignored for `walk`.
1093
+ */
1094
+ function applyVisitor(node, visitor, parent) {
1095
+ const key = VISITOR_KEY_BY_KIND[node.kind];
1096
+ if (!key) return void 0;
1097
+ const fn = visitor[key];
1098
+ return fn?.(node, { parent });
1099
+ }
1100
+ /**
1101
+ * Async depth-first traversal for side effects. Visitor return values are
1102
+ * ignored. Use `transform` when you want to rewrite nodes.
1103
+ *
1104
+ * Sibling nodes at each depth run concurrently up to `options.concurrency`
1105
+ * (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor
1106
+ * work. Lower values reduce memory pressure.
1107
+ *
1108
+ * @example Log every operation
1109
+ * ```ts
1110
+ * await walk(root, {
1111
+ * operation(node) {
1112
+ * console.log(node.operationId)
1113
+ * },
1114
+ * })
1115
+ * ```
1116
+ *
1117
+ * @example Only visit the root node
1118
+ * ```ts
1119
+ * await walk(root, { depth: 'shallow', input: () => {} })
1120
+ * ```
1121
+ */
1122
+ async function walk(node, options) {
1123
+ return _walk(node, options, (options.depth ?? visitorDepths.deep) === visitorDepths.deep, createLimit(options.concurrency ?? 30), void 0);
1124
+ }
1125
+ async function _walk(node, visitor, recurse, limit, parent) {
1126
+ await limit(() => applyVisitor(node, visitor, parent));
1127
+ const children = Array.from(getChildren(node, recurse));
1128
+ if (children.length === 0) return;
1129
+ await Promise.all(children.map((child) => _walk(child, visitor, recurse, limit, node)));
1130
+ }
1131
+ function transform(node, options) {
1132
+ const { depth, parent, ...visitor } = options;
1133
+ const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep;
1134
+ return transformChildren(applyVisitor(node, visitor, parent) ?? node, options, recurse);
1135
+ }
1136
+ /**
1137
+ * Immutably rebuilds a node's children using {@link VISITOR_KEYS}, transforming
1138
+ * each child node and leaving non-node values (e.g. `additionalProperties: true`) intact.
1139
+ * `Schema` children are skipped in shallow mode.
1140
+ */
1141
+ function transformChildren(node, options, recurse) {
1142
+ if (node.kind === "Schema" && !recurse) return node;
1143
+ const keys = visitorKeysByKind[node.kind];
1144
+ if (!keys) return node;
1145
+ const record = node;
1146
+ const childOptions = {
1147
+ ...options,
1148
+ parent: node
1149
+ };
1150
+ let updates;
1151
+ for (const key of keys) {
1152
+ if (!(key in record)) continue;
1153
+ const value = record[key];
1154
+ if (Array.isArray(value)) {
1155
+ let changed = false;
1156
+ const mapped = value.map((item) => {
1157
+ if (!isNode(item)) return item;
1158
+ const next = transform(item, childOptions);
1159
+ if (next !== item) changed = true;
1160
+ return next;
1161
+ });
1162
+ if (changed) (updates ??= {})[key] = mapped;
1163
+ } else if (isNode(value)) {
1164
+ const next = transform(value, childOptions);
1165
+ if (next !== value) (updates ??= {})[key] = next;
1166
+ }
1167
+ }
1168
+ return updates ? {
1169
+ ...node,
1170
+ ...updates
1171
+ } : node;
1172
+ }
1173
+ /**
1174
+ * Lazy depth-first collection pass. Yields every non-null value returned by
1175
+ * the visitor callbacks. Use `collect` for the eager array form.
1176
+ *
1177
+ * @example Collect every operationId
1178
+ * ```ts
1179
+ * const ids: string[] = []
1180
+ * for (const id of collectLazy<string>(root, {
1181
+ * operation(node) {
1182
+ * return node.operationId
1183
+ * },
1184
+ * })) {
1185
+ * ids.push(id)
1186
+ * }
1187
+ * ```
1188
+ */
1189
+ function* collectLazy(node, options) {
1190
+ const { depth, parent, ...visitor } = options;
1191
+ const recurse = (depth ?? visitorDepths.deep) === visitorDepths.deep;
1192
+ const v = applyVisitor(node, visitor, parent);
1193
+ if (v != null) yield v;
1194
+ for (const child of getChildren(node, recurse)) yield* collectLazy(child, {
1195
+ ...options,
1196
+ parent: node
1197
+ });
1198
+ }
1199
+ /**
1200
+ * Eager depth-first collection pass. Gathers every non-null value the visitor
1201
+ * callbacks return into an array.
1202
+ *
1203
+ * @example Collect every operationId
1204
+ * ```ts
1205
+ * const ids = collect<string>(root, {
1206
+ * operation(node) {
1207
+ * return node.operationId
1208
+ * },
1209
+ * })
1210
+ * ```
1211
+ */
1212
+ function collect(node, options) {
1213
+ return Array.from(collectLazy(node, options));
1214
+ }
1215
+ //#endregion
1216
+ Object.defineProperty(exports, "__exportAll", {
1217
+ enumerable: true,
1218
+ get: function() {
1219
+ return __exportAll;
1220
+ }
1221
+ });
1222
+ Object.defineProperty(exports, "__name", {
1223
+ enumerable: true,
1224
+ get: function() {
1225
+ return __name;
1226
+ }
1227
+ });
1228
+ Object.defineProperty(exports, "arrowFunctionDef", {
1229
+ enumerable: true,
1230
+ get: function() {
1231
+ return arrowFunctionDef;
1232
+ }
1233
+ });
1234
+ Object.defineProperty(exports, "breakDef", {
1235
+ enumerable: true,
1236
+ get: function() {
1237
+ return breakDef;
1238
+ }
1239
+ });
1240
+ Object.defineProperty(exports, "collect", {
1241
+ enumerable: true,
1242
+ get: function() {
1243
+ return collect;
1244
+ }
1245
+ });
1246
+ Object.defineProperty(exports, "collectLazy", {
1247
+ enumerable: true,
1248
+ get: function() {
1249
+ return collectLazy;
1250
+ }
1251
+ });
1252
+ Object.defineProperty(exports, "constDef", {
1253
+ enumerable: true,
1254
+ get: function() {
1255
+ return constDef;
1256
+ }
1257
+ });
1258
+ Object.defineProperty(exports, "contentDef", {
1259
+ enumerable: true,
1260
+ get: function() {
1261
+ return contentDef;
1262
+ }
1263
+ });
1264
+ Object.defineProperty(exports, "createArrowFunction", {
1265
+ enumerable: true,
1266
+ get: function() {
1267
+ return createArrowFunction;
1268
+ }
1269
+ });
1270
+ Object.defineProperty(exports, "createBreak", {
1271
+ enumerable: true,
1272
+ get: function() {
1273
+ return createBreak;
1274
+ }
1275
+ });
1276
+ Object.defineProperty(exports, "createConst", {
1277
+ enumerable: true,
1278
+ get: function() {
1279
+ return createConst;
1280
+ }
1281
+ });
1282
+ Object.defineProperty(exports, "createContent", {
1283
+ enumerable: true,
1284
+ get: function() {
1285
+ return createContent;
1286
+ }
1287
+ });
1288
+ Object.defineProperty(exports, "createExport", {
1289
+ enumerable: true,
1290
+ get: function() {
1291
+ return createExport;
1292
+ }
1293
+ });
1294
+ Object.defineProperty(exports, "createFile", {
1295
+ enumerable: true,
1296
+ get: function() {
1297
+ return createFile;
1298
+ }
1299
+ });
1300
+ Object.defineProperty(exports, "createFunction", {
1301
+ enumerable: true,
1302
+ get: function() {
1303
+ return createFunction;
1304
+ }
1305
+ });
1306
+ Object.defineProperty(exports, "createImport", {
1307
+ enumerable: true,
1308
+ get: function() {
1309
+ return createImport;
1310
+ }
1311
+ });
1312
+ Object.defineProperty(exports, "createInput", {
1313
+ enumerable: true,
1314
+ get: function() {
1315
+ return createInput;
1316
+ }
1317
+ });
1318
+ Object.defineProperty(exports, "createJsx", {
1319
+ enumerable: true,
1320
+ get: function() {
1321
+ return createJsx;
1322
+ }
1323
+ });
1324
+ Object.defineProperty(exports, "createOperation", {
1325
+ enumerable: true,
1326
+ get: function() {
1327
+ return createOperation;
1328
+ }
1329
+ });
1330
+ Object.defineProperty(exports, "createOutput", {
1331
+ enumerable: true,
1332
+ get: function() {
1333
+ return createOutput;
1334
+ }
1335
+ });
1336
+ Object.defineProperty(exports, "createParameter", {
1337
+ enumerable: true,
1338
+ get: function() {
1339
+ return createParameter;
1340
+ }
1341
+ });
1342
+ Object.defineProperty(exports, "createProperty", {
1343
+ enumerable: true,
1344
+ get: function() {
1345
+ return createProperty;
1346
+ }
1347
+ });
1348
+ Object.defineProperty(exports, "createRequestBody", {
1349
+ enumerable: true,
1350
+ get: function() {
1351
+ return createRequestBody;
1352
+ }
1353
+ });
1354
+ Object.defineProperty(exports, "createResponse", {
1355
+ enumerable: true,
1356
+ get: function() {
1357
+ return createResponse;
1358
+ }
1359
+ });
1360
+ Object.defineProperty(exports, "createSchema", {
1361
+ enumerable: true,
1362
+ get: function() {
1363
+ return createSchema;
1364
+ }
1365
+ });
1366
+ Object.defineProperty(exports, "createSource", {
1367
+ enumerable: true,
1368
+ get: function() {
1369
+ return createSource;
1370
+ }
1371
+ });
1372
+ Object.defineProperty(exports, "createText", {
1373
+ enumerable: true,
1374
+ get: function() {
1375
+ return createText;
1376
+ }
1377
+ });
1378
+ Object.defineProperty(exports, "createType", {
1379
+ enumerable: true,
1380
+ get: function() {
1381
+ return createType;
1382
+ }
1383
+ });
1384
+ Object.defineProperty(exports, "defineNode", {
1385
+ enumerable: true,
1386
+ get: function() {
1387
+ return defineNode;
1388
+ }
1389
+ });
1390
+ Object.defineProperty(exports, "exportDef", {
1391
+ enumerable: true,
1392
+ get: function() {
1393
+ return exportDef;
1394
+ }
1395
+ });
1396
+ Object.defineProperty(exports, "extractStringsFromNodes", {
1397
+ enumerable: true,
1398
+ get: function() {
1399
+ return extractStringsFromNodes;
1400
+ }
1401
+ });
1402
+ Object.defineProperty(exports, "fileDef", {
1403
+ enumerable: true,
1404
+ get: function() {
1405
+ return fileDef;
1406
+ }
1407
+ });
1408
+ Object.defineProperty(exports, "functionDef", {
1409
+ enumerable: true,
1410
+ get: function() {
1411
+ return functionDef;
1412
+ }
1413
+ });
1414
+ Object.defineProperty(exports, "importDef", {
1415
+ enumerable: true,
1416
+ get: function() {
1417
+ return importDef;
1418
+ }
1419
+ });
1420
+ Object.defineProperty(exports, "inputDef", {
1421
+ enumerable: true,
1422
+ get: function() {
1423
+ return inputDef;
1424
+ }
1425
+ });
1426
+ Object.defineProperty(exports, "isHttpOperationNode", {
1427
+ enumerable: true,
1428
+ get: function() {
1429
+ return isHttpOperationNode;
1430
+ }
1431
+ });
1432
+ Object.defineProperty(exports, "jsxDef", {
1433
+ enumerable: true,
1434
+ get: function() {
1435
+ return jsxDef;
1436
+ }
1437
+ });
1438
+ Object.defineProperty(exports, "narrowSchema", {
1439
+ enumerable: true,
1440
+ get: function() {
1441
+ return narrowSchema;
1442
+ }
1443
+ });
1444
+ Object.defineProperty(exports, "nodeDefs", {
1445
+ enumerable: true,
1446
+ get: function() {
1447
+ return nodeDefs;
1448
+ }
1449
+ });
1450
+ Object.defineProperty(exports, "operationDef", {
1451
+ enumerable: true,
1452
+ get: function() {
1453
+ return operationDef;
1454
+ }
1455
+ });
1456
+ Object.defineProperty(exports, "optionality", {
1457
+ enumerable: true,
1458
+ get: function() {
1459
+ return optionality;
1460
+ }
1461
+ });
1462
+ Object.defineProperty(exports, "outputDef", {
1463
+ enumerable: true,
1464
+ get: function() {
1465
+ return outputDef;
1466
+ }
1467
+ });
1468
+ Object.defineProperty(exports, "parameterDef", {
1469
+ enumerable: true,
1470
+ get: function() {
1471
+ return parameterDef;
1472
+ }
1473
+ });
1474
+ Object.defineProperty(exports, "pascalCase", {
1475
+ enumerable: true,
1476
+ get: function() {
1477
+ return pascalCase;
1478
+ }
1479
+ });
1480
+ Object.defineProperty(exports, "propertyDef", {
1481
+ enumerable: true,
1482
+ get: function() {
1483
+ return propertyDef;
1484
+ }
1485
+ });
1486
+ Object.defineProperty(exports, "requestBodyDef", {
1487
+ enumerable: true,
1488
+ get: function() {
1489
+ return requestBodyDef;
1490
+ }
1491
+ });
1492
+ Object.defineProperty(exports, "responseDef", {
1493
+ enumerable: true,
1494
+ get: function() {
1495
+ return responseDef;
1496
+ }
1497
+ });
1498
+ Object.defineProperty(exports, "schemaDef", {
1499
+ enumerable: true,
1500
+ get: function() {
1501
+ return schemaDef;
1502
+ }
1503
+ });
1504
+ Object.defineProperty(exports, "schemaTypes", {
1505
+ enumerable: true,
1506
+ get: function() {
1507
+ return schemaTypes;
1508
+ }
1509
+ });
1510
+ Object.defineProperty(exports, "sourceDef", {
1511
+ enumerable: true,
1512
+ get: function() {
1513
+ return sourceDef;
1514
+ }
1515
+ });
1516
+ Object.defineProperty(exports, "textDef", {
1517
+ enumerable: true,
1518
+ get: function() {
1519
+ return textDef;
1520
+ }
1521
+ });
1522
+ Object.defineProperty(exports, "transform", {
1523
+ enumerable: true,
1524
+ get: function() {
1525
+ return transform;
1526
+ }
1527
+ });
1528
+ Object.defineProperty(exports, "typeDef", {
1529
+ enumerable: true,
1530
+ get: function() {
1531
+ return typeDef;
1532
+ }
1533
+ });
1534
+ Object.defineProperty(exports, "visitorKeys", {
1535
+ enumerable: true,
1536
+ get: function() {
1537
+ return visitorKeys;
1538
+ }
1539
+ });
1540
+ Object.defineProperty(exports, "walk", {
1541
+ enumerable: true,
1542
+ get: function() {
1543
+ return walk;
1544
+ }
1545
+ });
1546
+
1547
+ //# sourceMappingURL=visitor-CDa9Cn6x.cjs.map