moved models from remote to models folder
This commit is contained in:
@@ -5,7 +5,8 @@ use tracing::{info, warn};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
lock_w,
|
lock_w,
|
||||||
remotes::health::{HealthError, HealthRemote},
|
models::health::HealthError,
|
||||||
|
remotes::health::HealthRemote,
|
||||||
services::{
|
services::{
|
||||||
active_app::init_active_app_changes_listener,
|
active_app::init_active_app_changes_listener,
|
||||||
auth::{get_access_token, get_tokens},
|
auth::{get_access_token, get_tokens},
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
lock_r,
|
lock_r,
|
||||||
|
models::dolls::{CreateDollDto, DollDto, UpdateDollDto},
|
||||||
remotes::{
|
remotes::{
|
||||||
dolls::{CreateDollDto, DollDto, DollsRemote, UpdateDollDto},
|
dolls::DollsRemote,
|
||||||
user::UserRemote,
|
user::UserRemote,
|
||||||
},
|
},
|
||||||
state::{init_app_data_scoped, AppDataRefreshScope, FDOLL},
|
state::{init_app_data_scoped, AppDataRefreshScope, FDOLL},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::remotes::friends::{
|
use crate::remotes::friends::FriendRemote;
|
||||||
FriendRemote, FriendRequestResponseDto, FriendshipResponseDto, SendFriendRequestDto,
|
use crate::models::friends::{
|
||||||
UserBasicDto,
|
FriendRequestResponseDto, FriendshipResponseDto, SendFriendRequestDto, UserBasicDto,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
use crate::remotes::{dolls::DollDto, friends::FriendshipResponseDto, user::UserProfile};
|
use crate::models::{dolls::DollDto, friends::FriendshipResponseDto, user::UserProfile};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, TS)]
|
#[derive(Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
|
|||||||
53
src-tauri/src/models/dolls.rs
Normal file
53
src-tauri/src/models/dolls.rs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use thiserror::Error;
|
||||||
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum RemoteError {
|
||||||
|
#[error("HTTP error: {0}")]
|
||||||
|
Http(#[from] reqwest::Error),
|
||||||
|
#[error("JSON parse error: {0}")]
|
||||||
|
Json(#[from] serde_json::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct DollColorSchemeDto {
|
||||||
|
pub outline: String,
|
||||||
|
pub body: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct DollConfigurationDto {
|
||||||
|
pub color_scheme: DollColorSchemeDto,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct CreateDollDto {
|
||||||
|
pub name: String,
|
||||||
|
pub configuration: Option<DollConfigurationDto>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct UpdateDollDto {
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub configuration: Option<DollConfigurationDto>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct DollDto {
|
||||||
|
pub id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub configuration: DollConfigurationDto,
|
||||||
|
pub created_at: String,
|
||||||
|
pub updated_at: String,
|
||||||
|
}
|
||||||
53
src-tauri/src/models/friends.rs
Normal file
53
src-tauri/src/models/friends.rs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use thiserror::Error;
|
||||||
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
use super::dolls::DollDto;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum RemoteError {
|
||||||
|
#[error("HTTP error: {0}")]
|
||||||
|
Http(#[from] reqwest::Error),
|
||||||
|
#[error("JSON parse error: {0}")]
|
||||||
|
Json(#[from] serde_json::Error),
|
||||||
|
#[error("{0}")]
|
||||||
|
Api(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct UserBasicDto {
|
||||||
|
pub id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub username: Option<String>,
|
||||||
|
pub active_doll: Option<DollDto>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct FriendshipResponseDto {
|
||||||
|
pub id: String,
|
||||||
|
pub friend: UserBasicDto,
|
||||||
|
pub created_at: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct SendFriendRequestDto {
|
||||||
|
pub receiver_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct FriendRequestResponseDto {
|
||||||
|
pub id: String,
|
||||||
|
pub sender: UserBasicDto,
|
||||||
|
pub receiver: UserBasicDto,
|
||||||
|
pub status: String,
|
||||||
|
pub created_at: String,
|
||||||
|
pub updated_at: String,
|
||||||
|
}
|
||||||
28
src-tauri/src/models/health.rs
Normal file
28
src-tauri/src/models/health.rs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
use reqwest::StatusCode;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use thiserror::Error;
|
||||||
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct HealthResponseDto {
|
||||||
|
pub status: String,
|
||||||
|
pub version: String,
|
||||||
|
pub uptime_secs: u64,
|
||||||
|
pub db: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum HealthError {
|
||||||
|
#[error("app configuration missing {0}")]
|
||||||
|
ConfigMissing(&'static str),
|
||||||
|
#[error("health request failed: {0}")]
|
||||||
|
Request(reqwest::Error),
|
||||||
|
#[error("unexpected health status: {0}")]
|
||||||
|
UnexpectedStatus(StatusCode),
|
||||||
|
#[error("health status reported not OK: {0}")]
|
||||||
|
NonOkStatus(String),
|
||||||
|
#[error("health response decode failed: {0}")]
|
||||||
|
Decode(reqwest::Error),
|
||||||
|
}
|
||||||
@@ -1,2 +1,6 @@
|
|||||||
pub mod app_data;
|
pub mod app_data;
|
||||||
|
pub mod dolls;
|
||||||
|
pub mod friends;
|
||||||
|
pub mod health;
|
||||||
pub mod interaction;
|
pub mod interaction;
|
||||||
|
pub mod user;
|
||||||
|
|||||||
19
src-tauri/src/models/user.rs
Normal file
19
src-tauri/src/models/user.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use ts_rs::TS;
|
||||||
|
|
||||||
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[ts(export)]
|
||||||
|
pub struct UserProfile {
|
||||||
|
pub id: String,
|
||||||
|
pub keycloak_sub: String,
|
||||||
|
pub name: String,
|
||||||
|
pub email: String,
|
||||||
|
pub username: Option<String>,
|
||||||
|
|
||||||
|
pub roles: Vec<String>,
|
||||||
|
pub created_at: String,
|
||||||
|
pub updated_at: String,
|
||||||
|
pub last_login_at: Option<String>,
|
||||||
|
pub active_doll_id: Option<String>,
|
||||||
|
}
|
||||||
@@ -1,59 +1,6 @@
|
|||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use thiserror::Error;
|
|
||||||
use ts_rs::TS;
|
|
||||||
|
|
||||||
use crate::{lock_r, services::auth::with_auth, state::FDOLL};
|
use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::dolls::*};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum RemoteError {
|
|
||||||
#[error("HTTP error: {0}")]
|
|
||||||
Http(#[from] reqwest::Error),
|
|
||||||
#[error("JSON parse error: {0}")]
|
|
||||||
Json(#[from] serde_json::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct DollColorSchemeDto {
|
|
||||||
pub outline: String,
|
|
||||||
pub body: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct DollConfigurationDto {
|
|
||||||
pub color_scheme: DollColorSchemeDto,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct CreateDollDto {
|
|
||||||
pub name: String,
|
|
||||||
pub configuration: Option<DollConfigurationDto>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct UpdateDollDto {
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub configuration: Option<DollConfigurationDto>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct DollDto {
|
|
||||||
pub id: String,
|
|
||||||
pub name: String,
|
|
||||||
pub configuration: DollConfigurationDto,
|
|
||||||
pub created_at: String,
|
|
||||||
pub updated_at: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct DollsRemote {
|
pub struct DollsRemote {
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
|
|||||||
@@ -1,57 +1,6 @@
|
|||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use thiserror::Error;
|
|
||||||
use ts_rs::TS;
|
|
||||||
|
|
||||||
use crate::{lock_r, remotes::dolls::DollDto, services::auth::with_auth, state::FDOLL};
|
use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::friends::*};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum RemoteError {
|
|
||||||
#[error("HTTP error: {0}")]
|
|
||||||
Http(#[from] reqwest::Error),
|
|
||||||
#[error("JSON parse error: {0}")]
|
|
||||||
Json(#[from] serde_json::Error),
|
|
||||||
#[error("{0}")]
|
|
||||||
Api(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct UserBasicDto {
|
|
||||||
pub id: String,
|
|
||||||
pub name: String,
|
|
||||||
pub username: Option<String>,
|
|
||||||
pub active_doll: Option<DollDto>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct FriendshipResponseDto {
|
|
||||||
pub id: String,
|
|
||||||
pub friend: UserBasicDto,
|
|
||||||
pub created_at: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct SendFriendRequestDto {
|
|
||||||
pub receiver_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct FriendRequestResponseDto {
|
|
||||||
pub id: String,
|
|
||||||
pub sender: UserBasicDto,
|
|
||||||
pub receiver: UserBasicDto,
|
|
||||||
pub status: String,
|
|
||||||
pub created_at: String,
|
|
||||||
pub updated_at: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct FriendRemote {
|
pub struct FriendRemote {
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
|
|||||||
@@ -1,33 +1,6 @@
|
|||||||
use reqwest::{Client, StatusCode};
|
use reqwest::Client;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use thiserror::Error;
|
|
||||||
use ts_rs::TS;
|
|
||||||
|
|
||||||
use crate::{lock_r, state::FDOLL};
|
use crate::{lock_r, state::FDOLL, models::health::*};
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct HealthResponseDto {
|
|
||||||
pub status: String,
|
|
||||||
pub version: String,
|
|
||||||
pub uptime_secs: u64,
|
|
||||||
pub db: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum HealthError {
|
|
||||||
#[error("app configuration missing {0}")]
|
|
||||||
ConfigMissing(&'static str),
|
|
||||||
#[error("health request failed: {0}")]
|
|
||||||
Request(reqwest::Error),
|
|
||||||
#[error("unexpected health status: {0}")]
|
|
||||||
UnexpectedStatus(StatusCode),
|
|
||||||
#[error("health status reported not OK: {0}")]
|
|
||||||
NonOkStatus(String),
|
|
||||||
#[error("health response decode failed: {0}")]
|
|
||||||
Decode(reqwest::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct HealthRemote {
|
pub struct HealthRemote {
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
|
|||||||
@@ -1,25 +1,6 @@
|
|||||||
use reqwest::{Client, Error};
|
use reqwest::{Client, Error};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use ts_rs::TS;
|
|
||||||
|
|
||||||
use crate::{lock_r, services::auth::with_auth, state::FDOLL};
|
use crate::{lock_r, services::auth::with_auth, state::FDOLL, models::user::*};
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
#[ts(export)]
|
|
||||||
pub struct UserProfile {
|
|
||||||
pub id: String,
|
|
||||||
pub keycloak_sub: String,
|
|
||||||
pub name: String,
|
|
||||||
pub email: String,
|
|
||||||
pub username: Option<String>,
|
|
||||||
|
|
||||||
pub roles: Vec<String>,
|
|
||||||
pub created_at: String,
|
|
||||||
pub updated_at: String,
|
|
||||||
pub last_login_at: Option<String>,
|
|
||||||
pub active_doll_id: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UserRemote {
|
pub struct UserRemote {
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user