@ankhorage/dependency-graph 1.3.1 → 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 +6 -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 +1 -1
  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
@@ -1,121 +1,12 @@
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 { createTypeScriptImportResolver } from '../../dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js';
5
- import { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';
6
- import { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';
7
- import { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';
8
- import { createSourceGraph } from '../domain/createSourceGraph.js';
9
- import { createSourceRelationDraft } from '../domain/createSourceRelationDraft.js';
10
- import { createSourceStructureDraft } from '../domain/createSourceStructureDraft.js';
1
+ import { createProjectAnalysisSnapshotAsync } from './createProjectAnalysisSnapshotAsync.js';
2
+ import { createSourceGraphFromProjectAnalysisSnapshots } from './createSourceGraphFromProjectAnalysisSnapshots.js';
11
3
  /*** Analyze inspected files once into a language-neutral factual source graph. */
12
4
  export async function createSourceGraphFromInspectionsAsync(input) {
13
- assertProjects(input);
14
- const files = (await Promise.all(input.projects.map(({ id, inspection }) => readProjectFilesAsync(id, inspection, input.signal)))).flat();
15
- const structure = createSourceStructureDraft(input.projects, files);
16
- return createSourceGraph(createSourceRelationDraft(structure, files));
17
- }
18
- /*** Read package declarations once and associate them with their owning source files. */
19
- async function readProjectFilesAsync(projectId, inspection, signal) {
20
- const declarations = await readPackageDeclarationsAsync(inspection);
21
- const resolveTypeScriptImports = createTypeScriptImportResolver(inspection.rootPath);
22
- return Promise.all(inspection.files.flatMap((file) => {
23
- const analyzerId = analyzerForPath(file);
24
- if (analyzerId === undefined)
25
- return [];
26
- const [owner] = inspection.packages
27
- .filter(({ rootPath }) => rootPath === '.' || file.startsWith(`${rootPath}/`))
28
- .sort((left, right) => right.rootPath.length - left.rootPath.length);
29
- const root = owner?.rootPath ?? '.';
30
- const sourceRoots = owner?.detection.languages.find(({ id }) => id === analyzerId)?.sourceRoots ??
31
- defaultSourceRoots(analyzerId);
32
- const relative = root === '.' ? file : file.slice(root.length + 1);
33
- if (!sourceRoots.some((sourceRoot) => sourceRoot === '.' || relative.startsWith(`${sourceRoot}/`)))
34
- return [];
35
- return [
36
- readAnalyzedFileAsync({
37
- projectId,
38
- file,
39
- analyzerId,
40
- projectRoot: inspection.rootPath,
41
- packageRoot: path.resolve(inspection.rootPath, root),
42
- sourceRoots,
43
- declaredDependencies: declarations.get(root),
44
- resolveTypeScriptImports,
45
- signal,
46
- }),
47
- ];
48
- }));
49
- }
50
- /*** Preserve manifest declaration evidence at the package that owns each source file. */
51
- async function readPackageDeclarationsAsync(inspection) {
52
- const entries = await Promise.all(inspection.packages.map(async (item) => [
53
- item.rootPath,
54
- item.manifestPath.endsWith('.json')
55
- ? await readDependencyDeclarationsAsync(path.join(inspection.rootPath, item.manifestPath))
56
- : {},
57
- ]));
58
- return new Map(entries);
59
- }
60
- async function readAnalyzedFileAsync(input) {
61
- input.signal?.throwIfAborted();
62
- const absolute = path.resolve(input.projectRoot, ...input.file.split('/'));
63
- const content = await readFile(absolute, 'utf8');
64
- input.signal?.throwIfAborted();
65
- return {
66
- projectId: input.projectId,
67
- path: input.file,
68
- analyzerId: input.analyzerId,
69
- ...(input.declaredDependencies === undefined
70
- ? {}
71
- : { declaredDependencies: input.declaredDependencies }),
72
- facts: input.analyzerId === 'java'
73
- ? extractJavaSourceFacts(content)
74
- : input.analyzerId === 'typescript'
75
- ? input.resolveTypeScriptImports(absolute, input.packageRoot, extractTypeScriptSourceFacts(input.file, content))
76
- : extractOtherLanguageFacts(input.analyzerId, content, absolute, input.packageRoot, input.sourceRoots),
77
- };
78
- }
79
- /*** Declare supported parsers without attributing their capabilities to other languages. */
80
- function analyzerForPath(file) {
81
- if (file.endsWith('.java'))
82
- return 'java';
83
- if (['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension))) {
84
- return 'typescript';
85
- }
86
- if (file.endsWith('.kt') || file.endsWith('.kts'))
87
- return 'kotlin';
88
- if (file.endsWith('.py') || file.endsWith('.pyi'))
89
- return 'python';
90
- if (['.cpp', '.cc', '.cxx', '.h', '.hpp', '.hxx'].some((extension) => file.endsWith(extension)))
91
- return 'cpp';
92
- if (['.pas', '.pp', '.dpr'].some((extension) => file.toLowerCase().endsWith(extension)))
93
- return 'delphi';
94
- return undefined;
95
- }
96
- /*** Preserve existing analyzer source-root defaults for import-only languages. */
97
- function defaultSourceRoots(analyzerId) {
98
- if (analyzerId === 'java')
99
- return ['src/main/java', '.'];
100
- if (analyzerId === 'kotlin')
101
- return ['src/main/kotlin', 'src', '.'];
102
- if (analyzerId === 'python')
103
- return ['src', 'app', '.'];
104
- if (analyzerId === 'delphi')
105
- return ['src', 'Source', '.'];
106
- return ['.'];
107
- }
108
- /*** Reject duplicate project identities and incomplete scans before reading any source. */
109
- function assertProjects(input) {
110
- const ids = new Set();
111
- for (const project of input.projects) {
112
- if (project.id.trim() === '' || ids.has(project.id)) {
113
- throw new Error(`Invalid or duplicate source graph project ID: ${project.id}.`);
114
- }
115
- if (!project.inspection.complete) {
116
- throw new Error(`Source graph inspection is incomplete for ${project.id}.`);
117
- }
118
- ids.add(project.id);
119
- }
5
+ const snapshots = await Promise.all(input.projects.map(({ id, inspection }) => createProjectAnalysisSnapshotAsync({
6
+ id,
7
+ inspection,
8
+ ...(input.signal === undefined ? {} : { signal: input.signal }),
9
+ })));
10
+ return createSourceGraphFromProjectAnalysisSnapshots(snapshots);
120
11
  }
121
12
  //# sourceMappingURL=createSourceGraphFromInspectionsAsync.js.map
@@ -1 +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,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,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,EA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GAAG,CAAC,CAAC;AACf,CAAC;AAED,2FAA2F;AAC3F,SAAS,cAAc,CAAC,KAA4C;IAClE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,iDAAiD,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,6CAA6C,OAAO,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 { 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 { 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 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 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 resolveTypeScriptImports: ReturnType<typeof createTypeScriptImportResolver>;\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 ? 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/*** 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"]}
1
+ {"version":3,"file":"createSourceGraphFromInspectionsAsync.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,6CAA6C,EAAE,MAAM,oDAAoD,CAAC;AAEnH,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,KAA4C;IAE5C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CACxC,kCAAkC,CAAC;QACjC,EAAE;QACF,UAAU;QACV,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CACH,CACF,CAAC;IACF,OAAO,6CAA6C,CAAC,SAAS,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type {\n CreateSourceGraphFromInspectionsInput,\n SourceGraph,\n} from '../../../types/sourceGraph.js';\nimport { createProjectAnalysisSnapshotAsync } from './createProjectAnalysisSnapshotAsync.js';\nimport { createSourceGraphFromProjectAnalysisSnapshots } from './createSourceGraphFromProjectAnalysisSnapshots.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 const snapshots = await Promise.all(\n input.projects.map(({ id, inspection }) =>\n createProjectAnalysisSnapshotAsync({\n id,\n inspection,\n ...(input.signal === undefined ? {} : { signal: input.signal }),\n }),\n ),\n );\n return createSourceGraphFromProjectAnalysisSnapshots(snapshots);\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
2
+ import type { SourceGraph } from '../../../types/sourceGraph.js';
3
+ /*** Recompose portable project facts through the canonical structure and relation pipeline. */
4
+ export declare function createSourceGraphFromProjectAnalysisSnapshots(snapshots: readonly ProjectAnalysisSnapshot[]): SourceGraph;
5
+ //# sourceMappingURL=createSourceGraphFromProjectAnalysisSnapshots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSourceGraphFromProjectAnalysisSnapshots.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,KAAK,EAAsB,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAMrF,+FAA+F;AAC/F,wBAAgB,6CAA6C,CAC3D,SAAS,EAAE,SAAS,uBAAuB,EAAE,GAC5C,WAAW,CAeb"}
@@ -0,0 +1,31 @@
1
+ import { createSourceGraph } from '../domain/createSourceGraph.js';
2
+ import { createSourceRelationDraft } from '../domain/createSourceRelationDraft.js';
3
+ import { createSourceStructureDraft } from '../domain/createSourceStructureDraft.js';
4
+ import { assertProjectAnalysisSnapshot } from '../domain/projectAnalysisSnapshot.js';
5
+ /*** Recompose portable project facts through the canonical structure and relation pipeline. */
6
+ export function createSourceGraphFromProjectAnalysisSnapshots(snapshots) {
7
+ assertSnapshots(snapshots);
8
+ const files = snapshots.flatMap((snapshot) => snapshot.analyzedFiles.map((file) => ({
9
+ projectId: snapshot.projectId,
10
+ analyzerId: file.analyzerId,
11
+ facts: file.facts,
12
+ path: file.path,
13
+ ...(file.declaredDependencies === undefined
14
+ ? {}
15
+ : { declaredDependencies: file.declaredDependencies }),
16
+ })));
17
+ const structure = createSourceStructureDraft(snapshots, files);
18
+ return createSourceGraph(createSourceRelationDraft(structure, files));
19
+ }
20
+ /*** Reject duplicate identities and unsupported snapshot contracts before any relation is resolved. */
21
+ function assertSnapshots(snapshots) {
22
+ const ids = new Set();
23
+ for (const snapshot of snapshots) {
24
+ assertProjectAnalysisSnapshot(snapshot);
25
+ if (ids.has(snapshot.projectId)) {
26
+ throw new Error(`Duplicate project analysis snapshot ID: ${snapshot.projectId}.`);
27
+ }
28
+ ids.add(snapshot.projectId);
29
+ }
30
+ }
31
+ //# sourceMappingURL=createSourceGraphFromProjectAnalysisSnapshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSourceGraphFromProjectAnalysisSnapshots.js","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromProjectAnalysisSnapshots.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAErF,+FAA+F;AAC/F,MAAM,UAAU,6CAA6C,CAC3D,SAA6C;IAE7C,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC3C,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAsB,EAAE,CAAC,CAAC;QACxD,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,CAAC,IAAI,CAAC,oBAAoB,KAAK,SAAS;YACzC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC;KACzD,CAAC,CAAC,CACJ,CAAC;IACF,MAAM,SAAS,GAAG,0BAA0B,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC/D,OAAO,iBAAiB,CAAC,yBAAyB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,uGAAuG;AACvG,SAAS,eAAe,CAAC,SAA6C;IACpE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,2CAA2C,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC;QACpF,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC","sourcesContent":["import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';\nimport type { SourceAnalyzedFile, SourceGraph } from '../../../types/sourceGraph.js';\nimport { createSourceGraph } from '../domain/createSourceGraph.js';\nimport { createSourceRelationDraft } from '../domain/createSourceRelationDraft.js';\nimport { createSourceStructureDraft } from '../domain/createSourceStructureDraft.js';\nimport { assertProjectAnalysisSnapshot } from '../domain/projectAnalysisSnapshot.js';\n\n/*** Recompose portable project facts through the canonical structure and relation pipeline. */\nexport function createSourceGraphFromProjectAnalysisSnapshots(\n snapshots: readonly ProjectAnalysisSnapshot[],\n): SourceGraph {\n assertSnapshots(snapshots);\n const files = snapshots.flatMap((snapshot) =>\n snapshot.analyzedFiles.map((file): SourceAnalyzedFile => ({\n projectId: snapshot.projectId,\n analyzerId: file.analyzerId,\n facts: file.facts,\n path: file.path,\n ...(file.declaredDependencies === undefined\n ? {}\n : { declaredDependencies: file.declaredDependencies }),\n })),\n );\n const structure = createSourceStructureDraft(snapshots, files);\n return createSourceGraph(createSourceRelationDraft(structure, files));\n}\n\n/*** Reject duplicate identities and unsupported snapshot contracts before any relation is resolved. */\nfunction assertSnapshots(snapshots: readonly ProjectAnalysisSnapshot[]): void {\n const ids = new Set<string>();\n for (const snapshot of snapshots) {\n assertProjectAnalysisSnapshot(snapshot);\n if (ids.has(snapshot.projectId)) {\n throw new Error(`Duplicate project analysis snapshot ID: ${snapshot.projectId}.`);\n }\n ids.add(snapshot.projectId);\n }\n}\n"]}
@@ -1,11 +1,6 @@
1
- import type { ProjectInspection } from '@ankhorage/project-detector/types';
1
+ import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
2
2
  import type { SourceAnalyzedFile, SourceGraphDraft } from '../../../types/sourceGraph.js';
3
- interface SourceProject {
4
- readonly id: string;
5
- readonly inspection: ProjectInspection;
6
- }
7
3
  /*** Preserve scanned projects, packages, empty directories, files, and nested declarations. */
8
- export declare function createSourceStructureDraft(projects: readonly SourceProject[], files: readonly SourceAnalyzedFile[]): SourceGraphDraft;
4
+ export declare function createSourceStructureDraft(projects: readonly ProjectAnalysisSnapshot[], files: readonly SourceAnalyzedFile[]): SourceGraphDraft;
9
5
  export declare function fileKey(projectId: string, file: string): string;
10
- export {};
11
6
  //# sourceMappingURL=createSourceStructureDraft.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createSourceStructureDraft.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceStructureDraft.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,KAAK,EACV,kBAAkB,EAElB,gBAAgB,EAIjB,MAAM,+BAA+B,CAAC;AAGvC,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;CACxC;AAED,+FAA+F;AAC/F,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,gBAAgB,CAoBlB;AA8RD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D"}
1
+ {"version":3,"file":"createSourceStructureDraft.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceStructureDraft.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,KAAK,EACV,kBAAkB,EAElB,gBAAgB,EAIjB,MAAM,+BAA+B,CAAC;AAGvC,+FAA+F;AAC/F,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,gBAAgB,CAelB;AA6PD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D"}
@@ -9,46 +9,37 @@ export function createSourceStructureDraft(projects, files) {
9
9
  return {
10
10
  nodes: [...nodes.values()],
11
11
  edges,
12
- capabilities: projects.flatMap(({ id, inspection }) => {
13
- const analyzers = new Set([
14
- 'project-detector',
15
- ...inspection.detection.languages.map(({ id: languageId }) => languageId),
16
- ...files.filter((file) => file.projectId === id).map((file) => file.analyzerId),
17
- ]);
18
- return [...analyzers].map((analyzerId) => ({
19
- projectId: id,
20
- analyzerId,
21
- available: analyzerCapabilities(analyzerId),
22
- }));
23
- }),
12
+ capabilities: projects.flatMap(({ projectId, analyzers }) => analyzers.map(({ id: analyzerId, capabilities: available }) => ({
13
+ projectId,
14
+ analyzerId,
15
+ available,
16
+ }))),
24
17
  };
25
18
  }
26
19
  /*** Add the physical containment tree for one inspected project. */
27
20
  function addProject(project, analyzedFiles, nodes, edges) {
28
- const { id, inspection } = project;
29
- if (!inspection.complete)
30
- throw new Error(`Source graph inspection is incomplete for ${id}.`);
31
- const projectKey = sourceSemanticPath('project', id);
32
- addNode(nodes, { semanticPath: projectKey, kind: 'project', name: id, projectId: id });
33
- const packageRoots = new Set(['.', ...inspection.packages.map(({ rootPath }) => rootPath)]);
21
+ const { projectId } = project;
22
+ const projectKey = sourceSemanticPath('project', projectId);
23
+ addNode(nodes, { semanticPath: projectKey, kind: 'project', name: projectId, projectId });
24
+ const packageRoots = new Set(['.', ...project.packages.map(({ rootPath }) => rootPath)]);
34
25
  addPackages(project, packageRoots, projectKey, nodes, edges);
35
26
  addDirectories(project, packageRoots, nodes, edges);
36
27
  addFiles(project, packageRoots, nodes, edges);
37
- for (const file of analyzedFiles.filter((item) => item.projectId === id)) {
28
+ for (const file of analyzedFiles.filter((item) => item.projectId === projectId)) {
38
29
  addFileFacts(file, nodes, edges);
39
30
  }
40
31
  }
41
32
  /*** Preserve package and workspace roots as explicit containment boundaries. */
42
33
  function addPackages(project, packageRoots, projectKey, nodes, edges) {
43
- const { id, inspection } = project;
34
+ const { projectId } = project;
44
35
  for (const root of packageRoots) {
45
- const key = packageKey(id, root);
46
- const name = inspection.packages.find(({ rootPath }) => rootPath === root)?.name ?? root;
36
+ const key = packageKey(projectId, root);
37
+ const name = project.packages.find(({ rootPath }) => rootPath === root)?.name ?? root;
47
38
  addNode(nodes, {
48
39
  semanticPath: key,
49
40
  kind: 'package',
50
41
  name,
51
- projectId: id,
42
+ projectId,
52
43
  path: root,
53
44
  classification: 'intrinsic',
54
45
  });
@@ -57,41 +48,43 @@ function addPackages(project, packageRoots, projectKey, nodes, edges) {
57
48
  }
58
49
  /*** Preserve empty directories and their exact scanned hierarchy. */
59
50
  function addDirectories(project, packageRoots, nodes, edges) {
60
- const { id, inspection } = project;
61
- for (const directory of inspection.directories.filter((item) => item !== '.')) {
51
+ const { projectId } = project;
52
+ for (const directory of project.directories.filter((item) => item !== '.')) {
62
53
  const root = owningPackageRoot(directory, packageRoots);
63
54
  if (directory === root)
64
55
  continue;
65
- const key = directoryKey(id, directory);
56
+ const key = directoryKey(projectId, directory);
66
57
  addNode(nodes, {
67
58
  semanticPath: key,
68
59
  kind: 'directory',
69
60
  name: path.posix.basename(directory),
70
- projectId: id,
61
+ projectId,
71
62
  path: directory,
72
63
  classification: 'intrinsic',
73
64
  });
74
65
  const parent = path.posix.dirname(directory);
75
- addContains(edges, parent === root ? packageKey(id, root) : directoryKey(id, parent), key, 'project-detector', directory);
66
+ addContains(edges, parent === root ? packageKey(projectId, root) : directoryKey(projectId, parent), key, 'project-detector', directory);
76
67
  }
77
68
  }
78
69
  /*** Preserve all inspected files, including files without an implemented language parser. */
79
70
  function addFiles(project, packageRoots, nodes, edges) {
80
- const { id, inspection } = project;
81
- for (const file of inspection.files) {
71
+ const { projectId } = project;
72
+ for (const file of project.files) {
82
73
  const root = owningPackageRoot(file, packageRoots);
83
74
  const parent = path.posix.dirname(file);
84
- const key = fileKey(id, file);
75
+ const key = fileKey(projectId, file);
85
76
  addNode(nodes, {
86
77
  semanticPath: key,
87
78
  kind: 'file',
88
79
  name: path.posix.basename(file),
89
- projectId: id,
80
+ projectId,
90
81
  path: file,
91
82
  filePath: file,
92
83
  classification: 'intrinsic',
93
84
  });
94
- addContains(edges, parent === root || parent === '.' ? packageKey(id, root) : directoryKey(id, parent), key, 'project-detector', file);
85
+ addContains(edges, parent === root || parent === '.'
86
+ ? packageKey(projectId, root)
87
+ : directoryKey(projectId, parent), key, 'project-detector', file);
95
88
  }
96
89
  }
97
90
  /*** Attach portable declarations and their observed documentation to a source file. */
@@ -170,39 +163,6 @@ function addDeclaration(file, declaration, parent, nodes, edges) {
170
163
  for (const child of declaration.children)
171
164
  addDeclaration(file, child, key, nodes, edges);
172
165
  }
173
- /*** Define source facts that each parser actually emits. */
174
- function analyzerCapabilities(analyzerId) {
175
- if (analyzerId === 'project-detector')
176
- return ['containment'];
177
- if (analyzerId === 'java')
178
- return [
179
- 'containment',
180
- 'declarations',
181
- 'documentation',
182
- 'extends',
183
- 'implements',
184
- 'imports',
185
- 'signatures',
186
- 'source-locations',
187
- 'visibility',
188
- ];
189
- if (analyzerId === 'typescript')
190
- return [
191
- 'containment',
192
- 'declarations',
193
- 'documentation',
194
- 'exports',
195
- 'extends',
196
- 'implements',
197
- 'imports',
198
- 'signatures',
199
- 'source-locations',
200
- 'visibility',
201
- ];
202
- if (['cpp', 'delphi', 'kotlin', 'python'].includes(analyzerId))
203
- return ['imports'];
204
- return [];
205
- }
206
166
  /*** Select the deepest workspace/package root that owns a portable source path. */
207
167
  function owningPackageRoot(file, roots) {
208
168
  return ([...roots]
@@ -1 +1 @@
1
- {"version":3,"file":"createSourceStructureDraft.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceStructureDraft.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAY7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAO7D,+FAA+F;AAC/F,MAAM,UAAU,0BAA0B,CACxC,QAAkC,EAClC,KAAoC;IAEpC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IACjD,MAAM,KAAK,GAAsB,EAAE,CA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,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,iEAAiE;AACjE,SAAS,WAAW,CAClB,KAAwB,EACxB,MAAc,EACd,MAAc,EACd,UAAkB,EAClB,UAAkB,EAClB,QAA6C;IAE7C,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE;QAC7C,UAAU;QACV,UAAU;QACV,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;KAChD,CAAC,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,SAAS,WAAW,CAClB,KAAwB,EACxB,MAAc,EACd,MAAc,EACd,IAAqC,EACrC,QAAgC;IAEhC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,UAAU,CAAC,SAAiB,EAAE,IAAY;IACjD,OAAO,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,SAAiB,EAAE,SAAiB;IACxD,OAAO,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,SAAiB,EAAE,IAAY;IACrD,OAAO,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import path from 'node:path';\n\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n SourceAnalyzedFile,\n SourceEdgeDraft,\n SourceGraphDraft,\n SourceNodeData,\n SourceNodeDraft,\n SourceRelationEvidence,\n} from '../../../types/sourceGraph.js';\nimport { sourceSemanticPath } from './sourceSemanticPath.js';\n\ninterface SourceProject {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\n/*** Preserve scanned projects, packages, empty directories, files, and nested declarations. */\nexport function createSourceStructureDraft(\n projects: readonly SourceProject[],\n files: readonly SourceAnalyzedFile[],\n): SourceGraphDraft {\n const nodes = new Map<string, SourceNodeDraft>();\n const edges: SourceEdgeDraft[] = [];\n for (const project of projects) addProject(project, files, nodes, edges);\n return {\n nodes: [...nodes.values()],\n edges,\n capabilities: projects.flatMap(({ id, inspection }) => {\n const analyzers = new Set([\n 'project-detector',\n ...inspection.detection.languages.map(({ id: languageId }) => languageId),\n ...files.filter((file) => file.projectId === id).map((file) => file.analyzerId),\n ]);\n return [...analyzers].map((analyzerId) => ({\n projectId: id,\n analyzerId,\n available: analyzerCapabilities(analyzerId),\n }));\n }),\n };\n}\n\n/*** Add the physical containment tree for one inspected project. */\nfunction addProject(\n project: SourceProject,\n analyzedFiles: readonly SourceAnalyzedFile[],\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { id, inspection } = project;\n if (!inspection.complete) throw new Error(`Source graph inspection is incomplete for ${id}.`);\n const projectKey = sourceSemanticPath('project', id);\n addNode(nodes, { semanticPath: projectKey, kind: 'project', name: id, projectId: id });\n const packageRoots = new Set(['.', ...inspection.packages.map(({ rootPath }) => rootPath)]);\n addPackages(project, packageRoots, projectKey, nodes, edges);\n addDirectories(project, packageRoots, nodes, edges);\n addFiles(project, packageRoots, nodes, edges);\n for (const file of analyzedFiles.filter((item) => item.projectId === id)) {\n addFileFacts(file, nodes, edges);\n }\n}\n\n/*** Preserve package and workspace roots as explicit containment boundaries. */\nfunction addPackages(\n project: SourceProject,\n packageRoots: ReadonlySet<string>,\n projectKey: string,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { id, inspection } = project;\n for (const root of packageRoots) {\n const key = packageKey(id, root);\n const name = inspection.packages.find(({ rootPath }) => rootPath === root)?.name ?? root;\n addNode(nodes, {\n semanticPath: key,\n kind: 'package',\n name,\n projectId: id,\n path: root,\n classification: 'intrinsic',\n });\n addContains(edges, projectKey, key, 'project-detector', root);\n }\n}\n\n/*** Preserve empty directories and their exact scanned hierarchy. */\nfunction addDirectories(\n project: SourceProject,\n packageRoots: ReadonlySet<string>,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { id, inspection } = project;\n for (const directory of inspection.directories.filter((item) => item !== '.')) {\n const root = owningPackageRoot(directory, packageRoots);\n if (directory === root) continue;\n const key = directoryKey(id, directory);\n addNode(nodes, {\n semanticPath: key,\n kind: 'directory',\n name: path.posix.basename(directory),\n projectId: id,\n path: directory,\n classification: 'intrinsic',\n });\n const parent = path.posix.dirname(directory);\n addContains(\n edges,\n parent === root ? packageKey(id, root) : directoryKey(id, parent),\n key,\n 'project-detector',\n directory,\n );\n }\n}\n\n/*** Preserve all inspected files, including files without an implemented language parser. */\nfunction addFiles(\n project: SourceProject,\n packageRoots: ReadonlySet<string>,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { id, inspection } = project;\n for (const file of inspection.files) {\n const root = owningPackageRoot(file, packageRoots);\n const parent = path.posix.dirname(file);\n const key = fileKey(id, file);\n addNode(nodes, {\n semanticPath: key,\n kind: 'file',\n name: path.posix.basename(file),\n projectId: id,\n path: file,\n filePath: file,\n classification: 'intrinsic',\n });\n addContains(\n edges,\n parent === root || parent === '.' ? packageKey(id, root) : directoryKey(id, parent),\n key,\n 'project-detector',\n file,\n );\n }\n}\n\n/*** Attach portable declarations and their observed documentation to a source file. */\nfunction addFileFacts(\n file: SourceAnalyzedFile,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const parent = fileKey(file.projectId, file.path);\n const fileNode = nodes.get(parent);\n if (fileNode === undefined)\n throw new Error(`Analyzed source file was not inspected: ${file.path}.`);\n if (file.facts.packageName !== undefined && file.facts.packageName !== '') {\n nodes.set(parent, {\n data: { ...fileNode.data, analyzerId: file.analyzerId, packageName: file.facts.packageName },\n });\n const packagePath = addNamespaceHierarchy(file, nodes, edges);\n addRelation(edges, parent, packagePath, 'declares-in', {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n });\n } else nodes.set(parent, { data: { ...fileNode.data, analyzerId: file.analyzerId } });\n for (const declaration of file.facts.declarations) {\n addDeclaration(file, declaration, parent, nodes, edges);\n }\n}\n\n/*** Materialize each observed namespace ancestor once for package-level queries. */\nfunction addNamespaceHierarchy(\n file: SourceAnalyzedFile,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): string {\n const segments = file.facts.packageName?.split('.') ?? [];\n let parent = sourceSemanticPath('project', file.projectId);\n let current = '';\n for (const segment of segments) {\n current = current === '' ? segment : `${current}.${segment}`;\n const key = sourceSemanticPath('namespace', file.projectId, current);\n if (!nodes.has(key)) {\n addNode(nodes, {\n semanticPath: key,\n kind: 'package',\n name: current,\n projectId: file.projectId,\n packageName: current,\n classification: 'intrinsic',\n });\n addContains(edges, parent, key, file.analyzerId, file.path);\n }\n parent = key;\n }\n return parent;\n}\n\n/*** Materialize one nested declaration with a location-qualified stable identity. */\nfunction addDeclaration(\n file: SourceAnalyzedFile,\n declaration: SourceAnalyzedFile['facts']['declarations'][number],\n parent: string,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const key = sourceSemanticPath(\n parent,\n declaration.kind,\n declaration.name,\n `${declaration.location.line}:${declaration.location.column}`,\n );\n addNode(nodes, {\n semanticPath: key,\n kind: declaration.kind,\n name: declaration.name,\n projectId: file.projectId,\n filePath: file.path,\n ...(file.facts.packageName === undefined ? {} : { packageName: file.facts.packageName }),\n classification: 'intrinsic',\n location: declaration.location,\n visibility: declaration.visibility,\n modifiers: declaration.modifiers,\n ...(declaration.signature === undefined ? {} : { signature: declaration.signature }),\n ...(declaration.documentation === undefined\n ? {}\n : { documentation: declaration.documentation }),\n ...(declaration.typeOnly === undefined ? {} : { typeOnly: declaration.typeOnly }),\n });\n addContains(edges, parent, key, file.analyzerId, file.path, declaration.location);\n if (declaration.exported === true) {\n addRelation(edges, parent, key, 'exports', {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n location: declaration.location,\n });\n }\n for (const child of declaration.children) addDeclaration(file, child, key, nodes, edges);\n}\n\n/*** Define source facts that each parser actually emits. */\nfunction analyzerCapabilities(\n analyzerId: string,\n): SourceGraphDraft['capabilities'][number]['available'] {\n if (analyzerId === 'project-detector') return ['containment'];\n if (analyzerId === 'java')\n return [\n 'containment',\n 'declarations',\n 'documentation',\n 'extends',\n 'implements',\n 'imports',\n 'signatures',\n 'source-locations',\n 'visibility',\n ];\n if (analyzerId === 'typescript')\n return [\n 'containment',\n 'declarations',\n 'documentation',\n 'exports',\n 'extends',\n 'implements',\n 'imports',\n 'signatures',\n 'source-locations',\n 'visibility',\n ];\n if (['cpp', 'delphi', 'kotlin', 'python'].includes(analyzerId)) return ['imports'];\n return [];\n}\n\n/*** Select the deepest workspace/package root that owns a portable source path. */\nfunction owningPackageRoot(file: string, roots: ReadonlySet<string>): string {\n return (\n [...roots]\n .filter((root) => root === '.' || file === root || file.startsWith(`${root}/`))\n .sort((left, right) => right.length - left.length)[0] ?? '.'\n );\n}\n\n/*** Keep node insertion idempotent when multiple files share one namespace. */\nfunction addNode(nodes: Map<string, SourceNodeDraft>, data: SourceNodeData): void {\n if (!nodes.has(data.semanticPath)) nodes.set(data.semanticPath, { data });\n}\n\n/*** Record physical or syntactic containment with provenance. */\nfunction addContains(\n edges: SourceEdgeDraft[],\n source: string,\n target: string,\n analyzerId: string,\n sourcePath: string,\n location?: SourceRelationEvidence['location'],\n): void {\n addRelation(edges, source, target, 'contains', {\n analyzerId,\n sourcePath,\n ...(location === undefined ? {} : { location }),\n });\n}\n\n/*** Append one observed relation without pre-aggregating its evidence. */\nfunction addRelation(\n edges: SourceEdgeDraft[],\n source: string,\n target: string,\n kind: SourceEdgeDraft['data']['kind'],\n evidence: SourceRelationEvidence,\n): void {\n edges.push({ source, target, data: { kind, evidence: [evidence] } });\n}\n\nfunction packageKey(projectId: string, root: string): string {\n return sourceSemanticPath('package', projectId, root);\n}\n\nfunction directoryKey(projectId: string, directory: string): string {\n return sourceSemanticPath('directory', projectId, directory);\n}\n\nexport function fileKey(projectId: string, file: string): string {\n return sourceSemanticPath('file', projectId, file);\n}\n"]}
1
+ {"version":3,"file":"createSourceStructureDraft.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceStructureDraft.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,UAAU,0BAA0B,CACxC,QAA4C,EAC5C,KAAoC;IAEpC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IACjD,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACzE,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,KAAK;QACL,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,CAC1D,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;YAC9D,SAAS;YACT,UAAU;YACV,SAAS;SACV,CAAC,CAAC,CACJ;KACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,SAAS,UAAU,CACjB,OAAgC,EAChC,aAA4C,EAC5C,KAAmC,EACnC,KAAwB;IAExB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,UAAU,GAAG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SAAS,UAAU,CAAC,SAAiB,EAAE,IAAY;IACjD,OAAO,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,SAAiB,EAAE,SAAiB;IACxD,OAAO,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,SAAiB,EAAE,IAAY;IACrD,OAAO,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import path from 'node:path';\n\nimport type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';\nimport type {\n SourceAnalyzedFile,\n SourceEdgeDraft,\n SourceGraphDraft,\n SourceNodeData,\n SourceNodeDraft,\n SourceRelationEvidence,\n} from '../../../types/sourceGraph.js';\nimport { sourceSemanticPath } from './sourceSemanticPath.js';\n\n/*** Preserve scanned projects, packages, empty directories, files, and nested declarations. */\nexport function createSourceStructureDraft(\n projects: readonly ProjectAnalysisSnapshot[],\n files: readonly SourceAnalyzedFile[],\n): SourceGraphDraft {\n const nodes = new Map<string, SourceNodeDraft>();\n const edges: SourceEdgeDraft[] = [];\n for (const project of projects) addProject(project, files, nodes, edges);\n return {\n nodes: [...nodes.values()],\n edges,\n capabilities: projects.flatMap(({ projectId, analyzers }) =>\n analyzers.map(({ id: analyzerId, capabilities: available }) => ({\n projectId,\n analyzerId,\n available,\n })),\n ),\n };\n}\n\n/*** Add the physical containment tree for one inspected project. */\nfunction addProject(\n project: ProjectAnalysisSnapshot,\n analyzedFiles: readonly SourceAnalyzedFile[],\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { projectId } = project;\n const projectKey = sourceSemanticPath('project', projectId);\n addNode(nodes, { semanticPath: projectKey, kind: 'project', name: projectId, projectId });\n const packageRoots = new Set(['.', ...project.packages.map(({ rootPath }) => rootPath)]);\n addPackages(project, packageRoots, projectKey, nodes, edges);\n addDirectories(project, packageRoots, nodes, edges);\n addFiles(project, packageRoots, nodes, edges);\n for (const file of analyzedFiles.filter((item) => item.projectId === projectId)) {\n addFileFacts(file, nodes, edges);\n }\n}\n\n/*** Preserve package and workspace roots as explicit containment boundaries. */\nfunction addPackages(\n project: ProjectAnalysisSnapshot,\n packageRoots: ReadonlySet<string>,\n projectKey: string,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { projectId } = project;\n for (const root of packageRoots) {\n const key = packageKey(projectId, root);\n const name = project.packages.find(({ rootPath }) => rootPath === root)?.name ?? root;\n addNode(nodes, {\n semanticPath: key,\n kind: 'package',\n name,\n projectId,\n path: root,\n classification: 'intrinsic',\n });\n addContains(edges, projectKey, key, 'project-detector', root);\n }\n}\n\n/*** Preserve empty directories and their exact scanned hierarchy. */\nfunction addDirectories(\n project: ProjectAnalysisSnapshot,\n packageRoots: ReadonlySet<string>,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { projectId } = project;\n for (const directory of project.directories.filter((item) => item !== '.')) {\n const root = owningPackageRoot(directory, packageRoots);\n if (directory === root) continue;\n const key = directoryKey(projectId, directory);\n addNode(nodes, {\n semanticPath: key,\n kind: 'directory',\n name: path.posix.basename(directory),\n projectId,\n path: directory,\n classification: 'intrinsic',\n });\n const parent = path.posix.dirname(directory);\n addContains(\n edges,\n parent === root ? packageKey(projectId, root) : directoryKey(projectId, parent),\n key,\n 'project-detector',\n directory,\n );\n }\n}\n\n/*** Preserve all inspected files, including files without an implemented language parser. */\nfunction addFiles(\n project: ProjectAnalysisSnapshot,\n packageRoots: ReadonlySet<string>,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const { projectId } = project;\n for (const file of project.files) {\n const root = owningPackageRoot(file, packageRoots);\n const parent = path.posix.dirname(file);\n const key = fileKey(projectId, file);\n addNode(nodes, {\n semanticPath: key,\n kind: 'file',\n name: path.posix.basename(file),\n projectId,\n path: file,\n filePath: file,\n classification: 'intrinsic',\n });\n addContains(\n edges,\n parent === root || parent === '.'\n ? packageKey(projectId, root)\n : directoryKey(projectId, parent),\n key,\n 'project-detector',\n file,\n );\n }\n}\n\n/*** Attach portable declarations and their observed documentation to a source file. */\nfunction addFileFacts(\n file: SourceAnalyzedFile,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const parent = fileKey(file.projectId, file.path);\n const fileNode = nodes.get(parent);\n if (fileNode === undefined)\n throw new Error(`Analyzed source file was not inspected: ${file.path}.`);\n if (file.facts.packageName !== undefined && file.facts.packageName !== '') {\n nodes.set(parent, {\n data: { ...fileNode.data, analyzerId: file.analyzerId, packageName: file.facts.packageName },\n });\n const packagePath = addNamespaceHierarchy(file, nodes, edges);\n addRelation(edges, parent, packagePath, 'declares-in', {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n });\n } else nodes.set(parent, { data: { ...fileNode.data, analyzerId: file.analyzerId } });\n for (const declaration of file.facts.declarations) {\n addDeclaration(file, declaration, parent, nodes, edges);\n }\n}\n\n/*** Materialize each observed namespace ancestor once for package-level queries. */\nfunction addNamespaceHierarchy(\n file: SourceAnalyzedFile,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): string {\n const segments = file.facts.packageName?.split('.') ?? [];\n let parent = sourceSemanticPath('project', file.projectId);\n let current = '';\n for (const segment of segments) {\n current = current === '' ? segment : `${current}.${segment}`;\n const key = sourceSemanticPath('namespace', file.projectId, current);\n if (!nodes.has(key)) {\n addNode(nodes, {\n semanticPath: key,\n kind: 'package',\n name: current,\n projectId: file.projectId,\n packageName: current,\n classification: 'intrinsic',\n });\n addContains(edges, parent, key, file.analyzerId, file.path);\n }\n parent = key;\n }\n return parent;\n}\n\n/*** Materialize one nested declaration with a location-qualified stable identity. */\nfunction addDeclaration(\n file: SourceAnalyzedFile,\n declaration: SourceAnalyzedFile['facts']['declarations'][number],\n parent: string,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n): void {\n const key = sourceSemanticPath(\n parent,\n declaration.kind,\n declaration.name,\n `${declaration.location.line}:${declaration.location.column}`,\n );\n addNode(nodes, {\n semanticPath: key,\n kind: declaration.kind,\n name: declaration.name,\n projectId: file.projectId,\n filePath: file.path,\n ...(file.facts.packageName === undefined ? {} : { packageName: file.facts.packageName }),\n classification: 'intrinsic',\n location: declaration.location,\n visibility: declaration.visibility,\n modifiers: declaration.modifiers,\n ...(declaration.signature === undefined ? {} : { signature: declaration.signature }),\n ...(declaration.documentation === undefined\n ? {}\n : { documentation: declaration.documentation }),\n ...(declaration.typeOnly === undefined ? {} : { typeOnly: declaration.typeOnly }),\n });\n addContains(edges, parent, key, file.analyzerId, file.path, declaration.location);\n if (declaration.exported === true) {\n addRelation(edges, parent, key, 'exports', {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n location: declaration.location,\n });\n }\n for (const child of declaration.children) addDeclaration(file, child, key, nodes, edges);\n}\n\n/*** Select the deepest workspace/package root that owns a portable source path. */\nfunction owningPackageRoot(file: string, roots: ReadonlySet<string>): string {\n return (\n [...roots]\n .filter((root) => root === '.' || file === root || file.startsWith(`${root}/`))\n .sort((left, right) => right.length - left.length)[0] ?? '.'\n );\n}\n\n/*** Keep node insertion idempotent when multiple files share one namespace. */\nfunction addNode(nodes: Map<string, SourceNodeDraft>, data: SourceNodeData): void {\n if (!nodes.has(data.semanticPath)) nodes.set(data.semanticPath, { data });\n}\n\n/*** Record physical or syntactic containment with provenance. */\nfunction addContains(\n edges: SourceEdgeDraft[],\n source: string,\n target: string,\n analyzerId: string,\n sourcePath: string,\n location?: SourceRelationEvidence['location'],\n): void {\n addRelation(edges, source, target, 'contains', {\n analyzerId,\n sourcePath,\n ...(location === undefined ? {} : { location }),\n });\n}\n\n/*** Append one observed relation without pre-aggregating its evidence. */\nfunction addRelation(\n edges: SourceEdgeDraft[],\n source: string,\n target: string,\n kind: SourceEdgeDraft['data']['kind'],\n evidence: SourceRelationEvidence,\n): void {\n edges.push({ source, target, data: { kind, evidence: [evidence] } });\n}\n\nfunction packageKey(projectId: string, root: string): string {\n return sourceSemanticPath('package', projectId, root);\n}\n\nfunction directoryKey(projectId: string, directory: string): string {\n return sourceSemanticPath('directory', projectId, directory);\n}\n\nexport function fileKey(projectId: string, file: string): string {\n return sourceSemanticPath('file', projectId, file);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
2
+ /*** Restore and validate one portable project analysis snapshot before it enters recomposition. */
3
+ export declare function deserializeProjectAnalysisSnapshot(serialized: string): ProjectAnalysisSnapshot;
4
+ //# sourceMappingURL=deserializeProjectAnalysisSnapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deserializeProjectAnalysisSnapshot.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/deserializeProjectAnalysisSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGzF,mGAAmG;AACnG,wBAAgB,kCAAkC,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,CAI9F"}
@@ -0,0 +1,8 @@
1
+ import { assertProjectAnalysisSnapshot } from './projectAnalysisSnapshot.js';
2
+ /*** Restore and validate one portable project analysis snapshot before it enters recomposition. */
3
+ export function deserializeProjectAnalysisSnapshot(serialized) {
4
+ const value = JSON.parse(serialized);
5
+ assertProjectAnalysisSnapshot(value);
6
+ return value;
7
+ }
8
+ //# sourceMappingURL=deserializeProjectAnalysisSnapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deserializeProjectAnalysisSnapshot.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/deserializeProjectAnalysisSnapshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE7E,mGAAmG;AACnG,MAAM,UAAU,kCAAkC,CAAC,UAAkB;IACnE,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9C,6BAA6B,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';\nimport { assertProjectAnalysisSnapshot } from './projectAnalysisSnapshot.js';\n\n/*** Restore and validate one portable project analysis snapshot before it enters recomposition. */\nexport function deserializeProjectAnalysisSnapshot(serialized: string): ProjectAnalysisSnapshot {\n const value: unknown = JSON.parse(serialized);\n assertProjectAnalysisSnapshot(value);\n return value;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ProjectAnalysisSnapshot } from '../../../types/projectAnalysisSnapshot.js';
2
+ /*** Reject unsupported or malformed snapshot contracts before canonical graph construction. */
3
+ export declare function assertProjectAnalysisSnapshot(value: unknown): asserts value is ProjectAnalysisSnapshot;
4
+ //# sourceMappingURL=projectAnalysisSnapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectAnalysisSnapshot.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/projectAnalysisSnapshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,uBAAuB,EAGxB,MAAM,2CAA2C,CAAC;AAGnD,+FAA+F;AAC/F,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,uBAAuB,CAE1C"}