UNPKG

theater-client

Version:

TypeScript client library for Theater actor system TCP protocol

231 lines 4.23 kB
/** * Core Theater protocol types * These types match exactly with the Rust server implementation */ export type TheaterId = string; export type ChannelId = string; export type SubscriptionId = string; export type ChannelParticipant = { Actor: TheaterId; } | { Client: string; }; export type ManagementCommand = { StartActor: StartActorOptions; } | { StopActor: { id: TheaterId; }; } | { ListActors: {}; } | { SubscribeToActor: { id: TheaterId; }; } | { UnsubscribeFromActor: { id: TheaterId; subscription_id: SubscriptionId; }; } | { SendActorMessage: { id: TheaterId; data: number[]; }; } | { RequestActorMessage: { id: TheaterId; data: number[]; }; } | { GetActorManifest: { id: TheaterId; }; } | { GetActorStatus: { id: TheaterId; }; } | { RestartActor: { id: TheaterId; }; } | { GetActorState: { id: TheaterId; }; } | { GetActorEvents: { id: TheaterId; }; } | { GetActorMetrics: { id: TheaterId; }; } | { UpdateActorComponent: { id: TheaterId; component: string; }; } | { OpenChannel: { actor_id: ChannelParticipant; initial_message: number[]; }; } | { SendOnChannel: { channel_id: ChannelId; message: number[]; }; } | { CloseChannel: { channel_id: ChannelId; }; } | { NewStore: {}; }; export interface StartActorOptions { manifest: string; initial_state?: number[] | null; parent: boolean; subscribe: boolean; } export type ManagementResponse = { ActorStarted: { id: TheaterId; }; } | { ActorStopped: { id: TheaterId; }; } | { ActorList: { actors: Array<[TheaterId, string]>; }; } | { Subscribed: { id: TheaterId; subscription_id: SubscriptionId; }; } | { Unsubscribed: { id: TheaterId; }; } | { ActorEvent: { event: ChainEvent; }; } | { ActorResult: ActorResult; } | { ActorError: { error: ActorError; }; } | { Error: { error: ManagementError; }; } | { RequestedMessage: { id: TheaterId; message: number[]; }; } | { SentMessage: { id: TheaterId; }; } | { ActorStatus: { id: TheaterId; status: ActorStatus; }; } | { Restarted: { id: TheaterId; }; } | { ActorManifest: { id: TheaterId; manifest: ManifestConfig; }; } | { ActorState: { id: TheaterId; state: number[] | null; }; } | { ActorEvents: { id: TheaterId; events: ChainEvent[]; }; } | { ActorMetrics: { id: TheaterId; metrics: any; }; } | { ActorComponentUpdated: { id: TheaterId; }; } | { ChannelOpened: { channel_id: ChannelId; actor_id: ChannelParticipant; }; } | { MessageSent: { channel_id: ChannelId; }; } | { ChannelMessage: { channel_id: ChannelId; sender_id: ChannelParticipant; message: number[]; }; } | { ChannelClosed: { channel_id: ChannelId; }; } | { StoreCreated: { store_id: string; }; }; export type ManagementError = 'ActorNotFound' | 'ActorAlreadyExists' | 'ActorNotRunning' | { ActorError: string; } | 'ChannelNotFound' | 'ChannelClosed' | 'ChannelRejected' | { StoreError: string; } | { CommunicationError: string; } | { InvalidRequest: string; } | 'Timeout' | { RuntimeError: string; } | { InternalError: string; }; export interface ActorStatus { [key: string]: any; } export interface ActorResult { [key: string]: any; } export interface ActorError { [key: string]: any; } export interface ChainEvent { [key: string]: any; } export interface ManifestConfig { [key: string]: any; } export interface FrameMessage { Complete?: number[]; Fragment?: FragmentData; } export interface FragmentData { message_id: number; fragment_index: number; total_fragments: number; data: string; } //# sourceMappingURL=protocol.d.ts.map