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

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.
@@ -1,10 +1,12 @@
1
+ import { Option } from "@sniptt/monads";
2
+ import "reflect-metadata";
1
3
  import { CommentAggregates, CommunityAggregates, PersonAggregates, PostAggregates, SiteAggregates } from "./aggregates";
2
4
  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 {
5
+ export declare class PersonViewSafe {
4
6
  person: PersonSafe;
5
7
  counts: PersonAggregates;
6
8
  }
7
- export interface PersonMentionView {
9
+ export declare class PersonMentionView {
8
10
  person_mention: PersonMention;
9
11
  comment: Comment;
10
12
  creator: PersonSafe;
@@ -16,24 +18,23 @@ export interface PersonMentionView {
16
18
  subscribed: boolean;
17
19
  saved: boolean;
18
20
  creator_blocked: boolean;
19
- my_vote?: number;
21
+ my_vote: Option<number>;
20
22
  }
21
- export interface LocalUserSettingsView {
23
+ export declare class LocalUserSettingsView {
22
24
  local_user: LocalUserSettings;
23
25
  person: PersonSafe;
24
26
  counts: PersonAggregates;
25
27
  }
26
- export interface SiteView {
28
+ export declare class SiteView {
27
29
  site: Site;
28
- creator: PersonSafe;
29
30
  counts: SiteAggregates;
30
31
  }
31
- export interface PrivateMessageView {
32
+ export declare class PrivateMessageView {
32
33
  private_message: PrivateMessage;
33
34
  creator: PersonSafe;
34
35
  recipient: PersonSafe;
35
36
  }
36
- export interface PostView {
37
+ export declare class PostView {
37
38
  post: Post;
38
39
  creator: PersonSafe;
39
40
  community: CommunitySafe;
@@ -43,23 +44,23 @@ export interface PostView {
43
44
  saved: boolean;
44
45
  read: boolean;
45
46
  creator_blocked: boolean;
46
- my_vote?: number;
47
+ my_vote: Option<number>;
47
48
  }
48
- export interface PostReportView {
49
+ export declare class PostReportView {
49
50
  post_report: PostReport;
50
51
  post: Post;
51
52
  community: CommunitySafe;
52
53
  creator: PersonSafe;
53
54
  post_creator: PersonSafe;
54
55
  creator_banned_from_community: boolean;
55
- my_vote?: number;
56
+ my_vote: Option<number>;
56
57
  counts: PostAggregates;
57
- resolver?: PersonSafe;
58
+ resolver: Option<PersonSafe>;
58
59
  }
59
- export interface CommentView {
60
+ export declare class CommentView {
60
61
  comment: Comment;
61
62
  creator: PersonSafe;
62
- recipient?: PersonSafe;
63
+ recipient: Option<PersonSafe>;
63
64
  post: Post;
64
65
  community: CommunitySafe;
65
66
  counts: CommentAggregates;
@@ -67,9 +68,9 @@ export interface CommentView {
67
68
  subscribed: boolean;
68
69
  saved: boolean;
69
70
  creator_blocked: boolean;
70
- my_vote?: number;
71
+ my_vote: Option<number>;
71
72
  }
72
- export interface CommentReportView {
73
+ export declare class CommentReportView {
73
74
  comment_report: CommentReport;
74
75
  comment: Comment;
75
76
  post: Post;
@@ -78,44 +79,44 @@ export interface CommentReportView {
78
79
  comment_creator: PersonSafe;
79
80
  counts: CommentAggregates;
80
81
  creator_banned_from_community: boolean;
81
- my_vote?: number;
82
- resolver?: PersonSafe;
82
+ my_vote: Option<number>;
83
+ resolver: Option<PersonSafe>;
83
84
  }
84
- export interface ModAddCommunityView {
85
+ export declare class ModAddCommunityView {
85
86
  mod_add_community: ModAddCommunity;
86
87
  moderator: PersonSafe;
87
88
  community: CommunitySafe;
88
89
  modded_person: PersonSafe;
89
90
  }
90
- export interface ModTransferCommunityView {
91
+ export declare class ModTransferCommunityView {
91
92
  mod_transfer_community: ModTransferCommunity;
92
93
  moderator: PersonSafe;
93
94
  community: CommunitySafe;
94
95
  modded_person: PersonSafe;
95
96
  }
96
- export interface ModAddView {
97
+ export declare class ModAddView {
97
98
  mod_add: ModAdd;
98
99
  moderator: PersonSafe;
99
100
  modded_person: PersonSafe;
100
101
  }
101
- export interface ModBanFromCommunityView {
102
+ export declare class ModBanFromCommunityView {
102
103
  mod_ban_from_community: ModBanFromCommunity;
103
104
  moderator: PersonSafe;
104
105
  community: CommunitySafe;
105
106
  banned_person: PersonSafe;
106
107
  }
107
- export interface ModBanView {
108
+ export declare class ModBanView {
108
109
  mod_ban: ModBan;
109
110
  moderator: PersonSafe;
110
111
  banned_person: PersonSafe;
111
112
  }
112
- export interface ModLockPostView {
113
+ export declare class ModLockPostView {
113
114
  mod_lock_post: ModLockPost;
114
115
  moderator: PersonSafe;
115
116
  post: Post;
116
117
  community: CommunitySafe;
117
118
  }
118
- export interface ModRemoveCommentView {
119
+ export declare class ModRemoveCommentView {
119
120
  mod_remove_comment: ModRemoveComment;
120
121
  moderator: PersonSafe;
121
122
  comment: Comment;
@@ -123,53 +124,52 @@ export interface ModRemoveCommentView {
123
124
  post: Post;
124
125
  community: CommunitySafe;
125
126
  }
126
- export interface ModRemoveCommunityView {
127
+ export declare class ModRemoveCommunityView {
127
128
  mod_remove_community: ModRemoveCommunity;
128
129
  moderator: PersonSafe;
129
130
  community: CommunitySafe;
130
131
  }
131
- export interface ModRemovePostView {
132
+ export declare class ModRemovePostView {
132
133
  mod_remove_post: ModRemovePost;
133
134
  moderator: PersonSafe;
134
135
  post: Post;
135
136
  community: CommunitySafe;
136
137
  }
137
- export interface ModStickyPostView {
138
+ export declare class ModStickyPostView {
138
139
  mod_sticky_post: ModStickyPost;
139
140
  moderator: PersonSafe;
140
141
  post: Post;
141
142
  community: CommunitySafe;
142
143
  }
143
- export interface CommunityFollowerView {
144
+ export declare class CommunityFollowerView {
144
145
  community: CommunitySafe;
145
146
  follower: PersonSafe;
146
- pending?: boolean;
147
147
  }
148
- export interface CommunityBlockView {
148
+ export declare class CommunityBlockView {
149
149
  person: PersonSafe;
150
150
  community: CommunitySafe;
151
151
  }
152
- export interface CommunityModeratorView {
152
+ export declare class CommunityModeratorView {
153
153
  community: CommunitySafe;
154
154
  moderator: PersonSafe;
155
155
  }
156
- export interface CommunityPersonBanView {
156
+ export declare class CommunityPersonBanView {
157
157
  community: CommunitySafe;
158
158
  person: PersonSafe;
159
159
  }
160
- export interface PersonBlockView {
160
+ export declare class PersonBlockView {
161
161
  person: PersonSafe;
162
162
  target: PersonSafe;
163
163
  }
164
- export interface CommunityView {
164
+ export declare class CommunityView {
165
165
  community: CommunitySafe;
166
166
  subscribed: boolean;
167
167
  blocked: boolean;
168
168
  counts: CommunityAggregates;
169
169
  }
170
- export interface RegistrationApplicationView {
170
+ export declare class RegistrationApplicationView {
171
171
  registration_application: RegistrationApplication;
172
172
  creator_local_user: LocalUserSettings;
173
173
  creator: PersonSafe;
174
- admin?: PersonSafe;
174
+ admin: Option<PersonSafe>;
175
175
  }
@@ -1,2 +1,276 @@
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
+ require("reflect-metadata");
13
+ var utils_1 = require("../utils");
14
+ var source_1 = require("./source");
15
+ var PersonViewSafe = /** @class */ (function () {
16
+ function PersonViewSafe() {
17
+ }
18
+ return PersonViewSafe;
19
+ }());
20
+ exports.PersonViewSafe = PersonViewSafe;
21
+ var PersonMentionView = /** @class */ (function () {
22
+ function PersonMentionView() {
23
+ }
24
+ __decorate([
25
+ (0, class_transformer_1.Transform)(function (_a) {
26
+ var value = _a.value;
27
+ return (0, monads_1.Some)(value);
28
+ }, { toClassOnly: true }),
29
+ (0, class_transformer_1.Transform)(function (_a) {
30
+ var value = _a.value;
31
+ return (0, utils_1.toUndefined)(value);
32
+ }, { toPlainOnly: true }),
33
+ (0, class_transformer_1.Expose)()
34
+ ], PersonMentionView.prototype, "my_vote", void 0);
35
+ return PersonMentionView;
36
+ }());
37
+ exports.PersonMentionView = PersonMentionView;
38
+ var LocalUserSettingsView = /** @class */ (function () {
39
+ function LocalUserSettingsView() {
40
+ }
41
+ return LocalUserSettingsView;
42
+ }());
43
+ exports.LocalUserSettingsView = LocalUserSettingsView;
44
+ var SiteView = /** @class */ (function () {
45
+ function SiteView() {
46
+ }
47
+ __decorate([
48
+ (0, class_transformer_1.Type)(function () { return source_1.Site; })
49
+ ], SiteView.prototype, "site", void 0);
50
+ return SiteView;
51
+ }());
52
+ exports.SiteView = SiteView;
53
+ var PrivateMessageView = /** @class */ (function () {
54
+ function PrivateMessageView() {
55
+ }
56
+ return PrivateMessageView;
57
+ }());
58
+ exports.PrivateMessageView = PrivateMessageView;
59
+ var PostView = /** @class */ (function () {
60
+ function PostView() {
61
+ }
62
+ __decorate([
63
+ (0, class_transformer_1.Transform)(function (_a) {
64
+ var value = _a.value;
65
+ return (0, monads_1.Some)(value);
66
+ }, { toClassOnly: true }),
67
+ (0, class_transformer_1.Transform)(function (_a) {
68
+ var value = _a.value;
69
+ return (0, utils_1.toUndefined)(value);
70
+ }, { toPlainOnly: true }),
71
+ (0, class_transformer_1.Expose)()
72
+ ], PostView.prototype, "my_vote", void 0);
73
+ return PostView;
74
+ }());
75
+ exports.PostView = PostView;
76
+ var PostReportView = /** @class */ (function () {
77
+ function PostReportView() {
78
+ }
79
+ __decorate([
80
+ (0, class_transformer_1.Transform)(function (_a) {
81
+ var value = _a.value;
82
+ return (0, monads_1.Some)(value);
83
+ }, { toClassOnly: true }),
84
+ (0, class_transformer_1.Transform)(function (_a) {
85
+ var value = _a.value;
86
+ return (0, utils_1.toUndefined)(value);
87
+ }, { toPlainOnly: true }),
88
+ (0, class_transformer_1.Expose)()
89
+ ], PostReportView.prototype, "my_vote", void 0);
90
+ __decorate([
91
+ (0, class_transformer_1.Transform)(function (_a) {
92
+ var value = _a.value;
93
+ return (0, monads_1.Some)(value);
94
+ }, { toClassOnly: true }),
95
+ (0, class_transformer_1.Transform)(function (_a) {
96
+ var value = _a.value;
97
+ return (0, utils_1.toUndefined)(value);
98
+ }, { toPlainOnly: true }),
99
+ (0, class_transformer_1.Expose)(),
100
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
101
+ ], PostReportView.prototype, "resolver", void 0);
102
+ return PostReportView;
103
+ }());
104
+ exports.PostReportView = PostReportView;
105
+ var CommentView = /** @class */ (function () {
106
+ function CommentView() {
107
+ }
108
+ __decorate([
109
+ (0, class_transformer_1.Transform)(function (_a) {
110
+ var value = _a.value;
111
+ return (0, monads_1.Some)(value);
112
+ }, { toClassOnly: true }),
113
+ (0, class_transformer_1.Transform)(function (_a) {
114
+ var value = _a.value;
115
+ return (0, utils_1.toUndefined)(value);
116
+ }, { toPlainOnly: true }),
117
+ (0, class_transformer_1.Expose)(),
118
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
119
+ ], CommentView.prototype, "recipient", void 0);
120
+ __decorate([
121
+ (0, class_transformer_1.Transform)(function (_a) {
122
+ var value = _a.value;
123
+ return (0, monads_1.Some)(value);
124
+ }, { toClassOnly: true }),
125
+ (0, class_transformer_1.Transform)(function (_a) {
126
+ var value = _a.value;
127
+ return (0, utils_1.toUndefined)(value);
128
+ }, { toPlainOnly: true }),
129
+ (0, class_transformer_1.Expose)()
130
+ ], CommentView.prototype, "my_vote", void 0);
131
+ return CommentView;
132
+ }());
133
+ exports.CommentView = CommentView;
134
+ var CommentReportView = /** @class */ (function () {
135
+ function CommentReportView() {
136
+ }
137
+ __decorate([
138
+ (0, class_transformer_1.Transform)(function (_a) {
139
+ var value = _a.value;
140
+ return (0, monads_1.Some)(value);
141
+ }, { toClassOnly: true }),
142
+ (0, class_transformer_1.Transform)(function (_a) {
143
+ var value = _a.value;
144
+ return (0, utils_1.toUndefined)(value);
145
+ }, { toPlainOnly: true }),
146
+ (0, class_transformer_1.Expose)()
147
+ ], CommentReportView.prototype, "my_vote", void 0);
148
+ __decorate([
149
+ (0, class_transformer_1.Transform)(function (_a) {
150
+ var value = _a.value;
151
+ return (0, monads_1.Some)(value);
152
+ }, { toClassOnly: true }),
153
+ (0, class_transformer_1.Transform)(function (_a) {
154
+ var value = _a.value;
155
+ return (0, utils_1.toUndefined)(value);
156
+ }, { toPlainOnly: true }),
157
+ (0, class_transformer_1.Expose)(),
158
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
159
+ ], CommentReportView.prototype, "resolver", void 0);
160
+ return CommentReportView;
161
+ }());
162
+ exports.CommentReportView = CommentReportView;
163
+ var ModAddCommunityView = /** @class */ (function () {
164
+ function ModAddCommunityView() {
165
+ }
166
+ return ModAddCommunityView;
167
+ }());
168
+ exports.ModAddCommunityView = ModAddCommunityView;
169
+ var ModTransferCommunityView = /** @class */ (function () {
170
+ function ModTransferCommunityView() {
171
+ }
172
+ return ModTransferCommunityView;
173
+ }());
174
+ exports.ModTransferCommunityView = ModTransferCommunityView;
175
+ var ModAddView = /** @class */ (function () {
176
+ function ModAddView() {
177
+ }
178
+ return ModAddView;
179
+ }());
180
+ exports.ModAddView = ModAddView;
181
+ var ModBanFromCommunityView = /** @class */ (function () {
182
+ function ModBanFromCommunityView() {
183
+ }
184
+ return ModBanFromCommunityView;
185
+ }());
186
+ exports.ModBanFromCommunityView = ModBanFromCommunityView;
187
+ var ModBanView = /** @class */ (function () {
188
+ function ModBanView() {
189
+ }
190
+ return ModBanView;
191
+ }());
192
+ exports.ModBanView = ModBanView;
193
+ var ModLockPostView = /** @class */ (function () {
194
+ function ModLockPostView() {
195
+ }
196
+ return ModLockPostView;
197
+ }());
198
+ exports.ModLockPostView = ModLockPostView;
199
+ var ModRemoveCommentView = /** @class */ (function () {
200
+ function ModRemoveCommentView() {
201
+ }
202
+ return ModRemoveCommentView;
203
+ }());
204
+ exports.ModRemoveCommentView = ModRemoveCommentView;
205
+ var ModRemoveCommunityView = /** @class */ (function () {
206
+ function ModRemoveCommunityView() {
207
+ }
208
+ return ModRemoveCommunityView;
209
+ }());
210
+ exports.ModRemoveCommunityView = ModRemoveCommunityView;
211
+ var ModRemovePostView = /** @class */ (function () {
212
+ function ModRemovePostView() {
213
+ }
214
+ return ModRemovePostView;
215
+ }());
216
+ exports.ModRemovePostView = ModRemovePostView;
217
+ var ModStickyPostView = /** @class */ (function () {
218
+ function ModStickyPostView() {
219
+ }
220
+ return ModStickyPostView;
221
+ }());
222
+ exports.ModStickyPostView = ModStickyPostView;
223
+ var CommunityFollowerView = /** @class */ (function () {
224
+ function CommunityFollowerView() {
225
+ }
226
+ return CommunityFollowerView;
227
+ }());
228
+ exports.CommunityFollowerView = CommunityFollowerView;
229
+ var CommunityBlockView = /** @class */ (function () {
230
+ function CommunityBlockView() {
231
+ }
232
+ return CommunityBlockView;
233
+ }());
234
+ exports.CommunityBlockView = CommunityBlockView;
235
+ var CommunityModeratorView = /** @class */ (function () {
236
+ function CommunityModeratorView() {
237
+ }
238
+ return CommunityModeratorView;
239
+ }());
240
+ exports.CommunityModeratorView = CommunityModeratorView;
241
+ var CommunityPersonBanView = /** @class */ (function () {
242
+ function CommunityPersonBanView() {
243
+ }
244
+ return CommunityPersonBanView;
245
+ }());
246
+ exports.CommunityPersonBanView = CommunityPersonBanView;
247
+ var PersonBlockView = /** @class */ (function () {
248
+ function PersonBlockView() {
249
+ }
250
+ return PersonBlockView;
251
+ }());
252
+ exports.PersonBlockView = PersonBlockView;
253
+ var CommunityView = /** @class */ (function () {
254
+ function CommunityView() {
255
+ }
256
+ return CommunityView;
257
+ }());
258
+ exports.CommunityView = CommunityView;
259
+ var RegistrationApplicationView = /** @class */ (function () {
260
+ function RegistrationApplicationView() {
261
+ }
262
+ __decorate([
263
+ (0, class_transformer_1.Transform)(function (_a) {
264
+ var value = _a.value;
265
+ return (0, monads_1.Some)(value);
266
+ }, { toClassOnly: true }),
267
+ (0, class_transformer_1.Transform)(function (_a) {
268
+ var value = _a.value;
269
+ return (0, utils_1.toUndefined)(value);
270
+ }, { toPlainOnly: true }),
271
+ (0, class_transformer_1.Expose)(),
272
+ (0, class_transformer_1.Type)(function () { return source_1.PersonSafe; })
273
+ ], RegistrationApplicationView.prototype, "admin", void 0);
274
+ return RegistrationApplicationView;
275
+ }());
276
+ 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.22",
5
5
  "author": "Dessalines <tyhou13@gmx.com>",
6
6
  "license": "AGPL-3.0",
7
7
  "main": "./dist/index.js",
@@ -16,23 +16,26 @@
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",
34
+ "reflect-metadata": "^0.1.13",
32
35
  "sortpack": "^2.2.0",
33
36
  "typedoc": "^0.21.6",
34
37
  "typedoc-plugin-sourcefile-url": "^1.0.6",
35
- "typescript": "^4.5.4"
38
+ "typescript": "^4.6.4"
36
39
  },
37
40
  "types": "./dist/index.d.ts",
38
41
  "lint-staged": {