Files
Checkmate/server/src/domain/monitors/monitor.repository.interface.ts
T

70 lines
3.0 KiB
TypeScript
Raw Normal View History

2026-08-04 15:16:03 -07:00
import type { MonitorType, Monitor, MonitorStatus, MonitorsSummary, CheckSnapshot, MonitorScheduleFields } from "@/domain/monitors/monitor.type.js";
2026-01-12 22:58:46 +00:00
export interface TeamQueryConfig {
limit?: number;
type?: MonitorType | MonitorType[];
2026-05-19 14:44:18 -07:00
tags?: string | string[];
2026-01-12 22:58:46 +00:00
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-05-20 12:25:36 -07:00
tags?: string | string[];
2026-01-14 23:34:05 +00:00
}
2026-08-19 10:20:21 -07:00
export type RecentChecksMode = "all" | "latestHardware" | "none";
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-06-18 11:06:19 -07:00
// for workers, don't need all details
findByIdLean(monitorId: string): Promise<Monitor | null>;
2026-01-13 20:20:00 +00:00
2026-01-12 19:32:23 +00:00
// collection fetch
2026-08-04 15:16:03 -07:00
findAllForScheduling(): Promise<MonitorScheduleFields[]>;
2026-08-04 15:30:34 -07:00
findByTeamId(teamId: string, config: TeamQueryConfig, options?: { includeRecentChecks?: boolean }): Promise<Monitor[]>;
findByTeamIdWithStats(teamId: string, config: TeamQueryConfig): Promise<Monitor[]>;
2026-08-19 10:20:21 -07:00
findByIds(monitorIds: string[], options?: { recentChecks?: RecentChecksMode }): Promise<Monitor[]>;
2026-01-15 18:21:36 +00:00
2026-01-12 19:32:23 +00:00
// update
2026-08-26 11:19:08 -07:00
updateById(monitorId: string, teamId: string, updates: Partial<Monitor>, options?: { unsetProxyId?: boolean }): Promise<Monitor>;
2026-05-21 11:02:59 -07:00
updateByIds(monitorIds: string[], teamId: string, updates: Partial<Monitor>, excludeStatuses?: MonitorStatus[]): Promise<number>;
2026-04-16 10:41:00 -07:00
updateStatusWindowAndChecks(
monitorId: string,
teamId: string,
status: boolean,
checkSnapshot: CheckSnapshot,
windowSize: number,
maxRecentChecks: number,
statusPatch?: Partial<Monitor>
2026-04-16 10:41:00 -07:00
): Promise<Monitor>;
2026-01-15 18:21:36 +00:00
togglePauseById(monitorId: string, teamId: string): Promise<Monitor>;
bulkTogglePause(monitorIds: string[], teamId: string, pause: boolean): 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-08-20 11:31:51 -07:00
findMonitorCountByProxyId(proxyId: string): Promise<number>;
2026-01-14 23:34:05 +00:00
// Docker TLS
findDockerTlsKeyById(monitorId: string): Promise<string | null>;
findAllDockerTlsKeys(): Promise<{ id: string; dockerTlsKey: string }[]>;
updateDockerTlsKey(monitorId: string, dockerTlsKey: string): Promise<void>; // Needed for worker to rotate keys, no teamId/userId
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-21 13:51:04 -08:00
removeNotificationFromMonitors(notificationId: string): Promise<void>;
removeTagFromMonitors(tagId: 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
}