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