lemmy-js-client 0.17.0-rc.14 → 0.17.0-rc.17

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