refactor(repo): remove extras types (inlined)
zhenyi committed
Deleted lib/repo/features/extras/types.rs lib/repo/features/extras/types.rs +0 −306
@@ -1,306 +0,0 @@
1use serde::{Deserialize, Serialize};
2use time::OffsetDateTime;
3use time::format_description::well_known::Rfc3339;
4use utoipa::{IntoParams, ToSchema};
5use uuid::Uuid;
6
7fn fmt_ts(ts: OffsetDateTime) -> String {
8 ts.format(&Rfc3339).unwrap_or_default()
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
12pub struct SearchResults {
13 pub data: Vec<RepoSummary>,
14 pub ok: bool,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
18pub struct RepoSummary {
19 pub id: Uuid,
20 pub name: String,
21 pub full_name: String,
22 pub description: Option<String>,
23 pub empty: bool,
24 pub private: bool,
25 pub fork: bool,
26 pub template: bool,
27 pub mirror: bool,
28 pub size: i64,
29 pub stars_count: i32,
30 pub forks_count: i32,
31 pub watchers_count: i32,
32 pub open_issues_count: i32,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
36pub struct RepoSearchQuery {
37 pub q: Option<String>,
38 pub topic: Option<bool>,
39 pub include_desc: Option<bool>,
40 pub uid: Option<Uuid>,
41 pub priority_owner_id: Option<Uuid>,
42 pub team_id: Option<i64>,
43 pub starred_by: Option<Uuid>,
44 pub private: Option<bool>,
45 pub is_private: Option<bool>,
46 pub template: Option<bool>,
47 pub archived: Option<bool>,
48 pub mode: Option<String>,
49 pub exclusive: Option<bool>,
50 pub sort: Option<String>,
51 pub order: Option<String>,
52 pub page: Option<u64>,
53 pub limit: Option<u64>,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
57pub struct UpdateAvatarOption {
58 pub image: String,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
62pub struct IssueTemplate {
63 pub name: String,
64 pub title: String,
65 pub description: Option<String>,
66 pub content: String,
67 pub fields: Vec<IssueTemplateField>,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
71pub struct IssueTemplateField {
72 pub type_: String,
73 pub id: String,
74 pub name: String,
75 pub description: Option<String>,
76 pub required: Option<bool>,
77 pub validations: Option<serde_json::Value>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
81pub struct IssueConfig {
82 pub blank_issues_enabled: bool,
83 pub contact_links: Option<serde_json::Value>,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
87pub struct IssueConfigValidation {
88 pub valid: bool,
89 pub message: Option<String>,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
93pub struct LanguageStat {
94 pub language: String,
95 pub size: i64,
96 pub percentage: f64,
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
100pub struct LanguagesResponse {
101 pub languages: std::collections::BTreeMap<String, i64>,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
105pub struct LicensesResponse {
106 pub licenses: Vec<String>,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
110pub struct UserMini {
111 pub id: Uuid,
112 pub login: String,
113 pub full_name: Option<String>,
114 pub email: Option<String>,
115 pub avatar_url: Option<String>,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
119pub struct AssigneesResponse {
120 pub items: Vec<UserMini>,
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
124pub struct ReviewersResponse {
125 pub items: Vec<UserMini>,
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
129pub struct NewPinAllowedResponse {
130 pub allowed: bool,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
134pub struct GetFilesRequest {
135 pub files: Vec<String>,
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
139pub struct CommitSummary {
140 pub sha: String,
141 pub message: String,
142 pub author: Option<UserMini>,
143 pub committer: Option<UserMini>,
144 pub parent_shas: Vec<String>,
145 pub tree_sha: String,
146 pub authored_at: Option<String>,
147 pub committed_at: Option<String>,
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
151pub struct CommitsResponse {
152 pub items: Vec<CommitSummary>,
153 pub total: i64,
154}
155
156#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
157pub struct CommitsQuery {
158 pub sha: Option<String>,
159 pub path: Option<String>,
160 pub since: Option<String>,
161 pub until: Option<String>,
162 pub stat: Option<bool>,
163 pub verification: Option<bool>,
164 pub files: Option<bool>,
165 pub not: Option<String>,
166 pub page: Option<u64>,
167 pub limit: Option<u64>,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
171pub struct FileDeleteResponse {
172 pub commit: Option<CommitSummary>,
173 pub content: Option<serde_json::Value>,
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
177pub struct CommitComparison {
178 pub total_commits: i64,
179 pub commits: Vec<CommitSummary>,
180 pub base_sha: Option<String>,
181 pub head_sha: Option<String>,
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
185pub struct GitRef {
186 pub name: String,
187 pub sha: String,
188 pub type_: String,
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
192pub struct GitTreeEntry {
193 pub path: String,
194 pub mode: String,
195 pub type_: String,
196 pub sha: String,
197 pub size: Option<i64>,
198 pub url: String,
199}
200
201#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
202pub struct GitTreeResponse {
203 pub sha: String,
204 pub url: String,
205 pub tree: Vec<GitTreeEntry>,
206 pub truncated: bool,
207 pub page: i64,
208 pub total_count: i64,
209}
210
211#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
212pub struct TreeQuery {
213 pub recursive: Option<bool>,
214 pub page: Option<u64>,
215 pub per_page: Option<u64>,
216}
217
218#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
219pub struct GitBlobResponse {
220 pub content: Option<String>,
221 pub encoding: Option<String>,
222 pub url: String,
223 pub sha: String,
224 pub size: i64,
225 pub lfs_oid: Option<String>,
226 pub lfs_size: Option<i64>,
227}
228
229#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
230pub struct GitNote {
231 pub message: String,
232 pub commit: CommitSummary,
233 pub verification: Option<serde_json::Value>,
234}
235
236#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
237pub struct ForkView {
238 pub id: Uuid,
239 pub name: String,
240 pub full_name: String,
241 pub owner: UserMini,
242 pub private: bool,
243 pub fork: bool,
244 pub created_at: String,
245 pub updated_at: String,
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
249pub struct ForksResponse {
250 pub items: Vec<ForkView>,
251 pub total: i64,
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
255pub struct ForksQuery {
256 pub page: Option<u64>,
257 pub limit: Option<u64>,
258}
259
260#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
261pub struct CreateForkOption {
262 pub name: Option<String>,
263 pub description: Option<String>,
264}
265
266#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
267pub struct Subscription {
268 pub user_id: Uuid,
269 pub repo_id: Uuid,
270 pub mode: String,
271 pub created_at: String,
272}
273
274#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
275pub struct ReleaseAttachmentView {
276 pub id: Uuid,
277 pub name: String,
278 pub size: i64,
279 pub download_url: String,
280 pub created_at: String,
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
284pub struct ReleaseAttachmentListResponse {
285 pub items: Vec<ReleaseAttachmentView>,
286}
287
288#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
289pub struct EditAttachmentOptions {
290 pub name: String,
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
294pub struct SubscriptionMode {
295 pub mode: String,
296}
297
298#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, IntoParams)]
299pub struct SubscriptionQuery {
300 pub mode: Option<String>,
301}
302
303#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
304pub struct SubscriptionCount {
305 pub count: i64,
306}