@ctrl/qbittorrent 3.1.0 → 4.0.2

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.
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { Options as GotOptions, Response } from 'got';
3
3
  import { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
4
4
  import { AddMagnetOptions, AddTorrentOptions, BuildInfo, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types.js';
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
1
2
  /* eslint-disable @typescript-eslint/ban-types */
2
3
  import { existsSync } from 'fs';
3
4
  import { URLSearchParams } from 'url';
@@ -373,7 +374,6 @@ export class QBittorrent {
373
374
  return true;
374
375
  }
375
376
  async addTorrent(torrent, options = {}) {
376
- var _a, _b;
377
377
  const form = new FormData();
378
378
  // remove options.filename, not used in form
379
379
  if (options.filename) {
@@ -382,7 +382,7 @@ export class QBittorrent {
382
382
  const type = { type: 'application/x-bittorrent' };
383
383
  if (typeof torrent === 'string') {
384
384
  if (existsSync(torrent)) {
385
- const file = await fileFromPath(torrent, (_a = options.filename) !== null && _a !== void 0 ? _a : 'torrent', type);
385
+ const file = await fileFromPath(torrent, options.filename ?? 'torrent', type);
386
386
  form.set('file', file);
387
387
  }
388
388
  else {
@@ -390,7 +390,7 @@ export class QBittorrent {
390
390
  }
391
391
  }
392
392
  else {
393
- const file = new File([torrent], (_b = options.filename) !== null && _b !== void 0 ? _b : 'torrent', type);
393
+ const file = new File([torrent], options.filename ?? 'torrent', type);
394
394
  form.set('file', file);
395
395
  }
396
396
  if (options) {
@@ -542,14 +542,13 @@ export class QBittorrent {
542
542
  * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#login}
543
543
  */
544
544
  async login() {
545
- var _a, _b;
546
545
  const url = urlJoin(this.config.baseUrl, this.config.path, '/auth/login');
547
546
  const res = await got({
548
547
  url,
549
548
  method: 'POST',
550
549
  form: {
551
- username: (_a = this.config.username) !== null && _a !== void 0 ? _a : '',
552
- password: (_b = this.config.password) !== null && _b !== void 0 ? _b : '',
550
+ username: this.config.username ?? '',
551
+ password: this.config.password ?? '',
553
552
  },
554
553
  followRedirect: false,
555
554
  retry: { limit: 0 },
@@ -575,7 +574,6 @@ export class QBittorrent {
575
574
  }
576
575
  // eslint-disable-next-line max-params
577
576
  async request(path, method, params = {}, body, form, headers = {}, json = true) {
578
- var _a;
579
577
  if (!this._sid || !this._exp || this._exp.getTime() < new Date().getTime()) {
580
578
  const authed = await this.login();
581
579
  if (!authed) {
@@ -588,7 +586,7 @@ export class QBittorrent {
588
586
  resolveBodyOnly: false,
589
587
  method,
590
588
  headers: {
591
- Cookie: `SID=${(_a = this._sid) !== null && _a !== void 0 ? _a : ''}`,
589
+ Cookie: `SID=${this._sid ?? ''}`,
592
590
  ...headers,
593
591
  },
594
592
  retry: { limit: 0 },
@@ -424,21 +424,21 @@ export declare enum TorrentTrackerStatus {
424
424
  */
425
425
  Disabled = 0,
426
426
  /**
427
- * Tracker has been contacted and is working
427
+ * Tracker has not been contacted yet
428
428
  */
429
- Working = 1,
429
+ Waiting = 1,
430
430
  /**
431
- * Tracker is currently being updated
431
+ * Tracker has been contacted and is working
432
432
  */
433
- Updating = 2,
433
+ Working = 2,
434
434
  /**
435
- * Tracker has been contacted, but it is not working (or doesn't send proper replies)
435
+ * Tracker is updating
436
436
  */
437
- Errored = 3,
437
+ Updating = 3,
438
438
  /**
439
- * Tracker has not been contacted yet
439
+ * Tracker has been contacted, but it is not working (or doesn't send proper replies)
440
440
  */
441
- Waiting = 4
441
+ Errored = 4
442
442
  }
443
443
  export interface WebSeed {
444
444
  /**
@@ -534,9 +534,10 @@ export interface AddTorrentOptions {
534
534
  */
535
535
  paused: TrueFalseStr;
536
536
  /**
537
- * Create the root folder. Possible values are true, false, unset (default)
537
+ * Control filesystem structure for content (added in Web API v2.7)
538
+ * Migrating from rootFolder example rootFolder ? 'Original' : 'NoSubfolder'
538
539
  */
539
- root_folder: TrueFalseStr;
540
+ contentLayout: 'Original' | 'Subfolder' | 'NoSubfolder';
540
541
  /**
541
542
  * Rename torrent
542
543
  */
package/dist/src/types.js CHANGED
@@ -77,7 +77,7 @@ export var TorrentState;
77
77
  * Torrent data files is missing
78
78
  */
79
79
  TorrentState["MissingFiles"] = "missingFiles";
80
- })(TorrentState || (TorrentState = {}));
80
+ })(TorrentState = TorrentState || (TorrentState = {}));
81
81
  export var TorrentTrackerStatus;
82
82
  (function (TorrentTrackerStatus) {
83
83
  /**
@@ -85,22 +85,22 @@ export var TorrentTrackerStatus;
85
85
  */
86
86
  TorrentTrackerStatus[TorrentTrackerStatus["Disabled"] = 0] = "Disabled";
87
87
  /**
88
- * Tracker has been contacted and is working
88
+ * Tracker has not been contacted yet
89
89
  */
90
- TorrentTrackerStatus[TorrentTrackerStatus["Working"] = 1] = "Working";
90
+ TorrentTrackerStatus[TorrentTrackerStatus["Waiting"] = 1] = "Waiting";
91
91
  /**
92
- * Tracker is currently being updated
92
+ * Tracker has been contacted and is working
93
93
  */
94
- TorrentTrackerStatus[TorrentTrackerStatus["Updating"] = 2] = "Updating";
94
+ TorrentTrackerStatus[TorrentTrackerStatus["Working"] = 2] = "Working";
95
95
  /**
96
- * Tracker has been contacted, but it is not working (or doesn't send proper replies)
96
+ * Tracker is updating
97
97
  */
98
- TorrentTrackerStatus[TorrentTrackerStatus["Errored"] = 3] = "Errored";
98
+ TorrentTrackerStatus[TorrentTrackerStatus["Updating"] = 3] = "Updating";
99
99
  /**
100
- * Tracker has not been contacted yet
100
+ * Tracker has been contacted, but it is not working (or doesn't send proper replies)
101
101
  */
102
- TorrentTrackerStatus[TorrentTrackerStatus["Waiting"] = 4] = "Waiting";
103
- })(TorrentTrackerStatus || (TorrentTrackerStatus = {}));
102
+ TorrentTrackerStatus[TorrentTrackerStatus["Errored"] = 4] = "Errored";
103
+ })(TorrentTrackerStatus = TorrentTrackerStatus || (TorrentTrackerStatus = {}));
104
104
  export var TorrentFilePriority;
105
105
  (function (TorrentFilePriority) {
106
106
  /**
@@ -119,7 +119,7 @@ export var TorrentFilePriority;
119
119
  * Maximal priority
120
120
  */
121
121
  TorrentFilePriority[TorrentFilePriority["MaxPriority"] = 7] = "MaxPriority";
122
- })(TorrentFilePriority || (TorrentFilePriority = {}));
122
+ })(TorrentFilePriority = TorrentFilePriority || (TorrentFilePriority = {}));
123
123
  export var TorrentPieceState;
124
124
  (function (TorrentPieceState) {
125
125
  /**
@@ -134,4 +134,4 @@ export var TorrentPieceState;
134
134
  * Already downloaded
135
135
  */
136
136
  TorrentPieceState[TorrentPieceState["Downloaded"] = 2] = "Downloaded";
137
- })(TorrentPieceState || (TorrentPieceState = {}));
137
+ })(TorrentPieceState = TorrentPieceState || (TorrentPieceState = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/qbittorrent",
3
- "version": "3.1.0",
3
+ "version": "4.0.2",
4
4
  "description": "TypeScript api wrapper for qbittorrent using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://qbittorrent.vercel.app",
9
9
  "type": "module",
10
10
  "main": "./dist/src/index.js",
11
- "typings": "./dist/src/index.d.ts",
11
+ "types": "./dist/src/index.d.ts",
12
12
  "files": [
13
13
  "dist/src"
14
14
  ],
@@ -26,45 +26,34 @@
26
26
  "prepare": "npm run build",
27
27
  "build": "tsc",
28
28
  "build:docs": "typedoc",
29
- "test": "ava",
30
- "test:watch": "ava --watch",
31
- "test:ci": "c8 --reporter=text --reporter=lcov ava --tap | tap-junit -o junit -n test-result.xml"
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "test:ci": "vitest run --coverage --reporter=junit --outputFile=./junit.xml"
32
32
  },
33
33
  "dependencies": {
34
- "@ctrl/magnet-link": "^3.1.0",
35
- "@ctrl/shared-torrent": "^4.1.0",
36
- "@ctrl/torrent-file": "^2.0.1",
37
- "@ctrl/url-join": "^2.0.0",
38
- "formdata-node": "^4.3.2",
39
- "got": "^12.0.3",
34
+ "@ctrl/magnet-link": "^3.1.1",
35
+ "@ctrl/shared-torrent": "^4.1.1",
36
+ "@ctrl/torrent-file": "^2.0.2",
37
+ "@ctrl/url-join": "^2.0.2",
38
+ "formdata-node": "^4.3.3",
39
+ "got": "^12.1.0",
40
40
  "tough-cookie": "^4.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@ctrl/eslint-config": "3.4.1",
44
- "@sindresorhus/tsconfig": "2.0.0",
45
- "@types/node": "17.0.23",
46
- "@types/tough-cookie": "4.0.1",
47
- "ava": "4.2.0",
48
- "c8": "7.11.0",
43
+ "@ctrl/eslint-config": "3.4.6",
44
+ "@sindresorhus/tsconfig": "3.0.1",
45
+ "@types/node": "18.0.0",
46
+ "@types/tough-cookie": "4.0.2",
47
+ "c8": "7.11.3",
49
48
  "p-wait-for": "4.1.0",
50
- "tap-junit": "5.0.2",
51
- "ts-node": "10.7.0",
52
- "typedoc": "0.22.15",
53
- "typescript": "4.6.3"
54
- },
55
- "ava": {
56
- "files": [
57
- "test/**/*.spec.ts"
58
- ],
59
- "extensions": {
60
- "ts": "module"
61
- },
62
- "nodeArguments": [
63
- "--loader=ts-node/esm"
64
- ]
49
+ "typedoc": "0.23.2",
50
+ "typescript": "4.7.4",
51
+ "vitest": "0.16.0"
65
52
  },
66
53
  "release": {
67
- "branch": "master"
54
+ "branches": [
55
+ "master"
56
+ ]
68
57
  },
69
58
  "engines": {
70
59
  "node": ">=14.16"