โ– humdrum codex / soft
1.9 KB raw
 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { z } from "zod";

export const WeatherConfig = z.object({
  lat: z.number().optional(),
  lon: z.number().optional(),
  label: z.string().optional(),
});
export type WeatherConfig = z.infer<typeof WeatherConfig>;

export const WeatherDay = z.object({
  date: z.string(),
  max: z.number(),
  min: z.number(),
  code: z.number(),
  text: z.string(),
  precipProb: z.number().nullable(),
});

// One of today's four day-parts (morning/noon/evening/night) โ€” drives the
// printed weather hero strip. Empty array when hourly data is unavailable.
export const WeatherPart = z.object({
  label: z.string(), // "Morning" | "Noon" | "Evening" | "Night"
  temp: z.number(),
  code: z.number(),
  text: z.string(),
  precipProb: z.number().nullable(),
});

export const WeatherAlert = z.object({
  event: z.string(),
  severity: z.string(), // "Extreme" | "Severe" | "Moderate" | "Minor" | "Unknown"
  headline: z.string().optional(),
  ends: z.string().nullable().optional(),
});

export const WeatherPollen = z.object({
  label: z.string(),
  value: z.number(),
  level: z.string(), // "Low" | "Moderate" | "High" | "Very High"
});

export const WeatherPayload = z.object({
  location: z.string(),
  units: z.enum(["metric", "imperial"]),
  current: z.object({
    temp: z.number(),
    feelsLike: z.number().nullable().default(null),
    code: z.number(),
    text: z.string(),
    wind: z.number(),
    humidity: z.number().nullable(),
    uvIndex: z.number().nullable().default(null),
  }),
  daily: z.array(WeatherDay),
  parts: z.array(WeatherPart).default([]),
  sunrise: z.string().nullable().default(null),
  sunset: z.string().nullable().default(null),
  moonPhase: z.string().default(""),
  moonEmoji: z.string().default(""),
  aqi: z.number().nullable().default(null),
  aqiCategory: z.string().default(""),
  pollen: z.array(WeatherPollen).default([]),
  alerts: z.array(WeatherAlert).default([]),
});
export type WeatherPayload = z.infer<typeof WeatherPayload>;