@tutkli/jikan-ts 1.1.0 → 1.2.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/dist/index.d.ts +153 -89
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.3.1
|
|
2
2
|
|
|
3
3
|
import { AxiosError } from 'axios';
|
|
4
|
-
import {
|
|
4
|
+
import { CacheAxiosResponse, CacheOptions, InternalCacheRequestConfig } from 'axios-cache-interceptor';
|
|
5
5
|
|
|
6
6
|
export interface JikanImages {
|
|
7
7
|
jpg: JikanImagesCollection;
|
|
@@ -39,6 +39,21 @@ export declare enum CharacterRole {
|
|
|
39
39
|
main = "Main",
|
|
40
40
|
supporting = "Supporting"
|
|
41
41
|
}
|
|
42
|
+
export interface JikanMoreInfo {
|
|
43
|
+
moreinfo: string;
|
|
44
|
+
}
|
|
45
|
+
export interface JikanNews {
|
|
46
|
+
mal_id: number;
|
|
47
|
+
url: string;
|
|
48
|
+
title: string;
|
|
49
|
+
date: string;
|
|
50
|
+
author_username: string;
|
|
51
|
+
author_url: string;
|
|
52
|
+
forum_url: string;
|
|
53
|
+
images: JikanImages;
|
|
54
|
+
comments: number;
|
|
55
|
+
excerpt: string;
|
|
56
|
+
}
|
|
42
57
|
export interface Recommendation {
|
|
43
58
|
entry: RecommendationEntry;
|
|
44
59
|
}
|
|
@@ -48,6 +63,16 @@ export interface RecommendationEntry {
|
|
|
48
63
|
images: JikanImages;
|
|
49
64
|
title: string;
|
|
50
65
|
}
|
|
66
|
+
export interface JikanRelation {
|
|
67
|
+
relation: string;
|
|
68
|
+
entry: RelationEntry[];
|
|
69
|
+
}
|
|
70
|
+
export interface RelationEntry {
|
|
71
|
+
mal_id: number;
|
|
72
|
+
type: string;
|
|
73
|
+
name: string;
|
|
74
|
+
url: string;
|
|
75
|
+
}
|
|
51
76
|
export interface JikanResource {
|
|
52
77
|
mal_id: number;
|
|
53
78
|
type: string;
|
|
@@ -114,6 +139,22 @@ export interface AnimeEpisode {
|
|
|
114
139
|
recap: boolean;
|
|
115
140
|
forum_url: string;
|
|
116
141
|
}
|
|
142
|
+
export interface AnimeForum {
|
|
143
|
+
mal_id: number;
|
|
144
|
+
url: string;
|
|
145
|
+
title: string;
|
|
146
|
+
date: string;
|
|
147
|
+
author_username: string;
|
|
148
|
+
author_url: string;
|
|
149
|
+
comments: number;
|
|
150
|
+
last_comment: {
|
|
151
|
+
url: string;
|
|
152
|
+
author_username: string;
|
|
153
|
+
author_url: string;
|
|
154
|
+
date: string;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export type AnimeForumFilter = "all" | "episode" | "other";
|
|
117
158
|
export interface AnimePicture {
|
|
118
159
|
images: JikanImages;
|
|
119
160
|
}
|
|
@@ -516,11 +557,14 @@ export interface ClientArgs {
|
|
|
516
557
|
* This client is responsible for creating an Axios Instance and the cache and logging configurations
|
|
517
558
|
*/
|
|
518
559
|
export declare abstract class BaseClient {
|
|
519
|
-
api
|
|
560
|
+
private api;
|
|
520
561
|
constructor(clientOptions?: Partial<ClientArgs>);
|
|
521
|
-
protected
|
|
562
|
+
protected getResource<T>(endpoint: string, pathParams?: {
|
|
563
|
+
[key in string]: unknown;
|
|
564
|
+
}, params?: {
|
|
522
565
|
[key in string]: unknown;
|
|
523
|
-
}):
|
|
566
|
+
}): Promise<T>;
|
|
567
|
+
private replacePathParams;
|
|
524
568
|
private addLoggingInterceptors;
|
|
525
569
|
}
|
|
526
570
|
/**
|
|
@@ -532,80 +576,91 @@ export declare abstract class BaseClient {
|
|
|
532
576
|
*/
|
|
533
577
|
export declare class AnimeClient extends BaseClient {
|
|
534
578
|
/**
|
|
535
|
-
* Get
|
|
536
|
-
* @param
|
|
537
|
-
* @returns JikanResponse with Anime array data
|
|
579
|
+
* Get complete anime resource data
|
|
580
|
+
* @param id anime id
|
|
538
581
|
*/
|
|
539
|
-
|
|
582
|
+
getAnimeFullById(id: number): Promise<JikanResponse<Anime>>;
|
|
540
583
|
/**
|
|
541
|
-
* Get
|
|
542
|
-
* @param
|
|
543
|
-
* @returns JikanResponse with Anime data
|
|
584
|
+
* Get anime resource
|
|
585
|
+
* @param id anime id
|
|
544
586
|
*/
|
|
545
|
-
|
|
587
|
+
getAnimeById(id: number): Promise<JikanResponse<Anime>>;
|
|
546
588
|
/**
|
|
547
|
-
* Get
|
|
548
|
-
* @param
|
|
549
|
-
* @returns JikanResponse with Anime data
|
|
589
|
+
* Get characters of a specific anime
|
|
590
|
+
* @param id anime id
|
|
550
591
|
*/
|
|
551
|
-
|
|
592
|
+
getAnimeCharacters(id: number): Promise<JikanResponse<AnimeCharacter[]>>;
|
|
552
593
|
/**
|
|
553
|
-
* Get
|
|
554
|
-
* @param
|
|
555
|
-
* @returns JikanResponse with AnimeCharacter array data
|
|
594
|
+
* Get staff of a specific Anime
|
|
595
|
+
* @param id anime id
|
|
556
596
|
*/
|
|
557
|
-
|
|
597
|
+
getAnimeStaff(id: number): Promise<JikanResponse<AnimeStaff[]>>;
|
|
558
598
|
/**
|
|
559
|
-
* Get
|
|
560
|
-
* @param
|
|
561
|
-
* @
|
|
599
|
+
* Get a list of all the episodes of a specific anime
|
|
600
|
+
* @param id anime id
|
|
601
|
+
* @param page page number
|
|
562
602
|
*/
|
|
563
|
-
|
|
603
|
+
getAnimeEpisodes(id: number, page?: number): Promise<JikanResponse<AnimeEpisode[]>>;
|
|
564
604
|
/**
|
|
565
|
-
* Get a
|
|
566
|
-
* @param
|
|
567
|
-
* @param
|
|
568
|
-
* @returns JikanResponse with AnimeEpisode array data
|
|
605
|
+
* Get a single episode of a specific anime by its id
|
|
606
|
+
* @param anime_id anime id
|
|
607
|
+
* @param episode_id episode id
|
|
569
608
|
*/
|
|
570
|
-
|
|
609
|
+
getAnimeEpisodeById(anime_id: number, episode_id: number): Promise<JikanResponse<AnimeEpisode>>;
|
|
571
610
|
/**
|
|
572
|
-
* Get a
|
|
573
|
-
* @param
|
|
574
|
-
* @param
|
|
575
|
-
* @returns JikanResponse with AnimeEpisode data
|
|
611
|
+
* Get a list of news articles related to the anime
|
|
612
|
+
* @param id anime id
|
|
613
|
+
* @param page page number
|
|
576
614
|
*/
|
|
577
|
-
|
|
615
|
+
getAnimeNews(id: number, page: number): Promise<JikanResponse<JikanNews>>;
|
|
578
616
|
/**
|
|
579
|
-
* Get
|
|
580
|
-
* @param
|
|
581
|
-
* @
|
|
617
|
+
* Get a list of forum topics related to the anime
|
|
618
|
+
* @param id anime id
|
|
619
|
+
* @param filter forum filter
|
|
582
620
|
*/
|
|
583
|
-
|
|
621
|
+
getAnimeForum(id: number, filter: AnimeForumFilter): Promise<JikanResponse<AnimeForum[]>>;
|
|
584
622
|
/**
|
|
585
|
-
* Get
|
|
586
|
-
* @param
|
|
587
|
-
* @param page The page number
|
|
588
|
-
* @returns JikanResponse with AnimeVideoEpisode array data
|
|
623
|
+
* Get videos related to the anime
|
|
624
|
+
* @param id anime id
|
|
589
625
|
*/
|
|
590
|
-
|
|
626
|
+
getAnimeVideos(id: number): Promise<JikanResponse<AnimeVideos>>;
|
|
591
627
|
/**
|
|
592
|
-
* Get
|
|
593
|
-
* @param
|
|
594
|
-
* @
|
|
628
|
+
* Get episode videos related to the anime
|
|
629
|
+
* @param id anime id
|
|
630
|
+
* @param page page number
|
|
595
631
|
*/
|
|
596
|
-
|
|
632
|
+
getAnimeEpisodeVideos(id: number, page?: number): Promise<JikanResponse<AnimeEpisodeVideo[]>>;
|
|
597
633
|
/**
|
|
598
|
-
* Get
|
|
599
|
-
* @param
|
|
600
|
-
* @returns JikanResponse with AnimeStatistics data
|
|
634
|
+
* Get pictures related to the Anime
|
|
635
|
+
* @param id anime id
|
|
601
636
|
*/
|
|
602
|
-
|
|
637
|
+
getAnimePictures(id: number): Promise<JikanResponse<AnimePicture[]>>;
|
|
603
638
|
/**
|
|
604
|
-
* Get
|
|
605
|
-
* @param
|
|
606
|
-
* @returns JikanResponse with Recommendation array data
|
|
639
|
+
* Get statistics related to the Anime
|
|
640
|
+
* @param id anime id
|
|
607
641
|
*/
|
|
608
|
-
|
|
642
|
+
getAnimeStatistics(id: number): Promise<JikanResponse<AnimeStatistics>>;
|
|
643
|
+
/**
|
|
644
|
+
* Get more info related to the anime
|
|
645
|
+
* @param id anime id
|
|
646
|
+
*/
|
|
647
|
+
getAnimeMoreInfo(id: number): Promise<JikanResponse<JikanMoreInfo>>;
|
|
648
|
+
/**
|
|
649
|
+
* Get recommendations based on the anime
|
|
650
|
+
* @param id anime id
|
|
651
|
+
*/
|
|
652
|
+
getAnimeRecommendations(id: number): Promise<JikanResponse<Recommendation[]>>;
|
|
653
|
+
/**
|
|
654
|
+
* Get anime relations
|
|
655
|
+
* @param id anime id
|
|
656
|
+
*/
|
|
657
|
+
getAnimeRelations(id: number): Promise<JikanResponse<JikanRelation[]>>;
|
|
658
|
+
/**
|
|
659
|
+
* Get all the Animes within the given filter. Returns all the Animes if no filters are given.
|
|
660
|
+
* @param searchParams Filter parameters
|
|
661
|
+
* @returns JikanResponse with Anime array data
|
|
662
|
+
*/
|
|
663
|
+
getAnimeSearch(searchParams?: Partial<AnimeSearchParams>): Promise<JikanResponse<Anime[]>>;
|
|
609
664
|
}
|
|
610
665
|
/**
|
|
611
666
|
* **Characters Client**
|
|
@@ -617,40 +672,40 @@ export declare class AnimeClient extends BaseClient {
|
|
|
617
672
|
export declare class CharactersClient extends BaseClient {
|
|
618
673
|
/**
|
|
619
674
|
* Get complete Character data
|
|
620
|
-
* @param
|
|
675
|
+
* @param id The Character ID
|
|
621
676
|
* @returns JikanResponse with Character data
|
|
622
677
|
*/
|
|
623
|
-
getCharacterFullById(
|
|
678
|
+
getCharacterFullById(id: number): Promise<JikanResponse<Character>>;
|
|
624
679
|
/**
|
|
625
680
|
* Get Character data
|
|
626
|
-
* @param
|
|
681
|
+
* @param id The Character ID
|
|
627
682
|
* @returns JikanResponse with Character data
|
|
628
683
|
*/
|
|
629
|
-
getCharacterById(
|
|
684
|
+
getCharacterById(id: number): Promise<JikanResponse<Character>>;
|
|
630
685
|
/**
|
|
631
686
|
* Get Character anime data
|
|
632
|
-
* @param
|
|
687
|
+
* @param id The Character ID
|
|
633
688
|
* @returns JikanResponse with CharacterAnime data
|
|
634
689
|
*/
|
|
635
|
-
getCharacterAnime(
|
|
690
|
+
getCharacterAnime(id: number): Promise<JikanResponse<CharacterAnime[]>>;
|
|
636
691
|
/**
|
|
637
692
|
* Get Character manga data
|
|
638
|
-
* @param
|
|
693
|
+
* @param id The Character ID
|
|
639
694
|
* @returns JikanResponse with CharacterManga data
|
|
640
695
|
*/
|
|
641
|
-
getCharacterManga(
|
|
696
|
+
getCharacterManga(id: number): Promise<JikanResponse<CharacterManga[]>>;
|
|
642
697
|
/**
|
|
643
698
|
* Get Character voices data
|
|
644
|
-
* @param
|
|
699
|
+
* @param id The Character ID
|
|
645
700
|
* @returns JikanResponse with CharacterVoiceActor data
|
|
646
701
|
*/
|
|
647
|
-
getCharacterVoiceActors(
|
|
702
|
+
getCharacterVoiceActors(id: number): Promise<JikanResponse<CharacterVoiceActor[]>>;
|
|
648
703
|
/**
|
|
649
704
|
* Get Character pictures data
|
|
650
|
-
* @param
|
|
705
|
+
* @param id The Character ID
|
|
651
706
|
* @returns JikanResponse with JikanImagesCollection data
|
|
652
707
|
*/
|
|
653
|
-
getCharacterPictures(
|
|
708
|
+
getCharacterPictures(id: number): Promise<JikanResponse<JikanImagesCollection[]>>;
|
|
654
709
|
/**
|
|
655
710
|
* Get all the Characters within the given filter. Returns all Characters if no filters are given.
|
|
656
711
|
@param searchParams Filter parameters
|
|
@@ -659,9 +714,9 @@ export declare class CharactersClient extends BaseClient {
|
|
|
659
714
|
getCharacterSearch(searchParams: Partial<CharactersSearchParams>): Promise<JikanResponse<Character[]>>;
|
|
660
715
|
}
|
|
661
716
|
/**
|
|
662
|
-
* **
|
|
717
|
+
* **Genres Client**
|
|
663
718
|
*
|
|
664
|
-
* Client used to access the
|
|
719
|
+
* Client used to access the Genres Endpoints:
|
|
665
720
|
*
|
|
666
721
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
667
722
|
*/
|
|
@@ -685,48 +740,48 @@ export declare class GenresClient extends BaseClient {
|
|
|
685
740
|
* See also: [Jikan Documentation](https://docs.api.jikan.moe/)
|
|
686
741
|
*/
|
|
687
742
|
export declare class MangaClient extends BaseClient {
|
|
688
|
-
/**
|
|
689
|
-
* Get all the filtered Mangas. Returns all the Mangas if no filters are given.
|
|
690
|
-
* @param searchParams Filter parameters
|
|
691
|
-
* @returns JikanResponse with Manga array data
|
|
692
|
-
*/
|
|
693
|
-
getMangaSearch(searchParams?: Partial<MangaSearchParams>): Promise<JikanResponse<Manga[]>>;
|
|
694
743
|
/**
|
|
695
744
|
* Get a Manga with full information by its ID
|
|
696
|
-
* @param
|
|
745
|
+
* @param id The Manga ID
|
|
697
746
|
* @returns JikanResponse with Manga data
|
|
698
747
|
*/
|
|
699
|
-
getMangaFullById(
|
|
748
|
+
getMangaFullById(id: number): Promise<JikanResponse<Manga>>;
|
|
700
749
|
/**
|
|
701
750
|
* Get a Manga by its ID
|
|
702
|
-
* @param
|
|
751
|
+
* @param id The Manga ID
|
|
703
752
|
* @returns JikanResponse with Manga data
|
|
704
753
|
*/
|
|
705
|
-
getMangaById(
|
|
754
|
+
getMangaById(id: number): Promise<JikanResponse<Manga>>;
|
|
706
755
|
/**
|
|
707
756
|
* Get Characters of a specific Manga
|
|
708
|
-
* @param
|
|
757
|
+
* @param id The Manga ID
|
|
709
758
|
* @returns JikanResponse with CommonCharacter array data
|
|
710
759
|
*/
|
|
711
|
-
getMangaCharacters(
|
|
760
|
+
getMangaCharacters(id: number): Promise<JikanResponse<CommonCharacter[]>>;
|
|
712
761
|
/**
|
|
713
762
|
* Get Pictures related to a specific Manga
|
|
714
|
-
* @param
|
|
763
|
+
* @param id The Manga ID
|
|
715
764
|
* @returns JikanResponse with JikanImages array data
|
|
716
765
|
*/
|
|
717
|
-
getMangaPictures(
|
|
766
|
+
getMangaPictures(id: number): Promise<JikanResponse<JikanImages[]>>;
|
|
718
767
|
/**
|
|
719
768
|
* Get Statistics related to a specific Manga
|
|
720
|
-
* @param
|
|
769
|
+
* @param id The Manga ID
|
|
721
770
|
* @returns JikanResponse with MangaStatistics data
|
|
722
771
|
*/
|
|
723
|
-
getMangaStatistics(
|
|
772
|
+
getMangaStatistics(id: number): Promise<JikanResponse<MangaStatistics>>;
|
|
724
773
|
/**
|
|
725
774
|
* Get Recommendations related to a specific Manga
|
|
726
|
-
* @param
|
|
775
|
+
* @param id The Manga ID
|
|
727
776
|
* @returns JikanResponse with Recommendation array data
|
|
728
777
|
*/
|
|
729
|
-
getMangaRecommendations(
|
|
778
|
+
getMangaRecommendations(id: number): Promise<JikanResponse<Recommendation[]>>;
|
|
779
|
+
/**
|
|
780
|
+
* Get all the filtered Mangas. Returns all the Mangas if no filters are given.
|
|
781
|
+
* @param searchParams Filter parameters
|
|
782
|
+
* @returns JikanResponse with Manga array data
|
|
783
|
+
*/
|
|
784
|
+
getMangaSearch(searchParams?: Partial<MangaSearchParams>): Promise<JikanResponse<Manga[]>>;
|
|
730
785
|
}
|
|
731
786
|
/**
|
|
732
787
|
* **Schedules Client**
|
|
@@ -823,18 +878,27 @@ export declare enum BaseURL {
|
|
|
823
878
|
REST = "https://api.jikan.moe/v4"
|
|
824
879
|
}
|
|
825
880
|
export declare enum AnimeEndpoints {
|
|
826
|
-
AnimeSearch = "/anime",
|
|
827
881
|
AnimeFullById = "/anime/{id}/full",
|
|
828
882
|
AnimeById = "/anime/{id}",
|
|
829
883
|
AnimeCharacters = "/anime/{id}/characters",
|
|
830
884
|
AnimeStaff = "/anime/{id}/staff",
|
|
831
885
|
AnimeEpisodes = "/anime/{id}/episodes",
|
|
832
886
|
AnimeEpisodeById = "/anime/{id}/episodes/{episode}",
|
|
887
|
+
AnimeNews = "/anime/{id}/news",
|
|
888
|
+
AnimeForum = "/anime/{id}/forum",
|
|
833
889
|
AnimeVideos = "/anime/{id}/videos",
|
|
834
890
|
AnimeVideosEpisodes = "/anime/{id}/videos/episodes",
|
|
835
891
|
AnimePictures = "/anime/{id}/pictures",
|
|
836
892
|
AnimeStatistics = "/anime/{id}/statistics",
|
|
837
|
-
|
|
893
|
+
AnimeMoreInfo = "/anime/{id}/moreinfo",
|
|
894
|
+
AnimeRecommendations = "/anime/{id}/recommendations",
|
|
895
|
+
AnimeUserUpdates = "/anime/{id}/userupdates",
|
|
896
|
+
AnimeReviews = "/anime/{id}/reviews",
|
|
897
|
+
AnimeRelations = "/anime/{id}/relations",
|
|
898
|
+
AnimeThemes = "/anime/{id}/themes",
|
|
899
|
+
AnimeExternal = "/anime/{id}/external",
|
|
900
|
+
AnimeStreaming = "/anime/{id}/streaming",
|
|
901
|
+
AnimeSearch = "/anime"
|
|
838
902
|
}
|
|
839
903
|
export declare enum CharactersEndpoints {
|
|
840
904
|
CharacterFullById = "/characters/{id}/full",
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
var k=(e=>(e.REST="https://api.jikan.moe/v4",e))(k||{});var x=(a=>(a.AnimeFullById="/anime/{id}/full",a.AnimeById="/anime/{id}",a.AnimeCharacters="/anime/{id}/characters",a.AnimeStaff="/anime/{id}/staff",a.AnimeEpisodes="/anime/{id}/episodes",a.AnimeEpisodeById="/anime/{id}/episodes/{episode}",a.AnimeNews="/anime/{id}/news",a.AnimeForum="/anime/{id}/forum",a.AnimeVideos="/anime/{id}/videos",a.AnimeVideosEpisodes="/anime/{id}/videos/episodes",a.AnimePictures="/anime/{id}/pictures",a.AnimeStatistics="/anime/{id}/statistics",a.AnimeMoreInfo="/anime/{id}/moreinfo",a.AnimeRecommendations="/anime/{id}/recommendations",a.AnimeUserUpdates="/anime/{id}/userupdates",a.AnimeReviews="/anime/{id}/reviews",a.AnimeRelations="/anime/{id}/relations",a.AnimeThemes="/anime/{id}/themes",a.AnimeExternal="/anime/{id}/external",a.AnimeStreaming="/anime/{id}/streaming",a.AnimeSearch="/anime",a))(x||{});var b=(n=>(n.CharacterFullById="/characters/{id}/full",n.CharacterById="/characters/{id}",n.CharacterAnime="/characters/{id}/anime",n.CharactersManga="/characters/{id}/manga",n.CharacterVoiceActors="/characters/{id}/voices",n.CharacterPictures="/characters/{id}/pictures",n.CharacterSearch="/characters",n))(b||{});var J=(r=>(r.AnimeGenres="/genres/anime",r.MangaGenres="genres/manga",r))(J||{});var A=(n=>(n.MangaSearch="/manga",n.MangaFullById="/manga/{id}/full",n.MangaById="/manga/{id}",n.MangaCharacters="/manga/{id}/characters",n.MangaPictures="/manga/{id}/pictures",n.MangaStatistics="/manga/{id}/statistics",n.MangaRecommendations="/manga/{id}/recommendations",n))(A||{});var y=(s=>(s.Season="/seasons/{year}/{season}",s.SeasonNow="/seasons/now",s.SeasonsList="/seasons",s.SeasonUpcoming="/seasons/upcoming",s))(y||{});var P=(r=>(r.TopAnime="/top/anime",r.TopManga="/top/manga",r))(P||{});import _ from"axios";import{setupCache as S}from"axios-cache-interceptor";var C=i=>(console.info(`[Request] ${i.method?.toUpperCase()??""} | ${i.url??""}`),i),I=i=>{throw console.error(`[Request Error] CODE ${i.code??"UNKNOWN"} | ${i.message}`),i},M=i=>(console.info(`[Request Response] ${i.config.method?.toUpperCase()??""} | ${i.config.url??""}`,i.data),i),w=i=>{throw console.error(`[ Response Error ] CODE ${i.code??"UNKNOWN"} | ${i.message}`),i};var t=class{api;constructor(e={}){this.api=S(_.create({baseURL:e.baseURL??"https://api.jikan.moe/v4",headers:{"Content-Type":"application/json"}}),{...e.cacheOptions,cacheTakeover:!1}),e.enableLogging&&this.addLoggingInterceptors()}async getResource(e,r={},o={}){return(await this.api.get(this.replacePathParams(e,r),{params:o})).data}replacePathParams(e,r){for(let o of Object.keys(r)){if(!e.match(`{${o}}`))throw new Error(`Path does not contain "${o}" parameter.`);e=e.replace(`{${o}}`,String(r[o]))}return e}addLoggingInterceptors(){this.api.interceptors.request.use(e=>C(e),e=>I(e)),this.api.interceptors.response.use(e=>M(e),e=>w(e))}};var u=class extends t{async getAnimeFullById(e){return this.getResource("/anime/{id}/full",{id:e})}async getAnimeById(e){return this.getResource("/anime/{id}",{id:e})}async getAnimeCharacters(e){return this.getResource("/anime/{id}/characters",{id:e})}async getAnimeStaff(e){return this.getResource("/anime/{id}/staff",{id:e})}async getAnimeEpisodes(e,r=1){return this.getResource("/anime/{id}/episodes",{id:e},{page:r})}async getAnimeEpisodeById(e,r){return this.getResource("/anime/{id}/episodes/{episode}",{id:e,episode:r})}async getAnimeNews(e,r){return this.getResource("/anime/{id}/news",{id:e},{page:r})}async getAnimeForum(e,r){return this.getResource("/anime/{id}/news",{id:e},{filter:r})}async getAnimeVideos(e){return this.getResource("/anime/{id}/videos",{id:e})}async getAnimeEpisodeVideos(e,r=1){return this.getResource("/anime/{id}/videos/episodes",{id:e},{page:r})}async getAnimePictures(e){return this.getResource("/anime/{id}/pictures",{id:e})}async getAnimeStatistics(e){return this.getResource("/anime/{id}/statistics",{id:e})}async getAnimeMoreInfo(e){return this.getResource("/anime/{id}/moreinfo",{id:e})}async getAnimeRecommendations(e){return this.getResource("/anime/{id}/recommendations",{id:e})}async getAnimeRelations(e){return this.getResource("/anime/{id}/relations",{id:e})}async getAnimeSearch(e){return this.getResource("/anime",{},e)}};var g=class extends t{async getCharacterFullById(e){return this.getResource("/characters/{id}/full",{id:e})}async getCharacterById(e){return this.getResource("/characters/{id}",{id:e})}async getCharacterAnime(e){return this.getResource("/characters/{id}/anime",{id:e})}async getCharacterManga(e){return this.getResource("/characters/{id}/manga",{id:e})}async getCharacterVoiceActors(e){return this.getResource("/characters/{id}/voices",{id:e})}async getCharacterPictures(e){return this.getResource("/characters/{id}/pictures",{id:e})}async getCharacterSearch(e){return this.getResource("/characters/{id}/pictures",{},e)}};var l=class extends t{async getAnimeGenres(e){return this.getResource("/genres/anime",{},{filter:e})}async getMangaGenres(e){return this.getResource("genres/manga",{},{filter:e})}};var R=class extends t{async getMangaFullById(e){return this.getResource("/manga/{id}/full",{id:e})}async getMangaById(e){return this.getResource("/manga/{id}",{id:e})}async getMangaCharacters(e){return this.getResource("/manga/{id}/characters",{id:e})}async getMangaPictures(e){return this.getResource("/manga/{id}/pictures",{id:e})}async getMangaStatistics(e){return this.getResource("/manga/{id}/statistics",{id:e})}async getMangaRecommendations(e){return this.getResource("/manga/{id}/recommendations",{id:e})}async getMangaSearch(e){return this.getResource("/manga",{},e)}};var h=class extends t{async getSchedules(e){return this.getResource("/schedules",{},e)}};var d=class extends t{async getSeason(e,r,o){return this.getResource("/seasons/{year}/{season}",{year:e,season:r},o)}async getSeasonNow(e){return this.getResource("/seasons/now",{},e)}async getSeasonsList(){return this.getResource("/seasons")}async getSeasonUpcoming(e){return this.getResource("/seasons/upcoming",{},e)}};var f=class extends t{async getTopAnime(e){return this.getResource("/top/anime",{},e)}async getTopManga(e){return this.getResource("/top/manga",{},e)}};var v=class{anime;characters;genres;manga;top;schedules;seasons;constructor(e){this.anime=new u(e),this.characters=new g(e),this.genres=new l(e),this.manga=new R(e),this.top=new f(e),this.schedules=new h(e),this.seasons=new d(e)}};var B=(m=>(m.tv="TV",m.movie="Movie",m.ova="Ova",m.special="Special",m.ona="Ona",m.music="Music",m))(B||{}),N=(s=>(s.finished="Finished Airing",s.airing="Currently Airing",s.complete="Complete",s.upcoming="Not yet aired",s))(N||{}),V=(m=>(m.g="g",m.pg="pg",m.pg13="pg13",m.r17="r17",m.r="r",m.rx="rx",m))(V||{}),T=(s=>(s.spring="spring",s.summer="summer",s.fall="fall",s.winter="winter",s))(T||{});var L=(r=>(r.main="Main",r.supporting="Supporting",r))(L||{});var q=(n=>(n.manga="Manga",n.novel="Novel",n.lightnovel="Lightnovel",n.oneshot="Oneshot",n.doujin="Doujin",n.manhwa="Manhwa",n.manhua="Manhua",n))(q||{}),U=(c=>(c.publishing="Publishing",c.complete="Complete",c.hiatus="On Hiatus",c.discontinued="Discontinued",c.upcoming="Upcoming",c))(U||{});var $=(o=>(o.mal_id="mal_id",o.name="name",o.favorites="favorites",o))($||{});var G=(s=>(s.genres="genres",s.explicit_genres="explicit_genres",s.theme="themes",s.demographics="demographics",s))(G||{});var D=(n=>(n.monday="monday",n.tuesday="tuesday",n.wednesday="wednesday",n.thursday="thursday",n.friday="friday",n.unknown="unknown",n.other="other",n))(D||{});var j=(r=>(r.asc="asc",r.desc="desc",r))(j||{}),F=(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))(F||{}),z=(o=>(o.type="type",o.rating="rating",o.episodes="episodes",o))(z||{}),K=(o=>(o.airing="airing",o.complete="complete",o.upcoming="upcoming",o))(K||{}),W=(r=>(r.chapters="chapters",r.volumes="volumes",r))(W||{}),Y=(c=>(c.publishing="publishing",c.complete="complete",c.hiatus="hiatus",c.discontinued="discontinued",c.upcoming="upcoming",c))(Y||{});var H=(s=>(s.airing="airing",s.upcoming="upcoming",s.bypopularity="bypopularity",s.favorite="favorite",s))(H||{}),E=(s=>(s.publishing="publishing",s.upcoming="upcoming",s.bypopularity="bypopularity",s.favorite="favorite",s))(E||{});export{u as AnimeClient,x as AnimeEndpoints,V as AnimeRating,z as AnimeSearchOrder,K as AnimeSearchStatus,T as AnimeSeason,N as AnimeStatus,B as AnimeType,t as BaseClient,k as BaseURL,L as CharacterRole,g as CharactersClient,b as CharactersEndpoints,$ as CharactersSearchOrder,l as GenresClient,J as GenresEndpoints,G as GenresFilter,v as JikanClient,R as MangaClient,A as MangaEndpoints,W as MangaSearchOrder,Y as MangaSearchStatus,U as MangaStatus,q as MangaType,h as SchedulesClient,D as SchedulesFilter,F as SearchOrder,d as SeasonsClient,y as SeasonsEndpoints,j as SortOptions,H as TopAnimeFilter,f as TopClient,P as TopEndpoints,E as TopMangaFilter,C as handleRequest,I as handleRequestError,M as handleResponse,w as handleResponseError};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tutkli/jikan-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
|
+
"prepare": "git config core.hookspath .githooks",
|
|
10
11
|
"prebuild": "rimraf dist",
|
|
11
12
|
"build": "yarn run esbuild && yarn run build-types",
|
|
12
13
|
"esbuild": "node ./esbuild.config.js",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"test:dev": "jest --verbose --colors --expand --maxWorkers=50% --detectOpenHandles --errorOnDeprecated --bail",
|
|
17
18
|
"lint:fix": "npx eslint src/** --fix",
|
|
18
19
|
"prettify": "prettier --write .",
|
|
19
|
-
"version": "auto-changelog -p && git add CHANGELOG.md"
|
|
20
|
+
"version": "auto-changelog -p -l false && git add CHANGELOG.md"
|
|
20
21
|
},
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|