feat(q1): 前端类型安全治理完成 — any 83→40, P0 全部 done
- types/monitor.ts: 新增 6 个运行时记录类型(AlertEventRecord/AlertRuleRecord/ AgentHostRecord/CronJobRecord/CertExpiryRecord/ApprovalWorkflowStepRecord) - types/common.ts: 新增 OptionItem 通用下拉类型 - 组件级 any 清理 43 处: - AlertEventsTab/AlertRulesTab/AlertChannelDialog/alertShared (19处) - AuditOperationsTab normalizeLog + 筛选器 (8处) - CronJobManager 任务列表/编辑/操作 (6处) - AgentMonitor 主机列表/命令执行 (5处) - DashboardRecent 5 张卡片组件 (5处) - AlertManager 状态类型对齐 (联动修复) - Dashboard.tsx 调用端类型对齐 (联动修复) - AlertChannel 接口新增 test_status 字段 - ESLint any: 83→40 (<50 目标达成) - tsc -b / tsc --noEmit: 零错误 - npm run build: ✓ built in 17.11s - 9/9 核心 API 回归通过
This commit is contained in:
1 parent
0535f30c87
commit
bb2b91ebe0
15 files changed
+259
-93
No files matched your search
@@ -37,6 +37,12 @@ export const ErrorCode = {
|
||||
INTERNAL_ERROR: 500,
|
||||
} as const;
|
||||
|
||||
// 下拉选项通用类型(模块/操作类型等筛选器)
|
||||
export interface OptionItem {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
// WebSocket 消息
|
||||
export interface WsMessage<T = unknown> {
|
||||
type: string;
|
||||
|
||||
@@ -175,6 +175,7 @@ export interface AlertChannel {
|
||||
config: string; // JSON string
|
||||
enabled: boolean;
|
||||
description: string;
|
||||
test_status?: string;
|
||||
}
|
||||
|
||||
// ===== 健康探针 =====
|
||||
@@ -371,3 +372,113 @@ export interface GrafanaDashboard {
|
||||
createdBy: string;
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
// ===== 运行时记录类型(与后端 API 响应 JSON 对齐,snake_case)=====
|
||||
|
||||
/** 告警事件运行时记录 — GET /alerts 返回,字段高度动态 */
|
||||
export interface AlertEventRecord {
|
||||
id: number;
|
||||
rule?: { id: number; name: string };
|
||||
rule_id?: number;
|
||||
rule_name?: string;
|
||||
severity: string;
|
||||
status: string;
|
||||
message: string;
|
||||
target: string;
|
||||
value?: number;
|
||||
threshold?: number;
|
||||
started_at?: string;
|
||||
resolved_at?: string;
|
||||
created_at?: string;
|
||||
acked?: boolean;
|
||||
}
|
||||
|
||||
/** 告警规则运行时记录 — GET /alerts/rules 返回 */
|
||||
export interface AlertRuleRecord {
|
||||
id: number;
|
||||
name: string;
|
||||
metric?: string;
|
||||
operator?: string;
|
||||
threshold?: number;
|
||||
duration?: number;
|
||||
duration_sec?: number;
|
||||
severity: string;
|
||||
enabled: boolean;
|
||||
description?: string;
|
||||
notify_channels?: string | (number | string)[];
|
||||
server_id?: number;
|
||||
server_hostname?: string;
|
||||
type?: string;
|
||||
source?: string;
|
||||
expression?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
/** Agent 主机运行时记录 — GET /agent/latest 返回 */
|
||||
export interface AgentHostRecord {
|
||||
id?: number;
|
||||
hostname: string;
|
||||
ip?: string;
|
||||
agent_version?: string;
|
||||
os?: string;
|
||||
kernel?: string;
|
||||
status?: string;
|
||||
agent_status?: string;
|
||||
last_seen?: string;
|
||||
last_report?: string;
|
||||
last_reported_at?: string;
|
||||
updated_at?: string;
|
||||
cpu_percent?: number;
|
||||
cpu?: number;
|
||||
mem_percent?: number;
|
||||
mem?: number;
|
||||
disk_percent?: number;
|
||||
disk?: number;
|
||||
ports?: unknown[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/** 定时任务运行时记录 — GET /cron-jobs 返回 */
|
||||
export interface CronJobRecord {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
enabled: boolean;
|
||||
cron?: string;
|
||||
cron_expr?: string;
|
||||
command?: string;
|
||||
content?: string;
|
||||
script?: { name: string; [key: string]: unknown } | null;
|
||||
type?: string;
|
||||
target_type?: string;
|
||||
targets?: string[];
|
||||
success_count?: number;
|
||||
fail_count?: number;
|
||||
run_count?: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
last_run_at?: string;
|
||||
last_status?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/** 域名证书到期记录 */
|
||||
export interface CertExpiryRecord {
|
||||
id?: number | string;
|
||||
domain: string;
|
||||
name?: string;
|
||||
expire_date: string;
|
||||
days_until_expiry?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/** 审批工作流步骤运行时记录 */
|
||||
export interface ApprovalWorkflowStepRecord {
|
||||
id?: number;
|
||||
step_order: number;
|
||||
step_type: 'submit' | 'audit' | 'execute' | string;
|
||||
name: string;
|
||||
approver_ids?: number[];
|
||||
description?: string;
|
||||
}
|
||||
Reference in new issue
Block a user