@irfanshadikrishad/anilist 1.1.10 → 1.2.0-forbidden.6
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/LICENSE +373 -382
- package/LICENSE.md +382 -0
- package/README.md +87 -53
- package/bin/helpers/auth.d.ts +52 -8
- package/bin/helpers/auth.js +639 -271
- package/bin/helpers/fetcher.d.ts +2 -1
- package/bin/helpers/fetcher.js +9 -3
- package/bin/helpers/lists.d.ts +5 -1
- package/bin/helpers/lists.js +347 -260
- package/bin/helpers/mutations.d.ts +2 -1
- package/bin/helpers/mutations.js +37 -32
- package/bin/helpers/queries.d.ts +14 -7
- package/bin/helpers/queries.js +184 -128
- package/bin/helpers/truncate.d.ts +6 -0
- package/bin/helpers/truncate.js +10 -0
- package/bin/helpers/types.d.ts +367 -16
- package/bin/helpers/validation.d.ts +29 -0
- package/bin/helpers/validation.js +117 -0
- package/bin/helpers/workers.d.ts +22 -9
- package/bin/helpers/workers.js +220 -81
- package/bin/index.js +50 -8
- package/package.json +86 -75
package/bin/helpers/fetcher.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Sends a GraphQL request to the AniList API.
|
|
3
3
|
*
|
|
4
4
|
* This function constructs a request with the provided query and variables,
|
|
5
|
-
* handles authorization, and processes the API response.
|
|
5
|
+
* handles authorization, and processes the API response. If a rate-limit error (429) is returned,
|
|
6
|
+
* it waits for 1 minute and retries the request.
|
|
6
7
|
*
|
|
7
8
|
* @param {string} query - The AniList GraphQL query to be executed.
|
|
8
9
|
* @param {object} variables - An object containing the variables for the query.
|
package/bin/helpers/fetcher.js
CHANGED
|
@@ -14,7 +14,8 @@ import { aniListEndpoint } from "./workers.js";
|
|
|
14
14
|
* Sends a GraphQL request to the AniList API.
|
|
15
15
|
*
|
|
16
16
|
* This function constructs a request with the provided query and variables,
|
|
17
|
-
* handles authorization, and processes the API response.
|
|
17
|
+
* handles authorization, and processes the API response. If a rate-limit error (429) is returned,
|
|
18
|
+
* it waits for 1 minute and retries the request.
|
|
18
19
|
*
|
|
19
20
|
* @param {string} query - The AniList GraphQL query to be executed.
|
|
20
21
|
* @param {object} variables - An object containing the variables for the query.
|
|
@@ -22,7 +23,7 @@ import { aniListEndpoint } from "./workers.js";
|
|
|
22
23
|
*/
|
|
23
24
|
function fetcher(query, variables) {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
var _a;
|
|
26
|
+
var _a, _b;
|
|
26
27
|
try {
|
|
27
28
|
const headers = {
|
|
28
29
|
"content-type": "application/json",
|
|
@@ -39,8 +40,13 @@ function fetcher(query, variables) {
|
|
|
39
40
|
if (request.status === 200) {
|
|
40
41
|
return response;
|
|
41
42
|
}
|
|
43
|
+
else if (request.status === 429) {
|
|
44
|
+
console.warn("Rate limit reached. Retrying in 1 minute...");
|
|
45
|
+
yield new Promise((resolve) => setTimeout(resolve, 60000)); // Wait for 1 minute
|
|
46
|
+
return yield fetcher(query, variables); // Retry the request
|
|
47
|
+
}
|
|
42
48
|
else {
|
|
43
|
-
console.error(`\n${request.status} ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null ||
|
|
49
|
+
console.error(`\n${request.status} ${((_b = (_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) || "Unknown error"}.`);
|
|
44
50
|
return null;
|
|
45
51
|
}
|
|
46
52
|
}
|
package/bin/helpers/lists.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare class AniList {
|
|
|
10
10
|
static getUpcomingAnime(count: number): Promise<void>;
|
|
11
11
|
static getUserByUsername(username: string): Promise<void>;
|
|
12
12
|
static getAnimeDetailsByID(anilistID: number): Promise<void>;
|
|
13
|
+
static getMangaDetailsByID(mangaID: number): Promise<void>;
|
|
13
14
|
static searchAnime(search: string, count: number): Promise<void>;
|
|
14
15
|
static searchManga(search: string, count: number): Promise<void>;
|
|
15
16
|
}
|
|
@@ -19,4 +20,7 @@ declare class MyAnimeList {
|
|
|
19
20
|
static exportAnime(): Promise<void>;
|
|
20
21
|
static exportManga(): Promise<void>;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
declare class AniDB {
|
|
24
|
+
static importAnime(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export { AniDB, AniList, MyAnimeList };
|