lemmy-js-client 0.19.0-rc.8 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http.d.ts +87 -15
- package/dist/http.js +99 -13
- package/dist/index.d.ts +14 -8
- package/dist/{types/others.d.ts → other_types.d.ts} +4 -4
- package/dist/types/ActivityId.d.ts +1 -0
- package/dist/types/BlockInstance.d.ts +5 -0
- package/dist/types/BlockInstanceResponse.d.ts +3 -0
- package/dist/types/CommentAggregates.d.ts +0 -3
- package/dist/types/CommentReplyView.d.ts +2 -0
- package/dist/types/CommentView.d.ts +2 -0
- package/dist/types/Community.d.ts +0 -2
- package/dist/types/CommunityAggregates.d.ts +0 -2
- package/dist/types/CustomEmojiKeyword.d.ts +0 -1
- package/dist/types/FederatedInstances.d.ts +4 -4
- package/dist/types/GenerateTotpSecretResponse.d.ts +3 -0
- package/dist/types/GetPosts.d.ts +2 -0
- package/dist/types/GetPostsResponse.d.ts +2 -0
- package/dist/types/ImageUpload.d.ts +0 -2
- package/dist/types/InstanceBlockView.d.ts +8 -0
- package/dist/types/InstanceBlockView.js +2 -0
- package/dist/types/InstanceWithFederationState.d.ts +11 -0
- package/dist/types/InstanceWithFederationState.js +2 -0
- package/dist/types/LemmyErrorType.d.ts +171 -138
- package/dist/types/LocalSite.d.ts +1 -0
- package/dist/types/LocalSiteRateLimit.d.ts +2 -1
- package/dist/types/LocalUser.d.ts +4 -3
- package/dist/types/LoginToken.d.ts +7 -0
- package/dist/types/LoginToken.js +2 -0
- package/dist/types/MarkPostAsRead.d.ts +2 -1
- package/dist/types/ModRemoveCommunity.d.ts +0 -1
- package/dist/types/MyUserInfo.d.ts +2 -0
- package/dist/types/PaginationCursor.d.ts +1 -0
- package/dist/types/Person.d.ts +0 -1
- package/dist/types/PersonAggregates.d.ts +0 -3
- package/dist/types/PersonMentionView.d.ts +2 -0
- package/dist/types/PersonView.d.ts +1 -0
- package/dist/types/PostAggregates.d.ts +0 -12
- package/dist/types/PostView.d.ts +2 -0
- package/dist/types/ReadableFederationState.d.ts +10 -0
- package/dist/types/ReadableFederationState.js +2 -0
- package/dist/types/RemoveCommunity.d.ts +0 -1
- package/dist/types/SaveUserSettings.d.ts +5 -2
- package/dist/types/SiteAggregates.d.ts +0 -1
- package/dist/types/SortType.d.ts +1 -1
- package/dist/types/SuccessResponse.d.ts +3 -0
- package/dist/types/UpdateTotp.d.ts +4 -0
- package/dist/types/UpdateTotpResponse.d.ts +3 -0
- package/package.json +12 -12
- package/dist/types/CommunityBlockId.d.ts +0 -1
- package/dist/types/DeleteAccountResponse.d.ts +0 -1
- package/dist/types/DeleteCustomEmojiResponse.d.ts +0 -5
- package/dist/types/ImageUploadId.d.ts +0 -1
- package/dist/types/PasswordResetResponse.d.ts +0 -1
- package/dist/types/PersonSortType.d.ts +0 -1
- package/dist/types/PurgeItemResponse.d.ts +0 -3
- package/dist/types/VerifyEmailResponse.d.ts +0 -1
- package/dist/utils.d.ts +0 -0
- package/dist/utils.js +0 -0
- /package/dist/{types/others.js → other_types.js} +0 -0
- /package/dist/types/{CommunityBlockId.js → ActivityId.js} +0 -0
- /package/dist/types/{DeleteCustomEmojiResponse.js → BlockInstance.js} +0 -0
- /package/dist/types/{DeleteAccountResponse.js → BlockInstanceResponse.js} +0 -0
- /package/dist/types/{ImageUploadId.js → GenerateTotpSecretResponse.js} +0 -0
- /package/dist/types/{PasswordResetResponse.js → PaginationCursor.js} +0 -0
- /package/dist/types/{PersonSortType.js → SuccessResponse.js} +0 -0
- /package/dist/types/{PurgeItemResponse.js → UpdateTotp.js} +0 -0
- /package/dist/types/{VerifyEmailResponse.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";
|
@@ -100,7 +99,6 @@ import { PrivateMessageResponse } from "./types/PrivateMessageResponse";
|
|
100
99
|
import { PrivateMessagesResponse } from "./types/PrivateMessagesResponse";
|
101
100
|
import { PurgeComment } from "./types/PurgeComment";
|
102
101
|
import { PurgeCommunity } from "./types/PurgeCommunity";
|
103
|
-
import { PurgeItemResponse } from "./types/PurgeItemResponse";
|
104
102
|
import { PurgePerson } from "./types/PurgePerson";
|
105
103
|
import { PurgePost } from "./types/PurgePost";
|
106
104
|
import { Register } from "./types/Register";
|
@@ -121,7 +119,15 @@ import { SearchResponse } from "./types/SearchResponse";
|
|
121
119
|
import { SiteResponse } from "./types/SiteResponse";
|
122
120
|
import { TransferCommunity } from "./types/TransferCommunity";
|
123
121
|
import { VerifyEmail } from "./types/VerifyEmail";
|
124
|
-
import { UploadImage, UploadImageResponse } from "./
|
122
|
+
import { DeleteImage, UploadImage, UploadImageResponse } from "./other_types";
|
123
|
+
import { HideCommunity } from "./types/HideCommunity";
|
124
|
+
import { BlockInstance } from "./types/BlockInstance";
|
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";
|
125
131
|
/**
|
126
132
|
* Helps build lemmy HTTP requests.
|
127
133
|
*/
|
@@ -162,6 +168,49 @@ export declare class LemmyHttp {
|
|
162
168
|
* `HTTP.POST /user/leave_admin`
|
163
169
|
*/
|
164
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>;
|
165
214
|
/**
|
166
215
|
* Get the modlog.
|
167
216
|
*
|
@@ -222,6 +271,12 @@ export declare class LemmyHttp {
|
|
222
271
|
* `HTTP.POST /community/delete`
|
223
272
|
*/
|
224
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>;
|
225
280
|
/**
|
226
281
|
* A moderator remove for a community.
|
227
282
|
*
|
@@ -281,7 +336,7 @@ export declare class LemmyHttp {
|
|
281
336
|
*
|
282
337
|
* `HTTP.POST /post/mark_as_read`
|
283
338
|
*/
|
284
|
-
markPostAsRead(form: MarkPostAsRead): Promise<
|
339
|
+
markPostAsRead(form: MarkPostAsRead): Promise<SuccessResponse>;
|
285
340
|
/**
|
286
341
|
* A moderator can lock a post ( IE disable new comments ).
|
287
342
|
*
|
@@ -474,6 +529,7 @@ export declare class LemmyHttp {
|
|
474
529
|
* `HTTP.POST /user/login`
|
475
530
|
*/
|
476
531
|
login(form: Login): Promise<LoginResponse>;
|
532
|
+
logout(): Promise<SuccessResponse>;
|
477
533
|
/**
|
478
534
|
* Get the details for a person.
|
479
535
|
*
|
@@ -527,19 +583,19 @@ export declare class LemmyHttp {
|
|
527
583
|
*
|
528
584
|
* `HTTP.POST /user/delete_account`
|
529
585
|
*/
|
530
|
-
deleteAccount(form: DeleteAccount): Promise<
|
586
|
+
deleteAccount(form: DeleteAccount): Promise<SuccessResponse>;
|
531
587
|
/**
|
532
588
|
* Reset your password.
|
533
589
|
*
|
534
590
|
* `HTTP.POST /user/password_reset`
|
535
591
|
*/
|
536
|
-
passwordReset(form: PasswordReset): Promise<
|
592
|
+
passwordReset(form: PasswordReset): Promise<SuccessResponse>;
|
537
593
|
/**
|
538
594
|
* Change your password from an email / token based reset.
|
539
595
|
*
|
540
596
|
* `HTTP.POST /user/password_change`
|
541
597
|
*/
|
542
|
-
passwordChangeAfterReset(form: PasswordChangeAfterReset): Promise<
|
598
|
+
passwordChangeAfterReset(form: PasswordChangeAfterReset): Promise<SuccessResponse>;
|
543
599
|
/**
|
544
600
|
* Mark all replies as read.
|
545
601
|
*
|
@@ -551,7 +607,7 @@ export declare class LemmyHttp {
|
|
551
607
|
*
|
552
608
|
* `HTTP.PUT /user/save_user_settings`
|
553
609
|
*/
|
554
|
-
saveUserSettings(form: SaveUserSettings): Promise<
|
610
|
+
saveUserSettings(form: SaveUserSettings): Promise<SuccessResponse>;
|
555
611
|
/**
|
556
612
|
* Change your user password.
|
557
613
|
*
|
@@ -575,7 +631,7 @@ export declare class LemmyHttp {
|
|
575
631
|
*
|
576
632
|
* `HTTP.POST /user/verify_email`
|
577
633
|
*/
|
578
|
-
verifyEmail(form: VerifyEmail): Promise<
|
634
|
+
verifyEmail(form: VerifyEmail): Promise<SuccessResponse>;
|
579
635
|
/**
|
580
636
|
* Add an admin to your site.
|
581
637
|
*
|
@@ -605,25 +661,25 @@ export declare class LemmyHttp {
|
|
605
661
|
*
|
606
662
|
* `HTTP.POST /admin/purge/person`
|
607
663
|
*/
|
608
|
-
purgePerson(form: PurgePerson): Promise<
|
664
|
+
purgePerson(form: PurgePerson): Promise<SuccessResponse>;
|
609
665
|
/**
|
610
666
|
* Purge / Delete a community from the database.
|
611
667
|
*
|
612
668
|
* `HTTP.POST /admin/purge/community`
|
613
669
|
*/
|
614
|
-
purgeCommunity(form: PurgeCommunity): Promise<
|
670
|
+
purgeCommunity(form: PurgeCommunity): Promise<SuccessResponse>;
|
615
671
|
/**
|
616
672
|
* Purge / Delete a post from the database.
|
617
673
|
*
|
618
674
|
* `HTTP.POST /admin/purge/post`
|
619
675
|
*/
|
620
|
-
purgePost(form: PurgePost): Promise<
|
676
|
+
purgePost(form: PurgePost): Promise<SuccessResponse>;
|
621
677
|
/**
|
622
678
|
* Purge / Delete a comment from the database.
|
623
679
|
*
|
624
680
|
* `HTTP.POST /admin/purge/comment`
|
625
681
|
*/
|
626
|
-
purgeComment(form: PurgeComment): Promise<
|
682
|
+
purgeComment(form: PurgeComment): Promise<SuccessResponse>;
|
627
683
|
/**
|
628
684
|
* Create a new custom emoji
|
629
685
|
*
|
@@ -641,15 +697,31 @@ export declare class LemmyHttp {
|
|
641
697
|
*
|
642
698
|
* `HTTP.Post /custom_emoji/delete`
|
643
699
|
*/
|
644
|
-
deleteCustomEmoji(form: DeleteCustomEmoji): Promise<
|
700
|
+
deleteCustomEmoji(form: DeleteCustomEmoji): Promise<SuccessResponse>;
|
645
701
|
/**
|
646
702
|
* Fetch federated instances.
|
647
703
|
*
|
648
704
|
* `HTTP.Get /federated_instances`
|
649
705
|
*/
|
650
706
|
getFederatedInstances(): Promise<GetFederatedInstancesResponse>;
|
707
|
+
/**
|
708
|
+
* Block an instance.
|
709
|
+
*
|
710
|
+
* `HTTP.Post /site/block`
|
711
|
+
*/
|
712
|
+
blockInstance(form: BlockInstance): Promise<BlockInstanceResponse>;
|
651
713
|
/**
|
652
714
|
* Upload an image to the server.
|
653
715
|
*/
|
654
|
-
uploadImage({ image
|
716
|
+
uploadImage({ image }: UploadImage): Promise<UploadImageResponse>;
|
717
|
+
/**
|
718
|
+
* Delete a pictrs image
|
719
|
+
*/
|
720
|
+
deleteImage({ token, filename }: DeleteImage): Promise<boolean>;
|
721
|
+
/**
|
722
|
+
* Set the headers (can be used to set the auth header)
|
723
|
+
*/
|
724
|
+
setHeaders(headers: {
|
725
|
+
[key: string]: string;
|
726
|
+
}): void;
|
655
727
|
}
|
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
|
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/${
|
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");
|
@@ -90,6 +90,61 @@ class LemmyHttp {
|
|
90
90
|
leaveAdmin() {
|
91
91
|
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/leave_admin", {});
|
92
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);
|
147
|
+
}
|
93
148
|
/**
|
94
149
|
* Get the modlog.
|
95
150
|
*
|
@@ -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
|
*
|
@@ -738,25 +804,26 @@ class LemmyHttp {
|
|
738
804
|
getFederatedInstances() {
|
739
805
|
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", {});
|
740
806
|
}
|
807
|
+
/**
|
808
|
+
* Block an instance.
|
809
|
+
*
|
810
|
+
* `HTTP.Post /site/block`
|
811
|
+
*/
|
812
|
+
blockInstance(form) {
|
813
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/site/block", form);
|
814
|
+
}
|
741
815
|
/**
|
742
816
|
* Upload an image to the server.
|
743
817
|
*/
|
744
|
-
uploadImage({ image
|
745
|
-
var _a, _b, _c, _d;
|
818
|
+
uploadImage({ image }) {
|
746
819
|
return __awaiter(this, void 0, void 0, function* () {
|
747
820
|
const formData = createFormData(image);
|
748
|
-
// If jwt cookie not already set by browser, set it with passed in auth
|
749
|
-
const headers = {};
|
750
|
-
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=")) &&
|
751
|
-
!((_d = (_c = __classPrivateFieldGet(this, _LemmyHttp_headers, "f")) === null || _c === void 0 ? void 0 : _c.Cookie) === null || _d === void 0 ? void 0 : _d.includes("jwt="))) {
|
752
|
-
headers.Cookie = `jwt=${auth}`;
|
753
|
-
}
|
754
821
|
let url = undefined;
|
755
822
|
let delete_url = undefined;
|
756
823
|
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), {
|
757
824
|
method: HttpType.Post,
|
758
825
|
body: formData,
|
759
|
-
headers:
|
826
|
+
headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
|
760
827
|
});
|
761
828
|
if (response.status === 413) {
|
762
829
|
return { msg: "too_large" };
|
@@ -771,6 +838,25 @@ class LemmyHttp {
|
|
771
838
|
delete_url });
|
772
839
|
});
|
773
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
|
+
}
|
854
|
+
/**
|
855
|
+
* Set the headers (can be used to set the auth header)
|
856
|
+
*/
|
857
|
+
setHeaders(headers) {
|
858
|
+
__classPrivateFieldSet(this, _LemmyHttp_headers, headers, "f");
|
859
|
+
}
|
774
860
|
}
|
775
861
|
exports.LemmyHttp = LemmyHttp;
|
776
862
|
_LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHttp_pictrsUrl = new WeakMap(), _LemmyHttp_fetchFunction = new WeakMap(), _LemmyHttp_instances = new WeakSet(), _LemmyHttp_buildFullUrl = function _LemmyHttp_buildFullUrl(endpoint) {
|
@@ -798,10 +884,10 @@ _LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHtt
|
|
798
884
|
json = yield response.json();
|
799
885
|
}
|
800
886
|
catch (error) {
|
801
|
-
throw response.statusText;
|
887
|
+
throw new Error(response.statusText);
|
802
888
|
}
|
803
889
|
if (!response.ok) {
|
804
|
-
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);
|
805
891
|
}
|
806
892
|
else {
|
807
893
|
return json;
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "./http";
|
2
|
+
export { ActivityId } from "./types/ActivityId";
|
2
3
|
export { AddAdmin } from "./types/AddAdmin";
|
3
4
|
export { AddAdminResponse } from "./types/AddAdminResponse";
|
4
5
|
export { AddModToCommunity } from "./types/AddModToCommunity";
|
@@ -19,6 +20,8 @@ export { BanPersonResponse } from "./types/BanPersonResponse";
|
|
19
20
|
export { BannedPersonsResponse } from "./types/BannedPersonsResponse";
|
20
21
|
export { BlockCommunity } from "./types/BlockCommunity";
|
21
22
|
export { BlockCommunityResponse } from "./types/BlockCommunityResponse";
|
23
|
+
export { BlockInstance } from "./types/BlockInstance";
|
24
|
+
export { BlockInstanceResponse } from "./types/BlockInstanceResponse";
|
22
25
|
export { BlockPerson } from "./types/BlockPerson";
|
23
26
|
export { BlockPersonResponse } from "./types/BlockPersonResponse";
|
24
27
|
export { CaptchaResponse } from "./types/CaptchaResponse";
|
@@ -39,7 +42,6 @@ export { CommentSortType } from "./types/CommentSortType";
|
|
39
42
|
export { CommentView } from "./types/CommentView";
|
40
43
|
export { Community } from "./types/Community";
|
41
44
|
export { CommunityAggregates } from "./types/CommunityAggregates";
|
42
|
-
export { CommunityBlockId } from "./types/CommunityBlockId";
|
43
45
|
export { CommunityBlockView } from "./types/CommunityBlockView";
|
44
46
|
export { CommunityFollowerView } from "./types/CommunityFollowerView";
|
45
47
|
export { CommunityId } from "./types/CommunityId";
|
@@ -63,11 +65,9 @@ export { CustomEmojiKeyword } from "./types/CustomEmojiKeyword";
|
|
63
65
|
export { CustomEmojiResponse } from "./types/CustomEmojiResponse";
|
64
66
|
export { CustomEmojiView } from "./types/CustomEmojiView";
|
65
67
|
export { DeleteAccount } from "./types/DeleteAccount";
|
66
|
-
export { DeleteAccountResponse } from "./types/DeleteAccountResponse";
|
67
68
|
export { DeleteComment } from "./types/DeleteComment";
|
68
69
|
export { DeleteCommunity } from "./types/DeleteCommunity";
|
69
70
|
export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
|
70
|
-
export { DeleteCustomEmojiResponse } from "./types/DeleteCustomEmojiResponse";
|
71
71
|
export { DeletePost } from "./types/DeletePost";
|
72
72
|
export { DeletePrivateMessage } from "./types/DeletePrivateMessage";
|
73
73
|
export { DistinguishComment } from "./types/DistinguishComment";
|
@@ -80,6 +80,7 @@ export { EditSite } from "./types/EditSite";
|
|
80
80
|
export { FeaturePost } from "./types/FeaturePost";
|
81
81
|
export { FederatedInstances } from "./types/FederatedInstances";
|
82
82
|
export { FollowCommunity } from "./types/FollowCommunity";
|
83
|
+
export { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
|
83
84
|
export { GetCaptchaResponse } from "./types/GetCaptchaResponse";
|
84
85
|
export { GetComment } from "./types/GetComment";
|
85
86
|
export { GetComments } from "./types/GetComments";
|
@@ -109,11 +110,13 @@ export { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
|
|
109
110
|
export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
|
110
111
|
export { HideCommunity } from "./types/HideCommunity";
|
111
112
|
export { ImageUpload } from "./types/ImageUpload";
|
112
|
-
export { ImageUploadId } from "./types/ImageUploadId";
|
113
113
|
export { Instance } from "./types/Instance";
|
114
|
+
export { InstanceBlockView } from "./types/InstanceBlockView";
|
114
115
|
export { InstanceId } from "./types/InstanceId";
|
116
|
+
export { InstanceWithFederationState } from "./types/InstanceWithFederationState";
|
115
117
|
export { Language } from "./types/Language";
|
116
118
|
export { LanguageId } from "./types/LanguageId";
|
119
|
+
export { LemmyErrorType } from "./types/LemmyErrorType";
|
117
120
|
export { ListCommentReports } from "./types/ListCommentReports";
|
118
121
|
export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
|
119
122
|
export { ListCommunities } from "./types/ListCommunities";
|
@@ -134,6 +137,7 @@ export { LocalUserView } from "./types/LocalUserView";
|
|
134
137
|
export { LockPost } from "./types/LockPost";
|
135
138
|
export { Login } from "./types/Login";
|
136
139
|
export { LoginResponse } from "./types/LoginResponse";
|
140
|
+
export { LoginToken } from "./types/LoginToken";
|
137
141
|
export { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
|
138
142
|
export { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
|
139
143
|
export { MarkPostAsRead } from "./types/MarkPostAsRead";
|
@@ -163,9 +167,9 @@ export { ModTransferCommunityView } from "./types/ModTransferCommunityView";
|
|
163
167
|
export { ModlogActionType } from "./types/ModlogActionType";
|
164
168
|
export { ModlogListParams } from "./types/ModlogListParams";
|
165
169
|
export { MyUserInfo } from "./types/MyUserInfo";
|
170
|
+
export { PaginationCursor } from "./types/PaginationCursor";
|
166
171
|
export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset";
|
167
172
|
export { PasswordReset } from "./types/PasswordReset";
|
168
|
-
export { PasswordResetResponse } from "./types/PasswordResetResponse";
|
169
173
|
export { Person } from "./types/Person";
|
170
174
|
export { PersonAggregates } from "./types/PersonAggregates";
|
171
175
|
export { PersonBlockId } from "./types/PersonBlockId";
|
@@ -175,7 +179,6 @@ export { PersonMention } from "./types/PersonMention";
|
|
175
179
|
export { PersonMentionId } from "./types/PersonMentionId";
|
176
180
|
export { PersonMentionResponse } from "./types/PersonMentionResponse";
|
177
181
|
export { PersonMentionView } from "./types/PersonMentionView";
|
178
|
-
export { PersonSortType } from "./types/PersonSortType";
|
179
182
|
export { PersonView } from "./types/PersonView";
|
180
183
|
export { Post } from "./types/Post";
|
181
184
|
export { PostAggregates } from "./types/PostAggregates";
|
@@ -199,9 +202,9 @@ export { PrivateMessageView } from "./types/PrivateMessageView";
|
|
199
202
|
export { PrivateMessagesResponse } from "./types/PrivateMessagesResponse";
|
200
203
|
export { PurgeComment } from "./types/PurgeComment";
|
201
204
|
export { PurgeCommunity } from "./types/PurgeCommunity";
|
202
|
-
export { PurgeItemResponse } from "./types/PurgeItemResponse";
|
203
205
|
export { PurgePerson } from "./types/PurgePerson";
|
204
206
|
export { PurgePost } from "./types/PurgePost";
|
207
|
+
export { ReadableFederationState } from "./types/ReadableFederationState";
|
205
208
|
export { Register } from "./types/Register";
|
206
209
|
export { RegistrationApplication } from "./types/RegistrationApplication";
|
207
210
|
export { RegistrationApplicationResponse } from "./types/RegistrationApplicationResponse";
|
@@ -229,7 +232,10 @@ export { SiteResponse } from "./types/SiteResponse";
|
|
229
232
|
export { SiteView } from "./types/SiteView";
|
230
233
|
export { SortType } from "./types/SortType";
|
231
234
|
export { SubscribedType } from "./types/SubscribedType";
|
235
|
+
export { SuccessResponse } from "./types/SuccessResponse";
|
232
236
|
export { Tagline } from "./types/Tagline";
|
233
237
|
export { TransferCommunity } from "./types/TransferCommunity";
|
238
|
+
export { UpdateTotp } from "./types/UpdateTotp";
|
239
|
+
export { UpdateTotpResponse } from "./types/UpdateTotpResponse";
|
234
240
|
export { VerifyEmail } from "./types/VerifyEmail";
|
235
|
-
export {
|
241
|
+
export { UploadImage, UploadImageResponse, ImageFile, DeleteImage, } from "./other_types";
|
@@ -2,10 +2,6 @@
|
|
2
2
|
export declare const VERSION = "v3";
|
3
3
|
export interface UploadImage {
|
4
4
|
image: File | Buffer;
|
5
|
-
/**
|
6
|
-
* Optional if cookie with jwt set is already present. Otherwise, auth is required.
|
7
|
-
*/
|
8
|
-
auth?: string;
|
9
5
|
}
|
10
6
|
export interface UploadImageResponse {
|
11
7
|
/**
|
@@ -20,3 +16,7 @@ export interface ImageFile {
|
|
20
16
|
file: string;
|
21
17
|
delete_token: string;
|
22
18
|
}
|
19
|
+
export interface DeleteImage {
|
20
|
+
token: string;
|
21
|
+
filename: string;
|
22
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export type ActivityId = number;
|
@@ -1,12 +1,9 @@
|
|
1
1
|
import type { CommentId } from "./CommentId";
|
2
2
|
export interface CommentAggregates {
|
3
|
-
id: number;
|
4
3
|
comment_id: CommentId;
|
5
4
|
score: number;
|
6
5
|
upvotes: number;
|
7
6
|
downvotes: number;
|
8
7
|
published: string;
|
9
8
|
child_count: number;
|
10
|
-
hot_rank: number;
|
11
|
-
controversy_rank: number;
|
12
9
|
}
|
@@ -14,6 +14,8 @@ export interface CommentReplyView {
|
|
14
14
|
recipient: Person;
|
15
15
|
counts: CommentAggregates;
|
16
16
|
creator_banned_from_community: boolean;
|
17
|
+
creator_is_moderator: boolean;
|
18
|
+
creator_is_admin: boolean;
|
17
19
|
subscribed: SubscribedType;
|
18
20
|
saved: boolean;
|
19
21
|
creator_blocked: boolean;
|
@@ -11,6 +11,8 @@ export interface CommentView {
|
|
11
11
|
community: Community;
|
12
12
|
counts: CommentAggregates;
|
13
13
|
creator_banned_from_community: boolean;
|
14
|
+
creator_is_moderator: boolean;
|
15
|
+
creator_is_admin: boolean;
|
14
16
|
subscribed: SubscribedType;
|
15
17
|
saved: boolean;
|
16
18
|
creator_blocked: boolean;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { CommunityId } from "./CommunityId";
|
2
2
|
export interface CommunityAggregates {
|
3
|
-
id: number;
|
4
3
|
community_id: CommunityId;
|
5
4
|
subscribers: number;
|
6
5
|
posts: number;
|
@@ -10,5 +9,4 @@ export interface CommunityAggregates {
|
|
10
9
|
users_active_week: number;
|
11
10
|
users_active_month: number;
|
12
11
|
users_active_half_year: number;
|
13
|
-
hot_rank: number;
|
14
12
|
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type {
|
1
|
+
import type { InstanceWithFederationState } from "./InstanceWithFederationState";
|
2
2
|
export interface FederatedInstances {
|
3
|
-
linked: Array<
|
4
|
-
allowed: Array<
|
5
|
-
blocked: Array<
|
3
|
+
linked: Array<InstanceWithFederationState>;
|
4
|
+
allowed: Array<InstanceWithFederationState>;
|
5
|
+
blocked: Array<InstanceWithFederationState>;
|
6
6
|
}
|
package/dist/types/GetPosts.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { CommunityId } from "./CommunityId";
|
2
2
|
import type { ListingType } from "./ListingType";
|
3
|
+
import type { PaginationCursor } from "./PaginationCursor";
|
3
4
|
import type { SortType } from "./SortType";
|
4
5
|
export interface GetPosts {
|
5
6
|
type_?: ListingType;
|
@@ -11,4 +12,5 @@ export interface GetPosts {
|
|
11
12
|
saved_only?: boolean;
|
12
13
|
liked_only?: boolean;
|
13
14
|
disliked_only?: boolean;
|
15
|
+
page_cursor?: PaginationCursor;
|
14
16
|
}
|