Skip to main content

linkrs_server/web/models/
schema.rs

1//! Schema Extension Models
2
3use serde::{Deserialize, Serialize};
4
5/// Space detail response
6#[derive(Debug, Serialize, utoipa::ToSchema)]
7pub struct SpaceDetail {
8    pub id: u64,
9    pub name: String,
10    pub vid_type: String,
11    pub partition_num: i32,
12    pub replica_factor: i32,
13    pub comment: Option<String>,
14    pub created_at: i64,
15    pub statistics: SpaceStatistics,
16}
17
18/// Space statistics
19#[derive(Debug, Serialize, utoipa::ToSchema)]
20pub struct SpaceStatistics {
21    pub tag_count: i64,
22    pub edge_type_count: i64,
23    pub index_count: i64,
24    pub estimated_vertex_count: i64,
25    pub estimated_edge_count: i64,
26}
27
28/// Tag summary
29#[derive(Debug, Serialize, utoipa::ToSchema)]
30pub struct TagSummary {
31    pub id: i64,
32    pub name: String,
33    pub property_count: i64,
34    pub index_count: i64,
35    pub created_at: i64,
36}
37
38/// Tag detail
39#[derive(Debug, Serialize, utoipa::ToSchema)]
40pub struct TagDetail {
41    pub id: i64,
42    pub name: String,
43    pub properties: Vec<PropertyDef>,
44    pub indexes: Vec<IndexInfo>,
45    pub created_at: i64,
46}
47
48/// Edge type summary
49#[derive(Debug, Serialize, utoipa::ToSchema)]
50pub struct EdgeTypeSummary {
51    pub id: i64,
52    pub name: String,
53    pub property_count: i64,
54    pub index_count: i64,
55    pub created_at: i64,
56}
57
58/// Edge type detail
59#[derive(Debug, Serialize, utoipa::ToSchema)]
60pub struct EdgeTypeDetail {
61    pub id: i64,
62    pub name: String,
63    pub properties: Vec<PropertyDef>,
64    pub indexes: Vec<IndexInfo>,
65    pub created_at: i64,
66}
67
68/// Property definition
69#[derive(Debug, Serialize, Deserialize, utoipa::ToSchema)]
70pub struct PropertyDef {
71    pub name: String,
72    pub data_type: String,
73    pub nullable: bool,
74    pub default_value: Option<String>,
75}
76
77/// Index information
78#[derive(Debug, Serialize, utoipa::ToSchema)]
79pub struct IndexInfo {
80    pub id: i64,
81    pub name: String,
82    pub index_type: String, // INDEX, UNIQUE, FULLTEXT
83    pub fields: Vec<String>,
84    pub status: String, // ACTIVE, BUILDING, FAILED
85    pub progress: Option<i32>,
86    pub created_at: i64,
87}
88
89/// Create index request
90#[derive(Debug, Deserialize, utoipa::ToSchema)]
91pub struct CreateIndexRequest {
92    pub name: String,
93    pub index_type: String,
94    pub entity_type: String, // TAG or EDGE
95    pub entity_name: String,
96    pub fields: Vec<String>,
97    pub comment: Option<String>,
98}
99
100/// Update tag request
101#[derive(Debug, Deserialize, utoipa::ToSchema)]
102pub struct UpdateTagRequest {
103    pub add_properties: Option<Vec<PropertyDef>>,
104    pub drop_properties: Option<Vec<String>>,
105}
106
107/// Update edge type request
108#[derive(Debug, Deserialize, utoipa::ToSchema)]
109pub struct UpdateEdgeTypeRequest {
110    pub add_properties: Option<Vec<PropertyDef>>,
111    pub drop_properties: Option<Vec<String>>,
112}