UNPKG

dt-common-device

Version:

A secure and robust device management library for IoT applications

107 lines (106 loc) 3.21 kB
import { IAlertDocument } from "./Alert.model"; import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, EntityType } from "./alert.types"; export declare class AlertRepository { /** * Create a new alert */ create(alertData: CreateAlertData): Promise<IAlertDocument>; /** * Find alert by ID */ findById(id: string, includeDeleted?: boolean): Promise<IAlertDocument | null>; /** * Find all alerts with filters */ findAll(filters?: { propertyId?: string; category?: AlertCategory | AlertCategory[]; severity?: AlertSeverity; entityType?: EntityType; entityId?: string; isActive?: boolean; isRead?: boolean; includeDeleted?: boolean; limit?: number; skip?: number; sort?: { [key: string]: 1 | -1; }; }): Promise<IAlertDocument[]>; /** * Update an alert */ update(id: string, updateData: UpdateAlertData): Promise<IAlertDocument | null>; /** * Soft delete an alert */ softDelete(id: string, deletedBy: string): Promise<boolean>; /** * Permanently delete an alert */ hardDelete(id: string): Promise<boolean>; /** * Count alerts with filters */ count(filters?: { propertyId?: string; category?: AlertCategory | AlertCategory[]; severity?: AlertSeverity; entityType?: EntityType; entityId?: string; isActive?: boolean; isRead?: boolean; includeDeleted?: boolean; }): Promise<number>; /** * Find alerts by property */ findByProperty(propertyId: string, includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find alerts by entity */ findByEntity(entityId: string, entityType: EntityType, includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find alerts by category */ findByCategory(category: AlertCategory | AlertCategory[], includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find alerts by severity */ findBySeverity(severity: AlertSeverity, includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find active alerts */ findActive(includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find unread alerts */ findUnread(includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find snoozed alerts */ findSnoozed(includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Find expired snooze alerts */ findExpiredSnooze(includeDeleted?: boolean): Promise<IAlertDocument[]>; /** * Get alert statistics */ getStatistics(propertyId?: string): Promise<{ total: number; active: number; unread: number; snoozed: number; bySeverity: Record<AlertSeverity, number>; byCategory: Record<AlertCategory, number>; }>; /** * Bulk update alerts */ bulkUpdate(ids: string[], updateData: Partial<UpdateAlertData>): Promise<number>; /** * Bulk soft delete alerts */ bulkSoftDelete(ids: string[], deletedBy: string): Promise<number>; }