refactor(q1): src/api 全量清零 any + types/monitor 扩展输入 DTO
ROADMAP Q1 推进(前端类型安全治理 in_progress): - src/api/ 整个目录 any 清零(含 monitor/ deploy/ 子目录 12+ 文件) create/update 入参 any -> Record<string, unknown> / object mock 桩 trace/grafana 对接 types/ 标准类型(Trace/GrafanaDashboard) 典型接口 LdapFormData/ProbeForm 等强类型表单用 object 接收 - types/monitor.ts 扩展 ~150 行接口: ZabbixDatasource / AlertSilence / 7 个输入 DTO Trace / TraceSpan / TraceServiceMetrics / GrafanaDashboard / DashboardPanel HealthProbeInput 验证: - 整个 src/api/ 目录 any=0 - ESLint no-explicit-any: 995 -> 937 (本项目此轮贡献 -58) - tsc -b 零错误, npm run build ✓ (17.06s) - API 回归 8/8 核心端点通过, Docker 部署 healthy
This commit is contained in:
1 parent
480e677042
commit
b553c7956d
436 files changed
+410
-1198
No files matched your search
@@ -215,3 +215,158 @@ export interface PrometheusDatasource {
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== Zabbix 数据源 =====
|
||||
export interface ZabbixDatasource {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
username: string;
|
||||
password: string;
|
||||
enabled: boolean;
|
||||
is_default: boolean;
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 告警静默规则 =====
|
||||
export interface AlertSilence {
|
||||
id: number;
|
||||
name: string;
|
||||
matchers: { key: string; value: string; is_regex?: boolean }[];
|
||||
starts_at: string;
|
||||
ends_at: string;
|
||||
repeat_mode: 'onetime' | 'daily' | 'weekly';
|
||||
enabled: boolean;
|
||||
created_by: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 输入 DTO(创建/更新用,枚举字段放宽为 string 以兼容表单)=====
|
||||
export interface AlertRuleInput {
|
||||
name?: string;
|
||||
server_id?: number;
|
||||
server_hostname?: string;
|
||||
metric?: string;
|
||||
operator?: string;
|
||||
threshold?: number;
|
||||
duration_sec?: number;
|
||||
severity?: string;
|
||||
enabled?: boolean;
|
||||
notify_channels?: (number | string)[];
|
||||
description?: string;
|
||||
type?: string;
|
||||
source?: string;
|
||||
expression?: string;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export interface AlertContactInput {
|
||||
name?: string;
|
||||
channel_type?: string;
|
||||
webhook_url?: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
enabled?: boolean;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface AlertContactGroupInput {
|
||||
name?: string;
|
||||
description?: string;
|
||||
contact_ids?: number[];
|
||||
}
|
||||
|
||||
export interface AlertChannelInput {
|
||||
name?: string;
|
||||
type?: string;
|
||||
config?: string;
|
||||
enabled?: boolean;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export type PrometheusDatasourceInput = Record<string, unknown>;
|
||||
export type ZabbixDatasourceInput = Record<string, unknown>;
|
||||
|
||||
export interface AlertSilenceInput {
|
||||
name?: string;
|
||||
description?: string;
|
||||
matchers?: { key: string; value: string; is_regex?: boolean }[];
|
||||
starts_at?: string;
|
||||
ends_at?: string;
|
||||
silence_type?: string;
|
||||
start_time?: string;
|
||||
end_time?: string;
|
||||
repeat_mode?: string;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
// ===== 健康探针输入 =====
|
||||
export type HealthProbeInput = Partial<Omit<HealthProbe, 'id' | 'last_status' | 'last_checked_at'>>;
|
||||
|
||||
// ===== 链路追踪(mock 桩,与 TraceManager 消费者形状对齐)=====
|
||||
export interface TraceSpan {
|
||||
id: string;
|
||||
spanId: string;
|
||||
parentSpanId?: string;
|
||||
serviceName: string;
|
||||
operationName: string;
|
||||
startTime: string;
|
||||
duration: number;
|
||||
status: 'success' | 'error' | 'pending';
|
||||
kind: 'client' | 'server' | 'producer' | 'consumer' | 'internal';
|
||||
tags: Record<string, string>;
|
||||
logs: { timestamp: string; fields: Record<string, string> }[];
|
||||
children: TraceSpan[];
|
||||
}
|
||||
|
||||
export interface Trace {
|
||||
id: string;
|
||||
traceId: string;
|
||||
serviceName: string;
|
||||
operationName: string;
|
||||
startTime: string;
|
||||
duration: number;
|
||||
status: 'success' | 'error' | 'pending';
|
||||
spanCount: number;
|
||||
tags: Record<string, string>;
|
||||
spans?: TraceSpan[];
|
||||
}
|
||||
|
||||
export interface TraceServiceMetrics {
|
||||
serviceName: string;
|
||||
requestCount: number;
|
||||
errorRate: number;
|
||||
avgDuration: number;
|
||||
p95Duration: number;
|
||||
p99Duration: number;
|
||||
}
|
||||
|
||||
// ===== Grafana 仪表盘(mock 桩,与消费者形状对齐)=====
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export interface DashboardPanel {
|
||||
id: string;
|
||||
title: string;
|
||||
type: string;
|
||||
query: string;
|
||||
datasource: string;
|
||||
width: number;
|
||||
height: number;
|
||||
x: number;
|
||||
y: number;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
options: any;
|
||||
}
|
||||
|
||||
export interface GrafanaDashboard {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
datasource: string;
|
||||
datasourceUrl: string;
|
||||
panels: DashboardPanel[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
createdBy: string;
|
||||
isDefault: boolean;
|
||||
}
|
||||
Reference in new issue
Block a user