@cloudbase/manager-node 4.2.1 → 4.2.3

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.
@@ -146,6 +146,9 @@ class FunctionService {
146
146
  functionPath,
147
147
  functionRootPath
148
148
  }, params.InstallDependency);
149
+ const { TopicId, LogsetId } = this.getClsServiceConfig();
150
+ params.ClsTopicId = TopicId;
151
+ params.ClsLogsetId = LogsetId;
149
152
  try {
150
153
  // 创建云函数
151
154
  const res = await this.scfService.request('CreateFunction', params);
@@ -854,6 +857,19 @@ class FunctionService {
854
857
  env: envConfig.EnvId
855
858
  };
856
859
  }
860
+ /**
861
+ * 获取日志cls配置信息
862
+ */
863
+ getClsServiceConfig() {
864
+ var _a, _b;
865
+ const currentEnv = this.environment.lazyEnvironmentConfig;
866
+ const customLogServices = (_a = currentEnv === null || currentEnv === void 0 ? void 0 : currentEnv.CustomLogServices) === null || _a === void 0 ? void 0 : _a[0];
867
+ const logServices = (_b = currentEnv === null || currentEnv === void 0 ? void 0 : currentEnv.LogServices) === null || _b === void 0 ? void 0 : _b[0];
868
+ return {
869
+ TopicId: (customLogServices === null || customLogServices === void 0 ? void 0 : customLogServices.ClsTopicId) || (logServices === null || logServices === void 0 ? void 0 : logServices.TopicId),
870
+ LogsetId: (customLogServices === null || customLogServices === void 0 ? void 0 : customLogServices.ClsLogsetId) || (logServices === null || logServices === void 0 ? void 0 : logServices.LogsetId)
871
+ };
872
+ }
857
873
  /**
858
874
  * 获取 vpc 信息
859
875
  * @returns
@@ -839,13 +839,14 @@ class StorageService {
839
839
  getCos(parallel = 20) {
840
840
  const { secretId, secretKey, token, proxy } = this.environment.getAuthConfig();
841
841
  const cosProxy = process.env.TCB_COS_PROXY;
842
- return new cos_nodejs_sdk_v5_1.default({
843
- FileParallelLimit: parallel,
844
- SecretId: secretId,
845
- SecretKey: secretKey,
846
- Proxy: cosProxy || proxy,
847
- SecurityToken: token
848
- });
842
+ const useCosInternalDomain = !!process.env.USE_COS_INTERNAL_DOMAIN;
843
+ return new cos_nodejs_sdk_v5_1.default(Object.assign({ FileParallelLimit: parallel, SecretId: secretId, SecretKey: secretKey, Proxy: cosProxy || proxy, SecurityToken: token }, (useCosInternalDomain
844
+ ? {
845
+ Domain: '{Bucket}.cos-internal.{Region}.tencentcos.cn',
846
+ ServiceDomain: 'service.cos.tencentcos.cn',
847
+ Protocol: 'http:'
848
+ }
849
+ : {})));
849
850
  }
850
851
  /**
851
852
  * 将 cloudPath 转换成 cloudPath/ 形式
@@ -919,7 +920,8 @@ class StorageService {
919
920
  times: times - 1,
920
921
  interval,
921
922
  failedFiles: tempFailedFiles
922
- }).then(res => resolve(res))
923
+ })
924
+ .then(res => resolve(res))
923
925
  .catch(err => reject(err)), interval);
924
926
  });
925
927
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.2.1",
3
+ "version": "4.2.3",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -165,7 +165,6 @@ export interface IPublishVersionRes extends IResponseInfo {
165
165
  Namespace: string
166
166
  }
167
167
 
168
-
169
168
  export interface IListFunctionVersionParams {
170
169
  functionName: string
171
170
  offset?: number
@@ -398,6 +397,10 @@ export class FunctionService {
398
397
  params.InstallDependency
399
398
  )
400
399
 
400
+ const { TopicId, LogsetId } = this.getClsServiceConfig()
401
+ params.ClsTopicId = TopicId
402
+ params.ClsLogsetId = LogsetId
403
+
401
404
  try {
402
405
  // 创建云函数
403
406
  const res = await this.scfService.request<IResponseInfo | ICreateFunctionRes>(
@@ -1296,6 +1299,19 @@ export class FunctionService {
1296
1299
  }
1297
1300
  }
1298
1301
 
1302
+ /**
1303
+ * 获取日志cls配置信息
1304
+ */
1305
+ private getClsServiceConfig() {
1306
+ const currentEnv = this.environment.lazyEnvironmentConfig
1307
+ const customLogServices = currentEnv?.CustomLogServices?.[0]
1308
+ const logServices = currentEnv?.LogServices?.[0]
1309
+ return {
1310
+ TopicId: customLogServices?.ClsTopicId || logServices?.TopicId,
1311
+ LogsetId: customLogServices?.ClsLogsetId || logServices?.LogsetId
1312
+ }
1313
+ }
1314
+
1299
1315
  /**
1300
1316
  * 获取 vpc 信息
1301
1317
  * @returns
@@ -139,7 +139,6 @@ export interface IFunctionCode {
139
139
  ZipFile: string
140
140
  }
141
141
 
142
-
143
142
  export interface ILayerVersionItem {
144
143
  LayerName: string
145
144
  LayerVersion: number
@@ -161,4 +160,6 @@ export interface IFunctionUpdateAttribute {
161
160
  EipConfig: { EipStatus: string; EipAddress: string[] }
162
161
  }
163
162
  Layers?: ILayerVersionItem[]
163
+ ClsLogsetId?: string
164
+ ClsTopicId?: string
164
165
  }
@@ -248,6 +248,12 @@ export interface EnvInfo {
248
248
  PackageName: string
249
249
  // 云日志服务列表
250
250
  LogServices: LogServiceInfo[]
251
+ CustomLogServices: {
252
+ CreateTime: string
253
+ ClsLogsetId: string
254
+ ClsTopicId: string
255
+ ClsRegion: string
256
+ }[]
251
257
  }
252
258
  export interface FunctionInfo {
253
259
  // 命名空间
@@ -1137,13 +1137,21 @@ export class StorageService {
1137
1137
  private getCos(parallel = 20) {
1138
1138
  const { secretId, secretKey, token, proxy } = this.environment.getAuthConfig()
1139
1139
  const cosProxy = process.env.TCB_COS_PROXY
1140
+ const useCosInternalDomain = !!process.env.USE_COS_INTERNAL_DOMAIN
1140
1141
 
1141
1142
  return new COS({
1142
1143
  FileParallelLimit: parallel,
1143
1144
  SecretId: secretId,
1144
1145
  SecretKey: secretKey,
1145
1146
  Proxy: cosProxy || proxy,
1146
- SecurityToken: token
1147
+ SecurityToken: token,
1148
+ ...(useCosInternalDomain
1149
+ ? {
1150
+ Domain: '{Bucket}.cos-internal.{Region}.tencentcos.cn',
1151
+ ServiceDomain: 'service.cos.tencentcos.cn',
1152
+ Protocol: 'http:'
1153
+ }
1154
+ : {})
1147
1155
  })
1148
1156
  }
1149
1157
 
@@ -1229,7 +1237,8 @@ export class StorageService {
1229
1237
  times: times - 1,
1230
1238
  interval,
1231
1239
  failedFiles: tempFailedFiles
1232
- }).then(res => resolve(res))
1240
+ })
1241
+ .then(res => resolve(res))
1233
1242
  .catch(err => reject(err)),
1234
1243
  interval
1235
1244
  )
@@ -360,6 +360,10 @@ export declare class FunctionService {
360
360
  * @memberof FunctionService
361
361
  */
362
362
  private getFunctionConfig;
363
+ /**
364
+ * 获取日志cls配置信息
365
+ */
366
+ private getClsServiceConfig;
363
367
  /**
364
368
  * 获取 vpc 信息
365
369
  * @returns
@@ -151,4 +151,6 @@ export interface IFunctionUpdateAttribute {
151
151
  };
152
152
  };
153
153
  Layers?: ILayerVersionItem[];
154
+ ClsLogsetId?: string;
155
+ ClsTopicId?: string;
154
156
  }
@@ -119,6 +119,12 @@ export interface EnvInfo {
119
119
  PackageId: string;
120
120
  PackageName: string;
121
121
  LogServices: LogServiceInfo[];
122
+ CustomLogServices: {
123
+ CreateTime: string;
124
+ ClsLogsetId: string;
125
+ ClsTopicId: string;
126
+ ClsRegion: string;
127
+ }[];
122
128
  }
123
129
  export interface FunctionInfo {
124
130
  Namespace?: string;