lemmy-js-client 0.20.0-image-api-rework.7 → 0.20.0-image-api-rework.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/http.d.ts +72 -6
- package/dist/http.js +127 -15
- package/package.json +2 -2
package/dist/http.d.ts
CHANGED
@@ -861,17 +861,83 @@ export declare class LemmyHttp {
|
|
861
861
|
*/
|
862
862
|
adminAllowInstance(form: AdminAllowInstanceParams, options?: RequestOptions): Promise<SuccessResponse>;
|
863
863
|
/**
|
864
|
-
* Upload
|
864
|
+
* Upload new user avatar.
|
865
865
|
*
|
866
|
-
* `HTTP.Post /
|
866
|
+
* `HTTP.Post /account/avatar`
|
867
867
|
*/
|
868
|
-
|
868
|
+
uploadUserAvatar(image: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
869
869
|
/**
|
870
|
-
*
|
870
|
+
* Delete the user avatar.
|
871
871
|
*
|
872
|
-
* `HTTP.
|
872
|
+
* `HTTP.Delete /account/avatar`
|
873
|
+
*/
|
874
|
+
deleteUserAvatar(options?: RequestOptions): Promise<SuccessResponse>;
|
875
|
+
/**
|
876
|
+
* Upload new user banner.
|
877
|
+
*
|
878
|
+
* `HTTP.Post /account/banner`
|
879
|
+
*/
|
880
|
+
uploadUserBanner(image: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
881
|
+
/**
|
882
|
+
* Delete the user banner.
|
883
|
+
*
|
884
|
+
* `HTTP.Delete /account/banner`
|
885
|
+
*/
|
886
|
+
deleteUserBanner(options?: RequestOptions): Promise<SuccessResponse>;
|
887
|
+
/**
|
888
|
+
* Upload new community icon.
|
889
|
+
*
|
890
|
+
* `HTTP.Post /community/icon`
|
891
|
+
*/
|
892
|
+
uploadCommunityIcon(image: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
893
|
+
/**
|
894
|
+
* Delete the community icon.
|
895
|
+
*
|
896
|
+
* `HTTP.Delete /community/icon`
|
897
|
+
*/
|
898
|
+
deleteCommunityIcon(options?: RequestOptions): Promise<SuccessResponse>;
|
899
|
+
/**
|
900
|
+
* Upload new community banner.
|
901
|
+
*
|
902
|
+
* `HTTP.Post /community/banner`
|
903
|
+
*/
|
904
|
+
uploadCommunityBanner(image: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
905
|
+
/**
|
906
|
+
* Delete the community banner.
|
907
|
+
*
|
908
|
+
* `HTTP.Delete /community/banner`
|
909
|
+
*/
|
910
|
+
deleteCommunityBanner(options?: RequestOptions): Promise<SuccessResponse>;
|
911
|
+
/**
|
912
|
+
* Upload new site icon.
|
913
|
+
*
|
914
|
+
* `HTTP.Post /site/icon`
|
915
|
+
*/
|
916
|
+
uploadSiteIcon(image: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
917
|
+
/**
|
918
|
+
* Delete the site icon.
|
919
|
+
*
|
920
|
+
* `HTTP.Delete /site/icon`
|
921
|
+
*/
|
922
|
+
deleteSiteIcon(options?: RequestOptions): Promise<SuccessResponse>;
|
923
|
+
/**
|
924
|
+
* Upload new site banner.
|
925
|
+
*
|
926
|
+
* `HTTP.Post /site/banner`
|
927
|
+
*/
|
928
|
+
uploadSiteBanner(image: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
929
|
+
/**
|
930
|
+
* Delete the site banner.
|
931
|
+
*
|
932
|
+
* `HTTP.Delete /site/banner`
|
933
|
+
*/
|
934
|
+
deleteSiteBanner(options?: RequestOptions): Promise<SuccessResponse>;
|
935
|
+
/**
|
936
|
+
* Upload an image to the server.
|
937
|
+
*
|
938
|
+
* `HTTP.Post /image`
|
873
939
|
*/
|
874
|
-
|
940
|
+
uploadImage(image: UploadImage, options?: RequestOptions): Promise<UploadImageResponse>;
|
875
941
|
/**
|
876
942
|
* Delete a pictrs image
|
877
943
|
*
|
package/dist/http.js
CHANGED
@@ -19,7 +19,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
19
19
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
20
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
21
21
|
};
|
22
|
-
var _LemmyHttp_instances, _LemmyHttp_apiUrl, _LemmyHttp_headers, _LemmyHttp_fetchFunction, _LemmyHttp_buildFullUrl, _LemmyHttp_wrapper;
|
22
|
+
var _LemmyHttp_instances, _LemmyHttp_apiUrl, _LemmyHttp_headers, _LemmyHttp_fetchFunction, _LemmyHttp_buildFullUrl, _LemmyHttp_upload, _LemmyHttp_wrapper;
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
24
24
|
exports.LemmyHttp = void 0;
|
25
25
|
const other_types_1 = require("./other_types");
|
@@ -974,27 +974,133 @@ class LemmyHttp {
|
|
974
974
|
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/instance/allow", form, options);
|
975
975
|
}
|
976
976
|
/**
|
977
|
-
* Upload
|
977
|
+
* Upload new user avatar.
|
978
978
|
*
|
979
|
-
* `HTTP.Post /
|
979
|
+
* `HTTP.Post /account/avatar`
|
980
980
|
*/
|
981
|
-
|
982
|
-
return __awaiter(this,
|
983
|
-
|
984
|
-
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, "/image"), Object.assign(Object.assign({}, options), { method: HttpType.Post, body: formData, headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f") }));
|
985
|
-
return response.json();
|
981
|
+
uploadUserAvatar(image, options) {
|
982
|
+
return __awaiter(this, void 0, void 0, function* () {
|
983
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/account/avatar", image, options);
|
986
984
|
});
|
987
985
|
}
|
988
986
|
/**
|
989
|
-
*
|
987
|
+
* Delete the user avatar.
|
990
988
|
*
|
991
|
-
* `HTTP.
|
989
|
+
* `HTTP.Delete /account/avatar`
|
990
|
+
*/
|
991
|
+
deleteUserAvatar(options) {
|
992
|
+
return __awaiter(this, void 0, void 0, function* () {
|
993
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/account/avatar", {}, options);
|
994
|
+
});
|
995
|
+
}
|
996
|
+
/**
|
997
|
+
* Upload new user banner.
|
998
|
+
*
|
999
|
+
* `HTTP.Post /account/banner`
|
1000
|
+
*/
|
1001
|
+
uploadUserBanner(image, options) {
|
1002
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1003
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/account/banner", image, options);
|
1004
|
+
});
|
1005
|
+
}
|
1006
|
+
/**
|
1007
|
+
* Delete the user banner.
|
1008
|
+
*
|
1009
|
+
* `HTTP.Delete /account/banner`
|
992
1010
|
*/
|
993
|
-
|
994
|
-
return __awaiter(this,
|
995
|
-
|
996
|
-
|
997
|
-
|
1011
|
+
deleteUserBanner(options) {
|
1012
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1013
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/account/banner", {}, options);
|
1014
|
+
});
|
1015
|
+
}
|
1016
|
+
/**
|
1017
|
+
* Upload new community icon.
|
1018
|
+
*
|
1019
|
+
* `HTTP.Post /community/icon`
|
1020
|
+
*/
|
1021
|
+
uploadCommunityIcon(image, options) {
|
1022
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1023
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/community/icon", image, options);
|
1024
|
+
});
|
1025
|
+
}
|
1026
|
+
/**
|
1027
|
+
* Delete the community icon.
|
1028
|
+
*
|
1029
|
+
* `HTTP.Delete /community/icon`
|
1030
|
+
*/
|
1031
|
+
deleteCommunityIcon(options) {
|
1032
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1033
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/community/icon", {}, options);
|
1034
|
+
});
|
1035
|
+
}
|
1036
|
+
/**
|
1037
|
+
* Upload new community banner.
|
1038
|
+
*
|
1039
|
+
* `HTTP.Post /community/banner`
|
1040
|
+
*/
|
1041
|
+
uploadCommunityBanner(image, options) {
|
1042
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1043
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/community/banner", image, options);
|
1044
|
+
});
|
1045
|
+
}
|
1046
|
+
/**
|
1047
|
+
* Delete the community banner.
|
1048
|
+
*
|
1049
|
+
* `HTTP.Delete /community/banner`
|
1050
|
+
*/
|
1051
|
+
deleteCommunityBanner(options) {
|
1052
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1053
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/community/banner", {}, options);
|
1054
|
+
});
|
1055
|
+
}
|
1056
|
+
/**
|
1057
|
+
* Upload new site icon.
|
1058
|
+
*
|
1059
|
+
* `HTTP.Post /site/icon`
|
1060
|
+
*/
|
1061
|
+
uploadSiteIcon(image, options) {
|
1062
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1063
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/site/icon", image, options);
|
1064
|
+
});
|
1065
|
+
}
|
1066
|
+
/**
|
1067
|
+
* Delete the site icon.
|
1068
|
+
*
|
1069
|
+
* `HTTP.Delete /site/icon`
|
1070
|
+
*/
|
1071
|
+
deleteSiteIcon(options) {
|
1072
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1073
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/site/icon", {}, options);
|
1074
|
+
});
|
1075
|
+
}
|
1076
|
+
/**
|
1077
|
+
* Upload new site banner.
|
1078
|
+
*
|
1079
|
+
* `HTTP.Post /site/banner`
|
1080
|
+
*/
|
1081
|
+
uploadSiteBanner(image, options) {
|
1082
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1083
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/site/banner", image, options);
|
1084
|
+
});
|
1085
|
+
}
|
1086
|
+
/**
|
1087
|
+
* Delete the site banner.
|
1088
|
+
*
|
1089
|
+
* `HTTP.Delete /site/banner`
|
1090
|
+
*/
|
1091
|
+
deleteSiteBanner(options) {
|
1092
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1093
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/site/banner", {}, options);
|
1094
|
+
});
|
1095
|
+
}
|
1096
|
+
/**
|
1097
|
+
* Upload an image to the server.
|
1098
|
+
*
|
1099
|
+
* `HTTP.Post /image`
|
1100
|
+
*/
|
1101
|
+
uploadImage(image, options) {
|
1102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1103
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_upload).call(this, "/image", image, options);
|
998
1104
|
});
|
999
1105
|
}
|
1000
1106
|
/**
|
@@ -1027,6 +1133,12 @@ class LemmyHttp {
|
|
1027
1133
|
exports.LemmyHttp = LemmyHttp;
|
1028
1134
|
_LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHttp_fetchFunction = new WeakMap(), _LemmyHttp_instances = new WeakSet(), _LemmyHttp_buildFullUrl = function _LemmyHttp_buildFullUrl(endpoint) {
|
1029
1135
|
return `${__classPrivateFieldGet(this, _LemmyHttp_apiUrl, "f")}${endpoint}`;
|
1136
|
+
}, _LemmyHttp_upload = function _LemmyHttp_upload(path_1, _a, options_1) {
|
1137
|
+
return __awaiter(this, arguments, void 0, function* (path, { image }, options) {
|
1138
|
+
const formData = createFormData(image);
|
1139
|
+
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, path), Object.assign(Object.assign({}, options), { method: HttpType.Post, body: formData, headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f") }));
|
1140
|
+
return response.json();
|
1141
|
+
});
|
1030
1142
|
}, _LemmyHttp_wrapper = function _LemmyHttp_wrapper(type_, endpoint, form, options) {
|
1031
1143
|
return __awaiter(this, void 0, void 0, function* () {
|
1032
1144
|
var _a;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "lemmy-js-client",
|
3
3
|
"description": "A javascript / typescript client for Lemmy",
|
4
|
-
"version": "0.20.0-image-api-rework.
|
4
|
+
"version": "0.20.0-image-api-rework.8",
|
5
5
|
"author": "Dessalines <tyhou13@gmx.com>",
|
6
6
|
"license": "AGPL-3.0",
|
7
7
|
"main": "./dist/index.js",
|
@@ -35,7 +35,7 @@
|
|
35
35
|
"typescript": "^5.5.4",
|
36
36
|
"typescript-eslint": "^8.7.0"
|
37
37
|
},
|
38
|
-
"packageManager": "pnpm@9.15.
|
38
|
+
"packageManager": "pnpm@9.15.2",
|
39
39
|
"types": "./dist/index.d.ts",
|
40
40
|
"lint-staged": {
|
41
41
|
"*.{ts,tsx,js}": [
|