mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
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:
+9
-2
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user