@lorenzopant/tmdb 0.0.6 → 0.0.7
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ApiClient } from "../client";
|
|
2
2
|
import { TMDBOptions } from "../tmdb";
|
|
3
3
|
import { Changes } from "../types/common";
|
|
4
|
-
import { MovieAlternativeTitles, MovieCredits, MovieDetails, MovieExternalIDs, MovieImages, MovieKeywords, MovieReleaseDates,
|
|
5
|
-
import { MovieAlternativeTitlesParams, MovieChangesParams, MovieCreditsParams, MovieDetailsParams, MovieExternalIDsParams, MovieImagesParams, MovieKeywordsParams, MovieRecommendationsParams, MovieReleaseDatesParams, MovieSimilarParams, MovieTranslationsParams, MovieVideosParams, MovieWathProvidersParams
|
|
4
|
+
import { MovieAlternativeTitles, MovieAppendToResponseNamespace, MovieCredits, MovieDetails, MovieDetailsWithAppends, MovieExternalIDs, MovieImages, MovieKeywords, MovieRecommendations, MovieReleaseDates, MovieReviews, MovieSimilar, MovieTranslations, MovieVideos, MovieWatchProvider } from "../types/movies";
|
|
5
|
+
import { MovieAlternativeTitlesParams, MovieChangesParams, MovieCreditsParams, MovieDetailsParams, MovieExternalIDsParams, MovieImagesParams, MovieKeywordsParams, MovieRecommendationsParams, MovieReleaseDatesParams, MovieReviewsParams, MovieSimilarParams, MovieTranslationsParams, MovieVideosParams, MovieWathProvidersParams } from "../types/params";
|
|
6
6
|
export declare const MOVIE_ENDPOINTS: {
|
|
7
7
|
MOVIE: string;
|
|
8
8
|
ALTERNATIVE_TITLES: string;
|
|
@@ -18,6 +18,7 @@ export declare const MOVIE_ENDPOINTS: {
|
|
|
18
18
|
TRANSLATIONS: string;
|
|
19
19
|
VIDEOS: string;
|
|
20
20
|
WATCH_PROVIDERS: string;
|
|
21
|
+
REVIEWS: string;
|
|
21
22
|
};
|
|
22
23
|
export declare class MoviesAPI {
|
|
23
24
|
private client;
|
|
@@ -34,7 +35,9 @@ export declare class MoviesAPI {
|
|
|
34
35
|
* @returns A promise that resolves to the movie details.
|
|
35
36
|
* @reference https://developer.themoviedb.org/reference/movie-details
|
|
36
37
|
*/
|
|
37
|
-
details(params: MovieDetailsParams
|
|
38
|
+
details<T extends readonly MovieAppendToResponseNamespace[] = []>(params: MovieDetailsParams & {
|
|
39
|
+
append_to_response?: T[number] | T;
|
|
40
|
+
}): Promise<T extends [] ? MovieDetails : MovieDetailsWithAppends<T>>;
|
|
38
41
|
/**
|
|
39
42
|
* Alternative Titles
|
|
40
43
|
* GET - https://api.themoviedb.org/3/movie/{movie_id}/alternative_titles
|
|
@@ -133,7 +136,7 @@ export declare class MoviesAPI {
|
|
|
133
136
|
* @returns A promise that resolves to a paginated response of similar movies.
|
|
134
137
|
* @reference https://developer.themoviedb.org/reference/movie-recommendations
|
|
135
138
|
*/
|
|
136
|
-
recommendations(params: MovieRecommendationsParams): Promise<
|
|
139
|
+
recommendations(params: MovieRecommendationsParams): Promise<MovieRecommendations>;
|
|
137
140
|
/**
|
|
138
141
|
* Release Dates
|
|
139
142
|
* GET - https://api.themoviedb.org/3/movie/{movie_id}/release_dates
|
|
@@ -151,6 +154,18 @@ export declare class MoviesAPI {
|
|
|
151
154
|
* @reference https://developer.themoviedb.org/reference/movie-release-dates
|
|
152
155
|
*/
|
|
153
156
|
release_dates(params: MovieReleaseDatesParams): Promise<MovieReleaseDates>;
|
|
157
|
+
/**
|
|
158
|
+
* Reviews
|
|
159
|
+
* GET - https://api.themoviedb.org/3/movie/{movie_id}/reviews
|
|
160
|
+
*
|
|
161
|
+
* Get the user reviews for a movie.
|
|
162
|
+
* @param movie_id The ID of the movie.
|
|
163
|
+
* @param page Page number of the results to return. Defaults to 1.
|
|
164
|
+
* @param language Language code to filter the results. Default is "en-US".
|
|
165
|
+
* @returns A promise that resolves to a paginated response of movies reviews.
|
|
166
|
+
* @reference https://developer.themoviedb.org/reference/movie-reviews
|
|
167
|
+
*/
|
|
168
|
+
reviews(params: MovieReviewsParams): Promise<MovieReviews>;
|
|
154
169
|
/**
|
|
155
170
|
* Similar
|
|
156
171
|
* GET -https://api.themoviedb.org/3/movie/{movie_id}/similar
|
|
@@ -164,7 +179,7 @@ export declare class MoviesAPI {
|
|
|
164
179
|
* @returns A promise that resolves to a paginated response of similar movies.
|
|
165
180
|
* @reference https://developer.themoviedb.org/reference/movie-similar
|
|
166
181
|
*/
|
|
167
|
-
similar(params: MovieSimilarParams): Promise<
|
|
182
|
+
similar(params: MovieSimilarParams): Promise<MovieSimilar>;
|
|
168
183
|
/**
|
|
169
184
|
* Translations
|
|
170
185
|
* GET - https://api.themoviedb.org/3/movie/{movie_id}/translations
|
package/dist/endpoints/movies.js
CHANGED
|
@@ -13,10 +13,10 @@ export const MOVIE_ENDPOINTS = {
|
|
|
13
13
|
TRANSLATIONS: "/translations",
|
|
14
14
|
VIDEOS: "/videos",
|
|
15
15
|
WATCH_PROVIDERS: "/watch/providers",
|
|
16
|
+
REVIEWS: "/reviews",
|
|
16
17
|
// Missing:
|
|
17
18
|
// ACCOUNT_STATES
|
|
18
19
|
// LISTS
|
|
19
|
-
// REVIEWS
|
|
20
20
|
// ADD RATING
|
|
21
21
|
// DELETE RATING
|
|
22
22
|
};
|
|
@@ -189,6 +189,22 @@ export class MoviesAPI {
|
|
|
189
189
|
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RELEASE_DATES}`;
|
|
190
190
|
return this.client.request(endpoint);
|
|
191
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Reviews
|
|
194
|
+
* GET - https://api.themoviedb.org/3/movie/{movie_id}/reviews
|
|
195
|
+
*
|
|
196
|
+
* Get the user reviews for a movie.
|
|
197
|
+
* @param movie_id The ID of the movie.
|
|
198
|
+
* @param page Page number of the results to return. Defaults to 1.
|
|
199
|
+
* @param language Language code to filter the results. Default is "en-US".
|
|
200
|
+
* @returns A promise that resolves to a paginated response of movies reviews.
|
|
201
|
+
* @reference https://developer.themoviedb.org/reference/movie-reviews
|
|
202
|
+
*/
|
|
203
|
+
async reviews(params) {
|
|
204
|
+
const { language = this.defaultOptions.language, ...rest } = params;
|
|
205
|
+
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.REVIEWS}`;
|
|
206
|
+
return this.client.request(endpoint, { language, ...rest });
|
|
207
|
+
}
|
|
192
208
|
/**
|
|
193
209
|
* Similar
|
|
194
210
|
* GET -https://api.themoviedb.org/3/movie/{movie_id}/similar
|
|
@@ -25,6 +25,15 @@ describe("Movies (integration)", () => {
|
|
|
25
25
|
expect(error).toBeInstanceOf(TMDBError);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
+
it("(MOVIE DETAILS) should get movie details with appended response", async () => {
|
|
29
|
+
const movie_id = 550; // Fight Club
|
|
30
|
+
const movie = await tmdb.movies.details({ movie_id, append_to_response: ["reviews"] });
|
|
31
|
+
expect(movie).toBeDefined();
|
|
32
|
+
expect(movie.id).toBe(movie_id);
|
|
33
|
+
expect(movie.title).toBe("Fight Club");
|
|
34
|
+
expect(movie.reviews.results).toBeDefined();
|
|
35
|
+
expect(movie.reviews.results.length).toBeGreaterThanOrEqual(0);
|
|
36
|
+
});
|
|
28
37
|
it("(MOVIE ALTERNATIVE TITLES) should get movie alternative titles", async () => {
|
|
29
38
|
const movie_id = 550; // Fight Club
|
|
30
39
|
const movie_titles = await tmdb.movies.alternative_titles({ movie_id });
|
|
@@ -106,6 +115,16 @@ describe("Movies (integration)", () => {
|
|
|
106
115
|
expect(release_dates.results[0].iso_3166_1).toBeDefined();
|
|
107
116
|
expect(release_dates.results[0].release_dates.length).toBeGreaterThan(0);
|
|
108
117
|
});
|
|
118
|
+
it("(MOVIE REVIEWS) should get movie reviews", async () => {
|
|
119
|
+
const movie_id = 550; // Fight Club
|
|
120
|
+
const reviews = await tmdb.movies.reviews({ movie_id });
|
|
121
|
+
expect(reviews).toBeDefined();
|
|
122
|
+
expect(reviews.results.length).toBeGreaterThan(0);
|
|
123
|
+
expect(reviews.results[0].id).toBeDefined();
|
|
124
|
+
expect(reviews.page).toBe(1);
|
|
125
|
+
expect(reviews.total_results).toBeGreaterThan(0);
|
|
126
|
+
expect(reviews.total_pages).toBeGreaterThan(0);
|
|
127
|
+
});
|
|
109
128
|
it("(MOVIE SIMILAR) should get similar movies", async () => {
|
|
110
129
|
const movie_id = 550;
|
|
111
130
|
const similar = await tmdb.movies.similar({ movie_id });
|
|
@@ -13,9 +13,9 @@ describe("MoviesAPI", () => {
|
|
|
13
13
|
});
|
|
14
14
|
it("should call client.request with the correct parameters", async () => {
|
|
15
15
|
const movie_id = 550;
|
|
16
|
-
const append_to_response = ["credits", "images"];
|
|
17
16
|
const language = "en";
|
|
18
|
-
|
|
17
|
+
const append_to_response = ["credits", "images"];
|
|
18
|
+
await moviesAPI.details({ movie_id, language, append_to_response });
|
|
19
19
|
expect(clientMock.request).toHaveBeenCalledOnce();
|
|
20
20
|
expect(clientMock.request).toHaveBeenCalledWith("/movie/550", {
|
|
21
21
|
movie_id,
|
package/dist/types/movies.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Cast, Collection, Crew, Genre, ImageItem, Keyword, ProductionCompany, ProductionCountry, SpokenLanguage, VideoItem } from "./common";
|
|
1
|
+
import { Cast, Changes, Collection, Crew, Genre, ImageItem, Keyword, ProductionCompany, ProductionCountry, SpokenLanguage, VideoItem } from "./common";
|
|
2
2
|
import { ReleaseType } from "./enums";
|
|
3
|
+
import { PaginatedResponse } from "./params";
|
|
3
4
|
import { ISO3166Country } from "./utility";
|
|
4
5
|
export type MovieDetails = {
|
|
5
6
|
adult: boolean;
|
|
@@ -55,6 +56,7 @@ export type MovieAlternativeTitle = {
|
|
|
55
56
|
iso_3166_1: string;
|
|
56
57
|
type: string;
|
|
57
58
|
};
|
|
59
|
+
export type MovieChanges = Changes;
|
|
58
60
|
export type MovieCredits = {
|
|
59
61
|
id: number;
|
|
60
62
|
cast: Cast[];
|
|
@@ -77,6 +79,8 @@ export type MovieImages = {
|
|
|
77
79
|
logos: ImageItem[];
|
|
78
80
|
posters: ImageItem[];
|
|
79
81
|
};
|
|
82
|
+
export type MovieRecommendations = PaginatedResponse<MovieResultItem>;
|
|
83
|
+
export type MovieSimilar = PaginatedResponse<MovieResultItem>;
|
|
80
84
|
export type MovieReleaseDates = {
|
|
81
85
|
id: number;
|
|
82
86
|
results: MovieReleaseDateResult[];
|
|
@@ -93,6 +97,22 @@ export type MovieReleaseDate = {
|
|
|
93
97
|
note: string;
|
|
94
98
|
descriptors: any[];
|
|
95
99
|
};
|
|
100
|
+
export type MovieReviews = PaginatedResponse<MovieReview>;
|
|
101
|
+
export type MovieReview = {
|
|
102
|
+
author: string;
|
|
103
|
+
author_details: MovieReviewAuthorDetails;
|
|
104
|
+
content: string;
|
|
105
|
+
created_at: string;
|
|
106
|
+
id: string;
|
|
107
|
+
updated_at: string;
|
|
108
|
+
url: string;
|
|
109
|
+
};
|
|
110
|
+
export type MovieReviewAuthorDetails = {
|
|
111
|
+
name: string;
|
|
112
|
+
username: string;
|
|
113
|
+
avatar_path?: string;
|
|
114
|
+
rating?: number;
|
|
115
|
+
};
|
|
96
116
|
export type MovieTranslations = {
|
|
97
117
|
id: number;
|
|
98
118
|
translations: MovieTranslationResults[];
|
|
@@ -130,3 +150,22 @@ export type WatchProviderItem = {
|
|
|
130
150
|
provider_name: string;
|
|
131
151
|
display_priority: number;
|
|
132
152
|
};
|
|
153
|
+
/** Append To Response */
|
|
154
|
+
export type MovieAppendToResponseNamespace = "alternative_titles" | "changes" | "credits" | "external_ids" | "images" | "keywords" | "recommendations" | "release_dates" | "reviews" | "similar" | "translations" | "videos";
|
|
155
|
+
export type MovieAppendableMap = {
|
|
156
|
+
alternative_titles: MovieAlternativeTitles;
|
|
157
|
+
changes: MovieChanges;
|
|
158
|
+
credits: MovieCredits;
|
|
159
|
+
external_ids: MovieExternalIDs;
|
|
160
|
+
images: MovieImages;
|
|
161
|
+
keywords: MovieKeywords;
|
|
162
|
+
recommendations: MovieRecommendations;
|
|
163
|
+
release_dates: MovieReleaseDates;
|
|
164
|
+
reviews: MovieReviews;
|
|
165
|
+
similar: MovieSimilar;
|
|
166
|
+
translations: MovieTranslations;
|
|
167
|
+
videos: MovieVideos;
|
|
168
|
+
};
|
|
169
|
+
export type MovieDetailsWithAppends<T extends readonly MovieAppendToResponseNamespace[]> = MovieDetails & {
|
|
170
|
+
[K in T[number]]: MovieAppendableMap[K];
|
|
171
|
+
};
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CountryISO3166_1 } from "./countries";
|
|
2
2
|
import { LanguageISO6391 } from "./lang";
|
|
3
|
+
import { MovieAppendToResponseNamespace } from "./movies";
|
|
3
4
|
export type PaginatedResponse<T> = {
|
|
4
5
|
page: number;
|
|
5
6
|
total_pages: number;
|
|
@@ -22,7 +23,7 @@ export type MovieListParams = {
|
|
|
22
23
|
};
|
|
23
24
|
export type MovieDetailsParams = {
|
|
24
25
|
movie_id: number;
|
|
25
|
-
append_to_response?:
|
|
26
|
+
append_to_response?: MovieAppendToResponseNamespace[];
|
|
26
27
|
language?: LanguageISO6391;
|
|
27
28
|
};
|
|
28
29
|
export type MovieAlternativeTitlesParams = {
|
|
@@ -58,3 +59,4 @@ export type MovieRecommendationsParams = {
|
|
|
58
59
|
};
|
|
59
60
|
export type MovieSimilarParams = MovieRecommendationsParams;
|
|
60
61
|
export type MovieVideosParams = MovieCreditsParams;
|
|
62
|
+
export type MovieReviewsParams = MovieRecommendationsParams;
|
package/package.json
CHANGED