@ankhorage/dependency-graph 0.7.2 → 1.1.0

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 (212) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +12 -3
  3. package/dist/dependencyGraph.d.ts +14 -9
  4. package/dist/dependencyGraph.d.ts.map +1 -1
  5. package/dist/dependencyGraph.js +12 -8
  6. package/dist/dependencyGraph.js.map +1 -1
  7. package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts +2 -1
  8. package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts.map +1 -1
  9. package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.js.map +1 -1
  10. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts +4 -0
  11. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts.map +1 -0
  12. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js +201 -0
  13. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js.map +1 -0
  14. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.d.ts +4 -0
  15. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.d.ts.map +1 -0
  16. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js +159 -0
  17. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js.map +1 -0
  18. package/dist/features/dependency-analysis/application/assertDependencyGraphInspections.d.ts +4 -0
  19. package/dist/features/dependency-analysis/application/assertDependencyGraphInspections.d.ts.map +1 -0
  20. package/dist/features/dependency-analysis/application/assertDependencyGraphInspections.js +13 -0
  21. package/dist/features/dependency-analysis/application/assertDependencyGraphInspections.js.map +1 -0
  22. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.d.ts +5 -0
  23. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.d.ts.map +1 -0
  24. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.js +43 -0
  25. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.js.map +1 -0
  26. package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.d.ts.map +1 -1
  27. package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.js +1 -2
  28. package/dist/features/dependency-analysis/composition/createDependencyGraphAsync.js.map +1 -0
  29. package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphFromInspectionsAsync.d.ts +1 -3
  30. package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.d.ts.map +1 -0
  31. package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js +13 -0
  32. package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js.map +1 -0
  33. package/dist/features/dependency-analysis/domain/extractCppPackageFromInclude.d.ts.map +1 -0
  34. package/dist/features/dependency-analysis/domain/extractCppPackageFromInclude.js.map +1 -0
  35. package/dist/features/dependency-analysis/domain/extractDelphiPackageFromImport.d.ts.map +1 -0
  36. package/dist/features/dependency-analysis/domain/extractDelphiPackageFromImport.js.map +1 -0
  37. package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.d.ts +3 -0
  38. package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.d.ts.map +1 -0
  39. package/dist/features/dependency-analysis/{adapters/outbound/java → domain}/extractJavaPackageFromImport.js +1 -1
  40. package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.js.map +1 -0
  41. package/dist/features/dependency-analysis/domain/extractKotlinPackageFromImport.d.ts.map +1 -0
  42. package/dist/features/dependency-analysis/domain/extractKotlinPackageFromImport.js.map +1 -0
  43. package/dist/features/dependency-analysis/domain/extractPythonPackageFromImport.d.ts.map +1 -0
  44. package/dist/features/dependency-analysis/domain/extractPythonPackageFromImport.js.map +1 -0
  45. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts +5 -0
  46. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts.map +1 -0
  47. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js +144 -0
  48. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js.map +1 -0
  49. package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.d.ts +4 -0
  50. package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.d.ts.map +1 -0
  51. package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.js +36 -0
  52. package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.js.map +1 -0
  53. package/dist/features/source-graph/composition/createSourceGraphAsync.d.ts +4 -0
  54. package/dist/features/source-graph/composition/createSourceGraphAsync.d.ts.map +1 -0
  55. package/dist/features/source-graph/composition/createSourceGraphAsync.js +16 -0
  56. package/dist/features/source-graph/composition/createSourceGraphAsync.js.map +1 -0
  57. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts +4 -0
  58. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts.map +1 -0
  59. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js +118 -0
  60. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js.map +1 -0
  61. package/dist/features/source-graph/domain/createSourceGraph.d.ts +4 -0
  62. package/dist/features/source-graph/domain/createSourceGraph.d.ts.map +1 -0
  63. package/dist/features/source-graph/domain/createSourceGraph.js +73 -0
  64. package/dist/features/source-graph/domain/createSourceGraph.js.map +1 -0
  65. package/dist/features/source-graph/domain/createSourceGraphIndex.d.ts +4 -0
  66. package/dist/features/source-graph/domain/createSourceGraphIndex.d.ts.map +1 -0
  67. package/dist/features/source-graph/domain/createSourceGraphIndex.js +57 -0
  68. package/dist/features/source-graph/domain/createSourceGraphIndex.js.map +1 -0
  69. package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts +4 -0
  70. package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts.map +1 -0
  71. package/dist/features/source-graph/domain/createSourceRelationDraft.js +119 -0
  72. package/dist/features/source-graph/domain/createSourceRelationDraft.js.map +1 -0
  73. package/dist/features/source-graph/domain/createSourceRollupIndex.d.ts +8 -0
  74. package/dist/features/source-graph/domain/createSourceRollupIndex.d.ts.map +1 -0
  75. package/dist/features/source-graph/domain/createSourceRollupIndex.js +27 -0
  76. package/dist/features/source-graph/domain/createSourceRollupIndex.js.map +1 -0
  77. package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts +11 -0
  78. package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts.map +1 -0
  79. package/dist/features/source-graph/domain/createSourceStructureDraft.js +238 -0
  80. package/dist/features/source-graph/domain/createSourceStructureDraft.js.map +1 -0
  81. package/dist/features/source-graph/domain/querySourceGraph.d.ts +15 -0
  82. package/dist/features/source-graph/domain/querySourceGraph.d.ts.map +1 -0
  83. package/dist/features/source-graph/domain/querySourceGraph.js +40 -0
  84. package/dist/features/source-graph/domain/querySourceGraph.js.map +1 -0
  85. package/dist/features/source-graph/domain/resolveSourceImport.d.ts +9 -0
  86. package/dist/features/source-graph/domain/resolveSourceImport.d.ts.map +1 -0
  87. package/dist/features/source-graph/domain/resolveSourceImport.js +146 -0
  88. package/dist/features/source-graph/domain/resolveSourceImport.js.map +1 -0
  89. package/dist/features/source-graph/domain/rollupSourceRelations.d.ts +4 -0
  90. package/dist/features/source-graph/domain/rollupSourceRelations.d.ts.map +1 -0
  91. package/dist/features/source-graph/domain/rollupSourceRelations.js +46 -0
  92. package/dist/features/source-graph/domain/rollupSourceRelations.js.map +1 -0
  93. package/dist/features/source-graph/domain/serializeSourceGraph.d.ts +6 -0
  94. package/dist/features/source-graph/domain/serializeSourceGraph.d.ts.map +1 -0
  95. package/dist/features/source-graph/domain/serializeSourceGraph.js +64 -0
  96. package/dist/features/source-graph/domain/serializeSourceGraph.js.map +1 -0
  97. package/dist/features/source-graph/domain/sourceSemanticPath.d.ts +3 -0
  98. package/dist/features/source-graph/domain/sourceSemanticPath.d.ts.map +1 -0
  99. package/dist/features/source-graph/domain/sourceSemanticPath.js +5 -0
  100. package/dist/features/source-graph/domain/sourceSemanticPath.js.map +1 -0
  101. package/dist/features/source-graph/domain/summarizeSourceNode.d.ts +4 -0
  102. package/dist/features/source-graph/domain/summarizeSourceNode.d.ts.map +1 -0
  103. package/dist/features/source-graph/domain/summarizeSourceNode.js +66 -0
  104. package/dist/features/source-graph/domain/summarizeSourceNode.js.map +1 -0
  105. package/dist/types/dependencyGraph.d.ts +2 -23
  106. package/dist/types/dependencyGraph.d.ts.map +1 -1
  107. package/dist/types/dependencyGraph.js.map +1 -1
  108. package/dist/types/sourceGraph.d.ts +173 -0
  109. package/dist/types/sourceGraph.d.ts.map +1 -0
  110. package/dist/types/sourceGraph.js +2 -0
  111. package/dist/types/sourceGraph.js.map +1 -0
  112. package/package.json +6 -4
  113. package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts +0 -4
  114. package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts.map +0 -1
  115. package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js +0 -103
  116. package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js.map +0 -1
  117. package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.d.ts +0 -4
  118. package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.d.ts.map +0 -1
  119. package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.js +0 -8
  120. package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.js.map +0 -1
  121. package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppPackageFromInclude.d.ts.map +0 -1
  122. package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppPackageFromInclude.js.map +0 -1
  123. package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.d.ts +0 -4
  124. package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.d.ts.map +0 -1
  125. package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js +0 -105
  126. package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js.map +0 -1
  127. package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.d.ts +0 -4
  128. package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.d.ts.map +0 -1
  129. package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js +0 -8
  130. package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js.map +0 -1
  131. package/dist/features/dependency-analysis/adapters/outbound/delphi/extractDelphiPackageFromImport.d.ts.map +0 -1
  132. package/dist/features/dependency-analysis/adapters/outbound/delphi/extractDelphiPackageFromImport.js.map +0 -1
  133. package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.d.ts +0 -4
  134. package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.d.ts.map +0 -1
  135. package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js +0 -103
  136. package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js.map +0 -1
  137. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.d.ts +0 -7
  138. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.d.ts.map +0 -1
  139. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.js +0 -7
  140. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.js.map +0 -1
  141. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.d.ts +0 -3
  142. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.d.ts.map +0 -1
  143. package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.js.map +0 -1
  144. package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.d.ts +0 -4
  145. package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.d.ts.map +0 -1
  146. package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.js +0 -8
  147. package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.js.map +0 -1
  148. package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.d.ts +0 -4
  149. package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.d.ts.map +0 -1
  150. package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js +0 -103
  151. package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js.map +0 -1
  152. package/dist/features/dependency-analysis/adapters/outbound/kotlin/extractKotlinPackageFromImport.d.ts.map +0 -1
  153. package/dist/features/dependency-analysis/adapters/outbound/kotlin/extractKotlinPackageFromImport.js.map +0 -1
  154. package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.d.ts +0 -4
  155. package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.d.ts.map +0 -1
  156. package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js +0 -8
  157. package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js.map +0 -1
  158. package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.d.ts +0 -4
  159. package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.d.ts.map +0 -1
  160. package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js +0 -103
  161. package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js.map +0 -1
  162. package/dist/features/dependency-analysis/adapters/outbound/python/extractPythonPackageFromImport.d.ts.map +0 -1
  163. package/dist/features/dependency-analysis/adapters/outbound/python/extractPythonPackageFromImport.js.map +0 -1
  164. package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.d.ts +0 -4
  165. package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.d.ts.map +0 -1
  166. package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.js +0 -8
  167. package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.js.map +0 -1
  168. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts +0 -4
  169. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts.map +0 -1
  170. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js +0 -92
  171. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js.map +0 -1
  172. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts +0 -5
  173. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts.map +0 -1
  174. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js +0 -29
  175. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js.map +0 -1
  176. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts +0 -3
  177. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts.map +0 -1
  178. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js +0 -9
  179. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js.map +0 -1
  180. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts +0 -3
  181. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts.map +0 -1
  182. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js +0 -8
  183. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js.map +0 -1
  184. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts +0 -11
  185. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts.map +0 -1
  186. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js +0 -85
  187. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js.map +0 -1
  188. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts +0 -4
  189. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts.map +0 -1
  190. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js +0 -8
  191. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js.map +0 -1
  192. package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js.map +0 -1
  193. package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.d.ts.map +0 -1
  194. package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js +0 -111
  195. package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js.map +0 -1
  196. package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts +0 -4
  197. package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts.map +0 -1
  198. package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js +0 -36
  199. package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js.map +0 -1
  200. package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.d.ts +0 -3
  201. package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.d.ts.map +0 -1
  202. package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.js +0 -8
  203. package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.js.map +0 -1
  204. /package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.d.ts +0 -0
  205. /package/dist/features/dependency-analysis/{adapters/outbound/cpp → domain}/extractCppPackageFromInclude.d.ts +0 -0
  206. /package/dist/features/dependency-analysis/{adapters/outbound/cpp → domain}/extractCppPackageFromInclude.js +0 -0
  207. /package/dist/features/dependency-analysis/{adapters/outbound/delphi → domain}/extractDelphiPackageFromImport.d.ts +0 -0
  208. /package/dist/features/dependency-analysis/{adapters/outbound/delphi → domain}/extractDelphiPackageFromImport.js +0 -0
  209. /package/dist/features/dependency-analysis/{adapters/outbound/kotlin → domain}/extractKotlinPackageFromImport.d.ts +0 -0
  210. /package/dist/features/dependency-analysis/{adapters/outbound/kotlin → domain}/extractKotlinPackageFromImport.js +0 -0
  211. /package/dist/features/dependency-analysis/{adapters/outbound/python → domain}/extractPythonPackageFromImport.d.ts +0 -0
  212. /package/dist/features/dependency-analysis/{adapters/outbound/python → domain}/extractPythonPackageFromImport.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializeSourceGraph.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/serializeSourceGraph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAQjE,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAarE;AAED,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAWtE"}
@@ -0,0 +1,64 @@
1
+ import { isRecord } from '@ankhorage/utility/object';
2
+ /*** Intern repeated source strings while retaining a lossless JSON interchange format. */
3
+ export function serializeSourceGraph(sourceGraph) {
4
+ const strings = [];
5
+ const ids = new Map();
6
+ const data = transform(sourceGraph, (value) => {
7
+ let id = ids.get(value);
8
+ if (id === undefined) {
9
+ id = strings.length;
10
+ strings.push(value);
11
+ ids.set(value, id);
12
+ }
13
+ return `#${id}`;
14
+ });
15
+ return JSON.stringify({ version: 1, strings, data });
16
+ }
17
+ /*** Restore the complete factual graph before constructing any derived index. */
18
+ export function deserializeSourceGraph(serialized) {
19
+ const packed = JSON.parse(serialized);
20
+ if (!isPackedSourceGraph(packed))
21
+ throw new Error('Invalid source graph serialization.');
22
+ const data = transform(packed.data, (value) => {
23
+ if (!/^#\d+$/u.test(value))
24
+ throw new Error('Invalid source graph string reference.');
25
+ const restored = packed.strings[Number(value.slice(1))];
26
+ if (restored === undefined)
27
+ throw new Error('Unknown source graph string reference.');
28
+ return restored;
29
+ });
30
+ if (!isSourceGraph(data))
31
+ throw new Error('Invalid source graph payload.');
32
+ return data;
33
+ }
34
+ /*** Traverse plain JSON values and intern repeated keys as well as string values. */
35
+ function transform(value, mapString) {
36
+ if (typeof value === 'string')
37
+ return mapString(value);
38
+ if (Array.isArray(value))
39
+ return value.map((item) => transform(item, mapString));
40
+ if (isRecord(value)) {
41
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [mapString(key), transform(item, mapString)]));
42
+ }
43
+ return value;
44
+ }
45
+ /*** Validate the envelope before decoding dictionary references. */
46
+ function isPackedSourceGraph(value) {
47
+ if (!isRecord(value))
48
+ return false;
49
+ const { version, strings } = value;
50
+ return (version === 1 && Array.isArray(strings) && strings.every((item) => typeof item === 'string'));
51
+ }
52
+ /*** Check the portable graph envelope after restoration. */
53
+ function isSourceGraph(value) {
54
+ if (!isRecord(value))
55
+ return false;
56
+ const { version, graph, capabilities } = value;
57
+ if (!isRecord(graph))
58
+ return false;
59
+ return (version === 1 &&
60
+ Array.isArray(capabilities) &&
61
+ Array.isArray(graph.nodes) &&
62
+ Array.isArray(graph.edges));
63
+ }
64
+ //# sourceMappingURL=serializeSourceGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializeSourceGraph.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/serializeSourceGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAUrD,0FAA0F;AAC1F,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtC,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5C,IAAI,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,EAAE,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAA8B,CAAC,CAAC;AACnF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACvD,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzF,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,wCAA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IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAC7F,CAAC;AACJ,CAAC;AAED,4DAA4D;AAC5D,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC/C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,CACL,OAAO,KAAK,CAAC;QACb,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;QAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC1B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { isRecord } from '@ankhorage/utility/object';\n\nimport type { SourceGraph } from '../../../types/sourceGraph.js';\n\ninterface PackedSourceGraph {\n readonly version: 1;\n readonly strings: readonly string[];\n readonly data: unknown;\n}\n\n/*** Intern repeated source strings while retaining a lossless JSON interchange format. */\nexport function serializeSourceGraph(sourceGraph: SourceGraph): string {\n const strings: string[] = [];\n const ids = new Map<string, number>();\n const data = transform(sourceGraph, (value) => {\n let id = ids.get(value);\n if (id === undefined) {\n id = strings.length;\n strings.push(value);\n ids.set(value, id);\n }\n return `#${id}`;\n });\n return JSON.stringify({ version: 1, strings, data } satisfies PackedSourceGraph);\n}\n\n/*** Restore the complete factual graph before constructing any derived index. */\nexport function deserializeSourceGraph(serialized: string): SourceGraph {\n const packed: unknown = JSON.parse(serialized);\n if (!isPackedSourceGraph(packed)) throw new Error('Invalid source graph serialization.');\n const data = transform(packed.data, (value) => {\n if (!/^#\\d+$/u.test(value)) throw new Error('Invalid source graph string reference.');\n const restored = packed.strings[Number(value.slice(1))];\n if (restored === undefined) throw new Error('Unknown source graph string reference.');\n return restored;\n });\n if (!isSourceGraph(data)) throw new Error('Invalid source graph payload.');\n return data;\n}\n\n/*** Traverse plain JSON values and intern repeated keys as well as string values. */\nfunction transform(value: unknown, mapString: (value: string) => string): unknown {\n if (typeof value === 'string') return mapString(value);\n if (Array.isArray(value)) return value.map((item) => transform(item, mapString));\n if (isRecord(value)) {\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [mapString(key), transform(item, mapString)]),\n );\n }\n return value;\n}\n\n/*** Validate the envelope before decoding dictionary references. */\nfunction isPackedSourceGraph(value: unknown): value is PackedSourceGraph {\n if (!isRecord(value)) return false;\n const { version, strings } = value;\n return (\n version === 1 && Array.isArray(strings) && strings.every((item) => typeof item === 'string')\n );\n}\n\n/*** Check the portable graph envelope after restoration. */\nfunction isSourceGraph(value: unknown): value is SourceGraph {\n if (!isRecord(value)) return false;\n const { version, graph, capabilities } = value;\n if (!isRecord(graph)) return false;\n return (\n version === 1 &&\n Array.isArray(capabilities) &&\n Array.isArray(graph.nodes) &&\n Array.isArray(graph.edges)\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /*** Encode semantic identity components without ambiguity from punctuation in source names. */
2
+ export declare function sourceSemanticPath(...parts: readonly string[]): string;
3
+ //# sourceMappingURL=sourceSemanticPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceSemanticPath.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/sourceSemanticPath.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,GAAG,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEtE"}
@@ -0,0 +1,5 @@
1
+ /*** Encode semantic identity components without ambiguity from punctuation in source names. */
2
+ export function sourceSemanticPath(...parts) {
3
+ return parts.map(encodeURIComponent).join(':');
4
+ }
5
+ //# sourceMappingURL=sourceSemanticPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceSemanticPath.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/sourceSemanticPath.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,MAAM,UAAU,kBAAkB,CAAC,GAAG,KAAwB;IAC5D,OAAO,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/*** Encode semantic identity components without ambiguity from punctuation in source names. */\nexport function sourceSemanticPath(...parts: readonly string[]): string {\n return parts.map(encodeURIComponent).join(':');\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { SourceGraph, SourceGraphIndex, SourceNodeSummary } from '../../../types/sourceGraph.js';
2
+ /*** Recompute one container summary from canonical containment and observed relations. */
3
+ export declare function summarizeSourceNode(sourceGraph: SourceGraph, index: SourceGraphIndex, semanticPath: string): SourceNodeSummary | undefined;
4
+ //# sourceMappingURL=summarizeSourceNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeSourceNode.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/summarizeSourceNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAEhB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAEvC,0FAA0F;AAC1F,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,gBAAgB,EACvB,YAAY,EAAE,MAAM,GACnB,iBAAiB,GAAG,SAAS,CAwC/B"}
@@ -0,0 +1,66 @@
1
+ /*** Recompute one container summary from canonical containment and observed relations. */
2
+ export function summarizeSourceNode(sourceGraph, index, semanticPath) {
3
+ const root = index.nodeBySemanticPath.get(semanticPath);
4
+ if (root === undefined)
5
+ return undefined;
6
+ const nodesById = new Map(sourceGraph.graph.nodes.map((node) => [node.id, node]));
7
+ const descendantCounts = new Map();
8
+ const dependencies = { intrinsic: 0, vendor: 0, unknown: 0 };
9
+ const exports = { runtime: 0, typeOnly: 0 };
10
+ let incomingRelations = 0;
11
+ let outgoingRelations = 0;
12
+ for (const node of sourceGraph.graph.nodes) {
13
+ if (node.id === root.id || !isDescendant(node.id, root.id, index))
14
+ continue;
15
+ descendantCounts.set(node.data.kind, (descendantCounts.get(node.data.kind) ?? 0) + 1);
16
+ }
17
+ for (const edge of sourceGraph.graph.edges) {
18
+ if (containsNode(edge.source, root.id, index)) {
19
+ outgoingRelations += 1;
20
+ if (edge.data.kind === 'imports') {
21
+ countDependency(dependencies, nodesById.get(edge.target)?.data.classification);
22
+ }
23
+ if (edge.data.kind === 'exports') {
24
+ if (nodesById.get(edge.target)?.data.typeOnly === true)
25
+ exports.typeOnly += 1;
26
+ else
27
+ exports.runtime += 1;
28
+ }
29
+ }
30
+ if (containsNode(edge.target, root.id, index))
31
+ incomingRelations += 1;
32
+ }
33
+ const descendants = Object.fromEntries(descendantCounts);
34
+ return {
35
+ nodeId: root.id,
36
+ descendants,
37
+ exports,
38
+ incomingRelations,
39
+ outgoingRelations,
40
+ dependencies,
41
+ };
42
+ }
43
+ /*** Include a container itself as well as its descendants. */
44
+ function containsNode(nodeId, rootId, index) {
45
+ return nodeId === rootId || isDescendant(nodeId, rootId, index);
46
+ }
47
+ /*** Count a factual import target using its known classification. */
48
+ function countDependency(counts, classification) {
49
+ if (classification === 'intrinsic')
50
+ counts.intrinsic += 1;
51
+ else if (classification === 'vendor')
52
+ counts.vendor += 1;
53
+ else
54
+ counts.unknown += 1;
55
+ }
56
+ /*** Follow indexed parents rather than rescanning containment edges. */
57
+ function isDescendant(nodeId, ancestorId, index) {
58
+ let current = index.parentByNodeId.get(nodeId);
59
+ while (current !== undefined) {
60
+ if (current === ancestorId)
61
+ return true;
62
+ current = index.parentByNodeId.get(current);
63
+ }
64
+ return false;
65
+ }
66
+ //# sourceMappingURL=summarizeSourceNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizeSourceNode.js","sourceRo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QAAE,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC;SACrD,IAAI,cAAc,KAAK,QAAQ;QAAE,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;;QACpD,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,wEAAwE;AACxE,SAAS,YAAY,CAAC,MAAc,EAAE,UAAkB,EAAE,KAAuB;IAC/E,IAAI,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,OAAO,KAAK,UAAU;YAAE,OAAO,IAAI,CAAC;QACxC,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type {\n SourceGraph,\n SourceGraphIndex,\n SourceNodeKind,\n SourceNodeSummary,\n} from '../../../types/sourceGraph.js';\n\n/*** Recompute one container summary from canonical containment and observed relations. */\nexport function summarizeSourceNode(\n sourceGraph: SourceGraph,\n index: SourceGraphIndex,\n semanticPath: string,\n): SourceNodeSummary | undefined {\n const root = index.nodeBySemanticPath.get(semanticPath);\n if (root === undefined) return undefined;\n const nodesById = new Map(sourceGraph.graph.nodes.map((node) => [node.id, node]));\n const descendantCounts = new Map<SourceNodeKind, number>();\n const dependencies = { intrinsic: 0, vendor: 0, unknown: 0 };\n const exports = { runtime: 0, typeOnly: 0 };\n let incomingRelations = 0;\n let outgoingRelations = 0;\n\n for (const node of sourceGraph.graph.nodes) {\n if (node.id === root.id || !isDescendant(node.id, root.id, index)) continue;\n descendantCounts.set(node.data.kind, (descendantCounts.get(node.data.kind) ?? 0) + 1);\n }\n\n for (const edge of sourceGraph.graph.edges) {\n if (containsNode(edge.source, root.id, index)) {\n outgoingRelations += 1;\n if (edge.data.kind === 'imports') {\n countDependency(dependencies, nodesById.get(edge.target)?.data.classification);\n }\n if (edge.data.kind === 'exports') {\n if (nodesById.get(edge.target)?.data.typeOnly === true) exports.typeOnly += 1;\n else exports.runtime += 1;\n }\n }\n if (containsNode(edge.target, root.id, index)) incomingRelations += 1;\n }\n\n const descendants = Object.fromEntries(descendantCounts) as Partial<\n Record<SourceNodeKind, number>\n >;\n return {\n nodeId: root.id,\n descendants,\n exports,\n incomingRelations,\n outgoingRelations,\n dependencies,\n };\n}\n\n/*** Include a container itself as well as its descendants. */\nfunction containsNode(nodeId: number, rootId: number, index: SourceGraphIndex): boolean {\n return nodeId === rootId || isDescendant(nodeId, rootId, index);\n}\n\n/*** Count a factual import target using its known classification. */\nfunction countDependency(\n counts: { intrinsic: number; vendor: number; unknown: number },\n classification: 'intrinsic' | 'vendor' | 'unknown' | undefined,\n): void {\n if (classification === 'intrinsic') counts.intrinsic += 1;\n else if (classification === 'vendor') counts.vendor += 1;\n else counts.unknown += 1;\n}\n\n/*** Follow indexed parents rather than rescanning containment edges. */\nfunction isDescendant(nodeId: number, ancestorId: number, index: SourceGraphIndex): boolean {\n let current = index.parentByNodeId.get(nodeId);\n while (current !== undefined) {\n if (current === ancestorId) return true;\n current = index.parentByNodeId.get(current);\n }\n return false;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';
2
- import type { ProjectDetection, ProjectInspection } from '@ankhorage/project-detector/types';
1
+ import type { Graph } from '@ankhorage/graph';
2
+ import type { ProjectInspection } from '@ankhorage/project-detector/types';
3
3
  export type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';
4
4
  export type DependencyReferenceClassification = DependencyNodeClassification | 'focus';
5
5
  export type DependencyNodeKind = 'module' | 'package';
@@ -43,36 +43,15 @@ export interface DependencyGraphPackage {
43
43
  readonly id: string;
44
44
  readonly nodeId: string;
45
45
  readonly projectId: string;
46
- readonly rootPath: string;
47
46
  readonly relativeRoot: string;
48
47
  readonly name?: string;
49
- readonly detection: ProjectDetection;
50
- readonly declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>;
51
- }
52
- export interface DependencyGraphFragment {
53
- readonly nodes: readonly GraphNode<DependencyGraphNodeData>[];
54
- readonly edges: readonly GraphEdge<DependencyGraphEdgeData>[];
55
- }
56
- export interface DependencyGraphAnalyzerContext {
57
- readonly package: DependencyGraphPackage;
58
- readonly inspection: ProjectInspection;
59
- readonly focusPackages: ReadonlyMap<string, string>;
60
- readonly excludedRoots: readonly string[];
61
- readonly signal?: AbortSignal;
62
- }
63
- export interface DependencyGraphAnalyzer {
64
- readonly id: string;
65
- readonly supports: (detection: ProjectDetection) => boolean;
66
- readonly analyzeAsync: (context: DependencyGraphAnalyzerContext) => Promise<DependencyGraphFragment>;
67
48
  }
68
49
  export interface CreateDependencyGraphInput {
69
50
  readonly projects: readonly DependencyGraphProjectInput[];
70
- readonly analyzers?: readonly DependencyGraphAnalyzer[];
71
51
  readonly signal?: AbortSignal;
72
52
  }
73
53
  export interface CreateDependencyGraphFromInspectionsInput {
74
54
  readonly projects: readonly DependencyGraphInspectionProjectInput[];
75
- readonly analyzers?: readonly DependencyGraphAnalyzer[];
76
55
  readonly signal?: AbortSignal;
77
56
  }
78
57
  //# sourceMappingURL=dependencyGraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC9E,MAAM,MAAM,iCAAiC,GAAG,4BAA4B,GAAG,OAAO,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,CAAC;AACtD,MAAM,MAAM,yBA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AAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,yCAAyC;IACxD,QAAQ,CAAC,QAAQ,EAAE,SAAS,qCAAqC,EAAE,CAAC;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"","sourcesContent":["import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectDetection, ProjectInspection } from '@ankhorage/project-detector/types';\n\nexport type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';\nexport type DependencyReferenceClassification = DependencyNodeClassification | 'focus';\nexport type DependencyNodeKind = 'module' | 'package';\nexport type DependencyDeclarationKind =\n 'dependency' | 'devDependency' | 'optionalDependency' | 'peerDependency';\n\nexport interface DependencyDeclaration {\n readonly kind: DependencyDeclarationKind;\n readonly range: string;\n}\n\nexport interface DependencyImportEvidence {\n readonly sourceFile: string;\n readonly specifier: string;\n readonly classification: DependencyReferenceClassification;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\nexport interface DependencyGraphNodeData {\n readonly kind: DependencyNodeKind;\n readonly classification: DependencyNodeClassification;\n readonly focus: boolean;\n readonly label: string;\n readonly projectId?: string;\n readonly packageName?: string;\n readonly path?: string;\n readonly parentPath?: string;\n}\n\nexport interface DependencyGraphEdgeData {\n readonly kind: 'import';\n readonly analyzerId: string;\n readonly weight: number;\n readonly evidence: readonly DependencyImportEvidence[];\n}\n\nexport type DependencyGraph = Graph<DependencyGraphNodeData, DependencyGraphEdgeData>;\n\nexport interface DependencyGraphProjectInput {\n readonly id: string;\n readonly rootPath: string;\n}\n\nexport interface DependencyGraphInspectionProjectInput {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\nexport interface DependencyGraphPackage {\n readonly id: string;\n readonly nodeId: string;\n readonly projectId: string;\n readonly rootPath: string;\n readonly relativeRoot: string;\n readonly name?: string;\n readonly detection: ProjectDetection;\n readonly declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface DependencyGraphFragment {\n readonly nodes: readonly GraphNode<DependencyGraphNodeData>[];\n readonly edges: readonly GraphEdge<DependencyGraphEdgeData>[];\n}\n\nexport interface DependencyGraphAnalyzerContext {\n readonly package: DependencyGraphPackage;\n readonly inspection: ProjectInspection;\n readonly focusPackages: ReadonlyMap<string, string>;\n readonly excludedRoots: readonly string[];\n readonly signal?: AbortSignal;\n}\n\nexport interface DependencyGraphAnalyzer {\n readonly id: string;\n readonly supports: (detection: ProjectDetection) => boolean;\n readonly analyzeAsync: (\n context: DependencyGraphAnalyzerContext,\n ) => Promise<DependencyGraphFragment>;\n}\n\nexport interface CreateDependencyGraphInput {\n readonly projects: readonly DependencyGraphProjectInput[];\n readonly analyzers?: readonly DependencyGraphAnalyzer[];\n readonly signal?: AbortSignal;\n}\n\nexport interface CreateDependencyGraphFromInspectionsInput {\n readonly projects: readonly DependencyGraphInspectionProjectInput[];\n readonly analyzers?: readonly DependencyGraphAnalyzer[];\n readonly signal?: AbortSignal;\n}\n"]}
1
+ {"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"","sourcesContent":["import type { Graph } from '@ankhorage/graph';\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nexport type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';\nexport type DependencyReferenceClassification = DependencyNodeClassification | 'focus';\nexport type DependencyNodeKind = 'module' | 'package';\nexport type DependencyDeclarationKind =\n 'dependency' | 'devDependency' | 'optionalDependency' | 'peerDependency';\n\nexport interface DependencyDeclaration {\n readonly kind: DependencyDeclarationKind;\n readonly range: string;\n}\n\nexport interface DependencyImportEvidence {\n readonly sourceFile: string;\n readonly specifier: string;\n readonly classification: DependencyReferenceClassification;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\nexport interface DependencyGraphNodeData {\n readonly kind: DependencyNodeKind;\n readonly classification: DependencyNodeClassification;\n readonly focus: boolean;\n readonly label: string;\n readonly projectId?: string;\n readonly packageName?: string;\n readonly path?: string;\n readonly parentPath?: string;\n}\n\nexport interface DependencyGraphEdgeData {\n readonly kind: 'import';\n readonly analyzerId: string;\n readonly weight: number;\n readonly evidence: readonly DependencyImportEvidence[];\n}\n\nexport type DependencyGraph = Graph<DependencyGraphNodeData, DependencyGraphEdgeData>;\n\nexport interface DependencyGraphProjectInput {\n readonly id: string;\n readonly rootPath: string;\n}\n\nexport interface DependencyGraphInspectionProjectInput {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\nexport interface DependencyGraphPackage {\n readonly id: string;\n readonly nodeId: string;\n readonly projectId: string;\n readonly relativeRoot: string;\n readonly name?: string;\n}\n\nexport interface CreateDependencyGraphInput {\n readonly projects: readonly DependencyGraphProjectInput[];\n readonly signal?: AbortSignal;\n}\n\nexport interface CreateDependencyGraphFromInspectionsInput {\n readonly projects: readonly DependencyGraphInspectionProjectInput[];\n readonly signal?: AbortSignal;\n}\n"]}
@@ -0,0 +1,173 @@
1
+ /*** A portable one-based source span emitted by a language analyzer. */
2
+ export interface SourceLocation {
3
+ readonly column: number;
4
+ readonly endColumn: number;
5
+ readonly endLine: number;
6
+ readonly line: number;
7
+ }
8
+ /*** Analyzer-observed source documentation, distinct from consumer interpretation. */
9
+ export interface SourceDocumentation {
10
+ readonly text: string;
11
+ readonly tags: Readonly<Record<string, readonly string[]>>;
12
+ }
13
+ type SourceDeclarationKind = 'class' | 'constant' | 'enum' | 'function' | 'interface' | 'method' | 'type' | 'variable';
14
+ export type SourceVisibility = 'package' | 'private' | 'protected' | 'public';
15
+ /*** A source declaration before graph-wide identity and relationship resolution. */
16
+ export interface SourceDeclarationFact {
17
+ readonly children: readonly SourceDeclarationFact[];
18
+ readonly documentation?: SourceDocumentation;
19
+ readonly exported?: boolean;
20
+ readonly typeOnly?: boolean;
21
+ readonly extends: readonly string[];
22
+ readonly implements: readonly string[];
23
+ readonly kind: SourceDeclarationKind;
24
+ readonly location: SourceLocation;
25
+ readonly modifiers: readonly string[];
26
+ readonly name: string;
27
+ readonly signature?: string;
28
+ readonly visibility: SourceVisibility;
29
+ }
30
+ /*** An import observed at an exact source position. */
31
+ export interface SourceImportFact {
32
+ readonly kind?: 'import' | 'reexport';
33
+ readonly local?: boolean;
34
+ readonly location?: SourceLocation;
35
+ readonly specifier: string;
36
+ readonly typeOnly?: boolean;
37
+ }
38
+ /*** Portable facts extracted from one source file by its language analyzer. */
39
+ export interface SourceFileFacts {
40
+ readonly declarations: readonly SourceDeclarationFact[];
41
+ readonly imports: readonly SourceImportFact[];
42
+ readonly packageName?: string;
43
+ }
44
+ /*** Analyzer capabilities whose absence must not be interpreted as a negative fact. */
45
+ export type SourceCapability = 'calls' | 'containment' | 'declarations' | 'documentation' | 'exports' | 'extends' | 'implements' | 'imports' | 'signatures' | 'source-locations' | 'visibility';
46
+ export interface SourceCapabilityReport {
47
+ readonly analyzerId: string;
48
+ readonly available: readonly SourceCapability[];
49
+ readonly projectId: string;
50
+ }
51
+ export type SourceNodeKind = 'project' | 'package' | 'directory' | 'file' | SourceDeclarationKind;
52
+ export type SourceRelationKind = 'contains' | 'declares-in' | 'exports' | 'extends' | 'implements' | 'imports';
53
+ /*** Factual node data with a stable semantic key independent from its dense local ID. */
54
+ export interface SourceNodeData {
55
+ readonly analyzerId?: string;
56
+ readonly kind: SourceNodeKind;
57
+ readonly semanticPath: string;
58
+ readonly name: string;
59
+ readonly projectId: string;
60
+ readonly filePath?: string;
61
+ readonly path?: string;
62
+ readonly packageName?: string;
63
+ readonly classification?: 'intrinsic' | 'unknown' | 'vendor';
64
+ readonly location?: SourceLocation;
65
+ readonly visibility?: SourceVisibility;
66
+ readonly modifiers?: readonly string[];
67
+ readonly signature?: string;
68
+ readonly documentation?: SourceDocumentation;
69
+ readonly typeOnly?: boolean;
70
+ }
71
+ /*** Evidence for one observed relationship, including analyzer provenance. */
72
+ export interface SourceRelationEvidence {
73
+ readonly analyzerId: string;
74
+ readonly sourcePath: string;
75
+ readonly location?: SourceLocation;
76
+ readonly specifier?: string;
77
+ readonly typeOnly?: boolean;
78
+ readonly declarations?: readonly DependencyDeclaration[];
79
+ }
80
+ export interface SourceEdgeData {
81
+ readonly kind: SourceRelationKind;
82
+ readonly evidence: readonly SourceRelationEvidence[];
83
+ }
84
+ /*** Compact serializable source graph; its indexes and rollups are derived separately. */
85
+ export interface SourceGraph {
86
+ readonly version: 1;
87
+ readonly graph: Graph<SourceNodeData, SourceEdgeData, number, number>;
88
+ readonly capabilities: readonly SourceCapabilityReport[];
89
+ }
90
+ export interface SourceNodeDraft {
91
+ readonly data: SourceNodeData;
92
+ }
93
+ export interface SourceEdgeDraft {
94
+ readonly source: string;
95
+ readonly target: string;
96
+ readonly data: SourceEdgeData;
97
+ }
98
+ export interface SourceGraphDraft {
99
+ readonly nodes: readonly SourceNodeDraft[];
100
+ readonly edges: readonly SourceEdgeDraft[];
101
+ readonly capabilities: readonly SourceCapabilityReport[];
102
+ }
103
+ /*** Parsed source fact associated with a project-relative path. */
104
+ export interface SourceAnalyzedFile {
105
+ readonly analyzerId: string;
106
+ readonly facts: SourceFileFacts;
107
+ readonly path: string;
108
+ readonly projectId: string;
109
+ readonly declaredDependencies?: Readonly<Record<string, readonly DependencyDeclaration[]>>;
110
+ }
111
+ export interface SourceInspectionProjectInput {
112
+ readonly id: string;
113
+ readonly inspection: ProjectInspection;
114
+ }
115
+ export interface CreateSourceGraphFromInspectionsInput {
116
+ readonly projects: readonly SourceInspectionProjectInput[];
117
+ readonly signal?: AbortSignal;
118
+ }
119
+ export interface CreateSourceGraphInput {
120
+ readonly projects: readonly {
121
+ readonly id: string;
122
+ readonly rootPath: string;
123
+ }[];
124
+ readonly signal?: AbortSignal;
125
+ }
126
+ /*** Indexed semantic access built from a serializable source graph snapshot. */
127
+ export interface SourceGraphIndex {
128
+ readonly nodeById: ReadonlyMap<number, GraphNode<SourceNodeData, number>>;
129
+ readonly nodeBySemanticPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;
130
+ readonly fileByPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;
131
+ readonly symbolsByFileAndName: ReadonlyMap<string, readonly GraphNode<SourceNodeData, number>[]>;
132
+ readonly incomingByNodeId: ReadonlyMap<number, readonly GraphEdge<SourceEdgeData, number, number>[]>;
133
+ readonly outgoingByNodeId: ReadonlyMap<number, readonly GraphEdge<SourceEdgeData, number, number>[]>;
134
+ readonly parentByNodeId: ReadonlyMap<number, number>;
135
+ }
136
+ /*** Semantic relation view with source evidence and no required ID lookup. */
137
+ export interface SourceRelationView {
138
+ readonly edgeId: number;
139
+ readonly kind: SourceRelationKind;
140
+ readonly source: SourceNodeData;
141
+ readonly target: SourceNodeData;
142
+ readonly evidence: readonly SourceRelationEvidence[];
143
+ }
144
+ /*** Pairwise projected dependency with references to canonical observed edges. */
145
+ export interface SourceRollupEdge {
146
+ readonly source: number;
147
+ readonly target: number;
148
+ readonly sourceSemanticPath: string;
149
+ readonly targetSemanticPath: string;
150
+ readonly weight: number;
151
+ readonly evidenceEdgeIds: readonly number[];
152
+ }
153
+ /*** Cached semantic queries for one deterministic projection level. */
154
+ export interface SourceRollupIndex {
155
+ readonly byPair: ReadonlyMap<string, SourceRollupEdge>;
156
+ readonly outgoingBySource: ReadonlyMap<string, readonly SourceRollupEdge[]>;
157
+ }
158
+ export interface SourceNodeSummary {
159
+ readonly nodeId: number;
160
+ readonly descendants: Readonly<Partial<Record<SourceNodeKind, number>>>;
161
+ readonly exports: Readonly<{
162
+ readonly runtime: number;
163
+ readonly typeOnly: number;
164
+ }>;
165
+ readonly incomingRelations: number;
166
+ readonly outgoingRelations: number;
167
+ readonly dependencies: Readonly<Record<'intrinsic' | 'unknown' | 'vendor', number>>;
168
+ }
169
+ import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';
170
+ import type { ProjectInspection } from '@ankhorage/project-detector/types';
171
+ import type { DependencyDeclaration } from './dependencyGraph.js';
172
+ export {};
173
+ //# sourceMappingURL=sourceGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceGraph.d.ts","sourceRoot":"","sources":["../../src/types/sourceGraph.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,sFAAsF;AACtF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CAC5D;AAED,KAAK,qBAAqB,GACxB,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5F,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE9E,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B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OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,GAAG,SAAS,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;CACrF;AACD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sourceGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceGraph.js","sourceRoot":"","sources":["../../src/types/sourceGraph.ts"],"names":[],"mappings":"","sourcesContent":["/*** A portable one-based source span emitted by a language analyzer. */\nexport interface SourceLocation {\n readonly column: number;\n readonly endColumn: number;\n readonly endLine: number;\n readonly line: number;\n}\n\n/*** Analyzer-observed source documentation, distinct from consumer interpretation. */\nexport interface SourceDocumentation {\n readonly text: string;\n readonly tags: Readonly<Record<string, readonly string[]>>;\n}\n\ntype SourceDeclarationKind =\n 'class' | 'constant' | 'enum' | 'function' | 'interface' | 'method' | 'type' | 'variable';\n\nexport type SourceVisibility = 'package' | 'private' | 'protected' | 'public';\n\n/*** A source declaration before graph-wide identity and relationship resolution. */\nexport interface SourceDeclarationFact {\n readonly children: readonly SourceDeclarationFact[];\n readonly documentation?: SourceDocumentation;\n readonly exported?: boolean;\n readonly typeOnly?: boolean;\n readonly extends: readonly string[];\n readonly implements: readonly string[];\n readonly kind: SourceDeclarationKind;\n readonly location: SourceLocation;\n readonly modifiers: readonly string[];\n readonly name: string;\n readonly signature?: string;\n readonly visibility: SourceVisibility;\n}\n\n/*** An import observed at an exact source position. */\nexport interface SourceImportFact {\n readonly kind?: 'import' | 'reexport';\n readonly local?: boolean;\n readonly location?: SourceLocation;\n readonly specifier: string;\n readonly typeOnly?: boolean;\n}\n\n/*** Portable facts extracted from one source file by its language analyzer. */\nexport interface SourceFileFacts {\n readonly declarations: readonly SourceDeclarationFact[];\n readonly imports: readonly SourceImportFact[];\n readonly packageName?: string;\n}\n\n/*** Analyzer capabilities whose absence must not be interpreted as a negative fact. */\nexport type SourceCapability =\n | 'calls'\n | 'containment'\n | 'declarations'\n | 'documentation'\n | 'exports'\n | 'extends'\n | 'implements'\n | 'imports'\n | 'signatures'\n | 'source-locations'\n | 'visibility';\n\nexport interface SourceCapabilityReport {\n readonly analyzerId: string;\n readonly available: readonly SourceCapability[];\n readonly projectId: string;\n}\n\nexport type SourceNodeKind = 'project' | 'package' | 'directory' | 'file' | SourceDeclarationKind;\nexport type SourceRelationKind =\n 'contains' | 'declares-in' | 'exports' | 'extends' | 'implements' | 'imports';\n\n/*** Factual node data with a stable semantic key independent from its dense local ID. */\nexport interface SourceNodeData {\n readonly analyzerId?: string;\n readonly kind: SourceNodeKind;\n readonly semanticPath: string;\n readonly name: string;\n readonly projectId: string;\n readonly filePath?: string;\n readonly path?: string;\n readonly packageName?: string;\n readonly classification?: 'intrinsic' | 'unknown' | 'vendor';\n readonly location?: SourceLocation;\n readonly visibility?: SourceVisibility;\n readonly modifiers?: readonly string[];\n readonly signature?: string;\n readonly documentation?: SourceDocumentation;\n readonly typeOnly?: boolean;\n}\n\n/*** Evidence for one observed relationship, including analyzer provenance. */\nexport interface SourceRelationEvidence {\n readonly analyzerId: string;\n readonly sourcePath: string;\n readonly location?: SourceLocation;\n readonly specifier?: string;\n readonly typeOnly?: boolean;\n readonly declarations?: readonly DependencyDeclaration[];\n}\n\nexport interface SourceEdgeData {\n readonly kind: SourceRelationKind;\n readonly evidence: readonly SourceRelationEvidence[];\n}\n\n/*** Compact serializable source graph; its indexes and rollups are derived separately. */\nexport interface SourceGraph {\n readonly version: 1;\n readonly graph: Graph<SourceNodeData, SourceEdgeData, number, number>;\n readonly capabilities: readonly SourceCapabilityReport[];\n}\n\nexport interface SourceNodeDraft {\n readonly data: SourceNodeData;\n}\n\nexport interface SourceEdgeDraft {\n readonly source: string;\n readonly target: string;\n readonly data: SourceEdgeData;\n}\n\nexport interface SourceGraphDraft {\n readonly nodes: readonly SourceNodeDraft[];\n readonly edges: readonly SourceEdgeDraft[];\n readonly capabilities: readonly SourceCapabilityReport[];\n}\n\n/*** Parsed source fact associated with a project-relative path. */\nexport interface SourceAnalyzedFile {\n readonly analyzerId: string;\n readonly facts: SourceFileFacts;\n readonly path: string;\n readonly projectId: string;\n readonly declaredDependencies?: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface SourceInspectionProjectInput {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\nexport interface CreateSourceGraphFromInspectionsInput {\n readonly projects: readonly SourceInspectionProjectInput[];\n readonly signal?: AbortSignal;\n}\n\nexport interface CreateSourceGraphInput {\n readonly projects: readonly { readonly id: string; readonly rootPath: string }[];\n readonly signal?: AbortSignal;\n}\n\n/*** Indexed semantic access built from a serializable source graph snapshot. */\nexport interface SourceGraphIndex {\n readonly nodeById: ReadonlyMap<number, GraphNode<SourceNodeData, number>>;\n readonly nodeBySemanticPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;\n readonly fileByPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;\n readonly symbolsByFileAndName: ReadonlyMap<string, readonly GraphNode<SourceNodeData, number>[]>;\n readonly incomingByNodeId: ReadonlyMap<\n number,\n readonly GraphEdge<SourceEdgeData, number, number>[]\n >;\n readonly outgoingByNodeId: ReadonlyMap<\n number,\n readonly GraphEdge<SourceEdgeData, number, number>[]\n >;\n readonly parentByNodeId: ReadonlyMap<number, number>;\n}\n\n/*** Semantic relation view with source evidence and no required ID lookup. */\nexport interface SourceRelationView {\n readonly edgeId: number;\n readonly kind: SourceRelationKind;\n readonly source: SourceNodeData;\n readonly target: SourceNodeData;\n readonly evidence: readonly SourceRelationEvidence[];\n}\n\n/*** Pairwise projected dependency with references to canonical observed edges. */\nexport interface SourceRollupEdge {\n readonly source: number;\n readonly target: number;\n readonly sourceSemanticPath: string;\n readonly targetSemanticPath: string;\n readonly weight: number;\n readonly evidenceEdgeIds: readonly number[];\n}\n\n/*** Cached semantic queries for one deterministic projection level. */\nexport interface SourceRollupIndex {\n readonly byPair: ReadonlyMap<string, SourceRollupEdge>;\n readonly outgoingBySource: ReadonlyMap<string, readonly SourceRollupEdge[]>;\n}\n\nexport interface SourceNodeSummary {\n readonly nodeId: number;\n readonly descendants: Readonly<Partial<Record<SourceNodeKind, number>>>;\n readonly exports: Readonly<{ readonly runtime: number; readonly typeOnly: number }>;\n readonly incomingRelations: number;\n readonly outgoingRelations: number;\n readonly dependencies: Readonly<Record<'intrinsic' | 'unknown' | 'vendor', number>>;\n}\nimport type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type { DependencyDeclaration } from './dependencyGraph.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankhorage/dependency-graph",
3
- "version": "0.7.2",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "description": "Project-aware dependency analysis that produces canonical Ankhorage graphs.",
6
6
  "license": "MIT",
@@ -41,6 +41,7 @@
41
41
  "node": ">=24"
42
42
  },
43
43
  "scripts": {
44
+ "bench:source-graph": "bun benchmarks/sourceGraph.ts",
44
45
  "build": "rm -rf dist tsconfig.tsbuildinfo && bun x tsc -p tsconfig.build.json",
45
46
  "changeset": "ankhorage-changeset",
46
47
  "changeset:status": "ankhorage-changeset status --since=origin/main",
@@ -56,9 +57,10 @@
56
57
  "knip:check": "ankhorage-knip"
57
58
  },
58
59
  "dependencies": {
59
- "@ankhorage/graph": "^0.1.0",
60
+ "@ankhorage/graph": "^0.3.0",
60
61
  "@ankhorage/project-detector": "^0.3.0",
61
- "@ankhorage/utility": "^0.8.0"
62
+ "@ankhorage/utility": "^0.8.0",
63
+ "java-parser": "^3.0.1"
62
64
  },
63
65
  "peerDependencies": {
64
66
  "typescript": "~6.0.3"
@@ -66,7 +68,7 @@
66
68
  "devDependencies": {
67
69
  "@ankhorage/devtools": "^1.14.7",
68
70
  "@ankhorage/paradox": "^0.1.26",
69
- "@types/bun": "^1.4.1",
71
+ "@types/bun": "^1.4.2",
70
72
  "@types/node": "^26.5.1",
71
73
  "typescript": "~6.0.3"
72
74
  },
@@ -1,4 +0,0 @@
1
- import type { DependencyGraphAnalyzerContext, DependencyGraphFragment } from '../../../../../types/dependencyGraph.js';
2
- /*** Analyze one detected C++ package into namespace/include dependency evidence. */
3
- export declare function analyzeCppProjectAsync(context: DependencyGraphAnalyzerContext): Promise<DependencyGraphFragment>;
4
- //# sourceMappingURL=analyzeCppProjectAsync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzeCppProjectAsync.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,8BAA8B,EAE9B,uBAAuB,EAGxB,MAAM,yCAAyC,CAAC;AAMjD,oFAAoF;AACpF,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,uBAAuB,CAAC,CAgClC"}
@@ -1,103 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { toPortablePath } from '@ankhorage/utility/node/path';
4
- import { collectInspectedSourceFiles } from '../../../utils/collectInspectedSourceFiles.js';
5
- import { extractCppDependencies } from './extractCppDependencies.js';
6
- import { extractCppPackageFromInclude } from './extractCppPackageFromInclude.js';
7
- /*** Analyze one detected C++ package into namespace/include dependency evidence. */
8
- export async function analyzeCppProjectAsync(context) {
9
- const language = context.package.detection.languages.find(({ id }) => id === 'cpp');
10
- const files = collectInspectedSourceFiles(context, language?.sourceRoots ?? ['src', '.'], (file) => ['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)), ['.git', 'build', 'coverage', 'dist', 'out']);
11
- const sources = await Promise.all(files.map(async (file) => ({
12
- file,
13
- dependencies: extractCppDependencies(await readFile(file, 'utf8')),
14
- })));
15
- const intrinsicNamespaces = new Set(sources
16
- .map(({ dependencies }) => dependencies.namespace)
17
- .filter((namespace) => namespace !== ''));
18
- const nodes = new Map();
19
- for (const namespace of intrinsicNamespaces)
20
- addIntrinsicHierarchy(context, namespace, nodes);
21
- const edges = new Map();
22
- for (const { file, dependencies } of sources) {
23
- context.signal?.throwIfAborted();
24
- const sourceNodeId = nodeIdForNamespace(context, dependencies.namespace);
25
- for (const include of dependencies.includes) {
26
- addInclude(context, file, sourceNodeId, include, nodes, edges);
27
- }
28
- }
29
- return { nodes: [...nodes.values()], edges: [...edges.values()] };
30
- }
31
- /*** Aggregate one C++ include into stable target nodes and weighted evidence. */
32
- function addInclude(context, sourceFile, sourceNodeId, include, nodes, edges) {
33
- const targetPackage = extractCppPackageFromInclude(include.specifier);
34
- if (targetPackage === '')
35
- return;
36
- const targetNodeId = include.local
37
- ? nodeIdForNamespace(context, targetPackage)
38
- : `unknown:${targetPackage}`;
39
- if (targetNodeId === sourceNodeId)
40
- return;
41
- if (include.local) {
42
- addIntrinsicHierarchy(context, targetPackage, nodes);
43
- }
44
- else if (!nodes.has(targetNodeId)) {
45
- nodes.set(targetNodeId, {
46
- id: targetNodeId,
47
- data: {
48
- kind: 'package',
49
- classification: 'unknown',
50
- focus: false,
51
- label: targetPackage,
52
- packageName: targetPackage,
53
- },
54
- });
55
- }
56
- const edgeId = `${sourceNodeId}->${targetNodeId}`;
57
- const existing = edges.get(edgeId);
58
- const evidence = {
59
- sourceFile: toPortablePath(path.relative(context.package.rootPath, sourceFile)),
60
- specifier: include.specifier,
61
- classification: include.local ? 'intrinsic' : 'unknown',
62
- declarations: [],
63
- };
64
- edges.set(edgeId, {
65
- id: edgeId,
66
- source: sourceNodeId,
67
- target: targetNodeId,
68
- data: {
69
- kind: 'import',
70
- analyzerId: 'cpp',
71
- weight: (existing?.data.weight ?? 0) + 1,
72
- evidence: [...(existing?.data.evidence ?? []), evidence],
73
- },
74
- });
75
- }
76
- /*** Materialize a C++ namespace/package and all ancestor nodes. */
77
- function addIntrinsicHierarchy(context, namespace, nodes) {
78
- const segments = namespace.split('.');
79
- segments.forEach((_, index) => {
80
- const current = segments.slice(0, index + 1).join('.');
81
- const id = nodeIdForNamespace(context, current);
82
- if (nodes.has(id))
83
- return;
84
- nodes.set(id, {
85
- id,
86
- data: {
87
- kind: 'module',
88
- classification: 'intrinsic',
89
- focus: true,
90
- label: current.split('.').at(-1) ?? current,
91
- projectId: context.package.projectId,
92
- ...(context.package.name === undefined ? {} : { packageName: context.package.name }),
93
- path: current,
94
- parentPath: current.includes('.') ? current.split('.').slice(0, -1).join('.') : '',
95
- },
96
- });
97
- });
98
- }
99
- /*** Resolve a C++ namespace/package node inside the current focus package. */
100
- function nodeIdForNamespace(context, namespace) {
101
- return namespace === '' ? context.package.nodeId : `${context.package.nodeId}#${namespace}`;
102
- }
103
- //# sourceMappingURL=analyzeCppProjectAsync.js.map