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