Skip to content

Commit 873c8a7

Browse files
committed
fix: task stats api
1 parent bb4da4f commit 873c8a7

File tree

9 files changed

+46
-12
lines changed

9 files changed

+46
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"type": "module",
55
"scripts": {
66
"build": "rollup -c",

packages/create-gopeed-ext/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-gopeed-ext",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"keywords": [
55
"gopeed"
66
],

packages/create-gopeed-ext/templates/webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"eslint": "^8.51.0",
2121
"eslint-config-prettier": "^9.0.0",
2222
"eslint-plugin-prettier": "^5.0.0",
23-
"gopeed": "^1.5.0",
23+
"gopeed": "^1.5.1",
2424
"gopeed-polyfill-webpack-plugin": "^1.0.6",
2525
"prettier": "^3.0.3",
2626
"webpack": "^5.75.0",

packages/gopeed-openapi/src/v1/TaskController.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
TaskStatus,
88
CreateTaskBatch,
99
Result,
10+
TaskStats,
1011
} from '@gopeed/types';
1112
import { Body, Controller, Delete, Get, Path, Post, Put, Query, Route, Security, SuccessResponse } from 'tsoa';
1213

@@ -57,14 +58,14 @@ export class UsersController extends Controller {
5758
}
5859

5960
/**
60-
* Get task download status detail info
61+
* Get task stats
6162
* @param id - Task id
6263
* @returns
6364
*/
6465
@Security('X-Api-Token')
6566
@Get('{id}/stats')
66-
public async stats(@Path() id: string): Promise<Result<Task>> {
67-
return null as unknown as Result<Task>;
67+
public async stats(@Path() id: string): Promise<Result<TaskStats>> {
68+
return null as unknown as Result<TaskStats>;
6869
}
6970

7071
/**

packages/gopeed-rest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gopeed/rest",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "",
55
"main": "dist/index.js",
66
"exports": {

packages/gopeed-rest/src/index.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import type {
22
Result,
33
Request,
4+
ResolveResult,
45
CreateTaskWithRequest,
56
CreateTaskWithResolveResult,
6-
ResolveResult,
7+
CreateTaskBatch,
78
Task,
89
TaskStatus,
10+
TaskBtStats,
11+
TaskStats,
912
} from '@gopeed/types';
1013

1114
interface ClientOptions {
@@ -53,6 +56,17 @@ class Client {
5356
});
5457
}
5558

59+
/**
60+
* Create a batch of download tasks
61+
* @param request - The request to create a batch of download tasks
62+
* @returns
63+
*/
64+
public async createTaskBatch(request: CreateTaskBatch): Promise<string[]> {
65+
return this.doRequest<string[]>('POST', '/api/v1/tasks/batch', {
66+
data: request,
67+
});
68+
}
69+
5670
/**
5771
* Get task info
5872
* @param id - Task id
@@ -75,6 +89,15 @@ class Client {
7589
});
7690
}
7791

92+
/**
93+
* Get task stats
94+
* @param id - Task id
95+
* @returns
96+
*/
97+
public async getTaskStats(id: string): Promise<TaskStats> {
98+
return this.doRequest<TaskBtStats>('GET', `/api/v1/tasks/${id}/stats`);
99+
}
100+
78101
/**
79102
* Pause a task
80103
* @param id - Task id

packages/gopeed-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gopeed/types",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "",
55
"main": "dist/index.js",
66
"exports": {

packages/gopeed-types/src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export interface BtReqExtra {
8282
trackers?: string[];
8383
}
8484

85+
export type ReqExtra = HttpReqExtra | BtReqExtra;
86+
8587
/**
8688
* HTTP download extra options
8789
* @example {
@@ -93,8 +95,14 @@ export interface HttpOptExtra {
9395
* Concurrent connections
9496
*/
9597
connections?: number;
98+
/**
99+
* When task download complete, and it is a .torrent file, it will be auto create a new task for the torrent file
100+
*/
101+
autoTorrent?: boolean;
96102
}
97103

104+
export type OptExtra = HttpOptExtra;
105+
98106
/**
99107
* Download request
100108
* @example {
@@ -109,7 +117,7 @@ export interface Request {
109117
/**
110118
* Extra request options
111119
*/
112-
extra?: HttpReqExtra | BtReqExtra;
120+
extra?: ReqExtra;
113121
/**
114122
* Request labels
115123
*/
@@ -190,7 +198,7 @@ export interface Options {
190198
/**
191199
* Download extra options
192200
*/
193-
extra?: HttpOptExtra;
201+
extra?: OptExtra;
194202
}
195203

196204
export type Protocol = 'http' | 'bt';
@@ -295,6 +303,8 @@ export interface TaskBtStats {
295303
seedTime: number;
296304
}
297305

306+
export type TaskStats = TaskBtStats;
307+
298308
export interface CreateTaskWithResolveResult {
299309
/**
300310
* Resolved id, from resolved result

packages/gopeed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gopeed",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)