@remote-app/transmission-client 0.0.6 → 0.0.11

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/client.js CHANGED
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { encode } from "base-64";
11
+ import { HTTPError, TransmissionError } from "./error";
11
12
  export class TransmissionClient {
12
13
  constructor(config) {
13
14
  this.config = config;
@@ -37,9 +38,13 @@ export class TransmissionClient {
37
38
  return yield this.request(body);
38
39
  }
39
40
  if (response.status >= 400) {
40
- throw new Error(response.statusText);
41
+ throw new HTTPError(response.status, response.statusText);
41
42
  }
42
- return (yield response.json());
43
+ const json = (yield response.json());
44
+ if (json && json.result !== "success") {
45
+ throw new TransmissionError(json.result);
46
+ }
47
+ return json;
43
48
  });
44
49
  }
45
50
  }
@@ -0,0 +1,9 @@
1
+ export declare class HTTPError extends Error {
2
+ readonly status: number;
3
+ readonly message: string;
4
+ constructor(status: number, message: string);
5
+ }
6
+ export declare class TransmissionError extends Error {
7
+ readonly message: string;
8
+ constructor(message: string);
9
+ }
package/dist/error.js ADDED
@@ -0,0 +1,15 @@
1
+ export class HTTPError extends Error {
2
+ constructor(status, message) {
3
+ super(message);
4
+ this.status = status;
5
+ this.message = message;
6
+ this.name = "HTTPError";
7
+ }
8
+ }
9
+ export class TransmissionError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.message = message;
13
+ this.name = "TransmissionError";
14
+ }
15
+ }
package/dist/index.d.ts CHANGED
@@ -1,16 +1,5 @@
1
- export type { Response as SessionGetResponse } from "./rpc-calls/session-get";
2
- export type { Request as SessionSetRequest } from "./rpc-calls/session-set";
3
- export type { Response as SessionStatsResponse } from "./rpc-calls/session-stats";
4
- export type { Request as FreeSpaceRequest, Response as FreeSpaceResponse, } from "./rpc-calls/free-space";
5
- export type { Request as TorrentStartRequest } from "./rpc-calls/torrent-start";
6
- export type { Request as TorrentStartNowRequest } from "./rpc-calls/torrent-start-now";
7
- export type { Request as TorrentStopRequest } from "./rpc-calls/torrent-stop";
8
- export type { Request as TorrentVerifyRequest } from "./rpc-calls/torrent-verify";
9
- export type { Request as TorrentReannounceRequest } from "./rpc-calls/torrent-reannounce";
10
- export type { Request as TorrentSetRequest } from "./rpc-calls/torrent-set";
11
- export type { Request as TorrentGetRequest, Response as TorrentGetResponse, } from "./rpc-calls/torrent-get";
12
- export type { Request as TorrentAddRequest, Response as TorrentAddResponse, } from "./rpc-calls/torrent-add";
13
- export type { Request as TorrentRemoveRequest } from "./rpc-calls/torrent-remove";
14
- export type { Request as TorrentSetLocationRequest } from "./rpc-calls/torrent-set-location";
1
+ export type { SessionGetResponse, SessionSetRequest, SessionStatsResponse, FreeSpaceRequest, FreeSpaceResponse, TorrentStartRequest, TorrentStartNowRequest, TorrentStopRequest, TorrentVerifyRequest, TorrentReannounceRequest, TorrentSetRequest, TorrentGetRequest, TorrentGetResponse, TorrentAddRequest, TorrentAddResponse, TorrentRemoveRequest, TorrentSetLocationRequest, } from "./rpc-calls";
2
+ export { TorrentStatus } from "./rpc-calls/torrent-get";
15
3
  export type { Methods } from "./rpc-call";
4
+ export { HTTPError, TransmissionError } from "./error";
16
5
  export { TransmissionClient as default } from "./client";
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
+ export { TorrentStatus } from "./rpc-calls/torrent-get";
2
+ export { HTTPError, TransmissionError } from "./error";
1
3
  export { TransmissionClient as default } from "./client";
@@ -1,17 +1,4 @@
1
- import type { Response as SessionGetResponse } from "./rpc-calls/session-get";
2
- import type { Request as SessionSetRequest } from "./rpc-calls/session-set";
3
- import type { Response as SessionStatsResponse } from "./rpc-calls/session-stats";
4
- import type { Request as FreeSpaceRequest, Response as FreeSpaceResponse } from "./rpc-calls/free-space";
5
- import type { Request as TorrentStartRequest } from "./rpc-calls/torrent-start";
6
- import type { Request as TorrentStartNowRequest } from "./rpc-calls/torrent-start-now";
7
- import type { Request as TorrentStopRequest } from "./rpc-calls/torrent-stop";
8
- import type { Request as TorrentVerifyRequest } from "./rpc-calls/torrent-verify";
9
- import type { Request as TorrentReannounceRequest } from "./rpc-calls/torrent-reannounce";
10
- import type { Request as TorrentSetRequest } from "./rpc-calls/torrent-set";
11
- import type { Request as TorrentGetRequest, Response as TorrentGetResponse } from "./rpc-calls/torrent-get";
12
- import type { Request as TorrentAddRequest, Response as TorrentAddResponse } from "./rpc-calls/torrent-add";
13
- import type { Request as TorrentRemoveRequest } from "./rpc-calls/torrent-remove";
14
- import type { Request as TorrentSetLocationRequest } from "./rpc-calls/torrent-set-location";
1
+ import type { SessionGetResponse, SessionSetRequest, SessionStatsResponse, FreeSpaceRequest, FreeSpaceResponse, TorrentStartRequest, TorrentStartNowRequest, TorrentStopRequest, TorrentVerifyRequest, TorrentReannounceRequest, TorrentSetRequest, TorrentGetRequest, TorrentGetResponse, TorrentAddRequest, TorrentAddResponse, TorrentRemoveRequest, TorrentSetLocationRequest } from "./rpc-calls";
15
2
  declare type SessionMethods = "session-get" | "session-set" | "session-stats" | "free-space";
16
3
  declare type TorrentMethods = "torrent-start" | "torrent-start-now" | "torrent-stop" | "torrent-verify" | "torrent-reannounce" | "torrent-set" | "torrent-get" | "torrent-add" | "torrent-remove" | "torrent-set-location";
17
4
  export declare type Methods = SessionMethods | TorrentMethods;
@@ -0,0 +1,14 @@
1
+ export type { Response as SessionGetResponse } from "./session-get";
2
+ export type { Request as SessionSetRequest } from "./session-set";
3
+ export type { Response as SessionStatsResponse } from "./session-stats";
4
+ export type { Request as FreeSpaceRequest, Response as FreeSpaceResponse, } from "./free-space";
5
+ export type { Request as TorrentStartRequest } from "./torrent-start";
6
+ export type { Request as TorrentStartNowRequest } from "./torrent-start-now";
7
+ export type { Request as TorrentStopRequest } from "./torrent-stop";
8
+ export type { Request as TorrentVerifyRequest } from "./torrent-verify";
9
+ export type { Request as TorrentReannounceRequest } from "./torrent-reannounce";
10
+ export type { Request as TorrentSetRequest } from "./torrent-set";
11
+ export type { Request as TorrentGetRequest, Response as TorrentGetResponse, } from "./torrent-get";
12
+ export type { Request as TorrentAddRequest, Response as TorrentAddResponse, } from "./torrent-add";
13
+ export type { Request as TorrentRemoveRequest } from "./torrent-remove";
14
+ export type { Request as TorrentSetLocationRequest } from "./torrent-set-location";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,7 @@
1
1
  import type { Response as TorrentAddResponse } from "./torrent-get";
2
- export declare type Request = {
2
+ declare type optionals = {
3
3
  cookies?: string;
4
- "download-dir": string;
5
- filename?: string;
6
- metainfo?: string;
4
+ "download-dir"?: string;
7
5
  paused?: boolean;
8
6
  "peer-limit"?: number;
9
7
  bandwidthPriority?: number;
@@ -13,6 +11,12 @@ export declare type Request = {
13
11
  "priority-low"?: number[];
14
12
  "priority-normal"?: number[];
15
13
  };
14
+ export declare type Request = ({
15
+ filename: string;
16
+ } | {
17
+ metainfo: string;
18
+ }) & optionals;
16
19
  export declare type Response = {
17
20
  torrents: Pick<TorrentAddResponse["torrents"][number], "id" | "name" | "hashString">[];
18
21
  };
22
+ export {};
@@ -76,6 +76,15 @@ declare type TrackerStats = {
76
76
  declare type WebSeed = {
77
77
  webseed: string;
78
78
  };
79
+ export declare enum TorrentStatus {
80
+ STOPPED = 0,
81
+ QUEUED_TO_VERIFY_LOCAL_DATA = 1,
82
+ VERIFYING_LOCAL_DATA = 2,
83
+ QUEUED_TO_DOWNLOAD = 3,
84
+ DOWNLOADING = 4,
85
+ QUEUED_TO_SEED = 5,
86
+ SEEDING = 6
87
+ }
79
88
  declare type Torrent = {
80
89
  activityDate: number;
81
90
  addedDate: number;
@@ -137,7 +146,7 @@ declare type Torrent = {
137
146
  seedRatioMode: number;
138
147
  sizeWhenDone: number;
139
148
  startDate: number;
140
- status: 0 | 1 | 2 | 3 | 4 | 5 | 6;
149
+ status: TorrentStatus;
141
150
  trackers: Tracker[];
142
151
  trackerStats: TrackerStats[];
143
152
  totalSize: number;
@@ -1 +1,10 @@
1
- export {};
1
+ export var TorrentStatus;
2
+ (function (TorrentStatus) {
3
+ TorrentStatus[TorrentStatus["STOPPED"] = 0] = "STOPPED";
4
+ TorrentStatus[TorrentStatus["QUEUED_TO_VERIFY_LOCAL_DATA"] = 1] = "QUEUED_TO_VERIFY_LOCAL_DATA";
5
+ TorrentStatus[TorrentStatus["VERIFYING_LOCAL_DATA"] = 2] = "VERIFYING_LOCAL_DATA";
6
+ TorrentStatus[TorrentStatus["QUEUED_TO_DOWNLOAD"] = 3] = "QUEUED_TO_DOWNLOAD";
7
+ TorrentStatus[TorrentStatus["DOWNLOADING"] = 4] = "DOWNLOADING";
8
+ TorrentStatus[TorrentStatus["QUEUED_TO_SEED"] = 5] = "QUEUED_TO_SEED";
9
+ TorrentStatus[TorrentStatus["SEEDING"] = 6] = "SEEDING";
10
+ })(TorrentStatus || (TorrentStatus = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remote-app/transmission-client",
3
- "version": "0.0.6",
3
+ "version": "0.0.11",
4
4
  "description": "Transmission RPC client",
5
5
  "license": "MIT",
6
6
  "repository": {