Files
Checkmate/server/src/repositories/monitors/IMonitorsRepository.ts
T

47 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-01-27 19:24:02 +00:00
import { type MonitorType, type Monitor, type MonitorsSummary } from "@/types/index.js";
2026-01-12 22:58:46 +00:00
export interface TeamQueryConfig {
limit?: number;
type?: MonitorType | MonitorType[];
page?: number;
rowsPerPage?: number;
filter?: string;
field?: string;
order?: "asc" | "desc";
}
2026-01-14 23:34:05 +00:00
export interface SummaryConfig {
type?: MonitorType | MonitorType[];
}
2026-01-12 19:32:23 +00:00
export interface IMonitorsRepository {
// create
2026-01-13 20:20:00 +00:00
create(monitor: Monitor, teamId: string, userId: string): Promise<Monitor | null>;
2026-02-21 16:17:23 +00:00
createMonitors(monitors: Monitor[]): Promise<Monitor[]>;
2026-01-12 19:32:23 +00:00
// single fetch
2026-01-15 20:55:01 +00:00
findById(monitorId: string, teamId: string): Promise<Monitor>;
2026-01-13 20:20:00 +00:00
2026-01-12 19:32:23 +00:00
// collection fetch
findAll(): Promise<Monitor[] | null>;
2026-01-12 22:58:46 +00:00
findByTeamId(teamId: string, config: TeamQueryConfig): Promise<Monitor[] | null>;
2026-01-15 20:55:01 +00:00
findByIds(monitorIds: string[]): Promise<Monitor[]>;
2026-01-27 19:24:02 +00:00
findByIdsWithChecks(monitorIds: string[], checksCount?: number): Promise<Monitor[]>;
2026-01-15 18:21:36 +00:00
2026-01-12 19:32:23 +00:00
// update
2026-01-15 18:33:03 +00:00
updateById(monitorId: string, teamId: string, updates: Partial<Monitor>): Promise<Monitor>;
2026-01-15 18:21:36 +00:00
togglePauseById(monitorId: string, teamId: string): Promise<Monitor>;
2026-01-12 19:32:23 +00:00
// delete
2026-01-15 18:24:58 +00:00
deleteById(monitorId: string, teamId: string): Promise<Monitor>;
2026-01-13 23:22:34 +00:00
deleteByTeamId(teamId: string): Promise<{ monitors: Monitor[]; deletedCount: number }>;
2026-01-12 22:58:46 +00:00
// counts
findMonitorCountByTeamIdAndType(teamId: string, config: TeamQueryConfig): Promise<number>;
2026-01-14 23:34:05 +00:00
// other
2026-01-21 00:01:38 +00:00
findMonitorsSummaryByTeamId(teamId: string, config?: SummaryConfig): Promise<MonitorsSummary>;
2026-01-15 18:21:36 +00:00
findGroupsByTeamId(teamId: string): Promise<string[]>;
2026-01-21 13:51:04 -08:00
removeNotificationFromMonitors(notificationId: string): Promise<void>;
updateNotifications(teamId: string, monitorIds: string[], notificationIds: string[], action: "add" | "remove" | "set"): Promise<number>;
2026-02-17 19:03:17 +00:00
deleteByTeamIdsNotIn(teamIds: string[]): Promise<number>;
findAllMonitorIds(): Promise<string[]>;
2026-01-12 19:32:23 +00:00
}