lemmy-js-client 0.17.0-rc.13 → 0.17.0-rc.16

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,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,23 +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
29
  counts: SiteAggregates;
29
30
  }
30
- export interface PrivateMessageView {
31
+ export declare class PrivateMessageView {
31
32
  private_message: PrivateMessage;
32
33
  creator: PersonSafe;
33
34
  recipient: PersonSafe;
34
35
  }
35
- export interface PostView {
36
+ export declare class PostView {
36
37
  post: Post;
37
38
  creator: PersonSafe;
38
39
  community: CommunitySafe;
@@ -42,23 +43,23 @@ export interface PostView {
42
43
  saved: boolean;
43
44
  read: boolean;
44
45
  creator_blocked: boolean;
45
- my_vote?: number;
46
+ my_vote: Option<number>;
46
47
  }
47
- export interface PostReportView {
48
+ export declare class PostReportView {
48
49
  post_report: PostReport;
49
50
  post: Post;
50
51
  community: CommunitySafe;
51
52
  creator: PersonSafe;
52
53
  post_creator: PersonSafe;
53
54
  creator_banned_from_community: boolean;
54
- my_vote?: number;
55
+ my_vote: Option<number>;
55
56
  counts: PostAggregates;
56
- resolver?: PersonSafe;
57
+ resolver: Option<PersonSafe>;
57
58
  }
58
- export interface CommentView {
59
+ export declare class CommentView {
59
60
  comment: Comment;
60
61
  creator: PersonSafe;
61
- recipient?: PersonSafe;
62
+ recipient: Option<PersonSafe>;
62
63
  post: Post;
63
64
  community: CommunitySafe;
64
65
  counts: CommentAggregates;
@@ -66,9 +67,9 @@ export interface CommentView {
66
67
  subscribed: boolean;
67
68
  saved: boolean;
68
69
  creator_blocked: boolean;
69
- my_vote?: number;
70
+ my_vote: Option<number>;
70
71
  }
71
- export interface CommentReportView {
72
+ export declare class CommentReportView {
72
73
  comment_report: CommentReport;
73
74
  comment: Comment;
74
75
  post: Post;
@@ -77,44 +78,44 @@ export interface CommentReportView {
77
78
  comment_creator: PersonSafe;
78
79
  counts: CommentAggregates;
79
80
  creator_banned_from_community: boolean;
80
- my_vote?: number;
81
- resolver?: PersonSafe;
81
+ my_vote: Option<number>;
82
+ resolver: Option<PersonSafe>;
82
83
  }
83
- export interface ModAddCommunityView {
84
+ export declare class ModAddCommunityView {
84
85
  mod_add_community: ModAddCommunity;
85
86
  moderator: PersonSafe;
86
87
  community: CommunitySafe;
87
88
  modded_person: PersonSafe;
88
89
  }
89
- export interface ModTransferCommunityView {
90
+ export declare class ModTransferCommunityView {
90
91
  mod_transfer_community: ModTransferCommunity;
91
92
  moderator: PersonSafe;
92
93
  community: CommunitySafe;
93
94
  modded_person: PersonSafe;
94
95
  }
95
- export interface ModAddView {
96
+ export declare class ModAddView {
96
97
  mod_add: ModAdd;
97
98
  moderator: PersonSafe;
98
99
  modded_person: PersonSafe;
99
100
  }
100
- export interface ModBanFromCommunityView {
101
+ export declare class ModBanFromCommunityView {
101
102
  mod_ban_from_community: ModBanFromCommunity;
102
103
  moderator: PersonSafe;
103
104
  community: CommunitySafe;
104
105
  banned_person: PersonSafe;
105
106
  }
106
- export interface ModBanView {
107
+ export declare class ModBanView {
107
108
  mod_ban: ModBan;
108
109
  moderator: PersonSafe;
109
110
  banned_person: PersonSafe;
110
111
  }
111
- export interface ModLockPostView {
112
+ export declare class ModLockPostView {
112
113
  mod_lock_post: ModLockPost;
113
114
  moderator: PersonSafe;
114
115
  post: Post;
115
116
  community: CommunitySafe;
116
117
  }
117
- export interface ModRemoveCommentView {
118
+ export declare class ModRemoveCommentView {
118
119
  mod_remove_comment: ModRemoveComment;
119
120
  moderator: PersonSafe;
120
121
  comment: Comment;
@@ -122,52 +123,52 @@ export interface ModRemoveCommentView {
122
123
  post: Post;
123
124
  community: CommunitySafe;
124
125
  }
125
- export interface ModRemoveCommunityView {
126
+ export declare class ModRemoveCommunityView {
126
127
  mod_remove_community: ModRemoveCommunity;
127
128
  moderator: PersonSafe;
128
129
  community: CommunitySafe;
129
130
  }
130
- export interface ModRemovePostView {
131
+ export declare class ModRemovePostView {
131
132
  mod_remove_post: ModRemovePost;
132
133
  moderator: PersonSafe;
133
134
  post: Post;
134
135
  community: CommunitySafe;
135
136
  }
136
- export interface ModStickyPostView {
137
+ export declare class ModStickyPostView {
137
138
  mod_sticky_post: ModStickyPost;
138
139
  moderator: PersonSafe;
139
140
  post: Post;
140
141
  community: CommunitySafe;
141
142
  }
142
- export interface CommunityFollowerView {
143
+ export declare class CommunityFollowerView {
143
144
  community: CommunitySafe;
144
145
  follower: PersonSafe;
145
146
  }
146
- export interface CommunityBlockView {
147
+ export declare class CommunityBlockView {
147
148
  person: PersonSafe;
148
149
  community: CommunitySafe;
149
150
  }
150
- export interface CommunityModeratorView {
151
+ export declare class CommunityModeratorView {
151
152
  community: CommunitySafe;
152
153
  moderator: PersonSafe;
153
154
  }
154
- export interface CommunityPersonBanView {
155
+ export declare class CommunityPersonBanView {
155
156
  community: CommunitySafe;
156
157
  person: PersonSafe;
157
158
  }
158
- export interface PersonBlockView {
159
+ export declare class PersonBlockView {
159
160
  person: PersonSafe;
160
161
  target: PersonSafe;
161
162
  }
162
- export interface CommunityView {
163
+ export declare class CommunityView {
163
164
  community: CommunitySafe;
164
165
  subscribed: boolean;
165
166
  blocked: boolean;
166
167
  counts: CommunityAggregates;
167
168
  }
168
- export interface RegistrationApplicationView {
169
+ export declare class RegistrationApplicationView {
169
170
  registration_application: RegistrationApplication;
170
171
  creator_local_user: LocalUserSettings;
171
172
  creator: PersonSafe;
172
- admin?: PersonSafe;
173
+ admin: Option<PersonSafe>;
173
174
  }
@@ -1,2 +1,267 @@
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 PersonViewSafe = /** @class */ (function () {
14
+ function PersonViewSafe() {
15
+ }
16
+ return PersonViewSafe;
17
+ }());
18
+ exports.PersonViewSafe = PersonViewSafe;
19
+ var PersonMentionView = /** @class */ (function () {
20
+ function PersonMentionView() {
21
+ }
22
+ __decorate([
23
+ (0, class_transformer_1.Transform)(function (_a) {
24
+ var value = _a.value;
25
+ return (0, monads_1.Some)(value);
26
+ }, { toClassOnly: true }),
27
+ (0, class_transformer_1.Transform)(function (_a) {
28
+ var value = _a.value;
29
+ return (0, utils_1.toUndefined)(value);
30
+ }, { toPlainOnly: true }),
31
+ (0, class_transformer_1.Expose)()
32
+ ], PersonMentionView.prototype, "my_vote", void 0);
33
+ return PersonMentionView;
34
+ }());
35
+ exports.PersonMentionView = PersonMentionView;
36
+ var LocalUserSettingsView = /** @class */ (function () {
37
+ function LocalUserSettingsView() {
38
+ }
39
+ return LocalUserSettingsView;
40
+ }());
41
+ exports.LocalUserSettingsView = LocalUserSettingsView;
42
+ var SiteView = /** @class */ (function () {
43
+ function SiteView() {
44
+ }
45
+ return SiteView;
46
+ }());
47
+ exports.SiteView = SiteView;
48
+ var PrivateMessageView = /** @class */ (function () {
49
+ function PrivateMessageView() {
50
+ }
51
+ return PrivateMessageView;
52
+ }());
53
+ exports.PrivateMessageView = PrivateMessageView;
54
+ var PostView = /** @class */ (function () {
55
+ function PostView() {
56
+ }
57
+ __decorate([
58
+ (0, class_transformer_1.Transform)(function (_a) {
59
+ var value = _a.value;
60
+ return (0, monads_1.Some)(value);
61
+ }, { toClassOnly: true }),
62
+ (0, class_transformer_1.Transform)(function (_a) {
63
+ var value = _a.value;
64
+ return (0, utils_1.toUndefined)(value);
65
+ }, { toPlainOnly: true }),
66
+ (0, class_transformer_1.Expose)()
67
+ ], PostView.prototype, "my_vote", void 0);
68
+ return PostView;
69
+ }());
70
+ exports.PostView = PostView;
71
+ var PostReportView = /** @class */ (function () {
72
+ function PostReportView() {
73
+ }
74
+ __decorate([
75
+ (0, class_transformer_1.Transform)(function (_a) {
76
+ var value = _a.value;
77
+ return (0, monads_1.Some)(value);
78
+ }, { toClassOnly: true }),
79
+ (0, class_transformer_1.Transform)(function (_a) {
80
+ var value = _a.value;
81
+ return (0, utils_1.toUndefined)(value);
82
+ }, { toPlainOnly: true }),
83
+ (0, class_transformer_1.Expose)()
84
+ ], PostReportView.prototype, "my_vote", void 0);
85
+ __decorate([
86
+ (0, class_transformer_1.Transform)(function (_a) {
87
+ var value = _a.value;
88
+ return (0, monads_1.Some)(value);
89
+ }, { toClassOnly: true }),
90
+ (0, class_transformer_1.Transform)(function (_a) {
91
+ var value = _a.value;
92
+ return (0, utils_1.toUndefined)(value);
93
+ }, { toPlainOnly: true }),
94
+ (0, class_transformer_1.Expose)()
95
+ ], PostReportView.prototype, "resolver", void 0);
96
+ return PostReportView;
97
+ }());
98
+ exports.PostReportView = PostReportView;
99
+ var CommentView = /** @class */ (function () {
100
+ function CommentView() {
101
+ }
102
+ __decorate([
103
+ (0, class_transformer_1.Transform)(function (_a) {
104
+ var value = _a.value;
105
+ return (0, monads_1.Some)(value);
106
+ }, { toClassOnly: true }),
107
+ (0, class_transformer_1.Transform)(function (_a) {
108
+ var value = _a.value;
109
+ return (0, utils_1.toUndefined)(value);
110
+ }, { toPlainOnly: true }),
111
+ (0, class_transformer_1.Expose)()
112
+ ], CommentView.prototype, "recipient", void 0);
113
+ __decorate([
114
+ (0, class_transformer_1.Transform)(function (_a) {
115
+ var value = _a.value;
116
+ return (0, monads_1.Some)(value);
117
+ }, { toClassOnly: true }),
118
+ (0, class_transformer_1.Transform)(function (_a) {
119
+ var value = _a.value;
120
+ return (0, utils_1.toUndefined)(value);
121
+ }, { toPlainOnly: true }),
122
+ (0, class_transformer_1.Expose)()
123
+ ], CommentView.prototype, "my_vote", void 0);
124
+ return CommentView;
125
+ }());
126
+ exports.CommentView = CommentView;
127
+ var CommentReportView = /** @class */ (function () {
128
+ function CommentReportView() {
129
+ }
130
+ __decorate([
131
+ (0, class_transformer_1.Transform)(function (_a) {
132
+ var value = _a.value;
133
+ return (0, monads_1.Some)(value);
134
+ }, { toClassOnly: true }),
135
+ (0, class_transformer_1.Transform)(function (_a) {
136
+ var value = _a.value;
137
+ return (0, utils_1.toUndefined)(value);
138
+ }, { toPlainOnly: true }),
139
+ (0, class_transformer_1.Expose)()
140
+ ], CommentReportView.prototype, "my_vote", void 0);
141
+ __decorate([
142
+ (0, class_transformer_1.Transform)(function (_a) {
143
+ var value = _a.value;
144
+ return (0, monads_1.Some)(value);
145
+ }, { toClassOnly: true }),
146
+ (0, class_transformer_1.Transform)(function (_a) {
147
+ var value = _a.value;
148
+ return (0, utils_1.toUndefined)(value);
149
+ }, { toPlainOnly: true }),
150
+ (0, class_transformer_1.Expose)()
151
+ ], CommentReportView.prototype, "resolver", void 0);
152
+ return CommentReportView;
153
+ }());
154
+ exports.CommentReportView = CommentReportView;
155
+ var ModAddCommunityView = /** @class */ (function () {
156
+ function ModAddCommunityView() {
157
+ }
158
+ return ModAddCommunityView;
159
+ }());
160
+ exports.ModAddCommunityView = ModAddCommunityView;
161
+ var ModTransferCommunityView = /** @class */ (function () {
162
+ function ModTransferCommunityView() {
163
+ }
164
+ return ModTransferCommunityView;
165
+ }());
166
+ exports.ModTransferCommunityView = ModTransferCommunityView;
167
+ var ModAddView = /** @class */ (function () {
168
+ function ModAddView() {
169
+ }
170
+ return ModAddView;
171
+ }());
172
+ exports.ModAddView = ModAddView;
173
+ var ModBanFromCommunityView = /** @class */ (function () {
174
+ function ModBanFromCommunityView() {
175
+ }
176
+ return ModBanFromCommunityView;
177
+ }());
178
+ exports.ModBanFromCommunityView = ModBanFromCommunityView;
179
+ var ModBanView = /** @class */ (function () {
180
+ function ModBanView() {
181
+ }
182
+ return ModBanView;
183
+ }());
184
+ exports.ModBanView = ModBanView;
185
+ var ModLockPostView = /** @class */ (function () {
186
+ function ModLockPostView() {
187
+ }
188
+ return ModLockPostView;
189
+ }());
190
+ exports.ModLockPostView = ModLockPostView;
191
+ var ModRemoveCommentView = /** @class */ (function () {
192
+ function ModRemoveCommentView() {
193
+ }
194
+ return ModRemoveCommentView;
195
+ }());
196
+ exports.ModRemoveCommentView = ModRemoveCommentView;
197
+ var ModRemoveCommunityView = /** @class */ (function () {
198
+ function ModRemoveCommunityView() {
199
+ }
200
+ return ModRemoveCommunityView;
201
+ }());
202
+ exports.ModRemoveCommunityView = ModRemoveCommunityView;
203
+ var ModRemovePostView = /** @class */ (function () {
204
+ function ModRemovePostView() {
205
+ }
206
+ return ModRemovePostView;
207
+ }());
208
+ exports.ModRemovePostView = ModRemovePostView;
209
+ var ModStickyPostView = /** @class */ (function () {
210
+ function ModStickyPostView() {
211
+ }
212
+ return ModStickyPostView;
213
+ }());
214
+ exports.ModStickyPostView = ModStickyPostView;
215
+ var CommunityFollowerView = /** @class */ (function () {
216
+ function CommunityFollowerView() {
217
+ }
218
+ return CommunityFollowerView;
219
+ }());
220
+ exports.CommunityFollowerView = CommunityFollowerView;
221
+ var CommunityBlockView = /** @class */ (function () {
222
+ function CommunityBlockView() {
223
+ }
224
+ return CommunityBlockView;
225
+ }());
226
+ exports.CommunityBlockView = CommunityBlockView;
227
+ var CommunityModeratorView = /** @class */ (function () {
228
+ function CommunityModeratorView() {
229
+ }
230
+ return CommunityModeratorView;
231
+ }());
232
+ exports.CommunityModeratorView = CommunityModeratorView;
233
+ var CommunityPersonBanView = /** @class */ (function () {
234
+ function CommunityPersonBanView() {
235
+ }
236
+ return CommunityPersonBanView;
237
+ }());
238
+ exports.CommunityPersonBanView = CommunityPersonBanView;
239
+ var PersonBlockView = /** @class */ (function () {
240
+ function PersonBlockView() {
241
+ }
242
+ return PersonBlockView;
243
+ }());
244
+ exports.PersonBlockView = PersonBlockView;
245
+ var CommunityView = /** @class */ (function () {
246
+ function CommunityView() {
247
+ }
248
+ return CommunityView;
249
+ }());
250
+ exports.CommunityView = CommunityView;
251
+ var RegistrationApplicationView = /** @class */ (function () {
252
+ function RegistrationApplicationView() {
253
+ }
254
+ __decorate([
255
+ (0, class_transformer_1.Transform)(function (_a) {
256
+ var value = _a.value;
257
+ return (0, monads_1.Some)(value);
258
+ }, { toClassOnly: true }),
259
+ (0, class_transformer_1.Transform)(function (_a) {
260
+ var value = _a.value;
261
+ return (0, utils_1.toUndefined)(value);
262
+ }, { toPlainOnly: true }),
263
+ (0, class_transformer_1.Expose)()
264
+ ], RegistrationApplicationView.prototype, "admin", void 0);
265
+ return RegistrationApplicationView;
266
+ }());
267
+ 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
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
  *
@@ -248,7 +250,7 @@ export declare class LemmyWebsocket {
248
250
  /**
249
251
  * Gets the site, and your user data.
250
252
  */
251
- getSite(form?: GetSite): string;
253
+ getSite(form: GetSite): string;
252
254
  /**
253
255
  * Get your site configuration.
254
256
  */
@@ -330,3 +332,11 @@ export declare class LemmyWebsocket {
330
332
  */
331
333
  blockCommunity(form: BlockCommunity): string;
332
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.
@@ -360,7 +361,6 @@ var LemmyWebsocket = /** @class */ (function () {
360
361
  * Gets the site, and your user data.
361
362
  */
362
363
  LemmyWebsocket.prototype.getSite = function (form) {
363
- if (form === void 0) { form = {}; }
364
364
  return wrapper(others_1.UserOperation.GetSite, form);
365
365
  };
366
366
  /**
@@ -487,7 +487,33 @@ var LemmyWebsocket = /** @class */ (function () {
487
487
  }());
488
488
  exports.LemmyWebsocket = LemmyWebsocket;
489
489
  function wrapper(op, data) {
490
- var send = { op: others_1.UserOperation[op], data: data };
490
+ var send = { op: others_1.UserOperation[op], data: (0, class_transformer_1.serialize)(data) };
491
491
  console.log(send);
492
492
  return JSON.stringify(send);
493
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.13",
4
+ "version": "0.17.0-rc.16",
5
5
  "author": "Dessalines <tyhou13@gmx.com>",
6
6
  "license": "AGPL-3.0",
7
7
  "main": "./dist/index.js",
@@ -16,11 +16,12 @@
16
16
  },
17
17
  "repository": "https://github.com/LemmyNet/lemmy-js-client",
18
18
  "devDependencies": {
19
- "@swan-io/boxed": "^0.9.0",
19
+ "@sniptt/monads": "^0.5.10",
20
20
  "@types/node": "^17.0.33",
21
21
  "@types/node-fetch": "^3.0.3",
22
22
  "@typescript-eslint/eslint-plugin": "^5.23.0",
23
23
  "@typescript-eslint/parser": "^5.23.0",
24
+ "class-transformer": "^0.5.1",
24
25
  "eslint": "^8.15.0",
25
26
  "eslint-plugin-prettier": "^4.0.0",
26
27
  "husky": "^8.0.1",