UNPKG

@22g/netease-im-web-sdk

Version:

typescript netease-im-web-sdk

39 lines (31 loc) 1.82 kB
import { NIMAudioFile, NIMError, NIMFile, NIMGeo, NIMImageFile, NIMVideoFile } from './Basic'; import { NIMClientType } from './LoginPort'; import { IsInvalid, IsUndefinedLiteral, OmitStrict, Overwrite, PartialByKeys, RequiredByKeys, StringLike, StringWrap } from '@22g/utility-types'; import { NIMBasicMessage, NIMMessage } from './Message'; export type NIMJsonStringKeys = Extract<keyof NIMMessage, 'custom' | 'pushContent' | 'pushPayload' | 'localCustom' | 'content'>; /** * 处理一些`JSON String`的字段 * - [[NIMMessage.pushContent|`NIMMessage.pushContent`]] * - [[NIMMessage.pushPayload|`NIMMessage.pushPayload`]] * - [[NIMMessage.custom|`NIMMessage.custom`]] */ export interface NIMBasicMessageEx<T extends Partial<Record<Extract<NIMJsonStringKeys, keyof NIMBasicMessage>, {} | StringLike>> = {}> extends Omit<NIMBasicMessage, Extract<NIMJsonStringKeys, keyof NIMBasicMessage>> { /** 自定义推送文案 */ pushContent?: IsUndefinedLiteral<IsInvalid<T['pushContent'], undefined>, {} | StringLike>; /** 自定义的推送属性 */ pushPayload?: IsUndefinedLiteral<IsInvalid<T['pushPayload'], undefined>, {} | StringLike>; /** 扩展字段 */ custom?: IsUndefinedLiteral<IsInvalid<T['custom'], undefined>, {} | StringLike>; } export interface NIMMessageEx<T extends Partial<Record<NIMJsonStringKeys, {} | StringLike>> = {}> extends NIMBasicMessageEx<T> { /** 文本消息的文本内容 */ text?: string; /** 文件消息的文件对象 */ file?: NIMFile | NIMAudioFile | NIMImageFile | NIMVideoFile; /** 地理位置消息的地理位置对象, */ geo?: NIMGeo; /** 提醒消息的内容 */ tip?: string; /** 自定义消息的消息内容 */ content?: IsUndefinedLiteral<IsInvalid<T['content'], undefined>, {} | StringLike>; }