Add type definitions
Some checks failed
CI / test (push) Failing after 6s

This commit is contained in:
2026-01-30 00:56:34 +00:00
parent 1ffdc08d97
commit f2b284f1bc

105
src/types/graph.ts Normal file
View File

@@ -0,0 +1,105 @@
export interface GraphNode {
id: string;
label: string;
kind: NodeKind;
filePath: string;
lineNumber: number;
metadata: Record<string, unknown>;
dependencies: string[];
}
export type NodeKind = 'interface' | 'type_alias' | 'class' | 'enum' | 'function' | 'import' | 'external';
export interface GraphEdge {
source: string;
target: string;
label?: string;
style?: EdgeStyle;
weight?: number;
}
export type EdgeStyle = 'solid' | 'dashed' | 'dotted';
export interface DependencyGraph {
nodes: Map<string, GraphNode>;
edges: GraphEdge[];
clusters: GraphCluster[];
metadata: GraphMetadata;
}
export interface GraphCluster {
id: string;
label: string;
nodeIds: string[];
style?: string;
}
export interface GraphMetadata {
createdAt: string;
sourceDirectory: string;
nodeCount: number;
edgeCount: number;
analysisOptions: AnalysisOptions;
}
export interface AnalysisOptions {
maxDepth?: number;
includeExternal?: boolean;
excludedPatterns?: string[];
focusTypes?: string[];
}
export interface CircularDependency {
cycle: string[];
nodes: string[];
edges: GraphEdge[];
length: number;
}
export interface WideningIssue {
nodeId: string;
typeName: string;
filePath: string;
lineNumber: number;
description: string;
originalType?: string;
widenedType?: string;
suggestion?: string;
}
export interface NarrowingIssue {
nodeId: string;
typeName: string;
filePath: string;
lineNumber: number;
description: string;
originalType?: string;
narrowedType?: string;
suggestion?: string;
}
export interface AnalysisResult {
graph: DependencyGraph;
circularDependencies: CircularDependency[];
wideningIssues: WideningIssue[];
narrowingIssues: NarrowingIssue[];
summary: AnalysisSummary;
}
export interface AnalysisSummary {
totalNodes: number;
totalEdges: number;
totalCircular: number;
totalWidening: number;
totalNarrowing: number;
filesAnalyzed: number;
analysisTimeMs: number;
}
export interface ExportOptions {
format: 'dot' | 'graphml' | 'json';
outputPath: string;
includeMetadata?: boolean;
layout?: string;
rankDir?: 'TB' | 'LR' | 'BT' | 'RL';
}