@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.
- package/CHANGELOG.md +20 -0
- package/dist/index-react-bindings.browser.cjs +48 -18
- package/dist/index-react-bindings.browser.cjs.map +1 -1
- package/dist/index-react-bindings.browser.js +48 -18
- package/dist/index-react-bindings.browser.js.map +1 -1
- package/dist/index-react-bindings.node.cjs +48 -18
- package/dist/index-react-bindings.node.cjs.map +1 -1
- package/dist/index-react-bindings.node.js +48 -18
- package/dist/index-react-bindings.node.js.map +1 -1
- package/dist/index.browser.cjs +48 -18
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +48 -18
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +48 -18
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +48 -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/gen/feeds/FeedsApi.d.ts +2 -1
- package/dist/src/gen/models/index.d.ts +32 -5
- 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/gen/feeds/FeedsApi.ts +26 -0
- package/src/gen/model-decoders/decoders.ts +7 -0
- package/src/gen/models/index.ts +52 -5
- package/src/types.ts +5 -2
package/dist/index.browser.js
CHANGED
|
@@ -1339,6 +1339,12 @@ decoders.UpsertConfigResponse = (input) => {
|
|
|
1339
1339
|
};
|
|
1340
1340
|
return decode(typeMappings, input);
|
|
1341
1341
|
};
|
|
1342
|
+
decoders.UpsertPushPreferencesResponse = (input) => {
|
|
1343
|
+
const typeMappings = {
|
|
1344
|
+
user_preferences: { type: 'PushPreferences', isSingle: false },
|
|
1345
|
+
};
|
|
1346
|
+
return decode(typeMappings, input);
|
|
1347
|
+
};
|
|
1342
1348
|
decoders.User = (input) => {
|
|
1343
1349
|
const typeMappings = {
|
|
1344
1350
|
ban_expires: { type: 'DatetimeType', isSingle: true },
|
|
@@ -1706,6 +1712,7 @@ class FeedsApi {
|
|
|
1706
1712
|
text: request?.text,
|
|
1707
1713
|
visibility: request?.visibility,
|
|
1708
1714
|
attachments: request?.attachments,
|
|
1715
|
+
feeds: request?.feeds,
|
|
1709
1716
|
filter_tags: request?.filter_tags,
|
|
1710
1717
|
interest_tags: request?.interest_tags,
|
|
1711
1718
|
custom: request?.custom,
|
|
@@ -2335,6 +2342,14 @@ class FeedsApi {
|
|
|
2335
2342
|
decoders.PollVotesResponse?.(response.body);
|
|
2336
2343
|
return { ...response.body, metadata: response.metadata };
|
|
2337
2344
|
}
|
|
2345
|
+
async updatePushNotificationPreferences(request) {
|
|
2346
|
+
const body = {
|
|
2347
|
+
preferences: request?.preferences,
|
|
2348
|
+
};
|
|
2349
|
+
const response = await this.apiClient.sendRequest('POST', '/api/v2/push_preferences', undefined, undefined, body, 'application/json');
|
|
2350
|
+
decoders.UpsertPushPreferencesResponse?.(response.body);
|
|
2351
|
+
return { ...response.body, metadata: response.metadata };
|
|
2352
|
+
}
|
|
2338
2353
|
async deleteFile(request) {
|
|
2339
2354
|
const queryParams = {
|
|
2340
2355
|
url: request?.url,
|
|
@@ -5730,6 +5745,11 @@ function handleUserUpdated(event) {
|
|
|
5730
5745
|
});
|
|
5731
5746
|
}
|
|
5732
5747
|
|
|
5748
|
+
var UnhandledErrorType;
|
|
5749
|
+
(function (UnhandledErrorType) {
|
|
5750
|
+
UnhandledErrorType["ReconnectionReconciliation"] = "reconnection-reconciliation";
|
|
5751
|
+
})(UnhandledErrorType || (UnhandledErrorType = {}));
|
|
5752
|
+
|
|
5733
5753
|
class FeedsClient extends FeedsApi {
|
|
5734
5754
|
constructor(apiKey, options) {
|
|
5735
5755
|
const tokenManager = new TokenManager();
|
|
@@ -5739,6 +5759,22 @@ class FeedsClient extends FeedsApi {
|
|
|
5739
5759
|
this.eventDispatcher = new EventDispatcher();
|
|
5740
5760
|
this.activeFeeds = {};
|
|
5741
5761
|
this.healthyConnectionChangedEventCount = 0;
|
|
5762
|
+
this.recoverOnReconnect = async () => {
|
|
5763
|
+
this.healthyConnectionChangedEventCount++;
|
|
5764
|
+
// we skip the first event as we could potentially be querying twice
|
|
5765
|
+
if (this.healthyConnectionChangedEventCount > 1) {
|
|
5766
|
+
const entries = Object.entries(this.activeFeeds);
|
|
5767
|
+
const results = await Promise.allSettled(entries.map(([, feed]) => feed.synchronize()));
|
|
5768
|
+
const failures = results.flatMap((result, index) => result.status === 'rejected'
|
|
5769
|
+
? [{ feed: entries[index][0], reason: result.reason }]
|
|
5770
|
+
: []);
|
|
5771
|
+
this.eventDispatcher.dispatch({
|
|
5772
|
+
type: 'errors.unhandled',
|
|
5773
|
+
error_type: UnhandledErrorType.ReconnectionReconciliation,
|
|
5774
|
+
failures,
|
|
5775
|
+
});
|
|
5776
|
+
}
|
|
5777
|
+
};
|
|
5742
5778
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
5743
5779
|
this.connectUser = async (user, tokenProvider) => {
|
|
5744
5780
|
if (this.state.getLatestValue().connected_user !== undefined ||
|
|
@@ -5834,18 +5870,18 @@ class FeedsClient extends FeedsApi {
|
|
|
5834
5870
|
};
|
|
5835
5871
|
this.getOrCreateActiveFeed = (group, id, data, watch) => {
|
|
5836
5872
|
const fid = `${group}:${id}`;
|
|
5837
|
-
if (this.activeFeeds[fid]) {
|
|
5838
|
-
|
|
5839
|
-
if (watch && !feed.currentState.watch) {
|
|
5840
|
-
handleWatchStarted.bind(feed)();
|
|
5841
|
-
}
|
|
5842
|
-
return feed;
|
|
5873
|
+
if (!this.activeFeeds[fid]) {
|
|
5874
|
+
this.activeFeeds[fid] = new Feed(this, group, id, data, watch);
|
|
5843
5875
|
}
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5876
|
+
const feed = this.activeFeeds[fid];
|
|
5877
|
+
if (!feed.currentState.watch) {
|
|
5878
|
+
// feed isn't watched and may be stale, update it
|
|
5879
|
+
if (data)
|
|
5880
|
+
handleFeedUpdated.call(feed, { feed: data });
|
|
5881
|
+
if (watch)
|
|
5882
|
+
handleWatchStarted.call(feed);
|
|
5848
5883
|
}
|
|
5884
|
+
return feed;
|
|
5849
5885
|
};
|
|
5850
5886
|
this.state = new StateStore({
|
|
5851
5887
|
connected_user: undefined,
|
|
@@ -5863,13 +5899,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5863
5899
|
const { online } = event;
|
|
5864
5900
|
this.state.partialNext({ is_ws_connection_healthy: online });
|
|
5865
5901
|
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
|
-
}
|
|
5902
|
+
this.recoverOnReconnect();
|
|
5873
5903
|
}
|
|
5874
5904
|
else {
|
|
5875
5905
|
for (const activeFeed of Object.values(this.activeFeeds)) {
|
|
@@ -5983,7 +6013,7 @@ class FeedsClient extends FeedsApi {
|
|
|
5983
6013
|
}
|
|
5984
6014
|
async queryFeeds(request) {
|
|
5985
6015
|
const response = await this._queryFeeds(request);
|
|
5986
|
-
const feeds = response.feeds.map((
|
|
6016
|
+
const feeds = response.feeds.map((feedResponse) => this.getOrCreateActiveFeed(feedResponse.group_id, feedResponse.id, feedResponse, request?.watch));
|
|
5987
6017
|
return {
|
|
5988
6018
|
feeds,
|
|
5989
6019
|
next: response.next,
|