import { LemmyHttp } from 'lemmy-js-client' import type { BaseClient, ClientType } from '../base' import { fromGetPosts, toListingType } from './rewrite' export class LemmyClient implements BaseClient { type: ClientType = { name: 'lemmy', baseUrl: '/api/v3' } #client: LemmyHttp constructor( baseUrl: string, args: { fetchFunction: (input: any, init: any) => Promise headers: any }, ) { this.#client = new LemmyHttp(baseUrl, args) } async getSite( ...params: Parameters ): ReturnType { return await this.#client.getSite(...params) } async generateTotpSecret( ...params: Parameters ): ReturnType { return await this.#client.generateTotpSecret(...params) } async listLogins( ...params: Parameters ): ReturnType { return await this.#client.listLogins(...params) } async listAllMedia( ...params: Parameters ): ReturnType { return await this.#client.listAllMedia(...params) } async updateTotp( ...params: Parameters ): ReturnType { return await this.#client.updateTotp(...params) } async getModlog( ...params: Parameters ): ReturnType { return await this.#client.getModlog(...params) } async search( params: Parameters[0], ): ReturnType { return await this.#client.search({ ...params, listing_type: toListingType(params.listing_type), }) } async resolveObject( ...params: Parameters ): ReturnType { return await this.#client.resolveObject(...params) } async createCommunity( ...params: Parameters ): ReturnType { return await this.#client.createCommunity(...params) } async getCommunity( ...params: Parameters ): ReturnType { return await this.#client.getCommunity(...params) } async editCommunity( ...params: Parameters ): ReturnType { return await this.#client.editCommunity(...params) } async listCommunities( params: Parameters[0], ): ReturnType { return await this.#client.listCommunities({ ...params, type_: toListingType(params.type_), }) } async followCommunity( ...params: Parameters ): ReturnType { return await this.#client.followCommunity(...params) } async blockCommunity( ...params: Parameters ): ReturnType { return await this.#client.blockCommunity(...params) } async deleteCommunity( ...params: Parameters ): ReturnType { return await this.#client.deleteCommunity(...params) } async hideCommunity( ...params: Parameters ): ReturnType { return await this.#client.hideCommunity(...params) } async removeCommunity( ...params: Parameters ): ReturnType { return await this.#client.removeCommunity(...params) } async banFromCommunity( ...params: Parameters ): ReturnType { return await this.#client.banFromCommunity(...params) } async addModToCommunity( ...params: Parameters ): ReturnType { return await this.#client.addModToCommunity(...params) } async createPost( ...params: Parameters ): ReturnType { return await this.#client.createPost(...params) } async getPost( ...params: Parameters ): ReturnType { return await this.#client.getPost(...params) } async editPost( ...params: Parameters ): ReturnType { return await this.#client.editPost(...params) } async deletePost( ...params: Parameters ): ReturnType { return await this.#client.deletePost(...params) } async removePost( ...params: Parameters ): ReturnType { return await this.#client.removePost(...params) } async markPostAsRead( ...params: Parameters ): ReturnType { return await this.#client.markPostAsRead(...params) } async hidePost( ...params: Parameters ): ReturnType { return await this.#client.hidePost(...params) } async lockPost( ...params: Parameters ): ReturnType { return await this.#client.lockPost(...params) } async featurePost( ...params: Parameters ): ReturnType { return await this.#client.featurePost(...params) } async getPosts( params: Parameters[0], ): ReturnType { return await this.#client.getPosts(fromGetPosts(params)) } async likePost( ...params: Parameters ): ReturnType { return await this.#client.likePost(...params) } async listPostLikes( ...params: Parameters ): ReturnType { return await this.#client.listPostLikes(...params) } async savePost( ...params: Parameters ): ReturnType { return await this.#client.savePost(...params) } async createPostReport( ...params: Parameters ): ReturnType { return await this.#client.createPostReport(...params) } async resolvePostReport( ...params: Parameters ): ReturnType { return await this.#client.resolvePostReport(...params) } async listPostReports( ...params: Parameters ): ReturnType { return await this.#client.listPostReports(...params) } async getSiteMetadata( ...params: Parameters ): ReturnType { return await this.#client.getSiteMetadata(...params) } async createComment( ...params: Parameters ): ReturnType { return await this.#client.createComment(...params) } async editComment( ...params: Parameters ): ReturnType { return await this.#client.editComment(...params) } async deleteComment( ...params: Parameters ): ReturnType { return await this.#client.deleteComment(...params) } async removeComment( ...params: Parameters ): ReturnType { return await this.#client.removeComment(...params) } async markCommentReplyAsRead( ...params: Parameters ): ReturnType { return await this.#client.markCommentReplyAsRead(...params) } async likeComment( ...params: Parameters ): ReturnType { return await this.#client.likeComment(...params) } async listCommentLikes( ...params: Parameters ): ReturnType { return await this.#client.listCommentLikes(...params) } async saveComment( ...params: Parameters ): ReturnType { return await this.#client.saveComment(...params) } async distinguishComment( ...params: Parameters ): ReturnType { return await this.#client.distinguishComment(...params) } async getComments( params: Parameters[0], ): ReturnType { return await this.#client.getComments({ ...params, type_: toListingType(params.type_), }) } async getComment( ...params: Parameters ): ReturnType { return await this.#client.getComment(...params) } async createCommentReport( ...params: Parameters ): ReturnType { return await this.#client.createCommentReport(...params) } async resolveCommentReport( ...params: Parameters ): ReturnType { return await this.#client.resolveCommentReport(...params) } async listCommentReports( ...params: Parameters ): ReturnType { return await this.#client.listCommentReports(...params) } async getPrivateMessages( ...params: Parameters ): ReturnType { return await this.#client.getPrivateMessages(...params) } async createPrivateMessage( ...params: Parameters ): ReturnType { return await this.#client.createPrivateMessage(...params) } async editPrivateMessage( ...params: Parameters ): ReturnType { return await this.#client.editPrivateMessage(...params) } async deletePrivateMessage( ...params: Parameters ): ReturnType { return await this.#client.deletePrivateMessage(...params) } async markPrivateMessageAsRead( ...params: Parameters ): ReturnType { return await this.#client.markPrivateMessageAsRead(...params) } async createPrivateMessageReport( ...params: Parameters ): ReturnType { return await this.#client.createPrivateMessageReport(...params) } async resolvePrivateMessageReport( ...params: Parameters ): ReturnType { return await this.#client.resolvePrivateMessageReport(...params) } async listPrivateMessageReports( ...params: Parameters ): ReturnType { return await this.#client.listPrivateMessageReports(...params) } async register( ...params: Parameters ): ReturnType { return await this.#client.register(...params) } async login( ...params: Parameters ): ReturnType { return await this.#client.login(...params) } async logout( ...params: Parameters ): ReturnType { return await this.#client.logout(...params) } async getPersonDetails( ...params: Parameters ): ReturnType { return await this.#client.getPersonDetails(...params) } async getPersonMentions( ...params: Parameters ): ReturnType { return await this.#client.getPersonMentions(...params) } async markPersonMentionAsRead( ...params: Parameters ): ReturnType { return await this.#client.markPersonMentionAsRead(...params) } async getReplies( ...params: Parameters ): ReturnType { return await this.#client.getReplies(...params) } async banPerson( ...params: Parameters ): ReturnType { return await this.#client.banPerson(...params) } async getBannedPersons( ...params: Parameters ): ReturnType { return await this.#client.getBannedPersons(...params) } async blockPerson( ...params: Parameters ): ReturnType { return await this.#client.blockPerson(...params) } async getCaptcha( ...params: Parameters ): ReturnType { return await this.#client.getCaptcha(...params) } async deleteAccount( ...params: Parameters ): ReturnType { return await this.#client.deleteAccount(...params) } async passwordReset( ...params: Parameters ): ReturnType { return await this.#client.passwordReset(...params) } async passwordChangeAfterReset( ...params: Parameters ): ReturnType { return await this.#client.passwordChangeAfterReset(...params) } async markAllAsRead( ...params: Parameters ): ReturnType { return await this.#client.markAllAsRead(...params) } async saveUserSettings( ...params: Parameters ): ReturnType { return await this.#client.saveUserSettings(...params) } async changePassword( ...params: Parameters ): ReturnType { return await this.#client.changePassword(...params) } async getReportCount( ...params: Parameters ): ReturnType { return await this.#client.getReportCount(...params) } async getUnreadCount( ...params: Parameters ): ReturnType { return await this.#client.getUnreadCount(...params) } async verifyEmail( ...params: Parameters ): ReturnType { return await this.#client.verifyEmail(...params) } async addAdmin( ...params: Parameters ): ReturnType { return await this.#client.addAdmin(...params) } async getUnreadRegistrationApplicationCount( ...params: Parameters ): ReturnType { return await this.#client.getUnreadRegistrationApplicationCount(...params) } async listRegistrationApplications( ...params: Parameters ): ReturnType { return await this.#client.listRegistrationApplications(...params) } async approveRegistrationApplication( ...params: Parameters ): ReturnType { return await this.#client.approveRegistrationApplication(...params) } async getRegistrationApplication( ...params: Parameters ): ReturnType { return await this.#client.getRegistrationApplication(...params) } async purgePerson( ...params: Parameters ): ReturnType { return await this.#client.purgePerson(...params) } async purgeCommunity( ...params: Parameters ): ReturnType { return await this.#client.purgeCommunity(...params) } async purgePost( ...params: Parameters ): ReturnType { return await this.#client.purgePost(...params) } async purgeComment( ...params: Parameters ): ReturnType { return await this.#client.purgeComment(...params) } async getFederatedInstances( ...params: Parameters ): ReturnType { return await this.#client.getFederatedInstances(...params) } async blockInstance( ...params: Parameters ): ReturnType { return await this.#client.blockInstance(...params) } async uploadImage( ...params: Parameters ): ReturnType { return await this.#client.uploadImage(...params) } async editSite( ...params: Parameters ): ReturnType { return await this.#client.editSite(...params) } async deleteImage( ...params: Parameters ): ReturnType { return await this.#client.deleteImage(...params) } }