@openfeed/sdk-js 1.8.0 → 1.8.1

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.8.1](https://github.com/openfeed-org/sdk-js/compare/1.8.0...1.8.1) (2026-11-06)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * reject instrument lookups on error and pass responses to send ([944323d](https://github.com/openfeed-org/sdk-js/commit/944323df09255ff1bfc4eb03598d96f12053ee6d))
11
+
5
12
  ## [1.8.0](https://github.com/openfeed-org/sdk-js/compare/1.7.2...1.8.0) (2026-11-04)
6
13
 
7
14
 
@@ -1 +1 @@
1
- export declare const version = "1.8.0";
1
+ export declare const version = "1.8.1";
package/dist/index.js CHANGED
@@ -9841,6 +9841,20 @@ var InvalidCredentialsError = class extends Error {
9841
9841
  return this.constructor.name;
9842
9842
  }
9843
9843
  };
9844
+ /** An instrument lookup the server refused, or found nothing for. Code should decide on `result`. */
9845
+ var InstrumentLookupError = class extends Error {
9846
+ result;
9847
+ serverMessage;
9848
+ constructor(result, serverMessage) {
9849
+ const failure = `${Result[result] ?? String(result)}: the instrument lookup failed.`;
9850
+ super(serverMessage ? `${failure} Server said: "${serverMessage}"` : failure);
9851
+ this.result = result;
9852
+ this.serverMessage = serverMessage;
9853
+ }
9854
+ get name() {
9855
+ return this.constructor.name;
9856
+ }
9857
+ };
9844
9858
  var ConnectionDisposedError = class extends Error {
9845
9859
  get name() {
9846
9860
  return this.constructor.name;
@@ -9907,20 +9921,7 @@ var OpenFeedConnection = class {
9907
9921
  this.disconnect(new DuplicateLoginError("Duplicate login"));
9908
9922
  return false;
9909
9923
  }
9910
- if (message.instrumentResponse) {
9911
- const { correlationId, instrumentDefinition, numberOfDefinitions } = message.instrumentResponse;
9912
- const id = toStringOrNumber(correlationId);
9913
- const request = this.#instrumentRequests.get(id);
9914
- if (!request) throw new Error(`Instrument request ID ${String(id)} not found`);
9915
- if (!instrumentDefinition) throw new Error(`Instrument definition not found in response ID ${String(id)}`);
9916
- let definitions = this.#definitionsInFlight.get(id);
9917
- if (definitions) definitions.push(instrumentDefinition);
9918
- else definitions = [instrumentDefinition];
9919
- if (definitions.length === numberOfDefinitions) {
9920
- this.#definitionsInFlight.delete(id);
9921
- request.resolve(definitions);
9922
- } else this.#definitionsInFlight.set(id, definitions);
9923
- }
9924
+ if (message.instrumentResponse) this.settleInstrumentRequest(message.instrumentResponse);
9924
9925
  if (message.instrumentReferenceResponse) {
9925
9926
  const { correlationId } = message.instrumentReferenceResponse;
9926
9927
  this.#instrumentReferenceRequests.get(toStringOrNumber(correlationId))?.resolve(message.instrumentReferenceResponse);
@@ -9936,6 +9937,25 @@ var OpenFeedConnection = class {
9936
9937
  this.listeners.onMessage(message);
9937
9938
  return true;
9938
9939
  }
9940
+ /** Settles the lookup a response belongs to. One that isn't a lookup's, such as a request made through `send`, is only passed on. */
9941
+ settleInstrumentRequest({ correlationId, instrumentDefinition, numberOfDefinitions, status }) {
9942
+ const id = toStringOrNumber(correlationId);
9943
+ const request = this.#instrumentRequests.get(id);
9944
+ if (!request) return;
9945
+ if (instrumentDefinition) {
9946
+ let definitions = this.#definitionsInFlight.get(id);
9947
+ if (definitions) definitions.push(instrumentDefinition);
9948
+ else definitions = [instrumentDefinition];
9949
+ if (definitions.length === numberOfDefinitions) {
9950
+ this.#definitionsInFlight.delete(id);
9951
+ request.resolve(definitions);
9952
+ } else this.#definitionsInFlight.set(id, definitions);
9953
+ } else if (status?.result === Result.SUCCESS && numberOfDefinitions === 0) request.resolve([]);
9954
+ else {
9955
+ this.#definitionsInFlight.delete(id);
9956
+ request.reject(new InstrumentLookupError(status?.result ?? Result.UNKNOWN_RESULT, status?.message ?? ""));
9957
+ }
9958
+ }
9939
9959
  disconnect(error) {
9940
9960
  this.socket.onmessage = null;
9941
9961
  this.socket.onerror = null;
@@ -10127,7 +10147,7 @@ var OpenFeedConnection = class {
10127
10147
  };
10128
10148
  };
10129
10149
  // generated/version.ts
10130
- var version = "1.8.0";
10150
+ var version = "1.8.1";
10131
10151
  // src/utilities/client_version.ts
10132
10152
  var describeNodePlatform = async () => {
10133
10153
  const os = await import("./empty-D7pqD0vK.js");
@@ -10411,4 +10431,4 @@ var OpenFeedListeners = class {
10411
10431
  onMessageWithMetadata = noop;
10412
10432
  onHeartBeat = noop;
10413
10433
  };
10414
- export { ActionType, AdminMessage_Status, BookSide, CrossType, InstrumentDefinition_BookType, InstrumentDefinition_EventType, InstrumentDefinition_InstrumentType, InstrumentDefinition_OptionStyle, InstrumentDefinition_OptionType, InstrumentDefinition_PriceFormat_SubFormat, InstrumentDefinition_State, InstrumentTradingStatus, MarketSummary_ClearSet, MarketSummary_SummaryType, MarketWideStatus, OpenCloseSettlementFlag, OpenFeedClient, OpenFeedListeners, RegulationSHOShortSalePriceTest, Result, Service, SettlementSource, SettlementTerms, SnapshotRequestResult, SnapshotRequest_SnapshotRequestType, SubscriptionType, SymbolType, decodeMessages, decodeRequestMessage, encodeMessage, encodeResponseMessage };
10434
+ export { ActionType, AdminMessage_Status, BookSide, CrossType, InstrumentDefinition_BookType, InstrumentDefinition_EventType, InstrumentDefinition_InstrumentType, InstrumentDefinition_OptionStyle, InstrumentDefinition_OptionType, InstrumentDefinition_PriceFormat_SubFormat, InstrumentDefinition_State, InstrumentLookupError, InstrumentTradingStatus, MarketSummary_ClearSet, MarketSummary_SummaryType, MarketWideStatus, OpenCloseSettlementFlag, OpenFeedClient, OpenFeedListeners, RegulationSHOShortSalePriceTest, Result, Service, SettlementSource, SettlementTerms, SnapshotRequestResult, SnapshotRequest_SnapshotRequestType, SubscriptionType, SymbolType, decodeMessages, decodeRequestMessage, encodeMessage, encodeResponseMessage };
package/dist/node.js CHANGED
@@ -17159,6 +17159,20 @@ var InvalidCredentialsError = class extends Error {
17159
17159
  return this.constructor.name;
17160
17160
  }
17161
17161
  };
17162
+ var InstrumentLookupError = class extends Error {
17163
+ constructor(result, serverMessage) {
17164
+ const name = Result[result];
17165
+ const failure = `${name ?? String(result)}: the instrument lookup failed.`;
17166
+ super(serverMessage ? `${failure} Server said: "${serverMessage}"` : failure);
17167
+ this.result = result;
17168
+ this.serverMessage = serverMessage;
17169
+ }
17170
+ result;
17171
+ serverMessage;
17172
+ get name() {
17173
+ return this.constructor.name;
17174
+ }
17175
+ };
17162
17176
  var ConnectionDisposedError = class extends Error {
17163
17177
  get name() {
17164
17178
  return this.constructor.name;
@@ -17237,27 +17251,7 @@ var OpenFeedConnection = class {
17237
17251
  return false;
17238
17252
  }
17239
17253
  if (message.instrumentResponse) {
17240
- const { correlationId, instrumentDefinition, numberOfDefinitions } = message.instrumentResponse;
17241
- const id = toStringOrNumber(correlationId);
17242
- const request = this.#instrumentRequests.get(id);
17243
- if (!request) {
17244
- throw new Error(`Instrument request ID ${String(id)} not found`);
17245
- }
17246
- if (!instrumentDefinition) {
17247
- throw new Error(`Instrument definition not found in response ID ${String(id)}`);
17248
- }
17249
- let definitions = this.#definitionsInFlight.get(id);
17250
- if (definitions) {
17251
- definitions.push(instrumentDefinition);
17252
- } else {
17253
- definitions = [instrumentDefinition];
17254
- }
17255
- if (definitions.length === numberOfDefinitions) {
17256
- this.#definitionsInFlight.delete(id);
17257
- request.resolve(definitions);
17258
- } else {
17259
- this.#definitionsInFlight.set(id, definitions);
17260
- }
17254
+ this.settleInstrumentRequest(message.instrumentResponse);
17261
17255
  }
17262
17256
  if (message.instrumentReferenceResponse) {
17263
17257
  const { correlationId } = message.instrumentReferenceResponse;
@@ -17279,6 +17273,33 @@ var OpenFeedConnection = class {
17279
17273
  void this.listeners.onMessage(message);
17280
17274
  return true;
17281
17275
  }
17276
+ /** Settles the lookup a response belongs to. One that isn't a lookup's, such as a request made through `send`, is only passed on. */
17277
+ settleInstrumentRequest({ correlationId, instrumentDefinition, numberOfDefinitions, status }) {
17278
+ const id = toStringOrNumber(correlationId);
17279
+ const request = this.#instrumentRequests.get(id);
17280
+ if (!request) {
17281
+ return;
17282
+ }
17283
+ if (instrumentDefinition) {
17284
+ let definitions = this.#definitionsInFlight.get(id);
17285
+ if (definitions) {
17286
+ definitions.push(instrumentDefinition);
17287
+ } else {
17288
+ definitions = [instrumentDefinition];
17289
+ }
17290
+ if (definitions.length === numberOfDefinitions) {
17291
+ this.#definitionsInFlight.delete(id);
17292
+ request.resolve(definitions);
17293
+ } else {
17294
+ this.#definitionsInFlight.set(id, definitions);
17295
+ }
17296
+ } else if ((status == null ? void 0 : status.result) === 1 /* SUCCESS */ && numberOfDefinitions === 0) {
17297
+ request.resolve([]);
17298
+ } else {
17299
+ this.#definitionsInFlight.delete(id);
17300
+ request.reject(new InstrumentLookupError((status == null ? void 0 : status.result) ?? 0 /* UNKNOWN_RESULT */, (status == null ? void 0 : status.message) ?? ""));
17301
+ }
17302
+ }
17282
17303
  disconnect(error) {
17283
17304
  this.socket.onmessage = null;
17284
17305
  this.socket.onerror = null;
@@ -17483,7 +17504,7 @@ var OpenFeedConnection = class {
17483
17504
  };
17484
17505
 
17485
17506
  // generated/version.ts
17486
- var version = "1.8.0";
17507
+ var version = "1.8.1";
17487
17508
 
17488
17509
  // src/utilities/client_version.ts
17489
17510
  var describeNodePlatform = async () => {
@@ -17858,6 +17879,7 @@ export {
17858
17879
  InstrumentDefinition_OptionType,
17859
17880
  InstrumentDefinition_PriceFormat_SubFormat,
17860
17881
  InstrumentDefinition_State,
17882
+ InstrumentLookupError,
17861
17883
  InstrumentTradingStatus,
17862
17884
  MarketSummary_ClearSet,
17863
17885
  MarketSummary_SummaryType,
@@ -18,6 +18,8 @@ export declare class OpenFeedConnection implements IOpenFeedConnection {
18
18
  private onMessage;
19
19
  /** Returns false when the connection was closed, and the rest of the messages should be dropped */
20
20
  private handleMessage;
21
+ /** Settles the lookup a response belongs to. One that isn't a lookup's, such as a request made through `send`, is only passed on. */
22
+ private settleInstrumentRequest;
21
23
  private disconnect;
22
24
  private onError;
23
25
  private onClose;
@@ -1,9 +1,17 @@
1
+ import { Result } from '../../generated/openfeed_api.js';
1
2
  export declare class DuplicateLoginError extends Error {
2
3
  get name(): string;
3
4
  }
4
5
  export declare class InvalidCredentialsError extends Error {
5
6
  get name(): string;
6
7
  }
8
+ /** An instrument lookup the server refused, or found nothing for. Code should decide on `result`. */
9
+ export declare class InstrumentLookupError extends Error {
10
+ readonly result: Result;
11
+ readonly serverMessage: string;
12
+ constructor(result: Result, serverMessage: string);
13
+ get name(): string;
14
+ }
7
15
  export declare class ConnectionDisposedError extends Error {
8
16
  get name(): string;
9
17
  }
@@ -1,5 +1,6 @@
1
1
  export * from './connection/client.js';
2
2
  export * from './connection/interfaces.js';
3
3
  export * from './connection/listeners.js';
4
+ export { InstrumentLookupError } from './connection/errors.js';
4
5
  export * from '../generated/index.js';
5
6
  export { encodeMessage, decodeMessages, encodeResponseMessage, decodeRequestMessage } from './utilities/communication.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfeed/sdk-js",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "JavaScript SDK for Barchart OpenFeed",
5
5
  "main": "dist/node.js",
6
6
  "browser": "dist/index.js",