tmdb-kit 1.0.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.
Files changed (45) hide show
  1. package/README.md +455 -196
  2. package/dist/cli.js +3823 -0
  3. package/dist/client.d.cts +71 -0
  4. package/dist/client.d.ts +71 -0
  5. package/dist/errors.d.cts +86 -0
  6. package/dist/errors.d.ts +86 -0
  7. package/dist/helpers/cache.d.cts +28 -0
  8. package/dist/helpers/cache.d.ts +28 -0
  9. package/dist/helpers/pagination.d.cts +35 -0
  10. package/dist/helpers/pagination.d.ts +35 -0
  11. package/dist/helpers/retry.d.cts +47 -0
  12. package/dist/helpers/retry.d.ts +47 -0
  13. package/dist/helpers/timeout.d.cts +20 -0
  14. package/dist/helpers/timeout.d.ts +20 -0
  15. package/dist/http.d.cts +80 -0
  16. package/dist/http.d.ts +80 -0
  17. package/dist/index.cjs +1115 -768
  18. package/dist/index.cjs.map +27 -1
  19. package/dist/index.d.cts +13 -783
  20. package/dist/index.d.ts +13 -783
  21. package/dist/index.js +1074 -744
  22. package/dist/index.js.map +27 -1
  23. package/dist/query.d.cts +91 -0
  24. package/dist/query.d.ts +91 -0
  25. package/dist/resources/configuration.d.cts +17 -0
  26. package/dist/resources/configuration.d.ts +17 -0
  27. package/dist/resources/genres.d.cts +13 -0
  28. package/dist/resources/genres.d.ts +13 -0
  29. package/dist/resources/images.d.cts +17 -0
  30. package/dist/resources/images.d.ts +17 -0
  31. package/dist/resources/movies.d.cts +21 -0
  32. package/dist/resources/movies.d.ts +21 -0
  33. package/dist/resources/people.d.cts +14 -0
  34. package/dist/resources/people.d.ts +14 -0
  35. package/dist/resources/search.d.cts +15 -0
  36. package/dist/resources/search.d.ts +15 -0
  37. package/dist/resources/trending.d.cts +23 -0
  38. package/dist/resources/trending.d.ts +23 -0
  39. package/dist/resources/tv.d.cts +30 -0
  40. package/dist/resources/tv.d.ts +30 -0
  41. package/dist/search-guards.d.cts +32 -0
  42. package/dist/search-guards.d.ts +32 -0
  43. package/dist/types.d.cts +550 -0
  44. package/dist/types.d.ts +550 -0
  45. package/package.json +26 -19
package/dist/index.d.ts CHANGED
@@ -1,783 +1,13 @@
1
- //#region src/types.d.ts
2
- /** Primitive JSON values returned by TMDB. */
3
- type JsonPrimitive = string | number | boolean | null;
4
- /** JSON object/array tree returned by TMDB for fields this SDK does not model yet. */
5
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
6
- interface JsonObject {
7
- [key: string]: JsonValue | undefined;
8
- }
9
- /** Escape hatch for append_to_response payloads and future TMDB fields. */
10
- type TMDBObject = Record<string, unknown>;
11
- /** Date string in TMDB format (typically `YYYY-MM-DD`). */
12
- type TMDBDateString = string;
13
- /** ISO 639-1 language code (e.g. `"en"`, `"zh"`). */
14
- type LanguageCode = string;
15
- /** ISO 3166-1 country/region code (e.g. `"US"`, `"CN"`). */
16
- type RegionCode = string;
17
- /** Supported media types for multi-search results. */
18
- type MediaType = 'movie' | 'tv' | 'person';
19
- /** Time window for trending endpoints: `"day"` or `"week"`. */
20
- type TrendingTimeWindow = 'day' | 'week';
21
- interface PagedResponse<T> {
22
- page: number;
23
- results: T[];
24
- total_pages: number;
25
- total_results: number;
26
- }
27
- interface Genre {
28
- id: number;
29
- name: string;
30
- }
31
- interface ProductionCompany {
32
- id: number;
33
- logo_path: string | null;
34
- name: string;
35
- origin_country: string;
36
- }
37
- interface ProductionCountry {
38
- iso_3166_1: string;
39
- name: string;
40
- }
41
- interface SpokenLanguage {
42
- english_name: string;
43
- iso_639_1: string;
44
- name: string;
45
- }
46
- interface CollectionSummary {
47
- id: number;
48
- name: string;
49
- poster_path: string | null;
50
- backdrop_path: string | null;
51
- }
52
- interface MovieSummary {
53
- adult: boolean;
54
- backdrop_path: string | null;
55
- genre_ids: number[];
56
- id: number;
57
- original_language: string;
58
- original_title: string;
59
- overview: string;
60
- popularity: number;
61
- poster_path: string | null;
62
- release_date: TMDBDateString;
63
- title: string;
64
- video: boolean;
65
- vote_average: number;
66
- vote_count: number;
67
- }
68
- interface MovieDetails extends Omit<MovieSummary, 'genre_ids'> {
69
- belongs_to_collection: CollectionSummary | null;
70
- budget: number;
71
- genres: Genre[];
72
- homepage: string | null;
73
- imdb_id: string | null;
74
- production_companies: ProductionCompany[];
75
- production_countries: ProductionCountry[];
76
- revenue: number;
77
- runtime: number | null;
78
- spoken_languages: SpokenLanguage[];
79
- status: string;
80
- tagline: string | null;
81
- }
82
- interface TVSummary {
83
- adult?: boolean;
84
- backdrop_path: string | null;
85
- first_air_date: TMDBDateString;
86
- genre_ids: number[];
87
- id: number;
88
- name: string;
89
- origin_country: string[];
90
- original_language: string;
91
- original_name: string;
92
- overview: string;
93
- popularity: number;
94
- poster_path: string | null;
95
- vote_average: number;
96
- vote_count: number;
97
- }
98
- interface CreatedBy {
99
- id: number;
100
- credit_id: string;
101
- name: string;
102
- gender: number;
103
- profile_path: string | null;
104
- }
105
- interface Network {
106
- id: number;
107
- logo_path: string | null;
108
- name: string;
109
- origin_country: string;
110
- }
111
- interface SeasonSummary {
112
- air_date: TMDBDateString | null;
113
- episode_count: number;
114
- id: number;
115
- name: string;
116
- overview: string;
117
- poster_path: string | null;
118
- season_number: number;
119
- vote_average: number;
120
- }
121
- interface EpisodeGuestStar {
122
- adult: boolean;
123
- character: string;
124
- credit_id: string;
125
- gender: number | null;
126
- id: number;
127
- known_for_department: string;
128
- name: string;
129
- order: number;
130
- original_name: string;
131
- popularity: number;
132
- profile_path: string | null;
133
- }
134
- interface EpisodeSummary {
135
- air_date: TMDBDateString | null;
136
- crew: CreditCrewMember[];
137
- episode_number: number;
138
- episode_type: string;
139
- guest_stars: EpisodeGuestStar[];
140
- id: number;
141
- name: string;
142
- overview: string;
143
- production_code: string | null;
144
- runtime: number | null;
145
- season_number: number;
146
- show_id: number;
147
- still_path: string | null;
148
- vote_average: number;
149
- vote_count: number;
150
- }
151
- interface TVSeasonDetails {
152
- _id: string;
153
- air_date: TMDBDateString | null;
154
- episodes: EpisodeSummary[];
155
- id: number;
156
- name: string;
157
- overview: string;
158
- poster_path: string | null;
159
- season_number: number;
160
- vote_average: number;
161
- }
162
- type TVSeasonAppendToResponse = 'account_states' | 'aggregate_credits' | 'credits' | 'external_ids' | 'images' | 'translations' | 'videos' | (string & {});
163
- interface TVSeasonDetailsOptions extends LanguageOptions {
164
- appendToResponse?: TVSeasonAppendToResponse | readonly TVSeasonAppendToResponse[];
165
- }
166
- interface TVDetails extends Omit<TVSummary, 'genre_ids'> {
167
- created_by: CreatedBy[];
168
- episode_run_time: number[];
169
- genres: Genre[];
170
- homepage: string | null;
171
- in_production: boolean;
172
- languages: string[];
173
- last_air_date: TMDBDateString | null;
174
- networks: Network[];
175
- number_of_episodes: number;
176
- number_of_seasons: number;
177
- production_companies: ProductionCompany[];
178
- production_countries: ProductionCountry[];
179
- seasons: SeasonSummary[];
180
- spoken_languages: SpokenLanguage[];
181
- status: string;
182
- tagline: string | null;
183
- type: string;
184
- }
185
- interface PersonKnownForMovie extends MovieSummary {
186
- media_type: 'movie';
187
- }
188
- interface PersonKnownForTV extends TVSummary {
189
- media_type: 'tv';
190
- }
191
- type PersonKnownFor = PersonKnownForMovie | PersonKnownForTV;
192
- interface PersonSummary {
193
- adult: boolean;
194
- gender: number;
195
- id: number;
196
- known_for: PersonKnownFor[];
197
- known_for_department: string;
198
- name: string;
199
- original_name?: string;
200
- popularity: number;
201
- profile_path: string | null;
202
- }
203
- interface PersonDetails extends Omit<PersonSummary, 'known_for'> {
204
- also_known_as: string[];
205
- biography: string;
206
- birthday: TMDBDateString | null;
207
- deathday: TMDBDateString | null;
208
- homepage: string | null;
209
- imdb_id: string | null;
210
- place_of_birth: string | null;
211
- }
212
- interface MovieSearchResult extends MovieSummary {
213
- media_type?: 'movie';
214
- }
215
- interface TVSearchResult extends TVSummary {
216
- media_type?: 'tv';
217
- }
218
- interface PersonSearchResult extends PersonSummary {
219
- media_type?: 'person';
220
- }
221
- type SearchMultiResult = (MovieSummary & {
222
- media_type: 'movie';
223
- }) | (TVSummary & {
224
- media_type: 'tv';
225
- }) | (PersonSummary & {
226
- media_type: 'person';
227
- });
228
- /** A single multi-search result narrowed to a specific media type. */
229
- type MovieMultiResult = MovieSummary & {
230
- media_type: 'movie';
231
- };
232
- type TVMultiResult = TVSummary & {
233
- media_type: 'tv';
234
- };
235
- type PersonMultiResult = PersonSummary & {
236
- media_type: 'person';
237
- };
238
- type TrendingResult = SearchMultiResult;
239
- interface CreditCastMember {
240
- adult?: boolean;
241
- cast_id?: number;
242
- character: string;
243
- credit_id: string;
244
- gender: number | null;
245
- id: number;
246
- known_for_department: string;
247
- name: string;
248
- order: number;
249
- original_name: string;
250
- popularity: number;
251
- profile_path: string | null;
252
- }
253
- interface CreditCrewMember {
254
- adult?: boolean;
255
- credit_id: string;
256
- department: string;
257
- gender: number | null;
258
- id: number;
259
- job: string;
260
- known_for_department: string;
261
- name: string;
262
- original_name: string;
263
- popularity: number;
264
- profile_path: string | null;
265
- }
266
- interface CreditsResponse {
267
- id: number;
268
- cast: CreditCastMember[];
269
- crew: CreditCrewMember[];
270
- }
271
- interface Video {
272
- id: string;
273
- iso_3166_1: string;
274
- iso_639_1: string;
275
- key: string;
276
- name: string;
277
- official: boolean;
278
- published_at: string;
279
- site: string;
280
- size: number;
281
- type: string;
282
- }
283
- interface VideosResponse {
284
- id: number;
285
- results: Video[];
286
- }
287
- interface ImageItem {
288
- aspect_ratio: number;
289
- height: number;
290
- iso_639_1: string | null;
291
- file_path: string;
292
- vote_average: number;
293
- vote_count: number;
294
- width: number;
295
- }
296
- interface ImagesResponse {
297
- id: number;
298
- backdrops: ImageItem[];
299
- logos?: ImageItem[];
300
- posters: ImageItem[];
301
- }
302
- interface ConfigurationImages {
303
- base_url: string;
304
- secure_base_url: string;
305
- backdrop_sizes: string[];
306
- logo_sizes: string[];
307
- poster_sizes: string[];
308
- profile_sizes: string[];
309
- still_sizes: string[];
310
- }
311
- interface Configuration {
312
- images: ConfigurationImages;
313
- change_keys: string[];
314
- }
315
- interface Country {
316
- iso_3166_1: string;
317
- english_name: string;
318
- native_name: string;
319
- }
320
- interface Language {
321
- iso_639_1: string;
322
- english_name: string;
323
- name: string;
324
- }
325
- interface Timezone {
326
- iso_3166_1: string;
327
- zones: string[];
328
- }
329
- interface JobDepartment {
330
- department: string;
331
- jobs: string[];
332
- }
333
- interface GenresResponse {
334
- genres: Genre[];
335
- }
336
- type BackdropSize = 'w300' | 'w780' | 'w1280' | 'original' | (string & {});
337
- type LogoSize = 'w45' | 'w92' | 'w154' | 'w185' | 'w300' | 'w500' | 'original' | (string & {});
338
- type PosterSize = 'w92' | 'w154' | 'w185' | 'w342' | 'w500' | 'w780' | 'original' | (string & {});
339
- type ProfileSize = 'w45' | 'w185' | 'h632' | 'original' | (string & {});
340
- type StillSize = 'w92' | 'w185' | 'w300' | 'original' | (string & {});
341
- type ImageSize = BackdropSize | LogoSize | PosterSize | ProfileSize | StillSize;
342
- /**
343
- * Public set of image sizes TMDB currently documents. The SDK does not
344
- * pin to a static copy of the TMDB docs — TMDB has added new sizes in
345
- * the past (e.g. `h632` for profile) without notice — but exposing the
346
- * canonical list lets callers:
347
- *
348
- * - iterate over the set to build a size picker
349
- * - validate user-supplied sizes with `isKnownBackdropSize(...)` etc.
350
- * - type a variable as a "known" size without giving up the
351
- * `(string & {})` escape hatch for forward-compatibility
352
- *
353
- * If TMDB publishes a new size, the SDK will still accept it at runtime
354
- * (every helper is `(string & {})` permissive), but you will need to
355
- * add the literal to these constants to get autocomplete on it.
356
- */
357
- declare const KNOWN_BACKDROP_SIZES: readonly ['w300', 'w780', 'w1280', 'original'];
358
- declare const KNOWN_LOGO_SIZES: readonly ['w45', 'w92', 'w154', 'w185', 'w300', 'w500', 'original'];
359
- declare const KNOWN_POSTER_SIZES: readonly ['w92', 'w154', 'w185', 'w342', 'w500', 'w780', 'original'];
360
- declare const KNOWN_PROFILE_SIZES: readonly ['w45', 'w185', 'h632', 'original'];
361
- declare const KNOWN_STILL_SIZES: readonly ['w92', 'w185', 'w300', 'original'];
362
- type KnownBackdropSize = (typeof KNOWN_BACKDROP_SIZES)[number];
363
- type KnownLogoSize = (typeof KNOWN_LOGO_SIZES)[number];
364
- type KnownPosterSize = (typeof KNOWN_POSTER_SIZES)[number];
365
- type KnownProfileSize = (typeof KNOWN_PROFILE_SIZES)[number];
366
- type KnownStillSize = (typeof KNOWN_STILL_SIZES)[number];
367
- type KnownImageSize = KnownBackdropSize | KnownLogoSize | KnownPosterSize | KnownProfileSize | KnownStillSize;
368
- /** Union of every documented image size. */
369
- declare const KNOWN_IMAGE_SIZES: readonly KnownImageSize[];
370
- declare function isKnownBackdropSize(value: string): value is KnownBackdropSize;
371
- declare function isKnownLogoSize(value: string): value is KnownLogoSize;
372
- declare function isKnownPosterSize(value: string): value is KnownPosterSize;
373
- declare function isKnownProfileSize(value: string): value is KnownProfileSize;
374
- declare function isKnownStillSize(value: string): value is KnownStillSize;
375
- /** True if `value` is in any documented size set. */
376
- declare function isKnownImageSize(value: string): value is KnownImageSize;
377
- type MovieAppendToResponse = 'account_states' | 'alternative_titles' | 'changes' | 'credits' | 'external_ids' | 'images' | 'keywords' | 'lists' | 'recommendations' | 'release_dates' | 'reviews' | 'similar' | 'translations' | 'videos' | 'watch/providers' | (string & {});
378
- type TVAppendToResponse = 'account_states' | 'aggregate_credits' | 'alternative_titles' | 'changes' | 'content_ratings' | 'credits' | 'episode_groups' | 'external_ids' | 'images' | 'keywords' | 'recommendations' | 'reviews' | 'screened_theatrically' | 'similar' | 'translations' | 'videos' | 'watch/providers' | (string & {});
379
- interface ListOptions {
380
- language?: LanguageCode;
381
- page?: number;
382
- region?: RegionCode;
383
- }
384
- interface LanguageOptions {
385
- language?: LanguageCode;
386
- }
387
- interface MovieDetailsOptions extends LanguageOptions {
388
- appendToResponse?: MovieAppendToResponse | readonly MovieAppendToResponse[];
389
- }
390
- interface TVDetailsOptions extends LanguageOptions {
391
- appendToResponse?: TVAppendToResponse | readonly TVAppendToResponse[];
392
- }
393
- interface MovieSearchOptions extends ListOptions {
394
- includeAdult?: boolean;
395
- primaryReleaseYear?: string | number;
396
- year?: string | number;
397
- }
398
- interface TVSearchOptions extends Omit<ListOptions, 'region'> {
399
- firstAirDateYear?: string | number;
400
- includeAdult?: boolean;
401
- year?: string | number;
402
- }
403
- interface MultiSearchOptions extends Omit<ListOptions, 'region'> {
404
- includeAdult?: boolean;
405
- /**
406
- * Media types to exclude from a `search.multi()` response. Filtering is
407
- * performed client-side because the TMDB multi-search endpoint does not
408
- * support a server-side media_type filter.
409
- */
410
- exclude?: ReadonlyArray<MediaType>;
411
- }
412
- interface ImageQueryOptions extends LanguageOptions {
413
- includeImageLanguage?: string | readonly string[];
414
- }
415
- //#endregion
416
- //#region src/query.d.ts
417
- /** Primitives allowed as query parameter values. */
418
- type QueryPrimitive = string | number | boolean;
419
- /** A single query parameter value: primitive, array, or nullish. */
420
- type QueryValue = QueryPrimitive | readonly QueryPrimitive[] | null | undefined;
421
- /** Key-value map of query parameters for API requests. */
422
- type QueryParams = Record<string, QueryValue>;
423
- /** Default query parameters inherited from the client configuration. */
424
- interface QueryDefaults {
425
- language?: LanguageCode;
426
- region?: RegionCode;
427
- }
428
- interface BuildImageUrlOptions {
429
- baseUrl?: string;
430
- /**
431
- * Transform the resolved TMDB image URL before returning it. Use this to
432
- * route requests through a CDN, image proxy, or to add signatures.
433
- */
434
- transform?: (url: string) => string;
435
- }
436
- /**
437
- * Build a full TMDB image URL from the path returned by API payloads.
438
- * Returns null for nullish image paths so UI code can branch naturally.
439
- */
440
- declare function buildImageUrl(path: string | null | undefined, size?: ImageSize, options?: BuildImageUrlOptions): string | null;
441
- //#endregion
442
- //#region src/resources/images.d.ts
443
- /** Function that transforms a TMDB image URL (e.g. for CDN proxying). */
444
- type ImageUrlTransform = (url: string) => string;
445
- /**
446
- * Helper for constructing TMDB image URLs from API path values.
447
- *
448
- * Obtained via `client.images`. Supports optional URL transforms for
449
- * routing image requests through a CDN or proxy.
450
- */
451
- declare class ImagesHelper {
452
- #private;
453
- constructor(transport: TMDBTransport, transform?: ImageUrlTransform);
454
- url(path: string | null | undefined, size?: ImageSize, options?: {
455
- transform?: ImageUrlTransform;
456
- }): string | null;
457
- }
458
- //#endregion
459
- //#region src/http.d.ts
460
- /**
461
- * A minimal fetch-like function signature. Any runtime's native `fetch`
462
- * or a test double conforming to this shape can be used.
463
- */
464
- type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
465
- interface TMDBAccessTokenAuth {
466
- /** TMDB API Read Access Token. Sent as an Authorization Bearer header. */
467
- accessToken: string;
468
- apiKey?: never;
469
- }
470
- interface TMDBApiKeyAuth {
471
- /** Legacy v3 API key. Sent as api_key query parameter. */
472
- apiKey: string;
473
- accessToken?: never;
474
- }
475
- type TMDBAuth = TMDBAccessTokenAuth | TMDBApiKeyAuth;
476
- /** Internal defaults resolved during client construction. */
477
- interface TMDBClientDefaults extends QueryDefaults {
478
- imageBaseUrl: string;
479
- }
480
- interface TMDBImagesOptions {
481
- /**
482
- * Default transform applied to every URL produced by the ImagesHelper.
483
- * Use this to route TMDB image requests through a CDN, image proxy, or
484
- * to add signed query parameters. Individual calls can still override it
485
- * via ImagesHelper.url(path, size, { transform }).
486
- */
487
- transform?: ImageUrlTransform;
488
- }
489
- type TMDBClientOptions = TMDBAuth & {
490
- /** Defaults to https://api.themoviedb.org/3. Useful for tests or proxies. */baseUrl?: string; /** Inject a fetch implementation for tests, custom runtimes, or instrumentation. */
491
- fetch?: FetchLike; /** Default language for endpoints that accept a language query parameter. */
492
- defaultLanguage?: LanguageCode; /** Default region for movie list/search endpoints that accept a region query parameter. */
493
- defaultRegion?: RegionCode; /** Custom image host. Defaults to https://image.tmdb.org/t/p. */
494
- imageBaseUrl?: string; /** Image-helper configuration: host overrides and URL transforms. */
495
- images?: TMDBImagesOptions; /** Additional headers merged into every request before authentication is applied. */
496
- headers?: HeadersInit;
497
- };
498
- /** Per-request overrides applied when making a single API call. */
499
- interface TMDBRequestOptions {
500
- headers?: HeadersInit;
501
- query?: QueryParams;
502
- signal?: AbortSignal;
503
- }
504
- /**
505
- * Transport abstraction for making HTTP requests to the TMDB API.
506
- *
507
- * The built-in {@link TMDBHttpClient} implements this interface. You can
508
- * provide a custom implementation via {@link TMDBFactoryOptions.transport}
509
- * for testing, caching, or instrumentation.
510
- */
511
- interface TMDBTransport {
512
- readonly defaults: TMDBClientDefaults;
513
- get<T>(path: string, options?: TMDBRequestOptions): Promise<T>;
514
- }
515
- //#endregion
516
- //#region src/resources/configuration.d.ts
517
- /**
518
- * Access TMDB configuration data (image sizes, countries, languages, etc.).
519
- *
520
- * Obtained via `client.configuration`.
521
- */
522
- declare class ConfigurationResource {
523
- #private;
524
- constructor(transport: TMDBTransport);
525
- details(): Promise<Configuration>;
526
- countries(): Promise<Country[]>;
527
- jobs(): Promise<JobDepartment[]>;
528
- languages(): Promise<Language[]>;
529
- primaryTranslations(): Promise<string[]>;
530
- timezones(): Promise<Timezone[]>;
531
- }
532
- //#endregion
533
- //#region src/resources/genres.d.ts
534
- /**
535
- * Access TMDB genre lists for movies and TV shows.
536
- *
537
- * Obtained via `client.genres`.
538
- */
539
- declare class GenresResource {
540
- #private;
541
- constructor(transport: TMDBTransport);
542
- movies(options?: LanguageOptions): Promise<GenresResponse>;
543
- tv(options?: LanguageOptions): Promise<GenresResponse>;
544
- }
545
- //#endregion
546
- //#region src/resources/movies.d.ts
547
- /**
548
- * Access TMDB movie endpoints (popular, top-rated, details, credits, etc.).
549
- *
550
- * Obtained via `client.movies`.
551
- */
552
- declare class MoviesResource {
553
- #private;
554
- constructor(transport: TMDBTransport);
555
- popular(options?: ListOptions): Promise<PagedResponse<MovieSummary>>;
556
- topRated(options?: ListOptions): Promise<PagedResponse<MovieSummary>>;
557
- nowPlaying(options?: ListOptions): Promise<PagedResponse<MovieSummary>>;
558
- upcoming(options?: ListOptions): Promise<PagedResponse<MovieSummary>>;
559
- details<TAppend extends TMDBObject = TMDBObject>(movieId: number, options?: MovieDetailsOptions): Promise<MovieDetails & TAppend>;
560
- credits(movieId: number, options?: Pick<ListOptions, 'language'>): Promise<CreditsResponse>;
561
- images(movieId: number, options?: ImageQueryOptions): Promise<ImagesResponse>;
562
- recommendations(movieId: number, options?: ListOptions): Promise<PagedResponse<MovieSummary>>;
563
- similar(movieId: number, options?: ListOptions): Promise<PagedResponse<MovieSummary>>;
564
- videos(movieId: number, options?: Pick<ListOptions, 'language'>): Promise<VideosResponse>;
565
- }
566
- //#endregion
567
- //#region src/resources/people.d.ts
568
- /**
569
- * Access TMDB person (actor, director, etc.) endpoints.
570
- *
571
- * Obtained via `client.people`.
572
- */
573
- declare class PeopleResource {
574
- #private;
575
- constructor(transport: TMDBTransport);
576
- popular(options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<PersonSummary>>;
577
- details(personId: number, options?: LanguageOptions): Promise<PersonDetails>;
578
- }
579
- //#endregion
580
- //#region src/resources/search.d.ts
581
- /**
582
- * Search TMDB for movies, TV shows, people, or all media types.
583
- *
584
- * Obtained via `client.search`.
585
- */
586
- declare class SearchResource {
587
- #private;
588
- constructor(transport: TMDBTransport);
589
- movies(query: string, options?: MovieSearchOptions): Promise<PagedResponse<MovieSearchResult>>;
590
- tv(query: string, options?: TVSearchOptions): Promise<PagedResponse<TVSearchResult>>;
591
- people(query: string, options?: MultiSearchOptions): Promise<PagedResponse<PersonSearchResult>>;
592
- multi(query: string, options?: MultiSearchOptions): Promise<PagedResponse<SearchMultiResult>>;
593
- }
594
- //#endregion
595
- //#region src/resources/trending.d.ts
596
- /**
597
- * Access TMDB trending content (movies, TV, people) for day/week windows.
598
- *
599
- * Obtained via `client.trending`.
600
- */
601
- declare class TrendingResource {
602
- #private;
603
- constructor(transport: TMDBTransport);
604
- all(timeWindow?: TrendingTimeWindow, options?: LanguageOptions): Promise<PagedResponse<TrendingResult>>;
605
- movies(timeWindow?: TrendingTimeWindow, options?: LanguageOptions): Promise<PagedResponse<MovieSummary & {
606
- media_type?: 'movie';
607
- }>>;
608
- tv(timeWindow?: TrendingTimeWindow, options?: LanguageOptions): Promise<PagedResponse<TVSummary & {
609
- media_type?: 'tv';
610
- }>>;
611
- people(timeWindow?: TrendingTimeWindow, options?: LanguageOptions): Promise<PagedResponse<PersonSummary & {
612
- media_type?: 'person';
613
- }>>;
614
- }
615
- //#endregion
616
- //#region src/resources/tv.d.ts
617
- /**
618
- * Access TMDB TV show endpoints (popular, top-rated, details, seasons, etc.).
619
- *
620
- * Obtained via `client.tv`.
621
- */
622
- declare class TVResource {
623
- #private;
624
- constructor(transport: TMDBTransport);
625
- popular(options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
626
- topRated(options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
627
- airingToday(options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
628
- onTheAir(options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
629
- details<TAppend extends TMDBObject = TMDBObject>(seriesId: number, options?: TVDetailsOptions): Promise<TVDetails & TAppend>;
630
- credits(seriesId: number, options?: LanguageOptions): Promise<CreditsResponse>;
631
- images(seriesId: number, options?: ImageQueryOptions): Promise<ImagesResponse>;
632
- recommendations(seriesId: number, options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
633
- similar(seriesId: number, options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
634
- videos(seriesId: number, options?: LanguageOptions): Promise<VideosResponse>;
635
- seasonDetails<TAppend extends TMDBObject = TMDBObject>(seriesId: number, seasonNumber: number, options?: TVSeasonDetailsOptions): Promise<TVSeasonDetails & TAppend>;
636
- }
637
- //#endregion
638
- //#region src/client.d.ts
639
- /**
640
- * Options accepted by {@link createTMDB} and the {@link TMDBClient} constructor.
641
- *
642
- * Extends {@link TMDBClientOptions} with an optional {@link TMDBTransport} so
643
- * callers can plug in a custom transport (typically for tests, caching, or
644
- * instrumentation) without having to mock `fetch` or the factory itself.
645
- */
646
- type TMDBFactoryOptions = TMDBClientOptions & {
647
- transport?: TMDBTransport;
648
- };
649
- /**
650
- * Main SDK entry point.
651
- *
652
- * Resource properties are intentionally small and explicit. The SDK focuses on
653
- * common TMDB workflows first, while request<T>() keeps uncommon endpoints easy
654
- * to call without waiting for a generated surface area.
655
- */
656
- declare class TMDBClient {
657
- #private;
658
- readonly configuration: ConfigurationResource;
659
- readonly genres: GenresResource;
660
- readonly images: ImagesHelper;
661
- readonly movies: MoviesResource;
662
- readonly people: PeopleResource;
663
- readonly search: SearchResource;
664
- readonly trending: TrendingResource;
665
- readonly tv: TVResource;
666
- constructor(options: TMDBFactoryOptions);
667
- /**
668
- * Make a raw GET request to any TMDB endpoint.
669
- *
670
- * This is an escape hatch for endpoints not covered by the typed resource
671
- * helpers. The `path` should be relative to the API base URL (e.g.
672
- * `/movie/{id}/credits`). Response is parsed as JSON and cast to `T`.
673
- *
674
- * @param path - API path relative to the base URL (e.g. `/movie/123`)
675
- * @param options - Optional request-level overrides (headers, query, signal)
676
- * @returns Parsed JSON response typed as `T`
677
- */
678
- request<T>(path: string, options?: TMDBRequestOptions): Promise<T>;
679
- }
680
- /**
681
- * Create a new {@link TMDBClient} instance.
682
- *
683
- * @example
684
- * ```ts
685
- * const tmdb = createTMDB({ accessToken: 'YOUR_TOKEN' })
686
- * const { results } = await tmdb.search.movies('Inception')
687
- * ```
688
- *
689
- * @param options - Authentication and configuration options
690
- * @returns A configured TMDBClient ready to make API calls
691
- */
692
- declare function createTMDB(options: TMDBFactoryOptions): TMDBClient;
693
- //#endregion
694
- //#region src/errors.d.ts
695
- /** Options for constructing a {@link TMDBResponseError} or its subclasses. */
696
- interface TMDBResponseErrorOptions {
697
- body: JsonValue | undefined;
698
- headers: Headers;
699
- status: number;
700
- statusText: string;
701
- url: string;
702
- }
703
- /** Base class for all SDK-originated errors. */
704
- declare class TMDBError extends Error {
705
- constructor(message: string, options?: ErrorOptions);
706
- }
707
- /** Thrown before a request is sent or when fetch itself rejects. */
708
- declare class TMDBRequestError extends TMDBError {
709
- constructor(message: string, options?: ErrorOptions);
710
- }
711
- /** Thrown when TMDB returns a non-2xx response. */
712
- declare class TMDBResponseError extends TMDBError {
713
- readonly body: JsonValue | undefined;
714
- readonly headers: Headers;
715
- readonly requestId: string | null;
716
- readonly status: number;
717
- readonly statusCode: number | undefined;
718
- readonly statusMessage: string | undefined;
719
- readonly statusText: string;
720
- readonly url: string;
721
- constructor(message: string, options: TMDBResponseErrorOptions);
722
- /** True when TMDB has asked the caller to back off (HTTP 429). */
723
- get isRateLimit(): boolean;
724
- /** True when the resource was not found (HTTP 404). */
725
- get isNotFound(): boolean;
726
- /** True when the request was rejected as unauthenticated (HTTP 401). */
727
- get isUnauthorized(): boolean;
728
- /** True when the request was rejected as forbidden (HTTP 403). */
729
- get isForbidden(): boolean;
730
- /** True when the upstream returned a 5xx server error. */
731
- get isServerError(): boolean;
732
- }
733
- interface TMDBRateLimitErrorOptions extends TMDBResponseErrorOptions {
734
- /** Seconds to wait before retrying. Parsed from the `Retry-After` header. */
735
- retryAfter: number;
736
- }
737
- /**
738
- * Thrown when TMDB returns HTTP 429.
739
- *
740
- * The SDK does NOT retry automatically — that decision is left to the
741
- * caller, since retry policies vary widely. Inspect `retryAfter` to
742
- * implement your own backoff.
743
- */
744
- declare class TMDBRateLimitError extends TMDBResponseError {
745
- readonly retryAfter: number;
746
- constructor(message: string, options: TMDBRateLimitErrorOptions);
747
- }
748
- //#endregion
749
- //#region src/search-guards.d.ts
750
- /**
751
- * Type guard that narrows a `search.multi()` result to a movie entry.
752
- *
753
- * The `media_type` field is required on every `/search/multi` payload by
754
- * TMDB, so this check is safe at runtime and produces a strictly typed
755
- * MovieSummary on the narrowed branch.
756
- */
757
- declare function isMovieSearchResult(result: SearchMultiResult): result is MovieMultiResult;
758
- declare function isMovieSearchResult(result: unknown): result is MovieMultiResult;
759
- /** Type guard that narrows a `search.multi()` result to a TV entry. */
760
- declare function isTVSearchResult(result: SearchMultiResult): result is TVMultiResult;
761
- declare function isTVSearchResult(result: unknown): result is TVMultiResult;
762
- /** Type guard that narrows a `search.multi()` result to a person entry. */
763
- declare function isPersonSearchResult(result: SearchMultiResult): result is PersonMultiResult;
764
- declare function isPersonSearchResult(result: unknown): result is PersonMultiResult;
765
- /**
766
- * Convenience alias: `isMovieSearchResult` works on a `search.movies()`
767
- * result (which already has the narrow type but is also tagged with
768
- * `media_type?: 'movie'`), as well as on multi-search results.
769
- */
770
- declare function isMovie(result: MovieSearchResult | SearchMultiResult): result is MovieMultiResult;
771
- declare function isMovie(result: SearchMultiResult): result is MovieMultiResult;
772
- declare function isMovie(result: unknown): result is MovieMultiResult;
773
- /** Type guard that narrows a search result to a TV entry. */
774
- declare function isTV(result: TVSearchResult | SearchMultiResult): result is TVMultiResult;
775
- declare function isTV(result: SearchMultiResult): result is TVMultiResult;
776
- declare function isTV(result: unknown): result is TVMultiResult;
777
- /** Type guard that narrows a search result to a person entry. */
778
- declare function isPerson(result: PersonSearchResult | SearchMultiResult): result is PersonMultiResult;
779
- declare function isPerson(result: SearchMultiResult): result is PersonMultiResult;
780
- declare function isPerson(result: unknown): result is PersonMultiResult;
781
- //#endregion
782
- export { type BackdropSize, type CollectionSummary, type Configuration, type ConfigurationImages, type Country, type CreditCastMember, type CreditCrewMember, type CreditsResponse, type EpisodeGuestStar, type EpisodeSummary, type FetchLike, type Genre, type GenresResponse, type ImageItem, type ImageQueryOptions, type ImageSize, type ImageUrlTransform, type ImagesResponse, type JobDepartment, KNOWN_BACKDROP_SIZES, KNOWN_IMAGE_SIZES, KNOWN_LOGO_SIZES, KNOWN_POSTER_SIZES, KNOWN_PROFILE_SIZES, KNOWN_STILL_SIZES, type KnownBackdropSize, type KnownImageSize, type KnownLogoSize, type KnownPosterSize, type KnownProfileSize, type KnownStillSize, type Language, type LanguageCode, type LanguageOptions, type ListOptions, type LogoSize, type MediaType, type MovieAppendToResponse, type MovieDetails, type MovieDetailsOptions, type MovieMultiResult, type MovieSearchOptions, type MovieSearchResult, type MovieSummary, type MultiSearchOptions, type Network, type PagedResponse, type PersonDetails, type PersonKnownFor, type PersonKnownForMovie, type PersonKnownForTV, type PersonMultiResult, type PersonSearchResult, type PersonSummary, type PosterSize, type ProductionCompany, type ProductionCountry, type ProfileSize, type RegionCode, type SearchMultiResult, type SeasonSummary, type SpokenLanguage, type StillSize, type TMDBAccessTokenAuth, type TMDBApiKeyAuth, type TMDBAuth, TMDBClient, type TMDBClientOptions, type TMDBDateString, TMDBError, type TMDBFactoryOptions, type TMDBImagesOptions, type TMDBObject, TMDBRateLimitError, TMDBRequestError, type TMDBRequestOptions, TMDBResponseError, type TMDBTransport, type TVAppendToResponse, type TVDetails, type TVDetailsOptions, type TVMultiResult, type TVSearchOptions, type TVSearchResult, type TVSeasonAppendToResponse, type TVSeasonDetails, type TVSeasonDetailsOptions, type TVSummary, type Timezone, type TrendingResult, type TrendingTimeWindow, type Video, type VideosResponse, buildImageUrl, createTMDB, isKnownBackdropSize, isKnownImageSize, isKnownLogoSize, isKnownPosterSize, isKnownProfileSize, isKnownStillSize, isMovie, isMovieSearchResult, isPerson, isPersonSearchResult, isTV, isTVSearchResult };
783
- //# sourceMappingURL=index.d.ts.map
1
+ export { createTMDB, TMDBClient, type TMDBFactoryOptions } from './client.js';
2
+ export { TMDBError, TMDBRateLimitError, TMDBRequestError, TMDBResponseError, TMDBTimeoutError, } from './errors.js';
3
+ export { TMDBHttpClient } from './http.js';
4
+ export { withMemoryCache, type MemoryCacheOptions, type MemoryCacheTransport, } from './helpers/cache.js';
5
+ export { paginate, paginateItems, type PageFetcher, type PaginateOptions, } from './helpers/pagination.js';
6
+ export { retry, withRetry, type RetryInfo, type RetryOptions } from './helpers/retry.js';
7
+ export { withTimeout, type TimeoutOptions } from './helpers/timeout.js';
8
+ export { buildImageUrl } from './query.js';
9
+ export { isMovie, isMovieSearchResult, isPerson, isPersonSearchResult, isTV, isTVSearchResult, } from './search-guards.js';
10
+ export { isKnownBackdropSize, isKnownImageSize, isKnownLogoSize, isKnownPosterSize, isKnownProfileSize, isKnownStillSize, KNOWN_BACKDROP_SIZES, KNOWN_IMAGE_SIZES, KNOWN_LOGO_SIZES, KNOWN_POSTER_SIZES, KNOWN_PROFILE_SIZES, KNOWN_STILL_SIZES, } from './types.js';
11
+ export type { ImageUrlTransform } from './resources/images.js';
12
+ export type { FetchLike, TMDBAccessTokenAuth, TMDBApiKeyAuth, TMDBAuth, TMDBClientOptions, TMDBImagesOptions, TMDBRequestOptions, TMDBTransport, } from './http.js';
13
+ export type { AggregateCastMember, AggregateCreditsResponse, AggregateCrewMember, AggregateJob, AggregateRole, BackdropSize, CollectionSummary, Configuration, ConfigurationImages, Country, CreditCastMember, CreditCrewMember, CreditsResponse, Genre, GenresResponse, ImageItem, ImageQueryOptions, ImagesResponse, ImageSize, JobDepartment, KnownBackdropSize, KnownImageSize, KnownLogoSize, KnownPosterSize, KnownProfileSize, KnownStillSize, Language, LanguageCode, LanguageOptions, ListOptions, LogoSize, MediaType, MovieAppendToResponse, MovieDetails, MovieDetailsOptions, MovieSearchOptions, MovieSearchResult, MovieMultiResult, MovieSummary, MultiSearchOptions, Network, PagedResponse, PersonCombinedCast, PersonCombinedCastMovie, PersonCombinedCastTV, PersonCombinedCrew, PersonCombinedCrewMovie, PersonCombinedCrewTV, PersonCombinedCreditsResponse, PersonDetails, PersonKnownFor, PersonKnownForMovie, PersonKnownForTV, PersonMultiResult, PersonSearchResult, PersonSummary, PosterSize, ProductionCompany, ProductionCountry, ProfileSize, RegionCode, RequestOptions, SearchMultiResult, TVMultiResult, EpisodeAppendToResponse, EpisodeDetails, EpisodeDetailsOptions, EpisodeGroup, EpisodeGroupDetails, EpisodeGroupEpisode, EpisodeGroupsResponse, EpisodeGroupSummary, EpisodeGuestStar, EpisodeSummary, SeasonImagesResponse, SeasonSummary, SpokenLanguage, StillSize, Timezone, TMDBDateString, TMDBObject, TrendingResult, TrendingTimeWindow, TVAppendToResponse, TVDetails, TVDetailsOptions, TVSeasonAppendToResponse, TVSeasonDetails, TVSeasonDetailsOptions, TVSearchOptions, TVSearchResult, TVSummary, Video, VideosResponse, } from './types.js';