import { ArgumentMap } from 'eventemitter3'; import { FileProgressObject, UploadFileResult } from './CloudStorageServiceInterface'; export interface StrObj { [key: string]: string; } export interface StrAnyObj { [key: string]: any; } export interface NumAnyObj { [key: number]: any; } export declare type NIMEStrAnyObj = { [key: string]: any; }; export declare type AnyArr = any[]; export declare type NIMServiceName = 'auth' | 'V2NIMLoginService' | 'V2NIMLocalConversationService' | 'V2NIMConversationService' | 'V2NIMConversationIdUtil' | 'V2NIMConversationGroupService' | 'V2NIMMessageService' | 'V2NIMClientAntispamUtil' | 'V2NIMMessageLogUtil' | 'V2NIMMessageExtendUtil' | 'V2NIMNotificationService' | 'V2NIMStorageService' | 'V2NIMStorageUtil' | 'V2NIMTeamService' | 'V2NIMUserService' | 'V2NIMFriendService' | 'V2NIMSettingService' | 'V2NIMSyncService' | 'V2NIMAIService' | 'V2NIMSignallingService' | 'V2NIMSubscriptionService' | 'V2NIMMessageConverter' | 'V2NIMMessageCreator' | 'V2NIMMessageAttachmentCreator' | 'V2NIMPassthroughService' | 'V2NIMTopicService' | 'YSFService' | 'misc' | 'cloudStorage' | 'offlinePush' | 'qchatChannel' | 'qchatMedia' | 'qchatMsg' | 'qchatRole' | 'qchatServer'; export declare class NIMEBaseServiceClass { on(eventName: T, fn: (...args: ArgumentMap[Extract]) => void): void; once(eventName: T, fn: (...args: ArgumentMap[Extract]) => void): void; off(eventName: T, fn: (...args: ArgumentMap[Extract]) => void): void; removeAllListeners(eventName?: T | undefined): void; } /** * 基础 service 模块定义 * * 因 typedoc 无法编译 nodeModules 里的 eventEmitter,故而只能己方写个定义 */ export interface NIMEBaseServiceInterface { /** * 继承自 eventEmitter3 的监听事件方法 */ on(eventName: T, fn: (...args: ArgumentMap[Extract]) => void): void; /** * 继承自 eventEmitter3 的监听事件方法 */ once(eventName: T, fn: (...args: ArgumentMap[Extract]) => void): void; /** * 继承自 eventEmitter3 的取消监听方法 */ off(eventName: T, fn: (...args: ArgumentMap[Extract]) => void): void; /** * 继承自 eventEmitter3 的移除事件方法 */ removeAllListeners(eventName?: T): void; } export declare type NIMEBaseListener = { [key: string]: [...args: any]; }; export interface IBaseUploadFileOptions { /** * @Multi_Lang_Tag * @locale cn * JS 的 File 对象。该属性和 `fileInput`, `filePath`仅需要填一个即可 * * 该属性仅在使用 NIM_BROWSER_SDK.js 时可以使用 * @locale * * @locale en * File object of JS * * Browser specific * @locale */ file?: File; /** * @deprecated * *
* * 请使用 {@link IBaseUploadFileOptions.file} 属性 * * @Multi_Lang_Tag * @locale cn * 存储文件的 DOM 元素,与上面的 file 只要选填一个就可以了。 * * - 该属性仅在使用 NIM_BROWSER_SDK.js 时可以使用 * - 如果传字符串,最后会以 document.getElementById('fileInput').files[0] 拿到 File 对象 * - 如果传的是 DOM 节点,最后以 fileInput.files[0] 拿到 File 对象 * @locale * * @locale en * The DOM element that stores the file * * Browser specific, about to be deprecated * * If you pass a string, you will finally get the File object with document.getElementById('fileInput').files[0] * If the DOM node is passed, finally get the File object with fileInput.files[0] * @locale * */ fileInput?: string | HTMLInputElement; /** * @Multi_Lang_Tag * @locale cn * 临时文件路径 * * - uni-app,小程序等特殊的 JS 运行环境专用(chooseImage 拿到的临时路径) * - 仅当使用 NIM_UNIAPP_SDK.js, NIM_MINIAPP_SDK.js 时可以使用 * * @example * ```js * // 微信小程序选择视频,并发送视频文件消息 * wx.chooseMedia({ * count: 1, * mediaType: ['video'], * success: (res) => { * let r = this.nim.msg.sendVideoMsg({ * "scene": "p2p", * "to": "cs5", * "filePath": res.tempFiles[0].tempFilePath * }) * r.then((res) => { * // 输出结果 * console.log('sendVideoMsg 完成:', res) * }).catch((e) => { * console.error('sendVideoMsg 出错:', e) * }) * } * }) * ``` * @locale * * @locale en * Temporary file path * * uni-app, RN, applet, and other special JS runtime environment dedicated (temporary path obtained by chooseImage) * @locale */ filePath?: string; /** * @Multi_Lang_Tag * @locale cn * maxSize 限制文件大小。 * * 对浏览器生效;在 uni-app、小程序等 filePath 上传场景中,若 adapter 能探查到本地文件大小,也会生效。 * * 若宿主环境不支持文件大小探查,则仍建议开发者在选择文件后自行判断,参考 wx.chooseImage、uni.chooseImage 等端能力。 * @locale * * @locale en * maxSize : maximum file size. * * Valid for browsers. For filePath uploads in uni-app and mini-program runtimes, it is also valid when the adapter can inspect local file size. * * If the host runtime does not support file size inspection, make your determination after selecting the file. Refer to those frame/platform’s APIs such as wx.chooseImage, uni.chooseImage. * @locale */ maxSize?: number; /** * @Multi_Lang_Tag * @locale cn * 存储场景,不传默认实例化配置,默认为"im" * * #### 常见说明 * - 常用场景为根据资源类型设置存储场景,然后设置定时任务调用 [清理文件](https://doc.yunxin.163.com/messaging/docs/zQyNDM0NzE?platform=server#%E6%B8%85%E7%90%86%E5%B7%B2%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6) 删除。 * - IM 默认的存储场景为: 'im' * - Chatroom 默认的存储场景为: 'chatroom' * * @locale * * @locale en * Storage scene (default: instantiation configuration, i.e., "im") * @locale */ nosScenes?: string; /** * @Multi_Lang_Tag * @locale cn * 存储有效时间,不传则默认实例化配置 * * 不得小于一天,单位秒 * @locale * * @locale en * Storage valid time (default: instantiation configuration) * * Cannot be less than one day (unit: second) * @locale */ nosSurvivalTime?: number; /** * @Multi_Lang_Tag * @locale cn * 上传进度 * @locale * * @locale en * Upload progress * @locale */ onUploadProgress?: (obj: FileProgressObject) => void; } export interface IUploadFileOptions extends IBaseUploadFileOptions { /** * @Multi_Lang_Tag * @locale cn * 文件类型 * @locale * * @locale en * File type * @locale */ type?: 'image' | 'audio' | 'video' | 'file'; /** * @Multi_Lang_Tag * @locale cn * 上传文件 md5 值。NOS 厂商根据该值判断文件完整性 * @locale * * @locale en * MD5 of the file being uploaded. The NOS service uses it to verify file integrity. * @locale */ md5?: string; /** * @Multi_Lang_Tag * @locale cn * 上传前回调事件。返回一个 task 对象,可以调用 task.abort() 取消上传 * @locale * * @locale en * Callback fired before the upload starts. It receives a task object whose abort() method cancels the upload. * @locale */ onUploadStart?: (task: { abort: () => void; [key: string]: any; }) => void; /** * @Multi_Lang_Tag * @locale cn * 上传完成的回调 * @locale * * @locale en * Callback fired when the upload completes. * @locale */ onUploadDone?: (file: UploadFileResult) => void; } export interface MixStoreTokenResTag { token: string; shortUrl: string; objectName: string; accessKeyId: string; secretAccessKey: string; sessionToken: string; region: string; maxRetries: number; bucket: string; } export interface V2NIMError extends Error { /** * 错误码 * * 注: 客户端错误码范围: 190000 ~ 199999 */ code: number; /** * 错误描述 */ desc: string; /** * 错误详情 */ detail: { /** * 可能的详细错误描述 */ reason?: string; /** * 原始错误 */ rawError?: Error; /** * 请求返回的原始数据 */ rawData?: string; /** * 原始数据的类型 * 需要收敛凭证(如登录 token)时,不保存 rawData 原值,改用它记录实际类型 */ rawDataType?: string; /** * 错误发生的时间 */ timetag?: number; [key: string]: any; }; } /** * 易盾反垃圾配置 * * 使用场景: 未使用云信安全通, 直接对接了易盾 */ export declare type V2NIMAntispamConfig = { /** * 指定易盾业务ID,而不使用云信后台配置的安全通 * * @example * ``` * '{"textbid":"","picbid":""}' * ``` */ antispamBusinessId: string; }; /** * 实例状态。 * * 原本定义在 v1 登录模块的契约文件里,v1 登录链移除后迁移到这里,保持对外类型名不变。 */ export declare type NIMEInstanceStatus = 'unconnected' | 'connecting' | 'connected' | 'logined' | 'waitReconnect' | 'destroyed';