@stream-io/feeds-client 0.2.4 → 0.2.6

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index-react-bindings.browser.cjs +48 -18
  3. package/dist/index-react-bindings.browser.cjs.map +1 -1
  4. package/dist/index-react-bindings.browser.js +48 -18
  5. package/dist/index-react-bindings.browser.js.map +1 -1
  6. package/dist/index-react-bindings.node.cjs +48 -18
  7. package/dist/index-react-bindings.node.cjs.map +1 -1
  8. package/dist/index-react-bindings.node.js +48 -18
  9. package/dist/index-react-bindings.node.js.map +1 -1
  10. package/dist/index.browser.cjs +48 -18
  11. package/dist/index.browser.cjs.map +1 -1
  12. package/dist/index.browser.js +48 -18
  13. package/dist/index.browser.js.map +1 -1
  14. package/dist/index.node.cjs +48 -18
  15. package/dist/index.node.cjs.map +1 -1
  16. package/dist/index.node.js +48 -18
  17. package/dist/index.node.js.map +1 -1
  18. package/dist/src/common/real-time/StableWSConnection.d.ts +3 -3
  19. package/dist/src/common/real-time/event-models.d.ts +14 -0
  20. package/dist/src/feed/event-handlers/feed/handle-feed-updated.d.ts +2 -2
  21. package/dist/src/feeds-client/feeds-client.d.ts +3 -2
  22. package/dist/src/gen/feeds/FeedsApi.d.ts +2 -1
  23. package/dist/src/gen/models/index.d.ts +32 -5
  24. package/dist/src/types.d.ts +2 -2
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +1 -1
  27. package/src/common/real-time/event-models.ts +16 -0
  28. package/src/feed/event-handlers/feed/handle-feed-updated.ts +2 -2
  29. package/src/feeds-client/feeds-client.ts +51 -20
  30. package/src/gen/feeds/FeedsApi.ts +26 -0
  31. package/src/gen/model-decoders/decoders.ts +7 -0
  32. package/src/gen/models/index.ts +52 -5
  33. package/src/types.ts +5 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.2.6](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.2.5...@stream-io/feeds-client-0.2.6) (2025-09-09)
6
+
7
+
8
+ * [FEEDS-708] regenerate client from spec ([#116](https://github.com/GetStream/stream-feeds-js/issues/116)) ([a7e7edd](https://github.com/GetStream/stream-feeds-js/commit/a7e7edde50d37445cc85b051e7a6236f2ee92955))
9
+
10
+ ## [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)
11
+
12
+
13
+ * 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))
14
+
15
+
16
+ ### Features
17
+
18
+ * add unhandled error events ([#109](https://github.com/GetStream/stream-feeds-js/issues/109)) ([2ac0cf3](https://github.com/GetStream/stream-feeds-js/commit/2ac0cf3adfa963348cf5602b462bda39487ffcaa))
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * 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))
24
+
5
25
  ## [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
26
 
7
27
 
@@ -1614,6 +1614,12 @@ decoders.UpsertConfigResponse = (input) => {
1614
1614
  };
1615
1615
  return decode(typeMappings, input);
1616
1616
  };
1617
+ decoders.UpsertPushPreferencesResponse = (input) => {
1618
+ const typeMappings = {
1619
+ user_preferences: { type: 'PushPreferences', isSingle: false },
1620
+ };
1621
+ return decode(typeMappings, input);
1622
+ };
1617
1623
  decoders.User = (input) => {
1618
1624
  const typeMappings = {
1619
1625
  ban_expires: { type: 'DatetimeType', isSingle: true },
@@ -1981,6 +1987,7 @@ class FeedsApi {
1981
1987
  text: request?.text,
1982
1988
  visibility: request?.visibility,
1983
1989
  attachments: request?.attachments,
1990
+ feeds: request?.feeds,
1984
1991
  filter_tags: request?.filter_tags,
1985
1992
  interest_tags: request?.interest_tags,
1986
1993
  custom: request?.custom,
@@ -2610,6 +2617,14 @@ class FeedsApi {
2610
2617
  decoders.PollVotesResponse?.(response.body);
2611
2618
  return { ...response.body, metadata: response.metadata };
2612
2619
  }
2620
+ async updatePushNotificationPreferences(request) {
2621
+ const body = {
2622
+ preferences: request?.preferences,
2623
+ };
2624
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/push_preferences', undefined, undefined, body, 'application/json');
2625
+ decoders.UpsertPushPreferencesResponse?.(response.body);
2626
+ return { ...response.body, metadata: response.metadata };
2627
+ }
2613
2628
  async deleteFile(request) {
2614
2629
  const queryParams = {
2615
2630
  url: request?.url,
@@ -5717,6 +5732,11 @@ function handleUserUpdated(event) {
5717
5732
  });
5718
5733
  }
5719
5734
 
5735
+ var UnhandledErrorType;
5736
+ (function (UnhandledErrorType) {
5737
+ UnhandledErrorType["ReconnectionReconciliation"] = "reconnection-reconciliation";
5738
+ })(UnhandledErrorType || (UnhandledErrorType = {}));
5739
+
5720
5740
  class FeedsClient extends FeedsApi {
5721
5741
  constructor(apiKey, options) {
5722
5742
  const tokenManager = new TokenManager();
@@ -5726,6 +5746,22 @@ class FeedsClient extends FeedsApi {
5726
5746
  this.eventDispatcher = new EventDispatcher();
5727
5747
  this.activeFeeds = {};
5728
5748
  this.healthyConnectionChangedEventCount = 0;
5749
+ this.recoverOnReconnect = async () => {
5750
+ this.healthyConnectionChangedEventCount++;
5751
+ // we skip the first event as we could potentially be querying twice
5752
+ if (this.healthyConnectionChangedEventCount > 1) {
5753
+ const entries = Object.entries(this.activeFeeds);
5754
+ const results = await Promise.allSettled(entries.map(([, feed]) => feed.synchronize()));
5755
+ const failures = results.flatMap((result, index) => result.status === 'rejected'
5756
+ ? [{ feed: entries[index][0], reason: result.reason }]
5757
+ : []);
5758
+ this.eventDispatcher.dispatch({
5759
+ type: 'errors.unhandled',
5760
+ error_type: UnhandledErrorType.ReconnectionReconciliation,
5761
+ failures,
5762
+ });
5763
+ }
5764
+ };
5729
5765
  this.pollFromState = (id) => this.polls_by_id.get(id);
5730
5766
  this.connectUser = async (user, tokenProvider) => {
5731
5767
  if (this.state.getLatestValue().connected_user !== undefined ||
@@ -5821,18 +5857,18 @@ class FeedsClient extends FeedsApi {
5821
5857
  };
5822
5858
  this.getOrCreateActiveFeed = (group, id, data, watch) => {
5823
5859
  const fid = `${group}:${id}`;
5824
- if (this.activeFeeds[fid]) {
5825
- const feed = this.activeFeeds[fid];
5826
- if (watch && !feed.currentState.watch) {
5827
- handleWatchStarted.bind(feed)();
5828
- }
5829
- return feed;
5860
+ if (!this.activeFeeds[fid]) {
5861
+ this.activeFeeds[fid] = new Feed(this, group, id, data, watch);
5830
5862
  }
5831
- else {
5832
- const feed = new Feed(this, group, id, data, watch);
5833
- this.activeFeeds[fid] = feed;
5834
- return feed;
5863
+ const feed = this.activeFeeds[fid];
5864
+ if (!feed.currentState.watch) {
5865
+ // feed isn't watched and may be stale, update it
5866
+ if (data)
5867
+ handleFeedUpdated.call(feed, { feed: data });
5868
+ if (watch)
5869
+ handleWatchStarted.call(feed);
5835
5870
  }
5871
+ return feed;
5836
5872
  };
5837
5873
  this.state = new StateStore({
5838
5874
  connected_user: undefined,
@@ -5850,13 +5886,7 @@ class FeedsClient extends FeedsApi {
5850
5886
  const { online } = event;
5851
5887
  this.state.partialNext({ is_ws_connection_healthy: online });
5852
5888
  if (online) {
5853
- this.healthyConnectionChangedEventCount++;
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
- }
5889
+ this.recoverOnReconnect();
5860
5890
  }
5861
5891
  else {
5862
5892
  for (const activeFeed of Object.values(this.activeFeeds)) {
@@ -5970,7 +6000,7 @@ class FeedsClient extends FeedsApi {
5970
6000
  }
5971
6001
  async queryFeeds(request) {
5972
6002
  const response = await this._queryFeeds(request);
5973
- const feeds = response.feeds.map((f) => this.getOrCreateActiveFeed(f.group_id, f.id, f, request?.watch));
6003
+ const feeds = response.feeds.map((feedResponse) => this.getOrCreateActiveFeed(feedResponse.group_id, feedResponse.id, feedResponse, request?.watch));
5974
6004
  return {
5975
6005
  feeds,
5976
6006
  next: response.next,