tmdb-kit 0.1.0-beta.0 → 0.1.0-beta.4
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/LICENSE +21 -0
- package/README.md +216 -12
- package/dist/index.cjs +381 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +282 -12
- package/dist/index.d.ts +282 -12
- package/dist/index.js +363 -24
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/dist/index.d.cts
CHANGED
|
@@ -8,10 +8,15 @@ interface JsonObject {
|
|
|
8
8
|
}
|
|
9
9
|
/** Escape hatch for append_to_response payloads and future TMDB fields. */
|
|
10
10
|
type TMDBObject = Record<string, unknown>;
|
|
11
|
+
/** Date string in TMDB format (typically `YYYY-MM-DD`). */
|
|
11
12
|
type TMDBDateString = string;
|
|
13
|
+
/** ISO 639-1 language code (e.g. `"en"`, `"zh"`). */
|
|
12
14
|
type LanguageCode = string;
|
|
15
|
+
/** ISO 3166-1 country/region code (e.g. `"US"`, `"CN"`). */
|
|
13
16
|
type RegionCode = string;
|
|
17
|
+
/** Supported media types for multi-search results. */
|
|
14
18
|
type MediaType = 'movie' | 'tv' | 'person';
|
|
19
|
+
/** Time window for trending endpoints: `"day"` or `"week"`. */
|
|
15
20
|
type TrendingTimeWindow = 'day' | 'week';
|
|
16
21
|
interface PagedResponse<T> {
|
|
17
22
|
page: number;
|
|
@@ -66,7 +71,6 @@ interface MovieDetails extends Omit<MovieSummary, 'genre_ids'> {
|
|
|
66
71
|
genres: Genre[];
|
|
67
72
|
homepage: string | null;
|
|
68
73
|
imdb_id: string | null;
|
|
69
|
-
origin_country?: string[];
|
|
70
74
|
production_companies: ProductionCompany[];
|
|
71
75
|
production_countries: ProductionCountry[];
|
|
72
76
|
revenue: number;
|
|
@@ -114,6 +118,51 @@ interface SeasonSummary {
|
|
|
114
118
|
season_number: number;
|
|
115
119
|
vote_average: number;
|
|
116
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
|
+
}
|
|
117
166
|
interface TVDetails extends Omit<TVSummary, 'genre_ids'> {
|
|
118
167
|
created_by: CreatedBy[];
|
|
119
168
|
episode_run_time: number[];
|
|
@@ -176,6 +225,16 @@ type SearchMultiResult = (MovieSummary & {
|
|
|
176
225
|
}) | (PersonSummary & {
|
|
177
226
|
media_type: 'person';
|
|
178
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
|
+
};
|
|
179
238
|
type TrendingResult = SearchMultiResult;
|
|
180
239
|
interface CreditCastMember {
|
|
181
240
|
adult?: boolean;
|
|
@@ -280,6 +339,41 @@ type PosterSize = 'w92' | 'w154' | 'w185' | 'w342' | 'w500' | 'w780' | 'original
|
|
|
280
339
|
type ProfileSize = 'w45' | 'w185' | 'h632' | 'original' | (string & {});
|
|
281
340
|
type StillSize = 'w92' | 'w185' | 'w300' | 'original' | (string & {});
|
|
282
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
|
+
/** Union of every documented image size. */
|
|
363
|
+
declare const KNOWN_IMAGE_SIZES: readonly ["w300", "w780", "w1280", "original", "w45", "w92", "w154", "w185", "w300", "w500", "original", "w92", "w154", "w185", "w342", "w500", "w780", "original", "w45", "w185", "h632", "original", "w92", "w185", "w300", "original"];
|
|
364
|
+
type KnownBackdropSize = (typeof KNOWN_BACKDROP_SIZES)[number];
|
|
365
|
+
type KnownLogoSize = (typeof KNOWN_LOGO_SIZES)[number];
|
|
366
|
+
type KnownPosterSize = (typeof KNOWN_POSTER_SIZES)[number];
|
|
367
|
+
type KnownProfileSize = (typeof KNOWN_PROFILE_SIZES)[number];
|
|
368
|
+
type KnownStillSize = (typeof KNOWN_STILL_SIZES)[number];
|
|
369
|
+
type KnownImageSize = KnownBackdropSize | KnownLogoSize | KnownPosterSize | KnownProfileSize | KnownStillSize;
|
|
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;
|
|
283
377
|
type MovieAppendToResponse = 'account_states' | 'alternative_titles' | 'changes' | 'credits' | 'external_ids' | 'images' | 'keywords' | 'lists' | 'recommendations' | 'release_dates' | 'reviews' | 'similar' | 'translations' | 'videos' | 'watch/providers' | (string & {});
|
|
284
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 & {});
|
|
285
379
|
interface ListOptions {
|
|
@@ -308,21 +402,36 @@ interface TVSearchOptions extends Omit<ListOptions, 'region'> {
|
|
|
308
402
|
}
|
|
309
403
|
interface MultiSearchOptions extends Omit<ListOptions, 'region'> {
|
|
310
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>;
|
|
311
411
|
}
|
|
312
412
|
interface ImageQueryOptions extends LanguageOptions {
|
|
313
413
|
includeImageLanguage?: string | readonly string[];
|
|
314
414
|
}
|
|
315
415
|
//#endregion
|
|
316
416
|
//#region src/query.d.ts
|
|
417
|
+
/** Primitives allowed as query parameter values. */
|
|
317
418
|
type QueryPrimitive = string | number | boolean;
|
|
419
|
+
/** A single query parameter value: primitive, array, or nullish. */
|
|
318
420
|
type QueryValue = QueryPrimitive | readonly QueryPrimitive[] | null | undefined;
|
|
421
|
+
/** Key-value map of query parameters for API requests. */
|
|
319
422
|
type QueryParams = Record<string, QueryValue>;
|
|
423
|
+
/** Default query parameters inherited from the client configuration. */
|
|
320
424
|
interface QueryDefaults {
|
|
321
425
|
language?: LanguageCode;
|
|
322
426
|
region?: RegionCode;
|
|
323
427
|
}
|
|
324
428
|
interface BuildImageUrlOptions {
|
|
325
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;
|
|
326
435
|
}
|
|
327
436
|
/**
|
|
328
437
|
* Build a full TMDB image URL from the path returned by API payloads.
|
|
@@ -330,7 +439,28 @@ interface BuildImageUrlOptions {
|
|
|
330
439
|
*/
|
|
331
440
|
declare function buildImageUrl(path: string | null | undefined, size?: ImageSize, options?: BuildImageUrlOptions): string | null;
|
|
332
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
|
|
333
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
|
+
*/
|
|
334
464
|
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
335
465
|
interface TMDBAccessTokenAuth {
|
|
336
466
|
/** TMDB API Read Access Token. Sent as an Authorization Bearer header. */
|
|
@@ -343,28 +473,52 @@ interface TMDBApiKeyAuth {
|
|
|
343
473
|
accessToken?: never;
|
|
344
474
|
}
|
|
345
475
|
type TMDBAuth = TMDBAccessTokenAuth | TMDBApiKeyAuth;
|
|
476
|
+
/** Internal defaults resolved during client construction. */
|
|
346
477
|
interface TMDBClientDefaults extends QueryDefaults {
|
|
347
478
|
imageBaseUrl: string;
|
|
348
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
|
+
}
|
|
349
489
|
type TMDBClientOptions = TMDBAuth & {
|
|
350
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. */
|
|
351
491
|
fetch?: FetchLike; /** Default language for endpoints that accept a language query parameter. */
|
|
352
492
|
defaultLanguage?: LanguageCode; /** Default region for movie list/search endpoints that accept a region query parameter. */
|
|
353
493
|
defaultRegion?: RegionCode; /** Custom image host. Defaults to https://image.tmdb.org/t/p. */
|
|
354
|
-
imageBaseUrl?: string; /**
|
|
494
|
+
imageBaseUrl?: string; /** Image-helper configuration: host overrides and URL transforms. */
|
|
495
|
+
images?: TMDBImagesOptions; /** Additional headers merged into every request before authentication is applied. */
|
|
355
496
|
headers?: HeadersInit;
|
|
356
497
|
};
|
|
498
|
+
/** Per-request overrides applied when making a single API call. */
|
|
357
499
|
interface TMDBRequestOptions {
|
|
358
500
|
headers?: HeadersInit;
|
|
359
501
|
query?: QueryParams;
|
|
360
502
|
signal?: AbortSignal;
|
|
361
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
|
+
*/
|
|
362
511
|
interface TMDBTransport {
|
|
363
512
|
readonly defaults: TMDBClientDefaults;
|
|
364
513
|
get<T>(path: string, options?: TMDBRequestOptions): Promise<T>;
|
|
365
514
|
}
|
|
366
515
|
//#endregion
|
|
367
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
|
+
*/
|
|
368
522
|
declare class ConfigurationResource {
|
|
369
523
|
#private;
|
|
370
524
|
constructor(transport: TMDBTransport);
|
|
@@ -377,6 +531,11 @@ declare class ConfigurationResource {
|
|
|
377
531
|
}
|
|
378
532
|
//#endregion
|
|
379
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
|
+
*/
|
|
380
539
|
declare class GenresResource {
|
|
381
540
|
#private;
|
|
382
541
|
constructor(transport: TMDBTransport);
|
|
@@ -384,14 +543,12 @@ declare class GenresResource {
|
|
|
384
543
|
tv(options?: LanguageOptions): Promise<GenresResponse>;
|
|
385
544
|
}
|
|
386
545
|
//#endregion
|
|
387
|
-
//#region src/resources/images.d.ts
|
|
388
|
-
declare class ImagesHelper {
|
|
389
|
-
#private;
|
|
390
|
-
constructor(transport: TMDBTransport);
|
|
391
|
-
url(path: string | null | undefined, size?: ImageSize): string | null;
|
|
392
|
-
}
|
|
393
|
-
//#endregion
|
|
394
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
|
+
*/
|
|
395
552
|
declare class MoviesResource {
|
|
396
553
|
#private;
|
|
397
554
|
constructor(transport: TMDBTransport);
|
|
@@ -408,6 +565,11 @@ declare class MoviesResource {
|
|
|
408
565
|
}
|
|
409
566
|
//#endregion
|
|
410
567
|
//#region src/resources/people.d.ts
|
|
568
|
+
/**
|
|
569
|
+
* Access TMDB person (actor, director, etc.) endpoints.
|
|
570
|
+
*
|
|
571
|
+
* Obtained via `client.people`.
|
|
572
|
+
*/
|
|
411
573
|
declare class PeopleResource {
|
|
412
574
|
#private;
|
|
413
575
|
constructor(transport: TMDBTransport);
|
|
@@ -416,6 +578,11 @@ declare class PeopleResource {
|
|
|
416
578
|
}
|
|
417
579
|
//#endregion
|
|
418
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
|
+
*/
|
|
419
586
|
declare class SearchResource {
|
|
420
587
|
#private;
|
|
421
588
|
constructor(transport: TMDBTransport);
|
|
@@ -426,6 +593,11 @@ declare class SearchResource {
|
|
|
426
593
|
}
|
|
427
594
|
//#endregion
|
|
428
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
|
+
*/
|
|
429
601
|
declare class TrendingResource {
|
|
430
602
|
#private;
|
|
431
603
|
constructor(transport: TMDBTransport);
|
|
@@ -442,6 +614,11 @@ declare class TrendingResource {
|
|
|
442
614
|
}
|
|
443
615
|
//#endregion
|
|
444
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
|
+
*/
|
|
445
622
|
declare class TVResource {
|
|
446
623
|
#private;
|
|
447
624
|
constructor(transport: TMDBTransport);
|
|
@@ -455,9 +632,20 @@ declare class TVResource {
|
|
|
455
632
|
recommendations(seriesId: number, options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
|
|
456
633
|
similar(seriesId: number, options?: Omit<ListOptions, 'region'>): Promise<PagedResponse<TVSummary>>;
|
|
457
634
|
videos(seriesId: number, options?: LanguageOptions): Promise<VideosResponse>;
|
|
635
|
+
seasonDetails<TAppend extends TMDBObject = TMDBObject>(seriesId: number, seasonNumber: number, options?: TVSeasonDetailsOptions): Promise<TVSeasonDetails & TAppend>;
|
|
458
636
|
}
|
|
459
637
|
//#endregion
|
|
460
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
|
+
};
|
|
461
649
|
/**
|
|
462
650
|
* Main SDK entry point.
|
|
463
651
|
*
|
|
@@ -475,12 +663,36 @@ declare class TMDBClient {
|
|
|
475
663
|
readonly search: SearchResource;
|
|
476
664
|
readonly trending: TrendingResource;
|
|
477
665
|
readonly tv: TVResource;
|
|
478
|
-
constructor(options:
|
|
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
|
+
*/
|
|
479
678
|
request<T>(path: string, options?: TMDBRequestOptions): Promise<T>;
|
|
480
679
|
}
|
|
481
|
-
|
|
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;
|
|
482
693
|
//#endregion
|
|
483
694
|
//#region src/errors.d.ts
|
|
695
|
+
/** Options for constructing a {@link TMDBResponseError} or its subclasses. */
|
|
484
696
|
interface TMDBResponseErrorOptions {
|
|
485
697
|
body: JsonValue | undefined;
|
|
486
698
|
headers: Headers;
|
|
@@ -507,7 +719,65 @@ declare class TMDBResponseError extends TMDBError {
|
|
|
507
719
|
readonly statusText: string;
|
|
508
720
|
readonly url: string;
|
|
509
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);
|
|
510
747
|
}
|
|
511
748
|
//#endregion
|
|
512
|
-
|
|
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 };
|
|
513
783
|
//# sourceMappingURL=index.d.cts.map
|