@stream-io/feeds-client 0.2.4 → 0.2.5
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 +15 -0
- package/dist/index-react-bindings.browser.cjs +33 -18
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +33 -18
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +33 -18
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +33 -18
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +33 -18
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +33 -18
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +33 -18
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +33 -18
- package/dist/index.node.js.map +1 -1
- package/dist/src/common/real-time/StableWSConnection.d.ts +3 -3
- package/dist/src/common/real-time/event-models.d.ts +14 -0
- package/dist/src/feed/event-handlers/feed/handle-feed-updated.d.ts +2 -2
- package/dist/src/feeds-client/feeds-client.d.ts +3 -2
- package/dist/src/types.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/real-time/event-models.ts +16 -0
- package/src/feed/event-handlers/feed/handle-feed-updated.ts +2 -2
- package/src/feeds-client/feeds-client.ts +51 -20
- package/src/types.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.5](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.2.4...@stream-io/feeds-client-0.2.5) (2025-09-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
* add push code snippets to docs snippets tests ([#113](https://github.com/GetStream/stream-feeds-js/issues/113)) ([1f4f6ea](https://github.com/GetStream/stream-feeds-js/commit/1f4f6ead115d24e23bcde99e0dc20b3d85d696e3))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add unhandled error events ([#109](https://github.com/GetStream/stream-feeds-js/issues/109)) ([2ac0cf3](https://github.com/GetStream/stream-feeds-js/commit/2ac0cf3adfa963348cf5602b462bda39487ffcaa))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* update possibly stale feeds (`FeedsClient.queryFeeds`) ([#111](https://github.com/GetStream/stream-feeds-js/issues/111)) ([b1660e1](https://github.com/GetStream/stream-feeds-js/commit/b1660e1be4b24d01bb7cd26e11f27b2a46b746af))
|
|
19
|
+
|
|
5
20
|
## [0.2.4](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.2.3...@stream-io/feeds-client-0.2.4) (2025-09-04)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -5717,6 +5717,11 @@ function handleUserUpdated(event) {
|
|
|
5717
5717
|
});
|
|
5718
5718
|
}
|
|
5719
5719
|
|
|
5720
|
+
var UnhandledErrorType;
|
|
5721
|
+
(function (UnhandledErrorType) {
|
|
5722
|
+
UnhandledErrorType["ReconnectionReconciliation"] = "reconnection-reconciliation";
|
|
5723
|
+
})(UnhandledErrorType || (UnhandledErrorType = {}));
|
|
5724
|
+
|
|
5720
5725
|
class FeedsClient extends FeedsApi {
|
|
5721
5726
|
constructor(apiKey, options) {
|
|
5722
5727
|
const tokenManager = new TokenManager();
|
|
@@ -5726,6 +5731,22 @@ class FeedsClient extends FeedsApi {
|
|
|
5726
5731
|
this.eventDispatcher = new EventDispatcher();
|
|
5727
5732
|
this.activeFeeds = {};
|
|
5728
5733
|
this.healthyConnectionChangedEventCount = 0;
|
|
5734
|
+
this.recoverOnReconnect = async () => {
|
|
5735
|
+
this.healthyConnectionChangedEventCount++;
|
|
5736
|
+
// we skip the first event as we could potentially be querying twice
|
|
5737
|
+
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5738
|
+
const entries = Object.entries(this.activeFeeds);
|
|
5739
|
+
const results = await Promise.allSettled(entries.map(([, feed]) => feed.synchronize()));
|
|
5740
|
+
const failures = results.flatMap((result, index) => result.status === 'rejected'
|
|
5741
|
+
? [{ feed: entries[index][0], reason: result.reason }]
|
|
5742
|
+
: []);
|
|
5743
|
+
this.eventDispatcher.dispatch({
|
|
5744
|
+
type: 'errors.unhandled',
|
|
5745
|
+
error_type: UnhandledErrorType.ReconnectionReconciliation,
|
|
5746
|
+
failures,
|
|
5747
|
+
});
|
|
5748
|
+
}
|
|
5749
|
+
};
|
|
5729
5750
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
5730
5751
|
this.connectUser = async (user, tokenProvider) => {
|
|
5731
5752
|
if (this.state.getLatestValue().connected_user !== undefined ||
|
|
@@ -5821,18 +5842,18 @@ class FeedsClient extends FeedsApi {
|
|
|
5821
5842
|
};
|
|
5822
5843
|
this.getOrCreateActiveFeed = (group, id, data, watch) => {
|
|
5823
5844
|
const fid = `${group}:${id}`;
|
|
5824
|
-
if (this.activeFeeds[fid]) {
|
|
5825
|
-
|
|
5826
|
-
if (watch && !feed.currentState.watch) {
|
|
5827
|
-
handleWatchStarted.bind(feed)();
|
|
5828
|
-
}
|
|
5829
|
-
return feed;
|
|
5845
|
+
if (!this.activeFeeds[fid]) {
|
|
5846
|
+
this.activeFeeds[fid] = new Feed(this, group, id, data, watch);
|
|
5830
5847
|
}
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5848
|
+
const feed = this.activeFeeds[fid];
|
|
5849
|
+
if (!feed.currentState.watch) {
|
|
5850
|
+
// feed isn't watched and may be stale, update it
|
|
5851
|
+
if (data)
|
|
5852
|
+
handleFeedUpdated.call(feed, { feed: data });
|
|
5853
|
+
if (watch)
|
|
5854
|
+
handleWatchStarted.call(feed);
|
|
5835
5855
|
}
|
|
5856
|
+
return feed;
|
|
5836
5857
|
};
|
|
5837
5858
|
this.state = new StateStore({
|
|
5838
5859
|
connected_user: undefined,
|
|
@@ -5850,13 +5871,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5850
5871
|
const { online } = event;
|
|
5851
5872
|
this.state.partialNext({ is_ws_connection_healthy: online });
|
|
5852
5873
|
if (online) {
|
|
5853
|
-
this.
|
|
5854
|
-
// we skip the first event as we could potentially be querying twice
|
|
5855
|
-
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5856
|
-
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
5857
|
-
activeFeed.synchronize();
|
|
5858
|
-
}
|
|
5859
|
-
}
|
|
5874
|
+
this.recoverOnReconnect();
|
|
5860
5875
|
}
|
|
5861
5876
|
else {
|
|
5862
5877
|
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
@@ -5970,7 +5985,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5970
5985
|
}
|
|
5971
5986
|
async queryFeeds(request) {
|
|
5972
5987
|
const response = await this._queryFeeds(request);
|
|
5973
|
-
const feeds = response.feeds.map((
|
|
5988
|
+
const feeds = response.feeds.map((feedResponse) => this.getOrCreateActiveFeed(feedResponse.group_id, feedResponse.id, feedResponse, request?.watch));
|
|
5974
5989
|
return {
|
|
5975
5990
|
feeds,
|
|
5976
5991
|
next: response.next,
|