import { AxiosRequestConfig } from 'axios'; import { EVENT_MAP } from './events'; import { Role } from './permissions'; /** * Utility Types */ export type ArrayOneOrMore = { 0: T; } & Array; export type ArrayTwoOrMore = { 0: T; 1: T; } & Array; export type KnownKeys = { [K in keyof T]: string extends K ? never : number extends K ? never : K; } extends { [_ in keyof T]: infer U } ? U : never; export type RequireAtLeastOne = { [K in keyof T]-?: Required> & Partial>>; }[keyof T]; export type RequireOnlyOne = Pick> & { [K in Keys]-?: Required> & Partial, undefined>>; }[Keys]; /* Unknown Record */ export type UR = Record; export type UnknownType = UR; //alias to avoid breaking change export type DefaultGenerics = { attachmentType: UR; channelType: UR; commandType: LiteralStringForUnion; eventType: UR; messageType: UR; reactionType: UR; userType: UR; }; export type ExtendableGenerics = { attachmentType: UR; channelType: UR; commandType: string; eventType: UR; messageType: UR; reactionType: UR; userType: UR; }; export type Unpacked = T extends (infer U)[] ? U // eslint-disable-next-line @typescript-eslint/no-explicit-any : T extends (...args: any[]) => infer U ? U : T extends Promise ? U : T; /** * Response Types */ export type APIResponse = { duration: string; }; export type AppSettingsAPIResponse = APIResponse & { app?: { channel_configs: Record< string, { automod?: ChannelConfigAutomod; automod_behavior?: ChannelConfigAutomodBehavior; blocklist_behavior?: ChannelConfigAutomodBehavior; commands?: CommandVariants[]; connect_events?: boolean; created_at?: string; custom_events?: boolean; max_message_length?: number; message_retention?: string; mutes?: boolean; name?: string; 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; } >; async_url_enrich_enabled?: boolean; auto_translation_enabled?: boolean; before_message_send_hook_url?: string; campaign_enabled?: boolean; custom_action_handler_url?: string; disable_auth_checks?: boolean; disable_permissions_checks?: boolean; enforce_unique_usernames?: 'no' | 'app' | 'team'; file_upload_config?: FileUploadConfig; grants?: Record; image_moderation_enabled?: boolean; image_upload_config?: FileUploadConfig; multi_tenant_enabled?: boolean; name?: string; organization?: string; permission_version?: string; policies?: Record; push_notifications?: { version: string; apn?: APNConfig; firebase?: FirebaseConfig; huawei?: HuaweiConfig; providers?: PushProviderConfig[]; xiaomi?: XiaomiConfig; }; revoke_tokens_issued_before?: string | null; search_backend?: 'disabled' | 'elasticsearch' | 'postgres'; sqs_key?: string; sqs_secret?: string; sqs_url?: string; suspended?: boolean; suspended_explanation?: string; user_search_disallowed_roles?: string[] | null; webhook_events?: Array; webhook_url?: string; }; }; export 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 type AutomodDetails = { action?: string; image_labels?: Array; original_message_type?: string; result?: ModerationResult; }; export type FlagDetails = { automod?: AutomodDetails; }; export type Flag = { created_at: string; created_by_automod: boolean; updated_at: string; details?: FlagDetails; target_message?: MessageResponse; target_user?: UserResponse; user?: UserResponse; }; export type FlagsResponse = APIResponse & { flags?: Array>; }; export type MessageFlagsResponse = APIResponse & { flags?: Array<{ message: MessageResponse; user: UserResponse; approved_at?: string; created_at?: string; created_by_automod?: boolean; moderation_result?: ModerationResult; rejected_at?: string; reviewed_at?: string; reviewed_by?: UserResponse; updated_at?: string; }>; }; export type FlagReport = { flags_count: number; id: string; message: MessageResponse; user: UserResponse; created_at?: string; details?: FlagDetails; review_result?: string; reviewed_at?: string; reviewed_by?: UserResponse; updated_at?: string; }; export type FlagReportsResponse = APIResponse & { flag_reports: Array>; }; export type ReviewFlagReportResponse = APIResponse & { flag_report: FlagReport; }; export type BannedUsersResponse = APIResponse & { bans?: Array<{ user: UserResponse; banned_by?: UserResponse; channel?: ChannelResponse; expires?: string; ip_ban?: boolean; reason?: string; timeout?: number; }>; }; export type BlockListResponse = BlockList & { created_at?: string; updated_at?: string; }; export 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; cooldown?: number; created_at?: string; created_by?: UserResponse | null; created_by_id?: string; deleted_at?: string; hidden?: boolean; invites?: string[]; last_message_at?: string; member_count?: number; members?: ChannelMemberResponse[]; muted?: boolean; name?: string; own_capabilities?: string[]; team?: string; truncated_at?: string; updated_at?: string; }; export type ChannelAPIResponse = APIResponse & { channel: ChannelResponse; members: ChannelMemberResponse[]; messages: MessageResponse[]; pinned_messages: MessageResponse[]; hidden?: boolean; membership?: ChannelMembership | null; read?: ReadResponse[]; watcher_count?: number; watchers?: UserResponse[]; }; export type ChannelUpdateOptions = { hide_history?: boolean; skip_push?: boolean; }; export type ChannelMemberAPIResponse = APIResponse & { members: ChannelMemberResponse[]; }; export type ChannelMemberResponse = { banned?: boolean; channel_role?: Role; created_at?: string; invite_accepted_at?: string; invite_rejected_at?: string; invited?: boolean; is_moderator?: boolean; role?: string; shadow_banned?: boolean; updated_at?: string; user?: UserResponse; user_id?: string; }; export 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 type CheckSQSResponse = APIResponse & { status: string; data?: {}; error?: string; }; export type CommandResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = Partial & { args?: string; description?: string; name?: CommandVariants; set?: CommandVariants; }; export type ConnectAPIResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = Promise>; export type CreateChannelResponse = APIResponse & Omit, 'client_id' | 'connection_id'> & { created_at: string; updated_at: string; grants?: Record; }; export type CreateCommandResponse = APIResponse & { command: CreateCommandOptions & CreatedAtUpdatedAt; }; export type DeleteChannelAPIResponse = APIResponse & { channel: ChannelResponse; }; export type DeleteCommandResponse = APIResponse & { name?: CommandVariants; }; export type EventAPIResponse = APIResponse & { event: Event; }; export type ExportChannelResponse = { task_id: string; }; export type ExportUsersResponse = { task_id: string; }; export type ExportChannelStatusResponse = { created_at?: string; error?: {}; result?: {}; updated_at?: string; }; export type FlagMessageResponse = APIResponse & { flag: { created_at: string; created_by_automod: boolean; target_message_id: string; updated_at: string; user: UserResponse; approved_at?: string; channel_cid?: string; details?: Object; // Any JSON message_user_id?: string; rejected_at?: string; reviewed_at?: string; reviewed_by?: string; }; }; export type FlagUserResponse = APIResponse & { flag: { created_at: string; created_by_automod: boolean; target_user: UserResponse; updated_at: string; user: UserResponse; approved_at?: string; details?: Object; // Any JSON rejected_at?: string; reviewed_at?: string; reviewed_by?: string; }; }; export type FormatMessageResponse = Omit< MessageResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: {}; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>, 'created_at' | 'pinned_at' | 'updated_at' | 'status' > & StreamChatGenerics['messageType'] & { created_at: Date; pinned_at: Date | null; status: string; updated_at: Date; }; export type GetChannelTypeResponse = APIResponse & Omit, 'client_id' | 'connection_id' | 'commands'> & { created_at: string; updated_at: string; commands?: CommandResponse[]; grants?: Record; }; export type GetCommandResponse = APIResponse & CreateCommandOptions & CreatedAtUpdatedAt; export type GetMultipleMessagesAPIResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = APIResponse & { messages: MessageResponse[]; }; export type GetRateLimitsResponse = APIResponse & { android?: RateLimitsMap; ios?: RateLimitsMap; server_side?: RateLimitsMap; web?: RateLimitsMap; }; export type GetReactionsAPIResponse = APIResponse & { reactions: ReactionResponse[]; }; export type GetRepliesAPIResponse = APIResponse & { messages: MessageResponse[]; }; export type ListChannelResponse = APIResponse & { channel_types: Record< string, Omit, 'client_id' | 'connection_id' | 'commands'> & { commands: CommandResponse[]; created_at: string; updated_at: string; grants?: Record; } >; }; export type ListChannelTypesAPIResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = ListChannelResponse; export type ListCommandsResponse = APIResponse & { commands: Array & Partial>; }; export type MuteChannelAPIResponse = APIResponse & { channel_mute: ChannelMute; own_user: OwnUserResponse; channel_mutes?: ChannelMute[]; mute?: MuteResponse; }; export type MessageResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = MessageResponseBase & { quoted_message?: MessageResponseBase; }; export type MessageResponseBase< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = MessageBase & { args?: string; channel?: ChannelResponse; cid?: string; command?: string; command_info?: { name?: string }; created_at?: string; deleted_at?: string; i18n?: RequireAtLeastOne> & { language: TranslationLanguages; }; latest_reactions?: ReactionResponse[]; mentioned_users?: UserResponse[]; own_reactions?: ReactionResponse[] | null; pin_expires?: string | null; pinned_at?: string | null; pinned_by?: UserResponse | null; reaction_counts?: { [key: string]: number } | null; reaction_scores?: { [key: string]: number } | null; reply_count?: number; shadowed?: boolean; silent?: boolean; status?: string; thread_participants?: UserResponse[]; type?: MessageLabel; updated_at?: string; }; export type MuteResponse = { user: UserResponse; created_at?: string; expires?: string; target?: UserResponse; updated_at?: string; }; export type MuteUserResponse = APIResponse & { mute?: MuteResponse; mutes?: Array>; own_user?: OwnUserResponse; }; export type OwnUserBase = { channel_mutes: ChannelMute[]; devices: Device[]; mutes: Mute[]; total_unread_count: number; unread_channels: number; unread_count: number; invisible?: boolean; roles?: string[]; }; export type OwnUserResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = UserResponse & OwnUserBase; export type PartialUpdateChannelAPIResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = APIResponse & { channel: ChannelResponse; members: ChannelMemberResponse[]; }; export type PermissionAPIResponse = APIResponse & { permission?: PermissionAPIObject; }; export type PermissionsAPIResponse = APIResponse & { permissions?: PermissionAPIObject[]; }; export type ReactionAPIResponse = APIResponse & { message: MessageResponse; reaction: ReactionResponse; }; export type ReactionResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = Reaction & { created_at: string; updated_at: string; }; export type ReadResponse = { last_read: string; user: UserResponse; unread_messages?: number; }; export type SearchAPIResponse = APIResponse & { results: { message: MessageResponse; }[]; next?: string; previous?: string; results_warning?: SearchWarning | null; }; export type SearchWarning = { channel_search_cids: string[]; channel_search_count: number; warning_code: number; warning_description: string; }; export type SendFileAPIResponse = APIResponse & { file: string }; export type SendMessageAPIResponse = APIResponse & { message: MessageResponse; }; export type TruncateChannelAPIResponse< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = APIResponse & { channel: ChannelResponse; message?: MessageResponse; }; export type UpdateChannelAPIResponse = APIResponse & { channel: ChannelResponse; members: ChannelMemberResponse[]; message?: MessageResponse; }; export type UpdateChannelResponse = APIResponse & Omit, 'client_id' | 'connection_id'> & { created_at: string; updated_at: string; }; export type UpdateCommandResponse = APIResponse & { command: UpdateCommandOptions & CreatedAtUpdatedAt & { name: CommandVariants; }; }; export type UpdateMessageAPIResponse = APIResponse & { message: MessageResponse; }; export type UsersAPIResponse = APIResponse & { users: Array>; }; export type UpdateUsersAPIResponse = APIResponse & { users: { [key: string]: UserResponse }; }; export type UserResponse = User & { banned?: boolean; created_at?: string; deactivated_at?: string; deleted_at?: string; language?: TranslationLanguages | ''; last_active?: string; online?: boolean; push_notifications?: PushNotificationSettings; revoke_tokens_issued_before?: string; shadow_banned?: boolean; updated_at?: string; }; export type PushNotificationSettings = { disabled?: boolean; disabled_until?: string | null; }; /** * Option Types */ export type MessageFlagsPaginationOptions = { limit?: number; offset?: number; }; export type FlagsPaginationOptions = { limit?: number; offset?: number; }; export type FlagReportsPaginationOptions = { limit?: number; offset?: number; }; export type ReviewFlagReportOptions = { review_details?: Object; user_id?: string; }; export type BannedUsersPaginationOptions = Omit; export type BanUserOptions = UnBanUserOptions & { banned_by?: UserResponse; banned_by_id?: string; ip_ban?: boolean; reason?: string; timeout?: number; }; export type ChannelOptions = { limit?: number; member_limit?: number; message_limit?: number; offset?: number; presence?: boolean; state?: boolean; user_id?: string; watch?: boolean; }; export type ChannelQueryOptions = { client_id?: string; connection_id?: string; data?: ChannelResponse; members?: PaginationOptions; messages?: MessagePaginationOptions; presence?: boolean; state?: boolean; watch?: boolean; watchers?: PaginationOptions; }; export type ChannelStateOptions = { skipInitialization?: string[]; }; export type CreateChannelOptions = { automod?: ChannelConfigAutomod; automod_behavior?: ChannelConfigAutomodBehavior; automod_thresholds?: ChannelConfigAutomodThresholds; blocklist?: string; blocklist_behavior?: ChannelConfigAutomodBehavior; client_id?: string; commands?: CommandVariants[]; connect_events?: boolean; connection_id?: string; custom_events?: boolean; grants?: Record; max_message_length?: number; message_retention?: string; mutes?: boolean; name?: string; permissions?: PermissionObject[]; push_notifications?: boolean; quotes?: boolean; reactions?: boolean; read_events?: boolean; replies?: boolean; search?: boolean; typing_events?: boolean; uploads?: boolean; url_enrichment?: boolean; }; export type CreateCommandOptions = { description: string; name: CommandVariants; args?: string; set?: CommandVariants; }; export type CustomPermissionOptions = { action: string; condition: object; id: string; name: string; description?: string; owner?: boolean; same_team?: boolean; }; // TODO: rename to UpdateChannelOptions in the next major update and use it in channel._update and/or channel.update export type InviteOptions = { accept_invite?: boolean; add_members?: string[]; add_moderators?: string[]; client_id?: string; connection_id?: string; data?: Omit, 'id' | 'cid'>; demote_moderators?: string[]; invites?: string[]; message?: MessageResponse; reject_invite?: boolean; remove_members?: string[]; user?: UserResponse; user_id?: string; }; /** @deprecated use MarkChannelsReadOptions instead */ export type MarkAllReadOptions< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = MarkChannelsReadOptions; export type MarkChannelsReadOptions = { client_id?: string; connection_id?: string; read_by_channel?: Record; user?: UserResponse; user_id?: string; }; export type MarkReadOptions = { client_id?: string; connection_id?: string; message_id?: string; user?: UserResponse; user_id?: string; }; export type MuteUserOptions = { client_id?: string; connection_id?: string; id?: string; reason?: string; target_user_id?: string; timeout?: number; type?: string; user?: UserResponse; user_id?: string; }; export 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 type MessagePaginationOptions = PaginationOptions & { created_at_around?: string | Date; id_around?: string; }; export 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 type QueryMembersOptions = { limit?: number; offset?: number; user_id_gt?: string; user_id_gte?: string; user_id_lt?: string; user_id_lte?: string; }; export type SearchOptions = { limit?: number; next?: string; offset?: number; sort?: SearchMessageSort; }; export type StreamChatOptions = AxiosRequestConfig & { /** * Used to disable warnings that are triggered by using connectUser or connectAnonymousUser server-side. */ allowServerSideConnect?: boolean; /** * Base url to use for API * such as https://chat-proxy-dublin.stream-io-api.com */ baseURL?: string; browser?: boolean; device?: BaseDeviceFields; enableInsights?: boolean; /** experimental feature, please contact support if you want this feature enabled for you */ enableWSFallback?: boolean; logger?: Logger; /** * 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; }; export type UnBanUserOptions = { client_id?: string; connection_id?: string; id?: string; shadow?: boolean; target_user_id?: string; type?: string; }; // TODO: rename to UpdateChannelTypeOptions in the next major update export type UpdateChannelOptions = Omit< CreateChannelOptions, 'name' > & { created_at?: string; updated_at?: string; }; export type UpdateCommandOptions = { description: string; args?: string; set?: CommandVariants; }; export type UserOptions = { limit?: number; offset?: number; presence?: boolean; }; /** * Event Types */ export type ConnectionChangeEvent = { type: EventTypes; online?: boolean; }; export type Event = StreamChatGenerics['eventType'] & { type: EventTypes; channel?: ChannelResponse; channel_id?: string; channel_type?: string; cid?: string; clear_history?: boolean; connection_id?: string; created_at?: string; hard_delete?: boolean; mark_messages_deleted?: boolean; me?: OwnUserResponse; member?: ChannelMemberResponse; message?: MessageResponse; online?: boolean; parent_id?: string; reaction?: ReactionResponse; received_at?: string | Date; team?: string; total_unread_count?: number; unread_channels?: number; unread_count?: number; user?: UserResponse; user_id?: string; watcher_count?: number; }; export type UserCustomEvent< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = StreamChatGenerics['eventType'] & { type: string; }; export type EventHandler = ( event: Event, ) => void; export type EventTypes = 'all' | keyof typeof EVENT_MAP; /** * Filter Types */ export type AscDesc = 1 | -1; export type MessageFlagsFiltersOptions = { channel_cid?: string; is_reviewed?: boolean; team?: string; user_id?: string; }; export type MessageFlagsFilters = QueryFilters< { channel_cid?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { team?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { user_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { [Key in keyof Omit]: | RequireOnlyOne> | PrimitiveFilter; } >; export type FlagsFiltersOptions = { channel_cid?: string; message_id?: string; message_user_id?: string; reporter_id?: string; team?: string; user_id?: string; }; export type FlagsFilters = QueryFilters< { user_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { message_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { message_user_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { channel_cid?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { reporter_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { team?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } >; export 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 type FlagReportsFilters = QueryFilters< { report_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { review_result?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { reviewed_by?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { user_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { message_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { message_user_id?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { channel_cid?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { team?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { [Key in keyof Omit< FlagReportsFiltersOptions, 'report_id' | 'user_id' | 'message_id' | 'review_result' | 'reviewed_by' >]: RequireOnlyOne> | PrimitiveFilter; } >; export type BannedUsersFilterOptions = { banned_by_id?: string; channel_cid?: string; created_at?: string; reason?: string; user_id?: string; }; export type BannedUsersFilters = QueryFilters< { channel_cid?: | RequireOnlyOne, '$eq' | '$in'>> | PrimitiveFilter; } & { reason?: | RequireOnlyOne< { $autocomplete?: BannedUsersFilterOptions['reason']; } & QueryFilter > | PrimitiveFilter; } & { [Key in keyof Omit]: | RequireOnlyOne> | PrimitiveFilter; } >; export type ChannelFilters = QueryFilters< ContainsOperator & { members?: | RequireOnlyOne, '$in' | '$nin'>> | RequireOnlyOne, '$eq'>> | PrimitiveFilter; } & { name?: | RequireOnlyOne< { $autocomplete?: ChannelResponse['name']; } & QueryFilter['name']> > | PrimitiveFilter['name']>; } & { [Key in keyof Omit< ChannelResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: {}; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: StreamChatGenerics['messageType']; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>, 'name' | 'members' >]: | RequireOnlyOne< QueryFilter< ChannelResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: {}; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: StreamChatGenerics['messageType']; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>[Key] > > | PrimitiveFilter< ChannelResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: {}; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: StreamChatGenerics['messageType']; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>[Key] >; } >; export type ContainsOperator = { [Key in keyof CustomType]?: CustomType[Key] extends (infer ContainType)[] ? | RequireOnlyOne< { $contains?: ContainType extends object ? PrimitiveFilter> : PrimitiveFilter; } & QueryFilter[]> > | PrimitiveFilter[]> : RequireOnlyOne> | PrimitiveFilter; }; export type MessageFilters = QueryFilters< ContainsOperator & { text?: | RequireOnlyOne< { $autocomplete?: MessageResponse['text']; $q?: MessageResponse['text']; } & QueryFilter['text']> > | PrimitiveFilter['text']>; } & { [Key in keyof Omit< MessageResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: {}; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>, 'text' >]?: | RequireOnlyOne< QueryFilter< MessageResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: {}; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>[Key] > > | PrimitiveFilter< MessageResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: {}; reactionType: StreamChatGenerics['reactionType']; userType: StreamChatGenerics['userType']; }>[Key] >; } >; export type PrimitiveFilter = ObjectType | null; export type QueryFilter = NonNullable extends string | number | boolean ? { $eq?: PrimitiveFilter; $exists?: boolean; $gt?: PrimitiveFilter; $gte?: PrimitiveFilter; $in?: PrimitiveFilter[]; $lt?: PrimitiveFilter; $lte?: PrimitiveFilter; $ne?: PrimitiveFilter; $nin?: PrimitiveFilter[]; } : { $eq?: PrimitiveFilter; $exists?: boolean; $in?: PrimitiveFilter[]; $ne?: PrimitiveFilter; $nin?: PrimitiveFilter[]; }; export type QueryFilters = { [Key in keyof Operators]?: Operators[Key]; } & QueryLogicalOperators; export type QueryLogicalOperators = { $and?: ArrayOneOrMore>; $nor?: ArrayOneOrMore>; $or?: ArrayTwoOrMore>; }; export type UserFilters = QueryFilters< ContainsOperator & { id?: | RequireOnlyOne< { $autocomplete?: UserResponse['id'] } & QueryFilter< UserResponse['id'] > > | PrimitiveFilter['id']>; name?: | RequireOnlyOne< { $autocomplete?: UserResponse['name'] } & QueryFilter< UserResponse['name'] > > | PrimitiveFilter['name']>; teams?: | RequireOnlyOne<{ $contains?: PrimitiveFilter; $eq?: PrimitiveFilter['teams']>; }> | PrimitiveFilter['teams']>; username?: | RequireOnlyOne< { $autocomplete?: UserResponse['username'] } & QueryFilter< UserResponse['username'] > > | PrimitiveFilter['username']>; } & { [Key in keyof Omit< UserResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: StreamChatGenerics['messageType']; reactionType: StreamChatGenerics['reactionType']; userType: {}; }>, 'id' | 'name' | 'teams' | 'username' >]?: | RequireOnlyOne< QueryFilter< UserResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: StreamChatGenerics['messageType']; reactionType: StreamChatGenerics['reactionType']; userType: {}; }>[Key] > > | PrimitiveFilter< UserResponse<{ attachmentType: StreamChatGenerics['attachmentType']; channelType: StreamChatGenerics['channelType']; commandType: StreamChatGenerics['commandType']; eventType: StreamChatGenerics['eventType']; messageType: StreamChatGenerics['messageType']; reactionType: StreamChatGenerics['reactionType']; userType: {}; }>[Key] >; } >; /** * Sort Types */ export type BannedUsersSort = BannedUsersSortBase | Array; export type BannedUsersSortBase = { created_at?: AscDesc }; export type ChannelSort = | ChannelSortBase | Array>; export type ChannelSortBase< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = Sort & { created_at?: AscDesc; has_unread?: AscDesc; last_message_at?: AscDesc; last_updated?: AscDesc; member_count?: AscDesc; unread_count?: AscDesc; updated_at?: AscDesc; }; export type PinnedMessagesSort = PinnedMessagesSortBase | Array; export type PinnedMessagesSortBase = { pinned_at?: AscDesc }; export type Sort = { [P in keyof T]?: AscDesc; }; export type UserSort = | Sort> | Array>>; export type MemberSort = | Sort, 'id' | 'created_at' | 'name'>> | Array, 'id' | 'created_at' | 'name'>>>; export type SearchMessageSortBase = Sort< StreamChatGenerics['messageType'] > & { attachments?: AscDesc; 'attachments.type'?: AscDesc; created_at?: AscDesc; id?: AscDesc; 'mentioned_users.id'?: AscDesc; parent_id?: AscDesc; pinned?: AscDesc; relevance?: AscDesc; reply_count?: AscDesc; text?: AscDesc; type?: AscDesc; updated_at?: AscDesc; 'user.id'?: AscDesc; }; export type SearchMessageSort = | SearchMessageSortBase | Array>; export type QuerySort = | BannedUsersSort | ChannelSort | SearchMessageSort | UserSort; /** * Base Types */ export type Action = { name?: string; style?: string; text?: string; type?: string; value?: string; }; export type AnonUserType = {}; export type APNConfig = { auth_key?: string; auth_type?: string; bundle_id?: string; development?: boolean; enabled?: boolean; host?: string; key_id?: string; notification_template?: string; p12_cert?: string; team_id?: string; }; export type AppSettings = { apn_config?: { auth_key?: string; auth_type?: string; bundle_id?: string; development?: boolean; host?: string; key_id?: string; notification_template?: string; p12_cert?: string; team_id?: string; }; async_url_enrich_enabled?: boolean; auto_translation_enabled?: boolean; custom_action_handler_url?: string; disable_auth_checks?: boolean; disable_permissions_checks?: boolean; enforce_unique_usernames?: 'no' | 'app' | 'team'; // all possible file mime types are https://www.iana.org/assignments/media-types/media-types.xhtml file_upload_config?: FileUploadConfig; firebase_config?: { credentials_json?: string; data_template?: string; notification_template?: string; server_key?: string; }; grants?: Record; huawei_config?: { id: string; secret: string; }; image_moderation_enabled?: boolean; image_upload_config?: FileUploadConfig; multi_tenant_enabled?: boolean; push_config?: { version?: string; }; revoke_tokens_issued_before?: string | null; sqs_key?: string; sqs_secret?: string; sqs_url?: string; webhook_events?: Array | null; webhook_url?: string; xiaomi_config?: { package_name: string; secret: string; }; }; export type Attachment< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = StreamChatGenerics['attachmentType'] & { actions?: Action[]; asset_url?: string; author_icon?: string; author_link?: string; author_name?: string; color?: string; fallback?: string; fields?: Field[]; file_size?: number | string; footer?: string; footer_icon?: string; giphy?: GiphyData; image_url?: string; mime_type?: string; og_scrape_url?: string; original_height?: number; original_width?: number; pretext?: string; text?: string; thumb_url?: string; title?: string; title_link?: string; type?: string; }; export type OGAttachment = { og_scrape_url: string; asset_url?: string; // og:video | og:audio author_link?: string; // og:site author_name?: string; // og:site_name image_url?: string; // og:image text?: string; // og:description thumb_url?: string; // og:image title?: string; // og:title title_link?: string; // og:url type?: string | 'video' | 'audio' | 'image'; }; export type BlockList = { name: string; words: string[]; }; export type ChannelConfig = ChannelConfigFields & CreatedAtUpdatedAt & { commands?: CommandVariants[]; }; export type ChannelConfigAutomod = '' | 'AI' | 'disabled' | 'simple'; export type ChannelConfigAutomodBehavior = '' | 'block' | 'flag'; export type ChannelConfigAutomodThresholds = null | { explicit?: { block?: number; flag?: number }; spam?: { block?: number; flag?: number }; toxic?: { block?: number; flag?: number }; }; export type ChannelConfigFields = { automod?: ChannelConfigAutomod; automod_behavior?: ChannelConfigAutomodBehavior; blocklist_behavior?: ChannelConfigAutomodBehavior; connect_events?: boolean; custom_events?: boolean; max_message_length?: number; message_retention?: string; mutes?: boolean; name?: string; push_notifications?: boolean; quotes?: boolean; reactions?: boolean; read_events?: boolean; replies?: boolean; search?: boolean; typing_events?: boolean; uploads?: boolean; url_enrichment?: boolean; }; export type ChannelConfigWithInfo< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = ChannelConfigFields & CreatedAtUpdatedAt & { commands?: CommandResponse[]; }; export type ChannelData< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = StreamChatGenerics['channelType'] & { members?: string[]; name?: string; }; export type ChannelMembership = { banned?: boolean; channel_role?: Role; created_at?: string; is_moderator?: boolean; role?: string; shadow_banned?: boolean; updated_at?: string; user?: UserResponse; }; export type ChannelMute = { user: UserResponse; channel?: ChannelResponse; created_at?: string; expires?: string; updated_at?: string; }; export type ChannelRole = { custom?: boolean; name?: string; owner?: boolean; resource?: string; same_team?: boolean; }; export type CheckPushInput = { apn_template?: string; client_id?: string; connection_id?: string; firebase_data_template?: string; firebase_template?: string; message_id?: string; user?: UserResponse; user_id?: string; }; export type PushProvider = 'apn' | 'firebase' | 'huawei' | 'xiaomi'; export type PushProviderConfig = PushProviderCommon & PushProviderAPN & PushProviderFirebase & PushProviderHuawei & PushProviderXiaomi; export type PushProviderID = { name: string; type: PushProvider; }; export type PushProviderCommon = { created_at: string; updated_at: string; description?: string; disabled_at?: string; disabled_reason?: string; }; export type PushProviderAPN = { apn_auth_key?: string; apn_auth_type?: 'token' | 'certificate'; apn_development?: boolean; apn_host?: string; apn_key_id?: string; apn_notification_template?: string; apn_p12_cert?: string; apn_team_id?: string; apn_topic?: string; }; export type PushProviderFirebase = { firebase_credentials?: string; firebase_data_template?: string; firebase_notification_template?: string; firebase_server_key?: string; }; export type PushProviderHuawei = { huawei_app_id?: string; huawei_app_secret?: string; }; export type PushProviderXiaomi = { xiaomi_package_name?: string; xiaomi_secret?: string; }; export type CommandVariants = | 'all' | 'ban' | 'fun_set' | 'giphy' | 'moderation_set' | 'mute' | 'unban' | 'unmute' | StreamChatGenerics['commandType']; export type Configs = { [channel_type: string]: ChannelConfigWithInfo | undefined; }; export type ConnectionOpen = { connection_id: string; cid?: string; created_at?: string; me?: OwnUserResponse; type?: string; }; export type CreatedAtUpdatedAt = { created_at: string; updated_at: string; }; export type Device = DeviceFields & { provider?: string; user?: UserResponse; user_id?: string; }; export type BaseDeviceFields = { id: string; push_provider: PushProvider; push_provider_name?: string; }; export type DeviceFields = BaseDeviceFields & { created_at: string; disabled?: boolean; disabled_reason?: string; }; export type EndpointName = | 'Connect' | 'DeleteFile' | 'DeleteImage' | 'DeleteMessage' | 'DeleteUser' | 'DeactivateUser' | 'ExportUser' | 'DeleteReaction' | 'UpdateChannel' | 'UpdateChannelPartial' | 'UpdateMessage' | 'GetMessage' | 'GetManyMessages' | 'UpdateUsers' | 'UpdateUsersPartial' | 'CreateGuest' | 'GetOrCreateChannel' | 'StopWatchingChannel' | 'QueryChannels' | 'Search' | 'QueryUsers' | 'QueryMembers' | 'QueryBannedUsers' | 'GetReactions' | 'GetReplies' | 'Ban' | 'Unban' | 'Mute' | 'MuteChannel' | 'UnmuteChannel' | 'UnmuteUser' | 'RunMessageAction' | 'SendEvent' | 'MarkRead' | 'MarkAllRead' | 'SendMessage' | 'ImportChannelMessages' | 'UploadFile' | 'UploadImage' | 'UpdateApp' | 'GetApp' | 'CreateDevice' | 'DeleteDevice' | 'SendReaction' | 'Flag' | 'Unflag' | 'CreateChannelType' | 'DeleteChannel' | 'DeleteChannelType' | 'GetChannelType' | 'ListChannelTypes' | 'ListDevices' | 'TruncateChannel' | 'UpdateChannelType' | 'CheckPush' | 'PrivateSubmitModeration' | 'ReactivateUser' | 'HideChannel' | 'ShowChannel' | 'CreatePermission' | 'UpdatePermission' | 'GetPermission' | 'DeletePermission' | 'ListPermissions' | 'CreateRole' | 'DeleteRole' | 'ListRoles' | 'Sync' | 'TranslateMessage' | 'CreateCommand' | 'GetCommand' | 'UpdateCommand' | 'DeleteCommand' | 'ListCommands' | 'CreateBlockList' | 'UpdateBlockList' | 'GetBlockList' | 'ListBlockLists' | 'DeleteBlockList' | 'ExportChannels' | 'GetExportChannelsStatus' | 'CheckSQS' | 'GetRateLimits' | 'MessageUpdatePartial'; export type ExportChannelRequest = { id: string; type: string; cid?: string; messages_since?: Date; messages_until?: Date; }; export type ExportChannelOptions = { clear_deleted_message_text?: boolean; export_users?: boolean; include_truncated_messages?: boolean; version?: string; }; export type ExportUsersRequest = { user_ids: string[]; }; export type Field = { short?: boolean; title?: string; value?: string; }; export type FileUploadConfig = { allowed_file_extensions?: string[] | null; allowed_mime_types?: string[] | null; blocked_file_extensions?: string[] | null; blocked_mime_types?: string[] | null; }; export type FirebaseConfig = { credentials_json?: string; data_template?: string; enabled?: boolean; notification_template?: string; server_key?: string; }; type GiphyVersionInfo = { height: string; url: string; width: string; }; type GiphyVersions = | 'original' | 'fixed_height' | 'fixed_height_still' | 'fixed_height_downsampled' | 'fixed_width' | 'fixed_width_still' | 'fixed_width_downsampled'; type GiphyData = { [key in GiphyVersions]: GiphyVersionInfo; }; export type HuaweiConfig = { enabled?: boolean; id?: string; secret?: string; }; export type XiaomiConfig = { enabled?: boolean; package_name?: string; secret?: string; }; export type LiteralStringForUnion = string & {}; export type LogLevel = 'info' | 'error' | 'warn'; export type Logger = (logLevel: LogLevel, message: string, extraData?: Record) => void; export type Message = Partial< MessageBase > & { mentioned_users?: string[]; }; export type MessageBase< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = StreamChatGenerics['messageType'] & { id: string; attachments?: Attachment[]; html?: string; mml?: string; parent_id?: string; pin_expires?: string | null; pinned?: boolean; pinned_at?: string | null; quoted_message_id?: string; show_in_channel?: boolean; text?: string; user?: UserResponse | null; user_id?: string; }; export type MessageLabel = 'deleted' | 'ephemeral' | 'error' | 'regular' | 'reply' | 'system'; export type Mute = { created_at: string; target: UserResponse; updated_at: string; user: UserResponse; }; export type PartialUpdateChannel = { set?: Partial>; unset?: Array>; }; export type PartialUserUpdate = { id: string; set?: Partial>; unset?: Array>; }; export type MessageUpdatableFields = Omit< MessageResponse, 'cid' | 'created_at' | 'updated_at' | 'deleted_at' | 'user' | 'user_id' >; export type PartialMessageUpdate = { set?: Partial>; unset?: Array>; }; export type PermissionAPIObject = { action?: string; condition?: object; custom?: boolean; description?: string; id?: string; level?: string; name?: string; owner?: boolean; same_team?: boolean; tags?: string[]; }; export type PermissionObject = { action?: 'Deny' | 'Allow'; name?: string; owner?: boolean; priority?: number; resources?: string[]; roles?: string[]; }; export type Policy = { action?: 0 | 1; created_at?: string; name?: string; owner?: boolean; priority?: number; resources?: string[]; roles?: string[]; updated_at?: string; }; export type RateLimitsInfo = { limit: number; remaining: number; reset: number; }; export type RateLimitsMap = Record; export type Reaction< StreamChatGenerics extends ExtendableGenerics = DefaultGenerics > = StreamChatGenerics['reactionType'] & { type: string; message_id?: string; score?: number; user?: UserResponse | null; user_id?: string; }; export type Resource = | 'AddLinks' | 'BanUser' | 'CreateChannel' | 'CreateMessage' | 'CreateReaction' | 'DeleteAttachment' | 'DeleteChannel' | 'DeleteMessage' | 'DeleteReaction' | 'EditUser' | 'MuteUser' | 'ReadChannel' | 'RunMessageAction' | 'UpdateChannel' | 'UpdateChannelMembers' | 'UpdateMessage' | 'UpdateUser' | 'UploadAttachment'; export type SearchPayload = Omit< SearchOptions, 'sort' > & { client_id?: string; connection_id?: string; filter_conditions?: ChannelFilters; message_filter_conditions?: MessageFilters; query?: string; sort?: Array<{ direction: AscDesc; field: keyof SearchMessageSortBase; }>; }; export type TestPushDataInput = { apnTemplate?: string; firebaseDataTemplate?: string; firebaseTemplate?: string; messageID?: string; pushProviderName?: string; pushProviderType?: PushProvider; skipDevices?: boolean; }; export type TestSQSDataInput = { sqs_key?: string; sqs_secret?: string; sqs_url?: string; }; export type TokenOrProvider = null | string | TokenProvider | undefined; export type TokenProvider = () => Promise; export type TranslationLanguages = | '' | 'af' | 'am' | 'ar' | 'az' | 'bg' | 'bn' | 'bs' | 'cs' | 'da' | 'de' | 'el' | 'en' | 'es' | 'es-MX' | 'et' | 'fa' | 'fa-AF' | 'fi' | 'fr' | 'fr-CA' | 'ha' | 'he' | 'hi' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ka' | 'ko' | 'lv' | 'ms' | 'nl' | 'no' | 'pl' | 'ps' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'so' | 'sq' | 'sr' | 'sv' | 'sw' | 'ta' | 'th' | 'tl' | 'tr' | 'uk' | 'ur' | 'vi' | 'zh' | 'zh-TW'; export type TypingStartEvent = Event; export type ReservedMessageFields = | 'command' | 'created_at' | 'html' | 'latest_reactions' | 'own_reactions' | 'quoted_message' | 'reaction_counts' | 'reply_count' | 'type' | 'updated_at' | 'user' | '__html'; export type UpdatedMessage = Omit< MessageResponse, 'mentioned_users' > & { mentioned_users?: string[] }; export type User = StreamChatGenerics['userType'] & { id: string; anon?: boolean; name?: string; role?: string; teams?: string[]; username?: string; }; export type TaskResponse = { task_id: string; }; export type DeleteChannelsResponse = { result: Record; } & Partial; export type DeleteType = 'soft' | 'hard'; /* DeleteUserOptions specifies a collection of one or more `user_ids` to be deleted. `user` soft|hard determines if the user needs to be hard- or soft-deleted, where hard-delete implies that all related objects (messages, flags, etc) will be hard-deleted as well. `conversations` soft|hard will delete any 1to1 channels that the user was a member of. `messages` soft-hard will delete any messages that the user has sent. `new_channel_owner_id` any channels owned by the hard-deleted user will be transferred to this user ID */ export type DeleteUserOptions = { user: DeleteType; conversations?: DeleteType; messages?: DeleteType; new_channel_owner_id?: string; }; export type SegmentData = { description: string; // TODO: define this type in more detail filter: { channel?: object; user?: object; }; name: string; }; export type Segment = { app_pk: number; created_at: string; id: string; updated_at: string; recipients?: number; } & SegmentData; export type CampaignData = { attachments: Attachment[]; defaults: Record; name: string; segment_id: string; text: string; description?: string; push_notifications?: boolean; sender_id?: string; }; export type CampaignStatus = { errors: string[]; status: 'draft' | 'stopped' | 'scheduled' | 'completed' | 'failed' | 'canceled' | 'in_progress'; completed_at?: string; failed_at?: string; progress?: number; resumed_at?: string; scheduled_at?: string; stopped_at?: string; }; export type Campaign = { app_pk: string; created_at: string; id: string; updated_at: string; } & CampaignData & CampaignStatus; export type TaskStatus = { created_at: string; status: string; task_id: string; updated_at: string; error?: { description: string; type: string; }; result?: UR; }; export type TruncateOptions = { hard_delete?: boolean; message?: Message; skip_push?: boolean; truncated_at?: Date; }; export type CreateImportURLResponse = { path: string; upload_url: string; }; export type CreateImportResponse = { import_task: ImportTask; }; export type GetImportResponse = { import_task: ImportTask; }; export type ListImportsPaginationOptions = { limit?: number; offset?: number; }; export type ListImportsResponse = { import_tasks: ImportTask[]; }; export type ImportTaskHistory = { created_at: string; next_state: string; prev_state: string; }; export type ImportTask = { created_at: string; history: ImportTaskHistory[]; id: string; path: string; state: string; updated_at: string; result?: UR; size?: number; }; export type MessageSetType = 'latest' | 'current' | 'new'; export type PushProviderUpsertResponse = { push_provider: PushProvider; }; export type PushProviderListResponse = { push_providers: PushProvider[]; };