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