UNPKG

theater-client

Version:

TypeScript client library for Theater actor system TCP protocol

67 lines 2.34 kB
/** * Client-specific types for the Theater client library */ import type { TheaterId, ChannelId, ChannelParticipant, ManagementError, ChainEvent, ActorError, ActorResult } from './protocol.js'; export interface TheaterClientConfig { host?: string; port?: number; timeout?: number; retryAttempts?: number; retryDelay?: number; } export interface ChannelMessage { senderId: ChannelParticipant; data: Uint8Array; timestamp: Date; } export interface ChannelStream { readonly channelId: ChannelId; readonly isOpen: boolean; onMessage(handler: (message: ChannelMessage) => void): () => void; onClose(handler: () => void): () => void; onError(handler: (error: Error) => void): () => void; sendMessage(data: Uint8Array): Promise<void>; close(): void; } export interface ActorEventStream { readonly actorId: TheaterId; readonly subscriptionId: string; readonly isActive: boolean; onEvent(handler: (event: any) => void): () => void; onError(handler: (error: Error) => void): () => void; onClose(handler: () => void): () => void; close(): void; } export declare class TheaterError extends Error { readonly code?: string | undefined; readonly details?: ManagementError | undefined; constructor(message: string, code?: string | undefined, details?: ManagementError | undefined); } export declare class TheaterConnectionError extends TheaterError { readonly cause?: Error | undefined; constructor(message: string, cause?: Error | undefined); } export declare class TheaterTimeoutError extends TheaterError { constructor(operation: string, timeout: number); } export declare class TheaterProtocolError extends TheaterError { readonly details?: any | undefined; constructor(message: string, details?: any | undefined); } export interface ActorCallbacks { onEvent?: (event: ChainEvent) => void; onError?: (error: ActorError) => void; onActorResult?: (result: ActorResult) => void; } export interface StartActorParams { manifest: string; initialState?: Uint8Array; onEvent?: (event: ChainEvent) => void; onError?: (error: ActorError) => void; onActorResult?: (result: ActorResult) => void; } export interface ActorInfo { id: TheaterId; manifest: string; } //# sourceMappingURL=client.d.ts.map