qing-client 0.0.26 → 0.0.27
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/lib/service/FileService.d.ts +12 -1
- package/lib/service/FileService.js +19 -0
- package/lib/types/file.d.ts +11 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseClient } from "../client/BaseClient";
|
|
2
2
|
import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
|
|
3
|
-
import { File, CreateFileRequest, UpdateFileRequest, FileListQuery, Folder, FolderItemsResponse, FolderTreeNode, CreateFolderRequest, UpdateFolderRequest, OSSConfig, GenerateOSSUploadSignRequest, GenerateOSSUploadSignResponse, OSSCallbackQuery, OSSCallbackBody, OSSCallbackResponse } from "../types/file";
|
|
3
|
+
import { File, CreateFileRequest, UpdateFileRequest, FileListQuery, Folder, FolderItemsResponse, FolderTreeNode, CreateFolderRequest, UpdateFolderRequest, OSSConfig, GenerateOSSUploadSignRequest, GenerateOSSUploadSignResponse, OSSCallbackQuery, OSSCallbackBody, OSSCallbackResponse, TaskOptionsResponse } from "../types/file";
|
|
4
4
|
export declare class FileService extends BaseClient {
|
|
5
5
|
constructor(config: ClientConfig);
|
|
6
6
|
/**
|
|
@@ -26,6 +26,10 @@ export declare class FileService extends BaseClient {
|
|
|
26
26
|
/**
|
|
27
27
|
* 获取文件列表
|
|
28
28
|
* GET /api/files (网关转发到 /api/v1/files)
|
|
29
|
+
*
|
|
30
|
+
* 权限说明:
|
|
31
|
+
* - 普通用户:只能查自己的文件,uid 参数会被忽略
|
|
32
|
+
* - 管理员/超管:可以查任意用户的文件,传 uid 查指定用户,不传则查所有
|
|
29
33
|
*/
|
|
30
34
|
listFiles(query?: FileListQuery, options?: RequestOptions): Promise<PaginatedResponse<File>>;
|
|
31
35
|
/**
|
|
@@ -38,6 +42,13 @@ export declare class FileService extends BaseClient {
|
|
|
38
42
|
* GET /api/files/oss/config/:projectId (网关转发到 /api/v1/files/oss/config/:projectId)
|
|
39
43
|
*/
|
|
40
44
|
getOSSConfig(projectId: string, options?: RequestOptions): Promise<OSSConfig>;
|
|
45
|
+
/**
|
|
46
|
+
* 获取当前项目可用的任务选项(用于前端 select 下拉框)
|
|
47
|
+
* GET /api/files/oss/task-options (网关转发到 /api/v1/files/oss/task-options)
|
|
48
|
+
*
|
|
49
|
+
* 根据请求头中的 x-project-id 自动获取当前项目可用的任务列表
|
|
50
|
+
*/
|
|
51
|
+
getTaskOptions(options?: RequestOptions): Promise<TaskOptionsResponse>;
|
|
41
52
|
/**
|
|
42
53
|
* 创建文件夹
|
|
43
54
|
* POST /api/files/folders (网关转发到 /api/v1/files/folders)
|
|
@@ -69,6 +69,10 @@ class FileService extends BaseClient_1.BaseClient {
|
|
|
69
69
|
/**
|
|
70
70
|
* 获取文件列表
|
|
71
71
|
* GET /api/files (网关转发到 /api/v1/files)
|
|
72
|
+
*
|
|
73
|
+
* 权限说明:
|
|
74
|
+
* - 普通用户:只能查自己的文件,uid 参数会被忽略
|
|
75
|
+
* - 管理员/超管:可以查任意用户的文件,传 uid 查指定用户,不传则查所有
|
|
72
76
|
*/
|
|
73
77
|
async listFiles(query, options) {
|
|
74
78
|
const params = {};
|
|
@@ -87,6 +91,9 @@ class FileService extends BaseClient_1.BaseClient {
|
|
|
87
91
|
if (query?.acl !== undefined) {
|
|
88
92
|
params.acl = query.acl;
|
|
89
93
|
}
|
|
94
|
+
if (query?.uid !== undefined) {
|
|
95
|
+
params.uid = query.uid;
|
|
96
|
+
}
|
|
90
97
|
const response = await this.paginatedRequest('', {
|
|
91
98
|
...options,
|
|
92
99
|
method: 'GET',
|
|
@@ -116,6 +123,18 @@ class FileService extends BaseClient_1.BaseClient {
|
|
|
116
123
|
method: 'GET'
|
|
117
124
|
});
|
|
118
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* 获取当前项目可用的任务选项(用于前端 select 下拉框)
|
|
128
|
+
* GET /api/files/oss/task-options (网关转发到 /api/v1/files/oss/task-options)
|
|
129
|
+
*
|
|
130
|
+
* 根据请求头中的 x-project-id 自动获取当前项目可用的任务列表
|
|
131
|
+
*/
|
|
132
|
+
async getTaskOptions(options) {
|
|
133
|
+
return this.request('/oss/task-options', {
|
|
134
|
+
...options,
|
|
135
|
+
method: 'GET'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
119
138
|
// ==================== 文件夹相关接口 ====================
|
|
120
139
|
/**
|
|
121
140
|
* 创建文件夹
|
package/lib/types/file.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface File {
|
|
|
13
13
|
etag?: string;
|
|
14
14
|
contentMd5?: string;
|
|
15
15
|
folderId?: string | null;
|
|
16
|
+
uid?: string;
|
|
16
17
|
createdAt: string;
|
|
17
18
|
updatedAt: string;
|
|
18
19
|
}
|
|
@@ -42,6 +43,7 @@ export interface FileListQuery {
|
|
|
42
43
|
folderId?: string;
|
|
43
44
|
taskId?: string;
|
|
44
45
|
acl?: 'private' | 'public-read';
|
|
46
|
+
uid?: string;
|
|
45
47
|
}
|
|
46
48
|
export interface Folder {
|
|
47
49
|
id: string;
|
|
@@ -77,6 +79,15 @@ export interface OSSConfig {
|
|
|
77
79
|
defaultTask: string;
|
|
78
80
|
isPublic?: boolean;
|
|
79
81
|
}
|
|
82
|
+
export interface TaskOption {
|
|
83
|
+
value: string;
|
|
84
|
+
label: string;
|
|
85
|
+
isPublic?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface TaskOptionsResponse {
|
|
88
|
+
options: TaskOption[];
|
|
89
|
+
defaultValue: string;
|
|
90
|
+
}
|
|
80
91
|
export interface GenerateOSSUploadSignRequest {
|
|
81
92
|
taskKey?: string;
|
|
82
93
|
fileName?: string;
|