@stream-io/feeds-client 0.3.42 → 0.3.44
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 +14 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +1 -1
- package/dist/{feeds-client-BIM-XpQr.mjs → feeds-client-B7anS3xV.mjs} +55 -11
- package/dist/feeds-client-B7anS3xV.mjs.map +1 -0
- package/dist/{feeds-client-9wb2RHSS.js → feeds-client-DK7vuKlg.js} +55 -11
- package/dist/feeds-client-DK7vuKlg.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/types/common/real-time/event-models.d.ts +2 -2
- package/dist/types/common/real-time/event-models.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +10 -0
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/dist/types/utils/retry.d.ts +25 -0
- package/dist/types/utils/retry.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/common/real-time/event-models.ts +2 -2
- package/src/feed/feed.ts +2 -1
- package/src/feeds-client/feeds-client.ts +11 -8
- package/src/gen/feeds/FeedsApi.ts +9 -0
- package/src/gen/models/index.ts +20 -0
- package/src/utils/retry.ts +76 -0
- package/dist/feeds-client-9wb2RHSS.js.map +0 -1
- package/dist/feeds-client-BIM-XpQr.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useStateStore } from "@stream-io/state-store/react-bindings";
|
|
2
2
|
export * from "@stream-io/state-store/react-bindings";
|
|
3
3
|
import { useState, useEffect, createContext, useContext, useRef, useCallback, useMemo } from "react";
|
|
4
|
-
import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-
|
|
4
|
+
import { F as FeedsClient, g as isCommentResponse, c as checkHasAnotherPage } from "../feeds-client-B7anS3xV.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
const useCreateFeedsClient = ({
|
|
7
7
|
apiKey,
|
|
@@ -1693,6 +1693,7 @@ class FeedsApi {
|
|
|
1693
1693
|
const body = {
|
|
1694
1694
|
type: request?.type,
|
|
1695
1695
|
feeds: request?.feeds,
|
|
1696
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
1696
1697
|
create_notification_activity: request?.create_notification_activity,
|
|
1697
1698
|
expires_at: request?.expires_at,
|
|
1698
1699
|
id: request?.id,
|
|
@@ -1895,6 +1896,7 @@ class FeedsApi {
|
|
|
1895
1896
|
};
|
|
1896
1897
|
const body = {
|
|
1897
1898
|
type: request?.type,
|
|
1899
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
1898
1900
|
create_notification_activity: request?.create_notification_activity,
|
|
1899
1901
|
enforce_unique: request?.enforce_unique,
|
|
1900
1902
|
skip_push: request?.skip_push,
|
|
@@ -1975,6 +1977,7 @@ class FeedsApi {
|
|
|
1975
1977
|
id: request?.id
|
|
1976
1978
|
};
|
|
1977
1979
|
const body = {
|
|
1980
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
1978
1981
|
handle_mention_notifications: request?.handle_mention_notifications,
|
|
1979
1982
|
run_activity_processors: request?.run_activity_processors,
|
|
1980
1983
|
unset: request?.unset,
|
|
@@ -1996,6 +1999,7 @@ class FeedsApi {
|
|
|
1996
1999
|
id: request?.id
|
|
1997
2000
|
};
|
|
1998
2001
|
const body = {
|
|
2002
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
1999
2003
|
expires_at: request?.expires_at,
|
|
2000
2004
|
handle_mention_notifications: request?.handle_mention_notifications,
|
|
2001
2005
|
poll_id: request?.poll_id,
|
|
@@ -2175,6 +2179,7 @@ class FeedsApi {
|
|
|
2175
2179
|
async addComment(request) {
|
|
2176
2180
|
const body = {
|
|
2177
2181
|
comment: request?.comment,
|
|
2182
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
2178
2183
|
create_notification_activity: request?.create_notification_activity,
|
|
2179
2184
|
id: request?.id,
|
|
2180
2185
|
object_id: request?.object_id,
|
|
@@ -2257,6 +2262,7 @@ class FeedsApi {
|
|
|
2257
2262
|
};
|
|
2258
2263
|
const body = {
|
|
2259
2264
|
comment: request?.comment,
|
|
2265
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
2260
2266
|
handle_mention_notifications: request?.handle_mention_notifications,
|
|
2261
2267
|
skip_enrich_url: request?.skip_enrich_url,
|
|
2262
2268
|
skip_push: request?.skip_push,
|
|
@@ -2281,6 +2287,7 @@ class FeedsApi {
|
|
|
2281
2287
|
};
|
|
2282
2288
|
const body = {
|
|
2283
2289
|
type: request?.type,
|
|
2290
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
2284
2291
|
create_notification_activity: request?.create_notification_activity,
|
|
2285
2292
|
enforce_unique: request?.enforce_unique,
|
|
2286
2293
|
skip_push: request?.skip_push,
|
|
@@ -2656,6 +2663,7 @@ class FeedsApi {
|
|
|
2656
2663
|
const body = {
|
|
2657
2664
|
source: request?.source,
|
|
2658
2665
|
target: request?.target,
|
|
2666
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
2659
2667
|
create_notification_activity: request?.create_notification_activity,
|
|
2660
2668
|
follower_role: request?.follower_role,
|
|
2661
2669
|
push_preference: request?.push_preference,
|
|
@@ -2677,6 +2685,7 @@ class FeedsApi {
|
|
|
2677
2685
|
const body = {
|
|
2678
2686
|
source: request?.source,
|
|
2679
2687
|
target: request?.target,
|
|
2688
|
+
copy_custom_to_notification: request?.copy_custom_to_notification,
|
|
2680
2689
|
create_notification_activity: request?.create_notification_activity,
|
|
2681
2690
|
push_preference: request?.push_preference,
|
|
2682
2691
|
skip_push: request?.skip_push,
|
|
@@ -3999,7 +4008,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3999
4008
|
};
|
|
4000
4009
|
return result;
|
|
4001
4010
|
};
|
|
4002
|
-
const version = "0.3.
|
|
4011
|
+
const version = "0.3.44";
|
|
4003
4012
|
const axios = axiosImport.default ?? axiosImport;
|
|
4004
4013
|
class ApiClient {
|
|
4005
4014
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
@@ -6283,6 +6292,38 @@ function handleWatchStarted() {
|
|
|
6283
6292
|
function handleWatchStopped() {
|
|
6284
6293
|
this.state.partialNext({ watch: false });
|
|
6285
6294
|
}
|
|
6295
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
6296
|
+
function isRetryableError(error) {
|
|
6297
|
+
if (error instanceof StreamApiError) {
|
|
6298
|
+
const statusCode = error.metadata?.response_code;
|
|
6299
|
+
if (statusCode && statusCode >= 400 && statusCode < 500) {
|
|
6300
|
+
return false;
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6303
|
+
return true;
|
|
6304
|
+
}
|
|
6305
|
+
async function withRetry(fn, options = {}) {
|
|
6306
|
+
const { maxRetries = DEFAULT_MAX_RETRIES, shouldRetry } = options;
|
|
6307
|
+
let lastError;
|
|
6308
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
6309
|
+
try {
|
|
6310
|
+
return await fn();
|
|
6311
|
+
} catch (error) {
|
|
6312
|
+
lastError = error;
|
|
6313
|
+
const isLastAttempt = attempt === maxRetries;
|
|
6314
|
+
if (isLastAttempt) {
|
|
6315
|
+
throw error;
|
|
6316
|
+
}
|
|
6317
|
+
const shouldRetryResult = shouldRetry ? shouldRetry(error, attempt) : isRetryableError(error);
|
|
6318
|
+
if (!shouldRetryResult) {
|
|
6319
|
+
throw error;
|
|
6320
|
+
}
|
|
6321
|
+
const delay = retryInterval(attempt + 1);
|
|
6322
|
+
await sleep(delay);
|
|
6323
|
+
}
|
|
6324
|
+
}
|
|
6325
|
+
throw lastError;
|
|
6326
|
+
}
|
|
6286
6327
|
const isPin = (entity) => {
|
|
6287
6328
|
return "activity" in entity;
|
|
6288
6329
|
};
|
|
@@ -6550,7 +6591,7 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6550
6591
|
const { last_get_or_create_request_config } = this.state.getLatestValue();
|
|
6551
6592
|
if (last_get_or_create_request_config?.watch) {
|
|
6552
6593
|
this.inProgressGetOrCreate = void 0;
|
|
6553
|
-
await this.getOrCreate(last_get_or_create_request_config);
|
|
6594
|
+
await withRetry(() => this.getOrCreate(last_get_or_create_request_config));
|
|
6554
6595
|
}
|
|
6555
6596
|
}
|
|
6556
6597
|
async getOrCreate(request) {
|
|
@@ -7102,7 +7143,7 @@ function handleUserUpdated(event) {
|
|
|
7102
7143
|
}
|
|
7103
7144
|
var UnhandledErrorType = /* @__PURE__ */ ((UnhandledErrorType2) => {
|
|
7104
7145
|
UnhandledErrorType2["ReconnectionReconciliation"] = "reconnection-reconciliation";
|
|
7105
|
-
UnhandledErrorType2["
|
|
7146
|
+
UnhandledErrorType2["FetchingOwnFieldsOnNewActivity"] = "fetching-own-fields-on-new-activity";
|
|
7106
7147
|
return UnhandledErrorType2;
|
|
7107
7148
|
})(UnhandledErrorType || {});
|
|
7108
7149
|
function updateCommentCount({
|
|
@@ -7354,7 +7395,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7354
7395
|
}).catch((error) => {
|
|
7355
7396
|
this.eventDispatcher.dispatch({
|
|
7356
7397
|
type: "errors.unhandled",
|
|
7357
|
-
error_type: UnhandledErrorType.
|
|
7398
|
+
error_type: UnhandledErrorType.FetchingOwnFieldsOnNewActivity,
|
|
7358
7399
|
error
|
|
7359
7400
|
});
|
|
7360
7401
|
});
|
|
@@ -7382,11 +7423,13 @@ class FeedsClient extends FeedsApi {
|
|
|
7382
7423
|
const feed = feedEntries[index]?.[0] ?? (activity && getFeed.call(activity)?.feed);
|
|
7383
7424
|
return [{ feed, reason: result.reason, activity_id: activity?.id }];
|
|
7384
7425
|
});
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7426
|
+
if (failures.length > 0) {
|
|
7427
|
+
this.eventDispatcher.dispatch({
|
|
7428
|
+
type: "errors.unhandled",
|
|
7429
|
+
error_type: UnhandledErrorType.ReconnectionReconciliation,
|
|
7430
|
+
failures
|
|
7431
|
+
});
|
|
7432
|
+
}
|
|
7390
7433
|
}
|
|
7391
7434
|
};
|
|
7392
7435
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
@@ -7578,6 +7621,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7578
7621
|
this.polls_by_id.clear();
|
|
7579
7622
|
this.activeActivities = [];
|
|
7580
7623
|
this.activeFeeds = {};
|
|
7624
|
+
this.healthyConnectionChangedEventCount = 0;
|
|
7581
7625
|
this.state.partialNext(this.initialState);
|
|
7582
7626
|
this.cancelGetBatchOwnFieldsTimer();
|
|
7583
7627
|
clearQueuedFeeds();
|
|
@@ -7842,7 +7886,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7842
7886
|
};
|
|
7843
7887
|
}
|
|
7844
7888
|
async ownBatch(request) {
|
|
7845
|
-
const response = await super.ownBatch(request);
|
|
7889
|
+
const response = await withRetry(() => super.ownBatch(request));
|
|
7846
7890
|
Object.entries(response.data).forEach(([fid, ownFields]) => {
|
|
7847
7891
|
const feed = this.activeFeeds[fid];
|
|
7848
7892
|
if (feed) {
|
|
@@ -8025,4 +8069,4 @@ export {
|
|
|
8025
8069
|
shouldUpdateState as s,
|
|
8026
8070
|
uniqueArrayMerge as u
|
|
8027
8071
|
};
|
|
8028
|
-
//# sourceMappingURL=feeds-client-
|
|
8072
|
+
//# sourceMappingURL=feeds-client-B7anS3xV.mjs.map
|