]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Adding comment and post vote loading indicators. Fixes #449
[lemmy.git] / ui / src / interfaces.ts
1 export enum UserOperation {
2   Login,
3   Register,
4   CreateCommunity,
5   CreatePost,
6   ListCommunities,
7   ListCategories,
8   GetPost,
9   GetCommunity,
10   CreateComment,
11   EditComment,
12   SaveComment,
13   CreateCommentLike,
14   GetPosts,
15   CreatePostLike,
16   EditPost,
17   SavePost,
18   EditCommunity,
19   FollowCommunity,
20   GetFollowedCommunities,
21   GetUserDetails,
22   GetReplies,
23   GetUserMentions,
24   EditUserMention,
25   GetModlog,
26   BanFromCommunity,
27   AddModToCommunity,
28   CreateSite,
29   EditSite,
30   GetSite,
31   AddAdmin,
32   BanUser,
33   Search,
34   MarkAllAsRead,
35   SaveUserSettings,
36   TransferCommunity,
37   TransferSite,
38   DeleteAccount,
39   PasswordReset,
40   PasswordChange,
41 }
42
43 export enum CommentSortType {
44   Hot,
45   Top,
46   New,
47 }
48
49 export enum ListingType {
50   All,
51   Subscribed,
52   Community,
53 }
54
55 export enum SortType {
56   Hot,
57   New,
58   TopDay,
59   TopWeek,
60   TopMonth,
61   TopYear,
62   TopAll,
63 }
64
65 export enum SearchType {
66   All,
67   Comments,
68   Posts,
69   Communities,
70   Users,
71   Url,
72 }
73
74 export interface User {
75   id: number;
76   iss: string;
77   username: string;
78   show_nsfw: boolean;
79   theme: string;
80   default_sort_type: SortType;
81   default_listing_type: ListingType;
82   lang: string;
83   avatar?: string;
84   show_avatars: boolean;
85 }
86
87 export interface UserView {
88   id: number;
89   name: string;
90   avatar?: string;
91   email?: string;
92   fedi_name: string;
93   published: string;
94   number_of_posts: number;
95   post_score: number;
96   number_of_comments: number;
97   comment_score: number;
98   banned: boolean;
99   show_avatars: boolean;
100   send_notifications_to_email: boolean;
101 }
102
103 export interface CommunityUser {
104   id: number;
105   user_id: number;
106   user_name: string;
107   avatar?: string;
108   community_id: number;
109   community_name: string;
110   published: string;
111 }
112
113 export interface Community {
114   id: number;
115   name: string;
116   title: string;
117   description?: string;
118   category_id: number;
119   creator_id: number;
120   removed: boolean;
121   deleted: boolean;
122   nsfw: boolean;
123   published: string;
124   updated?: string;
125   creator_name: string;
126   creator_avatar?: string;
127   category_name: string;
128   number_of_subscribers: number;
129   number_of_posts: number;
130   number_of_comments: number;
131   user_id?: number;
132   subscribed?: boolean;
133 }
134
135 export interface Post {
136   id: number;
137   name: string;
138   url?: string;
139   body?: string;
140   creator_id: number;
141   community_id: number;
142   removed: boolean;
143   deleted: boolean;
144   locked: boolean;
145   stickied: boolean;
146   nsfw: boolean;
147   banned: boolean;
148   banned_from_community: boolean;
149   published: string;
150   updated?: string;
151   creator_name: string;
152   creator_avatar?: string;
153   community_name: string;
154   community_removed: boolean;
155   community_deleted: boolean;
156   community_nsfw: boolean;
157   number_of_comments: number;
158   score: number;
159   upvotes: number;
160   downvotes: number;
161   hot_rank: number;
162   user_id?: number;
163   my_vote?: number;
164   subscribed?: boolean;
165   read?: boolean;
166   saved?: boolean;
167   upvoteLoading?: boolean;
168   downvoteLoading?: boolean;
169 }
170
171 export interface Comment {
172   id: number;
173   creator_id: number;
174   post_id: number;
175   parent_id?: number;
176   content: string;
177   removed: boolean;
178   deleted: boolean;
179   read: boolean;
180   published: string;
181   updated?: string;
182   community_id: number;
183   banned: boolean;
184   banned_from_community: boolean;
185   creator_name: string;
186   creator_avatar?: string;
187   score: number;
188   upvotes: number;
189   downvotes: number;
190   user_id?: number;
191   my_vote?: number;
192   saved?: boolean;
193   user_mention_id?: number; // For mention type
194   recipient_id?: number;
195   upvoteLoading?: boolean;
196   downvoteLoading?: boolean;
197 }
198
199 export interface Category {
200   id: number;
201   name: string;
202 }
203
204 export interface Site {
205   id: number;
206   name: string;
207   description?: string;
208   creator_id: number;
209   published: string;
210   updated?: string;
211   creator_name: string;
212   number_of_users: number;
213   number_of_posts: number;
214   number_of_comments: number;
215   number_of_communities: number;
216   enable_downvotes: boolean;
217   open_registration: boolean;
218   enable_nsfw: boolean;
219 }
220
221 export enum BanType {
222   Community,
223   Site,
224 }
225
226 export interface FollowCommunityForm {
227   community_id: number;
228   follow: boolean;
229   auth?: string;
230 }
231
232 export interface GetFollowedCommunitiesResponse {
233   op: string;
234   communities: Array<CommunityUser>;
235 }
236
237 export interface GetUserDetailsForm {
238   user_id?: number;
239   username?: string;
240   sort: string;
241   page?: number;
242   limit?: number;
243   community_id?: number;
244   saved_only: boolean;
245 }
246
247 export interface UserDetailsResponse {
248   op: string;
249   user: UserView;
250   follows: Array<CommunityUser>;
251   moderates: Array<CommunityUser>;
252   comments: Array<Comment>;
253   posts: Array<Post>;
254   admins: Array<UserView>;
255 }
256
257 export interface GetRepliesForm {
258   sort: string;
259   page?: number;
260   limit?: number;
261   unread_only: boolean;
262   auth?: string;
263 }
264
265 export interface GetRepliesResponse {
266   op: string;
267   replies: Array<Comment>;
268 }
269
270 export interface GetUserMentionsForm {
271   sort: string;
272   page?: number;
273   limit?: number;
274   unread_only: boolean;
275   auth?: string;
276 }
277
278 export interface GetUserMentionsResponse {
279   op: string;
280   mentions: Array<Comment>;
281 }
282
283 export interface EditUserMentionForm {
284   user_mention_id: number;
285   read?: boolean;
286   auth?: string;
287 }
288
289 export interface UserMentionResponse {
290   op: string;
291   mention: Comment;
292 }
293
294 export interface BanFromCommunityForm {
295   community_id: number;
296   user_id: number;
297   ban: boolean;
298   reason?: string;
299   expires?: number;
300   auth?: string;
301 }
302
303 export interface BanFromCommunityResponse {
304   op: string;
305   user: UserView;
306   banned: boolean;
307 }
308
309 export interface AddModToCommunityForm {
310   community_id: number;
311   user_id: number;
312   added: boolean;
313   auth?: string;
314 }
315
316 export interface TransferCommunityForm {
317   community_id: number;
318   user_id: number;
319   auth?: string;
320 }
321
322 export interface TransferSiteForm {
323   user_id: number;
324   auth?: string;
325 }
326
327 export interface AddModToCommunityResponse {
328   op: string;
329   moderators: Array<CommunityUser>;
330 }
331
332 export interface GetModlogForm {
333   mod_user_id?: number;
334   community_id?: number;
335   page?: number;
336   limit?: number;
337 }
338
339 export interface GetModlogResponse {
340   op: string;
341   removed_posts: Array<ModRemovePost>;
342   locked_posts: Array<ModLockPost>;
343   stickied_posts: Array<ModStickyPost>;
344   removed_comments: Array<ModRemoveComment>;
345   removed_communities: Array<ModRemoveCommunity>;
346   banned_from_community: Array<ModBanFromCommunity>;
347   banned: Array<ModBan>;
348   added_to_community: Array<ModAddCommunity>;
349   added: Array<ModAdd>;
350 }
351
352 export interface ModRemovePost {
353   id: number;
354   mod_user_id: number;
355   post_id: number;
356   reason?: string;
357   removed?: boolean;
358   when_: string;
359   mod_user_name: string;
360   post_name: string;
361   community_id: number;
362   community_name: string;
363 }
364
365 export interface ModLockPost {
366   id: number;
367   mod_user_id: number;
368   post_id: number;
369   locked?: boolean;
370   when_: string;
371   mod_user_name: string;
372   post_name: string;
373   community_id: number;
374   community_name: string;
375 }
376
377 export interface ModStickyPost {
378   id: number;
379   mod_user_id: number;
380   post_id: number;
381   stickied?: boolean;
382   when_: string;
383   mod_user_name: string;
384   post_name: string;
385   community_id: number;
386   community_name: string;
387 }
388
389 export interface ModRemoveComment {
390   id: number;
391   mod_user_id: number;
392   comment_id: number;
393   reason?: string;
394   removed?: boolean;
395   when_: string;
396   mod_user_name: string;
397   comment_user_id: number;
398   comment_user_name: string;
399   comment_content: string;
400   post_id: number;
401   post_name: string;
402   community_id: number;
403   community_name: string;
404 }
405
406 export interface ModRemoveCommunity {
407   id: number;
408   mod_user_id: number;
409   community_id: number;
410   reason?: string;
411   removed?: boolean;
412   expires?: number;
413   when_: string;
414   mod_user_name: string;
415   community_name: string;
416 }
417
418 export interface ModBanFromCommunity {
419   id: number;
420   mod_user_id: number;
421   other_user_id: number;
422   community_id: number;
423   reason?: string;
424   banned?: boolean;
425   expires?: number;
426   when_: string;
427   mod_user_name: string;
428   other_user_name: string;
429   community_name: string;
430 }
431
432 export interface ModBan {
433   id: number;
434   mod_user_id: number;
435   other_user_id: number;
436   reason?: string;
437   banned?: boolean;
438   expires?: number;
439   when_: string;
440   mod_user_name: string;
441   other_user_name: string;
442 }
443
444 export interface ModAddCommunity {
445   id: number;
446   mod_user_id: number;
447   other_user_id: number;
448   community_id: number;
449   removed?: boolean;
450   when_: string;
451   mod_user_name: string;
452   other_user_name: string;
453   community_name: string;
454 }
455
456 export interface ModAdd {
457   id: number;
458   mod_user_id: number;
459   other_user_id: number;
460   removed?: boolean;
461   when_: string;
462   mod_user_name: string;
463   other_user_name: string;
464 }
465
466 export interface LoginForm {
467   username_or_email: string;
468   password: string;
469 }
470
471 export interface RegisterForm {
472   username: string;
473   email?: string;
474   password: string;
475   password_verify: string;
476   admin: boolean;
477   show_nsfw: boolean;
478 }
479
480 export interface LoginResponse {
481   op: string;
482   jwt: string;
483 }
484
485 export interface UserSettingsForm {
486   show_nsfw: boolean;
487   theme: string;
488   default_sort_type: SortType;
489   default_listing_type: ListingType;
490   lang: string;
491   avatar?: string;
492   email?: string;
493   new_password?: string;
494   new_password_verify?: string;
495   old_password?: string;
496   show_avatars: boolean;
497   send_notifications_to_email: boolean;
498   auth: string;
499 }
500
501 export interface CommunityForm {
502   name: string;
503   title: string;
504   description?: string;
505   category_id: number;
506   edit_id?: number;
507   removed?: boolean;
508   deleted?: boolean;
509   nsfw: boolean;
510   reason?: string;
511   expires?: number;
512   auth?: string;
513 }
514
515 export interface GetCommunityResponse {
516   op: string;
517   community: Community;
518   moderators: Array<CommunityUser>;
519   admins: Array<UserView>;
520 }
521
522 export interface CommunityResponse {
523   op: string;
524   community: Community;
525 }
526
527 export interface ListCommunitiesForm {
528   sort: string;
529   page?: number;
530   limit?: number;
531   auth?: string;
532 }
533
534 export interface ListCommunitiesResponse {
535   op: string;
536   communities: Array<Community>;
537 }
538
539 export interface ListCategoriesResponse {
540   op: string;
541   categories: Array<Category>;
542 }
543
544 export interface PostForm {
545   name: string;
546   url?: string;
547   body?: string;
548   community_id: number;
549   updated?: number;
550   edit_id?: number;
551   creator_id: number;
552   removed?: boolean;
553   deleted?: boolean;
554   nsfw: boolean;
555   locked?: boolean;
556   stickied?: boolean;
557   reason?: string;
558   auth: string;
559 }
560
561 export interface PostFormParams {
562   name: string;
563   url?: string;
564   body?: string;
565   community?: string;
566 }
567
568 export interface GetPostResponse {
569   op: string;
570   post: Post;
571   comments: Array<Comment>;
572   community: Community;
573   moderators: Array<CommunityUser>;
574   admins: Array<UserView>;
575 }
576
577 export interface SavePostForm {
578   post_id: number;
579   save: boolean;
580   auth?: string;
581 }
582
583 export interface PostResponse {
584   op: string;
585   post: Post;
586 }
587
588 export interface CommentForm {
589   content: string;
590   post_id: number;
591   parent_id?: number;
592   edit_id?: number;
593   creator_id: number;
594   removed?: boolean;
595   deleted?: boolean;
596   reason?: string;
597   read?: boolean;
598   auth: string;
599 }
600
601 export interface SaveCommentForm {
602   comment_id: number;
603   save: boolean;
604   auth?: string;
605 }
606
607 export interface CommentResponse {
608   op: string;
609   comment: Comment;
610 }
611
612 export interface CommentLikeForm {
613   comment_id: number;
614   post_id: number;
615   score: number;
616   auth?: string;
617 }
618
619 export interface CommentNode {
620   comment: Comment;
621   children?: Array<CommentNode>;
622 }
623
624 export interface GetPostsForm {
625   type_: string;
626   sort: string;
627   page?: number;
628   limit?: number;
629   community_id?: number;
630   auth?: string;
631 }
632
633 export interface GetPostsResponse {
634   op: string;
635   posts: Array<Post>;
636 }
637
638 export interface CreatePostLikeForm {
639   post_id: number;
640   score: number;
641   auth?: string;
642 }
643
644 export interface CreatePostLikeResponse {
645   op: string;
646   post: Post;
647 }
648
649 export interface SiteForm {
650   name: string;
651   description?: string;
652   enable_downvotes: boolean;
653   open_registration: boolean;
654   enable_nsfw: boolean;
655   auth?: string;
656 }
657
658 export interface GetSiteResponse {
659   op: string;
660   site: Site;
661   admins: Array<UserView>;
662   banned: Array<UserView>;
663   online: number;
664 }
665
666 export interface SiteResponse {
667   op: string;
668   site: Site;
669 }
670
671 export interface BanUserForm {
672   user_id: number;
673   ban: boolean;
674   reason?: string;
675   expires?: number;
676   auth?: string;
677 }
678
679 export interface BanUserResponse {
680   op: string;
681   user: UserView;
682   banned: boolean;
683 }
684
685 export interface AddAdminForm {
686   user_id: number;
687   added: boolean;
688   auth?: string;
689 }
690
691 export interface AddAdminResponse {
692   op: string;
693   admins: Array<UserView>;
694 }
695
696 export interface SearchForm {
697   q: string;
698   type_: string;
699   community_id?: number;
700   sort: string;
701   page?: number;
702   limit?: number;
703 }
704
705 export interface SearchResponse {
706   op: string;
707   type_: string;
708   posts?: Array<Post>;
709   comments?: Array<Comment>;
710   communities: Array<Community>;
711   users: Array<UserView>;
712 }
713
714 export interface DeleteAccountForm {
715   password: string;
716 }
717
718 export interface PasswordResetForm {
719   email: string;
720 }
721
722 export interface PasswordResetResponse {
723   op: string;
724 }
725
726 export interface PasswordChangeForm {
727   token: string;
728   password: string;
729   password_verify: string;
730 }