File size: 4,841 Bytes
fd8cdf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import type { DashboardNode, DashboardEdge } from '../../types/dashboard.js';
import type { FileEntry } from './scanner.js';
import type { ParseResult } from './parser.js';
/**
 * Output of the graph building process.
 */
export interface GraphOutput {
    /** Generated graph nodes (files, functions, classes) */
    nodes: DashboardNode[];
    /** Generated graph edges (imports, containment, calls) */
    edges: DashboardEdge[];
}
/**
 * Builds file-level graph nodes from scanned files and their parse results.
 *
 * For each file, creates a DashboardNode with:
 * - id: the file's relative path
 * - type: "file"
 * - name: the file's basename
 * - summary: generated from parse result (exports, classes, functions, or fallback)
 * - tags: language, category, path-based patterns, and complexity
 *
 * @param files - Scanned file entries with metadata
 * @param parseResults - Map of file relative path to its parse result
 * @returns Array of DashboardNode for each file
 */
export declare function buildFileNodes(files: FileEntry[], parseResults: Map<string, ParseResult>): DashboardNode[];
/**
 * Builds function-level graph nodes for significant functions.
 *
 * A function is "significant" if it is exported OR has 10+ lines (endLine - startLine + 1 >= 10).
 *
 * For each significant function, creates a DashboardNode with:
 * - id: "{relativePath}::{functionName}"
 * - type: "function"
 * - name: the function name
 * - summary: "({params}) → {lineCount} lines"
 * - tags: language, "exported" if exported, "async" if name suggests async
 *
 * Also creates a `contains` edge from the file node to the function node.
 *
 * @param files - Scanned file entries with metadata
 * @param parseResults - Map of file relative path to its parse result
 * @returns Object with nodes and edges arrays
 */
export declare function buildFunctionNodes(files: FileEntry[], parseResults: Map<string, ParseResult>): {
    nodes: DashboardNode[];
    edges: DashboardEdge[];
};
/**
 * Builds class-level graph nodes for all classes found in parse results.
 *
 * For each class, creates a DashboardNode with:
 * - id: "{relativePath}::{className}"
 * - type: "class"
 * - name: the class name
 * - summary: "Methods: {methods}" or "Empty class" if no methods
 * - tags: language, "exported" if exported, size tag (small/medium/large-class)
 *
 * Also creates a `contains` edge from the file node to the class node.
 *
 * @param files - Scanned file entries with metadata
 * @param parseResults - Map of file relative path to its parse result
 * @returns Object with nodes and edges arrays
 */
export declare function buildClassNodes(files: FileEntry[], parseResults: Map<string, ParseResult>): {
    nodes: DashboardNode[];
    edges: DashboardEdge[];
};
/**
 * Builds import edges from resolved relative import paths.
 *
 * For each file's imports:
 * - Only processes imports with relative paths (starting with '.' or '..')
 * - Resolves the import path relative to the importing file's directory
 * - If the resolved path matches a known file, creates an 'imports' edge
 * - Skips external package imports and unresolvable imports
 *
 * @param files - Scanned file entries with metadata
 * @param parseResults - Map of file relative path to its parse result
 * @returns Array of DashboardEdge with type 'imports'
 */
export declare function buildImportEdges(files: FileEntry[], parseResults: Map<string, ParseResult>): DashboardEdge[];
/**
 * Builds call edges using a simple heuristic based on named imports.
 *
 * For each file's imports that resolve to a known file:
 * - If the import has named imports (e.g., `import { formatDate } from './utils'`)
 * - And the target file has a significant function node with that name
 * - Creates a 'calls' edge from the importing file to the function node
 *
 * This is a best-effort heuristic — it won't catch all calls but provides useful edges.
 *
 * @param files - Scanned file entries with metadata
 * @param parseResults - Map of file relative path to its parse result
 * @returns Array of DashboardEdge with type 'calls'
 */
export declare function buildCallEdges(files: FileEntry[], parseResults: Map<string, ParseResult>): DashboardEdge[];
/**
 * Builds graph nodes and edges from scanned files and their parse results.
 *
 * Generates:
 * - File nodes for each source file
 * - Function nodes for each extracted function
 * - Class nodes for each extracted class
 * - Import edges between files
 * - Containment edges (file → function/class)
 * - Call relationship edges where detected
 *
 * @param files - Scanned file entries with metadata
 * @param parseResults - Map of file relative path to its parse result
 * @returns GraphOutput with all generated nodes and edges
 */
export declare function buildGraph(files: FileEntry[], parseResults: Map<string, ParseResult>): GraphOutput;