ani-client 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  > A simple, typed client to fetch anime, manga, character, staff and user data from [AniList](https://anilist.co).
9
9
 
10
- ✨ **Showcase**: [Check here](https://gonzyuidev.xyz/projects/aniclient/showcase) to see which projects use this package!
10
+ ✨ **Showcase**: [Check here](https://ani-client.js.org/showcase) to see which projects use this package!
11
11
 
12
12
  - **Zero dependencies** — uses the native `fetch` API
13
13
  - **Universal** — Node.js ≥ 20, Bun, Deno and modern browsers
@@ -18,7 +18,7 @@
18
18
 
19
19
  The full API reference, usage guide, and configuration examples are available on our official documentation website!
20
20
 
21
- **[👉 View the full documentation here](https://gonzyuidev.xyz/projects/aniclient/)**
21
+ **[👉 View the full documentation here](https://ani-client.js.org)**
22
22
 
23
23
  ## Install
24
24
 
package/dist/index.d.mts CHANGED
@@ -90,6 +90,8 @@ interface AniListHooks {
90
90
  onRetry?: (attempt: number, reason: string, delayMs: number) => void;
91
91
  /** Called when a request completes. */
92
92
  onResponse?: (query: string, durationMs: number, fromCache: boolean, rateLimitInfo?: RateLimitInfo) => void;
93
+ /** Called when a request fails with an error. */
94
+ onError?: (error: Error, query: string, variables: Record<string, unknown>) => void;
93
95
  }
94
96
  /** Rate limit information parsed from AniList API response headers. */
95
97
  interface RateLimitInfo {
@@ -223,21 +225,11 @@ interface SearchStaffOptions {
223
225
  perPage?: number;
224
226
  }
225
227
  /** Compact voice actor data returned inside character edges. */
226
- interface VoiceActor {
227
- id: number;
228
- name: {
229
- first: string | null;
230
- middle: string | null;
231
- last: string | null;
232
- full: string | null;
233
- native: string | null;
228
+ interface VoiceActor extends Pick<Staff, "id" | "image" | "gender" | "primaryOccupations" | "siteUrl"> {
229
+ name: StaffName & {
234
230
  userPreferred: string | null;
235
231
  };
236
232
  languageV2: string | null;
237
- image: StaffImage;
238
- gender: string | null;
239
- primaryOccupations: string[];
240
- siteUrl: string | null;
241
233
  }
242
234
 
243
235
  declare enum CharacterSort {
@@ -387,8 +379,18 @@ interface Studio {
387
379
  interface StudioConnection {
388
380
  nodes: Studio[];
389
381
  }
382
+ declare enum StudioSort {
383
+ ID = "ID",
384
+ ID_DESC = "ID_DESC",
385
+ NAME = "NAME",
386
+ NAME_DESC = "NAME_DESC",
387
+ SEARCH_MATCH = "SEARCH_MATCH",
388
+ FAVOURITES = "FAVOURITES",
389
+ FAVOURITES_DESC = "FAVOURITES_DESC"
390
+ }
390
391
  interface SearchStudioOptions {
391
392
  query?: string;
393
+ sort?: StudioSort[];
392
394
  page?: number;
393
395
  perPage?: number;
394
396
  }
@@ -441,18 +443,10 @@ interface SearchUserOptions {
441
443
  }
442
444
  interface FavoriteMediaNode {
443
445
  id: number;
444
- title: {
445
- romaji: string | null;
446
- english: string | null;
447
- native: string | null;
448
- userPreferred: string | null;
449
- };
450
- coverImage: {
451
- large: string | null;
452
- medium: string | null;
453
- };
454
- type: string | null;
455
- format: string | null;
446
+ title: MediaTitle;
447
+ coverImage: Pick<MediaCoverImage, "large" | "medium">;
448
+ type: MediaType | null;
449
+ format: MediaFormat | null;
456
450
  siteUrl: string | null;
457
451
  }
458
452
  interface FavoriteCharacterNode {
@@ -656,7 +650,7 @@ interface ScoreDistribution {
656
650
  amount: number;
657
651
  }
658
652
  interface StatusDistribution {
659
- status: MediaListStatus | string;
653
+ status: MediaListStatus;
660
654
  amount: number;
661
655
  }
662
656
  interface MediaStats {
@@ -887,17 +881,9 @@ interface ThreadCategory {
887
881
  }
888
882
  interface ThreadMediaCategory {
889
883
  id: number;
890
- title: {
891
- romaji: string | null;
892
- english: string | null;
893
- native: string | null;
894
- userPreferred: string | null;
895
- };
896
- type: string;
897
- coverImage: {
898
- large: string | null;
899
- medium: string | null;
900
- } | null;
884
+ title: MediaTitle;
885
+ type: MediaType;
886
+ coverImage: Pick<MediaCoverImage, "large" | "medium"> | null;
901
887
  siteUrl: string | null;
902
888
  }
903
889
  /** Sort options for thread queries. */
@@ -1004,7 +990,15 @@ declare class AniListClient {
1004
990
  getTopRated(type?: MediaType, page?: number, perPage?: number): Promise<PagedResult<Media>>;
1005
991
  /** Get recently aired anime episodes. */
1006
992
  getAiredEpisodes(options?: GetAiringOptions): Promise<PagedResult<AiringSchedule>>;
1007
- /** Get currently releasing manga. */
993
+ /**
994
+ * Get currently releasing manga sorted by most recently updated.
995
+ *
996
+ * @param options - Pagination parameters
997
+ */
998
+ getRecentlyUpdatedManga(options?: GetRecentChaptersOptions): Promise<PagedResult<Media>>;
999
+ /**
1000
+ * @deprecated Use `getRecentlyUpdatedManga` instead. This alias will be removed in v2.
1001
+ */
1008
1002
  getAiredChapters(options?: GetRecentChaptersOptions): Promise<PagedResult<Media>>;
1009
1003
  /** Get the detailed schedule for the current week, sorted by day. */
1010
1004
  getWeeklySchedule(date?: Date): Promise<WeeklySchedule>;
@@ -1077,7 +1071,7 @@ declare class AniListClient {
1077
1071
  /** Clear the entire response cache. */
1078
1072
  clearCache(): Promise<void>;
1079
1073
  /** Number of entries currently in the cache. */
1080
- get cacheSize(): number | Promise<number>;
1074
+ cacheSize(): Promise<number>;
1081
1075
  /** Remove cache entries whose key matches the given pattern. */
1082
1076
  invalidateCache(pattern: string | RegExp): Promise<number>;
1083
1077
  /** Clean up resources held by the client. */
@@ -1219,6 +1213,8 @@ declare class RateLimiter {
1219
1213
  private readonly timestamps;
1220
1214
  private head;
1221
1215
  private count;
1216
+ /** @internal — active sleep timers for cleanup */
1217
+ private readonly activeTimers;
1222
1218
  constructor(options?: RateLimitOptions);
1223
1219
  /**
1224
1220
  * Wait until it's safe to make a request (respects rate limit window).
@@ -1237,15 +1233,10 @@ declare class RateLimiter {
1237
1233
  /** @internal */
1238
1234
  private fetchWithTimeout;
1239
1235
  private sleep;
1236
+ /** Cancel all pending sleep timers and reset internal state. */
1237
+ dispose(): void;
1240
1238
  }
1241
1239
 
1242
- /**
1243
- * Parses AniList specific markdown into standard HTML.
1244
- * Includes formatting for spoilers, images, videos (youtube/webm), and standard markdown elements.
1245
- *
1246
- * @param text The AniList markdown text to parse
1247
- * @returns The parsed HTML string
1248
- */
1249
1240
  declare function parseAniListMarkdown(text: string): string;
1250
1241
 
1251
- export { type AiringSchedule, AiringSort, AniListClient, type AniListClientOptions, AniListError, type AniListHooks, type CacheAdapter, type CacheOptions, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, type ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, type FuzzyDate, type GetAiringOptions, type GetPlanningOptions, type GetRecentChaptersOptions, type GetRecommendationsOptions, type GetSeasonOptions, type GetUserMediaListOptions, type Media, type MediaCharacterConnection, type MediaCharacterEdge, type MediaConnection, type MediaCoverImage, type MediaEdge, MediaFormat, type MediaIncludeOptions, type MediaListEntry, MediaListSort, MediaListStatus, type MediaRecommendationNode, MediaRelationType, MediaSeason, MediaSort, MediaSource, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type NextAiringEpisode, type PageInfo, type PagedResult, type RateLimitInfo, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ResponseMeta, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type SearchThreadOptions, type SearchUserOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, StaffSort, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
1242
+ export { type AiringSchedule, AiringSort, AniListClient, type AniListClientOptions, AniListError, type AniListHooks, type CacheAdapter, type CacheOptions, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, type ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, type FuzzyDate, type GetAiringOptions, type GetPlanningOptions, type GetRecentChaptersOptions, type GetRecommendationsOptions, type GetSeasonOptions, type GetUserMediaListOptions, type Media, type MediaCharacterConnection, type MediaCharacterEdge, type MediaConnection, type MediaCoverImage, type MediaEdge, MediaFormat, type MediaIncludeOptions, type MediaListEntry, MediaListSort, MediaListStatus, type MediaRecommendationNode, MediaRelationType, MediaSeason, MediaSort, MediaSource, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type NextAiringEpisode, type PageInfo, type PagedResult, type RateLimitInfo, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ResponseMeta, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type SearchThreadOptions, type SearchUserOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, StaffSort, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
package/dist/index.d.ts CHANGED
@@ -90,6 +90,8 @@ interface AniListHooks {
90
90
  onRetry?: (attempt: number, reason: string, delayMs: number) => void;
91
91
  /** Called when a request completes. */
92
92
  onResponse?: (query: string, durationMs: number, fromCache: boolean, rateLimitInfo?: RateLimitInfo) => void;
93
+ /** Called when a request fails with an error. */
94
+ onError?: (error: Error, query: string, variables: Record<string, unknown>) => void;
93
95
  }
94
96
  /** Rate limit information parsed from AniList API response headers. */
95
97
  interface RateLimitInfo {
@@ -223,21 +225,11 @@ interface SearchStaffOptions {
223
225
  perPage?: number;
224
226
  }
225
227
  /** Compact voice actor data returned inside character edges. */
226
- interface VoiceActor {
227
- id: number;
228
- name: {
229
- first: string | null;
230
- middle: string | null;
231
- last: string | null;
232
- full: string | null;
233
- native: string | null;
228
+ interface VoiceActor extends Pick<Staff, "id" | "image" | "gender" | "primaryOccupations" | "siteUrl"> {
229
+ name: StaffName & {
234
230
  userPreferred: string | null;
235
231
  };
236
232
  languageV2: string | null;
237
- image: StaffImage;
238
- gender: string | null;
239
- primaryOccupations: string[];
240
- siteUrl: string | null;
241
233
  }
242
234
 
243
235
  declare enum CharacterSort {
@@ -387,8 +379,18 @@ interface Studio {
387
379
  interface StudioConnection {
388
380
  nodes: Studio[];
389
381
  }
382
+ declare enum StudioSort {
383
+ ID = "ID",
384
+ ID_DESC = "ID_DESC",
385
+ NAME = "NAME",
386
+ NAME_DESC = "NAME_DESC",
387
+ SEARCH_MATCH = "SEARCH_MATCH",
388
+ FAVOURITES = "FAVOURITES",
389
+ FAVOURITES_DESC = "FAVOURITES_DESC"
390
+ }
390
391
  interface SearchStudioOptions {
391
392
  query?: string;
393
+ sort?: StudioSort[];
392
394
  page?: number;
393
395
  perPage?: number;
394
396
  }
@@ -441,18 +443,10 @@ interface SearchUserOptions {
441
443
  }
442
444
  interface FavoriteMediaNode {
443
445
  id: number;
444
- title: {
445
- romaji: string | null;
446
- english: string | null;
447
- native: string | null;
448
- userPreferred: string | null;
449
- };
450
- coverImage: {
451
- large: string | null;
452
- medium: string | null;
453
- };
454
- type: string | null;
455
- format: string | null;
446
+ title: MediaTitle;
447
+ coverImage: Pick<MediaCoverImage, "large" | "medium">;
448
+ type: MediaType | null;
449
+ format: MediaFormat | null;
456
450
  siteUrl: string | null;
457
451
  }
458
452
  interface FavoriteCharacterNode {
@@ -656,7 +650,7 @@ interface ScoreDistribution {
656
650
  amount: number;
657
651
  }
658
652
  interface StatusDistribution {
659
- status: MediaListStatus | string;
653
+ status: MediaListStatus;
660
654
  amount: number;
661
655
  }
662
656
  interface MediaStats {
@@ -887,17 +881,9 @@ interface ThreadCategory {
887
881
  }
888
882
  interface ThreadMediaCategory {
889
883
  id: number;
890
- title: {
891
- romaji: string | null;
892
- english: string | null;
893
- native: string | null;
894
- userPreferred: string | null;
895
- };
896
- type: string;
897
- coverImage: {
898
- large: string | null;
899
- medium: string | null;
900
- } | null;
884
+ title: MediaTitle;
885
+ type: MediaType;
886
+ coverImage: Pick<MediaCoverImage, "large" | "medium"> | null;
901
887
  siteUrl: string | null;
902
888
  }
903
889
  /** Sort options for thread queries. */
@@ -1004,7 +990,15 @@ declare class AniListClient {
1004
990
  getTopRated(type?: MediaType, page?: number, perPage?: number): Promise<PagedResult<Media>>;
1005
991
  /** Get recently aired anime episodes. */
1006
992
  getAiredEpisodes(options?: GetAiringOptions): Promise<PagedResult<AiringSchedule>>;
1007
- /** Get currently releasing manga. */
993
+ /**
994
+ * Get currently releasing manga sorted by most recently updated.
995
+ *
996
+ * @param options - Pagination parameters
997
+ */
998
+ getRecentlyUpdatedManga(options?: GetRecentChaptersOptions): Promise<PagedResult<Media>>;
999
+ /**
1000
+ * @deprecated Use `getRecentlyUpdatedManga` instead. This alias will be removed in v2.
1001
+ */
1008
1002
  getAiredChapters(options?: GetRecentChaptersOptions): Promise<PagedResult<Media>>;
1009
1003
  /** Get the detailed schedule for the current week, sorted by day. */
1010
1004
  getWeeklySchedule(date?: Date): Promise<WeeklySchedule>;
@@ -1077,7 +1071,7 @@ declare class AniListClient {
1077
1071
  /** Clear the entire response cache. */
1078
1072
  clearCache(): Promise<void>;
1079
1073
  /** Number of entries currently in the cache. */
1080
- get cacheSize(): number | Promise<number>;
1074
+ cacheSize(): Promise<number>;
1081
1075
  /** Remove cache entries whose key matches the given pattern. */
1082
1076
  invalidateCache(pattern: string | RegExp): Promise<number>;
1083
1077
  /** Clean up resources held by the client. */
@@ -1219,6 +1213,8 @@ declare class RateLimiter {
1219
1213
  private readonly timestamps;
1220
1214
  private head;
1221
1215
  private count;
1216
+ /** @internal — active sleep timers for cleanup */
1217
+ private readonly activeTimers;
1222
1218
  constructor(options?: RateLimitOptions);
1223
1219
  /**
1224
1220
  * Wait until it's safe to make a request (respects rate limit window).
@@ -1237,15 +1233,10 @@ declare class RateLimiter {
1237
1233
  /** @internal */
1238
1234
  private fetchWithTimeout;
1239
1235
  private sleep;
1236
+ /** Cancel all pending sleep timers and reset internal state. */
1237
+ dispose(): void;
1240
1238
  }
1241
1239
 
1242
- /**
1243
- * Parses AniList specific markdown into standard HTML.
1244
- * Includes formatting for spoilers, images, videos (youtube/webm), and standard markdown elements.
1245
- *
1246
- * @param text The AniList markdown text to parse
1247
- * @returns The parsed HTML string
1248
- */
1249
1240
  declare function parseAniListMarkdown(text: string): string;
1250
1241
 
1251
- export { type AiringSchedule, AiringSort, AniListClient, type AniListClientOptions, AniListError, type AniListHooks, type CacheAdapter, type CacheOptions, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, type ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, type FuzzyDate, type GetAiringOptions, type GetPlanningOptions, type GetRecentChaptersOptions, type GetRecommendationsOptions, type GetSeasonOptions, type GetUserMediaListOptions, type Media, type MediaCharacterConnection, type MediaCharacterEdge, type MediaConnection, type MediaCoverImage, type MediaEdge, MediaFormat, type MediaIncludeOptions, type MediaListEntry, MediaListSort, MediaListStatus, type MediaRecommendationNode, MediaRelationType, MediaSeason, MediaSort, MediaSource, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type NextAiringEpisode, type PageInfo, type PagedResult, type RateLimitInfo, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ResponseMeta, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type SearchThreadOptions, type SearchUserOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, StaffSort, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
1242
+ export { type AiringSchedule, AiringSort, AniListClient, type AniListClientOptions, AniListError, type AniListHooks, type CacheAdapter, type CacheOptions, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, type ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, type FuzzyDate, type GetAiringOptions, type GetPlanningOptions, type GetRecentChaptersOptions, type GetRecommendationsOptions, type GetSeasonOptions, type GetUserMediaListOptions, type Media, type MediaCharacterConnection, type MediaCharacterEdge, type MediaConnection, type MediaCoverImage, type MediaEdge, MediaFormat, type MediaIncludeOptions, type MediaListEntry, MediaListSort, MediaListStatus, type MediaRecommendationNode, MediaRelationType, MediaSeason, MediaSort, MediaSource, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type NextAiringEpisode, type PageInfo, type PagedResult, type RateLimitInfo, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ResponseMeta, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type SearchThreadOptions, type SearchUserOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, StaffSort, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };