anilink-api-wrapper 1.18.6 → 1.20.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 +49 -17
- package/dist/AniLink.js +11 -2
- package/dist/apis/anilist/interfaces/Activity.js +28 -1
- package/dist/apis/anilist/mutation/DeleteCustomList.js +60 -0
- package/dist/apis/anilist/mutation/DeleteMediaListEntry.js +58 -0
- package/dist/apis/anilist/mutation/SaveMediaListEntry.js +2 -2
- package/dist/apis/anilist/mutation/SaveTextActivity.js +62 -0
- package/dist/apis/anilist/mutation/UpdateMediaListEntries.js +2 -2
- package/dist/apis/anilist/mutation/UpdateUser.js +2 -2
- package/dist/apis/anilist/query/Activity.js +2 -2
- package/dist/apis/anilist/query/ActivityReply.js +1 -1
- package/dist/apis/anilist/query/AiringSchedule.js +2 -2
- package/dist/apis/anilist/query/Character.js +20 -0
- package/dist/apis/anilist/query/ExternalLinkSourceCollection.js +10 -0
- package/dist/apis/anilist/query/Follower.js +14 -0
- package/dist/apis/anilist/query/Following.js +14 -0
- package/dist/apis/anilist/query/Markdown.js +9 -1
- package/dist/apis/anilist/query/Media.js +84 -0
- package/dist/apis/anilist/query/MediaList.js +40 -0
- package/dist/apis/anilist/query/MediaListCollection.js +32 -0
- package/dist/apis/anilist/query/MediaTagCollection.js +7 -0
- package/dist/apis/anilist/query/MediaTrend.js +34 -0
- package/dist/apis/anilist/query/Notification.js +12 -0
- package/dist/apis/anilist/query/Recommendation.js +20 -2
- package/dist/apis/anilist/query/Review.js +14 -0
- package/dist/apis/anilist/query/SiteStatistics.js +28 -0
- package/dist/apis/anilist/query/Staff.js +29 -0
- package/dist/apis/anilist/query/Studio.js +32 -0
- package/dist/apis/anilist/query/Thread.js +18 -0
- package/dist/apis/anilist/query/ThreadComment.js +13 -0
- package/dist/apis/anilist/query/User.js +18 -0
- package/dist/apis/anilist/query/Viewer.js +14 -2
- package/dist/apis/anilist/query/page/Activities.js +38 -0
- package/dist/apis/anilist/query/page/ActivityReplies.js +12 -0
- package/dist/apis/anilist/query/page/AiringSchedules.js +30 -0
- package/dist/apis/anilist/query/page/Characters.js +22 -0
- package/dist/apis/anilist/query/page/Followers.js +16 -0
- package/dist/apis/anilist/query/page/Followings.js +16 -0
- package/dist/apis/anilist/query/page/Likes.js +12 -0
- package/dist/apis/anilist/query/page/MediaLists.js +42 -0
- package/dist/apis/anilist/query/page/MediaTrends.js +36 -0
- package/dist/apis/anilist/query/page/Medias.js +86 -0
- package/dist/apis/anilist/query/page/Notifications.js +14 -0
- package/dist/apis/anilist/query/page/Recommendations.js +20 -0
- package/dist/apis/anilist/query/page/Reviews.js +16 -0
- package/dist/apis/anilist/query/page/Staffs.js +31 -0
- package/dist/apis/anilist/query/page/Studios.js +34 -0
- package/dist/apis/anilist/query/page/ThreadCommments.js +15 -0
- package/dist/apis/anilist/query/page/Threads.js +20 -0
- package/dist/apis/anilist/query/page/Users.js +20 -0
- package/dist/apis/anilist/types/Format.js +30 -0
- package/dist/apis/anilist/types/Season.js +13 -0
- package/dist/apis/anilist/types/Sort.js +240 -1
- package/dist/apis/anilist/types/Source.js +25 -0
- package/dist/apis/anilist/types/Status.js +26 -0
- package/dist/apis/anilist/types/Type.js +44 -0
- package/package.json +1 -1
- package/.eslintrc.js +0 -16
- package/.gitattributes +0 -1
package/README.md
CHANGED
|
@@ -6,12 +6,18 @@ AniLink is a TypeScript library for interacting with the AniList API. It provide
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
To install AniLink, you can use npm
|
|
9
|
+
To install AniLink, you can use npm or yarn.:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install anilink-api-wrapper
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
or
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add anilink-api-wrapper
|
|
19
|
+
```
|
|
20
|
+
|
|
15
21
|
## Initialization
|
|
16
22
|
|
|
17
23
|
### AniList
|
|
@@ -43,11 +49,13 @@ You can also initialize AniLink without an authentication token
|
|
|
43
49
|
const aniLink = new AniLink();
|
|
44
50
|
```
|
|
45
51
|
|
|
46
|
-
##
|
|
52
|
+
## AniList API
|
|
53
|
+
|
|
54
|
+
### Structure
|
|
47
55
|
|
|
48
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.
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
#### Query Methods
|
|
51
59
|
|
|
52
60
|
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.
|
|
53
61
|
|
|
@@ -100,17 +108,18 @@ List of page query methods in `anilist.query.page`:
|
|
|
100
108
|
- recommendations
|
|
101
109
|
- likes
|
|
102
110
|
|
|
103
|
-
|
|
111
|
+
#### Mutation Methods
|
|
104
112
|
|
|
105
113
|
List of methods in `anilist.mutation`:
|
|
106
114
|
|
|
107
115
|
- updateUser
|
|
108
116
|
- saveMediaListEntry
|
|
109
117
|
- updateMediaListEntries
|
|
118
|
+
- deleteMediaListEntries
|
|
119
|
+
- deleteCustomLists
|
|
120
|
+
- saveTextActivity
|
|
110
121
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
### Anilist Errors
|
|
122
|
+
### Error Handling
|
|
114
123
|
|
|
115
124
|
AniLink will throw an error if the AniList API returns an error. You can catch these errors using a try-catch block.
|
|
116
125
|
|
|
@@ -125,7 +134,7 @@ try {
|
|
|
125
134
|
|
|
126
135
|
This includes status codes and error messages returned by the AniList API. Here is an example rate limit handler to catch the errors thrown by AniLink:
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
##### Typescript
|
|
129
138
|
|
|
130
139
|
```typescript
|
|
131
140
|
async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
|
|
@@ -155,7 +164,7 @@ async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
|
|
|
155
164
|
}
|
|
156
165
|
```
|
|
157
166
|
|
|
158
|
-
|
|
167
|
+
##### Javascript
|
|
159
168
|
|
|
160
169
|
```javascript
|
|
161
170
|
async function handleRateLimit(apiCall, retryAfter = 60) {
|
|
@@ -170,7 +179,7 @@ The possible error codes returned by the AniList API are:
|
|
|
170
179
|
- 429: Too Many Requests (e.g. rate limit exceeded)
|
|
171
180
|
- 500: Internal Server Error (e.g. AniList server error)
|
|
172
181
|
|
|
173
|
-
|
|
182
|
+
#### Missing or Invalid Variables
|
|
174
183
|
|
|
175
184
|
AniLink will also throw an error if any variables are missing or invalid. For example, if you try to query a user providing a string instead of a number for ID, AniLink will throw an error. Most variables are optional however there a few that are required.
|
|
176
185
|
```typescript
|
|
@@ -188,11 +197,11 @@ Example Error Thrown:
|
|
|
188
197
|
Invalid id: 542244. Expected type: number
|
|
189
198
|
```
|
|
190
199
|
|
|
191
|
-
|
|
200
|
+
### Examples
|
|
192
201
|
|
|
193
202
|
Here are examples of how to use AniLink to interact with the AniList API:
|
|
194
203
|
|
|
195
|
-
|
|
204
|
+
#### Querying user data
|
|
196
205
|
|
|
197
206
|
```typescript
|
|
198
207
|
// Querying user data
|
|
@@ -358,7 +367,7 @@ aniLink.anilist.query.page.likes({likeableId: 723422275, type: 'ACTIVITY', asHtm
|
|
|
358
367
|
});
|
|
359
368
|
```
|
|
360
369
|
|
|
361
|
-
|
|
370
|
+
#### Mutating user data
|
|
362
371
|
|
|
363
372
|
```typescript
|
|
364
373
|
// Updating a user
|
|
@@ -374,8 +383,8 @@ aniLink.anilist.mutation.updateUser({
|
|
|
374
383
|
notificationOptions: [{type: 'AIRING', enabled: true}],
|
|
375
384
|
timezone: '-06:00',
|
|
376
385
|
activityMergeTime: 30,
|
|
377
|
-
animeListOptions: {sectionOrder: ['title'], customLists: [], advancedScoring: [], advancedScoringEnabled: false},
|
|
378
|
-
mangaListOptions: {sectionOrder: ['title'], customLists: [], advancedScoring: [], advancedScoringEnabled: false},
|
|
386
|
+
animeListOptions: {sectionOrder: ['title'], customLists: ['test'], advancedScoring: [], advancedScoringEnabled: false},
|
|
387
|
+
mangaListOptions: {sectionOrder: ['title'], customLists: ['test'], advancedScoring: [], advancedScoringEnabled: false},
|
|
379
388
|
staffNameLanguage: 'ROMAJI',
|
|
380
389
|
restrictMessagesToFollowing: false,
|
|
381
390
|
disabledListActivity: [{type: 'CURRENT', disabled: false}]
|
|
@@ -383,7 +392,7 @@ aniLink.anilist.mutation.updateUser({
|
|
|
383
392
|
|
|
384
393
|
// Saving media list entries
|
|
385
394
|
aniLink.anilist.mutation.saveMediaListEntry({
|
|
386
|
-
mediaId:
|
|
395
|
+
mediaId: 143271,
|
|
387
396
|
status: 'CURRENT',
|
|
388
397
|
score: 8.5,
|
|
389
398
|
progress: 3,
|
|
@@ -396,4 +405,27 @@ aniLink.anilist.mutation.updateMediaListEntries({
|
|
|
396
405
|
progress: 3,
|
|
397
406
|
ids: [143271, 156822, 170890],
|
|
398
407
|
});
|
|
399
|
-
|
|
408
|
+
|
|
409
|
+
// Deleting custom list
|
|
410
|
+
aniLink.anilist.mutation.deleteCustomLists({customList: 'test'});
|
|
411
|
+
|
|
412
|
+
// Deleting media list entry
|
|
413
|
+
const entryId = (
|
|
414
|
+
await handleRateLimit(() => aniLink.anilist.query.mediaList(
|
|
415
|
+
{
|
|
416
|
+
userId: 6503722,
|
|
417
|
+
mediaId: 143271
|
|
418
|
+
}
|
|
419
|
+
))).data.MediaList.id;
|
|
420
|
+
aniLink.anilist.mutation.deleteMediaListEntry({id: entryId});
|
|
421
|
+
|
|
422
|
+
// Create text activity
|
|
423
|
+
aniLink.anilist.mutation.saveTextActivity({text: 'test'})
|
|
424
|
+
|
|
425
|
+
// Update text activity
|
|
426
|
+
aniLink.anilist.mutation.saveTextActivity({id: 725254160, text: 'Updated Text'})
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## License
|
|
430
|
+
|
|
431
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
package/dist/AniLink.js
CHANGED
|
@@ -47,6 +47,9 @@ const UpdateUser_1 = require("./apis/anilist/mutation/UpdateUser");
|
|
|
47
47
|
const User_1 = require("./apis/anilist/query/User");
|
|
48
48
|
const Users_1 = require("./apis/anilist/query/page/Users");
|
|
49
49
|
const Viewer_1 = require("./apis/anilist/query/Viewer");
|
|
50
|
+
const DeleteMediaListEntry_1 = require("./apis/anilist/mutation/DeleteMediaListEntry");
|
|
51
|
+
const DeleteCustomList_1 = require("./apis/anilist/mutation/DeleteCustomList");
|
|
52
|
+
const SaveTextActivity_1 = require("./apis/anilist/mutation/SaveTextActivity");
|
|
50
53
|
/**
|
|
51
54
|
* `AniLink` is a class for interacting with the APIs.
|
|
52
55
|
* It provides methods for querying and mutating data.
|
|
@@ -103,6 +106,9 @@ class AniLink {
|
|
|
103
106
|
const updateUserMutationInstance = new UpdateUser_1.UpdateUserMutation(authToken);
|
|
104
107
|
const saveMediaListEntryMutationInstance = new SaveMediaListEntry_1.SaveMediaListEntryMutation(authToken);
|
|
105
108
|
const updateMediaListEntriesMutationInstance = new UpdateMediaListEntries_1.UpdateMediaListEntriesMutation(authToken);
|
|
109
|
+
const deleteMediaListEntryMutationInstance = new DeleteMediaListEntry_1.DeleteMediaListEntryMutation(authToken);
|
|
110
|
+
const deleteCustomListMutationInstance = new DeleteCustomList_1.DeleteCustomListMutation(authToken);
|
|
111
|
+
const saveTextActivityMutationInstance = new SaveTextActivity_1.SaveTextActivityMutation(authToken);
|
|
106
112
|
this.anilist = {
|
|
107
113
|
query: {
|
|
108
114
|
user: userQueryInstance.user.bind(userQueryInstance),
|
|
@@ -125,7 +131,7 @@ class AniLink {
|
|
|
125
131
|
follower: followerQueryInstance.follower.bind(followerQueryInstance),
|
|
126
132
|
thread: threadQueryInstance.thread.bind(threadQueryInstance),
|
|
127
133
|
threadComment: threadCommentQueryInstance.threadComment.bind(threadCommentQueryInstance),
|
|
128
|
-
recommendation: recommendationQueryInstance.
|
|
134
|
+
recommendation: recommendationQueryInstance.recommendation.bind(recommendationQueryInstance),
|
|
129
135
|
markdown: markdownQueryInstance.markdown.bind(markdownQueryInstance),
|
|
130
136
|
aniChartUser: aniChartUserQueryInstance.aniChartUser.bind(aniChartUserQueryInstance),
|
|
131
137
|
siteStatistics: siteStatisticsQueryInstance.siteStatistics.bind(siteStatisticsQueryInstance),
|
|
@@ -154,7 +160,10 @@ class AniLink {
|
|
|
154
160
|
mutation: {
|
|
155
161
|
updateUser: updateUserMutationInstance.updateUser.bind(updateUserMutationInstance),
|
|
156
162
|
saveMediaListEntry: saveMediaListEntryMutationInstance.saveMediaListEntry.bind(saveMediaListEntryMutationInstance),
|
|
157
|
-
updateMediaListEntries: updateMediaListEntriesMutationInstance.updateMediaListEntries.bind(updateMediaListEntriesMutationInstance)
|
|
163
|
+
updateMediaListEntries: updateMediaListEntriesMutationInstance.updateMediaListEntries.bind(updateMediaListEntriesMutationInstance),
|
|
164
|
+
deleteMediaListEntry: deleteMediaListEntryMutationInstance.deleteMediaListEntry.bind(deleteMediaListEntryMutationInstance),
|
|
165
|
+
deleteCustomList: deleteCustomListMutationInstance.deleteCustomList.bind(deleteCustomListMutationInstance),
|
|
166
|
+
saveTextActivity: saveTextActivityMutationInstance.saveTextActivity.bind(saveTextActivityMutationInstance)
|
|
158
167
|
}
|
|
159
168
|
};
|
|
160
169
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActivityWithRepliesSchema = exports.ActivitySchema = void 0;
|
|
3
|
+
exports.TextActivitySchema = exports.ActivityWithRepliesSchema = exports.ActivitySchema = void 0;
|
|
4
4
|
const BasicUser_1 = require("./BasicUser");
|
|
5
5
|
const ActivityReply_1 = require("./ActivityReply");
|
|
6
6
|
/**
|
|
@@ -149,3 +149,30 @@ exports.ActivityWithRepliesSchema = `
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
`;
|
|
152
|
+
/**
|
|
153
|
+
* `TextActivity` is an object representing a text activity.
|
|
154
|
+
* It includes the id, user id, type, reply count, text, site url, lock status, subscription status, like count, like status, pin status, creation date, user details, replies, and likes.
|
|
155
|
+
*/
|
|
156
|
+
exports.TextActivitySchema = `
|
|
157
|
+
id
|
|
158
|
+
userId
|
|
159
|
+
type
|
|
160
|
+
replyCount
|
|
161
|
+
text (asHtml: $asHtml)
|
|
162
|
+
siteUrl
|
|
163
|
+
isLocked
|
|
164
|
+
isSubscribed
|
|
165
|
+
likeCount
|
|
166
|
+
isLiked
|
|
167
|
+
isPinned
|
|
168
|
+
createdAt
|
|
169
|
+
user {
|
|
170
|
+
${BasicUser_1.BasicUserSchema}
|
|
171
|
+
}
|
|
172
|
+
replies {
|
|
173
|
+
${ActivityReply_1.ActivityReplySchema}
|
|
174
|
+
}
|
|
175
|
+
likes {
|
|
176
|
+
${BasicUser_1.BasicUserSchema}
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
@@ -0,0 +1,60 @@
|
|
|
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.DeleteCustomListMutation = 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 Type_1 = require("../types/Type");
|
|
17
|
+
/**
|
|
18
|
+
* `DeleteCustomListMutation` is a class representing a mutation to delete a custom list.
|
|
19
|
+
* It includes a method to delete a custom list
|
|
20
|
+
*/
|
|
21
|
+
class DeleteCustomListMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `DeleteCustomListMutation` 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
|
+
* `deleteMediaListEntry` is a method that sends a mutation request to delete a custom list.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `DeleteCustomListVariables` 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
|
+
deleteCustomList(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!variables.customList || !variables.type) {
|
|
41
|
+
throw new Error('customList & type variables are required');
|
|
42
|
+
}
|
|
43
|
+
const variableTypeMappings = {
|
|
44
|
+
customList: 'string',
|
|
45
|
+
type: Type_1.MediaTypeMappings
|
|
46
|
+
};
|
|
47
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
48
|
+
const mutation = `
|
|
49
|
+
mutation ($customList: String, $type: MediaType) {
|
|
50
|
+
DeleteCustomList(customList: $customList, type: $type) {
|
|
51
|
+
deleted
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const data = { query: mutation, variables };
|
|
56
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.DeleteCustomListMutation = DeleteCustomListMutation;
|
|
@@ -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.DeleteMediaListEntryMutation = 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
|
+
* `DeleteMediaListEntryMutation` is a class representing a mutation to delete a media list entry.
|
|
18
|
+
* It includes a method to delete a media list entry.
|
|
19
|
+
*/
|
|
20
|
+
class DeleteMediaListEntryMutation extends APIWrapper_1.APIWrapper {
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new `DeleteMediaListEntryMutation` 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
|
+
* `deleteMediaListEntry` is a method that sends a mutation request to delete a media list entry.
|
|
32
|
+
*
|
|
33
|
+
* @param variables - An object of type `DeleteMediaListEntryVariables` 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
|
+
deleteMediaListEntry(variables) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (!variables.id) {
|
|
40
|
+
throw new Error('id variable is required');
|
|
41
|
+
}
|
|
42
|
+
const variableTypeMappings = {
|
|
43
|
+
id: 'number'
|
|
44
|
+
};
|
|
45
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
46
|
+
const mutation = `
|
|
47
|
+
mutation ($id: Int) {
|
|
48
|
+
DeleteMediaListEntry(id: $id) {
|
|
49
|
+
deleted
|
|
50
|
+
}
|
|
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.DeleteMediaListEntryMutation = DeleteMediaListEntryMutation;
|
|
@@ -13,9 +13,9 @@ exports.SaveMediaListEntryMutation = void 0;
|
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
15
|
const FuzzyDate_1 = require("../interfaces/FuzzyDate");
|
|
16
|
-
const MediaListStatus_1 = require("../types/MediaListStatus");
|
|
17
16
|
const FuzzyDate_2 = require("../types/FuzzyDate");
|
|
18
17
|
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
18
|
+
const Status_1 = require("../types/Status");
|
|
19
19
|
/**
|
|
20
20
|
* `SaveMediaListEntryMutation` is a class representing a mutation to save a media list entry.
|
|
21
21
|
* It includes a method to save a media list entry.
|
|
@@ -45,7 +45,7 @@ class SaveMediaListEntryMutation extends APIWrapper_1.APIWrapper {
|
|
|
45
45
|
const variableTypeMappings = {
|
|
46
46
|
id: 'number',
|
|
47
47
|
mediaId: 'number',
|
|
48
|
-
status:
|
|
48
|
+
status: Status_1.MediaListStatusMappings,
|
|
49
49
|
score: 'number',
|
|
50
50
|
scoreRaw: 'number',
|
|
51
51
|
progress: 'number',
|
|
@@ -0,0 +1,62 @@
|
|
|
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.SaveTextActivityMutation = 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 Activity_1 = require("../interfaces/Activity");
|
|
17
|
+
/**
|
|
18
|
+
* `SaveTextActivityMutation` is a class representing a mutation to save a text activity.
|
|
19
|
+
* It includes a method to save a text activity
|
|
20
|
+
*/
|
|
21
|
+
class SaveTextActivityMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `SaveTextActivityMutation` 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
|
+
* `saveTextActivity` is a method that sends a mutation request to save a text activity.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `SaveTextActivityVariables` 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
|
+
saveTextActivity(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!variables.id && !variables.text) {
|
|
41
|
+
throw new Error('id or text variable is required');
|
|
42
|
+
}
|
|
43
|
+
const variableTypeMappings = {
|
|
44
|
+
id: 'number',
|
|
45
|
+
text: 'string',
|
|
46
|
+
locked: 'boolean',
|
|
47
|
+
asHtml: 'boolean'
|
|
48
|
+
};
|
|
49
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
50
|
+
const mutation = `
|
|
51
|
+
mutation ($id: Int, $text: String, $locked: Boolean, $asHtml: Boolean) {
|
|
52
|
+
SaveTextActivity(id: $id, text: $text, locked:$locked) {
|
|
53
|
+
${Activity_1.TextActivitySchema}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
const data = { query: mutation, variables };
|
|
58
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.SaveTextActivityMutation = SaveTextActivityMutation;
|
|
@@ -13,9 +13,9 @@ exports.UpdateMediaListEntriesMutation = void 0;
|
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
15
|
const FuzzyDate_1 = require("../interfaces/FuzzyDate");
|
|
16
|
-
const MediaListStatus_1 = require("../types/MediaListStatus");
|
|
17
16
|
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
18
17
|
const FuzzyDate_2 = require("../types/FuzzyDate");
|
|
18
|
+
const Status_1 = require("../types/Status");
|
|
19
19
|
/**
|
|
20
20
|
* `UpdateMediaListEntriesMutation` is a class representing a mutation to update media list entries.
|
|
21
21
|
* It includes a method to update media list entries.
|
|
@@ -43,7 +43,7 @@ class UpdateMediaListEntriesMutation extends APIWrapper_1.APIWrapper {
|
|
|
43
43
|
throw new Error('ids must be an array of at least one number');
|
|
44
44
|
}
|
|
45
45
|
const variableTypeMappings = {
|
|
46
|
-
status:
|
|
46
|
+
status: Status_1.MediaListStatusMappings,
|
|
47
47
|
score: 'number',
|
|
48
48
|
scoreRaw: 'number',
|
|
49
49
|
progress: 'number',
|
|
@@ -12,13 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.UpdateUserMutation = void 0;
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
-
const ScoreFormat_1 = require("../types/ScoreFormat");
|
|
16
15
|
const UserStaffNameLanguage_1 = require("../types/UserStaffNameLanguage");
|
|
17
16
|
const UserTitleLanguage_1 = require("../types/UserTitleLanguage");
|
|
18
17
|
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
19
18
|
const NotificationOptions_1 = require("../types/NotificationOptions");
|
|
20
19
|
const MediaListOptions_1 = require("../types/MediaListOptions");
|
|
21
20
|
const DisabledListActivity_1 = require("../types/DisabledListActivity");
|
|
21
|
+
const Format_1 = require("../types/Format");
|
|
22
22
|
/**
|
|
23
23
|
* `UpdateUserMutation` is a class representing a mutation to update a user.
|
|
24
24
|
* It includes a method to update a user.
|
|
@@ -47,7 +47,7 @@ class UpdateUserMutation extends APIWrapper_1.APIWrapper {
|
|
|
47
47
|
titleLanguage: UserTitleLanguage_1.UserTitleLanguageMapping,
|
|
48
48
|
displayAdultContent: 'boolean',
|
|
49
49
|
airingNotifications: 'boolean',
|
|
50
|
-
scoreFormat:
|
|
50
|
+
scoreFormat: Format_1.ScoreFormatMapping,
|
|
51
51
|
rowOrder: 'string',
|
|
52
52
|
profileColor: 'string',
|
|
53
53
|
donatorBadge: 'string',
|
|
@@ -38,8 +38,8 @@ class ActivityQuery extends APIWrapper_1.APIWrapper {
|
|
|
38
38
|
*/
|
|
39
39
|
activity(variables) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
if (variables
|
|
42
|
-
throw new Error('
|
|
41
|
+
if (!variables) {
|
|
42
|
+
throw new Error('At least one variable must be set');
|
|
43
43
|
}
|
|
44
44
|
const variableTypeMappings = {
|
|
45
45
|
id: 'number',
|
|
@@ -36,7 +36,7 @@ class ActivityReplyQuery extends APIWrapper_1.APIWrapper {
|
|
|
36
36
|
*/
|
|
37
37
|
activityReply(variables) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (variables.id
|
|
39
|
+
if (!variables.id) {
|
|
40
40
|
throw new Error('The id is required');
|
|
41
41
|
}
|
|
42
42
|
const variableTypeMappings = {
|
|
@@ -37,8 +37,8 @@ class AiringScheduleQuery extends APIWrapper_1.APIWrapper {
|
|
|
37
37
|
*/
|
|
38
38
|
airingSchedule(variables) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!variables
|
|
41
|
-
throw new Error('
|
|
40
|
+
if (!variables) {
|
|
41
|
+
throw new Error('At least one variable must be set');
|
|
42
42
|
}
|
|
43
43
|
const variableTypeMappings = {
|
|
44
44
|
id: 'number',
|
|
@@ -13,6 +13,8 @@ exports.CharacterQuery = void 0;
|
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
15
|
const Character_1 = require("../interfaces/responses/query/Character");
|
|
16
|
+
const Sort_1 = require("../types/Sort");
|
|
17
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
18
|
/**
|
|
17
19
|
* `CharacterQuery` is a class representing a query for characters.
|
|
18
20
|
* It includes a method to get characters.
|
|
@@ -35,6 +37,24 @@ class CharacterQuery extends APIWrapper_1.APIWrapper {
|
|
|
35
37
|
*/
|
|
36
38
|
character(variables) {
|
|
37
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!variables) {
|
|
41
|
+
throw new Error('At least one variable must be set');
|
|
42
|
+
}
|
|
43
|
+
const variableTypeMappings = {
|
|
44
|
+
id: 'number',
|
|
45
|
+
isBirthday: 'boolean',
|
|
46
|
+
search: 'string',
|
|
47
|
+
id_not: 'number',
|
|
48
|
+
id_in: 'number[]',
|
|
49
|
+
id_not_in: 'number[]',
|
|
50
|
+
sort: Sort_1.CharacterSortMappings,
|
|
51
|
+
asHtml: 'boolean',
|
|
52
|
+
mediaSort: Sort_1.MediaSortMappings,
|
|
53
|
+
mediaOnList: 'boolean',
|
|
54
|
+
mediaPage: 'number',
|
|
55
|
+
mediaPerPage: 'number'
|
|
56
|
+
};
|
|
57
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
38
58
|
const query = `
|
|
39
59
|
query ($id: Int, $isBirthday: Boolean, $search: String, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $sort: [CharacterSort], $asHtml: Boolean, $mediaSort: [MediaSort], $mediaOnList: Boolean, $mediaPage: Int, $mediaPerPage: Int) {
|
|
40
60
|
Character (id: $id, isBirthday: $isBirthday, search: $search, id_not: $id_not, id_in: $id_in, id_not_in: $id_not_in, sort: $sort) {
|
|
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ExternalLinkSourceCollectionQuery = void 0;
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
|
+
const Type_1 = require("../types/Type");
|
|
15
17
|
/**
|
|
16
18
|
* `ExternalLinkSourceCollectionQuery` is a class representing a query for external link source collections.
|
|
17
19
|
* It includes a method to get external link source collections.
|
|
@@ -34,6 +36,14 @@ class ExternalLinkSourceCollectionQuery extends APIWrapper_1.APIWrapper {
|
|
|
34
36
|
*/
|
|
35
37
|
externalLinkSourceCollection() {
|
|
36
38
|
return __awaiter(this, arguments, void 0, function* (variables = {}) {
|
|
39
|
+
const variableTypeMappings = {
|
|
40
|
+
id: 'number',
|
|
41
|
+
type: 'string',
|
|
42
|
+
mediaType: Type_1.MediaTypeMappings
|
|
43
|
+
};
|
|
44
|
+
if (Object(variables).length > 0) {
|
|
45
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
46
|
+
}
|
|
37
47
|
const query = `
|
|
38
48
|
query ($id: Int, $type: ExternalLinkType, $mediaType: ExternalLinkMediaType) {
|
|
39
49
|
ExternalLinkSourceCollection (id: $id, type: $type, mediaType: $mediaType) {
|
|
@@ -13,6 +13,8 @@ exports.FollowerQuery = void 0;
|
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
15
|
const User_1 = require("../interfaces/responses/query/User");
|
|
16
|
+
const Sort_1 = require("../types/Sort");
|
|
17
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
18
|
/**
|
|
17
19
|
* `FollowerQuery` is a class representing a query for followers.
|
|
18
20
|
* It includes a method to get followers.
|
|
@@ -35,6 +37,18 @@ class FollowerQuery extends APIWrapper_1.APIWrapper {
|
|
|
35
37
|
*/
|
|
36
38
|
follower(variables) {
|
|
37
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!variables.userId) {
|
|
41
|
+
throw new Error('userId is required');
|
|
42
|
+
}
|
|
43
|
+
const variableTypeMappings = {
|
|
44
|
+
userId: 'number',
|
|
45
|
+
sort: Sort_1.UserSortMappings,
|
|
46
|
+
animeStatLimit: 'number',
|
|
47
|
+
mangaStatLimit: 'number',
|
|
48
|
+
animeStatSort: Sort_1.UserStatisticSortMappings,
|
|
49
|
+
mangaStatSort: Sort_1.UserStatisticSortMappings
|
|
50
|
+
};
|
|
51
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
38
52
|
const query = `
|
|
39
53
|
query ($userId: Int!, $sort: [UserSort], $asHtml: Boolean, $animeStatLimit: Int, $mangaStatLimit: Int, $animeStatSort: [UserStatisticsSort], $mangaStatSort: [UserStatisticsSort]) {
|
|
40
54
|
Follower (userId: $userId, sort: $sort) {
|
|
@@ -13,6 +13,8 @@ exports.FollowingQuery = void 0;
|
|
|
13
13
|
const APIWrapper_1 = require("../../../base/APIWrapper");
|
|
14
14
|
const RequestHandler_1 = require("../../../base/RequestHandler");
|
|
15
15
|
const User_1 = require("../interfaces/responses/query/User");
|
|
16
|
+
const Sort_1 = require("../types/Sort");
|
|
17
|
+
const ValidateVariables_1 = require("../../../base/ValidateVariables");
|
|
16
18
|
/**
|
|
17
19
|
* `FollowingQuery` is a class representing a query for following users.
|
|
18
20
|
* It includes a method to get following users.
|
|
@@ -35,6 +37,18 @@ class FollowingQuery extends APIWrapper_1.APIWrapper {
|
|
|
35
37
|
*/
|
|
36
38
|
following(variables) {
|
|
37
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!variables.userId) {
|
|
41
|
+
throw new Error('userId is required');
|
|
42
|
+
}
|
|
43
|
+
const variableTypeMappings = {
|
|
44
|
+
userId: 'number',
|
|
45
|
+
sort: Sort_1.UserSortMappings,
|
|
46
|
+
animeStatLimit: 'number',
|
|
47
|
+
mangaStatLimit: 'number',
|
|
48
|
+
animeStatSort: Sort_1.UserStatisticSortMappings,
|
|
49
|
+
mangaStatSort: Sort_1.UserStatisticSortMappings
|
|
50
|
+
};
|
|
51
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
38
52
|
const query = `
|
|
39
53
|
query ($userId: Int!, $sort: [UserSort], $asHtml: Boolean, $animeStatLimit: Int, $mangaStatLimit: Int, $animeStatSort: [UserStatisticsSort], $mangaStatSort: [UserStatisticsSort]) {
|
|
40
54
|
Following (userId: $userId, sort: $sort) {
|