@stream-io/feeds-client 0.2.7 → 0.2.9
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.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/index.js +408 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/react-bindings.js +1368 -0
- package/dist/cjs/react-bindings.js.map +1 -0
- package/dist/es/index.mjs +398 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/es/react-bindings.mjs +1368 -0
- package/dist/es/react-bindings.mjs.map +1 -0
- package/dist/index-B0Mm2xFU.js +6492 -0
- package/dist/index-B0Mm2xFU.js.map +1 -0
- package/dist/index-rSXIDTdA.mjs +6476 -0
- package/dist/index-rSXIDTdA.mjs.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/bindings/index.d.ts +2 -0
- package/dist/types/bindings/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamFeedContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamFeedContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamFeedsContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamFeedsContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamSearchContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamSearchContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/contexts/StreamSearchResultsContext.d.ts +2 -1
- package/dist/types/bindings/react/contexts/StreamSearchResultsContext.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/client-state-hooks/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/index.d.ts.map +1 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/useClientConnectedUser.d.ts +5 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/useClientConnectedUser.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/client-state-hooks/useWsConnectionState.d.ts +1 -0
- package/dist/types/bindings/react/hooks/client-state-hooks/useWsConnectionState.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/feed-state-hooks/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useAggregatedActivities.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useComments.d.ts +2 -3
- package/dist/types/bindings/react/hooks/feed-state-hooks/useComments.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFeedActivities.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFeedActivities.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFeedMetadata.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFeedMetadata.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFollowers.d.ts +5 -4
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFollowers.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useFollowing.d.ts +5 -4
- package/dist/types/bindings/react/hooks/feed-state-hooks/useFollowing.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts +2 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts +2 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useNotificationStatus.d.ts +2 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useNotificationStatus.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useOwnCapabilities.d.ts +2 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/feed-state-hooks/useOwnFollows.d.ts +3 -2
- package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnFollows.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/internal/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/internal/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/internal/useStableCallback.d.ts +1 -0
- package/dist/types/bindings/react/hooks/internal/useStableCallback.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/search-state-hooks/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/search-state-hooks/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/search-state-hooks/useSearchQuery.d.ts +2 -1
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchQuery.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/search-state-hooks/useSearchResult.d.ts +2 -1
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchResult.d.ts.map +1 -0
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchSources.d.ts +5 -0
- package/dist/types/bindings/react/hooks/search-state-hooks/useSearchSources.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/useCreateFeedsClient.d.ts +2 -4
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/util/index.d.ts +1 -0
- package/dist/types/bindings/react/hooks/util/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/util/useBookmarkActions.d.ts +2 -1
- package/dist/types/bindings/react/hooks/util/useBookmarkActions.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/hooks/util/useReactionActions.d.ts +2 -1
- package/dist/types/bindings/react/hooks/util/useReactionActions.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/index.d.ts +2 -1
- package/dist/types/bindings/react/index.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamFeed.d.ts +2 -1
- package/dist/types/bindings/react/wrappers/StreamFeed.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamFeeds.d.ts +1 -0
- package/dist/types/bindings/react/wrappers/StreamFeeds.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamSearch.d.ts +2 -1
- package/dist/types/bindings/react/wrappers/StreamSearch.d.ts.map +1 -0
- package/dist/{@react-bindings → types/bindings/react}/wrappers/StreamSearchResults.d.ts +2 -1
- package/dist/types/bindings/react/wrappers/StreamSearchResults.d.ts.map +1 -0
- package/dist/{src → types}/common/ApiClient.d.ts +18 -0
- package/dist/types/common/ApiClient.d.ts.map +1 -0
- package/dist/{src → types}/common/ConnectionIdManager.d.ts +1 -0
- package/dist/types/common/ConnectionIdManager.d.ts.map +1 -0
- package/dist/{src → types}/common/EventDispatcher.d.ts +1 -0
- package/dist/types/common/EventDispatcher.d.ts.map +1 -0
- package/dist/{src → types}/common/Poll.d.ts +2 -1
- package/dist/types/common/Poll.d.ts.map +1 -0
- package/dist/{src → types}/common/TokenManager.d.ts +2 -0
- package/dist/types/common/TokenManager.d.ts.map +1 -0
- package/dist/{src → types}/common/gen-imports.d.ts +1 -0
- package/dist/types/common/gen-imports.d.ts.map +1 -0
- package/dist/{src → types}/common/rate-limit.d.ts +1 -0
- package/dist/types/common/rate-limit.d.ts.map +1 -0
- package/dist/{src → types}/common/real-time/StableWSConnection.d.ts +4 -4
- package/dist/types/common/real-time/StableWSConnection.d.ts.map +1 -0
- package/dist/{src → types}/common/real-time/event-models.d.ts +1 -0
- package/dist/types/common/real-time/event-models.d.ts.map +1 -0
- package/dist/{src → types}/common/search/ActivitySearchSource.d.ts +1 -0
- package/dist/types/common/search/ActivitySearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/BaseSearchSource.d.ts +2 -1
- package/dist/types/common/search/BaseSearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/FeedSearchSource.d.ts +1 -0
- package/dist/types/common/search/FeedSearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/SearchController.d.ts +2 -1
- package/dist/types/common/search/SearchController.d.ts.map +1 -0
- package/dist/{src → types}/common/search/UserSearchSource.d.ts +2 -1
- package/dist/types/common/search/UserSearchSource.d.ts.map +1 -0
- package/dist/{src → types}/common/search/index.d.ts +1 -0
- package/dist/types/common/search/index.d.ts.map +1 -0
- package/dist/{src → types}/common/search/types.d.ts +1 -0
- package/dist/types/common/search/types.d.ts.map +1 -0
- package/dist/{src → types}/common/types.d.ts +3 -1
- package/dist/types/common/types.d.ts.map +1 -0
- package/dist/{src → types}/common/utils.d.ts +1 -0
- package/dist/types/common/utils.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-added.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-deleted.d.ts +3 -2
- package/dist/types/feed/event-handlers/activity/handle-activity-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-marked.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-marked.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-pinned.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-pinned.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-added.d.ts +15 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-added.d.ts.map +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts +15 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-removed-from-feed.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-removed-from-feed.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-unpinned.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-unpinned.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/handle-activity-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/handle-activity-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/activity/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/activity/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/handle-bookmark-added.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/handle-bookmark-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/bookmark/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/bookmark/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-added.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-deleted.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-reaction.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-reaction.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/handle-comment-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/handle-comment-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/comment/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/comment/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed/handle-feed-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed/handle-feed-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/handle-feed-member-added.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-added.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/handle-feed-member-removed.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-removed.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/handle-feed-member-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/handle-feed-member-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/feed-member/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/feed-member/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/handle-follow-created.d.ts +3 -2
- package/dist/types/feed/event-handlers/follow/handle-follow-created.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/handle-follow-deleted.d.ts +2 -1
- package/dist/types/feed/event-handlers/follow/handle-follow-deleted.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/handle-follow-updated.d.ts +3 -2
- package/dist/types/feed/event-handlers/follow/handle-follow-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/follow/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/follow/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts +1 -0
- package/dist/types/feed/event-handlers/notification-feed/handle-notification-feed-updated.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/notification-feed/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/notification-feed/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/watch/handle-watch-started.d.ts +1 -0
- package/dist/types/feed/event-handlers/watch/handle-watch-started.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/watch/handle-watch-stopped.d.ts +1 -0
- package/dist/types/feed/event-handlers/watch/handle-watch-stopped.d.ts.map +1 -0
- package/dist/{src → types}/feed/event-handlers/watch/index.d.ts +1 -0
- package/dist/types/feed/event-handlers/watch/index.d.ts.map +1 -0
- package/dist/{src → types}/feed/feed.d.ts +9 -6
- package/dist/types/feed/feed.d.ts.map +1 -0
- package/dist/{src → types}/feed/index.d.ts +1 -0
- package/dist/types/feed/index.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/event-handlers/index.d.ts +1 -0
- package/dist/types/feeds-client/event-handlers/index.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/event-handlers/user/handle-user-updated.d.ts +1 -0
- package/dist/types/feeds-client/event-handlers/user/handle-user-updated.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/feeds-client.d.ts +18 -10
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -0
- package/dist/{src → types}/feeds-client/index.d.ts +1 -0
- package/dist/types/feeds-client/index.d.ts.map +1 -0
- package/dist/{src → types}/gen/feeds/FeedApi.d.ts +1 -0
- package/dist/types/gen/feeds/FeedApi.d.ts.map +1 -0
- package/dist/{src → types}/gen/feeds/FeedsApi.d.ts +1 -0
- package/dist/types/gen/feeds/FeedsApi.d.ts.map +1 -0
- package/dist/{src → types}/gen/model-decoders/decoders.d.ts +1 -0
- package/dist/types/gen/model-decoders/decoders.d.ts.map +1 -0
- package/dist/{src → types}/gen/model-decoders/event-decoder-mapping.d.ts +1 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts.map +1 -0
- package/dist/{src → types}/gen/models/index.d.ts +43 -2
- package/dist/types/gen/models/index.d.ts.map +1 -0
- package/dist/{src → types}/gen/moderation/ModerationApi.d.ts +1 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts.map +1 -0
- package/dist/{src → types}/gen-imports.d.ts +1 -0
- package/dist/types/gen-imports.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{src → types}/moderation-client.d.ts +1 -0
- package/dist/types/moderation-client.d.ts.map +1 -0
- package/dist/{src → types}/types-internal.d.ts +4 -0
- package/dist/types/types-internal.d.ts.map +1 -0
- package/dist/{src → types}/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/{src → types}/utils/check-has-another-page.d.ts +1 -0
- package/dist/types/utils/check-has-another-page.d.ts.map +1 -0
- package/dist/{src → types}/utils/constants.d.ts +1 -0
- package/dist/types/utils/constants.d.ts.map +1 -0
- package/dist/{src → types}/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/is-react-native.d.ts +5 -0
- package/dist/types/utils/is-react-native.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts +61 -0
- package/dist/types/utils/logger.d.ts.map +1 -0
- package/dist/types/utils/state-update-queue.d.ts +83 -0
- package/dist/types/utils/state-update-queue.d.ts.map +1 -0
- package/dist/types/utils/type-assertions.d.ts +12 -0
- package/dist/types/utils/type-assertions.d.ts.map +1 -0
- package/dist/{src → types}/utils/unique-array-merge.d.ts +1 -0
- package/dist/types/utils/unique-array-merge.d.ts.map +1 -0
- package/dist/{src → types}/utils/update-entity-in-array.d.ts +1 -0
- package/dist/types/utils/update-entity-in-array.d.ts.map +1 -0
- package/package.json +21 -33
- package/src/bindings/index.ts +1 -0
- package/src/bindings/react/contexts/StreamFeedContext.tsx +18 -0
- package/src/bindings/react/contexts/StreamFeedsContext.tsx +21 -0
- package/src/bindings/react/contexts/StreamSearchContext.tsx +18 -0
- package/src/bindings/react/contexts/StreamSearchResultsContext.tsx +20 -0
- package/src/bindings/react/hooks/client-state-hooks/useClientConnectedUser.ts +18 -0
- package/src/bindings/react/hooks/client-state-hooks/useWsConnectionState.ts +18 -0
- package/src/bindings/react/hooks/feed-state-hooks/useAggregatedActivities.ts +25 -0
- package/src/bindings/react/hooks/feed-state-hooks/useComments.ts +91 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFeedActivities.ts +36 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFeedMetadata.ts +28 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFollowers.ts +54 -0
- package/src/bindings/react/hooks/feed-state-hooks/useFollowing.ts +54 -0
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivityRead.ts +29 -0
- package/src/bindings/react/hooks/feed-state-hooks/useIsAggregatedActivitySeen.ts +28 -0
- package/src/bindings/react/hooks/feed-state-hooks/useNotificationStatus.ts +28 -0
- package/src/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.ts +70 -0
- package/src/bindings/react/hooks/feed-state-hooks/useOwnFollows.ts +18 -0
- package/src/bindings/react/hooks/internal/useStableCallback.ts +37 -0
- package/src/bindings/react/hooks/search-state-hooks/useSearchQuery.ts +14 -0
- package/src/bindings/react/hooks/search-state-hooks/useSearchResult.ts +36 -0
- package/src/bindings/react/hooks/search-state-hooks/useSearchSources.ts +17 -0
- package/src/bindings/react/hooks/useCreateFeedsClient.ts +73 -0
- package/src/bindings/react/hooks/util/useBookmarkActions.ts +40 -0
- package/src/bindings/react/hooks/util/useReactionActions.ts +56 -0
- package/{@react-bindings → src/bindings/react}/index.ts +1 -1
- package/src/bindings/react/wrappers/StreamFeed.tsx +23 -0
- package/src/bindings/react/wrappers/StreamFeeds.tsx +13 -0
- package/src/bindings/react/wrappers/StreamSearch.tsx +23 -0
- package/src/bindings/react/wrappers/StreamSearchResults.tsx +23 -0
- package/src/common/ApiClient.ts +86 -33
- package/src/common/EventDispatcher.ts +3 -6
- package/src/common/Poll.ts +1 -1
- package/src/common/TokenManager.ts +4 -0
- package/src/common/real-time/StableWSConnection.ts +64 -60
- package/src/common/search/BaseSearchSource.ts +11 -4
- package/src/common/search/SearchController.ts +4 -2
- package/src/common/types.ts +3 -2
- package/src/feed/event-handlers/activity/activity-utils.test.ts +40 -9
- package/src/feed/event-handlers/activity/handle-activity-added.test.ts +1 -1
- package/src/feed/event-handlers/activity/handle-activity-added.ts +7 -7
- package/src/feed/event-handlers/activity/handle-activity-deleted.ts +15 -12
- package/src/feed/event-handlers/activity/handle-activity-reaction-added.test.ts +101 -1
- package/src/feed/event-handlers/activity/handle-activity-reaction-added.ts +55 -29
- package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.test.ts +118 -1
- package/src/feed/event-handlers/activity/handle-activity-reaction-deleted.ts +59 -32
- package/src/feed/event-handlers/activity/handle-activity-removed-from-feed.ts +1 -1
- package/src/feed/event-handlers/follow/follow-state-update-queue.test.ts +219 -0
- package/src/feed/event-handlers/follow/handle-follow-created.ts +7 -2
- package/src/feed/event-handlers/follow/handle-follow-deleted.ts +5 -0
- package/src/feed/event-handlers/follow/handle-follow-updated.test.ts +0 -43
- package/src/feed/event-handlers/follow/handle-follow-updated.ts +7 -2
- package/src/feed/feed.test.ts +90 -0
- package/src/feed/feed.ts +25 -4
- package/src/feeds-client/feeds-client.ts +35 -4
- package/src/gen/feeds/FeedsApi.ts +2 -0
- package/src/gen/model-decoders/decoders.ts +22 -0
- package/src/gen/models/index.ts +71 -3
- package/src/index.ts +9 -0
- package/src/test-utils/response-generators.ts +12 -3
- package/src/types-internal.ts +4 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/is-react-native.ts +7 -0
- package/src/utils/logger.ts +18 -0
- package/src/utils/state-update-queue.test.ts +85 -9
- package/src/utils/state-update-queue.ts +104 -11
- package/src/utils/type-assertions.ts +22 -1
- package/dist/@react-bindings/hooks/client-state-hooks/useClientConnectedUser.d.ts +0 -4
- package/dist/@react-bindings/hooks/search-state-hooks/useSearchSources.d.ts +0 -4
- package/dist/@react-bindings/hooks/useStateStore.d.ts +0 -3
- package/dist/index-react-bindings.browser.cjs +0 -6607
- package/dist/index-react-bindings.browser.cjs.map +0 -1
- package/dist/index-react-bindings.browser.js +0 -6574
- package/dist/index-react-bindings.browser.js.map +0 -1
- package/dist/index-react-bindings.node.cjs +0 -6607
- package/dist/index-react-bindings.node.cjs.map +0 -1
- package/dist/index-react-bindings.node.js +0 -6574
- package/dist/index-react-bindings.node.js.map +0 -1
- package/dist/index.browser.cjs +0 -6578
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.js +0 -6551
- package/dist/index.browser.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.node.cjs +0 -6578
- package/dist/index.node.cjs.map +0 -1
- package/dist/index.node.js +0 -6551
- package/dist/index.node.js.map +0 -1
- package/dist/src/common/StateStore.d.ts +0 -125
- package/dist/src/feed/event-handlers/activity/handle-activity-reaction-added.d.ts +0 -12
- package/dist/src/feed/event-handlers/activity/handle-activity-reaction-deleted.d.ts +0 -12
- package/dist/src/utils/state-update-queue.d.ts +0 -6
- package/dist/src/utils/type-assertions.d.ts +0 -7
- package/index.ts +0 -9
- package/src/common/StateStore.ts +0 -332
- /package/{@react-bindings → src/bindings/react}/hooks/client-state-hooks/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/feed-state-hooks/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/internal/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/search-state-hooks/index.ts +0 -0
- /package/{@react-bindings → src/bindings/react}/hooks/util/index.ts +0 -0
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
retryInterval,
|
|
7
7
|
sleep,
|
|
8
8
|
} from '../utils';
|
|
9
|
-
import type { LogLevel } from '../types';
|
|
10
9
|
import type { UserRequest } from '../../gen/models';
|
|
11
10
|
import { TokenManager } from '../TokenManager';
|
|
12
11
|
import { EventDispatcher } from '../EventDispatcher';
|
|
13
12
|
import { ConnectionIdManager } from '../ConnectionIdManager';
|
|
14
13
|
import { ConnectedEvent } from './event-models';
|
|
14
|
+
import { getLogger } from '../../utils/logger';
|
|
15
15
|
|
|
16
16
|
// Type guards to check WebSocket error type
|
|
17
17
|
const isCloseEvent = (
|
|
@@ -78,6 +78,7 @@ export class StableWSConnection {
|
|
|
78
78
|
wsID: number;
|
|
79
79
|
private readonly dispatcher = new EventDispatcher();
|
|
80
80
|
private readonly clientId: string;
|
|
81
|
+
private readonly logger = getLogger('stable-ws-connection');
|
|
81
82
|
|
|
82
83
|
constructor(
|
|
83
84
|
private readonly config: WSConfig,
|
|
@@ -111,11 +112,6 @@ export class StableWSConnection {
|
|
|
111
112
|
addConnectionEventListeners(this.onlineStatusChanged);
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
_log = (msg: string, extra: any = {}, level: LogLevel = 'info') => {
|
|
115
|
-
// TODO: fix logging
|
|
116
|
-
console.log(msg, extra, level);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
115
|
on = this.dispatcher.on;
|
|
120
116
|
off = this.dispatcher.off;
|
|
121
117
|
offAll = this.dispatcher.offAll;
|
|
@@ -126,6 +122,7 @@ export class StableWSConnection {
|
|
|
126
122
|
* @return {ConnectAPIResponse<ConnectedEvent>} Promise that completes once the first health check message is received
|
|
127
123
|
*/
|
|
128
124
|
async connect(timeout = 15000) {
|
|
125
|
+
const logger = this.logger.withExtraTags('connect');
|
|
129
126
|
if (this.isConnecting) {
|
|
130
127
|
throw Error(
|
|
131
128
|
`You've called connect twice, can only attempt 1 connection at the time`,
|
|
@@ -142,10 +139,7 @@ export class StableWSConnection {
|
|
|
142
139
|
const healthCheck = await this._connect();
|
|
143
140
|
this.consecutiveFailures = 0;
|
|
144
141
|
|
|
145
|
-
|
|
146
|
-
`connect() - Established ws connection with healthcheck`,
|
|
147
|
-
healthCheck,
|
|
148
|
-
);
|
|
142
|
+
logger.debug(`Established ws connection with healthcheck`, healthCheck);
|
|
149
143
|
} catch (error) {
|
|
150
144
|
this.isHealthy = false;
|
|
151
145
|
this.consecutiveFailures += 1;
|
|
@@ -155,8 +149,8 @@ export class StableWSConnection {
|
|
|
155
149
|
error.code === KnownCodes.TOKEN_EXPIRED &&
|
|
156
150
|
!this.tokenManager.isStatic()
|
|
157
151
|
) {
|
|
158
|
-
|
|
159
|
-
'
|
|
152
|
+
logger.debug(
|
|
153
|
+
'WS failure due to expired token, so going to try to reload token and reconnect',
|
|
160
154
|
);
|
|
161
155
|
void this._reconnect({ refreshToken: true });
|
|
162
156
|
} else {
|
|
@@ -227,9 +221,8 @@ export class StableWSConnection {
|
|
|
227
221
|
*
|
|
228
222
|
*/
|
|
229
223
|
disconnect(timeout?: number) {
|
|
230
|
-
this.
|
|
231
|
-
|
|
232
|
-
);
|
|
224
|
+
const logger = this.logger.withExtraTags('disconnect');
|
|
225
|
+
logger.debug(`Closing the WS connection for wsID ${this.wsID}`);
|
|
233
226
|
|
|
234
227
|
this.wsID += 1;
|
|
235
228
|
this.isConnecting = false;
|
|
@@ -262,8 +255,8 @@ export class StableWSConnection {
|
|
|
262
255
|
if (ws?.close && ws.readyState === ws.OPEN) {
|
|
263
256
|
isClosedPromise = new Promise((resolve) => {
|
|
264
257
|
const onclose = (event: CloseEvent) => {
|
|
265
|
-
|
|
266
|
-
`
|
|
258
|
+
logger.debug(
|
|
259
|
+
`resolving isClosedPromise ${
|
|
267
260
|
event ? 'with' : 'without'
|
|
268
261
|
} close frame`,
|
|
269
262
|
{ event },
|
|
@@ -277,18 +270,14 @@ export class StableWSConnection {
|
|
|
277
270
|
setTimeout(onclose, timeout ?? 1000);
|
|
278
271
|
});
|
|
279
272
|
|
|
280
|
-
|
|
281
|
-
`disconnect() - Manually closed connection by calling client.disconnect()`,
|
|
282
|
-
);
|
|
273
|
+
logger.debug(`Manually closed connection by calling client.disconnect()`);
|
|
283
274
|
|
|
284
275
|
ws.close(
|
|
285
276
|
KnownCodes.WS_CLOSED_SUCCESS,
|
|
286
277
|
'Manually closed connection by calling client.disconnect()',
|
|
287
278
|
);
|
|
288
279
|
} else {
|
|
289
|
-
|
|
290
|
-
`disconnect() - ws connection doesn't exist or it is already closed.`,
|
|
291
|
-
);
|
|
280
|
+
logger.debug(`WS connection doesn't exist or it is already closed.`);
|
|
292
281
|
isClosedPromise = Promise.resolve();
|
|
293
282
|
}
|
|
294
283
|
|
|
@@ -303,12 +292,13 @@ export class StableWSConnection {
|
|
|
303
292
|
* @return {ConnectAPIResponse<ConnectedEvent>} Promise that completes once the first health check message is received
|
|
304
293
|
*/
|
|
305
294
|
async _connect() {
|
|
295
|
+
const logger = this.logger.withExtraTags('_connect');
|
|
306
296
|
if (this.isConnecting) return; // simply ignore _connect if it's currently trying to connect
|
|
307
297
|
this.isConnecting = true;
|
|
308
298
|
this.requestID = randomId();
|
|
309
299
|
let isTokenReady = false;
|
|
310
300
|
try {
|
|
311
|
-
|
|
301
|
+
logger.debug(`waiting for token`);
|
|
312
302
|
await this.tokenManager.getToken();
|
|
313
303
|
isTokenReady = true;
|
|
314
304
|
} catch (_) {
|
|
@@ -317,15 +307,13 @@ export class StableWSConnection {
|
|
|
317
307
|
|
|
318
308
|
try {
|
|
319
309
|
if (!isTokenReady) {
|
|
320
|
-
|
|
321
|
-
`_connect() - tokenProvider failed before, so going to retry`,
|
|
322
|
-
);
|
|
310
|
+
logger.debug(`tokenProvider failed before, so going to retry`);
|
|
323
311
|
await this.tokenManager.loadToken();
|
|
324
312
|
}
|
|
325
313
|
|
|
326
314
|
this._setupConnectionPromise();
|
|
327
315
|
const wsURL = this.config.baseUrl;
|
|
328
|
-
|
|
316
|
+
logger.debug(`Connecting to ${wsURL}`, {
|
|
329
317
|
wsURL,
|
|
330
318
|
requestID: this.requestID,
|
|
331
319
|
});
|
|
@@ -342,7 +330,6 @@ export class StableWSConnection {
|
|
|
342
330
|
}
|
|
343
331
|
} catch (err) {
|
|
344
332
|
this.isConnecting = false;
|
|
345
|
-
this._log(`_connect() - Error - `, err);
|
|
346
333
|
throw err;
|
|
347
334
|
}
|
|
348
335
|
}
|
|
@@ -358,11 +345,13 @@ export class StableWSConnection {
|
|
|
358
345
|
async _reconnect(
|
|
359
346
|
options: { interval?: number; refreshToken?: boolean } = {},
|
|
360
347
|
): Promise<void> {
|
|
361
|
-
this.
|
|
348
|
+
const logger = this.logger.withExtraTags('_reconnect');
|
|
349
|
+
|
|
350
|
+
logger.debug('Initiating the reconnect');
|
|
362
351
|
|
|
363
352
|
// only allow 1 connection at the time
|
|
364
353
|
if (this.isConnecting || this.isHealthy) {
|
|
365
|
-
|
|
354
|
+
logger.debug('Abort (1) since already connecting or healthy');
|
|
366
355
|
return;
|
|
367
356
|
}
|
|
368
357
|
|
|
@@ -378,16 +367,16 @@ export class StableWSConnection {
|
|
|
378
367
|
// Check once again if by some other call to _reconnect is active or connection is
|
|
379
368
|
// already restored, then no need to proceed.
|
|
380
369
|
if (this.isConnecting || this.isHealthy) {
|
|
381
|
-
|
|
370
|
+
logger.debug('Abort (2) since already connecting or healthy');
|
|
382
371
|
return;
|
|
383
372
|
}
|
|
384
373
|
|
|
385
374
|
if (this.isDisconnected) {
|
|
386
|
-
|
|
375
|
+
logger.debug('Abort (3) since disconnect() is called');
|
|
387
376
|
return;
|
|
388
377
|
}
|
|
389
378
|
|
|
390
|
-
|
|
379
|
+
logger.debug('Destroying current WS connection');
|
|
391
380
|
|
|
392
381
|
// cleanup the old connection
|
|
393
382
|
this._destroyCurrentWSConnection();
|
|
@@ -398,9 +387,9 @@ export class StableWSConnection {
|
|
|
398
387
|
|
|
399
388
|
try {
|
|
400
389
|
await this._connect();
|
|
401
|
-
|
|
390
|
+
// logger.debug('Waiting for recoverCallBack');
|
|
402
391
|
// await this.client.recoverState();
|
|
403
|
-
|
|
392
|
+
// logger.debug('Finished recoverCallBack');
|
|
404
393
|
|
|
405
394
|
this.consecutiveFailures = 0;
|
|
406
395
|
} catch (error: any) {
|
|
@@ -410,8 +399,8 @@ export class StableWSConnection {
|
|
|
410
399
|
error.code === KnownCodes.TOKEN_EXPIRED &&
|
|
411
400
|
!this.tokenManager.isStatic()
|
|
412
401
|
) {
|
|
413
|
-
|
|
414
|
-
'
|
|
402
|
+
logger.debug(
|
|
403
|
+
'WS failure due to expired token, so going to try to reload token and reconnect',
|
|
415
404
|
);
|
|
416
405
|
|
|
417
406
|
return await this._reconnect({ refreshToken: true });
|
|
@@ -419,12 +408,12 @@ export class StableWSConnection {
|
|
|
419
408
|
|
|
420
409
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
421
410
|
if (error.isWSFailure) {
|
|
422
|
-
|
|
411
|
+
logger.debug('WS failure, so going to try to reconnect');
|
|
423
412
|
|
|
424
413
|
void this._reconnect();
|
|
425
414
|
}
|
|
426
415
|
}
|
|
427
|
-
|
|
416
|
+
logger.debug('== END ==');
|
|
428
417
|
}
|
|
429
418
|
|
|
430
419
|
/**
|
|
@@ -434,9 +423,11 @@ export class StableWSConnection {
|
|
|
434
423
|
*
|
|
435
424
|
*/
|
|
436
425
|
onlineStatusChanged = (event: Event) => {
|
|
426
|
+
const logger = this.logger.withExtraTags('onlineStatusChanged');
|
|
427
|
+
|
|
437
428
|
if (event.type === 'offline') {
|
|
438
429
|
// mark the connection as down
|
|
439
|
-
|
|
430
|
+
logger.debug('Status changing to offline');
|
|
440
431
|
// we know that the app is offline so dispatch the unhealthy connection event immediately
|
|
441
432
|
this._setHealth(false, true);
|
|
442
433
|
} else if (event.type === 'online') {
|
|
@@ -444,9 +435,7 @@ export class StableWSConnection {
|
|
|
444
435
|
// We check this.isHealthy, not sure if it's always
|
|
445
436
|
// smart to create a new WS connection if the old one is still up and running.
|
|
446
437
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
447
|
-
this.
|
|
448
|
-
`onlineStatusChanged() - Status changing to online. isHealthy: ${this.isHealthy}`,
|
|
449
|
-
);
|
|
438
|
+
logger.debug(`Status changing to online. isHealthy: ${this.isHealthy}`);
|
|
450
439
|
if (!this.isHealthy) {
|
|
451
440
|
void this._reconnect({ interval: 10 });
|
|
452
441
|
}
|
|
@@ -454,17 +443,19 @@ export class StableWSConnection {
|
|
|
454
443
|
};
|
|
455
444
|
|
|
456
445
|
onopen = async (wsID: number) => {
|
|
446
|
+
const logger = this.logger.withExtraTags('onopen');
|
|
447
|
+
|
|
457
448
|
if (this.wsID !== wsID) return;
|
|
458
449
|
|
|
459
450
|
const user = this.config.user;
|
|
460
451
|
if (!user) {
|
|
461
|
-
|
|
452
|
+
logger.warn(`User not set, can't connect to WS`);
|
|
462
453
|
return;
|
|
463
454
|
}
|
|
464
455
|
|
|
465
456
|
const token = await this.tokenManager.getToken();
|
|
466
457
|
if (!token) {
|
|
467
|
-
|
|
458
|
+
logger.warn(`Token not set, can't connect authenticate`);
|
|
468
459
|
return;
|
|
469
460
|
}
|
|
470
461
|
|
|
@@ -481,13 +472,15 @@ export class StableWSConnection {
|
|
|
481
472
|
|
|
482
473
|
this.authenticationSent = true;
|
|
483
474
|
this.ws?.send(JSON.stringify(authMessage));
|
|
484
|
-
|
|
475
|
+
logger.debug('onopen callback', { wsID });
|
|
485
476
|
};
|
|
486
477
|
|
|
487
478
|
onmessage = (wsID: number, event: MessageEvent) => {
|
|
479
|
+
const logger = this.logger.withExtraTags('onmessage');
|
|
480
|
+
|
|
488
481
|
if (this.wsID !== wsID) return;
|
|
489
482
|
|
|
490
|
-
|
|
483
|
+
logger.debug('onmessage callback', {
|
|
491
484
|
event: { ...event, data: JSON.parse(event.data) },
|
|
492
485
|
wsID,
|
|
493
486
|
});
|
|
@@ -531,8 +524,8 @@ export class StableWSConnection {
|
|
|
531
524
|
this.consecutiveFailures += 1;
|
|
532
525
|
if (code === KnownCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic()) {
|
|
533
526
|
clearTimeout(this.connectionCheckTimeoutRef);
|
|
534
|
-
|
|
535
|
-
'
|
|
527
|
+
logger.debug(
|
|
528
|
+
'WS failure due to expired token, so going to try to reload token and reconnect',
|
|
536
529
|
);
|
|
537
530
|
void this._reconnect({ refreshToken: true });
|
|
538
531
|
}
|
|
@@ -546,15 +539,20 @@ export class StableWSConnection {
|
|
|
546
539
|
};
|
|
547
540
|
|
|
548
541
|
onclose = (wsID: number, event: CloseEvent) => {
|
|
542
|
+
const logger = this.logger.withExtraTags('onclose');
|
|
543
|
+
|
|
549
544
|
if (this.wsID !== wsID) return;
|
|
550
545
|
|
|
551
|
-
|
|
546
|
+
logger.debug('onclose callback - ' + event.code, {
|
|
547
|
+
event,
|
|
548
|
+
wsID,
|
|
549
|
+
});
|
|
552
550
|
|
|
553
551
|
if (event.code === KnownCodes.WS_CLOSED_SUCCESS) {
|
|
554
552
|
// this is a permanent error raised by stream..
|
|
555
553
|
// usually caused by invalid auth details
|
|
556
554
|
this.rejectPromise?.(this._errorFromWSEvent(event));
|
|
557
|
-
|
|
555
|
+
logger.debug(`WS connection reject with error ${event.reason}`, {
|
|
558
556
|
event,
|
|
559
557
|
});
|
|
560
558
|
} else {
|
|
@@ -565,7 +563,7 @@ export class StableWSConnection {
|
|
|
565
563
|
|
|
566
564
|
this.rejectPromise?.(this._errorFromWSEvent(event));
|
|
567
565
|
|
|
568
|
-
|
|
566
|
+
logger.debug(`WS connection closed. Calling reconnect ...`, {
|
|
569
567
|
event,
|
|
570
568
|
});
|
|
571
569
|
|
|
@@ -582,7 +580,11 @@ export class StableWSConnection {
|
|
|
582
580
|
this._setHealth(false);
|
|
583
581
|
this.isConnecting = false;
|
|
584
582
|
this.rejectPromise?.(this._errorFromWSEvent(event));
|
|
585
|
-
this.
|
|
583
|
+
this.logger
|
|
584
|
+
.withExtraTags('onerror')
|
|
585
|
+
.debug(`WS connection resulted into error`, {
|
|
586
|
+
event,
|
|
587
|
+
});
|
|
586
588
|
|
|
587
589
|
void this._reconnect();
|
|
588
590
|
};
|
|
@@ -661,11 +663,11 @@ export class StableWSConnection {
|
|
|
661
663
|
}
|
|
662
664
|
|
|
663
665
|
// Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
664
|
-
this.
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
666
|
+
this.logger
|
|
667
|
+
.withExtraTags('_errorFromWSEvent')
|
|
668
|
+
.debug(`WS failed with code ${code}`, {
|
|
669
|
+
event,
|
|
670
|
+
});
|
|
669
671
|
|
|
670
672
|
const error = new Error(
|
|
671
673
|
`WS failed with code ${code} and reason - ${message}`,
|
|
@@ -755,7 +757,9 @@ export class StableWSConnection {
|
|
|
755
757
|
this.lastEvent &&
|
|
756
758
|
now.getTime() - this.lastEvent.getTime() > this.connectionCheckTimeout
|
|
757
759
|
) {
|
|
758
|
-
this.
|
|
760
|
+
this.logger
|
|
761
|
+
.withExtraTags('scheduleConnectionCheck')
|
|
762
|
+
.debug('going to reconnect');
|
|
759
763
|
this._setHealth(false);
|
|
760
764
|
void this._reconnect();
|
|
761
765
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
2
|
import { debounce, type DebouncedFunc } from '../utils';
|
|
3
3
|
import type {
|
|
4
4
|
QueryReturnValue,
|
|
@@ -10,7 +10,9 @@ import type {
|
|
|
10
10
|
export type DebounceOptions = {
|
|
11
11
|
debounceMs: number;
|
|
12
12
|
};
|
|
13
|
-
type DebouncedExecQueryFunction = DebouncedFunc<
|
|
13
|
+
type DebouncedExecQueryFunction = DebouncedFunc<
|
|
14
|
+
(searchString?: string) => Promise<void>
|
|
15
|
+
>;
|
|
14
16
|
|
|
15
17
|
interface ISearchSource<T = any> {
|
|
16
18
|
activate(): void;
|
|
@@ -64,7 +66,10 @@ abstract class BaseSearchSourceBase<T> implements ISearchSource<T> {
|
|
|
64
66
|
abstract readonly type: SearchSourceType;
|
|
65
67
|
|
|
66
68
|
protected constructor(options?: SearchSourceOptions) {
|
|
67
|
-
const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
|
|
69
|
+
const { pageSize, allowEmptySearchString, resetOnNewSearchQuery } = {
|
|
70
|
+
...DEFAULT_SEARCH_SOURCE_OPTIONS,
|
|
71
|
+
...options,
|
|
72
|
+
};
|
|
68
73
|
this.pageSize = pageSize;
|
|
69
74
|
this.allowEmptySearchString = allowEmptySearchString;
|
|
70
75
|
this.resetOnNewSearchQuery = resetOnNewSearchQuery;
|
|
@@ -141,7 +146,9 @@ abstract class BaseSearchSourceBase<T> implements ISearchSource<T> {
|
|
|
141
146
|
);
|
|
142
147
|
};
|
|
143
148
|
|
|
144
|
-
protected getStateBeforeFirstQuery(
|
|
149
|
+
protected getStateBeforeFirstQuery(
|
|
150
|
+
newSearchString: string,
|
|
151
|
+
): SearchSourceState<T> {
|
|
145
152
|
const initialState = this.initialState;
|
|
146
153
|
const oldItems = this.items;
|
|
147
154
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
2
|
import type { SearchSource } from './BaseSearchSource';
|
|
3
3
|
|
|
4
4
|
export type SearchControllerState = {
|
|
@@ -114,7 +114,9 @@ export class SearchController {
|
|
|
114
114
|
this.state.partialNext({
|
|
115
115
|
searchQuery,
|
|
116
116
|
});
|
|
117
|
-
await Promise.all(
|
|
117
|
+
await Promise.all(
|
|
118
|
+
searchedSources.map((source) => source.search(searchQuery)),
|
|
119
|
+
);
|
|
118
120
|
};
|
|
119
121
|
|
|
120
122
|
cancelSearchQueries = () => {
|
package/src/common/types.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { ConfigureLoggersOptions } from '../utils/logger';
|
|
2
|
+
|
|
1
3
|
export * from './search/types';
|
|
2
4
|
|
|
3
5
|
export type FeedsClientOptions = {
|
|
4
6
|
base_url?: string;
|
|
5
7
|
timeout?: number;
|
|
8
|
+
configure_loggers_options?: ConfigureLoggersOptions;
|
|
6
9
|
};
|
|
7
10
|
|
|
8
11
|
export type RateLimit = {
|
|
@@ -34,8 +37,6 @@ export class StreamApiError extends Error {
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
|
38
|
-
|
|
39
40
|
export interface NetworkChangedEvent {
|
|
40
41
|
type: 'network.changed';
|
|
41
42
|
online: boolean;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
1
|
+
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
2
|
import { ActivityResponse } from '../../../gen/models';
|
|
3
|
+
import { FeedsClient } from '../../../feeds-client';
|
|
3
4
|
import {
|
|
4
|
-
addActivitiesToState,
|
|
5
|
+
addActivitiesToState as addActivitiesToStateOriginal,
|
|
5
6
|
updateActivityInState,
|
|
6
|
-
removeActivityFromState,
|
|
7
|
+
removeActivityFromState as removeActivityFromStateOriginal,
|
|
7
8
|
} from './';
|
|
8
9
|
import {
|
|
9
10
|
generateActivityResponse,
|
|
@@ -11,6 +12,36 @@ import {
|
|
|
11
12
|
} from '../../../test-utils';
|
|
12
13
|
|
|
13
14
|
describe('activity-utils', () => {
|
|
15
|
+
let addActivitiesToState: OmitThisParameter<
|
|
16
|
+
typeof addActivitiesToStateOriginal
|
|
17
|
+
>;
|
|
18
|
+
let removeActivityFromState: OmitThisParameter<
|
|
19
|
+
typeof removeActivityFromStateOriginal
|
|
20
|
+
>;
|
|
21
|
+
let prehydrateActivities: (
|
|
22
|
+
newActivities: ActivityResponse[],
|
|
23
|
+
) => ActivityResponse[];
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
const client = new FeedsClient('mock-api-key');
|
|
27
|
+
const feed = client.feed('some', 'feed');
|
|
28
|
+
|
|
29
|
+
addActivitiesToState = addActivitiesToStateOriginal.bind(feed);
|
|
30
|
+
removeActivityFromState = removeActivityFromStateOriginal.bind(feed);
|
|
31
|
+
|
|
32
|
+
prehydrateActivities = (newActivities: ActivityResponse[]) => {
|
|
33
|
+
const existingActivities = [...newActivities];
|
|
34
|
+
|
|
35
|
+
feed.state.partialNext({ activities: existingActivities });
|
|
36
|
+
|
|
37
|
+
return existingActivities;
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
vi.resetAllMocks();
|
|
43
|
+
});
|
|
44
|
+
|
|
14
45
|
describe('addActivitiesToState', () => {
|
|
15
46
|
const activity1 = generateActivityResponse({ id: 'activity1' });
|
|
16
47
|
const activity2 = generateActivityResponse({ id: 'activity2' });
|
|
@@ -24,7 +55,7 @@ describe('activity-utils', () => {
|
|
|
24
55
|
});
|
|
25
56
|
|
|
26
57
|
it('should add activities to the start of existing activities', () => {
|
|
27
|
-
const existingActivities = [activity2];
|
|
58
|
+
const existingActivities = prehydrateActivities([activity2]);
|
|
28
59
|
const result = addActivitiesToState(
|
|
29
60
|
[activity1],
|
|
30
61
|
existingActivities,
|
|
@@ -38,7 +69,7 @@ describe('activity-utils', () => {
|
|
|
38
69
|
});
|
|
39
70
|
|
|
40
71
|
it('should add activities to the end of existing activities', () => {
|
|
41
|
-
const existingActivities = [activity1];
|
|
72
|
+
const existingActivities = prehydrateActivities([activity1]);
|
|
42
73
|
const result = addActivitiesToState(
|
|
43
74
|
[activity2],
|
|
44
75
|
existingActivities,
|
|
@@ -52,7 +83,7 @@ describe('activity-utils', () => {
|
|
|
52
83
|
});
|
|
53
84
|
|
|
54
85
|
it('should not add duplicate activities', () => {
|
|
55
|
-
const existingActivities = [activity1];
|
|
86
|
+
const existingActivities = prehydrateActivities([activity1]);
|
|
56
87
|
const result = addActivitiesToState(
|
|
57
88
|
[activity1],
|
|
58
89
|
existingActivities,
|
|
@@ -67,7 +98,7 @@ describe('activity-utils', () => {
|
|
|
67
98
|
it('should handle multiple new activities correctly', () => {
|
|
68
99
|
const activity3 = generateActivityResponse({ id: 'activity3' });
|
|
69
100
|
|
|
70
|
-
const existingActivities = [activity1];
|
|
101
|
+
const existingActivities = prehydrateActivities([activity1]);
|
|
71
102
|
const result = addActivitiesToState(
|
|
72
103
|
[activity2, activity3],
|
|
73
104
|
existingActivities,
|
|
@@ -185,7 +216,7 @@ describe('activity-utils', () => {
|
|
|
185
216
|
it('should remove an activity from the state', () => {
|
|
186
217
|
const activity1 = generateActivityResponse({ id: 'activity1' });
|
|
187
218
|
const activity2 = generateActivityResponse({ id: 'activity2' });
|
|
188
|
-
const activities = [activity1, activity2];
|
|
219
|
+
const activities = prehydrateActivities([activity1, activity2]);
|
|
189
220
|
|
|
190
221
|
const result = removeActivityFromState(activity1, activities);
|
|
191
222
|
|
|
@@ -199,7 +230,7 @@ describe('activity-utils', () => {
|
|
|
199
230
|
it('should return unchanged state if activity not found', () => {
|
|
200
231
|
const activity1 = generateActivityResponse({ id: 'activity1' });
|
|
201
232
|
const activity2 = generateActivityResponse({ id: 'activity2' });
|
|
202
|
-
const activities = [activity1];
|
|
233
|
+
const activities = prehydrateActivities([activity1]);
|
|
203
234
|
|
|
204
235
|
const result = removeActivityFromState(activity2, activities);
|
|
205
236
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Feed } from '
|
|
1
|
+
import { Feed } from '../../feed';
|
|
2
2
|
import { ActivityResponse } from '../../../gen/models';
|
|
3
3
|
import { EventPayload, UpdateStateResult } from '../../../types-internal';
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export function addActivitiesToState(
|
|
6
|
+
this: Feed,
|
|
6
7
|
newActivities: ActivityResponse[],
|
|
7
8
|
activities: ActivityResponse[] | undefined,
|
|
8
9
|
position: 'start' | 'end',
|
|
9
|
-
)
|
|
10
|
+
) {
|
|
10
11
|
let result: UpdateStateResult<{ activities: ActivityResponse[] }>;
|
|
11
12
|
if (activities === undefined) {
|
|
12
13
|
activities = [];
|
|
@@ -23,8 +24,7 @@ export const addActivitiesToState = (
|
|
|
23
24
|
|
|
24
25
|
const newActivitiesDeduplicated: ActivityResponse[] = [];
|
|
25
26
|
newActivities.forEach((newActivityResponse) => {
|
|
26
|
-
|
|
27
|
-
if (index === -1) {
|
|
27
|
+
if (!this.hasActivity(newActivityResponse.id)) {
|
|
28
28
|
newActivitiesDeduplicated.push(newActivityResponse);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -41,14 +41,14 @@ export const addActivitiesToState = (
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return result;
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
export function handleActivityAdded(
|
|
47
47
|
this: Feed,
|
|
48
48
|
event: EventPayload<'feeds.activity.added'>,
|
|
49
49
|
) {
|
|
50
50
|
const currentActivities = this.currentState.activities;
|
|
51
|
-
const result = addActivitiesToState(
|
|
51
|
+
const result = addActivitiesToState.bind(this)(
|
|
52
52
|
[event.activity],
|
|
53
53
|
currentActivities,
|
|
54
54
|
'start',
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import type { Feed } from '
|
|
1
|
+
import type { Feed } from '../../feed';
|
|
2
2
|
import type {
|
|
3
3
|
ActivityPinResponse,
|
|
4
4
|
ActivityResponse,
|
|
5
5
|
} from '../../../gen/models';
|
|
6
6
|
import type { EventPayload, UpdateStateResult } from '../../../types-internal';
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export function removeActivityFromState(
|
|
9
|
+
this: Feed,
|
|
9
10
|
activityResponse: ActivityResponse,
|
|
10
11
|
activities: ActivityResponse[] | undefined,
|
|
11
12
|
): UpdateStateResult<{
|
|
12
13
|
activities: ActivityResponse[] | undefined;
|
|
13
|
-
}>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
}> {
|
|
15
|
+
if (this.hasActivity(activityResponse.id)) {
|
|
16
|
+
const index =
|
|
17
|
+
activities?.findIndex(
|
|
18
|
+
(activity) => activity.id === activityResponse.id,
|
|
19
|
+
) ?? -1;
|
|
19
20
|
const newActivities = [...activities!];
|
|
20
21
|
newActivities.splice(index, 1);
|
|
21
22
|
return { changed: true, activities: newActivities };
|
|
22
23
|
} else {
|
|
23
24
|
return { changed: false, activities };
|
|
24
25
|
}
|
|
25
|
-
}
|
|
26
|
+
}
|
|
26
27
|
|
|
27
28
|
export const removePinnedActivityFromState = (
|
|
28
29
|
activityResponse: ActivityResponse,
|
|
@@ -54,13 +55,15 @@ export function handleActivityDeleted(
|
|
|
54
55
|
} = this.currentState;
|
|
55
56
|
|
|
56
57
|
const [result1, result2] = [
|
|
57
|
-
|
|
58
|
+
this.hasActivity(event.activity.id)
|
|
59
|
+
? removeActivityFromState.bind(this)(event.activity, currentActivities)
|
|
60
|
+
: undefined,
|
|
58
61
|
removePinnedActivityFromState(event.activity, currentPinnedActivities),
|
|
59
62
|
];
|
|
60
63
|
|
|
61
|
-
if (result1
|
|
64
|
+
if (result1?.changed || result2.changed) {
|
|
62
65
|
this.state.partialNext({
|
|
63
|
-
activities: result1.activities,
|
|
66
|
+
activities: result1?.changed ? result1.activities : currentActivities,
|
|
64
67
|
pinned_activities: result2.pinned_activities,
|
|
65
68
|
});
|
|
66
69
|
}
|