1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { z } from "zod";
// App-wide settings, stored as key/value JSON rows. Known keys are typed below;
// unknown keys are allowed (forward-compatible).
export const Location = z.object({
label: z.string().default(""),
lat: z.number(),
lon: z.number(),
});
export type Location = z.infer<typeof Location>;
export const Settings = z.object({
location: Location.nullable().default(null),
units: z.enum(["metric", "imperial"]).default("imperial"),
// ordered list of source ids for the dashboard grid; empty = use Source.position
layout: z.array(z.string()).default([]),
});
export type Settings = z.infer<typeof Settings>;
export const SETTINGS_DEFAULTS: Settings = {
location: { label: "Napa, CA", lat: 38.2975, lon: -122.2869 },
units: "imperial",
layout: [],
};
// One row in the settings table.
export const SettingRow = z.object({
key: z.string(),
value: z.unknown(),
});
export type SettingRow = z.infer<typeof SettingRow>;
|