From f2b284f1bc162b0d829f2611f66785ac3588a4f5 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Fri, 30 Jan 2026 00:56:34 +0000 Subject: [PATCH] Add type definitions --- src/types/graph.ts | 105 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/types/graph.ts diff --git a/src/types/graph.ts b/src/types/graph.ts new file mode 100644 index 0000000..432bf1b --- /dev/null +++ b/src/types/graph.ts @@ -0,0 +1,105 @@ +export interface GraphNode { + id: string; + label: string; + kind: NodeKind; + filePath: string; + lineNumber: number; + metadata: Record; + 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; + 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'; +}