use std::hash::Hash;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[cfg(feature = "typescript")]
use ts_rs::TS;
use crate::{AuthorId, FileMetaId, PlatformId, PostId};
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct Author {
pub id: AuthorId,
pub name: String,
pub thumb: Option<FileMetaId>,
pub updated: DateTime<Utc>,
}
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct Alias {
pub source: String,
pub platform: PlatformId,
pub target: AuthorId,
pub link: Option<String>,
}
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct AuthorPost {
pub author: AuthorId,
pub post: PostId,
}
#[cfg(feature = "utils")]
mod definitions {
use crate::utils::macros::as_table;
use super::*;
as_table! {
"authors" => Author {
id: "id",
name: "name",
thumb: "thumb",
updated: "updated",
}
"author_posts" => AuthorPost {
author: "author",
post: "post",
}
"author_aliases" => Alias {
source: "source",
platform: "platform",
target: "target",
link: "link",
}
}
}