@evedex/exchange-api 1.0.63 → 1.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { utils as cryptoUtils } from "@evedex/exchange-crypto";
2
- import { Callback, CentrifugeClient, MarketDepth, MarketDepthLevel, MatcherState, Order, OrderFillFee, Position, TpSl, OrderBookRoundPrices, type RecentTrade, type InstrumentUpdateEvent, Transfer, type OrderFill } from "./utils";
2
+ import { Callback, CentrifugeClient, MarketDepth, MarketDepthLevel, MatcherState, Order, OrderFillFee, Position, TpSl, OrderBookRoundPrices, type RecentTrade, type InstrumentUpdateEvent, Transfer, type OrderFill, type SubscriptionOptions } from "./utils";
3
3
  export interface HeartbeatEvent {
4
4
  t: number;
5
5
  }
@@ -106,8 +106,8 @@ export declare class ExchangeWsGateway {
106
106
  constructor(options: ExchangeWsGatewayOptions);
107
107
  protected listenChannel<T>(name: string, recoverable: boolean, handler: Callback<{
108
108
  data: T;
109
- }>): void;
110
- protected unListenChannel(name: string, recoverable: boolean): void;
109
+ }>, options?: Partial<SubscriptionOptions>): void;
110
+ protected unListenChannel(name: string, recoverable: boolean, options?: Partial<SubscriptionOptions>): void;
111
111
  onHeartbeat: import("./utils").Signal<HeartbeatEvent>;
112
112
  listenHeartbeat(): void;
113
113
  unListenHeartbeat(): void;
@@ -25,18 +25,18 @@ class ExchangeWsGateway {
25
25
  this.onFundingRateUpdate = (0, utils_1.signal)();
26
26
  this.onInstrumentUpdate = (0, utils_1.signal)();
27
27
  }
28
- listenChannel(name, recoverable, handler) {
28
+ listenChannel(name, recoverable, handler, options = {}) {
29
29
  if (this.listenedChannels.has(name))
30
30
  return;
31
- const channel = this.options.wsClient.assignChannel(name, { recoverable });
31
+ const channel = this.options.wsClient.assignChannel(name, Object.assign(Object.assign({}, options), { recoverable }));
32
32
  channel.onPublication(handler);
33
33
  channel.subscribe();
34
34
  this.listenedChannels.add(name);
35
35
  }
36
- unListenChannel(name, recoverable) {
36
+ unListenChannel(name, recoverable, options = {}) {
37
37
  if (!this.listenedChannels.has(name))
38
38
  return;
39
- this.options.wsClient.assignChannel(name, { recoverable }).unsubscribe();
39
+ this.options.wsClient.assignChannel(name, Object.assign(Object.assign({}, options), { recoverable })).unsubscribe();
40
40
  this.listenedChannels.delete(name);
41
41
  }
42
42
  listenHeartbeat() {
@@ -4,12 +4,44 @@ export interface CentrifugeSubscription {
4
4
  subscribe(): void;
5
5
  unsubscribe(): void;
6
6
  }
7
- export interface AssignChannelOptions {
7
+ export interface SubscriptionTokenContext {
8
+ channel: string;
9
+ }
10
+ export interface SubscriptionDataContext {
11
+ channel: string;
12
+ }
13
+ /** Stream postion describes position of publication inside a stream. */
14
+ export interface StreamPosition {
15
+ offset: number;
16
+ epoch: string;
17
+ }
18
+ export interface SubscriptionOptions {
19
+ /** allows setting initial subscription token (JWT) */
20
+ token: string;
21
+ /** allows setting function to get/refresh subscription token */
22
+ getToken: null | ((ctx: SubscriptionTokenContext) => Promise<string>);
23
+ /** data to send to a server with subscribe command */
24
+ data: any | null;
25
+ /** allows setting function to get/renew subscription data */
26
+ getData: null | ((ctx: SubscriptionDataContext) => Promise<any>);
27
+ /** force recovery on first subscribe from a provided StreamPosition. */
28
+ since: StreamPosition | null;
29
+ /** min delay between resubscribe attempts. */
30
+ minResubscribeDelay: number;
31
+ /** max delay between resubscribe attempts. */
32
+ maxResubscribeDelay: number;
33
+ /** ask server to make subscription positioned. */
34
+ positioned: boolean;
35
+ /** ask server to make subscription recoverable. */
8
36
  recoverable: boolean;
37
+ /** ask server to send join/leave messages. */
38
+ joinLeave: boolean;
39
+ /** delta format to be used */
40
+ delta: "fossil";
9
41
  }
10
42
  export interface CentrifugeClient {
11
43
  onConnected(callback: Callback<any>): void;
12
44
  onDisconnected(callback: Callback<any>): void;
13
45
  connect(): void;
14
- assignChannel(name: string, options?: AssignChannelOptions): CentrifugeSubscription;
46
+ assignChannel(name: string, options?: Partial<SubscriptionOptions>): CentrifugeSubscription;
15
47
  }
@@ -1,5 +1,5 @@
1
1
  import { utils as cryptoUtils } from "@evedex/exchange-crypto";
2
- import { Callback, CentrifugeClient, MarketDepth, MarketDepthLevel, MatcherState, Order, OrderFillFee, Position, TpSl, OrderBookRoundPrices, type RecentTrade, type InstrumentUpdateEvent, Transfer, type OrderFill } from "./utils";
2
+ import { Callback, CentrifugeClient, MarketDepth, MarketDepthLevel, MatcherState, Order, OrderFillFee, Position, TpSl, OrderBookRoundPrices, type RecentTrade, type InstrumentUpdateEvent, Transfer, type OrderFill, type SubscriptionOptions } from "./utils";
3
3
  export interface HeartbeatEvent {
4
4
  t: number;
5
5
  }
@@ -106,8 +106,8 @@ export declare class ExchangeWsGateway {
106
106
  constructor(options: ExchangeWsGatewayOptions);
107
107
  protected listenChannel<T>(name: string, recoverable: boolean, handler: Callback<{
108
108
  data: T;
109
- }>): void;
110
- protected unListenChannel(name: string, recoverable: boolean): void;
109
+ }>, options?: Partial<SubscriptionOptions>): void;
110
+ protected unListenChannel(name: string, recoverable: boolean, options?: Partial<SubscriptionOptions>): void;
111
111
  onHeartbeat: import("./utils").Signal<HeartbeatEvent>;
112
112
  listenHeartbeat(): void;
113
113
  unListenHeartbeat(): void;
@@ -5,18 +5,18 @@ export class ExchangeWsGateway {
5
5
  constructor(options) {
6
6
  this.options = options;
7
7
  }
8
- listenChannel(name, recoverable, handler) {
8
+ listenChannel(name, recoverable, handler, options = {}) {
9
9
  if (this.listenedChannels.has(name))
10
10
  return;
11
- const channel = this.options.wsClient.assignChannel(name, { recoverable });
11
+ const channel = this.options.wsClient.assignChannel(name, { ...options, recoverable });
12
12
  channel.onPublication(handler);
13
13
  channel.subscribe();
14
14
  this.listenedChannels.add(name);
15
15
  }
16
- unListenChannel(name, recoverable) {
16
+ unListenChannel(name, recoverable, options = {}) {
17
17
  if (!this.listenedChannels.has(name))
18
18
  return;
19
- this.options.wsClient.assignChannel(name, { recoverable }).unsubscribe();
19
+ this.options.wsClient.assignChannel(name, { ...options, recoverable }).unsubscribe();
20
20
  this.listenedChannels.delete(name);
21
21
  }
22
22
  // Market
@@ -4,12 +4,44 @@ export interface CentrifugeSubscription {
4
4
  subscribe(): void;
5
5
  unsubscribe(): void;
6
6
  }
7
- export interface AssignChannelOptions {
7
+ export interface SubscriptionTokenContext {
8
+ channel: string;
9
+ }
10
+ export interface SubscriptionDataContext {
11
+ channel: string;
12
+ }
13
+ /** Stream postion describes position of publication inside a stream. */
14
+ export interface StreamPosition {
15
+ offset: number;
16
+ epoch: string;
17
+ }
18
+ export interface SubscriptionOptions {
19
+ /** allows setting initial subscription token (JWT) */
20
+ token: string;
21
+ /** allows setting function to get/refresh subscription token */
22
+ getToken: null | ((ctx: SubscriptionTokenContext) => Promise<string>);
23
+ /** data to send to a server with subscribe command */
24
+ data: any | null;
25
+ /** allows setting function to get/renew subscription data */
26
+ getData: null | ((ctx: SubscriptionDataContext) => Promise<any>);
27
+ /** force recovery on first subscribe from a provided StreamPosition. */
28
+ since: StreamPosition | null;
29
+ /** min delay between resubscribe attempts. */
30
+ minResubscribeDelay: number;
31
+ /** max delay between resubscribe attempts. */
32
+ maxResubscribeDelay: number;
33
+ /** ask server to make subscription positioned. */
34
+ positioned: boolean;
35
+ /** ask server to make subscription recoverable. */
8
36
  recoverable: boolean;
37
+ /** ask server to send join/leave messages. */
38
+ joinLeave: boolean;
39
+ /** delta format to be used */
40
+ delta: "fossil";
9
41
  }
10
42
  export interface CentrifugeClient {
11
43
  onConnected(callback: Callback<any>): void;
12
44
  onDisconnected(callback: Callback<any>): void;
13
45
  connect(): void;
14
- assignChannel(name: string, options?: AssignChannelOptions): CentrifugeSubscription;
46
+ assignChannel(name: string, options?: Partial<SubscriptionOptions>): CentrifugeSubscription;
15
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evedex/exchange-api",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/mjs/index.js",