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