@crysoline/lib 0.1.1 → 0.1.2

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.
@@ -21,6 +21,9 @@ export interface HianimeSearchMeta {
21
21
  export interface HianimeEpisodeMeta {
22
22
  title_jp: string | null;
23
23
  }
24
+ export interface HianimeServerMeta {
25
+ data_id: number | null;
26
+ }
24
27
  export interface HianimeInfoMeta {
25
28
  year: number | null;
26
29
  score: number | null;
@@ -4,7 +4,7 @@ import type { NEpisodeMeta, NInfoMeta, NSearchMeta } from './animenexus';
4
4
  import type { OEpisodeMeta, OInfoMeta } from './animeonsen';
5
5
  import type { PaheEpisodeMeta, PaheInfoMeta, PaheSearchMeta } from './animepahe';
6
6
  import type { AZEpisodeMeta, AZInfoMeta, AZSearchMeta } from './anizone';
7
- import type { HianimeEpisodeMeta, HianimeInfoMeta, HianimeSearchMeta } from './hianime';
7
+ import type { HianimeEpisodeMeta, HianimeInfoMeta, HianimeSearchMeta, HianimeServerMeta } from './hianime';
8
8
  import type { KEpisodeMeta, KInfoMeta, KSearchMeta, KSourceMeta } from './kickassanime';
9
9
  import type { LEpisodeMeta, LInfoMeta, LSearchMeta, LSourcesMeta } from './lunar';
10
10
  import type { UniqueEpisodeMeta, UniqueInfoMeta, UniqueSearchMeta } from './uniquestream';
@@ -107,6 +107,10 @@ declare const Anime: {
107
107
  subType?: string;
108
108
  server?: string;
109
109
  }) => Promise<import("../types").Source<unknown>>;
110
+ servers: (params: {
111
+ id: string | number;
112
+ episodeId: string | number;
113
+ }) => Promise<import("../types").Server<HianimeServerMeta>>;
110
114
  };
111
115
  KickAssAnime: (apiKey: string) => {
112
116
  search: (q: string) => Promise<import("../types").Search<KSearchMeta>[]>;
@@ -1,48 +1,230 @@
1
1
  import { AnimeFetch } from '../../helpers/fetch';
2
+ /**
3
+ * Creates a 123Anime API client.
4
+ *
5
+ * @param apiKey - Your API key for authentication
6
+ * @returns API client with methods: search, info, episodes, sources
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const client = OneTwoThreeAnime(process.env.API_KEY);
11
+ * const results = await client.search("naruto");
12
+ * const info = await client.info(results[0].id);
13
+ * ```
14
+ */
2
15
  const OneTwoThreeAnime = (apiKey) => AnimeFetch({
3
16
  provider: 'onetwothreeanime',
4
17
  apiKey,
5
18
  });
19
+ /**
20
+ * Creates an AnimeParadise API client.
21
+ *
22
+ * @param apiKey - Your API key for authentication
23
+ * @returns API client with methods: search, info, episodes, sources
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const client = AnimeParadise(process.env.API_KEY);
28
+ * const results = await client.search("one piece");
29
+ * const episodes = await client.episodes(results[0].id);
30
+ * ```
31
+ */
6
32
  const AnimeParadise = (apiKey) => AnimeFetch({
7
33
  provider: 'animeparadise',
8
34
  apiKey,
9
35
  });
36
+ /**
37
+ * Creates an AnimeHeaven API client.
38
+ *
39
+ * @param apiKey - Your API key for authentication
40
+ * @returns API client with methods: search, info, episodes, sources
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const client = AnimeHeaven(process.env.API_KEY);
45
+ * const results = await client.search("demon slayer");
46
+ * const info = await client.info(results[0].id);
47
+ * ```
48
+ */
10
49
  const AnimeHeaven = (apiKey) => AnimeFetch({
11
50
  provider: 'animeheaven',
12
51
  apiKey,
13
52
  });
53
+ /**
54
+ * Creates an AnimeKai API client.
55
+ *
56
+ * @param apiKey - Your API key for authentication
57
+ * @returns API client with methods: search, info, episodes, sources
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const client = AnimeKai(process.env.API_KEY);
62
+ * const results = await client.search("attack on titan");
63
+ * const episodes = await client.episodes(results[0].id);
64
+ * ```
65
+ */
14
66
  const AnimeKai = (apiKey) => AnimeFetch({
15
67
  provider: 'animekai',
16
68
  apiKey,
17
69
  });
70
+ /**
71
+ * Creates an AnimeNexus API client.
72
+ *
73
+ * @param apiKey - Your API key for authentication
74
+ * @returns API client with methods: search, info, episodes, sources
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const client = AnimeNexus(process.env.API_KEY);
79
+ * const results = await client.search("jujutsu kaisen");
80
+ * const info = await client.info(results[0].id);
81
+ * ```
82
+ */
18
83
  const AnimeNexus = (apiKey) => AnimeFetch({
19
84
  provider: 'animenexus',
20
85
  apiKey,
21
86
  });
87
+ /**
88
+ * Creates an AnimeOnsen API client.
89
+ *
90
+ * @param apiKey - Your API key for authentication
91
+ * @returns API client with methods: search, info, episodes, sources
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const client = AnimeOnsen(process.env.API_KEY);
96
+ * const results = await client.search("my hero academia");
97
+ * const episodes = await client.episodes(results[0].id);
98
+ * ```
99
+ */
22
100
  const AnimeOnsen = (apiKey) => AnimeFetch({
23
101
  provider: 'animeonsen',
24
102
  apiKey,
25
103
  });
104
+ /**
105
+ * Creates an AnimePahe API client.
106
+ *
107
+ * @param apiKey - Your API key for authentication
108
+ * @returns API client with methods: search, info, episodes, sources
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const client = AnimePahe(process.env.API_KEY);
113
+ * const results = await client.search("chainsaw man");
114
+ * const info = await client.info(results[0].id);
115
+ * ```
116
+ */
26
117
  const AnimePahe = (apiKey) => AnimeFetch({
27
118
  provider: 'animepahe',
28
119
  apiKey,
29
120
  });
121
+ /**
122
+ * Creates an AniZone API client.
123
+ *
124
+ * @param apiKey - Your API key for authentication
125
+ * @returns API client with methods: search, info, episodes, sources
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * const client = AniZone(process.env.API_KEY);
130
+ * const results = await client.search("spy x family");
131
+ * const episodes = await client.episodes(results[0].id);
132
+ * ```
133
+ */
30
134
  const AniZone = (apiKey) => AnimeFetch({
31
135
  provider: 'anizone',
32
136
  apiKey,
33
137
  });
138
+ /**
139
+ * Creates a HiAnime API client.
140
+ *
141
+ * **Full-featured provider with server selection support.**
142
+ *
143
+ * @param apiKey - Your API key for authentication
144
+ * @returns API client with methods: search, info, episodes, sources, servers
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const client = HiAnime(process.env.API_KEY);
149
+ *
150
+ * // Search for anime
151
+ * const results = await client.search("alya");
152
+ *
153
+ * // Get anime info
154
+ * const info = await client.info(results[0].id);
155
+ *
156
+ * // Get episodes
157
+ * const episodes = await client.episodes(results[0].id);
158
+ *
159
+ * // Get available servers
160
+ * const servers = await client.servers({
161
+ * id: results[0].id,
162
+ * episodeId: episodes[0].id
163
+ * });
164
+ *
165
+ * // Get streaming sources
166
+ * const sources = await client.sources({
167
+ * id: results[0].id,
168
+ * episodeId: episodes[0].id,
169
+ * subType: "sub"
170
+ * });
171
+ * ```
172
+ */
34
173
  const HiAnime = (apiKey) => AnimeFetch({
35
174
  provider: 'hianime',
36
175
  apiKey,
37
176
  });
177
+ /**
178
+ * Creates a KickAssAnime API client.
179
+ *
180
+ * @param apiKey - Your API key for authentication
181
+ * @returns API client with methods: search, info, episodes, sources
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const client = KickAssAnime(process.env.API_KEY);
186
+ * const results = await client.search("vinland saga");
187
+ * const sources = await client.sources({
188
+ * id: results[0].id,
189
+ * episodeId: "ep-1"
190
+ * });
191
+ * ```
192
+ */
38
193
  const KickAssAnime = (apiKey) => AnimeFetch({
39
194
  provider: 'kickassanime',
40
195
  apiKey,
41
196
  });
197
+ /**
198
+ * Creates a LunarAnime API client.
199
+ *
200
+ * @param apiKey - Your API key for authentication
201
+ * @returns API client with methods: search, info, episodes, sources
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * const client = LunarAnime(process.env.API_KEY);
206
+ * const results = await client.search("bleach");
207
+ * const info = await client.info(results[0].id);
208
+ * const episodes = await client.episodes(results[0].id);
209
+ * ```
210
+ */
42
211
  const LunarAnime = (apiKey) => AnimeFetch({
43
212
  provider: 'lunaranime',
44
213
  apiKey,
45
214
  });
215
+ /**
216
+ * Creates a UniqueStream API client.
217
+ *
218
+ * @param apiKey - Your API key for authentication
219
+ * @returns API client with methods: search, info, episodes, sources
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * const client = UniqueStream(process.env.API_KEY);
224
+ * const results = await client.search("solo leveling");
225
+ * const episodes = await client.episodes(results[0].id);
226
+ * ```
227
+ */
46
228
  const UniqueStream = (apiKey) => AnimeFetch({
47
229
  provider: 'uniquestream',
48
230
  apiKey,
@@ -1,12 +1,55 @@
1
1
  import { HentaiFetch } from '../../helpers/fetch';
2
+ /**
3
+ * Creates an HAnime API client.
4
+ *
5
+ * @param apiKey - Your API key for authentication
6
+ * @returns API client with methods: search, info, episodes, sources
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const client = HAnime(process.env.API_KEY);
11
+ * const results = await client.search("query");
12
+ * const info = await client.info(results[0].id);
13
+ * const episodes = await client.episodes(results[0].id);
14
+ * ```
15
+ */
2
16
  const HAnime = (apiKey) => HentaiFetch({
3
17
  provider: 'hanime',
4
18
  apiKey,
5
19
  });
20
+ /**
21
+ * Creates a HentaiHaven API client.
22
+ *
23
+ * @param apiKey - Your API key for authentication
24
+ * @returns API client with methods: search, info, episodes, sources
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const client = HentaiHaven(process.env.API_KEY);
29
+ * const info = await client.info("content-id");
30
+ * const sources = await client.sources({
31
+ * id: "content-id",
32
+ * episodeId: "ep-1"
33
+ * });
34
+ * ```
35
+ */
6
36
  const HentaiHaven = (apiKey) => HentaiFetch({
7
37
  provider: 'hentaihaven',
8
38
  apiKey,
9
39
  });
40
+ /**
41
+ * Creates an HStream API client.
42
+ *
43
+ * @param apiKey - Your API key for authentication
44
+ * @returns API client with methods: search, info, episodes, sources
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const client = HStream(process.env.API_KEY);
49
+ * const results = await client.search("query");
50
+ * const info = await client.info(results[0].id);
51
+ * ```
52
+ */
10
53
  const HStream = (apiKey) => HentaiFetch({
11
54
  provider: 'hstream',
12
55
  apiKey,
@@ -4,7 +4,7 @@ import type { MFInfoMeta, MFSearchMeta } from './mangafire';
4
4
  declare const Manga: {
5
5
  LunarManga: (apiKey: string) => {
6
6
  search: (q: string) => Promise<import("../types").Search<LMangaSearchMeta>[]>;
7
- info: (id: string | number) => Promise<import("../types").Info<LMangaInfoMeta, unknown>>;
7
+ info: (id: string | number) => Promise<import("../types").Info<LMangaInfoMeta, import("../types").Episode<unknown>>>;
8
8
  chapters: (id: string | number) => Promise<import("../types").Chapter<unknown>[]>;
9
9
  pages: (params: {
10
10
  id: string | number;
@@ -14,7 +14,7 @@ declare const Manga: {
14
14
  };
15
15
  MangaDex: (apiKey: string) => {
16
16
  search: (q: string) => Promise<import("../types").Search<MDXSearchMeta>[]>;
17
- info: (id: string | number) => Promise<import("../types").Info<MDXInfoMeta, unknown>>;
17
+ info: (id: string | number) => Promise<import("../types").Info<MDXInfoMeta, import("../types").Episode<unknown>>>;
18
18
  chapters: (id: string | number) => Promise<import("../types").Chapter<unknown>[]>;
19
19
  pages: (params: {
20
20
  id: string | number;
@@ -24,7 +24,7 @@ declare const Manga: {
24
24
  };
25
25
  MangaFire: (apiKey: string) => {
26
26
  search: (q: string) => Promise<import("../types").Search<MFSearchMeta>[]>;
27
- info: (id: string | number) => Promise<import("../types").Info<MFInfoMeta, unknown>>;
27
+ info: (id: string | number) => Promise<import("../types").Info<MFInfoMeta, import("../types").Episode<unknown>>>;
28
28
  chapters: (id: string | number) => Promise<import("../types").Chapter<unknown>[]>;
29
29
  pages: (params: {
30
30
  id: string | number;
@@ -1,12 +1,64 @@
1
1
  import { MangaFetch } from '../../helpers/fetch';
2
+ /**
3
+ * Creates a LunarManga API client.
4
+ *
5
+ * @param apiKey - Your API key for authentication
6
+ * @returns API client with methods: search, info, chapters, pages
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const client = LunarManga(process.env.API_KEY);
11
+ * const results = await client.search("one piece");
12
+ * const info = await client.info(results[0].id);
13
+ * const chapters = await client.chapters(results[0].id);
14
+ * const pages = await client.pages({
15
+ * id: results[0].id,
16
+ * chapterId: chapters[0].id
17
+ * });
18
+ * ```
19
+ */
2
20
  const LunarManga = (apiKey) => MangaFetch({
3
21
  provider: 'lunarmanga',
4
22
  apiKey,
5
23
  });
24
+ /**
25
+ * Creates a MangaDex API client.
26
+ *
27
+ * **Popular provider with multi-language support.**
28
+ *
29
+ * @param apiKey - Your API key for authentication
30
+ * @returns API client with methods: search, info, chapters, pages
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const client = MangaDex(process.env.API_KEY);
35
+ * const results = await client.search("chainsaw man");
36
+ * const chapters = await client.chapters(results[0].id);
37
+ * const pages = await client.pages({
38
+ * id: results[0].id,
39
+ * chapterId: chapters[0].id,
40
+ * lang: "en"
41
+ * });
42
+ * ```
43
+ */
6
44
  const MangaDex = (apiKey) => MangaFetch({
7
45
  provider: 'mangadex',
8
46
  apiKey,
9
47
  });
48
+ /**
49
+ * Creates a MangaFire API client.
50
+ *
51
+ * @param apiKey - Your API key for authentication
52
+ * @returns API client with methods: search, info, chapters, pages
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const client = MangaFire(process.env.API_KEY);
57
+ * const results = await client.search("berserk");
58
+ * const info = await client.info(results[0].id);
59
+ * const chapters = await client.chapters(results[0].id);
60
+ * ```
61
+ */
10
62
  const MangaFire = (apiKey) => MangaFetch({
11
63
  provider: 'mangafire',
12
64
  apiKey,
@@ -1,7 +1,28 @@
1
+ /**
2
+ * Creates a Mapper API client for converting between provider IDs.
3
+ *
4
+ * **Use this to map AniList IDs to provider-specific IDs.**
5
+ *
6
+ * @param apiKey - Your API key for authentication
7
+ * @returns API client with method: map
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const mapper = Mapper(process.env.API_KEY);
12
+ *
13
+ * // Map AniList ID to provider ID
14
+ * const mapping = await mapper.map({
15
+ * id: 21, // AniList ID for "One Piece"
16
+ * provider: "animepahe"
17
+ * });
18
+ *
19
+ * console.log(mapping.idMap); // Provider-specific ID
20
+ * ```
21
+ */
1
22
  declare const Mapper: (apiKey: string) => {
2
23
  map: (params: {
3
24
  id: number;
4
25
  provider: string;
5
- }) => Promise<unknown>;
26
+ }) => Promise<import("./types").Mapping>;
6
27
  };
7
28
  export { Mapper };
@@ -1,4 +1,25 @@
1
1
  import { MapperFetch } from '../../helpers/fetch';
2
+ /**
3
+ * Creates a Mapper API client for converting between provider IDs.
4
+ *
5
+ * **Use this to map AniList IDs to provider-specific IDs.**
6
+ *
7
+ * @param apiKey - Your API key for authentication
8
+ * @returns API client with method: map
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const mapper = Mapper(process.env.API_KEY);
13
+ *
14
+ * // Map AniList ID to provider ID
15
+ * const mapping = await mapper.map({
16
+ * id: 21, // AniList ID for "One Piece"
17
+ * provider: "animepahe"
18
+ * });
19
+ *
20
+ * console.log(mapping.idMap); // Provider-specific ID
21
+ * ```
22
+ */
2
23
  const Mapper = (apiKey) => MapperFetch({
3
24
  provider: 'mapper',
4
25
  apiKey,
@@ -3,11 +3,11 @@ import type { MMLInfoMeta, MMSearchMeta } from './mymangalist';
3
3
  declare const Meta: {
4
4
  MyAnimeList: (apiKey: string) => {
5
5
  search: (q: string) => Promise<import("../types").Search<MSearchMeta>[]>;
6
- info: (id: string | number) => Promise<import("../types").Info<MInfoMeta, unknown>>;
6
+ info: (id: string | number) => Promise<import("../types").Info<MInfoMeta, import("../types").Episode<unknown>>>;
7
7
  };
8
8
  MyMangaList: (apiKey: string) => {
9
9
  search: (q: string) => Promise<import("../types").Search<MMSearchMeta>[]>;
10
- info: (id: string | number) => Promise<import("../types").Info<MMLInfoMeta, unknown>>;
10
+ info: (id: string | number) => Promise<import("../types").Info<MMLInfoMeta, import("../types").Episode<unknown>>>;
11
11
  };
12
12
  };
13
13
  export { Meta };
@@ -1,8 +1,48 @@
1
1
  import { MetaFetch } from '../../helpers/fetch';
2
+ /**
3
+ * Creates a MyAnimeList API client for anime metadata.
4
+ *
5
+ * **Provides comprehensive anime information and statistics from MyAnimeList.**
6
+ *
7
+ * @param apiKey - Your API key for authentication
8
+ * @returns API client with methods: search, info
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const mal = MyAnimeList(process.env.API_KEY);
13
+ *
14
+ * // Search for anime
15
+ * const results = await mal.search("steins gate");
16
+ *
17
+ * // Get detailed info with MAL ratings, stats, and metadata
18
+ * const info = await mal.info(results[0].id);
19
+ * console.log(info.score, info.rank, info.popularity);
20
+ * ```
21
+ */
2
22
  const MyAnimeList = (apiKey) => MetaFetch({
3
23
  provider: 'myanimelist',
4
24
  apiKey,
5
25
  });
26
+ /**
27
+ * Creates a MyMangaList API client for manga metadata.
28
+ *
29
+ * **Provides comprehensive manga information and statistics from MyAnimeList.**
30
+ *
31
+ * @param apiKey - Your API key for authentication
32
+ * @returns API client with methods: search, info
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const mml = MyMangaList(process.env.API_KEY);
37
+ *
38
+ * // Search for manga
39
+ * const results = await mml.search("berserk");
40
+ *
41
+ * // Get detailed info with MAL ratings, stats, and metadata
42
+ * const info = await mml.info(results[0].id);
43
+ * console.log(info.score, info.rank, info.members);
44
+ * ```
45
+ */
6
46
  const MyMangaList = (apiKey) => MetaFetch({
7
47
  provider: 'mymangalist',
8
48
  apiKey,
@@ -99,3 +99,9 @@ export interface Source<T = unknown> {
99
99
  thumbnails?: string | null;
100
100
  metadata?: T | null;
101
101
  }
102
+ export interface Server<T = unknown> {
103
+ id?: string | number | null;
104
+ name?: string | null;
105
+ type?: string | null;
106
+ metadata?: T | null;
107
+ }
@@ -1,49 +1,76 @@
1
- import type { Chapter, Episode, Info, Page, Search, Source } from '../core/types';
1
+ import type { Mapping } from '../core/mapper/types';
2
+ import type { Chapter, Episode, Info, Page, Search, Server, Source } from '../core/types';
3
+ type SearchRoute<T = unknown> = (q: string) => Promise<Search<T>[]>;
4
+ type InfoRoute<T = unknown, E = unknown> = (id: string | number) => Promise<Info<T, E>>;
5
+ type EpisodesRoute<T = unknown> = (id: string | number) => Promise<Episode<T>[]>;
6
+ type SourcesRoute<T> = (params: {
7
+ id: string | number;
8
+ episodeId: string | number;
9
+ subType?: string;
10
+ server?: string;
11
+ }) => Promise<Source<T>>;
12
+ type ServersRoute<T> = (params: {
13
+ id: string | number;
14
+ episodeId: string | number;
15
+ }) => Promise<Server<T>>;
16
+ type ChaptersRoute<T = unknown> = (id: string | number) => Promise<Chapter<T>[]>;
17
+ type PagesRoute = (params: {
18
+ id: string | number;
19
+ chapterId: string | number;
20
+ lang?: string;
21
+ }) => Promise<Page[]>;
22
+ type MapRoute = (params: {
23
+ id: number;
24
+ provider: string;
25
+ }) => Promise<Mapping>;
26
+ type RouteMap<TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown, TServerMeta = unknown, TChapterMeta = unknown> = {
27
+ search: SearchRoute<TSearchMeta>;
28
+ info: InfoRoute<TInfoMeta, Episode<TEpisodeMeta>>;
29
+ episodes: EpisodesRoute<TEpisodeMeta>;
30
+ sources: SourcesRoute<TSourceMeta>;
31
+ servers: ServersRoute<TServerMeta>;
32
+ chapters: ChaptersRoute<TChapterMeta>;
33
+ pages: PagesRoute;
34
+ map: MapRoute;
35
+ };
36
+ type SelectRoutes = {
37
+ [K in keyof RouteMap]?: boolean;
38
+ };
39
+ type BuildRoutes<T extends SelectRoutes, TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown, TServerMeta = unknown, TChapterMeta = unknown> = {
40
+ [K in keyof T & keyof RouteMap as T[K] extends true ? K : never]: RouteMap<TSearchMeta, TInfoMeta, TEpisodeMeta, TSourceMeta, TServerMeta, TChapterMeta>[K];
41
+ };
42
+ type BuildAnimeRoutes<T extends SelectRoutes, TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown, TServerMeta = unknown> = BuildRoutes<T, TSearchMeta, TInfoMeta, TEpisodeMeta, TSourceMeta, TServerMeta>;
43
+ type BuildMangaRoutes<T extends SelectRoutes, TSearchMeta = unknown, TInfoMeta = unknown, TChapterMeta = unknown> = BuildRoutes<T, TSearchMeta, TInfoMeta, unknown, unknown, unknown, TChapterMeta>;
44
+ type BuildMetaRoutes<T extends SelectRoutes, TSearchMeta = unknown, TInfoMeta = unknown> = BuildRoutes<T, TSearchMeta, TInfoMeta>;
2
45
  interface FetchModuleConfig {
3
46
  baseUrl?: string;
4
47
  provider: string;
5
48
  apiKey: string;
49
+ select?: SelectRoutes;
6
50
  }
7
- export declare const AnimeFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown>(config: FetchModuleConfig) => {
8
- search: (q: string) => Promise<Search<TSearchMeta>[]>;
9
- info: (id: string | number) => Promise<Info<TInfoMeta, Episode<TEpisodeMeta>>>;
10
- episodes: (id: string | number) => Promise<Episode<TEpisodeMeta>[]>;
11
- sources: (params: {
12
- id: string | number;
13
- episodeId: string | number;
14
- subType?: string;
15
- server?: string;
16
- }) => Promise<Source<TSourceMeta>>;
17
- };
18
- export declare const HentaiFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown>(config: FetchModuleConfig) => {
19
- search: (q: string) => Promise<Search<TSearchMeta>[]>;
20
- info: (id: string | number) => Promise<Info<TInfoMeta, Episode<TEpisodeMeta>>>;
21
- episodes: (id: string | number) => Promise<Episode<TEpisodeMeta>[]>;
22
- sources: (params: {
23
- id: string | number;
24
- episodeId: string | number;
25
- subType?: string;
26
- server?: string;
27
- }) => Promise<Source<TSourceMeta>>;
28
- };
29
- export declare const MangaFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TChapterMeta = unknown>(config: FetchModuleConfig) => {
30
- search: (q: string) => Promise<Search<TSearchMeta>[]>;
31
- info: (id: string | number) => Promise<Info<TInfoMeta, unknown>>;
32
- chapters: (id: string | number) => Promise<Chapter<TChapterMeta>[]>;
33
- pages: (params: {
34
- id: string | number;
35
- chapterId: string | number;
36
- lang?: string;
37
- }) => Promise<Page[]>;
38
- };
39
- export declare const MetaFetch: <TSearchMeta = unknown, TInfoMeta = unknown>(config: FetchModuleConfig) => {
40
- search: (q: string) => Promise<Search<TSearchMeta>[]>;
41
- info: (id: string | number) => Promise<Info<TInfoMeta, unknown>>;
42
- };
43
- export declare const MapperFetch: (config: FetchModuleConfig) => {
44
- map: (params: {
45
- id: number;
46
- provider: string;
47
- }) => Promise<unknown>;
48
- };
51
+ export declare const AnimeFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown, TServerMeta = unknown, S extends SelectRoutes = {
52
+ search: true;
53
+ info: true;
54
+ episodes: true;
55
+ sources: true;
56
+ }>(config: FetchModuleConfig) => BuildAnimeRoutes<S, TSearchMeta, TInfoMeta, TEpisodeMeta, TSourceMeta, TServerMeta>;
57
+ export declare const HentaiFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TEpisodeMeta = unknown, TSourceMeta = unknown, TServerMeta = unknown, S extends SelectRoutes = {
58
+ search: true;
59
+ info: true;
60
+ episodes: true;
61
+ sources: true;
62
+ }>(config: FetchModuleConfig) => BuildAnimeRoutes<S, TSearchMeta, TInfoMeta, TEpisodeMeta, TSourceMeta, TServerMeta>;
63
+ export declare const MangaFetch: <TSearchMeta = unknown, TInfoMeta = unknown, TChapterMeta = unknown, S extends SelectRoutes = {
64
+ search: true;
65
+ info: true;
66
+ chapters: true;
67
+ pages: true;
68
+ }>(config: FetchModuleConfig) => BuildMangaRoutes<S, TSearchMeta, TInfoMeta, TChapterMeta>;
69
+ export declare const MetaFetch: <TSearchMeta = unknown, TInfoMeta = unknown, S extends SelectRoutes = {
70
+ search: true;
71
+ info: true;
72
+ }>(config: FetchModuleConfig) => BuildMetaRoutes<S, TSearchMeta, TInfoMeta>;
73
+ export declare const MapperFetch: (config: FetchModuleConfig) => BuildRoutes<{
74
+ map: true;
75
+ }>;
49
76
  export {};
@@ -23,99 +23,43 @@ export const AnimeFetch = (config) => {
23
23
  const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
24
24
  const basePath = `${baseUrl}/api/anime/${provider}/`;
25
25
  const fetcher = fetchFn(basePath, apiKey);
26
- /**
27
- * Search for anime by query string.
28
- *
29
- * @param q - Search query.
30
- */
31
26
  const search = async (q) => fetcher('search', { q });
32
- /**
33
- * Fetch detailed info for a given anime id.
34
- *
35
- * @param id - Anime identifier (string or number)
36
- */
37
27
  const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
38
- /**
39
- * Fetch episodes list for a given anime id.
40
- *
41
- * @param id - Anime identifier (string or number)
42
- */
43
28
  const episodes = async (id) => fetcher(`episodes/${encodeURIComponent(id)}`);
44
- /**
45
- * Fetch sources for a particular episode.
46
- *
47
- * @param params - Object containing `id`, `episodeId` and optional `subType` and `server`
48
- */
49
29
  const sources = (params) => fetcher('sources', params);
30
+ const servers = (params) => fetcher('servers', params);
50
31
  return {
51
32
  search,
52
33
  info,
53
34
  episodes,
54
35
  sources,
36
+ servers,
55
37
  };
56
38
  };
57
39
  export const HentaiFetch = (config) => {
58
40
  const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
59
41
  const basePath = `${baseUrl}/api/hentai/${provider}/`;
60
42
  const fetcher = fetchFn(basePath, apiKey);
61
- /**
62
- * Search for hentai by query string.
63
- *
64
- * @param q - Search query.
65
- */
66
43
  const search = async (q) => fetcher('search', { q });
67
- /**
68
- * Get detailed info for an item by id.
69
- *
70
- * @param id - Item identifier.
71
- */
72
44
  const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
73
- /**
74
- * List episodes for a specific item.
75
- *
76
- * @param id - Item identifier.
77
- */
78
45
  const episodes = async (id) => fetcher(`episodes/${encodeURIComponent(id)}`);
79
- /**
80
- * Get sources for a specific episode.
81
- *
82
- * @param params - Parameters to identify the episode and optional filters.
83
- */
84
46
  const sources = (params) => fetcher('sources', params);
47
+ const servers = (params) => fetcher('servers', params);
85
48
  return {
86
49
  search,
87
50
  info,
88
51
  episodes,
89
52
  sources,
53
+ servers,
90
54
  };
91
55
  };
92
56
  export const MangaFetch = (config) => {
93
57
  const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
94
58
  const basePath = `${baseUrl}/api/manga/${provider}/`;
95
59
  const fetcher = fetchFn(basePath, apiKey);
96
- /**
97
- * Search for manga by query string.
98
- *
99
- * @param q - Search query.
100
- */
101
60
  const search = async (q) => fetcher('search', { q });
102
- /**
103
- * Get detailed info for a manga by id.
104
- *
105
- * @param id - Manga identifier.
106
- */
107
61
  const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
108
- /**
109
- * List chapters for a specific manga.
110
- *
111
- * @param id - Manga identifier.
112
- */
113
62
  const chapters = async (id) => fetcher(`chapters/${encodeURIComponent(id)}`);
114
- /**
115
- * Fetch pages for a specific manga chapter.
116
- *
117
- * @param params - Object containing `id`, `chapterId` and optional `lang`
118
- */
119
63
  const pages = (params) => fetcher('pages', params);
120
64
  return {
121
65
  search,
@@ -128,17 +72,7 @@ export const MetaFetch = (config) => {
128
72
  const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
129
73
  const basePath = `${baseUrl}/api/meta/${provider}/`;
130
74
  const fetcher = fetchFn(basePath, apiKey);
131
- /**
132
- * Search meta provider by query string.
133
- *
134
- * @param q - Search query.
135
- */
136
75
  const search = async (q) => fetcher('search', { q });
137
- /**
138
- * Get info from meta provider by id.
139
- *
140
- * @param id - Resource identifier.
141
- */
142
76
  const info = async (id) => fetcher(`info/${encodeURIComponent(id)}`);
143
77
  return {
144
78
  search,
@@ -149,11 +83,6 @@ export const MapperFetch = (config) => {
149
83
  const { baseUrl = 'https://api.crysoline.moe', provider, apiKey } = config;
150
84
  const basePath = `${baseUrl}/api/mapper/${provider}`;
151
85
  const fetcher = fetchFn(basePath, apiKey);
152
- /**
153
- * Map an id from one provider to another.
154
- *
155
- * @param params - Mapping parameters: `id` to map and `provider` to map to.
156
- */
157
86
  const map = async (params) => fetcher('map', params);
158
87
  return {
159
88
  map,
package/package.json CHANGED
@@ -2,17 +2,27 @@
2
2
  "name": "@crysoline/lib",
3
3
  "description": "The official crysoline library for anime, manga using the Crysoline API",
4
4
  "license": "MIT",
5
- "version": "0.1.1",
5
+ "version": "0.1.2",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
- "files": ["dist"],
9
+ "files": [
10
+ "dist"
11
+ ],
10
12
  "exports": {
11
13
  ".": {
12
14
  "types": "./dist/index.d.ts",
13
15
  "default": "./dist/index.js"
14
16
  }
15
17
  },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/crysoline/crysoline-lib.git"
21
+ },
22
+ "homepage": "https://github.com/crysoline/crysoline-lib",
23
+ "bugs": {
24
+ "url": "https://github.com/crysoline/crysoline-lib/issues"
25
+ },
16
26
  "scripts": {
17
27
  "build": "tsc",
18
28
  "prepublishOnly": "npm run build",