@irfanshadikrishad/anilist 1.7.0 → 2.0.0-forbidden
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.md +382 -0
- package/README.md +0 -1
- package/bin/helpers/auth.d.ts +6 -1
- package/bin/helpers/auth.js +413 -78
- package/bin/helpers/fetcher.js +7 -7
- package/bin/helpers/lib/colorize.d.ts +8 -0
- package/bin/helpers/lib/colorize.js +19 -0
- package/bin/helpers/lists.d.ts +1 -5
- package/bin/helpers/lists.js +166 -289
- package/bin/helpers/mutations.d.ts +2 -2
- package/bin/helpers/mutations.js +6 -9
- package/bin/helpers/queries.d.ts +4 -1
- package/bin/helpers/queries.js +35 -1
- package/bin/helpers/truncate.js +2 -2
- package/bin/helpers/types.d.ts +53 -15
- package/bin/helpers/validation.js +8 -8
- package/bin/helpers/workers.d.ts +3 -2
- package/bin/helpers/workers.js +114 -94
- package/bin/index.js +79 -93
- package/package.json +87 -84
- package/CITATION.cff +0 -8
package/bin/helpers/fetcher.js
CHANGED
|
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import fetch from
|
|
11
|
-
import { Auth } from
|
|
12
|
-
import { aniListEndpoint, handleRateLimitRetry } from
|
|
10
|
+
import fetch from 'node-fetch';
|
|
11
|
+
import { Auth } from './auth.js';
|
|
12
|
+
import { aniListEndpoint, handleRateLimitRetry } from './workers.js';
|
|
13
13
|
/**
|
|
14
14
|
* Sends a GraphQL request to the AniList API.
|
|
15
15
|
*
|
|
@@ -26,15 +26,15 @@ function fetcher(query, variables) {
|
|
|
26
26
|
var _a, _b;
|
|
27
27
|
try {
|
|
28
28
|
const headers = {
|
|
29
|
-
|
|
29
|
+
'content-type': 'application/json',
|
|
30
30
|
};
|
|
31
31
|
const token = (yield Auth.isLoggedIn())
|
|
32
32
|
? yield Auth.RetriveAccessToken()
|
|
33
33
|
: null;
|
|
34
34
|
if (token)
|
|
35
|
-
headers[
|
|
35
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
36
36
|
const request = yield fetch(aniListEndpoint, {
|
|
37
|
-
method:
|
|
37
|
+
method: 'POST',
|
|
38
38
|
headers: headers,
|
|
39
39
|
body: JSON.stringify({ query, variables }),
|
|
40
40
|
});
|
|
@@ -47,7 +47,7 @@ function fetcher(query, variables) {
|
|
|
47
47
|
return yield fetcher(query, variables);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
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) ||
|
|
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'}.`);
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
class colorize {
|
|
3
|
+
static Green(txt) {
|
|
4
|
+
return String(chalk.green(String(txt)));
|
|
5
|
+
}
|
|
6
|
+
static Red(txt) {
|
|
7
|
+
return String(chalk.red(String(txt)));
|
|
8
|
+
}
|
|
9
|
+
static Yellow(txt) {
|
|
10
|
+
return String(chalk.yellow(String(txt)));
|
|
11
|
+
}
|
|
12
|
+
static BgGreen(txt) {
|
|
13
|
+
return String(chalk.bgGreen(String(txt)));
|
|
14
|
+
}
|
|
15
|
+
static BgRed(txt) {
|
|
16
|
+
return String(chalk.bgRed(txt));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { colorize };
|
package/bin/helpers/lists.d.ts
CHANGED
|
@@ -23,8 +23,4 @@ declare class MyAnimeList {
|
|
|
23
23
|
declare class AniDB {
|
|
24
24
|
static importAnime(): Promise<void>;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
static AnimeList(): Promise<void>;
|
|
28
|
-
static MangaList(): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
export { AniDB, AniList, MoveTo, MyAnimeList };
|
|
26
|
+
export { AniDB, AniList, MyAnimeList };
|