From 404bd5d06b24a29e25da90a53f6cf1d6658a4f0a Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:28:53 -0700 Subject: [PATCH 1/3] add interface to AdvancedMathcer, fix type --- .../infrastructure/network/AdvancedMatcher.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/service/infrastructure/network/AdvancedMatcher.ts b/server/src/service/infrastructure/network/AdvancedMatcher.ts index 57bf7022f..f867770f3 100644 --- a/server/src/service/infrastructure/network/AdvancedMatcher.ts +++ b/server/src/service/infrastructure/network/AdvancedMatcher.ts @@ -2,6 +2,10 @@ import { Monitor } from "@/types/monitor.js"; import jmespath from "jmespath"; type JmesPath = typeof jmespath; +export interface IADvancedMatcher { + validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: T | undefined }; +} + export class AdvancedMatcher { constructor(private jmespath: JmesPath) {} @@ -12,7 +16,7 @@ export class AdvancedMatcher { return String(actual) === expected; // Default } - validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: any } { + validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: T | undefined } { const { useAdvancedMatching, jsonPath, matchMethod, expectedValue } = monitor; if (!useAdvancedMatching) return { ok: true, message: "Success" }; @@ -35,10 +39,10 @@ export class AdvancedMatcher { }; } - const isFalsey = dataToValidate === false || dataToValidate === "false" || dataToValidate === undefined || dataToValidate === null; + const isFalsy = dataToValidate === false || dataToValidate === "false" || dataToValidate === undefined || dataToValidate === null; return { - ok: !isFalsey, - message: !isFalsey ? "Success" : "Extracted value is falsey", + ok: !isFalsy, + message: !isFalsy ? "Success" : "Extracted value is falsy", extracted: dataToValidate, }; } From 465cea21bcc82a625908271ff4802ad26ac4993d Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:29:44 -0700 Subject: [PATCH 2/3] use interface --- server/src/service/infrastructure/network/AdvancedMatcher.ts | 4 ++-- server/src/service/infrastructure/network/HttpProvider.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/service/infrastructure/network/AdvancedMatcher.ts b/server/src/service/infrastructure/network/AdvancedMatcher.ts index f867770f3..d6350ef63 100644 --- a/server/src/service/infrastructure/network/AdvancedMatcher.ts +++ b/server/src/service/infrastructure/network/AdvancedMatcher.ts @@ -2,11 +2,11 @@ import { Monitor } from "@/types/monitor.js"; import jmespath from "jmespath"; type JmesPath = typeof jmespath; -export interface IADvancedMatcher { +export interface IAdvancedMatcher { validate(payload: T, monitor: Monitor): { ok: boolean; message: string; extracted?: T | undefined }; } -export class AdvancedMatcher { +export class AdvancedMatcher implements IAdvancedMatcher { constructor(private jmespath: JmesPath) {} private compare(actual: unknown, expected: string, method?: string): boolean { diff --git a/server/src/service/infrastructure/network/HttpProvider.ts b/server/src/service/infrastructure/network/HttpProvider.ts index a947727fd..bbc0934f8 100644 --- a/server/src/service/infrastructure/network/HttpProvider.ts +++ b/server/src/service/infrastructure/network/HttpProvider.ts @@ -1,5 +1,5 @@ import { type Got, HTTPError, RequestError } from "got"; -import { AdvancedMatcher } from "@/service/infrastructure/network/AdvancedMatcher.js"; +import { IAdvancedMatcher } from "@/service/infrastructure/network/AdvancedMatcher.js"; import { IStatusProvider } from "@/service/infrastructure/network/IStatusProvider.js"; import { HttpStatusPayload } from "@/types/network.js"; import { MonitorStatusResponse } from "@/types/network.js"; @@ -13,7 +13,7 @@ export class HttpProvider implements IStatusProvider { constructor( private got: Got, - private advancedMatcher: AdvancedMatcher + private advancedMatcher: IAdvancedMatcher ) { const cacheable = new CacheableLookup({ maxTtl: 300, errorTtl: 30 }); this.got = got.extend({ From 928ab7551ea530bfb701554a4420b5ad49fff981 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 20 Mar 2026 11:33:40 -0700 Subject: [PATCH 3/3] fixes --- server/src/controllers/maintenanceWindowController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/controllers/maintenanceWindowController.ts b/server/src/controllers/maintenanceWindowController.ts index edc236fa1..300cb0b1b 100644 --- a/server/src/controllers/maintenanceWindowController.ts +++ b/server/src/controllers/maintenanceWindowController.ts @@ -24,7 +24,7 @@ class MaintenanceWindowController { const monitorIDs = validatedBody.monitors; const name = validatedBody.name; - const active = validatedBody.active ? validatedBody.active : true; + const active = validatedBody.active ?? true; const duration = validatedBody.duration; const durationUnit = validatedBody.durationUnit; const repeat = validatedBody.repeat;