1use serde::{Deserialize, Serialize};
2
3pub type SymbolId = String;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Symbol {
12 pub id: SymbolId,
13 pub name: String,
14 pub kind: SymbolKind,
15 pub language: Language,
16 pub file: String,
17 pub line_start: u32,
18 pub line_end: u32,
19 pub signature: Option<String>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
23pub enum SymbolKind {
24 Class,
25 Interface,
26 TypeAlias,
27 Function,
28 Method,
29 Property,
30 Variable,
31 Module,
32 Enum,
33 EnumVariant,
34 ExternalPackage,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
38pub enum Language {
39 TypeScript,
40 JavaScript,
41 Python,
42 Rust,
43 Go,
44 Java,
45 C,
46 Cpp,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct Relationship {
52 pub from: SymbolId,
53 pub to: SymbolId,
54 pub kind: RelationshipKind,
55 pub alias: Option<String>,
56 pub properties_accessed: Vec<String>,
57 pub context: String,
58 pub file: String,
59 pub line: u32,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
63pub enum RelationshipKind {
64 Imports,
65 Calls,
66 Extends,
67 Implements,
68 UsesType,
69 AccessesProperty,
70 ReExports,
71 Instantiates,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
77pub enum DiagnosticLevel {
78 Error,
80 Warning,
82 Info,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
87pub enum DiagnosticCategory {
88 Parse,
90 Resolution,
92 Skip,
94 Policy,
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
99pub struct Diagnostic {
100 pub level: DiagnosticLevel,
101 pub category: DiagnosticCategory,
102 pub message: String,
103 pub file: Option<String>,
104 pub line: Option<u32>,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct ReExportEntry {
111 pub exported_name: String,
113 pub source_module: String,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct FileIR {
120 pub file: String,
121 pub language: Language,
122 pub symbols: Vec<Symbol>,
123 pub relationships: Vec<Relationship>,
124 pub diagnostics: Vec<Diagnostic>,
125 pub re_exports: Vec<ReExportEntry>,
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130pub struct RepoIR {
131 pub root: String,
132 pub files: Vec<FileIR>,
133 pub language_stats: std::collections::HashMap<String, usize>,
134}