ani-client 2.0.3 → 2.1.1

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/dist/index.mjs CHANGED
@@ -349,7 +349,7 @@ var AniListError = class _AniListError extends Error {
349
349
  this.status = status;
350
350
  this.errors = errors;
351
351
  Object.setPrototypeOf(this, _AniListError.prototype);
352
- if (Error.captureStackTrace) {
352
+ if ("captureStackTrace" in Error) {
353
353
  Error.captureStackTrace(this, _AniListError);
354
354
  }
355
355
  }
@@ -444,6 +444,7 @@ var RELATIONS_FIELDS = `
444
444
  coverImage { extraLarge large medium color }
445
445
  genres
446
446
  averageScore
447
+ meanScore
447
448
  studios { nodes { id name isAnimationStudio siteUrl } }
448
449
  siteUrl
449
450
  nextAiringEpisode {
@@ -457,6 +458,36 @@ var RELATIONS_FIELDS = `
457
458
  }
458
459
  }
459
460
  `;
461
+ var MEDIA_RECOMMENDATION_FIELDS = `
462
+ id
463
+ rating
464
+ mediaRecommendation {
465
+ id
466
+ title { romaji english native userPreferred }
467
+ type
468
+ format
469
+ coverImage { extraLarge large medium color }
470
+ averageScore
471
+ meanScore
472
+ episodes
473
+ chapters
474
+ volumes
475
+ nextAiringEpisode {
476
+ id
477
+ airingAt
478
+ episode
479
+ mediaId
480
+ timeUntilAiring
481
+ }
482
+ season
483
+ seasonYear
484
+ startDate { year month day }
485
+ endDate { year month day }
486
+ studios { nodes { id name isAnimationStudio siteUrl } }
487
+ genres
488
+ siteUrl
489
+ }
490
+ `;
460
491
  var MEDIA_FIELDS = `
461
492
  ${MEDIA_FIELDS_BASE}
462
493
  ${RELATIONS_FIELDS}
@@ -742,6 +773,7 @@ query (
742
773
  $genre_not_in: [String],
743
774
  $tag_not_in: [String],
744
775
  $isAdult: Boolean,
776
+ $idNotIn: [Int],
745
777
  $sort: [MediaSort],
746
778
  $page: Int,
747
779
  $perPage: Int
@@ -764,6 +796,7 @@ query (
764
796
  genre_not_in: $genre_not_in,
765
797
  tag_not_in: $tag_not_in,
766
798
  isAdult: $isAdult,
799
+ id_not_in: $idNotIn,
767
800
  sort: $sort
768
801
  ) {
769
802
  ${MEDIA_FIELDS_BASE}
@@ -771,44 +804,91 @@ query (
771
804
  }
772
805
  }`;
773
806
  var QUERY_TRENDING = `
774
- query ($type: MediaType, $isAdult: Boolean, $page: Int, $perPage: Int) {
807
+ query (
808
+ $type: MediaType,
809
+ $isAdult: Boolean,
810
+ $idNotIn: [Int],
811
+ $page: Int,
812
+ $perPage: Int
813
+ ) {
775
814
  Page(page: $page, perPage: $perPage) {
776
815
  pageInfo { total perPage currentPage lastPage hasNextPage }
777
- media(type: $type, isAdult: $isAdult, sort: TRENDING_DESC) {
816
+ media(
817
+ type: $type,
818
+ isAdult: $isAdult,
819
+ id_not_in: $idNotIn,
820
+ sort: TRENDING_DESC
821
+ ) {
778
822
  ${MEDIA_FIELDS_BASE}
779
823
  }
780
824
  }
781
825
  }`;
782
826
  var QUERY_AIRING_SCHEDULE = `
783
- query ($airingAt_greater: Int, $airingAt_lesser: Int, $isAdult: Boolean, $sort: [AiringSort], $page: Int, $perPage: Int) {
827
+ query (
828
+ $airingAt_greater: Int,
829
+ $airingAt_lesser: Int,
830
+ $sort: [AiringSort],
831
+ $idNotIn: [Int],
832
+ $page: Int,
833
+ $perPage: Int
834
+ ) {
784
835
  Page(page: $page, perPage: $perPage) {
785
836
  pageInfo { total perPage currentPage lastPage hasNextPage }
786
- airingSchedules(airingAt_greater: $airingAt_greater, airingAt_lesser: $airingAt_lesser, sort: $sort) {
837
+ airingSchedules(
838
+ airingAt_greater: $airingAt_greater,
839
+ airingAt_lesser: $airingAt_lesser,
840
+ id_not_in: $idNotIn,
841
+ sort: $sort
842
+ ) {
787
843
  id
788
844
  airingAt
789
845
  timeUntilAiring
790
846
  episode
791
847
  mediaId
792
- media(isAdult: $isAdult) {
848
+ media {
793
849
  ${MEDIA_FIELDS_BASE}
794
850
  }
795
851
  }
796
852
  }
797
853
  }`;
798
854
  var QUERY_RECENT_CHAPTERS = `
799
- query ($isAdult: Boolean $page: Int, $perPage: Int) {
855
+ query (
856
+ $isAdult: Boolean,
857
+ $idNotIn: [Int],
858
+ $page: Int,
859
+ $perPage: Int
860
+ ) {
800
861
  Page(page: $page, perPage: $perPage) {
801
862
  pageInfo { total perPage currentPage lastPage hasNextPage }
802
- media(type: MANGA, isAdult: $isAdult status: RELEASING, sort: UPDATED_AT_DESC) {
863
+ media(
864
+ type: MANGA,
865
+ isAdult: $isAdult,
866
+ id_not_in: $idNotIn,
867
+ status: RELEASING,
868
+ sort: UPDATED_AT_DESC
869
+ ) {
803
870
  ${MEDIA_FIELDS_BASE}
804
871
  }
805
872
  }
806
873
  }`;
807
874
  var QUERY_PLANNING = `
808
- query ($type: MediaType, $isAdult: Boolean, $sort: [MediaSort], $page: Int, $perPage: Int) {
875
+ query (
876
+ $type: MediaType,
877
+ $isAdult: Boolean,
878
+ $idNotIn: [Int],
879
+ $sort: [MediaSort],
880
+ $page: Int,
881
+ $perPage: Int
882
+ ) {
809
883
  Page(page: $page, perPage: $perPage) {
810
884
  pageInfo { total perPage currentPage lastPage hasNextPage }
811
- media(type: $type, isAdult: $isAdult, status: NOT_YET_RELEASED, sort: $sort) {
885
+ media(
886
+ type: $type,
887
+ isAdult: $isAdult,
888
+ id_not_in: $idNotIn,
889
+ status: NOT_YET_RELEASED,
890
+ sort: $sort
891
+ ) {
812
892
  ${MEDIA_FIELDS_BASE}
813
893
  }
814
894
  }
@@ -819,6 +899,7 @@ query (
819
899
  $seasonYear: Int!,
820
900
  $type: MediaType,
821
901
  $isAdult: Boolean,
902
+ $idNotIn: [Int],
822
903
  $sort: [MediaSort],
823
904
  $page: Int,
824
905
  $perPage: Int
@@ -830,6 +911,7 @@ query (
830
911
  seasonYear: $seasonYear,
831
912
  type: $type,
832
913
  isAdult: $isAdult,
914
+ id_not_in: $idNotIn,
833
915
  sort: $sort
834
916
  ) {
835
917
  ${MEDIA_FIELDS_BASE}
@@ -848,25 +930,7 @@ query ($mediaId: Int!, $page: Int, $perPage: Int, $sort: [RecommendationSort]) {
848
930
  recommendations(page: $page, perPage: $perPage, sort: $sort) {
849
931
  pageInfo { total perPage currentPage lastPage hasNextPage }
850
932
  nodes {
851
- id
852
- rating
853
- userRating
854
- mediaRecommendation {
855
- id
856
- idMal
857
- title { romaji english native userPreferred }
858
- type
859
- format
860
- status
861
- coverImage { extraLarge large medium color }
862
- bannerImage
863
- genres
864
- averageScore
865
- meanScore
866
- popularity
867
- favourites
868
- siteUrl
869
- }
933
+ ${MEDIA_RECOMMENDATION_FIELDS}
870
934
  user {
871
935
  id
872
936
  name
@@ -923,17 +987,7 @@ function buildMediaByIdQuery(include) {
923
987
  extra.push(`
924
988
  recommendations(perPage: ${perPage}, sort: [RATING_DESC]) {
925
989
  nodes {
926
- id
927
- rating
928
- mediaRecommendation {
929
- id
930
- title { romaji english native userPreferred }
931
- type
932
- format
933
- coverImage { large medium }
934
- averageScore
935
- siteUrl
936
- }
990
+ ${MEDIA_RECOMMENDATION_FIELDS}
937
991
  }
938
992
  }`);
939
993
  }
@@ -1068,6 +1122,75 @@ query {
1068
1122
  }
1069
1123
  }`;
1070
1124
 
1125
+ // src/queries/review.ts
1126
+ var QUERY_REVIEWS = `
1127
+ query ($page: Int, $perPage: Int, $sort: [ReviewSort], $mediaId: Int, $userId: Int) {
1128
+ Page(page: $page, perPage: $perPage) {
1129
+ pageInfo {
1130
+ total
1131
+ currentPage
1132
+ lastPage
1133
+ hasNextPage
1134
+ perPage
1135
+ }
1136
+ reviews(sort: $sort, mediaId: $mediaId, userId: $userId) {
1137
+ id
1138
+ userId
1139
+ mediaId
1140
+ mediaType
1141
+ summary
1142
+ body
1143
+ rating
1144
+ ratingAmount
1145
+ userRating
1146
+ score
1147
+ private
1148
+ siteUrl
1149
+ createdAt
1150
+ updatedAt
1151
+ user {
1152
+ id
1153
+ name
1154
+ avatar { large medium }
1155
+ siteUrl
1156
+ }
1157
+ media {
1158
+ ${MEDIA_FIELDS_LIGHT}
1159
+ }
1160
+ }
1161
+ }
1162
+ }
1163
+ `;
1164
+ var QUERY_REVIEW_BY_ID = `
1165
+ query ($id: Int) {
1166
+ Review(id: $id) {
1167
+ id
1168
+ userId
1169
+ mediaId
1170
+ mediaType
1171
+ summary
1172
+ body
1173
+ rating
1174
+ ratingAmount
1175
+ userRating
1176
+ score
1177
+ private
1178
+ siteUrl
1179
+ createdAt
1180
+ updatedAt
1181
+ user {
1182
+ id
1183
+ name
1184
+ avatar { large medium }
1185
+ siteUrl
1186
+ }
1187
+ media {
1188
+ ${MEDIA_FIELDS_BASE}
1189
+ }
1190
+ }
1191
+ }
1192
+ `;
1193
+
1071
1194
  // src/queries/staff.ts
1072
1195
  var QUERY_STAFF_BY_ID = `
1073
1196
  query ($id: Int!) {
@@ -1593,6 +1716,21 @@ var RecommendationSort = /* @__PURE__ */ ((RecommendationSort2) => {
1593
1716
  return RecommendationSort2;
1594
1717
  })(RecommendationSort || {});
1595
1718
 
1719
+ // src/types/review.ts
1720
+ var ReviewSort = /* @__PURE__ */ ((ReviewSort2) => {
1721
+ ReviewSort2["ID"] = "ID";
1722
+ ReviewSort2["ID_DESC"] = "ID_DESC";
1723
+ ReviewSort2["SCORE"] = "SCORE";
1724
+ ReviewSort2["SCORE_DESC"] = "SCORE_DESC";
1725
+ ReviewSort2["RATING"] = "RATING";
1726
+ ReviewSort2["RATING_DESC"] = "RATING_DESC";
1727
+ ReviewSort2["CREATED_AT"] = "CREATED_AT";
1728
+ ReviewSort2["CREATED_AT_DESC"] = "CREATED_AT_DESC";
1729
+ ReviewSort2["UPDATED_AT"] = "UPDATED_AT";
1730
+ ReviewSort2["UPDATED_AT_DESC"] = "UPDATED_AT_DESC";
1731
+ return ReviewSort2;
1732
+ })(ReviewSort || {});
1733
+
1596
1734
  // src/types/staff.ts
1597
1735
  var StaffSort = /* @__PURE__ */ ((StaffSort2) => {
1598
1736
  StaffSort2["ID"] = "ID";
@@ -1719,16 +1857,20 @@ async function searchMedia(client, options = {}) {
1719
1857
  );
1720
1858
  }
1721
1859
  async function getTrending(client, options) {
1722
- const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
1723
- return client.pagedRequest(QUERY_TRENDING, { type, isAdult, page, perPage: clampPerPage(perPage) }, "media");
1860
+ const { type = "ANIME" /* ANIME */, isAdult = false, idNotIn = [], page = 1, perPage = 20 } = options;
1861
+ return client.pagedRequest(
1862
+ QUERY_TRENDING,
1863
+ { type, isAdult, idNotIn, page, perPage: clampPerPage(perPage) },
1864
+ "media"
1865
+ );
1724
1866
  }
1725
1867
  async function getPopular(client, options) {
1726
- const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
1727
- return searchMedia(client, { type, isAdult, sort: ["POPULARITY_DESC" /* POPULARITY_DESC */], page, perPage });
1868
+ const { type = "ANIME" /* ANIME */, isAdult = false, idNotIn = [], page = 1, perPage = 20 } = options;
1869
+ return searchMedia(client, { type, isAdult, idNotIn, sort: ["POPULARITY_DESC" /* POPULARITY_DESC */], page, perPage });
1728
1870
  }
1729
1871
  async function getTopRated(client, options) {
1730
- const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
1731
- return searchMedia(client, { type, isAdult, sort: ["SCORE_DESC" /* SCORE_DESC */], page, perPage });
1872
+ const { type = "ANIME" /* ANIME */, isAdult = false, idNotIn = [], page = 1, perPage = 20 } = options;
1873
+ return searchMedia(client, { type, isAdult, idNotIn, sort: ["SCORE_DESC" /* SCORE_DESC */], page, perPage });
1732
1874
  }
1733
1875
  async function getAiredEpisodes(client, options = {}) {
1734
1876
  const now = Math.floor(Date.now() / 1e3);
@@ -1737,7 +1879,7 @@ async function getAiredEpisodes(client, options = {}) {
1737
1879
  {
1738
1880
  airingAt_greater: options.airingAtGreater ?? now - 24 * 3600,
1739
1881
  airingAt_lesser: options.airingAtLesser ?? now,
1740
- isAdult: options.isAdult ?? false,
1882
+ idNotIn: options.idNotIn ?? [],
1741
1883
  sort: options.sort,
1742
1884
  page: options.page ?? 1,
1743
1885
  perPage: clampPerPage(options.perPage ?? 20)
@@ -1750,6 +1892,7 @@ async function getRecentlyUpdatedManga(client, options = {}) {
1750
1892
  QUERY_RECENT_CHAPTERS,
1751
1893
  {
1752
1894
  isAdult: options.isAdult ?? false,
1895
+ idNotIn: options.idNotIn ?? [],
1753
1896
  page: options.page ?? 1,
1754
1897
  perPage: clampPerPage(options.perPage ?? 20)
1755
1898
  },
@@ -1762,6 +1905,7 @@ async function getPlanning(client, options = {}) {
1762
1905
  {
1763
1906
  type: options.type,
1764
1907
  isAdult: options.isAdult ?? false,
1908
+ idNotIn: options.idNotIn ?? [],
1765
1909
  sort: options.sort ?? ["POPULARITY_DESC" /* POPULARITY_DESC */],
1766
1910
  page: options.page ?? 1,
1767
1911
  perPage: clampPerPage(options.perPage ?? 20)
@@ -1790,6 +1934,7 @@ async function getMediaBySeason(client, options) {
1790
1934
  seasonYear: options.seasonYear,
1791
1935
  type: options.type,
1792
1936
  isAdult: options.isAdult ?? false,
1937
+ idNotIn: options.idNotIn ?? [],
1793
1938
  sort: options.sort,
1794
1939
  page: options.page ?? 1,
1795
1940
  perPage: clampPerPage(options.perPage ?? 20)
@@ -1797,7 +1942,7 @@ async function getMediaBySeason(client, options) {
1797
1942
  "media"
1798
1943
  );
1799
1944
  }
1800
- async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date(), isAdult = false) {
1945
+ async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date(), idNotIn) {
1801
1946
  const schedule = {
1802
1947
  Monday: [],
1803
1948
  Tuesday: [],
@@ -1819,7 +1964,7 @@ async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date(), isAd
1819
1964
  (page) => getAiredEpisodes(client, {
1820
1965
  airingAtGreater: startTimestamp,
1821
1966
  airingAtLesser: endTimestamp,
1822
- isAdult,
1967
+ idNotIn,
1823
1968
  page,
1824
1969
  perPage: 50
1825
1970
  }),
@@ -1834,6 +1979,17 @@ async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date(), isAd
1834
1979
  return schedule;
1835
1980
  }
1836
1981
 
1982
+ // src/client/review.ts
1983
+ async function getReview(client, id) {
1984
+ validateId(id, "reviewId");
1985
+ const data = await client.request(QUERY_REVIEW_BY_ID, { id });
1986
+ return data.Review;
1987
+ }
1988
+ async function searchReviews(client, options = {}) {
1989
+ const { mediaId, userId, sort, page = 1, perPage = 20 } = options;
1990
+ return client.pagedRequest(QUERY_REVIEWS, { mediaId, userId, sort, page, perPage }, "reviews");
1991
+ }
1992
+
1837
1993
  // src/client/staff.ts
1838
1994
  async function getStaff(client, id, include) {
1839
1995
  validateId(id, "staffId");
@@ -1965,7 +2121,7 @@ function mapFavorites(fav) {
1965
2121
 
1966
2122
  // src/client/index.ts
1967
2123
  var DEFAULT_API_URL = "https://graphql.anilist.co";
1968
- var LIB_VERSION = "2.0.3" ;
2124
+ var LIB_VERSION = "2.1.1" ;
1969
2125
  var AniListClient = class {
1970
2126
  apiUrl;
1971
2127
  headers;
@@ -2229,6 +2385,23 @@ var AniListClient = class {
2229
2385
  async getUserFavorites(idOrName, options) {
2230
2386
  return getUserFavorites(this, idOrName, options);
2231
2387
  }
2388
+ /**
2389
+ * Fetch a review by its AniList ID.
2390
+ *
2391
+ * @param id - The AniList review ID
2392
+ */
2393
+ async getReview(id) {
2394
+ return getReview(this, id);
2395
+ }
2396
+ /**
2397
+ * Search for reviews with optional filters.
2398
+ *
2399
+ * @param options - Search and filter options
2400
+ * @returns Paginated results with matching reviews
2401
+ */
2402
+ async searchReviews(options = {}) {
2403
+ return searchReviews(this, options);
2404
+ }
2232
2405
  /**
2233
2406
  * Fetch a studio by its AniList ID.
2234
2407
  * Pass `include` to customise the number of media returned.
@@ -2371,6 +2544,6 @@ var AniListClient = class {
2371
2544
  }
2372
2545
  };
2373
2546
 
2374
- export { AiringSort, AniListClient, AniListError, CharacterRole, CharacterSort, MediaFormat, MediaListSort, MediaListStatus, MediaRelationType, MediaSeason, MediaSort, MediaSource, MediaStatus, MediaType, MemoryCache, RateLimiter, RecommendationSort, RedisCache, StaffSort, StudioSort, ThreadSort, UserSort, parseAniListMarkdown };
2547
+ export { AiringSort, AniListClient, AniListError, CharacterRole, CharacterSort, MediaFormat, MediaListSort, MediaListStatus, MediaRelationType, MediaSeason, MediaSort, MediaSource, MediaStatus, MediaType, MemoryCache, RateLimiter, RecommendationSort, RedisCache, ReviewSort, StaffSort, StudioSort, ThreadSort, UserSort, parseAniListMarkdown };
2375
2548
  //# sourceMappingURL=index.mjs.map
2376
2549
  //# sourceMappingURL=index.mjs.map