use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use super::media::MediaResponse; #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct RegisterDeviceRequest { pub name: String, pub device_type: String, pub client_version: String, pub os_info: Option, } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct DeviceResponse { pub id: String, pub name: String, pub device_type: String, pub client_version: String, pub os_info: Option, pub last_sync_at: Option>, pub last_seen_at: DateTime, pub sync_cursor: Option, pub enabled: bool, pub created_at: DateTime, } impl From for DeviceResponse { fn from(d: pinakes_core::sync::SyncDevice) -> Self { Self { id: d.id.0.to_string(), name: d.name, device_type: d.device_type.to_string(), client_version: d.client_version, os_info: d.os_info, last_sync_at: d.last_sync_at, last_seen_at: d.last_seen_at, sync_cursor: d.sync_cursor, enabled: d.enabled, created_at: d.created_at, } } } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct DeviceRegistrationResponse { pub device: DeviceResponse, pub device_token: String, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct UpdateDeviceRequest { pub name: Option, pub enabled: Option, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct GetChangesParams { pub cursor: Option, pub limit: Option, } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct SyncChangeResponse { pub id: String, pub sequence: i64, pub change_type: String, pub media_id: Option, pub path: String, pub content_hash: Option, pub file_size: Option, pub timestamp: DateTime, } impl From for SyncChangeResponse { fn from(e: pinakes_core::sync::SyncLogEntry) -> Self { Self { id: e.id.to_string(), sequence: e.sequence, change_type: e.change_type.to_string(), media_id: e.media_id.map(|id| id.0.to_string()), path: e.path, content_hash: e.content_hash.map(|h| h.0), file_size: e.file_size, timestamp: e.timestamp, } } } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct ChangesResponse { pub changes: Vec, pub cursor: i64, pub has_more: bool, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct ClientChangeReport { pub path: String, pub change_type: String, pub content_hash: Option, pub file_size: Option, pub local_mtime: Option, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct ReportChangesRequest { pub changes: Vec, } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct ReportChangesResponse { pub accepted: Vec, pub conflicts: Vec, pub upload_required: Vec, } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct ConflictResponse { pub id: String, pub path: String, pub local_hash: String, pub server_hash: String, pub detected_at: DateTime, } impl From for ConflictResponse { fn from(c: pinakes_core::sync::SyncConflict) -> Self { Self { id: c.id.to_string(), path: c.path, local_hash: c.local_hash, server_hash: c.server_hash, detected_at: c.detected_at, } } } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct ResolveConflictRequest { pub resolution: String, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct CreateUploadSessionRequest { pub target_path: String, pub expected_hash: String, pub expected_size: u64, pub chunk_size: Option, } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct UploadSessionResponse { pub id: String, pub target_path: String, pub expected_hash: String, pub expected_size: u64, pub chunk_size: u64, pub chunk_count: u64, pub status: String, pub created_at: DateTime, pub expires_at: DateTime, } impl From for UploadSessionResponse { fn from(s: pinakes_core::sync::UploadSession) -> Self { Self { id: s.id.to_string(), target_path: s.target_path, expected_hash: s.expected_hash.0, expected_size: s.expected_size, chunk_size: s.chunk_size, chunk_count: s.chunk_count, status: s.status.to_string(), created_at: s.created_at, expires_at: s.expires_at, } } } #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct ChunkUploadedResponse { pub chunk_index: u64, pub received: bool, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct AcknowledgeChangesRequest { pub cursor: i64, } // Most viewed (uses MediaResponse) #[derive(Debug, Serialize, utoipa::ToSchema)] pub struct MostViewedResponse { pub media: MediaResponse, pub view_count: u64, }