Make private class properties actually private (#128)
* Make private class properties actually private * Update version in package.json
This commit is contained in:
parent
18777c5be2
commit
fa1c032835
3 changed files with 123 additions and 108 deletions
15
package.json
15
package.json
|
@ -1,13 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "lemmy-js-client",
|
"name": "lemmy-js-client",
|
||||||
"version": "0.17.2-rc.21",
|
"version": "0.17.2-rc.22",
|
||||||
"description": "A javascript / typescript client for Lemmy",
|
"description": "A javascript / typescript client for Lemmy",
|
||||||
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"author": "Dessalines <tyhou13@gmx.com>",
|
"author": "Dessalines <tyhou13@gmx.com>",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"files": ["/dist"],
|
"files": [
|
||||||
|
"/dist"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"docs": "typedoc src/index.ts",
|
"docs": "typedoc src/index.ts",
|
||||||
|
@ -15,8 +17,13 @@
|
||||||
"prepare": "yarn run build && husky install"
|
"prepare": "yarn run build && husky install"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{ts,tsx,js}": ["prettier --write", "eslint --fix"],
|
"*.{ts,tsx,js}": [
|
||||||
"package.json": ["sortpack"]
|
"prettier --write",
|
||||||
|
"eslint --fix"
|
||||||
|
],
|
||||||
|
"package.json": [
|
||||||
|
"sortpack"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
|
|
214
src/http.ts
214
src/http.ts
|
@ -145,9 +145,9 @@ enum HttpType {
|
||||||
* Helps build lemmy HTTP requests.
|
* Helps build lemmy HTTP requests.
|
||||||
*/
|
*/
|
||||||
export class LemmyHttp {
|
export class LemmyHttp {
|
||||||
private apiUrl: string;
|
#apiUrl: string;
|
||||||
private headers: { [key: string]: string } = {};
|
#headers: { [key: string]: string } = {};
|
||||||
private pictrsUrl: string;
|
#pictrsUrl: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new instance of LemmyHttp.
|
* Generates a new instance of LemmyHttp.
|
||||||
|
@ -155,11 +155,11 @@ export class LemmyHttp {
|
||||||
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
* @param headers optional headers. Should contain `x-real-ip` and `x-forwarded-for` .
|
||||||
*/
|
*/
|
||||||
constructor(baseUrl: string, headers?: { [key: string]: string }) {
|
constructor(baseUrl: string, headers?: { [key: string]: string }) {
|
||||||
this.apiUrl = `${baseUrl}/api/${VERSION}`;
|
this.#apiUrl = `${baseUrl}/api/${VERSION}`;
|
||||||
this.pictrsUrl = `${baseUrl}/pictrs/image`;
|
this.#pictrsUrl = `${baseUrl}/pictrs/image`;
|
||||||
|
|
||||||
if (headers) {
|
if (headers) {
|
||||||
this.headers = headers;
|
this.#headers = headers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /site`
|
* `HTTP.GET /site`
|
||||||
*/
|
*/
|
||||||
getSite(form: GetSite) {
|
getSite(form: GetSite) {
|
||||||
return this.wrapper<GetSite, GetSiteResponse>(HttpType.Get, "/site", form);
|
return this.#wrapper<GetSite, GetSiteResponse>(HttpType.Get, "/site", form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +178,11 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /site`
|
* `HTTP.POST /site`
|
||||||
*/
|
*/
|
||||||
createSite(form: CreateSite) {
|
createSite(form: CreateSite) {
|
||||||
return this.wrapper<CreateSite, SiteResponse>(HttpType.Post, "/site", form);
|
return this.#wrapper<CreateSite, SiteResponse>(
|
||||||
|
HttpType.Post,
|
||||||
|
"/site",
|
||||||
|
form
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,7 +191,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /site`
|
* `HTTP.PUT /site`
|
||||||
*/
|
*/
|
||||||
editSite(form: EditSite) {
|
editSite(form: EditSite) {
|
||||||
return this.wrapper<EditSite, SiteResponse>(HttpType.Put, "/site", form);
|
return this.#wrapper<EditSite, SiteResponse>(HttpType.Put, "/site", form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +200,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/leave_admin`
|
* `HTTP.POST /user/leave_admin`
|
||||||
*/
|
*/
|
||||||
leaveAdmin(form: LeaveAdmin) {
|
leaveAdmin(form: LeaveAdmin) {
|
||||||
return this.wrapper<LeaveAdmin, GetSiteResponse>(
|
return this.#wrapper<LeaveAdmin, GetSiteResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/leave_admin",
|
"/user/leave_admin",
|
||||||
form
|
form
|
||||||
|
@ -209,7 +213,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /modlog`
|
* `HTTP.GET /modlog`
|
||||||
*/
|
*/
|
||||||
getModlog(form: GetModlog) {
|
getModlog(form: GetModlog) {
|
||||||
return this.wrapper<GetModlog, GetModlogResponse>(
|
return this.#wrapper<GetModlog, GetModlogResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/modlog",
|
"/modlog",
|
||||||
form
|
form
|
||||||
|
@ -222,7 +226,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /search`
|
* `HTTP.GET /search`
|
||||||
*/
|
*/
|
||||||
search(form: Search) {
|
search(form: Search) {
|
||||||
return this.wrapper<Search, SearchResponse>(HttpType.Get, "/search", form);
|
return this.#wrapper<Search, SearchResponse>(HttpType.Get, "/search", form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,7 +235,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /resolve_object`
|
* `HTTP.GET /resolve_object`
|
||||||
*/
|
*/
|
||||||
resolveObject(form: ResolveObject) {
|
resolveObject(form: ResolveObject) {
|
||||||
return this.wrapper<ResolveObject, ResolveObjectResponse>(
|
return this.#wrapper<ResolveObject, ResolveObjectResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/resolve_object",
|
"/resolve_object",
|
||||||
form
|
form
|
||||||
|
@ -244,7 +248,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community`
|
* `HTTP.POST /community`
|
||||||
*/
|
*/
|
||||||
createCommunity(form: CreateCommunity) {
|
createCommunity(form: CreateCommunity) {
|
||||||
return this.wrapper<CreateCommunity, CommunityResponse>(
|
return this.#wrapper<CreateCommunity, CommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community",
|
"/community",
|
||||||
form
|
form
|
||||||
|
@ -257,7 +261,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /community`
|
* `HTTP.GET /community`
|
||||||
*/
|
*/
|
||||||
getCommunity(form: GetCommunity) {
|
getCommunity(form: GetCommunity) {
|
||||||
return this.wrapper<GetCommunity, GetCommunityResponse>(
|
return this.#wrapper<GetCommunity, GetCommunityResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/community",
|
"/community",
|
||||||
form
|
form
|
||||||
|
@ -270,7 +274,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /community`
|
* `HTTP.PUT /community`
|
||||||
*/
|
*/
|
||||||
editCommunity(form: EditCommunity) {
|
editCommunity(form: EditCommunity) {
|
||||||
return this.wrapper<EditCommunity, CommunityResponse>(
|
return this.#wrapper<EditCommunity, CommunityResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/community",
|
"/community",
|
||||||
form
|
form
|
||||||
|
@ -283,7 +287,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /community/list`
|
* `HTTP.GET /community/list`
|
||||||
*/
|
*/
|
||||||
listCommunities(form: ListCommunities) {
|
listCommunities(form: ListCommunities) {
|
||||||
return this.wrapper<ListCommunities, ListCommunitiesResponse>(
|
return this.#wrapper<ListCommunities, ListCommunitiesResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/community/list",
|
"/community/list",
|
||||||
form
|
form
|
||||||
|
@ -296,7 +300,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/follow`
|
* `HTTP.POST /community/follow`
|
||||||
*/
|
*/
|
||||||
followCommunity(form: FollowCommunity) {
|
followCommunity(form: FollowCommunity) {
|
||||||
return this.wrapper<FollowCommunity, CommunityResponse>(
|
return this.#wrapper<FollowCommunity, CommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/follow",
|
"/community/follow",
|
||||||
form
|
form
|
||||||
|
@ -309,7 +313,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/block`
|
* `HTTP.POST /community/block`
|
||||||
*/
|
*/
|
||||||
blockCommunity(form: BlockCommunity) {
|
blockCommunity(form: BlockCommunity) {
|
||||||
return this.wrapper<BlockCommunity, BlockCommunityResponse>(
|
return this.#wrapper<BlockCommunity, BlockCommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/block",
|
"/community/block",
|
||||||
form
|
form
|
||||||
|
@ -322,7 +326,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/delete`
|
* `HTTP.POST /community/delete`
|
||||||
*/
|
*/
|
||||||
deleteCommunity(form: DeleteCommunity) {
|
deleteCommunity(form: DeleteCommunity) {
|
||||||
return this.wrapper<DeleteCommunity, CommunityResponse>(
|
return this.#wrapper<DeleteCommunity, CommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/delete",
|
"/community/delete",
|
||||||
form
|
form
|
||||||
|
@ -335,7 +339,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/remove`
|
* `HTTP.POST /community/remove`
|
||||||
*/
|
*/
|
||||||
removeCommunity(form: RemoveCommunity) {
|
removeCommunity(form: RemoveCommunity) {
|
||||||
return this.wrapper<RemoveCommunity, CommunityResponse>(
|
return this.#wrapper<RemoveCommunity, CommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/remove",
|
"/community/remove",
|
||||||
form
|
form
|
||||||
|
@ -348,7 +352,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/transfer`
|
* `HTTP.POST /community/transfer`
|
||||||
*/
|
*/
|
||||||
transferCommunity(form: TransferCommunity) {
|
transferCommunity(form: TransferCommunity) {
|
||||||
return this.wrapper<TransferCommunity, GetCommunityResponse>(
|
return this.#wrapper<TransferCommunity, GetCommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/transfer",
|
"/community/transfer",
|
||||||
form
|
form
|
||||||
|
@ -361,7 +365,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/ban_user`
|
* `HTTP.POST /community/ban_user`
|
||||||
*/
|
*/
|
||||||
banFromCommunity(form: BanFromCommunity) {
|
banFromCommunity(form: BanFromCommunity) {
|
||||||
return this.wrapper<BanFromCommunity, BanFromCommunityResponse>(
|
return this.#wrapper<BanFromCommunity, BanFromCommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/ban_user",
|
"/community/ban_user",
|
||||||
form
|
form
|
||||||
|
@ -374,7 +378,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /community/mod`
|
* `HTTP.POST /community/mod`
|
||||||
*/
|
*/
|
||||||
addModToCommunity(form: AddModToCommunity) {
|
addModToCommunity(form: AddModToCommunity) {
|
||||||
return this.wrapper<AddModToCommunity, AddModToCommunityResponse>(
|
return this.#wrapper<AddModToCommunity, AddModToCommunityResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/community/mod",
|
"/community/mod",
|
||||||
form
|
form
|
||||||
|
@ -387,7 +391,11 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post`
|
* `HTTP.POST /post`
|
||||||
*/
|
*/
|
||||||
createPost(form: CreatePost) {
|
createPost(form: CreatePost) {
|
||||||
return this.wrapper<CreatePost, PostResponse>(HttpType.Post, "/post", form);
|
return this.#wrapper<CreatePost, PostResponse>(
|
||||||
|
HttpType.Post,
|
||||||
|
"/post",
|
||||||
|
form
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,7 +404,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /post`
|
* `HTTP.GET /post`
|
||||||
*/
|
*/
|
||||||
getPost(form: GetPost) {
|
getPost(form: GetPost) {
|
||||||
return this.wrapper<GetPost, GetPostResponse>(HttpType.Get, "/post", form);
|
return this.#wrapper<GetPost, GetPostResponse>(HttpType.Get, "/post", form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -405,7 +413,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /post`
|
* `HTTP.PUT /post`
|
||||||
*/
|
*/
|
||||||
editPost(form: EditPost) {
|
editPost(form: EditPost) {
|
||||||
return this.wrapper<EditPost, PostResponse>(HttpType.Put, "/post", form);
|
return this.#wrapper<EditPost, PostResponse>(HttpType.Put, "/post", form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -414,7 +422,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/delete`
|
* `HTTP.POST /post/delete`
|
||||||
*/
|
*/
|
||||||
deletePost(form: DeletePost) {
|
deletePost(form: DeletePost) {
|
||||||
return this.wrapper<DeletePost, PostResponse>(
|
return this.#wrapper<DeletePost, PostResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/delete",
|
"/post/delete",
|
||||||
form
|
form
|
||||||
|
@ -427,7 +435,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/remove`
|
* `HTTP.POST /post/remove`
|
||||||
*/
|
*/
|
||||||
removePost(form: RemovePost) {
|
removePost(form: RemovePost) {
|
||||||
return this.wrapper<RemovePost, PostResponse>(
|
return this.#wrapper<RemovePost, PostResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/remove",
|
"/post/remove",
|
||||||
form
|
form
|
||||||
|
@ -440,7 +448,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/mark_as_read`
|
* `HTTP.POST /post/mark_as_read`
|
||||||
*/
|
*/
|
||||||
markPostAsRead(form: MarkPostAsRead) {
|
markPostAsRead(form: MarkPostAsRead) {
|
||||||
return this.wrapper<MarkPostAsRead, PostResponse>(
|
return this.#wrapper<MarkPostAsRead, PostResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/mark_as_read",
|
"/post/mark_as_read",
|
||||||
form
|
form
|
||||||
|
@ -453,7 +461,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/lock`
|
* `HTTP.POST /post/lock`
|
||||||
*/
|
*/
|
||||||
lockPost(form: LockPost) {
|
lockPost(form: LockPost) {
|
||||||
return this.wrapper<LockPost, PostResponse>(
|
return this.#wrapper<LockPost, PostResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/lock",
|
"/post/lock",
|
||||||
form
|
form
|
||||||
|
@ -466,7 +474,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/feature`
|
* `HTTP.POST /post/feature`
|
||||||
*/
|
*/
|
||||||
featurePost(form: FeaturePost) {
|
featurePost(form: FeaturePost) {
|
||||||
return this.wrapper<FeaturePost, PostResponse>(
|
return this.#wrapper<FeaturePost, PostResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/feature",
|
"/post/feature",
|
||||||
form
|
form
|
||||||
|
@ -479,7 +487,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /post/list`
|
* `HTTP.GET /post/list`
|
||||||
*/
|
*/
|
||||||
getPosts(form: GetPosts) {
|
getPosts(form: GetPosts) {
|
||||||
return this.wrapper<GetPosts, GetPostsResponse>(
|
return this.#wrapper<GetPosts, GetPostsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/post/list",
|
"/post/list",
|
||||||
form
|
form
|
||||||
|
@ -492,7 +500,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/like`
|
* `HTTP.POST /post/like`
|
||||||
*/
|
*/
|
||||||
likePost(form: CreatePostLike) {
|
likePost(form: CreatePostLike) {
|
||||||
return this.wrapper<CreatePostLike, PostResponse>(
|
return this.#wrapper<CreatePostLike, PostResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/like",
|
"/post/like",
|
||||||
form
|
form
|
||||||
|
@ -505,7 +513,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /post/save`
|
* `HTTP.PUT /post/save`
|
||||||
*/
|
*/
|
||||||
savePost(form: SavePost) {
|
savePost(form: SavePost) {
|
||||||
return this.wrapper<SavePost, PostResponse>(
|
return this.#wrapper<SavePost, PostResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/post/save",
|
"/post/save",
|
||||||
form
|
form
|
||||||
|
@ -518,7 +526,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /post/report`
|
* `HTTP.POST /post/report`
|
||||||
*/
|
*/
|
||||||
createPostReport(form: CreatePostReport) {
|
createPostReport(form: CreatePostReport) {
|
||||||
return this.wrapper<CreatePostReport, PostReportResponse>(
|
return this.#wrapper<CreatePostReport, PostReportResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/post/report",
|
"/post/report",
|
||||||
form
|
form
|
||||||
|
@ -531,7 +539,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /post/report/resolve`
|
* `HTTP.PUT /post/report/resolve`
|
||||||
*/
|
*/
|
||||||
resolvePostReport(form: ResolvePostReport) {
|
resolvePostReport(form: ResolvePostReport) {
|
||||||
return this.wrapper<ResolvePostReport, PostReportResponse>(
|
return this.#wrapper<ResolvePostReport, PostReportResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/post/report/resolve",
|
"/post/report/resolve",
|
||||||
form
|
form
|
||||||
|
@ -544,7 +552,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /post/report/list`
|
* `HTTP.GET /post/report/list`
|
||||||
*/
|
*/
|
||||||
listPostReports(form: ListPostReports) {
|
listPostReports(form: ListPostReports) {
|
||||||
return this.wrapper<ListPostReports, ListPostReportsResponse>(
|
return this.#wrapper<ListPostReports, ListPostReportsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/post/report/list",
|
"/post/report/list",
|
||||||
form
|
form
|
||||||
|
@ -557,7 +565,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /post/site_metadata`
|
* `HTTP.GET /post/site_metadata`
|
||||||
*/
|
*/
|
||||||
getSiteMetadata(form: GetSiteMetadata) {
|
getSiteMetadata(form: GetSiteMetadata) {
|
||||||
return this.wrapper<GetSiteMetadata, GetSiteMetadataResponse>(
|
return this.#wrapper<GetSiteMetadata, GetSiteMetadataResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/post/site_metadata",
|
"/post/site_metadata",
|
||||||
form
|
form
|
||||||
|
@ -570,7 +578,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment`
|
* `HTTP.POST /comment`
|
||||||
*/
|
*/
|
||||||
createComment(form: CreateComment) {
|
createComment(form: CreateComment) {
|
||||||
return this.wrapper<CreateComment, CommentResponse>(
|
return this.#wrapper<CreateComment, CommentResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment",
|
"/comment",
|
||||||
form
|
form
|
||||||
|
@ -583,7 +591,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /comment`
|
* `HTTP.PUT /comment`
|
||||||
*/
|
*/
|
||||||
editComment(form: EditComment) {
|
editComment(form: EditComment) {
|
||||||
return this.wrapper<EditComment, CommentResponse>(
|
return this.#wrapper<EditComment, CommentResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/comment",
|
"/comment",
|
||||||
form
|
form
|
||||||
|
@ -596,7 +604,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment/delete`
|
* `HTTP.POST /comment/delete`
|
||||||
*/
|
*/
|
||||||
deleteComment(form: DeleteComment) {
|
deleteComment(form: DeleteComment) {
|
||||||
return this.wrapper<DeleteComment, CommentResponse>(
|
return this.#wrapper<DeleteComment, CommentResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment/delete",
|
"/comment/delete",
|
||||||
form
|
form
|
||||||
|
@ -609,7 +617,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment/remove`
|
* `HTTP.POST /comment/remove`
|
||||||
*/
|
*/
|
||||||
removeComment(form: RemoveComment) {
|
removeComment(form: RemoveComment) {
|
||||||
return this.wrapper<RemoveComment, CommentResponse>(
|
return this.#wrapper<RemoveComment, CommentResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment/remove",
|
"/comment/remove",
|
||||||
form
|
form
|
||||||
|
@ -622,7 +630,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment/mark_as_read`
|
* `HTTP.POST /comment/mark_as_read`
|
||||||
*/
|
*/
|
||||||
markCommentReplyAsRead(form: MarkCommentReplyAsRead) {
|
markCommentReplyAsRead(form: MarkCommentReplyAsRead) {
|
||||||
return this.wrapper<MarkCommentReplyAsRead, CommentReplyResponse>(
|
return this.#wrapper<MarkCommentReplyAsRead, CommentReplyResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment/mark_as_read",
|
"/comment/mark_as_read",
|
||||||
form
|
form
|
||||||
|
@ -635,7 +643,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment/like`
|
* `HTTP.POST /comment/like`
|
||||||
*/
|
*/
|
||||||
likeComment(form: CreateCommentLike) {
|
likeComment(form: CreateCommentLike) {
|
||||||
return this.wrapper<CreateCommentLike, CommentResponse>(
|
return this.#wrapper<CreateCommentLike, CommentResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment/like",
|
"/comment/like",
|
||||||
form
|
form
|
||||||
|
@ -648,7 +656,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /comment/save`
|
* `HTTP.PUT /comment/save`
|
||||||
*/
|
*/
|
||||||
saveComment(form: SaveComment) {
|
saveComment(form: SaveComment) {
|
||||||
return this.wrapper<SaveComment, CommentResponse>(
|
return this.#wrapper<SaveComment, CommentResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/comment/save",
|
"/comment/save",
|
||||||
form
|
form
|
||||||
|
@ -661,7 +669,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment/distinguish`
|
* `HTTP.POST /comment/distinguish`
|
||||||
*/
|
*/
|
||||||
distinguishComment(form: DistinguishComment) {
|
distinguishComment(form: DistinguishComment) {
|
||||||
return this.wrapper<DistinguishComment, CommentResponse>(
|
return this.#wrapper<DistinguishComment, CommentResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment/distinguish",
|
"/comment/distinguish",
|
||||||
form
|
form
|
||||||
|
@ -674,7 +682,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /comment/list`
|
* `HTTP.GET /comment/list`
|
||||||
*/
|
*/
|
||||||
getComments(form: GetComments) {
|
getComments(form: GetComments) {
|
||||||
return this.wrapper<GetComments, GetCommentsResponse>(
|
return this.#wrapper<GetComments, GetCommentsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/comment/list",
|
"/comment/list",
|
||||||
form
|
form
|
||||||
|
@ -687,7 +695,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /comment`
|
* `HTTP.GET /comment`
|
||||||
*/
|
*/
|
||||||
getComment(form: GetComment) {
|
getComment(form: GetComment) {
|
||||||
return this.wrapper<GetComment, CommentResponse>(
|
return this.#wrapper<GetComment, CommentResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/comment",
|
"/comment",
|
||||||
form
|
form
|
||||||
|
@ -700,7 +708,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /comment/report`
|
* `HTTP.POST /comment/report`
|
||||||
*/
|
*/
|
||||||
createCommentReport(form: CreateCommentReport) {
|
createCommentReport(form: CreateCommentReport) {
|
||||||
return this.wrapper<CreateCommentReport, CommentReportResponse>(
|
return this.#wrapper<CreateCommentReport, CommentReportResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/comment/report",
|
"/comment/report",
|
||||||
form
|
form
|
||||||
|
@ -713,7 +721,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /comment/report/resolve`
|
* `HTTP.PUT /comment/report/resolve`
|
||||||
*/
|
*/
|
||||||
resolveCommentReport(form: ResolveCommentReport) {
|
resolveCommentReport(form: ResolveCommentReport) {
|
||||||
return this.wrapper<ResolveCommentReport, CommentReportResponse>(
|
return this.#wrapper<ResolveCommentReport, CommentReportResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/comment/report/resolve",
|
"/comment/report/resolve",
|
||||||
form
|
form
|
||||||
|
@ -726,7 +734,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /comment/report/list`
|
* `HTTP.GET /comment/report/list`
|
||||||
*/
|
*/
|
||||||
listCommentReports(form: ListCommentReports) {
|
listCommentReports(form: ListCommentReports) {
|
||||||
return this.wrapper<ListCommentReports, ListCommentReportsResponse>(
|
return this.#wrapper<ListCommentReports, ListCommentReportsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/comment/report/list",
|
"/comment/report/list",
|
||||||
form
|
form
|
||||||
|
@ -739,7 +747,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /private_message/list`
|
* `HTTP.GET /private_message/list`
|
||||||
*/
|
*/
|
||||||
getPrivateMessages(form: GetPrivateMessages) {
|
getPrivateMessages(form: GetPrivateMessages) {
|
||||||
return this.wrapper<GetPrivateMessages, PrivateMessagesResponse>(
|
return this.#wrapper<GetPrivateMessages, PrivateMessagesResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/private_message/list",
|
"/private_message/list",
|
||||||
form
|
form
|
||||||
|
@ -752,7 +760,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /private_message`
|
* `HTTP.POST /private_message`
|
||||||
*/
|
*/
|
||||||
createPrivateMessage(form: CreatePrivateMessage) {
|
createPrivateMessage(form: CreatePrivateMessage) {
|
||||||
return this.wrapper<CreatePrivateMessage, PrivateMessageResponse>(
|
return this.#wrapper<CreatePrivateMessage, PrivateMessageResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/private_message",
|
"/private_message",
|
||||||
form
|
form
|
||||||
|
@ -765,7 +773,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /private_message`
|
* `HTTP.PUT /private_message`
|
||||||
*/
|
*/
|
||||||
editPrivateMessage(form: EditPrivateMessage) {
|
editPrivateMessage(form: EditPrivateMessage) {
|
||||||
return this.wrapper<EditPrivateMessage, PrivateMessageResponse>(
|
return this.#wrapper<EditPrivateMessage, PrivateMessageResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/private_message",
|
"/private_message",
|
||||||
form
|
form
|
||||||
|
@ -778,7 +786,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /private_message/delete`
|
* `HTTP.POST /private_message/delete`
|
||||||
*/
|
*/
|
||||||
deletePrivateMessage(form: DeletePrivateMessage) {
|
deletePrivateMessage(form: DeletePrivateMessage) {
|
||||||
return this.wrapper<DeletePrivateMessage, PrivateMessageResponse>(
|
return this.#wrapper<DeletePrivateMessage, PrivateMessageResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/private_message/delete",
|
"/private_message/delete",
|
||||||
form
|
form
|
||||||
|
@ -791,7 +799,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /private_message/mark_as_read`
|
* `HTTP.POST /private_message/mark_as_read`
|
||||||
*/
|
*/
|
||||||
markPrivateMessageAsRead(form: MarkPrivateMessageAsRead) {
|
markPrivateMessageAsRead(form: MarkPrivateMessageAsRead) {
|
||||||
return this.wrapper<MarkPrivateMessageAsRead, PrivateMessageResponse>(
|
return this.#wrapper<MarkPrivateMessageAsRead, PrivateMessageResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/private_message/mark_as_read",
|
"/private_message/mark_as_read",
|
||||||
form
|
form
|
||||||
|
@ -804,7 +812,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /private_message/report`
|
* `HTTP.POST /private_message/report`
|
||||||
*/
|
*/
|
||||||
createPrivateMessageReport(form: CreatePrivateMessageReport) {
|
createPrivateMessageReport(form: CreatePrivateMessageReport) {
|
||||||
return this.wrapper<
|
return this.#wrapper<
|
||||||
CreatePrivateMessageReport,
|
CreatePrivateMessageReport,
|
||||||
PrivateMessageReportResponse
|
PrivateMessageReportResponse
|
||||||
>(HttpType.Post, "/private_message/report", form);
|
>(HttpType.Post, "/private_message/report", form);
|
||||||
|
@ -816,7 +824,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /private_message/report/resolve`
|
* `HTTP.PUT /private_message/report/resolve`
|
||||||
*/
|
*/
|
||||||
resolvePrivateMessageReport(form: ResolvePrivateMessageReport) {
|
resolvePrivateMessageReport(form: ResolvePrivateMessageReport) {
|
||||||
return this.wrapper<
|
return this.#wrapper<
|
||||||
ResolvePrivateMessageReport,
|
ResolvePrivateMessageReport,
|
||||||
PrivateMessageReportResponse
|
PrivateMessageReportResponse
|
||||||
>(HttpType.Put, "/private_message/report/resolve", form);
|
>(HttpType.Put, "/private_message/report/resolve", form);
|
||||||
|
@ -828,7 +836,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /private_message/report/list`
|
* `HTTP.GET /private_message/report/list`
|
||||||
*/
|
*/
|
||||||
listPrivateMessageReports(form: ListPrivateMessageReports) {
|
listPrivateMessageReports(form: ListPrivateMessageReports) {
|
||||||
return this.wrapper<
|
return this.#wrapper<
|
||||||
ListPrivateMessageReports,
|
ListPrivateMessageReports,
|
||||||
ListPrivateMessageReportsResponse
|
ListPrivateMessageReportsResponse
|
||||||
>(HttpType.Get, "/private_message/report/list", form);
|
>(HttpType.Get, "/private_message/report/list", form);
|
||||||
|
@ -840,7 +848,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/register`
|
* `HTTP.POST /user/register`
|
||||||
*/
|
*/
|
||||||
register(form: Register) {
|
register(form: Register) {
|
||||||
return this.wrapper<Register, LoginResponse>(
|
return this.#wrapper<Register, LoginResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/register",
|
"/user/register",
|
||||||
form
|
form
|
||||||
|
@ -853,7 +861,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/login`
|
* `HTTP.POST /user/login`
|
||||||
*/
|
*/
|
||||||
login(form: Login) {
|
login(form: Login) {
|
||||||
return this.wrapper<Login, LoginResponse>(
|
return this.#wrapper<Login, LoginResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/login",
|
"/user/login",
|
||||||
form
|
form
|
||||||
|
@ -866,7 +874,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user`
|
* `HTTP.GET /user`
|
||||||
*/
|
*/
|
||||||
getPersonDetails(form: GetPersonDetails) {
|
getPersonDetails(form: GetPersonDetails) {
|
||||||
return this.wrapper<GetPersonDetails, GetPersonDetailsResponse>(
|
return this.#wrapper<GetPersonDetails, GetPersonDetailsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user",
|
"/user",
|
||||||
form
|
form
|
||||||
|
@ -879,7 +887,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user/mention`
|
* `HTTP.GET /user/mention`
|
||||||
*/
|
*/
|
||||||
getPersonMentions(form: GetPersonMentions) {
|
getPersonMentions(form: GetPersonMentions) {
|
||||||
return this.wrapper<GetPersonMentions, GetPersonMentionsResponse>(
|
return this.#wrapper<GetPersonMentions, GetPersonMentionsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user/mention",
|
"/user/mention",
|
||||||
form
|
form
|
||||||
|
@ -892,7 +900,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/mention/mark_as_read`
|
* `HTTP.POST /user/mention/mark_as_read`
|
||||||
*/
|
*/
|
||||||
markPersonMentionAsRead(form: MarkPersonMentionAsRead) {
|
markPersonMentionAsRead(form: MarkPersonMentionAsRead) {
|
||||||
return this.wrapper<MarkPersonMentionAsRead, PersonMentionResponse>(
|
return this.#wrapper<MarkPersonMentionAsRead, PersonMentionResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/mention/mark_as_read",
|
"/user/mention/mark_as_read",
|
||||||
form
|
form
|
||||||
|
@ -905,7 +913,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user/replies`
|
* `HTTP.GET /user/replies`
|
||||||
*/
|
*/
|
||||||
getReplies(form: GetReplies) {
|
getReplies(form: GetReplies) {
|
||||||
return this.wrapper<GetReplies, GetRepliesResponse>(
|
return this.#wrapper<GetReplies, GetRepliesResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user/replies",
|
"/user/replies",
|
||||||
form
|
form
|
||||||
|
@ -918,7 +926,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/ban`
|
* `HTTP.POST /user/ban`
|
||||||
*/
|
*/
|
||||||
banPerson(form: BanPerson) {
|
banPerson(form: BanPerson) {
|
||||||
return this.wrapper<BanPerson, BanPersonResponse>(
|
return this.#wrapper<BanPerson, BanPersonResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/ban",
|
"/user/ban",
|
||||||
form
|
form
|
||||||
|
@ -931,7 +939,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user/banned`
|
* `HTTP.GET /user/banned`
|
||||||
*/
|
*/
|
||||||
getBannedPersons(form: GetBannedPersons) {
|
getBannedPersons(form: GetBannedPersons) {
|
||||||
return this.wrapper<GetBannedPersons, BannedPersonsResponse>(
|
return this.#wrapper<GetBannedPersons, BannedPersonsResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user/banned",
|
"/user/banned",
|
||||||
form
|
form
|
||||||
|
@ -944,7 +952,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/block`
|
* `HTTP.POST /user/block`
|
||||||
*/
|
*/
|
||||||
blockPerson(form: BlockPerson) {
|
blockPerson(form: BlockPerson) {
|
||||||
return this.wrapper<BlockPerson, BlockPersonResponse>(
|
return this.#wrapper<BlockPerson, BlockPersonResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/block",
|
"/user/block",
|
||||||
form
|
form
|
||||||
|
@ -957,7 +965,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user/get_captcha`
|
* `HTTP.GET /user/get_captcha`
|
||||||
*/
|
*/
|
||||||
getCaptcha(form: GetCaptcha) {
|
getCaptcha(form: GetCaptcha) {
|
||||||
return this.wrapper<GetCaptcha, GetCaptchaResponse>(
|
return this.#wrapper<GetCaptcha, GetCaptchaResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user/get_captcha",
|
"/user/get_captcha",
|
||||||
form
|
form
|
||||||
|
@ -970,7 +978,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/delete_account`
|
* `HTTP.POST /user/delete_account`
|
||||||
*/
|
*/
|
||||||
deleteAccount(form: DeleteAccount) {
|
deleteAccount(form: DeleteAccount) {
|
||||||
return this.wrapper<DeleteAccount, DeleteAccountResponse>(
|
return this.#wrapper<DeleteAccount, DeleteAccountResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/delete_account",
|
"/user/delete_account",
|
||||||
form
|
form
|
||||||
|
@ -983,7 +991,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/password_reset`
|
* `HTTP.POST /user/password_reset`
|
||||||
*/
|
*/
|
||||||
passwordReset(form: PasswordReset) {
|
passwordReset(form: PasswordReset) {
|
||||||
return this.wrapper<PasswordReset, PasswordResetResponse>(
|
return this.#wrapper<PasswordReset, PasswordResetResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/password_reset",
|
"/user/password_reset",
|
||||||
form
|
form
|
||||||
|
@ -996,7 +1004,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/password_change`
|
* `HTTP.POST /user/password_change`
|
||||||
*/
|
*/
|
||||||
passwordChangeAfterReset(form: PasswordChangeAfterReset) {
|
passwordChangeAfterReset(form: PasswordChangeAfterReset) {
|
||||||
return this.wrapper<PasswordChangeAfterReset, LoginResponse>(
|
return this.#wrapper<PasswordChangeAfterReset, LoginResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/password_change",
|
"/user/password_change",
|
||||||
form
|
form
|
||||||
|
@ -1009,7 +1017,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/mark_all_as_read`
|
* `HTTP.POST /user/mark_all_as_read`
|
||||||
*/
|
*/
|
||||||
markAllAsRead(form: MarkAllAsRead) {
|
markAllAsRead(form: MarkAllAsRead) {
|
||||||
return this.wrapper<MarkAllAsRead, GetRepliesResponse>(
|
return this.#wrapper<MarkAllAsRead, GetRepliesResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/mark_all_as_read",
|
"/user/mark_all_as_read",
|
||||||
form
|
form
|
||||||
|
@ -1022,7 +1030,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /user/save_user_settings`
|
* `HTTP.PUT /user/save_user_settings`
|
||||||
*/
|
*/
|
||||||
saveUserSettings(form: SaveUserSettings) {
|
saveUserSettings(form: SaveUserSettings) {
|
||||||
return this.wrapper<SaveUserSettings, LoginResponse>(
|
return this.#wrapper<SaveUserSettings, LoginResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/user/save_user_settings",
|
"/user/save_user_settings",
|
||||||
form
|
form
|
||||||
|
@ -1035,7 +1043,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /user/change_password`
|
* `HTTP.PUT /user/change_password`
|
||||||
*/
|
*/
|
||||||
changePassword(form: ChangePassword) {
|
changePassword(form: ChangePassword) {
|
||||||
return this.wrapper<ChangePassword, LoginResponse>(
|
return this.#wrapper<ChangePassword, LoginResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/user/change_password",
|
"/user/change_password",
|
||||||
form
|
form
|
||||||
|
@ -1048,7 +1056,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user/report_count`
|
* `HTTP.GET /user/report_count`
|
||||||
*/
|
*/
|
||||||
getReportCount(form: GetReportCount) {
|
getReportCount(form: GetReportCount) {
|
||||||
return this.wrapper<GetReportCount, GetReportCountResponse>(
|
return this.#wrapper<GetReportCount, GetReportCountResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user/report_count",
|
"/user/report_count",
|
||||||
form
|
form
|
||||||
|
@ -1061,7 +1069,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /user/unread_count`
|
* `HTTP.GET /user/unread_count`
|
||||||
*/
|
*/
|
||||||
getUnreadCount(form: GetUnreadCount) {
|
getUnreadCount(form: GetUnreadCount) {
|
||||||
return this.wrapper<GetUnreadCount, GetUnreadCountResponse>(
|
return this.#wrapper<GetUnreadCount, GetUnreadCountResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/user/unread_count",
|
"/user/unread_count",
|
||||||
form
|
form
|
||||||
|
@ -1074,7 +1082,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /user/verify_email`
|
* `HTTP.POST /user/verify_email`
|
||||||
*/
|
*/
|
||||||
verifyEmail(form: VerifyEmail) {
|
verifyEmail(form: VerifyEmail) {
|
||||||
return this.wrapper<VerifyEmail, VerifyEmailResponse>(
|
return this.#wrapper<VerifyEmail, VerifyEmailResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/user/verify_email",
|
"/user/verify_email",
|
||||||
form
|
form
|
||||||
|
@ -1087,7 +1095,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /admin/add`
|
* `HTTP.POST /admin/add`
|
||||||
*/
|
*/
|
||||||
addAdmin(form: AddAdmin) {
|
addAdmin(form: AddAdmin) {
|
||||||
return this.wrapper<AddAdmin, AddAdminResponse>(
|
return this.#wrapper<AddAdmin, AddAdminResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/admin/add",
|
"/admin/add",
|
||||||
form
|
form
|
||||||
|
@ -1102,7 +1110,7 @@ export class LemmyHttp {
|
||||||
getUnreadRegistrationApplicationCount(
|
getUnreadRegistrationApplicationCount(
|
||||||
form: GetUnreadRegistrationApplicationCount
|
form: GetUnreadRegistrationApplicationCount
|
||||||
) {
|
) {
|
||||||
return this.wrapper<
|
return this.#wrapper<
|
||||||
GetUnreadRegistrationApplicationCount,
|
GetUnreadRegistrationApplicationCount,
|
||||||
GetUnreadRegistrationApplicationCountResponse
|
GetUnreadRegistrationApplicationCountResponse
|
||||||
>(HttpType.Get, "/admin/registration_application/count", form);
|
>(HttpType.Get, "/admin/registration_application/count", form);
|
||||||
|
@ -1114,7 +1122,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.GET /admin/registration_application/list`
|
* `HTTP.GET /admin/registration_application/list`
|
||||||
*/
|
*/
|
||||||
listRegistrationApplications(form: ListRegistrationApplications) {
|
listRegistrationApplications(form: ListRegistrationApplications) {
|
||||||
return this.wrapper<
|
return this.#wrapper<
|
||||||
ListRegistrationApplications,
|
ListRegistrationApplications,
|
||||||
ListRegistrationApplicationsResponse
|
ListRegistrationApplicationsResponse
|
||||||
>(HttpType.Get, "/admin/registration_application/list", form);
|
>(HttpType.Get, "/admin/registration_application/list", form);
|
||||||
|
@ -1126,7 +1134,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /admin/registration_application/approve`
|
* `HTTP.PUT /admin/registration_application/approve`
|
||||||
*/
|
*/
|
||||||
approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
||||||
return this.wrapper<
|
return this.#wrapper<
|
||||||
ApproveRegistrationApplication,
|
ApproveRegistrationApplication,
|
||||||
RegistrationApplicationResponse
|
RegistrationApplicationResponse
|
||||||
>(HttpType.Put, "/admin/registration_application/approve", form);
|
>(HttpType.Put, "/admin/registration_application/approve", form);
|
||||||
|
@ -1138,7 +1146,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /admin/purge/person`
|
* `HTTP.POST /admin/purge/person`
|
||||||
*/
|
*/
|
||||||
purgePerson(form: PurgePerson) {
|
purgePerson(form: PurgePerson) {
|
||||||
return this.wrapper<PurgePerson, PurgeItemResponse>(
|
return this.#wrapper<PurgePerson, PurgeItemResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/admin/purge/person",
|
"/admin/purge/person",
|
||||||
form
|
form
|
||||||
|
@ -1151,7 +1159,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /admin/purge/community`
|
* `HTTP.POST /admin/purge/community`
|
||||||
*/
|
*/
|
||||||
purgeCommunity(form: PurgeCommunity) {
|
purgeCommunity(form: PurgeCommunity) {
|
||||||
return this.wrapper<PurgeCommunity, PurgeItemResponse>(
|
return this.#wrapper<PurgeCommunity, PurgeItemResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/admin/purge/community",
|
"/admin/purge/community",
|
||||||
form
|
form
|
||||||
|
@ -1164,7 +1172,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /admin/purge/post`
|
* `HTTP.POST /admin/purge/post`
|
||||||
*/
|
*/
|
||||||
purgePost(form: PurgePost) {
|
purgePost(form: PurgePost) {
|
||||||
return this.wrapper<PurgePost, PurgeItemResponse>(
|
return this.#wrapper<PurgePost, PurgeItemResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/admin/purge/post",
|
"/admin/purge/post",
|
||||||
form
|
form
|
||||||
|
@ -1177,7 +1185,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /admin/purge/comment`
|
* `HTTP.POST /admin/purge/comment`
|
||||||
*/
|
*/
|
||||||
purgeComment(form: PurgeComment) {
|
purgeComment(form: PurgeComment) {
|
||||||
return this.wrapper<PurgeComment, PurgeItemResponse>(
|
return this.#wrapper<PurgeComment, PurgeItemResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/admin/purge/comment",
|
"/admin/purge/comment",
|
||||||
form
|
form
|
||||||
|
@ -1190,7 +1198,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.POST /custom_emoji`
|
* `HTTP.POST /custom_emoji`
|
||||||
*/
|
*/
|
||||||
async createCustomEmoji(form: CreateCustomEmoji) {
|
async createCustomEmoji(form: CreateCustomEmoji) {
|
||||||
return this.wrapper<CreateCustomEmoji, CustomEmojiResponse>(
|
return this.#wrapper<CreateCustomEmoji, CustomEmojiResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/custom_emoji",
|
"/custom_emoji",
|
||||||
form
|
form
|
||||||
|
@ -1203,7 +1211,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.PUT /custom_emoji`
|
* `HTTP.PUT /custom_emoji`
|
||||||
*/
|
*/
|
||||||
async editCustomEmoji(form: EditCustomEmoji) {
|
async editCustomEmoji(form: EditCustomEmoji) {
|
||||||
return this.wrapper<EditCustomEmoji, CustomEmojiResponse>(
|
return this.#wrapper<EditCustomEmoji, CustomEmojiResponse>(
|
||||||
HttpType.Put,
|
HttpType.Put,
|
||||||
"/custom_emoji",
|
"/custom_emoji",
|
||||||
form
|
form
|
||||||
|
@ -1216,7 +1224,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.Post /custom_emoji/delete`
|
* `HTTP.Post /custom_emoji/delete`
|
||||||
*/
|
*/
|
||||||
async deleteCustomEmoji(form: DeleteCustomEmoji) {
|
async deleteCustomEmoji(form: DeleteCustomEmoji) {
|
||||||
return this.wrapper<DeleteCustomEmoji, DeleteCustomEmojiResponse>(
|
return this.#wrapper<DeleteCustomEmoji, DeleteCustomEmojiResponse>(
|
||||||
HttpType.Post,
|
HttpType.Post,
|
||||||
"/custom_emoji/delete",
|
"/custom_emoji/delete",
|
||||||
form
|
form
|
||||||
|
@ -1229,7 +1237,7 @@ export class LemmyHttp {
|
||||||
* `HTTP.Get /federated_instances`
|
* `HTTP.Get /federated_instances`
|
||||||
*/
|
*/
|
||||||
async getFederatedInstances(form: GetFederatedInstances) {
|
async getFederatedInstances(form: GetFederatedInstances) {
|
||||||
return this.wrapper<GetFederatedInstances, GetFederatedInstancesResponse>(
|
return this.#wrapper<GetFederatedInstances, GetFederatedInstancesResponse>(
|
||||||
HttpType.Get,
|
HttpType.Get,
|
||||||
"/federated_instances",
|
"/federated_instances",
|
||||||
form
|
form
|
||||||
|
@ -1249,7 +1257,7 @@ export class LemmyHttp {
|
||||||
const headers = {} as any;
|
const headers = {} as any;
|
||||||
if (
|
if (
|
||||||
!globalThis?.document?.cookie?.includes("jwt=") &&
|
!globalThis?.document?.cookie?.includes("jwt=") &&
|
||||||
!this.headers?.Cookie?.includes("jwt=")
|
!this.#headers?.Cookie?.includes("jwt=")
|
||||||
) {
|
) {
|
||||||
headers.Cookie = `jwt=${auth}`;
|
headers.Cookie = `jwt=${auth}`;
|
||||||
}
|
}
|
||||||
|
@ -1257,11 +1265,11 @@ export class LemmyHttp {
|
||||||
let url: string | undefined = undefined;
|
let url: string | undefined = undefined;
|
||||||
let delete_url: string | undefined = undefined;
|
let delete_url: string | undefined = undefined;
|
||||||
|
|
||||||
const response = await fetch(this.pictrsUrl, {
|
const response = await fetch(this.#pictrsUrl, {
|
||||||
method: HttpType.Post,
|
method: HttpType.Post,
|
||||||
body: formData as unknown as BodyInit,
|
body: formData as unknown as BodyInit,
|
||||||
headers: {
|
headers: {
|
||||||
...this.headers,
|
...this.#headers,
|
||||||
...headers,
|
...headers,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1270,8 +1278,8 @@ export class LemmyHttp {
|
||||||
|
|
||||||
if (responseJson.msg === "ok") {
|
if (responseJson.msg === "ok") {
|
||||||
const { file: hash, delete_token: deleteToken } = responseJson.files[0];
|
const { file: hash, delete_token: deleteToken } = responseJson.files[0];
|
||||||
delete_url = `${this.pictrsUrl}/delete/${deleteToken}/${hash}`;
|
delete_url = `${this.#pictrsUrl}/delete/${deleteToken}/${hash}`;
|
||||||
url = `${this.pictrsUrl}/${hash}`;
|
url = `${this.#pictrsUrl}/${hash}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1281,28 +1289,28 @@ export class LemmyHttp {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildFullUrl(endpoint: string) {
|
#buildFullUrl(endpoint: string) {
|
||||||
return `${this.apiUrl}${endpoint}`;
|
return `${this.#apiUrl}${endpoint}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async wrapper<BodyType extends object, ResponseType>(
|
async #wrapper<BodyType extends object, ResponseType>(
|
||||||
type_: HttpType,
|
type_: HttpType,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
form: BodyType
|
form: BodyType
|
||||||
): Promise<ResponseType> {
|
): Promise<ResponseType> {
|
||||||
let response: Response;
|
let response: Response;
|
||||||
if (type_ === HttpType.Get) {
|
if (type_ === HttpType.Get) {
|
||||||
const getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
|
const getUrl = `${this.#buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
|
||||||
response = await fetch(getUrl, {
|
response = await fetch(getUrl, {
|
||||||
method: HttpType.Get,
|
method: HttpType.Get,
|
||||||
headers: this.headers,
|
headers: this.#headers,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
response = await fetch(this.buildFullUrl(endpoint), {
|
response = await 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),
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"lib": ["es2017", "es7", "es6", "dom"],
|
"lib": ["es2017", "es7", "es6", "dom"],
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"target": "ES5",
|
"target": "ES2015",
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
|
|
Loading…
Reference in a new issue