@irfanshadikrishad/anilist 1.0.5 → 1.0.7
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.
- package/CHANGELOG.md +18 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +75 -0
- package/README.md +232 -204
- package/bin/helpers/auth.d.ts +1 -1
- package/bin/helpers/auth.js +42 -28
- package/bin/helpers/fetcher.js +1 -2
- package/bin/helpers/lists.js +29 -50
- package/bin/helpers/more.d.ts +5 -1
- package/bin/helpers/more.js +235 -78
- package/bin/helpers/mutations.d.ts +3 -1
- package/bin/helpers/mutations.js +34 -21
- package/bin/helpers/queries.d.ts +2 -2
- package/bin/helpers/queries.js +120 -118
- package/bin/helpers/types.d.ts +11 -0
- package/bin/helpers/types.js +1 -0
- package/bin/helpers/workers.d.ts +15 -1
- package/bin/helpers/workers.js +203 -1
- package/bin/index.js +47 -3
- package/package.json +33 -5
package/bin/helpers/more.js
CHANGED
|
@@ -8,9 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import fetch from "node-fetch";
|
|
11
|
-
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, mangaSearchQuery, userActivityQuery, userQuery, } from "./queries.js";
|
|
11
|
+
import { activityAllQuery, activityAnimeListQuery, activityMangaListQuery, activityMediaList, activityMessageQuery, activityTextQuery, animeDetailsQuery, animeSearchQuery, currentUserAnimeList, currentUserMangaList, mangaSearchQuery, userActivityQuery, userQuery, } from "./queries.js";
|
|
12
12
|
import { currentUsersId, isLoggedIn, retriveAccessToken } from "./auth.js";
|
|
13
|
-
import { aniListEndpoint, formatDateObject, getTitle, removeHtmlAndMarkdown, } from "./workers.js";
|
|
13
|
+
import { aniListEndpoint, formatDateObject, getTitle, importAnimeListFromExportedJSON, importMangaListFromExportedJSON, removeHtmlAndMarkdown, saveJSONasCSV, saveJSONasJSON, } from "./workers.js";
|
|
14
14
|
import { fetcher } from "./fetcher.js";
|
|
15
15
|
import inquirer from "inquirer";
|
|
16
16
|
import { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, } from "./mutations.js";
|
|
@@ -18,11 +18,10 @@ function getUserInfoByUsername(username) {
|
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
22
|
-
let headers = {
|
|
21
|
+
const headers = {
|
|
23
22
|
"content-type": "application/json",
|
|
24
23
|
};
|
|
25
|
-
if (
|
|
24
|
+
if (yield isLoggedIn()) {
|
|
26
25
|
headers["Authorization"] = `Bearer ${yield retriveAccessToken()}`;
|
|
27
26
|
}
|
|
28
27
|
const request = yield fetch(aniListEndpoint, {
|
|
@@ -44,9 +43,8 @@ function getUserInfoByUsername(username) {
|
|
|
44
43
|
console.log(`siteUrl:\t${user === null || user === void 0 ? void 0 : user.siteUrl}`);
|
|
45
44
|
console.log(`Donator Tier:\t${user === null || user === void 0 ? void 0 : user.donatorTier}`);
|
|
46
45
|
console.log(`Donator Badge:\t${user === null || user === void 0 ? void 0 : user.donatorBadge}`);
|
|
47
|
-
{
|
|
48
|
-
(
|
|
49
|
-
console.log(`Account Created:${new Date((user === null || user === void 0 ? void 0 : user.createdAt) * 1000).toUTCString()}`);
|
|
46
|
+
if (user === null || user === void 0 ? void 0 : user.createdAt) {
|
|
47
|
+
console.log(`Account Created: ${new Date(user.createdAt * 1000).toUTCString()}`);
|
|
50
48
|
}
|
|
51
49
|
console.log(`Account Updated:${new Date((user === null || user === void 0 ? void 0 : user.updatedAt) * 1000).toUTCString()}`);
|
|
52
50
|
console.log(`I blocked?\t${user === null || user === void 0 ? void 0 : user.isBlocked}`);
|
|
@@ -57,12 +55,11 @@ function getUserInfoByUsername(username) {
|
|
|
57
55
|
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
56
|
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
57
|
console.log(`\nRecent Activities:`);
|
|
60
|
-
activities.length > 0
|
|
61
|
-
activities.map(({
|
|
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)}`);
|
|
58
|
+
if (activities.length > 0) {
|
|
59
|
+
activities.map(({ status, progress, media }) => {
|
|
60
|
+
console.log(`${status} ${progress ? `${progress} of ` : ""}${getTitle(media === null || media === void 0 ? void 0 : media.title)}`);
|
|
65
61
|
});
|
|
62
|
+
}
|
|
66
63
|
}
|
|
67
64
|
else {
|
|
68
65
|
console.error(`\n${request.status} ${(_t = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _t === void 0 ? void 0 : _t.message}`);
|
|
@@ -76,11 +73,11 @@ function getUserInfoByUsername(username) {
|
|
|
76
73
|
function getAnimeDetailsByID(anilistID) {
|
|
77
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
75
|
var _a;
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
const query = animeDetailsQuery;
|
|
77
|
+
const variables = { id: anilistID };
|
|
81
78
|
const details = yield fetcher(query, variables);
|
|
82
|
-
if (details) {
|
|
83
|
-
const { id,
|
|
79
|
+
if ((_a = details === null || details === void 0 ? void 0 : details.data) === null || _a === void 0 ? void 0 : _a.Media) {
|
|
80
|
+
const { id, title, description, duration, startDate, endDate, countryOfOrigin, isAdult, status, season, format, genres, siteUrl, } = details.data.Media;
|
|
84
81
|
console.log(`\nID: ${id}`);
|
|
85
82
|
console.log(`Title: ${(title === null || title === void 0 ? void 0 : title.userPreffered) || getTitle(title)}`);
|
|
86
83
|
console.log(`Description: ${removeHtmlAndMarkdown(description)}`);
|
|
@@ -134,8 +131,7 @@ function getAnimeSearchResults(search, count) {
|
|
|
134
131
|
},
|
|
135
132
|
]);
|
|
136
133
|
// Lets save to the list now
|
|
137
|
-
|
|
138
|
-
if (ISLOGGEDIN) {
|
|
134
|
+
if (yield isLoggedIn()) {
|
|
139
135
|
const query = addAnimeToListMutation;
|
|
140
136
|
const variables = { mediaId: selectedList, status: selectedListType };
|
|
141
137
|
const response = yield fetcher(query, variables);
|
|
@@ -194,8 +190,7 @@ function getMangaSearchResults(search, count) {
|
|
|
194
190
|
},
|
|
195
191
|
]);
|
|
196
192
|
// If logged in save to the list
|
|
197
|
-
|
|
198
|
-
if (ISLOGGEDIN) {
|
|
193
|
+
if (yield isLoggedIn()) {
|
|
199
194
|
const mutation = addMangaToListMutation;
|
|
200
195
|
const variables = { mediaId: selectedMangaId, status: selectedListType };
|
|
201
196
|
const response = yield fetcher(mutation, variables);
|
|
@@ -215,9 +210,8 @@ function getMangaSearchResults(search, count) {
|
|
|
215
210
|
}
|
|
216
211
|
function deleteUserActivities() {
|
|
217
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
-
var _a, _b, _c, _d;
|
|
219
|
-
|
|
220
|
-
if (LOGGEDIN) {
|
|
213
|
+
var _a, _b, _c, _d, _e, _f;
|
|
214
|
+
if (yield isLoggedIn()) {
|
|
221
215
|
const { activityType } = yield inquirer.prompt([
|
|
222
216
|
{
|
|
223
217
|
type: "list",
|
|
@@ -233,51 +227,52 @@ function deleteUserActivities() {
|
|
|
233
227
|
],
|
|
234
228
|
},
|
|
235
229
|
]);
|
|
236
|
-
let query = ``;
|
|
237
230
|
const userId = yield currentUsersId();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
console.log(`${activityID} ${isDeleted ? "✅" : "❌"}`);
|
|
276
|
-
// avoiding rate-limit
|
|
277
|
-
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
231
|
+
const variables = { page: 1, perPage: 100, userId };
|
|
232
|
+
const queryMap = {
|
|
233
|
+
0: activityAllQuery,
|
|
234
|
+
1: activityTextQuery,
|
|
235
|
+
2: activityMediaList,
|
|
236
|
+
3: activityAnimeListQuery,
|
|
237
|
+
4: activityMangaListQuery,
|
|
238
|
+
5: activityMessageQuery,
|
|
239
|
+
};
|
|
240
|
+
const query = queryMap[activityType];
|
|
241
|
+
let hasMoreActivities = true;
|
|
242
|
+
while (hasMoreActivities) {
|
|
243
|
+
const response = yield fetcher(query, {
|
|
244
|
+
page: 1,
|
|
245
|
+
perPage: 50,
|
|
246
|
+
userId: yield currentUsersId(),
|
|
247
|
+
});
|
|
248
|
+
if ((_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) {
|
|
249
|
+
let count = 0;
|
|
250
|
+
const activities = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.Page) === null || _d === void 0 ? void 0 : _d.activities;
|
|
251
|
+
if (!activities || activities.length === 0) {
|
|
252
|
+
console.log(`\nNo more activities available.`);
|
|
253
|
+
hasMoreActivities = false;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
for (const act of activities) {
|
|
257
|
+
// Ensure ID is present to avoid unintended errors
|
|
258
|
+
if (act === null || act === void 0 ? void 0 : act.id) {
|
|
259
|
+
const deleteResponse = yield fetcher(deleteActivityMutation, {
|
|
260
|
+
id: act === null || act === void 0 ? void 0 : act.id,
|
|
261
|
+
});
|
|
262
|
+
const isDeleted = (_f = (_e = deleteResponse === null || deleteResponse === void 0 ? void 0 : deleteResponse.data) === null || _e === void 0 ? void 0 : _e.DeleteActivity) === null || _f === void 0 ? void 0 : _f.deleted;
|
|
263
|
+
count++;
|
|
264
|
+
console.log(`[${count}/${activities.length}] ${act === null || act === void 0 ? void 0 : act.id} ${isDeleted ? "✅" : "❌"}`);
|
|
265
|
+
// Avoiding rate-limit
|
|
266
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
267
|
+
}
|
|
278
268
|
}
|
|
279
269
|
}
|
|
280
270
|
}
|
|
271
|
+
else {
|
|
272
|
+
// In case of an unexpected null response, exit the loop
|
|
273
|
+
console.log(`\nProbably deleted all the activities of this type.`);
|
|
274
|
+
hasMoreActivities = false;
|
|
275
|
+
}
|
|
281
276
|
}
|
|
282
277
|
}
|
|
283
278
|
else {
|
|
@@ -289,24 +284,186 @@ function writeTextActivity(status) {
|
|
|
289
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
290
285
|
var _a;
|
|
291
286
|
try {
|
|
292
|
-
if (yield isLoggedIn()) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
287
|
+
if (!(yield isLoggedIn())) {
|
|
288
|
+
console.error(`\nPlease login to use this feature.`);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const query = saveTextActivityMutation;
|
|
292
|
+
const variables = {
|
|
293
|
+
status: status +
|
|
294
|
+
`<br><br><br><br>*Written using [@irfanshadikrishad/anilist](https://www.npmjs.com/package/@irfanshadikrishad/anilist).*`,
|
|
295
|
+
};
|
|
296
|
+
const data = yield fetcher(query, variables);
|
|
297
|
+
if (!data) {
|
|
298
|
+
console.error(`\nSomething went wrong. ${data}.`);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const savedActivity = (_a = data.data) === null || _a === void 0 ? void 0 : _a.SaveTextActivity;
|
|
302
|
+
if (savedActivity === null || savedActivity === void 0 ? void 0 : savedActivity.id) {
|
|
303
|
+
console.log(`\n[${savedActivity.id}] status saved successfully!`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
console.error(`\n${error.message}`);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
function exportAnimeList() {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
var _a, _b, _c;
|
|
314
|
+
if (yield isLoggedIn()) {
|
|
315
|
+
const { exportType } = yield inquirer.prompt([
|
|
316
|
+
{
|
|
317
|
+
type: "list",
|
|
318
|
+
name: "exportType",
|
|
319
|
+
message: "Choose export type:",
|
|
320
|
+
choices: [
|
|
321
|
+
{ name: "CSV", value: 1 },
|
|
322
|
+
{ name: "JSON", value: 2 },
|
|
323
|
+
],
|
|
324
|
+
pageSize: 10,
|
|
325
|
+
},
|
|
326
|
+
]);
|
|
327
|
+
const animeList = yield fetcher(currentUserAnimeList, {
|
|
328
|
+
id: yield currentUsersId(),
|
|
329
|
+
});
|
|
330
|
+
if (animeList) {
|
|
331
|
+
const lists = (_c = (_b = (_a = animeList === null || animeList === void 0 ? void 0 : animeList.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) !== null && _c !== void 0 ? _c : [];
|
|
332
|
+
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
333
|
+
var _a, _b, _c, _d, _e;
|
|
334
|
+
return ({
|
|
335
|
+
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
336
|
+
title: exportType === 1
|
|
337
|
+
? getTitle((_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title)
|
|
338
|
+
: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
|
|
339
|
+
episodes: (_d = entry === null || entry === void 0 ? void 0 : entry.media) === null || _d === void 0 ? void 0 : _d.episodes,
|
|
340
|
+
siteUrl: (_e = entry === null || entry === void 0 ? void 0 : entry.media) === null || _e === void 0 ? void 0 : _e.siteUrl,
|
|
341
|
+
progress: entry.progress,
|
|
342
|
+
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
343
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
344
|
+
});
|
|
345
|
+
}));
|
|
346
|
+
switch (exportType) {
|
|
347
|
+
case 1:
|
|
348
|
+
yield saveJSONasCSV(mediaWithProgress, "anime");
|
|
349
|
+
break;
|
|
350
|
+
case 2:
|
|
351
|
+
yield saveJSONasJSON(mediaWithProgress, "anime");
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
console.error(`\nNo anime(s) found in your lists.`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
console.error(`\nMust login to use this feature.`);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function exportMangaList() {
|
|
365
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
+
var _a, _b;
|
|
367
|
+
if (yield isLoggedIn()) {
|
|
368
|
+
const mangaLists = yield fetcher(currentUserMangaList, {
|
|
369
|
+
id: yield currentUsersId(),
|
|
370
|
+
});
|
|
371
|
+
if (mangaLists) {
|
|
372
|
+
const lists = ((_b = (_a = mangaLists === null || mangaLists === void 0 ? void 0 : mangaLists.data) === null || _a === void 0 ? void 0 : _a.MediaListCollection) === null || _b === void 0 ? void 0 : _b.lists) || [];
|
|
373
|
+
if (lists.length > 0) {
|
|
374
|
+
const { exportType } = yield inquirer.prompt([
|
|
375
|
+
{
|
|
376
|
+
type: "list",
|
|
377
|
+
name: "exportType",
|
|
378
|
+
message: "Choose export type:",
|
|
379
|
+
choices: [
|
|
380
|
+
{ name: "CSV", value: 1 },
|
|
381
|
+
{ name: "JSON", value: 2 },
|
|
382
|
+
],
|
|
383
|
+
pageSize: 10,
|
|
384
|
+
},
|
|
385
|
+
]);
|
|
386
|
+
const mediaWithProgress = lists.flatMap((list) => list.entries.map((entry) => {
|
|
387
|
+
var _a, _b, _c;
|
|
388
|
+
return ({
|
|
389
|
+
id: (_a = entry === null || entry === void 0 ? void 0 : entry.media) === null || _a === void 0 ? void 0 : _a.id,
|
|
390
|
+
title: exportType === 1
|
|
391
|
+
? getTitle((_b = entry === null || entry === void 0 ? void 0 : entry.media) === null || _b === void 0 ? void 0 : _b.title)
|
|
392
|
+
: (_c = entry === null || entry === void 0 ? void 0 : entry.media) === null || _c === void 0 ? void 0 : _c.title,
|
|
393
|
+
private: entry.private,
|
|
394
|
+
chapters: entry.media.chapters,
|
|
395
|
+
progress: entry.progress,
|
|
396
|
+
status: entry === null || entry === void 0 ? void 0 : entry.status,
|
|
397
|
+
hiddenFromStatusLists: entry.hiddenFromStatusLists,
|
|
398
|
+
});
|
|
399
|
+
}));
|
|
400
|
+
switch (exportType) {
|
|
401
|
+
case 1:
|
|
402
|
+
yield saveJSONasCSV(mediaWithProgress, "manga");
|
|
403
|
+
break;
|
|
404
|
+
case 2:
|
|
405
|
+
yield saveJSONasJSON(mediaWithProgress, "manga");
|
|
406
|
+
break;
|
|
302
407
|
}
|
|
303
408
|
}
|
|
304
409
|
else {
|
|
305
|
-
console.
|
|
410
|
+
console.log(`\nList seems to be empty.`);
|
|
306
411
|
}
|
|
307
412
|
}
|
|
308
413
|
else {
|
|
309
|
-
console.error(`\
|
|
414
|
+
console.error(`\nCould not get manga list.`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
console.error(`\nPlease login to use this feature.`);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function importAnimeList() {
|
|
423
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
424
|
+
try {
|
|
425
|
+
const { source } = yield inquirer.prompt([
|
|
426
|
+
{
|
|
427
|
+
type: "list",
|
|
428
|
+
name: "source",
|
|
429
|
+
message: "Select a source:",
|
|
430
|
+
choices: [{ name: "Exported JSON file.", value: 1 }],
|
|
431
|
+
pageSize: 10,
|
|
432
|
+
},
|
|
433
|
+
]);
|
|
434
|
+
switch (source) {
|
|
435
|
+
case 1:
|
|
436
|
+
yield importAnimeListFromExportedJSON();
|
|
437
|
+
break;
|
|
438
|
+
default:
|
|
439
|
+
console.log(`\nInvalid Choice.`);
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
console.error(`\n${error.message}`);
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function importMangaList() {
|
|
449
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
450
|
+
try {
|
|
451
|
+
const { source } = yield inquirer.prompt([
|
|
452
|
+
{
|
|
453
|
+
type: "list",
|
|
454
|
+
name: "source",
|
|
455
|
+
message: "Select a source:",
|
|
456
|
+
choices: [{ name: "Exported JSON file.", value: 1 }],
|
|
457
|
+
pageSize: 10,
|
|
458
|
+
},
|
|
459
|
+
]);
|
|
460
|
+
switch (source) {
|
|
461
|
+
case 1:
|
|
462
|
+
yield importMangaListFromExportedJSON();
|
|
463
|
+
break;
|
|
464
|
+
default:
|
|
465
|
+
console.log(`\nInvalid Choice.`);
|
|
466
|
+
break;
|
|
310
467
|
}
|
|
311
468
|
}
|
|
312
469
|
catch (error) {
|
|
@@ -314,4 +471,4 @@ function writeTextActivity(status) {
|
|
|
314
471
|
}
|
|
315
472
|
});
|
|
316
473
|
}
|
|
317
|
-
export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, writeTextActivity, };
|
|
474
|
+
export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, writeTextActivity, exportAnimeList, exportMangaList, importAnimeList, importMangaList, };
|
|
@@ -2,4 +2,6 @@ declare const addAnimeToListMutation = "\nmutation($mediaId: Int, $status: Media
|
|
|
2
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
3
|
declare const deleteActivityMutation = "\nmutation($id: Int!) {\n DeleteActivity(id: $id) { deleted }\n}\n";
|
|
4
4
|
declare const saveTextActivityMutation = "\nmutation SaveTextActivity($status: String!) {\n SaveTextActivity(text: $status) { id text userId createdAt }\n}\n";
|
|
5
|
-
|
|
5
|
+
declare const saveAnimeWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean) {\n SaveMediaListEntry(mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists) {\n id progress hiddenFromStatusLists\n }\n}\n";
|
|
6
|
+
declare const saveMangaWithProgressMutation = "\nmutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean, $private: Boolean) {\n SaveMediaListEntry( mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists, private: $private\n ) { id progress hiddenFromStatusLists private }\n}\n";
|
|
7
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, };
|
package/bin/helpers/mutations.js
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
|
-
const addAnimeToListMutation = `
|
|
2
|
-
mutation($mediaId: Int, $status: MediaListStatus) {
|
|
3
|
-
SaveMediaListEntry(mediaId: $mediaId, status: $status) { id status }
|
|
4
|
-
}
|
|
1
|
+
const addAnimeToListMutation = `
|
|
2
|
+
mutation($mediaId: Int, $status: MediaListStatus) {
|
|
3
|
+
SaveMediaListEntry(mediaId: $mediaId, status: $status) { id status }
|
|
4
|
+
}
|
|
5
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
|
-
}
|
|
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
14
|
`;
|
|
15
|
-
const deleteActivityMutation = `
|
|
16
|
-
mutation($id: Int!) {
|
|
17
|
-
DeleteActivity(id: $id) { deleted }
|
|
18
|
-
}
|
|
15
|
+
const deleteActivityMutation = `
|
|
16
|
+
mutation($id: Int!) {
|
|
17
|
+
DeleteActivity(id: $id) { deleted }
|
|
18
|
+
}
|
|
19
19
|
`;
|
|
20
|
-
const saveTextActivityMutation = `
|
|
21
|
-
mutation SaveTextActivity($status: String!) {
|
|
22
|
-
SaveTextActivity(text: $status) { id text userId createdAt }
|
|
23
|
-
}
|
|
20
|
+
const saveTextActivityMutation = `
|
|
21
|
+
mutation SaveTextActivity($status: String!) {
|
|
22
|
+
SaveTextActivity(text: $status) { id text userId createdAt }
|
|
23
|
+
}
|
|
24
24
|
`;
|
|
25
|
-
|
|
25
|
+
const saveAnimeWithProgressMutation = `
|
|
26
|
+
mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean) {
|
|
27
|
+
SaveMediaListEntry(mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists) {
|
|
28
|
+
id progress hiddenFromStatusLists
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
const saveMangaWithProgressMutation = `
|
|
33
|
+
mutation ($mediaId: Int, $progress: Int, $status: MediaListStatus, $hiddenFromStatusLists: Boolean, $private: Boolean) {
|
|
34
|
+
SaveMediaListEntry( mediaId: $mediaId, progress: $progress, status: $status, hiddenFromStatusLists: $hiddenFromStatusLists, private: $private
|
|
35
|
+
) { id progress hiddenFromStatusLists private }
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, saveAnimeWithProgressMutation, saveMangaWithProgressMutation, };
|
package/bin/helpers/queries.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ declare const currentUserQuery = "{\n Viewer {\n id name about bans siteUrl
|
|
|
2
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
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
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 { id title { romaji english } } } }\n }\n}";
|
|
5
|
+
declare const currentUserAnimeList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: ANIME) {\n lists { name entries { id progress hiddenFromStatusLists status media { id title { romaji english } status episodes siteUrl } } }\n }\n}\n";
|
|
6
|
+
declare const currentUserMangaList = "query ($id: Int) {\n MediaListCollection(userId: $id, type: MANGA) {\n lists { name entries { id progress hiddenFromStatusLists private status media { id title { romaji english } status chapters } } }\n }\n}\n";
|
|
7
7
|
declare const deleteMediaEntryMutation = "mutation($id: Int!) {\n DeleteMediaListEntry(id: $id) { deleted }\n}";
|
|
8
8
|
declare const deleteMangaEntryMutation = "mutation($id: Int) {\n DeleteMediaListEntry(id: $id) { deleted }\n}";
|
|
9
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}";
|