import { RequestApi } from '../constant/api'; import { ConversationQueryType, GroupType, MessageType, ConnectionCloseReason, GroupEventType } from './enum'; import { HttpMethod } from '../utils/request'; import { MessageService } from '../api/message'; import { ConversationService } from '../api/conversation'; import { GroupService } from '../api/group'; import { UserService } from '../api/user'; import { ContactService } from '../api/contact'; export type ServiceTypes = { user: UserService; message: MessageService; conversation: ConversationService; group: GroupService; contact: ContactService; }; export declare enum ServiceName { MESSAGE = "message", CONVERSATION = "conversation", GROUP = "group", USER = "user", CONTACT = "contact" } export interface Request { url: RequestApi; username?: string; data: Record | undefined; method: HttpMethod; } export interface SseData { ev: number; dt: MessageItem[]; } export interface ServerResponse { type?: MessageType; code: number; msg: string; data: T; timestamp?: number; } export type Pagination = { offset: number; count: number; }; export type ConversationItem = { id: number; /** 群/会话业务 ID;缓存与推送映射仅用此字段(接口未单独下发时由 normalizeConversation 用 id 填入) */ groupId: number; name: string; chatId?: number; groupType: GroupType; avatar: string; status: number; latest: MessageItem; unreadCount: number; lastRead?: number; draftText: string; custom: string; groupMemberId: string; pin: boolean; mute: boolean; supportId?: string | null; supportNick?: string | null; identity: number; }; /** OnConversationListUpdated 事件载荷:包含会话列表及对应的 queryType */ export interface ConversationListUpdatedPayload { conversations: ConversationItem[]; queryType: number; } /** 历史消息拉取参数 */ export interface HistoryMessageParam { /** 群ID */ groupId: number; /** 上次拉取的最后一条消息ID */ lastId: string; /** 拉取类型:0 获取最新,1 获取大于lastId的,2 获取小于lastId */ type: 0 | 1 | 2; /** 拉取数量 */ size?: number; } export type LiveMessageParam = { groupId: number; }; export type ReqPageParam = { pageNo?: number; pageSize?: number; /** queryType≠0:第二页起必传(游标)。queryType=0 沿用原接口逻辑,不传也可 */ score?: number; /** 通用分页可选;拉会话列表请用 ReqConversationListParam(queryType 必填) */ queryType?: number; }; /** 获取会话列表:queryType 必传,见 ConversationQueryType */ export type ReqConversationListParam = Omit & { queryType: ConversationQueryType; }; export type ReqConversationQueryTypesParam = { pageNo?: number; pageSize?: number; /** queryTypes=5,7 是个数组,见 ConversationQueryType */ queryTypes: ConversationQueryType[]; }; /** * 连接关闭时传给前端的参数(OnDisconnected / onConnectionClosed) */ export interface ConnectionClosedPayload { /** 关闭原因枚举,前端可直接 switch(reason) 处理 */ reason: ConnectionCloseReason; } /** 群事件系统消息原始载荷(群事件 16 等;字段名与推送一致) */ export interface GroupEventRawMessage { msgType?: number; type?: number; groupId?: number; groupType?: number; memberIds?: unknown; content?: unknown; supportChatId?: number | string; supportNick?: string; data?: { eventType?: number; groupType?: number; supportChatId?: number | string; supportNick?: string; [key: string]: unknown; }; [key: string]: unknown; } export interface GroupEventPayload { groupId: number; type: GroupEventType; groupType?: number; content?: string; data: GroupEventRawMessage | NonNullable; } export interface SupportChatTransferPayload { /** 目标会话ID */ targetChatId: number; /** 类型 */ type: number; /** 客服会话ID;转出、未接入时 JSON 可能为 null */ supportChatId?: string | null; /** 客服昵称;可能为 null */ supportNick?: string | null; /** 群组ID */ groupId: number; } export type MarkConversationReadParam = { groupId?: number; id?: number; }; export type PageParam = { current: number; pages: number; size?: number; total?: number; records: T[]; }; interface AvatarMap { [username: string]: string; } export type MessageItem = { msgId: number; username: string; groupType: GroupType; groupId: number; replyMsgId: number; clientMsgId: string; recvId: string; receiverName: string; userId: number; send: number; to: number; msgType: MessageType; text?: string; link?: string; snapshot?: string; createTime: number; updateTime?: number; status: number; avatar?: string; /** 扩展字段(如 JSON 字符串,自定义业务数据;发送时随请求体一并提交) */ ext?: string; }; export interface GroupInfoVO { /** * 群名称 */ name: string; /** * 聊天群类型: 0:一对一私聊 ,1:群聊,2:客服聊天 */ groupType: GroupType; createTime: number; updateTime: number; /** * 创建人 */ createBy: number; /** * 群头像 */ avatar: string; /** * 群公告 */ announcement: string; /** * 群二维码 */ qrCode: string; /** * pin消息列表 */ pinMsg: string; /** * 群成员人数 */ membersCount: number; memberVOList: GroupMemberVO[]; /** * 人数上限 */ memberLimit: number; imagesCount: number; videosCount: number; filesCount: number; linksCount: number; gifsCount: number; /** * 群状态: 0:正常,1禁止发言,2解散 */ status: number; /** 私钥解密 */ s1?: string; /** 公钥加密 */ p2?: string; } export interface GroupMemberVO { username: string; /** * 群成员状态: 0:正常, 1:禁言, 2:删除 */ status: number; /** * 群身份: 0: owner, 1: admin, 2: user */ identity: number; remark: string; /** * 最后查看消息的时间 */ lastSeenTime: number; /** * 是否已经添加了好友 */ contact: boolean; } export interface HistoryMessageResponse { groupChatList: MessageItem[]; groupId: number; latest: MessageItem; avatarMap: AvatarMap; userId: number | null; } export interface MessagesListLoadedPayload { messages: MessageItem[]; groupId: number; lastId: string; error: string; } export interface ActiveConversationSyncPayload { conversationId: number; lastLocalMessageId?: number; serverLatestMessageId: number; timestamp: number; } export interface LatestMessagesUpdateResponse { ttl: number; groupChatIds: Record; } export interface GroupPermission { id?: number; /** * 权限状态: 0: 启用,1: 不启用 */ status?: number; /** * 权限描述 */ description?: string; /** * 权限值 */ value?: number; } export interface UpdateGroupPermission { /** 群id */ groupId: number; /** 更新的权限列表 */ permissions: GroupPermission[]; } export interface UpdateGroupMemberPermission { /** 群id */ groupId: number; /** * 群成员id */ targetMemberId: number; /** 更新的权限列表 */ permissions: GroupPermission[]; } export type SystemMessageResponse = { groupId: number; type: number; }; export interface KickGroupMemberParams { /** 群id */ groupId: number; /** * 0 :踢人 * 1:拉黑并踢人 */ kickType: number; /** 更新的权限列表 */ usernames: string[]; } export interface MuteMembersParams { /** 群id */ groupId: number; /** * 0: 禁言 ,1:解除禁言 */ type: number; /** 用户名列表 */ usernames: string[]; [key: string]: unknown; } /** * 批量添加群成员模型 */ export interface AddMembersModel { /** 群组ID */ groupId: number; /** 用户名列表 */ usernames: string[]; } /** * 联系人类型枚举 * 0: 查询会员 (客服对象:groupType 为 3 且 tag为 会员的) * 1: 查询同事 (私聊对象 groupType为0) * 2: 查询群聊 (groupType为 1和2) */ export declare enum ContactType { MEMBER = 0,// 会员 COLLEAGUE = 1,// 同事 GROUP = 2 } /** * 联系人信息 */ export interface ContactVO { /** 群id */ groupId: number; /** 群名称 */ name: string; /** 聊天群类型: 0:一对一私聊 ,1:群聊,2:客服聊天 */ groupType: number; /** 群头像 */ avatar: string; /** 如果是私聊或者客服聊天对象id */ targetChatId?: number; /** 聊天ID */ chatId?: number; /** * 如果查询的时候指定了groupId ,这里用来标识当前用户是否在群里 */ inGroup?: boolean; } /** * 联系人标签Bean */ export interface ContactTagBean { /** 标签名 */ tag: string; /** 联系人列表 */ contactVOList: ContactVO[]; } /** * 联系人列表模型 */ export interface ContactListModel { /** * 0 查询会员 : 客服对象:groupType 为 3 且 tag为 会员的 * 1 查询同事: 私聊对象 groupType为0 * 2 查询群聊: groupType为 1和2 * 不传即查询以上三种全部 */ concatType: ContactType; /** * 自己的chatId */ chatId: number; /** 联系人标签列表 */ contactTagBeans: ContactTagBean[]; } /** * 编辑联系人标签DTO */ export interface EditeContactTagDTO { /** * 0 会员 * 1 同事: * 2 群聊: */ contactType: ContactType; /** * 分组名称(逗号分割的字符串) */ tags: string; } /** * 分配联系人标签DTO */ export interface AllocationContactTagDTO { /** * 0 会员 * 1 同事: * 2 群聊: */ contactType: ContactType; /** * 分组名称 */ tag: string; /** * 这里存的是groupId */ groupIds: number[]; /** * 0 添加分组 ,1删除分组 */ type: number; } /** * 获取群文件参数 */ export interface GetFileByTypeParams { /** 群组ID */ groupId: number; /** 消息类型 */ msgType: MessageType; /** 页码,默认0 */ pageNo?: number; /** 每页大小,默认20 */ pageSize?: number; } /** * 客服消息预发送参数 */ export interface PushChatMessage { /** 接收者id */ recvId: number; msgType: MessageType; /** 消息内容 */ text?: string; /** 扩展字段(与 MessageItem.ext 一致) */ ext?: string; } /** * 聊天对象信息DTO */ export interface ChatMemberDTO { /** app用户id */ chatId: number; parentChatId: number; /** 昵称 */ nickname: string; /** 头像 */ avatar: string; /** 群组ID */ groupId: number; /** 等级 */ level: number; } export {};