lemmy-js-client 0.17.2-rc.9 → 0.18.0-rc.1

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.
Files changed (43) hide show
  1. package/dist/http.d.ts +27 -12
  2. package/dist/http.js +351 -375
  3. package/dist/index.d.ts +248 -1
  4. package/dist/index.js +3 -1
  5. package/dist/types/BanFromCommunity.d.ts +1 -1
  6. package/dist/types/BanPerson.d.ts +1 -1
  7. package/dist/types/CommentAggregates.d.ts +4 -3
  8. package/dist/types/CommunityAggregates.d.ts +8 -7
  9. package/dist/types/GetCaptcha.d.ts +3 -1
  10. package/dist/types/GetComments.d.ts +2 -2
  11. package/dist/types/GetCommunityResponse.d.ts +0 -2
  12. package/dist/types/GetFederatedInstances.d.ts +3 -1
  13. package/dist/types/GetModlog.d.ts +2 -2
  14. package/dist/types/GetPersonDetails.d.ts +2 -2
  15. package/dist/types/GetPersonMentions.d.ts +2 -2
  16. package/dist/types/GetPost.d.ts +4 -2
  17. package/dist/types/GetPostResponse.d.ts +0 -1
  18. package/dist/types/GetPosts.d.ts +2 -2
  19. package/dist/types/GetPrivateMessages.d.ts +2 -2
  20. package/dist/types/GetReplies.d.ts +2 -2
  21. package/dist/types/GetReportCountResponse.d.ts +3 -3
  22. package/dist/types/GetSiteResponse.d.ts +0 -1
  23. package/dist/types/GetUnreadCountResponse.d.ts +3 -3
  24. package/dist/types/GetUnreadRegistrationApplicationCountResponse.d.ts +1 -1
  25. package/dist/types/ListCommentReports.d.ts +2 -2
  26. package/dist/types/ListCommunities.d.ts +2 -2
  27. package/dist/types/ListPostReports.d.ts +2 -2
  28. package/dist/types/ListPrivateMessageReports.d.ts +2 -2
  29. package/dist/types/ListRegistrationApplications.d.ts +2 -2
  30. package/dist/types/LocalSite.d.ts +0 -1
  31. package/dist/types/ModlogListParams.d.ts +2 -2
  32. package/dist/types/PersonAggregates.d.ts +4 -4
  33. package/dist/types/PostAggregates.d.ts +6 -4
  34. package/dist/types/PostView.d.ts +1 -1
  35. package/dist/types/RemoveCommunity.d.ts +1 -1
  36. package/dist/types/Search.d.ts +2 -2
  37. package/dist/types/SiteAggregates.d.ts +8 -8
  38. package/dist/types/SiteResponse.d.ts +2 -0
  39. package/dist/types/others.d.ts +2 -1
  40. package/dist/types/others.js +1 -0
  41. package/dist/websocket.d.ts +7 -1
  42. package/dist/websocket.js +185 -181
  43. package/package.json +14 -15
package/dist/http.js CHANGED
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,41 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
48
21
  };
49
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
24
  };
25
+ var _LemmyHttp_instances, _LemmyHttp_apiUrl, _LemmyHttp_headers, _LemmyHttp_pictrsUrl, _LemmyHttp_buildFullUrl, _LemmyHttp_wrapper;
52
26
  Object.defineProperty(exports, "__esModule", { value: true });
53
27
  exports.LemmyHttp = void 0;
54
- var cross_fetch_1 = __importDefault(require("cross-fetch"));
55
- var form_data_1 = __importDefault(require("form-data"));
56
- var others_1 = require("./types/others");
28
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
29
+ const form_data_1 = __importDefault(require("form-data"));
30
+ const others_1 = require("./types/others");
57
31
  var HttpType;
58
32
  (function (HttpType) {
59
33
  HttpType["Get"] = "GET";
@@ -63,18 +37,21 @@ var HttpType;
63
37
  /**
64
38
  * Helps build lemmy HTTP requests.
65
39
  */
66
- var LemmyHttp = /** @class */ (function () {
40
+ class LemmyHttp {
67
41
  /**
68
42
  * Generates a new instance of LemmyHttp.
69
43
  * @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
70
44
  * @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
71
45
  */
72
- function LemmyHttp(baseUrl, headers) {
73
- this.headers = {};
74
- this.apiUrl = "".concat(baseUrl, "/api/").concat(others_1.VERSION);
75
- this.pictrsUrl = "".concat(baseUrl, "/pictrs/image");
46
+ constructor(baseUrl, headers) {
47
+ _LemmyHttp_instances.add(this);
48
+ _LemmyHttp_apiUrl.set(this, void 0);
49
+ _LemmyHttp_headers.set(this, {});
50
+ _LemmyHttp_pictrsUrl.set(this, void 0);
51
+ __classPrivateFieldSet(this, _LemmyHttp_apiUrl, `${baseUrl.replace(/\/+$/, "")}/api/${others_1.VERSION}`, "f");
52
+ __classPrivateFieldSet(this, _LemmyHttp_pictrsUrl, `${baseUrl}/pictrs/image`, "f");
76
53
  if (headers) {
77
- this.headers = headers;
54
+ __classPrivateFieldSet(this, _LemmyHttp_headers, headers, "f");
78
55
  }
79
56
  }
80
57
  /**
@@ -82,759 +59,758 @@ var LemmyHttp = /** @class */ (function () {
82
59
  *
83
60
  * `HTTP.GET /site`
84
61
  */
85
- LemmyHttp.prototype.getSite = function (form) {
86
- return this.wrapper(HttpType.Get, "/site", form);
87
- };
62
+ getSite(form) {
63
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/site", form);
64
+ }
88
65
  /**
89
66
  * Create your site.
90
67
  *
91
68
  * `HTTP.POST /site`
92
69
  */
93
- LemmyHttp.prototype.createSite = function (form) {
94
- return this.wrapper(HttpType.Post, "/site", form);
95
- };
70
+ createSite(form) {
71
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/site", form);
72
+ }
96
73
  /**
97
74
  * Edit your site.
98
75
  *
99
76
  * `HTTP.PUT /site`
100
77
  */
101
- LemmyHttp.prototype.editSite = function (form) {
102
- return this.wrapper(HttpType.Put, "/site", form);
103
- };
78
+ editSite(form) {
79
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/site", form);
80
+ }
104
81
  /**
105
82
  * Leave the Site admins.
106
83
  *
107
84
  * `HTTP.POST /user/leave_admin`
108
85
  */
109
- LemmyHttp.prototype.leaveAdmin = function (form) {
110
- return this.wrapper(HttpType.Post, "/user/leave_admin", form);
111
- };
86
+ leaveAdmin(form) {
87
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/leave_admin", form);
88
+ }
112
89
  /**
113
90
  * Get the modlog.
114
91
  *
115
92
  * `HTTP.GET /modlog`
116
93
  */
117
- LemmyHttp.prototype.getModlog = function (form) {
118
- return this.wrapper(HttpType.Get, "/modlog", form);
119
- };
94
+ getModlog(form) {
95
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/modlog", form);
96
+ }
120
97
  /**
121
98
  * Search lemmy.
122
99
  *
123
100
  * `HTTP.GET /search`
124
101
  */
125
- LemmyHttp.prototype.search = function (form) {
126
- return this.wrapper(HttpType.Get, "/search", form);
127
- };
102
+ search(form) {
103
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/search", form);
104
+ }
128
105
  /**
129
106
  * Fetch a non-local / federated object.
130
107
  *
131
108
  * `HTTP.GET /resolve_object`
132
109
  */
133
- LemmyHttp.prototype.resolveObject = function (form) {
134
- return this.wrapper(HttpType.Get, "/resolve_object", form);
135
- };
110
+ resolveObject(form) {
111
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/resolve_object", form);
112
+ }
136
113
  /**
137
114
  * Create a new community.
138
115
  *
139
116
  * `HTTP.POST /community`
140
117
  */
141
- LemmyHttp.prototype.createCommunity = function (form) {
142
- return this.wrapper(HttpType.Post, "/community", form);
143
- };
118
+ createCommunity(form) {
119
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community", form);
120
+ }
144
121
  /**
145
122
  * Get / fetch a community.
146
123
  *
147
124
  * `HTTP.GET /community`
148
125
  */
149
- LemmyHttp.prototype.getCommunity = function (form) {
150
- return this.wrapper(HttpType.Get, "/community", form);
151
- };
126
+ getCommunity(form) {
127
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/community", form);
128
+ }
152
129
  /**
153
130
  * Edit a community.
154
131
  *
155
132
  * `HTTP.PUT /community`
156
133
  */
157
- LemmyHttp.prototype.editCommunity = function (form) {
158
- return this.wrapper(HttpType.Put, "/community", form);
159
- };
134
+ editCommunity(form) {
135
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/community", form);
136
+ }
160
137
  /**
161
138
  * List communities, with various filters.
162
139
  *
163
140
  * `HTTP.GET /community/list`
164
141
  */
165
- LemmyHttp.prototype.listCommunities = function (form) {
166
- return this.wrapper(HttpType.Get, "/community/list", form);
167
- };
142
+ listCommunities(form) {
143
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/community/list", form);
144
+ }
168
145
  /**
169
146
  * Follow / subscribe to a community.
170
147
  *
171
148
  * `HTTP.POST /community/follow`
172
149
  */
173
- LemmyHttp.prototype.followCommunity = function (form) {
174
- return this.wrapper(HttpType.Post, "/community/follow", form);
175
- };
150
+ followCommunity(form) {
151
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/follow", form);
152
+ }
176
153
  /**
177
154
  * Block a community.
178
155
  *
179
156
  * `HTTP.POST /community/block`
180
157
  */
181
- LemmyHttp.prototype.blockCommunity = function (form) {
182
- return this.wrapper(HttpType.Post, "/community/block", form);
183
- };
158
+ blockCommunity(form) {
159
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/block", form);
160
+ }
184
161
  /**
185
162
  * Delete a community.
186
163
  *
187
164
  * `HTTP.POST /community/delete`
188
165
  */
189
- LemmyHttp.prototype.deleteCommunity = function (form) {
190
- return this.wrapper(HttpType.Post, "/community/delete", form);
191
- };
166
+ deleteCommunity(form) {
167
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/delete", form);
168
+ }
192
169
  /**
193
170
  * A moderator remove for a community.
194
171
  *
195
172
  * `HTTP.POST /community/remove`
196
173
  */
197
- LemmyHttp.prototype.removeCommunity = function (form) {
198
- return this.wrapper(HttpType.Post, "/community/remove", form);
199
- };
174
+ removeCommunity(form) {
175
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/remove", form);
176
+ }
200
177
  /**
201
178
  * Transfer your community to an existing moderator.
202
179
  *
203
180
  * `HTTP.POST /community/transfer`
204
181
  */
205
- LemmyHttp.prototype.transferCommunity = function (form) {
206
- return this.wrapper(HttpType.Post, "/community/transfer", form);
207
- };
182
+ transferCommunity(form) {
183
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/transfer", form);
184
+ }
208
185
  /**
209
186
  * Ban a user from a community.
210
187
  *
211
188
  * `HTTP.POST /community/ban_user`
212
189
  */
213
- LemmyHttp.prototype.banFromCommunity = function (form) {
214
- return this.wrapper(HttpType.Post, "/community/ban_user", form);
215
- };
190
+ banFromCommunity(form) {
191
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/ban_user", form);
192
+ }
216
193
  /**
217
194
  * Add a moderator to your community.
218
195
  *
219
196
  * `HTTP.POST /community/mod`
220
197
  */
221
- LemmyHttp.prototype.addModToCommunity = function (form) {
222
- return this.wrapper(HttpType.Post, "/community/mod", form);
223
- };
198
+ addModToCommunity(form) {
199
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/community/mod", form);
200
+ }
224
201
  /**
225
202
  * Create a post.
226
203
  *
227
204
  * `HTTP.POST /post`
228
205
  */
229
- LemmyHttp.prototype.createPost = function (form) {
230
- return this.wrapper(HttpType.Post, "/post", form);
231
- };
206
+ createPost(form) {
207
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post", form);
208
+ }
232
209
  /**
233
210
  * Get / fetch a post.
234
211
  *
235
212
  * `HTTP.GET /post`
236
213
  */
237
- LemmyHttp.prototype.getPost = function (form) {
238
- return this.wrapper(HttpType.Get, "/post", form);
239
- };
214
+ getPost(form) {
215
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post", form);
216
+ }
240
217
  /**
241
218
  * Edit a post.
242
219
  *
243
220
  * `HTTP.PUT /post`
244
221
  */
245
- LemmyHttp.prototype.editPost = function (form) {
246
- return this.wrapper(HttpType.Put, "/post", form);
247
- };
222
+ editPost(form) {
223
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/post", form);
224
+ }
248
225
  /**
249
226
  * Delete a post.
250
227
  *
251
228
  * `HTTP.POST /post/delete`
252
229
  */
253
- LemmyHttp.prototype.deletePost = function (form) {
254
- return this.wrapper(HttpType.Post, "/post/delete", form);
255
- };
230
+ deletePost(form) {
231
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/delete", form);
232
+ }
256
233
  /**
257
234
  * A moderator remove for a post.
258
235
  *
259
236
  * `HTTP.POST /post/remove`
260
237
  */
261
- LemmyHttp.prototype.removePost = function (form) {
262
- return this.wrapper(HttpType.Post, "/post/remove", form);
263
- };
238
+ removePost(form) {
239
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/remove", form);
240
+ }
264
241
  /**
265
242
  * Mark a post as read.
266
243
  *
267
244
  * `HTTP.POST /post/mark_as_read`
268
245
  */
269
- LemmyHttp.prototype.markPostAsRead = function (form) {
270
- return this.wrapper(HttpType.Post, "/post/mark_as_read", form);
271
- };
246
+ markPostAsRead(form) {
247
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/mark_as_read", form);
248
+ }
272
249
  /**
273
250
  * A moderator can lock a post ( IE disable new comments ).
274
251
  *
275
252
  * `HTTP.POST /post/lock`
276
253
  */
277
- LemmyHttp.prototype.lockPost = function (form) {
278
- return this.wrapper(HttpType.Post, "/post/lock", form);
279
- };
254
+ lockPost(form) {
255
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/lock", form);
256
+ }
280
257
  /**
281
258
  * A moderator can feature a community post ( IE stick it to the top of a community ).
282
259
  *
283
260
  * `HTTP.POST /post/feature`
284
261
  */
285
- LemmyHttp.prototype.featurePost = function (form) {
286
- return this.wrapper(HttpType.Post, "/post/feature", form);
287
- };
262
+ featurePost(form) {
263
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/feature", form);
264
+ }
288
265
  /**
289
266
  * Get / fetch posts, with various filters.
290
267
  *
291
268
  * `HTTP.GET /post/list`
292
269
  */
293
- LemmyHttp.prototype.getPosts = function (form) {
294
- return this.wrapper(HttpType.Get, "/post/list", form);
295
- };
270
+ getPosts(form) {
271
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/list", form);
272
+ }
296
273
  /**
297
274
  * Like / vote on a post.
298
275
  *
299
276
  * `HTTP.POST /post/like`
300
277
  */
301
- LemmyHttp.prototype.likePost = function (form) {
302
- return this.wrapper(HttpType.Post, "/post/like", form);
303
- };
278
+ likePost(form) {
279
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/like", form);
280
+ }
304
281
  /**
305
282
  * Save a post.
306
283
  *
307
284
  * `HTTP.PUT /post/save`
308
285
  */
309
- LemmyHttp.prototype.savePost = function (form) {
310
- return this.wrapper(HttpType.Put, "/post/save", form);
311
- };
286
+ savePost(form) {
287
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/post/save", form);
288
+ }
312
289
  /**
313
290
  * Report a post.
314
291
  *
315
292
  * `HTTP.POST /post/report`
316
293
  */
317
- LemmyHttp.prototype.createPostReport = function (form) {
318
- return this.wrapper(HttpType.Post, "/post/report", form);
319
- };
294
+ createPostReport(form) {
295
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/post/report", form);
296
+ }
320
297
  /**
321
298
  * Resolve a post report. Only a mod can do this.
322
299
  *
323
300
  * `HTTP.PUT /post/report/resolve`
324
301
  */
325
- LemmyHttp.prototype.resolvePostReport = function (form) {
326
- return this.wrapper(HttpType.Put, "/post/report/resolve", form);
327
- };
302
+ resolvePostReport(form) {
303
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/post/report/resolve", form);
304
+ }
328
305
  /**
329
306
  * List post reports.
330
307
  *
331
308
  * `HTTP.GET /post/report/list`
332
309
  */
333
- LemmyHttp.prototype.listPostReports = function (form) {
334
- return this.wrapper(HttpType.Get, "/post/report/list", form);
335
- };
310
+ listPostReports(form) {
311
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/report/list", form);
312
+ }
336
313
  /**
337
314
  * Fetch metadata for any given site.
338
315
  *
339
316
  * `HTTP.GET /post/site_metadata`
340
317
  */
341
- LemmyHttp.prototype.getSiteMetadata = function (form) {
342
- return this.wrapper(HttpType.Get, "/post/site_metadata", form);
343
- };
318
+ getSiteMetadata(form) {
319
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/post/site_metadata", form);
320
+ }
344
321
  /**
345
322
  * Create a comment.
346
323
  *
347
324
  * `HTTP.POST /comment`
348
325
  */
349
- LemmyHttp.prototype.createComment = function (form) {
350
- return this.wrapper(HttpType.Post, "/comment", form);
351
- };
326
+ createComment(form) {
327
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment", form);
328
+ }
352
329
  /**
353
330
  * Edit a comment.
354
331
  *
355
332
  * `HTTP.PUT /comment`
356
333
  */
357
- LemmyHttp.prototype.editComment = function (form) {
358
- return this.wrapper(HttpType.Put, "/comment", form);
359
- };
334
+ editComment(form) {
335
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/comment", form);
336
+ }
360
337
  /**
361
338
  * Delete a comment.
362
339
  *
363
340
  * `HTTP.POST /comment/delete`
364
341
  */
365
- LemmyHttp.prototype.deleteComment = function (form) {
366
- return this.wrapper(HttpType.Post, "/comment/delete", form);
367
- };
342
+ deleteComment(form) {
343
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/delete", form);
344
+ }
368
345
  /**
369
346
  * A moderator remove for a comment.
370
347
  *
371
348
  * `HTTP.POST /comment/remove`
372
349
  */
373
- LemmyHttp.prototype.removeComment = function (form) {
374
- return this.wrapper(HttpType.Post, "/comment/remove", form);
375
- };
350
+ removeComment(form) {
351
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/remove", form);
352
+ }
376
353
  /**
377
354
  * Mark a comment as read.
378
355
  *
379
356
  * `HTTP.POST /comment/mark_as_read`
380
357
  */
381
- LemmyHttp.prototype.markCommentReplyAsRead = function (form) {
382
- return this.wrapper(HttpType.Post, "/comment/mark_as_read", form);
383
- };
358
+ markCommentReplyAsRead(form) {
359
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/mark_as_read", form);
360
+ }
384
361
  /**
385
362
  * Like / vote on a comment.
386
363
  *
387
364
  * `HTTP.POST /comment/like`
388
365
  */
389
- LemmyHttp.prototype.likeComment = function (form) {
390
- return this.wrapper(HttpType.Post, "/comment/like", form);
391
- };
366
+ likeComment(form) {
367
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/like", form);
368
+ }
392
369
  /**
393
370
  * Save a comment.
394
371
  *
395
372
  * `HTTP.PUT /comment/save`
396
373
  */
397
- LemmyHttp.prototype.saveComment = function (form) {
398
- return this.wrapper(HttpType.Put, "/comment/save", form);
399
- };
374
+ saveComment(form) {
375
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/comment/save", form);
376
+ }
377
+ /**
378
+ * Distinguishes a comment (speak as moderator)
379
+ *
380
+ * `HTTP.POST /comment/distinguish`
381
+ */
382
+ distinguishComment(form) {
383
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/distinguish", form);
384
+ }
400
385
  /**
401
386
  * Get / fetch comments.
402
387
  *
403
388
  * `HTTP.GET /comment/list`
404
389
  */
405
- LemmyHttp.prototype.getComments = function (form) {
406
- return this.wrapper(HttpType.Get, "/comment/list", form);
407
- };
390
+ getComments(form) {
391
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment/list", form);
392
+ }
408
393
  /**
409
394
  * Get / fetch comment.
410
395
  *
411
396
  * `HTTP.GET /comment`
412
397
  */
413
- LemmyHttp.prototype.getComment = function (form) {
414
- return this.wrapper(HttpType.Get, "/comment", form);
415
- };
398
+ getComment(form) {
399
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment", form);
400
+ }
416
401
  /**
417
402
  * Report a comment.
418
403
  *
419
404
  * `HTTP.POST /comment/report`
420
405
  */
421
- LemmyHttp.prototype.createCommentReport = function (form) {
422
- return this.wrapper(HttpType.Post, "/comment/report", form);
423
- };
406
+ createCommentReport(form) {
407
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/comment/report", form);
408
+ }
424
409
  /**
425
410
  * Resolve a comment report. Only a mod can do this.
426
411
  *
427
412
  * `HTTP.PUT /comment/report/resolve`
428
413
  */
429
- LemmyHttp.prototype.resolveCommentReport = function (form) {
430
- return this.wrapper(HttpType.Put, "/comment/report/resolve", form);
431
- };
414
+ resolveCommentReport(form) {
415
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/comment/report/resolve", form);
416
+ }
432
417
  /**
433
418
  * List comment reports.
434
419
  *
435
420
  * `HTTP.GET /comment/report/list`
436
421
  */
437
- LemmyHttp.prototype.listCommentReports = function (form) {
438
- return this.wrapper(HttpType.Get, "/comment/report/list", form);
439
- };
422
+ listCommentReports(form) {
423
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/comment/report/list", form);
424
+ }
440
425
  /**
441
426
  * Get / fetch private messages.
442
427
  *
443
428
  * `HTTP.GET /private_message/list`
444
429
  */
445
- LemmyHttp.prototype.getPrivateMessages = function (form) {
446
- return this.wrapper(HttpType.Get, "/private_message/list", form);
447
- };
430
+ getPrivateMessages(form) {
431
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/private_message/list", form);
432
+ }
448
433
  /**
449
434
  * Create a private message.
450
435
  *
451
436
  * `HTTP.POST /private_message`
452
437
  */
453
- LemmyHttp.prototype.createPrivateMessage = function (form) {
454
- return this.wrapper(HttpType.Post, "/private_message", form);
455
- };
438
+ createPrivateMessage(form) {
439
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message", form);
440
+ }
456
441
  /**
457
442
  * Edit a private message.
458
443
  *
459
444
  * `HTTP.PUT /private_message`
460
445
  */
461
- LemmyHttp.prototype.editPrivateMessage = function (form) {
462
- return this.wrapper(HttpType.Put, "/private_message", form);
463
- };
446
+ editPrivateMessage(form) {
447
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/private_message", form);
448
+ }
464
449
  /**
465
450
  * Delete a private message.
466
451
  *
467
452
  * `HTTP.POST /private_message/delete`
468
453
  */
469
- LemmyHttp.prototype.deletePrivateMessage = function (form) {
470
- return this.wrapper(HttpType.Post, "/private_message/delete", form);
471
- };
454
+ deletePrivateMessage(form) {
455
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message/delete", form);
456
+ }
472
457
  /**
473
458
  * Mark a private message as read.
474
459
  *
475
460
  * `HTTP.POST /private_message/mark_as_read`
476
461
  */
477
- LemmyHttp.prototype.markPrivateMessageAsRead = function (form) {
478
- return this.wrapper(HttpType.Post, "/private_message/mark_as_read", form);
479
- };
462
+ markPrivateMessageAsRead(form) {
463
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message/mark_as_read", form);
464
+ }
480
465
  /**
481
466
  * Create a report for a private message.
482
467
  *
483
468
  * `HTTP.POST /private_message/report`
484
469
  */
485
- LemmyHttp.prototype.createPrivateMessageReport = function (form) {
486
- return this.wrapper(HttpType.Post, "/private_message/report", form);
487
- };
470
+ createPrivateMessageReport(form) {
471
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/private_message/report", form);
472
+ }
488
473
  /**
489
474
  * Resolve a report for a private message.
490
475
  *
491
476
  * `HTTP.PUT /private_message/report/resolve`
492
477
  */
493
- LemmyHttp.prototype.resolvePrivateMessageReport = function (form) {
494
- return this.wrapper(HttpType.Put, "/private_message/report/resolve", form);
495
- };
478
+ resolvePrivateMessageReport(form) {
479
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/private_message/report/resolve", form);
480
+ }
496
481
  /**
497
482
  * List private message reports.
498
483
  *
499
484
  * `HTTP.GET /private_message/report/list`
500
485
  */
501
- LemmyHttp.prototype.listPrivateMessageReports = function (form) {
502
- return this.wrapper(HttpType.Get, "/private_message/report/list", form);
503
- };
486
+ listPrivateMessageReports(form) {
487
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/private_message/report/list", form);
488
+ }
504
489
  /**
505
490
  * Register a new user.
506
491
  *
507
492
  * `HTTP.POST /user/register`
508
493
  */
509
- LemmyHttp.prototype.register = function (form) {
510
- return this.wrapper(HttpType.Post, "/user/register", form);
511
- };
494
+ register(form) {
495
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/register", form);
496
+ }
512
497
  /**
513
498
  * Log into lemmy.
514
499
  *
515
500
  * `HTTP.POST /user/login`
516
501
  */
517
- LemmyHttp.prototype.login = function (form) {
518
- return this.wrapper(HttpType.Post, "/user/login", form);
519
- };
502
+ login(form) {
503
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/login", form);
504
+ }
520
505
  /**
521
506
  * Get the details for a person.
522
507
  *
523
508
  * `HTTP.GET /user`
524
509
  */
525
- LemmyHttp.prototype.getPersonDetails = function (form) {
526
- return this.wrapper(HttpType.Get, "/user", form);
527
- };
510
+ getPersonDetails(form) {
511
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user", form);
512
+ }
528
513
  /**
529
514
  * Get mentions for your user.
530
515
  *
531
516
  * `HTTP.GET /user/mention`
532
517
  */
533
- LemmyHttp.prototype.getPersonMentions = function (form) {
534
- return this.wrapper(HttpType.Get, "/user/mention", form);
535
- };
518
+ getPersonMentions(form) {
519
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/mention", form);
520
+ }
536
521
  /**
537
522
  * Mark a person mention as read.
538
523
  *
539
524
  * `HTTP.POST /user/mention/mark_as_read`
540
525
  */
541
- LemmyHttp.prototype.markPersonMentionAsRead = function (form) {
542
- return this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form);
543
- };
526
+ markPersonMentionAsRead(form) {
527
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mention/mark_as_read", form);
528
+ }
544
529
  /**
545
530
  * Get comment replies.
546
531
  *
547
532
  * `HTTP.GET /user/replies`
548
533
  */
549
- LemmyHttp.prototype.getReplies = function (form) {
550
- return this.wrapper(HttpType.Get, "/user/replies", form);
551
- };
534
+ getReplies(form) {
535
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/replies", form);
536
+ }
552
537
  /**
553
538
  * Ban a person from your site.
554
539
  *
555
540
  * `HTTP.POST /user/ban`
556
541
  */
557
- LemmyHttp.prototype.banPerson = function (form) {
558
- return this.wrapper(HttpType.Post, "/user/ban", form);
559
- };
542
+ banPerson(form) {
543
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/ban", form);
544
+ }
560
545
  /**
561
546
  * Get a list of banned users
562
547
  *
563
548
  * `HTTP.GET /user/banned`
564
549
  */
565
- LemmyHttp.prototype.getBannedPersons = function (form) {
566
- return this.wrapper(HttpType.Get, "/user/banned", form);
567
- };
550
+ getBannedPersons(form) {
551
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/banned", form);
552
+ }
568
553
  /**
569
554
  * Block a person.
570
555
  *
571
556
  * `HTTP.POST /user/block`
572
557
  */
573
- LemmyHttp.prototype.blockPerson = function (form) {
574
- return this.wrapper(HttpType.Post, "/user/block", form);
575
- };
558
+ blockPerson(form) {
559
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/block", form);
560
+ }
576
561
  /**
577
562
  * Fetch a Captcha.
578
563
  *
579
564
  * `HTTP.GET /user/get_captcha`
580
565
  */
581
- LemmyHttp.prototype.getCaptcha = function () {
582
- return this.wrapper(HttpType.Get, "/user/get_captcha", {});
583
- };
566
+ getCaptcha(form) {
567
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/get_captcha", form);
568
+ }
584
569
  /**
585
570
  * Delete your account.
586
571
  *
587
572
  * `HTTP.POST /user/delete_account`
588
573
  */
589
- LemmyHttp.prototype.deleteAccount = function (form) {
590
- return this.wrapper(HttpType.Post, "/user/delete_account", form);
591
- };
574
+ deleteAccount(form) {
575
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/delete_account", form);
576
+ }
592
577
  /**
593
578
  * Reset your password.
594
579
  *
595
580
  * `HTTP.POST /user/password_reset`
596
581
  */
597
- LemmyHttp.prototype.passwordReset = function (form) {
598
- return this.wrapper(HttpType.Post, "/user/password_reset", form);
599
- };
582
+ passwordReset(form) {
583
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/password_reset", form);
584
+ }
600
585
  /**
601
586
  * Change your password from an email / token based reset.
602
587
  *
603
588
  * `HTTP.POST /user/password_change`
604
589
  */
605
- LemmyHttp.prototype.passwordChangeAfterReset = function (form) {
606
- return this.wrapper(HttpType.Post, "/user/password_change", form);
607
- };
590
+ passwordChangeAfterReset(form) {
591
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/password_change", form);
592
+ }
608
593
  /**
609
594
  * Mark all replies as read.
610
595
  *
611
596
  * `HTTP.POST /user/mark_all_as_read`
612
597
  */
613
- LemmyHttp.prototype.markAllAsRead = function (form) {
614
- return this.wrapper(HttpType.Post, "/user/mark_all_as_read", form);
615
- };
598
+ markAllAsRead(form) {
599
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/mark_all_as_read", form);
600
+ }
616
601
  /**
617
602
  * Save your user settings.
618
603
  *
619
604
  * `HTTP.PUT /user/save_user_settings`
620
605
  */
621
- LemmyHttp.prototype.saveUserSettings = function (form) {
622
- return this.wrapper(HttpType.Put, "/user/save_user_settings", form);
623
- };
606
+ saveUserSettings(form) {
607
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/user/save_user_settings", form);
608
+ }
624
609
  /**
625
610
  * Change your user password.
626
611
  *
627
612
  * `HTTP.PUT /user/change_password`
628
613
  */
629
- LemmyHttp.prototype.changePassword = function (form) {
630
- return this.wrapper(HttpType.Put, "/user/change_password", form);
631
- };
614
+ changePassword(form) {
615
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/user/change_password", form);
616
+ }
632
617
  /**
633
618
  * Get counts for your reports
634
619
  *
635
620
  * `HTTP.GET /user/report_count`
636
621
  */
637
- LemmyHttp.prototype.getReportCount = function (form) {
638
- return this.wrapper(HttpType.Get, "/user/report_count", form);
639
- };
622
+ getReportCount(form) {
623
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/report_count", form);
624
+ }
640
625
  /**
641
626
  * Get your unread counts
642
627
  *
643
628
  * `HTTP.GET /user/unread_count`
644
629
  */
645
- LemmyHttp.prototype.getUnreadCount = function (form) {
646
- return this.wrapper(HttpType.Get, "/user/unread_count", form);
647
- };
630
+ getUnreadCount(form) {
631
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/user/unread_count", form);
632
+ }
648
633
  /**
649
634
  * Verify your email
650
635
  *
651
636
  * `HTTP.POST /user/verify_email`
652
637
  */
653
- LemmyHttp.prototype.verifyEmail = function (form) {
654
- return this.wrapper(HttpType.Post, "/user/verify_email", form);
655
- };
638
+ verifyEmail(form) {
639
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/user/verify_email", form);
640
+ }
656
641
  /**
657
642
  * Add an admin to your site.
658
643
  *
659
644
  * `HTTP.POST /admin/add`
660
645
  */
661
- LemmyHttp.prototype.addAdmin = function (form) {
662
- return this.wrapper(HttpType.Post, "/admin/add", form);
663
- };
646
+ addAdmin(form) {
647
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/add", form);
648
+ }
664
649
  /**
665
650
  * Get the unread registration applications count.
666
651
  *
667
652
  * `HTTP.GET /admin/registration_application/count`
668
653
  */
669
- LemmyHttp.prototype.getUnreadRegistrationApplicationCount = function (form) {
670
- return this.wrapper(HttpType.Get, "/admin/registration_application/count", form);
671
- };
654
+ getUnreadRegistrationApplicationCount(form) {
655
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/count", form);
656
+ }
672
657
  /**
673
658
  * List the registration applications.
674
659
  *
675
660
  * `HTTP.GET /admin/registration_application/list`
676
661
  */
677
- LemmyHttp.prototype.listRegistrationApplications = function (form) {
678
- return this.wrapper(HttpType.Get, "/admin/registration_application/list", form);
679
- };
662
+ listRegistrationApplications(form) {
663
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/admin/registration_application/list", form);
664
+ }
680
665
  /**
681
666
  * Approve a registration application
682
667
  *
683
668
  * `HTTP.PUT /admin/registration_application/approve`
684
669
  */
685
- LemmyHttp.prototype.approveRegistrationApplication = function (form) {
686
- return this.wrapper(HttpType.Put, "/admin/registration_application/approve", form);
687
- };
670
+ approveRegistrationApplication(form) {
671
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/admin/registration_application/approve", form);
672
+ }
688
673
  /**
689
674
  * Purge / Delete a person from the database.
690
675
  *
691
676
  * `HTTP.POST /admin/purge/person`
692
677
  */
693
- LemmyHttp.prototype.purgePerson = function (form) {
694
- return this.wrapper(HttpType.Post, "/admin/purge/person", form);
695
- };
678
+ purgePerson(form) {
679
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/person", form);
680
+ }
696
681
  /**
697
682
  * Purge / Delete a community from the database.
698
683
  *
699
684
  * `HTTP.POST /admin/purge/community`
700
685
  */
701
- LemmyHttp.prototype.purgeCommunity = function (form) {
702
- return this.wrapper(HttpType.Post, "/admin/purge/community", form);
703
- };
686
+ purgeCommunity(form) {
687
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/community", form);
688
+ }
704
689
  /**
705
690
  * Purge / Delete a post from the database.
706
691
  *
707
692
  * `HTTP.POST /admin/purge/post`
708
693
  */
709
- LemmyHttp.prototype.purgePost = function (form) {
710
- return this.wrapper(HttpType.Post, "/admin/purge/post", form);
711
- };
694
+ purgePost(form) {
695
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/post", form);
696
+ }
712
697
  /**
713
698
  * Purge / Delete a comment from the database.
714
699
  *
715
700
  * `HTTP.POST /admin/purge/comment`
716
701
  */
717
- LemmyHttp.prototype.purgeComment = function (form) {
718
- return this.wrapper(HttpType.Post, "/admin/purge/comment", form);
719
- };
702
+ purgeComment(form) {
703
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/admin/purge/comment", form);
704
+ }
720
705
  /**
721
706
  * Create a new custom emoji
722
707
  *
723
708
  * `HTTP.POST /custom_emoji`
724
709
  */
725
- LemmyHttp.prototype.createCustomEmoji = function (form) {
726
- return __awaiter(this, void 0, void 0, function () {
727
- return __generator(this, function (_a) {
728
- return [2 /*return*/, this.wrapper(HttpType.Post, "/custom_emoji", form)];
729
- });
710
+ createCustomEmoji(form) {
711
+ return __awaiter(this, void 0, void 0, function* () {
712
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/custom_emoji", form);
730
713
  });
731
- };
714
+ }
732
715
  /**
733
716
  * Edit an existing custom emoji
734
717
  *
735
718
  * `HTTP.PUT /custom_emoji`
736
719
  */
737
- LemmyHttp.prototype.editCustomEmoji = function (form) {
738
- return __awaiter(this, void 0, void 0, function () {
739
- return __generator(this, function (_a) {
740
- return [2 /*return*/, this.wrapper(HttpType.Put, "/custom_emoji", form)];
741
- });
720
+ editCustomEmoji(form) {
721
+ return __awaiter(this, void 0, void 0, function* () {
722
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Put, "/custom_emoji", form);
742
723
  });
743
- };
724
+ }
744
725
  /**
745
726
  * Delete a custom emoji
746
727
  *
747
728
  * `HTTP.Post /custom_emoji/delete`
748
729
  */
749
- LemmyHttp.prototype.deleteCustomEmoji = function (form) {
750
- return __awaiter(this, void 0, void 0, function () {
751
- return __generator(this, function (_a) {
752
- return [2 /*return*/, this.wrapper(HttpType.Post, "/custom_emoji/delete", form)];
753
- });
730
+ deleteCustomEmoji(form) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Post, "/custom_emoji/delete", form);
754
733
  });
755
- };
734
+ }
756
735
  /**
757
- * Upload an image to the server.
736
+ * Fetch federated instances.
737
+ *
738
+ * `HTTP.Get /federated_instances`
758
739
  */
759
- LemmyHttp.prototype.uploadImage = function (_a) {
760
- var _b, _c, _d, _e;
761
- var image = _a.image, auth = _a.auth;
762
- return __awaiter(this, void 0, void 0, function () {
763
- var formData, headers, url, delete_url, response, responseJson, _f, hash, deleteToken;
764
- return __generator(this, function (_g) {
765
- switch (_g.label) {
766
- case 0:
767
- formData = createFormData(image);
768
- headers = {};
769
- 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=")) &&
770
- !((_e = (_d = this.headers) === null || _d === void 0 ? void 0 : _d.Cookie) === null || _e === void 0 ? void 0 : _e.includes("jwt="))) {
771
- headers.Cookie = "jwt=".concat(auth);
772
- }
773
- url = undefined;
774
- delete_url = undefined;
775
- return [4 /*yield*/, (0, cross_fetch_1.default)(this.pictrsUrl, {
776
- method: HttpType.Post,
777
- body: formData,
778
- headers: __assign(__assign({}, this.headers), headers),
779
- })];
780
- case 1:
781
- response = _g.sent();
782
- return [4 /*yield*/, response.json()];
783
- case 2:
784
- responseJson = _g.sent();
785
- if (responseJson.msg === "ok") {
786
- _f = responseJson.files[0], hash = _f.file, deleteToken = _f.delete_token;
787
- delete_url = "".concat(this.pictrsUrl, "/delete/").concat(deleteToken, "/").concat(hash);
788
- url = "".concat(this.pictrsUrl, "/").concat(hash);
789
- }
790
- return [2 /*return*/, __assign(__assign({}, responseJson), { url: url, delete_url: delete_url })];
791
- }
792
- });
740
+ getFederatedInstances(form) {
741
+ return __awaiter(this, void 0, void 0, function* () {
742
+ return __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_wrapper).call(this, HttpType.Get, "/federated_instances", form);
793
743
  });
794
- };
795
- LemmyHttp.prototype.buildFullUrl = function (endpoint) {
796
- return "".concat(this.apiUrl).concat(endpoint);
797
- };
798
- LemmyHttp.prototype.wrapper = function (type_, endpoint, form) {
799
- return __awaiter(this, void 0, void 0, function () {
800
- var getUrl, response, response;
801
- return __generator(this, function (_a) {
802
- switch (_a.label) {
803
- case 0:
804
- if (!(type_ === HttpType.Get)) return [3 /*break*/, 3];
805
- getUrl = "".concat(this.buildFullUrl(endpoint), "?").concat(encodeGetParams(form));
806
- return [4 /*yield*/, (0, cross_fetch_1.default)(getUrl, {
807
- method: HttpType.Get,
808
- headers: this.headers,
809
- })];
810
- case 1:
811
- response = _a.sent();
812
- return [4 /*yield*/, response.json()];
813
- case 2: return [2 /*return*/, _a.sent()];
814
- case 3: return [4 /*yield*/, (0, cross_fetch_1.default)(this.buildFullUrl(endpoint), {
815
- method: type_,
816
- headers: __assign({ "Content-Type": "application/json" }, this.headers),
817
- body: JSON.stringify(form),
818
- })];
819
- case 4:
820
- response = _a.sent();
821
- return [4 /*yield*/, response.json()];
822
- case 5: return [2 /*return*/, _a.sent()];
823
- }
744
+ }
745
+ /**
746
+ * Upload an image to the server.
747
+ */
748
+ uploadImage({ image, auth, }) {
749
+ var _a, _b, _c, _d;
750
+ return __awaiter(this, void 0, void 0, function* () {
751
+ const formData = createFormData(image);
752
+ // If jwt cookie not already set by browser, set it with passed in auth
753
+ const headers = {};
754
+ 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=")) &&
755
+ !((_d = (_c = __classPrivateFieldGet(this, _LemmyHttp_headers, "f")) === null || _c === void 0 ? void 0 : _c.Cookie) === null || _d === void 0 ? void 0 : _d.includes("jwt="))) {
756
+ headers.Cookie = `jwt=${auth}`;
757
+ }
758
+ let url = undefined;
759
+ let delete_url = undefined;
760
+ const response = yield (0, cross_fetch_1.default)(__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), {
761
+ method: HttpType.Post,
762
+ body: formData,
763
+ headers: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")), headers),
824
764
  });
765
+ const responseJson = yield response.json();
766
+ if (responseJson.msg === "ok") {
767
+ const { file: hash, delete_token: deleteToken } = responseJson.files[0];
768
+ delete_url = `${__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f")}/delete/${deleteToken}/${hash}`;
769
+ url = `${__classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f")}/${hash}`;
770
+ }
771
+ return Object.assign(Object.assign({}, responseJson), { url,
772
+ delete_url });
825
773
  });
826
- };
827
- return LemmyHttp;
828
- }());
774
+ }
775
+ }
829
776
  exports.LemmyHttp = LemmyHttp;
777
+ _LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHttp_pictrsUrl = new WeakMap(), _LemmyHttp_instances = new WeakSet(), _LemmyHttp_buildFullUrl = function _LemmyHttp_buildFullUrl(endpoint) {
778
+ return `${__classPrivateFieldGet(this, _LemmyHttp_apiUrl, "f")}${endpoint}`;
779
+ }, _LemmyHttp_wrapper = function _LemmyHttp_wrapper(type_, endpoint, form) {
780
+ var _a;
781
+ return __awaiter(this, void 0, void 0, function* () {
782
+ let response;
783
+ if (type_ === HttpType.Get) {
784
+ const getUrl = `${__classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, endpoint)}?${encodeGetParams(form)}`;
785
+ response = yield (0, cross_fetch_1.default)(getUrl, {
786
+ method: HttpType.Get,
787
+ headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
788
+ });
789
+ }
790
+ else {
791
+ response = yield (0, cross_fetch_1.default)(__classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, endpoint), {
792
+ method: type_,
793
+ headers: Object.assign({ "Content-Type": "application/json" }, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")),
794
+ body: JSON.stringify(form),
795
+ });
796
+ }
797
+ const json = yield response.json();
798
+ if (!response.ok) {
799
+ throw (_a = json["error"]) !== null && _a !== void 0 ? _a : response.statusText;
800
+ }
801
+ else {
802
+ return json;
803
+ }
804
+ });
805
+ };
830
806
  function encodeGetParams(p) {
831
807
  return Object.entries(p)
832
- .filter(function (kv) { return !!kv[1]; })
833
- .map(function (kv) { return kv.map(encodeURIComponent).join("="); })
808
+ .filter(kv => !!kv[1])
809
+ .map(kv => kv.map(encodeURIComponent).join("="))
834
810
  .join("&");
835
811
  }
836
812
  function createFormData(image) {
837
- var formData = new form_data_1.default();
813
+ let formData = new form_data_1.default();
838
814
  if (image.constructor.name === "File") {
839
815
  formData.append("images[]", image);
840
816
  }