@ankhorage/dependency-graph 0.7.1 → 1.0.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.
- package/CHANGELOG.md +12 -0
- package/README.md +12 -3
- package/dist/dependencyGraph.d.ts +13 -9
- package/dist/dependencyGraph.d.ts.map +1 -1
- package/dist/dependencyGraph.js +11 -8
- package/dist/dependencyGraph.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts +2 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts +4 -0
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js +201 -0
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.d.ts +4 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.d.ts.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js +159 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js.map +1 -0
- package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.d.ts.map +1 -1
- package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.js +1 -2
- package/dist/features/dependency-analysis/composition/createDependencyGraphAsync.js.map +1 -0
- package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.d.ts.map +1 -0
- package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js +58 -0
- package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractCppPackageFromInclude.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractCppPackageFromInclude.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractDelphiPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractDelphiPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.d.ts +3 -0
- package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/{adapters/outbound/java → domain}/extractJavaPackageFromImport.js +1 -1
- package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractKotlinPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractKotlinPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractPythonPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractPythonPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts +5 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js +144 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js.map +1 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.d.ts +4 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.d.ts.map +1 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.js +36 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.js.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.d.ts +4 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.d.ts.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.js +16 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.js.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts +4 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js +118 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraph.d.ts +4 -0
- package/dist/features/source-graph/domain/createSourceGraph.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraph.js +73 -0
- package/dist/features/source-graph/domain/createSourceGraph.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.d.ts +4 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.js +57 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts +4 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.js +119 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.d.ts +8 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.js +27 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts +11 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.js +238 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.js.map +1 -0
- package/dist/features/source-graph/domain/querySourceGraph.d.ts +15 -0
- package/dist/features/source-graph/domain/querySourceGraph.d.ts.map +1 -0
- package/dist/features/source-graph/domain/querySourceGraph.js +40 -0
- package/dist/features/source-graph/domain/querySourceGraph.js.map +1 -0
- package/dist/features/source-graph/domain/resolveSourceImport.d.ts +9 -0
- package/dist/features/source-graph/domain/resolveSourceImport.d.ts.map +1 -0
- package/dist/features/source-graph/domain/resolveSourceImport.js +146 -0
- package/dist/features/source-graph/domain/resolveSourceImport.js.map +1 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.d.ts +4 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.d.ts.map +1 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.js +46 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.js.map +1 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.d.ts +6 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.d.ts.map +1 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.js +64 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.js.map +1 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.d.ts +3 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.d.ts.map +1 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.js +5 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.js.map +1 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.d.ts +4 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.d.ts.map +1 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.js +66 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.js.map +1 -0
- package/dist/types/dependencyGraph.d.ts +2 -23
- package/dist/types/dependencyGraph.d.ts.map +1 -1
- package/dist/types/dependencyGraph.js.map +1 -1
- package/dist/types/sourceGraph.d.ts +173 -0
- package/dist/types/sourceGraph.d.ts.map +1 -0
- package/dist/types/sourceGraph.js +2 -0
- package/dist/types/sourceGraph.js.map +1 -0
- package/package.json +6 -4
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js +0 -103
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppPackageFromInclude.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppPackageFromInclude.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js +0 -105
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/extractDelphiPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/extractDelphiPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js +0 -101
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.d.ts +0 -7
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.js +0 -7
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js +0 -101
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/extractKotlinPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/extractKotlinPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js +0 -103
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/extractPythonPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/extractPythonPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js +0 -92
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts +0 -5
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js +0 -29
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js +0 -9
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts +0 -11
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js +0 -76
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js.map +0 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js +0 -111
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js.map +0 -1
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts +0 -4
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts.map +0 -1
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js +0 -36
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js.map +0 -1
- /package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.d.ts +0 -0
- /package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphFromInspectionsAsync.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/cpp → domain}/extractCppPackageFromInclude.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/cpp → domain}/extractCppPackageFromInclude.js +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/delphi → domain}/extractDelphiPackageFromImport.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/delphi → domain}/extractDelphiPackageFromImport.js +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/kotlin → domain}/extractKotlinPackageFromImport.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/kotlin → domain}/extractKotlinPackageFromImport.js +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/python → domain}/extractPythonPackageFromImport.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/python → domain}/extractPythonPackageFromImport.js +0 -0
package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inspectProjectAsync } from '@ankhorage/project-detector/node';
|
|
2
|
-
import { assertDependencyGraphProjectIds } from '
|
|
2
|
+
import { assertDependencyGraphProjectIds } from '../application/assertDependencyGraphProjectIds.js';
|
|
3
3
|
import { createDependencyGraphFromInspectionsAsync } from './createDependencyGraphFromInspectionsAsync.js';
|
|
4
4
|
/*** Inspect project roots, then delegate dependency topology construction to the inspection API. */
|
|
5
5
|
export async function createDependencyGraphAsync(input) {
|
|
@@ -12,7 +12,6 @@ export async function createDependencyGraphAsync(input) {
|
|
|
12
12
|
})));
|
|
13
13
|
return createDependencyGraphFromInspectionsAsync({
|
|
14
14
|
projects,
|
|
15
|
-
...(input.analyzers === undefined ? {} : { analyzers: input.analyzers }),
|
|
16
15
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
17
16
|
});
|
|
18
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDependencyGraphAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/composition/createDependencyGraphAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAMvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mDAAmD,CAAC;AACpG,OAAO,EAAE,yCAAyC,EAAE,MAAM,gDAAgD,CAAC;AAE3G,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAiC;IAEjC,+BAA+B,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QACrC,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,UAAU,EAAE,MAAM,mBAAmB,CAAC,OAAO,CAAC,QAAQ,EAAE;YACtD,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;SAChE,CAAC;KACH,CAAC,CAAC,CACJ,CAAC;IAEF,OAAO,yCAAyC,CAAC;QAC/C,QAAQ;QACR,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { inspectProjectAsync } from '@ankhorage/project-detector/node';\n\nimport type {\n CreateDependencyGraphInput,\n DependencyGraph,\n} from '../../../types/dependencyGraph.js';\nimport { assertDependencyGraphProjectIds } from '../application/assertDependencyGraphProjectIds.js';\nimport { createDependencyGraphFromInspectionsAsync } from './createDependencyGraphFromInspectionsAsync.js';\n\n/*** Inspect project roots, then delegate dependency topology construction to the inspection API. */\nexport async function createDependencyGraphAsync(\n input: CreateDependencyGraphInput,\n): Promise<DependencyGraph> {\n assertDependencyGraphProjectIds(input.projects);\n const projects = await Promise.all(\n input.projects.map(async (project) => ({\n id: project.id,\n inspection: await inspectProjectAsync(project.rootPath, {\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n }),\n })),\n );\n\n return createDependencyGraphFromInspectionsAsync({\n projects,\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDependencyGraphFromInspectionsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yCAAyC,EACzC,eAAe,EAGhB,MAAM,mCAAmC,CAAC;AAK3C;;GAEG;AACH,wBAAsB,yCAAyC,CAC7D,KAAK,EAAE,yCAAyC,GAC/C,OAAO,CAAC,eAAe,CAAC,CAU1B"}
|
package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createSourceGraphFromInspectionsAsync } from '../../source-graph/composition/createSourceGraphFromInspectionsAsync.js';
|
|
2
|
+
import { assertDependencyGraphProjectIds } from '../application/assertDependencyGraphProjectIds.js';
|
|
3
|
+
import { projectDependencyGraphFromSourceGraph } from '../domain/projectDependencyGraphFromSourceGraph.js';
|
|
4
|
+
/***
|
|
5
|
+
* Build one canonical dependency graph from already-inspected projects without rescanning them.
|
|
6
|
+
*/
|
|
7
|
+
export async function createDependencyGraphFromInspectionsAsync(input) {
|
|
8
|
+
assertDependencyGraphProjectIds(input.projects);
|
|
9
|
+
const inspected = input.projects.map(createInspectedInput);
|
|
10
|
+
const packages = inspected.flatMap(({ packages: projectPackages }) => projectPackages);
|
|
11
|
+
assertUniqueFocusNames(packages);
|
|
12
|
+
const sourceGraph = await createSourceGraphFromInspectionsAsync({
|
|
13
|
+
projects: input.projects,
|
|
14
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
15
|
+
});
|
|
16
|
+
return projectDependencyGraphFromSourceGraph(sourceGraph, packages, input.projects);
|
|
17
|
+
}
|
|
18
|
+
/*** Normalize one supplied inspection into dependency-analysis package contexts. */
|
|
19
|
+
function createInspectedInput(project) {
|
|
20
|
+
const { inspection } = project;
|
|
21
|
+
if (!inspection.complete) {
|
|
22
|
+
throw new Error(`Dependency graph inspection is incomplete for "${project.id}": ${inspection.diagnostics
|
|
23
|
+
.map(({ message }) => message)
|
|
24
|
+
.join('; ')}`);
|
|
25
|
+
}
|
|
26
|
+
const detectedPackages = selectFocusPackages(inspection);
|
|
27
|
+
const packages = detectedPackages.map((detected) => {
|
|
28
|
+
const relativeRoot = detected.rootPath;
|
|
29
|
+
const id = `${project.id}:${relativeRoot}`;
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
nodeId: `package:${id}`,
|
|
33
|
+
projectId: project.id,
|
|
34
|
+
relativeRoot,
|
|
35
|
+
...(detected.name === undefined ? {} : { name: detected.name }),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
return { packages };
|
|
39
|
+
}
|
|
40
|
+
/*** Select the repository root plus packages declared by root workspace metadata as graph focus. */
|
|
41
|
+
function selectFocusPackages(inspection) {
|
|
42
|
+
const rootPackage = inspection.packages.find(({ rootPath }) => rootPath === '.');
|
|
43
|
+
const workspaceRoots = new Set(inspection.workspaces
|
|
44
|
+
.filter(({ rootPath }) => rootPath === '.')
|
|
45
|
+
.flatMap(({ packagePaths }) => packagePaths));
|
|
46
|
+
const workspacePackages = inspection.packages.filter(({ rootPath }) => rootPath !== '.' && workspaceRoots.has(rootPath));
|
|
47
|
+
const root = rootPackage ?? { rootPath: '.', detection: inspection.detection, manifestPath: '' };
|
|
48
|
+
return [root, ...workspacePackages];
|
|
49
|
+
}
|
|
50
|
+
/*** Reject ambiguous package names before resolving cross-project source imports. */
|
|
51
|
+
function assertUniqueFocusNames(packages) {
|
|
52
|
+
const named = packages.filter((packageContext) => packageContext.name !== undefined);
|
|
53
|
+
const duplicates = named.filter((item, index) => named.findIndex(({ name }) => name === item.name) !== index);
|
|
54
|
+
if (duplicates.length > 0) {
|
|
55
|
+
throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=createDependencyGraphFromInspectionsAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDependencyGraphFromInspectionsAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qCAAqC,EAAE,MAAM,yEAAyE,CAAC;AAChI,OAAO,EAAE,+BAA+B,EAAE,MAAM,mDAAmD,CAAC;AACpG,OAAO,EAAE,qCAAqC,EAAE,MAAM,oDAAoD,CAAC;AAE3G;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yCAAyC,CAC7D,KAAgD;IAEhD,+BAA+B,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE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I,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 CreateDependencyGraphFromInspectionsInput,\n DependencyGraph,\n DependencyGraphInspectionProjectInput,\n DependencyGraphPackage,\n} from '../../../types/dependencyGraph.js';\nimport { createSourceGraphFromInspectionsAsync } from '../../source-graph/composition/createSourceGraphFromInspectionsAsync.js';\nimport { assertDependencyGraphProjectIds } from '../application/assertDependencyGraphProjectIds.js';\nimport { projectDependencyGraphFromSourceGraph } from '../domain/projectDependencyGraphFromSourceGraph.js';\n\n/***\n * Build one canonical dependency graph from already-inspected projects without rescanning them.\n */\nexport async function createDependencyGraphFromInspectionsAsync(\n input: CreateDependencyGraphFromInspectionsInput,\n): Promise<DependencyGraph> {\n assertDependencyGraphProjectIds(input.projects);\n const inspected = input.projects.map(createInspectedInput);\n const packages = inspected.flatMap(({ packages: projectPackages }) => projectPackages);\n assertUniqueFocusNames(packages);\n const sourceGraph = await createSourceGraphFromInspectionsAsync({\n projects: input.projects,\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n return projectDependencyGraphFromSourceGraph(sourceGraph, packages, input.projects);\n}\n\ninterface InspectedInput {\n readonly packages: readonly DependencyGraphPackage[];\n}\n\n/*** Normalize one supplied inspection into dependency-analysis package contexts. */\nfunction createInspectedInput(project: DependencyGraphInspectionProjectInput): InspectedInput {\n const { inspection } = project;\n if (!inspection.complete) {\n throw new Error(\n `Dependency graph inspection is incomplete for \"${project.id}\": ${inspection.diagnostics\n .map(({ message }) => message)\n .join('; ')}`,\n );\n }\n\n const detectedPackages = selectFocusPackages(inspection);\n const packages = detectedPackages.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 return { packages };\n}\n\n/*** Select the repository 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 @@
|
|
|
1
|
+
{"version":3,"file":"extractCppPackageFromInclude.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractCppPackageFromInclude.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractCppPackageFromInclude.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractCppPackageFromInclude.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,UAAU,4BAA4B,CAAC,SAAiB;IAC5D,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*** Reduce a C++ include path to PKGViz-compatible package notation. */\nexport function extractCppPackageFromInclude(specifier: string): string {\n const withoutExtension = specifier.replace(/\\.(h|hpp|hxx)$/u, '');\n const segments = withoutExtension.split('/');\n if (segments.length <= 1) return '';\n return segments.slice(0, -1).join('.');\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDelphiPackageFromImport.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractDelphiPackageFromImport.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDelphiPackageFromImport.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractDelphiPackageFromImport.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,UAAU,8BAA8B,CAAC,SAAiB;IAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;IACjC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;AAC1C,CAAC","sourcesContent":["/*** Reduce a Delphi unit import to its PKGViz-compatible package target. */\nexport function extractDelphiPackageFromImport(specifier: string): string {\n const trimmed = specifier.trim();\n return trimmed.split('.')[0] ?? trimmed;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractJavaPackageFromImport.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractJavaPackageFromImport.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOtE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*** Reduce a Java import specifier to its package path using
|
|
1
|
+
/*** Reduce a Java import specifier to its package path using established projection semantics. */
|
|
2
2
|
export function extractJavaPackageFromImport(specifier) {
|
|
3
3
|
const cleaned = specifier.replace(/\.\*$/u, '');
|
|
4
4
|
const segments = cleaned.split('.').reverse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractJavaPackageFromImport.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractJavaPackageFromImport.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,UAAU,4BAA4B,CAAC,SAAiB;IAC5D,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACxC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACpF,IAAI,iBAAiB,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/*** Reduce a Java import specifier to its package path using established projection semantics. */\nexport function extractJavaPackageFromImport(specifier: string): string {\n const cleaned = specifier.replace(/\\.\\*$/u, '');\n const segments = cleaned.split('.').reverse();\n if (segments.length < 2) return cleaned;\n const firstPackageIndex = segments.findIndex((segment) => !/^[A-Z]/u.test(segment));\n if (firstPackageIndex < 0) return cleaned;\n return segments.slice(firstPackageIndex).reverse().join('.');\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractKotlinPackageFromImport.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractKotlinPackageFromImport.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractKotlinPackageFromImport.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractKotlinPackageFromImport.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,MAAM,UAAU,8BAA8B,CAAC,SAAiB;IAC9D,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IACtC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/*** Reduce a Kotlin import specifier to its package path using PKGViz-compatible semantics. */\nexport function extractKotlinPackageFromImport(specifier: string): string {\n const cleaned = specifier.replace(/\\.\\*$/u, '');\n const parts = cleaned.split('.');\n if (parts.length <= 1) return cleaned;\n return parts.slice(0, -1).join('.');\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractPythonPackageFromImport.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractPythonPackageFromImport.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractPythonPackageFromImport.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/extractPythonPackageFromImport.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,UAAU,8BAA8B,CAAC,SAAiB;IAC9D,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACzC,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;AAC9C,CAAC","sourcesContent":["/*** Reduce a Python import specifier to its PKGViz-compatible package target. */\nexport function extractPythonPackageFromImport(specifier: string): string {\n if (specifier.startsWith('.')) return '';\n return specifier.split('.')[0] ?? specifier;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DependencyGraph, DependencyGraphInspectionProjectInput, DependencyGraphPackage } from '../../../types/dependencyGraph.js';
|
|
2
|
+
import type { SourceGraph } from '../../../types/sourceGraph.js';
|
|
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;
|
|
5
|
+
//# sourceMappingURL=projectDependencyGraphFromSourceGraph.d.ts.map
|
package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts.map
ADDED
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createGraph } from '@ankhorage/graph';
|
|
2
|
+
import { createFocusPackageNode } from './createFocusPackageNode.js';
|
|
3
|
+
/*** Derive the established module/package dependency view from canonical source facts. */
|
|
4
|
+
export function projectDependencyGraphFromSourceGraph(sourceGraph, packages, projects) {
|
|
5
|
+
const detectedRoots = new Map(projects.map(({ id, inspection }) => [id, inspection.packages.map(({ rootPath }) => rootPath)]));
|
|
6
|
+
const nodes = new Map(packages.map((item) => [item.nodeId, createFocusPackageNode(item)]));
|
|
7
|
+
const edges = new Map();
|
|
8
|
+
const sourceNodes = new Map(sourceGraph.graph.nodes.map((node) => [node.id, node.data]));
|
|
9
|
+
const files = sourceGraph.graph.nodes.filter(({ data }) => data.kind === 'file' && data.analyzerId !== undefined);
|
|
10
|
+
for (const { data } of files) {
|
|
11
|
+
const owner = packageForFile(packages, detectedRoots, data);
|
|
12
|
+
if (owner !== undefined)
|
|
13
|
+
addModuleHierarchy(nodes, owner, moduleForFile(data, owner));
|
|
14
|
+
}
|
|
15
|
+
for (const edge of sourceGraph.graph.edges) {
|
|
16
|
+
if (edge.data.kind !== 'imports')
|
|
17
|
+
continue;
|
|
18
|
+
const source = sourceNodes.get(edge.source);
|
|
19
|
+
const target = sourceNodes.get(edge.target);
|
|
20
|
+
if (source === undefined || target === undefined)
|
|
21
|
+
continue;
|
|
22
|
+
const owner = packageForFile(packages, detectedRoots, source);
|
|
23
|
+
if (owner === undefined || source.analyzerId === undefined)
|
|
24
|
+
continue;
|
|
25
|
+
const sourceId = moduleNodeId(owner, moduleForFile(source, owner));
|
|
26
|
+
const targetId = projectTarget(target, owner, packages, detectedRoots, nodes);
|
|
27
|
+
if (targetId === undefined || targetId === sourceId)
|
|
28
|
+
continue;
|
|
29
|
+
addProjectedEdge(edges, sourceId, targetId, source.analyzerId, owner, edge.data.evidence, target);
|
|
30
|
+
}
|
|
31
|
+
return createGraph({ nodes: [...nodes.values()], edges: [...edges.values()] });
|
|
32
|
+
}
|
|
33
|
+
/*** Select the deepest focus package root containing one project-relative source file. */
|
|
34
|
+
function packageForFile(packages, detectedRoots, file) {
|
|
35
|
+
if (file.filePath === undefined)
|
|
36
|
+
return undefined;
|
|
37
|
+
const { filePath } = file;
|
|
38
|
+
const detected = (detectedRoots.get(file.projectId) ?? ['.'])
|
|
39
|
+
.filter((root) => root === '.' || filePath === root || filePath.startsWith(`${root}/`))
|
|
40
|
+
.sort((left, right) => right.length - left.length)[0] ?? '.';
|
|
41
|
+
if (!packages.some((item) => item.projectId === file.projectId && item.relativeRoot === detected))
|
|
42
|
+
return undefined;
|
|
43
|
+
return packages
|
|
44
|
+
.filter((item) => item.projectId === file.projectId &&
|
|
45
|
+
(item.relativeRoot === '.' ||
|
|
46
|
+
filePath === item.relativeRoot ||
|
|
47
|
+
filePath.startsWith(`${item.relativeRoot}/`)))
|
|
48
|
+
.sort((left, right) => right.relativeRoot.length - left.relativeRoot.length)[0];
|
|
49
|
+
}
|
|
50
|
+
/*** Read the established dotted module path from one analyzed source file. */
|
|
51
|
+
function moduleForFile(file, owner) {
|
|
52
|
+
if (file.analyzerId !== 'typescript')
|
|
53
|
+
return file.packageName ?? '';
|
|
54
|
+
const relative = owner.relativeRoot === '.'
|
|
55
|
+
? (file.filePath ?? '')
|
|
56
|
+
: (file.filePath ?? '').slice(owner.relativeRoot.length + 1);
|
|
57
|
+
const directory = relative.split('/').slice(0, -1).join('/');
|
|
58
|
+
return directory.split('/').filter(Boolean).join('.');
|
|
59
|
+
}
|
|
60
|
+
/*** Preserve the existing package/module node identity and dotted ancestor structure. */
|
|
61
|
+
function addModuleHierarchy(nodes, owner, modulePath) {
|
|
62
|
+
const parts = modulePath.split('.').filter(Boolean);
|
|
63
|
+
parts.forEach((_, index) => {
|
|
64
|
+
const current = parts.slice(0, index + 1).join('.');
|
|
65
|
+
const id = moduleNodeId(owner, current);
|
|
66
|
+
if (nodes.has(id))
|
|
67
|
+
return;
|
|
68
|
+
nodes.set(id, {
|
|
69
|
+
id,
|
|
70
|
+
data: {
|
|
71
|
+
kind: 'module',
|
|
72
|
+
classification: 'intrinsic',
|
|
73
|
+
focus: true,
|
|
74
|
+
label: parts.at(index) ?? current,
|
|
75
|
+
projectId: owner.projectId,
|
|
76
|
+
...(owner.name === undefined ? {} : { packageName: owner.name }),
|
|
77
|
+
path: current,
|
|
78
|
+
parentPath: index === 0 ? '' : parts.slice(0, index).join('.'),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/*** Resolve canonical import targets to stable package/module projection identities. */
|
|
84
|
+
function projectTarget(target, sourceOwner, packages, detectedRoots, nodes) {
|
|
85
|
+
if (target.classification === 'vendor' || target.classification === 'unknown') {
|
|
86
|
+
const name = target.packageName ?? target.name;
|
|
87
|
+
const id = `${target.classification}:${name}`;
|
|
88
|
+
if (!nodes.has(id))
|
|
89
|
+
nodes.set(id, {
|
|
90
|
+
id,
|
|
91
|
+
data: {
|
|
92
|
+
kind: 'package',
|
|
93
|
+
classification: target.classification,
|
|
94
|
+
focus: false,
|
|
95
|
+
label: name,
|
|
96
|
+
packageName: name,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
return id;
|
|
100
|
+
}
|
|
101
|
+
if (target.kind === 'package' && target.path !== undefined) {
|
|
102
|
+
return packages.find((item) => item.projectId === target.projectId && item.relativeRoot === target.path)?.nodeId;
|
|
103
|
+
}
|
|
104
|
+
const owner = target.filePath === undefined ? sourceOwner : packageForFile(packages, detectedRoots, target);
|
|
105
|
+
if (owner === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
const modulePath = target.analyzerId === 'typescript' || target.kind === 'file'
|
|
108
|
+
? moduleForFile(target, owner)
|
|
109
|
+
: (target.packageName ?? '');
|
|
110
|
+
addModuleHierarchy(nodes, owner, modulePath);
|
|
111
|
+
return moduleNodeId(owner, modulePath);
|
|
112
|
+
}
|
|
113
|
+
/*** Add one canonical import to a weighted package edge with original evidence. */
|
|
114
|
+
function addProjectedEdge(edges, sourceId, targetId, analyzerId, owner, evidence, target) {
|
|
115
|
+
const id = `${sourceId}->${targetId}`;
|
|
116
|
+
const previous = edges.get(id);
|
|
117
|
+
const classification = target.kind === 'package' && target.path !== undefined
|
|
118
|
+
? 'focus'
|
|
119
|
+
: (target.classification ?? 'unknown');
|
|
120
|
+
const observed = evidence.map((item) => ({
|
|
121
|
+
sourceFile: owner.relativeRoot === '.'
|
|
122
|
+
? item.sourcePath
|
|
123
|
+
: item.sourcePath.slice(owner.relativeRoot.length + 1),
|
|
124
|
+
specifier: item.specifier ?? '',
|
|
125
|
+
classification,
|
|
126
|
+
declarations: item.declarations ?? [],
|
|
127
|
+
}));
|
|
128
|
+
edges.set(id, {
|
|
129
|
+
id,
|
|
130
|
+
source: sourceId,
|
|
131
|
+
target: targetId,
|
|
132
|
+
data: {
|
|
133
|
+
kind: 'import',
|
|
134
|
+
analyzerId,
|
|
135
|
+
weight: (previous?.data.weight ?? 0) + observed.length,
|
|
136
|
+
evidence: [...(previous?.data.evidence ?? []), ...observed],
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/*** Preserve the legacy projection's readable package/module node ID. */
|
|
141
|
+
function moduleNodeId(owner, modulePath) {
|
|
142
|
+
return modulePath === '' ? owner.nodeId : `${owner.nodeId}#${modulePath}`;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=projectDependencyGraphFromSourceGraph.js.map
|
|
@@ -0,0 +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,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzF,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAC1C,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAA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E,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"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SourceFileFacts } from '../../../../types/sourceGraph.js';
|
|
2
|
+
/*** Map existing import-only analyzers into the canonical factual vocabulary. */
|
|
3
|
+
export declare function extractOtherLanguageFacts(analyzerId: 'cpp' | 'delphi' | 'kotlin' | 'python', content: string, file: string, packageRoot: string, sourceRoots: readonly string[]): SourceFileFacts;
|
|
4
|
+
//# sourceMappingURL=extractOtherLanguageFacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractOtherLanguageFacts.d.ts","sourceRoot":"","sources":["../../../../../src/features/source-graph/adapters/outbound/extractOtherLanguageFacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAQxE,iFAAiF;AACjF,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,EAClD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,eAAe,CA2BjB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { extractCppDependencies } from '../../../dependency-analysis/adapters/outbound/cpp/extractCppDependencies.js';
|
|
2
|
+
import { delphiPackageForFile } from '../../../dependency-analysis/adapters/outbound/delphi/delphiPackageForFile.js';
|
|
3
|
+
import { extractDelphiDependencies } from '../../../dependency-analysis/adapters/outbound/delphi/extractDelphiDependencies.js';
|
|
4
|
+
import { extractKotlinDependencies } from '../../../dependency-analysis/adapters/outbound/kotlin/extractKotlinDependencies.js';
|
|
5
|
+
import { extractPythonDependencies } from '../../../dependency-analysis/adapters/outbound/python/extractPythonDependencies.js';
|
|
6
|
+
import { pythonPackageForFile } from '../../../dependency-analysis/adapters/outbound/python/pythonPackageForFile.js';
|
|
7
|
+
/*** Map existing import-only analyzers into the canonical factual vocabulary. */
|
|
8
|
+
export function extractOtherLanguageFacts(analyzerId, content, file, packageRoot, sourceRoots) {
|
|
9
|
+
if (analyzerId === 'kotlin') {
|
|
10
|
+
const { packageName, imports } = extractKotlinDependencies(content);
|
|
11
|
+
return { packageName, imports: imports.map((specifier) => ({ specifier })), declarations: [] };
|
|
12
|
+
}
|
|
13
|
+
if (analyzerId === 'python') {
|
|
14
|
+
const { imports } = extractPythonDependencies(content);
|
|
15
|
+
return {
|
|
16
|
+
packageName: pythonPackageForFile(packageRoot, sourceRoots, file),
|
|
17
|
+
imports: imports.map((specifier) => ({ specifier })),
|
|
18
|
+
declarations: [],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (analyzerId === 'cpp') {
|
|
22
|
+
const { namespace, includes } = extractCppDependencies(content);
|
|
23
|
+
return {
|
|
24
|
+
packageName: namespace,
|
|
25
|
+
imports: includes.map(({ specifier, local }) => ({ specifier, local })),
|
|
26
|
+
declarations: [],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const { imports, unitName } = extractDelphiDependencies(content);
|
|
30
|
+
return {
|
|
31
|
+
packageName: delphiPackageForFile(packageRoot, sourceRoots, file, unitName),
|
|
32
|
+
imports: imports.map((specifier) => ({ specifier })),
|
|
33
|
+
declarations: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=extractOtherLanguageFacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractOtherLanguageFacts.js","sourceRoot":"","sources":["../../../../../src/features/source-graph/adapters/outbound/extractOtherLanguageFacts.ts"],"names":[],"m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E,SAAS;YACtB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACjE,OAAO;QACL,WAAW,EAAE,oBAAoB,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC;QAC3E,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACpD,YAAY,EAAE,EAAE;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { SourceFileFacts } from '../../../../types/sourceGraph.js';\nimport { extractCppDependencies } from '../../../dependency-analysis/adapters/outbound/cpp/extractCppDependencies.js';\nimport { delphiPackageForFile } from '../../../dependency-analysis/adapters/outbound/delphi/delphiPackageForFile.js';\nimport { extractDelphiDependencies } from '../../../dependency-analysis/adapters/outbound/delphi/extractDelphiDependencies.js';\nimport { extractKotlinDependencies } from '../../../dependency-analysis/adapters/outbound/kotlin/extractKotlinDependencies.js';\nimport { extractPythonDependencies } from '../../../dependency-analysis/adapters/outbound/python/extractPythonDependencies.js';\nimport { pythonPackageForFile } from '../../../dependency-analysis/adapters/outbound/python/pythonPackageForFile.js';\n\n/*** Map existing import-only analyzers into the canonical factual vocabulary. */\nexport function extractOtherLanguageFacts(\n analyzerId: 'cpp' | 'delphi' | 'kotlin' | 'python',\n content: string,\n file: string,\n packageRoot: string,\n sourceRoots: readonly string[],\n): SourceFileFacts {\n if (analyzerId === 'kotlin') {\n const { packageName, imports } = extractKotlinDependencies(content);\n return { packageName, imports: imports.map((specifier) => ({ specifier })), declarations: [] };\n }\n if (analyzerId === 'python') {\n const { imports } = extractPythonDependencies(content);\n return {\n packageName: pythonPackageForFile(packageRoot, sourceRoots, file),\n imports: imports.map((specifier) => ({ specifier })),\n declarations: [],\n };\n }\n if (analyzerId === 'cpp') {\n const { namespace, includes } = extractCppDependencies(content);\n return {\n packageName: namespace,\n imports: includes.map(({ specifier, local }) => ({ specifier, local })),\n declarations: [],\n };\n }\n const { imports, unitName } = extractDelphiDependencies(content);\n return {\n packageName: delphiPackageForFile(packageRoot, sourceRoots, file, unitName),\n imports: imports.map((specifier) => ({ specifier })),\n declarations: [],\n };\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CreateSourceGraphInput, SourceGraph } from '../../../types/sourceGraph.js';
|
|
2
|
+
/*** Inspect project roots, then build the canonical source graph from their bounded scan. */
|
|
3
|
+
export declare function createSourceGraphAsync(input: CreateSourceGraphInput): Promise<SourceGraph>;
|
|
4
|
+
//# sourceMappingURL=createSourceGraphAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSourceGraphAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGzF,6FAA6F;AAC7F,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAahG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { inspectProjectAsync } from '@ankhorage/project-detector/node';
|
|
2
|
+
import { createSourceGraphFromInspectionsAsync } from './createSourceGraphFromInspectionsAsync.js';
|
|
3
|
+
/*** Inspect project roots, then build the canonical source graph from their bounded scan. */
|
|
4
|
+
export async function createSourceGraphAsync(input) {
|
|
5
|
+
const projects = await Promise.all(input.projects.map(async ({ id, rootPath }) => ({
|
|
6
|
+
id,
|
|
7
|
+
inspection: await inspectProjectAsync(rootPath, {
|
|
8
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
9
|
+
}),
|
|
10
|
+
})));
|
|
11
|
+
return createSourceGraphFromInspectionsAsync({
|
|
12
|
+
projects,
|
|
13
|
+
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=createSourceGraphAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSourceGraphAsync.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAGvE,OAAO,EAAE,qCAAqC,EAAE,MAAM,4CAA4C,CAAC;AAEnG,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,KAA6B;IACxE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,EAAE;QACF,UAAU,EAAE,MAAM,mBAAmB,CAAC,QAAQ,EAAE;YAC9C,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;SAChE,CAAC;KACH,CAAC,CAAC,CACJ,CAAC;IACF,OAAO,qCAAqC,CAAC;QAC3C,QAAQ;QACR,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { inspectProjectAsync } from '@ankhorage/project-detector/node';\n\nimport type { CreateSourceGraphInput, SourceGraph } from '../../../types/sourceGraph.js';\nimport { createSourceGraphFromInspectionsAsync } from './createSourceGraphFromInspectionsAsync.js';\n\n/*** Inspect project roots, then build the canonical source graph from their bounded scan. */\nexport async function createSourceGraphAsync(input: CreateSourceGraphInput): Promise<SourceGraph> {\n const projects = await Promise.all(\n input.projects.map(async ({ id, rootPath }) => ({\n id,\n inspection: await inspectProjectAsync(rootPath, {\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n }),\n })),\n );\n return createSourceGraphFromInspectionsAsync({\n projects,\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n });\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CreateSourceGraphFromInspectionsInput, SourceGraph } from '../../../types/sourceGraph.js';
|
|
2
|
+
/*** Analyze inspected files once into a language-neutral factual source graph. */
|
|
3
|
+
export declare function createSourceGraphFromInspectionsAsync(input: CreateSourceGraphFromInspectionsInput): Promise<SourceGraph>;
|
|
4
|
+
//# sourceMappingURL=createSourceGraphFromInspectionsAsync.d.ts.map
|
|
@@ -0,0 +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;AASvC,kFAAkF;AAClF,wBAAsB,qCAAqC,CACzD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,WAAW,CAAC,CAWtB"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js';
|
|
4
|
+
import { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';
|
|
5
|
+
import { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';
|
|
6
|
+
import { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';
|
|
7
|
+
import { createSourceGraph } from '../domain/createSourceGraph.js';
|
|
8
|
+
import { createSourceRelationDraft } from '../domain/createSourceRelationDraft.js';
|
|
9
|
+
import { createSourceStructureDraft } from '../domain/createSourceStructureDraft.js';
|
|
10
|
+
/*** Analyze inspected files once into a language-neutral factual source graph. */
|
|
11
|
+
export async function createSourceGraphFromInspectionsAsync(input) {
|
|
12
|
+
assertProjects(input);
|
|
13
|
+
const files = (await Promise.all(input.projects.map(({ id, inspection }) => readProjectFilesAsync(id, inspection, input.signal)))).flat();
|
|
14
|
+
const structure = createSourceStructureDraft(input.projects, files);
|
|
15
|
+
return createSourceGraph(createSourceRelationDraft(structure, files));
|
|
16
|
+
}
|
|
17
|
+
/*** Read package declarations once and associate them with their owning source files. */
|
|
18
|
+
async function readProjectFilesAsync(projectId, inspection, signal) {
|
|
19
|
+
const declarations = await readPackageDeclarationsAsync(inspection);
|
|
20
|
+
return Promise.all(inspection.files.flatMap((file) => {
|
|
21
|
+
const analyzerId = analyzerForPath(file);
|
|
22
|
+
if (analyzerId === undefined)
|
|
23
|
+
return [];
|
|
24
|
+
const [owner] = inspection.packages
|
|
25
|
+
.filter(({ rootPath }) => rootPath === '.' || file.startsWith(`${rootPath}/`))
|
|
26
|
+
.sort((left, right) => right.rootPath.length - left.rootPath.length);
|
|
27
|
+
const root = owner?.rootPath ?? '.';
|
|
28
|
+
const sourceRoots = owner?.detection.languages.find(({ id }) => id === analyzerId)?.sourceRoots ??
|
|
29
|
+
defaultSourceRoots(analyzerId);
|
|
30
|
+
const relative = root === '.' ? file : file.slice(root.length + 1);
|
|
31
|
+
if (!sourceRoots.some((sourceRoot) => sourceRoot === '.' || relative.startsWith(`${sourceRoot}/`)))
|
|
32
|
+
return [];
|
|
33
|
+
return [
|
|
34
|
+
readAnalyzedFileAsync({
|
|
35
|
+
projectId,
|
|
36
|
+
file,
|
|
37
|
+
analyzerId,
|
|
38
|
+
projectRoot: inspection.rootPath,
|
|
39
|
+
packageRoot: path.resolve(inspection.rootPath, root),
|
|
40
|
+
sourceRoots,
|
|
41
|
+
declaredDependencies: declarations.get(root),
|
|
42
|
+
signal,
|
|
43
|
+
}),
|
|
44
|
+
];
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
/*** Preserve manifest declaration evidence at the package that owns each source file. */
|
|
48
|
+
async function readPackageDeclarationsAsync(inspection) {
|
|
49
|
+
const entries = await Promise.all(inspection.packages.map(async (item) => [
|
|
50
|
+
item.rootPath,
|
|
51
|
+
item.manifestPath.endsWith('.json')
|
|
52
|
+
? await readDependencyDeclarationsAsync(path.join(inspection.rootPath, item.manifestPath))
|
|
53
|
+
: {},
|
|
54
|
+
]));
|
|
55
|
+
return new Map(entries);
|
|
56
|
+
}
|
|
57
|
+
async function readAnalyzedFileAsync(input) {
|
|
58
|
+
input.signal?.throwIfAborted();
|
|
59
|
+
const absolute = path.resolve(input.projectRoot, ...input.file.split('/'));
|
|
60
|
+
const content = await readFile(absolute, 'utf8');
|
|
61
|
+
input.signal?.throwIfAborted();
|
|
62
|
+
return {
|
|
63
|
+
projectId: input.projectId,
|
|
64
|
+
path: input.file,
|
|
65
|
+
analyzerId: input.analyzerId,
|
|
66
|
+
...(input.declaredDependencies === undefined
|
|
67
|
+
? {}
|
|
68
|
+
: { declaredDependencies: input.declaredDependencies }),
|
|
69
|
+
facts: input.analyzerId === 'java'
|
|
70
|
+
? extractJavaSourceFacts(content)
|
|
71
|
+
: input.analyzerId === 'typescript'
|
|
72
|
+
? extractTypeScriptSourceFacts(input.file, content)
|
|
73
|
+
: extractOtherLanguageFacts(input.analyzerId, content, absolute, input.packageRoot, input.sourceRoots),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/*** Declare supported parsers without attributing their capabilities to other languages. */
|
|
77
|
+
function analyzerForPath(file) {
|
|
78
|
+
if (file.endsWith('.java'))
|
|
79
|
+
return 'java';
|
|
80
|
+
if (['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension))) {
|
|
81
|
+
return 'typescript';
|
|
82
|
+
}
|
|
83
|
+
if (file.endsWith('.kt') || file.endsWith('.kts'))
|
|
84
|
+
return 'kotlin';
|
|
85
|
+
if (file.endsWith('.py') || file.endsWith('.pyi'))
|
|
86
|
+
return 'python';
|
|
87
|
+
if (['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)))
|
|
88
|
+
return 'cpp';
|
|
89
|
+
if (['.pas', '.pp', '.dpr'].some((extension) => file.toLowerCase().endsWith(extension)))
|
|
90
|
+
return 'delphi';
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/*** Preserve existing analyzer source-root defaults for import-only languages. */
|
|
94
|
+
function defaultSourceRoots(analyzerId) {
|
|
95
|
+
if (analyzerId === 'java')
|
|
96
|
+
return ['src/main/java', '.'];
|
|
97
|
+
if (analyzerId === 'kotlin')
|
|
98
|
+
return ['src/main/kotlin', 'src', '.'];
|
|
99
|
+
if (analyzerId === 'python')
|
|
100
|
+
return ['src', 'app', '.'];
|
|
101
|
+
if (analyzerId === 'delphi')
|
|
102
|
+
return ['src', 'Source', '.'];
|
|
103
|
+
return ['.'];
|
|
104
|
+
}
|
|
105
|
+
/*** Reject duplicate project identities and incomplete scans before reading any source. */
|
|
106
|
+
function assertProjects(input) {
|
|
107
|
+
const ids = new Set();
|
|
108
|
+
for (const project of input.projects) {
|
|
109
|
+
if (project.id.trim() === '' || ids.has(project.id)) {
|
|
110
|
+
throw new Error(`Invalid or duplicate source graph project ID: ${project.id}.`);
|
|
111
|
+
}
|
|
112
|
+
if (!project.inspection.complete) {
|
|
113
|
+
throw new Error(`Source graph inspection is incomplete for ${project.id}.`);
|
|
114
|
+
}
|
|
115
|
+
ids.add(project.id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=createSourceGraphFromInspectionsAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSourceGraphFromInspectionsAsync.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,4EAA4E,CAAC;AACpH,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,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,KAA4C;IAE5C,cAAc,CAAC,KAAK,CAAC,CAAC;IACtB,MAAM,KAAK,GAAG,CACZ,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CACxC,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CACpD,CACF,CACF,CAAC,IAAI,EAAE,CAAC;IACT,MAAM,SAAS,GAAG,0BAA0B,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpE,OAAO,iBAAiB,CAAC,yBAAyB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,yFAAyF;AACzF,KAAK,UAAU,qBAAqB,CAClC,SAA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AO,CAAC,EAAE,GAAG,CAAC,CAAC;QAC9E,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateSourceGraphFromInspectionsInput,\n SourceAnalyzedFile,\n SourceGraph,\n} from '../../../types/sourceGraph.js';\nimport { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.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 { createSourceGraph } from '../domain/createSourceGraph.js';\nimport { createSourceRelationDraft } from '../domain/createSourceRelationDraft.js';\nimport { createSourceStructureDraft } from '../domain/createSourceStructureDraft.js';\n\n/*** Analyze inspected files once into a language-neutral factual source graph. */\nexport async function createSourceGraphFromInspectionsAsync(\n input: CreateSourceGraphFromInspectionsInput,\n): Promise<SourceGraph> {\n assertProjects(input);\n const files = (\n await Promise.all(\n input.projects.map(({ id, inspection }) =>\n readProjectFilesAsync(id, inspection, input.signal),\n ),\n )\n ).flat();\n const structure = createSourceStructureDraft(input.projects, files);\n return createSourceGraph(createSourceRelationDraft(structure, files));\n}\n\n/*** Read package declarations once and associate them with their owning source files. */\nasync function readProjectFilesAsync(\n projectId: string,\n inspection: ProjectInspection,\n signal: AbortSignal | undefined,\n): Promise<readonly SourceAnalyzedFile[]> {\n const declarations = await readPackageDeclarationsAsync(inspection);\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 signal,\n }),\n ];\n }),\n );\n}\n\n/*** Preserve manifest declaration evidence at the package that owns each source file. */\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\n/*** Read one inspected source path and map its parser facts into the common contract. */\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 signal: AbortSignal | undefined;\n}\n\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 ? extractTypeScriptSourceFacts(input.file, content)\n : extractOtherLanguageFacts(\n input.analyzerId,\n content,\n absolute,\n input.packageRoot,\n input.sourceRoots,\n ),\n };\n}\n\n/*** Declare supported parsers without attributing their capabilities to other languages. */\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 }\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/*** Preserve existing analyzer source-root defaults for import-only languages. */\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/*** Reject duplicate project identities and incomplete scans before reading any source. */\nfunction assertProjects(input: CreateSourceGraphFromInspectionsInput): void {\n const ids = new Set<string>();\n for (const project of input.projects) {\n if (project.id.trim() === '' || ids.has(project.id)) {\n throw new Error(`Invalid or duplicate source graph project ID: ${project.id}.`);\n }\n if (!project.inspection.complete) {\n throw new Error(`Source graph inspection is incomplete for ${project.id}.`);\n }\n ids.add(project.id);\n }\n}\n"]}
|