@stream-io/feeds-client 0.1.4 → 0.1.6

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 (62) hide show
  1. package/@react-bindings/hooks/client-state-hooks/index.ts +2 -0
  2. package/@react-bindings/hooks/feed-state-hooks/index.ts +7 -0
  3. package/@react-bindings/hooks/internal/index.ts +1 -0
  4. package/@react-bindings/hooks/util/index.ts +1 -0
  5. package/@react-bindings/index.ts +6 -3
  6. package/CHANGELOG.md +31 -0
  7. package/dist/@react-bindings/contexts/StreamFeedContext.d.ts +12 -0
  8. package/dist/@react-bindings/hooks/client-state-hooks/index.d.ts +2 -0
  9. package/dist/@react-bindings/hooks/client-state-hooks/useClientConnectedUser.d.ts +4 -0
  10. package/dist/@react-bindings/hooks/client-state-hooks/useWsConnectionState.d.ts +6 -0
  11. package/dist/@react-bindings/hooks/feed-state-hooks/index.d.ts +7 -0
  12. package/dist/@react-bindings/hooks/feed-state-hooks/useComments.d.ts +19 -0
  13. package/dist/@react-bindings/hooks/feed-state-hooks/useFeedActivities.d.ts +11 -0
  14. package/dist/@react-bindings/hooks/feed-state-hooks/useFeedMetadata.d.ts +12 -0
  15. package/dist/@react-bindings/hooks/feed-state-hooks/useFollowers.d.ts +16 -0
  16. package/dist/@react-bindings/hooks/feed-state-hooks/useFollowing.d.ts +16 -0
  17. package/dist/@react-bindings/hooks/feed-state-hooks/useOwnCapabilities.d.ts +33 -0
  18. package/dist/@react-bindings/hooks/feed-state-hooks/useOwnFollows.d.ts +8 -0
  19. package/dist/@react-bindings/hooks/internal/index.d.ts +1 -0
  20. package/dist/@react-bindings/hooks/internal/useStableCallback.d.ts +25 -0
  21. package/dist/@react-bindings/hooks/util/index.d.ts +1 -0
  22. package/dist/@react-bindings/hooks/util/useReactionActions.d.ts +17 -0
  23. package/dist/@react-bindings/index.d.ts +5 -3
  24. package/dist/@react-bindings/wrappers/StreamFeed.d.ts +12 -0
  25. package/dist/index-react-bindings.browser.cjs +521 -210
  26. package/dist/index-react-bindings.browser.cjs.map +1 -1
  27. package/dist/index-react-bindings.browser.js +514 -212
  28. package/dist/index-react-bindings.browser.js.map +1 -1
  29. package/dist/index-react-bindings.node.cjs +521 -210
  30. package/dist/index-react-bindings.node.cjs.map +1 -1
  31. package/dist/index-react-bindings.node.js +514 -212
  32. package/dist/index-react-bindings.node.js.map +1 -1
  33. package/dist/index.browser.cjs +212 -106
  34. package/dist/index.browser.cjs.map +1 -1
  35. package/dist/index.browser.js +209 -107
  36. package/dist/index.browser.js.map +1 -1
  37. package/dist/index.node.cjs +212 -106
  38. package/dist/index.node.cjs.map +1 -1
  39. package/dist/index.node.js +209 -107
  40. package/dist/index.node.js.map +1 -1
  41. package/dist/src/Feed.d.ts +7 -3
  42. package/dist/src/FeedsClient.d.ts +6 -5
  43. package/dist/src/types.d.ts +7 -0
  44. package/dist/src/utils.d.ts +9 -1
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +6 -2
  47. package/src/Feed.ts +214 -97
  48. package/src/FeedsClient.ts +22 -12
  49. package/src/common/ActivitySearchSource.ts +5 -5
  50. package/src/common/ApiClient.ts +1 -1
  51. package/src/common/FeedSearchSource.ts +1 -1
  52. package/src/common/Poll.ts +35 -10
  53. package/src/common/TokenManager.ts +2 -3
  54. package/src/common/UserSearchSource.ts +1 -1
  55. package/src/common/real-time/StableWSConnection.ts +4 -1
  56. package/src/state-updates/bookmark-utils.test.ts +134 -8
  57. package/src/state-updates/bookmark-utils.ts +17 -7
  58. package/src/types.ts +12 -1
  59. package/src/utils.ts +25 -1
  60. package/dist/@react-bindings/hooks/clientStateHooks.d.ts +0 -10
  61. package/dist/@react-bindings/hooks/useComments.d.ts +0 -12
  62. package/dist/@react-bindings/hooks/useOwnCapabilities.d.ts +0 -33
@@ -0,0 +1,2 @@
1
+ export * from './useClientConnectedUser';
2
+ export * from './useWsConnectionState';
@@ -0,0 +1,7 @@
1
+ export * from './useFeedActivities';
2
+ export * from './useComments';
3
+ export * from './useOwnCapabilities';
4
+ export * from './useFollowers';
5
+ export * from './useFollowing';
6
+ export * from './useFeedMetadata';
7
+ export * from './useOwnFollows';
@@ -0,0 +1 @@
1
+ export * from './useStableCallback';
@@ -0,0 +1 @@
1
+ export * from './useReactionActions'
@@ -1,15 +1,18 @@
1
1
  // Hooks
2
2
 
3
- export * from './hooks/useComments';
4
3
  export * from './hooks/useStateStore';
5
- export * from './hooks/useOwnCapabilities';
6
- export * from './hooks/clientStateHooks';
7
4
  export * from './hooks/useCreateFeedsClient';
8
5
 
6
+ export * from './hooks/client-state-hooks';
7
+ export * from './hooks/feed-state-hooks';
8
+ export * from './hooks/util';
9
+
9
10
  // Contexts
10
11
 
11
12
  export * from './contexts/StreamFeedsContext';
13
+ export * from './contexts/StreamFeedContext';
12
14
 
13
15
  // Wrappers
14
16
 
15
17
  export * from './wrappers/StreamFeeds';
18
+ export * from './wrappers/StreamFeed';
package/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.1.6](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.1.5...@stream-io/feeds-client-0.1.6) (2025-07-22)
6
+
7
+
8
+ * Run tests on CI ([#68](https://github.com/GetStream/stream-feeds-js/issues/68)) ([89b0a4b](https://github.com/GetStream/stream-feeds-js/commit/89b0a4bbce14af563380c17c73188e7e6f688e65))
9
+
10
+
11
+ ### Features
12
+
13
+ * following and user screens ([#71](https://github.com/GetStream/stream-feeds-js/issues/71)) ([7123f0a](https://github.com/GetStream/stream-feeds-js/commit/7123f0a2472ca59da697326e99253ebcbc7db147))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * bookmark is identified by activity id and folder id ([#70](https://github.com/GetStream/stream-feeds-js/issues/70)) ([97ee937](https://github.com/GetStream/stream-feeds-js/commit/97ee937a951de0d76ebf88a6083d3c67d4cef762))
19
+
20
+ ## [0.1.5](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.1.4...@stream-io/feeds-client-0.1.5) (2025-07-18)
21
+
22
+
23
+ ### Features
24
+
25
+ * add loadNextPage to useComments ([#57](https://github.com/GetStream/stream-feeds-js/issues/57)) ([fef823c](https://github.com/GetStream/stream-feeds-js/commit/fef823ceeb1d181f44607821cb46ec2458e199f3))
26
+ * add loadNextPageMembers ([#56](https://github.com/GetStream/stream-feeds-js/issues/56)) ([104dad0](https://github.com/GetStream/stream-feeds-js/commit/104dad0c1440ad26b41b76e1402ef0635e4358ac))
27
+ * add useFollowers & useFollowing ([#55](https://github.com/GetStream/stream-feeds-js/issues/55)) ([95bef04](https://github.com/GetStream/stream-feeds-js/commit/95bef04d2d921574fd1461cca0965963bc245910))
28
+ * feed context, file uploads and reactions ([#66](https://github.com/GetStream/stream-feeds-js/issues/66)) ([886123a](https://github.com/GetStream/stream-feeds-js/commit/886123aeb243c04d9ae82112634e826518e61089))
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * post useComments/useFollows merge fixes ([#64](https://github.com/GetStream/stream-feeds-js/issues/64)) ([2da2670](https://github.com/GetStream/stream-feeds-js/commit/2da2670d9575aba8b3f22d4cc019ae911a92edfb))
34
+ * replace `eol` with `checkHasAnotherPage` ([#67](https://github.com/GetStream/stream-feeds-js/issues/67)) ([f490e1f](https://github.com/GetStream/stream-feeds-js/commit/f490e1f16775adac46bccc979d5d0d2ce825f859))
35
+
5
36
  ## [0.1.4](https://github.com/GetStream/stream-feeds-js/compare/@stream-io/feeds-client-0.1.3...@stream-io/feeds-client-0.1.4) (2025-07-16)
6
37
 
7
38
 
@@ -0,0 +1,12 @@
1
+ import type { Feed } from '../../src/Feed';
2
+ export declare const StreamFeedContext: import("react").Context<Feed | undefined>;
3
+ /**
4
+ * The props for the StreamFeedProvider component.
5
+ */
6
+ export type StreamFeedContextProps = {
7
+ feed: Feed;
8
+ };
9
+ /**
10
+ * Hook to access the nearest Feed instance.
11
+ */
12
+ export declare const useFeedContext: () => Feed | undefined;
@@ -0,0 +1,2 @@
1
+ export * from './useClientConnectedUser';
2
+ export * from './useWsConnectionState';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * A React hook that returns the currently connected user on a `FeedsClient` instance and null otherwise.
3
+ */
4
+ export declare const useClientConnectedUser: () => import("../../..").OwnUser | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A React hook that returns the websocket connection state of `FeedsClient`.
3
+ */
4
+ export declare const useWsConnectionState: () => {
5
+ is_healthy: boolean | undefined;
6
+ };
@@ -0,0 +1,7 @@
1
+ export * from './useFeedActivities';
2
+ export * from './useComments';
3
+ export * from './useOwnCapabilities';
4
+ export * from './useFollowers';
5
+ export * from './useFollowing';
6
+ export * from './useFeedMetadata';
7
+ export * from './useOwnFollows';
@@ -0,0 +1,19 @@
1
+ import type { ActivityResponse, CommentResponse } from '../../../src/gen/models';
2
+ import type { CommentParent } from '../../../src/types';
3
+ import { Feed, FeedState } from '../../../src/Feed';
4
+ type UseCommentsReturnType<T extends ActivityResponse | CommentResponse> = {
5
+ comments: NonNullable<FeedState['comments_by_entity_id'][T['id']]>['comments'];
6
+ comments_pagination: NonNullable<FeedState['comments_by_entity_id'][T['id']]>['pagination'];
7
+ has_next_page: boolean;
8
+ is_loading_next_page: boolean;
9
+ loadNextPage: (request?: T extends CommentResponse ? Parameters<Feed['loadNextPageCommentReplies']>[1] : Parameters<Feed['loadNextPageActivityComments']>[1]) => Promise<void>;
10
+ };
11
+ export declare function useComments<T extends CommentParent>(_: {
12
+ feed: Feed;
13
+ parent: T;
14
+ }): UseCommentsReturnType<T>;
15
+ export declare function useComments<T extends CommentParent>(_: {
16
+ feed?: Feed;
17
+ parent: T;
18
+ }): UseCommentsReturnType<T> | undefined;
19
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Feed } from '../../../src/Feed';
2
+ /**
3
+ * A React hook that returns a reactive object containing the current activities,
4
+ * loading state and whether there is a next page to paginate to or not.
5
+ */
6
+ export declare const useFeedActivities: (feedFromProps?: Feed) => {
7
+ loadNextPage: import("../internal").StableCallback<[], Promise<void>>;
8
+ is_loading?: boolean | undefined;
9
+ has_next_page?: boolean | undefined;
10
+ activities?: import("../../..").ActivityResponse[] | undefined;
11
+ };
@@ -0,0 +1,12 @@
1
+ import { Feed } from '../../../src/Feed';
2
+ /**
3
+ * A React hook that returns a reactive object containing some often used
4
+ * metadata for a feed.
5
+ */
6
+ export declare const useFeedMetadata: (feedFromProps?: Feed) => {
7
+ created_by: import("../../..").UserResponse | undefined;
8
+ follower_count: number;
9
+ following_count: number;
10
+ created_at: Date | undefined;
11
+ updated_at: Date | undefined;
12
+ } | undefined;
@@ -0,0 +1,16 @@
1
+ import { Feed, FeedState } from '../../../src/Feed';
2
+ declare const selector: ({ follower_count, followers, followers_pagination, }: FeedState) => {
3
+ follower_count: number | undefined;
4
+ followers: import("../../..").FollowResponse[] | undefined;
5
+ followers_pagination: (import("../../..").PagerResponse & import("../../..").LoadingStates & {
6
+ sort?: import("../../..").SortParamRequest[];
7
+ }) | undefined;
8
+ };
9
+ type UseFollowersReturnType = ReturnType<typeof selector> & {
10
+ is_loading_next_page: boolean;
11
+ has_next_page: boolean;
12
+ loadNextPage: (...options: Parameters<Feed['loadNextPageFollowers']>) => Promise<void>;
13
+ };
14
+ export declare function useFollowers(feed: Feed): UseFollowersReturnType;
15
+ export declare function useFollowers(feed?: Feed): UseFollowersReturnType | undefined;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Feed, FeedState } from '../../../src/Feed';
2
+ declare const selector: ({ following_count, following, following_pagination, }: FeedState) => {
3
+ following_count: number | undefined;
4
+ following: import("../../..").FollowResponse[] | undefined;
5
+ following_pagination: (import("../../..").PagerResponse & import("../../..").LoadingStates & {
6
+ sort?: import("../../..").SortParamRequest[];
7
+ }) | undefined;
8
+ };
9
+ type UseFollowingReturnType = ReturnType<typeof selector> & {
10
+ is_loading_next_page: boolean;
11
+ has_next_page: boolean;
12
+ loadNextPage: (...options: Parameters<Feed['loadNextPageFollowers']>) => Promise<void>;
13
+ };
14
+ export declare function useFollowing(feed: Feed): UseFollowingReturnType;
15
+ export declare function useFollowing(feed?: Feed): UseFollowingReturnType | undefined;
16
+ export {};
@@ -0,0 +1,33 @@
1
+ import { Feed } from '../../../src/Feed';
2
+ export declare const useOwnCapabilities: (feedFromProps?: Feed) => {
3
+ can_add_activity: boolean;
4
+ can_add_activity_reaction: boolean;
5
+ can_add_comment: boolean;
6
+ can_add_comment_reaction: boolean;
7
+ can_bookmark_activity: boolean;
8
+ can_create_feed: boolean;
9
+ can_delete_bookmark: boolean;
10
+ can_delete_comment: boolean;
11
+ can_delete_feed: boolean;
12
+ can_edit_bookmark: boolean;
13
+ can_follow: boolean;
14
+ can_remove_activity: boolean;
15
+ can_remove_activity_reaction: boolean;
16
+ can_remove_comment_reaction: boolean;
17
+ can_unfollow: boolean;
18
+ can_update_feed: boolean;
19
+ can_invite_feed: boolean;
20
+ can_join_feed: boolean;
21
+ can_leave_feed: boolean;
22
+ can_manage_feed_group: boolean;
23
+ can_mark_activity: boolean;
24
+ can_pin_activity: boolean;
25
+ can_query_feed_members: boolean;
26
+ can_query_follows: boolean;
27
+ can_read_activities: boolean;
28
+ can_read_feed: boolean;
29
+ can_update_activity: boolean;
30
+ can_update_comment: boolean;
31
+ can_update_feed_followers: boolean;
32
+ can_update_feed_members: boolean;
33
+ };
@@ -0,0 +1,8 @@
1
+ import { Feed } from '../../../src/Feed';
2
+ /**
3
+ * A React hook that returns a reactive array of feeds that the current user
4
+ * owns and are following the respective feed that we are observing.
5
+ */
6
+ export declare const useOwnFollows: (feedFromProps?: Feed) => {
7
+ own_follows: import("../../..").FollowResponse[] | undefined;
8
+ } | undefined;
@@ -0,0 +1 @@
1
+ export * from './useStableCallback';
@@ -0,0 +1,25 @@
1
+ export type StableCallback<A extends unknown[], R> = (...args: A) => R;
2
+ /**
3
+ * A utility hook implementing a stable callback. It takes in an unstable method that
4
+ * is supposed to be invoked somewhere deeper in the DOM tree without making it
5
+ * change its reference every time the parent component rerenders. It will also return
6
+ * the value of the callback if it does return one.
7
+ * A common use-case would be having a function whose invocation depends on state
8
+ * somewhere high up in the DOM tree and wanting to use the same function deeper
9
+ * down, for example in a leaf node and simply using useCallback results in
10
+ * cascading dependency hell. If we wrap it in useStableCallback, we would be able
11
+ * to:
12
+ * - Use the same function as a dependency of another hook (since it is stable)
13
+ * - Still invoke it and get the latest state
14
+ *
15
+ * **Caveats:**
16
+ * - Never wrap a function that is supposed to return a React.ReactElement in
17
+ * useStableCallback, since React will not know that the DOM needs to be updated
18
+ * whenever the callback value changes (for example, renderItem from FlatList must
19
+ * never be wrapped in this hook)
20
+ * - Always prefer using a standard useCallback/stable function wherever possible
21
+ * (the purpose of useStableCallback is to bridge the gap between top level contexts
22
+ * and cascading rereders in downstream components - **not** as an escape hatch)
23
+ * @param callback - the callback we want to stabilize
24
+ */
25
+ export declare const useStableCallback: <A extends unknown[], R>(callback: StableCallback<A, R>) => StableCallback<A, R>;
@@ -0,0 +1 @@
1
+ export * from './useReactionActions';
@@ -0,0 +1,17 @@
1
+ import { CommentParent } from '../../../src/types';
2
+ /**
3
+ * A utility hook that takes in an entity and a reaction type, and creates reaction actions
4
+ * that can then be used on the UI. The entity can be either an ActivityResponse or a CommentResponse
5
+ * as the hook determines internally which APIs it is supposed to use, while taking the
6
+ * correct ownCapabilities into account.
7
+ * @param entity - The entity to which we want to add a reaction, can be either ActivityResponse or CommentResponse.
8
+ * @param type - The type of reaction we want to add or remove.
9
+ */
10
+ export declare const useReactionActions: ({ entity, type, }: {
11
+ entity: CommentParent;
12
+ type: string;
13
+ }) => {
14
+ addReaction: import("../internal").StableCallback<[], Promise<void>>;
15
+ removeReaction: import("../internal").StableCallback<[], Promise<void>>;
16
+ toggleReaction: import("../internal").StableCallback<[], Promise<void>>;
17
+ };
@@ -1,7 +1,9 @@
1
- export * from './hooks/useComments';
2
1
  export * from './hooks/useStateStore';
3
- export * from './hooks/useOwnCapabilities';
4
- export * from './hooks/clientStateHooks';
5
2
  export * from './hooks/useCreateFeedsClient';
3
+ export * from './hooks/client-state-hooks';
4
+ export * from './hooks/feed-state-hooks';
5
+ export * from './hooks/util';
6
6
  export * from './contexts/StreamFeedsContext';
7
+ export * from './contexts/StreamFeedContext';
7
8
  export * from './wrappers/StreamFeeds';
9
+ export * from './wrappers/StreamFeed';
@@ -0,0 +1,12 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import type { Feed } from '../../src/Feed';
3
+ /**
4
+ * The props for the StreamFeed component. It accepts a `Feed` instance.
5
+ */
6
+ export type StreamFeedProps = {
7
+ feed: Feed;
8
+ };
9
+ export declare const StreamFeed: {
10
+ ({ feed, children }: PropsWithChildren<StreamFeedProps>): import("react/jsx-runtime").JSX.Element;
11
+ displayName: string;
12
+ };