lemmy-js-client 0.19.0-rc.9 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. package/dist/http.d.ts +83 -33
  2. package/dist/http.js +103 -31
  3. package/dist/index.d.ts +11 -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/ListCommentReports.d.ts +0 -1
  66. package/dist/types/ListCommunities.d.ts +0 -1
  67. package/dist/types/ListPostReports.d.ts +0 -1
  68. package/dist/types/ListPrivateMessageReports.d.ts +0 -1
  69. package/dist/types/ListRegistrationApplications.d.ts +0 -1
  70. package/dist/types/LocalSite.d.ts +1 -0
  71. package/dist/types/LocalSiteRateLimit.d.ts +2 -1
  72. package/dist/types/LocalUser.d.ts +4 -3
  73. package/dist/types/LockPost.d.ts +0 -1
  74. package/dist/types/LoginToken.d.ts +7 -0
  75. package/dist/types/MarkCommentReplyAsRead.d.ts +0 -1
  76. package/dist/types/MarkPersonMentionAsRead.d.ts +0 -1
  77. package/dist/types/MarkPostAsRead.d.ts +2 -2
  78. package/dist/types/MarkPrivateMessageAsRead.d.ts +0 -1
  79. package/dist/types/ModRemoveCommunity.d.ts +0 -1
  80. package/dist/types/PaginationCursor.d.ts +1 -0
  81. package/dist/types/Person.d.ts +0 -1
  82. package/dist/types/PersonAggregates.d.ts +0 -3
  83. package/dist/types/PersonMentionView.d.ts +2 -0
  84. package/dist/types/PersonView.d.ts +1 -0
  85. package/dist/types/PostAggregates.d.ts +0 -14
  86. package/dist/types/PostView.d.ts +2 -0
  87. package/dist/types/PurgeComment.d.ts +0 -1
  88. package/dist/types/PurgeCommunity.d.ts +0 -1
  89. package/dist/types/PurgePerson.d.ts +0 -1
  90. package/dist/types/PurgePost.d.ts +0 -1
  91. package/dist/types/ReadableFederationState.d.ts +10 -0
  92. package/dist/types/RemoveComment.d.ts +0 -1
  93. package/dist/types/RemoveCommunity.d.ts +0 -2
  94. package/dist/types/RemovePost.d.ts +0 -1
  95. package/dist/types/ResolveCommentReport.d.ts +0 -1
  96. package/dist/types/ResolveObject.d.ts +0 -1
  97. package/dist/types/ResolvePostReport.d.ts +0 -1
  98. package/dist/types/ResolvePrivateMessageReport.d.ts +0 -1
  99. package/dist/types/SaveComment.d.ts +0 -1
  100. package/dist/types/SavePost.d.ts +0 -1
  101. package/dist/types/SaveUserSettings.d.ts +5 -3
  102. package/dist/types/Search.d.ts +0 -1
  103. package/dist/types/SiteAggregates.d.ts +0 -1
  104. package/dist/types/SortType.d.ts +1 -1
  105. package/dist/types/SuccessResponse.d.ts +3 -0
  106. package/dist/types/TransferCommunity.d.ts +0 -1
  107. package/dist/types/UpdateTotp.d.ts +4 -0
  108. package/dist/types/UpdateTotpResponse.d.ts +3 -0
  109. package/package.json +12 -12
  110. package/dist/types/CommunityBlockId.d.ts +0 -1
  111. package/dist/types/CommunityJoin.d.ts +0 -4
  112. package/dist/types/CommunityJoinResponse.d.ts +0 -3
  113. package/dist/types/DeleteAccountResponse.d.ts +0 -1
  114. package/dist/types/DeleteCustomEmojiResponse.d.ts +0 -5
  115. package/dist/types/GetBannedPersons.d.ts +0 -3
  116. package/dist/types/GetCaptcha.d.ts +0 -3
  117. package/dist/types/GetFederatedInstances.d.ts +0 -3
  118. package/dist/types/GetSite.d.ts +0 -3
  119. package/dist/types/GetSite.js +0 -3
  120. package/dist/types/GetUnreadCount.d.ts +0 -3
  121. package/dist/types/GetUnreadCount.js +0 -3
  122. package/dist/types/GetUnreadRegistrationApplicationCount.d.ts +0 -3
  123. package/dist/types/GetUnreadRegistrationApplicationCount.js +0 -3
  124. package/dist/types/LeaveAdmin.d.ts +0 -3
  125. package/dist/types/LeaveAdmin.js +0 -3
  126. package/dist/types/MarkAllAsRead.d.ts +0 -3
  127. package/dist/types/MarkAllAsRead.js +0 -3
  128. package/dist/types/ModJoin.d.ts +0 -4
  129. package/dist/types/ModJoinResponse.d.ts +0 -3
  130. package/dist/types/ModJoinResponse.js +0 -3
  131. package/dist/types/PasswordResetResponse.d.ts +0 -1
  132. package/dist/types/PasswordResetResponse.js +0 -3
  133. package/dist/types/PersonSortType.d.ts +0 -1
  134. package/dist/types/PersonSortType.js +0 -3
  135. package/dist/types/PostJoin.d.ts +0 -4
  136. package/dist/types/PostJoinResponse.d.ts +0 -3
  137. package/dist/types/PostJoinResponse.js +0 -3
  138. package/dist/types/PostOrCommentId.d.ts +0 -7
  139. package/dist/types/PostOrCommentId.js +0 -2
  140. package/dist/types/PurgeItemResponse.d.ts +0 -3
  141. package/dist/types/PurgeItemResponse.js +0 -3
  142. package/dist/types/UserJoin.d.ts +0 -3
  143. package/dist/types/UserJoin.js +0 -3
  144. package/dist/types/UserJoinResponse.d.ts +0 -3
  145. package/dist/types/UserJoinResponse.js +0 -3
  146. package/dist/types/VerifyEmailResponse.d.ts +0 -1
  147. package/dist/types/VerifyEmailResponse.js +0 -3
  148. package/dist/utils.d.ts +0 -0
  149. package/dist/utils.js +0 -0
  150. /package/dist/{types/others.js → other_types.js} +0 -0
  151. /package/dist/types/{CommunityBlockId.js → ActivityId.js} +0 -0
  152. /package/dist/types/{CommunityJoinResponse.js → GenerateTotpSecretResponse.js} +0 -0
  153. /package/dist/types/{CommunityJoin.js → ImageUpload.js} +0 -0
  154. /package/dist/types/{DeleteCustomEmojiResponse.js → InstanceWithFederationState.js} +0 -0
  155. /package/dist/types/{ModJoin.js → LoginToken.js} +0 -0
  156. /package/dist/types/{DeleteAccountResponse.js → PaginationCursor.js} +0 -0
  157. /package/dist/types/{PostJoin.js → ReadableFederationState.js} +0 -0
  158. /package/dist/types/{GetBannedPersons.js → SuccessResponse.js} +0 -0
  159. /package/dist/types/{GetCaptcha.js → UpdateTotp.js} +0 -0
  160. /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,15 @@ 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";
135
131
  /**
136
132
  * Helps build lemmy HTTP requests.
137
133
  */
@@ -153,7 +149,7 @@ export declare class LemmyHttp {
153
149
  *
154
150
  * `HTTP.GET /site`
155
151
  */
156
- getSite(form?: GetSite): Promise<GetSiteResponse>;
152
+ getSite(): Promise<GetSiteResponse>;
157
153
  /**
158
154
  * Create your site.
159
155
  *
@@ -171,7 +167,50 @@ export declare class LemmyHttp {
171
167
  *
172
168
  * `HTTP.POST /user/leave_admin`
173
169
  */
174
- leaveAdmin(form: LeaveAdmin): Promise<GetSiteResponse>;
170
+ leaveAdmin(): Promise<GetSiteResponse>;
171
+ /**
172
+ * Generate a TOTP / two-factor secret.
173
+ *
174
+ * Afterwards you need to call `/user/totp/update` with a valid token to enable it.
175
+ *
176
+ * `HTTP.POST /user/totp/generate`
177
+ */
178
+ generateTotpSecret(): Promise<GenerateTotpSecretResponse>;
179
+ /**
180
+ * Export a backup of your user settings, including your saved content,
181
+ * followed communities, and blocks.
182
+ *
183
+ * `HTTP.GET /user/export_settings`
184
+ */
185
+ exportSettings(): Promise<any>;
186
+ /**
187
+ * Import a backup of your user settings.
188
+ *
189
+ * `HTTP.POST /user/import_settings`
190
+ */
191
+ importSettings(form: any): Promise<SuccessResponse>;
192
+ /**
193
+ * List login tokens for your user
194
+ *
195
+ * `HTTP.GET /user/list_logins`
196
+ */
197
+ listLogins(): Promise<LoginToken[]>;
198
+ /**
199
+ * Returns an error message if your auth token is invalid
200
+ *
201
+ * `HTTP.GET /user/validate_auth`
202
+ */
203
+ validateAuth(): Promise<SuccessResponse>;
204
+ /**
205
+ * Enable / Disable TOTP / two-factor authentication.
206
+ *
207
+ * To enable, you need to first call `/user/totp/generate` and then pass a valid token to this.
208
+ *
209
+ * Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.
210
+ *
211
+ * `HTTP.POST /user/totp/update`
212
+ */
213
+ updateTotp(form: UpdateTotp): Promise<UpdateTotpResponse>;
175
214
  /**
176
215
  * Get the modlog.
177
216
  *
@@ -232,6 +271,12 @@ export declare class LemmyHttp {
232
271
  * `HTTP.POST /community/delete`
233
272
  */
234
273
  deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse>;
274
+ /**
275
+ * Hide a community from public / "All" view. Admins only.
276
+ *
277
+ * `HTTP.PUT /community/hide`
278
+ */
279
+ hideCommunity(form: HideCommunity): Promise<SuccessResponse>;
235
280
  /**
236
281
  * A moderator remove for a community.
237
282
  *
@@ -291,7 +336,7 @@ export declare class LemmyHttp {
291
336
  *
292
337
  * `HTTP.POST /post/mark_as_read`
293
338
  */
294
- markPostAsRead(form: MarkPostAsRead): Promise<PostResponse>;
339
+ markPostAsRead(form: MarkPostAsRead): Promise<SuccessResponse>;
295
340
  /**
296
341
  * A moderator can lock a post ( IE disable new comments ).
297
342
  *
@@ -484,6 +529,7 @@ export declare class LemmyHttp {
484
529
  * `HTTP.POST /user/login`
485
530
  */
486
531
  login(form: Login): Promise<LoginResponse>;
532
+ logout(): Promise<SuccessResponse>;
487
533
  /**
488
534
  * Get the details for a person.
489
535
  *
@@ -519,7 +565,7 @@ export declare class LemmyHttp {
519
565
  *
520
566
  * `HTTP.GET /user/banned`
521
567
  */
522
- getBannedPersons(form: GetBannedPersons): Promise<BannedPersonsResponse>;
568
+ getBannedPersons(): Promise<BannedPersonsResponse>;
523
569
  /**
524
570
  * Block a person.
525
571
  *
@@ -531,37 +577,37 @@ export declare class LemmyHttp {
531
577
  *
532
578
  * `HTTP.GET /user/get_captcha`
533
579
  */
534
- getCaptcha(form?: GetCaptcha): Promise<GetCaptchaResponse>;
580
+ getCaptcha(): Promise<GetCaptchaResponse>;
535
581
  /**
536
582
  * Delete your account.
537
583
  *
538
584
  * `HTTP.POST /user/delete_account`
539
585
  */
540
- deleteAccount(form: DeleteAccount): Promise<null>;
586
+ deleteAccount(form: DeleteAccount): Promise<SuccessResponse>;
541
587
  /**
542
588
  * Reset your password.
543
589
  *
544
590
  * `HTTP.POST /user/password_reset`
545
591
  */
546
- passwordReset(form: PasswordReset): Promise<null>;
592
+ passwordReset(form: PasswordReset): Promise<SuccessResponse>;
547
593
  /**
548
594
  * Change your password from an email / token based reset.
549
595
  *
550
596
  * `HTTP.POST /user/password_change`
551
597
  */
552
- passwordChangeAfterReset(form: PasswordChangeAfterReset): Promise<LoginResponse>;
598
+ passwordChangeAfterReset(form: PasswordChangeAfterReset): Promise<SuccessResponse>;
553
599
  /**
554
600
  * Mark all replies as read.
555
601
  *
556
602
  * `HTTP.POST /user/mark_all_as_read`
557
603
  */
558
- markAllAsRead(form: MarkAllAsRead): Promise<GetRepliesResponse>;
604
+ markAllAsRead(): Promise<GetRepliesResponse>;
559
605
  /**
560
606
  * Save your user settings.
561
607
  *
562
608
  * `HTTP.PUT /user/save_user_settings`
563
609
  */
564
- saveUserSettings(form: SaveUserSettings): Promise<LoginResponse>;
610
+ saveUserSettings(form: SaveUserSettings): Promise<SuccessResponse>;
565
611
  /**
566
612
  * Change your user password.
567
613
  *
@@ -579,13 +625,13 @@ export declare class LemmyHttp {
579
625
  *
580
626
  * `HTTP.GET /user/unread_count`
581
627
  */
582
- getUnreadCount(form: GetUnreadCount): Promise<GetUnreadCountResponse>;
628
+ getUnreadCount(): Promise<GetUnreadCountResponse>;
583
629
  /**
584
630
  * Verify your email
585
631
  *
586
632
  * `HTTP.POST /user/verify_email`
587
633
  */
588
- verifyEmail(form: VerifyEmail): Promise<null>;
634
+ verifyEmail(form: VerifyEmail): Promise<SuccessResponse>;
589
635
  /**
590
636
  * Add an admin to your site.
591
637
  *
@@ -597,7 +643,7 @@ export declare class LemmyHttp {
597
643
  *
598
644
  * `HTTP.GET /admin/registration_application/count`
599
645
  */
600
- getUnreadRegistrationApplicationCount(form: GetUnreadRegistrationApplicationCount): Promise<GetUnreadRegistrationApplicationCountResponse>;
646
+ getUnreadRegistrationApplicationCount(): Promise<GetUnreadRegistrationApplicationCountResponse>;
601
647
  /**
602
648
  * List the registration applications.
603
649
  *
@@ -615,25 +661,25 @@ export declare class LemmyHttp {
615
661
  *
616
662
  * `HTTP.POST /admin/purge/person`
617
663
  */
618
- purgePerson(form: PurgePerson): Promise<PurgeItemResponse>;
664
+ purgePerson(form: PurgePerson): Promise<SuccessResponse>;
619
665
  /**
620
666
  * Purge / Delete a community from the database.
621
667
  *
622
668
  * `HTTP.POST /admin/purge/community`
623
669
  */
624
- purgeCommunity(form: PurgeCommunity): Promise<PurgeItemResponse>;
670
+ purgeCommunity(form: PurgeCommunity): Promise<SuccessResponse>;
625
671
  /**
626
672
  * Purge / Delete a post from the database.
627
673
  *
628
674
  * `HTTP.POST /admin/purge/post`
629
675
  */
630
- purgePost(form: PurgePost): Promise<PurgeItemResponse>;
676
+ purgePost(form: PurgePost): Promise<SuccessResponse>;
631
677
  /**
632
678
  * Purge / Delete a comment from the database.
633
679
  *
634
680
  * `HTTP.POST /admin/purge/comment`
635
681
  */
636
- purgeComment(form: PurgeComment): Promise<PurgeItemResponse>;
682
+ purgeComment(form: PurgeComment): Promise<SuccessResponse>;
637
683
  /**
638
684
  * Create a new custom emoji
639
685
  *
@@ -651,23 +697,27 @@ export declare class LemmyHttp {
651
697
  *
652
698
  * `HTTP.Post /custom_emoji/delete`
653
699
  */
654
- deleteCustomEmoji(form: DeleteCustomEmoji): Promise<DeleteCustomEmojiResponse>;
700
+ deleteCustomEmoji(form: DeleteCustomEmoji): Promise<SuccessResponse>;
655
701
  /**
656
702
  * Fetch federated instances.
657
703
  *
658
704
  * `HTTP.Get /federated_instances`
659
705
  */
660
- getFederatedInstances(form?: GetFederatedInstances): Promise<GetFederatedInstancesResponse>;
706
+ getFederatedInstances(): Promise<GetFederatedInstancesResponse>;
661
707
  /**
662
- * Block an instance
708
+ * Block an instance.
663
709
  *
664
- * `HTTP.POST /site/block`
710
+ * `HTTP.Post /site/block`
665
711
  */
666
712
  blockInstance(form: BlockInstance): Promise<BlockInstanceResponse>;
667
713
  /**
668
714
  * Upload an image to the server.
669
715
  */
670
- uploadImage({ image, auth, }: UploadImage): Promise<UploadImageResponse>;
716
+ uploadImage({ image }: UploadImage): Promise<UploadImageResponse>;
717
+ /**
718
+ * Delete a pictrs image
719
+ */
720
+ deleteImage({ token, filename }: DeleteImage): Promise<boolean>;
671
721
  /**
672
722
  * Set the headers (can be used to set the auth header)
673
723
  */
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
  *
@@ -506,6 +569,9 @@ class LemmyHttp {
506
569
  login(form) {
507
570
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/login", form);
508
571
  }
572
+ logout() {
573
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/logout", {});
574
+ }
509
575
  /**
510
576
  * Get the details for a person.
511
577
  *
@@ -551,8 +617,8 @@ class LemmyHttp {
551
617
  *
552
618
  * `HTTP.GET /user/banned`
553
619
  */
554
- getBannedPersons(form) {
555
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/banned", form);
620
+ getBannedPersons() {
621
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/banned", {});
556
622
  }
557
623
  /**
558
624
  * Block a person.
@@ -567,8 +633,8 @@ class LemmyHttp {
567
633
  *
568
634
  * `HTTP.GET /user/get_captcha`
569
635
  */
570
- getCaptcha(form = {}) {
571
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/get_captcha", form);
636
+ getCaptcha() {
637
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/get_captcha", {});
572
638
  }
573
639
  /**
574
640
  * Delete your account.
@@ -599,8 +665,8 @@ class LemmyHttp {
599
665
  *
600
666
  * `HTTP.POST /user/mark_all_as_read`
601
667
  */
602
- markAllAsRead(form) {
603
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mark_all_as_read", form);
668
+ markAllAsRead() {
669
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mark_all_as_read", {});
604
670
  }
605
671
  /**
606
672
  * Save your user settings.
@@ -631,8 +697,8 @@ class LemmyHttp {
631
697
  *
632
698
  * `HTTP.GET /user/unread_count`
633
699
  */
634
- getUnreadCount(form) {
635
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/unread_count", form);
700
+ getUnreadCount() {
701
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/unread_count", {});
636
702
  }
637
703
  /**
638
704
  * Verify your email
@@ -655,8 +721,8 @@ class LemmyHttp {
655
721
  *
656
722
  * `HTTP.GET /admin/registration_application/count`
657
723
  */
658
- getUnreadRegistrationApplicationCount(form) {
659
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/count", form);
724
+ getUnreadRegistrationApplicationCount() {
725
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/count", {});
660
726
  }
661
727
  /**
662
728
  * List the registration applications.
@@ -735,13 +801,13 @@ class LemmyHttp {
735
801
  *
736
802
  * `HTTP.Get /federated_instances`
737
803
  */
738
- getFederatedInstances(form = {}) {
739
- return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", form);
804
+ getFederatedInstances() {
805
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", {});
740
806
  }
741
807
  /**
742
- * Block an instance
808
+ * Block an instance.
743
809
  *
744
- * `HTTP.POST /site/block`
810
+ * `HTTP.Post /site/block`
745
811
  */
746
812
  blockInstance(form) {
747
813
  return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/site/block", form);
@@ -749,22 +815,15 @@ class LemmyHttp {
749
815
  /**
750
816
  * Upload an image to the server.
751
817
  */
752
- uploadImage({ image, auth, }) {
753
- var _a, _b, _c, _d;
818
+ uploadImage({ image }) {
754
819
  return __awaiter(this, void 0, void 0, function* () {
755
820
  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
821
  let url = undefined;
763
822
  let delete_url = undefined;
764
823
  const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), {
765
824
  method: HttpType.Post,
766
825
  body: formData,
767
- headers: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")), headers),
826
+ headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
768
827
  });
769
828
  if (response.status === 413) {
770
829
  return { msg: "too_large" };
@@ -779,6 +838,19 @@ class LemmyHttp {
779
838
  delete_url });
780
839
  });
781
840
  }
841
+ /**
842
+ * Delete a pictrs image
843
+ */
844
+ deleteImage({ token, filename }) {
845
+ return __awaiter(this, void 0, void 0, function* () {
846
+ const deleteUrl = `${__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f")}/delete/${token}/${filename}`;
847
+ const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, deleteUrl, {
848
+ method: HttpType.Get,
849
+ headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
850
+ });
851
+ return response.status == 204;
852
+ });
853
+ }
782
854
  /**
783
855
  * Set the headers (can be used to set the auth header)
784
856
  */
@@ -812,10 +884,10 @@ _LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHtt
812
884
  json = yield response.json();
813
885
  }
814
886
  catch (error) {
815
- throw response.statusText;
887
+ throw new Error(response.statusText);
816
888
  }
817
889
  if (!response.ok) {
818
- throw (_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText;
890
+ throw new Error((_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText);
819
891
  }
820
892
  else {
821
893
  return json;