@tutkli/jikan-ts 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.githooks/pre-commit +3 -0
- package/.lintstagedrc.json +3 -0
- package/README.md +12 -13
- package/dist/index.d.ts +285 -275
- package/dist/index.js +1 -1
- package/package.json +28 -25
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
6
5
|

|
|
7
6
|

|
|
8
7
|

|
|
@@ -18,8 +17,6 @@
|
|
|
18
17
|
- 📄 Logging
|
|
19
18
|
- 📦 ESM with tree shaking support
|
|
20
19
|
|
|
21
|
-
#### 📖 Check out the [documentation page](https://tutkli.github.io/jikan-ts/)!
|
|
22
|
-
|
|
23
20
|
## Installation
|
|
24
21
|
|
|
25
22
|
```bash
|
|
@@ -39,8 +36,10 @@ const animeClient = new AnimeClient();
|
|
|
39
36
|
|
|
40
37
|
animeClient
|
|
41
38
|
.getAnimeById(1)
|
|
42
|
-
.then((jikanResponse: JikanResponse<Anime>) => {
|
|
43
|
-
|
|
39
|
+
.then((jikanResponse: JikanResponse<Anime>) => {
|
|
40
|
+
/* ... */
|
|
41
|
+
})
|
|
42
|
+
.catch(error => console.error(error));
|
|
44
43
|
```
|
|
45
44
|
|
|
46
45
|
Or, using the **JikanClient**:
|
|
@@ -52,8 +51,10 @@ const jikanClient = new JikanClient();
|
|
|
52
51
|
|
|
53
52
|
jikanClient.anime
|
|
54
53
|
.getAnimeById(1)
|
|
55
|
-
.then((jikanResponse: JikanResponse<Anime>) => {
|
|
56
|
-
|
|
54
|
+
.then((jikanResponse: JikanResponse<Anime>) => {
|
|
55
|
+
/* ... */
|
|
56
|
+
})
|
|
57
|
+
.catch(error => console.error(error));
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
## Client configuration
|
|
@@ -66,7 +67,7 @@ To use a specific configuration, pass the `cacheOptions` argument when instantia
|
|
|
66
67
|
```ts
|
|
67
68
|
import { AnimeClient } from '@tutkli/jikan-ts';
|
|
68
69
|
|
|
69
|
-
const animeClient = new AnimeClient({
|
|
70
|
+
const animeClient = new AnimeClient({
|
|
70
71
|
cacheOptions: { ... } // axios-cache-interceptor options
|
|
71
72
|
}
|
|
72
73
|
);
|
|
@@ -81,10 +82,9 @@ To enable logging, pass the `enableLogging` argument as `true`.
|
|
|
81
82
|
```ts
|
|
82
83
|
import { AnimeClient } from '@tutkli/jikan-ts';
|
|
83
84
|
|
|
84
|
-
const animeClient = new AnimeClient({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
85
|
+
const animeClient = new AnimeClient({
|
|
86
|
+
enableLogging: true,
|
|
87
|
+
});
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
## Available Clients
|
|
@@ -103,4 +103,3 @@ const animeClient = new AnimeClient({
|
|
|
103
103
|
- Did you find this project useful? [Leave a ⭐](https://github.com/tutkli/jikan-ts)
|
|
104
104
|
- Found a problem? [Create an issue 🔎](https://github.com/tutkli/jikan-ts/issues)
|
|
105
105
|
- Want to contribute? [Submit a PR 📑](https://github.com/tutkli/jikan-ts/pulls)
|
|
106
|
-
|
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1,8 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator
|
|
2
|
-
|
|
3
|
-
/// <reference types="node" />
|
|
1
|
+
// Generated by dts-bundle-generator v9.3.1
|
|
4
2
|
|
|
5
3
|
import { AxiosError } from 'axios';
|
|
6
|
-
import { AxiosCacheInstance, CacheAxiosResponse, CacheOptions,
|
|
4
|
+
import { AxiosCacheInstance, CacheAxiosResponse, CacheOptions, InternalCacheRequestConfig } from 'axios-cache-interceptor';
|
|
7
5
|
|
|
8
|
-
/**
|
|
9
|
-
* **Client Args**
|
|
10
|
-
*
|
|
11
|
-
* Used to pass optional configuration for logging and cache to the clients.
|
|
12
|
-
*/
|
|
13
|
-
export interface ClientArgs {
|
|
14
|
-
/**
|
|
15
|
-
* **EnableLogging**
|
|
16
|
-
* Enables logging request responses.
|
|
17
|
-
*/
|
|
18
|
-
enableLogging: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* **Axios Cache Options**
|
|
21
|
-
* Options for cache.
|
|
22
|
-
* @see https://axios-cache-interceptor.js.org/#/pages/configuration
|
|
23
|
-
*/
|
|
24
|
-
cacheOptions: Partial<CacheOptions>;
|
|
25
|
-
/**
|
|
26
|
-
* **Base URL**
|
|
27
|
-
* Location of the JikanAPI. Leave empty to use the official JikanAPI instance.
|
|
28
|
-
*/
|
|
29
|
-
baseURL: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* **Base Client**
|
|
33
|
-
*
|
|
34
|
-
* This client is responsible for creating an Axios Instance and the cache and logging configurations
|
|
35
|
-
*/
|
|
36
|
-
export declare abstract class BaseClient {
|
|
37
|
-
api: AxiosCacheInstance;
|
|
38
|
-
constructor(clientOptions?: Partial<ClientArgs>);
|
|
39
|
-
protected replacePathParams(path: string, params: {
|
|
40
|
-
[key in string]: unknown;
|
|
41
|
-
}): string;
|
|
42
|
-
private addLoggingInterceptors;
|
|
43
|
-
}
|
|
44
|
-
export interface JikanResource {
|
|
45
|
-
mal_id: number;
|
|
46
|
-
type: string;
|
|
47
|
-
name: string;
|
|
48
|
-
url: string;
|
|
49
|
-
}
|
|
50
|
-
export interface JikanNamedResource {
|
|
51
|
-
name: string;
|
|
52
|
-
url: string;
|
|
53
|
-
}
|
|
54
|
-
export interface JikanResourceTitle {
|
|
55
|
-
type: string;
|
|
56
|
-
title: string;
|
|
57
|
-
}
|
|
58
|
-
export interface JikanResourcePeriod {
|
|
59
|
-
from: string;
|
|
60
|
-
to: string;
|
|
61
|
-
prop: {
|
|
62
|
-
form: {
|
|
63
|
-
day: number;
|
|
64
|
-
month: number;
|
|
65
|
-
year: number;
|
|
66
|
-
};
|
|
67
|
-
to: {
|
|
68
|
-
day: number;
|
|
69
|
-
month: number;
|
|
70
|
-
year: number;
|
|
71
|
-
};
|
|
72
|
-
string: string;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export interface JikanResourceRelation {
|
|
76
|
-
relation: string;
|
|
77
|
-
entry: JikanResource[];
|
|
78
|
-
}
|
|
79
6
|
export interface JikanImages {
|
|
80
7
|
jpg: JikanImagesCollection;
|
|
81
8
|
webp?: JikanImagesCollection;
|
|
@@ -121,6 +48,45 @@ export interface RecommendationEntry {
|
|
|
121
48
|
images: JikanImages;
|
|
122
49
|
title: string;
|
|
123
50
|
}
|
|
51
|
+
export interface JikanResource {
|
|
52
|
+
mal_id: number;
|
|
53
|
+
type: string;
|
|
54
|
+
name: string;
|
|
55
|
+
url: string;
|
|
56
|
+
}
|
|
57
|
+
export interface JikanNamedResource {
|
|
58
|
+
name: string;
|
|
59
|
+
url: string;
|
|
60
|
+
}
|
|
61
|
+
export interface JikanResourceTitle {
|
|
62
|
+
type: string;
|
|
63
|
+
title: string;
|
|
64
|
+
}
|
|
65
|
+
export interface JikanResourcePeriod {
|
|
66
|
+
from: string;
|
|
67
|
+
to: string;
|
|
68
|
+
prop: {
|
|
69
|
+
form: {
|
|
70
|
+
day: number;
|
|
71
|
+
month: number;
|
|
72
|
+
year: number;
|
|
73
|
+
};
|
|
74
|
+
to: {
|
|
75
|
+
day: number;
|
|
76
|
+
month: number;
|
|
77
|
+
year: number;
|
|
78
|
+
};
|
|
79
|
+
string: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface JikanResourceRelation {
|
|
83
|
+
relation: string;
|
|
84
|
+
entry: JikanResource[];
|
|
85
|
+
}
|
|
86
|
+
export interface SeasonsListData {
|
|
87
|
+
year: number;
|
|
88
|
+
seasons: Array<keyof typeof AnimeSeason>;
|
|
89
|
+
}
|
|
124
90
|
export interface Statistics {
|
|
125
91
|
completed: number;
|
|
126
92
|
on_hold: number;
|
|
@@ -133,9 +99,31 @@ export interface StatisticsScore {
|
|
|
133
99
|
votes: number;
|
|
134
100
|
percentage: number;
|
|
135
101
|
}
|
|
136
|
-
export interface
|
|
137
|
-
|
|
138
|
-
|
|
102
|
+
export interface AnimeCharacter extends CommonCharacter {
|
|
103
|
+
voice_actors: CharacterVoiceActor[];
|
|
104
|
+
}
|
|
105
|
+
export interface AnimeEpisode {
|
|
106
|
+
mal_id: number;
|
|
107
|
+
url: string;
|
|
108
|
+
title: string;
|
|
109
|
+
title_japanese: string;
|
|
110
|
+
title_romanji: string;
|
|
111
|
+
duration: number;
|
|
112
|
+
aired: string;
|
|
113
|
+
filler: boolean;
|
|
114
|
+
recap: boolean;
|
|
115
|
+
forum_url: string;
|
|
116
|
+
}
|
|
117
|
+
export interface AnimePicture {
|
|
118
|
+
images: JikanImages;
|
|
119
|
+
}
|
|
120
|
+
export interface AnimeStaff {
|
|
121
|
+
person: JikanPerson;
|
|
122
|
+
positions: string[];
|
|
123
|
+
}
|
|
124
|
+
export interface AnimeStatistics extends Statistics {
|
|
125
|
+
watching: number;
|
|
126
|
+
plan_to_watch: number;
|
|
139
127
|
}
|
|
140
128
|
export interface AnimeVideos {
|
|
141
129
|
promo: AnimePromoVideo[];
|
|
@@ -248,31 +236,38 @@ export declare enum AnimeSeason {
|
|
|
248
236
|
fall = "fall",
|
|
249
237
|
winter = "winter"
|
|
250
238
|
}
|
|
251
|
-
export interface
|
|
252
|
-
voice_actors: CharacterVoiceActor[];
|
|
253
|
-
}
|
|
254
|
-
export interface AnimeStaff {
|
|
255
|
-
person: JikanPerson;
|
|
256
|
-
positions: string[];
|
|
257
|
-
}
|
|
258
|
-
export interface AnimeEpisode {
|
|
239
|
+
export interface Character {
|
|
259
240
|
mal_id: number;
|
|
260
241
|
url: string;
|
|
261
|
-
title: string;
|
|
262
|
-
title_japanese: string;
|
|
263
|
-
title_romanji: string;
|
|
264
|
-
duration: number;
|
|
265
|
-
aired: string;
|
|
266
|
-
filler: boolean;
|
|
267
|
-
recap: boolean;
|
|
268
|
-
forum_url: string;
|
|
269
|
-
}
|
|
270
|
-
export interface AnimePicture {
|
|
271
242
|
images: JikanImages;
|
|
243
|
+
name: string;
|
|
244
|
+
name_kanji: string;
|
|
245
|
+
nicknames: string[];
|
|
246
|
+
favorites: number;
|
|
247
|
+
about: string;
|
|
248
|
+
anime: CharacterAnime[];
|
|
249
|
+
manga: CharacterManga[];
|
|
250
|
+
voices: CharacterVoiceActor[];
|
|
272
251
|
}
|
|
273
|
-
export interface
|
|
274
|
-
|
|
275
|
-
|
|
252
|
+
export interface CharacterAnime {
|
|
253
|
+
role: CharacterRole;
|
|
254
|
+
anime: CommonCharacterData & {
|
|
255
|
+
title: string;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
export interface CharacterManga {
|
|
259
|
+
role: CharacterRole;
|
|
260
|
+
manga: CommonCharacterData & {
|
|
261
|
+
title: string;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
export interface Genre extends JikanNamedResource {
|
|
265
|
+
mal_id: number;
|
|
266
|
+
count: number;
|
|
267
|
+
}
|
|
268
|
+
export interface MangaStatistics extends Statistics {
|
|
269
|
+
reading: number;
|
|
270
|
+
plan_to_read: number;
|
|
276
271
|
}
|
|
277
272
|
export interface Manga {
|
|
278
273
|
mal_id: number;
|
|
@@ -318,28 +313,10 @@ export declare enum MangaType {
|
|
|
318
313
|
export declare enum MangaStatus {
|
|
319
314
|
publishing = "Publishing",
|
|
320
315
|
complete = "Complete",
|
|
321
|
-
hiatus = "Hiatus",
|
|
316
|
+
hiatus = "On Hiatus",
|
|
322
317
|
discontinued = "Discontinued",
|
|
323
318
|
upcoming = "Upcoming"
|
|
324
319
|
}
|
|
325
|
-
export interface MangaStatistics extends Statistics {
|
|
326
|
-
reading: number;
|
|
327
|
-
plan_to_read: number;
|
|
328
|
-
}
|
|
329
|
-
export interface JikanPagination {
|
|
330
|
-
last_visible_page: number;
|
|
331
|
-
has_next_page: boolean;
|
|
332
|
-
items?: JikanPaginationItems;
|
|
333
|
-
}
|
|
334
|
-
export interface JikanPaginationItems {
|
|
335
|
-
count: number;
|
|
336
|
-
total: number;
|
|
337
|
-
per_page: number;
|
|
338
|
-
}
|
|
339
|
-
export interface JikanResponse<T> {
|
|
340
|
-
data: T;
|
|
341
|
-
pagination?: JikanPagination;
|
|
342
|
-
}
|
|
343
320
|
export declare enum SortOptions {
|
|
344
321
|
asc = "asc",
|
|
345
322
|
desc = "desc"
|
|
@@ -361,10 +338,22 @@ export declare enum AnimeSearchOrder {
|
|
|
361
338
|
rating = "rating",
|
|
362
339
|
episodes = "episodes"
|
|
363
340
|
}
|
|
341
|
+
export declare enum AnimeSearchStatus {
|
|
342
|
+
airing = "airing",
|
|
343
|
+
complete = "complete",
|
|
344
|
+
upcoming = "upcoming"
|
|
345
|
+
}
|
|
364
346
|
export declare enum MangaSearchOrder {
|
|
365
347
|
chapters = "chapters",
|
|
366
348
|
volumes = "volumes"
|
|
367
349
|
}
|
|
350
|
+
export declare enum MangaSearchStatus {
|
|
351
|
+
publishing = "publishing",
|
|
352
|
+
complete = "complete",
|
|
353
|
+
hiatus = "hiatus",
|
|
354
|
+
discontinued = "discontinued",
|
|
355
|
+
upcoming = "upcoming"
|
|
356
|
+
}
|
|
368
357
|
export interface JikanSearchParams {
|
|
369
358
|
q?: string;
|
|
370
359
|
page?: number;
|
|
@@ -389,7 +378,7 @@ export interface JikanSearchParams {
|
|
|
389
378
|
*/
|
|
390
379
|
export interface MangaSearchParams extends JikanSearchParams {
|
|
391
380
|
type?: MangaType | string;
|
|
392
|
-
status?:
|
|
381
|
+
status?: MangaSearchStatus | string;
|
|
393
382
|
order_by?: MangaSearchOrder | SearchOrder | string;
|
|
394
383
|
magazines?: string;
|
|
395
384
|
}
|
|
@@ -400,10 +389,56 @@ export interface MangaSearchParams extends JikanSearchParams {
|
|
|
400
389
|
*/
|
|
401
390
|
export interface AnimeSearchParams extends JikanSearchParams {
|
|
402
391
|
type?: AnimeType | string;
|
|
403
|
-
status?:
|
|
392
|
+
status?: AnimeSearchStatus | string;
|
|
404
393
|
rating?: AnimeRating | string;
|
|
405
394
|
order_by?: AnimeSearchOrder | SearchOrder | string;
|
|
406
395
|
}
|
|
396
|
+
export interface CharactersSearchParams {
|
|
397
|
+
page?: number;
|
|
398
|
+
limit?: number;
|
|
399
|
+
q?: string;
|
|
400
|
+
order_by?: CharactersSearchOrder;
|
|
401
|
+
sort?: SortOptions;
|
|
402
|
+
letter?: string;
|
|
403
|
+
}
|
|
404
|
+
export declare enum CharactersSearchOrder {
|
|
405
|
+
mal_id = "mal_id",
|
|
406
|
+
name = "name",
|
|
407
|
+
favorites = "favorites"
|
|
408
|
+
}
|
|
409
|
+
export declare enum GenresFilter {
|
|
410
|
+
genres = "genres",
|
|
411
|
+
explicit_genres = "explicit_genres",
|
|
412
|
+
theme = "themes",
|
|
413
|
+
demographics = "demographics"
|
|
414
|
+
}
|
|
415
|
+
export interface SchedulesParams {
|
|
416
|
+
page?: number;
|
|
417
|
+
limit?: number;
|
|
418
|
+
filter?: SchedulesFilter;
|
|
419
|
+
kids?: boolean;
|
|
420
|
+
sfw?: boolean;
|
|
421
|
+
unapproved?: boolean;
|
|
422
|
+
}
|
|
423
|
+
export declare enum SchedulesFilter {
|
|
424
|
+
monday = "monday",
|
|
425
|
+
tuesday = "tuesday",
|
|
426
|
+
wednesday = "wednesday",
|
|
427
|
+
thursday = "thursday",
|
|
428
|
+
friday = "friday",
|
|
429
|
+
unknown = "unknown",
|
|
430
|
+
other = "other"
|
|
431
|
+
}
|
|
432
|
+
export interface JikanSeasonsParams {
|
|
433
|
+
page?: number;
|
|
434
|
+
limit?: number;
|
|
435
|
+
filter?: AnimeType;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* QueryParams used in **getSeasonNow** call
|
|
439
|
+
*
|
|
440
|
+
*/
|
|
441
|
+
export type SeasonNowParams = Omit<JikanSeasonsParams, "filter">;
|
|
407
442
|
export declare enum TopAnimeFilter {
|
|
408
443
|
airing = "airing",
|
|
409
444
|
upcoming = "upcoming",
|
|
@@ -438,80 +473,55 @@ export interface MangaTopParams extends JikanTopParams {
|
|
|
438
473
|
type?: MangaType;
|
|
439
474
|
filter?: TopMangaFilter;
|
|
440
475
|
}
|
|
441
|
-
export interface
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
476
|
+
export interface JikanPagination {
|
|
477
|
+
last_visible_page: number;
|
|
478
|
+
has_next_page: boolean;
|
|
479
|
+
items?: JikanPaginationItems;
|
|
480
|
+
}
|
|
481
|
+
export interface JikanPaginationItems {
|
|
482
|
+
count: number;
|
|
483
|
+
total: number;
|
|
484
|
+
per_page: number;
|
|
485
|
+
}
|
|
486
|
+
export interface JikanResponse<T> {
|
|
487
|
+
data: T;
|
|
488
|
+
pagination?: JikanPagination;
|
|
445
489
|
}
|
|
446
490
|
/**
|
|
447
|
-
*
|
|
491
|
+
* **Client Args**
|
|
448
492
|
*
|
|
493
|
+
* Used to pass optional configuration for logging and cache to the clients.
|
|
449
494
|
*/
|
|
450
|
-
export
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
name = "name",
|
|
468
|
-
favorites = "favorites"
|
|
469
|
-
}
|
|
470
|
-
export interface SchedulesParams {
|
|
471
|
-
page?: number;
|
|
472
|
-
limit?: number;
|
|
473
|
-
filter?: SchedulesFilter;
|
|
474
|
-
kids?: boolean;
|
|
475
|
-
sfw?: boolean;
|
|
476
|
-
unapproved?: boolean;
|
|
477
|
-
}
|
|
478
|
-
export declare enum SchedulesFilter {
|
|
479
|
-
monday = "monday",
|
|
480
|
-
tuesday = "tuesday",
|
|
481
|
-
wednesday = "wednesday",
|
|
482
|
-
thursday = "thursday",
|
|
483
|
-
friday = "friday",
|
|
484
|
-
unknown = "unknown",
|
|
485
|
-
other = "other"
|
|
486
|
-
}
|
|
487
|
-
export interface Character {
|
|
488
|
-
mal_id: number;
|
|
489
|
-
url: string;
|
|
490
|
-
images: JikanImages;
|
|
491
|
-
name: string;
|
|
492
|
-
name_kanji: string;
|
|
493
|
-
nicknames: string[];
|
|
494
|
-
favorites: number;
|
|
495
|
-
about: string;
|
|
496
|
-
anime: CharacterAnime[];
|
|
497
|
-
manga: CharacterManga[];
|
|
498
|
-
voices: CharacterVoiceActor[];
|
|
499
|
-
}
|
|
500
|
-
export interface CharacterAnime {
|
|
501
|
-
role: CharacterRole;
|
|
502
|
-
anime: CommonCharacterData & {
|
|
503
|
-
title: string;
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
export interface CharacterManga {
|
|
507
|
-
role: CharacterRole;
|
|
508
|
-
manga: CommonCharacterData & {
|
|
509
|
-
title: string;
|
|
510
|
-
};
|
|
495
|
+
export interface ClientArgs {
|
|
496
|
+
/**
|
|
497
|
+
* **EnableLogging**
|
|
498
|
+
* Enables logging request responses.
|
|
499
|
+
*/
|
|
500
|
+
enableLogging: boolean;
|
|
501
|
+
/**
|
|
502
|
+
* **Axios Cache Options**
|
|
503
|
+
* Options for cache.
|
|
504
|
+
* @see https://axios-cache-interceptor.js.org/#/pages/configuration
|
|
505
|
+
*/
|
|
506
|
+
cacheOptions: Partial<CacheOptions>;
|
|
507
|
+
/**
|
|
508
|
+
* **Base URL**
|
|
509
|
+
* Location of the JikanAPI. Leave empty to use the official JikanAPI instance.
|
|
510
|
+
*/
|
|
511
|
+
baseURL: string;
|
|
511
512
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
513
|
+
/**
|
|
514
|
+
* **Base Client**
|
|
515
|
+
*
|
|
516
|
+
* This client is responsible for creating an Axios Instance and the cache and logging configurations
|
|
517
|
+
*/
|
|
518
|
+
export declare abstract class BaseClient {
|
|
519
|
+
api: AxiosCacheInstance;
|
|
520
|
+
constructor(clientOptions?: Partial<ClientArgs>);
|
|
521
|
+
protected replacePathParams(path: string, params: {
|
|
522
|
+
[key in string]: unknown;
|
|
523
|
+
}): string;
|
|
524
|
+
private addLoggingInterceptors;
|
|
515
525
|
}
|
|
516
526
|
/**
|
|
517
527
|
* **Anime Client**
|
|
@@ -597,6 +607,76 @@ export declare class AnimeClient extends BaseClient {
|
|
|
597
607
|
*/
|
|
598
608
|
getAnimeRecommendations(mal_id: number): Promise<JikanResponse<Recommendation[]>>;
|
|
599
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* **Characters Client**
|
|
612
|
+
*
|
|
613
|
+
* Client used to access the Character Endpoints:
|
|
614
|
+
*
|
|
615
|
+
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
616
|
+
*/
|
|
617
|
+
export declare class CharactersClient extends BaseClient {
|
|
618
|
+
/**
|
|
619
|
+
* Get complete Character data
|
|
620
|
+
* @param mal_id The Character ID
|
|
621
|
+
* @returns JikanResponse with Character data
|
|
622
|
+
*/
|
|
623
|
+
getCharacterFullById(mal_id: number): Promise<JikanResponse<Character>>;
|
|
624
|
+
/**
|
|
625
|
+
* Get Character data
|
|
626
|
+
* @param mal_id The Character ID
|
|
627
|
+
* @returns JikanResponse with Character data
|
|
628
|
+
*/
|
|
629
|
+
getCharacterById(mal_id: number): Promise<JikanResponse<Character>>;
|
|
630
|
+
/**
|
|
631
|
+
* Get Character anime data
|
|
632
|
+
* @param mal_id The Character ID
|
|
633
|
+
* @returns JikanResponse with CharacterAnime data
|
|
634
|
+
*/
|
|
635
|
+
getCharacterAnime(mal_id: number): Promise<JikanResponse<CharacterAnime[]>>;
|
|
636
|
+
/**
|
|
637
|
+
* Get Character manga data
|
|
638
|
+
* @param mal_id The Character ID
|
|
639
|
+
* @returns JikanResponse with CharacterManga data
|
|
640
|
+
*/
|
|
641
|
+
getCharacterManga(mal_id: number): Promise<JikanResponse<CharacterManga[]>>;
|
|
642
|
+
/**
|
|
643
|
+
* Get Character voices data
|
|
644
|
+
* @param mal_id The Character ID
|
|
645
|
+
* @returns JikanResponse with CharacterVoiceActor data
|
|
646
|
+
*/
|
|
647
|
+
getCharacterVoiceActors(mal_id: number): Promise<JikanResponse<CharacterVoiceActor[]>>;
|
|
648
|
+
/**
|
|
649
|
+
* Get Character pictures data
|
|
650
|
+
* @param mal_id The Character ID
|
|
651
|
+
* @returns JikanResponse with JikanImagesCollection data
|
|
652
|
+
*/
|
|
653
|
+
getCharacterPictures(mal_id: number): Promise<JikanResponse<JikanImagesCollection[]>>;
|
|
654
|
+
/**
|
|
655
|
+
* Get all the Characters within the given filter. Returns all Characters if no filters are given.
|
|
656
|
+
@param searchParams Filter parameters
|
|
657
|
+
* @returns JikanResponse with Character array data
|
|
658
|
+
*/
|
|
659
|
+
getCharacterSearch(searchParams: Partial<CharactersSearchParams>): Promise<JikanResponse<Character[]>>;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* **Anime Client**
|
|
663
|
+
*
|
|
664
|
+
* Client used to access the Anime Endpoints:
|
|
665
|
+
*
|
|
666
|
+
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
667
|
+
*/
|
|
668
|
+
export declare class GenresClient extends BaseClient {
|
|
669
|
+
/**
|
|
670
|
+
* Get Anime genres
|
|
671
|
+
* @param filter Type of the desired genres
|
|
672
|
+
*/
|
|
673
|
+
getAnimeGenres(filter?: GenresFilter): Promise<JikanResponse<Genre[]>>;
|
|
674
|
+
/**
|
|
675
|
+
* Get Manga genres
|
|
676
|
+
* @param filter Type of the desired genres
|
|
677
|
+
*/
|
|
678
|
+
getMangaGenres(filter?: GenresFilter): Promise<JikanResponse<Genre[]>>;
|
|
679
|
+
}
|
|
600
680
|
/**
|
|
601
681
|
* **Manga Client**
|
|
602
682
|
*
|
|
@@ -649,25 +729,19 @@ export declare class MangaClient extends BaseClient {
|
|
|
649
729
|
getMangaRecommendations(mal_id: number): Promise<JikanResponse<Recommendation[]>>;
|
|
650
730
|
}
|
|
651
731
|
/**
|
|
652
|
-
* **
|
|
732
|
+
* **Schedules Client**
|
|
653
733
|
*
|
|
654
|
-
* Client used to access the
|
|
734
|
+
* Client used to access the Schedules Endpoints
|
|
655
735
|
*
|
|
656
736
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
657
737
|
*/
|
|
658
|
-
export declare class
|
|
738
|
+
export declare class SchedulesClient extends BaseClient {
|
|
659
739
|
/**
|
|
660
|
-
*
|
|
740
|
+
* Returns weekly schedule
|
|
661
741
|
* @param searchParams Filter parameters
|
|
662
742
|
* @returns JikanResponse with Anime array data
|
|
663
743
|
*/
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Get the top Mangas
|
|
667
|
-
* @param searchParams Filter parameters
|
|
668
|
-
* @returns JikanResponse with Manga array data
|
|
669
|
-
*/
|
|
670
|
-
getTopManga(searchParams?: Partial<MangaTopParams>): Promise<JikanResponse<Manga[]>>;
|
|
744
|
+
getSchedules(searchParams?: Partial<SchedulesParams>): Promise<JikanResponse<Anime[]>>;
|
|
671
745
|
}
|
|
672
746
|
/**
|
|
673
747
|
* **Seasons Client**
|
|
@@ -704,89 +778,25 @@ export declare class SeasonsClient extends BaseClient {
|
|
|
704
778
|
getSeasonUpcoming(searchParams?: Partial<JikanSeasonsParams>): Promise<JikanResponse<Anime[]>>;
|
|
705
779
|
}
|
|
706
780
|
/**
|
|
707
|
-
* **
|
|
708
|
-
*
|
|
709
|
-
* Client used to access the Anime Endpoints:
|
|
710
|
-
*
|
|
711
|
-
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
712
|
-
*/
|
|
713
|
-
export declare class GenresClient extends BaseClient {
|
|
714
|
-
/**
|
|
715
|
-
* Get Anime genres
|
|
716
|
-
* @param filter Type of the desired genres
|
|
717
|
-
*/
|
|
718
|
-
getAnimeGenres(filter?: GenresFilter): Promise<JikanResponse<Genre[]>>;
|
|
719
|
-
/**
|
|
720
|
-
* Get Manga genres
|
|
721
|
-
* @param filter Type of the desired genres
|
|
722
|
-
*/
|
|
723
|
-
getMangaGenres(filter?: GenresFilter): Promise<JikanResponse<Genre[]>>;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* **Characters Client**
|
|
781
|
+
* **Top Client**
|
|
727
782
|
*
|
|
728
|
-
* Client used to access the
|
|
783
|
+
* Client used to access the Top Endpoints:
|
|
729
784
|
*
|
|
730
785
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
731
786
|
*/
|
|
732
|
-
export declare class
|
|
733
|
-
/**
|
|
734
|
-
* Get complete Character data
|
|
735
|
-
* @param mal_id The Character ID
|
|
736
|
-
* @returns JikanResponse with Character data
|
|
737
|
-
*/
|
|
738
|
-
getCharacterFullById(mal_id: number): Promise<JikanResponse<Character>>;
|
|
739
|
-
/**
|
|
740
|
-
* Get Character data
|
|
741
|
-
* @param mal_id The Character ID
|
|
742
|
-
* @returns JikanResponse with Character data
|
|
743
|
-
*/
|
|
744
|
-
getCharacterById(mal_id: number): Promise<JikanResponse<Character>>;
|
|
745
|
-
/**
|
|
746
|
-
* Get Character anime data
|
|
747
|
-
* @param mal_id The Character ID
|
|
748
|
-
* @returns JikanResponse with CharacterAnime data
|
|
749
|
-
*/
|
|
750
|
-
getCharacterAnime(mal_id: number): Promise<JikanResponse<CharacterAnime[]>>;
|
|
751
|
-
/**
|
|
752
|
-
* Get Character manga data
|
|
753
|
-
* @param mal_id The Character ID
|
|
754
|
-
* @returns JikanResponse with CharacterManga data
|
|
755
|
-
*/
|
|
756
|
-
getCharacterManga(mal_id: number): Promise<JikanResponse<CharacterManga[]>>;
|
|
757
|
-
/**
|
|
758
|
-
* Get Character voices data
|
|
759
|
-
* @param mal_id The Character ID
|
|
760
|
-
* @returns JikanResponse with CharacterVoiceActor data
|
|
761
|
-
*/
|
|
762
|
-
getCharacterVoiceActors(mal_id: number): Promise<JikanResponse<CharacterVoiceActor[]>>;
|
|
763
|
-
/**
|
|
764
|
-
* Get Character pictures data
|
|
765
|
-
* @param mal_id The Character ID
|
|
766
|
-
* @returns JikanResponse with JikanImagesCollection data
|
|
767
|
-
*/
|
|
768
|
-
getCharacterPictures(mal_id: number): Promise<JikanResponse<JikanImagesCollection[]>>;
|
|
787
|
+
export declare class TopClient extends BaseClient {
|
|
769
788
|
/**
|
|
770
|
-
* Get
|
|
771
|
-
@param searchParams Filter parameters
|
|
772
|
-
* @returns JikanResponse with
|
|
789
|
+
* Get the top Animes
|
|
790
|
+
* @param searchParams Filter parameters
|
|
791
|
+
* @returns JikanResponse with Anime array data
|
|
773
792
|
*/
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* **Schedules Client**
|
|
778
|
-
*
|
|
779
|
-
* Client used to access the Schedules Endpoints
|
|
780
|
-
*
|
|
781
|
-
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
782
|
-
*/
|
|
783
|
-
export declare class SchedulesClient extends BaseClient {
|
|
793
|
+
getTopAnime(searchParams?: Partial<AnimeTopParams>): Promise<JikanResponse<Anime[]>>;
|
|
784
794
|
/**
|
|
785
|
-
*
|
|
795
|
+
* Get the top Mangas
|
|
786
796
|
* @param searchParams Filter parameters
|
|
787
|
-
* @returns JikanResponse with
|
|
797
|
+
* @returns JikanResponse with Manga array data
|
|
788
798
|
*/
|
|
789
|
-
|
|
799
|
+
getTopManga(searchParams?: Partial<MangaTopParams>): Promise<JikanResponse<Manga[]>>;
|
|
790
800
|
}
|
|
791
801
|
/**
|
|
792
802
|
* **Jikan Client**
|
|
@@ -805,7 +815,7 @@ export declare class JikanClient {
|
|
|
805
815
|
seasons: SeasonsClient;
|
|
806
816
|
constructor(clientOptions?: Partial<ClientArgs>);
|
|
807
817
|
}
|
|
808
|
-
export declare const handleRequest: (requestConfig:
|
|
818
|
+
export declare const handleRequest: (requestConfig: InternalCacheRequestConfig) => InternalCacheRequestConfig;
|
|
809
819
|
export declare const handleRequestError: (error: AxiosError) => Promise<AxiosError>;
|
|
810
820
|
export declare const handleResponse: (response: CacheAxiosResponse) => CacheAxiosResponse;
|
|
811
821
|
export declare const handleResponseError: (error: AxiosError) => Promise<AxiosError>;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setupCache as I}from"axios-cache-interceptor";import v from"axios";var x=(a=>(a.REST="https://api.jikan.moe/v4",a))(x||{});var k=(p=>(p.AnimeSearch="/anime",p.AnimeFullById="/anime/{id}/full",p.AnimeById="/anime/{id}",p.AnimeCharacters="/anime/{id}/characters",p.AnimeStaff="/anime/{id}/staff",p.AnimeEpisodes="/anime/{id}/episodes",p.AnimeEpisodeById="/anime/{id}/episodes/{episode}",p.AnimeVideos="/anime/{id}/videos",p.AnimeVideosEpisodes="/anime/{id}/videos/episodes",p.AnimePictures="/anime/{id}/pictures",p.AnimeStatistics="/anime/{id}/statistics",p.AnimeRecommendations="/anime/{id}/recommendations",p))(k||{});var J=(i=>(i.CharacterFullById="/characters/{id}/full",i.CharacterById="/characters/{id}",i.CharacterAnime="/characters/{id}/anime",i.CharactersManga="/characters/{id}/manga",i.CharacterVoiceActors="/characters/{id}/voices",i.CharacterPictures="/characters/{id}/pictures",i.CharacterSearch="/characters",i))(J||{});var P=(n=>(n.AnimeGenres="/genres/anime",n.MangaGenres="genres/manga",n))(P||{});var f=(i=>(i.MangaSearch="/manga",i.MangaFullById="/manga/{id}/full",i.MangaById="/manga/{id}",i.MangaCharacters="/manga/{id}/characters",i.MangaPictures="/manga/{id}/pictures",i.MangaStatistics="/manga/{id}/statistics",i.MangaRecommendations="/manga/{id}/recommendations",i))(f||{});var C=(s=>(s.Season="/seasons/{year}/{season}",s.SeasonNow="/seasons/now",s.SeasonsList="/seasons",s.SeasonUpcoming="/seasons/upcoming",s))(C||{});var b=(n=>(n.TopAnime="/top/anime",n.TopManga="/top/manga",n))(b||{});var y=t=>(console.info(`[Request] ${t.method?.toUpperCase()||""} | ${t.url||""}`),t),w=t=>{throw console.error(`[Request Error] CODE ${t.code||"UNKNOWN"} | ${t.message}`),t},M=t=>(console.info(`[Request Response] ${t.config.method?.toUpperCase()||""} | ${t.config.url||""}`,t.data),t),E=t=>{throw console.error(`[ Response Error ] CODE ${t.code||"UNKNOWN"} | ${t.message}`),t};var m=class{api;constructor(a={}){this.api=I(v.create({baseURL:a.baseURL??"https://api.jikan.moe/v4",headers:{"Content-Type":"application/json"}}),a.cacheOptions),a.enableLogging&&this.addLoggingInterceptors()}replacePathParams(a,n){for(let r of Object.keys(n)){if(!a.match(`{${r}}`))throw new Error(`Path does not contain "${r}" parameter.`);a=a.replace(`{${r}}`,String(n[r]))}return a}addLoggingInterceptors(){this.api.interceptors.request.use(a=>y(a),a=>w(a)),this.api.interceptors.response.use(a=>M(a),a=>E(a))}};var h=class extends m{async getAnimeSearch(a){return new Promise((n,r)=>{let s=`${"/anime"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeFullById(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/full",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeById(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeCharacters(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/characters",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeStaff(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/staff",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeEpisodes(a,n=1){return new Promise((r,s)=>{let e=this.replacePathParams("/anime/{id}/episodes",{id:a});this.api.get(e,{params:{page:n}}).then(o=>r(o.data)).catch(o=>s(o))})}async getAnimeEpisodeById(a,n){return new Promise((r,s)=>{let e=this.replacePathParams("/anime/{id}/episodes/{episode}",{id:a,episode:n});this.api.get(e).then(o=>r(o.data)).catch(o=>s(o))})}async getAnimeVideos(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/videos",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeEpisodeVideos(a,n=1){return new Promise((r,s)=>{let e=this.replacePathParams("/anime/{id}/videos/episodes",{id:a});this.api.get(e,{params:{page:n}}).then(o=>r(o.data)).catch(o=>s(o))})}async getAnimePictures(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/pictures",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeStatistics(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/statistics",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getAnimeRecommendations(a){return new Promise((n,r)=>{let s=this.replacePathParams("/anime/{id}/recommendations",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}};var g=class extends m{async getMangaSearch(a){return new Promise((n,r)=>{let s=`${"/manga"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaFullById(a){return new Promise((n,r)=>{let s=this.replacePathParams("/manga/{id}/full",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaById(a){return new Promise((n,r)=>{let s=this.replacePathParams("/manga/{id}",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaCharacters(a){return new Promise((n,r)=>{let s=this.replacePathParams("/manga/{id}/characters",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaPictures(a){return new Promise((n,r)=>{let s=this.replacePathParams("/manga/{id}/pictures",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaStatistics(a){return new Promise((n,r)=>{let s=this.replacePathParams("/manga/{id}/statistics",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaRecommendations(a){return new Promise((n,r)=>{let s=this.replacePathParams("/manga/{id}/recommendations",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}};var u=class extends m{async getTopAnime(a){return new Promise((n,r)=>{let s=`${"/top/anime"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}async getTopManga(a){return new Promise((n,r)=>{let s=`${"/top/manga"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}};var d=class extends m{async getSeason(a,n,r){return new Promise((s,e)=>{let o=this.replacePathParams("/seasons/{year}/{season}",{year:a,season:n});this.api.get(o,{params:r}).then(i=>s(i.data)).catch(i=>e(i))})}async getSeasonNow(a){return new Promise((n,r)=>{let s=`${"/seasons/now"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}async getSeasonsList(){return new Promise((a,n)=>{let r=`${"/seasons"}`;this.api.get(r).then(s=>a(s.data)).catch(s=>n(s))})}async getSeasonUpcoming(a){return new Promise((n,r)=>{let s=`${"/seasons/upcoming"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}};var R=class extends m{async getAnimeGenres(a){return new Promise((n,r)=>{let s=`${"/genres/anime"}`;this.api.get(s,{params:{filter:a}}).then(e=>n(e.data)).catch(e=>r(e))})}async getMangaGenres(a){return new Promise((n,r)=>{let s=`${"genres/manga"}`;this.api.get(s,{params:{filter:a}}).then(e=>n(e.data)).catch(e=>r(e))})}};var l=class extends m{async getCharacterFullById(a){return new Promise((n,r)=>{let s=this.replacePathParams("/characters/{id}/full",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getCharacterById(a){return new Promise((n,r)=>{let s=this.replacePathParams("/characters/{id}",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getCharacterAnime(a){return new Promise((n,r)=>{let s=this.replacePathParams("/characters/{id}/anime",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getCharacterManga(a){return new Promise((n,r)=>{let s=this.replacePathParams("/characters/{id}/manga",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getCharacterVoiceActors(a){return new Promise((n,r)=>{let s=this.replacePathParams("/characters/{id}/voices",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getCharacterPictures(a){return new Promise((n,r)=>{let s=this.replacePathParams("/characters/{id}/pictures",{id:a});this.api.get(s).then(e=>n(e.data)).catch(e=>r(e))})}async getCharacterSearch(a){return new Promise((n,r)=>{let s=`${"/characters"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}};var A=class extends m{async getSchedules(a){return new Promise((n,r)=>{let s=`${"/schedules"}`;this.api.get(s,{params:a}).then(e=>n(e.data)).catch(e=>r(e))})}};var S=class{anime;characters;genres;manga;top;schedules;seasons;constructor(a){this.anime=new h(a),this.characters=new l(a),this.genres=new R(a),this.manga=new g(a),this.top=new u(a),this.schedules=new A(a),this.seasons=new d(a)}};var _=(o=>(o.tv="TV",o.movie="Movie",o.ova="Ova",o.special="Special",o.ona="Ona",o.music="Music",o))(_||{}),B=(s=>(s.finished="Finished Airing",s.airing="Currently Airing",s.complete="Complete",s.upcoming="Not yet aired",s))(B||{}),V=(o=>(o.g="g",o.pg="pg",o.pg13="pg13",o.r17="r17",o.r="r",o.rx="rx",o))(V||{}),$=(s=>(s.spring="spring",s.summer="summer",s.fall="fall",s.winter="winter",s))($||{});var N=(n=>(n.main="Main",n.supporting="Supporting",n))(N||{});var L=(i=>(i.manga="Manga",i.novel="Novel",i.lightnovel="Lightnovel",i.oneshot="Oneshot",i.doujin="Doujin",i.manhwa="Manhwa",i.manhua="Manhua",i))(L||{}),T=(e=>(e.publishing="Publishing",e.complete="Complete",e.hiatus="Hiatus",e.discontinued="Discontinued",e.upcoming="Upcoming",e))(T||{});var q=(n=>(n.asc="asc",n.desc="desc",n))(q||{}),G=(c=>(c.mal_id="mal_id",c.title="title",c.start_date="start_date",c.end_date="end_date",c.score="score",c.scored_by="scored_by",c.rank="rank",c.popularity="popularity",c.members="members",c.favorites="favorites",c))(G||{}),D=(r=>(r.type="type",r.rating="rating",r.episodes="episodes",r))(D||{}),U=(n=>(n.chapters="chapters",n.volumes="volumes",n))(U||{});var j=(s=>(s.airing="airing",s.upcoming="upcoming",s.bypopularity="bypopularity",s.favorite="favorite",s))(j||{}),z=(s=>(s.publishing="publishing",s.upcoming="upcoming",s.bypopularity="bypopularity",s.favorite="favorite",s))(z||{});var K=(s=>(s.genres="genres",s.explicit_genres="explicit_genres",s.theme="themes",s.demographics="demographics",s))(K||{});var W=(r=>(r.mal_id="mal_id",r.name="name",r.favorites="favorites",r))(W||{});var Y=(i=>(i.monday="monday",i.tuesday="tuesday",i.wednesday="wednesday",i.thursday="thursday",i.friday="friday",i.unknown="unknown",i.other="other",i))(Y||{});export{h as AnimeClient,k as AnimeEndpoints,V as AnimeRating,D as AnimeSearchOrder,$ as AnimeSeason,B as AnimeStatus,_ as AnimeType,m as BaseClient,x as BaseURL,N as CharacterRole,l as CharactersClient,J as CharactersEndpoints,W as CharactersSearchOrder,R as GenresClient,P as GenresEndpoints,K as GenresFilter,S as JikanClient,g as MangaClient,f as MangaEndpoints,U as MangaSearchOrder,T as MangaStatus,L as MangaType,A as SchedulesClient,Y as SchedulesFilter,G as SearchOrder,d as SeasonsClient,C as SeasonsEndpoints,q as SortOptions,j as TopAnimeFilter,u as TopClient,b as TopEndpoints,z as TopMangaFilter,y as handleRequest,w as handleRequestError,M as handleResponse,E as handleResponseError};
|
|
1
|
+
var A=(n=>(n.REST="https://api.jikan.moe/v4",n))(A||{});var k=(p=>(p.AnimeSearch="/anime",p.AnimeFullById="/anime/{id}/full",p.AnimeById="/anime/{id}",p.AnimeCharacters="/anime/{id}/characters",p.AnimeStaff="/anime/{id}/staff",p.AnimeEpisodes="/anime/{id}/episodes",p.AnimeEpisodeById="/anime/{id}/episodes/{episode}",p.AnimeVideos="/anime/{id}/videos",p.AnimeVideosEpisodes="/anime/{id}/videos/episodes",p.AnimePictures="/anime/{id}/pictures",p.AnimeStatistics="/anime/{id}/statistics",p.AnimeRecommendations="/anime/{id}/recommendations",p))(k||{});var J=(i=>(i.CharacterFullById="/characters/{id}/full",i.CharacterById="/characters/{id}",i.CharacterAnime="/characters/{id}/anime",i.CharactersManga="/characters/{id}/manga",i.CharacterVoiceActors="/characters/{id}/voices",i.CharacterPictures="/characters/{id}/pictures",i.CharacterSearch="/characters",i))(J||{});var P=(a=>(a.AnimeGenres="/genres/anime",a.MangaGenres="genres/manga",a))(P||{});var f=(i=>(i.MangaSearch="/manga",i.MangaFullById="/manga/{id}/full",i.MangaById="/manga/{id}",i.MangaCharacters="/manga/{id}/characters",i.MangaPictures="/manga/{id}/pictures",i.MangaStatistics="/manga/{id}/statistics",i.MangaRecommendations="/manga/{id}/recommendations",i))(f||{});var C=(s=>(s.Season="/seasons/{year}/{season}",s.SeasonNow="/seasons/now",s.SeasonsList="/seasons",s.SeasonUpcoming="/seasons/upcoming",s))(C||{});var b=(a=>(a.TopAnime="/top/anime",a.TopManga="/top/manga",a))(b||{});import S from"axios";import{setupCache as v}from"axios-cache-interceptor";var y=t=>(console.info(`[Request] ${t.method?.toUpperCase()??""} | ${t.url??""}`),t),w=t=>{throw console.error(`[Request Error] CODE ${t.code??"UNKNOWN"} | ${t.message}`),t},E=t=>(console.info(`[Request Response] ${t.config.method?.toUpperCase()??""} | ${t.config.url??""}`,t.data),t),M=t=>{throw console.error(`[ Response Error ] CODE ${t.code??"UNKNOWN"} | ${t.message}`),t};var m=class{api;constructor(n={}){this.api=v(S.create({baseURL:n.baseURL??"https://api.jikan.moe/v4",headers:{"Content-Type":"application/json"}}),{...n.cacheOptions,cacheTakeover:!1}),n.enableLogging&&this.addLoggingInterceptors()}replacePathParams(n,a){for(let r of Object.keys(a)){if(!n.match(`{${r}}`))throw new Error(`Path does not contain "${r}" parameter.`);n=n.replace(`{${r}}`,String(a[r]))}return n}addLoggingInterceptors(){this.api.interceptors.request.use(n=>y(n),n=>w(n)),this.api.interceptors.response.use(n=>E(n),n=>M(n))}};var h=class extends m{async getAnimeSearch(n){return new Promise((a,r)=>{let s="/anime";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeFullById(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/full",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeById(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeCharacters(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/characters",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeStaff(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/staff",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeEpisodes(n,a=1){return new Promise((r,s)=>{let e=this.replacePathParams("/anime/{id}/episodes",{id:n});this.api.get(e,{params:{page:a}}).then(o=>r(o.data)).catch(o=>s(o))})}async getAnimeEpisodeById(n,a){return new Promise((r,s)=>{let e=this.replacePathParams("/anime/{id}/episodes/{episode}",{id:n,episode:a});this.api.get(e).then(o=>r(o.data)).catch(o=>s(o))})}async getAnimeVideos(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/videos",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeEpisodeVideos(n,a=1){return new Promise((r,s)=>{let e=this.replacePathParams("/anime/{id}/videos/episodes",{id:n});this.api.get(e,{params:{page:a}}).then(o=>r(o.data)).catch(o=>s(o))})}async getAnimePictures(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/pictures",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeStatistics(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/statistics",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getAnimeRecommendations(n){return new Promise((a,r)=>{let s=this.replacePathParams("/anime/{id}/recommendations",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}};var g=class extends m{async getCharacterFullById(n){return new Promise((a,r)=>{let s=this.replacePathParams("/characters/{id}/full",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getCharacterById(n){return new Promise((a,r)=>{let s=this.replacePathParams("/characters/{id}",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getCharacterAnime(n){return new Promise((a,r)=>{let s=this.replacePathParams("/characters/{id}/anime",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getCharacterManga(n){return new Promise((a,r)=>{let s=this.replacePathParams("/characters/{id}/manga",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getCharacterVoiceActors(n){return new Promise((a,r)=>{let s=this.replacePathParams("/characters/{id}/voices",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getCharacterPictures(n){return new Promise((a,r)=>{let s=this.replacePathParams("/characters/{id}/pictures",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getCharacterSearch(n){return new Promise((a,r)=>{let s="/characters";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}};var u=class extends m{async getAnimeGenres(n){return new Promise((a,r)=>{let s="/genres/anime";this.api.get(s,{params:{filter:n}}).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaGenres(n){return new Promise((a,r)=>{let s="genres/manga";this.api.get(s,{params:{filter:n}}).then(e=>a(e.data)).catch(e=>r(e))})}};var d=class extends m{async getMangaSearch(n){return new Promise((a,r)=>{let s="/manga";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaFullById(n){return new Promise((a,r)=>{let s=this.replacePathParams("/manga/{id}/full",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaById(n){return new Promise((a,r)=>{let s=this.replacePathParams("/manga/{id}",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaCharacters(n){return new Promise((a,r)=>{let s=this.replacePathParams("/manga/{id}/characters",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaPictures(n){return new Promise((a,r)=>{let s=this.replacePathParams("/manga/{id}/pictures",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaStatistics(n){return new Promise((a,r)=>{let s=this.replacePathParams("/manga/{id}/statistics",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}async getMangaRecommendations(n){return new Promise((a,r)=>{let s=this.replacePathParams("/manga/{id}/recommendations",{id:n});this.api.get(s).then(e=>a(e.data)).catch(e=>r(e))})}};var R=class extends m{async getSchedules(n){return new Promise((a,r)=>{let s="/schedules";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}};var l=class extends m{async getSeason(n,a,r){return new Promise((s,e)=>{let o=this.replacePathParams("/seasons/{year}/{season}",{year:n,season:a});this.api.get(o,{params:r}).then(i=>s(i.data)).catch(i=>e(i))})}async getSeasonNow(n){return new Promise((a,r)=>{let s="/seasons/now";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}async getSeasonsList(){return new Promise((n,a)=>{let r="/seasons";this.api.get(r).then(s=>n(s.data)).catch(s=>a(s))})}async getSeasonUpcoming(n){return new Promise((a,r)=>{let s="/seasons/upcoming";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}};var x=class extends m{async getTopAnime(n){return new Promise((a,r)=>{let s="/top/anime";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}async getTopManga(n){return new Promise((a,r)=>{let s="/top/manga";this.api.get(s,{params:n}).then(e=>a(e.data)).catch(e=>r(e))})}};var I=class{anime;characters;genres;manga;top;schedules;seasons;constructor(n){this.anime=new h(n),this.characters=new g(n),this.genres=new u(n),this.manga=new d(n),this.top=new x(n),this.schedules=new R(n),this.seasons=new l(n)}};var _=(o=>(o.tv="TV",o.movie="Movie",o.ova="Ova",o.special="Special",o.ona="Ona",o.music="Music",o))(_||{}),B=(s=>(s.finished="Finished Airing",s.airing="Currently Airing",s.complete="Complete",s.upcoming="Not yet aired",s))(B||{}),V=(o=>(o.g="g",o.pg="pg",o.pg13="pg13",o.r17="r17",o.r="r",o.rx="rx",o))(V||{}),$=(s=>(s.spring="spring",s.summer="summer",s.fall="fall",s.winter="winter",s))($||{});var N=(a=>(a.main="Main",a.supporting="Supporting",a))(N||{});var T=(i=>(i.manga="Manga",i.novel="Novel",i.lightnovel="Lightnovel",i.oneshot="Oneshot",i.doujin="Doujin",i.manhwa="Manhwa",i.manhua="Manhua",i))(T||{}),L=(e=>(e.publishing="Publishing",e.complete="Complete",e.hiatus="On Hiatus",e.discontinued="Discontinued",e.upcoming="Upcoming",e))(L||{});var q=(r=>(r.mal_id="mal_id",r.name="name",r.favorites="favorites",r))(q||{});var G=(s=>(s.genres="genres",s.explicit_genres="explicit_genres",s.theme="themes",s.demographics="demographics",s))(G||{});var D=(i=>(i.monday="monday",i.tuesday="tuesday",i.wednesday="wednesday",i.thursday="thursday",i.friday="friday",i.unknown="unknown",i.other="other",i))(D||{});var U=(a=>(a.asc="asc",a.desc="desc",a))(U||{}),j=(c=>(c.mal_id="mal_id",c.title="title",c.start_date="start_date",c.end_date="end_date",c.score="score",c.scored_by="scored_by",c.rank="rank",c.popularity="popularity",c.members="members",c.favorites="favorites",c))(j||{}),z=(r=>(r.type="type",r.rating="rating",r.episodes="episodes",r))(z||{}),K=(r=>(r.airing="airing",r.complete="complete",r.upcoming="upcoming",r))(K||{}),W=(a=>(a.chapters="chapters",a.volumes="volumes",a))(W||{}),Y=(e=>(e.publishing="publishing",e.complete="complete",e.hiatus="hiatus",e.discontinued="discontinued",e.upcoming="upcoming",e))(Y||{});var H=(s=>(s.airing="airing",s.upcoming="upcoming",s.bypopularity="bypopularity",s.favorite="favorite",s))(H||{}),Q=(s=>(s.publishing="publishing",s.upcoming="upcoming",s.bypopularity="bypopularity",s.favorite="favorite",s))(Q||{});export{h as AnimeClient,k as AnimeEndpoints,V as AnimeRating,z as AnimeSearchOrder,K as AnimeSearchStatus,$ as AnimeSeason,B as AnimeStatus,_ as AnimeType,m as BaseClient,A as BaseURL,N as CharacterRole,g as CharactersClient,J as CharactersEndpoints,q as CharactersSearchOrder,u as GenresClient,P as GenresEndpoints,G as GenresFilter,I as JikanClient,d as MangaClient,f as MangaEndpoints,W as MangaSearchOrder,Y as MangaSearchStatus,L as MangaStatus,T as MangaType,R as SchedulesClient,D as SchedulesFilter,j as SearchOrder,l as SeasonsClient,C as SeasonsEndpoints,U as SortOptions,H as TopAnimeFilter,x as TopClient,b as TopEndpoints,Q as TopMangaFilter,y as handleRequest,w as handleRequestError,E as handleResponse,M as handleResponseError};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tutkli/jikan-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Node.js wrapper for the Jikan API with built-in typings.",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
"test:coverage": "jest --coverage",
|
|
16
16
|
"test:dev": "jest --verbose --colors --expand --maxWorkers=50% --detectOpenHandles --errorOnDeprecated --bail",
|
|
17
17
|
"lint:fix": "npx eslint src/** --fix",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"docs:preview": "vitepress preview docs"
|
|
18
|
+
"prettify": "prettier --write .",
|
|
19
|
+
"version": "auto-changelog -p && git add CHANGELOG.md"
|
|
21
20
|
},
|
|
22
21
|
"repository": {
|
|
23
22
|
"type": "git",
|
|
@@ -38,29 +37,33 @@
|
|
|
38
37
|
"url": "https://github.com/tutkli/jikan-ts/issues"
|
|
39
38
|
},
|
|
40
39
|
"homepage": "https://github.com/tutkli/jikan-ts#readme",
|
|
41
|
-
"
|
|
42
|
-
"axios": "^
|
|
43
|
-
"axios-cache-interceptor": "^
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"axios": "^1.6.7",
|
|
42
|
+
"axios-cache-interceptor": "^1.5.1"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@swc/core": "1.
|
|
47
|
-
"@swc/jest": "0.2.
|
|
48
|
-
"@types/jest": "29.5.
|
|
49
|
-
"@types/node": "20.
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "
|
|
51
|
-
"@typescript-eslint/parser": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
45
|
+
"@swc/core": "1.4.0",
|
|
46
|
+
"@swc/jest": "0.2.36",
|
|
47
|
+
"@types/jest": "29.5.12",
|
|
48
|
+
"@types/node": "20.11.16",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
50
|
+
"@typescript-eslint/parser": "6.21.0",
|
|
51
|
+
"auto-changelog": "^2.4.0",
|
|
52
|
+
"axios": "^1.6.7",
|
|
53
|
+
"axios-cache-interceptor": "^1.5.1",
|
|
54
|
+
"dts-bundle-generator": "9.3.1",
|
|
55
|
+
"esbuild": "0.20.0",
|
|
56
|
+
"esbuild-node-externals": "1.12.0",
|
|
57
|
+
"eslint": "8.56.0",
|
|
58
|
+
"eslint-config-prettier": "9.1.0",
|
|
59
|
+
"eslint-plugin-jest": "27.6.3",
|
|
58
60
|
"eslint-plugin-node": "^11.1.0",
|
|
59
|
-
"eslint-plugin-prettier": "
|
|
60
|
-
"jest": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
61
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
62
|
+
"jest": "29.7.0",
|
|
63
|
+
"lint-staged": "^15.2.2",
|
|
64
|
+
"prettier": "3.2.5",
|
|
65
|
+
"prettier-plugin-organize-imports": "^3.2.4",
|
|
66
|
+
"rimraf": "5.0.5",
|
|
67
|
+
"typescript": "5.3.3"
|
|
65
68
|
}
|
|
66
69
|
}
|