lemmy-js-client 0.17.0-rc.5 → 0.17.0-rc.50
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/http.d.ts +196 -14
- package/dist/http.js +332 -98
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -1
- package/dist/interfaces/aggregates.d.ts +1 -0
- package/dist/interfaces/api/comment.d.ts +54 -46
- package/dist/interfaces/api/comment.js +393 -0
- package/dist/interfaces/api/community.d.ts +56 -48
- package/dist/interfaces/api/community.js +433 -0
- package/dist/interfaces/api/index.js +5 -1
- package/dist/interfaces/api/person.d.ts +159 -102
- package/dist/interfaces/api/person.js +1004 -0
- package/dist/interfaces/api/post.d.ts +73 -54
- package/dist/interfaces/api/post.js +475 -0
- package/dist/interfaces/api/site.d.ts +182 -99
- package/dist/interfaces/api/site.js +1552 -0
- package/dist/interfaces/index.js +5 -1
- package/dist/interfaces/others.d.ts +122 -90
- package/dist/interfaces/others.js +187 -59
- package/dist/interfaces/source.d.ts +178 -83
- package/dist/interfaces/source.js +899 -0
- package/dist/interfaces/views.d.ts +99 -50
- package/dist/interfaces/views.js +761 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +18 -0
- package/dist/websocket.d.ts +43 -12
- package/dist/websocket.js +64 -16
- package/package.json +17 -14
package/dist/utils.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
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;
|
6
|
+
/**
|
7
|
+
* Converts a null value to an option.
|
8
|
+
*/
|
9
|
+
export declare function toOption<T>(val: T): Option<T>;
|
package/dist/utils.js
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.toOption = exports.toUndefined = void 0;
|
4
|
+
var monads_1 = require("@sniptt/monads");
|
5
|
+
/**
|
6
|
+
* Converts an option to an undefined. Necessary for API requests.
|
7
|
+
*/
|
8
|
+
function toUndefined(opt) {
|
9
|
+
return opt.isSome() ? opt.unwrap() : undefined;
|
10
|
+
}
|
11
|
+
exports.toUndefined = toUndefined;
|
12
|
+
/**
|
13
|
+
* Converts a null value to an option.
|
14
|
+
*/
|
15
|
+
function toOption(val) {
|
16
|
+
return (0, monads_1.Some)(val || undefined);
|
17
|
+
}
|
18
|
+
exports.toOption = toOption;
|
package/dist/websocket.d.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
import {
|
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,
|
4
|
+
import { AddAdmin, BanPerson, BlockPerson, ChangePassword, CreatePrivateMessage, CreatePrivateMessageReport, DeleteAccount, DeletePrivateMessage, EditPrivateMessage, GetBannedPersons, GetPersonDetails, GetPersonMentions, GetPrivateMessages, GetReplies, GetReportCount, GetUnreadCount, ListPrivateMessageReports, Login, MarkAllAsRead, MarkCommentReplyAsRead, MarkPersonMentionAsRead, MarkPrivateMessageAsRead, PasswordChange, PasswordReset, Register, ResolvePrivateMessageReport, 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
|
-
|
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
|
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
|
*/
|
@@ -314,9 +316,17 @@ export declare class LemmyWebsocket {
|
|
314
316
|
*/
|
315
317
|
getPrivateMessages(form: GetPrivateMessages): string;
|
316
318
|
/**
|
317
|
-
*
|
319
|
+
* Create a report for a private message.
|
318
320
|
*/
|
319
|
-
|
321
|
+
createPrivateMessageReport(form: CreatePrivateMessageReport): string;
|
322
|
+
/**
|
323
|
+
* Resolve a report for a private message.
|
324
|
+
*/
|
325
|
+
resolvePrivateMessageReport(form: ResolvePrivateMessageReport): string;
|
326
|
+
/**
|
327
|
+
* List private message reports.
|
328
|
+
*/
|
329
|
+
listPrivateMessageReports(form: ListPrivateMessageReports): string;
|
320
330
|
/**
|
321
331
|
* Block a person.
|
322
332
|
*/
|
@@ -325,4 +335,25 @@ export declare class LemmyWebsocket {
|
|
325
335
|
* Block a community.
|
326
336
|
*/
|
327
337
|
blockCommunity(form: BlockCommunity): string;
|
338
|
+
/**
|
339
|
+
* Purge / Delete a person from the database.
|
340
|
+
*/
|
341
|
+
purgePerson(form: PurgePerson): string;
|
342
|
+
/**
|
343
|
+
* Purge / Delete a community from the database.
|
344
|
+
*/
|
345
|
+
purgeCommunity(form: PurgeCommunity): string;
|
346
|
+
/**
|
347
|
+
* Purge / Delete a post from the database.
|
348
|
+
*/
|
349
|
+
purgePost(form: PurgePost): string;
|
350
|
+
/**
|
351
|
+
* Purge / Delete a comment from the database.
|
352
|
+
*/
|
353
|
+
purgeComment(form: PurgeComment): string;
|
328
354
|
}
|
355
|
+
export declare function wsUserOp(msg: any): UserOperation;
|
356
|
+
/**
|
357
|
+
* Converts a websocket string response to a usable result
|
358
|
+
*/
|
359
|
+
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.
|
141
|
-
return wrapper(others_1.UserOperation.
|
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
|
*/
|
@@ -460,10 +460,22 @@ var LemmyWebsocket = /** @class */ (function () {
|
|
460
460
|
return wrapper(others_1.UserOperation.GetPrivateMessages, form);
|
461
461
|
};
|
462
462
|
/**
|
463
|
-
*
|
463
|
+
* Create a report for a private message.
|
464
|
+
*/
|
465
|
+
LemmyWebsocket.prototype.createPrivateMessageReport = function (form) {
|
466
|
+
return wrapper(others_1.UserOperation.CreatePrivateMessageReport, form);
|
467
|
+
};
|
468
|
+
/**
|
469
|
+
* Resolve a report for a private message.
|
464
470
|
*/
|
465
|
-
LemmyWebsocket.prototype.
|
466
|
-
return wrapper(others_1.UserOperation.
|
471
|
+
LemmyWebsocket.prototype.resolvePrivateMessageReport = function (form) {
|
472
|
+
return wrapper(others_1.UserOperation.ResolvePrivateMessageReport, form);
|
473
|
+
};
|
474
|
+
/**
|
475
|
+
* List private message reports.
|
476
|
+
*/
|
477
|
+
LemmyWebsocket.prototype.listPrivateMessageReports = function (form) {
|
478
|
+
return wrapper(others_1.UserOperation.ListPrivateMessageReports, form);
|
467
479
|
};
|
468
480
|
/**
|
469
481
|
* Block a person.
|
@@ -477,11 +489,47 @@ var LemmyWebsocket = /** @class */ (function () {
|
|
477
489
|
LemmyWebsocket.prototype.blockCommunity = function (form) {
|
478
490
|
return wrapper(others_1.UserOperation.BlockCommunity, form);
|
479
491
|
};
|
492
|
+
/**
|
493
|
+
* Purge / Delete a person from the database.
|
494
|
+
*/
|
495
|
+
LemmyWebsocket.prototype.purgePerson = function (form) {
|
496
|
+
return wrapper(others_1.UserOperation.PurgePerson, form);
|
497
|
+
};
|
498
|
+
/**
|
499
|
+
* Purge / Delete a community from the database.
|
500
|
+
*/
|
501
|
+
LemmyWebsocket.prototype.purgeCommunity = function (form) {
|
502
|
+
return wrapper(others_1.UserOperation.PurgeCommunity, form);
|
503
|
+
};
|
504
|
+
/**
|
505
|
+
* Purge / Delete a post from the database.
|
506
|
+
*/
|
507
|
+
LemmyWebsocket.prototype.purgePost = function (form) {
|
508
|
+
return wrapper(others_1.UserOperation.PurgePost, form);
|
509
|
+
};
|
510
|
+
/**
|
511
|
+
* Purge / Delete a comment from the database.
|
512
|
+
*/
|
513
|
+
LemmyWebsocket.prototype.purgeComment = function (form) {
|
514
|
+
return wrapper(others_1.UserOperation.PurgeComment, form);
|
515
|
+
};
|
480
516
|
return LemmyWebsocket;
|
481
517
|
}());
|
482
518
|
exports.LemmyWebsocket = LemmyWebsocket;
|
483
519
|
function wrapper(op, data) {
|
484
|
-
var send = { op: others_1.UserOperation[op], data: data };
|
485
|
-
|
486
|
-
|
520
|
+
var send = (0, class_transformer_1.serialize)({ op: others_1.UserOperation[op], data: data });
|
521
|
+
return send;
|
522
|
+
}
|
523
|
+
function wsUserOp(msg) {
|
524
|
+
var opStr = msg.op;
|
525
|
+
return others_1.UserOperation[opStr];
|
526
|
+
}
|
527
|
+
exports.wsUserOp = wsUserOp;
|
528
|
+
/**
|
529
|
+
* Converts a websocket string response to a usable result
|
530
|
+
*/
|
531
|
+
function wsJsonToRes(msg, responseClass) {
|
532
|
+
// Have to deserialize the response again into the correct class
|
533
|
+
return (0, class_transformer_1.deserialize)(responseClass, (0, class_transformer_1.serialize)(msg.data));
|
487
534
|
}
|
535
|
+
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
|
+
"version": "0.17.0-rc.50",
|
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
|
-
"@
|
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.
|
22
|
-
"@typescript-eslint/parser": "^5.
|
23
|
-
"
|
24
|
-
"eslint
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
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": "^
|
31
|
-
"prettier-plugin-packagejson": "^2.2.
|
32
|
-
"
|
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.
|
38
|
+
"typescript": "^4.7.4"
|
36
39
|
},
|
37
40
|
"types": "./dist/index.d.ts",
|
38
41
|
"lint-staged": {
|