]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Squashed commit of the following:
[lemmy.git] / ui / src / interfaces.ts
1 export enum UserOperation {
2   Login, Register, CreateCommunity, CreatePost, ListCommunities, ListCategories, GetPost, GetCommunity, CreateComment, EditComment, SaveComment, CreateCommentLike, GetPosts, CreatePostLike, EditPost, SavePost, EditCommunity, FollowCommunity, GetFollowedCommunities, GetUserDetails, GetReplies, GetModlog, BanFromCommunity, AddModToCommunity, CreateSite, EditSite, GetSite, AddAdmin, BanUser, Search, MarkAllAsRead, SaveUserSettings
3 }
4
5 export enum CommentSortType {
6   Hot, Top, New
7 }
8
9 export enum ListingType {
10   All, Subscribed, Community
11 }
12
13 export enum SortType {
14   Hot, New, TopDay, TopWeek, TopMonth, TopYear, TopAll
15 }
16
17 export enum SearchType {
18   All, Comments, Posts, Communities, Users
19 }
20
21 export interface User {
22   id: number;
23   iss: string;
24   username: string;
25   show_nsfw: boolean;
26 }
27
28 export interface UserView {
29   id: number;
30   name: string;
31   fedi_name: string;
32   published: string;
33   number_of_posts: number;
34   post_score: number;
35   number_of_comments: number;
36   comment_score: number;
37 }
38
39 export interface CommunityUser {
40   id: number;
41   user_id: number;
42   user_name: string;
43   community_id: number;
44   community_name: string;
45   published: string;
46 }
47
48 export interface Community {
49   id: number;
50   name: string;
51   title: string;
52   description?: string;
53   category_id: number;
54   creator_id: number;
55   removed: boolean;
56   deleted: boolean;
57   nsfw: boolean;
58   published: string;
59   updated?: string;
60   creator_name: string;
61   category_name: string;
62   number_of_subscribers: number;
63   number_of_posts: number;
64   number_of_comments: number;
65   user_id?: number;
66   subscribed?: boolean;
67 }
68
69 export interface Post {
70   id: number;
71   name: string;
72   url?: string;
73   body?: string;
74   creator_id: number;
75   community_id: number;
76   removed: boolean;
77   deleted: boolean;
78   locked: boolean;
79   nsfw: boolean;
80   published: string;
81   updated?: string;
82   creator_name: string;
83   community_name: string;
84   community_removed: boolean;
85   community_deleted: boolean;
86   community_nsfw: boolean;
87   number_of_comments: number;
88   score: number;
89   upvotes: number;
90   downvotes: number;
91   hot_rank: number;
92   user_id?: number;
93   my_vote?: number;
94   subscribed?: boolean;
95   read?: boolean;
96   saved?: boolean;
97 }
98
99 export interface Comment {
100   id: number;
101   creator_id: number;
102   post_id: number,
103   parent_id?: number;
104   content: string;
105   removed: boolean;
106   deleted: boolean;
107   read: boolean;
108   published: string;
109   updated?: string;
110   community_id: number,
111   banned: boolean;
112   banned_from_community: boolean;
113   creator_name: string;
114   score: number;
115   upvotes: number;
116   downvotes: number;
117   user_id?: number;
118   my_vote?: number;
119   saved?: boolean;
120 }
121
122 export interface Category {
123   id: number;
124   name: string;
125 }
126
127 export interface Site {
128   id: number;
129   name: string;
130   description?: string;
131   creator_id: number;
132   published: string;
133   updated?: string;
134   creator_name: string;
135   number_of_users: number;
136   number_of_posts: number;
137   number_of_comments: number;
138 }
139
140 export interface FollowCommunityForm {
141   community_id: number;
142   follow: boolean;
143   auth?: string;
144 }
145
146 export interface GetFollowedCommunitiesResponse {
147   op: string;
148   communities: Array<CommunityUser>;
149 }
150
151 export interface GetUserDetailsForm {
152   user_id?: number;
153   username?: string;
154   sort: string;
155   page?: number;
156   limit?: number;
157   community_id?: number;
158   saved_only: boolean;
159 }
160
161 export interface UserDetailsResponse {
162   op: string;
163   user: UserView;
164   follows: Array<CommunityUser>;
165   moderates: Array<CommunityUser>;
166   comments: Array<Comment>;
167   posts: Array<Post>;
168 }
169
170 export interface GetRepliesForm {
171   sort: string; // TODO figure this one out
172   page?: number;
173   limit?: number;
174   unread_only: boolean;
175   auth?: string;
176 }
177
178 export interface GetRepliesResponse {
179   op: string;
180   replies: Array<Comment>;
181 }
182
183 export interface BanFromCommunityForm {
184   community_id: number;
185   user_id: number;
186   ban: boolean;
187   reason?: string,
188   expires?: number,
189   auth?: string;
190 }
191
192 export interface BanFromCommunityResponse {
193   op: string;
194   user: UserView,
195   banned: boolean,
196 }
197
198 export interface AddModToCommunityForm {
199   community_id: number;
200   user_id: number;
201   added: boolean;
202   auth?: string;
203 }
204
205 export interface AddModToCommunityResponse {
206   op: string;
207   moderators: Array<CommunityUser>;
208 }
209
210 export interface GetModlogForm {
211   mod_user_id?: number;
212   community_id?: number;
213   page?: number;
214   limit?: number;
215 }
216
217 export interface GetModlogResponse {
218   op: string;
219   removed_posts: Array<ModRemovePost>,
220   locked_posts: Array<ModLockPost>,
221   removed_comments: Array<ModRemoveComment>,
222   removed_communities: Array<ModRemoveCommunity>,
223   banned_from_community: Array<ModBanFromCommunity>,
224   banned: Array<ModBan>,
225   added_to_community: Array<ModAddCommunity>,
226   added: Array<ModAdd>,
227 }
228
229 export interface ModRemovePost {
230   id: number;
231   mod_user_id: number;
232   post_id: number;
233   reason?: string;
234   removed?: boolean;
235   when_: string
236   mod_user_name: string;
237   post_name: string;
238   community_id: number;
239   community_name: string;
240 }
241
242 export interface ModLockPost {
243   id: number,
244   mod_user_id: number,
245   post_id: number,
246   locked?: boolean,
247   when_: string,
248   mod_user_name: string,
249   post_name: string,
250   community_id: number,
251   community_name: string,
252 }
253
254 export interface ModRemoveComment {
255   id: number,
256   mod_user_id: number,
257   comment_id: number,
258   reason?: string,
259   removed?: boolean,
260   when_: string,
261   mod_user_name: string,
262   comment_user_id: number,
263   comment_user_name: string,
264   comment_content: string,
265   post_id: number,
266   post_name: string,
267   community_id: number,
268   community_name: string,
269 }
270
271 export interface ModRemoveCommunity {
272   id: number,
273   mod_user_id: number,
274   community_id: number,
275   reason?: string,
276   removed?: boolean,
277   expires?: number,
278   when_: string,
279   mod_user_name: string,
280   community_name: string,
281 }
282
283 export interface ModBanFromCommunity {
284   id: number,
285   mod_user_id: number,
286   other_user_id: number,
287   community_id: number,
288   reason?: string,
289   banned?: boolean,
290   expires?: number,
291   when_: string,
292   mod_user_name: string,
293   other_user_name: string,
294   community_name: string,
295 }
296
297 export interface ModBan {
298   id: number,
299   mod_user_id: number,
300   other_user_id: number,
301   reason?: string,
302   banned?: boolean,
303   expires?: number,
304   when_: string,
305   mod_user_name: string,
306   other_user_name: string,
307 }
308
309 export interface ModAddCommunity {
310   id: number,
311   mod_user_id: number,
312   other_user_id: number,
313   community_id: number,
314   removed?: boolean,
315   when_: string,
316   mod_user_name: string,
317   other_user_name: string,
318   community_name: string,
319 }
320
321 export interface ModAdd {
322   id: number,
323   mod_user_id: number,
324   other_user_id: number,
325   removed?: boolean,
326   when_: string,
327   mod_user_name: string,
328   other_user_name: string,
329 }
330
331 export interface LoginForm {
332   username_or_email: string;
333   password: string;
334 }
335
336 export interface RegisterForm {
337   username: string;
338   email?: string;
339   password: string;
340   password_verify: string;
341   admin: boolean;
342   show_nsfw: boolean;
343 }
344
345 export interface LoginResponse {
346   op: string;
347   jwt: string;
348 }
349
350 export interface UserSettingsForm {
351   show_nsfw: boolean;
352   auth: string;
353 }
354
355 export interface CommunityForm {
356   name: string;
357   title: string;
358   description?: string,
359   category_id: number,
360   edit_id?: number;
361   removed?: boolean;
362   deleted?: boolean;
363   nsfw: boolean;
364   reason?: string;
365   expires?: number;
366   auth?: string;
367 }
368
369 export interface GetCommunityResponse {
370   op: string;
371   community: Community;
372   moderators: Array<CommunityUser>;
373   admins: Array<UserView>;
374 }
375
376
377 export interface CommunityResponse {
378   op: string;
379   community: Community;
380 }
381
382 export interface ListCommunitiesForm {
383   sort: string;
384   page?: number;
385   limit?: number;
386   auth?: string;
387 }
388
389 export interface ListCommunitiesResponse {
390   op: string;
391   communities: Array<Community>;
392 }
393
394 export interface ListCategoriesResponse {
395   op: string;
396   categories: Array<Category>;
397 }
398
399 export interface PostForm {
400   name: string;
401   url?: string;
402   body?: string;
403   community_id: number;
404   updated?: number;
405   edit_id?: number;
406   creator_id: number;
407   removed?: boolean;
408   deleted?: boolean;
409   nsfw: boolean;
410   locked?: boolean;
411   reason?: string;
412   auth: string;
413 }
414
415 export interface GetPostResponse {
416   op: string;
417   post: Post;
418   comments: Array<Comment>;
419   community: Community;
420   moderators: Array<CommunityUser>;
421   admins: Array<UserView>;
422 }
423
424 export interface SavePostForm {
425   post_id: number;
426   save: boolean;
427   auth?: string;
428 }
429
430 export interface PostResponse {
431   op: string;
432   post: Post;
433 }
434
435 export interface CommentForm {
436   content: string;
437   post_id: number;
438   parent_id?: number;
439   edit_id?: number;
440   creator_id: number;
441   removed?: boolean;
442   deleted?: boolean;
443   reason?: string;
444   read?: boolean;
445   auth: string;
446 }
447
448 export interface SaveCommentForm {
449   comment_id: number;
450   save: boolean;
451   auth?: string;
452 }
453
454 export interface CommentResponse {
455   op: string;
456   comment: Comment;
457 }
458
459 export interface CommentLikeForm {
460   comment_id: number;
461   post_id: number;
462   score: number;
463   auth?: string;
464 }
465
466 export interface CommentNode {
467   comment: Comment;
468   children?: Array<CommentNode>;
469 }
470
471 export interface GetPostsForm {
472   type_: string;
473   sort: string;
474   page?: number;
475   limit?: number;
476   community_id?: number;
477   auth?: string;
478 }
479
480 export interface GetPostsResponse {
481   op: string;
482   posts: Array<Post>;
483 }
484
485 export interface CreatePostLikeForm {
486   post_id: number;
487   score: number;
488   auth?: string;
489 }
490
491 export interface CreatePostLikeResponse {
492   op: string;
493   post: Post;
494 }
495
496 export interface SiteForm {
497   name: string;
498   description?: string,
499   removed?: boolean;
500   reason?: string;
501   expires?: number;
502   auth?: string;
503 }
504
505 export interface GetSiteResponse {
506   op: string;
507   site: Site;
508   admins: Array<UserView>;
509   banned: Array<UserView>;
510 }
511
512
513 export interface SiteResponse {
514   op: string;
515   site: Site;
516 }
517
518 export interface BanUserForm {
519   user_id: number;
520   ban: boolean;
521   reason?: string,
522   expires?: number,
523   auth?: string;
524 }
525
526 export interface BanUserResponse {
527   op: string;
528   user: UserView,
529   banned: boolean,
530 }
531
532 export interface AddAdminForm {
533   user_id: number;
534   added: boolean;
535   auth?: string;
536 }
537
538 export interface AddAdminResponse {
539   op: string;
540   admins: Array<UserView>;
541 }
542
543 export interface SearchForm {
544   q: string;
545   type_: string;
546   community_id?: number;
547   sort: string;
548   page?: number;
549   limit?: number;
550 }
551
552 export interface SearchResponse {
553   op: string;
554   posts?: Array<Post>;
555   comments?: Array<Comment>;
556   communities: Array<Community>;  
557   users: Array<UserView>;
558 }