1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Deserialize, Serialize)]
4#[serde(rename_all = "camelCase")]
5pub struct PingRequest {
6 pub value: Option<String>,
7}
8
9#[derive(Debug, Clone, Default, Deserialize, Serialize)]
10#[serde(rename_all = "camelCase")]
11pub struct PingResponse {
12 pub value: Option<String>,
13}
14
15#[derive(Debug, Serialize, Deserialize)]
16#[serde(rename_all = "camelCase")]
17pub struct GenerateModelsRequest {
18 pub project_path: String,
19 pub output_path: Option<String>,
20 pub validation_library: Option<String>,
21}
22
23#[derive(Debug, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct GenerateModelsResponse {
26 pub generated_files: Vec<String>,
27 pub commands_found: i32,
28 pub types_generated: i32,
29}
30
31#[derive(Debug, Serialize, Deserialize)]
32#[serde(rename_all = "camelCase")]
33pub struct AnalyzeCommandsRequest {
34 pub project_path: String,
35}
36
37#[derive(Debug, Serialize, Deserialize)]
38#[serde(rename_all = "camelCase")]
39pub struct AnalyzeCommandsResponse {
40 pub commands: Vec<CommandInfo>,
41}
42
43#[derive(Debug, Serialize, Deserialize)]
44#[serde(rename_all = "camelCase")]
45pub struct CommandInfo {
46 pub name: String,
47 pub file_path: String,
48 pub line_number: usize,
49 pub parameters: Vec<ParameterInfo>,
50 pub return_type: String, pub return_type_ts: String, pub is_async: bool,
53 pub channels: Vec<ChannelInfo>,
54}
55
56#[derive(Debug, Serialize, Deserialize)]
57#[serde(rename_all = "camelCase")]
58pub struct ParameterInfo {
59 pub name: String,
60 pub rust_type: String,
61 pub typescript_type: String,
62 pub is_optional: bool,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct StructInfo {
69 pub name: String,
70 pub fields: Vec<FieldInfo>,
71 pub file_path: String,
72 pub is_enum: bool,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(rename_all = "camelCase")]
77pub struct FieldInfo {
78 pub name: String,
79 pub rust_type: String,
80 pub typescript_type: String,
81 pub is_optional: bool,
82 pub is_public: bool,
83 pub validator_attributes: Option<ValidatorAttributes>,
84 #[serde(default, skip_serializing_if = "Option::is_none")]
87 pub serialized_name: Option<String>,
88}
89
90impl FieldInfo {
91 pub fn get_serialized_name(&self) -> &str {
93 self.serialized_name.as_deref().unwrap_or(&self.name)
94 }
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(rename_all = "camelCase")]
99pub struct ValidatorAttributes {
100 pub length: Option<LengthConstraint>,
101 pub range: Option<RangeConstraint>,
102 pub email: bool,
103 pub url: bool,
104 pub custom_message: Option<String>,
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(rename_all = "camelCase")]
109pub struct LengthConstraint {
110 pub min: Option<u64>,
111 pub max: Option<u64>,
112 pub message: Option<String>,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(rename_all = "camelCase")]
117pub struct RangeConstraint {
118 pub min: Option<f64>,
119 pub max: Option<f64>,
120 pub message: Option<String>,
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(rename_all = "camelCase")]
126pub struct EventInfo {
127 pub event_name: String,
128 pub payload_type: String,
129 pub typescript_payload_type: String,
130 pub file_path: String,
131 pub line_number: usize,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(rename_all = "camelCase")]
137pub struct ChannelInfo {
138 pub parameter_name: String,
139 pub message_type: String,
140 pub typescript_message_type: String,
141 pub command_name: String,
142 pub file_path: String,
143 pub line_number: usize,
144}