Files
HealthLog/src/lib/validations/admin.ts
T
Marc-André Bombeck 17b8d8d2c2 chore(release): v1.4.25
Largest feature delta in the v1.4.x line. Insights expands into seven dedicated metric sub-pages; GLP-1 medication tracking lands end-to-end (drug-level chart with Research Mode acknowledgment, EMA titration ladder, cadence + compliance, side-effect taxonomy, pen/vial inventory); cross-source priority becomes a two-axis resolver; per-user timezone threads through ten analytics surfaces; Withings activity + sleep v2 sync; onboarding rebuilt as a nested-route wizard; Personal Records ship end-to-end; Health Score provenance accordion; Coach runs native first-party prompts across six locales with a 1800-assertion refusal-probe matrix; OpenAPI drift gate hard-fails; multi-arch GHCR image. Migrations 0043 through 0060 are additive and forward-only. PROMPT_VERSION 4.24.0 → 4.25.0 with GROUND RULE 9 (refuses dose recommendations) and GROUND RULE 15 (refuses drug-level estimates with MDR + MDCG 2021-24 cites).

See CHANGELOG.md for the full per-section delta.
2026-05-14 23:49:32 +02:00

85 lines
2.8 KiB
TypeScript

import { z } from "zod/v4";
/**
* Schema for admin settings update (PUT /api/admin/settings).
* All fields are optional — partial updates are supported.
*/
export const adminSettingsSchema = z
.object({
registrationEnabled: z.boolean().optional(),
defaultLocale: z.enum(["de", "en"]).optional(),
telegramGlobal: z.boolean().optional(),
ntfyGlobal: z.boolean().optional(),
webPushGlobal: z.boolean().optional(),
webPushVapidPublicKey: z.string().optional(),
webPushVapidSubject: z
.string()
.refine((v) => !v.trim() || /^mailto:.+@.+$/.test(v.trim()), {
message:
"webPushVapidSubject must be in mailto:address@example.com format",
})
.optional(),
webPushVapidPrivateKey: z.string().optional(),
clearWebPushVapidPrivateKey: z.boolean().optional(),
apiGlobal: z.boolean().optional(),
umamiEnabled: z.boolean().optional(),
umamiScriptUrl: z
.string()
.refine(
(v) => {
const trimmed = v.trim();
if (!trimmed) return true;
try {
const parsed = new URL(trimmed);
return ["https:", "http:"].includes(parsed.protocol);
} catch {
return false;
}
},
{ message: "Umami script URL is invalid" },
)
.optional(),
umamiWebsiteId: z.string().optional(),
glitchtipEnabled: z.boolean().optional(),
glitchtipDsn: z
.string()
.refine(
(v) => {
const trimmed = v.trim();
if (!trimmed) return true;
try {
const parsed = new URL(trimmed);
return ["https:", "http:"].includes(parsed.protocol);
} catch {
return false;
}
},
{ message: "Glitchtip DSN is invalid" },
)
.optional(),
glitchtipEnvironment: z.string().optional(),
bugReportRepo: z
.string()
.refine(
(v) => {
const trimmed = v.trim();
if (!trimmed) return true;
return /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(trimmed);
},
{ message: "GitHub repository must be in owner/repo format" },
)
.optional(),
bugReportToken: z.string().optional(),
clearBugReportToken: z.boolean().optional(),
bugReportEnabled: z.boolean().optional(),
reminderLateMinutes: z.number().int().min(15).max(480).optional(),
reminderMissedMinutes: z.number().int().min(30).max(720).optional(),
moodLogGlobal: z.boolean().optional(),
// v1.4.25 W7 — server-wide default timezone for new signups
// that don't carry a browser-detected zone. The route validates
// against Intl.supportedValuesOf at runtime; this schema just
// guards the shape + length.
defaultUserTimezone: z.string().max(64).optional(),
})
.strict();