@openfeed/sdk-js 1.6.0 → 1.6.2

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 +1 @@
1
- export declare const version = "1.6.0";
1
+ export declare const version = "1.6.2";
package/dist/index.js CHANGED
@@ -8920,6 +8920,18 @@ class OpenFeedConnection {
8920
8920
  this.subscriptionRequests.delete(originalRequest.correlationId.toString());
8921
8921
  }
8922
8922
  }
8923
+ send = (msg, correlationId) => {
8924
+ correlationId ??= CorrelationId.create();
8925
+ const token = this.connectionToken;
8926
+ const msg2 = {};
8927
+ if (msg.exchangeRequest !== void 0) msg2.exchangeRequest = { ...msg.exchangeRequest, correlationId, token };
8928
+ else if (msg.instrumentReferenceRequest !== void 0) msg2.instrumentReferenceRequest = { ...msg.instrumentReferenceRequest, correlationId, token };
8929
+ else if (msg.instrumentRequest !== void 0) msg2.instrumentRequest = { ...msg.instrumentRequest, correlationId, token };
8930
+ else if (msg.listSubscriptionsRequest !== void 0) msg2.listSubscriptionsRequest = { ...msg.listSubscriptionsRequest, correlationId, token };
8931
+ else if (msg.subscriptionRequest !== void 0) msg2.subscriptionRequest = { ...msg.subscriptionRequest, correlationId, token };
8932
+ send(this.socket, msg2);
8933
+ return correlationId;
8934
+ };
8923
8935
  getExchanges = async () => {
8924
8936
  if (this.whenDisconnectedSource.completed) {
8925
8937
  throw new ConnectionDisposedError("This connection was closed");
@@ -8988,7 +9000,7 @@ class OpenFeedConnection {
8988
9000
  whenDisconnected = () => this.whenDisconnectedSource.whenCompleted;
8989
9001
  dispose = () => this.disconnect(new ConnectionDisposedError("Disposed"));
8990
9002
  }
8991
- const version = "1.6.0";
9003
+ const version = "1.6.2";
8992
9004
  const getClientVersion = async (clientId) => {
8993
9005
  let platformDescription;
8994
9006
  if (typeof window !== "undefined") {
@@ -9318,16 +9330,14 @@ class OpenFeedListeners {
9318
9330
  return symbols?.map(([symbol2]) => symbol2) ?? [];
9319
9331
  };
9320
9332
  /* eslint-disable class-methods-use-this */
9321
- onCleanup = () => {
9322
- };
9333
+ onCleanup;
9323
9334
  onConnected = () => {
9324
9335
  };
9325
9336
  onCredentialsRejected = () => {
9326
9337
  };
9327
9338
  onDisconnected = () => {
9328
9339
  };
9329
- onMessage = () => {
9330
- };
9340
+ onMessage;
9331
9341
  onMessageWithMetadata = () => {
9332
9342
  };
9333
9343
  onHeartBeat = () => {
package/dist/node.js CHANGED
@@ -12618,6 +12618,18 @@ var OpenFeedConnection = class {
12618
12618
  this.subscriptionRequests.delete(originalRequest.correlationId.toString());
12619
12619
  }
12620
12620
  }
12621
+ send = (msg, correlationId) => {
12622
+ correlationId ??= CorrelationId.create();
12623
+ const token = this.connectionToken;
12624
+ const msg2 = {};
12625
+ if (msg.exchangeRequest !== void 0) msg2.exchangeRequest = { ...msg.exchangeRequest, correlationId, token };
12626
+ else if (msg.instrumentReferenceRequest !== void 0) msg2.instrumentReferenceRequest = { ...msg.instrumentReferenceRequest, correlationId, token };
12627
+ else if (msg.instrumentRequest !== void 0) msg2.instrumentRequest = { ...msg.instrumentRequest, correlationId, token };
12628
+ else if (msg.listSubscriptionsRequest !== void 0) msg2.listSubscriptionsRequest = { ...msg.listSubscriptionsRequest, correlationId, token };
12629
+ else if (msg.subscriptionRequest !== void 0) msg2.subscriptionRequest = { ...msg.subscriptionRequest, correlationId, token };
12630
+ send(this.socket, msg2);
12631
+ return correlationId;
12632
+ };
12621
12633
  getExchanges = async () => {
12622
12634
  var _a;
12623
12635
  if (this.whenDisconnectedSource.completed) {
@@ -12691,7 +12703,7 @@ var OpenFeedConnection = class {
12691
12703
  };
12692
12704
 
12693
12705
  // generated/version.ts
12694
- var version = "1.6.0";
12706
+ var version = "1.6.2";
12695
12707
 
12696
12708
  // src/utilities/client_version.ts
12697
12709
  var getClientVersion = async (clientId) => {
@@ -13046,16 +13058,14 @@ var OpenFeedListeners = class {
13046
13058
  return (symbols == null ? void 0 : symbols.map(([symbol2]) => symbol2)) ?? [];
13047
13059
  };
13048
13060
  /* eslint-disable class-methods-use-this */
13049
- onCleanup = () => {
13050
- };
13061
+ onCleanup;
13051
13062
  onConnected = () => {
13052
13063
  };
13053
13064
  onCredentialsRejected = () => {
13054
13065
  };
13055
13066
  onDisconnected = () => {
13056
13067
  };
13057
- onMessage = () => {
13058
- };
13068
+ onMessage;
13059
13069
  onMessageWithMetadata = () => {
13060
13070
  };
13061
13071
  onHeartBeat = () => {
@@ -3,7 +3,7 @@ import Long from "long";
3
3
  import type { ExchangeResponse_Exchange, InstrumentReferenceResponse, SubscriptionType } from "@gen/openfeed_api";
4
4
  import type { InstrumentDefinition } from "@gen/openfeed_instrument";
5
5
  import type { Service } from "@gen/openfeed";
6
- import { IOpenFeedConnection, IOpenFeedLogger, OpenFeedInstrumentReferenceRequest, OpenFeedInstrumentRequest } from "./interfaces";
6
+ import { IOpenFeedConnection, IOpenFeedLogger, OpenFeedInstrumentReferenceRequest, OpenFeedInstrumentRequest, OpenfeedRequest } from "./interfaces";
7
7
  import { OpenFeedListeners } from "./listeners";
8
8
  export declare class OpenFeedConnection implements IOpenFeedConnection {
9
9
  private readonly connectionToken;
@@ -26,6 +26,7 @@ export declare class OpenFeedConnection implements IOpenFeedConnection {
26
26
  subscribe: (service: Service, subscriptionType: SubscriptionType, snapshotIntervalSeconds: number, symbols?: string[] | null, marketIds?: Long[] | null, exchanges?: string[] | null, channels?: number[] | null) => Long;
27
27
  unsubscribe: (subscriptionId: Long) => void;
28
28
  private fireUnsubscribeWhenReady;
29
+ send: (msg: OpenfeedRequest, correlationId?: Long) => Long;
29
30
  getExchanges: () => Promise<ExchangeResponse_Exchange[]>;
30
31
  getInstrument: (request: OpenFeedInstrumentRequest) => Promise<InstrumentDefinition[]>;
31
32
  getInstrumentReference: (request: OpenFeedInstrumentReferenceRequest) => Promise<InstrumentReferenceResponse>;
@@ -1,10 +1,18 @@
1
1
  import Long from "long";
2
2
  import type { Service } from "@gen/openfeed";
3
- import type { ExchangeResponse_Exchange, InstrumentReferenceRequest, InstrumentReferenceResponse, InstrumentRequest, SubscriptionType } from "@gen/openfeed_api";
3
+ import type { ExchangeResponse_Exchange, InstrumentReferenceRequest, InstrumentReferenceResponse, InstrumentRequest, OpenfeedGatewayRequest, SubscriptionType } from "@gen/openfeed_api";
4
4
  import { OptionalUndefined } from "@src/utilities/messages";
5
5
  import type { InstrumentDefinition } from "@gen/openfeed_instrument";
6
6
  export type OpenFeedInstrumentRequest = Omit<OptionalUndefined<InstrumentRequest>, "correlationId" | "token" | "version">;
7
7
  export type OpenFeedInstrumentReferenceRequest = Omit<OptionalUndefined<InstrumentReferenceRequest>, "correlationId" | "token">;
8
+ type OmitDistributive<T, K extends PropertyKey> = T extends any ? (T extends object ? Id<Omit<T, K>> : T) : never;
9
+ type Id<T> = {} & {
10
+ [P in keyof T]: T[P];
11
+ };
12
+ type OmitRecursively<T, K extends PropertyKey> = {
13
+ [P in keyof T]: OmitDistributive<T[P], K>;
14
+ };
15
+ export type OpenfeedRequest = OmitRecursively<Omit<OpenfeedGatewayRequest, "loginRequest" | "logoutRequest">, "correlationId" | "token">;
8
16
  export interface IOpenFeedConnection {
9
17
  subscribe: (service: Service, subscriptionType: SubscriptionType, snapshotIntervalSeconds: number, symbols: string[] | null, marketIds: Long[] | null, exchanges: string[] | null, channels: number[] | null) => Long;
10
18
  unsubscribe: (subscriptionId: Long) => void;
@@ -12,6 +20,7 @@ export interface IOpenFeedConnection {
12
20
  getExchanges: () => Promise<ExchangeResponse_Exchange[]>;
13
21
  getInstrument: (request: OpenFeedInstrumentRequest) => Promise<InstrumentDefinition[]>;
14
22
  getInstrumentReference: (request: OpenFeedInstrumentReferenceRequest) => Promise<InstrumentReferenceResponse>;
23
+ send(msg: OpenfeedRequest, correlationId?: Long): Long;
15
24
  }
16
25
  export interface IOpenFeedClient {
17
26
  get connection(): Promise<IOpenFeedConnection>;
@@ -24,3 +33,4 @@ export interface IOpenFeedLogger {
24
33
  warn: (...data: any[]) => void;
25
34
  error: (...data: any[]) => void;
26
35
  }
36
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfeed/sdk-js",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "JavaScript SDK for Barchart OpenFeed",
5
5
  "main": "dist/node.js",
6
6
  "browser": "dist/index.js",