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,72 @@
1
+ import { Image } from '../Image'
2
+ import { Statistics } from '../Statistics'
3
+ import { UserStats } from '../UserStats'
4
+
5
+ export interface UserResponse {
6
+ id: number
7
+ name: string
8
+ about: string
9
+ avatar: Image
10
+ bannerImage: string
11
+ isFollowing: boolean
12
+ isFollower: boolean
13
+ isBlocked: boolean
14
+ bans: any[]
15
+ options: {
16
+ titleLanguage: string
17
+ displayAdultContent: boolean
18
+ airingNotifications: boolean
19
+ profileColor: string
20
+ notificationOptions: Array<{
21
+ type: string
22
+ enabled: boolean
23
+ }>
24
+ timezone: string
25
+ activityMergeTime: number
26
+ staffNameLanguage: string
27
+ restrictMessagesToFollowing: boolean
28
+ disabledListActivity: Array<{
29
+ disabled: boolean
30
+ type: string
31
+ }>
32
+ }
33
+ mediaListOptions: {
34
+ scoreFormat: string
35
+ rowOrder: string
36
+ animeList: {
37
+ sectionOrder: string[]
38
+ splitCompletedSectionByFormat: boolean
39
+ customLists: string[]
40
+ advancedScoring: string[]
41
+ advancedScoringEnabled: boolean
42
+ }
43
+ mangaList: {
44
+ sectionOrder: string[]
45
+ splitCompletedSectionByFormat: boolean
46
+ customLists: string[]
47
+ advancedScoring: string[]
48
+ advancedScoringEnabled: boolean
49
+ }
50
+ }
51
+ favourites: {
52
+ anime: any[]
53
+ manga: any[]
54
+ characters: any[]
55
+ staff: any[]
56
+ studios: any[]
57
+ }
58
+ statistics: Statistics
59
+ stats: UserStats
60
+ unreadNotificationCount: number
61
+ siteUrl: string
62
+ donatorTier: number
63
+ donatorBadge: string
64
+ moderatorRoles: string[]
65
+ createdAt: number
66
+ updatedAt: number
67
+ previousNames: Array<{
68
+ name: string
69
+ createdAt: number
70
+ updatedAt: number
71
+ }>
72
+ }
@@ -0,0 +1,162 @@
1
+ import { APIWrapper } from '../../../base/APIWrapper'
2
+ import { sendRequest } from '../../../base/RequestHandler'
3
+
4
+ export type UserTitleLanguage =
5
+ 'ROMAJI'
6
+ | 'ENGLISH'
7
+ | 'NATIVE'
8
+ | 'ROMAJI_STYLISED'
9
+ | 'ENGLISH_STYLISED'
10
+ | 'NATIVE_STYLISED'
11
+ export type ScoreFormat = 'POINT_100' | 'POINT_10_DECIMAL' | 'POINT_10' | 'POINT_5' | 'POINT_3'
12
+ export type UserStaffNameLanguage =
13
+ 'ROMAJI'
14
+ | 'ENGLISH'
15
+ | 'NATIVE'
16
+ | 'ROMAJI_STYLISED'
17
+ | 'ENGLISH_STYLISED'
18
+ | 'NATIVE_STYLISED'
19
+ export interface NotificationOptionInput { type: string, enabled: boolean }
20
+ export interface MediaListOptionsInput { scoreFormat: ScoreFormat, rowOrder: string, animeList: any, mangaList: any }
21
+ export type ListActivityOptionInput = 'ANIME_LIST' | 'MANGA_LIST'
22
+
23
+ interface UpdateUserVariables {
24
+ about?: string
25
+ titleLanguage?: UserTitleLanguage
26
+ displayAdultContent?: boolean
27
+ airingNotifications?: boolean
28
+ scoreFormat?: ScoreFormat
29
+ rowOrder?: string
30
+ profileColor?: string
31
+ donatorBadge?: string
32
+ notificationOptions?: NotificationOptionInput[]
33
+ timezone?: string
34
+ activityMergeTime?: number
35
+ animeListOptions?: MediaListOptionsInput
36
+ mangaListOptions?: MediaListOptionsInput
37
+ staffNameLanguage?: UserStaffNameLanguage
38
+ restrictMessagesToFollowing?: boolean
39
+ disabledListActivity?: ListActivityOptionInput[]
40
+ }
41
+
42
+ interface UpdateUserResponse {
43
+ id: number
44
+ name: string
45
+ about: string
46
+ avatar: {
47
+ large: string
48
+ medium: string
49
+ }
50
+ bannerImage: string
51
+ isFollowing: boolean
52
+ isFollower: boolean
53
+ isBlocked: boolean
54
+ bans: any[]
55
+ options: {
56
+ titleLanguage: string
57
+ displayAdultContent: boolean
58
+ airingNotifications: boolean
59
+ profileColor: string
60
+ notificationOptions: Array<{
61
+ type: string
62
+ enabled: boolean
63
+ }>
64
+ timezone: string
65
+ activityMergeTime: number
66
+ staffNameLanguage: string
67
+ restrictMessagesToFollowing: boolean
68
+ }
69
+ mediaListOptions: {
70
+ scoreFormat: string
71
+ rowOrder: string
72
+ animeList: {
73
+ sectionOrder: string[]
74
+ customLists: string[]
75
+ advancedScoring: string[]
76
+ advancedScoringEnabled: boolean
77
+ }
78
+ mangaList: {
79
+ sectionOrder: string[]
80
+ customLists: string[]
81
+ advancedScoring: string[]
82
+ advancedScoringEnabled: boolean
83
+ }
84
+ }
85
+ unreadNotificationCount: number
86
+ siteUrl: string
87
+ donatorTier: number
88
+ donatorBadge: string
89
+ moderatorRoles: string[]
90
+ createdAt: number
91
+ updatedAt: number
92
+ }
93
+
94
+ export class UpdateUserMutation extends APIWrapper {
95
+ private readonly authToken: string
96
+
97
+ constructor (authToken: string) {
98
+ super('https://graphql.anilist.co')
99
+ this.authToken = authToken
100
+ }
101
+
102
+ async updateUser (variables: UpdateUserVariables): Promise<UpdateUserResponse> {
103
+ const mutation = `
104
+ mutation ($about: String, $titleLanguage: UserTitleLanguage, $displayAdultContent: Boolean, $airingNotifications: Boolean, $scoreFormat: ScoreFormat, $rowOrder: String, $profileColor: String, $donatorBadge: String, $notificationOptions: [NotificationOptionInput], $timezone: String, $activityMergeTime: Int, $animeListOptions: MediaListOptionsInput, $mangaListOptions: MediaListOptionsInput, $staffNameLanguage: UserStaffNameLanguage, $restrictMessagesToFollowing: Boolean, $disabledListActivity: [ListActivityOptionInput]) {
105
+ UpdateUser(about: $about, titleLanguage: $titleLanguage, displayAdultContent: $displayAdultContent, airingNotifications: $airingNotifications, scoreFormat: $scoreFormat, rowOrder: $rowOrder, profileColor: $profileColor, donatorBadge: $donatorBadge, notificationOptions: $notificationOptions, timezone: $timezone, activityMergeTime: $activityMergeTime, animeListOptions: $animeListOptions, mangaListOptions: $mangaListOptions, staffNameLanguage: $staffNameLanguage, restrictMessagesToFollowing: $restrictMessagesToFollowing, disabledListActivity: $disabledListActivity) {
106
+ id
107
+ name
108
+ about
109
+ avatar {
110
+ large
111
+ medium
112
+ }
113
+ bannerImage
114
+ isFollowing
115
+ isFollower
116
+ isBlocked
117
+ bans
118
+ options {
119
+ titleLanguage
120
+ displayAdultContent
121
+ airingNotifications
122
+ profileColor
123
+ notificationOptions {
124
+ type
125
+ enabled
126
+ }
127
+ timezone
128
+ activityMergeTime
129
+ staffNameLanguage
130
+ restrictMessagesToFollowing
131
+ }
132
+ mediaListOptions {
133
+ scoreFormat
134
+ rowOrder
135
+ animeList {
136
+ sectionOrder
137
+ customLists
138
+ advancedScoring
139
+ advancedScoringEnabled
140
+ }
141
+ mangaList {
142
+ sectionOrder
143
+ customLists
144
+ advancedScoring
145
+ advancedScoringEnabled
146
+ }
147
+ }
148
+ unreadNotificationCount
149
+ siteUrl
150
+ donatorTier
151
+ donatorBadge
152
+ moderatorRoles
153
+ createdAt
154
+ updatedAt
155
+ }
156
+ }
157
+ `
158
+
159
+ const data = { query: mutation, variables }
160
+ return await sendRequest(this.baseURL, 'POST', data, this.authToken)
161
+ }
162
+ }
@@ -0,0 +1,160 @@
1
+ import { APIWrapper } from '../../../base/APIWrapper'
2
+ import { sendRequest } from '../../../base/RequestHandler'
3
+ import { AiringScheduleResponse } from '../interfaces/responses/AiringSchedule'
4
+
5
+ interface AiringScheduleVariables {
6
+ id?: number
7
+ mediaId?: number
8
+ episode?: number
9
+ airingAt?: number
10
+ notYetAired?: boolean
11
+ id_not?: number
12
+ id_in?: number[]
13
+ id_not_in?: number[]
14
+ mediaId_not?: number
15
+ mediaId_in?: number[]
16
+ mediaId_not_in?: number[]
17
+ episode_not?: number
18
+ episode_in?: number[]
19
+ episode_not_in?: number[]
20
+ episode_greater?: number
21
+ episode_lesser?: number
22
+ airingAt_greater?: number
23
+ airingAt_lesser?: number
24
+ sort?: string[]
25
+ }
26
+
27
+ export class AiringScheduleQuery extends APIWrapper {
28
+ private readonly authToken: string
29
+
30
+ constructor (authToken: string) {
31
+ super('https://graphql.anilist.co')
32
+ this.authToken = authToken
33
+ }
34
+
35
+ async airingSchedule (variables?: AiringScheduleVariables): Promise<AiringScheduleResponse> {
36
+ const query = `
37
+ query ($id: Int, $mediaId: Int, $episode: Int, $airingAt: Int, $notYetAired: Boolean, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $mediaId_not: Int, $mediaId_in: [Int], $mediaId_not_in: [Int], $episode_not: Int, $episode_in: [Int], $episode_not_in: [Int], $episode_greater: Int, $episode_lesser: Int, $airingAt_greater: Int, $airingAt_lesser: Int, $sort: [AiringSort]) {
38
+ AiringSchedule (id: $id, mediaId: $mediaId, episode: $episode, airingAt: $airingAt, notYetAired: $notYetAired, id_not: $id_not, id_in: $id_in, id_not_in: $id_not_in, mediaId_not: $mediaId_not, mediaId_in: $mediaId_in, mediaId_not_in: $mediaId_not_in, episode_not: $episode_not, episode_in: $episode_in, episode_not_in: $episode_not_in, episode_greater: $episode_greater, episode_lesser: $episode_lesser, airingAt_greater: $airingAt_greater, airingAt_lesser: $airingAt_lesser, sort: $sort) {
39
+ id
40
+ airingAt
41
+ timeUntilAiring
42
+ episode
43
+ mediaId
44
+ media {
45
+ id
46
+ idMal
47
+ title {
48
+ romaji
49
+ english
50
+ native
51
+ userPreferred
52
+ }
53
+ type
54
+ format
55
+ status
56
+ description
57
+ startDate {
58
+ year
59
+ month
60
+ day
61
+ }
62
+ endDate {
63
+ year
64
+ month
65
+ day
66
+ }
67
+ season
68
+ seasonYear
69
+ seasonInt
70
+ episodes
71
+ duration
72
+ countryOfOrigin
73
+ isLicensed
74
+ source
75
+ hashtag
76
+ trailer {
77
+ id
78
+ site
79
+ thumbnail
80
+ }
81
+ updatedAt
82
+ coverImage {
83
+ extraLarge
84
+ large
85
+ medium
86
+ color
87
+ }
88
+ bannerImage
89
+ genres
90
+ synonyms
91
+ averageScore
92
+ meanScore
93
+ popularity
94
+ isLocked
95
+ trending
96
+ favourites
97
+ tags {
98
+ id
99
+ name
100
+ description
101
+ rank
102
+ isGeneralSpoiler
103
+ isMediaSpoiler
104
+ isAdult
105
+ }
106
+ isFavourite
107
+ isAdult
108
+ nextAiringEpisode {
109
+ airingAt
110
+ timeUntilAiring
111
+ episode
112
+ }
113
+ externalLinks {
114
+ id
115
+ url
116
+ site
117
+ }
118
+ streamingEpisodes {
119
+ title
120
+ thumbnail
121
+ url
122
+ site
123
+ }
124
+ rankings {
125
+ id
126
+ rank
127
+ type
128
+ format
129
+ year
130
+ season
131
+ allTime
132
+ context
133
+ }
134
+ mediaListEntry {
135
+ id
136
+ status
137
+ }
138
+ stats {
139
+ scoreDistribution {
140
+ score
141
+ amount
142
+ }
143
+ statusDistribution {
144
+ status
145
+ amount
146
+ }
147
+ }
148
+ siteUrl
149
+ autoCreateForumThread
150
+ isRecommendationBlocked
151
+ modNotes
152
+ }
153
+ }
154
+ }
155
+ `
156
+
157
+ const data = { query, variables }
158
+ return await sendRequest(this.baseURL, 'POST', data, this.authToken)
159
+ }
160
+ }
@@ -0,0 +1,75 @@
1
+ import { APIWrapper } from '../../../base/APIWrapper'
2
+ import { sendRequest } from '../../../base/RequestHandler'
3
+ import { CharacterResponse } from '../interfaces/responses/Character'
4
+
5
+ interface CharacterVariables {
6
+ id?: number
7
+ isBirthday?: boolean
8
+ search?: string
9
+ id_not?: number
10
+ id_in?: number[]
11
+ id_not_in?: number[]
12
+ sort?: string[]
13
+ asHtml?: boolean
14
+ mediaSort?: string[]
15
+ mediaOnList?: boolean
16
+ mediaPage?: number
17
+ mediaPerPage?: number
18
+ }
19
+
20
+ export class CharacterQuery extends APIWrapper {
21
+ private readonly authToken: string
22
+
23
+ constructor (authToken: string) {
24
+ super('https://graphql.anilist.co')
25
+ this.authToken = authToken
26
+ }
27
+
28
+ async character (variables?: CharacterVariables): Promise<CharacterResponse> {
29
+ const query = `
30
+ query ($id: Int, $isBirthday: Boolean, $search: String, $id_not: Int, $id_in: [Int], $id_not_in: [Int], $sort: [CharacterSort], $asHtml: Boolean, $mediaSort: [MediaSort], $mediaOnList: Boolean, $mediaPage: Int, $mediaPerPage: Int) {
31
+ Character (id: $id, isBirthday: $isBirthday, search: $search, id_not: $id_not, id_in: $id_in, id_not_in: $id_not_in, sort: $sort) {
32
+ id
33
+ name {
34
+ first
35
+ last
36
+ full
37
+ native
38
+ }
39
+ image {
40
+ large
41
+ medium
42
+ }
43
+ description(asHtml: $asHtml)
44
+ gender
45
+ dateOfBirth {
46
+ year
47
+ month
48
+ day
49
+ }
50
+ age
51
+ bloodType
52
+ isFavourite
53
+ isFavouriteBlocked
54
+ siteUrl
55
+ media(sort: $mediaSort, onList: $mediaOnList, page: $mediaPage, perPage: $mediaPerPage) {
56
+ nodes {
57
+ id
58
+ title {
59
+ romaji
60
+ english
61
+ native
62
+ userPreferred
63
+ }
64
+ }
65
+ }
66
+ favourites
67
+ modNotes
68
+ }
69
+ }
70
+ `
71
+
72
+ const data = { query, variables }
73
+ return await sendRequest(this.baseURL, 'POST', data, this.authToken)
74
+ }
75
+ }