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