@ctrl/deluge 6.0.0 → 7.0.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.
- package/dist/src/deluge.d.ts +3 -3
- package/dist/src/deluge.js +10 -9
- package/dist/src/normalizeTorrentData.d.ts +2 -2
- package/dist/src/types.d.ts +5 -5
- package/package.json +19 -20
package/dist/src/deluge.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ofetch } from 'ofetch';
|
2
2
|
import type { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
|
3
3
|
import type { AddTorrentOptions, AddTorrentResponse, BooleanStatus, ConfigResponse, DefaultResponse, DelugeSettings, GetHostsResponse, GetHostStatusResponse, ListMethods, PluginInfo, PluginsListResponse, StringStatus, TorrentFiles, TorrentInfo, TorrentListResponse, TorrentOptions, TorrentStatus, Tracker, UploadResponse } from './types.js';
|
4
4
|
export declare class Deluge implements TorrentClient {
|
@@ -69,7 +69,7 @@ export declare class Deluge implements TorrentClient {
|
|
69
69
|
/**
|
70
70
|
*
|
71
71
|
* @param torrentId torrent id from list torrents
|
72
|
-
* @param removeData true
|
72
|
+
* @param removeData (default: false) If true, remove the data from disk
|
73
73
|
*/
|
74
74
|
removeTorrent(torrentId: string, removeData?: boolean): Promise<BooleanStatus>;
|
75
75
|
changePassword(password: string): Promise<BooleanStatus>;
|
@@ -105,6 +105,6 @@ export declare class Deluge implements TorrentClient {
|
|
105
105
|
getPluginInfo(plugins: string[]): Promise<PluginInfo>;
|
106
106
|
enablePlugin(plugins: string[]): Promise<DefaultResponse>;
|
107
107
|
disablePlugin(plugins: string[]): Promise<DefaultResponse>;
|
108
|
-
request<T extends object>(method: string, params?: any[], needsAuth?: boolean, autoConnect?: boolean): Promise<
|
108
|
+
request<T extends object>(method: string, params?: any[], needsAuth?: boolean, autoConnect?: boolean): Promise<ReturnType<typeof ofetch.raw<T>>>;
|
109
109
|
private _validateAuth;
|
110
110
|
}
|
package/dist/src/deluge.js
CHANGED
@@ -167,8 +167,7 @@ export class Deluge {
|
|
167
167
|
retry: 0,
|
168
168
|
timeout: this.config.timeout,
|
169
169
|
parseResponse: JSON.parse,
|
170
|
-
|
171
|
-
agent: this.config.agent,
|
170
|
+
dispatcher: this.config.dispatcher,
|
172
171
|
});
|
173
172
|
return res;
|
174
173
|
}
|
@@ -188,7 +187,8 @@ export class Deluge {
|
|
188
187
|
}
|
189
188
|
async addTorrent(torrent, config = {}) {
|
190
189
|
let path;
|
191
|
-
|
190
|
+
const isUploaded = typeof torrent === 'string' && torrent.includes('delugeweb-');
|
191
|
+
if (isUint8Array(torrent) || !isUploaded) {
|
192
192
|
const upload = await this.upload(torrent);
|
193
193
|
if (!upload.success || !upload.files.length) {
|
194
194
|
throw new Error('Failed to upload');
|
@@ -196,7 +196,10 @@ export class Deluge {
|
|
196
196
|
path = upload.files[0];
|
197
197
|
}
|
198
198
|
else {
|
199
|
-
/**
|
199
|
+
/**
|
200
|
+
* Assume paths starting with /tmp/ are from {@link Deluge.upload}
|
201
|
+
* Example temp path: /run/deluged-temp/delugeweb-s0jy917j/ubuntu-20.10-desktop-amd64.iso.torrent
|
202
|
+
*/
|
200
203
|
path = torrent;
|
201
204
|
}
|
202
205
|
const options = {
|
@@ -278,9 +281,9 @@ export class Deluge {
|
|
278
281
|
/**
|
279
282
|
*
|
280
283
|
* @param torrentId torrent id from list torrents
|
281
|
-
* @param removeData true
|
284
|
+
* @param removeData (default: false) If true, remove the data from disk
|
282
285
|
*/
|
283
|
-
async removeTorrent(torrentId, removeData =
|
286
|
+
async removeTorrent(torrentId, removeData = false) {
|
284
287
|
const req = await this.request('core.remove_torrent', [torrentId, removeData]);
|
285
288
|
return req._data;
|
286
289
|
}
|
@@ -508,7 +511,6 @@ export class Deluge {
|
|
508
511
|
const req = await this.request('core.disable_plugin', plugins);
|
509
512
|
return req._data;
|
510
513
|
}
|
511
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
512
514
|
async request(method, params = [], needsAuth = true, autoConnect = true) {
|
513
515
|
if (this._msgId === 4096) {
|
514
516
|
this._msgId = 0;
|
@@ -538,8 +540,7 @@ export class Deluge {
|
|
538
540
|
timeout: this.config.timeout,
|
539
541
|
responseType: 'json',
|
540
542
|
parseResponse: JSON.parse,
|
541
|
-
|
542
|
-
agent: this.config.agent,
|
543
|
+
dispatcher: this.config.dispatcher,
|
543
544
|
});
|
544
545
|
const err = res.body?.error ?? (typeof res.body === 'string' && res.body);
|
545
546
|
if (err) {
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
2
|
-
import { Torrent } from './types.js';
|
1
|
+
import { type NormalizedTorrent } from '@ctrl/shared-torrent';
|
2
|
+
import type { Torrent } from './types.js';
|
3
3
|
export declare function normalizeTorrentData(id: string, torrent: Torrent): NormalizedTorrent;
|
package/dist/src/types.d.ts
CHANGED
@@ -16,7 +16,7 @@ export interface ListMethods extends DefaultResponse {
|
|
16
16
|
result: string[];
|
17
17
|
}
|
18
18
|
export interface AddTorrentResponse extends DefaultResponse {
|
19
|
-
result:
|
19
|
+
result: [boolean, string][];
|
20
20
|
}
|
21
21
|
/**
|
22
22
|
* ex -
|
@@ -35,7 +35,7 @@ export interface GetHostsResponse extends DefaultResponse {
|
|
35
35
|
* port - 58846
|
36
36
|
* status - "Online"
|
37
37
|
*/
|
38
|
-
result:
|
38
|
+
result: [string, string, number, string][];
|
39
39
|
}
|
40
40
|
export type HostStatus = 'Online' | 'Offline' | 'Connected';
|
41
41
|
export interface GetHostStatusResponse extends DefaultResponse {
|
@@ -101,9 +101,9 @@ export interface TorrentList {
|
|
101
101
|
* ['label', 'id']
|
102
102
|
*/
|
103
103
|
export interface TorrentFilters {
|
104
|
-
state:
|
105
|
-
tracker_host:
|
106
|
-
label?:
|
104
|
+
state: [string, number][];
|
105
|
+
tracker_host: [string, number][];
|
106
|
+
label?: [string, number][];
|
107
107
|
}
|
108
108
|
export interface Stats {
|
109
109
|
upload_protocol_rate: number;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/deluge",
|
3
|
-
"version": "
|
3
|
+
"version": "7.0.0",
|
4
4
|
"description": "TypeScript api wrapper for deluge using got",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -20,10 +20,10 @@
|
|
20
20
|
"scripts": {
|
21
21
|
"lint": "pnpm run '/^(lint:biome|lint:eslint)$/'",
|
22
22
|
"lint:biome": "biome check .",
|
23
|
-
"lint:eslint": "eslint
|
23
|
+
"lint:eslint": "eslint .",
|
24
24
|
"lint:fix": "pnpm run '/^(lint:biome|lint:eslint):fix$/'",
|
25
|
-
"lint:eslint:fix": "eslint
|
26
|
-
"lint:biome:fix": "biome check . --
|
25
|
+
"lint:eslint:fix": "eslint . --fix",
|
26
|
+
"lint:biome:fix": "biome check . --write",
|
27
27
|
"prepare": "npm run build",
|
28
28
|
"build": "tsc",
|
29
29
|
"build:docs": "typedoc",
|
@@ -32,25 +32,24 @@
|
|
32
32
|
"test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@ctrl/magnet-link": "^4.0.
|
36
|
-
"@ctrl/shared-torrent": "^6.
|
37
|
-
"node-fetch-native": "^1.6.
|
38
|
-
"ofetch": "^1.
|
39
|
-
"tough-cookie": "^
|
40
|
-
"ufo": "^1.4
|
41
|
-
"uint8array-extras": "^1.
|
35
|
+
"@ctrl/magnet-link": "^4.0.2",
|
36
|
+
"@ctrl/shared-torrent": "^6.1.0",
|
37
|
+
"node-fetch-native": "^1.6.4",
|
38
|
+
"ofetch": "^1.4.1",
|
39
|
+
"tough-cookie": "^5.0.0",
|
40
|
+
"ufo": "^1.5.4",
|
41
|
+
"uint8array-extras": "^1.4.0"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
|
-
"@biomejs/biome": "1.
|
45
|
-
"@ctrl/eslint-config-biome": "2.
|
46
|
-
"@sindresorhus/tsconfig": "
|
47
|
-
"@types/node": "
|
48
|
-
"@
|
49
|
-
"@vitest/coverage-v8": "1.3.1",
|
44
|
+
"@biomejs/biome": "1.9.4",
|
45
|
+
"@ctrl/eslint-config-biome": "4.2.11",
|
46
|
+
"@sindresorhus/tsconfig": "6.0.0",
|
47
|
+
"@types/node": "22.9.0",
|
48
|
+
"@vitest/coverage-v8": "2.1.4",
|
50
49
|
"p-wait-for": "5.0.2",
|
51
|
-
"typedoc": "0.
|
52
|
-
"typescript": "5.
|
53
|
-
"vitest": "1.
|
50
|
+
"typedoc": "0.26.11",
|
51
|
+
"typescript": "5.6.3",
|
52
|
+
"vitest": "2.1.4"
|
54
53
|
},
|
55
54
|
"publishConfig": {
|
56
55
|
"access": "public",
|