@ankhorage/dependency-graph 1.1.0 → 1.2.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 +13 -0
- package/dist/dependencyGraphApi.d.ts +3 -0
- package/dist/dependencyGraphApi.d.ts.map +1 -0
- package/dist/dependencyGraphApi.js +2 -0
- package/dist/dependencyGraphApi.js.map +1 -0
- package/dist/features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.d.ts +3 -0
- package/dist/features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.d.ts.map +1 -0
- package/dist/features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.js +69 -0
- package/dist/features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.js.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.d.ts +4 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.d.ts.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js +45 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts.map +1 -1
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js +4 -1
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js.map +1 -1
- package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts.map +1 -1
- package/dist/features/source-graph/domain/createSourceRelationDraft.js +1 -1
- package/dist/features/source-graph/domain/createSourceRelationDraft.js.map +1 -1
- package/dist/features/source-graph/domain/resolveSourceImport.d.ts +1 -1
- package/dist/features/source-graph/domain/resolveSourceImport.d.ts.map +1 -1
- package/dist/features/source-graph/domain/resolveSourceImport.js +10 -5
- package/dist/features/source-graph/domain/resolveSourceImport.js.map +1 -1
- package/dist/types/dependencyGraphApi.d.ts +5 -0
- package/dist/types/dependencyGraphApi.d.ts.map +1 -0
- package/dist/types/dependencyGraphApi.js +2 -0
- package/dist/types/dependencyGraphApi.js.map +1 -0
- package/dist/types/sourceGraph.d.ts +1 -0
- package/dist/types/sourceGraph.d.ts.map +1 -1
- package/dist/types/sourceGraph.js.map +1 -1
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ankhorage/dependency-graph
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9960384: Expose dependency graph creation as the canonical `dependency-graph` API action through a new public
|
|
8
|
+
`@ankhorage/dependency-graph/api` entrypoint.
|
|
9
|
+
|
|
10
|
+
## 1.1.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fd718bf: Resolve TypeScript compiler path aliases into canonical intrinsic source edges and preserve package dependency weights.
|
|
15
|
+
|
|
3
16
|
## 1.1.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraphApi.d.ts","sourceRoot":"","sources":["../src/dependencyGraphApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;AAC/G,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraphApi.js","sourceRoot":"","sources":["../src/dependencyGraphApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC","sourcesContent":["export { dependencyGraphApi } from './features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.js';\nexport type { DependencyGraphApiInput } from './types/dependencyGraphApi.js';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraphApi.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.ts"],"names":[],"mappings":"AAKA,sGAAsG;AACtG,eAAO,MAAM,kBAAkB,qCA2C7B,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createApiRuntime } from '@ankhorage/api';
|
|
2
|
+
import { createDependencyGraphAsync } from '../../../composition/createDependencyGraphAsync.js';
|
|
3
|
+
/*** Expose dependency graph creation through the canonical framework-neutral Ankhorage API action. */
|
|
4
|
+
export const dependencyGraphApi = createApiRuntime({
|
|
5
|
+
definition: {
|
|
6
|
+
id: 'dependency-graph',
|
|
7
|
+
origin: 'internal',
|
|
8
|
+
protocol: 'rest',
|
|
9
|
+
basePath: '/api',
|
|
10
|
+
endpoints: {
|
|
11
|
+
actions: {
|
|
12
|
+
id: 'actions',
|
|
13
|
+
kind: 'http',
|
|
14
|
+
operations: {
|
|
15
|
+
'dependency-graph': {
|
|
16
|
+
id: 'dependency-graph',
|
|
17
|
+
endpointId: 'actions',
|
|
18
|
+
protocol: 'http',
|
|
19
|
+
intent: 'action',
|
|
20
|
+
method: 'POST',
|
|
21
|
+
path: '/dependency-graph',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
handlers: {
|
|
28
|
+
'dependency-graph': async (request) => {
|
|
29
|
+
const input = readDependencyGraphApiInput(request.body);
|
|
30
|
+
if (input === undefined) {
|
|
31
|
+
return {
|
|
32
|
+
status: 400,
|
|
33
|
+
body: {
|
|
34
|
+
error: {
|
|
35
|
+
code: 'invalid_dependency_graph_input',
|
|
36
|
+
operationId: 'dependency-graph',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
body: await createDependencyGraphAsync({ projects: input.projects }),
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
/*** Validate the transport-neutral input before invoking filesystem-backed dependency analysis. */
|
|
48
|
+
function readDependencyGraphApiInput(input) {
|
|
49
|
+
if (typeof input !== 'object' ||
|
|
50
|
+
input === null ||
|
|
51
|
+
!('projects' in input) ||
|
|
52
|
+
!Array.isArray(input.projects) ||
|
|
53
|
+
!input.projects.every(isDependencyGraphProjectInput)) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return { projects: input.projects };
|
|
57
|
+
}
|
|
58
|
+
/*** Validate one project identity/root pair accepted by dependency graph analysis. */
|
|
59
|
+
function isDependencyGraphProjectInput(value) {
|
|
60
|
+
return (typeof value === 'object' &&
|
|
61
|
+
value !== null &&
|
|
62
|
+
'id' in value &&
|
|
63
|
+
typeof value.id === 'string' &&
|
|
64
|
+
value.id.length > 0 &&
|
|
65
|
+
'rootPath' in value &&
|
|
66
|
+
typeof value.rootPath === 'string' &&
|
|
67
|
+
value.rootPath.length > 0);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=dependencyGraphApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraphApi.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/inbound/api/dependencyGraphApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oDAAoD,CAAC;AAEhG,sGAAsG;AACtG,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;IACjD,UAAU,EAAE;QACV,EAAE,EAAE,kBAAkB;QACtB,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,MAAM;QAChB,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE;YACT,OAAO,EAAE;gBACP,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE;oBACV,kBAAkB,EAAE;wBAClB,EAAE,EAAE,kBAAkB;wBACtB,UAA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E,CAAC,MAAM,GAAG,CAAC;QACnB,UAAU,IAAI,KAAK;QACnB,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ;QAClC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { createApiRuntime } from '@ankhorage/api';\n\nimport type { DependencyGraphApiInput } from '../../../../../types/dependencyGraphApi.js';\nimport { createDependencyGraphAsync } from '../../../composition/createDependencyGraphAsync.js';\n\n/*** Expose dependency graph creation through the canonical framework-neutral Ankhorage API action. */\nexport const dependencyGraphApi = createApiRuntime({\n definition: {\n id: 'dependency-graph',\n origin: 'internal',\n protocol: 'rest',\n basePath: '/api',\n endpoints: {\n actions: {\n id: 'actions',\n kind: 'http',\n operations: {\n 'dependency-graph': {\n id: 'dependency-graph',\n endpointId: 'actions',\n protocol: 'http',\n intent: 'action',\n method: 'POST',\n path: '/dependency-graph',\n },\n },\n },\n },\n },\n handlers: {\n 'dependency-graph': async (request) => {\n const input = readDependencyGraphApiInput(request.body);\n if (input === undefined) {\n return {\n status: 400,\n body: {\n error: {\n code: 'invalid_dependency_graph_input',\n operationId: 'dependency-graph',\n },\n },\n };\n }\n\n return {\n body: await createDependencyGraphAsync({ projects: input.projects }),\n };\n },\n },\n});\n\n/*** Validate the transport-neutral input before invoking filesystem-backed dependency analysis. */\nfunction readDependencyGraphApiInput(input: unknown): DependencyGraphApiInput | undefined {\n if (\n typeof input !== 'object' ||\n input === null ||\n !('projects' in input) ||\n !Array.isArray(input.projects) ||\n !input.projects.every(isDependencyGraphProjectInput)\n ) {\n return undefined;\n }\n\n return { projects: input.projects };\n}\n\n/*** Validate one project identity/root pair accepted by dependency graph analysis. */\nfunction isDependencyGraphProjectInput(\n value: unknown,\n): value is DependencyGraphApiInput['projects'][number] {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'id' in value &&\n typeof value.id === 'string' &&\n value.id.length > 0 &&\n 'rootPath' in value &&\n typeof value.rootPath === 'string' &&\n value.rootPath.length > 0\n );\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SourceFileFacts } from '../../../../../types/sourceGraph.js';
|
|
2
|
+
/*** Resolve TypeScript imports with the package's own compiler configuration. */
|
|
3
|
+
export declare function createTypeScriptImportResolver(projectRoot: string): (sourcePath: string, packageRoot: string, facts: SourceFileFacts) => SourceFileFacts;
|
|
4
|
+
//# sourceMappingURL=createTypeScriptImportResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTypeScriptImportResolver.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE3E,iFAAiF;AACjF,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM,IAIxD,YAAY,MAAM,EAAE,aAAa,MAAM,EAAE,OAAO,eAAe,KAAG,eAAe,CA0B1F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
/*** Resolve TypeScript imports with the package's own compiler configuration. */
|
|
4
|
+
export function createTypeScriptImportResolver(projectRoot) {
|
|
5
|
+
const configByPackageRoot = new Map();
|
|
6
|
+
const optionsByConfig = new Map();
|
|
7
|
+
return (sourcePath, packageRoot, facts) => {
|
|
8
|
+
const configPath = configByPackageRoot.has(packageRoot)
|
|
9
|
+
? configByPackageRoot.get(packageRoot)
|
|
10
|
+
: ts.findConfigFile(packageRoot, (candidate) => ts.sys.fileExists(candidate), 'tsconfig.json');
|
|
11
|
+
configByPackageRoot.set(packageRoot, configPath);
|
|
12
|
+
if (configPath === undefined || !isInside(projectRoot, configPath))
|
|
13
|
+
return facts;
|
|
14
|
+
const options = optionsByConfig.get(configPath) ?? readOptions(configPath);
|
|
15
|
+
optionsByConfig.set(configPath, options);
|
|
16
|
+
return {
|
|
17
|
+
...facts,
|
|
18
|
+
imports: facts.imports.map((item) => {
|
|
19
|
+
const resolved = ts.resolveModuleName(item.specifier, sourcePath, options, ts.sys)
|
|
20
|
+
.resolvedModule?.resolvedFileName;
|
|
21
|
+
if (resolved === undefined || !isInside(projectRoot, resolved))
|
|
22
|
+
return item;
|
|
23
|
+
return {
|
|
24
|
+
...item,
|
|
25
|
+
resolvedPath: path.relative(projectRoot, resolved).split(path.sep).join('/'),
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/*** Parse compiler options once per configuration, including extends and path aliases. */
|
|
32
|
+
function readOptions(configPath) {
|
|
33
|
+
const config = ts.readConfigFile(configPath, (candidate) => ts.sys.readFile(candidate));
|
|
34
|
+
if (config.error !== undefined) {
|
|
35
|
+
throw new Error(ts.flattenDiagnosticMessageText(config.error.messageText, '\n'));
|
|
36
|
+
}
|
|
37
|
+
const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));
|
|
38
|
+
return parsed.options;
|
|
39
|
+
}
|
|
40
|
+
/*** Keep resolved targets inside the inspected project rather than following host files. */
|
|
41
|
+
function isInside(root, candidate) {
|
|
42
|
+
const relative = path.relative(root, candidate);
|
|
43
|
+
return relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=createTypeScriptImportResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTypeScriptImportResolver.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,iFAAiF;AACjF,MAAM,UAAU,8BAA8B,CAAC,WAAmB;IAChE,MAAM,mBAAmB,GAAG,I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IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;iBAC7E,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,WAAW,CAAC,UAAkB;IACrC,MAAM,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACxF,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AAED,4FAA4F;AAC5F,SAAS,QAAQ,CAAC,IAAY,EAAE,SAAiB;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChD,OAAO,QAAQ,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAClG,CAAC","sourcesContent":["import path from 'node:path';\n\nimport ts from 'typescript';\n\nimport type { SourceFileFacts } from '../../../../../types/sourceGraph.js';\n\n/*** Resolve TypeScript imports with the package's own compiler configuration. */\nexport function createTypeScriptImportResolver(projectRoot: string) {\n const configByPackageRoot = new Map<string, string | undefined>();\n const optionsByConfig = new Map<string, ts.CompilerOptions>();\n\n return (sourcePath: string, packageRoot: string, facts: SourceFileFacts): SourceFileFacts => {\n const configPath = configByPackageRoot.has(packageRoot)\n ? configByPackageRoot.get(packageRoot)\n : ts.findConfigFile(\n packageRoot,\n (candidate) => ts.sys.fileExists(candidate),\n 'tsconfig.json',\n );\n configByPackageRoot.set(packageRoot, configPath);\n if (configPath === undefined || !isInside(projectRoot, configPath)) return facts;\n const options = optionsByConfig.get(configPath) ?? readOptions(configPath);\n optionsByConfig.set(configPath, options);\n\n return {\n ...facts,\n imports: facts.imports.map((item) => {\n const resolved = ts.resolveModuleName(item.specifier, sourcePath, options, ts.sys)\n .resolvedModule?.resolvedFileName;\n if (resolved === undefined || !isInside(projectRoot, resolved)) return item;\n return {\n ...item,\n resolvedPath: path.relative(projectRoot, resolved).split(path.sep).join('/'),\n };\n }),\n };\n };\n}\n\n/*** Parse compiler options once per configuration, including extends and path aliases. */\nfunction readOptions(configPath: string): ts.CompilerOptions {\n const config = ts.readConfigFile(configPath, (candidate) => ts.sys.readFile(candidate));\n if (config.error !== undefined) {\n throw new Error(ts.flattenDiagnosticMessageText(config.error.messageText, '\\n'));\n }\n const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, path.dirname(configPath));\n return parsed.options;\n}\n\n/*** Keep resolved targets inside the inspected project rather than following host files. */\nfunction isInside(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);\n}\n"]}
|
package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSourceGraphFromInspectionsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qCAAqC,EAErC,WAAW,EACZ,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"createSourceGraphFromInspectionsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/composition/createSourceGraphFromInspectionsAsync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,qCAAqC,EAErC,WAAW,EACZ,MAAM,+BAA+B,CAAC;AAUvC,kFAAkF;AAClF,wBAAsB,qCAAqC,CACzD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,WAAW,CAAC,CAWtB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { extractJavaSourceFacts } from '../../dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js';
|
|
4
|
+
import { createTypeScriptImportResolver } from '../../dependency-analysis/adapters/outbound/typescript/createTypeScriptImportResolver.js';
|
|
4
5
|
import { extractTypeScriptSourceFacts } from '../../dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js';
|
|
5
6
|
import { readDependencyDeclarationsAsync } from '../../dependency-analysis/domain/readDependencyDeclarationsAsync.js';
|
|
6
7
|
import { extractOtherLanguageFacts } from '../adapters/outbound/extractOtherLanguageFacts.js';
|
|
@@ -17,6 +18,7 @@ export async function createSourceGraphFromInspectionsAsync(input) {
|
|
|
17
18
|
/*** Read package declarations once and associate them with their owning source files. */
|
|
18
19
|
async function readProjectFilesAsync(projectId, inspection, signal) {
|
|
19
20
|
const declarations = await readPackageDeclarationsAsync(inspection);
|
|
21
|
+
const resolveTypeScriptImports = createTypeScriptImportResolver(inspection.rootPath);
|
|
20
22
|
return Promise.all(inspection.files.flatMap((file) => {
|
|
21
23
|
const analyzerId = analyzerForPath(file);
|
|
22
24
|
if (analyzerId === undefined)
|
|
@@ -39,6 +41,7 @@ async function readProjectFilesAsync(projectId, inspection, signal) {
|
|
|
39
41
|
packageRoot: path.resolve(inspection.rootPath, root),
|
|
40
42
|
sourceRoots,
|
|
41
43
|
declaredDependencies: declarations.get(root),
|
|
44
|
+
resolveTypeScriptImports,
|
|
42
45
|
signal,
|
|
43
46
|
}),
|
|
44
47
|
];
|
|
@@ -69,7 +72,7 @@ async function readAnalyzedFileAsync(input) {
|
|
|
69
72
|
facts: input.analyzerId === 'java'
|
|
70
73
|
? extractJavaSourceFacts(content)
|
|
71
74
|
: input.analyzerId === 'typescript'
|
|
72
|
-
? extractTypeScriptSourceFacts(input.file, content)
|
|
75
|
+
? input.resolveTypeScriptImports(absolute, input.packageRoot, extractTypeScriptSourceFacts(input.file, content))
|
|
73
76
|
: extractOtherLanguageFacts(input.analyzerId, content, absolute, input.packageRoot, input.sourceRoots),
|
|
74
77
|
};
|
|
75
78
|
}
|
|
@@ -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,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,UAA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I,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 { 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"]}
|
|
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,EAAE,EAAE,EAAE,CACxC,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CACpD,CACF,CACF,CAAC,IAAI,EAAE,CAAC;IACT,M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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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSourceRelationDraft.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceRelationDraft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAGlB,gBAAgB,EAGjB,MAAM,+BAA+B,CAAC;AAKvC,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"createSourceRelationDraft.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceRelationDraft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAGlB,gBAAgB,EAGjB,MAAM,+BAA+B,CAAC;AAKvC,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,SAAS,kBAAkB,EAAE,GACnC,gBAAgB,CA6ClB"}
|
|
@@ -13,7 +13,7 @@ export function createSourceRelationDraft(structure, files) {
|
|
|
13
13
|
: []));
|
|
14
14
|
for (const file of files) {
|
|
15
15
|
for (const imported of file.facts.imports) {
|
|
16
|
-
const resolved = resolveImport(file, imported.specifier, imported.local, nodes, symbolIndex, namespaceIndex, focusPackages);
|
|
16
|
+
const resolved = resolveImport(file, imported.specifier, imported.local, imported.resolvedPath, nodes, symbolIndex, namespaceIndex, focusPackages);
|
|
17
17
|
addRelation(edges, fileKey(file.projectId, file.path), resolved.target, imported.kind === 'reexport' ? 'exports' : 'imports', {
|
|
18
18
|
analyzerId: file.analyzerId,
|
|
19
19
|
sourcePath: file.path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSourceRelationDraft.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceRelationDraft.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,wFAAwF;AACxF,MAAM,UAAU,yBAAyB,CACvC,SAA2B,EAC3B,KAAoC;IAEpC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,mBAAmB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CACnC,IAAI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n SourceNodeDraft,\n SourceRelationEvidence,\n} from '../../../types/sourceGraph.js';\nimport { fileKey } from './createSourceStructureDraft.js';\nimport { resolveImport } from './resolveSourceImport.js';\nimport { sourceSemanticPath } from './sourceSemanticPath.js';\n\n/*** Resolve source imports and inheritance after all declarations have been indexed. */\nexport function createSourceRelationDraft(\n structure: SourceGraphDraft,\n files: readonly SourceAnalyzedFile[],\n): SourceGraphDraft {\n const nodes = new Map(structure.nodes.map((node) => [node.data.semanticPath, node]));\n const edges = [...structure.edges];\n const symbolIndex = buildSymbolIndex(structure.nodes);\n const declarationIndex = buildDeclarationIndex(structure.nodes);\n const namespaceIndex = buildNamespaceIndex(structure.nodes);\n const focusPackages = new Map(\n structure.nodes.flatMap(({ data }) =>\n data.kind === 'package' && data.path !== undefined && data.classification === 'intrinsic'\n ? [[data.name, data.semanticPath] as const]\n : [],\n ),\n );\n for (const file of files) {\n for (const imported of file.facts.imports) {\n const resolved = resolveImport(\n file,\n imported.specifier,\n imported.local,\n nodes,\n symbolIndex,\n namespaceIndex,\n focusPackages,\n );\n addRelation(\n edges,\n fileKey(file.projectId, file.path),\n resolved.target,\n imported.kind === 'reexport' ? 'exports' : 'imports',\n {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n ...(imported.location === undefined ? {} : { location: imported.location }),\n specifier: imported.specifier,\n ...(imported.typeOnly === undefined ? {} : { typeOnly: imported.typeOnly }),\n ...(resolved.declarations.length === 0 ? {} : { declarations: resolved.declarations }),\n },\n );\n }\n for (const declaration of file.facts.declarations) {\n addInheritance(file, declaration, nodes, edges, symbolIndex, declarationIndex);\n }\n }\n return { nodes: [...nodes.values()], edges, capabilities: structure.capabilities };\n}\n\n/*** Index intrinsic namespaces once for import resolution. */\nfunction buildNamespaceIndex(\n nodes: readonly SourceNodeDraft[],\n): ReadonlyMap<string, readonly string[]> {\n const names = new Map<string, string[]>();\n for (const { data } of nodes) {\n if (\n data.kind !== 'package' ||\n data.packageName === undefined ||\n data.classification !== 'intrinsic'\n )\n continue;\n names.set(data.projectId, [...(names.get(data.projectId) ?? []), data.packageName]);\n }\n return new Map(\n [...names].map(([projectId, values]) => [\n projectId,\n values.sort((left, right) => right.length - left.length),\n ]),\n );\n}\n\n/*** Index declaration locations once for evidence relationship resolution. */\nfunction buildDeclarationIndex(nodes: readonly SourceNodeDraft[]): ReadonlyMap<string, string> {\n const index = new Map<string, string>();\n for (const { data } of nodes) {\n if (data.filePath === undefined || data.location === undefined) continue;\n const key = sourceSemanticPath(\n data.projectId,\n data.filePath,\n data.kind,\n data.name,\n `${data.location.line}:${data.location.column}`,\n );\n index.set(key, data.semanticPath);\n }\n return index;\n}\n\n/*** Index source types by project, namespace, and simple name for language-neutral resolution. */\nfunction buildSymbolIndex(nodes: readonly SourceNodeDraft[]): ReadonlyMap<string, string> {\n const index = new Map<string, string>();\n for (const { data } of nodes) {\n if (data.kind !== 'class' && data.kind !== 'interface' && data.kind !== 'type') continue;\n index.set(symbolKey(data.projectId, data.packageName ?? '', data.name), data.semanticPath);\n index.set(symbolKey(data.projectId, '', data.name), data.semanticPath);\n }\n return index;\n}\n\n/*** Resolve observed extends/implements references with exact source evidence. */\nfunction addInheritance(\n file: SourceAnalyzedFile,\n declaration: SourceDeclarationFact,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n symbols: ReadonlyMap<string, string>,\n declarations: ReadonlyMap<string, string>,\n): void {\n const source = declarations.get(\n sourceSemanticPath(\n file.projectId,\n file.path,\n declaration.kind,\n declaration.name,\n `${declaration.location.line}:${declaration.location.column}`,\n ),\n );\n if (source !== undefined) {\n for (const [kind, names] of [\n ['extends', declaration.extends],\n ['implements', declaration.implements],\n ] as const) {\n for (const name of names) {\n const simpleName = name.replace(/<.*$/u, '').split('.').at(-1) ?? name;\n const resolved =\n symbols.get(symbolKey(file.projectId, file.facts.packageName ?? '', simpleName)) ??\n symbols.get(symbolKey(file.projectId, '', simpleName));\n const target = resolved ?? unresolvedType(file, name, nodes);\n addRelation(edges, source, target, kind, {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n location: declaration.location,\n specifier: name,\n });\n }\n }\n }\n for (const child of declaration.children) {\n addInheritance(file, child, nodes, edges, symbols, declarations);\n }\n}\n\n/*** Preserve a base-type reference even when its declaration is outside the scan. */\nfunction unresolvedType(\n file: SourceAnalyzedFile,\n name: string,\n nodes: Map<string, SourceNodeDraft>,\n): string {\n const key = sourceSemanticPath('external-type', file.projectId, name);\n if (!nodes.has(key)) {\n nodes.set(key, {\n data: {\n semanticPath: key,\n kind: 'type',\n name,\n projectId: file.projectId,\n classification: 'unknown',\n },\n });\n }\n return key;\n}\n\n/*** Scope type names without confusing same names in separate Java packages. */\nfunction symbolKey(projectId: string, packageName: string, name: string): string {\n return sourceSemanticPath(projectId, packageName, name);\n}\n\n/*** Preserve each observed relation as one traceable canonical edge. */\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"]}
|
|
1
|
+
{"version":3,"file":"createSourceRelationDraft.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/createSourceRelationDraft.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,wFAAwF;AACxF,MAAM,UAAU,yBAAyB,CACvC,SAA2B,EAC3B,KAAoC;IAEpC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,CAAC,GAAG,SAAS,CAA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S,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC;AAED,wEAAwE;AACxE,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","sourcesContent":["import type {\n SourceAnalyzedFile,\n SourceDeclarationFact,\n SourceEdgeDraft,\n SourceGraphDraft,\n SourceNodeDraft,\n SourceRelationEvidence,\n} from '../../../types/sourceGraph.js';\nimport { fileKey } from './createSourceStructureDraft.js';\nimport { resolveImport } from './resolveSourceImport.js';\nimport { sourceSemanticPath } from './sourceSemanticPath.js';\n\n/*** Resolve source imports and inheritance after all declarations have been indexed. */\nexport function createSourceRelationDraft(\n structure: SourceGraphDraft,\n files: readonly SourceAnalyzedFile[],\n): SourceGraphDraft {\n const nodes = new Map(structure.nodes.map((node) => [node.data.semanticPath, node]));\n const edges = [...structure.edges];\n const symbolIndex = buildSymbolIndex(structure.nodes);\n const declarationIndex = buildDeclarationIndex(structure.nodes);\n const namespaceIndex = buildNamespaceIndex(structure.nodes);\n const focusPackages = new Map(\n structure.nodes.flatMap(({ data }) =>\n data.kind === 'package' && data.path !== undefined && data.classification === 'intrinsic'\n ? [[data.name, data.semanticPath] as const]\n : [],\n ),\n );\n for (const file of files) {\n for (const imported of file.facts.imports) {\n const resolved = resolveImport(\n file,\n imported.specifier,\n imported.local,\n imported.resolvedPath,\n nodes,\n symbolIndex,\n namespaceIndex,\n focusPackages,\n );\n addRelation(\n edges,\n fileKey(file.projectId, file.path),\n resolved.target,\n imported.kind === 'reexport' ? 'exports' : 'imports',\n {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n ...(imported.location === undefined ? {} : { location: imported.location }),\n specifier: imported.specifier,\n ...(imported.typeOnly === undefined ? {} : { typeOnly: imported.typeOnly }),\n ...(resolved.declarations.length === 0 ? {} : { declarations: resolved.declarations }),\n },\n );\n }\n for (const declaration of file.facts.declarations) {\n addInheritance(file, declaration, nodes, edges, symbolIndex, declarationIndex);\n }\n }\n return { nodes: [...nodes.values()], edges, capabilities: structure.capabilities };\n}\n\n/*** Index intrinsic namespaces once for import resolution. */\nfunction buildNamespaceIndex(\n nodes: readonly SourceNodeDraft[],\n): ReadonlyMap<string, readonly string[]> {\n const names = new Map<string, string[]>();\n for (const { data } of nodes) {\n if (\n data.kind !== 'package' ||\n data.packageName === undefined ||\n data.classification !== 'intrinsic'\n )\n continue;\n names.set(data.projectId, [...(names.get(data.projectId) ?? []), data.packageName]);\n }\n return new Map(\n [...names].map(([projectId, values]) => [\n projectId,\n values.sort((left, right) => right.length - left.length),\n ]),\n );\n}\n\n/*** Index declaration locations once for evidence relationship resolution. */\nfunction buildDeclarationIndex(nodes: readonly SourceNodeDraft[]): ReadonlyMap<string, string> {\n const index = new Map<string, string>();\n for (const { data } of nodes) {\n if (data.filePath === undefined || data.location === undefined) continue;\n const key = sourceSemanticPath(\n data.projectId,\n data.filePath,\n data.kind,\n data.name,\n `${data.location.line}:${data.location.column}`,\n );\n index.set(key, data.semanticPath);\n }\n return index;\n}\n\n/*** Index source types by project, namespace, and simple name for language-neutral resolution. */\nfunction buildSymbolIndex(nodes: readonly SourceNodeDraft[]): ReadonlyMap<string, string> {\n const index = new Map<string, string>();\n for (const { data } of nodes) {\n if (data.kind !== 'class' && data.kind !== 'interface' && data.kind !== 'type') continue;\n index.set(symbolKey(data.projectId, data.packageName ?? '', data.name), data.semanticPath);\n index.set(symbolKey(data.projectId, '', data.name), data.semanticPath);\n }\n return index;\n}\n\n/*** Resolve observed extends/implements references with exact source evidence. */\nfunction addInheritance(\n file: SourceAnalyzedFile,\n declaration: SourceDeclarationFact,\n nodes: Map<string, SourceNodeDraft>,\n edges: SourceEdgeDraft[],\n symbols: ReadonlyMap<string, string>,\n declarations: ReadonlyMap<string, string>,\n): void {\n const source = declarations.get(\n sourceSemanticPath(\n file.projectId,\n file.path,\n declaration.kind,\n declaration.name,\n `${declaration.location.line}:${declaration.location.column}`,\n ),\n );\n if (source !== undefined) {\n for (const [kind, names] of [\n ['extends', declaration.extends],\n ['implements', declaration.implements],\n ] as const) {\n for (const name of names) {\n const simpleName = name.replace(/<.*$/u, '').split('.').at(-1) ?? name;\n const resolved =\n symbols.get(symbolKey(file.projectId, file.facts.packageName ?? '', simpleName)) ??\n symbols.get(symbolKey(file.projectId, '', simpleName));\n const target = resolved ?? unresolvedType(file, name, nodes);\n addRelation(edges, source, target, kind, {\n analyzerId: file.analyzerId,\n sourcePath: file.path,\n location: declaration.location,\n specifier: name,\n });\n }\n }\n }\n for (const child of declaration.children) {\n addInheritance(file, child, nodes, edges, symbols, declarations);\n }\n}\n\n/*** Preserve a base-type reference even when its declaration is outside the scan. */\nfunction unresolvedType(\n file: SourceAnalyzedFile,\n name: string,\n nodes: Map<string, SourceNodeDraft>,\n): string {\n const key = sourceSemanticPath('external-type', file.projectId, name);\n if (!nodes.has(key)) {\n nodes.set(key, {\n data: {\n semanticPath: key,\n kind: 'type',\n name,\n projectId: file.projectId,\n classification: 'unknown',\n },\n });\n }\n return key;\n}\n\n/*** Scope type names without confusing same names in separate Java packages. */\nfunction symbolKey(projectId: string, packageName: string, name: string): string {\n return sourceSemanticPath(projectId, packageName, name);\n}\n\n/*** Preserve each observed relation as one traceable canonical edge. */\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"]}
|
|
@@ -5,5 +5,5 @@ export interface ResolvedImport {
|
|
|
5
5
|
readonly declarations: readonly DependencyDeclaration[];
|
|
6
6
|
}
|
|
7
7
|
/*** Resolve a source import to an observed file/type or explicit unresolved target. */
|
|
8
|
-
export declare function resolveImport(file: SourceAnalyzedFile, specifier: string, local: boolean | undefined, nodes: Map<string, SourceNodeDraft>, symbols: ReadonlyMap<string, string>, namespaces: ReadonlyMap<string, readonly string[]>, focusPackages: ReadonlyMap<string, string>): ResolvedImport;
|
|
8
|
+
export declare function resolveImport(file: SourceAnalyzedFile, specifier: string, local: boolean | undefined, resolvedPath: string | undefined, nodes: Map<string, SourceNodeDraft>, symbols: ReadonlyMap<string, string>, namespaces: ReadonlyMap<string, readonly string[]>, focusPackages: ReadonlyMap<string, string>): ResolvedImport;
|
|
9
9
|
//# sourceMappingURL=resolveSourceImport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSourceImport.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/resolveSourceImport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AASzF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACzD;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,GAAG,SAAS,EAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACnC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EAClD,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,
|
|
1
|
+
{"version":3,"file":"resolveSourceImport.d.ts","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/resolveSourceImport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AASzF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACzD;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,GAAG,SAAS,EAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACnC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EAClD,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,CAYhB"}
|
|
@@ -7,18 +7,18 @@ import { extractPythonPackageFromImport } from '../../dependency-analysis/domain
|
|
|
7
7
|
import { fileKey } from './createSourceStructureDraft.js';
|
|
8
8
|
import { sourceSemanticPath } from './sourceSemanticPath.js';
|
|
9
9
|
/*** Resolve a source import to an observed file/type or explicit unresolved target. */
|
|
10
|
-
export function resolveImport(file, specifier, local, nodes, symbols, namespaces, focusPackages) {
|
|
11
|
-
const intrinsic = resolveIntrinsicImport(file, specifier, local, nodes, symbols, namespaces);
|
|
10
|
+
export function resolveImport(file, specifier, local, resolvedPath, nodes, symbols, namespaces, focusPackages) {
|
|
11
|
+
const intrinsic = resolveIntrinsicImport(file, specifier, local, resolvedPath, nodes, symbols, namespaces);
|
|
12
12
|
if (intrinsic !== undefined)
|
|
13
13
|
return { target: intrinsic, declarations: [] };
|
|
14
14
|
return resolveExternalImport(file, specifier, nodes, focusPackages);
|
|
15
15
|
}
|
|
16
16
|
/*** Route language-specific reference syntax into one observed intrinsic target. */
|
|
17
|
-
function resolveIntrinsicImport(file, specifier, local, nodes, symbols, namespaces) {
|
|
17
|
+
function resolveIntrinsicImport(file, specifier, local, resolvedPath, nodes, symbols, namespaces) {
|
|
18
18
|
if (file.analyzerId === 'java')
|
|
19
19
|
return resolveJavaImport(file, specifier, nodes, symbols, namespaces);
|
|
20
20
|
if (file.analyzerId === 'typescript')
|
|
21
|
-
return resolveTypeScriptFileImport(file, specifier, nodes);
|
|
21
|
+
return resolveTypeScriptFileImport(file, specifier, resolvedPath, nodes);
|
|
22
22
|
if (file.analyzerId === 'cpp')
|
|
23
23
|
return local ? resolveLocalCppInclude(file, specifier, nodes) : undefined;
|
|
24
24
|
return resolveNamespaceImport(file, specifier, namespaces);
|
|
@@ -70,7 +70,12 @@ function resolveJavaImport(file, specifier, nodes, symbols, namespaces) {
|
|
|
70
70
|
return resolveNamespaceImport(file, specifier, namespaces);
|
|
71
71
|
}
|
|
72
72
|
/*** Resolve a relative TypeScript import to a scanned source file. */
|
|
73
|
-
function resolveTypeScriptFileImport(file, specifier, nodes) {
|
|
73
|
+
function resolveTypeScriptFileImport(file, specifier, resolvedPath, nodes) {
|
|
74
|
+
if (resolvedPath !== undefined) {
|
|
75
|
+
const resolved = fileKey(file.projectId, resolvedPath);
|
|
76
|
+
if (nodes.has(resolved))
|
|
77
|
+
return resolved;
|
|
78
|
+
}
|
|
74
79
|
if (!specifier.startsWith('.'))
|
|
75
80
|
return undefined;
|
|
76
81
|
const base = path.posix.normalize(path.posix.join(path.posix.dirname(file.path), specifier));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSourceImport.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/resolveSourceImport.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,kEAAkE,CAAC;AAChH,OAAO,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;QAAE,OAAO,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACzE,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC;AAED,+EAA+E;AAC/E,SAAS,eAAe,CAAC,SAAiB;IACxC,IACE,SAAS,KAAK,EAAE;QAChB,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QACzB,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QACzB,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAEzB,OAAO,SAAS,CAAC;IACnB,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAC9B,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;YACpB,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;YACjC,CAAC,CAAC,SAAS;QACb,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,gFAAgF;AAChF,SAAS,SAAS,CAAC,SAAiB,EAAE,WAAmB,EAAE,IAAY;IACrE,OAAO,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import path from 'node:path';\n\nimport type { DependencyDeclaration } from '../../../types/dependencyGraph.js';\nimport type { SourceAnalyzedFile, SourceNodeDraft } from '../../../types/sourceGraph.js';\nimport { extractCppPackageFromInclude } from '../../dependency-analysis/domain/extractCppPackageFromInclude.js';\nimport { extractDelphiPackageFromImport } from '../../dependency-analysis/domain/extractDelphiPackageFromImport.js';\nimport { extractJavaPackageFromImport } from '../../dependency-analysis/domain/extractJavaPackageFromImport.js';\nimport { extractKotlinPackageFromImport } from '../../dependency-analysis/domain/extractKotlinPackageFromImport.js';\nimport { extractPythonPackageFromImport } from '../../dependency-analysis/domain/extractPythonPackageFromImport.js';\nimport { fileKey } from './createSourceStructureDraft.js';\nimport { sourceSemanticPath } from './sourceSemanticPath.js';\n\nexport interface ResolvedImport {\n readonly target: string;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\n/*** Resolve a source import to an observed file/type or explicit unresolved target. */\nexport function resolveImport(\n file: SourceAnalyzedFile,\n specifier: string,\n local: boolean | undefined,\n nodes: Map<string, SourceNodeDraft>,\n symbols: ReadonlyMap<string, string>,\n namespaces: ReadonlyMap<string, readonly string[]>,\n focusPackages: ReadonlyMap<string, string>,\n): ResolvedImport {\n const intrinsic = resolveIntrinsicImport(file, specifier, local, nodes, symbols, namespaces);\n if (intrinsic !== undefined) return { target: intrinsic, declarations: [] };\n return resolveExternalImport(file, specifier, nodes, focusPackages);\n}\n\n/*** Route language-specific reference syntax into one observed intrinsic target. */\nfunction resolveIntrinsicImport(\n file: SourceAnalyzedFile,\n specifier: string,\n local: boolean | undefined,\n nodes: Map<string, SourceNodeDraft>,\n symbols: ReadonlyMap<string, string>,\n namespaces: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n if (file.analyzerId === 'java')\n return resolveJavaImport(file, specifier, nodes, symbols, namespaces);\n if (file.analyzerId === 'typescript') return resolveTypeScriptFileImport(file, specifier, nodes);\n if (file.analyzerId === 'cpp')\n return local ? resolveLocalCppInclude(file, specifier, nodes) : undefined;\n return resolveNamespaceImport(file, specifier, namespaces);\n}\n\n/*** Resolve a local C++ include to its existing or newly observed namespace. */\nfunction resolveLocalCppInclude(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: Map<string, SourceNodeDraft>,\n): string | undefined {\n const packageName = extractCppPackageFromInclude(specifier);\n if (packageName === '') return undefined;\n const key = sourceSemanticPath('namespace', file.projectId, packageName);\n if (!nodes.has(key)) {\n nodes.set(key, {\n data: {\n semanticPath: key,\n kind: 'package',\n name: packageName,\n projectId: file.projectId,\n packageName,\n classification: 'intrinsic',\n },\n });\n }\n return key;\n}\n\n/*** Resolve imports against namespaces declared by Kotlin, Python, and Delphi source files. */\nfunction resolveNamespaceImport(\n file: SourceAnalyzedFile,\n specifier: string,\n namespaces: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n const candidates = namespaces.get(file.projectId) ?? [];\n const matching =\n file.analyzerId === 'python'\n ? candidates.find((name) => name === extractPythonPackageFromImport(specifier))\n : file.analyzerId === 'delphi'\n ? candidates.find((name) => name === extractDelphiPackageFromImport(specifier))\n : candidates.find((name) => specifier === name || specifier.startsWith(`${name}.`));\n return matching === undefined\n ? undefined\n : sourceSemanticPath('namespace', file.projectId, matching);\n}\n\n/*** Resolve an imported Java type or package from observed declarations. */\nfunction resolveJavaImport(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: ReadonlyMap<string, SourceNodeDraft>,\n symbols: ReadonlyMap<string, string>,\n namespaces: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n const name = specifier.replace(/\\.\\*$/u, '');\n const separator = name.lastIndexOf('.');\n const packageName = separator < 0 ? '' : name.slice(0, separator);\n const simpleName = name.slice(separator + 1);\n const symbol = symbols.get(symbolKey(file.projectId, packageName, simpleName));\n if (symbol !== undefined) return symbol;\n const namespace = sourceSemanticPath('namespace', file.projectId, name);\n if (nodes.has(namespace)) return namespace;\n return resolveNamespaceImport(file, specifier, namespaces);\n}\n\n/*** Resolve a relative TypeScript import to a scanned source file. */\nfunction resolveTypeScriptFileImport(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: ReadonlyMap<string, SourceNodeDraft>,\n): string | undefined {\n if (!specifier.startsWith('.')) return undefined;\n const base = path.posix.normalize(path.posix.join(path.posix.dirname(file.path), specifier));\n const candidates = [\n base,\n `${base}.ts`,\n `${base}.tsx`,\n `${base}.mts`,\n `${base}.cts`,\n `${base}/index.ts`,\n `${base}/index.tsx`,\n ];\n return candidates\n .map((candidate) => fileKey(file.projectId, candidate))\n .find((key) => nodes.has(key));\n}\n\n/*** Distinguish declared vendor imports, focus packages, and unresolved imports. */\nfunction resolveExternalImport(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: Map<string, SourceNodeDraft>,\n focusPackages: ReadonlyMap<string, string>,\n): ResolvedImport {\n const packageName = packageFromSpecifier(file.analyzerId, specifier);\n const declarations =\n packageName === undefined\n ? []\n : (Object.entries(file.declaredDependencies ?? {}).find(\n ([name]) => name === packageName,\n )?.[1] ?? []);\n const focus = packageName === undefined ? undefined : focusPackages.get(packageName);\n if (focus !== undefined) return { target: focus, declarations };\n const external = sourceSemanticPath('external', file.projectId, packageName ?? specifier);\n if (!nodes.has(external)) {\n nodes.set(external, {\n data: {\n semanticPath: external,\n kind: 'package',\n name: packageName ?? specifier,\n projectId: file.projectId,\n packageName: packageName ?? specifier,\n classification:\n file.analyzerId === 'typescript' && declarations.length > 0 ? 'vendor' : 'unknown',\n },\n });\n }\n return { target: external, declarations };\n}\n\n/*** Project an unresolved reference onto the established package naming semantics. */\nfunction packageFromSpecifier(analyzerId: string, specifier: string): string | undefined {\n if (analyzerId === 'java') return extractJavaPackageFromImport(specifier);\n if (analyzerId === 'kotlin') return extractKotlinPackageFromImport(specifier);\n if (analyzerId === 'python') return extractPythonPackageFromImport(specifier);\n if (analyzerId === 'delphi') return extractDelphiPackageFromImport(specifier);\n if (analyzerId === 'cpp') return extractCppPackageFromInclude(specifier);\n return barePackageName(specifier);\n}\n\n/*** Extract the declared npm package identity from a bare module specifier. */\nfunction barePackageName(specifier: string): string | undefined {\n if (\n specifier === '' ||\n specifier.startsWith('.') ||\n specifier.startsWith('#') ||\n specifier.startsWith('/')\n )\n return undefined;\n const segments = specifier.split('/');\n return specifier.startsWith('@')\n ? segments.length >= 2\n ? `${segments[0]}/${segments[1]}`\n : undefined\n : segments[0];\n}\n\n/*** Scope type names without confusing same names in separate Java packages. */\nfunction symbolKey(projectId: string, packageName: string, name: string): string {\n return sourceSemanticPath(projectId, packageName, name);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolveSourceImport.js","sourceRoot":"","sources":["../../../../src/features/source-graph/domain/resolveSourceImport.ts"],"names":[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} from '../../../types/dependencyGraph.js';\nimport type { SourceAnalyzedFile, SourceNodeDraft } from '../../../types/sourceGraph.js';\nimport { extractCppPackageFromInclude } from '../../dependency-analysis/domain/extractCppPackageFromInclude.js';\nimport { extractDelphiPackageFromImport } from '../../dependency-analysis/domain/extractDelphiPackageFromImport.js';\nimport { extractJavaPackageFromImport } from '../../dependency-analysis/domain/extractJavaPackageFromImport.js';\nimport { extractKotlinPackageFromImport } from '../../dependency-analysis/domain/extractKotlinPackageFromImport.js';\nimport { extractPythonPackageFromImport } from '../../dependency-analysis/domain/extractPythonPackageFromImport.js';\nimport { fileKey } from './createSourceStructureDraft.js';\nimport { sourceSemanticPath } from './sourceSemanticPath.js';\n\nexport interface ResolvedImport {\n readonly target: string;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\n/*** Resolve a source import to an observed file/type or explicit unresolved target. */\nexport function resolveImport(\n file: SourceAnalyzedFile,\n specifier: string,\n local: boolean | undefined,\n resolvedPath: string | undefined,\n nodes: Map<string, SourceNodeDraft>,\n symbols: ReadonlyMap<string, string>,\n namespaces: ReadonlyMap<string, readonly string[]>,\n focusPackages: ReadonlyMap<string, string>,\n): ResolvedImport {\n const intrinsic = resolveIntrinsicImport(\n file,\n specifier,\n local,\n resolvedPath,\n nodes,\n symbols,\n namespaces,\n );\n if (intrinsic !== undefined) return { target: intrinsic, declarations: [] };\n return resolveExternalImport(file, specifier, nodes, focusPackages);\n}\n\n/*** Route language-specific reference syntax into one observed intrinsic target. */\nfunction resolveIntrinsicImport(\n file: SourceAnalyzedFile,\n specifier: string,\n local: boolean | undefined,\n resolvedPath: string | undefined,\n nodes: Map<string, SourceNodeDraft>,\n symbols: ReadonlyMap<string, string>,\n namespaces: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n if (file.analyzerId === 'java')\n return resolveJavaImport(file, specifier, nodes, symbols, namespaces);\n if (file.analyzerId === 'typescript')\n return resolveTypeScriptFileImport(file, specifier, resolvedPath, nodes);\n if (file.analyzerId === 'cpp')\n return local ? resolveLocalCppInclude(file, specifier, nodes) : undefined;\n return resolveNamespaceImport(file, specifier, namespaces);\n}\n\n/*** Resolve a local C++ include to its existing or newly observed namespace. */\nfunction resolveLocalCppInclude(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: Map<string, SourceNodeDraft>,\n): string | undefined {\n const packageName = extractCppPackageFromInclude(specifier);\n if (packageName === '') return undefined;\n const key = sourceSemanticPath('namespace', file.projectId, packageName);\n if (!nodes.has(key)) {\n nodes.set(key, {\n data: {\n semanticPath: key,\n kind: 'package',\n name: packageName,\n projectId: file.projectId,\n packageName,\n classification: 'intrinsic',\n },\n });\n }\n return key;\n}\n\n/*** Resolve imports against namespaces declared by Kotlin, Python, and Delphi source files. */\nfunction resolveNamespaceImport(\n file: SourceAnalyzedFile,\n specifier: string,\n namespaces: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n const candidates = namespaces.get(file.projectId) ?? [];\n const matching =\n file.analyzerId === 'python'\n ? candidates.find((name) => name === extractPythonPackageFromImport(specifier))\n : file.analyzerId === 'delphi'\n ? candidates.find((name) => name === extractDelphiPackageFromImport(specifier))\n : candidates.find((name) => specifier === name || specifier.startsWith(`${name}.`));\n return matching === undefined\n ? undefined\n : sourceSemanticPath('namespace', file.projectId, matching);\n}\n\n/*** Resolve an imported Java type or package from observed declarations. */\nfunction resolveJavaImport(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: ReadonlyMap<string, SourceNodeDraft>,\n symbols: ReadonlyMap<string, string>,\n namespaces: ReadonlyMap<string, readonly string[]>,\n): string | undefined {\n const name = specifier.replace(/\\.\\*$/u, '');\n const separator = name.lastIndexOf('.');\n const packageName = separator < 0 ? '' : name.slice(0, separator);\n const simpleName = name.slice(separator + 1);\n const symbol = symbols.get(symbolKey(file.projectId, packageName, simpleName));\n if (symbol !== undefined) return symbol;\n const namespace = sourceSemanticPath('namespace', file.projectId, name);\n if (nodes.has(namespace)) return namespace;\n return resolveNamespaceImport(file, specifier, namespaces);\n}\n\n/*** Resolve a relative TypeScript import to a scanned source file. */\nfunction resolveTypeScriptFileImport(\n file: SourceAnalyzedFile,\n specifier: string,\n resolvedPath: string | undefined,\n nodes: ReadonlyMap<string, SourceNodeDraft>,\n): string | undefined {\n if (resolvedPath !== undefined) {\n const resolved = fileKey(file.projectId, resolvedPath);\n if (nodes.has(resolved)) return resolved;\n }\n if (!specifier.startsWith('.')) return undefined;\n const base = path.posix.normalize(path.posix.join(path.posix.dirname(file.path), specifier));\n const candidates = [\n base,\n `${base}.ts`,\n `${base}.tsx`,\n `${base}.mts`,\n `${base}.cts`,\n `${base}/index.ts`,\n `${base}/index.tsx`,\n ];\n return candidates\n .map((candidate) => fileKey(file.projectId, candidate))\n .find((key) => nodes.has(key));\n}\n\n/*** Distinguish declared vendor imports, focus packages, and unresolved imports. */\nfunction resolveExternalImport(\n file: SourceAnalyzedFile,\n specifier: string,\n nodes: Map<string, SourceNodeDraft>,\n focusPackages: ReadonlyMap<string, string>,\n): ResolvedImport {\n const packageName = packageFromSpecifier(file.analyzerId, specifier);\n const declarations =\n packageName === undefined\n ? []\n : (Object.entries(file.declaredDependencies ?? {}).find(\n ([name]) => name === packageName,\n )?.[1] ?? []);\n const focus = packageName === undefined ? undefined : focusPackages.get(packageName);\n if (focus !== undefined) return { target: focus, declarations };\n const external = sourceSemanticPath('external', file.projectId, packageName ?? specifier);\n if (!nodes.has(external)) {\n nodes.set(external, {\n data: {\n semanticPath: external,\n kind: 'package',\n name: packageName ?? specifier,\n projectId: file.projectId,\n packageName: packageName ?? specifier,\n classification:\n file.analyzerId === 'typescript' && declarations.length > 0 ? 'vendor' : 'unknown',\n },\n });\n }\n return { target: external, declarations };\n}\n\n/*** Project an unresolved reference onto the established package naming semantics. */\nfunction packageFromSpecifier(analyzerId: string, specifier: string): string | undefined {\n if (analyzerId === 'java') return extractJavaPackageFromImport(specifier);\n if (analyzerId === 'kotlin') return extractKotlinPackageFromImport(specifier);\n if (analyzerId === 'python') return extractPythonPackageFromImport(specifier);\n if (analyzerId === 'delphi') return extractDelphiPackageFromImport(specifier);\n if (analyzerId === 'cpp') return extractCppPackageFromInclude(specifier);\n return barePackageName(specifier);\n}\n\n/*** Extract the declared npm package identity from a bare module specifier. */\nfunction barePackageName(specifier: string): string | undefined {\n if (\n specifier === '' ||\n specifier.startsWith('.') ||\n specifier.startsWith('#') ||\n specifier.startsWith('/')\n )\n return undefined;\n const segments = specifier.split('/');\n return specifier.startsWith('@')\n ? segments.length >= 2\n ? `${segments[0]}/${segments[1]}`\n : undefined\n : segments[0];\n}\n\n/*** Scope type names without confusing same names in separate Java packages. */\nfunction symbolKey(projectId: string, packageName: string, name: string): string {\n return sourceSemanticPath(projectId, packageName, name);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraphApi.d.ts","sourceRoot":"","sources":["../../src/types/dependencyGraphApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,SAAS,2BAA2B,EAAE,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyGraphApi.js","sourceRoot":"","sources":["../../src/types/dependencyGraphApi.ts"],"names":[],"mappings":"","sourcesContent":["import type { DependencyGraphProjectInput } from './dependencyGraph.js';\n\nexport interface DependencyGraphApiInput {\n readonly projects: readonly DependencyGraphProjectInput[];\n}\n"]}
|
|
@@ -33,6 +33,7 @@ export interface SourceImportFact {
|
|
|
33
33
|
readonly local?: boolean;
|
|
34
34
|
readonly location?: SourceLocation;
|
|
35
35
|
readonly specifier: string;
|
|
36
|
+
readonly resolvedPath?: string;
|
|
36
37
|
readonly typeOnly?: boolean;
|
|
37
38
|
}
|
|
38
39
|
/*** Portable facts extracted from one source file by its language analyzer. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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Q,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,GAAG,SAAS,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;CACrF;AACD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceGraph.js","sourceRoot":"","sources":["../../src/types/sourceGraph.ts"],"names":[],"mappings":"","sourcesContent":["/*** A portable one-based source span emitted by a language analyzer. */\nexport interface SourceLocation {\n readonly column: number;\n readonly endColumn: number;\n readonly endLine: number;\n readonly line: number;\n}\n\n/*** Analyzer-observed source documentation, distinct from consumer interpretation. */\nexport interface SourceDocumentation {\n readonly text: string;\n readonly tags: Readonly<Record<string, readonly string[]>>;\n}\n\ntype SourceDeclarationKind =\n 'class' | 'constant' | 'enum' | 'function' | 'interface' | 'method' | 'type' | 'variable';\n\nexport type SourceVisibility = 'package' | 'private' | 'protected' | 'public';\n\n/*** A source declaration before graph-wide identity and relationship resolution. */\nexport interface SourceDeclarationFact {\n readonly children: readonly SourceDeclarationFact[];\n readonly documentation?: SourceDocumentation;\n readonly exported?: boolean;\n readonly typeOnly?: boolean;\n readonly extends: readonly string[];\n readonly implements: readonly string[];\n readonly kind: SourceDeclarationKind;\n readonly location: SourceLocation;\n readonly modifiers: readonly string[];\n readonly name: string;\n readonly signature?: string;\n readonly visibility: SourceVisibility;\n}\n\n/*** An import observed at an exact source position. */\nexport interface SourceImportFact {\n readonly kind?: 'import' | 'reexport';\n readonly local?: boolean;\n readonly location?: SourceLocation;\n readonly specifier: string;\n readonly typeOnly?: boolean;\n}\n\n/*** Portable facts extracted from one source file by its language analyzer. */\nexport interface SourceFileFacts {\n readonly declarations: readonly SourceDeclarationFact[];\n readonly imports: readonly SourceImportFact[];\n readonly packageName?: string;\n}\n\n/*** Analyzer capabilities whose absence must not be interpreted as a negative fact. */\nexport type SourceCapability =\n | 'calls'\n | 'containment'\n | 'declarations'\n | 'documentation'\n | 'exports'\n | 'extends'\n | 'implements'\n | 'imports'\n | 'signatures'\n | 'source-locations'\n | 'visibility';\n\nexport interface SourceCapabilityReport {\n readonly analyzerId: string;\n readonly available: readonly SourceCapability[];\n readonly projectId: string;\n}\n\nexport type SourceNodeKind = 'project' | 'package' | 'directory' | 'file' | SourceDeclarationKind;\nexport type SourceRelationKind =\n 'contains' | 'declares-in' | 'exports' | 'extends' | 'implements' | 'imports';\n\n/*** Factual node data with a stable semantic key independent from its dense local ID. */\nexport interface SourceNodeData {\n readonly analyzerId?: string;\n readonly kind: SourceNodeKind;\n readonly semanticPath: string;\n readonly name: string;\n readonly projectId: string;\n readonly filePath?: string;\n readonly path?: string;\n readonly packageName?: string;\n readonly classification?: 'intrinsic' | 'unknown' | 'vendor';\n readonly location?: SourceLocation;\n readonly visibility?: SourceVisibility;\n readonly modifiers?: readonly string[];\n readonly signature?: string;\n readonly documentation?: SourceDocumentation;\n readonly typeOnly?: boolean;\n}\n\n/*** Evidence for one observed relationship, including analyzer provenance. */\nexport interface SourceRelationEvidence {\n readonly analyzerId: string;\n readonly sourcePath: string;\n readonly location?: SourceLocation;\n readonly specifier?: string;\n readonly typeOnly?: boolean;\n readonly declarations?: readonly DependencyDeclaration[];\n}\n\nexport interface SourceEdgeData {\n readonly kind: SourceRelationKind;\n readonly evidence: readonly SourceRelationEvidence[];\n}\n\n/*** Compact serializable source graph; its indexes and rollups are derived separately. */\nexport interface SourceGraph {\n readonly version: 1;\n readonly graph: Graph<SourceNodeData, SourceEdgeData, number, number>;\n readonly capabilities: readonly SourceCapabilityReport[];\n}\n\nexport interface SourceNodeDraft {\n readonly data: SourceNodeData;\n}\n\nexport interface SourceEdgeDraft {\n readonly source: string;\n readonly target: string;\n readonly data: SourceEdgeData;\n}\n\nexport interface SourceGraphDraft {\n readonly nodes: readonly SourceNodeDraft[];\n readonly edges: readonly SourceEdgeDraft[];\n readonly capabilities: readonly SourceCapabilityReport[];\n}\n\n/*** Parsed source fact associated with a project-relative path. */\nexport interface SourceAnalyzedFile {\n readonly analyzerId: string;\n readonly facts: SourceFileFacts;\n readonly path: string;\n readonly projectId: string;\n readonly declaredDependencies?: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface SourceInspectionProjectInput {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\nexport interface CreateSourceGraphFromInspectionsInput {\n readonly projects: readonly SourceInspectionProjectInput[];\n readonly signal?: AbortSignal;\n}\n\nexport interface CreateSourceGraphInput {\n readonly projects: readonly { readonly id: string; readonly rootPath: string }[];\n readonly signal?: AbortSignal;\n}\n\n/*** Indexed semantic access built from a serializable source graph snapshot. */\nexport interface SourceGraphIndex {\n readonly nodeById: ReadonlyMap<number, GraphNode<SourceNodeData, number>>;\n readonly nodeBySemanticPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;\n readonly fileByPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;\n readonly symbolsByFileAndName: ReadonlyMap<string, readonly GraphNode<SourceNodeData, number>[]>;\n readonly incomingByNodeId: ReadonlyMap<\n number,\n readonly GraphEdge<SourceEdgeData, number, number>[]\n >;\n readonly outgoingByNodeId: ReadonlyMap<\n number,\n readonly GraphEdge<SourceEdgeData, number, number>[]\n >;\n readonly parentByNodeId: ReadonlyMap<number, number>;\n}\n\n/*** Semantic relation view with source evidence and no required ID lookup. */\nexport interface SourceRelationView {\n readonly edgeId: number;\n readonly kind: SourceRelationKind;\n readonly source: SourceNodeData;\n readonly target: SourceNodeData;\n readonly evidence: readonly SourceRelationEvidence[];\n}\n\n/*** Pairwise projected dependency with references to canonical observed edges. */\nexport interface SourceRollupEdge {\n readonly source: number;\n readonly target: number;\n readonly sourceSemanticPath: string;\n readonly targetSemanticPath: string;\n readonly weight: number;\n readonly evidenceEdgeIds: readonly number[];\n}\n\n/*** Cached semantic queries for one deterministic projection level. */\nexport interface SourceRollupIndex {\n readonly byPair: ReadonlyMap<string, SourceRollupEdge>;\n readonly outgoingBySource: ReadonlyMap<string, readonly SourceRollupEdge[]>;\n}\n\nexport interface SourceNodeSummary {\n readonly nodeId: number;\n readonly descendants: Readonly<Partial<Record<SourceNodeKind, number>>>;\n readonly exports: Readonly<{ readonly runtime: number; readonly typeOnly: number }>;\n readonly incomingRelations: number;\n readonly outgoingRelations: number;\n readonly dependencies: Readonly<Record<'intrinsic' | 'unknown' | 'vendor', number>>;\n}\nimport type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type { DependencyDeclaration } from './dependencyGraph.js';\n"]}
|
|
1
|
+
{"version":3,"file":"sourceGraph.js","sourceRoot":"","sources":["../../src/types/sourceGraph.ts"],"names":[],"mappings":"","sourcesContent":["/*** A portable one-based source span emitted by a language analyzer. */\nexport interface SourceLocation {\n readonly column: number;\n readonly endColumn: number;\n readonly endLine: number;\n readonly line: number;\n}\n\n/*** Analyzer-observed source documentation, distinct from consumer interpretation. */\nexport interface SourceDocumentation {\n readonly text: string;\n readonly tags: Readonly<Record<string, readonly string[]>>;\n}\n\ntype SourceDeclarationKind =\n 'class' | 'constant' | 'enum' | 'function' | 'interface' | 'method' | 'type' | 'variable';\n\nexport type SourceVisibility = 'package' | 'private' | 'protected' | 'public';\n\n/*** A source declaration before graph-wide identity and relationship resolution. */\nexport interface SourceDeclarationFact {\n readonly children: readonly SourceDeclarationFact[];\n readonly documentation?: SourceDocumentation;\n readonly exported?: boolean;\n readonly typeOnly?: boolean;\n readonly extends: readonly string[];\n readonly implements: readonly string[];\n readonly kind: SourceDeclarationKind;\n readonly location: SourceLocation;\n readonly modifiers: readonly string[];\n readonly name: string;\n readonly signature?: string;\n readonly visibility: SourceVisibility;\n}\n\n/*** An import observed at an exact source position. */\nexport interface SourceImportFact {\n readonly kind?: 'import' | 'reexport';\n readonly local?: boolean;\n readonly location?: SourceLocation;\n readonly specifier: string;\n readonly resolvedPath?: string;\n readonly typeOnly?: boolean;\n}\n\n/*** Portable facts extracted from one source file by its language analyzer. */\nexport interface SourceFileFacts {\n readonly declarations: readonly SourceDeclarationFact[];\n readonly imports: readonly SourceImportFact[];\n readonly packageName?: string;\n}\n\n/*** Analyzer capabilities whose absence must not be interpreted as a negative fact. */\nexport type SourceCapability =\n | 'calls'\n | 'containment'\n | 'declarations'\n | 'documentation'\n | 'exports'\n | 'extends'\n | 'implements'\n | 'imports'\n | 'signatures'\n | 'source-locations'\n | 'visibility';\n\nexport interface SourceCapabilityReport {\n readonly analyzerId: string;\n readonly available: readonly SourceCapability[];\n readonly projectId: string;\n}\n\nexport type SourceNodeKind = 'project' | 'package' | 'directory' | 'file' | SourceDeclarationKind;\nexport type SourceRelationKind =\n 'contains' | 'declares-in' | 'exports' | 'extends' | 'implements' | 'imports';\n\n/*** Factual node data with a stable semantic key independent from its dense local ID. */\nexport interface SourceNodeData {\n readonly analyzerId?: string;\n readonly kind: SourceNodeKind;\n readonly semanticPath: string;\n readonly name: string;\n readonly projectId: string;\n readonly filePath?: string;\n readonly path?: string;\n readonly packageName?: string;\n readonly classification?: 'intrinsic' | 'unknown' | 'vendor';\n readonly location?: SourceLocation;\n readonly visibility?: SourceVisibility;\n readonly modifiers?: readonly string[];\n readonly signature?: string;\n readonly documentation?: SourceDocumentation;\n readonly typeOnly?: boolean;\n}\n\n/*** Evidence for one observed relationship, including analyzer provenance. */\nexport interface SourceRelationEvidence {\n readonly analyzerId: string;\n readonly sourcePath: string;\n readonly location?: SourceLocation;\n readonly specifier?: string;\n readonly typeOnly?: boolean;\n readonly declarations?: readonly DependencyDeclaration[];\n}\n\nexport interface SourceEdgeData {\n readonly kind: SourceRelationKind;\n readonly evidence: readonly SourceRelationEvidence[];\n}\n\n/*** Compact serializable source graph; its indexes and rollups are derived separately. */\nexport interface SourceGraph {\n readonly version: 1;\n readonly graph: Graph<SourceNodeData, SourceEdgeData, number, number>;\n readonly capabilities: readonly SourceCapabilityReport[];\n}\n\nexport interface SourceNodeDraft {\n readonly data: SourceNodeData;\n}\n\nexport interface SourceEdgeDraft {\n readonly source: string;\n readonly target: string;\n readonly data: SourceEdgeData;\n}\n\nexport interface SourceGraphDraft {\n readonly nodes: readonly SourceNodeDraft[];\n readonly edges: readonly SourceEdgeDraft[];\n readonly capabilities: readonly SourceCapabilityReport[];\n}\n\n/*** Parsed source fact associated with a project-relative path. */\nexport interface SourceAnalyzedFile {\n readonly analyzerId: string;\n readonly facts: SourceFileFacts;\n readonly path: string;\n readonly projectId: string;\n readonly declaredDependencies?: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface SourceInspectionProjectInput {\n readonly id: string;\n readonly inspection: ProjectInspection;\n}\n\nexport interface CreateSourceGraphFromInspectionsInput {\n readonly projects: readonly SourceInspectionProjectInput[];\n readonly signal?: AbortSignal;\n}\n\nexport interface CreateSourceGraphInput {\n readonly projects: readonly { readonly id: string; readonly rootPath: string }[];\n readonly signal?: AbortSignal;\n}\n\n/*** Indexed semantic access built from a serializable source graph snapshot. */\nexport interface SourceGraphIndex {\n readonly nodeById: ReadonlyMap<number, GraphNode<SourceNodeData, number>>;\n readonly nodeBySemanticPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;\n readonly fileByPath: ReadonlyMap<string, GraphNode<SourceNodeData, number>>;\n readonly symbolsByFileAndName: ReadonlyMap<string, readonly GraphNode<SourceNodeData, number>[]>;\n readonly incomingByNodeId: ReadonlyMap<\n number,\n readonly GraphEdge<SourceEdgeData, number, number>[]\n >;\n readonly outgoingByNodeId: ReadonlyMap<\n number,\n readonly GraphEdge<SourceEdgeData, number, number>[]\n >;\n readonly parentByNodeId: ReadonlyMap<number, number>;\n}\n\n/*** Semantic relation view with source evidence and no required ID lookup. */\nexport interface SourceRelationView {\n readonly edgeId: number;\n readonly kind: SourceRelationKind;\n readonly source: SourceNodeData;\n readonly target: SourceNodeData;\n readonly evidence: readonly SourceRelationEvidence[];\n}\n\n/*** Pairwise projected dependency with references to canonical observed edges. */\nexport interface SourceRollupEdge {\n readonly source: number;\n readonly target: number;\n readonly sourceSemanticPath: string;\n readonly targetSemanticPath: string;\n readonly weight: number;\n readonly evidenceEdgeIds: readonly number[];\n}\n\n/*** Cached semantic queries for one deterministic projection level. */\nexport interface SourceRollupIndex {\n readonly byPair: ReadonlyMap<string, SourceRollupEdge>;\n readonly outgoingBySource: ReadonlyMap<string, readonly SourceRollupEdge[]>;\n}\n\nexport interface SourceNodeSummary {\n readonly nodeId: number;\n readonly descendants: Readonly<Partial<Record<SourceNodeKind, number>>>;\n readonly exports: Readonly<{ readonly runtime: number; readonly typeOnly: number }>;\n readonly incomingRelations: number;\n readonly outgoingRelations: number;\n readonly dependencies: Readonly<Record<'intrinsic' | 'unknown' | 'vendor', number>>;\n}\nimport type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type { DependencyDeclaration } from './dependencyGraph.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/dependency-graph",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Project-aware dependency analysis that produces canonical Ankhorage graphs.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"types": "./dist/dependencyGraph.d.ts",
|
|
33
33
|
"import": "./dist/dependencyGraph.js"
|
|
34
34
|
},
|
|
35
|
+
"./api": {
|
|
36
|
+
"types": "./dist/dependencyGraphApi.d.ts",
|
|
37
|
+
"import": "./dist/dependencyGraphApi.js"
|
|
38
|
+
},
|
|
35
39
|
"./package.json": "./package.json"
|
|
36
40
|
},
|
|
37
41
|
"publishConfig": {
|
|
@@ -57,20 +61,18 @@
|
|
|
57
61
|
"knip:check": "ankhorage-knip"
|
|
58
62
|
},
|
|
59
63
|
"dependencies": {
|
|
64
|
+
"@ankhorage/api": "^0.2.0",
|
|
60
65
|
"@ankhorage/graph": "^0.3.0",
|
|
61
66
|
"@ankhorage/project-detector": "^0.3.0",
|
|
62
67
|
"@ankhorage/utility": "^0.8.0",
|
|
63
|
-
"java-parser": "^3.0.1"
|
|
64
|
-
},
|
|
65
|
-
"peerDependencies": {
|
|
68
|
+
"java-parser": "^3.0.1",
|
|
66
69
|
"typescript": "~6.0.3"
|
|
67
70
|
},
|
|
68
71
|
"devDependencies": {
|
|
69
72
|
"@ankhorage/devtools": "^1.14.7",
|
|
70
73
|
"@ankhorage/paradox": "^0.1.26",
|
|
71
74
|
"@types/bun": "^1.4.2",
|
|
72
|
-
"@types/node": "^26.5.1"
|
|
73
|
-
"typescript": "~6.0.3"
|
|
75
|
+
"@types/node": "^26.5.1"
|
|
74
76
|
},
|
|
75
77
|
"packageManager": "bun@1.4.2"
|
|
76
78
|
}
|