Derive client domain types from the shared schema contracts

Add entity/response Zod schemas to @trek/shared (place, trip, assignment, day, budget, packing, reservation), each matched against the producing server service, and re-export them from client types.ts instead of the hand-written duplicates that had drifted (name/title, amount/total_price, owner_id/user_id, cover_url/cover_image, ...). Updates the call sites and test fixtures the corrected types surfaced; type-only, no runtime behaviour change.
This commit is contained in:
Maurice
2026-05-31 15:42:39 +02:00
parent 239a68bb48
commit 3977a5ecba
52 changed files with 732 additions and 435 deletions
@@ -9,21 +9,21 @@ beforeEach(() => {
describe('remoteEventHandler > trip', () => {
it('FE-WSEVT-TRIP-001: trip:updated replaces trip in state', () => {
const originalTrip = buildTrip({ id: 1, name: 'Paris Trip' });
const originalTrip = buildTrip({ id: 1, title: 'Paris Trip' });
useTripStore.setState({ trip: originalTrip });
const updatedTrip = buildTrip({ id: 1, name: 'Paris & Lyon Trip' });
const updatedTrip = buildTrip({ id: 1, title: 'Paris & Lyon Trip' });
useTripStore.getState().handleRemoteEvent({ type: 'trip:updated', trip: updatedTrip });
const { trip } = useTripStore.getState();
expect(trip?.name).toBe('Paris & Lyon Trip');
expect(trip?.title).toBe('Paris & Lyon Trip');
});
it('FE-WSEVT-TRIP-002: trip:updated does not affect other state fields', () => {
const existingPlace = buildPlace({ id: 55, name: 'Eiffel Tower' });
useTripStore.setState({
trip: buildTrip({ id: 1, name: 'Original' }),
trip: buildTrip({ id: 1, title: 'Original' }),
places: [existingPlace],
});
const updatedTrip = buildTrip({ id: 1, name: 'Updated' });
const updatedTrip = buildTrip({ id: 1, title: 'Updated' });
useTripStore.getState().handleRemoteEvent({ type: 'trip:updated', trip: updatedTrip });
const { places } = useTripStore.getState();
expect(places).toHaveLength(1);