import type { Context, JsonValue, ServiceCall, ServiceProviderUpdate } from "@earendil-works/chord"; import type { ServerListener } from "./listener.ts"; export interface ServerOptions { listeners: readonly ServerListener[]; /** Stable logical server identity supplied by the installation or profile. */ serverId: string; maxFrameLength?: number; handshakeTimeoutMs?: number; onConnectionCountChanged?: (count: number) => void; onError?: (error: Error) => void; } export type MaybePromise = T | Promise; /** Minimal durable Session metadata the server needs for routing. Applications may extend it. */ export interface SessionMetadata { readonly id: string; } /** One presentation connection's live capability for a hosted Session. */ export interface RoutedSessionAttachment { /** Route one contract-agnostic service operation to the attached Session endpoint. */ invokeService(call: ServiceCall, publish: (subscriptionId: string, update: ServiceProviderUpdate, context: Context) => MaybePromise, context: Context): Promise; release(context: Context): MaybePromise; } /** Presentation-scoped routing capabilities available to server service implementations. */ export interface RoutedServerPresentation { attachSession(sessionId: string, context: Context): Promise; detachSession(context: Context): Promise; /** Release routed attachments and handles before the application deletes durable metadata. */ prepareSessionRemoval(sessionId: string, context: Context): Promise; } /** One connection's server-scoped service endpoint. */ export interface RoutedServerServiceAttachment { invokeService(call: ServiceCall, publish: (subscriptionId: string, update: ServiceProviderUpdate, context: Context) => MaybePromise, context: Context): Promise; release(context: Context): MaybePromise; } export interface RoutedServerServiceHost { attachClient(presentation: RoutedServerPresentation, context: Context): MaybePromise; } /** A process-safe handle that acquires presentation-scoped Session capabilities. */ export interface RoutedSessionHandle { attachClient(context: Context): MaybePromise; /** Resolves with an error for unexpected termination, or undefined after an expected close. */ readonly terminated?: Promise; close(context: Context): Promise; } /** Application capabilities used by server-wide management and Session routing. */ export interface ServerHost { readonly serverServices: RoutedServerServiceHost; /** Resolve one durable Session ID or throw a bounded routing error. */ resolveSession(sessionId: string, context: Context): Promise; openSession(metadata: TMetadata, context: Context): Promise; } //# sourceMappingURL=types.d.ts.map