@irfanshadikrishad/anilist 1.0.1 → 1.0.3

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