Skip to content

Conversation

@neet
Copy link
Owner

@neet neet commented Nov 5, 2025

Closes #684


  • Handle paginators

Copilot AI review requested due to automatic review settings November 5, 2025 13:33
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/neet/masto.js/masto@1352

commit: d343d06

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

size-limit report 📦

Path Size
rest 3.86 KB (+0.36% 🔺)
streaming 3.87 KB (+0.72% 🔺)
oauth 3.85 KB (+0.28% 🔺)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors API method definitions to use a new Endpoint type utility instead of explicit method signatures. The change standardizes how API endpoints are typed across the accounts resource by introducing a generic type that handles optional parameters more elegantly and adds experimental $raw method support.

Key Changes

  • Introduced a new Endpoint<Params, Meta, Response> utility type that provides both standard and raw response methods
  • Converted all method signatures in accounts.ts to use the Endpoint type
  • Added JSDoc comments and fixed indentation for some existing documentation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/mastodon/endpoint.ts New file defining the Endpoint utility type with conditional typing for optional vs required parameters
src/mastodon/rest/v1/accounts.ts Refactored all method signatures to use the new Endpoint type instead of explicit function signatures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,15 @@
type OptionalRecord = {
[key in string]?: any;
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using any defeats TypeScript's type safety. Consider using unknown instead, or if you need any indexable object, use [key: string]: unknown.

Suggested change
[key in string]?: any;
[key in string]?: unknown;

Copilot uses AI. Check for mistakes.
params?: FollowAccountParams,
meta?: HttpMetaParams<"json">,
): Promise<Relationship>;
follow: Endpoint<FollowAccountParams, HttpMetaParams<"json">, Relationship>;
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FollowAccountParams interface contains only optional properties, which should make params optional in the resulting Endpoint signature. However, the Endpoint type's conditional logic requires Params extends OptionalRecord | undefined to make params optional. Since FollowAccountParams is not explicitly undefined, params will be required even though all properties are optional. Consider using Endpoint<FollowAccountParams | undefined, ...> or updating the Endpoint type to better handle interfaces with all-optional properties.

Copilot uses AI. Check for mistakes.
params?: FollowAccountParams,
meta?: HttpMetaParams<"json">,
): Promise<Relationship>;
unfollow: Endpoint<FollowAccountParams, HttpMetaParams<"json">, Relationship>;
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as follow: FollowAccountParams has all optional properties but will result in required params parameter. The original signature had params?: making it optional. Consider using Endpoint<FollowAccountParams | undefined, ...> to maintain the original API behavior.

Suggested change
unfollow: Endpoint<FollowAccountParams, HttpMetaParams<"json">, Relationship>;
unfollow: Endpoint<FollowAccountParams | undefined, HttpMetaParams<"json">, Relationship>;

Copilot uses AI. Check for mistakes.
params?: MuteAccountParams,
meta?: HttpMetaParams<"json">,
): Promise<Relationship>;
mute: Endpoint<MuteAccountParams, HttpMetaParams<"json">, Relationship>;
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MuteAccountParams interface contains only optional properties, but will result in a required params parameter. The original signature had params?: making it optional. Consider using Endpoint<MuteAccountParams | undefined, ...> to maintain backward compatibility.

Suggested change
mute: Endpoint<MuteAccountParams, HttpMetaParams<"json">, Relationship>;
mute: Endpoint<MuteAccountParams | undefined, HttpMetaParams<"json">, Relationship>;

Copilot uses AI. Check for mistakes.
@neet neet force-pushed the add-raw-method branch 2 times, most recently from 6e444a2 to 422bc6a Compare November 24, 2025 08:56
@neet neet closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return Rate Limits

2 participants