@tutkli/jikan-ts 0.6.61 → 0.6.62
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 +11 -15
- package/dist/index.d.ts +32 -29
- package/dist/index.js +1 -1
- package/package.json +16 -17
package/README.md
CHANGED
|
@@ -35,14 +35,12 @@ Using a specific client, like **AnimeClient**:
|
|
|
35
35
|
```ts
|
|
36
36
|
import { AnimeClient, JikanResponse, Anime } from '@tutkli/jikan-ts';
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.catch((error) => console.error(error));
|
|
45
|
-
})();
|
|
38
|
+
const animeClient = new AnimeClient();
|
|
39
|
+
|
|
40
|
+
animeClient
|
|
41
|
+
.getAnimeById(1)
|
|
42
|
+
.then((jikanResponse: JikanResponse<Anime>) => { /* ... */ })
|
|
43
|
+
.catch((error) => console.error(error));
|
|
46
44
|
```
|
|
47
45
|
|
|
48
46
|
Or, using the **JikanClient**:
|
|
@@ -50,14 +48,12 @@ Or, using the **JikanClient**:
|
|
|
50
48
|
```ts
|
|
51
49
|
import { JikanClient, JikanResponse, Anime } from '@tutkli/jikan-ts';
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
const jikanClient = new JikanClient();
|
|
51
|
+
const jikanClient = new JikanClient();
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})();
|
|
53
|
+
jikanClient.anime
|
|
54
|
+
.getAnimeById(1)
|
|
55
|
+
.then((jikanResponse: JikanResponse<Anime>) => { /* ... */ })
|
|
56
|
+
.catch((error) => console.error(error));
|
|
61
57
|
```
|
|
62
58
|
|
|
63
59
|
## Client configuration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator
|
|
1
|
+
// Generated by dts-bundle-generator v8.0.1
|
|
2
2
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
|
|
@@ -33,6 +33,9 @@ export interface ClientArgs {
|
|
|
33
33
|
export declare abstract class BaseClient {
|
|
34
34
|
api: AxiosCacheInstance;
|
|
35
35
|
protected constructor(clientOptions?: Partial<ClientArgs>);
|
|
36
|
+
protected replacePathParams(path: string, params: {
|
|
37
|
+
[key in string]: unknown;
|
|
38
|
+
}): string;
|
|
36
39
|
private addLoggingInterceptors;
|
|
37
40
|
}
|
|
38
41
|
export interface JikanResource {
|
|
@@ -359,20 +362,20 @@ export declare enum MangaSearchOrder {
|
|
|
359
362
|
volumes = "volumes"
|
|
360
363
|
}
|
|
361
364
|
export interface JikanSearchParams {
|
|
362
|
-
q
|
|
363
|
-
page
|
|
364
|
-
limit
|
|
365
|
-
score
|
|
366
|
-
min_score
|
|
367
|
-
max_score
|
|
368
|
-
sfw
|
|
369
|
-
genres
|
|
370
|
-
genres_exclude
|
|
371
|
-
sort
|
|
372
|
-
letter
|
|
373
|
-
producers
|
|
374
|
-
start_date
|
|
375
|
-
end_date
|
|
365
|
+
q?: string;
|
|
366
|
+
page?: number;
|
|
367
|
+
limit?: number;
|
|
368
|
+
score?: number;
|
|
369
|
+
min_score?: number;
|
|
370
|
+
max_score?: number;
|
|
371
|
+
sfw?: boolean;
|
|
372
|
+
genres?: string;
|
|
373
|
+
genres_exclude?: string;
|
|
374
|
+
sort?: SortOptions | string;
|
|
375
|
+
letter?: string;
|
|
376
|
+
producers?: string;
|
|
377
|
+
start_date?: string;
|
|
378
|
+
end_date?: string;
|
|
376
379
|
}
|
|
377
380
|
/**
|
|
378
381
|
* QueryParams used in **getMangaSearch** call
|
|
@@ -380,10 +383,10 @@ export interface JikanSearchParams {
|
|
|
380
383
|
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/manga/operation/getMangaSearch)
|
|
381
384
|
*/
|
|
382
385
|
export interface MangaSearchParams extends JikanSearchParams {
|
|
383
|
-
type
|
|
384
|
-
status
|
|
385
|
-
order_by
|
|
386
|
-
magazines
|
|
386
|
+
type?: MangaType | string;
|
|
387
|
+
status?: MangaStatus | string;
|
|
388
|
+
order_by?: MangaSearchOrder | SearchOrder | string;
|
|
389
|
+
magazines?: string;
|
|
387
390
|
}
|
|
388
391
|
/**
|
|
389
392
|
* QueryParams used in **getAnimeSearch** call
|
|
@@ -391,10 +394,10 @@ export interface MangaSearchParams extends JikanSearchParams {
|
|
|
391
394
|
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/anime/operation/getAnimeSearch)
|
|
392
395
|
*/
|
|
393
396
|
export interface AnimeSearchParams extends JikanSearchParams {
|
|
394
|
-
type
|
|
395
|
-
status
|
|
396
|
-
rating
|
|
397
|
-
order_by
|
|
397
|
+
type?: AnimeType | string;
|
|
398
|
+
status?: AnimeStatus | string;
|
|
399
|
+
rating?: AnimeRating | string;
|
|
400
|
+
order_by?: AnimeSearchOrder | SearchOrder | string;
|
|
398
401
|
}
|
|
399
402
|
export declare enum TopAnimeFilter {
|
|
400
403
|
airing = "airing",
|
|
@@ -409,8 +412,8 @@ export declare enum TopMangaFilter {
|
|
|
409
412
|
favorite = "favorite"
|
|
410
413
|
}
|
|
411
414
|
export interface JikanTopParams {
|
|
412
|
-
page
|
|
413
|
-
limit
|
|
415
|
+
page?: number;
|
|
416
|
+
limit?: number;
|
|
414
417
|
}
|
|
415
418
|
/**
|
|
416
419
|
* QueryParams used in **getTopAnime** call
|
|
@@ -418,8 +421,8 @@ export interface JikanTopParams {
|
|
|
418
421
|
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/top/operation/getTopAnime)
|
|
419
422
|
*/
|
|
420
423
|
export interface AnimeTopParams extends JikanTopParams {
|
|
421
|
-
type
|
|
422
|
-
filter
|
|
424
|
+
type?: AnimeType;
|
|
425
|
+
filter?: TopAnimeFilter;
|
|
423
426
|
}
|
|
424
427
|
/**
|
|
425
428
|
* QueryParams used in **getTopManga** call
|
|
@@ -427,8 +430,8 @@ export interface AnimeTopParams extends JikanTopParams {
|
|
|
427
430
|
* See also: [Jikan API Documentation](https://docs.api.jikan.moe/#tag/top/operation/getTopManga)
|
|
428
431
|
*/
|
|
429
432
|
export interface MangaTopParams extends JikanTopParams {
|
|
430
|
-
type
|
|
431
|
-
filter
|
|
433
|
+
type?: MangaType;
|
|
434
|
+
filter?: TopMangaFilter;
|
|
432
435
|
}
|
|
433
436
|
export interface JikanSeasonsParams {
|
|
434
437
|
page?: number;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setupCache as y}from"axios-cache-interceptor";import
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tutkli/jikan-ts",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Node.js wrapper for the Jikan API with
|
|
3
|
+
"version": "0.6.62",
|
|
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
|
-
"sideEffects": false,
|
|
10
9
|
"scripts": {
|
|
11
10
|
"prebuild": "rimraf dist",
|
|
12
11
|
"build": "yarn run esbuild && yarn run build-types",
|
|
@@ -44,24 +43,24 @@
|
|
|
44
43
|
"axios-cache-interceptor": "^0.10.7"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@swc/core": "1.3.
|
|
48
|
-
"@swc/jest": "
|
|
49
|
-
"@types/jest": "29.5.
|
|
50
|
-
"@types/node": "
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
52
|
-
"@typescript-eslint/parser": "5.
|
|
53
|
-
"dts-bundle-generator": "
|
|
54
|
-
"esbuild": "0.17.
|
|
55
|
-
"esbuild-node-externals": "
|
|
56
|
-
"eslint": "8.
|
|
57
|
-
"eslint-config-prettier": "8.
|
|
46
|
+
"@swc/core": "1.3.56",
|
|
47
|
+
"@swc/jest": "0.2.26",
|
|
48
|
+
"@types/jest": "29.5.1",
|
|
49
|
+
"@types/node": "20.1.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "5.59.2",
|
|
51
|
+
"@typescript-eslint/parser": "5.59.2",
|
|
52
|
+
"dts-bundle-generator": "8.0.1",
|
|
53
|
+
"esbuild": "0.17.18",
|
|
54
|
+
"esbuild-node-externals": "1.7.0",
|
|
55
|
+
"eslint": "8.40.0",
|
|
56
|
+
"eslint-config-prettier": "8.8.0",
|
|
58
57
|
"eslint-plugin-jest": "27.2.1",
|
|
59
58
|
"eslint-plugin-node": "^11.1.0",
|
|
60
59
|
"eslint-plugin-prettier": "^4.2.1",
|
|
61
60
|
"jest": "^29.3.1",
|
|
62
|
-
"prettier": "2.8.
|
|
63
|
-
"rimraf": "
|
|
64
|
-
"typescript": "5.0.
|
|
61
|
+
"prettier": "2.8.8",
|
|
62
|
+
"rimraf": "5.0.0",
|
|
63
|
+
"typescript": "5.0.4",
|
|
65
64
|
"vitepress": "^1.0.0-alpha.60"
|
|
66
65
|
}
|
|
67
66
|
}
|