@stream-io/feeds-client 0.1.11 → 0.2.0

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 (52) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/index-react-bindings.browser.cjs +172 -124
  3. package/dist/index-react-bindings.browser.cjs.map +1 -1
  4. package/dist/index-react-bindings.browser.js +172 -124
  5. package/dist/index-react-bindings.browser.js.map +1 -1
  6. package/dist/index-react-bindings.node.cjs +172 -124
  7. package/dist/index-react-bindings.node.cjs.map +1 -1
  8. package/dist/index-react-bindings.node.js +172 -124
  9. package/dist/index-react-bindings.node.js.map +1 -1
  10. package/dist/index.browser.cjs +170 -122
  11. package/dist/index.browser.cjs.map +1 -1
  12. package/dist/index.browser.js +170 -122
  13. package/dist/index.browser.js.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.node.cjs +170 -122
  16. package/dist/index.node.cjs.map +1 -1
  17. package/dist/index.node.js +170 -122
  18. package/dist/index.node.js.map +1 -1
  19. package/dist/src/feed/event-handlers/index.d.ts +1 -0
  20. package/dist/src/feed/event-handlers/watch/handle-watch-started.d.ts +2 -0
  21. package/dist/src/feed/event-handlers/watch/handle-watch-stopped.d.ts +2 -0
  22. package/dist/src/feed/event-handlers/watch/index.d.ts +2 -0
  23. package/dist/src/feed/feed.d.ts +4 -12
  24. package/dist/src/feeds-client/event-handlers/index.d.ts +1 -0
  25. package/dist/src/feeds-client/event-handlers/user/handle-user-updated.d.ts +3 -0
  26. package/dist/src/{feeds-client.d.ts → feeds-client/feeds-client.d.ts} +16 -16
  27. package/dist/src/feeds-client/index.d.ts +2 -0
  28. package/dist/src/gen/feeds/FeedsApi.d.ts +27 -23
  29. package/dist/src/gen/models/index.d.ts +163 -23
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/index.ts +1 -1
  32. package/package.json +2 -2
  33. package/src/feed/event-handlers/follow/handle-follow-created.test.ts +16 -12
  34. package/src/feed/event-handlers/follow/handle-follow-created.ts +4 -7
  35. package/src/feed/event-handlers/follow/handle-follow-deleted.test.ts +19 -15
  36. package/src/feed/event-handlers/follow/handle-follow-deleted.ts +6 -6
  37. package/src/feed/event-handlers/follow/handle-follow-updated.ts +7 -10
  38. package/src/feed/event-handlers/index.ts +2 -1
  39. package/src/feed/event-handlers/watch/handle-watch-started.ts +5 -0
  40. package/src/feed/event-handlers/watch/handle-watch-stopped.ts +5 -0
  41. package/src/feed/event-handlers/watch/index.ts +2 -0
  42. package/src/feed/feed.ts +15 -33
  43. package/src/feeds-client/event-handlers/index.ts +1 -0
  44. package/src/feeds-client/event-handlers/user/handle-user-updated.test.ts +53 -0
  45. package/src/feeds-client/event-handlers/user/handle-user-updated.ts +28 -0
  46. package/src/{feeds-client.ts → feeds-client/feeds-client.ts} +48 -39
  47. package/src/feeds-client/index.ts +2 -0
  48. package/src/gen/feeds/FeedsApi.ts +164 -138
  49. package/src/gen/model-decoders/decoders.ts +15 -0
  50. package/src/gen/models/index.ts +278 -29
  51. package/src/test-utils/response-generators.ts +10 -11
  52. package/src/utils/state-update-queue.ts +1 -1
@@ -907,6 +907,7 @@ decoders.FeedResponse = (input) => {
907
907
  updated_at: { type: 'DatetimeType', isSingle: true },
908
908
  created_by: { type: 'UserResponse', isSingle: true },
909
909
  deleted_at: { type: 'DatetimeType', isSingle: true },
910
+ own_follows: { type: 'FollowResponse', isSingle: false },
910
911
  };
911
912
  return decode(typeMappings, input);
912
913
  };
@@ -1125,6 +1126,13 @@ decoders.ModerationCustomActionEvent = (input) => {
1125
1126
  };
1126
1127
  return decode(typeMappings, input);
1127
1128
  };
1129
+ decoders.ModerationFlagResponse = (input) => {
1130
+ const typeMappings = {
1131
+ review_queue_item: { type: 'ReviewQueueItemResponse', isSingle: true },
1132
+ user: { type: 'UserResponse', isSingle: true },
1133
+ };
1134
+ return decode(typeMappings, input);
1135
+ };
1128
1136
  decoders.ModerationFlaggedEvent = (input) => {
1129
1137
  const typeMappings = {
1130
1138
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -1161,6 +1169,7 @@ decoders.NotificationFeedUpdatedEvent = (input) => {
1161
1169
  };
1162
1170
  decoders.NotificationStatusResponse = (input) => {
1163
1171
  const typeMappings = {
1172
+ last_read_at: { type: 'DatetimeType', isSingle: true },
1164
1173
  last_seen_at: { type: 'DatetimeType', isSingle: true },
1165
1174
  };
1166
1175
  return decode(typeMappings, input);
@@ -1428,6 +1437,7 @@ decoders.ReviewQueueItemResponse = (input) => {
1428
1437
  updated_at: { type: 'DatetimeType', isSingle: true },
1429
1438
  actions: { type: 'ActionLogResponse', isSingle: false },
1430
1439
  bans: { type: 'Ban', isSingle: false },
1440
+ flags: { type: 'ModerationFlagResponse', isSingle: false },
1431
1441
  completed_at: { type: 'DatetimeType', isSingle: true },
1432
1442
  reviewed_at: { type: 'DatetimeType', isSingle: true },
1433
1443
  assigned_to: { type: 'UserResponse', isSingle: true },
@@ -1750,7 +1760,7 @@ class FeedsApi {
1750
1760
  async addActivity(request) {
1751
1761
  const body = {
1752
1762
  type: request?.type,
1753
- fids: request?.fids,
1763
+ feeds: request?.feeds,
1754
1764
  expires_at: request?.expires_at,
1755
1765
  id: request?.id,
1756
1766
  parent_id: request?.parent_id,
@@ -1780,7 +1790,7 @@ class FeedsApi {
1780
1790
  }
1781
1791
  async deleteActivities(request) {
1782
1792
  const body = {
1783
- activity_ids: request?.activity_ids,
1793
+ ids: request?.ids,
1784
1794
  hard_delete: request?.hard_delete,
1785
1795
  };
1786
1796
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/delete', undefined, undefined, body, 'application/json');
@@ -1799,56 +1809,6 @@ class FeedsApi {
1799
1809
  decoders.QueryActivitiesResponse?.(response.body);
1800
1810
  return { ...response.body, metadata: response.metadata };
1801
1811
  }
1802
- async deleteActivity(request) {
1803
- const queryParams = {
1804
- hard_delete: request?.hard_delete,
1805
- };
1806
- const pathParams = {
1807
- activity_id: request?.activity_id,
1808
- };
1809
- const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/activities/{activity_id}', pathParams, queryParams);
1810
- decoders.DeleteActivityResponse?.(response.body);
1811
- return { ...response.body, metadata: response.metadata };
1812
- }
1813
- async getActivity(request) {
1814
- const pathParams = {
1815
- activity_id: request?.activity_id,
1816
- };
1817
- const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined);
1818
- decoders.GetActivityResponse?.(response.body);
1819
- return { ...response.body, metadata: response.metadata };
1820
- }
1821
- async updateActivityPartial(request) {
1822
- const pathParams = {
1823
- activity_id: request?.activity_id,
1824
- };
1825
- const body = {
1826
- unset: request?.unset,
1827
- set: request?.set,
1828
- };
1829
- const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined, body, 'application/json');
1830
- decoders.UpdateActivityPartialResponse?.(response.body);
1831
- return { ...response.body, metadata: response.metadata };
1832
- }
1833
- async updateActivity(request) {
1834
- const pathParams = {
1835
- activity_id: request?.activity_id,
1836
- };
1837
- const body = {
1838
- expires_at: request?.expires_at,
1839
- poll_id: request?.poll_id,
1840
- text: request?.text,
1841
- visibility: request?.visibility,
1842
- attachments: request?.attachments,
1843
- filter_tags: request?.filter_tags,
1844
- interest_tags: request?.interest_tags,
1845
- custom: request?.custom,
1846
- location: request?.location,
1847
- };
1848
- const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined, body, 'application/json');
1849
- decoders.UpdateActivityResponse?.(response.body);
1850
- return { ...response.body, metadata: response.metadata };
1851
- }
1852
1812
  async deleteBookmark(request) {
1853
1813
  const queryParams = {
1854
1814
  folder_id: request?.folder_id,
@@ -1887,6 +1847,21 @@ class FeedsApi {
1887
1847
  decoders.AddBookmarkResponse?.(response.body);
1888
1848
  return { ...response.body, metadata: response.metadata };
1889
1849
  }
1850
+ async activityFeedback(request) {
1851
+ const pathParams = {
1852
+ activity_id: request?.activity_id,
1853
+ };
1854
+ const body = {
1855
+ hide: request?.hide,
1856
+ mute_user: request?.mute_user,
1857
+ reason: request?.reason,
1858
+ report: request?.report,
1859
+ show_less: request?.show_less,
1860
+ };
1861
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/{activity_id}/feedback', pathParams, undefined, body, 'application/json');
1862
+ decoders.ActivityFeedbackResponse?.(response.body);
1863
+ return { ...response.body, metadata: response.metadata };
1864
+ }
1890
1865
  async castPollVote(request) {
1891
1866
  const pathParams = {
1892
1867
  activity_id: request?.activity_id,
@@ -1949,6 +1924,56 @@ class FeedsApi {
1949
1924
  decoders.DeleteActivityReactionResponse?.(response.body);
1950
1925
  return { ...response.body, metadata: response.metadata };
1951
1926
  }
1927
+ async deleteActivity(request) {
1928
+ const queryParams = {
1929
+ hard_delete: request?.hard_delete,
1930
+ };
1931
+ const pathParams = {
1932
+ id: request?.id,
1933
+ };
1934
+ const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/activities/{id}', pathParams, queryParams);
1935
+ decoders.DeleteActivityResponse?.(response.body);
1936
+ return { ...response.body, metadata: response.metadata };
1937
+ }
1938
+ async getActivity(request) {
1939
+ const pathParams = {
1940
+ id: request?.id,
1941
+ };
1942
+ const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/activities/{id}', pathParams, undefined);
1943
+ decoders.GetActivityResponse?.(response.body);
1944
+ return { ...response.body, metadata: response.metadata };
1945
+ }
1946
+ async updateActivityPartial(request) {
1947
+ const pathParams = {
1948
+ id: request?.id,
1949
+ };
1950
+ const body = {
1951
+ unset: request?.unset,
1952
+ set: request?.set,
1953
+ };
1954
+ const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/activities/{id}', pathParams, undefined, body, 'application/json');
1955
+ decoders.UpdateActivityPartialResponse?.(response.body);
1956
+ return { ...response.body, metadata: response.metadata };
1957
+ }
1958
+ async updateActivity(request) {
1959
+ const pathParams = {
1960
+ id: request?.id,
1961
+ };
1962
+ const body = {
1963
+ expires_at: request?.expires_at,
1964
+ poll_id: request?.poll_id,
1965
+ text: request?.text,
1966
+ visibility: request?.visibility,
1967
+ attachments: request?.attachments,
1968
+ filter_tags: request?.filter_tags,
1969
+ interest_tags: request?.interest_tags,
1970
+ custom: request?.custom,
1971
+ location: request?.location,
1972
+ };
1973
+ const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/activities/{id}', pathParams, undefined, body, 'application/json');
1974
+ decoders.UpdateActivityResponse?.(response.body);
1975
+ return { ...response.body, metadata: response.metadata };
1976
+ }
1952
1977
  async queryBookmarkFolders(request) {
1953
1978
  const body = {
1954
1979
  limit: request?.limit,
@@ -2044,49 +2069,52 @@ class FeedsApi {
2044
2069
  return { ...response.body, metadata: response.metadata };
2045
2070
  }
2046
2071
  async deleteComment(request) {
2072
+ const queryParams = {
2073
+ hard_delete: request?.hard_delete,
2074
+ };
2047
2075
  const pathParams = {
2048
- comment_id: request?.comment_id,
2076
+ id: request?.id,
2049
2077
  };
2050
- const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{comment_id}', pathParams, undefined);
2078
+ const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{id}', pathParams, queryParams);
2051
2079
  decoders.DeleteCommentResponse?.(response.body);
2052
2080
  return { ...response.body, metadata: response.metadata };
2053
2081
  }
2054
2082
  async getComment(request) {
2055
2083
  const pathParams = {
2056
- comment_id: request?.comment_id,
2084
+ id: request?.id,
2057
2085
  };
2058
- const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{comment_id}', pathParams, undefined);
2086
+ const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{id}', pathParams, undefined);
2059
2087
  decoders.GetCommentResponse?.(response.body);
2060
2088
  return { ...response.body, metadata: response.metadata };
2061
2089
  }
2062
2090
  async updateComment(request) {
2063
2091
  const pathParams = {
2064
- comment_id: request?.comment_id,
2092
+ id: request?.id,
2065
2093
  };
2066
2094
  const body = {
2067
2095
  comment: request?.comment,
2068
2096
  custom: request?.custom,
2069
2097
  };
2070
- const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{comment_id}', pathParams, undefined, body, 'application/json');
2098
+ const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{id}', pathParams, undefined, body, 'application/json');
2071
2099
  decoders.UpdateCommentResponse?.(response.body);
2072
2100
  return { ...response.body, metadata: response.metadata };
2073
2101
  }
2074
2102
  async addCommentReaction(request) {
2075
2103
  const pathParams = {
2076
- comment_id: request?.comment_id,
2104
+ id: request?.id,
2077
2105
  };
2078
2106
  const body = {
2079
2107
  type: request?.type,
2080
2108
  create_notification_activity: request?.create_notification_activity,
2081
2109
  custom: request?.custom,
2082
2110
  };
2083
- const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{comment_id}/reactions', pathParams, undefined, body, 'application/json');
2111
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions', pathParams, undefined, body, 'application/json');
2084
2112
  decoders.AddCommentReactionResponse?.(response.body);
2085
2113
  return { ...response.body, metadata: response.metadata };
2086
2114
  }
2087
2115
  async queryCommentReactions(request) {
2088
2116
  const pathParams = {
2089
- comment_id: request?.comment_id,
2117
+ id: request?.id,
2090
2118
  };
2091
2119
  const body = {
2092
2120
  limit: request?.limit,
@@ -2095,16 +2123,16 @@ class FeedsApi {
2095
2123
  sort: request?.sort,
2096
2124
  filter: request?.filter,
2097
2125
  };
2098
- const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{comment_id}/reactions/query', pathParams, undefined, body, 'application/json');
2126
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions/query', pathParams, undefined, body, 'application/json');
2099
2127
  decoders.QueryCommentReactionsResponse?.(response.body);
2100
2128
  return { ...response.body, metadata: response.metadata };
2101
2129
  }
2102
2130
  async deleteCommentReaction(request) {
2103
2131
  const pathParams = {
2104
- comment_id: request?.comment_id,
2132
+ id: request?.id,
2105
2133
  type: request?.type,
2106
2134
  };
2107
- const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{comment_id}/reactions/{type}', pathParams, undefined);
2135
+ const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{id}/reactions/{type}', pathParams, undefined);
2108
2136
  decoders.DeleteCommentReactionResponse?.(response.body);
2109
2137
  return { ...response.body, metadata: response.metadata };
2110
2138
  }
@@ -2118,9 +2146,9 @@ class FeedsApi {
2118
2146
  next: request?.next,
2119
2147
  };
2120
2148
  const pathParams = {
2121
- comment_id: request?.comment_id,
2149
+ id: request?.id,
2122
2150
  };
2123
- const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{comment_id}/replies', pathParams, queryParams);
2151
+ const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{id}/replies', pathParams, queryParams);
2124
2152
  decoders.GetCommentRepliesResponse?.(response.body);
2125
2153
  return { ...response.body, metadata: response.metadata };
2126
2154
  }
@@ -2169,7 +2197,6 @@ class FeedsApi {
2169
2197
  feed_id: request?.feed_id,
2170
2198
  };
2171
2199
  const body = {
2172
- created_by_id: request?.created_by_id,
2173
2200
  custom: request?.custom,
2174
2201
  };
2175
2202
  const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/feed_groups/{feed_group_id}/feeds/{feed_id}', pathParams, undefined, body, 'application/json');
@@ -2185,6 +2212,7 @@ class FeedsApi {
2185
2212
  mark_all_read: request?.mark_all_read,
2186
2213
  mark_all_seen: request?.mark_all_seen,
2187
2214
  mark_read: request?.mark_read,
2215
+ mark_seen: request?.mark_seen,
2188
2216
  mark_watched: request?.mark_watched,
2189
2217
  };
2190
2218
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/feed_groups/{feed_group_id}/feeds/{feed_id}/activities/mark/batch', pathParams, undefined, body, 'application/json');
@@ -2295,7 +2323,7 @@ class FeedsApi {
2295
2323
  decoders.CreateFeedsBatchResponse?.(response.body);
2296
2324
  return { ...response.body, metadata: response.metadata };
2297
2325
  }
2298
- async feedsQueryFeeds(request) {
2326
+ async _queryFeeds(request) {
2299
2327
  const queryParams = {
2300
2328
  connection_id: request?.connection_id,
2301
2329
  };
@@ -2338,8 +2366,8 @@ class FeedsApi {
2338
2366
  }
2339
2367
  async acceptFollow(request) {
2340
2368
  const body = {
2341
- source_fid: request?.source_fid,
2342
- target_fid: request?.target_fid,
2369
+ source: request?.source,
2370
+ target: request?.target,
2343
2371
  follower_role: request?.follower_role,
2344
2372
  };
2345
2373
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows/accept', undefined, undefined, body, 'application/json');
@@ -2368,8 +2396,8 @@ class FeedsApi {
2368
2396
  }
2369
2397
  async rejectFollow(request) {
2370
2398
  const body = {
2371
- source_fid: request?.source_fid,
2372
- target_fid: request?.target_fid,
2399
+ source: request?.source,
2400
+ target: request?.target,
2373
2401
  };
2374
2402
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows/reject', undefined, undefined, body, 'application/json');
2375
2403
  decoders.RejectFollowResponse?.(response.body);
@@ -4249,7 +4277,7 @@ const shouldUpdateState = ({ stateUpdateQueueId, stateUpdateQueue, watch, }) =>
4249
4277
  };
4250
4278
  function getStateUpdateQueueId(data, prefix) {
4251
4279
  if (isFollowResponse(data)) {
4252
- const toJoin = [data.source_feed.fid, data.target_feed.fid];
4280
+ const toJoin = [data.source_feed.feed, data.target_feed.feed];
4253
4281
  if (prefix) {
4254
4282
  toJoin.unshift(prefix);
4255
4283
  }
@@ -4267,7 +4295,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
4267
4295
  }
4268
4296
  let newState = { ...currentState };
4269
4297
  // this feed followed someone
4270
- if (follow.source_feed.fid === currentFeedId) {
4298
+ if (follow.source_feed.feed === currentFeedId) {
4271
4299
  newState = {
4272
4300
  ...newState,
4273
4301
  // Update FeedResponse fields, that has the new follower/following count
@@ -4280,7 +4308,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
4280
4308
  }
4281
4309
  else if (
4282
4310
  // someone followed this feed
4283
- follow.target_feed.fid === currentFeedId) {
4311
+ follow.target_feed.feed === currentFeedId) {
4284
4312
  const source = follow.source_feed;
4285
4313
  newState = {
4286
4314
  ...newState,
@@ -4309,7 +4337,7 @@ function handleFollowCreated(eventOrResponse) {
4309
4337
  return;
4310
4338
  }
4311
4339
  const connectedUser = this.client.state.getLatestValue().connected_user;
4312
- const result = updateStateFollowCreated(follow, this.currentState, this.fid, connectedUser?.id);
4340
+ const result = updateStateFollowCreated(follow, this.currentState, this.feed, connectedUser?.id);
4313
4341
  if (result.changed) {
4314
4342
  this.state.next(result.data);
4315
4343
  }
@@ -4318,7 +4346,7 @@ function handleFollowCreated(eventOrResponse) {
4318
4346
  const updateStateFollowDeleted = (follow, currentState, currentFeedId, connectedUserId) => {
4319
4347
  let newState = { ...currentState };
4320
4348
  // this feed unfollowed someone
4321
- if (follow.source_feed.fid === currentFeedId) {
4349
+ if (follow.source_feed.feed === currentFeedId) {
4322
4350
  newState = {
4323
4351
  ...newState,
4324
4352
  // Update FeedResponse fields, that has the new follower/following count
@@ -4326,12 +4354,12 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
4326
4354
  };
4327
4355
  // Only update if following array already exists
4328
4356
  if (currentState.following !== undefined) {
4329
- newState.following = currentState.following.filter((followItem) => followItem.target_feed.fid !== follow.target_feed.fid);
4357
+ newState.following = currentState.following.filter((followItem) => followItem.target_feed.feed !== follow.target_feed.feed);
4330
4358
  }
4331
4359
  }
4332
4360
  else if (
4333
4361
  // someone unfollowed this feed
4334
- follow.target_feed.fid === currentFeedId) {
4362
+ follow.target_feed.feed === currentFeedId) {
4335
4363
  const source = follow.source_feed;
4336
4364
  newState = {
4337
4365
  ...newState,
@@ -4340,11 +4368,11 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
4340
4368
  };
4341
4369
  if (source.created_by.id === connectedUserId &&
4342
4370
  currentState.own_follows !== undefined) {
4343
- newState.own_follows = currentState.own_follows.filter((followItem) => followItem.source_feed.fid !== follow.source_feed.fid);
4371
+ newState.own_follows = currentState.own_follows.filter((followItem) => followItem.source_feed.feed !== follow.source_feed.feed);
4344
4372
  }
4345
4373
  // Only update if followers array already exists
4346
4374
  if (currentState.followers !== undefined) {
4347
- newState.followers = currentState.followers.filter((followItem) => followItem.source_feed.fid !== follow.source_feed.fid);
4375
+ newState.followers = currentState.followers.filter((followItem) => followItem.source_feed.feed !== follow.source_feed.feed);
4348
4376
  }
4349
4377
  }
4350
4378
  return { changed: true, data: newState };
@@ -4359,7 +4387,7 @@ function handleFollowDeleted(eventOrResponse) {
4359
4387
  return;
4360
4388
  }
4361
4389
  const connectedUser = this.client.state.getLatestValue().connected_user;
4362
- const result = updateStateFollowDeleted(follow, this.currentState, this.fid, connectedUser?.id);
4390
+ const result = updateStateFollowDeleted(follow, this.currentState, this.feed, connectedUser?.id);
4363
4391
  {
4364
4392
  this.state.next(result.data);
4365
4393
  }
@@ -4368,7 +4396,7 @@ function handleFollowDeleted(eventOrResponse) {
4368
4396
  function handleFollowUpdated(eventOrResponse) {
4369
4397
  const follow = eventOrResponse.follow;
4370
4398
  const connectedUserId = this.client.state.getLatestValue().connected_user?.id;
4371
- const currentFeedId = this.fid;
4399
+ const currentFeedId = this.feed;
4372
4400
  if (!shouldUpdateState({
4373
4401
  stateUpdateQueueId: getStateUpdateQueueId(follow, 'updated'),
4374
4402
  stateUpdateQueue: this.stateUpdateQueue,
@@ -4379,13 +4407,13 @@ function handleFollowUpdated(eventOrResponse) {
4379
4407
  this.state.next((currentState) => {
4380
4408
  let newState;
4381
4409
  // this feed followed someone
4382
- if (follow.source_feed.fid === currentFeedId) {
4410
+ if (follow.source_feed.feed === currentFeedId) {
4383
4411
  newState ?? (newState = {
4384
4412
  ...currentState,
4385
4413
  // Update FeedResponse fields, that has the new follower/following count
4386
4414
  ...follow.source_feed,
4387
4415
  });
4388
- const index = currentState.following?.findIndex((f) => f.target_feed.fid === follow.target_feed.fid) ?? -1;
4416
+ const index = currentState.following?.findIndex((f) => f.target_feed.feed === follow.target_feed.feed) ?? -1;
4389
4417
  if (index >= 0) {
4390
4418
  newState.following = [...newState.following];
4391
4419
  newState.following[index] = follow;
@@ -4393,7 +4421,7 @@ function handleFollowUpdated(eventOrResponse) {
4393
4421
  }
4394
4422
  else if (
4395
4423
  // someone followed this feed
4396
- follow.target_feed.fid === currentFeedId) {
4424
+ follow.target_feed.feed === currentFeedId) {
4397
4425
  const source = follow.source_feed;
4398
4426
  newState ?? (newState = {
4399
4427
  ...currentState,
@@ -4402,13 +4430,13 @@ function handleFollowUpdated(eventOrResponse) {
4402
4430
  });
4403
4431
  if (source.created_by.id === connectedUserId &&
4404
4432
  currentState.own_follows) {
4405
- const index = currentState.own_follows.findIndex((f) => f.source_feed.fid === follow.source_feed.fid);
4433
+ const index = currentState.own_follows.findIndex((f) => f.source_feed.feed === follow.source_feed.feed);
4406
4434
  if (index >= 0) {
4407
4435
  newState.own_follows = [...currentState.own_follows];
4408
4436
  newState.own_follows[index] = follow;
4409
4437
  }
4410
4438
  }
4411
- const index = currentState.followers?.findIndex((f) => f.source_feed.fid === follow.source_feed.fid) ?? -1;
4439
+ const index = currentState.followers?.findIndex((f) => f.source_feed.feed === follow.source_feed.feed) ?? -1;
4412
4440
  if (index >= 0) {
4413
4441
  newState.followers = [...newState.followers];
4414
4442
  newState.followers[index] = follow;
@@ -4896,6 +4924,14 @@ function handleNotificationFeedUpdated(event) {
4896
4924
  // TODO: handle notification feed updates
4897
4925
  }
4898
4926
 
4927
+ function handleWatchStarted() {
4928
+ this.state.partialNext({ watch: true });
4929
+ }
4930
+
4931
+ function handleWatchStopped() {
4932
+ this.state.partialNext({ watch: false });
4933
+ }
4934
+
4899
4935
  class Feed extends FeedApi {
4900
4936
  constructor(client, groupId, id, data, watch = false) {
4901
4937
  super(client, groupId, id);
@@ -4956,7 +4992,7 @@ class Feed extends FeedApi {
4956
4992
  this.on = this.eventDispatcher.on;
4957
4993
  this.off = this.eventDispatcher.off;
4958
4994
  this.state = new StateStore({
4959
- fid: `${groupId}:${id}`,
4995
+ feed: `${groupId}:${id}`,
4960
4996
  group_id: groupId,
4961
4997
  id,
4962
4998
  ...(data ?? {}),
@@ -4967,7 +5003,7 @@ class Feed extends FeedApi {
4967
5003
  });
4968
5004
  this.client = client;
4969
5005
  }
4970
- get fid() {
5006
+ get feed() {
4971
5007
  return `${this.group}:${this.id}`;
4972
5008
  }
4973
5009
  get currentState() {
@@ -5042,22 +5078,6 @@ class Feed extends FeedApi {
5042
5078
  });
5043
5079
  }
5044
5080
  }
5045
- /**
5046
- * @internal
5047
- */
5048
- handleWatchStopped() {
5049
- this.state.partialNext({
5050
- watch: false,
5051
- });
5052
- }
5053
- /**
5054
- * @internal
5055
- */
5056
- handleWatchStarted() {
5057
- this.state.partialNext({
5058
- watch: true,
5059
- });
5060
- }
5061
5081
  /**
5062
5082
  * Returns index of the provided comment object.
5063
5083
  */
@@ -5217,7 +5237,7 @@ class Feed extends FeedApi {
5217
5237
  entityId: comment.id,
5218
5238
  base: () => this.client.getCommentReplies({
5219
5239
  ...request,
5220
- comment_id: comment.id,
5240
+ id: comment.id,
5221
5241
  // use known sort first (prevents broken pagination)
5222
5242
  sort,
5223
5243
  next: currentNextCursor,
@@ -5257,7 +5277,7 @@ class Feed extends FeedApi {
5257
5277
  ...currentState,
5258
5278
  [type]: currentState[type] === undefined
5259
5279
  ? follows
5260
- : uniqueArrayMerge(currentState[type], follows, (follow) => `${follow.source_feed.fid}-${follow.target_feed.fid}`),
5280
+ : uniqueArrayMerge(currentState[type], follows, (follow) => `${follow.source_feed.feed}-${follow.target_feed.feed}`),
5261
5281
  [paginationKey]: {
5262
5282
  ...currentState[paginationKey],
5263
5283
  next: newNextCursor,
@@ -5350,7 +5370,7 @@ class Feed extends FeedApi {
5350
5370
  */
5351
5371
  async queryFollowers(request) {
5352
5372
  const filter = {
5353
- target_feed: this.fid,
5373
+ target_feed: this.feed,
5354
5374
  };
5355
5375
  const response = await this.client.queryFollows({
5356
5376
  filter,
@@ -5365,7 +5385,7 @@ class Feed extends FeedApi {
5365
5385
  */
5366
5386
  async queryFollowing(request) {
5367
5387
  const filter = {
5368
- source_feed: this.fid,
5388
+ source_feed: this.feed,
5369
5389
  };
5370
5390
  const response = await this.client.queryFollows({
5371
5391
  filter,
@@ -5374,18 +5394,18 @@ class Feed extends FeedApi {
5374
5394
  return response;
5375
5395
  }
5376
5396
  async follow(feedOrFid, options) {
5377
- const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.fid;
5397
+ const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.feed;
5378
5398
  const response = await this.client.follow({
5379
5399
  ...options,
5380
- source: this.fid,
5400
+ source: this.feed,
5381
5401
  target: fid,
5382
5402
  });
5383
5403
  return response;
5384
5404
  }
5385
5405
  async unfollow(feedOrFid) {
5386
- const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.fid;
5406
+ const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.feed;
5387
5407
  const response = await this.client.unfollow({
5388
- source: this.fid,
5408
+ source: this.feed,
5389
5409
  target: fid,
5390
5410
  });
5391
5411
  return response;
@@ -5409,7 +5429,7 @@ class Feed extends FeedApi {
5409
5429
  addActivity(request) {
5410
5430
  return this.feedsApi.addActivity({
5411
5431
  ...request,
5412
- fids: [this.fid],
5432
+ feeds: [this.feed],
5413
5433
  });
5414
5434
  }
5415
5435
  handleWSEvent(event) {
@@ -5427,6 +5447,24 @@ class Feed extends FeedApi {
5427
5447
  }
5428
5448
  Feed.noop = () => { };
5429
5449
 
5450
+ function handleUserUpdated(event) {
5451
+ this.state.next((currentState) => {
5452
+ let newState;
5453
+ const { connected_user } = currentState;
5454
+ if (connected_user && connected_user.id === event.user.id) {
5455
+ newState ?? (newState = {
5456
+ ...currentState,
5457
+ });
5458
+ newState.connected_user = {
5459
+ ...connected_user,
5460
+ ...event.user,
5461
+ };
5462
+ }
5463
+ // TODO: update other users in user map (if/once applicable)
5464
+ return newState ?? currentState;
5465
+ });
5466
+ }
5467
+
5430
5468
  class FeedsClient extends FeedsApi {
5431
5469
  constructor(apiKey, options) {
5432
5470
  const tokenManager = new TokenManager();
@@ -5534,7 +5572,7 @@ class FeedsClient extends FeedsApi {
5534
5572
  if (this.activeFeeds[fid]) {
5535
5573
  const feed = this.activeFeeds[fid];
5536
5574
  if (watch && !feed.currentState.watch) {
5537
- feed.handleWatchStarted();
5575
+ handleWatchStarted.bind(feed)();
5538
5576
  }
5539
5577
  return feed;
5540
5578
  }
@@ -5570,7 +5608,7 @@ class FeedsClient extends FeedsApi {
5570
5608
  }
5571
5609
  else {
5572
5610
  for (const activeFeed of Object.values(this.activeFeeds)) {
5573
- activeFeed.handleWatchStopped();
5611
+ handleWatchStopped.bind(activeFeed)();
5574
5612
  }
5575
5613
  }
5576
5614
  break;
@@ -5650,6 +5688,10 @@ class FeedsClient extends FeedsApi {
5650
5688
  feeds.forEach((f) => f.handleWSEvent(event));
5651
5689
  break;
5652
5690
  }
5691
+ case 'user.updated': {
5692
+ handleUserUpdated.call(this, event);
5693
+ break;
5694
+ }
5653
5695
  default: {
5654
5696
  feed?.handleWSEvent(event);
5655
5697
  }
@@ -5675,7 +5717,7 @@ class FeedsClient extends FeedsApi {
5675
5717
  }
5676
5718
  }
5677
5719
  async queryFeeds(request) {
5678
- const response = await this.feedsQueryFeeds(request);
5720
+ const response = await this._queryFeeds(request);
5679
5721
  const feeds = response.feeds.map((f) => this.getOrCreateActiveFeed(f.group_id, f.id, f, request?.watch));
5680
5722
  return {
5681
5723
  feeds,
@@ -5687,7 +5729,10 @@ class FeedsClient extends FeedsApi {
5687
5729
  }
5688
5730
  async updateFollow(request) {
5689
5731
  const response = await super.updateFollow(request);
5690
- [response.follow.source_feed.fid, response.follow.target_feed.fid].forEach((fid) => {
5732
+ [
5733
+ response.follow.source_feed.feed,
5734
+ response.follow.target_feed.feed,
5735
+ ].forEach((fid) => {
5691
5736
  const feed = this.activeFeeds[fid];
5692
5737
  if (feed) {
5693
5738
  handleFollowUpdated.bind(feed)(response);
@@ -5698,7 +5743,10 @@ class FeedsClient extends FeedsApi {
5698
5743
  // For follow API endpoints we update the state after HTTP response to allow queryFeeds with watch: false
5699
5744
  async follow(request) {
5700
5745
  const response = await super.follow(request);
5701
- [response.follow.source_feed.fid, response.follow.target_feed.fid].forEach((fid) => {
5746
+ [
5747
+ response.follow.source_feed.feed,
5748
+ response.follow.target_feed.feed,
5749
+ ].forEach((fid) => {
5702
5750
  const feed = this.activeFeeds[fid];
5703
5751
  if (feed) {
5704
5752
  handleFollowCreated.bind(feed)(response);
@@ -5709,7 +5757,7 @@ class FeedsClient extends FeedsApi {
5709
5757
  async followBatch(request) {
5710
5758
  const response = await super.followBatch(request);
5711
5759
  response.follows.forEach((follow) => {
5712
- const feed = this.activeFeeds[follow.source_feed.fid];
5760
+ const feed = this.activeFeeds[follow.source_feed.feed];
5713
5761
  if (feed) {
5714
5762
  handleFollowCreated.bind(feed)({ follow });
5715
5763
  }
@@ -5734,7 +5782,7 @@ class FeedsClient extends FeedsApi {
5734
5782
  });
5735
5783
  const feed = this.activeFeeds[`${request.feed_group_id}:${request.feed_id}`];
5736
5784
  if (feed) {
5737
- feed.handleWatchStopped();
5785
+ handleWatchStopped.bind(feed)();
5738
5786
  }
5739
5787
  return response;
5740
5788
  }
@@ -6128,12 +6176,12 @@ const useReactionActions = ({ entity, type, }) => {
6128
6176
  const hasOwnReaction = react.useMemo(() => !!entity.own_reactions?.find((r) => r.type === type), [entity.own_reactions, type]);
6129
6177
  const addReaction = useStableCallback(async () => {
6130
6178
  await (isComment
6131
- ? client?.addCommentReaction({ comment_id: entity.id, type })
6179
+ ? client?.addCommentReaction({ id: entity.id, type })
6132
6180
  : client?.addReaction({ activity_id: entity.id, type }));
6133
6181
  });
6134
6182
  const removeReaction = useStableCallback(async () => {
6135
6183
  await (isComment
6136
- ? client?.deleteCommentReaction({ comment_id: entity.id, type })
6184
+ ? client?.deleteCommentReaction({ id: entity.id, type })
6137
6185
  : client?.deleteActivityReaction({
6138
6186
  activity_id: entity.id,
6139
6187
  type,