UNPKG

stream-chat

Version:

JS SDK for the Stream Chat API

1,254 lines 114 kB
import { AxiosRequestConfig, AxiosResponse } from 'axios'; import { StableWSConnection } from './connection'; import { EVENT_MAP } from './events'; import { Role } from './permissions'; import type { Channel } from './channel'; /** * Utility Types */ export declare type ArrayOneOrMore<T> = { 0: T; } & Array<T>; export declare type ArrayTwoOrMore<T> = { 0: T; 1: T; } & Array<T>; export declare type KnownKeys<T> = { [K in keyof T]: string extends K ? never : number extends K ? never : K; } extends { [_ in keyof T]: infer U; } ? U : never; export declare type RequireAtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>; }[keyof T]; export declare type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>; }[Keys]; export declare type UR = Record<string, unknown>; export declare type UnknownType = UR; export declare type DefaultGenerics = { attachmentType: UR; channelType: UR; commandType: LiteralStringForUnion; eventType: UR; memberType: UR; messageType: UR; pollOptionType: UR; pollType: UR; reactionType: UR; userType: UR; }; export declare type ExtendableGenerics = { attachmentType: UR; channelType: UR; commandType: string; eventType: UR; memberType: UR; messageType: UR; pollOptionType: UR; pollType: UR; reactionType: UR; userType: UR; }; export declare type Unpacked<T> = T extends (infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise<infer U> ? U : T; /** * Response Types */ export declare type APIResponse = { duration: string; }; export declare type TranslateResponse = { language: string; translated_text: string; }; export declare type AppSettingsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { app?: { call_types: any; channel_configs: Record<string, { reminders: boolean; automod?: ChannelConfigAutomod; automod_behavior?: ChannelConfigAutomodBehavior; automod_thresholds?: ChannelConfigAutomodThresholds; blocklist_behavior?: ChannelConfigAutomodBehavior; commands?: CommandVariants<StreamChatGenerics>[]; connect_events?: boolean; created_at?: string; custom_events?: boolean; mark_messages_pending?: boolean; max_message_length?: number; message_retention?: string; mutes?: boolean; name?: string; polls?: boolean; push_notifications?: boolean; quotes?: boolean; reactions?: boolean; read_events?: boolean; replies?: boolean; search?: boolean; typing_events?: boolean; updated_at?: string; uploads?: boolean; url_enrichment?: boolean; }>; reminders_interval: number; agora_options?: AgoraOptions | null; async_moderation_config?: AsyncModerationOptions; async_url_enrich_enabled?: boolean; auto_translation_enabled?: boolean; before_message_send_hook_url?: string; campaign_enabled?: boolean; cdn_expiration_seconds?: number; custom_action_handler_url?: string; datadog_info?: { api_key: string; site: string; enabled?: boolean; }; disable_auth_checks?: boolean; disable_permissions_checks?: boolean; enforce_unique_usernames?: 'no' | 'app' | 'team'; file_upload_config?: FileUploadConfig; geofences?: Array<{ country_codes: Array<string>; description: string; name: string; type: string; }>; grants?: Record<string, string[]>; hms_options?: HMSOptions | null; image_moderation_enabled?: boolean; image_upload_config?: FileUploadConfig; multi_tenant_enabled?: boolean; name?: string; organization?: string; permission_version?: string; policies?: Record<string, Policy[]>; poll_enabled?: boolean; push_notifications?: { offline_only: boolean; version: string; apn?: APNConfig; firebase?: FirebaseConfig; huawei?: HuaweiConfig; providers?: PushProviderConfig[]; xiaomi?: XiaomiConfig; }; revoke_tokens_issued_before?: string | null; search_backend?: 'disabled' | 'elasticsearch' | 'postgres'; sns_key?: string; sns_secret?: string; sns_topic_arn?: string; sqs_key?: string; sqs_secret?: string; sqs_url?: string; suspended?: boolean; suspended_explanation?: string; user_search_disallowed_roles?: string[] | null; video_provider?: string; webhook_events?: Array<string>; webhook_url?: string; }; }; export declare type ModerationResult = { action: string; created_at: string; message_id: string; updated_at: string; user_bad_karma: boolean; user_karma: number; blocked_word?: string; blocklist_name?: string; moderated_by?: string; }; export declare type AutomodDetails = { action?: string; image_labels?: Array<string>; original_message_type?: string; result?: ModerationResult; }; export declare type FlagDetails = { automod?: AutomodDetails; }; export declare type Flag<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { created_at: string; created_by_automod: boolean; updated_at: string; details?: FlagDetails; target_message?: MessageResponse<StreamChatGenerics>; target_user?: UserResponse<StreamChatGenerics>; user?: UserResponse<StreamChatGenerics>; }; export declare type FlagsResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { flags?: Array<Flag<StreamChatGenerics>>; }; export declare type MessageFlagsResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { flags?: Array<{ message: MessageResponse<StreamChatGenerics>; user: UserResponse<StreamChatGenerics>; approved_at?: string; created_at?: string; created_by_automod?: boolean; moderation_result?: ModerationResult; rejected_at?: string; reviewed_at?: string; reviewed_by?: UserResponse<StreamChatGenerics>; updated_at?: string; }>; }; export declare type FlagReport<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { flags_count: number; id: string; message: MessageResponse<StreamChatGenerics>; user: UserResponse<StreamChatGenerics>; created_at?: string; details?: FlagDetails; first_reporter?: UserResponse<StreamChatGenerics>; review_result?: string; reviewed_at?: string; reviewed_by?: UserResponse<StreamChatGenerics>; updated_at?: string; }; export declare type FlagReportsResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { flag_reports: Array<FlagReport<StreamChatGenerics>>; }; export declare type ReviewFlagReportResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { flag_report: FlagReport<StreamChatGenerics>; }; export declare type BannedUsersResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { bans?: Array<{ user: UserResponse<StreamChatGenerics>; banned_by?: UserResponse<StreamChatGenerics>; channel?: ChannelResponse<StreamChatGenerics>; expires?: string; ip_ban?: boolean; reason?: string; timeout?: number; }>; }; export declare type BlockListResponse = BlockList & { created_at?: string; type?: string; updated_at?: string; }; export declare type ChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = StreamChatGenerics['channelType'] & { cid: string; disabled: boolean; frozen: boolean; id: string; type: string; auto_translation_enabled?: boolean; auto_translation_language?: TranslationLanguages | ''; config?: ChannelConfigWithInfo<StreamChatGenerics>; cooldown?: number; created_at?: string; created_by?: UserResponse<StreamChatGenerics> | null; created_by_id?: string; deleted_at?: string; hidden?: boolean; invites?: string[]; joined?: boolean; last_message_at?: string; member_count?: number; members?: ChannelMemberResponse<StreamChatGenerics>[]; muted?: boolean; name?: string; own_capabilities?: string[]; team?: string; truncated_at?: string; truncated_by?: UserResponse<StreamChatGenerics>; truncated_by_id?: string; updated_at?: string; }; export declare type QueryReactionsOptions = Pager; export declare type QueryReactionsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { reactions: ReactionResponse<StreamChatGenerics>[]; next?: string; }; export declare type QueryChannelsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channels: Omit<ChannelAPIResponse<StreamChatGenerics>, keyof APIResponse>[]; }; export declare type QueryChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & ChannelAPIResponse<StreamChatGenerics>; export declare type ChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { channel: ChannelResponse<StreamChatGenerics>; members: ChannelMemberResponse<StreamChatGenerics>[]; messages: MessageResponse<StreamChatGenerics>[]; pinned_messages: MessageResponse<StreamChatGenerics>[]; hidden?: boolean; membership?: ChannelMemberResponse<StreamChatGenerics> | null; pending_messages?: PendingMessageResponse<StreamChatGenerics>[]; push_preferences?: PushPreference; read?: ReadResponse<StreamChatGenerics>[]; threads?: ThreadResponse[]; watcher_count?: number; watchers?: UserResponse<StreamChatGenerics>[]; }; export declare type ChannelUpdateOptions = { hide_history?: boolean; skip_push?: boolean; }; export declare type ChannelMemberAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { members: ChannelMemberResponse<StreamChatGenerics>[]; }; export declare type ChannelMemberUpdates<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = StreamChatGenerics['memberType'] & { archived?: boolean; channel_role?: Role; pinned?: boolean; }; export declare type ChannelMemberResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = StreamChatGenerics['memberType'] & { archived_at?: string; ban_expires?: string; banned?: boolean; channel_role?: Role; created_at?: string; invite_accepted_at?: string; invite_rejected_at?: string; invited?: boolean; is_moderator?: boolean; notifications_muted?: boolean; pinned_at?: string; role?: string; shadow_banned?: boolean; status?: InviteStatus; updated_at?: string; user?: UserResponse<StreamChatGenerics>; user_id?: string; }; export declare type PartialUpdateMemberAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel_member: ChannelMemberResponse<StreamChatGenerics>; }; export declare type CheckPushResponse = APIResponse & { device_errors?: { [deviceID: string]: { error_message?: string; provider?: PushProvider; provider_name?: string; }; }; general_errors?: string[]; rendered_apn_template?: string; rendered_firebase_template?: string; rendered_message?: {}; skip_devices?: boolean; }; export declare type CheckSQSResponse = APIResponse & { status: string; data?: {}; error?: string; }; export declare type CheckSNSResponse = APIResponse & { status: string; data?: {}; error?: string; }; export declare type CommandResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Partial<CreatedAtUpdatedAt> & { args?: string; description?: string; name?: CommandVariants<StreamChatGenerics>; set?: CommandVariants<StreamChatGenerics>; }; export declare type ConnectAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Promise<void | ConnectionOpen<StreamChatGenerics>>; export declare type CreateChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & Omit<CreateChannelOptions<StreamChatGenerics>, 'client_id' | 'connection_id'> & { created_at: string; updated_at: string; grants?: Record<string, string[]>; }; export declare type CreateCommandResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { command: CreateCommandOptions<StreamChatGenerics> & CreatedAtUpdatedAt; }; export declare type DeleteChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel: ChannelResponse<StreamChatGenerics>; }; export declare type DeleteCommandResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { name?: CommandVariants<StreamChatGenerics>; }; export declare type EventAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { event: Event<StreamChatGenerics>; }; export declare type ExportChannelResponse = { task_id: string; }; export declare type ExportUsersResponse = { task_id: string; }; export declare type ExportChannelStatusResponse = { created_at?: string; error?: {}; result?: {}; updated_at?: string; }; export declare type FlagMessageResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { flag: { created_at: string; created_by_automod: boolean; target_message_id: string; updated_at: string; user: UserResponse<StreamChatGenerics>; approved_at?: string; channel_cid?: string; details?: Object; message_user_id?: string; rejected_at?: string; reviewed_at?: string; reviewed_by?: string; }; review_queue_item_id?: string; }; export declare type FlagUserResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { flag: { created_at: string; created_by_automod: boolean; target_user: UserResponse<StreamChatGenerics>; updated_at: string; user: UserResponse<StreamChatGenerics>; approved_at?: string; details?: Object; rejected_at?: string; reviewed_at?: string; reviewed_by?: string; }; review_queue_item_id?: string; }; export declare type FormatMessageResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Omit<MessageResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; memberType: StreamChatGenerics['memberType']; messageType: {}; pollOptionType: StreamChatGenerics['pollOptionType']; pollType: StreamChatGenerics['pollType']; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>, 'created_at' | 'pinned_at' | 'updated_at' | 'deleted_at' | 'status'> & StreamChatGenerics['messageType'] & { created_at: Date; deleted_at: Date | null; pinned_at: Date | null; status: string; updated_at: Date; }; export declare type GetChannelTypeResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & Omit<CreateChannelOptions<StreamChatGenerics>, 'client_id' | 'connection_id' | 'commands'> & { created_at: string; updated_at: string; commands?: CommandResponse<StreamChatGenerics>[]; grants?: Record<string, string[]>; }; export declare type GetCommandResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & CreateCommandOptions<StreamChatGenerics> & CreatedAtUpdatedAt; export declare type GetMessageAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = SendMessageAPIResponse<StreamChatGenerics>; export interface ThreadResponseCustomData { } export interface ThreadResponse<SCG extends ExtendableGenerics = DefaultGenerics> extends ThreadResponseCustomData { channel: ChannelResponse<SCG>; channel_cid: string; created_at: string; created_by_user_id: string; latest_replies: Array<MessageResponse<SCG>>; parent_message: MessageResponse<SCG>; parent_message_id: string; title: string; updated_at: string; active_participant_count?: number; created_by?: UserResponse<SCG>; deleted_at?: string; last_message_at?: string; participant_count?: number; read?: Array<ReadResponse<SCG>>; reply_count?: number; thread_participants?: Array<{ channel_cid: string; created_at: string; last_read_at: string; last_thread_message_at?: string; left_thread_at?: string; thread_id?: string; user?: UserResponse<SCG>; user_id?: string; }>; } export declare type PartialThreadUpdate = { set?: Partial<Record<string, unknown>>; unset?: Array<string>; }; export declare type QueryThreadsOptions = { limit?: number; member_limit?: number; next?: string; participant_limit?: number; reply_limit?: number; watch?: boolean; }; export declare type QueryThreadsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { threads: ThreadResponse<StreamChatGenerics>[]; next?: string; }; export declare type GetThreadOptions = { member_limit?: number; participant_limit?: number; reply_limit?: number; watch?: boolean; }; export declare type GetThreadAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { thread: ThreadResponse<StreamChatGenerics>; }; export declare type GetMultipleMessagesAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { messages: MessageResponse<StreamChatGenerics>[]; }; export declare type GetRateLimitsResponse = APIResponse & { android?: RateLimitsMap; ios?: RateLimitsMap; server_side?: RateLimitsMap; web?: RateLimitsMap; }; export declare type GetReactionsAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { reactions: ReactionResponse<StreamChatGenerics>[]; }; export declare type GetRepliesAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { messages: MessageResponse<StreamChatGenerics>[]; }; export declare type GetUnreadCountAPIResponse = APIResponse & { channel_type: { channel_count: number; channel_type: string; unread_count: number; }[]; channels: { channel_id: string; last_read: string; unread_count: number; }[]; threads: { last_read: string; last_read_message_id: string; parent_message_id: string; unread_count: number; }[]; total_unread_count: number; total_unread_threads_count: number; }; export declare type ChatLevelPushPreference = 'all' | 'none' | 'mentions' | (string & {}); export declare type PushPreference = { callLevel?: 'all' | 'none' | (string & {}); chatLevel?: ChatLevelPushPreference; disabledUntil?: string; removeDisable?: boolean; }; export declare type ChannelPushPreference = { chatLevel?: ChatLevelPushPreference; disabledUntil?: string; removeDisable?: boolean; }; export declare type UpsertPushPreferencesResponse = APIResponse & { userChannelPreferences: Record<string, Record<string, ChannelPushPreference>>; userPreferences: Record<string, PushPreference>; }; export declare type GetUnreadCountBatchAPIResponse = APIResponse & { counts_by_user: { [userId: string]: GetUnreadCountAPIResponse; }; }; export declare type ListChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel_types: Record<string, Omit<CreateChannelOptions<StreamChatGenerics>, 'client_id' | 'connection_id' | 'commands'> & { commands: CommandResponse<StreamChatGenerics>[]; created_at: string; updated_at: string; grants?: Record<string, string[]>; }>; }; export declare type ListChannelTypesAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = ListChannelResponse<StreamChatGenerics>; export declare type ListCommandsResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { commands: Array<CreateCommandOptions<StreamChatGenerics> & Partial<CreatedAtUpdatedAt>>; }; export declare type MuteChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel_mute: ChannelMute<StreamChatGenerics>; own_user: OwnUserResponse<StreamChatGenerics>; channel_mutes?: ChannelMute<StreamChatGenerics>[]; mute?: MuteResponse<StreamChatGenerics>; }; export declare type MessageResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = MessageResponseBase<StreamChatGenerics> & { quoted_message?: MessageResponseBase<StreamChatGenerics>; }; export declare type MessageResponseBase<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = MessageBase<StreamChatGenerics> & { type: MessageLabel; args?: string; before_message_send_failed?: boolean; channel?: ChannelResponse<StreamChatGenerics>; cid?: string; command?: string; command_info?: { name?: string; }; created_at?: string; deleted_at?: string; deleted_reply_count?: number; i18n?: RequireAtLeastOne<Record<`${TranslationLanguages}_text`, string>> & { language: TranslationLanguages; }; latest_reactions?: ReactionResponse<StreamChatGenerics>[]; mentioned_users?: UserResponse<StreamChatGenerics>[]; message_text_updated_at?: string; moderation?: ModerationResponse; moderation_details?: ModerationDetailsResponse; own_reactions?: ReactionResponse<StreamChatGenerics>[] | null; pin_expires?: string | null; pinned_at?: string | null; pinned_by?: UserResponse<StreamChatGenerics> | null; poll?: PollResponse<StreamChatGenerics>; reaction_counts?: { [key: string]: number; } | null; reaction_groups?: { [key: string]: ReactionGroupResponse; } | null; reaction_scores?: { [key: string]: number; } | null; reply_count?: number; shadowed?: boolean; status?: string; thread_participants?: UserResponse<StreamChatGenerics>[]; updated_at?: string; }; export declare type ReactionGroupResponse = { count: number; sum_scores: number; first_reaction_at?: string; last_reaction_at?: string; }; export declare type ModerationDetailsResponse = { action: 'MESSAGE_RESPONSE_ACTION_BOUNCE' | (string & {}); error_msg: string; harms: ModerationHarmResponse[]; original_text: string; }; export declare type ModerationHarmResponse = { name: string; phrase_list_ids: number[]; }; export declare type ModerationAction = 'bounce' | 'flag' | 'remove' | 'shadow'; export declare type ModerationResponse = { action: ModerationAction; original_text: string; }; export declare type MuteResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { user: UserResponse<StreamChatGenerics>; created_at?: string; expires?: string; target?: UserResponse<StreamChatGenerics>; updated_at?: string; }; export declare type MuteUserResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { mute?: MuteResponse<StreamChatGenerics>; mutes?: Array<Mute<StreamChatGenerics>>; own_user?: OwnUserResponse<StreamChatGenerics>; }; export declare type BlockUserAPIResponse = APIResponse & { blocked_at: string; blocked_by_user_id: string; blocked_user_id: string; }; export declare type GetBlockedUsersAPIResponse = APIResponse & { blocks: BlockedUserDetails[]; }; export declare type BlockedUserDetails = APIResponse & { blocked_user: UserResponse; blocked_user_id: string; created_at: string; user: UserResponse; user_id: string; }; export declare type OwnUserBase<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { channel_mutes: ChannelMute<StreamChatGenerics>[]; devices: Device<StreamChatGenerics>[]; mutes: Mute<StreamChatGenerics>[]; total_unread_count: number; unread_channels: number; unread_count: number; unread_threads: number; invisible?: boolean; privacy_settings?: PrivacySettings; push_preferences?: PushPreference; roles?: string[]; }; export declare type OwnUserResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = UserResponse<StreamChatGenerics> & OwnUserBase<StreamChatGenerics>; export declare type PartialUpdateChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel: ChannelResponse<StreamChatGenerics>; members: ChannelMemberResponse<StreamChatGenerics>[]; }; export declare type PermissionAPIResponse = APIResponse & { permission?: PermissionAPIObject; }; export declare type PermissionsAPIResponse = APIResponse & { permissions?: PermissionAPIObject[]; }; export declare type ReactionAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { message: MessageResponse<StreamChatGenerics>; reaction: ReactionResponse<StreamChatGenerics>; }; export declare type ReactionResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Reaction<StreamChatGenerics> & { created_at: string; message_id: string; updated_at: string; }; export declare type ReadResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { last_read: string; user: UserResponse<StreamChatGenerics>; last_read_message_id?: string; unread_messages?: number; }; export declare type SearchAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { results: { message: MessageResponse<StreamChatGenerics>; }[]; next?: string; previous?: string; results_warning?: SearchWarning | null; }; export declare type SearchWarning = { channel_search_cids: string[]; channel_search_count: number; warning_code: number; warning_description: string; }; export declare type SendFileAPIResponse = APIResponse & { file: string; thumb_url?: string; }; export declare type SendMessageAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { message: MessageResponse<StreamChatGenerics>; pending_message_metadata?: Record<string, string> | null; }; export declare type SyncResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { events: Event<StreamChatGenerics>[]; inaccessible_cids?: string[]; }; export declare type TruncateChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel: ChannelResponse<StreamChatGenerics>; message?: MessageResponse<StreamChatGenerics>; }; export declare type UpdateChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { channel: ChannelResponse<StreamChatGenerics>; members: ChannelMemberResponse<StreamChatGenerics>[]; message?: MessageResponse<StreamChatGenerics>; }; export declare type UpdateChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & Omit<CreateChannelOptions<StreamChatGenerics>, 'client_id' | 'connection_id'> & { created_at: string; updated_at: string; }; export declare type UpdateCommandResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { command: UpdateCommandOptions<StreamChatGenerics> & CreatedAtUpdatedAt & { name: CommandVariants<StreamChatGenerics>; }; }; export declare type UpdateMessageAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { message: MessageResponse<StreamChatGenerics>; }; export declare type UsersAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { users: Array<UserResponse<StreamChatGenerics>>; }; export declare type UpdateUsersAPIResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & { users: { [key: string]: UserResponse<StreamChatGenerics>; }; }; export declare type UserResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = User<StreamChatGenerics> & { banned?: boolean; blocked_user_ids?: string[]; created_at?: string; deactivated_at?: string; deleted_at?: string; language?: TranslationLanguages | ''; last_active?: string; online?: boolean; privacy_settings?: PrivacySettings; push_notifications?: PushNotificationSettings; revoke_tokens_issued_before?: string; shadow_banned?: boolean; updated_at?: string; }; export declare type PrivacySettings = { read_receipts?: { enabled?: boolean; }; typing_indicators?: { enabled?: boolean; }; }; export declare type PushNotificationSettings = { disabled?: boolean; disabled_until?: string | null; }; /** * Option Types */ export declare type MessageFlagsPaginationOptions = { limit?: number; offset?: number; }; export declare type FlagsPaginationOptions = { limit?: number; offset?: number; }; export declare type FlagReportsPaginationOptions = { limit?: number; offset?: number; }; export declare type ReviewFlagReportOptions = { review_details?: Object; user_id?: string; }; export declare type BannedUsersPaginationOptions = Omit<PaginationOptions, 'id_gt' | 'id_gte' | 'id_lt' | 'id_lte'> & { exclude_expired_bans?: boolean; }; export declare type BanUserOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = UnBanUserOptions & { banned_by?: UserResponse<StreamChatGenerics>; banned_by_id?: string; ip_ban?: boolean; reason?: string; timeout?: number; }; export declare type ChannelOptions = { limit?: number; member_limit?: number; message_limit?: number; offset?: number; presence?: boolean; state?: boolean; user_id?: string; watch?: boolean; }; export declare type ChannelQueryOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { client_id?: string; connection_id?: string; data?: ChannelResponse<StreamChatGenerics>; hide_for_creator?: boolean; members?: PaginationOptions; messages?: MessagePaginationOptions; presence?: boolean; state?: boolean; watch?: boolean; watchers?: PaginationOptions; }; export declare type ChannelStateOptions = { offlineMode?: boolean; skipInitialization?: string[]; }; export declare type CreateChannelOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { automod?: ChannelConfigAutomod; automod_behavior?: ChannelConfigAutomodBehavior; automod_thresholds?: ChannelConfigAutomodThresholds; blocklist?: string; blocklist_behavior?: ChannelConfigAutomodBehavior; client_id?: string; commands?: CommandVariants<StreamChatGenerics>[]; connect_events?: boolean; connection_id?: string; custom_events?: boolean; grants?: Record<string, string[]>; mark_messages_pending?: boolean; max_message_length?: number; message_retention?: string; mutes?: boolean; name?: string; permissions?: PermissionObject[]; polls?: boolean; push_notifications?: boolean; quotes?: boolean; reactions?: boolean; read_events?: boolean; reminders?: boolean; replies?: boolean; search?: boolean; skip_last_msg_update_for_system_msgs?: boolean; typing_events?: boolean; uploads?: boolean; url_enrichment?: boolean; }; export declare type CreateCommandOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { description: string; name: CommandVariants<StreamChatGenerics>; args?: string; set?: CommandVariants<StreamChatGenerics>; }; export declare type CustomPermissionOptions = { action: string; condition: object; id: string; name: string; description?: string; owner?: boolean; same_team?: boolean; }; export declare type DeactivateUsersOptions = { created_by_id?: string; mark_messages_deleted?: boolean; }; export declare type NewMemberPayload<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = StreamChatGenerics['memberType'] & Pick<ChannelMemberResponse<StreamChatGenerics>, 'user_id' | 'channel_role'>; export declare type InviteOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { accept_invite?: boolean; add_members?: string[]; add_moderators?: string[]; client_id?: string; connection_id?: string; data?: Omit<ChannelResponse<StreamChatGenerics>, 'id' | 'cid'>; demote_moderators?: string[]; invites?: string[]; message?: MessageResponse<StreamChatGenerics>; reject_invite?: boolean; remove_members?: string[]; user?: UserResponse<StreamChatGenerics>; user_id?: string; }; /** @deprecated use MarkChannelsReadOptions instead */ export declare type MarkAllReadOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = MarkChannelsReadOptions<StreamChatGenerics>; export declare type MarkChannelsReadOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { client_id?: string; connection_id?: string; read_by_channel?: Record<string, string>; user?: UserResponse<StreamChatGenerics>; user_id?: string; }; export declare type MarkReadOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { client_id?: string; connection_id?: string; thread_id?: string; user?: UserResponse<StreamChatGenerics>; user_id?: string; }; export declare type MarkUnreadOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { client_id?: string; connection_id?: string; message_id?: string; thread_id?: string; user?: UserResponse<StreamChatGenerics>; user_id?: string; }; export declare type MuteUserOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { client_id?: string; connection_id?: string; id?: string; reason?: string; target_user_id?: string; timeout?: number; type?: string; user?: UserResponse<StreamChatGenerics>; user_id?: string; }; export declare type PaginationOptions = { created_at_after?: string | Date; created_at_after_or_equal?: string | Date; created_at_before?: string | Date; created_at_before_or_equal?: string | Date; id_gt?: string; id_gte?: string; id_lt?: string; id_lte?: string; limit?: number; offset?: number; }; export declare type MessagePaginationOptions = PaginationOptions & { created_at_around?: string | Date; id_around?: string; }; export declare type PinnedMessagePaginationOptions = { id_around?: string; id_gt?: string; id_gte?: string; id_lt?: string; id_lte?: string; limit?: number; offset?: number; pinned_at_after?: string | Date; pinned_at_after_or_equal?: string | Date; pinned_at_around?: string | Date; pinned_at_before?: string | Date; pinned_at_before_or_equal?: string | Date; }; export declare type QueryMembersOptions = { created_at_after?: string; created_at_after_or_equal?: string; created_at_before?: string; created_at_before_or_equal?: string; limit?: number; offset?: number; user_id_gt?: string; user_id_gte?: string; user_id_lt?: string; user_id_lte?: string; }; export declare type ReactivateUserOptions = { created_by_id?: string; name?: string; restore_messages?: boolean; }; export declare type ReactivateUsersOptions = { created_by_id?: string; restore_messages?: boolean; }; export declare type SearchOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { limit?: number; next?: string; offset?: number; sort?: SearchMessageSort<StreamChatGenerics>; }; export declare type StreamChatOptions = AxiosRequestConfig & { /** * Used to disable warnings that are triggered by using connectUser or connectAnonymousUser server-side. */ allowServerSideConnect?: boolean; axiosRequestConfig?: AxiosRequestConfig; /** * Base url to use for API * such as https://chat-proxy-dublin.stream-io-api.com */ baseURL?: string; browser?: boolean; device?: BaseDeviceFields; /** * Disables the hydration of all caches within the JS Client. This includes this.activeChannels, * this.polls.pollCache and this.config. * It is mainly meant to be used for integrations where stream-chat is used as a server-side service * interacting with Stream's REST API, not depending on any state and purely serving as a wrapper * around HTTP requests. Using this property on either the client side or a backend implementation * that also relies on WS events will break these functionalities, so please use carefully. */ disableCache?: boolean; enableInsights?: boolean; /** experimental feature, please contact support if you want this feature enabled for you */ enableWSFallback?: boolean; logger?: Logger; /** * When true, user will be persisted on client. Otherwise if `connectUser` call fails, then you need to * call `connectUser` again to retry. * This is mainly useful for chat application working in offline mode, where you will need client.user to * persist even if connectUser call fails. */ persistUserOnConnectionFailure?: boolean; /** * When network is recovered, we re-query the active channels on client. But in single query, you can recover * only 30 channels. So its not guaranteed that all the channels in activeChannels object have updated state. * Thus in UI sdks, state recovery is managed by components themselves, they don't rely on js client for this. * * `recoverStateOnReconnect` parameter can be used in such cases, to disable state recovery within js client. * When false, user/consumer of this client will need to make sure all the channels present on UI by * manually calling queryChannels endpoint. */ recoverStateOnReconnect?: boolean; warmUp?: boolean; /** * Set the instance of StableWSConnection on chat client. Its purely for testing purpose and should * not be used in production apps. */ wsConnection?: StableWSConnection; /** * Sets a suffix to the wsUrl when it is being built in `wsConnection`. Is meant to be * used purely in testing suites and should not be used in production apps. */ wsUrlParams?: URLSearchParams; }; export declare type SyncOptions = { /** * This will behave as queryChannels option. */ watch?: boolean; /** * Return channels from request that user does not have access to in a separate * field in the response called 'inaccessible_cids' instead of * adding them as 'notification.removed_from_channel' events. */ with_inaccessible_cids?: boolean; }; export declare type UnBanUserOptions = { client_id?: string; connection_id?: string; id?: string; shadow?: boolean; target_user_id?: string; type?: string; }; export declare type UpdateChannelOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Omit<CreateChannelOptions<StreamChatGenerics>, 'name'> & { created_at?: string; updated_at?: string; }; export declare type UpdateCommandOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = { description: string; args?: string; set?: CommandVariants<StreamChatGenerics>; }; export declare type UserOptions = { include_deactivated_users?: boolean; limit?: number; offset?: number; presence?: boolean; }; /** * Event Types */ export declare type ConnectionChangeEvent = { type: EventTypes; online?: boolean; }; export declare type Event<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = StreamChatGenerics['eventType'] & { type: EventTypes; ai_message?: string; ai_state?: AIState; channel?: ChannelResponse<StreamChatGenerics>; channel_id?: string; channel_type?: string; cid?: string; clear_history?: boolean; connection_id?: string; created_at?: string; first_unread_message_id?: string; hard_delete?: boolean; last_read_at?: string; last_read_message_id?: string; mark_messages_deleted?: boolean; me?: OwnUserResponse<StreamChatGenerics>; member?: ChannelMemberResponse<StreamChatGenerics>; message?: MessageResponse<StreamChatGenerics>; message_id?: string; mode?: string; online?: boolean; parent_id?: string; poll?: PollResponse<StreamChatGenerics>; poll_vote?: PollVote<StreamChatGenerics> | PollAnswer<StreamChatGenerics>; queriedChannels?: { channels: ChannelAPIResponse<StreamChatGenerics>[]; isLatestMessageSet?: boolean; }; reaction?: ReactionResponse<StreamChatGenerics>; received_at?: string | Date; team?: string; thread?: ThreadResponse<StreamChatGenerics>; total_unread_count?: number; unread_channels?: number; unread_count?: number; unread_messages?: number; unread_thread_messages?: number; unread_threads?: number; user?: UserResponse<StreamChatGenerics>; user_id?: string; watcher_count?: number; }; export declare type UserCustomEvent<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = StreamChatGenerics['eventType'] & { type: string; }; export declare type EventHandler<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = (event: Event<StreamChatGenerics>) => void; export declare type EventTypes = 'all' | keyof typeof EVENT_MAP; /** * Filter Types */ export declare type AscDesc = 1 | -1; export declare type MessageFlagsFiltersOptions = { channel_cid?: string; is_reviewed?: boolean; team?: string; user_id?: string; }; export declare type MessageFlagsFilters = QueryFilters<{ channel_cid?: RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['channel_cid']>, '$eq' | '$in'>> | PrimitiveFilter<MessageFlagsFiltersOptions['channel_cid']>; } & { team?: RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['team']>, '$eq' | '$in'>> | PrimitiveFilter<MessageFlagsFiltersOptions['team']>; } & { user_id?: RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['user_id']>, '$eq' | '$in'>> | PrimitiveFilter<MessageFlagsFiltersOptions['user_id']>; } & { [Key in keyof Omit<MessageFlagsFiltersOptions, 'channel_cid' | 'user_id' | 'is_reviewed'>]: RequireOnlyOne<QueryFilter<MessageFlagsFiltersOptions[Key]>> | PrimitiveFilter<MessageFlagsFiltersOptions[Key]>; }>; export declare type FlagsFiltersOptions = { channel_cid?: string; message_id?: string; message_user_id?: string; reporter_id?: string; team?: string; user_id?: string; }; export declare type FlagsFilters = QueryFilters<{ user_id?: RequireOnlyOne<Pick<QueryFilter<FlagsFiltersOptions['user_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagsFiltersOptions['user_id']>; } & { message_id?: RequireOnlyOne<Pick<QueryFilter<FlagsFiltersOptions['message_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagsFiltersOptions['message_id']>; } & { message_user_id?: RequireOnlyOne<Pick<QueryFilter<FlagsFiltersOptions['message_user_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagsFiltersOptions['message_user_id']>; } & { channel_cid?: RequireOnlyOne<Pick<QueryFilter<FlagsFiltersOptions['channel_cid']>, '$eq' | '$in'>> | PrimitiveFilter<FlagsFiltersOptions['channel_cid']>; } & { reporter_id?: RequireOnlyOne<Pick<QueryFilter<FlagsFiltersOptions['reporter_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagsFiltersOptions['reporter_id']>; } & { team?: RequireOnlyOne<Pick<QueryFilter<FlagsFiltersOptions['team']>, '$eq' | '$in'>> | PrimitiveFilter<FlagsFiltersOptions['team']>; }>; export declare type FlagReportsFiltersOptions = { channel_cid?: string; is_reviewed?: boolean; message_id?: string; message_user_id?: string; report_id?: string; review_result?: string; reviewed_by?: string; team?: string; user_id?: string; }; export declare type FlagReportsFilters = QueryFilters<{ report_id?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['report_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['report_id']>; } & { review_result?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['review_result']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['review_result']>; } & { reviewed_by?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['reviewed_by']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['reviewed_by']>; } & { user_id?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['user_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['user_id']>; } & { message_id?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['message_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['message_id']>; } & { message_user_id?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['message_user_id']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['message_user_id']>; } & { channel_cid?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['channel_cid']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['channel_cid']>; } & { team?: RequireOnlyOne<Pick<QueryFilter<FlagReportsFiltersOptions['team']>, '$eq' | '$in'>> | PrimitiveFilter<FlagReportsFiltersOptions['team']>; } & { [Key in keyof Omit<FlagReportsFiltersOptions, 'report_id' | 'user_id' | 'message_id' | 'review_result' | 'reviewed_by'>]: RequireOnlyOne<QueryFilter<FlagReportsFiltersOptions[Key]>> | PrimitiveFilter<FlagReportsFiltersOptions[Key]>; }>; export declare type BannedUsersFilterOptions = { banned_by_id?: string; channel_cid?: string; created_at?: string; reason?: string; user_id?: string; }; export declare type BannedUsersFilters = QueryFilters<{ channel_cid?: RequireOnlyOne<Pick<QueryFilter<BannedUsersFilterOptions['channel_cid']>, '$eq' | '$in'>> | PrimitiveFilter<BannedUsersFilterOptions['channel_cid']>; } & { reason?: RequireOnlyOne<{ $autocomplete?: BannedUsersFilterOptions['reason']; } & QueryFilter<BannedUsersFilterOptions['reason']>> | PrimitiveFilter<BannedUsersFilterOptions['reason']>; } & { [Key in keyof Omit<BannedUsersFilterOptions, 'channel_cid' | 'reason'>]: RequireOnlyOne<QueryFilter<BannedUsersFilterOptions[Key]>> | PrimitiveFilter<BannedUsersFilterOptions[Key]>; }>; export declare type ReactionFilters<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = QueryFilters<{ user_id?: RequireOnlyOne<Pick<QueryFilter<ReactionResponse<StreamChatGenerics>['user_id']>, '$eq' | '$in'>> | PrimitiveFilter<ReactionResponse<StreamChatGenerics>['user_id']>; } & { type?: RequireOnlyOne<Pick<QueryFilter<ReactionResponse<StreamChatGenerics>['type']>, '$eq'>> | PrimitiveFilter<ReactionResponse<StreamChatGenerics>['type']>; } & { created_at?: RequireOnlyOne<Pick<QueryFilter<PollResponse['created_at']>, '$eq' | '$gt' | '$lt' | '$gte' | '$lte'>> | PrimitiveFilter<PollResponse['created_at']>; }>; export declare type ChannelFilters<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = QueryFilters<ContainsOperator<StreamChatGenerics['channelType']> & { members?: RequireOnlyOne<Pick<QueryFilter<string>, '$in' | '$nin'>> | RequireOnlyOne<Pick<QueryFilter<string[]>, '$eq'>> | PrimitiveFilter<string[]>; } & { name?: RequireOnlyOne<{ $autocomplete?: ChannelResponse<StreamChatGenerics>['name']; } & QueryFilter<ChannelResponse<StreamChatGenerics>['name']>> | PrimitiveFilter<ChannelResponse<StreamChatGenerics>['name']>; } & { [Key in keyof Omit<ChannelResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: {}; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; memberType: StreamChatGenerics['memberType']; messageType: StreamChatGenerics['messageType']; pollOptionType: StreamChatGenerics['pollOptionType']; pollType: StreamChatGenerics['pollType']; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>, 'name' | 'members'>]: RequireOnlyOne<QueryFilter<ChannelResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: {}; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; memberType: StreamChatGenerics['