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}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct Relationship {
50 pub from: SymbolId,
51 pub to: SymbolId,
52 pub kind: RelationshipKind,
53 pub alias: Option<String>,
54 pub properties_accessed: Vec<String>,
55 pub context: String,
56 pub file: String,
57 pub line: u32,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
61pub enum RelationshipKind {
62 Imports,
63 Calls,
64 Extends,
65 Implements,
66 UsesType,
67 AccessesProperty,
68 ReExports,
69 Instantiates,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
75pub enum DiagnosticLevel {
76 Error,
78 Warning,
80 Info,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
85pub enum DiagnosticCategory {
86 Parse,
88 Resolution,
90 Skip,
92 Policy,
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct Diagnostic {
98 pub level: DiagnosticLevel,
99 pub category: DiagnosticCategory,
100 pub message: String,
101 pub file: Option<String>,
102 pub line: Option<u32>,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct ReExportEntry {
109 pub exported_name: String,
111 pub source_module: String,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct FileIR {
118 pub file: String,
119 pub language: Language,
120 pub symbols: Vec<Symbol>,
121 pub relationships: Vec<Relationship>,
122 pub diagnostics: Vec<Diagnostic>,
123 pub re_exports: Vec<ReExportEntry>,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128pub struct RepoIR {
129 pub root: String,
130 pub files: Vec<FileIR>,
131 pub language_stats: std::collections::HashMap<String, usize>,
132}