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,295 @@
1
+ import { APIWrapper } from '../../../base/APIWrapper'
2
+ import { sendRequest } from '../../../base/RequestHandler'
3
+ import { MediaResponse } from '../interfaces/responses/Media'
4
+
5
+ interface MediaVariables {
6
+ id?: number
7
+ idMal?: number
8
+ startDate?: number
9
+ endDate?: number
10
+ season?: string
11
+ seasonYear?: number
12
+ type?: 'ANIME' | 'MANGA'
13
+ format?: string
14
+ status?: string
15
+ episodes?: number
16
+ duration?: number
17
+ chapters?: number
18
+ volumes?: number
19
+ isAdult?: boolean
20
+ genre?: string
21
+ tag?: string
22
+ minimumTagRank?: number
23
+ tagCategory?: string
24
+ onList?: boolean
25
+ licensedBy?: string
26
+ licensedById?: number
27
+ averageScore?: number
28
+ popularity?: number
29
+ source?: string
30
+ countryOfOrigin?: string
31
+ isLicensed?: boolean
32
+ search?: string
33
+ id_not?: number
34
+ id_in?: number[]
35
+ id_not_in?: number[]
36
+ idMal_not?: number
37
+ idMal_in?: number[]
38
+ idMal_not_in?: number[]
39
+ startDate_greater?: number
40
+ startDate_lesser?: number
41
+ startDate_like?: string
42
+ endDate_greater?: number
43
+ endDate_lesser?: number
44
+ endDate_like?: string
45
+ format_in?: string[]
46
+ format_not?: string
47
+ format_not_in?: string[]
48
+ status_in?: string[]
49
+ status_not?: string
50
+ status_not_in?: string[]
51
+ episodes_greater?: number
52
+ episodes_lesser?: number
53
+ duration_greater?: number
54
+ duration_lesser?: number
55
+ chapters_greater?: number
56
+ chapters_lesser?: number
57
+ volumes_greater?: number
58
+ volumes_lesser?: number
59
+ genre_in?: string[]
60
+ genre_not_in?: string[]
61
+ tag_in?: string[]
62
+ tag_not_in?: string[]
63
+ tagCategory_in?: string[]
64
+ tagCategory_not_in?: string[]
65
+ licensedBy_in?: string[]
66
+ licensedById_in?: number[]
67
+ averageScore_not?: number
68
+ averageScore_greater?: number
69
+ averageScore_lesser?: number
70
+ popularity_not?: number
71
+ popularity_greater?: number
72
+ popularity_lesser?: number
73
+ source_in?: string[]
74
+ sort?: string[]
75
+ }
76
+
77
+ export class MediaQuery extends APIWrapper {
78
+ private readonly authToken: string
79
+
80
+ constructor (authToken: string) {
81
+ super('https://graphql.anilist.co')
82
+ this.authToken = authToken
83
+ }
84
+
85
+ async media (variables?: MediaVariables): Promise<MediaResponse> {
86
+ const query = `
87
+ query ($id: Int, $idMal: Int, $startDate: FuzzyDateInt, $endDate: FuzzyDateInt, $season: MediaSeason, $seasonYear: Int, $type: MediaType, $format: MediaFormat, $status: MediaStatus, $episodes: Int, $duration: Int, $chapters: Int, $volumes: Int, $isAdult: Boolean, $genre: String, $tag: String, $minimumTagRank: Int, $tagCategory: String, $onList: Boolean, $licensedBy: String, $licensedById: Int, $averageScore: Int, $popularity: Int, $source: MediaSource, $countryOfOrigin: CountryCode, $isLicensed: Boolean, $search: String, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $idMal_not: Int, $idMal_in: [Int], $idMal_not_in: [Int], $startDate_greater: FuzzyDateInt, $startDate_lesser: FuzzyDateInt, $startDate_like: String, $endDate_greater: FuzzyDateInt, $endDate_lesser: FuzzyDateInt, $endDate_like: String, $format_in: [MediaFormat], $format_not: MediaFormat, $format_not_in: [MediaFormat], $status_in: [MediaStatus], $status_not: MediaStatus, $status_not_in: [MediaStatus], $episodes_greater: Int, $episodes_lesser: Int, $duration_greater: Int, $duration_lesser: Int, $chapters_greater: Int, $chapters_lesser: Int, $volumes_greater: Int, $volumes_lesser: Int, $genre_in: [String], $genre_not_in: [String], $tag_in: [String], $tag_not_in: [String], $tagCategory_in: [String], $tagCategory_not_in: [String], $licensedBy_in: [String], $licensedById_in: [Int], $averageScore_not: Int, $averageScore_greater: Int, $averageScore_lesser: Int, $popularity_not: Int, $popularity_greater: Int, $popularity_lesser: Int, $source_in: [MediaSource], $sort: [MediaSort]) {
88
+ Media (id: $id, idMal: $idMal, startDate: $startDate, endDate: $endDate, season: $season, seasonYear: $seasonYear, type: $type, format: $format, status: $status, episodes: $episodes, duration: $duration, chapters: $chapters, volumes: $volumes, isAdult: $isAdult, genre: $genre, tag: $tag, minimumTagRank: $minimumTagRank, tagCategory: $tagCategory, onList: $onList, licensedBy: $licensedBy, licensedById: $licensedById, averageScore: $averageScore, popularity: $popularity, source: $source, countryOfOrigin: $countryOfOrigin, isLicensed: $isLicensed, search: $search, id_not: $id_not, id_in: $id_in, id_not_in: $id_not_in, idMal_not: $idMal_not, idMal_in: $idMal_in, idMal_not_in: $idMal_not_in, startDate_greater: $startDate_greater, startDate_lesser: $startDate_lesser, startDate_like: $startDate_like, endDate_greater: $endDate_greater, endDate_lesser: $endDate_lesser, endDate_like: $endDate_like, format_in: $format_in, format_not: $format_not, format_not_in: $format_not_in, status_in: $status_in, status_not: $status_not, status_not_in: $status_not_in, episodes_greater: $episodes_greater, episodes_lesser: $episodes_lesser, duration_greater: $duration_greater, duration_lesser: $duration_lesser, chapters_greater: $chapters_greater, chapters_lesser: $chapters_lesser, volumes_greater: $volumes_greater, volumes_lesser: $volumes_lesser, genre_in: $genre_in, genre_not_in: $genre_not_in, tag_in: $tag_in, tag_not_in: $tag_not_in, tagCategory_in: $tagCategory_in, tagCategory_not_in: $tagCategory_not_in, licensedBy_in: $licensedBy_in, licensedById_in: $licensedById_in, averageScore_not: $averageScore_not, averageScore_greater: $averageScore_greater, averageScore_lesser: $averageScore_lesser, popularity_not: $popularity_not, popularity_greater: $popularity_greater, popularity_lesser: $popularity_lesser, source_in: $source_in, sort: $sort) {
89
+ id
90
+ idMal
91
+ title {
92
+ romaji
93
+ english
94
+ native
95
+ userPreferred
96
+ }
97
+ type
98
+ format
99
+ status
100
+ description
101
+ startDate {
102
+ year
103
+ month
104
+ day
105
+ }
106
+ endDate {
107
+ year
108
+ month
109
+ day
110
+ }
111
+ season
112
+ seasonYear
113
+ seasonInt
114
+ ${variables?.type === 'ANIME' ? 'episodes\nduration' : 'chapters\nvolumes'}
115
+ countryOfOrigin
116
+ isLicensed
117
+ source
118
+ hashtag
119
+ trailer {
120
+ id
121
+ site
122
+ thumbnail
123
+ }
124
+ updatedAt
125
+ coverImage {
126
+ extraLarge
127
+ large
128
+ medium
129
+ color
130
+ }
131
+ bannerImage
132
+ genres
133
+ synonyms
134
+ averageScore
135
+ meanScore
136
+ popularity
137
+ isLocked
138
+ trending
139
+ favourites
140
+ tags {
141
+ id
142
+ name
143
+ description
144
+ rank
145
+ isGeneralSpoiler
146
+ isMediaSpoiler
147
+ isAdult
148
+ }
149
+ relations {
150
+ edges {
151
+ relationType
152
+ node {
153
+ id
154
+ title {
155
+ romaji
156
+ english
157
+ native
158
+ userPreferred
159
+ }
160
+ }
161
+ }
162
+ }
163
+ characters {
164
+ edges {
165
+ id
166
+ role
167
+ name
168
+ voiceActors {
169
+ id
170
+ name {
171
+ first
172
+ last
173
+ full
174
+ native
175
+ }
176
+ image {
177
+ large
178
+ }
179
+ }
180
+ media {
181
+ id
182
+ title {
183
+ romaji
184
+ english
185
+ native
186
+ userPreferred
187
+ }
188
+ coverImage {
189
+ extraLarge
190
+ large
191
+ medium
192
+ color
193
+ }
194
+ }
195
+ favouriteOrder
196
+ node {
197
+ id
198
+ name {
199
+ first
200
+ last
201
+ full
202
+ native
203
+ }
204
+ image {
205
+ large
206
+ }
207
+ }
208
+ }
209
+ }
210
+ staff {
211
+ edges {
212
+ id
213
+ role
214
+ favouriteOrder
215
+ node {
216
+ id
217
+ name {
218
+ first
219
+ last
220
+ full
221
+ native
222
+ }
223
+ image {
224
+ large
225
+ }
226
+ }
227
+ }
228
+ }
229
+ studios {
230
+ edges {
231
+ id
232
+ isMain
233
+ favouriteOrder
234
+ node {
235
+ id
236
+ name
237
+ isAnimationStudio
238
+ siteUrl
239
+ }
240
+ }
241
+ }
242
+ isFavourite
243
+ isAdult
244
+ nextAiringEpisode {
245
+ airingAt
246
+ timeUntilAiring
247
+ episode
248
+ }
249
+ externalLinks {
250
+ id
251
+ url
252
+ site
253
+ }
254
+ streamingEpisodes {
255
+ title
256
+ thumbnail
257
+ url
258
+ site
259
+ }
260
+ rankings {
261
+ id
262
+ rank
263
+ type
264
+ format
265
+ year
266
+ season
267
+ allTime
268
+ context
269
+ }
270
+ mediaListEntry {
271
+ id
272
+ status
273
+ }
274
+ stats {
275
+ scoreDistribution {
276
+ score
277
+ amount
278
+ }
279
+ statusDistribution {
280
+ status
281
+ amount
282
+ }
283
+ }
284
+ siteUrl
285
+ autoCreateForumThread
286
+ isRecommendationBlocked
287
+ modNotes
288
+ }
289
+ }
290
+ `
291
+
292
+ const data = { query, variables }
293
+ return await sendRequest(this.baseURL, 'POST', data, this.authToken)
294
+ }
295
+ }
@@ -0,0 +1,192 @@
1
+ import { APIWrapper } from '../../../base/APIWrapper'
2
+ import { sendRequest } from '../../../base/RequestHandler'
3
+ import { MediaListResponse } from '../interfaces/responses/MediaList'
4
+
5
+ interface MediaListVariables {
6
+ id?: number
7
+ userId?: number
8
+ userName?: string
9
+ type?: string
10
+ status?: string
11
+ mediaId?: number
12
+ isFollowing?: boolean
13
+ notes?: string
14
+ startedAt?: number
15
+ completedAt?: number
16
+ compareWithAuthList?: boolean
17
+ userId_in?: number[]
18
+ status_in?: string[]
19
+ status_not_in?: string[]
20
+ status_not?: string
21
+ mediaId_in?: number[]
22
+ mediaId_not_in?: number[]
23
+ notes_like?: string
24
+ startedAt_greater?: number
25
+ startedAt_lesser?: number
26
+ startedAt_like?: string
27
+ completedAt_greater?: number
28
+ completedAt_lesser?: number
29
+ completedAt_like?: string
30
+ sort?: string[]
31
+ scoreFormat?: string
32
+ asArray?: boolean
33
+ asHtml?: boolean
34
+ }
35
+
36
+ export class MediaListQuery extends APIWrapper {
37
+ private readonly authToken: string
38
+
39
+ constructor (authToken: string) {
40
+ super('https://graphql.anilist.co')
41
+ this.authToken = authToken
42
+ }
43
+
44
+ async mediaList (variables?: MediaListVariables): Promise<MediaListResponse> {
45
+ const query = `
46
+ query ($id: Int, $userId: Int, $userName: String, $type: MediaType, $status: MediaListStatus, $mediaId: Int, $isFollowing: Boolean, $notes: String, $startedAt: FuzzyDateInt, $completedAt: FuzzyDateInt, $compareWithAuthList: Boolean, $userId_in: [Int], $status_in: [MediaListStatus], $status_not_in: [MediaListStatus], $status_not: MediaListStatus, $mediaId_in: [Int], $mediaId_not_in: [Int], $notes_like: String, $startedAt_greater: FuzzyDateInt, $startedAt_lesser: FuzzyDateInt, $startedAt_like: String, $completedAt_greater: FuzzyDateInt, $completedAt_lesser: FuzzyDateInt, $completedAt_like: String, $ScoreFormat: ScoreFormat, $asArray: Boolean, $asHtml: Boolean) {
47
+ MediaList (id: $id, userId: $userId, userName: $userName, type: $type, status: $status, mediaId: $mediaId, isFollowing: $isFollowing, notes: $notes, startedAt: $startedAt, completedAt: $completedAt, compareWithAuthList: $compareWithAuthList, userId_in: $userId_in, status_in: $status_in, status_not_in: $status_not_in, status_not: $status_not, mediaId_in: $mediaId_in, mediaId_not_in: $mediaId_not_in, 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) {
48
+ id
49
+ userId
50
+ mediaId
51
+ status
52
+ score (format: $ScoreFormat)
53
+ progress
54
+ progressVolumes
55
+ repeat
56
+ priority
57
+ private
58
+ notes
59
+ hiddenFromStatusLists
60
+ customLists (asArray: $asArray)
61
+ advancedScores
62
+ startedAt {
63
+ year
64
+ month
65
+ day
66
+ }
67
+ completedAt {
68
+ year
69
+ month
70
+ day
71
+ }
72
+ updatedAt
73
+ createdAt
74
+ media {
75
+ id
76
+ idMal
77
+ title {
78
+ romaji
79
+ english
80
+ native
81
+ userPreferred
82
+ }
83
+ type
84
+ format
85
+ status
86
+ description (asHtml: $asHtml)
87
+ startDate {
88
+ year
89
+ month
90
+ day
91
+ }
92
+ endDate {
93
+ year
94
+ month
95
+ day
96
+ }
97
+ season
98
+ seasonYear
99
+ seasonInt
100
+ episodes
101
+ duration
102
+ chapters
103
+ volumes
104
+ countryOfOrigin
105
+ isLicensed
106
+ source
107
+ hashtag
108
+ trailer {
109
+ id
110
+ site
111
+ thumbnail
112
+ }
113
+ updatedAt
114
+ coverImage {
115
+ extraLarge
116
+ large
117
+ medium
118
+ color
119
+ }
120
+ bannerImage
121
+ genres
122
+ synonyms
123
+ averageScore
124
+ meanScore
125
+ popularity
126
+ isLocked
127
+ trending
128
+ favourites
129
+ tags {
130
+ id
131
+ name
132
+ description
133
+ category
134
+ rank
135
+ isGeneralSpoiler
136
+ isMediaSpoiler
137
+ isAdult
138
+ }
139
+ isFavourite
140
+ isFavouriteBlocked
141
+ isAdult
142
+ nextAiringEpisode {
143
+ id
144
+ airingAt
145
+ timeUntilAiring
146
+ episode
147
+ }
148
+ externalLinks {
149
+ id
150
+ url
151
+ site
152
+ }
153
+ streamingEpisodes {
154
+ title
155
+ thumbnail
156
+ url
157
+ site
158
+ }
159
+ rankings {
160
+ id
161
+ rank
162
+ type
163
+ format
164
+ year
165
+ season
166
+ allTime
167
+ context
168
+ }
169
+ stats {
170
+ scoreDistribution {
171
+ score
172
+ amount
173
+ }
174
+ statusDistribution {
175
+ status
176
+ amount
177
+ }
178
+ }
179
+ siteUrl
180
+ autoCreateForumThread
181
+ isRecommendationBlocked
182
+ isReviewBlocked
183
+ modNotes
184
+ }
185
+ }
186
+ }
187
+ `
188
+
189
+ const data = { query, variables }
190
+ return await sendRequest(this.baseURL, 'POST', data, this.authToken)
191
+ }
192
+ }