lemmy-js-client 0.17.0-rc.2 → 0.17.0-rc.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,11 @@
1
+ import { Option } from "@sniptt/monads";
1
2
  import { CommentAggregates, CommunityAggregates, PersonAggregates, PostAggregates, SiteAggregates } from "./aggregates";
2
3
  import { Comment, CommentReport, CommunitySafe, LocalUserSettings, ModAdd, ModAddCommunity, ModBan, ModBanFromCommunity, ModLockPost, ModRemoveComment, ModRemoveCommunity, ModRemovePost, ModStickyPost, ModTransferCommunity, PersonMention, PersonSafe, Post, PostReport, PrivateMessage, RegistrationApplication, Site } from "./source";
3
- export interface PersonViewSafe {
4
+ export declare class PersonViewSafe {
4
5
  person: PersonSafe;
5
6
  counts: PersonAggregates;
6
7
  }
7
- export interface PersonMentionView {
8
+ export declare class PersonMentionView {
8
9
  person_mention: PersonMention;
9
10
  comment: Comment;
10
11
  creator: PersonSafe;
@@ -16,24 +17,23 @@ export interface PersonMentionView {
16
17
  subscribed: boolean;
17
18
  saved: boolean;
18
19
  creator_blocked: boolean;
19
- my_vote?: number;
20
+ my_vote: Option<number>;
20
21
  }
21
- export interface LocalUserSettingsView {
22
+ export declare class LocalUserSettingsView {
22
23
  local_user: LocalUserSettings;
23
24
  person: PersonSafe;
24
25
  counts: PersonAggregates;
25
26
  }
26
- export interface SiteView {
27
+ export declare class SiteView {
27
28
  site: Site;
28
- creator: PersonSafe;
29
29
  counts: SiteAggregates;
30
30
  }
31
- export interface PrivateMessageView {
31
+ export declare class PrivateMessageView {
32
32
  private_message: PrivateMessage;
33
33
  creator: PersonSafe;
34
34
  recipient: PersonSafe;
35
35
  }
36
- export interface PostView {
36
+ export declare class PostView {
37
37
  post: Post;
38
38
  creator: PersonSafe;
39
39
  community: CommunitySafe;
@@ -43,23 +43,23 @@ export interface PostView {
43
43
  saved: boolean;
44
44
  read: boolean;
45
45
  creator_blocked: boolean;
46
- my_vote?: number;
46
+ my_vote: Option<number>;
47
47
  }
48
- export interface PostReportView {
48
+ export declare class PostReportView {
49
49
  post_report: PostReport;
50
50
  post: Post;
51
51
  community: CommunitySafe;
52
52
  creator: PersonSafe;
53
53
  post_creator: PersonSafe;
54
54
  creator_banned_from_community: boolean;
55
- my_vote?: number;
55
+ my_vote: Option<number>;
56
56
  counts: PostAggregates;
57
- resolver?: PersonSafe;
57
+ resolver: Option<PersonSafe>;
58
58
  }
59
- export interface CommentView {
59
+ export declare class CommentView {
60
60
  comment: Comment;
61
61
  creator: PersonSafe;
62
- recipient?: PersonSafe;
62
+ recipient: Option<PersonSafe>;
63
63
  post: Post;
64
64
  community: CommunitySafe;
65
65
  counts: CommentAggregates;
@@ -67,9 +67,9 @@ export interface CommentView {
67
67
  subscribed: boolean;
68
68
  saved: boolean;
69
69
  creator_blocked: boolean;
70
- my_vote?: number;
70
+ my_vote: Option<number>;
71
71
  }
72
- export interface CommentReportView {
72
+ export declare class CommentReportView {
73
73
  comment_report: CommentReport;
74
74
  comment: Comment;
75
75
  post: Post;
@@ -78,44 +78,44 @@ export interface CommentReportView {
78
78
  comment_creator: PersonSafe;
79
79
  counts: CommentAggregates;
80
80
  creator_banned_from_community: boolean;
81
- my_vote?: number;
82
- resolver?: PersonSafe;
81
+ my_vote: Option<number>;
82
+ resolver: Option<PersonSafe>;
83
83
  }
84
- export interface ModAddCommunityView {
84
+ export declare class ModAddCommunityView {
85
85
  mod_add_community: ModAddCommunity;
86
86
  moderator: PersonSafe;
87
87
  community: CommunitySafe;
88
88
  modded_person: PersonSafe;
89
89
  }
90
- export interface ModTransferCommunityView {
90
+ export declare class ModTransferCommunityView {
91
91
  mod_transfer_community: ModTransferCommunity;
92
92
  moderator: PersonSafe;
93
93
  community: CommunitySafe;
94
94
  modded_person: PersonSafe;
95
95
  }
96
- export interface ModAddView {
96
+ export declare class ModAddView {
97
97
  mod_add: ModAdd;
98
98
  moderator: PersonSafe;
99
99
  modded_person: PersonSafe;
100
100
  }
101
- export interface ModBanFromCommunityView {
101
+ export declare class ModBanFromCommunityView {
102
102
  mod_ban_from_community: ModBanFromCommunity;
103
103
  moderator: PersonSafe;
104
104
  community: CommunitySafe;
105
105
  banned_person: PersonSafe;
106
106
  }
107
- export interface ModBanView {
107
+ export declare class ModBanView {
108
108
  mod_ban: ModBan;
109
109
  moderator: PersonSafe;
110
110
  banned_person: PersonSafe;
111
111
  }
112
- export interface ModLockPostView {
112
+ export declare class ModLockPostView {
113
113
  mod_lock_post: ModLockPost;
114
114
  moderator: PersonSafe;
115
115
  post: Post;
116
116
  community: CommunitySafe;
117
117
  }
118
- export interface ModRemoveCommentView {
118
+ export declare class ModRemoveCommentView {
119
119
  mod_remove_comment: ModRemoveComment;
120
120
  moderator: PersonSafe;
121
121
  comment: Comment;
@@ -123,53 +123,52 @@ export interface ModRemoveCommentView {
123
123
  post: Post;
124
124
  community: CommunitySafe;
125
125
  }
126
- export interface ModRemoveCommunityView {
126
+ export declare class ModRemoveCommunityView {
127
127
  mod_remove_community: ModRemoveCommunity;
128
128
  moderator: PersonSafe;
129
129
  community: CommunitySafe;
130
130
  }
131
- export interface ModRemovePostView {
131
+ export declare class ModRemovePostView {
132
132
  mod_remove_post: ModRemovePost;
133
133
  moderator: PersonSafe;
134
134
  post: Post;
135
135
  community: CommunitySafe;
136
136
  }
137
- export interface ModStickyPostView {
137
+ export declare class ModStickyPostView {
138
138
  mod_sticky_post: ModStickyPost;
139
139
  moderator: PersonSafe;
140
140
  post: Post;
141
141
  community: CommunitySafe;
142
142
  }
143
- export interface CommunityFollowerView {
143
+ export declare class CommunityFollowerView {
144
144
  community: CommunitySafe;
145
145
  follower: PersonSafe;
146
- pending?: boolean;
147
146
  }
148
- export interface CommunityBlockView {
147
+ export declare class CommunityBlockView {
149
148
  person: PersonSafe;
150
149
  community: CommunitySafe;
151
150
  }
152
- export interface CommunityModeratorView {
151
+ export declare class CommunityModeratorView {
153
152
  community: CommunitySafe;
154
153
  moderator: PersonSafe;
155
154
  }
156
- export interface CommunityPersonBanView {
155
+ export declare class CommunityPersonBanView {
157
156
  community: CommunitySafe;
158
157
  person: PersonSafe;
159
158
  }
160
- export interface PersonBlockView {
159
+ export declare class PersonBlockView {
161
160
  person: PersonSafe;
162
161
  target: PersonSafe;
163
162
  }
164
- export interface CommunityView {
163
+ export declare class CommunityView {
165
164
  community: CommunitySafe;
166
165
  subscribed: boolean;
167
166
  blocked: boolean;
168
167
  counts: CommunityAggregates;
169
168
  }
170
- export interface RegistrationApplicationView {
169
+ export declare class RegistrationApplicationView {
171
170
  registration_application: RegistrationApplication;
172
171
  creator_local_user: LocalUserSettings;
173
172
  creator: PersonSafe;
174
- admin?: PersonSafe;
173
+ admin: Option<PersonSafe>;
175
174
  }
@@ -1,2 +1,272 @@
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.RegistrationApplicationView = exports.CommunityView = exports.PersonBlockView = exports.CommunityPersonBanView = exports.CommunityModeratorView = exports.CommunityBlockView = exports.CommunityFollowerView = exports.ModStickyPostView = exports.ModRemovePostView = exports.ModRemoveCommunityView = exports.ModRemoveCommentView = exports.ModLockPostView = exports.ModBanView = exports.ModBanFromCommunityView = exports.ModAddView = exports.ModTransferCommunityView = exports.ModAddCommunityView = exports.CommentReportView = exports.CommentView = exports.PostReportView = exports.PostView = exports.PrivateMessageView = exports.SiteView = exports.LocalUserSettingsView = exports.PersonMentionView = exports.PersonViewSafe = 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 source_1 = require("./source");
14
+ var PersonViewSafe = /** @class */ (function () {
15
+ function PersonViewSafe() {
16
+ }
17
+ return PersonViewSafe;
18
+ }());
19
+ exports.PersonViewSafe = PersonViewSafe;
20
+ var PersonMentionView = /** @class */ (function () {
21
+ function PersonMentionView() {
22
+ }
23
+ __decorate([
24
+ (0, class_transformer_1.Transform)(function (_a) {
25
+ var value = _a.value;
26
+ return (0, monads_1.Some)(value);
27
+ }, { toClassOnly: true }),
28
+ (0, class_transformer_1.Transform)(function (_a) {
29
+ var value = _a.value;
30
+ return (0, utils_1.toUndefined)(value);
31
+ }, { toPlainOnly: true }),
32
+ (0, class_transformer_1.Expose)()
33
+ ], PersonMentionView.prototype, "my_vote", void 0);
34
+ return PersonMentionView;
35
+ }());
36
+ exports.PersonMentionView = PersonMentionView;
37
+ var LocalUserSettingsView = /** @class */ (function () {
38
+ function LocalUserSettingsView() {
39
+ }
40
+ return LocalUserSettingsView;
41
+ }());
42
+ exports.LocalUserSettingsView = LocalUserSettingsView;
43
+ var SiteView = /** @class */ (function () {
44
+ function SiteView() {
45
+ }
46
+ return SiteView;
47
+ }());
48
+ exports.SiteView = SiteView;
49
+ var PrivateMessageView = /** @class */ (function () {
50
+ function PrivateMessageView() {
51
+ }
52
+ return PrivateMessageView;
53
+ }());
54
+ exports.PrivateMessageView = PrivateMessageView;
55
+ var PostView = /** @class */ (function () {
56
+ function PostView() {
57
+ }
58
+ __decorate([
59
+ (0, class_transformer_1.Transform)(function (_a) {
60
+ var value = _a.value;
61
+ return (0, monads_1.Some)(value);
62
+ }, { toClassOnly: true }),
63
+ (0, class_transformer_1.Transform)(function (_a) {
64
+ var value = _a.value;
65
+ return (0, utils_1.toUndefined)(value);
66
+ }, { toPlainOnly: true }),
67
+ (0, class_transformer_1.Expose)()
68
+ ], PostView.prototype, "my_vote", void 0);
69
+ return PostView;
70
+ }());
71
+ exports.PostView = PostView;
72
+ var PostReportView = /** @class */ (function () {
73
+ function PostReportView() {
74
+ }
75
+ __decorate([
76
+ (0, class_transformer_1.Transform)(function (_a) {
77
+ var value = _a.value;
78
+ return (0, monads_1.Some)(value);
79
+ }, { toClassOnly: true }),
80
+ (0, class_transformer_1.Transform)(function (_a) {
81
+ var value = _a.value;
82
+ return (0, utils_1.toUndefined)(value);
83
+ }, { toPlainOnly: true }),
84
+ (0, class_transformer_1.Expose)()
85
+ ], PostReportView.prototype, "my_vote", void 0);
86
+ __decorate([
87
+ (0, class_transformer_1.Transform)(function (_a) {
88
+ var value = _a.value;
89
+ return (0, monads_1.Some)(value);
90
+ }, { toClassOnly: true }),
91
+ (0, class_transformer_1.Transform)(function (_a) {
92
+ var value = _a.value;
93
+ return (0, utils_1.toUndefined)(value);
94
+ }, { toPlainOnly: true }),
95
+ (0, class_transformer_1.Expose)(),
96
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
97
+ ], PostReportView.prototype, "resolver", void 0);
98
+ return PostReportView;
99
+ }());
100
+ exports.PostReportView = PostReportView;
101
+ var CommentView = /** @class */ (function () {
102
+ function CommentView() {
103
+ }
104
+ __decorate([
105
+ (0, class_transformer_1.Transform)(function (_a) {
106
+ var value = _a.value;
107
+ return (0, monads_1.Some)(value);
108
+ }, { toClassOnly: true }),
109
+ (0, class_transformer_1.Transform)(function (_a) {
110
+ var value = _a.value;
111
+ return (0, utils_1.toUndefined)(value);
112
+ }, { toPlainOnly: true }),
113
+ (0, class_transformer_1.Expose)(),
114
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
115
+ ], CommentView.prototype, "recipient", void 0);
116
+ __decorate([
117
+ (0, class_transformer_1.Transform)(function (_a) {
118
+ var value = _a.value;
119
+ return (0, monads_1.Some)(value);
120
+ }, { toClassOnly: true }),
121
+ (0, class_transformer_1.Transform)(function (_a) {
122
+ var value = _a.value;
123
+ return (0, utils_1.toUndefined)(value);
124
+ }, { toPlainOnly: true }),
125
+ (0, class_transformer_1.Expose)()
126
+ ], CommentView.prototype, "my_vote", void 0);
127
+ return CommentView;
128
+ }());
129
+ exports.CommentView = CommentView;
130
+ var CommentReportView = /** @class */ (function () {
131
+ function CommentReportView() {
132
+ }
133
+ __decorate([
134
+ (0, class_transformer_1.Transform)(function (_a) {
135
+ var value = _a.value;
136
+ return (0, monads_1.Some)(value);
137
+ }, { toClassOnly: true }),
138
+ (0, class_transformer_1.Transform)(function (_a) {
139
+ var value = _a.value;
140
+ return (0, utils_1.toUndefined)(value);
141
+ }, { toPlainOnly: true }),
142
+ (0, class_transformer_1.Expose)()
143
+ ], CommentReportView.prototype, "my_vote", void 0);
144
+ __decorate([
145
+ (0, class_transformer_1.Transform)(function (_a) {
146
+ var value = _a.value;
147
+ return (0, monads_1.Some)(value);
148
+ }, { toClassOnly: true }),
149
+ (0, class_transformer_1.Transform)(function (_a) {
150
+ var value = _a.value;
151
+ return (0, utils_1.toUndefined)(value);
152
+ }, { toPlainOnly: true }),
153
+ (0, class_transformer_1.Expose)(),
154
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
155
+ ], CommentReportView.prototype, "resolver", void 0);
156
+ return CommentReportView;
157
+ }());
158
+ exports.CommentReportView = CommentReportView;
159
+ var ModAddCommunityView = /** @class */ (function () {
160
+ function ModAddCommunityView() {
161
+ }
162
+ return ModAddCommunityView;
163
+ }());
164
+ exports.ModAddCommunityView = ModAddCommunityView;
165
+ var ModTransferCommunityView = /** @class */ (function () {
166
+ function ModTransferCommunityView() {
167
+ }
168
+ return ModTransferCommunityView;
169
+ }());
170
+ exports.ModTransferCommunityView = ModTransferCommunityView;
171
+ var ModAddView = /** @class */ (function () {
172
+ function ModAddView() {
173
+ }
174
+ return ModAddView;
175
+ }());
176
+ exports.ModAddView = ModAddView;
177
+ var ModBanFromCommunityView = /** @class */ (function () {
178
+ function ModBanFromCommunityView() {
179
+ }
180
+ return ModBanFromCommunityView;
181
+ }());
182
+ exports.ModBanFromCommunityView = ModBanFromCommunityView;
183
+ var ModBanView = /** @class */ (function () {
184
+ function ModBanView() {
185
+ }
186
+ return ModBanView;
187
+ }());
188
+ exports.ModBanView = ModBanView;
189
+ var ModLockPostView = /** @class */ (function () {
190
+ function ModLockPostView() {
191
+ }
192
+ return ModLockPostView;
193
+ }());
194
+ exports.ModLockPostView = ModLockPostView;
195
+ var ModRemoveCommentView = /** @class */ (function () {
196
+ function ModRemoveCommentView() {
197
+ }
198
+ return ModRemoveCommentView;
199
+ }());
200
+ exports.ModRemoveCommentView = ModRemoveCommentView;
201
+ var ModRemoveCommunityView = /** @class */ (function () {
202
+ function ModRemoveCommunityView() {
203
+ }
204
+ return ModRemoveCommunityView;
205
+ }());
206
+ exports.ModRemoveCommunityView = ModRemoveCommunityView;
207
+ var ModRemovePostView = /** @class */ (function () {
208
+ function ModRemovePostView() {
209
+ }
210
+ return ModRemovePostView;
211
+ }());
212
+ exports.ModRemovePostView = ModRemovePostView;
213
+ var ModStickyPostView = /** @class */ (function () {
214
+ function ModStickyPostView() {
215
+ }
216
+ return ModStickyPostView;
217
+ }());
218
+ exports.ModStickyPostView = ModStickyPostView;
219
+ var CommunityFollowerView = /** @class */ (function () {
220
+ function CommunityFollowerView() {
221
+ }
222
+ return CommunityFollowerView;
223
+ }());
224
+ exports.CommunityFollowerView = CommunityFollowerView;
225
+ var CommunityBlockView = /** @class */ (function () {
226
+ function CommunityBlockView() {
227
+ }
228
+ return CommunityBlockView;
229
+ }());
230
+ exports.CommunityBlockView = CommunityBlockView;
231
+ var CommunityModeratorView = /** @class */ (function () {
232
+ function CommunityModeratorView() {
233
+ }
234
+ return CommunityModeratorView;
235
+ }());
236
+ exports.CommunityModeratorView = CommunityModeratorView;
237
+ var CommunityPersonBanView = /** @class */ (function () {
238
+ function CommunityPersonBanView() {
239
+ }
240
+ return CommunityPersonBanView;
241
+ }());
242
+ exports.CommunityPersonBanView = CommunityPersonBanView;
243
+ var PersonBlockView = /** @class */ (function () {
244
+ function PersonBlockView() {
245
+ }
246
+ return PersonBlockView;
247
+ }());
248
+ exports.PersonBlockView = PersonBlockView;
249
+ var CommunityView = /** @class */ (function () {
250
+ function CommunityView() {
251
+ }
252
+ return CommunityView;
253
+ }());
254
+ exports.CommunityView = CommunityView;
255
+ var RegistrationApplicationView = /** @class */ (function () {
256
+ function RegistrationApplicationView() {
257
+ }
258
+ __decorate([
259
+ (0, class_transformer_1.Transform)(function (_a) {
260
+ var value = _a.value;
261
+ return (0, monads_1.Some)(value);
262
+ }, { toClassOnly: true }),
263
+ (0, class_transformer_1.Transform)(function (_a) {
264
+ var value = _a.value;
265
+ return (0, utils_1.toUndefined)(value);
266
+ }, { toPlainOnly: true }),
267
+ (0, class_transformer_1.Expose)(),
268
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
269
+ ], RegistrationApplicationView.prototype, "admin", void 0);
270
+ return RegistrationApplicationView;
271
+ }());
272
+ exports.RegistrationApplicationView = RegistrationApplicationView;
@@ -0,0 +1,5 @@
1
+ import { Option } from "@sniptt/monads";
2
+ /**
3
+ * Converts an option to an undefined. Necessary for API requests.
4
+ */
5
+ export declare function toUndefined<T>(opt: Option<T>): T;
package/dist/utils.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toUndefined = void 0;
4
+ /**
5
+ * Converts an option to an undefined. Necessary for API requests.
6
+ */
7
+ function toUndefined(opt) {
8
+ return opt.isSome() ? opt.unwrap() : undefined;
9
+ }
10
+ exports.toUndefined = toUndefined;
@@ -1,9 +1,11 @@
1
+ import { ClassConstructor } from "class-transformer";
1
2
  import { CreateComment, CreateCommentLike, CreateCommentReport, DeleteComment, EditComment, GetComments, ListCommentReports, MarkCommentAsRead, RemoveComment, ResolveCommentReport, SaveComment } from "./interfaces/api/comment";
2
3
  import { AddModToCommunity, BanFromCommunity, BlockCommunity, CreateCommunity, DeleteCommunity, EditCommunity, FollowCommunity, GetCommunity, ListCommunities, RemoveCommunity, TransferCommunity } from "./interfaces/api/community";
3
4
  import { AddAdmin, BanPerson, BlockPerson, ChangePassword, CreatePrivateMessage, DeleteAccount, DeletePrivateMessage, EditPrivateMessage, GetBannedPersons, GetPersonDetails, GetPersonMentions, GetPrivateMessages, GetReplies, GetReportCount, GetUnreadCount, Login, MarkAllAsRead, MarkPersonMentionAsRead, MarkPrivateMessageAsRead, PasswordChange, PasswordReset, Register, SaveUserSettings, VerifyEmail } from "./interfaces/api/person";
4
- import { CreatePost, CreatePostLike, CreatePostReport, DeletePost, EditPost, GetPost, GetPosts, GetSiteMetadata, ListPostReports, LockPost, RemovePost, ResolvePostReport, SavePost, StickyPost } from "./interfaces/api/post";
5
+ import { CreatePost, CreatePostLike, CreatePostReport, DeletePost, EditPost, GetPost, GetPosts, GetSiteMetadata, ListPostReports, LockPost, MarkPostAsRead, RemovePost, ResolvePostReport, SavePost, StickyPost } from "./interfaces/api/post";
5
6
  import { ApproveRegistrationApplication, CreateSite, EditSite, GetModlog, GetSite, GetSiteConfig, GetUnreadRegistrationApplicationCount, LeaveAdmin, ListRegistrationApplications, ResolveObject, SaveSiteConfig, Search } from "./interfaces/api/site";
6
7
  import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
8
+ import { UserOperation } from "./interfaces/others";
7
9
  /**
8
10
  * Helps build lemmy websocket message requests, that you can use in your Websocket sends.
9
11
  *
@@ -153,6 +155,10 @@ export declare class LemmyWebsocket {
153
155
  * A moderator can sticky a post ( IE stick it to the top of a community ).
154
156
  */
155
157
  stickyPost(form: StickyPost): string;
158
+ /**
159
+ * Mark a post as read.
160
+ */
161
+ markPostAsRead(form: MarkPostAsRead): string;
156
162
  /**
157
163
  * Save a post.
158
164
  */
@@ -244,7 +250,7 @@ export declare class LemmyWebsocket {
244
250
  /**
245
251
  * Gets the site, and your user data.
246
252
  */
247
- getSite(form?: GetSite): string;
253
+ getSite(form: GetSite): string;
248
254
  /**
249
255
  * Get your site configuration.
250
256
  */
@@ -326,3 +332,11 @@ export declare class LemmyWebsocket {
326
332
  */
327
333
  blockCommunity(form: BlockCommunity): string;
328
334
  }
335
+ /**
336
+ * A websocket JSON response that includes the errors.
337
+ */
338
+ export declare function wsUserOp(msg: any): UserOperation;
339
+ /**
340
+ * Converts a websocket string response to a usable result
341
+ */
342
+ export declare function wsJsonToRes<ResponseType>(msg: any, responseClass: ClassConstructor<ResponseType>): ResponseType;
package/dist/websocket.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LemmyWebsocket = void 0;
3
+ exports.wsJsonToRes = exports.wsUserOp = exports.LemmyWebsocket = void 0;
4
+ var class_transformer_1 = require("class-transformer");
4
5
  var others_1 = require("./interfaces/others");
5
6
  /**
6
7
  * Helps build lemmy websocket message requests, that you can use in your Websocket sends.
@@ -218,6 +219,12 @@ var LemmyWebsocket = /** @class */ (function () {
218
219
  LemmyWebsocket.prototype.stickyPost = function (form) {
219
220
  return wrapper(others_1.UserOperation.StickyPost, form);
220
221
  };
222
+ /**
223
+ * Mark a post as read.
224
+ */
225
+ LemmyWebsocket.prototype.markPostAsRead = function (form) {
226
+ return wrapper(others_1.UserOperation.MarkPostAsRead, form);
227
+ };
221
228
  /**
222
229
  * Save a post.
223
230
  */
@@ -354,7 +361,6 @@ var LemmyWebsocket = /** @class */ (function () {
354
361
  * Gets the site, and your user data.
355
362
  */
356
363
  LemmyWebsocket.prototype.getSite = function (form) {
357
- if (form === void 0) { form = {}; }
358
364
  return wrapper(others_1.UserOperation.GetSite, form);
359
365
  };
360
366
  /**
@@ -481,7 +487,33 @@ var LemmyWebsocket = /** @class */ (function () {
481
487
  }());
482
488
  exports.LemmyWebsocket = LemmyWebsocket;
483
489
  function wrapper(op, data) {
484
- var send = { op: others_1.UserOperation[op], data: data };
490
+ var send = { op: others_1.UserOperation[op], data: (0, class_transformer_1.serialize)(data) };
485
491
  console.log(send);
486
492
  return JSON.stringify(send);
487
493
  }
494
+ /**
495
+ * A websocket JSON response that includes the errors.
496
+ */
497
+ // interface WebSocketJsonResponse {
498
+ // op?: string;
499
+ // /**
500
+ // * This contains the data for a websocket response.
501
+ // *
502
+ // * The correct response type if given is in [[LemmyHttp]].
503
+ // */
504
+ // data?: ResponseType;
505
+ // error?: string;
506
+ // reconnect?: boolean;
507
+ // }
508
+ function wsUserOp(msg) {
509
+ var opStr = msg.op;
510
+ return others_1.UserOperation[opStr];
511
+ }
512
+ exports.wsUserOp = wsUserOp;
513
+ /**
514
+ * Converts a websocket string response to a usable result
515
+ */
516
+ function wsJsonToRes(msg, responseClass) {
517
+ return (0, class_transformer_1.deserialize)(responseClass, msg.data);
518
+ }
519
+ exports.wsJsonToRes = wsJsonToRes;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lemmy-js-client",
3
3
  "description": "A javascript / typescript client for Lemmy",
4
- "version": "0.17.0-rc.2",
4
+ "version": "0.17.0-rc.20",
5
5
  "author": "Dessalines <tyhou13@gmx.com>",
6
6
  "license": "AGPL-3.0",
7
7
  "main": "./dist/index.js",
@@ -16,23 +16,25 @@
16
16
  },
17
17
  "repository": "https://github.com/LemmyNet/lemmy-js-client",
18
18
  "devDependencies": {
19
- "@types/node": "^17.0.10",
19
+ "@sniptt/monads": "^0.5.10",
20
+ "@types/node": "^17.0.33",
20
21
  "@types/node-fetch": "^3.0.3",
21
- "@typescript-eslint/eslint-plugin": "^5.10.0",
22
- "@typescript-eslint/parser": "^5.10.0",
23
- "eslint": "^8.7.0",
22
+ "@typescript-eslint/eslint-plugin": "^5.23.0",
23
+ "@typescript-eslint/parser": "^5.23.0",
24
+ "class-transformer": "^0.5.1",
25
+ "eslint": "^8.15.0",
24
26
  "eslint-plugin-prettier": "^4.0.0",
25
- "husky": "^7.0.4",
26
- "lint-staged": "^12.2.2",
27
- "node-fetch": "^3.1.1",
28
- "prettier": "^2.5.0",
27
+ "husky": "^8.0.1",
28
+ "lint-staged": "^12.4.1",
29
+ "node-fetch": "^3.2.4",
30
+ "prettier": "^2.6.2",
29
31
  "prettier-plugin-import-sort": "^0.0.7",
30
32
  "prettier-plugin-organize-imports": "^2.3.4",
31
- "prettier-plugin-packagejson": "^2.2.15",
33
+ "prettier-plugin-packagejson": "^2.2.18",
32
34
  "sortpack": "^2.2.0",
33
35
  "typedoc": "^0.21.6",
34
36
  "typedoc-plugin-sourcefile-url": "^1.0.6",
35
- "typescript": "^4.5.4"
37
+ "typescript": "^4.6.4"
36
38
  },
37
39
  "types": "./dist/index.d.ts",
38
40
  "lint-staged": {