From 68a0924c97f3a3aeaaa7704f13bfd904401d3835 Mon Sep 17 00:00:00 2001 From: Alexander Harding Date: Sat, 27 Dec 2025 21:32:59 -0600 Subject: [PATCH] chore: enforce prettier --- .github/workflows/ci.yml | 1 + .prettierignore | 1 + package.json | 2 + pnpm-lock.yaml | 10 +++ src/BaseClient.ts | 116 ++++++++++++++--------------- src/ThreadiverseClient.ts | 4 +- src/providers/lemmyv0/compat.ts | 2 +- src/providers/lemmyv0/index.ts | 86 ++++++++++----------- src/providers/piefed/compat.ts | 24 +++--- src/providers/piefed/index.ts | 128 ++++++++++++++++---------------- 10 files changed, 194 insertions(+), 180 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a857713..4630924 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: node-version: 22 cache: "pnpm" - run: pnpm install + - run: pnpm format:check - run: pnpm lint - run: pnpm test:types - run: pnpm build diff --git a/.prettierignore b/.prettierignore index 74c79ff..5c0ccdc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ src/providers/piefed/schema.ts +pnpm-lock.yaml \ No newline at end of file diff --git a/package.json b/package.json index ea4a879..1edca4f 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ ], "scripts": { "dev": "vitest dev", + "format:check": "prettier --check .", "lint": "eslint .", "lint:fix": "eslint . --fix", "test": "pnpm lint && pnpm test:types && vitest run --coverage", @@ -51,6 +52,7 @@ }, "devDependencies": { "@eslint/js": "^9.29.0", + "prettier": "^3.7.4", "@types/node": "22.14.1", "@vitest/coverage-v8": "3.1.1", "eslint": "9.25.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6d2cc8e..3ae103f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,6 +45,9 @@ importers: eslint-plugin-perfectionist: specifier: ^4.15.0 version: 4.15.0(eslint@9.25.0(jiti@2.4.2))(typescript@5.8.3) + prettier: + specifier: ^3.7.4 + version: 3.7.4 typescript: specifier: 5.8.3 version: 5.8.3 @@ -1963,6 +1966,11 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier@3.7.4: + resolution: {integrity: sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==} + engines: {node: '>=14'} + hasBin: true + pretty-bytes@6.1.1: resolution: {integrity: sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==} engines: {node: ^14.13.1 || >=16.0.0} @@ -4355,6 +4363,8 @@ snapshots: prelude-ls@1.2.1: {} + prettier@3.7.4: {} + pretty-bytes@6.1.1: {} proxy-addr@2.0.7: diff --git a/src/BaseClient.ts b/src/BaseClient.ts index c5fa27a..830c225 100644 --- a/src/BaseClient.ts +++ b/src/BaseClient.ts @@ -26,82 +26,82 @@ export abstract class BaseClient { abstract banFromCommunity( payload: types.BanFromCommunity, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract blockCommunity( payload: { block: boolean; community_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ community_view: types.CommunityView }>; abstract blockInstance( payload: { block: boolean; instance_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract blockPerson( payload: { block: boolean; person_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ person_view: types.PersonView }>; abstract createComment( payload: types.CreateComment, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract createCommentReport( payload: { comment_id: number; reason: string }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract createPost( payload: types.CreatePost, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract createPostReport( payload: { post_id: number; reason: string }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract createPrivateMessage( payload: { content: string; recipient_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ private_message_view: types.PrivateMessageView }>; abstract createPrivateMessageReport( payload: { private_message_id: number; reason: string }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract deleteComment( payload: { comment_id: number; deleted: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract deleteImage( payload: { delete_token: string; url: string }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract deletePost( payload: { deleted: boolean; post_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract distinguishComment( payload: { comment_id: number; distinguished: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract editComment( payload: types.EditComment, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract editPost( payload: types.EditPost, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract featurePost( @@ -110,26 +110,26 @@ export abstract class BaseClient { featured: boolean; post_id: number; }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract followCommunity( payload: { community_id: number; follow: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ community_view: types.CommunityView }>; abstract getCaptcha( - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getComments( payload: types.GetComments, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getCommunity( payload: types.GetCommunity, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getFederatedInstances(options?: RequestOptions): Promise<{ @@ -138,108 +138,108 @@ export abstract class BaseClient { abstract getModlog( payload: types.GetModlog, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getNotifications( payload: types.GetPersonMentions, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getPersonDetails( payload: { person_id: number } | { username: string }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getPersonMentions( payload: types.GetPersonMentions, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getPost( payload: types.GetPost, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract getPosts( payload: types.GetPosts, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getPrivateMessages( payload: types.GetPrivateMessages, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getRandomCommunity( payload: { type_: types.ListingType }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ community_view: types.CommunityView }>; abstract getReplies( payload: types.GetReplies, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getSite(options?: RequestOptions): Promise; abstract getSiteMetadata( payload: { url: string }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract getUnreadCount( - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract likeComment( payload: { comment_id: number; score: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract likePost( payload: { post_id: number; score: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract listCommentReports( payload: types.PageParams & { unresolved_only?: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract listCommunities( payload: types.ListCommunities, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract listPersonContent( payload: types.ListPersonContent, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract listPersonLiked( payload: types.PageParams & { type: types.LikeType }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract listPersonSaved( payload: types.PageParams & { person_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract listPostReports( payload: types.PageParams & { unresolved_only?: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract listReports( payload: types.ListReports, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract lockPost( payload: { locked: boolean; post_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract login( @@ -248,7 +248,7 @@ export abstract class BaseClient { totp_2fa_token?: string; username_or_email: string; }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ jwt?: string }>; abstract logout(options?: RequestOptions): Promise; @@ -257,78 +257,78 @@ export abstract class BaseClient { abstract markCommentReplyAsRead( payload: { comment_reply_id: number; read: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract markPersonMentionAsRead( payload: { person_mention_id: number; read: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract markPostAsRead( payload: { post_ids: number[]; read: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract markPrivateMessageAsRead( payload: { private_message_id: number; read: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract register( payload: types.Register, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract removeComment( payload: { comment_id: number; reason?: string; removed: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract removePost( payload: { post_id: number; reason?: string; removed: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract resolveCommentReport( payload: { report_id: number; resolved: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract resolveObject( payload: { q: string; }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract resolvePostReport( payload: { report_id: number; resolved: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract saveComment( payload: { comment_id: number; save: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ comment_view: types.CommentView }>; abstract savePost( payload: { post_id: number; save: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: types.PostView }>; abstract saveUserSettings( payload: { show_nsfw: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract search( payload: types.Search, - options?: RequestOptions + options?: RequestOptions, ): Promise; abstract uploadImage( payload: { file: File }, - options?: RequestOptions + options?: RequestOptions, ): Promise; } diff --git a/src/ThreadiverseClient.ts b/src/ThreadiverseClient.ts index a4e4a47..3953890 100644 --- a/src/ThreadiverseClient.ts +++ b/src/ThreadiverseClient.ts @@ -25,7 +25,7 @@ export default class ThreadiverseClient implements BaseClient { !this.discoveredSoftware ) throw new Error( - "Client not initialized. Wait for getSoftware() or any other async method to resolve first" + "Client not initialized. Wait for getSoftware() or any other async method to resolve first", ); return { @@ -450,7 +450,7 @@ export default class ThreadiverseClient implements BaseClient { if (!Client) { throw new UnsupportedSoftwareError( - `${this.discoveredSoftware.name} v${this.discoveredSoftware.version} is not supported` + `${this.discoveredSoftware.name} v${this.discoveredSoftware.version} is not supported`, ); } diff --git a/src/providers/lemmyv0/compat.ts b/src/providers/lemmyv0/compat.ts index 4c6d03d..eac9c07 100644 --- a/src/providers/lemmyv0/compat.ts +++ b/src/providers/lemmyv0/compat.ts @@ -174,5 +174,5 @@ function compatCommunityVisibility( ): types.CommunityVisibility { return visibility === "LocalOnly" ? "LocalOnlyPublic" - : visibility ?? "Public"; + : (visibility ?? "Public"); } diff --git a/src/providers/lemmyv0/index.ts b/src/providers/lemmyv0/index.ts index effc337..22ddb9f 100644 --- a/src/providers/lemmyv0/index.ts +++ b/src/providers/lemmyv0/index.ts @@ -119,14 +119,14 @@ export class UnsafeLemmyV0Client implements BaseClient { async deleteImage( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.deleteImage( { filename: new URL(payload.url).pathname.split("/").pop()!, token: payload.delete_token, }, - options + options, ); } @@ -199,16 +199,16 @@ export class UnsafeLemmyV0Client implements BaseClient { async getComments( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { if (payload.mode && payload.mode !== "lemmyv0") throw new InvalidPayloadError( - `Connected to lemmyv1, ${payload.mode} is not supported` + `Connected to lemmyv1, ${payload.mode} is not supported`, ); const response = await this.#client.getComments( cleanThreadiverseParams(compat.fromPageParams(payload)), - options + options, ); return { @@ -239,11 +239,11 @@ export class UnsafeLemmyV0Client implements BaseClient { async getModlog( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.getModlog( compat.fromPageParams(payload), - options + options, ); return { @@ -257,7 +257,7 @@ export class UnsafeLemmyV0Client implements BaseClient { async getNotifications( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const params = compat.fromPageParams(payload); @@ -274,7 +274,7 @@ export class UnsafeLemmyV0Client implements BaseClient { ].sort( (a, b) => Date.parse(getInboxItemPublished(b)) - - Date.parse(getInboxItemPublished(a)) + Date.parse(getInboxItemPublished(a)), ); return { @@ -285,14 +285,14 @@ export class UnsafeLemmyV0Client implements BaseClient { async getPersonDetails( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.getPersonDetails( { ...payload, limit: 1, // Lemmy melts down if limit is 0 }, - options + options, ); return { @@ -303,11 +303,11 @@ export class UnsafeLemmyV0Client implements BaseClient { async getPersonMentions( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.getPersonMentions( { ...payload, sort: "New" }, - options + options, ); return { @@ -328,11 +328,11 @@ export class UnsafeLemmyV0Client implements BaseClient { async getPosts( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { if (payload.mode && payload.mode !== "lemmyv0") throw new InvalidPayloadError( - `Connected to lemmyv1, ${payload.mode} is not supported` + `Connected to lemmyv1, ${payload.mode} is not supported`, ); const page_cursor = payload.page_cursor; @@ -346,7 +346,7 @@ export class UnsafeLemmyV0Client implements BaseClient { ...cleanThreadiverseParams(payload), page_cursor, }, - options + options, ); return { @@ -361,11 +361,11 @@ export class UnsafeLemmyV0Client implements BaseClient { async getPrivateMessages( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.getPrivateMessages( compat.fromPageParams(payload), - options + options, ); return { @@ -378,17 +378,17 @@ export class UnsafeLemmyV0Client implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "Get random community is not supported by Lemmy v0" + "Get random community is not supported by Lemmy v0", ); } async getReplies( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.getReplies( compat.fromPageParams({ ...payload, sort: "New" }), - options + options, ); return { @@ -409,7 +409,7 @@ export class UnsafeLemmyV0Client implements BaseClient { ...site.my_user, follows: site.my_user.follows.map(compat.toCommunityFollowerView), moderates: site.my_user.moderates.map( - compat.toCommunityModeratorView + compat.toCommunityModeratorView, ), ...compat.toBlocks(site.my_user), } @@ -455,11 +455,11 @@ export class UnsafeLemmyV0Client implements BaseClient { async listCommentReports( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.listCommentReports( compat.fromPageParams(payload), - options + options, ); return { @@ -470,16 +470,16 @@ export class UnsafeLemmyV0Client implements BaseClient { async listCommunities( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { if (payload.mode && payload.mode !== "lemmyv0") throw new InvalidPayloadError( - `Connected to lemmyv1, ${payload.mode} is not supported` + `Connected to lemmyv1, ${payload.mode} is not supported`, ); const response = await this.#client.listCommunities( cleanThreadiverseParams(compat.fromPageParams(payload)), - options + options, ); return { @@ -490,14 +490,14 @@ export class UnsafeLemmyV0Client implements BaseClient { async listPersonContent( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.getPersonDetails( { ...compat.fromPageParams(payload), sort: "New", }, - options + options, ); const data = (() => { @@ -510,7 +510,7 @@ export class UnsafeLemmyV0Client implements BaseClient { ].sort( (a, b) => getPostCommentItemCreatedDate(b) - - getPostCommentItemCreatedDate(a) + getPostCommentItemCreatedDate(a), ); case "Comments": return response.comments.map(compat.toCommentView); @@ -527,7 +527,7 @@ export class UnsafeLemmyV0Client implements BaseClient { async listPersonLiked( { type, ...payload }: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): Promise { const v0Payload: LemmyV0.GetComments & LemmyV0.GetPosts = { ...compat.fromPageParams(payload), @@ -552,7 +552,7 @@ export class UnsafeLemmyV0Client implements BaseClient { async listPersonSaved( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { return this.listPersonContent( { @@ -560,17 +560,17 @@ export class UnsafeLemmyV0Client implements BaseClient { // @ts-expect-error Dogfood the api saved_only: true, }, - options + options, ); } async listPostReports( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.listPostReports( compat.fromPageParams(payload), - options + options, ); return { @@ -581,7 +581,7 @@ export class UnsafeLemmyV0Client implements BaseClient { async listReports( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const params = compat.fromPageParams(payload); @@ -597,7 +597,7 @@ export class UnsafeLemmyV0Client implements BaseClient { ...post_reports.map(compat.toPostReportView), ].sort( (a, b) => - getPostCommentItemCreatedDate(b) - getPostCommentItemCreatedDate(a) + getPostCommentItemCreatedDate(b) - getPostCommentItemCreatedDate(a), ), }; } @@ -688,7 +688,7 @@ export class UnsafeLemmyV0Client implements BaseClient { async resolveObject( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.resolveObject(payload, options); @@ -738,16 +738,16 @@ export class UnsafeLemmyV0Client implements BaseClient { async search( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { if (payload.mode && payload.mode !== "lemmyv0") throw new InvalidPayloadError( - `Connected to lemmyv1, ${payload.mode} is not supported` + `Connected to lemmyv1, ${payload.mode} is not supported`, ); const response = await this.#client.search( cleanThreadiverseParams(compat.fromPageParams(payload)), - options + options, ); return { @@ -763,11 +763,11 @@ export class UnsafeLemmyV0Client implements BaseClient { async uploadImage( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.uploadImage( { image: payload.file }, - options + options, ); const fileResponse = response.files?.[0]; diff --git a/src/providers/piefed/compat.ts b/src/providers/piefed/compat.ts index 8b7ed62..e0a9d32 100644 --- a/src/providers/piefed/compat.ts +++ b/src/providers/piefed/compat.ts @@ -7,7 +7,7 @@ export const fromPageParams = lemmyCompat.fromPageParams; export function toComment( comment: components["schemas"]["Comment"], - creator_id: number // TODO piefed types are wrong, this isn't being returned rn + creator_id: number, // TODO piefed types are wrong, this isn't being returned rn ) { return { ...comment, @@ -18,7 +18,7 @@ export function toComment( } export function toCommentReplyView( - reply: components["schemas"]["CommentReplyView"] + reply: components["schemas"]["CommentReplyView"], ) { return { ...reply, @@ -32,7 +32,7 @@ export function toCommentReplyView( } export function toCommentView( - comment: components["schemas"]["CommentView"] + comment: components["schemas"]["CommentView"], ): types.CommentView { return { ...comment, @@ -47,7 +47,7 @@ export function toCommentView( } export function toCommunity( - community: components["schemas"]["Community"] + community: components["schemas"]["Community"], ): types.Community { return { ...community, @@ -59,7 +59,7 @@ export function toCommunity( } export function toCommunityModeratorView( - view: components["schemas"]["CommunityModeratorView"] + view: components["schemas"]["CommunityModeratorView"], ) { return { ...view, @@ -69,7 +69,7 @@ export function toCommunityModeratorView( } export function toCommunityView( - community: components["schemas"]["CommunityView"] + community: components["schemas"]["CommunityView"], ): types.CommunityView { return { ...community, @@ -87,7 +87,7 @@ export function toCommunityView( } export function toGetCommunityResponse( - response: components["schemas"]["GetCommunityResponse"] + response: components["schemas"]["GetCommunityResponse"], ) { return { community_view: toCommunityView(response.community_view), @@ -96,7 +96,7 @@ export function toGetCommunityResponse( } export function toLocalSite( - site: components["schemas"]["Site"] + site: components["schemas"]["Site"], ): types.LocalSite { return { captcha_enabled: false, @@ -110,7 +110,7 @@ export function toLocalSite( } export function toPerson( - person: components["schemas"]["Person"] + person: components["schemas"]["Person"], ): types.Person { return { ...person, @@ -125,7 +125,7 @@ export function toPerson( } export function toPersonMentionView( - mention: components["schemas"]["CommentReplyView"] + mention: components["schemas"]["CommentReplyView"], ): types.PersonMentionView { return { ...mention, @@ -157,7 +157,7 @@ export function toPost(post: components["schemas"]["Post"]) { } export function toPostView( - post: components["schemas"]["PostView"] + post: components["schemas"]["PostView"], ): types.PostView { return { ...post, @@ -169,7 +169,7 @@ export function toPostView( } export function toPrivateMessageView( - message: components["schemas"]["PrivateMessageView"] + message: components["schemas"]["PrivateMessageView"], ) { return { ...message, diff --git a/src/providers/piefed/index.ts b/src/providers/piefed/index.ts index a39f6bb..2c1b846 100644 --- a/src/providers/piefed/index.ts +++ b/src/providers/piefed/index.ts @@ -73,7 +73,7 @@ export class UnsafePiefedClient implements BaseClient { async banFromCommunity( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/community/moderate/ban", { ...options, @@ -84,7 +84,7 @@ export class UnsafePiefedClient implements BaseClient { async blockCommunity( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/community/block", { ...options, @@ -98,7 +98,7 @@ export class UnsafePiefedClient implements BaseClient { async blockInstance( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/site/block", { ...options, @@ -108,7 +108,7 @@ export class UnsafePiefedClient implements BaseClient { async blockPerson( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/user/block", { ...options, @@ -123,7 +123,7 @@ export class UnsafePiefedClient implements BaseClient { async createComment( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/comment", { ...options, @@ -140,7 +140,7 @@ export class UnsafePiefedClient implements BaseClient { async createCommentReport( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/comment/report", { ...options, @@ -150,7 +150,7 @@ export class UnsafePiefedClient implements BaseClient { async createPost( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const response = await this.#client.POST("/api/alpha/post", { ...options, @@ -167,7 +167,7 @@ export class UnsafePiefedClient implements BaseClient { async createPostReport( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/post/report", { ...options, @@ -177,7 +177,7 @@ export class UnsafePiefedClient implements BaseClient { async createPrivateMessage( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/private_message", { ...options, @@ -186,7 +186,7 @@ export class UnsafePiefedClient implements BaseClient { return { private_message_view: compat.toPrivateMessageView( - response.data!.private_message_view + response.data!.private_message_view, ), }; } @@ -195,13 +195,13 @@ export class UnsafePiefedClient implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "Create private message report is not supported by piefed" + "Create private message report is not supported by piefed", ); } async deleteComment( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/comment/delete", { ...options, @@ -221,7 +221,7 @@ export class UnsafePiefedClient implements BaseClient { async deletePost( payload: { deleted: boolean; post_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: PostView }> { const response = await this.#client.POST("/api/alpha/post/delete", { ...options, @@ -237,13 +237,13 @@ export class UnsafePiefedClient implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "Distinguish comment is not supported by piefed" + "Distinguish comment is not supported by piefed", ); } async editComment( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.PUT("/api/alpha/comment", { ...options, @@ -263,7 +263,7 @@ export class UnsafePiefedClient implements BaseClient { async editPost( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const response = await this.#client.PUT("/api/alpha/post", { ...options, @@ -280,7 +280,7 @@ export class UnsafePiefedClient implements BaseClient { async featurePost( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: PostView }> { const response = await this.#client.POST("/api/alpha/post/feature", { ...options, @@ -294,7 +294,7 @@ export class UnsafePiefedClient implements BaseClient { async followCommunity( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/community/follow", { ...options, @@ -314,15 +314,15 @@ export class UnsafePiefedClient implements BaseClient { async getComments( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { if (payload.mode && payload.mode !== "piefed") throw new InvalidPayloadError( - `Connected to piefed, ${payload.mode} is not supported` + `Connected to piefed, ${payload.mode} is not supported`, ); const query = cleanThreadiverseParams( - compat.fromPageParams(payload) + compat.fromPageParams(payload), ) satisfies paths["/api/alpha/comment/list"]["get"]["parameters"]["query"]; const response = await this.#client.GET("/api/alpha/comment/list", { @@ -338,7 +338,7 @@ export class UnsafePiefedClient implements BaseClient { async getCommunity( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/community", { ...options, @@ -378,7 +378,7 @@ export class UnsafePiefedClient implements BaseClient { ].sort( (a, b) => Date.parse(getInboxItemPublished(b)) - - Date.parse(getInboxItemPublished(a)) + Date.parse(getInboxItemPublished(a)), ); return { @@ -389,7 +389,7 @@ export class UnsafePiefedClient implements BaseClient { async getPersonDetails( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/user", { ...options, @@ -405,7 +405,7 @@ export class UnsafePiefedClient implements BaseClient { async getPersonMentions( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/user/mentions", { ...options, @@ -420,7 +420,7 @@ export class UnsafePiefedClient implements BaseClient { async getPost( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const query = payload satisfies paths["/api/alpha/post"]["get"]["parameters"]["query"]; @@ -437,15 +437,15 @@ export class UnsafePiefedClient implements BaseClient { async getPosts( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { if (payload.mode && payload.mode !== "piefed") throw new InvalidPayloadError( - `Connected to piefed, ${payload.mode} is not supported` + `Connected to piefed, ${payload.mode} is not supported`, ); const query = cleanThreadiverseParams( - compat.fromPageParams(payload) + compat.fromPageParams(payload), ) satisfies paths["/api/alpha/post/list"]["get"]["parameters"]["query"]; const response = await this.#client.GET("/api/alpha/post/list", { @@ -461,7 +461,7 @@ export class UnsafePiefedClient implements BaseClient { async getPrivateMessages( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/private_message/list", { ...options, @@ -478,13 +478,13 @@ export class UnsafePiefedClient implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "Get random community is not supported by piefed" + "Get random community is not supported by piefed", ); } async getReplies( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/user/replies", { ...options, @@ -510,14 +510,14 @@ export class UnsafePiefedClient implements BaseClient { ? { ...response.data!.my_user, community_blocks: response.data!.my_user?.community_blocks.map( - ({ community }) => compat.toCommunity(community!) + ({ community }) => compat.toCommunity(community!), ), follows: response.data!.my_user.follows.map((f) => ({ community: compat.toCommunity(f.community), follower: compat.toPerson(f.follower), })), instance_blocks: response.data!.my_user?.instance_blocks.map( - ({ instance }) => instance + ({ instance }) => instance, ), local_user_view: { ...response.data!.my_user.local_user_view, @@ -527,14 +527,14 @@ export class UnsafePiefedClient implements BaseClient { response.data!.my_user.local_user_view.local_user.show_nsfw, }, person: compat.toPerson( - response.data!.my_user.local_user_view.person + response.data!.my_user.local_user_view.person, ), }, moderates: response.data!.my_user.moderates.map( - compat.toCommunityModeratorView + compat.toCommunityModeratorView, ), person_blocks: response.data!.my_user?.person_blocks.map( - ({ target }) => compat.toPerson(target) + ({ target }) => compat.toPerson(target), ), } : undefined, @@ -561,7 +561,7 @@ export class UnsafePiefedClient implements BaseClient { async likeComment( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/comment/like", { ...options, @@ -578,7 +578,7 @@ export class UnsafePiefedClient implements BaseClient { async likePost( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const response = await this.#client.POST("/api/alpha/post/like", { ...options, @@ -596,13 +596,13 @@ export class UnsafePiefedClient implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "List comment reports is not supported by piefed" + "List comment reports is not supported by piefed", ); } async listCommunities( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/community/list", { ...options, @@ -618,7 +618,7 @@ export class UnsafePiefedClient implements BaseClient { async listPersonContent( payload: ListPersonContent, - options?: RequestOptions + options?: RequestOptions, ): Promise { switch (payload.type) { case "All": @@ -631,8 +631,8 @@ export class UnsafePiefedClient implements BaseClient { [...posts.data, ...comments.data].sort( (a, b) => getPostCommentItemCreatedDate(b) - - getPostCommentItemCreatedDate(a) - ) + getPostCommentItemCreatedDate(a), + ), ); return { @@ -658,7 +658,7 @@ export class UnsafePiefedClient implements BaseClient { async listPersonSaved( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/user", { ...options, @@ -677,7 +677,7 @@ export class UnsafePiefedClient implements BaseClient { ].sort( (a, b) => getPostCommentItemCreatedDate(b) - - getPostCommentItemCreatedDate(a) + getPostCommentItemCreatedDate(a), ); case "Comments": return response.data!.comments.map(compat.toCommentView); @@ -706,7 +706,7 @@ export class UnsafePiefedClient implements BaseClient { async lockPost( payload: { locked: boolean; post_id: number }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: PostView }> { const response = await this.#client.POST("/api/alpha/post/lock", { ...options, @@ -720,7 +720,7 @@ export class UnsafePiefedClient implements BaseClient { async login( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const response = await this.#client.POST("/api/alpha/user/login", { ...options, @@ -739,7 +739,7 @@ export class UnsafePiefedClient implements BaseClient { async markCommentReplyAsRead( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/comment/mark_as_read", { ...options, @@ -749,7 +749,7 @@ export class UnsafePiefedClient implements BaseClient { async markPersonMentionAsRead( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/comment/mark_as_read", { ...options, @@ -762,7 +762,7 @@ export class UnsafePiefedClient implements BaseClient { async markPostAsRead( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/post/mark_as_read", { ...options, @@ -772,7 +772,7 @@ export class UnsafePiefedClient implements BaseClient { async markPrivateMessageAsRead( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { await this.#client.POST("/api/alpha/private_message/mark_as_read", { ...options, @@ -788,7 +788,7 @@ export class UnsafePiefedClient implements BaseClient { async removeComment( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.POST("/api/alpha/comment/remove", { ...options, @@ -802,7 +802,7 @@ export class UnsafePiefedClient implements BaseClient { async removePost( payload: { post_id: number; removed: boolean }, - options?: RequestOptions + options?: RequestOptions, ): Promise<{ post_view: PostView }> { const response = await this.#client.POST("/api/alpha/post/remove", { ...options, @@ -818,13 +818,13 @@ export class UnsafePiefedClient implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "Resolve comment report is not supported by piefed" + "Resolve comment report is not supported by piefed", ); } async resolveObject( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/resolve_object", { ...options, @@ -855,13 +855,13 @@ export class UnsafePiefedClient implements BaseClient { ..._params: Parameters ): ReturnType { throw new UnsupportedError( - "Resolve post report is not supported by piefed" + "Resolve post report is not supported by piefed", ); } async saveComment( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.PUT("/api/alpha/comment/save", { ...options, @@ -875,7 +875,7 @@ export class UnsafePiefedClient implements BaseClient { async savePost( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.PUT("/api/alpha/post/save", { ...options, @@ -895,7 +895,7 @@ export class UnsafePiefedClient implements BaseClient { async search( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ): ReturnType { const response = await this.#client.GET("/api/alpha/search", { ...options, @@ -916,7 +916,7 @@ export class UnsafePiefedClient implements BaseClient { async uploadImage( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const formData = new FormData(); formData.append("file", payload.file); @@ -934,7 +934,7 @@ export class UnsafePiefedClient implements BaseClient { body: formData, headers: this.#headers, method: "POST", - } + }, ); await validateResponse(response); @@ -948,7 +948,7 @@ export class UnsafePiefedClient implements BaseClient { async #listPersonComments( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const response = await this.#client.GET("/api/alpha/comment/list", { ...options, @@ -963,7 +963,7 @@ export class UnsafePiefedClient implements BaseClient { async #listPersonPosts( payload: Parameters[0], - options?: RequestOptions + options?: RequestOptions, ) { const response = await this.#client.GET("/api/alpha/post/list", { ...options,