1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Deserialize, Serialize)]
8pub struct GraphNode {
9 pub id: String,
10 pub label: String,
11 #[serde(default)]
12 pub node_type: Option<String>,
13 #[serde(default)]
14 pub description: Option<String>,
15 #[serde(default)]
16 pub properties: Option<HashMap<String, serde_json::Value>>,
17 #[serde(default)]
18 pub degree: Option<u32>,
19}
20
21#[derive(Debug, Clone, Deserialize, Serialize)]
23pub struct GraphEdge {
24 pub source: String,
25 pub target: String,
26 #[serde(default)]
27 pub edge_type: Option<String>,
28 #[serde(default)]
29 pub weight: Option<f64>,
30 #[serde(default)]
31 pub properties: Option<HashMap<String, serde_json::Value>>,
32}
33
34#[derive(Debug, Clone, Deserialize, Serialize)]
36pub struct GraphResponse {
37 #[serde(default)]
38 pub nodes: Vec<GraphNode>,
39 #[serde(default)]
40 pub edges: Vec<GraphEdge>,
41 #[serde(default)]
42 pub total_nodes: Option<u32>,
43 #[serde(default)]
44 pub total_edges: Option<u32>,
45}
46
47#[derive(Debug, Clone, Deserialize, Serialize)]
49pub struct SearchNodesResponse {
50 #[serde(default)]
51 pub nodes: Vec<GraphNode>,
52 #[serde(default)]
53 pub edges: Vec<GraphEdge>,
54 #[serde(default)]
55 pub total_matches: Option<u32>,
56}
57
58#[derive(Debug, Clone, Deserialize, Serialize)]
60pub struct Entity {
61 pub id: String,
62 #[serde(default)]
63 pub entity_name: String,
64 #[serde(default)]
65 pub entity_type: Option<String>,
66 #[serde(default)]
67 pub description: Option<String>,
68 #[serde(default)]
69 pub source_id: Option<String>,
70 #[serde(default)]
71 pub properties: Option<HashMap<String, serde_json::Value>>,
72 #[serde(default)]
73 pub degree: Option<u32>,
74 #[serde(default)]
75 pub created_at: Option<String>,
76 #[serde(default)]
77 pub updated_at: Option<String>,
78 #[serde(default)]
79 pub metadata: Option<serde_json::Value>,
80}
81
82#[derive(Debug, Clone, Deserialize)]
84pub struct EntityListResponse {
85 #[serde(default)]
86 pub items: Vec<Entity>,
87 #[serde(default)]
88 pub total: u32,
89 #[serde(default)]
90 pub page: u32,
91 #[serde(default)]
92 pub page_size: u32,
93 #[serde(default)]
94 pub total_pages: u32,
95}
96
97#[derive(Debug, Clone, Deserialize)]
99pub struct EntityDetailResponse {
100 pub entity: Entity,
101 #[serde(default)]
102 pub relationships: Option<EntityRelationships>,
103 #[serde(default)]
104 pub statistics: Option<EntityStatistics>,
105}
106
107#[derive(Debug, Clone, Deserialize)]
109pub struct EntityRelationships {
110 #[serde(default)]
111 pub outgoing: Vec<Relationship>,
112 #[serde(default)]
113 pub incoming: Vec<Relationship>,
114}
115
116#[derive(Debug, Clone, Deserialize)]
118pub struct EntityStatistics {
119 #[serde(default)]
120 pub total_relationships: u32,
121 #[serde(default)]
122 pub outgoing_count: u32,
123 #[serde(default)]
124 pub incoming_count: u32,
125 #[serde(default)]
126 pub document_references: u32,
127}
128
129#[derive(Debug, Clone, Serialize)]
131pub struct CreateEntityRequest {
132 pub entity_name: String,
133 pub entity_type: String,
134 pub description: String,
135 pub source_id: String,
136 #[serde(skip_serializing_if = "Option::is_none")]
137 pub metadata: Option<serde_json::Value>,
138}
139
140#[derive(Debug, Clone, Deserialize)]
142pub struct CreateEntityResponse {
143 pub status: String,
144 #[serde(default)]
145 pub message: Option<String>,
146 #[serde(default)]
147 pub entity: Option<Entity>,
148}
149
150#[derive(Debug, Clone, Deserialize)]
152pub struct EntityExistsResponse {
153 pub exists: bool,
154 #[serde(default)]
155 pub entity_id: Option<String>,
156 #[serde(default)]
157 pub entity_type: Option<String>,
158 #[serde(default)]
159 pub degree: Option<u32>,
160}
161
162#[derive(Debug, Clone, Deserialize)]
164pub struct MergeEntitiesResponse {
165 #[serde(default)]
166 pub merged_entity: Option<Entity>,
167 #[serde(default)]
168 pub merged_count: u32,
169 #[serde(default)]
170 pub message: Option<String>,
171}
172
173#[derive(Debug, Clone, Serialize)]
175pub struct MergeEntitiesRequest {
176 pub source_entity: String,
177 pub target_entity: String,
178}
179
180#[derive(Debug, Clone, Deserialize)]
182pub struct NeighborhoodResponse {
183 #[serde(default)]
184 pub center: Option<Entity>,
185 #[serde(default)]
186 pub nodes: Vec<GraphNode>,
187 #[serde(default)]
188 pub edges: Vec<GraphEdge>,
189 #[serde(default = "default_depth")]
190 pub depth: u32,
191}
192
193fn default_depth() -> u32 {
194 1
195}
196
197#[derive(Debug, Clone, Deserialize, Serialize)]
199pub struct Relationship {
200 #[serde(default)]
201 pub id: Option<String>,
202 pub source: String,
203 pub target: String,
204 #[serde(default)]
205 pub relationship_type: Option<String>,
206 #[serde(default)]
207 pub weight: Option<f64>,
208 #[serde(default)]
209 pub description: Option<String>,
210 #[serde(default)]
211 pub properties: Option<HashMap<String, serde_json::Value>>,
212}
213
214#[derive(Debug, Clone, Serialize)]
216pub struct CreateRelationshipRequest {
217 pub source: String,
218 pub target: String,
219 pub relationship_type: String,
220 #[serde(skip_serializing_if = "Option::is_none")]
221 pub weight: Option<f64>,
222 #[serde(skip_serializing_if = "Option::is_none")]
223 pub description: Option<String>,
224}
225
226#[derive(Debug, Clone, Deserialize)]
228pub struct DegreesBatchResponse {
229 #[serde(default)]
230 pub degrees: HashMap<String, u32>,
231}
232
233#[derive(Debug, Clone, Deserialize)]
235pub struct RelationshipListResponse {
236 #[serde(default)]
237 pub items: Vec<Relationship>,
238 #[serde(default)]
239 pub total: u32,
240 #[serde(default)]
241 pub page: u32,
242 #[serde(default)]
243 pub page_size: u32,
244 #[serde(default)]
245 pub total_pages: u32,
246}