update openapi docs

This commit is contained in:
Alex Holliday committed 2026-08-17 12:36:39 -07:00
1 parent c1f0bf3dd4
commit ab7f2cd8f4
6 files changed
+429 -24

No files matched your search

@@ -1,6 +1,7 @@
import { z } from "zod";
import { booleanCoercion, dnsHostnameRegex, timezoneValidation } from "./shared.js";
import { StatusPageTypes, StatusPageThemes, StatusPageThemeModes, StatusPageRanges } from "@/domain/status-pages/status-page.type.js";
import { MonitorTypes, MonitorStatuses } from "@/domain/monitors/monitor.type.js";
import { normalizeStatusPageDomain } from "@/utils/statusPageDomain.js";
import { cssReferencesExternalResource } from "@/utils/customCss.js";
import { ImageMimeTypes } from "@/types/upload.js";
@@ -80,3 +81,82 @@ export const imageValidation = z
.refine((data) => data.buffer, {
message: "Image file is required",
});
// Keep aligned with DailyCheckBucket in domain/checks/check.type.ts. avgResponseTime is null
// when no check that day recorded a response time ($avg skips missing, $round passes null through).
export const dailyCheckBucketResponseSchema = z.object({
monitorId: z.string(),
date: z.string(),
totalChecks: z.number(),
upChecks: z.number(),
downChecks: z.number(),
avgResponseTime: z.number().nullable(),
});
// Keep aligned with CheckSnapshot in domain/checks/check.type.ts.
export const checkSnapshotResponseSchema = z
.object({
id: z.string(),
status: z.boolean(),
responseTime: z.number(),
statusCode: z.number(),
message: z.string(),
createdAt: z.string(),
accessibility: z.number().optional(),
bestPractices: z.number().optional(),
seo: z.number().optional(),
performance: z.number().optional(),
})
.passthrough();
// Status page entity as serialized by the repository. Keep aligned with StatusPage in
// domain/status-pages/status-page.type.ts.
export const statusPageResponseSchema = z.object({
id: z.string(),
userId: z.string(),
teamId: z.string(),
type: z.array(z.enum(StatusPageTypes)),
companyName: z.string(),
url: z.string(),
customDomain: z.string().nullable().optional(),
timezone: z.string().optional(),
color: z.string(),
monitors: z.array(z.string()),
subMonitors: z.array(z.string()),
originalMonitors: z.array(z.string()).optional(),
logo: z.object({ data: z.string(), contentType: z.string() }).nullable().optional(),
isPublished: z.boolean(),
showCharts: z.boolean(),
showUptimePercentage: z.boolean(),
showAdminLoginLink: z.boolean(),
showInfrastructure: z.boolean(),
customCSS: z.string(),
theme: z.enum(StatusPageThemes),
themeMode: z.enum(StatusPageThemeModes),
createdAt: z.string(),
updatedAt: z.string(),
});
// Keep aligned with PublicStatusPageMonitor in domain/status-pages/status-page.type.ts.
// url/port are present only when the showURL setting is enabled; dailyChecks only when range !== "latest".
export const publicStatusPageMonitorResponseSchema = z.object({
id: z.string(),
name: z.string(),
type: z.enum(MonitorTypes),
status: z.enum(MonitorStatuses),
uptimePercentage: z.number().optional(),
recentChecks: z.array(checkSnapshotResponseSchema),
url: z.string().optional(),
port: z.number().optional(),
dailyChecks: z.array(dailyCheckBucketResponseSchema).optional(),
});
// Response of the public status page endpoints. Keep aligned with PublicStatusPagePayload in
// domain/status-pages/status-page.type.ts; range, bucketTimezone, and checkTTLDays are present only when range !== "latest".
export const publicStatusPagePayloadResponseSchema = z.object({
statusPage: statusPageResponseSchema,
monitors: z.array(publicStatusPageMonitorResponseSchema),
range: z.enum(StatusPageRanges).optional(),
bucketTimezone: z.string().optional(),
checkTTLDays: z.number().optional(),
});