176 lines
3.2 KiB
TypeScript
176 lines
3.2 KiB
TypeScript
// Canonical shapes from /home/noel/Documents/Hackathon_2026/CONTRACT.md (v1 draft).
|
|
// Keep these in sync with the Go API; the UI consumes exactly these fields.
|
|
|
|
export const HORIZONS = ['15m', '1h', '48h', '7d'] as const
|
|
export type Horizon = (typeof HORIZONS)[number]
|
|
|
|
export const SCENARIOS = ['base', 'sunny-saturday-market', 'rainy-saturday', 'weekday-event'] as const
|
|
export type Scenario = (typeof SCENARIOS)[number]
|
|
|
|
export const STANDARDS = ['relaxed', 'standard', 'premium'] as const
|
|
export type Standard = (typeof STANDARDS)[number]
|
|
|
|
export type Coverage = 'under' | 'ok' | 'over'
|
|
|
|
export interface Sensor {
|
|
id: string
|
|
name: string
|
|
lat: number
|
|
lon: number
|
|
mean: number
|
|
p95: number
|
|
battery: number | null
|
|
}
|
|
|
|
export interface Point {
|
|
t: string
|
|
v: number
|
|
lo?: number
|
|
hi?: number
|
|
}
|
|
|
|
export interface SeriesResponse {
|
|
sensor: string
|
|
step: '15m' | '1h'
|
|
points: Array<Pick<Point, 't' | 'v'>>
|
|
}
|
|
|
|
export interface ForecastResponse {
|
|
sensor: string
|
|
horizon: Horizon
|
|
scenario: Scenario
|
|
points: Point[]
|
|
cached: boolean
|
|
data_version: string
|
|
model_version: string
|
|
context_version: string
|
|
}
|
|
|
|
export interface WeatherPoint {
|
|
t: string
|
|
temp_c: number
|
|
precip_mm: number
|
|
cloud_pct: number
|
|
wind_kmh: number
|
|
humidity_pct: number
|
|
}
|
|
|
|
export interface Holiday {
|
|
date: string
|
|
name: string
|
|
}
|
|
|
|
export interface ContextResponse {
|
|
weather: {
|
|
now: WeatherPoint
|
|
forecast: WeatherPoint[]
|
|
}
|
|
holidays: Holiday[]
|
|
updated_at: string
|
|
cached: boolean
|
|
}
|
|
|
|
export interface MetaResponse {
|
|
data_version: string
|
|
model_version: string
|
|
context_version: string
|
|
coverage: {
|
|
sensors: number
|
|
from: string
|
|
to: string
|
|
cadence_min: number
|
|
}
|
|
metrics: {
|
|
model: string
|
|
mae: number
|
|
wape: number
|
|
r2: number
|
|
baseline_mae: number
|
|
baseline_wape: number
|
|
}
|
|
limits: string[]
|
|
}
|
|
|
|
export interface StaffingAssumptions {
|
|
visitors_per_staff_hour: number
|
|
safety_factor: number
|
|
min_staff: number
|
|
shift_length_h: number
|
|
labor_cost_eur_h: number
|
|
store_hours: {
|
|
open: string
|
|
close: string
|
|
tz: string
|
|
}
|
|
}
|
|
|
|
export interface StaffingHour {
|
|
t: string
|
|
footfall: number
|
|
required_staff: number
|
|
scheduled_staff: number
|
|
coverage: Coverage
|
|
}
|
|
|
|
export interface Shift {
|
|
date: string
|
|
start: string
|
|
end: string
|
|
staff: number
|
|
}
|
|
|
|
export interface StaffingSummary {
|
|
coverage_pct: number
|
|
cost_eur: number
|
|
flat_schedule_cost_eur: number
|
|
overstaffed_hours: number
|
|
understaffed_hours: number
|
|
}
|
|
|
|
export interface StaffingResponse {
|
|
sensor: string
|
|
scenario: Scenario
|
|
standard: Standard
|
|
assumptions: StaffingAssumptions
|
|
hours: StaffingHour[]
|
|
shifts: Shift[]
|
|
summary: StaffingSummary
|
|
why: string[]
|
|
cached: boolean
|
|
data_version: string
|
|
model_version: string
|
|
context_version: string
|
|
}
|
|
|
|
export interface ScenarioDefinition {
|
|
scenario: Scenario
|
|
weather?: {
|
|
temp_delta_c?: number
|
|
precip_mm?: number
|
|
}
|
|
event?: {
|
|
type: string
|
|
uplift: number
|
|
}
|
|
}
|
|
|
|
export interface ScenarioState {
|
|
version: number
|
|
scenario: ScenarioDefinition
|
|
at: string
|
|
}
|
|
|
|
export interface ScenarioPreset extends ScenarioDefinition {
|
|
id: Scenario
|
|
label: string
|
|
short: string
|
|
description: string
|
|
}
|
|
|
|
export interface DemoClock {
|
|
now: string
|
|
plan_start: string
|
|
plan_end: string
|
|
timezone: string
|
|
}
|