lemmy-js-client 0.11.4-rc.9 → 0.12.3-rc.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +14 -22
- package/dist/http.d.ts +219 -6
- package/dist/http.js +269 -2
- package/dist/interfaces/aggregates.d.ts +42 -0
- package/dist/interfaces/api/comment.d.ts +24 -9
- package/dist/interfaces/api/community.d.ts +14 -0
- package/dist/interfaces/api/person.d.ts +48 -9
- package/dist/interfaces/api/post.d.ts +30 -15
- package/dist/interfaces/api/site.d.ts +37 -2
- package/dist/interfaces/others.d.ts +99 -22
- package/dist/interfaces/others.js +67 -22
- package/dist/interfaces/source.d.ts +8 -0
- package/dist/interfaces/views.d.ts +7 -1
- package/dist/websocket.d.ts +236 -5
- package/dist/websocket.js +250 -1
- package/package.json +4 -1
package/README.md
CHANGED
@@ -16,39 +16,31 @@ A javascript / typescript http and websocket client and type system for [Lemmy](
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
-
|
19
|
+
### Websocket Client
|
20
20
|
|
21
|
-
|
21
|
+
[LemmyWebsocket docs](classes/LemmyWebsocket.html)
|
22
22
|
|
23
|
-
```
|
24
|
-
import {
|
23
|
+
```ts
|
24
|
+
import { Login, LemmyWebsocket } from 'lemmy-js-client';
|
25
25
|
|
26
26
|
let client: LemmyWebsocket = new LemmyWebsocket();
|
27
|
+
|
28
|
+
let form: Login {
|
29
|
+
username_or_email: "my_email@email.tld",
|
30
|
+
password: "my_pass",
|
31
|
+
};
|
32
|
+
|
27
33
|
this.ws.send(client.login(form));
|
28
34
|
```
|
29
35
|
|
30
|
-
### HTTP
|
36
|
+
### HTTP Client
|
37
|
+
|
38
|
+
[LemmyHttp docs](classes/LemmyHttp.html)
|
31
39
|
|
32
|
-
```
|
40
|
+
```ts
|
33
41
|
import { LemmyHttp } from 'lemmy-js-client';
|
34
42
|
|
35
43
|
let baseUrl = 'https://lemmy.ml';
|
36
44
|
let client: LemmyHttp = new LemmyHttp(baseUrl, headers?);
|
37
45
|
let jwt = await client.httpLogin(loginForm).jwt;
|
38
46
|
```
|
39
|
-
|
40
|
-
## Support / Donate
|
41
|
-
|
42
|
-
Lemmy is free, open-source software, meaning no advertising, monetizing, or venture capital, ever. Your donations directly support full-time development of the project.
|
43
|
-
|
44
|
-
- [Support on Liberapay](https://liberapay.com/Lemmy).
|
45
|
-
- [Support on Patreon](https://www.patreon.com/dessalines).
|
46
|
-
- [Support on OpenCollective](https://opencollective.com/lemmy).
|
47
|
-
- [List of Sponsors](https://dev.lemmy.ml/sponsors).
|
48
|
-
|
49
|
-
### Crypto
|
50
|
-
|
51
|
-
- bitcoin: `1Hefs7miXS5ff5Ck5xvmjKjXf5242KzRtK`
|
52
|
-
- ethereum: `0x400c96c96acbC6E7B3B43B1dc1BB446540a88A01`
|
53
|
-
- monero: `41taVyY6e1xApqKyMVDRVxJ76sPkfZhALLTjRvVKpaAh2pBd4wv9RgYj1tSPrx8wc6iE1uWUfjtQdTmTy2FGMeChGVKPQuV`
|
54
|
-
|
package/dist/http.d.ts
CHANGED
@@ -1,76 +1,289 @@
|
|
1
|
-
import { CommentResponse, CreateComment, CreateCommentLike, DeleteComment, EditComment, GetComments, GetCommentsResponse, MarkCommentAsRead, RemoveComment, SaveComment } from './interfaces/api/comment';
|
1
|
+
import { CommentReportResponse, CommentResponse, CreateComment, CreateCommentLike, CreateCommentReport, DeleteComment, EditComment, GetComments, GetCommentsResponse, ListCommentReports, ListCommentReportsResponse, MarkCommentAsRead, RemoveComment, ResolveCommentReport, SaveComment } from './interfaces/api/comment';
|
2
2
|
import { AddModToCommunity, AddModToCommunityResponse, BanFromCommunity, BanFromCommunityResponse, BlockCommunity, BlockCommunityResponse, CommunityResponse, CreateCommunity, DeleteCommunity, EditCommunity, FollowCommunity, GetCommunity, GetCommunityResponse, ListCommunities, ListCommunitiesResponse, RemoveCommunity, TransferCommunity } from './interfaces/api/community';
|
3
|
-
import { CreatePost, CreatePostLike, DeletePost, EditPost, GetPost, GetPostResponse, GetPosts, GetPostsResponse, LockPost, PostResponse, RemovePost, SavePost, StickyPost } from './interfaces/api/post';
|
4
|
-
import { CreateSite, EditSite, GetModlog, GetModlogResponse, GetSite, GetSiteConfig, GetSiteConfigResponse, GetSiteResponse, SaveSiteConfig, Search, SearchResponse, SiteResponse, TransferSite } from './interfaces/api/site';
|
5
|
-
import { AddAdmin, AddAdminResponse, BanPerson, BanPersonResponse, CreatePrivateMessage, DeleteAccount, DeletePrivateMessage, EditPrivateMessage, GetCaptchaResponse, GetPrivateMessages, GetReplies, GetRepliesResponse, GetPersonDetails, GetPersonDetailsResponse, GetPersonMentions, GetPersonMentionsResponse, Login, LoginResponse, MarkAllAsRead, MarkPrivateMessageAsRead, MarkPersonMentionAsRead, PasswordChange, PasswordReset, PasswordResetResponse, PrivateMessageResponse, PrivateMessagesResponse, Register, SaveUserSettings, ChangePassword, PersonMentionResponse, BlockPerson, BlockPersonResponse } from './interfaces/api/person';
|
3
|
+
import { CreatePost, CreatePostLike, DeletePost, EditPost, GetPost, GetPostResponse, GetPosts, GetPostsResponse, GetSiteMetadata, GetSiteMetadataResponse, LockPost, CreatePostReport, PostReportResponse, PostResponse, RemovePost, SavePost, StickyPost, ResolvePostReport, ListPostReports, ListPostReportsResponse } from './interfaces/api/post';
|
4
|
+
import { CreateSite, EditSite, GetModlog, GetModlogResponse, GetSite, GetSiteConfig, GetSiteConfigResponse, GetSiteResponse, ResolveObject, ResolveObjectResponse, SaveSiteConfig, Search, SearchResponse, SiteResponse, TransferSite } from './interfaces/api/site';
|
5
|
+
import { AddAdmin, AddAdminResponse, BanPerson, BanPersonResponse, CreatePrivateMessage, DeleteAccount, DeletePrivateMessage, EditPrivateMessage, GetCaptchaResponse, GetPrivateMessages, GetReplies, GetRepliesResponse, GetPersonDetails, GetPersonDetailsResponse, GetPersonMentions, GetPersonMentionsResponse, Login, LoginResponse, MarkAllAsRead, MarkPrivateMessageAsRead, MarkPersonMentionAsRead, PasswordChange, PasswordReset, PasswordResetResponse, PrivateMessageResponse, PrivateMessagesResponse, Register, SaveUserSettings, ChangePassword, PersonMentionResponse, BlockPerson, BlockPersonResponse, GetReportCount, GetReportCountResponse } from './interfaces/api/person';
|
6
|
+
/**
|
7
|
+
* Helps build lemmy HTTP requests.
|
8
|
+
*/
|
6
9
|
export declare class LemmyHttp {
|
7
10
|
private apiUrl;
|
8
11
|
private headers;
|
9
12
|
/**
|
10
|
-
* Generates a new instance of LemmyHttp
|
13
|
+
* Generates a new instance of LemmyHttp.
|
11
14
|
* @param baseUrl the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX
|
12
|
-
* @param headers optional headers. Should contain x-real-ip and x-forwarded-for
|
15
|
+
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
13
16
|
*/
|
14
17
|
constructor(baseUrl: string, headers?: {
|
15
18
|
[key: string]: string;
|
16
19
|
});
|
20
|
+
/**
|
21
|
+
* Gets the site, and your user data.
|
22
|
+
*/
|
17
23
|
getSite(form: GetSite): Promise<GetSiteResponse>;
|
24
|
+
/**
|
25
|
+
* Create your site.
|
26
|
+
*/
|
18
27
|
createSite(form: CreateSite): Promise<SiteResponse>;
|
28
|
+
/**
|
29
|
+
* Edit your site.
|
30
|
+
*/
|
19
31
|
editSite(form: EditSite): Promise<SiteResponse>;
|
32
|
+
/**
|
33
|
+
* Transfer your site to another user.
|
34
|
+
*/
|
20
35
|
transferSite(form: TransferSite): Promise<GetSiteResponse>;
|
36
|
+
/**
|
37
|
+
* Get your site configuration.
|
38
|
+
*/
|
21
39
|
getSiteConfig(form: GetSiteConfig): Promise<GetSiteConfigResponse>;
|
40
|
+
/**
|
41
|
+
* Save your site config.
|
42
|
+
*/
|
22
43
|
saveSiteConfig(form: SaveSiteConfig): Promise<GetSiteConfigResponse>;
|
44
|
+
/**
|
45
|
+
* Get the modlog.
|
46
|
+
*/
|
23
47
|
getModlog(form: GetModlog): Promise<GetModlogResponse>;
|
48
|
+
/**
|
49
|
+
* Search lemmy.
|
50
|
+
*/
|
24
51
|
search(form: Search): Promise<SearchResponse>;
|
52
|
+
/**
|
53
|
+
* Fetch a non-local / federated object.
|
54
|
+
*/
|
55
|
+
resolveObject(form: ResolveObject): Promise<ResolveObjectResponse>;
|
56
|
+
/**
|
57
|
+
* Create a new community.
|
58
|
+
*/
|
25
59
|
createCommunity(form: CreateCommunity): Promise<CommunityResponse>;
|
60
|
+
/**
|
61
|
+
* Get / fetch a community.
|
62
|
+
*/
|
26
63
|
getCommunity(form: GetCommunity): Promise<GetCommunityResponse>;
|
64
|
+
/**
|
65
|
+
* Edit a community.
|
66
|
+
*/
|
27
67
|
editCommunity(form: EditCommunity): Promise<CommunityResponse>;
|
68
|
+
/**
|
69
|
+
* List communities, with various filters.
|
70
|
+
*/
|
28
71
|
listCommunities(form: ListCommunities): Promise<ListCommunitiesResponse>;
|
72
|
+
/**
|
73
|
+
* Follow / subscribe to a community.
|
74
|
+
*/
|
29
75
|
followCommunity(form: FollowCommunity): Promise<CommunityResponse>;
|
76
|
+
/**
|
77
|
+
* Block a community.
|
78
|
+
*/
|
30
79
|
blockCommunity(form: BlockCommunity): Promise<BlockCommunityResponse>;
|
80
|
+
/**
|
81
|
+
* Delete a community.
|
82
|
+
*/
|
31
83
|
deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse>;
|
84
|
+
/**
|
85
|
+
* A moderator remove for a community.
|
86
|
+
*/
|
32
87
|
removeCommunity(form: RemoveCommunity): Promise<CommunityResponse>;
|
88
|
+
/**
|
89
|
+
* Transfer your community to an existing moderator.
|
90
|
+
*/
|
33
91
|
transferCommunity(form: TransferCommunity): Promise<GetCommunityResponse>;
|
92
|
+
/**
|
93
|
+
* Ban a user from a community.
|
94
|
+
*/
|
34
95
|
banFromCommunity(form: BanFromCommunity): Promise<BanFromCommunityResponse>;
|
96
|
+
/**
|
97
|
+
* Add a moderator to your community.
|
98
|
+
*/
|
35
99
|
addModToCommunity(form: AddModToCommunity): Promise<AddModToCommunityResponse>;
|
100
|
+
/**
|
101
|
+
* Create a post.
|
102
|
+
*/
|
36
103
|
createPost(form: CreatePost): Promise<PostResponse>;
|
104
|
+
/**
|
105
|
+
* Get / fetch a post.
|
106
|
+
*/
|
37
107
|
getPost(form: GetPost): Promise<GetPostResponse>;
|
108
|
+
/**
|
109
|
+
* Edit a post.
|
110
|
+
*/
|
38
111
|
editPost(form: EditPost): Promise<PostResponse>;
|
112
|
+
/**
|
113
|
+
* Delete a post.
|
114
|
+
*/
|
39
115
|
deletePost(form: DeletePost): Promise<PostResponse>;
|
116
|
+
/**
|
117
|
+
* A moderator remove for a post.
|
118
|
+
*/
|
40
119
|
removePost(form: RemovePost): Promise<PostResponse>;
|
120
|
+
/**
|
121
|
+
* A moderator can lock a post ( IE disable new comments ).
|
122
|
+
*/
|
41
123
|
lockPost(form: LockPost): Promise<PostResponse>;
|
124
|
+
/**
|
125
|
+
* A moderator can sticky a post ( IE stick it to the top of a community ).
|
126
|
+
*/
|
42
127
|
stickyPost(form: StickyPost): Promise<PostResponse>;
|
128
|
+
/**
|
129
|
+
* Get / fetch posts, with various filters.
|
130
|
+
*/
|
43
131
|
getPosts(form: GetPosts): Promise<GetPostsResponse>;
|
132
|
+
/**
|
133
|
+
* Like / vote on a post.
|
134
|
+
*/
|
44
135
|
likePost(form: CreatePostLike): Promise<PostResponse>;
|
136
|
+
/**
|
137
|
+
* Save a post.
|
138
|
+
*/
|
45
139
|
savePost(form: SavePost): Promise<PostResponse>;
|
140
|
+
/**
|
141
|
+
* Report a post.
|
142
|
+
*/
|
143
|
+
createPostReport(form: CreatePostReport): Promise<PostReportResponse>;
|
144
|
+
/**
|
145
|
+
* Resolve a post report. Only a mod can do this.
|
146
|
+
*/
|
147
|
+
resolvePostReport(form: ResolvePostReport): Promise<PostReportResponse>;
|
148
|
+
/**
|
149
|
+
* List post reports.
|
150
|
+
*/
|
151
|
+
listPostReports(form: ListPostReports): Promise<ListPostReportsResponse>;
|
152
|
+
/**
|
153
|
+
* Fetch metadata for any given site.
|
154
|
+
*/
|
155
|
+
getSiteMetadata(form: GetSiteMetadata): Promise<GetSiteMetadataResponse>;
|
156
|
+
/**
|
157
|
+
* Create a comment.
|
158
|
+
*/
|
46
159
|
createComment(form: CreateComment): Promise<CommentResponse>;
|
160
|
+
/**
|
161
|
+
* Edit a comment.
|
162
|
+
*/
|
47
163
|
editComment(form: EditComment): Promise<CommentResponse>;
|
164
|
+
/**
|
165
|
+
* Delete a comment.
|
166
|
+
*/
|
48
167
|
deleteComment(form: DeleteComment): Promise<CommentResponse>;
|
168
|
+
/**
|
169
|
+
* A moderator remove for a comment.
|
170
|
+
*/
|
49
171
|
removeComment(form: RemoveComment): Promise<CommentResponse>;
|
172
|
+
/**
|
173
|
+
* Mark a comment as read.
|
174
|
+
*/
|
50
175
|
markCommentAsRead(form: MarkCommentAsRead): Promise<CommentResponse>;
|
176
|
+
/**
|
177
|
+
* Like / vote on a comment.
|
178
|
+
*/
|
51
179
|
likeComment(form: CreateCommentLike): Promise<CommentResponse>;
|
180
|
+
/**
|
181
|
+
* Save a comment.
|
182
|
+
*/
|
52
183
|
saveComment(form: SaveComment): Promise<CommentResponse>;
|
184
|
+
/**
|
185
|
+
* Get / fetch comments.
|
186
|
+
*/
|
53
187
|
getComments(form: GetComments): Promise<GetCommentsResponse>;
|
188
|
+
/**
|
189
|
+
* Report a comment.
|
190
|
+
*/
|
191
|
+
createCommentReport(form: CreateCommentReport): Promise<CommentReportResponse>;
|
192
|
+
/**
|
193
|
+
* Resolve a comment report. Only a mod can do this.
|
194
|
+
*/
|
195
|
+
resolveCommentReport(form: ResolveCommentReport): Promise<CommentReportResponse>;
|
196
|
+
/**
|
197
|
+
* List comment reports.
|
198
|
+
*/
|
199
|
+
listCommentReports(form: ListCommentReports): Promise<ListCommentReportsResponse>;
|
200
|
+
/**
|
201
|
+
* Get / fetch private messages.
|
202
|
+
*/
|
54
203
|
getPrivateMessages(form: GetPrivateMessages): Promise<PrivateMessagesResponse>;
|
204
|
+
/**
|
205
|
+
* Create a private message.
|
206
|
+
*/
|
55
207
|
createPrivateMessage(form: CreatePrivateMessage): Promise<PrivateMessageResponse>;
|
208
|
+
/**
|
209
|
+
* Edit a private message.
|
210
|
+
*/
|
56
211
|
editPrivateMessage(form: EditPrivateMessage): Promise<PrivateMessageResponse>;
|
212
|
+
/**
|
213
|
+
* Delete a private message.
|
214
|
+
*/
|
57
215
|
deletePrivateMessage(form: DeletePrivateMessage): Promise<PrivateMessageResponse>;
|
216
|
+
/**
|
217
|
+
* Mark a private message as read.
|
218
|
+
*/
|
58
219
|
markPrivateMessageAsRead(form: MarkPrivateMessageAsRead): Promise<PrivateMessageResponse>;
|
220
|
+
/**
|
221
|
+
* Register a new user.
|
222
|
+
*/
|
59
223
|
register(form: Register): Promise<LoginResponse>;
|
224
|
+
/**
|
225
|
+
* Log into lemmy.
|
226
|
+
*/
|
60
227
|
login(form: Login): Promise<LoginResponse>;
|
228
|
+
/**
|
229
|
+
* Get the details for a person.
|
230
|
+
*/
|
61
231
|
getPersonDetails(form: GetPersonDetails): Promise<GetPersonDetailsResponse>;
|
232
|
+
/**
|
233
|
+
* Get mentions for your user.
|
234
|
+
*/
|
62
235
|
getPersonMentions(form: GetPersonMentions): Promise<GetPersonMentionsResponse>;
|
236
|
+
/**
|
237
|
+
* Mark a person mention as read.
|
238
|
+
*/
|
63
239
|
markPersonMentionAsRead(form: MarkPersonMentionAsRead): Promise<PersonMentionResponse>;
|
240
|
+
/**
|
241
|
+
* Get comment replies.
|
242
|
+
*/
|
64
243
|
getReplies(form: GetReplies): Promise<GetRepliesResponse>;
|
244
|
+
/**
|
245
|
+
* Ban a person from your site.
|
246
|
+
*/
|
65
247
|
banPerson(form: BanPerson): Promise<BanPersonResponse>;
|
248
|
+
/**
|
249
|
+
* Block a person.
|
250
|
+
*/
|
66
251
|
blockPerson(form: BlockPerson): Promise<BlockPersonResponse>;
|
252
|
+
/**
|
253
|
+
* Fetch a Captcha.
|
254
|
+
*/
|
67
255
|
getCaptcha(): Promise<GetCaptchaResponse>;
|
256
|
+
/**
|
257
|
+
* Delete your account.
|
258
|
+
*/
|
68
259
|
deleteAccount(form: DeleteAccount): Promise<LoginResponse>;
|
260
|
+
/**
|
261
|
+
* Reset your password.
|
262
|
+
*/
|
69
263
|
passwordReset(form: PasswordReset): Promise<PasswordResetResponse>;
|
264
|
+
/**
|
265
|
+
* Change your password from an email / token based reset.
|
266
|
+
*/
|
70
267
|
passwordChange(form: PasswordChange): Promise<LoginResponse>;
|
268
|
+
/**
|
269
|
+
* Mark all replies as read.
|
270
|
+
*/
|
71
271
|
markAllAsRead(form: MarkAllAsRead): Promise<GetRepliesResponse>;
|
272
|
+
/**
|
273
|
+
* Save your user settings.
|
274
|
+
*/
|
72
275
|
saveUserSettings(form: SaveUserSettings): Promise<LoginResponse>;
|
276
|
+
/**
|
277
|
+
* Change your user password.
|
278
|
+
*/
|
73
279
|
changePassword(form: ChangePassword): Promise<LoginResponse>;
|
280
|
+
/**
|
281
|
+
* Get counts for your reports
|
282
|
+
*/
|
283
|
+
getReportCount(form: GetReportCount): Promise<GetReportCountResponse>;
|
284
|
+
/**
|
285
|
+
* Add an admin to your site.
|
286
|
+
*/
|
74
287
|
addAdmin(form: AddAdmin): Promise<AddAdminResponse>;
|
75
288
|
private buildFullUrl;
|
76
289
|
private wrapper;
|