diff --git a/src/@types/stream-chat-common-custom-data.d.ts b/src/@types/stream-chat-common-custom-data.d.ts deleted file mode 100644 index 2755dd9c7..000000000 --- a/src/@types/stream-chat-common-custom-data.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import 'stream-chat'; - -declare module 'stream-chat' { - interface CustomChannelData { - image?: string; - name?: string; - subtitle?: string; - } -} diff --git a/src/@types/stream-chat-custom-data.d.ts b/src/@types/stream-chat-custom-data.d.ts new file mode 100644 index 000000000..a85f74b4e --- /dev/null +++ b/src/@types/stream-chat-custom-data.d.ts @@ -0,0 +1,39 @@ +import 'stream-chat'; + +import { + DefaultAttachmentData, + DefaultChannelData, + DefaultCommandData, + DefaultEventData, + DefaultMemberData, + DefaultMessageData, + DefaultPollData, + DefaultPollOptionData, + DefaultReactionData, + DefaultThreadData, + DefaultUserData, +} from '../types/defaultDataInterfaces'; + +declare module 'stream-chat' { + interface CustomChannelData extends DefaultChannelData {} + + interface CustomAttachmentData extends DefaultAttachmentData {} + + interface CustomCommandData extends DefaultCommandData {} + + interface CustomEventData extends DefaultEventData {} + + interface CustomMemberData extends DefaultMemberData {} + + interface CustomMessageData extends DefaultMessageData {} + + interface CustomPollOptionData extends DefaultPollOptionData {} + + interface CustomPollData extends DefaultPollData {} + + interface CustomReactionData extends DefaultReactionData {} + + interface CustomUserData extends DefaultUserData {} + + interface CustomThreadData extends DefaultThreadData {} +} diff --git a/src/types/defaultDataInterfaces.ts b/src/types/defaultDataInterfaces.ts new file mode 100644 index 000000000..8267bf5e8 --- /dev/null +++ b/src/types/defaultDataInterfaces.ts @@ -0,0 +1,26 @@ +/* eslint-disable @typescript-eslint/no-empty-object-type */ +export interface DefaultChannelData { + image?: string; + name?: string; + subtitle?: string; +} + +export interface DefaultAttachmentData {} + +export interface DefaultCommandData {} + +export interface DefaultEventData {} + +export interface DefaultMemberData {} + +export interface DefaultMessageData {} + +export interface DefaultPollOptionData {} + +export interface DefaultPollData {} + +export interface DefaultReactionData {} + +export interface DefaultUserData {} + +export interface DefaultThreadData {} diff --git a/src/types/index.ts b/src/types/index.ts index 340d5c54e..7794a2ae4 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1 +1,2 @@ export type { ChannelUnreadUiState } from './types'; +export type * from './defaultDataInterfaces'; diff --git a/src/types/types.ts b/src/types/types.ts index 0902131c9..3aae67dce 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -1,13 +1,6 @@ import type { PropsWithChildren } from 'react'; import type { LoadingIndicatorProps } from '../components/Loading/LoadingIndicator'; -import type { - APIErrorResponse, - Attachment, - ErrorFromResponse, - Event, - Mute, - ChannelState as StreamChannelState, -} from 'stream-chat'; +import type { Attachment, ChannelState as StreamChannelState } from 'stream-chat'; export type UnknownType = Record; export type PropsWithChildrenOnly = PropsWithChildren>; @@ -21,42 +14,6 @@ export type CustomTrigger = { export type CustomMessageType = 'channel.intro' | 'message.date'; -export type DefaultAttachmentType = UnknownType & { - asset_url?: string; - file_size?: number; - id?: string; - images?: Array<{ - image_url?: string; - thumb_url?: string; - }>; -}; - -export type DefaultChannelType = UnknownType & { - frozen?: boolean; - image?: string; - member_count?: number; - subtitle?: string; -}; - -export type DefaultMessageType = UnknownType & { - customType?: CustomMessageType; - date?: string | Date; - error?: ErrorFromResponse; - errorStatusCode?: number; - event?: Event; - unread?: boolean; -}; - -export type DefaultUserTypeInternal = { - image?: string; - status?: string; -}; - -export type DefaultUserType = UnknownType & - DefaultUserTypeInternal & { - mutes?: Array; - }; - export type GiphyVersions = | 'original' | 'fixed_height' @@ -117,7 +74,7 @@ export type VideoAttachmentSizeHandler = ( export type ChannelUnreadUiState = Omit, 'user'>; -// todo: fix export from stream-chat - for some reason not exported +// TODO: fix export from stream-chat - for some reason not exported export type SendMessageOptions = { force_moderation?: boolean; is_pending_message?: boolean;