@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
@@ -905,6 +905,7 @@ decoders.FeedResponse = (input) => {
905
905
  updated_at: { type: 'DatetimeType', isSingle: true },
906
906
  created_by: { type: 'UserResponse', isSingle: true },
907
907
  deleted_at: { type: 'DatetimeType', isSingle: true },
908
+ own_follows: { type: 'FollowResponse', isSingle: false },
908
909
  };
909
910
  return decode(typeMappings, input);
910
911
  };
@@ -1123,6 +1124,13 @@ decoders.ModerationCustomActionEvent = (input) => {
1123
1124
  };
1124
1125
  return decode(typeMappings, input);
1125
1126
  };
1127
+ decoders.ModerationFlagResponse = (input) => {
1128
+ const typeMappings = {
1129
+ review_queue_item: { type: 'ReviewQueueItemResponse', isSingle: true },
1130
+ user: { type: 'UserResponse', isSingle: true },
1131
+ };
1132
+ return decode(typeMappings, input);
1133
+ };
1126
1134
  decoders.ModerationFlaggedEvent = (input) => {
1127
1135
  const typeMappings = {
1128
1136
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -1159,6 +1167,7 @@ decoders.NotificationFeedUpdatedEvent = (input) => {
1159
1167
  };
1160
1168
  decoders.NotificationStatusResponse = (input) => {
1161
1169
  const typeMappings = {
1170
+ last_read_at: { type: 'DatetimeType', isSingle: true },
1162
1171
  last_seen_at: { type: 'DatetimeType', isSingle: true },
1163
1172
  };
1164
1173
  return decode(typeMappings, input);
@@ -1426,6 +1435,7 @@ decoders.ReviewQueueItemResponse = (input) => {
1426
1435
  updated_at: { type: 'DatetimeType', isSingle: true },
1427
1436
  actions: { type: 'ActionLogResponse', isSingle: false },
1428
1437
  bans: { type: 'Ban', isSingle: false },
1438
+ flags: { type: 'ModerationFlagResponse', isSingle: false },
1429
1439
  completed_at: { type: 'DatetimeType', isSingle: true },
1430
1440
  reviewed_at: { type: 'DatetimeType', isSingle: true },
1431
1441
  assigned_to: { type: 'UserResponse', isSingle: true },
@@ -1748,7 +1758,7 @@ class FeedsApi {
1748
1758
  async addActivity(request) {
1749
1759
  const body = {
1750
1760
  type: request?.type,
1751
- fids: request?.fids,
1761
+ feeds: request?.feeds,
1752
1762
  expires_at: request?.expires_at,
1753
1763
  id: request?.id,
1754
1764
  parent_id: request?.parent_id,
@@ -1778,7 +1788,7 @@ class FeedsApi {
1778
1788
  }
1779
1789
  async deleteActivities(request) {
1780
1790
  const body = {
1781
- activity_ids: request?.activity_ids,
1791
+ ids: request?.ids,
1782
1792
  hard_delete: request?.hard_delete,
1783
1793
  };
1784
1794
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/delete', undefined, undefined, body, 'application/json');
@@ -1797,56 +1807,6 @@ class FeedsApi {
1797
1807
  decoders.QueryActivitiesResponse?.(response.body);
1798
1808
  return { ...response.body, metadata: response.metadata };
1799
1809
  }
1800
- async deleteActivity(request) {
1801
- const queryParams = {
1802
- hard_delete: request?.hard_delete,
1803
- };
1804
- const pathParams = {
1805
- activity_id: request?.activity_id,
1806
- };
1807
- const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/activities/{activity_id}', pathParams, queryParams);
1808
- decoders.DeleteActivityResponse?.(response.body);
1809
- return { ...response.body, metadata: response.metadata };
1810
- }
1811
- async getActivity(request) {
1812
- const pathParams = {
1813
- activity_id: request?.activity_id,
1814
- };
1815
- const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined);
1816
- decoders.GetActivityResponse?.(response.body);
1817
- return { ...response.body, metadata: response.metadata };
1818
- }
1819
- async updateActivityPartial(request) {
1820
- const pathParams = {
1821
- activity_id: request?.activity_id,
1822
- };
1823
- const body = {
1824
- unset: request?.unset,
1825
- set: request?.set,
1826
- };
1827
- const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined, body, 'application/json');
1828
- decoders.UpdateActivityPartialResponse?.(response.body);
1829
- return { ...response.body, metadata: response.metadata };
1830
- }
1831
- async updateActivity(request) {
1832
- const pathParams = {
1833
- activity_id: request?.activity_id,
1834
- };
1835
- const body = {
1836
- expires_at: request?.expires_at,
1837
- poll_id: request?.poll_id,
1838
- text: request?.text,
1839
- visibility: request?.visibility,
1840
- attachments: request?.attachments,
1841
- filter_tags: request?.filter_tags,
1842
- interest_tags: request?.interest_tags,
1843
- custom: request?.custom,
1844
- location: request?.location,
1845
- };
1846
- const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/activities/{activity_id}', pathParams, undefined, body, 'application/json');
1847
- decoders.UpdateActivityResponse?.(response.body);
1848
- return { ...response.body, metadata: response.metadata };
1849
- }
1850
1810
  async deleteBookmark(request) {
1851
1811
  const queryParams = {
1852
1812
  folder_id: request?.folder_id,
@@ -1885,6 +1845,21 @@ class FeedsApi {
1885
1845
  decoders.AddBookmarkResponse?.(response.body);
1886
1846
  return { ...response.body, metadata: response.metadata };
1887
1847
  }
1848
+ async activityFeedback(request) {
1849
+ const pathParams = {
1850
+ activity_id: request?.activity_id,
1851
+ };
1852
+ const body = {
1853
+ hide: request?.hide,
1854
+ mute_user: request?.mute_user,
1855
+ reason: request?.reason,
1856
+ report: request?.report,
1857
+ show_less: request?.show_less,
1858
+ };
1859
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/activities/{activity_id}/feedback', pathParams, undefined, body, 'application/json');
1860
+ decoders.ActivityFeedbackResponse?.(response.body);
1861
+ return { ...response.body, metadata: response.metadata };
1862
+ }
1888
1863
  async castPollVote(request) {
1889
1864
  const pathParams = {
1890
1865
  activity_id: request?.activity_id,
@@ -1947,6 +1922,56 @@ class FeedsApi {
1947
1922
  decoders.DeleteActivityReactionResponse?.(response.body);
1948
1923
  return { ...response.body, metadata: response.metadata };
1949
1924
  }
1925
+ async deleteActivity(request) {
1926
+ const queryParams = {
1927
+ hard_delete: request?.hard_delete,
1928
+ };
1929
+ const pathParams = {
1930
+ id: request?.id,
1931
+ };
1932
+ const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/activities/{id}', pathParams, queryParams);
1933
+ decoders.DeleteActivityResponse?.(response.body);
1934
+ return { ...response.body, metadata: response.metadata };
1935
+ }
1936
+ async getActivity(request) {
1937
+ const pathParams = {
1938
+ id: request?.id,
1939
+ };
1940
+ const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/activities/{id}', pathParams, undefined);
1941
+ decoders.GetActivityResponse?.(response.body);
1942
+ return { ...response.body, metadata: response.metadata };
1943
+ }
1944
+ async updateActivityPartial(request) {
1945
+ const pathParams = {
1946
+ id: request?.id,
1947
+ };
1948
+ const body = {
1949
+ unset: request?.unset,
1950
+ set: request?.set,
1951
+ };
1952
+ const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/activities/{id}', pathParams, undefined, body, 'application/json');
1953
+ decoders.UpdateActivityPartialResponse?.(response.body);
1954
+ return { ...response.body, metadata: response.metadata };
1955
+ }
1956
+ async updateActivity(request) {
1957
+ const pathParams = {
1958
+ id: request?.id,
1959
+ };
1960
+ const body = {
1961
+ expires_at: request?.expires_at,
1962
+ poll_id: request?.poll_id,
1963
+ text: request?.text,
1964
+ visibility: request?.visibility,
1965
+ attachments: request?.attachments,
1966
+ filter_tags: request?.filter_tags,
1967
+ interest_tags: request?.interest_tags,
1968
+ custom: request?.custom,
1969
+ location: request?.location,
1970
+ };
1971
+ const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/activities/{id}', pathParams, undefined, body, 'application/json');
1972
+ decoders.UpdateActivityResponse?.(response.body);
1973
+ return { ...response.body, metadata: response.metadata };
1974
+ }
1950
1975
  async queryBookmarkFolders(request) {
1951
1976
  const body = {
1952
1977
  limit: request?.limit,
@@ -2042,49 +2067,52 @@ class FeedsApi {
2042
2067
  return { ...response.body, metadata: response.metadata };
2043
2068
  }
2044
2069
  async deleteComment(request) {
2070
+ const queryParams = {
2071
+ hard_delete: request?.hard_delete,
2072
+ };
2045
2073
  const pathParams = {
2046
- comment_id: request?.comment_id,
2074
+ id: request?.id,
2047
2075
  };
2048
- const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{comment_id}', pathParams, undefined);
2076
+ const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{id}', pathParams, queryParams);
2049
2077
  decoders.DeleteCommentResponse?.(response.body);
2050
2078
  return { ...response.body, metadata: response.metadata };
2051
2079
  }
2052
2080
  async getComment(request) {
2053
2081
  const pathParams = {
2054
- comment_id: request?.comment_id,
2082
+ id: request?.id,
2055
2083
  };
2056
- const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{comment_id}', pathParams, undefined);
2084
+ const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{id}', pathParams, undefined);
2057
2085
  decoders.GetCommentResponse?.(response.body);
2058
2086
  return { ...response.body, metadata: response.metadata };
2059
2087
  }
2060
2088
  async updateComment(request) {
2061
2089
  const pathParams = {
2062
- comment_id: request?.comment_id,
2090
+ id: request?.id,
2063
2091
  };
2064
2092
  const body = {
2065
2093
  comment: request?.comment,
2066
2094
  custom: request?.custom,
2067
2095
  };
2068
- const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{comment_id}', pathParams, undefined, body, 'application/json');
2096
+ const response = await this.apiClient.sendRequest('PATCH', '/api/v2/feeds/comments/{id}', pathParams, undefined, body, 'application/json');
2069
2097
  decoders.UpdateCommentResponse?.(response.body);
2070
2098
  return { ...response.body, metadata: response.metadata };
2071
2099
  }
2072
2100
  async addCommentReaction(request) {
2073
2101
  const pathParams = {
2074
- comment_id: request?.comment_id,
2102
+ id: request?.id,
2075
2103
  };
2076
2104
  const body = {
2077
2105
  type: request?.type,
2078
2106
  create_notification_activity: request?.create_notification_activity,
2079
2107
  custom: request?.custom,
2080
2108
  };
2081
- const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{comment_id}/reactions', pathParams, undefined, body, 'application/json');
2109
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions', pathParams, undefined, body, 'application/json');
2082
2110
  decoders.AddCommentReactionResponse?.(response.body);
2083
2111
  return { ...response.body, metadata: response.metadata };
2084
2112
  }
2085
2113
  async queryCommentReactions(request) {
2086
2114
  const pathParams = {
2087
- comment_id: request?.comment_id,
2115
+ id: request?.id,
2088
2116
  };
2089
2117
  const body = {
2090
2118
  limit: request?.limit,
@@ -2093,16 +2121,16 @@ class FeedsApi {
2093
2121
  sort: request?.sort,
2094
2122
  filter: request?.filter,
2095
2123
  };
2096
- const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{comment_id}/reactions/query', pathParams, undefined, body, 'application/json');
2124
+ const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/comments/{id}/reactions/query', pathParams, undefined, body, 'application/json');
2097
2125
  decoders.QueryCommentReactionsResponse?.(response.body);
2098
2126
  return { ...response.body, metadata: response.metadata };
2099
2127
  }
2100
2128
  async deleteCommentReaction(request) {
2101
2129
  const pathParams = {
2102
- comment_id: request?.comment_id,
2130
+ id: request?.id,
2103
2131
  type: request?.type,
2104
2132
  };
2105
- const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{comment_id}/reactions/{type}', pathParams, undefined);
2133
+ const response = await this.apiClient.sendRequest('DELETE', '/api/v2/feeds/comments/{id}/reactions/{type}', pathParams, undefined);
2106
2134
  decoders.DeleteCommentReactionResponse?.(response.body);
2107
2135
  return { ...response.body, metadata: response.metadata };
2108
2136
  }
@@ -2116,9 +2144,9 @@ class FeedsApi {
2116
2144
  next: request?.next,
2117
2145
  };
2118
2146
  const pathParams = {
2119
- comment_id: request?.comment_id,
2147
+ id: request?.id,
2120
2148
  };
2121
- const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{comment_id}/replies', pathParams, queryParams);
2149
+ const response = await this.apiClient.sendRequest('GET', '/api/v2/feeds/comments/{id}/replies', pathParams, queryParams);
2122
2150
  decoders.GetCommentRepliesResponse?.(response.body);
2123
2151
  return { ...response.body, metadata: response.metadata };
2124
2152
  }
@@ -2167,7 +2195,6 @@ class FeedsApi {
2167
2195
  feed_id: request?.feed_id,
2168
2196
  };
2169
2197
  const body = {
2170
- created_by_id: request?.created_by_id,
2171
2198
  custom: request?.custom,
2172
2199
  };
2173
2200
  const response = await this.apiClient.sendRequest('PUT', '/api/v2/feeds/feed_groups/{feed_group_id}/feeds/{feed_id}', pathParams, undefined, body, 'application/json');
@@ -2183,6 +2210,7 @@ class FeedsApi {
2183
2210
  mark_all_read: request?.mark_all_read,
2184
2211
  mark_all_seen: request?.mark_all_seen,
2185
2212
  mark_read: request?.mark_read,
2213
+ mark_seen: request?.mark_seen,
2186
2214
  mark_watched: request?.mark_watched,
2187
2215
  };
2188
2216
  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');
@@ -2293,7 +2321,7 @@ class FeedsApi {
2293
2321
  decoders.CreateFeedsBatchResponse?.(response.body);
2294
2322
  return { ...response.body, metadata: response.metadata };
2295
2323
  }
2296
- async feedsQueryFeeds(request) {
2324
+ async _queryFeeds(request) {
2297
2325
  const queryParams = {
2298
2326
  connection_id: request?.connection_id,
2299
2327
  };
@@ -2336,8 +2364,8 @@ class FeedsApi {
2336
2364
  }
2337
2365
  async acceptFollow(request) {
2338
2366
  const body = {
2339
- source_fid: request?.source_fid,
2340
- target_fid: request?.target_fid,
2367
+ source: request?.source,
2368
+ target: request?.target,
2341
2369
  follower_role: request?.follower_role,
2342
2370
  };
2343
2371
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows/accept', undefined, undefined, body, 'application/json');
@@ -2366,8 +2394,8 @@ class FeedsApi {
2366
2394
  }
2367
2395
  async rejectFollow(request) {
2368
2396
  const body = {
2369
- source_fid: request?.source_fid,
2370
- target_fid: request?.target_fid,
2397
+ source: request?.source,
2398
+ target: request?.target,
2371
2399
  };
2372
2400
  const response = await this.apiClient.sendRequest('POST', '/api/v2/feeds/follows/reject', undefined, undefined, body, 'application/json');
2373
2401
  decoders.RejectFollowResponse?.(response.body);
@@ -4247,7 +4275,7 @@ const shouldUpdateState = ({ stateUpdateQueueId, stateUpdateQueue, watch, }) =>
4247
4275
  };
4248
4276
  function getStateUpdateQueueId(data, prefix) {
4249
4277
  if (isFollowResponse(data)) {
4250
- const toJoin = [data.source_feed.fid, data.target_feed.fid];
4278
+ const toJoin = [data.source_feed.feed, data.target_feed.feed];
4251
4279
  if (prefix) {
4252
4280
  toJoin.unshift(prefix);
4253
4281
  }
@@ -4265,7 +4293,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
4265
4293
  }
4266
4294
  let newState = { ...currentState };
4267
4295
  // this feed followed someone
4268
- if (follow.source_feed.fid === currentFeedId) {
4296
+ if (follow.source_feed.feed === currentFeedId) {
4269
4297
  newState = {
4270
4298
  ...newState,
4271
4299
  // Update FeedResponse fields, that has the new follower/following count
@@ -4278,7 +4306,7 @@ const updateStateFollowCreated = (follow, currentState, currentFeedId, connected
4278
4306
  }
4279
4307
  else if (
4280
4308
  // someone followed this feed
4281
- follow.target_feed.fid === currentFeedId) {
4309
+ follow.target_feed.feed === currentFeedId) {
4282
4310
  const source = follow.source_feed;
4283
4311
  newState = {
4284
4312
  ...newState,
@@ -4307,7 +4335,7 @@ function handleFollowCreated(eventOrResponse) {
4307
4335
  return;
4308
4336
  }
4309
4337
  const connectedUser = this.client.state.getLatestValue().connected_user;
4310
- const result = updateStateFollowCreated(follow, this.currentState, this.fid, connectedUser?.id);
4338
+ const result = updateStateFollowCreated(follow, this.currentState, this.feed, connectedUser?.id);
4311
4339
  if (result.changed) {
4312
4340
  this.state.next(result.data);
4313
4341
  }
@@ -4316,7 +4344,7 @@ function handleFollowCreated(eventOrResponse) {
4316
4344
  const updateStateFollowDeleted = (follow, currentState, currentFeedId, connectedUserId) => {
4317
4345
  let newState = { ...currentState };
4318
4346
  // this feed unfollowed someone
4319
- if (follow.source_feed.fid === currentFeedId) {
4347
+ if (follow.source_feed.feed === currentFeedId) {
4320
4348
  newState = {
4321
4349
  ...newState,
4322
4350
  // Update FeedResponse fields, that has the new follower/following count
@@ -4324,12 +4352,12 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
4324
4352
  };
4325
4353
  // Only update if following array already exists
4326
4354
  if (currentState.following !== undefined) {
4327
- newState.following = currentState.following.filter((followItem) => followItem.target_feed.fid !== follow.target_feed.fid);
4355
+ newState.following = currentState.following.filter((followItem) => followItem.target_feed.feed !== follow.target_feed.feed);
4328
4356
  }
4329
4357
  }
4330
4358
  else if (
4331
4359
  // someone unfollowed this feed
4332
- follow.target_feed.fid === currentFeedId) {
4360
+ follow.target_feed.feed === currentFeedId) {
4333
4361
  const source = follow.source_feed;
4334
4362
  newState = {
4335
4363
  ...newState,
@@ -4338,11 +4366,11 @@ const updateStateFollowDeleted = (follow, currentState, currentFeedId, connected
4338
4366
  };
4339
4367
  if (source.created_by.id === connectedUserId &&
4340
4368
  currentState.own_follows !== undefined) {
4341
- newState.own_follows = currentState.own_follows.filter((followItem) => followItem.source_feed.fid !== follow.source_feed.fid);
4369
+ newState.own_follows = currentState.own_follows.filter((followItem) => followItem.source_feed.feed !== follow.source_feed.feed);
4342
4370
  }
4343
4371
  // Only update if followers array already exists
4344
4372
  if (currentState.followers !== undefined) {
4345
- newState.followers = currentState.followers.filter((followItem) => followItem.source_feed.fid !== follow.source_feed.fid);
4373
+ newState.followers = currentState.followers.filter((followItem) => followItem.source_feed.feed !== follow.source_feed.feed);
4346
4374
  }
4347
4375
  }
4348
4376
  return { changed: true, data: newState };
@@ -4357,7 +4385,7 @@ function handleFollowDeleted(eventOrResponse) {
4357
4385
  return;
4358
4386
  }
4359
4387
  const connectedUser = this.client.state.getLatestValue().connected_user;
4360
- const result = updateStateFollowDeleted(follow, this.currentState, this.fid, connectedUser?.id);
4388
+ const result = updateStateFollowDeleted(follow, this.currentState, this.feed, connectedUser?.id);
4361
4389
  {
4362
4390
  this.state.next(result.data);
4363
4391
  }
@@ -4366,7 +4394,7 @@ function handleFollowDeleted(eventOrResponse) {
4366
4394
  function handleFollowUpdated(eventOrResponse) {
4367
4395
  const follow = eventOrResponse.follow;
4368
4396
  const connectedUserId = this.client.state.getLatestValue().connected_user?.id;
4369
- const currentFeedId = this.fid;
4397
+ const currentFeedId = this.feed;
4370
4398
  if (!shouldUpdateState({
4371
4399
  stateUpdateQueueId: getStateUpdateQueueId(follow, 'updated'),
4372
4400
  stateUpdateQueue: this.stateUpdateQueue,
@@ -4377,13 +4405,13 @@ function handleFollowUpdated(eventOrResponse) {
4377
4405
  this.state.next((currentState) => {
4378
4406
  let newState;
4379
4407
  // this feed followed someone
4380
- if (follow.source_feed.fid === currentFeedId) {
4408
+ if (follow.source_feed.feed === currentFeedId) {
4381
4409
  newState ?? (newState = {
4382
4410
  ...currentState,
4383
4411
  // Update FeedResponse fields, that has the new follower/following count
4384
4412
  ...follow.source_feed,
4385
4413
  });
4386
- const index = currentState.following?.findIndex((f) => f.target_feed.fid === follow.target_feed.fid) ?? -1;
4414
+ const index = currentState.following?.findIndex((f) => f.target_feed.feed === follow.target_feed.feed) ?? -1;
4387
4415
  if (index >= 0) {
4388
4416
  newState.following = [...newState.following];
4389
4417
  newState.following[index] = follow;
@@ -4391,7 +4419,7 @@ function handleFollowUpdated(eventOrResponse) {
4391
4419
  }
4392
4420
  else if (
4393
4421
  // someone followed this feed
4394
- follow.target_feed.fid === currentFeedId) {
4422
+ follow.target_feed.feed === currentFeedId) {
4395
4423
  const source = follow.source_feed;
4396
4424
  newState ?? (newState = {
4397
4425
  ...currentState,
@@ -4400,13 +4428,13 @@ function handleFollowUpdated(eventOrResponse) {
4400
4428
  });
4401
4429
  if (source.created_by.id === connectedUserId &&
4402
4430
  currentState.own_follows) {
4403
- const index = currentState.own_follows.findIndex((f) => f.source_feed.fid === follow.source_feed.fid);
4431
+ const index = currentState.own_follows.findIndex((f) => f.source_feed.feed === follow.source_feed.feed);
4404
4432
  if (index >= 0) {
4405
4433
  newState.own_follows = [...currentState.own_follows];
4406
4434
  newState.own_follows[index] = follow;
4407
4435
  }
4408
4436
  }
4409
- const index = currentState.followers?.findIndex((f) => f.source_feed.fid === follow.source_feed.fid) ?? -1;
4437
+ const index = currentState.followers?.findIndex((f) => f.source_feed.feed === follow.source_feed.feed) ?? -1;
4410
4438
  if (index >= 0) {
4411
4439
  newState.followers = [...newState.followers];
4412
4440
  newState.followers[index] = follow;
@@ -4894,6 +4922,14 @@ function handleNotificationFeedUpdated(event) {
4894
4922
  // TODO: handle notification feed updates
4895
4923
  }
4896
4924
 
4925
+ function handleWatchStarted() {
4926
+ this.state.partialNext({ watch: true });
4927
+ }
4928
+
4929
+ function handleWatchStopped() {
4930
+ this.state.partialNext({ watch: false });
4931
+ }
4932
+
4897
4933
  class Feed extends FeedApi {
4898
4934
  constructor(client, groupId, id, data, watch = false) {
4899
4935
  super(client, groupId, id);
@@ -4954,7 +4990,7 @@ class Feed extends FeedApi {
4954
4990
  this.on = this.eventDispatcher.on;
4955
4991
  this.off = this.eventDispatcher.off;
4956
4992
  this.state = new StateStore({
4957
- fid: `${groupId}:${id}`,
4993
+ feed: `${groupId}:${id}`,
4958
4994
  group_id: groupId,
4959
4995
  id,
4960
4996
  ...(data ?? {}),
@@ -4965,7 +5001,7 @@ class Feed extends FeedApi {
4965
5001
  });
4966
5002
  this.client = client;
4967
5003
  }
4968
- get fid() {
5004
+ get feed() {
4969
5005
  return `${this.group}:${this.id}`;
4970
5006
  }
4971
5007
  get currentState() {
@@ -5040,22 +5076,6 @@ class Feed extends FeedApi {
5040
5076
  });
5041
5077
  }
5042
5078
  }
5043
- /**
5044
- * @internal
5045
- */
5046
- handleWatchStopped() {
5047
- this.state.partialNext({
5048
- watch: false,
5049
- });
5050
- }
5051
- /**
5052
- * @internal
5053
- */
5054
- handleWatchStarted() {
5055
- this.state.partialNext({
5056
- watch: true,
5057
- });
5058
- }
5059
5079
  /**
5060
5080
  * Returns index of the provided comment object.
5061
5081
  */
@@ -5215,7 +5235,7 @@ class Feed extends FeedApi {
5215
5235
  entityId: comment.id,
5216
5236
  base: () => this.client.getCommentReplies({
5217
5237
  ...request,
5218
- comment_id: comment.id,
5238
+ id: comment.id,
5219
5239
  // use known sort first (prevents broken pagination)
5220
5240
  sort,
5221
5241
  next: currentNextCursor,
@@ -5255,7 +5275,7 @@ class Feed extends FeedApi {
5255
5275
  ...currentState,
5256
5276
  [type]: currentState[type] === undefined
5257
5277
  ? follows
5258
- : uniqueArrayMerge(currentState[type], follows, (follow) => `${follow.source_feed.fid}-${follow.target_feed.fid}`),
5278
+ : uniqueArrayMerge(currentState[type], follows, (follow) => `${follow.source_feed.feed}-${follow.target_feed.feed}`),
5259
5279
  [paginationKey]: {
5260
5280
  ...currentState[paginationKey],
5261
5281
  next: newNextCursor,
@@ -5348,7 +5368,7 @@ class Feed extends FeedApi {
5348
5368
  */
5349
5369
  async queryFollowers(request) {
5350
5370
  const filter = {
5351
- target_feed: this.fid,
5371
+ target_feed: this.feed,
5352
5372
  };
5353
5373
  const response = await this.client.queryFollows({
5354
5374
  filter,
@@ -5363,7 +5383,7 @@ class Feed extends FeedApi {
5363
5383
  */
5364
5384
  async queryFollowing(request) {
5365
5385
  const filter = {
5366
- source_feed: this.fid,
5386
+ source_feed: this.feed,
5367
5387
  };
5368
5388
  const response = await this.client.queryFollows({
5369
5389
  filter,
@@ -5372,18 +5392,18 @@ class Feed extends FeedApi {
5372
5392
  return response;
5373
5393
  }
5374
5394
  async follow(feedOrFid, options) {
5375
- const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.fid;
5395
+ const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.feed;
5376
5396
  const response = await this.client.follow({
5377
5397
  ...options,
5378
- source: this.fid,
5398
+ source: this.feed,
5379
5399
  target: fid,
5380
5400
  });
5381
5401
  return response;
5382
5402
  }
5383
5403
  async unfollow(feedOrFid) {
5384
- const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.fid;
5404
+ const fid = typeof feedOrFid === 'string' ? feedOrFid : feedOrFid.feed;
5385
5405
  const response = await this.client.unfollow({
5386
- source: this.fid,
5406
+ source: this.feed,
5387
5407
  target: fid,
5388
5408
  });
5389
5409
  return response;
@@ -5407,7 +5427,7 @@ class Feed extends FeedApi {
5407
5427
  addActivity(request) {
5408
5428
  return this.feedsApi.addActivity({
5409
5429
  ...request,
5410
- fids: [this.fid],
5430
+ feeds: [this.feed],
5411
5431
  });
5412
5432
  }
5413
5433
  handleWSEvent(event) {
@@ -5425,6 +5445,24 @@ class Feed extends FeedApi {
5425
5445
  }
5426
5446
  Feed.noop = () => { };
5427
5447
 
5448
+ function handleUserUpdated(event) {
5449
+ this.state.next((currentState) => {
5450
+ let newState;
5451
+ const { connected_user } = currentState;
5452
+ if (connected_user && connected_user.id === event.user.id) {
5453
+ newState ?? (newState = {
5454
+ ...currentState,
5455
+ });
5456
+ newState.connected_user = {
5457
+ ...connected_user,
5458
+ ...event.user,
5459
+ };
5460
+ }
5461
+ // TODO: update other users in user map (if/once applicable)
5462
+ return newState ?? currentState;
5463
+ });
5464
+ }
5465
+
5428
5466
  class FeedsClient extends FeedsApi {
5429
5467
  constructor(apiKey, options) {
5430
5468
  const tokenManager = new TokenManager();
@@ -5532,7 +5570,7 @@ class FeedsClient extends FeedsApi {
5532
5570
  if (this.activeFeeds[fid]) {
5533
5571
  const feed = this.activeFeeds[fid];
5534
5572
  if (watch && !feed.currentState.watch) {
5535
- feed.handleWatchStarted();
5573
+ handleWatchStarted.bind(feed)();
5536
5574
  }
5537
5575
  return feed;
5538
5576
  }
@@ -5568,7 +5606,7 @@ class FeedsClient extends FeedsApi {
5568
5606
  }
5569
5607
  else {
5570
5608
  for (const activeFeed of Object.values(this.activeFeeds)) {
5571
- activeFeed.handleWatchStopped();
5609
+ handleWatchStopped.bind(activeFeed)();
5572
5610
  }
5573
5611
  }
5574
5612
  break;
@@ -5648,6 +5686,10 @@ class FeedsClient extends FeedsApi {
5648
5686
  feeds.forEach((f) => f.handleWSEvent(event));
5649
5687
  break;
5650
5688
  }
5689
+ case 'user.updated': {
5690
+ handleUserUpdated.call(this, event);
5691
+ break;
5692
+ }
5651
5693
  default: {
5652
5694
  feed?.handleWSEvent(event);
5653
5695
  }
@@ -5673,7 +5715,7 @@ class FeedsClient extends FeedsApi {
5673
5715
  }
5674
5716
  }
5675
5717
  async queryFeeds(request) {
5676
- const response = await this.feedsQueryFeeds(request);
5718
+ const response = await this._queryFeeds(request);
5677
5719
  const feeds = response.feeds.map((f) => this.getOrCreateActiveFeed(f.group_id, f.id, f, request?.watch));
5678
5720
  return {
5679
5721
  feeds,
@@ -5685,7 +5727,10 @@ class FeedsClient extends FeedsApi {
5685
5727
  }
5686
5728
  async updateFollow(request) {
5687
5729
  const response = await super.updateFollow(request);
5688
- [response.follow.source_feed.fid, response.follow.target_feed.fid].forEach((fid) => {
5730
+ [
5731
+ response.follow.source_feed.feed,
5732
+ response.follow.target_feed.feed,
5733
+ ].forEach((fid) => {
5689
5734
  const feed = this.activeFeeds[fid];
5690
5735
  if (feed) {
5691
5736
  handleFollowUpdated.bind(feed)(response);
@@ -5696,7 +5741,10 @@ class FeedsClient extends FeedsApi {
5696
5741
  // For follow API endpoints we update the state after HTTP response to allow queryFeeds with watch: false
5697
5742
  async follow(request) {
5698
5743
  const response = await super.follow(request);
5699
- [response.follow.source_feed.fid, response.follow.target_feed.fid].forEach((fid) => {
5744
+ [
5745
+ response.follow.source_feed.feed,
5746
+ response.follow.target_feed.feed,
5747
+ ].forEach((fid) => {
5700
5748
  const feed = this.activeFeeds[fid];
5701
5749
  if (feed) {
5702
5750
  handleFollowCreated.bind(feed)(response);
@@ -5707,7 +5755,7 @@ class FeedsClient extends FeedsApi {
5707
5755
  async followBatch(request) {
5708
5756
  const response = await super.followBatch(request);
5709
5757
  response.follows.forEach((follow) => {
5710
- const feed = this.activeFeeds[follow.source_feed.fid];
5758
+ const feed = this.activeFeeds[follow.source_feed.feed];
5711
5759
  if (feed) {
5712
5760
  handleFollowCreated.bind(feed)({ follow });
5713
5761
  }
@@ -5732,7 +5780,7 @@ class FeedsClient extends FeedsApi {
5732
5780
  });
5733
5781
  const feed = this.activeFeeds[`${request.feed_group_id}:${request.feed_id}`];
5734
5782
  if (feed) {
5735
- feed.handleWatchStopped();
5783
+ handleWatchStopped.bind(feed)();
5736
5784
  }
5737
5785
  return response;
5738
5786
  }
@@ -6126,12 +6174,12 @@ const useReactionActions = ({ entity, type, }) => {
6126
6174
  const hasOwnReaction = useMemo(() => !!entity.own_reactions?.find((r) => r.type === type), [entity.own_reactions, type]);
6127
6175
  const addReaction = useStableCallback(async () => {
6128
6176
  await (isComment
6129
- ? client?.addCommentReaction({ comment_id: entity.id, type })
6177
+ ? client?.addCommentReaction({ id: entity.id, type })
6130
6178
  : client?.addReaction({ activity_id: entity.id, type }));
6131
6179
  });
6132
6180
  const removeReaction = useStableCallback(async () => {
6133
6181
  await (isComment
6134
- ? client?.deleteCommentReaction({ comment_id: entity.id, type })
6182
+ ? client?.deleteCommentReaction({ id: entity.id, type })
6135
6183
  : client?.deleteActivityReaction({
6136
6184
  activity_id: entity.id,
6137
6185
  type,