@media-engine/sdk 1.0.0 → 1.2.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.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +31 -19
  3. package/README.ru.md +31 -19
  4. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Media Engine contributors
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
+ MIT License
2
+
3
+ Copyright (c) 2026 Media Engine contributors
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,14 +2,19 @@
2
2
 
3
3
  **English** | [Русский](https://github.com/Yaneart/media-engine/blob/main/packages/sdk/README.ru.md)
4
4
 
5
- A typed `fetch` client for the Media Engine REST API.
5
+ A small typed client for the Media Engine HTTP API. Use it in a browser, bot, or another service
6
+ instead of building request URLs by hand.
6
7
 
7
- Use it when your browser, bot, or another service talks to `apps/api` instead of creating `MediaEngine` directly.
8
+ ## Install
8
9
 
9
10
  ```bash
10
11
  npm install @media-engine/sdk
11
12
  ```
12
13
 
14
+ Node.js 20 or newer is required when you use the SDK on the server.
15
+
16
+ ## Basic example
17
+
13
18
  ```ts
14
19
  import { MediaEngineClient } from "@media-engine/sdk";
15
20
 
@@ -19,34 +24,41 @@ const media = new MediaEngineClient({
19
24
 
20
25
  const search = await media.search({ title: "Interstellar" });
21
26
  const details = await media.getDetails({ imdb: "tt0816692" });
22
- const torrents = await media.discoverTorrents({ type: "movie", imdb: "tt0816692" });
23
- const health = await media.getHealth();
24
- const live = await media.getLiveness();
25
- const ready = await media.getReadiness();
26
27
  ```
27
28
 
28
- Pass a namespaced external ID to `getDetails()`, through `ids` or a shortcut such as `imdb`. The API rejects the deprecated plain `id` lookup with HTTP 400.
29
-
30
- The main client methods are:
29
+ The client has methods for the public API:
31
30
 
32
31
  - `search()`;
33
32
  - `getDetails()`;
34
33
  - `getAvailability()`;
35
34
  - `discoverTorrents()`;
36
- - `getProviders()`;
37
- - `getStreamingProviders()`;
38
- - `getTorrentProviders()`;
39
- - `getHealth()`.
35
+ - `getProviders()`, `getStreamingProviders()`, and `getTorrentProviders()`;
36
+ - `getHealth()`, `getLiveness()`, and `getReadiness()`.
37
+
38
+ For details, pass an external ID together with its namespace, for example
39
+ `media.getDetails({ imdb: "tt0816692" })`.
40
40
 
41
- Each method accepts optional headers and an `AbortSignal`. You can also provide your own compatible `fetch` implementation.
41
+ ## Requests and errors
42
42
 
43
- Failed HTTP responses and invalid payloads throw `MediaEngineApiError`, which keeps the HTTP status and response body when possible.
43
+ You can set headers once for the whole client or for one request. Every method also accepts an
44
+ `AbortSignal`:
45
+
46
+ ```ts
47
+ const controller = new AbortController();
48
+
49
+ const request = media.search(
50
+ { title: "Dune" },
51
+ { signal: controller.signal },
52
+ );
53
+ ```
44
54
 
45
- The SDK does not call providers, render players, or run a torrent client. It only turns typed method calls into HTTP requests.
55
+ You may pass your own fetch-compatible function through the constructor's `fetch` option. Failed
56
+ HTTP responses and invalid JSON throw `MediaEngineApiError`; it keeps the HTTP status and response
57
+ body when available.
46
58
 
47
- See the [public API guide](https://github.com/Yaneart/media-engine/blob/main/docs/public-api.md) for query examples.
48
- For a complete browser-to-NestJS setup, follow the
49
- [beginner quick start](https://github.com/Yaneart/media-engine/blob/main/docs/quick-start.md).
59
+ The SDK only talks to the API. It does not call providers directly, render players, or run a torrent
60
+ client. Follow the [beginner quick start](https://github.com/Yaneart/media-engine/blob/main/docs/quick-start.md)
61
+ for a complete backend and frontend example.
50
62
 
51
63
  ## License
52
64
 
package/README.ru.md CHANGED
@@ -2,14 +2,19 @@
2
2
 
3
3
  [English](https://github.com/Yaneart/media-engine/blob/main/packages/sdk/README.md) | **Русский**
4
4
 
5
- Типизированный `fetch`-клиент для REST API Media Engine.
5
+ Это небольшой типизированный клиент для HTTP API Media Engine. Используйте его в браузере, боте или
6
+ другом сервисе, чтобы не собирать URL запросов вручную.
6
7
 
7
- Он нужен, когда браузер, бот или другой сервис обращается к `apps/api`, а не создаёт `MediaEngine` напрямую.
8
+ ## Установка
8
9
 
9
10
  ```bash
10
11
  npm install @media-engine/sdk
11
12
  ```
12
13
 
14
+ Для серверного использования нужен Node.js 20 или новее.
15
+
16
+ ## Простой пример
17
+
13
18
  ```ts
14
19
  import { MediaEngineClient } from "@media-engine/sdk";
15
20
 
@@ -19,34 +24,41 @@ const media = new MediaEngineClient({
19
24
 
20
25
  const search = await media.search({ title: "Интерстеллар" });
21
26
  const details = await media.getDetails({ imdb: "tt0816692" });
22
- const torrents = await media.discoverTorrents({ type: "movie", imdb: "tt0816692" });
23
- const health = await media.getHealth();
24
- const live = await media.getLiveness();
25
- const ready = await media.getReadiness();
26
27
  ```
27
28
 
28
- В `getDetails()` передавайте внешний ID с указанием источника — через `ids` или сокращение вроде `imdb`. API отклоняет устаревший запрос с одним обычным `id` и возвращает HTTP 400.
29
-
30
- Основные методы клиента:
29
+ У клиента есть методы для всего публичного API:
31
30
 
32
31
  - `search()`;
33
32
  - `getDetails()`;
34
33
  - `getAvailability()`;
35
34
  - `discoverTorrents()`;
36
- - `getProviders()`;
37
- - `getStreamingProviders()`;
38
- - `getTorrentProviders()`;
39
- - `getHealth()`.
35
+ - `getProviders()`, `getStreamingProviders()` и `getTorrentProviders()`;
36
+ - `getHealth()`, `getLiveness()` и `getReadiness()`.
37
+
38
+ Для подробностей передавайте внешний ID вместе с его типом, например
39
+ `media.getDetails({ imdb: "tt0816692" })`.
40
40
 
41
- Каждый метод принимает дополнительные заголовки и `AbortSignal`. При необходимости можно передать собственную совместимую реализацию `fetch`.
41
+ ## Запросы и ошибки
42
42
 
43
- При неуспешном HTTP-ответе или неверных данных SDK выбрасывает `MediaEngineApiError` и по возможности сохраняет HTTP-статус и тело ответа.
43
+ Headers можно задать сразу для всего клиента или только для одного запроса. Каждый метод также
44
+ принимает `AbortSignal`:
45
+
46
+ ```ts
47
+ const controller = new AbortController();
48
+
49
+ const request = media.search(
50
+ { title: "Дюна" },
51
+ { signal: controller.signal },
52
+ );
53
+ ```
44
54
 
45
- SDK не вызывает провайдеры, не рисует плееры и не запускает torrent-клиент. Он только превращает типизированные методы в HTTP-запросы.
55
+ Через опцию `fetch` конструктора можно передать свою fetch-совместимую функцию. При неуспешном HTTP
56
+ ответе или неверном JSON SDK выбрасывает `MediaEngineApiError`. В ошибке по возможности сохраняются
57
+ HTTP status и тело ответа.
46
58
 
47
- Примеры запросов есть в [описании публичного API](https://github.com/Yaneart/media-engine/blob/main/docs/public-api.md).
48
- Полная настройка связи browser с NestJS показана в
49
- [быстром старте для новичка](https://github.com/Yaneart/media-engine/blob/main/docs/quick-start.ru.md).
59
+ SDK только общается с API. Он не вызывает провайдеры напрямую, не рисует плееры и не запускает
60
+ torrent-клиент. Полный пример backend и frontend есть в
61
+ [быстром старте](https://github.com/Yaneart/media-engine/blob/main/docs/quick-start.ru.md).
50
62
 
51
63
  ## Лицензия
52
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@media-engine/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Typed HTTP SDK for Media Engine API clients.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/Yaneart/media-engine#readme",
@@ -47,7 +47,7 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@media-engine/core": "1.0.0"
50
+ "@media-engine/core": "1.2.0"
51
51
  },
52
52
  "scripts": {
53
53
  "clean": "node ../../scripts/clean-package-dist.mjs",