@irfanshadikrishad/anilist 1.0.11 → 1.1.0-forbidden.7
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 -58
- package/bin/helpers/auth.d.ts +24 -8
- package/bin/helpers/auth.js +661 -258
- package/bin/helpers/fetcher.d.ts +2 -1
- package/bin/helpers/fetcher.js +14 -7
- package/bin/helpers/lists.d.ts +5 -1
- package/bin/helpers/lists.js +516 -405
- package/bin/helpers/mutations.d.ts +8 -4
- package/bin/helpers/mutations.js +14 -10
- package/bin/helpers/queries.d.ts +13 -9
- package/bin/helpers/queries.js +62 -16
- package/bin/helpers/truncate.d.ts +6 -0
- package/bin/helpers/truncate.js +10 -0
- package/bin/helpers/types.d.ts +319 -28
- package/bin/helpers/validation.d.ts +29 -0
- package/bin/helpers/validation.js +117 -0
- package/bin/helpers/workers.d.ts +24 -9
- package/bin/helpers/workers.js +210 -16
- package/bin/index.js +43 -4
- package/package.json +29 -16
- package/assets/binance.jpg +0 -0
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
|
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import fetch from "node-fetch";
|
|
11
11
|
import { Auth } from "./auth.js";
|
|
12
|
-
import { aniListEndpoint } from "./workers.js";
|
|
12
|
+
import { aniListEndpoint, handleRateLimitRetry } from "./workers.js";
|
|
13
13
|
/**
|
|
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,14 +23,16 @@ 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",
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const token = (yield Auth.isLoggedIn())
|
|
32
|
+
? yield Auth.RetriveAccessToken()
|
|
33
|
+
: null;
|
|
34
|
+
if (token)
|
|
35
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
33
36
|
const request = yield fetch(aniListEndpoint, {
|
|
34
37
|
method: "POST",
|
|
35
38
|
headers: headers,
|
|
@@ -39,8 +42,12 @@ function fetcher(query, variables) {
|
|
|
39
42
|
if (request.status === 200) {
|
|
40
43
|
return response;
|
|
41
44
|
}
|
|
45
|
+
else if (request.status === 429) {
|
|
46
|
+
yield handleRateLimitRetry(60);
|
|
47
|
+
return yield fetcher(query, variables);
|
|
48
|
+
}
|
|
42
49
|
else {
|
|
43
|
-
console.error(`\n${request.status} ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null ||
|
|
50
|
+
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
51
|
return null;
|
|
45
52
|
}
|
|
46
53
|
}
|
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 };
|