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