@ankhorage/dependency-graph 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +5 -0
  4. package/dist/dependencyGraph.d.ts +4 -0
  5. package/dist/dependencyGraph.d.ts.map +1 -0
  6. package/dist/dependencyGraph.js +3 -0
  7. package/dist/dependencyGraph.js.map +1 -0
  8. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts +4 -0
  9. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts.map +1 -0
  10. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js +92 -0
  11. package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js.map +1 -0
  12. package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.d.ts +3 -0
  13. package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.d.ts.map +1 -0
  14. package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.js +52 -0
  15. package/dist/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.js.map +1 -0
  16. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts +5 -0
  17. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts.map +1 -0
  18. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js +29 -0
  19. package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js.map +1 -0
  20. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts +3 -0
  21. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts.map +1 -0
  22. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js +9 -0
  23. package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js.map +1 -0
  24. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts +3 -0
  25. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts.map +1 -0
  26. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js +8 -0
  27. package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js.map +1 -0
  28. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts +11 -0
  29. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts.map +1 -0
  30. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js +76 -0
  31. package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js.map +1 -0
  32. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts +4 -0
  33. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts.map +1 -0
  34. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js +8 -0
  35. package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js.map +1 -0
  36. package/dist/features/dependency-analysis/application/createDependencyGraphAsync.d.ts +4 -0
  37. package/dist/features/dependency-analysis/application/createDependencyGraphAsync.d.ts.map +1 -0
  38. package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js +105 -0
  39. package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js.map +1 -0
  40. package/dist/features/dependency-analysis/domain/createFocusPackageNode.d.ts +5 -0
  41. package/dist/features/dependency-analysis/domain/createFocusPackageNode.d.ts.map +1 -0
  42. package/dist/features/dependency-analysis/domain/createFocusPackageNode.js +16 -0
  43. package/dist/features/dependency-analysis/domain/createFocusPackageNode.js.map +1 -0
  44. package/dist/features/dependency-analysis/domain/readDependencyDeclarationsAsync.d.ts +4 -0
  45. package/dist/features/dependency-analysis/domain/readDependencyDeclarationsAsync.d.ts.map +1 -0
  46. package/dist/features/dependency-analysis/domain/readDependencyDeclarationsAsync.js +27 -0
  47. package/dist/features/dependency-analysis/domain/readDependencyDeclarationsAsync.js.map +1 -0
  48. package/dist/types/dependencyGraph.d.ts +69 -0
  49. package/dist/types/dependencyGraph.d.ts.map +1 -0
  50. package/dist/types/dependencyGraph.js +2 -0
  51. package/dist/types/dependencyGraph.js.map +1 -0
  52. package/examples/basic-usage/analyze.ts +13 -0
  53. package/package.json +74 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ankhorage/dependency-graph
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b528b28: Add project-aware dependency graph analysis with a first TypeScript import analyzer.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ankhorage
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @ankhorage/dependency-graph
2
+
3
+ Project-aware dependency analysis that produces canonical `@ankhorage/graph` data.
4
+
5
+ The first analyzer covers TypeScript static imports. Project detection is delegated to `@ankhorage/project-detector`. Cytoscape, UI, update execution, and GitHub transport are intentionally outside this package.
@@ -0,0 +1,4 @@
1
+ export { typescriptDependencyGraphAnalyzer } from './features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';
2
+ export { createDependencyGraphAsync } from './features/dependency-analysis/application/createDependencyGraphAsync.js';
3
+ export type { CreateDependencyGraphInput, DependencyDeclaration, DependencyDeclarationKind, DependencyGraph, DependencyGraphAnalyzer, DependencyGraphAnalyzerContext, DependencyGraphEdgeData, DependencyGraphFragment, DependencyGraphNodeData, DependencyGraphPackage, DependencyGraphProjectInput, DependencyImportEvidence, DependencyNodeClassification, DependencyNodeKind, DependencyReferenceClassification, } from './types/dependencyGraph.js';
4
+ //# sourceMappingURL=dependencyGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,kGAAkG,CAAC;AACrJ,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,YAAY,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { typescriptDependencyGraphAnalyzer } from './features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';
2
+ export { createDependencyGraphAsync } from './features/dependency-analysis/application/createDependencyGraphAsync.js';
3
+ //# sourceMappingURL=dependencyGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,kGAAkG,CAAC;AACrJ,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC","sourcesContent":["export { typescriptDependencyGraphAnalyzer } from './features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';\nexport { createDependencyGraphAsync } from './features/dependency-analysis/application/createDependencyGraphAsync.js';\nexport type {\n CreateDependencyGraphInput,\n DependencyDeclaration,\n DependencyDeclarationKind,\n DependencyGraph,\n DependencyGraphAnalyzer,\n DependencyGraphAnalyzerContext,\n DependencyGraphEdgeData,\n DependencyGraphFragment,\n DependencyGraphNodeData,\n DependencyGraphPackage,\n DependencyGraphProjectInput,\n DependencyImportEvidence,\n DependencyNodeClassification,\n DependencyNodeKind,\n DependencyReferenceClassification,\n} from './types/dependencyGraph.js';\n"]}
@@ -0,0 +1,4 @@
1
+ import type { DependencyGraphAnalyzerContext, DependencyGraphFragment } from '../../../../../types/dependencyGraph.js';
2
+ /*** Analyze one detected TypeScript package into module/import dependency evidence. */
3
+ export declare function analyzeTypeScriptProjectAsync(context: DependencyGraphAnalyzerContext): Promise<DependencyGraphFragment>;
4
+ //# sourceMappingURL=analyzeTypeScriptProjectAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzeTypeScriptProjectAsync.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,8BAA8B,EAE9B,uBAAuB,EAGxB,MAAM,yCAAyC,CAAC;AAOjD,uFAAuF;AACvF,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,uBAAuB,CAAC,CAwBlC"}
@@ -0,0 +1,92 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { toPortablePath } from '@ankhorage/utility/node/path';
4
+ import { collectTypeScriptFilesAsync } from './collectTypeScriptFilesAsync.js';
5
+ import { createTypeScriptModuleNodes } from './createTypeScriptModuleNodes.js';
6
+ import { extractTypeScriptImports } from './extractTypeScriptImports.js';
7
+ import { modulePathForFile } from './modulePathForFile.js';
8
+ import { resolveTypeScriptImport } from './resolveTypeScriptImport.js';
9
+ /*** Analyze one detected TypeScript package into module/import dependency evidence. */
10
+ export async function analyzeTypeScriptProjectAsync(context) {
11
+ const language = context.package.detection.languages.find(({ id }) => id === 'typescript');
12
+ const files = await collectTypeScriptFilesAsync(context.package.rootPath, language?.sourceRoots ?? ['.'], context.excludedRoots, context.signal);
13
+ const sourceFiles = new Set(files);
14
+ const nodes = new Map(createTypeScriptModuleNodes(context.package, files).map((node) => [node.id, node]));
15
+ const edges = new Map();
16
+ for (const file of files) {
17
+ context.signal?.throwIfAborted();
18
+ const sourceNodeId = nodeIdForFile(context, file);
19
+ const imports = extractTypeScriptImports(file, await readFile(file, 'utf8'));
20
+ for (const specifier of imports) {
21
+ addImport(context, file, sourceNodeId, specifier, sourceFiles, nodes, edges);
22
+ }
23
+ }
24
+ return { nodes: [...nodes.values()], edges: [...edges.values()] };
25
+ }
26
+ /*** Aggregate one import into stable target nodes and weighted evidence. */
27
+ function addImport(context, sourceFile, sourceNodeId, specifier, sourceFiles, nodes, edges) {
28
+ const resolved = resolveTypeScriptImport(context.package, sourceFile, specifier, sourceFiles, context.focusPackages);
29
+ if (resolved.targetNodeId === sourceNodeId)
30
+ return;
31
+ addTargetNode(context, resolved, nodes);
32
+ const edgeId = `${sourceNodeId}->${resolved.targetNodeId}`;
33
+ const evidence = {
34
+ sourceFile: toPortablePath(path.relative(context.package.rootPath, sourceFile)),
35
+ specifier,
36
+ classification: resolved.classification,
37
+ declarations: resolved.declarations,
38
+ };
39
+ const existing = edges.get(edgeId);
40
+ edges.set(edgeId, {
41
+ id: edgeId,
42
+ source: sourceNodeId,
43
+ target: resolved.targetNodeId,
44
+ data: {
45
+ kind: 'import',
46
+ analyzerId: 'typescript',
47
+ weight: (existing?.data.weight ?? 0) + 1,
48
+ evidence: [...(existing?.data.evidence ?? []), evidence],
49
+ },
50
+ });
51
+ }
52
+ /*** Materialize intrinsic, vendor and unknown targets while focus targets are globally owned. */
53
+ function addTargetNode(context, resolved, nodes) {
54
+ if (resolved.classification === 'focus' || nodes.has(resolved.targetNodeId))
55
+ return;
56
+ if (resolved.classification === 'intrinsic') {
57
+ if (resolved.targetPath === undefined || resolved.targetPath === '')
58
+ return;
59
+ nodes.set(resolved.targetNodeId, {
60
+ id: resolved.targetNodeId,
61
+ data: {
62
+ kind: 'module',
63
+ classification: 'intrinsic',
64
+ focus: true,
65
+ label: resolved.targetPath.split('.').at(-1) ?? resolved.targetPath,
66
+ projectId: context.package.projectId,
67
+ ...(context.package.name === undefined ? {} : { packageName: context.package.name }),
68
+ path: resolved.targetPath,
69
+ parentPath: resolved.targetPath.includes('.')
70
+ ? resolved.targetPath.split('.').slice(0, -1).join('.')
71
+ : '',
72
+ },
73
+ });
74
+ return;
75
+ }
76
+ nodes.set(resolved.targetNodeId, {
77
+ id: resolved.targetNodeId,
78
+ data: {
79
+ kind: 'package',
80
+ classification: resolved.classification,
81
+ focus: false,
82
+ label: resolved.packageName ?? resolved.targetNodeId.replace(/^unknown:/u, ''),
83
+ ...(resolved.packageName === undefined ? {} : { packageName: resolved.packageName }),
84
+ },
85
+ });
86
+ }
87
+ /*** Resolve the source node at package granularity, using the package root for root-level files. */
88
+ function nodeIdForFile(context, file) {
89
+ const modulePath = modulePathForFile(context.package.rootPath, file);
90
+ return modulePath === '' ? context.package.nodeId : `${context.package.nodeId}#${modulePath}`;
91
+ }
92
+ //# sourceMappingURL=analyzeTypeScriptProjectAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzeTypeScriptProjectAsync.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAS9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAuC;IAEvC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC;IAC3F,MAAM,KAAK,GAAG,MAAM,2BAA2B,CAC7C,OAAO,CAAC,OAAO,CAAC,QAAQ,EACxB,QAAQ,EAAE,WAAW,IAAI,CAAC,GAAG,CAAC,EAC9B,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,MAAM,CACf,CAAC;IACF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,2BAA2B,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,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AAO,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;AAChG,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { GraphEdge, GraphNode } from '@ankhorage/graph';\nimport { toPortablePath } from '@ankhorage/utility/node/path';\n\nimport type {\n DependencyGraphAnalyzerContext,\n DependencyGraphEdgeData,\n DependencyGraphFragment,\n DependencyGraphNodeData,\n DependencyImportEvidence,\n} from '../../../../../types/dependencyGraph.js';\nimport { collectTypeScriptFilesAsync } from './collectTypeScriptFilesAsync.js';\nimport { createTypeScriptModuleNodes } from './createTypeScriptModuleNodes.js';\nimport { extractTypeScriptImports } from './extractTypeScriptImports.js';\nimport { modulePathForFile } from './modulePathForFile.js';\nimport { resolveTypeScriptImport } from './resolveTypeScriptImport.js';\n\n/*** Analyze one detected TypeScript package into module/import dependency evidence. */\nexport async function analyzeTypeScriptProjectAsync(\n context: DependencyGraphAnalyzerContext,\n): Promise<DependencyGraphFragment> {\n const language = context.package.detection.languages.find(({ id }) => id === 'typescript');\n const files = await collectTypeScriptFilesAsync(\n context.package.rootPath,\n language?.sourceRoots ?? ['.'],\n context.excludedRoots,\n context.signal,\n );\n const sourceFiles = new Set(files);\n const nodes = new Map(\n createTypeScriptModuleNodes(context.package, files).map((node) => [node.id, node] as const),\n );\n const edges = new Map<string, GraphEdge<DependencyGraphEdgeData>>();\n\n for (const file of files) {\n context.signal?.throwIfAborted();\n const sourceNodeId = nodeIdForFile(context, file);\n const imports = extractTypeScriptImports(file, await readFile(file, 'utf8'));\n for (const specifier of imports) {\n addImport(context, file, sourceNodeId, specifier, sourceFiles, nodes, edges);\n }\n }\n\n return { nodes: [...nodes.values()], edges: [...edges.values()] };\n}\n\n/*** Aggregate one import into stable target nodes and weighted evidence. */\nfunction addImport(\n context: DependencyGraphAnalyzerContext,\n sourceFile: string,\n sourceNodeId: string,\n specifier: string,\n sourceFiles: ReadonlySet<string>,\n nodes: Map<string, GraphNode<DependencyGraphNodeData>>,\n edges: Map<string, GraphEdge<DependencyGraphEdgeData>>,\n): void {\n const resolved = resolveTypeScriptImport(\n context.package,\n sourceFile,\n specifier,\n sourceFiles,\n context.focusPackages,\n );\n if (resolved.targetNodeId === sourceNodeId) return;\n addTargetNode(context, resolved, nodes);\n const edgeId = `${sourceNodeId}->${resolved.targetNodeId}`;\n const evidence: DependencyImportEvidence = {\n sourceFile: toPortablePath(path.relative(context.package.rootPath, sourceFile)),\n specifier,\n classification: resolved.classification,\n declarations: resolved.declarations,\n };\n const existing = edges.get(edgeId);\n edges.set(edgeId, {\n id: edgeId,\n source: sourceNodeId,\n target: resolved.targetNodeId,\n data: {\n kind: 'import',\n analyzerId: 'typescript',\n weight: (existing?.data.weight ?? 0) + 1,\n evidence: [...(existing?.data.evidence ?? []), evidence],\n },\n });\n}\n\n/*** Materialize intrinsic, vendor and unknown targets while focus targets are globally owned. */\nfunction addTargetNode(\n context: DependencyGraphAnalyzerContext,\n resolved: ReturnType<typeof resolveTypeScriptImport>,\n nodes: Map<string, GraphNode<DependencyGraphNodeData>>,\n): void {\n if (resolved.classification === 'focus' || nodes.has(resolved.targetNodeId)) return;\n if (resolved.classification === 'intrinsic') {\n if (resolved.targetPath === undefined || resolved.targetPath === '') return;\n nodes.set(resolved.targetNodeId, {\n id: resolved.targetNodeId,\n data: {\n kind: 'module',\n classification: 'intrinsic',\n focus: true,\n label: resolved.targetPath.split('.').at(-1) ?? resolved.targetPath,\n projectId: context.package.projectId,\n ...(context.package.name === undefined ? {} : { packageName: context.package.name }),\n path: resolved.targetPath,\n parentPath: resolved.targetPath.includes('.')\n ? resolved.targetPath.split('.').slice(0, -1).join('.')\n : '',\n },\n });\n return;\n }\n\n nodes.set(resolved.targetNodeId, {\n id: resolved.targetNodeId,\n data: {\n kind: 'package',\n classification: resolved.classification,\n focus: false,\n label: resolved.packageName ?? resolved.targetNodeId.replace(/^unknown:/u, ''),\n ...(resolved.packageName === undefined ? {} : { packageName: resolved.packageName }),\n },\n });\n}\n\n/*** Resolve the source node at package granularity, using the package root for root-level files. */\nfunction nodeIdForFile(context: DependencyGraphAnalyzerContext, file: string): string {\n const modulePath = modulePathForFile(context.package.rootPath, file);\n return modulePath === '' ? context.package.nodeId : `${context.package.nodeId}#${modulePath}`;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /*** Collect deterministic TypeScript source files without following symlinks or nested package roots. */
2
+ export declare function collectTypeScriptFilesAsync(rootPath: string, sourceRoots: readonly string[], excludedRoots: readonly string[], signal: AbortSignal | undefined): Promise<readonly string[]>;
3
+ //# sourceMappingURL=collectTypeScriptFilesAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectTypeScriptFilesAsync.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.ts"],"names":[],"mappings":"AAGA,yGAAyG;AACzG,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAW5B"}
@@ -0,0 +1,52 @@
1
+ import { opendir } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ /*** Collect deterministic TypeScript source files without following symlinks or nested package roots. */
4
+ export async function collectTypeScriptFilesAsync(rootPath, sourceRoots, excludedRoots, signal) {
5
+ const files = await Promise.all(sourceRoots.map((sourceRoot) => visitDirectoryAsync(sourceRoot === '.' ? rootPath : path.resolve(rootPath, sourceRoot), new Set(excludedRoots), signal)));
6
+ return [...new Set(files.flat())].sort();
7
+ }
8
+ const excludedDirectoryNames = new Set([
9
+ '.git',
10
+ '.next',
11
+ 'build',
12
+ 'coverage',
13
+ 'dist',
14
+ 'node_modules',
15
+ ]);
16
+ /*** Recursively collect TypeScript files from one source root. */
17
+ async function visitDirectoryAsync(directory, excludedRoots, signal) {
18
+ signal?.throwIfAborted();
19
+ try {
20
+ const handle = await opendir(directory);
21
+ const files = [];
22
+ for await (const entry of handle) {
23
+ signal?.throwIfAborted();
24
+ const target = path.join(directory, entry.name);
25
+ if (entry.isSymbolicLink())
26
+ continue;
27
+ if (entry.isDirectory()) {
28
+ if (excludedDirectoryNames.has(entry.name) || excludedRoots.has(target))
29
+ continue;
30
+ files.push(...(await visitDirectoryAsync(target, excludedRoots, signal)));
31
+ }
32
+ else if (entry.isFile() && isTypeScriptFile(entry.name)) {
33
+ files.push(target);
34
+ }
35
+ }
36
+ return files;
37
+ }
38
+ catch (error) {
39
+ if (isMissingPathError(error))
40
+ return [];
41
+ throw error;
42
+ }
43
+ }
44
+ /*** Identify TypeScript source suffixes supported by the first analyzer. */
45
+ function isTypeScriptFile(file) {
46
+ return ['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension));
47
+ }
48
+ /*** Treat absent optional detector source roots as empty instead of analysis failures. */
49
+ function isMissingPathError(error) {
50
+ return error instanceof Error && 'code' in error && error.code === 'ENOENT';
51
+ }
52
+ //# sourceMappingURL=collectTypeScriptFilesAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectTypeScriptFilesAsync.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/collectTypeScriptFilesAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,QAAgB,EAChB,WAA8B,EAC9B,aAAgC,EAChC,MAA+B;IAE/B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,WAAW,CAAC,GAAG,CA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AC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1D,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,kBAAkB,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,0FAA0F;AAC1F,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC","sourcesContent":["import { opendir } from 'node:fs/promises';\nimport path from 'node:path';\n\n/*** Collect deterministic TypeScript source files without following symlinks or nested package roots. */\nexport async function collectTypeScriptFilesAsync(\n rootPath: string,\n sourceRoots: readonly string[],\n excludedRoots: readonly string[],\n signal: AbortSignal | undefined,\n): Promise<readonly string[]> {\n const files = await Promise.all(\n sourceRoots.map((sourceRoot) =>\n visitDirectoryAsync(\n sourceRoot === '.' ? rootPath : path.resolve(rootPath, sourceRoot),\n new Set(excludedRoots),\n signal,\n ),\n ),\n );\n return [...new Set(files.flat())].sort();\n}\n\nconst excludedDirectoryNames = new Set([\n '.git',\n '.next',\n 'build',\n 'coverage',\n 'dist',\n 'node_modules',\n]);\n\n/*** Recursively collect TypeScript files from one source root. */\nasync function visitDirectoryAsync(\n directory: string,\n excludedRoots: ReadonlySet<string>,\n signal: AbortSignal | undefined,\n): Promise<readonly string[]> {\n signal?.throwIfAborted();\n try {\n const handle = await opendir(directory);\n const files: string[] = [];\n for await (const entry of handle) {\n signal?.throwIfAborted();\n const target = path.join(directory, entry.name);\n if (entry.isSymbolicLink()) continue;\n if (entry.isDirectory()) {\n if (excludedDirectoryNames.has(entry.name) || excludedRoots.has(target)) continue;\n files.push(...(await visitDirectoryAsync(target, excludedRoots, signal)));\n } else if (entry.isFile() && isTypeScriptFile(entry.name)) {\n files.push(target);\n }\n }\n return files;\n } catch (error) {\n if (isMissingPathError(error)) return [];\n throw error;\n }\n}\n\n/*** Identify TypeScript source suffixes supported by the first analyzer. */\nfunction isTypeScriptFile(file: string): boolean {\n return ['.ts', '.tsx', '.mts', '.cts'].some((extension) => file.endsWith(extension));\n}\n\n/*** Treat absent optional detector source roots as empty instead of analysis failures. */\nfunction isMissingPathError(error: unknown): boolean {\n return error instanceof Error && 'code' in error && error.code === 'ENOENT';\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { GraphNode } from '@ankhorage/graph';
2
+ import type { DependencyGraphNodeData, DependencyGraphPackage } from '../../../../../types/dependencyGraph.js';
3
+ /*** Create intrinsic module nodes, including ancestor directories, for TypeScript source files. */
4
+ export declare function createTypeScriptModuleNodes(packageContext: DependencyGraphPackage, files: readonly string[]): readonly GraphNode<DependencyGraphNodeData>[];
5
+ //# sourceMappingURL=createTypeScriptModuleNodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTypeScriptModuleNodes.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,yCAAyC,CAAC;AAGjD,mGAAmG;AACnG,wBAAgB,2BAA2B,CACzC,cAAc,EAAE,sBAAsB,EACtC,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,SAAS,SAAS,CAAC,uBAAuB,CAAC,EAAE,CAoB/C"}
@@ -0,0 +1,29 @@
1
+ import { modulePathForFile } from './modulePathForFile.js';
2
+ /*** Create intrinsic module nodes, including ancestor directories, for TypeScript source files. */
3
+ export function createTypeScriptModuleNodes(packageContext, files) {
4
+ const paths = new Set(files.flatMap((file) => ancestorModulePaths(modulePathForFile(packageContext.rootPath, file))));
5
+ return [...paths]
6
+ .sort()
7
+ .filter((modulePath) => modulePath !== '')
8
+ .map((modulePath) => ({
9
+ id: `${packageContext.nodeId}#${modulePath}`,
10
+ data: {
11
+ kind: 'module',
12
+ classification: 'intrinsic',
13
+ focus: true,
14
+ label: modulePath.split('.').at(-1) ?? modulePath,
15
+ projectId: packageContext.projectId,
16
+ ...(packageContext.name === undefined ? {} : { packageName: packageContext.name }),
17
+ path: modulePath,
18
+ parentPath: modulePath.includes('.') ? modulePath.split('.').slice(0, -1).join('.') : '',
19
+ },
20
+ }));
21
+ }
22
+ /*** Expand a module path into the hierarchy required for package-level graph projections. */
23
+ function ancestorModulePaths(modulePath) {
24
+ if (modulePath === '')
25
+ return [''];
26
+ const segments = modulePath.split('.');
27
+ return segments.map((_, index) => segments.slice(0, index + 1).join('.'));
28
+ }
29
+ //# sourceMappingURL=createTypeScriptModuleNodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTypeScriptModuleNodes.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,mGAAmG;AACnG,MAAM,UAAU,2BAA2B,CACzC,cAAsC,EACtC,KAAwB;IAExB,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,iBAAiB,CA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C,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type { GraphNode } from '@ankhorage/graph';\n\nimport type {\n DependencyGraphNodeData,\n DependencyGraphPackage,\n} from '../../../../../types/dependencyGraph.js';\nimport { modulePathForFile } from './modulePathForFile.js';\n\n/*** Create intrinsic module nodes, including ancestor directories, for TypeScript source files. */\nexport function createTypeScriptModuleNodes(\n packageContext: DependencyGraphPackage,\n files: readonly string[],\n): readonly GraphNode<DependencyGraphNodeData>[] {\n const paths = new Set(\n files.flatMap((file) => ancestorModulePaths(modulePathForFile(packageContext.rootPath, file))),\n );\n return [...paths]\n .sort()\n .filter((modulePath) => modulePath !== '')\n .map((modulePath) => ({\n id: `${packageContext.nodeId}#${modulePath}`,\n data: {\n kind: 'module',\n classification: 'intrinsic',\n focus: true,\n label: modulePath.split('.').at(-1) ?? modulePath,\n projectId: packageContext.projectId,\n ...(packageContext.name === undefined ? {} : { packageName: packageContext.name }),\n path: modulePath,\n parentPath: modulePath.includes('.') ? modulePath.split('.').slice(0, -1).join('.') : '',\n },\n }));\n}\n\n/*** Expand a module path into the hierarchy required for package-level graph projections. */\nfunction ancestorModulePaths(modulePath: string): readonly string[] {\n if (modulePath === '') return [''];\n const segments = modulePath.split('.');\n return segments.map((_, index) => segments.slice(0, index + 1).join('.'));\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /*** Extract static import module specifiers from TypeScript source text. */
2
+ export declare function extractTypeScriptImports(filePath: string, content: string): readonly string[];
3
+ //# sourceMappingURL=extractTypeScriptImports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractTypeScriptImports.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAO7F"}
@@ -0,0 +1,9 @@
1
+ import ts from 'typescript';
2
+ /*** Extract static import module specifiers from TypeScript source text. */
3
+ export function extractTypeScriptImports(filePath, content) {
4
+ const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
5
+ return source.statements.flatMap((statement) => ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)
6
+ ? [statement.moduleSpecifier.text]
7
+ : []);
8
+ }
9
+ //# sourceMappingURL=extractTypeScriptImports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractTypeScriptImports.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CAAC,QAAgB,EAAE,OAAe;IACxE,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpF,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAC7C,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC;QAChF,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC;QAClC,CAAC,CAAC,EAAE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import ts from 'typescript';\n\n/*** Extract static import module specifiers from TypeScript source text. */\nexport function extractTypeScriptImports(filePath: string, content: string): readonly string[] {\n const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n return source.statements.flatMap((statement) =>\n ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)\n ? [statement.moduleSpecifier.text]\n : [],\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /*** Return the package-level dotted path owning one source file. */
2
+ export declare function modulePathForFile(rootPath: string, file: string): string;
3
+ //# sourceMappingURL=modulePathForFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modulePathForFile.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.ts"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGxE"}
@@ -0,0 +1,8 @@
1
+ import path from 'node:path';
2
+ import { toPortablePath } from '@ankhorage/utility/node/path';
3
+ /*** Return the package-level dotted path owning one source file. */
4
+ export function modulePathForFile(rootPath, file) {
5
+ const relativeDirectory = toPortablePath(path.relative(rootPath, path.dirname(file)));
6
+ return relativeDirectory === '.' ? '' : relativeDirectory.split('/').join('.');
7
+ }
8
+ //# sourceMappingURL=modulePathForFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modulePathForFile.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,oEAAoE;AACpE,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,IAAY;IAC9D,MAAM,iBAAiB,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtF,OAAO,iBAAiB,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjF,CAAC","sourcesContent":["import path from 'node:path';\n\nimport { toPortablePath } from '@ankhorage/utility/node/path';\n\n/*** Return the package-level dotted path owning one source file. */\nexport function modulePathForFile(rootPath: string, file: string): string {\n const relativeDirectory = toPortablePath(path.relative(rootPath, path.dirname(file)));\n return relativeDirectory === '.' ? '' : relativeDirectory.split('/').join('.');\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { DependencyDeclaration, DependencyGraphPackage, DependencyReferenceClassification } from '../../../../../types/dependencyGraph.js';
2
+ export interface ResolvedTypeScriptImport {
3
+ readonly targetNodeId: string;
4
+ readonly classification: DependencyReferenceClassification;
5
+ readonly targetPath?: string;
6
+ readonly packageName?: string;
7
+ readonly declarations: readonly DependencyDeclaration[];
8
+ }
9
+ /*** Resolve one TypeScript import to an intrinsic module, focus package, vendor or unknown node. */
10
+ export declare function resolveTypeScriptImport(packageContext: DependencyGraphPackage, sourceFile: string, specifier: string, sourceFiles: ReadonlySet<string>, focusPackages: ReadonlyMap<string, string>): ResolvedTypeScriptImport;
11
+ //# sourceMappingURL=resolveTypeScriptImport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTypeScriptImport.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,yCAAyC,CAAC;AAEjD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,iCAAiC,CAAC;IAC3D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACzD;AAED,oGAAoG;AACpG,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,sBAAsB,EACtC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,wBAAwB,CAgC1B"}
@@ -0,0 +1,76 @@
1
+ import path from 'node:path';
2
+ import { toPortablePath } from '@ankhorage/utility/node/path';
3
+ /*** Resolve one TypeScript import to an intrinsic module, focus package, vendor or unknown node. */
4
+ export function resolveTypeScriptImport(packageContext, sourceFile, specifier, sourceFiles, focusPackages) {
5
+ if (specifier.startsWith('./') || specifier.startsWith('../')) {
6
+ return resolveIntrinsic(packageContext, path.resolve(path.dirname(sourceFile), specifier), sourceFiles);
7
+ }
8
+ if (specifier.startsWith('@/')) {
9
+ return resolveIntrinsic(packageContext, path.resolve(packageContext.rootPath, 'src', specifier.slice(2)), sourceFiles);
10
+ }
11
+ const packageName = barePackageName(specifier);
12
+ if (packageName !== undefined) {
13
+ const focusNodeId = focusPackages.get(packageName);
14
+ return {
15
+ targetNodeId: focusNodeId ?? `vendor:${packageName}`,
16
+ classification: focusNodeId === undefined ? 'vendor' : 'focus',
17
+ packageName,
18
+ declarations: declarationsFor(packageContext.declarations, packageName),
19
+ };
20
+ }
21
+ return {
22
+ targetNodeId: `unknown:${specifier}`,
23
+ classification: 'unknown',
24
+ declarations: [],
25
+ };
26
+ }
27
+ /*** Resolve a source-like path to the containing intrinsic package module. */
28
+ function resolveIntrinsic(packageContext, unresolvedPath, sourceFiles) {
29
+ const targetFile = sourceCandidates(unresolvedPath).find((candidate) => sourceFiles.has(candidate));
30
+ const target = targetFile ?? unresolvedPath;
31
+ const relative = toPortablePath(path.relative(packageContext.rootPath, target));
32
+ if (relative === '..' || relative.startsWith('../')) {
33
+ return {
34
+ targetNodeId: `unknown:${relative}`,
35
+ classification: 'unknown',
36
+ declarations: [],
37
+ };
38
+ }
39
+ const modulePath = toPortablePath(path.dirname(relative));
40
+ const normalizedPath = modulePath === '.' ? '' : modulePath.split('/').join('.');
41
+ return {
42
+ targetNodeId: normalizedPath === '' ? packageContext.nodeId : `${packageContext.nodeId}#${normalizedPath}`,
43
+ classification: 'intrinsic',
44
+ targetPath: normalizedPath,
45
+ declarations: [],
46
+ };
47
+ }
48
+ /*** Read dependency declarations without dynamic object-key access. */
49
+ function declarationsFor(declarations, packageName) {
50
+ const entry = Object.entries(declarations).find(([name]) => name === packageName);
51
+ return entry === undefined ? [] : entry[1];
52
+ }
53
+ /*** Generate deterministic TypeScript module resolution candidates without executing project config. */
54
+ function sourceCandidates(base) {
55
+ const extensions = ['.ts', '.tsx', '.mts', '.cts'];
56
+ return [
57
+ base,
58
+ ...extensions.map((extension) => `${base}${extension}`),
59
+ ...extensions.map((extension) => path.join(base, `index${extension}`)),
60
+ ];
61
+ }
62
+ /*** Extract the npm package identity from a bare module specifier. */
63
+ function barePackageName(specifier) {
64
+ if (specifier === '' ||
65
+ specifier.startsWith('#') ||
66
+ specifier.startsWith('/') ||
67
+ specifier.startsWith('~')) {
68
+ return undefined;
69
+ }
70
+ const segments = specifier.split('/');
71
+ if (specifier.startsWith('@')) {
72
+ return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : undefined;
73
+ }
74
+ return segments[0];
75
+ }
76
+ //# sourceMappingURL=resolveTypeScriptImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTypeScriptImport.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAgB9D,oGAAoG;AACpG,MAAM,UAAU,uBAAuB,CACrC,cAAsC,EACtC,UAAkB,EAClB,SAAiB,EACjB,WAAgC,EAChC,aAA0C;IAE1C,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;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IAAI;QACJ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC;QACvD,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,SAAS,EAAE,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,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,EACzB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import path from 'node:path';\n\nimport { toPortablePath } from '@ankhorage/utility/node/path';\n\nimport type {\n DependencyDeclaration,\n DependencyGraphPackage,\n DependencyReferenceClassification,\n} from '../../../../../types/dependencyGraph.js';\n\nexport interface ResolvedTypeScriptImport {\n readonly targetNodeId: string;\n readonly classification: DependencyReferenceClassification;\n readonly targetPath?: string;\n readonly packageName?: string;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\n/*** Resolve one TypeScript import to an intrinsic module, focus package, vendor or unknown node. */\nexport function resolveTypeScriptImport(\n packageContext: DependencyGraphPackage,\n sourceFile: string,\n specifier: string,\n sourceFiles: ReadonlySet<string>,\n focusPackages: ReadonlyMap<string, string>,\n): ResolvedTypeScriptImport {\n if (specifier.startsWith('./') || specifier.startsWith('../')) {\n return resolveIntrinsic(\n packageContext,\n path.resolve(path.dirname(sourceFile), specifier),\n sourceFiles,\n );\n }\n if (specifier.startsWith('@/')) {\n return resolveIntrinsic(\n packageContext,\n path.resolve(packageContext.rootPath, 'src', specifier.slice(2)),\n sourceFiles,\n );\n }\n\n const packageName = barePackageName(specifier);\n if (packageName !== undefined) {\n const focusNodeId = focusPackages.get(packageName);\n return {\n targetNodeId: focusNodeId ?? `vendor:${packageName}`,\n classification: focusNodeId === undefined ? 'vendor' : 'focus',\n packageName,\n declarations: declarationsFor(packageContext.declarations, packageName),\n };\n }\n\n return {\n targetNodeId: `unknown:${specifier}`,\n classification: 'unknown',\n declarations: [],\n };\n}\n\n/*** Resolve a source-like path to the containing intrinsic package module. */\nfunction resolveIntrinsic(\n packageContext: DependencyGraphPackage,\n unresolvedPath: string,\n sourceFiles: ReadonlySet<string>,\n): ResolvedTypeScriptImport {\n const targetFile = sourceCandidates(unresolvedPath).find((candidate) =>\n sourceFiles.has(candidate),\n );\n const target = targetFile ?? unresolvedPath;\n const relative = toPortablePath(path.relative(packageContext.rootPath, target));\n if (relative === '..' || relative.startsWith('../')) {\n return {\n targetNodeId: `unknown:${relative}`,\n classification: 'unknown',\n declarations: [],\n };\n }\n\n const modulePath = toPortablePath(path.dirname(relative));\n const normalizedPath = modulePath === '.' ? '' : modulePath.split('/').join('.');\n return {\n targetNodeId:\n normalizedPath === '' ? packageContext.nodeId : `${packageContext.nodeId}#${normalizedPath}`,\n classification: 'intrinsic',\n targetPath: normalizedPath,\n declarations: [],\n };\n}\n\n/*** Read dependency declarations without dynamic object-key access. */\nfunction declarationsFor(\n declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>,\n packageName: string,\n): readonly DependencyDeclaration[] {\n const entry = Object.entries(declarations).find(([name]) => name === packageName);\n return entry === undefined ? [] : entry[1];\n}\n\n/*** Generate deterministic TypeScript module resolution candidates without executing project config. */\nfunction sourceCandidates(base: string): readonly string[] {\n const extensions = ['.ts', '.tsx', '.mts', '.cts'];\n return [\n base,\n ...extensions.map((extension) => `${base}${extension}`),\n ...extensions.map((extension) => path.join(base, `index${extension}`)),\n ];\n}\n\n/*** Extract the 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 }\n\n const segments = specifier.split('/');\n if (specifier.startsWith('@')) {\n return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : undefined;\n }\n return segments[0];\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { DependencyGraphAnalyzer } from '../../../../../types/dependencyGraph.js';
2
+ /*** TypeScript analyzer adapter selected from project-detector language evidence. */
3
+ export declare const typescriptDependencyGraphAnalyzer: DependencyGraphAnalyzer;
4
+ //# sourceMappingURL=typescriptDependencyGraphAnalyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescriptDependencyGraphAnalyzer.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAGvF,qFAAqF;AACrF,eAAO,MAAM,iCAAiC,EAAE,uBAI/C,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { analyzeTypeScriptProjectAsync } from './analyzeTypeScriptProjectAsync.js';
2
+ /*** TypeScript analyzer adapter selected from project-detector language evidence. */
3
+ export const typescriptDependencyGraphAnalyzer = {
4
+ id: 'typescript',
5
+ supports: (detection) => detection.languages.some(({ id }) => id === 'typescript'),
6
+ analyzeAsync: analyzeTypeScriptProjectAsync,
7
+ };
8
+ //# sourceMappingURL=typescriptDependencyGraphAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescriptDependencyGraphAnalyzer.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,qFAAqF;AACrF,MAAM,CAAC,MAAM,iCAAiC,GAA4B;IACxE,EAAE,EAAE,YAAY;IAChB,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,YAAY,CAAC;IAClF,YAAY,EAAE,6BAA6B;CAC5C,CAAC","sourcesContent":["import type { DependencyGraphAnalyzer } from '../../../../../types/dependencyGraph.js';\nimport { analyzeTypeScriptProjectAsync } from './analyzeTypeScriptProjectAsync.js';\n\n/*** TypeScript analyzer adapter selected from project-detector language evidence. */\nexport const typescriptDependencyGraphAnalyzer: DependencyGraphAnalyzer = {\n id: 'typescript',\n supports: (detection) => detection.languages.some(({ id }) => id === 'typescript'),\n analyzeAsync: analyzeTypeScriptProjectAsync,\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CreateDependencyGraphInput, DependencyGraph } from '../../../types/dependencyGraph.js';
2
+ /*** Inspect projects, run supported analyzers and combine their evidence into one canonical graph. */
3
+ export declare function createDependencyGraphAsync(input: CreateDependencyGraphInput): Promise<DependencyGraph>;
4
+ //# sourceMappingURL=createDependencyGraphAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDependencyGraphAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/createDependencyGraphAsync.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EAKhB,MAAM,mCAAmC,CAAC;AAK3C,sGAAsG;AACtG,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,eAAe,CAAC,CAsB1B"}
@@ -0,0 +1,105 @@
1
+ import path from 'node:path';
2
+ import { createGraph } from '@ankhorage/graph';
3
+ import { inspectProjectAsync } from '@ankhorage/project-detector/node';
4
+ import { typescriptDependencyGraphAnalyzer } from '../adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';
5
+ import { createFocusPackageNode } from '../domain/createFocusPackageNode.js';
6
+ import { readDependencyDeclarationsAsync } from '../domain/readDependencyDeclarationsAsync.js';
7
+ /*** Inspect projects, run supported analyzers and combine their evidence into one canonical graph. */
8
+ export async function createDependencyGraphAsync(input) {
9
+ assertProjectInputs(input.projects);
10
+ const analyzers = input.analyzers ?? [typescriptDependencyGraphAnalyzer];
11
+ const inspected = await Promise.all(input.projects.map((project) => inspectProjectInputAsync(project, input.signal)));
12
+ const packages = inspected.flatMap(({ packages }) => packages);
13
+ const focusPackages = createFocusPackageMap(packages);
14
+ const fragments = await analyzePackagesAsync(inspected, analyzers, focusPackages, input.signal);
15
+ const nodes = new Map(packages.map((packageContext) => {
16
+ const node = createFocusPackageNode(packageContext);
17
+ return [node.id, node];
18
+ }));
19
+ for (const node of fragments.flatMap(({ nodes: fragmentNodes }) => fragmentNodes)) {
20
+ if (!nodes.has(node.id))
21
+ nodes.set(node.id, node);
22
+ }
23
+ const edges = fragments.flatMap(({ edges: fragmentEdges }) => fragmentEdges);
24
+ return createGraph({ nodes: [...nodes.values()], edges });
25
+ }
26
+ /*** Inspect one input and normalize its package/workspace contexts. */
27
+ async function inspectProjectInputAsync(project, signal) {
28
+ const inspection = await inspectProjectAsync(project.rootPath, {
29
+ ...(signal === undefined ? {} : { signal }),
30
+ });
31
+ if (!inspection.complete) {
32
+ throw new Error(`Dependency graph inspection is incomplete for "${project.id}": ${inspection.diagnostics
33
+ .map(({ message }) => message)
34
+ .join('; ')}`);
35
+ }
36
+ const detectedPackages = inspection.packages.length > 0
37
+ ? inspection.packages
38
+ : [{ rootPath: '.', detection: inspection.detection, manifestPath: '' }];
39
+ const packages = await Promise.all(detectedPackages.map(async (detected) => {
40
+ const relativeRoot = detected.rootPath;
41
+ const id = `${project.id}:${relativeRoot}`;
42
+ const manifestPath = detected.manifestPath === ''
43
+ ? undefined
44
+ : path.join(inspection.rootPath, detected.manifestPath);
45
+ return {
46
+ id,
47
+ nodeId: `package:${id}`,
48
+ projectId: project.id,
49
+ rootPath: path.resolve(inspection.rootPath, relativeRoot),
50
+ relativeRoot,
51
+ ...(detected.name === undefined ? {} : { name: detected.name }),
52
+ detection: detected.detection,
53
+ declarations: await readDependencyDeclarationsAsync(manifestPath),
54
+ };
55
+ }));
56
+ return { inspection, packages };
57
+ }
58
+ /*** Analyze each package with the first compatible analyzer and retain mixed-language packages safely. */
59
+ async function analyzePackagesAsync(inspected, analyzers, focusPackages, signal) {
60
+ const tasks = inspected.flatMap(({ inspection, packages }) => packages.flatMap((packageContext) => {
61
+ const analyzer = analyzers.find(({ supports }) => supports(packageContext.detection));
62
+ if (analyzer === undefined)
63
+ return [];
64
+ const excludedRoots = packages
65
+ .filter((candidate) => candidate.id !== packageContext.id &&
66
+ candidate.rootPath.startsWith(`${packageContext.rootPath}${path.sep}`))
67
+ .map(({ rootPath }) => rootPath);
68
+ return [
69
+ analyzer.analyzeAsync({
70
+ package: packageContext,
71
+ inspection,
72
+ focusPackages,
73
+ excludedRoots,
74
+ ...(signal === undefined ? {} : { signal }),
75
+ }),
76
+ ];
77
+ }));
78
+ if (tasks.length === 0) {
79
+ throw new Error('No dependency graph analyzer supports the supplied projects.');
80
+ }
81
+ return Promise.all(tasks);
82
+ }
83
+ /*** Build a unique package-name map for focus routing across repositories and workspaces. */
84
+ function createFocusPackageMap(packages) {
85
+ const named = packages.filter((packageContext) => packageContext.name !== undefined);
86
+ const duplicates = named.filter((item, index) => named.findIndex(({ name }) => name === item.name) !== index);
87
+ if (duplicates.length > 0) {
88
+ throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);
89
+ }
90
+ return new Map(named.map(({ name, nodeId }) => [name, nodeId]));
91
+ }
92
+ /*** Reject ambiguous project IDs before filesystem inspection. */
93
+ function assertProjectInputs(projects) {
94
+ if (projects.length === 0) {
95
+ throw new Error('At least one dependency graph project is required.');
96
+ }
97
+ const ids = projects.map(({ id }) => id);
98
+ if (ids.some((id) => id.trim() === '')) {
99
+ throw new Error('Dependency graph project IDs must be non-empty.');
100
+ }
101
+ if (new Set(ids).size !== ids.length) {
102
+ throw new Error('Dependency graph project IDs must be unique.');
103
+ }
104
+ }
105
+ //# sourceMappingURL=createDependencyGraphAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDependencyGraphAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/application/createDependencyGraphAsync.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAWvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,sEAAsE,CAAC;AACzH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,8CAA8C,CAAC;AAE/F,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAiC;IAEjC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,CAAC,iCAAiC,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CACjF,CAAC;IACF,MAAM,QAAQ,GAAG,SAAS,CAAC,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,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;AACH,CAAC","sourcesContent":["import path from 'node:path';\n\nimport { createGraph } from '@ankhorage/graph';\nimport { inspectProjectAsync } from '@ankhorage/project-detector/node';\nimport type { InspectedPackage, ProjectInspection } from '@ankhorage/project-detector/types';\n\nimport type {\n CreateDependencyGraphInput,\n DependencyGraph,\n DependencyGraphAnalyzer,\n DependencyGraphFragment,\n DependencyGraphPackage,\n DependencyGraphProjectInput,\n} from '../../../types/dependencyGraph.js';\nimport { typescriptDependencyGraphAnalyzer } from '../adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js';\nimport { createFocusPackageNode } from '../domain/createFocusPackageNode.js';\nimport { readDependencyDeclarationsAsync } from '../domain/readDependencyDeclarationsAsync.js';\n\n/*** Inspect projects, run supported analyzers and combine their evidence into one canonical graph. */\nexport async function createDependencyGraphAsync(\n input: CreateDependencyGraphInput,\n): Promise<DependencyGraph> {\n assertProjectInputs(input.projects);\n const analyzers = input.analyzers ?? [typescriptDependencyGraphAnalyzer];\n const inspected = await Promise.all(\n input.projects.map((project) => inspectProjectInputAsync(project, input.signal)),\n );\n const packages = inspected.flatMap(({ packages }) => packages);\n const focusPackages = createFocusPackageMap(packages);\n const fragments = await analyzePackagesAsync(inspected, analyzers, focusPackages, input.signal);\n const nodes = new Map(\n packages.map((packageContext) => {\n const node = createFocusPackageNode(packageContext);\n return [node.id, node] as const;\n }),\n );\n\n for (const node of fragments.flatMap(({ nodes: fragmentNodes }) => fragmentNodes)) {\n if (!nodes.has(node.id)) nodes.set(node.id, node);\n }\n\n const edges = fragments.flatMap(({ edges: fragmentEdges }) => fragmentEdges);\n return createGraph({ nodes: [...nodes.values()], edges });\n}\n\ninterface InspectedInput {\n readonly inspection: ProjectInspection;\n readonly packages: readonly DependencyGraphPackage[];\n}\n\n/*** Inspect one input and normalize its package/workspace contexts. */\nasync function inspectProjectInputAsync(\n project: DependencyGraphProjectInput,\n signal: AbortSignal | undefined,\n): Promise<InspectedInput> {\n const inspection = await inspectProjectAsync(project.rootPath, {\n ...(signal === undefined ? {} : { signal }),\n });\n if (!inspection.complete) {\n throw new Error(\n `Dependency graph inspection is incomplete for \"${project.id}\": ${inspection.diagnostics\n .map(({ message }) => message)\n .join('; ')}`,\n );\n }\n\n const detectedPackages: readonly InspectedPackage[] =\n inspection.packages.length > 0\n ? inspection.packages\n : [{ rootPath: '.', detection: inspection.detection, manifestPath: '' }];\n\n const packages = await Promise.all(\n detectedPackages.map(async (detected) => {\n const relativeRoot = detected.rootPath;\n const id = `${project.id}:${relativeRoot}`;\n const manifestPath =\n detected.manifestPath === ''\n ? undefined\n : path.join(inspection.rootPath, detected.manifestPath);\n\n return {\n id,\n nodeId: `package:${id}`,\n projectId: project.id,\n rootPath: path.resolve(inspection.rootPath, relativeRoot),\n relativeRoot,\n ...(detected.name === undefined ? {} : { name: detected.name }),\n detection: detected.detection,\n declarations: await readDependencyDeclarationsAsync(manifestPath),\n } satisfies DependencyGraphPackage;\n }),\n );\n return { inspection, packages };\n}\n\n/*** Analyze each package with the first compatible analyzer and retain mixed-language packages safely. */\nasync function analyzePackagesAsync(\n inspected: readonly InspectedInput[],\n analyzers: readonly DependencyGraphAnalyzer[],\n focusPackages: ReadonlyMap<string, string>,\n signal: AbortSignal | undefined,\n): Promise<readonly DependencyGraphFragment[]> {\n const tasks = inspected.flatMap(({ inspection, packages }) =>\n packages.flatMap((packageContext) => {\n const analyzer = analyzers.find(({ supports }) => supports(packageContext.detection));\n if (analyzer === undefined) return [];\n\n const excludedRoots = packages\n .filter(\n (candidate) =>\n candidate.id !== packageContext.id &&\n candidate.rootPath.startsWith(`${packageContext.rootPath}${path.sep}`),\n )\n .map(({ rootPath }) => rootPath);\n\n return [\n analyzer.analyzeAsync({\n package: packageContext,\n inspection,\n focusPackages,\n excludedRoots,\n ...(signal === undefined ? {} : { signal }),\n }),\n ];\n }),\n );\n\n if (tasks.length === 0) {\n throw new Error('No dependency graph analyzer supports the supplied projects.');\n }\n return Promise.all(tasks);\n}\n\n/*** Build a unique package-name map for focus routing across repositories and workspaces. */\nfunction createFocusPackageMap(\n packages: readonly DependencyGraphPackage[],\n): ReadonlyMap<string, string> {\n const named = packages.filter(\n (packageContext): packageContext is DependencyGraphPackage & { readonly name: string } =>\n packageContext.name !== undefined,\n );\n const duplicates = named.filter(\n (item, index) => named.findIndex(({ name }) => name === item.name) !== index,\n );\n if (duplicates.length > 0) {\n throw new Error(`Duplicate focus package name: ${duplicates[0]?.name ?? 'unknown'}.`);\n }\n return new Map(named.map(({ name, nodeId }) => [name, nodeId]));\n}\n\n/*** Reject ambiguous project IDs before filesystem inspection. */\nfunction assertProjectInputs(projects: readonly DependencyGraphProjectInput[]): void {\n if (projects.length === 0) {\n throw new Error('At least one dependency graph project is required.');\n }\n\n const ids = projects.map(({ id }) => id);\n if (ids.some((id) => id.trim() === '')) {\n throw new Error('Dependency graph project IDs must be non-empty.');\n }\n if (new Set(ids).size !== ids.length) {\n throw new Error('Dependency graph project IDs must be unique.');\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { GraphNode } from '@ankhorage/graph';
2
+ import type { DependencyGraphNodeData, DependencyGraphPackage } from '../../../types/dependencyGraph.js';
3
+ /*** Create the focus package node representing one inspected package root. */
4
+ export declare function createFocusPackageNode(packageContext: DependencyGraphPackage): GraphNode<DependencyGraphNodeData>;
5
+ //# sourceMappingURL=createFocusPackageNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFocusPackageNode.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/createFocusPackageNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAE3C,8EAA8E;AAC9E,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,sBAAsB,GACrC,SAAS,CAAC,uBAAuB,CAAC,CAapC"}
@@ -0,0 +1,16 @@
1
+ /*** Create the focus package node representing one inspected package root. */
2
+ export function createFocusPackageNode(packageContext) {
3
+ return {
4
+ id: packageContext.nodeId,
5
+ data: {
6
+ kind: 'package',
7
+ classification: 'intrinsic',
8
+ focus: true,
9
+ label: packageContext.name ?? packageContext.id,
10
+ projectId: packageContext.projectId,
11
+ ...(packageContext.name === undefined ? {} : { packageName: packageContext.name }),
12
+ path: packageContext.relativeRoot,
13
+ },
14
+ };
15
+ }
16
+ //# sourceMappingURL=createFocusPackageNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFocusPackageNode.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/createFocusPackageNode.ts"],"names":[],"mappings":"AAOA,8EAA8E;AAC9E,MAAM,UAAU,sBAAsB,CACpC,cAAsC;IAEtC,OAAO;QACL,EAAE,EAAE,cAAc,CAAC,MAAM;QACzB,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,cAAc,EAAE,WAAW;YAC3B,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,cAAc,CAAC,IAAI,IAAI,cAAc,CAAC,EAAE;YAC/C,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,GAAG,CAAC,cAAc,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC;YAClF,IAAI,EAAE,cAAc,CAAC,YAAY;SAClC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { GraphNode } from '@ankhorage/graph';\n\nimport type {\n DependencyGraphNodeData,\n DependencyGraphPackage,\n} from '../../../types/dependencyGraph.js';\n\n/*** Create the focus package node representing one inspected package root. */\nexport function createFocusPackageNode(\n packageContext: DependencyGraphPackage,\n): GraphNode<DependencyGraphNodeData> {\n return {\n id: packageContext.nodeId,\n data: {\n kind: 'package',\n classification: 'intrinsic',\n focus: true,\n label: packageContext.name ?? packageContext.id,\n projectId: packageContext.projectId,\n ...(packageContext.name === undefined ? {} : { packageName: packageContext.name }),\n path: packageContext.relativeRoot,\n },\n };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { DependencyDeclaration } from '../../../types/dependencyGraph.js';
2
+ /*** Read dependency declarations from one already-inspected package manifest. */
3
+ export declare function readDependencyDeclarationsAsync(manifestPath: string | undefined): Promise<Readonly<Record<string, readonly DependencyDeclaration[]>>>;
4
+ //# sourceMappingURL=readDependencyDeclarationsAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readDependencyDeclarationsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/readDependencyDeclarationsAsync.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EAEtB,MAAM,mCAAmC,CAAC;AAE3C,iFAAiF;AACjF,wBAAsB,+BAA+B,CACnD,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC,CAAC,CAAC,CAiBrE"}
@@ -0,0 +1,27 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { isRecord } from '@ankhorage/utility/object';
3
+ /*** Read dependency declarations from one already-inspected package manifest. */
4
+ export async function readDependencyDeclarationsAsync(manifestPath) {
5
+ if (manifestPath === undefined)
6
+ return {};
7
+ const value = JSON.parse(await readFile(manifestPath, 'utf8'));
8
+ if (!isRecord(value))
9
+ return {};
10
+ return Object.fromEntries([
11
+ ...declarationsFor(value.dependencies, 'dependency'),
12
+ ...declarationsFor(value.devDependencies, 'devDependency'),
13
+ ...declarationsFor(value.optionalDependencies, 'optionalDependency'),
14
+ ...declarationsFor(value.peerDependencies, 'peerDependency'),
15
+ ].reduce((byName, [name, declaration]) => {
16
+ const current = byName.get(name) ?? [];
17
+ byName.set(name, [...current, declaration]);
18
+ return byName;
19
+ }, new Map()));
20
+ }
21
+ /*** Normalize one package.json dependency section into named declarations. */
22
+ function declarationsFor(value, kind) {
23
+ if (!isRecord(value))
24
+ return [];
25
+ return Object.entries(value).flatMap(([name, range]) => typeof range === 'string' ? [[name, { kind, range }]] : []);
26
+ }
27
+ //# sourceMappingURL=readDependencyDeclarationsAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readDependencyDeclarationsAsync.js","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/domain/readDependencyDeclarationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAOrD,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,YAAgC;IAEhC,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEhC,OAAO,MAAM,CAAC,WAAW,CACvB;QACE,GAAG,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,CAAC;QACpD,GAAG,eAAe,CAAC,KAAK,CAAC,eAAe,EAAE,eAAe,CAAC;QAC1D,GAAG,eAAe,CAAC,KAAK,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;QACpE,GAAG,eAAe,CAAC,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;KAC7D,CAAC,MAAM,CAAuC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE;QAC7E,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CACd,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,SAAS,eAAe,CACtB,KAAc,EACd,IAA+B;IAE/B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CACrD,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CACpE,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\n\nimport { isRecord } from '@ankhorage/utility/object';\n\nimport type {\n DependencyDeclaration,\n DependencyDeclarationKind,\n} from '../../../types/dependencyGraph.js';\n\n/*** Read dependency declarations from one already-inspected package manifest. */\nexport async function readDependencyDeclarationsAsync(\n manifestPath: string | undefined,\n): Promise<Readonly<Record<string, readonly DependencyDeclaration[]>>> {\n if (manifestPath === undefined) return {};\n const value: unknown = JSON.parse(await readFile(manifestPath, 'utf8'));\n if (!isRecord(value)) return {};\n\n return Object.fromEntries(\n [\n ...declarationsFor(value.dependencies, 'dependency'),\n ...declarationsFor(value.devDependencies, 'devDependency'),\n ...declarationsFor(value.optionalDependencies, 'optionalDependency'),\n ...declarationsFor(value.peerDependencies, 'peerDependency'),\n ].reduce<Map<string, DependencyDeclaration[]>>((byName, [name, declaration]) => {\n const current = byName.get(name) ?? [];\n byName.set(name, [...current, declaration]);\n return byName;\n }, new Map()),\n );\n}\n\n/*** Normalize one package.json dependency section into named declarations. */\nfunction declarationsFor(\n value: unknown,\n kind: DependencyDeclarationKind,\n): readonly (readonly [string, DependencyDeclaration])[] {\n if (!isRecord(value)) return [];\n return Object.entries(value).flatMap(([name, range]) =>\n typeof range === 'string' ? [[name, { kind, range }] as const] : [],\n );\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';
2
+ import type { ProjectDetection, ProjectInspection } from '@ankhorage/project-detector/types';
3
+ export type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';
4
+ export type DependencyReferenceClassification = DependencyNodeClassification | 'focus';
5
+ export type DependencyNodeKind = 'module' | 'package';
6
+ export type DependencyDeclarationKind = 'dependency' | 'devDependency' | 'optionalDependency' | 'peerDependency';
7
+ export interface DependencyDeclaration {
8
+ readonly kind: DependencyDeclarationKind;
9
+ readonly range: string;
10
+ }
11
+ export interface DependencyImportEvidence {
12
+ readonly sourceFile: string;
13
+ readonly specifier: string;
14
+ readonly classification: DependencyReferenceClassification;
15
+ readonly declarations: readonly DependencyDeclaration[];
16
+ }
17
+ export interface DependencyGraphNodeData {
18
+ readonly kind: DependencyNodeKind;
19
+ readonly classification: DependencyNodeClassification;
20
+ readonly focus: boolean;
21
+ readonly label: string;
22
+ readonly projectId?: string;
23
+ readonly packageName?: string;
24
+ readonly path?: string;
25
+ readonly parentPath?: string;
26
+ }
27
+ export interface DependencyGraphEdgeData {
28
+ readonly kind: 'import';
29
+ readonly analyzerId: string;
30
+ readonly weight: number;
31
+ readonly evidence: readonly DependencyImportEvidence[];
32
+ }
33
+ export type DependencyGraph = Graph<DependencyGraphNodeData, DependencyGraphEdgeData>;
34
+ export interface DependencyGraphProjectInput {
35
+ readonly id: string;
36
+ readonly rootPath: string;
37
+ }
38
+ export interface DependencyGraphPackage {
39
+ readonly id: string;
40
+ readonly nodeId: string;
41
+ readonly projectId: string;
42
+ readonly rootPath: string;
43
+ readonly relativeRoot: string;
44
+ readonly name?: string;
45
+ readonly detection: ProjectDetection;
46
+ readonly declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>;
47
+ }
48
+ export interface DependencyGraphFragment {
49
+ readonly nodes: readonly GraphNode<DependencyGraphNodeData>[];
50
+ readonly edges: readonly GraphEdge<DependencyGraphEdgeData>[];
51
+ }
52
+ export interface DependencyGraphAnalyzerContext {
53
+ readonly package: DependencyGraphPackage;
54
+ readonly inspection: ProjectInspection;
55
+ readonly focusPackages: ReadonlyMap<string, string>;
56
+ readonly excludedRoots: readonly string[];
57
+ readonly signal?: AbortSignal;
58
+ }
59
+ export interface DependencyGraphAnalyzer {
60
+ readonly id: string;
61
+ readonly supports: (detection: ProjectDetection) => boolean;
62
+ readonly analyzeAsync: (context: DependencyGraphAnalyzerContext) => Promise<DependencyGraphFragment>;
63
+ }
64
+ export interface CreateDependencyGraphInput {
65
+ readonly projects: readonly DependencyGraphProjectInput[];
66
+ readonly analyzers?: readonly DependencyGraphAnalyzer[];
67
+ readonly signal?: AbortSignal;
68
+ }
69
+ //# sourceMappingURL=dependencyGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE7F,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC9E,MAAM,MAAM,iCAAiC,GAAG,4BAA4B,GAAG,OAAO,CAAC;AACvF,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B,KACpC,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dependencyGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../../src/types/dependencyGraph.ts"],"names":[],"mappings":"","sourcesContent":["import type { Graph, GraphEdge, GraphNode } from '@ankhorage/graph';\nimport type { ProjectDetection, ProjectInspection } from '@ankhorage/project-detector/types';\n\nexport type DependencyNodeClassification = 'intrinsic' | 'unknown' | 'vendor';\nexport type DependencyReferenceClassification = DependencyNodeClassification | 'focus';\nexport type DependencyNodeKind = 'module' | 'package';\nexport type DependencyDeclarationKind =\n 'dependency' | 'devDependency' | 'optionalDependency' | 'peerDependency';\n\nexport interface DependencyDeclaration {\n readonly kind: DependencyDeclarationKind;\n readonly range: string;\n}\n\nexport interface DependencyImportEvidence {\n readonly sourceFile: string;\n readonly specifier: string;\n readonly classification: DependencyReferenceClassification;\n readonly declarations: readonly DependencyDeclaration[];\n}\n\nexport interface DependencyGraphNodeData {\n readonly kind: DependencyNodeKind;\n readonly classification: DependencyNodeClassification;\n readonly focus: boolean;\n readonly label: string;\n readonly projectId?: string;\n readonly packageName?: string;\n readonly path?: string;\n readonly parentPath?: string;\n}\n\nexport interface DependencyGraphEdgeData {\n readonly kind: 'import';\n readonly analyzerId: string;\n readonly weight: number;\n readonly evidence: readonly DependencyImportEvidence[];\n}\n\nexport type DependencyGraph = Graph<DependencyGraphNodeData, DependencyGraphEdgeData>;\n\nexport interface DependencyGraphProjectInput {\n readonly id: string;\n readonly rootPath: string;\n}\n\nexport interface DependencyGraphPackage {\n readonly id: string;\n readonly nodeId: string;\n readonly projectId: string;\n readonly rootPath: string;\n readonly relativeRoot: string;\n readonly name?: string;\n readonly detection: ProjectDetection;\n readonly declarations: Readonly<Record<string, readonly DependencyDeclaration[]>>;\n}\n\nexport interface DependencyGraphFragment {\n readonly nodes: readonly GraphNode<DependencyGraphNodeData>[];\n readonly edges: readonly GraphEdge<DependencyGraphEdgeData>[];\n}\n\nexport interface DependencyGraphAnalyzerContext {\n readonly package: DependencyGraphPackage;\n readonly inspection: ProjectInspection;\n readonly focusPackages: ReadonlyMap<string, string>;\n readonly excludedRoots: readonly string[];\n readonly signal?: AbortSignal;\n}\n\nexport interface DependencyGraphAnalyzer {\n readonly id: string;\n readonly supports: (detection: ProjectDetection) => boolean;\n readonly analyzeAsync: (\n context: DependencyGraphAnalyzerContext,\n ) => Promise<DependencyGraphFragment>;\n}\n\nexport interface CreateDependencyGraphInput {\n readonly projects: readonly DependencyGraphProjectInput[];\n readonly analyzers?: readonly DependencyGraphAnalyzer[];\n readonly signal?: AbortSignal;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { createDependencyGraphAsync } from '@ankhorage/dependency-graph';
2
+
3
+ /***
4
+ * Analyze the current project and print its canonical dependency graph.
5
+ *
6
+ * @usage
7
+ * @readme
8
+ */
9
+ const graph = await createDependencyGraphAsync({
10
+ projects: [{ id: 'current', rootPath: process.cwd() }],
11
+ });
12
+
13
+ console.log(graph);
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@ankhorage/dependency-graph",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Project-aware dependency analysis that produces canonical Ankhorage graphs.",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ankhorage/dependency-graph.git"
10
+ },
11
+ "homepage": "https://github.com/ankhorage/dependency-graph#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/ankhorage/dependency-graph/issues"
14
+ },
15
+ "keywords": [
16
+ "ankhorage",
17
+ "dependency-analysis",
18
+ "dependency-graph",
19
+ "graph",
20
+ "typescript"
21
+ ],
22
+ "sideEffects": false,
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE",
27
+ "CHANGELOG.md",
28
+ "examples"
29
+ ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/dependencyGraph.d.ts",
33
+ "import": "./dist/dependencyGraph.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "engines": {
41
+ "node": ">=24"
42
+ },
43
+ "scripts": {
44
+ "build": "rm -rf dist tsconfig.tsbuildinfo && bun x tsc -p tsconfig.build.json",
45
+ "changeset": "ankhorage-changeset",
46
+ "changeset:status": "ankhorage-changeset status --since=origin/main",
47
+ "docs": "paradox",
48
+ "format": "ankhorage-prettier --write .",
49
+ "format:check": "ankhorage-prettier --check .",
50
+ "lint": "ankhorage-eslint . --max-warnings=0",
51
+ "lint:fix": "ankhorage-eslint . --fix --max-warnings=0",
52
+ "prepack": "bun run build",
53
+ "test": "bun test src",
54
+ "typecheck": "bun x tsc --noEmit -p tsconfig.json",
55
+ "version-packages": "ankhorage-changeset version",
56
+ "knip:check": "ankhorage-knip"
57
+ },
58
+ "dependencies": {
59
+ "@ankhorage/graph": "^0.1.0",
60
+ "@ankhorage/project-detector": "^0.1.0",
61
+ "@ankhorage/utility": "^0.8.0"
62
+ },
63
+ "peerDependencies": {
64
+ "typescript": "~6.0.3"
65
+ },
66
+ "devDependencies": {
67
+ "@ankhorage/devtools": "^1.14.7",
68
+ "@ankhorage/paradox": "^0.1.26",
69
+ "@types/bun": "^1.4.1",
70
+ "@types/node": "^26.5.1",
71
+ "typescript": "~6.0.3"
72
+ },
73
+ "packageManager": "bun@1.4.2"
74
+ }