Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace individual serde rename to rename all #89

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions server/src/http/connect_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpConnectSessionRequest {
#[serde(rename = "clientId")]
pub client_id: String,
#[serde(rename = "publicKeys")]
pub public_keys: Vec<String>,
#[serde(rename = "sessionId")]
pub session_id: String,
#[ts(optional)]
pub notification: Option<Notification>,
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/drop_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpDropSessionsRequest {
#[serde(rename = "clientId")]
pub client_id: ClientId,
pub sessions: Vec<SessionId>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpDropSessionsResponse {
#[serde(rename = "droppedSessions")]
pub dropped_sessions: Vec<SessionId>,
}

Expand Down
11 changes: 4 additions & 7 deletions server/src/http/get_pending_request.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::{
errors::NightlyError,
state::{ClientId, SessionId, Sessions},
structs::common::PendingRequest,
};
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpGetPendingRequestRequest {
#[serde(rename = "clientId")]
pub client_id: ClientId,
#[serde(rename = "sessionId")]
pub session_id: SessionId,
#[serde(rename = "requestId")]
pub request_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
Expand Down
12 changes: 5 additions & 7 deletions server/src/http/get_pending_requests.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::{
errors::NightlyError,
state::{ClientId, SessionId, Sessions},
structs::common::PendingRequest,
};
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpGetPendingRequestsRequest {
#[serde(rename = "clientId")]
pub client_id: ClientId,
#[serde(rename = "sessionId")]
pub session_id: SessionId,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpGetPendingRequestsResponse {
#[serde(rename = "pendingRequests")]
pub pending_requests: Vec<PendingRequest>,
}
pub async fn get_pending_requests(
Expand Down
12 changes: 6 additions & 6 deletions server/src/http/get_session_info.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::{
errors::NightlyError,
state::{SessionId, Sessions},
structs::common::{AppMetadata, Network, SessionStatus, Version},
};
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpGetSessionInfoRequest {
#[serde(rename = "sessionId")]
pub session_id: SessionId,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpGetSessionInfoResponse {
pub status: SessionStatus,
pub persistent: bool,
pub version: Version,
pub network: Network,
#[serde(rename = "appMetadata")]
pub app_metadata: AppMetadata,
}

pub async fn get_session_info(
State(sessions): State<Sessions>,
Json(request): Json<HttpGetSessionInfoRequest>,
Expand Down
3 changes: 2 additions & 1 deletion server/src/http/get_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ use crate::state::{ClientId, ClientToSessions, ModifySession, SessionId};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpGetSessionsRequest {
#[serde(rename = "clientId")]
client_id: ClientId,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct HttpGetSessionsResponse {
sessions: Vec<SessionId>,
}

pub async fn get_sessions(
State(client_to_sessions): State<ClientToSessions>,
Json(request): Json<HttpGetSessionsRequest>,
Expand Down
12 changes: 5 additions & 7 deletions server/src/http/resolve_request.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::{
errors::NightlyError,
state::{ClientId, Sessions},
structs::app_messages::{app_messages::ServerToApp, payload::ResponsePayload},
};
use axum::{extract::State, http::StatusCode, Json};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct HttpResolveRequestRequest {
#[serde(rename = "clientId")]
pub client_id: ClientId,
#[serde(rename = "sessionId")]
pub session_id: String,
#[serde(rename = "requestId")]
pub request_id: String,
pub content: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct HttpResolveRequestResponse {}

pub async fn resolve_request(
State(sessions): State<Sessions>,
Json(request): Json<HttpResolveRequestRequest>,
Expand Down
2 changes: 1 addition & 1 deletion server/src/structs/app_messages/already_connected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct AlreadyConnected {
#[serde(rename = "sessionId")]
pub session_id: String,
}
8 changes: 3 additions & 5 deletions server/src/structs/app_messages/app_messages.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::structs::common::{AckMessage, ErrorMessage};

use super::{
already_connected::AlreadyConnected,
initialize::{InitializeRequest, InitializeResponse},
payload::{RequestPayload, ResponsePayload},
user_connected_event::UserConnectedEvent,
user_disconnected_event::UserDisconnectedEvent,
};
use crate::structs::common::{AckMessage, ErrorMessage};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
Expand Down
10 changes: 2 additions & 8 deletions server/src/structs/app_messages/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,25 @@ use crate::structs::common::{AppMetadata, Network, Version};

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct InitializeRequest {
#[serde(rename = "responseId")]
pub response_id: String,
#[serde(rename = "appMetadata")]
pub app_metadata: AppMetadata,
pub network: Network,
pub version: Version,
pub persistent: bool,
#[serde(rename = "persistentSessionId")]
#[ts(optional)]
pub persistent_session_id: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct InitializeResponse {
#[serde(rename = "responseId")]
pub response_id: String,
#[serde(rename = "sessionId")]
pub session_id: String,
#[serde(rename = "createdNew")]
pub created_new: bool, // if the session was created new or if it was restored
#[serde(rename = "publicKeys")]
pub public_keys: Vec<String>, // if session was restored, this is the list of public keys that were restored
#[serde(rename = "metadata")]
#[ts(optional)]
pub metadata: Option<String>, // if session was restored, this is the metadata that was restored
}
4 changes: 2 additions & 2 deletions server/src/structs/app_messages/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct RequestPayload {
#[serde(rename = "responseId")]
pub response_id: String,
pub content: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct ResponsePayload {
#[serde(rename = "responseId")]
pub response_id: String,
pub content: String,
}
2 changes: 1 addition & 1 deletion server/src/structs/app_messages/user_connected_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct UserConnectedEvent {
#[serde(rename = "publicKeys")]
pub public_keys: Vec<String>,
#[ts(optional)]
pub metadata: Option<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct AppDisconnectedEvent {
#[serde(rename = "sessionId")]
pub session_id: String,
pub reason: String,
}
5 changes: 2 additions & 3 deletions server/src/structs/client_messages/client_initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ use ts_rs::TS;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct ClientInitializeRequest {
#[serde(rename = "responseId")]
pub response_id: String,
#[serde(rename = "clientId")]
pub client_id: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct ClientInitializeResponse {
#[serde(rename = "responseId")]
pub response_id: String,
}
8 changes: 3 additions & 5 deletions server/src/structs/client_messages/client_messages.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::structs::common::{AckMessage, ErrorMessage};

use super::{
app_disconnected_event::AppDisconnectedEvent,
client_initialize::{ClientInitializeRequest, ClientInitializeResponse},
Expand All @@ -13,6 +8,9 @@ use super::{
get_sessions::{GetSessionsRequest, GetSessionsResponse},
new_payload_event::{NewPayloadEvent, NewPayloadEventReply},
};
use crate::structs::common::{AckMessage, ErrorMessage};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
Expand Down
10 changes: 3 additions & 7 deletions server/src/structs/client_messages/connect.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
use crate::structs::common::{Device, Notification};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

use crate::structs::common::{Device, Notification};

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct ConnectRequest {
#[serde(rename = "responseId")]
pub response_id: String,
#[serde(rename = "clientId")]
pub client_id: String, // used for session resolution
#[serde(rename = "publicKeys")]
pub public_keys: Vec<String>,
#[serde(rename = "sessionId")]
pub session_id: String,
#[ts(optional)]
pub notification: Option<Notification>,
Expand All @@ -24,7 +20,7 @@ pub struct ConnectRequest {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct ConnectResponse {
#[serde(rename = "responseId")]
pub response_id: String,
}
5 changes: 2 additions & 3 deletions server/src/structs/client_messages/drop_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ use crate::state::SessionId;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct DropSessionsRequest {
#[serde(rename = "responseId")]
pub response_id: String,
pub sessions: Vec<SessionId>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct DropSessionsResponse {
#[serde(rename = "responseId")]
pub response_id: String,
#[serde(rename = "droppedSessions")]
pub dropped_sessions: Vec<SessionId>,
}
6 changes: 2 additions & 4 deletions server/src/structs/client_messages/get_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ use crate::structs::common::{AppMetadata, Network, Version};

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct GetInfoRequest {
#[serde(rename = "responseId")]
pub response_id: String,
#[serde(rename = "sessionId")]
pub session_id: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct GetInfoResponse {
#[serde(rename = "responseId")]
pub response_id: String,
pub network: Network,
pub version: Version,
#[serde(rename = "appMetadata")]
pub app_metadata: AppMetadata,
}
Loading
Loading