@cloudbase/manager-node 4.10.3 → 4.11.0-alpha.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.
@@ -28,6 +28,12 @@ class BillingService {
28
28
  OrderIds: orderIds
29
29
  });
30
30
  }
31
+ /**
32
+ * 订单询价
33
+ */
34
+ async calculatePrice(params) {
35
+ return this.billService.request('CalculatePrice', params);
36
+ }
31
37
  }
32
38
  exports.BillingService = BillingService;
33
39
  BillingService.billServiceVersion = {
package/lib/env/index.js CHANGED
@@ -15,13 +15,16 @@ const util_1 = __importDefault(require("util"));
15
15
  const error_1 = require("../error");
16
16
  const utils_1 = require("../utils");
17
17
  const constant_1 = require("../constant");
18
+ const billing_1 = require("../billing");
19
+ const uuid_1 = require("uuid");
18
20
  class EnvService {
19
21
  constructor(environment) {
20
22
  this.environment = environment;
21
23
  this.envId = environment.getEnvId();
22
24
  this.envType = environment.getEnvType();
23
25
  this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
24
- this.commonService = environment.getCommonService("lowcode", "2021-01-08");
26
+ this.commonService = environment.getCommonService('lowcode', '2021-01-08');
27
+ this.billingService = new billing_1.BillingService(environment.cloudBaseContext);
25
28
  }
26
29
  /**
27
30
  * 列出所有环境
@@ -117,10 +120,16 @@ class EnvService {
117
120
  * @memberof EnvService
118
121
  */
119
122
  async destroyEnv(envId) {
120
- return this.cloudService.request('DestroyEnv', {
123
+ return await this.destroyEnvWithParams({
121
124
  EnvId: envId
122
125
  });
123
126
  }
127
+ /**
128
+ * 销毁环境(完整传参)
129
+ */
130
+ async destroyEnvWithParams(params) {
131
+ return this.cloudService.request('DestroyEnv', params);
132
+ }
124
133
  /**
125
134
  * 获取环境信息
126
135
  * @returns {Promise<IEnvInfoRes>}
@@ -133,13 +142,19 @@ class EnvService {
133
142
  if (this.envType === 'run') {
134
143
  params.EnvType = 'run';
135
144
  }
136
- const { EnvList, RequestId } = await this.cloudService.request('DescribeEnvs', params);
145
+ const { EnvList, RequestId } = await this.describeEnvs(params);
137
146
  return {
138
147
  // @ts-ignore
139
148
  EnvInfo: (EnvList === null || EnvList === void 0 ? void 0 : EnvList.length) ? EnvList[0] : {},
140
149
  RequestId
141
150
  };
142
151
  }
152
+ /**
153
+ * 获取环境列表
154
+ */
155
+ async describeEnvs(params) {
156
+ return this.cloudService.request('DescribeEnvs', params);
157
+ }
143
158
  /**
144
159
  * 修改环境名称
145
160
  * @param {string} alias 环境名称
@@ -264,6 +279,235 @@ class EnvService {
264
279
  // ...params
265
280
  // })
266
281
  // }
282
+ /**
283
+ * 创建环境
284
+ */
285
+ async createEnv(params) {
286
+ return this.cloudService.request('CreateEnv', Object.assign({}, params));
287
+ }
288
+ /**
289
+ * 获取新套餐
290
+ */
291
+ async describeBaasPackageList(params) {
292
+ return this.cloudService.request('DescribeBaasPackageList', Object.assign({}, params));
293
+ }
294
+ /**
295
+ * 新购套餐询价
296
+ */
297
+ async calculatePackageCreatePrice(params) {
298
+ var _a, _b, _c;
299
+ const { packageId, region, period = 1, currency = 'CNY' } = params;
300
+ const packageRes = await this.describeBaasPackageList({
301
+ PackageName: packageId,
302
+ Source: 'qcloud',
303
+ PackageTypeList: ['default', 'vip', 'basic', 'trial']
304
+ });
305
+ const packageInfo = (_a = packageRes.PackageList) === null || _a === void 0 ? void 0 : _a[0];
306
+ if (!packageInfo) {
307
+ throw new error_1.CloudBaseError(`Invalid package id: ${packageId}`);
308
+ }
309
+ const { BillTags: billTags } = packageInfo;
310
+ const newBillTag = this.parseBillTags(billTags);
311
+ const priceRes = await this.billingService.calculatePrice({
312
+ PriceType: 'getPrice',
313
+ ResInfo: [
314
+ {
315
+ Currency: currency,
316
+ GoodsCategoryId: (_b = newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.categoryIds) === null || _b === void 0 ? void 0 : _b.create,
317
+ GoodsNum: 1,
318
+ PayMode: 'prePay',
319
+ Region: region,
320
+ Zone: `${region}-1`,
321
+ GoodsDetail: JSON.stringify({
322
+ timeUnit: 'm',
323
+ timeSpan: period,
324
+ requestId: (0, uuid_1.v4)(),
325
+ pid: newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.pid,
326
+ productCode: newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.productCode,
327
+ subProductCode: newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.subProductCode,
328
+ [newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.tag]: 1
329
+ })
330
+ }
331
+ ]
332
+ });
333
+ const priceInfo = (_c = priceRes.PriceInfos) === null || _c === void 0 ? void 0 : _c[0];
334
+ if (!priceInfo) {
335
+ throw new error_1.CloudBaseError(`Invalid package id: ${packageId}`);
336
+ }
337
+ return priceInfo;
338
+ }
339
+ /**
340
+ * 续费套餐询价
341
+ */
342
+ async calculatePackageRenewPrice(params) {
343
+ var _a, _b, _c, _d, _e, _f;
344
+ const { envId, period = 1, currency = 'CNY' } = params;
345
+ const [packageRes, envRes, billingRes] = await Promise.all([
346
+ this.describeBaasPackageList({
347
+ Source: 'qcloud',
348
+ PackageTypeList: ['default', 'vip', 'basic', 'trial']
349
+ }),
350
+ this.describeEnvs({
351
+ EnvId: envId
352
+ }),
353
+ this.describeBillingInfo({
354
+ EnvId: envId
355
+ })
356
+ ]);
357
+ const envInfo = (_a = envRes.EnvList) === null || _a === void 0 ? void 0 : _a[0];
358
+ const billingInfo = (_b = billingRes.EnvBillingInfoList) === null || _b === void 0 ? void 0 : _b[0];
359
+ if (!envInfo || !billingInfo) {
360
+ throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
361
+ }
362
+ const packageInfo = (_c = packageRes.PackageList) === null || _c === void 0 ? void 0 : _c.find(item => item.PackageName === envInfo.PackageId);
363
+ if (!packageInfo) {
364
+ throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
365
+ }
366
+ const region = envInfo.Region;
367
+ const extPackageData = ((_d = billingInfo.ExtPackageCode) === null || _d === void 0 ? void 0 : _d.reduce((acc, { Code, Num }) => {
368
+ acc[Code] = Num;
369
+ return acc;
370
+ }, {})) || {};
371
+ const { BillTags: billTags } = packageInfo;
372
+ const newBillTag = this.parseBillTags(billTags);
373
+ const priceRes = await this.billingService.calculatePrice({
374
+ PriceType: 'getPrice',
375
+ ResInfo: [
376
+ {
377
+ Currency: currency,
378
+ GoodsCategoryId: (_e = newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.categoryIds) === null || _e === void 0 ? void 0 : _e.renew,
379
+ GoodsNum: 1,
380
+ PayMode: 'prePay',
381
+ Region: region,
382
+ Zone: `${region}-1`,
383
+ GoodsDetail: JSON.stringify(Object.assign({ timeUnit: 'm', timeSpan: period, requestId: (0, uuid_1.v4)(), pid: newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.pid, productCode: newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.productCode, subProductCode: newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.subProductCode, [newBillTag === null || newBillTag === void 0 ? void 0 : newBillTag.tag]: 1 }, extPackageData))
384
+ }
385
+ ]
386
+ });
387
+ const priceInfo = (_f = priceRes.PriceInfos) === null || _f === void 0 ? void 0 : _f[0];
388
+ if (!priceInfo) {
389
+ throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
390
+ }
391
+ return priceInfo;
392
+ }
393
+ /**
394
+ * 变配套餐询价
395
+ */
396
+ async calculatePackageModifyPrice(params) {
397
+ var _a, _b, _c, _d, _e, _f, _g;
398
+ const { newPackageId, envId, currency = 'CNY' } = params;
399
+ const [packageRes, envRes, billingRes] = await Promise.all([
400
+ this.describeBaasPackageList({
401
+ Source: 'qcloud',
402
+ PackageTypeList: ['default', 'vip', 'basic', 'trial']
403
+ }),
404
+ this.describeEnvs({
405
+ EnvId: envId
406
+ }),
407
+ this.describeBillingInfo({
408
+ EnvId: envId
409
+ })
410
+ ]);
411
+ const envInfo = (_a = envRes.EnvList) === null || _a === void 0 ? void 0 : _a[0];
412
+ const billingInfo = (_b = billingRes.EnvBillingInfoList) === null || _b === void 0 ? void 0 : _b[0];
413
+ if (!envInfo || !billingInfo || !billingInfo.PackageId) {
414
+ throw new error_1.CloudBaseError(`Invalid env id: ${envId}`);
415
+ }
416
+ const oldPackageInfo = (_c = packageRes.PackageList) === null || _c === void 0 ? void 0 : _c.find(item => item.PackageName === billingInfo.PackageId);
417
+ if (!oldPackageInfo) {
418
+ throw new error_1.CloudBaseError(`Modification for this package is not available`);
419
+ }
420
+ const newPackageInfo = (_d = packageRes.PackageList) === null || _d === void 0 ? void 0 : _d.find(item => item.PackageName === newPackageId);
421
+ if (!newPackageInfo) {
422
+ throw new error_1.CloudBaseError(`Invalid package id: ${newPackageId}`);
423
+ }
424
+ const region = envInfo.Region;
425
+ const newBillTags = this.parseBillTags(newPackageInfo.BillTags);
426
+ const oldBillTags = this.parseBillTags(oldPackageInfo.BillTags);
427
+ let userNumber = 0;
428
+ let appNumber = 0;
429
+ const oldExtPackageData = ((_e = billingInfo.ExtPackageCode) === null || _e === void 0 ? void 0 : _e.reduce((acc, { Code, Num }) => {
430
+ if (Code.includes('_user')) {
431
+ userNumber = Num;
432
+ }
433
+ if (Code.includes('_app')) {
434
+ appNumber = Num;
435
+ }
436
+ acc[Code] = Num;
437
+ return acc;
438
+ }, {})) || {};
439
+ let userBillTag;
440
+ let appBillTag;
441
+ if (Array.isArray(newBillTags.extTags)) {
442
+ userBillTag = newBillTags.extTags.find(item => {
443
+ return item.includes('_user');
444
+ });
445
+ appBillTag = newBillTags.extTags.find(item => {
446
+ return item.includes('_app');
447
+ });
448
+ }
449
+ const newExtPackageData = {};
450
+ if (userBillTag && userNumber) {
451
+ newExtPackageData[userBillTag] = userNumber;
452
+ }
453
+ if (appBillTag && appNumber) {
454
+ newExtPackageData[appBillTag] = appNumber;
455
+ }
456
+ const priceRes = await this.billingService.calculatePrice({
457
+ PriceType: 'getPrice',
458
+ ResInfo: [
459
+ {
460
+ Currency: currency,
461
+ GoodsCategoryId: (_f = newBillTags === null || newBillTags === void 0 ? void 0 : newBillTags.categoryIds) === null || _f === void 0 ? void 0 : _f.modify,
462
+ GoodsNum: 1,
463
+ PayMode: 'prePay',
464
+ Region: region,
465
+ Zone: `${region}-1`,
466
+ GoodsDetail: JSON.stringify({
467
+ resourceId: envId,
468
+ curDeadline: billingInfo.ExpireTime,
469
+ oldConfig: Object.assign({ productCode: 'p_tcb', subProductCode: oldBillTags.subProductCode, pid: oldBillTags.pid, [oldBillTags.tag]: 1 }, oldExtPackageData),
470
+ newConfig: Object.assign({ productCode: 'p_tcb', subProductCode: newBillTags.subProductCode, pid: newBillTags.pid, [newBillTags.tag]: 1 }, newExtPackageData)
471
+ })
472
+ }
473
+ ]
474
+ });
475
+ const priceInfo = (_g = priceRes.PriceInfos) === null || _g === void 0 ? void 0 : _g[0];
476
+ if (!priceInfo) {
477
+ throw new error_1.CloudBaseError(`Invalid package id: ${newPackageId}`);
478
+ }
479
+ return priceInfo;
480
+ }
481
+ /**
482
+ * 更新云开发环境套餐
483
+ */
484
+ async modifyEnvPlan(params) {
485
+ return this.cloudService.request('ModifyEnvPlan', Object.assign({}, params));
486
+ }
487
+ /**
488
+ * 获取计费相关信息
489
+ */
490
+ async describeBillingInfo(params) {
491
+ return this.cloudService.request('DescribeBillingInfo', Object.assign({}, params));
492
+ }
493
+ /**
494
+ * 续费云开发环境
495
+ */
496
+ async renewEnv(params) {
497
+ return this.cloudService.request('RenewEnv', Object.assign({}, params));
498
+ }
499
+ /**
500
+ * 查询环境计费周期
501
+ */
502
+ async describeEnvAccountCircle(params) {
503
+ return this.cloudService.request('DescribeEnvAccountCircle', Object.assign({}, params));
504
+ }
505
+ /**
506
+ * 获取资源点用量明细
507
+ */
508
+ async describeCreditsUsageDetail(params) {
509
+ return this.cloudService.request('DescribeCreditsUsageDetail', Object.assign({}, params));
510
+ }
267
511
  // 获取 COS CORS 域名
268
512
  async getCOSDomains() {
269
513
  const cos = this.getCos();
@@ -310,7 +554,7 @@ class EnvService {
310
554
  SecretId: secretId,
311
555
  SecretKey: secretKey,
312
556
  SecurityToken: token,
313
- Domain: internalEndpoint ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
557
+ Domain: internalEndpoint ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */
314
558
  };
315
559
  if (constant_1.COS_SDK_PROTOCOL) {
316
560
  cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
@@ -333,6 +577,17 @@ class EnvService {
333
577
  bucket: Bucket
334
578
  };
335
579
  }
580
+ parseBillTags(billTags) {
581
+ if (typeof billTags !== 'string') {
582
+ return billTags;
583
+ }
584
+ try {
585
+ return JSON.parse(billTags);
586
+ }
587
+ catch (e) {
588
+ throw new error_1.CloudBaseError(`Failed to parse BillTags: ${billTags}`);
589
+ }
590
+ }
336
591
  }
337
592
  exports.EnvService = EnvService;
338
593
  __decorate([
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -21,6 +21,10 @@ async function fetch(url, config = {}, proxy = null) {
21
21
  try {
22
22
  const res = await (0, node_fetch_1.default)(escapeUrl, config);
23
23
  text = await res.text();
24
+ // 移除 UTF-8 BOM 读取文档需要 (\uFEFF)
25
+ if (text.charCodeAt(0) === 0xFEFF) {
26
+ text = text.slice(1);
27
+ }
24
28
  json = JSON.parse(text);
25
29
  }
26
30
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.10.3",
3
+ "version": "4.11.0-alpha.0",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -52,6 +52,7 @@
52
52
  "node-fetch": "^2.6.0",
53
53
  "query-string": "^6.8.3",
54
54
  "unzipper": "^0.12.3",
55
+ "uuid": "^13.0.0",
55
56
  "walkdir": "^0.4.1"
56
57
  },
57
58
  "husky": {
@@ -1,5 +1,5 @@
1
1
  import { CloudBaseContext } from '../context';
2
- import { IServiceVersion, IGoodItem, IGenerateDealsRes, IPayDealsRes } from '../interfaces';
2
+ import { IServiceVersion, IGoodItem, IGenerateDealsRes, IPayDealsRes, CalculatePriceParams, CalculatePriceRes } from '../interfaces';
3
3
  export declare class BillingService {
4
4
  static billServiceVersion: IServiceVersion;
5
5
  private billService;
@@ -18,4 +18,8 @@ export declare class BillingService {
18
18
  * @memberof BillingService
19
19
  */
20
20
  PayDeals(orderIds: Array<string>): Promise<IPayDealsRes>;
21
+ /**
22
+ * 订单询价
23
+ */
24
+ calculatePrice(params: CalculatePriceParams): Promise<CalculatePriceRes>;
21
25
  }
@@ -1,5 +1,7 @@
1
1
  import { Environment } from '../environment';
2
- import { IResponseInfo, AuthDomain, EnvInfo, LoginConfigItem, ICheckTcbServiceRes, ICreatePostpayRes } from '../interfaces';
2
+ import { IResponseInfo, AuthDomain, EnvInfo, LoginConfigItem, ICheckTcbServiceRes, ICreatePostpayRes, EnvBillingInfoItem, PriceResult } from '../interfaces';
3
+ import { CalculatePackageCreatePriceParams, CalculatePackageRenewPriceParams, CalculatePackageModifyPriceParams } from './type';
4
+ import { CreateBillingDealParams, CreateEnvParams, BaasPackageInfo, DescribeBaasPackageListParams, ModifyEnvPlanParams, RenewEnvParams, DestroyEnvParams, DescribeEnvsParams, DescribeEnvAccountCircleParams, DescribeEnvAccountCircleRes, DescribeCreditsUsageDetailParams, EnvPkgCreditsUsage } from '../interfaces/tcb.interface';
3
5
  type SOURCE = 'miniapp' | 'qcloud';
4
6
  interface IDeleteDomainRes {
5
7
  RequestId: string;
@@ -63,48 +65,13 @@ interface IInitParam {
63
65
  Channel?: string;
64
66
  Source?: string;
65
67
  }
66
- interface CreateBillingDealParams {
67
- /** 下单操作类型 purchase 购买 | renew 续费 | modify 变配 */
68
- DealType: 'purchase' | 'renew' | 'modify';
69
- /** 购买的产品类型,可取[tcb-baas,tcb-promotion,tcb-package], 分别代表baas套餐、大促包、资源包 */
70
- ProductType: 'tcb-baas' | 'tcb-promotion' | 'tcb-package';
71
- /** 目标下单产品/套餐Id */
72
- PackageId: string;
73
- /** 是否自动支付 */
74
- CreateAndPay?: boolean;
75
- /** 购买时长 */
76
- TimeSpan?: number;
77
- /** 购买时长单位 d 天 | m 月 | y 年 | p 一次性 */
78
- TimeUnit?: 'd' | 'm' | 'y' | 'p';
79
- /** 资源唯一标识符 */
80
- ResourceId?: string;
81
- /** 来源 */
82
- Source?: 'qcloud' | 'miniapp';
83
- /** 资源别名 */
84
- Alias?: string;
85
- /** 环境id */
86
- EnvId?: string;
87
- /** 开启超限按量计费 */
88
- EnableExcess?: boolean;
89
- /** 变配目标产品/套餐id */
90
- ModifyPackageId?: string;
91
- /** jsonstr 附加信息 */
92
- Extension?: string;
93
- /** 是否自动选择代金券支付 */
94
- AutoVoucher?: boolean;
95
- /**
96
- * 资源类型
97
- * 代表新购环境(DealType=purchase 并且 ProductType=tcb-baas )时需要发货哪些资源。
98
- * 可取值:flexdb, cos, cdn, scf
99
- */
100
- ResourceTypes?: string[];
101
- }
102
68
  export declare class EnvService {
103
69
  private environment;
104
70
  private envId;
105
71
  private cloudService;
106
72
  private envType?;
107
73
  private commonService;
74
+ private billingService;
108
75
  constructor(environment: Environment);
109
76
  /**
110
77
  * 列出所有环境
@@ -155,6 +122,10 @@ export declare class EnvService {
155
122
  * @memberof EnvService
156
123
  */
157
124
  destroyEnv(envId: string): Promise<IResponseInfo>;
125
+ /**
126
+ * 销毁环境(完整传参)
127
+ */
128
+ destroyEnvWithParams(params: DestroyEnvParams): Promise<IResponseInfo>;
158
129
  /**
159
130
  * 获取环境信息
160
131
  * @returns {Promise<IEnvInfoRes>}
@@ -163,6 +134,14 @@ export declare class EnvService {
163
134
  EnvInfo: EnvInfo;
164
135
  RequestId: string;
165
136
  }>;
137
+ /**
138
+ * 获取环境列表
139
+ */
140
+ describeEnvs(params: DescribeEnvsParams): Promise<{
141
+ RequestId: string;
142
+ EnvList: EnvInfo[];
143
+ Total: number;
144
+ }>;
166
145
  /**
167
146
  * 修改环境名称
168
147
  * @param {string} alias 环境名称
@@ -231,9 +210,64 @@ export declare class EnvService {
231
210
  /**
232
211
  * 删除已取消的订单
233
212
  */
213
+ /**
214
+ * 创建环境
215
+ */
216
+ createEnv(params: CreateEnvParams): Promise<{
217
+ EnvId: string;
218
+ RequestId: string;
219
+ }>;
220
+ /**
221
+ * 获取新套餐
222
+ */
223
+ describeBaasPackageList(params: DescribeBaasPackageListParams): Promise<{
224
+ PackageList: BaasPackageInfo[];
225
+ RequestId: string;
226
+ }>;
227
+ /**
228
+ * 新购套餐询价
229
+ */
230
+ calculatePackageCreatePrice(params: CalculatePackageCreatePriceParams): Promise<PriceResult>;
231
+ /**
232
+ * 续费套餐询价
233
+ */
234
+ calculatePackageRenewPrice(params: CalculatePackageRenewPriceParams): Promise<PriceResult>;
235
+ /**
236
+ * 变配套餐询价
237
+ */
238
+ calculatePackageModifyPrice(params: CalculatePackageModifyPriceParams): Promise<PriceResult>;
239
+ /**
240
+ * 更新云开发环境套餐
241
+ */
242
+ modifyEnvPlan(params: ModifyEnvPlanParams): Promise<IResponseInfo>;
243
+ /**
244
+ * 获取计费相关信息
245
+ */
246
+ describeBillingInfo(params: {
247
+ EnvId?: string;
248
+ }): Promise<{
249
+ EnvBillingInfoList: EnvBillingInfoItem[];
250
+ RequestId: string;
251
+ }>;
252
+ /**
253
+ * 续费云开发环境
254
+ */
255
+ renewEnv(params: RenewEnvParams): Promise<IResponseInfo>;
256
+ /**
257
+ * 查询环境计费周期
258
+ */
259
+ describeEnvAccountCircle(params: DescribeEnvAccountCircleParams): Promise<DescribeEnvAccountCircleRes>;
260
+ /**
261
+ * 获取资源点用量明细
262
+ */
263
+ describeCreditsUsageDetail(params: DescribeCreditsUsageDetailParams): Promise<{
264
+ Usages: EnvPkgCreditsUsage[];
265
+ RequestId: string;
266
+ }>;
234
267
  private getCOSDomains;
235
268
  private modifyCosCorsDomain;
236
269
  private getCos;
237
270
  private getStorageConfig;
271
+ private parseBillTags;
238
272
  }
239
273
  export {};
@@ -0,0 +1,16 @@
1
+ export interface CalculatePackageCreatePriceParams {
2
+ packageId: string;
3
+ region: string;
4
+ period?: number;
5
+ currency?: 'CNY' | 'USD';
6
+ }
7
+ export interface CalculatePackageRenewPriceParams {
8
+ envId: string;
9
+ period?: number;
10
+ currency?: 'CNY' | 'USD';
11
+ }
12
+ export interface CalculatePackageModifyPriceParams {
13
+ newPackageId: string;
14
+ envId: string;
15
+ currency?: 'CNY' | 'USD';
16
+ }
@@ -16,3 +16,71 @@ export interface IPayDealsRes extends IResponseInfo {
16
16
  OrderIds: Array<string>;
17
17
  ResourceIds: Array<string>;
18
18
  }
19
+ export interface PriceResInfo {
20
+ GoodsDetail: string;
21
+ GoodsCategoryId?: number;
22
+ Region?: string;
23
+ Zone?: string;
24
+ GoodsNum?: number;
25
+ Currency?: string;
26
+ ProductCode?: string;
27
+ SubProductCode?: string;
28
+ PayMode?: string;
29
+ ActivityId?: number;
30
+ Purpose?: string;
31
+ ActivityNumber?: string;
32
+ Action?: string;
33
+ }
34
+ export interface CreateAuth {
35
+ Version: string;
36
+ SecretId: string;
37
+ Timestamp: string;
38
+ Signature: string;
39
+ Nonce: string;
40
+ Flag?: string;
41
+ }
42
+ export interface CalculatePriceParams {
43
+ PriceType: string;
44
+ ResInfo: PriceResInfo[];
45
+ PayMode?: string;
46
+ Auth?: CreateAuth;
47
+ ClientUin?: string;
48
+ AgentPay?: string;
49
+ Anonymous?: boolean;
50
+ DisplayDiscountDetail?: boolean;
51
+ }
52
+ export interface HighPrecisionPriceResult {
53
+ [key: string]: any;
54
+ }
55
+ export interface PriceResult {
56
+ Price: number;
57
+ TotalCost: number;
58
+ TimeUnit: string;
59
+ TimeSpan: number;
60
+ GoodsNum: number;
61
+ ProductCode: string;
62
+ SubProductCode: string;
63
+ PartDetail: string;
64
+ Policy: number;
65
+ RealTotalCost: number;
66
+ RefundDetail: string;
67
+ RefundPayer: string;
68
+ TaxRate?: number;
69
+ Formula: string;
70
+ HasUserPrice?: boolean;
71
+ Currency?: string;
72
+ HighPrecisionPrice?: HighPrecisionPriceResult;
73
+ PolicyDetail?: string;
74
+ New?: string;
75
+ Old?: string;
76
+ Refund?: string;
77
+ AmountUnit?: string;
78
+ PayerMode?: string;
79
+ Action?: string;
80
+ RefTaxDeal?: string;
81
+ CountryIsoCode?: string;
82
+ FormulaList?: string;
83
+ }
84
+ export interface CalculatePriceRes extends IResponseInfo {
85
+ PriceInfos: Array<PriceResult>;
86
+ }
@@ -125,6 +125,7 @@ export interface EnvInfo {
125
125
  ClsTopicId: string;
126
126
  ClsRegion: string;
127
127
  }[];
128
+ Region: string;
128
129
  }
129
130
  export interface FunctionInfo {
130
131
  Namespace?: string;
@@ -181,6 +182,12 @@ export interface EnvBillingInfoItem {
181
182
  CreateTime?: string;
182
183
  UpdateTime?: string;
183
184
  IsAlwaysFree?: boolean;
185
+ PaymentChannel?: string;
186
+ PackageName?: string;
187
+ ExtPackageCode?: {
188
+ Code: string;
189
+ Num: number;
190
+ }[];
184
191
  }
185
192
  export interface InvoiceVATGeneral {
186
193
  TaxPayerType?: string;
@@ -303,3 +310,153 @@ export interface IGWOrDomainNumRes extends IResponseInfo {
303
310
  export interface IHttpServiceDomainRes extends IResponseInfo {
304
311
  ServiceSet: Array<CloudBaseGWService>;
305
312
  }
313
+ export interface CreateBillingDealParams {
314
+ /** 下单操作类型 purchase 购买 | renew 续费 | modify 变配 */
315
+ DealType: 'purchase' | 'renew' | 'modify';
316
+ /** 购买的产品类型,可取[tcb-baas,tcb-promotion,tcb-package], 分别代表baas套餐、大促包、资源包 */
317
+ ProductType: 'tcb-baas' | 'tcb-promotion' | 'tcb-package';
318
+ /** 目标下单产品/套餐Id */
319
+ PackageId: string;
320
+ /** 是否自动支付 */
321
+ CreateAndPay?: boolean;
322
+ /** 购买时长 */
323
+ TimeSpan?: number;
324
+ /** 购买时长单位 d 天 | m 月 | y 年 | p 一次性 */
325
+ TimeUnit?: 'd' | 'm' | 'y' | 'p';
326
+ /** 资源唯一标识符 */
327
+ ResourceId?: string;
328
+ /** 来源 */
329
+ Source?: 'qcloud' | 'miniapp';
330
+ /** 资源别名 */
331
+ Alias?: string;
332
+ /** 环境id */
333
+ EnvId?: string;
334
+ /** 开启超限按量计费 */
335
+ EnableExcess?: boolean;
336
+ /** 变配目标产品/套餐id */
337
+ ModifyPackageId?: string;
338
+ /** jsonstr 附加信息 */
339
+ Extension?: string;
340
+ /** 是否自动选择代金券支付 */
341
+ AutoVoucher?: boolean;
342
+ /**
343
+ * 资源类型
344
+ * 代表新购环境(DealType=purchase 并且 ProductType=tcb-baas )时需要发货哪些资源。
345
+ * 可取值:flexdb, cos, cdn, scf
346
+ */
347
+ ResourceTypes?: string[];
348
+ }
349
+ export interface Tag {
350
+ Key: string;
351
+ Value: string;
352
+ }
353
+ export interface CreateEnvParams {
354
+ Alias: string;
355
+ PackageId: string;
356
+ Resources: string[];
357
+ Period?: number;
358
+ AutoVoucher?: boolean;
359
+ Tags?: Tag[];
360
+ RenewFlag?: 'NOTIFY_AND_AUTO_RENEW' | 'NOTIFY_AND_MANUAL_RENEW';
361
+ }
362
+ export interface BaasPackageInfo {
363
+ PackageName: string;
364
+ PackageTitle: string;
365
+ GroupName: string;
366
+ GroupTitle: string;
367
+ BillTags: string;
368
+ ResourceLimit: string;
369
+ AdvanceLimit: string;
370
+ PackageDescription: string;
371
+ IsExternal: boolean;
372
+ UnitPrice: string;
373
+ }
374
+ export interface DescribeBaasPackageListParams {
375
+ PackageName?: string;
376
+ EnvId?: string;
377
+ Source?: string;
378
+ EnvChannel?: string;
379
+ TargetAction?: string;
380
+ GroupName?: string;
381
+ PackageTypeList?: string[];
382
+ PaymentChannel?: string;
383
+ InternationalPackage?: boolean;
384
+ }
385
+ export interface ModifyEnvPlanParams {
386
+ EnvId: string;
387
+ PackageId: string;
388
+ AutoVoucher?: boolean;
389
+ }
390
+ export interface RenewEnvParams {
391
+ EnvId: string;
392
+ Period?: number;
393
+ AutoVoucher?: boolean;
394
+ }
395
+ export interface DestroyEnvParams {
396
+ EnvId: string;
397
+ IsForce?: boolean;
398
+ BypassCheck?: boolean;
399
+ }
400
+ export interface DescribeEnvsParams {
401
+ EnvId?: string;
402
+ WxAppId?: string;
403
+ IsVisible?: boolean;
404
+ Channels?: string[];
405
+ EnvType?: string;
406
+ EnvTypes?: string[];
407
+ Limit?: number;
408
+ Offset?: number;
409
+ }
410
+ export interface DescribeEnvAccountCircleParams {
411
+ EnvId: string;
412
+ WxAppId?: string;
413
+ WithHistoryCircle?: boolean;
414
+ }
415
+ export interface CircleTime {
416
+ StartTime: string;
417
+ EndTime: string;
418
+ }
419
+ export interface DescribeEnvAccountCircleRes extends IResponseInfo {
420
+ StartTime: string;
421
+ EndTime: string;
422
+ HistoryTime: CircleTime[];
423
+ }
424
+ export interface DescribeCreditsUsageDetailParams {
425
+ Modules: string[];
426
+ StartDate: string;
427
+ EndDate: string;
428
+ NeedUsageDetails: boolean;
429
+ EnvId: string;
430
+ }
431
+ export interface ValueDetail {
432
+ CalcTime?: string;
433
+ RawValue?: number;
434
+ CreditsValue?: number;
435
+ DeductValue?: number;
436
+ PackageDeductValue?: number;
437
+ ReportValue?: number;
438
+ OriginCredits?: number;
439
+ }
440
+ export interface MetricUsage {
441
+ MetricName?: string;
442
+ ResourceType?: string;
443
+ Value?: number;
444
+ CreditsValue?: number;
445
+ BillingCycleType?: string;
446
+ Unit?: string;
447
+ ValueDetailList?: ValueDetail[];
448
+ DeductValue?: number;
449
+ PackageDeductValue?: number;
450
+ ReportValue?: number;
451
+ OriginCredits?: number;
452
+ }
453
+ export interface EnvPkgCreditsUsage {
454
+ EnvId?: string;
455
+ Module?: string;
456
+ CreditsValue?: number;
457
+ MetricUsageDetail?: MetricUsage[];
458
+ DeductValue?: number;
459
+ PackageDeductValue?: number;
460
+ ReportValue?: number;
461
+ OriginCredits?: number;
462
+ }