]> Untitled Git - lemmy.git/blob - ui/src/interfaces.ts
Merge branch 'dev' and similar_post_fetch
[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
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 AddModToCommunityResponse {
206   op: string;
207   moderators: Array<CommunityUser>;
208 }
209
210 export interface GetModlogForm {
211   mod_user_id?: number;
212   community_id?: number;
213   page?: number;
214   limit?: number;
215 }
216
217 export interface GetModlogResponse {
218   op: string;
219   removed_posts: Array<ModRemovePost>,
220   locked_posts: Array<ModLockPost>,
221   removed_comments: Array<ModRemoveComment>,
222   removed_communities: Array<ModRemoveCommunity>,
223   banned_from_community: Array<ModBanFromCommunity>,
224   banned: Array<ModBan>,
225   added_to_community: Array<ModAddCommunity>,
226   added: Array<ModAdd>,
227 }
228
229 export interface ModRemovePost {
230   id: number;
231   mod_user_id: number;
232   post_id: number;
233   reason?: string;
234   removed?: boolean;
235   when_: string
236   mod_user_name: string;
237   post_name: string;
238   community_id: number;
239   community_name: string;
240 }
241
242 export interface ModLockPost {
243   id: number,
244   mod_user_id: number,
245   post_id: number,
246   locked?: boolean,
247   when_: string,
248   mod_user_name: string,
249   post_name: string,
250   community_id: number,
251   community_name: string,
252 }
253
254 export interface ModRemoveComment {
255   id: number,
256   mod_user_id: number,
257   comment_id: number,
258   reason?: string,
259   removed?: boolean,
260   when_: string,
261   mod_user_name: string,
262   comment_user_id: number,
263   comment_user_name: string,
264   comment_content: string,
265   post_id: number,
266   post_name: string,
267   community_id: number,
268   community_name: string,
269 }
270
271 export interface ModRemoveCommunity {
272   id: number,
273   mod_user_id: number,
274   community_id: number,
275   reason?: string,
276   removed?: boolean,
277   expires?: number,
278   when_: string,
279   mod_user_name: string,
280   community_name: string,
281 }
282
283 export interface ModBanFromCommunity {
284   id: number,
285   mod_user_id: number,
286   other_user_id: number,
287   community_id: number,
288   reason?: string,
289   banned?: boolean,
290   expires?: number,
291   when_: string,
292   mod_user_name: string,
293   other_user_name: string,
294   community_name: string,
295 }
296
297 export interface ModBan {
298   id: number,
299   mod_user_id: number,
300   other_user_id: number,
301   reason?: string,
302   banned?: boolean,
303   expires?: number,
304   when_: string,
305   mod_user_name: string,
306   other_user_name: string,
307 }
308
309 export interface ModAddCommunity {
310   id: number,
311   mod_user_id: number,
312   other_user_id: number,
313   community_id: number,
314   removed?: boolean,
315   when_: string,
316   mod_user_name: string,
317   other_user_name: string,
318   community_name: string,
319 }
320
321 export interface ModAdd {
322   id: number,
323   mod_user_id: number,
324   other_user_id: number,
325   removed?: boolean,
326   when_: string,
327   mod_user_name: string,
328   other_user_name: string,
329 }
330
331 export interface LoginForm {
332   username_or_email: string;
333   password: string;
334 }
335
336 export interface RegisterForm {
337   username: string;
338   email?: string;
339   password: string;
340   password_verify: string;
341   admin: boolean;
342   show_nsfw: boolean;
343 }
344
345 export interface LoginResponse {
346   op: string;
347   jwt: string;
348 }
349
350 export interface UserSettingsForm {
351   show_nsfw: boolean;
352   auth: string;
353 }
354
355 export interface CommunityForm {
356   name: string;
357   title: string;
358   description?: string,
359   category_id: number,
360   edit_id?: number;
361   removed?: boolean;
362   deleted?: boolean;
363   nsfw: boolean;
364   reason?: string;
365   expires?: number;
366   auth?: string;
367 }
368
369 export interface GetCommunityResponse {
370   op: string;
371   community: Community;
372   moderators: Array<CommunityUser>;
373   admins: Array<UserView>;
374 }
375
376
377 export interface CommunityResponse {
378   op: string;
379   community: Community;
380 }
381
382 export interface ListCommunitiesForm {
383   sort: string;
384   page?: number;
385   limit?: number;
386   auth?: string;
387 }
388
389 export interface ListCommunitiesResponse {
390   op: string;
391   communities: Array<Community>;
392 }
393
394 export interface ListCategoriesResponse {
395   op: string;
396   categories: Array<Category>;
397 }
398
399 export interface PostForm {
400   name: string;
401   url?: string;
402   body?: string;
403   community_id: number;
404   updated?: number;
405   edit_id?: number;
406   creator_id: number;
407   removed?: boolean;
408   deleted?: boolean;
409   nsfw: boolean;
410   locked?: boolean;
411   reason?: string;
412   auth: string;
413 }
414
415 export interface PostFormParams {
416   name: string;
417   url?: string;
418   body?: string;
419   community?: string;
420 }
421
422 export interface GetPostResponse {
423   op: string;
424   post: Post;
425   comments: Array<Comment>;
426   community: Community;
427   moderators: Array<CommunityUser>;
428   admins: Array<UserView>;
429 }
430
431 export interface SavePostForm {
432   post_id: number;
433   save: boolean;
434   auth?: string;
435 }
436
437 export interface PostResponse {
438   op: string;
439   post: Post;
440 }
441
442 export interface CommentForm {
443   content: string;
444   post_id: number;
445   parent_id?: number;
446   edit_id?: number;
447   creator_id: number;
448   removed?: boolean;
449   deleted?: boolean;
450   reason?: string;
451   read?: boolean;
452   auth: string;
453 }
454
455 export interface SaveCommentForm {
456   comment_id: number;
457   save: boolean;
458   auth?: string;
459 }
460
461 export interface CommentResponse {
462   op: string;
463   comment: Comment;
464 }
465
466 export interface CommentLikeForm {
467   comment_id: number;
468   post_id: number;
469   score: number;
470   auth?: string;
471 }
472
473 export interface CommentNode {
474   comment: Comment;
475   children?: Array<CommentNode>;
476 }
477
478 export interface GetPostsForm {
479   type_: string;
480   sort: string;
481   page?: number;
482   limit?: number;
483   community_id?: number;
484   auth?: string;
485 }
486
487 export interface GetPostsResponse {
488   op: string;
489   posts: Array<Post>;
490 }
491
492 export interface CreatePostLikeForm {
493   post_id: number;
494   score: number;
495   auth?: string;
496 }
497
498 export interface CreatePostLikeResponse {
499   op: string;
500   post: Post;
501 }
502
503 export interface SiteForm {
504   name: string;
505   description?: string,
506   removed?: boolean;
507   reason?: string;
508   expires?: number;
509   auth?: string;
510 }
511
512 export interface GetSiteResponse {
513   op: string;
514   site: Site;
515   admins: Array<UserView>;
516   banned: Array<UserView>;
517 }
518
519
520 export interface SiteResponse {
521   op: string;
522   site: Site;
523 }
524
525 export interface BanUserForm {
526   user_id: number;
527   ban: boolean;
528   reason?: string,
529   expires?: number,
530   auth?: string;
531 }
532
533 export interface BanUserResponse {
534   op: string;
535   user: UserView,
536   banned: boolean,
537 }
538
539 export interface AddAdminForm {
540   user_id: number;
541   added: boolean;
542   auth?: string;
543 }
544
545 export interface AddAdminResponse {
546   op: string;
547   admins: Array<UserView>;
548 }
549
550 export interface SearchForm {
551   q: string;
552   type_: string;
553   community_id?: number;
554   sort: string;
555   page?: number;
556   limit?: number;
557 }
558
559 export interface SearchResponse {
560   op: string;
561   type_: string;
562   posts?: Array<Post>;
563   comments?: Array<Comment>;
564   communities: Array<Community>;  
565   users: Array<UserView>;
566 }