@tdanks2000/tmdb-wrapper 1.1.2 → 1.3.1

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.
Files changed (61) hide show
  1. package/dist/index.cjs +1598 -0
  2. package/dist/index.d.cts +2812 -0
  3. package/dist/index.d.cts.map +1 -0
  4. package/dist/index.d.mts +2812 -0
  5. package/dist/index.d.mts.map +1 -0
  6. package/dist/index.mjs +1563 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +70 -61
  9. package/dist/@types/endpoints/account.js +0 -2
  10. package/dist/@types/endpoints/certification.js +0 -2
  11. package/dist/@types/endpoints/changes.js +0 -2
  12. package/dist/@types/endpoints/collection.js +0 -2
  13. package/dist/@types/endpoints/companies.js +0 -2
  14. package/dist/@types/endpoints/configuration.js +0 -101
  15. package/dist/@types/endpoints/credits.js +0 -2
  16. package/dist/@types/endpoints/discover.js +0 -2
  17. package/dist/@types/endpoints/find.js +0 -2
  18. package/dist/@types/endpoints/genre.js +0 -2
  19. package/dist/@types/endpoints/index.js +0 -38
  20. package/dist/@types/endpoints/keywords.js +0 -2
  21. package/dist/@types/endpoints/movies.js +0 -12
  22. package/dist/@types/endpoints/networks.js +0 -2
  23. package/dist/@types/endpoints/options.js +0 -2
  24. package/dist/@types/endpoints/people.js +0 -2
  25. package/dist/@types/endpoints/review.js +0 -2
  26. package/dist/@types/endpoints/search.js +0 -2
  27. package/dist/@types/endpoints/trending.js +0 -2
  28. package/dist/@types/endpoints/tvEpisode.js +0 -2
  29. package/dist/@types/endpoints/tvSeasons.js +0 -2
  30. package/dist/@types/endpoints/tvShows.js +0 -2
  31. package/dist/@types/endpoints/watchProviders.js +0 -2
  32. package/dist/@types/index.js +0 -19
  33. package/dist/@types/models/baseEndpoint.js +0 -11
  34. package/dist/@types/models/index.js +0 -17
  35. package/dist/@types/types.js +0 -2
  36. package/dist/endpoints/account.js +0 -25
  37. package/dist/endpoints/certification.js +0 -32
  38. package/dist/endpoints/changes.js +0 -42
  39. package/dist/endpoints/collections.js +0 -50
  40. package/dist/endpoints/companies.js +0 -42
  41. package/dist/endpoints/configuration.js +0 -25
  42. package/dist/endpoints/credits.js +0 -26
  43. package/dist/endpoints/discover.js +0 -35
  44. package/dist/endpoints/find.js +0 -27
  45. package/dist/endpoints/genre.js +0 -34
  46. package/dist/endpoints/index.js +0 -37
  47. package/dist/endpoints/keywords.js +0 -36
  48. package/dist/endpoints/movies.js +0 -198
  49. package/dist/endpoints/networks.js +0 -42
  50. package/dist/endpoints/people.js +0 -119
  51. package/dist/endpoints/review.js +0 -26
  52. package/dist/endpoints/search.js +0 -75
  53. package/dist/endpoints/trending.js +0 -29
  54. package/dist/endpoints/tvEpisodes.js +0 -98
  55. package/dist/endpoints/tvSeasons.js +0 -109
  56. package/dist/endpoints/tvShows.js +0 -230
  57. package/dist/endpoints/watchProviders.js +0 -46
  58. package/dist/index.js +0 -46
  59. package/dist/utils/api.js +0 -61
  60. package/dist/utils/getimagePath.js +0 -50
  61. package/dist/utils/index.js +0 -18
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TvSeasonsEndpoint = void 0;
4
- const _types_1 = require("../@types");
5
- const BASE_SEASON = (seasonSelection) => {
6
- return `/tv/${seasonSelection.tvShowID}/season/${seasonSelection.seasonNumber}`;
7
- };
8
- /**
9
- * Represents an endpoint for accessing TV season-related information.
10
- */
11
- class TvSeasonsEndpoint extends _types_1.BaseEndpoint {
12
- /**
13
- * Constructs a new TvSeasonsEndpoint instance.
14
- * @param {string} access_token - The access token used for authentication.
15
- */
16
- constructor(access_token) {
17
- super(access_token);
18
- this.access_token = access_token;
19
- }
20
- /**
21
- * Retrieves details of a specific TV season asynchronously.
22
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
23
- * @param {AppendToResponseTvSeasonKey[]} [appendToResponse] - Additional data to append to the response.
24
- * @param {LanguageOption} [options] - Optional parameters for specifying the language.
25
- * @returns {Promise<AppendToResponse<SeasonDetails, AppendToResponseTvSeasonKey[], 'tvSeason'>>}
26
- * A Promise that resolves with the details of the TV season.
27
- */
28
- async details(seasonSelection, appendToResponse, options) {
29
- const combinedOptions = {
30
- append_to_response: appendToResponse
31
- ? appendToResponse.join(",")
32
- : undefined,
33
- ...options,
34
- };
35
- return await this.api.get(`${BASE_SEASON(seasonSelection)}`, combinedOptions);
36
- }
37
- /**
38
- * Retrieves aggregate credits for a specific TV season asynchronously.
39
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
40
- * @param {LanguageOption} [options] - Optional parameters for specifying the language.
41
- * @returns {Promise<AggregateCredits>} A Promise that resolves with the aggregate credits for the TV season.
42
- */
43
- async aggregateCredits(seasonSelection, options) {
44
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/aggregate_credits`, options);
45
- }
46
- /**
47
- * Retrieves changes related to a specific TV season asynchronously.
48
- * @param {number} seasonId - The ID of the TV season.
49
- * @param {ChangeOption} [options] - Optional parameters for specifying changes.
50
- * @returns {Promise<Changes<TvSeasonChangeValue>>} A Promise that resolves with the changes related to the TV season.
51
- */
52
- async changes(seasonId, options) {
53
- return await this.api.get(`/tv/season/${seasonId}/changes`, options);
54
- }
55
- /**
56
- * Retrieves credits for a specific TV season asynchronously.
57
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
58
- * @param {LanguageOption} [options] - Optional parameters for specifying the language.
59
- * @returns {Promise<Credits>} A Promise that resolves with the credits for the TV season.
60
- */
61
- async credits(seasonSelection, options) {
62
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/credits`, options);
63
- }
64
- /**
65
- * Retrieves external IDs for a specific TV season asynchronously.
66
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
67
- * @param {LanguageOption} [options] - Optional parameters for specifying the language.
68
- * @returns {Promise<ExternalIds>} A Promise that resolves with the external IDs for the TV season.
69
- */
70
- async externalIds(seasonSelection, options) {
71
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/external_ids`, options);
72
- }
73
- /**
74
- * Retrieves images for a specific TV season asynchronously.
75
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
76
- * @param {TvSeasonImageSearchOptions} [options] - Optional parameters for specifying image search options.
77
- * @returns {Promise<Images>} A Promise that resolves with the images for the TV season.
78
- */
79
- async images(seasonSelection, options) {
80
- const computedOptions = {
81
- include_image_language: options?.include_image_language?.join(","),
82
- language: options?.language,
83
- };
84
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/images`, computedOptions);
85
- }
86
- /**
87
- * Retrieves videos for a specific TV season asynchronously.
88
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
89
- * @param {TvSeasonVideoSearchOptions} [options] - Optional parameters for specifying video search options.
90
- * @returns {Promise<Videos>} A Promise that resolves with the videos for the TV season.
91
- */
92
- async videos(seasonSelection, options) {
93
- const computedOptions = {
94
- include_video_language: options?.include_video_language?.join(","),
95
- language: options?.language,
96
- };
97
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/videos`, computedOptions);
98
- }
99
- /**
100
- * Retrieves translations for a specific TV season asynchronously.
101
- * @param {SeasonSelection} seasonSelection - The selection criteria for the TV season.
102
- * @param {LanguageOption} [options] - Optional parameters for specifying the language.
103
- * @returns {Promise<Translations>} A Promise that resolves with the translations for the TV season.
104
- */
105
- async translations(seasonSelection, options) {
106
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/translations`, options);
107
- }
108
- }
109
- exports.TvSeasonsEndpoint = TvSeasonsEndpoint;
@@ -1,230 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TvShowsEndpoint = void 0;
4
- const _types_1 = require("../@types");
5
- const BASE_TV = "/tv";
6
- /**
7
- * Represents an endpoint for accessing TV show-related information.
8
- */
9
- class TvShowsEndpoint extends _types_1.BaseEndpoint {
10
- /**
11
- * Constructs a new TvShowsEndpoint instance.
12
- * @param {string} access_token - The access token used for authentication.
13
- */
14
- constructor(access_token) {
15
- super(access_token);
16
- this.access_token = access_token;
17
- }
18
- /**
19
- * Retrieves details of a specific TV show asynchronously.
20
- * @param {number} id - The ID of the TV show.
21
- * @param {AppendToResponseTvKey[]} [appendToResponse] - Additional data to append to the response.
22
- * @param {string} [language] - The language for the response.
23
- * @returns {Promise<AppendToResponse<TvShowDetails, AppendToResponseTvKey[], 'tvShow'>>}
24
- * A Promise that resolves with the details of the TV show.
25
- */
26
- async details(id, appendToResponse, language) {
27
- const options = {
28
- append_to_response: appendToResponse
29
- ? appendToResponse.join(",")
30
- : undefined,
31
- language: language,
32
- };
33
- return await this.api.get(`${BASE_TV}/${id}`, options);
34
- }
35
- /**
36
- * Retrieves alternative titles of a specific TV show asynchronously.
37
- * @param {number} id - The ID of the TV show.
38
- * @returns {Promise<AlternativeTitles>} A Promise that resolves with the alternative titles of the TV show.
39
- */
40
- async alternativeTitles(id) {
41
- return await this.api.get(`${BASE_TV}/${id}/alternative_titles`);
42
- }
43
- /**
44
- * Retrieves changes for a specific TV show asynchronously.
45
- * @param {number} id - The ID of the TV show.
46
- * @param {ChangeOption} [options] - Additional options for the request.
47
- * @returns {Promise<Changes<TvShowChangeValue>>}
48
- * A Promise that resolves with the changes for the TV show.
49
- */
50
- async changes(id, options) {
51
- return await this.api.get(`${BASE_TV}/${id}/changes`, options);
52
- }
53
- /**
54
- * Retrieves content ratings for a specific TV show asynchronously.
55
- * @param {number} id - The ID of the TV show.
56
- * @returns {Promise<ContentRatings>} A Promise that resolves with the content ratings of the TV show.
57
- */
58
- async contentRatings(id) {
59
- return await this.api.get(`${BASE_TV}/${id}/content_ratings`);
60
- }
61
- /**
62
- * Retrieves aggregate credits for a specific TV show asynchronously.
63
- * @param {number} id - The ID of the TV show.
64
- * @param {LanguageOption} [options] - Additional options for the request.
65
- * @returns {Promise<AggregateCredits>} A Promise that resolves with the aggregate credits of the TV show.
66
- */
67
- async aggregateCredits(id, options) {
68
- return await this.api.get(`${BASE_TV}/${id}/aggregate_credits`, options);
69
- }
70
- /**
71
- * Retrieves credits for a specific TV show asynchronously.
72
- * @param {number} id - The ID of the TV show.
73
- * @param {LanguageOption} [options] - Additional options for the request.
74
- * @returns {Promise<Credits>} A Promise that resolves with the credits of the TV show.
75
- */
76
- async credits(id, options) {
77
- return await this.api.get(`${BASE_TV}/${id}/credits`, options);
78
- }
79
- /**
80
- * Retrieves details of a specific season of a TV show asynchronously.
81
- * @param {number} tvId - The ID of the TV show.
82
- * @param {number} seasonNumber - The season number.
83
- * @returns {Promise<SeasonDetails>} A Promise that resolves with the details of the season.
84
- */
85
- async season(tvId, seasonNumber) {
86
- return await this.api.get(`${BASE_TV}/${tvId}/season/${seasonNumber}`);
87
- }
88
- /**
89
- * Retrieves episode groups for a specific TV show asynchronously.
90
- * @param {number} id - The ID of the TV show.
91
- * @returns {Promise<EpisodeGroups>} A Promise that resolves with the episode groups of the TV show.
92
- */
93
- async episodeGroups(id) {
94
- return await this.api.get(`${BASE_TV}/${id}/episode_groups`);
95
- }
96
- /**
97
- * Retrieves external IDs for a specific TV show asynchronously.
98
- * @param {number} id - The ID of the TV show.
99
- * @returns {Promise<ExternalIds>} A Promise that resolves with the external IDs of the TV show.
100
- */
101
- async externalIds(id) {
102
- return await this.api.get(`${BASE_TV}/${id}/external_ids`);
103
- }
104
- /**
105
- * Retrieves images for a specific TV show asynchronously.
106
- * @param {number} id - The ID of the TV show.
107
- * @param {TvShowImageOptions} [options] - Additional options for the request.
108
- * @returns {Promise<Images>} A Promise that resolves with the images of the TV show.
109
- */
110
- async images(id, options) {
111
- const computedOptions = {
112
- include_image_language: options?.include_image_language?.join(","),
113
- language: options?.language,
114
- };
115
- return await this.api.get(`${BASE_TV}/${id}/images`, computedOptions);
116
- }
117
- /**
118
- * Retrieves keywords for a specific TV show asynchronously.
119
- * @param {number} id - The ID of the TV show.
120
- * @returns {Promise<Keywords>} A Promise that resolves with the keywords of the TV show.
121
- */
122
- async keywords(id) {
123
- return await this.api.get(`${BASE_TV}/${id}/keywords`);
124
- }
125
- /**
126
- * Retrieves recommendations for a specific TV show asynchronously.
127
- * @param {number} id - The ID of the TV show.
128
- * @param {LanguageOption & PageOption} [options] - Additional options for the request.
129
- * @returns {Promise<Recommendations>} A Promise that resolves with the recommendations for the TV show.
130
- */
131
- async recommendations(id, options) {
132
- return await this.api.get(`${BASE_TV}/${id}/recommendations`, options);
133
- }
134
- /**
135
- * Retrieves reviews for a specific TV show asynchronously.
136
- * @param {number} id - The ID of the TV show.
137
- * @param {LanguageOption & PageOption} [options] - Additional options for the request.
138
- * @returns {Promise<Reviews>} A Promise that resolves with the reviews of the TV show.
139
- */
140
- async reviews(id, options) {
141
- return await this.api.get(`${BASE_TV}/${id}/reviews`, options);
142
- }
143
- /**
144
- * Retrieves information about whether the TV show was screened theatrically asynchronously.
145
- * @param {number} id - The ID of the TV show.
146
- * @returns {Promise<ScreenedTheatrically>} A Promise that resolves with information about theatrical screenings.
147
- */
148
- async screenedTheatrically(id) {
149
- return await this.api.get(`${BASE_TV}/${id}/screened_theatrically`);
150
- }
151
- /**
152
- * Retrieves similar TV shows for a specific TV show asynchronously.
153
- * @param {number} id - The ID of the TV show.
154
- * @param {LanguageOption & PageOption} [options] - Additional options for the request.
155
- * @returns {Promise<Similartv>} A Promise that resolves with the similar TV shows.
156
- */
157
- async similar(id, options) {
158
- return await this.api.get(`${BASE_TV}/${id}/similar`, options);
159
- }
160
- /**
161
- * Retrieves translations for a specific TV show asynchronously.
162
- * @param {number} id - The ID of the TV show.
163
- * @returns {Promise<Translations>} A Promise that resolves with the translations of the TV show.
164
- */
165
- async translations(id) {
166
- return await this.api.get(`${BASE_TV}/${id}/translations`);
167
- }
168
- /**
169
- * Retrieves videos for a specific TV show asynchronously.
170
- * @param {number} id - The ID of the TV show.
171
- * @param {TvShowVideoOptions} [options] - Additional options for the request.
172
- * @returns {Promise<Videos>} A Promise that resolves with the videos of the TV show.
173
- */
174
- async videos(id, options) {
175
- const computedOptions = {
176
- include_video_language: options?.include_video_language?.join(","),
177
- language: options?.language,
178
- };
179
- return await this.api.get(`${BASE_TV}/${id}/videos`, computedOptions);
180
- }
181
- /**
182
- * Retrieves watch providers for a specific TV show asynchronously.
183
- * Powered by JustWatch.
184
- * @param {number} id - The ID of the TV show.
185
- * @returns {Promise<WatchProviders>} A Promise that resolves with the watch providers of the TV show.
186
- */
187
- async watchProviders(id) {
188
- return await this.api.get(`${BASE_TV}/${id}/watch/providers`);
189
- }
190
- /**
191
- * Retrieves the latest TV show asynchronously.
192
- * @returns {Promise<Latesttv>} A Promise that resolves with the latest TV show.
193
- */
194
- async latest() {
195
- return await this.api.get(`${BASE_TV}/latest`);
196
- }
197
- /**
198
- * Retrieves TV shows that are currently on the air asynchronously.
199
- * @param {PageOption & LanguageOption & TimezoneOption} [options] - Additional options for the request.
200
- * @returns {Promise<OnTheAir>} A Promise that resolves with TV shows currently on the air.
201
- */
202
- async onTheAir(options) {
203
- return await this.api.get(`${BASE_TV}/on_the_air`, options);
204
- }
205
- /**
206
- * Retrieves TV shows that are airing today asynchronously.
207
- * @param {PageOption & LanguageOption & TimezoneOption} [options] - Additional options for the request.
208
- * @returns {Promise<tvAiringToday>} A Promise that resolves with TV shows airing today.
209
- */
210
- async airingToday(options) {
211
- return await this.api.get(`${BASE_TV}/airing_today`, options);
212
- }
213
- /**
214
- * Retrieves popular TV shows asynchronously.
215
- * @param {PageOption & LanguageOption} [options] - Additional options for the request.
216
- * @returns {Promise<Populartv>} A Promise that resolves with popular TV shows.
217
- */
218
- async popular(options) {
219
- return await this.api.get(`${BASE_TV}/popular`, options);
220
- }
221
- /**
222
- * Retrieves top-rated TV shows asynchronously.
223
- * @param {PageOption & LanguageOption} [options] - Additional options for the request.
224
- * @returns {Promise<TopRatedtv>} A Promise that resolves with top-rated TV shows.
225
- */
226
- async topRated(options) {
227
- return await this.api.get(`${BASE_TV}/top_rated`, options);
228
- }
229
- }
230
- exports.TvShowsEndpoint = TvShowsEndpoint;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WatchProvidersEndpoint = void 0;
4
- const _types_1 = require("../@types");
5
- /**
6
- * Represents an endpoint for accessing watch provider information.
7
- */
8
- class WatchProvidersEndpoint extends _types_1.BaseEndpoint {
9
- /**
10
- * Constructs a new WatchProvidersEndpoint instance.
11
- * @param {string} access_token - The access token used for authentication.
12
- */
13
- constructor(access_token) {
14
- super(access_token);
15
- this.access_token = access_token;
16
- }
17
- /**
18
- * Retrieves a list of all available watch providers (streaming services).
19
- * @returns {Promise<WatchProviders>} A Promise that resolves with the list of watch providers.
20
- */
21
- async available() {
22
- return await this.api.get("/watch/providers/movie");
23
- }
24
- /**
25
- * Retrieves a list of available regions for watch providers.
26
- * @returns {Promise<WatchRegionsResponse>} A Promise that resolves with the list of available regions.
27
- */
28
- async regions() {
29
- return await this.api.get("/watch/providers/regions");
30
- }
31
- /**
32
- * Retrieves a list of watch providers for movies.
33
- * @returns {Promise<WatchProviders>} A Promise that resolves with the list of movie watch providers.
34
- */
35
- async movie() {
36
- return await this.api.get("/watch/providers/movie");
37
- }
38
- /**
39
- * Retrieves a list of watch providers for TV shows.
40
- * @returns {Promise<WatchProviders>} A Promise that resolves with the list of TV watch providers.
41
- */
42
- async tv() {
43
- return await this.api.get("/watch/providers/tv");
44
- }
45
- }
46
- exports.WatchProvidersEndpoint = WatchProvidersEndpoint;
package/dist/index.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.TMDB = void 0;
18
- const endpoints_1 = require("./endpoints");
19
- class TMDB {
20
- constructor(auth) {
21
- this.account = new endpoints_1.AccountEndpoint(auth);
22
- this.certification = new endpoints_1.CertificationEndpoint(auth);
23
- this.changes = new endpoints_1.ChangeEndpoint(auth);
24
- this.collections = new endpoints_1.CollectionsEndpoint(auth);
25
- this.companies = new endpoints_1.CompaniesEndpoint(auth);
26
- this.configuration = new endpoints_1.ConfigurationEndpoint(auth);
27
- this.credits = new endpoints_1.CreditsEndpoint(auth);
28
- this.discover = new endpoints_1.DiscoverEndpoint(auth);
29
- this.find = new endpoints_1.FindEndpoint(auth);
30
- this.genre = new endpoints_1.GenreEndpoint(auth);
31
- this.keywords = new endpoints_1.KeywordsEndpoint(auth);
32
- this.movies = new endpoints_1.MoviesEndpoint(auth);
33
- this.networks = new endpoints_1.NetworksEndpoint(auth);
34
- this.people = new endpoints_1.PeopleEndpoint(auth);
35
- this.review = new endpoints_1.ReviewEndpoint(auth);
36
- this.search = new endpoints_1.SearchEndpoint(auth);
37
- this.trending = new endpoints_1.TrendingEndpoint(auth);
38
- this.tvEpisodes = new endpoints_1.TvEpisodesEndpoint(auth);
39
- this.tvSeasons = new endpoints_1.TvSeasonsEndpoint(auth);
40
- this.tvShows = new endpoints_1.TvShowsEndpoint(auth);
41
- this.watchProviders = new endpoints_1.WatchProvidersEndpoint(auth);
42
- }
43
- }
44
- exports.TMDB = TMDB;
45
- __exportStar(require("./@types"), exports);
46
- __exportStar(require("./utils"), exports);
package/dist/utils/api.js DELETED
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseOptions = exports.API = void 0;
4
- const BASE_URL_V3 = "https://api.themoviedb.org/3";
5
- class API {
6
- constructor(auth) {
7
- if (typeof auth === "string") {
8
- this.accessToken = auth;
9
- }
10
- else {
11
- this.apiKey = auth.apiKey;
12
- this.accessToken = auth.accessToken;
13
- }
14
- }
15
- /**
16
- * Generic GET:
17
- * @template T — response type
18
- * @template O — options (query params) type
19
- */
20
- async get(path, options) {
21
- const rawOptions = {
22
- ...(options ?? {}),
23
- ...(this.apiKey ? { api_key: this.apiKey } : {}),
24
- };
25
- const params = (0, exports.parseOptions)(rawOptions);
26
- const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
27
- method: "GET",
28
- headers: {
29
- ...(this.accessToken
30
- ? { Authorization: `Bearer ${this.accessToken}` }
31
- : {}),
32
- "Content-Type": "application/json;charset=utf-8",
33
- },
34
- });
35
- if (!response.ok) {
36
- const error = (await response.json());
37
- return Promise.reject(error);
38
- }
39
- return (await response.json());
40
- }
41
- }
42
- exports.API = API;
43
- const parseOptions = (options) => {
44
- if (!options)
45
- return "";
46
- const entries = [];
47
- for (const [key, value] of Object.entries(options)) {
48
- if (value === undefined || value === null)
49
- continue;
50
- if (Array.isArray(value)) {
51
- for (const item of value) {
52
- entries.push([key, String(item)]);
53
- }
54
- }
55
- else {
56
- entries.push([key, String(value)]);
57
- }
58
- }
59
- return new URLSearchParams(entries).toString();
60
- };
61
- exports.parseOptions = parseOptions;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImageFormats = exports.ImageSizes = exports.getFullImagePath = void 0;
4
- /**
5
- * Utility method to construct full url for image
6
- * based on configuration
7
- *
8
- * https://developers.themoviedb.org/3/getting-started/images
9
- * @param {string} baseUrl base image url (e.g., 'https://image.tmdb.org/t/p/')
10
- * @param {string} fileSize file size (e.g., 'original', 'w500')
11
- * @param {string} imagePath raw image path
12
- * @param {string} format override image format (e.g., 'svg', 'png', 'jpg')
13
- * @returns {string} The complete image URL
14
- */
15
- const getFullImagePath = (baseUrl, fileSize, imagePath, format) => {
16
- if (!imagePath)
17
- return "";
18
- // Handle case where imagePath doesn't have an extension
19
- const hasExtension = imagePath.includes(".");
20
- if (hasExtension) {
21
- const imagePathArr = imagePath.split(".");
22
- const imageFormat = format || imagePathArr[1];
23
- return `${baseUrl}${fileSize}${imagePathArr[0]}.${imageFormat}`;
24
- }
25
- else {
26
- // If no extension in path, use provided format or default to jpg
27
- const imageFormat = format || "jpg";
28
- return `${baseUrl}${fileSize}${imagePath}.${imageFormat}`;
29
- }
30
- };
31
- exports.getFullImagePath = getFullImagePath;
32
- /**
33
- * Common image sizes available in TMDB
34
- */
35
- exports.ImageSizes = {
36
- ORIGINAL: "original",
37
- W500: "w500",
38
- W300: "w300",
39
- W185: "w185",
40
- W92: "w92",
41
- H632: "h632",
42
- };
43
- /**
44
- * Image formats supported by TMDB
45
- */
46
- exports.ImageFormats = {
47
- JPG: "jpg",
48
- PNG: "png",
49
- SVG: "svg",
50
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./api"), exports);
18
- __exportStar(require("./getimagePath"), exports);