@lorenzopant/tmdb 1.15.1 → 1.17.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/client.js +13 -4
- package/dist/endpoints/base.d.ts +1 -0
- package/dist/endpoints/base.js +3 -2
- package/dist/endpoints/people.d.ts +91 -0
- package/dist/endpoints/people.js +128 -0
- package/dist/endpoints/people_lists.d.ts +16 -0
- package/dist/endpoints/people_lists.js +16 -0
- package/dist/endpoints/reviews.d.ts +14 -0
- package/dist/endpoints/reviews.js +16 -0
- package/dist/endpoints/tv_series.js +19 -18
- package/dist/routes.d.ts +18 -0
- package/dist/routes.js +18 -0
- package/dist/tmdb.d.ts +6 -0
- package/dist/tmdb.js +9 -0
- package/dist/types/collections.d.ts +2 -1
- package/dist/types/companies.d.ts +3 -2
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/movies.d.ts +2 -2
- package/dist/types/people-lists.d.ts +5 -0
- package/dist/types/people-lists.js +1 -0
- package/dist/types/people.d.ts +214 -0
- package/dist/types/people.js +1 -0
- package/dist/types/reviews.d.ts +22 -0
- package/dist/types/reviews.js +1 -0
- package/dist/types/tv-episodes.d.ts +2 -1
- package/dist/types/tv-seasons.d.ts +3 -1
- package/dist/types/tv-series.d.ts +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/jwt.d.ts +1 -0
- package/dist/utils/jwt.js +61 -0
- package/package.json +4 -2
package/dist/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TMDBError } from "./errors/tmdb";
|
|
2
2
|
import { TMDBLogger } from "./utils/logger";
|
|
3
|
+
import { isJwt } from "./utils";
|
|
3
4
|
export class ApiClient {
|
|
4
5
|
accessToken;
|
|
5
6
|
baseUrl = "https://api.themoviedb.org/3";
|
|
@@ -10,11 +11,15 @@ export class ApiClient {
|
|
|
10
11
|
}
|
|
11
12
|
async request(endpoint, params = {}) {
|
|
12
13
|
const url = new URL(`${this.baseUrl}${endpoint}`);
|
|
14
|
+
const jwt = isJwt(this.accessToken);
|
|
13
15
|
for (const [key, value] of Object.entries(params)) {
|
|
14
16
|
if (value === undefined)
|
|
15
17
|
continue;
|
|
16
18
|
url.searchParams.append(key, String(value));
|
|
17
19
|
}
|
|
20
|
+
if (!jwt) {
|
|
21
|
+
url.searchParams.append("api_key", this.accessToken);
|
|
22
|
+
}
|
|
18
23
|
const startedAt = Date.now();
|
|
19
24
|
this.logger?.log({
|
|
20
25
|
type: "request",
|
|
@@ -24,10 +29,14 @@ export class ApiClient {
|
|
|
24
29
|
let res;
|
|
25
30
|
try {
|
|
26
31
|
res = await fetch(url.toString(), {
|
|
27
|
-
headers:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
headers: jwt
|
|
33
|
+
? {
|
|
34
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
35
|
+
"Content-Type": "application/json;charset=utf-8",
|
|
36
|
+
}
|
|
37
|
+
: {
|
|
38
|
+
"Content-Type": "application/json;charset=utf-8",
|
|
39
|
+
},
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
42
|
catch (error) {
|
package/dist/endpoints/base.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare abstract class TMDBAPIBase {
|
|
|
14
14
|
/**
|
|
15
15
|
* Ensures params contains a language: prefer explicit param, fallback to defaultOptions.language.
|
|
16
16
|
* If neither is present, returns the original params unmodified.
|
|
17
|
+
* When params is undefined but a default language is set, returns { language: defaultLang }.
|
|
17
18
|
*/
|
|
18
19
|
protected withLanguage<T extends {
|
|
19
20
|
language?: Language;
|
package/dist/endpoints/base.js
CHANGED
|
@@ -17,13 +17,14 @@ export class TMDBAPIBase {
|
|
|
17
17
|
/**
|
|
18
18
|
* Ensures params contains a language: prefer explicit param, fallback to defaultOptions.language.
|
|
19
19
|
* If neither is present, returns the original params unmodified.
|
|
20
|
+
* When params is undefined but a default language is set, returns { language: defaultLang }.
|
|
20
21
|
*/
|
|
21
22
|
withLanguage(params) {
|
|
23
|
+
const defaultLang = this.defaultOptions?.language;
|
|
22
24
|
if (!params)
|
|
23
|
-
return undefined
|
|
25
|
+
return defaultLang !== undefined ? { language: defaultLang } : undefined;
|
|
24
26
|
if (params.language !== undefined)
|
|
25
27
|
return params;
|
|
26
|
-
const defaultLang = this.defaultOptions?.language;
|
|
27
28
|
if (defaultLang === undefined)
|
|
28
29
|
return params;
|
|
29
30
|
return { ...params, language: defaultLang };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { TMDBAPIBase } from "./base";
|
|
2
|
+
import type { PersonAppendToResponseNamespace, PersonChanges, PersonChangesParams, PersonCombinedCredits, PersonCreditsParams, PersonDetails, PersonDetailsParams, PersonDetailsWithAppends, PersonExternalIDs, PersonExternalIDsParams, PersonImages, PersonImagesParams, PersonMovieCredits, PersonTaggedImages, PersonTaggedImagesParams, PersonTranslations, PersonTranslationsParams, PersonTVCredits } from "../types/people";
|
|
3
|
+
export declare class PeopleAPI extends TMDBAPIBase {
|
|
4
|
+
private personPath;
|
|
5
|
+
private personSubPath;
|
|
6
|
+
/**
|
|
7
|
+
* Details
|
|
8
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}
|
|
9
|
+
*
|
|
10
|
+
* Get the primary person details by TMDB person id.
|
|
11
|
+
* @param person_id The TMDB person id.
|
|
12
|
+
* @param append_to_response Additional person subresources to append.
|
|
13
|
+
* @param language Language for localized results.
|
|
14
|
+
* @reference https://developer.themoviedb.org/reference/person-details
|
|
15
|
+
*/
|
|
16
|
+
details<T extends readonly PersonAppendToResponseNamespace[] = []>(params: PersonDetailsParams & {
|
|
17
|
+
append_to_response?: T[number] | T;
|
|
18
|
+
}): Promise<T extends [] ? PersonDetails : PersonDetailsWithAppends<T>>;
|
|
19
|
+
/**
|
|
20
|
+
* Changes
|
|
21
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/changes
|
|
22
|
+
*
|
|
23
|
+
* Get the change history for a person.
|
|
24
|
+
* @reference https://developer.themoviedb.org/reference/person-changes
|
|
25
|
+
*/
|
|
26
|
+
changes(params: PersonChangesParams): Promise<PersonChanges>;
|
|
27
|
+
/**
|
|
28
|
+
* Combined Credits
|
|
29
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/combined_credits
|
|
30
|
+
*
|
|
31
|
+
* Get movie and TV credits in a single response.
|
|
32
|
+
* @reference https://developer.themoviedb.org/reference/person-combined-credits
|
|
33
|
+
*/
|
|
34
|
+
combined_credits(params: PersonCreditsParams): Promise<PersonCombinedCredits>;
|
|
35
|
+
/**
|
|
36
|
+
* External IDs
|
|
37
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/external_ids
|
|
38
|
+
*
|
|
39
|
+
* Get external platform identifiers for a person.
|
|
40
|
+
* @reference https://developer.themoviedb.org/reference/person-external-ids
|
|
41
|
+
*/
|
|
42
|
+
external_ids(params: PersonExternalIDsParams): Promise<PersonExternalIDs>;
|
|
43
|
+
/**
|
|
44
|
+
* Images
|
|
45
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/images
|
|
46
|
+
*
|
|
47
|
+
* Get profile images for a person.
|
|
48
|
+
* @reference https://developer.themoviedb.org/reference/person-images
|
|
49
|
+
*/
|
|
50
|
+
images(params: PersonImagesParams): Promise<PersonImages>;
|
|
51
|
+
/**
|
|
52
|
+
* Latest
|
|
53
|
+
* GET - https://api.themoviedb.org/3/person/latest
|
|
54
|
+
*
|
|
55
|
+
* Get the newest person id added to TMDB.
|
|
56
|
+
* @reference https://developer.themoviedb.org/reference/person-latest-id
|
|
57
|
+
*/
|
|
58
|
+
latest(): Promise<PersonDetails>;
|
|
59
|
+
/**
|
|
60
|
+
* Movie Credits
|
|
61
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/movie_credits
|
|
62
|
+
*
|
|
63
|
+
* Get a person's movie cast and crew credits.
|
|
64
|
+
* @reference https://developer.themoviedb.org/reference/person-movie-credits
|
|
65
|
+
*/
|
|
66
|
+
movie_credits(params: PersonCreditsParams): Promise<PersonMovieCredits>;
|
|
67
|
+
/**
|
|
68
|
+
* Tagged Images
|
|
69
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/tagged_images
|
|
70
|
+
*
|
|
71
|
+
* Get images where the person has been tagged.
|
|
72
|
+
* @reference https://developer.themoviedb.org/reference/person-tagged-images
|
|
73
|
+
*/
|
|
74
|
+
tagged_images(params: PersonTaggedImagesParams): Promise<PersonTaggedImages>;
|
|
75
|
+
/**
|
|
76
|
+
* Translations
|
|
77
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/translations
|
|
78
|
+
*
|
|
79
|
+
* Get the translations available for a person biography and name.
|
|
80
|
+
* @reference https://developer.themoviedb.org/reference/person-translations
|
|
81
|
+
*/
|
|
82
|
+
translations(params: PersonTranslationsParams): Promise<PersonTranslations>;
|
|
83
|
+
/**
|
|
84
|
+
* TV Credits
|
|
85
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/tv_credits
|
|
86
|
+
*
|
|
87
|
+
* Get a person's TV cast and crew credits.
|
|
88
|
+
* @reference https://developer.themoviedb.org/reference/person-tv-credits
|
|
89
|
+
*/
|
|
90
|
+
tv_credits(params: PersonCreditsParams): Promise<PersonTVCredits>;
|
|
91
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../routes";
|
|
2
|
+
import { TMDBAPIBase } from "./base";
|
|
3
|
+
export class PeopleAPI extends TMDBAPIBase {
|
|
4
|
+
personPath(person_id) {
|
|
5
|
+
return `${ENDPOINTS.PEOPLE.DETAILS}/${person_id}`;
|
|
6
|
+
}
|
|
7
|
+
personSubPath(person_id, route) {
|
|
8
|
+
return `${this.personPath(person_id)}${route}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Details
|
|
12
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}
|
|
13
|
+
*
|
|
14
|
+
* Get the primary person details by TMDB person id.
|
|
15
|
+
* @param person_id The TMDB person id.
|
|
16
|
+
* @param append_to_response Additional person subresources to append.
|
|
17
|
+
* @param language Language for localized results.
|
|
18
|
+
* @reference https://developer.themoviedb.org/reference/person-details
|
|
19
|
+
*/
|
|
20
|
+
async details(params) {
|
|
21
|
+
const { language = this.defaultOptions.language, person_id, ...rest } = params;
|
|
22
|
+
return this.client.request(this.personPath(person_id), { language, ...rest });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Changes
|
|
26
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/changes
|
|
27
|
+
*
|
|
28
|
+
* Get the change history for a person.
|
|
29
|
+
* @reference https://developer.themoviedb.org/reference/person-changes
|
|
30
|
+
*/
|
|
31
|
+
async changes(params) {
|
|
32
|
+
const { person_id, ...rest } = params;
|
|
33
|
+
return this.client.request(this.personSubPath(person_id, ENDPOINTS.PEOPLE.CHANGES), rest);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Combined Credits
|
|
37
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/combined_credits
|
|
38
|
+
*
|
|
39
|
+
* Get movie and TV credits in a single response.
|
|
40
|
+
* @reference https://developer.themoviedb.org/reference/person-combined-credits
|
|
41
|
+
*/
|
|
42
|
+
async combined_credits(params) {
|
|
43
|
+
const { language = this.defaultOptions.language, person_id, ...rest } = params;
|
|
44
|
+
return this.client.request(this.personSubPath(person_id, ENDPOINTS.PEOPLE.COMBINED_CREDITS), {
|
|
45
|
+
language,
|
|
46
|
+
...rest,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* External IDs
|
|
51
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/external_ids
|
|
52
|
+
*
|
|
53
|
+
* Get external platform identifiers for a person.
|
|
54
|
+
* @reference https://developer.themoviedb.org/reference/person-external-ids
|
|
55
|
+
*/
|
|
56
|
+
async external_ids(params) {
|
|
57
|
+
return this.client.request(this.personSubPath(params.person_id, ENDPOINTS.PEOPLE.EXTERNAL_IDS));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Images
|
|
61
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/images
|
|
62
|
+
*
|
|
63
|
+
* Get profile images for a person.
|
|
64
|
+
* @reference https://developer.themoviedb.org/reference/person-images
|
|
65
|
+
*/
|
|
66
|
+
async images(params) {
|
|
67
|
+
return this.client.request(this.personSubPath(params.person_id, ENDPOINTS.PEOPLE.IMAGES));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Latest
|
|
71
|
+
* GET - https://api.themoviedb.org/3/person/latest
|
|
72
|
+
*
|
|
73
|
+
* Get the newest person id added to TMDB.
|
|
74
|
+
* @reference https://developer.themoviedb.org/reference/person-latest-id
|
|
75
|
+
*/
|
|
76
|
+
async latest() {
|
|
77
|
+
return this.client.request(`${ENDPOINTS.PEOPLE.DETAILS}${ENDPOINTS.PEOPLE.LATEST}`);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Movie Credits
|
|
81
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/movie_credits
|
|
82
|
+
*
|
|
83
|
+
* Get a person's movie cast and crew credits.
|
|
84
|
+
* @reference https://developer.themoviedb.org/reference/person-movie-credits
|
|
85
|
+
*/
|
|
86
|
+
async movie_credits(params) {
|
|
87
|
+
const { language = this.defaultOptions.language, person_id, ...rest } = params;
|
|
88
|
+
return this.client.request(this.personSubPath(person_id, ENDPOINTS.PEOPLE.MOVIE_CREDITS), {
|
|
89
|
+
language,
|
|
90
|
+
...rest,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Tagged Images
|
|
95
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/tagged_images
|
|
96
|
+
*
|
|
97
|
+
* Get images where the person has been tagged.
|
|
98
|
+
* @reference https://developer.themoviedb.org/reference/person-tagged-images
|
|
99
|
+
*/
|
|
100
|
+
async tagged_images(params) {
|
|
101
|
+
const { person_id, ...rest } = params;
|
|
102
|
+
return this.client.request(this.personSubPath(person_id, ENDPOINTS.PEOPLE.TAGGED_IMAGES), rest);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Translations
|
|
106
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/translations
|
|
107
|
+
*
|
|
108
|
+
* Get the translations available for a person biography and name.
|
|
109
|
+
* @reference https://developer.themoviedb.org/reference/person-translations
|
|
110
|
+
*/
|
|
111
|
+
async translations(params) {
|
|
112
|
+
return this.client.request(this.personSubPath(params.person_id, ENDPOINTS.PEOPLE.TRANSLATIONS));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* TV Credits
|
|
116
|
+
* GET - https://api.themoviedb.org/3/person/{person_id}/tv_credits
|
|
117
|
+
*
|
|
118
|
+
* Get a person's TV cast and crew credits.
|
|
119
|
+
* @reference https://developer.themoviedb.org/reference/person-tv-credits
|
|
120
|
+
*/
|
|
121
|
+
async tv_credits(params) {
|
|
122
|
+
const { language = this.defaultOptions.language, person_id, ...rest } = params;
|
|
123
|
+
return this.client.request(this.personSubPath(person_id, ENDPOINTS.PEOPLE.TV_CREDITS), {
|
|
124
|
+
language,
|
|
125
|
+
...rest,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PaginatedResponse } from "../types";
|
|
2
|
+
import type { PersonResultItem } from "../types/search";
|
|
3
|
+
import type { PeopleListParams } from "../types/people-lists";
|
|
4
|
+
import { TMDBAPIBase } from "./base";
|
|
5
|
+
export declare class PeopleListsAPI extends TMDBAPIBase {
|
|
6
|
+
/**
|
|
7
|
+
* Popular
|
|
8
|
+
* GET - https://api.themoviedb.org/3/person/popular
|
|
9
|
+
*
|
|
10
|
+
* Get a list of people ordered by popularity.
|
|
11
|
+
* @param language Language for localised results (Defaults to en-US or TMDB default)
|
|
12
|
+
* @param page Page number (Defaults to 1)
|
|
13
|
+
* @reference https://developer.themoviedb.org/reference/person-popular-list
|
|
14
|
+
*/
|
|
15
|
+
popular(params?: PeopleListParams): Promise<PaginatedResponse<PersonResultItem>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../routes";
|
|
2
|
+
import { TMDBAPIBase } from "./base";
|
|
3
|
+
export class PeopleListsAPI extends TMDBAPIBase {
|
|
4
|
+
/**
|
|
5
|
+
* Popular
|
|
6
|
+
* GET - https://api.themoviedb.org/3/person/popular
|
|
7
|
+
*
|
|
8
|
+
* Get a list of people ordered by popularity.
|
|
9
|
+
* @param language Language for localised results (Defaults to en-US or TMDB default)
|
|
10
|
+
* @param page Page number (Defaults to 1)
|
|
11
|
+
* @reference https://developer.themoviedb.org/reference/person-popular-list
|
|
12
|
+
*/
|
|
13
|
+
async popular(params = {}) {
|
|
14
|
+
return this.client.request(ENDPOINTS.PEOPLE_LISTS.POPULAR, this.withLanguage(params) ?? params);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReviewDetails, ReviewDetailsParams } from "../types/reviews";
|
|
2
|
+
import { TMDBAPIBase } from "./base";
|
|
3
|
+
export declare class ReviewsAPI extends TMDBAPIBase {
|
|
4
|
+
/**
|
|
5
|
+
* Details
|
|
6
|
+
* GET - https://api.themoviedb.org/3/review/{review_id}
|
|
7
|
+
*
|
|
8
|
+
* Retrieve the details of a single review by its TMDB review ID.
|
|
9
|
+
* @param review_id The TMDB review identifier.
|
|
10
|
+
* @returns A promise that resolves to the full review details.
|
|
11
|
+
* @reference https://developer.themoviedb.org/reference/review-details
|
|
12
|
+
*/
|
|
13
|
+
details(params: ReviewDetailsParams): Promise<ReviewDetails>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ENDPOINTS } from "../routes";
|
|
2
|
+
import { TMDBAPIBase } from "./base";
|
|
3
|
+
export class ReviewsAPI extends TMDBAPIBase {
|
|
4
|
+
/**
|
|
5
|
+
* Details
|
|
6
|
+
* GET - https://api.themoviedb.org/3/review/{review_id}
|
|
7
|
+
*
|
|
8
|
+
* Retrieve the details of a single review by its TMDB review ID.
|
|
9
|
+
* @param review_id The TMDB review identifier.
|
|
10
|
+
* @returns A promise that resolves to the full review details.
|
|
11
|
+
* @reference https://developer.themoviedb.org/reference/review-details
|
|
12
|
+
*/
|
|
13
|
+
async details(params) {
|
|
14
|
+
return this.client.request(`${ENDPOINTS.REVIEWS.DETAILS}/${params.review_id}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -19,8 +19,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
19
19
|
* @reference https://developer.themoviedb.org/reference/tv-series-details
|
|
20
20
|
*/
|
|
21
21
|
async details(params) {
|
|
22
|
-
const { language = this.defaultOptions.language, ...rest } = params;
|
|
23
|
-
const endpoint = this.seriesPath(
|
|
22
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
23
|
+
const endpoint = this.seriesPath(series_id);
|
|
24
24
|
return this.client.request(endpoint, { language, ...rest });
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -37,8 +37,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
37
37
|
* @reference https://developer.themoviedb.org/reference/tv-series-aggregate-credits
|
|
38
38
|
*/
|
|
39
39
|
async aggregate_credits(params) {
|
|
40
|
-
const { language = this.defaultOptions.language, ...rest } = params;
|
|
41
|
-
const endpoint = this.seriesSubPath(
|
|
40
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
41
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.AGGREGATE_CREDITS);
|
|
42
42
|
return this.client.request(endpoint, { language, ...rest });
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -72,8 +72,9 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
72
72
|
* @reference https://developer.themoviedb.org/reference/tv-series-changes
|
|
73
73
|
*/
|
|
74
74
|
async changes(params) {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const { series_id, ...rest } = params;
|
|
76
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.CHANGES);
|
|
77
|
+
return this.client.request(endpoint, { ...rest });
|
|
77
78
|
}
|
|
78
79
|
/**
|
|
79
80
|
* Content Ratings
|
|
@@ -103,8 +104,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
103
104
|
* @reference https://developer.themoviedb.org/reference/tv-series-credits
|
|
104
105
|
*/
|
|
105
106
|
async credits(params) {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
107
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
108
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.CREDITS);
|
|
108
109
|
return this.client.request(endpoint, { language, ...rest });
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
@@ -150,8 +151,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
150
151
|
* @reference https://developer.themoviedb.org/reference/tv-series-images
|
|
151
152
|
*/
|
|
152
153
|
async images(params) {
|
|
153
|
-
const { language = this.defaultOptions.language, ...rest } = params;
|
|
154
|
-
const endpoint = this.seriesSubPath(
|
|
154
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
155
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.IMAGES);
|
|
155
156
|
return this.client.request(endpoint, { language, ...rest });
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
@@ -192,8 +193,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
192
193
|
* @reference https://developer.themoviedb.org/reference/lists-copy (TODO: Check this url for updates, it's like this on TMDB docs (??))
|
|
193
194
|
*/
|
|
194
195
|
async lists(params) {
|
|
195
|
-
const
|
|
196
|
-
const
|
|
196
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
197
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.LISTS);
|
|
197
198
|
return this.client.request(endpoint, { language, ...rest });
|
|
198
199
|
}
|
|
199
200
|
/**
|
|
@@ -208,8 +209,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
208
209
|
* @reference https://developer.themoviedb.org/reference/tv-series-recommendations
|
|
209
210
|
*/
|
|
210
211
|
async recommendations(params) {
|
|
211
|
-
const
|
|
212
|
-
const
|
|
212
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
213
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.RECOMMENDATIONS);
|
|
213
214
|
return this.client.request(endpoint, { language, ...rest });
|
|
214
215
|
}
|
|
215
216
|
/**
|
|
@@ -224,8 +225,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
224
225
|
* @reference https://developer.themoviedb.org/reference/tv-series-recommendations
|
|
225
226
|
*/
|
|
226
227
|
async reviews(params) {
|
|
227
|
-
const
|
|
228
|
-
const
|
|
228
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
229
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.REVIEWS);
|
|
229
230
|
return this.client.request(endpoint, { language, ...rest });
|
|
230
231
|
}
|
|
231
232
|
/**
|
|
@@ -253,8 +254,8 @@ export class TVSeriesAPI extends TMDBAPIBase {
|
|
|
253
254
|
* @reference https://developer.themoviedb.org/reference/tv-series-similar
|
|
254
255
|
*/
|
|
255
256
|
async similar(params) {
|
|
256
|
-
const
|
|
257
|
-
const
|
|
257
|
+
const { language = this.defaultOptions.language, series_id, ...rest } = params;
|
|
258
|
+
const endpoint = this.seriesSubPath(series_id, ENDPOINTS.TV_SERIES.SIMILAR);
|
|
258
259
|
return this.client.request(endpoint, { language, ...rest });
|
|
259
260
|
}
|
|
260
261
|
/**
|
package/dist/routes.d.ts
CHANGED
|
@@ -68,6 +68,18 @@ export declare const ENDPOINTS: {
|
|
|
68
68
|
ALTERNATIVE_NAMES: string;
|
|
69
69
|
IMAGES: string;
|
|
70
70
|
};
|
|
71
|
+
PEOPLE: {
|
|
72
|
+
DETAILS: string;
|
|
73
|
+
CHANGES: string;
|
|
74
|
+
COMBINED_CREDITS: string;
|
|
75
|
+
EXTERNAL_IDS: string;
|
|
76
|
+
IMAGES: string;
|
|
77
|
+
LATEST: string;
|
|
78
|
+
MOVIE_CREDITS: string;
|
|
79
|
+
TAGGED_IMAGES: string;
|
|
80
|
+
TRANSLATIONS: string;
|
|
81
|
+
TV_CREDITS: string;
|
|
82
|
+
};
|
|
71
83
|
SEARCH: {
|
|
72
84
|
MOVIE: string;
|
|
73
85
|
COLLECTION: string;
|
|
@@ -136,4 +148,10 @@ export declare const ENDPOINTS: {
|
|
|
136
148
|
TV: string;
|
|
137
149
|
PERSON: string;
|
|
138
150
|
};
|
|
151
|
+
REVIEWS: {
|
|
152
|
+
DETAILS: string;
|
|
153
|
+
};
|
|
154
|
+
PEOPLE_LISTS: {
|
|
155
|
+
POPULAR: string;
|
|
156
|
+
};
|
|
139
157
|
};
|
package/dist/routes.js
CHANGED
|
@@ -68,6 +68,18 @@ export const ENDPOINTS = {
|
|
|
68
68
|
ALTERNATIVE_NAMES: "/alternative_names",
|
|
69
69
|
IMAGES: "/images",
|
|
70
70
|
},
|
|
71
|
+
PEOPLE: {
|
|
72
|
+
DETAILS: "/person",
|
|
73
|
+
CHANGES: "/changes",
|
|
74
|
+
COMBINED_CREDITS: "/combined_credits",
|
|
75
|
+
EXTERNAL_IDS: "/external_ids",
|
|
76
|
+
IMAGES: "/images",
|
|
77
|
+
LATEST: "/latest",
|
|
78
|
+
MOVIE_CREDITS: "/movie_credits",
|
|
79
|
+
TAGGED_IMAGES: "/tagged_images",
|
|
80
|
+
TRANSLATIONS: "/translations",
|
|
81
|
+
TV_CREDITS: "/tv_credits",
|
|
82
|
+
},
|
|
71
83
|
SEARCH: {
|
|
72
84
|
MOVIE: "/search/movie",
|
|
73
85
|
COLLECTION: "/search/collection",
|
|
@@ -136,4 +148,10 @@ export const ENDPOINTS = {
|
|
|
136
148
|
TV: "/trending/tv",
|
|
137
149
|
PERSON: "/trending/person",
|
|
138
150
|
},
|
|
151
|
+
REVIEWS: {
|
|
152
|
+
DETAILS: "/review",
|
|
153
|
+
},
|
|
154
|
+
PEOPLE_LISTS: {
|
|
155
|
+
POPULAR: "/person/popular",
|
|
156
|
+
},
|
|
139
157
|
};
|
package/dist/tmdb.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ import { TVEpisodesAPI } from "./endpoints/tv_episodes";
|
|
|
21
21
|
import { TVEpisodeGroupsAPI } from "./endpoints/tv_episode_groups";
|
|
22
22
|
import { TVSeasonsAPI } from "./endpoints/tv_seasons";
|
|
23
23
|
import { TrendingAPI } from "./endpoints/trending";
|
|
24
|
+
import { ReviewsAPI } from "./endpoints/reviews";
|
|
25
|
+
import { PeopleListsAPI } from "./endpoints/people_lists";
|
|
26
|
+
import { PeopleAPI } from "./endpoints/people";
|
|
24
27
|
export declare class TMDB {
|
|
25
28
|
private client;
|
|
26
29
|
private options;
|
|
@@ -46,6 +49,9 @@ export declare class TMDB {
|
|
|
46
49
|
tv_episode_groups: TVEpisodeGroupsAPI;
|
|
47
50
|
tv_seasons: TVSeasonsAPI;
|
|
48
51
|
trending: TrendingAPI;
|
|
52
|
+
reviews: ReviewsAPI;
|
|
53
|
+
people_lists: PeopleListsAPI;
|
|
54
|
+
people: PeopleAPI;
|
|
49
55
|
/**
|
|
50
56
|
* Creates a new TMDB instance.
|
|
51
57
|
* @param accessToken The TMDB API access token.
|
package/dist/tmdb.js
CHANGED
|
@@ -23,6 +23,9 @@ import { TVEpisodesAPI } from "./endpoints/tv_episodes";
|
|
|
23
23
|
import { TVEpisodeGroupsAPI } from "./endpoints/tv_episode_groups";
|
|
24
24
|
import { TVSeasonsAPI } from "./endpoints/tv_seasons";
|
|
25
25
|
import { TrendingAPI } from "./endpoints/trending";
|
|
26
|
+
import { ReviewsAPI } from "./endpoints/reviews";
|
|
27
|
+
import { PeopleListsAPI } from "./endpoints/people_lists";
|
|
28
|
+
import { PeopleAPI } from "./endpoints/people";
|
|
26
29
|
export class TMDB {
|
|
27
30
|
client;
|
|
28
31
|
options; // ** Default options for all requests
|
|
@@ -48,6 +51,9 @@ export class TMDB {
|
|
|
48
51
|
tv_episode_groups;
|
|
49
52
|
tv_seasons;
|
|
50
53
|
trending;
|
|
54
|
+
reviews;
|
|
55
|
+
people_lists;
|
|
56
|
+
people;
|
|
51
57
|
// etc...
|
|
52
58
|
/**
|
|
53
59
|
* Creates a new TMDB instance.
|
|
@@ -81,5 +87,8 @@ export class TMDB {
|
|
|
81
87
|
this.tv_episode_groups = new TVEpisodeGroupsAPI(this.client, this.options);
|
|
82
88
|
this.tv_seasons = new TVSeasonsAPI(this.client, this.options);
|
|
83
89
|
this.trending = new TrendingAPI(this.client, this.options);
|
|
90
|
+
this.reviews = new ReviewsAPI(this.client, this.options);
|
|
91
|
+
this.people_lists = new PeopleListsAPI(this.client, this.options);
|
|
92
|
+
this.people = new PeopleAPI(this.client, this.options);
|
|
84
93
|
}
|
|
85
94
|
}
|
|
@@ -67,5 +67,6 @@ export type CollectionBaseParam = {
|
|
|
67
67
|
export type CollectionDetailsParams = CollectionBaseParam & WithLanguage;
|
|
68
68
|
export type CollectionImagesParams = CollectionBaseParam & {
|
|
69
69
|
language?: Language | LanguageISO6391;
|
|
70
|
-
|
|
70
|
+
/** Languages to include images for. Pass an array — it will be serialized as a comma-separated list (e.g. ["en", "null"]). Use "null" to include untagged images. */
|
|
71
|
+
include_image_language?: (Language | "null")[];
|
|
71
72
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AlternativeName, AlternativeNamesResult, WithLanguage } from "./common";
|
|
2
2
|
import { ImagesResult, OrganizationImage } from "./common/images";
|
|
3
3
|
import { CountryISO3166_1 } from "./config/countries";
|
|
4
|
-
import { Language
|
|
4
|
+
import { Language } from "./config";
|
|
5
5
|
/**
|
|
6
6
|
* Minimal company data reused across company-related responses.
|
|
7
7
|
*/
|
|
@@ -48,5 +48,6 @@ export type CompanyBaseParam = {
|
|
|
48
48
|
export type CompanyDetailsParams = CompanyBaseParam;
|
|
49
49
|
export type CompanyAlternativeNamesParams = CompanyBaseParam;
|
|
50
50
|
export type CompanyImagesParams = CompanyBaseParam & {
|
|
51
|
-
|
|
51
|
+
/** Languages to include images for. Pass an array — it will be serialized as a comma-separated list (e.g. ["en", "null"]). Use "null" to include untagged images. */
|
|
52
|
+
include_image_language?: (Language | "null")[];
|
|
52
53
|
} & WithLanguage;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/movies.d.ts
CHANGED
|
@@ -282,8 +282,8 @@ export type MovieChangesParams = Prettify<MovieBaseParam & WithParams<"page"> &
|
|
|
282
282
|
export type MovieImagesParams = Prettify<MovieBaseParam & {
|
|
283
283
|
/** Language for image metadata (supports both ISO-639-1 and full Language format) */
|
|
284
284
|
language?: Language | LanguageISO6391;
|
|
285
|
-
/**
|
|
286
|
-
include_image_language?: Language |
|
|
285
|
+
/** Languages to include images for. Pass an array — it will be serialized as a comma-separated list (e.g. ["en", "null"]). Use "null" to include untagged images. */
|
|
286
|
+
include_image_language?: (Language | "null")[];
|
|
287
287
|
}>;
|
|
288
288
|
/**
|
|
289
289
|
* Parameters for fetching movie recommendations.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { Changes, DateRange, ImageItem, ImagesResult, MediaType, PaginatedResponse, TranslationResults, WithLanguage, WithPage } from "./common";
|
|
2
|
+
import { MovieResultItem, TVSeriesResultItem } from "./search";
|
|
3
|
+
import { Prettify } from "./utility";
|
|
4
|
+
/**
|
|
5
|
+
* Top-level person details returned by TMDB.
|
|
6
|
+
*/
|
|
7
|
+
export type PersonDetails = {
|
|
8
|
+
/** Whether the person is marked as adult content */
|
|
9
|
+
adult: boolean;
|
|
10
|
+
/** Alternative names or aliases */
|
|
11
|
+
also_known_as: string[];
|
|
12
|
+
/** Localized or default biography text */
|
|
13
|
+
biography?: string;
|
|
14
|
+
/** Date of birth in ISO 8601 format */
|
|
15
|
+
birthday?: string;
|
|
16
|
+
/** Date of death in ISO 8601 format, if applicable */
|
|
17
|
+
deathday?: string;
|
|
18
|
+
/** Gender code reported by TMDB */
|
|
19
|
+
gender: number;
|
|
20
|
+
/** Official homepage URL, if available */
|
|
21
|
+
homepage?: string;
|
|
22
|
+
/** TMDB person identifier */
|
|
23
|
+
id: number;
|
|
24
|
+
/** IMDb identifier, if linked */
|
|
25
|
+
imdb_id?: string;
|
|
26
|
+
/** Primary department the person is known for */
|
|
27
|
+
known_for_department?: string;
|
|
28
|
+
/** Display name */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Place of birth, if known */
|
|
31
|
+
place_of_birth?: string;
|
|
32
|
+
/** Popularity score */
|
|
33
|
+
popularity: number;
|
|
34
|
+
/** Relative path to the profile image */
|
|
35
|
+
profile_path?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Endpoints that can be appended to a person details request.
|
|
39
|
+
*/
|
|
40
|
+
export type PersonAppendToResponseNamespace = "changes" | "combined_credits" | "external_ids" | "images" | "movie_credits" | "tagged_images" | "translations" | "tv_credits";
|
|
41
|
+
/**
|
|
42
|
+
* Person details with appended subresources.
|
|
43
|
+
*/
|
|
44
|
+
export type PersonDetailsWithAppends<T extends readonly PersonAppendToResponseNamespace[]> = PersonDetails & {
|
|
45
|
+
[K in T[number]]: PersonAppendableMap[K];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Changes made to a person resource.
|
|
49
|
+
*/
|
|
50
|
+
export type PersonChanges = Changes;
|
|
51
|
+
/**
|
|
52
|
+
* External identifiers linked to a person.
|
|
53
|
+
*/
|
|
54
|
+
export type PersonExternalIDs = {
|
|
55
|
+
id: number;
|
|
56
|
+
freebase_mid?: string;
|
|
57
|
+
freebase_id?: string;
|
|
58
|
+
imdb_id?: string;
|
|
59
|
+
tvrage_id?: number;
|
|
60
|
+
wikidata_id?: string;
|
|
61
|
+
facebook_id?: string;
|
|
62
|
+
instagram_id?: string;
|
|
63
|
+
tiktok_id?: string;
|
|
64
|
+
twitter_id?: string;
|
|
65
|
+
youtube_id?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Profile images belonging to a person.
|
|
69
|
+
*/
|
|
70
|
+
export type PersonImages = ImagesResult<ImageItem, "profiles">;
|
|
71
|
+
/**
|
|
72
|
+
* Cast credit for a movie on a person profile.
|
|
73
|
+
*/
|
|
74
|
+
export type PersonMovieCastCredit = MovieResultItem & {
|
|
75
|
+
character: string;
|
|
76
|
+
credit_id: string;
|
|
77
|
+
order: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Crew credit for a movie on a person profile.
|
|
81
|
+
*/
|
|
82
|
+
export type PersonMovieCrewCredit = MovieResultItem & {
|
|
83
|
+
credit_id: string;
|
|
84
|
+
department: string;
|
|
85
|
+
job: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Movie credits for a person.
|
|
89
|
+
*/
|
|
90
|
+
export type PersonMovieCredits = {
|
|
91
|
+
id: number;
|
|
92
|
+
cast: PersonMovieCastCredit[];
|
|
93
|
+
crew: PersonMovieCrewCredit[];
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Cast credit for a TV show on a person profile.
|
|
97
|
+
*/
|
|
98
|
+
export type PersonTVCastCredit = TVSeriesResultItem & {
|
|
99
|
+
character: string;
|
|
100
|
+
credit_id: string;
|
|
101
|
+
episode_count: number;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Crew credit for a TV show on a person profile.
|
|
105
|
+
*/
|
|
106
|
+
export type PersonTVCrewCredit = TVSeriesResultItem & {
|
|
107
|
+
credit_id: string;
|
|
108
|
+
department: string;
|
|
109
|
+
episode_count: number;
|
|
110
|
+
job: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* TV credits for a person.
|
|
114
|
+
*/
|
|
115
|
+
export type PersonTVCredits = {
|
|
116
|
+
id: number;
|
|
117
|
+
cast: PersonTVCastCredit[];
|
|
118
|
+
crew: PersonTVCrewCredit[];
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Combined movie/TV cast credit for a person.
|
|
122
|
+
*/
|
|
123
|
+
export type PersonCombinedCastCredit = (PersonMovieCastCredit & {
|
|
124
|
+
media_type: "movie";
|
|
125
|
+
}) | (PersonTVCastCredit & {
|
|
126
|
+
media_type: "tv";
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Combined movie/TV crew credit for a person.
|
|
130
|
+
*/
|
|
131
|
+
export type PersonCombinedCrewCredit = (PersonMovieCrewCredit & {
|
|
132
|
+
media_type: "movie";
|
|
133
|
+
}) | (PersonTVCrewCredit & {
|
|
134
|
+
media_type: "tv";
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Combined credits for a person.
|
|
138
|
+
*/
|
|
139
|
+
export type PersonCombinedCredits = {
|
|
140
|
+
id: number;
|
|
141
|
+
cast: PersonCombinedCastCredit[];
|
|
142
|
+
crew: PersonCombinedCrewCredit[];
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Tagged image media payload associated with a person image tag.
|
|
146
|
+
*/
|
|
147
|
+
export type PersonTaggedImageMedia = (MovieResultItem & {
|
|
148
|
+
media_type: "movie";
|
|
149
|
+
}) | (TVSeriesResultItem & {
|
|
150
|
+
media_type: "tv";
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* A single tagged image entry for a person.
|
|
154
|
+
*/
|
|
155
|
+
export type PersonTaggedImage = ImageItem & {
|
|
156
|
+
id: string;
|
|
157
|
+
image_type: string;
|
|
158
|
+
media: PersonTaggedImageMedia;
|
|
159
|
+
media_type: MediaType;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Paginated tagged images for a person.
|
|
163
|
+
*/
|
|
164
|
+
export type PersonTaggedImages = PaginatedResponse<PersonTaggedImage> & {
|
|
165
|
+
id: number;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Translation payload for person records.
|
|
169
|
+
*/
|
|
170
|
+
export type PersonTranslationData = {
|
|
171
|
+
biography?: string;
|
|
172
|
+
name?: string;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Available translations for a person.
|
|
176
|
+
*/
|
|
177
|
+
export type PersonTranslations = TranslationResults<PersonTranslationData>;
|
|
178
|
+
/**
|
|
179
|
+
* Mapping of person append keys to their response types.
|
|
180
|
+
*/
|
|
181
|
+
export type PersonAppendableMap = {
|
|
182
|
+
changes: PersonChanges;
|
|
183
|
+
combined_credits: PersonCombinedCredits;
|
|
184
|
+
external_ids: PersonExternalIDs;
|
|
185
|
+
images: PersonImages;
|
|
186
|
+
movie_credits: PersonMovieCredits;
|
|
187
|
+
tagged_images: PersonTaggedImages;
|
|
188
|
+
translations: PersonTranslations;
|
|
189
|
+
tv_credits: PersonTVCredits;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Base param for person-specific endpoints.
|
|
193
|
+
*/
|
|
194
|
+
export type PersonBaseParam = {
|
|
195
|
+
person_id: number;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Parameters for fetching person details.
|
|
199
|
+
*/
|
|
200
|
+
export type PersonDetailsParams = Prettify<PersonBaseParam & {
|
|
201
|
+
append_to_response?: PersonAppendToResponseNamespace | PersonAppendToResponseNamespace[];
|
|
202
|
+
} & WithLanguage>;
|
|
203
|
+
/**
|
|
204
|
+
* Parameters for fetching person changes.
|
|
205
|
+
*/
|
|
206
|
+
export type PersonChangesParams = Prettify<PersonBaseParam & WithPage & DateRange>;
|
|
207
|
+
/**
|
|
208
|
+
* Parameters for language-aware person credit endpoints.
|
|
209
|
+
*/
|
|
210
|
+
export type PersonCreditsParams = Prettify<PersonBaseParam & WithLanguage>;
|
|
211
|
+
export type PersonExternalIDsParams = PersonBaseParam;
|
|
212
|
+
export type PersonImagesParams = PersonBaseParam;
|
|
213
|
+
export type PersonTranslationsParams = PersonBaseParam;
|
|
214
|
+
export type PersonTaggedImagesParams = Prettify<PersonBaseParam & WithPage>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Review } from "./common/media";
|
|
2
|
+
/**
|
|
3
|
+
* Full details for a single TMDB review, as returned by GET /review/{review_id}.
|
|
4
|
+
* Extends the base Review type with media context fields.
|
|
5
|
+
*/
|
|
6
|
+
export type ReviewDetails = Review & {
|
|
7
|
+
/** ISO 639-1 language code of the review content */
|
|
8
|
+
iso_639_1: string;
|
|
9
|
+
/** The TMDB ID of the reviewed media */
|
|
10
|
+
media_id: number;
|
|
11
|
+
/** The title of the reviewed media */
|
|
12
|
+
media_title: string;
|
|
13
|
+
/** The type of media being reviewed */
|
|
14
|
+
media_type: "movie" | "tv";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Parameters for fetching a review by its TMDB review ID.
|
|
18
|
+
*/
|
|
19
|
+
export type ReviewDetailsParams = {
|
|
20
|
+
/** The TMDB review identifier */
|
|
21
|
+
review_id: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -93,5 +93,6 @@ export type TVEpisodeDetailsParams = Prettify<TVEpisodeBaseParams & {
|
|
|
93
93
|
/** Parameters for tv episode credits endpoint */
|
|
94
94
|
export type TVEpisodeCreditsParams = TVEpisodeBaseParams & WithLanguage;
|
|
95
95
|
export type TVEpisodeImagesParams = TVEpisodeBaseParams & WithLanguage & {
|
|
96
|
-
|
|
96
|
+
/** Languages to include images for. Pass an array — it will be serialized as a comma-separated list (e.g. ["en", "null"]). Use "null" to include untagged images. */
|
|
97
|
+
include_image_language?: (Language | "null")[];
|
|
97
98
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Cast, Crew, DateRange, ImageItem, ImagesResult, TranslationResults, VideoResults, WithLanguage, WithParams } from "./common";
|
|
2
|
+
import { Language } from "./config";
|
|
2
3
|
import { TVAggregateCredits, TVBaseParam, TVEpisodeItem, TVExternalIDs } from "./tv-series";
|
|
3
4
|
import { MediaWatchProviders } from "./common/media";
|
|
4
5
|
import { NetworkItem } from "./networks";
|
|
@@ -119,7 +120,8 @@ export type TVSeasonAggregateCreditsParams = TVSeasonBaseParams & WithLanguage;
|
|
|
119
120
|
export type TVSeasonCreditsParams = TVSeasonBaseParams & WithLanguage;
|
|
120
121
|
/** Parameters for the season images endpoint, with optional language filtering. */
|
|
121
122
|
export type TVSeasonImagesParams = TVSeasonBaseParams & WithLanguage & {
|
|
122
|
-
|
|
123
|
+
/** Languages to include images for. Pass an array — it will be serialized as a comma-separated list (e.g. ["en", "null"]). Use "null" to include untagged images. */
|
|
124
|
+
include_image_language?: (Language | "null")[];
|
|
123
125
|
};
|
|
124
126
|
/** Parameters for the season videos endpoint, with optional language filtering. */
|
|
125
127
|
export type TVSeasonVideosParams = TVSeasonBaseParams & WithLanguage & {
|
|
@@ -424,8 +424,8 @@ export type TVCreditsParams = Prettify<TVBaseParam & WithLanguage>;
|
|
|
424
424
|
export type TVImagesParams = Prettify<TVBaseParam & {
|
|
425
425
|
/** Language for image metadata (supports both ISO-639-1 and full Language format) */
|
|
426
426
|
language?: Language | LanguageISO6391;
|
|
427
|
-
/**
|
|
428
|
-
include_image_language?: Language |
|
|
427
|
+
/** Languages to include images for. Pass an array — it will be serialized as a comma-separated list (e.g. ["en", "null"]). Use "null" to include untagged images. */
|
|
428
|
+
include_image_language?: (Language | "null")[];
|
|
429
429
|
}>;
|
|
430
430
|
/**
|
|
431
431
|
* Parameters for fetching TV series lists (lists endpoint, different from airing_today ecc...).
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isJwt(token: string): boolean;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function isBase64Url(str) {
|
|
2
|
+
return /^[A-Za-z0-9\-_]+$/.test(str);
|
|
3
|
+
}
|
|
4
|
+
function decodeBase64Url(str) {
|
|
5
|
+
try {
|
|
6
|
+
const base64 = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
7
|
+
const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "=");
|
|
8
|
+
return atob(padded);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function isObject(value) {
|
|
15
|
+
return typeof value === "object" && value !== null;
|
|
16
|
+
}
|
|
17
|
+
function isJwtHeader(value) {
|
|
18
|
+
if (!isObject(value))
|
|
19
|
+
return false;
|
|
20
|
+
return typeof value.alg === "string";
|
|
21
|
+
}
|
|
22
|
+
function isJwtPayload(value) {
|
|
23
|
+
if (!isObject(value))
|
|
24
|
+
return false;
|
|
25
|
+
if ("exp" in value && typeof value.exp !== "number")
|
|
26
|
+
return false;
|
|
27
|
+
if ("nbf" in value && typeof value.nbf !== "number")
|
|
28
|
+
return false;
|
|
29
|
+
if ("iat" in value && typeof value.iat !== "number")
|
|
30
|
+
return false;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
export function isJwt(token) {
|
|
34
|
+
if (typeof token !== "string")
|
|
35
|
+
return false;
|
|
36
|
+
const parts = token.split(".");
|
|
37
|
+
if (parts.length !== 3)
|
|
38
|
+
return false;
|
|
39
|
+
const [headerB64, payloadB64, signatureB64] = parts;
|
|
40
|
+
if (!isBase64Url(headerB64) || !isBase64Url(payloadB64) || !isBase64Url(signatureB64)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const headerStr = decodeBase64Url(headerB64);
|
|
44
|
+
const payloadStr = decodeBase64Url(payloadB64);
|
|
45
|
+
if (!headerStr || !payloadStr)
|
|
46
|
+
return false;
|
|
47
|
+
let parsedHeader;
|
|
48
|
+
let parsedPayload;
|
|
49
|
+
try {
|
|
50
|
+
parsedHeader = JSON.parse(headerStr);
|
|
51
|
+
parsedPayload = JSON.parse(payloadStr);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (!isJwtHeader(parsedHeader))
|
|
57
|
+
return false;
|
|
58
|
+
if (!isJwtPayload(parsedPayload))
|
|
59
|
+
return false;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lorenzopant/tmdb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "A completely type-safe The Movie Database (TMDB) API wrapper for typescript applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"dev": "tsc --watch",
|
|
22
22
|
"typecheck": "tsc --noEmit",
|
|
23
23
|
"test": "vitest",
|
|
24
|
+
"test:unit": "vitest run --exclude '**/*.integration.test.ts'",
|
|
25
|
+
"test:integration": "vitest run integration",
|
|
24
26
|
"test:ui": "vitest --ui",
|
|
25
27
|
"test:coverage": "vitest --coverage",
|
|
26
28
|
"prepare": "husky",
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
"@eslint/compat": "^2.0.0",
|
|
44
46
|
"@eslint/eslintrc": "^3.3.1",
|
|
45
47
|
"@eslint/js": "^9.30.0",
|
|
46
|
-
"@types/node": "^22.
|
|
48
|
+
"@types/node": "^22.19.11",
|
|
47
49
|
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
48
50
|
"@typescript-eslint/parser": "^8.35.0",
|
|
49
51
|
"@vitest/coverage-v8": "^4.0.9",
|