@experts_hub/shared
Version:
Shared DTOs, interfaces, and utilities for experts hub applications
85 lines (84 loc) • 2.04 kB
TypeScript
export declare enum AlertSeverity {
CRITICAL = "CRITICAL",
ERROR = "ERROR",
WARNING = "WARNING",
SECURITY = "SECURITY",
INFO = "INFO",
SUCCESS = "SUCCESS"
}
export declare enum AlertCategory {
CRITICAL_ERROR = "CRITICAL_ERROR",
DATABASE = "DATABASE",
PAYMENT = "PAYMENT",
SECURITY = "SECURITY",
PERFORMANCE = "PERFORMANCE",
BUSINESS_EVENT = "BUSINESS_EVENT"
}
export interface DiscordAlertOptions {
severity: AlertSeverity;
category: AlertCategory;
title: string;
description: string;
fields?: Record<string, string | number | boolean>;
metadata?: {
microservice?: string;
environment?: string;
correlationId?: string;
userId?: string;
requestPath?: string;
requestMethod?: string;
errorStack?: string;
hostname?: string;
[key: string]: any;
};
}
export interface DiscordWebhookConfig {
errorWebhookUrl?: string;
securityWebhookUrl?: string;
businessWebhookUrl?: string;
performanceWebhookUrl?: string;
enabled?: boolean;
rateLimitPerMinute?: number;
environment?: string;
microserviceName?: string;
}
export interface DiscordEmbedField {
name: string;
value: string;
inline?: boolean;
}
export interface DiscordEmbedFooter {
text: string;
icon_url?: string;
}
export interface DiscordEmbed {
title: string;
description: string;
color: number;
fields: DiscordEmbedField[];
footer?: DiscordEmbedFooter;
timestamp: string;
thumbnail?: {
url: string;
};
author?: {
name: string;
icon_url?: string;
};
}
export interface DiscordWebhookPayload {
content?: string;
embeds: DiscordEmbed[];
username?: string;
avatar_url?: string;
}
export interface RateLimitState {
webhookUrl: string;
timestamps: number[];
}
export interface AlertKeyComponents {
severity: AlertSeverity;
category: AlertCategory;
title: string;
microservice?: string;
}