@stream-io/feeds-client 0.2.3 → 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 +27 -0
- package/dist/index-react-bindings.browser.cjs +36 -19
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +36 -19
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +36 -19
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +36 -19
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +35 -20
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +35 -20
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +35 -20
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +35 -20
- 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/common/search/FeedSearchSource.d.ts +2 -2
- 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/gen/models/index.d.ts +18 -8
- 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/common/search/BaseSearchSource.ts +1 -1
- package/src/common/search/FeedSearchSource.ts +3 -2
- package/src/feed/event-handlers/feed/handle-feed-updated.ts +2 -2
- package/src/feeds-client/feeds-client.ts +51 -20
- package/src/gen/models/index.ts +26 -8
- package/src/types.ts +5 -2
package/dist/index.browser.js
CHANGED
|
@@ -5730,6 +5730,11 @@ function handleUserUpdated(event) {
|
|
|
5730
5730
|
});
|
|
5731
5731
|
}
|
|
5732
5732
|
|
|
5733
|
+
var UnhandledErrorType;
|
|
5734
|
+
(function (UnhandledErrorType) {
|
|
5735
|
+
UnhandledErrorType["ReconnectionReconciliation"] = "reconnection-reconciliation";
|
|
5736
|
+
})(UnhandledErrorType || (UnhandledErrorType = {}));
|
|
5737
|
+
|
|
5733
5738
|
class FeedsClient extends FeedsApi {
|
|
5734
5739
|
constructor(apiKey, options) {
|
|
5735
5740
|
const tokenManager = new TokenManager();
|
|
@@ -5739,6 +5744,22 @@ class FeedsClient extends FeedsApi {
|
|
|
5739
5744
|
this.eventDispatcher = new EventDispatcher();
|
|
5740
5745
|
this.activeFeeds = {};
|
|
5741
5746
|
this.healthyConnectionChangedEventCount = 0;
|
|
5747
|
+
this.recoverOnReconnect = async () => {
|
|
5748
|
+
this.healthyConnectionChangedEventCount++;
|
|
5749
|
+
// we skip the first event as we could potentially be querying twice
|
|
5750
|
+
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5751
|
+
const entries = Object.entries(this.activeFeeds);
|
|
5752
|
+
const results = await Promise.allSettled(entries.map(([, feed]) => feed.synchronize()));
|
|
5753
|
+
const failures = results.flatMap((result, index) => result.status === 'rejected'
|
|
5754
|
+
? [{ feed: entries[index][0], reason: result.reason }]
|
|
5755
|
+
: []);
|
|
5756
|
+
this.eventDispatcher.dispatch({
|
|
5757
|
+
type: 'errors.unhandled',
|
|
5758
|
+
error_type: UnhandledErrorType.ReconnectionReconciliation,
|
|
5759
|
+
failures,
|
|
5760
|
+
});
|
|
5761
|
+
}
|
|
5762
|
+
};
|
|
5742
5763
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
5743
5764
|
this.connectUser = async (user, tokenProvider) => {
|
|
5744
5765
|
if (this.state.getLatestValue().connected_user !== undefined ||
|
|
@@ -5834,18 +5855,18 @@ class FeedsClient extends FeedsApi {
|
|
|
5834
5855
|
};
|
|
5835
5856
|
this.getOrCreateActiveFeed = (group, id, data, watch) => {
|
|
5836
5857
|
const fid = `${group}:${id}`;
|
|
5837
|
-
if (this.activeFeeds[fid]) {
|
|
5838
|
-
|
|
5839
|
-
if (watch && !feed.currentState.watch) {
|
|
5840
|
-
handleWatchStarted.bind(feed)();
|
|
5841
|
-
}
|
|
5842
|
-
return feed;
|
|
5858
|
+
if (!this.activeFeeds[fid]) {
|
|
5859
|
+
this.activeFeeds[fid] = new Feed(this, group, id, data, watch);
|
|
5843
5860
|
}
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5861
|
+
const feed = this.activeFeeds[fid];
|
|
5862
|
+
if (!feed.currentState.watch) {
|
|
5863
|
+
// feed isn't watched and may be stale, update it
|
|
5864
|
+
if (data)
|
|
5865
|
+
handleFeedUpdated.call(feed, { feed: data });
|
|
5866
|
+
if (watch)
|
|
5867
|
+
handleWatchStarted.call(feed);
|
|
5848
5868
|
}
|
|
5869
|
+
return feed;
|
|
5849
5870
|
};
|
|
5850
5871
|
this.state = new StateStore({
|
|
5851
5872
|
connected_user: undefined,
|
|
@@ -5863,13 +5884,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5863
5884
|
const { online } = event;
|
|
5864
5885
|
this.state.partialNext({ is_ws_connection_healthy: online });
|
|
5865
5886
|
if (online) {
|
|
5866
|
-
this.
|
|
5867
|
-
// we skip the first event as we could potentially be querying twice
|
|
5868
|
-
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5869
|
-
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
5870
|
-
activeFeed.synchronize();
|
|
5871
|
-
}
|
|
5872
|
-
}
|
|
5887
|
+
this.recoverOnReconnect();
|
|
5873
5888
|
}
|
|
5874
5889
|
else {
|
|
5875
5890
|
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
@@ -5983,7 +5998,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5983
5998
|
}
|
|
5984
5999
|
async queryFeeds(request) {
|
|
5985
6000
|
const response = await this._queryFeeds(request);
|
|
5986
|
-
const feeds = response.feeds.map((
|
|
6001
|
+
const feeds = response.feeds.map((feedResponse) => this.getOrCreateActiveFeed(feedResponse.group_id, feedResponse.id, feedResponse, request?.watch));
|
|
5987
6002
|
return {
|
|
5988
6003
|
feeds,
|
|
5989
6004
|
next: response.next,
|
|
@@ -6342,7 +6357,7 @@ class BaseSearchSourceBase {
|
|
|
6342
6357
|
updatePaginationStateFromQuery(result) {
|
|
6343
6358
|
const { items, next } = result;
|
|
6344
6359
|
const stateUpdate = {};
|
|
6345
|
-
if (
|
|
6360
|
+
if (Object.prototype.hasOwnProperty.call(result, 'next')) {
|
|
6346
6361
|
stateUpdate.next = next;
|
|
6347
6362
|
stateUpdate.hasNext = !!next;
|
|
6348
6363
|
}
|
|
@@ -6457,9 +6472,9 @@ class ActivitySearchSource extends BaseSearchSource {
|
|
|
6457
6472
|
class FeedSearchSource extends BaseSearchSource {
|
|
6458
6473
|
constructor(client, options) {
|
|
6459
6474
|
super(options);
|
|
6460
|
-
this.type = 'feed';
|
|
6461
6475
|
this.client = client;
|
|
6462
6476
|
this.feedGroupId = options?.groupId;
|
|
6477
|
+
this.type = `${this.feedGroupId}-feed`;
|
|
6463
6478
|
}
|
|
6464
6479
|
async query(searchQuery) {
|
|
6465
6480
|
const { connected_user: connectedUser } = this.client.state.getLatestValue();
|