@kubb/ast 5.23.1 → 5.23.3

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 (163) hide show
  1. package/dist/{constants-Ckeonm-D.js → constants-BTTus9ee.js} +1 -1
  2. package/dist/{constants-Ckeonm-D.js.map → constants-BTTus9ee.js.map} +1 -1
  3. package/dist/{constants-CquR083U.cjs → constants-DztHlVmY.cjs} +1 -1
  4. package/dist/{constants-CquR083U.cjs.map → constants-DztHlVmY.cjs.map} +1 -1
  5. package/dist/factory.cjs +3 -3
  6. package/dist/factory.d.cts +3 -3
  7. package/dist/factory.d.ts +3 -3
  8. package/dist/factory.js +3 -3
  9. package/dist/{file-Dd50jPkH.cjs → file-BAICym_L.cjs} +19 -10
  10. package/dist/file-BAICym_L.cjs.map +1 -0
  11. package/dist/{file-CnuL8oUj.js → file-DUFttt26.js} +21 -11
  12. package/dist/file-DUFttt26.js.map +1 -0
  13. package/dist/{file-CvlMAp_d.js → file-Dj9lsbJu.js} +19 -10
  14. package/dist/file-Dj9lsbJu.js.map +1 -0
  15. package/dist/{file-BVqSiSvV.d.cts → file-DkFGn_Os.d.ts} +29 -7
  16. package/dist/{file-Cg0T6cgz.cjs → file-Dz1HPMld.cjs} +21 -11
  17. package/dist/file-Dz1HPMld.cjs.map +1 -0
  18. package/dist/{file-xJnBQPGq.d.ts → file-KunZhFIV.d.cts} +29 -7
  19. package/dist/file.cjs +1 -1
  20. package/dist/file.d.cts +1 -1
  21. package/dist/file.d.ts +1 -1
  22. package/dist/file.js +1 -1
  23. package/dist/{graph-BcwFCvei.js → graph-BUEOBomo.js} +5 -5
  24. package/dist/{graph-BcwFCvei.js.map → graph-BUEOBomo.js.map} +1 -1
  25. package/dist/{graph-DcIY6tQb.cjs → graph-CFJ4wzFR.cjs} +5 -5
  26. package/dist/{graph-DcIY6tQb.cjs.map → graph-CFJ4wzFR.cjs.map} +1 -1
  27. package/dist/graph.cjs +1 -1
  28. package/dist/graph.d.cts +1 -1
  29. package/dist/graph.d.ts +1 -1
  30. package/dist/graph.js +1 -1
  31. package/dist/{guards-COVJE6TU.cjs → guards-4drgx10i.cjs} +1 -1
  32. package/dist/{guards-COVJE6TU.cjs.map → guards-4drgx10i.cjs.map} +1 -1
  33. package/dist/{guards-D-h9R_sV.d.ts → guards-C6w6KQSY.d.ts} +1 -1
  34. package/dist/{guards-B8qDgSaT.d.cts → guards-COBkDtgu.d.cts} +1 -1
  35. package/dist/{guards-DlJkKsT1.js → guards-DKw4uwc5.js} +1 -1
  36. package/dist/{guards-DlJkKsT1.js.map → guards-DKw4uwc5.js.map} +1 -1
  37. package/dist/{http-DwboM6pK.js → http-CAWf6TAJ.js} +2 -2
  38. package/dist/http-CAWf6TAJ.js.map +1 -0
  39. package/dist/{http-Bm5lhVK4.cjs → http-Dv8py6wh.cjs} +2 -2
  40. package/dist/http-Dv8py6wh.cjs.map +1 -0
  41. package/dist/http.cjs +2 -2
  42. package/dist/http.d.cts +2 -2
  43. package/dist/http.d.ts +2 -2
  44. package/dist/http.js +2 -2
  45. package/dist/{index-DNiIem0x.d.ts → index-9l1xMEl_.d.ts} +4 -4
  46. package/dist/{index-Dp50LM3a.d.ts → index-B5w-X5V6.d.ts} +1 -1
  47. package/dist/{index-BwnMIoLl.d.ts → index-Be5d4Zcl.d.ts} +2 -2
  48. package/dist/index-CI6Tu2c7.d.ts +5 -0
  49. package/dist/{index-CAGuKv6t.d.ts → index-CPXo4cA8.d.cts} +8 -3
  50. package/dist/{index-eGkM4FE9.d.ts → index-CX7yfAGI.d.ts} +1 -1
  51. package/dist/{index-CFH4ZC7q.d.ts → index-CnY3KmAg.d.ts} +1 -1
  52. package/dist/{index-CIqwy4EE.d.cts → index-CwFC71XK.d.ts} +8 -3
  53. package/dist/{index-DYDha-3I.d.cts → index-D-BjRrJo.d.cts} +1 -1
  54. package/dist/{index-DU_jYpBt.d.cts → index-DZe5evGM.d.cts} +1 -1
  55. package/dist/{index-D3M2spDR.d.ts → index-DjThtAn4.d.ts} +3 -3
  56. package/dist/{index-cpjUxIik.d.ts → index-DkThxxxq.d.cts} +3 -3
  57. package/dist/{index-BngGJux5.d.cts → index-Dr81DOsC.d.cts} +3 -3
  58. package/dist/index-DuDvNFQ8.d.cts +5 -0
  59. package/dist/{index-C-vhkzwR.d.cts → index-dgiKWRpD.d.cts} +4 -4
  60. package/dist/{index-Bb1kqq8H.d.cts → index-gDZYBeJw.d.cts} +1 -1
  61. package/dist/{index-Csf8xsCc.d.cts → index-jWtEIa7j.d.ts} +3 -3
  62. package/dist/{index-DSVef1pp.d.cts → index-ss1YqjpW.d.cts} +2 -2
  63. package/dist/index.cjs +30 -24
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +27 -27
  66. package/dist/index.d.ts +27 -27
  67. package/dist/index.js +30 -24
  68. package/dist/index.js.map +1 -1
  69. package/dist/{json-DURdtz9A.cjs → json-CCWMgzJZ.cjs} +2 -2
  70. package/dist/{json-DURdtz9A.cjs.map → json-CCWMgzJZ.cjs.map} +1 -1
  71. package/dist/{json-DH7_lcWm.js → json-DyDtIZTj.js} +2 -2
  72. package/dist/{json-DH7_lcWm.js.map → json-DyDtIZTj.js.map} +1 -1
  73. package/dist/json.cjs +1 -1
  74. package/dist/json.d.cts +1 -1
  75. package/dist/json.d.ts +1 -1
  76. package/dist/json.js +1 -1
  77. package/dist/{macro-D0KfNtff.js → macro-9WouvtZe.js} +3 -3
  78. package/dist/macro-9WouvtZe.js.map +1 -0
  79. package/dist/{macro-DrTBT7fh.cjs → macro-BEwfGNu1.cjs} +3 -3
  80. package/dist/macro-BEwfGNu1.cjs.map +1 -0
  81. package/dist/macro.cjs +1 -1
  82. package/dist/macro.d.cts +1 -1
  83. package/dist/macro.d.ts +1 -1
  84. package/dist/macro.js +1 -1
  85. package/dist/{mediaType-D8uIO8sG.cjs → mediaType-BbIfudh0.cjs} +1 -1
  86. package/dist/{mediaType-D8uIO8sG.cjs.map → mediaType-BbIfudh0.cjs.map} +1 -1
  87. package/dist/{mediaType-CRjggmoG.js → mediaType-DXQCNYdM.js} +1 -1
  88. package/dist/{mediaType-CRjggmoG.js.map → mediaType-DXQCNYdM.js.map} +1 -1
  89. package/dist/mediaType.cjs +1 -1
  90. package/dist/mediaType.d.cts +1 -1
  91. package/dist/mediaType.d.ts +1 -1
  92. package/dist/mediaType.js +1 -1
  93. package/dist/{node-Djh-mZB2.js → node-DtuO3zr8.js} +4 -4
  94. package/dist/{node-Djh-mZB2.js.map → node-DtuO3zr8.js.map} +1 -1
  95. package/dist/{node-DjcETnc8.cjs → node-vTrAIz3e.cjs} +4 -4
  96. package/dist/{node-DjcETnc8.cjs.map → node-vTrAIz3e.cjs.map} +1 -1
  97. package/dist/node.cjs +4 -4
  98. package/dist/node.d.cts +3 -3
  99. package/dist/node.d.ts +3 -3
  100. package/dist/node.js +4 -4
  101. package/dist/{nodeText-DVVDZQjF.js → nodeText-BSYvDZOH.js} +2 -2
  102. package/dist/{nodeText-DVVDZQjF.js.map → nodeText-BSYvDZOH.js.map} +1 -1
  103. package/dist/{nodeText-DRb_rVd1.cjs → nodeText-CZ7wgxu9.cjs} +2 -2
  104. package/dist/{nodeText-DRb_rVd1.cjs.map → nodeText-CZ7wgxu9.cjs.map} +1 -1
  105. package/dist/{nodes-BB60Bq2H.cjs → nodes-BT2Ocq0x.cjs} +5 -5
  106. package/dist/{nodes-BB60Bq2H.cjs.map → nodes-BT2Ocq0x.cjs.map} +1 -1
  107. package/dist/{nodes-CWMa9xhW.js → nodes-CwYIFVt5.js} +5 -5
  108. package/dist/{nodes-CWMa9xhW.js.map → nodes-CwYIFVt5.js.map} +1 -1
  109. package/dist/{operation-X7chCdL2.d.cts → operation-BUhPuZMY.d.cts} +1 -1
  110. package/dist/{operation-BgRyVS7z.d.ts → operation-jxEr2No4.d.ts} +1 -1
  111. package/dist/{optionality-D-zqzVMH.cjs → optionality-C-qULYxo.cjs} +1 -1
  112. package/dist/{optionality-D-zqzVMH.cjs.map → optionality-C-qULYxo.cjs.map} +1 -1
  113. package/dist/{optionality-DISn8ytP.js → optionality-FkRredTC.js} +1 -1
  114. package/dist/{optionality-DISn8ytP.js.map → optionality-FkRredTC.js.map} +1 -1
  115. package/dist/{promise-RpnEev9D.js → promise-B3YkZ4C8.js} +1 -1
  116. package/dist/{promise-RpnEev9D.js.map → promise-B3YkZ4C8.js.map} +1 -1
  117. package/dist/{promise-BOdlgT0N.cjs → promise-DScaykew.cjs} +1 -1
  118. package/dist/{promise-BOdlgT0N.cjs.map → promise-DScaykew.cjs.map} +1 -1
  119. package/dist/{ref-P0ZLT1Bg.cjs → ref-Bh5Xo8T7.cjs} +4 -4
  120. package/dist/{ref-P0ZLT1Bg.cjs.map → ref-Bh5Xo8T7.cjs.map} +1 -1
  121. package/dist/{ref-Bu7PoHar.js → ref-DPqeS8K1.js} +4 -4
  122. package/dist/{ref-Bu7PoHar.js.map → ref-DPqeS8K1.js.map} +1 -1
  123. package/dist/ref.cjs +2 -2
  124. package/dist/ref.d.cts +1 -1
  125. package/dist/ref.d.ts +1 -1
  126. package/dist/ref.js +2 -2
  127. package/dist/{refs-YCV3CznS.js → refs-Bgf8_9Ui.js} +2 -2
  128. package/dist/{refs-YCV3CznS.js.map → refs-Bgf8_9Ui.js.map} +1 -1
  129. package/dist/{refs-CYHpRlQo.cjs → refs-rmr2LFV1.cjs} +2 -2
  130. package/dist/{refs-CYHpRlQo.cjs.map → refs-rmr2LFV1.cjs.map} +1 -1
  131. package/dist/{schema-DloctnMm.js → schema-4UcdIPQ2.js} +7 -7
  132. package/dist/{schema-DloctnMm.js.map → schema-4UcdIPQ2.js.map} +1 -1
  133. package/dist/{schema-BIErWqgc.cjs → schema-DuCY4lCG.cjs} +7 -7
  134. package/dist/{schema-BIErWqgc.cjs.map → schema-DuCY4lCG.cjs.map} +1 -1
  135. package/dist/{schema-hxMlgCrV.cjs → schema-gSjYgaCl.cjs} +2 -2
  136. package/dist/{schema-hxMlgCrV.cjs.map → schema-gSjYgaCl.cjs.map} +1 -1
  137. package/dist/{schema-2ZAQk7qE.js → schema-tH14gE6i.js} +2 -2
  138. package/dist/{schema-2ZAQk7qE.js.map → schema-tH14gE6i.js.map} +1 -1
  139. package/dist/schema.cjs +5 -5
  140. package/dist/schema.d.cts +4 -4
  141. package/dist/schema.d.ts +4 -4
  142. package/dist/schema.js +5 -5
  143. package/dist/{visitor-DTrzvA3R.cjs → visitor-Bh1CBAOz.cjs} +4 -5
  144. package/dist/{visitor-DTrzvA3R.cjs.map → visitor-Bh1CBAOz.cjs.map} +1 -1
  145. package/dist/{visitor-BZozlXBF.d.ts → visitor-CFbuH7BY.d.ts} +6 -3
  146. package/dist/{visitor-Bw_opzjF.d.cts → visitor-DxhkIQyP.d.cts} +6 -3
  147. package/dist/{visitor-NoQSUQTu.js → visitor-XA0W3OVv.js} +4 -5
  148. package/dist/{visitor-NoQSUQTu.js.map → visitor-XA0W3OVv.js.map} +1 -1
  149. package/package.json +1 -1
  150. package/dist/file-Cg0T6cgz.cjs.map +0 -1
  151. package/dist/file-CnuL8oUj.js.map +0 -1
  152. package/dist/file-CvlMAp_d.js.map +0 -1
  153. package/dist/file-Dd50jPkH.cjs.map +0 -1
  154. package/dist/http-Bm5lhVK4.cjs.map +0 -1
  155. package/dist/http-DwboM6pK.js.map +0 -1
  156. package/dist/index-BWd95onW.d.cts +0 -5
  157. package/dist/index-DaHsMJ_S.d.ts +0 -5
  158. package/dist/macro-D0KfNtff.js.map +0 -1
  159. package/dist/macro-DrTBT7fh.cjs.map +0 -1
  160. /package/dist/{base-IpYuh3ZP.d.cts → base-LhsPvVY1.d.ts} +0 -0
  161. /package/dist/{base-IpYuh3ZP.d.ts → base-UFBZi-FO.d.cts} +0 -0
  162. /package/dist/{index-Cc2K3OzU.d.cts → index-C-nsgwuD.d.ts} +0 -0
  163. /package/dist/{index-Cc2K3OzU.d.ts → index-DR9ahJ-x.d.cts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-Dz1HPMld.cjs","names":["memo","path","nodeKinds","path","getNodeText","hash"],"sources":["../src/utils/combineFileMembers.ts","../src/nodes/base.ts","../src/nodes/file.ts"],"sourcesContent":["/**\n * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and\n * export entries of one file, while `combineSources` deduplicates source entries in original order.\n * `combineImports` also drops imports nothing references. This works on a file's members, not on\n * schema content.\n */\nimport path from 'node:path'\nimport { memo } from '@internals/utils'\nimport type { ExportNode, ImportNode, SourceNode } from '../nodes/file.ts'\n\nconst IDENTIFIER_RUN = /[\\w$]+/g\n\n/**\n * How many imports a file needs before indexing the source beats scanning it once per name.\n */\nconst INDEX_ABOVE_IMPORTS = 128\n\ntype ImportNameItem = string | { propertyName: string; name?: string }\n\ntype FileMember = { name?: string | Array<unknown> | null; isTypeOnly?: boolean | null; path: string; root?: string | null }\n\n/**\n * Returns the local binding an import name item introduces: the alias when there is one, else the\n * imported name.\n */\nexport function importLocalName(item: ImportNameItem): string {\n return typeof item === 'string' ? item : (item.name ?? item.propertyName)\n}\n\n/**\n * Relative specifiers by `root`, then `path`. `createFile` sorts a file's imports again on every\n * merge, and the path math dominated that sort on large specs. Two levels keep the existing strings\n * as keys, so lookups reuse their hashes instead of hashing a new joined key each time.\n */\nconst specifierCache = memo.create<string, Map<string, string>>({ max: 10_000 })\n\n/**\n * Returns the specifier a member is written with: POSIX and relative to the importing file when it\n * has a `root`, like `getRelativePath` in parser-ts. Sorting on it keeps the order the same on every OS.\n */\nfunction specifier(node: FileMember): string {\n const { root, path: target } = node\n if (!root) return target\n const byPath = memo(specifierCache, root, () => new Map<string, string>())\n return memo(byPath, target, () => {\n const relative = path.relative(path.dirname(root), target).replaceAll('\\\\', '/')\n return relative.startsWith('../') ? relative : `./${relative}`\n })\n}\n\n/**\n * Computes a multi-level sort key for exports and imports:\n * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical specifier. Unnamed before named.\n */\nfunction sortKey(node: FileMember): string {\n const isArray = Array.isArray(node.name) ? '1' : '0'\n const typeOnly = node.isTypeOnly ? '0' : '1'\n const hasName = node.name != null ? '1' : '0'\n const name = Array.isArray(node.name) ? node.name.toSorted().join('\\0') : (node.name ?? '')\n return `${isArray}:${typeOnly}:${specifier(node)}:${hasName}:${name}`\n}\n\n/**\n * Sorts members by {@link sortKey}. Keys are computed once per node, not per comparison.\n */\nfunction sortMembers<TNode extends FileMember>(nodes: Array<TNode>): Array<TNode> {\n return nodes\n .map((node) => ({ node, key: sortKey(node) }))\n .sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))\n .map(({ node }) => node)\n}\n\n/**\n * Returns a collector for array-named members. A member whose path and `isTypeOnly` were already\n * seen folds its names into that entry, otherwise it joins `result` as a new entry.\n */\nfunction mergeByPath<TNode extends FileMember>(result: Array<TNode>): (member: { node: TNode; names: Array<unknown> }) => void {\n // Append new names instead of rebuilding the list, which went quadratic on a shared path.\n const byPath = new Map<string, { names: Array<unknown>; seen: Set<unknown> }>()\n\n return ({ node, names }) => {\n const key = `${node.path}:${node.isTypeOnly ?? false}`\n const existing = byPath.get(key)\n\n if (existing) {\n for (const name of names) {\n if (existing.seen.has(name)) continue\n existing.seen.add(name)\n existing.names.push(name)\n }\n return\n }\n\n const item = { ...node, name: [...names] }\n result.push(item)\n byPath.set(key, { names: item.name, seen: new Set(names) })\n }\n}\n\n/**\n * Deduplicates `SourceNode` objects by `name + export + isTypeOnly`, keeping the first of each\n * key. An unnamed source only drops when the same node appears twice, so markdown can repeat a\n * paragraph or a table. Returns the deduplicated array in original order.\n */\nexport function combineSources(sources: Array<SourceNode>): Array<SourceNode> {\n const seen = new Set<SourceNode | string>()\n return sources.filter((source) => {\n const key = source.name != null ? `${source.name}:${source.export ?? source.isExportable ?? false}:${source.isTypeOnly ?? false}` : source\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n}\n\n/**\n * Deduplicates and merges `ExportNode` objects by path and type.\n *\n * Named exports with the same path and `isTypeOnly` flag have their names merged into a single export.\n * Non-array exports are deduplicated by exact identity. Returns a sorted, deduplicated array.\n */\nexport function combineExports(exports: Array<ExportNode>): Array<ExportNode> {\n const result: Array<ExportNode> = []\n const merge = mergeByPath(result)\n // Deduplicates non-array exports by their exact identity\n const seen = new Set<string>()\n\n for (const curr of sortMembers(exports)) {\n const { name, path, isTypeOnly, asAlias } = curr\n\n if (Array.isArray(name)) {\n if (name.length) merge({ node: curr, names: [...new Set(name)] })\n continue\n }\n\n const key = `${path}:${name ?? ''}:${isTypeOnly ?? false}:${asAlias ?? ''}`\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n\n return result\n}\n\n/**\n * Deduplicates and merges `ImportNode` objects, filtering out unused imports.\n *\n * Retains imports that are referenced in `source` or re-exported. Imports with the same path and\n * `isTypeOnly` flag have their names merged. Returns a sorted, deduplicated, filtered array.\n */\nexport function combineImports(imports: Array<ImportNode>, exports: Array<ExportNode>, source?: string): Array<ImportNode> {\n // Build a lookup of all exported names to retain imports that are re-exported\n const exportedNames = new Set(exports.flatMap((e) => (Array.isArray(e.name) ? e.name : e.name ? [e.name] : [])))\n // `createFile` re-runs on every merge into a file, so scanning the source once per import name\n // costs a heavily merged file that scan again for every fragment it already holds. Indexing pays\n // for itself there, and costs more than it saves on the small files the default output produces.\n const identifiers = source && imports.length > INDEX_ABOVE_IMPORTS ? new Set(source.match(IDENTIFIER_RUN)) : null\n\n // A name in the index is used. One that is not still might be, inside a longer identifier, so the\n // substring test stays behind it.\n const isUsed = (importName: string): boolean => !source || identifiers?.has(importName) || source.includes(importName) || exportedNames.has(importName)\n\n // Memoize object import names so the same logical (propertyName, name) pair always\n // reuses the same object reference. Set-based deduplication then works correctly.\n const importNameMemo = memo.create<string, ImportNameItem>()\n const canonicalizeName = (n: ImportNameItem): ImportNameItem => {\n if (typeof n === 'string') return n\n const key = `${n.propertyName}:${n.name ?? ''}`\n return memo(importNameMemo, key, () => n)\n }\n\n // Paths that keep at least one used named import. A default import from such a path is retained\n // even when its binding can't be found in `source` e.g. a generated `client` default import\n // alongside `import type { Client } from <same path>`, where merged grouped output omits the body.\n const pathsWithUsedNamedImport = new Set<string>()\n for (const node of imports) {\n if (Array.isArray(node.name) && node.name.some((item) => isUsed(importLocalName(item)))) {\n pathsWithUsedNamedImport.add(node.path)\n }\n }\n\n const result: Array<ImportNode> = []\n const merge = mergeByPath(result)\n // Deduplicates non-array imports by their exact identity\n const seen = new Set<string>()\n\n for (const curr of sortMembers(imports)) {\n if (curr.path === curr.root) continue\n\n const { name, path, isTypeOnly } = curr\n\n if (Array.isArray(name)) {\n const names = [...new Set(name.map(canonicalizeName))].filter((item) => isUsed(importLocalName(item)))\n if (names.length) merge({ node: curr, names })\n continue\n }\n\n if (!isUsed(name) && !pathsWithUsedNamedImport.has(path)) continue\n\n const key = `${path}:${name}:${isTypeOnly ?? false}`\n if (!seen.has(key)) {\n result.push(curr)\n seen.add(key)\n }\n }\n\n return result\n}\n","import type { ValueOf } from '@internals/utils'\nimport type { nodeKinds } from '../constants.ts'\n\n/**\n * `kind` values used by AST nodes.\n *\n * @example\n * ```ts\n * const kind: NodeKind = 'Schema'\n * ```\n */\nexport type NodeKind = ValueOf<typeof nodeKinds>\n\n/**\n * Base shape shared by all AST nodes.\n *\n * @example\n * ```ts\n * const base: BaseNode = { kind: 'Input' }\n * ```\n */\nexport type BaseNode = {\n /**\n * Node discriminator.\n */\n kind: NodeKind\n /**\n * Where the node comes from in the input, in the form the adapter's `locate` reads. Document\n * adapters such as OpenAPI and AsyncAPI use an RFC 6901 JSON pointer, for example\n * `#/components/schemas/Pet`. Plugins can copy it to the code nodes they emit.\n */\n pointer?: string\n}\n\n/** `Omit` applied to each member of a union, so the union survives. */\nexport type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** Builds a `createX` factory for a node whose only computed field is `kind`. */\nexport function nodeFactory<T extends BaseNode>(kind: T['kind']): (input: Omit<T, 'kind'>) => T {\n return (input) => {\n const node = { ...input, kind }\n return node as T\n }\n}\n","import { hash } from 'node:crypto'\nimport path from 'node:path'\nimport { nodeKinds } from '../constants.ts'\nimport { combineExports, combineImports, combineSources, importLocalName } from '../utils/combineFileMembers.ts'\nimport { getNodeText } from '../utils/nodeText.ts'\nimport { type BaseNode, nodeFactory } from './base.ts'\nimport type { CodeNode } from './code.ts'\n\n/**\n * Supported file extensions.\n */\ntype Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\ntype ImportName = string | Array<string | { propertyName: string; name?: string }>\n\n/**\n * Represents a language-agnostic import/dependency declaration.\n *\n * @example Named import (TypeScript: `import { useState } from 'react'`)\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * ```\n *\n * @example Default import (TypeScript: `import React from 'react'`)\n * ```ts\n * createImport({ name: 'React', path: 'react' })\n * ```\n *\n * @example Type-only import (TypeScript: `import type { FC } from 'react'`)\n * ```ts\n * createImport({ name: ['FC'], path: 'react', isTypeOnly: true })\n * ```\n *\n * @example Namespace import (TypeScript: `import * as React from 'react'`)\n * ```ts\n * createImport({ name: 'React', path: 'react', isNameSpace: true })\n * ```\n */\nexport type ImportNode = BaseNode & {\n kind: 'Import'\n /**\n * Import name(s) to be used.\n *\n * @example Named imports\n * `['useState']`\n *\n * @example Default import\n * `'React'`\n */\n name: ImportName\n /**\n * Path for the import.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only import prefix.\n * - `true` generates `import type { Type } from './path'`\n * - `false` generates `import { Type } from './path'`\n */\n isTypeOnly?: boolean | null\n /**\n * Import the entire module as a namespace.\n * - `true` generates `import * as Name from './path'`\n * - `false` generates a standard import\n */\n isNameSpace?: boolean | null\n /**\n * When set, the import path is resolved relative to this root.\n */\n root?: string | null\n}\n\n/**\n * Represents a language-agnostic export/public API declaration.\n *\n * @example Named export (TypeScript: `export { Pets } from './Pets'`)\n * ```ts\n * createExport({ name: ['Pets'], path: './Pets' })\n * ```\n *\n * @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })\n * ```\n *\n * @example Wildcard export (TypeScript: `export * from './utils'`)\n * ```ts\n * createExport({ path: './utils' })\n * ```\n *\n * @example Namespace alias (TypeScript: `export * as utils from './utils'`)\n * ```ts\n * createExport({ name: 'utils', path: './utils', asAlias: true })\n * ```\n */\nexport type ExportNode = BaseNode & {\n kind: 'Export'\n /**\n * Export name(s) to be used. When omitted, generates a wildcard export.\n *\n * @example Named exports\n * `['useState']`\n *\n * @example Single export\n * `'React'`\n */\n name?: string | Array<string> | null\n /**\n * Path for the export.\n *\n * @example\n * `'@kubb/core'`\n */\n path: string\n /**\n * Add a type-only export prefix.\n * - `true` generates `export type { Type } from './path'`\n * - `false` generates `export { Type } from './path'`\n */\n isTypeOnly?: boolean | null\n /**\n * Export as an aliased namespace.\n * - `true` generates `export * as aliasName from './path'`\n * - `false` generates a standard export\n */\n asAlias?: boolean | null\n}\n\n/**\n * Represents a fragment of source code within a file.\n *\n * @example Named exportable source\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n *\n * @example Inline unnamed code block\n * ```ts\n * createSource({ nodes: [createText('const x = 1')] })\n * ```\n */\nexport type SourceNode = BaseNode & {\n kind: 'Source'\n /**\n * Optional name identifying this source (used for deduplication and barrel generation).\n */\n name?: string | null\n /**\n * Mark this source as a type-only export.\n */\n isTypeOnly?: boolean | null\n /**\n * Mark this source as an exported declaration, which barrels list. The source text carries its own `export` keyword.\n */\n export?: boolean | null\n /**\n * Mark this exported source as the module's default export. Barrels skip it, since they can't re-export it by name.\n */\n default?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isExportable?: boolean | null\n /**\n * @deprecated Use `export`. Removed in Kubb v6.\n */\n isIndexable?: boolean | null\n /**\n * Marks the source as a definition that importing files absorb instead of import. `expression` is\n * the declaration's right-hand side, such as `{ body: Pet }`.\n *\n * @deprecated Set `inline` on the file. Removed in Kubb v6.\n */\n inline?: { expression: string } | null\n /**\n * Child nodes that make up this source fragment, in DOM order.\n * Use a {@link TextNode} for raw string content.\n */\n nodes?: Array<CodeNode>\n}\n\n/**\n * Represents a fully resolved file in the AST.\n *\n * Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input\n * and deduplicates `imports`, `exports`, and `sources`.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of the path\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n */\nexport type FileNode<TMeta extends object = object> = BaseNode & {\n kind: 'File'\n /**\n * Unique identifier derived from a SHA256 hash of the file path. `createFile`\n * computes it, so callers do not need to provide it.\n */\n id: string\n /**\n * File name without extension, derived from `baseName`.\n *\n * @see https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n /**\n * File base name, including extension, shaped like `${name}${extname}`.\n *\n * @see https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: `${string}.${string}`\n /**\n * Full qualified path to the file.\n */\n path: string\n /**\n * File extension extracted from `baseName`.\n */\n extname: Extname\n /**\n * Deduplicated list of source code fragments.\n */\n sources: Array<SourceNode>\n /**\n * Deduplicated list of import declarations.\n */\n imports: Array<ImportNode>\n /**\n * Deduplicated list of export declarations.\n */\n exports: Array<ExportNode>\n /**\n * Optional metadata attached to this file, read by plugins during barrel generation.\n */\n meta?: TMeta\n /**\n * Optional banner prepended to the generated file content.\n * Accepts `null` so `resolver.default.banner()` results can be passed directly.\n */\n banner?: string | null\n /**\n * Optional footer appended to the generated file content.\n * Accepts `null` so `resolver.default.footer()` results can be passed directly.\n */\n footer?: string | null\n /**\n * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has one.\n *\n * Use to emit a real source file shipped inside a package (a template) into the generated\n * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for\n * output; `sources` may still carry `name`/`export` so barrel generation\n * treats the file the same as a rendered one.\n */\n copy?: string | null\n /**\n * Marks a file that is never written. Each file that imports from it gets the body of each imported declaration, such as `{ body: Pet }`, in place of its name.\n */\n inline?: boolean | null\n}\n\n/**\n * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.\n *\n * @example Named import\n * ```ts\n * createImport({ name: ['useState'], path: 'react' })\n * // import { useState } from 'react'\n * ```\n */\nexport const createImport = nodeFactory<ImportNode>(nodeKinds.import)\n\n/**\n * Creates an `ExportNode` representing a language-agnostic export/public API declaration.\n *\n * @example Named export\n * ```ts\n * createExport({ name: ['Pet'], path: './Pet' })\n * // export { Pet } from './Pet'\n * ```\n */\nexport const createExport = nodeFactory<ExportNode>(nodeKinds.export)\n\n/**\n * Creates a `SourceNode` representing a fragment of source code within a file.\n *\n * @example\n * ```ts\n * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })\n * ```\n */\nexport const createSource = nodeFactory<SourceNode>(nodeKinds.source)\n\n/**\n * Input descriptor for {@link createFile}, before `id`, `name`, and `extname` are computed\n * and `imports`/`exports`/`sources` are deduplicated.\n */\nexport type UserFileNode<TMeta extends object = object> = Omit<FileNode<TMeta>, 'kind' | 'id' | 'name' | 'extname' | 'imports' | 'exports' | 'sources'> &\n Pick<Partial<FileNode<TMeta>>, 'imports' | 'exports' | 'sources'>\n\n/**\n * Creates a fully resolved `FileNode` from a file input descriptor.\n *\n * Computes:\n * - `id` SHA256 hash of the file path\n * - `name` `baseName` without extension\n * - `extname` extension extracted from `baseName`\n *\n * Deduplicates:\n * - `sources` via `combineSources`\n * - `exports` via `combineExports`\n * - `imports` via `combineImports` (also filters unused imports)\n *\n * @throws {Error} when `baseName` has no extension.\n *\n * @example\n * ```ts\n * const file = createFile({\n * baseName: 'petStore.ts',\n * path: 'src/models/petStore.ts',\n * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')] })],\n * imports: [createImport({ name: ['z'], path: 'zod' })],\n * exports: [createExport({ name: ['Pet'], path: './petStore' })],\n * })\n * // file.id = SHA256 hash of 'src/models/petStore.ts'\n * // file.name = 'petStore'\n * // file.extname = '.ts'\n * ```\n *\n * @example Copy a real file into the output\n * ```ts\n * const file = createFile({\n * baseName: 'client.ts',\n * path: 'src/gen/client.ts',\n * copy: '/abs/path/to/templates/client.ts',\n * })\n * ```\n */\nexport function createFile<TMeta extends object = object>(input: UserFileNode<TMeta>): FileNode<TMeta> {\n const extname = path.extname(input.baseName) as `.${string}`\n if (!extname) {\n throw new Error(`No extname found for ${input.baseName}`)\n }\n\n const resolvedExports = input.exports?.length ? combineExports(input.exports) : []\n const resolvedSources = input.sources?.length ? combineSources(input.sources) : []\n\n // Skip building the source text and local-name set when there are no imports to resolve against them.\n const resolvedImports: Array<ImportNode> = (() => {\n if (!input.imports?.length) return []\n\n const sourceParts: Array<string> = []\n const localNames = new Set<string>()\n // Only the sources the file keeps count: an import used just by a dropped duplicate is unused.\n for (const item of resolvedSources) {\n const extracted = item.nodes && getNodeText(item.nodes)\n if (extracted) sourceParts.push(extracted)\n if (item.name) localNames.add(item.name)\n }\n const source = sourceParts.join('\\n') || undefined\n const combinedImports = combineImports(input.imports, resolvedExports, source)\n // Consolidating output (`mode: 'file'`) can put a symbol's definition and an import of it in the\n // same file: by path when the import still targets this file, by name when consolidation moved it.\n return combinedImports.flatMap((imp) => {\n if (imp.path === input.path) return []\n if (!Array.isArray(imp.name)) {\n return typeof imp.name === 'string' && localNames.has(imp.name) ? [] : [imp]\n }\n const kept = imp.name.filter((item) => !localNames.has(importLocalName(item)))\n\n if (!kept.length) return []\n return [kept.length === imp.name.length ? imp : { ...imp, name: kept }]\n })\n })()\n\n return {\n ...input,\n kind: nodeKinds.file,\n id: hash('sha256', input.path, 'hex'),\n name: path.basename(input.baseName, extname),\n extname,\n imports: resolvedImports,\n exports: resolvedExports,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IAAI,IAAY;EAEnC,KAAK,MAAM,QAAQ,iBAAiB;GAClC,MAAM,YAAY,KAAK,SAASC,iBAAAA,YAAY,KAAK,KAAK;GACtD,IAAI,WAAW,YAAY,KAAK,SAAS;GACzC,IAAI,KAAK,MAAM,WAAW,IAAI,KAAK,IAAI;EACzC;EACA,MAAM,SAAS,YAAY,KAAK,IAAI,KAAK,KAAA;EAIzC,OAHwB,eAAe,MAAM,SAAS,iBAAiB,MAGlD,CAAC,CAAC,SAAS,QAAQ;GACtC,IAAI,IAAI,SAAS,MAAM,MAAM,OAAO,CAAC;GACrC,IAAI,CAAC,MAAM,QAAQ,IAAI,IAAI,GACzB,OAAO,OAAO,IAAI,SAAS,YAAY,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG;GAE7E,MAAM,OAAO,IAAI,KAAK,QAAQ,SAAS,CAAC,WAAW,IAAI,gBAAgB,IAAI,CAAC,CAAC;GAE7E,IAAI,CAAC,KAAK,QAAQ,OAAO,CAAC;GAC1B,OAAO,CAAC,KAAK,WAAW,IAAI,KAAK,SAAS,MAAM;IAAE,GAAG;IAAK,MAAM;GAAK,CAAC;EACxE,CAAC;CACH,EAAA,CAAG;CAEH,OAAO;EACL,GAAG;EACH,MAAMF,kBAAAA,UAAU;EAChB,KAAA,GAAIG,YAAAA,KAAAA,CAAK,UAAU,MAAM,MAAM,KAAK;EACpC,MAAMF,UAAAA,QAAK,SAAS,MAAM,UAAU,OAAO;EAC3C;EACA,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAO,MAAM,QAAQ,CAAC;CACxB;AACF"}
@@ -1,4 +1,4 @@
1
- import { t as BaseNode } from "./base-IpYuh3ZP.js";
1
+ import { t as BaseNode } from "./base-UFBZi-FO.cjs";
2
2
  /**
3
3
  * JSDoc documentation metadata attached to code declarations.
4
4
  */
@@ -78,6 +78,14 @@ type TypeNode = BaseNode & {
78
78
  * Whether the declaration should be exported.
79
79
  */
80
80
  export?: boolean | null;
81
+ /**
82
+ * How the declaration is written.
83
+ * - `'type'` declares `type Name = …`
84
+ * - `'interface'` declares `interface Name { … }`, so the body must be an object type
85
+ *
86
+ * @default 'type'
87
+ */
88
+ syntax?: 'type' | 'interface' | null;
81
89
  /**
82
90
  * JSDoc documentation metadata.
83
91
  */
@@ -426,7 +434,7 @@ type ExportNode = BaseNode & {
426
434
  *
427
435
  * @example Named exportable source
428
436
  * ```ts
429
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
437
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
430
438
  * ```
431
439
  *
432
440
  * @example Inline unnamed code block
@@ -445,16 +453,26 @@ type SourceNode = BaseNode & {
445
453
  */
446
454
  isTypeOnly?: boolean | null;
447
455
  /**
448
- * Mark this source as an exported declaration. The source text carries its own `export` keyword.
456
+ * Mark this source as an exported declaration, which barrels list. The source text carries its own `export` keyword.
457
+ */
458
+ export?: boolean | null;
459
+ /**
460
+ * Mark this exported source as the module's default export. Barrels skip it, since they can't re-export it by name.
461
+ */
462
+ default?: boolean | null;
463
+ /**
464
+ * @deprecated Use `export`. Removed in Kubb v6.
449
465
  */
450
466
  isExportable?: boolean | null;
451
467
  /**
452
- * Include this source in barrel/index file generation.
468
+ * @deprecated Use `export`. Removed in Kubb v6.
453
469
  */
454
470
  isIndexable?: boolean | null;
455
471
  /**
456
472
  * Marks the source as a definition that importing files absorb instead of import. `expression` is
457
473
  * the declaration's right-hand side, such as `{ body: Pet }`.
474
+ *
475
+ * @deprecated Set `inline` on the file. Removed in Kubb v6.
458
476
  */
459
477
  inline?: {
460
478
  expression: string;
@@ -476,7 +494,7 @@ type SourceNode = BaseNode & {
476
494
  * const file = createFile({
477
495
  * baseName: 'petStore.ts',
478
496
  * path: 'src/models/petStore.ts',
479
- * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
497
+ * sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })],
480
498
  * imports: [createImport({ name: ['z'], path: 'zod' })],
481
499
  * exports: [createExport({ name: ['Pet'], path: './petStore' })],
482
500
  * })
@@ -543,10 +561,14 @@ type FileNode<TMeta extends object = object> = BaseNode & {
543
561
  *
544
562
  * Use to emit a real source file shipped inside a package (a template) into the generated
545
563
  * folder. When set, `copy` provides the file content and any `sources` nodes are ignored for
546
- * output; `sources` may still carry `name`/`isExportable`/`isIndexable` so barrel generation
564
+ * output; `sources` may still carry `name`/`export` so barrel generation
547
565
  * treats the file the same as a rendered one.
548
566
  */
549
567
  copy?: string | null;
568
+ /**
569
+ * Marks a file that is never written. Each file that imports from it gets the body of each imported declaration, such as `{ body: Pet }`, in place of its name.
570
+ */
571
+ inline?: boolean | null;
550
572
  };
551
573
  /**
552
574
  * Creates an `ImportNode` representing a language-agnostic import/dependency declaration.
@@ -573,7 +595,7 @@ declare const createExport: (input: Omit<ExportNode, "kind">) => ExportNode;
573
595
  *
574
596
  * @example
575
597
  * ```ts
576
- * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })
598
+ * createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], export: true })
577
599
  * ```
578
600
  */
579
601
  declare const createSource: (input: Omit<SourceNode, "kind">) => SourceNode;
package/dist/file.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_file = require("./file-Dd50jPkH.cjs");
2
+ const require_file = require("./file-BAICym_L.cjs");
3
3
  exports.inline = require_file.inlineFiles;
package/dist/file.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { r as inlineFiles } from "./index-Csf8xsCc.cjs";
1
+ import { r as inlineFiles } from "./index-DkThxxxq.cjs";
2
2
  export { inlineFiles as inline };
package/dist/file.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { r as inlineFiles } from "./index-cpjUxIik.js";
1
+ import { r as inlineFiles } from "./index-jWtEIa7j.js";
2
2
  export { inlineFiles as inline };
package/dist/file.js CHANGED
@@ -1 +1 @@
1
- export { n as inline } from "./file-CvlMAp_d.js";
1
+ export { n as inline } from "./file-Dj9lsbJu.js";
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
- import { t as memo } from "./promise-RpnEev9D.js";
3
- import { t as nodeKinds } from "./constants-Ckeonm-D.js";
4
- import { i as visitChildNodes, t as collect } from "./visitor-NoQSUQTu.js";
5
- import { a as resolveRefName } from "./refs-YCV3CznS.js";
2
+ import { t as memo } from "./promise-B3YkZ4C8.js";
3
+ import { t as nodeKinds } from "./constants-BTTus9ee.js";
4
+ import { i as visitChildNodes, t as collect } from "./visitor-XA0W3OVv.js";
5
+ import { a as resolveRefName } from "./refs-Bgf8_9Ui.js";
6
6
  // src/utils/schemaGraph.ts
7
7
  const refEntries = memo.create({ weak: true });
8
8
  const checkRefEntries = memo.create({ weak: true });
@@ -141,4 +141,4 @@ var graph_exports = /* @__PURE__ */ __exportAll({
141
141
  });
142
142
  export { findCircularSchemas as a, collectUsedSchemaNames as i, collectImportedRefNames as n, collectSchemaRefs as r, graph_exports as t };
143
143
 
144
- //# sourceMappingURL=graph-BcwFCvei.js.map
144
+ //# sourceMappingURL=graph-BUEOBomo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph-BcwFCvei.js","names":[],"sources":["../src/utils/schemaGraph.ts","../src/graph/index.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport { nodeKinds } from '../constants.ts'\nimport type { Node } from '../nodes/index.ts'\nimport type { OperationNode } from '../nodes/operation.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { collect, visitChildNodes } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\ntype RefEntry = { name: string; hasPointer: boolean }\n\nconst refEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst checkRefEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst schemaRefs = memo.create<SchemaNode, ReadonlySet<string>>({ weak: true })\nconst importedRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\nconst importedCheckRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\n\n/**\n * Walks a node's subtree once and lists every ref it holds, in traversal order, as the resolved\n * name plus whether the ref carries a `$ref` pointer. Memoized per node and per `checks` mode, so\n * each helper below scans a schema once.\n */\nfunction collectRefEntries(node: SchemaNode, { checks }: { checks: boolean }): ReadonlyArray<RefEntry> {\n return memo(checks ? checkRefEntries : refEntries, node, () => {\n const entries: Array<RefEntry> = []\n const walk = (current: Node): boolean => {\n if (current.kind === nodeKinds.schema && current.type === 'ref') {\n const name = resolveRefName(current)\n if (name) entries.push({ name, hasPointer: Boolean(current.ref) })\n }\n visitChildNodes(current, walk, { checks })\n return false\n }\n walk(node)\n return entries\n })\n}\n\n/**\n * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.\n * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by\n * node identity, so repeated calls on one schema scan it once.\n *\n * @example\n * ```ts\n * collectSchemaRefs(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n */\nexport function collectSchemaRefs(node: SchemaNode): ReadonlySet<string> {\n return memo(schemaRefs, node, () => new Set(collectRefEntries(node, { checks: true }).map((entry) => entry.name)))\n}\n\n/**\n * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in\n * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result\n * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.\n *\n * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the\n * same file (a union member created by name) is left out. That leaves exactly the set\n * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with\n * `checks: true`, for a plugin that prints those checks.\n *\n * @example\n * ```ts\n * collectImportedRefNames(petSchema)\n * // ['Category', 'Tag']\n * ```\n */\nexport function collectImportedRefNames(node: SchemaNode, { checks = false }: { checks?: boolean } = {}): ReadonlyArray<string> {\n return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [\n ...new Set(collectRefEntries(node, { checks }).flatMap((entry) => (entry.hasPointer ? [entry.name] : []))),\n ])\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n for (const name of collectSchemaRefs(schema)) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const op of operations) {\n for (const schema of collect<SchemaNode>(op, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, ReadonlySet<string>>()\n for (const schema of schemas) {\n if (schema.name) graph.set(schema.name, collectSchemaRefs(schema))\n }\n\n const circular = new Set<string>()\n for (const start of graph.keys()) {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) {\n circular.add(start)\n break\n }\n if (visited.has(node)) continue\n visited.add(node)\n\n const next = graph.get(node)\n if (next) for (const r of next) stack.push(r)\n }\n }\n\n return circular\n}\n","export {\n collectImportedRefNames as getImportedNames,\n collectSchemaRefs as getRefNames,\n collectUsedSchemaNames as getUsedNames,\n findCircularSchemas as getCircularNames,\n} from '../utils/schemaGraph.ts'\n"],"mappings":";;;;;;AAUA,MAAM,aAAa,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AAClF,MAAM,kBAAkB,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AACvF,MAAM,aAAa,KAAK,OAAwC,EAAE,MAAM,KAAK,CAAC;AAC9E,MAAM,mBAAmB,KAAK,OAA0C,EAAE,MAAM,KAAK,CAAC;AACtF,MAAM,wBAAwB,KAAK,OAA0C,EAAE,MAAM,KAAK,CAAC;;;;;;AAO3F,SAAS,kBAAkB,MAAkB,EAAE,UAAwD;CACrG,OAAO,KAAK,SAAS,kBAAkB,YAAY,YAAY;EAC7D,MAAM,UAA2B,CAAC;EAClC,MAAM,QAAQ,YAA2B;GACvC,IAAI,QAAQ,SAAS,UAAU,UAAU,QAAQ,SAAS,OAAO;IAC/D,MAAM,OAAO,eAAe,OAAO;IACnC,IAAI,MAAM,QAAQ,KAAK;KAAE;KAAM,YAAY,QAAQ,QAAQ,GAAG;IAAE,CAAC;GACnE;GACA,gBAAgB,SAAS,MAAM,EAAE,OAAO,CAAC;GACzC,OAAO;EACT;EACA,KAAK,IAAI;EACT,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,kBAAkB,MAAuC;CACvE,OAAO,KAAK,YAAY,YAAY,IAAI,IAAI,kBAAkB,MAAM,EAAE,QAAQ,KAAK,CAAC,CA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zD,OAAO,MAAM,SAAS,GAAG;GACvB,MAAM,OAAO,MAAM,IAAI;GACvB,IAAI,SAAS,OAAO;IAClB,SAAS,IAAI,KAAK;IAClB;GACF;GACA,IAAI,QAAQ,IAAI,IAAI,GAAG;GACvB,QAAQ,IAAI,IAAI;GAEhB,MAAM,OAAO,MAAM,IAAI,IAAI;GAC3B,IAAI,MAAM,KAAK,MAAM,KAAK,MAAM,MAAM,KAAK,CAAC;EAC9C;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"graph-BUEOBomo.js","names":[],"sources":["../src/utils/schemaGraph.ts","../src/graph/index.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport { nodeKinds } from '../constants.ts'\nimport type { Node } from '../nodes/index.ts'\nimport type { OperationNode } from '../nodes/operation.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { collect, visitChildNodes } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\ntype RefEntry = { name: string; hasPointer: boolean }\n\nconst refEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst checkRefEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst schemaRefs = memo.create<SchemaNode, ReadonlySet<string>>({ weak: true })\nconst importedRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\nconst importedCheckRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\n\n/**\n * Walks a node's subtree once and lists every ref it holds, in traversal order, as the resolved\n * name plus whether the ref carries a `$ref` pointer. Memoized per node and per `checks` mode, so\n * each helper below scans a schema once.\n */\nfunction collectRefEntries(node: SchemaNode, { checks }: { checks: boolean }): ReadonlyArray<RefEntry> {\n return memo(checks ? checkRefEntries : refEntries, node, () => {\n const entries: Array<RefEntry> = []\n const walk = (current: Node): boolean => {\n if (current.kind === nodeKinds.schema && current.type === 'ref') {\n const name = resolveRefName(current)\n if (name) entries.push({ name, hasPointer: Boolean(current.ref) })\n }\n visitChildNodes(current, walk, { checks })\n return false\n }\n walk(node)\n return entries\n })\n}\n\n/**\n * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.\n * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by\n * node identity, so repeated calls on one schema scan it once.\n *\n * @example\n * ```ts\n * collectSchemaRefs(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n */\nexport function collectSchemaRefs(node: SchemaNode): ReadonlySet<string> {\n return memo(schemaRefs, node, () => new Set(collectRefEntries(node, { checks: true }).map((entry) => entry.name)))\n}\n\n/**\n * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in\n * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result\n * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.\n *\n * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the\n * same file (a union member created by name) is left out. That leaves exactly the set\n * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with\n * `checks: true`, for a plugin that prints those checks.\n *\n * @example\n * ```ts\n * collectImportedRefNames(petSchema)\n * // ['Category', 'Tag']\n * ```\n */\nexport function collectImportedRefNames(node: SchemaNode, { checks = false }: { checks?: boolean } = {}): ReadonlyArray<string> {\n return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [\n ...new Set(collectRefEntries(node, { checks }).flatMap((entry) => (entry.hasPointer ? [entry.name] : []))),\n ])\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n for (const name of collectSchemaRefs(schema)) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const op of operations) {\n for (const schema of collect<SchemaNode>(op, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, ReadonlySet<string>>()\n for (const schema of schemas) {\n if (schema.name) graph.set(schema.name, collectSchemaRefs(schema))\n }\n\n const circular = new Set<string>()\n for (const start of graph.keys()) {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) {\n circular.add(start)\n break\n }\n if (visited.has(node)) continue\n visited.add(node)\n\n const next = graph.get(node)\n if (next) for (const r of next) stack.push(r)\n }\n }\n\n return circular\n}\n","export {\n collectImportedRefNames as getImportedNames,\n collectSchemaRefs as getRefNames,\n collectUsedSchemaNames as getUsedNames,\n findCircularSchemas as getCircularNames,\n} from '../utils/schemaGraph.ts'\n"],"mappings":";;;;;;AAUA,MAAM,aAAa,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AAClF,MAAM,kBAAkB,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;A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GpD,MAAM,yBAAS,IAAI,IAAY;CAE/B,SAAS,YAAY,QAA0B;EAC7C,KAAK,MAAM,QAAQ,kBAAkB,MAAM,GACzC,IAAI,CAAC,OAAO,IAAI,IAAI,GAAG;GACrB,OAAO,IAAI,IAAI;GACf,MAAM,cAAc,UAAU,IAAI,IAAI;GACtC,IAAI,aAAa,YAAY,WAAW;EAC1C;CAEJ;CAEA,KAAK,MAAM,MAAM,YACf,KAAK,MAAM,UAAU,QAAoB,IAAI;EAAE,OAAO;EAAW,SAAS,SAAS;CAAK,CAAC,GACvF,YAAY,MAAM;CAItB,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,oBAAoB,SAAiD;CACnF,MAAM,wBAAQ,IAAI,IAAiC;CACnD,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,MAAM,MAAM,IAAI,OAAO,MAAM,kBAAkB,MAAM,CAAC;CAGnE,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,SAAS,MAAM,KAAK,GAAG;EAChC,MAAM,0BAAU,IAAI,IAAY;EAChC,MAAM,QAAuB,CAAC,GAAI,MAAM,IAAI,KAAK,KAAK,CAAC,CAAE;EACzD,OAAO,MAAM,SAAS,GAAG;GACvB,MAAM,OAAO,MAAM,IAAI;GACvB,IAAI,SAAS,OAAO;IAClB,SAAS,IAAI,KAAK;IAClB;GACF;GACA,IAAI,QAAQ,IAAI,IAAI,GAAG;GACvB,QAAQ,IAAI,IAAI;GAEhB,MAAM,OAAO,MAAM,IAAI,IAAI;GAC3B,IAAI,MAAM,KAAK,MAAM,KAAK,MAAM,MAAM,KAAK,CAAC;EAC9C;CACF;CAEA,OAAO;AACT"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_promise = require("./promise-BOdlgT0N.cjs");
3
- const require_constants = require("./constants-CquR083U.cjs");
4
- const require_visitor = require("./visitor-DTrzvA3R.cjs");
5
- const require_refs = require("./refs-CYHpRlQo.cjs");
2
+ const require_promise = require("./promise-DScaykew.cjs");
3
+ const require_constants = require("./constants-DztHlVmY.cjs");
4
+ const require_visitor = require("./visitor-Bh1CBAOz.cjs");
5
+ const require_refs = require("./refs-rmr2LFV1.cjs");
6
6
  // src/utils/schemaGraph.ts
7
7
  const refEntries = require_promise.memo.create({ weak: true });
8
8
  const checkRefEntries = require_promise.memo.create({ weak: true });
@@ -170,4 +170,4 @@ Object.defineProperty(exports, "graph_exports", {
170
170
  }
171
171
  });
172
172
 
173
- //# sourceMappingURL=graph-DcIY6tQb.cjs.map
173
+ //# sourceMappingURL=graph-CFJ4wzFR.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph-DcIY6tQb.cjs","names":["memo","nodeKinds","resolveRefName","visitChildNodes","collect"],"sources":["../src/utils/schemaGraph.ts","../src/graph/index.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport { nodeKinds } from '../constants.ts'\nimport type { Node } from '../nodes/index.ts'\nimport type { OperationNode } from '../nodes/operation.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { collect, visitChildNodes } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\ntype RefEntry = { name: string; hasPointer: boolean }\n\nconst refEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst checkRefEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst schemaRefs = memo.create<SchemaNode, ReadonlySet<string>>({ weak: true })\nconst importedRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\nconst importedCheckRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\n\n/**\n * Walks a node's subtree once and lists every ref it holds, in traversal order, as the resolved\n * name plus whether the ref carries a `$ref` pointer. Memoized per node and per `checks` mode, so\n * each helper below scans a schema once.\n */\nfunction collectRefEntries(node: SchemaNode, { checks }: { checks: boolean }): ReadonlyArray<RefEntry> {\n return memo(checks ? checkRefEntries : refEntries, node, () => {\n const entries: Array<RefEntry> = []\n const walk = (current: Node): boolean => {\n if (current.kind === nodeKinds.schema && current.type === 'ref') {\n const name = resolveRefName(current)\n if (name) entries.push({ name, hasPointer: Boolean(current.ref) })\n }\n visitChildNodes(current, walk, { checks })\n return false\n }\n walk(node)\n return entries\n })\n}\n\n/**\n * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.\n * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by\n * node identity, so repeated calls on one schema scan it once.\n *\n * @example\n * ```ts\n * collectSchemaRefs(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n */\nexport function collectSchemaRefs(node: SchemaNode): ReadonlySet<string> {\n return memo(schemaRefs, node, () => new Set(collectRefEntries(node, { checks: true }).map((entry) => entry.name)))\n}\n\n/**\n * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in\n * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result\n * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.\n *\n * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the\n * same file (a union member created by name) is left out. That leaves exactly the set\n * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with\n * `checks: true`, for a plugin that prints those checks.\n *\n * @example\n * ```ts\n * collectImportedRefNames(petSchema)\n * // ['Category', 'Tag']\n * ```\n */\nexport function collectImportedRefNames(node: SchemaNode, { checks = false }: { checks?: boolean } = {}): ReadonlyArray<string> {\n return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [\n ...new Set(collectRefEntries(node, { checks }).flatMap((entry) => (entry.hasPointer ? [entry.name] : []))),\n ])\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n for (const name of collectSchemaRefs(schema)) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const op of operations) {\n for (const schema of collect<SchemaNode>(op, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, ReadonlySet<string>>()\n for (const schema of schemas) {\n if (schema.name) graph.set(schema.name, collectSchemaRefs(schema))\n }\n\n const circular = new Set<string>()\n for (const start of graph.keys()) {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) {\n circular.add(start)\n break\n }\n if (visited.has(node)) continue\n visited.add(node)\n\n const next = graph.get(node)\n if (next) for (const r of next) stack.push(r)\n }\n }\n\n return circular\n}\n","export {\n collectImportedRefNames as getImportedNames,\n collectSchemaRefs as getRefNames,\n collectUsedSchemaNames as getUsedNames,\n findCircularSchemas as getCircularNames,\n} from '../utils/schemaGraph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AAM,KAAK,CAAC;EAC9C;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"graph-CFJ4wzFR.cjs","names":["memo","nodeKinds","resolveRefName","visitChildNodes","collect"],"sources":["../src/utils/schemaGraph.ts","../src/graph/index.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport { nodeKinds } from '../constants.ts'\nimport type { Node } from '../nodes/index.ts'\nimport type { OperationNode } from '../nodes/operation.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { collect, visitChildNodes } from '../visitor.ts'\nimport { resolveRefName } from './refs.ts'\n\ntype RefEntry = { name: string; hasPointer: boolean }\n\nconst refEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst checkRefEntries = memo.create<SchemaNode, ReadonlyArray<RefEntry>>({ weak: true })\nconst schemaRefs = memo.create<SchemaNode, ReadonlySet<string>>({ weak: true })\nconst importedRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\nconst importedCheckRefNames = memo.create<SchemaNode, ReadonlyArray<string>>({ weak: true })\n\n/**\n * Walks a node's subtree once and lists every ref it holds, in traversal order, as the resolved\n * name plus whether the ref carries a `$ref` pointer. Memoized per node and per `checks` mode, so\n * each helper below scans a schema once.\n */\nfunction collectRefEntries(node: SchemaNode, { checks }: { checks: boolean }): ReadonlyArray<RefEntry> {\n return memo(checks ? checkRefEntries : refEntries, node, () => {\n const entries: Array<RefEntry> = []\n const walk = (current: Node): boolean => {\n if (current.kind === nodeKinds.schema && current.type === 'ref') {\n const name = resolveRefName(current)\n if (name) entries.push({ name, hasPointer: Boolean(current.ref) })\n }\n visitChildNodes(current, walk, { checks })\n return false\n }\n walk(node)\n return entries\n })\n}\n\n/**\n * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.\n * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by\n * node identity, so repeated calls on one schema scan it once.\n *\n * @example\n * ```ts\n * collectSchemaRefs(petSchema)\n * // Set { 'Category', 'Tag' }\n * ```\n */\nexport function collectSchemaRefs(node: SchemaNode): ReadonlySet<string> {\n return memo(schemaRefs, node, () => new Set(collectRefEntries(node, { checks: true }).map((entry) => entry.name)))\n}\n\n/**\n * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in\n * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result\n * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.\n *\n * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the\n * same file (a union member created by name) is left out. That leaves exactly the set\n * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with\n * `checks: true`, for a plugin that prints those checks.\n *\n * @example\n * ```ts\n * collectImportedRefNames(petSchema)\n * // ['Category', 'Tag']\n * ```\n */\nexport function collectImportedRefNames(node: SchemaNode, { checks = false }: { checks?: boolean } = {}): ReadonlyArray<string> {\n return memo(checks ? importedCheckRefNames : importedRefNames, node, () => [\n ...new Set(collectRefEntries(node, { checks }).flatMap((entry) => (entry.hasPointer ? [entry.name] : []))),\n ])\n}\n\n/**\n * Collects the names of all top-level schemas transitively used by a set of operations.\n *\n * An operation uses a schema when its parameters, request body, or responses reference it, directly\n * or through other named schemas. Once a name is added to the result it is not revisited, so\n * reference cycles terminate.\n *\n * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.\n *\n * @example Only generate schemas referenced by included operations\n * ```ts\n * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)\n * const allowed = collectUsedSchemaNames(includedOps, schemas)\n *\n * for (const schema of schemas) {\n * if (schema.name && !allowed.has(schema.name)) continue\n * // generate schema\n * }\n * ```\n */\nexport function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const schemaMap = new Map<string, SchemaNode>()\n for (const schema of schemas) {\n if (schema.name) schemaMap.set(schema.name, schema)\n }\n\n const result = new Set<string>()\n\n function visitSchema(schema: SchemaNode): void {\n for (const name of collectSchemaRefs(schema)) {\n if (!result.has(name)) {\n result.add(name)\n const namedSchema = schemaMap.get(name)\n if (namedSchema) visitSchema(namedSchema)\n }\n }\n }\n\n for (const op of operations) {\n for (const schema of collect<SchemaNode>(op, { depth: 'shallow', schema: (node) => node })) {\n visitSchema(schema)\n }\n }\n\n return result\n}\n\n/**\n * Finds every schema that takes part in a circular dependency chain, including direct self-loops.\n *\n * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so\n * the generated code does not recurse forever. Refs are followed by name only, so the walk stays\n * linear in the size of the schema graph.\n *\n * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.\n */\nexport function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string> {\n const graph = new Map<string, ReadonlySet<string>>()\n for (const schema of schemas) {\n if (schema.name) graph.set(schema.name, collectSchemaRefs(schema))\n }\n\n const circular = new Set<string>()\n for (const start of graph.keys()) {\n const visited = new Set<string>()\n const stack: Array<string> = [...(graph.get(start) ?? [])]\n while (stack.length > 0) {\n const node = stack.pop()!\n if (node === start) {\n circular.add(start)\n break\n }\n if (visited.has(node)) continue\n visited.add(node)\n\n const next = graph.get(node)\n if (next) for (const r of next) stack.push(r)\n }\n }\n\n return circular\n}\n","export {\n collectImportedRefNames as getImportedNames,\n collectSchemaRefs as getRefNames,\n collectUsedSchemaNames as getUsedNames,\n findCircularSchemas as getCircularNames,\n} from '../utils/schemaGraph.ts'\n"],"mappings":";;;;;;AAUA,MAAM,aAAaA,gBAAAA,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AAClF,MAAM,kBAAkBA,gBAAAA,KAAK,OAA4C,EAAE,MAAM,KAAK,CAAC;AACvF,MAAM,aAAaA,gBAAAA,KAAK,OAAwC,EAAE,MAAM,KAAK,CAAC;AAC9E,MAAM,mBAAmBA,gBAAAA,KAAK,OAA0C,EAAE,MAAM,KAAK,CAAC;AACtF,MAAM,wBAAwBA,gBAAAA,KAAK,OAA0C,EAAE,MAAM,KAAK,CAAC;;;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AO,IAAI,IAAI,GAAG;GACrB,OAAO,IAAI,IAAI;GACf,MAAM,cAAc,UAAU,IAAI,IAAI;GACtC,IAAI,aAAa,YAAY,WAAW;EAC1C;CAEJ;CAEA,KAAK,MAAM,MAAM,YACf,KAAK,MAAM,UAAUI,gBAAAA,QAAoB,IAAI;EAAE,OAAO;EAAW,SAAS,SAAS;CAAK,CAAC,GACvF,YAAY,MAAM;CAItB,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,oBAAoB,SAAiD;CACnF,MAAM,wBAAQ,IAAI,IAAiC;CACnD,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,MAAM,MAAM,IAAI,OAAO,MAAM,kBAAkB,MAAM,CAAC;CAGnE,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,SAAS,MAAM,KAAK,GAAG;EAChC,MAAM,0BAAU,IAAI,IAAY;EAChC,MAAM,QAAuB,CAAC,GAAI,MAAM,IAAI,KAAK,KAAK,CAAC,CAAE;EACzD,OAAO,MAAM,SAAS,GAAG;GACvB,MAAM,OAAO,MAAM,IAAI;GACvB,IAAI,SAAS,OAAO;IAClB,SAAS,IAAI,KAAK;IAClB;GACF;GACA,IAAI,QAAQ,IAAI,IAAI,GAAG;GACvB,QAAQ,IAAI,IAAI;GAEhB,MAAM,OAAO,MAAM,IAAI,IAAI;GAC3B,IAAI,MAAM,KAAK,MAAM,KAAK,MAAM,MAAM,KAAK,CAAC;EAC9C;CACF;CAEA,OAAO;AACT"}
package/dist/graph.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_graph = require("./graph-DcIY6tQb.cjs");
2
+ const require_graph = require("./graph-CFJ4wzFR.cjs");
3
3
  exports.getCircularNames = require_graph.findCircularSchemas;
4
4
  exports.getImportedNames = require_graph.collectImportedRefNames;
5
5
  exports.getRefNames = require_graph.collectSchemaRefs;
package/dist/graph.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-DYDha-3I.cjs";
1
+ import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-D-BjRrJo.cjs";
2
2
  export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
package/dist/graph.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-Dp50LM3a.js";
1
+ import { a as findCircularSchemas, i as collectUsedSchemaNames, n as collectImportedRefNames, r as collectSchemaRefs } from "./index-B5w-X5V6.js";
2
2
  export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
package/dist/graph.js CHANGED
@@ -1 +1 @@
1
- export { a as getCircularNames, n as getImportedNames, r as getRefNames, i as getUsedNames } from "./graph-BcwFCvei.js";
1
+ export { a as getCircularNames, n as getImportedNames, r as getRefNames, i as getUsedNames } from "./graph-BUEOBomo.js";
@@ -38,4 +38,4 @@ Object.defineProperty(exports, "narrowSchema", {
38
38
  }
39
39
  });
40
40
 
41
- //# sourceMappingURL=guards-COVJE6TU.cjs.map
41
+ //# sourceMappingURL=guards-4drgx10i.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"guards-COVJE6TU.cjs","names":[],"sources":["../src/guards.ts"],"sourcesContent":["import type { HttpOperationNode, OperationNode } from './nodes/operation.ts'\nimport type { SchemaNode, SchemaNodeByType } from './nodes/schema.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 (ast.http.isOperation(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"],"mappings":";;;;;;;;;;;AAYA,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"}
1
+ {"version":3,"file":"guards-4drgx10i.cjs","names":[],"sources":["../src/guards.ts"],"sourcesContent":["import type { HttpOperationNode, OperationNode } from './nodes/operation.ts'\nimport type { SchemaNode, SchemaNodeByType } from './nodes/schema.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 (ast.http.isOperation(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"],"mappings":";;;;;;;;;;;AAYA,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"}
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, U as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-BgRyVS7z.js";
1
+ import { H as SchemaNode, U as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-jxEr2No4.js";
2
2
  /**
3
3
  * Narrows a `SchemaNode` to the variant that matches `type`.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, U as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-X7chCdL2.cjs";
1
+ import { H as SchemaNode, U as SchemaNodeByType, i as OperationNode, r as HttpOperationNode } from "./operation-BUhPuZMY.cjs";
2
2
  /**
3
3
  * Narrows a `SchemaNode` to the variant that matches `type`.
4
4
  *
@@ -27,4 +27,4 @@ function isHttpOperationNode(node) {
27
27
  }
28
28
  export { narrowSchema as n, isHttpOperationNode as t };
29
29
 
30
- //# sourceMappingURL=guards-DlJkKsT1.js.map
30
+ //# sourceMappingURL=guards-DKw4uwc5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guards-DlJkKsT1.js","names":[],"sources":["../src/guards.ts"],"sourcesContent":["import type { HttpOperationNode, OperationNode } from './nodes/operation.ts'\nimport type { SchemaNode, SchemaNodeByType } from './nodes/schema.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 (ast.http.isOperation(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"],"mappings":";;;;;;;;;;;AAYA,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"}
1
+ {"version":3,"file":"guards-DKw4uwc5.js","names":[],"sources":["../src/guards.ts"],"sourcesContent":["import type { HttpOperationNode, OperationNode } from './nodes/operation.ts'\nimport type { SchemaNode, SchemaNodeByType } from './nodes/schema.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 (ast.http.isOperation(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"],"mappings":";;;;;;;;;;;AAYA,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"}
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
- import { t as isHttpOperationNode } from "./guards-DlJkKsT1.js";
2
+ import { t as isHttpOperationNode } from "./guards-DKw4uwc5.js";
3
3
  // src/http/index.ts
4
4
  var http_exports = /* @__PURE__ */ __exportAll({ isOperation: () => isHttpOperationNode });
5
5
  export { http_exports as t };
6
6
 
7
- //# sourceMappingURL=http-DwboM6pK.js.map
7
+ //# sourceMappingURL=http-CAWf6TAJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-CAWf6TAJ.js","names":[],"sources":["../src/http/index.ts"],"sourcesContent":["export { isHttpOperationNode as isOperation } from '../guards.ts'\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_guards = require("./guards-COVJE6TU.cjs");
2
+ const require_guards = require("./guards-4drgx10i.cjs");
3
3
  // src/http/index.ts
4
4
  var http_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ isOperation: () => require_guards.isHttpOperationNode });
5
5
  Object.defineProperty(exports, "http_exports", {
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "http_exports", {
9
9
  }
10
10
  });
11
11
 
12
- //# sourceMappingURL=http-Bm5lhVK4.cjs.map
12
+ //# sourceMappingURL=http-Dv8py6wh.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-Dv8py6wh.cjs","names":[],"sources":["../src/http/index.ts"],"sourcesContent":["export { isHttpOperationNode as isOperation } from '../guards.ts'\n"],"mappings":""}
package/dist/http.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_guards = require("./guards-COVJE6TU.cjs");
3
- require("./http-Bm5lhVK4.cjs");
2
+ const require_guards = require("./guards-4drgx10i.cjs");
3
+ require("./http-Dv8py6wh.cjs");
4
4
  exports.isOperation = require_guards.isHttpOperationNode;
package/dist/http.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as isHttpOperationNode } from "./guards-B8qDgSaT.cjs";
2
- import "./index-BWd95onW.cjs";
1
+ import { t as isHttpOperationNode } from "./guards-COBkDtgu.cjs";
2
+ import "./index-DuDvNFQ8.cjs";
3
3
  export { isHttpOperationNode as isOperation };
package/dist/http.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { t as isHttpOperationNode } from "./guards-D-h9R_sV.js";
2
- import "./index-DaHsMJ_S.js";
1
+ import { t as isHttpOperationNode } from "./guards-C6w6KQSY.js";
2
+ import "./index-CI6Tu2c7.js";
3
3
  export { isHttpOperationNode as isOperation };
package/dist/http.js CHANGED
@@ -1,2 +1,2 @@
1
- export { t as isOperation } from "./guards-DlJkKsT1.js";
2
- import "./http-DwboM6pK.js";
1
+ export { t as isOperation } from "./guards-DKw4uwc5.js";
2
+ import "./http-CAWf6TAJ.js";
@@ -1,7 +1,7 @@
1
- import { G as StringSchemaNode, H as SchemaNode, X as PropertyNode } from "./operation-BgRyVS7z.js";
2
- import { a as schemaTypes } from "./base-IpYuh3ZP.js";
3
- import { n as narrowSchema } from "./guards-D-h9R_sV.js";
4
- import { a as findSchema } from "./visitor-BZozlXBF.js";
1
+ import { G as StringSchemaNode, H as SchemaNode, X as PropertyNode } from "./operation-jxEr2No4.js";
2
+ import { a as schemaTypes } from "./base-LhsPvVY1.js";
3
+ import { n as narrowSchema } from "./guards-C6w6KQSY.js";
4
+ import { o as findSchema } from "./visitor-CFbuH7BY.js";
5
5
  /**
6
6
  * Generic JSON Schema optionality: a non-required field is optional, and a
7
7
  * non-required nullable field is nullish.
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, i as OperationNode } from "./operation-BgRyVS7z.js";
1
+ import { H as SchemaNode, i as OperationNode } from "./operation-jxEr2No4.js";
2
2
  /**
3
3
  * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.
4
4
  * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
@@ -1,5 +1,5 @@
1
- import { C as createJsx, S as createFunction, T as createType, _ as TextNode, a as UserFileNode, b as createBreak, c as createImport, d as BreakNode, g as JsxNode, i as SourceNode, l as createSource, m as FunctionNode, n as FileNode, o as createExport, p as ConstNode, r as ImportNode, s as createFile, t as ExportNode, u as ArrowFunctionNode, v as TypeNode, w as createText, x as createConst, y as createArrowFunction } from "./file-xJnBQPGq.js";
2
- import { H as SchemaNode, T as InputNode, X as PropertyNode, Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, g as ContentNode, h as createParameter, i as OperationNode, k as createInput, l as createResponse, p as ParameterNode, s as ResponseNode, u as RequestBodyNode, y as createContent } from "./operation-BgRyVS7z.js";
1
+ import { C as createJsx, S as createFunction, T as createType, _ as TextNode, a as UserFileNode, b as createBreak, c as createImport, d as BreakNode, g as JsxNode, i as SourceNode, l as createSource, m as FunctionNode, n as FileNode, o as createExport, p as ConstNode, r as ImportNode, s as createFile, t as ExportNode, u as ArrowFunctionNode, v as TypeNode, w as createText, x as createConst, y as createArrowFunction } from "./file-DkFGn_Os.js";
2
+ import { H as SchemaNode, T as InputNode, X as PropertyNode, Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, g as ContentNode, h as createParameter, i as OperationNode, k as createInput, l as createResponse, p as ParameterNode, s as ResponseNode, u as RequestBodyNode, y as createContent } from "./operation-jxEr2No4.js";
3
3
  declare namespace index_d_exports {
4
4
  export { Node, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
5
5
  }
@@ -0,0 +1,5 @@
1
+ import { t as isHttpOperationNode } from "./guards-C6w6KQSY.js";
2
+ declare namespace index_d_exports {
3
+ export { isHttpOperationNode as isOperation };
4
+ }
5
+ export { index_d_exports as t };
@@ -1,5 +1,5 @@
1
- import { t as Node } from "./index-BwnMIoLl.js";
2
- import { r as VisitorDepth, t as Visitor } from "./visitor-BZozlXBF.js";
1
+ import { t as Node } from "./index-ss1YqjpW.cjs";
2
+ import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-DxhkIQyP.cjs";
3
3
  /**
4
4
  * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
5
5
  * and `undefined` keeps declaration order.
@@ -13,13 +13,18 @@ type Enforce = 'pre' | 'post';
13
13
  * `plugins.sort((a, b) => compareMacroOrder(a.enforce, b.enforce))`
14
14
  */
15
15
  declare function compareMacroOrder(a?: Enforce, b?: Enforce): number;
16
+ /**
17
+ * The {@link Visitor} callbacks with `this` typed as the {@link VisitorContext}. A macro callback gets
18
+ * the context both as `this` and as its second argument.
19
+ */
20
+ type MacroCallbacks = { [K in VisitorKey]?: (this: VisitorContext, ...args: Parameters<NonNullable<Visitor[K]>>) => ReturnType<NonNullable<Visitor[K]>>; };
16
21
  /**
17
22
  * A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
18
23
  * {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
19
24
  * optional `match` predicate. Macros run on the shared AST, so the same macro works across every
20
25
  * adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
21
26
  */
22
- type Macro = Visitor & {
27
+ type Macro = MacroCallbacks & {
23
28
  /**
24
29
  * Macro identifier used to tell macros apart, for example `'dedupe-union'`.
25
30
  */
@@ -1,4 +1,4 @@
1
- import { T as InputNode } from "./operation-BgRyVS7z.js";
1
+ import { T as InputNode } from "./operation-jxEr2No4.js";
2
2
  declare namespace index_d_exports {
3
3
  export { parse, stringify };
4
4
  }
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, z as RefSchemaNode } from "./operation-BgRyVS7z.js";
1
+ import { H as SchemaNode, z as RefSchemaNode } from "./operation-jxEr2No4.js";
2
2
  /**
3
3
  * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { t as Node } from "./index-DSVef1pp.cjs";
2
- import { r as VisitorDepth, t as Visitor } from "./visitor-Bw_opzjF.cjs";
1
+ import { t as Node } from "./index-Be5d4Zcl.js";
2
+ import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-CFbuH7BY.js";
3
3
  /**
4
4
  * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
5
5
  * and `undefined` keeps declaration order.
@@ -13,13 +13,18 @@ type Enforce = 'pre' | 'post';
13
13
  * `plugins.sort((a, b) => compareMacroOrder(a.enforce, b.enforce))`
14
14
  */
15
15
  declare function compareMacroOrder(a?: Enforce, b?: Enforce): number;
16
+ /**
17
+ * The {@link Visitor} callbacks with `this` typed as the {@link VisitorContext}. A macro callback gets
18
+ * the context both as `this` and as its second argument.
19
+ */
20
+ type MacroCallbacks = { [K in VisitorKey]?: (this: VisitorContext, ...args: Parameters<NonNullable<Visitor[K]>>) => ReturnType<NonNullable<Visitor[K]>>; };
16
21
  /**
17
22
  * A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
18
23
  * {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
19
24
  * optional `match` predicate. Macros run on the shared AST, so the same macro works across every
20
25
  * adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
21
26
  */
22
- type Macro = Visitor & {
27
+ type Macro = MacroCallbacks & {
23
28
  /**
24
29
  * Macro identifier used to tell macros apart, for example `'dedupe-union'`.
25
30
  */
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, i as OperationNode } from "./operation-X7chCdL2.cjs";
1
+ import { H as SchemaNode, i as OperationNode } from "./operation-BUhPuZMY.cjs";
2
2
  /**
3
3
  * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.
4
4
  * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
@@ -1,4 +1,4 @@
1
- import { H as SchemaNode, z as RefSchemaNode } from "./operation-X7chCdL2.cjs";
1
+ import { H as SchemaNode, z as RefSchemaNode } from "./operation-BUhPuZMY.cjs";
2
2
  /**
3
3
  * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
4
4
  *
@@ -1,6 +1,6 @@
1
- import { i as nodeKinds } from "./base-IpYuh3ZP.js";
2
- import { f as CodeNode } from "./file-xJnBQPGq.js";
3
- import { i as collect, o as transform } from "./visitor-BZozlXBF.js";
1
+ import { i as nodeKinds } from "./base-LhsPvVY1.js";
2
+ import { f as CodeNode } from "./file-DkFGn_Os.js";
3
+ import { a as collect, s as transform } from "./visitor-CFbuH7BY.js";
4
4
  /**
5
5
  * Extracts all string content from a `CodeNode` tree recursively.
6
6
  * Collects the text fields and nested node content, to build the source string for import filtering.