lemmy-js-client 0.18.0-rc.1 → 0.18.0-rc.2
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.
- package/README.md +6 -19
- package/dist/http.d.ts +6 -2
- package/dist/http.js +12 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -3
- package/dist/types/SortType.d.ts +1 -1
- package/dist/types/others.d.ts +0 -92
- package/dist/types/others.js +1 -94
- package/package.json +1 -1
- package/dist/websocket.d.ts +0 -459
- package/dist/websocket.js +0 -563
package/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
# lemmy-js-client
|
11
11
|
|
12
|
-
A javascript / typescript http
|
12
|
+
A javascript / typescript http client and type system for [Lemmy](https://github.com/LemmyNet/lemmy).
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -17,32 +17,19 @@ A javascript / typescript http and websocket client and type system for [Lemmy](
|
|
17
17
|
|
18
18
|
## Usage
|
19
19
|
|
20
|
-
### Websocket Client
|
21
|
-
|
22
|
-
[LemmyWebsocket docs](https://join-lemmy.org/api/classes/LemmyWebsocket.html)
|
23
|
-
|
24
|
-
```ts
|
25
|
-
import { Login, LemmyWebsocket } from "lemmy-js-client";
|
26
|
-
|
27
|
-
let client: LemmyWebsocket = new LemmyWebsocket();
|
28
|
-
|
29
|
-
let form: Login = {
|
30
|
-
username_or_email: "my_email@email.tld",
|
31
|
-
password: "my_pass",
|
32
|
-
};
|
33
|
-
|
34
|
-
this.ws.send(client.login(form));
|
35
|
-
```
|
36
|
-
|
37
20
|
### HTTP Client
|
38
21
|
|
39
22
|
[LemmyHttp docs](https://join-lemmy.org/api/classes/LemmyHttp.html)
|
40
23
|
|
41
24
|
```ts
|
42
|
-
import { LemmyHttp } from 'lemmy-js-client';
|
25
|
+
import { LemmyHttp, Login } from 'lemmy-js-client';
|
43
26
|
|
44
27
|
let baseUrl = 'https://lemmy.ml';
|
45
28
|
let client: LemmyHttp = new LemmyHttp(baseUrl, headers?);
|
29
|
+
let loginForm: Login = {
|
30
|
+
username_or_email: "my_name",
|
31
|
+
password: "my_pass",
|
32
|
+
};
|
46
33
|
let jwt = await client.login(loginForm).jwt;
|
47
34
|
```
|
48
35
|
|
package/dist/http.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import fetch from "cross-fetch";
|
1
2
|
import { AddAdmin } from "./types/AddAdmin";
|
2
3
|
import { AddAdminResponse } from "./types/AddAdminResponse";
|
3
4
|
import { AddModToCommunity } from "./types/AddModToCommunity";
|
@@ -139,8 +140,11 @@ export declare class LemmyHttp {
|
|
139
140
|
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
|
140
141
|
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
141
142
|
*/
|
142
|
-
constructor(baseUrl: string,
|
143
|
-
|
143
|
+
constructor(baseUrl: string, options?: {
|
144
|
+
fetchFunction: typeof fetch;
|
145
|
+
headers?: {
|
146
|
+
[key: string]: string;
|
147
|
+
};
|
144
148
|
});
|
145
149
|
/**
|
146
150
|
* Gets the site, and your user data.
|
package/dist/http.js
CHANGED
@@ -22,7 +22,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
24
24
|
};
|
25
|
-
var _LemmyHttp_instances, _LemmyHttp_apiUrl, _LemmyHttp_headers, _LemmyHttp_pictrsUrl, _LemmyHttp_buildFullUrl, _LemmyHttp_wrapper;
|
25
|
+
var _LemmyHttp_instances, _LemmyHttp_apiUrl, _LemmyHttp_headers, _LemmyHttp_pictrsUrl, _LemmyHttp_fetchFunction, _LemmyHttp_buildFullUrl, _LemmyHttp_wrapper;
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
27
27
|
exports.LemmyHttp = void 0;
|
28
28
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
@@ -43,15 +43,19 @@ class LemmyHttp {
|
|
43
43
|
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
|
44
44
|
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
45
45
|
*/
|
46
|
-
constructor(baseUrl,
|
46
|
+
constructor(baseUrl, options) {
|
47
47
|
_LemmyHttp_instances.add(this);
|
48
48
|
_LemmyHttp_apiUrl.set(this, void 0);
|
49
49
|
_LemmyHttp_headers.set(this, {});
|
50
50
|
_LemmyHttp_pictrsUrl.set(this, void 0);
|
51
|
+
_LemmyHttp_fetchFunction.set(this, cross_fetch_1.default);
|
51
52
|
__classPrivateFieldSet(this, _LemmyHttp_apiUrl, `${baseUrl.replace(/\/+$/, "")}/api/${others_1.VERSION}`, "f");
|
52
53
|
__classPrivateFieldSet(this, _LemmyHttp_pictrsUrl, `${baseUrl}/pictrs/image`, "f");
|
53
|
-
if (headers) {
|
54
|
-
__classPrivateFieldSet(this, _LemmyHttp_headers, headers, "f");
|
54
|
+
if (options === null || options === void 0 ? void 0 : options.headers) {
|
55
|
+
__classPrivateFieldSet(this, _LemmyHttp_headers, options.headers, "f");
|
56
|
+
}
|
57
|
+
if (options === null || options === void 0 ? void 0 : options.fetchFunction) {
|
58
|
+
__classPrivateFieldSet(this, _LemmyHttp_fetchFunction, options.fetchFunction, "f");
|
55
59
|
}
|
56
60
|
}
|
57
61
|
/**
|
@@ -757,7 +761,7 @@ class LemmyHttp {
|
|
757
761
|
}
|
758
762
|
let url = undefined;
|
759
763
|
let delete_url = undefined;
|
760
|
-
const response = yield (
|
764
|
+
const response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_pictrsUrl, "f"), {
|
761
765
|
method: HttpType.Post,
|
762
766
|
body: formData,
|
763
767
|
headers: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")), headers),
|
@@ -774,7 +778,7 @@ class LemmyHttp {
|
|
774
778
|
}
|
775
779
|
}
|
776
780
|
exports.LemmyHttp = LemmyHttp;
|
777
|
-
_LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHttp_pictrsUrl = new WeakMap(), _LemmyHttp_instances = new WeakSet(), _LemmyHttp_buildFullUrl = function _LemmyHttp_buildFullUrl(endpoint) {
|
781
|
+
_LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHttp_pictrsUrl = new WeakMap(), _LemmyHttp_fetchFunction = new WeakMap(), _LemmyHttp_instances = new WeakSet(), _LemmyHttp_buildFullUrl = function _LemmyHttp_buildFullUrl(endpoint) {
|
778
782
|
return `${__classPrivateFieldGet(this, _LemmyHttp_apiUrl, "f")}${endpoint}`;
|
779
783
|
}, _LemmyHttp_wrapper = function _LemmyHttp_wrapper(type_, endpoint, form) {
|
780
784
|
var _a;
|
@@ -782,13 +786,13 @@ _LemmyHttp_apiUrl = new WeakMap(), _LemmyHttp_headers = new WeakMap(), _LemmyHtt
|
|
782
786
|
let response;
|
783
787
|
if (type_ === HttpType.Get) {
|
784
788
|
const getUrl = `${__classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, endpoint)}?${encodeGetParams(form)}`;
|
785
|
-
response = yield (
|
789
|
+
response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, getUrl, {
|
786
790
|
method: HttpType.Get,
|
787
791
|
headers: __classPrivateFieldGet(this, _LemmyHttp_headers, "f"),
|
788
792
|
});
|
789
793
|
}
|
790
794
|
else {
|
791
|
-
response = yield (
|
795
|
+
response = yield __classPrivateFieldGet(this, _LemmyHttp_fetchFunction, "f").call(this, __classPrivateFieldGet(this, _LemmyHttp_instances, "m", _LemmyHttp_buildFullUrl).call(this, endpoint), {
|
792
796
|
method: type_,
|
793
797
|
headers: Object.assign({ "Content-Type": "application/json" }, __classPrivateFieldGet(this, _LemmyHttp_headers, "f")),
|
794
798
|
body: JSON.stringify(form),
|
package/dist/index.d.ts
CHANGED
@@ -246,4 +246,4 @@ export { UserJoin } from "./types/UserJoin";
|
|
246
246
|
export { UserJoinResponse } from "./types/UserJoinResponse";
|
247
247
|
export { VerifyEmail } from "./types/VerifyEmail";
|
248
248
|
export { VerifyEmailResponse } from "./types/VerifyEmailResponse";
|
249
|
-
export { ImageFile, UploadImage, UploadImageResponse
|
249
|
+
export { ImageFile, UploadImage, UploadImageResponse } from "./types/others";
|
package/dist/index.js
CHANGED
@@ -14,7 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
exports.UserOperation = void 0;
|
18
17
|
__exportStar(require("./http"), exports);
|
19
|
-
var others_1 = require("./types/others");
|
20
|
-
Object.defineProperty(exports, "UserOperation", { enumerable: true, get: function () { return others_1.UserOperation; } });
|
package/dist/types/SortType.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export type SortType = "Active" | "Hot" | "New" | "Old" | "TopDay" | "TopWeek" | "TopMonth" | "TopYear" | "TopAll" | "MostComments" | "NewComments";
|
1
|
+
export type SortType = "Active" | "Hot" | "New" | "Old" | "TopDay" | "TopWeek" | "TopMonth" | "TopYear" | "TopAll" | "MostComments" | "NewComments" | "TopHour" | "TopSixHour" | "TopTwelveHour";
|
package/dist/types/others.d.ts
CHANGED
@@ -1,97 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
export declare const VERSION = "v3";
|
3
|
-
/**
|
4
|
-
* All of the websocket operations available.
|
5
|
-
*/
|
6
|
-
export declare enum UserOperation {
|
7
|
-
Login = 0,
|
8
|
-
Register = 1,
|
9
|
-
GetCaptcha = 2,
|
10
|
-
CreateCommunity = 3,
|
11
|
-
CreatePost = 4,
|
12
|
-
ListCommunities = 5,
|
13
|
-
GetPost = 6,
|
14
|
-
GetCommunity = 7,
|
15
|
-
CreateComment = 8,
|
16
|
-
EditComment = 9,
|
17
|
-
DeleteComment = 10,
|
18
|
-
RemoveComment = 11,
|
19
|
-
SaveComment = 12,
|
20
|
-
CreateCommentLike = 13,
|
21
|
-
GetPosts = 14,
|
22
|
-
CreatePostLike = 15,
|
23
|
-
EditPost = 16,
|
24
|
-
DeletePost = 17,
|
25
|
-
RemovePost = 18,
|
26
|
-
LockPost = 19,
|
27
|
-
FeaturePost = 20,
|
28
|
-
MarkPostAsRead = 21,
|
29
|
-
SavePost = 22,
|
30
|
-
EditCommunity = 23,
|
31
|
-
DeleteCommunity = 24,
|
32
|
-
RemoveCommunity = 25,
|
33
|
-
FollowCommunity = 26,
|
34
|
-
GetPersonDetails = 27,
|
35
|
-
GetReplies = 28,
|
36
|
-
GetPersonMentions = 29,
|
37
|
-
MarkPersonMentionAsRead = 30,
|
38
|
-
MarkCommentReplyAsRead = 31,
|
39
|
-
GetModlog = 32,
|
40
|
-
BanFromCommunity = 33,
|
41
|
-
AddModToCommunity = 34,
|
42
|
-
CreateSite = 35,
|
43
|
-
EditSite = 36,
|
44
|
-
GetSite = 37,
|
45
|
-
AddAdmin = 38,
|
46
|
-
GetUnreadRegistrationApplicationCount = 39,
|
47
|
-
ListRegistrationApplications = 40,
|
48
|
-
ApproveRegistrationApplication = 41,
|
49
|
-
BanPerson = 42,
|
50
|
-
GetBannedPersons = 43,
|
51
|
-
Search = 44,
|
52
|
-
ResolveObject = 45,
|
53
|
-
MarkAllAsRead = 46,
|
54
|
-
SaveUserSettings = 47,
|
55
|
-
TransferCommunity = 48,
|
56
|
-
LeaveAdmin = 49,
|
57
|
-
DeleteAccount = 50,
|
58
|
-
PasswordReset = 51,
|
59
|
-
PasswordChangeAfterReset = 52,
|
60
|
-
CreatePrivateMessage = 53,
|
61
|
-
EditPrivateMessage = 54,
|
62
|
-
DeletePrivateMessage = 55,
|
63
|
-
MarkPrivateMessageAsRead = 56,
|
64
|
-
CreatePrivateMessageReport = 57,
|
65
|
-
ResolvePrivateMessageReport = 58,
|
66
|
-
ListPrivateMessageReports = 59,
|
67
|
-
GetPrivateMessages = 60,
|
68
|
-
UserJoin = 61,
|
69
|
-
GetComments = 62,
|
70
|
-
GetComment = 63,
|
71
|
-
PostJoin = 64,
|
72
|
-
CommunityJoin = 65,
|
73
|
-
ChangePassword = 66,
|
74
|
-
GetSiteMetadata = 67,
|
75
|
-
BlockCommunity = 68,
|
76
|
-
BlockPerson = 69,
|
77
|
-
PurgePerson = 70,
|
78
|
-
PurgeCommunity = 71,
|
79
|
-
PurgePost = 72,
|
80
|
-
PurgeComment = 73,
|
81
|
-
CreateCommentReport = 74,
|
82
|
-
ResolveCommentReport = 75,
|
83
|
-
ListCommentReports = 76,
|
84
|
-
CreatePostReport = 77,
|
85
|
-
ResolvePostReport = 78,
|
86
|
-
ListPostReports = 79,
|
87
|
-
GetReportCount = 80,
|
88
|
-
GetUnreadCount = 81,
|
89
|
-
VerifyEmail = 82,
|
90
|
-
CreateCustomEmoji = 83,
|
91
|
-
EditCustomEmoji = 84,
|
92
|
-
DeleteCustomEmoji = 85,
|
93
|
-
GetFederatedInstances = 86
|
94
|
-
}
|
95
3
|
export interface UploadImage {
|
96
4
|
image: File | Buffer;
|
97
5
|
/**
|
package/dist/types/others.js
CHANGED
@@ -1,97 +1,4 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.VERSION = void 0;
|
4
4
|
exports.VERSION = "v3";
|
5
|
-
/**
|
6
|
-
* All of the websocket operations available.
|
7
|
-
*/
|
8
|
-
var UserOperation;
|
9
|
-
(function (UserOperation) {
|
10
|
-
UserOperation[UserOperation["Login"] = 0] = "Login";
|
11
|
-
UserOperation[UserOperation["Register"] = 1] = "Register";
|
12
|
-
UserOperation[UserOperation["GetCaptcha"] = 2] = "GetCaptcha";
|
13
|
-
UserOperation[UserOperation["CreateCommunity"] = 3] = "CreateCommunity";
|
14
|
-
UserOperation[UserOperation["CreatePost"] = 4] = "CreatePost";
|
15
|
-
UserOperation[UserOperation["ListCommunities"] = 5] = "ListCommunities";
|
16
|
-
UserOperation[UserOperation["GetPost"] = 6] = "GetPost";
|
17
|
-
UserOperation[UserOperation["GetCommunity"] = 7] = "GetCommunity";
|
18
|
-
UserOperation[UserOperation["CreateComment"] = 8] = "CreateComment";
|
19
|
-
UserOperation[UserOperation["EditComment"] = 9] = "EditComment";
|
20
|
-
UserOperation[UserOperation["DeleteComment"] = 10] = "DeleteComment";
|
21
|
-
UserOperation[UserOperation["RemoveComment"] = 11] = "RemoveComment";
|
22
|
-
UserOperation[UserOperation["SaveComment"] = 12] = "SaveComment";
|
23
|
-
UserOperation[UserOperation["CreateCommentLike"] = 13] = "CreateCommentLike";
|
24
|
-
UserOperation[UserOperation["GetPosts"] = 14] = "GetPosts";
|
25
|
-
UserOperation[UserOperation["CreatePostLike"] = 15] = "CreatePostLike";
|
26
|
-
UserOperation[UserOperation["EditPost"] = 16] = "EditPost";
|
27
|
-
UserOperation[UserOperation["DeletePost"] = 17] = "DeletePost";
|
28
|
-
UserOperation[UserOperation["RemovePost"] = 18] = "RemovePost";
|
29
|
-
UserOperation[UserOperation["LockPost"] = 19] = "LockPost";
|
30
|
-
UserOperation[UserOperation["FeaturePost"] = 20] = "FeaturePost";
|
31
|
-
UserOperation[UserOperation["MarkPostAsRead"] = 21] = "MarkPostAsRead";
|
32
|
-
UserOperation[UserOperation["SavePost"] = 22] = "SavePost";
|
33
|
-
UserOperation[UserOperation["EditCommunity"] = 23] = "EditCommunity";
|
34
|
-
UserOperation[UserOperation["DeleteCommunity"] = 24] = "DeleteCommunity";
|
35
|
-
UserOperation[UserOperation["RemoveCommunity"] = 25] = "RemoveCommunity";
|
36
|
-
UserOperation[UserOperation["FollowCommunity"] = 26] = "FollowCommunity";
|
37
|
-
UserOperation[UserOperation["GetPersonDetails"] = 27] = "GetPersonDetails";
|
38
|
-
UserOperation[UserOperation["GetReplies"] = 28] = "GetReplies";
|
39
|
-
UserOperation[UserOperation["GetPersonMentions"] = 29] = "GetPersonMentions";
|
40
|
-
UserOperation[UserOperation["MarkPersonMentionAsRead"] = 30] = "MarkPersonMentionAsRead";
|
41
|
-
UserOperation[UserOperation["MarkCommentReplyAsRead"] = 31] = "MarkCommentReplyAsRead";
|
42
|
-
UserOperation[UserOperation["GetModlog"] = 32] = "GetModlog";
|
43
|
-
UserOperation[UserOperation["BanFromCommunity"] = 33] = "BanFromCommunity";
|
44
|
-
UserOperation[UserOperation["AddModToCommunity"] = 34] = "AddModToCommunity";
|
45
|
-
UserOperation[UserOperation["CreateSite"] = 35] = "CreateSite";
|
46
|
-
UserOperation[UserOperation["EditSite"] = 36] = "EditSite";
|
47
|
-
UserOperation[UserOperation["GetSite"] = 37] = "GetSite";
|
48
|
-
UserOperation[UserOperation["AddAdmin"] = 38] = "AddAdmin";
|
49
|
-
UserOperation[UserOperation["GetUnreadRegistrationApplicationCount"] = 39] = "GetUnreadRegistrationApplicationCount";
|
50
|
-
UserOperation[UserOperation["ListRegistrationApplications"] = 40] = "ListRegistrationApplications";
|
51
|
-
UserOperation[UserOperation["ApproveRegistrationApplication"] = 41] = "ApproveRegistrationApplication";
|
52
|
-
UserOperation[UserOperation["BanPerson"] = 42] = "BanPerson";
|
53
|
-
UserOperation[UserOperation["GetBannedPersons"] = 43] = "GetBannedPersons";
|
54
|
-
UserOperation[UserOperation["Search"] = 44] = "Search";
|
55
|
-
UserOperation[UserOperation["ResolveObject"] = 45] = "ResolveObject";
|
56
|
-
UserOperation[UserOperation["MarkAllAsRead"] = 46] = "MarkAllAsRead";
|
57
|
-
UserOperation[UserOperation["SaveUserSettings"] = 47] = "SaveUserSettings";
|
58
|
-
UserOperation[UserOperation["TransferCommunity"] = 48] = "TransferCommunity";
|
59
|
-
UserOperation[UserOperation["LeaveAdmin"] = 49] = "LeaveAdmin";
|
60
|
-
UserOperation[UserOperation["DeleteAccount"] = 50] = "DeleteAccount";
|
61
|
-
UserOperation[UserOperation["PasswordReset"] = 51] = "PasswordReset";
|
62
|
-
UserOperation[UserOperation["PasswordChangeAfterReset"] = 52] = "PasswordChangeAfterReset";
|
63
|
-
UserOperation[UserOperation["CreatePrivateMessage"] = 53] = "CreatePrivateMessage";
|
64
|
-
UserOperation[UserOperation["EditPrivateMessage"] = 54] = "EditPrivateMessage";
|
65
|
-
UserOperation[UserOperation["DeletePrivateMessage"] = 55] = "DeletePrivateMessage";
|
66
|
-
UserOperation[UserOperation["MarkPrivateMessageAsRead"] = 56] = "MarkPrivateMessageAsRead";
|
67
|
-
UserOperation[UserOperation["CreatePrivateMessageReport"] = 57] = "CreatePrivateMessageReport";
|
68
|
-
UserOperation[UserOperation["ResolvePrivateMessageReport"] = 58] = "ResolvePrivateMessageReport";
|
69
|
-
UserOperation[UserOperation["ListPrivateMessageReports"] = 59] = "ListPrivateMessageReports";
|
70
|
-
UserOperation[UserOperation["GetPrivateMessages"] = 60] = "GetPrivateMessages";
|
71
|
-
UserOperation[UserOperation["UserJoin"] = 61] = "UserJoin";
|
72
|
-
UserOperation[UserOperation["GetComments"] = 62] = "GetComments";
|
73
|
-
UserOperation[UserOperation["GetComment"] = 63] = "GetComment";
|
74
|
-
UserOperation[UserOperation["PostJoin"] = 64] = "PostJoin";
|
75
|
-
UserOperation[UserOperation["CommunityJoin"] = 65] = "CommunityJoin";
|
76
|
-
UserOperation[UserOperation["ChangePassword"] = 66] = "ChangePassword";
|
77
|
-
UserOperation[UserOperation["GetSiteMetadata"] = 67] = "GetSiteMetadata";
|
78
|
-
UserOperation[UserOperation["BlockCommunity"] = 68] = "BlockCommunity";
|
79
|
-
UserOperation[UserOperation["BlockPerson"] = 69] = "BlockPerson";
|
80
|
-
UserOperation[UserOperation["PurgePerson"] = 70] = "PurgePerson";
|
81
|
-
UserOperation[UserOperation["PurgeCommunity"] = 71] = "PurgeCommunity";
|
82
|
-
UserOperation[UserOperation["PurgePost"] = 72] = "PurgePost";
|
83
|
-
UserOperation[UserOperation["PurgeComment"] = 73] = "PurgeComment";
|
84
|
-
UserOperation[UserOperation["CreateCommentReport"] = 74] = "CreateCommentReport";
|
85
|
-
UserOperation[UserOperation["ResolveCommentReport"] = 75] = "ResolveCommentReport";
|
86
|
-
UserOperation[UserOperation["ListCommentReports"] = 76] = "ListCommentReports";
|
87
|
-
UserOperation[UserOperation["CreatePostReport"] = 77] = "CreatePostReport";
|
88
|
-
UserOperation[UserOperation["ResolvePostReport"] = 78] = "ResolvePostReport";
|
89
|
-
UserOperation[UserOperation["ListPostReports"] = 79] = "ListPostReports";
|
90
|
-
UserOperation[UserOperation["GetReportCount"] = 80] = "GetReportCount";
|
91
|
-
UserOperation[UserOperation["GetUnreadCount"] = 81] = "GetUnreadCount";
|
92
|
-
UserOperation[UserOperation["VerifyEmail"] = 82] = "VerifyEmail";
|
93
|
-
UserOperation[UserOperation["CreateCustomEmoji"] = 83] = "CreateCustomEmoji";
|
94
|
-
UserOperation[UserOperation["EditCustomEmoji"] = 84] = "EditCustomEmoji";
|
95
|
-
UserOperation[UserOperation["DeleteCustomEmoji"] = 85] = "DeleteCustomEmoji";
|
96
|
-
UserOperation[UserOperation["GetFederatedInstances"] = 86] = "GetFederatedInstances";
|
97
|
-
})(UserOperation = exports.UserOperation || (exports.UserOperation = {}));
|
package/package.json
CHANGED
package/dist/websocket.d.ts
DELETED
@@ -1,459 +0,0 @@
|
|
1
|
-
import { AddAdmin } from "./types/AddAdmin";
|
2
|
-
import { AddModToCommunity } from "./types/AddModToCommunity";
|
3
|
-
import { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication";
|
4
|
-
import { BanFromCommunity } from "./types/BanFromCommunity";
|
5
|
-
import { BanPerson } from "./types/BanPerson";
|
6
|
-
import { BlockCommunity } from "./types/BlockCommunity";
|
7
|
-
import { BlockPerson } from "./types/BlockPerson";
|
8
|
-
import { ChangePassword } from "./types/ChangePassword";
|
9
|
-
import { CommunityJoin } from "./types/CommunityJoin";
|
10
|
-
import { CreateComment } from "./types/CreateComment";
|
11
|
-
import { CreateCommentLike } from "./types/CreateCommentLike";
|
12
|
-
import { CreateCommentReport } from "./types/CreateCommentReport";
|
13
|
-
import { CreateCommunity } from "./types/CreateCommunity";
|
14
|
-
import { CreateCustomEmoji } from "./types/CreateCustomEmoji";
|
15
|
-
import { CreatePost } from "./types/CreatePost";
|
16
|
-
import { CreatePostLike } from "./types/CreatePostLike";
|
17
|
-
import { CreatePostReport } from "./types/CreatePostReport";
|
18
|
-
import { CreatePrivateMessage } from "./types/CreatePrivateMessage";
|
19
|
-
import { CreatePrivateMessageReport } from "./types/CreatePrivateMessageReport";
|
20
|
-
import { CreateSite } from "./types/CreateSite";
|
21
|
-
import { DeleteAccount } from "./types/DeleteAccount";
|
22
|
-
import { DeleteComment } from "./types/DeleteComment";
|
23
|
-
import { DeleteCommunity } from "./types/DeleteCommunity";
|
24
|
-
import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
|
25
|
-
import { DeletePost } from "./types/DeletePost";
|
26
|
-
import { DeletePrivateMessage } from "./types/DeletePrivateMessage";
|
27
|
-
import { EditComment } from "./types/EditComment";
|
28
|
-
import { EditCommunity } from "./types/EditCommunity";
|
29
|
-
import { EditCustomEmoji } from "./types/EditCustomEmoji";
|
30
|
-
import { EditPost } from "./types/EditPost";
|
31
|
-
import { EditPrivateMessage } from "./types/EditPrivateMessage";
|
32
|
-
import { EditSite } from "./types/EditSite";
|
33
|
-
import { FeaturePost } from "./types/FeaturePost";
|
34
|
-
import { FollowCommunity } from "./types/FollowCommunity";
|
35
|
-
import { GetBannedPersons } from "./types/GetBannedPersons";
|
36
|
-
import { GetCaptcha } from "./types/GetCaptcha";
|
37
|
-
import { GetComment } from "./types/GetComment";
|
38
|
-
import { GetComments } from "./types/GetComments";
|
39
|
-
import { GetCommunity } from "./types/GetCommunity";
|
40
|
-
import { GetFederatedInstances } from "./types/GetFederatedInstances";
|
41
|
-
import { GetModlog } from "./types/GetModlog";
|
42
|
-
import { GetPersonDetails } from "./types/GetPersonDetails";
|
43
|
-
import { GetPersonMentions } from "./types/GetPersonMentions";
|
44
|
-
import { GetPost } from "./types/GetPost";
|
45
|
-
import { GetPosts } from "./types/GetPosts";
|
46
|
-
import { GetPrivateMessages } from "./types/GetPrivateMessages";
|
47
|
-
import { GetReplies } from "./types/GetReplies";
|
48
|
-
import { GetReportCount } from "./types/GetReportCount";
|
49
|
-
import { GetSite } from "./types/GetSite";
|
50
|
-
import { GetSiteMetadata } from "./types/GetSiteMetadata";
|
51
|
-
import { GetUnreadCount } from "./types/GetUnreadCount";
|
52
|
-
import { GetUnreadRegistrationApplicationCount } from "./types/GetUnreadRegistrationApplicationCount";
|
53
|
-
import { LeaveAdmin } from "./types/LeaveAdmin";
|
54
|
-
import { ListCommentReports } from "./types/ListCommentReports";
|
55
|
-
import { ListCommunities } from "./types/ListCommunities";
|
56
|
-
import { ListPostReports } from "./types/ListPostReports";
|
57
|
-
import { ListPrivateMessageReports } from "./types/ListPrivateMessageReports";
|
58
|
-
import { ListRegistrationApplications } from "./types/ListRegistrationApplications";
|
59
|
-
import { LockPost } from "./types/LockPost";
|
60
|
-
import { Login } from "./types/Login";
|
61
|
-
import { MarkAllAsRead } from "./types/MarkAllAsRead";
|
62
|
-
import { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
|
63
|
-
import { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
|
64
|
-
import { MarkPostAsRead } from "./types/MarkPostAsRead";
|
65
|
-
import { MarkPrivateMessageAsRead } from "./types/MarkPrivateMessageAsRead";
|
66
|
-
import { UserOperation } from "./types/others";
|
67
|
-
import { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset";
|
68
|
-
import { PasswordReset } from "./types/PasswordReset";
|
69
|
-
import { PostJoin } from "./types/PostJoin";
|
70
|
-
import { PurgeComment } from "./types/PurgeComment";
|
71
|
-
import { PurgeCommunity } from "./types/PurgeCommunity";
|
72
|
-
import { PurgePerson } from "./types/PurgePerson";
|
73
|
-
import { PurgePost } from "./types/PurgePost";
|
74
|
-
import { Register } from "./types/Register";
|
75
|
-
import { RemoveComment } from "./types/RemoveComment";
|
76
|
-
import { RemoveCommunity } from "./types/RemoveCommunity";
|
77
|
-
import { RemovePost } from "./types/RemovePost";
|
78
|
-
import { ResolveCommentReport } from "./types/ResolveCommentReport";
|
79
|
-
import { ResolveObject } from "./types/ResolveObject";
|
80
|
-
import { ResolvePostReport } from "./types/ResolvePostReport";
|
81
|
-
import { ResolvePrivateMessageReport } from "./types/ResolvePrivateMessageReport";
|
82
|
-
import { SaveComment } from "./types/SaveComment";
|
83
|
-
import { SavePost } from "./types/SavePost";
|
84
|
-
import { SaveUserSettings } from "./types/SaveUserSettings";
|
85
|
-
import { Search } from "./types/Search";
|
86
|
-
import { TransferCommunity } from "./types/TransferCommunity";
|
87
|
-
import { UserJoin } from "./types/UserJoin";
|
88
|
-
import { VerifyEmail } from "./types/VerifyEmail";
|
89
|
-
/**
|
90
|
-
* Helps build lemmy websocket message requests, that you can use in your Websocket sends.
|
91
|
-
*
|
92
|
-
* You'll receive back a [[WebSocketResponse]].
|
93
|
-
*
|
94
|
-
* The return types for these are given in [[LemmyHttp]]
|
95
|
-
*/
|
96
|
-
export declare class LemmyWebsocket {
|
97
|
-
constructor();
|
98
|
-
/**
|
99
|
-
* Log into lemmy.
|
100
|
-
*/
|
101
|
-
login(form: Login): string;
|
102
|
-
/**
|
103
|
-
* A websocket join for your user.
|
104
|
-
*
|
105
|
-
* Allows your user to receive private messages and notifications.
|
106
|
-
*/
|
107
|
-
userJoin(form: UserJoin): string;
|
108
|
-
/**
|
109
|
-
* A websocket join for the current post room.
|
110
|
-
*
|
111
|
-
* Allows your user to receive new comments and updates for that post.
|
112
|
-
*/
|
113
|
-
postJoin(form: PostJoin): string;
|
114
|
-
/**
|
115
|
-
* A websocket join for a given community.
|
116
|
-
*
|
117
|
-
* Allows your user to receive community updates.
|
118
|
-
*
|
119
|
-
* Note: community_id: 0, is your front page.
|
120
|
-
*/
|
121
|
-
communityJoin(form: CommunityJoin): string;
|
122
|
-
/**
|
123
|
-
* Register a new user.
|
124
|
-
*/
|
125
|
-
register(register: Register): string;
|
126
|
-
/**
|
127
|
-
* Fetch a Captcha.
|
128
|
-
*/
|
129
|
-
getCaptcha(form: GetCaptcha): string;
|
130
|
-
/**
|
131
|
-
* Create a new community.
|
132
|
-
*/
|
133
|
-
createCommunity(form: CreateCommunity): string;
|
134
|
-
/**
|
135
|
-
* Edit a community.
|
136
|
-
*/
|
137
|
-
editCommunity(form: EditCommunity): string;
|
138
|
-
/**
|
139
|
-
* Delete a community.
|
140
|
-
*/
|
141
|
-
deleteCommunity(form: DeleteCommunity): string;
|
142
|
-
/**
|
143
|
-
* A moderator remove for a community.
|
144
|
-
*/
|
145
|
-
removeCommunity(form: RemoveCommunity): string;
|
146
|
-
/**
|
147
|
-
* Follow / subscribe to a community.
|
148
|
-
*/
|
149
|
-
followCommunity(form: FollowCommunity): string;
|
150
|
-
/**
|
151
|
-
* List communities, with various filters.
|
152
|
-
*/
|
153
|
-
listCommunities(form: ListCommunities): string;
|
154
|
-
/**
|
155
|
-
* Create a post.
|
156
|
-
*/
|
157
|
-
createPost(form: CreatePost): string;
|
158
|
-
/**
|
159
|
-
* Get / fetch a post.
|
160
|
-
*/
|
161
|
-
getPost(form: GetPost): string;
|
162
|
-
/**
|
163
|
-
* Get / fetch a community.
|
164
|
-
*/
|
165
|
-
getCommunity(form: GetCommunity): string;
|
166
|
-
/**
|
167
|
-
* Create a comment.
|
168
|
-
*/
|
169
|
-
createComment(form: CreateComment): string;
|
170
|
-
/**
|
171
|
-
* Edit a comment.
|
172
|
-
*/
|
173
|
-
editComment(form: EditComment): string;
|
174
|
-
/**
|
175
|
-
* Delete a comment.
|
176
|
-
*/
|
177
|
-
deleteComment(form: DeleteComment): string;
|
178
|
-
/**
|
179
|
-
* A moderator remove for a comment.
|
180
|
-
*/
|
181
|
-
removeComment(form: RemoveComment): string;
|
182
|
-
/**
|
183
|
-
* Mark a comment as read.
|
184
|
-
*/
|
185
|
-
markCommentReplyAsRead(form: MarkCommentReplyAsRead): string;
|
186
|
-
/**
|
187
|
-
* Like / vote on a comment.
|
188
|
-
*/
|
189
|
-
likeComment(form: CreateCommentLike): string;
|
190
|
-
/**
|
191
|
-
* Save a comment.
|
192
|
-
*/
|
193
|
-
saveComment(form: SaveComment): string;
|
194
|
-
/**
|
195
|
-
* Report a comment.
|
196
|
-
*/
|
197
|
-
createCommentReport(form: CreateCommentReport): string;
|
198
|
-
/**
|
199
|
-
* Resolve a comment report. Only a mod can do this.
|
200
|
-
*/
|
201
|
-
resolveCommentReport(form: ResolveCommentReport): string;
|
202
|
-
/**
|
203
|
-
* List comment reports.
|
204
|
-
*/
|
205
|
-
listCommentReports(form: ListCommentReports): string;
|
206
|
-
/**
|
207
|
-
* Get / fetch posts, with various filters.
|
208
|
-
*/
|
209
|
-
getPosts(form: GetPosts): string;
|
210
|
-
/**
|
211
|
-
* Get / fetch comments.
|
212
|
-
*/
|
213
|
-
getComments(form: GetComments): string;
|
214
|
-
/**
|
215
|
-
* Get / fetch comment.
|
216
|
-
*/
|
217
|
-
getComment(form: GetComment): string;
|
218
|
-
/**
|
219
|
-
* Like / vote on a post.
|
220
|
-
*/
|
221
|
-
likePost(form: CreatePostLike): string;
|
222
|
-
/**
|
223
|
-
* Edit a post.
|
224
|
-
*/
|
225
|
-
editPost(form: EditPost): string;
|
226
|
-
/**
|
227
|
-
* Delete a post.
|
228
|
-
*/
|
229
|
-
deletePost(form: DeletePost): string;
|
230
|
-
/**
|
231
|
-
* A moderator remove for a post.
|
232
|
-
*/
|
233
|
-
removePost(form: RemovePost): string;
|
234
|
-
/**
|
235
|
-
* A moderator can lock a post ( IE disable new comments ).
|
236
|
-
*/
|
237
|
-
lockPost(form: LockPost): string;
|
238
|
-
/**
|
239
|
-
* A moderator can feature a post ( IE stick it to the top of a community ).
|
240
|
-
*/
|
241
|
-
featurePost(form: FeaturePost): string;
|
242
|
-
/**
|
243
|
-
* Mark a post as read.
|
244
|
-
*/
|
245
|
-
markPostAsRead(form: MarkPostAsRead): string;
|
246
|
-
/**
|
247
|
-
* Save a post.
|
248
|
-
*/
|
249
|
-
savePost(form: SavePost): string;
|
250
|
-
/**
|
251
|
-
* Report a post.
|
252
|
-
*/
|
253
|
-
createPostReport(form: CreatePostReport): string;
|
254
|
-
/**
|
255
|
-
* Resolve a post report. Only a mod can do this.
|
256
|
-
*/
|
257
|
-
resolvePostReport(form: ResolvePostReport): string;
|
258
|
-
/**
|
259
|
-
* List post reports.
|
260
|
-
*/
|
261
|
-
listPostReports(form: ListPostReports): string;
|
262
|
-
/**
|
263
|
-
* Fetch metadata for any given site.
|
264
|
-
*/
|
265
|
-
getSiteMetadata(form: GetSiteMetadata): string;
|
266
|
-
/**
|
267
|
-
* Ban a user from a community.
|
268
|
-
*/
|
269
|
-
banFromCommunity(form: BanFromCommunity): string;
|
270
|
-
/**
|
271
|
-
* Add a moderator to your community.
|
272
|
-
*/
|
273
|
-
addModToCommunity(form: AddModToCommunity): string;
|
274
|
-
/**
|
275
|
-
* Transfer your community to an existing moderator.
|
276
|
-
*/
|
277
|
-
transferCommunity(form: TransferCommunity): string;
|
278
|
-
/**
|
279
|
-
* Leave the Site admins.
|
280
|
-
*/
|
281
|
-
leaveAdmin(form: LeaveAdmin): string;
|
282
|
-
/**
|
283
|
-
* Ban a person from your site.
|
284
|
-
*/
|
285
|
-
banPerson(form: BanPerson): string;
|
286
|
-
/**
|
287
|
-
* Get a list of banned users
|
288
|
-
*/
|
289
|
-
getBannedPersons(form: GetBannedPersons): string;
|
290
|
-
/**
|
291
|
-
* Add an admin to your site.
|
292
|
-
*/
|
293
|
-
addAdmin(form: AddAdmin): string;
|
294
|
-
/**
|
295
|
-
* Get the unread registration applications count.
|
296
|
-
*/
|
297
|
-
getUnreadRegistrationApplicationCount(form: GetUnreadRegistrationApplicationCount): string;
|
298
|
-
/**
|
299
|
-
* List the unread registration applications.
|
300
|
-
*/
|
301
|
-
listRegistrationApplications(form: ListRegistrationApplications): string;
|
302
|
-
/**
|
303
|
-
* Approve a registration application
|
304
|
-
*/
|
305
|
-
approveRegistrationApplication(form: ApproveRegistrationApplication): string;
|
306
|
-
/**
|
307
|
-
* Get the details for a person.
|
308
|
-
*/
|
309
|
-
getPersonDetails(form: GetPersonDetails): string;
|
310
|
-
/**
|
311
|
-
* Get comment replies.
|
312
|
-
*/
|
313
|
-
getReplies(form: GetReplies): string;
|
314
|
-
/**
|
315
|
-
* Get mentions for your user.
|
316
|
-
*/
|
317
|
-
getPersonMentions(form: GetPersonMentions): string;
|
318
|
-
/**
|
319
|
-
* Mark a person mention as read.
|
320
|
-
*/
|
321
|
-
markPersonMentionAsRead(form: MarkPersonMentionAsRead): string;
|
322
|
-
/**
|
323
|
-
* Get the modlog.
|
324
|
-
*/
|
325
|
-
getModlog(form: GetModlog): string;
|
326
|
-
/**
|
327
|
-
* Create your site.
|
328
|
-
*/
|
329
|
-
createSite(form: CreateSite): string;
|
330
|
-
/**
|
331
|
-
* Edit your site.
|
332
|
-
*/
|
333
|
-
editSite(form: EditSite): string;
|
334
|
-
/**
|
335
|
-
* Gets the site, and your user data.
|
336
|
-
*/
|
337
|
-
getSite(form: GetSite): string;
|
338
|
-
/**
|
339
|
-
* Search lemmy.
|
340
|
-
*/
|
341
|
-
search(form: Search): string;
|
342
|
-
/**
|
343
|
-
* Fetch a non-local / federated object.
|
344
|
-
*/
|
345
|
-
resolveObject(form: ResolveObject): string;
|
346
|
-
/**
|
347
|
-
* Mark all replies as read.
|
348
|
-
*/
|
349
|
-
markAllAsRead(form: MarkAllAsRead): string;
|
350
|
-
/**
|
351
|
-
* Save your user settings.
|
352
|
-
*/
|
353
|
-
saveUserSettings(form: SaveUserSettings): string;
|
354
|
-
/**
|
355
|
-
* Change your user password.
|
356
|
-
*/
|
357
|
-
changePassword(form: ChangePassword): string;
|
358
|
-
/**
|
359
|
-
* Get counts for your reports
|
360
|
-
*/
|
361
|
-
getReportCount(form: GetReportCount): string;
|
362
|
-
/**
|
363
|
-
* Get your unread counts
|
364
|
-
*/
|
365
|
-
getUnreadCount(form: GetUnreadCount): string;
|
366
|
-
/**
|
367
|
-
* Verify your email
|
368
|
-
*/
|
369
|
-
verifyEmail(form: VerifyEmail): string;
|
370
|
-
/**
|
371
|
-
* Delete your account.
|
372
|
-
*/
|
373
|
-
deleteAccount(form: DeleteAccount): string;
|
374
|
-
/**
|
375
|
-
* Reset your password.
|
376
|
-
*/
|
377
|
-
passwordReset(form: PasswordReset): string;
|
378
|
-
/**
|
379
|
-
* Change your password from an email / token based reset.
|
380
|
-
*/
|
381
|
-
passwordChange(form: PasswordChangeAfterReset): string;
|
382
|
-
/**
|
383
|
-
* Create a private message.
|
384
|
-
*/
|
385
|
-
createPrivateMessage(form: CreatePrivateMessage): string;
|
386
|
-
/**
|
387
|
-
* Edit a private message.
|
388
|
-
*/
|
389
|
-
editPrivateMessage(form: EditPrivateMessage): string;
|
390
|
-
/**
|
391
|
-
* Delete a private message.
|
392
|
-
*/
|
393
|
-
deletePrivateMessage(form: DeletePrivateMessage): string;
|
394
|
-
/**
|
395
|
-
* Mark a private message as read.
|
396
|
-
*/
|
397
|
-
markPrivateMessageAsRead(form: MarkPrivateMessageAsRead): string;
|
398
|
-
/**
|
399
|
-
* Get / fetch private messages.
|
400
|
-
*/
|
401
|
-
getPrivateMessages(form: GetPrivateMessages): string;
|
402
|
-
/**
|
403
|
-
* Create a report for a private message.
|
404
|
-
*/
|
405
|
-
createPrivateMessageReport(form: CreatePrivateMessageReport): string;
|
406
|
-
/**
|
407
|
-
* Resolve a report for a private message.
|
408
|
-
*/
|
409
|
-
resolvePrivateMessageReport(form: ResolvePrivateMessageReport): string;
|
410
|
-
/**
|
411
|
-
* List private message reports.
|
412
|
-
*/
|
413
|
-
listPrivateMessageReports(form: ListPrivateMessageReports): string;
|
414
|
-
/**
|
415
|
-
* Block a person.
|
416
|
-
*/
|
417
|
-
blockPerson(form: BlockPerson): string;
|
418
|
-
/**
|
419
|
-
* Block a community.
|
420
|
-
*/
|
421
|
-
blockCommunity(form: BlockCommunity): string;
|
422
|
-
/**
|
423
|
-
* Purge / Delete a person from the database.
|
424
|
-
*/
|
425
|
-
purgePerson(form: PurgePerson): string;
|
426
|
-
/**
|
427
|
-
* Purge / Delete a community from the database.
|
428
|
-
*/
|
429
|
-
purgeCommunity(form: PurgeCommunity): string;
|
430
|
-
/**
|
431
|
-
* Purge / Delete a post from the database.
|
432
|
-
*/
|
433
|
-
purgePost(form: PurgePost): string;
|
434
|
-
/**
|
435
|
-
* Purge / Delete a comment from the database.
|
436
|
-
*/
|
437
|
-
purgeComment(form: PurgeComment): string;
|
438
|
-
/**
|
439
|
-
* Create a custom emoji
|
440
|
-
*/
|
441
|
-
createCustomEmoji(form: CreateCustomEmoji): string;
|
442
|
-
/**
|
443
|
-
* Edit a custom emoji
|
444
|
-
*/
|
445
|
-
editCustomEmoji(form: EditCustomEmoji): string;
|
446
|
-
/**
|
447
|
-
* Delete a custom emoji
|
448
|
-
*/
|
449
|
-
deleteCustomEmoji(form: DeleteCustomEmoji): string;
|
450
|
-
/**
|
451
|
-
* Fetch federated instances.
|
452
|
-
*/
|
453
|
-
getFederatedInstances(form: GetFederatedInstances): string;
|
454
|
-
}
|
455
|
-
export declare function wsUserOp(msg: any): UserOperation;
|
456
|
-
/**
|
457
|
-
* Converts a websocket string response to a usable result
|
458
|
-
*/
|
459
|
-
export declare function wsJsonToRes<ResponseType>(msg: any): ResponseType;
|
package/dist/websocket.js
DELETED
@@ -1,563 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.wsJsonToRes = exports.wsUserOp = exports.LemmyWebsocket = void 0;
|
4
|
-
const others_1 = require("./types/others");
|
5
|
-
/**
|
6
|
-
* Helps build lemmy websocket message requests, that you can use in your Websocket sends.
|
7
|
-
*
|
8
|
-
* You'll receive back a [[WebSocketResponse]].
|
9
|
-
*
|
10
|
-
* The return types for these are given in [[LemmyHttp]]
|
11
|
-
*/
|
12
|
-
class LemmyWebsocket {
|
13
|
-
constructor() { }
|
14
|
-
/**
|
15
|
-
* Log into lemmy.
|
16
|
-
*/
|
17
|
-
login(form) {
|
18
|
-
return wrapper(others_1.UserOperation.Login, form);
|
19
|
-
}
|
20
|
-
/**
|
21
|
-
* A websocket join for your user.
|
22
|
-
*
|
23
|
-
* Allows your user to receive private messages and notifications.
|
24
|
-
*/
|
25
|
-
userJoin(form) {
|
26
|
-
return wrapper(others_1.UserOperation.UserJoin, form);
|
27
|
-
}
|
28
|
-
/**
|
29
|
-
* A websocket join for the current post room.
|
30
|
-
*
|
31
|
-
* Allows your user to receive new comments and updates for that post.
|
32
|
-
*/
|
33
|
-
postJoin(form) {
|
34
|
-
return wrapper(others_1.UserOperation.PostJoin, form);
|
35
|
-
}
|
36
|
-
/**
|
37
|
-
* A websocket join for a given community.
|
38
|
-
*
|
39
|
-
* Allows your user to receive community updates.
|
40
|
-
*
|
41
|
-
* Note: community_id: 0, is your front page.
|
42
|
-
*/
|
43
|
-
communityJoin(form) {
|
44
|
-
return wrapper(others_1.UserOperation.CommunityJoin, form);
|
45
|
-
}
|
46
|
-
/**
|
47
|
-
* Register a new user.
|
48
|
-
*/
|
49
|
-
register(register) {
|
50
|
-
return wrapper(others_1.UserOperation.Register, register);
|
51
|
-
}
|
52
|
-
/**
|
53
|
-
* Fetch a Captcha.
|
54
|
-
*/
|
55
|
-
getCaptcha(form) {
|
56
|
-
return wrapper(others_1.UserOperation.GetCaptcha, form);
|
57
|
-
}
|
58
|
-
/**
|
59
|
-
* Create a new community.
|
60
|
-
*/
|
61
|
-
createCommunity(form) {
|
62
|
-
return wrapper(others_1.UserOperation.CreateCommunity, form);
|
63
|
-
}
|
64
|
-
/**
|
65
|
-
* Edit a community.
|
66
|
-
*/
|
67
|
-
editCommunity(form) {
|
68
|
-
return wrapper(others_1.UserOperation.EditCommunity, form);
|
69
|
-
}
|
70
|
-
/**
|
71
|
-
* Delete a community.
|
72
|
-
*/
|
73
|
-
deleteCommunity(form) {
|
74
|
-
return wrapper(others_1.UserOperation.DeleteCommunity, form);
|
75
|
-
}
|
76
|
-
/**
|
77
|
-
* A moderator remove for a community.
|
78
|
-
*/
|
79
|
-
removeCommunity(form) {
|
80
|
-
return wrapper(others_1.UserOperation.RemoveCommunity, form);
|
81
|
-
}
|
82
|
-
/**
|
83
|
-
* Follow / subscribe to a community.
|
84
|
-
*/
|
85
|
-
followCommunity(form) {
|
86
|
-
return wrapper(others_1.UserOperation.FollowCommunity, form);
|
87
|
-
}
|
88
|
-
/**
|
89
|
-
* List communities, with various filters.
|
90
|
-
*/
|
91
|
-
listCommunities(form) {
|
92
|
-
return wrapper(others_1.UserOperation.ListCommunities, form);
|
93
|
-
}
|
94
|
-
/**
|
95
|
-
* Create a post.
|
96
|
-
*/
|
97
|
-
createPost(form) {
|
98
|
-
return wrapper(others_1.UserOperation.CreatePost, form);
|
99
|
-
}
|
100
|
-
/**
|
101
|
-
* Get / fetch a post.
|
102
|
-
*/
|
103
|
-
getPost(form) {
|
104
|
-
return wrapper(others_1.UserOperation.GetPost, form);
|
105
|
-
}
|
106
|
-
/**
|
107
|
-
* Get / fetch a community.
|
108
|
-
*/
|
109
|
-
getCommunity(form) {
|
110
|
-
return wrapper(others_1.UserOperation.GetCommunity, form);
|
111
|
-
}
|
112
|
-
/**
|
113
|
-
* Create a comment.
|
114
|
-
*/
|
115
|
-
createComment(form) {
|
116
|
-
return wrapper(others_1.UserOperation.CreateComment, form);
|
117
|
-
}
|
118
|
-
/**
|
119
|
-
* Edit a comment.
|
120
|
-
*/
|
121
|
-
editComment(form) {
|
122
|
-
return wrapper(others_1.UserOperation.EditComment, form);
|
123
|
-
}
|
124
|
-
/**
|
125
|
-
* Delete a comment.
|
126
|
-
*/
|
127
|
-
deleteComment(form) {
|
128
|
-
return wrapper(others_1.UserOperation.DeleteComment, form);
|
129
|
-
}
|
130
|
-
/**
|
131
|
-
* A moderator remove for a comment.
|
132
|
-
*/
|
133
|
-
removeComment(form) {
|
134
|
-
return wrapper(others_1.UserOperation.RemoveComment, form);
|
135
|
-
}
|
136
|
-
/**
|
137
|
-
* Mark a comment as read.
|
138
|
-
*/
|
139
|
-
markCommentReplyAsRead(form) {
|
140
|
-
return wrapper(others_1.UserOperation.MarkCommentReplyAsRead, form);
|
141
|
-
}
|
142
|
-
/**
|
143
|
-
* Like / vote on a comment.
|
144
|
-
*/
|
145
|
-
likeComment(form) {
|
146
|
-
return wrapper(others_1.UserOperation.CreateCommentLike, form);
|
147
|
-
}
|
148
|
-
/**
|
149
|
-
* Save a comment.
|
150
|
-
*/
|
151
|
-
saveComment(form) {
|
152
|
-
return wrapper(others_1.UserOperation.SaveComment, form);
|
153
|
-
}
|
154
|
-
/**
|
155
|
-
* Report a comment.
|
156
|
-
*/
|
157
|
-
createCommentReport(form) {
|
158
|
-
return wrapper(others_1.UserOperation.CreateCommentReport, form);
|
159
|
-
}
|
160
|
-
/**
|
161
|
-
* Resolve a comment report. Only a mod can do this.
|
162
|
-
*/
|
163
|
-
resolveCommentReport(form) {
|
164
|
-
return wrapper(others_1.UserOperation.ResolveCommentReport, form);
|
165
|
-
}
|
166
|
-
/**
|
167
|
-
* List comment reports.
|
168
|
-
*/
|
169
|
-
listCommentReports(form) {
|
170
|
-
return wrapper(others_1.UserOperation.ListCommentReports, form);
|
171
|
-
}
|
172
|
-
/**
|
173
|
-
* Get / fetch posts, with various filters.
|
174
|
-
*/
|
175
|
-
getPosts(form) {
|
176
|
-
return wrapper(others_1.UserOperation.GetPosts, form);
|
177
|
-
}
|
178
|
-
/**
|
179
|
-
* Get / fetch comments.
|
180
|
-
*/
|
181
|
-
getComments(form) {
|
182
|
-
return wrapper(others_1.UserOperation.GetComments, form);
|
183
|
-
}
|
184
|
-
/**
|
185
|
-
* Get / fetch comment.
|
186
|
-
*/
|
187
|
-
getComment(form) {
|
188
|
-
return wrapper(others_1.UserOperation.GetComment, form);
|
189
|
-
}
|
190
|
-
/**
|
191
|
-
* Like / vote on a post.
|
192
|
-
*/
|
193
|
-
likePost(form) {
|
194
|
-
return wrapper(others_1.UserOperation.CreatePostLike, form);
|
195
|
-
}
|
196
|
-
/**
|
197
|
-
* Edit a post.
|
198
|
-
*/
|
199
|
-
editPost(form) {
|
200
|
-
return wrapper(others_1.UserOperation.EditPost, form);
|
201
|
-
}
|
202
|
-
/**
|
203
|
-
* Delete a post.
|
204
|
-
*/
|
205
|
-
deletePost(form) {
|
206
|
-
return wrapper(others_1.UserOperation.DeletePost, form);
|
207
|
-
}
|
208
|
-
/**
|
209
|
-
* A moderator remove for a post.
|
210
|
-
*/
|
211
|
-
removePost(form) {
|
212
|
-
return wrapper(others_1.UserOperation.RemovePost, form);
|
213
|
-
}
|
214
|
-
/**
|
215
|
-
* A moderator can lock a post ( IE disable new comments ).
|
216
|
-
*/
|
217
|
-
lockPost(form) {
|
218
|
-
return wrapper(others_1.UserOperation.LockPost, form);
|
219
|
-
}
|
220
|
-
/**
|
221
|
-
* A moderator can feature a post ( IE stick it to the top of a community ).
|
222
|
-
*/
|
223
|
-
featurePost(form) {
|
224
|
-
return wrapper(others_1.UserOperation.FeaturePost, form);
|
225
|
-
}
|
226
|
-
/**
|
227
|
-
* Mark a post as read.
|
228
|
-
*/
|
229
|
-
markPostAsRead(form) {
|
230
|
-
return wrapper(others_1.UserOperation.MarkPostAsRead, form);
|
231
|
-
}
|
232
|
-
/**
|
233
|
-
* Save a post.
|
234
|
-
*/
|
235
|
-
savePost(form) {
|
236
|
-
return wrapper(others_1.UserOperation.SavePost, form);
|
237
|
-
}
|
238
|
-
/**
|
239
|
-
* Report a post.
|
240
|
-
*/
|
241
|
-
createPostReport(form) {
|
242
|
-
return wrapper(others_1.UserOperation.CreatePostReport, form);
|
243
|
-
}
|
244
|
-
/**
|
245
|
-
* Resolve a post report. Only a mod can do this.
|
246
|
-
*/
|
247
|
-
resolvePostReport(form) {
|
248
|
-
return wrapper(others_1.UserOperation.ResolvePostReport, form);
|
249
|
-
}
|
250
|
-
/**
|
251
|
-
* List post reports.
|
252
|
-
*/
|
253
|
-
listPostReports(form) {
|
254
|
-
return wrapper(others_1.UserOperation.ListPostReports, form);
|
255
|
-
}
|
256
|
-
/**
|
257
|
-
* Fetch metadata for any given site.
|
258
|
-
*/
|
259
|
-
getSiteMetadata(form) {
|
260
|
-
return wrapper(others_1.UserOperation.GetSiteMetadata, form);
|
261
|
-
}
|
262
|
-
/**
|
263
|
-
* Ban a user from a community.
|
264
|
-
*/
|
265
|
-
banFromCommunity(form) {
|
266
|
-
return wrapper(others_1.UserOperation.BanFromCommunity, form);
|
267
|
-
}
|
268
|
-
/**
|
269
|
-
* Add a moderator to your community.
|
270
|
-
*/
|
271
|
-
addModToCommunity(form) {
|
272
|
-
return wrapper(others_1.UserOperation.AddModToCommunity, form);
|
273
|
-
}
|
274
|
-
/**
|
275
|
-
* Transfer your community to an existing moderator.
|
276
|
-
*/
|
277
|
-
transferCommunity(form) {
|
278
|
-
return wrapper(others_1.UserOperation.TransferCommunity, form);
|
279
|
-
}
|
280
|
-
/**
|
281
|
-
* Leave the Site admins.
|
282
|
-
*/
|
283
|
-
leaveAdmin(form) {
|
284
|
-
return wrapper(others_1.UserOperation.LeaveAdmin, form);
|
285
|
-
}
|
286
|
-
/**
|
287
|
-
* Ban a person from your site.
|
288
|
-
*/
|
289
|
-
banPerson(form) {
|
290
|
-
return wrapper(others_1.UserOperation.BanPerson, form);
|
291
|
-
}
|
292
|
-
/**
|
293
|
-
* Get a list of banned users
|
294
|
-
*/
|
295
|
-
getBannedPersons(form) {
|
296
|
-
return wrapper(others_1.UserOperation.GetBannedPersons, form);
|
297
|
-
}
|
298
|
-
/**
|
299
|
-
* Add an admin to your site.
|
300
|
-
*/
|
301
|
-
addAdmin(form) {
|
302
|
-
return wrapper(others_1.UserOperation.AddAdmin, form);
|
303
|
-
}
|
304
|
-
/**
|
305
|
-
* Get the unread registration applications count.
|
306
|
-
*/
|
307
|
-
getUnreadRegistrationApplicationCount(form) {
|
308
|
-
return wrapper(others_1.UserOperation.GetUnreadRegistrationApplicationCount, form);
|
309
|
-
}
|
310
|
-
/**
|
311
|
-
* List the unread registration applications.
|
312
|
-
*/
|
313
|
-
listRegistrationApplications(form) {
|
314
|
-
return wrapper(others_1.UserOperation.ListRegistrationApplications, form);
|
315
|
-
}
|
316
|
-
/**
|
317
|
-
* Approve a registration application
|
318
|
-
*/
|
319
|
-
approveRegistrationApplication(form) {
|
320
|
-
return wrapper(others_1.UserOperation.ApproveRegistrationApplication, form);
|
321
|
-
}
|
322
|
-
/**
|
323
|
-
* Get the details for a person.
|
324
|
-
*/
|
325
|
-
getPersonDetails(form) {
|
326
|
-
return wrapper(others_1.UserOperation.GetPersonDetails, form);
|
327
|
-
}
|
328
|
-
/**
|
329
|
-
* Get comment replies.
|
330
|
-
*/
|
331
|
-
getReplies(form) {
|
332
|
-
return wrapper(others_1.UserOperation.GetReplies, form);
|
333
|
-
}
|
334
|
-
/**
|
335
|
-
* Get mentions for your user.
|
336
|
-
*/
|
337
|
-
getPersonMentions(form) {
|
338
|
-
return wrapper(others_1.UserOperation.GetPersonMentions, form);
|
339
|
-
}
|
340
|
-
/**
|
341
|
-
* Mark a person mention as read.
|
342
|
-
*/
|
343
|
-
markPersonMentionAsRead(form) {
|
344
|
-
return wrapper(others_1.UserOperation.MarkPersonMentionAsRead, form);
|
345
|
-
}
|
346
|
-
/**
|
347
|
-
* Get the modlog.
|
348
|
-
*/
|
349
|
-
getModlog(form) {
|
350
|
-
return wrapper(others_1.UserOperation.GetModlog, form);
|
351
|
-
}
|
352
|
-
/**
|
353
|
-
* Create your site.
|
354
|
-
*/
|
355
|
-
createSite(form) {
|
356
|
-
return wrapper(others_1.UserOperation.CreateSite, form);
|
357
|
-
}
|
358
|
-
/**
|
359
|
-
* Edit your site.
|
360
|
-
*/
|
361
|
-
editSite(form) {
|
362
|
-
return wrapper(others_1.UserOperation.EditSite, form);
|
363
|
-
}
|
364
|
-
/**
|
365
|
-
* Gets the site, and your user data.
|
366
|
-
*/
|
367
|
-
getSite(form) {
|
368
|
-
return wrapper(others_1.UserOperation.GetSite, form);
|
369
|
-
}
|
370
|
-
/**
|
371
|
-
* Search lemmy.
|
372
|
-
*/
|
373
|
-
search(form) {
|
374
|
-
return wrapper(others_1.UserOperation.Search, form);
|
375
|
-
}
|
376
|
-
/**
|
377
|
-
* Fetch a non-local / federated object.
|
378
|
-
*/
|
379
|
-
resolveObject(form) {
|
380
|
-
return wrapper(others_1.UserOperation.ResolveObject, form);
|
381
|
-
}
|
382
|
-
/**
|
383
|
-
* Mark all replies as read.
|
384
|
-
*/
|
385
|
-
markAllAsRead(form) {
|
386
|
-
return wrapper(others_1.UserOperation.MarkAllAsRead, form);
|
387
|
-
}
|
388
|
-
/**
|
389
|
-
* Save your user settings.
|
390
|
-
*/
|
391
|
-
saveUserSettings(form) {
|
392
|
-
return wrapper(others_1.UserOperation.SaveUserSettings, form);
|
393
|
-
}
|
394
|
-
/**
|
395
|
-
* Change your user password.
|
396
|
-
*/
|
397
|
-
changePassword(form) {
|
398
|
-
return wrapper(others_1.UserOperation.ChangePassword, form);
|
399
|
-
}
|
400
|
-
/**
|
401
|
-
* Get counts for your reports
|
402
|
-
*/
|
403
|
-
getReportCount(form) {
|
404
|
-
return wrapper(others_1.UserOperation.GetReportCount, form);
|
405
|
-
}
|
406
|
-
/**
|
407
|
-
* Get your unread counts
|
408
|
-
*/
|
409
|
-
getUnreadCount(form) {
|
410
|
-
return wrapper(others_1.UserOperation.GetUnreadCount, form);
|
411
|
-
}
|
412
|
-
/**
|
413
|
-
* Verify your email
|
414
|
-
*/
|
415
|
-
verifyEmail(form) {
|
416
|
-
return wrapper(others_1.UserOperation.VerifyEmail, form);
|
417
|
-
}
|
418
|
-
/**
|
419
|
-
* Delete your account.
|
420
|
-
*/
|
421
|
-
deleteAccount(form) {
|
422
|
-
return wrapper(others_1.UserOperation.DeleteAccount, form);
|
423
|
-
}
|
424
|
-
/**
|
425
|
-
* Reset your password.
|
426
|
-
*/
|
427
|
-
passwordReset(form) {
|
428
|
-
return wrapper(others_1.UserOperation.PasswordReset, form);
|
429
|
-
}
|
430
|
-
/**
|
431
|
-
* Change your password from an email / token based reset.
|
432
|
-
*/
|
433
|
-
passwordChange(form) {
|
434
|
-
return wrapper(others_1.UserOperation.PasswordChangeAfterReset, form);
|
435
|
-
}
|
436
|
-
/**
|
437
|
-
* Create a private message.
|
438
|
-
*/
|
439
|
-
createPrivateMessage(form) {
|
440
|
-
return wrapper(others_1.UserOperation.CreatePrivateMessage, form);
|
441
|
-
}
|
442
|
-
/**
|
443
|
-
* Edit a private message.
|
444
|
-
*/
|
445
|
-
editPrivateMessage(form) {
|
446
|
-
return wrapper(others_1.UserOperation.EditPrivateMessage, form);
|
447
|
-
}
|
448
|
-
/**
|
449
|
-
* Delete a private message.
|
450
|
-
*/
|
451
|
-
deletePrivateMessage(form) {
|
452
|
-
return wrapper(others_1.UserOperation.DeletePrivateMessage, form);
|
453
|
-
}
|
454
|
-
/**
|
455
|
-
* Mark a private message as read.
|
456
|
-
*/
|
457
|
-
markPrivateMessageAsRead(form) {
|
458
|
-
return wrapper(others_1.UserOperation.MarkPrivateMessageAsRead, form);
|
459
|
-
}
|
460
|
-
/**
|
461
|
-
* Get / fetch private messages.
|
462
|
-
*/
|
463
|
-
getPrivateMessages(form) {
|
464
|
-
return wrapper(others_1.UserOperation.GetPrivateMessages, form);
|
465
|
-
}
|
466
|
-
/**
|
467
|
-
* Create a report for a private message.
|
468
|
-
*/
|
469
|
-
createPrivateMessageReport(form) {
|
470
|
-
return wrapper(others_1.UserOperation.CreatePrivateMessageReport, form);
|
471
|
-
}
|
472
|
-
/**
|
473
|
-
* Resolve a report for a private message.
|
474
|
-
*/
|
475
|
-
resolvePrivateMessageReport(form) {
|
476
|
-
return wrapper(others_1.UserOperation.ResolvePrivateMessageReport, form);
|
477
|
-
}
|
478
|
-
/**
|
479
|
-
* List private message reports.
|
480
|
-
*/
|
481
|
-
listPrivateMessageReports(form) {
|
482
|
-
return wrapper(others_1.UserOperation.ListPrivateMessageReports, form);
|
483
|
-
}
|
484
|
-
/**
|
485
|
-
* Block a person.
|
486
|
-
*/
|
487
|
-
blockPerson(form) {
|
488
|
-
return wrapper(others_1.UserOperation.BlockPerson, form);
|
489
|
-
}
|
490
|
-
/**
|
491
|
-
* Block a community.
|
492
|
-
*/
|
493
|
-
blockCommunity(form) {
|
494
|
-
return wrapper(others_1.UserOperation.BlockCommunity, form);
|
495
|
-
}
|
496
|
-
/**
|
497
|
-
* Purge / Delete a person from the database.
|
498
|
-
*/
|
499
|
-
purgePerson(form) {
|
500
|
-
return wrapper(others_1.UserOperation.PurgePerson, form);
|
501
|
-
}
|
502
|
-
/**
|
503
|
-
* Purge / Delete a community from the database.
|
504
|
-
*/
|
505
|
-
purgeCommunity(form) {
|
506
|
-
return wrapper(others_1.UserOperation.PurgeCommunity, form);
|
507
|
-
}
|
508
|
-
/**
|
509
|
-
* Purge / Delete a post from the database.
|
510
|
-
*/
|
511
|
-
purgePost(form) {
|
512
|
-
return wrapper(others_1.UserOperation.PurgePost, form);
|
513
|
-
}
|
514
|
-
/**
|
515
|
-
* Purge / Delete a comment from the database.
|
516
|
-
*/
|
517
|
-
purgeComment(form) {
|
518
|
-
return wrapper(others_1.UserOperation.PurgeComment, form);
|
519
|
-
}
|
520
|
-
/**
|
521
|
-
* Create a custom emoji
|
522
|
-
*/
|
523
|
-
createCustomEmoji(form) {
|
524
|
-
return wrapper(others_1.UserOperation.CreateCustomEmoji, form);
|
525
|
-
}
|
526
|
-
/**
|
527
|
-
* Edit a custom emoji
|
528
|
-
*/
|
529
|
-
editCustomEmoji(form) {
|
530
|
-
return wrapper(others_1.UserOperation.EditCustomEmoji, form);
|
531
|
-
}
|
532
|
-
/**
|
533
|
-
* Delete a custom emoji
|
534
|
-
*/
|
535
|
-
deleteCustomEmoji(form) {
|
536
|
-
return wrapper(others_1.UserOperation.DeleteCustomEmoji, form);
|
537
|
-
}
|
538
|
-
/**
|
539
|
-
* Fetch federated instances.
|
540
|
-
*/
|
541
|
-
getFederatedInstances(form) {
|
542
|
-
return wrapper(others_1.UserOperation.GetFederatedInstances, form);
|
543
|
-
}
|
544
|
-
}
|
545
|
-
exports.LemmyWebsocket = LemmyWebsocket;
|
546
|
-
function wrapper(op, data) {
|
547
|
-
let send = JSON.stringify({ op: others_1.UserOperation[op], data });
|
548
|
-
return send;
|
549
|
-
}
|
550
|
-
function wsUserOp(msg) {
|
551
|
-
let opStr = msg.op;
|
552
|
-
return others_1.UserOperation[opStr];
|
553
|
-
}
|
554
|
-
exports.wsUserOp = wsUserOp;
|
555
|
-
/**
|
556
|
-
* Converts a websocket string response to a usable result
|
557
|
-
*/
|
558
|
-
// TODO is this still necessary?
|
559
|
-
function wsJsonToRes(msg) {
|
560
|
-
// Have to deserialize the response again into the correct class
|
561
|
-
return msg.data;
|
562
|
-
}
|
563
|
-
exports.wsJsonToRes = wsJsonToRes;
|