UNPKG

rn-kore-bot-socket-lib-v77

Version:
201 lines (192 loc) 6.2 kB
import { EventEmitter } from 'events'; declare const RTM_EVENT: { CONNECTING: string; AUTHENTICATED: string; ON_OPEN: string; ON_DISCONNECT: string; ON_CLOSE: string; ON_ERROR: string; ON_MESSAGE: string; ON_FAILURE: string; PING: string; PONG: string; ERROR: string; RECONNECTING: string; UNABLE_TO_RTM_START: string; GET_HISTORY: string; GET_RESULT_VIEW_SETTINGS: string; ON_ACK: string; ON_JWT_TOKEN_AUTHORIZED: string; }; declare const ConnectionState: { CONNECTING: number; CONNECTED: number; DISCONNECTED: number; }; declare const APP_STATE: { ACTIVE: string; SLEEP: string; }; interface BotConfigModel { botName: string; botId: string; clientId: string; clientSecret: string; botUrl: string; identity: string; jwtServerUrl: string; isWebHook: boolean; value_aud: string; isHeaderVisible: boolean; isFooterVisible: boolean; } interface IBotClient { sendMessage(message: any, payload?: any, attachments?: any): any; reconnect(isReconnectionAttempt: boolean, resetReconnectAttemptCount?: boolean): any; setIsNetworkAvailable(setNetWork: boolean): any; initializeBotClient(model: BotConfigModel): any; disconnect(): any; setSessionActive(isActive: boolean): any; setAppState(appState: string): any; checkSocketAndReconnect(): any; getBotHistory(): any; getBotUserIdentity(): any; getConnectionState(): any; getBotName(): string | undefined; getBotUrl(): string | undefined; getUserId(): string; getAccessToken(): string; getAuthorization(): string | undefined; getAppState(): string | undefined; } declare class BotClient extends EventEmitter implements IBotClient { private pingInterval; private pingTimer?; private receivedLastPong; private timer?; private isConnecting; private jwtToken; private resultViewSettings; private webSocket?; private botUrl; private sessionActive; private appState; private isNetWorkAvailable; private botInfo; private customData; private userInfo; private authorization; private botCustomData; private isConnectAtleastOnce; private connectionState; private reconnectAttemptCount; private isReconnectAttemptRequired; private DATA_IDENTITY; private DATA_USERNAME; private RECONNECT_PARAM; private reconnectTimer?; private botConfig?; private isChangeToken?; constructor(); initializeBotClient(config: BotConfigModel): void; getAccessToken(): any; getUserId: () => any; getBotName: () => string | undefined; getBotUrl: () => string; getJwtServerUrl: () => string; getAuthorization: () => string | undefined; private connectToBot; private getJwtToken; private initialize; setSessionActive(isActive: boolean): void; setAppState(appState: string): void; getAppState(): string | undefined; setIsNetworkAvailable(isNetWorkAvailable: boolean): void; private connectWithJwToken; private getRtmUrl; private connect; private onMessage; getBotHistory(): Promise<void>; subscribePushNotifications(deviceId?: string): Promise<boolean>; unsubscribePushNotifications(deviceId?: string): Promise<boolean>; private fetchWithRetries; getConnectionState(): number; disconnect(): void; private initSocketConnection; reconnect(isReconnectionAttempt: boolean, resetReconnectAttemptCount?: boolean): void; private refreshTokenAndReconnect; private getReconnectDelay; checkSocketAndReconnect(): void; getSettings(): Promise<boolean>; private startSendingPing; private setTimer; send: (message: { type?: string | undefined; clientMessageId?: {} | undefined; message?: any; resourceid?: string | undefined; botInfo?: {} | undefined; id?: {} | undefined; client?: string | undefined; }) => void; getBotAccessToken(): any; getResultViewSettings(): never[]; getBotUserId(): any; getBotUserIdentity(): any; getBotInfo(): any; sendMessage(message: any, payload?: any, attachments?: any): any; } declare class KoreBotClient extends BotClient implements IBotClient { private static _instance; private constructor(); static getInstance(): KoreBotClient; static disconnectClient(): void; setSessionActive(isActive: boolean): void; setAppState(_appState: string): void; setIsNetworkAvailable(isNetWorkAvailable: boolean): void; checkSocketAndReconnect(): void; } declare class ActiveThemeAPI { private isSocketACtive; private fetchWithRetries; getThemeAPI(botConfig: BotConfigModel, callback?: (data?: any) => void): Promise<void>; private getAppTheme; } declare enum LogLevel { DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3 } interface LogEntry { timestamp: string; level: LogLevel; category: string; message: string; data?: any; error?: any; } declare class Logger { private static instance; private logLevel; private logs; private maxLogs; private constructor(); static getInstance(): Logger; setLogLevel(level: LogLevel): void; private log; logApiRequest(endpoint: string, method: string, data?: any): void; logApiSuccess(endpoint: string, method: string, responseData?: any, duration?: number): void; logApiError(endpoint: string, method: string, error: any, duration?: number): void; logWebSocketEvent(event: string, data?: any): void; logWebSocketError(event: string, error: any): void; logConnectionEvent(event: string, data?: any): void; logConnectionError(event: string, error: any): void; debug(message: string, data?: any): void; info(message: string, data?: any): void; warn(message: string, data?: any, error?: any): void; error(message: string, data?: any, error?: any): void; getLogs(level?: LogLevel): LogEntry[]; clearLogs(): void; } export { APP_STATE, ActiveThemeAPI, type BotConfigModel, ConnectionState, type LogEntry, LogLevel, Logger, RTM_EVENT, KoreBotClient as default };