mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-01 01:59:55 +00:00
parent
edcd37d507
commit
5e4ff291c5
16 changed files with 1044 additions and 1547 deletions
|
@ -4,11 +4,11 @@
|
|||
"browser": true
|
||||
},
|
||||
"plugins": [
|
||||
"jane"
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:jane/recommended",
|
||||
"plugin:jane/typescript"
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
|
@ -16,14 +16,11 @@
|
|||
"warnOnUnsupportedTypeScriptVersion": false
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/member-delimiter-style": 0,
|
||||
"@typescript-eslint/no-empty-interface": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/ban-ts-comment": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-this-alias": 0,
|
||||
"@typescript-eslint/no-unused-vars": 0,
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/no-useless-constructor": 0,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
"arrow-body-style": 0,
|
||||
"curly": 0,
|
||||
"eol-last": 0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = Object.assign(require('eslint-plugin-jane/prettier-ts'), {
|
||||
arrowParens: 'avoid',
|
||||
module.exports = Object.assign(require("eslint-plugin-prettier"), {
|
||||
arrowParens: "avoid",
|
||||
semi: true,
|
||||
});
|
||||
|
|
27
package.json
27
package.json
|
@ -16,18 +16,23 @@
|
|||
},
|
||||
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.10.2",
|
||||
"@types/node": "^16.11.11",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-jane": "^9.0.6",
|
||||
"husky": "^7.0.2",
|
||||
"lint-staged": "^11.1.2",
|
||||
"node-fetch": "^3.0.0",
|
||||
"prettier": "^2.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
||||
"@typescript-eslint/parser": "^5.5.0",
|
||||
"eslint": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"lint-staged": "^12.1.2",
|
||||
"node-fetch": "^3.1.0",
|
||||
"prettier": "^2.5.0",
|
||||
"prettier-plugin-import-sort": "^0.0.7",
|
||||
"prettier-plugin-organize-imports": "^2.3.4",
|
||||
"prettier-plugin-packagejson": "^2.2.15",
|
||||
"sortpack": "^2.2.0",
|
||||
"typedoc": "^0.21.6",
|
||||
"typedoc-plugin-sourcefile-url": "^1.0.6",
|
||||
"typescript": "^4.4.3"
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"lint-staged": {
|
||||
|
@ -38,5 +43,11 @@
|
|||
"package.json": [
|
||||
"sortpack"
|
||||
]
|
||||
},
|
||||
"importSort": {
|
||||
".js, .jsx, .ts, .tsx": {
|
||||
"style": "module",
|
||||
"parser": "typescript"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
247
src/http.ts
247
src/http.ts
|
@ -1,4 +1,4 @@
|
|||
import fetch from 'node-fetch';
|
||||
import fetch from "node-fetch";
|
||||
import {
|
||||
CommentReportResponse,
|
||||
CommentResponse,
|
||||
|
@ -15,7 +15,7 @@ import {
|
|||
RemoveComment,
|
||||
ResolveCommentReport,
|
||||
SaveComment,
|
||||
} from './interfaces/api/comment';
|
||||
} from "./interfaces/api/comment";
|
||||
import {
|
||||
AddModToCommunity,
|
||||
AddModToCommunityResponse,
|
||||
|
@ -34,10 +34,49 @@ import {
|
|||
ListCommunitiesResponse,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from './interfaces/api/community';
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
AddAdmin,
|
||||
AddAdminResponse,
|
||||
BanPerson,
|
||||
BanPersonResponse,
|
||||
BlockPerson,
|
||||
BlockPersonResponse,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetCaptchaResponse,
|
||||
GetPersonDetails,
|
||||
GetPersonDetailsResponse,
|
||||
GetPersonMentions,
|
||||
GetPersonMentionsResponse,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetRepliesResponse,
|
||||
GetReportCount,
|
||||
GetReportCountResponse,
|
||||
GetUnreadCount,
|
||||
GetUnreadCountResponse,
|
||||
Login,
|
||||
LoginResponse,
|
||||
MarkAllAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
PasswordResetResponse,
|
||||
PersonMentionResponse,
|
||||
PrivateMessageResponse,
|
||||
PrivateMessagesResponse,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
CreatePostReport,
|
||||
DeletePost,
|
||||
EditPost,
|
||||
GetPost,
|
||||
|
@ -46,17 +85,16 @@ import {
|
|||
GetPostsResponse,
|
||||
GetSiteMetadata,
|
||||
GetSiteMetadataResponse,
|
||||
ListPostReports,
|
||||
ListPostReportsResponse,
|
||||
LockPost,
|
||||
CreatePostReport,
|
||||
PostReportResponse,
|
||||
PostResponse,
|
||||
RemovePost,
|
||||
ResolvePostReport,
|
||||
SavePost,
|
||||
StickyPost,
|
||||
ResolvePostReport,
|
||||
ListPostReports,
|
||||
ListPostReportsResponse,
|
||||
} from './interfaces/api/post';
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
CreateSite,
|
||||
EditSite,
|
||||
|
@ -73,52 +111,13 @@ import {
|
|||
SearchResponse,
|
||||
SiteResponse,
|
||||
TransferSite,
|
||||
} from './interfaces/api/site';
|
||||
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,
|
||||
GetUnreadCount,
|
||||
GetUnreadCountResponse,
|
||||
} from './interfaces/api/person';
|
||||
|
||||
import { VERSION } from './interfaces/others';
|
||||
} from "./interfaces/api/site";
|
||||
import { VERSION } from "./interfaces/others";
|
||||
|
||||
enum HttpType {
|
||||
Get = 'GET',
|
||||
Post = 'POST',
|
||||
Put = 'PUT',
|
||||
Get = "GET",
|
||||
Post = "POST",
|
||||
Put = "PUT",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,84 +144,84 @@ export class LemmyHttp {
|
|||
* Gets the site, and your user data.
|
||||
*/
|
||||
async getSite(form: GetSite): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Get, '/site', form);
|
||||
return this.wrapper(HttpType.Get, "/site", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create your site.
|
||||
*/
|
||||
async createSite(form: CreateSite): Promise<SiteResponse> {
|
||||
return this.wrapper(HttpType.Post, '/site', form);
|
||||
return this.wrapper(HttpType.Post, "/site", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit your site.
|
||||
*/
|
||||
async editSite(form: EditSite): Promise<SiteResponse> {
|
||||
return this.wrapper(HttpType.Put, '/site', form);
|
||||
return this.wrapper(HttpType.Put, "/site", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer your site to another user.
|
||||
*/
|
||||
async transferSite(form: TransferSite): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Post, '/site/transfer', form);
|
||||
return this.wrapper(HttpType.Post, "/site/transfer", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your site configuration.
|
||||
*/
|
||||
async getSiteConfig(form: GetSiteConfig): Promise<GetSiteConfigResponse> {
|
||||
return this.wrapper(HttpType.Get, '/site/config', form);
|
||||
return this.wrapper(HttpType.Get, "/site/config", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save your site config.
|
||||
*/
|
||||
async saveSiteConfig(form: SaveSiteConfig): Promise<GetSiteConfigResponse> {
|
||||
return this.wrapper(HttpType.Put, '/site/config', form);
|
||||
return this.wrapper(HttpType.Put, "/site/config", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the modlog.
|
||||
*/
|
||||
async getModlog(form: GetModlog): Promise<GetModlogResponse> {
|
||||
return this.wrapper(HttpType.Get, '/modlog', form);
|
||||
return this.wrapper(HttpType.Get, "/modlog", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search lemmy.
|
||||
*/
|
||||
async search(form: Search): Promise<SearchResponse> {
|
||||
return this.wrapper(HttpType.Get, '/search', form);
|
||||
return this.wrapper(HttpType.Get, "/search", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a non-local / federated object.
|
||||
*/
|
||||
async resolveObject(form: ResolveObject): Promise<ResolveObjectResponse> {
|
||||
return this.wrapper(HttpType.Get, '/resolve_object', form);
|
||||
return this.wrapper(HttpType.Get, "/resolve_object", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new community.
|
||||
*/
|
||||
async createCommunity(form: CreateCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community', form);
|
||||
return this.wrapper(HttpType.Post, "/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch a community.
|
||||
*/
|
||||
async getCommunity(form: GetCommunity): Promise<GetCommunityResponse> {
|
||||
return this.wrapper(HttpType.Get, '/community', form);
|
||||
return this.wrapper(HttpType.Get, "/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a community.
|
||||
*/
|
||||
async editCommunity(form: EditCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Put, '/community', form);
|
||||
return this.wrapper(HttpType.Put, "/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,35 +230,35 @@ export class LemmyHttp {
|
|||
async listCommunities(
|
||||
form: ListCommunities
|
||||
): Promise<ListCommunitiesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/community/list', form);
|
||||
return this.wrapper(HttpType.Get, "/community/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow / subscribe to a community.
|
||||
*/
|
||||
async followCommunity(form: FollowCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/follow', form);
|
||||
return this.wrapper(HttpType.Post, "/community/follow", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a community.
|
||||
*/
|
||||
async blockCommunity(form: BlockCommunity): Promise<BlockCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/block', form);
|
||||
return this.wrapper(HttpType.Post, "/community/block", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a community.
|
||||
*/
|
||||
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/community/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator remove for a community.
|
||||
*/
|
||||
async removeCommunity(form: RemoveCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/remove', form);
|
||||
return this.wrapper(HttpType.Post, "/community/remove", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,7 +267,7 @@ export class LemmyHttp {
|
|||
async transferCommunity(
|
||||
form: TransferCommunity
|
||||
): Promise<GetCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/transfer', form);
|
||||
return this.wrapper(HttpType.Post, "/community/transfer", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,7 +276,7 @@ export class LemmyHttp {
|
|||
async banFromCommunity(
|
||||
form: BanFromCommunity
|
||||
): Promise<BanFromCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/ban_user', form);
|
||||
return this.wrapper(HttpType.Post, "/community/ban_user", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,84 +285,84 @@ export class LemmyHttp {
|
|||
async addModToCommunity(
|
||||
form: AddModToCommunity
|
||||
): Promise<AddModToCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/mod', form);
|
||||
return this.wrapper(HttpType.Post, "/community/mod", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a post.
|
||||
*/
|
||||
async createPost(form: CreatePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post', form);
|
||||
return this.wrapper(HttpType.Post, "/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch a post.
|
||||
*/
|
||||
async getPost(form: GetPost): Promise<GetPostResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post', form);
|
||||
return this.wrapper(HttpType.Get, "/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a post.
|
||||
*/
|
||||
async editPost(form: EditPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post', form);
|
||||
return this.wrapper(HttpType.Put, "/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a post.
|
||||
*/
|
||||
async deletePost(form: DeletePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/post/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator remove for a post.
|
||||
*/
|
||||
async removePost(form: RemovePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/remove', form);
|
||||
return this.wrapper(HttpType.Post, "/post/remove", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator can lock a post ( IE disable new comments ).
|
||||
*/
|
||||
async lockPost(form: LockPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/lock', form);
|
||||
return this.wrapper(HttpType.Post, "/post/lock", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator can sticky a post ( IE stick it to the top of a community ).
|
||||
*/
|
||||
async stickyPost(form: StickyPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/sticky', form);
|
||||
return this.wrapper(HttpType.Post, "/post/sticky", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch posts, with various filters.
|
||||
*/
|
||||
async getPosts(form: GetPosts): Promise<GetPostsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/list', form);
|
||||
return this.wrapper(HttpType.Get, "/post/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like / vote on a post.
|
||||
*/
|
||||
async likePost(form: CreatePostLike): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/like', form);
|
||||
return this.wrapper(HttpType.Post, "/post/like", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a post.
|
||||
*/
|
||||
async savePost(form: SavePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post/save', form);
|
||||
return this.wrapper(HttpType.Put, "/post/save", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a post.
|
||||
*/
|
||||
async createPostReport(form: CreatePostReport): Promise<PostReportResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/report', form);
|
||||
return this.wrapper(HttpType.Post, "/post/report", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -372,7 +371,7 @@ export class LemmyHttp {
|
|||
async resolvePostReport(
|
||||
form: ResolvePostReport
|
||||
): Promise<PostReportResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post/report/resolve', form);
|
||||
return this.wrapper(HttpType.Put, "/post/report/resolve", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -381,7 +380,7 @@ export class LemmyHttp {
|
|||
async listPostReports(
|
||||
form: ListPostReports
|
||||
): Promise<ListPostReportsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/report/list', form);
|
||||
return this.wrapper(HttpType.Get, "/post/report/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,63 +389,63 @@ export class LemmyHttp {
|
|||
async getSiteMetadata(
|
||||
form: GetSiteMetadata
|
||||
): Promise<GetSiteMetadataResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/site_metadata', form);
|
||||
return this.wrapper(HttpType.Get, "/post/site_metadata", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a comment.
|
||||
*/
|
||||
async createComment(form: CreateComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment', form);
|
||||
return this.wrapper(HttpType.Post, "/comment", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a comment.
|
||||
*/
|
||||
async editComment(form: EditComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment', form);
|
||||
return this.wrapper(HttpType.Put, "/comment", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a comment.
|
||||
*/
|
||||
async deleteComment(form: DeleteComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator remove for a comment.
|
||||
*/
|
||||
async removeComment(form: RemoveComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/remove', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/remove", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a comment as read.
|
||||
*/
|
||||
async markCommentAsRead(form: MarkCommentAsRead): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/mark_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like / vote on a comment.
|
||||
*/
|
||||
async likeComment(form: CreateCommentLike): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/like', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/like", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a comment.
|
||||
*/
|
||||
async saveComment(form: SaveComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment/save', form);
|
||||
return this.wrapper(HttpType.Put, "/comment/save", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch comments.
|
||||
*/
|
||||
async getComments(form: GetComments): Promise<GetCommentsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/comment/list', form);
|
||||
return this.wrapper(HttpType.Get, "/comment/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -455,7 +454,7 @@ export class LemmyHttp {
|
|||
async createCommentReport(
|
||||
form: CreateCommentReport
|
||||
): Promise<CommentReportResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/report', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/report", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,7 +463,7 @@ export class LemmyHttp {
|
|||
async resolveCommentReport(
|
||||
form: ResolveCommentReport
|
||||
): Promise<CommentReportResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment/report/resolve', form);
|
||||
return this.wrapper(HttpType.Put, "/comment/report/resolve", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -473,7 +472,7 @@ export class LemmyHttp {
|
|||
async listCommentReports(
|
||||
form: ListCommentReports
|
||||
): Promise<ListCommentReportsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/comment/report/list', form);
|
||||
return this.wrapper(HttpType.Get, "/comment/report/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -482,7 +481,7 @@ export class LemmyHttp {
|
|||
async getPrivateMessages(
|
||||
form: GetPrivateMessages
|
||||
): Promise<PrivateMessagesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/private_message/list', form);
|
||||
return this.wrapper(HttpType.Get, "/private_message/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -491,7 +490,7 @@ export class LemmyHttp {
|
|||
async createPrivateMessage(
|
||||
form: CreatePrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message', form);
|
||||
return this.wrapper(HttpType.Post, "/private_message", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -500,7 +499,7 @@ export class LemmyHttp {
|
|||
async editPrivateMessage(
|
||||
form: EditPrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Put, '/private_message', form);
|
||||
return this.wrapper(HttpType.Put, "/private_message", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,7 +508,7 @@ export class LemmyHttp {
|
|||
async deletePrivateMessage(
|
||||
form: DeletePrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/private_message/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -518,21 +517,21 @@ export class LemmyHttp {
|
|||
async markPrivateMessageAsRead(
|
||||
form: MarkPrivateMessageAsRead
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message/mark_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/private_message/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
*/
|
||||
async register(form: Register): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/register', form);
|
||||
return this.wrapper(HttpType.Post, "/user/register", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log into lemmy.
|
||||
*/
|
||||
async login(form: Login): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/login', form);
|
||||
return this.wrapper(HttpType.Post, "/user/login", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -541,7 +540,7 @@ export class LemmyHttp {
|
|||
async getPersonDetails(
|
||||
form: GetPersonDetails
|
||||
): Promise<GetPersonDetailsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user', form);
|
||||
return this.wrapper(HttpType.Get, "/user", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -550,7 +549,7 @@ export class LemmyHttp {
|
|||
async getPersonMentions(
|
||||
form: GetPersonMentions
|
||||
): Promise<GetPersonMentionsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/mention', form);
|
||||
return this.wrapper(HttpType.Get, "/user/mention", form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -559,98 +558,98 @@ export class LemmyHttp {
|
|||
async markPersonMentionAsRead(
|
||||
form: MarkPersonMentionAsRead
|
||||
): Promise<PersonMentionResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/mention/mark_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment replies.
|
||||
*/
|
||||
async getReplies(form: GetReplies): Promise<GetRepliesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/replies', form);
|
||||
return this.wrapper(HttpType.Get, "/user/replies", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban a person from your site.
|
||||
*/
|
||||
async banPerson(form: BanPerson): Promise<BanPersonResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/ban', form);
|
||||
return this.wrapper(HttpType.Post, "/user/ban", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a person.
|
||||
*/
|
||||
async blockPerson(form: BlockPerson): Promise<BlockPersonResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/block', form);
|
||||
return this.wrapper(HttpType.Post, "/user/block", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a Captcha.
|
||||
*/
|
||||
async getCaptcha(): Promise<GetCaptchaResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
||||
return this.wrapper(HttpType.Get, "/user/get_captcha", {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete your account.
|
||||
*/
|
||||
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/delete_account', form);
|
||||
return this.wrapper(HttpType.Post, "/user/delete_account", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset your password.
|
||||
*/
|
||||
async passwordReset(form: PasswordReset): Promise<PasswordResetResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/password_reset', form);
|
||||
return this.wrapper(HttpType.Post, "/user/password_reset", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your password from an email / token based reset.
|
||||
*/
|
||||
async passwordChange(form: PasswordChange): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/password_change', form);
|
||||
return this.wrapper(HttpType.Post, "/user/password_change", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark all replies as read.
|
||||
*/
|
||||
async markAllAsRead(form: MarkAllAsRead): Promise<GetRepliesResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/mark_all_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/user/mark_all_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save your user settings.
|
||||
*/
|
||||
async saveUserSettings(form: SaveUserSettings): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Put, '/user/save_user_settings', form);
|
||||
return this.wrapper(HttpType.Put, "/user/save_user_settings", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your user password.
|
||||
*/
|
||||
async changePassword(form: ChangePassword): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Put, '/user/change_password', form);
|
||||
return this.wrapper(HttpType.Put, "/user/change_password", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get counts for your reports
|
||||
*/
|
||||
async getReportCount(form: GetReportCount): Promise<GetReportCountResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/report_count', form);
|
||||
return this.wrapper(HttpType.Get, "/user/report_count", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your unread counts
|
||||
*/
|
||||
async getUnreadCount(form: GetUnreadCount): Promise<GetUnreadCountResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/unread_count', form);
|
||||
return this.wrapper(HttpType.Get, "/user/unread_count", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an admin to your site.
|
||||
*/
|
||||
async addAdmin(form: AddAdmin): Promise<AddAdminResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/add', form);
|
||||
return this.wrapper(HttpType.Post, "/admin/add", form);
|
||||
}
|
||||
|
||||
private buildFullUrl(endpoint: string): string {
|
||||
|
@ -665,14 +664,14 @@ export class LemmyHttp {
|
|||
if (type_ == HttpType.Get) {
|
||||
let getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
|
||||
return fetch(getUrl, {
|
||||
method: 'GET',
|
||||
method: "GET",
|
||||
headers: this.headers,
|
||||
}).then(d => d.json() as Promise<ResponseType>);
|
||||
} else {
|
||||
return fetch(this.buildFullUrl(endpoint), {
|
||||
method: type_,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
...this.headers,
|
||||
},
|
||||
body: JSON.stringify(form),
|
||||
|
@ -683,6 +682,6 @@ export class LemmyHttp {
|
|||
|
||||
function encodeGetParams(p: any): string {
|
||||
return Object.entries(p)
|
||||
.map(kv => kv.map(encodeURIComponent).join('='))
|
||||
.join('&');
|
||||
.map(kv => kv.map(encodeURIComponent).join("="))
|
||||
.join("&");
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export * from './interfaces';
|
||||
export * from './http';
|
||||
export * from './websocket';
|
||||
export * from "./http";
|
||||
export * from "./interfaces";
|
||||
export * from "./websocket";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CommentReportView, CommentView } from '../views';
|
||||
import { CommentReportView, CommentView } from "../views";
|
||||
|
||||
export interface CreateComment {
|
||||
content: string;
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
PersonViewSafe,
|
||||
} from '../views';
|
||||
} from "../views";
|
||||
|
||||
/**
|
||||
* You can use either `id` or `name` as an id.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export * from './comment';
|
||||
export * from './community';
|
||||
export * from './post';
|
||||
export * from './site';
|
||||
export * from './person';
|
||||
export * from './websocket';
|
||||
export * from "./comment";
|
||||
export * from "./community";
|
||||
export * from "./person";
|
||||
export * from "./post";
|
||||
export * from "./site";
|
||||
export * from "./websocket";
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {
|
||||
CommentView,
|
||||
CommunityModeratorView,
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
PersonMentionView,
|
||||
PersonViewSafe,
|
||||
} from '../views';
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
} from "../views";
|
||||
|
||||
export interface Login {
|
||||
username_or_email: string;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { SiteMetadata } from '..';
|
||||
import { SiteMetadata } from "..";
|
||||
import {
|
||||
CommunityView,
|
||||
CommentView,
|
||||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
PostReportView,
|
||||
PostView,
|
||||
} from '../views';
|
||||
} from "../views";
|
||||
|
||||
export interface CreatePost {
|
||||
name: string;
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
import {
|
||||
CommentView,
|
||||
CommunityBlockView,
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
LocalUserSettingsView,
|
||||
PersonBlockView,
|
||||
} from '../views';
|
||||
import {
|
||||
CommentView,
|
||||
CommunityView,
|
||||
LocalUserSettingsView,
|
||||
ModAddCommunityView,
|
||||
ModTransferCommunityView,
|
||||
ModAddView,
|
||||
ModBanFromCommunityView,
|
||||
ModBanView,
|
||||
|
@ -18,10 +14,12 @@ import {
|
|||
ModRemoveCommunityView,
|
||||
ModRemovePostView,
|
||||
ModStickyPostView,
|
||||
ModTransferCommunityView,
|
||||
PersonBlockView,
|
||||
PersonViewSafe,
|
||||
PostView,
|
||||
SiteView,
|
||||
PersonViewSafe,
|
||||
} from '../views';
|
||||
} from "../views";
|
||||
|
||||
/**
|
||||
* Search lemmy for different types of data.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export * from './api';
|
||||
export * from './aggregates';
|
||||
export * from './others';
|
||||
export * from './source';
|
||||
export * from './views';
|
||||
export * from "./aggregates";
|
||||
export * from "./api";
|
||||
export * from "./others";
|
||||
export * from "./source";
|
||||
export * from "./views";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const VERSION = 'v3';
|
||||
export const VERSION = "v3";
|
||||
|
||||
/**
|
||||
* All of the websocket operations available.
|
||||
|
@ -84,62 +84,62 @@ export enum SortType {
|
|||
/**
|
||||
* Posts sorted by the most recent comment.
|
||||
*/
|
||||
Active = 'Active',
|
||||
Active = "Active",
|
||||
/**
|
||||
* Posts sorted by the published time.
|
||||
*/
|
||||
Hot = 'Hot',
|
||||
New = 'New',
|
||||
Hot = "Hot",
|
||||
New = "New",
|
||||
/**
|
||||
* The top posts for this last day.
|
||||
*/
|
||||
TopDay = 'TopDay',
|
||||
TopDay = "TopDay",
|
||||
/**
|
||||
* The top posts for this last week.
|
||||
*/
|
||||
TopWeek = 'TopWeek',
|
||||
TopWeek = "TopWeek",
|
||||
/**
|
||||
* The top posts for this last month.
|
||||
*/
|
||||
TopMonth = 'TopMonth',
|
||||
TopMonth = "TopMonth",
|
||||
/**
|
||||
* The top posts for this last year.
|
||||
*/
|
||||
TopYear = 'TopYear',
|
||||
TopYear = "TopYear",
|
||||
/**
|
||||
* The top posts of all time.
|
||||
*/
|
||||
TopAll = 'TopAll',
|
||||
TopAll = "TopAll",
|
||||
/**
|
||||
* Posts sorted by the most comments.
|
||||
*/
|
||||
MostComments = 'MostComments',
|
||||
MostComments = "MostComments",
|
||||
/**
|
||||
* Posts sorted by the newest comments, with no necrobumping. IE a forum sort.
|
||||
*/
|
||||
NewComments = 'NewComments',
|
||||
NewComments = "NewComments",
|
||||
}
|
||||
|
||||
/**
|
||||
* The different listing types for post and comment fetches.
|
||||
*/
|
||||
export enum ListingType {
|
||||
All = 'All',
|
||||
Local = 'Local',
|
||||
Subscribed = 'Subscribed',
|
||||
Community = 'Community',
|
||||
All = "All",
|
||||
Local = "Local",
|
||||
Subscribed = "Subscribed",
|
||||
Community = "Community",
|
||||
}
|
||||
|
||||
/**
|
||||
* Search types for lemmy's search.
|
||||
*/
|
||||
export enum SearchType {
|
||||
All = 'All',
|
||||
Comments = 'Comments',
|
||||
Posts = 'Posts',
|
||||
Communities = 'Communities',
|
||||
Users = 'Users',
|
||||
Url = 'Url',
|
||||
All = "All",
|
||||
Comments = "Comments",
|
||||
Posts = "Posts",
|
||||
Communities = "Communities",
|
||||
Users = "Users",
|
||||
Url = "Url",
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import {
|
||||
CommentAggregates,
|
||||
CommunityAggregates,
|
||||
PersonAggregates,
|
||||
PostAggregates,
|
||||
SiteAggregates,
|
||||
PersonAggregates,
|
||||
} from './aggregates';
|
||||
} from "./aggregates";
|
||||
import {
|
||||
Comment,
|
||||
CommentReport,
|
||||
CommunitySafe,
|
||||
LocalUserSettings,
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModTransferCommunity,
|
||||
ModBan,
|
||||
ModBanFromCommunity,
|
||||
ModLockPost,
|
||||
|
@ -19,14 +19,14 @@ import {
|
|||
ModRemoveCommunity,
|
||||
ModRemovePost,
|
||||
ModStickyPost,
|
||||
ModTransferCommunity,
|
||||
PersonMention,
|
||||
PersonSafe,
|
||||
Post,
|
||||
PostReport,
|
||||
PrivateMessage,
|
||||
Site,
|
||||
PersonMention,
|
||||
PersonSafe,
|
||||
LocalUserSettings,
|
||||
} from './source';
|
||||
} from "./source";
|
||||
|
||||
export interface PersonViewSafe {
|
||||
person: PersonSafe;
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
RemoveComment,
|
||||
ResolveCommentReport,
|
||||
SaveComment,
|
||||
} from './interfaces/api/comment';
|
||||
} from "./interfaces/api/comment";
|
||||
import {
|
||||
AddModToCommunity,
|
||||
BanFromCommunity,
|
||||
|
@ -23,7 +23,31 @@ import {
|
|||
ListCommunities,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from './interfaces/api/community';
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
BlockPerson,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPersonDetails,
|
||||
GetPersonMentions,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
|
@ -39,7 +63,7 @@ import {
|
|||
ResolvePostReport,
|
||||
SavePost,
|
||||
StickyPost,
|
||||
} from './interfaces/api/post';
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
CreateSite,
|
||||
EditSite,
|
||||
|
@ -50,33 +74,9 @@ import {
|
|||
SaveSiteConfig,
|
||||
Search,
|
||||
TransferSite,
|
||||
} from './interfaces/api/site';
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetPersonDetails,
|
||||
GetPersonMentions,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
ChangePassword,
|
||||
BlockPerson,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
} from './interfaces/api/person';
|
||||
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
||||
import { UserOperation } from './interfaces/others';
|
||||
} from "./interfaces/api/site";
|
||||
import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
|
||||
import { UserOperation } from "./interfaces/others";
|
||||
|
||||
/**
|
||||
* Helps build lemmy websocket message requests, that you can use in your Websocket sends.
|
||||
|
|
Loading…
Reference in a new issue