@tdanks2000/tmdb-wrapper 1.1.1 → 1.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tommy Danks
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,2 +1,101 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangeKeys = exports.StillSizes = exports.ProfileSizes = exports.PosterSizes = exports.LogoSizes = exports.BackdropSizes = void 0;
4
+ var BackdropSizes;
5
+ (function (BackdropSizes) {
6
+ BackdropSizes["W300"] = "w300";
7
+ BackdropSizes["W500"] = "w500";
8
+ BackdropSizes["W780"] = "w780";
9
+ BackdropSizes["W1280"] = "w1280";
10
+ BackdropSizes["ORIGINAL"] = "original";
11
+ })(BackdropSizes || (exports.BackdropSizes = BackdropSizes = {}));
12
+ var LogoSizes;
13
+ (function (LogoSizes) {
14
+ LogoSizes["W45"] = "w45";
15
+ LogoSizes["W92"] = "w92";
16
+ LogoSizes["W154"] = "w154";
17
+ LogoSizes["W185"] = "w185";
18
+ LogoSizes["W300"] = "w300";
19
+ LogoSizes["W500"] = "w500";
20
+ LogoSizes["ORIGINAL"] = "original";
21
+ })(LogoSizes || (exports.LogoSizes = LogoSizes = {}));
22
+ var PosterSizes;
23
+ (function (PosterSizes) {
24
+ PosterSizes["W92"] = "w92";
25
+ PosterSizes["W154"] = "w154";
26
+ PosterSizes["W185"] = "w185";
27
+ PosterSizes["W300"] = "w300";
28
+ PosterSizes["W500"] = "w500";
29
+ PosterSizes["W780"] = "w780";
30
+ PosterSizes["ORIGINAL"] = "original";
31
+ })(PosterSizes || (exports.PosterSizes = PosterSizes = {}));
32
+ var ProfileSizes;
33
+ (function (ProfileSizes) {
34
+ ProfileSizes["W45"] = "w45";
35
+ ProfileSizes["W185"] = "w185";
36
+ ProfileSizes["W632"] = "w632";
37
+ ProfileSizes["ORIGINAL"] = "original";
38
+ })(ProfileSizes || (exports.ProfileSizes = ProfileSizes = {}));
39
+ var StillSizes;
40
+ (function (StillSizes) {
41
+ StillSizes["W92"] = "w92";
42
+ StillSizes["W185"] = "w185";
43
+ StillSizes["W300"] = "w300";
44
+ StillSizes["ORIGINAL"] = "original";
45
+ })(StillSizes || (exports.StillSizes = StillSizes = {}));
46
+ var ChangeKeys;
47
+ (function (ChangeKeys) {
48
+ ChangeKeys["ADULT"] = "adult";
49
+ ChangeKeys["AIR_DATE"] = "air_date";
50
+ ChangeKeys["ALSO_KNOWN_AS"] = "also_known_as";
51
+ ChangeKeys["ALTERNATIVE_TITLES"] = "alternative_titles";
52
+ ChangeKeys["BIOGRAPHY"] = "biography";
53
+ ChangeKeys["BIRTHDAY"] = "birthday";
54
+ ChangeKeys["BUDGET"] = "budget";
55
+ ChangeKeys["CAST"] = "cast";
56
+ ChangeKeys["CERTIFICATIONS"] = "certifications";
57
+ ChangeKeys["CHARACTER_NAMES"] = "character_names";
58
+ ChangeKeys["CREATED_BY"] = "created_by";
59
+ ChangeKeys["CREW"] = "crew";
60
+ ChangeKeys["DEATHDAY"] = "deathday";
61
+ ChangeKeys["EPISODE"] = "episode";
62
+ ChangeKeys["EPISODE_NUMBER"] = "episode_number";
63
+ ChangeKeys["EPISODE_RUN_TIME"] = "episode_run_time";
64
+ ChangeKeys["FREEBASE_ID"] = "freebase_id";
65
+ ChangeKeys["FREEBASE_MID"] = "freebase_mid";
66
+ ChangeKeys["GENERAL"] = "general";
67
+ ChangeKeys["GENRES"] = "genres";
68
+ ChangeKeys["GUEST_STARS"] = "guest_stars";
69
+ ChangeKeys["HOMEPAGE"] = "homepage";
70
+ ChangeKeys["IMAGES"] = "images";
71
+ ChangeKeys["IMDB_ID"] = "imdb_id";
72
+ ChangeKeys["LANGUAGES"] = "languages";
73
+ ChangeKeys["NAME"] = "name";
74
+ ChangeKeys["NETWORK"] = "network";
75
+ ChangeKeys["ORIGIN_COUNTRY"] = "origin_country";
76
+ ChangeKeys["ORIGINAL_NAME"] = "original_name";
77
+ ChangeKeys["ORIGINAL_TITLE"] = "original_title";
78
+ ChangeKeys["OVERVIEW"] = "overview";
79
+ ChangeKeys["PARTS"] = "parts";
80
+ ChangeKeys["PLACE_OF_BIRTH"] = "place_of_birth";
81
+ ChangeKeys["PLOT_KEYWORDS"] = "plot_keywords";
82
+ ChangeKeys["PRODUCTION_CODE"] = "production_code";
83
+ ChangeKeys["PRODUCTION_COMPANIES"] = "production_companies";
84
+ ChangeKeys["PRODUCTION_COUNTRIES"] = "production_countries";
85
+ ChangeKeys["RELEASES"] = "releases";
86
+ ChangeKeys["REVENUE"] = "revenue";
87
+ ChangeKeys["RUNTIME"] = "runtime";
88
+ ChangeKeys["SEASON"] = "season";
89
+ ChangeKeys["SEASON_NUMBER"] = "season_number";
90
+ ChangeKeys["SEASON_REGULAR"] = "season_regular";
91
+ ChangeKeys["SPOKEN_LANGUAGES"] = "spoken_languages";
92
+ ChangeKeys["STATUS"] = "status";
93
+ ChangeKeys["TAGLINE"] = "tagline";
94
+ ChangeKeys["TITLE"] = "title";
95
+ ChangeKeys["TRANSLATIONS"] = "translations";
96
+ ChangeKeys["TVDB_ID"] = "tvdb_id";
97
+ ChangeKeys["TVRAGE_ID"] = "tvrage_id";
98
+ ChangeKeys["TYPE"] = "type";
99
+ ChangeKeys["VIDEO"] = "video";
100
+ ChangeKeys["VIDEOS"] = "videos";
101
+ })(ChangeKeys || (exports.ChangeKeys = ChangeKeys = {}));
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEndpoint = void 0;
4
4
  const utils_1 = require("../../utils");
5
5
  class BaseEndpoint {
6
- constructor(access_token) {
7
- this.access_token = access_token;
8
- this.api = new utils_1.API(access_token);
6
+ constructor(auth) {
7
+ this.auth = auth;
8
+ this.api = new utils_1.API(auth);
9
9
  }
10
10
  }
11
11
  exports.BaseEndpoint = BaseEndpoint;
@@ -12,13 +12,14 @@ class AccountEndpoint extends _types_1.BaseEndpoint {
12
12
  */
13
13
  constructor(access_token) {
14
14
  super(access_token);
15
+ this.access_token = access_token;
15
16
  }
16
17
  /**
17
18
  * Retrieves account details asynchronously.
18
19
  * @returns {Promise<AccountDetails>} A Promise that resolves with the account details.
19
20
  */
20
21
  async details() {
21
- return await this.api.get('/account');
22
+ return await this.api.get("/account");
22
23
  }
23
24
  }
24
25
  exports.AccountEndpoint = AccountEndpoint;
@@ -19,14 +19,14 @@ class CertificationEndpoint extends _types_1.BaseEndpoint {
19
19
  * @returns {Promise<Certifications>} A Promise that resolves with the certifications for movies.
20
20
  */
21
21
  async movies() {
22
- return await this.api.get('/certification/movie/list');
22
+ return await this.api.get("/certification/movie/list");
23
23
  }
24
24
  /**
25
25
  * Retrieves certifications for TV shows asynchronously.
26
26
  * @returns {Promise<Certifications>} A Promise that resolves with the certifications for TV shows.
27
27
  */
28
28
  async tv() {
29
- return await this.api.get('/certification/tv/list');
29
+ return await this.api.get("/certification/tv/list");
30
30
  }
31
31
  }
32
32
  exports.CertificationEndpoint = CertificationEndpoint;
@@ -20,7 +20,7 @@ class ChangeEndpoint extends _types_1.BaseEndpoint {
20
20
  * @returns {Promise<MediaChanges>} A Promise that resolves with the changes in movies.
21
21
  */
22
22
  async movies(options) {
23
- return await this.api.get('/movie/changes', options);
23
+ return await this.api.get("/movie/changes", options);
24
24
  }
25
25
  /**
26
26
  * Retrieves changes in TV shows asynchronously.
@@ -28,7 +28,7 @@ class ChangeEndpoint extends _types_1.BaseEndpoint {
28
28
  * @returns {Promise<MediaChanges>} A Promise that resolves with the changes in TV shows.
29
29
  */
30
30
  async tv(options) {
31
- return await this.api.get('/tv/changes', options);
31
+ return await this.api.get("/tv/changes", options);
32
32
  }
33
33
  /**
34
34
  * Retrieves changes related to persons asynchronously.
@@ -36,7 +36,7 @@ class ChangeEndpoint extends _types_1.BaseEndpoint {
36
36
  * @returns {Promise<MediaChanges>} A Promise that resolves with the changes related to persons.
37
37
  */
38
38
  async person(options) {
39
- return await this.api.get('/person/change', options);
39
+ return await this.api.get("/person/change", options);
40
40
  }
41
41
  }
42
42
  exports.ChangeEndpoint = ChangeEndpoint;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CollectionsEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_COLLECTION = '/collection';
5
+ const BASE_COLLECTION = "/collection";
6
6
  /**
7
7
  * Represents an endpoint for accessing collections and their details.
8
8
  */
@@ -32,7 +32,7 @@ class CollectionsEndpoint extends _types_1.BaseEndpoint {
32
32
  */
33
33
  async images(id, options) {
34
34
  const computedOptions = {
35
- include_image_language: options?.include_image_language?.join(','),
35
+ include_image_language: options?.include_image_language?.join(","),
36
36
  language: options?.language,
37
37
  };
38
38
  return await this.api.get(`${BASE_COLLECTION}/${id}/images`, computedOptions);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DiscoverEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_DISCOVER = '/discover';
5
+ const BASE_DISCOVER = "/discover";
6
6
  /**
7
7
  * Represents an endpoint for discovering movies and TV shows based on various criteria.
8
8
  */
@@ -13,6 +13,7 @@ class DiscoverEndpoint extends _types_1.BaseEndpoint {
13
13
  */
14
14
  constructor(access_token) {
15
15
  super(access_token);
16
+ this.access_token = access_token;
16
17
  }
17
18
  /**
18
19
  * Retrieves a list of movies based on the provided query options asynchronously.
@@ -12,6 +12,7 @@ class FindEndpoint extends _types_1.BaseEndpoint {
12
12
  */
13
13
  constructor(access_token) {
14
14
  super(access_token);
15
+ this.access_token = access_token;
15
16
  }
16
17
  /**
17
18
  * Retrieves media by external ID asynchronously.
@@ -20,7 +20,7 @@ class GenreEndpoint extends _types_1.BaseEndpoint {
20
20
  * @returns {Promise<Genres>} A Promise that resolves with the genre information for movies.
21
21
  */
22
22
  async movies(options) {
23
- return await this.api.get('/genre/movie/list', options);
23
+ return await this.api.get("/genre/movie/list", options);
24
24
  }
25
25
  /**
26
26
  * Retrieves genre information for TV shows asynchronously.
@@ -28,7 +28,7 @@ class GenreEndpoint extends _types_1.BaseEndpoint {
28
28
  * @returns {Promise<Genres>} A Promise that resolves with the genre information for TV shows.
29
29
  */
30
30
  async tv(options) {
31
- return await this.api.get('/genre/tv/list', options);
31
+ return await this.api.get("/genre/tv/list", options);
32
32
  }
33
33
  }
34
34
  exports.GenreEndpoint = GenreEndpoint;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KeywordsEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_KEYWORD = '/keyword';
5
+ const BASE_KEYWORD = "/keyword";
6
6
  /**
7
7
  * Represents an endpoint for accessing keyword details and related movies.
8
8
  */
@@ -13,6 +13,7 @@ class KeywordsEndpoint extends _types_1.BaseEndpoint {
13
13
  */
14
14
  constructor(access_token) {
15
15
  super(access_token);
16
+ this.access_token = access_token;
16
17
  }
17
18
  /**
18
19
  * Retrieves details of a specific keyword asynchronously.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MoviesEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_MOVIE = '/movie';
5
+ const BASE_MOVIE = "/movie";
6
6
  /**
7
7
  * Represents an endpoint for accessing movie-related information.
8
8
  */
@@ -24,7 +24,9 @@ class MoviesEndpoint extends _types_1.BaseEndpoint {
24
24
  */
25
25
  async details(id, appendToResponse, language) {
26
26
  const options = {
27
- append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
27
+ append_to_response: appendToResponse
28
+ ? appendToResponse.join(",")
29
+ : undefined,
28
30
  language: language,
29
31
  };
30
32
  return await this.api.get(`${BASE_MOVIE}/${id}`, options);
@@ -71,7 +73,7 @@ class MoviesEndpoint extends _types_1.BaseEndpoint {
71
73
  */
72
74
  async images(id, options) {
73
75
  const computedOptions = {
74
- include_image_language: options?.include_image_language?.join(','),
76
+ include_image_language: options?.include_image_language?.join(","),
75
77
  language: options?.language,
76
78
  };
77
79
  return await this.api.get(`${BASE_MOVIE}/${id}/images`, computedOptions);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PeopleEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_PERSON = '/person';
5
+ const BASE_PERSON = "/person";
6
6
  /**
7
7
  * Represents an endpoint for accessing information about people.
8
8
  */
@@ -13,6 +13,7 @@ class PeopleEndpoint extends _types_1.BaseEndpoint {
13
13
  */
14
14
  constructor(access_token) {
15
15
  super(access_token);
16
+ this.access_token = access_token;
16
17
  }
17
18
  /**
18
19
  * Retrieves details of a specific person asynchronously.
@@ -23,7 +24,9 @@ class PeopleEndpoint extends _types_1.BaseEndpoint {
23
24
  */
24
25
  async details(id, appendToResponse, language) {
25
26
  const options = {
26
- append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
27
+ append_to_response: appendToResponse
28
+ ? appendToResponse.join(",")
29
+ : undefined,
27
30
  language: language,
28
31
  };
29
32
  return await this.api.get(`${BASE_PERSON}/${id}`, options);
@@ -12,6 +12,7 @@ class ReviewEndpoint extends _types_1.BaseEndpoint {
12
12
  */
13
13
  constructor(access_token) {
14
14
  super(access_token);
15
+ this.access_token = access_token;
15
16
  }
16
17
  /**
17
18
  * Retrieves details of a specific review asynchronously.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SearchEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_SEARCH = '/search';
5
+ const BASE_SEARCH = "/search";
6
6
  /**
7
7
  * Represents an endpoint for performing various search operations.
8
8
  */
@@ -12,6 +12,7 @@ class TrendingEndpoint extends _types_1.BaseEndpoint {
12
12
  */
13
13
  constructor(access_token) {
14
14
  super(access_token);
15
+ this.access_token = access_token;
15
16
  }
16
17
  /**
17
18
  * Retrieves trending content asynchronously based on media type and time window.
@@ -15,6 +15,7 @@ class TvEpisodesEndpoint extends _types_1.BaseEndpoint {
15
15
  */
16
16
  constructor(access_token) {
17
17
  super(access_token);
18
+ this.access_token = access_token;
18
19
  }
19
20
  /**
20
21
  * Retrieves details of a specific TV episode asynchronously.
@@ -26,7 +27,9 @@ class TvEpisodesEndpoint extends _types_1.BaseEndpoint {
26
27
  */
27
28
  async details(episodeSelection, appendToResponse, options) {
28
29
  const combinedOptions = {
29
- append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
30
+ append_to_response: appendToResponse
31
+ ? appendToResponse.join(",")
32
+ : undefined,
30
33
  ...options,
31
34
  };
32
35
  return await this.api.get(`${BASE_EPISODE(episodeSelection)}`, combinedOptions);
@@ -65,7 +68,7 @@ class TvEpisodesEndpoint extends _types_1.BaseEndpoint {
65
68
  */
66
69
  async images(episodeSelection, options) {
67
70
  const computedOptions = {
68
- include_image_language: options?.include_image_language?.join(','),
71
+ include_image_language: options?.include_image_language?.join(","),
69
72
  language: options?.language,
70
73
  };
71
74
  return await this.api.get(`${BASE_EPISODE(episodeSelection)}/images`, computedOptions);
@@ -86,7 +89,7 @@ class TvEpisodesEndpoint extends _types_1.BaseEndpoint {
86
89
  */
87
90
  async videos(episodeSelection, options) {
88
91
  const computedOptions = {
89
- include_video_language: options?.include_video_language?.join(','),
92
+ include_video_language: options?.include_video_language?.join(","),
90
93
  language: options?.language,
91
94
  };
92
95
  return await this.api.get(`${BASE_EPISODE(episodeSelection)}/videos`, computedOptions);
@@ -15,6 +15,7 @@ class TvSeasonsEndpoint extends _types_1.BaseEndpoint {
15
15
  */
16
16
  constructor(access_token) {
17
17
  super(access_token);
18
+ this.access_token = access_token;
18
19
  }
19
20
  /**
20
21
  * Retrieves details of a specific TV season asynchronously.
@@ -26,7 +27,9 @@ class TvSeasonsEndpoint extends _types_1.BaseEndpoint {
26
27
  */
27
28
  async details(seasonSelection, appendToResponse, options) {
28
29
  const combinedOptions = {
29
- append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
30
+ append_to_response: appendToResponse
31
+ ? appendToResponse.join(",")
32
+ : undefined,
30
33
  ...options,
31
34
  };
32
35
  return await this.api.get(`${BASE_SEASON(seasonSelection)}`, combinedOptions);
@@ -75,7 +78,7 @@ class TvSeasonsEndpoint extends _types_1.BaseEndpoint {
75
78
  */
76
79
  async images(seasonSelection, options) {
77
80
  const computedOptions = {
78
- include_image_language: options?.include_image_language?.join(','),
81
+ include_image_language: options?.include_image_language?.join(","),
79
82
  language: options?.language,
80
83
  };
81
84
  return await this.api.get(`${BASE_SEASON(seasonSelection)}/images`, computedOptions);
@@ -88,7 +91,7 @@ class TvSeasonsEndpoint extends _types_1.BaseEndpoint {
88
91
  */
89
92
  async videos(seasonSelection, options) {
90
93
  const computedOptions = {
91
- include_video_language: options?.include_video_language?.join(','),
94
+ include_video_language: options?.include_video_language?.join(","),
92
95
  language: options?.language,
93
96
  };
94
97
  return await this.api.get(`${BASE_SEASON(seasonSelection)}/videos`, computedOptions);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TvShowsEndpoint = void 0;
4
4
  const _types_1 = require("../@types");
5
- const BASE_TV = '/tv';
5
+ const BASE_TV = "/tv";
6
6
  /**
7
7
  * Represents an endpoint for accessing TV show-related information.
8
8
  */
@@ -25,7 +25,9 @@ class TvShowsEndpoint extends _types_1.BaseEndpoint {
25
25
  */
26
26
  async details(id, appendToResponse, language) {
27
27
  const options = {
28
- append_to_response: appendToResponse ? appendToResponse.join(',') : undefined,
28
+ append_to_response: appendToResponse
29
+ ? appendToResponse.join(",")
30
+ : undefined,
29
31
  language: language,
30
32
  };
31
33
  return await this.api.get(`${BASE_TV}/${id}`, options);
@@ -107,7 +109,7 @@ class TvShowsEndpoint extends _types_1.BaseEndpoint {
107
109
  */
108
110
  async images(id, options) {
109
111
  const computedOptions = {
110
- include_image_language: options?.include_image_language?.join(','),
112
+ include_image_language: options?.include_image_language?.join(","),
111
113
  language: options?.language,
112
114
  };
113
115
  return await this.api.get(`${BASE_TV}/${id}/images`, computedOptions);
@@ -171,7 +173,7 @@ class TvShowsEndpoint extends _types_1.BaseEndpoint {
171
173
  */
172
174
  async videos(id, options) {
173
175
  const computedOptions = {
174
- include_video_language: options?.include_video_language?.join(','),
176
+ include_video_language: options?.include_video_language?.join(","),
175
177
  language: options?.language,
176
178
  };
177
179
  return await this.api.get(`${BASE_TV}/${id}/videos`, computedOptions);
@@ -19,28 +19,28 @@ class WatchProvidersEndpoint extends _types_1.BaseEndpoint {
19
19
  * @returns {Promise<WatchProviders>} A Promise that resolves with the list of watch providers.
20
20
  */
21
21
  async available() {
22
- return await this.api.get('/watch/providers/movie');
22
+ return await this.api.get("/watch/providers/movie");
23
23
  }
24
24
  /**
25
25
  * Retrieves a list of available regions for watch providers.
26
- * @returns {Promise<any>} A Promise that resolves with the list of available regions.
26
+ * @returns {Promise<WatchRegionsResponse>} A Promise that resolves with the list of available regions.
27
27
  */
28
28
  async regions() {
29
- return await this.api.get('/watch/providers/regions');
29
+ return await this.api.get("/watch/providers/regions");
30
30
  }
31
31
  /**
32
32
  * Retrieves a list of watch providers for movies.
33
33
  * @returns {Promise<WatchProviders>} A Promise that resolves with the list of movie watch providers.
34
34
  */
35
35
  async movie() {
36
- return await this.api.get('/watch/providers/movie');
36
+ return await this.api.get("/watch/providers/movie");
37
37
  }
38
38
  /**
39
39
  * Retrieves a list of watch providers for TV shows.
40
40
  * @returns {Promise<WatchProviders>} A Promise that resolves with the list of TV watch providers.
41
41
  */
42
42
  async tv() {
43
- return await this.api.get('/watch/providers/tv');
43
+ return await this.api.get("/watch/providers/tv");
44
44
  }
45
45
  }
46
46
  exports.WatchProvidersEndpoint = WatchProvidersEndpoint;
package/dist/index.js CHANGED
@@ -17,28 +17,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.TMDB = void 0;
18
18
  const endpoints_1 = require("./endpoints");
19
19
  class TMDB {
20
- constructor(access_token) {
21
- this.account = new endpoints_1.AccountEndpoint(access_token);
22
- this.certification = new endpoints_1.CertificationEndpoint(access_token);
23
- this.changes = new endpoints_1.ChangeEndpoint(access_token);
24
- this.collections = new endpoints_1.CollectionsEndpoint(access_token);
25
- this.companies = new endpoints_1.CompaniesEndpoint(access_token);
26
- this.configuration = new endpoints_1.ConfigurationEndpoint(access_token);
27
- this.credits = new endpoints_1.CreditsEndpoint(access_token);
28
- this.discover = new endpoints_1.DiscoverEndpoint(access_token);
29
- this.find = new endpoints_1.FindEndpoint(access_token);
30
- this.genre = new endpoints_1.GenreEndpoint(access_token);
31
- this.keywords = new endpoints_1.KeywordsEndpoint(access_token);
32
- this.movies = new endpoints_1.MoviesEndpoint(access_token);
33
- this.networks = new endpoints_1.NetworksEndpoint(access_token);
34
- this.people = new endpoints_1.PeopleEndpoint(access_token);
35
- this.review = new endpoints_1.ReviewEndpoint(access_token);
36
- this.search = new endpoints_1.SearchEndpoint(access_token);
37
- this.trending = new endpoints_1.TrendingEndpoint(access_token);
38
- this.tvEpisodes = new endpoints_1.TvEpisodesEndpoint(access_token);
39
- this.tvSeasons = new endpoints_1.TvSeasonsEndpoint(access_token);
40
- this.tvShows = new endpoints_1.TvShowsEndpoint(access_token);
41
- this.watchProviders = new endpoints_1.WatchProvidersEndpoint(access_token);
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
42
  }
43
43
  }
44
44
  exports.TMDB = TMDB;
package/dist/utils/api.js CHANGED
@@ -1,28 +1,61 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseOptions = exports.API = void 0;
4
- const BASE_URL_V3 = 'https://api.themoviedb.org/3';
4
+ const BASE_URL_V3 = "https://api.themoviedb.org/3";
5
5
  class API {
6
- constructor(access_token) {
7
- this.access_token = access_token;
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
+ }
8
14
  }
15
+ /**
16
+ * Generic GET:
17
+ * @template T — response type
18
+ * @template O — options (query params) type
19
+ */
9
20
  async get(path, options) {
10
- const params = (0, exports.parseOptions)(options);
21
+ const rawOptions = {
22
+ ...(options ?? {}),
23
+ ...(this.apiKey ? { api_key: this.apiKey } : {}),
24
+ };
25
+ const params = (0, exports.parseOptions)(rawOptions);
11
26
  const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
12
- method: 'GET',
27
+ method: "GET",
13
28
  headers: {
14
- Authorization: `Bearer ${this.access_token}`,
15
- 'Content-Type': 'application/json;charset=utf-8',
29
+ ...(this.accessToken
30
+ ? { Authorization: `Bearer ${this.accessToken}` }
31
+ : {}),
32
+ "Content-Type": "application/json;charset=utf-8",
16
33
  },
17
34
  });
18
35
  if (!response.ok) {
19
- return Promise.reject((await response.json()));
36
+ const error = (await response.json());
37
+ return Promise.reject(error);
20
38
  }
21
39
  return (await response.json());
22
40
  }
23
41
  }
24
42
  exports.API = API;
25
43
  const parseOptions = (options) => {
26
- return options ? new URLSearchParams(Object.entries(options)).toString() : '';
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();
27
60
  };
28
61
  exports.parseOptions = parseOptions;
@@ -14,17 +14,17 @@ exports.ImageFormats = exports.ImageSizes = exports.getFullImagePath = void 0;
14
14
  */
15
15
  const getFullImagePath = (baseUrl, fileSize, imagePath, format) => {
16
16
  if (!imagePath)
17
- return '';
17
+ return "";
18
18
  // Handle case where imagePath doesn't have an extension
19
- const hasExtension = imagePath.includes('.');
19
+ const hasExtension = imagePath.includes(".");
20
20
  if (hasExtension) {
21
- const imagePathArr = imagePath.split('.');
21
+ const imagePathArr = imagePath.split(".");
22
22
  const imageFormat = format || imagePathArr[1];
23
23
  return `${baseUrl}${fileSize}${imagePathArr[0]}.${imageFormat}`;
24
24
  }
25
25
  else {
26
26
  // If no extension in path, use provided format or default to jpg
27
- const imageFormat = format || 'jpg';
27
+ const imageFormat = format || "jpg";
28
28
  return `${baseUrl}${fileSize}${imagePath}.${imageFormat}`;
29
29
  }
30
30
  };
@@ -33,18 +33,18 @@ exports.getFullImagePath = getFullImagePath;
33
33
  * Common image sizes available in TMDB
34
34
  */
35
35
  exports.ImageSizes = {
36
- ORIGINAL: 'original',
37
- W500: 'w500',
38
- W300: 'w300',
39
- W185: 'w185',
40
- W92: 'w92',
41
- H632: 'h632'
36
+ ORIGINAL: "original",
37
+ W500: "w500",
38
+ W300: "w300",
39
+ W185: "w185",
40
+ W92: "w92",
41
+ H632: "h632",
42
42
  };
43
43
  /**
44
44
  * Image formats supported by TMDB
45
45
  */
46
46
  exports.ImageFormats = {
47
- JPG: 'jpg',
48
- PNG: 'png',
49
- SVG: 'svg'
47
+ JPG: "jpg",
48
+ PNG: "png",
49
+ SVG: "svg",
50
50
  };
package/package.json CHANGED
@@ -1,59 +1,63 @@
1
1
  {
2
- "name": "@tdanks2000/tmdb-wrapper",
3
- "version": "1.1.1",
4
- "description": "A powerful and easy-to-use TypeScript wrapper for The Movie Database (TMDb) API",
5
- "module": "./src/index.ts",
6
- "type": "module",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "publishConfig": {
10
- "access": "public"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/tdanks2000/tmdb-wrapper.git"
15
- },
16
- "homepage": "https://github.com/tdanks2000/tmdb-wrapper#readme",
17
- "bugs": {
18
- "url": "https://github.com/tdanks2000/tmdb-wrapper/issues"
19
- },
20
- "files": [
21
- "dist/**/*",
22
- "README.md"
23
- ],
24
- "keywords": [
25
- "tmdb",
26
- "tmdbWrapper",
27
- "tmdb wrapper",
28
- "tmdb-wrapper",
29
- "api wrapper",
30
- "node",
31
- "typescript",
32
- "movies",
33
- "tv shows",
34
- "movie database",
35
- "themoviedb",
36
- "tmdb api",
37
- "entertainment",
38
- "media"
39
- ],
40
- "engines": {
41
- "node": ">=16"
42
- },
43
- "author": "TDanks2000",
44
- "license": "MIT",
45
- "private": false,
46
- "scripts": {
47
- "build": "tsc",
48
- "release": "npm run build && npm version patch && npm publish",
49
- "release:minor": "npm run build && npm version minor && npm publish",
50
- "release:major": "npm run build && npm version major && npm publish",
51
- "preversion": "npm run build"
52
- },
53
- "devDependencies": {
54
- "@types/node": "^22.15.3",
55
- "ts-node": "^10.9.2",
56
- "tsc-alias": "^1.8.15",
57
- "typescript": "^5.8.3"
58
- }
2
+ "name": "@tdanks2000/tmdb-wrapper",
3
+ "version": "1.1.2",
4
+ "description": "A powerful and easy-to-use TypeScript wrapper for The Movie Database (TMDb) API",
5
+ "module": "./src/index.ts",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/tdanks2000/tmdb-wrapper.git"
15
+ },
16
+ "homepage": "https://github.com/tdanks2000/tmdb-wrapper#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/tdanks2000/tmdb-wrapper/issues"
19
+ },
20
+ "files": [
21
+ "dist/**/*",
22
+ "README.md"
23
+ ],
24
+ "keywords": [
25
+ "tmdb",
26
+ "tmdbWrapper",
27
+ "tmdb wrapper",
28
+ "tmdb-wrapper",
29
+ "api wrapper",
30
+ "node",
31
+ "typescript",
32
+ "movies",
33
+ "tv shows",
34
+ "movie database",
35
+ "themoviedb",
36
+ "tmdb api",
37
+ "entertainment",
38
+ "media"
39
+ ],
40
+ "engines": {
41
+ "node": ">=16"
42
+ },
43
+ "author": "TDanks2000",
44
+ "license": "MIT",
45
+ "private": false,
46
+ "scripts": {
47
+ "build": "tsc",
48
+ "release": "npm run build && npm version patch && npm publish",
49
+ "release:minor": "npm run build && npm version minor && npm publish",
50
+ "release:major": "npm run build && npm version major && npm publish",
51
+ "preversion": "npm run build",
52
+ "check": "biome check .",
53
+ "check:unsafe": "biome check --write --unsafe .",
54
+ "check:write": "biome check --write ."
55
+ },
56
+ "devDependencies": {
57
+ "@biomejs/biome": "^2.0.0-beta.2",
58
+ "@types/node": "^22.15.3",
59
+ "ts-node": "^10.9.2",
60
+ "tsc-alias": "^1.8.15",
61
+ "typescript": "^5.8.3"
62
+ }
59
63
  }