anilink-api-wrapper 1.19.0 → 1.21.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/Examples/ANILIST_API_EXAMPLES.md +253 -0
- package/README.md +18 -215
- package/dist/AniLink.js +28 -3
- package/dist/apis/anilist/interfaces/Activity.js +94 -1
- package/dist/apis/anilist/mutation/DeleteActivity.js +61 -0
- package/dist/apis/anilist/mutation/DeleteCustomList.js +63 -0
- package/dist/apis/anilist/mutation/DeleteMediaListEntry.js +61 -0
- package/dist/apis/anilist/mutation/SaveListActivity.js +64 -0
- package/dist/apis/anilist/mutation/SaveMediaListEntry.js +3 -0
- package/dist/apis/anilist/mutation/SaveMessageActivity.js +68 -0
- package/dist/apis/anilist/mutation/SaveTextActivity.js +65 -0
- package/dist/apis/anilist/mutation/UpdateMediaListEntries.js +3 -0
- package/dist/apis/anilist/mutation/UpdateUser.js +3 -0
- package/dist/apis/anilist/query/AniChartUser.js +3 -3
- package/dist/apis/anilist/query/Notification.js +3 -0
- package/dist/apis/anilist/query/Viewer.js +3 -0
- package/package.json +9 -3
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
Here are examples of how to use AniLink to interact with the AniList API:
|
|
4
|
+
|
|
5
|
+
### Querying user data
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// Querying user data
|
|
9
|
+
aniLink.anilist.query.user({id: 542244, isHTML: true});
|
|
10
|
+
|
|
11
|
+
// Querying media data
|
|
12
|
+
aniLink.anilist.query.media({id: 1, type: 'ANIME'});
|
|
13
|
+
|
|
14
|
+
// Querying media trend data
|
|
15
|
+
aniLink.anilist.query.mediaTrend({mediaId: 1, type: 'ANIME'});
|
|
16
|
+
|
|
17
|
+
// Querying airing schedule data
|
|
18
|
+
aniLink.anilist.query.airingSchedule({mediaId: 130590});
|
|
19
|
+
|
|
20
|
+
// Querying character data
|
|
21
|
+
aniLink.anilist.query.character({
|
|
22
|
+
id: 1,
|
|
23
|
+
asHtml: true,
|
|
24
|
+
mediaSort: ['POPULARITY_DESC'],
|
|
25
|
+
mediaType: 'ANIME',
|
|
26
|
+
mediaOnList: true,
|
|
27
|
+
mediaPage: 1,
|
|
28
|
+
mediaPerPage: 10
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Querying staff data
|
|
32
|
+
aniLink.anilist.query.staff({
|
|
33
|
+
id: 132186,
|
|
34
|
+
asHtml: true,
|
|
35
|
+
staffMediaSort: ['POPULARITY_DESC'],
|
|
36
|
+
staffMediaType: 'ANIME',
|
|
37
|
+
staffMediaOnList: true,
|
|
38
|
+
staffMediaPage: 1,
|
|
39
|
+
staffMediaPerPage: 10,
|
|
40
|
+
charactersSort: ['ID'],
|
|
41
|
+
charactersPage: 1,
|
|
42
|
+
charactersPerPage: 10,
|
|
43
|
+
characterMediaSort: ['POPULARITY_DESC'],
|
|
44
|
+
characterMediaOnList: true,
|
|
45
|
+
characterMediaPage: 1,
|
|
46
|
+
characterMediaPerPage: 10
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Querying media list data
|
|
50
|
+
aniLink.anilist.query.mediaList({userId: 542244});
|
|
51
|
+
|
|
52
|
+
// Querying media list collection data
|
|
53
|
+
aniLink.anilist.query.mediaListCollection({
|
|
54
|
+
userId: 542244,
|
|
55
|
+
type: 'ANIME',
|
|
56
|
+
status: 'COMPLETED',
|
|
57
|
+
chunk: 1,
|
|
58
|
+
perChunk: 10000
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Querying genre collection data
|
|
62
|
+
aniLink.anilist.query.genreCollection();
|
|
63
|
+
|
|
64
|
+
// Querying media tag collection data
|
|
65
|
+
aniLink.anilist.query.mediaTagCollection();
|
|
66
|
+
|
|
67
|
+
// Querying viewer data
|
|
68
|
+
aniLink.anilist.query.viewer({isHTML: true});
|
|
69
|
+
|
|
70
|
+
// Querying notification data
|
|
71
|
+
aniLink.anilist.query.notification({asHtml: true});
|
|
72
|
+
|
|
73
|
+
// Querying studio data
|
|
74
|
+
aniLink.anilist.query.studio({id: 561, asHtml: true});
|
|
75
|
+
|
|
76
|
+
// Querying review data
|
|
77
|
+
aniLink.anilist.query.review({id: 8008, asHtml: true});
|
|
78
|
+
|
|
79
|
+
// Querying activity data
|
|
80
|
+
aniLink.anilist.query.activity({id: 723235883, asHtml: true});
|
|
81
|
+
|
|
82
|
+
// Querying activity reply data
|
|
83
|
+
aniLink.anilist.query.activityReply({id: 12191046, asHtml: true});
|
|
84
|
+
|
|
85
|
+
// Querying following data
|
|
86
|
+
aniLink.anilist.query.following({userId: 542244, asHtml: true});
|
|
87
|
+
|
|
88
|
+
// Querying follower data
|
|
89
|
+
aniLink.anilist.query.follower({userId: 542244, asHtml: true});
|
|
90
|
+
|
|
91
|
+
// Querying thread data
|
|
92
|
+
aniLink.anilist.query.thread({id: 71881, asHtml: true});
|
|
93
|
+
|
|
94
|
+
// Querying thread comment data
|
|
95
|
+
aniLink.anilist.query.threadComment({id: 2555166, asHtml: true});
|
|
96
|
+
|
|
97
|
+
// Querying recommendation data
|
|
98
|
+
aniLink.anilist.query.recommendation({mediaId: 156822, asHtml: true});
|
|
99
|
+
|
|
100
|
+
// Querying markdown data
|
|
101
|
+
aniLink.anilist.query.markdown({markdown: 'Hello'});
|
|
102
|
+
|
|
103
|
+
// Querying AniChartUser data
|
|
104
|
+
aniLink.anilist.query.aniChartUser();
|
|
105
|
+
|
|
106
|
+
// Querying site statistics data
|
|
107
|
+
aniLink.anilist.query.siteStatistics();
|
|
108
|
+
|
|
109
|
+
// Querying external link source collection data
|
|
110
|
+
aniLink.anilist.query.externalLinkSourceCollection();
|
|
111
|
+
|
|
112
|
+
// Querying users page data
|
|
113
|
+
aniLink.anilist.query.page.users({id: 542244, isHTML: true});
|
|
114
|
+
|
|
115
|
+
// Querying media page data
|
|
116
|
+
aniLink.anilist.query.page.medias({id: 1, type: 'ANIME'});
|
|
117
|
+
|
|
118
|
+
// Querying character page data
|
|
119
|
+
aniLink.anilist.query.page.characters({id: 1, asHtml: true});
|
|
120
|
+
|
|
121
|
+
// Querying staff page data
|
|
122
|
+
aniLink.anilist.query.page.staffs({id: 132186, asHtml: true});
|
|
123
|
+
|
|
124
|
+
// Querying studio page data
|
|
125
|
+
aniLink.anilist.query.page.studios({id: 561, asHtml: true});
|
|
126
|
+
|
|
127
|
+
// Querying media list page data
|
|
128
|
+
aniLink.anilist.query.page.mediaLists({userId: 542244});
|
|
129
|
+
|
|
130
|
+
// Querying airing schedule page data
|
|
131
|
+
aniLink.anilist.query.page.airingSchedules({mediaId: 130590});
|
|
132
|
+
|
|
133
|
+
// Querying media trend page data
|
|
134
|
+
aniLink.anilist.query.page.mediaTrends({mediaId: 1, type: 'ANIME'});
|
|
135
|
+
|
|
136
|
+
// Querying notification page data
|
|
137
|
+
aniLink.anilist.query.page.notifications({asHtml: true});
|
|
138
|
+
|
|
139
|
+
// Querying follower page data
|
|
140
|
+
aniLink.anilist.query.page.followers({userId: 542244, asHtml: true});
|
|
141
|
+
|
|
142
|
+
// Querying following page data
|
|
143
|
+
aniLink.anilist.query.page.following({userId: 542244, asHtml: true});
|
|
144
|
+
|
|
145
|
+
// Querying activity page data
|
|
146
|
+
aniLink.anilist.query.page.activities({id: 723235883, asHtml: true});
|
|
147
|
+
|
|
148
|
+
// Querying activity reply page data
|
|
149
|
+
aniLink.anilist.query.page.activityReplies({id: 12191046, asHtml: true
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Querying thread page data
|
|
153
|
+
aniLink.anilist.query.page.threads({id: 71881, asHtml: true});
|
|
154
|
+
|
|
155
|
+
// Querying thread comment page data
|
|
156
|
+
aniLink.anilist.query.page.threadComments({threadId: 71881, asHtml: true
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Querying review page data
|
|
160
|
+
aniLink.anilist.query.page.reviews({id: 8008, asHtml: true});
|
|
161
|
+
|
|
162
|
+
// Querying recommendation page data
|
|
163
|
+
aniLink.anilist.query.page.recommendations({mediaId: 156822, asHtml: true
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Querying likes page data
|
|
167
|
+
aniLink.anilist.query.page.likes({likeableId: 723422275, type: 'ACTIVITY', asHtml: true
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Mutating user data
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
// Updating a user
|
|
175
|
+
aniLink.anilist.mutation.updateUser({
|
|
176
|
+
about: 'New about text',
|
|
177
|
+
titleLanguage: 'ENGLISH',
|
|
178
|
+
displayAdultContent: true,
|
|
179
|
+
airingNotifications: true,
|
|
180
|
+
scoreFormat: 'POINT_10',
|
|
181
|
+
rowOrder: 'title',
|
|
182
|
+
profileColor: 'blue',
|
|
183
|
+
donatorBadge: 'Supporter',
|
|
184
|
+
notificationOptions: [{type: 'AIRING', enabled: true}],
|
|
185
|
+
timezone: '-06:00',
|
|
186
|
+
activityMergeTime: 30,
|
|
187
|
+
animeListOptions: {sectionOrder: ['title'], customLists: ['test'], advancedScoring: [], advancedScoringEnabled: false},
|
|
188
|
+
mangaListOptions: {sectionOrder: ['title'], customLists: ['test'], advancedScoring: [], advancedScoringEnabled: false},
|
|
189
|
+
staffNameLanguage: 'ROMAJI',
|
|
190
|
+
restrictMessagesToFollowing: false,
|
|
191
|
+
disabledListActivity: [{type: 'CURRENT', disabled: false}]
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Saving media list entries
|
|
195
|
+
aniLink.anilist.mutation.saveMediaListEntry({
|
|
196
|
+
mediaId: 143271,
|
|
197
|
+
status: 'CURRENT',
|
|
198
|
+
score: 8.5,
|
|
199
|
+
progress: 3,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// Updating media list entries
|
|
203
|
+
aniLink.anilist.mutation.updateMediaListEntries({
|
|
204
|
+
status: 'CURRENT',
|
|
205
|
+
score: 8.5,
|
|
206
|
+
progress: 3,
|
|
207
|
+
ids: [143271, 156822, 170890],
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Deleting media list entry
|
|
211
|
+
const entryId = (
|
|
212
|
+
await handleRateLimit(() => aniLink.anilist.query.mediaList(
|
|
213
|
+
{
|
|
214
|
+
userId: 6503722,
|
|
215
|
+
mediaId: 143271
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
).data.MediaList.id;
|
|
220
|
+
aniLink.anilist.mutation.deleteMediaListEntry({id: entryId});
|
|
221
|
+
|
|
222
|
+
// Deleting custom list
|
|
223
|
+
aniLink.anilist.mutation.deleteCustomLists({customList: 'test'});
|
|
224
|
+
|
|
225
|
+
// Create text activity
|
|
226
|
+
aniLink.anilist.mutation.saveTextActivity({text: 'test'})
|
|
227
|
+
|
|
228
|
+
// Update text activity
|
|
229
|
+
aniLink.anilist.mutation.saveTextActivity({id: 725254160, text: 'Updated Text'})
|
|
230
|
+
|
|
231
|
+
// Create message activity
|
|
232
|
+
aniLink.anilist.mutation.saveMessageActivity({recipientId: 542244, message: 'test'})
|
|
233
|
+
|
|
234
|
+
// Update message activity
|
|
235
|
+
aniLink.anilist.mutation.saveMessageActivity({id: 725254160, message: 'Updated Message'})
|
|
236
|
+
|
|
237
|
+
// Update list activity
|
|
238
|
+
// Mod only
|
|
239
|
+
aniLink.anilist.mutation.saveListActivity({id: 725254160})
|
|
240
|
+
|
|
241
|
+
// Delete Activity
|
|
242
|
+
const activityId = (
|
|
243
|
+
await handleRateLimit(() => aniLink.anilist.query.activity(
|
|
244
|
+
{
|
|
245
|
+
userId: 542244,
|
|
246
|
+
messengerId: 6503722,
|
|
247
|
+
type: 'MESSAGE'
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
).data.Activity.id
|
|
252
|
+
const response = await handleRateLimit(() => aniLink.anilist.mutation.deleteActivity({id: activityId}))
|
|
253
|
+
```
|
package/README.md
CHANGED
|
@@ -49,11 +49,13 @@ You can also initialize AniLink without an authentication token
|
|
|
49
49
|
const aniLink = new AniLink();
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## AniList API
|
|
53
|
+
|
|
54
|
+
### Structure
|
|
53
55
|
|
|
54
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.
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
#### Query Methods
|
|
57
59
|
|
|
58
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.
|
|
59
61
|
|
|
@@ -106,17 +108,20 @@ List of page query methods in `anilist.query.page`:
|
|
|
106
108
|
- recommendations
|
|
107
109
|
- likes
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
#### Mutation Methods
|
|
110
112
|
|
|
111
113
|
List of methods in `anilist.mutation`:
|
|
112
114
|
|
|
113
115
|
- updateUser
|
|
114
116
|
- saveMediaListEntry
|
|
115
117
|
- updateMediaListEntries
|
|
118
|
+
- deleteMediaListEntries
|
|
119
|
+
- deleteCustomLists
|
|
120
|
+
- saveTextActivity
|
|
121
|
+
- saveMessageActivity
|
|
122
|
+
- deleteActivity
|
|
116
123
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
### Anilist Errors
|
|
124
|
+
### Error Handling
|
|
120
125
|
|
|
121
126
|
AniLink will throw an error if the AniList API returns an error. You can catch these errors using a try-catch block.
|
|
122
127
|
|
|
@@ -131,7 +136,7 @@ try {
|
|
|
131
136
|
|
|
132
137
|
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:
|
|
133
138
|
|
|
134
|
-
|
|
139
|
+
##### Typescript
|
|
135
140
|
|
|
136
141
|
```typescript
|
|
137
142
|
async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
|
|
@@ -161,7 +166,7 @@ async function handleRateLimit(apiCall: () => Promise<any>, retryAfter = 60) {
|
|
|
161
166
|
}
|
|
162
167
|
```
|
|
163
168
|
|
|
164
|
-
|
|
169
|
+
##### Javascript
|
|
165
170
|
|
|
166
171
|
```javascript
|
|
167
172
|
async function handleRateLimit(apiCall, retryAfter = 60) {
|
|
@@ -176,7 +181,7 @@ The possible error codes returned by the AniList API are:
|
|
|
176
181
|
- 429: Too Many Requests (e.g. rate limit exceeded)
|
|
177
182
|
- 500: Internal Server Error (e.g. AniList server error)
|
|
178
183
|
|
|
179
|
-
|
|
184
|
+
#### Missing or Invalid Variables
|
|
180
185
|
|
|
181
186
|
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.
|
|
182
187
|
```typescript
|
|
@@ -194,212 +199,10 @@ Example Error Thrown:
|
|
|
194
199
|
Invalid id: 542244. Expected type: number
|
|
195
200
|
```
|
|
196
201
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
Here are examples of how to use AniLink to interact with the AniList API:
|
|
200
|
-
|
|
201
|
-
### Querying user data
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
// Querying user data
|
|
205
|
-
aniLink.anilist.query.user({id: 542244, isHTML: true});
|
|
206
|
-
|
|
207
|
-
// Querying media data
|
|
208
|
-
aniLink.anilist.query.media({id: 1, type: 'ANIME'});
|
|
209
|
-
|
|
210
|
-
// Querying media trend data
|
|
211
|
-
aniLink.anilist.query.mediaTrend({mediaId: 1, type: 'ANIME'});
|
|
212
|
-
|
|
213
|
-
// Querying airing schedule data
|
|
214
|
-
aniLink.anilist.query.airingSchedule({mediaId: 130590});
|
|
215
|
-
|
|
216
|
-
// Querying character data
|
|
217
|
-
aniLink.anilist.query.character({
|
|
218
|
-
id: 1,
|
|
219
|
-
asHtml: true,
|
|
220
|
-
mediaSort: ['POPULARITY_DESC'],
|
|
221
|
-
mediaType: 'ANIME',
|
|
222
|
-
mediaOnList: true,
|
|
223
|
-
mediaPage: 1,
|
|
224
|
-
mediaPerPage: 10
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Querying staff data
|
|
228
|
-
aniLink.anilist.query.staff({
|
|
229
|
-
id: 132186,
|
|
230
|
-
asHtml: true,
|
|
231
|
-
staffMediaSort: ['POPULARITY_DESC'],
|
|
232
|
-
staffMediaType: 'ANIME',
|
|
233
|
-
staffMediaOnList: true,
|
|
234
|
-
staffMediaPage: 1,
|
|
235
|
-
staffMediaPerPage: 10,
|
|
236
|
-
charactersSort: ['ID'],
|
|
237
|
-
charactersPage: 1,
|
|
238
|
-
charactersPerPage: 10,
|
|
239
|
-
characterMediaSort: ['POPULARITY_DESC'],
|
|
240
|
-
characterMediaOnList: true,
|
|
241
|
-
characterMediaPage: 1,
|
|
242
|
-
characterMediaPerPage: 10
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// Querying media list data
|
|
246
|
-
aniLink.anilist.query.mediaList({userId: 542244});
|
|
247
|
-
|
|
248
|
-
// Querying media list collection data
|
|
249
|
-
aniLink.anilist.query.mediaListCollection({
|
|
250
|
-
userId: 542244,
|
|
251
|
-
type: 'ANIME',
|
|
252
|
-
status: 'COMPLETED',
|
|
253
|
-
chunk: 1,
|
|
254
|
-
perChunk: 10000
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Querying genre collection data
|
|
258
|
-
aniLink.anilist.query.genreCollection();
|
|
259
|
-
|
|
260
|
-
// Querying media tag collection data
|
|
261
|
-
aniLink.anilist.query.mediaTagCollection();
|
|
262
|
-
|
|
263
|
-
// Querying viewer data
|
|
264
|
-
aniLink.anilist.query.viewer({isHTML: true});
|
|
265
|
-
|
|
266
|
-
// Querying notification data
|
|
267
|
-
aniLink.anilist.query.notification({asHtml: true});
|
|
268
|
-
|
|
269
|
-
// Querying studio data
|
|
270
|
-
aniLink.anilist.query.studio({id: 561, asHtml: true});
|
|
271
|
-
|
|
272
|
-
// Querying review data
|
|
273
|
-
aniLink.anilist.query.review({id: 8008, asHtml: true});
|
|
274
|
-
|
|
275
|
-
// Querying activity data
|
|
276
|
-
aniLink.anilist.query.activity({id: 723235883, asHtml: true});
|
|
277
|
-
|
|
278
|
-
// Querying activity reply data
|
|
279
|
-
aniLink.anilist.query.activityReply({id: 12191046, asHtml: true});
|
|
280
|
-
|
|
281
|
-
// Querying following data
|
|
282
|
-
aniLink.anilist.query.following({userId: 542244, asHtml: true});
|
|
283
|
-
|
|
284
|
-
// Querying follower data
|
|
285
|
-
aniLink.anilist.query.follower({userId: 542244, asHtml: true});
|
|
286
|
-
|
|
287
|
-
// Querying thread data
|
|
288
|
-
aniLink.anilist.query.thread({id: 71881, asHtml: true});
|
|
289
|
-
|
|
290
|
-
// Querying thread comment data
|
|
291
|
-
aniLink.anilist.query.threadComment({id: 2555166, asHtml: true});
|
|
292
|
-
|
|
293
|
-
// Querying recommendation data
|
|
294
|
-
aniLink.anilist.query.recommendation({mediaId: 156822, asHtml: true});
|
|
202
|
+
### Examples
|
|
295
203
|
|
|
296
|
-
|
|
297
|
-
aniLink.anilist.query.markdown({markdown: 'Hello'});
|
|
204
|
+
See the [ANILIST_API_EXAMPLES](https://github.com/RLAlpha49/AniLink/blob/master/Examples/ANILIST_API_EXAMPLES.md) for examples of how to use AniLink to interact with the AniList API.
|
|
298
205
|
|
|
299
|
-
|
|
300
|
-
aniLink.anilist.query.aniChartUser();
|
|
206
|
+
## License
|
|
301
207
|
|
|
302
|
-
|
|
303
|
-
aniLink.anilist.query.siteStatistics();
|
|
304
|
-
|
|
305
|
-
// Querying external link source collection data
|
|
306
|
-
aniLink.anilist.query.externalLinkSourceCollection();
|
|
307
|
-
|
|
308
|
-
// Querying users page data
|
|
309
|
-
aniLink.anilist.query.page.users({id: 542244, isHTML: true});
|
|
310
|
-
|
|
311
|
-
// Querying media page data
|
|
312
|
-
aniLink.anilist.query.page.medias({id: 1, type: 'ANIME'});
|
|
313
|
-
|
|
314
|
-
// Querying character page data
|
|
315
|
-
aniLink.anilist.query.page.characters({id: 1, asHtml: true});
|
|
316
|
-
|
|
317
|
-
// Querying staff page data
|
|
318
|
-
aniLink.anilist.query.page.staffs({id: 132186, asHtml: true});
|
|
319
|
-
|
|
320
|
-
// Querying studio page data
|
|
321
|
-
aniLink.anilist.query.page.studios({id: 561, asHtml: true});
|
|
322
|
-
|
|
323
|
-
// Querying media list page data
|
|
324
|
-
aniLink.anilist.query.page.mediaLists({userId: 542244});
|
|
325
|
-
|
|
326
|
-
// Querying airing schedule page data
|
|
327
|
-
aniLink.anilist.query.page.airingSchedules({mediaId: 130590});
|
|
328
|
-
|
|
329
|
-
// Querying media trend page data
|
|
330
|
-
aniLink.anilist.query.page.mediaTrends({mediaId: 1, type: 'ANIME'});
|
|
331
|
-
|
|
332
|
-
// Querying notification page data
|
|
333
|
-
aniLink.anilist.query.page.notifications({asHtml: true});
|
|
334
|
-
|
|
335
|
-
// Querying follower page data
|
|
336
|
-
aniLink.anilist.query.page.followers({userId: 542244, asHtml: true});
|
|
337
|
-
|
|
338
|
-
// Querying following page data
|
|
339
|
-
aniLink.anilist.query.page.following({userId: 542244, asHtml: true});
|
|
340
|
-
|
|
341
|
-
// Querying activity page data
|
|
342
|
-
aniLink.anilist.query.page.activities({id: 723235883, asHtml: true});
|
|
343
|
-
|
|
344
|
-
// Querying activity reply page data
|
|
345
|
-
aniLink.anilist.query.page.activityReplies({id: 12191046, asHtml: true
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// Querying thread page data
|
|
349
|
-
aniLink.anilist.query.page.threads({id: 71881, asHtml: true});
|
|
350
|
-
|
|
351
|
-
// Querying thread comment page data
|
|
352
|
-
aniLink.anilist.query.page.threadComments({threadId: 71881, asHtml: true
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// Querying review page data
|
|
356
|
-
aniLink.anilist.query.page.reviews({id: 8008, asHtml: true});
|
|
357
|
-
|
|
358
|
-
// Querying recommendation page data
|
|
359
|
-
aniLink.anilist.query.page.recommendations({mediaId: 156822, asHtml: true
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
// Querying likes page data
|
|
363
|
-
aniLink.anilist.query.page.likes({likeableId: 723422275, type: 'ACTIVITY', asHtml: true
|
|
364
|
-
});
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
### Mutating user data
|
|
368
|
-
|
|
369
|
-
```typescript
|
|
370
|
-
// Updating a user
|
|
371
|
-
aniLink.anilist.mutation.updateUser({
|
|
372
|
-
about: 'New about text',
|
|
373
|
-
titleLanguage: 'ENGLISH',
|
|
374
|
-
displayAdultContent: true,
|
|
375
|
-
airingNotifications: true,
|
|
376
|
-
scoreFormat: 'POINT_10',
|
|
377
|
-
rowOrder: 'title',
|
|
378
|
-
profileColor: 'blue',
|
|
379
|
-
donatorBadge: 'Supporter',
|
|
380
|
-
notificationOptions: [{type: 'AIRING', enabled: true}],
|
|
381
|
-
timezone: '-06:00',
|
|
382
|
-
activityMergeTime: 30,
|
|
383
|
-
animeListOptions: {sectionOrder: ['title'], customLists: [], advancedScoring: [], advancedScoringEnabled: false},
|
|
384
|
-
mangaListOptions: {sectionOrder: ['title'], customLists: [], advancedScoring: [], advancedScoringEnabled: false},
|
|
385
|
-
staffNameLanguage: 'ROMAJI',
|
|
386
|
-
restrictMessagesToFollowing: false,
|
|
387
|
-
disabledListActivity: [{type: 'CURRENT', disabled: false}]
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
// Saving media list entries
|
|
391
|
-
aniLink.anilist.mutation.saveMediaListEntry({
|
|
392
|
-
mediaId: 1,
|
|
393
|
-
status: 'CURRENT',
|
|
394
|
-
score: 8.5,
|
|
395
|
-
progress: 3,
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
// Updating media list entries
|
|
399
|
-
aniLink.anilist.mutation.updateMediaListEntries({
|
|
400
|
-
status: 'CURRENT',
|
|
401
|
-
score: 8.5,
|
|
402
|
-
progress: 3,
|
|
403
|
-
ids: [143271, 156822, 170890],
|
|
404
|
-
});
|
|
405
|
-
```
|
|
208
|
+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/RLAlpha49/AniLink/blob/master/LICENSE) file for details.
|
package/dist/AniLink.js
CHANGED
|
@@ -47,14 +47,27 @@ 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");
|
|
53
|
+
const SaveMessageActivity_1 = require("./apis/anilist/mutation/SaveMessageActivity");
|
|
54
|
+
const SaveListActivity_1 = require("./apis/anilist/mutation/SaveListActivity");
|
|
55
|
+
const DeleteActivity_1 = require("./apis/anilist/mutation/DeleteActivity");
|
|
50
56
|
/**
|
|
51
57
|
* `AniLink` is a class for interacting with the APIs.
|
|
52
58
|
* It provides methods for querying and mutating data.
|
|
53
59
|
*/
|
|
54
60
|
class AniLink {
|
|
55
61
|
/**
|
|
56
|
-
* Creates a new AniLink instance.
|
|
57
|
-
* @param {string} authToken - The authentication token to use for API requests.
|
|
62
|
+
* Creates a new AniLink instance. The `authToken` parameter is optional and only required for authenticated queries and mutations. If no `authToken` is provided, only public queries will be available. You are able to create multiple AniLink instances with different `authToken`s.
|
|
63
|
+
* @param {string} [authToken] - The authentication token to use for API requests.
|
|
64
|
+
* @public
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const aniLink = new AniLink('authToken');
|
|
68
|
+
*
|
|
69
|
+
* const aniLink2 = new AniLink();
|
|
70
|
+
* ```
|
|
58
71
|
*/
|
|
59
72
|
constructor(authToken) {
|
|
60
73
|
const userQueryInstance = new User_1.UserQuery(authToken);
|
|
@@ -103,6 +116,12 @@ class AniLink {
|
|
|
103
116
|
const updateUserMutationInstance = new UpdateUser_1.UpdateUserMutation(authToken);
|
|
104
117
|
const saveMediaListEntryMutationInstance = new SaveMediaListEntry_1.SaveMediaListEntryMutation(authToken);
|
|
105
118
|
const updateMediaListEntriesMutationInstance = new UpdateMediaListEntries_1.UpdateMediaListEntriesMutation(authToken);
|
|
119
|
+
const deleteMediaListEntryMutationInstance = new DeleteMediaListEntry_1.DeleteMediaListEntryMutation(authToken);
|
|
120
|
+
const deleteCustomListMutationInstance = new DeleteCustomList_1.DeleteCustomListMutation(authToken);
|
|
121
|
+
const saveTextActivityMutationInstance = new SaveTextActivity_1.SaveTextActivityMutation(authToken);
|
|
122
|
+
const saveMessageActivityMutationInstance = new SaveMessageActivity_1.SaveMessageActivityMutation(authToken);
|
|
123
|
+
const saveListActivityMutationInstance = new SaveListActivity_1.SaveListActivityMutation(authToken);
|
|
124
|
+
const deleteActivityMutationInstance = new DeleteActivity_1.DeleteActivityMutation(authToken);
|
|
106
125
|
this.anilist = {
|
|
107
126
|
query: {
|
|
108
127
|
user: userQueryInstance.user.bind(userQueryInstance),
|
|
@@ -154,7 +173,13 @@ class AniLink {
|
|
|
154
173
|
mutation: {
|
|
155
174
|
updateUser: updateUserMutationInstance.updateUser.bind(updateUserMutationInstance),
|
|
156
175
|
saveMediaListEntry: saveMediaListEntryMutationInstance.saveMediaListEntry.bind(saveMediaListEntryMutationInstance),
|
|
157
|
-
updateMediaListEntries: updateMediaListEntriesMutationInstance.updateMediaListEntries.bind(updateMediaListEntriesMutationInstance)
|
|
176
|
+
updateMediaListEntries: updateMediaListEntriesMutationInstance.updateMediaListEntries.bind(updateMediaListEntriesMutationInstance),
|
|
177
|
+
deleteMediaListEntry: deleteMediaListEntryMutationInstance.deleteMediaListEntry.bind(deleteMediaListEntryMutationInstance),
|
|
178
|
+
deleteCustomList: deleteCustomListMutationInstance.deleteCustomList.bind(deleteCustomListMutationInstance),
|
|
179
|
+
saveTextActivity: saveTextActivityMutationInstance.saveTextActivity.bind(saveTextActivityMutationInstance),
|
|
180
|
+
saveMessageActivity: saveMessageActivityMutationInstance.saveMessageActivity.bind(saveMessageActivityMutationInstance),
|
|
181
|
+
saveListActivity: saveListActivityMutationInstance.saveListActivity.bind(saveListActivityMutationInstance),
|
|
182
|
+
deleteActivity: deleteActivityMutationInstance.deleteActivity.bind(deleteActivityMutationInstance)
|
|
158
183
|
}
|
|
159
184
|
};
|
|
160
185
|
}
|
|
@@ -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.MessageActivitySchema = exports.ListActivitySchema = 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,96 @@ 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
|
+
`;
|
|
179
|
+
/**
|
|
180
|
+
* `ListActivitySchema` is an object representing a list activity.
|
|
181
|
+
* It includes the id, user id, type, reply count, status, progress, lock status, subscription status, like count, like status, pin status, site url, creation date, media details, user details, replies, and likes.
|
|
182
|
+
*/
|
|
183
|
+
exports.ListActivitySchema = `
|
|
184
|
+
id
|
|
185
|
+
userId
|
|
186
|
+
type
|
|
187
|
+
replyCount
|
|
188
|
+
status
|
|
189
|
+
progress
|
|
190
|
+
isLocked
|
|
191
|
+
isSubscribed
|
|
192
|
+
likeCount
|
|
193
|
+
isLiked
|
|
194
|
+
isPinned
|
|
195
|
+
siteUrl
|
|
196
|
+
createdAt
|
|
197
|
+
media {
|
|
198
|
+
id
|
|
199
|
+
title {
|
|
200
|
+
romaji
|
|
201
|
+
english
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
user {
|
|
205
|
+
${BasicUser_1.BasicUserSchema}
|
|
206
|
+
}
|
|
207
|
+
replies {
|
|
208
|
+
${ActivityReply_1.ActivityReplySchema}
|
|
209
|
+
}
|
|
210
|
+
likes {
|
|
211
|
+
${BasicUser_1.BasicUserSchema}
|
|
212
|
+
}
|
|
213
|
+
`;
|
|
214
|
+
/**
|
|
215
|
+
* `MessageActivitySchema` is an object representing a message activity.
|
|
216
|
+
* It includes the id, recipient id, messenger id, type, reply count, message, lock status, subscription status, like count, like status, privacy status, site url, creation date, recipient details, messenger details, replies, and likes.
|
|
217
|
+
*/
|
|
218
|
+
exports.MessageActivitySchema = `
|
|
219
|
+
id
|
|
220
|
+
recipientId
|
|
221
|
+
messengerId
|
|
222
|
+
type
|
|
223
|
+
replyCount
|
|
224
|
+
message (asHtml: $asHtml)
|
|
225
|
+
isLocked
|
|
226
|
+
isSubscribed
|
|
227
|
+
likeCount
|
|
228
|
+
isLiked
|
|
229
|
+
isPrivate
|
|
230
|
+
siteUrl
|
|
231
|
+
createdAt
|
|
232
|
+
recipient {
|
|
233
|
+
${BasicUser_1.BasicUserSchema}
|
|
234
|
+
}
|
|
235
|
+
messenger {
|
|
236
|
+
${BasicUser_1.BasicUserSchema}
|
|
237
|
+
}
|
|
238
|
+
replies {
|
|
239
|
+
${ActivityReply_1.ActivityReplySchema}
|
|
240
|
+
}
|
|
241
|
+
likes {
|
|
242
|
+
${BasicUser_1.BasicUserSchema}
|
|
243
|
+
}
|
|
244
|
+
`;
|
|
@@ -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.DeleteActivityMutation = 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
|
+
* `DeleteActivityMutation` is a class representing a mutation to delete a activity.
|
|
18
|
+
* It includes a method to delete a activity
|
|
19
|
+
*/
|
|
20
|
+
class DeleteActivityMutation extends APIWrapper_1.APIWrapper {
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new `DeleteActivityMutation` 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 activity.
|
|
32
|
+
*
|
|
33
|
+
* @param variables - An object of type `DeleteActivityVariables` 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
|
+
deleteActivity(variables) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (!this.authToken) {
|
|
40
|
+
throw new Error('DeleteActivityMutation 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
|
+
DeleteActivity(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.DeleteActivityMutation = DeleteActivityMutation;
|
|
@@ -0,0 +1,63 @@
|
|
|
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 (!this.authToken) {
|
|
41
|
+
throw new Error('DeleteCustomListMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.customList || !variables.type) {
|
|
44
|
+
throw new Error('customList & type variables are required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
customList: 'string',
|
|
48
|
+
type: Type_1.MediaTypeMappings
|
|
49
|
+
};
|
|
50
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
51
|
+
const mutation = `
|
|
52
|
+
mutation ($customList: String, $type: MediaType) {
|
|
53
|
+
DeleteCustomList(customList: $customList, type: $type) {
|
|
54
|
+
deleted
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
const data = { query: mutation, variables };
|
|
59
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.DeleteCustomListMutation = DeleteCustomListMutation;
|
|
@@ -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.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 (!this.authToken) {
|
|
40
|
+
throw new Error('DeleteMediaListEntryMutation 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
|
+
DeleteMediaListEntry(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.DeleteMediaListEntryMutation = DeleteMediaListEntryMutation;
|
|
@@ -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.SaveListActivityMutation = 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
|
+
* `SaveListActivityMutation` is a class representing a mutation to save a list activity.
|
|
19
|
+
* It includes a method to save a list activity
|
|
20
|
+
*/
|
|
21
|
+
class SaveListActivityMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `SaveListActivityMutation` 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
|
+
* `saveListActivity` is a method that sends a mutation request to save a list activity.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `SaveListActivityVariables` 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
|
+
saveListActivity(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('SaveListActivityMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.id) {
|
|
44
|
+
throw new Error('id variable is required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
id: 'number',
|
|
48
|
+
locked: 'boolean',
|
|
49
|
+
asHtml: 'boolean'
|
|
50
|
+
};
|
|
51
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
52
|
+
const mutation = `
|
|
53
|
+
mutation ($id: Int, $locked: Boolean, $asHtml: Boolean) {
|
|
54
|
+
SaveListActivity(id: $id, locked:$locked)
|
|
55
|
+
${Activity_1.ListActivitySchema}
|
|
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.SaveListActivityMutation = SaveListActivityMutation;
|
|
@@ -39,6 +39,9 @@ class SaveMediaListEntryMutation extends APIWrapper_1.APIWrapper {
|
|
|
39
39
|
*/
|
|
40
40
|
saveMediaListEntry(variables) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (!this.authToken) {
|
|
43
|
+
throw new Error('SaveMediaListEntryMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
44
|
+
}
|
|
42
45
|
if (variables.mediaId === undefined) {
|
|
43
46
|
throw new Error('mediaId is required for SaveMediaListEntryMutation');
|
|
44
47
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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.SaveMessageActivityMutation = 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
|
+
* `SaveMessageActivityMutation` is a class representing a mutation to save a message activity.
|
|
19
|
+
* It includes a method to save a message activity
|
|
20
|
+
*/
|
|
21
|
+
class SaveMessageActivityMutation extends APIWrapper_1.APIWrapper {
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new `SaveMessageActivityMutation` 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
|
+
* `saveMessageActivity` is a method that sends a mutation request to save a message activity.
|
|
33
|
+
*
|
|
34
|
+
* @param variables - An object of type `SaveMessageActivityVariables` 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
|
+
saveMessageActivity(variables) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('SaveMessageActivityMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.id && !variables.message) {
|
|
44
|
+
throw new Error('id or text variable is required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
id: 'number',
|
|
48
|
+
message: 'string',
|
|
49
|
+
recipientId: 'number',
|
|
50
|
+
private: 'boolean',
|
|
51
|
+
locked: 'boolean',
|
|
52
|
+
asMod: 'boolean',
|
|
53
|
+
asHtml: 'boolean'
|
|
54
|
+
};
|
|
55
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
56
|
+
const mutation = `
|
|
57
|
+
mutation ($id: Int, $message: String, $recipientId: Int, $private: Boolean, $locked: Boolean, $asMod: Boolean, $asHtml: Boolean) {
|
|
58
|
+
SaveMessageActivity(id: $id, message: $message, recipientId: $recipientId, private: $private, locked:$locked, asMod: $asMod) {
|
|
59
|
+
${Activity_1.MessageActivitySchema}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
const data = { query: mutation, variables };
|
|
64
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.SaveMessageActivityMutation = SaveMessageActivityMutation;
|
|
@@ -0,0 +1,65 @@
|
|
|
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 (!this.authToken) {
|
|
41
|
+
throw new Error('SaveTextActivityMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
43
|
+
if (!variables.id && !variables.text) {
|
|
44
|
+
throw new Error('id or text variable is required');
|
|
45
|
+
}
|
|
46
|
+
const variableTypeMappings = {
|
|
47
|
+
id: 'number',
|
|
48
|
+
text: 'string',
|
|
49
|
+
locked: 'boolean',
|
|
50
|
+
asHtml: 'boolean'
|
|
51
|
+
};
|
|
52
|
+
(0, ValidateVariables_1.validateVariables)(variables, variableTypeMappings);
|
|
53
|
+
const mutation = `
|
|
54
|
+
mutation ($id: Int, $text: String, $locked: Boolean, $asHtml: Boolean) {
|
|
55
|
+
SaveTextActivity(id: $id, text: $text, locked:$locked) {
|
|
56
|
+
${Activity_1.TextActivitySchema}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
const data = { query: mutation, variables };
|
|
61
|
+
return yield (0, RequestHandler_1.sendRequest)(this.baseURL, 'POST', data, this.authToken);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.SaveTextActivityMutation = SaveTextActivityMutation;
|
|
@@ -39,6 +39,9 @@ class UpdateMediaListEntriesMutation extends APIWrapper_1.APIWrapper {
|
|
|
39
39
|
* */
|
|
40
40
|
updateMediaListEntries(variables) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (!this.authToken) {
|
|
43
|
+
throw new Error('UpdateMediaListEntriesMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
44
|
+
}
|
|
42
45
|
if (!variables.ids || variables.ids.length === 0) {
|
|
43
46
|
throw new Error('ids must be an array of at least one number');
|
|
44
47
|
}
|
|
@@ -42,6 +42,9 @@ class UpdateUserMutation extends APIWrapper_1.APIWrapper {
|
|
|
42
42
|
*/
|
|
43
43
|
updateUser(variables) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (!this.authToken) {
|
|
46
|
+
throw new Error('UpdateUserMutation requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
47
|
+
}
|
|
45
48
|
const variableTypeMappings = {
|
|
46
49
|
about: 'string',
|
|
47
50
|
titleLanguage: UserTitleLanguage_1.UserTitleLanguageMapping,
|
|
@@ -26,9 +26,6 @@ class AniChartUserQuery extends APIWrapper_1.APIWrapper {
|
|
|
26
26
|
constructor(authToken) {
|
|
27
27
|
super('https://graphql.anilist.co');
|
|
28
28
|
this.authToken = authToken;
|
|
29
|
-
if (!this.authToken) {
|
|
30
|
-
throw new Error('AniChartUserQuery requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
31
|
-
}
|
|
32
29
|
}
|
|
33
30
|
/**
|
|
34
31
|
* `aniChartUser` is a method that sends a query request to get AniChart users.
|
|
@@ -37,6 +34,9 @@ class AniChartUserQuery extends APIWrapper_1.APIWrapper {
|
|
|
37
34
|
*/
|
|
38
35
|
aniChartUser() {
|
|
39
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if (!this.authToken) {
|
|
38
|
+
throw new Error('AniChartUserQuery requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
39
|
+
}
|
|
40
40
|
const query = `
|
|
41
41
|
query {
|
|
42
42
|
AniChartUser {
|
|
@@ -37,6 +37,9 @@ class NotificationQuery extends APIWrapper_1.APIWrapper {
|
|
|
37
37
|
*/
|
|
38
38
|
notification(variables) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('NotificationQuery requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
40
43
|
if (!variables) {
|
|
41
44
|
throw new Error('At least one variable must be set');
|
|
42
45
|
}
|
|
@@ -37,6 +37,9 @@ class ViewerQuery extends APIWrapper_1.APIWrapper {
|
|
|
37
37
|
*/
|
|
38
38
|
viewer() {
|
|
39
39
|
return __awaiter(this, arguments, void 0, function* (variables = {}) {
|
|
40
|
+
if (!this.authToken) {
|
|
41
|
+
throw new Error('ViewerQuery requires an authentication token. Create a new instance of AniLink and pass the token as an argument.');
|
|
42
|
+
}
|
|
40
43
|
const variableTypeMappings = {
|
|
41
44
|
asHtml: 'boolean',
|
|
42
45
|
animeStatLimit: 'number',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anilink-api-wrapper",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Anilist
|
|
3
|
+
"version": "1.21.0",
|
|
4
|
+
"description": "API wrapper for AniManga sites such as Anilist, MyAnimeList, Kitsu.",
|
|
5
5
|
"main": "dist/AniLink.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest",
|
|
@@ -11,8 +11,14 @@
|
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"anilist",
|
|
14
|
+
"myanimelist",
|
|
15
|
+
"kitsu",
|
|
14
16
|
"api",
|
|
15
|
-
"wrapper"
|
|
17
|
+
"wrapper",
|
|
18
|
+
"anilist-api",
|
|
19
|
+
"anilist-query",
|
|
20
|
+
"anilist-mutation",
|
|
21
|
+
"anilist-graphql"
|
|
16
22
|
],
|
|
17
23
|
"author": "RLAlpha49",
|
|
18
24
|
"license": "MIT",
|