@stream-io/feeds-client 0.3.41 → 0.3.43
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-KQeNaHO_.js → feeds-client-B1mzWjrM.js} +46 -11
- package/dist/feeds-client-B1mzWjrM.js.map +1 -0
- package/dist/{feeds-client-CCo39BpN.mjs → feeds-client-O3lXU8Bl.mjs} +46 -11
- package/dist/feeds-client-O3lXU8Bl.mjs.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/models/index.d.ts +8 -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/models/index.ts +14 -0
- package/src/utils/retry.ts +76 -0
- package/dist/feeds-client-CCo39BpN.mjs.map +0 -1
- package/dist/feeds-client-KQeNaHO_.js.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-O3lXU8Bl.mjs";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
const useCreateFeedsClient = ({
|
|
7
7
|
apiKey,
|
|
@@ -4017,7 +4017,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
4017
4017
|
};
|
|
4018
4018
|
return result;
|
|
4019
4019
|
};
|
|
4020
|
-
const version = "0.3.
|
|
4020
|
+
const version = "0.3.43";
|
|
4021
4021
|
const axios = axiosImport.default ?? axiosImport;
|
|
4022
4022
|
class ApiClient {
|
|
4023
4023
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
@@ -6301,6 +6301,38 @@ function handleWatchStarted() {
|
|
|
6301
6301
|
function handleWatchStopped() {
|
|
6302
6302
|
this.state.partialNext({ watch: false });
|
|
6303
6303
|
}
|
|
6304
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
6305
|
+
function isRetryableError(error) {
|
|
6306
|
+
if (error instanceof StreamApiError) {
|
|
6307
|
+
const statusCode = error.metadata?.response_code;
|
|
6308
|
+
if (statusCode && statusCode >= 400 && statusCode < 500) {
|
|
6309
|
+
return false;
|
|
6310
|
+
}
|
|
6311
|
+
}
|
|
6312
|
+
return true;
|
|
6313
|
+
}
|
|
6314
|
+
async function withRetry(fn, options = {}) {
|
|
6315
|
+
const { maxRetries = DEFAULT_MAX_RETRIES, shouldRetry } = options;
|
|
6316
|
+
let lastError;
|
|
6317
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
6318
|
+
try {
|
|
6319
|
+
return await fn();
|
|
6320
|
+
} catch (error) {
|
|
6321
|
+
lastError = error;
|
|
6322
|
+
const isLastAttempt = attempt === maxRetries;
|
|
6323
|
+
if (isLastAttempt) {
|
|
6324
|
+
throw error;
|
|
6325
|
+
}
|
|
6326
|
+
const shouldRetryResult = shouldRetry ? shouldRetry(error, attempt) : isRetryableError(error);
|
|
6327
|
+
if (!shouldRetryResult) {
|
|
6328
|
+
throw error;
|
|
6329
|
+
}
|
|
6330
|
+
const delay = retryInterval(attempt + 1);
|
|
6331
|
+
await sleep(delay);
|
|
6332
|
+
}
|
|
6333
|
+
}
|
|
6334
|
+
throw lastError;
|
|
6335
|
+
}
|
|
6304
6336
|
const isPin = (entity) => {
|
|
6305
6337
|
return "activity" in entity;
|
|
6306
6338
|
};
|
|
@@ -6568,7 +6600,7 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6568
6600
|
const { last_get_or_create_request_config } = this.state.getLatestValue();
|
|
6569
6601
|
if (last_get_or_create_request_config?.watch) {
|
|
6570
6602
|
this.inProgressGetOrCreate = void 0;
|
|
6571
|
-
await this.getOrCreate(last_get_or_create_request_config);
|
|
6603
|
+
await withRetry(() => this.getOrCreate(last_get_or_create_request_config));
|
|
6572
6604
|
}
|
|
6573
6605
|
}
|
|
6574
6606
|
async getOrCreate(request) {
|
|
@@ -7120,7 +7152,7 @@ function handleUserUpdated(event) {
|
|
|
7120
7152
|
}
|
|
7121
7153
|
var UnhandledErrorType = /* @__PURE__ */ ((UnhandledErrorType2) => {
|
|
7122
7154
|
UnhandledErrorType2["ReconnectionReconciliation"] = "reconnection-reconciliation";
|
|
7123
|
-
UnhandledErrorType2["
|
|
7155
|
+
UnhandledErrorType2["FetchingOwnFieldsOnNewActivity"] = "fetching-own-fields-on-new-activity";
|
|
7124
7156
|
return UnhandledErrorType2;
|
|
7125
7157
|
})(UnhandledErrorType || {});
|
|
7126
7158
|
function updateCommentCount({
|
|
@@ -7372,7 +7404,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7372
7404
|
}).catch((error) => {
|
|
7373
7405
|
this.eventDispatcher.dispatch({
|
|
7374
7406
|
type: "errors.unhandled",
|
|
7375
|
-
error_type: UnhandledErrorType.
|
|
7407
|
+
error_type: UnhandledErrorType.FetchingOwnFieldsOnNewActivity,
|
|
7376
7408
|
error
|
|
7377
7409
|
});
|
|
7378
7410
|
});
|
|
@@ -7400,11 +7432,13 @@ class FeedsClient extends FeedsApi {
|
|
|
7400
7432
|
const feed = feedEntries[index]?.[0] ?? (activity && getFeed.call(activity)?.feed);
|
|
7401
7433
|
return [{ feed, reason: result.reason, activity_id: activity?.id }];
|
|
7402
7434
|
});
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7435
|
+
if (failures.length > 0) {
|
|
7436
|
+
this.eventDispatcher.dispatch({
|
|
7437
|
+
type: "errors.unhandled",
|
|
7438
|
+
error_type: UnhandledErrorType.ReconnectionReconciliation,
|
|
7439
|
+
failures
|
|
7440
|
+
});
|
|
7441
|
+
}
|
|
7408
7442
|
}
|
|
7409
7443
|
};
|
|
7410
7444
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
@@ -7596,6 +7630,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7596
7630
|
this.polls_by_id.clear();
|
|
7597
7631
|
this.activeActivities = [];
|
|
7598
7632
|
this.activeFeeds = {};
|
|
7633
|
+
this.healthyConnectionChangedEventCount = 0;
|
|
7599
7634
|
this.state.partialNext(this.initialState);
|
|
7600
7635
|
this.cancelGetBatchOwnFieldsTimer();
|
|
7601
7636
|
clearQueuedFeeds();
|
|
@@ -7860,7 +7895,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7860
7895
|
};
|
|
7861
7896
|
}
|
|
7862
7897
|
async ownBatch(request) {
|
|
7863
|
-
const response = await super.ownBatch(request);
|
|
7898
|
+
const response = await withRetry(() => super.ownBatch(request));
|
|
7864
7899
|
Object.entries(response.data).forEach(([fid, ownFields]) => {
|
|
7865
7900
|
const feed = this.activeFeeds[fid];
|
|
7866
7901
|
if (feed) {
|
|
@@ -8041,4 +8076,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
|
|
|
8041
8076
|
exports.shouldUpdateState = shouldUpdateState;
|
|
8042
8077
|
exports.uniqueArrayMerge = uniqueArrayMerge;
|
|
8043
8078
|
exports.updateEntityInArray = updateEntityInArray;
|
|
8044
|
-
//# sourceMappingURL=feeds-client-
|
|
8079
|
+
//# sourceMappingURL=feeds-client-B1mzWjrM.js.map
|