qing-client 0.0.25 → 0.0.26
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,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/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
|
+
}
|