2026-03-17 09:46:39 -05:00
|
|
|
|
// FILE: model/alert.go
|
2026-01-13 18:14:21 -06:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
2026-01-16 21:40:20 -06:00
|
|
|
|
// WeatherAlertRun is a snapshot of *active* alerts for a location as-of a point in time.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This mirrors WeatherForecastRun's "one issued snapshot -> many contained items" shape:
|
|
|
|
|
|
//
|
|
|
|
|
|
// - A single run may contain zero, one, or many alerts.
|
|
|
|
|
|
// - Runs are intended to be immutable snapshots (“provider asserted X at AsOf”).
|
|
|
|
|
|
//
|
|
|
|
|
|
// Normalizers should prefer to set AsOf from a provider-supplied “updated/generated” timestamp.
|
|
|
|
|
|
// If unavailable, AsOf may be set to the poll/emit time as a fallback.
|
|
|
|
|
|
type WeatherAlertRun struct {
|
|
|
|
|
|
// Optional location metadata (provider-dependent).
|
|
|
|
|
|
LocationID string `json:"locationId,omitempty"`
|
|
|
|
|
|
LocationName string `json:"locationName,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// AsOf is when the provider asserted this alert snapshot is current (required).
|
|
|
|
|
|
AsOf time.Time `json:"asOf"`
|
|
|
|
|
|
|
|
|
|
|
|
// Optional spatial context.
|
|
|
|
|
|
Latitude *float64 `json:"latitude,omitempty"`
|
|
|
|
|
|
Longitude *float64 `json:"longitude,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
// Active alerts contained in this snapshot (order is provider-dependent).
|
|
|
|
|
|
Alerts []WeatherAlert `json:"alerts"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// WeatherAlert is the canonical representation of a single alert.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This is intentionally a “useful subset” of rich provider payloads.
|
|
|
|
|
|
// Normalizers may populate ProviderExtras for structured provider-specific fields
|
|
|
|
|
|
// that don’t cleanly fit the canonical shape.
|
2026-01-13 18:14:21 -06:00
|
|
|
|
type WeatherAlert struct {
|
2026-01-16 21:40:20 -06:00
|
|
|
|
// Provider-stable identifier (often a URL/URI).
|
2026-01-15 22:39:37 -06:00
|
|
|
|
ID string `json:"id"`
|
2026-01-13 18:14:21 -06:00
|
|
|
|
|
2026-01-16 21:40:20 -06:00
|
|
|
|
// Classification / headline fields.
|
|
|
|
|
|
Event string `json:"event,omitempty"`
|
|
|
|
|
|
Headline string `json:"headline,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
Severity string `json:"severity,omitempty"` // e.g. Extreme/Severe/Moderate/Minor/Unknown
|
2026-06-10 20:28:41 +00:00
|
|
|
|
Urgency string `json:"urgency,omitempty"` // provider-defined urgency value
|
2026-01-16 21:40:20 -06:00
|
|
|
|
Certainty string `json:"certainty,omitempty"` // e.g. Observed/Likely/Possible/Unlikely/Unknown
|
|
|
|
|
|
|
|
|
|
|
|
Status string `json:"status,omitempty"` // e.g. Actual/Exercise/Test/System/Unknown
|
|
|
|
|
|
MessageType string `json:"messageType,omitempty"` // e.g. Alert/Update/Cancel
|
|
|
|
|
|
Category string `json:"category,omitempty"` // e.g. Met/Geo/Safety/Rescue/Fire/Health/Env/Transport/Infra/CBRNE/Other
|
|
|
|
|
|
Response string `json:"response,omitempty"` // e.g. Shelter/Evacuate/Prepare/Execute/Avoid/Monitor/Assess/AllClear/None
|
|
|
|
|
|
|
|
|
|
|
|
// Narrative.
|
2026-01-15 22:39:37 -06:00
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
|
|
Instruction string `json:"instruction,omitempty"`
|
2026-01-13 18:14:21 -06:00
|
|
|
|
|
2026-01-16 21:40:20 -06:00
|
|
|
|
// Timing (all optional; provider-dependent).
|
2026-06-16 19:57:48 -05:00
|
|
|
|
// Onset and Ends describe the alert period. Expires is provider expiration metadata.
|
2026-01-15 22:39:37 -06:00
|
|
|
|
Sent *time.Time `json:"sent,omitempty"`
|
|
|
|
|
|
Effective *time.Time `json:"effective,omitempty"`
|
2026-01-16 21:40:20 -06:00
|
|
|
|
Onset *time.Time `json:"onset,omitempty"`
|
2026-06-16 19:57:48 -05:00
|
|
|
|
Ends *time.Time `json:"ends,omitempty"`
|
2026-01-15 22:39:37 -06:00
|
|
|
|
Expires *time.Time `json:"expires,omitempty"`
|
2026-01-13 18:14:21 -06:00
|
|
|
|
|
2026-01-16 21:40:20 -06:00
|
|
|
|
// Scope / affected area.
|
|
|
|
|
|
AreaDescription string `json:"areaDescription,omitempty"` // often a provider string
|
|
|
|
|
|
|
|
|
|
|
|
// Provenance.
|
|
|
|
|
|
SenderName string `json:"senderName,omitempty"`
|
|
|
|
|
|
|
|
|
|
|
|
References []AlertReference `json:"references,omitempty"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AlertReference is a reference to a related alert (updates, replacements, etc.).
|
|
|
|
|
|
type AlertReference struct {
|
|
|
|
|
|
ID string `json:"id,omitempty"` // provider reference ID/URI
|
|
|
|
|
|
Identifier string `json:"identifier,omitempty"` // provider identifier string, if distinct
|
|
|
|
|
|
Sender string `json:"sender,omitempty"`
|
|
|
|
|
|
Sent *time.Time `json:"sent,omitempty"`
|
2026-01-13 18:14:21 -06:00
|
|
|
|
}
|