@lorenzopant/tmdb 1.15.1 → 1.16.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.
@@ -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;
@@ -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; // Handle undefined params
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,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(params.series_id);
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(params.series_id, ENDPOINTS.TV_SERIES.AGGREGATE_CREDITS);
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 endpoint = this.seriesSubPath(params.series_id, ENDPOINTS.TV_SERIES.CHANGES);
76
- return this.client.request(endpoint, { ...params });
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 endpoint = this.seriesSubPath(params.series_id, ENDPOINTS.TV_SERIES.CREDITS);
107
- const { language = this.defaultOptions.language, ...rest } = params;
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(params.series_id, ENDPOINTS.TV_SERIES.IMAGES);
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 endpoint = this.seriesSubPath(params.series_id, ENDPOINTS.TV_SERIES.LISTS);
196
- const { language = this.defaultOptions.language, ...rest } = params;
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 endpoint = this.seriesSubPath(params.series_id, ENDPOINTS.TV_SERIES.RECOMMENDATIONS);
212
- const { language = this.defaultOptions.language, ...rest } = params;
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 endpoint = this.seriesSubPath(params.series_id, ENDPOINTS.TV_SERIES.REVIEWS);
228
- const { language = this.defaultOptions.language, ...rest } = params;
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 endpoint = this.seriesSubPath(params.series_id, ENDPOINTS.TV_SERIES.SIMILAR);
257
- const { language = this.defaultOptions.language, ...rest } = params;
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
@@ -136,4 +136,10 @@ export declare const ENDPOINTS: {
136
136
  TV: string;
137
137
  PERSON: string;
138
138
  };
139
+ REVIEWS: {
140
+ DETAILS: string;
141
+ };
142
+ PEOPLE_LISTS: {
143
+ POPULAR: string;
144
+ };
139
145
  };
package/dist/routes.js CHANGED
@@ -136,4 +136,10 @@ export const ENDPOINTS = {
136
136
  TV: "/trending/tv",
137
137
  PERSON: "/trending/person",
138
138
  },
139
+ REVIEWS: {
140
+ DETAILS: "/review",
141
+ },
142
+ PEOPLE_LISTS: {
143
+ POPULAR: "/person/popular",
144
+ },
139
145
  };
package/dist/tmdb.d.ts CHANGED
@@ -21,6 +21,8 @@ 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";
24
26
  export declare class TMDB {
25
27
  private client;
26
28
  private options;
@@ -46,6 +48,8 @@ export declare class TMDB {
46
48
  tv_episode_groups: TVEpisodeGroupsAPI;
47
49
  tv_seasons: TVSeasonsAPI;
48
50
  trending: TrendingAPI;
51
+ reviews: ReviewsAPI;
52
+ people_lists: PeopleListsAPI;
49
53
  /**
50
54
  * Creates a new TMDB instance.
51
55
  * @param accessToken The TMDB API access token.
package/dist/tmdb.js CHANGED
@@ -23,6 +23,8 @@ 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";
26
28
  export class TMDB {
27
29
  client;
28
30
  options; // ** Default options for all requests
@@ -48,6 +50,8 @@ export class TMDB {
48
50
  tv_episode_groups;
49
51
  tv_seasons;
50
52
  trending;
53
+ reviews;
54
+ people_lists;
51
55
  // etc...
52
56
  /**
53
57
  * Creates a new TMDB instance.
@@ -81,5 +85,7 @@ export class TMDB {
81
85
  this.tv_episode_groups = new TVEpisodeGroupsAPI(this.client, this.options);
82
86
  this.tv_seasons = new TVSeasonsAPI(this.client, this.options);
83
87
  this.trending = new TrendingAPI(this.client, this.options);
88
+ this.reviews = new ReviewsAPI(this.client, this.options);
89
+ this.people_lists = new PeopleListsAPI(this.client, this.options);
84
90
  }
85
91
  }
@@ -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
- include_image_language?: Language | LanguageISO6391;
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, LanguageISO6391 } from "./config/languages";
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
- include_image_language?: Language | LanguageISO6391;
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;
@@ -16,3 +16,5 @@ export * from "./find";
16
16
  export * from "./watch-providers";
17
17
  export * from "./keywords";
18
18
  export * from "./credits";
19
+ export * from "./reviews";
20
+ export * from "./people-lists";
@@ -16,3 +16,5 @@ export * from "./find";
16
16
  export * from "./watch-providers";
17
17
  export * from "./keywords";
18
18
  export * from "./credits";
19
+ export * from "./reviews";
20
+ export * from "./people-lists";
@@ -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
- /** Include images with specific language tags (comma-separated, e.g., "en,null") */
286
- include_image_language?: Language | LanguageISO6391;
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,5 @@
1
+ import type { WithLanguage, WithPage } from "./common/params";
2
+ /**
3
+ * Query parameters for the people popular list endpoint.
4
+ */
5
+ export type PeopleListParams = WithLanguage & 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
- include_image_language?: Language;
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
- include_image_language?: string;
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
- /** Include images with specific language tags (comma-separated, e.g., "en,null") */
428
- include_image_language?: Language | LanguageISO6391;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lorenzopant/tmdb",
3
- "version": "1.15.1",
3
+ "version": "1.16.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",