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