ani-client 1.9.0 → 2.0.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 +2 -0
- package/dist/index.d.mts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +58 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -8
package/dist/index.mjs
CHANGED
|
@@ -434,7 +434,17 @@ var RELATIONS_FIELDS = `
|
|
|
434
434
|
type
|
|
435
435
|
format
|
|
436
436
|
status
|
|
437
|
-
|
|
437
|
+
startDate { year month day }
|
|
438
|
+
endDate { year month day }
|
|
439
|
+
season
|
|
440
|
+
seasonYear
|
|
441
|
+
episodes
|
|
442
|
+
chapters
|
|
443
|
+
volumes
|
|
444
|
+
coverImage { extraLarge large medium color }
|
|
445
|
+
genres
|
|
446
|
+
averageScore
|
|
447
|
+
studios { nodes { id name isAnimationStudio siteUrl } }
|
|
438
448
|
siteUrl
|
|
439
449
|
}
|
|
440
450
|
}
|
|
@@ -754,16 +764,16 @@ query (
|
|
|
754
764
|
}
|
|
755
765
|
}`;
|
|
756
766
|
var QUERY_TRENDING = `
|
|
757
|
-
query ($type: MediaType, $page: Int, $perPage: Int) {
|
|
767
|
+
query ($type: MediaType, $isAdult: Boolean, $page: Int, $perPage: Int) {
|
|
758
768
|
Page(page: $page, perPage: $perPage) {
|
|
759
769
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
760
|
-
media(type: $type, sort: TRENDING_DESC) {
|
|
770
|
+
media(type: $type, isAdult: $isAdult, sort: TRENDING_DESC) {
|
|
761
771
|
${MEDIA_FIELDS_BASE}
|
|
762
772
|
}
|
|
763
773
|
}
|
|
764
774
|
}`;
|
|
765
775
|
var QUERY_AIRING_SCHEDULE = `
|
|
766
|
-
query ($airingAt_greater: Int, $airingAt_lesser: Int, $sort: [AiringSort], $page: Int, $perPage: Int) {
|
|
776
|
+
query ($airingAt_greater: Int, $airingAt_lesser: Int, $isAdult: Boolean, $sort: [AiringSort], $page: Int, $perPage: Int) {
|
|
767
777
|
Page(page: $page, perPage: $perPage) {
|
|
768
778
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
769
779
|
airingSchedules(airingAt_greater: $airingAt_greater, airingAt_lesser: $airingAt_lesser, sort: $sort) {
|
|
@@ -772,35 +782,49 @@ query ($airingAt_greater: Int, $airingAt_lesser: Int, $sort: [AiringSort], $page
|
|
|
772
782
|
timeUntilAiring
|
|
773
783
|
episode
|
|
774
784
|
mediaId
|
|
775
|
-
media {
|
|
785
|
+
media(isAdult: $isAdult) {
|
|
776
786
|
${MEDIA_FIELDS_BASE}
|
|
777
787
|
}
|
|
778
788
|
}
|
|
779
789
|
}
|
|
780
790
|
}`;
|
|
781
791
|
var QUERY_RECENT_CHAPTERS = `
|
|
782
|
-
query ($page: Int, $perPage: Int) {
|
|
792
|
+
query ($isAdult: Boolean $page: Int, $perPage: Int) {
|
|
783
793
|
Page(page: $page, perPage: $perPage) {
|
|
784
794
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
785
|
-
media(type: MANGA, status: RELEASING, sort: UPDATED_AT_DESC) {
|
|
795
|
+
media(type: MANGA, isAdult: $isAdult status: RELEASING, sort: UPDATED_AT_DESC) {
|
|
786
796
|
${MEDIA_FIELDS_BASE}
|
|
787
797
|
}
|
|
788
798
|
}
|
|
789
799
|
}`;
|
|
790
800
|
var QUERY_PLANNING = `
|
|
791
|
-
query ($type: MediaType, $sort: [MediaSort], $page: Int, $perPage: Int) {
|
|
801
|
+
query ($type: MediaType, $isAdult: Boolean, $sort: [MediaSort], $page: Int, $perPage: Int) {
|
|
792
802
|
Page(page: $page, perPage: $perPage) {
|
|
793
803
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
794
|
-
media(type: $type, status: NOT_YET_RELEASED, sort: $sort) {
|
|
804
|
+
media(type: $type, isAdult: $isAdult, status: NOT_YET_RELEASED, sort: $sort) {
|
|
795
805
|
${MEDIA_FIELDS_BASE}
|
|
796
806
|
}
|
|
797
807
|
}
|
|
798
808
|
}`;
|
|
799
809
|
var QUERY_MEDIA_BY_SEASON = `
|
|
800
|
-
query (
|
|
810
|
+
query (
|
|
811
|
+
$season: MediaSeason!,
|
|
812
|
+
$seasonYear: Int!,
|
|
813
|
+
$type: MediaType,
|
|
814
|
+
$isAdult: Boolean,
|
|
815
|
+
$sort: [MediaSort],
|
|
816
|
+
$page: Int,
|
|
817
|
+
$perPage: Int
|
|
818
|
+
) {
|
|
801
819
|
Page(page: $page, perPage: $perPage) {
|
|
802
820
|
pageInfo { total perPage currentPage lastPage hasNextPage }
|
|
803
|
-
media(
|
|
821
|
+
media(
|
|
822
|
+
season: $season,
|
|
823
|
+
seasonYear: $seasonYear,
|
|
824
|
+
type: $type,
|
|
825
|
+
isAdult: $isAdult,
|
|
826
|
+
sort: $sort
|
|
827
|
+
) {
|
|
804
828
|
${MEDIA_FIELDS_BASE}
|
|
805
829
|
}
|
|
806
830
|
}
|
|
@@ -1199,7 +1223,7 @@ var RateLimiter = class {
|
|
|
1199
1223
|
/** @internal — active sleep timers for cleanup */
|
|
1200
1224
|
activeTimers = /* @__PURE__ */ new Set();
|
|
1201
1225
|
constructor(options = {}) {
|
|
1202
|
-
this.maxRequests = options.maxRequests ??
|
|
1226
|
+
this.maxRequests = options.maxRequests ?? 25;
|
|
1203
1227
|
this.windowMs = options.windowMs ?? 6e4;
|
|
1204
1228
|
this.maxRetries = options.maxRetries ?? 3;
|
|
1205
1229
|
this.retryDelayMs = options.retryDelayMs ?? 2e3;
|
|
@@ -1630,14 +1654,17 @@ async function searchMedia(client, options = {}) {
|
|
|
1630
1654
|
"media"
|
|
1631
1655
|
);
|
|
1632
1656
|
}
|
|
1633
|
-
async function getTrending(client,
|
|
1634
|
-
|
|
1657
|
+
async function getTrending(client, options) {
|
|
1658
|
+
const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
|
|
1659
|
+
return client.pagedRequest(QUERY_TRENDING, { type, isAdult, page, perPage: clampPerPage(perPage) }, "media");
|
|
1635
1660
|
}
|
|
1636
|
-
async function getPopular(client,
|
|
1637
|
-
|
|
1661
|
+
async function getPopular(client, options) {
|
|
1662
|
+
const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
|
|
1663
|
+
return searchMedia(client, { type, isAdult, sort: ["POPULARITY_DESC" /* POPULARITY_DESC */], page, perPage });
|
|
1638
1664
|
}
|
|
1639
|
-
async function getTopRated(client,
|
|
1640
|
-
|
|
1665
|
+
async function getTopRated(client, options) {
|
|
1666
|
+
const { type = "ANIME" /* ANIME */, isAdult = false, page = 1, perPage = 20 } = options;
|
|
1667
|
+
return searchMedia(client, { type, isAdult, sort: ["SCORE_DESC" /* SCORE_DESC */], page, perPage });
|
|
1641
1668
|
}
|
|
1642
1669
|
async function getAiredEpisodes(client, options = {}) {
|
|
1643
1670
|
const now = Math.floor(Date.now() / 1e3);
|
|
@@ -1646,6 +1673,7 @@ async function getAiredEpisodes(client, options = {}) {
|
|
|
1646
1673
|
{
|
|
1647
1674
|
airingAt_greater: options.airingAtGreater ?? now - 24 * 3600,
|
|
1648
1675
|
airingAt_lesser: options.airingAtLesser ?? now,
|
|
1676
|
+
isAdult: options.isAdult ?? false,
|
|
1649
1677
|
sort: options.sort,
|
|
1650
1678
|
page: options.page ?? 1,
|
|
1651
1679
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
@@ -1657,6 +1685,7 @@ async function getRecentlyUpdatedManga(client, options = {}) {
|
|
|
1657
1685
|
return client.pagedRequest(
|
|
1658
1686
|
QUERY_RECENT_CHAPTERS,
|
|
1659
1687
|
{
|
|
1688
|
+
isAdult: options.isAdult ?? false,
|
|
1660
1689
|
page: options.page ?? 1,
|
|
1661
1690
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
1662
1691
|
},
|
|
@@ -1668,6 +1697,7 @@ async function getPlanning(client, options = {}) {
|
|
|
1668
1697
|
QUERY_PLANNING,
|
|
1669
1698
|
{
|
|
1670
1699
|
type: options.type,
|
|
1700
|
+
isAdult: options.isAdult ?? false,
|
|
1671
1701
|
sort: options.sort ?? ["POPULARITY_DESC" /* POPULARITY_DESC */],
|
|
1672
1702
|
page: options.page ?? 1,
|
|
1673
1703
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
@@ -1695,6 +1725,7 @@ async function getMediaBySeason(client, options) {
|
|
|
1695
1725
|
season: options.season,
|
|
1696
1726
|
seasonYear: options.seasonYear,
|
|
1697
1727
|
type: options.type,
|
|
1728
|
+
isAdult: options.isAdult ?? false,
|
|
1698
1729
|
sort: options.sort,
|
|
1699
1730
|
page: options.page ?? 1,
|
|
1700
1731
|
perPage: clampPerPage(options.perPage ?? 20)
|
|
@@ -1702,7 +1733,7 @@ async function getMediaBySeason(client, options) {
|
|
|
1702
1733
|
"media"
|
|
1703
1734
|
);
|
|
1704
1735
|
}
|
|
1705
|
-
async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date()) {
|
|
1736
|
+
async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date(), isAdult = false) {
|
|
1706
1737
|
const schedule = {
|
|
1707
1738
|
Monday: [],
|
|
1708
1739
|
Tuesday: [],
|
|
@@ -1724,6 +1755,7 @@ async function getWeeklySchedule(client, date = /* @__PURE__ */ new Date()) {
|
|
|
1724
1755
|
(page) => getAiredEpisodes(client, {
|
|
1725
1756
|
airingAtGreater: startTimestamp,
|
|
1726
1757
|
airingAtLesser: endTimestamp,
|
|
1758
|
+
isAdult,
|
|
1727
1759
|
page,
|
|
1728
1760
|
perPage: 50
|
|
1729
1761
|
}),
|
|
@@ -1869,7 +1901,7 @@ function mapFavorites(fav) {
|
|
|
1869
1901
|
|
|
1870
1902
|
// src/client/index.ts
|
|
1871
1903
|
var DEFAULT_API_URL = "https://graphql.anilist.co";
|
|
1872
|
-
var LIB_VERSION = "
|
|
1904
|
+
var LIB_VERSION = "2.0.0" ;
|
|
1873
1905
|
var AniListClient = class {
|
|
1874
1906
|
apiUrl;
|
|
1875
1907
|
headers;
|
|
@@ -2022,16 +2054,16 @@ var AniListClient = class {
|
|
|
2022
2054
|
return searchMedia(this, options);
|
|
2023
2055
|
}
|
|
2024
2056
|
/** Get currently trending anime or manga. */
|
|
2025
|
-
async getTrending(
|
|
2026
|
-
return getTrending(this,
|
|
2057
|
+
async getTrending(options = {}) {
|
|
2058
|
+
return getTrending(this, options);
|
|
2027
2059
|
}
|
|
2028
2060
|
/** Get the most popular anime or manga. */
|
|
2029
|
-
async getPopular(
|
|
2030
|
-
return getPopular(this,
|
|
2061
|
+
async getPopular(options = {}) {
|
|
2062
|
+
return getPopular(this, options);
|
|
2031
2063
|
}
|
|
2032
2064
|
/** Get the highest-rated anime or manga. */
|
|
2033
|
-
async getTopRated(
|
|
2034
|
-
return getTopRated(this,
|
|
2065
|
+
async getTopRated(options = {}) {
|
|
2066
|
+
return getTopRated(this, options);
|
|
2035
2067
|
}
|
|
2036
2068
|
/** Get recently aired anime episodes. */
|
|
2037
2069
|
async getAiredEpisodes(options = {}) {
|