update monitor model/repos
This commit is contained in:
1 parent
5435167e73
commit
80097afb71
4 files changed
+20
-2
No files matched your search
@@ -10,6 +10,7 @@ import {
|
|||||||
MonitorStatuses,
|
MonitorStatuses,
|
||||||
MonitorTypes,
|
MonitorTypes,
|
||||||
PageSpeedStrategies,
|
PageSpeedStrategies,
|
||||||
|
ProxyModes,
|
||||||
} from "@/domain/monitors/monitor.type.js";
|
} from "@/domain/monitors/monitor.type.js";
|
||||||
import { DateRanges, SortOrders } from "@/types/query.js";
|
import { DateRanges, SortOrders } from "@/types/query.js";
|
||||||
|
|
||||||
@@ -215,6 +216,8 @@ const importedMonitorSchema = z
|
|||||||
statusWindowThreshold: z.number().min(1).max(100).default(60),
|
statusWindowThreshold: z.number().min(1).max(100).default(60),
|
||||||
type: z.enum(MonitorTypes, "Invalid monitor type"),
|
type: z.enum(MonitorTypes, "Invalid monitor type"),
|
||||||
ignoreTlsErrors: z.boolean().default(false),
|
ignoreTlsErrors: z.boolean().default(false),
|
||||||
|
proxyMode: z.enum(ProxyModes).default("inherit"),
|
||||||
|
proxyId: z.string().optional(),
|
||||||
useAdvancedMatching: z.boolean().default(false),
|
useAdvancedMatching: z.boolean().default(false),
|
||||||
jsonPath: z.union([z.string(), z.literal("")]).optional(),
|
jsonPath: z.union([z.string(), z.literal("")]).optional(),
|
||||||
expectedValue: z.union([z.string(), z.literal("")]).optional(),
|
expectedValue: z.union([z.string(), z.literal("")]).optional(),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Schema, model, Types } from "mongoose";
|
import { Schema, model, Types } from "mongoose";
|
||||||
import type { Monitor, MonitorMatchMethod, CheckSnapshot } from "@/domain/monitors/monitor.type.js";
|
import type { Monitor, MonitorMatchMethod, CheckSnapshot } from "@/domain/monitors/monitor.type.js";
|
||||||
import { DnsRecordTypes, MonitorTypes, MonitorStatuses, PageSpeedStrategies, HttpMethods } from "@/domain/monitors/monitor.type.js";
|
import { DnsRecordTypes, MonitorTypes, MonitorStatuses, PageSpeedStrategies, HttpMethods, ProxyModes } from "@/domain/monitors/monitor.type.js";
|
||||||
import type {
|
import type {
|
||||||
CheckAudits,
|
CheckAudits,
|
||||||
ILighthouseAudit,
|
ILighthouseAudit,
|
||||||
@@ -14,7 +14,7 @@ type CheckSnapshotDocument = Omit<CheckSnapshot, "createdAt"> & { createdAt: Dat
|
|||||||
|
|
||||||
type MonitorDocumentBase = Omit<
|
type MonitorDocumentBase = Omit<
|
||||||
Monitor,
|
Monitor,
|
||||||
"id" | "userId" | "teamId" | "notifications" | "tags" | "selectedDisks" | "statusWindow" | "recentChecks" | "createdAt" | "updatedAt"
|
"id" | "userId" | "teamId" | "notifications" | "tags" | "selectedDisks" | "statusWindow" | "recentChecks" | "proxyId" | "createdAt" | "updatedAt"
|
||||||
> & {
|
> & {
|
||||||
statusWindow: boolean[];
|
statusWindow: boolean[];
|
||||||
recentChecks: CheckSnapshotDocument[];
|
recentChecks: CheckSnapshotDocument[];
|
||||||
@@ -22,6 +22,7 @@ type MonitorDocumentBase = Omit<
|
|||||||
tags: Types.ObjectId[];
|
tags: Types.ObjectId[];
|
||||||
selectedDisks: string[];
|
selectedDisks: string[];
|
||||||
matchMethod?: MonitorMatchMethod;
|
matchMethod?: MonitorMatchMethod;
|
||||||
|
proxyId?: Types.ObjectId;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface MonitorDocument extends MonitorDocumentBase {
|
interface MonitorDocument extends MonitorDocumentBase {
|
||||||
@@ -170,6 +171,16 @@ const MonitorSchema = new Schema<MonitorDocument>(
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
proxyMode: {
|
||||||
|
type: String,
|
||||||
|
enum: ProxyModes,
|
||||||
|
default: "inherit",
|
||||||
|
},
|
||||||
|
proxyId: {
|
||||||
|
type: Schema.Types.ObjectId,
|
||||||
|
ref: "Proxy",
|
||||||
|
},
|
||||||
|
|
||||||
useAdvancedMatching: {
|
useAdvancedMatching: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@@ -418,6 +418,8 @@ class MongoMonitorsRepository implements IMonitorsRepository {
|
|||||||
statusWindowThreshold: doc.statusWindowThreshold,
|
statusWindowThreshold: doc.statusWindowThreshold,
|
||||||
type: doc.type,
|
type: doc.type,
|
||||||
ignoreTlsErrors: doc.ignoreTlsErrors,
|
ignoreTlsErrors: doc.ignoreTlsErrors,
|
||||||
|
proxyMode: doc.proxyMode ?? "inherit",
|
||||||
|
proxyId: doc.proxyId ? toStringId(doc.proxyId) : undefined,
|
||||||
useAdvancedMatching: doc.useAdvancedMatching ?? false,
|
useAdvancedMatching: doc.useAdvancedMatching ?? false,
|
||||||
jsonPath: doc.jsonPath ?? undefined,
|
jsonPath: doc.jsonPath ?? undefined,
|
||||||
expectedValue: doc.expectedValue ?? undefined,
|
expectedValue: doc.expectedValue ?? undefined,
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ export interface Monitor {
|
|||||||
statusWindowThreshold: number;
|
statusWindowThreshold: number;
|
||||||
type: MonitorType;
|
type: MonitorType;
|
||||||
ignoreTlsErrors: boolean;
|
ignoreTlsErrors: boolean;
|
||||||
|
proxyMode: ProxyMode;
|
||||||
|
proxyId?: string;
|
||||||
useAdvancedMatching: boolean;
|
useAdvancedMatching: boolean;
|
||||||
jsonPath?: string;
|
jsonPath?: string;
|
||||||
expectedValue?: string;
|
expectedValue?: string;
|
||||||
|
|||||||
Reference in new issue
Block a user