anilink-api-wrapper 1.20.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 +4 -227
- package/dist/AniLink.js +19 -3
- package/dist/apis/anilist/interfaces/Activity.js +67 -1
- package/dist/apis/anilist/mutation/DeleteActivity.js +61 -0
- package/dist/apis/anilist/mutation/DeleteCustomList.js +3 -0
- package/dist/apis/anilist/mutation/DeleteMediaListEntry.js +3 -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 +3 -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
|
@@ -118,6 +118,8 @@ List of methods in `anilist.mutation`:
|
|
|
118
118
|
- deleteMediaListEntries
|
|
119
119
|
- deleteCustomLists
|
|
120
120
|
- saveTextActivity
|
|
121
|
+
- saveMessageActivity
|
|
122
|
+
- deleteActivity
|
|
121
123
|
|
|
122
124
|
### Error Handling
|
|
123
125
|
|
|
@@ -199,233 +201,8 @@ Example Error Thrown:
|
|
|
199
201
|
|
|
200
202
|
### Examples
|
|
201
203
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
#### Querying user data
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
// Querying user data
|
|
208
|
-
aniLink.anilist.query.user({id: 542244, isHTML: true});
|
|
209
|
-
|
|
210
|
-
// Querying media data
|
|
211
|
-
aniLink.anilist.query.media({id: 1, type: 'ANIME'});
|
|
212
|
-
|
|
213
|
-
// Querying media trend data
|
|
214
|
-
aniLink.anilist.query.mediaTrend({mediaId: 1, type: 'ANIME'});
|
|
215
|
-
|
|
216
|
-
// Querying airing schedule data
|
|
217
|
-
aniLink.anilist.query.airingSchedule({mediaId: 130590});
|
|
218
|
-
|
|
219
|
-
// Querying character data
|
|
220
|
-
aniLink.anilist.query.character({
|
|
221
|
-
id: 1,
|
|
222
|
-
asHtml: true,
|
|
223
|
-
mediaSort: ['POPULARITY_DESC'],
|
|
224
|
-
mediaType: 'ANIME',
|
|
225
|
-
mediaOnList: true,
|
|
226
|
-
mediaPage: 1,
|
|
227
|
-
mediaPerPage: 10
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
// Querying staff data
|
|
231
|
-
aniLink.anilist.query.staff({
|
|
232
|
-
id: 132186,
|
|
233
|
-
asHtml: true,
|
|
234
|
-
staffMediaSort: ['POPULARITY_DESC'],
|
|
235
|
-
staffMediaType: 'ANIME',
|
|
236
|
-
staffMediaOnList: true,
|
|
237
|
-
staffMediaPage: 1,
|
|
238
|
-
staffMediaPerPage: 10,
|
|
239
|
-
charactersSort: ['ID'],
|
|
240
|
-
charactersPage: 1,
|
|
241
|
-
charactersPerPage: 10,
|
|
242
|
-
characterMediaSort: ['POPULARITY_DESC'],
|
|
243
|
-
characterMediaOnList: true,
|
|
244
|
-
characterMediaPage: 1,
|
|
245
|
-
characterMediaPerPage: 10
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// Querying media list data
|
|
249
|
-
aniLink.anilist.query.mediaList({userId: 542244});
|
|
250
|
-
|
|
251
|
-
// Querying media list collection data
|
|
252
|
-
aniLink.anilist.query.mediaListCollection({
|
|
253
|
-
userId: 542244,
|
|
254
|
-
type: 'ANIME',
|
|
255
|
-
status: 'COMPLETED',
|
|
256
|
-
chunk: 1,
|
|
257
|
-
perChunk: 10000
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// Querying genre collection data
|
|
261
|
-
aniLink.anilist.query.genreCollection();
|
|
262
|
-
|
|
263
|
-
// Querying media tag collection data
|
|
264
|
-
aniLink.anilist.query.mediaTagCollection();
|
|
265
|
-
|
|
266
|
-
// Querying viewer data
|
|
267
|
-
aniLink.anilist.query.viewer({isHTML: true});
|
|
268
|
-
|
|
269
|
-
// Querying notification data
|
|
270
|
-
aniLink.anilist.query.notification({asHtml: true});
|
|
271
|
-
|
|
272
|
-
// Querying studio data
|
|
273
|
-
aniLink.anilist.query.studio({id: 561, asHtml: true});
|
|
274
|
-
|
|
275
|
-
// Querying review data
|
|
276
|
-
aniLink.anilist.query.review({id: 8008, asHtml: true});
|
|
277
|
-
|
|
278
|
-
// Querying activity data
|
|
279
|
-
aniLink.anilist.query.activity({id: 723235883, asHtml: true});
|
|
280
|
-
|
|
281
|
-
// Querying activity reply data
|
|
282
|
-
aniLink.anilist.query.activityReply({id: 12191046, asHtml: true});
|
|
283
|
-
|
|
284
|
-
// Querying following data
|
|
285
|
-
aniLink.anilist.query.following({userId: 542244, asHtml: true});
|
|
286
|
-
|
|
287
|
-
// Querying follower data
|
|
288
|
-
aniLink.anilist.query.follower({userId: 542244, asHtml: true});
|
|
289
|
-
|
|
290
|
-
// Querying thread data
|
|
291
|
-
aniLink.anilist.query.thread({id: 71881, asHtml: true});
|
|
292
|
-
|
|
293
|
-
// Querying thread comment data
|
|
294
|
-
aniLink.anilist.query.threadComment({id: 2555166, asHtml: true});
|
|
295
|
-
|
|
296
|
-
// Querying recommendation data
|
|
297
|
-
aniLink.anilist.query.recommendation({mediaId: 156822, asHtml: true});
|
|
298
|
-
|
|
299
|
-
// Querying markdown data
|
|
300
|
-
aniLink.anilist.query.markdown({markdown: 'Hello'});
|
|
301
|
-
|
|
302
|
-
// Querying AniChartUser data
|
|
303
|
-
aniLink.anilist.query.aniChartUser();
|
|
304
|
-
|
|
305
|
-
// Querying site statistics data
|
|
306
|
-
aniLink.anilist.query.siteStatistics();
|
|
307
|
-
|
|
308
|
-
// Querying external link source collection data
|
|
309
|
-
aniLink.anilist.query.externalLinkSourceCollection();
|
|
310
|
-
|
|
311
|
-
// Querying users page data
|
|
312
|
-
aniLink.anilist.query.page.users({id: 542244, isHTML: true});
|
|
313
|
-
|
|
314
|
-
// Querying media page data
|
|
315
|
-
aniLink.anilist.query.page.medias({id: 1, type: 'ANIME'});
|
|
316
|
-
|
|
317
|
-
// Querying character page data
|
|
318
|
-
aniLink.anilist.query.page.characters({id: 1, asHtml: true});
|
|
319
|
-
|
|
320
|
-
// Querying staff page data
|
|
321
|
-
aniLink.anilist.query.page.staffs({id: 132186, asHtml: true});
|
|
322
|
-
|
|
323
|
-
// Querying studio page data
|
|
324
|
-
aniLink.anilist.query.page.studios({id: 561, asHtml: true});
|
|
325
|
-
|
|
326
|
-
// Querying media list page data
|
|
327
|
-
aniLink.anilist.query.page.mediaLists({userId: 542244});
|
|
328
|
-
|
|
329
|
-
// Querying airing schedule page data
|
|
330
|
-
aniLink.anilist.query.page.airingSchedules({mediaId: 130590});
|
|
331
|
-
|
|
332
|
-
// Querying media trend page data
|
|
333
|
-
aniLink.anilist.query.page.mediaTrends({mediaId: 1, type: 'ANIME'});
|
|
334
|
-
|
|
335
|
-
// Querying notification page data
|
|
336
|
-
aniLink.anilist.query.page.notifications({asHtml: true});
|
|
337
|
-
|
|
338
|
-
// Querying follower page data
|
|
339
|
-
aniLink.anilist.query.page.followers({userId: 542244, asHtml: true});
|
|
340
|
-
|
|
341
|
-
// Querying following page data
|
|
342
|
-
aniLink.anilist.query.page.following({userId: 542244, asHtml: true});
|
|
343
|
-
|
|
344
|
-
// Querying activity page data
|
|
345
|
-
aniLink.anilist.query.page.activities({id: 723235883, asHtml: true});
|
|
346
|
-
|
|
347
|
-
// Querying activity reply page data
|
|
348
|
-
aniLink.anilist.query.page.activityReplies({id: 12191046, asHtml: true
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
// Querying thread page data
|
|
352
|
-
aniLink.anilist.query.page.threads({id: 71881, asHtml: true});
|
|
353
|
-
|
|
354
|
-
// Querying thread comment page data
|
|
355
|
-
aniLink.anilist.query.page.threadComments({threadId: 71881, asHtml: true
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// Querying review page data
|
|
359
|
-
aniLink.anilist.query.page.reviews({id: 8008, asHtml: true});
|
|
360
|
-
|
|
361
|
-
// Querying recommendation page data
|
|
362
|
-
aniLink.anilist.query.page.recommendations({mediaId: 156822, asHtml: true
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
// Querying likes page data
|
|
366
|
-
aniLink.anilist.query.page.likes({likeableId: 723422275, type: 'ACTIVITY', asHtml: true
|
|
367
|
-
});
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
#### Mutating user data
|
|
371
|
-
|
|
372
|
-
```typescript
|
|
373
|
-
// Updating a user
|
|
374
|
-
aniLink.anilist.mutation.updateUser({
|
|
375
|
-
about: 'New about text',
|
|
376
|
-
titleLanguage: 'ENGLISH',
|
|
377
|
-
displayAdultContent: true,
|
|
378
|
-
airingNotifications: true,
|
|
379
|
-
scoreFormat: 'POINT_10',
|
|
380
|
-
rowOrder: 'title',
|
|
381
|
-
profileColor: 'blue',
|
|
382
|
-
donatorBadge: 'Supporter',
|
|
383
|
-
notificationOptions: [{type: 'AIRING', enabled: true}],
|
|
384
|
-
timezone: '-06:00',
|
|
385
|
-
activityMergeTime: 30,
|
|
386
|
-
animeListOptions: {sectionOrder: ['title'], customLists: ['test'], advancedScoring: [], advancedScoringEnabled: false},
|
|
387
|
-
mangaListOptions: {sectionOrder: ['title'], customLists: ['test'], advancedScoring: [], advancedScoringEnabled: false},
|
|
388
|
-
staffNameLanguage: 'ROMAJI',
|
|
389
|
-
restrictMessagesToFollowing: false,
|
|
390
|
-
disabledListActivity: [{type: 'CURRENT', disabled: false}]
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
// Saving media list entries
|
|
394
|
-
aniLink.anilist.mutation.saveMediaListEntry({
|
|
395
|
-
mediaId: 143271,
|
|
396
|
-
status: 'CURRENT',
|
|
397
|
-
score: 8.5,
|
|
398
|
-
progress: 3,
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// Updating media list entries
|
|
402
|
-
aniLink.anilist.mutation.updateMediaListEntries({
|
|
403
|
-
status: 'CURRENT',
|
|
404
|
-
score: 8.5,
|
|
405
|
-
progress: 3,
|
|
406
|
-
ids: [143271, 156822, 170890],
|
|
407
|
-
});
|
|
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
|
-
```
|
|
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.
|
|
428
205
|
|
|
429
206
|
## License
|
|
430
207
|
|
|
431
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
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
|
@@ -50,14 +50,24 @@ const Viewer_1 = require("./apis/anilist/query/Viewer");
|
|
|
50
50
|
const DeleteMediaListEntry_1 = require("./apis/anilist/mutation/DeleteMediaListEntry");
|
|
51
51
|
const DeleteCustomList_1 = require("./apis/anilist/mutation/DeleteCustomList");
|
|
52
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");
|
|
53
56
|
/**
|
|
54
57
|
* `AniLink` is a class for interacting with the APIs.
|
|
55
58
|
* It provides methods for querying and mutating data.
|
|
56
59
|
*/
|
|
57
60
|
class AniLink {
|
|
58
61
|
/**
|
|
59
|
-
* Creates a new AniLink instance.
|
|
60
|
-
* @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
|
+
* ```
|
|
61
71
|
*/
|
|
62
72
|
constructor(authToken) {
|
|
63
73
|
const userQueryInstance = new User_1.UserQuery(authToken);
|
|
@@ -109,6 +119,9 @@ class AniLink {
|
|
|
109
119
|
const deleteMediaListEntryMutationInstance = new DeleteMediaListEntry_1.DeleteMediaListEntryMutation(authToken);
|
|
110
120
|
const deleteCustomListMutationInstance = new DeleteCustomList_1.DeleteCustomListMutation(authToken);
|
|
111
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);
|
|
112
125
|
this.anilist = {
|
|
113
126
|
query: {
|
|
114
127
|
user: userQueryInstance.user.bind(userQueryInstance),
|
|
@@ -163,7 +176,10 @@ class AniLink {
|
|
|
163
176
|
updateMediaListEntries: updateMediaListEntriesMutationInstance.updateMediaListEntries.bind(updateMediaListEntriesMutationInstance),
|
|
164
177
|
deleteMediaListEntry: deleteMediaListEntryMutationInstance.deleteMediaListEntry.bind(deleteMediaListEntryMutationInstance),
|
|
165
178
|
deleteCustomList: deleteCustomListMutationInstance.deleteCustomList.bind(deleteCustomListMutationInstance),
|
|
166
|
-
saveTextActivity: saveTextActivityMutationInstance.saveTextActivity.bind(saveTextActivityMutationInstance)
|
|
179
|
+
saveTextActivity: saveTextActivityMutationInstance.saveTextActivity.bind(saveTextActivityMutationInstance),
|
|
180
|
+
saveMessageActivity: saveMessageActivityMutationInstance.saveMessageActivity.bind(saveMessageActivityMutationInstance),
|
|
181
|
+
saveListActivity: saveListActivityMutationInstance.saveListActivity.bind(saveListActivityMutationInstance),
|
|
182
|
+
deleteActivity: deleteActivityMutationInstance.deleteActivity.bind(deleteActivityMutationInstance)
|
|
167
183
|
}
|
|
168
184
|
};
|
|
169
185
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextActivitySchema = 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
|
/**
|
|
@@ -176,3 +176,69 @@ exports.TextActivitySchema = `
|
|
|
176
176
|
${BasicUser_1.BasicUserSchema}
|
|
177
177
|
}
|
|
178
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;
|
|
@@ -37,6 +37,9 @@ class DeleteCustomListMutation extends APIWrapper_1.APIWrapper {
|
|
|
37
37
|
* */
|
|
38
38
|
deleteCustomList(variables) {
|
|
39
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
|
+
}
|
|
40
43
|
if (!variables.customList || !variables.type) {
|
|
41
44
|
throw new Error('customList & type variables are required');
|
|
42
45
|
}
|
|
@@ -36,6 +36,9 @@ class DeleteMediaListEntryMutation extends APIWrapper_1.APIWrapper {
|
|
|
36
36
|
* */
|
|
37
37
|
deleteMediaListEntry(variables) {
|
|
38
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
|
+
}
|
|
39
42
|
if (!variables.id) {
|
|
40
43
|
throw new Error('id variable is required');
|
|
41
44
|
}
|
|
@@ -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;
|
|
@@ -37,6 +37,9 @@ class SaveTextActivityMutation extends APIWrapper_1.APIWrapper {
|
|
|
37
37
|
* */
|
|
38
38
|
saveTextActivity(variables) {
|
|
39
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
|
+
}
|
|
40
43
|
if (!variables.id && !variables.text) {
|
|
41
44
|
throw new Error('id or text variable is required');
|
|
42
45
|
}
|
|
@@ -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",
|