anilink-api-wrapper 1.28.0 → 1.29.1
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 +14 -0
- package/dist/AniLink.js +3 -0
- package/dist/apis/anilist/Custom.js +42 -0
- package/dist/base/ValidateVariables.js +1 -2
- package/package.json +46 -46
package/README.md
CHANGED
|
@@ -55,6 +55,20 @@ const aniLink = new AniLink();
|
|
|
55
55
|
|
|
56
56
|
AniLink for AniList is divided into two main sections: `anilist.query` and `anilist.mutation`. The `anilist.query` section contains methods for querying data from the AniList API, while the `anilist.mutation` section contains methods for mutating data.
|
|
57
57
|
|
|
58
|
+
#### Custom Queries and Mutations
|
|
59
|
+
|
|
60
|
+
If needed there is a custom section `anilist.custom` that allows the user to pass a custom query or mutation to the AniList API.
|
|
61
|
+
|
|
62
|
+
The method accepts two parameters: the query or mutation string and an optional variables object.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const viewer = await aniLink.anilist.custom('query {Viewer {id}}');
|
|
66
|
+
|
|
67
|
+
const mutation = 'mutation ($about: String) {UpdateUser (about: $about) {id}}';
|
|
68
|
+
const variables = { about: "New about text" };
|
|
69
|
+
const response = await aniLink.anilist.custom(mutation, variables);
|
|
70
|
+
```
|
|
71
|
+
|
|
58
72
|
#### Query Methods
|
|
59
73
|
|
|
60
74
|
The `anilist.query` section is further divided into main query methods and page query methods. The main query methods return a single piece of data, while the page query methods return pages of data.
|
package/dist/AniLink.js
CHANGED
|
@@ -72,6 +72,7 @@ const SaveThreadComment_1 = require("./apis/anilist/mutation/SaveThreadComment")
|
|
|
72
72
|
const DeleteThreadComment_1 = require("./apis/anilist/mutation/DeleteThreadComment");
|
|
73
73
|
const UpdateAniChartSettings_1 = require("./apis/anilist/mutation/UpdateAniChartSettings");
|
|
74
74
|
const UpdateAniChartHighlights_1 = require("./apis/anilist/mutation/UpdateAniChartHighlights");
|
|
75
|
+
const Custom_1 = require("./apis/anilist/Custom");
|
|
75
76
|
/**
|
|
76
77
|
* `AniLink` is a class for interacting with the APIs.
|
|
77
78
|
* It provides methods for querying and mutating data.
|
|
@@ -89,6 +90,7 @@ class AniLink {
|
|
|
89
90
|
* ```
|
|
90
91
|
*/
|
|
91
92
|
constructor(authToken) {
|
|
93
|
+
const customInstance = new Custom_1.CustomRequest(authToken);
|
|
92
94
|
const userQueryInstance = new User_1.UserQuery(authToken);
|
|
93
95
|
const mediaQueryInstance = new Media_1.MediaQuery(authToken);
|
|
94
96
|
const mediaTrendQueryInstance = new MediaTrend_1.MediaTrendQuery(authToken);
|
|
@@ -161,6 +163,7 @@ class AniLink {
|
|
|
161
163
|
const updateAniChartSettingsMutationInstance = new UpdateAniChartSettings_1.UpdateAniChartSettingsMutation(authToken);
|
|
162
164
|
const updateAniChartHighlightsMutationInstance = new UpdateAniChartHighlights_1.UpdateAniChartHighlightsMutation(authToken);
|
|
163
165
|
this.anilist = {
|
|
166
|
+
custom: customInstance.custom.bind(customInstance),
|
|
164
167
|
query: {
|
|
165
168
|
user: userQueryInstance.user.bind(userQueryInstance),
|
|
166
169
|
media: mediaQueryInstance.media.bind(mediaQueryInstance),
|
|
@@ -0,0 +1,42 @@
|
|
|
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.CustomRequest = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../base/RequestHandler");
|
|
15
|
+
/**
|
|
16
|
+
* `CustomRequest` is a class representing a custom query or mutation by the user.
|
|
17
|
+
*/
|
|
18
|
+
class CustomRequest extends APIWrapper_1.APIWrapper {
|
|
19
|
+
/**
|
|
20
|
+
* Constructs a new `ActivityQuery` instance.
|
|
21
|
+
*
|
|
22
|
+
* @param authToken - The authentication token.
|
|
23
|
+
*/
|
|
24
|
+
constructor(authToken) {
|
|
25
|
+
super('https://graphql.anilist.co');
|
|
26
|
+
this.authToken = authToken;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `custom` is a method that sends a custom query or mutation by the user.
|
|
30
|
+
*
|
|
31
|
+
* @param query - The query for the request.
|
|
32
|
+
* @param variables - The variables for the request. This parameter is optional.
|
|
33
|
+
* @returns The response from the query request.
|
|
34
|
+
*/
|
|
35
|
+
custom(query_1) {
|
|
36
|
+
return __awaiter(this, arguments, void 0, function* (query, variables = {}) {
|
|
37
|
+
const data = { query, variables };
|
|
38
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CustomRequest = CustomRequest;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateVariables =
|
|
3
|
+
exports.validateVariables = validateVariables;
|
|
4
4
|
/**
|
|
5
5
|
* Validates the provided variables against the expected types.
|
|
6
6
|
*
|
|
@@ -123,4 +123,3 @@ function validateVariables(variables, variableTypeMappings) {
|
|
|
123
123
|
throw new Error(errors.join('\n'));
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
exports.validateVariables = validateVariables;
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "anilink-api-wrapper",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "API wrapper for AniManga sites such as Anilist, MyAnimeList, Kitsu.",
|
|
5
|
-
"main": "dist/AniLink.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"build": "rimraf dist && tsc",
|
|
9
|
-
"generate-docs": "typedoc --entryPoints ./src --entryPointStrategy expand --out docs --plugin typedoc-theme-hierarchy --theme hierarchy && node add-ga.js",
|
|
10
|
-
"prepublishOnly": "npm run build"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"anilist",
|
|
14
|
-
"myanimelist",
|
|
15
|
-
"kitsu",
|
|
16
|
-
"api",
|
|
17
|
-
"wrapper",
|
|
18
|
-
"anilist-api",
|
|
19
|
-
"anilist-query",
|
|
20
|
-
"anilist-mutation",
|
|
21
|
-
"anilist-graphql"
|
|
22
|
-
],
|
|
23
|
-
"author": "RLAlpha49",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@babel/preset-typescript": "^7.24.
|
|
27
|
-
"@types/jest": "^29.5.12",
|
|
28
|
-
"babel-jest": "^29.7.0",
|
|
29
|
-
"dotenv": "^16.4.5",
|
|
30
|
-
"eslint": "^8.57.0",
|
|
31
|
-
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
32
|
-
"eslint-plugin-import": "^2.29.1",
|
|
33
|
-
"eslint-plugin-n": "^
|
|
34
|
-
"eslint-plugin-promise": "^6.
|
|
35
|
-
"jest": "^29.7.0",
|
|
36
|
-
"rimraf": "^
|
|
37
|
-
"standard": "^17.1.0",
|
|
38
|
-
"ts-jest": "^29.
|
|
39
|
-
"typedoc": "^0.
|
|
40
|
-
"typedoc-theme-hierarchy": "^
|
|
41
|
-
"typescript": "^5.4
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"axios": "^1.
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "anilink-api-wrapper",
|
|
3
|
+
"version": "1.29.1",
|
|
4
|
+
"description": "API wrapper for AniManga sites such as Anilist, MyAnimeList, Kitsu.",
|
|
5
|
+
"main": "dist/AniLink.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest",
|
|
8
|
+
"build": "rimraf dist && tsc",
|
|
9
|
+
"generate-docs": "typedoc --entryPoints ./src --entryPointStrategy expand --out docs --plugin typedoc-theme-hierarchy --theme hierarchy && node add-ga.js",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"anilist",
|
|
14
|
+
"myanimelist",
|
|
15
|
+
"kitsu",
|
|
16
|
+
"api",
|
|
17
|
+
"wrapper",
|
|
18
|
+
"anilist-api",
|
|
19
|
+
"anilist-query",
|
|
20
|
+
"anilist-mutation",
|
|
21
|
+
"anilist-graphql"
|
|
22
|
+
],
|
|
23
|
+
"author": "RLAlpha49",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
27
|
+
"@types/jest": "^29.5.12",
|
|
28
|
+
"babel-jest": "^29.7.0",
|
|
29
|
+
"dotenv": "^16.4.5",
|
|
30
|
+
"eslint": "^8.57.0",
|
|
31
|
+
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
32
|
+
"eslint-plugin-import": "^2.29.1",
|
|
33
|
+
"eslint-plugin-n": "^16.6.2",
|
|
34
|
+
"eslint-plugin-promise": "^6.6.0",
|
|
35
|
+
"jest": "^29.7.0",
|
|
36
|
+
"rimraf": "^6.0.1",
|
|
37
|
+
"standard": "^17.1.0",
|
|
38
|
+
"ts-jest": "^29.2.5",
|
|
39
|
+
"typedoc": "^0.26.6",
|
|
40
|
+
"typedoc-theme-hierarchy": "^5.0.3",
|
|
41
|
+
"typescript": "^5.5.4"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"axios": "^1.7.5"
|
|
45
|
+
}
|
|
46
|
+
}
|