diff --git a/server/src/controllers/monitorController.ts b/server/src/controllers/monitorController.ts index 03cd09e20..9a2b7b774 100644 --- a/server/src/controllers/monitorController.ts +++ b/server/src/controllers/monitorController.ts @@ -59,7 +59,6 @@ class MonitorController { const monitorId = validatedParams.monitorId; const dateRange = validatedQuery.dateRange; - const normalize = validatedQuery.normalize; const teamId = requireTeamId(req.user?.teamId); @@ -67,7 +66,6 @@ class MonitorController { teamId, monitorId, dateRange, - normalize, }); return res.status(200).json({ success: true, @@ -323,7 +321,6 @@ class MonitorController { try { const validatedQuery = getMonitorsWithChecksQueryValidation.parse(req.query); - const explain = validatedQuery.explain; const limit = validatedQuery.limit; const page = validatedQuery.page; const rowsPerPage = validatedQuery.rowsPerPage; @@ -342,7 +339,6 @@ class MonitorController { filter, field, order, - explain, }); return res.status(200).json({ diff --git a/server/src/service/business/monitorService.ts b/server/src/service/business/monitorService.ts index 8a08a7003..8d56fae20 100644 --- a/server/src/service/business/monitorService.ts +++ b/server/src/service/business/monitorService.ts @@ -21,6 +21,7 @@ import type { } from "@/repositories/index.js"; import demoMonitorsData from "@/utils/demoMonitors.json" with { type: "json" }; import { AppError } from "@/utils/AppError.js"; +import type { ImportedMonitor } from "@/validation/monitorValidation.js"; import { ISuperSimpleQueue } from "../infrastructure/SuperSimpleQueue/SuperSimpleQueue.js"; import { IEmailService } from "../infrastructure/emailService.js"; import { ILogger } from "@/utils/logger.js"; @@ -37,7 +38,7 @@ export interface IMonitorService { addDemoMonitors(args: { userId: string; teamId: string }): Promise; // read - getUptimeDetailsById(args: { teamId: string; monitorId: string; dateRange: string; normalize?: boolean }): Promise; + getUptimeDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise; getHardwareDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise; getPageSpeedDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise; getGeoChecksByMonitorId(args: { @@ -66,7 +67,6 @@ export interface IMonitorService { filter?: string; field?: string; order?: "asc" | "desc"; - explain?: boolean; }): Promise; getAllGames(): GamesMap; getGroupsByTeamId(args: { teamId: string }): Promise; @@ -81,7 +81,7 @@ export interface IMonitorService { // other exportMonitorsToJSON(args: { teamId: string }): Promise; - importMonitorsFromJSON(args: { teamId: string; userId: string; monitors: Partial[] }): Promise<{ imported: number; errors: string[] }>; + importMonitorsFromJSON(args: { teamId: string; userId: string; monitors: ImportedMonitor[] }): Promise<{ imported: number; errors: string[] }>; } export class MonitorService implements IMonitorService { @@ -528,24 +528,26 @@ export class MonitorService implements IMonitorService { importMonitorsFromJSON = async ({ teamId, + userId, monitors, }: { teamId: string; - monitors: Partial[]; + userId: string; + monitors: ImportedMonitor[]; }): Promise<{ imported: number; errors: string[] }> => { const errors: string[] = []; - const cleanedMonitors = monitors.map((monitor) => { - const cleanData = { ...monitor }; - delete cleanData.id; - delete cleanData.createdAt; - delete cleanData.updatedAt; - delete cleanData.recentChecks; - cleanData.teamId = teamId; - return cleanData; - }); + const cleanedMonitors: Monitor[] = monitors.map((monitor) => ({ + ...monitor, + id: "", + teamId, + userId, + recentChecks: [], + createdAt: "", + updatedAt: "", + })); - const createdMonitors = await this.createMonitors(cleanedMonitors as Monitor[]); + const createdMonitors = await this.createMonitors(cleanedMonitors); if (!createdMonitors || createdMonitors.length === 0) { throw new AppError({ diff --git a/server/src/validation/monitorValidation.ts b/server/src/validation/monitorValidation.ts index bfd5b9126..df000ecef 100644 --- a/server/src/validation/monitorValidation.ts +++ b/server/src/validation/monitorValidation.ts @@ -168,6 +168,8 @@ export const importMonitorsBodyValidation = z.object({ monitors: z.array(importedMonitorSchema).min(1, "At least one monitor is required"), }); +export type ImportedMonitor = z.output; + export const getHardwareDetailsByIdParamValidation = z.object({ monitorId: z.string().min(1, "Monitor ID is required"), });