@openfeed/sdk-js 1.6.1 → 1.6.3
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.
|
|
1
|
+
export declare const version = "1.6.3";
|
package/dist/index.js
CHANGED
|
@@ -8666,22 +8666,25 @@ class CorrelationId {
|
|
|
8666
8666
|
};
|
|
8667
8667
|
}
|
|
8668
8668
|
const toT = (obj) => obj;
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
}
|
|
8669
|
+
function encodeMessages(message) {
|
|
8670
|
+
return OpenfeedGatewayRequestEncode.encode(message).finish();
|
|
8671
|
+
}
|
|
8672
|
+
function send(socket, message) {
|
|
8673
|
+
socket.send(encodeMessages(toT(message)));
|
|
8674
|
+
}
|
|
8672
8675
|
const getShort = (a, b) => a << 8 | b << 0;
|
|
8673
|
-
|
|
8674
|
-
const array = new Uint8Array(msgEvent.data);
|
|
8676
|
+
function* decodeMessages(bytes) {
|
|
8675
8677
|
let currentIndex = 0;
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
const
|
|
8679
|
-
const currentArray = array.subarray(currentIndex + 2, currentIndex + shortVal);
|
|
8678
|
+
while (getShort(bytes[currentIndex], bytes[currentIndex + 1])) {
|
|
8679
|
+
const shortVal = getShort(bytes[currentIndex], bytes[currentIndex + 1]) + 2;
|
|
8680
|
+
const currentArray = bytes.subarray(currentIndex + 2, currentIndex + shortVal);
|
|
8680
8681
|
currentIndex += shortVal;
|
|
8681
|
-
|
|
8682
|
+
yield OpenfeedGatewayMessageDecode.decode(currentArray);
|
|
8682
8683
|
}
|
|
8683
|
-
|
|
8684
|
-
|
|
8684
|
+
}
|
|
8685
|
+
function receive(msgEvent) {
|
|
8686
|
+
return [...decodeMessages(new Uint8Array(msgEvent.data))];
|
|
8687
|
+
}
|
|
8685
8688
|
const TIME = {
|
|
8686
8689
|
RECONNECT: 5e3,
|
|
8687
8690
|
RECONNECT_RANDOMIZE: 5e3,
|
|
@@ -8920,8 +8923,8 @@ class OpenFeedConnection {
|
|
|
8920
8923
|
this.subscriptionRequests.delete(originalRequest.correlationId.toString());
|
|
8921
8924
|
}
|
|
8922
8925
|
}
|
|
8923
|
-
send = (msg) => {
|
|
8924
|
-
|
|
8926
|
+
send = (msg, correlationId) => {
|
|
8927
|
+
correlationId ??= CorrelationId.create();
|
|
8925
8928
|
const token = this.connectionToken;
|
|
8926
8929
|
const msg2 = {};
|
|
8927
8930
|
if (msg.exchangeRequest !== void 0) msg2.exchangeRequest = { ...msg.exchangeRequest, correlationId, token };
|
|
@@ -9000,7 +9003,7 @@ class OpenFeedConnection {
|
|
|
9000
9003
|
whenDisconnected = () => this.whenDisconnectedSource.whenCompleted;
|
|
9001
9004
|
dispose = () => this.disconnect(new ConnectionDisposedError("Disposed"));
|
|
9002
9005
|
}
|
|
9003
|
-
const version = "1.6.
|
|
9006
|
+
const version = "1.6.3";
|
|
9004
9007
|
const getClientVersion = async (clientId) => {
|
|
9005
9008
|
let platformDescription;
|
|
9006
9009
|
if (typeof window !== "undefined") {
|
package/dist/node.js
CHANGED
|
@@ -12354,22 +12354,25 @@ var CorrelationId = class {
|
|
|
12354
12354
|
var toT = (obj) => obj;
|
|
12355
12355
|
|
|
12356
12356
|
// src/utilities/communication.ts
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
}
|
|
12357
|
+
function encodeMessages(message) {
|
|
12358
|
+
return OpenfeedGatewayRequestEncode.encode(message).finish();
|
|
12359
|
+
}
|
|
12360
|
+
function send(socket, message) {
|
|
12361
|
+
socket.send(encodeMessages(toT(message)));
|
|
12362
|
+
}
|
|
12360
12363
|
var getShort = (a, b) => a << 8 | b << 0;
|
|
12361
|
-
|
|
12362
|
-
const array = new Uint8Array(msgEvent.data);
|
|
12364
|
+
function* decodeMessages(bytes) {
|
|
12363
12365
|
let currentIndex = 0;
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
const
|
|
12367
|
-
const currentArray = array.subarray(currentIndex + 2, currentIndex + shortVal);
|
|
12366
|
+
while (getShort(bytes[currentIndex], bytes[currentIndex + 1])) {
|
|
12367
|
+
const shortVal = getShort(bytes[currentIndex], bytes[currentIndex + 1]) + 2;
|
|
12368
|
+
const currentArray = bytes.subarray(currentIndex + 2, currentIndex + shortVal);
|
|
12368
12369
|
currentIndex += shortVal;
|
|
12369
|
-
|
|
12370
|
+
yield OpenfeedGatewayMessageDecode.decode(currentArray);
|
|
12370
12371
|
}
|
|
12371
|
-
|
|
12372
|
-
|
|
12372
|
+
}
|
|
12373
|
+
function receive(msgEvent) {
|
|
12374
|
+
return [...decodeMessages(new Uint8Array(msgEvent.data))];
|
|
12375
|
+
}
|
|
12373
12376
|
|
|
12374
12377
|
// src/utilities/constants.ts
|
|
12375
12378
|
var TIME = {
|
|
@@ -12618,8 +12621,8 @@ var OpenFeedConnection = class {
|
|
|
12618
12621
|
this.subscriptionRequests.delete(originalRequest.correlationId.toString());
|
|
12619
12622
|
}
|
|
12620
12623
|
}
|
|
12621
|
-
send = (msg) => {
|
|
12622
|
-
|
|
12624
|
+
send = (msg, correlationId) => {
|
|
12625
|
+
correlationId ??= CorrelationId.create();
|
|
12623
12626
|
const token = this.connectionToken;
|
|
12624
12627
|
const msg2 = {};
|
|
12625
12628
|
if (msg.exchangeRequest !== void 0) msg2.exchangeRequest = { ...msg.exchangeRequest, correlationId, token };
|
|
@@ -12703,7 +12706,7 @@ var OpenFeedConnection = class {
|
|
|
12703
12706
|
};
|
|
12704
12707
|
|
|
12705
12708
|
// generated/version.ts
|
|
12706
|
-
var version = "1.6.
|
|
12709
|
+
var version = "1.6.3";
|
|
12707
12710
|
|
|
12708
12711
|
// src/utilities/client_version.ts
|
|
12709
12712
|
var getClientVersion = async (clientId) => {
|
|
@@ -26,7 +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) => Long;
|
|
29
|
+
send: (msg: OpenfeedRequest, correlationId?: Long) => Long;
|
|
30
30
|
getExchanges: () => Promise<ExchangeResponse_Exchange[]>;
|
|
31
31
|
getInstrument: (request: OpenFeedInstrumentRequest) => Promise<InstrumentDefinition[]>;
|
|
32
32
|
getInstrumentReference: (request: OpenFeedInstrumentReferenceRequest) => Promise<InstrumentReferenceResponse>;
|
|
@@ -5,13 +5,13 @@ 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 ?
|
|
8
|
+
type OmitDistributive<T, K extends PropertyKey> = T extends any ? (T extends object ? Id<Omit<T, K>> : T) : never;
|
|
9
9
|
type Id<T> = {} & {
|
|
10
10
|
[P in keyof T]: T[P];
|
|
11
11
|
};
|
|
12
|
-
type OmitRecursively<T, K extends PropertyKey> =
|
|
12
|
+
type OmitRecursively<T, K extends PropertyKey> = {
|
|
13
13
|
[P in keyof T]: OmitDistributive<T[P], K>;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
export type OpenfeedRequest = OmitRecursively<Omit<OpenfeedGatewayRequest, "loginRequest" | "logoutRequest">, "correlationId" | "token">;
|
|
16
16
|
export interface IOpenFeedConnection {
|
|
17
17
|
subscribe: (service: Service, subscriptionType: SubscriptionType, snapshotIntervalSeconds: number, symbols: string[] | null, marketIds: Long[] | null, exchanges: string[] | null, channels: number[] | null) => Long;
|
|
@@ -20,7 +20,7 @@ export interface IOpenFeedConnection {
|
|
|
20
20
|
getExchanges: () => Promise<ExchangeResponse_Exchange[]>;
|
|
21
21
|
getInstrument: (request: OpenFeedInstrumentRequest) => Promise<InstrumentDefinition[]>;
|
|
22
22
|
getInstrumentReference: (request: OpenFeedInstrumentReferenceRequest) => Promise<InstrumentReferenceResponse>;
|
|
23
|
-
send(msg: OpenfeedRequest): Long;
|
|
23
|
+
send(msg: OpenfeedRequest, correlationId?: Long): Long;
|
|
24
24
|
}
|
|
25
25
|
export interface IOpenFeedClient {
|
|
26
26
|
get connection(): Promise<IOpenFeedConnection>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import WebSocket from "isomorphic-ws";
|
|
2
2
|
import { OptionalUndefined } from "@src/utilities/messages";
|
|
3
3
|
import type { OpenfeedGatewayMessage, OpenfeedGatewayRequest } from "@gen/openfeed_api";
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
4
|
+
export declare function encodeMessages(message: OpenfeedGatewayRequest): Uint8Array;
|
|
5
|
+
export declare function send(socket: WebSocket, message: OptionalUndefined<OpenfeedGatewayRequest>): void;
|
|
6
|
+
export declare function decodeMessages(bytes: Uint8Array): Iterable<OpenfeedGatewayMessage>;
|
|
7
|
+
export declare function receive(msgEvent: WebSocket.MessageEvent): OpenfeedGatewayMessage[];
|