@lorenzopant/tmdb 1.18.1 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +129 -1
- package/dist/index.mjs +139 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3359,6 +3359,47 @@ type PersonImagesParams = PersonBaseParam;
|
|
|
3359
3359
|
type PersonTranslationsParams = PersonBaseParam;
|
|
3360
3360
|
type PersonTaggedImagesParams = Prettify<PersonBaseParam & WithPage>;
|
|
3361
3361
|
//#endregion
|
|
3362
|
+
//#region src/types/v4/auth.d.ts
|
|
3363
|
+
/** Optional request body for POST /4/auth/request_token. */
|
|
3364
|
+
type V4AuthCreateRequestTokenBody = {
|
|
3365
|
+
/** URL to redirect the user back to after they approve the request token on TMDB. */redirect_to?: string;
|
|
3366
|
+
};
|
|
3367
|
+
/**
|
|
3368
|
+
* Response from POST /4/auth/request_token.
|
|
3369
|
+
* Contains a short-lived request token the user must approve at the TMDB website.
|
|
3370
|
+
*/
|
|
3371
|
+
type V4AuthRequestTokenResponse = {
|
|
3372
|
+
/** Always `true` on success. */success: boolean;
|
|
3373
|
+
/** The generated request token. Redirect the user to:
|
|
3374
|
+
* `https://www.themoviedb.org/auth/access?request_token={request_token}` to approve it. */
|
|
3375
|
+
request_token: string;
|
|
3376
|
+
};
|
|
3377
|
+
/** Request body for POST /4/auth/access_token. */
|
|
3378
|
+
type V4AuthCreateAccessTokenBody = {
|
|
3379
|
+
/** The request token that the user has approved at the TMDB website. */request_token: string;
|
|
3380
|
+
};
|
|
3381
|
+
/**
|
|
3382
|
+
* Response from POST /4/auth/access_token.
|
|
3383
|
+
* Contains the permanent user access token and the TMDB account ID.
|
|
3384
|
+
*/
|
|
3385
|
+
type V4AuthAccessTokenResponse = {
|
|
3386
|
+
/** Always `true` on success. */success: boolean; /** The permanent user access token (Bearer token). Store this securely — treat it like a password. */
|
|
3387
|
+
access_token: string; /** The TMDB account ID associated with this access token. Used by v4 account endpoints. */
|
|
3388
|
+
account_id: string;
|
|
3389
|
+
};
|
|
3390
|
+
/** Request body for DELETE /4/auth/access_token. */
|
|
3391
|
+
type V4AuthDeleteAccessTokenBody = {
|
|
3392
|
+
/** The access token to invalidate. */access_token: string;
|
|
3393
|
+
};
|
|
3394
|
+
/**
|
|
3395
|
+
* Response from DELETE /4/auth/access_token.
|
|
3396
|
+
*/
|
|
3397
|
+
type V4AuthDeleteAccessTokenResponse = {
|
|
3398
|
+
/** `true` if the access token was successfully deleted. */success: boolean; /** TMDB internal status code. */
|
|
3399
|
+
status_code: number; /** Human-readable status message. */
|
|
3400
|
+
status_message: string;
|
|
3401
|
+
};
|
|
3402
|
+
//#endregion
|
|
3362
3403
|
//#region src/client.d.ts
|
|
3363
3404
|
declare class ApiClient {
|
|
3364
3405
|
private accessToken;
|
|
@@ -3377,6 +3418,7 @@ declare class ApiClient {
|
|
|
3377
3418
|
private onErrorInterceptor?;
|
|
3378
3419
|
private imageApi?;
|
|
3379
3420
|
constructor(accessToken: string, options?: {
|
|
3421
|
+
/** @internal API version to target. Used by TMDBv4 — not exposed in TMDBOptions. */version?: 3 | 4;
|
|
3380
3422
|
logger?: boolean | TMDBLoggerFn;
|
|
3381
3423
|
deduplication?: boolean;
|
|
3382
3424
|
images?: ImagesConfig;
|
|
@@ -5109,9 +5151,89 @@ declare class AuthenticationAPI extends TMDBAPIBase {
|
|
|
5109
5151
|
delete_session(body: AuthDeleteSessionBody): Promise<AuthDeleteSessionResponse>;
|
|
5110
5152
|
}
|
|
5111
5153
|
//#endregion
|
|
5154
|
+
//#region src/endpoints/v4/auth.d.ts
|
|
5155
|
+
declare class V4AuthAPI extends TMDBAPIBase {
|
|
5156
|
+
/**
|
|
5157
|
+
* Create Request Token
|
|
5158
|
+
* POST - https://api.themoviedb.org/4/auth/request_token
|
|
5159
|
+
*
|
|
5160
|
+
* Generate a request token that the user must approve at the TMDB website to begin
|
|
5161
|
+
* the v4 OAuth-style flow. Redirect the user to:
|
|
5162
|
+
* `https://www.themoviedb.org/auth/access?request_token={request_token}`
|
|
5163
|
+
*
|
|
5164
|
+
* Once approved, exchange the token for an access token using `create_access_token`.
|
|
5165
|
+
* @param body Optional body with a `redirect_to` URL for post-approval redirect.
|
|
5166
|
+
* @reference https://developer.themoviedb.org/reference/create-request-token
|
|
5167
|
+
*/
|
|
5168
|
+
create_request_token(body?: V4AuthCreateRequestTokenBody): Promise<V4AuthRequestTokenResponse>;
|
|
5169
|
+
/**
|
|
5170
|
+
* Create Access Token
|
|
5171
|
+
* POST - https://api.themoviedb.org/4/auth/access_token
|
|
5172
|
+
*
|
|
5173
|
+
* Exchange a user-approved request token for a permanent user access token and
|
|
5174
|
+
* TMDB account ID. Store the returned `access_token` securely — it is valid
|
|
5175
|
+
* indefinitely until explicitly deleted with `delete_access_token`.
|
|
5176
|
+
* @param body An object containing the approved `request_token`.
|
|
5177
|
+
* @reference https://developer.themoviedb.org/reference/create-access-token
|
|
5178
|
+
*/
|
|
5179
|
+
create_access_token(body: V4AuthCreateAccessTokenBody): Promise<V4AuthAccessTokenResponse>;
|
|
5180
|
+
/**
|
|
5181
|
+
* Delete Access Token (Logout)
|
|
5182
|
+
* DELETE - https://api.themoviedb.org/4/auth/access_token
|
|
5183
|
+
*
|
|
5184
|
+
* Invalidate a user access token. Use this to log a user out of your application.
|
|
5185
|
+
* @param body An object containing the `access_token` to delete.
|
|
5186
|
+
* @reference https://developer.themoviedb.org/reference/delete-access-token
|
|
5187
|
+
*/
|
|
5188
|
+
delete_access_token(body: V4AuthDeleteAccessTokenBody): Promise<V4AuthDeleteAccessTokenResponse>;
|
|
5189
|
+
}
|
|
5190
|
+
//#endregion
|
|
5191
|
+
//#region src/endpoints/v4/account.d.ts
|
|
5192
|
+
declare class V4AccountAPI extends TMDBAPIBase {}
|
|
5193
|
+
//#endregion
|
|
5194
|
+
//#region src/endpoints/v4/lists.d.ts
|
|
5195
|
+
declare class V4ListsAPI extends TMDBAPIBase {}
|
|
5196
|
+
//#endregion
|
|
5197
|
+
//#region src/tmdb.v4.d.ts
|
|
5198
|
+
/**
|
|
5199
|
+
* Aggregator for all TMDB API v4 namespaces.
|
|
5200
|
+
*
|
|
5201
|
+
* Access via `tmdb.v4` — the v4 client is backed by `https://api.themoviedb.org/4`
|
|
5202
|
+
* and inherits the same access token and options as the parent TMDB instance.
|
|
5203
|
+
*
|
|
5204
|
+
* @example
|
|
5205
|
+
* ```ts
|
|
5206
|
+
* const tmdb = new TMDB(accessToken);
|
|
5207
|
+
*
|
|
5208
|
+
* // v4 auth flow
|
|
5209
|
+
* const { request_token } = await tmdb.v4.auth.create_request_token();
|
|
5210
|
+
* // ... user approves at https://www.themoviedb.org/auth/access?request_token=...
|
|
5211
|
+
* const { access_token, account_id } = await tmdb.v4.auth.create_access_token({ request_token });
|
|
5212
|
+
*
|
|
5213
|
+
* // v4 account (account_id is a string from the access token response)
|
|
5214
|
+
* const profile = await tmdb.v4.account.details(account_id);
|
|
5215
|
+
* const favorites = await tmdb.v4.account.favorite_movies({ account_id, page: 1 });
|
|
5216
|
+
*
|
|
5217
|
+
* // v4 lists (full CRUD)
|
|
5218
|
+
* const list = await tmdb.v4.lists.create({ name: "My list", iso_639_1: "en" });
|
|
5219
|
+
* await tmdb.v4.lists.add_items(list.id, { items: [{ media_type: "movie", media_id: 550 }] });
|
|
5220
|
+
* ```
|
|
5221
|
+
*/
|
|
5222
|
+
declare class TMDBv4 {
|
|
5223
|
+
private client;
|
|
5224
|
+
/** v4 authentication — request token → access token → logout. */
|
|
5225
|
+
auth: V4AuthAPI;
|
|
5226
|
+
/** v4 account — details, lists, favorites, watchlist, rated. */
|
|
5227
|
+
account: V4AccountAPI;
|
|
5228
|
+
/** v4 lists — full CRUD for user-created lists. */
|
|
5229
|
+
lists: V4ListsAPI;
|
|
5230
|
+
constructor(accessToken: string, options?: TMDBOptions);
|
|
5231
|
+
}
|
|
5232
|
+
//#endregion
|
|
5112
5233
|
//#region src/tmdb.d.ts
|
|
5113
5234
|
declare class TMDB {
|
|
5114
5235
|
private client;
|
|
5236
|
+
private accessToken;
|
|
5115
5237
|
private options;
|
|
5116
5238
|
movies: MoviesAPI;
|
|
5117
5239
|
movie_lists: MovieListsAPI;
|
|
@@ -5140,6 +5262,12 @@ declare class TMDB {
|
|
|
5140
5262
|
people: PeopleAPI;
|
|
5141
5263
|
account: AccountAPI;
|
|
5142
5264
|
authentication: AuthenticationAPI;
|
|
5265
|
+
/**
|
|
5266
|
+
* TMDB API v4 namespaces. Access via `tmdb.v4.auth`, `tmdb.v4.account`, `tmdb.v4.lists`.
|
|
5267
|
+
* Requires a Bearer (JWT) access token — throws if the instance was created with an API key.
|
|
5268
|
+
*/
|
|
5269
|
+
get v4(): TMDBv4;
|
|
5270
|
+
private _v4;
|
|
5143
5271
|
/**
|
|
5144
5272
|
* Creates a new TMDB instance.
|
|
5145
5273
|
* @param accessToken The TMDB API access token.
|
|
@@ -5184,4 +5312,4 @@ declare function hasLogoPath(data: unknown): data is {
|
|
|
5184
5312
|
logo_path: string;
|
|
5185
5313
|
};
|
|
5186
5314
|
//#endregion
|
|
5187
|
-
export { AccountAPI, AccountAddFavoriteBody, AccountAddToWatchlistBody, AccountAvatar, AccountDetails, AccountDetailsParams, AccountListItem, AccountListsParams, AccountListsResponse, AccountMediaListParams, AccountMovieItem, AccountMovieListResponse, AccountMutationParams, AccountMutationResponse, AccountRatedEpisodeItem, AccountRatedEpisodesResponse, AccountRatedMovieItem, AccountRatedMoviesResponse, AccountRatedTVItem, AccountRatedTVResponse, AccountSortBy, AccountTVItem, AccountTVListResponse, AlternativeName, AlternativeNamesResult, AlternativeTitle, AuthCreateSessionBody, AuthCreateSessionResponse, AuthCreateSessionWithLoginBody, AuthDeleteSessionBody, AuthDeleteSessionResponse, AuthGuestSessionResponse, AuthRequestTokenResponse, AuthValidateKeyResponse, AuthenticationAPI, BACKDROP_SIZES, BackdropSize, Cast, CertificationItem, Certifications, CertificationsAPI, Change, ChangeItem, ChangeResultItem, Changes, ChangesAPI, Collection, CollectionBaseParam, CollectionDetailsParams, CollectionImages, CollectionImagesParams, CollectionItem, CollectionResultItem, CollectionTranslationData, CollectionTranslations, CollectionsAPI, CompaniesAPI, Company, CompanyAlternativeName, CompanyAlternativeNames, CompanyAlternativeNamesParams, CompanyBaseParam, CompanyDetailsParams, CompanyImages, CompanyImagesParams, CompanyResultItem, CompanySummary, ConfigurationAPI, ConfigurationCountriesParams, ConfigurationCountry, ConfigurationJob, ConfigurationLanguage, ConfigurationResponse, ConfigurationTimezone, ContentRating, CountryISO3166_1, Credit, CreditBaseParam, CreditDetails, CreditDetailsMedia, CreditDetailsMovieMedia, CreditDetailsParams, CreditDetailsPerson, CreditDetailsTVEpisode, CreditDetailsTVMedia, CreditDetailsTVSeason, CreditsAPI, Crew, DateRange, DefaultImageSizesConfig, DiscoverAPI, DiscoverFilterExpression, DiscoverMovieParams, DiscoverMovieSortBy, DiscoverTVParams, DiscoverTVResultItem, DiscoverTVSortBy, DiscoverTVStatus, DiscoverTVType, FileType, FindAPI, FindByIDParams, FindExternalSource, FindMovieResultItem, FindPersonResultItem, FindResults, FindTVEpisodeResultItem, FindTVResultItem, FindTVSeasonResultItem, Genre, GenresAPI, GenresResponse, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, ImageCollectionKey, ImageConfiguration, ImageItem, ImageSize, ImageSizeTypes, ImagesConfig, ImagesResult, Keyword, KeywordBaseParam, KeywordDetailsParams, KeywordMoviesParams, KeywordResultItem, KeywordsAPI, KnownForItem, KnownForMovie, KnownForTV, LOGO_SIZES, Language, LanguageISO6391, LiteralUnion, LogoSize, MediaType, MediaWatchProviders, MovieAlternativeTitles, MovieAlternativeTitlesParams, MovieAppendToResponseNamespace, MovieAppendableMap, MovieChanges, MovieChangesParams, MovieCollection, MovieCredits, MovieCreditsParams, MovieDetails, MovieDetailsParams, MovieDetailsWithAppends, MovieExternalIDs, MovieExternalIDsParams, MovieImages, MovieImagesParams, MovieKeywords, MovieKeywordsParams, MovieListParams, MovieListsAPI, MovieRecommendations, MovieRecommendationsParams, MovieReleaseDate, MovieReleaseDateResult, MovieReleaseDates, MovieReleaseDatesParams, MovieResultItem, MovieReviews, MovieReviewsParams, MovieSimilar, MovieSimilarParams, MovieTranslationData, MovieTranslations, MovieTranslationsParams, MovieVideos, MovieVideosParams, MovieWatchProvidersParams, MoviesAPI, MultiSearchResultItem, Network, NetworkBaseParams, NetworkImages, NetworkItem, NetworksAPI, OrganizationImage, POSTER_SIZES, PROFILE_SIZES, PaginatedResponse, PeopleAPI, PeopleListParams, PeopleListsAPI, PersonAppendToResponseNamespace, PersonAppendableMap, PersonBaseParam, PersonChanges, PersonChangesParams, PersonCombinedCastCredit, PersonCombinedCredits, PersonCombinedCrewCredit, PersonCreditsParams, PersonDetails, PersonDetailsParams, PersonDetailsWithAppends, PersonExternalIDs, PersonExternalIDsParams, PersonImages, PersonImagesParams, PersonMovieCastCredit, PersonMovieCredits, PersonMovieCrewCredit, PersonResultItem, PersonTVCastCredit, PersonTVCredits, PersonTVCrewCredit, PersonTaggedImage, PersonTaggedImageMedia, PersonTaggedImages, PersonTaggedImagesParams, PersonTranslationData, PersonTranslations, PersonTranslationsParams, PosterSize, Prettify, PrimaryTranslations, ProductionCompany, ProductionCountry, ProfileSize, RequestInterceptor, RequestInterceptorContext, ResponseErrorInterceptor, ResponseSuccessInterceptor, Review, ReviewAuthorDetails, ReviewDetails, ReviewDetailsParams, ReviewsAPI, STILL_SIZES, SearchAPI, SearchCollectionsParams, SearchCompanyParams, SearchKeywordsParams, SearchMoviesParams, SearchMultiParams, SearchPersonParams, SearchTVSeriesParams, SpokenLanguage, StillSize, TMDB, TMDBCountries, TMDBError, TMDBLogger, TMDBLoggerEntry, TMDBLoggerFn, TMDBOptions, TMDBQueryParams, TVAggregateCredits, TVAggregateCreditsCastItem, TVAggregateCreditsCrewItem, TVAggregateCreditsParams, TVAlternativeTitles, TVAppendToResponseNamespace, TVAppendableMap, TVBaseParam, TVChangeParams, TVContentRatings, TVCreditJob, TVCreditRole, TVCredits, TVCreditsParams, TVDetailsParams, TVDetailsWithAppends, TVEpisode, TVEpisodeAppendToResponseNamespace, TVEpisodeAppendableMap, TVEpisodeBaseParams, TVEpisodeCredits, TVEpisodeCreditsParams, TVEpisodeDetailsParams, TVEpisodeDetailsWithAppends, TVEpisodeExternalIDs, TVEpisodeGroupDetails, TVEpisodeGroupDetailsItem, TVEpisodeGroupEpisode, TVEpisodeGroupItem, TVEpisodeGroupParams, TVEpisodeGroupType, TVEpisodeGroups, TVEpisodeGroupsAPI, TVEpisodeId, TVEpisodeImages, TVEpisodeImagesParams, TVEpisodeItem, TVEpisodeTranslationData, TVEpisodeTranslations, TVEpisodeVideos, TVEpisodesAPI, TVExternalIDs, TVImageItem, TVImages, TVImagesParams, TVKeywords, TVRecommendations, TVRecommendationsParams, TVReviews, TVReviewsParams, TVScreenedTheatrically, TVScreeningItem, TVSeason, TVSeasonAggregateCredits, TVSeasonAggregateCreditsParams, TVSeasonAppendToResponseNamespace, TVSeasonAppendableMap, TVSeasonBaseParams, TVSeasonChanges, TVSeasonChangesParams, TVSeasonCredits, TVSeasonCreditsParams, TVSeasonDetailsParams, TVSeasonDetailsWithAppends, TVSeasonEpisode, TVSeasonExternalIDs, TVSeasonId, TVSeasonImages, TVSeasonImagesParams, TVSeasonItem, TVSeasonTranslationData, TVSeasonTranslations, TVSeasonVideos, TVSeasonVideosParams, TVSeasonWatchProvidersParams, TVSeasonsAPI, TVSeriesAPI, TVSeriesChanges, TVSeriesDetails, TVSeriesListItem, TVSeriesListParams, TVSeriesLists, TVSeriesListsAPI, TVSeriesListsParams, TVSeriesResultItem, TVSimilar, TVSimilarParams, TVTranslationData, TVTranslations, TVVideos, Timezone, Translation, TranslationResults, TrendingAPI, TrendingAllResult, TrendingMovieResult, TrendingParams, TrendingPersonResult, TrendingTVResult, TrendingTimeWindow, VideoItem, VideoResults, WatchMonetizationType, WatchProvider, WatchProviderDisplayPriorities, WatchProviderItem, WatchProviderListItem, WatchProviderListParams, WatchProviderListResponse, WatchProviderRegionsParams, WatchProviderRegionsResponse, WatchProvidersAPI, WithLanguage, WithLanguagePage, WithPage, WithPageAndDateRange, WithParams, WithRegion, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
|
|
5315
|
+
export { AccountAPI, AccountAddFavoriteBody, AccountAddToWatchlistBody, AccountAvatar, AccountDetails, AccountDetailsParams, AccountListItem, AccountListsParams, AccountListsResponse, AccountMediaListParams, AccountMovieItem, AccountMovieListResponse, AccountMutationParams, AccountMutationResponse, AccountRatedEpisodeItem, AccountRatedEpisodesResponse, AccountRatedMovieItem, AccountRatedMoviesResponse, AccountRatedTVItem, AccountRatedTVResponse, AccountSortBy, AccountTVItem, AccountTVListResponse, AlternativeName, AlternativeNamesResult, AlternativeTitle, AuthCreateSessionBody, AuthCreateSessionResponse, AuthCreateSessionWithLoginBody, AuthDeleteSessionBody, AuthDeleteSessionResponse, AuthGuestSessionResponse, AuthRequestTokenResponse, AuthValidateKeyResponse, AuthenticationAPI, BACKDROP_SIZES, BackdropSize, Cast, CertificationItem, Certifications, CertificationsAPI, Change, ChangeItem, ChangeResultItem, Changes, ChangesAPI, Collection, CollectionBaseParam, CollectionDetailsParams, CollectionImages, CollectionImagesParams, CollectionItem, CollectionResultItem, CollectionTranslationData, CollectionTranslations, CollectionsAPI, CompaniesAPI, Company, CompanyAlternativeName, CompanyAlternativeNames, CompanyAlternativeNamesParams, CompanyBaseParam, CompanyDetailsParams, CompanyImages, CompanyImagesParams, CompanyResultItem, CompanySummary, ConfigurationAPI, ConfigurationCountriesParams, ConfigurationCountry, ConfigurationJob, ConfigurationLanguage, ConfigurationResponse, ConfigurationTimezone, ContentRating, CountryISO3166_1, Credit, CreditBaseParam, CreditDetails, CreditDetailsMedia, CreditDetailsMovieMedia, CreditDetailsParams, CreditDetailsPerson, CreditDetailsTVEpisode, CreditDetailsTVMedia, CreditDetailsTVSeason, CreditsAPI, Crew, DateRange, DefaultImageSizesConfig, DiscoverAPI, DiscoverFilterExpression, DiscoverMovieParams, DiscoverMovieSortBy, DiscoverTVParams, DiscoverTVResultItem, DiscoverTVSortBy, DiscoverTVStatus, DiscoverTVType, FileType, FindAPI, FindByIDParams, FindExternalSource, FindMovieResultItem, FindPersonResultItem, FindResults, FindTVEpisodeResultItem, FindTVResultItem, FindTVSeasonResultItem, Genre, GenresAPI, GenresResponse, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, ImageCollectionKey, ImageConfiguration, ImageItem, ImageSize, ImageSizeTypes, ImagesConfig, ImagesResult, Keyword, KeywordBaseParam, KeywordDetailsParams, KeywordMoviesParams, KeywordResultItem, KeywordsAPI, KnownForItem, KnownForMovie, KnownForTV, LOGO_SIZES, Language, LanguageISO6391, LiteralUnion, LogoSize, MediaType, MediaWatchProviders, MovieAlternativeTitles, MovieAlternativeTitlesParams, MovieAppendToResponseNamespace, MovieAppendableMap, MovieChanges, MovieChangesParams, MovieCollection, MovieCredits, MovieCreditsParams, MovieDetails, MovieDetailsParams, MovieDetailsWithAppends, MovieExternalIDs, MovieExternalIDsParams, MovieImages, MovieImagesParams, MovieKeywords, MovieKeywordsParams, MovieListParams, MovieListsAPI, MovieRecommendations, MovieRecommendationsParams, MovieReleaseDate, MovieReleaseDateResult, MovieReleaseDates, MovieReleaseDatesParams, MovieResultItem, MovieReviews, MovieReviewsParams, MovieSimilar, MovieSimilarParams, MovieTranslationData, MovieTranslations, MovieTranslationsParams, MovieVideos, MovieVideosParams, MovieWatchProvidersParams, MoviesAPI, MultiSearchResultItem, Network, NetworkBaseParams, NetworkImages, NetworkItem, NetworksAPI, OrganizationImage, POSTER_SIZES, PROFILE_SIZES, PaginatedResponse, PeopleAPI, PeopleListParams, PeopleListsAPI, PersonAppendToResponseNamespace, PersonAppendableMap, PersonBaseParam, PersonChanges, PersonChangesParams, PersonCombinedCastCredit, PersonCombinedCredits, PersonCombinedCrewCredit, PersonCreditsParams, PersonDetails, PersonDetailsParams, PersonDetailsWithAppends, PersonExternalIDs, PersonExternalIDsParams, PersonImages, PersonImagesParams, PersonMovieCastCredit, PersonMovieCredits, PersonMovieCrewCredit, PersonResultItem, PersonTVCastCredit, PersonTVCredits, PersonTVCrewCredit, PersonTaggedImage, PersonTaggedImageMedia, PersonTaggedImages, PersonTaggedImagesParams, PersonTranslationData, PersonTranslations, PersonTranslationsParams, PosterSize, Prettify, PrimaryTranslations, ProductionCompany, ProductionCountry, ProfileSize, RequestInterceptor, RequestInterceptorContext, ResponseErrorInterceptor, ResponseSuccessInterceptor, Review, ReviewAuthorDetails, ReviewDetails, ReviewDetailsParams, ReviewsAPI, STILL_SIZES, SearchAPI, SearchCollectionsParams, SearchCompanyParams, SearchKeywordsParams, SearchMoviesParams, SearchMultiParams, SearchPersonParams, SearchTVSeriesParams, SpokenLanguage, StillSize, TMDB, TMDBCountries, TMDBError, TMDBLogger, TMDBLoggerEntry, TMDBLoggerFn, TMDBOptions, TMDBQueryParams, TMDBv4, TVAggregateCredits, TVAggregateCreditsCastItem, TVAggregateCreditsCrewItem, TVAggregateCreditsParams, TVAlternativeTitles, TVAppendToResponseNamespace, TVAppendableMap, TVBaseParam, TVChangeParams, TVContentRatings, TVCreditJob, TVCreditRole, TVCredits, TVCreditsParams, TVDetailsParams, TVDetailsWithAppends, TVEpisode, TVEpisodeAppendToResponseNamespace, TVEpisodeAppendableMap, TVEpisodeBaseParams, TVEpisodeCredits, TVEpisodeCreditsParams, TVEpisodeDetailsParams, TVEpisodeDetailsWithAppends, TVEpisodeExternalIDs, TVEpisodeGroupDetails, TVEpisodeGroupDetailsItem, TVEpisodeGroupEpisode, TVEpisodeGroupItem, TVEpisodeGroupParams, TVEpisodeGroupType, TVEpisodeGroups, TVEpisodeGroupsAPI, TVEpisodeId, TVEpisodeImages, TVEpisodeImagesParams, TVEpisodeItem, TVEpisodeTranslationData, TVEpisodeTranslations, TVEpisodeVideos, TVEpisodesAPI, TVExternalIDs, TVImageItem, TVImages, TVImagesParams, TVKeywords, TVRecommendations, TVRecommendationsParams, TVReviews, TVReviewsParams, TVScreenedTheatrically, TVScreeningItem, TVSeason, TVSeasonAggregateCredits, TVSeasonAggregateCreditsParams, TVSeasonAppendToResponseNamespace, TVSeasonAppendableMap, TVSeasonBaseParams, TVSeasonChanges, TVSeasonChangesParams, TVSeasonCredits, TVSeasonCreditsParams, TVSeasonDetailsParams, TVSeasonDetailsWithAppends, TVSeasonEpisode, TVSeasonExternalIDs, TVSeasonId, TVSeasonImages, TVSeasonImagesParams, TVSeasonItem, TVSeasonTranslationData, TVSeasonTranslations, TVSeasonVideos, TVSeasonVideosParams, TVSeasonWatchProvidersParams, TVSeasonsAPI, TVSeriesAPI, TVSeriesChanges, TVSeriesDetails, TVSeriesListItem, TVSeriesListParams, TVSeriesLists, TVSeriesListsAPI, TVSeriesListsParams, TVSeriesResultItem, TVSimilar, TVSimilarParams, TVTranslationData, TVTranslations, TVVideos, Timezone, Translation, TranslationResults, TrendingAPI, TrendingAllResult, TrendingMovieResult, TrendingParams, TrendingPersonResult, TrendingTVResult, TrendingTimeWindow, V4AccountAPI, V4AuthAPI, V4AuthAccessTokenResponse, V4AuthCreateAccessTokenBody, V4AuthCreateRequestTokenBody, V4AuthDeleteAccessTokenBody, V4AuthDeleteAccessTokenResponse, V4AuthRequestTokenResponse, V4ListsAPI, VideoItem, VideoResults, WatchMonetizationType, WatchProvider, WatchProviderDisplayPriorities, WatchProviderItem, WatchProviderListItem, WatchProviderListParams, WatchProviderListResponse, WatchProviderRegionsParams, WatchProviderRegionsResponse, WatchProvidersAPI, WithLanguage, WithLanguagePage, WithPage, WithPageAndDateRange, WithParams, WithRegion, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
|
package/dist/index.mjs
CHANGED
|
@@ -299,7 +299,7 @@ var ImageAPI = class {
|
|
|
299
299
|
//#region src/client.ts
|
|
300
300
|
var ApiClient = class {
|
|
301
301
|
accessToken;
|
|
302
|
-
baseUrl
|
|
302
|
+
baseUrl;
|
|
303
303
|
logger;
|
|
304
304
|
/**
|
|
305
305
|
* Tracks in-flight requests keyed by a deterministic string derived from the endpoint
|
|
@@ -315,6 +315,7 @@ var ApiClient = class {
|
|
|
315
315
|
imageApi;
|
|
316
316
|
constructor(accessToken, options = {}) {
|
|
317
317
|
this.accessToken = accessToken;
|
|
318
|
+
this.baseUrl = `https://api.themoviedb.org/${options.version ?? 3}`;
|
|
318
319
|
this.logger = TMDBLogger.from(options.logger);
|
|
319
320
|
this.deduplication = options.deduplication !== false;
|
|
320
321
|
const raw = options.interceptors?.request;
|
|
@@ -662,6 +663,31 @@ const ENDPOINTS = {
|
|
|
662
663
|
REVIEWS: { DETAILS: "/review" },
|
|
663
664
|
PEOPLE_LISTS: { POPULAR: "/person/popular" }
|
|
664
665
|
};
|
|
666
|
+
/**
|
|
667
|
+
* TMDB API v4 endpoint fragments.
|
|
668
|
+
* These are combined with `https://api.themoviedb.org/4` by the v4 ApiClient.
|
|
669
|
+
*/
|
|
670
|
+
const ENDPOINTS_V4 = {
|
|
671
|
+
AUTH: {
|
|
672
|
+
REQUEST_TOKEN: "/auth/request_token",
|
|
673
|
+
ACCESS_TOKEN: "/auth/access_token"
|
|
674
|
+
},
|
|
675
|
+
ACCOUNT: {
|
|
676
|
+
DETAILS: "/account",
|
|
677
|
+
LISTS: "/lists",
|
|
678
|
+
FAVORITE_MOVIES: "/favorite/movies",
|
|
679
|
+
FAVORITE_TV: "/favorite/tv",
|
|
680
|
+
WATCHLIST_MOVIES: "/watchlist/movies",
|
|
681
|
+
WATCHLIST_TV: "/watchlist/tv",
|
|
682
|
+
RATED_MOVIES: "/rated/movies",
|
|
683
|
+
RATED_TV: "/rated/tv"
|
|
684
|
+
},
|
|
685
|
+
LISTS: {
|
|
686
|
+
DETAILS: "/list",
|
|
687
|
+
ITEMS: "/items",
|
|
688
|
+
ITEM_STATUS: "/item_status"
|
|
689
|
+
}
|
|
690
|
+
};
|
|
665
691
|
//#endregion
|
|
666
692
|
//#region src/errors/messages.ts
|
|
667
693
|
/**
|
|
@@ -670,7 +696,8 @@ const ENDPOINTS = {
|
|
|
670
696
|
*/
|
|
671
697
|
const Errors = {
|
|
672
698
|
NO_ACCESS_TOKEN: "TMDB requires a valid access token, please provide one.",
|
|
673
|
-
INVALID_CLIENT: "TMDB received an invalid ApiClient instance. Pass a valid ApiClient or an access token string."
|
|
699
|
+
INVALID_CLIENT: "TMDB received an invalid ApiClient instance. Pass a valid ApiClient or an access token string.",
|
|
700
|
+
V4_REQUIRES_JWT: "TMDB v4 requires a Bearer (JWT) access token. API key strings are not supported for v4 endpoints."
|
|
674
701
|
};
|
|
675
702
|
//#endregion
|
|
676
703
|
//#region src/endpoints/base.ts
|
|
@@ -2882,9 +2909,107 @@ var AuthenticationAPI = class extends TMDBAPIBase {
|
|
|
2882
2909
|
}
|
|
2883
2910
|
};
|
|
2884
2911
|
//#endregion
|
|
2912
|
+
//#region src/endpoints/v4/auth.ts
|
|
2913
|
+
var V4AuthAPI = class extends TMDBAPIBase {
|
|
2914
|
+
/**
|
|
2915
|
+
* Create Request Token
|
|
2916
|
+
* POST - https://api.themoviedb.org/4/auth/request_token
|
|
2917
|
+
*
|
|
2918
|
+
* Generate a request token that the user must approve at the TMDB website to begin
|
|
2919
|
+
* the v4 OAuth-style flow. Redirect the user to:
|
|
2920
|
+
* `https://www.themoviedb.org/auth/access?request_token={request_token}`
|
|
2921
|
+
*
|
|
2922
|
+
* Once approved, exchange the token for an access token using `create_access_token`.
|
|
2923
|
+
* @param body Optional body with a `redirect_to` URL for post-approval redirect.
|
|
2924
|
+
* @reference https://developer.themoviedb.org/reference/create-request-token
|
|
2925
|
+
*/
|
|
2926
|
+
async create_request_token(body) {
|
|
2927
|
+
return this.client.mutate("POST", ENDPOINTS_V4.AUTH.REQUEST_TOKEN, body ?? {});
|
|
2928
|
+
}
|
|
2929
|
+
/**
|
|
2930
|
+
* Create Access Token
|
|
2931
|
+
* POST - https://api.themoviedb.org/4/auth/access_token
|
|
2932
|
+
*
|
|
2933
|
+
* Exchange a user-approved request token for a permanent user access token and
|
|
2934
|
+
* TMDB account ID. Store the returned `access_token` securely — it is valid
|
|
2935
|
+
* indefinitely until explicitly deleted with `delete_access_token`.
|
|
2936
|
+
* @param body An object containing the approved `request_token`.
|
|
2937
|
+
* @reference https://developer.themoviedb.org/reference/create-access-token
|
|
2938
|
+
*/
|
|
2939
|
+
async create_access_token(body) {
|
|
2940
|
+
return this.client.mutate("POST", ENDPOINTS_V4.AUTH.ACCESS_TOKEN, body);
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* Delete Access Token (Logout)
|
|
2944
|
+
* DELETE - https://api.themoviedb.org/4/auth/access_token
|
|
2945
|
+
*
|
|
2946
|
+
* Invalidate a user access token. Use this to log a user out of your application.
|
|
2947
|
+
* @param body An object containing the `access_token` to delete.
|
|
2948
|
+
* @reference https://developer.themoviedb.org/reference/delete-access-token
|
|
2949
|
+
*/
|
|
2950
|
+
async delete_access_token(body) {
|
|
2951
|
+
return this.client.mutate("DELETE", ENDPOINTS_V4.AUTH.ACCESS_TOKEN, body);
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
//#endregion
|
|
2955
|
+
//#region src/endpoints/v4/account.ts
|
|
2956
|
+
var V4AccountAPI = class extends TMDBAPIBase {};
|
|
2957
|
+
//#endregion
|
|
2958
|
+
//#region src/endpoints/v4/lists.ts
|
|
2959
|
+
var V4ListsAPI = class extends TMDBAPIBase {};
|
|
2960
|
+
//#endregion
|
|
2961
|
+
//#region src/tmdb.v4.ts
|
|
2962
|
+
/**
|
|
2963
|
+
* Aggregator for all TMDB API v4 namespaces.
|
|
2964
|
+
*
|
|
2965
|
+
* Access via `tmdb.v4` — the v4 client is backed by `https://api.themoviedb.org/4`
|
|
2966
|
+
* and inherits the same access token and options as the parent TMDB instance.
|
|
2967
|
+
*
|
|
2968
|
+
* @example
|
|
2969
|
+
* ```ts
|
|
2970
|
+
* const tmdb = new TMDB(accessToken);
|
|
2971
|
+
*
|
|
2972
|
+
* // v4 auth flow
|
|
2973
|
+
* const { request_token } = await tmdb.v4.auth.create_request_token();
|
|
2974
|
+
* // ... user approves at https://www.themoviedb.org/auth/access?request_token=...
|
|
2975
|
+
* const { access_token, account_id } = await tmdb.v4.auth.create_access_token({ request_token });
|
|
2976
|
+
*
|
|
2977
|
+
* // v4 account (account_id is a string from the access token response)
|
|
2978
|
+
* const profile = await tmdb.v4.account.details(account_id);
|
|
2979
|
+
* const favorites = await tmdb.v4.account.favorite_movies({ account_id, page: 1 });
|
|
2980
|
+
*
|
|
2981
|
+
* // v4 lists (full CRUD)
|
|
2982
|
+
* const list = await tmdb.v4.lists.create({ name: "My list", iso_639_1: "en" });
|
|
2983
|
+
* await tmdb.v4.lists.add_items(list.id, { items: [{ media_type: "movie", media_id: 550 }] });
|
|
2984
|
+
* ```
|
|
2985
|
+
*/
|
|
2986
|
+
var TMDBv4 = class {
|
|
2987
|
+
client;
|
|
2988
|
+
/** v4 authentication — request token → access token → logout. */
|
|
2989
|
+
auth;
|
|
2990
|
+
/** v4 account — details, lists, favorites, watchlist, rated. */
|
|
2991
|
+
account;
|
|
2992
|
+
/** v4 lists — full CRUD for user-created lists. */
|
|
2993
|
+
lists;
|
|
2994
|
+
constructor(accessToken, options = {}) {
|
|
2995
|
+
if (!accessToken) throw new Error(Errors.NO_ACCESS_TOKEN);
|
|
2996
|
+
this.client = new ApiClient(accessToken, {
|
|
2997
|
+
version: 4,
|
|
2998
|
+
logger: options.logger,
|
|
2999
|
+
deduplication: options.deduplication,
|
|
3000
|
+
images: options.images,
|
|
3001
|
+
interceptors: options.interceptors
|
|
3002
|
+
});
|
|
3003
|
+
this.auth = new V4AuthAPI(this.client, options);
|
|
3004
|
+
this.account = new V4AccountAPI(this.client, options);
|
|
3005
|
+
this.lists = new V4ListsAPI(this.client, options);
|
|
3006
|
+
}
|
|
3007
|
+
};
|
|
3008
|
+
//#endregion
|
|
2885
3009
|
//#region src/tmdb.ts
|
|
2886
3010
|
var TMDB = class {
|
|
2887
3011
|
client;
|
|
3012
|
+
accessToken;
|
|
2888
3013
|
options;
|
|
2889
3014
|
movies;
|
|
2890
3015
|
movie_lists;
|
|
@@ -2914,12 +3039,23 @@ var TMDB = class {
|
|
|
2914
3039
|
account;
|
|
2915
3040
|
authentication;
|
|
2916
3041
|
/**
|
|
3042
|
+
* TMDB API v4 namespaces. Access via `tmdb.v4.auth`, `tmdb.v4.account`, `tmdb.v4.lists`.
|
|
3043
|
+
* Requires a Bearer (JWT) access token — throws if the instance was created with an API key.
|
|
3044
|
+
*/
|
|
3045
|
+
get v4() {
|
|
3046
|
+
if (!isJwt(this.accessToken)) throw new Error(Errors.V4_REQUIRES_JWT);
|
|
3047
|
+
if (!this._v4) this._v4 = new TMDBv4(this.accessToken, this.options);
|
|
3048
|
+
return this._v4;
|
|
3049
|
+
}
|
|
3050
|
+
_v4;
|
|
3051
|
+
/**
|
|
2917
3052
|
* Creates a new TMDB instance.
|
|
2918
3053
|
* @param accessToken The TMDB API access token.
|
|
2919
3054
|
* @param options Optional default options (e.g., language) for all requests.
|
|
2920
3055
|
*/
|
|
2921
3056
|
constructor(accessToken, options = {}) {
|
|
2922
3057
|
if (!accessToken) throw new Error(Errors.NO_ACCESS_TOKEN);
|
|
3058
|
+
this.accessToken = accessToken;
|
|
2923
3059
|
this.options = options;
|
|
2924
3060
|
this.client = new ApiClient(accessToken, {
|
|
2925
3061
|
logger: options.logger,
|
|
@@ -4272,4 +4408,4 @@ let TVEpisodeGroupType = /* @__PURE__ */ function(TVEpisodeGroupType) {
|
|
|
4272
4408
|
return TVEpisodeGroupType;
|
|
4273
4409
|
}({});
|
|
4274
4410
|
//#endregion
|
|
4275
|
-
export { AccountAPI, AuthenticationAPI, BACKDROP_SIZES, CertificationsAPI, ChangesAPI, CollectionsAPI, CompaniesAPI, ConfigurationAPI, CreditsAPI, DiscoverAPI, DiscoverTVStatus, DiscoverTVType, FindAPI, GenresAPI, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, KeywordsAPI, LOGO_SIZES, MovieListsAPI, MoviesAPI, NetworksAPI, POSTER_SIZES, PROFILE_SIZES, PeopleAPI, PeopleListsAPI, ReviewsAPI, STILL_SIZES, SearchAPI, TMDB, TMDBCountries, TMDBError, TMDBLogger, TVEpisodeGroupType, TVEpisodeGroupsAPI, TVEpisodesAPI, TVSeasonsAPI, TVSeriesAPI, TVSeriesListsAPI, TrendingAPI, WatchProvidersAPI, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
|
|
4411
|
+
export { AccountAPI, AuthenticationAPI, BACKDROP_SIZES, CertificationsAPI, ChangesAPI, CollectionsAPI, CompaniesAPI, ConfigurationAPI, CreditsAPI, DiscoverAPI, DiscoverTVStatus, DiscoverTVType, FindAPI, GenresAPI, IMAGE_BASE_URL, IMAGE_SECURE_BASE_URL, KeywordsAPI, LOGO_SIZES, MovieListsAPI, MoviesAPI, NetworksAPI, POSTER_SIZES, PROFILE_SIZES, PeopleAPI, PeopleListsAPI, ReviewsAPI, STILL_SIZES, SearchAPI, TMDB, TMDBCountries, TMDBError, TMDBLogger, TMDBv4, TVEpisodeGroupType, TVEpisodeGroupsAPI, TVEpisodesAPI, TVSeasonsAPI, TVSeriesAPI, TVSeriesListsAPI, TrendingAPI, V4AccountAPI, V4AuthAPI, V4ListsAPI, WatchProvidersAPI, hasBackdropPath, hasLogoPath, hasPosterPath, hasProfilePath, hasStillPath, isJwt, isKnownForMovie, isKnownForTV, isPlainObject, isRecord };
|