import { ResourceType } from "../core/resource"; import { Observer } from "rxjs"; export declare enum WebSocketState { CONNECTING = 0, OPEN = 1, CLOSING = 2, CLOSED = 3 } export interface IWebSocket { readyState: number; onclose: ((ev: any) => any) | null; onerror: ((ev: any) => any) | null; onmessage: ((ev: any) => any) | null; onopen: ((ev: any) => any) | null; close(code?: number): void; send(data: string): void; } export declare type IWebSocketBuilder = (appUrl: string) => IWebSocket; export interface RealTimeMessage { type: RealTimeMessageTypes; data: RealTimeEventMessage | RealTimeCommand | RealTimeCommandResponse | RealTimeNotification; } export declare enum RealTimeMessageTypes { Command = "command", CommandResponse = "command response", EventMessage = "event", Notification = "notification" } export interface RealTimeEventMessage { action: EventSubscriptionType; resource: Resource; modifier: Modifier; timestamp: string; data: T; } export interface RealTimeCommandStack { events: EventSubscriptionType[]; setName: string; setType: ResourceType; observer: Observer; } export interface RealTimeCommand { command: RealTimeCommandTypes; arguments: SubscriptionArgument | JwtRefreshArgument | PublishArgument; correlation_id?: string; } export declare enum RealTimeCommandTypes { Subscribe = "subscribe", UnSubscribe = "unsubscribe", JwtRefresh = "jwt replace", Publish = "publish" } export interface RealTimeCommandResponse { request: any; response?: any; error?: CommandError; } export interface CommandError { code: CommandErrorCodes; info: string; } export interface RealTimeNotification { code: NotificationCodes; info: string; data?: any; } export declare enum NotificationCodes { TokenAboutToExpire = "1" } export interface SubscriptionArgument { action: EventSubscriptionType[]; resource: Resource; } export interface PublishArgument { channel: string; data: any; } export interface JwtRefreshArgument { token: string; } export interface RealTimeStoredMessage { id: string; created_at: string; updated_at: string; sender_id: string; sender_type: string; data: any; } export interface Resource { type: ResourceType; name: string; } export interface Modifier { type: string; id: string; } export declare enum CommandErrorCodes { InternalError = "1", Unauthorized = "2", InvalidToken = "3", BadFormatting = "4", UnknownType = "5", UnknownCommand = "6", UnknownResourceType = "1000", UnknownResourceName = "1001", UnknownAction = "1002" } export declare type EventSubscriptionType = "created" | "updated" | "deleted" | "published" | "all";