@cloudbase/cli 1.9.9 → 1.12.1-beta

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.
Files changed (53) hide show
  1. package/lib/commands/functions/alias/getRoute.js +98 -0
  2. package/lib/commands/functions/alias/index.js +14 -0
  3. package/lib/commands/functions/alias/setRoute.js +100 -0
  4. package/lib/commands/functions/concurrency/delete.js +70 -0
  5. package/lib/commands/functions/concurrency/index.js +15 -0
  6. package/lib/commands/functions/concurrency/list.js +81 -0
  7. package/lib/commands/functions/concurrency/set.js +72 -0
  8. package/lib/commands/functions/index.js +3 -0
  9. package/lib/commands/functions/list.js +2 -8
  10. package/lib/commands/functions/version/index.js +14 -0
  11. package/lib/commands/functions/version/list.js +96 -0
  12. package/lib/commands/functions/version/publish.js +70 -0
  13. package/lib/constant.js +23 -1
  14. package/lib/function/alias.js +53 -0
  15. package/lib/function/concurrency.js +69 -0
  16. package/lib/function/index.js +3 -0
  17. package/lib/function/version.js +51 -0
  18. package/package.json +9 -3
  19. package/src/commands/functions/alias/getRoute.ts +76 -0
  20. package/src/commands/functions/alias/index.ts +2 -0
  21. package/src/commands/functions/alias/setRoute.ts +82 -0
  22. package/src/commands/functions/concurrency/delete.ts +45 -0
  23. package/src/commands/functions/concurrency/index.ts +3 -0
  24. package/src/commands/functions/concurrency/list.ts +58 -0
  25. package/src/commands/functions/concurrency/set.ts +47 -0
  26. package/src/commands/functions/index.ts +3 -0
  27. package/src/commands/functions/list.ts +1 -8
  28. package/src/commands/functions/version/index.ts +2 -0
  29. package/src/commands/functions/version/list.ts +73 -0
  30. package/src/commands/functions/version/publish.ts +43 -0
  31. package/src/constant.ts +24 -0
  32. package/src/function/alias.ts +43 -0
  33. package/src/function/concurrency.ts +57 -0
  34. package/src/function/index.ts +4 -1
  35. package/src/function/version.ts +39 -0
  36. package/src/types.ts +95 -0
  37. package/types/commands/functions/alias/getRoute.d.ts +13 -0
  38. package/types/commands/functions/alias/index.d.ts +2 -0
  39. package/types/commands/functions/alias/setRoute.d.ts +13 -0
  40. package/types/commands/functions/concurrency/delete.d.ts +13 -0
  41. package/types/commands/functions/concurrency/index.d.ts +3 -0
  42. package/types/commands/functions/concurrency/list.d.ts +13 -0
  43. package/types/commands/functions/concurrency/set.d.ts +13 -0
  44. package/types/commands/functions/index.d.ts +3 -0
  45. package/types/commands/functions/version/index.d.ts +2 -0
  46. package/types/commands/functions/version/list.d.ts +13 -0
  47. package/types/commands/functions/version/publish.d.ts +13 -0
  48. package/types/constant.d.ts +16 -0
  49. package/types/function/alias.d.ts +3 -0
  50. package/types/function/concurrency.d.ts +4 -0
  51. package/types/function/index.d.ts +3 -0
  52. package/types/function/version.d.ts +3 -0
  53. package/types/types.d.ts +82 -0
@@ -0,0 +1,98 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.getFunctionRoutingConfig = void 0;
25
+ const common_1 = require("../../common");
26
+ const utils_1 = require("../../../utils");
27
+ const function_1 = require("../../../function");
28
+ const decorators_1 = require("../../../decorators");
29
+ function parseRoutingConfigValue(expression) {
30
+ const commaIndex = expression.indexOf(',');
31
+ const valueExpression = expression.substring(commaIndex + 1, expression.length - 1);
32
+ return valueExpression;
33
+ }
34
+ let getFunctionRoutingConfig = class getFunctionRoutingConfig extends common_1.Command {
35
+ get options() {
36
+ return {
37
+ cmd: 'fn',
38
+ childCmd: 'get-route <name>',
39
+ options: [
40
+ {
41
+ flags: '-e, --envId <envId>',
42
+ desc: '环境 Id'
43
+ }
44
+ ],
45
+ desc: '查看函数版本流量配置'
46
+ };
47
+ }
48
+ execute(ctx, params) {
49
+ var _a;
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const name = params === null || params === void 0 ? void 0 : params[0];
52
+ const { envId } = ctx;
53
+ const loading = (0, utils_1.loadingFactory)();
54
+ loading.start(`查询函数 [${name}] 版本流量配置中...`);
55
+ const aliasRes = yield (0, function_1.getFunctionAliasConfig)({
56
+ envId,
57
+ functionName: name,
58
+ name: '$DEFAULT'
59
+ });
60
+ const routingConfig = (_a = aliasRes === null || aliasRes === void 0 ? void 0 : aliasRes.RoutingConfig) === null || _a === void 0 ? void 0 : _a.AddtionVersionMatchs;
61
+ let finalConfig = [];
62
+ if (routingConfig.length === 1) {
63
+ finalConfig.push({
64
+ version: routingConfig[0].Version,
65
+ value: parseRoutingConfigValue(routingConfig[0].Expression)
66
+ });
67
+ }
68
+ else if (routingConfig.length === 2) {
69
+ finalConfig.push({
70
+ version: routingConfig[0].Version,
71
+ value: parseRoutingConfigValue(routingConfig[0].Expression)
72
+ }, {
73
+ version: routingConfig[1].Version,
74
+ value: 100 - Number(parseRoutingConfigValue(routingConfig[0].Expression))
75
+ });
76
+ }
77
+ loading.stop();
78
+ const head = ['版本', '流量比例'];
79
+ const tableData = finalConfig.map((item) => [
80
+ item.version,
81
+ item.value
82
+ ]);
83
+ (0, utils_1.printHorizontalTable)(head, tableData);
84
+ });
85
+ }
86
+ };
87
+ __decorate([
88
+ (0, decorators_1.InjectParams)(),
89
+ __param(0, (0, decorators_1.CmdContext)()),
90
+ __param(1, (0, decorators_1.ArgsParams)()),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [Object, Object]),
93
+ __metadata("design:returntype", Promise)
94
+ ], getFunctionRoutingConfig.prototype, "execute", null);
95
+ getFunctionRoutingConfig = __decorate([
96
+ (0, common_1.ICommand)()
97
+ ], getFunctionRoutingConfig);
98
+ exports.getFunctionRoutingConfig = getFunctionRoutingConfig;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./setRoute"), exports);
14
+ __exportStar(require("./getRoute"), exports);
@@ -0,0 +1,100 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.setFunctionRoutingConfig = void 0;
25
+ const common_1 = require("../../common");
26
+ const error_1 = require("../../../error");
27
+ const utils_1 = require("../../../utils");
28
+ const function_1 = require("../../../function");
29
+ const decorators_1 = require("../../../decorators");
30
+ let setFunctionRoutingConfig = class setFunctionRoutingConfig extends common_1.Command {
31
+ get options() {
32
+ return {
33
+ cmd: 'fn',
34
+ childCmd: 'config-route <name> <version1> <traffic1> [version2] [traffic2]',
35
+ options: [
36
+ {
37
+ flags: '-e, --envId <envId>',
38
+ desc: '环境 Id'
39
+ }
40
+ ],
41
+ desc: '设置函数版本流量配置'
42
+ };
43
+ }
44
+ execute(ctx, params) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const name = params === null || params === void 0 ? void 0 : params[0];
47
+ const version1 = params === null || params === void 0 ? void 0 : params[1];
48
+ const traffic1 = Number(params === null || params === void 0 ? void 0 : params[2]);
49
+ const version2 = params === null || params === void 0 ? void 0 : params[3];
50
+ const traffic2 = Number(params === null || params === void 0 ? void 0 : params[4]);
51
+ if ((version2 === undefined && traffic2 !== undefined) || (version2 !== undefined && traffic2 === undefined)) {
52
+ throw new error_1.CloudBaseError('version2 和 traffic2 必须同时设置');
53
+ }
54
+ if (traffic1 !== undefined && traffic2 !== undefined) {
55
+ if (traffic1 + traffic2 !== 100) {
56
+ throw new error_1.CloudBaseError('traffic1 和 traffic2 同时设置时,需保证总和 100');
57
+ }
58
+ }
59
+ const { envId } = ctx;
60
+ const loading = (0, utils_1.loadingFactory)();
61
+ loading.start(`设置函数 [${name}] 版本流量配置中...`);
62
+ let routingConfigParams = {
63
+ AddtionVersionMatchs: [{
64
+ Expression: `[0,${traffic1})`,
65
+ Key: "invoke.headers.X-Tcb-Route-Key",
66
+ Method: "range",
67
+ Version: version1
68
+ }]
69
+ };
70
+ if (version2 !== undefined) {
71
+ routingConfigParams.AddtionVersionMatchs.push({
72
+ Expression: `[${traffic1},${100})`,
73
+ Key: "invoke.headers.X-Tcb-Route-Key",
74
+ Method: "range",
75
+ Version: version2
76
+ });
77
+ }
78
+ yield (0, function_1.setFunctionAliasConfig)({
79
+ envId,
80
+ functionName: name,
81
+ name: '$DEFAULT',
82
+ functionVersion: '$LATEST',
83
+ routingConfig: routingConfigParams
84
+ });
85
+ loading.succeed(`设置函数 [${name}] 版本流量配置成功!`);
86
+ });
87
+ }
88
+ };
89
+ __decorate([
90
+ (0, decorators_1.InjectParams)(),
91
+ __param(0, (0, decorators_1.CmdContext)()),
92
+ __param(1, (0, decorators_1.ArgsParams)()),
93
+ __metadata("design:type", Function),
94
+ __metadata("design:paramtypes", [Object, Object]),
95
+ __metadata("design:returntype", Promise)
96
+ ], setFunctionRoutingConfig.prototype, "execute", null);
97
+ setFunctionRoutingConfig = __decorate([
98
+ (0, common_1.ICommand)()
99
+ ], setFunctionRoutingConfig);
100
+ exports.setFunctionRoutingConfig = setFunctionRoutingConfig;
@@ -0,0 +1,70 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.deleteProvisionedConcurrency = void 0;
25
+ const common_1 = require("../../common");
26
+ const utils_1 = require("../../../utils");
27
+ const function_1 = require("../../../function");
28
+ const decorators_1 = require("../../../decorators");
29
+ let deleteProvisionedConcurrency = class deleteProvisionedConcurrency extends common_1.Command {
30
+ get options() {
31
+ return {
32
+ cmd: 'fn',
33
+ childCmd: 'delete-provisioned-concurrency <name> <version>',
34
+ options: [
35
+ {
36
+ flags: '-e, --envId <envId>',
37
+ desc: '环境 Id'
38
+ }
39
+ ],
40
+ desc: '删除函数版本预置并发配置'
41
+ };
42
+ }
43
+ execute(ctx, params) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const name = params === null || params === void 0 ? void 0 : params[0];
46
+ const version = params === null || params === void 0 ? void 0 : params[1];
47
+ const { envId } = ctx;
48
+ const loading = (0, utils_1.loadingFactory)();
49
+ loading.start(`删除函数 [${name}] 预置并发配置中...`);
50
+ yield (0, function_1.deleteProvisionedConcurrencyConfig)({
51
+ envId,
52
+ functionName: name,
53
+ qualifier: version
54
+ });
55
+ loading.succeed(`删除函数 [${name}] 预置并发配置成功!`);
56
+ });
57
+ }
58
+ };
59
+ __decorate([
60
+ (0, decorators_1.InjectParams)(),
61
+ __param(0, (0, decorators_1.CmdContext)()),
62
+ __param(1, (0, decorators_1.ArgsParams)()),
63
+ __metadata("design:type", Function),
64
+ __metadata("design:paramtypes", [Object, Object]),
65
+ __metadata("design:returntype", Promise)
66
+ ], deleteProvisionedConcurrency.prototype, "execute", null);
67
+ deleteProvisionedConcurrency = __decorate([
68
+ (0, common_1.ICommand)()
69
+ ], deleteProvisionedConcurrency);
70
+ exports.deleteProvisionedConcurrency = deleteProvisionedConcurrency;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./delete"), exports);
14
+ __exportStar(require("./list"), exports);
15
+ __exportStar(require("./set"), exports);
@@ -0,0 +1,81 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.getProvisionedConcurrency = void 0;
25
+ const common_1 = require("../../common");
26
+ const utils_1 = require("../../../utils");
27
+ const function_1 = require("../../../function");
28
+ const decorators_1 = require("../../../decorators");
29
+ const constant_1 = require("../../../constant");
30
+ let getProvisionedConcurrency = class getProvisionedConcurrency extends common_1.Command {
31
+ get options() {
32
+ return {
33
+ cmd: 'fn',
34
+ childCmd: 'get-provisioned-concurrency <name> [version]',
35
+ options: [
36
+ {
37
+ flags: '-e, --envId <envId>',
38
+ desc: '环境 Id'
39
+ }
40
+ ],
41
+ desc: '获取函数版本预置并发配置'
42
+ };
43
+ }
44
+ execute(ctx, params, options) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const name = params === null || params === void 0 ? void 0 : params[0];
47
+ const version = params === null || params === void 0 ? void 0 : params[1];
48
+ const { envId } = ctx;
49
+ const loading = (0, utils_1.loadingFactory)();
50
+ loading.start(`拉取函数 [${name}] 预置并发配置中...`);
51
+ const res = yield (0, function_1.getProvisionedConcurrencyConfig)({
52
+ envId,
53
+ functionName: name,
54
+ qualifier: version
55
+ });
56
+ loading.stop();
57
+ const head = ['设置并发数', '已完成并发数', '预置任务状态', '状态说明', '版本号'];
58
+ const tableData = res.Allocated.map((item) => [
59
+ item.AllocatedProvisionedConcurrencyNum,
60
+ item.AvailableProvisionedConcurrencyNum,
61
+ constant_1.ConcurrencyTaskStatus[item.Status] || '无',
62
+ item.StatusReason,
63
+ item.Qualifier
64
+ ]);
65
+ (0, utils_1.printHorizontalTable)(head, tableData);
66
+ });
67
+ }
68
+ };
69
+ __decorate([
70
+ (0, decorators_1.InjectParams)(),
71
+ __param(0, (0, decorators_1.CmdContext)()),
72
+ __param(1, (0, decorators_1.ArgsParams)()),
73
+ __param(2, (0, decorators_1.ArgsOptions)()),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", [Object, Object, Object]),
76
+ __metadata("design:returntype", Promise)
77
+ ], getProvisionedConcurrency.prototype, "execute", null);
78
+ getProvisionedConcurrency = __decorate([
79
+ (0, common_1.ICommand)()
80
+ ], getProvisionedConcurrency);
81
+ exports.getProvisionedConcurrency = getProvisionedConcurrency;
@@ -0,0 +1,72 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.setProvisionedConcurrency = void 0;
25
+ const common_1 = require("../../common");
26
+ const utils_1 = require("../../../utils");
27
+ const function_1 = require("../../../function");
28
+ const decorators_1 = require("../../../decorators");
29
+ let setProvisionedConcurrency = class setProvisionedConcurrency extends common_1.Command {
30
+ get options() {
31
+ return {
32
+ cmd: 'fn',
33
+ childCmd: 'set-provisioned-concurrency <name> <version> <concurrency>',
34
+ options: [
35
+ {
36
+ flags: '-e, --envId <envId>',
37
+ desc: '环境 Id'
38
+ }
39
+ ],
40
+ desc: '设置函数版本预置并发'
41
+ };
42
+ }
43
+ execute(ctx, params) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const name = params === null || params === void 0 ? void 0 : params[0];
46
+ const version = params === null || params === void 0 ? void 0 : params[1];
47
+ const concurrency = Number((params === null || params === void 0 ? void 0 : params[2]) || 0);
48
+ const { envId } = ctx;
49
+ const loading = (0, utils_1.loadingFactory)();
50
+ loading.start(`配置函数 [${name}] 预置并发中...`);
51
+ yield (0, function_1.setProvisionedConcurrencyConfig)({
52
+ envId,
53
+ functionName: name,
54
+ qualifier: version,
55
+ versionProvisionedConcurrencyNum: concurrency
56
+ });
57
+ loading.succeed(`配置函数 [${name}] 预置并发成功!`);
58
+ });
59
+ }
60
+ };
61
+ __decorate([
62
+ (0, decorators_1.InjectParams)(),
63
+ __param(0, (0, decorators_1.CmdContext)()),
64
+ __param(1, (0, decorators_1.ArgsParams)()),
65
+ __metadata("design:type", Function),
66
+ __metadata("design:paramtypes", [Object, Object]),
67
+ __metadata("design:returntype", Promise)
68
+ ], setProvisionedConcurrency.prototype, "execute", null);
69
+ setProvisionedConcurrency = __decorate([
70
+ (0, common_1.ICommand)()
71
+ ], setProvisionedConcurrency);
72
+ exports.setProvisionedConcurrency = setProvisionedConcurrency;
@@ -23,3 +23,6 @@ __exportStar(require("./trigger-create"), exports);
23
23
  __exportStar(require("./trigger-delete"), exports);
24
24
  __exportStar(require("./code-update"), exports);
25
25
  __exportStar(require("./code-download"), exports);
26
+ __exportStar(require("./version"), exports);
27
+ __exportStar(require("./concurrency"), exports);
28
+ __exportStar(require("./alias"), exports);
@@ -27,13 +27,7 @@ const error_1 = require("../../error");
27
27
  const function_1 = require("../../function");
28
28
  const utils_1 = require("../../utils");
29
29
  const decorators_1 = require("../../decorators");
30
- const StatusMap = {
31
- Active: '部署完成',
32
- Creating: '创建中',
33
- CreateFailed: '创建失败',
34
- Updating: '更新中',
35
- UpdateFailed: '更新失败'
36
- };
30
+ const constant_1 = require("../../constant");
37
31
  let ListFunction = class ListFunction extends common_1.Command {
38
32
  get options() {
39
33
  return {
@@ -80,7 +74,7 @@ let ListFunction = class ListFunction extends common_1.Command {
80
74
  item.Runtime,
81
75
  item.AddTime,
82
76
  item.ModTime,
83
- StatusMap[item.Status]
77
+ constant_1.StatusMap[item.Status]
84
78
  ]);
85
79
  (0, utils_1.printHorizontalTable)(head, tableData);
86
80
  });
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./publish"), exports);
14
+ __exportStar(require("./list"), exports);
@@ -0,0 +1,96 @@
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 __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.ListFunctionVersion = void 0;
25
+ const common_1 = require("../../common");
26
+ const error_1 = require("../../../error");
27
+ const utils_1 = require("../../../utils");
28
+ const function_1 = require("../../../function");
29
+ const decorators_1 = require("../../../decorators");
30
+ const constant_1 = require("../../../constant");
31
+ let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
32
+ get options() {
33
+ return {
34
+ cmd: 'fn',
35
+ childCmd: 'list-function-versions <name>',
36
+ options: [
37
+ {
38
+ flags: '-e, --envId <envId>',
39
+ desc: '环境 Id'
40
+ },
41
+ { flags: '-l, --limit <limit>', desc: '返回数据长度,默认值为 20' },
42
+ {
43
+ flags: '-o, --offset <offset>',
44
+ desc: '数据偏移量,默认值为 0'
45
+ }
46
+ ],
47
+ desc: '展示函数版本列表'
48
+ };
49
+ }
50
+ execute(ctx, params, options) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const name = params === null || params === void 0 ? void 0 : params[0];
53
+ let { limit = 20, offset = 0 } = options;
54
+ limit = Number(limit);
55
+ offset = Number(offset);
56
+ if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
57
+ throw new error_1.CloudBaseError('limit 和 offset 必须为整数');
58
+ }
59
+ if (limit < 0 || offset < 0) {
60
+ throw new error_1.CloudBaseError('limit 和 offset 必须为大于 0 的整数');
61
+ }
62
+ const { envId } = ctx;
63
+ const loading = (0, utils_1.loadingFactory)();
64
+ loading.start(`拉取函数 [${name}] 版本列表中...`);
65
+ const res = yield (0, function_1.listFunctionVersions)({
66
+ envId,
67
+ functionName: name,
68
+ offset,
69
+ limit
70
+ });
71
+ loading.stop();
72
+ const head = ['版本', '描述', '创建时间', '修改时间', '状态'];
73
+ const tableData = res.Versions.map((item) => [
74
+ item.Version,
75
+ item.Description,
76
+ item.AddTime,
77
+ item.ModTime,
78
+ constant_1.StatusMap[item.Status]
79
+ ]);
80
+ (0, utils_1.printHorizontalTable)(head, tableData);
81
+ });
82
+ }
83
+ };
84
+ __decorate([
85
+ (0, decorators_1.InjectParams)(),
86
+ __param(0, (0, decorators_1.CmdContext)()),
87
+ __param(1, (0, decorators_1.ArgsParams)()),
88
+ __param(2, (0, decorators_1.ArgsOptions)()),
89
+ __metadata("design:type", Function),
90
+ __metadata("design:paramtypes", [Object, Object, Object]),
91
+ __metadata("design:returntype", Promise)
92
+ ], ListFunctionVersion.prototype, "execute", null);
93
+ ListFunctionVersion = __decorate([
94
+ (0, common_1.ICommand)()
95
+ ], ListFunctionVersion);
96
+ exports.ListFunctionVersion = ListFunctionVersion;