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