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

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,11 @@
1
- import { CreateComment, CreateCommentLike, CreateCommentReport, DeleteComment, EditComment, GetComments, ListCommentReports, MarkCommentAsRead, RemoveComment, ResolveCommentReport, SaveComment } from "./interfaces/api/comment";
1
+ import { ClassConstructor } from "class-transformer";
2
+ import { CreateComment, CreateCommentLike, CreateCommentReport, DeleteComment, EditComment, GetComments, ListCommentReports, 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
- 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 { ApproveRegistrationApplication, CreateSite, EditSite, GetModlog, GetSite, GetSiteConfig, GetUnreadRegistrationApplicationCount, LeaveAdmin, ListRegistrationApplications, ResolveObject, SaveSiteConfig, Search } from "./interfaces/api/site";
4
+ import { AddAdmin, BanPerson, BlockPerson, ChangePassword, CreatePrivateMessage, DeleteAccount, DeletePrivateMessage, EditPrivateMessage, GetBannedPersons, GetPersonDetails, GetPersonMentions, GetPrivateMessages, GetReplies, GetReportCount, GetUnreadCount, Login, MarkAllAsRead, MarkCommentReplyAsRead, MarkPersonMentionAsRead, MarkPrivateMessageAsRead, PasswordChange, PasswordReset, Register, SaveUserSettings, VerifyEmail } from "./interfaces/api/person";
5
+ import { CreatePost, CreatePostLike, CreatePostReport, DeletePost, EditPost, GetPost, GetPosts, GetSiteMetadata, ListPostReports, LockPost, MarkPostAsRead, RemovePost, ResolvePostReport, SavePost, StickyPost } from "./interfaces/api/post";
6
+ import { ApproveRegistrationApplication, CreateSite, EditSite, GetModlog, GetSite, GetUnreadRegistrationApplicationCount, LeaveAdmin, ListRegistrationApplications, PurgeComment, PurgeCommunity, PurgePerson, PurgePost, ResolveObject, 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
  *
@@ -100,7 +102,7 @@ export declare class LemmyWebsocket {
100
102
  /**
101
103
  * Mark a comment as read.
102
104
  */
103
- markCommentAsRead(form: MarkCommentAsRead): string;
105
+ markCommentReplyAsRead(form: MarkCommentReplyAsRead): string;
104
106
  /**
105
107
  * Like / vote on a comment.
106
108
  */
@@ -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,11 +250,7 @@ export declare class LemmyWebsocket {
244
250
  /**
245
251
  * Gets the site, and your user data.
246
252
  */
247
- getSite(form?: GetSite): string;
248
- /**
249
- * Get your site configuration.
250
- */
251
- getSiteConfig(form: GetSiteConfig): string;
253
+ getSite(form: GetSite): string;
252
254
  /**
253
255
  * Search lemmy.
254
256
  */
@@ -313,10 +315,6 @@ export declare class LemmyWebsocket {
313
315
  * Get / fetch private messages.
314
316
  */
315
317
  getPrivateMessages(form: GetPrivateMessages): string;
316
- /**
317
- * Save your site config.
318
- */
319
- saveSiteConfig(form: SaveSiteConfig): string;
320
318
  /**
321
319
  * Block a person.
322
320
  */
@@ -325,4 +323,25 @@ export declare class LemmyWebsocket {
325
323
  * Block a community.
326
324
  */
327
325
  blockCommunity(form: BlockCommunity): string;
326
+ /**
327
+ * Purge / Delete a person from the database.
328
+ */
329
+ purgePerson(form: PurgePerson): string;
330
+ /**
331
+ * Purge / Delete a community from the database.
332
+ */
333
+ purgeCommunity(form: PurgeCommunity): string;
334
+ /**
335
+ * Purge / Delete a post from the database.
336
+ */
337
+ purgePost(form: PurgePost): string;
338
+ /**
339
+ * Purge / Delete a comment from the database.
340
+ */
341
+ purgeComment(form: PurgeComment): string;
328
342
  }
343
+ export declare function wsUserOp(msg: any): UserOperation;
344
+ /**
345
+ * Converts a websocket string response to a usable result
346
+ */
347
+ 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.
@@ -137,8 +138,8 @@ var LemmyWebsocket = /** @class */ (function () {
137
138
  /**
138
139
  * Mark a comment as read.
139
140
  */
140
- LemmyWebsocket.prototype.markCommentAsRead = function (form) {
141
- return wrapper(others_1.UserOperation.MarkCommentAsRead, form);
141
+ LemmyWebsocket.prototype.markCommentReplyAsRead = function (form) {
142
+ return wrapper(others_1.UserOperation.MarkCommentReplyAsRead, form);
142
143
  };
143
144
  /**
144
145
  * Like / vote on a comment.
@@ -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,15 +361,8 @@ 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
- /**
361
- * Get your site configuration.
362
- */
363
- LemmyWebsocket.prototype.getSiteConfig = function (form) {
364
- return wrapper(others_1.UserOperation.GetSiteConfig, form);
365
- };
366
366
  /**
367
367
  * Search lemmy.
368
368
  */
@@ -459,12 +459,6 @@ var LemmyWebsocket = /** @class */ (function () {
459
459
  LemmyWebsocket.prototype.getPrivateMessages = function (form) {
460
460
  return wrapper(others_1.UserOperation.GetPrivateMessages, form);
461
461
  };
462
- /**
463
- * Save your site config.
464
- */
465
- LemmyWebsocket.prototype.saveSiteConfig = function (form) {
466
- return wrapper(others_1.UserOperation.SaveSiteConfig, form);
467
- };
468
462
  /**
469
463
  * Block a person.
470
464
  */
@@ -477,11 +471,47 @@ var LemmyWebsocket = /** @class */ (function () {
477
471
  LemmyWebsocket.prototype.blockCommunity = function (form) {
478
472
  return wrapper(others_1.UserOperation.BlockCommunity, form);
479
473
  };
474
+ /**
475
+ * Purge / Delete a person from the database.
476
+ */
477
+ LemmyWebsocket.prototype.purgePerson = function (form) {
478
+ return wrapper(others_1.UserOperation.PurgePerson, form);
479
+ };
480
+ /**
481
+ * Purge / Delete a community from the database.
482
+ */
483
+ LemmyWebsocket.prototype.purgeCommunity = function (form) {
484
+ return wrapper(others_1.UserOperation.PurgeCommunity, form);
485
+ };
486
+ /**
487
+ * Purge / Delete a post from the database.
488
+ */
489
+ LemmyWebsocket.prototype.purgePost = function (form) {
490
+ return wrapper(others_1.UserOperation.PurgePost, form);
491
+ };
492
+ /**
493
+ * Purge / Delete a comment from the database.
494
+ */
495
+ LemmyWebsocket.prototype.purgeComment = function (form) {
496
+ return wrapper(others_1.UserOperation.PurgeComment, form);
497
+ };
480
498
  return LemmyWebsocket;
481
499
  }());
482
500
  exports.LemmyWebsocket = LemmyWebsocket;
483
501
  function wrapper(op, data) {
484
- var send = { op: others_1.UserOperation[op], data: data };
485
- console.log(send);
486
- return JSON.stringify(send);
502
+ var send = (0, class_transformer_1.serialize)({ op: others_1.UserOperation[op], data: data });
503
+ return send;
504
+ }
505
+ function wsUserOp(msg) {
506
+ var opStr = msg.op;
507
+ return others_1.UserOperation[opStr];
508
+ }
509
+ exports.wsUserOp = wsUserOp;
510
+ /**
511
+ * Converts a websocket string response to a usable result
512
+ */
513
+ function wsJsonToRes(msg, responseClass) {
514
+ // Have to deserialize the response again into the correct class
515
+ return (0, class_transformer_1.deserialize)(responseClass, (0, class_transformer_1.serialize)(msg.data));
487
516
  }
517
+ 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.4",
4
+ "version": "0.17.0-rc.42",
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": "^18.6.2",
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",
24
- "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",
22
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
23
+ "@typescript-eslint/parser": "^5.31.0",
24
+ "class-transformer": "^0.5.1",
25
+ "eslint": "^8.20.0",
26
+ "eslint-plugin-prettier": "^4.2.1",
27
+ "husky": "^8.0.1",
28
+ "lint-staged": "^13.0.3",
29
+ "node-fetch": "^3.2.9",
30
+ "prettier": "^2.7.1",
29
31
  "prettier-plugin-import-sort": "^0.0.7",
30
- "prettier-plugin-organize-imports": "^2.3.4",
31
- "prettier-plugin-packagejson": "^2.2.15",
32
- "sortpack": "^2.2.0",
32
+ "prettier-plugin-organize-imports": "^3.0.0",
33
+ "prettier-plugin-packagejson": "^2.2.18",
34
+ "reflect-metadata": "^0.1.13",
35
+ "sortpack": "^2.3.0",
33
36
  "typedoc": "^0.21.6",
34
37
  "typedoc-plugin-sourcefile-url": "^1.0.6",
35
- "typescript": "^4.5.4"
38
+ "typescript": "^4.7.4"
36
39
  },
37
40
  "types": "./dist/index.d.ts",
38
41
  "lint-staged": {