@irfanshadikrishad/anilist 1.0.3 → 1.0.5

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- #### AniList
1
+ #### @irfanshadikrishad/anilist
2
2
 
3
- Unofficial Anilist CLI
3
+ Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.
4
4
 
5
5
  #### How to install?
6
6
 
@@ -39,21 +39,22 @@ here `<client-id>` and `<client-secret>` should be replaced by the ones that you
39
39
 
40
40
  #### CLI Commands Overview
41
41
 
42
- | **Command** | **Options** | **Description** |
43
- | ----------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------ |
44
- | **`login`** | `-i, --id` `-s, --secret` | Log in with your AniList credentials |
45
- | **`logout`** | _None_ | Log out from your AniList account |
46
- | **`me`** | _None_ | Display information about the logged-in user |
47
- | **`-V, --version`** | _None_ | Display the current version of the CLI |
48
- | **`-h, --help`** | _None_ | Display available commands and options |
49
- | **`trending`** <br> _(alias: `tr`)_ | `-c (default: 10)` | Fetch trending anime (default count is 10) |
50
- | **`popular`** <br> _(alias: `plr`)_ | `-c (default: 10)` | Fetch popular anime (default count is 10) |
51
- | **`user`** | `<username>` | Get information about a specific AniList user |
52
- | **`lists`** <br> _(alias: `ls`)_ | `-a, --anime` <br> `-m, --manga` | Fetch anime or manga lists of the logged-in user |
53
- | **`delete`** <br> _(alias: `del`)_ | `-a, --anime` <br> `-m, --manga` <br> `-ac, --activity` | Delete collections of anime, manga or activities |
54
- | **`upcoming`** <br> _(alias:`up`)_ | `-c (default: 10)` | Fetch upcoming anime (default count is 10) |
55
- | **`anime`** | `<anime-id>` | Get anime details by Anime Id |
56
- | **`search`** <br> _(alias:`srch`/`find`)_ | `<query>` <br> `-a, --anime` <br> `-m, --manga` <br> `-c (default: 10)` | Get anime/manga search results |
42
+ | **Command** | **Options** | **Description** |
43
+ | ------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------ |
44
+ | **`login`** | `-i, --id` `-s, --secret` | Log in with your AniList credentials |
45
+ | **`logout`** | _None_ | Log out from your AniList account |
46
+ | **`me`** | _None_ | Display information about the logged-in user |
47
+ | **`-V, --version`** | _None_ | Display the current version of the CLI |
48
+ | **`-h, --help`** | _None_ | Display available commands and options |
49
+ | **`trending`** <br> _(alias: `tr`)_ | `-c (default: 10)` | Fetch trending anime (default count is 10) |
50
+ | **`popular`** <br> _(alias: `plr`)_ | `-c (default: 10)` | Fetch popular anime (default count is 10) |
51
+ | **`user`** | `<username>` | Get information about a specific AniList user |
52
+ | **`lists`** <br> _(alias: `ls`)_ | `-a, --anime` <br> `-m, --manga` | Fetch anime or manga lists of the logged-in user |
53
+ | **`delete`** <br> _(alias: `del`)_ | `-a, --anime` <br> `-m, --manga` <br> `-ac, --activity` | Delete collections of anime, manga or activities |
54
+ | **`upcoming`** <br> _(alias:`up`)_ | `-c (default: 10)` | Fetch upcoming anime (default count is 10) |
55
+ | **`anime`** | `<anime-id>` | Get anime details by Anime Id |
56
+ | **`search`** <br> _(alias:`srch`/`find`)_ | `<query>` <br> `-a, --anime` <br> `-m, --manga` <br> `-c (default: 10)` | Get anime/manga search results |
57
+ | **`status`** <br> _(alias: `write`/`post`)_ | `<status>` (text/markdown/html but wrap it with quotation mark). | Write a status... |
57
58
 
58
59
  #### Command Breakdown:
59
60
 
@@ -186,6 +187,16 @@ anilist search <query> -a -c 20
186
187
  - `-c (count)`: Specify how many items to fetch (default: 10).
187
188
  - **Description**: Get anime/manga search results
188
189
 
190
+ #### `status` _(alias: `write`/`post`)_:
191
+
192
+ ```bash
193
+ anilist write <status>
194
+ ```
195
+
196
+ - **Options**:
197
+ - `<status>` : This is what you want to write, It can be HTML, Markdown and/or Text. But wrap it with quotation mark (") else it might get cut-off.
198
+ - **Description**: Get anime/manga search results
199
+
189
200
  #### Security
190
201
 
191
202
  Since you are creating your own API client for login no else else can get your credentials and the generated access token will be stored in your own system. So, As long as you don't share your device (in case you do, just logout) you are safe.
@@ -133,12 +133,12 @@ function currentUserInfo() {
133
133
  return user;
134
134
  }
135
135
  else {
136
- console.log(`Something went wrong. Please log in again. ${errors[0].message}`);
136
+ console.error(`\nSomething went wrong. Please log in again. ${errors[0].message}`);
137
137
  return null;
138
138
  }
139
139
  }
140
140
  else {
141
- console.log(`User not logged in. Please login first.`);
141
+ console.error(`\nPlease login first to use this feature.`);
142
142
  return null;
143
143
  }
144
144
  });
@@ -162,11 +162,11 @@ function logoutUser() {
162
162
  console.log("\nLogout successful.");
163
163
  }
164
164
  catch (error) {
165
- console.error("Error logging out:", error);
165
+ console.error("\nError logging out:", error);
166
166
  }
167
167
  }
168
168
  else {
169
- console.log("You may already be logged out.");
169
+ console.error("\nYou may already be logged out.");
170
170
  }
171
171
  });
172
172
  }
@@ -41,12 +41,12 @@ function fetcher(query, variables) {
41
41
  return response;
42
42
  }
43
43
  else {
44
- console.error(`Error from fetcher. ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _a === void 0 ? void 0 : _a.message}.`);
44
+ console.error(`\n${request.status} ${(_a = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _a === void 0 ? void 0 : _a.message}.`);
45
45
  return null;
46
46
  }
47
47
  }
48
48
  catch (error) {
49
- console.error(`Something went wrong. ${error.message}.`);
49
+ console.error(`\nSomething went wrong. ${error.message}.`);
50
50
  return null;
51
51
  }
52
52
  });
@@ -75,7 +75,7 @@ function getTrending(count) {
75
75
  }
76
76
  }
77
77
  else {
78
- console.error(`Please log in first to use this feature.`);
78
+ console.error(`\nPlease log in first to use this feature.`);
79
79
  }
80
80
  }
81
81
  else {
@@ -83,11 +83,11 @@ function getTrending(count) {
83
83
  }
84
84
  }
85
85
  else {
86
- console.log(`Something went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
86
+ console.log(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
87
87
  }
88
88
  }
89
89
  catch (error) {
90
- console.log(`Something went wrong. ${error.message}`);
90
+ console.log(`\nSomething went wrong. ${error.message}`);
91
91
  }
92
92
  });
93
93
  }
@@ -151,19 +151,19 @@ function getPopular(count) {
151
151
  }
152
152
  }
153
153
  else {
154
- console.error(`Please log in first to use this feature.`);
154
+ console.error(`\nPlease log in first to use this feature.`);
155
155
  }
156
156
  }
157
157
  else {
158
- console.log(`No popular available at this moment.`);
158
+ console.log(`\nNo popular available at this moment.`);
159
159
  }
160
160
  }
161
161
  else {
162
- console.log(`Something went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
162
+ console.log(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
163
163
  }
164
164
  }
165
165
  catch (error) {
166
- console.log(`Something went wrong. ${error.message}`);
166
+ console.log(`\nSomething went wrong. ${error.message}`);
167
167
  }
168
168
  });
169
169
  }
@@ -247,15 +247,15 @@ function loggedInUsersAnimeLists() {
247
247
  }
248
248
  }
249
249
  else {
250
- console.error(`Please log in first to use this feature.`);
250
+ console.error(`\nPlease log in first to use this feature.`);
251
251
  }
252
252
  }
253
253
  else {
254
- console.log(`Not available at this moment.`);
254
+ console.log(`\nNot available at this moment.`);
255
255
  }
256
256
  }
257
257
  else {
258
- console.log("No entries found.");
258
+ console.log("\nNo entries found.");
259
259
  }
260
260
  }
261
261
  else {
@@ -263,19 +263,19 @@ function loggedInUsersAnimeLists() {
263
263
  }
264
264
  }
265
265
  else {
266
- console.log(`Something went wrong. ${(_e = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _e === void 0 ? void 0 : _e.message}`);
266
+ console.log(`\nSomething went wrong. ${(_e = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _e === void 0 ? void 0 : _e.message}`);
267
267
  }
268
268
  }
269
269
  else {
270
- console.log(`Failed getting current user Id.`);
270
+ console.log(`\nFailed getting current user Id.`);
271
271
  }
272
272
  }
273
273
  else {
274
- console.log(`Please log in first.`);
274
+ console.error(`\nPlease log in first to access your lists.`);
275
275
  }
276
276
  }
277
277
  catch (error) {
278
- console.log(`Something went wrong. ${error.message}`);
278
+ console.log(`\nSomething went wrong. ${error.message}`);
279
279
  }
280
280
  });
281
281
  }
@@ -365,15 +365,15 @@ function loggedInUsersMangaLists() {
365
365
  console.log(`\nEntry ${saved.id}. Saved as ${saved.status}.`);
366
366
  }
367
367
  else {
368
- console.error(`Failed to save the manga. ${((_d = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.message) || "Unknown error"}`);
368
+ console.error(`\nFailed to save the manga. ${((_d = (_c = saveResponse === null || saveResponse === void 0 ? void 0 : saveResponse.errors) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.message) || "Unknown error"}`);
369
369
  }
370
370
  }
371
371
  else {
372
- console.error(`Please log in first to use this feature.`);
372
+ console.error(`\nPlease log in first to use this feature.`);
373
373
  }
374
374
  }
375
375
  else {
376
- console.log("No manga entries found in the selected list.");
376
+ console.log("\nNo manga entries found in the selected list.");
377
377
  }
378
378
  }
379
379
  else {
@@ -381,19 +381,19 @@ function loggedInUsersMangaLists() {
381
381
  }
382
382
  }
383
383
  else {
384
- console.error(`Failed to fetch manga lists. ${((_f = (_e = response === null || response === void 0 ? void 0 : response.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || "Unknown error"}`);
384
+ console.error(`\nFailed to fetch manga lists. ${((_f = (_e = response === null || response === void 0 ? void 0 : response.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) || "Unknown error"}`);
385
385
  }
386
386
  }
387
387
  else {
388
- console.error(`Failed to get the current user ID.`);
388
+ console.error(`\nFailed to get the current user ID.`);
389
389
  }
390
390
  }
391
391
  else {
392
- console.error("Please log in first.");
392
+ console.error(`\nPlease log in first to access your lists.`);
393
393
  }
394
394
  }
395
395
  catch (error) {
396
- console.error(`Something went wrong. ${error.message}`);
396
+ console.error(`\nSomething went wrong. ${error.message}`);
397
397
  }
398
398
  });
399
399
  }
@@ -451,15 +451,15 @@ function deleteAnimeCollection() {
451
451
  }
452
452
  }
453
453
  else {
454
- console.log(`Something went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
454
+ console.log(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
455
455
  }
456
456
  }
457
457
  else {
458
- console.log(`Failed getting current user Id.`);
458
+ console.log(`\nFailed getting current user Id.`);
459
459
  }
460
460
  }
461
461
  else {
462
- console.log(`Please log in first.`);
462
+ console.error(`\nPlease log in first to delete your lists.`);
463
463
  }
464
464
  });
465
465
  }
@@ -484,12 +484,12 @@ function deleteAnimeByAnimeId(id, title) {
484
484
  console.log(`del ${title ? getTitle(title) : ""} ${deleted ? "✅" : "❌"}`);
485
485
  }
486
486
  else {
487
- console.log(`Error deleting anime. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _c === void 0 ? void 0 : _c.message}`);
487
+ console.log(`\nError deleting anime. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _c === void 0 ? void 0 : _c.message}`);
488
488
  console.log(response);
489
489
  }
490
490
  }
491
491
  catch (error) {
492
- console.log(`Error deleting anime. ${id} ${error.message}`);
492
+ console.log(`\nError deleting anime. ${id} ${error.message}`);
493
493
  }
494
494
  });
495
495
  }
@@ -539,23 +539,23 @@ function deleteMangaCollection() {
539
539
  }
540
540
  }
541
541
  else {
542
- console.log("No entries found.");
542
+ console.error("\nNo entries found.");
543
543
  }
544
544
  }
545
545
  else {
546
- console.log(`\nNo manga(s) found in any list.`);
546
+ console.error(`\nNo manga(s) found in any list.`);
547
547
  }
548
548
  }
549
549
  else {
550
- console.log(`Something went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
550
+ console.error(`\nSomething went wrong. ${(_d = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _d === void 0 ? void 0 : _d.message}`);
551
551
  }
552
552
  }
553
553
  else {
554
- console.log(`Failed getting current user Id.`);
554
+ console.error(`\nFailed getting current user Id.`);
555
555
  }
556
556
  }
557
557
  else {
558
- console.log(`Please log in first.`);
558
+ console.error(`\nPlease log in first to delete your lists.`);
559
559
  }
560
560
  });
561
561
  }
@@ -580,12 +580,12 @@ function deleteMangaByMangaId(id, title) {
580
580
  console.log(`del ${title ? getTitle(title) : ""} ${deleted ? "✅" : "❌"}`);
581
581
  }
582
582
  else {
583
- console.log(`Error deleting manga. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _c === void 0 ? void 0 : _c.message}`);
583
+ console.log(`\nError deleting manga. ${(_c = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _c === void 0 ? void 0 : _c.message}`);
584
584
  console.log(response);
585
585
  }
586
586
  }
587
587
  catch (error) {
588
- console.log(`Error deleting manga. ${id} ${error.message}`);
588
+ console.log(`\nError deleting manga. ${id} ${error.message}`);
589
589
  }
590
590
  });
591
591
  }
@@ -651,15 +651,15 @@ function getUpcomingAnimes(count) {
651
651
  }
652
652
  }
653
653
  else {
654
- console.error(`Please log in first to use this feature.`);
654
+ console.error(`\nPlease log in first to use this feature.`);
655
655
  }
656
656
  }
657
657
  else {
658
- console.error(`Something went wrong. ${(_e = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _e === void 0 ? void 0 : _e.message}`);
658
+ console.error(`\nSomething went wrong. ${(_e = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _e === void 0 ? void 0 : _e.message}`);
659
659
  }
660
660
  }
661
661
  catch (error) {
662
- console.error(`Error getting upcoming animes. ${error.message}`);
662
+ console.error(`\nError getting upcoming animes. ${error.message}`);
663
663
  }
664
664
  });
665
665
  }
@@ -3,4 +3,5 @@ declare function getAnimeDetailsByID(anilistID: number): Promise<void>;
3
3
  declare function getAnimeSearchResults(search: string, count: number): Promise<void>;
4
4
  declare function getMangaSearchResults(search: string, count: number): Promise<void>;
5
5
  declare function deleteUserActivities(): Promise<void>;
6
- export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, };
6
+ declare function writeTextActivity(status: string): Promise<void>;
7
+ export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, writeTextActivity, };
@@ -13,7 +13,7 @@ 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
15
  import inquirer from "inquirer";
16
- import { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, } from "./mutations.js";
16
+ import { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, } from "./mutations.js";
17
17
  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;
@@ -65,11 +65,11 @@ function getUserInfoByUsername(username) {
65
65
  });
66
66
  }
67
67
  else {
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
+ console.error(`\n${request.status} ${(_t = response === null || response === void 0 ? void 0 : response.errors[0]) === null || _t === void 0 ? void 0 : _t.message}`);
69
69
  }
70
70
  }
71
71
  catch (error) {
72
- console.log(`Something went wrong. ${error.message}`);
72
+ console.error(`\nSomething went wrong. ${error.message}`);
73
73
  }
74
74
  });
75
75
  }
@@ -145,7 +145,7 @@ function getAnimeSearchResults(search, count) {
145
145
  }
146
146
  }
147
147
  else {
148
- console.error(`Please log in first to use this feature.`);
148
+ console.error(`\nPlease log in first to use this feature.`);
149
149
  }
150
150
  }
151
151
  else {
@@ -153,7 +153,7 @@ function getAnimeSearchResults(search, count) {
153
153
  }
154
154
  }
155
155
  else {
156
- console.error(`Something went wrong.`);
156
+ console.error(`\nSomething went wrong.`);
157
157
  }
158
158
  });
159
159
  }
@@ -205,11 +205,11 @@ function getMangaSearchResults(search, count) {
205
205
  }
206
206
  }
207
207
  else {
208
- console.error(`Please log in first to use this feature.`);
208
+ console.error(`\nPlease log in first to use this feature.`);
209
209
  }
210
210
  }
211
211
  else {
212
- console.error(`Something went wrong.`);
212
+ console.error(`\nSomething went wrong.`);
213
213
  }
214
214
  });
215
215
  }
@@ -264,21 +264,54 @@ function deleteUserActivities() {
264
264
  }
265
265
  else {
266
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));
267
+ // Making sure to have ID
268
+ // to avoid unintended errors
269
+ if (act === null || act === void 0 ? void 0 : act.id) {
270
+ const activityID = act === null || act === void 0 ? void 0 : act.id;
271
+ const deleteResponse = yield fetcher(deleteActivityMutation, {
272
+ id: activityID,
273
+ });
274
+ 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;
275
+ console.log(`${activityID} ${isDeleted ? "✅" : "❌"}`);
276
+ // avoiding rate-limit
277
+ yield new Promise((resolve) => setTimeout(resolve, 2000));
278
+ }
275
279
  }
276
280
  }
277
281
  }
278
282
  }
279
283
  else {
280
- console.error(`Please log in to use this feature.`);
284
+ console.error(`\nPlease log in to delete your activities.`);
281
285
  }
282
286
  });
283
287
  }
284
- export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, };
288
+ function writeTextActivity(status) {
289
+ return __awaiter(this, void 0, void 0, function* () {
290
+ var _a;
291
+ try {
292
+ if (yield isLoggedIn()) {
293
+ const query = saveTextActivityMutation;
294
+ const addTagInStatus = status +
295
+ `<br><br><br><br>*Written using [@irfanshadikrishad/anilist](https://www.npmjs.com/package/@irfanshadikrishad/anilist).*`;
296
+ const variables = { status: addTagInStatus };
297
+ const data = yield fetcher(query, variables);
298
+ if (data) {
299
+ const savedActivity = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.SaveTextActivity;
300
+ if (savedActivity === null || savedActivity === void 0 ? void 0 : savedActivity.id) {
301
+ console.log(`\n[${savedActivity === null || savedActivity === void 0 ? void 0 : savedActivity.id}] status saved successfully!`);
302
+ }
303
+ }
304
+ else {
305
+ console.error(`\nSomething went wrong. ${data}.`);
306
+ }
307
+ }
308
+ else {
309
+ console.error(`\nPlease login to use this feature.`);
310
+ }
311
+ }
312
+ catch (error) {
313
+ console.error(`\n${error.message}`);
314
+ }
315
+ });
316
+ }
317
+ export { getUserInfoByUsername, getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, writeTextActivity, };
@@ -1,4 +1,5 @@
1
1
  declare const addAnimeToListMutation = "\nmutation($mediaId: Int, $status: MediaListStatus) {\n SaveMediaListEntry(mediaId: $mediaId, status: $status) { id status }\n}\n";
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
- export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, };
4
+ declare const saveTextActivityMutation = "\nmutation SaveTextActivity($status: String!) {\n SaveTextActivity(text: $status) { id text userId createdAt }\n}\n";
5
+ export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, };
@@ -17,4 +17,9 @@ mutation($id: Int!) {
17
17
  DeleteActivity(id: $id) { deleted }
18
18
  }
19
19
  `;
20
- export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, };
20
+ const saveTextActivityMutation = `
21
+ mutation SaveTextActivity($status: String!) {
22
+ SaveTextActivity(text: $status) { id text userId createdAt }
23
+ }
24
+ `;
25
+ export { addAnimeToListMutation, addMangaToListMutation, deleteActivityMutation, saveTextActivityMutation, };
@@ -1,20 +1,20 @@
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}";
1
+ declare const currentUserQuery = "{\n Viewer {\n id name about bans siteUrl options { profileColor timezone activityMergeTime }\n donatorTier donatorBadge createdAt updatedAt unreadNotificationCount previousNames { name createdAt updatedAt }\n moderatorRoles favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } } }\n statistics { anime { count meanScore minutesWatched } manga { count chaptersRead volumesRead } }\n mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }\n }\n}";
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
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";
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}";
7
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}";
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}";
10
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
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
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
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}";
14
+ declare const activityTextQuery = "query ($userId: Int, $page: Int, $perPage: Int) {\n Page(page: $page, perPage: $perPage) {\n activities(userId: $userId, type: TEXT, sort: ID_DESC) {\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, sort: ID_DESC) {\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, sort: ID_DESC) {\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, sort: ID_DESC) {\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, sort: ID_DESC) {\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, sort: ID_DESC) {\n ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }\n }\n }\n}";
20
20
  export { currentUserQuery, trendingQuery, popularQuery, userQuery, currentUserAnimeList, currentUserMangaList, deleteMediaEntryMutation, deleteMangaEntryMutation, upcomingAnimesQuery, animeDetailsQuery, userActivityQuery, animeSearchQuery, mangaSearchQuery, activityAllQuery, activityMediaList, activityAnimeListQuery, activityMangaListQuery, activityMessageQuery, activityTextQuery, };
@@ -1,10 +1,8 @@
1
1
  const currentUserQuery = `{
2
2
  Viewer {
3
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 } } }
7
- }
4
+ donatorTier donatorBadge createdAt updatedAt unreadNotificationCount previousNames { name createdAt updatedAt }
5
+ moderatorRoles favourites { anime { nodes { id title { romaji english } } } manga { nodes { id title { romaji english } } } }
8
6
  statistics { anime { count meanScore minutesWatched } manga { count chaptersRead volumesRead } }
9
7
  mediaListOptions { scoreFormat rowOrder animeList { sectionOrder } mangaList { sectionOrder } }
10
8
  }
@@ -33,26 +31,13 @@ const currentUserAnimeList = `query ($id: Int) {
33
31
  }`;
34
32
  const currentUserMangaList = `query ($id: Int) {
35
33
  MediaListCollection(userId: $id, type: MANGA) {
36
- lists {
37
- name
38
- entries {
39
- id
40
- media {
41
- id
42
- title {
43
- romaji
44
- english
45
- }
46
- }
47
- }
48
- }
34
+ lists { name entries { id media { id title { romaji english } } } }
49
35
  }
50
- }
51
- `;
36
+ }`;
52
37
  const deleteMediaEntryMutation = `mutation($id: Int!) {
53
38
  DeleteMediaListEntry(id: $id) { deleted }
54
39
  }`;
55
- const deleteMangaEntryMutation = `mutation ($id: Int) {
40
+ const deleteMangaEntryMutation = `mutation($id: Int) {
56
41
  DeleteMediaListEntry(id: $id) { deleted }
57
42
  }`;
58
43
  const upcomingAnimesQuery = `query GetNextSeasonAnime($nextSeason: MediaSeason, $nextYear: Int, $perPage: Int) {
@@ -89,35 +74,35 @@ const mangaSearchQuery = `query ($search: String, $perPage: Int) {
89
74
  }`;
90
75
  const activityTextQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
91
76
  Page(page: $page, perPage: $perPage) {
92
- activities(userId: $userId, type: TEXT) {
77
+ activities(userId: $userId, type: TEXT, sort: ID_DESC) {
93
78
  ... on TextActivity { id type text createdAt user { id name } }
94
79
  }
95
80
  }
96
81
  }`;
97
82
  const activityAnimeListQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
98
83
  Page(page: $page, perPage: $perPage) {
99
- activities(userId: $userId, type: ANIME_LIST) {
84
+ activities(userId: $userId, type: ANIME_LIST, sort: ID_DESC) {
100
85
  ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }
101
86
  }
102
87
  }
103
88
  }`;
104
89
  const activityMangaListQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
105
90
  Page(page: $page, perPage: $perPage) {
106
- activities(userId: $userId, type: MANGA_LIST) {
91
+ activities(userId: $userId, type: MANGA_LIST, sort: ID_DESC) {
107
92
  ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }
108
93
  }
109
94
  }
110
95
  }`;
111
96
  const activityMessageQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
112
97
  Page(page: $page, perPage: $perPage) {
113
- activities(userId: $userId, type: MESSAGE) {
98
+ activities(userId: $userId, type: MESSAGE, sort: ID_DESC) {
114
99
  ... on MessageActivity { id type message recipient { id name } createdAt }
115
100
  }
116
101
  }
117
102
  }`;
118
103
  const activityAllQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
119
104
  Page(page: $page, perPage: $perPage) {
120
- activities(userId: $userId) {
105
+ activities(userId: $userId, sort: ID_DESC) {
121
106
  ... on TextActivity { id type text createdAt user { id name } }
122
107
  ... on ListActivity { id type status progress createdAt media { id title { romaji english native } } }
123
108
  ... on MessageActivity { id type message recipient { id name } createdAt }
@@ -127,7 +112,7 @@ const activityAllQuery = `query ($userId: Int, $page: Int, $perPage: Int) {
127
112
  const activityMediaList = `query ($userId: Int, $page: Int, $perPage: Int, $type: ActivityType) {
128
113
  Page(page: $page, perPage: $perPage) {
129
114
  pageInfo { total currentPage lastPage hasNextPage perPage }
130
- activities(userId: $userId, type: $type) {
115
+ activities(userId: $userId, type: $type, sort: ID_DESC) {
131
116
  ... on ListActivity { id type status progress media { id title { romaji english native } format } createdAt }
132
117
  }
133
118
  }
package/bin/index.js CHANGED
@@ -11,9 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  import { Command } from "commander";
12
12
  import { anilistUserLogin, currentUserInfo, logoutUser, } from "./helpers/auth.js";
13
13
  import { deleteAnimeCollection, deleteMangaCollection, getPopular, getTrending, getUpcomingAnimes, loggedInUsersAnimeLists, loggedInUsersMangaLists, } from "./helpers/lists.js";
14
- import { getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, getUserInfoByUsername, } from "./helpers/more.js";
14
+ import { getAnimeDetailsByID, getAnimeSearchResults, getMangaSearchResults, deleteUserActivities, getUserInfoByUsername, writeTextActivity, } from "./helpers/more.js";
15
15
  const cli = new Command();
16
- cli.name("anilist").description("Unofficial AniList CLI").version("1.0.3");
16
+ cli
17
+ .name("anilist")
18
+ .description("Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts.")
19
+ .version("1.0.5");
17
20
  cli
18
21
  .command("login")
19
22
  .description("Login with AniList")
@@ -24,7 +27,7 @@ cli
24
27
  yield anilistUserLogin(id, secret);
25
28
  }
26
29
  else {
27
- console.log("Tokens not provided correctly!");
30
+ console.log("\nMust provide both ClientId and ClientSecret!");
28
31
  }
29
32
  }));
30
33
  cli
@@ -69,7 +72,7 @@ cli
69
72
  .option("-m, --manga", "For manga list of authenticated user", false)
70
73
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga }) {
71
74
  if ((!anime && !manga) || (anime && manga)) {
72
- console.error(`Must select an option, either --anime or --manga`);
75
+ console.error(`\nMust select an option, either --anime or --manga`);
73
76
  }
74
77
  else if (anime) {
75
78
  yield loggedInUsersAnimeLists();
@@ -88,11 +91,11 @@ cli
88
91
  .action((_a) => __awaiter(void 0, [_a], void 0, function* ({ anime, manga, activity }) {
89
92
  const selectedOptions = [anime, manga, activity].filter(Boolean).length;
90
93
  if (selectedOptions === 0) {
91
- console.error(`Must select one option: either --anime, --manga, or --activity`);
94
+ console.error(`\nMust select one option: either --anime, --manga, or --activity`);
92
95
  process.exit(1);
93
96
  }
94
97
  if (selectedOptions > 1) {
95
- console.error(`Only one option can be selected at a time: --anime, --manga, or --activity`);
98
+ console.error(`\nOnly one option can be selected at a time: --anime, --manga, or --activity`);
96
99
  process.exit(1);
97
100
  }
98
101
  if (anime) {
@@ -121,7 +124,7 @@ cli
121
124
  yield getAnimeDetailsByID(Number(id));
122
125
  }
123
126
  else {
124
- console.error("Invalid or missing ID. Please provide a valid numeric ID.");
127
+ console.error(`\nInvalid or missing ID (${id}). Please provide a valid numeric ID.`);
125
128
  }
126
129
  }));
127
130
  cli
@@ -134,7 +137,7 @@ cli
134
137
  .option("-c, --count <number>", "Number of search results to show.", "10")
135
138
  .action((query_1, _a) => __awaiter(void 0, [query_1, _a], void 0, function* (query, { anime, manga, count }) {
136
139
  if ((!anime && !manga) || (anime && manga)) {
137
- console.error(`Must select an option, either --anime or --manga`);
140
+ console.error(`\nMust select an option, either --anime or --manga`);
138
141
  }
139
142
  else {
140
143
  if (anime) {
@@ -144,8 +147,16 @@ cli
144
147
  yield getMangaSearchResults(query, Number(count));
145
148
  }
146
149
  else {
147
- console.error(`Must select an option, either --anime or --manga`);
150
+ console.error(`\nMust select an option, either --anime or --manga`);
148
151
  }
149
152
  }
150
153
  }));
154
+ cli
155
+ .command("status <status>")
156
+ .alias("post")
157
+ .alias("write")
158
+ .description("Write a status...")
159
+ .action((status) => __awaiter(void 0, void 0, void 0, function* () {
160
+ yield writeTextActivity(status);
161
+ }));
151
162
  cli.parse(process.argv);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@irfanshadikrishad/anilist",
3
- "description": "Unofficial AniList CLI",
3
+ "description": "Minimalist unofficial AniList CLI for Anime and Manga Enthusiasts",
4
4
  "author": "Irfan Shadik Rishad",
5
- "version": "1.0.3",
5
+ "version": "1.0.5",
6
6
  "main": "./bin/index.js",
7
7
  "type": "module",
8
8
  "types": "./bin/index.d.ts",