claritykit-svelte
Version:
A comprehensive Svelte component library focused on accessibility, ADHD-optimized design, developer experience, and full SSR compatibility
626 lines • 15.9 kB
TypeScript
import type { HTMLAttributes } from 'svelte/elements';
export type SystemStatus = 'healthy' | 'warning' | 'critical' | 'degraded' | 'down';
export type AlertSeverity = 'info' | 'warning' | 'critical';
export type AgentStatus = 'healthy' | 'warning' | 'critical' | 'disabled' | 'offline';
export type EventType = 'system' | 'alert' | 'agent' | 'performance' | 'security';
export type TimeRange = '1h' | '6h' | '24h' | '7d' | '30d';
export type MetricType = 'performance' | 'resource' | 'agent' | 'alert';
export interface SystemMetrics {
uptime: number;
totalRequests: number;
requestsPerSecond: number;
errorRate: number;
responseTime: {
average: number;
p95: number;
p99: number;
median?: number;
};
activeConnections: number;
lastUpdated: Date;
throughput?: {
successfulRequests: number;
failedRequests: number;
timeoutRequests: number;
};
availability?: number;
reliability?: number;
serviceLevel?: {
target: number;
current: number;
};
}
export interface AgentHealth {
id: string;
type: string;
status: AgentStatus;
metrics: {
responseTime: number;
successRate: number;
activeTasks: number;
completedTasks: number;
failedTasks: number;
averageTaskDuration: number;
};
lastHealthCheck: Date;
lastStatusChange: Date;
consecutiveFailures: number;
resourceUsage?: {
cpu: number;
memory: number;
networkIO: number;
};
lastError?: string;
errorHistory?: Array<{
timestamp: Date;
error: string;
severity: AlertSeverity;
}>;
endpoint?: string;
version?: string;
capabilities?: string[];
startTime?: Date;
uptime?: number;
restartCount?: number;
}
export interface AlertRule {
id: string;
name: string;
description?: string;
condition: string;
threshold: number;
severity: AlertSeverity;
enabled: boolean;
triggered: boolean;
triggeredAt?: Date;
resolvedAt?: Date;
acknowledgment?: {
acknowledgedBy: string;
acknowledgedAt: Date;
note?: string;
};
createdAt: Date;
createdBy?: string;
lastModified?: Date;
notificationChannels: string[];
suppressionRules?: {
timeWindow: number;
maxNotifications: number;
};
escalation?: {
enabled: boolean;
delay: number;
recipients: string[];
};
tags?: string[];
category?: string;
documentation?: string;
}
export interface PerformanceMetric {
id: string;
metricName: string;
value: number;
unit: string;
timestamp: Date;
source: string;
category: 'system' | 'application' | 'database' | 'network';
metadata?: Record<string, any>;
dimensions?: Record<string, string>;
dataQuality?: {
accuracy: number;
completeness: number;
freshness: number;
};
}
export interface ResourceUsage {
cpu: number;
memory: number;
storage: number;
network: {
inbound: number;
outbound: number;
connections: number;
latency?: number;
};
database: {
connections: number;
maxConnections: number;
queryTime: number;
cacheHitRatio?: number;
lockWaitTime?: number;
};
application?: {
threadPoolUsage: number;
queueDepth: number;
sessionCount: number;
errorRate: number;
};
infrastructure?: {
loadBalancerHealth: SystemStatus;
cacheHealth: SystemStatus;
storageHealth: SystemStatus;
};
lastUpdated: Date;
collectionInterval?: number;
}
export interface SystemEvent {
id: string;
type: EventType;
severity: AlertSeverity;
message: string;
timestamp: Date;
source: string;
details?: Record<string, any>;
affected?: {
agents?: string[];
services?: string[];
users?: string[];
};
resolved?: boolean;
resolvedAt?: Date;
resolvedBy?: string;
resolution?: string;
correlationId?: string;
parentEventId?: string;
relatedEvents?: string[];
impact?: {
level: 'low' | 'medium' | 'high' | 'critical';
affectedUsers: number;
businessImpact: string;
technicalImpact: string;
};
tags?: string[];
category?: string;
location?: string;
}
export interface SystemMonitoringDashboardProps extends HTMLAttributes<HTMLDivElement> {
/**
* Current system performance metrics
*/
systemMetrics?: SystemMetrics;
/**
* Health status of all agents
*/
agentHealth?: AgentHealth[];
/**
* Configured alert rules
*/
alertRules?: AlertRule[];
/**
* Historical performance metrics
*/
performanceMetrics?: PerformanceMetric[];
/**
* Current resource utilization
*/
resourceUsage?: ResourceUsage;
/**
* Recent system events and logs
*/
systemEvents?: SystemEvent[];
/**
* Show real-time metrics section
* @default true
*/
showRealTimeMetrics?: boolean;
/**
* Show agent health monitoring
* @default true
*/
showAgentHealth?: boolean;
/**
* Show alert management interface
* @default true
*/
showAlertManagement?: boolean;
/**
* Show resource usage monitoring
* @default true
*/
showResourceUsage?: boolean;
/**
* Show system events log
* @default true
*/
showSystemEvents?: boolean;
/**
* Enable automatic refresh of metrics
* @default true
*/
autoRefresh?: boolean;
/**
* Refresh interval in milliseconds
* @default 30000
*/
refreshInterval?: number;
/**
* Callback when alert is triggered
*/
onAlertTriggered?: (alert: AlertRule) => void;
/**
* Callback when agent status changes
*/
onAgentStatusChanged?: (agentId: string, status: AgentStatus) => void;
/**
* Callback when metrics are updated
*/
onMetricsUpdated?: (metrics: SystemMetrics) => void;
/**
* Callback when alert rule is created/modified
*/
onAlertRuleChanged?: (rule: AlertRule, action: 'created' | 'updated' | 'deleted') => void;
/**
* Callback when system event occurs
*/
onSystemEvent?: (event: SystemEvent) => void;
/**
* Callback when user acknowledges alert
*/
onAlertAcknowledged?: (alertId: string, note?: string) => void;
}
export interface MonitoringService {
/**
* Get current system metrics
*/
getCurrentMetrics: () => Promise<SystemMetrics>;
/**
* Get historical metrics for time range
*/
getHistoricalMetrics: (timeRange: TimeRange, metricTypes?: string[]) => Promise<PerformanceMetric[]>;
/**
* Get agent health status
*/
getAgentHealth: () => Promise<AgentHealth[]>;
/**
* Get resource utilization
*/
getResourceUsage: () => Promise<ResourceUsage>;
/**
* Get system events
*/
getSystemEvents: (limit?: number, severity?: AlertSeverity, type?: EventType) => Promise<SystemEvent[]>;
/**
* Subscribe to real-time updates
*/
subscribeToUpdates: (callback: (update: MonitoringUpdate) => void) => () => void;
}
export interface MonitoringUpdate {
type: 'metrics' | 'agent' | 'alert' | 'event' | 'resource';
timestamp: Date;
data: any;
source: string;
}
export interface AlertManager {
/**
* Create new alert rule
*/
createAlert: (rule: Omit<AlertRule, 'id' | 'createdAt'>) => Promise<AlertRule>;
/**
* Update existing alert rule
*/
updateAlert: (id: string, updates: Partial<AlertRule>) => Promise<AlertRule>;
/**
* Delete alert rule
*/
deleteAlert: (id: string) => Promise<void>;
/**
* Enable/disable alert rule
*/
toggleAlert: (id: string, enabled: boolean) => Promise<void>;
/**
* Acknowledge alert
*/
acknowledgeAlert: (id: string, acknowledgedBy: string, note?: string) => Promise<void>;
/**
* Test alert condition
*/
testAlert: (condition: string, threshold: number) => Promise<{
result: boolean;
currentValue: number;
explanation: string;
}>;
/**
* Get alert history
*/
getAlertHistory: (alertId?: string, timeRange?: TimeRange) => Promise<AlertHistory[]>;
}
export interface AlertHistory {
id: string;
alertRuleId: string;
alertRuleName: string;
triggeredAt: Date;
resolvedAt?: Date;
duration?: number;
severity: AlertSeverity;
triggerValue: number;
threshold: number;
acknowledgment?: {
acknowledgedBy: string;
acknowledgedAt: Date;
note?: string;
};
resolution?: {
resolvedBy: string;
resolvedAt: Date;
resolution: string;
rootCause?: string;
};
}
export interface AgentManager {
/**
* Get detailed agent information
*/
getAgentDetails: (agentId: string) => Promise<AgentHealth>;
/**
* Restart agent
*/
restartAgent: (agentId: string) => Promise<void>;
/**
* Stop agent
*/
stopAgent: (agentId: string) => Promise<void>;
/**
* Start agent
*/
startAgent: (agentId: string) => Promise<void>;
/**
* Get agent logs
*/
getAgentLogs: (agentId: string, limit?: number, severity?: AlertSeverity) => Promise<AgentLogEntry[]>;
/**
* Update agent configuration
*/
updateAgentConfig: (agentId: string, config: Record<string, any>) => Promise<void>;
/**
* Run health check on agent
*/
healthCheck: (agentId: string) => Promise<{
healthy: boolean;
responseTime: number;
details: Record<string, any>;
}>;
}
export interface AgentLogEntry {
timestamp: Date;
level: 'debug' | 'info' | 'warning' | 'error';
message: string;
source: string;
context?: Record<string, any>;
error?: {
name: string;
message: string;
stack?: string;
};
}
export interface DashboardConfig {
layout: {
sections: DashboardSection[];
refreshInterval: number;
autoRefresh: boolean;
};
alerts: {
defaultSeverity: AlertSeverity;
notificationChannels: NotificationChannel[];
escalationPolicy: EscalationPolicy;
};
metrics: {
retentionPeriod: number;
aggregationIntervals: number[];
customMetrics: CustomMetric[];
};
appearance: {
theme: 'light' | 'dark' | 'auto';
dateFormat: string;
timezone: string;
language: string;
};
}
export interface DashboardSection {
id: string;
type: MetricType;
title: string;
enabled: boolean;
position: {
row: number;
col: number;
};
size: {
width: number;
height: number;
};
config: Record<string, any>;
}
export interface NotificationChannel {
id: string;
type: 'email' | 'slack' | 'webhook' | 'sms' | 'pagerduty';
name: string;
config: Record<string, any>;
enabled: boolean;
}
export interface EscalationPolicy {
id: string;
name: string;
steps: EscalationStep[];
enabled: boolean;
}
export interface EscalationStep {
delay: number;
recipients: string[];
channels: string[];
condition?: string;
}
export interface CustomMetric {
id: string;
name: string;
query: string;
unit: string;
description: string;
category: string;
enabled: boolean;
}
export interface MetricsStreamer {
/**
* Start streaming metrics
*/
startStream: (types: MetricType[]) => void;
/**
* Stop streaming metrics
*/
stopStream: () => void;
/**
* Subscribe to specific metric updates
*/
subscribe: (metricName: string, callback: (value: number, timestamp: Date) => void) => () => void;
/**
* Get streaming status
*/
getStatus: () => {
connected: boolean;
lastUpdate: Date;
activeSubscriptions: number;
};
}
export interface MonitoringAnalytics {
/**
* Generate system health report
*/
generateHealthReport: (timeRange: TimeRange) => Promise<HealthReport>;
/**
* Generate performance analysis
*/
generatePerformanceAnalysis: (timeRange: TimeRange, metrics: string[]) => Promise<PerformanceAnalysis>;
/**
* Generate SLA report
*/
generateSLAReport: (timeRange: TimeRange, services: string[]) => Promise<SLAReport>;
/**
* Get trending metrics
*/
getTrendingMetrics: (timeRange: TimeRange) => Promise<TrendingMetric[]>;
/**
* Detect anomalies
*/
detectAnomalies: (metrics: string[], timeRange: TimeRange) => Promise<Anomaly[]>;
}
export interface HealthReport {
timeRange: {
start: Date;
end: Date;
};
overallHealth: SystemStatus;
summary: {
uptime: number;
incidents: number;
resolvedIncidents: number;
averageResolutionTime: number;
};
components: Array<{
name: string;
status: SystemStatus;
uptime: number;
incidents: number;
}>;
trends: {
uptimeTrend: 'improving' | 'stable' | 'declining';
performanceTrend: 'improving' | 'stable' | 'declining';
errorRateTrend: 'improving' | 'stable' | 'declining';
};
recommendations: string[];
insights: string[];
}
export interface PerformanceAnalysis {
timeRange: {
start: Date;
end: Date;
};
summary: {
averageResponseTime: number;
throughput: number;
errorRate: number;
availability: number;
};
bottlenecks: Array<{
component: string;
metric: string;
impact: 'low' | 'medium' | 'high';
description: string;
recommendation: string;
}>;
patterns: Array<{
type: 'seasonal' | 'daily' | 'weekly' | 'irregular';
description: string;
confidence: number;
}>;
comparisons: {
previousPeriod: {
responseTime: {
change: number;
trend: 'better' | 'worse' | 'same';
};
throughput: {
change: number;
trend: 'better' | 'worse' | 'same';
};
errorRate: {
change: number;
trend: 'better' | 'worse' | 'same';
};
};
};
}
export interface SLAReport {
timeRange: {
start: Date;
end: Date;
};
services: Array<{
name: string;
target: number;
actual: number;
status: 'met' | 'at-risk' | 'breached';
breaches: Array<{
start: Date;
end: Date;
duration: number;
impact: string;
}>;
creditCalculation?: {
totalCredits: number;
details: Array<{
period: Date;
credit: number;
reason: string;
}>;
};
}>;
overall: {
met: number;
atRisk: number;
breached: number;
};
}
export interface TrendingMetric {
name: string;
currentValue: number;
trend: {
direction: 'up' | 'down' | 'stable';
magnitude: number;
timeframe: string;
};
significance: 'high' | 'medium' | 'low';
category: string;
}
export interface Anomaly {
id: string;
metricName: string;
timestamp: Date;
expectedValue: number;
actualValue: number;
deviation: number;
severity: 'low' | 'medium' | 'high';
confidence: number;
description: string;
possibleCauses: string[];
relatedAnomalies?: string[];
}
//# sourceMappingURL=types.d.ts.map