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