@lorenzopant/tmdb 0.0.19 → 1.0.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.
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +71 -0
- package/LICENSE +21 -0
- package/README.md +15 -47
- package/dist/client.js +7 -3
- package/dist/endpoints/movie_lists.js +9 -5
- package/dist/endpoints/movies.js +21 -17
- package/dist/endpoints/search.js +7 -3
- package/dist/errors/messages.js +5 -2
- package/dist/errors/tmdb.js +5 -1
- package/dist/images/images.d.ts +3 -2
- package/dist/images/images.d.ts.map +1 -1
- package/dist/images/images.js +15 -11
- package/dist/index.js +22 -3
- package/dist/tmdb.js +17 -13
- package/dist/types/common.js +2 -1
- package/dist/types/countries.js +4 -1
- package/dist/types/enums.js +5 -2
- package/dist/types/images.js +10 -7
- package/dist/types/index.js +24 -8
- package/dist/types/intl.d.ts +1 -0
- package/dist/types/intl.js +1 -0
- package/dist/types/lang.js +4 -1
- package/dist/types/movies.js +2 -1
- package/dist/types/params.js +2 -1
- package/dist/types/utility.d.ts +18 -0
- package/dist/types/utility.d.ts.map +1 -1
- package/dist/types/utility.js +2 -1
- package/package.json +11 -10
- package/tsconfig.json +3 -3
- package/dist/tests/images/images.test.d.ts +0 -2
- package/dist/tests/images/images.test.d.ts.map +0 -1
- package/dist/tests/images/images.test.js +0 -38
- package/dist/tests/movie_list/movie_list.integration.test.d.ts +0 -2
- package/dist/tests/movie_list/movie_list.integration.test.d.ts.map +0 -1
- package/dist/tests/movie_list/movie_list.integration.test.js +0 -32
- package/dist/tests/movies/movies.integration.test.d.ts +0 -2
- package/dist/tests/movies/movies.integration.test.d.ts.map +0 -1
- package/dist/tests/movies/movies.integration.test.js +0 -163
- package/dist/tests/movies/movies.test.d.ts +0 -2
- package/dist/tests/movies/movies.test.d.ts.map +0 -1
- package/dist/tests/movies/movies.test.js +0 -40
- package/dist/tests/search/search.integration.test.d.ts +0 -2
- package/dist/tests/search/search.integration.test.d.ts.map +0 -1
- package/dist/tests/search/search.integration.test.js +0 -23
- package/dist/tests/tmdb.test.d.ts +0 -2
- package/dist/tests/tmdb.test.d.ts.map +0 -1
- package/dist/tests/tmdb.test.js +0 -12
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
l.pantano97@gmail.com.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Contributing to tmdb-api-ts
|
|
2
|
+
|
|
3
|
+
Thank you for considering contributing to **tmdb-api-ts**! Whether it's bug reports, feature requests, documentation improvements, or code contributions — all help is appreciated 🙌
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🧰 Getting Started
|
|
8
|
+
|
|
9
|
+
1. Fork the repository and clone it locally.
|
|
10
|
+
2. Install dependencies:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
3. Run the development server and test suite:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm dev
|
|
20
|
+
pnpm test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🧪 Running Tests
|
|
26
|
+
|
|
27
|
+
We use [Vitest](https://vitest.dev/) for testing.
|
|
28
|
+
|
|
29
|
+
To run tests:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To generate a coverage report:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm test --coverage
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## ✍️ Code Style
|
|
44
|
+
|
|
45
|
+
- Use **TypeScript**
|
|
46
|
+
- Use **named exports** where possible
|
|
47
|
+
- Follow the established file structure (`src/`, `types/`, `tests/`, etc.)
|
|
48
|
+
- Use `pnpm lint` and `pnpm format` before submitting a PR
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 🧩 Submitting a Pull Request
|
|
53
|
+
|
|
54
|
+
1. Create a new branch from `main`
|
|
55
|
+
2. Follow the PR template if available
|
|
56
|
+
3. Provide a clear description of what you changed and why
|
|
57
|
+
4. Include related issue numbers if applicable
|
|
58
|
+
5. Ensure all tests pass and types are correct
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🗃 Feature Requests & Bugs
|
|
63
|
+
|
|
64
|
+
- Open an issue describing the problem or idea
|
|
65
|
+
- Provide examples if possible (stack traces, API request/response, etc.)
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 🙌 Thank You
|
|
70
|
+
|
|
71
|
+
You're helping improve the developer experience for people building with the TMDB API in TypeScript. Thank you for your contributions!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 @lorenzopant
|
|
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.
|
package/README.md
CHANGED
|
@@ -2,27 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
A **TypeScript-first** lightweight client for [The Movie Database (TMDB)](https://developer.themoviedb.org/docs/getting-started) API.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
Feel free to open pull requests on the project repository
|
|
7
|
-
[tmdb-api-ts](https://github.com/lorenzopantano/tmdb-api-ts)
|
|
5
|
+
This package is open-source and will be updated regularly with new features.
|
|
6
|
+
Feel free to open pull requests on the project repository.
|
|
8
7
|
|
|
9
8
|
- 📦 Full TypeScript support
|
|
10
9
|
- 🔥 Simple and tiny wrapper
|
|
11
|
-
- 🚀 Designed for server-side and frontend use (React, Vue, etc.)
|
|
12
|
-
|
|
10
|
+
- 🚀 Designed for server-side and frontend use (NextJS, React, Vue, etc.)
|
|
11
|
+
|
|
12
|
+
## Full documentation is available at [@lorenzopant/tmdb](https://lorenzopant-docs.vercel.app/)
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install tmdb
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
or
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
yarn add tmdb-api-ts
|
|
19
|
+
npm install @lorenzopant/tmdb
|
|
26
20
|
```
|
|
27
21
|
|
|
28
22
|
---
|
|
@@ -30,7 +24,7 @@ yarn add tmdb-api-ts
|
|
|
30
24
|
## Usage
|
|
31
25
|
|
|
32
26
|
```typescript
|
|
33
|
-
import { TMDB } from 'tmdb
|
|
27
|
+
import { TMDB } from '@lorenzopant/tmdb';
|
|
34
28
|
|
|
35
29
|
const tmdb = new TMDB('your_access_token');
|
|
36
30
|
|
|
@@ -75,7 +69,7 @@ const tmdb = new TMDB(accessToken: string);
|
|
|
75
69
|
Search for movies:
|
|
76
70
|
|
|
77
71
|
```typescript
|
|
78
|
-
tmdb.search.movies("Fight Club");
|
|
72
|
+
tmdb.search.movies({ query: "Fight Club" });
|
|
79
73
|
```
|
|
80
74
|
|
|
81
75
|
Returns a **typed response** containing movies.
|
|
@@ -99,48 +93,22 @@ Returns a **typed response** containing movies.
|
|
|
99
93
|
|
|
100
94
|
### `Movie`
|
|
101
95
|
|
|
102
|
-
|
|
96
|
+
Details, alternative titles, changes, credits, external IDs and more:
|
|
103
97
|
|
|
104
98
|
```typescript
|
|
105
|
-
tmdb.movie.details(550);
|
|
106
|
-
tmdb.movie.alternative_titles(550);
|
|
107
|
-
tmdb.movie.changes(550);
|
|
108
|
-
tmdb.movie.credits(550);
|
|
109
|
-
tmdb.movie.external_ids(550);
|
|
99
|
+
tmdb.movie.details({ movie_id: 550 });
|
|
100
|
+
tmdb.movie.alternative_titles({ movie_id: 550 });
|
|
101
|
+
tmdb.movie.changes({ movie_id: 550 });
|
|
102
|
+
tmdb.movie.credits({ movie_id: 550 });
|
|
103
|
+
tmdb.movie.external_ids({ movie_id: 550 });
|
|
110
104
|
|
|
111
|
-
...
|
|
105
|
+
...and more
|
|
112
106
|
```
|
|
113
107
|
|
|
114
108
|
Returns a **typed response** containing movies.
|
|
115
109
|
|
|
116
110
|
---
|
|
117
111
|
|
|
118
|
-
## Error Handling
|
|
119
|
-
|
|
120
|
-
All errors thrown from the TMDB API are wrapped in a `TMDBError` class.
|
|
121
|
-
|
|
122
|
-
You can catch them:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
catch (error) {
|
|
126
|
-
if (error instanceof TMDBError) {
|
|
127
|
-
console.log(error.message);
|
|
128
|
-
console.log(error.http_status_code);
|
|
129
|
-
console.log(error.tmdb_status_code);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Properties available:
|
|
135
|
-
|
|
136
|
-
- `message`
|
|
137
|
-
- `http_status_code`
|
|
138
|
-
- `tmdb_status_code`
|
|
139
|
-
|
|
140
|
-
If the TMDB service is unreachable or returns unexpected errors, `tmdb_status_code` is set to `-1`.
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
112
|
## Requirements
|
|
145
113
|
|
|
146
114
|
- Node.js 18+ recommended
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiClient = void 0;
|
|
4
|
+
const tmdb_1 = require("./errors/tmdb");
|
|
5
|
+
class ApiClient {
|
|
3
6
|
accessToken;
|
|
4
7
|
baseUrl = "https://api.themoviedb.org/3";
|
|
5
8
|
constructor(accessToken) {
|
|
@@ -37,7 +40,8 @@ export class ApiClient {
|
|
|
37
40
|
console.error(`Unknown error: ${error}`);
|
|
38
41
|
// If response is not JSON, fallback to HTTP status text
|
|
39
42
|
}
|
|
40
|
-
const error = new TMDBError(errorMessage, res.status, tmdbStatusCode);
|
|
43
|
+
const error = new tmdb_1.TMDBError(errorMessage, res.status, tmdbStatusCode);
|
|
41
44
|
throw error;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
47
|
+
exports.ApiClient = ApiClient;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MovieListsAPI = exports.MovieListEndpoints = void 0;
|
|
4
|
+
const movies_1 = require("./movies");
|
|
5
|
+
var MovieListEndpoints;
|
|
3
6
|
(function (MovieListEndpoints) {
|
|
4
7
|
MovieListEndpoints["NOW_PLAYING"] = "/now_playing";
|
|
5
8
|
MovieListEndpoints["POPULAR"] = "/popular";
|
|
6
9
|
MovieListEndpoints["TOP_RATED"] = "/top_rated";
|
|
7
10
|
MovieListEndpoints["UPCOMING"] = "/upcoming";
|
|
8
|
-
})(MovieListEndpoints || (MovieListEndpoints = {}));
|
|
9
|
-
|
|
11
|
+
})(MovieListEndpoints || (exports.MovieListEndpoints = MovieListEndpoints = {}));
|
|
12
|
+
class MovieListsAPI {
|
|
10
13
|
client;
|
|
11
14
|
defaultOptions;
|
|
12
15
|
constructor(client, defaultOptions = {}) {
|
|
@@ -24,7 +27,7 @@ export class MovieListsAPI {
|
|
|
24
27
|
* @returns Specific to endpoint (MovieListResult)
|
|
25
28
|
*/
|
|
26
29
|
fetch_movie_list(endpoint, params = {}) {
|
|
27
|
-
return this.client.request(MOVIE_ENDPOINTS.MOVIE + endpoint, this.withDefaults(params));
|
|
30
|
+
return this.client.request(movies_1.MOVIE_ENDPOINTS.MOVIE + endpoint, this.withDefaults(params));
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* Now Playing
|
|
@@ -75,3 +78,4 @@ export class MovieListsAPI {
|
|
|
75
78
|
return this.fetch_movie_list(MovieListEndpoints.UPCOMING, params);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
81
|
+
exports.MovieListsAPI = MovieListsAPI;
|
package/dist/endpoints/movies.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MoviesAPI = exports.MOVIE_ENDPOINTS = void 0;
|
|
4
|
+
exports.MOVIE_ENDPOINTS = {
|
|
2
5
|
MOVIE: "/movie",
|
|
3
6
|
ALTERNATIVE_TITLES: "/alternative_titles",
|
|
4
7
|
CREDITS: "/credits",
|
|
@@ -20,7 +23,7 @@ export const MOVIE_ENDPOINTS = {
|
|
|
20
23
|
// ADD RATING
|
|
21
24
|
// DELETE RATING
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
class MoviesAPI {
|
|
24
27
|
client;
|
|
25
28
|
defaultOptions;
|
|
26
29
|
constructor(client, options = {}) {
|
|
@@ -40,7 +43,7 @@ export class MoviesAPI {
|
|
|
40
43
|
*/
|
|
41
44
|
async details(params) {
|
|
42
45
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
43
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}`;
|
|
46
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}`;
|
|
44
47
|
return this.client.request(endpoint, { language, ...rest });
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
@@ -54,7 +57,7 @@ export class MoviesAPI {
|
|
|
54
57
|
* @reference https://developer.themoviedb.org/reference/movie-alternative-titles
|
|
55
58
|
*/
|
|
56
59
|
async alternative_titles(params) {
|
|
57
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.ALTERNATIVE_TITLES}`;
|
|
60
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.ALTERNATIVE_TITLES}`;
|
|
58
61
|
return this.client.request(endpoint, params);
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
@@ -68,7 +71,7 @@ export class MoviesAPI {
|
|
|
68
71
|
* @reference https://developer.themoviedb.org/reference/movie-credits
|
|
69
72
|
*/
|
|
70
73
|
async credits(params) {
|
|
71
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.CREDITS}`;
|
|
74
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.CREDITS}`;
|
|
72
75
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
73
76
|
return this.client.request(endpoint, { language, ...rest });
|
|
74
77
|
}
|
|
@@ -84,7 +87,7 @@ export class MoviesAPI {
|
|
|
84
87
|
* @reference https://developer.themoviedb.org/reference/movie-external-ids
|
|
85
88
|
*/
|
|
86
89
|
async external_ids(params) {
|
|
87
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.EXTERNAL_IDS}`;
|
|
90
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.EXTERNAL_IDS}`;
|
|
88
91
|
return this.client.request(endpoint);
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
@@ -98,7 +101,7 @@ export class MoviesAPI {
|
|
|
98
101
|
* @reference https://developer.themoviedb.org/reference/movie-keywords
|
|
99
102
|
*/
|
|
100
103
|
async keywords(params) {
|
|
101
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.KEYWORDS}`;
|
|
104
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.KEYWORDS}`;
|
|
102
105
|
return this.client.request(endpoint);
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
@@ -116,7 +119,7 @@ export class MoviesAPI {
|
|
|
116
119
|
* @reference https://developer.themoviedb.org/reference/movie-changes
|
|
117
120
|
*/
|
|
118
121
|
async changes(params) {
|
|
119
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.CHANGES}`;
|
|
122
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.CHANGES}`;
|
|
120
123
|
return this.client.request(endpoint, params);
|
|
121
124
|
}
|
|
122
125
|
/**
|
|
@@ -136,7 +139,7 @@ export class MoviesAPI {
|
|
|
136
139
|
*/
|
|
137
140
|
async images(params) {
|
|
138
141
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
139
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.IMAGES}`;
|
|
142
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.IMAGES}`;
|
|
140
143
|
return this.client.request(endpoint, { language, ...rest });
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
@@ -149,7 +152,7 @@ export class MoviesAPI {
|
|
|
149
152
|
* @reference https://developer.themoviedb.org/reference/movie-latest-id
|
|
150
153
|
*/
|
|
151
154
|
async latest() {
|
|
152
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}${MOVIE_ENDPOINTS.LATEST}`;
|
|
155
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}${exports.MOVIE_ENDPOINTS.LATEST}`;
|
|
153
156
|
return this.client.request(endpoint);
|
|
154
157
|
}
|
|
155
158
|
/**
|
|
@@ -166,7 +169,7 @@ export class MoviesAPI {
|
|
|
166
169
|
*/
|
|
167
170
|
async recommendations(params) {
|
|
168
171
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
169
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RECOMMENDATIONS}`;
|
|
172
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.RECOMMENDATIONS}`;
|
|
170
173
|
return this.client.request(endpoint, { language, ...rest });
|
|
171
174
|
}
|
|
172
175
|
/**
|
|
@@ -186,7 +189,7 @@ export class MoviesAPI {
|
|
|
186
189
|
* @reference https://developer.themoviedb.org/reference/movie-release-dates
|
|
187
190
|
*/
|
|
188
191
|
async release_dates(params) {
|
|
189
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RELEASE_DATES}`;
|
|
192
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.RELEASE_DATES}`;
|
|
190
193
|
return this.client.request(endpoint);
|
|
191
194
|
}
|
|
192
195
|
/**
|
|
@@ -202,7 +205,7 @@ export class MoviesAPI {
|
|
|
202
205
|
*/
|
|
203
206
|
async reviews(params) {
|
|
204
207
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
205
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.REVIEWS}`;
|
|
208
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.REVIEWS}`;
|
|
206
209
|
return this.client.request(endpoint, { language, ...rest });
|
|
207
210
|
}
|
|
208
211
|
/**
|
|
@@ -220,7 +223,7 @@ export class MoviesAPI {
|
|
|
220
223
|
*/
|
|
221
224
|
async similar(params) {
|
|
222
225
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
223
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.SIMILAR}`;
|
|
226
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.SIMILAR}`;
|
|
224
227
|
return this.client.request(endpoint, { language, ...rest });
|
|
225
228
|
}
|
|
226
229
|
/**
|
|
@@ -235,7 +238,7 @@ export class MoviesAPI {
|
|
|
235
238
|
* @reference https://developer.themoviedb.org/reference/movie-translations
|
|
236
239
|
*/
|
|
237
240
|
async translations(params) {
|
|
238
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.TRANSLATIONS}`;
|
|
241
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.TRANSLATIONS}`;
|
|
239
242
|
return this.client.request(endpoint);
|
|
240
243
|
}
|
|
241
244
|
/**
|
|
@@ -249,7 +252,7 @@ export class MoviesAPI {
|
|
|
249
252
|
*/
|
|
250
253
|
async videos(params) {
|
|
251
254
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
252
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.VIDEOS}`;
|
|
255
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.VIDEOS}`;
|
|
253
256
|
return this.client.request(endpoint, { language, ...rest });
|
|
254
257
|
}
|
|
255
258
|
/**
|
|
@@ -269,7 +272,8 @@ export class MoviesAPI {
|
|
|
269
272
|
* @reference https://developer.themoviedb.org/reference/movie-videos
|
|
270
273
|
*/
|
|
271
274
|
async watch_providers(params) {
|
|
272
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.WATCH_PROVIDERS}`;
|
|
275
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.WATCH_PROVIDERS}`;
|
|
273
276
|
return this.client.request(endpoint);
|
|
274
277
|
}
|
|
275
278
|
}
|
|
279
|
+
exports.MoviesAPI = MoviesAPI;
|
package/dist/endpoints/search.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchAPI = exports.SEARCH_ENDPOINTS = void 0;
|
|
4
|
+
exports.SEARCH_ENDPOINTS = {
|
|
2
5
|
MOVIE: "/search/movie",
|
|
3
6
|
};
|
|
4
|
-
|
|
7
|
+
class SearchAPI {
|
|
5
8
|
client;
|
|
6
9
|
defaultOptions; // ** Default options for all requests
|
|
7
10
|
constructor(client, defaultOptions = {}) {
|
|
@@ -27,7 +30,8 @@ export class SearchAPI {
|
|
|
27
30
|
* @reference https://developer.themoviedb.org/reference/search-movie
|
|
28
31
|
*/
|
|
29
32
|
async movies(params) {
|
|
30
|
-
const endpoint = `${SEARCH_ENDPOINTS.MOVIE}`;
|
|
33
|
+
const endpoint = `${exports.SEARCH_ENDPOINTS.MOVIE}`;
|
|
31
34
|
return this.client.request(endpoint, this.withDefaults(params));
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
exports.SearchAPI = SearchAPI;
|
package/dist/errors/messages.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TMDB_ERRORS = exports.Errors = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* A collection of error messages used throughout the application.
|
|
3
6
|
* For library-specific errors (-1 status code) only.
|
|
4
7
|
*/
|
|
5
|
-
|
|
8
|
+
exports.Errors = {
|
|
6
9
|
NO_ACCESS_TOKEN: "TMDB requires a valid access token, please provide one.",
|
|
7
10
|
};
|
|
8
11
|
/**
|
|
9
12
|
* TMDB Error Codes and messages.
|
|
10
13
|
* @reference https://developer.themoviedb.org/docs/errors
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
exports.TMDB_ERRORS = new Map([
|
|
13
16
|
[1, { message: "Success", http_status: 200 }],
|
|
14
17
|
[2, { message: "Invalid service: this service does not exist.", http_status: 501 }],
|
|
15
18
|
[3, { message: "Authentication failed: You do not have permissions to access the service.", http_status: 401 }],
|
package/dist/errors/tmdb.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TMDBError = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Represents a generic error or an error specific to the TMDB (The Movie Database) API.
|
|
3
6
|
* This error class extends the built-in `Error` class and includes additional
|
|
4
7
|
* properties to provide more context about the error.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
class TMDBError extends Error {
|
|
7
10
|
/**
|
|
8
11
|
* The status code returned by the TMDB API.
|
|
9
12
|
* If the value is `-1`, it indicates a library-specific error rather than a TMDB API error.
|
|
@@ -37,3 +40,4 @@ export class TMDBError extends Error {
|
|
|
37
40
|
this.http_status_code = http_status;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
exports.TMDBError = TMDBError;
|
package/dist/images/images.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ImagesConfig } from "../types";
|
|
1
2
|
import { BackdropSize, LogoSize, PosterSize, ProfileSize, StillSize } from "../types/images";
|
|
2
3
|
export declare class ImageAPI {
|
|
3
|
-
private
|
|
4
|
-
constructor(
|
|
4
|
+
private options;
|
|
5
|
+
constructor(options?: ImagesConfig);
|
|
5
6
|
private buildUrl;
|
|
6
7
|
backdrop(path: string, size?: BackdropSize): string;
|
|
7
8
|
logo(path: string, size?: LogoSize): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/images/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEpI,qBAAa,QAAQ;IACpB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/images/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAyC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEpI,qBAAa,QAAQ;IACpB,OAAO,CAAC,OAAO,CAAe;gBAElB,OAAO,GAAE,YAAiB;IAItC,OAAO,CAAC,QAAQ;IAKT,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,YAAoE,GAAG,MAAM;IAI1G,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,QAA4D,GAAG,MAAM;IAI9F,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,UAAgE,GAAG,MAAM;IAIpG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAkE,GAAG,MAAM;IAIvG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,SAA6D,GAAG,MAAM;CAGvG"}
|
package/dist/images/images.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageAPI = void 0;
|
|
4
|
+
const images_1 = require("../types/images");
|
|
5
|
+
class ImageAPI {
|
|
6
|
+
options;
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.options = { secure_images_url: true, ...options };
|
|
6
9
|
}
|
|
7
10
|
buildUrl(path, size) {
|
|
8
|
-
const baseUrl = this.
|
|
11
|
+
const baseUrl = this.options.secure_images_url ? images_1.IMAGE_SECURE_BASE_URL : images_1.IMAGE_BASE_URL;
|
|
9
12
|
return `${baseUrl}${size}${path}`;
|
|
10
13
|
}
|
|
11
|
-
backdrop(path, size = "w780") {
|
|
14
|
+
backdrop(path, size = this.options.default_image_sizes?.backdrops || "w780") {
|
|
12
15
|
return this.buildUrl(path, size);
|
|
13
16
|
}
|
|
14
|
-
logo(path, size = "w185") {
|
|
17
|
+
logo(path, size = this.options.default_image_sizes?.logos || "w185") {
|
|
15
18
|
return this.buildUrl(path, size);
|
|
16
19
|
}
|
|
17
|
-
poster(path, size = "w500") {
|
|
20
|
+
poster(path, size = this.options.default_image_sizes?.posters || "w500") {
|
|
18
21
|
return this.buildUrl(path, size);
|
|
19
22
|
}
|
|
20
|
-
profile(path, size = "w185") {
|
|
23
|
+
profile(path, size = this.options.default_image_sizes?.profiles || "w185") {
|
|
21
24
|
return this.buildUrl(path, size);
|
|
22
25
|
}
|
|
23
|
-
still(path, size = "w300") {
|
|
26
|
+
still(path, size = this.options.default_image_sizes?.still || "w300") {
|
|
24
27
|
return this.buildUrl(path, size);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
30
|
+
exports.ImageAPI = ImageAPI;
|