1 | import { ListenerFn } from 'eventemitter3';
|
2 | import { ExecutionResult } from 'graphql/execution/execute';
|
3 | import { DocumentNode } from 'graphql/language/ast';
|
4 | export interface Observer<T> {
|
5 | next?: (value: T) => void;
|
6 | error?: (error: Error) => void;
|
7 | complete?: () => void;
|
8 | }
|
9 | export interface Observable<T> {
|
10 | subscribe(observer: Observer<T>): {
|
11 | unsubscribe: () => void;
|
12 | };
|
13 | }
|
14 | export interface OperationOptions {
|
15 | query?: string | DocumentNode;
|
16 | variables?: Object;
|
17 | operationName?: string;
|
18 | [key: string]: any;
|
19 | }
|
20 | export declare type FormatedError = Error & {
|
21 | originalError?: any;
|
22 | };
|
23 | export interface Operation {
|
24 | options: OperationOptions;
|
25 | handler: (error: Error[], result?: any) => void;
|
26 | }
|
27 | export interface Operations {
|
28 | [id: string]: Operation;
|
29 | }
|
30 | export interface Middleware {
|
31 | applyMiddleware(options: OperationOptions, next: Function): void;
|
32 | }
|
33 | export declare type ConnectionParams = {
|
34 | [paramName: string]: any;
|
35 | };
|
36 | export declare type ConnectionParamsOptions = ConnectionParams | Function | Promise<ConnectionParams>;
|
37 | export interface ClientOptions {
|
38 | connectionParams?: ConnectionParamsOptions;
|
39 | minTimeout?: number;
|
40 | timeout?: number;
|
41 | reconnect?: boolean;
|
42 | reconnectionAttempts?: number;
|
43 | connectionCallback?: (error: Error[], result?: any) => void;
|
44 | lazy?: boolean;
|
45 | inactivityTimeout?: number;
|
46 | wsOptionArguments?: any[];
|
47 | }
|
48 | export declare class SubscriptionClient {
|
49 | client: any;
|
50 | operations: Operations;
|
51 | private url;
|
52 | private nextOperationId;
|
53 | private connectionParams;
|
54 | private minWsTimeout;
|
55 | private wsTimeout;
|
56 | private unsentMessagesQueue;
|
57 | private reconnect;
|
58 | private reconnecting;
|
59 | private reconnectionAttempts;
|
60 | private backoff;
|
61 | private connectionCallback;
|
62 | private eventEmitter;
|
63 | private lazy;
|
64 | private inactivityTimeout;
|
65 | private inactivityTimeoutId;
|
66 | private closedByUser;
|
67 | private wsImpl;
|
68 | private wsProtocols;
|
69 | private wasKeepAliveReceived;
|
70 | private tryReconnectTimeoutId;
|
71 | private checkConnectionIntervalId;
|
72 | private maxConnectTimeoutId;
|
73 | private middlewares;
|
74 | private maxConnectTimeGenerator;
|
75 | private wsOptionArguments;
|
76 | constructor(url: string, options?: ClientOptions, webSocketImpl?: any, webSocketProtocols?: string | string[]);
|
77 | get status(): any;
|
78 | close(isForced?: boolean, closedByUser?: boolean): void;
|
79 | request(request: OperationOptions): Observable<ExecutionResult>;
|
80 | on(eventName: string, callback: ListenerFn, context?: any): Function;
|
81 | onConnected(callback: ListenerFn, context?: any): Function;
|
82 | onConnecting(callback: ListenerFn, context?: any): Function;
|
83 | onDisconnected(callback: ListenerFn, context?: any): Function;
|
84 | onReconnected(callback: ListenerFn, context?: any): Function;
|
85 | onReconnecting(callback: ListenerFn, context?: any): Function;
|
86 | onError(callback: ListenerFn, context?: any): Function;
|
87 | unsubscribeAll(): void;
|
88 | applyMiddlewares(options: OperationOptions): Promise<OperationOptions>;
|
89 | use(middlewares: Middleware[]): SubscriptionClient;
|
90 | private getConnectionParams;
|
91 | private executeOperation;
|
92 | private getObserver;
|
93 | private createMaxConnectTimeGenerator;
|
94 | private clearCheckConnectionInterval;
|
95 | private clearMaxConnectTimeout;
|
96 | private clearTryReconnectTimeout;
|
97 | private clearInactivityTimeout;
|
98 | private setInactivityTimeout;
|
99 | private checkOperationOptions;
|
100 | private buildMessage;
|
101 | private formatErrors;
|
102 | private sendMessage;
|
103 | private sendMessageRaw;
|
104 | private generateOperationId;
|
105 | private tryReconnect;
|
106 | private flushUnsentMessagesQueue;
|
107 | private checkConnection;
|
108 | private checkMaxConnectTimeout;
|
109 | private connect;
|
110 | private processReceivedData;
|
111 | private unsubscribe;
|
112 | }
|