@ankhorage/dependency-graph 1.3.0 → 1.4.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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +4 -1
  3. package/dist/dependencyGraph.d.ts +7 -0
  4. package/dist/dependencyGraph.d.ts.map +1 -1
  5. package/dist/dependencyGraph.js +6 -0
  6. package/dist/dependencyGraph.js.map +1 -1
  7. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.d.ts.map +1 -1
  8. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.js +1 -1
  9. package/dist/features/dependency-analysis/application/projectDependencyGraphFromInspections.js.map +1 -1
  10. package/dist/features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.d.ts +6 -0
  11. package/dist/features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.d.ts.map +1 -0
  12. package/dist/features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.js +35 -0
  13. package/dist/features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.js.map +1 -0
  14. package/dist/features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.d.ts +5 -0
  15. package/dist/features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.d.ts.map +1 -0
  16. package/dist/features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.js +7 -0
  17. package/dist/features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.js.map +1 -0
  18. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts +7 -2
  19. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts.map +1 -1
  20. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js +4 -2
  21. package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js.map +1 -1
  22. package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.d.ts +6 -0
  23. package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.d.ts.map +1 -0
  24. package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.js +143 -0
  25. package/dist/features/source-graph/composition/createProjectAnalysisSnapshotAsync.js.map +1 -0
  26. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts.map +1 -1
  27. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js +8 -117
  28. package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js.map +1 -1
  29. package/dist/features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.d.ts +5 -0
  30. package/dist/features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.d.ts.map +1 -0
  31. package/dist/features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js +31 -0
  32. package/dist/features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js.map +1 -0
  33. package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts +2 -7
  34. package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts.map +1 -1
  35. package/dist/features/source-graph/domain/createSourceStructureDraft.js +26 -66
  36. package/dist/features/source-graph/domain/createSourceStructureDraft.js.map +1 -1
  37. package/dist/features/source-graph/domain/deserializeProjectAnalysisSnapshot.d.ts +4 -0
  38. package/dist/features/source-graph/domain/deserializeProjectAnalysisSnapshot.d.ts.map +1 -0
  39. package/dist/features/source-graph/domain/deserializeProjectAnalysisSnapshot.js +8 -0
  40. package/dist/features/source-graph/domain/deserializeProjectAnalysisSnapshot.js.map +1 -0
  41. package/dist/features/source-graph/domain/projectAnalysisSnapshot.d.ts +4 -0
  42. package/dist/features/source-graph/domain/projectAnalysisSnapshot.d.ts.map +1 -0
  43. package/dist/features/source-graph/domain/projectAnalysisSnapshot.js +175 -0
  44. package/dist/features/source-graph/domain/projectAnalysisSnapshot.js.map +1 -0
  45. package/dist/features/source-graph/domain/serializeProjectAnalysisSnapshot.d.ts +4 -0
  46. package/dist/features/source-graph/domain/serializeProjectAnalysisSnapshot.d.ts.map +1 -0
  47. package/dist/features/source-graph/domain/serializeProjectAnalysisSnapshot.js +7 -0
  48. package/dist/features/source-graph/domain/serializeProjectAnalysisSnapshot.js.map +1 -0
  49. package/dist/features/source-graph/domain/sourceAnalyzerCapabilities.d.ts +6 -0
  50. package/dist/features/source-graph/domain/sourceAnalyzerCapabilities.d.ts.map +1 -0
  51. package/dist/features/source-graph/domain/sourceAnalyzerCapabilities.js +47 -0
  52. package/dist/features/source-graph/domain/sourceAnalyzerCapabilities.js.map +1 -0
  53. package/dist/types/projectAnalysisSnapshot.d.ts +44 -0
  54. package/dist/types/projectAnalysisSnapshot.d.ts.map +1 -0
  55. package/dist/types/projectAnalysisSnapshot.js +2 -0
  56. package/dist/types/projectAnalysisSnapshot.js.map +1 -0
  57. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ankhorage/dependency-graph
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b8211fc: Add portable, validated project-analysis snapshots and canonical multi-project recomposition APIs.
8
+
9
+ ## 1.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 93a207f: Preserve distinct TypeScript root-module identities in dependency projections.
14
+
3
15
  ## 1.3.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # @ankhorage/dependency-graph
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v0.7.2](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![docs: paradox](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v1.3.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![docs: paradox](././paradox/badges/docs.svg)
7
7
 
8
8
  Project-aware dependency analysis that produces canonical Ankhorage graphs.
9
9
 
@@ -15,14 +15,17 @@ Project-aware dependency analysis that produces canonical Ankhorage graphs.
15
15
  - [Architecture overview](././paradox/diagrams/architecture-overview.mmd)
16
16
  - [Module relationships](././paradox/diagrams/module-relationships.mmd)
17
17
  - [Export graph](././paradox/diagrams/export-graph.mmd)
18
+ - [createProjectAnalysisSnapshotAsync sequence](././paradox/diagrams/sequences/create-project-analysis-snapshot-async.mmd)
18
19
  - [createSourceGraph sequence](././paradox/diagrams/sequences/create-source-graph.mmd)
19
20
  - [createSourceGraphIndex sequence](././paradox/diagrams/sequences/create-source-graph-index.mmd)
20
21
  - [createSourceRollupIndex sequence](././paradox/diagrams/sequences/create-source-rollup-index.mmd)
22
+ - [deserializeProjectAnalysisSnapshot sequence](././paradox/diagrams/sequences/deserialize-project-analysis-snapshot.mmd)
21
23
  - [deserializeSourceGraph sequence](././paradox/diagrams/sequences/deserialize-source-graph.mmd)
22
24
  - [findRolledUpDependency sequence](././paradox/diagrams/sequences/find-rolled-up-dependency.mmd)
23
25
  - [findSourceRelationsBetween sequence](././paradox/diagrams/sequences/find-source-relations-between.mmd)
24
26
  - [incomingSourceRelations sequence](././paradox/diagrams/sequences/incoming-source-relations.mmd)
25
27
  - [outgoingSourceRelations sequence](././paradox/diagrams/sequences/outgoing-source-relations.mmd)
26
28
  - [rollupSourceRelations sequence](././paradox/diagrams/sequences/rollup-source-relations.mmd)
29
+ - [serializeProjectAnalysisSnapshot sequence](././paradox/diagrams/sequences/serialize-project-analysis-snapshot.mmd)
27
30
  - [serializeSourceGraph sequence](././paradox/diagrams/sequences/serialize-source-graph.mmd)
28
31
  - [summarizeSourceNode sequence](././paradox/diagrams/sequences/summarize-source-node.mmd)
@@ -1,15 +1,22 @@
1
1
  export { projectDependencyGraphFromInspections } from './features/dependency-analysis/application/projectDependencyGraphFromInspections.js';
2
+ export { projectDependencyGraphFromProjectAnalysisSnapshots } from './features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.js';
2
3
  export { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';
3
4
  export { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';
5
+ export { createDependencyGraphFromProjectAnalysisSnapshots } from './features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.js';
6
+ export { createProjectAnalysisSnapshotAsync } from './features/source-graph/composition/createProjectAnalysisSnapshotAsync.js';
4
7
  export { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';
5
8
  export { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';
9
+ export { createSourceGraphFromProjectAnalysisSnapshots } from './features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js';
6
10
  export { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';
7
11
  export { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';
8
12
  export { createSourceRollupIndex, findRolledUpDependency, outgoingRolledUpDependencies, } from './features/source-graph/domain/createSourceRollupIndex.js';
13
+ export { deserializeProjectAnalysisSnapshot } from './features/source-graph/domain/deserializeProjectAnalysisSnapshot.js';
9
14
  export { findSourceFile, findSourceNode, findSourceRelationsBetween, findSourceSymbols, incomingSourceRelations, outgoingSourceRelations, } from './features/source-graph/domain/querySourceGraph.js';
10
15
  export { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';
16
+ export { serializeProjectAnalysisSnapshot } from './features/source-graph/domain/serializeProjectAnalysisSnapshot.js';
11
17
  export { deserializeSourceGraph, serializeSourceGraph, } from './features/source-graph/domain/serializeSourceGraph.js';
12
18
  export { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';
13
19
  export type { CreateDependencyGraphFromInspectionsInput, CreateDependencyGraphInput, DependencyDeclaration, DependencyDeclarationKind, DependencyGraph, DependencyGraphEdgeData, DependencyGraphInspectionProjectInput, DependencyGraphNodeData, DependencyGraphPackage, DependencyGraphProjectInput, DependencyImportEvidence, DependencyNodeClassification, DependencyNodeKind, DependencyReferenceClassification, } from './types/dependencyGraph.js';
20
+ export type { CreateProjectAnalysisSnapshotInput, ProjectAnalysisAnalyzer, ProjectAnalysisPackage, ProjectAnalysisSnapshot, ProjectAnalysisSourceFile, ProjectAnalysisWorkspace, } from './types/projectAnalysisSnapshot.js';
14
21
  export type { CreateSourceGraphFromInspectionsInput, CreateSourceGraphInput, SourceAnalyzedFile, SourceCapability, SourceCapabilityReport, SourceDeclarationFact, SourceDocumentation, SourceEdgeData, SourceEdgeDraft, SourceFileFacts, SourceGraph, SourceGraphDraft, SourceGraphIndex, SourceImportFact, SourceInspectionProjectInput, SourceLocation, SourceNodeData, SourceNodeDraft, SourceNodeKind, SourceNodeSummary, SourceRelationEvidence, SourceRelationKind, SourceRelationView, SourceRollupEdge, SourceRollupIndex, SourceVisibility, } from './types/sourceGraph.js';
15
22
  //# sourceMappingURL=dependencyGraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,qFAAqF,CAAC;AAC5I,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,yCAAyC,EAAE,MAAM,yFAAyF,CAAC;AACpJ,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,qCAAqC,EAAE,MAAM,8EAA8E,CAAC;AACrI,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAC5F,YAAY,EACV,yCAAyC,EACzC,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,qCAAqC,EACrC,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,qCAAqC,EACrC,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,qFAAqF,CAAC;AAC5I,OAA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AA4B,CAAC;AACpC,YAAY,EACV,kCAAkC,EAClC,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACV,qCAAqC,EACrC,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC"}
@@ -1,13 +1,19 @@
1
1
  export { projectDependencyGraphFromInspections } from './features/dependency-analysis/application/projectDependencyGraphFromInspections.js';
2
+ export { projectDependencyGraphFromProjectAnalysisSnapshots } from './features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.js';
2
3
  export { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';
3
4
  export { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';
5
+ export { createDependencyGraphFromProjectAnalysisSnapshots } from './features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.js';
6
+ export { createProjectAnalysisSnapshotAsync } from './features/source-graph/composition/createProjectAnalysisSnapshotAsync.js';
4
7
  export { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';
5
8
  export { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';
9
+ export { createSourceGraphFromProjectAnalysisSnapshots } from './features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js';
6
10
  export { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';
7
11
  export { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';
8
12
  export { createSourceRollupIndex, findRolledUpDependency, outgoingRolledUpDependencies, } from './features/source-graph/domain/createSourceRollupIndex.js';
13
+ export { deserializeProjectAnalysisSnapshot } from './features/source-graph/domain/deserializeProjectAnalysisSnapshot.js';
9
14
  export { findSourceFile, findSourceNode, findSourceRelationsBetween, findSourceSymbols, incomingSourceRelations, outgoingSourceRelations, } from './features/source-graph/domain/querySourceGraph.js';
10
15
  export { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';
16
+ export { serializeProjectAnalysisSnapshot } from './features/source-graph/domain/serializeProjectAnalysisSnapshot.js';
11
17
  export { deserializeSourceGraph, serializeSourceGraph, } from './features/source-graph/domain/serializeSourceGraph.js';
12
18
  export { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';
13
19
  //# sourceMappingURL=dependencyGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,qFAAqF,CAAC;AAC5I,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,yCAAyC,EAAE,MAAM,yFAAyF,CAAC;AACpJ,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,qCAAqC,EAAE,MAAM,8EAA8E,CAAC;AACrI,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC","sourcesContent":["export { projectDependencyGraphFromInspections } from './features/dependency-analysis/application/projectDependencyGraphFromInspections.js';\nexport { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';\nexport { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';\nexport { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';\nexport { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';\nexport { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';\nexport { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';\nexport {\n createSourceRollupIndex,\n findRolledUpDependency,\n outgoingRolledUpDependencies,\n} from './features/source-graph/domain/createSourceRollupIndex.js';\nexport {\n findSourceFile,\n findSourceNode,\n findSourceRelationsBetween,\n findSourceSymbols,\n incomingSourceRelations,\n outgoingSourceRelations,\n} from './features/source-graph/domain/querySourceGraph.js';\nexport { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';\nexport {\n deserializeSourceGraph,\n serializeSourceGraph,\n} from './features/source-graph/domain/serializeSourceGraph.js';\nexport { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';\nexport type {\n CreateDependencyGraphFromInspectionsInput,\n CreateDependencyGraphInput,\n DependencyDeclaration,\n DependencyDeclarationKind,\n DependencyGraph,\n DependencyGraphEdgeData,\n DependencyGraphInspectionProjectInput,\n DependencyGraphNodeData,\n DependencyGraphPackage,\n DependencyGraphProjectInput,\n DependencyImportEvidence,\n DependencyNodeClassification,\n DependencyNodeKind,\n DependencyReferenceClassification,\n} from './types/dependencyGraph.js';\nexport type {\n CreateSourceGraphFromInspectionsInput,\n CreateSourceGraphInput,\n SourceAnalyzedFile,\n SourceCapability,\n SourceCapabilityReport,\n SourceDeclarationFact,\n SourceDocumentation,\n SourceEdgeData,\n SourceEdgeDraft,\n SourceFileFacts,\n SourceGraph,\n SourceGraphDraft,\n SourceGraphIndex,\n SourceImportFact,\n SourceInspectionProjectInput,\n SourceLocation,\n SourceNodeData,\n SourceNodeDraft,\n SourceNodeKind,\n SourceNodeSummary,\n SourceRelationEvidence,\n SourceRelationKind,\n SourceRelationView,\n SourceRollupEdge,\n SourceRollupIndex,\n SourceVisibility,\n} from './types/sourceGraph.js';\n"]}
1
+ {"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,qFAAqF,CAAC;AAC5I,OAAO,EAAE,kDAAkD,EAAE,MAAM,kGAAkG,CAAC;AACtK,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,yCAAyC,EAAE,MAAM,yFAAyF,CAAC;AACpJ,OAAO,EAAE,iDAAiD,EAAE,MAAM,iGAAiG,CAAC;AACpK,OAAO,EAAE,kCAAkC,EAAE,MAAM,2EAA2E,CAAC;AAC/H,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,qCAAqC,EAAE,MAAM,8EAA8E,CAAC;AACrI,OAAO,EAAE,6CAA6C,EAAE,MAAM,sFAAsF,CAAC;AACrJ,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,kCAAkC,EAAE,MAAM,sEAAsE,CAAC;AAC1H,OAAO,EACL,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EAAE,gCAAgC,EAAE,MAAM,oEAAoE,CAAC;AACtH,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC","sourcesContent":["export { projectDependencyGraphFromInspections } from './features/dependency-analysis/application/projectDependencyGraphFromInspections.js';\nexport { projectDependencyGraphFromProjectAnalysisSnapshots } from './features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.js';\nexport { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';\nexport { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';\nexport { createDependencyGraphFromProjectAnalysisSnapshots } from './features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.js';\nexport { createProjectAnalysisSnapshotAsync } from './features/source-graph/composition/createProjectAnalysisSnapshotAsync.js';\nexport { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';\nexport { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';\nexport { createSourceGraphFromProjectAnalysisSnapshots } from './features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js';\nexport { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';\nexport { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';\nexport {\n createSourceRollupIndex,\n findRolledUpDependency,\n outgoingRolledUpDependencies,\n} from './features/source-graph/domain/createSourceRollupIndex.js';\nexport { deserializeProjectAnalysisSnapshot } from './features/source-graph/domain/deserializeProjectAnalysisSnapshot.js';\nexport {\n findSourceFile,\n findSourceNode,\n findSourceRelationsBetween,\n findSourceSymbols,\n incomingSourceRelations,\n outgoingSourceRelations,\n} from './features/source-graph/domain/querySourceGraph.js';\nexport { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';\nexport { serializeProjectAnalysisSnapshot } from './features/source-graph/domain/serializeProjectAnalysisSnapshot.js';\nexport {\n deserializeSourceGraph,\n serializeSourceGraph,\n} from './features/source-graph/domain/serializeSourceGraph.js';\nexport { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';\nexport type {\n CreateDependencyGraphFromInspectionsInput,\n CreateDependencyGraphInput,\n DependencyDeclaration,\n DependencyDeclarationKind,\n DependencyGraph,\n DependencyGraphEdgeData,\n DependencyGraphInspectionProjectInput,\n DependencyGraphNodeData,\n DependencyGraphPackage,\n DependencyGraphProjectInput,\n DependencyImportEvidence,\n DependencyNodeClassification,\n DependencyNodeKind,\n DependencyReferenceClassification,\n} from './types/dependencyGraph.js';\nexport type {\n CreateProjectAnalysisSnapshotInput,\n ProjectAnalysisAnalyzer,\n ProjectAnalysisPackage,\n ProjectAnalysisSnapshot,\n ProjectAnalysisSourceFile,\n ProjectAnalysisWorkspace,\n} from './types/projectAnalysisSnapshot.js';\nexport type {\n CreateSourceGraphFromInspectionsInput,\n CreateSourceGraphInput,\n SourceAnalyzedFile,\n SourceCapability,\n SourceCapabilityReport,\n SourceDeclarationFact,\n SourceDocumentation,\n SourceEdgeData,\n SourceEdgeDraft,\n SourceFileFacts,\n SourceGraph,\n SourceGraphDraft,\n SourceGraphIndex,\n SourceImportFact,\n SourceInspectionProjectInput,\n SourceLocation,\n SourceNodeData,\n SourceNodeDraft,\n SourceNodeKind,\n SourceNodeSummary,\n SourceRelationEvidence,\n SourceRelationKind,\n SourceRelationView,\n SourceRollupEdge,\n SourceRollupIndex,\n SourceVisibility,\n} from './types/sourceGraph.js';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"projectDependencyGraphFromInspections.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/projectDependencyGraphFromInspections.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,qCAAqC,EAEtC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAIjE,4FAA4F;AAC5F,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,SAAS,qCAAqC,EAAE,GACzD,eAAe,CAKjB"}
1
+ {"version":3,"file":"projectDependencyGraphFromInspections.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/projectDependencyGraphFromInspections.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,qCAAqC,EAEtC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAIjE,4FAA4F;AAC5F,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,SAAS,qCAAqC,EAAE,GACzD,eAAe,CASjB"}
@@ -5,7 +5,7 @@ export function projectDependencyGraphFromInspections(sourceGraph, projects) {
5
5
  assertDependencyGraphInspections(projects);
6
6
  const packages = projects.flatMap(createInspectedPackages);
7
7
  assertUniqueFocusNames(packages);
8
- return projectDependencyGraphFromSourceGraph(sourceGraph, packages, projects);
8
+ return projectDependencyGraphFromSourceGraph(sourceGraph, packages, projects.map(({ id, inspection }) => ({ id, packages: inspection.packages })));
9
9
  }
10
10
  /*** Normalize one supplied inspection into dependency-analysis package contexts. */
11
11
  function createInspectedPackages(project) {
@@ -1 +1 @@
1
- {"version":3,"file":"projectDependencyGraphFromInspections.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/projectDependencyGraphFromInspections.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAEzF,4FAA4F;AAC5F,MAAM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C,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,CAC/C,CAAC;IACF,MAAM,iBAAiB,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,CAClD,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CACnE,CAAC;IACF,MAAM,IAAI,GAAG,WAAW,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACjG,OAAO,CAAC,IAAI,EAAE,GAAG,iBAAiB,CAAC,CAAC;AACtC,CAAC;AAED,qFAAqF;AACrF,SAAS,sBAAsB,CAAC,QAA2C;IACzE,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAC3B,CAAC,cAAc,EAAwE,EAAE,CACvF,cAAc,CAAC,IAAI,KAAK,SAAS,CACpC,CAAC;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAC7B,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,CAC7E,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,SAAS,GAAG,CAAC,CAAC;IACxF,CAAC;AACH,CAAC","sourcesContent":["import type { InspectedPackage, ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n DependencyGraph,\n DependencyGraphInspectionProjectInput,\n DependencyGraphPackage,\n} from '../../../types/dependencyGraph.js';\nimport type { SourceGraph } from '../../../types/sourceGraph.js';\nimport { projectDependencyGraphFromSourceGraph } from '../domain/projectDependencyGraphFromSourceGraph.js';\nimport { assertDependencyGraphInspections } from './assertDependencyGraphInspections.js';\n\n/*** Project a previously analyzed source graph into the established package/module view. */\nexport function projectDependencyGraphFromInspections(\n sourceGraph: SourceGraph,\n projects: readonly DependencyGraphInspectionProjectInput[],\n): DependencyGraph {\n assertDependencyGraphInspections(projects);\n const packages = projects.flatMap(createInspectedPackages);\n assertUniqueFocusNames(packages);\n return projectDependencyGraphFromSourceGraph(sourceGraph, packages, projects);\n}\n\n/*** Normalize one supplied inspection into dependency-analysis package contexts. */\nfunction createInspectedPackages(\n project: DependencyGraphInspectionProjectInput,\n): readonly DependencyGraphPackage[] {\n const { inspection } = project;\n return selectFocusPackages(inspection).map((detected) => {\n const relativeRoot = detected.rootPath;\n const id = `${project.id}:${relativeRoot}`;\n return {\n id,\n nodeId: `package:${id}`,\n projectId: project.id,\n relativeRoot,\n ...(detected.name === undefined ? {} : { name: detected.name }),\n } satisfies DependencyGraphPackage;\n });\n}\n\n/*** Select the root plus packages declared by root workspace metadata as graph focus. */\nfunction selectFocusPackages(inspection: ProjectInspection): readonly InspectedPackage[] {\n const rootPackage = inspection.packages.find(({ rootPath }) => rootPath === '.');\n const workspaceRoots = new Set(\n inspection.workspaces\n .filter(({ rootPath }) => rootPath === '.')\n .flatMap(({ packagePaths }) => packagePaths),\n );\n const workspacePackages = inspection.packages.filter(\n ({ rootPath }) => rootPath !== '.' && workspaceRoots.has(rootPath),\n );\n const root = rootPackage ?? { rootPath: '.', detection: inspection.detection, manifestPath: '' };\n return [root, ...workspacePackages];\n}\n\n/*** Reject ambiguous package names before resolving cross-project source imports. */\nfunction assertUniqueFocusNames(packages: readonly DependencyGraphPackage[]): void {\n const named = packages.filter(\n (packageContext): packageContext is DependencyGraphPackage & { readonly name: string } =>\n packageContext.name !== undefined,\n );\n const duplicates = named.filter(\n (item, index) => named.findIndex(({ name }) => name === item.name) !== index,\n );\n if (duplicates.length > 0) {\n throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);\n }\n}\n"]}
1
+ {"version":3,"file":"projectDependencyGraphFromInspections.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/projectDependencyGraphFromInspections.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAC3G,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAEzF,4FAA4F;AAC5F,MAAM,UAAU,qCAAqC,CACnD,WAAwB,EACxB,QAA0D;IAE1D,gCAAgC,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC3D,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,qCAAqC,CAC1C,WAAW,EACX,QAAQ,EACR,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAC9E,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,SAAS,uBAAuB,CAC9B,OAA8C;IAE9C,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,OAAO,mBAAmB,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACtD,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACvC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,EAAE,IAAI,YAAY,EAAE,CAAC;QAC3C,OAAO;YACL,EAAE;YACF,MAAM,EAAE,WAAW,EAAE,EAAE;YACvB,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,YAAY;YACZ,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI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AK,CAC7E,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,SAAS,GAAG,CAAC,CAAC;IACxF,CAAC;AACH,CAAC","sourcesContent":["import type { InspectedPackage, ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n DependencyGraph,\n DependencyGraphInspectionProjectInput,\n DependencyGraphPackage,\n} from '../../../types/dependencyGraph.js';\nimport type { SourceGraph } from '../../../types/sourceGraph.js';\nimport { projectDependencyGraphFromSourceGraph } from '../domain/projectDependencyGraphFromSourceGraph.js';\nimport { assertDependencyGraphInspections } from './assertDependencyGraphInspections.js';\n\n/*** Project a previously analyzed source graph into the established package/module view. */\nexport function projectDependencyGraphFromInspections(\n sourceGraph: SourceGraph,\n projects: readonly DependencyGraphInspectionProjectInput[],\n): DependencyGraph {\n assertDependencyGraphInspections(projects);\n const packages = projects.flatMap(createInspectedPackages);\n assertUniqueFocusNames(packages);\n return projectDependencyGraphFromSourceGraph(\n sourceGraph,\n packages,\n projects.map(({ id, inspection }) => ({ id, packages: inspection.packages })),\n );\n}\n\n/*** Normalize one supplied inspection into dependency-analysis package contexts. */\nfunction createInspectedPackages(\n project: DependencyGraphInspectionProjectInput,\n): readonly DependencyGraphPackage[] {\n const { inspection } = project;\n return selectFocusPackages(inspection).map((detected) => {\n const relativeRoot = detected.rootPath;\n const id = `${project.id}:${relativeRoot}`;\n return {\n id,\n nodeId: `package:${id}`,\n projectId: project.id,\n relativeRoot,\n ...(detected.name === undefined ? {} : { name: detected.name }),\n } satisfies DependencyGraphPackage;\n });\n}\n\n/*** Select the root plus packages declared by root workspace metadata as graph focus. */\nfunction selectFocusPackages(inspection: ProjectInspection): readonly InspectedPackage[] {\n const rootPackage = inspection.packages.find(({ rootPath }) => rootPath === '.');\n const workspaceRoots = new Set(\n inspection.workspaces\n .filter(({ rootPath }) => rootPath === '.')\n .flatMap(({ packagePaths }) => packagePaths),\n );\n const workspacePackages = inspection.packages.filter(\n ({ rootPath }) => rootPath !== '.' && workspaceRoots.has(rootPath),\n );\n const root = rootPackage ?? { rootPath: '.', detection: inspection.detection, manifestPath: '' };\n return [root, ...workspacePackages];\n}\n\n/*** Reject ambiguous package names before resolving cross-project source imports. */\nfunction assertUniqueFocusNames(packages: readonly DependencyGraphPackage[]): void {\n const named = packages.filter(\n (packageContext): packageContext is DependencyGraphPackage & { readonly name: string } =>\n packageContext.name !== undefined,\n );\n const duplicates = named.filter(\n (item, index) => named.findIndex(({ name }) => name === item.name) !== index,\n );\n if (duplicates.length > 0) {\n throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { DependencyGraph } from '../../../types/dependencyGraph.js';
2
+ import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
3
+ import type { SourceGraph } from '../../../types/sourceGraph.js';
4
+ /*** Project recomposed portable source facts through the established package/module graph view. */
5
+ export declare function projectDependencyGraphFromProjectAnalysisSnapshots(sourceGraph: SourceGraph, snapshots: readonly ProjectAnalysisSnapshot[]): DependencyGraph;
6
+ //# sourceMappingURL=projectDependencyGraphFromProjectAnalysisSnapshots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectDependencyGraphFromProjectAnalysisSnapshots.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/projectDependencyGraphFromProjectAnalysisSnapshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,mCAAmC,CAAC;AACjG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGjE,mGAAmG;AACnG,wBAAgB,kDAAkD,CAChE,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,uBAAuB,EAAE,GAC5C,eAAe,CAQjB"}
@@ -0,0 +1,35 @@
1
+ import { projectDependencyGraphFromSourceGraph } from '../domain/projectDependencyGraphFromSourceGraph.js';
2
+ /*** Project recomposed portable source facts through the established package/module graph view. */
3
+ export function projectDependencyGraphFromProjectAnalysisSnapshots(sourceGraph, snapshots) {
4
+ const packages = snapshots.flatMap(createSnapshotPackages);
5
+ assertUniqueFocusNames(packages);
6
+ return projectDependencyGraphFromSourceGraph(sourceGraph, packages, snapshots.map(({ projectId: id, packages: detected }) => ({ id, packages: detected })));
7
+ }
8
+ /*** Normalize portable package and workspace facts into dependency projection contexts. */
9
+ function createSnapshotPackages(snapshot) {
10
+ const rootPackage = snapshot.packages.find(({ rootPath }) => rootPath === '.');
11
+ const workspaceRoots = new Set(snapshot.workspaces
12
+ .filter(({ rootPath }) => rootPath === '.')
13
+ .flatMap(({ packagePaths }) => packagePaths));
14
+ const workspacePackages = snapshot.packages.filter(({ rootPath }) => rootPath !== '.' && workspaceRoots.has(rootPath));
15
+ const root = rootPackage ?? { rootPath: '.' };
16
+ return [root, ...workspacePackages].map(({ rootPath: relativeRoot, name }) => {
17
+ const id = `${snapshot.projectId}:${relativeRoot}`;
18
+ return {
19
+ id,
20
+ nodeId: `package:${id}`,
21
+ projectId: snapshot.projectId,
22
+ relativeRoot,
23
+ ...(name === undefined ? {} : { name }),
24
+ };
25
+ });
26
+ }
27
+ /*** Reject ambiguous package names before resolving cross-project source imports. */
28
+ function assertUniqueFocusNames(packages) {
29
+ const named = packages.filter((item) => item.name !== undefined);
30
+ const duplicates = named.filter((item, index) => named.findIndex(({ name }) => name === item.name) !== index);
31
+ if (duplicates.length > 0) {
32
+ throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);
33
+ }
34
+ }
35
+ //# sourceMappingURL=projectDependencyGraphFromProjectAnalysisSnapshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectDependencyGraphFromProjectAnalysisSnap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,EAAE,CAAC;IAC9C,OAAO,CAAC,IAAI,EAAE,GAAG,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE;QAC3E,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,SAAS,IAAI,YAAY,EAAE,CAAC;QACnD,OAAO;YACL,EAAE;YACF,MAAM,EAAE,WAAW,EAAE,EAAE;YACvB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,YAAY;YACZ,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;SACP,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,qFAAqF;AACrF,SAAS,sBAAsB,CAAC,QAA2C;IACzE,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAC3B,CAAC,IAAI,EAA8D,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAC9F,CAAC;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAC7B,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,CAC7E,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,SAAS,GAAG,CAAC,CAAC;IACxF,CAAC;AACH,CAAC","sourcesContent":["import type { DependencyGraph, DependencyGraphPackage } from '../../../types/dependencyGraph.js';\nimport type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';\nimport type { SourceGraph } from '../../../types/sourceGraph.js';\nimport { projectDependencyGraphFromSourceGraph } from '../domain/projectDependencyGraphFromSourceGraph.js';\n\n/*** Project recomposed portable source facts through the established package/module graph view. */\nexport function projectDependencyGraphFromProjectAnalysisSnapshots(\n sourceGraph: SourceGraph,\n snapshots: readonly ProjectAnalysisSnapshot[],\n): DependencyGraph {\n const packages = snapshots.flatMap(createSnapshotPackages);\n assertUniqueFocusNames(packages);\n return projectDependencyGraphFromSourceGraph(\n sourceGraph,\n packages,\n snapshots.map(({ projectId: id, packages: detected }) => ({ id, packages: detected })),\n );\n}\n\n/*** Normalize portable package and workspace facts into dependency projection contexts. */\nfunction createSnapshotPackages(\n snapshot: ProjectAnalysisSnapshot,\n): readonly DependencyGraphPackage[] {\n const rootPackage = snapshot.packages.find(({ rootPath }) => rootPath === '.');\n const workspaceRoots = new Set(\n snapshot.workspaces\n .filter(({ rootPath }) => rootPath === '.')\n .flatMap(({ packagePaths }) => packagePaths),\n );\n const workspacePackages = snapshot.packages.filter(\n ({ rootPath }) => rootPath !== '.' && workspaceRoots.has(rootPath),\n );\n const root = rootPackage ?? { rootPath: '.' };\n return [root, ...workspacePackages].map(({ rootPath: relativeRoot, name }) => {\n const id = `${snapshot.projectId}:${relativeRoot}`;\n return {\n id,\n nodeId: `package:${id}`,\n projectId: snapshot.projectId,\n relativeRoot,\n ...(name === undefined ? {} : { name }),\n } satisfies DependencyGraphPackage;\n });\n}\n\n/*** Reject ambiguous package names before resolving cross-project source imports. */\nfunction assertUniqueFocusNames(packages: readonly DependencyGraphPackage[]): void {\n const named = packages.filter(\n (item): item is DependencyGraphPackage & { readonly name: string } => item.name !== undefined,\n );\n const duplicates = named.filter(\n (item, index) => named.findIndex(({ name }) => name === item.name) !== index,\n );\n if (duplicates.length > 0) {\n throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { DependencyGraph } from '../../../types/dependencyGraph.js';
2
+ import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
3
+ /*** Recompose portable project snapshots into the canonical dependency graph. */
4
+ export declare function createDependencyGraphFromProjectAnalysisSnapshots(snapshots: readonly ProjectAnalysisSnapshot[]): DependencyGraph;
5
+ //# sourceMappingURL=createDependencyGraphFromProjectAnalysisSnapshots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDependencyGraphFromProjectAnalysisSnapshots.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAIzF,iFAAiF;AACjF,wBAAgB,iDAAiD,CAC/D,SAAS,EAAE,SAAS,uBAAuB,EAAE,GAC5C,eAAe,CAKjB"}
@@ -0,0 +1,7 @@
1
+ import { createSourceGraphFromProjectAnalysisSnapshots } from '../../source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js';
2
+ import { projectDependencyGraphFromProjectAnalysisSnapshots } from '../application/projectDependencyGraphFromProjectAnalysisSnapshots.js';
3
+ /*** Recompose portable project snapshots into the canonical dependency graph. */
4
+ export function createDependencyGraphFromProjectAnalysisSnapshots(snapshots) {
5
+ return projectDependencyGraphFromProjectAnalysisSnapshots(createSourceGraphFromProjectAnalysisSnapshots(snapshots), snapshots);
6
+ }
7
+ //# sourceMappingURL=createDependencyGraphFromProjectAnalysisSnapshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDependencyGraphFromProjectAnalysisSnapshots.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/composition/createDependencyGraphFromProjectAnalysisSnapshots.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6CAA6C,EAAE,MAAM,iFAAiF,CAAC;AAChJ,OAAO,EAAE,kDAAkD,EAAE,MAAM,sEAAsE,CAAC;AAE1I,iFAAiF;AACjF,MAAM,UAAU,iDAAiD,CAC/D,SAA6C;IAE7C,OAAO,kDAAkD,CACvD,6CAA6C,CAAC,SAAS,CAAC,EACxD,SAAS,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { DependencyGraph } from '../../../types/dependencyGraph.js';\nimport type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';\nimport { createSourceGraphFromProjectAnalysisSnapshots } from '../../source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.js';\nimport { projectDependencyGraphFromProjectAnalysisSnapshots } from '../application/projectDependencyGraphFromProjectAnalysisSnapshots.js';\n\n/*** Recompose portable project snapshots into the canonical dependency graph. */\nexport function createDependencyGraphFromProjectAnalysisSnapshots(\n snapshots: readonly ProjectAnalysisSnapshot[],\n): DependencyGraph {\n return projectDependencyGraphFromProjectAnalysisSnapshots(\n createSourceGraphFromProjectAnalysisSnapshots(snapshots),\n snapshots,\n );\n}\n"]}
@@ -1,5 +1,10 @@
1
- import type { DependencyGraph, DependencyGraphInspectionProjectInput, DependencyGraphPackage } from '../../../types/dependencyGraph.js';
1
+ import type { DependencyGraph, DependencyGraphPackage } from '../../../types/dependencyGraph.js';
2
2
  import type { SourceGraph } from '../../../types/sourceGraph.js';
3
3
  /*** Derive the established module/package dependency view from canonical source facts. */
4
- export declare function projectDependencyGraphFromSourceGraph(sourceGraph: SourceGraph, packages: readonly DependencyGraphPackage[], projects: readonly DependencyGraphInspectionProjectInput[]): DependencyGraph;
4
+ export declare function projectDependencyGraphFromSourceGraph(sourceGraph: SourceGraph, packages: readonly DependencyGraphPackage[], projects: readonly {
5
+ readonly id: string;
6
+ readonly packages: readonly {
7
+ readonly rootPath: string;
8
+ }[];
9
+ }[]): DependencyGraph;
5
10
  //# sourceMappingURL=projectDependencyGraphFromSourceGraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectDependencyGraphFromSourceGraph.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAEf,qCAAqC,EAErC,sBAAsB,EAGvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AAGvC,0FAA0F;AAC1F,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,SAAS,sBAAsB,EAAE,EAC3C,QAAQ,EAAE,SAAS,qCAAqC,EAAE,GACzD,eAAe,CAuCjB"}
1
+ {"version":3,"file":"projectDependencyGraphFromSourceGraph.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAGf,sBAAsB,EAGvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AAGvC,0FAA0F;AAC1F,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,SAAS,sBAAsB,EAAE,EAC3C,QAAQ,EAAE,SAAS;IACjB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7D,EAAE,GACF,eAAe,CAuCjB"}
@@ -2,7 +2,7 @@ import { createGraph } from '@ankhorage/graph';
2
2
  import { createFocusPackageNode } from './createFocusPackageNode.js';
3
3
  /*** Derive the established module/package dependency view from canonical source facts. */
4
4
  export function projectDependencyGraphFromSourceGraph(sourceGraph, packages, projects) {
5
- const detectedRoots = new Map(projects.map(({ id, inspection }) => [id, inspection.packages.map(({ rootPath }) => rootPath)]));
5
+ const detectedRoots = new Map(projects.map(({ id, packages: detected }) => [id, detected.map(({ rootPath }) => rootPath)]));
6
6
  const nodes = new Map(packages.map((item) => [item.nodeId, createFocusPackageNode(item)]));
7
7
  const edges = new Map();
8
8
  const sourceNodes = new Map(sourceGraph.graph.nodes.map((node) => [node.id, node.data]));
@@ -55,7 +55,9 @@ function moduleForFile(file, owner) {
55
55
  ? (file.filePath ?? '')
56
56
  : (file.filePath ?? '').slice(owner.relativeRoot.length + 1);
57
57
  const directory = relative.split('/').slice(0, -1).join('/');
58
- return directory.split('/').filter(Boolean).join('.');
58
+ if (directory !== '')
59
+ return directory.split('/').filter(Boolean).join('.');
60
+ return relative.replace(/\.[^.]+$/u, '');
59
61
  }
60
62
  /*** Preserve the existing package/module node identity and dotted ancestor structure. */
61
63
  function addModuleHierarchy(nodes, owner, modulePath) {
@@ -1 +1 @@
1
- {"version":3,"file":"projectDependencyGraphFromSourceGraph.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgB/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,0FAA0F;AAC1F,MAAM,UAAU,qCAAqC,CACnD,WAAwB,EACxB,QAA2C,EAC3C,QAA0D;IAE1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,QAAQ,CAAC,GAAG,CACV,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAU,CAC3F,CACF,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,CACpE,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,GAAG,EAA8C,CAAC;IACpE,MAAM,WAAW,GAAG,IAAI,GA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AAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC;SAC5D;KACF,CAAC,CAAC;AACL,CAAC;AAED,yEAAyE;AACzE,SAAS,YAAY,CAAC,KAA6B,EAAE,UAAkB;IACrE,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import type { GraphEdge, GraphNode } from '@ankhorage/graph';\nimport { createGraph } from '@ankhorage/graph';\n\nimport type {\n DependencyGraph,\n DependencyGraphEdgeData,\n DependencyGraphInspectionProjectInput,\n DependencyGraphNodeData,\n DependencyGraphPackage,\n DependencyImportEvidence,\n DependencyReferenceClassification,\n} from '../../../types/dependencyGraph.js';\nimport type {\n SourceGraph,\n SourceNodeData,\n SourceRelationEvidence,\n} from '../../../types/sourceGraph.js';\nimport { createFocusPackageNode } from './createFocusPackageNode.js';\n\n/*** Derive the established module/package dependency view from canonical source facts. */\nexport function projectDependencyGraphFromSourceGraph(\n sourceGraph: SourceGraph,\n packages: readonly DependencyGraphPackage[],\n projects: readonly DependencyGraphInspectionProjectInput[],\n): DependencyGraph {\n const detectedRoots = new Map(\n projects.map(\n ({ id, inspection }) => [id, inspection.packages.map(({ rootPath }) => rootPath)] as const,\n ),\n );\n const nodes = new Map<string, GraphNode<DependencyGraphNodeData>>(\n packages.map((item) => [item.nodeId, createFocusPackageNode(item)]),\n );\n const edges = new Map<string, GraphEdge<DependencyGraphEdgeData>>();\n const sourceNodes = new Map(sourceGraph.graph.nodes.map((node) => [node.id, node.data]));\n const files = sourceGraph.graph.nodes.filter(\n ({ data }) => data.kind === 'file' && data.analyzerId !== undefined,\n );\n for (const { data } of files) {\n const owner = packageForFile(packages, detectedRoots, data);\n if (owner !== undefined) addModuleHierarchy(nodes, owner, moduleForFile(data, owner));\n }\n for (const edge of sourceGraph.graph.edges) {\n if (edge.data.kind !== 'imports') continue;\n const source = sourceNodes.get(edge.source);\n const target = sourceNodes.get(edge.target);\n if (source === undefined || target === undefined) continue;\n const owner = packageForFile(packages, detectedRoots, source);\n if (owner === undefined || source.analyzerId === undefined) continue;\n const sourceId = moduleNodeId(owner, moduleForFile(source, owner));\n const targetId = projectTarget(target, owner, packages, detectedRoots, nodes);\n if (targetId === undefined || targetId === sourceId) continue;\n addProjectedEdge(\n edges,\n sourceId,\n targetId,\n source.analyzerId,\n owner,\n edge.data.evidence,\n target,\n );\n }\n return createGraph({ nodes: [...nodes.values()], edges: [...edges.values()] });\n}\n\n/*** Select the deepest focus package root containing one project-relative source file. */\nfunction packageForFile(\n packages: readonly DependencyGraphPackage[],\n detectedRoots: ReadonlyMap<string, readonly string[]>,\n file: SourceNodeData,\n): DependencyGraphPackage | undefined {\n if (file.filePath === undefined) return undefined;\n const { filePath } = file;\n const detected =\n (detectedRoots.get(file.projectId) ?? ['.'])\n .filter((root) => root === '.' || filePath === root || filePath.startsWith(`${root}/`))\n .sort((left, right) => right.length - left.length)[0] ?? '.';\n if (!packages.some((item) => item.projectId === file.projectId && item.relativeRoot === detected))\n return undefined;\n return packages\n .filter(\n (item) =>\n item.projectId === file.projectId &&\n (item.relativeRoot === '.' ||\n filePath === item.relativeRoot ||\n filePath.startsWith(`${item.relativeRoot}/`)),\n )\n .sort((left, right) => right.relativeRoot.length - left.relativeRoot.length)[0];\n}\n\n/*** Read the established dotted module path from one analyzed source file. */\nfunction moduleForFile(file: SourceNodeData, owner: DependencyGraphPackage): string {\n if (file.analyzerId !== 'typescript') return file.packageName ?? '';\n const relative =\n owner.relativeRoot === '.'\n ? (file.filePath ?? '')\n : (file.filePath ?? '').slice(owner.relativeRoot.length + 1);\n const directory = relative.split('/').slice(0, -1).join('/');\n return directory.split('/').filter(Boolean).join('.');\n}\n\n/*** Preserve the existing package/module node identity and dotted ancestor structure. */\nfunction addModuleHierarchy(\n nodes: Map<string, GraphNode<DependencyGraphNodeData>>,\n owner: DependencyGraphPackage,\n modulePath: string,\n): void {\n const parts = modulePath.split('.').filter(Boolean);\n parts.forEach((_, index) => {\n const current = parts.slice(0, index + 1).join('.');\n const id = moduleNodeId(owner, current);\n if (nodes.has(id)) return;\n nodes.set(id, {\n id,\n data: {\n kind: 'module',\n classification: 'intrinsic',\n focus: true,\n label: parts.at(index) ?? current,\n projectId: owner.projectId,\n ...(owner.name === undefined ? {} : { packageName: owner.name }),\n path: current,\n parentPath: index === 0 ? '' : parts.slice(0, index).join('.'),\n },\n });\n });\n}\n\n/*** Resolve canonical import targets to stable package/module projection identities. */\nfunction projectTarget(\n target: SourceNodeData,\n sourceOwner: DependencyGraphPackage,\n packages: readonly DependencyGraphPackage[],\n detectedRoots: ReadonlyMap<string, readonly string[]>,\n nodes: Map<string, GraphNode<DependencyGraphNodeData>>,\n): string | undefined {\n if (target.classification === 'vendor' || target.classification === 'unknown') {\n const name = target.packageName ?? target.name;\n const id = `${target.classification}:${name}`;\n if (!nodes.has(id))\n nodes.set(id, {\n id,\n data: {\n kind: 'package',\n classification: target.classification,\n focus: false,\n label: name,\n packageName: name,\n },\n });\n return id;\n }\n if (target.kind === 'package' && target.path !== undefined) {\n return packages.find(\n (item) => item.projectId === target.projectId && item.relativeRoot === target.path,\n )?.nodeId;\n }\n const owner =\n target.filePath === undefined ? sourceOwner : packageForFile(packages, detectedRoots, target);\n if (owner === undefined) return undefined;\n const modulePath =\n target.analyzerId === 'typescript' || target.kind === 'file'\n ? moduleForFile(target, owner)\n : (target.packageName ?? '');\n addModuleHierarchy(nodes, owner, modulePath);\n return moduleNodeId(owner, modulePath);\n}\n\n/*** Add one canonical import to a weighted package edge with original evidence. */\nfunction addProjectedEdge(\n edges: Map<string, GraphEdge<DependencyGraphEdgeData>>,\n sourceId: string,\n targetId: string,\n analyzerId: string,\n owner: DependencyGraphPackage,\n evidence: readonly SourceRelationEvidence[],\n target: SourceNodeData,\n): void {\n const id = `${sourceId}->${targetId}`;\n const previous = edges.get(id);\n const classification: DependencyReferenceClassification =\n target.kind === 'package' && target.path !== undefined\n ? 'focus'\n : (target.classification ?? 'unknown');\n const observed = evidence.map((item): DependencyImportEvidence => ({\n sourceFile:\n owner.relativeRoot === '.'\n ? item.sourcePath\n : item.sourcePath.slice(owner.relativeRoot.length + 1),\n specifier: item.specifier ?? '',\n classification,\n declarations: item.declarations ?? [],\n }));\n edges.set(id, {\n id,\n source: sourceId,\n target: targetId,\n data: {\n kind: 'import',\n analyzerId,\n weight: (previous?.data.weight ?? 0) + observed.length,\n evidence: [...(previous?.data.evidence ?? []), ...observed],\n },\n });\n}\n\n/*** Preserve the legacy projection's readable package/module node ID. */\nfunction moduleNodeId(owner: DependencyGraphPackage, modulePath: string): string {\n return modulePath === '' ? owner.nodeId : `${owner.nodeId}#${modulePath}`;\n}\n"]}
1
+ {"version":3,"file":"projectDependencyGraphFromSourceGraph.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAe/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,0FAA0F;AAC1F,MAAM,UAAU,qCAAqC,CACnD,WAAwB,EACxB,QAA2C,EAC3C,QAGG;IAEH,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,QAAQ,CAAC,GAAG,CACV,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAU,CACxF,CACF,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,sBAAsB,CAAC,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QAAQ;QAChB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,UAAU;YACV,MAAM,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM;YACtD,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC;SAC5D;KACF,CAAC,CAAC;AACL,CAAC;AAED,yEAAyE;AACzE,SAAS,YAAY,CAAC,KAA6B,EAAE,UAAkB;IACrE,OAAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import type { GraphEdge, GraphNode } from '@ankhorage/graph';\nimport { createGraph } from '@ankhorage/graph';\n\nimport type {\n DependencyGraph,\n DependencyGraphEdgeData,\n DependencyGraphNodeData,\n DependencyGraphPackage,\n DependencyImportEvidence,\n DependencyReferenceClassification,\n} from '../../../types/dependencyGraph.js';\nimport type {\n SourceGraph,\n SourceNodeData,\n SourceRelationEvidence,\n} from '../../../types/sourceGraph.js';\nimport { createFocusPackageNode } from './createFocusPackageNode.js';\n\n/*** Derive the established module/package dependency view from canonical source facts. */\nexport function projectDependencyGraphFromSourceGraph(\n sourceGraph: SourceGraph,\n packages: readonly DependencyGraphPackage[],\n projects: readonly {\n readonly id: string;\n readonly packages: readonly { readonly rootPath: string }[];\n }[],\n): DependencyGraph {\n const detectedRoots = new Map(\n projects.map(\n ({ id, packages: detected }) => [id, detected.map(({ rootPath }) => rootPath)] as const,\n ),\n );\n const nodes = new Map<string, GraphNode<DependencyGraphNodeData>>(\n packages.map((item) => [item.nodeId, createFocusPackageNode(item)]),\n );\n const edges = new Map<string, GraphEdge<DependencyGraphEdgeData>>();\n const sourceNodes = new Map(sourceGraph.graph.nodes.map((node) => [node.id, node.data]));\n const files = sourceGraph.graph.nodes.filter(\n ({ data }) => data.kind === 'file' && data.analyzerId !== undefined,\n );\n for (const { data } of files) {\n const owner = packageForFile(packages, detectedRoots, data);\n if (owner !== undefined) addModuleHierarchy(nodes, owner, moduleForFile(data, owner));\n }\n for (const edge of sourceGraph.graph.edges) {\n if (edge.data.kind !== 'imports') continue;\n const source = sourceNodes.get(edge.source);\n const target = sourceNodes.get(edge.target);\n if (source === undefined || target === undefined) continue;\n const owner = packageForFile(packages, detectedRoots, source);\n if (owner === undefined || source.analyzerId === undefined) continue;\n const sourceId = moduleNodeId(owner, moduleForFile(source, owner));\n const targetId = projectTarget(target, owner, packages, detectedRoots, nodes);\n if (targetId === undefined || targetId === sourceId) continue;\n addProjectedEdge(\n edges,\n sourceId,\n targetId,\n source.analyzerId,\n owner,\n edge.data.evidence,\n target,\n );\n }\n return createGraph({ nodes: [...nodes.values()], edges: [...edges.values()] });\n}\n\n/*** Select the deepest focus package root containing one project-relative source file. */\nfunction packageForFile(\n packages: readonly DependencyGraphPackage[],\n detectedRoots: ReadonlyMap<string, readonly string[]>,\n file: SourceNodeData,\n): DependencyGraphPackage | undefined {\n if (file.filePath === undefined) return undefined;\n const { filePath } = file;\n const detected =\n (detectedRoots.get(file.projectId) ?? ['.'])\n .filter((root) => root === '.' || filePath === root || filePath.startsWith(`${root}/`))\n .sort((left, right) => right.length - left.length)[0] ?? '.';\n if (!packages.some((item) => item.projectId === file.projectId && item.relativeRoot === detected))\n return undefined;\n return packages\n .filter(\n (item) =>\n item.projectId === file.projectId &&\n (item.relativeRoot === '.' ||\n filePath === item.relativeRoot ||\n filePath.startsWith(`${item.relativeRoot}/`)),\n )\n .sort((left, right) => right.relativeRoot.length - left.relativeRoot.length)[0];\n}\n\n/*** Read the established dotted module path from one analyzed source file. */\nfunction moduleForFile(file: SourceNodeData, owner: DependencyGraphPackage): string {\n if (file.analyzerId !== 'typescript') return file.packageName ?? '';\n const relative =\n owner.relativeRoot === '.'\n ? (file.filePath ?? '')\n : (file.filePath ?? '').slice(owner.relativeRoot.length + 1);\n const directory = relative.split('/').slice(0, -1).join('/');\n if (directory !== '') return directory.split('/').filter(Boolean).join('.');\n return relative.replace(/\\.[^.]+$/u, '');\n}\n\n/*** Preserve the existing package/module node identity and dotted ancestor structure. */\nfunction addModuleHierarchy(\n nodes: Map<string, GraphNode<DependencyGraphNodeData>>,\n owner: DependencyGraphPackage,\n modulePath: string,\n): void {\n const parts = modulePath.split('.').filter(Boolean);\n parts.forEach((_, index) => {\n const current = parts.slice(0, index + 1).join('.');\n const id = moduleNodeId(owner, current);\n if (nodes.has(id)) return;\n nodes.set(id, {\n id,\n data: {\n kind: 'module',\n classification: 'intrinsic',\n focus: true,\n label: parts.at(index) ?? current,\n projectId: owner.projectId,\n ...(owner.name === undefined ? {} : { packageName: owner.name }),\n path: current,\n parentPath: index === 0 ? '' : parts.slice(0, index).join('.'),\n },\n });\n });\n}\n\n/*** Resolve canonical import targets to stable package/module projection identities. */\nfunction projectTarget(\n target: SourceNodeData,\n sourceOwner: DependencyGraphPackage,\n packages: readonly DependencyGraphPackage[],\n detectedRoots: ReadonlyMap<string, readonly string[]>,\n nodes: Map<string, GraphNode<DependencyGraphNodeData>>,\n): string | undefined {\n if (target.classification === 'vendor' || target.classification === 'unknown') {\n const name = target.packageName ?? target.name;\n const id = `${target.classification}:${name}`;\n if (!nodes.has(id))\n nodes.set(id, {\n id,\n data: {\n kind: 'package',\n classification: target.classification,\n focus: false,\n label: name,\n packageName: name,\n },\n });\n return id;\n }\n if (target.kind === 'package' && target.path !== undefined) {\n return packages.find(\n (item) => item.projectId === target.projectId && item.relativeRoot === target.path,\n )?.nodeId;\n }\n const owner =\n target.filePath === undefined ? sourceOwner : packageForFile(packages, detectedRoots, target);\n if (owner === undefined) return undefined;\n const modulePath =\n target.analyzerId === 'typescript' || target.kind === 'file'\n ? moduleForFile(target, owner)\n : (target.packageName ?? '');\n addModuleHierarchy(nodes, owner, modulePath);\n return moduleNodeId(owner, modulePath);\n}\n\n/*** Add one canonical import to a weighted package edge with original evidence. */\nfunction addProjectedEdge(\n edges: Map<string, GraphEdge<DependencyGraphEdgeData>>,\n sourceId: string,\n targetId: string,\n analyzerId: string,\n owner: DependencyGraphPackage,\n evidence: readonly SourceRelationEvidence[],\n target: SourceNodeData,\n): void {\n const id = `${sourceId}->${targetId}`;\n const previous = edges.get(id);\n const classification: DependencyReferenceClassification =\n target.kind === 'package' && target.path !== undefined\n ? 'focus'\n : (target.classification ?? 'unknown');\n const observed = evidence.map((item): DependencyImportEvidence => ({\n sourceFile:\n owner.relativeRoot === '.'\n ? item.sourcePath\n : item.sourcePath.slice(owner.relativeRoot.length + 1),\n specifier: item.specifier ?? '',\n classification,\n declarations: item.declarations ?? [],\n }));\n edges.set(id, {\n id,\n source: sourceId,\n target: targetId,\n data: {\n kind: 'import',\n analyzerId,\n weight: (previous?.data.weight ?? 0) + observed.length,\n evidence: [...(previous?.data.evidence ?? []), ...observed],\n },\n });\n}\n\n/*** Preserve the legacy projection's readable package/module node ID. */\nfunction moduleNodeId(owner: DependencyGraphPackage, modulePath: string): string {\n return modulePath === '' ? owner.nodeId : `${owner.nodeId}#${modulePath}`;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { CreateProjectAnalysisSnapshotInput, ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
2
+ /*** Analyze one bounded project into facts that remain valid after its source root is removed. */
3
+ export declare function createProjectAnalysisSnapshotAsync(input: CreateProjectAnalysisSnapshotInput & {
4
+ readonly signal?: AbortSignal;
5
+ }): Promise<ProjectAnalysisSnapshot>;
6
+ //# sourceMappingURL=createProjectAnalysisSnapshotAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProjectAnalysisSnapshotAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createProjectAnalysisSnapshotAsync.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,2CAA2C,CAAC;AASnD,kGAAkG;AAClG,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,kCAAkC,GAAG;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAC5E,OAAO,CAAC,uBAAuB,CAAC,CAoClC"}
@@ -0,0 +1,143 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { inspectProjectAsync } from '@ankhorage/project-detector/node';
4
+ import { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js';
5
+ import { createTypeScriptImportResolver } from '../../dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js';
6
+ import { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';
7
+ import { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';
8
+ import { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';
9
+ import { sourceAnalyzerCapabilities } from '../domain/sourceAnalyzerCapabilities.js';
10
+ /*** Analyze one bounded project into facts that remain valid after its source root is removed. */
11
+ export async function createProjectAnalysisSnapshotAsync(input) {
12
+ const inspection = 'inspection' in input
13
+ ? input.inspection
14
+ : await inspectProjectAsync(input.rootPath, {
15
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
16
+ });
17
+ if (!inspection.complete)
18
+ throw new Error(`Project analysis inspection is incomplete for ${input.id}.`);
19
+ const analyzedFiles = await readProjectFilesAsync(input.id, inspection, input.signal);
20
+ const analyzerIds = new Set([
21
+ 'project-detector',
22
+ ...inspection.detection.languages.map(({ id }) => id),
23
+ ...analyzedFiles.map(({ analyzerId }) => analyzerId),
24
+ ]);
25
+ return {
26
+ version: 1,
27
+ projectId: input.id,
28
+ directories: [...inspection.directories].sort(compareText),
29
+ files: [...inspection.files].sort(compareText),
30
+ packages: inspection.packages
31
+ .map(({ rootPath, name }) => ({ rootPath, ...(name === undefined ? {} : { name }) }))
32
+ .sort((left, right) => compareText(left.rootPath, right.rootPath)),
33
+ workspaces: inspection.workspaces
34
+ .map(({ rootPath, packagePaths }) => ({
35
+ rootPath,
36
+ packagePaths: [...packagePaths].sort(compareText),
37
+ }))
38
+ .sort((left, right) => compareText(left.rootPath, right.rootPath)),
39
+ analyzers: [...analyzerIds]
40
+ .sort(compareText)
41
+ .map((id) => ({ id, capabilities: sourceAnalyzerCapabilities(id) })),
42
+ analyzedFiles: analyzedFiles
43
+ .map(({ projectId: _, ...file }) => file)
44
+ .sort((left, right) => compareText(left.path, right.path)),
45
+ };
46
+ }
47
+ /*** Read project-relative source files once and retain only portable analyzer facts. */
48
+ async function readProjectFilesAsync(projectId, inspection, signal) {
49
+ const declarations = await readPackageDeclarationsAsync(inspection);
50
+ const resolveTypeScriptImports = createTypeScriptImportResolver(inspection.rootPath);
51
+ return Promise.all(inspection.files.flatMap((file) => {
52
+ const analyzerId = analyzerForPath(file);
53
+ if (analyzerId === undefined)
54
+ return [];
55
+ const [owner] = inspection.packages
56
+ .filter(({ rootPath }) => rootPath === '.' || file.startsWith(`${rootPath}/`))
57
+ .sort((left, right) => right.rootPath.length - left.rootPath.length);
58
+ const root = owner?.rootPath ?? '.';
59
+ const sourceRoots = owner?.detection.languages.find(({ id }) => id === analyzerId)?.sourceRoots ??
60
+ defaultSourceRoots(analyzerId);
61
+ const relative = root === '.' ? file : file.slice(root.length + 1);
62
+ if (!sourceRoots.some((sourceRoot) => sourceRoot === '.' || relative.startsWith(`${sourceRoot}/`)))
63
+ return [];
64
+ return [
65
+ readAnalyzedFileAsync({
66
+ projectId,
67
+ file,
68
+ analyzerId,
69
+ projectRoot: inspection.rootPath,
70
+ packageRoot: path.resolve(inspection.rootPath, root),
71
+ sourceRoots,
72
+ declaredDependencies: declarations.get(root),
73
+ resolveTypeScriptImports,
74
+ signal,
75
+ }),
76
+ ];
77
+ }));
78
+ }
79
+ /*** Preserve manifest declarations as project-relative import evidence. */
80
+ async function readPackageDeclarationsAsync(inspection) {
81
+ const entries = await Promise.all(inspection.packages.map(async (item) => [
82
+ item.rootPath,
83
+ item.manifestPath.endsWith('.json')
84
+ ? await readDependencyDeclarationsAsync(path.join(inspection.rootPath, item.manifestPath))
85
+ : {},
86
+ ]));
87
+ return new Map(entries);
88
+ }
89
+ /*** Read one source file at the materialization boundary and discard its absolute path afterward. */
90
+ async function readAnalyzedFileAsync(input) {
91
+ input.signal?.throwIfAborted();
92
+ const absolute = path.resolve(input.projectRoot, ...input.file.split('/'));
93
+ const content = await readFile(absolute, 'utf8');
94
+ input.signal?.throwIfAborted();
95
+ return {
96
+ projectId: input.projectId,
97
+ path: input.file,
98
+ analyzerId: input.analyzerId,
99
+ ...(input.declaredDependencies === undefined
100
+ ? {}
101
+ : { declaredDependencies: input.declaredDependencies }),
102
+ facts: input.analyzerId === 'java'
103
+ ? extractJavaSourceFacts(content)
104
+ : input.analyzerId === 'typescript'
105
+ ? input.resolveTypeScriptImports(absolute, input.packageRoot, extractTypeScriptSourceFacts(input.file, content))
106
+ : extractOtherLanguageFacts(input.analyzerId, content, absolute, input.packageRoot, input.sourceRoots),
107
+ };
108
+ }
109
+ /*** Select the implemented language analyzer from a project-relative source filename. */
110
+ function analyzerForPath(file) {
111
+ if (file.endsWith('.java'))
112
+ return 'java';
113
+ if (['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension)))
114
+ return 'typescript';
115
+ if (file.endsWith('.kt') || file.endsWith('.kts'))
116
+ return 'kotlin';
117
+ if (file.endsWith('.py') || file.endsWith('.pyi'))
118
+ return 'python';
119
+ if (['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)))
120
+ return 'cpp';
121
+ if (['.pas', '.pp', '.dpr'].some((extension) => file.toLowerCase().endsWith(extension)))
122
+ return 'delphi';
123
+ return undefined;
124
+ }
125
+ /*** Keep established default source roots for analyzers without explicit project metadata. */
126
+ function defaultSourceRoots(analyzerId) {
127
+ if (analyzerId === 'java')
128
+ return ['src/main/java', '.'];
129
+ if (analyzerId === 'kotlin')
130
+ return ['src/main/kotlin', 'src', '.'];
131
+ if (analyzerId === 'python')
132
+ return ['src', 'app', '.'];
133
+ if (analyzerId === 'delphi')
134
+ return ['src', 'Source', '.'];
135
+ return ['.'];
136
+ }
137
+ /*** Compare portable identities deterministically without host locale rules. */
138
+ function compareText(left, right) {
139
+ if (left < right)
140
+ return -1;
141
+ return left > right ? 1 : 0;
142
+ }
143
+ //# sourceMappingURL=createProjectAnalysisSnapshotAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProjectAnalysisSnapshotAsync.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createProjectAnalysisSnapshotAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAQvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4EAA4E,CAAC;AACpH,OAAO,EAAE,8BAA8B,EAAE,MAAM,0FAA0F,CAAC;AAC1I,OAAO,EAAE,4BAA4B,EAAE,MAAM,wFAAwF,CAAC;AACtI,OAAO,EAAE,+BAA+B,EAAE,MAAM,qEAAqE,CAAC;AACtH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,KAA6E;IAE7E,MAAM,UAAU,GACd,YAAY,IAAI,KAAK;QACnB,CAAC,CAAC,KAAK,CAAC,UAAU;QAClB,CAAC,CAAC,MAAM,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE;YACxC,GAAG,CAAC,KAAK,CAAC,MAAM,K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WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACrF,OAAO,QAAQ,CAAC;IAClB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,8FAA8F;AAC9F,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,IAAI,UAAU,KAAK,MAAM;QAAE,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;IACzD,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,CAAC,iBAAiB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACpE,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACxD,IAAI,UAAU,KAAK,QAAQ;QAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,gFAAgF;AAChF,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { inspectProjectAsync } from '@ankhorage/project-detector/node';\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateProjectAnalysisSnapshotInput,\n ProjectAnalysisSnapshot,\n} from '../../../types/projectAnalysisSnapshot.js';\nimport type { SourceAnalyzedFile } from '../../../types/sourceGraph.js';\nimport { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js';\nimport { createTypeScriptImportResolver } from '../../dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js';\nimport { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';\nimport { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';\nimport { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';\nimport { sourceAnalyzerCapabilities } from '../domain/sourceAnalyzerCapabilities.js';\n\n/*** Analyze one bounded project into facts that remain valid after its source root is removed. */\nexport async function createProjectAnalysisSnapshotAsync(\n input: CreateProjectAnalysisSnapshotInput & { readonly signal?: AbortSignal },\n): Promise<ProjectAnalysisSnapshot> {\n const inspection =\n 'inspection' in input\n ? input.inspection\n : await inspectProjectAsync(input.rootPath, {\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n if (!inspection.complete)\n throw new Error(`Project analysis inspection is incomplete for ${input.id}.`);\n const analyzedFiles = await readProjectFilesAsync(input.id, inspection, input.signal);\n const analyzerIds = new Set([\n 'project-detector',\n ...inspection.detection.languages.map(({ id }) => id),\n ...analyzedFiles.map(({ analyzerId }) => analyzerId),\n ]);\n return {\n version: 1,\n projectId: input.id,\n directories: [...inspection.directories].sort(compareText),\n files: [...inspection.files].sort(compareText),\n packages: inspection.packages\n .map(({ rootPath, name }) => ({ rootPath, ...(name === undefined ? {} : { name }) }))\n .sort((left, right) => compareText(left.rootPath, right.rootPath)),\n workspaces: inspection.workspaces\n .map(({ rootPath, packagePaths }) => ({\n rootPath,\n packagePaths: [...packagePaths].sort(compareText),\n }))\n .sort((left, right) => compareText(left.rootPath, right.rootPath)),\n analyzers: [...analyzerIds]\n .sort(compareText)\n .map((id) => ({ id, capabilities: sourceAnalyzerCapabilities(id) })),\n analyzedFiles: analyzedFiles\n .map(({ projectId: _, ...file }) => file)\n .sort((left, right) => compareText(left.path, right.path)),\n };\n}\n\n/*** Read project-relative source files once and retain only portable analyzer facts. */\nasync function readProjectFilesAsync(\n projectId: string,\n inspection: ProjectInspection,\n signal: AbortSignal | undefined,\n): Promise<readonly SourceAnalyzedFile[]> {\n const declarations = await readPackageDeclarationsAsync(inspection);\n const resolveTypeScriptImports = createTypeScriptImportResolver(inspection.rootPath);\n return Promise.all(\n inspection.files.flatMap((file) => {\n const analyzerId = analyzerForPath(file);\n if (analyzerId === undefined) return [];\n const [owner] = inspection.packages\n .filter(({ rootPath }) => rootPath === '.' || file.startsWith(`${rootPath}/`))\n .sort((left, right) => right.rootPath.length - left.rootPath.length);\n const root = owner?.rootPath ?? '.';\n const sourceRoots =\n owner?.detection.languages.find(({ id }) => id === analyzerId)?.sourceRoots ??\n defaultSourceRoots(analyzerId);\n const relative = root === '.' ? file : file.slice(root.length + 1);\n if (\n !sourceRoots.some(\n (sourceRoot) => sourceRoot === '.' || relative.startsWith(`${sourceRoot}/`),\n )\n )\n return [];\n return [\n readAnalyzedFileAsync({\n projectId,\n file,\n analyzerId,\n projectRoot: inspection.rootPath,\n packageRoot: path.resolve(inspection.rootPath, root),\n sourceRoots,\n declaredDependencies: declarations.get(root),\n resolveTypeScriptImports,\n signal,\n }),\n ];\n }),\n );\n}\n\n/*** Preserve manifest declarations as project-relative import evidence. */\nasync function readPackageDeclarationsAsync(\n inspection: ProjectInspection,\n): Promise<ReadonlyMap<string, SourceAnalyzedFile['declaredDependencies']>> {\n const entries = await Promise.all(\n inspection.packages.map(\n async (item) =>\n [\n item.rootPath,\n item.manifestPath.endsWith('.json')\n ? await readDependencyDeclarationsAsync(\n path.join(inspection.rootPath, item.manifestPath),\n )\n : {},\n ] as const,\n ),\n );\n return new Map(entries);\n}\n\ninterface ReadSourceFileInput {\n readonly projectId: string;\n readonly projectRoot: string;\n readonly packageRoot: string;\n readonly sourceRoots: readonly string[];\n readonly file: string;\n readonly analyzerId: Exclude<ReturnType<typeof analyzerForPath>, undefined>;\n readonly declaredDependencies: SourceAnalyzedFile['declaredDependencies'];\n readonly resolveTypeScriptImports: ReturnType<typeof createTypeScriptImportResolver>;\n readonly signal: AbortSignal | undefined;\n}\n\n/*** Read one source file at the materialization boundary and discard its absolute path afterward. */\nasync function readAnalyzedFileAsync(input: ReadSourceFileInput): Promise<SourceAnalyzedFile> {\n input.signal?.throwIfAborted();\n const absolute = path.resolve(input.projectRoot, ...input.file.split('/'));\n const content = await readFile(absolute, 'utf8');\n input.signal?.throwIfAborted();\n return {\n projectId: input.projectId,\n path: input.file,\n analyzerId: input.analyzerId,\n ...(input.declaredDependencies === undefined\n ? {}\n : { declaredDependencies: input.declaredDependencies }),\n facts:\n input.analyzerId === 'java'\n ? extractJavaSourceFacts(content)\n : input.analyzerId === 'typescript'\n ? input.resolveTypeScriptImports(\n absolute,\n input.packageRoot,\n extractTypeScriptSourceFacts(input.file, content),\n )\n : extractOtherLanguageFacts(\n input.analyzerId,\n content,\n absolute,\n input.packageRoot,\n input.sourceRoots,\n ),\n };\n}\n\n/*** Select the implemented language analyzer from a project-relative source filename. */\nfunction analyzerForPath(\n file: string,\n): 'java' | 'typescript' | 'cpp' | 'delphi' | 'kotlin' | 'python' | undefined {\n if (file.endsWith('.java')) return 'java';\n if (['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension)))\n return 'typescript';\n if (file.endsWith('.kt') || file.endsWith('.kts')) return 'kotlin';\n if (file.endsWith('.py') || file.endsWith('.pyi')) return 'python';\n if (['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)))\n return 'cpp';\n if (['.pas', '.pp', '.dpr'].some((extension) => file.toLowerCase().endsWith(extension)))\n return 'delphi';\n return undefined;\n}\n\n/*** Keep established default source roots for analyzers without explicit project metadata. */\nfunction defaultSourceRoots(analyzerId: string): readonly string[] {\n if (analyzerId === 'java') return ['src/main/java', '.'];\n if (analyzerId === 'kotlin') return ['src/main/kotlin', 'src', '.'];\n if (analyzerId === 'python') return ['src', 'app', '.'];\n if (analyzerId === 'delphi') return ['src', 'Source', '.'];\n return ['.'];\n}\n\n/*** Compare portable identities deterministically without host locale rules. */\nfunction compareText(left: string, right: string): number {\n if (left < right) return -1;\n return left > right ? 1 : 0;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createSourceGraphFromInspectionsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qCAAqC,EAErC,WAAW,EACZ,MAAM,+BAA+B,CAAC;AAUvC,kFAAkF;AAClF,wBAAsB,qCAAqC,CACzD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,WAAW,CAAC,CAWtB"}
1
+ {"version":3,"file":"createSourceGraphFromInspectionsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qCAAqC,EACrC,WAAW,EACZ,MAAM,+BAA+B,CAAC;AAIvC,kFAAkF;AAClF,wBAAsB,qCAAqC,CACzD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,WAAW,CAAC,CAWtB"}