1 import { z } from 'zod';
3 const zUnixTime = z.number();
5 export const zIsDefaultProtocol = z.enum(['true', 'false', 'unknown']);
6 export type IsDefaultProtocolReport = z.infer<typeof zIsDefaultProtocol>;
7 export const zDefaultProtocolChanged = z.enum(['yes_to_no', 'no_to_yes', 'no_change']);
8 export type IsDefaultProtocolChangedReport = z.infer<typeof zDefaultProtocolChanged>;
10 const zDefaultProtocolActual = z.object({
11 isDefault: z.boolean(),
12 wasChecked: z.boolean(),
14 export type DefaultProtocolActual = z.infer<typeof zDefaultProtocolActual>;
16 export const UNCHECKED_PROTOCOL: DefaultProtocolActual = {
21 const zDefaultProtocolStored = z.object({
22 shouldBeDefault: z.boolean(),
23 wasDefaultInPast: z.boolean(),
24 lastReport: z.object({
25 wasDefault: z.boolean(),
29 export type DefaultProtocolStored = z.infer<typeof zDefaultProtocolStored>;
31 export const zDefaultProtocol = zDefaultProtocolActual.merge(zDefaultProtocolStored);
33 export type DefaultProtocol = z.infer<typeof zDefaultProtocol>;
35 const zDefaultProtocolsStored = z.object({
36 mailto: zDefaultProtocolStored,
39 export type DefaultProtocolsStored = z.infer<typeof zDefaultProtocolsStored>;
40 export const parseDefaultProtocolsStored = (data: unknown): DefaultProtocolsStored =>
41 zDefaultProtocolsStored.parse(data);
43 export type PROTOCOLS = keyof DefaultProtocolsStored;