1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use std::{collections::HashSet, hash::Hash, path::PathBuf};

use chrono::{DateTime, Local};
use serde::{Deserialize, Serialize};


#[cfg(feature = "typescript")]
use ts_rs::TS;

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
pub struct ArchiveAuthorsList(pub Vec<ArchiveAuthorsItem>);

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
pub struct ArchiveAuthorsItem {
    pub id: String,
    pub name: String,
    #[cfg_attr(feature = "typescript", ts(optional))]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumb: Option<PathBuf>,
    pub from: HashSet<ArchiveFrom>,
}

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ArchiveAuthor {
    pub id: String,
    pub name: String,
    pub from: HashSet<ArchiveFrom>,
    pub posts: Vec<ArchivePostShort>,
    #[cfg_attr(feature = "typescript", ts(optional))]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumb: Option<PathBuf>,
}

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, Hash)]
#[serde(rename_all = "camelCase")]
pub struct ArchivePost {
    pub id: String,
    pub title: String,
    pub author: String,
    pub from: ArchiveFrom,
    pub thumb: Option<PathBuf>,
    pub files: Vec<ArchiveFile>,
    pub updated: DateTime<Local>,
    pub published: DateTime<Local>,
    pub content: Vec<ArchiveContent>,
    pub comments: Vec<ArchiveComment>,
}

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ArchivePostShort {
    pub id: String,
    pub url: PathBuf,
    pub title: String,
    pub author: String,
    pub from: ArchiveFrom,
    pub thumb: Option<PathBuf>,
    pub updated: DateTime<Local>,
}

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, Hash, PartialEq, Eq)]
#[serde(rename_all = "camelCase", tag = "type")]
pub enum ArchiveFile {
    Image {
        width: u32,
        height: u32,
        filename: PathBuf,
        path: PathBuf,
    },
    Video {
        filename: PathBuf,
        path: PathBuf,
    },
    File {
        filename: PathBuf,
        path: PathBuf,
    },
}

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, Hash, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum ArchiveFrom {
    Fanbox,
}

//MarkDown
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))] 
#[derive(Deserialize, Serialize, Debug, Clone, Hash)]
#[serde(rename_all = "camelCase")]
pub enum ArchiveContent {
    Text(String),
    Image(String),
    Video(String),
    File(String),
}

#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, Hash)]
#[serde(rename_all = "camelCase")]
pub struct ArchiveComment {
    pub user: String,
    pub text: String,
    #[cfg_attr(feature = "typescript", ts(as = "Option<Vec<ArchiveComment>>", optional))]
    #[serde(skip_serializing_if = "<[_]>::is_empty")]
    pub replies: Vec<ArchiveComment>,
}