feat(client): handle WS events against the shared registry

remoteEventHandler's two switches become enumerable lookups keyed by
TrekWsTripEventName (bodies unchanged); WebSocketEvent.type derives
from the registry. wsEventPolicy.ts makes the client's non-reactions
explicit (HANDLED_OUTSIDE_TRIP_STORE + IGNORED_WS_EVENTS) and the
registry-parity test turns an unclassified server event into a red
test instead of silence. Zero behavior change.
This commit is contained in:
jubnl
2026-07-29 00:17:47 +02:00
parent f66f8d8bd9
commit a2011dc991
4 changed files with 597 additions and 419 deletions
+9 -2
View File
@@ -6,6 +6,8 @@
// each documented against the producing service). Re-exported here so the rest
// of the client keeps importing from '../types' unchanged.
import type {
TrekWsEventName,
TrekWsPluginEventName,
Trip,
TripMember,
Day,
@@ -256,9 +258,14 @@ export interface AppConfig {
// Translation function type
export type TranslationFn = (key: string, params?: Record<string, string | number | null>) => string
// WebSocket event type
// WebSocket event type — `type` is derived from the shared WS event registry
// (TREK_WS_EVENTS): a registered name, the reserved plugin namespace, or (via
// the `string & {}` widening) a transport control frame the registry
// deliberately excludes (welcome/joined/left/error). Payload fields stay
// index-typed at this boundary; per-event payload contracts live in
// TrekWsPayload<E> from @trek/shared.
export interface WebSocketEvent {
type: string
type: TrekWsEventName | TrekWsPluginEventName | (string & {})
[key: string]: unknown
}