dt-common-device
Version:
A secure and robust device management library for IoT applications
100 lines (99 loc) • 3.29 kB
TypeScript
import { IAlertDocument } from "./Alert.model";
import { CreateAlertData, UpdateAlertData, AlertCategory, AlertSeverity, IAlertQuery } from "./alert.types";
export declare class AlertRepository {
private buildQuery;
private buildOptions;
/**
* 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
*/
query(filters?: IAlertQuery): 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?: IAlertQuery): Promise<number>;
/**
* Find alerts by category
*/
findByCategory(category: AlertCategory, 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, zoneId?: 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>;
/**
* Find alerts by zone ID
*/
findByZoneId(zoneId: string, includeDeleted?: boolean): Promise<IAlertDocument[]>;
/**
* Find alerts by zone ID and category
*/
findByZoneIdAndCategory(zoneId: string, category: AlertCategory, includeDeleted?: boolean): Promise<IAlertDocument[]>;
/**
* Find alerts by zone ID and severity
*/
findByZoneIdAndSeverity(zoneId: string, severity: AlertSeverity, includeDeleted?: boolean): Promise<IAlertDocument[]>;
/**
* Find alerts by zone ID and active status
*/
findByZoneIdAndActiveStatus(zoneId: string, isActive: boolean, includeDeleted?: boolean): Promise<IAlertDocument[]>;
/**
* Find alerts by zone ID and read status
*/
findByZoneIdAndReadStatus(zoneId: string, isRead: boolean, includeDeleted?: boolean): Promise<IAlertDocument[]>;
/**
* Find alerts by multiple zone IDs
*/
findByZoneIds(zoneIds: string[], includeDeleted?: boolean): Promise<IAlertDocument[]>;
/**
* Get alert statistics by zone ID and severity
*/
getStatisticsByZoneAndSeverity(zoneId: string, severity?: AlertSeverity): Promise<{
total: number;
active: number;
unread: number;
snoozed: number;
byCategory: Record<AlertCategory, number>;
}>;
}