anilink-api-wrapper 1.1.0 → 1.2.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/dist/AniLink.js +10 -1
- package/dist/apis/anilist/interfaces/Tag.js +2 -0
- package/dist/apis/anilist/interfaces/responses/MediaTag.js +2 -0
- package/dist/apis/anilist/interfaces/responses/MediaTagCollection.js +2 -0
- package/dist/apis/anilist/interfaces/responses/User.js +3 -3
- package/dist/apis/anilist/query/GenreCollection.js +32 -0
- package/dist/apis/anilist/query/MediaTagCollection.js +35 -0
- package/dist/apis/anilist/query/User.js +2 -15
- package/dist/apis/anilist/query/Viewer.js +35 -0
- package/package.json +3 -2
- package/.eslintignore +0 -1
- package/.github/workflows/code_quality.yml +0 -32
- package/.github/workflows/codeql.yml +0 -33
- package/.github/workflows/test.yml +0 -30
- package/__tests__/anilist.test.ts +0 -268
- package/babel.config.js +0 -6
- package/jest.config.js +0 -11
- package/src/AniLink.ts +0 -80
- package/src/apis/anilist/interfaces/ActivityHistory.ts +0 -5
- package/src/apis/anilist/interfaces/CoverImage.ts +0 -15
- package/src/apis/anilist/interfaces/Distribution.ts +0 -4
- package/src/apis/anilist/interfaces/ExternalLink.ts +0 -13
- package/src/apis/anilist/interfaces/Favoured.ts +0 -15
- package/src/apis/anilist/interfaces/FuzzyDate.ts +0 -11
- package/src/apis/anilist/interfaces/Image.ts +0 -11
- package/src/apis/anilist/interfaces/ListScores.ts +0 -4
- package/src/apis/anilist/interfaces/Media.ts +0 -59
- package/src/apis/anilist/interfaces/MediaListEntry.ts +0 -11
- package/src/apis/anilist/interfaces/MediaStatistics.ts +0 -23
- package/src/apis/anilist/interfaces/MediaStats.ts +0 -7
- package/src/apis/anilist/interfaces/Name.ts +0 -17
- package/src/apis/anilist/interfaces/NextAiringEpisode.ts +0 -13
- package/src/apis/anilist/interfaces/Ranking.ts +0 -23
- package/src/apis/anilist/interfaces/ScoreDistribution.ts +0 -11
- package/src/apis/anilist/interfaces/Staff.ts +0 -6
- package/src/apis/anilist/interfaces/Stat.ts +0 -24
- package/src/apis/anilist/interfaces/Statistics.ts +0 -6
- package/src/apis/anilist/interfaces/StatusDistribution.ts +0 -11
- package/src/apis/anilist/interfaces/StreamingEpisode.ts +0 -15
- package/src/apis/anilist/interfaces/Studio.ts +0 -4
- package/src/apis/anilist/interfaces/Tag.ts +0 -20
- package/src/apis/anilist/interfaces/Title.ts +0 -15
- package/src/apis/anilist/interfaces/Trailer.ts +0 -13
- package/src/apis/anilist/interfaces/UserStats.ts +0 -39
- package/src/apis/anilist/interfaces/responses/AiringSchedule.ts +0 -22
- package/src/apis/anilist/interfaces/responses/Character.ts +0 -50
- package/src/apis/anilist/interfaces/responses/Media.ts +0 -322
- package/src/apis/anilist/interfaces/responses/MediaList.ts +0 -54
- package/src/apis/anilist/interfaces/responses/MediaListCollectionResponse.ts +0 -75
- package/src/apis/anilist/interfaces/responses/MediaTrend.ts +0 -28
- package/src/apis/anilist/interfaces/responses/Staff.ts +0 -102
- package/src/apis/anilist/interfaces/responses/User.ts +0 -432
- package/src/apis/anilist/mutation/UpdateUser.ts +0 -162
- package/src/apis/anilist/query/AiringSchedule.ts +0 -48
- package/src/apis/anilist/query/Character.ts +0 -40
- package/src/apis/anilist/query/Media.ts +0 -98
- package/src/apis/anilist/query/MediaList.ts +0 -56
- package/src/apis/anilist/query/MediaListCollection.ts +0 -47
- package/src/apis/anilist/query/MediaTrend.ts +0 -54
- package/src/apis/anilist/query/Staff.ts +0 -48
- package/src/apis/anilist/query/User.ts +0 -41
- package/src/base/APIWrapper.ts +0 -7
- package/src/base/RequestHandler.ts +0 -21
- package/tsconfig.json +0 -15
package/dist/AniLink.js
CHANGED
|
@@ -8,7 +8,10 @@ const Character_1 = require("./apis/anilist/query/Character");
|
|
|
8
8
|
const MediaList_1 = require("./apis/anilist/query/MediaList");
|
|
9
9
|
const Staff_1 = require("./apis/anilist/query/Staff");
|
|
10
10
|
const MediaListCollection_1 = require("./apis/anilist/query/MediaListCollection");
|
|
11
|
+
const GenreCollection_1 = require("./apis/anilist/query/GenreCollection");
|
|
11
12
|
const UpdateUser_1 = require("./apis/anilist/mutation/UpdateUser");
|
|
13
|
+
const MediaTagCollection_1 = require("./apis/anilist/query/MediaTagCollection");
|
|
14
|
+
const Viewer_1 = require("./apis/anilist/query/Viewer");
|
|
12
15
|
class AniLink {
|
|
13
16
|
constructor(authToken) {
|
|
14
17
|
const userQueryInstance = new User_1.UserQuery(authToken);
|
|
@@ -19,6 +22,9 @@ class AniLink {
|
|
|
19
22
|
const staffQueryInstance = new Staff_1.StaffQuery(authToken);
|
|
20
23
|
const mediaListQueryInstance = new MediaList_1.MediaListQuery(authToken);
|
|
21
24
|
const mediaListCollectionQueryInstance = new MediaListCollection_1.MediaListCollectionQuery(authToken);
|
|
25
|
+
const genreCollectionQueryInstance = new GenreCollection_1.GenreCollectionQuery(authToken);
|
|
26
|
+
const mediaTagCollectionQueryInstance = new MediaTagCollection_1.MediaTagCollectionQuery(authToken);
|
|
27
|
+
const viewerQueryInstance = new Viewer_1.ViewerQuery(authToken);
|
|
22
28
|
const updateUserMutationInstance = new UpdateUser_1.UpdateUserMutation(authToken);
|
|
23
29
|
this.anilist = {
|
|
24
30
|
query: {
|
|
@@ -29,7 +35,10 @@ class AniLink {
|
|
|
29
35
|
character: characterQueryInstance.character.bind(characterQueryInstance),
|
|
30
36
|
staff: staffQueryInstance.staff.bind(staffQueryInstance),
|
|
31
37
|
mediaList: mediaListQueryInstance.mediaList.bind(mediaListQueryInstance),
|
|
32
|
-
mediaListCollection: mediaListCollectionQueryInstance.mediaListCollection.bind(mediaListQueryInstance)
|
|
38
|
+
mediaListCollection: mediaListCollectionQueryInstance.mediaListCollection.bind(mediaListQueryInstance),
|
|
39
|
+
genreCollection: genreCollectionQueryInstance.genreCollection.bind(genreCollectionQueryInstance),
|
|
40
|
+
mediaTagCollection: mediaTagCollectionQueryInstance.mediaTagCollection.bind(mediaTagCollectionQueryInstance),
|
|
41
|
+
viewer: viewerQueryInstance.viewer.bind(viewerQueryInstance)
|
|
33
42
|
},
|
|
34
43
|
mutation: {
|
|
35
44
|
updateUser: updateUserMutationInstance.updateUser.bind(updateUserMutationInstance)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserSchema = void 0;
|
|
4
|
+
const Image_1 = require("../Image");
|
|
5
|
+
const UserStats_1 = require("../UserStats");
|
|
4
6
|
const Title_1 = require("../Title");
|
|
5
7
|
const Name_1 = require("../Name");
|
|
6
|
-
const Image_1 = require("../Image");
|
|
7
8
|
const CoverImage_1 = require("../CoverImage");
|
|
8
|
-
const UserStats_1 = require("../UserStats");
|
|
9
9
|
const Tag_1 = require("../Tag");
|
|
10
10
|
exports.UserSchema = `
|
|
11
11
|
id
|
|
12
12
|
name
|
|
13
|
-
about(asHtml: $
|
|
13
|
+
about(asHtml: $asHtml)
|
|
14
14
|
avatar {
|
|
15
15
|
large
|
|
16
16
|
medium
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GenreCollectionQuery = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
class GenreCollectionQuery extends APIWrapper_1.APIWrapper {
|
|
16
|
+
constructor(authToken) {
|
|
17
|
+
super('https://graphql.anilist.co');
|
|
18
|
+
this.authToken = authToken;
|
|
19
|
+
}
|
|
20
|
+
genreCollection() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const query = `
|
|
23
|
+
query {
|
|
24
|
+
GenreCollection
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
const data = { query };
|
|
28
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.GenreCollectionQuery = GenreCollectionQuery;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MediaTagCollectionQuery = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
const Tag_1 = require("../interfaces/Tag");
|
|
16
|
+
class MediaTagCollectionQuery extends APIWrapper_1.APIWrapper {
|
|
17
|
+
constructor(authToken) {
|
|
18
|
+
super('https://graphql.anilist.co');
|
|
19
|
+
this.authToken = authToken;
|
|
20
|
+
}
|
|
21
|
+
mediaTagCollection(variables) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const query = `
|
|
24
|
+
query ($status: Int) {
|
|
25
|
+
MediaTagCollection (status: $status) {
|
|
26
|
+
${Tag_1.TagSchema}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const data = { query, variables };
|
|
31
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.MediaTagCollectionQuery = MediaTagCollectionQuery;
|
|
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.UserQuery = void 0;
|
|
24
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
@@ -31,16 +20,14 @@ class UserQuery extends APIWrapper_1.APIWrapper {
|
|
|
31
20
|
}
|
|
32
21
|
user(variables) {
|
|
33
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
// If isHTML is not provided in variables, default it to true
|
|
35
|
-
const _a = variables != null ? variables : {}, { isHTML = true } = _a, rest = __rest(_a, ["isHTML"]);
|
|
36
23
|
const query = `
|
|
37
|
-
query ($id: Int, $name: String, $isModerator: Boolean, $search: String, $sort: [UserSort], $
|
|
24
|
+
query ($id: Int, $name: String, $isModerator: Boolean, $search: String, $sort: [UserSort], $asHtml: Boolean, $animeStatLimit: Int, $mangaStatLimit: Int, $animeStatSort: [UserStatisticsSort], $mangaStatSort: [UserStatisticsSort]) {
|
|
38
25
|
User (id: $id, name: $name, isModerator: $isModerator, search: $search, sort: $sort) {
|
|
39
26
|
${User_1.UserSchema}
|
|
40
27
|
}
|
|
41
28
|
}
|
|
42
29
|
`;
|
|
43
|
-
const data = { query, variables
|
|
30
|
+
const data = { query, variables };
|
|
44
31
|
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
45
32
|
});
|
|
46
33
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ViewerQuery = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
const User_1 = require("../interfaces/responses/User");
|
|
16
|
+
class ViewerQuery extends APIWrapper_1.APIWrapper {
|
|
17
|
+
constructor(authToken) {
|
|
18
|
+
super('https://graphql.anilist.co');
|
|
19
|
+
this.authToken = authToken;
|
|
20
|
+
}
|
|
21
|
+
viewer(variables) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const query = `
|
|
24
|
+
query ($asHtml: Boolean, $animeStatLimit: Int, $mangaStatLimit: Int, $animeStatSort: [UserStatisticsSort], $mangaStatSort: [UserStatisticsSort]) {
|
|
25
|
+
Viewer {
|
|
26
|
+
${User_1.UserSchema}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const data = { query, variables };
|
|
31
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ViewerQuery = ViewerQuery;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anilink-api-wrapper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Anilist API Wrapper",
|
|
5
5
|
"main": "dist/AniLink.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest",
|
|
8
|
-
"build": "tsc"
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
9
10
|
},
|
|
10
11
|
"keywords": [
|
|
11
12
|
"anilist",
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/__tests__/*
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Qodana
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
pull_request:
|
|
6
|
-
push:
|
|
7
|
-
branches:
|
|
8
|
-
- master
|
|
9
|
-
- 'releases/*'
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
qodana:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
permissions:
|
|
15
|
-
contents: read
|
|
16
|
-
pull-requests: write
|
|
17
|
-
checks: write
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v4
|
|
20
|
-
with:
|
|
21
|
-
ref: ${{ github.event.pull_request.head.sha }}
|
|
22
|
-
fetch-depth: 0
|
|
23
|
-
- name: Setup Node.js environment
|
|
24
|
-
uses: actions/setup-node@v4.0.2
|
|
25
|
-
with:
|
|
26
|
-
node-version: '21'
|
|
27
|
-
cache: 'npm'
|
|
28
|
-
- run: npm ci
|
|
29
|
-
- name: 'Qodana Scan'
|
|
30
|
-
uses: JetBrains/qodana-action@v2023.3.1
|
|
31
|
-
env:
|
|
32
|
-
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "CodeQL"
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: ["master"]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: ["master"]
|
|
8
|
-
schedule:
|
|
9
|
-
- cron: '0 7 * * 1'
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
analyze:
|
|
13
|
-
name: Analyze
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
permissions:
|
|
16
|
-
security-events: write
|
|
17
|
-
actions: read
|
|
18
|
-
contents: read
|
|
19
|
-
strategy:
|
|
20
|
-
fail-fast: false
|
|
21
|
-
matrix:
|
|
22
|
-
language: ['javascript-typescript']
|
|
23
|
-
steps:
|
|
24
|
-
- name: Checkout repository
|
|
25
|
-
uses: actions/checkout@v4
|
|
26
|
-
- name: Initialize CodeQL
|
|
27
|
-
uses: github/codeql-action/init@v3
|
|
28
|
-
with:
|
|
29
|
-
languages: ${{ matrix.language }}
|
|
30
|
-
- name: Perform CodeQL Analysis
|
|
31
|
-
uses: github/codeql-action/analyze@v3
|
|
32
|
-
with:
|
|
33
|
-
category: "/language:${{matrix.language}}"
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: Run Jest Tests
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: ["master"]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: ["master"]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v4
|
|
15
|
-
|
|
16
|
-
- name: Use Node.js
|
|
17
|
-
uses: actions/setup-node@v4
|
|
18
|
-
with:
|
|
19
|
-
node-version: '21'
|
|
20
|
-
|
|
21
|
-
- name: Install Dependencies
|
|
22
|
-
run: npm ci
|
|
23
|
-
|
|
24
|
-
- name: Build Project
|
|
25
|
-
run: npm run build
|
|
26
|
-
|
|
27
|
-
- name: Run Jest
|
|
28
|
-
run: npm run test
|
|
29
|
-
env:
|
|
30
|
-
ANILIST_TOKEN: ${{ secrets.ANILIST_TOKEN }}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
require('dotenv').config()
|
|
2
|
-
import AniLink from '../dist/AniLink.js'
|
|
3
|
-
// import AniLink from '../src/AniLink'
|
|
4
|
-
|
|
5
|
-
async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
|
|
6
|
-
try {
|
|
7
|
-
return await apiCall();
|
|
8
|
-
} catch (error: any) {
|
|
9
|
-
if (error.response && error.response.status === 429) {
|
|
10
|
-
console.log('Rate limit exceeded, waiting for 1 minute before retrying...');
|
|
11
|
-
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
|
|
12
|
-
console.log('Retrying...');
|
|
13
|
-
return handleRateLimit(apiCall, retryAfter);
|
|
14
|
-
} else {
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe('Anilist API Query', () => {
|
|
21
|
-
let aniLink: AniLink
|
|
22
|
-
|
|
23
|
-
beforeAll(() => {
|
|
24
|
-
const token = process.env.ANILIST_TOKEN
|
|
25
|
-
aniLink = new AniLink(token)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test('user query', async () => {
|
|
29
|
-
try {
|
|
30
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.user({ id: 542244, isHTML: true }))
|
|
31
|
-
console.log(response)
|
|
32
|
-
expect(response).toBeDefined()
|
|
33
|
-
} catch (error: any) {
|
|
34
|
-
if (error.response.data) {
|
|
35
|
-
throw error.response.data
|
|
36
|
-
} else {
|
|
37
|
-
throw error.response
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('user query should handle errors', async () => {
|
|
43
|
-
try {
|
|
44
|
-
await handleRateLimit(() => aniLink.anilist.query.user({ id: 'invalid', isHTML: false }))
|
|
45
|
-
} catch (error: any) {
|
|
46
|
-
expect(error).toBeDefined()
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test('media query', async () => {
|
|
51
|
-
try {
|
|
52
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.media({ id: 1, type: 'ANIME' }))
|
|
53
|
-
console.log(response)
|
|
54
|
-
expect(response).toBeDefined()
|
|
55
|
-
} catch (error: any) {
|
|
56
|
-
if (error.response.data) {
|
|
57
|
-
throw error.response.data
|
|
58
|
-
} else {
|
|
59
|
-
throw error.response
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
test('media query should handle errors', async () => {
|
|
65
|
-
try {
|
|
66
|
-
await handleRateLimit(() => aniLink.anilist.query.media({ id: 'invalid', type: 'ANIME' }))
|
|
67
|
-
} catch (error: any) {
|
|
68
|
-
expect(error).toBeDefined()
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('media trend query', async () => {
|
|
73
|
-
try {
|
|
74
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.mediaTrend({ mediaId: 1, type: 'ANIME' }))
|
|
75
|
-
console.log(response)
|
|
76
|
-
expect(response).toBeDefined()
|
|
77
|
-
} catch (error: any) {
|
|
78
|
-
if (error.response.data) {
|
|
79
|
-
throw error.response.data
|
|
80
|
-
} else {
|
|
81
|
-
throw error.response
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
test('media trend query should handle errors', async () => {
|
|
87
|
-
try {
|
|
88
|
-
await handleRateLimit(() => aniLink.anilist.query.mediaTrend({ mediaId: 'invalid', type: 'ANIME' }))
|
|
89
|
-
} catch (error: any) {
|
|
90
|
-
expect(error).toBeDefined()
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
test('airing schedule query should return a response', async () => {
|
|
95
|
-
try {
|
|
96
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.airingSchedule({ mediaId: 130590 })) // id needs to be an airing anime
|
|
97
|
-
console.log(response)
|
|
98
|
-
expect(response).toBeDefined()
|
|
99
|
-
} catch (error: any) {
|
|
100
|
-
if (error.response.data) {
|
|
101
|
-
throw error.response.data
|
|
102
|
-
} else {
|
|
103
|
-
throw error.response
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
test('airing schedule query should handle errors', async () => {
|
|
109
|
-
try {
|
|
110
|
-
await handleRateLimit(() => aniLink.anilist.query.airingSchedule({ mediaId: 'invalid' }))
|
|
111
|
-
} catch (error) {
|
|
112
|
-
expect(error).toBeDefined()
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test('character query should return a response', async () => {
|
|
117
|
-
try {
|
|
118
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.character({ id: 1, asHtml: true, mediaSort: ['POPULARITY_DESC'], mediaType: 'ANIME', mediaOnList: true, mediaPage: 1, mediaPerPage: 10 }))
|
|
119
|
-
console.log(response)
|
|
120
|
-
expect(response).toBeDefined()
|
|
121
|
-
} catch (error: any) {
|
|
122
|
-
if (error.response.data) {
|
|
123
|
-
throw error.response.data
|
|
124
|
-
} else {
|
|
125
|
-
throw error.response
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
test('character query should handle errors', async () => {
|
|
131
|
-
try {
|
|
132
|
-
await handleRateLimit(() => aniLink.anilist.query.character({ id: 'invalid', asHtml: true, mediaSort: ['POPULARITY_DESC'], mediaOnList: true, mediaPage: 1, mediaPerPage: 10 }))
|
|
133
|
-
} catch (error) {
|
|
134
|
-
expect(error).toBeDefined()
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test('staff query should return a response', async () => {
|
|
139
|
-
try {
|
|
140
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.staff({
|
|
141
|
-
id: 132186,
|
|
142
|
-
asHtml: true,
|
|
143
|
-
staffMediaSort: ['POPULARITY_DESC'],
|
|
144
|
-
staffMediaType: 'ANIME',
|
|
145
|
-
staffMediaOnList: true,
|
|
146
|
-
staffMediaPage: 1,
|
|
147
|
-
staffMediaPerPage: 10,
|
|
148
|
-
charactersSort: ['ID'],
|
|
149
|
-
charactersPage: 1,
|
|
150
|
-
charactersPerPage: 10,
|
|
151
|
-
characterMediaSort: ['POPULARITY_DESC'],
|
|
152
|
-
characterMediaOnList: true,
|
|
153
|
-
characterMediaPage: 1,
|
|
154
|
-
characterMediaPerPage: 10
|
|
155
|
-
}))
|
|
156
|
-
console.log(response)
|
|
157
|
-
expect(response).toBeDefined()
|
|
158
|
-
} catch (error: any) {
|
|
159
|
-
if (error.response.data) {
|
|
160
|
-
throw error.response.data
|
|
161
|
-
} else {
|
|
162
|
-
throw error.response
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
test('staff query should handle errors', async () => {
|
|
168
|
-
try {
|
|
169
|
-
await handleRateLimit(() => aniLink.anilist.query.staff({
|
|
170
|
-
id: 'invalid'
|
|
171
|
-
}))
|
|
172
|
-
} catch (error) {
|
|
173
|
-
expect(error).toBeDefined()
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
test('media list query should return a response', async () => {
|
|
178
|
-
try {
|
|
179
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.mediaList({ userId: 542244 }))
|
|
180
|
-
console.log(response)
|
|
181
|
-
expect(response).toBeDefined()
|
|
182
|
-
} catch (error: any) {
|
|
183
|
-
if (error.response.data) {
|
|
184
|
-
throw error.response.data
|
|
185
|
-
} else {
|
|
186
|
-
throw error.response
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
test('media list query should handle errors', async () => {
|
|
192
|
-
try {
|
|
193
|
-
await handleRateLimit(() => aniLink.anilist.query.mediaList({ userId: 'invalid' }))
|
|
194
|
-
} catch (error) {
|
|
195
|
-
expect(error).toBeDefined()
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
test('media list collection query should return a response', async () => {
|
|
200
|
-
try {
|
|
201
|
-
const response = await handleRateLimit(() => aniLink.anilist.query.mediaListCollection({
|
|
202
|
-
userId: 542244,
|
|
203
|
-
type: 'ANIME',
|
|
204
|
-
status: 'COMPLETED',
|
|
205
|
-
chunk: 1,
|
|
206
|
-
perChunk: 10000
|
|
207
|
-
}))
|
|
208
|
-
console.log(response)
|
|
209
|
-
expect(response).toBeDefined()
|
|
210
|
-
} catch (error: any) {
|
|
211
|
-
if (error.response.data) {
|
|
212
|
-
throw error.response.data
|
|
213
|
-
} else {
|
|
214
|
-
throw error.response
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
test('media list collection query should handle errors', async () => {
|
|
220
|
-
try {
|
|
221
|
-
await handleRateLimit(() => aniLink.anilist.query.mediaListCollection({
|
|
222
|
-
userId: 'invalid'
|
|
223
|
-
}))
|
|
224
|
-
} catch (error) {
|
|
225
|
-
expect(error).toBeDefined()
|
|
226
|
-
}
|
|
227
|
-
})
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
describe('Anilist API Mutation', () => {
|
|
231
|
-
let aniLink: AniLink
|
|
232
|
-
|
|
233
|
-
beforeAll(() => {
|
|
234
|
-
const token = process.env.ANILIST_TOKEN
|
|
235
|
-
aniLink = new AniLink(token)
|
|
236
|
-
})
|
|
237
|
-
|
|
238
|
-
test('update user', async () => {
|
|
239
|
-
try {
|
|
240
|
-
const response = await handleRateLimit(() => aniLink.anilist.mutation.updateUser({
|
|
241
|
-
about: 'New about text',
|
|
242
|
-
titleLanguage: 'ENGLISH',
|
|
243
|
-
displayAdultContent: true,
|
|
244
|
-
airingNotifications: true,
|
|
245
|
-
scoreFormat: 'POINT_10',
|
|
246
|
-
rowOrder: 'title',
|
|
247
|
-
profileColor: 'blue',
|
|
248
|
-
donatorBadge: 'Supporter',
|
|
249
|
-
notificationOptions: [{ type: 'AIRING', enabled: true }],
|
|
250
|
-
timezone: '-06:00',
|
|
251
|
-
activityMergeTime: 30,
|
|
252
|
-
animeListOptions: { sectionOrder: ['title'], customLists: [], advancedScoring: [], advancedScoringEnabled: false },
|
|
253
|
-
mangaListOptions: { sectionOrder: ['title'], customLists: [], advancedScoring: [], advancedScoringEnabled: false },
|
|
254
|
-
staffNameLanguage: 'ROMAJI',
|
|
255
|
-
restrictMessagesToFollowing: false,
|
|
256
|
-
disabledListActivity: [{ type: 'CURRENT', disabled: false }]
|
|
257
|
-
}))
|
|
258
|
-
console.log(response)
|
|
259
|
-
expect(response).toBeDefined()
|
|
260
|
-
} catch (error: any) {
|
|
261
|
-
if (error.response.data) {
|
|
262
|
-
throw error.response.data
|
|
263
|
-
} else {
|
|
264
|
-
throw error.response
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
})
|
package/babel.config.js
DELETED
package/jest.config.js
DELETED