lemmy-js-client 0.17.2-rc.17 → 0.17.2-rc.20
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/http.d.ts +17 -5
- package/dist/http.js +37 -5
- package/package.json +1 -1
package/dist/http.d.ts
CHANGED
@@ -13,6 +13,7 @@ import { BlockCommunityResponse } from "./types/BlockCommunityResponse";
|
|
13
13
|
import { BlockPerson } from "./types/BlockPerson";
|
14
14
|
import { BlockPersonResponse } from "./types/BlockPersonResponse";
|
15
15
|
import { ChangePassword } from "./types/ChangePassword";
|
16
|
+
import { CommentReplyResponse } from "./types/CommentReplyResponse";
|
16
17
|
import { CommentReportResponse } from "./types/CommentReportResponse";
|
17
18
|
import { CommentResponse } from "./types/CommentResponse";
|
18
19
|
import { CommunityResponse } from "./types/CommunityResponse";
|
@@ -27,12 +28,15 @@ import { CreatePostReport } from "./types/CreatePostReport";
|
|
27
28
|
import { CreatePrivateMessage } from "./types/CreatePrivateMessage";
|
28
29
|
import { CreatePrivateMessageReport } from "./types/CreatePrivateMessageReport";
|
29
30
|
import { CreateSite } from "./types/CreateSite";
|
31
|
+
import { CustomEmojiResponse } from "./types/CustomEmojiResponse";
|
30
32
|
import { DeleteAccount } from "./types/DeleteAccount";
|
31
33
|
import { DeleteComment } from "./types/DeleteComment";
|
32
34
|
import { DeleteCommunity } from "./types/DeleteCommunity";
|
33
35
|
import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
|
36
|
+
import { DeleteCustomEmojiResponse } from "./types/DeleteCustomEmojiResponse";
|
34
37
|
import { DeletePost } from "./types/DeletePost";
|
35
38
|
import { DeletePrivateMessage } from "./types/DeletePrivateMessage";
|
39
|
+
import { DistinguishComment } from "./types/DistinguishComment";
|
36
40
|
import { EditComment } from "./types/EditComment";
|
37
41
|
import { EditCommunity } from "./types/EditCommunity";
|
38
42
|
import { EditCustomEmoji } from "./types/EditCustomEmoji";
|
@@ -50,6 +54,7 @@ import { GetCommentsResponse } from "./types/GetCommentsResponse";
|
|
50
54
|
import { GetCommunity } from "./types/GetCommunity";
|
51
55
|
import { GetCommunityResponse } from "./types/GetCommunityResponse";
|
52
56
|
import { GetFederatedInstances } from "./types/GetFederatedInstances";
|
57
|
+
import { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
|
53
58
|
import { GetModlog } from "./types/GetModlog";
|
54
59
|
import { GetModlogResponse } from "./types/GetModlogResponse";
|
55
60
|
import { GetPersonDetails } from "./types/GetPersonDetails";
|
@@ -366,7 +371,7 @@ export declare class LemmyHttp {
|
|
366
371
|
*
|
367
372
|
* `HTTP.POST /comment/mark_as_read`
|
368
373
|
*/
|
369
|
-
markCommentReplyAsRead(form: MarkCommentReplyAsRead): Promise<
|
374
|
+
markCommentReplyAsRead(form: MarkCommentReplyAsRead): Promise<CommentReplyResponse>;
|
370
375
|
/**
|
371
376
|
* Like / vote on a comment.
|
372
377
|
*
|
@@ -379,6 +384,12 @@ export declare class LemmyHttp {
|
|
379
384
|
* `HTTP.PUT /comment/save`
|
380
385
|
*/
|
381
386
|
saveComment(form: SaveComment): Promise<CommentResponse>;
|
387
|
+
/**
|
388
|
+
* Distinguishes a comment (speak as moderator)
|
389
|
+
*
|
390
|
+
* `HTTP.POST /comment/distinguish`
|
391
|
+
*/
|
392
|
+
distinguishComment(form: DistinguishComment): Promise<CommentResponse>;
|
382
393
|
/**
|
383
394
|
* Get / fetch comments.
|
384
395
|
*
|
@@ -624,29 +635,30 @@ export declare class LemmyHttp {
|
|
624
635
|
*
|
625
636
|
* `HTTP.POST /custom_emoji`
|
626
637
|
*/
|
627
|
-
createCustomEmoji(form: CreateCustomEmoji): Promise<
|
638
|
+
createCustomEmoji(form: CreateCustomEmoji): Promise<CustomEmojiResponse>;
|
628
639
|
/**
|
629
640
|
* Edit an existing custom emoji
|
630
641
|
*
|
631
642
|
* `HTTP.PUT /custom_emoji`
|
632
643
|
*/
|
633
|
-
editCustomEmoji(form: EditCustomEmoji): Promise<
|
644
|
+
editCustomEmoji(form: EditCustomEmoji): Promise<CustomEmojiResponse>;
|
634
645
|
/**
|
635
646
|
* Delete a custom emoji
|
636
647
|
*
|
637
648
|
* `HTTP.Post /custom_emoji/delete`
|
638
649
|
*/
|
639
|
-
deleteCustomEmoji(form: DeleteCustomEmoji): Promise<
|
650
|
+
deleteCustomEmoji(form: DeleteCustomEmoji): Promise<DeleteCustomEmojiResponse>;
|
640
651
|
/**
|
641
652
|
* Fetch federated instances.
|
642
653
|
*
|
643
654
|
* `HTTP.Get /federated_instances`
|
644
655
|
*/
|
645
|
-
getFederatedInstances(form: GetFederatedInstances): Promise<
|
656
|
+
getFederatedInstances(form: GetFederatedInstances): Promise<GetFederatedInstancesResponse>;
|
646
657
|
/**
|
647
658
|
* Upload an image to the server.
|
648
659
|
*/
|
649
660
|
uploadImage({ image, auth, }: UploadImage): Promise<UploadImageResponse>;
|
650
661
|
private buildFullUrl;
|
651
662
|
private wrapper;
|
663
|
+
private checkandThrowError;
|
652
664
|
}
|
package/dist/http.js
CHANGED
@@ -401,6 +401,14 @@ var LemmyHttp = /** @class */ (function () {
|
|
401
401
|
LemmyHttp.prototype.saveComment = function (form) {
|
402
402
|
return this.wrapper(HttpType.Put, "/comment/save", form);
|
403
403
|
};
|
404
|
+
/**
|
405
|
+
* Distinguishes a comment (speak as moderator)
|
406
|
+
*
|
407
|
+
* `HTTP.POST /comment/distinguish`
|
408
|
+
*/
|
409
|
+
LemmyHttp.prototype.distinguishComment = function (form) {
|
410
|
+
return this.wrapper(HttpType.Post, "/comment/distinguish", form);
|
411
|
+
};
|
404
412
|
/**
|
405
413
|
* Get / fetch comments.
|
406
414
|
*
|
@@ -817,7 +825,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
817
825
|
return __generator(this, function (_a) {
|
818
826
|
switch (_a.label) {
|
819
827
|
case 0:
|
820
|
-
if (!(type_ === HttpType.Get)) return [3 /*break*/,
|
828
|
+
if (!(type_ === HttpType.Get)) return [3 /*break*/, 4];
|
821
829
|
getUrl = "".concat(this.buildFullUrl(endpoint), "?").concat(encodeGetParams(form));
|
822
830
|
return [4 /*yield*/, (0, cross_fetch_1.default)(getUrl, {
|
823
831
|
method: HttpType.Get,
|
@@ -825,17 +833,41 @@ var LemmyHttp = /** @class */ (function () {
|
|
825
833
|
})];
|
826
834
|
case 1:
|
827
835
|
response = _a.sent();
|
836
|
+
return [4 /*yield*/, this.checkandThrowError(response)];
|
837
|
+
case 2:
|
838
|
+
_a.sent();
|
828
839
|
return [4 /*yield*/, response.json()];
|
829
|
-
case
|
830
|
-
case
|
840
|
+
case 3: return [2 /*return*/, _a.sent()];
|
841
|
+
case 4: return [4 /*yield*/, (0, cross_fetch_1.default)(this.buildFullUrl(endpoint), {
|
831
842
|
method: type_,
|
832
843
|
headers: __assign({ "Content-Type": "application/json" }, this.headers),
|
833
844
|
body: JSON.stringify(form),
|
834
845
|
})];
|
835
|
-
case
|
846
|
+
case 5:
|
836
847
|
response = _a.sent();
|
848
|
+
return [4 /*yield*/, this.checkandThrowError(response)];
|
849
|
+
case 6:
|
850
|
+
_a.sent();
|
837
851
|
return [4 /*yield*/, response.json()];
|
838
|
-
case
|
852
|
+
case 7: return [2 /*return*/, _a.sent()];
|
853
|
+
}
|
854
|
+
});
|
855
|
+
});
|
856
|
+
};
|
857
|
+
LemmyHttp.prototype.checkandThrowError = function (response) {
|
858
|
+
var _a;
|
859
|
+
return __awaiter(this, void 0, void 0, function () {
|
860
|
+
var errJson, errString;
|
861
|
+
return __generator(this, function (_b) {
|
862
|
+
switch (_b.label) {
|
863
|
+
case 0:
|
864
|
+
if (!!response.ok) return [3 /*break*/, 2];
|
865
|
+
return [4 /*yield*/, response.json()];
|
866
|
+
case 1:
|
867
|
+
errJson = _b.sent();
|
868
|
+
errString = (_a = errJson["error"]) !== null && _a !== void 0 ? _a : response.statusText;
|
869
|
+
throw new Error(errString);
|
870
|
+
case 2: return [2 /*return*/];
|
839
871
|
}
|
840
872
|
});
|
841
873
|
});
|
package/package.json
CHANGED