@cloudbase/manager-node 4.11.0-alpha.8 → 4.11.0-alpha.9
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/.claude/settings.local.json +9 -0
- package/lib/cloudApp/index.js +243 -0
- package/lib/cloudApp/types.js +10 -0
- package/lib/environment.js +5 -0
- package/lib/index.js +25 -0
- package/lib/interfaces/cloudApp.interface.js +20 -0
- package/lib/interfaces/index.js +1 -0
- package/package.json +1 -1
- package/types/cloudApp/index.d.ts +73 -0
- package/types/cloudApp/types.d.ts +325 -0
- package/types/environment.d.ts +3 -0
- package/types/index.d.ts +20 -0
- package/types/interfaces/cloudApp.interface.d.ts +4 -0
- package/types/interfaces/index.d.ts +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(TCB_BASE_URL=https://tcb.pre.tencentcloudapi.woa.com npm test -- --testPathPattern=cloudApp 2>&1)",
|
|
5
|
+
"Bash(TCB_BASE_URL=https://tcb.pre.tencentcloudapi.woa.com npm test 2>&1)",
|
|
6
|
+
"Bash(TCB_BASE_URL=https://tcb.pre.tencentcloudapi.woa.com npm test -- --testPathPattern=cloudApp --testNamePattern=\"获取版本列表\")"
|
|
7
|
+
]
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.CloudAppService = void 0;
|
|
27
|
+
const fs_1 = __importDefault(require("fs"));
|
|
28
|
+
const os_1 = __importDefault(require("os"));
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const error_1 = require("../error");
|
|
31
|
+
const utils_1 = require("../utils");
|
|
32
|
+
const http_request_1 = require("../utils/http-request");
|
|
33
|
+
__exportStar(require("./types"), exports);
|
|
34
|
+
/**
|
|
35
|
+
* CloudApp 统一部署服务
|
|
36
|
+
* 提供 Web 应用的创建、查询、删除、版本管理等功能
|
|
37
|
+
*/
|
|
38
|
+
class CloudAppService {
|
|
39
|
+
constructor(environment) {
|
|
40
|
+
this.environment = environment;
|
|
41
|
+
this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
|
|
42
|
+
}
|
|
43
|
+
// =========== 应用管理 API ===========
|
|
44
|
+
/**
|
|
45
|
+
* 创建/更新 CloudApp 应用
|
|
46
|
+
* @param params 创建参数
|
|
47
|
+
*/
|
|
48
|
+
async createApp(params) {
|
|
49
|
+
const { envId } = this.getEnvInfo();
|
|
50
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType']);
|
|
51
|
+
return this.tcbService.request('CreateCloudApp', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 获取 CloudApp 应用列表
|
|
55
|
+
* @param params 查询参数
|
|
56
|
+
*/
|
|
57
|
+
async describeAppList(params) {
|
|
58
|
+
const { envId } = this.getEnvInfo();
|
|
59
|
+
return this.tcbService.request('DescribeCloudAppList', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 获取 CloudApp 应用详情
|
|
63
|
+
* @param params 查询参数
|
|
64
|
+
*/
|
|
65
|
+
async describeAppInfo(params) {
|
|
66
|
+
const { envId } = this.getEnvInfo();
|
|
67
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType']);
|
|
68
|
+
return this.tcbService.request('DescribeCloudAppInfo', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 删除 CloudApp 应用
|
|
72
|
+
* @param params 删除参数
|
|
73
|
+
*/
|
|
74
|
+
async deleteApp(params) {
|
|
75
|
+
const { envId } = this.getEnvInfo();
|
|
76
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType']);
|
|
77
|
+
return this.tcbService.request('DeleteCloudApp', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
78
|
+
}
|
|
79
|
+
// =========== 版本管理 API ===========
|
|
80
|
+
/**
|
|
81
|
+
* 获取 CloudApp 版本详情
|
|
82
|
+
* 不指定 versionName 或 buildId 时返回最新版本
|
|
83
|
+
* @param params 查询参数
|
|
84
|
+
*/
|
|
85
|
+
async describeAppVersion(params) {
|
|
86
|
+
const { envId } = this.getEnvInfo();
|
|
87
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType']);
|
|
88
|
+
return this.tcbService.request('DescribeCloudAppVersion', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 获取 CloudApp 版本列表
|
|
92
|
+
* @param params 查询参数
|
|
93
|
+
*/
|
|
94
|
+
async describeAppVersionList(params) {
|
|
95
|
+
const { envId } = this.getEnvInfo();
|
|
96
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType']);
|
|
97
|
+
return this.tcbService.request('DescribeCloudAppVersionList', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 删除 CloudApp 版本
|
|
101
|
+
* @param params 删除参数
|
|
102
|
+
*/
|
|
103
|
+
async deleteAppVersion(params) {
|
|
104
|
+
const { envId } = this.getEnvInfo();
|
|
105
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType', 'versionName']);
|
|
106
|
+
return this.tcbService.request('DeleteCloudAppVersion', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId })));
|
|
107
|
+
}
|
|
108
|
+
// =========== COS 上传相关 API ===========
|
|
109
|
+
/**
|
|
110
|
+
* 获取 CloudApp COS 上传信息(预签名 URL)
|
|
111
|
+
* @param params 查询参数
|
|
112
|
+
*/
|
|
113
|
+
async describeCosInfo(params) {
|
|
114
|
+
const { envId } = this.getEnvInfo();
|
|
115
|
+
this.validateRequiredParams(params, ['serviceName', 'deployType']);
|
|
116
|
+
return this.tcbService.request('DescribeCloudAppCosInfo', (0, utils_1.upperCaseObjKey)(Object.assign(Object.assign({}, params), { envId: params.envId || envId, suffix: params.suffix || '.zip' })));
|
|
117
|
+
}
|
|
118
|
+
// =========== 辅助方法 ===========
|
|
119
|
+
/**
|
|
120
|
+
* 上传本地代码到 COS
|
|
121
|
+
* 自动打包 ZIP 并上传到预签名 URL
|
|
122
|
+
*
|
|
123
|
+
* 注意:此方法不依赖应用是否已创建,可在创建应用前调用
|
|
124
|
+
* 返回的 cosTimestamp 用于 createApp 时传入 staticConfig.cosTimestamp
|
|
125
|
+
*
|
|
126
|
+
* @param params 上传参数
|
|
127
|
+
*/
|
|
128
|
+
async uploadCode(params) {
|
|
129
|
+
const { serviceName, localPath, ignore = [] } = params;
|
|
130
|
+
// 1. 验证本地路径
|
|
131
|
+
if (!fs_1.default.existsSync(localPath)) {
|
|
132
|
+
throw new error_1.CloudBaseError(`本地路径不存在: ${localPath}`);
|
|
133
|
+
}
|
|
134
|
+
const stat = fs_1.default.statSync(localPath);
|
|
135
|
+
if (!stat.isDirectory()) {
|
|
136
|
+
throw new error_1.CloudBaseError(`localPath 必须是目录: ${localPath}`);
|
|
137
|
+
}
|
|
138
|
+
// 2. 打包本地文件为 ZIP
|
|
139
|
+
const tmpZipPath = path_1.default.join(os_1.default.tmpdir(), `cloudapp-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`);
|
|
140
|
+
const defaultIgnore = ['node_modules/**', '.git/**', '.DS_Store', '**/.DS_Store'];
|
|
141
|
+
await (0, utils_1.compressToZip)({
|
|
142
|
+
dirPath: localPath,
|
|
143
|
+
outputPath: tmpZipPath,
|
|
144
|
+
ignore: [...defaultIgnore, ...ignore]
|
|
145
|
+
});
|
|
146
|
+
try {
|
|
147
|
+
// 3. 获取上传凭证
|
|
148
|
+
const cosInfo = await this.describeCosInfo({
|
|
149
|
+
deployType: params.deployType,
|
|
150
|
+
serviceName,
|
|
151
|
+
suffix: '.zip'
|
|
152
|
+
});
|
|
153
|
+
// 4. 读取 ZIP 文件
|
|
154
|
+
const zipBuffer = fs_1.default.readFileSync(tmpZipPath);
|
|
155
|
+
// 5. 构建请求头
|
|
156
|
+
const headers = {
|
|
157
|
+
'Content-Type': 'application/zip'
|
|
158
|
+
};
|
|
159
|
+
if (cosInfo.UploadHeaders && cosInfo.UploadHeaders.length > 0) {
|
|
160
|
+
for (const h of cosInfo.UploadHeaders) {
|
|
161
|
+
headers[h.Key] = h.Value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// 6. 使用预签名 URL 上传
|
|
165
|
+
const response = await (0, http_request_1.fetchStream)(cosInfo.UploadUrl, {
|
|
166
|
+
method: 'PUT',
|
|
167
|
+
body: zipBuffer,
|
|
168
|
+
headers
|
|
169
|
+
});
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
let errorDetail = '';
|
|
172
|
+
try {
|
|
173
|
+
const responseText = await response.text();
|
|
174
|
+
errorDetail = responseText ? ` - ${responseText.substring(0, 500)}` : '';
|
|
175
|
+
}
|
|
176
|
+
catch (_a) {
|
|
177
|
+
// 解析失败时 errorDetail 保持空串,不影响主错误抛出
|
|
178
|
+
}
|
|
179
|
+
throw new error_1.CloudBaseError(`上传失败: ${response.status} ${response.statusText}${errorDetail}`);
|
|
180
|
+
}
|
|
181
|
+
// 7. 返回结果(返回 cosTimestamp,用于创建应用)
|
|
182
|
+
return {
|
|
183
|
+
cosTimestamp: cosInfo.UnixTimestamp,
|
|
184
|
+
unixTimestamp: cosInfo.UnixTimestamp
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
// 8. 清理临时文件
|
|
189
|
+
if (fs_1.default.existsSync(tmpZipPath)) {
|
|
190
|
+
fs_1.default.unlinkSync(tmpZipPath);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 获取环境信息
|
|
196
|
+
*/
|
|
197
|
+
getEnvInfo() {
|
|
198
|
+
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
199
|
+
return {
|
|
200
|
+
envId: envConfig.EnvId
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 校验必填参数
|
|
205
|
+
* @param params 参数对象
|
|
206
|
+
* @param fields 必填字段列表
|
|
207
|
+
*/
|
|
208
|
+
validateRequiredParams(params, fields) {
|
|
209
|
+
for (const field of fields) {
|
|
210
|
+
if (!params[field]) {
|
|
211
|
+
throw new error_1.CloudBaseError(`${field} 是必填参数`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.CloudAppService = CloudAppService;
|
|
217
|
+
__decorate([
|
|
218
|
+
(0, utils_1.preLazy)()
|
|
219
|
+
], CloudAppService.prototype, "createApp", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, utils_1.preLazy)()
|
|
222
|
+
], CloudAppService.prototype, "describeAppList", null);
|
|
223
|
+
__decorate([
|
|
224
|
+
(0, utils_1.preLazy)()
|
|
225
|
+
], CloudAppService.prototype, "describeAppInfo", null);
|
|
226
|
+
__decorate([
|
|
227
|
+
(0, utils_1.preLazy)()
|
|
228
|
+
], CloudAppService.prototype, "deleteApp", null);
|
|
229
|
+
__decorate([
|
|
230
|
+
(0, utils_1.preLazy)()
|
|
231
|
+
], CloudAppService.prototype, "describeAppVersion", null);
|
|
232
|
+
__decorate([
|
|
233
|
+
(0, utils_1.preLazy)()
|
|
234
|
+
], CloudAppService.prototype, "describeAppVersionList", null);
|
|
235
|
+
__decorate([
|
|
236
|
+
(0, utils_1.preLazy)()
|
|
237
|
+
], CloudAppService.prototype, "deleteAppVersion", null);
|
|
238
|
+
__decorate([
|
|
239
|
+
(0, utils_1.preLazy)()
|
|
240
|
+
], CloudAppService.prototype, "describeCosInfo", null);
|
|
241
|
+
__decorate([
|
|
242
|
+
(0, utils_1.preLazy)()
|
|
243
|
+
], CloudAppService.prototype, "uploadCode", null);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CloudApp 统一部署服务类型定义
|
|
4
|
+
* 支持 static-hosting(静态托管)和 http-function(预留)两种部署类型
|
|
5
|
+
*
|
|
6
|
+
* 命名规范:
|
|
7
|
+
* - 入参接口(IXxxParams):camelCase,通过 upperCaseObjKey 转换后透传给 API
|
|
8
|
+
* - 返回值接口(IXxxResult):PascalCase,与 API 响应字段保持一致
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/environment.js
CHANGED
|
@@ -18,6 +18,7 @@ const access_1 = require("./access");
|
|
|
18
18
|
const user_1 = require("./user");
|
|
19
19
|
const cloudBaseRun_1 = require("./cloudBaseRun");
|
|
20
20
|
const mysql_1 = require("./mysql");
|
|
21
|
+
const cloudApp_1 = require("./cloudApp");
|
|
21
22
|
const permission_1 = require("./permission");
|
|
22
23
|
class Environment {
|
|
23
24
|
constructor(context, envId) {
|
|
@@ -41,6 +42,7 @@ class Environment {
|
|
|
41
42
|
this.cloudBaseRunService = new cloudBaseRun_1.CloudBaseRunService(this);
|
|
42
43
|
this.mysqlService = new mysql_1.MysqlService(this);
|
|
43
44
|
this.permissionService = new permission_1.PermissionService(this);
|
|
45
|
+
this.cloudAppService = new cloudApp_1.CloudAppService(this);
|
|
44
46
|
}
|
|
45
47
|
async lazyInit() {
|
|
46
48
|
if (!this.inited) {
|
|
@@ -103,6 +105,9 @@ class Environment {
|
|
|
103
105
|
getMysqlService() {
|
|
104
106
|
return this.mysqlService;
|
|
105
107
|
}
|
|
108
|
+
getCloudAppService() {
|
|
109
|
+
return this.cloudAppService;
|
|
110
|
+
}
|
|
106
111
|
getPermissionService() {
|
|
107
112
|
return this.permissionService;
|
|
108
113
|
}
|
package/lib/index.js
CHANGED
|
@@ -70,9 +70,34 @@ class CloudBase {
|
|
|
70
70
|
get mysql() {
|
|
71
71
|
return this.currentEnvironment().getMysqlService();
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* 云托管服务(CloudBaseRun)
|
|
75
|
+
* 提供云托管版本流量配置等能力
|
|
76
|
+
* @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
|
|
77
|
+
*/
|
|
73
78
|
get cloudApp() {
|
|
74
79
|
return this.currentEnvironment().getCloudBaseRunService();
|
|
75
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* 云托管服务(CloudBaseRun)
|
|
83
|
+
* 提供云托管版本流量配置等能力
|
|
84
|
+
*/
|
|
85
|
+
get cloudBaseRun() {
|
|
86
|
+
return this.currentEnvironment().getCloudBaseRunService();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 云应用服务(CloudApp 统一部署)
|
|
90
|
+
* 提供 Web 应用的创建、部署、版本管理等能力
|
|
91
|
+
*/
|
|
92
|
+
get cloudAppService() {
|
|
93
|
+
return this.currentEnvironment().getCloudAppService();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 获取云应用服务
|
|
97
|
+
*/
|
|
98
|
+
getCloudAppService() {
|
|
99
|
+
return this.currentEnvironment().getCloudAppService();
|
|
100
|
+
}
|
|
76
101
|
commonService(service, version) {
|
|
77
102
|
return this.currentEnvironment().getCommonService(service, version);
|
|
78
103
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* CloudApp 统一部署服务接口导出
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("../cloudApp/types"), exports);
|
package/lib/interfaces/index.js
CHANGED
|
@@ -21,3 +21,4 @@ __exportStar(require("./base.interface"), exports);
|
|
|
21
21
|
__exportStar(require("./storage.interface"), exports);
|
|
22
22
|
__exportStar(require("./cam.interface"), exports);
|
|
23
23
|
__exportStar(require("./billing.interface"), exports);
|
|
24
|
+
__exportStar(require("./cloudApp.interface"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { ICreateCloudAppParams, ICreateCloudAppResult, IDescribeCloudAppListParams, IDescribeCloudAppListResult, IDescribeCloudAppInfoParams, IDescribeCloudAppInfoResult, IDeleteCloudAppParams, IDeleteCloudAppResult, IDescribeCloudAppVersionParams, IDescribeCloudAppVersionResult, IDescribeCloudAppVersionListParams, IDescribeCloudAppVersionListResult, IDeleteCloudAppVersionParams, IDeleteCloudAppVersionResult, IDescribeCloudAppCosInfoParams, IDescribeCloudAppCosInfoResult, IUploadCloudAppCodeParams, IUploadCloudAppCodeResult } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
/**
|
|
5
|
+
* CloudApp 统一部署服务
|
|
6
|
+
* 提供 Web 应用的创建、查询、删除、版本管理等功能
|
|
7
|
+
*/
|
|
8
|
+
export declare class CloudAppService {
|
|
9
|
+
private tcbService;
|
|
10
|
+
private environment;
|
|
11
|
+
constructor(environment: Environment);
|
|
12
|
+
/**
|
|
13
|
+
* 创建/更新 CloudApp 应用
|
|
14
|
+
* @param params 创建参数
|
|
15
|
+
*/
|
|
16
|
+
createApp(params: ICreateCloudAppParams): Promise<ICreateCloudAppResult>;
|
|
17
|
+
/**
|
|
18
|
+
* 获取 CloudApp 应用列表
|
|
19
|
+
* @param params 查询参数
|
|
20
|
+
*/
|
|
21
|
+
describeAppList(params: IDescribeCloudAppListParams): Promise<IDescribeCloudAppListResult>;
|
|
22
|
+
/**
|
|
23
|
+
* 获取 CloudApp 应用详情
|
|
24
|
+
* @param params 查询参数
|
|
25
|
+
*/
|
|
26
|
+
describeAppInfo(params: IDescribeCloudAppInfoParams): Promise<IDescribeCloudAppInfoResult>;
|
|
27
|
+
/**
|
|
28
|
+
* 删除 CloudApp 应用
|
|
29
|
+
* @param params 删除参数
|
|
30
|
+
*/
|
|
31
|
+
deleteApp(params: IDeleteCloudAppParams): Promise<IDeleteCloudAppResult>;
|
|
32
|
+
/**
|
|
33
|
+
* 获取 CloudApp 版本详情
|
|
34
|
+
* 不指定 versionName 或 buildId 时返回最新版本
|
|
35
|
+
* @param params 查询参数
|
|
36
|
+
*/
|
|
37
|
+
describeAppVersion(params: IDescribeCloudAppVersionParams): Promise<IDescribeCloudAppVersionResult>;
|
|
38
|
+
/**
|
|
39
|
+
* 获取 CloudApp 版本列表
|
|
40
|
+
* @param params 查询参数
|
|
41
|
+
*/
|
|
42
|
+
describeAppVersionList(params: IDescribeCloudAppVersionListParams): Promise<IDescribeCloudAppVersionListResult>;
|
|
43
|
+
/**
|
|
44
|
+
* 删除 CloudApp 版本
|
|
45
|
+
* @param params 删除参数
|
|
46
|
+
*/
|
|
47
|
+
deleteAppVersion(params: IDeleteCloudAppVersionParams): Promise<IDeleteCloudAppVersionResult>;
|
|
48
|
+
/**
|
|
49
|
+
* 获取 CloudApp COS 上传信息(预签名 URL)
|
|
50
|
+
* @param params 查询参数
|
|
51
|
+
*/
|
|
52
|
+
describeCosInfo(params: IDescribeCloudAppCosInfoParams): Promise<IDescribeCloudAppCosInfoResult>;
|
|
53
|
+
/**
|
|
54
|
+
* 上传本地代码到 COS
|
|
55
|
+
* 自动打包 ZIP 并上传到预签名 URL
|
|
56
|
+
*
|
|
57
|
+
* 注意:此方法不依赖应用是否已创建,可在创建应用前调用
|
|
58
|
+
* 返回的 cosTimestamp 用于 createApp 时传入 staticConfig.cosTimestamp
|
|
59
|
+
*
|
|
60
|
+
* @param params 上传参数
|
|
61
|
+
*/
|
|
62
|
+
uploadCode(params: IUploadCloudAppCodeParams): Promise<IUploadCloudAppCodeResult>;
|
|
63
|
+
/**
|
|
64
|
+
* 获取环境信息
|
|
65
|
+
*/
|
|
66
|
+
private getEnvInfo;
|
|
67
|
+
/**
|
|
68
|
+
* 校验必填参数
|
|
69
|
+
* @param params 参数对象
|
|
70
|
+
* @param fields 必填字段列表
|
|
71
|
+
*/
|
|
72
|
+
private validateRequiredParams;
|
|
73
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudApp 统一部署服务类型定义
|
|
3
|
+
* 支持 static-hosting(静态托管)和 http-function(预留)两种部署类型
|
|
4
|
+
*
|
|
5
|
+
* 命名规范:
|
|
6
|
+
* - 入参接口(IXxxParams):camelCase,通过 upperCaseObjKey 转换后透传给 API
|
|
7
|
+
* - 返回值接口(IXxxResult):PascalCase,与 API 响应字段保持一致
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 部署类型
|
|
11
|
+
* - static-hosting: 静态托管部署
|
|
12
|
+
* - http-function: HTTP 云函数部署(预留)
|
|
13
|
+
*/
|
|
14
|
+
export type DeployType = 'static-hosting' | 'http-function';
|
|
15
|
+
/**
|
|
16
|
+
* 构建类型
|
|
17
|
+
* - GIT: 从 Git 仓库构建
|
|
18
|
+
* - ZIP: 从 ZIP 包构建
|
|
19
|
+
* - TEMPLATE: 从模板构建
|
|
20
|
+
*/
|
|
21
|
+
export type BuildType = 'GIT' | 'ZIP' | 'TEMPLATE';
|
|
22
|
+
/**
|
|
23
|
+
* 构建状态
|
|
24
|
+
*/
|
|
25
|
+
export type BuildStatus = 'BUILDING' | 'SUCCESS' | 'FAILED';
|
|
26
|
+
/**
|
|
27
|
+
* 构建命令配置(入参)
|
|
28
|
+
*/
|
|
29
|
+
export interface IStaticCmd {
|
|
30
|
+
buildCmd?: string;
|
|
31
|
+
installCmd?: string;
|
|
32
|
+
deployCmd?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 静态环境变量配置(入参)
|
|
36
|
+
*/
|
|
37
|
+
export interface IStaticEnv {
|
|
38
|
+
variables?: Array<{
|
|
39
|
+
key: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 静态托管配置(入参)
|
|
45
|
+
*/
|
|
46
|
+
export interface IStaticConfig {
|
|
47
|
+
/** 框架类型:vue、react、nextjs 等 */
|
|
48
|
+
framework?: string;
|
|
49
|
+
/** Node.js 版本,默认 20 */
|
|
50
|
+
nodeJsVersion?: string;
|
|
51
|
+
/** 访问路径 */
|
|
52
|
+
appPath?: string;
|
|
53
|
+
/** 构建目录 */
|
|
54
|
+
buildPath?: string;
|
|
55
|
+
/** ZIP 文件地址(BuildType=ZIP/TEMPLATE 时使用) */
|
|
56
|
+
zipFileUrl?: string;
|
|
57
|
+
/** COS 时间戳(通过 uploadCode 上传后获取,BuildType=ZIP 时使用) */
|
|
58
|
+
cosTimestamp?: string;
|
|
59
|
+
/** COS 文件后缀 */
|
|
60
|
+
cosSuffix?: string;
|
|
61
|
+
/** 代码源平台:github、gitlab、gitee */
|
|
62
|
+
codeSource?: string;
|
|
63
|
+
/** 代码仓库 */
|
|
64
|
+
codeRepo?: string;
|
|
65
|
+
/** 代码分支 */
|
|
66
|
+
codeBranch?: string;
|
|
67
|
+
/** 构建命令配置 */
|
|
68
|
+
staticCmd?: IStaticCmd;
|
|
69
|
+
/** 构建环境变量 */
|
|
70
|
+
staticEnv?: IStaticEnv;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 静态托管构建命令配置(API 响应)
|
|
74
|
+
*/
|
|
75
|
+
export interface StaticCmd {
|
|
76
|
+
BuildCmd?: string;
|
|
77
|
+
InstallCmd?: string;
|
|
78
|
+
DeployCmd?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 静态托管环境变量配置(API 响应,对应文档 StaticEnvironment)
|
|
82
|
+
*/
|
|
83
|
+
export interface StaticEnv {
|
|
84
|
+
/** 环境变量数组,可能为 null */
|
|
85
|
+
Variables?: Array<{
|
|
86
|
+
Key: string;
|
|
87
|
+
Value: string;
|
|
88
|
+
}> | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 静态托管配置(API 响应,对应文档 StaticConfig)
|
|
92
|
+
* 被 CreateCloudApp、DescribeCloudAppVersion、DescribeCloudAppVersionList 引用
|
|
93
|
+
* 注意:所有字段均可能返回 null
|
|
94
|
+
*/
|
|
95
|
+
export interface CloudAppStaticConfig {
|
|
96
|
+
/** 框架类型:vue、react、nextjs 等 */
|
|
97
|
+
Framework?: string | null;
|
|
98
|
+
/** Node.js 版本,默认 20 */
|
|
99
|
+
NodeJsVersion?: string | null;
|
|
100
|
+
/** 访问路径 */
|
|
101
|
+
AppPath?: string | null;
|
|
102
|
+
/** 构建目录 */
|
|
103
|
+
BuildPath?: string | null;
|
|
104
|
+
/** ZIP 文件地址(BuildType=ZIP/TEMPLATE 时使用) */
|
|
105
|
+
ZipFileUrl?: string | null;
|
|
106
|
+
/** COS 时间戳 */
|
|
107
|
+
CosTimestamp?: string | null;
|
|
108
|
+
/** COS 文件后缀 */
|
|
109
|
+
CosSuffix?: string | null;
|
|
110
|
+
/** 代码源平台:github、gitlab、gitee */
|
|
111
|
+
CodeSource?: string | null;
|
|
112
|
+
/** 代码仓库 */
|
|
113
|
+
CodeRepo?: string | null;
|
|
114
|
+
/** 代码分支 */
|
|
115
|
+
CodeBranch?: string | null;
|
|
116
|
+
/** 构建命令配置 */
|
|
117
|
+
StaticCmd?: StaticCmd | null;
|
|
118
|
+
/** 构建环境变量 */
|
|
119
|
+
StaticEnv?: StaticEnv | null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 应用列表项(API 响应 CloudAppServiceItem)
|
|
123
|
+
*/
|
|
124
|
+
export interface CloudAppServiceItem {
|
|
125
|
+
ServiceName: string;
|
|
126
|
+
DeployType: string;
|
|
127
|
+
Framework?: string;
|
|
128
|
+
Domain?: string;
|
|
129
|
+
AppPath?: string;
|
|
130
|
+
CreateTime: string;
|
|
131
|
+
LatestVersionName?: string;
|
|
132
|
+
LatestStatus?: string;
|
|
133
|
+
LatestBuildTime?: string;
|
|
134
|
+
}
|
|
135
|
+
/** @deprecated 请使用 CloudAppServiceItem */
|
|
136
|
+
export type CloudAppItem = CloudAppServiceItem;
|
|
137
|
+
/**
|
|
138
|
+
* 版本信息(API 响应 CloudAppVersionItem)
|
|
139
|
+
*/
|
|
140
|
+
export interface CloudAppVersion {
|
|
141
|
+
VersionName: string;
|
|
142
|
+
BuildId: string;
|
|
143
|
+
BuildType?: string;
|
|
144
|
+
Status: string;
|
|
145
|
+
Framework?: string;
|
|
146
|
+
BuildTime?: string;
|
|
147
|
+
StaticConfig?: CloudAppStaticConfig;
|
|
148
|
+
}
|
|
149
|
+
export interface ICreateCloudAppParams {
|
|
150
|
+
/** 环境 ID(可选,默认从 Environment 获取) */
|
|
151
|
+
envId?: string;
|
|
152
|
+
/** 部署类型:static-hosting / http-function */
|
|
153
|
+
deployType: DeployType;
|
|
154
|
+
/** 服务名称 */
|
|
155
|
+
serviceName: string;
|
|
156
|
+
/** 构建类型:GIT / ZIP / TEMPLATE */
|
|
157
|
+
buildType?: BuildType;
|
|
158
|
+
/** 静态托管配置(deployType 为 static-hosting 时使用) */
|
|
159
|
+
staticConfig?: IStaticConfig;
|
|
160
|
+
}
|
|
161
|
+
export interface ICreateCloudAppResult {
|
|
162
|
+
ServiceName: string;
|
|
163
|
+
BuildId: string;
|
|
164
|
+
VersionName: string;
|
|
165
|
+
RequestId: string;
|
|
166
|
+
}
|
|
167
|
+
export interface IDescribeCloudAppListParams {
|
|
168
|
+
/** 环境 ID(可选) */
|
|
169
|
+
envId?: string;
|
|
170
|
+
/** 部署类型 */
|
|
171
|
+
deployType: DeployType;
|
|
172
|
+
/** 页码(从 1 开始) */
|
|
173
|
+
pageNo?: number;
|
|
174
|
+
/** 每页大小 */
|
|
175
|
+
pageSize?: number;
|
|
176
|
+
/** 搜索关键字,按应用名模糊搜索 */
|
|
177
|
+
searchKey?: string;
|
|
178
|
+
}
|
|
179
|
+
export interface IDescribeCloudAppListResult {
|
|
180
|
+
Total: number;
|
|
181
|
+
ServiceList: CloudAppServiceItem[];
|
|
182
|
+
RequestId: string;
|
|
183
|
+
}
|
|
184
|
+
export interface IDescribeCloudAppInfoParams {
|
|
185
|
+
/** 环境 ID(可选) */
|
|
186
|
+
envId?: string;
|
|
187
|
+
/** 部署类型 */
|
|
188
|
+
deployType: DeployType;
|
|
189
|
+
/** 服务名称 */
|
|
190
|
+
serviceName: string;
|
|
191
|
+
}
|
|
192
|
+
export interface IDescribeCloudAppInfoResult {
|
|
193
|
+
ServiceName: string;
|
|
194
|
+
DeployType: string;
|
|
195
|
+
Framework?: string;
|
|
196
|
+
Domain?: string;
|
|
197
|
+
AppPath?: string;
|
|
198
|
+
CreateTime: string;
|
|
199
|
+
LatestVersionName?: string;
|
|
200
|
+
LatestStatus?: string;
|
|
201
|
+
LatestBuildTime?: string;
|
|
202
|
+
RequestId: string;
|
|
203
|
+
}
|
|
204
|
+
export interface IDeleteCloudAppParams {
|
|
205
|
+
/** 环境 ID(可选) */
|
|
206
|
+
envId?: string;
|
|
207
|
+
/** 部署类型 */
|
|
208
|
+
deployType: DeployType;
|
|
209
|
+
/** 服务名称 */
|
|
210
|
+
serviceName: string;
|
|
211
|
+
}
|
|
212
|
+
export interface IDeleteCloudAppResult {
|
|
213
|
+
Result: boolean;
|
|
214
|
+
RequestId: string;
|
|
215
|
+
}
|
|
216
|
+
export interface IDescribeCloudAppVersionParams {
|
|
217
|
+
/** 环境 ID(可选) */
|
|
218
|
+
envId?: string;
|
|
219
|
+
/** 部署类型 */
|
|
220
|
+
deployType: DeployType;
|
|
221
|
+
/** 服务名称 */
|
|
222
|
+
serviceName: string;
|
|
223
|
+
/** 版本名称(与 buildId 二选一) */
|
|
224
|
+
versionName?: string;
|
|
225
|
+
/** 构建 ID(与 versionName 二选一) */
|
|
226
|
+
buildId?: string;
|
|
227
|
+
}
|
|
228
|
+
export interface IDescribeCloudAppVersionResult {
|
|
229
|
+
BuildType: string;
|
|
230
|
+
BuildId: string;
|
|
231
|
+
Status: BuildStatus;
|
|
232
|
+
Framework?: string;
|
|
233
|
+
StaticConfig?: CloudAppStaticConfig;
|
|
234
|
+
BuildTime?: string;
|
|
235
|
+
RequestId: string;
|
|
236
|
+
}
|
|
237
|
+
export interface IDescribeCloudAppVersionListParams {
|
|
238
|
+
/** 环境 ID(可选) */
|
|
239
|
+
envId?: string;
|
|
240
|
+
/** 部署类型 */
|
|
241
|
+
deployType: DeployType;
|
|
242
|
+
/** 服务名称 */
|
|
243
|
+
serviceName: string;
|
|
244
|
+
/** 页码(从 1 开始) */
|
|
245
|
+
pageNo?: number;
|
|
246
|
+
/** 每页大小 */
|
|
247
|
+
pageSize?: number;
|
|
248
|
+
}
|
|
249
|
+
export interface IDescribeCloudAppVersionListResult {
|
|
250
|
+
Total: number;
|
|
251
|
+
VersionList: CloudAppVersion[] | null;
|
|
252
|
+
RequestId: string;
|
|
253
|
+
}
|
|
254
|
+
export interface IDeleteCloudAppVersionParams {
|
|
255
|
+
/** 环境 ID(可选) */
|
|
256
|
+
envId?: string;
|
|
257
|
+
/** 部署类型 */
|
|
258
|
+
deployType: DeployType;
|
|
259
|
+
/** 服务名称 */
|
|
260
|
+
serviceName: string;
|
|
261
|
+
/** 版本名称 */
|
|
262
|
+
versionName: string;
|
|
263
|
+
}
|
|
264
|
+
export interface IDeleteCloudAppVersionResult {
|
|
265
|
+
Result: boolean;
|
|
266
|
+
RequestId: string;
|
|
267
|
+
}
|
|
268
|
+
export interface IDescribeCloudAppCosInfoParams {
|
|
269
|
+
/** 环境 ID(可选) */
|
|
270
|
+
envId?: string;
|
|
271
|
+
/** 部署类型 */
|
|
272
|
+
deployType: DeployType;
|
|
273
|
+
/** 服务名称 */
|
|
274
|
+
serviceName: string;
|
|
275
|
+
/** Unix 时间戳(用于指定文件路径,不传则自动生成) */
|
|
276
|
+
unixTimestamp?: string;
|
|
277
|
+
/** 文件后缀(默认 .zip) */
|
|
278
|
+
suffix?: string;
|
|
279
|
+
/** 是否需要下载 URL */
|
|
280
|
+
needDownload?: boolean;
|
|
281
|
+
}
|
|
282
|
+
export interface CosHeader {
|
|
283
|
+
Key: string;
|
|
284
|
+
Value: string;
|
|
285
|
+
}
|
|
286
|
+
export interface IDescribeCloudAppCosInfoResult {
|
|
287
|
+
UploadUrl: string;
|
|
288
|
+
UploadHeaders?: CosHeader[];
|
|
289
|
+
DownloadUrl?: string;
|
|
290
|
+
DownloadHeaders?: CosHeader[];
|
|
291
|
+
UnixTimestamp: string;
|
|
292
|
+
RequestId: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* 上传进度信息
|
|
296
|
+
*/
|
|
297
|
+
export interface IProgressData {
|
|
298
|
+
loaded: number;
|
|
299
|
+
total: number;
|
|
300
|
+
percent: number;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* 上传代码参数
|
|
304
|
+
*/
|
|
305
|
+
export interface IUploadCloudAppCodeParams {
|
|
306
|
+
/** 部署类型 */
|
|
307
|
+
deployType: DeployType;
|
|
308
|
+
/** 服务名称 */
|
|
309
|
+
serviceName: string;
|
|
310
|
+
/** 本地文件夹路径 */
|
|
311
|
+
localPath: string;
|
|
312
|
+
/** 忽略的文件/目录模式 */
|
|
313
|
+
ignore?: string[];
|
|
314
|
+
/** 进度回调 */
|
|
315
|
+
onProgress?: (progress: IProgressData) => void;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 上传代码结果
|
|
319
|
+
*/
|
|
320
|
+
export interface IUploadCloudAppCodeResult {
|
|
321
|
+
/** COS 时间戳(用于 createApp 时传入 staticConfig.cosTimestamp) */
|
|
322
|
+
cosTimestamp: string;
|
|
323
|
+
/** Unix 时间戳(与 cosTimestamp 相同) */
|
|
324
|
+
unixTimestamp: string;
|
|
325
|
+
}
|
package/types/environment.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { AccessService } from './access';
|
|
|
13
13
|
import { UserService } from './user';
|
|
14
14
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
15
15
|
import { MysqlService } from './mysql';
|
|
16
|
+
import { CloudAppService } from './cloudApp';
|
|
16
17
|
import { EnvInfo } from './interfaces';
|
|
17
18
|
import { PermissionService } from './permission';
|
|
18
19
|
export declare class Environment {
|
|
@@ -35,6 +36,7 @@ export declare class Environment {
|
|
|
35
36
|
private cloudBaseRunService;
|
|
36
37
|
private mysqlService;
|
|
37
38
|
private permissionService;
|
|
39
|
+
private cloudAppService;
|
|
38
40
|
constructor(context: CloudBaseContext, envId: string);
|
|
39
41
|
lazyInit(): Promise<any>;
|
|
40
42
|
getEnvId(): string;
|
|
@@ -52,6 +54,7 @@ export declare class Environment {
|
|
|
52
54
|
getUserService(): UserService;
|
|
53
55
|
getCloudBaseRunService(): CloudBaseRunService;
|
|
54
56
|
getMysqlService(): MysqlService;
|
|
57
|
+
getCloudAppService(): CloudAppService;
|
|
55
58
|
getPermissionService(): PermissionService;
|
|
56
59
|
getCommonService(serviceType: string, serviceVersion: any): CommonService;
|
|
57
60
|
getServicesEnvInfo(): Promise<any>;
|
package/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { CloudBaseRunService } from './cloudBaseRun';
|
|
|
16
16
|
import { MysqlService } from './mysql';
|
|
17
17
|
import { DocsService } from './docs';
|
|
18
18
|
import { PermissionService } from './permission';
|
|
19
|
+
import { CloudAppService } from './cloudApp';
|
|
19
20
|
interface CloudBaseConfig {
|
|
20
21
|
secretId?: string;
|
|
21
22
|
secretKey?: string;
|
|
@@ -53,7 +54,26 @@ declare class CloudBase {
|
|
|
53
54
|
get hosting(): HostingService;
|
|
54
55
|
get access(): AccessService;
|
|
55
56
|
get mysql(): MysqlService;
|
|
57
|
+
/**
|
|
58
|
+
* 云托管服务(CloudBaseRun)
|
|
59
|
+
* 提供云托管版本流量配置等能力
|
|
60
|
+
* @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
|
|
61
|
+
*/
|
|
56
62
|
get cloudApp(): CloudBaseRunService;
|
|
63
|
+
/**
|
|
64
|
+
* 云托管服务(CloudBaseRun)
|
|
65
|
+
* 提供云托管版本流量配置等能力
|
|
66
|
+
*/
|
|
67
|
+
get cloudBaseRun(): CloudBaseRunService;
|
|
68
|
+
/**
|
|
69
|
+
* 云应用服务(CloudApp 统一部署)
|
|
70
|
+
* 提供 Web 应用的创建、部署、版本管理等能力
|
|
71
|
+
*/
|
|
72
|
+
get cloudAppService(): CloudAppService;
|
|
73
|
+
/**
|
|
74
|
+
* 获取云应用服务
|
|
75
|
+
*/
|
|
76
|
+
getCloudAppService(): CloudAppService;
|
|
57
77
|
commonService(service?: string, version?: string): CommonService;
|
|
58
78
|
get env(): EnvService;
|
|
59
79
|
get log(): LogService;
|