Centralize waypoint Yjs serialization in waypointFromYMap/waypointToYMap

Introduce waypoint-ymap.ts with typed helpers so all Yjs↔Waypoint
conversions go through one place. New Waypoint fields now only need
to be added once rather than in every consumer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-18 21:02:27 +02:00
parent 02f8a8be44
commit 9e2ca5595e
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
8 changed files with 63 additions and 52 deletions

View file

@ -3,6 +3,7 @@ import type { Route } from "./+types/api.sessions";
import { createSession, listSessions } from "~/lib/sessions";
import { parseGpxAsync, extractWaypoints } from "@trails-cool/gpx";
import { withDb } from "@trails-cool/db";
import type { Waypoint } from "@trails-cool/types";
export async function action({ request }: Route.ActionArgs) {
if (request.method !== "POST") {
@ -19,7 +20,7 @@ export async function action({ request }: Route.ActionArgs) {
return withDb(async () => {
const session = await createSession({ callbackUrl, callbackToken });
let initialWaypoints: Array<{ lat: number; lon: number; name?: string; isDayBreak?: boolean; note?: string; osmId?: number; poiTags?: Record<string, string> }> | undefined;
let initialWaypoints: Waypoint[] | undefined;
let initialNoGoAreas: Array<{ points: Array<{ lat: number; lon: number }> }> | undefined;
let initialNotes: string | undefined;
if (gpx) {