90 lines
2.1 KiB
Rust
90 lines
2.1 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use ts_rs::TS;
|
|
|
|
use crate::types::user::PackUserBase;
|
|
|
|
use magnetar_sdk_macros::pack;
|
|
|
|
use crate::types::Id;
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct ImageMeta {
|
|
pub width: Option<u64>,
|
|
pub height: Option<u64>,
|
|
pub orientation: Option<u64>,
|
|
pub color: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct DriveFolderBase {
|
|
pub name: String,
|
|
pub created_at: DateTime<Utc>,
|
|
pub comment: Option<String>,
|
|
pub file_count: u64,
|
|
pub folder_count: u64,
|
|
pub parent_id: Option<String>,
|
|
pub user_id: String,
|
|
}
|
|
|
|
pack!(PackDriveFolderBase, Id as id & DriveFolderBase as folder);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct DriveFolderParentExt {
|
|
pub folder: Box<DriveFolderBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackDriveFolderWithParent,
|
|
Id as id & DriveFolderBase as folder & DriveFolderParentExt as parent
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct DriveFileBase {
|
|
pub name: String,
|
|
pub created_at: DateTime<Utc>,
|
|
pub size: u64,
|
|
pub sha256: String,
|
|
pub mime_type: String,
|
|
pub image_meta: ImageMeta,
|
|
pub url: Option<String>,
|
|
pub thumbnail_url: Option<String>,
|
|
pub sensitive: bool,
|
|
pub comment: Option<String>,
|
|
pub folder_id: Option<String>,
|
|
pub user_id: String,
|
|
}
|
|
|
|
pack!(PackDriveFileBase, Id as id & DriveFileBase as file);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct DriveFileFolderExt {
|
|
pub folder: Box<PackDriveFolderBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackDriveFileWithFolder,
|
|
Id as id & DriveFileBase as file & DriveFileFolderExt as folder
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct DriveFileUserExt {
|
|
pub user: Box<PackUserBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackDriveFileWithUser,
|
|
Id as id & DriveFileBase as file & DriveFileUserExt as user
|
|
);
|
|
|
|
pack!(
|
|
PackDriveFileFull,
|
|
Id as id & DriveFileBase as file & DriveFileFolderExt as folder & DriveFileUserExt as user
|
|
);
|