lemmy-js-client 0.19.0-rc.9 → 0.19.2-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. package/dist/http.d.ts +99 -33
  2. package/dist/http.js +119 -31
  3. package/dist/index.d.ts +16 -25
  4. package/dist/{types/others.d.ts → other_types.d.ts} +4 -4
  5. package/dist/types/ActivityId.d.ts +1 -0
  6. package/dist/types/AddAdmin.d.ts +0 -1
  7. package/dist/types/AddModToCommunity.d.ts +0 -1
  8. package/dist/types/ApproveRegistrationApplication.d.ts +0 -1
  9. package/dist/types/BanFromCommunity.d.ts +0 -1
  10. package/dist/types/BanPerson.d.ts +0 -1
  11. package/dist/types/BlockCommunity.d.ts +0 -1
  12. package/dist/types/BlockInstance.d.ts +0 -1
  13. package/dist/types/BlockPerson.d.ts +0 -1
  14. package/dist/types/ChangePassword.d.ts +0 -1
  15. package/dist/types/CommentAggregates.d.ts +0 -3
  16. package/dist/types/CommentReplyView.d.ts +2 -0
  17. package/dist/types/CommentView.d.ts +2 -0
  18. package/dist/types/Community.d.ts +0 -2
  19. package/dist/types/CommunityAggregates.d.ts +0 -2
  20. package/dist/types/CreateComment.d.ts +0 -1
  21. package/dist/types/CreateCommentLike.d.ts +0 -1
  22. package/dist/types/CreateCommentReport.d.ts +0 -1
  23. package/dist/types/CreateCommunity.d.ts +0 -1
  24. package/dist/types/CreateCustomEmoji.d.ts +0 -1
  25. package/dist/types/CreatePost.d.ts +0 -1
  26. package/dist/types/CreatePostLike.d.ts +0 -1
  27. package/dist/types/CreatePostReport.d.ts +0 -1
  28. package/dist/types/CreatePrivateMessage.d.ts +0 -1
  29. package/dist/types/CreatePrivateMessageReport.d.ts +0 -1
  30. package/dist/types/CreateSite.d.ts +0 -1
  31. package/dist/types/CustomEmojiKeyword.d.ts +0 -1
  32. package/dist/types/DeleteAccount.d.ts +0 -1
  33. package/dist/types/DeleteComment.d.ts +0 -1
  34. package/dist/types/DeleteCommunity.d.ts +0 -1
  35. package/dist/types/DeleteCustomEmoji.d.ts +0 -1
  36. package/dist/types/DeletePost.d.ts +0 -1
  37. package/dist/types/DeletePrivateMessage.d.ts +0 -1
  38. package/dist/types/DistinguishComment.d.ts +0 -1
  39. package/dist/types/EditComment.d.ts +0 -1
  40. package/dist/types/EditCommunity.d.ts +0 -1
  41. package/dist/types/EditCustomEmoji.d.ts +0 -1
  42. package/dist/types/EditPost.d.ts +0 -1
  43. package/dist/types/EditPrivateMessage.d.ts +0 -1
  44. package/dist/types/EditSite.d.ts +0 -1
  45. package/dist/types/FeaturePost.d.ts +0 -1
  46. package/dist/types/FederatedInstances.d.ts +4 -4
  47. package/dist/types/FollowCommunity.d.ts +0 -1
  48. package/dist/types/GenerateTotpSecretResponse.d.ts +3 -0
  49. package/dist/types/GetComment.d.ts +0 -1
  50. package/dist/types/GetComments.d.ts +0 -1
  51. package/dist/types/GetCommunity.d.ts +0 -1
  52. package/dist/types/GetModlog.d.ts +0 -1
  53. package/dist/types/GetPersonDetails.d.ts +0 -1
  54. package/dist/types/GetPersonMentions.d.ts +0 -1
  55. package/dist/types/GetPost.d.ts +0 -1
  56. package/dist/types/GetPosts.d.ts +2 -1
  57. package/dist/types/GetPostsResponse.d.ts +2 -0
  58. package/dist/types/GetPrivateMessages.d.ts +0 -1
  59. package/dist/types/GetReplies.d.ts +0 -1
  60. package/dist/types/GetReportCount.d.ts +0 -1
  61. package/dist/types/HideCommunity.d.ts +0 -1
  62. package/dist/types/ImageUpload.d.ts +7 -0
  63. package/dist/types/InstanceWithFederationState.d.ts +11 -0
  64. package/dist/types/LemmyErrorType.d.ts +171 -138
  65. package/dist/types/ListCommentLikes.d.ts +6 -0
  66. package/dist/types/ListCommentLikesResponse.d.ts +4 -0
  67. package/dist/types/ListCommentReports.d.ts +0 -1
  68. package/dist/types/ListCommunities.d.ts +0 -1
  69. package/dist/types/ListPostLikes.d.ts +6 -0
  70. package/dist/types/ListPostLikesResponse.d.ts +4 -0
  71. package/dist/types/ListPostLikesResponse.js +2 -0
  72. package/dist/types/ListPostReports.d.ts +0 -1
  73. package/dist/types/ListPrivateMessageReports.d.ts +0 -1
  74. package/dist/types/ListRegistrationApplications.d.ts +0 -1
  75. package/dist/types/LocalSite.d.ts +1 -0
  76. package/dist/types/LocalSiteRateLimit.d.ts +2 -1
  77. package/dist/types/LocalUser.d.ts +4 -3
  78. package/dist/types/LockPost.d.ts +0 -1
  79. package/dist/types/LoginToken.d.ts +7 -0
  80. package/dist/types/LoginToken.js +2 -0
  81. package/dist/types/MarkCommentReplyAsRead.d.ts +0 -1
  82. package/dist/types/MarkPersonMentionAsRead.d.ts +0 -1
  83. package/dist/types/MarkPostAsRead.d.ts +2 -2
  84. package/dist/types/MarkPrivateMessageAsRead.d.ts +0 -1
  85. package/dist/types/ModRemoveCommunity.d.ts +0 -1
  86. package/dist/types/PaginationCursor.d.ts +1 -0
  87. package/dist/types/Person.d.ts +0 -1
  88. package/dist/types/PersonAggregates.d.ts +0 -3
  89. package/dist/types/PersonMentionView.d.ts +2 -0
  90. package/dist/types/PersonView.d.ts +1 -0
  91. package/dist/types/PostAggregates.d.ts +0 -14
  92. package/dist/types/PostView.d.ts +2 -0
  93. package/dist/types/PurgeComment.d.ts +0 -1
  94. package/dist/types/PurgeCommunity.d.ts +0 -1
  95. package/dist/types/PurgePerson.d.ts +0 -1
  96. package/dist/types/PurgePost.d.ts +0 -1
  97. package/dist/types/ReadableFederationState.d.ts +10 -0
  98. package/dist/types/ReadableFederationState.js +2 -0
  99. package/dist/types/RemoveComment.d.ts +0 -1
  100. package/dist/types/RemoveCommunity.d.ts +0 -2
  101. package/dist/types/RemovePost.d.ts +0 -1
  102. package/dist/types/ResolveCommentReport.d.ts +0 -1
  103. package/dist/types/ResolveObject.d.ts +0 -1
  104. package/dist/types/ResolvePostReport.d.ts +0 -1
  105. package/dist/types/ResolvePrivateMessageReport.d.ts +0 -1
  106. package/dist/types/SaveComment.d.ts +0 -1
  107. package/dist/types/SavePost.d.ts +0 -1
  108. package/dist/types/SaveUserSettings.d.ts +5 -3
  109. package/dist/types/Search.d.ts +0 -1
  110. package/dist/types/SiteAggregates.d.ts +0 -1
  111. package/dist/types/SortType.d.ts +1 -1
  112. package/dist/types/SuccessResponse.d.ts +3 -0
  113. package/dist/types/TransferCommunity.d.ts +0 -1
  114. package/dist/types/UpdateTotp.d.ts +4 -0
  115. package/dist/types/UpdateTotpResponse.d.ts +3 -0
  116. package/dist/types/VoteView.d.ts +5 -0
  117. package/dist/types/VoteView.js +2 -0
  118. package/package.json +12 -12
  119. package/dist/types/CommunityBlockId.d.ts +0 -1
  120. package/dist/types/CommunityJoin.d.ts +0 -4
  121. package/dist/types/CommunityJoinResponse.d.ts +0 -3
  122. package/dist/types/DeleteAccountResponse.d.ts +0 -1
  123. package/dist/types/DeleteCustomEmojiResponse.d.ts +0 -5
  124. package/dist/types/GetBannedPersons.d.ts +0 -3
  125. package/dist/types/GetCaptcha.d.ts +0 -3
  126. package/dist/types/GetFederatedInstances.d.ts +0 -3
  127. package/dist/types/GetSite.d.ts +0 -3
  128. package/dist/types/GetSite.js +0 -3
  129. package/dist/types/GetUnreadCount.d.ts +0 -3
  130. package/dist/types/GetUnreadCount.js +0 -3
  131. package/dist/types/GetUnreadRegistrationApplicationCount.d.ts +0 -3
  132. package/dist/types/GetUnreadRegistrationApplicationCount.js +0 -3
  133. package/dist/types/LeaveAdmin.d.ts +0 -3
  134. package/dist/types/LeaveAdmin.js +0 -3
  135. package/dist/types/MarkAllAsRead.d.ts +0 -3
  136. package/dist/types/MarkAllAsRead.js +0 -3
  137. package/dist/types/ModJoin.d.ts +0 -4
  138. package/dist/types/ModJoinResponse.d.ts +0 -3
  139. package/dist/types/ModJoinResponse.js +0 -3
  140. package/dist/types/PasswordResetResponse.d.ts +0 -1
  141. package/dist/types/PasswordResetResponse.js +0 -3
  142. package/dist/types/PersonSortType.d.ts +0 -1
  143. package/dist/types/PersonSortType.js +0 -3
  144. package/dist/types/PostJoin.d.ts +0 -4
  145. package/dist/types/PostJoinResponse.d.ts +0 -3
  146. package/dist/types/PostJoinResponse.js +0 -3
  147. package/dist/types/PostOrCommentId.d.ts +0 -7
  148. package/dist/types/PurgeItemResponse.d.ts +0 -3
  149. package/dist/types/PurgeItemResponse.js +0 -3
  150. package/dist/types/UserJoin.d.ts +0 -3
  151. package/dist/types/UserJoin.js +0 -3
  152. package/dist/types/UserJoinResponse.d.ts +0 -3
  153. package/dist/types/UserJoinResponse.js +0 -3
  154. package/dist/types/VerifyEmailResponse.d.ts +0 -1
  155. package/dist/types/VerifyEmailResponse.js +0 -3
  156. package/dist/utils.d.ts +0 -0
  157. package/dist/utils.js +0 -0
  158. /package/dist/{types/others.js → other_types.js} +0 -0
  159. /package/dist/types/{CommunityBlockId.js → ActivityId.js} +0 -0
  160. /package/dist/types/{CommunityJoinResponse.js → GenerateTotpSecretResponse.js} +0 -0
  161. /package/dist/types/{CommunityJoin.js → ImageUpload.js} +0 -0
  162. /package/dist/types/{DeleteCustomEmojiResponse.js → InstanceWithFederationState.js} +0 -0
  163. /package/dist/types/{ModJoin.js → ListCommentLikes.js} +0 -0
  164. /package/dist/types/{PostJoin.js → ListCommentLikesResponse.js} +0 -0
  165. /package/dist/types/{PostOrCommentId.js → ListPostLikes.js} +0 -0
  166. /package/dist/types/{DeleteAccountResponse.js → PaginationCursor.js} +0 -0
  167. /package/dist/types/{GetBannedPersons.js → SuccessResponse.js} +0 -0
  168. /package/dist/types/{GetCaptcha.js → UpdateTotp.js} +0 -0
  169. /package/dist/types/{GetFederatedInstances.js → UpdateTotpResponse.js} +0 -0
package/dist/http.d.ts CHANGED
@@ -34,7 +34,6 @@ import { DeleteAccount } from "./types/DeleteAccount";
34
34
  import { DeleteComment } from "./types/DeleteComment";
35
35
  import { DeleteCommunity } from "./types/DeleteCommunity";
36
36
  import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
37
- import { DeleteCustomEmojiResponse } from "./types/DeleteCustomEmojiResponse";
38
37
  import { DeletePost } from "./types/DeletePost";
39
38
  import { DeletePrivateMessage } from "./types/DeletePrivateMessage";
40
39
  import { DistinguishComment } from "./types/DistinguishComment";
@@ -46,15 +45,12 @@ import { EditPrivateMessage } from "./types/EditPrivateMessage";
46
45
  import { EditSite } from "./types/EditSite";
47
46
  import { FeaturePost } from "./types/FeaturePost";
48
47
  import { FollowCommunity } from "./types/FollowCommunity";
49
- import { GetBannedPersons } from "./types/GetBannedPersons";
50
- import { GetCaptcha } from "./types/GetCaptcha";
51
48
  import { GetCaptchaResponse } from "./types/GetCaptchaResponse";
52
49
  import { GetComment } from "./types/GetComment";
53
50
  import { GetComments } from "./types/GetComments";
54
51
  import { GetCommentsResponse } from "./types/GetCommentsResponse";
55
52
  import { GetCommunity } from "./types/GetCommunity";
56
53
  import { GetCommunityResponse } from "./types/GetCommunityResponse";
57
- import { GetFederatedInstances } from "./types/GetFederatedInstances";
58
54
  import { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
59
55
  import { GetModlog } from "./types/GetModlog";
60
56
  import { GetModlogResponse } from "./types/GetModlogResponse";
@@ -71,15 +67,11 @@ import { GetReplies } from "./types/GetReplies";
71
67
  import { GetRepliesResponse } from "./types/GetRepliesResponse";
72
68
  import { GetReportCount } from "./types/GetReportCount";
73
69
  import { GetReportCountResponse } from "./types/GetReportCountResponse";
74
- import { GetSite } from "./types/GetSite";
75
70
  import { GetSiteMetadata } from "./types/GetSiteMetadata";
76
71
  import { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse";
77
72
  import { GetSiteResponse } from "./types/GetSiteResponse";
78
- import { GetUnreadCount } from "./types/GetUnreadCount";
79
73
  import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
80
- import { GetUnreadRegistrationApplicationCount } from "./types/GetUnreadRegistrationApplicationCount";
81
74
  import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
82
- import { LeaveAdmin } from "./types/LeaveAdmin";
83
75
  import { ListCommentReports } from "./types/ListCommentReports";
84
76
  import { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
85
77
  import { ListCommunities } from "./types/ListCommunities";
@@ -93,7 +85,6 @@ import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationAp
93
85
  import { LockPost } from "./types/LockPost";
94
86
  import { Login } from "./types/Login";
95
87
  import { LoginResponse } from "./types/LoginResponse";
96
- import { MarkAllAsRead } from "./types/MarkAllAsRead";
97
88
  import { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
98
89
  import { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
99
90
  import { MarkPostAsRead } from "./types/MarkPostAsRead";
@@ -108,7 +99,6 @@ import { PrivateMessageResponse } from "./types/PrivateMessageResponse";
108
99
  import { PrivateMessagesResponse } from "./types/PrivateMessagesResponse";
109
100
  import { PurgeComment } from "./types/PurgeComment";
110
101
  import { PurgeCommunity } from "./types/PurgeCommunity";
111
- import { PurgeItemResponse } from "./types/PurgeItemResponse";
112
102
  import { PurgePerson } from "./types/PurgePerson";
113
103
  import { PurgePost } from "./types/PurgePost";
114
104
  import { Register } from "./types/Register";
@@ -129,9 +119,19 @@ import { SearchResponse } from "./types/SearchResponse";
129
119
  import { SiteResponse } from "./types/SiteResponse";
130
120
  import { TransferCommunity } from "./types/TransferCommunity";
131
121
  import { VerifyEmail } from "./types/VerifyEmail";
132
- import { UploadImage, UploadImageResponse } from "./types/others";
122
+ import { DeleteImage, UploadImage, UploadImageResponse } from "./other_types";
123
+ import { HideCommunity } from "./types/HideCommunity";
133
124
  import { BlockInstance } from "./types/BlockInstance";
134
125
  import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
126
+ import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
127
+ import { UpdateTotp } from "./types/UpdateTotp";
128
+ import { UpdateTotpResponse } from "./types/UpdateTotpResponse";
129
+ import { SuccessResponse } from "./types/SuccessResponse";
130
+ import { LoginToken } from "./types/LoginToken";
131
+ import { ListPostLikes } from "./types/ListPostLikes";
132
+ import { ListPostLikesResponse } from "./types/ListPostLikesResponse";
133
+ import { ListCommentLikes } from "./types/ListCommentLikes";
134
+ import { ListCommentLikesResponse } from "./types/ListCommentLikesResponse";
135
135
  /**
136
136
  * Helps build lemmy HTTP requests.
137
137
  */
@@ -153,7 +153,7 @@ export declare class LemmyHttp {
153
153
  *
154
154
  * `HTTP.GET /site`
155
155
  */
156
- getSite(form?: GetSite): Promise<GetSiteResponse>;
156
+ getSite(): Promise<GetSiteResponse>;
157
157
  /**
158
158
  * Create your site.
159
159
  *
@@ -171,7 +171,50 @@ export declare class LemmyHttp {
171
171
  *
172
172
  * `HTTP.POST /user/leave_admin`
173
173
  */
174
- leaveAdmin(form: LeaveAdmin): Promise<GetSiteResponse>;
174
+ leaveAdmin(): Promise<GetSiteResponse>;
175
+ /**
176
+ * Generate a TOTP / two-factor secret.
177
+ *
178
+ * Afterwards you need to call `/user/totp/update` with a valid token to enable it.
179
+ *
180
+ * `HTTP.POST /user/totp/generate`
181
+ */
182
+ generateTotpSecret(): Promise<GenerateTotpSecretResponse>;
183
+ /**
184
+ * Export a backup of your user settings, including your saved content,
185
+ * followed communities, and blocks.
186
+ *
187
+ * `HTTP.GET /user/export_settings`
188
+ */
189
+ exportSettings(): Promise<any>;
190
+ /**
191
+ * Import a backup of your user settings.
192
+ *
193
+ * `HTTP.POST /user/import_settings`
194
+ */
195
+ importSettings(form: any): Promise<SuccessResponse>;
196
+ /**
197
+ * List login tokens for your user
198
+ *
199
+ * `HTTP.GET /user/list_logins`
200
+ */
201
+ listLogins(): Promise<LoginToken[]>;
202
+ /**
203
+ * Returns an error message if your auth token is invalid
204
+ *
205
+ * `HTTP.GET /user/validate_auth`
206
+ */
207
+ validateAuth(): Promise<SuccessResponse>;
208
+ /**
209
+ * Enable / Disable TOTP / two-factor authentication.
210
+ *
211
+ * To enable, you need to first call `/user/totp/generate` and then pass a valid token to this.
212
+ *
213
+ * Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.
214
+ *
215
+ * `HTTP.POST /user/totp/update`
216
+ */
217
+ updateTotp(form: UpdateTotp): Promise<UpdateTotpResponse>;
175
218
  /**
176
219
  * Get the modlog.
177
220
  *
@@ -232,6 +275,12 @@ export declare class LemmyHttp {
232
275
  * `HTTP.POST /community/delete`
233
276
  */
234
277
  deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse>;
278
+ /**
279
+ * Hide a community from public / "All" view. Admins only.
280
+ *
281
+ * `HTTP.PUT /community/hide`
282
+ */
283
+ hideCommunity(form: HideCommunity): Promise<SuccessResponse>;
235
284
  /**
236
285
  * A moderator remove for a community.
237
286
  *
@@ -291,7 +340,7 @@ export declare class LemmyHttp {
291
340
  *
292
341
  * `HTTP.POST /post/mark_as_read`
293
342
  */
294
- markPostAsRead(form: MarkPostAsRead): Promise<PostResponse>;
343
+ markPostAsRead(form: MarkPostAsRead): Promise<SuccessResponse>;
295
344
  /**
296
345
  * A moderator can lock a post ( IE disable new comments ).
297
346
  *
@@ -316,6 +365,12 @@ export declare class LemmyHttp {
316
365
  * `HTTP.POST /post/like`
317
366
  */
318
367
  likePost(form: CreatePostLike): Promise<PostResponse>;
368
+ /**
369
+ * List a post's likes. Admin-only.
370
+ *
371
+ * `HTTP.GET /post/like`
372
+ */
373
+ listPostLikes(form: ListPostLikes): Promise<ListPostLikesResponse>;
319
374
  /**
320
375
  * Save a post.
321
376
  *
@@ -382,6 +437,12 @@ export declare class LemmyHttp {
382
437
  * `HTTP.POST /comment/like`
383
438
  */
384
439
  likeComment(form: CreateCommentLike): Promise<CommentResponse>;
440
+ /**
441
+ * List a comment's likes. Admin-only.
442
+ *
443
+ * `HTTP.GET //like`
444
+ */
445
+ listCommentLikes(form: ListCommentLikes): Promise<ListCommentLikesResponse>;
385
446
  /**
386
447
  * Save a comment.
387
448
  *
@@ -484,6 +545,7 @@ export declare class LemmyHttp {
484
545
  * `HTTP.POST /user/login`
485
546
  */
486
547
  login(form: Login): Promise<LoginResponse>;
548
+ logout(): Promise<SuccessResponse>;
487
549
  /**
488
550
  * Get the details for a person.
489
551
  *
@@ -519,7 +581,7 @@ export declare class LemmyHttp {
519
581
  *
520
582
  * `HTTP.GET /user/banned`
521
583
  */
522
- getBannedPersons(form: GetBannedPersons): Promise<BannedPersonsResponse>;
584
+ getBannedPersons(): Promise<BannedPersonsResponse>;
523
585
  /**
524
586
  * Block a person.
525
587
  *
@@ -531,37 +593,37 @@ export declare class LemmyHttp {
531
593
  *
532
594
  * `HTTP.GET /user/get_captcha`
533
595
  */
534
- getCaptcha(form?: GetCaptcha): Promise<GetCaptchaResponse>;
596
+ getCaptcha(): Promise<GetCaptchaResponse>;
535
597
  /**
536
598
  * Delete your account.
537
599
  *
538
600
  * `HTTP.POST /user/delete_account`
539
601
  */
540
- deleteAccount(form: DeleteAccount): Promise<null>;
602
+ deleteAccount(form: DeleteAccount): Promise<SuccessResponse>;
541
603
  /**
542
604
  * Reset your password.
543
605
  *
544
606
  * `HTTP.POST /user/password_reset`
545
607
  */
546
- passwordReset(form: PasswordReset): Promise<null>;
608
+ passwordReset(form: PasswordReset): Promise<SuccessResponse>;
547
609
  /**
548
610
  * Change your password from an email / token based reset.
549
611
  *
550
612
  * `HTTP.POST /user/password_change`
551
613
  */
552
- passwordChangeAfterReset(form: PasswordChangeAfterReset): Promise<LoginResponse>;
614
+ passwordChangeAfterReset(form: PasswordChangeAfterReset): Promise<SuccessResponse>;
553
615
  /**
554
616
  * Mark all replies as read.
555
617
  *
556
618
  * `HTTP.POST /user/mark_all_as_read`
557
619
  */
558
- markAllAsRead(form: MarkAllAsRead): Promise<GetRepliesResponse>;
620
+ markAllAsRead(): Promise<GetRepliesResponse>;
559
621
  /**
560
622
  * Save your user settings.
561
623
  *
562
624
  * `HTTP.PUT /user/save_user_settings`
563
625
  */
564
- saveUserSettings(form: SaveUserSettings): Promise<LoginResponse>;
626
+ saveUserSettings(form: SaveUserSettings): Promise<SuccessResponse>;
565
627
  /**
566
628
  * Change your user password.
567
629
  *
@@ -579,13 +641,13 @@ export declare class LemmyHttp {
579
641
  *
580
642
  * `HTTP.GET /user/unread_count`
581
643
  */
582
- getUnreadCount(form: GetUnreadCount): Promise<GetUnreadCountResponse>;
644
+ getUnreadCount(): Promise<GetUnreadCountResponse>;
583
645
  /**
584
646
  * Verify your email
585
647
  *
586
648
  * `HTTP.POST /user/verify_email`
587
649
  */
588
- verifyEmail(form: VerifyEmail): Promise<null>;
650
+ verifyEmail(form: VerifyEmail): Promise<SuccessResponse>;
589
651
  /**
590
652
  * Add an admin to your site.
591
653
  *
@@ -597,7 +659,7 @@ export declare class LemmyHttp {
597
659
  *
598
660
  * `HTTP.GET /admin/registration_application/count`
599
661
  */
600
- getUnreadRegistrationApplicationCount(form: GetUnreadRegistrationApplicationCount): Promise<GetUnreadRegistrationApplicationCountResponse>;
662
+ getUnreadRegistrationApplicationCount(): Promise<GetUnreadRegistrationApplicationCountResponse>;
601
663
  /**
602
664
  * List the registration applications.
603
665
  *
@@ -615,25 +677,25 @@ export declare class LemmyHttp {
615
677
  *
616
678
  * `HTTP.POST /admin/purge/person`
617
679
  */
618
- purgePerson(form: PurgePerson): Promise<PurgeItemResponse>;
680
+ purgePerson(form: PurgePerson): Promise<SuccessResponse>;
619
681
  /**
620
682
  * Purge / Delete a community from the database.
621
683
  *
622
684
  * `HTTP.POST /admin/purge/community`
623
685
  */
624
- purgeCommunity(form: PurgeCommunity): Promise<PurgeItemResponse>;
686
+ purgeCommunity(form: PurgeCommunity): Promise<SuccessResponse>;
625
687
  /**
626
688
  * Purge / Delete a post from the database.
627
689
  *
628
690
  * `HTTP.POST /admin/purge/post`
629
691
  */
630
- purgePost(form: PurgePost): Promise<PurgeItemResponse>;
692
+ purgePost(form: PurgePost): Promise<SuccessResponse>;
631
693
  /**
632
694
  * Purge / Delete a comment from the database.
633
695
  *
634
696
  * `HTTP.POST /admin/purge/comment`
635
697
  */
636
- purgeComment(form: PurgeComment): Promise<PurgeItemResponse>;
698
+ purgeComment(form: PurgeComment): Promise<SuccessResponse>;
637
699
  /**
638
700
  * Create a new custom emoji
639
701
  *
@@ -651,23 +713,27 @@ export declare class LemmyHttp {
651
713
  *
652
714
  * `HTTP.Post /custom_emoji/delete`
653
715
  */
654
- deleteCustomEmoji(form: DeleteCustomEmoji): Promise<DeleteCustomEmojiResponse>;
716
+ deleteCustomEmoji(form: DeleteCustomEmoji): Promise<SuccessResponse>;
655
717
  /**
656
718
  * Fetch federated instances.
657
719
  *
658
720
  * `HTTP.Get /federated_instances`
659
721
  */
660
- getFederatedInstances(form?: GetFederatedInstances): Promise<GetFederatedInstancesResponse>;
722
+ getFederatedInstances(): Promise<GetFederatedInstancesResponse>;
661
723
  /**
662
- * Block an instance
724
+ * Block an instance.
663
725
  *
664
- * `HTTP.POST /site/block`
726
+ * `HTTP.Post /site/block`
665
727
  */
666
728
  blockInstance(form: BlockInstance): Promise<BlockInstanceResponse>;
667
729
  /**
668
730
  * Upload an image to the server.
669
731
  */
670
- uploadImage({ image, auth, }: UploadImage): Promise<UploadImageResponse>;
732
+ uploadImage({ image }: UploadImage): Promise<UploadImageResponse>;
733
+ /**
734
+ * Delete a pictrs image
735
+ */
736
+ deleteImage({ token, filename }: DeleteImage): Promise<boolean>;
671
737
  /**
672
738
  * Set the headers (can be used to set the auth header)
673
739
  */
package/dist/http.js CHANGED
@@ -27,7 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.LemmyHttp = void 0;
28
28
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
29
29
  const form_data_1 = __importDefault(require("form-data"));
30
- const others_1 = require("./types/others");
30
+ const other_types_1 = require("./other_types");
31
31
  var HttpType;
32
32
  (function (HttpType) {
33
33
  HttpType["Get"] = "GET";
@@ -49,7 +49,7 @@ class LemmyHttp {
49
49
  _LemmyHttp_headers.set(this, {});
50
50
  _LemmyHttp_pictrsUrl.set(this, void 0);
51
51
  _LemmyHttp_fetchFunction.set(this, cross_fetch_1.default);
52
- __classPrivateFieldSet(this, _LemmyHttp_apiUrl, `${baseUrl.replace(/\/+$/, "")}/api/${others_1.VERSION}`, "f");
52
+ __classPrivateFieldSet(this, _LemmyHttp_apiUrl, `${baseUrl.replace(/\/+$/, "")}/api/${other_types_1.VERSION}`, "f");
53
53
  __classPrivateFieldSet(this, _LemmyHttp_pictrsUrl, `${baseUrl}/pictrs/image`, "f");
54
54
  if (options === null || options === void 0 ? void 0 : options.headers) {
55
55
  __classPrivateFieldSet(this, _LemmyHttp_headers, options.headers, "f");
@@ -63,8 +63,8 @@ class LemmyHttp {
63
63
  *
64
64
  * `HTTP.GET /site`
65
65
  */
66
- getSite(form = {}) {
67
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/site", form);
66
+ getSite() {
67
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/site", {});
68
68
  }
69
69
  /**
70
70
  * Create your site.
@@ -87,8 +87,63 @@ class LemmyHttp {
87
87
  *
88
88
  * `HTTP.POST /user/leave_admin`
89
89
  */
90
- leaveAdmin(form) {
91
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/leave_admin", form);
90
+ leaveAdmin() {
91
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/leave_admin", {});
92
+ }
93
+ /**
94
+ * Generate a TOTP / two-factor secret.
95
+ *
96
+ * Afterwards you need to call `/user/totp/update` with a valid token to enable it.
97
+ *
98
+ * `HTTP.POST /user/totp/generate`
99
+ */
100
+ generateTotpSecret() {
101
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/totp/generate", {});
102
+ }
103
+ /**
104
+ * Export a backup of your user settings, including your saved content,
105
+ * followed communities, and blocks.
106
+ *
107
+ * `HTTP.GET /user/export_settings`
108
+ */
109
+ exportSettings() {
110
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/export_settings", {});
111
+ }
112
+ /**
113
+ * Import a backup of your user settings.
114
+ *
115
+ * `HTTP.POST /user/import_settings`
116
+ */
117
+ importSettings(form) {
118
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/import_settings", form);
119
+ }
120
+ /**
121
+ * List login tokens for your user
122
+ *
123
+ * `HTTP.GET /user/list_logins`
124
+ */
125
+ listLogins() {
126
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/list_logins", {});
127
+ }
128
+ /**
129
+ * Returns an error message if your auth token is invalid
130
+ *
131
+ * `HTTP.GET /user/validate_auth`
132
+ */
133
+ validateAuth() {
134
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/validate_auth", {});
135
+ }
136
+ /**
137
+ * Enable / Disable TOTP / two-factor authentication.
138
+ *
139
+ * To enable, you need to first call `/user/totp/generate` and then pass a valid token to this.
140
+ *
141
+ * Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.
142
+ *
143
+ * `HTTP.POST /user/totp/update`
144
+ */
145
+ updateTotp(form) {
146
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/totp/update", form);
92
147
  }
93
148
  /**
94
149
  * Get the modlog.
@@ -170,6 +225,14 @@ class LemmyHttp {
170
225
  deleteCommunity(form) {
171
226
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/delete", form);
172
227
  }
228
+ /**
229
+ * Hide a community from public / "All" view. Admins only.
230
+ *
231
+ * `HTTP.PUT /community/hide`
232
+ */
233
+ hideCommunity(form) {
234
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/community/hide", form);
235
+ }
173
236
  /**
174
237
  * A moderator remove for a community.
175
238
  *
@@ -282,6 +345,14 @@ class LemmyHttp {
282
345
  likePost(form) {
283
346
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/like", form);
284
347
  }
348
+ /**
349
+ * List a post's likes. Admin-only.
350
+ *
351
+ * `HTTP.GET /post/like`
352
+ */
353
+ listPostLikes(form) {
354
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/like/list", form);
355
+ }
285
356
  /**
286
357
  * Save a post.
287
358
  *
@@ -370,6 +441,14 @@ class LemmyHttp {
370
441
  likeComment(form) {
371
442
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/like", form);
372
443
  }
444
+ /**
445
+ * List a comment's likes. Admin-only.
446
+ *
447
+ * `HTTP.GET //like`
448
+ */
449
+ listCommentLikes(form) {
450
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment/like/list", form);
451
+ }
373
452
  /**
374
453
  * Save a comment.
375
454
  *
@@ -506,6 +585,9 @@ class LemmyHttp {
506
585
  login(form) {
507
586
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/login", form);
508
587
  }
588
+ logout() {
589
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/logout", {});
590
+ }
509
591
  /**
510
592
  * Get the details for a person.
511
593
  *
@@ -551,8 +633,8 @@ class LemmyHttp {
551
633
  *
552
634
  * `HTTP.GET /user/banned`
553
635
  */
554
- getBannedPersons(form) {
555
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/banned", form);
636
+ getBannedPersons() {
637
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/banned", {});
556
638
  }
557
639
  /**
558
640
  * Block a person.
@@ -567,8 +649,8 @@ class LemmyHttp {
567
649
  *
568
650
  * `HTTP.GET /user/get_captcha`
569
651
  */
570
- getCaptcha(form = {}) {
571
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/get_captcha", form);
652
+ getCaptcha() {
653
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/get_captcha", {});
572
654
  }
573
655
  /**
574
656
  * Delete your account.
@@ -599,8 +681,8 @@ class LemmyHttp {
599
681
  *
600
682
  * `HTTP.POST /user/mark_all_as_read`
601
683
  */
602
- markAllAsRead(form) {
603
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mark_all_as_read", form);
684
+ markAllAsRead() {
685
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mark_all_as_read", {});
604
686
  }
605
687
  /**
606
688
  * Save your user settings.
@@ -631,8 +713,8 @@ class LemmyHttp {
631
713
  *
632
714
  * `HTTP.GET /user/unread_count`
633
715
  */
634
- getUnreadCount(form) {
635
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/unread_count", form);
716
+ getUnreadCount() {
717
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/unread_count", {});
636
718
  }
637
719
  /**
638
720
  * Verify your email
@@ -655,8 +737,8 @@ class LemmyHttp {
655
737
  *
656
738
  * `HTTP.GET /admin/registration_application/count`
657
739
  */
658
- getUnreadRegistrationApplicationCount(form) {
659
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/count", form);
740
+ getUnreadRegistrationApplicationCount() {
741
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/count", {});
660
742
  }
661
743
  /**
662
744
  * List the registration applications.
@@ -735,13 +817,13 @@ class LemmyHttp {
735
817
  *
736
818
  * `HTTP.Get /federated_instances`
737
819
  */
738
- getFederatedInstances(form = {}) {
739
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", form);
820
+ getFederatedInstances() {
821
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", {});
740
822
  }
741
823
  /**
742
- * Block an instance
824
+ * Block an instance.
743
825
  *
744
- * `HTTP.POST /site/block`
826
+ * `HTTP.Post /site/block`
745
827
  */
746
828
  blockInstance(form) {
747
829
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/site/block", form);
@@ -749,22 +831,15 @@ class LemmyHttp {
749
831
  /**
750
832
  * Upload an image to the server.
751
833
  */
752
- uploadImage({ image, auth, }) {
753
- var _a, _b, _c, _d;
834
+ uploadImage({ image }) {
754
835
  return __awaiter(this, void 0, void 0, function* () {
755
836
  const formData = createFormData(image);
756
- // If jwt cookie not already set by browser, set it with passed in auth
757
- const headers = {};
758
- if (!((_b = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) === null || _a === void 0 ? void 0 : _a.cookie) === null || _b === void 0 ? void 0 : _b.includes("jwt=")) &&
759
- !((_d = (_c = __classPrivateFieldGet(this, _LemmyHttp_headers, "f")) === null || _c === void 0 ? void 0 : _c.Cookie) === null || _d === void 0 ? void 0 : _d.includes("jwt="))) {
760
- headers.Cookie = `jwt=${auth}`;
761
- }
762
837
  let url = undefined;
763
838
  let delete_url = undefined;
764
839
  const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), {
765
840
  method: HttpType.Post,
766
841
  body: formData,
767
- headers: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")), headers),
842
+ headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
768
843
  });
769
844
  if (response.status === 413) {
770
845
  return { msg: "too_large" };
@@ -779,6 +854,19 @@ class LemmyHttp {
779
854
  delete_url });
780
855
  });
781
856
  }
857
+ /**
858
+ * Delete a pictrs image
859
+ */
860
+ deleteImage({ token, filename }) {
861
+ return __awaiter(this, void 0, void 0, function* () {
862
+ const deleteUrl = `${__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f")}/delete/${token}/${filename}`;
863
+ const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, deleteUrl, {
864
+ method: HttpType.Get,
865
+ headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
866
+ });
867
+ return response.status == 204;
868
+ });
869
+ }
782
870
  /**
783
871
  * Set the headers (can be used to set the auth header)
784
872
  */
@@ -812,10 +900,10 @@ _LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHtt
812
900
  json = yield response.json();
813
901
  }
814
902
  catch (error) {
815
- throw response.statusText;
903
+ throw new Error(response.statusText);
816
904
  }
817
905
  if (!response.ok) {
818
- throw (_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText;
906
+ throw new Error((_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText);
819
907
  }
820
908
  else {
821
909
  return json;