lemmy-js-client 0.20.0-api-v4.17 → 0.20.0-image-api-rework.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/http.d.ts +20 -2
- package/dist/http.js +31 -18
- package/dist/index.d.ts +5 -1
- package/dist/other_types.d.ts +0 -17
- package/dist/types/DeleteImageParams.d.ts +4 -0
- package/dist/types/DeleteImageParams.js +3 -0
- package/dist/types/ImageGetParams.d.ts +4 -0
- package/dist/types/ImageGetParams.js +3 -0
- package/dist/types/ImageProxyParams.d.ts +5 -0
- package/dist/types/ImageProxyParams.js +3 -0
- package/dist/types/LemmyErrorType.d.ts +2 -0
- package/dist/types/SaveUserSettings.d.ts +0 -4
- package/dist/types/UploadImageResponse.d.ts +5 -0
- package/dist/types/UploadImageResponse.js +3 -0
- package/package.json +1 -1
package/dist/http.d.ts
CHANGED
@@ -123,7 +123,7 @@ import { SearchResponse } from "./types/SearchResponse";
|
|
123
123
|
import { SiteResponse } from "./types/SiteResponse";
|
124
124
|
import { TransferCommunity } from "./types/TransferCommunity";
|
125
125
|
import { VerifyEmail } from "./types/VerifyEmail";
|
126
|
-
import {
|
126
|
+
import { UploadImage } from "./other_types";
|
127
127
|
import { HideCommunity } from "./types/HideCommunity";
|
128
128
|
import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
|
129
129
|
import { UpdateTotp } from "./types/UpdateTotp";
|
@@ -157,6 +157,8 @@ import { MyUserInfo } from "./types/MyUserInfo";
|
|
157
157
|
import { UserBlockInstanceParams } from "./types/UserBlockInstanceParams";
|
158
158
|
import { AdminAllowInstanceParams } from "./types/AdminAllowInstanceParams";
|
159
159
|
import { AdminBlockInstanceParams } from "./types/AdminBlockInstanceParams";
|
160
|
+
import { DeleteImageParams } from "./types/DeleteImageParams";
|
161
|
+
import { UploadImageResponse } from "./types/UploadImageResponse";
|
160
162
|
type RequestOptions = Pick<RequestInit, "signal">;
|
161
163
|
/**
|
162
164
|
* Helps build lemmy HTTP requests.
|
@@ -876,12 +878,28 @@ export declare class LemmyHttp {
|
|
876
878
|
adminAllowInstance(form: AdminAllowInstanceParams, options?: RequestOptions): Promise<SuccessResponse>;
|
877
879
|
/**
|
878
880
|
* Upload an image to the server.
|
881
|
+
*
|
882
|
+
* `HTTP.Post /image`
|
879
883
|
*/
|
880
884
|
uploadImage({ image }: UploadImage, options?: RequestOptions): Promise<UploadImageResponse>;
|
885
|
+
/**
|
886
|
+
* Upload new user avatar.
|
887
|
+
*
|
888
|
+
* `HTTP.Post /account/avatar`
|
889
|
+
*/
|
890
|
+
userUploadAvatar({ image }: UploadImage, options?: RequestOptions): Promise<SuccessResponse>;
|
881
891
|
/**
|
882
892
|
* Delete a pictrs image
|
893
|
+
*
|
894
|
+
* `HTTP.Delete /image`
|
895
|
+
*/
|
896
|
+
deleteImage(form: DeleteImageParams, options?: RequestOptions): Promise<SuccessResponse>;
|
897
|
+
/**
|
898
|
+
* Health check for image functionality
|
899
|
+
*
|
900
|
+
* `HTTP.Get /image/health`
|
883
901
|
*/
|
884
|
-
|
902
|
+
imageHealth(options?: RequestOptions): Promise<SuccessResponse>;
|
885
903
|
/**
|
886
904
|
* Set the headers (can be used to set the auth header)
|
887
905
|
*/
|
package/dist/http.js
CHANGED
@@ -28,6 +28,7 @@ var HttpType;
|
|
28
28
|
HttpType["Get"] = "GET";
|
29
29
|
HttpType["Post"] = "POST";
|
30
30
|
HttpType["Put"] = "PUT";
|
31
|
+
HttpType["Delete"] = "DELETE";
|
31
32
|
})(HttpType || (HttpType = {}));
|
32
33
|
/**
|
33
34
|
* Helps build lemmy HTTP requests.
|
@@ -992,34 +993,46 @@ class LemmyHttp {
|
|
992
993
|
}
|
993
994
|
/**
|
994
995
|
* Upload an image to the server.
|
996
|
+
*
|
997
|
+
* `HTTP.Post /image`
|
995
998
|
*/
|
996
999
|
uploadImage(_a, options_1) {
|
997
1000
|
return __awaiter(this, arguments, void 0, function* ({ image }, options) {
|
998
1001
|
const formData = createFormData(image);
|
999
|
-
let url = undefined;
|
1000
|
-
let delete_url = undefined;
|
1001
1002
|
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), Object.assign(Object.assign({}, options), { method: HttpType.Post, body: formData, headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f") }));
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1003
|
+
return response.json();
|
1004
|
+
});
|
1005
|
+
}
|
1006
|
+
/**
|
1007
|
+
* Upload new user avatar.
|
1008
|
+
*
|
1009
|
+
* `HTTP.Post /account/avatar`
|
1010
|
+
*/
|
1011
|
+
userUploadAvatar(_a, options_1) {
|
1012
|
+
return __awaiter(this, arguments, void 0, function* ({ image }, options) {
|
1013
|
+
const formData = createFormData(image);
|
1014
|
+
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), Object.assign(Object.assign({}, options), { method: HttpType.Post, body: formData, headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f") }));
|
1015
|
+
return response.json();
|
1013
1016
|
});
|
1014
1017
|
}
|
1015
1018
|
/**
|
1016
1019
|
* Delete a pictrs image
|
1020
|
+
*
|
1021
|
+
* `HTTP.Delete /image`
|
1022
|
+
*/
|
1023
|
+
deleteImage(form, options) {
|
1024
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1025
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Delete, "/image", form, options);
|
1026
|
+
});
|
1027
|
+
}
|
1028
|
+
/**
|
1029
|
+
* Health check for image functionality
|
1030
|
+
*
|
1031
|
+
* `HTTP.Get /image/health`
|
1017
1032
|
*/
|
1018
|
-
|
1019
|
-
return __awaiter(this,
|
1020
|
-
|
1021
|
-
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, deleteUrl, Object.assign(Object.assign({}, options), { method: HttpType.Get, headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f") }));
|
1022
|
-
return response.status == 204;
|
1033
|
+
imageHealth(options) {
|
1034
|
+
return __awaiter(this, void 0, void 0, function* () {
|
1035
|
+
return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/image/health", {}, options);
|
1023
1036
|
});
|
1024
1037
|
}
|
1025
1038
|
/**
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export * from "./http";
|
2
|
-
export { UploadImage
|
2
|
+
export { UploadImage } from "./other_types";
|
3
3
|
export { ActivityId } from "./types/ActivityId";
|
4
4
|
export { AddAdmin } from "./types/AddAdmin";
|
5
5
|
export { AddAdminResponse } from "./types/AddAdminResponse";
|
@@ -80,6 +80,7 @@ export { DeleteAccount } from "./types/DeleteAccount";
|
|
80
80
|
export { DeleteComment } from "./types/DeleteComment";
|
81
81
|
export { DeleteCommunity } from "./types/DeleteCommunity";
|
82
82
|
export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
|
83
|
+
export { DeleteImageParams } from "./types/DeleteImageParams";
|
83
84
|
export { DeleteOAuthProvider } from "./types/DeleteOAuthProvider";
|
84
85
|
export { DeletePost } from "./types/DeletePost";
|
85
86
|
export { DeletePrivateMessage } from "./types/DeletePrivateMessage";
|
@@ -133,6 +134,8 @@ export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnread
|
|
133
134
|
export { HideCommunity } from "./types/HideCommunity";
|
134
135
|
export { HidePost } from "./types/HidePost";
|
135
136
|
export { ImageDetails } from "./types/ImageDetails";
|
137
|
+
export { ImageGetParams } from "./types/ImageGetParams";
|
138
|
+
export { ImageProxyParams } from "./types/ImageProxyParams";
|
136
139
|
export { Instance } from "./types/Instance";
|
137
140
|
export { InstanceId } from "./types/InstanceId";
|
138
141
|
export { InstanceWithFederationState } from "./types/InstanceWithFederationState";
|
@@ -286,6 +289,7 @@ export { TransferCommunity } from "./types/TransferCommunity";
|
|
286
289
|
export { UpdateTagline } from "./types/UpdateTagline";
|
287
290
|
export { UpdateTotp } from "./types/UpdateTotp";
|
288
291
|
export { UpdateTotpResponse } from "./types/UpdateTotpResponse";
|
292
|
+
export { UploadImageResponse } from "./types/UploadImageResponse";
|
289
293
|
export { UserBlockInstanceParams } from "./types/UserBlockInstanceParams";
|
290
294
|
export { VerifyEmail } from "./types/VerifyEmail";
|
291
295
|
export { VoteView } from "./types/VoteView";
|
package/dist/other_types.d.ts
CHANGED
@@ -2,20 +2,3 @@ export declare const VERSION = "v4";
|
|
2
2
|
export interface UploadImage {
|
3
3
|
image: File | Buffer;
|
4
4
|
}
|
5
|
-
export interface UploadImageResponse {
|
6
|
-
/**
|
7
|
-
* Is "ok" if the upload was successful; is something else otherwise.
|
8
|
-
*/
|
9
|
-
msg: string;
|
10
|
-
files?: ImageFile[];
|
11
|
-
url?: string;
|
12
|
-
delete_url?: string;
|
13
|
-
}
|
14
|
-
export interface ImageFile {
|
15
|
-
file: string;
|
16
|
-
delete_token: string;
|
17
|
-
}
|
18
|
-
export interface DeleteImage {
|
19
|
-
token: string;
|
20
|
-
filename: string;
|
21
|
-
}
|
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-api-
|
4
|
+
"version": "0.20.0-image-api-rework.0",
|
5
5
|
"author": "Dessalines <tyhou13@gmx.com>",
|
6
6
|
"license": "AGPL-3.0",
|
7
7
|
"main": "./dist/index.js",
|