Skip to content

Commit 16d12a2

Browse files
committed
fix: model monitor commend workspace issue & change bl log count api
1 parent 1d99e03 commit 16d12a2

47 files changed

Lines changed: 1957 additions & 323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/commands/src/commands/alert/create.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
defineCommand,
3-
detectOutputFormat,
4-
effectiveConsoleGatewayConfig,
5-
unwrapResponse,
6-
} from "bailian-cli-core";
1+
import { detectOutputFormat, unwrapResponse } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
73
import { emitResult } from "bailian-cli-runtime";
84
import {
95
ALERT_RULE_WRITE_FLAGS,
@@ -14,7 +10,7 @@ import {
1410

1511
const CREATE_RULE_API = "zeldaEasy.bailian-telemetry.alertRule.createAlertRule";
1612

17-
export default defineCommand({
13+
export default defineTelemetryCommand({
1814
description: {
1915
"en-US": "Create a model alert rule from an alert template",
2016
"zh-CN": "基于告警模板创建模型告警规则",
@@ -39,7 +35,7 @@ export default defineCommand({
3935
validate: (flags) => validateAlertRuleFlags(flags),
4036
async run(ctx) {
4137
const { settings, flags } = ctx;
42-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
38+
const format = detectOutputFormat(settings.output);
4339

4440
const reqDTO = {
4541
...(settings.workspaceId ? { workspaceId: settings.workspaceId } : {}),
@@ -51,7 +47,7 @@ export default defineCommand({
5147
{
5248
api: CREATE_RULE_API,
5349
data: { reqDTO },
54-
...effectiveConsoleGatewayConfig(settings),
50+
...telemetryGatewayPreview(settings),
5551
},
5652
format,
5753
);

‎packages/commands/src/commands/alert/delete.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig } from "bailian-cli-core";
1+
import { detectOutputFormat } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
23
import { emitResult } from "bailian-cli-runtime";
34
import { parseCommaList } from "../shared/params.ts";
45
import { ensureAlertReady } from "./shared.ts";
56

67
const DELETE_RULES_API = "zeldaEasy.bailian-telemetry.alertRule.deleteAlertRules";
78

8-
export default defineCommand({
9+
export default defineTelemetryCommand({
910
description: {
1011
"en-US": "Delete model alert rules",
1112
"zh-CN": "删除模型告警规则",
@@ -39,7 +40,7 @@ export default defineCommand({
3940
],
4041
async run(ctx) {
4142
const { settings, flags } = ctx;
42-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
43+
const format = detectOutputFormat(settings.output);
4344

4445
const reqDTO = { ruleIds: parseCommaList(flags.ruleId) };
4546

@@ -48,7 +49,7 @@ export default defineCommand({
4849
{
4950
api: DELETE_RULES_API,
5051
data: { reqDTO },
51-
...effectiveConsoleGatewayConfig(settings),
52+
...telemetryGatewayPreview(settings),
5253
},
5354
format,
5455
);

‎packages/commands/src/commands/alert/disable.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig } from "bailian-cli-core";
1+
import { detectOutputFormat } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
23
import { emitResult } from "bailian-cli-runtime";
34
import { ensureAlertReady } from "./shared.ts";
45

56
const DISABLE_RULE_API = "zeldaEasy.bailian-telemetry.alertRule.disableAlertRule";
67

7-
export default defineCommand({
8+
export default defineTelemetryCommand({
89
description: {
910
"en-US": "Disable a model alert rule (keeps the rule, stops notifications)",
1011
"zh-CN": "停用模型告警规则(保留规则,停止通知)",
@@ -25,7 +26,7 @@ export default defineCommand({
2526
exampleArgs: ["--rule-id 789", "--rule-id 789 --dry-run"],
2627
async run(ctx) {
2728
const { settings, flags } = ctx;
28-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
29+
const format = detectOutputFormat(settings.output);
2930

3031
const reqDTO = {
3132
workspaceId: settings.workspaceId,
@@ -38,7 +39,7 @@ export default defineCommand({
3839
{
3940
api: DISABLE_RULE_API,
4041
data: { reqDTO },
41-
...effectiveConsoleGatewayConfig(settings),
42+
...telemetryGatewayPreview(settings),
4243
},
4344
format,
4445
);

‎packages/commands/src/commands/alert/enable.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig } from "bailian-cli-core";
1+
import { detectOutputFormat } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
23
import { emitResult } from "bailian-cli-runtime";
34
import { ensureAlertReady } from "./shared.ts";
45

5-
export default defineCommand({
6+
export default defineTelemetryCommand({
67
description: {
78
"en-US": "Enable a model alert rule",
89
"zh-CN": "启用模型告警规则",
@@ -23,7 +24,7 @@ export default defineCommand({
2324
exampleArgs: ["--rule-id 789", "--rule-id 789 --dry-run"],
2425
async run(ctx) {
2526
const { settings, flags } = ctx;
26-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
27+
const format = detectOutputFormat(settings.output);
2728

2829
const reqDTO = {
2930
workspaceId: settings.workspaceId,
@@ -36,7 +37,7 @@ export default defineCommand({
3637
{
3738
api: "zeldaEasy.bailian-telemetry.alertRule.enableAlertRule",
3839
data: { reqDTO },
39-
...effectiveConsoleGatewayConfig(settings),
40+
...telemetryGatewayPreview(settings),
4041
},
4142
format,
4243
);

‎packages/commands/src/commands/alert/history.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig } from "bailian-cli-core";
1+
import { detectOutputFormat } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
23
import { ansi, emitResult, renderBoxTable } from "bailian-cli-runtime";
34
import { formatDateTime } from "../shared/format.ts";
45
import { TELEMETRY_TIME_FLAGS, resolveTimeRange } from "../shared/telemetry.ts";
@@ -30,7 +31,7 @@ function instanceText(item: AlertHistoryItem): string {
3031
);
3132
}
3233

33-
export default defineCommand({
34+
export default defineTelemetryCommand({
3435
description: {
3536
"en-US": "List model alert history (firing and recovered events)",
3637
"zh-CN": "查看模型告警历史(告警中与已恢复事件)",
@@ -104,7 +105,7 @@ export default defineCommand({
104105
},
105106
async run(ctx) {
106107
const { settings, flags } = ctx;
107-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
108+
const format = detectOutputFormat(settings.output);
108109
const { startTime, endTime } = resolveTimeRange(flags);
109110

110111
const reqDTO = {
@@ -126,7 +127,7 @@ export default defineCommand({
126127
{
127128
api: LIST_HISTORIES_API,
128129
data: { reqDTO },
129-
...effectiveConsoleGatewayConfig(settings),
130+
...telemetryGatewayPreview(settings),
130131
},
131132
format,
132133
);

‎packages/commands/src/commands/alert/list.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig } from "bailian-cli-core";
1+
import { detectOutputFormat } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
23
import { ansi, emitResult, renderBoxTable } from "bailian-cli-runtime";
34
import { ensureAlertReady, extractAlertPage, ALERT_LEVELS } from "./shared.ts";
45

@@ -43,7 +44,7 @@ function printTable(list: AlertRuleItem[]): void {
4344
for (const line of lines) process.stdout.write(line + "\n");
4445
}
4546

46-
export default defineCommand({
47+
export default defineTelemetryCommand({
4748
description: {
4849
"en-US": "List model alert rules",
4950
"zh-CN": "查看模型告警规则列表",
@@ -112,7 +113,7 @@ export default defineCommand({
112113
exampleArgs: ["", "--enabled true", "--name 失败率 --level ERROR", "--output json"],
113114
async run(ctx) {
114115
const { settings, flags } = ctx;
115-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
116+
const format = detectOutputFormat(settings.output);
116117

117118
const reqDTO = {
118119
workspaceId: settings.workspaceId,
@@ -132,7 +133,7 @@ export default defineCommand({
132133
{
133134
api: LIST_RULES_API,
134135
data: { reqDTO },
135-
...effectiveConsoleGatewayConfig(settings),
136+
...telemetryGatewayPreview(settings),
136137
},
137138
format,
138139
);

‎packages/commands/src/commands/alert/metrics.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
defineCommand,
3-
detectOutputFormat,
4-
effectiveConsoleGatewayConfig,
5-
unwrapResponse,
6-
} from "bailian-cli-core";
1+
import { detectOutputFormat, unwrapResponse } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
73
import { emitResult, renderBoxTable } from "bailian-cli-runtime";
84
import { ensureAlertReady } from "./shared.ts";
95

@@ -17,7 +13,7 @@ interface AlertMetric {
1713
resourceType?: string;
1814
}
1915

20-
export default defineCommand({
16+
export default defineTelemetryCommand({
2117
description: {
2218
"en-US": "List metrics that alert rules can be created on, with supported aggregations",
2319
"zh-CN": "查看可创建告警的指标及其支持的聚合方式",
@@ -27,14 +23,14 @@ export default defineCommand({
2723
exampleArgs: ["", "--output json"],
2824
async run(ctx) {
2925
const { settings } = ctx;
30-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
26+
const format = detectOutputFormat(settings.output);
3127

3228
if (settings.dryRun) {
3329
emitResult(
3430
{
3531
api: LIST_METRICS_API,
3632
data: { reqDTO: { workspaceId: settings.workspaceId, resourceType: "model" } },
37-
...effectiveConsoleGatewayConfig(settings),
33+
...telemetryGatewayPreview(settings),
3834
},
3935
format,
4036
);

‎packages/commands/src/commands/alert/template-create.ts‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import {
2-
defineCommand,
3-
BailianError,
4-
ExitCode,
5-
detectOutputFormat,
6-
effectiveConsoleGatewayConfig,
7-
unwrapResponse,
8-
} from "bailian-cli-core";
1+
import { BailianError, ExitCode, detectOutputFormat, unwrapResponse } from "bailian-cli-core";
92
import { emitResult } from "bailian-cli-runtime";
3+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
104
import {
115
ensureAlertReady,
126
extractAlertPage,
@@ -52,7 +46,7 @@ async function resolveConditions(
5246
}));
5347
}
5448

55-
export default defineCommand({
49+
export default defineTelemetryCommand({
5650
description: {
5751
"en-US": "Create a custom alert template (or copy an official one with --from)",
5852
"zh-CN": "创建自定义告警模板(或用 --from 复制官方模板)",
@@ -107,7 +101,7 @@ export default defineCommand({
107101
validate: (flags) => validateTemplateConditions(flags.condition, Boolean(flags.from)),
108102
async run(ctx) {
109103
const { settings, flags } = ctx;
110-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
104+
const format = detectOutputFormat(settings.output);
111105

112106
const conditions = flags.condition?.length ? flags.condition.map(parseCondition) : undefined;
113107

@@ -124,7 +118,7 @@ export default defineCommand({
124118
conditions: conditions ?? "(copied from --from template)",
125119
},
126120
},
127-
...effectiveConsoleGatewayConfig(settings),
121+
...telemetryGatewayPreview(settings),
128122
},
129123
format,
130124
);

‎packages/commands/src/commands/alert/template-delete.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import {
2-
defineCommand,
3-
detectOutputFormat,
4-
effectiveConsoleGatewayConfig,
5-
unwrapResponse,
6-
} from "bailian-cli-core";
1+
import { detectOutputFormat, unwrapResponse } from "bailian-cli-core";
72
import { emitResult } from "bailian-cli-runtime";
83
import { parseCommaList } from "../shared/params.ts";
94
import { ensureAlertReady } from "./shared.ts";
5+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
106

117
const DELETE_TEMPLATES_API = "zeldaEasy.bailian-telemetry.alertTemplate.deleteAlertTemplates";
128

13-
export default defineCommand({
9+
export default defineTelemetryCommand({
1410
description: {
1511
"en-US": "Delete custom alert templates (official templates cannot be deleted)",
1612
"zh-CN": "删除自定义告警模板(官方模板不可删除)",
@@ -44,7 +40,7 @@ export default defineCommand({
4440
],
4541
async run(ctx) {
4642
const { settings, flags } = ctx;
47-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
43+
const format = detectOutputFormat(settings.output);
4844

4945
const reqDTO = { templateIds: parseCommaList(flags.templateId) };
5046

@@ -53,7 +49,7 @@ export default defineCommand({
5349
{
5450
api: DELETE_TEMPLATES_API,
5551
data: { reqDTO },
56-
...effectiveConsoleGatewayConfig(settings),
52+
...telemetryGatewayPreview(settings),
5753
},
5854
format,
5955
);

‎packages/commands/src/commands/alert/template-list.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { defineCommand, detectOutputFormat, effectiveConsoleGatewayConfig } from "bailian-cli-core";
1+
import { detectOutputFormat } from "bailian-cli-core";
2+
import { defineTelemetryCommand, telemetryGatewayPreview } from "../shared/telemetry.ts";
23
import { emitResult, renderBoxTable } from "bailian-cli-runtime";
34
import { ensureAlertReady, extractAlertPage } from "./shared.ts";
45

@@ -28,7 +29,7 @@ function formatCondition(condition: AlertCondition): string {
2829
return `${agg}${metric} ${condition.compareType} ${condition.compareValue} (${condition.period}s)`;
2930
}
3031

31-
export default defineCommand({
32+
export default defineTelemetryCommand({
3233
description: {
3334
"en-US": "List alert templates (official and custom); pass --template-id for details",
3435
"zh-CN": "查看告警模板(官方与自定义);传 --template-id 查看单个模板详情",
@@ -81,7 +82,7 @@ export default defineCommand({
8182
exampleArgs: ["", "--source Official", "--name 失败率", "--template-id 123 --output json"],
8283
async run(ctx) {
8384
const { settings, flags } = ctx;
84-
const format = settings.outputExplicit ? detectOutputFormat(settings.output) : "json";
85+
const format = detectOutputFormat(settings.output);
8586

8687
const reqDTO = {
8788
resourceType: "model",
@@ -97,7 +98,7 @@ export default defineCommand({
9798
{
9899
api: LIST_TEMPLATES_API,
99100
data: { reqDTO },
100-
...effectiveConsoleGatewayConfig(settings),
101+
...telemetryGatewayPreview(settings),
101102
},
102103
format,
103104
);

0 commit comments

Comments
 (0)