@irfanshadikrishad/anilist 1.0.0 → 1.0.2

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.
@@ -8,12 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import fetch from "node-fetch";
11
- import { userQuery } from "./queries.js";
12
- import { isLoggedIn, retriveAccessToken } from "./auth.js";
13
- import { aniListEndpoint } from "./workers.js";
11
+ import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, mangaSearchQuery, userActivityQuery, userQuery, } from "./queries.js";
12
+ import { currentUsersId, isLoggedIn, retriveAccessToken } from "./auth.js";
13
+ import { aniListEndpoint, formatDateObject, getTitle, removeHtmlAndMarkdown, } from "./workers.js";
14
+ import { fetcher } from "./fetcher.js";
15
+ import inquirer from "inquirer";
16
+ import { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, } from "./mutations.js";
14
17
  function getUserInfoByUsername(username) {
15
18
  return __awaiter(this, void 0, void 0, function* () {
16
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
19
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
17
20
  try {
18
21
  const loggedIn = yield isLoggedIn();
19
22
  let headers = {
@@ -30,6 +33,12 @@ function getUserInfoByUsername(username) {
30
33
  const response = yield request.json();
31
34
  if (request.status === 200) {
32
35
  const user = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.User;
36
+ const responseUserActivity = yield fetcher(userActivityQuery, {
37
+ id: user === null || user === void 0 ? void 0 : user.id,
38
+ page: 1,
39
+ perPage: 10,
40
+ });
41
+ const activities = ((_c = (_b = responseUserActivity === null || responseUserActivity === void 0 ? void 0 : responseUserActivity.data) === null || _b === void 0 ? void 0 : _b.Page) === null || _c === void 0 ? void 0 : _c.activities) || [];
33
42
  console.log(`\nID:\t\t${user === null || user === void 0 ? void 0 : user.id}`);
34
43
  console.log(`Name:\t\t${user === null || user === void 0 ? void 0 : user.name}`);
35
44
  console.log(`siteUrl:\t${user === null || user === void 0 ? void 0 : user.siteUrl}`);
@@ -43,13 +52,20 @@ function getUserInfoByUsername(username) {
43
52
  console.log(`I blocked?\t${user === null || user === void 0 ? void 0 : user.isBlocked}`);
44
53
  console.log(`My follower:\t${user === null || user === void 0 ? void 0 : user.isFollower}`);
45
54
  console.log(`I'm following:\t${user === null || user === void 0 ? void 0 : user.isFollowing}`);
46
- console.log(`Color:\t${(_b = user === null || user === void 0 ? void 0 : user.options) === null || _b === void 0 ? void 0 : _b.profileColor}`);
47
- console.log(`Timezone:\t${(_c = user === null || user === void 0 ? void 0 : user.options) === null || _c === void 0 ? void 0 : _c.timezone}`);
48
- console.log(`Statistics (Anime)\nCount: ${(_e = (_d = user === null || user === void 0 ? void 0 : user.statistics) === null || _d === void 0 ? void 0 : _d.anime) === null || _e === void 0 ? void 0 : _e.count} episodesWatched: ${(_g = (_f = user === null || user === void 0 ? void 0 : user.statistics) === null || _f === void 0 ? void 0 : _f.anime) === null || _g === void 0 ? void 0 : _g.episodesWatched} minutesWatched: ${(_j = (_h = user === null || user === void 0 ? void 0 : user.statistics) === null || _h === void 0 ? void 0 : _h.anime) === null || _j === void 0 ? void 0 : _j.minutesWatched}`);
49
- console.log(`Statistics (Manga)\nCount: ${(_l = (_k = user === null || user === void 0 ? void 0 : user.statistics) === null || _k === void 0 ? void 0 : _k.manga) === null || _l === void 0 ? void 0 : _l.count} Chapter Read: ${(_o = (_m = user === null || user === void 0 ? void 0 : user.statistics) === null || _m === void 0 ? void 0 : _m.manga) === null || _o === void 0 ? void 0 : _o.chaptersRead} Volumes Read: ${(_q = (_p = user === null || user === void 0 ? void 0 : user.statistics) === null || _p === void 0 ? void 0 : _p.manga) === null || _q === void 0 ? void 0 : _q.volumesRead}`);
55
+ console.log(`Color:\t${(_d = user === null || user === void 0 ? void 0 : user.options) === null || _d === void 0 ? void 0 : _d.profileColor}`);
56
+ console.log(`Timezone:\t${(_e = user === null || user === void 0 ? void 0 : user.options) === null || _e === void 0 ? void 0 : _e.timezone}`);
57
+ console.log(`\nStatistics (Anime)\nCount: ${(_g = (_f = user === null || user === void 0 ? void 0 : user.statistics) === null || _f === void 0 ? void 0 : _f.anime) === null || _g === void 0 ? void 0 : _g.count} episodesWatched: ${(_j = (_h = user === null || user === void 0 ? void 0 : user.statistics) === null || _h === void 0 ? void 0 : _h.anime) === null || _j === void 0 ? void 0 : _j.episodesWatched} minutesWatched: ${(_l = (_k = user === null || user === void 0 ? void 0 : user.statistics) === null || _k === void 0 ? void 0 : _k.anime) === null || _l === void 0 ? void 0 : _l.minutesWatched}`);
58
+ console.log(`Statistics (Manga)\nCount: ${(_o = (_m = user === null || user === void 0 ? void 0 : user.statistics) === null || _m === void 0 ? void 0 : _m.manga) === null || _o === void 0 ? void 0 : _o.count} Chapter Read: ${(_q = (_p = user === null || user === void 0 ? void 0 : user.statistics) === null || _p === void 0 ? void 0 : _p.manga) === null || _q === void 0 ? void 0 : _q.chaptersRead} Volumes Read: ${(_s = (_r = user === null || user === void 0 ? void 0 : user.statistics) === null || _r === void 0 ? void 0 : _r.manga) === null || _s === void 0 ? void 0 : _s.volumesRead}`);
59
+ console.log(`\nRecent Activities:`);
60
+ activities.length > 0 &&
61
+ activities.map(({ id, status, progress, createdAt, media }, idx) => {
62
+ progress
63
+ ? console.log(`${status} ${progress} of ${getTitle(media === null || media === void 0 ? void 0 : media.title)}`)
64
+ : console.log(`${status} ${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
65
+ });
50
66
  }
51
67
  else {
52
- console.log(`Something went wrong. ${(_r = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _r === void 0 ? void 0 : _r.message}`);
68
+ console.log(`Something went wrong. ${(_t = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _t === void 0 ? void 0 : _t.message}`);
53
69
  }
54
70
  }
55
71
  catch (error) {
@@ -57,4 +73,205 @@ function getUserInfoByUsername(username) {
57
73
  }
58
74
  });
59
75
  }
60
- export { getUserInfoByUsername };
76
+ function getAnimeDetailsByID(anilistID) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ var _a;
79
+ let query = animeDetailsQuery;
80
+ let variables = { id: anilistID };
81
+ const details = yield fetcher(query, variables);
82
+ if (details) {
83
+ const { id, idMal, title, description, episodes, nextAiringEpisode, duration, startDate, endDate, countryOfOrigin, isAdult, status, season, format, genres, siteUrl, stats, } = (_a = details === null || details === void 0 ? void 0 : details.data) === null || _a === void 0 ? void 0 : _a.Media;
84
+ console.log(`\nID: ${id}`);
85
+ console.log(`Title: ${(title === null || title === void 0 ? void 0 : title.userPreffered) || getTitle(title)}`);
86
+ console.log(`Description: ${removeHtmlAndMarkdown(description)}`);
87
+ console.log(`Episode Duration: ${duration}min`);
88
+ console.log(`Origin: ${countryOfOrigin}`);
89
+ console.log(`Status: ${String(status)}`);
90
+ console.log(`Format: ${format}`);
91
+ console.log(`Genres: ${genres.join(", ")}`);
92
+ console.log(`Season: ${season}`);
93
+ console.log(`Url: `, siteUrl);
94
+ console.log(`isAdult: ${isAdult}`);
95
+ console.log(`Released: ${formatDateObject(startDate)}`);
96
+ console.log(`Finished: ${formatDateObject(endDate)}`);
97
+ }
98
+ });
99
+ }
100
+ function getAnimeSearchResults(search, count) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ var _a, _b, _c;
103
+ const query = animeSearchQuery;
104
+ const variables = { search, page: 1, perPage: count };
105
+ const searchResults = yield fetcher(query, variables);
106
+ if (searchResults) {
107
+ const results = (_b = (_a = searchResults === null || searchResults === void 0 ? void 0 : searchResults.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
108
+ const { selectedList } = yield inquirer.prompt([
109
+ {
110
+ type: "list",
111
+ name: "selectedList",
112
+ message: "Select anime to add to your list:",
113
+ choices: results.map((res, idx) => ({
114
+ name: getTitle(res === null || res === void 0 ? void 0 : res.title),
115
+ value: res === null || res === void 0 ? void 0 : res.id,
116
+ })),
117
+ },
118
+ ]);
119
+ // Where to save
120
+ const { selectedListType } = yield inquirer.prompt([
121
+ {
122
+ type: "list",
123
+ name: "selectedListType",
124
+ message: "Select the list where you want to save this anime:",
125
+ choices: [
126
+ { name: "Planning", value: "PLANNING" },
127
+ { name: "Watching", value: "CURRENT" },
128
+ { name: "Completed", value: "COMPLETED" },
129
+ { name: "Paused", value: "PAUSED" },
130
+ { name: "Dropped", value: "DROPPED" },
131
+ ],
132
+ },
133
+ ]);
134
+ // Lets save to the list now
135
+ const ISLOGGEDIN = yield isLoggedIn();
136
+ if (ISLOGGEDIN) {
137
+ const query = addAnimeToListMutation;
138
+ const variables = { mediaId: selectedList, status: selectedListType };
139
+ const response = yield fetcher(query, variables);
140
+ if (response) {
141
+ const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
142
+ console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
143
+ }
144
+ }
145
+ else {
146
+ console.error(`Please log in first to use this feature.`);
147
+ }
148
+ }
149
+ else {
150
+ console.error(`Something went wrong.`);
151
+ }
152
+ });
153
+ }
154
+ function getMangaSearchResults(search, count) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ var _a, _b, _c;
157
+ const query = mangaSearchQuery;
158
+ const variables = { search, page: 1, perPage: count };
159
+ const mangaSearchResult = yield fetcher(query, variables);
160
+ if (mangaSearchResult) {
161
+ const results = (_b = (_a = mangaSearchResult === null || mangaSearchResult === void 0 ? void 0 : mangaSearchResult.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.media;
162
+ // List of manga search results
163
+ const { selectedMangaId } = yield inquirer.prompt([
164
+ {
165
+ type: "list",
166
+ name: "selectedMangaId",
167
+ message: "Select manga to add to your list:",
168
+ choices: results.map((res) => ({
169
+ name: getTitle(res === null || res === void 0 ? void 0 : res.title),
170
+ value: res === null || res === void 0 ? void 0 : res.id,
171
+ })),
172
+ },
173
+ ]);
174
+ // Options to save to the list
175
+ const { selectedListType } = yield inquirer.prompt([
176
+ {
177
+ type: "list",
178
+ name: "selectedListType",
179
+ message: "Select the list where you want to save this manga:",
180
+ choices: [
181
+ { name: "Planning", value: "PLANNING" },
182
+ { name: "Reading", value: "CURRENT" },
183
+ { name: "Completed", value: "COMPLETED" },
184
+ { name: "Paused", value: "PAUSED" },
185
+ { name: "Dropped", value: "DROPPED" },
186
+ ],
187
+ },
188
+ ]);
189
+ // If logged in save to the list
190
+ const ISLOGGEDIN = yield isLoggedIn();
191
+ if (ISLOGGEDIN) {
192
+ const mutation = addMangaToListMutation;
193
+ const variables = { mediaId: selectedMangaId, status: selectedListType };
194
+ const response = yield fetcher(mutation, variables);
195
+ if (response) {
196
+ const saved = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.SaveMediaListEntry;
197
+ console.log(`\nEntry ${saved === null || saved === void 0 ? void 0 : saved.id}. Saved as ${saved === null || saved === void 0 ? void 0 : saved.status}.`);
198
+ }
199
+ }
200
+ else {
201
+ console.error(`Please log in first to use this feature.`);
202
+ }
203
+ }
204
+ else {
205
+ console.error(`Something went wrong.`);
206
+ }
207
+ });
208
+ }
209
+ function deleteUserActivities() {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ var _a, _b, _c, _d;
212
+ const LOGGEDIN = yield isLoggedIn();
213
+ if (LOGGEDIN) {
214
+ const { activityType } = yield inquirer.prompt([
215
+ {
216
+ type: "list",
217
+ name: "activityType",
218
+ message: "What type of activity you want to delete?",
219
+ choices: [
220
+ { name: "All Activity", value: 0 },
221
+ { name: "Text Activity", value: 1 },
222
+ { name: "Media List Activity", value: 2 },
223
+ { name: "Anime List Activity", value: 3 },
224
+ { name: "Manga List Activity", value: 4 },
225
+ { name: "Message Activity", value: 5 },
226
+ ],
227
+ },
228
+ ]);
229
+ let query = ``;
230
+ const userId = yield currentUsersId();
231
+ let variables = { page: 1, perPage: 100, userId };
232
+ switch (activityType) {
233
+ case 0:
234
+ query = activityAllQuery;
235
+ break;
236
+ case 1:
237
+ query = activityTextQuery;
238
+ break;
239
+ case 2:
240
+ query = activityMediaList;
241
+ break;
242
+ case 3:
243
+ query = activityAnimeListQuery;
244
+ break;
245
+ case 4:
246
+ query = activityMangaListQuery;
247
+ break;
248
+ case 5:
249
+ query = activityMessageQuery;
250
+ break;
251
+ }
252
+ const response = yield fetcher(query, variables);
253
+ if (response) {
254
+ const activities = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.Page) === null || _b === void 0 ? void 0 : _b.activities;
255
+ if (activities.length <= 0) {
256
+ console.log(`\nNo activities available of this type.`);
257
+ }
258
+ else {
259
+ for (let act of activities) {
260
+ const activityID = act === null || act === void 0 ? void 0 : act.id;
261
+ const deleteResponse = yield fetcher(deleteActivityMutation, {
262
+ id: activityID,
263
+ });
264
+ const isDeleted = (_d = (_c = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _c === void 0 ? void 0 : _c.DeleteActivity) === null || _d === void 0 ? void 0 : _d.deleted;
265
+ console.log(`${activityID} ${isDeleted ? "✅" : "❌"}`);
266
+ // avoiding rate-limit
267
+ yield new Promise((resolve) => setTimeout(resolve, 2000));
268
+ }
269
+ }
270
+ }
271
+ }
272
+ else {
273
+ console.error(`Please log in to use this feature.`);
274
+ }
275
+ });
276
+ }
277
+ export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, };
@@ -0,0 +1,4 @@
1
+ declare const addAnimeToListMutation = "\nmutation($mediaId: Int, $status: MediaListStatus) {\n SaveMediaListEntry(mediaId: $mediaId, status: $status) { id status }\n}\n";
2
+ declare const addMangaToListMutation = "\n mutation($mediaId: Int, $status: MediaListStatus) {\n SaveMediaListEntry(mediaId: $mediaId, status: $status) {\n id\n status\n media { title { romaji english } }\n }\n }\n";
3
+ declare const deleteActivityMutation = "\nmutation($id: Int!) {\n DeleteActivity(id: $id) { deleted }\n}\n";
4
+ export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, };
@@ -0,0 +1,20 @@
1
+ const addAnimeToListMutation = `
2
+ mutation($mediaId: Int, $status: MediaListStatus) {
3
+ SaveMediaListEntry(mediaId: $mediaId, status: $status) { id status }
4
+ }
5
+ `;
6
+ const addMangaToListMutation = `
7
+ mutation($mediaId: Int, $status: MediaListStatus) {
8
+ SaveMediaListEntry(mediaId: $mediaId, status: $status) {
9
+ id
10
+ status
11
+ media { title { romaji english } }
12
+ }
13
+ }
14
+ `;
15
+ const deleteActivityMutation = `
16
+ mutation($id: Int!) {
17
+ DeleteActivity(id: $id) { deleted }
18
+ }
19
+ `;
20
+ export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, };
@@ -1,9 +1,20 @@
1
- declare const currentUserQuery = "\n{\n Viewer {\n id\n name\n about\n bans\n siteUrl\n options {\n profileColor\n timezone\n activityMergeTime\n }\n donatorTier\n donatorBadge\n createdAt\n updatedAt\n unreadNotificationCount\n previousNames {\n name\n createdAt\n updatedAt\n }\n moderatorRoles\n favourites {\n anime {\n nodes {\n id\n title {\n romaji\n english\n }\n }\n }\n manga {\n nodes {\n id\n title {\n romaji\n english\n }\n }\n }\n }\n statistics {\n anime {\n count\n meanScore\n minutesWatched\n }\n manga {\n count\n chaptersRead\n volumesRead\n }\n }\n mediaListOptions {\n scoreFormat\n rowOrder\n animeList {\n sectionOrder\n }\n mangaList {\n sectionOrder\n }\n }\n }\n}\n";
2
- declare const trendingQuery = "\nquery ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: TRENDING_DESC, type: ANIME) {\n id\n title {\n romaji\n english\n }\n }\n }\n}\n";
3
- declare const popularQuery = "\nquery ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: POPULARITY_DESC, type: ANIME) {\n id\n title {\n romaji\n english\n }\n }\n }\n}\n";
4
- declare const userQuery = "\nquery ($username: String) {\n User(name: $username) {\n id\n name\n siteUrl\n donatorTier\n donatorBadge\n createdAt\n updatedAt\n previousNames {\n name\n createdAt\n updatedAt\n }\n isBlocked\n isFollower\n isFollowing\n options {\n profileColor\n timezone\n activityMergeTime\n }\n statistics {\n anime {\n count\n episodesWatched\n minutesWatched\n }\n manga {\n count\n chaptersRead\n volumesRead\n }\n }\n }\n}\n";
5
- declare const currentUserAnimeList = "\nquery ($id: Int) {\n MediaListCollection(userId: $id, type: ANIME) {\n lists {\n name\n entries {\n id\n media {\n id\n title {\n romaji\n english\n }\n }\n }\n }\n }\n}\n";
6
- declare const currentUserMangaList = "\n query ($id: Int) {\n MediaListCollection(userId: $id, type: MANGA) {\n lists {\n name\n entries {\n id\n media {\n title {\n romaji\n english\n }\n }\n }\n }\n }\n }\n";
7
- declare const deleteMediaEntryMutation = "\n mutation($id: Int!) {\n DeleteMediaListEntry(id: $id) {\n deleted\n }\n }";
8
- declare const deleteMangaEntryMutation = "\n mutation ($id: Int) {\n DeleteMediaListEntry(id: $id) {\n deleted\n }\n }\n";
9
- export { currentUserQuery, trendingQuery, popularQuery, userQuery, currentUserAnimeList, currentUserMangaList, deleteMediaEntryMutation, deleteMangaEntryMutation, };
1
+ declare const currentUserQuery = "{\n Viewer {\n id name about bans siteUrl options { profileColor timezone activityMergeTime }\n donatorTier donatorBadge createdAt updatedAt unreadNotificationCount\n previousNames { name createdAt updatedAt } moderatorRoles\n favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } }\n }\n statistics { anime { count meanScore minutesWatched } manga { count chaptersRead volumesRead } }\n mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }\n }\n}";
2
+ declare const trendingQuery = "query ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: TRENDING_DESC, type: ANIME) { id title { romaji english } }\n }\n}";
3
+ declare const popularQuery = "query ($page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n media(sort: POPULARITY_DESC, type: ANIME) { id title { romaji english } }\n }\n}";
4
+ declare const userQuery = "query ($username: String) {\n User(name: $username) {\n id name siteUrl donatorTier donatorBadge createdAt updatedAt previousNames { name createdAt updatedAt }\n isBlocked isFollower isFollowing options { profileColor timezone activityMergeTime }\n statistics { anime { count episodesWatched minutesWatched } manga { count chaptersRead volumesRead } }\n }\n}";
5
+ declare const currentUserAnimeList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: ANIME) {\n lists { name entries { id media { id title { romaji english } } } }\n }\n}";
6
+ declare const currentUserMangaList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: MANGA) {\n lists { name entries { id media { title { romaji english } } } }\n }\n}";
7
+ declare const deleteMediaEntryMutation = "mutation($id: Int!) {\n DeleteMediaListEntry(id: $id) { deleted }\n}";
8
+ declare const deleteMangaEntryMutation = "mutation ($id: Int) {\n DeleteMediaListEntry(id: $id) { deleted }\n}";
9
+ declare const upcomingAnimesQuery = "query GetNextSeasonAnime($nextSeason: MediaSeason, $nextYear: Int, $perPage: Int) {\n Page(perPage: $perPage) {\n media(season: $nextSeason, seasonYear: $nextYear, type: ANIME, sort: POPULARITY_DESC) {\n id title { romaji english native userPreferred } season seasonYear startDate { year month day }\n episodes description genres\n }\n }\n}";
10
+ declare const animeDetailsQuery = "query ($id: Int) {\n Media(id: $id) {\n id idMal title { romaji english native userPreferred } episodes nextAiringEpisode { id }\n duration startDate { year month day } endDate { year month day } countryOfOrigin description isAdult status season format genres siteUrl\n stats { scoreDistribution { score amount } statusDistribution { status amount } }\n }\n}";
11
+ declare const userActivityQuery = "query ($id: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $id, type_in: [ANIME_LIST, MANGA_LIST], sort: ID_DESC) {\n ... on ListActivity { id status progress createdAt media { id title { romaji english } } }\n }\n }\n}";
12
+ declare const animeSearchQuery = "query ($search: String, $perPage: Int) {\n Page(perPage: $perPage) {\n media(search: $search, type: ANIME) { id title { romaji english native userPreferred } episodes status description }\n }\n}";
13
+ declare const mangaSearchQuery = "query ($search: String, $perPage: Int) {\n Page(perPage: $perPage) {\n media(search: $search, type: MANGA) { id title { romaji english native userPreferred } chapters status description }\n }\n}";
14
+ declare const activityTextQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: TEXT) {\n ... on TextActivity { id type text createdAt user { id name } }\n }\n }\n}";
15
+ declare const activityAnimeListQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: ANIME_LIST) {\n ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }\n }\n }\n}";
16
+ declare const activityMangaListQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: MANGA_LIST) {\n ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }\n }\n }\n}";
17
+ declare const activityMessageQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: MESSAGE) {\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
18
+ declare const activityAllQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId) {\n ... on TextActivity { id type text createdAt user { id name } }\n ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }\n ... on MessageActivity { id type message recipient { id name } createdAt }\n }\n }\n}";
19
+ declare const activityMediaList = "query ($userId: Int, $page: Int, $perPage: Int, $type: ActivityType) {\n Page(page: $page, perPage: $perPage) {\n pageInfo { total currentPage lastPage hasNextPage perPage }\n activities(userId: $userId, type: $type) {\n ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }\n }\n }\n}";
20
+ export { currentUserQuery, trendingQuery, popularQuery, userQuery, currentUserAnimeList, currentUserMangaList, deleteMediaEntryMutation, deleteMangaEntryMutation, upcomingAnimesQuery, animeDetailsQuery, userActivityQuery, animeSearchQuery, mangaSearchQuery, activityAllQuery, activityMediaList, activityAnimeListQuery, activityMangaListQuery, activityMessageQuery, activityTextQuery, };
@@ -1,184 +1,122 @@
1
- const currentUserQuery = `
2
- {
1
+ const currentUserQuery = `{
3
2
  Viewer {
4
- id
5
- name
6
- about
7
- bans
8
- siteUrl
9
- options {
10
- profileColor
11
- timezone
12
- activityMergeTime
13
- }
14
- donatorTier
15
- donatorBadge
16
- createdAt
17
- updatedAt
18
- unreadNotificationCount
19
- previousNames {
20
- name
21
- createdAt
22
- updatedAt
23
- }
24
- moderatorRoles
25
- favourites {
26
- anime {
27
- nodes {
28
- id
29
- title {
30
- romaji
31
- english
32
- }
33
- }
34
- }
35
- manga {
36
- nodes {
37
- id
38
- title {
39
- romaji
40
- english
41
- }
42
- }
43
- }
44
- }
45
- statistics {
46
- anime {
47
- count
48
- meanScore
49
- minutesWatched
50
- }
51
- manga {
52
- count
53
- chaptersRead
54
- volumesRead
55
- }
56
- }
57
- mediaListOptions {
58
- scoreFormat
59
- rowOrder
60
- animeList {
61
- sectionOrder
62
- }
63
- mangaList {
64
- sectionOrder
65
- }
3
+ id name about bans siteUrl options { profileColor timezone activityMergeTime }
4
+ donatorTier donatorBadge createdAt updatedAt unreadNotificationCount
5
+ previousNames { name createdAt updatedAt } moderatorRoles
6
+ favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } }
66
7
  }
8
+ statistics { anime { count meanScore minutesWatched } manga { count chaptersRead volumesRead } }
9
+ mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }
67
10
  }
68
- }
69
- `;
70
- const trendingQuery = `
71
- query ($page: Int, $perPage: Int) {
11
+ }`;
12
+ const trendingQuery = `query ($page: Int, $perPage: Int) {
72
13
  Page(page: $page, perPage: $perPage) {
73
- media(sort: TRENDING_DESC, type: ANIME) {
74
- id
75
- title {
76
- romaji
77
- english
78
- }
79
- }
14
+ media(sort: TRENDING_DESC, type: ANIME) { id title { romaji english } }
80
15
  }
81
- }
82
- `;
83
- const popularQuery = `
84
- query ($page: Int, $perPage: Int) {
16
+ }`;
17
+ const popularQuery = `query ($page: Int, $perPage: Int) {
85
18
  Page(page: $page, perPage: $perPage) {
86
- media(sort: POPULARITY_DESC, type: ANIME) {
87
- id
88
- title {
89
- romaji
90
- english
91
- }
92
- }
19
+ media(sort: POPULARITY_DESC, type: ANIME) { id title { romaji english } }
93
20
  }
94
- }
95
- `;
96
- const userQuery = `
97
- query ($username: String) {
21
+ }`;
22
+ const userQuery = `query ($username: String) {
98
23
  User(name: $username) {
99
- id
100
- name
101
- siteUrl
102
- donatorTier
103
- donatorBadge
104
- createdAt
105
- updatedAt
106
- previousNames {
107
- name
108
- createdAt
109
- updatedAt
24
+ id name siteUrl donatorTier donatorBadge createdAt updatedAt previousNames { name createdAt updatedAt }
25
+ isBlocked isFollower isFollowing options { profileColor timezone activityMergeTime }
26
+ statistics { anime { count episodesWatched minutesWatched } manga { count chaptersRead volumesRead } }
27
+ }
28
+ }`;
29
+ const currentUserAnimeList = `query ($id: Int) {
30
+ MediaListCollection(userId: $id, type: ANIME) {
31
+ lists { name entries { id media { id title { romaji english } } } }
32
+ }
33
+ }`;
34
+ const currentUserMangaList = `query ($id: Int) {
35
+ MediaListCollection(userId: $id, type: MANGA) {
36
+ lists { name entries { id media { title { romaji english } } } }
37
+ }
38
+ }`;
39
+ const deleteMediaEntryMutation = `mutation($id: Int!) {
40
+ DeleteMediaListEntry(id: $id) { deleted }
41
+ }`;
42
+ const deleteMangaEntryMutation = `mutation ($id: Int) {
43
+ DeleteMediaListEntry(id: $id) { deleted }
44
+ }`;
45
+ const upcomingAnimesQuery = `query GetNextSeasonAnime($nextSeason: MediaSeason, $nextYear: Int, $perPage: Int) {
46
+ Page(perPage: $perPage) {
47
+ media(season: $nextSeason, seasonYear: $nextYear, type: ANIME, sort: POPULARITY_DESC) {
48
+ id title { romaji english native userPreferred } season seasonYear startDate { year month day }
49
+ episodes description genres
50
+ }
51
+ }
52
+ }`;
53
+ const animeDetailsQuery = `query ($id: Int) {
54
+ Media(id: $id) {
55
+ id idMal title { romaji english native userPreferred } episodes nextAiringEpisode { id }
56
+ duration startDate { year month day } endDate { year month day } countryOfOrigin description isAdult status season format genres siteUrl
57
+ stats { scoreDistribution { score amount } statusDistribution { status amount } }
58
+ }
59
+ }`;
60
+ const userActivityQuery = `query ($id: Int, $page: Int, $perPage: Int) {
61
+ Page(page: $page, perPage: $perPage) {
62
+ activities(userId: $id, type_in: [ANIME_LIST, MANGA_LIST], sort: ID_DESC) {
63
+ ... on ListActivity { id status progress createdAt media { id title { romaji english } } }
110
64
  }
111
- isBlocked
112
- isFollower
113
- isFollowing
114
- options {
115
- profileColor
116
- timezone
117
- activityMergeTime
65
+ }
66
+ }`;
67
+ const animeSearchQuery = `query ($search: String, $perPage: Int) {
68
+ Page(perPage: $perPage) {
69
+ media(search: $search, type: ANIME) { id title { romaji english native userPreferred } episodes status description }
70
+ }
71
+ }`;
72
+ const mangaSearchQuery = `query ($search: String, $perPage: Int) {
73
+ Page(perPage: $perPage) {
74
+ media(search: $search, type: MANGA) { id title { romaji english native userPreferred } chapters status description }
75
+ }
76
+ }`;
77
+ const activityTextQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
78
+ Page(page: $page, perPage: $perPage) {
79
+ activities(userId: $userId, type: TEXT) {
80
+ ... on TextActivity { id type text createdAt user { id name } }
118
81
  }
119
- statistics {
120
- anime {
121
- count
122
- episodesWatched
123
- minutesWatched
124
- }
125
- manga {
126
- count
127
- chaptersRead
128
- volumesRead
129
- }
82
+ }
83
+ }`;
84
+ const activityAnimeListQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
85
+ Page(page: $page, perPage: $perPage) {
86
+ activities(userId: $userId, type: ANIME_LIST) {
87
+ ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }
130
88
  }
131
89
  }
132
- }
133
- `;
134
- const currentUserAnimeList = `
135
- query ($id: Int) {
136
- MediaListCollection(userId: $id, type: ANIME) {
137
- lists {
138
- name
139
- entries {
140
- id
141
- media {
142
- id
143
- title {
144
- romaji
145
- english
146
- }
147
- }
148
- }
90
+ }`;
91
+ const activityMangaListQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
92
+ Page(page: $page, perPage: $perPage) {
93
+ activities(userId: $userId, type: MANGA_LIST) {
94
+ ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }
149
95
  }
150
96
  }
151
- }
152
- `;
153
- const currentUserMangaList = `
154
- query ($id: Int) {
155
- MediaListCollection(userId: $id, type: MANGA) {
156
- lists {
157
- name
158
- entries {
159
- id
160
- media {
161
- title {
162
- romaji
163
- english
164
- }
165
- }
166
- }
167
- }
97
+ }`;
98
+ const activityMessageQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
99
+ Page(page: $page, perPage: $perPage) {
100
+ activities(userId: $userId, type: MESSAGE) {
101
+ ... on MessageActivity { id type message recipient { id name } createdAt }
168
102
  }
169
103
  }
170
- `;
171
- const deleteMediaEntryMutation = `
172
- mutation($id: Int!) {
173
- DeleteMediaListEntry(id: $id) {
174
- deleted
104
+ }`;
105
+ const activityAllQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
106
+ Page(page: $page, perPage: $perPage) {
107
+ activities(userId: $userId) {
108
+ ... on TextActivity { id type text createdAt user { id name } }
109
+ ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }
110
+ ... on MessageActivity { id type message recipient { id name } createdAt }
175
111
  }
176
- }`;
177
- const deleteMangaEntryMutation = `
178
- mutation ($id: Int) {
179
- DeleteMediaListEntry(id: $id) {
180
- deleted
112
+ }
113
+ }`;
114
+ const activityMediaList = `query ($userId: Int, $page: Int, $perPage: Int, $type: ActivityType) {
115
+ Page(page: $page, perPage: $perPage) {
116
+ pageInfo { total currentPage lastPage hasNextPage perPage }
117
+ activities(userId: $userId, type: $type) {
118
+ ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }
181
119
  }
182
120
  }
183
- `;
184
- export { currentUserQuery, trendingQuery, popularQuery, userQuery, currentUserAnimeList, currentUserMangaList, deleteMediaEntryMutation, deleteMangaEntryMutation, };
121
+ }`;
122
+ export { currentUserQuery, trendingQuery, popularQuery, userQuery, currentUserAnimeList, currentUserMangaList, deleteMediaEntryMutation, deleteMangaEntryMutation, upcomingAnimesQuery, animeDetailsQuery, userActivityQuery, animeSearchQuery, mangaSearchQuery, activityAllQuery, activityMediaList, activityAnimeListQuery, activityMangaListQuery, activityMessageQuery, activityTextQuery, };
@@ -4,4 +4,14 @@ declare function getTitle(title: {
4
4
  english?: string;
5
5
  romaji?: string;
6
6
  }): string;
7
- export { aniListEndpoint, redirectUri, getTitle };
7
+ declare function formatDateObject(dateObj: {
8
+ day?: string;
9
+ month?: string;
10
+ year?: string;
11
+ } | null): string;
12
+ declare function getNextSeasonAndYear(): {
13
+ nextSeason: string;
14
+ nextYear: number;
15
+ };
16
+ declare function removeHtmlAndMarkdown(input: string): string;
17
+ export { aniListEndpoint, redirectUri, getTitle, getNextSeasonAndYear, formatDateObject, removeHtmlAndMarkdown, };