@cloudbase/cli 3.0.0-alpha.8 → 3.0.0-alpha.9

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 (2) hide show
  1. package/dist/standalone/cli.js +2819 -1061
  2. package/package.json +1 -1
@@ -7584,6 +7584,216 @@ module.exports.loadAll = loadAll;
7584
7584
  module.exports.load = load;
7585
7585
 
7586
7586
 
7587
+ /***/ }),
7588
+
7589
+ /***/ 871:
7590
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7591
+
7592
+ "use strict";
7593
+
7594
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7595
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7596
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7597
+ 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;
7598
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7599
+ };
7600
+ var __metadata = (this && this.__metadata) || function (k, v) {
7601
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7602
+ };
7603
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
7604
+ return function (target, key) { decorator(target, key, paramIndex); }
7605
+ };
7606
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7607
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7608
+ return new (P || (P = Promise))(function (resolve, reject) {
7609
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7610
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7611
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7612
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
7613
+ });
7614
+ };
7615
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7616
+ exports.EditRoutesCommand = void 0;
7617
+ const error_1 = __webpack_require__(66759);
7618
+ const interactive_1 = __webpack_require__(57695);
7619
+ const common_1 = __webpack_require__(48431);
7620
+ const utils_1 = __webpack_require__(82079);
7621
+ const decorators_1 = __webpack_require__(93480);
7622
+ const routes_1 = __webpack_require__(46212);
7623
+ const i18n_1 = __webpack_require__(69258);
7624
+ let EditRoutesCommand = class EditRoutesCommand extends common_1.Command {
7625
+ get options() {
7626
+ return {
7627
+ cmd: 'routes',
7628
+ childCmd: 'edit',
7629
+ options: [
7630
+ {
7631
+ flags: '-d, --data <data>',
7632
+ desc: (0, i18n_1.t)(`路由配置JSON数据(增量更新,只更新传入字段),格式:
7633
+ {
7634
+ "domain": "必填,域名",
7635
+ "routes": [{
7636
+ "path": "必填,路径(用于定位路由)",
7637
+ "upstreamResourceType": "可选,上游类型(SCF|CBR|STATIC_STORE|WEB_SCF|LH)",
7638
+ "upstreamResourceName": "可选,上游服务名",
7639
+ "enable": "可选,启用路由",
7640
+ "enableAuth": "可选,身份认证",
7641
+ "enableSafeDomain": "可选,安全域名",
7642
+ "enablePathTransmission": "可选,路径透传",
7643
+ "pathRewrite": "可选,路径重写 {prefix:\"/newpath\"}",
7644
+ "qpsPolicy": "可选,限频 {qpsTotal:100,qpsPerClient:{limitBy:\"ClientIP\",limitValue:10}}"
7645
+ }]
7646
+ }`)
7647
+ }
7648
+ ],
7649
+ desc: (0, i18n_1.t)('修改已有的 HTTP 服务路由配置。通过域名+路径定位路由,支持增量更新指定字段,不会删除已有路由'),
7650
+ examples: [
7651
+ `tcb routes edit -e envId --data '{"domain":"api.example.com","routes":[{"path":"/api/*","upstreamResourceName":"new-service"}]}'`,
7652
+ `tcb routes edit -e envId --data '{"domain":"api.example.com","routes":[{"path":"/api/*","enable":false}]}'`,
7653
+ `tcb routes edit -e envId --data '{"domain":"api.example.com","routes":[{"path":"/api/*","enableAuth":true,"enablePathTransmission":true}]}'`,
7654
+ `tcb routes edit -e envId --data '{"domain":"api.example.com","routes":[{"path":"/v1/*","qpsPolicy":{"qpsTotal":2000,"qpsPerClient":{"limitBy":"ClientIP","limitValue":20}}}]}'`
7655
+ ]
7656
+ };
7657
+ }
7658
+ execute(envId, options, log) {
7659
+ return __awaiter(this, void 0, void 0, function* () {
7660
+ log.verbose(options);
7661
+ if (!options.data) {
7662
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请提供路由配置数据,使用 --data 参数'));
7663
+ }
7664
+ let routeData;
7665
+ try {
7666
+ routeData = JSON.parse(options.data);
7667
+ }
7668
+ catch (e) {
7669
+ throw new error_1.CloudBaseError((0, i18n_1.t)('JSON 数据格式错误: {{error}}', { error: e.message }));
7670
+ }
7671
+ if (!routeData.domain) {
7672
+ throw new error_1.CloudBaseError((0, i18n_1.t)('缺少必填字段: domain'));
7673
+ }
7674
+ if (!routeData.routes || !Array.isArray(routeData.routes) || routeData.routes.length === 0) {
7675
+ throw new error_1.CloudBaseError((0, i18n_1.t)('缺少路由配置: routes 必须是非空数组'));
7676
+ }
7677
+ const invalidRoutes = [];
7678
+ routeData.routes.forEach((route, index) => {
7679
+ if (!route.path) {
7680
+ invalidRoutes.push(`routes[${index}].path`);
7681
+ }
7682
+ });
7683
+ if (invalidRoutes.length > 0) {
7684
+ throw new error_1.CloudBaseError((0, i18n_1.t)('路由配置缺少必填字段: {{fields}}', { fields: invalidRoutes.join(', ') }));
7685
+ }
7686
+ let domains = [];
7687
+ try {
7688
+ const result = yield (0, routes_1.getHTTPServiceRoutes)({
7689
+ envId,
7690
+ });
7691
+ domains = result.domains;
7692
+ }
7693
+ catch (e) {
7694
+ throw new error_1.CloudBaseError({
7695
+ message: e.message || (0, i18n_1.t)('获取路由列表失败'),
7696
+ code: 'API_ERROR',
7697
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
7698
+ original: e
7699
+ });
7700
+ }
7701
+ const targetDomain = domains.find((d) => d.Domain === routeData.domain);
7702
+ if (!targetDomain) {
7703
+ throw new error_1.CloudBaseError((0, i18n_1.t)('域名 [{{domain}}] 不存在,无法更新', { domain: routeData.domain }));
7704
+ }
7705
+ const existingRoutes = targetDomain.Routes || [];
7706
+ const existingPaths = new Set(existingRoutes.map((r) => r.Path));
7707
+ const notFoundRoutes = [];
7708
+ routeData.routes.forEach((route) => {
7709
+ if (!existingPaths.has(route.path)) {
7710
+ notFoundRoutes.push(route.path);
7711
+ }
7712
+ });
7713
+ if (notFoundRoutes.length > 0) {
7714
+ throw new error_1.CloudBaseError((0, i18n_1.t)('以下路由不存在,无法更新: {{paths}}', { paths: notFoundRoutes.join(', ') }));
7715
+ }
7716
+ let confirmMessage = (0, i18n_1.t)('确认更新以下 HTTP 服务路由配置?\n域名: {{domain}}', {
7717
+ domain: routeData.domain
7718
+ });
7719
+ confirmMessage += (0, i18n_1.t)('\n\n待更新路由 ({{count}}个):', { count: routeData.routes.length });
7720
+ routeData.routes.forEach((route) => {
7721
+ confirmMessage += (0, i18n_1.t)('\n ~ {{path}}', { path: route.path });
7722
+ if (route.upstreamResourceName !== undefined) {
7723
+ confirmMessage += (0, i18n_1.t)(' (upstreamResourceName: {{value}})', { value: route.upstreamResourceName });
7724
+ }
7725
+ if (route.upstreamResourceType !== undefined) {
7726
+ confirmMessage += (0, i18n_1.t)(' (upstreamResourceType: {{value}})', { value: route.upstreamResourceType });
7727
+ }
7728
+ if (route.enable !== undefined) {
7729
+ confirmMessage += (0, i18n_1.t)(' (enable: {{value}})', { value: route.enable });
7730
+ }
7731
+ if (route.enableAuth !== undefined) {
7732
+ confirmMessage += (0, i18n_1.t)(' (enableAuth: {{value}})', { value: route.enableAuth });
7733
+ }
7734
+ if (route.enablePathTransmission !== undefined) {
7735
+ confirmMessage += (0, i18n_1.t)(' (enablePathTransmission: {{value}})', { value: route.enablePathTransmission });
7736
+ }
7737
+ if (route.enableSafeDomain !== undefined) {
7738
+ confirmMessage += (0, i18n_1.t)(' (enableSafeDomain: {{value}})', { value: route.enableSafeDomain });
7739
+ }
7740
+ });
7741
+ const confirm = yield (0, interactive_1.autoConfirm)(confirmMessage, true);
7742
+ if (!confirm) {
7743
+ throw new error_1.CloudBaseError({
7744
+ message: (0, i18n_1.t)('操作已取消'),
7745
+ code: 'USER_CANCEL'
7746
+ });
7747
+ }
7748
+ const domainParam = {
7749
+ Domain: routeData.domain,
7750
+ Routes: routeData.routes.map((route) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ Path: route.path }, (route.upstreamResourceType !== undefined && { UpstreamResourceType: route.upstreamResourceType })), (route.upstreamResourceName !== undefined && { UpstreamResourceName: route.upstreamResourceName })), (route.enable !== undefined && { Enable: route.enable })), (route.enableAuth !== undefined && { EnableAuth: route.enableAuth })), (route.enableSafeDomain !== undefined && { EnableSafeDomain: route.enableSafeDomain })), (route.enablePathTransmission !== undefined && { EnablePathTransmission: route.enablePathTransmission })), (route.pathRewrite !== undefined && { PathRewrite: route.pathRewrite })), (route.qpsPolicy !== undefined && { QPSPolicy: route.qpsPolicy }))))
7751
+ };
7752
+ log.verbose('更新路由参数:', domainParam);
7753
+ try {
7754
+ yield (0, routes_1.modifyHTTPServiceRoute)({
7755
+ envId,
7756
+ domain: domainParam
7757
+ });
7758
+ }
7759
+ catch (e) {
7760
+ throw new error_1.CloudBaseError({
7761
+ message: e.message || (0, i18n_1.t)('更新路由失败'),
7762
+ code: 'API_ERROR',
7763
+ solution: [(0, i18n_1.t)('请检查路由配置是否正确')],
7764
+ original: e
7765
+ });
7766
+ }
7767
+ if ((0, utils_1.isJsonOutput)()) {
7768
+ (0, utils_1.outputJson)({
7769
+ domain: routeData.domain,
7770
+ updateCount: routeData.routes.length,
7771
+ message: (0, i18n_1.t)('成功更新 HTTP 服务路由配置')
7772
+ });
7773
+ return;
7774
+ }
7775
+ log.success((0, i18n_1.t)('成功更新域名 [{{domain}}] 的 {{count}} 个路由', {
7776
+ domain: routeData.domain,
7777
+ count: routeData.routes.length
7778
+ }));
7779
+ });
7780
+ }
7781
+ };
7782
+ __decorate([
7783
+ (0, decorators_1.InjectParams)(),
7784
+ __param(0, (0, decorators_1.EnvId)()),
7785
+ __param(1, (0, decorators_1.ArgsOptions)()),
7786
+ __param(2, (0, decorators_1.Log)()),
7787
+ __metadata("design:type", Function),
7788
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
7789
+ __metadata("design:returntype", Promise)
7790
+ ], EditRoutesCommand.prototype, "execute", null);
7791
+ EditRoutesCommand = __decorate([
7792
+ (0, common_1.ICommand)()
7793
+ ], EditRoutesCommand);
7794
+ exports.EditRoutesCommand = EditRoutesCommand;
7795
+
7796
+
7587
7797
  /***/ }),
7588
7798
 
7589
7799
  /***/ 920:
@@ -296301,7 +296511,7 @@ function validateRoleCreateInput(name, identity, users, policies) {
296301
296511
  code: 'INVALID_PARAM'
296302
296512
  });
296303
296513
  }
296304
- if (!/^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5\\-_:@.]*$/.test(name)) {
296514
+ if (!/^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5_:@.-]*$/.test(name)) {
296305
296515
  throw new error_1.CloudBaseError({
296306
296516
  message: (0, i18n_1.t)('角色名称格式不合法'),
296307
296517
  code: 'INVALID_PARAM',
@@ -296906,7 +297116,7 @@ let RoleUpdateCommand = class RoleUpdateCommand extends common_1.Command {
296906
297116
  code: 'INVALID_PARAM'
296907
297117
  });
296908
297118
  }
296909
- if (!/^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5\\-_:@.]*$/.test(trimmedName)) {
297119
+ if (!/^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5_:@.-]*$/.test(trimmedName)) {
296910
297120
  throw new error_1.CloudBaseError({
296911
297121
  message: (0, i18n_1.t)('角色名称格式不合法'),
296912
297122
  code: 'INVALID_PARAM',
@@ -324940,7 +325150,7 @@ let UpdateUserCommand = class UpdateUserCommand extends common_1.Command {
324940
325150
  throw new error_1.CloudBaseError({
324941
325151
  message: (0, i18n_1.t)('请指定用户 UID,例如:tcb user update 1001'),
324942
325152
  code: 'MISSING_PARAM',
324943
- solution: [(0, i18n_1.t)('用法:tcb user update <uid> --envId <envId>')]
325153
+ solution: [(0, i18n_1.t)('用法:tcb user update <uid> --env-id <envId>')]
324944
325154
  });
324945
325155
  }
324946
325156
  if (options.status) {
@@ -325002,7 +325212,7 @@ let UpdateUserCommand = class UpdateUserCommand extends common_1.Command {
325002
325212
  throw new error_1.CloudBaseError({
325003
325213
  message: e.message || (0, i18n_1.t)('更新用户失败'),
325004
325214
  code: 'API_ERROR',
325005
- solution: [(0, i18n_1.t)('请检查用户 UID 是否正确:tcb user list --envId {{envId}}', { envId })],
325215
+ solution: [(0, i18n_1.t)('请检查用户 UID 是否正确:tcb user list --env-id {{envId}}', { envId })],
325006
325216
  original: e
325007
325217
  });
325008
325218
  }
@@ -330928,6 +331138,199 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
330928
331138
  exports.stringifyPair = stringifyPair;
330929
331139
 
330930
331140
 
331141
+ /***/ }),
331142
+
331143
+ /***/ 8028:
331144
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
331145
+
331146
+ "use strict";
331147
+
331148
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
331149
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
331150
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
331151
+ 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;
331152
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
331153
+ };
331154
+ var __metadata = (this && this.__metadata) || function (k, v) {
331155
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
331156
+ };
331157
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
331158
+ return function (target, key) { decorator(target, key, paramIndex); }
331159
+ };
331160
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
331161
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
331162
+ return new (P || (P = Promise))(function (resolve, reject) {
331163
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
331164
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
331165
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
331166
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
331167
+ });
331168
+ };
331169
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
331170
+ exports.ListDomainsCommand = void 0;
331171
+ const common_1 = __webpack_require__(48431);
331172
+ const error_1 = __webpack_require__(66759);
331173
+ const utils_1 = __webpack_require__(82079);
331174
+ const decorators_1 = __webpack_require__(93480);
331175
+ const routes_1 = __webpack_require__(46212);
331176
+ const i18n_1 = __webpack_require__(69258);
331177
+ let ListDomainsCommand = class ListDomainsCommand extends common_1.Command {
331178
+ get options() {
331179
+ return {
331180
+ cmd: 'domains',
331181
+ childCmd: 'ls',
331182
+ options: [
331183
+ {
331184
+ flags: '--offset <offset>',
331185
+ desc: (0, i18n_1.t)('分页偏移量,默认为 0'),
331186
+ default: '0'
331187
+ },
331188
+ {
331189
+ flags: '--limit <limit>',
331190
+ desc: (0, i18n_1.t)('分页限制,默认 20'),
331191
+ default: '20'
331192
+ },
331193
+ {
331194
+ flags: '--filter <filter>',
331195
+ desc: (0, i18n_1.t)('过滤条件。可过滤字段: Domain(域名)、DomainType(域名类型: HTTPSERVICE/CBR/ANYSERVICE/AI_AGENT/VM/INTEGRATION_CALLBACK)、AccessType(接入方式: DIRECT/CDN/CUSTOM)。多个条件用&连接(且关系),多值用逗号分隔(或关系)')
331196
+ }
331197
+ ],
331198
+ desc: (0, i18n_1.t)('查询自定义域名列表。展示所有绑定的自定义域名信息,包括域名状态、证书、接入方式、协议类型及其下绑定的路由'),
331199
+ examples: [
331200
+ 'tcb domains ls -e envId',
331201
+ 'tcb domains ls -e envId --json',
331202
+ 'tcb domains ls -e envId --limit 50 --offset 0',
331203
+ 'tcb domains ls -e envId --filter "Domain=api.example.com"',
331204
+ 'tcb domains ls -e envId --filter "AccessType=CDN"',
331205
+ 'tcb domains ls -e envId --filter "DomainType=HTTPSERVICE&AccessType=DIRECT"'
331206
+ ]
331207
+ };
331208
+ }
331209
+ execute(envId, options, log) {
331210
+ return __awaiter(this, void 0, void 0, function* () {
331211
+ const offset = parseInt(options.offset, 10) || 0;
331212
+ const limit = parseInt(options.limit, 10) || 20;
331213
+ const filters = [];
331214
+ let hasDomainTypeFilter = false;
331215
+ if (options.filter) {
331216
+ const filterStr = Array.isArray(options.filter)
331217
+ ? options.filter.join('&')
331218
+ : options.filter;
331219
+ const conditions = filterStr.split('&');
331220
+ conditions.forEach((condition) => {
331221
+ const equalIndex = condition.indexOf('=');
331222
+ if (equalIndex > 0) {
331223
+ const name = condition.substring(0, equalIndex);
331224
+ const value = condition.substring(equalIndex + 1);
331225
+ if (name && value) {
331226
+ if (name === 'DomainType') {
331227
+ hasDomainTypeFilter = true;
331228
+ }
331229
+ filters.push({
331230
+ Name: name,
331231
+ Values: value.split(',').map((v) => v.trim())
331232
+ });
331233
+ }
331234
+ }
331235
+ });
331236
+ }
331237
+ if (!hasDomainTypeFilter) {
331238
+ filters.push({
331239
+ Name: 'DomainType',
331240
+ Values: ['HTTPSERVICE']
331241
+ });
331242
+ }
331243
+ let domains = [];
331244
+ let totalCount = 0;
331245
+ try {
331246
+ const result = yield (0, routes_1.getHTTPServiceRoutes)({
331247
+ envId,
331248
+ offset,
331249
+ limit,
331250
+ filters
331251
+ });
331252
+ domains = result.domains;
331253
+ totalCount = result.totalCount;
331254
+ }
331255
+ catch (e) {
331256
+ throw new error_1.CloudBaseError({
331257
+ message: e.message || (0, i18n_1.t)('获取域名列表失败'),
331258
+ code: 'API_ERROR',
331259
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
331260
+ original: e
331261
+ });
331262
+ }
331263
+ if ((0, utils_1.isJsonOutput)()) {
331264
+ const toCamelCase = (obj) => {
331265
+ if (Array.isArray(obj)) {
331266
+ return obj.map((item) => toCamelCase(item));
331267
+ }
331268
+ if (obj !== null && typeof obj === 'object') {
331269
+ const result = {};
331270
+ for (const key in obj) {
331271
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
331272
+ const camelKey = key.charAt(0).toLowerCase() + key.slice(1);
331273
+ result[camelKey] = toCamelCase(obj[key]);
331274
+ }
331275
+ }
331276
+ return result;
331277
+ }
331278
+ return obj;
331279
+ };
331280
+ (0, utils_1.outputJson)(toCamelCase(domains), { total: totalCount, limit, offset });
331281
+ return;
331282
+ }
331283
+ if (domains.length === 0) {
331284
+ log.info((0, i18n_1.t)('域名列表为空!'));
331285
+ return;
331286
+ }
331287
+ const head = [
331288
+ (0, i18n_1.t)('域名'),
331289
+ (0, i18n_1.t)('域名启用'),
331290
+ (0, i18n_1.t)('证书ID'),
331291
+ (0, i18n_1.t)('DNS状态'),
331292
+ (0, i18n_1.t)('状态'),
331293
+ (0, i18n_1.t)('接入方式'),
331294
+ (0, i18n_1.t)('CName'),
331295
+ (0, i18n_1.t)('协议类型'),
331296
+ (0, i18n_1.t)('更新时间'),
331297
+ (0, i18n_1.t)('路由')
331298
+ ];
331299
+ const tableData = domains.map((domain) => {
331300
+ const routes = domain.Routes || [];
331301
+ const routePaths = routes.map((r) => r.Path).join(', ');
331302
+ return [
331303
+ domain.Domain,
331304
+ domain.Enable ? (0, i18n_1.t)('开启') : (0, i18n_1.t)('关闭'),
331305
+ domain.CertId || '-',
331306
+ domain.DNSStatus || '-',
331307
+ domain.Status || '-',
331308
+ domain.AccessType || '-',
331309
+ domain.Cname || '-',
331310
+ domain.Protocol || '-',
331311
+ domain.UpdateTime || '-',
331312
+ routePaths || '-'
331313
+ ];
331314
+ });
331315
+ (0, utils_1.printHorizontalTable)(head, tableData);
331316
+ });
331317
+ }
331318
+ };
331319
+ __decorate([
331320
+ (0, decorators_1.InjectParams)(),
331321
+ __param(0, (0, decorators_1.EnvId)()),
331322
+ __param(1, (0, decorators_1.ArgsOptions)()),
331323
+ __param(2, (0, decorators_1.Log)()),
331324
+ __metadata("design:type", Function),
331325
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
331326
+ __metadata("design:returntype", Promise)
331327
+ ], ListDomainsCommand.prototype, "execute", null);
331328
+ ListDomainsCommand = __decorate([
331329
+ (0, common_1.ICommand)()
331330
+ ], ListDomainsCommand);
331331
+ exports.ListDomainsCommand = ListDomainsCommand;
331332
+
331333
+
330931
331334
  /***/ }),
330932
331335
 
330933
331336
  /***/ 8104:
@@ -332009,7 +332412,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
332009
332412
  /***/ ((module) => {
332010
332413
 
332011
332414
  "use strict";
332012
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"3.0.0-alpha.8","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","test:e2e":"node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern=\'test/e2e/\' --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.11.0-alpha.9","@cloudbase/toolbox":"0.7.17","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","i18next-scanner":"^4.6.0","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557","ai":{"skills":"./skills","skillsIndex":"./skills/index.json","compatible":["codebuddy","cursor","copilot","claude","windsurf"],"description":"CloudBase CLI - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
332415
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"3.0.0-alpha.9","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","test:e2e":"node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathPattern=\'test/e2e/\' --runInBand --forceExit --detectOpenHandles --verbose --testTimeout=120000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.11.0-alpha.10","@cloudbase/toolbox":"0.7.17","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","i18next-scanner":"^4.6.0","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557","ai":{"skills":"./skills","skillsIndex":"./skills/index.json","compatible":["codebuddy","cursor","copilot","claude","windsurf"],"description":"CloudBase CLI - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
332013
332416
 
332014
332417
  /***/ }),
332015
332418
 
@@ -333701,6 +334104,44 @@ function from(Readable, iterable, opts) {
333701
334104
  module.exports = from;
333702
334105
 
333703
334106
 
334107
+ /***/ }),
334108
+
334109
+ /***/ 8906:
334110
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
334111
+
334112
+ "use strict";
334113
+
334114
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
334115
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
334116
+ return new (P || (P = Promise))(function (resolve, reject) {
334117
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
334118
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
334119
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
334120
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
334121
+ });
334122
+ };
334123
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
334124
+ exports.ensureEnvId = void 0;
334125
+ const error_1 = __webpack_require__(66759);
334126
+ const utils_1 = __webpack_require__(75213);
334127
+ const i18n_1 = __webpack_require__(69258);
334128
+ function ensureEnvId(envId, isJson) {
334129
+ return __awaiter(this, void 0, void 0, function* () {
334130
+ if (envId)
334131
+ return envId;
334132
+ if (isJson) {
334133
+ throw new error_1.CloudBaseError({
334134
+ message: (0, i18n_1.t)('请通过 --env-id 指定环境'),
334135
+ code: 'MISSING_PARAM',
334136
+ solution: [(0, i18n_1.t)('使用 -e, --env-id 指定环境')]
334137
+ });
334138
+ }
334139
+ return (0, utils_1.selectEnv)();
334140
+ });
334141
+ }
334142
+ exports.ensureEnvId = ensureEnvId;
334143
+
334144
+
333704
334145
  /***/ }),
333705
334146
 
333706
334147
  /***/ 8908:
@@ -377091,18 +377532,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
377091
377532
  step((generator = generator.apply(thisArg, _arguments || [])).next());
377092
377533
  });
377093
377534
  };
377094
- var __importDefault = (this && this.__importDefault) || function (mod) {
377095
- return (mod && mod.__esModule) ? mod : { "default": mod };
377096
- };
377097
377535
  Object.defineProperty(exports, "__esModule", ({ value: true }));
377098
377536
  exports.InstanceRestartCommand = exports.InstanceListCommand = void 0;
377099
377537
  const common_1 = __webpack_require__(48431);
377100
377538
  const decorators_1 = __webpack_require__(93480);
377101
377539
  const utils_1 = __webpack_require__(82079);
377102
- const utils_2 = __webpack_require__(75213);
377103
377540
  const mysql_1 = __webpack_require__(69116);
377104
377541
  const common_2 = __webpack_require__(79101);
377105
- const inquirer_1 = __importDefault(__webpack_require__(6403));
377542
+ const common_3 = __webpack_require__(8906);
377543
+ const error_1 = __webpack_require__(66759);
377106
377544
  const i18n_1 = __webpack_require__(69258);
377107
377545
  let InstanceListCommand = class InstanceListCommand extends common_1.Command {
377108
377546
  get options() {
@@ -377112,90 +377550,69 @@ let InstanceListCommand = class InstanceListCommand extends common_1.Command {
377112
377550
  childSubCmd: 'list',
377113
377551
  options: [
377114
377552
  common_2.limitOption,
377115
- common_2.offsetOption,
377116
- common_2.jsonOption
377553
+ common_2.offsetOption
377117
377554
  ],
377118
377555
  desc: (0, i18n_1.t)('列出 MySQL 实例'),
377119
377556
  requiredEnvId: false,
377120
377557
  autoRunLogin: true
377121
377558
  };
377122
377559
  }
377123
- execute(envId, options, log) {
377560
+ execute(ctx, envId, options, log) {
377561
+ var _a;
377124
377562
  return __awaiter(this, void 0, void 0, function* () {
377125
- const isJson = options.json;
377126
- let selectedEnvId = envId;
377127
- if (!selectedEnvId) {
377128
- if (isJson) {
377129
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
377130
- return;
377131
- }
377132
- selectedEnvId = yield (0, utils_2.selectEnv)();
377133
- }
377563
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
377564
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
377134
377565
  const loading = (0, utils_1.loadingFactory)();
377135
- try {
377136
- const limit = options.limit ? Number(options.limit) : undefined;
377137
- const offset = options.offset ? Number(options.offset) : undefined;
377138
- loading.start((0, i18n_1.t)('获取实例列表中...'));
377139
- const result = yield (0, mysql_1.describeInstances)({
377140
- envId: selectedEnvId,
377141
- limit,
377142
- offset
377143
- });
377144
- loading.stop();
377145
- const instances = result.InstanceSet || [];
377146
- if (isJson) {
377147
- (0, common_2.jsonOutput)({
377148
- code: 0,
377149
- data: {
377150
- instances,
377151
- totalCount: result.TotalCount || instances.length
377152
- }
377153
- });
377154
- return;
377155
- }
377156
- if (instances.length === 0) {
377157
- log.info((0, i18n_1.t)('当前环境下没有 MySQL 实例'));
377158
- return;
377159
- }
377160
- const head = [
377161
- (0, i18n_1.t)('实例 ID'),
377162
- (0, i18n_1.t)('名称'),
377163
- (0, i18n_1.t)('状态'),
377164
- (0, i18n_1.t)('集群 ID'),
377165
- (0, i18n_1.t)('内网地址'),
377166
- (0, i18n_1.t)('CPU'),
377167
- (0, i18n_1.t)('内存(GB)')
377168
- ];
377169
- const tableData = instances.map((item) => [
377170
- item.InstanceId,
377171
- item.InstanceName || '-',
377172
- item.StatusDesc || item.Status,
377173
- item.ClusterId || '-',
377174
- item.Vip ? `${item.Vip}:${item.Vport}` : '-',
377175
- `${item.Cpu}`,
377176
- `${item.Memory}`
377177
- ]);
377178
- (0, utils_1.printHorizontalTable)(head, tableData);
377179
- log.info((0, i18n_1.t)('共 {{count}} 个实例', { count: String(result.TotalCount || instances.length) }));
377566
+ const limit = options.limit ? Number(options.limit) : undefined;
377567
+ const offset = options.offset ? Number(options.offset) : undefined;
377568
+ loading.start((0, i18n_1.t)('获取实例列表中...'));
377569
+ const result = yield (0, mysql_1.describeInstances)({
377570
+ envId: selectedEnvId,
377571
+ limit,
377572
+ offset
377573
+ });
377574
+ loading.stop();
377575
+ const instances = result.InstanceSet || [];
377576
+ const totalCount = result.TotalCount || instances.length;
377577
+ if (isJson) {
377578
+ (0, utils_1.outputJson)(instances, { total: totalCount, limit, offset });
377579
+ return;
377180
377580
  }
377181
- catch (e) {
377182
- loading.stop();
377183
- if (isJson) {
377184
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
377185
- return;
377186
- }
377187
- throw e;
377581
+ if (instances.length === 0) {
377582
+ log.info((0, i18n_1.t)('当前环境下没有 MySQL 实例'));
377583
+ return;
377188
377584
  }
377585
+ const head = [
377586
+ (0, i18n_1.t)('实例 ID'),
377587
+ (0, i18n_1.t)('名称'),
377588
+ (0, i18n_1.t)('状态'),
377589
+ (0, i18n_1.t)('集群 ID'),
377590
+ (0, i18n_1.t)('内网地址'),
377591
+ (0, i18n_1.t)('CPU'),
377592
+ (0, i18n_1.t)('内存(GB)')
377593
+ ];
377594
+ const tableData = instances.map((item) => [
377595
+ item.InstanceId,
377596
+ item.InstanceName || '-',
377597
+ item.StatusDesc || item.Status,
377598
+ item.ClusterId || '-',
377599
+ item.Vip ? `${item.Vip}:${item.Vport}` : '-',
377600
+ `${item.Cpu}`,
377601
+ `${item.Memory}`
377602
+ ]);
377603
+ (0, utils_1.printHorizontalTable)(head, tableData);
377604
+ log.info((0, i18n_1.t)('共 {{count}} 个实例', { count: String(totalCount) }));
377189
377605
  });
377190
377606
  }
377191
377607
  };
377192
377608
  __decorate([
377193
377609
  (0, decorators_1.InjectParams)(),
377194
- __param(0, (0, decorators_1.EnvId)()),
377195
- __param(1, (0, decorators_1.ArgsOptions)()),
377196
- __param(2, (0, decorators_1.Log)()),
377610
+ __param(0, (0, decorators_1.CmdContext)()),
377611
+ __param(1, (0, decorators_1.EnvId)()),
377612
+ __param(2, (0, decorators_1.ArgsOptions)()),
377613
+ __param(3, (0, decorators_1.Log)()),
377197
377614
  __metadata("design:type", Function),
377198
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
377615
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
377199
377616
  __metadata("design:returntype", Promise)
377200
377617
  ], InstanceListCommand.prototype, "execute", null);
377201
377618
  InstanceListCommand = __decorate([
@@ -377209,84 +377626,57 @@ let InstanceRestartCommand = class InstanceRestartCommand extends common_1.Comma
377209
377626
  childCmd: { cmd: 'instance', desc: (0, i18n_1.t)('MySQL 实例管理') },
377210
377627
  childSubCmd: 'restart',
377211
377628
  options: [
377212
- common_2.instanceIdOption,
377213
- common_2.yesOption,
377214
- common_2.jsonOption
377629
+ common_2.instanceIdOption
377215
377630
  ],
377216
377631
  desc: (0, i18n_1.t)('重启 MySQL 实例'),
377217
377632
  requiredEnvId: false,
377218
377633
  autoRunLogin: true
377219
377634
  };
377220
377635
  }
377221
- execute(envId, options, log) {
377636
+ execute(ctx, envId, options, log) {
377637
+ var _a;
377222
377638
  return __awaiter(this, void 0, void 0, function* () {
377223
- const isJson = options.json;
377224
- let selectedEnvId = envId;
377225
- if (!selectedEnvId) {
377226
- if (isJson) {
377227
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
377228
- return;
377229
- }
377230
- selectedEnvId = yield (0, utils_2.selectEnv)();
377231
- }
377639
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
377640
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
377232
377641
  let selectedInstanceId = options.instanceId;
377233
377642
  if (!selectedInstanceId) {
377234
377643
  if (isJson) {
377235
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --instanceId 指定实例') });
377236
- return;
377644
+ throw new error_1.CloudBaseError({
377645
+ message: (0, i18n_1.t)('请通过 --instance-id 指定实例'),
377646
+ code: 'MISSING_PARAM',
377647
+ solution: [(0, i18n_1.t)('使用 --instance-id 指定实例')]
377648
+ });
377237
377649
  }
377238
377650
  selectedInstanceId = yield (0, common_2.selectInstance)(selectedEnvId);
377239
377651
  }
377240
- if (!options.yes) {
377241
- if (isJson) {
377242
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--json 模式下需要配合 --yes 跳过确认') });
377243
- return;
377244
- }
377245
- const { confirm } = yield inquirer_1.default.prompt([
377246
- {
377247
- type: 'confirm',
377248
- name: 'confirm',
377249
- message: (0, i18n_1.t)('确定要重启实例 {{instanceId}} 吗?', { instanceId: selectedInstanceId }),
377250
- default: false
377251
- }
377252
- ]);
377253
- if (!confirm) {
377254
- log.info((0, i18n_1.t)('已取消操作'));
377255
- return;
377256
- }
377652
+ const confirmed = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('确定要重启实例 {{instanceId}} 吗?', { instanceId: selectedInstanceId }));
377653
+ if (!confirmed) {
377654
+ log.info((0, i18n_1.t)('已取消操作'));
377655
+ return;
377257
377656
  }
377258
377657
  const loading = (0, utils_1.loadingFactory)();
377259
- try {
377260
- loading.start((0, i18n_1.t)('正在重启实例...'));
377261
- const result = yield (0, mysql_1.restartInstance)({
377262
- envId: selectedEnvId,
377263
- instanceId: selectedInstanceId
377264
- });
377265
- loading.stop();
377266
- if (isJson) {
377267
- (0, common_2.jsonOutput)({ code: 0, data: { flowId: result.FlowId } });
377268
- return;
377269
- }
377270
- log.success((0, i18n_1.t)('重启操作已提交,FlowId: {{flowId}}', { flowId: String(result.FlowId) }));
377271
- }
377272
- catch (e) {
377273
- loading.stop();
377274
- if (isJson) {
377275
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
377276
- return;
377277
- }
377278
- throw e;
377658
+ loading.start((0, i18n_1.t)('正在重启实例...'));
377659
+ const result = yield (0, mysql_1.restartInstance)({
377660
+ envId: selectedEnvId,
377661
+ instanceId: selectedInstanceId
377662
+ });
377663
+ loading.stop();
377664
+ if (isJson) {
377665
+ (0, utils_1.outputJson)({ flowId: result.FlowId });
377666
+ return;
377279
377667
  }
377668
+ log.success((0, i18n_1.t)('重启操作已提交,FlowId: {{flowId}}', { flowId: String(result.FlowId) }));
377280
377669
  });
377281
377670
  }
377282
377671
  };
377283
377672
  __decorate([
377284
377673
  (0, decorators_1.InjectParams)(),
377285
- __param(0, (0, decorators_1.EnvId)()),
377286
- __param(1, (0, decorators_1.ArgsOptions)()),
377287
- __param(2, (0, decorators_1.Log)()),
377674
+ __param(0, (0, decorators_1.CmdContext)()),
377675
+ __param(1, (0, decorators_1.EnvId)()),
377676
+ __param(2, (0, decorators_1.ArgsOptions)()),
377677
+ __param(3, (0, decorators_1.Log)()),
377288
377678
  __metadata("design:type", Function),
377289
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
377679
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
377290
377680
  __metadata("design:returntype", Promise)
377291
377681
  ], InstanceRestartCommand.prototype, "execute", null);
377292
377682
  InstanceRestartCommand = __decorate([
@@ -378506,6 +378896,33 @@ HARError.prototype = Error.prototype
378506
378896
  module.exports = HARError
378507
378897
 
378508
378898
 
378899
+ /***/ }),
378900
+
378901
+ /***/ 14120:
378902
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
378903
+
378904
+ "use strict";
378905
+
378906
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
378907
+ if (k2 === undefined) k2 = k;
378908
+ var desc = Object.getOwnPropertyDescriptor(m, k);
378909
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
378910
+ desc = { enumerable: true, get: function() { return m[k]; } };
378911
+ }
378912
+ Object.defineProperty(o, k2, desc);
378913
+ }) : (function(o, m, k, k2) {
378914
+ if (k2 === undefined) k2 = k;
378915
+ o[k2] = m[k];
378916
+ }));
378917
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
378918
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
378919
+ };
378920
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
378921
+ __exportStar(__webpack_require__(21826), exports);
378922
+ __exportStar(__webpack_require__(95499), exports);
378923
+ __exportStar(__webpack_require__(50455), exports);
378924
+
378925
+
378509
378926
  /***/ }),
378510
378927
 
378511
378928
  /***/ 14155:
@@ -397267,6 +397684,71 @@ exports["default"] = def;
397267
397684
  })));
397268
397685
 
397269
397686
 
397687
+ /***/ }),
397688
+
397689
+ /***/ 17375:
397690
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
397691
+
397692
+ "use strict";
397693
+
397694
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
397695
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
397696
+ return new (P || (P = Promise))(function (resolve, reject) {
397697
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
397698
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
397699
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
397700
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
397701
+ });
397702
+ };
397703
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
397704
+ exports.deleteCustomDomain = exports.bindCustomDomain = exports.getCustomDomains = void 0;
397705
+ const net_1 = __webpack_require__(25491);
397706
+ function getCustomDomains({ envId, offset = 0, limit = 20, filters = [] }) {
397707
+ return __awaiter(this, void 0, void 0, function* () {
397708
+ const params = {
397709
+ EnvId: envId,
397710
+ Offset: offset,
397711
+ Limit: limit
397712
+ };
397713
+ if (filters.length > 0) {
397714
+ params.Filters = filters;
397715
+ }
397716
+ const envService = yield (0, net_1.getEnvService)(envId);
397717
+ const result = yield envService.describeHttpServiceRoute(params);
397718
+ const domains = (result === null || result === void 0 ? void 0 : result.Domains) || [];
397719
+ const totalCount = typeof (result === null || result === void 0 ? void 0 : result.TotalCount) === 'number' ? result.TotalCount : 0;
397720
+ return { domains, totalCount };
397721
+ });
397722
+ }
397723
+ exports.getCustomDomains = getCustomDomains;
397724
+ function bindCustomDomain({ envId, domain, certId, accessType = 'DIRECT', enable = true, customCname }) {
397725
+ return __awaiter(this, void 0, void 0, function* () {
397726
+ const envService = yield (0, net_1.getEnvService)(envId);
397727
+ yield envService.bindCustomDomain({
397728
+ EnvId: envId,
397729
+ Domain: {
397730
+ Domain: domain,
397731
+ CertId: certId,
397732
+ AccessType: accessType,
397733
+ Enable: enable,
397734
+ CustomCname: customCname
397735
+ }
397736
+ });
397737
+ });
397738
+ }
397739
+ exports.bindCustomDomain = bindCustomDomain;
397740
+ function deleteCustomDomain({ envId, domain }) {
397741
+ return __awaiter(this, void 0, void 0, function* () {
397742
+ const envService = yield (0, net_1.getEnvService)(envId);
397743
+ yield envService.deleteCustomDomain({
397744
+ EnvId: envId,
397745
+ Domain: domain
397746
+ });
397747
+ });
397748
+ }
397749
+ exports.deleteCustomDomain = deleteCustomDomain;
397750
+
397751
+
397270
397752
  /***/ }),
397271
397753
 
397272
397754
  /***/ 17382:
@@ -417413,6 +417895,107 @@ class ProviderAsync extends provider_1.default {
417413
417895
  exports["default"] = ProviderAsync;
417414
417896
 
417415
417897
 
417898
+ /***/ }),
417899
+
417900
+ /***/ 21826:
417901
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
417902
+
417903
+ "use strict";
417904
+
417905
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
417906
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
417907
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
417908
+ 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;
417909
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
417910
+ };
417911
+ var __metadata = (this && this.__metadata) || function (k, v) {
417912
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
417913
+ };
417914
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
417915
+ return function (target, key) { decorator(target, key, paramIndex); }
417916
+ };
417917
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
417918
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
417919
+ return new (P || (P = Promise))(function (resolve, reject) {
417920
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
417921
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
417922
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
417923
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
417924
+ });
417925
+ };
417926
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
417927
+ exports.ListCorsCommand = void 0;
417928
+ const common_1 = __webpack_require__(48431);
417929
+ const error_1 = __webpack_require__(66759);
417930
+ const utils_1 = __webpack_require__(82079);
417931
+ const decorators_1 = __webpack_require__(93480);
417932
+ const cors_1 = __webpack_require__(59515);
417933
+ const i18n_1 = __webpack_require__(69258);
417934
+ let ListCorsCommand = class ListCorsCommand extends common_1.Command {
417935
+ get options() {
417936
+ return {
417937
+ cmd: 'cors',
417938
+ childCmd: 'list',
417939
+ options: [],
417940
+ desc: (0, i18n_1.t)('列出环境的安全域名列表')
417941
+ };
417942
+ }
417943
+ execute(envId, log) {
417944
+ return __awaiter(this, void 0, void 0, function* () {
417945
+ let domains = [];
417946
+ try {
417947
+ domains = yield (0, cors_1.getCorsDomains)({
417948
+ envId: envId
417949
+ });
417950
+ }
417951
+ catch (e) {
417952
+ throw new error_1.CloudBaseError({
417953
+ message: e.message || (0, i18n_1.t)('获取安全域名列表失败'),
417954
+ code: 'API_ERROR',
417955
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
417956
+ original: e
417957
+ });
417958
+ }
417959
+ if ((0, utils_1.isJsonOutput)()) {
417960
+ (0, utils_1.outputJson)(domains.map((item) => ({
417961
+ id: item.Id,
417962
+ domain: item.Domain,
417963
+ createTime: item.CreateTime,
417964
+ status: item.Status
417965
+ })), {
417966
+ total: domains.length
417967
+ });
417968
+ return;
417969
+ }
417970
+ if (domains.length === 0) {
417971
+ log.info((0, i18n_1.t)('安全域名为空!'));
417972
+ return;
417973
+ }
417974
+ const head = [(0, i18n_1.t)('域名 Id'), (0, i18n_1.t)('域名'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('状态')];
417975
+ const tableData = domains.map((item) => [
417976
+ item.Id,
417977
+ item.Domain,
417978
+ item.CreateTime,
417979
+ item.Status === 'ENABLE' ? (0, i18n_1.t)('启用中') : (0, i18n_1.t)('禁用中')
417980
+ ]);
417981
+ (0, utils_1.printHorizontalTable)(head, tableData);
417982
+ });
417983
+ }
417984
+ };
417985
+ __decorate([
417986
+ (0, decorators_1.InjectParams)(),
417987
+ __param(0, (0, decorators_1.EnvId)()),
417988
+ __param(1, (0, decorators_1.Log)()),
417989
+ __metadata("design:type", Function),
417990
+ __metadata("design:paramtypes", [Object, decorators_1.Logger]),
417991
+ __metadata("design:returntype", Promise)
417992
+ ], ListCorsCommand.prototype, "execute", null);
417993
+ ListCorsCommand = __decorate([
417994
+ (0, common_1.ICommand)()
417995
+ ], ListCorsCommand);
417996
+ exports.ListCorsCommand = ListCorsCommand;
417997
+
417998
+
417416
417999
  /***/ }),
417417
418000
 
417418
418001
  /***/ 21827:
@@ -461105,32 +461688,29 @@ const common_1 = __webpack_require__(48431);
461105
461688
  const deep_command_1 = __webpack_require__(81752);
461106
461689
  const decorators_1 = __webpack_require__(93480);
461107
461690
  const utils_1 = __webpack_require__(82079);
461108
- const utils_2 = __webpack_require__(75213);
461109
461691
  const mysql_1 = __webpack_require__(69116);
461110
461692
  const common_2 = __webpack_require__(79101);
461693
+ const common_3 = __webpack_require__(8906);
461694
+ const error_1 = __webpack_require__(66759);
461111
461695
  const i18n_1 = __webpack_require__(69258);
461112
461696
  const startOption = { flags: '--start <start>', desc: (0, i18n_1.t)('开始时间,如 2026-03-01 00:00:00') };
461113
461697
  const endOption = { flags: '--end <end>', desc: (0, i18n_1.t)('结束时间,如 2026-03-19 23:59:59') };
461114
461698
  const thresholdOption = { flags: '--threshold <threshold>', desc: (0, i18n_1.t)('慢查询阈值(秒),用于本地过滤,如 1') };
461115
- const orderByOption = { flags: '--orderBy <orderBy>', desc: (0, i18n_1.t)('排序字段: QueryTime / LockTime / RowsExamined / RowsSent') };
461116
- const orderByTypeOption = { flags: '--orderByType <orderByType>', desc: (0, i18n_1.t)('排序方式: asc / desc') };
461699
+ const orderByOption = { flags: '--order-by <orderBy>', desc: (0, i18n_1.t)('排序字段: QueryTime / LockTime / RowsExamined / RowsSent') };
461700
+ const orderByTypeOption = { flags: '--order-by-type <orderByType>', desc: (0, i18n_1.t)('排序方式: asc / desc') };
461117
461701
  const databaseOption = { flags: '--database <database>', desc: (0, i18n_1.t)('按数据库名过滤') };
461118
461702
  const usernameOption = { flags: '--username <username>', desc: (0, i18n_1.t)('按用户名过滤') };
461119
461703
  function resolveEnvAndInstance(envId, instanceId, isJson) {
461120
461704
  return __awaiter(this, void 0, void 0, function* () {
461121
- let selectedEnvId = envId;
461122
- if (!selectedEnvId) {
461123
- if (isJson) {
461124
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
461125
- return null;
461126
- }
461127
- selectedEnvId = yield (0, utils_2.selectEnv)();
461128
- }
461705
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
461129
461706
  let selectedInstanceId = instanceId;
461130
461707
  if (!selectedInstanceId) {
461131
461708
  if (isJson) {
461132
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --instanceId 指定实例') });
461133
- return null;
461709
+ throw new error_1.CloudBaseError({
461710
+ message: (0, i18n_1.t)('请通过 --instance-id 指定实例'),
461711
+ code: 'MISSING_PARAM',
461712
+ solution: [(0, i18n_1.t)('使用 --instance-id 指定实例')]
461713
+ });
461134
461714
  }
461135
461715
  selectedInstanceId = yield (0, common_2.selectInstance)(selectedEnvId);
461136
461716
  }
@@ -461153,105 +461733,89 @@ let SlowQueryCommand = class SlowQueryCommand extends deep_command_1.DeepCommand
461153
461733
  databaseOption,
461154
461734
  usernameOption,
461155
461735
  common_2.limitOption,
461156
- common_2.offsetOption,
461157
- common_2.jsonOption
461736
+ common_2.offsetOption
461158
461737
  ],
461159
461738
  desc: (0, i18n_1.t)('查看慢查询日志'),
461160
461739
  requiredEnvId: false,
461161
461740
  autoRunLogin: true
461162
461741
  };
461163
461742
  }
461164
- execute(envId, options, log) {
461743
+ execute(ctx, envId, options, log) {
461744
+ var _a;
461165
461745
  return __awaiter(this, void 0, void 0, function* () {
461166
- const isJson = options.json;
461746
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
461167
461747
  const resolved = yield resolveEnvAndInstance(envId, options.instanceId, isJson);
461168
- if (!resolved)
461169
- return;
461170
461748
  const loading = (0, utils_1.loadingFactory)();
461171
- try {
461172
- loading.start((0, i18n_1.t)('查询慢查询日志中...'));
461173
- const result = yield (0, mysql_1.describeInstanceSlowQueries)({
461174
- envId: resolved.envId,
461175
- instanceId: resolved.instanceId,
461176
- startTime: options.start,
461177
- endTime: options.end,
461178
- limit: options.limit ? Number(options.limit) : undefined,
461179
- offset: options.offset ? Number(options.offset) : undefined,
461180
- orderBy: options.orderBy || 'QueryTime',
461181
- orderByType: options.orderByType || 'desc',
461182
- database: options.database,
461183
- username: options.username
461184
- });
461185
- loading.stop();
461186
- let slowQueries = result.SlowQueries || [];
461187
- if (options.threshold) {
461188
- const threshold = Number(options.threshold);
461189
- if (!isNaN(threshold)) {
461190
- slowQueries = slowQueries.filter((sq) => sq.QueryTime !== undefined && sq.QueryTime >= threshold);
461191
- }
461192
- }
461193
- if (isJson) {
461194
- (0, common_2.jsonOutput)({
461195
- code: 0,
461196
- data: {
461197
- totalCount: result.TotalCount,
461198
- count: slowQueries.length,
461199
- slowQueries,
461200
- requestId: result.RequestId
461201
- }
461202
- });
461203
- return;
461204
- }
461205
- if (slowQueries.length === 0) {
461206
- log.info((0, i18n_1.t)('当前没有慢查询记录'));
461207
- return;
461749
+ const limit = options.limit ? Number(options.limit) : undefined;
461750
+ const offset = options.offset ? Number(options.offset) : undefined;
461751
+ loading.start((0, i18n_1.t)('查询慢查询日志中...'));
461752
+ const result = yield (0, mysql_1.describeInstanceSlowQueries)({
461753
+ envId: resolved.envId,
461754
+ instanceId: resolved.instanceId,
461755
+ startTime: options.start,
461756
+ endTime: options.end,
461757
+ limit,
461758
+ offset,
461759
+ orderBy: options.orderBy || 'QueryTime',
461760
+ orderByType: options.orderByType || 'desc',
461761
+ database: options.database,
461762
+ username: options.username
461763
+ });
461764
+ loading.stop();
461765
+ let slowQueries = result.SlowQueries || [];
461766
+ if (options.threshold) {
461767
+ const threshold = Number(options.threshold);
461768
+ if (!isNaN(threshold)) {
461769
+ slowQueries = slowQueries.filter((sq) => sq.QueryTime !== undefined && sq.QueryTime >= threshold);
461208
461770
  }
461209
- log.info((0, i18n_1.t)('慢查询记录(共 {{total}} 条,当前展示 {{count}} 条):', {
461210
- total: String(result.TotalCount),
461211
- count: String(slowQueries.length)
461212
- }));
461213
- const head = [
461214
- (0, i18n_1.t)('时间'),
461215
- (0, i18n_1.t)('数据库'),
461216
- (0, i18n_1.t)('用户'),
461217
- (0, i18n_1.t)('耗时(s)'),
461218
- (0, i18n_1.t)('锁等待(s)'),
461219
- (0, i18n_1.t)('扫描行数'),
461220
- (0, i18n_1.t)('SQL')
461221
- ];
461222
- const tableData = slowQueries.map((sq) => [
461223
- sq.Timestamp
461224
- ? new Date(sq.Timestamp * 1000).toISOString().replace('T', ' ').substring(0, 19)
461225
- : '-',
461226
- sq.Database || '-',
461227
- sq.UserName || '-',
461228
- sq.QueryTime !== undefined ? String(sq.QueryTime) : '-',
461229
- sq.LockTime !== undefined ? String(sq.LockTime) : '-',
461230
- sq.RowsExamined !== undefined ? String(sq.RowsExamined) : '-',
461231
- sq.SqlText
461232
- ? (sq.SqlText.length > 60 ? sq.SqlText.substring(0, 60) + '...' : sq.SqlText)
461233
- : '-'
461234
- ]);
461235
- (0, utils_1.printHorizontalTable)(head, tableData);
461236
461771
  }
461237
- catch (e) {
461238
- loading.stop();
461239
- if (isJson) {
461240
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
461241
- return;
461242
- }
461243
- throw e;
461772
+ const totalCount = result.TotalCount;
461773
+ if (isJson) {
461774
+ (0, utils_1.outputJson)({ slowQueries, requestId: result.RequestId }, { total: totalCount, limit, offset });
461775
+ return;
461244
461776
  }
461777
+ if (slowQueries.length === 0) {
461778
+ log.info((0, i18n_1.t)('当前没有慢查询记录'));
461779
+ return;
461780
+ }
461781
+ log.info((0, i18n_1.t)('慢查询记录(共 {{total}} 条,当前展示 {{count}} 条):', {
461782
+ total: String(totalCount),
461783
+ count: String(slowQueries.length)
461784
+ }));
461785
+ const head = [
461786
+ (0, i18n_1.t)('时间'),
461787
+ (0, i18n_1.t)('数据库'),
461788
+ (0, i18n_1.t)('用户'),
461789
+ (0, i18n_1.t)('耗时(s)'),
461790
+ (0, i18n_1.t)('锁等待(s)'),
461791
+ (0, i18n_1.t)('扫描行数'),
461792
+ (0, i18n_1.t)('SQL')
461793
+ ];
461794
+ const tableData = slowQueries.map((sq) => [
461795
+ sq.Timestamp
461796
+ ? new Date(sq.Timestamp * 1000).toISOString().replace('T', ' ').substring(0, 19)
461797
+ : '-',
461798
+ sq.Database || '-',
461799
+ sq.UserName || '-',
461800
+ sq.QueryTime !== undefined ? String(sq.QueryTime) : '-',
461801
+ sq.LockTime !== undefined ? String(sq.LockTime) : '-',
461802
+ sq.RowsExamined !== undefined ? String(sq.RowsExamined) : '-',
461803
+ sq.SqlText
461804
+ ? (sq.SqlText.length > 60 ? sq.SqlText.substring(0, 60) + '...' : sq.SqlText)
461805
+ : '-'
461806
+ ]);
461807
+ (0, utils_1.printHorizontalTable)(head, tableData);
461245
461808
  });
461246
461809
  }
461247
461810
  };
461248
461811
  __decorate([
461249
461812
  (0, decorators_1.InjectParams)(),
461250
- __param(0, (0, decorators_1.EnvId)()),
461251
- __param(1, (0, decorators_1.ArgsOptions)()),
461252
- __param(2, (0, decorators_1.Log)()),
461813
+ __param(0, (0, decorators_1.CmdContext)()),
461814
+ __param(1, (0, decorators_1.EnvId)()),
461815
+ __param(2, (0, decorators_1.ArgsOptions)()),
461816
+ __param(3, (0, decorators_1.Log)()),
461253
461817
  __metadata("design:type", Function),
461254
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
461818
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
461255
461819
  __metadata("design:returntype", Promise)
461256
461820
  ], SlowQueryCommand.prototype, "execute", null);
461257
461821
  SlowQueryCommand = __decorate([
@@ -461622,6 +462186,250 @@ __exportStar(__webpack_require__(21753), exports);
461622
462186
  __exportStar(__webpack_require__(30411), exports);
461623
462187
 
461624
462188
 
462189
+ /***/ }),
462190
+
462191
+ /***/ 25812:
462192
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
462193
+
462194
+ "use strict";
462195
+
462196
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
462197
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
462198
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
462199
+ 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;
462200
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
462201
+ };
462202
+ var __metadata = (this && this.__metadata) || function (k, v) {
462203
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
462204
+ };
462205
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
462206
+ return function (target, key) { decorator(target, key, paramIndex); }
462207
+ };
462208
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
462209
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
462210
+ return new (P || (P = Promise))(function (resolve, reject) {
462211
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
462212
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
462213
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
462214
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
462215
+ });
462216
+ };
462217
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
462218
+ exports.AddRoutesCommand = void 0;
462219
+ const error_1 = __webpack_require__(66759);
462220
+ const interactive_1 = __webpack_require__(57695);
462221
+ const common_1 = __webpack_require__(48431);
462222
+ const utils_1 = __webpack_require__(82079);
462223
+ const decorators_1 = __webpack_require__(93480);
462224
+ const routes_1 = __webpack_require__(46212);
462225
+ const i18n_1 = __webpack_require__(69258);
462226
+ let AddRoutesCommand = class AddRoutesCommand extends common_1.Command {
462227
+ get options() {
462228
+ return {
462229
+ cmd: 'routes',
462230
+ childCmd: 'add',
462231
+ options: [
462232
+ {
462233
+ flags: '-d, --data <data>',
462234
+ desc: (0, i18n_1.t)(`路由配置JSON数据,格式:
462235
+ {
462236
+ "domain": "必填,域名",
462237
+ "routes": [{
462238
+ "path": "必填,路径(支持通配符/*)",
462239
+ "upstreamResourceType": "必填,上游类型(SCF|CBR|STATIC_STORE|WEB_SCF|LH)",
462240
+ "upstreamResourceName": "必填,上游服务名",
462241
+ "enable": "可选,启用路由(默认true)",
462242
+ "enableAuth": "可选,身份认证(默认false)",
462243
+ "enableSafeDomain": "可选,安全域名(默认true)",
462244
+ "enablePathTransmission": "可选,路径透传(默认false)",
462245
+ "pathRewrite": "可选,路径重写 {prefix:\"/newpath\"}",
462246
+ "qpsPolicy": "可选,限频 {qpsTotal:100,qpsPerClient:{limitBy:\"ClientIP\",limitValue:10}}"
462247
+ }]
462248
+ }`)
462249
+ }
462250
+ ],
462251
+ desc: (0, i18n_1.t)('创建 HTTP 服务路由。为指定域名添加一个或多个路由规则,将请求转发到云函数、云托管、静态托管等上游服务'),
462252
+ examples: [
462253
+ `tcb routes add -e envId --data '{"domain":"api.example.com","routes":[{"path":"/api/*","upstreamResourceType":"CBR","upstreamResourceName":"my-service"}]}'`,
462254
+ `tcb routes add -e envId --data '{"domain":"api.example.com","routes":[{"path":"/func/*","upstreamResourceType":"SCF","upstreamResourceName":"my-function","enableAuth":true}]}'`,
462255
+ `tcb routes add -e envId --data '{"domain":"www.example.com","routes":[{"path":"/*","upstreamResourceType":"STATIC_STORE","upstreamResourceName":"website"}]}'`,
462256
+ `tcb routes add -e envId --data '{"domain":"api.example.com","routes":[{"path":"/v1/*","upstreamResourceType":"CBR","upstreamResourceName":"backend","qpsPolicy":{"qpsTotal":1000}}]}'`
462257
+ ]
462258
+ };
462259
+ }
462260
+ execute(envId, options, log) {
462261
+ var _a;
462262
+ return __awaiter(this, void 0, void 0, function* () {
462263
+ log.verbose(options);
462264
+ if (!options.data) {
462265
+ throw new error_1.CloudBaseError({
462266
+ message: (0, i18n_1.t)('请提供路由配置数据,使用 --data 参数'),
462267
+ code: 'MISSING_PARAM',
462268
+ solution: [(0, i18n_1.t)('使用 --data 参数提供 JSON 格式的路由配置')]
462269
+ });
462270
+ }
462271
+ let routeData;
462272
+ try {
462273
+ routeData = JSON.parse(options.data);
462274
+ }
462275
+ catch (e) {
462276
+ throw new error_1.CloudBaseError({
462277
+ message: (0, i18n_1.t)('请提供路由配置数据,使用 --data 参数'),
462278
+ code: 'MISSING_PARAM',
462279
+ solution: [(0, i18n_1.t)('JSON格式错误,请检查路由配置的JSON格式是否正确')]
462280
+ });
462281
+ }
462282
+ if (!routeData.domain) {
462283
+ throw new error_1.CloudBaseError({
462284
+ message: (0, i18n_1.t)('缺少必填字段: domain'),
462285
+ code: 'MISSING_PARAM',
462286
+ solution: [(0, i18n_1.t)('使用 --data 参数提供 JSON 格式的路由配置')]
462287
+ });
462288
+ }
462289
+ if (!routeData.routes || !Array.isArray(routeData.routes) || routeData.routes.length === 0) {
462290
+ throw new error_1.CloudBaseError({
462291
+ message: (0, i18n_1.t)('缺少路由配置: routes 必须是非空数组'),
462292
+ code: 'MISSING_PARAM',
462293
+ solution: [(0, i18n_1.t)('使用 --data 参数提供 JSON 格式的路由配置')]
462294
+ });
462295
+ }
462296
+ const invalidRoutes = [];
462297
+ routeData.routes.forEach((route, index) => {
462298
+ if (!route.path) {
462299
+ invalidRoutes.push(`routes[${index}].path`);
462300
+ }
462301
+ if (!route.upstreamResourceType) {
462302
+ invalidRoutes.push(`routes[${index}].upstreamResourceType`);
462303
+ }
462304
+ if (!route.upstreamResourceName) {
462305
+ invalidRoutes.push(`routes[${index}].upstreamResourceName`);
462306
+ }
462307
+ });
462308
+ if (invalidRoutes.length > 0) {
462309
+ throw new error_1.CloudBaseError({
462310
+ message: (0, i18n_1.t)('路由配置缺少必填字段: {{fields}}', { fields: invalidRoutes.join(', ') }),
462311
+ code: 'MISSING_PARAM',
462312
+ solution: [(0, i18n_1.t)('使用 --data 参数提供 JSON 格式的路由配置')]
462313
+ });
462314
+ }
462315
+ let existingDomains = [];
462316
+ try {
462317
+ const result = yield (0, routes_1.getHTTPServiceRoutes)({
462318
+ envId,
462319
+ });
462320
+ existingDomains = result.domains;
462321
+ }
462322
+ catch (e) {
462323
+ throw new error_1.CloudBaseError({
462324
+ message: e.message || (0, i18n_1.t)('获取路由列表失败'),
462325
+ code: 'API_ERROR',
462326
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
462327
+ original: e
462328
+ });
462329
+ }
462330
+ const existingDomain = existingDomains.find((d) => d.Domain === routeData.domain);
462331
+ if (existingDomain) {
462332
+ const existingPaths = new Set(((_a = existingDomain.Routes) === null || _a === void 0 ? void 0 : _a.map((r) => r.Path)) || []);
462333
+ const duplicatePaths = [];
462334
+ routeData.routes.forEach((route) => {
462335
+ if (existingPaths.has(route.path)) {
462336
+ duplicatePaths.push(route.path);
462337
+ }
462338
+ });
462339
+ if (duplicatePaths.length > 0) {
462340
+ throw new error_1.CloudBaseError({
462341
+ message: (0, i18n_1.t)('域名 [{{domain}}] 下以下路径已存在: {{paths}}', {
462342
+ domain: routeData.domain,
462343
+ paths: duplicatePaths.join(', ')
462344
+ }),
462345
+ code: 'INVALID_PARAM',
462346
+ solution: [(0, i18n_1.t)('请勿在同一域名下使用重复路由')],
462347
+ });
462348
+ }
462349
+ }
462350
+ const routeCount = routeData.routes.length;
462351
+ let confirmMessage = (0, i18n_1.t)('确认创建以下 HTTP 服务路由?\n\n域名: {{domain}}\n路由数量: {{count}}', {
462352
+ domain: routeData.domain,
462353
+ count: routeCount
462354
+ });
462355
+ routeData.routes.forEach((route, index) => {
462356
+ confirmMessage += (0, i18n_1.t)('\n\n路由 {{index}}:', { index: index + 1 });
462357
+ confirmMessage += (0, i18n_1.t)('\n 路径: {{path}}', { path: route.path });
462358
+ confirmMessage += (0, i18n_1.t)('\n 上游类型: {{type}}', { type: route.upstreamResourceType });
462359
+ confirmMessage += (0, i18n_1.t)('\n 上游服务: {{name}}', { name: route.upstreamResourceName });
462360
+ if (route.enableAuth !== undefined) {
462361
+ confirmMessage += (0, i18n_1.t)('\n 身份认证: {{auth}}', { auth: route.enableAuth ? '开启' : '关闭' });
462362
+ }
462363
+ if (route.enableSafeDomain !== undefined) {
462364
+ confirmMessage += (0, i18n_1.t)('\n 安全域名: {{safe}}', { safe: route.enableSafeDomain ? '开启' : '关闭' });
462365
+ }
462366
+ });
462367
+ const confirm = yield (0, interactive_1.autoConfirm)(confirmMessage, true);
462368
+ if (!confirm) {
462369
+ throw new error_1.CloudBaseError({
462370
+ message: (0, i18n_1.t)('操作已取消'),
462371
+ code: 'USER_CANCEL'
462372
+ });
462373
+ }
462374
+ const domainParam = {
462375
+ Domain: routeData.domain,
462376
+ Routes: routeData.routes.map((route) => (Object.assign(Object.assign({ Path: route.path, UpstreamResourceType: route.upstreamResourceType, UpstreamResourceName: route.upstreamResourceName, Enable: route.enable !== undefined ? route.enable : true, EnableAuth: route.enableAuth !== undefined ? route.enableAuth : false, EnableSafeDomain: route.enableSafeDomain !== undefined ? route.enableSafeDomain : true, EnablePathTransmission: route.enablePathTransmission !== undefined ? route.enablePathTransmission : false }, (route.pathRewrite && { PathRewrite: route.pathRewrite })), (route.qpsPolicy && { QPSPolicy: route.qpsPolicy }))))
462377
+ };
462378
+ if (routeData.accessType)
462379
+ domainParam.AccessType = routeData.accessType;
462380
+ if (routeData.certId)
462381
+ domainParam.CertId = routeData.certId;
462382
+ if (routeData.protocol)
462383
+ domainParam.Protocol = routeData.protocol;
462384
+ if (routeData.customCname)
462385
+ domainParam.CustomCname = routeData.customCname;
462386
+ if (routeData.enable !== undefined)
462387
+ domainParam.Enable = routeData.enable;
462388
+ log.verbose('创建路由参数:', domainParam);
462389
+ try {
462390
+ yield (0, routes_1.createHTTPServiceRoute)({
462391
+ envId,
462392
+ domain: domainParam
462393
+ });
462394
+ }
462395
+ catch (e) {
462396
+ throw new error_1.CloudBaseError({
462397
+ message: e.message || (0, i18n_1.t)('创建路由失败'),
462398
+ code: 'API_ERROR',
462399
+ solution: [(0, i18n_1.t)('请检查路由配置是否正确')],
462400
+ original: e
462401
+ });
462402
+ }
462403
+ if ((0, utils_1.isJsonOutput)()) {
462404
+ (0, utils_1.outputJson)({
462405
+ domain: routeData.domain,
462406
+ routeCount,
462407
+ message: (0, i18n_1.t)('成功创建 HTTP 服务路由')
462408
+ });
462409
+ return;
462410
+ }
462411
+ log.success((0, i18n_1.t)('成功创建域名 [{{domain}}] 的 {{count}} 个路由', {
462412
+ domain: routeData.domain,
462413
+ count: routeCount
462414
+ }));
462415
+ });
462416
+ }
462417
+ };
462418
+ __decorate([
462419
+ (0, decorators_1.InjectParams)(),
462420
+ __param(0, (0, decorators_1.EnvId)()),
462421
+ __param(1, (0, decorators_1.ArgsOptions)()),
462422
+ __param(2, (0, decorators_1.Log)()),
462423
+ __metadata("design:type", Function),
462424
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
462425
+ __metadata("design:returntype", Promise)
462426
+ ], AddRoutesCommand.prototype, "execute", null);
462427
+ AddRoutesCommand = __decorate([
462428
+ (0, common_1.ICommand)()
462429
+ ], AddRoutesCommand);
462430
+ exports.AddRoutesCommand = AddRoutesCommand;
462431
+
462432
+
461625
462433
  /***/ }),
461626
462434
 
461627
462435
  /***/ 25835:
@@ -466838,6 +467646,203 @@ ZipArchiveOutputStream.prototype.setComment = function(comment) {
466838
467646
  };
466839
467647
 
466840
467648
 
467649
+ /***/ }),
467650
+
467651
+ /***/ 26957:
467652
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
467653
+
467654
+ "use strict";
467655
+
467656
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
467657
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
467658
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
467659
+ 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;
467660
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
467661
+ };
467662
+ var __metadata = (this && this.__metadata) || function (k, v) {
467663
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
467664
+ };
467665
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
467666
+ return function (target, key) { decorator(target, key, paramIndex); }
467667
+ };
467668
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
467669
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
467670
+ return new (P || (P = Promise))(function (resolve, reject) {
467671
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
467672
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
467673
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
467674
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
467675
+ });
467676
+ };
467677
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
467678
+ exports.AddDomainsCommand = void 0;
467679
+ const error_1 = __webpack_require__(66759);
467680
+ const interactive_1 = __webpack_require__(57695);
467681
+ const common_1 = __webpack_require__(48431);
467682
+ const utils_1 = __webpack_require__(82079);
467683
+ const decorators_1 = __webpack_require__(93480);
467684
+ const domains_1 = __webpack_require__(17375);
467685
+ const i18n_1 = __webpack_require__(69258);
467686
+ let AddDomainsCommand = class AddDomainsCommand extends common_1.Command {
467687
+ get options() {
467688
+ return {
467689
+ cmd: 'domains',
467690
+ childCmd: 'add <domain>',
467691
+ options: [
467692
+ {
467693
+ flags: '--certid <certId>',
467694
+ desc: (0, i18n_1.t)('SSL 证书 ID(必填)。在腾讯云 SSL 证书控制台获取')
467695
+ },
467696
+ {
467697
+ flags: '--access-type <accessType>',
467698
+ desc: (0, i18n_1.t)('绑定类型:DIRECT(直连,默认)、CDN(接入云开发 CDN)、CUSTOM(自定义接入)'),
467699
+ choices: ['DIRECT', 'CDN', 'CUSTOM'],
467700
+ default: 'DIRECT'
467701
+ },
467702
+ {
467703
+ flags: '--custom-cname <customCname>',
467704
+ desc: (0, i18n_1.t)('自定义 CNAME。当 access-type 为 CUSTOM 时使用')
467705
+ },
467706
+ {
467707
+ flags: '--disable',
467708
+ desc: (0, i18n_1.t)('绑定后禁用域名(默认启用)')
467709
+ }
467710
+ ],
467711
+ desc: (0, i18n_1.t)('绑定自定义域名到 HTTP 访问服务。需要域名已完成 ICP 备案,并提供有效的 SSL 证书'),
467712
+ examples: [
467713
+ 'tcb domains add api.example.com --certid abc123 -e envId',
467714
+ 'tcb domains add api.example.com --certid abc123 --access-type CDN -e envId',
467715
+ 'tcb domains add api.example.com --certid abc123 --access-type CUSTOM --custom-cname origin.example.com -e envId'
467716
+ ]
467717
+ };
467718
+ }
467719
+ execute(params, envId, options, log) {
467720
+ var _a;
467721
+ return __awaiter(this, void 0, void 0, function* () {
467722
+ log.verbose(params, options);
467723
+ const domain = params === null || params === void 0 ? void 0 : params[0];
467724
+ if (!domain) {
467725
+ throw new error_1.CloudBaseError({
467726
+ message: (0, i18n_1.t)('请提供要绑定的域名'),
467727
+ code: 'INVALID_PARAM',
467728
+ solution: [(0, i18n_1.t)('请在命令后面添加要绑定的域名,例如: tcb domains add api.example.com --certid xxx -e <envId>')]
467729
+ });
467730
+ }
467731
+ if (!options.certid) {
467732
+ throw new error_1.CloudBaseError({
467733
+ message: (0, i18n_1.t)('请提供 SSL 证书 ID,使用 --certid 参数'),
467734
+ code: 'INVALID_PARAM',
467735
+ solution: [
467736
+ (0, i18n_1.t)('请在腾讯云 SSL 证书控制台获取证书 ID'),
467737
+ (0, i18n_1.t)('使用 --certid <certId> 参数传入')
467738
+ ]
467739
+ });
467740
+ }
467741
+ const validAccessTypes = ['DIRECT', 'CDN', 'CUSTOM'];
467742
+ const accessType = ((_a = options.accessType) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || 'DIRECT';
467743
+ if (!validAccessTypes.includes(accessType)) {
467744
+ throw new error_1.CloudBaseError({
467745
+ message: (0, i18n_1.t)('无效的绑定类型: {{type}}。支持的类型: DIRECT, CDN, CUSTOM', { type: accessType }),
467746
+ code: 'INVALID_PARAM',
467747
+ solution: [(0, i18n_1.t)('请使用 --access-type DIRECT|CDN|CUSTOM')]
467748
+ });
467749
+ }
467750
+ if (accessType === 'CUSTOM' && !options.customCname) {
467751
+ throw new error_1.CloudBaseError({
467752
+ message: (0, i18n_1.t)('当绑定类型为 CUSTOM 时,必须提供 --custom-cname 参数'),
467753
+ code: 'INVALID_PARAM',
467754
+ solution: [(0, i18n_1.t)('请使用 --custom-cname <cname> 参数提供自定义 CNAME')]
467755
+ });
467756
+ }
467757
+ let existingDomains = [];
467758
+ try {
467759
+ const result = yield (0, domains_1.getCustomDomains)({ envId });
467760
+ existingDomains = result.domains;
467761
+ }
467762
+ catch (e) {
467763
+ throw new error_1.CloudBaseError({
467764
+ message: e.message || (0, i18n_1.t)('获取域名列表失败'),
467765
+ code: 'API_ERROR',
467766
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
467767
+ original: e
467768
+ });
467769
+ }
467770
+ const existingDomain = existingDomains.find((d) => d.Domain === domain);
467771
+ if (existingDomain) {
467772
+ throw new error_1.CloudBaseError({
467773
+ message: (0, i18n_1.t)('域名 [{{domain}}] 已存在!', { domain }),
467774
+ code: 'INVALID_PARAM',
467775
+ solution: [
467776
+ (0, i18n_1.t)('如需重新配置,请先删除已存在的域名'),
467777
+ (0, i18n_1.t)('使用 tcb domains rm {{domain}} -e <envId> 删除后重试', { domain })
467778
+ ]
467779
+ });
467780
+ }
467781
+ let confirmMessage = (0, i18n_1.t)('确认绑定以下自定义域名?\n\n域名: {{domain}}\n证书 ID: {{certId}}\n绑定类型: {{accessType}}', {
467782
+ domain,
467783
+ certId: options.certid,
467784
+ accessType
467785
+ });
467786
+ if (accessType === 'CUSTOM' && options.customCname) {
467787
+ confirmMessage += (0, i18n_1.t)('\n自定义 CNAME: {{cname}}', { cname: options.customCname });
467788
+ }
467789
+ confirmMessage += (0, i18n_1.t)('\n启用状态: {{enable}}', { enable: options.disable ? '禁用' : '启用' });
467790
+ const confirm = yield (0, interactive_1.autoConfirm)(confirmMessage, true);
467791
+ if (!confirm) {
467792
+ throw new error_1.CloudBaseError({
467793
+ message: (0, i18n_1.t)('操作已取消'),
467794
+ code: 'USER_CANCEL'
467795
+ });
467796
+ }
467797
+ try {
467798
+ yield (0, domains_1.bindCustomDomain)({
467799
+ envId,
467800
+ domain,
467801
+ certId: options.certid,
467802
+ accessType: accessType,
467803
+ enable: !options.disable,
467804
+ customCname: options.customCname
467805
+ });
467806
+ }
467807
+ catch (e) {
467808
+ throw new error_1.CloudBaseError({
467809
+ message: e.message || (0, i18n_1.t)('绑定域名失败'),
467810
+ code: 'API_ERROR',
467811
+ solution: [(0, i18n_1.t)('请检查域名配置是否正确,证书是否有效')],
467812
+ original: e
467813
+ });
467814
+ }
467815
+ if ((0, utils_1.isJsonOutput)()) {
467816
+ (0, utils_1.outputJson)({
467817
+ domain,
467818
+ certId: options.certid,
467819
+ accessType,
467820
+ enable: !options.disable,
467821
+ message: (0, i18n_1.t)('绑定自定义域名成功')
467822
+ });
467823
+ return;
467824
+ }
467825
+ log.success((0, i18n_1.t)('成功绑定自定义域名 [{{domain}}]', { domain }));
467826
+ log.info((0, i18n_1.t)('请将域名 DNS 解析配置 CNAME 记录指向您的 CloudBase 环境域名'));
467827
+ });
467828
+ }
467829
+ };
467830
+ __decorate([
467831
+ (0, decorators_1.InjectParams)(),
467832
+ __param(0, (0, decorators_1.ArgsParams)()),
467833
+ __param(1, (0, decorators_1.EnvId)()),
467834
+ __param(2, (0, decorators_1.ArgsOptions)()),
467835
+ __param(3, (0, decorators_1.Log)()),
467836
+ __metadata("design:type", Function),
467837
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
467838
+ __metadata("design:returntype", Promise)
467839
+ ], AddDomainsCommand.prototype, "execute", null);
467840
+ AddDomainsCommand = __decorate([
467841
+ (0, common_1.ICommand)()
467842
+ ], AddDomainsCommand);
467843
+ exports.AddDomainsCommand = AddDomainsCommand;
467844
+
467845
+
466841
467846
  /***/ }),
466842
467847
 
466843
467848
  /***/ 27019:
@@ -470370,6 +471375,100 @@ class EnvService {
470370
471375
  async describeCreditsUsageDetail(params) {
470371
471376
  return this.cloudService.request('DescribeCreditsUsageDetail', Object.assign({}, params));
470372
471377
  }
471378
+ /**
471379
+ * 查询HTTP访问服务域名路由信息
471380
+ * @param {DescribeHttpServiceRouteParams} params 查询参数
471381
+ * @returns {Promise<DescribeHttpServiceRouteRes>}
471382
+ */
471383
+ async describeHttpServiceRoute(params) {
471384
+ return this.cloudService.request('DescribeHTTPServiceRoute', Object.assign({}, params));
471385
+ }
471386
+ /**
471387
+ * 创建HTTP访问服务域名路由
471388
+ * @param {CreateHttpServiceRouteParams} params 创建参数
471389
+ * @returns {Promise<CreateHttpServiceRouteRes>}
471390
+ */
471391
+ async createHttpServiceRoute(params) {
471392
+ return this.cloudService.request('CreateHTTPServiceRoute', Object.assign({}, params));
471393
+ }
471394
+ /**
471395
+ * 修改HTTP访问服务域名路由
471396
+ * @param {ModifyHttpServiceRouteParams} params 修改参数
471397
+ * @returns {Promise<ModifyHttpServiceRouteRes>}
471398
+ */
471399
+ async modifyHttpServiceRoute(params) {
471400
+ return this.cloudService.request('ModifyHTTPServiceRoute', Object.assign({}, params));
471401
+ }
471402
+ /**
471403
+ * 删除HTTP访问服务域名路由
471404
+ * @param {DeleteHttpServiceRouteParams} params 删除参数
471405
+ * @returns {Promise<DeleteHttpServiceRouteRes>}
471406
+ */
471407
+ async deleteHttpServiceRoute(params) {
471408
+ return this.cloudService.request('DeleteHTTPServiceRoute', Object.assign({}, params));
471409
+ }
471410
+ /**
471411
+ * 绑定自定义域名到HTTP访问服务
471412
+ * 底层调用 CreateHTTPServiceRoute API,专用于域名绑定场景
471413
+ * @param {BindCustomDomainParams} params 绑定参数
471414
+ * @returns {Promise<BindCustomDomainRes>}
471415
+ */
471416
+ async bindCustomDomain(params) {
471417
+ const { EnvId, Domain } = params;
471418
+ // 构建域名参数,设置默认值
471419
+ const domainParam = {
471420
+ Domain: Domain.Domain,
471421
+ CertId: Domain.CertId,
471422
+ AccessType: Domain.AccessType || 'DIRECT',
471423
+ Protocol: Domain.Protocol || 'HTTP_AND_HTTPS',
471424
+ Enable: Domain.Enable !== undefined ? Domain.Enable : true
471425
+ };
471426
+ // 自定义接入类型时需要传入 CustomCname
471427
+ if (domainParam.AccessType === 'CUSTOM' && Domain.CustomCname) {
471428
+ domainParam.CustomCname = Domain.CustomCname;
471429
+ }
471430
+ return this.cloudService.request('CreateHTTPServiceRoute', {
471431
+ EnvId,
471432
+ Domain: domainParam
471433
+ });
471434
+ }
471435
+ /**
471436
+ * 删除自定义域名
471437
+ * 仅当域名下无路由绑定时可删除,否则抛出错误
471438
+ * @param {DeleteCustomDomainParams} params 删除参数
471439
+ * @returns {Promise<DeleteCustomDomainRes>}
471440
+ */
471441
+ async deleteCustomDomain(params) {
471442
+ const { EnvId, Domain } = params;
471443
+ // 先查询域名下是否有路由绑定
471444
+ const queryRes = await this.describeHttpServiceRoute({
471445
+ EnvId,
471446
+ Filters: [
471447
+ {
471448
+ Name: 'Domain',
471449
+ Values: [Domain]
471450
+ }
471451
+ ],
471452
+ Limit: 1
471453
+ });
471454
+ // 检查域名是否存在
471455
+ const domains = queryRes.Domains || [];
471456
+ const targetDomain = domains.find(d => d.Domain === Domain);
471457
+ if (!targetDomain) {
471458
+ throw new error_1.CloudBaseError(`域名 ${Domain} 不存在`);
471459
+ }
471460
+ // 检查域名下是否有路由绑定
471461
+ const routes = targetDomain.Routes || [];
471462
+ if (routes.length > 0) {
471463
+ const routePaths = routes.map(r => r.Path).join(', ');
471464
+ throw new error_1.CloudBaseError(`域名 ${Domain} 下还有 ${routes.length} 个路由绑定(${routePaths}),请先删除路由后再删除域名`);
471465
+ }
471466
+ // 无路由绑定,可以删除域名
471467
+ return this.cloudService.request('DeleteHTTPServiceRoute', {
471468
+ EnvId,
471469
+ Domain
471470
+ });
471471
+ }
470373
471472
  // 获取 COS CORS 域名
470374
471473
  async getCOSDomains() {
470375
471474
  const cos = this.getCos();
@@ -478484,20 +479583,14 @@ module.exports = convert;
478484
479583
  "use strict";
478485
479584
 
478486
479585
  Object.defineProperty(exports, "__esModule", ({ value: true }));
478487
- exports.jsonOutput = exports.tablesOption = exports.filtersOption = exports.timeOption = exports.yesOption = exports.jsonOption = exports.databaseNameOption = exports.instanceIdOption = exports.tagOption = void 0;
479586
+ exports.tablesOption = exports.filtersOption = exports.timeOption = exports.databaseNameOption = exports.instanceIdOption = exports.tagOption = void 0;
478488
479587
  const i18n_1 = __webpack_require__(69258);
478489
479588
  exports.tagOption = { flags: '--tag <tag>', desc: (0, i18n_1.t)('Mongo 实例 Tag(用于区分同环境下的多个实例)') };
478490
- exports.instanceIdOption = { flags: '--instanceId <instanceId>', desc: (0, i18n_1.t)('MongoConnector 实例 ID') };
478491
- exports.databaseNameOption = { flags: '--databaseName <databaseName>', desc: (0, i18n_1.t)('MongoConnector 数据库名') };
478492
- exports.jsonOption = { flags: '--json', desc: (0, i18n_1.t)('以 JSON 格式输出结果') };
478493
- exports.yesOption = { flags: '-y, --yes', desc: (0, i18n_1.t)('跳过确认提示,直接执行') };
479589
+ exports.instanceIdOption = { flags: '--instance-id <instanceId>', desc: (0, i18n_1.t)('MongoConnector 实例 ID') };
479590
+ exports.databaseNameOption = { flags: '--database-name <databaseName>', desc: (0, i18n_1.t)('MongoConnector 数据库名') };
478494
479591
  exports.timeOption = { flags: '--time <time>', desc: (0, i18n_1.t)('回档时间') };
478495
479592
  exports.filtersOption = { flags: '--filters <filters>', desc: (0, i18n_1.t)('过滤条件(逗号分隔的集合名列表)') };
478496
479593
  exports.tablesOption = { flags: '--tables <tables>', desc: (0, i18n_1.t)('回档表格映射(JSON 字符串),格式: \'[{"OldTableName":"原集合名","NewTableName":"新集合名"}]\'') };
478497
- function jsonOutput(result) {
478498
- console.log(JSON.stringify(result, null, 2));
478499
- }
478500
- exports.jsonOutput = jsonOutput;
478501
479594
 
478502
479595
 
478503
479596
  /***/ }),
@@ -489424,6 +490517,34 @@ function baseValues(object, props) {
489424
490517
  module.exports = baseValues;
489425
490518
 
489426
490519
 
490520
+ /***/ }),
490521
+
490522
+ /***/ 30527:
490523
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
490524
+
490525
+ "use strict";
490526
+
490527
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
490528
+ if (k2 === undefined) k2 = k;
490529
+ var desc = Object.getOwnPropertyDescriptor(m, k);
490530
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
490531
+ desc = { enumerable: true, get: function() { return m[k]; } };
490532
+ }
490533
+ Object.defineProperty(o, k2, desc);
490534
+ }) : (function(o, m, k, k2) {
490535
+ if (k2 === undefined) k2 = k;
490536
+ o[k2] = m[k];
490537
+ }));
490538
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
490539
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
490540
+ };
490541
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
490542
+ __exportStar(__webpack_require__(46291), exports);
490543
+ __exportStar(__webpack_require__(84876), exports);
490544
+ __exportStar(__webpack_require__(25812), exports);
490545
+ __exportStar(__webpack_require__(871), exports);
490546
+
490547
+
489427
490548
  /***/ }),
489428
490549
 
489429
490550
  /***/ 30578:
@@ -498349,26 +499470,23 @@ const common_1 = __webpack_require__(48431);
498349
499470
  const deep_command_1 = __webpack_require__(81752);
498350
499471
  const decorators_1 = __webpack_require__(93480);
498351
499472
  const utils_1 = __webpack_require__(82079);
498352
- const utils_2 = __webpack_require__(75213);
498353
499473
  const mysql_1 = __webpack_require__(69116);
498354
499474
  const common_2 = __webpack_require__(79101);
499475
+ const common_3 = __webpack_require__(8906);
499476
+ const error_1 = __webpack_require__(66759);
498355
499477
  const inquirer_1 = __importDefault(__webpack_require__(6403));
498356
499478
  const i18n_1 = __webpack_require__(69258);
498357
499479
  function resolveEnvAndInstance(envId, instanceId, isJson) {
498358
499480
  return __awaiter(this, void 0, void 0, function* () {
498359
- let selectedEnvId = envId;
498360
- if (!selectedEnvId) {
498361
- if (isJson) {
498362
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
498363
- return null;
498364
- }
498365
- selectedEnvId = yield (0, utils_2.selectEnv)();
498366
- }
499481
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
498367
499482
  let selectedInstanceId = instanceId;
498368
499483
  if (!selectedInstanceId) {
498369
499484
  if (isJson) {
498370
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --instanceId 指定实例') });
498371
- return null;
499485
+ throw new error_1.CloudBaseError({
499486
+ message: (0, i18n_1.t)('请通过 --instance-id 指定实例'),
499487
+ code: 'MISSING_PARAM',
499488
+ solution: [(0, i18n_1.t)('使用 --instance-id 指定实例')]
499489
+ });
498372
499490
  }
498373
499491
  selectedInstanceId = yield (0, common_2.selectInstance)(selectedEnvId);
498374
499492
  }
@@ -498424,66 +499542,55 @@ let InstanceConfigGetCommand = class InstanceConfigGetCommand extends deep_comma
498424
499542
  childSubCmd: 'config',
498425
499543
  childChildSubCmd: 'get',
498426
499544
  options: [
498427
- common_2.instanceIdOption,
498428
- common_2.jsonOption
499545
+ common_2.instanceIdOption
498429
499546
  ],
498430
499547
  desc: (0, i18n_1.t)('查询 MySQL 实例配置'),
498431
499548
  requiredEnvId: false,
498432
499549
  autoRunLogin: true
498433
499550
  };
498434
499551
  }
498435
- execute(envId, options, log) {
499552
+ execute(ctx, envId, options, log) {
499553
+ var _a;
498436
499554
  return __awaiter(this, void 0, void 0, function* () {
498437
- const isJson = options.json;
499555
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
498438
499556
  const resolved = yield resolveEnvAndInstance(envId, options.instanceId, isJson);
498439
- if (!resolved)
498440
- return;
498441
499557
  const loading = (0, utils_1.loadingFactory)();
498442
- try {
498443
- loading.start((0, i18n_1.t)('获取实例配置中...'));
498444
- const result = yield (0, mysql_1.describeInstanceDetail)({
498445
- envId: resolved.envId,
498446
- instanceId: resolved.instanceId
498447
- });
498448
- loading.stop();
498449
- const detail = result.Detail || {};
498450
- if (isJson) {
498451
- (0, common_2.jsonOutput)({ code: 0, data: detail });
498452
- return;
498453
- }
498454
- const head = [(0, i18n_1.t)('字段'), (0, i18n_1.t)('值')];
498455
- const tableData = [
498456
- [(0, i18n_1.t)('实例 ID'), detail.InstanceId || '-'],
498457
- [(0, i18n_1.t)('名称'), detail.InstanceName || '-'],
498458
- [(0, i18n_1.t)('状态'), detail.StatusDesc || detail.Status || '-'],
498459
- [(0, i18n_1.t)('CPU'), `${detail.Cpu || '-'} ${(0, i18n_1.t)('核')}`],
498460
- [(0, i18n_1.t)('内存'), `${detail.Memory || '-'} GB`],
498461
- [(0, i18n_1.t)('存储'), `${detail.Storage || '-'} GB`],
498462
- [(0, i18n_1.t)('内网地址'), detail.Vip ? `${detail.Vip}:${detail.Vport}` : '-'],
498463
- [(0, i18n_1.t)('集群 ID'), detail.ClusterId || '-'],
498464
- [(0, i18n_1.t)('地域'), detail.Region || '-'],
498465
- [(0, i18n_1.t)('可用区'), detail.Zone || '-']
498466
- ];
498467
- (0, utils_1.printHorizontalTable)(head, tableData);
498468
- }
498469
- catch (e) {
498470
- loading.stop();
498471
- if (isJson) {
498472
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
498473
- return;
498474
- }
498475
- throw e;
499558
+ loading.start((0, i18n_1.t)('获取实例配置中...'));
499559
+ const result = yield (0, mysql_1.describeInstanceDetail)({
499560
+ envId: resolved.envId,
499561
+ instanceId: resolved.instanceId
499562
+ });
499563
+ loading.stop();
499564
+ const detail = result.Detail || {};
499565
+ if (isJson) {
499566
+ (0, utils_1.outputJson)(detail);
499567
+ return;
498476
499568
  }
499569
+ const head = [(0, i18n_1.t)('字段'), (0, i18n_1.t)('值')];
499570
+ const tableData = [
499571
+ [(0, i18n_1.t)('实例 ID'), detail.InstanceId || '-'],
499572
+ [(0, i18n_1.t)('名称'), detail.InstanceName || '-'],
499573
+ [(0, i18n_1.t)('状态'), detail.StatusDesc || detail.Status || '-'],
499574
+ [(0, i18n_1.t)('CPU'), `${detail.Cpu || '-'} ${(0, i18n_1.t)('核')}`],
499575
+ [(0, i18n_1.t)('内存'), `${detail.Memory || '-'} GB`],
499576
+ [(0, i18n_1.t)('存储'), `${detail.Storage || '-'} GB`],
499577
+ [(0, i18n_1.t)('内网地址'), detail.Vip ? `${detail.Vip}:${detail.Vport}` : '-'],
499578
+ [(0, i18n_1.t)('集群 ID'), detail.ClusterId || '-'],
499579
+ [(0, i18n_1.t)('地域'), detail.Region || '-'],
499580
+ [(0, i18n_1.t)('可用区'), detail.Zone || '-']
499581
+ ];
499582
+ (0, utils_1.printHorizontalTable)(head, tableData);
498477
499583
  });
498478
499584
  }
498479
499585
  };
498480
499586
  __decorate([
498481
499587
  (0, decorators_1.InjectParams)(),
498482
- __param(0, (0, decorators_1.EnvId)()),
498483
- __param(1, (0, decorators_1.ArgsOptions)()),
498484
- __param(2, (0, decorators_1.Log)()),
499588
+ __param(0, (0, decorators_1.CmdContext)()),
499589
+ __param(1, (0, decorators_1.EnvId)()),
499590
+ __param(2, (0, decorators_1.ArgsOptions)()),
499591
+ __param(3, (0, decorators_1.Log)()),
498485
499592
  __metadata("design:type", Function),
498486
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
499593
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
498487
499594
  __metadata("design:returntype", Promise)
498488
499595
  ], InstanceConfigGetCommand.prototype, "execute", null);
498489
499596
  InstanceConfigGetCommand = __decorate([
@@ -498500,35 +499607,35 @@ let InstanceConfigSetCommand = class InstanceConfigSetCommand extends deep_comma
498500
499607
  options: [
498501
499608
  common_2.instanceIdOption,
498502
499609
  { flags: '--cpu <cpu>', desc: (0, i18n_1.t)('CPU 核数(可选 1/2/4/8/16)') },
498503
- { flags: '--memory <memory>', desc: (0, i18n_1.t)('内存大小 GB(可选 2/4/8/16/32/64/128)') },
498504
- common_2.yesOption,
498505
- common_2.jsonOption
499610
+ { flags: '--memory <memory>', desc: (0, i18n_1.t)('内存大小 GB(可选 2/4/8/16/32/64/128)') }
498506
499611
  ],
498507
499612
  desc: (0, i18n_1.t)('修改 MySQL 实例配置(变配)'),
498508
499613
  requiredEnvId: false,
498509
499614
  autoRunLogin: true
498510
499615
  };
498511
499616
  }
498512
- execute(envId, options, log) {
499617
+ execute(ctx, envId, options, log) {
499618
+ var _a, _b;
498513
499619
  return __awaiter(this, void 0, void 0, function* () {
498514
- const isJson = options.json;
499620
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
498515
499621
  const resolved = yield resolveEnvAndInstance(envId, options.instanceId, isJson);
498516
- if (!resolved)
498517
- return;
498518
499622
  const cpu = Number(options.cpu);
498519
499623
  const memory = Number(options.memory);
498520
499624
  if (!cpu || !memory) {
498521
- if (isJson) {
498522
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请指定 --cpu 和 --memory 参数') });
498523
- return;
498524
- }
498525
- log.error((0, i18n_1.t)('请指定 --cpu 和 --memory 参数'));
498526
- return;
499625
+ throw new error_1.CloudBaseError({
499626
+ message: (0, i18n_1.t)('请指定 --cpu 和 --memory 参数'),
499627
+ code: 'MISSING_PARAM',
499628
+ solution: [(0, i18n_1.t)('使用 --cpu 和 --memory 指定目标配置,如 --cpu 2 --memory 4')]
499629
+ });
498527
499630
  }
498528
- if (!options.yes) {
499631
+ const yes = (_b = ctx.globalOptions) === null || _b === void 0 ? void 0 : _b.yes;
499632
+ if (!yes) {
498529
499633
  if (isJson) {
498530
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--json 模式下需要配合 --yes 跳过确认') });
498531
- return;
499634
+ throw new error_1.CloudBaseError({
499635
+ message: (0, i18n_1.t)('--json 模式下需要配合 --yes 跳过确认'),
499636
+ code: 'MISSING_PARAM',
499637
+ solution: [(0, i18n_1.t)('添加 --yes 参数跳过确认')]
499638
+ });
498532
499639
  }
498533
499640
  const confirmed = yield confirmUpgrade(resolved.envId, resolved.instanceId, cpu, memory);
498534
499641
  if (!confirmed) {
@@ -498537,52 +499644,43 @@ let InstanceConfigSetCommand = class InstanceConfigSetCommand extends deep_comma
498537
499644
  }
498538
499645
  }
498539
499646
  const loading = (0, utils_1.loadingFactory)();
498540
- try {
498541
- loading.start((0, i18n_1.t)('正在变更实例配置...'));
498542
- const result = yield (0, mysql_1.upgradeInstance)({
498543
- envId: resolved.envId,
498544
- instanceId: resolved.instanceId,
498545
- cpu,
498546
- memory
498547
- });
498548
- loading.stop();
498549
- if (isJson) {
498550
- const data = {};
498551
- if (result.TranId) {
498552
- data.tranId = result.TranId;
498553
- }
498554
- if (result.DealNames && result.DealNames.length > 0) {
498555
- data.dealNames = result.DealNames;
498556
- }
498557
- (0, common_2.jsonOutput)({ code: 0, data });
498558
- return;
498559
- }
498560
- log.success((0, i18n_1.t)('变配操作已提交'));
499647
+ loading.start((0, i18n_1.t)('正在变更实例配置...'));
499648
+ const result = yield (0, mysql_1.upgradeInstance)({
499649
+ envId: resolved.envId,
499650
+ instanceId: resolved.instanceId,
499651
+ cpu,
499652
+ memory
499653
+ });
499654
+ loading.stop();
499655
+ if (isJson) {
499656
+ const data = {};
498561
499657
  if (result.TranId) {
498562
- log.info((0, i18n_1.t)('交易 ID: {{tranId}}', { tranId: result.TranId }));
499658
+ data.tranId = result.TranId;
498563
499659
  }
498564
499660
  if (result.DealNames && result.DealNames.length > 0) {
498565
- log.info((0, i18n_1.t)('订单号: {{dealNames}}', { dealNames: result.DealNames.join(', ') }));
499661
+ data.dealNames = result.DealNames;
498566
499662
  }
499663
+ (0, utils_1.outputJson)(data);
499664
+ return;
498567
499665
  }
498568
- catch (e) {
498569
- loading.stop();
498570
- if (isJson) {
498571
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
498572
- return;
498573
- }
498574
- throw e;
499666
+ log.success((0, i18n_1.t)('变配操作已提交'));
499667
+ if (result.TranId) {
499668
+ log.info((0, i18n_1.t)('交易 ID: {{tranId}}', { tranId: result.TranId }));
499669
+ }
499670
+ if (result.DealNames && result.DealNames.length > 0) {
499671
+ log.info((0, i18n_1.t)('订单号: {{dealNames}}', { dealNames: result.DealNames.join(', ') }));
498575
499672
  }
498576
499673
  });
498577
499674
  }
498578
499675
  };
498579
499676
  __decorate([
498580
499677
  (0, decorators_1.InjectParams)(),
498581
- __param(0, (0, decorators_1.EnvId)()),
498582
- __param(1, (0, decorators_1.ArgsOptions)()),
498583
- __param(2, (0, decorators_1.Log)()),
499678
+ __param(0, (0, decorators_1.CmdContext)()),
499679
+ __param(1, (0, decorators_1.EnvId)()),
499680
+ __param(2, (0, decorators_1.ArgsOptions)()),
499681
+ __param(3, (0, decorators_1.Log)()),
498584
499682
  __metadata("design:type", Function),
498585
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
499683
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
498586
499684
  __metadata("design:returntype", Promise)
498587
499685
  ], InstanceConfigSetCommand.prototype, "execute", null);
498588
499686
  InstanceConfigSetCommand = __decorate([
@@ -500808,33 +501906,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
500808
501906
  step((generator = generator.apply(thisArg, _arguments || [])).next());
500809
501907
  });
500810
501908
  };
500811
- var __importDefault = (this && this.__importDefault) || function (mod) {
500812
- return (mod && mod.__esModule) ? mod : { "default": mod };
500813
- };
500814
501909
  Object.defineProperty(exports, "__esModule", ({ value: true }));
500815
501910
  exports.BackupTaskCommand = exports.NosqlBackupRestoreCommand = exports.BackupCollectionCommand = exports.BackupTimeCommand = void 0;
500816
501911
  const common_1 = __webpack_require__(48431);
500817
501912
  const deep_command_1 = __webpack_require__(81752);
500818
501913
  const decorators_1 = __webpack_require__(93480);
500819
501914
  const utils_1 = __webpack_require__(82079);
500820
- const utils_2 = __webpack_require__(75213);
500821
501915
  const nosql_1 = __webpack_require__(56547);
500822
501916
  const common_2 = __webpack_require__(28680);
500823
- const inquirer_1 = __importDefault(__webpack_require__(6403));
501917
+ const common_3 = __webpack_require__(8906);
501918
+ const error_1 = __webpack_require__(66759);
500824
501919
  const i18n_1 = __webpack_require__(69258);
500825
- function resolveEnv(envId, isJson) {
500826
- return __awaiter(this, void 0, void 0, function* () {
500827
- let selectedEnvId = envId;
500828
- if (!selectedEnvId) {
500829
- if (isJson) {
500830
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
500831
- return null;
500832
- }
500833
- selectedEnvId = yield (0, utils_2.selectEnv)();
500834
- }
500835
- return selectedEnvId;
500836
- });
500837
- }
500838
501920
  let BackupTimeCommand = class BackupTimeCommand extends deep_command_1.DeepCommand {
500839
501921
  get options() {
500840
501922
  return {
@@ -500843,79 +501925,65 @@ let BackupTimeCommand = class BackupTimeCommand extends deep_command_1.DeepComma
500843
501925
  childSubCmd: 'backup',
500844
501926
  childChildSubCmd: 'time',
500845
501927
  options: [
500846
- common_2.tagOption,
500847
- common_2.jsonOption
501928
+ common_2.tagOption
500848
501929
  ],
500849
501930
  desc: (0, i18n_1.t)('查询可回档时间'),
500850
501931
  requiredEnvId: false,
500851
501932
  autoRunLogin: true
500852
501933
  };
500853
501934
  }
500854
- execute(envId, options, log) {
501935
+ execute(ctx, envId, options, log) {
501936
+ var _a;
500855
501937
  return __awaiter(this, void 0, void 0, function* () {
500856
- const isJson = options.json;
500857
- const selectedEnvId = yield resolveEnv(envId, isJson);
500858
- if (!selectedEnvId)
500859
- return;
501938
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
501939
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
500860
501940
  const loading = (0, utils_1.loadingFactory)();
500861
- try {
500862
- loading.start((0, i18n_1.t)('查询可回档时间中...'));
500863
- const result = yield (0, nosql_1.describeRestoreTime)({
500864
- envId: selectedEnvId,
500865
- tag: options.tag
501941
+ loading.start((0, i18n_1.t)('查询可回档时间中...'));
501942
+ const result = yield (0, nosql_1.describeRestoreTime)({
501943
+ envId: selectedEnvId,
501944
+ tag: options.tag
501945
+ });
501946
+ loading.stop();
501947
+ const restoreTimes = result.RestoreTimes || [];
501948
+ const restoreTimeRanges = result.RestoreTimeRanges || [];
501949
+ if (isJson) {
501950
+ (0, utils_1.outputJson)({
501951
+ restoreTimes,
501952
+ restoreTimeRanges,
501953
+ requestId: result.RequestId
500866
501954
  });
500867
- loading.stop();
500868
- const restoreTimes = result.RestoreTimes || [];
500869
- const restoreTimeRanges = result.RestoreTimeRanges || [];
500870
- if (isJson) {
500871
- (0, common_2.jsonOutput)({
500872
- code: 0,
500873
- data: {
500874
- restoreTimes,
500875
- restoreTimeRanges,
500876
- requestId: result.RequestId
500877
- }
500878
- });
500879
- return;
500880
- }
500881
- if (restoreTimes.length === 0 && restoreTimeRanges.length === 0) {
500882
- log.info((0, i18n_1.t)('当前没有可回档时间'));
500883
- return;
500884
- }
500885
- if (restoreTimes.length > 0) {
500886
- log.info((0, i18n_1.t)('可回档时间列表:'));
500887
- const head = [(0, i18n_1.t)('可回档时间')];
500888
- const tableData = restoreTimes.map((time) => [time]);
500889
- (0, utils_1.printHorizontalTable)(head, tableData);
500890
- }
500891
- if (restoreTimeRanges.length > 0) {
500892
- log.info((0, i18n_1.t)('任意时间回档范围:'));
500893
- const head = [(0, i18n_1.t)('起始时间'), (0, i18n_1.t)('结束时间')];
500894
- const tableData = restoreTimeRanges.map((range) => [
500895
- range.StartTime || range.start || '-',
500896
- range.EndTime || range.end || '-'
500897
- ]);
500898
- (0, utils_1.printHorizontalTable)(head, tableData);
500899
- }
501955
+ return;
500900
501956
  }
500901
- catch (e) {
500902
- loading.stop();
500903
- if (isJson) {
500904
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
500905
- return;
500906
- }
500907
- throw e;
501957
+ if (restoreTimes.length === 0 && restoreTimeRanges.length === 0) {
501958
+ log.info((0, i18n_1.t)('当前没有可回档时间'));
501959
+ return;
501960
+ }
501961
+ if (restoreTimes.length > 0) {
501962
+ log.info((0, i18n_1.t)('可回档时间列表:'));
501963
+ const head = [(0, i18n_1.t)('可回档时间')];
501964
+ const tableData = restoreTimes.map((time) => [time]);
501965
+ (0, utils_1.printHorizontalTable)(head, tableData);
501966
+ }
501967
+ if (restoreTimeRanges.length > 0) {
501968
+ log.info((0, i18n_1.t)('任意时间回档范围:'));
501969
+ const head = [(0, i18n_1.t)('起始时间'), (0, i18n_1.t)('结束时间')];
501970
+ const tableData = restoreTimeRanges.map((range) => [
501971
+ range.StartTime || range.start || '-',
501972
+ range.EndTime || range.end || '-'
501973
+ ]);
501974
+ (0, utils_1.printHorizontalTable)(head, tableData);
500908
501975
  }
500909
501976
  });
500910
501977
  }
500911
501978
  };
500912
501979
  __decorate([
500913
501980
  (0, decorators_1.InjectParams)(),
500914
- __param(0, (0, decorators_1.EnvId)()),
500915
- __param(1, (0, decorators_1.ArgsOptions)()),
500916
- __param(2, (0, decorators_1.Log)()),
501981
+ __param(0, (0, decorators_1.CmdContext)()),
501982
+ __param(1, (0, decorators_1.EnvId)()),
501983
+ __param(2, (0, decorators_1.ArgsOptions)()),
501984
+ __param(3, (0, decorators_1.Log)()),
500917
501985
  __metadata("design:type", Function),
500918
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
501986
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
500919
501987
  __metadata("design:returntype", Promise)
500920
501988
  ], BackupTimeCommand.prototype, "execute", null);
500921
501989
  BackupTimeCommand = __decorate([
@@ -500932,79 +502000,64 @@ let BackupCollectionCommand = class BackupCollectionCommand extends deep_command
500932
502000
  options: [
500933
502001
  common_2.tagOption,
500934
502002
  common_2.timeOption,
500935
- common_2.filtersOption,
500936
- common_2.jsonOption
502003
+ common_2.filtersOption
500937
502004
  ],
500938
502005
  desc: (0, i18n_1.t)('获取可回档集合'),
500939
502006
  requiredEnvId: false,
500940
502007
  autoRunLogin: true
500941
502008
  };
500942
502009
  }
500943
- execute(envId, options, log) {
502010
+ execute(ctx, envId, options, log) {
502011
+ var _a;
500944
502012
  return __awaiter(this, void 0, void 0, function* () {
500945
- const isJson = options.json;
500946
- const selectedEnvId = yield resolveEnv(envId, isJson);
500947
- if (!selectedEnvId)
500948
- return;
502013
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
502014
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
500949
502015
  if (!options.time) {
500950
- if (isJson) {
500951
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --time 参数指定回档时间') });
500952
- return;
500953
- }
500954
- log.error((0, i18n_1.t)('请通过 --time 参数指定回档时间'));
500955
- return;
502016
+ throw new error_1.CloudBaseError({
502017
+ message: (0, i18n_1.t)('请通过 --time 参数指定回档时间'),
502018
+ code: 'MISSING_PARAM',
502019
+ solution: [(0, i18n_1.t)('运行 `tcb db nosql backup time` 查询可回档时间')]
502020
+ });
500956
502021
  }
500957
502022
  const filters = options.filters
500958
502023
  ? options.filters.split(',').map((f) => f.trim())
500959
502024
  : undefined;
500960
502025
  const loading = (0, utils_1.loadingFactory)();
500961
- try {
500962
- loading.start((0, i18n_1.t)('获取可回档集合中...'));
500963
- const result = yield (0, nosql_1.describeRestoreTables)({
500964
- envId: selectedEnvId,
500965
- tag: options.tag,
500966
- time: options.time,
500967
- filters
502026
+ loading.start((0, i18n_1.t)('获取可回档集合中...'));
502027
+ const result = yield (0, nosql_1.describeRestoreTables)({
502028
+ envId: selectedEnvId,
502029
+ tag: options.tag,
502030
+ time: options.time,
502031
+ filters
502032
+ });
502033
+ loading.stop();
502034
+ const tables = result.Tables || [];
502035
+ if (isJson) {
502036
+ (0, utils_1.outputJson)({
502037
+ tables,
502038
+ requestId: result.RequestId
500968
502039
  });
500969
- loading.stop();
500970
- const tables = result.Tables || [];
500971
- if (isJson) {
500972
- (0, common_2.jsonOutput)({
500973
- code: 0,
500974
- data: {
500975
- tables,
500976
- requestId: result.RequestId
500977
- }
500978
- });
500979
- return;
500980
- }
500981
- if (tables.length === 0) {
500982
- log.info((0, i18n_1.t)('当前没有可回档的集合'));
500983
- return;
500984
- }
500985
- log.info((0, i18n_1.t)('可回档集合列表:'));
500986
- const head = [(0, i18n_1.t)('集合名')];
500987
- const tableData = tables.map((table) => [table]);
500988
- (0, utils_1.printHorizontalTable)(head, tableData);
502040
+ return;
500989
502041
  }
500990
- catch (e) {
500991
- loading.stop();
500992
- if (isJson) {
500993
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
500994
- return;
500995
- }
500996
- throw e;
502042
+ if (tables.length === 0) {
502043
+ log.info((0, i18n_1.t)('当前没有可回档的集合'));
502044
+ return;
500997
502045
  }
502046
+ log.info((0, i18n_1.t)('可回档集合列表:'));
502047
+ const head = [(0, i18n_1.t)('集合名')];
502048
+ const tableData = tables.map((table) => [table]);
502049
+ (0, utils_1.printHorizontalTable)(head, tableData);
500998
502050
  });
500999
502051
  }
501000
502052
  };
501001
502053
  __decorate([
501002
502054
  (0, decorators_1.InjectParams)(),
501003
- __param(0, (0, decorators_1.EnvId)()),
501004
- __param(1, (0, decorators_1.ArgsOptions)()),
501005
- __param(2, (0, decorators_1.Log)()),
502055
+ __param(0, (0, decorators_1.CmdContext)()),
502056
+ __param(1, (0, decorators_1.EnvId)()),
502057
+ __param(2, (0, decorators_1.ArgsOptions)()),
502058
+ __param(3, (0, decorators_1.Log)()),
501006
502059
  __metadata("design:type", Function),
501007
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
502060
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
501008
502061
  __metadata("design:returntype", Promise)
501009
502062
  ], BackupCollectionCommand.prototype, "execute", null);
501010
502063
  BackupCollectionCommand = __decorate([
@@ -501021,123 +502074,89 @@ let NosqlBackupRestoreCommand = class NosqlBackupRestoreCommand extends deep_com
501021
502074
  options: [
501022
502075
  common_2.tagOption,
501023
502076
  common_2.timeOption,
501024
- common_2.tablesOption,
501025
- common_2.yesOption,
501026
- common_2.jsonOption
502077
+ common_2.tablesOption
501027
502078
  ],
501028
502079
  desc: (0, i18n_1.t)('实例表格回档'),
501029
502080
  requiredEnvId: false,
501030
502081
  autoRunLogin: true
501031
502082
  };
501032
502083
  }
501033
- execute(envId, options, log) {
502084
+ execute(ctx, envId, options, log) {
502085
+ var _a;
501034
502086
  return __awaiter(this, void 0, void 0, function* () {
501035
- const isJson = options.json;
501036
- const selectedEnvId = yield resolveEnv(envId, isJson);
501037
- if (!selectedEnvId)
501038
- return;
502087
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
502088
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
501039
502089
  if (!options.time) {
501040
- if (isJson) {
501041
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --time 参数指定回档时间') });
501042
- return;
501043
- }
501044
- log.error((0, i18n_1.t)('请通过 --time 参数指定回档时间'));
501045
- return;
502090
+ throw new error_1.CloudBaseError({
502091
+ message: (0, i18n_1.t)('请通过 --time 参数指定回档时间'),
502092
+ code: 'MISSING_PARAM',
502093
+ solution: [(0, i18n_1.t)('运行 `tcb db nosql backup time` 查询可回档时间')]
502094
+ });
501046
502095
  }
501047
502096
  if (!options.tables) {
501048
- if (isJson) {
501049
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --tables 参数指定回档表格映射 JSON') });
501050
- return;
501051
- }
501052
- log.error((0, i18n_1.t)('请通过 --tables 参数指定回档表格映射 JSON'));
501053
- log.info((0, i18n_1.t)('格式示例: --tables \'[{"OldTableName":"users","NewTableName":"users_backup"}]\''));
501054
- return;
502097
+ throw new error_1.CloudBaseError({
502098
+ message: (0, i18n_1.t)('请通过 --tables 参数指定回档表格映射 JSON'),
502099
+ code: 'MISSING_PARAM',
502100
+ solution: [(0, i18n_1.t)('格式示例: --tables \'[{"OldTableName":"users","NewTableName":"users_backup"}]\'')]
502101
+ });
501055
502102
  }
501056
502103
  let parsedTables;
501057
502104
  try {
501058
502105
  parsedTables = JSON.parse(options.tables);
501059
502106
  }
501060
502107
  catch (e) {
501061
- if (isJson) {
501062
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--tables JSON 解析失败: {{message}}', { message: e.message }) });
501063
- return;
501064
- }
501065
- log.error((0, i18n_1.t)('--tables JSON 解析失败: {{message}}', { message: e.message }));
501066
- log.info((0, i18n_1.t)('格式示例: --tables \'[{"OldTableName":"users","NewTableName":"users_backup"}]\''));
501067
- return;
502108
+ throw new error_1.CloudBaseError({
502109
+ message: (0, i18n_1.t)('--tables JSON 解析失败: {{message}}', { message: e.message }),
502110
+ code: 'INVALID_PARAM',
502111
+ solution: [(0, i18n_1.t)('格式示例: --tables \'[{"OldTableName":"users","NewTableName":"users_backup"}]\'')]
502112
+ });
501068
502113
  }
501069
502114
  if (!Array.isArray(parsedTables) || parsedTables.length === 0) {
501070
- if (isJson) {
501071
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--tables 应为非空的 JSON 数组') });
501072
- return;
501073
- }
501074
- log.error((0, i18n_1.t)('--tables 应为非空的 JSON 数组'));
501075
- log.info((0, i18n_1.t)('格式示例: --tables \'[{"OldTableName":"users","NewTableName":"users_backup"}]\''));
501076
- return;
502115
+ throw new error_1.CloudBaseError({
502116
+ message: (0, i18n_1.t)('--tables 应为非空的 JSON 数组'),
502117
+ code: 'INVALID_PARAM',
502118
+ solution: [(0, i18n_1.t)('格式示例: --tables \'[{"OldTableName":"users","NewTableName":"users_backup"}]\'')]
502119
+ });
501077
502120
  }
501078
- if (!options.yes) {
501079
- if (isJson) {
501080
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--json 模式下需要配合 --yes 跳过确认') });
501081
- return;
501082
- }
501083
- const tableList = parsedTables.map((item) => `${item.OldTableName} → ${item.NewTableName}`).join('\n ');
501084
- const { confirm } = yield inquirer_1.default.prompt([
501085
- {
501086
- type: 'confirm',
501087
- name: 'confirm',
501088
- message: (0, i18n_1.t)('确定要执行表格回档操作吗?回档将创建新表格,不会覆盖原始数据') +
501089
- `\n ${(0, i18n_1.t)('回档时间')}: ${options.time}\n ${tableList}`,
501090
- default: false
501091
- }
501092
- ]);
501093
- if (!confirm) {
501094
- log.info((0, i18n_1.t)('已取消操作'));
501095
- return;
501096
- }
502121
+ const tableList = parsedTables.map((item) => `${item.OldTableName} → ${item.NewTableName}`).join('\n ');
502122
+ const confirmMsg = (0, i18n_1.t)('确定要执行表格回档操作吗?回档将创建新表格,不会覆盖原始数据') +
502123
+ `\n ${(0, i18n_1.t)('回档时间')}: ${options.time}\n ${tableList}`;
502124
+ const confirmed = yield (0, utils_1.autoConfirm)(confirmMsg, false);
502125
+ if (!confirmed) {
502126
+ log.info((0, i18n_1.t)('已取消操作'));
502127
+ return;
501097
502128
  }
501098
502129
  const loading = (0, utils_1.loadingFactory)();
501099
- try {
501100
- loading.start((0, i18n_1.t)('正在执行表格回档...'));
501101
- const result = yield (0, nosql_1.restoreTables)({
501102
- envId: selectedEnvId,
501103
- tag: options.tag,
501104
- time: options.time,
501105
- tables: parsedTables
502130
+ loading.start((0, i18n_1.t)('正在执行表格回档...'));
502131
+ const result = yield (0, nosql_1.restoreTables)({
502132
+ envId: selectedEnvId,
502133
+ tag: options.tag,
502134
+ time: options.time,
502135
+ tables: parsedTables
502136
+ });
502137
+ loading.stop();
502138
+ if (isJson) {
502139
+ (0, utils_1.outputJson)({
502140
+ flowId: result.FlowId,
502141
+ requestId: result.RequestId
501106
502142
  });
501107
- loading.stop();
501108
- if (isJson) {
501109
- (0, common_2.jsonOutput)({
501110
- code: 0,
501111
- data: {
501112
- flowId: result.FlowId,
501113
- requestId: result.RequestId
501114
- }
501115
- });
501116
- return;
501117
- }
501118
- log.success((0, i18n_1.t)('表格回档操作已提交'));
501119
- if (result.FlowId) {
501120
- log.info((0, i18n_1.t)('回档流程 ID: {{flowId}}', { flowId: String(result.FlowId) }));
501121
- }
502143
+ return;
501122
502144
  }
501123
- catch (e) {
501124
- loading.stop();
501125
- if (isJson) {
501126
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
501127
- return;
501128
- }
501129
- throw e;
502145
+ log.success((0, i18n_1.t)('表格回档操作已提交'));
502146
+ if (result.FlowId) {
502147
+ log.info((0, i18n_1.t)('回档流程 ID: {{flowId}}', { flowId: String(result.FlowId) }));
501130
502148
  }
501131
502149
  });
501132
502150
  }
501133
502151
  };
501134
502152
  __decorate([
501135
502153
  (0, decorators_1.InjectParams)(),
501136
- __param(0, (0, decorators_1.EnvId)()),
501137
- __param(1, (0, decorators_1.ArgsOptions)()),
501138
- __param(2, (0, decorators_1.Log)()),
502154
+ __param(0, (0, decorators_1.CmdContext)()),
502155
+ __param(1, (0, decorators_1.EnvId)()),
502156
+ __param(2, (0, decorators_1.ArgsOptions)()),
502157
+ __param(3, (0, decorators_1.Log)()),
501139
502158
  __metadata("design:type", Function),
501140
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
502159
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
501141
502160
  __metadata("design:returntype", Promise)
501142
502161
  ], NosqlBackupRestoreCommand.prototype, "execute", null);
501143
502162
  NosqlBackupRestoreCommand = __decorate([
@@ -501152,72 +502171,55 @@ let BackupTaskCommand = class BackupTaskCommand extends deep_command_1.DeepComma
501152
502171
  childSubCmd: 'backup',
501153
502172
  childChildSubCmd: 'task',
501154
502173
  options: [
501155
- common_2.tagOption,
501156
- common_2.jsonOption
502174
+ common_2.tagOption
501157
502175
  ],
501158
502176
  desc: (0, i18n_1.t)('获取回档任务'),
501159
502177
  requiredEnvId: false,
501160
502178
  autoRunLogin: true
501161
502179
  };
501162
502180
  }
501163
- execute(envId, options, log) {
502181
+ execute(ctx, envId, options, log) {
502182
+ var _a;
501164
502183
  return __awaiter(this, void 0, void 0, function* () {
501165
- const isJson = options.json;
501166
- const selectedEnvId = yield resolveEnv(envId, isJson);
501167
- if (!selectedEnvId)
501168
- return;
502184
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
502185
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
501169
502186
  const loading = (0, utils_1.loadingFactory)();
501170
- try {
501171
- loading.start((0, i18n_1.t)('获取回档任务中...'));
501172
- const result = yield (0, nosql_1.describeRestoreTask)({
501173
- envId: selectedEnvId,
501174
- tag: options.tag
501175
- });
501176
- loading.stop();
501177
- const tasks = result.Tasks || [];
501178
- if (isJson) {
501179
- (0, common_2.jsonOutput)({
501180
- code: 0,
501181
- data: {
501182
- tasks,
501183
- requestId: result.RequestId
501184
- }
501185
- });
501186
- return;
501187
- }
501188
- if (tasks.length === 0) {
501189
- log.info((0, i18n_1.t)('当前没有回档任务'));
501190
- return;
501191
- }
501192
- log.info((0, i18n_1.t)('回档任务列表:'));
501193
- const head = [(0, i18n_1.t)('任务 ID'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('回档时间'), (0, i18n_1.t)('环境 ID'), (0, i18n_1.t)('类型')];
501194
- const tableData = tasks.map((task) => [
501195
- task.TaskId || '-',
501196
- task.Status || '-',
501197
- task.Time || '-',
501198
- task.EnvId || '-',
501199
- task.Type || '-'
501200
- ]);
501201
- (0, utils_1.printHorizontalTable)(head, tableData);
502187
+ loading.start((0, i18n_1.t)('获取回档任务中...'));
502188
+ const result = yield (0, nosql_1.describeRestoreTask)({
502189
+ envId: selectedEnvId,
502190
+ tag: options.tag
502191
+ });
502192
+ loading.stop();
502193
+ const tasks = result.Tasks || [];
502194
+ if (isJson) {
502195
+ (0, utils_1.outputJson)(tasks, { total: tasks.length });
502196
+ return;
501202
502197
  }
501203
- catch (e) {
501204
- loading.stop();
501205
- if (isJson) {
501206
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
501207
- return;
501208
- }
501209
- throw e;
502198
+ if (tasks.length === 0) {
502199
+ log.info((0, i18n_1.t)('当前没有回档任务'));
502200
+ return;
501210
502201
  }
502202
+ log.info((0, i18n_1.t)('回档任务列表:'));
502203
+ const head = [(0, i18n_1.t)('任务 ID'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('回档时间'), (0, i18n_1.t)('环境 ID'), (0, i18n_1.t)('类型')];
502204
+ const tableData = tasks.map((task) => [
502205
+ task.TaskId || '-',
502206
+ task.Status || '-',
502207
+ task.Time || '-',
502208
+ task.EnvId || '-',
502209
+ task.Type || '-'
502210
+ ]);
502211
+ (0, utils_1.printHorizontalTable)(head, tableData);
501211
502212
  });
501212
502213
  }
501213
502214
  };
501214
502215
  __decorate([
501215
502216
  (0, decorators_1.InjectParams)(),
501216
- __param(0, (0, decorators_1.EnvId)()),
501217
- __param(1, (0, decorators_1.ArgsOptions)()),
501218
- __param(2, (0, decorators_1.Log)()),
502217
+ __param(0, (0, decorators_1.CmdContext)()),
502218
+ __param(1, (0, decorators_1.EnvId)()),
502219
+ __param(2, (0, decorators_1.ArgsOptions)()),
502220
+ __param(3, (0, decorators_1.Log)()),
501219
502221
  __metadata("design:type", Function),
501220
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
502222
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
501221
502223
  __metadata("design:returntype", Promise)
501222
502224
  ], BackupTaskCommand.prototype, "execute", null);
501223
502225
  BackupTaskCommand = __decorate([
@@ -534869,9 +535871,9 @@ exports.ExecuteCommand = void 0;
534869
535871
  const common_1 = __webpack_require__(48431);
534870
535872
  const decorators_1 = __webpack_require__(93480);
534871
535873
  const utils_1 = __webpack_require__(82079);
534872
- const utils_2 = __webpack_require__(75213);
534873
535874
  const mysql_1 = __webpack_require__(69116);
534874
- const common_2 = __webpack_require__(79101);
535875
+ const common_2 = __webpack_require__(8906);
535876
+ const error_1 = __webpack_require__(66759);
534875
535877
  const i18n_1 = __webpack_require__(69258);
534876
535878
  let ExecuteCommand = class ExecuteCommand extends common_1.Command {
534877
535879
  get options() {
@@ -534880,93 +535882,76 @@ let ExecuteCommand = class ExecuteCommand extends common_1.Command {
534880
535882
  childCmd: 'execute',
534881
535883
  options: [
534882
535884
  { flags: '-s, --sql <sql>', desc: (0, i18n_1.t)('要执行的 SQL 语句') },
534883
- { flags: '--readOnly', desc: (0, i18n_1.t)('以只读模式执行(默认 false)') },
534884
- common_2.jsonOption
535885
+ { flags: '--read-only', desc: (0, i18n_1.t)('以只读模式执行(默认 false)') }
534885
535886
  ],
534886
535887
  desc: (0, i18n_1.t)('执行 SQL 语句'),
534887
535888
  requiredEnvId: false,
534888
535889
  autoRunLogin: true
534889
535890
  };
534890
535891
  }
534891
- execute(envId, options, log) {
535892
+ execute(ctx, envId, options, log) {
535893
+ var _a;
534892
535894
  return __awaiter(this, void 0, void 0, function* () {
534893
- const isJson = options.json;
534894
- let selectedEnvId = envId;
534895
- if (!selectedEnvId) {
534896
- if (isJson) {
534897
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
534898
- return;
534899
- }
534900
- selectedEnvId = yield (0, utils_2.selectEnv)();
534901
- }
535895
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
535896
+ const selectedEnvId = yield (0, common_2.ensureEnvId)(envId, isJson);
534902
535897
  const { sql, readOnly } = options;
534903
535898
  if (!sql) {
534904
- if (isJson) {
534905
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --sql 参数指定要执行的 SQL 语句') });
534906
- return;
534907
- }
534908
- log.error((0, i18n_1.t)('请通过 --sql 参数指定要执行的 SQL 语句'));
534909
- return;
535899
+ throw new error_1.CloudBaseError({
535900
+ message: (0, i18n_1.t)('请通过 --sql 参数指定要执行的 SQL 语句'),
535901
+ code: 'MISSING_PARAM',
535902
+ solution: [(0, i18n_1.t)('使用 -s, --sql 指定 SQL 语句,如 --sql "SELECT 1"')]
535903
+ });
534910
535904
  }
534911
535905
  const loading = (0, utils_1.loadingFactory)();
534912
- try {
534913
- loading.start((0, i18n_1.t)('正在执行 SQL...'));
534914
- const result = yield (0, mysql_1.runSql)({
534915
- envId: selectedEnvId,
534916
- sql,
534917
- readOnly: readOnly || false
534918
- });
534919
- loading.stop();
534920
- const items = result.Items || [];
534921
- if (items.length > 0) {
534922
- const rows = items.map((item) => {
534923
- try {
534924
- return JSON.parse(item);
534925
- }
534926
- catch (_a) {
534927
- return {};
534928
- }
534929
- });
534930
- if (isJson) {
534931
- (0, common_2.jsonOutput)({ code: 0, data: { items: rows, count: rows.length } });
534932
- return;
535906
+ loading.start((0, i18n_1.t)('正在执行 SQL...'));
535907
+ const result = yield (0, mysql_1.runSql)({
535908
+ envId: selectedEnvId,
535909
+ sql,
535910
+ readOnly: readOnly || false
535911
+ });
535912
+ loading.stop();
535913
+ const items = result.Items || [];
535914
+ if (items.length > 0) {
535915
+ const rows = items.map((item) => {
535916
+ try {
535917
+ return JSON.parse(item);
534933
535918
  }
534934
- if (rows.length > 0 && Object.keys(rows[0]).length > 0) {
534935
- const head = Object.keys(rows[0]);
534936
- const tableData = rows.map((row) => head.map((key) => {
534937
- const val = row[key];
534938
- return val === null || val === undefined ? 'NULL' : String(val);
534939
- }));
534940
- (0, utils_1.printHorizontalTable)(head, tableData);
534941
- log.info((0, i18n_1.t)('共 {{count}} 条记录', { count: String(rows.length) }));
535919
+ catch (_a) {
535920
+ return {};
534942
535921
  }
535922
+ });
535923
+ if (isJson) {
535924
+ (0, utils_1.outputJson)({ items: rows, count: rows.length });
535925
+ return;
534943
535926
  }
534944
- else {
534945
- if (isJson) {
534946
- (0, common_2.jsonOutput)({ code: 0, data: { rowsAffected: result.RowsAffected || 0 } });
534947
- return;
534948
- }
534949
- log.info((0, i18n_1.t)('受影响行数: {{count}}', { count: String(result.RowsAffected || 0) }));
535927
+ if (rows.length > 0 && Object.keys(rows[0]).length > 0) {
535928
+ const head = Object.keys(rows[0]);
535929
+ const tableData = rows.map((row) => head.map((key) => {
535930
+ const val = row[key];
535931
+ return val === null || val === undefined ? 'NULL' : String(val);
535932
+ }));
535933
+ (0, utils_1.printHorizontalTable)(head, tableData);
535934
+ log.info((0, i18n_1.t)('共 {{count}} 条记录', { count: String(rows.length) }));
534950
535935
  }
534951
535936
  }
534952
- catch (e) {
534953
- loading.stop();
535937
+ else {
534954
535938
  if (isJson) {
534955
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
535939
+ (0, utils_1.outputJson)({ rowsAffected: result.RowsAffected || 0 });
534956
535940
  return;
534957
535941
  }
534958
- throw e;
535942
+ log.info((0, i18n_1.t)('受影响行数: {{count}}', { count: String(result.RowsAffected || 0) }));
534959
535943
  }
534960
535944
  });
534961
535945
  }
534962
535946
  };
534963
535947
  __decorate([
534964
535948
  (0, decorators_1.InjectParams)(),
534965
- __param(0, (0, decorators_1.EnvId)()),
534966
- __param(1, (0, decorators_1.ArgsOptions)()),
534967
- __param(2, (0, decorators_1.Log)()),
535949
+ __param(0, (0, decorators_1.CmdContext)()),
535950
+ __param(1, (0, decorators_1.EnvId)()),
535951
+ __param(2, (0, decorators_1.ArgsOptions)()),
535952
+ __param(3, (0, decorators_1.Log)()),
534968
535953
  __metadata("design:type", Function),
534969
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
535954
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
534970
535955
  __metadata("design:returntype", Promise)
534971
535956
  ], ExecuteCommand.prototype, "execute", null);
534972
535957
  ExecuteCommand = __decorate([
@@ -549933,14 +550918,14 @@ let ListUserCommand = class ListUserCommand extends common_1.Command {
549933
550918
  throw new error_1.CloudBaseError({
549934
550919
  message: (0, i18n_1.t)('无效的 --offset,必须为非负整数'),
549935
550920
  code: 'INVALID_PARAM',
549936
- solution: [(0, i18n_1.t)('示例:tcb user list --offset 0 --limit 20 --envId <envId>')]
550921
+ solution: [(0, i18n_1.t)('示例:tcb user list --offset 0 --limit 20 --env-id <envId>')]
549937
550922
  });
549938
550923
  }
549939
550924
  if (isNaN(limit) || limit < 1 || limit > 100) {
549940
550925
  throw new error_1.CloudBaseError({
549941
550926
  message: (0, i18n_1.t)('无效的 --limit,必须为 1-100 的正整数'),
549942
550927
  code: 'INVALID_PARAM',
549943
- solution: [(0, i18n_1.t)('示例:tcb user list --limit 20 --envId <envId>')]
550928
+ solution: [(0, i18n_1.t)('示例:tcb user list --limit 20 --env-id <envId>')]
549944
550929
  });
549945
550930
  }
549946
550931
  const page = Math.floor(offset / limit) + 1;
@@ -549997,7 +550982,7 @@ let ListUserCommand = class ListUserCommand extends common_1.Command {
549997
550982
  throw new error_1.CloudBaseError({
549998
550983
  message: e.message || (0, i18n_1.t)('查询用户列表失败'),
549999
550984
  code: 'API_ERROR',
550000
- solution: [(0, i18n_1.t)('请检查参数是否正确,或运行 `tcb user list --envId {{envId}}` 确认环境状态', { envId })]
550985
+ solution: [(0, i18n_1.t)('请检查参数是否正确,或运行 `tcb user list --env-id {{envId}}` 确认环境状态', { envId })]
550001
550986
  });
550002
550987
  }
550003
550988
  });
@@ -553500,9 +554485,10 @@ exports.NosqlExecuteCommand = void 0;
553500
554485
  const common_1 = __webpack_require__(48431);
553501
554486
  const decorators_1 = __webpack_require__(93480);
553502
554487
  const utils_1 = __webpack_require__(82079);
553503
- const utils_2 = __webpack_require__(75213);
553504
554488
  const nosql_1 = __webpack_require__(56547);
553505
554489
  const common_2 = __webpack_require__(28680);
554490
+ const common_3 = __webpack_require__(8906);
554491
+ const error_1 = __webpack_require__(66759);
553506
554492
  const i18n_1 = __webpack_require__(69258);
553507
554493
  let NosqlExecuteCommand = class NosqlExecuteCommand extends common_1.Command {
553508
554494
  get options() {
@@ -553514,152 +554500,133 @@ let NosqlExecuteCommand = class NosqlExecuteCommand extends common_1.Command {
553514
554500
  { flags: '-c, --command <command>', desc: (0, i18n_1.t)('要执行的 MgoCommands JSON') },
553515
554501
  common_2.tagOption,
553516
554502
  common_2.instanceIdOption,
553517
- common_2.databaseNameOption,
553518
- common_2.jsonOption
554503
+ common_2.databaseNameOption
553519
554504
  ],
553520
554505
  desc: (0, i18n_1.t)('执行文档型数据库命令') + '\n RunCommands 接口文档: https://cloud.tencent.com/document/api/876/129012\n MgoCommandParam 数据结构: https://cloud.tencent.com/document/api/876/34822#MgoCommandParam',
553521
554506
  requiredEnvId: false,
553522
554507
  autoRunLogin: true
553523
554508
  };
553524
554509
  }
553525
- execute(envId, options, log) {
554510
+ execute(ctx, envId, options, log) {
554511
+ var _a;
553526
554512
  return __awaiter(this, void 0, void 0, function* () {
553527
- const isJson = options.json;
553528
- let selectedEnvId = envId;
553529
- if (!selectedEnvId) {
553530
- if (isJson) {
553531
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
553532
- return;
553533
- }
553534
- selectedEnvId = yield (0, utils_2.selectEnv)();
553535
- }
554513
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
554514
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
553536
554515
  const { command, tag, instanceId: connInstanceId, databaseName } = options;
553537
554516
  if (!command) {
553538
- if (isJson) {
553539
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --command 参数指定要执行的命令 JSON') });
553540
- return;
553541
- }
553542
- log.error((0, i18n_1.t)('请通过 --command 参数指定要执行的命令 JSON'));
553543
- return;
554517
+ throw new error_1.CloudBaseError({
554518
+ message: (0, i18n_1.t)('请通过 --command 参数指定要执行的命令 JSON'),
554519
+ code: 'MISSING_PARAM',
554520
+ solution: [
554521
+ (0, i18n_1.t)('RunCommands 接口文档: https://cloud.tencent.com/document/api/876/129012'),
554522
+ (0, i18n_1.t)('MgoCommandParam 数据结构: https://cloud.tencent.com/document/api/876/34822#MgoCommandParam')
554523
+ ]
554524
+ });
553544
554525
  }
553545
554526
  let parsedCommand;
553546
554527
  try {
553547
554528
  parsedCommand = JSON.parse(command);
553548
554529
  }
553549
554530
  catch (e) {
553550
- if (isJson) {
553551
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('命令参数 JSON 解析失败: {{message}}', { message: e.message }) });
553552
- return;
553553
- }
553554
- log.error((0, i18n_1.t)('命令参数 JSON 解析失败: {{message}}', { message: e.message }));
553555
- return;
554531
+ throw new error_1.CloudBaseError({
554532
+ message: (0, i18n_1.t)('命令参数 JSON 解析失败: {{message}}', { message: e.message }),
554533
+ code: 'INVALID_PARAM',
554534
+ solution: [(0, i18n_1.t)('请确保 --command 参数为合法的 JSON 数组')]
554535
+ });
553556
554536
  }
553557
554537
  if (!Array.isArray(parsedCommand)) {
553558
- if (isJson) {
553559
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('命令参数应为 MgoCommands 数组') });
553560
- return;
553561
- }
553562
- log.error((0, i18n_1.t)('命令参数应为 MgoCommands 数组'));
553563
- return;
554538
+ throw new error_1.CloudBaseError({
554539
+ message: (0, i18n_1.t)('命令参数应为 MgoCommands 数组'),
554540
+ code: 'INVALID_PARAM',
554541
+ solution: [(0, i18n_1.t)('请确保 --command 参数为 JSON 数组格式')]
554542
+ });
553564
554543
  }
553565
554544
  const mongoConnector = (connInstanceId || databaseName)
553566
554545
  ? Object.assign(Object.assign({}, (connInstanceId ? { instanceId: connInstanceId } : {})), (databaseName ? { databaseName } : {})) : undefined;
553567
554546
  const loading = (0, utils_1.loadingFactory)();
553568
- try {
553569
- loading.start((0, i18n_1.t)('正在执行命令...'));
553570
- const result = yield (0, nosql_1.runCommands)({
553571
- envId: selectedEnvId,
553572
- mgoCommands: parsedCommand,
553573
- tag,
553574
- mongoConnector
553575
- });
553576
- loading.stop();
553577
- const data = result.Data || [];
553578
- if (isJson) {
553579
- const results = data.map((item) => {
553580
- try {
553581
- const parsed = JSON.parse(item);
553582
- if (Array.isArray(parsed)) {
553583
- return parsed.map((sub) => {
553584
- if (typeof sub === 'string') {
553585
- try {
553586
- return JSON.parse(sub);
553587
- }
553588
- catch (_a) {
553589
- return sub;
553590
- }
554547
+ loading.start((0, i18n_1.t)('正在执行命令...'));
554548
+ const result = yield (0, nosql_1.runCommands)({
554549
+ envId: selectedEnvId,
554550
+ mgoCommands: parsedCommand,
554551
+ tag,
554552
+ mongoConnector
554553
+ });
554554
+ loading.stop();
554555
+ const data = result.Data || [];
554556
+ if (isJson) {
554557
+ const results = data.map((item) => {
554558
+ try {
554559
+ const parsed = JSON.parse(item);
554560
+ if (Array.isArray(parsed)) {
554561
+ return parsed.map((sub) => {
554562
+ if (typeof sub === 'string') {
554563
+ try {
554564
+ return JSON.parse(sub);
553591
554565
  }
553592
- return sub;
553593
- });
553594
- }
553595
- return parsed;
553596
- }
553597
- catch (_a) {
553598
- return item;
553599
- }
553600
- });
553601
- (0, common_2.jsonOutput)({
553602
- code: 0,
553603
- data: {
553604
- results,
553605
- requestId: result.RequestId
553606
- }
553607
- });
553608
- return;
553609
- }
553610
- if (data.length === 0) {
553611
- log.info((0, i18n_1.t)('无返回数据'));
553612
- }
553613
- else {
553614
- data.forEach((item, index) => {
553615
- if (data.length > 1) {
553616
- log.info((0, i18n_1.t)('返回数据 ({{index}}/{{total}}):', { index: String(index + 1), total: String(data.length) }));
554566
+ catch (_a) {
554567
+ return sub;
554568
+ }
554569
+ }
554570
+ return sub;
554571
+ });
553617
554572
  }
553618
- try {
553619
- const parsed = JSON.parse(item);
553620
- if (Array.isArray(parsed)) {
553621
- const deepParsed = parsed.map((sub) => {
553622
- if (typeof sub === 'string') {
553623
- try {
553624
- return JSON.parse(sub);
553625
- }
553626
- catch (_a) {
553627
- return sub;
553628
- }
554573
+ return parsed;
554574
+ }
554575
+ catch (_a) {
554576
+ return item;
554577
+ }
554578
+ });
554579
+ (0, utils_1.outputJson)({
554580
+ results,
554581
+ requestId: result.RequestId
554582
+ });
554583
+ return;
554584
+ }
554585
+ if (data.length === 0) {
554586
+ log.info((0, i18n_1.t)('无返回数据'));
554587
+ }
554588
+ else {
554589
+ data.forEach((item, index) => {
554590
+ if (data.length > 1) {
554591
+ log.info((0, i18n_1.t)('返回数据 ({{index}}/{{total}}):', { index: String(index + 1), total: String(data.length) }));
554592
+ }
554593
+ try {
554594
+ const parsed = JSON.parse(item);
554595
+ if (Array.isArray(parsed)) {
554596
+ const deepParsed = parsed.map((sub) => {
554597
+ if (typeof sub === 'string') {
554598
+ try {
554599
+ return JSON.parse(sub);
553629
554600
  }
553630
- return sub;
553631
- });
553632
- console.log(JSON.stringify(deepParsed, null, 2));
553633
- }
553634
- else {
553635
- console.log(JSON.stringify(parsed, null, 2));
553636
- }
554601
+ catch (_a) {
554602
+ return sub;
554603
+ }
554604
+ }
554605
+ return sub;
554606
+ });
554607
+ console.log(JSON.stringify(deepParsed, null, 2));
553637
554608
  }
553638
- catch (_a) {
553639
- console.log(item);
554609
+ else {
554610
+ console.log(JSON.stringify(parsed, null, 2));
553640
554611
  }
553641
- });
553642
- }
553643
- log.verbose(`RequestId: ${result.RequestId}`);
553644
- }
553645
- catch (e) {
553646
- loading.stop();
553647
- if (isJson) {
553648
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
553649
- return;
553650
- }
553651
- throw e;
554612
+ }
554613
+ catch (_a) {
554614
+ console.log(item);
554615
+ }
554616
+ });
553652
554617
  }
554618
+ log.verbose(`RequestId: ${result.RequestId}`);
553653
554619
  });
553654
554620
  }
553655
554621
  };
553656
554622
  __decorate([
553657
554623
  (0, decorators_1.InjectParams)(),
553658
- __param(0, (0, decorators_1.EnvId)()),
553659
- __param(1, (0, decorators_1.ArgsOptions)()),
553660
- __param(2, (0, decorators_1.Log)()),
554624
+ __param(0, (0, decorators_1.CmdContext)()),
554625
+ __param(1, (0, decorators_1.EnvId)()),
554626
+ __param(2, (0, decorators_1.ArgsOptions)()),
554627
+ __param(3, (0, decorators_1.Log)()),
553661
554628
  __metadata("design:type", Function),
553662
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
554629
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
553663
554630
  __metadata("design:returntype", Promise)
553664
554631
  ], NosqlExecuteCommand.prototype, "execute", null);
553665
554632
  NosqlExecuteCommand = __decorate([
@@ -582368,6 +583335,79 @@ module.exports = function (Promise, apiRejection, tryConvertToPromise,
582368
583335
  "use strict";
582369
583336
  module.exports = require("node:string_decoder");
582370
583337
 
583338
+ /***/ }),
583339
+
583340
+ /***/ 46212:
583341
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
583342
+
583343
+ "use strict";
583344
+
583345
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
583346
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
583347
+ return new (P || (P = Promise))(function (resolve, reject) {
583348
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
583349
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
583350
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
583351
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
583352
+ });
583353
+ };
583354
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
583355
+ exports.modifyHTTPServiceRoute = exports.createHTTPServiceRoute = exports.deleteHTTPServiceRoute = exports.getHTTPServiceRoutes = void 0;
583356
+ const net_1 = __webpack_require__(25491);
583357
+ function getHTTPServiceRoutes({ envId, offset = 0, limit = 20, filters = [] }) {
583358
+ return __awaiter(this, void 0, void 0, function* () {
583359
+ const params = {
583360
+ EnvId: envId,
583361
+ Offset: offset,
583362
+ Limit: limit
583363
+ };
583364
+ if (filters.length > 0) {
583365
+ params.Filters = filters;
583366
+ }
583367
+ const envService = yield (0, net_1.getEnvService)(envId);
583368
+ const result = yield envService.describeHttpServiceRoute(params);
583369
+ const domains = (result === null || result === void 0 ? void 0 : result.Domains) || [];
583370
+ const totalCount = typeof (result === null || result === void 0 ? void 0 : result.TotalCount) === 'number' ? result.TotalCount : 0;
583371
+ return { domains, totalCount };
583372
+ });
583373
+ }
583374
+ exports.getHTTPServiceRoutes = getHTTPServiceRoutes;
583375
+ function deleteHTTPServiceRoute({ envId, domain, paths }) {
583376
+ return __awaiter(this, void 0, void 0, function* () {
583377
+ const params = {
583378
+ EnvId: envId,
583379
+ Domain: domain
583380
+ };
583381
+ if (paths && paths.length > 0) {
583382
+ params.Paths = paths;
583383
+ }
583384
+ const envService = yield (0, net_1.getEnvService)(envId);
583385
+ yield envService.deleteHttpServiceRoute(params);
583386
+ });
583387
+ }
583388
+ exports.deleteHTTPServiceRoute = deleteHTTPServiceRoute;
583389
+ function createHTTPServiceRoute({ envId, domain }) {
583390
+ return __awaiter(this, void 0, void 0, function* () {
583391
+ const envService = yield (0, net_1.getEnvService)(envId);
583392
+ yield envService.createHttpServiceRoute({
583393
+ EnvId: envId,
583394
+ Domain: domain
583395
+ });
583396
+ });
583397
+ }
583398
+ exports.createHTTPServiceRoute = createHTTPServiceRoute;
583399
+ function modifyHTTPServiceRoute({ envId, domain }) {
583400
+ return __awaiter(this, void 0, void 0, function* () {
583401
+ const envService = yield (0, net_1.getEnvService)(envId);
583402
+ yield envService.modifyHttpServiceRoute({
583403
+ EnvId: envId,
583404
+ Domain: domain
583405
+ });
583406
+ });
583407
+ }
583408
+ exports.modifyHTTPServiceRoute = modifyHTTPServiceRoute;
583409
+
583410
+
582371
583411
  /***/ }),
582372
583412
 
582373
583413
  /***/ 46254:
@@ -583197,6 +584237,174 @@ function isNumeric(val) {
583197
584237
  //# sourceMappingURL=isNumeric.js.map
583198
584238
 
583199
584239
 
584240
+ /***/ }),
584241
+
584242
+ /***/ 46291:
584243
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
584244
+
584245
+ "use strict";
584246
+
584247
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
584248
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
584249
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
584250
+ 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;
584251
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
584252
+ };
584253
+ var __metadata = (this && this.__metadata) || function (k, v) {
584254
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
584255
+ };
584256
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
584257
+ return function (target, key) { decorator(target, key, paramIndex); }
584258
+ };
584259
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
584260
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
584261
+ return new (P || (P = Promise))(function (resolve, reject) {
584262
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
584263
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
584264
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
584265
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
584266
+ });
584267
+ };
584268
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
584269
+ exports.ListRoutesCommand = void 0;
584270
+ const common_1 = __webpack_require__(48431);
584271
+ const error_1 = __webpack_require__(66759);
584272
+ const utils_1 = __webpack_require__(82079);
584273
+ const decorators_1 = __webpack_require__(93480);
584274
+ const routes_1 = __webpack_require__(46212);
584275
+ const i18n_1 = __webpack_require__(69258);
584276
+ let ListRoutesCommand = class ListRoutesCommand extends common_1.Command {
584277
+ get options() {
584278
+ return {
584279
+ cmd: 'routes',
584280
+ childCmd: 'list',
584281
+ options: [
584282
+ {
584283
+ flags: '--offset <offset>',
584284
+ desc: (0, i18n_1.t)('分页偏移量,默认为 0')
584285
+ },
584286
+ {
584287
+ flags: '--limit <limit>',
584288
+ desc: (0, i18n_1.t)('分页限制,默认 20,最大 1000')
584289
+ },
584290
+ {
584291
+ flags: '--filter <filter>',
584292
+ desc: (0, i18n_1.t)('过滤条件。可过滤字段: Domain(域名)、Path(路径)、UpstreamResourceType(上游服务类型: SCF/CBR/STATIC_STORE/WEB_SCF/LH)。多个条件用&连接(且关系),多值用逗号分隔(或关系)')
584293
+ }
584294
+ ],
584295
+ desc: (0, i18n_1.t)('查询 HTTP 服务路由列表。展示域名下的所有路由配置,包括路径、上游服务、启用状态等信息'),
584296
+ examples: [
584297
+ 'tcb routes list -e envId',
584298
+ 'tcb routes list -e envId --json',
584299
+ 'tcb routes list -e envId --limit 50 --offset 0',
584300
+ 'tcb routes list -e envId --filter "Domain=api.example.com"',
584301
+ 'tcb routes list -e envId --filter "UpstreamResourceType=CBR"',
584302
+ 'tcb routes list -e envId --filter "UpstreamResourceType=SCF&Domain=api.example.com,api2.example.com"'
584303
+ ]
584304
+ };
584305
+ }
584306
+ execute(envId, options, log) {
584307
+ return __awaiter(this, void 0, void 0, function* () {
584308
+ const offset = parseInt(options.offset, 10) || 0;
584309
+ const limit = parseInt(options.limit, 10) || 20;
584310
+ const filters = [
584311
+ { Name: 'DomainType', Values: ['HTTPSERVICE'] }
584312
+ ];
584313
+ if (options.filter) {
584314
+ const filterStr = Array.isArray(options.filter)
584315
+ ? options.filter.join('&')
584316
+ : options.filter;
584317
+ const conditions = filterStr.split('&');
584318
+ conditions.forEach((condition) => {
584319
+ const equalIndex = condition.indexOf('=');
584320
+ if (equalIndex > 0) {
584321
+ const name = condition.substring(0, equalIndex);
584322
+ const value = condition.substring(equalIndex + 1);
584323
+ if (name && value) {
584324
+ filters.push({
584325
+ Name: name,
584326
+ Values: value.split(',').map((v) => v.trim())
584327
+ });
584328
+ }
584329
+ }
584330
+ });
584331
+ }
584332
+ let domains = [];
584333
+ try {
584334
+ const result = yield (0, routes_1.getHTTPServiceRoutes)({
584335
+ envId,
584336
+ offset,
584337
+ limit,
584338
+ filters
584339
+ });
584340
+ domains = result.domains;
584341
+ }
584342
+ catch (e) {
584343
+ throw new error_1.CloudBaseError({
584344
+ message: e.message || (0, i18n_1.t)('获取路由列表失败'),
584345
+ code: 'API_ERROR',
584346
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
584347
+ original: e
584348
+ });
584349
+ }
584350
+ const allRoutes = [];
584351
+ domains.forEach((domain) => {
584352
+ const routes = domain.Routes || [];
584353
+ routes.forEach((route) => {
584354
+ allRoutes.push({
584355
+ domain: domain.Domain,
584356
+ path: route.Path,
584357
+ upstreamResourceName: route.UpstreamResourceName,
584358
+ upstreamResourceType: route.UpstreamResourceType,
584359
+ enable: route.Enable,
584360
+ enableAuth: route.EnableAuth,
584361
+ enablePathTransmission: route.EnablePathTransmission,
584362
+ updateTime: route.UpdateTime
584363
+ });
584364
+ });
584365
+ });
584366
+ if ((0, utils_1.isJsonOutput)()) {
584367
+ (0, utils_1.outputJson)(allRoutes, {
584368
+ total: allRoutes.length,
584369
+ limit,
584370
+ offset
584371
+ });
584372
+ return;
584373
+ }
584374
+ if (allRoutes.length === 0) {
584375
+ log.info((0, i18n_1.t)('路由列表为空!'));
584376
+ return;
584377
+ }
584378
+ const head = [(0, i18n_1.t)('域名'), (0, i18n_1.t)('路由'), (0, i18n_1.t)('路由启用'), (0, i18n_1.t)('资源类型'), (0, i18n_1.t)('资源对象'), (0, i18n_1.t)('路径透传'), (0, i18n_1.t)('身份认证'), (0, i18n_1.t)('更新时间')];
584379
+ const tableData = allRoutes.map((item) => [
584380
+ item.domain,
584381
+ item.path,
584382
+ item.enable ? (0, i18n_1.t)('开启') : (0, i18n_1.t)('关闭'),
584383
+ item.upstreamResourceType,
584384
+ item.upstreamResourceName,
584385
+ item.enablePathTransmission ? (0, i18n_1.t)('开启') : (0, i18n_1.t)('关闭'),
584386
+ item.enableAuth ? (0, i18n_1.t)('开启') : (0, i18n_1.t)('关闭'),
584387
+ item.updateTime
584388
+ ]);
584389
+ (0, utils_1.printHorizontalTable)(head, tableData);
584390
+ });
584391
+ }
584392
+ };
584393
+ __decorate([
584394
+ (0, decorators_1.InjectParams)(),
584395
+ __param(0, (0, decorators_1.EnvId)()),
584396
+ __param(1, (0, decorators_1.ArgsOptions)()),
584397
+ __param(2, (0, decorators_1.Log)()),
584398
+ __metadata("design:type", Function),
584399
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
584400
+ __metadata("design:returntype", Promise)
584401
+ ], ListRoutesCommand.prototype, "execute", null);
584402
+ ListRoutesCommand = __decorate([
584403
+ (0, common_1.ICommand)()
584404
+ ], ListRoutesCommand);
584405
+ exports.ListRoutesCommand = ListRoutesCommand;
584406
+
584407
+
583200
584408
  /***/ }),
583201
584409
 
583202
584410
  /***/ 46308:
@@ -599476,6 +600684,9 @@ __exportStar(__webpack_require__(11502), exports);
599476
600684
  __exportStar(__webpack_require__(81106), exports);
599477
600685
  __exportStar(__webpack_require__(60928), exports);
599478
600686
  __exportStar(__webpack_require__(41650), exports);
600687
+ __exportStar(__webpack_require__(14120), exports);
600688
+ __exportStar(__webpack_require__(30527), exports);
600689
+ __exportStar(__webpack_require__(55918), exports);
599479
600690
 
599480
600691
 
599481
600692
  /***/ }),
@@ -607359,6 +608570,137 @@ module.exports = (string, columns, options) => {
607359
608570
  };
607360
608571
 
607361
608572
 
608573
+ /***/ }),
608574
+
608575
+ /***/ 50455:
608576
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
608577
+
608578
+ "use strict";
608579
+
608580
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
608581
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
608582
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
608583
+ 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;
608584
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
608585
+ };
608586
+ var __metadata = (this && this.__metadata) || function (k, v) {
608587
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
608588
+ };
608589
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
608590
+ return function (target, key) { decorator(target, key, paramIndex); }
608591
+ };
608592
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
608593
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
608594
+ return new (P || (P = Promise))(function (resolve, reject) {
608595
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
608596
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
608597
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
608598
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
608599
+ });
608600
+ };
608601
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
608602
+ exports.RmCorsCommand = void 0;
608603
+ const error_1 = __webpack_require__(66759);
608604
+ const interactive_1 = __webpack_require__(57695);
608605
+ const common_1 = __webpack_require__(48431);
608606
+ const utils_1 = __webpack_require__(82079);
608607
+ const decorators_1 = __webpack_require__(93480);
608608
+ const cors_1 = __webpack_require__(59515);
608609
+ const i18n_1 = __webpack_require__(69258);
608610
+ let RmCorsCommand = class RmCorsCommand extends common_1.Command {
608611
+ get options() {
608612
+ return {
608613
+ cmd: 'cors',
608614
+ childCmd: 'rm <domain>',
608615
+ options: [],
608616
+ desc: (0, i18n_1.t)('删除安全域名,多个以逗号分隔')
608617
+ };
608618
+ }
608619
+ execute(params, envId, log) {
608620
+ return __awaiter(this, void 0, void 0, function* () {
608621
+ log.verbose(params);
608622
+ const domain = params === null || params === void 0 ? void 0 : params[0];
608623
+ const domains = domain.split(',');
608624
+ const confirm = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('确认删除以下安全域名: {{domains}} ?', { domains }), true);
608625
+ if (!confirm) {
608626
+ throw new error_1.CloudBaseError({
608627
+ message: (0, i18n_1.t)('操作终止!'),
608628
+ code: 'USER_CANCEL'
608629
+ });
608630
+ }
608631
+ let corsDomains = [];
608632
+ try {
608633
+ corsDomains = yield (0, cors_1.getCorsDomains)({
608634
+ envId
608635
+ });
608636
+ }
608637
+ catch (e) {
608638
+ throw new error_1.CloudBaseError({
608639
+ message: e.message || (0, i18n_1.t)('获取安全域名列表失败'),
608640
+ code: 'API_ERROR',
608641
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
608642
+ original: e
608643
+ });
608644
+ }
608645
+ const domainNames = [];
608646
+ const notFoundDomains = [];
608647
+ domains.forEach((item) => {
608648
+ const found = corsDomains.find((d) => d.Domain === item);
608649
+ if (found) {
608650
+ domainNames.push(found.Domain);
608651
+ }
608652
+ else {
608653
+ notFoundDomains.push(item);
608654
+ }
608655
+ });
608656
+ if (notFoundDomains.length) {
608657
+ throw new error_1.CloudBaseError({
608658
+ message: (0, i18n_1.t)('域名 [{{domains}}] 不存在!', { domains: notFoundDomains.join(', ') }),
608659
+ code: 'RESOURCE_NOT_FOUND',
608660
+ solution: [
608661
+ (0, i18n_1.t)('请检查域名是否正确'),
608662
+ (0, i18n_1.t)('使用 tcb cors list -e <envId> 查看已有域名')
608663
+ ]
608664
+ });
608665
+ }
608666
+ let deleted;
608667
+ try {
608668
+ deleted = yield (0, cors_1.deleteCorsDomain)({
608669
+ envId,
608670
+ domains: domainNames
608671
+ });
608672
+ }
608673
+ catch (e) {
608674
+ throw new error_1.CloudBaseError({
608675
+ message: e.message || (0, i18n_1.t)('删除安全域名失败'),
608676
+ code: 'API_ERROR',
608677
+ solution: [(0, i18n_1.t)('请检查域名是否存在')],
608678
+ original: e
608679
+ });
608680
+ }
608681
+ if ((0, utils_1.isJsonOutput)()) {
608682
+ (0, utils_1.outputJson)({ message: (0, i18n_1.t)('成功删除了 {{count}} 个域名', { count: deleted }) });
608683
+ return;
608684
+ }
608685
+ log.success((0, i18n_1.t)('成功删除了 {{count}} 个域名!', { count: deleted }));
608686
+ });
608687
+ }
608688
+ };
608689
+ __decorate([
608690
+ (0, decorators_1.InjectParams)(),
608691
+ __param(0, (0, decorators_1.ArgsParams)()),
608692
+ __param(1, (0, decorators_1.EnvId)()),
608693
+ __param(2, (0, decorators_1.Log)()),
608694
+ __metadata("design:type", Function),
608695
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
608696
+ __metadata("design:returntype", Promise)
608697
+ ], RmCorsCommand.prototype, "execute", null);
608698
+ RmCorsCommand = __decorate([
608699
+ (0, common_1.ICommand)()
608700
+ ], RmCorsCommand);
608701
+ exports.RmCorsCommand = RmCorsCommand;
608702
+
608703
+
607362
608704
  /***/ }),
607363
608705
 
607364
608706
  /***/ 50520:
@@ -645408,6 +646750,33 @@ util.inherits(module.exports.ISO_8859_7, sbcs);
645408
646750
 
645409
646751
 
645410
646752
 
646753
+ /***/ }),
646754
+
646755
+ /***/ 55918:
646756
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
646757
+
646758
+ "use strict";
646759
+
646760
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
646761
+ if (k2 === undefined) k2 = k;
646762
+ var desc = Object.getOwnPropertyDescriptor(m, k);
646763
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
646764
+ desc = { enumerable: true, get: function() { return m[k]; } };
646765
+ }
646766
+ Object.defineProperty(o, k2, desc);
646767
+ }) : (function(o, m, k, k2) {
646768
+ if (k2 === undefined) k2 = k;
646769
+ o[k2] = m[k];
646770
+ }));
646771
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
646772
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
646773
+ };
646774
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
646775
+ __exportStar(__webpack_require__(8028), exports);
646776
+ __exportStar(__webpack_require__(26957), exports);
646777
+ __exportStar(__webpack_require__(73289), exports);
646778
+
646779
+
645411
646780
  /***/ }),
645412
646781
 
645413
646782
  /***/ 55921:
@@ -652391,7 +653760,7 @@ let DeleteUserCommand = class DeleteUserCommand extends common_1.Command {
652391
653760
  throw new error_1.CloudBaseError({
652392
653761
  message: (0, i18n_1.t)('请指定要删除的用户 UID,例如:tcb user delete 1001'),
652393
653762
  code: 'MISSING_PARAM',
652394
- solution: [(0, i18n_1.t)('用法:tcb user delete <uid1> <uid2> --envId <envId>')]
653763
+ solution: [(0, i18n_1.t)('用法:tcb user delete <uid1> <uid2> --env-id <envId>')]
652395
653764
  });
652396
653765
  }
652397
653766
  if (uids.length > 100) {
@@ -652426,7 +653795,7 @@ let DeleteUserCommand = class DeleteUserCommand extends common_1.Command {
652426
653795
  throw new error_1.CloudBaseError({
652427
653796
  message: e.message || (0, i18n_1.t)('删除用户失败'),
652428
653797
  code: 'API_ERROR',
652429
- solution: [(0, i18n_1.t)('请确认用户 UID 正确,运行 `tcb user list --envId {{envId}}` 查看', { envId })],
653798
+ solution: [(0, i18n_1.t)('请确认用户 UID 正确,运行 `tcb user list --env-id {{envId}}` 查看', { envId })],
652430
653799
  original: e
652431
653800
  });
652432
653801
  }
@@ -667490,6 +668859,50 @@ function singletonify(inst) {
667490
668859
  }
667491
668860
 
667492
668861
 
668862
+ /***/ }),
668863
+
668864
+ /***/ 59515:
668865
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
668866
+
668867
+ "use strict";
668868
+
668869
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
668870
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
668871
+ return new (P || (P = Promise))(function (resolve, reject) {
668872
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
668873
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
668874
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
668875
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
668876
+ });
668877
+ };
668878
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
668879
+ exports.deleteCorsDomain = exports.createCorsDomain = exports.getCorsDomains = void 0;
668880
+ const net_1 = __webpack_require__(25491);
668881
+ function getCorsDomains({ envId }) {
668882
+ return __awaiter(this, void 0, void 0, function* () {
668883
+ const envService = yield (0, net_1.getEnvService)(envId);
668884
+ const { Domains = [] } = yield envService.getEnvAuthDomains();
668885
+ return Domains;
668886
+ });
668887
+ }
668888
+ exports.getCorsDomains = getCorsDomains;
668889
+ function createCorsDomain({ envId, domains }) {
668890
+ return __awaiter(this, void 0, void 0, function* () {
668891
+ const envService = yield (0, net_1.getEnvService)(envId);
668892
+ yield envService.createEnvDomain(domains);
668893
+ });
668894
+ }
668895
+ exports.createCorsDomain = createCorsDomain;
668896
+ function deleteCorsDomain({ envId, domains }) {
668897
+ return __awaiter(this, void 0, void 0, function* () {
668898
+ const envService = yield (0, net_1.getEnvService)(envId);
668899
+ const { Deleted } = yield envService.deleteEnvDomain(domains);
668900
+ return Deleted;
668901
+ });
668902
+ }
668903
+ exports.deleteCorsDomain = deleteCorsDomain;
668904
+
668905
+
667493
668906
  /***/ }),
667494
668907
 
667495
668908
  /***/ 59520:
@@ -676342,7 +677755,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
676342
677755
  return (mod && mod.__esModule) ? mod : { "default": mod };
676343
677756
  };
676344
677757
  Object.defineProperty(exports, "__esModule", ({ value: true }));
676345
- exports.getStorageService = exports.getMangerService = void 0;
677758
+ exports.getEnvService = exports.getStorageService = exports.getMangerService = void 0;
676346
677759
  const manager_node_1 = __importDefault(__webpack_require__(95492));
676347
677760
  const toolbox_1 = __webpack_require__(25901);
676348
677761
  const credential_1 = __webpack_require__(13930);
@@ -676379,6 +677792,22 @@ function getStorageService(envId) {
676379
677792
  });
676380
677793
  }
676381
677794
  exports.getStorageService = getStorageService;
677795
+ function getEnvService(envId) {
677796
+ return __awaiter(this, void 0, void 0, function* () {
677797
+ const { secretId, secretKey, token } = yield (0, credential_1.checkAndGetCredential)(true);
677798
+ const region = yield (0, toolbox_1.getRegion)();
677799
+ const app = new manager_node_1.default({
677800
+ token,
677801
+ envId,
677802
+ secretId,
677803
+ region,
677804
+ secretKey,
677805
+ proxy: (0, proxy_1.getProxy)()
677806
+ });
677807
+ return app.env;
677808
+ });
677809
+ }
677810
+ exports.getEnvService = getEnvService;
676382
677811
 
676383
677812
 
676384
677813
  /***/ }),
@@ -756412,6 +757841,118 @@ module.exports = Array.isArray || function (arr) {
756412
757841
  };
756413
757842
 
756414
757843
 
757844
+ /***/ }),
757845
+
757846
+ /***/ 73289:
757847
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
757848
+
757849
+ "use strict";
757850
+
757851
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
757852
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
757853
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
757854
+ 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;
757855
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
757856
+ };
757857
+ var __metadata = (this && this.__metadata) || function (k, v) {
757858
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
757859
+ };
757860
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
757861
+ return function (target, key) { decorator(target, key, paramIndex); }
757862
+ };
757863
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
757864
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
757865
+ return new (P || (P = Promise))(function (resolve, reject) {
757866
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
757867
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
757868
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
757869
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
757870
+ });
757871
+ };
757872
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
757873
+ exports.RmDomainsCommand = void 0;
757874
+ const error_1 = __webpack_require__(66759);
757875
+ const interactive_1 = __webpack_require__(57695);
757876
+ const common_1 = __webpack_require__(48431);
757877
+ const utils_1 = __webpack_require__(82079);
757878
+ const decorators_1 = __webpack_require__(93480);
757879
+ const domains_1 = __webpack_require__(17375);
757880
+ const i18n_1 = __webpack_require__(69258);
757881
+ let RmDomainsCommand = class RmDomainsCommand extends common_1.Command {
757882
+ get options() {
757883
+ return {
757884
+ cmd: 'domains',
757885
+ childCmd: 'rm <domain>',
757886
+ options: [],
757887
+ desc: (0, i18n_1.t)('解绑自定义域名。仅当域名下无路由绑定时可删除,否则需先删除路由'),
757888
+ examples: [
757889
+ 'tcb domains rm api.example.com'
757890
+ ]
757891
+ };
757892
+ }
757893
+ execute(params, envId, log) {
757894
+ return __awaiter(this, void 0, void 0, function* () {
757895
+ log.verbose(params);
757896
+ const domain = params === null || params === void 0 ? void 0 : params[0];
757897
+ if (!domain) {
757898
+ throw new error_1.CloudBaseError({
757899
+ message: (0, i18n_1.t)('请提供要删除的域名'),
757900
+ code: 'INVALID_PARAM',
757901
+ solution: [(0, i18n_1.t)('请在命令后面添加要删除的域名,例如: tcb domains rm api.example.com -e <envId>')]
757902
+ });
757903
+ }
757904
+ const confirm = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('确认解绑自定义域名 [{{domain}}]?\n\n注意:如果域名下还有路由绑定,删除将会失败', {
757905
+ domain
757906
+ }), true);
757907
+ if (!confirm) {
757908
+ throw new error_1.CloudBaseError({
757909
+ message: (0, i18n_1.t)('操作已取消'),
757910
+ code: 'USER_CANCEL'
757911
+ });
757912
+ }
757913
+ try {
757914
+ yield (0, domains_1.deleteCustomDomain)({
757915
+ envId,
757916
+ domain
757917
+ });
757918
+ }
757919
+ catch (e) {
757920
+ throw new error_1.CloudBaseError({
757921
+ message: e.message || (0, i18n_1.t)('解绑域名失败'),
757922
+ code: 'API_ERROR',
757923
+ solution: [
757924
+ (0, i18n_1.t)('如果域名下有路由绑定,请先使用 tcb routes delete 删除路由'),
757925
+ (0, i18n_1.t)('使用 tcb routes list -d {{domain}} 查看域名下的路由', { domain })
757926
+ ],
757927
+ original: e
757928
+ });
757929
+ }
757930
+ if ((0, utils_1.isJsonOutput)()) {
757931
+ (0, utils_1.outputJson)({
757932
+ domain,
757933
+ message: (0, i18n_1.t)('解绑自定义域名成功')
757934
+ });
757935
+ return;
757936
+ }
757937
+ log.success((0, i18n_1.t)('成功解绑自定义域名 [{{domain}}]', { domain }));
757938
+ });
757939
+ }
757940
+ };
757941
+ __decorate([
757942
+ (0, decorators_1.InjectParams)(),
757943
+ __param(0, (0, decorators_1.ArgsParams)()),
757944
+ __param(1, (0, decorators_1.EnvId)()),
757945
+ __param(2, (0, decorators_1.Log)()),
757946
+ __metadata("design:type", Function),
757947
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
757948
+ __metadata("design:returntype", Promise)
757949
+ ], RmDomainsCommand.prototype, "execute", null);
757950
+ RmDomainsCommand = __decorate([
757951
+ (0, common_1.ICommand)()
757952
+ ], RmDomainsCommand);
757953
+ exports.RmDomainsCommand = RmDomainsCommand;
757954
+
757955
+
756415
757956
  /***/ }),
756416
757957
 
756417
757958
  /***/ 73316:
@@ -793515,25 +795056,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
793515
795056
  return (mod && mod.__esModule) ? mod : { "default": mod };
793516
795057
  };
793517
795058
  Object.defineProperty(exports, "__esModule", ({ value: true }));
793518
- exports.selectInstance = exports.jsonOutput = exports.jsonOption = exports.offsetOption = exports.limitOption = exports.yesOption = exports.instanceIdOption = void 0;
795059
+ exports.selectInstance = exports.offsetOption = exports.limitOption = exports.instanceIdOption = void 0;
793519
795060
  const inquirer_1 = __importDefault(__webpack_require__(6403));
793520
795061
  const i18n_1 = __webpack_require__(69258);
795062
+ const error_1 = __webpack_require__(66759);
793521
795063
  const mysql_1 = __webpack_require__(69116);
793522
- exports.instanceIdOption = { flags: '--instanceId <instanceId>', desc: (0, i18n_1.t)('实例 Id') };
793523
- exports.yesOption = { flags: '-y, --yes', desc: (0, i18n_1.t)('跳过确认提示,直接执行') };
795064
+ exports.instanceIdOption = { flags: '--instance-id <instanceId>', desc: (0, i18n_1.t)('实例 Id') };
793524
795065
  exports.limitOption = { flags: '--limit <limit>', desc: (0, i18n_1.t)('返回数量,默认 20') };
793525
795066
  exports.offsetOption = { flags: '--offset <offset>', desc: (0, i18n_1.t)('偏移量,默认 0') };
793526
- exports.jsonOption = { flags: '--json', desc: (0, i18n_1.t)('以 JSON 格式输出结果') };
793527
- function jsonOutput(result) {
793528
- console.log(JSON.stringify(result, null, 2));
793529
- }
793530
- exports.jsonOutput = jsonOutput;
793531
795067
  function selectInstance(envId) {
793532
795068
  return __awaiter(this, void 0, void 0, function* () {
793533
795069
  const result = yield (0, mysql_1.describeInstances)({ envId });
793534
795070
  const instances = result.InstanceSet || [];
793535
795071
  if (instances.length === 0) {
793536
- throw new Error((0, i18n_1.t)('当前环境下没有 MySQL 实例'));
795072
+ throw new error_1.CloudBaseError({
795073
+ message: (0, i18n_1.t)('当前环境下没有 MySQL 实例'),
795074
+ code: 'RESOURCE_NOT_FOUND',
795075
+ solution: [
795076
+ (0, i18n_1.t)('请先创建 MySQL 实例'),
795077
+ (0, i18n_1.t)('运行 `tcb db instance list` 查看实例列表')
795078
+ ]
795079
+ });
793537
795080
  }
793538
795081
  const choices = instances.map((item) => ({
793539
795082
  name: `${item.InstanceName || item.InstanceId} (${item.InstanceId}) [${item.StatusDesc || item.Status}]`,
@@ -835559,6 +837102,175 @@ exports.coerce = {
835559
837102
  exports.NEVER = parseUtil_js_1.INVALID;
835560
837103
 
835561
837104
 
837105
+ /***/ }),
837106
+
837107
+ /***/ 84876:
837108
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
837109
+
837110
+ "use strict";
837111
+
837112
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
837113
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
837114
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
837115
+ 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;
837116
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
837117
+ };
837118
+ var __metadata = (this && this.__metadata) || function (k, v) {
837119
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
837120
+ };
837121
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
837122
+ return function (target, key) { decorator(target, key, paramIndex); }
837123
+ };
837124
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
837125
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
837126
+ return new (P || (P = Promise))(function (resolve, reject) {
837127
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
837128
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
837129
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
837130
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
837131
+ });
837132
+ };
837133
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
837134
+ exports.DeleteRoutesCommand = void 0;
837135
+ const error_1 = __webpack_require__(66759);
837136
+ const interactive_1 = __webpack_require__(57695);
837137
+ const common_1 = __webpack_require__(48431);
837138
+ const utils_1 = __webpack_require__(82079);
837139
+ const decorators_1 = __webpack_require__(93480);
837140
+ const routes_1 = __webpack_require__(46212);
837141
+ const i18n_1 = __webpack_require__(69258);
837142
+ let DeleteRoutesCommand = class DeleteRoutesCommand extends common_1.Command {
837143
+ get options() {
837144
+ return {
837145
+ cmd: 'routes',
837146
+ childCmd: 'delete <domain>',
837147
+ options: [
837148
+ {
837149
+ flags: '-p, --path <paths>',
837150
+ desc: (0, i18n_1.t)('要删除的路由路径,多个路径用逗号分隔(必填)')
837151
+ }
837152
+ ],
837153
+ desc: (0, i18n_1.t)('删除 HTTP 服务路由。删除指定域名下的特定路由'),
837154
+ examples: [
837155
+ 'tcb routes delete api.example.com -e envId -p /api/*',
837156
+ 'tcb routes delete api.example.com -e envId -p "/api/v1/*,/api/v2/*"'
837157
+ ]
837158
+ };
837159
+ }
837160
+ execute(params, envId, options, log) {
837161
+ return __awaiter(this, void 0, void 0, function* () {
837162
+ log.verbose(params);
837163
+ const domain = params === null || params === void 0 ? void 0 : params[0];
837164
+ if (!domain) {
837165
+ throw new error_1.CloudBaseError({
837166
+ message: (0, i18n_1.t)('请指定要删除的域名'),
837167
+ code: 'MISSING_PARAM',
837168
+ solution: [(0, i18n_1.t)('示例: tcb routes delete example.com -e envId -p /api/*')]
837169
+ });
837170
+ }
837171
+ if (!options.path) {
837172
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请使用 -p, --path 参数指定要删除的路由路径,例如:tcb routes delete {{domain}} -e {{envId}} -p /api/*', {
837173
+ domain,
837174
+ envId
837175
+ }));
837176
+ }
837177
+ const paths = options.path.split(',').map((p) => p.trim()).filter(Boolean);
837178
+ if (paths.length === 0) {
837179
+ throw new error_1.CloudBaseError((0, i18n_1.t)('路由路径不能为空'));
837180
+ }
837181
+ let domains = [];
837182
+ try {
837183
+ const result = yield (0, routes_1.getHTTPServiceRoutes)({
837184
+ envId,
837185
+ });
837186
+ domains = result.domains;
837187
+ }
837188
+ catch (e) {
837189
+ throw new error_1.CloudBaseError({
837190
+ message: e.message || (0, i18n_1.t)('获取路由列表失败'),
837191
+ code: 'API_ERROR',
837192
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
837193
+ original: e
837194
+ });
837195
+ }
837196
+ const targetDomain = domains.find((d) => d.Domain === domain);
837197
+ if (!targetDomain) {
837198
+ throw new error_1.CloudBaseError((0, i18n_1.t)('域名 [{{domain}}] 不存在', { domain }));
837199
+ }
837200
+ const existingRoutes = targetDomain.Routes || [];
837201
+ const existingPaths = existingRoutes.map((r) => r.Path);
837202
+ const notFoundPaths = [];
837203
+ paths.forEach((path) => {
837204
+ if (!existingPaths.includes(path)) {
837205
+ notFoundPaths.push(path);
837206
+ }
837207
+ });
837208
+ if (notFoundPaths.length > 0) {
837209
+ throw new error_1.CloudBaseError((0, i18n_1.t)('域名 [{{domain}}] 下不存在以下路由:{{paths}}', {
837210
+ domain,
837211
+ paths: notFoundPaths.join(', ')
837212
+ }));
837213
+ }
837214
+ let confirmMessage;
837215
+ if (paths.length === 1) {
837216
+ confirmMessage = (0, i18n_1.t)('确认删除域名 [{{domain}}] 下的路由 [{{path}}]?', { domain, path: paths[0] });
837217
+ }
837218
+ else {
837219
+ confirmMessage = (0, i18n_1.t)('确认删除域名 [{{domain}}] 下的以下路由?\n{{paths}}', {
837220
+ domain,
837221
+ paths: paths.map((p) => ` - ${p}`).join('\n')
837222
+ });
837223
+ }
837224
+ const confirm = yield (0, interactive_1.autoConfirm)(confirmMessage, true);
837225
+ if (!confirm) {
837226
+ throw new error_1.CloudBaseError({
837227
+ message: (0, i18n_1.t)('操作已取消'),
837228
+ code: 'USER_CANCEL'
837229
+ });
837230
+ }
837231
+ try {
837232
+ yield (0, routes_1.deleteHTTPServiceRoute)({
837233
+ envId,
837234
+ domain,
837235
+ paths
837236
+ });
837237
+ }
837238
+ catch (e) {
837239
+ throw new error_1.CloudBaseError({
837240
+ message: e.message || (0, i18n_1.t)('删除路由失败'),
837241
+ code: 'API_ERROR',
837242
+ solution: [(0, i18n_1.t)('请检查路由是否存在')],
837243
+ original: e
837244
+ });
837245
+ }
837246
+ if ((0, utils_1.isJsonOutput)()) {
837247
+ (0, utils_1.outputJson)({
837248
+ domain,
837249
+ paths,
837250
+ message: (0, i18n_1.t)('成功删除 {{count}} 个路由', { count: paths.length })
837251
+ });
837252
+ return;
837253
+ }
837254
+ log.success((0, i18n_1.t)('成功删除 {{count}} 个路由', { count: paths.length }));
837255
+ });
837256
+ }
837257
+ };
837258
+ __decorate([
837259
+ (0, decorators_1.InjectParams)(),
837260
+ __param(0, (0, decorators_1.ArgsParams)()),
837261
+ __param(1, (0, decorators_1.EnvId)()),
837262
+ __param(2, (0, decorators_1.ArgsOptions)()),
837263
+ __param(3, (0, decorators_1.Log)()),
837264
+ __metadata("design:type", Function),
837265
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
837266
+ __metadata("design:returntype", Promise)
837267
+ ], DeleteRoutesCommand.prototype, "execute", null);
837268
+ DeleteRoutesCommand = __decorate([
837269
+ (0, common_1.ICommand)()
837270
+ ], DeleteRoutesCommand);
837271
+ exports.DeleteRoutesCommand = DeleteRoutesCommand;
837272
+
837273
+
835562
837274
  /***/ }),
835563
837275
 
835564
837276
  /***/ 84881:
@@ -875058,7 +876770,7 @@ let CreateUserCommand = class CreateUserCommand extends common_1.Command {
875058
876770
  throw new error_1.CloudBaseError({
875059
876771
  message: (0, i18n_1.t)('请指定用户名,例如:tcb user create zhangsan'),
875060
876772
  code: 'MISSING_PARAM',
875061
- solution: [(0, i18n_1.t)('用法:tcb user create <name> --envId <envId>')]
876773
+ solution: [(0, i18n_1.t)('用法:tcb user create <name> --env-id <envId>')]
875062
876774
  });
875063
876775
  }
875064
876776
  if (options.type) {
@@ -883585,6 +885297,7 @@ const common_1 = __webpack_require__(48431);
883585
885297
  const decorators_1 = __webpack_require__(93480);
883586
885298
  const log_1 = __webpack_require__(17793);
883587
885299
  const i18n_1 = __webpack_require__(69258);
885300
+ const error_1 = __webpack_require__(66759);
883588
885301
  const docs_1 = __webpack_require__(53481);
883589
885302
  let DocsListCommand = class DocsListCommand extends common_1.Command {
883590
885303
  get options() {
@@ -883605,8 +885318,12 @@ let DocsListCommand = class DocsListCommand extends common_1.Command {
883605
885318
  modules = yield svc.listModules();
883606
885319
  }
883607
885320
  catch (e) {
883608
- log.error((0, i18n_1.t)('获取文档模块列表失败:') + e.message);
883609
- return;
885321
+ throw new error_1.CloudBaseError({
885322
+ message: (0, i18n_1.t)('获取文档模块列表失败:') + e.message,
885323
+ code: 'API_ERROR',
885324
+ solution: [(0, i18n_1.t)('检查网络连接是否正常')],
885325
+ original: e
885326
+ });
883610
885327
  }
883611
885328
  log.log(chalk_1.default.bold.cyan((0, i18n_1.t)('\n文档站业务模块列表:')));
883612
885329
  modules.forEach((name, i) => {
@@ -883643,8 +885360,10 @@ let DocsReadCommand = class DocsReadCommand extends common_1.Command {
883643
885360
  return __awaiter(this, void 0, void 0, function* () {
883644
885361
  const input = (_a = params === null || params === void 0 ? void 0 : params[0]) === null || _a === void 0 ? void 0 : _a.join(' ');
883645
885362
  if (!input) {
883646
- log.error((0, i18n_1.t)('请提供模块名、文档标题或文档URL地址'));
883647
- return;
885363
+ throw new error_1.CloudBaseError({
885364
+ message: (0, i18n_1.t)('请提供模块名、文档标题或文档URL地址'),
885365
+ solution: [(0, i18n_1.t)('用法: tcb docs read <模块名|文档标题|文档URL>')]
885366
+ });
883648
885367
  }
883649
885368
  const svc = yield (0, docs_1.getDocsService)();
883650
885369
  try {
@@ -883660,7 +885379,14 @@ let DocsReadCommand = class DocsReadCommand extends common_1.Command {
883660
885379
  }
883661
885380
  }
883662
885381
  catch (e) {
883663
- log.error((0, i18n_1.t)('未找到模块或文档,请确保是否有该模块,先执行docs list获取一级模块名,再read读取一级模块名获取相关url地址:') + e.message);
885382
+ throw new error_1.CloudBaseError({
885383
+ message: (0, i18n_1.t)('未找到模块或文档:') + e.message,
885384
+ solution: [
885385
+ (0, i18n_1.t)('先执行 tcb docs list 获取一级模块名'),
885386
+ (0, i18n_1.t)('再使用 tcb docs read <模块名> 读取相关文档')
885387
+ ],
885388
+ original: e
885389
+ });
883664
885390
  }
883665
885391
  });
883666
885392
  }
@@ -883693,8 +885419,10 @@ let DocsSearchCommand = class DocsSearchCommand extends common_1.Command {
883693
885419
  return __awaiter(this, void 0, void 0, function* () {
883694
885420
  const keyword = (_b = (_a = ctx.params) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.join(' ');
883695
885421
  if (!keyword) {
883696
- log.error((0, i18n_1.t)('请提供搜索关键词'));
883697
- return;
885422
+ throw new error_1.CloudBaseError({
885423
+ message: (0, i18n_1.t)('请提供搜索关键词'),
885424
+ solution: [(0, i18n_1.t)('用法: tcb docs search <关键词>')]
885425
+ });
883698
885426
  }
883699
885427
  const svc = yield (0, docs_1.getDocsService)();
883700
885428
  let results;
@@ -883702,8 +885430,12 @@ let DocsSearchCommand = class DocsSearchCommand extends common_1.Command {
883702
885430
  results = yield svc.searchDocs(keyword);
883703
885431
  }
883704
885432
  catch (e) {
883705
- log.error((0, i18n_1.t)('搜索失败:') + e.message);
883706
- return;
885433
+ throw new error_1.CloudBaseError({
885434
+ message: (0, i18n_1.t)('搜索失败:') + e.message,
885435
+ code: 'API_ERROR',
885436
+ solution: [(0, i18n_1.t)('检查网络连接是否正常')],
885437
+ original: e
885438
+ });
883707
885439
  }
883708
885440
  if (!results.length) {
883709
885441
  log.log((0, i18n_1.t)('未找到相关文档'));
@@ -940842,6 +942574,10 @@ const outputHelpInfo = () => {
940842
942574
  user [cmd] ${(0, i18n_1.t)('用户管理操作')}
940843
942575
  permission [cmd] ${(0, i18n_1.t)('资源权限管理操作')}
940844
942576
  role [cmd] ${(0, i18n_1.t)('角色管理操作')}
942577
+ cors [cmd] ${(0, i18n_1.t)('安全域名(跨域)配置')}
942578
+ routes [cmd] ${(0, i18n_1.t)('路由管理配置')}
942579
+ domains [cmd] ${(0, i18n_1.t)('自定义域名配置')}
942580
+
940845
942581
  `;
940846
942582
  const options = `
940847
942583
  ${(0, i18n_1.t)('选项')}
@@ -948081,6 +949817,132 @@ class CloudBase {
948081
949817
  module.exports = CloudBase;
948082
949818
 
948083
949819
 
949820
+ /***/ }),
949821
+
949822
+ /***/ 95499:
949823
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
949824
+
949825
+ "use strict";
949826
+
949827
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
949828
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
949829
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
949830
+ 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;
949831
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
949832
+ };
949833
+ var __metadata = (this && this.__metadata) || function (k, v) {
949834
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
949835
+ };
949836
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
949837
+ return function (target, key) { decorator(target, key, paramIndex); }
949838
+ };
949839
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
949840
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
949841
+ return new (P || (P = Promise))(function (resolve, reject) {
949842
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
949843
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
949844
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
949845
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
949846
+ });
949847
+ };
949848
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
949849
+ exports.AddCorsCommand = void 0;
949850
+ const error_1 = __webpack_require__(66759);
949851
+ const interactive_1 = __webpack_require__(57695);
949852
+ const common_1 = __webpack_require__(48431);
949853
+ const utils_1 = __webpack_require__(82079);
949854
+ const decorators_1 = __webpack_require__(93480);
949855
+ const cors_1 = __webpack_require__(59515);
949856
+ const i18n_1 = __webpack_require__(69258);
949857
+ let AddCorsCommand = class AddCorsCommand extends common_1.Command {
949858
+ get options() {
949859
+ return {
949860
+ cmd: 'cors',
949861
+ childCmd: 'add <domain>',
949862
+ options: [],
949863
+ desc: (0, i18n_1.t)('添加安全域名,多个以逗号分隔')
949864
+ };
949865
+ }
949866
+ execute(params, envId, log) {
949867
+ return __awaiter(this, void 0, void 0, function* () {
949868
+ log.verbose(params);
949869
+ const domain = params === null || params === void 0 ? void 0 : params[0];
949870
+ const domains = domain.split(',');
949871
+ const confirm = yield (0, interactive_1.autoConfirm)((0, i18n_1.t)('确认添加以下安全域名: {{domains}} ?', { domains }), true);
949872
+ if (!confirm) {
949873
+ throw new error_1.CloudBaseError({
949874
+ message: (0, i18n_1.t)('操作终止!'),
949875
+ code: 'USER_CANCEL'
949876
+ });
949877
+ }
949878
+ let corsDomains = [];
949879
+ try {
949880
+ const result = yield (0, cors_1.getCorsDomains)({
949881
+ envId
949882
+ });
949883
+ corsDomains = result.map((item) => item.Domain);
949884
+ }
949885
+ catch (e) {
949886
+ throw new error_1.CloudBaseError({
949887
+ message: e.message || (0, i18n_1.t)('获取安全域名列表失败'),
949888
+ code: 'API_ERROR',
949889
+ solution: [(0, i18n_1.t)('请检查环境 ID 是否正确')],
949890
+ original: e
949891
+ });
949892
+ }
949893
+ const exitDomains = [];
949894
+ domains.forEach((item) => {
949895
+ if (corsDomains.includes(item)) {
949896
+ exitDomains.push(item);
949897
+ }
949898
+ });
949899
+ if (exitDomains.length) {
949900
+ throw new error_1.CloudBaseError({
949901
+ message: (0, i18n_1.t)('域名 [{{domains}}] 已存在!', { domains: exitDomains.join(', ') }),
949902
+ code: 'INVALID_PARAM',
949903
+ solution: [
949904
+ (0, i18n_1.t)('如需重新配置,请先删除已存在的域名'),
949905
+ (0, i18n_1.t)('使用 tcb cors rm {{domains}} -e <envId> 删除后重试', { domains: exitDomains.join(',') })
949906
+ ]
949907
+ });
949908
+ }
949909
+ try {
949910
+ yield (0, cors_1.createCorsDomain)({
949911
+ envId,
949912
+ domains: domains
949913
+ });
949914
+ }
949915
+ catch (e) {
949916
+ throw new error_1.CloudBaseError({
949917
+ message: e.message || (0, i18n_1.t)('添加安全域名失败'),
949918
+ code: 'API_ERROR',
949919
+ solution: [(0, i18n_1.t)('请检查域名格式是否正确')],
949920
+ original: e
949921
+ });
949922
+ }
949923
+ if ((0, utils_1.isJsonOutput)()) {
949924
+ (0, utils_1.outputJson)({ message: (0, i18n_1.t)('添加安全域名成功') });
949925
+ return;
949926
+ }
949927
+ log.success((0, i18n_1.t)('添加安全域名成功!'));
949928
+ });
949929
+ }
949930
+ };
949931
+ __decorate([
949932
+ (0, decorators_1.InjectParams)(),
949933
+ __param(0, (0, decorators_1.ArgsParams)()),
949934
+ __param(1, (0, decorators_1.EnvId)()),
949935
+ __param(2, (0, decorators_1.Log)()),
949936
+ __metadata("design:type", Function),
949937
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
949938
+ __metadata("design:returntype", Promise)
949939
+ ], AddCorsCommand.prototype, "execute", null);
949940
+ AddCorsCommand = __decorate([
949941
+ (0, common_1.ICommand)()
949942
+ ], AddCorsCommand);
949943
+ exports.AddCorsCommand = AddCorsCommand;
949944
+
949945
+
948084
949946
  /***/ }),
948085
949947
 
948086
949948
  /***/ 95502:
@@ -969975,18 +971837,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
969975
971837
  step((generator = generator.apply(thisArg, _arguments || [])).next());
969976
971838
  });
969977
971839
  };
969978
- var __importDefault = (this && this.__importDefault) || function (mod) {
969979
- return (mod && mod.__esModule) ? mod : { "default": mod };
969980
- };
969981
971840
  Object.defineProperty(exports, "__esModule", ({ value: true }));
969982
971841
  exports.BackupDropCommand = exports.BackupRestoreCommand = exports.BackupListCommand = exports.BackupCreateCommand = void 0;
969983
971842
  const common_1 = __webpack_require__(48431);
969984
971843
  const decorators_1 = __webpack_require__(93480);
969985
971844
  const utils_1 = __webpack_require__(82079);
969986
- const utils_2 = __webpack_require__(75213);
969987
971845
  const mysql_1 = __webpack_require__(69116);
969988
971846
  const common_2 = __webpack_require__(79101);
969989
- const inquirer_1 = __importDefault(__webpack_require__(6403));
971847
+ const common_3 = __webpack_require__(8906);
971848
+ const error_1 = __webpack_require__(66759);
969990
971849
  const i18n_1 = __webpack_require__(69258);
969991
971850
  let BackupCreateCommand = class BackupCreateCommand extends common_1.Command {
969992
971851
  get options() {
@@ -969997,61 +971856,45 @@ let BackupCreateCommand = class BackupCreateCommand extends common_1.Command {
969997
971856
  options: [
969998
971857
  { flags: '--type <type>', desc: (0, i18n_1.t)('备份类型: snapshot(快照) 或 logic(逻辑)') },
969999
971858
  { flags: '--databases <databases>', desc: (0, i18n_1.t)('要备份的数据库列表,逗号分隔(仅逻辑备份有效)') },
970000
- { flags: '--name <name>', desc: (0, i18n_1.t)('备份备注名') },
970001
- common_2.jsonOption
971859
+ { flags: '--name <name>', desc: (0, i18n_1.t)('备份备注名') }
970002
971860
  ],
970003
971861
  desc: (0, i18n_1.t)('创建 MySQL 备份'),
970004
971862
  requiredEnvId: false,
970005
971863
  autoRunLogin: true
970006
971864
  };
970007
971865
  }
970008
- execute(envId, options, log) {
971866
+ execute(ctx, envId, options, log) {
971867
+ var _a;
970009
971868
  return __awaiter(this, void 0, void 0, function* () {
970010
- const isJson = options.json;
970011
- let selectedEnvId = envId;
970012
- if (!selectedEnvId) {
970013
- if (isJson) {
970014
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
970015
- return;
970016
- }
970017
- selectedEnvId = yield (0, utils_2.selectEnv)();
970018
- }
971869
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
971870
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
970019
971871
  const loading = (0, utils_1.loadingFactory)();
970020
- try {
970021
- const backupType = options.type;
970022
- const databases = options.databases ? options.databases.split(',').map((s) => s.trim()) : undefined;
970023
- loading.start((0, i18n_1.t)('正在创建备份...'));
970024
- const result = yield (0, mysql_1.createBackup)({
970025
- envId: selectedEnvId,
970026
- type: backupType,
970027
- databases,
970028
- name: options.name
970029
- });
970030
- loading.stop();
970031
- if (isJson) {
970032
- (0, common_2.jsonOutput)({ code: 0, data: { flowId: result.FlowId } });
970033
- return;
970034
- }
970035
- log.success((0, i18n_1.t)('备份任务已提交,FlowId: {{flowId}}', { flowId: String(result.FlowId) }));
970036
- }
970037
- catch (e) {
970038
- loading.stop();
970039
- if (isJson) {
970040
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
970041
- return;
970042
- }
970043
- throw e;
971872
+ loading.start((0, i18n_1.t)('正在创建备份...'));
971873
+ const backupType = options.type;
971874
+ const databases = options.databases ? options.databases.split(',').map((s) => s.trim()) : undefined;
971875
+ const result = yield (0, mysql_1.createBackup)({
971876
+ envId: selectedEnvId,
971877
+ type: backupType,
971878
+ databases,
971879
+ name: options.name
971880
+ });
971881
+ loading.stop();
971882
+ if (isJson) {
971883
+ (0, utils_1.outputJson)({ flowId: result.FlowId });
971884
+ return;
970044
971885
  }
971886
+ log.success((0, i18n_1.t)('备份任务已提交,FlowId: {{flowId}}', { flowId: String(result.FlowId) }));
970045
971887
  });
970046
971888
  }
970047
971889
  };
970048
971890
  __decorate([
970049
971891
  (0, decorators_1.InjectParams)(),
970050
- __param(0, (0, decorators_1.EnvId)()),
970051
- __param(1, (0, decorators_1.ArgsOptions)()),
970052
- __param(2, (0, decorators_1.Log)()),
971892
+ __param(0, (0, decorators_1.CmdContext)()),
971893
+ __param(1, (0, decorators_1.EnvId)()),
971894
+ __param(2, (0, decorators_1.ArgsOptions)()),
971895
+ __param(3, (0, decorators_1.Log)()),
970053
971896
  __metadata("design:type", Function),
970054
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
971897
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
970055
971898
  __metadata("design:returntype", Promise)
970056
971899
  ], BackupCreateCommand.prototype, "execute", null);
970057
971900
  BackupCreateCommand = __decorate([
@@ -970067,97 +971910,76 @@ let BackupListCommand = class BackupListCommand extends common_1.Command {
970067
971910
  options: [
970068
971911
  common_2.limitOption,
970069
971912
  common_2.offsetOption,
970070
- { flags: '--startTime <startTime>', desc: (0, i18n_1.t)('备份开始时间') },
970071
- { flags: '--endTime <endTime>', desc: (0, i18n_1.t)('备份结束时间') },
970072
- common_2.jsonOption
971913
+ { flags: '--start-time <startTime>', desc: (0, i18n_1.t)('备份开始时间') },
971914
+ { flags: '--end-time <endTime>', desc: (0, i18n_1.t)('备份结束时间') }
970073
971915
  ],
970074
971916
  desc: (0, i18n_1.t)('列出 MySQL 备份'),
970075
971917
  requiredEnvId: false,
970076
971918
  autoRunLogin: true
970077
971919
  };
970078
971920
  }
970079
- execute(envId, options, log) {
971921
+ execute(ctx, envId, options, log) {
971922
+ var _a;
970080
971923
  return __awaiter(this, void 0, void 0, function* () {
970081
- const isJson = options.json;
970082
- let selectedEnvId = envId;
970083
- if (!selectedEnvId) {
970084
- if (isJson) {
970085
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
970086
- return;
970087
- }
970088
- selectedEnvId = yield (0, utils_2.selectEnv)();
970089
- }
971924
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
971925
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
970090
971926
  const loading = (0, utils_1.loadingFactory)();
970091
- try {
970092
- const limit = options.limit ? Number(options.limit) : undefined;
970093
- const offset = options.offset ? Number(options.offset) : undefined;
970094
- loading.start((0, i18n_1.t)('获取备份列表中...'));
970095
- const result = yield (0, mysql_1.describeBackupList)({
970096
- envId: selectedEnvId,
970097
- limit,
970098
- offset,
970099
- startTime: options.startTime,
970100
- endTime: options.endTime
970101
- });
970102
- loading.stop();
970103
- const backups = result.BackupList || [];
970104
- if (isJson) {
970105
- (0, common_2.jsonOutput)({
970106
- code: 0,
970107
- data: {
970108
- backups,
970109
- totalCount: result.TotalCount || backups.length
970110
- }
970111
- });
970112
- return;
970113
- }
970114
- if (backups.length === 0) {
970115
- log.info((0, i18n_1.t)('当前环境下没有备份记录'));
970116
- return;
970117
- }
970118
- const head = [
970119
- (0, i18n_1.t)('备份 ID'),
970120
- (0, i18n_1.t)('文件名'),
970121
- (0, i18n_1.t)('类型'),
970122
- (0, i18n_1.t)('方式'),
970123
- (0, i18n_1.t)('状态'),
970124
- (0, i18n_1.t)('大小'),
970125
- (0, i18n_1.t)('开始时间'),
970126
- (0, i18n_1.t)('完成时间'),
970127
- (0, i18n_1.t)('备注')
970128
- ];
970129
- const tableData = backups.map((item) => [
970130
- String(item.BackupId),
970131
- item.FileName || '-',
970132
- item.BackupType || '-',
970133
- item.BackupMethod || '-',
970134
- item.BackupStatus || '-',
970135
- item.FileSize ? formatFileSize(item.FileSize) : '-',
970136
- item.StartTime || '-',
970137
- item.FinishTime || '-',
970138
- item.BackupName || '-'
970139
- ]);
970140
- (0, utils_1.printHorizontalTable)(head, tableData);
970141
- log.info((0, i18n_1.t)('共 {{count}} 个备份', { count: String(result.TotalCount || backups.length) }));
971927
+ const limit = options.limit ? Number(options.limit) : undefined;
971928
+ const offset = options.offset ? Number(options.offset) : undefined;
971929
+ loading.start((0, i18n_1.t)('获取备份列表中...'));
971930
+ const result = yield (0, mysql_1.describeBackupList)({
971931
+ envId: selectedEnvId,
971932
+ limit,
971933
+ offset,
971934
+ startTime: options.startTime,
971935
+ endTime: options.endTime
971936
+ });
971937
+ loading.stop();
971938
+ const backups = result.BackupList || [];
971939
+ const totalCount = result.TotalCount || backups.length;
971940
+ if (isJson) {
971941
+ (0, utils_1.outputJson)(backups, { total: totalCount, limit, offset });
971942
+ return;
970142
971943
  }
970143
- catch (e) {
970144
- loading.stop();
970145
- if (isJson) {
970146
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
970147
- return;
970148
- }
970149
- throw e;
971944
+ if (backups.length === 0) {
971945
+ log.info((0, i18n_1.t)('当前环境下没有备份记录'));
971946
+ return;
970150
971947
  }
971948
+ const head = [
971949
+ (0, i18n_1.t)('备份 ID'),
971950
+ (0, i18n_1.t)('文件名'),
971951
+ (0, i18n_1.t)('类型'),
971952
+ (0, i18n_1.t)('方式'),
971953
+ (0, i18n_1.t)('状态'),
971954
+ (0, i18n_1.t)('大小'),
971955
+ (0, i18n_1.t)('开始时间'),
971956
+ (0, i18n_1.t)('完成时间'),
971957
+ (0, i18n_1.t)('备注')
971958
+ ];
971959
+ const tableData = backups.map((item) => [
971960
+ String(item.BackupId),
971961
+ item.FileName || '-',
971962
+ item.BackupType || '-',
971963
+ item.BackupMethod || '-',
971964
+ item.BackupStatus || '-',
971965
+ item.FileSize ? formatFileSize(item.FileSize) : '-',
971966
+ item.StartTime || '-',
971967
+ item.FinishTime || '-',
971968
+ item.BackupName || '-'
971969
+ ]);
971970
+ (0, utils_1.printHorizontalTable)(head, tableData);
971971
+ log.info((0, i18n_1.t)('共 {{count}} 个备份', { count: String(totalCount) }));
970151
971972
  });
970152
971973
  }
970153
971974
  };
970154
971975
  __decorate([
970155
971976
  (0, decorators_1.InjectParams)(),
970156
- __param(0, (0, decorators_1.EnvId)()),
970157
- __param(1, (0, decorators_1.ArgsOptions)()),
970158
- __param(2, (0, decorators_1.Log)()),
971977
+ __param(0, (0, decorators_1.CmdContext)()),
971978
+ __param(1, (0, decorators_1.EnvId)()),
971979
+ __param(2, (0, decorators_1.ArgsOptions)()),
971980
+ __param(3, (0, decorators_1.Log)()),
970159
971981
  __metadata("design:type", Function),
970160
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
971982
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
970161
971983
  __metadata("design:returntype", Promise)
970162
971984
  ], BackupListCommand.prototype, "execute", null);
970163
971985
  BackupListCommand = __decorate([
@@ -970172,104 +971994,71 @@ let BackupRestoreCommand = class BackupRestoreCommand extends common_1.Command {
970172
971994
  childSubCmd: 'restore',
970173
971995
  options: [
970174
971996
  { flags: '--strategy <strategy>', desc: (0, i18n_1.t)('回档策略: snapRollback(按备份) 或 timeRollback(按时间点)') },
970175
- { flags: '--backupId <backupId>', desc: (0, i18n_1.t)('备份文件 ID(按备份回档时必填)') },
970176
- { flags: '--expectTime <expectTime>', desc: (0, i18n_1.t)('期望回档时间(按时间点回档时必填)') },
970177
- common_2.yesOption,
970178
- common_2.jsonOption
971997
+ { flags: '--backup-id <backupId>', desc: (0, i18n_1.t)('备份文件 ID(按备份回档时必填)') },
971998
+ { flags: '--expect-time <expectTime>', desc: (0, i18n_1.t)('期望回档时间(按时间点回档时必填)') }
970179
971999
  ],
970180
972000
  desc: (0, i18n_1.t)('恢复 MySQL 备份(集群回档)'),
970181
972001
  requiredEnvId: false,
970182
972002
  autoRunLogin: true
970183
972003
  };
970184
972004
  }
970185
- execute(envId, options, log) {
972005
+ execute(ctx, envId, options, log) {
972006
+ var _a;
970186
972007
  return __awaiter(this, void 0, void 0, function* () {
970187
- const isJson = options.json;
970188
- let selectedEnvId = envId;
970189
- if (!selectedEnvId) {
970190
- if (isJson) {
970191
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
970192
- return;
970193
- }
970194
- selectedEnvId = yield (0, utils_2.selectEnv)();
970195
- }
972008
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
972009
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
970196
972010
  const { strategy, backupId, expectTime } = options;
970197
972011
  if (!strategy) {
970198
- if (isJson) {
970199
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --strategy 参数指定回档策略 (snapRollback 或 timeRollback)') });
970200
- return;
970201
- }
970202
- log.error((0, i18n_1.t)('请通过 --strategy 参数指定回档策略 (snapRollback 或 timeRollback)'));
970203
- return;
972012
+ throw new error_1.CloudBaseError({
972013
+ message: (0, i18n_1.t)('请通过 --strategy 参数指定回档策略 (snapRollback 或 timeRollback)'),
972014
+ code: 'MISSING_PARAM',
972015
+ solution: [(0, i18n_1.t)('使用 --strategy snapRollback 或 --strategy timeRollback')]
972016
+ });
970204
972017
  }
970205
972018
  if (strategy === 'snapRollback' && !backupId) {
970206
- if (isJson) {
970207
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('按备份回档时,请通过 --backupId 参数指定备份文件 ID') });
970208
- return;
970209
- }
970210
- log.error((0, i18n_1.t)('按备份回档时,请通过 --backupId 参数指定备份文件 ID'));
970211
- return;
972019
+ throw new error_1.CloudBaseError({
972020
+ message: (0, i18n_1.t)('按备份回档时,请通过 --backup-id 参数指定备份文件 ID'),
972021
+ code: 'MISSING_PARAM',
972022
+ solution: [(0, i18n_1.t)('运行 `tcb db backup list` 查看可用的备份 ID')]
972023
+ });
970212
972024
  }
970213
972025
  if (strategy === 'timeRollback' && !expectTime) {
970214
- if (isJson) {
970215
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('按时间点回档时,请通过 --expectTime 参数指定期望回档时间') });
970216
- return;
970217
- }
970218
- log.error((0, i18n_1.t)('按时间点回档时,请通过 --expectTime 参数指定期望回档时间'));
970219
- return;
972026
+ throw new error_1.CloudBaseError({
972027
+ message: (0, i18n_1.t)('按时间点回档时,请通过 --expect-time 参数指定期望回档时间'),
972028
+ code: 'MISSING_PARAM',
972029
+ solution: [(0, i18n_1.t)('使用 --expect-time 指定期望回档时间')]
972030
+ });
970220
972031
  }
970221
- if (!options.yes) {
970222
- if (isJson) {
970223
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--json 模式下需要配合 --yes 跳过确认') });
970224
- return;
970225
- }
970226
- const { confirm } = yield inquirer_1.default.prompt([
970227
- {
970228
- type: 'confirm',
970229
- name: 'confirm',
970230
- message: (0, i18n_1.t)('确定要执行集群回档操作吗?此操作不可撤销'),
970231
- default: false
970232
- }
970233
- ]);
970234
- if (!confirm) {
970235
- log.info((0, i18n_1.t)('已取消操作'));
970236
- return;
970237
- }
972032
+ const confirmed = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('确定要执行集群回档操作吗?此操作不可撤销'));
972033
+ if (!confirmed) {
972034
+ log.info((0, i18n_1.t)('已取消操作'));
972035
+ return;
970238
972036
  }
970239
972037
  const loading = (0, utils_1.loadingFactory)();
970240
- try {
970241
- loading.start((0, i18n_1.t)('正在提交回档任务...'));
970242
- const result = yield (0, mysql_1.rollBackCluster)({
970243
- envId: selectedEnvId,
970244
- strategy,
970245
- backupId: backupId ? Number(backupId) : undefined,
970246
- expectTime
970247
- });
970248
- loading.stop();
970249
- if (isJson) {
970250
- (0, common_2.jsonOutput)({ code: 0, data: { flowId: result.FlowId } });
970251
- return;
970252
- }
970253
- log.success((0, i18n_1.t)('回档任务已提交,FlowId: {{flowId}}', { flowId: String(result.FlowId) }));
970254
- }
970255
- catch (e) {
970256
- loading.stop();
970257
- if (isJson) {
970258
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
970259
- return;
970260
- }
970261
- throw e;
972038
+ loading.start((0, i18n_1.t)('正在提交回档任务...'));
972039
+ const result = yield (0, mysql_1.rollBackCluster)({
972040
+ envId: selectedEnvId,
972041
+ strategy,
972042
+ backupId: backupId ? Number(backupId) : undefined,
972043
+ expectTime
972044
+ });
972045
+ loading.stop();
972046
+ if (isJson) {
972047
+ (0, utils_1.outputJson)({ flowId: result.FlowId });
972048
+ return;
970262
972049
  }
972050
+ log.success((0, i18n_1.t)('回档任务已提交,FlowId: {{flowId}}', { flowId: String(result.FlowId) }));
970263
972051
  });
970264
972052
  }
970265
972053
  };
970266
972054
  __decorate([
970267
972055
  (0, decorators_1.InjectParams)(),
970268
- __param(0, (0, decorators_1.EnvId)()),
970269
- __param(1, (0, decorators_1.ArgsOptions)()),
970270
- __param(2, (0, decorators_1.Log)()),
972056
+ __param(0, (0, decorators_1.CmdContext)()),
972057
+ __param(1, (0, decorators_1.EnvId)()),
972058
+ __param(2, (0, decorators_1.ArgsOptions)()),
972059
+ __param(3, (0, decorators_1.Log)()),
970271
972060
  __metadata("design:type", Function),
970272
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
972061
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
970273
972062
  __metadata("design:returntype", Promise)
970274
972063
  ], BackupRestoreCommand.prototype, "execute", null);
970275
972064
  BackupRestoreCommand = __decorate([
@@ -970283,85 +972072,54 @@ let BackupDropCommand = class BackupDropCommand extends common_1.Command {
970283
972072
  childCmd: { cmd: 'backup', desc: (0, i18n_1.t)('MySQL 备份管理') },
970284
972073
  childSubCmd: 'drop',
970285
972074
  options: [
970286
- { flags: '--backupId <backupId>', desc: (0, i18n_1.t)('备份文件 ID') },
970287
- common_2.yesOption,
970288
- common_2.jsonOption
972075
+ { flags: '--backup-id <backupId>', desc: (0, i18n_1.t)('备份文件 ID') }
970289
972076
  ],
970290
972077
  desc: (0, i18n_1.t)('删除 MySQL 备份'),
970291
972078
  requiredEnvId: false,
970292
972079
  autoRunLogin: true
970293
972080
  };
970294
972081
  }
970295
- execute(envId, options, log) {
972082
+ execute(ctx, envId, options, log) {
972083
+ var _a;
970296
972084
  return __awaiter(this, void 0, void 0, function* () {
970297
- const isJson = options.json;
970298
- let selectedEnvId = envId;
970299
- if (!selectedEnvId) {
970300
- if (isJson) {
970301
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --envId 指定环境') });
970302
- return;
970303
- }
970304
- selectedEnvId = yield (0, utils_2.selectEnv)();
970305
- }
972085
+ const isJson = (_a = ctx.globalOptions) === null || _a === void 0 ? void 0 : _a.json;
972086
+ const selectedEnvId = yield (0, common_3.ensureEnvId)(envId, isJson);
970306
972087
  const { backupId } = options;
970307
972088
  if (!backupId) {
970308
- if (isJson) {
970309
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('请通过 --backupId 参数指定要删除的备份文件 ID') });
970310
- return;
970311
- }
970312
- log.error((0, i18n_1.t)('请通过 --backupId 参数指定要删除的备份文件 ID'));
970313
- return;
972089
+ throw new error_1.CloudBaseError({
972090
+ message: (0, i18n_1.t)('请通过 --backup-id 参数指定要删除的备份文件 ID'),
972091
+ code: 'MISSING_PARAM',
972092
+ solution: [(0, i18n_1.t)('运行 `tcb db backup list` 查看可用的备份 ID')]
972093
+ });
970314
972094
  }
970315
- if (!options.yes) {
970316
- if (isJson) {
970317
- (0, common_2.jsonOutput)({ code: 1, error: (0, i18n_1.t)('--json 模式下需要配合 --yes 跳过确认') });
970318
- return;
970319
- }
970320
- const { confirm } = yield inquirer_1.default.prompt([
970321
- {
970322
- type: 'confirm',
970323
- name: 'confirm',
970324
- message: (0, i18n_1.t)('确定要删除备份 {{backupId}} 吗?此操作不可恢复', { backupId }),
970325
- default: false
970326
- }
970327
- ]);
970328
- if (!confirm) {
970329
- log.info((0, i18n_1.t)('已取消操作'));
970330
- return;
970331
- }
972095
+ const confirmed = yield (0, utils_1.autoConfirm)((0, i18n_1.t)('确定要删除备份 {{backupId}} 吗?此操作不可恢复', { backupId }));
972096
+ if (!confirmed) {
972097
+ log.info((0, i18n_1.t)('已取消操作'));
972098
+ return;
970332
972099
  }
970333
972100
  const loading = (0, utils_1.loadingFactory)();
970334
- try {
970335
- loading.start((0, i18n_1.t)('正在删除备份...'));
970336
- yield (0, mysql_1.deleteBackup)({
970337
- envId: selectedEnvId,
970338
- backupId: Number(backupId)
970339
- });
970340
- loading.stop();
970341
- if (isJson) {
970342
- (0, common_2.jsonOutput)({ code: 0, data: { success: true } });
970343
- return;
970344
- }
970345
- log.success((0, i18n_1.t)('备份删除成功'));
970346
- }
970347
- catch (e) {
970348
- loading.stop();
970349
- if (isJson) {
970350
- (0, common_2.jsonOutput)({ code: 1, error: e.message || (0, i18n_1.t)('未知错误') });
970351
- return;
970352
- }
970353
- throw e;
972101
+ loading.start((0, i18n_1.t)('正在删除备份...'));
972102
+ yield (0, mysql_1.deleteBackup)({
972103
+ envId: selectedEnvId,
972104
+ backupId: Number(backupId)
972105
+ });
972106
+ loading.stop();
972107
+ if (isJson) {
972108
+ (0, utils_1.outputJson)({ success: true });
972109
+ return;
970354
972110
  }
972111
+ log.success((0, i18n_1.t)('备份删除成功'));
970355
972112
  });
970356
972113
  }
970357
972114
  };
970358
972115
  __decorate([
970359
972116
  (0, decorators_1.InjectParams)(),
970360
- __param(0, (0, decorators_1.EnvId)()),
970361
- __param(1, (0, decorators_1.ArgsOptions)()),
970362
- __param(2, (0, decorators_1.Log)()),
972117
+ __param(0, (0, decorators_1.CmdContext)()),
972118
+ __param(1, (0, decorators_1.EnvId)()),
972119
+ __param(2, (0, decorators_1.ArgsOptions)()),
972120
+ __param(3, (0, decorators_1.Log)()),
970363
972121
  __metadata("design:type", Function),
970364
- __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
972122
+ __metadata("design:paramtypes", [Object, Object, Object, decorators_1.Logger]),
970365
972123
  __metadata("design:returntype", Promise)
970366
972124
  ], BackupDropCommand.prototype, "execute", null);
970367
972125
  BackupDropCommand = __decorate([