mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 07:40:59 +00:00
62cccf32f3
Two boot migrations. The first appends the missing dated days to a trip the old 365-day cap clipped, only where the dated days still run unbroken from the start date, so a trip that was re-dated by hand or lost a day in the middle is left alone; dateless days that hold content stay behind the dated ones as generateDays keeps them. The second rebuilds roadtrip_day_boundaries without the CHECK that held day_number to 366, which would have refused a boundary on a later day of a longer trip. The road-trip contracts follow the same limit: the day boundary and corridor schemas, the set_day_boundary tool and the day window's runaway guard read MAX_TRIP_DAYS instead of their own 365 or 366, and the tooLong message carries the number as a placeholder in all 23 locales.
18 lines
646 B
TypeScript
18 lines
646 B
TypeScript
import { MAX_TRIP_DAYS } from '../trip/trip.schema';
|
|
|
|
import { z } from 'zod';
|
|
|
|
export const roadtripDayBoundarySchema = z
|
|
.object({
|
|
day_number: z.number().int().min(1).max(MAX_TRIP_DAYS),
|
|
from_assignment_id: z.number().int().positive(),
|
|
to_assignment_id: z.number().int().positive().nullable(),
|
|
fraction: z.number().min(0).max(1),
|
|
})
|
|
.refine((b) => b.to_assignment_id !== b.from_assignment_id, 'A boundary needs two different stops');
|
|
|
|
export const roadtripDayBoundaryListSchema = z.object({
|
|
boundaries: z.array(roadtripDayBoundarySchema),
|
|
});
|
|
export type RoadtripDayBoundary = z.infer<typeof roadtripDayBoundarySchema>;
|