]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Merge branch 'main' into front_end_prettying
[lemmy.git] / ui / src / interfaces.ts
1 export enum UserOperation {
2   Login,
3   Register,
4   GetCaptcha,
5   CreateCommunity,
6   CreatePost,
7   ListCommunities,
8   ListCategories,
9   GetPost,
10   GetCommunity,
11   CreateComment,
12   EditComment,
13   DeleteComment,
14   RemoveComment,
15   MarkCommentAsRead,
16   SaveComment,
17   CreateCommentLike,
18   GetPosts,
19   CreatePostLike,
20   EditPost,
21   DeletePost,
22   RemovePost,
23   LockPost,
24   StickyPost,
25   SavePost,
26   EditCommunity,
27   DeleteCommunity,
28   RemoveCommunity,
29   FollowCommunity,
30   GetFollowedCommunities,
31   GetUserDetails,
32   GetReplies,
33   GetUserMentions,
34   MarkUserMentionAsRead,
35   GetModlog,
36   BanFromCommunity,
37   AddModToCommunity,
38   CreateSite,
39   EditSite,
40   GetSite,
41   AddAdmin,
42   BanUser,
43   Search,
44   MarkAllAsRead,
45   SaveUserSettings,
46   TransferCommunity,
47   TransferSite,
48   DeleteAccount,
49   PasswordReset,
50   PasswordChange,
51   CreatePrivateMessage,
52   EditPrivateMessage,
53   DeletePrivateMessage,
54   MarkPrivateMessageAsRead,
55   GetPrivateMessages,
56   UserJoin,
57   GetComments,
58   GetSiteConfig,
59   SaveSiteConfig,
60 }
61
62 export enum CommentSortType {
63   Hot,
64   Top,
65   New,
66   Old,
67 }
68
69 export enum CommentViewType {
70   Tree,
71   Chat,
72 }
73
74 export enum ListingType {
75   All,
76   Subscribed,
77   Community,
78 }
79
80 export enum DataType {
81   Post,
82   Comment,
83 }
84
85 export enum SortType {
86   Hot,
87   New,
88   TopDay,
89   TopWeek,
90   TopMonth,
91   TopYear,
92   TopAll,
93 }
94
95 export enum SearchType {
96   All,
97   Comments,
98   Posts,
99   Communities,
100   Users,
101   Url,
102 }
103
104 export interface Claims {
105   id: number;
106   iss: string;
107 }
108
109 export interface User {
110   id: number;
111   name: string;
112   preferred_username?: string;
113   email?: string;
114   avatar?: string;
115   admin: boolean;
116   banned: boolean;
117   published: string;
118   updated?: string;
119   show_nsfw: boolean;
120   theme: string;
121   default_sort_type: SortType;
122   default_listing_type: ListingType;
123   lang: string;
124   show_avatars: boolean;
125   send_notifications_to_email: boolean;
126   matrix_user_id?: string;
127   actor_id: string;
128   bio?: string;
129   local: boolean;
130   last_refreshed_at: string;
131 }
132
133 export interface UserView {
134   id: number;
135   actor_id: string;
136   name: string;
137   avatar?: string;
138   email?: string;
139   matrix_user_id?: string;
140   bio?: string;
141   local: boolean;
142   published: string;
143   number_of_posts: number;
144   post_score: number;
145   number_of_comments: number;
146   comment_score: number;
147   banned: boolean;
148   show_avatars: boolean;
149   send_notifications_to_email: boolean;
150 }
151
152 export interface CommunityUser {
153   id: number;
154   user_id: number;
155   user_actor_id: string;
156   user_local: boolean;
157   user_name: string;
158   avatar?: string;
159   community_id: number;
160   community_actor_id: string;
161   community_local: boolean;
162   community_name: string;
163   published: string;
164 }
165
166 export interface Community {
167   id: number;
168   actor_id: string;
169   local: boolean;
170   name: string;
171   title: string;
172   description?: string;
173   category_id: number;
174   creator_id: number;
175   removed: boolean;
176   deleted: boolean;
177   nsfw: boolean;
178   published: string;
179   updated?: string;
180   creator_actor_id: string;
181   creator_local: boolean;
182   last_refreshed_at: string;
183   creator_name: string;
184   creator_avatar?: string;
185   category_name: string;
186   number_of_subscribers: number;
187   number_of_posts: number;
188   number_of_comments: number;
189   user_id?: number;
190   subscribed?: boolean;
191 }
192
193 export interface Post {
194   id: number;
195   name: string;
196   url?: string;
197   body?: string;
198   creator_id: number;
199   community_id: number;
200   removed: boolean;
201   deleted: boolean;
202   locked: boolean;
203   stickied: boolean;
204   embed_title?: string;
205   embed_description?: string;
206   embed_html?: string;
207   thumbnail_url?: string;
208   ap_id: string;
209   local: boolean;
210   nsfw: boolean;
211   banned: boolean;
212   banned_from_community: boolean;
213   published: string;
214   updated?: string;
215   creator_actor_id: string;
216   creator_local: boolean;
217   creator_name: string;
218   creator_published: string;
219   creator_avatar?: string;
220   community_actor_id: string;
221   community_local: boolean;
222   community_name: string;
223   community_removed: boolean;
224   community_deleted: boolean;
225   community_nsfw: boolean;
226   number_of_comments: number;
227   score: number;
228   upvotes: number;
229   downvotes: number;
230   hot_rank: number;
231   newest_activity_time: string;
232   user_id?: number;
233   my_vote?: number;
234   subscribed?: boolean;
235   read?: boolean;
236   saved?: boolean;
237   duplicates?: Array<Post>;
238 }
239
240 export interface Comment {
241   id: number;
242   ap_id: string;
243   local: boolean;
244   creator_id: number;
245   post_id: number;
246   post_name: string;
247   parent_id?: number;
248   content: string;
249   removed: boolean;
250   deleted: boolean;
251   read: boolean;
252   published: string;
253   updated?: string;
254   community_id: number;
255   community_actor_id: string;
256   community_local: boolean;
257   community_name: string;
258   banned: boolean;
259   banned_from_community: boolean;
260   creator_actor_id: string;
261   creator_local: boolean;
262   creator_name: string;
263   creator_avatar?: string;
264   creator_published: string;
265   score: number;
266   upvotes: number;
267   downvotes: number;
268   hot_rank: number;
269   user_id?: number;
270   my_vote?: number;
271   subscribed?: number;
272   saved?: boolean;
273   user_mention_id?: number; // For mention type
274   recipient_id?: number;
275   recipient_actor_id?: string;
276   recipient_local?: boolean;
277   depth?: number;
278 }
279
280 export interface Category {
281   id: number;
282   name: string;
283 }
284
285 export interface Site {
286   id: number;
287   name: string;
288   description?: string;
289   creator_id: number;
290   published: string;
291   updated?: string;
292   creator_name: string;
293   number_of_users: number;
294   number_of_posts: number;
295   number_of_comments: number;
296   number_of_communities: number;
297   enable_downvotes: boolean;
298   open_registration: boolean;
299   enable_nsfw: boolean;
300 }
301
302 export interface PrivateMessage {
303   id: number;
304   creator_id: number;
305   recipient_id: number;
306   content: string;
307   deleted: boolean;
308   read: boolean;
309   published: string;
310   updated?: string;
311   ap_id: string;
312   local: boolean;
313   creator_name: string;
314   creator_avatar?: string;
315   creator_actor_id: string;
316   creator_local: boolean;
317   recipient_name: string;
318   recipient_avatar?: string;
319   recipient_actor_id: string;
320   recipient_local: boolean;
321 }
322
323 export enum BanType {
324   Community,
325   Site,
326 }
327
328 export interface FollowCommunityForm {
329   community_id: number;
330   follow: boolean;
331   auth?: string;
332 }
333
334 export interface GetFollowedCommunitiesForm {
335   auth: string;
336 }
337
338 export interface GetFollowedCommunitiesResponse {
339   communities: Array<CommunityUser>;
340 }
341
342 export interface GetUserDetailsForm {
343   user_id?: number;
344   username?: string;
345   sort: string;
346   page?: number;
347   limit?: number;
348   community_id?: number;
349   saved_only: boolean;
350 }
351
352 export interface UserDetailsResponse {
353   user: UserView;
354   follows: Array<CommunityUser>;
355   moderates: Array<CommunityUser>;
356   comments: Array<Comment>;
357   posts: Array<Post>;
358   admins: Array<UserView>;
359 }
360
361 export interface GetRepliesForm {
362   sort: string;
363   page?: number;
364   limit?: number;
365   unread_only: boolean;
366   auth?: string;
367 }
368
369 export interface GetRepliesResponse {
370   replies: Array<Comment>;
371 }
372
373 export interface GetUserMentionsForm {
374   sort: string;
375   page?: number;
376   limit?: number;
377   unread_only: boolean;
378   auth?: string;
379 }
380
381 export interface GetUserMentionsResponse {
382   mentions: Array<Comment>;
383 }
384
385 export interface MarkUserMentionAsReadForm {
386   user_mention_id: number;
387   read: boolean;
388   auth?: string;
389 }
390
391 export interface UserMentionResponse {
392   mention: Comment;
393 }
394
395 export interface BanFromCommunityForm {
396   community_id: number;
397   user_id: number;
398   ban: boolean;
399   reason?: string;
400   expires?: number;
401   auth?: string;
402 }
403
404 export interface BanFromCommunityResponse {
405   user: UserView;
406   banned: boolean;
407 }
408
409 export interface AddModToCommunityForm {
410   community_id: number;
411   user_id: number;
412   added: boolean;
413   auth?: string;
414 }
415
416 export interface TransferCommunityForm {
417   community_id: number;
418   user_id: number;
419   auth?: string;
420 }
421
422 export interface TransferSiteForm {
423   user_id: number;
424   auth?: string;
425 }
426
427 export interface AddModToCommunityResponse {
428   moderators: Array<CommunityUser>;
429 }
430
431 export interface GetModlogForm {
432   mod_user_id?: number;
433   community_id?: number;
434   page?: number;
435   limit?: number;
436 }
437
438 export interface GetModlogResponse {
439   removed_posts: Array<ModRemovePost>;
440   locked_posts: Array<ModLockPost>;
441   stickied_posts: Array<ModStickyPost>;
442   removed_comments: Array<ModRemoveComment>;
443   removed_communities: Array<ModRemoveCommunity>;
444   banned_from_community: Array<ModBanFromCommunity>;
445   banned: Array<ModBan>;
446   added_to_community: Array<ModAddCommunity>;
447   added: Array<ModAdd>;
448 }
449
450 export interface ModRemovePost {
451   id: number;
452   mod_user_id: number;
453   post_id: number;
454   reason?: string;
455   removed?: boolean;
456   when_: string;
457   mod_user_name: string;
458   post_name: string;
459   community_id: number;
460   community_name: string;
461 }
462
463 export interface ModLockPost {
464   id: number;
465   mod_user_id: number;
466   post_id: number;
467   locked?: boolean;
468   when_: string;
469   mod_user_name: string;
470   post_name: string;
471   community_id: number;
472   community_name: string;
473 }
474
475 export interface ModStickyPost {
476   id: number;
477   mod_user_id: number;
478   post_id: number;
479   stickied?: boolean;
480   when_: string;
481   mod_user_name: string;
482   post_name: string;
483   community_id: number;
484   community_name: string;
485 }
486
487 export interface ModRemoveComment {
488   id: number;
489   mod_user_id: number;
490   comment_id: number;
491   reason?: string;
492   removed?: boolean;
493   when_: string;
494   mod_user_name: string;
495   comment_user_id: number;
496   comment_user_name: string;
497   comment_content: string;
498   post_id: number;
499   post_name: string;
500   community_id: number;
501   community_name: string;
502 }
503
504 export interface ModRemoveCommunity {
505   id: number;
506   mod_user_id: number;
507   community_id: number;
508   reason?: string;
509   removed?: boolean;
510   expires?: number;
511   when_: string;
512   mod_user_name: string;
513   community_name: string;
514 }
515
516 export interface ModBanFromCommunity {
517   id: number;
518   mod_user_id: number;
519   other_user_id: number;
520   community_id: number;
521   reason?: string;
522   banned?: boolean;
523   expires?: number;
524   when_: string;
525   mod_user_name: string;
526   other_user_name: string;
527   community_name: string;
528 }
529
530 export interface ModBan {
531   id: number;
532   mod_user_id: number;
533   other_user_id: number;
534   reason?: string;
535   banned?: boolean;
536   expires?: number;
537   when_: string;
538   mod_user_name: string;
539   other_user_name: string;
540 }
541
542 export interface ModAddCommunity {
543   id: number;
544   mod_user_id: number;
545   other_user_id: number;
546   community_id: number;
547   removed?: boolean;
548   when_: string;
549   mod_user_name: string;
550   other_user_name: string;
551   community_name: string;
552 }
553
554 export interface ModAdd {
555   id: number;
556   mod_user_id: number;
557   other_user_id: number;
558   removed?: boolean;
559   when_: string;
560   mod_user_name: string;
561   other_user_name: string;
562 }
563
564 export interface LoginForm {
565   username_or_email: string;
566   password: string;
567 }
568
569 export interface RegisterForm {
570   username: string;
571   email?: string;
572   password: string;
573   password_verify: string;
574   admin: boolean;
575   show_nsfw: boolean;
576   captcha_uuid?: string;
577   captcha_answer?: string;
578 }
579
580 export interface GetCaptchaResponse {
581   ok?: {
582     png: string;
583     wav?: string;
584     uuid: string;
585   };
586 }
587
588 export interface LoginResponse {
589   jwt: string;
590 }
591
592 export interface UserSettingsForm {
593   show_nsfw: boolean;
594   theme: string;
595   default_sort_type: SortType;
596   default_listing_type: ListingType;
597   lang: string;
598   avatar?: string;
599   email?: string;
600   bio?: string;
601   matrix_user_id?: string;
602   new_password?: string;
603   new_password_verify?: string;
604   old_password?: string;
605   show_avatars: boolean;
606   send_notifications_to_email: boolean;
607   auth: string;
608 }
609
610 export interface CommunityForm {
611   name: string;
612   edit_id?: number;
613   title: string;
614   description?: string;
615   category_id: number;
616   nsfw: boolean;
617   auth?: string;
618 }
619
620 export interface DeleteCommunityForm {
621   edit_id: number;
622   deleted: boolean;
623   auth?: string;
624 }
625
626 export interface RemoveCommunityForm {
627   edit_id: number;
628   removed: boolean;
629   reason?: string;
630   expires?: number;
631   auth?: string;
632 }
633
634 export interface GetCommunityForm {
635   id?: number;
636   name?: string;
637   auth?: string;
638 }
639
640 export interface GetCommunityResponse {
641   community: Community;
642   moderators: Array<CommunityUser>;
643   online: number;
644 }
645
646 export interface CommunityResponse {
647   community: Community;
648 }
649
650 export interface ListCommunitiesForm {
651   sort: string;
652   page?: number;
653   limit?: number;
654   auth?: string;
655 }
656
657 export interface ListCommunitiesResponse {
658   communities: Array<Community>;
659 }
660
661 export interface ListCategoriesResponse {
662   categories: Array<Category>;
663 }
664
665 export interface PostForm {
666   name: string;
667   url?: string;
668   body?: string;
669   community_id?: number;
670   edit_id?: number;
671   nsfw: boolean;
672   auth: string;
673 }
674
675 export interface DeletePostForm {
676   edit_id: number;
677   deleted: boolean;
678   auth: string;
679 }
680
681 export interface RemovePostForm {
682   edit_id: number;
683   removed: boolean;
684   reason?: string;
685   auth: string;
686 }
687
688 export interface LockPostForm {
689   edit_id: number;
690   locked: boolean;
691   auth: string;
692 }
693
694 export interface StickyPostForm {
695   edit_id: number;
696   stickied: boolean;
697   auth: string;
698 }
699
700 export interface PostFormParams {
701   name: string;
702   url?: string;
703   body?: string;
704   community?: string;
705 }
706
707 export interface GetPostForm {
708   id: number;
709   auth?: string;
710 }
711
712 export interface GetPostResponse {
713   post: Post;
714   comments: Array<Comment>;
715   community: Community;
716   moderators: Array<CommunityUser>;
717   online: number;
718 }
719
720 export interface SavePostForm {
721   post_id: number;
722   save: boolean;
723   auth?: string;
724 }
725
726 export interface PostResponse {
727   post: Post;
728 }
729
730 export interface CommentForm {
731   content: string;
732   post_id?: number;
733   parent_id?: number;
734   edit_id?: number;
735   creator_id?: number;
736   form_id?: string;
737   auth: string;
738 }
739
740 export interface DeleteCommentForm {
741   edit_id: number;
742   deleted: boolean;
743   auth: string;
744 }
745
746 export interface RemoveCommentForm {
747   edit_id: number;
748   removed: boolean;
749   reason?: string;
750   auth: string;
751 }
752
753 export interface MarkCommentAsReadForm {
754   edit_id: number;
755   read: boolean;
756   auth: string;
757 }
758
759 export interface SaveCommentForm {
760   comment_id: number;
761   save: boolean;
762   auth?: string;
763 }
764
765 export interface CommentResponse {
766   comment: Comment;
767   recipient_ids: Array<number>;
768   form_id?: string;
769 }
770
771 export interface CommentLikeForm {
772   comment_id: number;
773   score: number;
774   auth?: string;
775 }
776
777 export interface CommentNode {
778   comment: Comment;
779   children?: Array<CommentNode>;
780 }
781
782 export interface GetPostsForm {
783   type_: string;
784   sort: string;
785   page?: number;
786   limit?: number;
787   community_id?: number;
788   auth?: string;
789 }
790
791 export interface GetPostsResponse {
792   posts: Array<Post>;
793 }
794
795 export interface GetCommentsForm {
796   type_: string;
797   sort: string;
798   page?: number;
799   limit: number;
800   community_id?: number;
801   auth?: string;
802 }
803
804 export interface GetCommentsResponse {
805   comments: Array<Comment>;
806 }
807
808 export interface CreatePostLikeForm {
809   post_id: number;
810   score: number;
811   auth?: string;
812 }
813
814 export interface SiteForm {
815   name: string;
816   description?: string;
817   enable_downvotes: boolean;
818   open_registration: boolean;
819   enable_nsfw: boolean;
820   auth?: string;
821 }
822
823 export interface GetSiteConfig {
824   auth?: string;
825 }
826
827 export interface GetSiteForm {
828   auth?: string;
829 }
830
831 export interface GetSiteConfigResponse {
832   config_hjson: string;
833 }
834
835 export interface SiteConfigForm {
836   config_hjson: string;
837   auth?: string;
838 }
839
840 export interface GetSiteResponse {
841   site: Site;
842   admins: Array<UserView>;
843   banned: Array<UserView>;
844   online: number;
845   version: string;
846   my_user?: User;
847 }
848
849 export interface SiteResponse {
850   site: Site;
851 }
852
853 export interface BanUserForm {
854   user_id: number;
855   ban: boolean;
856   reason?: string;
857   expires?: number;
858   auth?: string;
859 }
860
861 export interface BanUserResponse {
862   user: UserView;
863   banned: boolean;
864 }
865
866 export interface AddAdminForm {
867   user_id: number;
868   added: boolean;
869   auth?: string;
870 }
871
872 export interface AddAdminResponse {
873   admins: Array<UserView>;
874 }
875
876 export interface SearchForm {
877   q: string;
878   type_: string;
879   community_id?: number;
880   sort: string;
881   page?: number;
882   limit?: number;
883   auth?: string;
884 }
885
886 export interface SearchResponse {
887   type_: string;
888   posts?: Array<Post>;
889   comments?: Array<Comment>;
890   communities: Array<Community>;
891   users: Array<UserView>;
892 }
893
894 export interface DeleteAccountForm {
895   password: string;
896 }
897
898 export interface PasswordResetForm {
899   email: string;
900 }
901
902 // export interface PasswordResetResponse {
903 // }
904
905 export interface PasswordChangeForm {
906   token: string;
907   password: string;
908   password_verify: string;
909 }
910
911 export interface PrivateMessageForm {
912   content: string;
913   recipient_id: number;
914   auth?: string;
915 }
916
917 export interface PrivateMessageFormParams {
918   recipient_id: number;
919 }
920
921 export interface EditPrivateMessageForm {
922   edit_id: number;
923   content: string;
924   auth?: string;
925 }
926
927 export interface DeletePrivateMessageForm {
928   edit_id: number;
929   deleted: boolean;
930   auth?: string;
931 }
932
933 export interface MarkPrivateMessageAsReadForm {
934   edit_id: number;
935   read: boolean;
936   auth?: string;
937 }
938
939 export interface GetPrivateMessagesForm {
940   unread_only: boolean;
941   page?: number;
942   limit?: number;
943   auth?: string;
944 }
945
946 export interface PrivateMessagesResponse {
947   messages: Array<PrivateMessage>;
948 }
949
950 export interface PrivateMessageResponse {
951   message: PrivateMessage;
952 }
953
954 export interface UserJoinForm {
955   auth: string;
956 }
957
958 export interface UserJoinResponse {
959   user_id: number;
960 }
961
962 export type MessageType =
963   | LoginForm
964   | RegisterForm
965   | CommunityForm
966   | DeleteCommunityForm
967   | RemoveCommunityForm
968   | FollowCommunityForm
969   | ListCommunitiesForm
970   | GetFollowedCommunitiesForm
971   | PostForm
972   | DeletePostForm
973   | RemovePostForm
974   | LockPostForm
975   | StickyPostForm
976   | GetPostForm
977   | GetPostsForm
978   | GetCommunityForm
979   | CommentForm
980   | DeleteCommentForm
981   | RemoveCommentForm
982   | MarkCommentAsReadForm
983   | CommentLikeForm
984   | SaveCommentForm
985   | CreatePostLikeForm
986   | BanFromCommunityForm
987   | AddAdminForm
988   | AddModToCommunityForm
989   | TransferCommunityForm
990   | TransferSiteForm
991   | SaveCommentForm
992   | BanUserForm
993   | AddAdminForm
994   | GetUserDetailsForm
995   | GetRepliesForm
996   | GetUserMentionsForm
997   | MarkUserMentionAsReadForm
998   | GetModlogForm
999   | SiteForm
1000   | SearchForm
1001   | UserSettingsForm
1002   | DeleteAccountForm
1003   | PasswordResetForm
1004   | PasswordChangeForm
1005   | PrivateMessageForm
1006   | EditPrivateMessageForm
1007   | DeletePrivateMessageForm
1008   | MarkPrivateMessageAsReadForm
1009   | GetPrivateMessagesForm
1010   | SiteConfigForm;
1011
1012 type ResponseType =
1013   | SiteResponse
1014   | GetFollowedCommunitiesResponse
1015   | ListCommunitiesResponse
1016   | GetPostsResponse
1017   | PostResponse
1018   | GetRepliesResponse
1019   | GetUserMentionsResponse
1020   | ListCategoriesResponse
1021   | CommunityResponse
1022   | CommentResponse
1023   | UserMentionResponse
1024   | LoginResponse
1025   | GetCaptchaResponse
1026   | GetModlogResponse
1027   | SearchResponse
1028   | BanFromCommunityResponse
1029   | AddModToCommunityResponse
1030   | BanUserResponse
1031   | AddAdminResponse
1032   | PrivateMessageResponse
1033   | PrivateMessagesResponse
1034   | GetSiteConfigResponse
1035   | GetSiteResponse;
1036
1037 export interface WebSocketResponse {
1038   op: UserOperation;
1039   data: ResponseType;
1040 }
1041
1042 export interface WebSocketJsonResponse {
1043   op?: string;
1044   data?: ResponseType;
1045   error?: string;
1046   reconnect?: boolean;
1047 }
1048
1049 export enum UserDetailsView {
1050   Overview,
1051   Comments,
1052   Posts,
1053   Saved,
1054 }