fix: adapt to removed stream-chat-js hand-written types - #3274
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the βοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`stream-chat` collapsed the twelve `*Sort` aliases, which were all exactly `SortParamRequest[]` β twelve names for one type β and retired the `APIResponse`-based response aliases in favour of the generated response types. * `ReactionSort` -> `SortParamRequest[]` across 13 sites in 5 files. Note the brackets: the alias *was* the array, so this is not `SortParamRequest`. Four of the sites are public API and change the emitted `.d.ts`: `MessageContextValue.handleFetchReactions` and `.reactionDetailsSort`, `MessageProps.reactionDetailsSort`, `MessageReactionsDetailProps.sort`, and `FetchReactionsOptions.sort`. The type is structurally identical, so no consumer code needs to change β only the name they import if they annotate it themselves. * `ChannelSort` -> `SortParamRequest[]` in the tutorial and vite examples. * `SendFileAPIResponse` -> `Awaited<ReturnType<Channel['uploadImage' | 'uploadFile']>>` in the two test files that annotated upload spies, following the `ReturnType<β¦>` idiom already used for `markRead` in 7842c17 so these track the method rather than a name. Deriving from the method also drops `SendFileAPIResponse`'s claim that `file` is required β the generated `FileUploadResponse.file` is optional. That was always true of the real response; the alias was hiding it. * `useSendMessageFn` no longer casts `message` to `MessageRequest`. `compose()` used to widen it to `MessageRequest | UpdatedMessage` and the cast narrowed it back; the union is gone, so the cast and its explanatory comment are both dead. Docs: `AI.md` also had a stale `const sort: ChannelSort = { last_message_at: -1 }` β the v9 keyed-object form, which stopped being valid when sort became an array. Corrected alongside the rename. `specs/message-pagination/decisions.md` referenced `channel.getReplies(...)`, which `stream-chat` removed in favour of `client.getReplies()`. Verified: `tsc -p tsconfig.lib.json` clean, 2828 tests passing, eslint clean on every touched file. Note on `yarn types`: the root `tsconfig.json` is solution-style (`"files": []` plus `references`), so `tsc --noEmit` without `--build` typechecks nothing and the script passes unconditionally. The real check is `tsc -p tsconfig.lib.json`. Left alone here as it is a pre-existing issue unrelated to this change. Note on `yarn types:tests`: already failing before this change with ~1216 errors, none of them from this migration β `ChannelAPIResponse`, `QueryChannelAPIResponse`, `MuteChannelAPIResponse`, `AppSettingsAPIResponse` and several stream-chat-react-local context types were removed by earlier v10 work and never migrated in the test tree. This change takes that count down by 2 and adds none. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
207db88 to
a2b4ccb
Compare
Codecov Reportβ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-v15 #3274 +/- ##
==============================================
Coverage ? 84.46%
==============================================
Files ? 526
Lines ? 15940
Branches ? 5109
==============================================
Hits ? 13463
Misses ? 2477
Partials ? 0 β View full report in Codecov by Harness. π New features to boost your workflow:
|
`stream-chat` removed the hand-written `/moderation/*` methods from `StreamChat` in favour
of the generated V2 moderation API, reachable as `client.moderation`.
* `client.muteUser(id)` -> `client.moderation.mute({ target_ids: [id] })`
* `client.unmuteUser(id)` -> `client.moderation.unmute({ target_ids: [id] })`
* `client.flagMessage(id)` -> `client.moderation.flagMessage(id)`
V2 mute/unmute take `target_ids` as an array, hence the wrapping. `flagMessage` keeps its
`(messageId)` shape because the moderation wrapper supplies the entity type, and `reason`
is optional there.
Call sites: `useMuteHandler`, `useFlagHandler`, and the mute toggles in
`ChannelManagementActions.defaults` and `ChannelMemberActions.defaults`.
`channel.banUser` / `channel.unbanUser` are unchanged β `Channel` keeps those wrappers, and
`unbanUser` has no generated equivalent so it stays on v1 upstream.
No public API change: none of these responses were read, and no exported type or prop
signature moves.
Tests: the spies moved from `client.muteUser` / `client.unmuteUser` / `client.flagMessage`
to their `client.moderation` counterparts, and the mute assertions expect
`{ target_ids: [id] }` rather than a bare id. The hoisted mock client in
`ChannelManagementActions.defaults.test` grows a `moderation` object for the same reason.
Verified: `tsc -p tsconfig.lib.json` clean, 2828 tests passing, eslint clean on every
touched file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Not yet ready to be merged
Relevant stream-chat-js PR: GetStream/stream-chat-js#1836
π― Goal
Describe why we are making this change
π Implementation details
Provide a description of the implementation
π¨ UI Changes
Add relevant screenshots