Running prettier.

This commit is contained in:
Dessalines 2021-12-06 14:41:08 -05:00
parent a630b76bf0
commit 0be709aa08
12 changed files with 209 additions and 212 deletions

View file

@ -1,4 +1,4 @@
import fetch from 'node-fetch'; import fetch from "node-fetch";
import { import {
CommentReportResponse, CommentReportResponse,
CommentResponse, CommentResponse,
@ -15,7 +15,7 @@ import {
RemoveComment, RemoveComment,
ResolveCommentReport, ResolveCommentReport,
SaveComment, SaveComment,
} from './interfaces/api/comment'; } from "./interfaces/api/comment";
import { import {
AddModToCommunity, AddModToCommunity,
AddModToCommunityResponse, AddModToCommunityResponse,
@ -34,10 +34,49 @@ import {
ListCommunitiesResponse, ListCommunitiesResponse,
RemoveCommunity, RemoveCommunity,
TransferCommunity, 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 { import {
CreatePost, CreatePost,
CreatePostLike, CreatePostLike,
CreatePostReport,
DeletePost, DeletePost,
EditPost, EditPost,
GetPost, GetPost,
@ -46,17 +85,16 @@ import {
GetPostsResponse, GetPostsResponse,
GetSiteMetadata, GetSiteMetadata,
GetSiteMetadataResponse, GetSiteMetadataResponse,
ListPostReports,
ListPostReportsResponse,
LockPost, LockPost,
CreatePostReport,
PostReportResponse, PostReportResponse,
PostResponse, PostResponse,
RemovePost, RemovePost,
ResolvePostReport,
SavePost, SavePost,
StickyPost, StickyPost,
ResolvePostReport, } from "./interfaces/api/post";
ListPostReports,
ListPostReportsResponse,
} from './interfaces/api/post';
import { import {
CreateSite, CreateSite,
EditSite, EditSite,
@ -73,52 +111,13 @@ import {
SearchResponse, SearchResponse,
SiteResponse, SiteResponse,
TransferSite, TransferSite,
} from './interfaces/api/site'; } from "./interfaces/api/site";
import { import { VERSION } from "./interfaces/others";
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';
enum HttpType { enum HttpType {
Get = 'GET', Get = "GET",
Post = 'POST', Post = "POST",
Put = 'PUT', Put = "PUT",
} }
/** /**
@ -145,84 +144,84 @@ export class LemmyHttp {
* Gets the site, and your user data. * Gets the site, and your user data.
*/ */
async getSite(form: GetSite): Promise<GetSiteResponse> { async getSite(form: GetSite): Promise<GetSiteResponse> {
return this.wrapper(HttpType.Get, '/site', form); return this.wrapper(HttpType.Get, "/site", form);
} }
/** /**
* Create your site. * Create your site.
*/ */
async createSite(form: CreateSite): Promise<SiteResponse> { async createSite(form: CreateSite): Promise<SiteResponse> {
return this.wrapper(HttpType.Post, '/site', form); return this.wrapper(HttpType.Post, "/site", form);
} }
/** /**
* Edit your site. * Edit your site.
*/ */
async editSite(form: EditSite): Promise<SiteResponse> { 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. * Transfer your site to another user.
*/ */
async transferSite(form: TransferSite): Promise<GetSiteResponse> { 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. * Get your site configuration.
*/ */
async getSiteConfig(form: GetSiteConfig): Promise<GetSiteConfigResponse> { 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. * Save your site config.
*/ */
async saveSiteConfig(form: SaveSiteConfig): Promise<GetSiteConfigResponse> { 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. * Get the modlog.
*/ */
async getModlog(form: GetModlog): Promise<GetModlogResponse> { async getModlog(form: GetModlog): Promise<GetModlogResponse> {
return this.wrapper(HttpType.Get, '/modlog', form); return this.wrapper(HttpType.Get, "/modlog", form);
} }
/** /**
* Search lemmy. * Search lemmy.
*/ */
async search(form: Search): Promise<SearchResponse> { 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. * Fetch a non-local / federated object.
*/ */
async resolveObject(form: ResolveObject): Promise<ResolveObjectResponse> { 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. * Create a new community.
*/ */
async createCommunity(form: CreateCommunity): Promise<CommunityResponse> { async createCommunity(form: CreateCommunity): Promise<CommunityResponse> {
return this.wrapper(HttpType.Post, '/community', form); return this.wrapper(HttpType.Post, "/community", form);
} }
/** /**
* Get / fetch a community. * Get / fetch a community.
*/ */
async getCommunity(form: GetCommunity): Promise<GetCommunityResponse> { async getCommunity(form: GetCommunity): Promise<GetCommunityResponse> {
return this.wrapper(HttpType.Get, '/community', form); return this.wrapper(HttpType.Get, "/community", form);
} }
/** /**
* Edit a community. * Edit a community.
*/ */
async editCommunity(form: EditCommunity): Promise<CommunityResponse> { 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( async listCommunities(
form: ListCommunities form: ListCommunities
): Promise<ListCommunitiesResponse> { ): Promise<ListCommunitiesResponse> {
return this.wrapper(HttpType.Get, '/community/list', form); return this.wrapper(HttpType.Get, "/community/list", form);
} }
/** /**
* Follow / subscribe to a community. * Follow / subscribe to a community.
*/ */
async followCommunity(form: FollowCommunity): Promise<CommunityResponse> { 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. * Block a community.
*/ */
async blockCommunity(form: BlockCommunity): Promise<BlockCommunityResponse> { 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. * Delete a community.
*/ */
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> { 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. * A moderator remove for a community.
*/ */
async removeCommunity(form: RemoveCommunity): Promise<CommunityResponse> { 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( async transferCommunity(
form: TransferCommunity form: TransferCommunity
): Promise<GetCommunityResponse> { ): 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( async banFromCommunity(
form: BanFromCommunity form: BanFromCommunity
): Promise<BanFromCommunityResponse> { ): 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( async addModToCommunity(
form: AddModToCommunity form: AddModToCommunity
): Promise<AddModToCommunityResponse> { ): Promise<AddModToCommunityResponse> {
return this.wrapper(HttpType.Post, '/community/mod', form); return this.wrapper(HttpType.Post, "/community/mod", form);
} }
/** /**
* Create a post. * Create a post.
*/ */
async createPost(form: CreatePost): Promise<PostResponse> { async createPost(form: CreatePost): Promise<PostResponse> {
return this.wrapper(HttpType.Post, '/post', form); return this.wrapper(HttpType.Post, "/post", form);
} }
/** /**
* Get / fetch a post. * Get / fetch a post.
*/ */
async getPost(form: GetPost): Promise<GetPostResponse> { async getPost(form: GetPost): Promise<GetPostResponse> {
return this.wrapper(HttpType.Get, '/post', form); return this.wrapper(HttpType.Get, "/post", form);
} }
/** /**
* Edit a post. * Edit a post.
*/ */
async editPost(form: EditPost): Promise<PostResponse> { async editPost(form: EditPost): Promise<PostResponse> {
return this.wrapper(HttpType.Put, '/post', form); return this.wrapper(HttpType.Put, "/post", form);
} }
/** /**
* Delete a post. * Delete a post.
*/ */
async deletePost(form: DeletePost): Promise<PostResponse> { 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. * A moderator remove for a post.
*/ */
async removePost(form: RemovePost): Promise<PostResponse> { 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 ). * A moderator can lock a post ( IE disable new comments ).
*/ */
async lockPost(form: LockPost): Promise<PostResponse> { 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 ). * A moderator can sticky a post ( IE stick it to the top of a community ).
*/ */
async stickyPost(form: StickyPost): Promise<PostResponse> { 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. * Get / fetch posts, with various filters.
*/ */
async getPosts(form: GetPosts): Promise<GetPostsResponse> { 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. * Like / vote on a post.
*/ */
async likePost(form: CreatePostLike): Promise<PostResponse> { 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. * Save a post.
*/ */
async savePost(form: SavePost): Promise<PostResponse> { 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. * Report a post.
*/ */
async createPostReport(form: CreatePostReport): Promise<PostReportResponse> { 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( async resolvePostReport(
form: ResolvePostReport form: ResolvePostReport
): Promise<PostReportResponse> { ): 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( async listPostReports(
form: ListPostReports form: ListPostReports
): Promise<ListPostReportsResponse> { ): 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( async getSiteMetadata(
form: GetSiteMetadata form: GetSiteMetadata
): Promise<GetSiteMetadataResponse> { ): Promise<GetSiteMetadataResponse> {
return this.wrapper(HttpType.Get, '/post/site_metadata', form); return this.wrapper(HttpType.Get, "/post/site_metadata", form);
} }
/** /**
* Create a comment. * Create a comment.
*/ */
async createComment(form: CreateComment): Promise<CommentResponse> { async createComment(form: CreateComment): Promise<CommentResponse> {
return this.wrapper(HttpType.Post, '/comment', form); return this.wrapper(HttpType.Post, "/comment", form);
} }
/** /**
* Edit a comment. * Edit a comment.
*/ */
async editComment(form: EditComment): Promise<CommentResponse> { async editComment(form: EditComment): Promise<CommentResponse> {
return this.wrapper(HttpType.Put, '/comment', form); return this.wrapper(HttpType.Put, "/comment", form);
} }
/** /**
* Delete a comment. * Delete a comment.
*/ */
async deleteComment(form: DeleteComment): Promise<CommentResponse> { 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. * A moderator remove for a comment.
*/ */
async removeComment(form: RemoveComment): Promise<CommentResponse> { 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. * Mark a comment as read.
*/ */
async markCommentAsRead(form: MarkCommentAsRead): Promise<CommentResponse> { 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. * Like / vote on a comment.
*/ */
async likeComment(form: CreateCommentLike): Promise<CommentResponse> { 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. * Save a comment.
*/ */
async saveComment(form: SaveComment): Promise<CommentResponse> { 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. * Get / fetch comments.
*/ */
async getComments(form: GetComments): Promise<GetCommentsResponse> { 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( async createCommentReport(
form: CreateCommentReport form: CreateCommentReport
): Promise<CommentReportResponse> { ): 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( async resolveCommentReport(
form: ResolveCommentReport form: ResolveCommentReport
): Promise<CommentReportResponse> { ): 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( async listCommentReports(
form: ListCommentReports form: ListCommentReports
): Promise<ListCommentReportsResponse> { ): 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( async getPrivateMessages(
form: GetPrivateMessages form: GetPrivateMessages
): Promise<PrivateMessagesResponse> { ): 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( async createPrivateMessage(
form: CreatePrivateMessage form: CreatePrivateMessage
): Promise<PrivateMessageResponse> { ): 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( async editPrivateMessage(
form: EditPrivateMessage form: EditPrivateMessage
): Promise<PrivateMessageResponse> { ): 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( async deletePrivateMessage(
form: DeletePrivateMessage form: DeletePrivateMessage
): Promise<PrivateMessageResponse> { ): 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( async markPrivateMessageAsRead(
form: MarkPrivateMessageAsRead form: MarkPrivateMessageAsRead
): Promise<PrivateMessageResponse> { ): 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. * Register a new user.
*/ */
async register(form: Register): Promise<LoginResponse> { 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. * Log into lemmy.
*/ */
async login(form: Login): Promise<LoginResponse> { 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( async getPersonDetails(
form: GetPersonDetails form: GetPersonDetails
): Promise<GetPersonDetailsResponse> { ): 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( async getPersonMentions(
form: GetPersonMentions form: GetPersonMentions
): Promise<GetPersonMentionsResponse> { ): 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( async markPersonMentionAsRead(
form: MarkPersonMentionAsRead form: MarkPersonMentionAsRead
): Promise<PersonMentionResponse> { ): 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. * Get comment replies.
*/ */
async getReplies(form: GetReplies): Promise<GetRepliesResponse> { 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. * Ban a person from your site.
*/ */
async banPerson(form: BanPerson): Promise<BanPersonResponse> { 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. * Block a person.
*/ */
async blockPerson(form: BlockPerson): Promise<BlockPersonResponse> { 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. * Fetch a Captcha.
*/ */
async getCaptcha(): Promise<GetCaptchaResponse> { async getCaptcha(): Promise<GetCaptchaResponse> {
return this.wrapper(HttpType.Get, '/user/get_captcha', {}); return this.wrapper(HttpType.Get, "/user/get_captcha", {});
} }
/** /**
* Delete your account. * Delete your account.
*/ */
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> { 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. * Reset your password.
*/ */
async passwordReset(form: PasswordReset): Promise<PasswordResetResponse> { 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. * Change your password from an email / token based reset.
*/ */
async passwordChange(form: PasswordChange): Promise<LoginResponse> { 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. * Mark all replies as read.
*/ */
async markAllAsRead(form: MarkAllAsRead): Promise<GetRepliesResponse> { 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. * Save your user settings.
*/ */
async saveUserSettings(form: SaveUserSettings): Promise<LoginResponse> { 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. * Change your user password.
*/ */
async changePassword(form: ChangePassword): Promise<LoginResponse> { 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 * Get counts for your reports
*/ */
async getReportCount(form: GetReportCount): Promise<GetReportCountResponse> { 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 * Get your unread counts
*/ */
async getUnreadCount(form: GetUnreadCount): Promise<GetUnreadCountResponse> { 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. * Add an admin to your site.
*/ */
async addAdmin(form: AddAdmin): Promise<AddAdminResponse> { 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 { private buildFullUrl(endpoint: string): string {
@ -665,14 +664,14 @@ export class LemmyHttp {
if (type_ == HttpType.Get) { if (type_ == HttpType.Get) {
let getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`; let getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
return fetch(getUrl, { return fetch(getUrl, {
method: 'GET', method: "GET",
headers: this.headers, headers: this.headers,
}).then(d => d.json() as Promise<ResponseType>); }).then(d => d.json() as Promise<ResponseType>);
} else { } else {
return fetch(this.buildFullUrl(endpoint), { return fetch(this.buildFullUrl(endpoint), {
method: type_, method: type_,
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
...this.headers, ...this.headers,
}, },
body: JSON.stringify(form), body: JSON.stringify(form),
@ -683,6 +682,6 @@ export class LemmyHttp {
function encodeGetParams(p: any): string { function encodeGetParams(p: any): string {
return Object.entries(p) return Object.entries(p)
.map(kv => kv.map(encodeURIComponent).join('=')) .map(kv => kv.map(encodeURIComponent).join("="))
.join('&'); .join("&");
} }

View file

@ -1,3 +1,3 @@
export * from './interfaces'; export * from "./http";
export * from './http'; export * from "./interfaces";
export * from './websocket'; export * from "./websocket";

View file

@ -1,4 +1,4 @@
import { CommentReportView, CommentView } from '../views'; import { CommentReportView, CommentView } from "../views";
export interface CreateComment { export interface CreateComment {
content: string; content: string;

View file

@ -2,7 +2,7 @@ import {
CommunityModeratorView, CommunityModeratorView,
CommunityView, CommunityView,
PersonViewSafe, PersonViewSafe,
} from '../views'; } from "../views";
/** /**
* You can use either `id` or `name` as an id. * You can use either `id` or `name` as an id.

View file

@ -1,6 +1,6 @@
export * from './comment'; export * from "./comment";
export * from './community'; export * from "./community";
export * from './post'; export * from "./person";
export * from './site'; export * from "./post";
export * from './person'; export * from "./site";
export * from './websocket'; export * from "./websocket";

View file

@ -1,11 +1,11 @@
import { import {
CommentView, CommentView,
CommunityModeratorView, CommunityModeratorView,
PostView,
PrivateMessageView,
PersonMentionView, PersonMentionView,
PersonViewSafe, PersonViewSafe,
} from '../views'; PostView,
PrivateMessageView,
} from "../views";
export interface Login { export interface Login {
username_or_email: string; username_or_email: string;

View file

@ -1,11 +1,11 @@
import { SiteMetadata } from '..'; import { SiteMetadata } from "..";
import { import {
CommunityView,
CommentView, CommentView,
CommunityModeratorView, CommunityModeratorView,
CommunityView,
PostReportView, PostReportView,
PostView, PostView,
} from '../views'; } from "../views";
export interface CreatePost { export interface CreatePost {
name: string; name: string;

View file

@ -1,15 +1,11 @@
import { import {
CommentView,
CommunityBlockView, CommunityBlockView,
CommunityFollowerView, CommunityFollowerView,
CommunityModeratorView, CommunityModeratorView,
LocalUserSettingsView,
PersonBlockView,
} from '../views';
import {
CommentView,
CommunityView, CommunityView,
LocalUserSettingsView,
ModAddCommunityView, ModAddCommunityView,
ModTransferCommunityView,
ModAddView, ModAddView,
ModBanFromCommunityView, ModBanFromCommunityView,
ModBanView, ModBanView,
@ -18,10 +14,12 @@ import {
ModRemoveCommunityView, ModRemoveCommunityView,
ModRemovePostView, ModRemovePostView,
ModStickyPostView, ModStickyPostView,
ModTransferCommunityView,
PersonBlockView,
PersonViewSafe,
PostView, PostView,
SiteView, SiteView,
PersonViewSafe, } from "../views";
} from '../views';
/** /**
* Search lemmy for different types of data. * Search lemmy for different types of data.

View file

@ -1,5 +1,5 @@
export * from './api'; export * from "./aggregates";
export * from './aggregates'; export * from "./api";
export * from './others'; export * from "./others";
export * from './source'; export * from "./source";
export * from './views'; export * from "./views";

View file

@ -1,4 +1,4 @@
export const VERSION = 'v3'; export const VERSION = "v3";
/** /**
* All of the websocket operations available. * All of the websocket operations available.
@ -84,62 +84,62 @@ export enum SortType {
/** /**
* Posts sorted by the most recent comment. * Posts sorted by the most recent comment.
*/ */
Active = 'Active', Active = "Active",
/** /**
* Posts sorted by the published time. * Posts sorted by the published time.
*/ */
Hot = 'Hot', Hot = "Hot",
New = 'New', New = "New",
/** /**
* The top posts for this last day. * The top posts for this last day.
*/ */
TopDay = 'TopDay', TopDay = "TopDay",
/** /**
* The top posts for this last week. * The top posts for this last week.
*/ */
TopWeek = 'TopWeek', TopWeek = "TopWeek",
/** /**
* The top posts for this last month. * The top posts for this last month.
*/ */
TopMonth = 'TopMonth', TopMonth = "TopMonth",
/** /**
* The top posts for this last year. * The top posts for this last year.
*/ */
TopYear = 'TopYear', TopYear = "TopYear",
/** /**
* The top posts of all time. * The top posts of all time.
*/ */
TopAll = 'TopAll', TopAll = "TopAll",
/** /**
* Posts sorted by the most comments. * Posts sorted by the most comments.
*/ */
MostComments = 'MostComments', MostComments = "MostComments",
/** /**
* Posts sorted by the newest comments, with no necrobumping. IE a forum sort. * 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. * The different listing types for post and comment fetches.
*/ */
export enum ListingType { export enum ListingType {
All = 'All', All = "All",
Local = 'Local', Local = "Local",
Subscribed = 'Subscribed', Subscribed = "Subscribed",
Community = 'Community', Community = "Community",
} }
/** /**
* Search types for lemmy's search. * Search types for lemmy's search.
*/ */
export enum SearchType { export enum SearchType {
All = 'All', All = "All",
Comments = 'Comments', Comments = "Comments",
Posts = 'Posts', Posts = "Posts",
Communities = 'Communities', Communities = "Communities",
Users = 'Users', Users = "Users",
Url = 'Url', Url = "Url",
} }
/** /**

View file

@ -1,17 +1,17 @@
import { import {
CommentAggregates, CommentAggregates,
CommunityAggregates, CommunityAggregates,
PersonAggregates,
PostAggregates, PostAggregates,
SiteAggregates, SiteAggregates,
PersonAggregates, } from "./aggregates";
} from './aggregates';
import { import {
Comment, Comment,
CommentReport, CommentReport,
CommunitySafe, CommunitySafe,
LocalUserSettings,
ModAdd, ModAdd,
ModAddCommunity, ModAddCommunity,
ModTransferCommunity,
ModBan, ModBan,
ModBanFromCommunity, ModBanFromCommunity,
ModLockPost, ModLockPost,
@ -19,14 +19,14 @@ import {
ModRemoveCommunity, ModRemoveCommunity,
ModRemovePost, ModRemovePost,
ModStickyPost, ModStickyPost,
ModTransferCommunity,
PersonMention,
PersonSafe,
Post, Post,
PostReport, PostReport,
PrivateMessage, PrivateMessage,
Site, Site,
PersonMention, } from "./source";
PersonSafe,
LocalUserSettings,
} from './source';
export interface PersonViewSafe { export interface PersonViewSafe {
person: PersonSafe; person: PersonSafe;

View file

@ -10,7 +10,7 @@ import {
RemoveComment, RemoveComment,
ResolveCommentReport, ResolveCommentReport,
SaveComment, SaveComment,
} from './interfaces/api/comment'; } from "./interfaces/api/comment";
import { import {
AddModToCommunity, AddModToCommunity,
BanFromCommunity, BanFromCommunity,
@ -23,7 +23,31 @@ import {
ListCommunities, ListCommunities,
RemoveCommunity, RemoveCommunity,
TransferCommunity, 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 { import {
CreatePost, CreatePost,
CreatePostLike, CreatePostLike,
@ -39,7 +63,7 @@ import {
ResolvePostReport, ResolvePostReport,
SavePost, SavePost,
StickyPost, StickyPost,
} from './interfaces/api/post'; } from "./interfaces/api/post";
import { import {
CreateSite, CreateSite,
EditSite, EditSite,
@ -50,33 +74,9 @@ import {
SaveSiteConfig, SaveSiteConfig,
Search, Search,
TransferSite, TransferSite,
} from './interfaces/api/site'; } from "./interfaces/api/site";
import { import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
AddAdmin, import { UserOperation } from "./interfaces/others";
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';
/** /**
* Helps build lemmy websocket message requests, that you can use in your Websocket sends. * Helps build lemmy websocket message requests, that you can use in your Websocket sends.