11import  type  {  WebSocket  }  from  'ws' ; 
22
3- export  type  ReconnectOptions  =  { 
4-   enabled ?: boolean ; 
5-   maxReconnectAttempts ?: number ; 
6-   reconnectInterval ?: number ; 
7- } ; 
8- export  default  class  ChainlinkDataStreamsConsumer  { 
3+ export  { 
4+   Report , 
5+   EventEmitter , 
6+   ChainlinkDataStreamsConsumer  as  default , 
7+   ChainlinkDataStreamsConsumer  as  Consumer , 
8+   ChainlinkDataStreamsError  as  Error , 
9+   generateHeaders , 
10+ } 
11+ 
12+ declare  class  EventEmitter  { 
13+   on ( event : string ,  cb : Function ) : this; 
14+   off ( event : string ,  cb : Function ) : this; 
15+   once ( event : string ,  cb : Function ) : this; 
16+   emit ( event : string ,  data : unknown ) : this; 
17+ } 
18+ 
19+ declare  class  ChainlinkDataStreamsConsumer  extends  EventEmitter  { 
920  constructor ( args : { 
1021    /** API client ID. */ 
1122    clientId ?: string ; 
@@ -17,40 +28,42 @@ export default class ChainlinkDataStreamsConsumer {
1728    wsUrl ?: string ; 
1829    /** List of feed IDs to subscribe to. */ 
1930    feeds ?: string [ ] ; 
20-     /** Disable or configure socket auto-reconnect. */ 
21-     reconnect ?: boolean | ReconnectOptions ; 
22-     /** Don't automatically connect to socket on construction or setting feeds. */ 
31+     /** Automatically connect to socket on construction or setting feeds? */ 
2332    lazy ?: boolean ; 
33+     /** Disable or configure socket auto-reconnect. */ 
34+     reconnect ?: boolean | { 
35+       enabled ?: boolean ; 
36+       maxAttempts ?: number ; 
37+       interval ?: number ; 
38+     } ; 
2439  } ) ; 
25- 
26-   fetchFeed ( args : { 
27-     timestamp : string  |  number ; 
28-     feed : string ; 
29-   } ) : Promise < Report > ; 
30- 
31-   fetchFeeds ( args : { 
32-     timestamp : string  |  number ; 
33-     feeds : string [ ] ; 
34-   } ) : Promise < Record < string ,  Report > > ; 
35- 
36-   subscribeTo ( feeds : string  |  string [ ] ) : Promise < WebSocket  |  null > ; 
37- 
38-   unsubscribeFrom ( feeds : string  |  string [ ] ) : Promise < WebSocket  |  null > ; 
39- 
40-   connect ( ) : Promise < void > ; 
41- 
42-   disconnect ( ) : void ; 
43- 
44-   feeds : Set < string > ; 
45- 
46-   on ( event : string ,  cb : Function ) : this; 
47- 
48-   off ( event : string ,  cb : Function ) : this; 
49- 
50-   once ( event : string ,  cb : Function ) : this; 
40+   get  socketState  ( ) :
41+     WebSocket [ "readyState" ] | null ; 
42+   fetchFeed ( args : {  timestamp : string  |  number ;  feed : string ;  } ) :
43+     Promise < Report > ; 
44+   fetchFeeds ( args : {  timestamp : string  |  number ;  feeds : string [ ] ;  } ) :
45+     Promise < Record < string ,  Report > > ; 
46+   subscribeTo ( feeds : string  |  string [ ] ) : 
47+     Promise < WebSocket  |  null > ; 
48+   unsubscribeFrom ( feeds : string  |  string [ ] ) :
49+     Promise < WebSocket  |  null > ; 
50+   unsubscribeAll ( ) :
51+     Promise < WebSocket  |  null > ; 
52+   connect ( ) :
53+     Promise < void > ; 
54+   disconnect ( ) :
55+     void ; 
56+   get  feeds :
57+     Set < string >  &  {  add : never ,  delete : never ,  clear : never  } ; 
58+   generateHeaders ( 
59+     method : string , 
60+     path : string , 
61+     search : string | URLSearchParams , 
62+     timestamp ?: number 
63+   ) : AuthHeaders ; 
5164} 
5265
53- export  type  Report  =  { 
66+ declare  type  Report  =  { 
5467  feedId : string ; 
5568  observationsTimestamp : bigint ; 
5669}  &  ( 
@@ -90,3 +103,21 @@ export type Report = {
90103      marketStatus : number ; 
91104    } 
92105) ; 
106+ 
107+ declare  class  ChainlinkDataStreamsError  extends  Error  { 
108+ } 
109+ 
110+ declare  function  generateHeaders  ( args : { 
111+   clientId : string , 
112+   clientSecret : string , 
113+   method : string , 
114+   path : string , 
115+   search : string | URLSearchParams , 
116+   timestamp ?: number 
117+ } ) : AuthHeaders 
118+ 
119+ declare  type  AuthHeaders  =  { 
120+   'Authorization' :                    string 
121+   'X-Authorization-Timestamp' :        string 
122+   'X-Authorization-Signature-SHA256' : string 
123+ } 
0 commit comments