@irfanshadikrishad/anilist 1.0.8 → 1.1.0-forbidden.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 +232 -232
- package/bin/helpers/auth.d.ts +26 -10
- package/bin/helpers/auth.js +747 -192
- package/bin/helpers/fetcher.d.ts +1 -1
- package/bin/helpers/fetcher.js +25 -24
- package/bin/helpers/lists.d.ts +22 -8
- package/bin/helpers/lists.js +915 -536
- package/bin/helpers/mutations.d.ts +2 -1
- package/bin/helpers/mutations.js +37 -32
- package/bin/helpers/queries.d.ts +6 -3
- package/bin/helpers/queries.js +157 -128
- package/bin/helpers/types.d.ts +3 -3
- package/bin/helpers/workers.d.ts +9 -11
- package/bin/helpers/workers.js +72 -371
- package/bin/index.js +31 -25
- package/package.json +73 -72
- package/bin/helpers/more.d.ts +0 -11
- package/bin/helpers/more.js +0 -500
package/bin/helpers/fetcher.d.ts
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* @param {object} variables - An object containing the variables for the query.
|
|
9
9
|
* @returns {Promise<object|null>} The response from the API as a JSON object if successful; otherwise, null.
|
|
10
10
|
*/
|
|
11
|
-
declare function fetcher(query: string, variables
|
|
11
|
+
declare function fetcher(query: string, variables?: object): Promise<any | null>;
|
|
12
12
|
export { fetcher };
|
package/bin/helpers/fetcher.js
CHANGED
|
@@ -8,8 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import fetch from "node-fetch";
|
|
11
|
-
import {
|
|
12
|
-
import { aniListEndpoint } from "./workers.js";
|
|
11
|
+
import { Auth } from "./auth.js";
|
|
13
12
|
/**
|
|
14
13
|
* Sends a GraphQL request to the AniList API.
|
|
15
14
|
*
|
|
@@ -22,32 +21,34 @@ import { aniListEndpoint } from "./workers.js";
|
|
|
22
21
|
*/
|
|
23
22
|
function fetcher(query, variables) {
|
|
24
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
const headers = {
|
|
25
|
+
"content-type": "application/json",
|
|
26
|
+
};
|
|
27
|
+
if (yield Auth.isLoggedIn()) {
|
|
28
|
+
headers["Authorization"] = `Bearer ${yield Auth.RetriveAccessToken()}`;
|
|
29
|
+
}
|
|
30
|
+
const response = yield fetch("https://graphql.anilist.co", {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: headers,
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
query,
|
|
35
|
+
variables,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
// Check if the response is successful
|
|
39
|
+
if (response.status !== 200) {
|
|
40
|
+
// If the status is 429, handle the rate limit
|
|
41
|
+
if (response.status === 429) {
|
|
42
|
+
console.warn("Rate limit hit. Waiting for 1 minute before retrying...");
|
|
43
|
+
yield new Promise((resolve) => setTimeout(resolve, 60000)); // Wait for 1 minute
|
|
44
|
+
return fetcher(query, variables); // Retry the request
|
|
41
45
|
}
|
|
42
46
|
else {
|
|
43
|
-
|
|
44
|
-
return null;
|
|
47
|
+
throw new Error(`\nError fetching data: ${response.statusText}`);
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
50
|
+
const data = yield response.json();
|
|
51
|
+
return data;
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
export { fetcher };
|
package/bin/helpers/lists.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
declare class AniList {
|
|
2
|
+
static importAnime(): Promise<void>;
|
|
3
|
+
static importManga(): Promise<void>;
|
|
4
|
+
static exportAnime(): Promise<void>;
|
|
5
|
+
static exportManga(): Promise<void>;
|
|
6
|
+
static MyAnime(): Promise<void>;
|
|
7
|
+
static MyManga(): Promise<void>;
|
|
8
|
+
static getTrendingAnime(count: number): Promise<void>;
|
|
9
|
+
static getPopularAnime(count: number): Promise<void>;
|
|
10
|
+
static getUpcomingAnime(count: number): Promise<void>;
|
|
11
|
+
static getUserByUsername(username: string): Promise<void>;
|
|
12
|
+
static getAnimeDetailsByID(anilistID: number): Promise<void>;
|
|
13
|
+
static searchAnime(search: string, count: number): Promise<void>;
|
|
14
|
+
static searchManga(search: string, count: number): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
declare class MyAnimeList {
|
|
17
|
+
static importAnime(): Promise<void>;
|
|
18
|
+
static importManga(): Promise<void>;
|
|
19
|
+
static exportAnime(): Promise<void>;
|
|
20
|
+
static exportManga(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export { AniList, MyAnimeList };
|