@ctrl/qbittorrent 4.0.0 → 4.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.
@@ -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 },
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
  /**
@@ -100,7 +100,7 @@ export var TorrentTrackerStatus;
100
100
  * Tracker has not been contacted yet
101
101
  */
102
102
  TorrentTrackerStatus[TorrentTrackerStatus["Waiting"] = 4] = "Waiting";
103
- })(TorrentTrackerStatus || (TorrentTrackerStatus = {}));
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": "4.0.0",
3
+ "version": "4.0.1",
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",
34
+ "@ctrl/magnet-link": "^3.1.1",
35
+ "@ctrl/shared-torrent": "^4.1.1",
36
36
  "@ctrl/torrent-file": "^2.0.1",
37
37
  "@ctrl/url-join": "^2.0.0",
38
38
  "formdata-node": "^4.3.2",
39
- "got": "^12.0.4",
39
+ "got": "^12.1.0",
40
40
  "tough-cookie": "^4.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@ctrl/eslint-config": "3.4.2",
44
- "@sindresorhus/tsconfig": "2.0.0",
45
- "@types/node": "17.0.31",
43
+ "@ctrl/eslint-config": "3.4.4",
44
+ "@sindresorhus/tsconfig": "3.0.1",
45
+ "@types/node": "17.0.40",
46
46
  "@types/tough-cookie": "4.0.2",
47
- "ava": "4.2.0",
48
- "c8": "7.11.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.4"
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.22.17",
50
+ "typescript": "4.7.3",
51
+ "vitest": "0.14.0"
65
52
  },
66
53
  "release": {
67
- "branch": "master"
54
+ "branches": [
55
+ "master"
56
+ ]
68
57
  },
69
58
  "engines": {
70
59
  "node": ">=14.16"