@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
@@ -2339,12 +2339,14 @@ class FeedsApi {
2339
2339
  feed_id: request?.feed_id
2340
2340
  };
2341
2341
  const body = {
2342
+ id_around: request?.id_around,
2342
2343
  limit: request?.limit,
2343
2344
  next: request?.next,
2344
2345
  prev: request?.prev,
2345
2346
  view: request?.view,
2346
2347
  watch: request?.watch,
2347
2348
  data: request?.data,
2349
+ enrichment_options: request?.enrichment_options,
2348
2350
  external_ranking: request?.external_ranking,
2349
2351
  filter: request?.filter,
2350
2352
  followers_pagination: request?.followers_pagination,
@@ -3233,8 +3235,15 @@ const capitalize = (s) => {
3233
3235
  };
3234
3236
  class TokenManager {
3235
3237
  constructor() {
3238
+ this._isAnonymous = false;
3236
3239
  this.logger = feedsLoggerSystem.getLogger("token-manager");
3237
3240
  this.setTokenOrProvider = (tokenOrProvider) => {
3241
+ if (tokenOrProvider === void 0) {
3242
+ this._isAnonymous = true;
3243
+ tokenOrProvider = "";
3244
+ } else {
3245
+ this._isAnonymous = false;
3246
+ }
3238
3247
  if (isFunction(tokenOrProvider)) {
3239
3248
  this.tokenProvider = tokenOrProvider;
3240
3249
  this.type = "provider";
@@ -3245,7 +3254,9 @@ class TokenManager {
3245
3254
  }
3246
3255
  };
3247
3256
  this.reset = () => {
3257
+ this._isAnonymous = false;
3248
3258
  this.token = void 0;
3259
+ this.tokenProvider = void 0;
3249
3260
  this.loadTokenPromise = null;
3250
3261
  };
3251
3262
  this.loadToken = () => {
@@ -3288,6 +3299,9 @@ class TokenManager {
3288
3299
  return this.loadTokenPromise;
3289
3300
  };
3290
3301
  this.getToken = () => {
3302
+ if (this._isAnonymous) {
3303
+ return "";
3304
+ }
3291
3305
  if (this.token) {
3292
3306
  return this.token;
3293
3307
  }
@@ -3304,6 +3318,9 @@ class TokenManager {
3304
3318
  this.loadTokenPromise = null;
3305
3319
  this.type = "static";
3306
3320
  }
3321
+ get isAnonymous() {
3322
+ return this._isAnonymous;
3323
+ }
3307
3324
  }
3308
3325
  class ConnectionIdManager {
3309
3326
  constructor() {
@@ -3315,10 +3332,12 @@ class ConnectionIdManager {
3315
3332
  };
3316
3333
  this.resetConnectionIdPromise = () => {
3317
3334
  this.connectionId = void 0;
3318
- this.loadConnectionIdPromise = new Promise((resolve, reject) => {
3319
- this.resolve = resolve;
3320
- this.reject = reject;
3321
- });
3335
+ this.loadConnectionIdPromise = new Promise(
3336
+ (resolve, reject) => {
3337
+ this.resolve = resolve;
3338
+ this.reject = reject;
3339
+ }
3340
+ );
3322
3341
  };
3323
3342
  this.resolveConnectionidPromise = (connectionId) => {
3324
3343
  this.connectionId = connectionId;
@@ -3420,7 +3439,7 @@ class StableWSConnection {
3420
3439
  return;
3421
3440
  }
3422
3441
  const token = await this.tokenManager.getToken();
3423
- if (!token) {
3442
+ if (!token && !this.tokenManager.isAnonymous) {
3424
3443
  logger.warn(`Token not set, can't connect authenticate`);
3425
3444
  return;
3426
3445
  }
@@ -3903,7 +3922,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
3903
3922
  };
3904
3923
  return result;
3905
3924
  };
3906
- const version = "0.3.13";
3925
+ const version = "0.3.15";
3907
3926
  class ApiClient {
3908
3927
  constructor(apiKey, tokenManager, connectionIdManager, options) {
3909
3928
  this.apiKey = apiKey;
@@ -3917,7 +3936,9 @@ class ApiClient {
3917
3936
  if (queryParams?.watch || queryParams?.presence || queryParams?.payload?.watch || queryParams?.payload?.presence || body?.watch || body?.presence) {
3918
3937
  this.logger.info("Getting connection_id for watch or presence request");
3919
3938
  const connectionId = await this.connectionIdManager.getConnectionId();
3920
- queryParams.connection_id = connectionId;
3939
+ if (connectionId) {
3940
+ queryParams.connection_id = connectionId;
3941
+ }
3921
3942
  }
3922
3943
  let requestUrl = url;
3923
3944
  if (pathParams) {
@@ -4065,7 +4086,7 @@ class ApiClient {
4065
4086
  }
4066
4087
  get commonHeaders() {
4067
4088
  return {
4068
- "stream-auth-type": "jwt",
4089
+ "stream-auth-type": this.tokenManager.isAnonymous ? "anonymous" : "jwt",
4069
4090
  "X-Stream-Client": this.generateStreamClientHeader()
4070
4091
  };
4071
4092
  }
@@ -7159,6 +7180,19 @@ class FeedsClient extends FeedsApi {
7159
7180
  }
7160
7181
  };
7161
7182
  this.pollFromState = (id) => this.polls_by_id.get(id);
7183
+ this.connectAnonymous = () => {
7184
+ this.connectionIdManager.resolveConnectionidPromise();
7185
+ this.tokenManager.setTokenOrProvider(void 0);
7186
+ this.setGetBatchOwnCapabilitiesThrottlingInterval(
7187
+ this.query_batch_own_capabilties_throttling_interval
7188
+ );
7189
+ this.state.partialNext({
7190
+ connected_user: void 0,
7191
+ is_anonymous: true,
7192
+ is_ws_connection_healthy: false
7193
+ });
7194
+ return Promise.resolve();
7195
+ };
7162
7196
  this.connectUser = async (user, tokenProvider) => {
7163
7197
  if (this.state.getLatestValue().connected_user !== void 0 || this.wsConnection) {
7164
7198
  throw new Error(`Can't connect a new user, call "disconnectUser" first`);
@@ -7393,6 +7427,7 @@ class FeedsClient extends FeedsApi {
7393
7427
  };
7394
7428
  this.state = new stateStore.StateStore({
7395
7429
  connected_user: void 0,
7430
+ is_anonymous: false,
7396
7431
  is_ws_connection_healthy: false,
7397
7432
  own_capabilities_by_fid: {}
7398
7433
  });
@@ -7714,4 +7749,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
7714
7749
  exports.shouldUpdateState = shouldUpdateState;
7715
7750
  exports.uniqueArrayMerge = uniqueArrayMerge;
7716
7751
  exports.updateEntityInArray = updateEntityInArray;
7717
- //# sourceMappingURL=feeds-client-DaiBvVCs.js.map
7752
+ //# sourceMappingURL=feeds-client-DTDDoiJL.js.map