ani-client 2.4.0 → 2.5.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 +4 -0
- package/dist/cache/redis.d.mts +1 -1
- package/dist/cache/redis.d.ts +1 -1
- package/dist/index.d.mts +72 -4
- package/dist/index.d.ts +72 -4
- package/dist/index.js +120 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -33
- package/dist/index.mjs.map +1 -1
- package/dist/{redis-UeRs8nqC.d.mts → redis-ClB2nNrs.d.mts} +13 -0
- package/dist/{redis-UeRs8nqC.d.ts → redis-ClB2nNrs.d.ts} +13 -0
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -79,6 +79,10 @@ Contributions are welcome! Before opening an issue or a pull request, please rea
|
|
|
79
79
|
- [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
80
80
|
- [SECURITY.md](SECURITY.md)
|
|
81
81
|
|
|
82
|
+
## Disclaimer
|
|
83
|
+
|
|
84
|
+
> **Note:** `ani-client` is an unofficial, community-driven tool. It is not affiliated with, endorsed by, or associated with AniList or AniChart in any way.
|
|
85
|
+
|
|
82
86
|
## License
|
|
83
87
|
|
|
84
88
|
[MIT](LICENSE) © [gonzyui](https://gonzyuidev.xyz)
|
package/dist/cache/redis.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from '../redis-
|
|
1
|
+
export { f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from '../redis-ClB2nNrs.mjs';
|
package/dist/cache/redis.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from '../redis-
|
|
1
|
+
export { f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from '../redis-ClB2nNrs.js';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FuzzyDate, P as PageInfo, E as ExternalLink, C as CacheAdapter, a as CacheOptions, b as PagedResult, A as AniListClientOptions, R as RateLimitInfo, c as ResponseMeta, d as RateLimitOptions } from './redis-
|
|
2
|
-
export { e as AniListHooks, L as Logger, f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from './redis-
|
|
1
|
+
import { F as FuzzyDate, P as PageInfo, E as ExternalLink, C as CacheAdapter, a as CacheOptions, b as PagedResult, A as AniListClientOptions, R as RateLimitInfo, c as ResponseMeta, d as RateLimitOptions } from './redis-ClB2nNrs.mjs';
|
|
2
|
+
export { e as AniListHooks, L as Logger, f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from './redis-ClB2nNrs.mjs';
|
|
3
3
|
|
|
4
4
|
declare enum MediaListStatus {
|
|
5
5
|
CURRENT = "CURRENT",
|
|
@@ -156,6 +156,10 @@ interface Staff {
|
|
|
156
156
|
}
|
|
157
157
|
/** Options to include additional related data when fetching a staff member by ID. */
|
|
158
158
|
interface StaffIncludeOptions {
|
|
159
|
+
/** Include character roles (voice acting) for each media the staff member worked on. */
|
|
160
|
+
characterRoles?: boolean;
|
|
161
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
162
|
+
customFields?: string;
|
|
159
163
|
/** Include media the staff member has worked on.
|
|
160
164
|
* `true` = 25 results sorted by popularity. Object form to customize. */
|
|
161
165
|
media?: boolean | {
|
|
@@ -211,10 +215,14 @@ interface SearchStudioOptions {
|
|
|
211
215
|
* Pass `{ media: { perPage: 50 } }` to fetch more media per studio.
|
|
212
216
|
*/
|
|
213
217
|
interface StudioIncludeOptions {
|
|
214
|
-
/**
|
|
218
|
+
/** Include the media produced by this studio. */
|
|
215
219
|
media?: boolean | {
|
|
216
220
|
perPage?: number;
|
|
221
|
+
isMain?: boolean;
|
|
222
|
+
sort?: boolean;
|
|
217
223
|
};
|
|
224
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
225
|
+
customFields?: string;
|
|
218
226
|
}
|
|
219
227
|
|
|
220
228
|
declare enum UserSort {
|
|
@@ -707,6 +715,8 @@ interface MediaIncludeOptions {
|
|
|
707
715
|
recommendations?: boolean | {
|
|
708
716
|
perPage?: number;
|
|
709
717
|
};
|
|
718
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
719
|
+
customFields?: string;
|
|
710
720
|
}
|
|
711
721
|
interface GetMediaCharactersOptions {
|
|
712
722
|
/** Page number */
|
|
@@ -788,6 +798,8 @@ interface Character {
|
|
|
788
798
|
interface CharacterIncludeOptions {
|
|
789
799
|
/** Include voice actors for each media the character appears in. */
|
|
790
800
|
voiceActors?: boolean;
|
|
801
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
802
|
+
customFields?: string;
|
|
791
803
|
}
|
|
792
804
|
interface SearchCharacterOptions {
|
|
793
805
|
query?: string;
|
|
@@ -1038,6 +1050,7 @@ interface ClientBase {
|
|
|
1038
1050
|
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
1039
1051
|
pagedRequest<T>(query: string, variables: Record<string, unknown>, field: string): Promise<PagedResult<T>>;
|
|
1040
1052
|
paginate<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): AsyncGenerator<T, void, undefined>;
|
|
1053
|
+
fetchAll<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): Promise<T[]>;
|
|
1041
1054
|
}
|
|
1042
1055
|
|
|
1043
1056
|
/**
|
|
@@ -1072,6 +1085,7 @@ declare class AniListClient implements ClientBase {
|
|
|
1072
1085
|
private readonly mediaLoader;
|
|
1073
1086
|
private readonly characterLoader;
|
|
1074
1087
|
private readonly staffLoader;
|
|
1088
|
+
private readonly batchingEnabled;
|
|
1075
1089
|
constructor(options?: AniListClientOptions);
|
|
1076
1090
|
/**
|
|
1077
1091
|
* The current rate limit information from the last API response.
|
|
@@ -1213,6 +1227,13 @@ declare class AniListClient implements ClientBase {
|
|
|
1213
1227
|
* @param maxPages - Maximum number of pages to fetch (default: Infinity)
|
|
1214
1228
|
*/
|
|
1215
1229
|
paginate<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): AsyncGenerator<T, void, undefined>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Utility to fetch all pages of a paginated request and return them as a single array.
|
|
1232
|
+
*
|
|
1233
|
+
* @param fetchPage - A function that takes a page number and returns a `PagedResult<T>`
|
|
1234
|
+
* @param maxPages - Maximum number of pages to fetch (default: Infinity)
|
|
1235
|
+
*/
|
|
1236
|
+
fetchAll<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): Promise<T[]>;
|
|
1216
1237
|
/** Fetch multiple media entries in a single API request. */
|
|
1217
1238
|
getMediaBatch(ids: number[]): Promise<Media[]>;
|
|
1218
1239
|
/** Fetch multiple characters in a single API request. */
|
|
@@ -1273,6 +1294,53 @@ declare class AniListError extends Error {
|
|
|
1273
1294
|
constructor(message: string, status: number, errors?: GraphQLError[] | unknown[]);
|
|
1274
1295
|
}
|
|
1275
1296
|
|
|
1297
|
+
/**
|
|
1298
|
+
* Lightweight media fields — minimal payload for list/search contexts.
|
|
1299
|
+
* Does NOT include tags, studios, trailer, synonyms, or nextAiringEpisode.
|
|
1300
|
+
*/
|
|
1301
|
+
declare const MEDIA_FIELDS_LIGHT = "\n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n coverImage { large medium color }\n bannerImage\n genres\n averageScore\n popularity\n favourites\n isAdult\n siteUrl\n season\n seasonYear\n episodes\n chapters\n nextAiringEpisode {\n id\n airingAt\n episode\n timeUntilAiring\n }\n";
|
|
1302
|
+
/** Core media fields — always returned. Does NOT include relations (opt-in via include). */
|
|
1303
|
+
declare const MEDIA_FIELDS_BASE = "\n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n duration\n chapters\n volumes\n countryOfOrigin\n isLicensed\n source\n hashtag\n trailer { id site thumbnail }\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n synonyms\n averageScore\n meanScore\n popularity\n favourites\n trending\n tags { id name description category rank isMediaSpoiler }\n studios { nodes { id name isAnimationStudio siteUrl } }\n isAdult\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n";
|
|
1304
|
+
declare const RELATIONS_FIELDS = "\n relations {\n edges {\n relationType(version: 2)\n node {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n chapters\n volumes\n coverImage { extraLarge large medium color }\n genres\n averageScore\n meanScore\n studios { nodes { id name isAnimationStudio siteUrl } }\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n }\n }\n }\n";
|
|
1305
|
+
/** Media Recommendation fields - used for when fetching recommendation for a specific media entry */
|
|
1306
|
+
declare const MEDIA_RECOMMENDATION_FIELDS = "\n __typename\n id\n rating\n mediaRecommendation {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n coverImage { extraLarge large medium color }\n averageScore\n meanScore\n \tepisodes\n \tchapters\n \tvolumes\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n \tseason\n \tseasonYear\n \tstartDate { year month day }\n endDate { year month day }\n \tstudios { nodes { id name isAnimationStudio siteUrl } }\n \tgenres\n siteUrl\n }\n";
|
|
1307
|
+
/** Full media fields with relations — used by existing queries for backward compat. */
|
|
1308
|
+
declare const MEDIA_FIELDS = "\n \n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n duration\n chapters\n volumes\n countryOfOrigin\n isLicensed\n source\n hashtag\n trailer { id site thumbnail }\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n synonyms\n averageScore\n meanScore\n popularity\n favourites\n trending\n tags { id name description category rank isMediaSpoiler }\n studios { nodes { id name isAnimationStudio siteUrl } }\n isAdult\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n\n \n relations {\n edges {\n relationType(version: 2)\n node {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n chapters\n volumes\n coverImage { extraLarge large medium color }\n genres\n averageScore\n meanScore\n studios { nodes { id name isAnimationStudio siteUrl } }\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n }\n }\n }\n\n";
|
|
1309
|
+
/** Character fields without back-reference to media (used when embedding characters inside a Media query). */
|
|
1310
|
+
declare const CHARACTER_FIELDS_COMPACT = "\n __typename\n id\n name { first middle last full native alternative }\n image { large medium }\n description(asHtml: false)\n gender\n dateOfBirth { year month day }\n age\n bloodType\n favourites\n siteUrl\n";
|
|
1311
|
+
/** Compact voice actor fields — lightweight subset for embedding inside character edges. */
|
|
1312
|
+
declare const VOICE_ACTOR_FIELDS_COMPACT = "\n __typename\n id\n name { first middle last full native userPreferred }\n languageV2\n image { large medium }\n gender\n primaryOccupations\n siteUrl\n";
|
|
1313
|
+
declare const CHARACTER_FIELDS = "\n \n __typename\n id\n name { first middle last full native alternative }\n image { large medium }\n description(asHtml: false)\n gender\n dateOfBirth { year month day }\n age\n bloodType\n favourites\n siteUrl\n\n \n media(perPage: 10) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n type\n coverImage { large medium }\n siteUrl\n }\n }\n\n";
|
|
1314
|
+
declare const CHARACTER_FIELDS_WITH_VA = "\n \n __typename\n id\n name { first middle last full native alternative }\n image { large medium }\n description(asHtml: false)\n gender\n dateOfBirth { year month day }\n age\n bloodType\n favourites\n siteUrl\n\n \n media(perPage: 10) {\n edges {\n voiceActors {\n \n __typename\n id\n name { first middle last full native userPreferred }\n languageV2\n image { large medium }\n gender\n primaryOccupations\n siteUrl\n\n }\n node {\n __typename\n id\n title { romaji english native userPreferred }\n type\n coverImage { large medium }\n siteUrl\n }\n }\n }\n\n";
|
|
1315
|
+
declare const STAFF_FIELDS = "\n __typename\n id\n name { first middle last full native }\n language\n image { large medium }\n description(asHtml: false)\n primaryOccupations\n gender\n dateOfBirth { year month day }\n dateOfDeath { year month day }\n age\n yearsActive\n homeTown\n bloodType\n favourites\n siteUrl\n";
|
|
1316
|
+
declare const STAFF_MEDIA_FIELDS = "\n staffMedia(perPage: $perPage, sort: [POPULARITY_DESC]) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n averageScore\n meanScore\n popularity\n favourites\n episodes\n trending\n hashtag\n season\n seasonYear\n startDate { year month day }\n endDate { year month day }\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n studios {\n edges {\n node {\n name\n }\n }\n }\n siteUrl\n }\n }\n";
|
|
1317
|
+
declare const USER_FIELDS = "\n __typename\n id\n name\n about(asHtml: false)\n avatar { large medium }\n bannerImage\n isFollowing\n isFollower\n donatorTier\n donatorBadge\n createdAt\n siteUrl\n statistics {\n anime { count meanScore minutesWatched episodesWatched chaptersRead volumesRead }\n manga { count meanScore minutesWatched episodesWatched chaptersRead volumesRead }\n }\n";
|
|
1318
|
+
/** Favorites fragment — lightweight fields for each favorite category. */
|
|
1319
|
+
declare const USER_FAVORITES_FIELDS = "\n favourites {\n anime(perPage: 25) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n coverImage { large medium }\n type\n format\n siteUrl\n }\n }\n manga(perPage: 25) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n coverImage { large medium }\n type\n format\n siteUrl\n }\n }\n characters(perPage: 25) {\n nodes {\n __typename\n id\n name { full native }\n image { large medium }\n siteUrl\n }\n }\n staff(perPage: 25) {\n nodes {\n __typename\n id\n name { full native }\n image { large medium }\n siteUrl\n }\n }\n studios(perPage: 25) {\n nodes {\n __typename\n id\n name\n siteUrl\n }\n }\n }\n";
|
|
1320
|
+
declare const MEDIA_LIST_FIELDS = "\n __typename\n id\n mediaId\n status\n score(format: POINT_100)\n progress\n progressVolumes\n repeat\n priority\n private\n notes\n startedAt { year month day }\n completedAt { year month day }\n updatedAt\n createdAt\n media {\n \n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n duration\n chapters\n volumes\n countryOfOrigin\n isLicensed\n source\n hashtag\n trailer { id site thumbnail }\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n synonyms\n averageScore\n meanScore\n popularity\n favourites\n trending\n tags { id name description category rank isMediaSpoiler }\n studios { nodes { id name isAnimationStudio siteUrl } }\n isAdult\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n\n }\n";
|
|
1321
|
+
declare const STUDIO_FIELDS = "\n __typename\n id\n name\n isAnimationStudio\n siteUrl\n favourites\n media(page: 1, perPage: 25, sort: POPULARITY_DESC) {\n pageInfo { total perPage currentPage lastPage hasNextPage }\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n coverImage { large medium }\n siteUrl\n }\n }\n";
|
|
1322
|
+
declare const THREAD_FIELDS = "\n __typename\n id\n title\n body(asHtml: false)\n userId\n replyUserId\n replyCommentId\n replyCount\n viewCount\n isLocked\n isSticky\n isSubscribed\n repliedAt\n createdAt\n updatedAt\n siteUrl\n user {\n __typename\n id\n name\n avatar { large medium }\n }\n replyUser {\n __typename\n id\n name\n avatar { large medium }\n }\n categories {\n __typename\n id\n name\n }\n mediaCategories {\n __typename\n id\n title { romaji english native userPreferred }\n type\n coverImage { large medium }\n siteUrl\n }\n likes {\n __typename\n id\n name\n }\n";
|
|
1323
|
+
|
|
1324
|
+
declare const fragments_CHARACTER_FIELDS: typeof CHARACTER_FIELDS;
|
|
1325
|
+
declare const fragments_CHARACTER_FIELDS_COMPACT: typeof CHARACTER_FIELDS_COMPACT;
|
|
1326
|
+
declare const fragments_CHARACTER_FIELDS_WITH_VA: typeof CHARACTER_FIELDS_WITH_VA;
|
|
1327
|
+
declare const fragments_MEDIA_FIELDS: typeof MEDIA_FIELDS;
|
|
1328
|
+
declare const fragments_MEDIA_FIELDS_BASE: typeof MEDIA_FIELDS_BASE;
|
|
1329
|
+
declare const fragments_MEDIA_FIELDS_LIGHT: typeof MEDIA_FIELDS_LIGHT;
|
|
1330
|
+
declare const fragments_MEDIA_LIST_FIELDS: typeof MEDIA_LIST_FIELDS;
|
|
1331
|
+
declare const fragments_MEDIA_RECOMMENDATION_FIELDS: typeof MEDIA_RECOMMENDATION_FIELDS;
|
|
1332
|
+
declare const fragments_RELATIONS_FIELDS: typeof RELATIONS_FIELDS;
|
|
1333
|
+
declare const fragments_STAFF_FIELDS: typeof STAFF_FIELDS;
|
|
1334
|
+
declare const fragments_STAFF_MEDIA_FIELDS: typeof STAFF_MEDIA_FIELDS;
|
|
1335
|
+
declare const fragments_STUDIO_FIELDS: typeof STUDIO_FIELDS;
|
|
1336
|
+
declare const fragments_THREAD_FIELDS: typeof THREAD_FIELDS;
|
|
1337
|
+
declare const fragments_USER_FAVORITES_FIELDS: typeof USER_FAVORITES_FIELDS;
|
|
1338
|
+
declare const fragments_USER_FIELDS: typeof USER_FIELDS;
|
|
1339
|
+
declare const fragments_VOICE_ACTOR_FIELDS_COMPACT: typeof VOICE_ACTOR_FIELDS_COMPACT;
|
|
1340
|
+
declare namespace fragments {
|
|
1341
|
+
export { fragments_CHARACTER_FIELDS as CHARACTER_FIELDS, fragments_CHARACTER_FIELDS_COMPACT as CHARACTER_FIELDS_COMPACT, fragments_CHARACTER_FIELDS_WITH_VA as CHARACTER_FIELDS_WITH_VA, fragments_MEDIA_FIELDS as MEDIA_FIELDS, fragments_MEDIA_FIELDS_BASE as MEDIA_FIELDS_BASE, fragments_MEDIA_FIELDS_LIGHT as MEDIA_FIELDS_LIGHT, fragments_MEDIA_LIST_FIELDS as MEDIA_LIST_FIELDS, fragments_MEDIA_RECOMMENDATION_FIELDS as MEDIA_RECOMMENDATION_FIELDS, fragments_RELATIONS_FIELDS as RELATIONS_FIELDS, fragments_STAFF_FIELDS as STAFF_FIELDS, fragments_STAFF_MEDIA_FIELDS as STAFF_MEDIA_FIELDS, fragments_STUDIO_FIELDS as STUDIO_FIELDS, fragments_THREAD_FIELDS as THREAD_FIELDS, fragments_USER_FAVORITES_FIELDS as USER_FAVORITES_FIELDS, fragments_USER_FIELDS as USER_FIELDS, fragments_VOICE_ACTOR_FIELDS_COMPACT as VOICE_ACTOR_FIELDS_COMPACT };
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1276
1344
|
/**
|
|
1277
1345
|
* Rate limiter with automatic retry for AniList API.
|
|
1278
1346
|
*
|
|
@@ -1320,4 +1388,4 @@ declare class RateLimiter {
|
|
|
1320
1388
|
|
|
1321
1389
|
declare function parseAniListMarkdown(text: string): string;
|
|
1322
1390
|
|
|
1323
|
-
export { type AiringSchedule, AiringSort, AniListClient, AniListClientOptions, AniListError, CacheAdapter, CacheOptions, type CacheStats, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, FuzzyDate, type GetAiringOptions, type GetMediaCharactersOptions, type GetMediaStaffOptions, 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, NormalizedCache, PageInfo, PagedResult, RateLimitInfo, RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, ResponseMeta, type Review, ReviewSort, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchReviewOptions, 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 StudioIncludeOptions, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, type UserFavoritesOptions, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
|
|
1391
|
+
export { type AiringSchedule, AiringSort, AniListClient, AniListClientOptions, AniListError, CacheAdapter, CacheOptions, type CacheStats, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, fragments as Fragments, FuzzyDate, type GetAiringOptions, type GetMediaCharactersOptions, type GetMediaStaffOptions, 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, NormalizedCache, PageInfo, PagedResult, RateLimitInfo, RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, ResponseMeta, type Review, ReviewSort, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchReviewOptions, 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 StudioIncludeOptions, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, type UserFavoritesOptions, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FuzzyDate, P as PageInfo, E as ExternalLink, C as CacheAdapter, a as CacheOptions, b as PagedResult, A as AniListClientOptions, R as RateLimitInfo, c as ResponseMeta, d as RateLimitOptions } from './redis-
|
|
2
|
-
export { e as AniListHooks, L as Logger, f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from './redis-
|
|
1
|
+
import { F as FuzzyDate, P as PageInfo, E as ExternalLink, C as CacheAdapter, a as CacheOptions, b as PagedResult, A as AniListClientOptions, R as RateLimitInfo, c as ResponseMeta, d as RateLimitOptions } from './redis-ClB2nNrs.js';
|
|
2
|
+
export { e as AniListHooks, L as Logger, f as RedisCache, g as RedisCacheOptions, h as RedisLikeClient } from './redis-ClB2nNrs.js';
|
|
3
3
|
|
|
4
4
|
declare enum MediaListStatus {
|
|
5
5
|
CURRENT = "CURRENT",
|
|
@@ -156,6 +156,10 @@ interface Staff {
|
|
|
156
156
|
}
|
|
157
157
|
/** Options to include additional related data when fetching a staff member by ID. */
|
|
158
158
|
interface StaffIncludeOptions {
|
|
159
|
+
/** Include character roles (voice acting) for each media the staff member worked on. */
|
|
160
|
+
characterRoles?: boolean;
|
|
161
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
162
|
+
customFields?: string;
|
|
159
163
|
/** Include media the staff member has worked on.
|
|
160
164
|
* `true` = 25 results sorted by popularity. Object form to customize. */
|
|
161
165
|
media?: boolean | {
|
|
@@ -211,10 +215,14 @@ interface SearchStudioOptions {
|
|
|
211
215
|
* Pass `{ media: { perPage: 50 } }` to fetch more media per studio.
|
|
212
216
|
*/
|
|
213
217
|
interface StudioIncludeOptions {
|
|
214
|
-
/**
|
|
218
|
+
/** Include the media produced by this studio. */
|
|
215
219
|
media?: boolean | {
|
|
216
220
|
perPage?: number;
|
|
221
|
+
isMain?: boolean;
|
|
222
|
+
sort?: boolean;
|
|
217
223
|
};
|
|
224
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
225
|
+
customFields?: string;
|
|
218
226
|
}
|
|
219
227
|
|
|
220
228
|
declare enum UserSort {
|
|
@@ -707,6 +715,8 @@ interface MediaIncludeOptions {
|
|
|
707
715
|
recommendations?: boolean | {
|
|
708
716
|
perPage?: number;
|
|
709
717
|
};
|
|
718
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
719
|
+
customFields?: string;
|
|
710
720
|
}
|
|
711
721
|
interface GetMediaCharactersOptions {
|
|
712
722
|
/** Page number */
|
|
@@ -788,6 +798,8 @@ interface Character {
|
|
|
788
798
|
interface CharacterIncludeOptions {
|
|
789
799
|
/** Include voice actors for each media the character appears in. */
|
|
790
800
|
voiceActors?: boolean;
|
|
801
|
+
/** Raw GraphQL fields to append to the query (e.g. for custom data) */
|
|
802
|
+
customFields?: string;
|
|
791
803
|
}
|
|
792
804
|
interface SearchCharacterOptions {
|
|
793
805
|
query?: string;
|
|
@@ -1038,6 +1050,7 @@ interface ClientBase {
|
|
|
1038
1050
|
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
1039
1051
|
pagedRequest<T>(query: string, variables: Record<string, unknown>, field: string): Promise<PagedResult<T>>;
|
|
1040
1052
|
paginate<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): AsyncGenerator<T, void, undefined>;
|
|
1053
|
+
fetchAll<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): Promise<T[]>;
|
|
1041
1054
|
}
|
|
1042
1055
|
|
|
1043
1056
|
/**
|
|
@@ -1072,6 +1085,7 @@ declare class AniListClient implements ClientBase {
|
|
|
1072
1085
|
private readonly mediaLoader;
|
|
1073
1086
|
private readonly characterLoader;
|
|
1074
1087
|
private readonly staffLoader;
|
|
1088
|
+
private readonly batchingEnabled;
|
|
1075
1089
|
constructor(options?: AniListClientOptions);
|
|
1076
1090
|
/**
|
|
1077
1091
|
* The current rate limit information from the last API response.
|
|
@@ -1213,6 +1227,13 @@ declare class AniListClient implements ClientBase {
|
|
|
1213
1227
|
* @param maxPages - Maximum number of pages to fetch (default: Infinity)
|
|
1214
1228
|
*/
|
|
1215
1229
|
paginate<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): AsyncGenerator<T, void, undefined>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Utility to fetch all pages of a paginated request and return them as a single array.
|
|
1232
|
+
*
|
|
1233
|
+
* @param fetchPage - A function that takes a page number and returns a `PagedResult<T>`
|
|
1234
|
+
* @param maxPages - Maximum number of pages to fetch (default: Infinity)
|
|
1235
|
+
*/
|
|
1236
|
+
fetchAll<T>(fetchPage: (page: number) => Promise<PagedResult<T>>, maxPages?: number): Promise<T[]>;
|
|
1216
1237
|
/** Fetch multiple media entries in a single API request. */
|
|
1217
1238
|
getMediaBatch(ids: number[]): Promise<Media[]>;
|
|
1218
1239
|
/** Fetch multiple characters in a single API request. */
|
|
@@ -1273,6 +1294,53 @@ declare class AniListError extends Error {
|
|
|
1273
1294
|
constructor(message: string, status: number, errors?: GraphQLError[] | unknown[]);
|
|
1274
1295
|
}
|
|
1275
1296
|
|
|
1297
|
+
/**
|
|
1298
|
+
* Lightweight media fields — minimal payload for list/search contexts.
|
|
1299
|
+
* Does NOT include tags, studios, trailer, synonyms, or nextAiringEpisode.
|
|
1300
|
+
*/
|
|
1301
|
+
declare const MEDIA_FIELDS_LIGHT = "\n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n coverImage { large medium color }\n bannerImage\n genres\n averageScore\n popularity\n favourites\n isAdult\n siteUrl\n season\n seasonYear\n episodes\n chapters\n nextAiringEpisode {\n id\n airingAt\n episode\n timeUntilAiring\n }\n";
|
|
1302
|
+
/** Core media fields — always returned. Does NOT include relations (opt-in via include). */
|
|
1303
|
+
declare const MEDIA_FIELDS_BASE = "\n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n duration\n chapters\n volumes\n countryOfOrigin\n isLicensed\n source\n hashtag\n trailer { id site thumbnail }\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n synonyms\n averageScore\n meanScore\n popularity\n favourites\n trending\n tags { id name description category rank isMediaSpoiler }\n studios { nodes { id name isAnimationStudio siteUrl } }\n isAdult\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n";
|
|
1304
|
+
declare const RELATIONS_FIELDS = "\n relations {\n edges {\n relationType(version: 2)\n node {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n chapters\n volumes\n coverImage { extraLarge large medium color }\n genres\n averageScore\n meanScore\n studios { nodes { id name isAnimationStudio siteUrl } }\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n }\n }\n }\n";
|
|
1305
|
+
/** Media Recommendation fields - used for when fetching recommendation for a specific media entry */
|
|
1306
|
+
declare const MEDIA_RECOMMENDATION_FIELDS = "\n __typename\n id\n rating\n mediaRecommendation {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n coverImage { extraLarge large medium color }\n averageScore\n meanScore\n \tepisodes\n \tchapters\n \tvolumes\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n \tseason\n \tseasonYear\n \tstartDate { year month day }\n endDate { year month day }\n \tstudios { nodes { id name isAnimationStudio siteUrl } }\n \tgenres\n siteUrl\n }\n";
|
|
1307
|
+
/** Full media fields with relations — used by existing queries for backward compat. */
|
|
1308
|
+
declare const MEDIA_FIELDS = "\n \n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n duration\n chapters\n volumes\n countryOfOrigin\n isLicensed\n source\n hashtag\n trailer { id site thumbnail }\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n synonyms\n averageScore\n meanScore\n popularity\n favourites\n trending\n tags { id name description category rank isMediaSpoiler }\n studios { nodes { id name isAnimationStudio siteUrl } }\n isAdult\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n\n \n relations {\n edges {\n relationType(version: 2)\n node {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n chapters\n volumes\n coverImage { extraLarge large medium color }\n genres\n averageScore\n meanScore\n studios { nodes { id name isAnimationStudio siteUrl } }\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n }\n }\n }\n\n";
|
|
1309
|
+
/** Character fields without back-reference to media (used when embedding characters inside a Media query). */
|
|
1310
|
+
declare const CHARACTER_FIELDS_COMPACT = "\n __typename\n id\n name { first middle last full native alternative }\n image { large medium }\n description(asHtml: false)\n gender\n dateOfBirth { year month day }\n age\n bloodType\n favourites\n siteUrl\n";
|
|
1311
|
+
/** Compact voice actor fields — lightweight subset for embedding inside character edges. */
|
|
1312
|
+
declare const VOICE_ACTOR_FIELDS_COMPACT = "\n __typename\n id\n name { first middle last full native userPreferred }\n languageV2\n image { large medium }\n gender\n primaryOccupations\n siteUrl\n";
|
|
1313
|
+
declare const CHARACTER_FIELDS = "\n \n __typename\n id\n name { first middle last full native alternative }\n image { large medium }\n description(asHtml: false)\n gender\n dateOfBirth { year month day }\n age\n bloodType\n favourites\n siteUrl\n\n \n media(perPage: 10) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n type\n coverImage { large medium }\n siteUrl\n }\n }\n\n";
|
|
1314
|
+
declare const CHARACTER_FIELDS_WITH_VA = "\n \n __typename\n id\n name { first middle last full native alternative }\n image { large medium }\n description(asHtml: false)\n gender\n dateOfBirth { year month day }\n age\n bloodType\n favourites\n siteUrl\n\n \n media(perPage: 10) {\n edges {\n voiceActors {\n \n __typename\n id\n name { first middle last full native userPreferred }\n languageV2\n image { large medium }\n gender\n primaryOccupations\n siteUrl\n\n }\n node {\n __typename\n id\n title { romaji english native userPreferred }\n type\n coverImage { large medium }\n siteUrl\n }\n }\n }\n\n";
|
|
1315
|
+
declare const STAFF_FIELDS = "\n __typename\n id\n name { first middle last full native }\n language\n image { large medium }\n description(asHtml: false)\n primaryOccupations\n gender\n dateOfBirth { year month day }\n dateOfDeath { year month day }\n age\n yearsActive\n homeTown\n bloodType\n favourites\n siteUrl\n";
|
|
1316
|
+
declare const STAFF_MEDIA_FIELDS = "\n staffMedia(perPage: $perPage, sort: [POPULARITY_DESC]) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n status\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n averageScore\n meanScore\n popularity\n favourites\n episodes\n trending\n hashtag\n season\n seasonYear\n startDate { year month day }\n endDate { year month day }\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n studios {\n edges {\n node {\n name\n }\n }\n }\n siteUrl\n }\n }\n";
|
|
1317
|
+
declare const USER_FIELDS = "\n __typename\n id\n name\n about(asHtml: false)\n avatar { large medium }\n bannerImage\n isFollowing\n isFollower\n donatorTier\n donatorBadge\n createdAt\n siteUrl\n statistics {\n anime { count meanScore minutesWatched episodesWatched chaptersRead volumesRead }\n manga { count meanScore minutesWatched episodesWatched chaptersRead volumesRead }\n }\n";
|
|
1318
|
+
/** Favorites fragment — lightweight fields for each favorite category. */
|
|
1319
|
+
declare const USER_FAVORITES_FIELDS = "\n favourites {\n anime(perPage: 25) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n coverImage { large medium }\n type\n format\n siteUrl\n }\n }\n manga(perPage: 25) {\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n coverImage { large medium }\n type\n format\n siteUrl\n }\n }\n characters(perPage: 25) {\n nodes {\n __typename\n id\n name { full native }\n image { large medium }\n siteUrl\n }\n }\n staff(perPage: 25) {\n nodes {\n __typename\n id\n name { full native }\n image { large medium }\n siteUrl\n }\n }\n studios(perPage: 25) {\n nodes {\n __typename\n id\n name\n siteUrl\n }\n }\n }\n";
|
|
1320
|
+
declare const MEDIA_LIST_FIELDS = "\n __typename\n id\n mediaId\n status\n score(format: POINT_100)\n progress\n progressVolumes\n repeat\n priority\n private\n notes\n startedAt { year month day }\n completedAt { year month day }\n updatedAt\n createdAt\n media {\n \n __typename\n id\n idMal\n title { romaji english native userPreferred }\n type\n format\n status\n description(asHtml: false)\n startDate { year month day }\n endDate { year month day }\n season\n seasonYear\n episodes\n duration\n chapters\n volumes\n countryOfOrigin\n isLicensed\n source\n hashtag\n trailer { id site thumbnail }\n coverImage { extraLarge large medium color }\n bannerImage\n genres\n synonyms\n averageScore\n meanScore\n popularity\n favourites\n trending\n tags { id name description category rank isMediaSpoiler }\n studios { nodes { id name isAnimationStudio siteUrl } }\n isAdult\n siteUrl\n nextAiringEpisode {\n id\n airingAt\n episode\n mediaId\n timeUntilAiring\n }\n\n }\n";
|
|
1321
|
+
declare const STUDIO_FIELDS = "\n __typename\n id\n name\n isAnimationStudio\n siteUrl\n favourites\n media(page: 1, perPage: 25, sort: POPULARITY_DESC) {\n pageInfo { total perPage currentPage lastPage hasNextPage }\n nodes {\n __typename\n id\n title { romaji english native userPreferred }\n type\n format\n coverImage { large medium }\n siteUrl\n }\n }\n";
|
|
1322
|
+
declare const THREAD_FIELDS = "\n __typename\n id\n title\n body(asHtml: false)\n userId\n replyUserId\n replyCommentId\n replyCount\n viewCount\n isLocked\n isSticky\n isSubscribed\n repliedAt\n createdAt\n updatedAt\n siteUrl\n user {\n __typename\n id\n name\n avatar { large medium }\n }\n replyUser {\n __typename\n id\n name\n avatar { large medium }\n }\n categories {\n __typename\n id\n name\n }\n mediaCategories {\n __typename\n id\n title { romaji english native userPreferred }\n type\n coverImage { large medium }\n siteUrl\n }\n likes {\n __typename\n id\n name\n }\n";
|
|
1323
|
+
|
|
1324
|
+
declare const fragments_CHARACTER_FIELDS: typeof CHARACTER_FIELDS;
|
|
1325
|
+
declare const fragments_CHARACTER_FIELDS_COMPACT: typeof CHARACTER_FIELDS_COMPACT;
|
|
1326
|
+
declare const fragments_CHARACTER_FIELDS_WITH_VA: typeof CHARACTER_FIELDS_WITH_VA;
|
|
1327
|
+
declare const fragments_MEDIA_FIELDS: typeof MEDIA_FIELDS;
|
|
1328
|
+
declare const fragments_MEDIA_FIELDS_BASE: typeof MEDIA_FIELDS_BASE;
|
|
1329
|
+
declare const fragments_MEDIA_FIELDS_LIGHT: typeof MEDIA_FIELDS_LIGHT;
|
|
1330
|
+
declare const fragments_MEDIA_LIST_FIELDS: typeof MEDIA_LIST_FIELDS;
|
|
1331
|
+
declare const fragments_MEDIA_RECOMMENDATION_FIELDS: typeof MEDIA_RECOMMENDATION_FIELDS;
|
|
1332
|
+
declare const fragments_RELATIONS_FIELDS: typeof RELATIONS_FIELDS;
|
|
1333
|
+
declare const fragments_STAFF_FIELDS: typeof STAFF_FIELDS;
|
|
1334
|
+
declare const fragments_STAFF_MEDIA_FIELDS: typeof STAFF_MEDIA_FIELDS;
|
|
1335
|
+
declare const fragments_STUDIO_FIELDS: typeof STUDIO_FIELDS;
|
|
1336
|
+
declare const fragments_THREAD_FIELDS: typeof THREAD_FIELDS;
|
|
1337
|
+
declare const fragments_USER_FAVORITES_FIELDS: typeof USER_FAVORITES_FIELDS;
|
|
1338
|
+
declare const fragments_USER_FIELDS: typeof USER_FIELDS;
|
|
1339
|
+
declare const fragments_VOICE_ACTOR_FIELDS_COMPACT: typeof VOICE_ACTOR_FIELDS_COMPACT;
|
|
1340
|
+
declare namespace fragments {
|
|
1341
|
+
export { fragments_CHARACTER_FIELDS as CHARACTER_FIELDS, fragments_CHARACTER_FIELDS_COMPACT as CHARACTER_FIELDS_COMPACT, fragments_CHARACTER_FIELDS_WITH_VA as CHARACTER_FIELDS_WITH_VA, fragments_MEDIA_FIELDS as MEDIA_FIELDS, fragments_MEDIA_FIELDS_BASE as MEDIA_FIELDS_BASE, fragments_MEDIA_FIELDS_LIGHT as MEDIA_FIELDS_LIGHT, fragments_MEDIA_LIST_FIELDS as MEDIA_LIST_FIELDS, fragments_MEDIA_RECOMMENDATION_FIELDS as MEDIA_RECOMMENDATION_FIELDS, fragments_RELATIONS_FIELDS as RELATIONS_FIELDS, fragments_STAFF_FIELDS as STAFF_FIELDS, fragments_STAFF_MEDIA_FIELDS as STAFF_MEDIA_FIELDS, fragments_STUDIO_FIELDS as STUDIO_FIELDS, fragments_THREAD_FIELDS as THREAD_FIELDS, fragments_USER_FAVORITES_FIELDS as USER_FAVORITES_FIELDS, fragments_USER_FIELDS as USER_FIELDS, fragments_VOICE_ACTOR_FIELDS_COMPACT as VOICE_ACTOR_FIELDS_COMPACT };
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1276
1344
|
/**
|
|
1277
1345
|
* Rate limiter with automatic retry for AniList API.
|
|
1278
1346
|
*
|
|
@@ -1320,4 +1388,4 @@ declare class RateLimiter {
|
|
|
1320
1388
|
|
|
1321
1389
|
declare function parseAniListMarkdown(text: string): string;
|
|
1322
1390
|
|
|
1323
|
-
export { type AiringSchedule, AiringSort, AniListClient, AniListClientOptions, AniListError, CacheAdapter, CacheOptions, type CacheStats, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, FuzzyDate, type GetAiringOptions, type GetMediaCharactersOptions, type GetMediaStaffOptions, 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, NormalizedCache, PageInfo, PagedResult, RateLimitInfo, RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, ResponseMeta, type Review, ReviewSort, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchReviewOptions, 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 StudioIncludeOptions, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, type UserFavoritesOptions, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
|
|
1391
|
+
export { type AiringSchedule, AiringSort, AniListClient, AniListClientOptions, AniListError, CacheAdapter, CacheOptions, type CacheStats, type Character, type CharacterImage, type CharacterIncludeOptions, type CharacterMediaEdge, type CharacterName, CharacterRole, CharacterSort, type DayOfWeek, ExternalLink, type FavoriteCharacterNode, type FavoriteMediaNode, type FavoriteStaffNode, type FavoriteStudioNode, fragments as Fragments, FuzzyDate, type GetAiringOptions, type GetMediaCharactersOptions, type GetMediaStaffOptions, 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, NormalizedCache, PageInfo, PagedResult, RateLimitInfo, RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, ResponseMeta, type Review, ReviewSort, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchReviewOptions, 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 StudioIncludeOptions, StudioSort, type Thread, type ThreadCategory, type ThreadMediaCategory, ThreadSort, type User, type UserAvatar, type UserFavorites, type UserFavoritesOptions, UserSort, type UserStatistics, type VoiceActor, type WeeklySchedule, parseAniListMarkdown };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __export = (target, all) => {
|
|
5
|
+
for (var name in all)
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
// src/utils/dataloader.ts
|
|
4
10
|
var BatchLoader = class {
|
|
5
|
-
constructor(batchFetch, maxWaitMs = 50) {
|
|
11
|
+
constructor(batchFetch, maxWaitMs = 50, maxBatchSize = 50) {
|
|
6
12
|
this.batchFetch = batchFetch;
|
|
7
13
|
this.maxWaitMs = maxWaitMs;
|
|
14
|
+
this.maxBatchSize = maxBatchSize;
|
|
8
15
|
}
|
|
9
16
|
queue = /* @__PURE__ */ new Map();
|
|
10
17
|
timeout = null;
|
|
@@ -20,10 +27,21 @@ var BatchLoader = class {
|
|
|
20
27
|
this.queue.set(id, callbacks);
|
|
21
28
|
}
|
|
22
29
|
callbacks.push({ resolve, reject });
|
|
30
|
+
if (this.queue.size >= this.maxBatchSize) {
|
|
31
|
+
if (this.timeout) {
|
|
32
|
+
clearTimeout(this.timeout);
|
|
33
|
+
this.timeout = null;
|
|
34
|
+
}
|
|
35
|
+
void this.dispatch();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
23
38
|
if (this.timeout === null) {
|
|
24
|
-
this.timeout = setTimeout(() =>
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
this.timeout = setTimeout(() => {
|
|
40
|
+
void this.dispatch();
|
|
41
|
+
}, this.maxWaitMs);
|
|
42
|
+
const timer = this.timeout;
|
|
43
|
+
if (typeof timer.unref === "function") {
|
|
44
|
+
timer.unref();
|
|
27
45
|
}
|
|
28
46
|
}
|
|
29
47
|
});
|
|
@@ -632,6 +650,25 @@ var AniListError = class _AniListError extends Error {
|
|
|
632
650
|
};
|
|
633
651
|
|
|
634
652
|
// src/queries/fragments.ts
|
|
653
|
+
var fragments_exports = {};
|
|
654
|
+
__export(fragments_exports, {
|
|
655
|
+
CHARACTER_FIELDS: () => CHARACTER_FIELDS,
|
|
656
|
+
CHARACTER_FIELDS_COMPACT: () => CHARACTER_FIELDS_COMPACT,
|
|
657
|
+
CHARACTER_FIELDS_WITH_VA: () => CHARACTER_FIELDS_WITH_VA,
|
|
658
|
+
MEDIA_FIELDS: () => MEDIA_FIELDS,
|
|
659
|
+
MEDIA_FIELDS_BASE: () => MEDIA_FIELDS_BASE,
|
|
660
|
+
MEDIA_FIELDS_LIGHT: () => MEDIA_FIELDS_LIGHT,
|
|
661
|
+
MEDIA_LIST_FIELDS: () => MEDIA_LIST_FIELDS,
|
|
662
|
+
MEDIA_RECOMMENDATION_FIELDS: () => MEDIA_RECOMMENDATION_FIELDS,
|
|
663
|
+
RELATIONS_FIELDS: () => RELATIONS_FIELDS,
|
|
664
|
+
STAFF_FIELDS: () => STAFF_FIELDS,
|
|
665
|
+
STAFF_MEDIA_FIELDS: () => STAFF_MEDIA_FIELDS,
|
|
666
|
+
STUDIO_FIELDS: () => STUDIO_FIELDS,
|
|
667
|
+
THREAD_FIELDS: () => THREAD_FIELDS,
|
|
668
|
+
USER_FAVORITES_FIELDS: () => USER_FAVORITES_FIELDS,
|
|
669
|
+
USER_FIELDS: () => USER_FIELDS,
|
|
670
|
+
VOICE_ACTOR_FIELDS_COMPACT: () => VOICE_ACTOR_FIELDS_COMPACT
|
|
671
|
+
});
|
|
635
672
|
var MEDIA_FIELDS_LIGHT = `
|
|
636
673
|
__typename
|
|
637
674
|
id
|
|
@@ -1322,6 +1359,9 @@ function buildMediaIncludeQuery(include) {
|
|
|
1322
1359
|
statusDistribution { status amount }
|
|
1323
1360
|
}`);
|
|
1324
1361
|
}
|
|
1362
|
+
if (include.customFields) {
|
|
1363
|
+
extra.push(include.customFields);
|
|
1364
|
+
}
|
|
1325
1365
|
return extra;
|
|
1326
1366
|
}
|
|
1327
1367
|
function buildMediaByIdQuery(include) {
|
|
@@ -1549,6 +1589,14 @@ query ($id: Int!) {
|
|
|
1549
1589
|
${CHARACTER_FIELDS_WITH_VA}
|
|
1550
1590
|
}
|
|
1551
1591
|
}`;
|
|
1592
|
+
function buildCharacterByIdQuery(include) {
|
|
1593
|
+
if (!include?.customFields) {
|
|
1594
|
+
return include?.voiceActors ? QUERY_CHARACTER_BY_ID_WITH_VA : QUERY_CHARACTER_BY_ID;
|
|
1595
|
+
}
|
|
1596
|
+
const fields = include.voiceActors ? CHARACTER_FIELDS_WITH_VA : CHARACTER_FIELDS;
|
|
1597
|
+
return `query ($id: Int!) { Character(id: $id) { ${fields}
|
|
1598
|
+
${include.customFields} } }`;
|
|
1599
|
+
}
|
|
1552
1600
|
var QUERY_CHARACTER_SEARCH = `
|
|
1553
1601
|
query ($search: String, $sort: [CharacterSort], $page: Int, $perPage: Int) {
|
|
1554
1602
|
Page(page: $page, perPage: $perPage) {
|
|
@@ -1667,6 +1715,15 @@ query ($id: Int!, $perPage: Int) {
|
|
|
1667
1715
|
${STAFF_MEDIA_FIELDS}
|
|
1668
1716
|
}
|
|
1669
1717
|
}`;
|
|
1718
|
+
function buildStaffByIdQuery(include) {
|
|
1719
|
+
if (!include?.customFields) {
|
|
1720
|
+
return include?.characterRoles || include?.media ? QUERY_STAFF_BY_ID_WITH_MEDIA : QUERY_STAFF_BY_ID;
|
|
1721
|
+
}
|
|
1722
|
+
const extra = include?.characterRoles || include?.media ? `
|
|
1723
|
+
${STAFF_MEDIA_FIELDS}` : "";
|
|
1724
|
+
return `query ($id: Int!, $perPage: Int) { Staff(id: $id) { ${STAFF_FIELDS}${extra}
|
|
1725
|
+
${include.customFields} } }`;
|
|
1726
|
+
}
|
|
1670
1727
|
var QUERY_STAFF_SEARCH = `
|
|
1671
1728
|
query ($search: String, $sort: [StaffSort], $page: Int, $perPage: Int) {
|
|
1672
1729
|
Page(page: $page, perPage: $perPage) {
|
|
@@ -1684,9 +1741,15 @@ query ($id: Int!) {
|
|
|
1684
1741
|
${STUDIO_FIELDS}
|
|
1685
1742
|
}
|
|
1686
1743
|
}`;
|
|
1687
|
-
function buildStudioByIdQuery(
|
|
1688
|
-
|
|
1689
|
-
|
|
1744
|
+
function buildStudioByIdQuery(include) {
|
|
1745
|
+
const custom = include?.customFields ? `
|
|
1746
|
+
${include.customFields}` : "";
|
|
1747
|
+
if (!include?.media) {
|
|
1748
|
+
if (!custom) return QUERY_STUDIO_BY_ID;
|
|
1749
|
+
return `query ($id: Int!) { Studio(id: $id) { ${STUDIO_FIELDS}${custom} } }`;
|
|
1750
|
+
}
|
|
1751
|
+
const mediaOpts = typeof include.media === "object" ? include.media : {};
|
|
1752
|
+
const pp = clampPerPage(mediaOpts.perPage ?? 25);
|
|
1690
1753
|
return `
|
|
1691
1754
|
query ($id: Int!) {
|
|
1692
1755
|
Studio(id: $id) {
|
|
@@ -1700,7 +1763,7 @@ query ($id: Int!) {
|
|
|
1700
1763
|
nodes {
|
|
1701
1764
|
${MEDIA_FIELDS_LIGHT}
|
|
1702
1765
|
}
|
|
1703
|
-
}
|
|
1766
|
+
}${custom}
|
|
1704
1767
|
}
|
|
1705
1768
|
}`;
|
|
1706
1769
|
}
|
|
@@ -1983,7 +2046,7 @@ function isNetworkError(err) {
|
|
|
1983
2046
|
// src/client/character.ts
|
|
1984
2047
|
async function getCharacter(client, id, include) {
|
|
1985
2048
|
validateId(id, "characterId");
|
|
1986
|
-
const query = include
|
|
2049
|
+
const query = buildCharacterByIdQuery(include);
|
|
1987
2050
|
const data = await client.request(query, { id });
|
|
1988
2051
|
return data.Character;
|
|
1989
2052
|
}
|
|
@@ -2460,12 +2523,13 @@ async function searchReviews(client, options = {}) {
|
|
|
2460
2523
|
// src/client/staff.ts
|
|
2461
2524
|
async function getStaff(client, id, include) {
|
|
2462
2525
|
validateId(id, "staffId");
|
|
2463
|
-
|
|
2526
|
+
const query = buildStaffByIdQuery(include);
|
|
2527
|
+
if (include?.characterRoles || include?.media) {
|
|
2464
2528
|
const perPage = typeof include.media === "object" ? include.media.perPage ?? 25 : 25;
|
|
2465
|
-
const data2 = await client.request(
|
|
2529
|
+
const data2 = await client.request(query, { id, perPage });
|
|
2466
2530
|
return data2.Staff;
|
|
2467
2531
|
}
|
|
2468
|
-
const data = await client.request(
|
|
2532
|
+
const data = await client.request(query, { id });
|
|
2469
2533
|
return data.Staff;
|
|
2470
2534
|
}
|
|
2471
2535
|
async function searchStaff(client, options = {}) {
|
|
@@ -2480,13 +2544,8 @@ async function searchStaff(client, options = {}) {
|
|
|
2480
2544
|
// src/client/studio.ts
|
|
2481
2545
|
async function getStudio(client, id, include) {
|
|
2482
2546
|
validateId(id, "studioId");
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
const query = buildStudioByIdQuery(perPage);
|
|
2486
|
-
const data2 = await client.request(query, { id });
|
|
2487
|
-
return data2.Studio;
|
|
2488
|
-
}
|
|
2489
|
-
const data = await client.request(QUERY_STUDIO_BY_ID, { id });
|
|
2547
|
+
const query = buildStudioByIdQuery(include);
|
|
2548
|
+
const data = await client.request(query, { id });
|
|
2490
2549
|
return data.Studio;
|
|
2491
2550
|
}
|
|
2492
2551
|
async function searchStudios(client, options = {}) {
|
|
@@ -2588,7 +2647,7 @@ function mapFavorites(fav) {
|
|
|
2588
2647
|
|
|
2589
2648
|
// src/client/index.ts
|
|
2590
2649
|
var DEFAULT_API_URL = "https://graphql.anilist.co";
|
|
2591
|
-
var LIB_VERSION = "2.
|
|
2650
|
+
var LIB_VERSION = "2.5.0" ;
|
|
2592
2651
|
var AniListClient = class {
|
|
2593
2652
|
apiUrl;
|
|
2594
2653
|
headers;
|
|
@@ -2603,6 +2662,7 @@ var AniListClient = class {
|
|
|
2603
2662
|
mediaLoader;
|
|
2604
2663
|
characterLoader;
|
|
2605
2664
|
staffLoader;
|
|
2665
|
+
batchingEnabled;
|
|
2606
2666
|
constructor(options = {}) {
|
|
2607
2667
|
this.apiUrl = options.apiUrl ?? DEFAULT_API_URL;
|
|
2608
2668
|
this.headers = {
|
|
@@ -2618,9 +2678,12 @@ var AniListClient = class {
|
|
|
2618
2678
|
this.hooks = options.hooks ?? {};
|
|
2619
2679
|
this.logger = options.logger;
|
|
2620
2680
|
this.signal = options.signal;
|
|
2621
|
-
this.
|
|
2622
|
-
|
|
2623
|
-
|
|
2681
|
+
this.batchingEnabled = options.batching?.enabled ?? true;
|
|
2682
|
+
const windowMs = options.batching?.windowMs ?? 50;
|
|
2683
|
+
const maxBatchSize = options.batching?.maxBatchSize ?? 50;
|
|
2684
|
+
this.mediaLoader = new BatchLoader((ids) => this.getMediaBatch(ids), windowMs, maxBatchSize);
|
|
2685
|
+
this.characterLoader = new BatchLoader((ids) => this.getCharacterBatch(ids), windowMs, maxBatchSize);
|
|
2686
|
+
this.staffLoader = new BatchLoader((ids) => this.getStaffBatch(ids), windowMs, maxBatchSize);
|
|
2624
2687
|
}
|
|
2625
2688
|
/**
|
|
2626
2689
|
* The current rate limit information from the last API response.
|
|
@@ -2723,6 +2786,17 @@ var AniListClient = class {
|
|
|
2723
2786
|
remaining: Number.parseInt(rlRemaining, 10),
|
|
2724
2787
|
reset: Number.parseInt(rlReset, 10)
|
|
2725
2788
|
};
|
|
2789
|
+
const remainingPercent = this._rateLimitInfo.remaining / this._rateLimitInfo.limit;
|
|
2790
|
+
if (remainingPercent <= 0.15) {
|
|
2791
|
+
const resetIn = this._rateLimitInfo.reset - Math.floor(Date.now() / 1e3);
|
|
2792
|
+
const resetInSeconds = resetIn > 0 ? resetIn : 0;
|
|
2793
|
+
this.logger?.warn("Smart Alert: AniList API rate limit is critically low", {
|
|
2794
|
+
remaining: this._rateLimitInfo.remaining,
|
|
2795
|
+
limit: this._rateLimitInfo.limit,
|
|
2796
|
+
resetInSeconds
|
|
2797
|
+
});
|
|
2798
|
+
this.hooks.onRateLimitAlert?.(this._rateLimitInfo.remaining, resetInSeconds);
|
|
2799
|
+
}
|
|
2726
2800
|
}
|
|
2727
2801
|
const durationMs = Date.now() - start;
|
|
2728
2802
|
const data = json.data;
|
|
@@ -2751,10 +2825,10 @@ var AniListClient = class {
|
|
|
2751
2825
|
* @param include - Optional related data to include
|
|
2752
2826
|
*/
|
|
2753
2827
|
async getMedia(id, include) {
|
|
2754
|
-
if (!include) {
|
|
2755
|
-
return this
|
|
2828
|
+
if (!this.batchingEnabled || include) {
|
|
2829
|
+
return getMedia(this, id, include);
|
|
2756
2830
|
}
|
|
2757
|
-
return
|
|
2831
|
+
return this.mediaLoader.load(id);
|
|
2758
2832
|
}
|
|
2759
2833
|
async getMediaCharacters(mediaId, options = {}) {
|
|
2760
2834
|
return getMediaCharacters(this, mediaId, options);
|
|
@@ -2822,10 +2896,10 @@ var AniListClient = class {
|
|
|
2822
2896
|
}
|
|
2823
2897
|
/** Fetch a character by AniList ID. Pass `{ voiceActors: true }` to include VA data. */
|
|
2824
2898
|
async getCharacter(id, include) {
|
|
2825
|
-
if (!include) {
|
|
2826
|
-
return this
|
|
2899
|
+
if (!this.batchingEnabled || include) {
|
|
2900
|
+
return getCharacter(this, id, include);
|
|
2827
2901
|
}
|
|
2828
|
-
return
|
|
2902
|
+
return this.characterLoader.load(id);
|
|
2829
2903
|
}
|
|
2830
2904
|
/** Search for characters by name. */
|
|
2831
2905
|
async searchCharacters(options = {}) {
|
|
@@ -2833,10 +2907,10 @@ var AniListClient = class {
|
|
|
2833
2907
|
}
|
|
2834
2908
|
/** Fetch a staff member by AniList ID. Pass `{ media: true }` or `{ media: { perPage } }` for media credits. */
|
|
2835
2909
|
async getStaff(id, include) {
|
|
2836
|
-
if (!include) {
|
|
2837
|
-
return this
|
|
2910
|
+
if (!this.batchingEnabled || include) {
|
|
2911
|
+
return getStaff(this, id, include);
|
|
2838
2912
|
}
|
|
2839
|
-
return
|
|
2913
|
+
return this.staffLoader.load(id);
|
|
2840
2914
|
}
|
|
2841
2915
|
/** Search for staff (voice actors, directors, etc.). */
|
|
2842
2916
|
async searchStaff(options = {}) {
|
|
@@ -2950,6 +3024,19 @@ var AniListClient = class {
|
|
|
2950
3024
|
page++;
|
|
2951
3025
|
}
|
|
2952
3026
|
}
|
|
3027
|
+
/**
|
|
3028
|
+
* Utility to fetch all pages of a paginated request and return them as a single array.
|
|
3029
|
+
*
|
|
3030
|
+
* @param fetchPage - A function that takes a page number and returns a `PagedResult<T>`
|
|
3031
|
+
* @param maxPages - Maximum number of pages to fetch (default: Infinity)
|
|
3032
|
+
*/
|
|
3033
|
+
async fetchAll(fetchPage, maxPages = Number.POSITIVE_INFINITY) {
|
|
3034
|
+
const results = [];
|
|
3035
|
+
for await (const item of this.paginate(fetchPage, maxPages)) {
|
|
3036
|
+
results.push(item);
|
|
3037
|
+
}
|
|
3038
|
+
return results;
|
|
3039
|
+
}
|
|
2953
3040
|
/** Fetch multiple media entries in a single API request. */
|
|
2954
3041
|
async getMediaBatch(ids) {
|
|
2955
3042
|
if (ids.length === 0) return [];
|
|
@@ -3042,6 +3129,7 @@ exports.AniListClient = AniListClient;
|
|
|
3042
3129
|
exports.AniListError = AniListError;
|
|
3043
3130
|
exports.CharacterRole = CharacterRole;
|
|
3044
3131
|
exports.CharacterSort = CharacterSort;
|
|
3132
|
+
exports.Fragments = fragments_exports;
|
|
3045
3133
|
exports.MediaFormat = MediaFormat;
|
|
3046
3134
|
exports.MediaListSort = MediaListSort;
|
|
3047
3135
|
exports.MediaListStatus = MediaListStatus;
|