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-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-07-24 11:32:00 -07:00
|
|
|
findByTeamId(teamId: string, config: TeamQueryConfig): Promise<Monitor[]>;
|
|
|
|
|
findByTeamIdWithStats(teamId: string, config: TeamQueryConfig): Promise<Monitor[]>;
|
2026-01-15 20:55:01 +00:00
|
|
|
findByIds(monitorIds: string[]): 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-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,
|
2026-04-16 10:59:30 -07:00
|
|
|
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>;
|
2026-05-01 19:42:51 +05:30
|
|
|
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-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>;
|
2026-05-19 11:15:16 -07:00
|
|
|
removeTagFromMonitors(tagId: string): Promise<void>;
|
2026-03-20 23:39:38 +05:30
|
|
|
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
|
|
|
}
|