lemmy-js-client 0.17.2-rc.3 → 0.17.2-rc.4
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/README.md +1 -1
- package/dist/http.d.ts +6 -0
- package/dist/http.js +153 -407
- package/dist/interfaces/others.d.ts +21 -0
- package/package.json +3 -3
package/README.md
CHANGED
@@ -43,7 +43,7 @@ import { LemmyHttp } from 'lemmy-js-client';
|
|
43
43
|
|
44
44
|
let baseUrl = 'https://lemmy.ml';
|
45
45
|
let client: LemmyHttp = new LemmyHttp(baseUrl, headers?);
|
46
|
-
let jwt = await client.
|
46
|
+
let jwt = await client.login(loginForm).jwt;
|
47
47
|
```
|
48
48
|
|
49
49
|
## Development
|
package/dist/http.d.ts
CHANGED
@@ -3,12 +3,14 @@ import { AddModToCommunity, AddModToCommunityResponse, BanFromCommunity, BanFrom
|
|
3
3
|
import { AddAdmin, AddAdminResponse, BannedPersonsResponse, BanPerson, BanPersonResponse, BlockPerson, BlockPersonResponse, ChangePassword, CreatePrivateMessage, CreatePrivateMessageReport, DeleteAccount, DeleteAccountResponse, DeletePrivateMessage, EditPrivateMessage, GetBannedPersons, GetCaptchaResponse, GetPersonDetails, GetPersonDetailsResponse, GetPersonMentions, GetPersonMentionsResponse, GetPrivateMessages, GetReplies, GetRepliesResponse, GetReportCount, GetReportCountResponse, GetUnreadCount, GetUnreadCountResponse, ListPrivateMessageReports, ListPrivateMessageReportsResponse, Login, LoginResponse, MarkAllAsRead, MarkCommentReplyAsRead, MarkPersonMentionAsRead, MarkPrivateMessageAsRead, PasswordChange, PasswordReset, PasswordResetResponse, PersonMentionResponse, PrivateMessageReportResponse, PrivateMessageResponse, PrivateMessagesResponse, Register, ResolvePrivateMessageReport, SaveUserSettings, VerifyEmail, VerifyEmailResponse } from "./interfaces/api/person";
|
4
4
|
import { CreatePost, CreatePostLike, CreatePostReport, DeletePost, EditPost, FeaturePost, GetPost, GetPostResponse, GetPosts, GetPostsResponse, GetSiteMetadata, GetSiteMetadataResponse, ListPostReports, ListPostReportsResponse, LockPost, MarkPostAsRead, PostReportResponse, PostResponse, RemovePost, ResolvePostReport, SavePost } from "./interfaces/api/post";
|
5
5
|
import { ApproveRegistrationApplication, CreateSite, EditSite, GetModlog, GetModlogResponse, GetSite, GetSiteResponse, GetUnreadRegistrationApplicationCount, GetUnreadRegistrationApplicationCountResponse, LeaveAdmin, ListRegistrationApplications, ListRegistrationApplicationsResponse, PurgeComment, PurgeCommunity, PurgeItemResponse, PurgePerson, PurgePost, RegistrationApplicationResponse, ResolveObject, ResolveObjectResponse, Search, SearchResponse, SiteResponse } from "./interfaces/api/site";
|
6
|
+
import { UploadImage, UploadImageResponse } from "./interfaces/others";
|
6
7
|
/**
|
7
8
|
* Helps build lemmy HTTP requests.
|
8
9
|
*/
|
9
10
|
export declare class LemmyHttp {
|
10
11
|
private apiUrl;
|
11
12
|
private headers;
|
13
|
+
private pictrsUrl;
|
12
14
|
/**
|
13
15
|
* Generates a new instance of LemmyHttp.
|
14
16
|
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
|
@@ -491,6 +493,10 @@ export declare class LemmyHttp {
|
|
491
493
|
* `HTTP.POST /admin/purge/comment`
|
492
494
|
*/
|
493
495
|
purgeComment(form: PurgeComment): Promise<PurgeItemResponse>;
|
496
|
+
/**
|
497
|
+
* Upload an image to the server.
|
498
|
+
*/
|
499
|
+
uploadImage({ image, auth, }: UploadImage): Promise<UploadImageResponse>;
|
494
500
|
private buildFullUrl;
|
495
501
|
private wrapper;
|
496
502
|
}
|
package/dist/http.js
CHANGED
@@ -46,9 +46,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
47
47
|
}
|
48
48
|
};
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
51
|
+
};
|
49
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
50
53
|
exports.LemmyHttp = void 0;
|
51
|
-
var
|
54
|
+
var cross_fetch_1 = __importDefault(require("cross-fetch"));
|
55
|
+
var form_data_1 = __importDefault(require("form-data"));
|
52
56
|
var others_1 = require("./interfaces/others");
|
53
57
|
var HttpType;
|
54
58
|
(function (HttpType) {
|
@@ -68,6 +72,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
68
72
|
function LemmyHttp(baseUrl, headers) {
|
69
73
|
this.headers = {};
|
70
74
|
this.apiUrl = "".concat(baseUrl, "/api/").concat(others_1.VERSION);
|
75
|
+
this.pictrsUrl = "".concat(baseUrl, "/pictrs/image");
|
71
76
|
if (headers) {
|
72
77
|
this.headers = headers;
|
73
78
|
}
|
@@ -78,11 +83,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
78
83
|
* `HTTP.GET /site`
|
79
84
|
*/
|
80
85
|
LemmyHttp.prototype.getSite = function (form) {
|
81
|
-
return
|
82
|
-
return __generator(this, function (_a) {
|
83
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/site", form)];
|
84
|
-
});
|
85
|
-
});
|
86
|
+
return this.wrapper(HttpType.Get, "/site", form);
|
86
87
|
};
|
87
88
|
/**
|
88
89
|
* Create your site.
|
@@ -90,11 +91,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
90
91
|
* `HTTP.POST /site`
|
91
92
|
*/
|
92
93
|
LemmyHttp.prototype.createSite = function (form) {
|
93
|
-
return
|
94
|
-
return __generator(this, function (_a) {
|
95
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/site", form)];
|
96
|
-
});
|
97
|
-
});
|
94
|
+
return this.wrapper(HttpType.Post, "/site", form);
|
98
95
|
};
|
99
96
|
/**
|
100
97
|
* Edit your site.
|
@@ -102,11 +99,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
102
99
|
* `HTTP.PUT /site`
|
103
100
|
*/
|
104
101
|
LemmyHttp.prototype.editSite = function (form) {
|
105
|
-
return
|
106
|
-
return __generator(this, function (_a) {
|
107
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/site", form)];
|
108
|
-
});
|
109
|
-
});
|
102
|
+
return this.wrapper(HttpType.Put, "/site", form);
|
110
103
|
};
|
111
104
|
/**
|
112
105
|
* Leave the Site admins.
|
@@ -114,11 +107,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
114
107
|
* `HTTP.POST /user/leave_admin`
|
115
108
|
*/
|
116
109
|
LemmyHttp.prototype.leaveAdmin = function (form) {
|
117
|
-
return
|
118
|
-
return __generator(this, function (_a) {
|
119
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/leave_admin", form)];
|
120
|
-
});
|
121
|
-
});
|
110
|
+
return this.wrapper(HttpType.Post, "/user/leave_admin", form);
|
122
111
|
};
|
123
112
|
/**
|
124
113
|
* Get the modlog.
|
@@ -126,11 +115,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
126
115
|
* `HTTP.GET /modlog`
|
127
116
|
*/
|
128
117
|
LemmyHttp.prototype.getModlog = function (form) {
|
129
|
-
return
|
130
|
-
return __generator(this, function (_a) {
|
131
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/modlog", form)];
|
132
|
-
});
|
133
|
-
});
|
118
|
+
return this.wrapper(HttpType.Get, "/modlog", form);
|
134
119
|
};
|
135
120
|
/**
|
136
121
|
* Search lemmy.
|
@@ -138,11 +123,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
138
123
|
* `HTTP.GET /search`
|
139
124
|
*/
|
140
125
|
LemmyHttp.prototype.search = function (form) {
|
141
|
-
return
|
142
|
-
return __generator(this, function (_a) {
|
143
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/search", form)];
|
144
|
-
});
|
145
|
-
});
|
126
|
+
return this.wrapper(HttpType.Get, "/search", form);
|
146
127
|
};
|
147
128
|
/**
|
148
129
|
* Fetch a non-local / federated object.
|
@@ -150,11 +131,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
150
131
|
* `HTTP.GET /resolve_object`
|
151
132
|
*/
|
152
133
|
LemmyHttp.prototype.resolveObject = function (form) {
|
153
|
-
return
|
154
|
-
return __generator(this, function (_a) {
|
155
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/resolve_object", form)];
|
156
|
-
});
|
157
|
-
});
|
134
|
+
return this.wrapper(HttpType.Get, "/resolve_object", form);
|
158
135
|
};
|
159
136
|
/**
|
160
137
|
* Create a new community.
|
@@ -162,11 +139,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
162
139
|
* `HTTP.POST /community`
|
163
140
|
*/
|
164
141
|
LemmyHttp.prototype.createCommunity = function (form) {
|
165
|
-
return
|
166
|
-
return __generator(this, function (_a) {
|
167
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community", form)];
|
168
|
-
});
|
169
|
-
});
|
142
|
+
return this.wrapper(HttpType.Post, "/community", form);
|
170
143
|
};
|
171
144
|
/**
|
172
145
|
* Get / fetch a community.
|
@@ -174,11 +147,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
174
147
|
* `HTTP.GET /community`
|
175
148
|
*/
|
176
149
|
LemmyHttp.prototype.getCommunity = function (form) {
|
177
|
-
return
|
178
|
-
return __generator(this, function (_a) {
|
179
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/community", form)];
|
180
|
-
});
|
181
|
-
});
|
150
|
+
return this.wrapper(HttpType.Get, "/community", form);
|
182
151
|
};
|
183
152
|
/**
|
184
153
|
* Edit a community.
|
@@ -186,11 +155,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
186
155
|
* `HTTP.PUT /community`
|
187
156
|
*/
|
188
157
|
LemmyHttp.prototype.editCommunity = function (form) {
|
189
|
-
return
|
190
|
-
return __generator(this, function (_a) {
|
191
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/community", form)];
|
192
|
-
});
|
193
|
-
});
|
158
|
+
return this.wrapper(HttpType.Put, "/community", form);
|
194
159
|
};
|
195
160
|
/**
|
196
161
|
* List communities, with various filters.
|
@@ -198,11 +163,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
198
163
|
* `HTTP.GET /community/list`
|
199
164
|
*/
|
200
165
|
LemmyHttp.prototype.listCommunities = function (form) {
|
201
|
-
return
|
202
|
-
return __generator(this, function (_a) {
|
203
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/community/list", form)];
|
204
|
-
});
|
205
|
-
});
|
166
|
+
return this.wrapper(HttpType.Get, "/community/list", form);
|
206
167
|
};
|
207
168
|
/**
|
208
169
|
* Follow / subscribe to a community.
|
@@ -210,11 +171,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
210
171
|
* `HTTP.POST /community/follow`
|
211
172
|
*/
|
212
173
|
LemmyHttp.prototype.followCommunity = function (form) {
|
213
|
-
return
|
214
|
-
return __generator(this, function (_a) {
|
215
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/follow", form)];
|
216
|
-
});
|
217
|
-
});
|
174
|
+
return this.wrapper(HttpType.Post, "/community/follow", form);
|
218
175
|
};
|
219
176
|
/**
|
220
177
|
* Block a community.
|
@@ -222,11 +179,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
222
179
|
* `HTTP.POST /community/block`
|
223
180
|
*/
|
224
181
|
LemmyHttp.prototype.blockCommunity = function (form) {
|
225
|
-
return
|
226
|
-
return __generator(this, function (_a) {
|
227
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/block", form)];
|
228
|
-
});
|
229
|
-
});
|
182
|
+
return this.wrapper(HttpType.Post, "/community/block", form);
|
230
183
|
};
|
231
184
|
/**
|
232
185
|
* Delete a community.
|
@@ -234,11 +187,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
234
187
|
* `HTTP.POST /community/delete`
|
235
188
|
*/
|
236
189
|
LemmyHttp.prototype.deleteCommunity = function (form) {
|
237
|
-
return
|
238
|
-
return __generator(this, function (_a) {
|
239
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/delete", form)];
|
240
|
-
});
|
241
|
-
});
|
190
|
+
return this.wrapper(HttpType.Post, "/community/delete", form);
|
242
191
|
};
|
243
192
|
/**
|
244
193
|
* A moderator remove for a community.
|
@@ -246,11 +195,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
246
195
|
* `HTTP.POST /community/remove`
|
247
196
|
*/
|
248
197
|
LemmyHttp.prototype.removeCommunity = function (form) {
|
249
|
-
return
|
250
|
-
return __generator(this, function (_a) {
|
251
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/remove", form)];
|
252
|
-
});
|
253
|
-
});
|
198
|
+
return this.wrapper(HttpType.Post, "/community/remove", form);
|
254
199
|
};
|
255
200
|
/**
|
256
201
|
* Transfer your community to an existing moderator.
|
@@ -258,11 +203,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
258
203
|
* `HTTP.POST /community/transfer`
|
259
204
|
*/
|
260
205
|
LemmyHttp.prototype.transferCommunity = function (form) {
|
261
|
-
return
|
262
|
-
return __generator(this, function (_a) {
|
263
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/transfer", form)];
|
264
|
-
});
|
265
|
-
});
|
206
|
+
return this.wrapper(HttpType.Post, "/community/transfer", form);
|
266
207
|
};
|
267
208
|
/**
|
268
209
|
* Ban a user from a community.
|
@@ -270,11 +211,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
270
211
|
* `HTTP.POST /community/ban_user`
|
271
212
|
*/
|
272
213
|
LemmyHttp.prototype.banFromCommunity = function (form) {
|
273
|
-
return
|
274
|
-
return __generator(this, function (_a) {
|
275
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/ban_user", form)];
|
276
|
-
});
|
277
|
-
});
|
214
|
+
return this.wrapper(HttpType.Post, "/community/ban_user", form);
|
278
215
|
};
|
279
216
|
/**
|
280
217
|
* Add a moderator to your community.
|
@@ -282,11 +219,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
282
219
|
* `HTTP.POST /community/mod`
|
283
220
|
*/
|
284
221
|
LemmyHttp.prototype.addModToCommunity = function (form) {
|
285
|
-
return
|
286
|
-
return __generator(this, function (_a) {
|
287
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/community/mod", form)];
|
288
|
-
});
|
289
|
-
});
|
222
|
+
return this.wrapper(HttpType.Post, "/community/mod", form);
|
290
223
|
};
|
291
224
|
/**
|
292
225
|
* Create a post.
|
@@ -294,11 +227,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
294
227
|
* `HTTP.POST /post`
|
295
228
|
*/
|
296
229
|
LemmyHttp.prototype.createPost = function (form) {
|
297
|
-
return
|
298
|
-
return __generator(this, function (_a) {
|
299
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post", form)];
|
300
|
-
});
|
301
|
-
});
|
230
|
+
return this.wrapper(HttpType.Post, "/post", form);
|
302
231
|
};
|
303
232
|
/**
|
304
233
|
* Get / fetch a post.
|
@@ -306,11 +235,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
306
235
|
* `HTTP.GET /post`
|
307
236
|
*/
|
308
237
|
LemmyHttp.prototype.getPost = function (form) {
|
309
|
-
return
|
310
|
-
return __generator(this, function (_a) {
|
311
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/post", form)];
|
312
|
-
});
|
313
|
-
});
|
238
|
+
return this.wrapper(HttpType.Get, "/post", form);
|
314
239
|
};
|
315
240
|
/**
|
316
241
|
* Edit a post.
|
@@ -318,11 +243,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
318
243
|
* `HTTP.PUT /post`
|
319
244
|
*/
|
320
245
|
LemmyHttp.prototype.editPost = function (form) {
|
321
|
-
return
|
322
|
-
return __generator(this, function (_a) {
|
323
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/post", form)];
|
324
|
-
});
|
325
|
-
});
|
246
|
+
return this.wrapper(HttpType.Put, "/post", form);
|
326
247
|
};
|
327
248
|
/**
|
328
249
|
* Delete a post.
|
@@ -330,11 +251,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
330
251
|
* `HTTP.POST /post/delete`
|
331
252
|
*/
|
332
253
|
LemmyHttp.prototype.deletePost = function (form) {
|
333
|
-
return
|
334
|
-
return __generator(this, function (_a) {
|
335
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/delete", form)];
|
336
|
-
});
|
337
|
-
});
|
254
|
+
return this.wrapper(HttpType.Post, "/post/delete", form);
|
338
255
|
};
|
339
256
|
/**
|
340
257
|
* A moderator remove for a post.
|
@@ -342,11 +259,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
342
259
|
* `HTTP.POST /post/remove`
|
343
260
|
*/
|
344
261
|
LemmyHttp.prototype.removePost = function (form) {
|
345
|
-
return
|
346
|
-
return __generator(this, function (_a) {
|
347
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/remove", form)];
|
348
|
-
});
|
349
|
-
});
|
262
|
+
return this.wrapper(HttpType.Post, "/post/remove", form);
|
350
263
|
};
|
351
264
|
/**
|
352
265
|
* Mark a post as read.
|
@@ -354,11 +267,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
354
267
|
* `HTTP.POST /post/mark_as_read`
|
355
268
|
*/
|
356
269
|
LemmyHttp.prototype.markPostAsRead = function (form) {
|
357
|
-
return
|
358
|
-
return __generator(this, function (_a) {
|
359
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/mark_as_read", form)];
|
360
|
-
});
|
361
|
-
});
|
270
|
+
return this.wrapper(HttpType.Post, "/post/mark_as_read", form);
|
362
271
|
};
|
363
272
|
/**
|
364
273
|
* A moderator can lock a post ( IE disable new comments ).
|
@@ -366,11 +275,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
366
275
|
* `HTTP.POST /post/lock`
|
367
276
|
*/
|
368
277
|
LemmyHttp.prototype.lockPost = function (form) {
|
369
|
-
return
|
370
|
-
return __generator(this, function (_a) {
|
371
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/lock", form)];
|
372
|
-
});
|
373
|
-
});
|
278
|
+
return this.wrapper(HttpType.Post, "/post/lock", form);
|
374
279
|
};
|
375
280
|
/**
|
376
281
|
* A moderator can feature a community post ( IE stick it to the top of a community ).
|
@@ -378,11 +283,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
378
283
|
* `HTTP.POST /post/feature`
|
379
284
|
*/
|
380
285
|
LemmyHttp.prototype.featurePost = function (form) {
|
381
|
-
return
|
382
|
-
return __generator(this, function (_a) {
|
383
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/feature", form)];
|
384
|
-
});
|
385
|
-
});
|
286
|
+
return this.wrapper(HttpType.Post, "/post/feature", form);
|
386
287
|
};
|
387
288
|
/**
|
388
289
|
* Get / fetch posts, with various filters.
|
@@ -390,11 +291,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
390
291
|
* `HTTP.GET /post/list`
|
391
292
|
*/
|
392
293
|
LemmyHttp.prototype.getPosts = function (form) {
|
393
|
-
return
|
394
|
-
return __generator(this, function (_a) {
|
395
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/post/list", form)];
|
396
|
-
});
|
397
|
-
});
|
294
|
+
return this.wrapper(HttpType.Get, "/post/list", form);
|
398
295
|
};
|
399
296
|
/**
|
400
297
|
* Like / vote on a post.
|
@@ -402,11 +299,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
402
299
|
* `HTTP.POST /post/like`
|
403
300
|
*/
|
404
301
|
LemmyHttp.prototype.likePost = function (form) {
|
405
|
-
return
|
406
|
-
return __generator(this, function (_a) {
|
407
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/like", form)];
|
408
|
-
});
|
409
|
-
});
|
302
|
+
return this.wrapper(HttpType.Post, "/post/like", form);
|
410
303
|
};
|
411
304
|
/**
|
412
305
|
* Save a post.
|
@@ -414,11 +307,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
414
307
|
* `HTTP.PUT /post/save`
|
415
308
|
*/
|
416
309
|
LemmyHttp.prototype.savePost = function (form) {
|
417
|
-
return
|
418
|
-
return __generator(this, function (_a) {
|
419
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/post/save", form)];
|
420
|
-
});
|
421
|
-
});
|
310
|
+
return this.wrapper(HttpType.Put, "/post/save", form);
|
422
311
|
};
|
423
312
|
/**
|
424
313
|
* Report a post.
|
@@ -426,11 +315,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
426
315
|
* `HTTP.POST /post/report`
|
427
316
|
*/
|
428
317
|
LemmyHttp.prototype.createPostReport = function (form) {
|
429
|
-
return
|
430
|
-
return __generator(this, function (_a) {
|
431
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/post/report", form)];
|
432
|
-
});
|
433
|
-
});
|
318
|
+
return this.wrapper(HttpType.Post, "/post/report", form);
|
434
319
|
};
|
435
320
|
/**
|
436
321
|
* Resolve a post report. Only a mod can do this.
|
@@ -438,11 +323,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
438
323
|
* `HTTP.PUT /post/report/resolve`
|
439
324
|
*/
|
440
325
|
LemmyHttp.prototype.resolvePostReport = function (form) {
|
441
|
-
return
|
442
|
-
return __generator(this, function (_a) {
|
443
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/post/report/resolve", form)];
|
444
|
-
});
|
445
|
-
});
|
326
|
+
return this.wrapper(HttpType.Put, "/post/report/resolve", form);
|
446
327
|
};
|
447
328
|
/**
|
448
329
|
* List post reports.
|
@@ -450,11 +331,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
450
331
|
* `HTTP.GET /post/report/list`
|
451
332
|
*/
|
452
333
|
LemmyHttp.prototype.listPostReports = function (form) {
|
453
|
-
return
|
454
|
-
return __generator(this, function (_a) {
|
455
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/post/report/list", form)];
|
456
|
-
});
|
457
|
-
});
|
334
|
+
return this.wrapper(HttpType.Get, "/post/report/list", form);
|
458
335
|
};
|
459
336
|
/**
|
460
337
|
* Fetch metadata for any given site.
|
@@ -462,11 +339,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
462
339
|
* `HTTP.GET /post/site_metadata`
|
463
340
|
*/
|
464
341
|
LemmyHttp.prototype.getSiteMetadata = function (form) {
|
465
|
-
return
|
466
|
-
return __generator(this, function (_a) {
|
467
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/post/site_metadata", form)];
|
468
|
-
});
|
469
|
-
});
|
342
|
+
return this.wrapper(HttpType.Get, "/post/site_metadata", form);
|
470
343
|
};
|
471
344
|
/**
|
472
345
|
* Create a comment.
|
@@ -474,11 +347,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
474
347
|
* `HTTP.POST /comment`
|
475
348
|
*/
|
476
349
|
LemmyHttp.prototype.createComment = function (form) {
|
477
|
-
return
|
478
|
-
return __generator(this, function (_a) {
|
479
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/comment", form)];
|
480
|
-
});
|
481
|
-
});
|
350
|
+
return this.wrapper(HttpType.Post, "/comment", form);
|
482
351
|
};
|
483
352
|
/**
|
484
353
|
* Edit a comment.
|
@@ -486,11 +355,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
486
355
|
* `HTTP.PUT /comment`
|
487
356
|
*/
|
488
357
|
LemmyHttp.prototype.editComment = function (form) {
|
489
|
-
return
|
490
|
-
return __generator(this, function (_a) {
|
491
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/comment", form)];
|
492
|
-
});
|
493
|
-
});
|
358
|
+
return this.wrapper(HttpType.Put, "/comment", form);
|
494
359
|
};
|
495
360
|
/**
|
496
361
|
* Delete a comment.
|
@@ -498,11 +363,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
498
363
|
* `HTTP.POST /comment/delete`
|
499
364
|
*/
|
500
365
|
LemmyHttp.prototype.deleteComment = function (form) {
|
501
|
-
return
|
502
|
-
return __generator(this, function (_a) {
|
503
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/delete", form)];
|
504
|
-
});
|
505
|
-
});
|
366
|
+
return this.wrapper(HttpType.Post, "/comment/delete", form);
|
506
367
|
};
|
507
368
|
/**
|
508
369
|
* A moderator remove for a comment.
|
@@ -510,11 +371,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
510
371
|
* `HTTP.POST /comment/remove`
|
511
372
|
*/
|
512
373
|
LemmyHttp.prototype.removeComment = function (form) {
|
513
|
-
return
|
514
|
-
return __generator(this, function (_a) {
|
515
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/remove", form)];
|
516
|
-
});
|
517
|
-
});
|
374
|
+
return this.wrapper(HttpType.Post, "/comment/remove", form);
|
518
375
|
};
|
519
376
|
/**
|
520
377
|
* Mark a comment as read.
|
@@ -522,11 +379,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
522
379
|
* `HTTP.POST /comment/mark_as_read`
|
523
380
|
*/
|
524
381
|
LemmyHttp.prototype.markCommentReplyAsRead = function (form) {
|
525
|
-
return
|
526
|
-
return __generator(this, function (_a) {
|
527
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/mark_as_read", form)];
|
528
|
-
});
|
529
|
-
});
|
382
|
+
return this.wrapper(HttpType.Post, "/comment/mark_as_read", form);
|
530
383
|
};
|
531
384
|
/**
|
532
385
|
* Like / vote on a comment.
|
@@ -534,11 +387,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
534
387
|
* `HTTP.POST /comment/like`
|
535
388
|
*/
|
536
389
|
LemmyHttp.prototype.likeComment = function (form) {
|
537
|
-
return
|
538
|
-
return __generator(this, function (_a) {
|
539
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/like", form)];
|
540
|
-
});
|
541
|
-
});
|
390
|
+
return this.wrapper(HttpType.Post, "/comment/like", form);
|
542
391
|
};
|
543
392
|
/**
|
544
393
|
* Save a comment.
|
@@ -546,11 +395,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
546
395
|
* `HTTP.PUT /comment/save`
|
547
396
|
*/
|
548
397
|
LemmyHttp.prototype.saveComment = function (form) {
|
549
|
-
return
|
550
|
-
return __generator(this, function (_a) {
|
551
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/comment/save", form)];
|
552
|
-
});
|
553
|
-
});
|
398
|
+
return this.wrapper(HttpType.Put, "/comment/save", form);
|
554
399
|
};
|
555
400
|
/**
|
556
401
|
* Get / fetch comments.
|
@@ -558,11 +403,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
558
403
|
* `HTTP.GET /comment/list`
|
559
404
|
*/
|
560
405
|
LemmyHttp.prototype.getComments = function (form) {
|
561
|
-
return
|
562
|
-
return __generator(this, function (_a) {
|
563
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/comment/list", form)];
|
564
|
-
});
|
565
|
-
});
|
406
|
+
return this.wrapper(HttpType.Get, "/comment/list", form);
|
566
407
|
};
|
567
408
|
/**
|
568
409
|
* Report a comment.
|
@@ -570,11 +411,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
570
411
|
* `HTTP.POST /comment/report`
|
571
412
|
*/
|
572
413
|
LemmyHttp.prototype.createCommentReport = function (form) {
|
573
|
-
return
|
574
|
-
return __generator(this, function (_a) {
|
575
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/report", form)];
|
576
|
-
});
|
577
|
-
});
|
414
|
+
return this.wrapper(HttpType.Post, "/comment/report", form);
|
578
415
|
};
|
579
416
|
/**
|
580
417
|
* Resolve a comment report. Only a mod can do this.
|
@@ -582,11 +419,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
582
419
|
* `HTTP.PUT /comment/report/resolve`
|
583
420
|
*/
|
584
421
|
LemmyHttp.prototype.resolveCommentReport = function (form) {
|
585
|
-
return
|
586
|
-
return __generator(this, function (_a) {
|
587
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/comment/report/resolve", form)];
|
588
|
-
});
|
589
|
-
});
|
422
|
+
return this.wrapper(HttpType.Put, "/comment/report/resolve", form);
|
590
423
|
};
|
591
424
|
/**
|
592
425
|
* List comment reports.
|
@@ -594,11 +427,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
594
427
|
* `HTTP.GET /comment/report/list`
|
595
428
|
*/
|
596
429
|
LemmyHttp.prototype.listCommentReports = function (form) {
|
597
|
-
return
|
598
|
-
return __generator(this, function (_a) {
|
599
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/comment/report/list", form)];
|
600
|
-
});
|
601
|
-
});
|
430
|
+
return this.wrapper(HttpType.Get, "/comment/report/list", form);
|
602
431
|
};
|
603
432
|
/**
|
604
433
|
* Get / fetch private messages.
|
@@ -606,11 +435,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
606
435
|
* `HTTP.GET /private_message/list`
|
607
436
|
*/
|
608
437
|
LemmyHttp.prototype.getPrivateMessages = function (form) {
|
609
|
-
return
|
610
|
-
return __generator(this, function (_a) {
|
611
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/private_message/list", form)];
|
612
|
-
});
|
613
|
-
});
|
438
|
+
return this.wrapper(HttpType.Get, "/private_message/list", form);
|
614
439
|
};
|
615
440
|
/**
|
616
441
|
* Create a private message.
|
@@ -618,11 +443,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
618
443
|
* `HTTP.POST /private_message`
|
619
444
|
*/
|
620
445
|
LemmyHttp.prototype.createPrivateMessage = function (form) {
|
621
|
-
return
|
622
|
-
return __generator(this, function (_a) {
|
623
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message", form)];
|
624
|
-
});
|
625
|
-
});
|
446
|
+
return this.wrapper(HttpType.Post, "/private_message", form);
|
626
447
|
};
|
627
448
|
/**
|
628
449
|
* Edit a private message.
|
@@ -630,11 +451,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
630
451
|
* `HTTP.PUT /private_message`
|
631
452
|
*/
|
632
453
|
LemmyHttp.prototype.editPrivateMessage = function (form) {
|
633
|
-
return
|
634
|
-
return __generator(this, function (_a) {
|
635
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/private_message", form)];
|
636
|
-
});
|
637
|
-
});
|
454
|
+
return this.wrapper(HttpType.Put, "/private_message", form);
|
638
455
|
};
|
639
456
|
/**
|
640
457
|
* Delete a private message.
|
@@ -642,11 +459,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
642
459
|
* `HTTP.POST /private_message/delete`
|
643
460
|
*/
|
644
461
|
LemmyHttp.prototype.deletePrivateMessage = function (form) {
|
645
|
-
return
|
646
|
-
return __generator(this, function (_a) {
|
647
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/delete", form)];
|
648
|
-
});
|
649
|
-
});
|
462
|
+
return this.wrapper(HttpType.Post, "/private_message/delete", form);
|
650
463
|
};
|
651
464
|
/**
|
652
465
|
* Mark a private message as read.
|
@@ -654,11 +467,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
654
467
|
* `HTTP.POST /private_message/mark_as_read`
|
655
468
|
*/
|
656
469
|
LemmyHttp.prototype.markPrivateMessageAsRead = function (form) {
|
657
|
-
return
|
658
|
-
return __generator(this, function (_a) {
|
659
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/mark_as_read", form)];
|
660
|
-
});
|
661
|
-
});
|
470
|
+
return this.wrapper(HttpType.Post, "/private_message/mark_as_read", form);
|
662
471
|
};
|
663
472
|
/**
|
664
473
|
* Create a report for a private message.
|
@@ -666,11 +475,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
666
475
|
* `HTTP.POST /private_message/report`
|
667
476
|
*/
|
668
477
|
LemmyHttp.prototype.createPrivateMessageReport = function (form) {
|
669
|
-
return
|
670
|
-
return __generator(this, function (_a) {
|
671
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/report", form)];
|
672
|
-
});
|
673
|
-
});
|
478
|
+
return this.wrapper(HttpType.Post, "/private_message/report", form);
|
674
479
|
};
|
675
480
|
/**
|
676
481
|
* Resolve a report for a private message.
|
@@ -678,11 +483,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
678
483
|
* `HTTP.PUT /private_message/report/resolve`
|
679
484
|
*/
|
680
485
|
LemmyHttp.prototype.resolvePrivateMessageReport = function (form) {
|
681
|
-
return
|
682
|
-
return __generator(this, function (_a) {
|
683
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/private_message/report/resolve", form)];
|
684
|
-
});
|
685
|
-
});
|
486
|
+
return this.wrapper(HttpType.Put, "/private_message/report/resolve", form);
|
686
487
|
};
|
687
488
|
/**
|
688
489
|
* List private message reports.
|
@@ -690,11 +491,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
690
491
|
* `HTTP.GET /private_message/report/list`
|
691
492
|
*/
|
692
493
|
LemmyHttp.prototype.listPrivateMessageReports = function (form) {
|
693
|
-
return
|
694
|
-
return __generator(this, function (_a) {
|
695
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/private_message/report/list", form)];
|
696
|
-
});
|
697
|
-
});
|
494
|
+
return this.wrapper(HttpType.Get, "/private_message/report/list", form);
|
698
495
|
};
|
699
496
|
/**
|
700
497
|
* Register a new user.
|
@@ -702,11 +499,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
702
499
|
* `HTTP.POST /user/register`
|
703
500
|
*/
|
704
501
|
LemmyHttp.prototype.register = function (form) {
|
705
|
-
return
|
706
|
-
return __generator(this, function (_a) {
|
707
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/register", form)];
|
708
|
-
});
|
709
|
-
});
|
502
|
+
return this.wrapper(HttpType.Post, "/user/register", form);
|
710
503
|
};
|
711
504
|
/**
|
712
505
|
* Log into lemmy.
|
@@ -714,11 +507,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
714
507
|
* `HTTP.POST /user/login`
|
715
508
|
*/
|
716
509
|
LemmyHttp.prototype.login = function (form) {
|
717
|
-
return
|
718
|
-
return __generator(this, function (_a) {
|
719
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/login", form)];
|
720
|
-
});
|
721
|
-
});
|
510
|
+
return this.wrapper(HttpType.Post, "/user/login", form);
|
722
511
|
};
|
723
512
|
/**
|
724
513
|
* Get the details for a person.
|
@@ -726,11 +515,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
726
515
|
* `HTTP.GET /user`
|
727
516
|
*/
|
728
517
|
LemmyHttp.prototype.getPersonDetails = function (form) {
|
729
|
-
return
|
730
|
-
return __generator(this, function (_a) {
|
731
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user", form)];
|
732
|
-
});
|
733
|
-
});
|
518
|
+
return this.wrapper(HttpType.Get, "/user", form);
|
734
519
|
};
|
735
520
|
/**
|
736
521
|
* Get mentions for your user.
|
@@ -738,11 +523,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
738
523
|
* `HTTP.GET /user/mention`
|
739
524
|
*/
|
740
525
|
LemmyHttp.prototype.getPersonMentions = function (form) {
|
741
|
-
return
|
742
|
-
return __generator(this, function (_a) {
|
743
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user/mention", form)];
|
744
|
-
});
|
745
|
-
});
|
526
|
+
return this.wrapper(HttpType.Get, "/user/mention", form);
|
746
527
|
};
|
747
528
|
/**
|
748
529
|
* Mark a person mention as read.
|
@@ -750,11 +531,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
750
531
|
* `HTTP.POST /user/mention/mark_as_read`
|
751
532
|
*/
|
752
533
|
LemmyHttp.prototype.markPersonMentionAsRead = function (form) {
|
753
|
-
return
|
754
|
-
return __generator(this, function (_a) {
|
755
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form)];
|
756
|
-
});
|
757
|
-
});
|
534
|
+
return this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form);
|
758
535
|
};
|
759
536
|
/**
|
760
537
|
* Get comment replies.
|
@@ -762,11 +539,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
762
539
|
* `HTTP.GET /user/replies`
|
763
540
|
*/
|
764
541
|
LemmyHttp.prototype.getReplies = function (form) {
|
765
|
-
return
|
766
|
-
return __generator(this, function (_a) {
|
767
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user/replies", form)];
|
768
|
-
});
|
769
|
-
});
|
542
|
+
return this.wrapper(HttpType.Get, "/user/replies", form);
|
770
543
|
};
|
771
544
|
/**
|
772
545
|
* Ban a person from your site.
|
@@ -774,11 +547,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
774
547
|
* `HTTP.POST /user/ban`
|
775
548
|
*/
|
776
549
|
LemmyHttp.prototype.banPerson = function (form) {
|
777
|
-
return
|
778
|
-
return __generator(this, function (_a) {
|
779
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/ban", form)];
|
780
|
-
});
|
781
|
-
});
|
550
|
+
return this.wrapper(HttpType.Post, "/user/ban", form);
|
782
551
|
};
|
783
552
|
/**
|
784
553
|
* Get a list of banned users
|
@@ -786,11 +555,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
786
555
|
* `HTTP.GET /user/banned`
|
787
556
|
*/
|
788
557
|
LemmyHttp.prototype.getBannedPersons = function (form) {
|
789
|
-
return
|
790
|
-
return __generator(this, function (_a) {
|
791
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user/banned", form)];
|
792
|
-
});
|
793
|
-
});
|
558
|
+
return this.wrapper(HttpType.Get, "/user/banned", form);
|
794
559
|
};
|
795
560
|
/**
|
796
561
|
* Block a person.
|
@@ -798,11 +563,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
798
563
|
* `HTTP.POST /user/block`
|
799
564
|
*/
|
800
565
|
LemmyHttp.prototype.blockPerson = function (form) {
|
801
|
-
return
|
802
|
-
return __generator(this, function (_a) {
|
803
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/block", form)];
|
804
|
-
});
|
805
|
-
});
|
566
|
+
return this.wrapper(HttpType.Post, "/user/block", form);
|
806
567
|
};
|
807
568
|
/**
|
808
569
|
* Fetch a Captcha.
|
@@ -810,11 +571,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
810
571
|
* `HTTP.GET /user/get_captcha`
|
811
572
|
*/
|
812
573
|
LemmyHttp.prototype.getCaptcha = function () {
|
813
|
-
return
|
814
|
-
return __generator(this, function (_a) {
|
815
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user/get_captcha", {})];
|
816
|
-
});
|
817
|
-
});
|
574
|
+
return this.wrapper(HttpType.Get, "/user/get_captcha", {});
|
818
575
|
};
|
819
576
|
/**
|
820
577
|
* Delete your account.
|
@@ -822,11 +579,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
822
579
|
* `HTTP.POST /user/delete_account`
|
823
580
|
*/
|
824
581
|
LemmyHttp.prototype.deleteAccount = function (form) {
|
825
|
-
return
|
826
|
-
return __generator(this, function (_a) {
|
827
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/delete_account", form)];
|
828
|
-
});
|
829
|
-
});
|
582
|
+
return this.wrapper(HttpType.Post, "/user/delete_account", form);
|
830
583
|
};
|
831
584
|
/**
|
832
585
|
* Reset your password.
|
@@ -834,11 +587,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
834
587
|
* `HTTP.POST /user/password_reset`
|
835
588
|
*/
|
836
589
|
LemmyHttp.prototype.passwordReset = function (form) {
|
837
|
-
return
|
838
|
-
return __generator(this, function (_a) {
|
839
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/password_reset", form)];
|
840
|
-
});
|
841
|
-
});
|
590
|
+
return this.wrapper(HttpType.Post, "/user/password_reset", form);
|
842
591
|
};
|
843
592
|
/**
|
844
593
|
* Change your password from an email / token based reset.
|
@@ -846,11 +595,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
846
595
|
* `HTTP.POST /user/password_change`
|
847
596
|
*/
|
848
597
|
LemmyHttp.prototype.passwordChange = function (form) {
|
849
|
-
return
|
850
|
-
return __generator(this, function (_a) {
|
851
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/password_change", form)];
|
852
|
-
});
|
853
|
-
});
|
598
|
+
return this.wrapper(HttpType.Post, "/user/password_change", form);
|
854
599
|
};
|
855
600
|
/**
|
856
601
|
* Mark all replies as read.
|
@@ -858,11 +603,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
858
603
|
* `HTTP.POST /user/mark_all_as_read`
|
859
604
|
*/
|
860
605
|
LemmyHttp.prototype.markAllAsRead = function (form) {
|
861
|
-
return
|
862
|
-
return __generator(this, function (_a) {
|
863
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/mark_all_as_read", form)];
|
864
|
-
});
|
865
|
-
});
|
606
|
+
return this.wrapper(HttpType.Post, "/user/mark_all_as_read", form);
|
866
607
|
};
|
867
608
|
/**
|
868
609
|
* Save your user settings.
|
@@ -870,11 +611,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
870
611
|
* `HTTP.PUT /user/save_user_settings`
|
871
612
|
*/
|
872
613
|
LemmyHttp.prototype.saveUserSettings = function (form) {
|
873
|
-
return
|
874
|
-
return __generator(this, function (_a) {
|
875
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/user/save_user_settings", form)];
|
876
|
-
});
|
877
|
-
});
|
614
|
+
return this.wrapper(HttpType.Put, "/user/save_user_settings", form);
|
878
615
|
};
|
879
616
|
/**
|
880
617
|
* Change your user password.
|
@@ -882,11 +619,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
882
619
|
* `HTTP.PUT /user/change_password`
|
883
620
|
*/
|
884
621
|
LemmyHttp.prototype.changePassword = function (form) {
|
885
|
-
return
|
886
|
-
return __generator(this, function (_a) {
|
887
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/user/change_password", form)];
|
888
|
-
});
|
889
|
-
});
|
622
|
+
return this.wrapper(HttpType.Put, "/user/change_password", form);
|
890
623
|
};
|
891
624
|
/**
|
892
625
|
* Get counts for your reports
|
@@ -894,11 +627,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
894
627
|
* `HTTP.GET /user/report_count`
|
895
628
|
*/
|
896
629
|
LemmyHttp.prototype.getReportCount = function (form) {
|
897
|
-
return
|
898
|
-
return __generator(this, function (_a) {
|
899
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user/report_count", form)];
|
900
|
-
});
|
901
|
-
});
|
630
|
+
return this.wrapper(HttpType.Get, "/user/report_count", form);
|
902
631
|
};
|
903
632
|
/**
|
904
633
|
* Get your unread counts
|
@@ -906,11 +635,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
906
635
|
* `HTTP.GET /user/unread_count`
|
907
636
|
*/
|
908
637
|
LemmyHttp.prototype.getUnreadCount = function (form) {
|
909
|
-
return
|
910
|
-
return __generator(this, function (_a) {
|
911
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/user/unread_count", form)];
|
912
|
-
});
|
913
|
-
});
|
638
|
+
return this.wrapper(HttpType.Get, "/user/unread_count", form);
|
914
639
|
};
|
915
640
|
/**
|
916
641
|
* Verify your email
|
@@ -918,11 +643,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
918
643
|
* `HTTP.POST /user/verify_email`
|
919
644
|
*/
|
920
645
|
LemmyHttp.prototype.verifyEmail = function (form) {
|
921
|
-
return
|
922
|
-
return __generator(this, function (_a) {
|
923
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/user/verify_email", form)];
|
924
|
-
});
|
925
|
-
});
|
646
|
+
return this.wrapper(HttpType.Post, "/user/verify_email", form);
|
926
647
|
};
|
927
648
|
/**
|
928
649
|
* Add an admin to your site.
|
@@ -930,11 +651,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
930
651
|
* `HTTP.POST /admin/add`
|
931
652
|
*/
|
932
653
|
LemmyHttp.prototype.addAdmin = function (form) {
|
933
|
-
return
|
934
|
-
return __generator(this, function (_a) {
|
935
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/admin/add", form)];
|
936
|
-
});
|
937
|
-
});
|
654
|
+
return this.wrapper(HttpType.Post, "/admin/add", form);
|
938
655
|
};
|
939
656
|
/**
|
940
657
|
* Get the unread registration applications count.
|
@@ -942,11 +659,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
942
659
|
* `HTTP.GET /admin/registration_application/count`
|
943
660
|
*/
|
944
661
|
LemmyHttp.prototype.getUnreadRegistrationApplicationCount = function (form) {
|
945
|
-
return
|
946
|
-
return __generator(this, function (_a) {
|
947
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/admin/registration_application/count", form)];
|
948
|
-
});
|
949
|
-
});
|
662
|
+
return this.wrapper(HttpType.Get, "/admin/registration_application/count", form);
|
950
663
|
};
|
951
664
|
/**
|
952
665
|
* List the registration applications.
|
@@ -954,11 +667,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
954
667
|
* `HTTP.GET /admin/registration_application/list`
|
955
668
|
*/
|
956
669
|
LemmyHttp.prototype.listRegistrationApplications = function (form) {
|
957
|
-
return
|
958
|
-
return __generator(this, function (_a) {
|
959
|
-
return [2 /*return*/, this.wrapper(HttpType.Get, "/admin/registration_application/list", form)];
|
960
|
-
});
|
961
|
-
});
|
670
|
+
return this.wrapper(HttpType.Get, "/admin/registration_application/list", form);
|
962
671
|
};
|
963
672
|
/**
|
964
673
|
* Approve a registration application
|
@@ -966,11 +675,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
966
675
|
* `HTTP.PUT /admin/registration_application/approve`
|
967
676
|
*/
|
968
677
|
LemmyHttp.prototype.approveRegistrationApplication = function (form) {
|
969
|
-
return
|
970
|
-
return __generator(this, function (_a) {
|
971
|
-
return [2 /*return*/, this.wrapper(HttpType.Put, "/admin/registration_application/approve", form)];
|
972
|
-
});
|
973
|
-
});
|
678
|
+
return this.wrapper(HttpType.Put, "/admin/registration_application/approve", form);
|
974
679
|
};
|
975
680
|
/**
|
976
681
|
* Purge / Delete a person from the database.
|
@@ -978,11 +683,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
978
683
|
* `HTTP.POST /admin/purge/person`
|
979
684
|
*/
|
980
685
|
LemmyHttp.prototype.purgePerson = function (form) {
|
981
|
-
return
|
982
|
-
return __generator(this, function (_a) {
|
983
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/admin/purge/person", form)];
|
984
|
-
});
|
985
|
-
});
|
686
|
+
return this.wrapper(HttpType.Post, "/admin/purge/person", form);
|
986
687
|
};
|
987
688
|
/**
|
988
689
|
* Purge / Delete a community from the database.
|
@@ -990,11 +691,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
990
691
|
* `HTTP.POST /admin/purge/community`
|
991
692
|
*/
|
992
693
|
LemmyHttp.prototype.purgeCommunity = function (form) {
|
993
|
-
return
|
994
|
-
return __generator(this, function (_a) {
|
995
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/admin/purge/community", form)];
|
996
|
-
});
|
997
|
-
});
|
694
|
+
return this.wrapper(HttpType.Post, "/admin/purge/community", form);
|
998
695
|
};
|
999
696
|
/**
|
1000
697
|
* Purge / Delete a post from the database.
|
@@ -1002,11 +699,7 @@ var LemmyHttp = /** @class */ (function () {
|
|
1002
699
|
* `HTTP.POST /admin/purge/post`
|
1003
700
|
*/
|
1004
701
|
LemmyHttp.prototype.purgePost = function (form) {
|
1005
|
-
return
|
1006
|
-
return __generator(this, function (_a) {
|
1007
|
-
return [2 /*return*/, this.wrapper(HttpType.Post, "/admin/purge/post", form)];
|
1008
|
-
});
|
1009
|
-
});
|
702
|
+
return this.wrapper(HttpType.Post, "/admin/purge/post", form);
|
1010
703
|
};
|
1011
704
|
/**
|
1012
705
|
* Purge / Delete a comment from the database.
|
@@ -1014,9 +707,44 @@ var LemmyHttp = /** @class */ (function () {
|
|
1014
707
|
* `HTTP.POST /admin/purge/comment`
|
1015
708
|
*/
|
1016
709
|
LemmyHttp.prototype.purgeComment = function (form) {
|
1017
|
-
return
|
1018
|
-
|
1019
|
-
|
710
|
+
return this.wrapper(HttpType.Post, "/admin/purge/comment", form);
|
711
|
+
};
|
712
|
+
/**
|
713
|
+
* Upload an image to the server.
|
714
|
+
*/
|
715
|
+
LemmyHttp.prototype.uploadImage = function (_a) {
|
716
|
+
var _b, _c, _d, _e;
|
717
|
+
var image = _a.image, auth = _a.auth;
|
718
|
+
return __awaiter(this, void 0, void 0, function () {
|
719
|
+
var formData, headers, url, delete_url, response, responseJson, _f, hash, deleteToken;
|
720
|
+
return __generator(this, function (_g) {
|
721
|
+
switch (_g.label) {
|
722
|
+
case 0:
|
723
|
+
formData = createFormData(image);
|
724
|
+
headers = {};
|
725
|
+
if (!((_c = (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) === null || _b === void 0 ? void 0 : _b.cookie) === null || _c === void 0 ? void 0 : _c.includes("jwt=")) &&
|
726
|
+
!((_e = (_d = this.headers) === null || _d === void 0 ? void 0 : _d.Cookie) === null || _e === void 0 ? void 0 : _e.includes("jwt="))) {
|
727
|
+
headers.Cookie = "jwt=".concat(auth);
|
728
|
+
}
|
729
|
+
url = undefined;
|
730
|
+
delete_url = undefined;
|
731
|
+
return [4 /*yield*/, (0, cross_fetch_1.default)(this.pictrsUrl, {
|
732
|
+
method: HttpType.Post,
|
733
|
+
body: formData,
|
734
|
+
headers: __assign(__assign({}, this.headers), headers),
|
735
|
+
})];
|
736
|
+
case 1:
|
737
|
+
response = _g.sent();
|
738
|
+
return [4 /*yield*/, response.json()];
|
739
|
+
case 2:
|
740
|
+
responseJson = _g.sent();
|
741
|
+
if (responseJson.msg === "ok") {
|
742
|
+
_f = responseJson.files[0], hash = _f.file, deleteToken = _f.delete_token;
|
743
|
+
delete_url = "".concat(this.pictrsUrl, "/delete/").concat(deleteToken, "/").concat(hash);
|
744
|
+
url = "".concat(this.pictrsUrl, "/").concat(hash);
|
745
|
+
}
|
746
|
+
return [2 /*return*/, __assign(__assign({}, responseJson), { url: url, delete_url: delete_url })];
|
747
|
+
}
|
1020
748
|
});
|
1021
749
|
});
|
1022
750
|
};
|
@@ -1025,23 +753,30 @@ var LemmyHttp = /** @class */ (function () {
|
|
1025
753
|
};
|
1026
754
|
LemmyHttp.prototype.wrapper = function (type_, endpoint, form) {
|
1027
755
|
return __awaiter(this, void 0, void 0, function () {
|
1028
|
-
var getUrl;
|
1029
|
-
return __generator(this, function (_a) {
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
756
|
+
var getUrl, response, response;
|
757
|
+
return __generator(this, function (_a) {
|
758
|
+
switch (_a.label) {
|
759
|
+
case 0:
|
760
|
+
if (!(type_ === HttpType.Get)) return [3 /*break*/, 3];
|
761
|
+
getUrl = "".concat(this.buildFullUrl(endpoint), "?").concat(encodeGetParams(form));
|
762
|
+
return [4 /*yield*/, (0, cross_fetch_1.default)(getUrl, {
|
763
|
+
method: HttpType.Get,
|
764
|
+
headers: this.headers,
|
765
|
+
})];
|
766
|
+
case 1:
|
767
|
+
response = _a.sent();
|
768
|
+
return [4 /*yield*/, response.json()];
|
769
|
+
case 2: return [2 /*return*/, _a.sent()];
|
770
|
+
case 3: return [4 /*yield*/, (0, cross_fetch_1.default)(this.buildFullUrl(endpoint), {
|
1039
771
|
method: type_,
|
1040
772
|
headers: __assign({ "Content-Type": "application/json" }, this.headers),
|
1041
773
|
body: JSON.stringify(form),
|
1042
|
-
})
|
774
|
+
})];
|
775
|
+
case 4:
|
776
|
+
response = _a.sent();
|
777
|
+
return [4 /*yield*/, response.json()];
|
778
|
+
case 5: return [2 /*return*/, _a.sent()];
|
1043
779
|
}
|
1044
|
-
return [2 /*return*/];
|
1045
780
|
});
|
1046
781
|
});
|
1047
782
|
};
|
@@ -1054,3 +789,14 @@ function encodeGetParams(p) {
|
|
1054
789
|
.map(function (kv) { return kv.map(encodeURIComponent).join("="); })
|
1055
790
|
.join("&");
|
1056
791
|
}
|
792
|
+
function createFormData(image) {
|
793
|
+
var formData = new form_data_1.default();
|
794
|
+
if (image.constructor.name === "File") {
|
795
|
+
formData.append("images[]", image);
|
796
|
+
}
|
797
|
+
else {
|
798
|
+
// The filename doesn't affect the file type or file name that ends up in pictrs
|
799
|
+
formData.append("images[]", image, { filename: "image.jpg" });
|
800
|
+
}
|
801
|
+
return formData;
|
802
|
+
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
export declare const VERSION = "v3";
|
2
3
|
/**
|
3
4
|
* All of the websocket operations available.
|
@@ -221,3 +222,23 @@ export interface SiteMetadata {
|
|
221
222
|
image?: string;
|
222
223
|
html?: string;
|
223
224
|
}
|
225
|
+
export interface UploadImage {
|
226
|
+
image: File | Buffer;
|
227
|
+
/**
|
228
|
+
* Optional if cookie with jwt set is already present. Otherwise, auth is required.
|
229
|
+
*/
|
230
|
+
auth?: string;
|
231
|
+
}
|
232
|
+
export interface UploadImageResponse {
|
233
|
+
/**
|
234
|
+
* Is "ok" if the upload was successful; is something else otherwise.
|
235
|
+
*/
|
236
|
+
msg: string;
|
237
|
+
files?: ImageFile[];
|
238
|
+
url?: string;
|
239
|
+
delete_url?: string;
|
240
|
+
}
|
241
|
+
export interface ImageFile {
|
242
|
+
file: string;
|
243
|
+
delete_token: string;
|
244
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lemmy-js-client",
|
3
|
-
"version": "0.17.2-rc.
|
3
|
+
"version": "0.17.2-rc.4",
|
4
4
|
"description": "A javascript / typescript client for Lemmy",
|
5
5
|
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
6
6
|
"license": "AGPL-3.0",
|
@@ -26,11 +26,11 @@
|
|
26
26
|
]
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"
|
29
|
+
"cross-fetch": "^3.1.5",
|
30
|
+
"form-data": "^4.0.0"
|
30
31
|
},
|
31
32
|
"devDependencies": {
|
32
33
|
"@types/node": "^18.6.2",
|
33
|
-
"@types/node-fetch": "2.6.2",
|
34
34
|
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
35
35
|
"@typescript-eslint/parser": "^5.31.0",
|
36
36
|
"eslint": "^8.20.0",
|