@stream-io/feeds-client 0.3.13 → 0.3.15

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 (36) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/react-bindings.js +11 -5
  5. package/dist/cjs/react-bindings.js.map +1 -1
  6. package/dist/es/index.mjs +2 -2
  7. package/dist/es/index.mjs.map +1 -1
  8. package/dist/es/react-bindings.mjs +11 -5
  9. package/dist/es/react-bindings.mjs.map +1 -1
  10. package/dist/{feeds-client-B6dsdSNW.mjs → feeds-client-B00fi-i4.mjs} +44 -9
  11. package/dist/feeds-client-B00fi-i4.mjs.map +1 -0
  12. package/dist/{feeds-client-DaiBvVCs.js → feeds-client-DTDDoiJL.js} +44 -9
  13. package/dist/feeds-client-DTDDoiJL.js.map +1 -0
  14. package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts +3 -3
  15. package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -1
  16. package/dist/types/common/ApiClient.d.ts.map +1 -1
  17. package/dist/types/common/ConnectionIdManager.d.ts +3 -3
  18. package/dist/types/common/ConnectionIdManager.d.ts.map +1 -1
  19. package/dist/types/common/TokenManager.d.ts +3 -3
  20. package/dist/types/common/TokenManager.d.ts.map +1 -1
  21. package/dist/types/feeds-client/feeds-client.d.ts +5 -1
  22. package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
  23. package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -1
  24. package/dist/types/gen/models/index.d.ts +27 -0
  25. package/dist/types/gen/models/index.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/bindings/react/hooks/useCreateFeedsClient.ts +23 -12
  28. package/src/common/ApiClient.ts +4 -2
  29. package/src/common/ConnectionIdManager.ts +9 -7
  30. package/src/common/TokenManager.ts +19 -3
  31. package/src/common/real-time/StableWSConnection.ts +1 -1
  32. package/src/feeds-client/feeds-client.ts +22 -1
  33. package/src/gen/feeds/FeedsApi.ts +2 -0
  34. package/src/gen/models/index.ts +50 -0
  35. package/dist/feeds-client-B6dsdSNW.mjs.map +0 -1
  36. package/dist/feeds-client-DaiBvVCs.js.map +0 -1
@@ -2321,12 +2321,14 @@ class FeedsApi {
2321
2321
  feed_id: request?.feed_id
2322
2322
  };
2323
2323
  const body = {
2324
+ id_around: request?.id_around,
2324
2325
  limit: request?.limit,
2325
2326
  next: request?.next,
2326
2327
  prev: request?.prev,
2327
2328
  view: request?.view,
2328
2329
  watch: request?.watch,
2329
2330
  data: request?.data,
2331
+ enrichment_options: request?.enrichment_options,
2330
2332
  external_ranking: request?.external_ranking,
2331
2333
  filter: request?.filter,
2332
2334
  followers_pagination: request?.followers_pagination,
@@ -3215,8 +3217,15 @@ const capitalize = (s) => {
3215
3217
  };
3216
3218
  class TokenManager {
3217
3219
  constructor() {
3220
+ this._isAnonymous = false;
3218
3221
  this.logger = feedsLoggerSystem.getLogger("token-manager");
3219
3222
  this.setTokenOrProvider = (tokenOrProvider) => {
3223
+ if (tokenOrProvider === void 0) {
3224
+ this._isAnonymous = true;
3225
+ tokenOrProvider = "";
3226
+ } else {
3227
+ this._isAnonymous = false;
3228
+ }
3220
3229
  if (isFunction(tokenOrProvider)) {
3221
3230
  this.tokenProvider = tokenOrProvider;
3222
3231
  this.type = "provider";
@@ -3227,7 +3236,9 @@ class TokenManager {
3227
3236
  }
3228
3237
  };
3229
3238
  this.reset = () => {
3239
+ this._isAnonymous = false;
3230
3240
  this.token = void 0;
3241
+ this.tokenProvider = void 0;
3231
3242
  this.loadTokenPromise = null;
3232
3243
  };
3233
3244
  this.loadToken = () => {
@@ -3270,6 +3281,9 @@ class TokenManager {
3270
3281
  return this.loadTokenPromise;
3271
3282
  };
3272
3283
  this.getToken = () => {
3284
+ if (this._isAnonymous) {
3285
+ return "";
3286
+ }
3273
3287
  if (this.token) {
3274
3288
  return this.token;
3275
3289
  }
@@ -3286,6 +3300,9 @@ class TokenManager {
3286
3300
  this.loadTokenPromise = null;
3287
3301
  this.type = "static";
3288
3302
  }
3303
+ get isAnonymous() {
3304
+ return this._isAnonymous;
3305
+ }
3289
3306
  }
3290
3307
  class ConnectionIdManager {
3291
3308
  constructor() {
@@ -3297,10 +3314,12 @@ class ConnectionIdManager {
3297
3314
  };
3298
3315
  this.resetConnectionIdPromise = () => {
3299
3316
  this.connectionId = void 0;
3300
- this.loadConnectionIdPromise = new Promise((resolve, reject) => {
3301
- this.resolve = resolve;
3302
- this.reject = reject;
3303
- });
3317
+ this.loadConnectionIdPromise = new Promise(
3318
+ (resolve, reject) => {
3319
+ this.resolve = resolve;
3320
+ this.reject = reject;
3321
+ }
3322
+ );
3304
3323
  };
3305
3324
  this.resolveConnectionidPromise = (connectionId) => {
3306
3325
  this.connectionId = connectionId;
@@ -3402,7 +3421,7 @@ class StableWSConnection {
3402
3421
  return;
3403
3422
  }
3404
3423
  const token = await this.tokenManager.getToken();
3405
- if (!token) {
3424
+ if (!token && !this.tokenManager.isAnonymous) {
3406
3425
  logger.warn(`Token not set, can't connect authenticate`);
3407
3426
  return;
3408
3427
  }
@@ -3885,7 +3904,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3885
3904
  };
3886
3905
  return result;
3887
3906
  };
3888
- const version = "0.3.13";
3907
+ const version = "0.3.15";
3889
3908
  class ApiClient {
3890
3909
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3891
3910
  this.apiKey = apiKey;
@@ -3899,7 +3918,9 @@ class ApiClient {
3899
3918
  if (queryParams?.watch || queryParams?.presence || queryParams?.payload?.watch || queryParams?.payload?.presence || body?.watch || body?.presence) {
3900
3919
  this.logger.info("Getting connection_id for watch or presence request");
3901
3920
  const connectionId = await this.connectionIdManager.getConnectionId();
3902
- queryParams.connection_id = connectionId;
3921
+ if (connectionId) {
3922
+ queryParams.connection_id = connectionId;
3923
+ }
3903
3924
  }
3904
3925
  let requestUrl = url;
3905
3926
  if (pathParams) {
@@ -4047,7 +4068,7 @@ class ApiClient {
4047
4068
  }
4048
4069
  get commonHeaders() {
4049
4070
  return {
4050
- "stream-auth-type": "jwt",
4071
+ "stream-auth-type": this.tokenManager.isAnonymous ? "anonymous" : "jwt",
4051
4072
  "X-Stream-Client": this.generateStreamClientHeader()
4052
4073
  };
4053
4074
  }
@@ -7141,6 +7162,19 @@ class FeedsClient extends FeedsApi {
7141
7162
  }
7142
7163
  };
7143
7164
  this.pollFromState = (id) => this.polls_by_id.get(id);
7165
+ this.connectAnonymous = () => {
7166
+ this.connectionIdManager.resolveConnectionidPromise();
7167
+ this.tokenManager.setTokenOrProvider(void 0);
7168
+ this.setGetBatchOwnCapabilitiesThrottlingInterval(
7169
+ this.query_batch_own_capabilties_throttling_interval
7170
+ );
7171
+ this.state.partialNext({
7172
+ connected_user: void 0,
7173
+ is_anonymous: true,
7174
+ is_ws_connection_healthy: false
7175
+ });
7176
+ return Promise.resolve();
7177
+ };
7144
7178
  this.connectUser = async (user, tokenProvider) => {
7145
7179
  if (this.state.getLatestValue().connected_user !== void 0 || this.wsConnection) {
7146
7180
  throw new Error(`Can't connect a new user, call "disconnectUser" first`);
@@ -7375,6 +7409,7 @@ class FeedsClient extends FeedsApi {
7375
7409
  };
7376
7410
  this.state = new StateStore({
7377
7411
  connected_user: void 0,
7412
+ is_anonymous: false,
7378
7413
  is_ws_connection_healthy: false,
7379
7414
  own_capabilities_by_fid: {}
7380
7415
  });
@@ -7698,4 +7733,4 @@ export {
7698
7733
  shouldUpdateState as s,
7699
7734
  uniqueArrayMerge as u
7700
7735
  };
7701
- //# sourceMappingURL=feeds-client-B6dsdSNW.mjs.map
7736
+ //# sourceMappingURL=feeds-client-B00fi-i4.mjs.map