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

88 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-01-02 22:16:00 +00:00
import type {
Monitor,
MonitorType,
MonitorStatus,
} from "@/types/domain/monitor.js";
2026-01-02 23:28:36 +00:00
export type UpdateMonitorPatch = Partial<
Pick<
Monitor,
| "name"
| "secret"
| "interval"
| "rejectUnauthorized"
| "n"
| "thresholds"
| "notificationChannels"
| "status"
>
>;
2026-01-02 22:16:00 +00:00
export interface TeamQueryConfig {
search: string;
sortField: string;
sortOrder: string;
page: number;
rowsPerPage: number;
type: MonitorType[];
status: MonitorStatus[];
}
export interface IMonitorRepository {
2026-01-02 23:28:36 +00:00
// Create
create(
orgId: string,
userId: string,
currentTeamId: string,
monitorData: Monitor
): Promise<Monitor>;
2026-01-04 22:44:39 +00:00
createMany(
userId: string,
orgId: string,
teamId: string,
monitorData: Monitor[]
): Promise<Monitor[]>;
2026-01-02 22:16:00 +00:00
// Single fetch
2026-01-02 23:28:36 +00:00
findAll(): Promise<Monitor[]>;
2026-01-02 22:16:00 +00:00
findById(monitorId: string, teamId: string): Promise<Monitor | null>;
// Collection fetches
findByTeamId(teamId: string): Promise<Monitor[]>;
findByTeamIdWithConfig(
teamId: string,
config: TeamQueryConfig
): Promise<Monitor[]>;
findMonitorCountsByTeamId(teamId: string): Promise<{
total: number;
upCount: number;
downCount: number;
pausedCount: number;
}>;
findByOrgId(orgId: string): Promise<Monitor[]>;
// Deletions
2026-01-03 20:47:02 +00:00
deleteAll(): Promise<boolean>;
2026-01-02 23:28:36 +00:00
deleteById(monitorId: string, teamId: string): Promise<boolean>;
deleteByOrgId(orgId: string): Promise<boolean>;
// Updates
togglePauseById(
monitorId: string,
teamId: string,
userId: string
): Promise<Monitor | null>;
updateById(
monitorId: string,
teamId: string,
userId: string,
patch: UpdateMonitorPatch
): Promise<Monitor | null>;
2026-01-02 22:16:00 +00:00
2026-01-02 23:28:36 +00:00
// Counts
countByOrgId(orgId: string): Promise<number>;
2026-01-07 21:11:44 +00:00
countByIdAndTeamId(monitorIds: string[], teamId: string): Promise<number>;
2026-01-02 23:28:36 +00:00
}