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