@cloudbase/manager-node 4.2.10 → 4.3.0

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.
@@ -114,28 +114,28 @@ class AccessService {
114
114
  };
115
115
  }
116
116
  }
117
+ exports.AccessService = AccessService;
117
118
  __decorate([
118
- utils_1.preLazy()
119
+ (0, utils_1.preLazy)()
119
120
  ], AccessService.prototype, "createAccess", null);
120
121
  __decorate([
121
- utils_1.preLazy()
122
+ (0, utils_1.preLazy)()
122
123
  ], AccessService.prototype, "getDomainList", null);
123
124
  __decorate([
124
- utils_1.preLazy()
125
+ (0, utils_1.preLazy)()
125
126
  ], AccessService.prototype, "getAccessList", null);
126
127
  __decorate([
127
- utils_1.preLazy()
128
+ (0, utils_1.preLazy)()
128
129
  ], AccessService.prototype, "switchAuth", null);
129
130
  __decorate([
130
- utils_1.preLazy()
131
+ (0, utils_1.preLazy)()
131
132
  ], AccessService.prototype, "switchPathAuth", null);
132
133
  __decorate([
133
- utils_1.preLazy()
134
+ (0, utils_1.preLazy)()
134
135
  ], AccessService.prototype, "deleteAccess", null);
135
136
  __decorate([
136
- utils_1.preLazy()
137
+ (0, utils_1.preLazy)()
137
138
  ], AccessService.prototype, "addCustomDomain", null);
138
139
  __decorate([
139
- utils_1.preLazy()
140
+ (0, utils_1.preLazy)()
140
141
  ], AccessService.prototype, "deleteCustomDomain", null);
141
- exports.AccessService = AccessService;
@@ -19,7 +19,7 @@ class CloudBaseRunService {
19
19
  return this.tcbService.request('ModifyCloudBaseRunServerFlowConf', {
20
20
  EnvId: envId,
21
21
  ServerName: options.serverName,
22
- VersionFlowItems: utils_1.upperCaseObjKey(options.versionFlowItems)
22
+ VersionFlowItems: (0, utils_1.upperCaseObjKey)(options.versionFlowItems)
23
23
  // TrafficType: options.trafficType
24
24
  });
25
25
  }
@@ -30,7 +30,7 @@ class CloudBaseRunService {
30
30
  };
31
31
  }
32
32
  }
33
+ exports.CloudBaseRunService = CloudBaseRunService;
33
34
  __decorate([
34
- utils_1.preLazy()
35
+ (0, utils_1.preLazy)()
35
36
  ], CloudBaseRunService.prototype, "modifyServerFlow", null);
36
- exports.CloudBaseRunService = CloudBaseRunService;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CloudRunService = void 0;
13
+ const path_1 = __importDefault(require("path"));
14
+ const utils_1 = require("../utils");
15
+ /**
16
+ * 云托管服务管理类
17
+ * 提供云托管服务的初始化、下载、列表查询和删除等功能
18
+ */
19
+ class CloudRunService {
20
+ constructor(environment) {
21
+ this.environment = environment;
22
+ this.tcbrService = new utils_1.CloudService(environment.cloudBaseContext, 'tcbr', '2022-02-17');
23
+ this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
24
+ }
25
+ /**
26
+ * 初始化云托管代码项目
27
+ * @param {Object} params 初始化参数
28
+ * @param {string} params.serverName 服务名称,将作为项目目录名
29
+ * @param {string} [params.template='helloworld'] 模板标识符,默认为'helloworld'
30
+ * @param {string} [params.targetPath='.'] 目标路径,默认为当前目录
31
+ * @returns {Promise<void>}
32
+ * @throws 当模板不存在、下载失败或解压失败时抛出错误
33
+ */
34
+ async init(params) {
35
+ const { serverName, template = 'helloworld', targetPath = '.' } = params || {};
36
+ // 1. 获取模板列表
37
+ const templates = await this.getTemplates();
38
+ const templateData = templates.find(item => item.identifier === template);
39
+ if (!templateData || !templateData.zipFileStore) {
40
+ throw new Error(`未找到匹配的模板: ${template}`);
41
+ }
42
+ // 2. 下载并解压模板到目标目录
43
+ const downloadUrl = templateData.zipFileStore;
44
+ const projectDir = path_1.default.resolve(targetPath, serverName);
45
+ await (0, utils_1.downloadAndExtractRemoteZip)(downloadUrl, projectDir);
46
+ return { projectDir };
47
+ }
48
+ /**
49
+ * 下载云托管服务代码到本地目录
50
+ * @param {Object} params 下载参数
51
+ * @param {string} params.serverName 要下载的服务名称
52
+ * @param {string} params.targetPath 下载的目标路径(绝对路径或相对路径)
53
+ * @returns {Promise<void>}
54
+ * @throws 当以下情况发生时抛出错误:
55
+ * - 未找到服务版本
56
+ * - 获取下载地址失败
57
+ * - 下载或解压过程中出错
58
+ */
59
+ async download(params) {
60
+ var _a, _b;
61
+ const envConfig = this.environment.lazyEnvironmentConfig;
62
+ const { serverName, targetPath } = params;
63
+ /**
64
+ * 获取最新版本
65
+ */
66
+ const cloudRunServerDetailRes = await this.tcbrService.request('DescribeCloudRunServerDetail', {
67
+ EnvId: envConfig.EnvId,
68
+ ServerName: serverName
69
+ });
70
+ const version = (_b = (_a = cloudRunServerDetailRes.OnlineVersionInfos) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.VersionName;
71
+ if (!version) {
72
+ throw new Error('未找到云托管服务版本');
73
+ }
74
+ /**
75
+ * 获取下载地址
76
+ */
77
+ const cloudBaseBuildServiceRes = await this.tcbService.request('DescribeCloudBaseBuildService', {
78
+ EnvId: envConfig.EnvId,
79
+ ServiceName: serverName,
80
+ ServiceVersion: version
81
+ });
82
+ if (cloudBaseBuildServiceRes === null || cloudBaseBuildServiceRes === void 0 ? void 0 : cloudBaseBuildServiceRes.DownloadUrl) {
83
+ await (0, utils_1.downloadAndExtractRemoteZip)(cloudBaseBuildServiceRes === null || cloudBaseBuildServiceRes === void 0 ? void 0 : cloudBaseBuildServiceRes.DownloadUrl, path_1.default.resolve(targetPath));
84
+ }
85
+ else {
86
+ throw new Error(`云托管代码下载地址为空(请求ID: ${cloudBaseBuildServiceRes.RequestId})`);
87
+ }
88
+ }
89
+ /**
90
+ * 获取云托管服务列表
91
+ * @param {Object} [params] 查询参数
92
+ * @param {number} [params.pageSize] 每页数量
93
+ * @param {number} [params.pageNum] 页码
94
+ * @param {string} [params.serverName] 服务名称筛选
95
+ * @param {string} [params.serverType] 服务类型筛选
96
+ * @returns {Promise<ICloudrunListResponse>} 包含服务列表和总数等信息的响应对象
97
+ */
98
+ async list(params) {
99
+ const envConfig = this.environment.lazyEnvironmentConfig;
100
+ return this.tcbrService.request('DescribeCloudRunServers', Object.assign({ EnvId: envConfig.EnvId }, {
101
+ PageSize: (params === null || params === void 0 ? void 0 : params.pageSize) || 10,
102
+ PageNum: (params === null || params === void 0 ? void 0 : params.pageNum) || 1,
103
+ ServerName: params === null || params === void 0 ? void 0 : params.serverName,
104
+ ServerType: params === null || params === void 0 ? void 0 : params.serverType
105
+ }));
106
+ }
107
+ /**
108
+ *查询云托管服务详情
109
+ * @param {Object} params 查询参数
110
+ * @param {string} params.serverName 要查询的服务名称
111
+ * @returns {Promise<ICloudrunDetailResponse>} 返回服务详情响应对象
112
+ */
113
+ async detail(params) {
114
+ const envConfig = this.environment.lazyEnvironmentConfig;
115
+ return this.tcbrService.request('DescribeCloudRunServerDetail', {
116
+ EnvId: envConfig.EnvId,
117
+ ServerName: params.serverName
118
+ });
119
+ }
120
+ /**
121
+ * 删除指定的云托管服务
122
+ * @param {string} serverName - 要删除的服务名称,必须是在当前环境中已存在的服务
123
+ * @returns {Promise<IResponseInfo>} 返回删除操作的响应信息
124
+ */
125
+ async delete(params) {
126
+ // 获取当前环境配置(包含EnvId)
127
+ const envConfig = this.environment.lazyEnvironmentConfig;
128
+ // 调用TCBR服务的DeleteCloudRunServer接口执行删除
129
+ return this.tcbrService.request('DeleteCloudRunServer', {
130
+ EnvId: envConfig.EnvId, // 环境ID
131
+ ServerName: params.serverName // 要删除的服务名称
132
+ });
133
+ }
134
+ /**
135
+ * 获取云托管服务模板列表
136
+ * @returns {Promise<ITemplate[]>} 返回模板数组
137
+ */
138
+ async getTemplates() {
139
+ return (0, utils_1.fetchTemplates)(['tcbrFunc', 'tcbrContainer']);
140
+ }
141
+ }
142
+ exports.CloudRunService = CloudRunService;
143
+ __decorate([
144
+ (0, utils_1.preLazy)()
145
+ ], CloudRunService.prototype, "init", null);
146
+ __decorate([
147
+ (0, utils_1.preLazy)()
148
+ ], CloudRunService.prototype, "download", null);
149
+ __decorate([
150
+ (0, utils_1.preLazy)()
151
+ ], CloudRunService.prototype, "list", null);
152
+ __decorate([
153
+ (0, utils_1.preLazy)()
154
+ ], CloudRunService.prototype, "detail", null);
155
+ __decorate([
156
+ (0, utils_1.preLazy)()
157
+ ], CloudRunService.prototype, "delete", null);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudrunServerType = void 0;
4
+ var CloudrunServerType;
5
+ (function (CloudrunServerType) {
6
+ /**
7
+ * 函数型服务
8
+ */
9
+ CloudrunServerType["Function"] = "function";
10
+ /**
11
+ * 容器型服务
12
+ */
13
+ CloudrunServerType["Container"] = "container";
14
+ })(CloudrunServerType || (exports.CloudrunServerType = CloudrunServerType = {}));
@@ -218,6 +218,7 @@ class DatabaseService {
218
218
  return this.dbOpService.request('DatabaseMigrateExport', Object.assign({ CollectionName: collectionName, FilePath: filePath, FileType: fileType, EnvId: this.envId }, options));
219
219
  }
220
220
  }
221
+ exports.DatabaseService = DatabaseService;
221
222
  DatabaseService.tcbServiceVersion = {
222
223
  service: 'tcb',
223
224
  version: '2018-06-08'
@@ -241,4 +242,3 @@ __decorate([
241
242
  __decorate([
242
243
  preLazy()
243
244
  ], DatabaseService.prototype, "listCollections", null);
244
- exports.DatabaseService = DatabaseService;
package/lib/env/index.js CHANGED
@@ -134,6 +134,7 @@ class EnvService {
134
134
  }
135
135
  const { EnvList, RequestId } = await this.cloudService.request('DescribeEnvs', params);
136
136
  return {
137
+ // @ts-ignore
137
138
  EnvInfo: (EnvList === null || EnvList === void 0 ? void 0 : EnvList.length) ? EnvList[0] : {},
138
139
  RequestId
139
140
  };
@@ -177,7 +178,7 @@ class EnvService {
177
178
  // 平台, “QQ" "WECHAT-OPEN" "WECHAT-PUBLIC"
178
179
  Platform: platform,
179
180
  PlatformId: appId,
180
- PlatformSecret: finalAppSecret ? utils_1.rsaEncrypt(finalAppSecret) : undefined,
181
+ PlatformSecret: finalAppSecret ? (0, utils_1.rsaEncrypt)(finalAppSecret) : undefined,
181
182
  Status: 'ENABLE'
182
183
  });
183
184
  }
@@ -205,7 +206,7 @@ class EnvService {
205
206
  finalAppSecret = 'anonymous';
206
207
  }
207
208
  appId && (params.PlatformId = appId);
208
- finalAppSecret && (params.PlatformSecret = utils_1.rsaEncrypt(finalAppSecret));
209
+ finalAppSecret && (params.PlatformSecret = (0, utils_1.rsaEncrypt)(finalAppSecret));
209
210
  return this.cloudService.request('UpdateLoginConfig', params);
210
211
  }
211
212
  // 创建自定义登录私钥
@@ -259,12 +260,12 @@ class EnvService {
259
260
  SecretId: secretId,
260
261
  SecretKey: secretKey,
261
262
  SecurityToken: token,
262
- Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */,
263
+ Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
263
264
  };
264
265
  if (constant_1.COS_SDK_PROTOCOL) {
265
- cosConfig.Protocol = constant_1.COS_SDK_PROTOCOL.endsWith(':')
266
+ cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
266
267
  ? constant_1.COS_SDK_PROTOCOL.toLowerCase()
267
- : constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':';
268
+ : constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
268
269
  }
269
270
  if (constant_1.USE_INTERNAL_ENDPOINT) {
270
271
  cosConfig.Protocol = 'http:';
@@ -283,10 +284,10 @@ class EnvService {
283
284
  };
284
285
  }
285
286
  }
287
+ exports.EnvService = EnvService;
286
288
  __decorate([
287
- utils_1.preLazy()
289
+ (0, utils_1.preLazy)()
288
290
  ], EnvService.prototype, "createEnvDomain", null);
289
291
  __decorate([
290
- utils_1.preLazy()
292
+ (0, utils_1.preLazy)()
291
293
  ], EnvService.prototype, "deleteEnvDomain", null);
292
- exports.EnvService = EnvService;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Environment = void 0;
4
4
  const database_1 = require("./database");
5
5
  const function_1 = require("./function");
6
+ const cloudrun_1 = require("./cloudrun");
6
7
  const storage_1 = require("./storage");
7
8
  const env_1 = require("./env");
8
9
  const common_1 = require("./common");
@@ -22,6 +23,7 @@ class Environment {
22
23
  this.envType = context.envType;
23
24
  // 拉取当前环境 的环境信息 todo
24
25
  this.functionService = new function_1.FunctionService(this);
26
+ this.cloudRunService = new cloudrun_1.CloudRunService(this);
25
27
  this.databaseService = new database_1.DatabaseService(this);
26
28
  this.storageService = new storage_1.StorageService(this);
27
29
  this.envService = new env_1.EnvService(this);
@@ -62,6 +64,9 @@ class Environment {
62
64
  getFunctionService() {
63
65
  return this.functionService;
64
66
  }
67
+ getCloudRunService() {
68
+ return this.cloudRunService;
69
+ }
65
70
  getEnvService() {
66
71
  return this.envService;
67
72
  }
@@ -94,11 +99,11 @@ class Environment {
94
99
  const envId = this.getEnvId();
95
100
  if (!secretId || !secretKey) {
96
101
  // 未主动传入密钥,从环境变量中读取
97
- const envSecretId = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SECRETID);
98
- const envSecretKey = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SECRETKEY);
99
- const envToken = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
102
+ const envSecretId = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SECRETID);
103
+ const envSecretKey = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SECRETKEY);
104
+ const envToken = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
100
105
  if (!envSecretId || !envSecretKey) {
101
- if (utils_1.getRuntime() === constant_1.RUN_ENV.SCF) {
106
+ if ((0, utils_1.getRuntime)() === constant_1.RUN_ENV.SCF) {
102
107
  throw new Error('missing authoration key, redeploy the function');
103
108
  }
104
109
  else {
@@ -295,8 +295,11 @@ class FunctionService {
295
295
  const subnets = await this.getSubnets(VpcId);
296
296
  const vpc = vpcs.find(item => item.VpcId === VpcId);
297
297
  const subnet = subnets.find(item => item.SubnetId === SubnetId);
298
+ // FIXME: 这里的 vpc 和 subnet 不应该是 string 吧,它是 vpcs 和 subnets 的项啊
298
299
  data.VpcConfig = {
300
+ // @ts-ignore
299
301
  vpc,
302
+ // @ts-ignore
300
303
  subnet
301
304
  };
302
305
  }
@@ -554,22 +557,22 @@ class FunctionService {
554
557
  if (base64Content) {
555
558
  base64 = base64Content;
556
559
  }
557
- else if (utils_1.isDirectory(contentPath)) {
560
+ else if ((0, utils_1.isDirectory)(contentPath)) {
558
561
  // 压缩文件夹
559
562
  const dirName = path_1.default.parse(contentPath).name;
560
563
  const dest = path_1.default.join(process.cwd(), `temp-${dirName}.zip`);
561
564
  // ZIP 文件存在,删除 ZIP 文件
562
- if (utils_1.checkFullAccess(dest)) {
563
- utils_1.delSync(dest);
565
+ if ((0, utils_1.checkFullAccess)(dest)) {
566
+ (0, utils_1.delSync)(dest);
564
567
  }
565
- await utils_1.compressToZip({
568
+ await (0, utils_1.compressToZip)({
566
569
  dirPath: contentPath,
567
570
  outputPath: dest
568
571
  });
569
572
  // 转换成 base64
570
573
  const fileBuffer = await fs_1.default.promises.readFile(dest);
571
574
  base64 = fileBuffer.toString('base64');
572
- utils_1.delSync(dest);
575
+ (0, utils_1.delSync)(dest);
573
576
  }
574
577
  else {
575
578
  const fileType = path_1.default.extname(contentPath);
@@ -829,7 +832,7 @@ class FunctionService {
829
832
  }
830
833
  catch (e) {
831
834
  if (count < 3) {
832
- await utils_1.sleep(500);
835
+ await (0, utils_1.sleep)(500);
833
836
  const res = await this.retryCreateTrigger(name, triggers, count + 1);
834
837
  return res;
835
838
  }
@@ -932,91 +935,91 @@ class FunctionService {
932
935
  });
933
936
  }
934
937
  }
938
+ exports.FunctionService = FunctionService;
935
939
  __decorate([
936
- utils_1.preLazy()
940
+ (0, utils_1.preLazy)()
937
941
  ], FunctionService.prototype, "updateFunctionIncrementalCode", null);
938
942
  __decorate([
939
- utils_1.preLazy()
943
+ (0, utils_1.preLazy)()
940
944
  ], FunctionService.prototype, "createFunction", null);
941
945
  __decorate([
942
- utils_1.preLazy()
946
+ (0, utils_1.preLazy)()
943
947
  ], FunctionService.prototype, "getFunctionList", null);
944
948
  __decorate([
945
- utils_1.preLazy()
949
+ (0, utils_1.preLazy)()
946
950
  ], FunctionService.prototype, "listFunctions", null);
947
951
  __decorate([
948
- utils_1.preLazy()
952
+ (0, utils_1.preLazy)()
949
953
  ], FunctionService.prototype, "deleteFunction", null);
950
954
  __decorate([
951
- utils_1.preLazy()
955
+ (0, utils_1.preLazy)()
952
956
  ], FunctionService.prototype, "getFunctionDetail", null);
953
957
  __decorate([
954
- utils_1.preLazy()
958
+ (0, utils_1.preLazy)()
955
959
  ], FunctionService.prototype, "getFunctionLogs", null);
956
960
  __decorate([
957
- utils_1.preLazy()
961
+ (0, utils_1.preLazy)()
958
962
  ], FunctionService.prototype, "updateFunctionConfig", null);
959
963
  __decorate([
960
- utils_1.preLazy()
964
+ (0, utils_1.preLazy)()
961
965
  ], FunctionService.prototype, "updateFunctionCode", null);
962
966
  __decorate([
963
- utils_1.preLazy()
967
+ (0, utils_1.preLazy)()
964
968
  ], FunctionService.prototype, "invokeFunction", null);
965
969
  __decorate([
966
- utils_1.preLazy()
970
+ (0, utils_1.preLazy)()
967
971
  ], FunctionService.prototype, "copyFunction", null);
968
972
  __decorate([
969
- utils_1.preLazy()
973
+ (0, utils_1.preLazy)()
970
974
  ], FunctionService.prototype, "createFunctionTriggers", null);
971
975
  __decorate([
972
- utils_1.preLazy()
976
+ (0, utils_1.preLazy)()
973
977
  ], FunctionService.prototype, "deleteFunctionTrigger", null);
974
978
  __decorate([
975
- utils_1.preLazy()
979
+ (0, utils_1.preLazy)()
976
980
  ], FunctionService.prototype, "getFunctionDownloadUrl", null);
977
981
  __decorate([
978
- utils_1.preLazy()
982
+ (0, utils_1.preLazy)()
979
983
  ], FunctionService.prototype, "createLayer", null);
980
984
  __decorate([
981
- utils_1.preLazy()
985
+ (0, utils_1.preLazy)()
982
986
  ], FunctionService.prototype, "deleteLayerVersion", null);
983
987
  __decorate([
984
- utils_1.preLazy()
988
+ (0, utils_1.preLazy)()
985
989
  ], FunctionService.prototype, "listLayerVersions", null);
986
990
  __decorate([
987
- utils_1.preLazy()
991
+ (0, utils_1.preLazy)()
988
992
  ], FunctionService.prototype, "listLayers", null);
989
993
  __decorate([
990
- utils_1.preLazy()
994
+ (0, utils_1.preLazy)()
991
995
  ], FunctionService.prototype, "getLayerVersion", null);
992
996
  __decorate([
993
- utils_1.preLazy()
997
+ (0, utils_1.preLazy)()
994
998
  ], FunctionService.prototype, "setProvisionedConcurrencyConfig", null);
995
999
  __decorate([
996
- utils_1.preLazy()
1000
+ (0, utils_1.preLazy)()
997
1001
  ], FunctionService.prototype, "getProvisionedConcurrencyConfig", null);
998
1002
  __decorate([
999
- utils_1.preLazy()
1003
+ (0, utils_1.preLazy)()
1000
1004
  ], FunctionService.prototype, "deleteProvisionedConcurrencyConfig", null);
1001
1005
  __decorate([
1002
- utils_1.preLazy()
1006
+ (0, utils_1.preLazy)()
1003
1007
  ], FunctionService.prototype, "publishVersion", null);
1004
1008
  __decorate([
1005
- utils_1.preLazy()
1009
+ (0, utils_1.preLazy)()
1006
1010
  ], FunctionService.prototype, "listVersionByFunction", null);
1007
1011
  __decorate([
1008
- utils_1.preLazy()
1012
+ (0, utils_1.preLazy)()
1009
1013
  ], FunctionService.prototype, "updateFunctionAliasConfig", null);
1010
1014
  __decorate([
1011
- utils_1.preLazy()
1015
+ (0, utils_1.preLazy)()
1012
1016
  ], FunctionService.prototype, "getFunctionAlias", null);
1013
1017
  __decorate([
1014
- utils_1.preLazy()
1018
+ (0, utils_1.preLazy)()
1015
1019
  ], FunctionService.prototype, "createAccessPath", null);
1016
1020
  __decorate([
1017
- utils_1.preLazy()
1021
+ (0, utils_1.preLazy)()
1018
1022
  ], FunctionService.prototype, "getCodeParams", null);
1019
1023
  __decorate([
1020
- utils_1.preLazy()
1024
+ (0, utils_1.preLazy)()
1021
1025
  ], FunctionService.prototype, "getTempCosInfo", null);
1022
- exports.FunctionService = FunctionService;
@@ -1,4 +1,37 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -11,6 +44,7 @@ const make_dir_1 = __importDefault(require("make-dir"));
11
44
  const util_1 = __importDefault(require("util"));
12
45
  const utils_1 = require("../utils");
13
46
  const error_1 = require("../error");
47
+ const os = __importStar(require("os"));
14
48
  // 10 MB
15
49
  exports.BIG_FILE_SIZE = 10485760;
16
50
  exports.API_MAX_SIZE = 52428800;
@@ -18,8 +52,9 @@ var CodeType;
18
52
  (function (CodeType) {
19
53
  CodeType[CodeType["File"] = 0] = "File";
20
54
  CodeType[CodeType["JavaFile"] = 1] = "JavaFile";
21
- })(CodeType = exports.CodeType || (exports.CodeType = {}));
55
+ })(CodeType || (exports.CodeType = CodeType = {}));
22
56
  const TEMPDIR_NAME = '.cloudbase_temp';
57
+ const TEMPDIR = os.tmpdir();
23
58
  /**
24
59
  * 将函数代码转换成 Base64 编码
25
60
  * 普通文件:Node,PHP
@@ -34,16 +69,14 @@ class FunctionPacker {
34
69
  this.incrementalPath = incrementalPath;
35
70
  this.funcPath = functionPath ? functionPath : path_1.default.resolve(root, name);
36
71
  // 每个函数采用不同的文件夹
37
- this.tmpPath = root
38
- ? path_1.default.join(root, `${TEMPDIR_NAME}_${name}`)
39
- : path_1.default.join(process.cwd(), `${TEMPDIR_NAME}_${name}`);
72
+ this.tmpPath = path_1.default.join(TEMPDIR, `${TEMPDIR_NAME}_${name}`);
40
73
  }
41
74
  async compressFiles() {
42
- utils_1.checkFullAccess(this.funcPath, true);
75
+ (0, utils_1.checkFullAccess)(this.funcPath, true);
43
76
  // 清除原打包文件
44
77
  this.clean();
45
78
  // 确保目标路径存在
46
- await make_dir_1.default(this.tmpPath);
79
+ await (0, make_dir_1.default)(this.tmpPath);
47
80
  // 生成 name.zip 文件
48
81
  this.zipFilePath = path_1.default.resolve(this.tmpPath, `${this.name}.zip`);
49
82
  const zipOption = {
@@ -54,7 +87,7 @@ class FunctionPacker {
54
87
  if (this.incrementalPath) {
55
88
  zipOption.pattern = this.incrementalPath;
56
89
  }
57
- await utils_1.compressToZip(zipOption);
90
+ await (0, utils_1.compressToZip)(zipOption);
58
91
  }
59
92
  // 获取 Java 代码
60
93
  getJavaFile() {
@@ -62,8 +95,8 @@ class FunctionPacker {
62
95
  // funcPath 可能以 .jar 或 .zip 结尾
63
96
  const filePath = funcPath.replace(/\.jar$|\.zip$/g, '');
64
97
  // Java 代码为 jar 或 zip 包
65
- const jarExist = utils_1.checkFullAccess(`${filePath}.jar`);
66
- const zipExist = utils_1.checkFullAccess(`${filePath}.zip`);
98
+ const jarExist = (0, utils_1.checkFullAccess)(`${filePath}.jar`);
99
+ const zipExist = (0, utils_1.checkFullAccess)(`${filePath}.zip`);
67
100
  if (!jarExist && !zipExist) {
68
101
  throw new error_1.CloudBaseError('未找到部署函数的 Jar 或者 ZIP 格式文件!');
69
102
  }