lemmy-js-client 0.17.0-rc.4 → 0.17.0-rc.42

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./http";
2
2
  export * from "./interfaces";
3
+ export * from "./utils";
3
4
  export * from "./websocket";
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -12,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./http"), exports);
14
18
  __exportStar(require("./interfaces"), exports);
19
+ __exportStar(require("./utils"), exports);
15
20
  __exportStar(require("./websocket"), exports);
@@ -87,4 +87,5 @@ export interface CommentAggregates {
87
87
  score: number;
88
88
  upvotes: number;
89
89
  downvotes: number;
90
+ child_count: number;
90
91
  }
@@ -1,65 +1,66 @@
1
+ import { Option } from "@sniptt/monads";
2
+ import "reflect-metadata";
3
+ import { CommentSortType, ListingType } from "../others";
1
4
  import { CommentReportView, CommentView } from "../views";
2
- export interface CreateComment {
5
+ export declare class CreateComment {
3
6
  content: string;
4
- parent_id?: number;
7
+ parent_id: Option<number>;
5
8
  post_id: number;
6
9
  /**
7
10
  * An optional front end ID, to tell which is comment is coming back.
8
11
  */
9
- form_id?: string;
12
+ form_id: Option<string>;
10
13
  auth: string;
14
+ constructor(init: CreateComment);
11
15
  }
12
- export interface EditComment {
16
+ export declare class EditComment {
13
17
  content: string;
14
18
  comment_id: number;
15
19
  /**
16
20
  * An optional front end ID, to tell which is comment is coming back.
17
21
  */
18
- form_id?: string;
22
+ form_id: Option<string>;
19
23
  auth: string;
24
+ constructor(init: EditComment);
20
25
  }
21
26
  /**
22
27
  * Only the creator can delete the comment.
23
28
  */
24
- export interface DeleteComment {
29
+ export declare class DeleteComment {
25
30
  comment_id: number;
26
31
  deleted: boolean;
27
32
  auth: string;
33
+ constructor(init: DeleteComment);
28
34
  }
29
35
  /**
30
36
  * Only a mod or admin can remove the comment.
31
37
  */
32
- export interface RemoveComment {
38
+ export declare class RemoveComment {
33
39
  comment_id: number;
34
40
  removed: boolean;
35
- reason?: string;
41
+ reason: Option<string>;
36
42
  auth: string;
43
+ constructor(init: RemoveComment);
37
44
  }
38
- /**
39
- * Only the recipient can do this.
40
- */
41
- export interface MarkCommentAsRead {
42
- comment_id: number;
43
- read: boolean;
44
- auth: string;
45
- }
46
- export interface SaveComment {
45
+ export declare class SaveComment {
47
46
  comment_id: number;
48
47
  save: boolean;
49
48
  auth: string;
49
+ constructor(init: SaveComment);
50
50
  }
51
- export interface CommentResponse {
51
+ export declare class CommentResponse {
52
52
  comment_view: CommentView;
53
53
  recipient_ids: number[];
54
54
  /**
55
55
  * An optional front end ID, to tell which is comment is coming back.
56
56
  */
57
- form_id?: string;
57
+ form_id: Option<string>;
58
58
  }
59
- export interface CreateCommentLike {
59
+ export declare class CreateCommentLike {
60
60
  comment_id: number;
61
61
  score: number;
62
62
  auth: string;
63
+ constructor(init: CreateCommentLike);
63
64
  }
64
65
  /**
65
66
  * Comment listing types are `All, Subscribed, Community`
@@ -67,54 +68,55 @@ export interface CreateCommentLike {
67
68
  * You can use either `community_id` or `community_name` as an id.
68
69
  * To get posts for a federated community by name, use `name@instance.tld` .
69
70
  */
70
- export interface GetComments {
71
- /**
72
- * The [[ListingType]].
73
- */
74
- type_?: string;
75
- /**
76
- * The [[SortType]].
77
- */
78
- sort?: string;
79
- page?: number;
80
- limit?: number;
81
- community_id?: number;
82
- community_name?: string;
83
- saved_only?: boolean;
84
- auth?: string;
71
+ export declare class GetComments {
72
+ type_: Option<ListingType>;
73
+ sort: Option<CommentSortType>;
74
+ max_depth: Option<number>;
75
+ page: Option<number>;
76
+ limit: Option<number>;
77
+ community_id: Option<number>;
78
+ community_name: Option<string>;
79
+ post_id: Option<number>;
80
+ parent_id: Option<number>;
81
+ saved_only: Option<boolean>;
82
+ auth: Option<string>;
83
+ constructor(init: GetComments);
85
84
  }
86
- export interface GetCommentsResponse {
85
+ export declare class GetCommentsResponse {
87
86
  comments: CommentView[];
88
87
  }
89
- export interface CreateCommentReport {
88
+ export declare class CreateCommentReport {
90
89
  comment_id: number;
91
90
  reason: string;
92
91
  auth: string;
92
+ constructor(init: CreateCommentReport);
93
93
  }
94
- export interface CommentReportResponse {
94
+ export declare class CommentReportResponse {
95
95
  comment_report_view: CommentReportView;
96
96
  }
97
- export interface ResolveCommentReport {
97
+ export declare class ResolveCommentReport {
98
98
  report_id: number;
99
99
  /**
100
100
  * Either resolve or unresolve a report.
101
101
  */
102
102
  resolved: boolean;
103
103
  auth: string;
104
+ constructor(init: ResolveCommentReport);
104
105
  }
105
- export interface ListCommentReports {
106
- page?: number;
107
- limit?: number;
106
+ export declare class ListCommentReports {
107
+ page: Option<number>;
108
+ limit: Option<number>;
108
109
  /**
109
110
  * if no community is given, it returns reports for all communities moderated by the auth user.
110
111
  */
111
- community_id?: number;
112
+ community_id: Option<number>;
112
113
  /**
113
114
  * Only shows the unresolved reports.
114
115
  */
115
- unresolved_only?: boolean;
116
+ unresolved_only: Option<boolean>;
116
117
  auth: string;
118
+ constructor(init: ListCommentReports);
117
119
  }
118
- export interface ListCommentReportsResponse {
120
+ export declare class ListCommentReportsResponse {
119
121
  comment_reports: CommentReportView[];
120
122
  }
@@ -1,2 +1,351 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ListCommentReportsResponse = exports.ListCommentReports = exports.ResolveCommentReport = exports.CommentReportResponse = exports.CreateCommentReport = exports.GetCommentsResponse = exports.GetComments = exports.CreateCommentLike = exports.CommentResponse = exports.SaveComment = exports.RemoveComment = exports.DeleteComment = exports.EditComment = exports.CreateComment = void 0;
10
+ var class_transformer_1 = require("class-transformer");
11
+ require("reflect-metadata");
12
+ var utils_1 = require("../../utils");
13
+ var views_1 = require("../views");
14
+ var CreateComment = /** @class */ (function () {
15
+ function CreateComment(init) {
16
+ Object.assign(this, init);
17
+ }
18
+ __decorate([
19
+ (0, class_transformer_1.Transform)(function (_a) {
20
+ var value = _a.value;
21
+ return (0, utils_1.toOption)(value);
22
+ }, { toClassOnly: true }),
23
+ (0, class_transformer_1.Transform)(function (_a) {
24
+ var value = _a.value;
25
+ return (0, utils_1.toUndefined)(value);
26
+ }, { toPlainOnly: true }),
27
+ (0, class_transformer_1.Expose)()
28
+ ], CreateComment.prototype, "parent_id", void 0);
29
+ __decorate([
30
+ (0, class_transformer_1.Transform)(function (_a) {
31
+ var value = _a.value;
32
+ return (0, utils_1.toOption)(value);
33
+ }, { toClassOnly: true }),
34
+ (0, class_transformer_1.Transform)(function (_a) {
35
+ var value = _a.value;
36
+ return (0, utils_1.toUndefined)(value);
37
+ }, { toPlainOnly: true }),
38
+ (0, class_transformer_1.Expose)()
39
+ ], CreateComment.prototype, "form_id", void 0);
40
+ return CreateComment;
41
+ }());
42
+ exports.CreateComment = CreateComment;
43
+ var EditComment = /** @class */ (function () {
44
+ function EditComment(init) {
45
+ Object.assign(this, init);
46
+ }
47
+ __decorate([
48
+ (0, class_transformer_1.Transform)(function (_a) {
49
+ var value = _a.value;
50
+ return (0, utils_1.toOption)(value);
51
+ }, { toClassOnly: true }),
52
+ (0, class_transformer_1.Transform)(function (_a) {
53
+ var value = _a.value;
54
+ return (0, utils_1.toUndefined)(value);
55
+ }, { toPlainOnly: true }),
56
+ (0, class_transformer_1.Expose)()
57
+ ], EditComment.prototype, "form_id", void 0);
58
+ return EditComment;
59
+ }());
60
+ exports.EditComment = EditComment;
61
+ /**
62
+ * Only the creator can delete the comment.
63
+ */
64
+ var DeleteComment = /** @class */ (function () {
65
+ function DeleteComment(init) {
66
+ Object.assign(this, init);
67
+ }
68
+ return DeleteComment;
69
+ }());
70
+ exports.DeleteComment = DeleteComment;
71
+ /**
72
+ * Only a mod or admin can remove the comment.
73
+ */
74
+ var RemoveComment = /** @class */ (function () {
75
+ function RemoveComment(init) {
76
+ Object.assign(this, init);
77
+ }
78
+ __decorate([
79
+ (0, class_transformer_1.Transform)(function (_a) {
80
+ var value = _a.value;
81
+ return (0, utils_1.toOption)(value);
82
+ }, { toClassOnly: true }),
83
+ (0, class_transformer_1.Transform)(function (_a) {
84
+ var value = _a.value;
85
+ return (0, utils_1.toUndefined)(value);
86
+ }, { toPlainOnly: true }),
87
+ (0, class_transformer_1.Expose)()
88
+ ], RemoveComment.prototype, "reason", void 0);
89
+ return RemoveComment;
90
+ }());
91
+ exports.RemoveComment = RemoveComment;
92
+ var SaveComment = /** @class */ (function () {
93
+ function SaveComment(init) {
94
+ Object.assign(this, init);
95
+ }
96
+ return SaveComment;
97
+ }());
98
+ exports.SaveComment = SaveComment;
99
+ var CommentResponse = /** @class */ (function () {
100
+ function CommentResponse() {
101
+ }
102
+ __decorate([
103
+ (0, class_transformer_1.Type)(function () { return views_1.CommentView; })
104
+ ], CommentResponse.prototype, "comment_view", void 0);
105
+ __decorate([
106
+ (0, class_transformer_1.Transform)(function (_a) {
107
+ var value = _a.value;
108
+ return (0, utils_1.toOption)(value);
109
+ }, { toClassOnly: true }),
110
+ (0, class_transformer_1.Transform)(function (_a) {
111
+ var value = _a.value;
112
+ return (0, utils_1.toUndefined)(value);
113
+ }, { toPlainOnly: true }),
114
+ (0, class_transformer_1.Expose)()
115
+ ], CommentResponse.prototype, "form_id", void 0);
116
+ return CommentResponse;
117
+ }());
118
+ exports.CommentResponse = CommentResponse;
119
+ var CreateCommentLike = /** @class */ (function () {
120
+ function CreateCommentLike(init) {
121
+ Object.assign(this, init);
122
+ }
123
+ return CreateCommentLike;
124
+ }());
125
+ exports.CreateCommentLike = CreateCommentLike;
126
+ /**
127
+ * Comment listing types are `All, Subscribed, Community`
128
+ *
129
+ * You can use either `community_id` or `community_name` as an id.
130
+ * To get posts for a federated community by name, use `name@instance.tld` .
131
+ */
132
+ var GetComments = /** @class */ (function () {
133
+ function GetComments(init) {
134
+ Object.assign(this, init);
135
+ }
136
+ __decorate([
137
+ (0, class_transformer_1.Transform)(function (_a) {
138
+ var value = _a.value;
139
+ return (0, utils_1.toOption)(value);
140
+ }, { toClassOnly: true }),
141
+ (0, class_transformer_1.Transform)(function (_a) {
142
+ var value = _a.value;
143
+ return (0, utils_1.toUndefined)(value);
144
+ }, { toPlainOnly: true }),
145
+ (0, class_transformer_1.Expose)()
146
+ ], GetComments.prototype, "type_", void 0);
147
+ __decorate([
148
+ (0, class_transformer_1.Transform)(function (_a) {
149
+ var value = _a.value;
150
+ return (0, utils_1.toOption)(value);
151
+ }, { toClassOnly: true }),
152
+ (0, class_transformer_1.Transform)(function (_a) {
153
+ var value = _a.value;
154
+ return (0, utils_1.toUndefined)(value);
155
+ }, { toPlainOnly: true }),
156
+ (0, class_transformer_1.Expose)()
157
+ ], GetComments.prototype, "sort", void 0);
158
+ __decorate([
159
+ (0, class_transformer_1.Transform)(function (_a) {
160
+ var value = _a.value;
161
+ return (0, utils_1.toOption)(value);
162
+ }, { toClassOnly: true }),
163
+ (0, class_transformer_1.Transform)(function (_a) {
164
+ var value = _a.value;
165
+ return (0, utils_1.toUndefined)(value);
166
+ }, { toPlainOnly: true }),
167
+ (0, class_transformer_1.Expose)()
168
+ ], GetComments.prototype, "max_depth", void 0);
169
+ __decorate([
170
+ (0, class_transformer_1.Transform)(function (_a) {
171
+ var value = _a.value;
172
+ return (0, utils_1.toOption)(value);
173
+ }, { toClassOnly: true }),
174
+ (0, class_transformer_1.Transform)(function (_a) {
175
+ var value = _a.value;
176
+ return (0, utils_1.toUndefined)(value);
177
+ }, { toPlainOnly: true }),
178
+ (0, class_transformer_1.Expose)()
179
+ ], GetComments.prototype, "page", void 0);
180
+ __decorate([
181
+ (0, class_transformer_1.Transform)(function (_a) {
182
+ var value = _a.value;
183
+ return (0, utils_1.toOption)(value);
184
+ }, { toClassOnly: true }),
185
+ (0, class_transformer_1.Transform)(function (_a) {
186
+ var value = _a.value;
187
+ return (0, utils_1.toUndefined)(value);
188
+ }, { toPlainOnly: true }),
189
+ (0, class_transformer_1.Expose)()
190
+ ], GetComments.prototype, "limit", void 0);
191
+ __decorate([
192
+ (0, class_transformer_1.Transform)(function (_a) {
193
+ var value = _a.value;
194
+ return (0, utils_1.toOption)(value);
195
+ }, { toClassOnly: true }),
196
+ (0, class_transformer_1.Transform)(function (_a) {
197
+ var value = _a.value;
198
+ return (0, utils_1.toUndefined)(value);
199
+ }, { toPlainOnly: true }),
200
+ (0, class_transformer_1.Expose)()
201
+ ], GetComments.prototype, "community_id", void 0);
202
+ __decorate([
203
+ (0, class_transformer_1.Transform)(function (_a) {
204
+ var value = _a.value;
205
+ return (0, utils_1.toOption)(value);
206
+ }, { toClassOnly: true }),
207
+ (0, class_transformer_1.Transform)(function (_a) {
208
+ var value = _a.value;
209
+ return (0, utils_1.toUndefined)(value);
210
+ }, { toPlainOnly: true }),
211
+ (0, class_transformer_1.Expose)()
212
+ ], GetComments.prototype, "community_name", void 0);
213
+ __decorate([
214
+ (0, class_transformer_1.Transform)(function (_a) {
215
+ var value = _a.value;
216
+ return (0, utils_1.toOption)(value);
217
+ }, { toClassOnly: true }),
218
+ (0, class_transformer_1.Transform)(function (_a) {
219
+ var value = _a.value;
220
+ return (0, utils_1.toUndefined)(value);
221
+ }, { toPlainOnly: true }),
222
+ (0, class_transformer_1.Expose)()
223
+ ], GetComments.prototype, "post_id", void 0);
224
+ __decorate([
225
+ (0, class_transformer_1.Transform)(function (_a) {
226
+ var value = _a.value;
227
+ return (0, utils_1.toOption)(value);
228
+ }, { toClassOnly: true }),
229
+ (0, class_transformer_1.Transform)(function (_a) {
230
+ var value = _a.value;
231
+ return (0, utils_1.toUndefined)(value);
232
+ }, { toPlainOnly: true }),
233
+ (0, class_transformer_1.Expose)()
234
+ ], GetComments.prototype, "parent_id", void 0);
235
+ __decorate([
236
+ (0, class_transformer_1.Transform)(function (_a) {
237
+ var value = _a.value;
238
+ return (0, utils_1.toOption)(value);
239
+ }, { toClassOnly: true }),
240
+ (0, class_transformer_1.Transform)(function (_a) {
241
+ var value = _a.value;
242
+ return (0, utils_1.toUndefined)(value);
243
+ }, { toPlainOnly: true }),
244
+ (0, class_transformer_1.Expose)()
245
+ ], GetComments.prototype, "saved_only", void 0);
246
+ __decorate([
247
+ (0, class_transformer_1.Transform)(function (_a) {
248
+ var value = _a.value;
249
+ return (0, utils_1.toOption)(value);
250
+ }, { toClassOnly: true }),
251
+ (0, class_transformer_1.Transform)(function (_a) {
252
+ var value = _a.value;
253
+ return (0, utils_1.toUndefined)(value);
254
+ }, { toPlainOnly: true }),
255
+ (0, class_transformer_1.Expose)()
256
+ ], GetComments.prototype, "auth", void 0);
257
+ return GetComments;
258
+ }());
259
+ exports.GetComments = GetComments;
260
+ var GetCommentsResponse = /** @class */ (function () {
261
+ function GetCommentsResponse() {
262
+ }
263
+ __decorate([
264
+ (0, class_transformer_1.Type)(function () { return views_1.CommentView; })
265
+ ], GetCommentsResponse.prototype, "comments", void 0);
266
+ return GetCommentsResponse;
267
+ }());
268
+ exports.GetCommentsResponse = GetCommentsResponse;
269
+ var CreateCommentReport = /** @class */ (function () {
270
+ function CreateCommentReport(init) {
271
+ Object.assign(this, init);
272
+ }
273
+ return CreateCommentReport;
274
+ }());
275
+ exports.CreateCommentReport = CreateCommentReport;
276
+ var CommentReportResponse = /** @class */ (function () {
277
+ function CommentReportResponse() {
278
+ }
279
+ __decorate([
280
+ (0, class_transformer_1.Type)(function () { return views_1.CommentReportView; })
281
+ ], CommentReportResponse.prototype, "comment_report_view", void 0);
282
+ return CommentReportResponse;
283
+ }());
284
+ exports.CommentReportResponse = CommentReportResponse;
285
+ var ResolveCommentReport = /** @class */ (function () {
286
+ function ResolveCommentReport(init) {
287
+ Object.assign(this, init);
288
+ }
289
+ return ResolveCommentReport;
290
+ }());
291
+ exports.ResolveCommentReport = ResolveCommentReport;
292
+ var ListCommentReports = /** @class */ (function () {
293
+ function ListCommentReports(init) {
294
+ Object.assign(this, init);
295
+ }
296
+ __decorate([
297
+ (0, class_transformer_1.Transform)(function (_a) {
298
+ var value = _a.value;
299
+ return (0, utils_1.toOption)(value);
300
+ }, { toClassOnly: true }),
301
+ (0, class_transformer_1.Transform)(function (_a) {
302
+ var value = _a.value;
303
+ return (0, utils_1.toUndefined)(value);
304
+ }, { toPlainOnly: true }),
305
+ (0, class_transformer_1.Expose)()
306
+ ], ListCommentReports.prototype, "page", void 0);
307
+ __decorate([
308
+ (0, class_transformer_1.Transform)(function (_a) {
309
+ var value = _a.value;
310
+ return (0, utils_1.toOption)(value);
311
+ }, { toClassOnly: true }),
312
+ (0, class_transformer_1.Transform)(function (_a) {
313
+ var value = _a.value;
314
+ return (0, utils_1.toUndefined)(value);
315
+ }, { toPlainOnly: true }),
316
+ (0, class_transformer_1.Expose)()
317
+ ], ListCommentReports.prototype, "limit", void 0);
318
+ __decorate([
319
+ (0, class_transformer_1.Transform)(function (_a) {
320
+ var value = _a.value;
321
+ return (0, utils_1.toOption)(value);
322
+ }, { toClassOnly: true }),
323
+ (0, class_transformer_1.Transform)(function (_a) {
324
+ var value = _a.value;
325
+ return (0, utils_1.toUndefined)(value);
326
+ }, { toPlainOnly: true }),
327
+ (0, class_transformer_1.Expose)()
328
+ ], ListCommentReports.prototype, "community_id", void 0);
329
+ __decorate([
330
+ (0, class_transformer_1.Transform)(function (_a) {
331
+ var value = _a.value;
332
+ return (0, utils_1.toOption)(value);
333
+ }, { toClassOnly: true }),
334
+ (0, class_transformer_1.Transform)(function (_a) {
335
+ var value = _a.value;
336
+ return (0, utils_1.toUndefined)(value);
337
+ }, { toPlainOnly: true }),
338
+ (0, class_transformer_1.Expose)()
339
+ ], ListCommentReports.prototype, "unresolved_only", void 0);
340
+ return ListCommentReports;
341
+ }());
342
+ exports.ListCommentReports = ListCommentReports;
343
+ var ListCommentReportsResponse = /** @class */ (function () {
344
+ function ListCommentReportsResponse() {
345
+ }
346
+ __decorate([
347
+ (0, class_transformer_1.Type)(function () { return views_1.CommentReportView; })
348
+ ], ListCommentReportsResponse.prototype, "comment_reports", void 0);
349
+ return ListCommentReportsResponse;
350
+ }());
351
+ exports.ListCommentReportsResponse = ListCommentReportsResponse;