@openfeed/sdk-js 1.7.2 → 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 +20 -0
- package/DOCUMENTATION.md +16 -14
- package/README.md +42 -13
- package/dist/empty-D7pqD0vK.js +3 -0
- package/dist/generated/index.d.ts +6 -6
- package/dist/generated/openfeed.d.ts +3 -3
- package/dist/generated/openfeed_api.d.ts +4 -4
- package/dist/generated/openfeed_instrument.d.ts +19 -2
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.js +10192 -12525
- package/dist/node.js +6867 -5629
- package/dist/src/connection/client.d.ts +5 -5
- package/dist/src/connection/connection.d.ts +12 -8
- package/dist/src/connection/errors.d.ts +8 -0
- package/dist/src/connection/interfaces.d.ts +9 -9
- package/dist/src/connection/listeners.d.ts +5 -5
- package/dist/src/index.d.ts +6 -5
- package/dist/src/utilities/communication.d.ts +9 -9
- package/dist/src/utilities/correlation_id.d.ts +4 -5
- package/package.json +47 -38
- package/tsconfig.json +4 -5
- package/dist/empty-BvAKRCY4.js +0 -4
- package/dist/scripts/process.d.ts +0 -1
- package/dist/src/test.d.ts +0 -1
- package/dist/test/client.test.d.ts +0 -1
- package/dist/test/connection.test.d.ts +0 -1
- package/dist/test/listeners.test.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,4 +2,24 @@
|
|
|
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
|
+
|
|
12
|
+
## [1.8.0](https://github.com/openfeed-org/sdk-js/compare/1.7.2...1.8.0) (2026-11-04)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* regenerate from proto files ([0621672](https://github.com/openfeed-org/sdk-js/commit/0621672dcf301e0282c1ba0f1ac66fe8675c4300))
|
|
18
|
+
* support nodenext module resolution and fix type exports ([6329d85](https://github.com/openfeed-org/sdk-js/commit/6329d85ef327298c18cc303b379f16de316e0b8d))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* clean the correct map in connection ([75c645a](https://github.com/openfeed-org/sdk-js/commit/75c645a694c6bfec8f1e4bbcc91b89afc0d1c6dd))
|
|
24
|
+
|
|
5
25
|
### [1.7.2](https://github.com/openfeed-org/sdk-js/compare/1.7.0...1.7.2) (2026-06-17)
|
package/DOCUMENTATION.md
CHANGED
|
@@ -4,25 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
There are only two objects that you will need in order to work with OpenFeed: a connection client (represented by the `IOpenFeedClient` interface) and a listener.
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The connection client object will connect to the OpenFeed servers and maintain that connection until disposed. It can be used to send requests to subscribe to symbols and exchanges.
|
|
8
8
|
|
|
9
|
-
The listener object (represented by the `OpenFeedListeners` class) contains
|
|
9
|
+
The listener object (represented by the `OpenFeedListeners` class) contains callback delegates that you can wire to your own callback functions in order to process messages coming from the connection.
|
|
10
10
|
|
|
11
11
|
## The Listeners
|
|
12
12
|
|
|
13
|
-
The listener object, represented by the `OpenFeedListeners` class is dead-simple, just
|
|
13
|
+
The listener object, represented by the `OpenFeedListeners` class is dead-simple, just a few variables, that point to functions that handle the connected, disconnected, credentials rejected, heartbeat and new message events sent from the connection client.
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
class OpenFeedListeners {
|
|
17
17
|
public onConnected: (connection: IOpenFeedConnection) => void | Promise<void> = () => {};
|
|
18
18
|
public onCredentialsRejected: () => void | Promise<void> = () => {};
|
|
19
19
|
public onDisconnected: () => void | Promise<void> = () => {};
|
|
20
|
-
public onMessage: (message: OpenfeedGatewayMessage) => void | Promise<void
|
|
20
|
+
public onMessage: (message: OpenfeedGatewayMessage) => void | Promise<void>;
|
|
21
21
|
public onMessageWithMetadata: (
|
|
22
22
|
message: OpenfeedGatewayMessage,
|
|
23
23
|
symbolNames: string[],
|
|
24
24
|
instrument?: InstrumentDefinition
|
|
25
25
|
) => void | Promise<void> = () => {};
|
|
26
|
+
public onHeartBeat: (heartBeat: HeartBeat) => void | Promise<void> = () => {};
|
|
27
|
+
public onCleanup: () => void | Promise<void>;
|
|
26
28
|
}
|
|
27
29
|
```
|
|
28
30
|
|
|
@@ -53,7 +55,9 @@ The `onMessageWithMetadata` callback will be called when a new message is receiv
|
|
|
53
55
|
|
|
54
56
|
The last callback we wired is `onCredentialsRejected`, which will be called if you attempt to connect with wrong credentials or there was a second login with the same credentials. This is a terminal state - if you receive this callbacks no other callbacks will be called and no other connection attempts will be made. The only sensible thing to do in this case is to dispose the connection client object and then create a new one with the correct credentials.
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
Two callbacks aren't wired in the example. `onHeartBeat` is called with each heartbeat the server sends, if you want to track that the connection is alive. `onCleanup` is used internally to clear the instrument definitions and symbol names kept for `onMessageWithMetadata` when the connection drops, so leave it as it is.
|
|
59
|
+
|
|
60
|
+
It is OK not to implement all these callbacks as they all have an existing default implementation.
|
|
57
61
|
|
|
58
62
|
### Asynchronous Handlers
|
|
59
63
|
|
|
@@ -75,21 +79,23 @@ listeners.onMessage = async (msg) => {
|
|
|
75
79
|
|
|
76
80
|
## Connection Client
|
|
77
81
|
|
|
78
|
-
The connection client is represented by the `
|
|
82
|
+
The connection client is represented by the `IOpenFeedClient` interface:
|
|
79
83
|
|
|
80
84
|
```ts
|
|
81
85
|
interface IOpenFeedClient {
|
|
82
|
-
get connection(): Promise<
|
|
86
|
+
get connection(): Promise<IOpenFeedConnection>;
|
|
83
87
|
|
|
84
88
|
subscribe: (
|
|
85
89
|
service: Service,
|
|
86
90
|
subscriptionType: SubscriptionType,
|
|
91
|
+
snapshotIntervalSeconds: number,
|
|
87
92
|
symbols: string[] | null,
|
|
88
93
|
marketIds: Long[] | null,
|
|
89
94
|
exchanges: string[] | null,
|
|
90
95
|
channels: number[] | null
|
|
91
96
|
) => Long;
|
|
92
97
|
unsubscribe: (subscriptionId: Long) => void;
|
|
98
|
+
dispose: () => void;
|
|
93
99
|
}
|
|
94
100
|
```
|
|
95
101
|
|
|
@@ -150,6 +156,7 @@ enum SubscriptionType {
|
|
|
150
156
|
CUMULATIVE_VOLUME = 6,
|
|
151
157
|
OHLC = 7,
|
|
152
158
|
OHLC_NON_REGULAR = 8,
|
|
159
|
+
SETTLEMENT = 9,
|
|
153
160
|
}
|
|
154
161
|
```
|
|
155
162
|
|
|
@@ -158,12 +165,7 @@ enum SubscriptionType {
|
|
|
158
165
|
Now that we know how to use the listener and client objects, let's put together a little demo that subscribes to all MSFT messages and prints what's happening to the console:
|
|
159
166
|
|
|
160
167
|
```ts
|
|
161
|
-
import { OpenFeedClient } from "
|
|
162
|
-
|
|
163
|
-
import { Service } from "../generated/openfeed";
|
|
164
|
-
import { SubscriptionType } from "../generated/openfeed_api";
|
|
165
|
-
import { OpenFeedListeners } from "./connection/listeners";
|
|
166
|
-
import { IOpenFeedLogger } from "./connection/interfaces";
|
|
168
|
+
import { OpenFeedClient, OpenFeedListeners, Service, SubscriptionType, type IOpenFeedLogger } from "@openfeed/sdk-js";
|
|
167
169
|
|
|
168
170
|
const connect = async () => {
|
|
169
171
|
const logger: IOpenFeedLogger = console;
|
|
@@ -208,7 +210,7 @@ const connect = async () => {
|
|
|
208
210
|
connect();
|
|
209
211
|
```
|
|
210
212
|
|
|
211
|
-
This program is a simple amalgamation of what we learned before. We first set up a listener and connect the callbacks that simply print everything that's happening to the console. We update the username and password with our credentials, and then finally we create a client,
|
|
213
|
+
This program is a simple amalgamation of what we learned before. We first set up a listener and connect the callbacks that simply print everything that's happening to the console. We update the username and password with our credentials, and then finally we create a client, subscribe to all messages for the symbol MSFT, and dispose of the client after we have unsubscribed from the symbol feed.
|
|
212
214
|
|
|
213
215
|
## More Information
|
|
214
216
|
|
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ Using yarn:
|
|
|
16
16
|
yarn add @openfeed/sdk-js
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
If you use TypeScript, enable `esModuleInterop` in your `tsconfig.json`. The SDK's types import `long` with a default import, and without it 64-bit fields like `marketId` lose their `Long` type.
|
|
20
|
+
|
|
19
21
|
## User Guide
|
|
20
22
|
|
|
21
23
|
The User Guide for this project can be found in the [documentation](DOCUMENTATION.md) page.
|
|
@@ -24,29 +26,56 @@ The User Guide for this project can be found in the [documentation](DOCUMENTATIO
|
|
|
24
26
|
|
|
25
27
|
This library uses [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for clarity, tracking changes and versioning. It's recommended to install [Conventional Commits Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits) when contributing to the library.
|
|
26
28
|
|
|
27
|
-
###
|
|
29
|
+
### Setup
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
yarn
|
|
33
|
+
yarn generate:version
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`generate:version` writes `generated/version.ts`, which isn't committed. The tests, the linter and the type checker all need it, so run it once after cloning (the build scripts run it themselves).
|
|
37
|
+
|
|
38
|
+
### Checks
|
|
39
|
+
|
|
40
|
+
| Command | What it does |
|
|
41
|
+
| -------------------- | ----------------------------------------------- |
|
|
42
|
+
| `yarn test` | Runs the tests (Vitest) |
|
|
43
|
+
| `yarn lint` | Lints the project (ESLint) |
|
|
44
|
+
| `yarn format` | Formats the project (Prettier) |
|
|
45
|
+
| `yarn format:check` | Checks the formatting without changing anything |
|
|
46
|
+
| `yarn check:package` | Checks the built package with publint and attw |
|
|
47
|
+
| `yarn check:esm` | Imports the built package from Node as ESM |
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
`check:package` and `check:esm` need a build first. CI runs all of these on every branch, and the package checks again before publishing.
|
|
50
|
+
|
|
51
|
+
### Building
|
|
30
52
|
|
|
31
53
|
```shell
|
|
32
|
-
yarn
|
|
54
|
+
yarn build:ts # browser bundle and type declarations
|
|
55
|
+
yarn build:node # Node bundle
|
|
33
56
|
```
|
|
34
57
|
|
|
35
|
-
|
|
58
|
+
Both write to `dist`. Run `build:ts` first, as it clears `dist` before building.
|
|
59
|
+
|
|
60
|
+
### Updating the proto files
|
|
36
61
|
|
|
37
|
-
|
|
62
|
+
The generated code in `generated/` comes from the [openfeed-org/proto](https://github.com/openfeed-org/proto) repository, which is installed over SSH, so you need SSH access to it. You also need `protoc` on your `PATH`: download it from the [protobuf releases](https://github.com/protocolbuffers/protobuf/releases), or on macOS run `brew install protobuf`.
|
|
38
63
|
|
|
39
|
-
|
|
64
|
+
Then run:
|
|
40
65
|
|
|
41
66
|
```shell
|
|
42
|
-
yarn
|
|
43
|
-
git push --follow-tags origin master
|
|
67
|
+
yarn generate
|
|
44
68
|
```
|
|
45
69
|
|
|
46
|
-
|
|
70
|
+
This pulls the latest proto files, generates the TypeScript code with `ts-proto`, and post-processes it (splitting encoders from decoders to keep the bundle small, and writing `generated/index.ts`). Commit the changes to `generated/` and `yarn.lock`.
|
|
71
|
+
|
|
72
|
+
### Releasing
|
|
73
|
+
|
|
74
|
+
Releases are made by [release-please](https://github.com/googleapis/release-please), from the conventional commits on `master`:
|
|
47
75
|
|
|
48
|
-
|
|
76
|
+
1. Every push to `master` opens or updates a release PR, with the next version and its `CHANGELOG.md` entries.
|
|
77
|
+
2. Merging the release PR tags the version and creates the GitHub release.
|
|
78
|
+
3. The same workflow builds and checks that version, then stages it on npm.
|
|
79
|
+
4. A maintainer approves the staged version on npmjs.com (or with `npm stage approve`) with 2FA, which makes it public.
|
|
49
80
|
|
|
50
|
-
|
|
51
|
-
2. Put the protoc.exe in the root folder of the project
|
|
52
|
-
3. Run the following command: `yarn generate`
|
|
81
|
+
`feat` commits bump the minor version, `fix` and `perf` the patch, and a `!` or a `BREAKING CHANGE:` footer the major. Commits of other types (`build`, `chore`, `ci`, `docs`, `refactor`, `style`, `test`) don't trigger a release or appear in the changelog. Release notes from before release-please are in [`.releases/`](.releases/).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Result, SubscriptionType, SymbolType } from
|
|
2
|
-
export type * from
|
|
3
|
-
export { BookSide, InstrumentTradingStatus, RegulationSHOShortSalePriceTest, SettlementTerms, CrossType, OpenCloseSettlementFlag, SettlementSource, Service, MarketWideStatus, SnapshotRequestResult, ActionType, AdminMessage_Status, MarketSummary_ClearSet, MarketSummary_SummaryType, SnapshotRequest_SnapshotRequestType } from
|
|
4
|
-
export type * from
|
|
5
|
-
export { InstrumentDefinition_InstrumentType, InstrumentDefinition_BookType, InstrumentDefinition_OptionType, InstrumentDefinition_OptionStyle, InstrumentDefinition_State, InstrumentDefinition_EventType, InstrumentDefinition_PriceFormat_SubFormat } from
|
|
6
|
-
export type * from
|
|
1
|
+
export { Result, SubscriptionType, SymbolType } from './openfeed_api.js';
|
|
2
|
+
export type * from './openfeed_api.js';
|
|
3
|
+
export { BookSide, InstrumentTradingStatus, RegulationSHOShortSalePriceTest, SettlementTerms, CrossType, OpenCloseSettlementFlag, SettlementSource, Service, MarketWideStatus, SnapshotRequestResult, ActionType, AdminMessage_Status, MarketSummary_ClearSet, MarketSummary_SummaryType, SnapshotRequest_SnapshotRequestType } from './openfeed.js';
|
|
4
|
+
export type * from './openfeed.js';
|
|
5
|
+
export { InstrumentDefinition_InstrumentType, InstrumentDefinition_BookType, InstrumentDefinition_OptionType, InstrumentDefinition_OptionStyle, InstrumentDefinition_State, InstrumentDefinition_EventType, InstrumentDefinition_PriceFormat_SubFormat } from './openfeed_instrument.js';
|
|
6
|
+
export type * from './openfeed_instrument.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from
|
|
2
|
-
import Long from
|
|
3
|
-
import { InstrumentDefinition } from
|
|
1
|
+
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import { default as Long } from 'long';
|
|
3
|
+
import { InstrumentDefinition } from './openfeed_instrument.js';
|
|
4
4
|
/** / Book side */
|
|
5
5
|
export declare enum BookSide {
|
|
6
6
|
UNKNOWN_BOOK_SIDE = 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from
|
|
2
|
-
import Long from
|
|
3
|
-
import { HeartBeat, InstrumentAction, MarketSnapshot, MarketStatus, MarketUpdate, Ohlc, Service, VolumeAtPrice } from
|
|
4
|
-
import { InstrumentDefinition, InstrumentDefinition_InstrumentType } from
|
|
1
|
+
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import { default as Long } from 'long';
|
|
3
|
+
import { HeartBeat, InstrumentAction, MarketSnapshot, MarketStatus, MarketUpdate, Ohlc, Service, VolumeAtPrice } from './openfeed.js';
|
|
4
|
+
import { InstrumentDefinition, InstrumentDefinition_InstrumentType } from './openfeed_instrument.js';
|
|
5
5
|
export declare enum Result {
|
|
6
6
|
UNKNOWN_RESULT = 0,
|
|
7
7
|
SUCCESS = 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from
|
|
2
|
-
import Long from
|
|
1
|
+
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import { default as Long } from 'long';
|
|
3
3
|
export interface InstrumentDefinition {
|
|
4
4
|
/** / Unique ID used in the data feed. */
|
|
5
5
|
marketId: Long;
|
|
@@ -158,6 +158,7 @@ export interface InstrumentDefinition {
|
|
|
158
158
|
quantityFractionalDenominator: number;
|
|
159
159
|
/** / Divide fractional volumes by this value to get real volumes */
|
|
160
160
|
volumeFractionalDenominator: number;
|
|
161
|
+
contractMetadata: InstrumentDefinition_ContractMetadata | undefined;
|
|
161
162
|
}
|
|
162
163
|
/** ############################################# */
|
|
163
164
|
export declare enum InstrumentDefinition_InstrumentType {
|
|
@@ -311,6 +312,17 @@ export interface InstrumentDefinition_ExchangeMetadata {
|
|
|
311
312
|
securitySymbol: string;
|
|
312
313
|
underlyingSymbol: string;
|
|
313
314
|
}
|
|
315
|
+
/** / Contract Metadata */
|
|
316
|
+
export interface InstrumentDefinition_ContractMetadata {
|
|
317
|
+
productCategory: string;
|
|
318
|
+
marketCode: string;
|
|
319
|
+
name: string;
|
|
320
|
+
term: string;
|
|
321
|
+
beginDate: number;
|
|
322
|
+
endDate: number;
|
|
323
|
+
deliveryPeriod: string;
|
|
324
|
+
priceType: string;
|
|
325
|
+
}
|
|
314
326
|
export declare const InstrumentDefinitionEncode: {
|
|
315
327
|
encode(message: InstrumentDefinition, writer?: BinaryWriter): BinaryWriter;
|
|
316
328
|
}, InstrumentDefinitionDecode: {
|
|
@@ -366,3 +378,8 @@ export declare const InstrumentDefinition_ExchangeMetadataEncode: {
|
|
|
366
378
|
}, InstrumentDefinition_ExchangeMetadataDecode: {
|
|
367
379
|
decode(input: BinaryReader | Uint8Array, length?: number): InstrumentDefinition_ExchangeMetadata;
|
|
368
380
|
};
|
|
381
|
+
export declare const InstrumentDefinition_ContractMetadataEncode: {
|
|
382
|
+
encode(message: InstrumentDefinition_ContractMetadata, writer?: BinaryWriter): BinaryWriter;
|
|
383
|
+
}, InstrumentDefinition_ContractMetadataDecode: {
|
|
384
|
+
decode(input: BinaryReader | Uint8Array, length?: number): InstrumentDefinition_ContractMetadata;
|
|
385
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.8.1";
|