@ctrl/transmission 2.4.1 → 2.5.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.
@@ -2,6 +2,13 @@
2
2
  import { Response } from 'got';
3
3
  import { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
4
4
  import { AddTorrentOptions, AddTorrentResponse, DefaultResponse, FreeSpaceResponse, GetTorrentRepsonse, RenamePathOptions, SessionArguments, SessionResponse, SetTorrentOptions, TorrentIds } from './types';
5
+ /**
6
+ * TODO: remove when hash is available on normalized torrent
7
+ * @deprecated
8
+ */
9
+ export declare type TransmissionNormalizedTorrent = NormalizedTorrent & {
10
+ hash: string;
11
+ };
5
12
  export declare class Transmission implements TorrentClient {
6
13
  config: TorrentSettings;
7
14
  sessionId?: string;
@@ -49,8 +56,8 @@ export declare class Transmission implements TorrentClient {
49
56
  * @param torrent a string of file path or contents of the file as base64 string
50
57
  */
51
58
  addTorrent(torrent: string | Buffer, options?: Partial<AddTorrentOptions>): Promise<AddTorrentResponse>;
52
- normalizedAddTorrent(torrent: string | Buffer, options?: Partial<NormalizedAddTorrentOptions>): Promise<NormalizedTorrent>;
53
- getTorrent(id: TorrentIds): Promise<NormalizedTorrent>;
59
+ normalizedAddTorrent(torrent: string | Buffer, options?: Partial<NormalizedAddTorrentOptions>): Promise<TransmissionNormalizedTorrent>;
60
+ getTorrent(id: TorrentIds): Promise<TransmissionNormalizedTorrent>;
54
61
  getAllData(): Promise<AllClientData>;
55
62
  listTorrents(ids?: TorrentIds, additionalFields?: string[]): Promise<GetTorrentRepsonse>;
56
63
  request<T>(method: string, args?: any): Promise<Response<T>>;
@@ -154,8 +154,7 @@ class Transmission {
154
154
  const res = await this.addTorrent(torrent, torrentOptions);
155
155
  const torrentId = res.arguments['torrent-added'].id;
156
156
  if (options.label) {
157
- const res = await this.setTorrent(torrentId, { labels: [options.label] });
158
- console.log(res);
157
+ await this.setTorrent(torrentId, { labels: [options.label] });
159
158
  }
160
159
  return this.getTorrent(torrentId);
161
160
  }
@@ -256,10 +255,6 @@ class Transmission {
256
255
  const res = await this.request('torrent-get', args);
257
256
  return res.body;
258
257
  }
259
- // async getTorrent(id: TorrentIds): Promise<NormalizedTorrent> {
260
- // const torrent: any = {};
261
- // return torrent;
262
- // }
263
258
  async request(method, args = {}) {
264
259
  var _a, _b, _c;
265
260
  if (!this.sessionId && method !== 'session-get') {
@@ -294,6 +289,7 @@ class Transmission {
294
289
  // eslint-disable-next-line no-return-await
295
290
  return await this.request(method, args);
296
291
  }
292
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
297
293
  throw error;
298
294
  }
299
295
  }
@@ -319,8 +315,9 @@ class Transmission {
319
315
  else if (torrent.status === 3 || torrent.status === 5) {
320
316
  state = shared_torrent_1.TorrentState.queued;
321
317
  }
322
- const result = {
318
+ return {
323
319
  id: torrent.id,
320
+ hash: torrent.hashString,
324
321
  name: torrent.name,
325
322
  state,
326
323
  isCompleted: torrent.leftUntilDone < 1,
@@ -344,7 +341,6 @@ class Transmission {
344
341
  totalUploaded: torrent.uploadedEver,
345
342
  totalDownloaded: torrent.downloadedEver,
346
343
  };
347
- return result;
348
344
  }
349
345
  }
350
346
  exports.Transmission = Transmission;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/transmission",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "TypeScript api wrapper for transmission using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -31,17 +31,16 @@
31
31
  "@ctrl/url-join": "^1.0.4"
32
32
  },
33
33
  "devDependencies": {
34
- "@babel/plugin-transform-modules-commonjs": "7.16.0",
35
- "@babel/preset-typescript": "7.16.0",
36
- "@ctrl/eslint-config": "3.1.3",
37
- "@jest/globals": "27.4.2",
38
- "@types/node": "16.11.11",
39
- "@types/url-join": "4.0.1",
40
- "jest": "27.4.3",
34
+ "@babel/plugin-transform-modules-commonjs": "7.16.8",
35
+ "@babel/preset-typescript": "7.16.7",
36
+ "@ctrl/eslint-config": "3.3.1",
37
+ "@jest/globals": "27.4.6",
38
+ "@types/node": "17.0.14",
39
+ "jest": "27.4.7",
41
40
  "jest-junit": "13.0.0",
42
41
  "p-wait-for": "3.2.0",
43
- "typedoc": "0.22.10",
44
- "typescript": "4.5.2"
42
+ "typedoc": "0.22.11",
43
+ "typescript": "4.5.5"
45
44
  },
46
45
  "jest": {
47
46
  "testEnvironment": "node",