/** * Handler registry: stores routes by schema.type. * Implements conflict resolution for merge() and mount(). */ import type { ConnectionData } from "../context/base-context.js"; import type { MessageDescriptor } from "../protocol/message-descriptor.js"; import type { RouteEntry } from "./types.js"; export interface RouteTableOptions { onConflict?: "error" | "skip" | "replace"; } /** * Internal route table for handler lookups and merging. * * Stores handlers by message type. Supports deterministic conflict resolution: * - "error" (default): throw if type collision * - "skip": keep existing handler, ignore incoming * - "replace": replace existing with incoming */ export declare class RouteTable { private handlers; /** * Register a handler for a message type. * Validates schema shape, kind literal, and event/RPC invariants. * Throws if type already registered (use merge() for conflict handling). */ register(schema: MessageDescriptor, entry: RouteEntry): this; /** * Get handler for a message type. */ get(type: string): RouteEntry | undefined; /** * Check if a handler is registered for a message type. */ has(type: string): boolean; /** * Get the number of registered handlers. */ size(): number; /** * List all registered [type, entry] pairs. */ list(): readonly [string, RouteEntry][]; /** * Merge another route table into this one with conflict resolution. * Assumes entries in both tables were validated at registration time. * Only use with tables created via register(), merge(), or mount(). * * @param other - Route table to merge * @param opts.onConflict - Resolution strategy: * - "error" (default): throw on collision * - "skip": keep existing, ignore incoming * - "replace": replace existing with incoming */ merge(other: RouteTable, opts?: RouteTableOptions): this; /** * Mount another route table with a prefix. * All message types from the other route table are prefixed with `prefix + type`. * Assumes entries in other table were validated at registration time. * Only use with tables created via register(), merge(), or mount(). * * @param prefix - Prefix to add (e.g., "auth." → "auth.LOGIN", "auth.REGISTER") * @param other - Route table to mount * @param opts.onConflict - Resolution strategy (same as merge) */ mount(prefix: string, other: RouteTable, opts?: RouteTableOptions): this; } //# sourceMappingURL=route-table.d.ts.map