@tdanks2000/tmdb-wrapper 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -114,32 +114,42 @@ let ReleaseDateType = /* @__PURE__ */ function(ReleaseDateType$1) {
114
114
  //#endregion
115
115
  //#region src/utils/api.ts
116
116
  const BASE_URL_V3 = "https://api.themoviedb.org/3";
117
- /**
118
- * Lightweight TMDB v3 API client.
119
- *
120
- * - Sends requests to `https://api.themoviedb.org/3`.
121
- * - Supports authentication via:
122
- * - v4 API Read Access Token (Bearer), and/or
123
- * - v3 API key via `api_key` query parameter.
124
- *
125
- * Notes:
126
- * - Many endpoints accept either method depending on your TMDB settings.
127
- * - When an API key is present, it is appended as `api_key` in the query string.
128
- */
117
+ var TMDBError = class extends Error {
118
+ constructor(message, status, url, payload) {
119
+ super(message);
120
+ this.status = status;
121
+ this.url = url;
122
+ this.payload = payload;
123
+ this.name = "TMDBError";
124
+ }
125
+ };
126
+ const parseOptions = (options) => {
127
+ if (!options) return "";
128
+ const entries = [];
129
+ for (const [key, value] of Object.entries(options)) {
130
+ if (value === void 0 || value === null) continue;
131
+ if (Array.isArray(value)) for (const item of value) {
132
+ if (item === void 0 || item === null) continue;
133
+ entries.push([key, String(item)]);
134
+ }
135
+ else entries.push([key, String(value)]);
136
+ }
137
+ return new URLSearchParams(entries).toString();
138
+ };
139
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
140
+ const shouldRetry = (status) => status === 429 || status === 502 || status === 503 || status === 504;
141
+ const readRetryAfterMs = (res) => {
142
+ const raw = res.headers.get("retry-after");
143
+ if (!raw) return void 0;
144
+ const asSeconds = Number(raw);
145
+ if (Number.isFinite(asSeconds)) return Math.max(0, asSeconds * 1e3);
146
+ const asDate = Date.parse(raw);
147
+ if (!Number.isNaN(asDate)) return Math.max(0, asDate - Date.now());
148
+ return void 0;
149
+ };
129
150
  var API = class {
130
- /**
131
- * Optional v3 API key (sent as `api_key` query param).
132
- */
133
151
  apiKey;
134
- /**
135
- * Optional v4 read access token (sent as `Authorization: Bearer ...`).
136
- */
137
152
  accessToken;
138
- /**
139
- * Create a new API client.
140
- *
141
- * @param {TokenType} auth - Authentication information.
142
- */
143
153
  constructor(auth) {
144
154
  if (typeof auth === "string") this.accessToken = auth;
145
155
  else {
@@ -147,58 +157,55 @@ var API = class {
147
157
  this.accessToken = auth.accessToken;
148
158
  }
149
159
  }
150
- /**
151
- * Generic HTTP GET request.
152
- *
153
- * @template T - Response JSON type.
154
- * @template O - Query options (query params) type.
155
- *
156
- * @param {string} path - The TMDB path beginning with `/`, e.g. `/movie/550`.
157
- * @param {O} [options] - Query parameters to serialize.
158
- *
159
- * @returns {Promise<T>} Resolves with parsed JSON typed as `T`.
160
- * @throws {ErrorResponse} Rejects with parsed TMDB error payload when `response.ok` is false.
161
- */
162
- async get(path, options) {
163
- const rawOptions = {
164
- ...options ?? {},
160
+ async get(path, opts = {}) {
161
+ const query = {
162
+ ...opts.query ? opts.query : {},
165
163
  ...this.apiKey ? { api_key: this.apiKey } : {}
166
164
  };
167
- const params = parseOptions(rawOptions);
168
- const response = await fetch(`${BASE_URL_V3}${path}?${params}`, {
169
- method: "GET",
170
- headers: {
171
- ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {},
172
- "Content-Type": "application/json;charset=utf-8"
165
+ const qs = parseOptions(query);
166
+ const url = `${BASE_URL_V3}${path}${qs ? `?${qs}` : ""}`;
167
+ const retries = opts.retries ?? 2;
168
+ const retryDelayMs = opts.retryDelayMs ?? 300;
169
+ const timeoutMs = opts.timeoutMs ?? 3e4;
170
+ const controller = new AbortController();
171
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
172
+ if (opts.signal) if (opts.signal.aborted) controller.abort();
173
+ else opts.signal.addEventListener("abort", () => controller.abort(), { once: true });
174
+ try {
175
+ for (let attempt = 0; attempt <= retries; attempt++) {
176
+ const res = await fetch(url, {
177
+ method: "GET",
178
+ signal: controller.signal,
179
+ headers: {
180
+ ...this.accessToken ? { Authorization: `Bearer ${this.accessToken}` } : {},
181
+ Accept: "application/json"
182
+ }
183
+ });
184
+ if (res.ok) return await res.json();
185
+ let payload;
186
+ let message = `${res.status} ${res.statusText}`;
187
+ try {
188
+ payload = await res.json();
189
+ if (payload && typeof payload === "object" && "status_message" in payload) message = String(payload.status_message);
190
+ } catch {
191
+ try {
192
+ payload = await res.text();
193
+ } catch {}
194
+ }
195
+ if (attempt < retries && shouldRetry(res.status)) {
196
+ const retryAfter = readRetryAfterMs(res);
197
+ const delay = retryAfter ?? retryDelayMs * 2 ** attempt;
198
+ await sleep(delay);
199
+ continue;
200
+ }
201
+ throw new TMDBError(message, res.status, url, payload);
173
202
  }
174
- });
175
- if (!response.ok) {
176
- const error = await response.json();
177
- return Promise.reject(error);
203
+ throw new TMDBError("Request failed", 0, url);
204
+ } finally {
205
+ clearTimeout(timeout);
178
206
  }
179
- return await response.json();
180
207
  }
181
208
  };
182
- /**
183
- * Serializes an options object into a query string.
184
- *
185
- * - Skips `undefined` and `null`.
186
- * - Arrays are expanded into repeated keys:
187
- * `{ with_genres: ["12", "16"] }` -> `with_genres=12&with_genres=16`
188
- *
189
- * @param {Record<string, unknown>} [options] - Options to serialize.
190
- * @returns {string} Query string without the leading `?`.
191
- */
192
- const parseOptions = (options) => {
193
- if (!options) return "";
194
- const entries = [];
195
- for (const [key, value] of Object.entries(options)) {
196
- if (value === void 0 || value === null) continue;
197
- if (Array.isArray(value)) for (const item of value) entries.push([key, String(item)]);
198
- else entries.push([key, String(value)]);
199
- }
200
- return new URLSearchParams(entries).toString();
201
- };
202
209
 
203
210
  //#endregion
204
211
  //#region src/utils/getimagePath.ts
@@ -270,7 +277,7 @@ var BaseEndpoint = class {
270
277
  *
271
278
  * @param {TokenType} auth - Authentication information.
272
279
  * - If a string: treated as a v4 API Read Access Token (Bearer token).
273
- * - If an object: can include an API key and/or access token, depending on your {@link TokenType}.
280
+ * - If an object: can include an API key and/or access token.
274
281
  */
275
282
  constructor(auth) {
276
283
  this.auth = auth;
@@ -384,7 +391,7 @@ var ChangeEndpoint = class extends BaseEndpoint {
384
391
  * @returns {Promise<MediaChanges>} A Promise that resolves with the changes in movies.
385
392
  */
386
393
  movies(options) {
387
- return this.api.get("/movie/changes", options);
394
+ return this.api.get("/movie/changes", { query: options });
388
395
  }
389
396
  /**
390
397
  * Retrieves changes in TV shows asynchronously.
@@ -395,7 +402,7 @@ var ChangeEndpoint = class extends BaseEndpoint {
395
402
  * @returns {Promise<MediaChanges>} A Promise that resolves with the changes in TV shows.
396
403
  */
397
404
  tv(options) {
398
- return this.api.get("/tv/changes", options);
405
+ return this.api.get("/tv/changes", { query: options });
399
406
  }
400
407
  /**
401
408
  * Retrieves changes related to persons asynchronously.
@@ -406,7 +413,7 @@ var ChangeEndpoint = class extends BaseEndpoint {
406
413
  * @returns {Promise<MediaChanges>} A Promise that resolves with the changes related to persons.
407
414
  */
408
415
  person(options) {
409
- return this.api.get("/person/changes", options);
416
+ return this.api.get("/person/changes", { query: options });
410
417
  }
411
418
  };
412
419
 
@@ -432,7 +439,7 @@ var CollectionsEndpoint = class extends BaseEndpoint {
432
439
  * @returns {Promise<DetailedCollection>} A Promise that resolves with the detailed information of the collection.
433
440
  */
434
441
  async details(id, options) {
435
- return await this.api.get(`${BASE_COLLECTION}/${id}`, options);
442
+ return await this.api.get(`${BASE_COLLECTION}/${id}`, { query: options });
436
443
  }
437
444
  /**
438
445
  * Retrieves images associated with a specific collection asynchronously.
@@ -445,7 +452,7 @@ var CollectionsEndpoint = class extends BaseEndpoint {
445
452
  include_image_language: options?.include_image_language?.join(","),
446
453
  language: options?.language
447
454
  };
448
- return await this.api.get(`${BASE_COLLECTION}/${id}/images`, computedOptions);
455
+ return await this.api.get(`${BASE_COLLECTION}/${id}/images`, { query: computedOptions });
449
456
  }
450
457
  /**
451
458
  * Retrieves translations for a specific collection asynchronously.
@@ -454,7 +461,7 @@ var CollectionsEndpoint = class extends BaseEndpoint {
454
461
  * @returns {Promise<Translations>} A Promise that resolves with the translations of the collection.
455
462
  */
456
463
  async translations(id, options) {
457
- return await this.api.get(`${BASE_COLLECTION}/${id}/translations`, options);
464
+ return await this.api.get(`${BASE_COLLECTION}/${id}/translations`, { query: options });
458
465
  }
459
466
  };
460
467
 
@@ -574,7 +581,7 @@ var DiscoverEndpoint = class extends BaseEndpoint {
574
581
  * @returns {Promise<MovieDiscoverResult>} A Promise that resolves with the movie discovery results.
575
582
  */
576
583
  movie(options) {
577
- return this.api.get(`${BASE_DISCOVER}/movie`, options);
584
+ return this.api.get(`${BASE_DISCOVER}/movie`, { query: options });
578
585
  }
579
586
  /**
580
587
  * Retrieves a list of TV shows based on the provided query options asynchronously.
@@ -585,7 +592,7 @@ var DiscoverEndpoint = class extends BaseEndpoint {
585
592
  * @returns {Promise<TvShowDiscoverResult>} A Promise that resolves with the TV show discovery results.
586
593
  */
587
594
  tvShow(options) {
588
- return this.api.get(`${BASE_DISCOVER}/tv`, options);
595
+ return this.api.get(`${BASE_DISCOVER}/tv`, { query: options });
589
596
  }
590
597
  };
591
598
 
@@ -610,7 +617,7 @@ var FindEndpoint = class extends BaseEndpoint {
610
617
  * @returns {Promise<FindResult>} A Promise that resolves with the result of the find operation.
611
618
  */
612
619
  async byId(externalId, options) {
613
- return await this.api.get(`/find/${externalId}`, options);
620
+ return await this.api.get(`/find/${externalId}`, { query: options });
614
621
  }
615
622
  };
616
623
 
@@ -634,7 +641,7 @@ var GenreEndpoint = class extends BaseEndpoint {
634
641
  * @returns {Promise<Genres>} A Promise that resolves with the genre information for movies.
635
642
  */
636
643
  async movies(options) {
637
- return await this.api.get("/genre/movie/list", options);
644
+ return await this.api.get("/genre/movie/list", { query: options });
638
645
  }
639
646
  /**
640
647
  * Retrieves genre information for TV shows asynchronously.
@@ -642,7 +649,7 @@ var GenreEndpoint = class extends BaseEndpoint {
642
649
  * @returns {Promise<Genres>} A Promise that resolves with the genre information for TV shows.
643
650
  */
644
651
  async tv(options) {
645
- return await this.api.get("/genre/tv/list", options);
652
+ return await this.api.get("/genre/tv/list", { query: options });
646
653
  }
647
654
  };
648
655
 
@@ -676,7 +683,7 @@ var KeywordsEndpoint = class extends BaseEndpoint {
676
683
  * @returns {Promise<BelongingMovies>} A Promise that resolves with the movies belonging to the keyword.
677
684
  */
678
685
  async belongingMovies(keywordId, options) {
679
- return await this.api.get(`${BASE_KEYWORD}/${keywordId}/movies`, options);
686
+ return await this.api.get(`${BASE_KEYWORD}/${keywordId}/movies`, { query: options });
680
687
  }
681
688
  };
682
689
 
@@ -703,11 +710,11 @@ var MoviesEndpoint = class extends BaseEndpoint {
703
710
  * @returns {Promise<AppendToResponse<MovieDetails, AppendToResponseMovieKey[], 'movie'>>} A Promise that resolves with the details of the movie.
704
711
  */
705
712
  async details(id, appendToResponse, language) {
706
- const options = {
713
+ const query = {
707
714
  append_to_response: appendToResponse ? appendToResponse.join(",") : void 0,
708
715
  language
709
716
  };
710
- return await this.api.get(`${BASE_MOVIE}/${id}`, options);
717
+ return await this.api.get(`${BASE_MOVIE}/${id}`, { query });
711
718
  }
712
719
  /**
713
720
  * Retrieves alternative titles of a specific movie asynchronously.
@@ -724,7 +731,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
724
731
  * @returns {Promise<Changes<MovieChangeValue>>} A Promise that resolves with the changes made to the movie.
725
732
  */
726
733
  async changes(id, options) {
727
- return await this.api.get(`${BASE_MOVIE}/${id}/changes`, options);
734
+ return await this.api.get(`${BASE_MOVIE}/${id}/changes`, { query: options });
728
735
  }
729
736
  /**
730
737
  * Retrieves credits of a specific movie asynchronously.
@@ -733,7 +740,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
733
740
  * @returns {Promise<Credits>} A Promise that resolves with the credits of the movie.
734
741
  */
735
742
  async credits(id, options) {
736
- return await this.api.get(`${BASE_MOVIE}/${id}/credits`, options);
743
+ return await this.api.get(`${BASE_MOVIE}/${id}/credits`, { query: options });
737
744
  }
738
745
  /**
739
746
  * Retrieves external IDs of a specific movie asynchronously.
@@ -754,7 +761,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
754
761
  include_image_language: options?.include_image_language?.join(","),
755
762
  language: options?.language
756
763
  };
757
- return await this.api.get(`${BASE_MOVIE}/${id}/images`, computedOptions);
764
+ return await this.api.get(`${BASE_MOVIE}/${id}/images`, { query: computedOptions });
758
765
  }
759
766
  /**
760
767
  * Retrieves keywords of a specific movie asynchronously.
@@ -771,7 +778,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
771
778
  * @returns {Promise<MovieLists>} A Promise that resolves with the lists containing the movie.
772
779
  */
773
780
  async lists(id, options) {
774
- return await this.api.get(`${BASE_MOVIE}/${id}/lists`, options);
781
+ return await this.api.get(`${BASE_MOVIE}/${id}/lists`, { query: options });
775
782
  }
776
783
  /**
777
784
  * Retrieves recommendations for a specific movie asynchronously.
@@ -780,7 +787,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
780
787
  * @returns {Promise<Recommendations>} A Promise that resolves with the recommendations for the movie.
781
788
  */
782
789
  async recommendations(id, options) {
783
- return await this.api.get(`${BASE_MOVIE}/${id}/recommendations`, options);
790
+ return await this.api.get(`${BASE_MOVIE}/${id}/recommendations`, { query: options });
784
791
  }
785
792
  /**
786
793
  * Retrieves release dates of a specific movie asynchronously.
@@ -797,7 +804,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
797
804
  * @returns {Promise<Reviews>} A Promise that resolves with the reviews for the movie.
798
805
  */
799
806
  async reviews(id, options) {
800
- return await this.api.get(`${BASE_MOVIE}/${id}/reviews`, options);
807
+ return await this.api.get(`${BASE_MOVIE}/${id}/reviews`, { query: options });
801
808
  }
802
809
  /**
803
810
  * Retrieves similar movies for a specific movie asynchronously.
@@ -806,7 +813,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
806
813
  * @returns {Promise<SimilarMovies>} A Promise that resolves with the similar movies for the movie.
807
814
  */
808
815
  async similar(id, options) {
809
- return await this.api.get(`${BASE_MOVIE}/${id}/similar`, options);
816
+ return await this.api.get(`${BASE_MOVIE}/${id}/similar`, { query: options });
810
817
  }
811
818
  /**
812
819
  * Retrieves translations of a specific movie asynchronously.
@@ -823,7 +830,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
823
830
  * @returns {Promise<Videos>} A Promise that resolves with the videos of the movie.
824
831
  */
825
832
  async videos(id, options) {
826
- return await this.api.get(`${BASE_MOVIE}/${id}/videos`, options);
833
+ return await this.api.get(`${BASE_MOVIE}/${id}/videos`, { query: options });
827
834
  }
828
835
  /**
829
836
  * Retrieves watch providers of a specific movie asynchronously.
@@ -846,7 +853,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
846
853
  * @returns {Promise<MoviesPlayingNow>} A Promise that resolves with the movies playing now.
847
854
  */
848
855
  async nowPlaying(options) {
849
- return await this.api.get(`${BASE_MOVIE}/now_playing`, options);
856
+ return await this.api.get(`${BASE_MOVIE}/now_playing`, { query: options });
850
857
  }
851
858
  /**
852
859
  * Retrieves popular movies asynchronously.
@@ -854,7 +861,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
854
861
  * @returns {Promise<PopularMovies>} A Promise that resolves with the popular movies.
855
862
  */
856
863
  async popular(options) {
857
- return await this.api.get(`${BASE_MOVIE}/popular`, options);
864
+ return await this.api.get(`${BASE_MOVIE}/popular`, { query: options });
858
865
  }
859
866
  /**
860
867
  * Retrieves top rated movies asynchronously.
@@ -862,7 +869,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
862
869
  * @returns {Promise<TopRatedMovies>} A Promise that resolves with the top rated movies.
863
870
  */
864
871
  async topRated(options) {
865
- return await this.api.get(`${BASE_MOVIE}/top_rated`, options);
872
+ return await this.api.get(`${BASE_MOVIE}/top_rated`, { query: options });
866
873
  }
867
874
  /**
868
875
  * Retrieves upcoming movies asynchronously.
@@ -870,7 +877,7 @@ var MoviesEndpoint = class extends BaseEndpoint {
870
877
  * @returns {Promise<UpcomingMovies>} A Promise that resolves with the upcoming movies.
871
878
  */
872
879
  async upcoming(options) {
873
- return await this.api.get(`${BASE_MOVIE}/upcoming`, options);
880
+ return await this.api.get(`${BASE_MOVIE}/upcoming`, { query: options });
874
881
  }
875
882
  };
876
883
 
@@ -941,7 +948,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
941
948
  append_to_response: appendToResponse ? appendToResponse.join(",") : void 0,
942
949
  language
943
950
  };
944
- return await this.api.get(`${BASE_PERSON}/${id}`, options);
951
+ return await this.api.get(`${BASE_PERSON}/${id}`, { query: options });
945
952
  }
946
953
  /**
947
954
  * Retrieves changes made to a specific person asynchronously.
@@ -950,7 +957,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
950
957
  * @returns {Promise<Changes<PersonChangeValue>>} A Promise that resolves with the changes made to the person.
951
958
  */
952
959
  async changes(id, options) {
953
- return await this.api.get(`${BASE_PERSON}/${id}/changes`, options);
960
+ return await this.api.get(`${BASE_PERSON}/${id}/changes`, { query: options });
954
961
  }
955
962
  /**
956
963
  * Retrieves movie credits of a specific person asynchronously.
@@ -959,7 +966,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
959
966
  * @returns {Promise<PersonMovieCredit>} A Promise that resolves with the movie credits of the person.
960
967
  */
961
968
  async movieCredits(id, options) {
962
- return await this.api.get(`${BASE_PERSON}/${id}/movie_credits`, options);
969
+ return await this.api.get(`${BASE_PERSON}/${id}/movie_credits`, { query: options });
963
970
  }
964
971
  /**
965
972
  * Retrieves TV show credits of a specific person asynchronously.
@@ -968,7 +975,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
968
975
  * @returns {Promise<PersonTvShowCredit>} A Promise that resolves with the TV show credits of the person.
969
976
  */
970
977
  async tvShowCredits(id, options) {
971
- return await this.api.get(`${BASE_PERSON}/${id}/tv_credits`, options);
978
+ return await this.api.get(`${BASE_PERSON}/${id}/tv_credits`, { query: options });
972
979
  }
973
980
  /**
974
981
  * Retrieves combined credits of a specific person asynchronously.
@@ -977,7 +984,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
977
984
  * @returns {Promise<PersonCombinedCredits>} A Promise that resolves with the combined credits of the person.
978
985
  */
979
986
  async combinedCredits(id, options) {
980
- return await this.api.get(`${BASE_PERSON}/${id}/combined_credits`, options);
987
+ return await this.api.get(`${BASE_PERSON}/${id}/combined_credits`, { query: options });
981
988
  }
982
989
  /**
983
990
  * Retrieves external IDs of a specific person asynchronously.
@@ -1002,7 +1009,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
1002
1009
  * @returns {Promise<TaggedImages>} A Promise that resolves with the tagged images of the person.
1003
1010
  */
1004
1011
  async taggedImages(id, options) {
1005
- return await this.api.get(`${BASE_PERSON}/${id}/tagged_images`, options);
1012
+ return await this.api.get(`${BASE_PERSON}/${id}/tagged_images`, { query: options });
1006
1013
  }
1007
1014
  /**
1008
1015
  * Retrieves translations of a specific person asynchronously.
@@ -1025,7 +1032,7 @@ var PeopleEndpoint = class extends BaseEndpoint {
1025
1032
  * @returns {Promise<PopularPersons>} A Promise that resolves with the popular persons.
1026
1033
  */
1027
1034
  async popular(options) {
1028
- return await this.api.get(`${BASE_PERSON}/popular`, options);
1035
+ return await this.api.get(`${BASE_PERSON}/popular`, { query: options });
1029
1036
  }
1030
1037
  };
1031
1038
 
@@ -1074,7 +1081,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1074
1081
  * @returns {Promise<Search<Company>>} A Promise that resolves with the search results for companies.
1075
1082
  */
1076
1083
  async companies(options) {
1077
- return await this.api.get(`${BASE_SEARCH}/company`, options);
1084
+ return await this.api.get(`${BASE_SEARCH}/company`, { query: options });
1078
1085
  }
1079
1086
  /**
1080
1087
  * Searches for collections asynchronously.
@@ -1082,7 +1089,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1082
1089
  * @returns {Promise<Search<Collection>>} A Promise that resolves with the search results for collections.
1083
1090
  */
1084
1091
  async collections(options) {
1085
- return await this.api.get(`${BASE_SEARCH}/collection`, options);
1092
+ return await this.api.get(`${BASE_SEARCH}/collection`, { query: options });
1086
1093
  }
1087
1094
  /**
1088
1095
  * Searches for keywords asynchronously.
@@ -1090,7 +1097,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1090
1097
  * @returns {Promise<Search<{ id: string; name: string }>>} A Promise that resolves with the search results for keywords.
1091
1098
  */
1092
1099
  async keywords(options) {
1093
- return await this.api.get(`${BASE_SEARCH}/keyword`, options);
1100
+ return await this.api.get(`${BASE_SEARCH}/keyword`, { query: options });
1094
1101
  }
1095
1102
  /**
1096
1103
  * Searches for movies asynchronously.
@@ -1098,7 +1105,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1098
1105
  * @returns {Promise<Search<Movie>>} A Promise that resolves with the search results for movies.
1099
1106
  */
1100
1107
  async movies(options) {
1101
- return await this.api.get(`${BASE_SEARCH}/movie`, options);
1108
+ return await this.api.get(`${BASE_SEARCH}/movie`, { query: options });
1102
1109
  }
1103
1110
  /**
1104
1111
  * Searches for people asynchronously.
@@ -1106,7 +1113,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1106
1113
  * @returns {Promise<Search<Person>>} A Promise that resolves with the search results for people.
1107
1114
  */
1108
1115
  async people(options) {
1109
- return await this.api.get(`${BASE_SEARCH}/person`, options);
1116
+ return await this.api.get(`${BASE_SEARCH}/person`, { query: options });
1110
1117
  }
1111
1118
  /**
1112
1119
  * Searches for TV shows asynchronously.
@@ -1114,7 +1121,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1114
1121
  * @returns {Promise<Search<TV>>} A Promise that resolves with the search results for TV shows.
1115
1122
  */
1116
1123
  async tv(options) {
1117
- return await this.api.get(`${BASE_SEARCH}/tv`, options);
1124
+ return await this.api.get(`${BASE_SEARCH}/tv`, { query: options });
1118
1125
  }
1119
1126
  /**
1120
1127
  * Performs a multi-search asynchronously.
@@ -1122,7 +1129,7 @@ var SearchEndpoint = class extends BaseEndpoint {
1122
1129
  * @returns {Promise<Search<MultiSearchResult>>} A Promise that resolves with the multi-search results.
1123
1130
  */
1124
1131
  async multi(options) {
1125
- return await this.api.get(`${BASE_SEARCH}/multi`, options);
1132
+ return await this.api.get(`${BASE_SEARCH}/multi`, { query: options });
1126
1133
  }
1127
1134
  };
1128
1135
 
@@ -1149,7 +1156,7 @@ var TrendingEndpoint = class extends BaseEndpoint {
1149
1156
  * @template T - The type of media being searched for (e.g., 'movie', 'tv').
1150
1157
  */
1151
1158
  async trending(mediaType, timeWindow, options) {
1152
- return await this.api.get(`/trending/${mediaType}/${timeWindow}`, options);
1159
+ return await this.api.get(`/trending/${mediaType}/${timeWindow}`, { query: options });
1153
1160
  }
1154
1161
  };
1155
1162
 
@@ -1183,7 +1190,7 @@ var TvEpisodesEndpoint = class extends BaseEndpoint {
1183
1190
  append_to_response: appendToResponse ? appendToResponse.join(",") : void 0,
1184
1191
  ...options
1185
1192
  };
1186
- return await this.api.get(`${BASE_EPISODE(episodeSelection)}`, combinedOptions);
1193
+ return await this.api.get(`${BASE_EPISODE(episodeSelection)}`, { query: combinedOptions });
1187
1194
  }
1188
1195
  /**
1189
1196
  * Retrieves changes related to a specific TV episode asynchronously.
@@ -1192,7 +1199,7 @@ var TvEpisodesEndpoint = class extends BaseEndpoint {
1192
1199
  * @returns {Promise<Changes<TvEpisodeChangeValue>>} A Promise that resolves with the changes related to the TV episode.
1193
1200
  */
1194
1201
  async changes(episodeID, options) {
1195
- return await this.api.get(`/tv/episode/${episodeID}/changes`, options);
1202
+ return await this.api.get(`/tv/episode/${episodeID}/changes`, { query: options });
1196
1203
  }
1197
1204
  /**
1198
1205
  * Retrieves credits for a specific TV episode asynchronously.
@@ -1201,7 +1208,7 @@ var TvEpisodesEndpoint = class extends BaseEndpoint {
1201
1208
  * @returns {Promise<TvEpisodeCredit>} A Promise that resolves with the credits for the TV episode.
1202
1209
  */
1203
1210
  async credits(episodeSelection, options) {
1204
- return await this.api.get(`${BASE_EPISODE(episodeSelection)}/credits`, options);
1211
+ return await this.api.get(`${BASE_EPISODE(episodeSelection)}/credits`, { query: options });
1205
1212
  }
1206
1213
  /**
1207
1214
  * Retrieves external IDs for a specific TV episode asynchronously.
@@ -1222,7 +1229,7 @@ var TvEpisodesEndpoint = class extends BaseEndpoint {
1222
1229
  include_image_language: options?.include_image_language?.join(","),
1223
1230
  language: options?.language
1224
1231
  };
1225
- return await this.api.get(`${BASE_EPISODE(episodeSelection)}/images`, computedOptions);
1232
+ return await this.api.get(`${BASE_EPISODE(episodeSelection)}/images`, { query: computedOptions });
1226
1233
  }
1227
1234
  /**
1228
1235
  * Retrieves translations for a specific TV episode asynchronously.
@@ -1243,7 +1250,7 @@ var TvEpisodesEndpoint = class extends BaseEndpoint {
1243
1250
  include_video_language: options?.include_video_language?.join(","),
1244
1251
  language: options?.language
1245
1252
  };
1246
- return await this.api.get(`${BASE_EPISODE(episodeSelection)}/videos`, computedOptions);
1253
+ return await this.api.get(`${BASE_EPISODE(episodeSelection)}/videos`, { query: computedOptions });
1247
1254
  }
1248
1255
  };
1249
1256
 
@@ -1277,7 +1284,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1277
1284
  append_to_response: appendToResponse ? appendToResponse.join(",") : void 0,
1278
1285
  ...options
1279
1286
  };
1280
- return await this.api.get(`${BASE_SEASON(seasonSelection)}`, combinedOptions);
1287
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}`, { query: combinedOptions });
1281
1288
  }
1282
1289
  /**
1283
1290
  * Retrieves aggregate credits for a specific TV season asynchronously.
@@ -1286,7 +1293,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1286
1293
  * @returns {Promise<AggregateCredits>} A Promise that resolves with the aggregate credits for the TV season.
1287
1294
  */
1288
1295
  async aggregateCredits(seasonSelection, options) {
1289
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/aggregate_credits`, options);
1296
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}/aggregate_credits`, { query: options });
1290
1297
  }
1291
1298
  /**
1292
1299
  * Retrieves changes related to a specific TV season asynchronously.
@@ -1295,7 +1302,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1295
1302
  * @returns {Promise<Changes<TvSeasonChangeValue>>} A Promise that resolves with the changes related to the TV season.
1296
1303
  */
1297
1304
  async changes(seasonId, options) {
1298
- return await this.api.get(`/tv/season/${seasonId}/changes`, options);
1305
+ return await this.api.get(`/tv/season/${seasonId}/changes`, { query: options });
1299
1306
  }
1300
1307
  /**
1301
1308
  * Retrieves credits for a specific TV season asynchronously.
@@ -1304,7 +1311,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1304
1311
  * @returns {Promise<Credits>} A Promise that resolves with the credits for the TV season.
1305
1312
  */
1306
1313
  async credits(seasonSelection, options) {
1307
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/credits`, options);
1314
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}/credits`, { query: options });
1308
1315
  }
1309
1316
  /**
1310
1317
  * Retrieves external IDs for a specific TV season asynchronously.
@@ -1313,7 +1320,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1313
1320
  * @returns {Promise<ExternalIds>} A Promise that resolves with the external IDs for the TV season.
1314
1321
  */
1315
1322
  async externalIds(seasonSelection, options) {
1316
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/external_ids`, options);
1323
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}/external_ids`, { query: options });
1317
1324
  }
1318
1325
  /**
1319
1326
  * Retrieves images for a specific TV season asynchronously.
@@ -1326,7 +1333,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1326
1333
  include_image_language: options?.include_image_language?.join(","),
1327
1334
  language: options?.language
1328
1335
  };
1329
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/images`, computedOptions);
1336
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}/images`, { query: computedOptions });
1330
1337
  }
1331
1338
  /**
1332
1339
  * Retrieves videos for a specific TV season asynchronously.
@@ -1339,7 +1346,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1339
1346
  include_video_language: options?.include_video_language?.join(","),
1340
1347
  language: options?.language
1341
1348
  };
1342
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/videos`, computedOptions);
1349
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}/videos`, { query: computedOptions });
1343
1350
  }
1344
1351
  /**
1345
1352
  * Retrieves translations for a specific TV season asynchronously.
@@ -1348,7 +1355,7 @@ var TvSeasonsEndpoint = class extends BaseEndpoint {
1348
1355
  * @returns {Promise<Translations>} A Promise that resolves with the translations for the TV season.
1349
1356
  */
1350
1357
  async translations(seasonSelection, options) {
1351
- return await this.api.get(`${BASE_SEASON(seasonSelection)}/translations`, options);
1358
+ return await this.api.get(`${BASE_SEASON(seasonSelection)}/translations`, { query: options });
1352
1359
  }
1353
1360
  };
1354
1361
 
@@ -1380,7 +1387,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1380
1387
  append_to_response: appendToResponse ? appendToResponse.join(",") : void 0,
1381
1388
  language
1382
1389
  };
1383
- return await this.api.get(`${BASE_TV}/${id}`, options);
1390
+ return await this.api.get(`${BASE_TV}/${id}`, { query: options });
1384
1391
  }
1385
1392
  /**
1386
1393
  * Retrieves alternative titles of a specific TV show asynchronously.
@@ -1398,7 +1405,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1398
1405
  * A Promise that resolves with the changes for the TV show.
1399
1406
  */
1400
1407
  async changes(id, options) {
1401
- return await this.api.get(`${BASE_TV}/${id}/changes`, options);
1408
+ return await this.api.get(`${BASE_TV}/${id}/changes`, { query: options });
1402
1409
  }
1403
1410
  /**
1404
1411
  * Retrieves content ratings for a specific TV show asynchronously.
@@ -1415,7 +1422,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1415
1422
  * @returns {Promise<AggregateCredits>} A Promise that resolves with the aggregate credits of the TV show.
1416
1423
  */
1417
1424
  async aggregateCredits(id, options) {
1418
- return await this.api.get(`${BASE_TV}/${id}/aggregate_credits`, options);
1425
+ return await this.api.get(`${BASE_TV}/${id}/aggregate_credits`, { query: options });
1419
1426
  }
1420
1427
  /**
1421
1428
  * Retrieves credits for a specific TV show asynchronously.
@@ -1424,7 +1431,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1424
1431
  * @returns {Promise<Credits>} A Promise that resolves with the credits of the TV show.
1425
1432
  */
1426
1433
  async credits(id, options) {
1427
- return await this.api.get(`${BASE_TV}/${id}/credits`, options);
1434
+ return await this.api.get(`${BASE_TV}/${id}/credits`, { query: options });
1428
1435
  }
1429
1436
  /**
1430
1437
  * Retrieves details of a specific season of a TV show asynchronously.
@@ -1462,7 +1469,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1462
1469
  include_image_language: options?.include_image_language?.join(","),
1463
1470
  language: options?.language
1464
1471
  };
1465
- return await this.api.get(`${BASE_TV}/${id}/images`, computedOptions);
1472
+ return await this.api.get(`${BASE_TV}/${id}/images`, { query: computedOptions });
1466
1473
  }
1467
1474
  /**
1468
1475
  * Retrieves keywords for a specific TV show asynchronously.
@@ -1479,7 +1486,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1479
1486
  * @returns {Promise<Recommendations>} A Promise that resolves with the recommendations for the TV show.
1480
1487
  */
1481
1488
  async recommendations(id, options) {
1482
- return await this.api.get(`${BASE_TV}/${id}/recommendations`, options);
1489
+ return await this.api.get(`${BASE_TV}/${id}/recommendations`, { query: options });
1483
1490
  }
1484
1491
  /**
1485
1492
  * Retrieves reviews for a specific TV show asynchronously.
@@ -1488,7 +1495,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1488
1495
  * @returns {Promise<Reviews>} A Promise that resolves with the reviews of the TV show.
1489
1496
  */
1490
1497
  async reviews(id, options) {
1491
- return await this.api.get(`${BASE_TV}/${id}/reviews`, options);
1498
+ return await this.api.get(`${BASE_TV}/${id}/reviews`, { query: options });
1492
1499
  }
1493
1500
  /**
1494
1501
  * Retrieves information about whether the TV show was screened theatrically asynchronously.
@@ -1505,7 +1512,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1505
1512
  * @returns {Promise<Similartv>} A Promise that resolves with the similar TV shows.
1506
1513
  */
1507
1514
  async similar(id, options) {
1508
- return await this.api.get(`${BASE_TV}/${id}/similar`, options);
1515
+ return await this.api.get(`${BASE_TV}/${id}/similar`, { query: options });
1509
1516
  }
1510
1517
  /**
1511
1518
  * Retrieves translations for a specific TV show asynchronously.
@@ -1526,7 +1533,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1526
1533
  include_video_language: options?.include_video_language?.join(","),
1527
1534
  language: options?.language
1528
1535
  };
1529
- return await this.api.get(`${BASE_TV}/${id}/videos`, computedOptions);
1536
+ return await this.api.get(`${BASE_TV}/${id}/videos`, { query: computedOptions });
1530
1537
  }
1531
1538
  /**
1532
1539
  * Retrieves watch providers for a specific TV show asynchronously.
@@ -1550,7 +1557,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1550
1557
  * @returns {Promise<OnTheAir>} A Promise that resolves with TV shows currently on the air.
1551
1558
  */
1552
1559
  async onTheAir(options) {
1553
- return await this.api.get(`${BASE_TV}/on_the_air`, options);
1560
+ return await this.api.get(`${BASE_TV}/on_the_air`, { query: options });
1554
1561
  }
1555
1562
  /**
1556
1563
  * Retrieves TV shows that are airing today asynchronously.
@@ -1558,7 +1565,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1558
1565
  * @returns {Promise<tvAiringToday>} A Promise that resolves with TV shows airing today.
1559
1566
  */
1560
1567
  async airingToday(options) {
1561
- return await this.api.get(`${BASE_TV}/airing_today`, options);
1568
+ return await this.api.get(`${BASE_TV}/airing_today`, { query: options });
1562
1569
  }
1563
1570
  /**
1564
1571
  * Retrieves popular TV shows asynchronously.
@@ -1566,7 +1573,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1566
1573
  * @returns {Promise<Populartv>} A Promise that resolves with popular TV shows.
1567
1574
  */
1568
1575
  async popular(options) {
1569
- return await this.api.get(`${BASE_TV}/popular`, options);
1576
+ return await this.api.get(`${BASE_TV}/popular`, { query: options });
1570
1577
  }
1571
1578
  /**
1572
1579
  * Retrieves top-rated TV shows asynchronously.
@@ -1574,7 +1581,7 @@ var TvShowsEndpoint = class extends BaseEndpoint {
1574
1581
  * @returns {Promise<TopRatedtv>} A Promise that resolves with top-rated TV shows.
1575
1582
  */
1576
1583
  async topRated(options) {
1577
- return await this.api.get(`${BASE_TV}/top_rated`, options);
1584
+ return await this.api.get(`${BASE_TV}/top_rated`, { query: options });
1578
1585
  }
1579
1586
  };
1580
1587
 
@@ -1593,33 +1600,26 @@ var WatchProvidersEndpoint = class extends BaseEndpoint {
1593
1600
  this.access_token = access_token;
1594
1601
  }
1595
1602
  /**
1596
- * Retrieves a list of all available watch providers (streaming services).
1597
- * @returns {Promise<WatchProviders>} A Promise that resolves with the list of watch providers.
1598
- */
1599
- async available() {
1600
- return await this.api.get("/watch/providers/movie");
1601
- }
1602
- /**
1603
- * Retrieves a list of available regions for watch providers.
1604
- * @returns {Promise<WatchRegionsResponse>} A Promise that resolves with the list of available regions.
1605
- */
1606
- async regions() {
1607
- return await this.api.get("/watch/providers/regions");
1608
- }
1609
- /**
1610
1603
  * Retrieves a list of watch providers for movies.
1611
- * @returns {Promise<WatchProviders>} A Promise that resolves with the list of movie watch providers.
1604
+ * @returns {Promise<WatchProviderListResponse>} A Promise that resolves with the list of movie watch providers.
1612
1605
  */
1613
1606
  async movie() {
1614
1607
  return await this.api.get("/watch/providers/movie");
1615
1608
  }
1616
1609
  /**
1617
1610
  * Retrieves a list of watch providers for TV shows.
1618
- * @returns {Promise<WatchProviders>} A Promise that resolves with the list of TV watch providers.
1611
+ * @returns {Promise<WatchProviderListResponse>} A Promise that resolves with the list of TV watch providers.
1619
1612
  */
1620
1613
  async tv() {
1621
1614
  return await this.api.get("/watch/providers/tv");
1622
1615
  }
1616
+ /**
1617
+ * Retrieves a list of available regions for watch providers.
1618
+ * @returns {Promise<WatchProviderListResponse>} A Promise that resolves with the list of available regions.
1619
+ */
1620
+ async regions() {
1621
+ return await this.api.get("/watch/providers/regions");
1622
+ }
1623
1623
  };
1624
1624
 
1625
1625
  //#endregion
@@ -1684,6 +1684,7 @@ exports.ProfileSizes = ProfileSizes;
1684
1684
  exports.ReleaseDateType = ReleaseDateType;
1685
1685
  exports.StillSizes = StillSizes;
1686
1686
  exports.TMDB = TMDB;
1687
+ exports.TMDBError = TMDBError;
1687
1688
  exports.TMDB_IMAGE_BASE_URL = TMDB_IMAGE_BASE_URL;
1688
1689
  exports.formImage = formImage;
1689
1690
  exports.getFullImagePath = getFullImagePath;