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