@lark-apaas/miaoda-cli 0.1.2-alpha.45db14c → 0.1.2-alpha.4e370b6

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 (55) hide show
  1. package/dist/api/db/api.js +250 -6
  2. package/dist/api/db/client.js +36 -0
  3. package/dist/api/db/index.js +9 -1
  4. package/dist/api/file/api.js +15 -0
  5. package/dist/api/file/index.js +2 -1
  6. package/dist/api/index.js +1 -7
  7. package/dist/cli/commands/db/index.js +137 -0
  8. package/dist/cli/commands/file/index.js +7 -0
  9. package/dist/cli/commands/index.js +0 -6
  10. package/dist/cli/commands/shared.js +3 -61
  11. package/dist/cli/handlers/db/audit.js +285 -0
  12. package/dist/cli/handlers/db/changelog.js +117 -0
  13. package/dist/cli/handlers/db/data.js +1 -1
  14. package/dist/cli/handlers/db/index.js +17 -1
  15. package/dist/cli/handlers/db/migration.js +213 -0
  16. package/dist/cli/handlers/{app/update.js → db/quota.js} +29 -20
  17. package/dist/cli/handlers/db/recovery.js +188 -0
  18. package/dist/cli/handlers/file/index.js +3 -1
  19. package/dist/cli/handlers/{deploy/error-log.js → file/quota.js} +27 -22
  20. package/dist/utils/http.js +0 -86
  21. package/dist/utils/index.js +1 -13
  22. package/dist/utils/output.js +29 -338
  23. package/package.json +5 -7
  24. package/dist/api/app/api.js +0 -25
  25. package/dist/api/app/index.js +0 -15
  26. package/dist/api/app/schemas.js +0 -79
  27. package/dist/api/app/types.js +0 -58
  28. package/dist/api/deploy/api.js +0 -60
  29. package/dist/api/deploy/index.js +0 -16
  30. package/dist/api/deploy/schemas.js +0 -103
  31. package/dist/api/deploy/types.js +0 -22
  32. package/dist/api/observability/api.js +0 -52
  33. package/dist/api/observability/index.js +0 -16
  34. package/dist/api/observability/schemas.js +0 -39
  35. package/dist/api/observability/types.js +0 -27
  36. package/dist/cli/commands/app/index.js +0 -62
  37. package/dist/cli/commands/deploy/index.js +0 -140
  38. package/dist/cli/commands/observability/index.js +0 -229
  39. package/dist/cli/handlers/app/get.js +0 -48
  40. package/dist/cli/handlers/app/index.js +0 -7
  41. package/dist/cli/handlers/deploy/deploy.js +0 -83
  42. package/dist/cli/handlers/deploy/get.js +0 -70
  43. package/dist/cli/handlers/deploy/helpers.js +0 -41
  44. package/dist/cli/handlers/deploy/history.js +0 -70
  45. package/dist/cli/handlers/deploy/index.js +0 -14
  46. package/dist/cli/handlers/deploy/polling.js +0 -139
  47. package/dist/cli/handlers/observability/analytics.js +0 -190
  48. package/dist/cli/handlers/observability/helpers.js +0 -66
  49. package/dist/cli/handlers/observability/index.js +0 -12
  50. package/dist/cli/handlers/observability/log.js +0 -94
  51. package/dist/cli/handlers/observability/metric.js +0 -208
  52. package/dist/cli/handlers/observability/trace.js +0 -102
  53. package/dist/utils/devops-error.js +0 -28
  54. package/dist/utils/git.js +0 -29
  55. package/dist/utils/time.js +0 -132
@@ -1,229 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerObservabilityCommands = registerObservabilityCommands;
4
- const commander_1 = require("commander");
5
- const shared_1 = require("../../../cli/commands/shared");
6
- const index_1 = require("../../../cli/handlers/observability/index");
7
- const COMMON_TIME_HELP = `
8
- 时间格式:
9
- - 相对时间:1h(1 小时前)、2d(2 天前)、1w(1 周前)、30m(30 分钟前)
10
- - 日期:2026-04-01(按当日 00:00:00 UTC)
11
- - ISO 8601:2026-04-01T10:00:00Z
12
- `;
13
- function registerObservabilityCommands(program) {
14
- const obCmd = program
15
- .command("observability")
16
- .description("可观测性:查询线上日志、链路、监控指标、运营指标");
17
- obCmd.action(() => {
18
- obCmd.outputHelp();
19
- });
20
- obCmd.addHelpText("after", `
21
- 作用范围
22
- 仅供 Agent 在妙搭沙箱内调用,查询当前应用的线上观测数据。所有命令为只读。
23
- 应用上下文:--app-id <id> 或环境变量 MIAODA_APP_ID。
24
-
25
- 应用环境
26
- 目前只支持线上环境。
27
- `);
28
- registerLog(obCmd);
29
- registerTrace(obCmd);
30
- registerMetric(obCmd);
31
- registerAnalytics(obCmd);
32
- }
33
- // ── log ──
34
- function registerLog(parent) {
35
- const cmd = parent
36
- .command("log")
37
- .description("查询线上运行日志(按时间倒序,分页)")
38
- .addOption((0, shared_1.appIdOption)().hideHelp())
39
- .addOption(new commander_1.Option("--level <level>", "日志级别(大小写不敏感)")
40
- .choices(["DEBUG", "INFO", "WARN", "ERROR"])
41
- .argParser((0, shared_1.caseInsensitiveChoice)(["DEBUG", "INFO", "WARN", "ERROR"])))
42
- .option("--since <time>", "开始时间")
43
- .option("--until <time>", "截止时间")
44
- .option("--trace-id <id>", "按 trace ID 过滤")
45
- .option("--grep <pattern>", "按关键字模糊搜索 body")
46
- .option("--module <name>", "按模块名过滤")
47
- .option("--user-id <user-id>", "按触发用户 ID 过滤")
48
- .option("--page <path>", "按页面路径过滤")
49
- .option("--api <path>", "按接口路径过滤")
50
- .option("--min-duration <ms>", "最小耗时过滤(毫秒)")
51
- .option("--max-duration <ms>", "最大耗时过滤(毫秒)")
52
- .option("--limit <n>", "返回条数上限(1~100)", parseLimit, 50)
53
- .option("--cursor <token>", "下一页游标,从上一次返回的 next_cursor 取值")
54
- .addHelpText("after", `${COMMON_TIME_HELP}
55
- JSON 输出
56
- {"data": [...], "next_cursor": "...", "has_more": true|false}
57
-
58
- 示例
59
- $ miaoda observability log --since 1h --level error --json
60
- $ miaoda observability log --trace-id 140ebb5ac9b... --json
61
- $ miaoda observability log --api /api/orders --min-duration 200 --json
62
- `);
63
- cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
64
- (0, shared_1.rejectCliOverride)(cmd, "appId");
65
- await (0, index_1.handleObservabilityLog)({
66
- appId: rawOpts.appId,
67
- level: rawOpts.level,
68
- since: rawOpts.since,
69
- until: rawOpts.until,
70
- traceId: rawOpts.traceId,
71
- grep: rawOpts.grep,
72
- module: rawOpts.module,
73
- userId: rawOpts.userId,
74
- page: rawOpts.page,
75
- api: rawOpts.api,
76
- minDuration: rawOpts.minDuration,
77
- maxDuration: rawOpts.maxDuration,
78
- limit: rawOpts.limit,
79
- cursor: rawOpts.cursor,
80
- });
81
- }));
82
- }
83
- // ── trace ──
84
- function registerTrace(parent) {
85
- const traceCmd = parent.command("trace").description("链路追踪:列表 / 详情");
86
- traceCmd.action(() => {
87
- traceCmd.outputHelp();
88
- });
89
- const listCmd = traceCmd
90
- .command("list")
91
- .description("查询线上链路列表(按链路时间倒序,分页)")
92
- .addOption((0, shared_1.appIdOption)().hideHelp())
93
- .option("--since <time>", "开始时间")
94
- .option("--until <time>", "截止时间")
95
- .option("--trace-id <id>", "按 trace ID 过滤")
96
- .option("--root-span <span-name>", "按入口节点关键词过滤")
97
- .option("--user-id <user-id>", "按触发用户 ID 过滤")
98
- .option("--limit <n>", "返回条数上限(1~100)", parseLimit, 50)
99
- .option("--cursor <token>", "下一页游标")
100
- .addHelpText("after", `${COMMON_TIME_HELP}
101
- JSON 输出
102
- {"data": [...], "next_cursor": "...", "has_more": true|false}
103
-
104
- 示例
105
- $ miaoda observability trace list --since 1h --json
106
- $ miaoda observability trace list --root-span api-gateway --limit 20 --json
107
- `);
108
- listCmd.action((0, shared_1.withHelp)(listCmd, async (rawOpts) => {
109
- (0, shared_1.rejectCliOverride)(listCmd, "appId");
110
- await (0, index_1.handleObservabilityTraceList)({
111
- appId: rawOpts.appId,
112
- since: rawOpts.since,
113
- until: rawOpts.until,
114
- traceId: rawOpts.traceId,
115
- rootSpan: rawOpts.rootSpan,
116
- userId: rawOpts.userId,
117
- limit: rawOpts.limit,
118
- cursor: rawOpts.cursor,
119
- });
120
- }));
121
- const getCmd = traceCmd
122
- .command("get")
123
- .description("查询指定链路的完整详情")
124
- .argument("<trace-id>", "链路 ID")
125
- .addOption((0, shared_1.appIdOption)().hideHelp())
126
- .option("--with-log-severity-count", "返回每个 Span 各日志级别的数量", false)
127
- .addHelpText("after", `
128
- JSON 输出
129
- {"data": {"spans": [...], "isBreak": false}}
130
-
131
- 示例
132
- $ miaoda observability trace get 140ebb5ac9b55ed50d6ed1090cad4d --json
133
-
134
- # 报错:链路不存在
135
- $ miaoda observability trace get not-exist
136
- Error: Failed to get trace: 500 ...
137
- hint: 检查 trace-id 是否正确,或链路已超出保留时长
138
- `);
139
- getCmd.action((0, shared_1.withHelp)(getCmd, async (traceId, rawOpts) => {
140
- (0, shared_1.rejectCliOverride)(getCmd, "appId");
141
- await (0, index_1.handleObservabilityTraceGet)({
142
- traceId,
143
- appId: rawOpts.appId,
144
- withLogSeverityCount: rawOpts.withLogSeverityCount,
145
- });
146
- }));
147
- }
148
- // ── metric ──
149
- function registerMetric(parent) {
150
- const cmd = parent
151
- .command("metric")
152
- .description("查询监控指标:requests / latency / cpu / memory")
153
- .argument("<metric-name>", "指标名:requests | latency | cpu | memory")
154
- .addOption((0, shared_1.appIdOption)().hideHelp())
155
- .option("--page <path>", "按页面路径过滤(仅对 requests/latency 生效)")
156
- .option("--api <path>", "按接口路径过滤(仅对 requests/latency 生效)")
157
- .option("--series <name>", "过滤图表中的某条线:latency 取 p50/p99;requests 取 total/error;缺省返回所有相关线")
158
- .option("--since <time>", "开始时间")
159
- .option("--until <time>", "截止时间")
160
- .addOption(new commander_1.Option("--down-sample <duration>", "降采样粒度(1m=1分钟 / 1h=1小时 / 1d=1天,大小写不敏感)")
161
- .choices(["1m", "1h", "1d"])
162
- .argParser((0, shared_1.caseInsensitiveChoice)(["1m", "1h", "1d"]))
163
- .default("1h"))
164
- .addHelpText("after", `${COMMON_TIME_HELP}
165
- JSON 输出
166
- {"data": [{"metricName": "...", "dimensions": {...}, "dataPoints": [...]}], "next_cursor": null, "has_more": false}
167
-
168
- 示例
169
- $ miaoda observability metric latency --since 1h --json
170
- $ miaoda observability metric latency --since 1h --series p99 --json
171
- $ miaoda observability metric requests --api /api/users --json
172
- $ miaoda observability metric cpu --since 1d --down-sample 1d --json
173
- `);
174
- cmd.action((0, shared_1.withHelp)(cmd, async (metricName, rawOpts) => {
175
- (0, shared_1.rejectCliOverride)(cmd, "appId");
176
- await (0, index_1.handleObservabilityMetric)({
177
- metricName,
178
- appId: rawOpts.appId,
179
- page: rawOpts.page,
180
- api: rawOpts.api,
181
- series: rawOpts.series,
182
- since: rawOpts.since,
183
- until: rawOpts.until,
184
- downSample: rawOpts.downSample,
185
- });
186
- }));
187
- }
188
- // ── analytics ──
189
- function registerAnalytics(parent) {
190
- const cmd = parent
191
- .command("analytics")
192
- .description("查询运营指标:users(用户数)/ page-view(页面访问)")
193
- .argument("<analytics-name>", "指标名:users | page-view")
194
- .addOption((0, shared_1.appIdOption)().hideHelp())
195
- .option("--page <path>", "按页面路径过滤(仅对 page-view 生效)")
196
- .option("--series <name>", "过滤图表中的某条线:users 取 active-users/new-users/total-users;page-view 取 all-view/desktop-view/mobile-view;缺省返回所有相关线")
197
- .option("--since <time>", "开始时间")
198
- .option("--until <time>", "截止时间")
199
- .option("--granularity <duration>", "时间粒度:day | week | month", "day")
200
- .addHelpText("after", `${COMMON_TIME_HELP}
201
- JSON 输出
202
- {"data": [{"metricType": "...", "points": [{"timestampNs": "...", "value": ..., "dimensions": {...}}]}], "next_cursor": null, "has_more": false}
203
-
204
- 示例
205
- $ miaoda observability analytics users --json # 同时返回 active/new/total 三条线
206
- $ miaoda observability analytics users --series new-users --since 7d --json
207
- $ miaoda observability analytics page-view --granularity week --json
208
- `);
209
- cmd.action((0, shared_1.withHelp)(cmd, async (analyticsName, rawOpts) => {
210
- (0, shared_1.rejectCliOverride)(cmd, "appId");
211
- await (0, index_1.handleObservabilityAnalytics)({
212
- analyticsName,
213
- appId: rawOpts.appId,
214
- env: rawOpts.env,
215
- page: rawOpts.page,
216
- series: rawOpts.series,
217
- since: rawOpts.since,
218
- until: rawOpts.until,
219
- granularity: rawOpts.granularity,
220
- });
221
- }));
222
- }
223
- function parseLimit(value) {
224
- const n = Number(value);
225
- if (!Number.isFinite(n)) {
226
- throw new Error(`--limit 必须是数字,收到 '${value}'`);
227
- }
228
- return n;
229
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleAppGet = handleAppGet;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const index_1 = require("../../../api/app/index");
41
- /** miaoda app get [--app-id <id>] */
42
- async function handleAppGet(opts) {
43
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
44
- const resp = await api.app.getAppInfo(appID);
45
- // BAM 在 status_code=0 时 data 字段含 appInfo;不存在则 fallback 空对象
46
- const meta = resp.appInfo?.appMeta ?? {};
47
- (0, output_1.emit)({ data: meta, next_cursor: null, has_more: false }, index_1.appMetaSchema);
48
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleAppUpdate = exports.handleAppGet = void 0;
4
- var get_1 = require("./get");
5
- Object.defineProperty(exports, "handleAppGet", { enumerable: true, get: function () { return get_1.handleAppGet; } });
6
- var update_1 = require("./update");
7
- Object.defineProperty(exports, "handleAppUpdate", { enumerable: true, get: function () { return update_1.handleAppUpdate; } });
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleDeploy = handleDeploy;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const index_1 = require("../../../api/deploy/index");
41
- const polling_1 = require("./polling");
42
- /** miaoda deploy [--branch ...] [--wait] [--timeout 300] */
43
- async function handleDeploy(opts) {
44
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
45
- const resp = await api.deploy.createRelease({ appID, branch: opts.branch });
46
- const pipelineTaskID = resp.pipelineTaskID ?? "";
47
- if (!opts.wait) {
48
- if (!(0, output_1.isJsonMode)()) {
49
- process.stdout.write(`✓ Deployment triggered. (deploy-id: ${pipelineTaskID})\n`);
50
- }
51
- (0, output_1.emit)({
52
- data: { pipelineTaskID },
53
- next_cursor: null,
54
- has_more: false,
55
- });
56
- return;
57
- }
58
- if (!(0, output_1.isJsonMode)()) {
59
- process.stdout.write(`Waiting for deployment to complete... (deploy-id: ${pipelineTaskID})\n`);
60
- }
61
- const detail = await (0, polling_1.waitForPipeline)({
62
- appID,
63
- pipelineTaskID,
64
- timeoutSec: opts.timeout ?? 300,
65
- });
66
- if (!(0, output_1.isJsonMode)()) {
67
- if (detail.status === index_1.NodeStatus.SUCCESS) {
68
- process.stdout.write("✓ 发布成功\n");
69
- }
70
- else if (detail.status === index_1.NodeStatus.FAILED) {
71
- process.stdout.write("✗ 发布失败\n");
72
- process.stdout.write(` hint: Run \`miaoda deploy error-log ${pipelineTaskID}\` to view error logs\n`);
73
- }
74
- else {
75
- process.stdout.write("• 发布已取消\n");
76
- }
77
- }
78
- (0, output_1.emit)({
79
- data: { pipelineTaskID, detail },
80
- next_cursor: null,
81
- has_more: false,
82
- });
83
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleDeployGet = handleDeployGet;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const error_1 = require("../../../utils/error");
41
- const index_1 = require("../../../api/deploy/index");
42
- const helpers_1 = require("./helpers");
43
- /**
44
- * 单页拉取上限:BAM listPipelineInstances 限制 1~500,取 500 让 deploy get
45
- * 在最近 500 条记录里按 ID 命中。
46
- */
47
- const DEPLOY_GET_LOOKUP_LIMIT = 500;
48
- /**
49
- * miaoda deploy get <deploy-id>
50
- *
51
- * BAM 没有 by-ID 的查询接口,复用 listPipelineInstances 在最近窗口里按 ID 筛一条。
52
- * 命中失败时抛 DEPLOY_NOT_FOUND,提示用户用 history 查窗口。
53
- */
54
- async function handleDeployGet(opts) {
55
- if (!opts.deployId)
56
- (0, shared_1.failArgs)("<deploy-id> 必填");
57
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
58
- const deployId = (0, helpers_1.parseDeployId)(opts.deployId);
59
- const resp = await api.deploy.listPipelineInstances({
60
- appID,
61
- limit: DEPLOY_GET_LOOKUP_LIMIT,
62
- });
63
- const instance = resp.instances?.find((it) => Number(it.ID) === deployId);
64
- if (!instance) {
65
- throw new error_1.AppError("DEPLOY_NOT_FOUND", `未在最近 ${String(DEPLOY_GET_LOOKUP_LIMIT)} 条记录中找到 deploy-id=${opts.deployId}`, {
66
- next_actions: ["运行 `miaoda deploy history` 确认 deploy-id 是否在最近窗口内"],
67
- });
68
- }
69
- (0, output_1.emit)({ data: instance, next_cursor: null, has_more: false }, index_1.deployGetSchema);
70
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseStatusFlag = parseStatusFlag;
4
- exports.validateLimit = validateLimit;
5
- exports.parseDeployId = parseDeployId;
6
- const shared_1 = require("../../../cli/commands/shared");
7
- const index_1 = require("../../../api/deploy/index");
8
- /**
9
- * 把 CLI --status 字符串映射成 BAM NodeStatus 数字;非法值抛 ARGS_INVALID。
10
- *
11
- * 历史接口(CliListPipelineInstances)返回 SimpleInstance,状态语义是 pipeline 节点状态,
12
- * 取值 todo / running / success / failed / canceled / hold_on。
13
- */
14
- function parseStatusFlag(text) {
15
- const value = (0, index_1.nodeStatusFromText)(text);
16
- if (value === undefined) {
17
- (0, shared_1.failArgs)(`--status 无效:'${text}'。可选值:todo | running | success | failed | canceled | hold_on`);
18
- }
19
- return value;
20
- }
21
- /** limit/pageSize 校验(API 限制 1~100) */
22
- function validateLimit(limit, defaultLimit = 50) {
23
- const n = Number.isFinite(limit) ? limit : defaultLimit;
24
- if (n <= 0 || n > 100) {
25
- (0, shared_1.failArgs)(`--limit 必须在 1~100 之间,收到 ${String(n)}`);
26
- }
27
- return n;
28
- }
29
- /**
30
- * 把 CLI <deploy-id> 字符串转成 i64 number。
31
- *
32
- * 语义上 deploy-id 即 pipelineTaskID(pipeline 实例 ID);BAM CLIGetReleaseLogs
33
- * IDL 历史命名为 releaseID,但传入的就是这同一个值。
34
- */
35
- function parseDeployId(text) {
36
- const n = Number(text);
37
- if (!Number.isFinite(n) || !/^\d+$/.test(text)) {
38
- (0, shared_1.failArgs)(`<deploy-id> 必须是数字 ID,收到 '${text}'`);
39
- }
40
- return n;
41
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleDeployHistory = handleDeployHistory;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const time_1 = require("../../../utils/time");
41
- const index_1 = require("../../../api/deploy/index");
42
- const helpers_1 = require("./helpers");
43
- /** miaoda deploy history */
44
- async function handleDeployHistory(opts) {
45
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
46
- const limit = (0, helpers_1.validateLimit)(opts.limit ?? 50);
47
- const req = {
48
- appID,
49
- limit,
50
- pageToken: opts.cursor,
51
- };
52
- if (opts.status)
53
- req.status = [(0, helpers_1.parseStatusFlag)(opts.status)];
54
- // BAM startTimestamp / endTimestamp 单位是秒(IDL desc:单位:秒)
55
- if (opts.since !== undefined)
56
- req.startTimestamp = msToSec((0, time_1.parseToMs)(opts.since));
57
- if (opts.until !== undefined)
58
- req.endTimestamp = msToSec((0, time_1.parseToMs)(opts.until));
59
- const resp = await api.deploy.listPipelineInstances(req);
60
- (0, output_1.emit)({
61
- data: resp.instances ?? [],
62
- next_cursor: resp.hasMore ? (resp.nextPageToken ?? null) : null,
63
- has_more: resp.hasMore ?? false,
64
- }, index_1.deployHistorySchema);
65
- }
66
- function msToSec(ms) {
67
- if (ms === undefined)
68
- return undefined;
69
- return Math.floor(ms / 1000);
70
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_POLL_INTERVAL_MS = exports.waitForPipeline = exports.handleDeployErrorLog = exports.handleDeployHistory = exports.handleDeployGet = exports.handleDeploy = void 0;
4
- var deploy_1 = require("./deploy");
5
- Object.defineProperty(exports, "handleDeploy", { enumerable: true, get: function () { return deploy_1.handleDeploy; } });
6
- var get_1 = require("./get");
7
- Object.defineProperty(exports, "handleDeployGet", { enumerable: true, get: function () { return get_1.handleDeployGet; } });
8
- var history_1 = require("./history");
9
- Object.defineProperty(exports, "handleDeployHistory", { enumerable: true, get: function () { return history_1.handleDeployHistory; } });
10
- var error_log_1 = require("./error-log");
11
- Object.defineProperty(exports, "handleDeployErrorLog", { enumerable: true, get: function () { return error_log_1.handleDeployErrorLog; } });
12
- var polling_1 = require("./polling");
13
- Object.defineProperty(exports, "waitForPipeline", { enumerable: true, get: function () { return polling_1.waitForPipeline; } });
14
- Object.defineProperty(exports, "DEFAULT_POLL_INTERVAL_MS", { enumerable: true, get: function () { return polling_1.DEFAULT_POLL_INTERVAL_MS; } });