@lorenzopant/tmdb 0.0.4 → 0.0.6

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.
@@ -12,6 +12,7 @@ export declare class MovieListsAPI {
12
12
  private client;
13
13
  private defaultOptions;
14
14
  constructor(client: ApiClient, defaultOptions?: TMDBOptions);
15
+ private withDefaults;
15
16
  /**
16
17
  * Fetch Movie List Wrapper
17
18
  * @param endpoint Endpoint to call
@@ -13,6 +13,10 @@ export class MovieListsAPI {
13
13
  this.client = client;
14
14
  this.defaultOptions = defaultOptions;
15
15
  }
16
+ withDefaults(params) {
17
+ const { language = this.defaultOptions.language, region = this.defaultOptions.region, ...rest } = params;
18
+ return { language, region, ...rest };
19
+ }
16
20
  /**
17
21
  * Fetch Movie List Wrapper
18
22
  * @param endpoint Endpoint to call
@@ -20,8 +24,7 @@ export class MovieListsAPI {
20
24
  * @returns Specific to endpoint (MovieListResult)
21
25
  */
22
26
  fetch_movie_list(endpoint, params = {}) {
23
- const mergedParams = { ...this.defaultOptions, ...params };
24
- return this.client.request(MOVIE_ENDPOINTS.MOVIE + endpoint, mergedParams);
27
+ return this.client.request(MOVIE_ENDPOINTS.MOVIE + endpoint, this.withDefaults(params));
25
28
  }
26
29
  /**
27
30
  * Now Playing
@@ -2,7 +2,7 @@ import { ApiClient } from "../client";
2
2
  import { TMDBOptions } from "../tmdb";
3
3
  import { Changes } from "../types/common";
4
4
  import { MovieAlternativeTitles, MovieCredits, MovieDetails, MovieExternalIDs, MovieImages, MovieKeywords, MovieReleaseDates, MovieResultItem, MovieTranslations, MovieVideos, MovieWatchProvider } from "../types/movies";
5
- import { MovieAlternativeTitlesParams, MovieDetailsParams, PaginatedResponse } from "../types/params";
5
+ import { MovieAlternativeTitlesParams, MovieChangesParams, MovieCreditsParams, MovieDetailsParams, MovieExternalIDsParams, MovieImagesParams, MovieKeywordsParams, MovieRecommendationsParams, MovieReleaseDatesParams, MovieSimilarParams, MovieTranslationsParams, MovieVideosParams, MovieWathProvidersParams, PaginatedResponse } from "../types/params";
6
6
  export declare const MOVIE_ENDPOINTS: {
7
7
  MOVIE: string;
8
8
  ALTERNATIVE_TITLES: string;
@@ -56,7 +56,7 @@ export declare class MoviesAPI {
56
56
  * @returns A promise that resolves to the movie credits.
57
57
  * @reference https://developer.themoviedb.org/reference/movie-credits
58
58
  */
59
- credits(movie_id: number, language?: string): Promise<MovieCredits>;
59
+ credits(params: MovieCreditsParams): Promise<MovieCredits>;
60
60
  /**
61
61
  * External IDs
62
62
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/external_ids
@@ -68,7 +68,7 @@ export declare class MoviesAPI {
68
68
  * @returns A promise that resolves to the movie external IDs.
69
69
  * @reference https://developer.themoviedb.org/reference/movie-external-ids
70
70
  */
71
- external_ids(movie_id: number): Promise<MovieExternalIDs>;
71
+ external_ids(params: MovieExternalIDsParams): Promise<MovieExternalIDs>;
72
72
  /**
73
73
  * Keywords
74
74
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/keywords
@@ -79,7 +79,7 @@ export declare class MoviesAPI {
79
79
  * @returns A promise that resolves to the movie keywords.
80
80
  * @reference https://developer.themoviedb.org/reference/movie-keywords
81
81
  */
82
- keywords(movie_id: number): Promise<MovieKeywords>;
82
+ keywords(params: MovieKeywordsParams): Promise<MovieKeywords>;
83
83
  /**
84
84
  * Changes
85
85
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/changes
@@ -94,20 +94,23 @@ export declare class MoviesAPI {
94
94
  * @returns A promise that resolves to the changes made to the movie.
95
95
  * @reference https://developer.themoviedb.org/reference/movie-changes
96
96
  */
97
- changes(movie_id: number, page?: number, start_date?: string, end_date?: string): Promise<Changes>;
97
+ changes(params: MovieChangesParams): Promise<Changes>;
98
98
  /**
99
99
  * Images
100
100
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/images
101
101
  *
102
102
  * Fetches images related to a specific movie, such as posters and backdrops.
103
103
  * The images are returned in various sizes and formats.
104
+ *
105
+ * If you have a language specified, it will act as a filter on the returned items. You can use the include_image_language param to query additional languages.
106
+ *
104
107
  * @param movie_id - The unique identifier of the movie.
105
108
  * @param language - (Optional) The language code to filter the images by language.
106
109
  * @param include_image_language - (Optional) A comma-separated list of language codes to include images for.
107
110
  * @returns A promise that resolves to a `MovieImages` object containing the movie's images.
108
111
  * @reference https://developer.themoviedb.org/reference/movie-images
109
112
  */
110
- images(movie_id: number, language?: string, include_image_language?: string): Promise<MovieImages>;
113
+ images(params: MovieImagesParams): Promise<MovieImages>;
111
114
  /**
112
115
  * Latest
113
116
  * GET - https://api.themoviedb.org/3/movie/latest
@@ -130,7 +133,7 @@ export declare class MoviesAPI {
130
133
  * @returns A promise that resolves to a paginated response of similar movies.
131
134
  * @reference https://developer.themoviedb.org/reference/movie-recommendations
132
135
  */
133
- recommendations(movie_id: number, page?: number, language?: string): Promise<PaginatedResponse<MovieResultItem>>;
136
+ recommendations(params: MovieRecommendationsParams): Promise<PaginatedResponse<MovieResultItem>>;
134
137
  /**
135
138
  * Release Dates
136
139
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/release_dates
@@ -147,7 +150,7 @@ export declare class MoviesAPI {
147
150
  * @returns A promise that resolves to the release dates for the movie.
148
151
  * @reference https://developer.themoviedb.org/reference/movie-release-dates
149
152
  */
150
- release_dates(movie_id: number): Promise<MovieReleaseDates>;
153
+ release_dates(params: MovieReleaseDatesParams): Promise<MovieReleaseDates>;
151
154
  /**
152
155
  * Similar
153
156
  * GET -https://api.themoviedb.org/3/movie/{movie_id}/similar
@@ -161,7 +164,7 @@ export declare class MoviesAPI {
161
164
  * @returns A promise that resolves to a paginated response of similar movies.
162
165
  * @reference https://developer.themoviedb.org/reference/movie-similar
163
166
  */
164
- similar(movie_id: number, language?: string, page?: number): Promise<PaginatedResponse<MovieResultItem>>;
167
+ similar(params: MovieSimilarParams): Promise<PaginatedResponse<MovieResultItem>>;
165
168
  /**
166
169
  * Translations
167
170
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/translations
@@ -173,7 +176,7 @@ export declare class MoviesAPI {
173
176
  * @returns A promise that resolves to the translations of the movie.
174
177
  * @reference https://developer.themoviedb.org/reference/movie-translations
175
178
  */
176
- translations(movie_id: number): Promise<MovieTranslations>;
179
+ translations(params: MovieTranslationsParams): Promise<MovieTranslations>;
177
180
  /**
178
181
  * Videos
179
182
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/videos
@@ -183,7 +186,7 @@ export declare class MoviesAPI {
183
186
  * @returns A promise that resolves to a list of videos for the movie.
184
187
  * @reference https://developer.themoviedb.org/reference/movie-videos
185
188
  */
186
- videos(movie_id: number, language?: string): Promise<MovieVideos>;
189
+ videos(params: MovieVideosParams): Promise<MovieVideos>;
187
190
  /**
188
191
  * Watch Providers
189
192
  * GET - https://api.themoviedb.org/3/movie/{movie_id}/watch/providers
@@ -200,5 +203,5 @@ export declare class MoviesAPI {
200
203
  * @returns A promise that resolves to a list of videos for the movie.
201
204
  * @reference https://developer.themoviedb.org/reference/movie-videos
202
205
  */
203
- watch_providers(movie_id: number): Promise<MovieWatchProvider>;
206
+ watch_providers(params: MovieWathProvidersParams): Promise<MovieWatchProvider>;
204
207
  }
@@ -1,4 +1,3 @@
1
- import { mergeParams } from "../utils/params";
2
1
  export const MOVIE_ENDPOINTS = {
3
2
  MOVIE: "/movie",
4
3
  ALTERNATIVE_TITLES: "/alternative_titles",
@@ -40,9 +39,9 @@ export class MoviesAPI {
40
39
  * @reference https://developer.themoviedb.org/reference/movie-details
41
40
  */
42
41
  async details(params) {
43
- const mergedParams = { ...this.defaultOptions, ...params };
44
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${mergedParams.movie_id}`;
45
- return this.client.request(endpoint, mergedParams);
42
+ const { language = this.defaultOptions.language, ...rest } = params;
43
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}`;
44
+ return this.client.request(endpoint, { language, ...rest });
46
45
  }
47
46
  /**
48
47
  * Alternative Titles
@@ -55,9 +54,8 @@ export class MoviesAPI {
55
54
  * @reference https://developer.themoviedb.org/reference/movie-alternative-titles
56
55
  */
57
56
  async alternative_titles(params) {
58
- const mergedParams = mergeParams(this.defaultOptions, params);
59
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${mergedParams.movie_id}${MOVIE_ENDPOINTS.ALTERNATIVE_TITLES}`;
60
- return this.client.request(endpoint, mergedParams);
57
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.ALTERNATIVE_TITLES}`;
58
+ return this.client.request(endpoint, params);
61
59
  }
62
60
  /**
63
61
  * Credits
@@ -69,10 +67,10 @@ export class MoviesAPI {
69
67
  * @returns A promise that resolves to the movie credits.
70
68
  * @reference https://developer.themoviedb.org/reference/movie-credits
71
69
  */
72
- async credits(movie_id, language = "en-US") {
73
- const params = { language };
74
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.CREDITS}`;
75
- return this.client.request(endpoint, params);
70
+ async credits(params) {
71
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.CREDITS}`;
72
+ const { language = this.defaultOptions.language, ...rest } = params;
73
+ return this.client.request(endpoint, { language, ...rest });
76
74
  }
77
75
  /**
78
76
  * External IDs
@@ -85,8 +83,8 @@ export class MoviesAPI {
85
83
  * @returns A promise that resolves to the movie external IDs.
86
84
  * @reference https://developer.themoviedb.org/reference/movie-external-ids
87
85
  */
88
- async external_ids(movie_id) {
89
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.EXTERNAL_IDS}`;
86
+ async external_ids(params) {
87
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.EXTERNAL_IDS}`;
90
88
  return this.client.request(endpoint);
91
89
  }
92
90
  /**
@@ -99,8 +97,8 @@ export class MoviesAPI {
99
97
  * @returns A promise that resolves to the movie keywords.
100
98
  * @reference https://developer.themoviedb.org/reference/movie-keywords
101
99
  */
102
- async keywords(movie_id) {
103
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.KEYWORDS}`;
100
+ async keywords(params) {
101
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.KEYWORDS}`;
104
102
  return this.client.request(endpoint);
105
103
  }
106
104
  /**
@@ -117,9 +115,8 @@ export class MoviesAPI {
117
115
  * @returns A promise that resolves to the changes made to the movie.
118
116
  * @reference https://developer.themoviedb.org/reference/movie-changes
119
117
  */
120
- async changes(movie_id, page, start_date, end_date) {
121
- const params = { page, start_date, end_date };
122
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.CHANGES}`;
118
+ async changes(params) {
119
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.CHANGES}`;
123
120
  return this.client.request(endpoint, params);
124
121
  }
125
122
  /**
@@ -128,16 +125,19 @@ export class MoviesAPI {
128
125
  *
129
126
  * Fetches images related to a specific movie, such as posters and backdrops.
130
127
  * The images are returned in various sizes and formats.
128
+ *
129
+ * If you have a language specified, it will act as a filter on the returned items. You can use the include_image_language param to query additional languages.
130
+ *
131
131
  * @param movie_id - The unique identifier of the movie.
132
132
  * @param language - (Optional) The language code to filter the images by language.
133
133
  * @param include_image_language - (Optional) A comma-separated list of language codes to include images for.
134
134
  * @returns A promise that resolves to a `MovieImages` object containing the movie's images.
135
135
  * @reference https://developer.themoviedb.org/reference/movie-images
136
136
  */
137
- async images(movie_id, language, include_image_language) {
138
- const params = { language, include_image_language };
139
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.IMAGES}`;
140
- return this.client.request(endpoint, params);
137
+ async images(params) {
138
+ const { language = this.defaultOptions.language, ...rest } = params;
139
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.IMAGES}`;
140
+ return this.client.request(endpoint, { language, ...rest });
141
141
  }
142
142
  /**
143
143
  * Latest
@@ -164,10 +164,10 @@ export class MoviesAPI {
164
164
  * @returns A promise that resolves to a paginated response of similar movies.
165
165
  * @reference https://developer.themoviedb.org/reference/movie-recommendations
166
166
  */
167
- async recommendations(movie_id, page, language) {
168
- const params = { page, language };
169
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.RECOMMENDATIONS}`;
170
- return this.client.request(endpoint, params);
167
+ async recommendations(params) {
168
+ const { language = this.defaultOptions.language, ...rest } = params;
169
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RECOMMENDATIONS}`;
170
+ return this.client.request(endpoint, { language, ...rest });
171
171
  }
172
172
  /**
173
173
  * Release Dates
@@ -185,8 +185,8 @@ export class MoviesAPI {
185
185
  * @returns A promise that resolves to the release dates for the movie.
186
186
  * @reference https://developer.themoviedb.org/reference/movie-release-dates
187
187
  */
188
- async release_dates(movie_id) {
189
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.RELEASE_DATES}`;
188
+ async release_dates(params) {
189
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RELEASE_DATES}`;
190
190
  return this.client.request(endpoint);
191
191
  }
192
192
  /**
@@ -202,10 +202,10 @@ export class MoviesAPI {
202
202
  * @returns A promise that resolves to a paginated response of similar movies.
203
203
  * @reference https://developer.themoviedb.org/reference/movie-similar
204
204
  */
205
- async similar(movie_id, language, page) {
206
- const params = { page, language };
207
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.SIMILAR}`;
208
- return this.client.request(endpoint, params);
205
+ async similar(params) {
206
+ const { language = this.defaultOptions.language, ...rest } = params;
207
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.SIMILAR}`;
208
+ return this.client.request(endpoint, { language, ...rest });
209
209
  }
210
210
  /**
211
211
  * Translations
@@ -218,8 +218,8 @@ export class MoviesAPI {
218
218
  * @returns A promise that resolves to the translations of the movie.
219
219
  * @reference https://developer.themoviedb.org/reference/movie-translations
220
220
  */
221
- async translations(movie_id) {
222
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.TRANSLATIONS}`;
221
+ async translations(params) {
222
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.TRANSLATIONS}`;
223
223
  return this.client.request(endpoint);
224
224
  }
225
225
  /**
@@ -231,10 +231,10 @@ export class MoviesAPI {
231
231
  * @returns A promise that resolves to a list of videos for the movie.
232
232
  * @reference https://developer.themoviedb.org/reference/movie-videos
233
233
  */
234
- async videos(movie_id, language) {
235
- const params = { language };
236
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.VIDEOS}`;
237
- return this.client.request(endpoint, params);
234
+ async videos(params) {
235
+ const { language = this.defaultOptions.language, ...rest } = params;
236
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.VIDEOS}`;
237
+ return this.client.request(endpoint, { language, ...rest });
238
238
  }
239
239
  /**
240
240
  * Watch Providers
@@ -252,8 +252,8 @@ export class MoviesAPI {
252
252
  * @returns A promise that resolves to a list of videos for the movie.
253
253
  * @reference https://developer.themoviedb.org/reference/movie-videos
254
254
  */
255
- async watch_providers(movie_id) {
256
- const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${movie_id}${MOVIE_ENDPOINTS.WATCH_PROVIDERS}`;
255
+ async watch_providers(params) {
256
+ const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.WATCH_PROVIDERS}`;
257
257
  return this.client.request(endpoint);
258
258
  }
259
259
  }
@@ -9,6 +9,7 @@ export declare class SearchAPI {
9
9
  private client;
10
10
  private defaultOptions;
11
11
  constructor(client: ApiClient, defaultOptions?: TMDBOptions);
12
+ withDefaults(params: SearchMoviesParams): SearchMoviesParams;
12
13
  /**
13
14
  * Search
14
15
  * GET - https://api.themoviedb.org/3/search/movie
@@ -8,6 +8,10 @@ export class SearchAPI {
8
8
  this.client = client;
9
9
  this.defaultOptions = defaultOptions;
10
10
  }
11
+ withDefaults(params) {
12
+ const { language = this.defaultOptions.language, region = this.defaultOptions.region, ...rest } = params;
13
+ return { language, region, ...rest };
14
+ }
11
15
  /**
12
16
  * Search
13
17
  * GET - https://api.themoviedb.org/3/search/movie
@@ -24,8 +28,6 @@ export class SearchAPI {
24
28
  */
25
29
  async movies(params) {
26
30
  const endpoint = `${SEARCH_ENDPOINTS.MOVIE}`;
27
- // Merge defaultOptions with params, giving precedence to params
28
- const mergedParams = { ...this.defaultOptions, ...params };
29
- return this.client.request(endpoint, mergedParams);
31
+ return this.client.request(endpoint, this.withDefaults(params));
30
32
  }
31
33
  }
package/dist/index.d.ts CHANGED
@@ -2,3 +2,8 @@ export { TMDB } from "./tmdb";
2
2
  export { TMDBError } from "./errors/tmdb";
3
3
  export type { MovieDetails, MovieAlternativeTitle, MovieAlternativeTitles, MovieCredits, MovieExternalIDs, MovieImages, MovieKeywords, MovieReleaseDates, MovieTranslations, MovieVideos, } from "./types/movies";
4
4
  export type { Changes, Collection, Genre, ImageItem, Keyword, ProductionCompany, ProductionCountry, SpokenLanguage, VideoItem, Cast, Crew, } from "./types/common";
5
+ export type { SearchMoviesParams, MovieDetailsParams, MovieListParams, PaginatedResponse, MovieAlternativeTitlesParams, } from "./types/params";
6
+ export type { CountryISO3166_1 } from "./types/countries";
7
+ export { TMDBCountries } from "./types/countries";
8
+ export type { LanguageISO6391 } from "./types/lang";
9
+ export { Languages } from "./types/lang";
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  // src/index.ts
2
2
  export { TMDB } from "./tmdb";
3
3
  export { TMDBError } from "./errors/tmdb";
4
+ export { TMDBCountries } from "./types/countries";
5
+ export { Languages } from "./types/lang";
@@ -3,7 +3,7 @@ import { TMDB } from "../../tmdb";
3
3
  const token = process.env.TMDB_ACCESS_TOKEN;
4
4
  if (!token)
5
5
  throw new Error("TMDB_ACCESS_TOKEN is not set, plaase set it in your enviroment variables.");
6
- const tmdb = new TMDB(token, { language: "it-IT", region: "IT", country: "IT" });
6
+ const tmdb = new TMDB(token, { language: "it", region: "IT" });
7
7
  describe("Movie List (integration)", () => {
8
8
  it("(NOW PLAYING) should get now playing movies", async () => {
9
9
  const now_playing = await tmdb.movie_lists.now_playing();
@@ -34,7 +34,7 @@ describe("Movies (integration)", () => {
34
34
  });
35
35
  it("(MOVIE CREDITS) should get movie credits", async () => {
36
36
  const movie_id = 550; // Fight Club
37
- const credits = await tmdb.movies.credits(movie_id);
37
+ const credits = await tmdb.movies.credits({ movie_id });
38
38
  expect(credits).toBeDefined();
39
39
  expect(credits.id).toBe(movie_id);
40
40
  expect(credits.cast.length).toBeGreaterThan(0);
@@ -43,14 +43,14 @@ describe("Movies (integration)", () => {
43
43
  });
44
44
  it("(MOVIE EXTERNAL IDS) should get movie external IDs", async () => {
45
45
  const movie_id = 550; // Fight Club
46
- const external_ids = await tmdb.movies.external_ids(movie_id);
46
+ const external_ids = await tmdb.movies.external_ids({ movie_id });
47
47
  expect(external_ids).toBeDefined();
48
48
  expect(external_ids.id).toBe(movie_id);
49
49
  expect(external_ids.imdb_id).toBe("tt0137523");
50
50
  });
51
51
  it("(MOVIE KEYWORDS) should get movie keywords", async () => {
52
52
  const movie_id = 550; // Fight Club
53
- const keywords = await tmdb.movies.keywords(movie_id);
53
+ const keywords = await tmdb.movies.keywords({ movie_id });
54
54
  expect(keywords).toBeDefined();
55
55
  expect(keywords.id).toBe(movie_id);
56
56
  expect(keywords.keywords.length).toBeGreaterThan(0);
@@ -59,7 +59,7 @@ describe("Movies (integration)", () => {
59
59
  const movie_id = 550; // Fight Club
60
60
  const start_date = "2024-12-20";
61
61
  const end_date = "2024-12-24";
62
- const changes = await tmdb.movies.changes(movie_id, 1, start_date, end_date);
62
+ const changes = await tmdb.movies.changes({ movie_id, start_date, end_date });
63
63
  expect(changes).toBeDefined();
64
64
  expect(changes.changes).toBeDefined();
65
65
  expect(changes.changes[0].key).toBe("images");
@@ -67,7 +67,7 @@ describe("Movies (integration)", () => {
67
67
  });
68
68
  it("(MOVIE IMAGES) should get movie images", async () => {
69
69
  const movie_id = 550; // Fight Club
70
- const images = await tmdb.movies.images(movie_id);
70
+ const images = await tmdb.movies.images({ movie_id });
71
71
  expect(images).toBeDefined();
72
72
  expect(images.id).toBe(movie_id);
73
73
  expect(images.backdrops.length).toBeGreaterThan(0);
@@ -75,10 +75,10 @@ describe("Movies (integration)", () => {
75
75
  });
76
76
  it("(MOVIE IMAGES) should get movie images for a specific language", async () => {
77
77
  const movie_id = 550; // Fight Club
78
- const images = await tmdb.movies.images(movie_id, "en");
78
+ const images = await tmdb.movies.images({ movie_id, language: "de" });
79
79
  expect(images).toBeDefined();
80
80
  expect(images.id).toBe(movie_id);
81
- expect(images.backdrops.length).toBeGreaterThan(0);
81
+ expect(images.backdrops.length).toBeGreaterThanOrEqual(0);
82
82
  expect(images.posters.length).toBeGreaterThan(0);
83
83
  });
84
84
  it("(MOVIE LATEST) should get the latest movie details", async () => {
@@ -89,7 +89,7 @@ describe("Movies (integration)", () => {
89
89
  });
90
90
  it("(MOVIE RECOMMENDATIONS) should get movie recommendations", async () => {
91
91
  const movie_id = 550; // Fight Club
92
- const recommendations = await tmdb.movies.recommendations(movie_id);
92
+ const recommendations = await tmdb.movies.recommendations({ movie_id });
93
93
  expect(recommendations).toBeDefined();
94
94
  expect(recommendations.results.length).toBeGreaterThan(0);
95
95
  expect(recommendations.results[0].id).toBeDefined();
@@ -99,7 +99,7 @@ describe("Movies (integration)", () => {
99
99
  });
100
100
  it("(MOVIE RELEASE DATES) should get movie release dates", async () => {
101
101
  const movie_id = 550; // Fight Club
102
- const release_dates = await tmdb.movies.release_dates(movie_id);
102
+ const release_dates = await tmdb.movies.release_dates({ movie_id });
103
103
  expect(release_dates).toBeDefined();
104
104
  expect(release_dates.id).toBe(movie_id);
105
105
  expect(release_dates.results.length).toBeGreaterThan(0);
@@ -108,7 +108,7 @@ describe("Movies (integration)", () => {
108
108
  });
109
109
  it("(MOVIE SIMILAR) should get similar movies", async () => {
110
110
  const movie_id = 550;
111
- const similar = await tmdb.movies.similar(movie_id);
111
+ const similar = await tmdb.movies.similar({ movie_id });
112
112
  expect(similar).toBeDefined();
113
113
  expect(similar.results.length).toBeGreaterThan(0);
114
114
  expect(similar.results[0].id).toBeDefined();
@@ -118,7 +118,7 @@ describe("Movies (integration)", () => {
118
118
  });
119
119
  it("(MOVIE TRANSLATIONS) should get translations for a movie", async () => {
120
120
  const movie_id = 550;
121
- const translations = await tmdb.movies.translations(movie_id);
121
+ const translations = await tmdb.movies.translations({ movie_id });
122
122
  expect(translations).toBeDefined();
123
123
  expect(translations.id).toBe(movie_id);
124
124
  expect(translations.translations).toBeDefined();
@@ -127,7 +127,7 @@ describe("Movies (integration)", () => {
127
127
  });
128
128
  it("(MOVIE VIDEOS) should get videos for a movie", async () => {
129
129
  const movie_id = 550;
130
- const videos = await tmdb.movies.videos(movie_id);
130
+ const videos = await tmdb.movies.videos({ movie_id });
131
131
  expect(videos).toBeDefined();
132
132
  expect(videos.id).toBe(movie_id);
133
133
  expect(videos.results).toBeDefined();
@@ -136,7 +136,7 @@ describe("Movies (integration)", () => {
136
136
  });
137
137
  it("(MOVIE WATCH PROVIDERS) should get watch providers for a movie", async () => {
138
138
  const movie_id = 550;
139
- const watch_providers = await tmdb.movies.watch_providers(movie_id);
139
+ const watch_providers = await tmdb.movies.watch_providers({ movie_id });
140
140
  expect(watch_providers).toBeDefined();
141
141
  expect(watch_providers.id).toBe(movie_id);
142
142
  expect(watch_providers.results).toBeDefined();
@@ -13,7 +13,7 @@ describe("Search (integration)", () => {
13
13
  expect(movies.results[0].title).toBe("Fight Club");
14
14
  });
15
15
  it("(SEARCH MOVIE) should search for a movie with default options", async () => {
16
- const tmdb = new TMDB(token, { language: "it-IT", region: "IT" });
16
+ const tmdb = new TMDB(token, { language: "it", region: "IT" });
17
17
  const movies = await tmdb.search.movies({ query: "Fight Club" });
18
18
  expect(movies.page).toBe(1);
19
19
  expect(movies.total_results).toBeGreaterThan(0);
package/dist/tmdb.d.ts CHANGED
@@ -1,10 +1,21 @@
1
1
  import { MovieListsAPI } from "./endpoints/movie_lists";
2
2
  import { MoviesAPI } from "./endpoints/movies";
3
3
  import { SearchAPI } from "./endpoints/search";
4
+ import { CountryISO3166_1 } from "./types/countries";
5
+ import { LanguageISO6391 } from "./types/lang";
4
6
  export type TMDBOptions = {
5
- language?: string;
6
- region?: string;
7
- country?: string;
7
+ /**
8
+ * The language to use for requests (ISO 639-1 code)
9
+ * This provides localization and translated data.
10
+ */
11
+ language?: LanguageISO6391;
12
+ /**
13
+ * Region codes follow ISO 3166-1 (e.g. 'US', 'IT', 'JP') and are used to localize results.
14
+ * They affect release dates, age certifications, watch providers, and filtered movie lists.
15
+ * Example: 'region=IT' returns Italian-specific results for now playing, watch providers, etc.
16
+ * If not set, TMDB may fall back to a default or global data.
17
+ */
18
+ region?: CountryISO3166_1;
8
19
  };
9
20
  export declare class TMDB {
10
21
  private client;
@@ -18,9 +29,4 @@ export declare class TMDB {
18
29
  * @param options Optional default options (e.g., language) for all requests.
19
30
  */
20
31
  constructor(accessToken: string, options?: TMDBOptions);
21
- /**
22
- * Helper to merge default options with method-specific params.
23
- * Method-level params override defaults.
24
- */
25
- withDefaults<T extends object>(params?: T): T & TMDBOptions;
26
32
  }
package/dist/tmdb.js CHANGED
@@ -21,15 +21,8 @@ export class TMDB {
21
21
  throw new Error(Errors.NO_ACCESS_TOKEN);
22
22
  this.options = options;
23
23
  this.client = new ApiClient(accessToken);
24
- this.movies = new MoviesAPI(this.client, options);
25
- this.movie_lists = new MovieListsAPI(this.client, options);
26
- this.search = new SearchAPI(this.client, options);
27
- }
28
- /**
29
- * Helper to merge default options with method-specific params.
30
- * Method-level params override defaults.
31
- */
32
- withDefaults(params) {
33
- return { ...this.options, ...params };
24
+ this.movies = new MoviesAPI(this.client, this.options);
25
+ this.movie_lists = new MovieListsAPI(this.client, this.options);
26
+ this.search = new SearchAPI(this.client, this.options);
34
27
  }
35
28
  }
@@ -29,3 +29,32 @@ export type MovieAlternativeTitlesParams = {
29
29
  movie_id: number;
30
30
  country?: CountryISO3166_1;
31
31
  };
32
+ export type MovieCreditsParams = {
33
+ movie_id: number;
34
+ language?: LanguageISO6391;
35
+ };
36
+ export type MovieKeywordsParams = {
37
+ movie_id: number;
38
+ };
39
+ export type MovieExternalIDsParams = MovieKeywordsParams;
40
+ export type MovieReleaseDatesParams = MovieKeywordsParams;
41
+ export type MovieTranslationsParams = MovieKeywordsParams;
42
+ export type MovieWathProvidersParams = MovieKeywordsParams;
43
+ export type MovieChangesParams = {
44
+ movie_id: number;
45
+ page?: number;
46
+ start_date?: string;
47
+ end_date?: string;
48
+ };
49
+ export type MovieImagesParams = {
50
+ movie_id: number;
51
+ language?: LanguageISO6391;
52
+ include_image_language?: LanguageISO6391;
53
+ };
54
+ export type MovieRecommendationsParams = {
55
+ movie_id: number;
56
+ page?: number;
57
+ language?: LanguageISO6391;
58
+ };
59
+ export type MovieSimilarParams = MovieRecommendationsParams;
60
+ export type MovieVideosParams = MovieCreditsParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lorenzopant/tmdb",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
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",