qing-client 0.0.25 → 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.
|
@@ -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
|
* 创建文件夹
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BaseClient } from "../client/BaseClient";
|
|
2
|
-
import { ClientConfig, RequestOptions } from "../types";
|
|
3
|
-
import { FrontHostCreateProjectInput, FrontHostDomainAvailabilityResponse, FrontHostHealthResponse,
|
|
2
|
+
import { ClientConfig, RequestOptions, PaginatedResponse } from "../types";
|
|
3
|
+
import { FrontHostCreateProjectInput, FrontHostDeployResponse, FrontHostDomainAvailabilityResponse, FrontHostHealthResponse, FrontHostProject, FrontHostProjectVersion } from "../types/fronthost";
|
|
4
4
|
/**
|
|
5
5
|
* HTML 托管网关(gateway_h5 / fronthost)管理 API
|
|
6
6
|
*
|
|
7
7
|
* 部署在 API 网关后面时,建议使用 qing-client 的前端模式(config.gatewayUrl),
|
|
8
8
|
* 这样 BaseClient 会自动加 x-project-id / x-app-id(与 gateway_h5 verifyGatewayToken 一致)。
|
|
9
|
+
*
|
|
10
|
+
* 所有接口返回标准 ApiResponse / PaginatedResponse 格式
|
|
9
11
|
*/
|
|
10
12
|
export declare class FrontHostService extends BaseClient {
|
|
11
13
|
constructor(config: ClientConfig);
|
|
@@ -13,25 +15,31 @@ export declare class FrontHostService extends BaseClient {
|
|
|
13
15
|
health(options?: RequestOptions): Promise<FrontHostHealthResponse>;
|
|
14
16
|
/** 子域名可用性:GET /domains/available?subdomain=xx */
|
|
15
17
|
checkSubdomainAvailability(subdomain: string, options?: RequestOptions): Promise<FrontHostDomainAvailabilityResponse>;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 项目列表:GET /projects
|
|
20
|
+
* 返回分页响应格式
|
|
21
|
+
*/
|
|
22
|
+
listProjects(options?: RequestOptions): Promise<PaginatedResponse<FrontHostProject>>;
|
|
18
23
|
/** 项目详情:GET /projects/{id} */
|
|
19
24
|
getProject(id: string, options?: RequestOptions): Promise<FrontHostProject>;
|
|
20
25
|
/**
|
|
21
26
|
* 创建项目:POST /projects (multipart/form-data)
|
|
22
|
-
* - zip
|
|
27
|
+
* - zip 或单文件字段名必须是 file(与服务端 r.FormFile("file") 一致)
|
|
23
28
|
* - 其他字段按 deployType 决定传哪些
|
|
24
29
|
*/
|
|
25
30
|
createProject(input: FrontHostCreateProjectInput, options?: RequestOptions): Promise<FrontHostProject>;
|
|
26
31
|
/** 删除项目:DELETE /projects/{id} */
|
|
27
|
-
deleteProject(id: string, options?: RequestOptions): Promise<
|
|
32
|
+
deleteProject(id: string, options?: RequestOptions): Promise<void>;
|
|
28
33
|
/**
|
|
29
34
|
* 部署新版本:PUT /projects/{id}/deploy (multipart/form-data)
|
|
30
35
|
* - 文件字段名固定 file
|
|
31
36
|
*/
|
|
32
|
-
deployNewVersion(projectId: string, file: Blob | File, options?: RequestOptions): Promise<
|
|
33
|
-
/**
|
|
34
|
-
|
|
37
|
+
deployNewVersion(projectId: string, file: Blob | File, options?: RequestOptions): Promise<FrontHostDeployResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* 版本列表:GET /projects/{id}/versions
|
|
40
|
+
* 返回分页响应格式
|
|
41
|
+
*/
|
|
42
|
+
getProjectVersions(projectId: string, options?: RequestOptions): Promise<PaginatedResponse<FrontHostProjectVersion>>;
|
|
35
43
|
/** 回滚版本:POST /projects/{id}/rollback/{version_id} */
|
|
36
|
-
rollbackVersion(projectId: string, versionId: string, options?: RequestOptions): Promise<
|
|
44
|
+
rollbackVersion(projectId: string, versionId: string, options?: RequestOptions): Promise<FrontHostDeployResponse>;
|
|
37
45
|
}
|
|
@@ -8,6 +8,8 @@ const BaseClient_1 = require("../client/BaseClient");
|
|
|
8
8
|
*
|
|
9
9
|
* 部署在 API 网关后面时,建议使用 qing-client 的前端模式(config.gatewayUrl),
|
|
10
10
|
* 这样 BaseClient 会自动加 x-project-id / x-app-id(与 gateway_h5 verifyGatewayToken 一致)。
|
|
11
|
+
*
|
|
12
|
+
* 所有接口返回标准 ApiResponse / PaginatedResponse 格式
|
|
11
13
|
*/
|
|
12
14
|
class FrontHostService extends BaseClient_1.BaseClient {
|
|
13
15
|
constructor(config) {
|
|
@@ -29,9 +31,12 @@ class FrontHostService extends BaseClient_1.BaseClient {
|
|
|
29
31
|
params: { subdomain },
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* 项目列表:GET /projects
|
|
36
|
+
* 返回分页响应格式
|
|
37
|
+
*/
|
|
33
38
|
async listProjects(options) {
|
|
34
|
-
return this.
|
|
39
|
+
return this.paginatedRequest("/projects", {
|
|
35
40
|
...options,
|
|
36
41
|
method: "GET",
|
|
37
42
|
});
|
|
@@ -45,7 +50,7 @@ class FrontHostService extends BaseClient_1.BaseClient {
|
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
52
|
* 创建项目:POST /projects (multipart/form-data)
|
|
48
|
-
* - zip
|
|
53
|
+
* - zip 或单文件字段名必须是 file(与服务端 r.FormFile("file") 一致)
|
|
49
54
|
* - 其他字段按 deployType 决定传哪些
|
|
50
55
|
*/
|
|
51
56
|
async createProject(input, options) {
|
|
@@ -97,9 +102,12 @@ class FrontHostService extends BaseClient_1.BaseClient {
|
|
|
97
102
|
body: form,
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* 版本列表:GET /projects/{id}/versions
|
|
107
|
+
* 返回分页响应格式
|
|
108
|
+
*/
|
|
101
109
|
async getProjectVersions(projectId, options) {
|
|
102
|
-
return this.
|
|
110
|
+
return this.paginatedRequest(`/projects/${encodeURIComponent(projectId)}/versions`, {
|
|
103
111
|
...options,
|
|
104
112
|
method: "GET",
|
|
105
113
|
});
|
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;
|
package/lib/types/fronthost.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** 部署类型:子域名 / 路由 / 代理域名 */
|
|
2
|
-
export type FrontHostDeployType = "subdomain" | "route" | "proxy";
|
|
1
|
+
/** 部署类型:子域名 / 路由 / 代理域名 / 单文件 */
|
|
2
|
+
export type FrontHostDeployType = "subdomain" | "route" | "proxy" | "file";
|
|
3
3
|
/** 项目(后端返回的视图模型) */
|
|
4
4
|
export interface FrontHostProject {
|
|
5
5
|
id: string;
|
|
@@ -14,10 +14,6 @@ export interface FrontHostProject {
|
|
|
14
14
|
status: string;
|
|
15
15
|
createdAt: string;
|
|
16
16
|
}
|
|
17
|
-
/** 列表接口返回 */
|
|
18
|
-
export interface FrontHostProjectListResponse {
|
|
19
|
-
projects: FrontHostProject[];
|
|
20
|
-
}
|
|
21
17
|
/** 创建项目:表单字段(文件用 FormData 传) */
|
|
22
18
|
export interface FrontHostCreateProjectInput {
|
|
23
19
|
name?: string;
|
|
@@ -29,26 +25,26 @@ export interface FrontHostCreateProjectInput {
|
|
|
29
25
|
routePath?: string;
|
|
30
26
|
/** proxy 模式 */
|
|
31
27
|
proxyDomain?: string;
|
|
32
|
-
/** zip
|
|
28
|
+
/** zip 包或单文件(字段名必须是 file,与服务端一致) */
|
|
33
29
|
file: Blob | File;
|
|
34
30
|
}
|
|
35
|
-
/**
|
|
36
|
-
* 如果服务端字段与你们实际不一致,把这里字段名对齐即可
|
|
37
|
-
*/
|
|
31
|
+
/** 版本信息 */
|
|
38
32
|
export interface FrontHostProjectVersion {
|
|
39
33
|
id: string;
|
|
40
34
|
projectId: string;
|
|
41
35
|
versionNumber: number;
|
|
42
36
|
isActive: boolean;
|
|
43
37
|
deployedAt: string;
|
|
38
|
+
createdAt?: string;
|
|
44
39
|
}
|
|
45
|
-
/**
|
|
46
|
-
export interface
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
/** 部署/回滚响应中的数据 */
|
|
41
|
+
export interface FrontHostDeployResponse {
|
|
42
|
+
version: FrontHostProjectVersion;
|
|
43
|
+
project: {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
url: string;
|
|
47
|
+
};
|
|
52
48
|
}
|
|
53
49
|
/** 域名/子域名可用性 */
|
|
54
50
|
export interface FrontHostDomainAvailabilityResponse {
|
|
@@ -60,3 +56,15 @@ export interface FrontHostHealthResponse {
|
|
|
60
56
|
status: "ok" | string;
|
|
61
57
|
timestamp: string;
|
|
62
58
|
}
|
|
59
|
+
/** @deprecated 使用 PaginatedResponse<FrontHostProject[]> 替代 */
|
|
60
|
+
export interface FrontHostProjectListResponse {
|
|
61
|
+
projects: FrontHostProject[];
|
|
62
|
+
}
|
|
63
|
+
/** @deprecated 使用 PaginatedResponse<FrontHostProjectVersion[]> 替代 */
|
|
64
|
+
export interface FrontHostProjectVersionsResponse {
|
|
65
|
+
versions: FrontHostProjectVersion[];
|
|
66
|
+
}
|
|
67
|
+
/** @deprecated 使用 ApiResponse 替代 */
|
|
68
|
+
export interface FrontHostMessageResponse {
|
|
69
|
+
message: string;
|
|
70
|
+
}
|