@tutkli/jikan-ts 0.6.62 → 1.0.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/README.md +3 -0
- package/dist/index.d.ts +190 -35
- package/dist/index.js +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { AxiosCacheInstance, CacheAxiosResponse, CacheOptions, CacheRequestConfi
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* **Client Args**
|
|
10
|
+
*
|
|
10
11
|
* Used to pass optional configuration for logging and cache to the clients.
|
|
11
12
|
*/
|
|
12
13
|
export interface ClientArgs {
|
|
@@ -28,11 +29,13 @@ export interface ClientArgs {
|
|
|
28
29
|
baseURL: string;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
|
-
* **Base Client**
|
|
32
|
+
* **Base Client**
|
|
33
|
+
*
|
|
34
|
+
* This client is responsible for creating an Axios Instance and the cache and logging configurations
|
|
32
35
|
*/
|
|
33
36
|
export declare abstract class BaseClient {
|
|
34
37
|
api: AxiosCacheInstance;
|
|
35
|
-
|
|
38
|
+
constructor(clientOptions?: Partial<ClientArgs>);
|
|
36
39
|
protected replacePathParams(path: string, params: {
|
|
37
40
|
[key in string]: unknown;
|
|
38
41
|
}): string;
|
|
@@ -84,26 +87,31 @@ export interface JikanImagesCollection {
|
|
|
84
87
|
large_image_url?: string;
|
|
85
88
|
maximum_image_url?: string;
|
|
86
89
|
}
|
|
90
|
+
export interface JikanPerson {
|
|
91
|
+
mal_id: number;
|
|
92
|
+
url: string;
|
|
93
|
+
images: JikanImages;
|
|
94
|
+
name: string;
|
|
95
|
+
}
|
|
87
96
|
export interface CommonCharacter {
|
|
88
|
-
character: CommonCharacterData
|
|
97
|
+
character: CommonCharacterData & {
|
|
98
|
+
name: string;
|
|
99
|
+
};
|
|
89
100
|
role: CharacterRole;
|
|
90
101
|
}
|
|
91
102
|
export interface CommonCharacterData {
|
|
92
103
|
mal_id: number;
|
|
93
104
|
url: string;
|
|
94
105
|
images: JikanImages;
|
|
95
|
-
|
|
106
|
+
}
|
|
107
|
+
export interface CharacterVoiceActor {
|
|
108
|
+
person: JikanPerson;
|
|
109
|
+
language: string;
|
|
96
110
|
}
|
|
97
111
|
export declare enum CharacterRole {
|
|
98
112
|
main = "Main",
|
|
99
113
|
supporting = "Supporting"
|
|
100
114
|
}
|
|
101
|
-
export interface JikanPerson {
|
|
102
|
-
mal_id: number;
|
|
103
|
-
url: string;
|
|
104
|
-
images: JikanImages;
|
|
105
|
-
name: string;
|
|
106
|
-
}
|
|
107
115
|
export interface Recommendation {
|
|
108
116
|
entry: RecommendationEntry;
|
|
109
117
|
}
|
|
@@ -241,11 +249,7 @@ export declare enum AnimeSeason {
|
|
|
241
249
|
winter = "winter"
|
|
242
250
|
}
|
|
243
251
|
export interface AnimeCharacter extends CommonCharacter {
|
|
244
|
-
voice_actors:
|
|
245
|
-
}
|
|
246
|
-
export interface AnimeCharacterVoiceActor {
|
|
247
|
-
person: JikanPerson;
|
|
248
|
-
language: string;
|
|
252
|
+
voice_actors: CharacterVoiceActor[];
|
|
249
253
|
}
|
|
250
254
|
export interface AnimeStaff {
|
|
251
255
|
person: JikanPerson;
|
|
@@ -376,6 +380,7 @@ export interface JikanSearchParams {
|
|
|
376
380
|
producers?: string;
|
|
377
381
|
start_date?: string;
|
|
378
382
|
end_date?: string;
|
|
383
|
+
unapproved?: boolean;
|
|
379
384
|
}
|
|
380
385
|
/**
|
|
381
386
|
* QueryParams used in **getMangaSearch** call
|
|
@@ -443,6 +448,71 @@ export interface JikanSeasonsParams {
|
|
|
443
448
|
*
|
|
444
449
|
*/
|
|
445
450
|
export type SeasonNowParams = Omit<JikanSeasonsParams, "filter">;
|
|
451
|
+
export declare enum GenresFilter {
|
|
452
|
+
genres = "genres",
|
|
453
|
+
explicit_genres = "explicit_genres",
|
|
454
|
+
theme = "themes",
|
|
455
|
+
demographics = "demographics"
|
|
456
|
+
}
|
|
457
|
+
export interface CharactersSearchParams {
|
|
458
|
+
page?: number;
|
|
459
|
+
limit?: number;
|
|
460
|
+
q?: string;
|
|
461
|
+
order_by?: CharactersSearchOrder;
|
|
462
|
+
sort?: SortOptions;
|
|
463
|
+
letter?: string;
|
|
464
|
+
}
|
|
465
|
+
export declare enum CharactersSearchOrder {
|
|
466
|
+
mal_id = "mal_id",
|
|
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
|
+
};
|
|
511
|
+
}
|
|
512
|
+
export interface Genre extends JikanNamedResource {
|
|
513
|
+
mal_id: number;
|
|
514
|
+
count: number;
|
|
515
|
+
}
|
|
446
516
|
/**
|
|
447
517
|
* **Anime Client**
|
|
448
518
|
*
|
|
@@ -451,10 +521,6 @@ export type SeasonNowParams = Omit<JikanSeasonsParams, "filter">;
|
|
|
451
521
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
452
522
|
*/
|
|
453
523
|
export declare class AnimeClient extends BaseClient {
|
|
454
|
-
/**
|
|
455
|
-
* @argument clientOptions Options for the client.
|
|
456
|
-
*/
|
|
457
|
-
constructor(clientOptions?: Partial<ClientArgs>);
|
|
458
524
|
/**
|
|
459
525
|
* Get all the Animes within the given filter. Returns all the Animes if no filters are given.
|
|
460
526
|
* @param searchParams Filter parameters
|
|
@@ -539,10 +605,6 @@ export declare class AnimeClient extends BaseClient {
|
|
|
539
605
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
540
606
|
*/
|
|
541
607
|
export declare class MangaClient extends BaseClient {
|
|
542
|
-
/**
|
|
543
|
-
* @argument clientOptions Options for the client.
|
|
544
|
-
*/
|
|
545
|
-
constructor(clientOptions?: Partial<ClientArgs>);
|
|
546
608
|
/**
|
|
547
609
|
* Get all the filtered Mangas. Returns all the Mangas if no filters are given.
|
|
548
610
|
* @param searchParams Filter parameters
|
|
@@ -594,10 +656,6 @@ export declare class MangaClient extends BaseClient {
|
|
|
594
656
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
595
657
|
*/
|
|
596
658
|
export declare class TopClient extends BaseClient {
|
|
597
|
-
/**
|
|
598
|
-
* @argument clientOptions Options for the client.
|
|
599
|
-
*/
|
|
600
|
-
constructor(clientOptions?: Partial<ClientArgs>);
|
|
601
659
|
/**
|
|
602
660
|
* Get the top Animes
|
|
603
661
|
* @param searchParams Filter parameters
|
|
@@ -619,10 +677,6 @@ export declare class TopClient extends BaseClient {
|
|
|
619
677
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
620
678
|
*/
|
|
621
679
|
export declare class SeasonsClient extends BaseClient {
|
|
622
|
-
/**
|
|
623
|
-
* @argument clientOptions Options for the client.
|
|
624
|
-
*/
|
|
625
|
-
constructor(clientOptions?: Partial<ClientArgs>);
|
|
626
680
|
/**
|
|
627
681
|
* Get the seasonal anime by year and season
|
|
628
682
|
* @param year Season year
|
|
@@ -649,6 +703,91 @@ export declare class SeasonsClient extends BaseClient {
|
|
|
649
703
|
*/
|
|
650
704
|
getSeasonUpcoming(searchParams?: Partial<JikanSeasonsParams>): Promise<JikanResponse<Anime[]>>;
|
|
651
705
|
}
|
|
706
|
+
/**
|
|
707
|
+
* **Anime Client**
|
|
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**
|
|
727
|
+
*
|
|
728
|
+
* Client used to access the Character Endpoints:
|
|
729
|
+
*
|
|
730
|
+
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
731
|
+
*/
|
|
732
|
+
export declare class CharactersClient extends BaseClient {
|
|
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[]>>;
|
|
769
|
+
/**
|
|
770
|
+
* Get all the Characters within the given filter. Returns all Characters if no filters are given.
|
|
771
|
+
@param searchParams Filter parameters
|
|
772
|
+
* @returns JikanResponse with Character array data
|
|
773
|
+
*/
|
|
774
|
+
getCharacterSearch(searchParams: Partial<CharactersSearchParams>): Promise<JikanResponse<Character[]>>;
|
|
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 {
|
|
784
|
+
/**
|
|
785
|
+
* Returns weekly schedule
|
|
786
|
+
* @param searchParams Filter parameters
|
|
787
|
+
* @returns JikanResponse with Anime array data
|
|
788
|
+
*/
|
|
789
|
+
getSchedules(searchParams?: Partial<SchedulesParams>): Promise<JikanResponse<Anime[]>>;
|
|
790
|
+
}
|
|
652
791
|
/**
|
|
653
792
|
* **Jikan Client**
|
|
654
793
|
*
|
|
@@ -658,8 +797,11 @@ export declare class SeasonsClient extends BaseClient {
|
|
|
658
797
|
*/
|
|
659
798
|
export declare class JikanClient {
|
|
660
799
|
anime: AnimeClient;
|
|
800
|
+
characters: CharactersClient;
|
|
801
|
+
genres: GenresClient;
|
|
661
802
|
manga: MangaClient;
|
|
662
803
|
top: TopClient;
|
|
804
|
+
schedules: SchedulesClient;
|
|
663
805
|
seasons: SeasonsClient;
|
|
664
806
|
constructor(clientOptions?: Partial<ClientArgs>);
|
|
665
807
|
}
|
|
@@ -684,6 +826,19 @@ export declare enum AnimeEndpoints {
|
|
|
684
826
|
AnimeStatistics = "/anime/{id}/statistics",
|
|
685
827
|
AnimeRecommendations = "/anime/{id}/recommendations"
|
|
686
828
|
}
|
|
829
|
+
export declare enum CharactersEndpoints {
|
|
830
|
+
CharacterFullById = "/characters/{id}/full",
|
|
831
|
+
CharacterById = "/characters/{id}",
|
|
832
|
+
CharacterAnime = "/characters/{id}/anime",
|
|
833
|
+
CharactersManga = "/characters/{id}/manga",
|
|
834
|
+
CharacterVoiceActors = "/characters/{id}/voices",
|
|
835
|
+
CharacterPictures = "/characters/{id}/pictures",
|
|
836
|
+
CharacterSearch = "/characters"
|
|
837
|
+
}
|
|
838
|
+
export declare enum GenresEndpoints {
|
|
839
|
+
AnimeGenres = "/genres/anime",
|
|
840
|
+
MangaGenres = "genres/manga"
|
|
841
|
+
}
|
|
687
842
|
export declare enum MangaEndpoints {
|
|
688
843
|
MangaSearch = "/manga",
|
|
689
844
|
MangaFullById = "/manga/{id}/full",
|
|
@@ -693,15 +848,15 @@ export declare enum MangaEndpoints {
|
|
|
693
848
|
MangaStatistics = "/manga/{id}/statistics",
|
|
694
849
|
MangaRecommendations = "/manga/{id}/recommendations"
|
|
695
850
|
}
|
|
696
|
-
export declare enum TopEndpoints {
|
|
697
|
-
TopAnime = "/top/anime",
|
|
698
|
-
TopManga = "/top/manga"
|
|
699
|
-
}
|
|
700
851
|
export declare enum SeasonsEndpoints {
|
|
701
852
|
Season = "/seasons/{year}/{season}",
|
|
702
853
|
SeasonNow = "/seasons/now",
|
|
703
854
|
SeasonsList = "/seasons",
|
|
704
855
|
SeasonUpcoming = "/seasons/upcoming"
|
|
705
856
|
}
|
|
857
|
+
export declare enum TopEndpoints {
|
|
858
|
+
TopAnime = "/top/anime",
|
|
859
|
+
TopManga = "/top/manga"
|
|
860
|
+
}
|
|
706
861
|
|
|
707
862
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setupCache as y}from"axios-cache-interceptor";import E from"axios";var R=(s=>(s.REST="https://api.jikan.moe/v4",s))(R||{});var l=(m=>(m.AnimeSearch="/anime",m.AnimeFullById="/anime/{id}/full",m.AnimeById="/anime/{id}",m.AnimeCharacters="/anime/{id}/characters",m.AnimeStaff="/anime/{id}/staff",m.AnimeEpisodes="/anime/{id}/episodes",m.AnimeEpisodeById="/anime/{id}/episodes/{episode}",m.AnimeVideos="/anime/{id}/videos",m.AnimeVideosEpisodes="/anime/{id}/videos/episodes",m.AnimePictures="/anime/{id}/pictures",m.AnimeStatistics="/anime/{id}/statistics",m.AnimeRecommendations="/anime/{id}/recommendations",m))(l||{}),A=(t=>(t.MangaSearch="/manga",t.MangaFullById="/manga/{id}/full",t.MangaById="/manga/{id}",t.MangaCharacters="/manga/{id}/characters",t.MangaPictures="/manga/{id}/pictures",t.MangaStatistics="/manga/{id}/statistics",t.MangaRecommendations="/manga/{id}/recommendations",t))(A||{}),x=(i=>(i.TopAnime="/top/anime",i.TopManga="/top/manga",i))(x||{}),k=(n=>(n.Season="/seasons/{year}/{season}",n.SeasonNow="/seasons/now",n.SeasonsList="/seasons",n.SeasonUpcoming="/seasons/upcoming",n))(k||{});var J=r=>(console.info(`[Request] ${r.method?.toUpperCase()||""} | ${r.url||""}`),r),P=r=>{throw console.error(`[Request Error] CODE ${r.code||"UNKNOWN"} | ${r.message}`),r},f=r=>(console.info(`[Request Response] ${r.config.method?.toUpperCase()||""} | ${r.config.url||""}`,r.data),r),b=r=>{throw console.error(`[ Response Error ] CODE ${r.code||"UNKNOWN"} | ${r.message}`),r};var c=class{api;constructor(s={}){this.api=y(E.create({baseURL:s.baseURL??"https://api.jikan.moe/v4",headers:{"Content-Type":"application/json"}}),s.cacheOptions),s.enableLogging&&this.addLoggingInterceptors()}replacePathParams(s,i){for(let a of Object.keys(i)){if(!s.match(`{${a}}`))throw new Error(`Path does not contain "${a}" parameter.`);s=s.replace(`{${a}}`,String(i[a]))}return s}addLoggingInterceptors(){this.api.interceptors.request.use(s=>J(s),s=>P(s)),this.api.interceptors.response.use(s=>f(s),s=>b(s))}};var g=class extends c{constructor(s){super(s)}async getAnimeSearch(s){return new Promise((i,a)=>{let n=`${"/anime"}`;this.api.get(n,{params:s}).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeFullById(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/full",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeById(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeCharacters(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/characters",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeStaff(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/staff",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeEpisodes(s,i=1){return new Promise((a,n)=>{let e=this.replacePathParams("/anime/{id}/episodes",{id:s});this.api.get(e,{params:{page:i}}).then(o=>a(o.data)).catch(o=>n(o))})}async getAnimeEpisodeById(s,i){return new Promise((a,n)=>{let e=this.replacePathParams("/anime/{id}/episodes/{episode}",{id:s,episode:i});this.api.get(e).then(o=>a(o.data)).catch(o=>n(o))})}async getAnimeVideos(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/videos",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeEpisodeVideos(s,i=1){return new Promise((a,n)=>{let e=this.replacePathParams("/anime/{id}/videos/episodes",{id:s});this.api.get(e,{params:{page:i}}).then(o=>a(o.data)).catch(o=>n(o))})}async getAnimePictures(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/pictures",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeStatistics(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/statistics",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getAnimeRecommendations(s){return new Promise((i,a)=>{let n=this.replacePathParams("/anime/{id}/recommendations",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}};var u=class extends c{constructor(s){super(s)}async getMangaSearch(s){return new Promise((i,a)=>{let n=`${"/manga"}`;this.api.get(n,{params:s}).then(e=>i(e.data)).catch(e=>a(e))})}async getMangaFullById(s){return new Promise((i,a)=>{let n=this.replacePathParams("/manga/{id}/full",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getMangaById(s){return new Promise((i,a)=>{let n=this.replacePathParams("/manga/{id}",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getMangaCharacters(s){return new Promise((i,a)=>{let n=this.replacePathParams("/manga/{id}/characters",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getMangaPictures(s){return new Promise((i,a)=>{let n=this.replacePathParams("/manga/{id}/pictures",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getMangaStatistics(s){return new Promise((i,a)=>{let n=this.replacePathParams("/manga/{id}/statistics",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}async getMangaRecommendations(s){return new Promise((i,a)=>{let n=this.replacePathParams("/manga/{id}/recommendations",{id:s});this.api.get(n).then(e=>i(e.data)).catch(e=>a(e))})}};var h=class extends c{constructor(s){super(s)}async getTopAnime(s){return new Promise((i,a)=>{let n=`${"/top/anime"}`;this.api.get(n,{params:s}).then(e=>i(e.data)).catch(e=>a(e))})}async getTopManga(s){return new Promise((i,a)=>{let n=`${"/top/manga"}`;this.api.get(n,{params:s}).then(e=>i(e.data)).catch(e=>a(e))})}};var d=class extends c{constructor(s){super(s)}async getSeason(s,i,a){return new Promise((n,e)=>{let o=this.replacePathParams("/seasons/{year}/{season}",{year:s,season:i});this.api.get(o,{params:a}).then(t=>n(t.data)).catch(t=>e(t))})}async getSeasonNow(s){return new Promise((i,a)=>{let n=`${"/seasons/now"}`;this.api.get(n,{params:s}).then(e=>i(e.data)).catch(e=>a(e))})}async getSeasonsList(){return new Promise((s,i)=>{let a=`${"/seasons"}`;this.api.get(a).then(n=>s(n.data)).catch(n=>i(n))})}async getSeasonUpcoming(s){return new Promise((i,a)=>{let n=`${"/seasons/upcoming"}`;this.api.get(n,{params:s}).then(e=>i(e.data)).catch(e=>a(e))})}};var C=class{anime;manga;top;seasons;constructor(s){this.anime=new g(s),this.manga=new u(s),this.top=new h(s),this.seasons=new d(s)}};var S=(o=>(o.tv="TV",o.movie="Movie",o.ova="Ova",o.special="Special",o.ona="Ona",o.music="Music",o))(S||{}),M=(n=>(n.finished="Finished Airing",n.airing="Currently Airing",n.complete="Complete",n.upcoming="Not yet aired",n))(M||{}),w=(o=>(o.g="g",o.pg="pg",o.pg13="pg13",o.r17="r17",o.r="r",o.rx="rx",o))(w||{}),I=(n=>(n.spring="spring",n.summer="summer",n.fall="fall",n.winter="winter",n))(I||{});var v=(i=>(i.main="Main",i.supporting="Supporting",i))(v||{});var _=(t=>(t.manga="Manga",t.novel="Novel",t.lightnovel="Lightnovel",t.oneshot="Oneshot",t.doujin="Doujin",t.manhwa="Manhwa",t.manhua="Manhua",t))(_||{}),B=(e=>(e.publishing="Publishing",e.complete="Complete",e.hiatus="Hiatus",e.discontinued="Discontinued",e.upcoming="Upcoming",e))(B||{});var V=(i=>(i.asc="asc",i.desc="desc",i))(V||{}),N=(p=>(p.mal_id="mal_id",p.title="title",p.start_date="start_date",p.end_date="end_date",p.score="score",p.scored_by="scored_by",p.rank="rank",p.popularity="popularity",p.members="members",p.favorites="favorites",p))(N||{}),$=(a=>(a.type="type",a.rating="rating",a.episodes="episodes",a))($||{}),L=(i=>(i.chapters="chapters",i.volumes="volumes",i))(L||{});var T=(n=>(n.airing="airing",n.upcoming="upcoming",n.bypopularity="bypopularity",n.favorite="favorite",n))(T||{}),q=(n=>(n.publishing="publishing",n.upcoming="upcoming",n.bypopularity="bypopularity",n.favorite="favorite",n))(q||{});export{g as AnimeClient,l as AnimeEndpoints,w as AnimeRating,$ as AnimeSearchOrder,I as AnimeSeason,M as AnimeStatus,S as AnimeType,c as BaseClient,R as BaseURL,v as CharacterRole,C as JikanClient,u as MangaClient,A as MangaEndpoints,L as MangaSearchOrder,B as MangaStatus,_ as MangaType,N as SearchOrder,d as SeasonsClient,k as SeasonsEndpoints,V as SortOptions,T as TopAnimeFilter,h as TopClient,x as TopEndpoints,q as TopMangaFilter,J as handleRequest,P as handleRequestError,f as handleResponse,b as handleResponseError};
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tutkli/jikan-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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",
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"axios-cache-interceptor": "^0.10.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@swc/core": "1.3.
|
|
46
|
+
"@swc/core": "1.3.62",
|
|
47
47
|
"@swc/jest": "0.2.26",
|
|
48
|
-
"@types/jest": "29.5.
|
|
49
|
-
"@types/node": "20.
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "5.59.
|
|
51
|
-
"@typescript-eslint/parser": "5.59.
|
|
48
|
+
"@types/jest": "29.5.2",
|
|
49
|
+
"@types/node": "20.2.5",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "5.59.9",
|
|
51
|
+
"@typescript-eslint/parser": "5.59.9",
|
|
52
52
|
"dts-bundle-generator": "8.0.1",
|
|
53
|
-
"esbuild": "0.17.
|
|
53
|
+
"esbuild": "0.17.19",
|
|
54
54
|
"esbuild-node-externals": "1.7.0",
|
|
55
|
-
"eslint": "8.
|
|
55
|
+
"eslint": "8.42.0",
|
|
56
56
|
"eslint-config-prettier": "8.8.0",
|
|
57
57
|
"eslint-plugin-jest": "27.2.1",
|
|
58
58
|
"eslint-plugin-node": "^11.1.0",
|
|
59
59
|
"eslint-plugin-prettier": "^4.2.1",
|
|
60
60
|
"jest": "^29.3.1",
|
|
61
61
|
"prettier": "2.8.8",
|
|
62
|
-
"rimraf": "5.0.
|
|
63
|
-
"typescript": "5.
|
|
62
|
+
"rimraf": "5.0.1",
|
|
63
|
+
"typescript": "5.1.3",
|
|
64
64
|
"vitepress": "^1.0.0-alpha.60"
|
|
65
65
|
}
|
|
66
66
|
}
|