@ctrl/deluge 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 { Response } from 'got';
3
3
  import { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
4
4
  import { AddTorrentOptions, AddTorrentResponse, BooleanStatus, ConfigResponse, DefaultResponse, DelugeSettings, GetHostsResponse, GetHostStatusResponse, ListMethods, PluginInfo, PluginsListResponse, StringStatus, TorrentFiles, TorrentInfo, TorrentListResponse, TorrentOptions, TorrentStatus, Tracker, UploadResponse } from './types.js';
@@ -89,7 +89,6 @@ export class Deluge {
89
89
  * @returns true if valid
90
90
  */
91
91
  async checkSession() {
92
- var _a;
93
92
  // cookie is missing or expires in x seconds
94
93
  if (this._cookie) {
95
94
  // eslint-disable-next-line new-cap
@@ -102,7 +101,7 @@ export class Deluge {
102
101
  if (this._cookie) {
103
102
  try {
104
103
  const check = await this.request('auth.check_session', undefined, false);
105
- if ((_a = check === null || check === void 0 ? void 0 : check.body) === null || _a === void 0 ? void 0 : _a.result) {
104
+ if (check?.body?.result) {
106
105
  return true;
107
106
  }
108
107
  }
@@ -524,7 +523,6 @@ export class Deluge {
524
523
  }
525
524
  // eslint-disable-next-line @typescript-eslint/ban-types
526
525
  async request(method, params = [], needsAuth = true, autoConnect = true) {
527
- var _a, _b, _c, _d;
528
526
  if (this._msgId === 4096) {
529
527
  this._msgId = 0;
530
528
  }
@@ -538,7 +536,7 @@ export class Deluge {
538
536
  }
539
537
  }
540
538
  const headers = {
541
- Cookie: (_b = (_a = this._cookie) === null || _a === void 0 ? void 0 : _a.cookieString) === null || _b === void 0 ? void 0 : _b.call(_a),
539
+ Cookie: this._cookie?.cookieString?.(),
542
540
  };
543
541
  const url = urlJoin(this.config.baseUrl, this.config.path);
544
542
  const res = await got.post(url, {
@@ -554,7 +552,7 @@ export class Deluge {
554
552
  // allow proxy agent
555
553
  ...(this.config.agent ? { agent: this.config.agent } : {}),
556
554
  });
557
- const err = (_d = (_c = res.body) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : (typeof res.body === 'string' && res.body);
555
+ const err = res.body?.error ?? (typeof res.body === 'string' && res.body);
558
556
  if (err) {
559
557
  throw new Error(err.message || err);
560
558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/deluge",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "TypeScript api wrapper for deluge using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -23,46 +23,36 @@
23
23
  "prepare": "npm run build",
24
24
  "build": "tsc",
25
25
  "build:docs": "typedoc",
26
- "test": "ava",
27
- "test:watch": "ava --watch",
28
- "test:ci": "c8 --reporter=text --reporter=lcov ava"
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "test:ci": "vitest run --coverage"
29
29
  },
30
30
  "dependencies": {
31
31
  "@ctrl/magnet-link": "^3.1.0",
32
32
  "@ctrl/shared-torrent": "^4.1.0",
33
33
  "@ctrl/url-join": "^2.0.0",
34
34
  "formdata-node": "^4.3.2",
35
- "got": "^12.0.1",
35
+ "got": "^12.1.0",
36
36
  "tough-cookie": "^4.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@ctrl/eslint-config": "3.3.1",
40
- "@sindresorhus/tsconfig": "2.0.0",
41
- "@types/node": "17.0.21",
42
- "@types/tough-cookie": "4.0.1",
43
- "ava": "4.0.1",
44
- "c8": "7.11.0",
45
- "ts-node": "10.5.0",
39
+ "@ctrl/eslint-config": "3.4.4",
40
+ "@sindresorhus/tsconfig": "3.0.1",
41
+ "@types/node": "17.0.38",
42
+ "@types/tough-cookie": "4.0.2",
43
+ "c8": "7.11.3",
46
44
  "p-wait-for": "4.1.0",
47
- "typedoc": "0.22.12",
48
- "typescript": "4.5.5"
49
- },
50
- "ava": {
51
- "files": [
52
- "test/**/*.spec.ts"
53
- ],
54
- "extensions": {
55
- "ts": "module"
56
- },
57
- "nodeArguments": [
58
- "--loader=ts-node/esm"
59
- ]
45
+ "typedoc": "0.22.17",
46
+ "typescript": "4.7.2",
47
+ "vitest": "0.13.1"
60
48
  },
61
49
  "publishConfig": {
62
50
  "access": "public"
63
51
  },
64
52
  "release": {
65
- "branch": "master"
53
+ "branches": [
54
+ "master"
55
+ ]
66
56
  },
67
57
  "engines": {
68
58
  "node": ">=14.16"