diff --git a/ai-docs/ai-migration-v14-v15.md b/ai-docs/ai-migration-v14-v15.md index a74472d631..b3c3d2d298 100644 --- a/ai-docs/ai-migration-v14-v15.md +++ b/ai-docs/ai-migration-v14-v15.md @@ -2,7 +2,7 @@ Execution-only guide for a coding agent migrating a third-party app from `stream-chat-react` v14 to v15. Apply the changes below and fix each compile or runtime break before moving on. For evidence and edge cases, verify against the installed SDK source (see below). -Every breaking change confirmed in [`ai-docs/v15-breaking-changes.md`](https://github.com/GetStream/stream-chat-react/blob/master/ai-docs/v15-breaking-changes.md) (the audit this guide is written from, `BC-001` to `BC-077`) is covered here. The [index at the end](#index-of-breaking-changes) maps each `BC` entry to its section. +Every breaking change confirmed in [`ai-docs/v15-breaking-changes.md`](https://github.com/GetStream/stream-chat-react/blob/master/ai-docs/v15-breaking-changes.md) (the audit this guide is written from, `BC-001` to `BC-078`) is covered here. The [index at the end](#index-of-breaking-changes) maps each `BC` entry to its section. ## Source of truth @@ -144,6 +144,7 @@ Each import below is now a compile error (`TS2305` / `TS2724`) and `undefined` i | `useLegacyThreadContext` | [Section 7](#thread-takes-a-thread-prop-and-renders-its-children) | | `MESSAGE_ACTIONS`, `OPTIONAL_MESSAGE_ACTIONS`, `getMessageActions`, `MessageActionsArray`, `Capabilities` | [Section 10](#messageactions-and-message_actions-are-removed) | | `deTranslations` ... `trTranslations`, `enTranslations`, `isLanguageSupported`, `SupportedTranslations`, `DateFormatterOptions` | [Section 18](#18-i18n) | +| `DefaultCommandData` | [Section 17](#17-other-stream-chat-v10-data-shapes) | New root exports: `useMessagePaginator()` returns the active list's paginator (the thread's inside a thread, the channel's otherwise), and `useIsCooldownActive()` tells whether slow mode is counting down. @@ -2663,7 +2664,7 @@ export const DayDivider = ({ message }: { message: LocalMessage }) => { ## 17. Other `stream-chat` v10 data shapes -React props typed with `stream-chat` types change with them. The React APIs are unchanged; build and read the values with the v10 shapes. +React props typed with `stream-chat` types change with them. The React APIs are unchanged, apart from the removed `DefaultCommandData` (see the command names bullet under **Composer**); build and read the values with the v10 shapes. **Channel, chat context and search:** @@ -2726,6 +2727,19 @@ export const DeleteForMe = () => { **Composer:** - `CommandChip.command`, `CommandItem.entity`, `MessageComposerCommand.command`: `CommandResponse` → `Command`, where `args`, `description` and `set` are required. +- **Command names are `string`.** `stream-chat` v10 removes `CustomCommandData`, and `stream-chat-react` removes `DefaultCommandData` with it. In v14, `command.name` / `command.set` were `CommandVariants` (the built-in names plus the keys of `CustomCommandData`); in v15 they are plain `string`. Delete the `interface CustomCommandData extends DefaultCommandData {}` line from your `declare module 'stream-chat'` block and the `DefaultCommandData` import (`TS2305`). A leftover `CustomCommandData` augmentation without that import still compiles and does nothing, so search for the name. To keep a checked set of command names, declare the union in your app: + + ```ts + import type { Command } from 'stream-chat'; + + type AppCommandName = 'giphy' | 'poll'; + + export const isAppCommand = ( + command: Command, + ): command is Command & { name: AppCommandName } => + command.name === 'giphy' || command.name === 'poll'; + ``` + - `DefaultSuggestionListItemEntity`: `anon`, `channel_last_read_at`, `notifications_muted`, `privacy_settings`, `push_notifications`, `shadow_banned` and `username` are gone (v10 user custom fields live in `entity.custom`); dates are `TimestampNS`; `teams_role` is `Record`. - `getQuotedMessageAuthor` (on `QuotedMessagePreview` and its props): `(message: LocalMessage | MessageResponse) => string`. A callback typed with `LocalMessage` only is rejected under `strictFunctionTypes`. `QuotedMessagePreviewUI.quotedMessage`: `LocalMessage | MessageResponse`. - `GeolocationPreviewProps.location`, `useAttachmentsForPreview().location`: `StaticLocationPreview`. @@ -2956,3 +2970,4 @@ On narrow screens (`max-width: 767px`) the lists switch to an overlay sized by ` | BC-075 | `ChatView` view wrappers | [19](#19-css-and-markup) | | BC-076 | `str-chat__thread--virtualized` | [19](#19-css-and-markup) | | BC-077 | Quote and edit preview colours | [19](#19-css-and-markup) | +| BC-078 | `CustomCommandData` / `DefaultCommandData` removed | [17](#17-other-stream-chat-v10-data-shapes) | diff --git a/ai-docs/v15-breaking-changes.md b/ai-docs/v15-breaking-changes.md index daa58bbee7..e52afdbc5b 100644 --- a/ai-docs/v15-breaking-changes.md +++ b/ai-docs/v15-breaking-changes.md @@ -63,7 +63,7 @@ yarn api-surface check --doc ai-docs/v15-breaking-changes.md --diff diff.json ## Index -77 entries. +78 entries. | ID | Title | Group | | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | @@ -144,6 +144,7 @@ yarn api-surface check --doc ai-docs/v15-breaking-changes.md --diff diff.json | [BC-075](#bc-075) | CSS, ChatView: `str-chat__chat-view__channels` / `__threads` render only in `views` mode | CSS and markup | | [BC-076](#bc-076) | CSS, Thread: `str-chat__thread--virtualized` is no longer applied | CSS and markup | | [BC-077](#bc-077) | quote and edit previews set their text colour from the matching bubble token | CSS and markup | +| [BC-078](#bc-078) | `CustomCommandData` augmentation and `DefaultCommandData` are removed; command names are `string` | Types that follow stream-chat v10 (umbrella entries) | ## Package and runtime @@ -3179,6 +3180,27 @@ export const DeleteForMe = () => { - `02-ui-components/09-message-composer/05-ui_components.md` (`CommandChip`) - Example needed: no (belongs under the guide's "Dates on response types" and v10 data-shape umbrella, which other areas will also feed) +### BC-078: `CustomCommandData` augmentation and `DefaultCommandData` are removed; command names are `string` + +- Status: confirmed +- Area: custom data types, commands +- User impact: compile error `TS2305` on `import type { DefaultCommandData } from 'stream-chat-react'`, and, with a `stream-chat` release after `10.0.0-rc.31`, on `import type { CustomCommandData } from 'stream-chat'` once no augmentation of it is left in the program. Command names lose their type: v14 typed `command.name` / `command.set` as `CommandVariants` (the built-in names plus the keys of `CustomCommandData`), so a typo such as `command.name === 'gihpy'` failed to compile; v15 types them as `string`, and it compiles. A leftover `interface CustomCommandData { … }` in `declare module 'stream-chat'` still compiles and has no effect, because nothing reads it. +- Old API: + - `DefaultCommandData` (exported from `stream-chat-react`) + - `declare module 'stream-chat' { interface CustomCommandData extends DefaultCommandData {} }` +- Replacement: delete the `CustomCommandData` augmentation and the `DefaultCommandData` import. `Command['name']` and `Command['set']` are `string`; an app that wants a checked set of names declares its own union and narrows `command.name` against it. +- Evidence: + - `release-v14:src/types/defaultDataInterfaces.ts:11` `export interface DefaultCommandData {}`; `release-v14:src/@types/stream-chat-custom-data.d.ts:23` augments `CustomCommandData` with it + - `stream-chat` `v9.54.4:src/types.ts:2772-2781` `CommandVariants = 'all' | 'ban' | 'fun_set' | 'giphy' | 'moderation_set' | 'mute' | 'unban' | 'unmute' | keyof CustomCommandData`, used by `CommandResponse.name` / `set` (`:470-475`) + - `master:node_modules/stream-chat/src/gen/models/index.ts:2551-2568` `Command.name: string`, `Command.set: string` + - `stream-chat` `release-v10` removes `CustomCommandData` from `src/custom_types.ts` and the root exports after `10.0.0-rc.31` (REACT-1363); `10.0.0-rc.31`, which `master` pins, still exports it + - `master:src/types/defaultDataInterfaces.ts` has no `DefaultCommandData` + - examples: `release-v14:examples/ai-chatbot/src/components/stream-chat.d.ts:4,25` imported and augmented it +- Docs impact: + - `02-state/01-state-and-entities/06-data-conventions.md` ("Custom data types": drop the `CustomCommandData` line) + - `08-release-guides/01-upgrade-to-v15.md` (add a row: delete `CustomCommandData` augmentations and the `DefaultCommandData` import) +- Example needed: no + ## CSS and markup ### BC-073: CSS, channel layout wrappers: `Window` and the `str-chat__main-panel` / `str-chat__container` wrappers are removed diff --git a/src/@types/stream-chat-custom-data.d.ts b/src/@types/stream-chat-custom-data.d.ts index 85bdb21d2d..a899fb23ef 100644 --- a/src/@types/stream-chat-custom-data.d.ts +++ b/src/@types/stream-chat-custom-data.d.ts @@ -3,7 +3,6 @@ import 'stream-chat'; import { DefaultAttachmentData, DefaultChannelData, - DefaultCommandData, DefaultEventData, DefaultMemberData, DefaultMessageComposerData, @@ -20,8 +19,6 @@ declare module 'stream-chat' { interface CustomAttachmentData extends DefaultAttachmentData {} - interface CustomCommandData extends DefaultCommandData {} - interface CustomEventData extends DefaultEventData {} interface CustomMemberData extends DefaultMemberData {} diff --git a/src/types/defaultDataInterfaces.ts b/src/types/defaultDataInterfaces.ts index f0a06a9690..6255335444 100644 --- a/src/types/defaultDataInterfaces.ts +++ b/src/types/defaultDataInterfaces.ts @@ -8,8 +8,6 @@ export interface DefaultChannelData { export interface DefaultAttachmentData {} -export interface DefaultCommandData {} - export interface DefaultEventData {} export interface DefaultMemberData {}