anilink-api-wrapper 1.0.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.
Files changed (104) hide show
  1. package/.eslintignore +1 -0
  2. package/.github/workflows/code_quality.yml +32 -0
  3. package/.github/workflows/codeql.yml +33 -0
  4. package/.github/workflows/test.yml +30 -0
  5. package/LICENSE +21 -0
  6. package/README.md +1 -0
  7. package/__tests__/anilist.test.ts +268 -0
  8. package/babel.config.js +6 -0
  9. package/dist/AniLink.js +40 -0
  10. package/dist/apis/anilist/interfaces/ActivityHistory.js +2 -0
  11. package/dist/apis/anilist/interfaces/CoverImage.js +2 -0
  12. package/dist/apis/anilist/interfaces/Distribution.js +2 -0
  13. package/dist/apis/anilist/interfaces/ExternalLink.js +2 -0
  14. package/dist/apis/anilist/interfaces/Favoured.js +2 -0
  15. package/dist/apis/anilist/interfaces/FuzzyDate.js +2 -0
  16. package/dist/apis/anilist/interfaces/Image.js +2 -0
  17. package/dist/apis/anilist/interfaces/ListScores.js +2 -0
  18. package/dist/apis/anilist/interfaces/Media.js +2 -0
  19. package/dist/apis/anilist/interfaces/MediaListEntry.js +2 -0
  20. package/dist/apis/anilist/interfaces/MediaStatistics.js +2 -0
  21. package/dist/apis/anilist/interfaces/MediaStats.js +2 -0
  22. package/dist/apis/anilist/interfaces/Name.js +2 -0
  23. package/dist/apis/anilist/interfaces/NextAiringEpisode.js +2 -0
  24. package/dist/apis/anilist/interfaces/Ranking.js +2 -0
  25. package/dist/apis/anilist/interfaces/ScoreDistribution.js +2 -0
  26. package/dist/apis/anilist/interfaces/Staff.js +2 -0
  27. package/dist/apis/anilist/interfaces/Stat.js +2 -0
  28. package/dist/apis/anilist/interfaces/Statistics.js +2 -0
  29. package/dist/apis/anilist/interfaces/Stats.js +2 -0
  30. package/dist/apis/anilist/interfaces/StatusDistribution.js +2 -0
  31. package/dist/apis/anilist/interfaces/StreamingEpisode.js +2 -0
  32. package/dist/apis/anilist/interfaces/Studio.js +2 -0
  33. package/dist/apis/anilist/interfaces/Tag.js +2 -0
  34. package/dist/apis/anilist/interfaces/Title.js +2 -0
  35. package/dist/apis/anilist/interfaces/Trailer.js +2 -0
  36. package/dist/apis/anilist/interfaces/UserStats.js +2 -0
  37. package/dist/apis/anilist/interfaces/responses/AiringSchedule.js +2 -0
  38. package/dist/apis/anilist/interfaces/responses/Character.js +2 -0
  39. package/dist/apis/anilist/interfaces/responses/Media.js +2 -0
  40. package/dist/apis/anilist/interfaces/responses/MediaList.js +2 -0
  41. package/dist/apis/anilist/interfaces/responses/MediaListCollectionResponse.js +2 -0
  42. package/dist/apis/anilist/interfaces/responses/MediaTrend.js +2 -0
  43. package/dist/apis/anilist/interfaces/responses/Staff.js +2 -0
  44. package/dist/apis/anilist/interfaces/responses/User.js +2 -0
  45. package/dist/apis/anilist/mutation/UpdateUser.js +82 -0
  46. package/dist/apis/anilist/query/AiringSchedule.js +147 -0
  47. package/dist/apis/anilist/query/Character.js +69 -0
  48. package/dist/apis/anilist/query/Media.js +232 -0
  49. package/dist/apis/anilist/query/MediaList.js +170 -0
  50. package/dist/apis/anilist/query/MediaListCollection.js +650 -0
  51. package/dist/apis/anilist/query/MediaTrend.js +149 -0
  52. package/dist/apis/anilist/query/Staff.js +108 -0
  53. package/dist/apis/anilist/query/User.js +573 -0
  54. package/dist/base/APIWrapper.js +9 -0
  55. package/dist/base/RequestHandler.js +33 -0
  56. package/jest.config.js +11 -0
  57. package/package.json +31 -0
  58. package/src/AniLink.ts +80 -0
  59. package/src/apis/anilist/interfaces/ActivityHistory.ts +5 -0
  60. package/src/apis/anilist/interfaces/CoverImage.ts +6 -0
  61. package/src/apis/anilist/interfaces/Distribution.ts +4 -0
  62. package/src/apis/anilist/interfaces/ExternalLink.ts +5 -0
  63. package/src/apis/anilist/interfaces/Favoured.ts +15 -0
  64. package/src/apis/anilist/interfaces/FuzzyDate.ts +5 -0
  65. package/src/apis/anilist/interfaces/Image.ts +4 -0
  66. package/src/apis/anilist/interfaces/ListScores.ts +4 -0
  67. package/src/apis/anilist/interfaces/Media.ts +59 -0
  68. package/src/apis/anilist/interfaces/MediaListEntry.ts +4 -0
  69. package/src/apis/anilist/interfaces/MediaStatistics.ts +23 -0
  70. package/src/apis/anilist/interfaces/MediaStats.ts +7 -0
  71. package/src/apis/anilist/interfaces/Name.ts +8 -0
  72. package/src/apis/anilist/interfaces/NextAiringEpisode.ts +5 -0
  73. package/src/apis/anilist/interfaces/Ranking.ts +10 -0
  74. package/src/apis/anilist/interfaces/ScoreDistribution.ts +4 -0
  75. package/src/apis/anilist/interfaces/Staff.ts +6 -0
  76. package/src/apis/anilist/interfaces/Stat.ts +24 -0
  77. package/src/apis/anilist/interfaces/Statistics.ts +6 -0
  78. package/src/apis/anilist/interfaces/StatusDistribution.ts +4 -0
  79. package/src/apis/anilist/interfaces/StreamingEpisode.ts +6 -0
  80. package/src/apis/anilist/interfaces/Studio.ts +4 -0
  81. package/src/apis/anilist/interfaces/Tag.ts +10 -0
  82. package/src/apis/anilist/interfaces/Title.ts +6 -0
  83. package/src/apis/anilist/interfaces/Trailer.ts +5 -0
  84. package/src/apis/anilist/interfaces/UserStats.ts +25 -0
  85. package/src/apis/anilist/interfaces/responses/AiringSchedule.ts +10 -0
  86. package/src/apis/anilist/interfaces/responses/Character.ts +26 -0
  87. package/src/apis/anilist/interfaces/responses/Media.ts +118 -0
  88. package/src/apis/anilist/interfaces/responses/MediaList.ts +24 -0
  89. package/src/apis/anilist/interfaces/responses/MediaListCollectionResponse.ts +37 -0
  90. package/src/apis/anilist/interfaces/responses/MediaTrend.ts +13 -0
  91. package/src/apis/anilist/interfaces/responses/Staff.ts +53 -0
  92. package/src/apis/anilist/interfaces/responses/User.ts +72 -0
  93. package/src/apis/anilist/mutation/UpdateUser.ts +162 -0
  94. package/src/apis/anilist/query/AiringSchedule.ts +160 -0
  95. package/src/apis/anilist/query/Character.ts +75 -0
  96. package/src/apis/anilist/query/Media.ts +295 -0
  97. package/src/apis/anilist/query/MediaList.ts +192 -0
  98. package/src/apis/anilist/query/MediaListCollection.ts +673 -0
  99. package/src/apis/anilist/query/MediaTrend.ts +169 -0
  100. package/src/apis/anilist/query/Staff.ts +122 -0
  101. package/src/apis/anilist/query/User.ts +567 -0
  102. package/src/base/APIWrapper.ts +7 -0
  103. package/src/base/RequestHandler.ts +21 -0
  104. package/tsconfig.json +15 -0
@@ -0,0 +1,673 @@
1
+ import { APIWrapper } from '../../../base/APIWrapper'
2
+ import { sendRequest } from '../../../base/RequestHandler'
3
+ import { MediaListCollectionResponse } from '../interfaces/responses/MediaListCollectionResponse'
4
+ // import { MediaListCollectionResponse } from '../interfaces/responses/MediaListCollection'
5
+
6
+ interface MediaListCollectionVariables {
7
+ userId?: number
8
+ userName?: string
9
+ type?: string
10
+ status?: string
11
+ notes?: string
12
+ startedAt?: number
13
+ completedAt?: number
14
+ forceSingleCompletedList?: boolean
15
+ chunk?: number
16
+ perChunk?: number
17
+ status_in?: string[]
18
+ status_not_in?: string[]
19
+ status_not?: string
20
+ notes_like?: string
21
+ startedAt_greater?: number
22
+ startedAt_lesser?: number
23
+ startedAt_like?: string
24
+ completedAt_greater?: number
25
+ completedAt_lesser?: number
26
+ completedAt_like?: string
27
+ sort?: string[]
28
+ scoreFormat?: string
29
+ asArray?: boolean
30
+ asHtml?: boolean
31
+ animeStatLimit?: number
32
+ animeStatSort?: string[]
33
+ mangaStatLimit?: number
34
+ mangaStatSort?: string[]
35
+ }
36
+
37
+ export class MediaListCollectionQuery extends APIWrapper {
38
+ private readonly authToken: string
39
+
40
+ constructor (authToken: string) {
41
+ super('https://graphql.anilist.co')
42
+ this.authToken = authToken
43
+ }
44
+
45
+ async mediaListCollection (variables?: MediaListCollectionVariables): Promise<MediaListCollectionResponse> {
46
+ const query = `
47
+ query ($userId: Int, $userName: String, $type: MediaType, $status: MediaListStatus, $notes: String, $startedAt: FuzzyDateInt, $completedAt: FuzzyDateInt, $forceSingleCompletedList: Boolean, $chunk: Int, $perChunk: Int, $status_in: [MediaListStatus], $status_not_in: [MediaListStatus], $status_not: MediaListStatus, $notes_like: String, $startedAt_greater: FuzzyDateInt, $startedAt_lesser: FuzzyDateInt, $startedAt_like: String, $completedAt_greater: FuzzyDateInt, $completedAt_lesser: FuzzyDateInt, $completedAt_like: String, $sort: [MediaListSort], $scoreFormat: ScoreFormat, $asArray: Boolean, $asHtml: Boolean, $animeStatLimit: Int, $animeStatSort: [UserStatisticsSort], $mangaStatLimit: Int, $mangaStatSort: [UserStatisticsSort]) {
48
+ MediaListCollection (userId: $userId, userName: $userName, type: $type, status: $status, notes: $notes, startedAt: $startedAt, completedAt: $completedAt, forceSingleCompletedList: $forceSingleCompletedList, chunk: $chunk, perChunk: $perChunk, status_in: $status_in, status_not_in: $status_not_in, status_not: $status_not, notes_like: $notes_like, startedAt_greater: $startedAt_greater, startedAt_lesser: $startedAt_lesser, startedAt_like: $startedAt_like, completedAt_greater: $completedAt_greater, completedAt_lesser: $completedAt_lesser, completedAt_like: $completedAt_like, sort: $sort) {
49
+ lists {
50
+ entries {
51
+ id
52
+ userId
53
+ mediaId
54
+ status
55
+ score (format: $scoreFormat)
56
+ progress
57
+ progressVolumes
58
+ repeat
59
+ priority
60
+ private
61
+ notes
62
+ hiddenFromStatusLists
63
+ customLists (asArray: $asArray)
64
+ advancedScores
65
+ startedAt {
66
+ year
67
+ month
68
+ day
69
+ }
70
+ completedAt {
71
+ year
72
+ month
73
+ day
74
+ }
75
+ updatedAt
76
+ createdAt
77
+ media {
78
+ id
79
+ idMal
80
+ title {
81
+ romaji
82
+ english
83
+ native
84
+ }
85
+ type
86
+ format
87
+ status
88
+ description (asHtml: $asHtml)
89
+ startDate {
90
+ year
91
+ month
92
+ day
93
+ }
94
+ endDate {
95
+ year
96
+ month
97
+ day
98
+ }
99
+ season
100
+ seasonYear
101
+ seasonInt
102
+ episodes
103
+ duration
104
+ chapters
105
+ volumes
106
+ countryOfOrigin
107
+ isLicensed
108
+ source
109
+ hashtag
110
+ trailer {
111
+ id
112
+ site
113
+ thumbnail
114
+ }
115
+ updatedAt
116
+ coverImage {
117
+ extraLarge
118
+ large
119
+ medium
120
+ color
121
+ }
122
+ bannerImage
123
+ genres
124
+ synonyms
125
+ averageScore
126
+ meanScore
127
+ popularity
128
+ isLocked
129
+ trending
130
+ favourites
131
+ tags {
132
+ id
133
+ name
134
+ description
135
+ rank
136
+ isGeneralSpoiler
137
+ isMediaSpoiler
138
+ isAdult
139
+ }
140
+ relations {
141
+ edges {
142
+ relationType
143
+ node {
144
+ id
145
+ title {
146
+ romaji
147
+ english
148
+ native
149
+ }
150
+ }
151
+ }
152
+ }
153
+ characters {
154
+ edges {
155
+ id
156
+ role
157
+ name
158
+ voiceActors {
159
+ id
160
+ name {
161
+ full
162
+ native
163
+ }
164
+ image {
165
+ large
166
+ }
167
+ }
168
+ media {
169
+ id
170
+ title {
171
+ romaji
172
+ english
173
+ native
174
+ }
175
+ coverImage {
176
+ extraLarge
177
+ large
178
+ medium
179
+ color
180
+ }
181
+ }
182
+ favouriteOrder
183
+ node {
184
+ id
185
+ name {
186
+ full
187
+ native
188
+ }
189
+ image {
190
+ large
191
+ }
192
+ }
193
+ }
194
+ }
195
+ staff {
196
+ edges {
197
+ id
198
+ role
199
+ favouriteOrder
200
+ node {
201
+ id
202
+ name {
203
+ full
204
+ native
205
+ }
206
+ image {
207
+ large
208
+ }
209
+ }
210
+ }
211
+ }
212
+ studios {
213
+ edges {
214
+ id
215
+ isMain
216
+ favouriteOrder
217
+ node {
218
+ id
219
+ name
220
+ isAnimationStudio
221
+ siteUrl
222
+ }
223
+ }
224
+ }
225
+ isFavourite
226
+ isAdult
227
+ nextAiringEpisode {
228
+ airingAt
229
+ timeUntilAiring
230
+ episode
231
+ }
232
+ externalLinks {
233
+ id
234
+ url
235
+ site
236
+ }
237
+ streamingEpisodes {
238
+ title
239
+ thumbnail
240
+ url
241
+ site
242
+ }
243
+ rankings {
244
+ id
245
+ rank
246
+ type
247
+ format
248
+ year
249
+ season
250
+ allTime
251
+ context
252
+ }
253
+ mediaListEntry {
254
+ id
255
+ status
256
+ }
257
+ stats {
258
+ scoreDistribution {
259
+ score
260
+ amount
261
+ }
262
+ statusDistribution {
263
+ status
264
+ amount
265
+ }
266
+ }
267
+ siteUrl
268
+ autoCreateForumThread
269
+ isRecommendationBlocked
270
+ modNotes
271
+ }
272
+ }
273
+ name
274
+ isCustomList
275
+ isSplitCompletedList
276
+ status
277
+ }
278
+ user {
279
+ id
280
+ name
281
+ about (asHtml: $asHtml)
282
+ avatar {
283
+ large
284
+ medium
285
+ }
286
+ bannerImage
287
+ isFollowing
288
+ isFollower
289
+ isBlocked
290
+ bans
291
+ options {
292
+ titleLanguage
293
+ displayAdultContent
294
+ airingNotifications
295
+ profileColor
296
+ notificationOptions {
297
+ type
298
+ enabled
299
+ }
300
+ timezone
301
+ activityMergeTime
302
+ staffNameLanguage
303
+ restrictMessagesToFollowing
304
+ disabledListActivity {
305
+ disabled
306
+ type
307
+ }
308
+ }
309
+ mediaListOptions {
310
+ scoreFormat
311
+ rowOrder
312
+ animeList {
313
+ sectionOrder
314
+ splitCompletedSectionByFormat
315
+ customLists
316
+ advancedScoring
317
+ advancedScoringEnabled
318
+ }
319
+ mangaList {
320
+ sectionOrder
321
+ splitCompletedSectionByFormat
322
+ customLists
323
+ advancedScoring
324
+ advancedScoringEnabled
325
+ }
326
+ }
327
+ favourites {
328
+ anime (perPage: 50) {
329
+ edges {
330
+ node {
331
+ id
332
+ title {
333
+ romaji
334
+ english
335
+ native
336
+ }
337
+ }
338
+ }
339
+ nodes {
340
+ id
341
+ title {
342
+ romaji
343
+ english
344
+ native
345
+ userPreferred
346
+ }
347
+ }
348
+ }
349
+ manga (perPage: 50) {
350
+ edges {
351
+ node {
352
+ id
353
+ title {
354
+ romaji
355
+ english
356
+ native
357
+ userPreferred
358
+ }
359
+ }
360
+ }
361
+ nodes {
362
+ id
363
+ title {
364
+ romaji
365
+ english
366
+ native
367
+ userPreferred
368
+ }
369
+ }
370
+ }
371
+ characters (perPage: 50) {
372
+ edges {
373
+ id
374
+ role
375
+ name
376
+ voiceActors {
377
+ id
378
+ name {
379
+ full
380
+ native
381
+ }
382
+ image {
383
+ large
384
+ }
385
+ }
386
+ media {
387
+ id
388
+ title {
389
+ romaji
390
+ english
391
+ native
392
+ }
393
+ coverImage {
394
+ extraLarge
395
+ large
396
+ medium
397
+ color
398
+ }
399
+ }
400
+ favouriteOrder
401
+ node {
402
+ id
403
+ name {
404
+ full
405
+ native
406
+ }
407
+ image {
408
+ large
409
+ }
410
+ }
411
+ }
412
+ }
413
+ staff (perPage: 50) {
414
+ edges {
415
+ id
416
+ role
417
+ favouriteOrder
418
+ node {
419
+ id
420
+ name {
421
+ full
422
+ native
423
+ }
424
+ image {
425
+ large
426
+ }
427
+ }
428
+ }
429
+ }
430
+ studios (perPage: 50) {
431
+ edges {
432
+ id
433
+ isMain
434
+ favouriteOrder
435
+ node {
436
+ id
437
+ name
438
+ isAnimationStudio
439
+ siteUrl
440
+ }
441
+ }
442
+ }
443
+ }
444
+ statistics {
445
+ anime {
446
+ count
447
+ meanScore
448
+ standardDeviation
449
+ minutesWatched
450
+ episodesWatched
451
+ formats (limit: $animeStatLimit, sort: $animeStatSort) {
452
+ count
453
+ meanScore
454
+ minutesWatched
455
+ mediaIds
456
+ format
457
+ }
458
+ statuses (limit: $animeStatLimit, sort: $animeStatSort) {
459
+ count
460
+ meanScore
461
+ minutesWatched
462
+ mediaIds
463
+ status
464
+ }
465
+ scores (limit: $animeStatLimit, sort: $animeStatSort) {
466
+ count
467
+ meanScore
468
+ minutesWatched
469
+ mediaIds
470
+ score
471
+ }
472
+ lengths (limit: $animeStatLimit, sort: $animeStatSort) {
473
+ count
474
+ meanScore
475
+ minutesWatched
476
+ mediaIds
477
+ length
478
+ }
479
+ releaseYears (limit: $animeStatLimit, sort: $animeStatSort) {
480
+ count
481
+ meanScore
482
+ minutesWatched
483
+ mediaIds
484
+ releaseYear
485
+ }
486
+ startYears (limit: $animeStatLimit, sort: $animeStatSort) {
487
+ count
488
+ meanScore
489
+ minutesWatched
490
+ mediaIds
491
+ startYear
492
+ }
493
+ genres (limit: $animeStatLimit, sort: $animeStatSort) {
494
+ count
495
+ meanScore
496
+ minutesWatched
497
+ mediaIds
498
+ genre
499
+ }
500
+ tags (limit: $animeStatLimit, sort: $animeStatSort) {
501
+ count
502
+ meanScore
503
+ minutesWatched
504
+ mediaIds
505
+ tag {
506
+ id
507
+ name
508
+ description
509
+ category
510
+ rank
511
+ isGeneralSpoiler
512
+ isMediaSpoiler
513
+ isAdult
514
+ }
515
+ }
516
+ countries (limit: $animeStatLimit, sort: $animeStatSort) {
517
+ count
518
+ meanScore
519
+ minutesWatched
520
+ mediaIds
521
+ country
522
+ }
523
+ voiceActors (limit: $animeStatLimit, sort: $animeStatSort) {
524
+ count
525
+ meanScore
526
+ minutesWatched
527
+ mediaIds
528
+ voiceActor {
529
+ id
530
+ name {
531
+ full
532
+ native
533
+ }
534
+ }
535
+ characterIds
536
+ }
537
+ staff (limit: $animeStatLimit, sort: $animeStatSort) {
538
+ count
539
+ meanScore
540
+ minutesWatched
541
+ mediaIds
542
+ staff {
543
+ id
544
+ name {
545
+ full
546
+ native
547
+ }
548
+ }
549
+ }
550
+ studios (limit: $animeStatLimit, sort: $animeStatSort) {
551
+ count
552
+ meanScore
553
+ minutesWatched
554
+ mediaIds
555
+ studio {
556
+ id
557
+ name
558
+ }
559
+ }
560
+ }
561
+ manga {
562
+ count
563
+ meanScore
564
+ standardDeviation
565
+ chaptersRead
566
+ volumesRead
567
+ formats (limit: $mangaStatLimit, sort: $mangaStatSort) {
568
+ count
569
+ meanScore
570
+ chaptersRead
571
+ mediaIds
572
+ format
573
+ }
574
+ statuses (limit: $mangaStatLimit, sort: $mangaStatSort) {
575
+ count
576
+ meanScore
577
+ chaptersRead
578
+ mediaIds
579
+ status
580
+ }
581
+ scores (limit: $mangaStatLimit, sort: $mangaStatSort) {
582
+ count
583
+ meanScore
584
+ chaptersRead
585
+ mediaIds
586
+ score
587
+ }
588
+ lengths (limit: $mangaStatLimit, sort: $mangaStatSort) {
589
+ count
590
+ meanScore
591
+ chaptersRead
592
+ mediaIds
593
+ length
594
+ }
595
+ releaseYears (limit: $mangaStatLimit, sort: $mangaStatSort) {
596
+ count
597
+ meanScore
598
+ chaptersRead
599
+ mediaIds
600
+ releaseYear
601
+ }
602
+ startYears (limit: $mangaStatLimit, sort: $mangaStatSort) {
603
+ count
604
+ meanScore
605
+ chaptersRead
606
+ mediaIds
607
+ startYear
608
+ }
609
+ genres (limit: $mangaStatLimit, sort: $mangaStatSort) {
610
+ count
611
+ meanScore
612
+ chaptersRead
613
+ mediaIds
614
+ genre
615
+ }
616
+ tags (limit: $mangaStatLimit, sort: $mangaStatSort) {
617
+ count
618
+ meanScore
619
+ chaptersRead
620
+ mediaIds
621
+ tag {
622
+ id
623
+ name
624
+ description
625
+ category
626
+ rank
627
+ isGeneralSpoiler
628
+ isMediaSpoiler
629
+ isAdult
630
+ }
631
+ }
632
+ countries (limit: $mangaStatLimit, sort: $mangaStatSort) {
633
+ count
634
+ meanScore
635
+ chaptersRead
636
+ mediaIds
637
+ country
638
+ }
639
+ staff (limit: $mangaStatLimit, sort: $mangaStatSort) {
640
+ count
641
+ meanScore
642
+ chaptersRead
643
+ mediaIds
644
+ staff {
645
+ id
646
+ name {
647
+ full
648
+ native
649
+ }
650
+ }
651
+ }
652
+ studios (limit: $mangaStatLimit, sort: $mangaStatSort) {
653
+ count
654
+ meanScore
655
+ chaptersRead
656
+ mediaIds
657
+ studio {
658
+ id
659
+ name
660
+ }
661
+ }
662
+ }
663
+ }
664
+ }
665
+ hasNextChunk
666
+ }
667
+ }
668
+ `
669
+
670
+ const data = { query, variables }
671
+ return await sendRequest(this.baseURL, 'POST', data, this.authToken)
672
+ }
673
+ }