fix(ci): typed card points, the managed take route, and the failing card tests and ratchets

This commit is contained in:
Maurice
2026-10-22 16:21:20 +02:00
parent fd01a090fc
commit d8bd6ab9e2
77 changed files with 293 additions and 244 deletions
+3 -2
View File
@@ -16,7 +16,9 @@ export const cardLatSchema = z.number().min(-90).max(90);
export const cardLngSchema = z.number().min(-180).max(180);
/** A point of a line to draw, `[lat, lng]` at five decimals; single points are `{ lat, lng }` objects. */
export const cardPointSchema = z.tuple([cardLatSchema, cardLngSchema]);
export type CardPoint = [number, number];
// Typed by hand: server and client compile without strictNullChecks, where an inferred tuple makes every item optional.
export const cardPointSchema: z.ZodType<CardPoint> = z.tuple([cardLatSchema, cardLngSchema]);
export const cardDateSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
export const cardClockSchema = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/);
@@ -52,7 +54,6 @@ export const cardDaySchema = z.object({
/** The most one card may weigh, as JSON text; a heavier one is not sent at all. */
export const MAX_CARD_CHARS = 24_000;
export type CardPoint = z.infer<typeof cardPointSchema>;
export type CardMoney = z.infer<typeof cardMoneySchema>;
export type CardPerson = z.infer<typeof cardPersonSchema>;
export type CardDay = z.infer<typeof cardDaySchema>;
@@ -47,10 +47,7 @@ function hike(extra: Partial<TourRouteCard> = {}): TourRouteCard {
[47.61, 11.31, 1670],
],
stretches: [{ facet: 'sac', fromM: 0, toM: 4000, step: 3 }],
stops: [
stop(0, { role: 'start', clock: '08:00' }),
stop(4100, { role: 'end', kind: 'peak', name: 'Hochfelln' }),
],
stops: [stop(0, { role: 'start', clock: '08:00' }), stop(4100, { role: 'end', kind: 'peak', name: 'Hochfelln' })],
stages: null,
skiScheme: null,
schedule: {
@@ -4,7 +4,7 @@ import { HIKE_UNROUTED_REASONS } from '../../tours/hike-plan.schema';
import { HIKE_WARNING_KINDS } from '../../tours/hike-schedule';
import { tourPoiCategorySchema } from '../../tours/tour-poi-category';
import { tourMaxHikingDifficultySchema, tourTypeKeySchema } from '../../tours/tours.schema';
import { cardClockSchema, cardDateSchema, cardLatSchema, cardLngSchema, cardText } from './card-parts';
import { cardClockSchema, cardDateSchema, cardLatSchema, cardLngSchema, cardPointSchema, cardText } from './card-parts';
import { z } from 'zod';
@@ -37,7 +37,13 @@ const minutes = z.number().int().min(0).max(86_400);
const sacStep = z.number().int().min(1).max(6);
/** A point of the line, `[lat, lng, height]` at five decimals; every height is null when one is missing. */
export const tourRoutePointSchema = z.tuple([cardLatSchema, cardLngSchema, height.nullable()]);
export type TourRoutePoint = [number, number, number | null];
// Typed by hand like cardPointSchema: an inferred tuple reads every item as optional where strictNullChecks is off.
export const tourRoutePointSchema: z.ZodType<TourRoutePoint> = z.tuple([
cardLatSchema,
cardLngSchema,
height.nullable(),
]);
/** What a stop is beyond its role: a kind of place along a hike, its highest point, a city walk's station. */
export const TOUR_ROUTE_STOP_KINDS = ['highest', 'station'] as const;
@@ -164,7 +170,7 @@ export const tourRouteCardSchema = z.object({
/** A held change of a saved tour's way: the way it has now, to draw faintly beside the new one. */
previous: z
.object({
line: z.array(z.tuple([cardLatSchema, cardLngSchema])).min(2).max(L.previous),
line: z.array(cardPointSchema).min(2).max(L.previous),
distanceM: metres,
ascentM: climb.nullable(),
minutes: minutes.nullable(),