ani-client 1.4.1 → 1.4.2

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
@@ -265,12 +265,21 @@ const result = await client.searchCharacters({ query: "Luffy", voiceActors: true
265
265
 
266
266
  | Method | Description |
267
267
  | --- | --- |
268
- | `getStaff(id)` | Fetch a staff member by ID |
268
+ | `getStaff(id, include?)` | Fetch a staff member by ID (optionally with media) |
269
269
  | `searchStaff(options?)` | Search for staff members |
270
270
 
271
271
  ```ts
272
272
  const staff = await client.getStaff(95001);
273
273
  const results = await client.searchStaff({ query: "Miyazaki" });
274
+
275
+ // With media the staff member worked on
276
+ const staffWithMedia = await client.getStaff(95001, { media: true });
277
+ staffWithMedia.staffMedia?.nodes.forEach((m) => {
278
+ console.log(m.title.romaji, m.format, m.averageScore);
279
+ });
280
+
281
+ // Customize the number of media returned
282
+ const staffWith5Media = await client.getStaff(95001, { media: { perPage: 5 } });
274
283
  ```
275
284
 
276
285
  ### Users
@@ -566,6 +575,7 @@ import type {
566
575
  MediaEdge, MediaConnection, MediaCharacterEdge, MediaCharacterConnection,
567
576
  CharacterMediaEdge, CharacterIncludeOptions,
568
577
  MediaStaffEdge, MediaStaffConnection, MediaIncludeOptions,
578
+ StaffMediaNode, StaffIncludeOptions,
569
579
  StreamingEpisode, ExternalLink, MediaStats, MediaRecommendationNode,
570
580
  PageInfo, PagedResult,
571
581
  CacheAdapter, AniListHooks, AniListClientOptions,
package/dist/index.d.mts CHANGED
@@ -303,6 +303,43 @@ interface StaffImage {
303
303
  large: string | null;
304
304
  medium: string | null;
305
305
  }
306
+ /** A media node returned inside `Staff.staffMedia`. */
307
+ interface StaffMediaNode {
308
+ id: number;
309
+ title: MediaTitle;
310
+ type: MediaType;
311
+ format: MediaFormat | null;
312
+ status: MediaStatus | null;
313
+ coverImage: MediaCoverImage;
314
+ bannerImage: string | null;
315
+ genres: string[];
316
+ averageScore: number | null;
317
+ meanScore: number | null;
318
+ popularity: number | null;
319
+ favourites: number | null;
320
+ episodes: number | null;
321
+ trending: number | null;
322
+ hashtag: string | null;
323
+ season: MediaSeason | null;
324
+ seasonYear: number | null;
325
+ startDate: FuzzyDate | null;
326
+ endDate: FuzzyDate | null;
327
+ nextAiringEpisode: {
328
+ id: number;
329
+ airingAt: number;
330
+ episode: number;
331
+ mediaId: number;
332
+ timeUntilAiring: number;
333
+ } | null;
334
+ studios: {
335
+ edges: {
336
+ node: {
337
+ name: string;
338
+ };
339
+ }[];
340
+ } | null;
341
+ siteUrl: string | null;
342
+ }
306
343
  interface Staff {
307
344
  id: number;
308
345
  name: StaffName;
@@ -319,6 +356,19 @@ interface Staff {
319
356
  bloodType: string | null;
320
357
  favourites: number | null;
321
358
  siteUrl: string | null;
359
+ /** Media the staff member has worked on — only present when requested via include options. */
360
+ staffMedia?: {
361
+ nodes: StaffMediaNode[];
362
+ } | null;
363
+ }
364
+ /** Options to include additional related data when fetching a staff member by ID. */
365
+ interface StaffIncludeOptions {
366
+ /** Include media the staff member has worked on.
367
+ * `true` = 25 results sorted by popularity. Object form to customize. */
368
+ media?: boolean | {
369
+ perPage?: number;
370
+ sort?: boolean;
371
+ };
322
372
  }
323
373
  interface UserAvatar {
324
374
  large: string | null;
@@ -791,15 +841,20 @@ declare class AniListClient {
791
841
  * Fetch a staff member by AniList ID.
792
842
  *
793
843
  * @param id - The AniList staff ID
844
+ * @param include - Optional include options to fetch related data (e.g. media)
794
845
  * @returns The staff object
795
846
  *
796
847
  * @example
797
848
  * ```ts
798
849
  * const staff = await client.getStaff(95001);
799
850
  * console.log(staff.name.full);
851
+ *
852
+ * // With media the staff worked on
853
+ * const staff = await client.getStaff(95001, { media: true });
854
+ * staff.staffMedia?.nodes.forEach((m) => console.log(m.title.romaji));
800
855
  * ```
801
856
  */
802
- getStaff(id: number): Promise<Staff>;
857
+ getStaff(id: number, include?: StaffIncludeOptions): Promise<Staff>;
803
858
  /**
804
859
  * Search for staff (voice actors, directors, etc.).
805
860
  *
@@ -1207,4 +1262,4 @@ declare class RateLimiter {
1207
1262
  private sleep;
1208
1263
  }
1209
1264
 
1210
- 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 ExternalLink, 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, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type PageInfo, type PagedResult, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type Staff, type StaffImage, type StaffName, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type StudioDetail, type User, type UserAvatar, type UserStatistics, type VoiceActor };
1265
+ 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 ExternalLink, 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, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type PageInfo, type PagedResult, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type StudioDetail, type User, type UserAvatar, type UserStatistics, type VoiceActor };
package/dist/index.d.ts CHANGED
@@ -303,6 +303,43 @@ interface StaffImage {
303
303
  large: string | null;
304
304
  medium: string | null;
305
305
  }
306
+ /** A media node returned inside `Staff.staffMedia`. */
307
+ interface StaffMediaNode {
308
+ id: number;
309
+ title: MediaTitle;
310
+ type: MediaType;
311
+ format: MediaFormat | null;
312
+ status: MediaStatus | null;
313
+ coverImage: MediaCoverImage;
314
+ bannerImage: string | null;
315
+ genres: string[];
316
+ averageScore: number | null;
317
+ meanScore: number | null;
318
+ popularity: number | null;
319
+ favourites: number | null;
320
+ episodes: number | null;
321
+ trending: number | null;
322
+ hashtag: string | null;
323
+ season: MediaSeason | null;
324
+ seasonYear: number | null;
325
+ startDate: FuzzyDate | null;
326
+ endDate: FuzzyDate | null;
327
+ nextAiringEpisode: {
328
+ id: number;
329
+ airingAt: number;
330
+ episode: number;
331
+ mediaId: number;
332
+ timeUntilAiring: number;
333
+ } | null;
334
+ studios: {
335
+ edges: {
336
+ node: {
337
+ name: string;
338
+ };
339
+ }[];
340
+ } | null;
341
+ siteUrl: string | null;
342
+ }
306
343
  interface Staff {
307
344
  id: number;
308
345
  name: StaffName;
@@ -319,6 +356,19 @@ interface Staff {
319
356
  bloodType: string | null;
320
357
  favourites: number | null;
321
358
  siteUrl: string | null;
359
+ /** Media the staff member has worked on — only present when requested via include options. */
360
+ staffMedia?: {
361
+ nodes: StaffMediaNode[];
362
+ } | null;
363
+ }
364
+ /** Options to include additional related data when fetching a staff member by ID. */
365
+ interface StaffIncludeOptions {
366
+ /** Include media the staff member has worked on.
367
+ * `true` = 25 results sorted by popularity. Object form to customize. */
368
+ media?: boolean | {
369
+ perPage?: number;
370
+ sort?: boolean;
371
+ };
322
372
  }
323
373
  interface UserAvatar {
324
374
  large: string | null;
@@ -791,15 +841,20 @@ declare class AniListClient {
791
841
  * Fetch a staff member by AniList ID.
792
842
  *
793
843
  * @param id - The AniList staff ID
844
+ * @param include - Optional include options to fetch related data (e.g. media)
794
845
  * @returns The staff object
795
846
  *
796
847
  * @example
797
848
  * ```ts
798
849
  * const staff = await client.getStaff(95001);
799
850
  * console.log(staff.name.full);
851
+ *
852
+ * // With media the staff worked on
853
+ * const staff = await client.getStaff(95001, { media: true });
854
+ * staff.staffMedia?.nodes.forEach((m) => console.log(m.title.romaji));
800
855
  * ```
801
856
  */
802
- getStaff(id: number): Promise<Staff>;
857
+ getStaff(id: number, include?: StaffIncludeOptions): Promise<Staff>;
803
858
  /**
804
859
  * Search for staff (voice actors, directors, etc.).
805
860
  *
@@ -1207,4 +1262,4 @@ declare class RateLimiter {
1207
1262
  private sleep;
1208
1263
  }
1209
1264
 
1210
- 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 ExternalLink, 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, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type PageInfo, type PagedResult, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type Staff, type StaffImage, type StaffName, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type StudioDetail, type User, type UserAvatar, type UserStatistics, type VoiceActor };
1265
+ 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 ExternalLink, 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, type MediaStaffConnection, type MediaStaffEdge, type MediaStats, MediaStatus, type MediaTag, type MediaTitle, type MediaTrailer, MediaType, MemoryCache, type PageInfo, type PagedResult, type RateLimitOptions, RateLimiter, type Recommendation, RecommendationSort, RedisCache, type RedisCacheOptions, type RedisLikeClient, type ScoreDistribution, type SearchCharacterOptions, type SearchMediaOptions, type SearchStaffOptions, type SearchStudioOptions, type Staff, type StaffImage, type StaffIncludeOptions, type StaffMediaNode, type StaffName, type StatusDistribution, type StreamingEpisode, type Studio, type StudioConnection, type StudioDetail, type User, type UserAvatar, type UserStatistics, type VoiceActor };
package/dist/index.js CHANGED
@@ -129,6 +129,46 @@ var STAFF_FIELDS = `
129
129
  favourites
130
130
  siteUrl
131
131
  `;
132
+ var STAFF_MEDIA_FIELDS = `
133
+ staffMedia(perPage: $perPage, sort: [POPULARITY_DESC]) {
134
+ nodes {
135
+ id
136
+ title { romaji english native userPreferred }
137
+ type
138
+ format
139
+ status
140
+ coverImage { extraLarge large medium color }
141
+ bannerImage
142
+ genres
143
+ averageScore
144
+ meanScore
145
+ popularity
146
+ favourites
147
+ episodes
148
+ trending
149
+ hashtag
150
+ season
151
+ seasonYear
152
+ startDate { year month day }
153
+ endDate { year month day }
154
+ nextAiringEpisode {
155
+ id
156
+ airingAt
157
+ episode
158
+ mediaId
159
+ timeUntilAiring
160
+ }
161
+ studios {
162
+ edges {
163
+ node {
164
+ name
165
+ }
166
+ }
167
+ }
168
+ siteUrl
169
+ }
170
+ }
171
+ `;
132
172
  var USER_FIELDS = `
133
173
  id
134
174
  name
@@ -230,6 +270,13 @@ query ($id: Int!) {
230
270
  ${STAFF_FIELDS}
231
271
  }
232
272
  }`;
273
+ var QUERY_STAFF_BY_ID_WITH_MEDIA = `
274
+ query ($id: Int!, $perPage: Int) {
275
+ Staff(id: $id) {
276
+ ${STAFF_FIELDS}
277
+ ${STAFF_MEDIA_FIELDS}
278
+ }
279
+ }`;
233
280
  var QUERY_STAFF_SEARCH = `
234
281
  query ($search: String, $sort: [StaffSort], $page: Int, $perPage: Int) {
235
282
  Page(page: $page, perPage: $perPage) {
@@ -1051,15 +1098,26 @@ var AniListClient = class {
1051
1098
  * Fetch a staff member by AniList ID.
1052
1099
  *
1053
1100
  * @param id - The AniList staff ID
1101
+ * @param include - Optional include options to fetch related data (e.g. media)
1054
1102
  * @returns The staff object
1055
1103
  *
1056
1104
  * @example
1057
1105
  * ```ts
1058
1106
  * const staff = await client.getStaff(95001);
1059
1107
  * console.log(staff.name.full);
1108
+ *
1109
+ * // With media the staff worked on
1110
+ * const staff = await client.getStaff(95001, { media: true });
1111
+ * staff.staffMedia?.nodes.forEach((m) => console.log(m.title.romaji));
1060
1112
  * ```
1061
1113
  */
1062
- async getStaff(id) {
1114
+ async getStaff(id, include) {
1115
+ if (include?.media) {
1116
+ const opts = typeof include.media === "object" ? include.media : {};
1117
+ const perPage = opts.perPage ?? 25;
1118
+ const data2 = await this.request(QUERY_STAFF_BY_ID_WITH_MEDIA, { id, perPage });
1119
+ return data2.Staff;
1120
+ }
1063
1121
  const data = await this.request(QUERY_STAFF_BY_ID, { id });
1064
1122
  return data.Staff;
1065
1123
  }