@cloudbase/manager-node 4.7.4-beta.0 → 4.7.4-beta.2
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/cloudrun/index.js +2 -93
- package/lib/cloudrun/type.js +1 -12
- package/lib/constant.js +6 -1
- package/lib/function/index.js +70 -46
- package/package.json +1 -1
- package/types/cloudrun/index.d.ts +1 -17
- package/types/cloudrun/type.d.ts +0 -78
- package/types/constant.d.ts +4 -0
- package/types/interfaces/function.interface.d.ts +10 -0
package/lib/cloudrun/index.js
CHANGED
|
@@ -16,7 +16,6 @@ const archiver_1 = __importDefault(require("archiver"));
|
|
|
16
16
|
const fs_extra_1 = require("fs-extra");
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const utils_1 = require("../utils");
|
|
19
|
-
const type_1 = require("./type");
|
|
20
19
|
/**
|
|
21
20
|
* 云托管服务管理类
|
|
22
21
|
* 提供云托管服务的初始化、下载、列表查询和删除等功能
|
|
@@ -106,87 +105,6 @@ class CloudRunService {
|
|
|
106
105
|
ServerType: params === null || params === void 0 ? void 0 : params.serverType
|
|
107
106
|
}));
|
|
108
107
|
}
|
|
109
|
-
async setTraffic(serverName, stablePercent, canaryPercent) {
|
|
110
|
-
// 校验比例之和是否为100%
|
|
111
|
-
if (stablePercent + canaryPercent !== 100) {
|
|
112
|
-
throw new Error('稳定版本流量比例和灰度版本流量比例之和必须等于 100');
|
|
113
|
-
}
|
|
114
|
-
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
115
|
-
const { Task } = await this.tcbrService.request('DescribeServerManageTask', {
|
|
116
|
-
EnvId: envConfig.EnvId,
|
|
117
|
-
ServerName: serverName, // 服务名
|
|
118
|
-
TaskId: 0 // 任务Id
|
|
119
|
-
});
|
|
120
|
-
// 判断是否存在灰度版本
|
|
121
|
-
const isGary = (Task === null || Task === void 0 ? void 0 : Task.ReleaseType) === type_1.ReleaseTypeEnum.GRAY && (Task === null || Task === void 0 ? void 0 : Task.Status) === 'running';
|
|
122
|
-
if (!isGary) {
|
|
123
|
-
throw new Error('不存在灰度版本或版本部署未完成');
|
|
124
|
-
}
|
|
125
|
-
// 获取当前版本和灰度版本
|
|
126
|
-
const { ReleaseOrderInfo } = await this.tcbrService.request('DescribeReleaseOrder', {
|
|
127
|
-
EnvId: envConfig.EnvId, // 环境 Id
|
|
128
|
-
ServerName: serverName // 服务名
|
|
129
|
-
});
|
|
130
|
-
const { CurrentVersion, ReleaseVersion } = ReleaseOrderInfo;
|
|
131
|
-
// 设置版本比例
|
|
132
|
-
return await this.tcbrService.request('ReleaseGray', {
|
|
133
|
-
EnvId: envConfig.EnvId, // 环境 Id
|
|
134
|
-
ServerName: serverName, // 服务名
|
|
135
|
-
GrayType: "gray",
|
|
136
|
-
TrafficType: "FLOW",
|
|
137
|
-
GrayFlowRatio: canaryPercent,
|
|
138
|
-
VersionFlowItems: [{
|
|
139
|
-
VersionName: CurrentVersion.VersionName,
|
|
140
|
-
FlowRatio: stablePercent,
|
|
141
|
-
IsDefaultPriority: true,
|
|
142
|
-
Priority: 1,
|
|
143
|
-
}, {
|
|
144
|
-
VersionName: ReleaseVersion.VersionName,
|
|
145
|
-
FlowRatio: canaryPercent,
|
|
146
|
-
IsDefaultPriority: false,
|
|
147
|
-
Priority: 2,
|
|
148
|
-
}]
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* 完成灰度
|
|
153
|
-
*/
|
|
154
|
-
async promote(serverName) {
|
|
155
|
-
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
156
|
-
// 获取当前版本和灰度版本
|
|
157
|
-
const { ReleaseOrderInfo } = await this.tcbrService.request('DescribeReleaseOrder', {
|
|
158
|
-
EnvId: envConfig.EnvId, // 环境 Id
|
|
159
|
-
ServerName: serverName // 服务名
|
|
160
|
-
});
|
|
161
|
-
const { CurrentVersion, ReleaseVersion } = ReleaseOrderInfo;
|
|
162
|
-
const res = await this.tcbrService.request('ReleaseGray', {
|
|
163
|
-
EnvId: envConfig.EnvId, // 环境 Id
|
|
164
|
-
ServerName: serverName, // 服务名
|
|
165
|
-
GrayType: "gray",
|
|
166
|
-
TrafficType: "FLOW",
|
|
167
|
-
GrayFlowRatio: 100,
|
|
168
|
-
VersionFlowItems: [{ VersionName: ReleaseVersion.VersionName, FlowRatio: 100, Priority: 0, IsDefaultPriority: true }],
|
|
169
|
-
CloseGrayRelease: true,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* 取消灰度
|
|
174
|
-
*/
|
|
175
|
-
async rollback(serverName) {
|
|
176
|
-
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
177
|
-
const { Task } = await this.tcbrService.request('DescribeServerManageTask', {
|
|
178
|
-
EnvId: envConfig.EnvId,
|
|
179
|
-
ServerName: serverName, // 服务名
|
|
180
|
-
TaskId: 0 // 任务Id
|
|
181
|
-
});
|
|
182
|
-
const res = await this.tcbrService.request('OperateServerManage', {
|
|
183
|
-
EnvId: envConfig.EnvId, // 环境 Id
|
|
184
|
-
ServerName: serverName,
|
|
185
|
-
TaskId: Task.Id,
|
|
186
|
-
OperateType: 'go_back',
|
|
187
|
-
});
|
|
188
|
-
return res;
|
|
189
|
-
}
|
|
190
108
|
/**
|
|
191
109
|
*查询云托管服务详情
|
|
192
110
|
* @param {Object} params 查询参数
|
|
@@ -238,7 +156,7 @@ class CloudRunService {
|
|
|
238
156
|
* @returns {Promise<IResponseInfo>} 返回部署操作的响应信息
|
|
239
157
|
*/
|
|
240
158
|
async deploy(params) {
|
|
241
|
-
const { serverName, targetPath = process.cwd(), serverConfig
|
|
159
|
+
const { serverName, targetPath = process.cwd(), serverConfig } = params;
|
|
242
160
|
/**
|
|
243
161
|
* 参数校验和默认值设置
|
|
244
162
|
*/
|
|
@@ -286,7 +204,7 @@ class CloudRunService {
|
|
|
286
204
|
RepoLanguage: 'Node.js'
|
|
287
205
|
};
|
|
288
206
|
}
|
|
289
|
-
deployInfo.ReleaseType =
|
|
207
|
+
deployInfo.ReleaseType = 'FULL';
|
|
290
208
|
return this._upsertFunction(false, {
|
|
291
209
|
name: serverName,
|
|
292
210
|
deployInfo,
|
|
@@ -373,15 +291,6 @@ __decorate([
|
|
|
373
291
|
__decorate([
|
|
374
292
|
(0, utils_1.preLazy)()
|
|
375
293
|
], CloudRunService.prototype, "list", null);
|
|
376
|
-
__decorate([
|
|
377
|
-
(0, utils_1.preLazy)()
|
|
378
|
-
], CloudRunService.prototype, "setTraffic", null);
|
|
379
|
-
__decorate([
|
|
380
|
-
(0, utils_1.preLazy)()
|
|
381
|
-
], CloudRunService.prototype, "promote", null);
|
|
382
|
-
__decorate([
|
|
383
|
-
(0, utils_1.preLazy)()
|
|
384
|
-
], CloudRunService.prototype, "rollback", null);
|
|
385
294
|
__decorate([
|
|
386
295
|
(0, utils_1.preLazy)()
|
|
387
296
|
], CloudRunService.prototype, "detail", null);
|
package/lib/cloudrun/type.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CloudrunServerType = void 0;
|
|
4
4
|
var CloudrunServerType;
|
|
5
5
|
(function (CloudrunServerType) {
|
|
6
6
|
/**
|
|
@@ -12,14 +12,3 @@ var CloudrunServerType;
|
|
|
12
12
|
*/
|
|
13
13
|
CloudrunServerType["Container"] = "container";
|
|
14
14
|
})(CloudrunServerType || (exports.CloudrunServerType = CloudrunServerType = {}));
|
|
15
|
-
var ReleaseTypeEnum;
|
|
16
|
-
(function (ReleaseTypeEnum) {
|
|
17
|
-
/**
|
|
18
|
-
* 灰度发布
|
|
19
|
-
*/
|
|
20
|
-
ReleaseTypeEnum["GRAY"] = "GRAY";
|
|
21
|
-
/**
|
|
22
|
-
* 全量发布
|
|
23
|
-
*/
|
|
24
|
-
ReleaseTypeEnum["FULL"] = "FULL";
|
|
25
|
-
})(ReleaseTypeEnum || (exports.ReleaseTypeEnum = ReleaseTypeEnum = {}));
|
package/lib/constant.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// static credentail = 'credential'
|
|
5
5
|
// }
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.INTERNAL_ENDPOINT_REGION = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
|
|
7
|
+
exports.SCF_TEMP_COS = exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.INTERNAL_ENDPOINT_REGION = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
|
|
8
8
|
exports.ENV_NAME = {
|
|
9
9
|
ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
|
|
10
10
|
ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
|
|
@@ -59,3 +59,8 @@ exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
|
|
|
59
59
|
exports.INTERNAL_ENDPOINT_REGION = process.env.INTERNAL_ENDPOINT_REGION;
|
|
60
60
|
exports.COS_SDK_PROTOCOL = process.env.COS_SDK_PROTOCOL;
|
|
61
61
|
exports.COS_SDK_KEEPALIVE = process.env.COS_SDK_KEEPALIVE;
|
|
62
|
+
// SCF 临时 COS 配置(用于函数代码上传)
|
|
63
|
+
exports.SCF_TEMP_COS = {
|
|
64
|
+
APPID: '1253665819',
|
|
65
|
+
REGION: 'ap-shanghai'
|
|
66
|
+
};
|
package/lib/function/index.js
CHANGED
|
@@ -25,7 +25,7 @@ function isNodeFunction(runtime) {
|
|
|
25
25
|
}
|
|
26
26
|
// 解析函数配置,换成请求参数
|
|
27
27
|
function configToParams(options) {
|
|
28
|
-
var _a, _b, _c, _d, _e;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
29
29
|
const { func, codeSecret, baseParams } = options;
|
|
30
30
|
let installDependency;
|
|
31
31
|
// Node 函数默认安装依赖
|
|
@@ -81,6 +81,26 @@ function configToParams(options) {
|
|
|
81
81
|
// HTTP 云函数类型
|
|
82
82
|
if ((func === null || func === void 0 ? void 0 : func.type) === 'HTTP') {
|
|
83
83
|
params.Type = 'HTTP';
|
|
84
|
+
// WebSocket 协议支持
|
|
85
|
+
if ((func === null || func === void 0 ? void 0 : func.protocolType) === 'WS') {
|
|
86
|
+
params.ProtocolType = 'WS';
|
|
87
|
+
// 协议参数,直接透传或使用默认值
|
|
88
|
+
// 参考文档:https://cloud.tencent.com/document/api/583/17244#ProtocolParams
|
|
89
|
+
const idleTimeOut = (_g = (_f = func === null || func === void 0 ? void 0 : func.protocolParams) === null || _f === void 0 ? void 0 : _f.wsParams) === null || _g === void 0 ? void 0 : _g.idleTimeOut;
|
|
90
|
+
params.ProtocolParams = {
|
|
91
|
+
WSParams: {
|
|
92
|
+
IdleTimeOut: typeof idleTimeOut === 'number' ? idleTimeOut : 15
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// 多并发配置
|
|
97
|
+
// 参考文档:https://cloud.tencent.com/document/api/583/17244#InstanceConcurrencyConfig
|
|
98
|
+
if (func === null || func === void 0 ? void 0 : func.instanceConcurrencyConfig) {
|
|
99
|
+
params.InstanceConcurrencyConfig = {
|
|
100
|
+
DynamicEnabled: func.instanceConcurrencyConfig.dynamicEnabled || 'FALSE',
|
|
101
|
+
MaxConcurrency: func.instanceConcurrencyConfig.maxConcurrency || 10
|
|
102
|
+
};
|
|
103
|
+
}
|
|
84
104
|
}
|
|
85
105
|
// 云函数描述
|
|
86
106
|
if (func === null || func === void 0 ? void 0 : func.description) {
|
|
@@ -103,12 +123,13 @@ class FunctionService {
|
|
|
103
123
|
* @memberof FunctionService
|
|
104
124
|
*/
|
|
105
125
|
async updateFunctionIncrementalCode(funcParam) {
|
|
106
|
-
const { env } = this.getFunctionConfig();
|
|
126
|
+
const { env, namespace } = this.getFunctionConfig();
|
|
107
127
|
const { functionRootPath, func, deleteFiles, addFiles } = funcParam;
|
|
108
128
|
const { name, runtime } = func;
|
|
109
129
|
const params = {
|
|
110
130
|
FunctionName: name,
|
|
111
|
-
EnvId: env
|
|
131
|
+
EnvId: env,
|
|
132
|
+
Namespace: namespace
|
|
112
133
|
};
|
|
113
134
|
let packer;
|
|
114
135
|
let base64;
|
|
@@ -249,9 +270,9 @@ class FunctionService {
|
|
|
249
270
|
*/
|
|
250
271
|
async listFunctions(limit = 20, offset = 0) {
|
|
251
272
|
// 获取Function 环境配置
|
|
252
|
-
const {
|
|
253
|
-
const res = await this.
|
|
254
|
-
|
|
273
|
+
const { env } = this.getFunctionConfig();
|
|
274
|
+
const res = await this.tcbService.request('ListFunctions', {
|
|
275
|
+
EnvId: env,
|
|
255
276
|
Limit: limit,
|
|
256
277
|
Offset: offset
|
|
257
278
|
});
|
|
@@ -282,8 +303,8 @@ class FunctionService {
|
|
|
282
303
|
const { envId } = options;
|
|
283
304
|
while (true) {
|
|
284
305
|
try {
|
|
285
|
-
const res = await this.
|
|
286
|
-
|
|
306
|
+
const res = await this.tcbService.request('ListFunctions', {
|
|
307
|
+
EnvId: envId,
|
|
287
308
|
Limit: pageSize,
|
|
288
309
|
Offset: currentOffset
|
|
289
310
|
});
|
|
@@ -614,7 +635,8 @@ class FunctionService {
|
|
|
614
635
|
}
|
|
615
636
|
catch (e) {
|
|
616
637
|
throw new error_1.CloudBaseError(`[${func.name}] 更新函数配置失败:${e.message}`, {
|
|
617
|
-
code: e.code
|
|
638
|
+
code: e.code,
|
|
639
|
+
requestId: e.requestId
|
|
618
640
|
});
|
|
619
641
|
}
|
|
620
642
|
}
|
|
@@ -663,8 +685,9 @@ class FunctionService {
|
|
|
663
685
|
return res;
|
|
664
686
|
}
|
|
665
687
|
catch (e) {
|
|
666
|
-
throw new error_1.CloudBaseError(`[${funcName}]
|
|
667
|
-
code: e.code
|
|
688
|
+
throw new error_1.CloudBaseError(`[${funcName}] 函数代码更新失败:${e.message}`, {
|
|
689
|
+
code: e.code,
|
|
690
|
+
requestId: e.requestId
|
|
668
691
|
});
|
|
669
692
|
}
|
|
670
693
|
}
|
|
@@ -689,7 +712,9 @@ class FunctionService {
|
|
|
689
712
|
return Object.assign({ RequestId }, Result);
|
|
690
713
|
}
|
|
691
714
|
catch (e) {
|
|
692
|
-
throw new error_1.CloudBaseError(`[${name}]
|
|
715
|
+
throw new error_1.CloudBaseError(`[${name}] 调用失败:${e.message}`, {
|
|
716
|
+
requestId: e.requestId
|
|
717
|
+
});
|
|
693
718
|
}
|
|
694
719
|
}
|
|
695
720
|
/**
|
|
@@ -767,7 +792,8 @@ class FunctionService {
|
|
|
767
792
|
catch (e) {
|
|
768
793
|
throw new error_1.CloudBaseError(`[${name}] 创建触发器失败:${e.message}`, {
|
|
769
794
|
action: e.action,
|
|
770
|
-
code: e.code
|
|
795
|
+
code: e.code,
|
|
796
|
+
requestId: e.requestId
|
|
771
797
|
});
|
|
772
798
|
}
|
|
773
799
|
}
|
|
@@ -859,7 +885,9 @@ class FunctionService {
|
|
|
859
885
|
return { Url, RequestId, CodeSha256 };
|
|
860
886
|
}
|
|
861
887
|
catch (e) {
|
|
862
|
-
throw new error_1.CloudBaseError(`[${functionName}]
|
|
888
|
+
throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:${e.message}`, {
|
|
889
|
+
requestId: e.requestId
|
|
890
|
+
});
|
|
863
891
|
}
|
|
864
892
|
}
|
|
865
893
|
// 函数绑定文件层
|
|
@@ -1032,9 +1060,9 @@ class FunctionService {
|
|
|
1032
1060
|
return;
|
|
1033
1061
|
// 创建失败
|
|
1034
1062
|
if (Status === constant_1.SCF_STATUS.CREATE_FAILED) {
|
|
1035
|
-
|
|
1036
|
-
const
|
|
1037
|
-
throw new error_1.CloudBaseError(
|
|
1063
|
+
const errorDetails = (StatusReasons === null || StatusReasons === void 0 ? void 0 : StatusReasons.map(item => `[${item.ErrorCode}] ${item.ErrorMessage}`).join('\n')) || '';
|
|
1064
|
+
const errorMsg = `云函数创建失败${StatusDesc ? `\n状态描述: ${StatusDesc}` : ''}${errorDetails ? `\n失败信息: ${errorDetails}` : ''}`;
|
|
1065
|
+
throw new error_1.CloudBaseError(errorMsg, { requestId: RequestId });
|
|
1038
1066
|
}
|
|
1039
1067
|
// 函数状态正常
|
|
1040
1068
|
clearInterval(ticker);
|
|
@@ -1194,11 +1222,10 @@ class FunctionService {
|
|
|
1194
1222
|
const zipFilePath = await packer.compressFiles();
|
|
1195
1223
|
// 3. 初始化 cos 并上传
|
|
1196
1224
|
const tempCosObjectName = `/${cosDate}/${objectPath}`;
|
|
1197
|
-
const TEMP_COS_APPID = '1253665819';
|
|
1198
1225
|
const uploadParams = {
|
|
1199
|
-
Bucket: `shtempcos-${
|
|
1226
|
+
Bucket: `shtempcos-${constant_1.SCF_TEMP_COS.APPID}`,
|
|
1200
1227
|
Key: tempCosObjectName,
|
|
1201
|
-
Region:
|
|
1228
|
+
Region: constant_1.SCF_TEMP_COS.REGION,
|
|
1202
1229
|
FilePath: zipFilePath,
|
|
1203
1230
|
};
|
|
1204
1231
|
const cos = new cos_nodejs_sdk_v5_1.default({
|
|
@@ -1212,7 +1239,7 @@ class FunctionService {
|
|
|
1212
1239
|
// 清理临时文件
|
|
1213
1240
|
await packer.clean();
|
|
1214
1241
|
if (err) {
|
|
1215
|
-
reject(err);
|
|
1242
|
+
reject(new error_1.CloudBaseError(`COS 上传失败: ${err.message || err}`));
|
|
1216
1243
|
}
|
|
1217
1244
|
else {
|
|
1218
1245
|
resolve(data);
|
|
@@ -1323,32 +1350,28 @@ class FunctionService {
|
|
|
1323
1350
|
root: functionRootPath
|
|
1324
1351
|
});
|
|
1325
1352
|
await packer.build();
|
|
1326
|
-
//
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const cosResult = await this.uploadFunctionZipToCos(options, installDependency);
|
|
1353
|
+
// 指定 zip 上传方式:走 ZipFile base64 上传
|
|
1354
|
+
if (deployMode === 'zip') {
|
|
1355
|
+
// 判断是否超过 ZipFile 上传大小限制(1.5MB)
|
|
1356
|
+
const reachMax = await packer.isReachMaxSize();
|
|
1357
|
+
if (reachMax) {
|
|
1358
|
+
throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式(deployMode: "cos")');
|
|
1359
|
+
}
|
|
1360
|
+
const base64 = await packer.getBase64Code();
|
|
1361
|
+
if (!(base64 === null || base64 === void 0 ? void 0 : base64.length)) {
|
|
1362
|
+
throw new error_1.CloudBaseError('文件不能为空');
|
|
1363
|
+
}
|
|
1364
|
+
console.log(`[${func.name}] 部署方式: ZIP base64 上传`);
|
|
1339
1365
|
return {
|
|
1340
|
-
|
|
1341
|
-
CosBucketRegion: 'ap-shanghai',
|
|
1342
|
-
TempCosObjectName: `/${legacyResult.Key}`
|
|
1366
|
+
ZipFile: base64
|
|
1343
1367
|
};
|
|
1344
1368
|
}
|
|
1345
|
-
//
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
throw new error_1.CloudBaseError('文件不能为空');
|
|
1349
|
-
}
|
|
1369
|
+
// 默认走 COS 上传
|
|
1370
|
+
console.log(`[${func.name}] 部署方式: COS 上传`);
|
|
1371
|
+
const legacyResult = await this.uploadFunctionZipToCosLegacy(options, installDependency);
|
|
1350
1372
|
return {
|
|
1351
|
-
|
|
1373
|
+
CosBucketRegion: constant_1.SCF_TEMP_COS.REGION,
|
|
1374
|
+
TempCosObjectName: `/${legacyResult.Key}`
|
|
1352
1375
|
};
|
|
1353
1376
|
}
|
|
1354
1377
|
// 获取 COS 临时信息
|
|
@@ -1387,10 +1410,11 @@ class FunctionService {
|
|
|
1387
1410
|
* @memberof FunctionService
|
|
1388
1411
|
*/
|
|
1389
1412
|
getFunctionConfig() {
|
|
1390
|
-
var _a;
|
|
1413
|
+
var _a, _b, _c, _d;
|
|
1391
1414
|
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
1392
|
-
|
|
1393
|
-
const
|
|
1415
|
+
// Functions 可能为空
|
|
1416
|
+
const namespace = ((_b = (_a = envConfig.Functions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Namespace) || '';
|
|
1417
|
+
const appId = (_d = (_c = envConfig.Storages) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.AppId;
|
|
1394
1418
|
const { proxy } = this.environment.cloudBaseContext;
|
|
1395
1419
|
return {
|
|
1396
1420
|
proxy,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IResponseInfo } from '../interfaces';
|
|
3
|
-
import { CloudrunServerType, ICloudrunDetailResponse, ICloudrunListResponse, ICloudrunServerBaseConfig, ICloudrunServerBaseInfo, IDiffConfigItem, ITemplate
|
|
3
|
+
import { CloudrunServerType, ICloudrunDetailResponse, ICloudrunListResponse, ICloudrunServerBaseConfig, ICloudrunServerBaseInfo, IDiffConfigItem, ITemplate } from './type';
|
|
4
4
|
/**
|
|
5
5
|
* 云托管服务管理类
|
|
6
6
|
* 提供云托管服务的初始化、下载、列表查询和删除等功能
|
|
@@ -56,19 +56,6 @@ export declare class CloudRunService {
|
|
|
56
56
|
serverName?: string;
|
|
57
57
|
serverType?: CloudrunServerType;
|
|
58
58
|
}): Promise<ICloudrunListResponse>;
|
|
59
|
-
setTraffic(serverName: string, stablePercent: number, canaryPercent: number): Promise<{
|
|
60
|
-
RequestId?: string;
|
|
61
|
-
}>;
|
|
62
|
-
/**
|
|
63
|
-
* 完成灰度
|
|
64
|
-
*/
|
|
65
|
-
promote(serverName: string): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* 取消灰度
|
|
68
|
-
*/
|
|
69
|
-
rollback(serverName: string): Promise<{
|
|
70
|
-
RequestId?: string;
|
|
71
|
-
}>;
|
|
72
59
|
/**
|
|
73
60
|
*查询云托管服务详情
|
|
74
61
|
* @param {Object} params 查询参数
|
|
@@ -112,9 +99,6 @@ export declare class CloudRunService {
|
|
|
112
99
|
deploy(params: {
|
|
113
100
|
serverName: string;
|
|
114
101
|
targetPath: string;
|
|
115
|
-
deployInfo: {
|
|
116
|
-
ReleaseType: ReleaseTypeEnum;
|
|
117
|
-
};
|
|
118
102
|
serverConfig?: Partial<Pick<ICloudrunServerBaseConfig, 'OpenAccessTypes' | 'Cpu' | 'Mem' | 'MinNum' | 'MaxNum' | 'PolicyDetails' | 'CustomLogs' | 'EnvParams' | 'Port' | 'Dockerfile' | 'BuildDir' | 'InternalAccess' | 'InternalDomain' | 'EntryPoint' | 'Cmd' | 'InstallDependency'>>;
|
|
119
103
|
}): Promise<IResponseInfo>;
|
|
120
104
|
/**
|
package/types/cloudrun/type.d.ts
CHANGED
|
@@ -8,16 +8,6 @@ export declare enum CloudrunServerType {
|
|
|
8
8
|
*/
|
|
9
9
|
Container = "container"
|
|
10
10
|
}
|
|
11
|
-
export declare enum ReleaseTypeEnum {
|
|
12
|
-
/**
|
|
13
|
-
* 灰度发布
|
|
14
|
-
*/
|
|
15
|
-
GRAY = "GRAY",
|
|
16
|
-
/**
|
|
17
|
-
* 全量发布
|
|
18
|
-
*/
|
|
19
|
-
FULL = "FULL"
|
|
20
|
-
}
|
|
21
11
|
/**
|
|
22
12
|
* 服务基础信息接口
|
|
23
13
|
*/
|
|
@@ -337,71 +327,3 @@ export interface ITemplate {
|
|
|
337
327
|
language: string;
|
|
338
328
|
zipFileStore: string;
|
|
339
329
|
}
|
|
340
|
-
export interface ITaskStepInfo {
|
|
341
|
-
Name?: string;
|
|
342
|
-
Status?: string;
|
|
343
|
-
StartTime?: string;
|
|
344
|
-
EndTime?: string;
|
|
345
|
-
CostTime?: number;
|
|
346
|
-
FailReason?: string;
|
|
347
|
-
}
|
|
348
|
-
export interface IServerManageTaskInfo {
|
|
349
|
-
Id?: number;
|
|
350
|
-
EnvId?: string;
|
|
351
|
-
ServerName?: string;
|
|
352
|
-
CreateTime?: string;
|
|
353
|
-
ChangeType?: string;
|
|
354
|
-
ReleaseType?: string;
|
|
355
|
-
DeployType?: string;
|
|
356
|
-
PreVersionName?: string;
|
|
357
|
-
VersionName?: string;
|
|
358
|
-
PipelineId?: number;
|
|
359
|
-
PipelineTaskId?: number;
|
|
360
|
-
ReleaseId?: number;
|
|
361
|
-
Status?: string;
|
|
362
|
-
Steps?: ITaskStepInfo[];
|
|
363
|
-
FailReason?: string;
|
|
364
|
-
OperatorRemark?: string;
|
|
365
|
-
}
|
|
366
|
-
export interface IObjectKVPriority {
|
|
367
|
-
Key?: string;
|
|
368
|
-
Value?: string;
|
|
369
|
-
Priority?: number;
|
|
370
|
-
}
|
|
371
|
-
export interface IVersionInfo {
|
|
372
|
-
VersionName?: string;
|
|
373
|
-
FlowRatio?: number;
|
|
374
|
-
Status?: string;
|
|
375
|
-
CreatedTime?: string;
|
|
376
|
-
UpdatedTime?: string;
|
|
377
|
-
BuildId?: number;
|
|
378
|
-
UploadType?: string;
|
|
379
|
-
Remark?: string;
|
|
380
|
-
UrlParam?: IObjectKV;
|
|
381
|
-
Priority?: number;
|
|
382
|
-
IsDefaultPriority?: boolean;
|
|
383
|
-
FlowParams?: IObjectKVPriority[];
|
|
384
|
-
MinReplicas?: number;
|
|
385
|
-
MaxReplicas?: number;
|
|
386
|
-
RunId?: string;
|
|
387
|
-
Percent?: number;
|
|
388
|
-
CurrentReplicas?: number;
|
|
389
|
-
Architecture?: string;
|
|
390
|
-
}
|
|
391
|
-
export interface IObjectKV {
|
|
392
|
-
Key: string;
|
|
393
|
-
Value: string;
|
|
394
|
-
}
|
|
395
|
-
export interface IReleaseOrderInfo {
|
|
396
|
-
Id?: number;
|
|
397
|
-
ServerName?: string;
|
|
398
|
-
CurrentVersion?: IVersionInfo;
|
|
399
|
-
ReleaseVersion?: IVersionInfo;
|
|
400
|
-
GrayStatus?: string;
|
|
401
|
-
ReleaseStatus?: string;
|
|
402
|
-
TrafficTypeValues?: IObjectKV[];
|
|
403
|
-
TrafficType?: string;
|
|
404
|
-
FlowRatio?: number;
|
|
405
|
-
CreateTime?: string;
|
|
406
|
-
IsReleasing?: boolean;
|
|
407
|
-
}
|
package/types/constant.d.ts
CHANGED
|
@@ -25,6 +25,16 @@ export interface ICloudFunction extends ICloudFunctionConfig {
|
|
|
25
25
|
name: string;
|
|
26
26
|
description?: string;
|
|
27
27
|
type?: 'Event' | 'HTTP';
|
|
28
|
+
protocolType?: 'WS';
|
|
29
|
+
protocolParams?: {
|
|
30
|
+
wsParams?: {
|
|
31
|
+
idleTimeOut?: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
instanceConcurrencyConfig?: {
|
|
35
|
+
dynamicEnabled?: 'FALSE';
|
|
36
|
+
maxConcurrency?: number;
|
|
37
|
+
};
|
|
28
38
|
handler?: string;
|
|
29
39
|
codeSecret?: string;
|
|
30
40
|
isWaitInstall?: boolean;
|