anilink-api-wrapper 1.27.0 → 1.29.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 +21 -0
- package/dist/AniLink.js +25 -1
- package/dist/apis/anilist/Custom.js +42 -0
- package/dist/apis/anilist/mutation/DeleteThread.js +61 -0
- package/dist/apis/anilist/mutation/DeleteThreadComment.js +61 -0
- package/dist/apis/anilist/mutation/SaveThread.js +69 -0
- package/dist/apis/anilist/mutation/SaveThreadComment.js +67 -0
- package/dist/apis/anilist/mutation/ToggleThreadSubscription.js +64 -0
- package/dist/apis/anilist/mutation/UpdateAniChartHighlights.js +58 -0
- package/dist/apis/anilist/mutation/UpdateAniChartSettings.js +58 -0
- package/package.json +1 -1
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.
|
|
@@ -132,6 +146,13 @@ List of methods in `anilist.mutation`:
|
|
|
132
146
|
- saveReview
|
|
133
147
|
- deleteReview
|
|
134
148
|
- saveRecommendation
|
|
149
|
+
- saveThread
|
|
150
|
+
- deleteThread
|
|
151
|
+
- toggleThreadSubscription
|
|
152
|
+
- saveThreadComment
|
|
153
|
+
- deleteThreadComment
|
|
154
|
+
- updateAniChartSettings
|
|
155
|
+
- updateAniChartHighlights
|
|
135
156
|
|
|
136
157
|
### Error Handling
|
|
137
158
|
|
package/dist/AniLink.js
CHANGED
|
@@ -65,6 +65,14 @@ const UpdateFavouriteOrder_1 = require("./apis/anilist/mutation/UpdateFavouriteO
|
|
|
65
65
|
const SaveReview_1 = require("./apis/anilist/mutation/SaveReview");
|
|
66
66
|
const DeleteReview_1 = require("./apis/anilist/mutation/DeleteReview");
|
|
67
67
|
const SaveRecommendation_1 = require("./apis/anilist/mutation/SaveRecommendation");
|
|
68
|
+
const SaveThread_1 = require("./apis/anilist/mutation/SaveThread");
|
|
69
|
+
const DeleteThread_1 = require("./apis/anilist/mutation/DeleteThread");
|
|
70
|
+
const ToggleThreadSubscription_1 = require("./apis/anilist/mutation/ToggleThreadSubscription");
|
|
71
|
+
const SaveThreadComment_1 = require("./apis/anilist/mutation/SaveThreadComment");
|
|
72
|
+
const DeleteThreadComment_1 = require("./apis/anilist/mutation/DeleteThreadComment");
|
|
73
|
+
const UpdateAniChartSettings_1 = require("./apis/anilist/mutation/UpdateAniChartSettings");
|
|
74
|
+
const UpdateAniChartHighlights_1 = require("./apis/anilist/mutation/UpdateAniChartHighlights");
|
|
75
|
+
const Custom_1 = require("./apis/anilist/Custom");
|
|
68
76
|
/**
|
|
69
77
|
* `AniLink` is a class for interacting with the APIs.
|
|
70
78
|
* It provides methods for querying and mutating data.
|
|
@@ -82,6 +90,7 @@ class AniLink {
|
|
|
82
90
|
* ```
|
|
83
91
|
*/
|
|
84
92
|
constructor(authToken) {
|
|
93
|
+
const customInstance = new Custom_1.CustomRequest(authToken);
|
|
85
94
|
const userQueryInstance = new User_1.UserQuery(authToken);
|
|
86
95
|
const mediaQueryInstance = new Media_1.MediaQuery(authToken);
|
|
87
96
|
const mediaTrendQueryInstance = new MediaTrend_1.MediaTrendQuery(authToken);
|
|
@@ -146,7 +155,15 @@ class AniLink {
|
|
|
146
155
|
const saveReviewMutationInstance = new SaveReview_1.SaveReviewMutation(authToken);
|
|
147
156
|
const deleteReviewMutationInstance = new DeleteReview_1.DeleteReviewMutation(authToken);
|
|
148
157
|
const saveRecommendationMutationInstance = new SaveRecommendation_1.SaveRecommendationMutation(authToken);
|
|
158
|
+
const saveThreadMutationInstance = new SaveThread_1.SaveThreadMutation(authToken);
|
|
159
|
+
const deleteThreadMutationInstance = new DeleteThread_1.DeleteThreadMutation(authToken);
|
|
160
|
+
const toggleThreadSubscriptionMutationInstance = new ToggleThreadSubscription_1.ToggleThreadSubscriptionMutation(authToken);
|
|
161
|
+
const saveThreadCommentMutationInstance = new SaveThreadComment_1.SaveThreadCommentMutation(authToken);
|
|
162
|
+
const deleteThreadCommentMutationInstance = new DeleteThreadComment_1.DeleteThreadCommentMutation(authToken);
|
|
163
|
+
const updateAniChartSettingsMutationInstance = new UpdateAniChartSettings_1.UpdateAniChartSettingsMutation(authToken);
|
|
164
|
+
const updateAniChartHighlightsMutationInstance = new UpdateAniChartHighlights_1.UpdateAniChartHighlightsMutation(authToken);
|
|
149
165
|
this.anilist = {
|
|
166
|
+
custom: customInstance.custom.bind(customInstance),
|
|
150
167
|
query: {
|
|
151
168
|
user: userQueryInstance.user.bind(userQueryInstance),
|
|
152
169
|
media: mediaQueryInstance.media.bind(mediaQueryInstance),
|
|
@@ -215,7 +232,14 @@ class AniLink {
|
|
|
215
232
|
updateFavouriteOrder: updateFavouriteOrderMutationInstance.updateFavouriteOrder.bind(updateFavouriteOrderMutationInstance),
|
|
216
233
|
saveReview: saveReviewMutationInstance.saveReview.bind(saveReviewMutationInstance),
|
|
217
234
|
deleteReview: deleteReviewMutationInstance.deleteReview.bind(deleteReviewMutationInstance),
|
|
218
|
-
saveRecommendation: saveRecommendationMutationInstance.saveRecommendation.bind(saveRecommendationMutationInstance)
|
|
235
|
+
saveRecommendation: saveRecommendationMutationInstance.saveRecommendation.bind(saveRecommendationMutationInstance),
|
|
236
|
+
saveThread: saveThreadMutationInstance.saveThread.bind(saveThreadMutationInstance),
|
|
237
|
+
deleteThread: deleteThreadMutationInstance.deleteThread.bind(deleteThreadMutationInstance),
|
|
238
|
+
toggleThreadSubscription: toggleThreadSubscriptionMutationInstance.toggleThreadSubscription.bind(toggleThreadSubscriptionMutationInstance),
|
|
239
|
+
saveThreadComment: saveThreadCommentMutationInstance.saveThreadComment.bind(saveThreadCommentMutationInstance),
|
|
240
|
+
deleteThreadComment: deleteThreadCommentMutationInstance.deleteThreadComment.bind(deleteThreadCommentMutationInstance),
|
|
241
|
+
updateAniChartSettings: updateAniChartSettingsMutationInstance.updateAniChartSettings.bind(updateAniChartSettingsMutationInstance),
|
|
242
|
+
updateAniChartHighlights: updateAniChartHighlightsMutationInstance.updateAniChartHighlights.bind(updateAniChartHighlightsMutationInstance)
|
|
219
243
|
}
|
|
220
244
|
};
|
|
221
245
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.DeleteThreadMutation = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
+
/**
|
|
17
|
+
* `DeleteThreadMutation` is a class representing a mutation to delete a thread.
|
|
18
|
+
* It includes a method to delete a thread
|
|
19
|
+
*/
|
|
20
|
+
class DeleteThreadMutation extends APIWrapper_1.APIWrapper {
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new `DeleteThreadMutation` instance.
|
|
23
|
+
*
|
|
24
|
+
* @param authToken - The authentication token.
|
|
25
|
+
*/
|
|
26
|
+
constructor(authToken) {
|
|
27
|
+
super('https://graphql.anilist.co');
|
|
28
|
+
this.authToken = authToken;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `deleteThread` is a method that sends a mutation request to delete a thread.
|
|
32
|
+
*
|
|
33
|
+
* @param variables - An object of type `DeleteThreadVariables` representing the variables for the mutation.
|
|
34
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
35
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
36
|
+
* */
|
|
37
|
+
deleteThread(variables) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (!this.authToken) {
|
|
40
|
+
throw new Error('DeleteThreadMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
41
|
+
}
|
|
42
|
+
if (!variables.id) {
|
|
43
|
+
throw new Error('id variable is required');
|
|
44
|
+
}
|
|
45
|
+
const variableTypeMappings = {
|
|
46
|
+
id: 'number'
|
|
47
|
+
};
|
|
48
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
49
|
+
const mutation = `
|
|
50
|
+
mutation ($id: Int) {
|
|
51
|
+
DeleteThread (id: $id) {
|
|
52
|
+
deleted
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
const data = { query: mutation, variables };
|
|
57
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DeleteThreadMutation = DeleteThreadMutation;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.DeleteThreadCommentMutation = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
+
/**
|
|
17
|
+
* `DeleteThreadCommentMutation` is a class representing a mutation to delete a thread comment.
|
|
18
|
+
* It includes a method to delete a thread
|
|
19
|
+
*/
|
|
20
|
+
class DeleteThreadCommentMutation extends APIWrapper_1.APIWrapper {
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new `DeleteThreadCommentMutation` instance.
|
|
23
|
+
*
|
|
24
|
+
* @param authToken - The authentication token.
|
|
25
|
+
*/
|
|
26
|
+
constructor(authToken) {
|
|
27
|
+
super('https://graphql.anilist.co');
|
|
28
|
+
this.authToken = authToken;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `deleteThreadComment` is a method that sends a mutation request to delete a thread comment.
|
|
32
|
+
*
|
|
33
|
+
* @param variables - An object of type `DeleteThreadCommentVariables` representing the variables for the mutation.
|
|
34
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
35
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
36
|
+
* */
|
|
37
|
+
deleteThreadComment(variables) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (!this.authToken) {
|
|
40
|
+
throw new Error('DeleteThreadCommentMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
41
|
+
}
|
|
42
|
+
if (!variables.id) {
|
|
43
|
+
throw new Error('id variable is required');
|
|
44
|
+
}
|
|
45
|
+
const variableTypeMappings = {
|
|
46
|
+
id: 'number'
|
|
47
|
+
};
|
|
48
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
49
|
+
const mutation = `
|
|
50
|
+
mutation ($id: Int) {
|
|
51
|
+
DeleteThreadComment (id: $id) {
|
|
52
|
+
deleted
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
const data = { query: mutation, variables };
|
|
57
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DeleteThreadCommentMutation = DeleteThreadCommentMutation;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.SaveThreadMutation = void 0;
|
|
13
|
+
const Thread_1 = require("../interfaces/responses/query/Thread");
|
|
14
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
15
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
16
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
17
|
+
/**
|
|
18
|
+
* `SaveThreadMutation` is a class representing a mutation to save a thread.
|
|
19
|
+
* It includes a method to save a thread
|
|
20
|
+
*/
|
|
21
|
+
class SaveThreadMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `SaveThreadMutation` instance.
|
|
24
|
+
*
|
|
25
|
+
* @param authToken - The authentication token.
|
|
26
|
+
*/
|
|
27
|
+
constructor(authToken) {
|
|
28
|
+
super('https://graphql.anilist.co');
|
|
29
|
+
this.authToken = authToken;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `SaveThread` is a method that sends a mutation request to save a thread.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `SaveThreadVariables` representing the variables for the mutation.
|
|
35
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
+
* */
|
|
38
|
+
saveThread(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('SaveThreadMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.id && !variables.title) {
|
|
44
|
+
throw new Error('id or title variable is required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
id: 'number',
|
|
48
|
+
title: 'string',
|
|
49
|
+
body: 'string',
|
|
50
|
+
categories: 'number[]',
|
|
51
|
+
mediaCategories: 'number[]',
|
|
52
|
+
sticky: 'boolean',
|
|
53
|
+
locked: 'boolean',
|
|
54
|
+
asHtml: 'boolean'
|
|
55
|
+
};
|
|
56
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
57
|
+
const mutation = `
|
|
58
|
+
mutation ($id: Int, $title: String, $body: String, $categories: [Int], $mediaCategories: [Int], $sticky: Boolean, $locked: Boolean, $asHtml: Boolean) {
|
|
59
|
+
SaveThread (id: $id, title: $title, body: $body, categories: $categories, mediaCategories: $mediaCategories, sticky: $sticky, locked: $locked) {
|
|
60
|
+
${Thread_1.ThreadSchema}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
const data = { query: mutation, variables };
|
|
65
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.SaveThreadMutation = SaveThreadMutation;
|
|
@@ -0,0 +1,67 @@
|
|
|
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.SaveThreadCommentMutation = void 0;
|
|
13
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
14
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
15
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
16
|
+
const ThreadComment_1 = require("../interfaces/responses/query/ThreadComment");
|
|
17
|
+
/**
|
|
18
|
+
* `SaveThreadCommentMutation` is a class representing a mutation to save a thread comment.
|
|
19
|
+
* It includes a method to save a thread
|
|
20
|
+
*/
|
|
21
|
+
class SaveThreadCommentMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `SaveThreadCommentMutation` instance.
|
|
24
|
+
*
|
|
25
|
+
* @param authToken - The authentication token.
|
|
26
|
+
*/
|
|
27
|
+
constructor(authToken) {
|
|
28
|
+
super('https://graphql.anilist.co');
|
|
29
|
+
this.authToken = authToken;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `saveThreadComment` is a method that sends a mutation request to save a thread comment.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `SaveThreadCommentVariables` representing the variables for the mutation.
|
|
35
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
+
* */
|
|
38
|
+
saveThreadComment(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('SaveThreadCommentMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.id && !variables.threadId) {
|
|
44
|
+
throw new Error('id or title variable is required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
id: 'number',
|
|
48
|
+
threadId: 'number',
|
|
49
|
+
parentCommentId: 'number',
|
|
50
|
+
comment: 'string',
|
|
51
|
+
locked: 'boolean',
|
|
52
|
+
asHtml: 'boolean'
|
|
53
|
+
};
|
|
54
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
55
|
+
const mutation = `
|
|
56
|
+
mutation ($id: Int, $threadId: Int, $parentCommentId: Int, $comment: String, $locked: Boolean, $asHtml: Boolean) {
|
|
57
|
+
SaveThreadComment (id: $id, threadId: $threadId, parentCommentId: $parentCommentId, comment: $comment, locked: $locked) {
|
|
58
|
+
${ThreadComment_1.ThreadCommentSchema}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
const data = { query: mutation, variables };
|
|
63
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.SaveThreadCommentMutation = SaveThreadCommentMutation;
|
|
@@ -0,0 +1,64 @@
|
|
|
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.ToggleThreadSubscriptionMutation = void 0;
|
|
13
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
+
const Thread_1 = require("../interfaces/responses/query/Thread");
|
|
17
|
+
/**
|
|
18
|
+
* `ToggleThreadSubscriptionMutation` is a class representing a mutation to subscribe to a thread.
|
|
19
|
+
* It includes a method to subscribe to a thread
|
|
20
|
+
*/
|
|
21
|
+
class ToggleThreadSubscriptionMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `ToggleThreadSubscriptionMutation` instance.
|
|
24
|
+
*
|
|
25
|
+
* @param authToken - The authentication token.
|
|
26
|
+
*/
|
|
27
|
+
constructor(authToken) {
|
|
28
|
+
super('https://graphql.anilist.co');
|
|
29
|
+
this.authToken = authToken;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `toggleThreadSubscription` is a method that sends a mutation request to subscribe to an activity.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `ToggleThreadSubscriptionVariables` representing the variables for the mutation.
|
|
35
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
36
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
37
|
+
* */
|
|
38
|
+
toggleThreadSubscription(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('ToggleThreadSubscriptionMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.threadId || !variables.subscribe) {
|
|
44
|
+
throw new Error('threadId & subscribe variables are required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
threadId: 'number',
|
|
48
|
+
subscribe: 'boolean',
|
|
49
|
+
asHtml: 'boolean'
|
|
50
|
+
};
|
|
51
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
52
|
+
const mutation = `
|
|
53
|
+
mutation ($threadId: Int, $subscribe: Boolean, $asHtml: Boolean) {
|
|
54
|
+
ToggleThreadSubscription (threadId: $threadId, subscribe: $subscribe) {
|
|
55
|
+
${Thread_1.ThreadSchema}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
const data = { query: mutation, variables };
|
|
60
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.ToggleThreadSubscriptionMutation = ToggleThreadSubscriptionMutation;
|
|
@@ -0,0 +1,58 @@
|
|
|
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.UpdateAniChartHighlightsMutation = void 0;
|
|
13
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
14
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
15
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
16
|
+
/**
|
|
17
|
+
* `UpdateAniChartHighlightsMutation` is a class that represents a mutation to update the AniChart highlights.
|
|
18
|
+
*/
|
|
19
|
+
class UpdateAniChartHighlightsMutation extends APIWrapper_1.APIWrapper {
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new `UpdateAniChartHighlightsMutation` instance.
|
|
22
|
+
*
|
|
23
|
+
* @param authToken - The authentication token.
|
|
24
|
+
*/
|
|
25
|
+
constructor(authToken) {
|
|
26
|
+
super('https://graphql.anilist.co');
|
|
27
|
+
this.authToken = authToken;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `updateAniChartHighlights` is a method that sends a mutation request to update the AniChart highlights.
|
|
31
|
+
*
|
|
32
|
+
* @param variables - An object of type `UpdateAniChartHighlightsVariables` representing the variables for the mutation.
|
|
33
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
34
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
35
|
+
*/
|
|
36
|
+
updateAniChartHighlights(variables) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (!this.authToken) {
|
|
39
|
+
throw new Error('UpdateAniChartHighlightsMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
40
|
+
}
|
|
41
|
+
const variableTypeMappings = {
|
|
42
|
+
highlights: {
|
|
43
|
+
mediaId: 'number',
|
|
44
|
+
highlight: 'boolean'
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
48
|
+
const mutation = `
|
|
49
|
+
mutation ($highlights: [AniChartHighlightInput]) {
|
|
50
|
+
UpdateAniChartHighlights (highlights: $highlights)
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
const data = { query: mutation, variables };
|
|
54
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.UpdateAniChartHighlightsMutation = UpdateAniChartHighlightsMutation;
|
|
@@ -0,0 +1,58 @@
|
|
|
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.UpdateAniChartSettingsMutation = void 0;
|
|
13
|
+
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
14
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
15
|
+
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
16
|
+
/**
|
|
17
|
+
* `UpdateAniChartSettingsMutation` is a class that represents a mutation to update the AniChart settings.
|
|
18
|
+
*/
|
|
19
|
+
class UpdateAniChartSettingsMutation extends APIWrapper_1.APIWrapper {
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new `UpdateAniChartSettingsMutation` instance.
|
|
22
|
+
*
|
|
23
|
+
* @param authToken - The authentication token.
|
|
24
|
+
*/
|
|
25
|
+
constructor(authToken) {
|
|
26
|
+
super('https://graphql.anilist.co');
|
|
27
|
+
this.authToken = authToken;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `updateAniChartSettings` is a method that sends a mutation request to update the AniChart settings.
|
|
31
|
+
*
|
|
32
|
+
* @param variables - An object of type `UpdateAniChartSettingsVariables` representing the variables for the mutation.
|
|
33
|
+
* @returns A Promise that resolves to the response from the mutation request.
|
|
34
|
+
* @throws Will throw an error if the mutation request fails or if the provided variables do not pass the validation checks.
|
|
35
|
+
*/
|
|
36
|
+
updateAniChartSettings(variables) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (!this.authToken) {
|
|
39
|
+
throw new Error('UpdateAniChartSettingsMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
40
|
+
}
|
|
41
|
+
const variableTypeMappings = {
|
|
42
|
+
titleLanguage: 'string',
|
|
43
|
+
outgoingLinkProvider: 'string',
|
|
44
|
+
theme: 'string',
|
|
45
|
+
sort: 'string'
|
|
46
|
+
};
|
|
47
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
48
|
+
const mutation = `
|
|
49
|
+
mutation ($titleLanguage: String, $outgoingLinkProvider: String, $theme: String, $sort: String) {
|
|
50
|
+
UpdateAniChartSettings (titleLanguage: $titleLanguage, outgoingLinkProvider: $outgoingLinkProvider, theme: $theme, sort: $sort)
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
const data = { query: mutation, variables };
|
|
54
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.UpdateAniChartSettingsMutation = UpdateAniChartSettingsMutation;
|