@onyx-p/imlib-web 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +29757 -0
- package/index.umd.js +29811 -0
- package/package.json +9 -9
- package/types/index.d.ts +224 -0
- package/types/model/baseMessage.d.ts +50 -0
- package/types/model/iReceivedConversation.d.ts +54 -0
- package/types/model/iReceivedMessage.d.ts +87 -0
- package/types/model/mentionedInfo.d.ts +9 -0
- package/types/model/messages/commandMessage.d.ts +20 -0
- package/types/model/messages/custMessage.d.ts +34 -0
- package/types/model/messages/fileMessage.d.ts +25 -0
- package/types/model/messages/gifMessage.d.ts +28 -0
- package/types/model/messages/imageMessage.d.ts +32 -0
- package/types/model/messages/index.d.ts +10 -0
- package/types/model/messages/recallCommandMessage.d.ts +18 -0
- package/types/model/messages/textMessage.d.ts +16 -0
- package/types/model/messages/voiceMessage.d.ts +21 -0
- package/types/model/statusTypes.d.ts +417 -0
- package/types/types.d.ts +283 -0
@@ -0,0 +1,417 @@
|
|
1
|
+
/**
|
2
|
+
* 连接状态
|
3
|
+
*/
|
4
|
+
export declare enum ConnectionStatus {
|
5
|
+
/**
|
6
|
+
* 连接成功。
|
7
|
+
*/
|
8
|
+
CONNECTED = 0,
|
9
|
+
/**
|
10
|
+
* 连接中。
|
11
|
+
*/
|
12
|
+
CONNECTING = 1,
|
13
|
+
/**
|
14
|
+
* 正常断开连接。
|
15
|
+
*/
|
16
|
+
DISCONNECTED = 2,
|
17
|
+
/**
|
18
|
+
* 网络不可用。
|
19
|
+
*/
|
20
|
+
NETWORK_UNAVAILABLE = 3,
|
21
|
+
/**
|
22
|
+
* 连接关闭。
|
23
|
+
*/
|
24
|
+
CONNECTION_CLOSED = 4,
|
25
|
+
/**
|
26
|
+
* 用户账户在其他设备登录,本机会被踢掉线。
|
27
|
+
*/
|
28
|
+
KICKED_OFFLINE_BY_OTHER_CLIENT = 6,
|
29
|
+
/**
|
30
|
+
* websocket 连接失败
|
31
|
+
*/
|
32
|
+
WEBSOCKET_UNAVAILABLE = 7,
|
33
|
+
/**
|
34
|
+
* websocket 报错
|
35
|
+
*/
|
36
|
+
WEBSOCKET_ERROR = 8,
|
37
|
+
/**
|
38
|
+
* 用户被封禁
|
39
|
+
*/
|
40
|
+
BLOCKED = 9,
|
41
|
+
/**
|
42
|
+
* 服务器主动断开
|
43
|
+
*/
|
44
|
+
DISCONNECT_BY_SERVER = 13
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* IM 错误码范围段
|
48
|
+
* 2 开头为 IM Server 返回错误码
|
49
|
+
* 3 开头: 30000 到 33xxx 为协议栈错误码,34001 ~ 34999 为移动端自定错误码
|
50
|
+
* 备注:iOS 与 Android 错误码一致。Web 与移动端一致的错误码,也用此片段,比如 34008 (消息不支持扩展)
|
51
|
+
* 35001 ~ 39999 为 Web 端错误码 备注:由于 Web IM 历史版本 35xxx 36xxx 37xxx 38xxx 39xxxx 都占用过,所以错误码段范围较大
|
52
|
+
*/
|
53
|
+
export declare enum ErrorCode {
|
54
|
+
/** 超时 */
|
55
|
+
TIMEOUT = -1,
|
56
|
+
/**
|
57
|
+
* 未知原因失败。
|
58
|
+
*/
|
59
|
+
UNKNOWN = -2,
|
60
|
+
/** 参数错误 */
|
61
|
+
PARAMETER_ERROR = -3,
|
62
|
+
/**
|
63
|
+
* 成功
|
64
|
+
*/
|
65
|
+
SUCCESS = 0,
|
66
|
+
/**
|
67
|
+
* 己方网络出错
|
68
|
+
*/
|
69
|
+
NETWORK_ERROR = 7,
|
70
|
+
/**
|
71
|
+
* 消息加密失败
|
72
|
+
*/
|
73
|
+
MSG_ENCRYPT_ERROR = 6001,
|
74
|
+
/**
|
75
|
+
* 群组 Id 无效
|
76
|
+
*/
|
77
|
+
RC_DISCUSSION_GROUP_ID_INVALID = 20407,
|
78
|
+
/**
|
79
|
+
* 发送频率过快
|
80
|
+
*/
|
81
|
+
SEND_FREQUENCY_TOO_FAST = 20604,
|
82
|
+
/**
|
83
|
+
* 群组被禁言
|
84
|
+
*/
|
85
|
+
FORBIDDEN_IN_GROUP = 22408,
|
86
|
+
RECALL_MESSAGE = 25101,
|
87
|
+
/**
|
88
|
+
* 不在群组。
|
89
|
+
*/
|
90
|
+
NOT_IN_GROUP = 22406,
|
91
|
+
/**
|
92
|
+
* 敏感词屏蔽
|
93
|
+
*/
|
94
|
+
SENSITIVE_SHIELD = 21501,
|
95
|
+
/**
|
96
|
+
*获取用户失败
|
97
|
+
*/
|
98
|
+
GET_USERINFO_ERROR = 23407,
|
99
|
+
/**
|
100
|
+
* 在黑名单中。
|
101
|
+
*/
|
102
|
+
REJECTED_BY_BLACKLIST = 405,
|
103
|
+
/**
|
104
|
+
* 通信过程中,当前 Socket 不存在。
|
105
|
+
*/
|
106
|
+
RC_NET_CHANNEL_INVALID = 30001,
|
107
|
+
/**
|
108
|
+
* Socket 连接不可用。
|
109
|
+
*/
|
110
|
+
RC_NET_UNAVAILABLE = 30002,
|
111
|
+
/**
|
112
|
+
* 通信超时。
|
113
|
+
*/
|
114
|
+
RC_MSG_RESP_TIMEOUT = 30003,
|
115
|
+
/**
|
116
|
+
* 创建 Socket 失败。
|
117
|
+
*/
|
118
|
+
RC_SOCKET_NOT_CREATED = 30010,
|
119
|
+
/**
|
120
|
+
* Socket 被断开。
|
121
|
+
*/
|
122
|
+
RC_SOCKET_DISCONNECTED = 30011,
|
123
|
+
/**
|
124
|
+
* PING 超时。
|
125
|
+
*/
|
126
|
+
RC_PONG_RECV_FAIL = 30013,
|
127
|
+
/**
|
128
|
+
* 消息发送失败。
|
129
|
+
*/
|
130
|
+
RC_MSG_SEND_FAIL = 30014,
|
131
|
+
/**
|
132
|
+
* JSON 后的消息体超限, 目前最大 128kb
|
133
|
+
*/
|
134
|
+
RC_MSG_CONTENT_EXCEED_LIMIT = 30016,
|
135
|
+
/**
|
136
|
+
* 做 connect 连接时,收到的 ACK 超时。
|
137
|
+
*/
|
138
|
+
RC_CONN_ACK_TIMEOUT = 31000,
|
139
|
+
/**
|
140
|
+
* 参数错误,App Id 错误。
|
141
|
+
*/
|
142
|
+
RC_CONN_ID_REJECT = 31002,
|
143
|
+
/**
|
144
|
+
* 服务器不可用。
|
145
|
+
*/
|
146
|
+
RC_CONN_SERVER_UNAVAILABLE = 31003,
|
147
|
+
/**
|
148
|
+
* Token 错误。
|
149
|
+
*/
|
150
|
+
RC_CONN_USER_OR_PASSWD_ERROR = 31004,
|
151
|
+
/**
|
152
|
+
* websocket 鉴权失败
|
153
|
+
*/
|
154
|
+
RC_CONN_NOT_AUTHRORIZED = 31005,
|
155
|
+
/**
|
156
|
+
* Disconnect,由服务器返回,比如用户互踢。
|
157
|
+
*/
|
158
|
+
RC_DISCONN_KICK = 31010,
|
159
|
+
/**
|
160
|
+
* 开启禁止把已在线客户端踢下线开关后,该错误码标识已有同类型端在线,禁止链接;
|
161
|
+
*/
|
162
|
+
RC_DISCONN_SAME_CLIENT_ON_LINE = 31023,
|
163
|
+
/**
|
164
|
+
* 未调用 init 初始化函数。
|
165
|
+
*/
|
166
|
+
BIZ_ERROR_CLIENT_NOT_INIT = 33001,
|
167
|
+
/**
|
168
|
+
* 传入参数无效。
|
169
|
+
*/
|
170
|
+
BIZ_ERROR_INVALID_PARAMETER = 33003,
|
171
|
+
/**
|
172
|
+
* 重新连接成功。
|
173
|
+
*/
|
174
|
+
BIZ_ERROR_RECONNECT_SUCCESS = 33005,
|
175
|
+
/**
|
176
|
+
* 连接中,再调用 connect 被拒绝。
|
177
|
+
*/
|
178
|
+
BIZ_ERROR_CONNECTING = 33006,
|
179
|
+
/**
|
180
|
+
* 消息存入本地数据库失败
|
181
|
+
*/
|
182
|
+
MSG_INSERT_ERROR = 33008,
|
183
|
+
/**
|
184
|
+
* 删除本地消息失败
|
185
|
+
*/
|
186
|
+
MSG_DEL_ERROR = 33009,
|
187
|
+
/**
|
188
|
+
* 删除会话失败
|
189
|
+
*/
|
190
|
+
CONVER_REMOVE_ERROR = 34001,
|
191
|
+
/**
|
192
|
+
*拉取历史消息
|
193
|
+
*/
|
194
|
+
CONVER_GETLIST_ERROR = 34002,
|
195
|
+
/**
|
196
|
+
* 会话指定异常
|
197
|
+
*/
|
198
|
+
CONVER_SETOP_ERROR = 34003,
|
199
|
+
/**
|
200
|
+
* 获取会话未读消息总数失败
|
201
|
+
*/
|
202
|
+
CONVER_TOTAL_UNREAD_ERROR = 34004,
|
203
|
+
/**
|
204
|
+
* 获取指定会话类型未读消息数异常
|
205
|
+
*/
|
206
|
+
CONVER_TYPE_UNREAD_ERROR = 34005,
|
207
|
+
/**
|
208
|
+
* 获取指定用户ID&会话类型未读消息数异常
|
209
|
+
*/
|
210
|
+
CONVER_ID_TYPE_UNREAD_ERROR = 34006,
|
211
|
+
/**
|
212
|
+
* 会话数量超出上限
|
213
|
+
*/
|
214
|
+
CONVER_OUT_LIMIT_ERROR = 34013,
|
215
|
+
/**
|
216
|
+
* 媒体文件上传异常,媒体文件不存在或文件大小为 0 或超过限制
|
217
|
+
*/
|
218
|
+
MEDIA_EXCEPTION = 34018,
|
219
|
+
/**
|
220
|
+
* 获取会话失败
|
221
|
+
*/
|
222
|
+
CONVER_GET_ERROR = 35021,
|
223
|
+
/**
|
224
|
+
* 群组信息异常
|
225
|
+
*/
|
226
|
+
GROUP_SYNC_ERROR = 35001,
|
227
|
+
/**
|
228
|
+
* 已连接或者内部重连中,不允许调用重连,需先调用 disconnect 方法
|
229
|
+
*/
|
230
|
+
CAN_NOT_RECONNECT = 35007,
|
231
|
+
/**
|
232
|
+
* 开启`禁止把已在线客户端踢下线`开关后,该错误码标识已有同类型端在线,禁止链接
|
233
|
+
*/
|
234
|
+
HAS_OHTER_SAME_CLIENT_ON_LINE = 35010,
|
235
|
+
/**
|
236
|
+
* IM 在初次连接成功后,需立即同步消息,标记上线,然后获取全量超级群会话列表,列表同步完成前,所有超级群相关功能接口应不可用
|
237
|
+
*/
|
238
|
+
METHOD_NOT_AVAILABLE = 35011,
|
239
|
+
/**
|
240
|
+
* 该功能不支持超级群
|
241
|
+
*/
|
242
|
+
METHOD_NOT_SUPPORT = 35012,
|
243
|
+
/**
|
244
|
+
* 消息数量没在范围内
|
245
|
+
*/
|
246
|
+
MSG_LIMIT_ERROR = 35013,
|
247
|
+
/**
|
248
|
+
* 该功能仅支持超级群
|
249
|
+
*/
|
250
|
+
METHOD_ONLY_SUPPORT_ULTRA_GROUP = 35014,
|
251
|
+
/**
|
252
|
+
* 上传文件失败
|
253
|
+
*/
|
254
|
+
UPLOAD_FILE_FAILED = 35020,
|
255
|
+
/**
|
256
|
+
* 获取草稿失败
|
257
|
+
*/
|
258
|
+
DRAF_GET_ERROR = 38001,
|
259
|
+
/**
|
260
|
+
* 保存草稿失败
|
261
|
+
*/
|
262
|
+
DRAF_SAVE_ERROR = 38002,
|
263
|
+
/**
|
264
|
+
* 删除草稿失败
|
265
|
+
*/
|
266
|
+
DRAF_REMOVE_ERROR = 38003,
|
267
|
+
/**
|
268
|
+
* 方法未支持
|
269
|
+
*/
|
270
|
+
NOT_SUPPORT = 39002
|
271
|
+
}
|
272
|
+
export declare const ErrorDesc: (code: ErrorCode) => string;
|
273
|
+
/**
|
274
|
+
* 会话类型
|
275
|
+
*/
|
276
|
+
export declare enum ConversationType {
|
277
|
+
/**
|
278
|
+
* 单聊
|
279
|
+
*/
|
280
|
+
PRIVATE = 1,
|
281
|
+
/**
|
282
|
+
* 群组聊天
|
283
|
+
*/
|
284
|
+
GROUP = 3,
|
285
|
+
/**
|
286
|
+
* 超级群
|
287
|
+
*/
|
288
|
+
ULTRA_GROUP = 10
|
289
|
+
}
|
290
|
+
/**
|
291
|
+
* 群组 @ 类型
|
292
|
+
*/
|
293
|
+
export declare enum MentionedType {
|
294
|
+
/**
|
295
|
+
* 所有人
|
296
|
+
*/
|
297
|
+
ALL = 1,
|
298
|
+
/**
|
299
|
+
* 部分人
|
300
|
+
*/
|
301
|
+
SINGAL = 2
|
302
|
+
}
|
303
|
+
/**
|
304
|
+
* 会话提醒状态
|
305
|
+
*/
|
306
|
+
export declare enum NotificationStatus {
|
307
|
+
/**
|
308
|
+
* 免打扰已开启
|
309
|
+
*/
|
310
|
+
OPEN = 1,
|
311
|
+
/**
|
312
|
+
* 免打扰已关闭
|
313
|
+
*/
|
314
|
+
CLOSE = 2
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* 消息的方向
|
318
|
+
*/
|
319
|
+
export declare enum MessageDirection {
|
320
|
+
/**
|
321
|
+
* 己方发送消息
|
322
|
+
*/
|
323
|
+
SEND = 1,
|
324
|
+
/**
|
325
|
+
* 己方接收消息
|
326
|
+
*/
|
327
|
+
RECEIVE = 2
|
328
|
+
}
|
329
|
+
export interface IUserProfile {
|
330
|
+
/**
|
331
|
+
* 用户 ID
|
332
|
+
*/
|
333
|
+
id?: string;
|
334
|
+
/**
|
335
|
+
* 用户名
|
336
|
+
*/
|
337
|
+
name?: string;
|
338
|
+
/**
|
339
|
+
* user info 中附加信息
|
340
|
+
*/
|
341
|
+
extra?: string;
|
342
|
+
/**
|
343
|
+
* 用户头像地址(向移动端兼容)
|
344
|
+
*/
|
345
|
+
portrait?: string;
|
346
|
+
}
|
347
|
+
/**
|
348
|
+
* 发送状态
|
349
|
+
*/
|
350
|
+
export declare enum SentStatus {
|
351
|
+
/**
|
352
|
+
* 发送中
|
353
|
+
*/
|
354
|
+
SENDING = 10,
|
355
|
+
/**
|
356
|
+
* 发送失败
|
357
|
+
*/
|
358
|
+
FAILED = 20,
|
359
|
+
/**
|
360
|
+
* 已发送成功
|
361
|
+
*/
|
362
|
+
SENT = 30
|
363
|
+
}
|
364
|
+
export declare enum ReceivedStatus {
|
365
|
+
/**
|
366
|
+
* 已读
|
367
|
+
*/
|
368
|
+
READ = 1,
|
369
|
+
/**
|
370
|
+
* 已听
|
371
|
+
*/
|
372
|
+
LISTENED = 2,
|
373
|
+
/**
|
374
|
+
* 已下载
|
375
|
+
*/
|
376
|
+
DOWNLOADED = 4,
|
377
|
+
/**
|
378
|
+
* 该消息已经被其他登录的多端收取过。( 即该消息已经被其他端收取过后。当前端才登录,并重新拉取了这条消息。客户可以通过这个状态更新 UI,比如不再提示 )
|
379
|
+
*/
|
380
|
+
RETRIEVED = 8,
|
381
|
+
/**
|
382
|
+
* 未读
|
383
|
+
*/
|
384
|
+
UNREAD = 0
|
385
|
+
}
|
386
|
+
/**
|
387
|
+
* 免打扰等级
|
388
|
+
*/
|
389
|
+
export declare enum NotificationLevel {
|
390
|
+
/**
|
391
|
+
* 全部消息通知(接收全部消息通知 -- 显示指定关闭免打扰功能)
|
392
|
+
*/
|
393
|
+
ALL_MESSAGE = -1,
|
394
|
+
/**
|
395
|
+
* 未设置(向上查询群或者APP级别设置)// 存量数据中 0 表示未设置
|
396
|
+
*/
|
397
|
+
NOT_SET = 0,
|
398
|
+
/**
|
399
|
+
* @所有人 或者 @成员列表有自己 时通知;单聊代表消息不通知
|
400
|
+
*/
|
401
|
+
AT_MESSAGE_NOTIFICATION = 1,
|
402
|
+
/**
|
403
|
+
* @成员列表有自己时通知,@所有人不通知;单聊代表消息不通知
|
404
|
+
*/
|
405
|
+
AT_USER_NOTIFICATION = 2,
|
406
|
+
/**
|
407
|
+
* @ 群用户组通知,通知用户组暂未实现,暂不暴露出去
|
408
|
+
*/
|
409
|
+
/**
|
410
|
+
* @ 群全员通知
|
411
|
+
*/
|
412
|
+
AT_GROUP_ALL_USER_NOTIFICATION = 4,
|
413
|
+
/**
|
414
|
+
* 消息通知被屏蔽,即不接收消息通知
|
415
|
+
*/
|
416
|
+
NOT_MESSAGE_NOTIFICATION = 5
|
417
|
+
}
|
package/types/types.d.ts
ADDED
@@ -0,0 +1,283 @@
|
|
1
|
+
import { BaseMessage, IExtraData, IUserInfo } from './model/baseMessage';
|
2
|
+
import IReceivedMessage from './model/iReceivedMessage';
|
3
|
+
import { ConnectionStatus, ConversationType, ErrorCode, IUserProfile, MessageDirection, NotificationLevel, NotificationStatus } from './model/statusTypes';
|
4
|
+
import IReceivedConversation from './model/iReceivedConversation';
|
5
|
+
import Long from 'long';
|
6
|
+
export declare enum LogLevel {
|
7
|
+
DEBUG = 0,
|
8
|
+
INFO = 1,
|
9
|
+
WARN = 2,
|
10
|
+
ERROR = 3,
|
11
|
+
FATAL = 4,
|
12
|
+
NONE = 1000
|
13
|
+
}
|
14
|
+
export type IInitOption = {
|
15
|
+
appkey: string;
|
16
|
+
/**
|
17
|
+
* 修改 engine log 打印等级
|
18
|
+
*/
|
19
|
+
logLevel?: LogLevel;
|
20
|
+
/**
|
21
|
+
* 修改默认的 log 输出函数
|
22
|
+
*/
|
23
|
+
logStdout?: (logLevel: LogLevel, content: string) => void;
|
24
|
+
serverInfo?: string;
|
25
|
+
};
|
26
|
+
export interface ProfileInfo {
|
27
|
+
deviceId: Long;
|
28
|
+
sessionId: Long;
|
29
|
+
uid: Long;
|
30
|
+
}
|
31
|
+
export declare enum Events {
|
32
|
+
CONNECTING = "CONNECTING",
|
33
|
+
CONNECTED = "CONNECTED",
|
34
|
+
DISCONNECT = "DISCONNECT",
|
35
|
+
SUSPEND = "SUSPEND",
|
36
|
+
MESSAGES = "MESSAGES",
|
37
|
+
PULL_OFFLINE_MESSAGE_FINISHED = "PULL_OFFLINE_MESSAGE_FINISHED",
|
38
|
+
CONVERSATION = "CONVERSATION"
|
39
|
+
}
|
40
|
+
export type EventListeners = {
|
41
|
+
[Events.CONNECTING]: () => void;
|
42
|
+
[Events.CONNECTED]: () => void;
|
43
|
+
[Events.DISCONNECT]: (status: ConnectionStatus) => void;
|
44
|
+
[Events.SUSPEND]: (status: ConnectionStatus | ErrorCode) => void;
|
45
|
+
[Events.MESSAGES]: (events: {
|
46
|
+
messages: IReceivedMessage[];
|
47
|
+
}) => void;
|
48
|
+
[Events.PULL_OFFLINE_MESSAGE_FINISHED]: () => void;
|
49
|
+
[Events.CONVERSATION]: (event: {
|
50
|
+
conversations: IUpdatedConversation[];
|
51
|
+
}) => void;
|
52
|
+
};
|
53
|
+
export interface IBaseConversationInfo {
|
54
|
+
conversationType: ConversationType;
|
55
|
+
targetId: string;
|
56
|
+
channelId?: string;
|
57
|
+
}
|
58
|
+
export interface IConversationState extends IBaseConversationInfo {
|
59
|
+
unreadCount: number;
|
60
|
+
unreadMentionedCount: number;
|
61
|
+
notificationLevel: NotificationLevel;
|
62
|
+
notificationStatus: NotificationStatus;
|
63
|
+
isTop: boolean;
|
64
|
+
}
|
65
|
+
/**
|
66
|
+
* 会话信息
|
67
|
+
*/
|
68
|
+
export type IConversationOption = IBaseConversationInfo;
|
69
|
+
export type IUpdatedConversationItemKeys = Extract<keyof IReceivedConversation, 'isTop' | 'notificationStatus' | 'notificationLevel' | 'unreadMessageCount' | 'hasMentioned' | 'unreadMentionedCount' | 'latestMessage'>;
|
70
|
+
export type IUpdatedConversationItem = Partial<Record<IUpdatedConversationItemKeys, {
|
71
|
+
time: number;
|
72
|
+
val: any;
|
73
|
+
}>>;
|
74
|
+
/**
|
75
|
+
* 会话更新内容
|
76
|
+
*/
|
77
|
+
export type IUpdatedConversation = {
|
78
|
+
conversation: IReceivedConversation;
|
79
|
+
updatedItems: IUpdatedConversationItem;
|
80
|
+
};
|
81
|
+
/**
|
82
|
+
* 消息的推送配置
|
83
|
+
*/
|
84
|
+
export type IPushConfig = {
|
85
|
+
/**
|
86
|
+
* 推送标题
|
87
|
+
如果没有设置,会使用下面的默认标题显示规则
|
88
|
+
默认标题显示规则:
|
89
|
+
内置消息:单聊通知标题显示为发送者名称,群聊通知标题显示为群名称。
|
90
|
+
自定义消息:默认不显示标题。
|
91
|
+
*/
|
92
|
+
pushTitle?: string;
|
93
|
+
/**
|
94
|
+
* 推送内容 在通知栏里会显示这个字段
|
95
|
+
* 自定义消息,该字段必须填写,否则无法收到 push 消息.
|
96
|
+
SDK 中默认的消息类型(如 RC:TxtMsg, RC:VcMsg, RC:ImgMsg) 默认已经指定, 可设置为 nil
|
97
|
+
*/
|
98
|
+
pushContent?: string;
|
99
|
+
/**
|
100
|
+
* 远程推送附加信息
|
101
|
+
*/
|
102
|
+
pushData?: string;
|
103
|
+
};
|
104
|
+
/**
|
105
|
+
* 发送消息时的可选项信息
|
106
|
+
*/
|
107
|
+
export interface ISendMessageOptions {
|
108
|
+
/**
|
109
|
+
* 用于发送群定向消息,只当 conversationType 值为 `ConversationType.GROUP` 时有效
|
110
|
+
*/
|
111
|
+
directionalUserIdList?: string[];
|
112
|
+
/**
|
113
|
+
* 消息发送之前的回调
|
114
|
+
*/
|
115
|
+
onSendBefore?: (message: IReceivedMessage) => void;
|
116
|
+
/**
|
117
|
+
* 重发消息时用到,重发消息的 messageId。
|
118
|
+
* 当要重发消息时所有参数需与原始消息参数一致,messageId 必须存在。
|
119
|
+
* 正常发消息时无需传该参数。
|
120
|
+
*/
|
121
|
+
messageId?: number;
|
122
|
+
/**
|
123
|
+
* 推送配置,用于配置移动端远程推送的推送栏显示内容
|
124
|
+
*/
|
125
|
+
pushConfig?: IPushConfig;
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* 要发送的文件信息(本地资源)
|
129
|
+
*/
|
130
|
+
export type ISendBody = IUserInfo & IExtraData & {
|
131
|
+
file: Blob;
|
132
|
+
};
|
133
|
+
/**
|
134
|
+
* 上传过程中的回调钩子
|
135
|
+
*/
|
136
|
+
export interface IUploadHooks {
|
137
|
+
/**
|
138
|
+
* 文件上传进度回调
|
139
|
+
*/
|
140
|
+
onProgress?: (progress: number) => void;
|
141
|
+
/**
|
142
|
+
* 文件上传完成回调,可通过修改返回值以修改待发布的消息内容,如实现自定义消息
|
143
|
+
*/
|
144
|
+
onComplete?: (fileInfo: {
|
145
|
+
url: string;
|
146
|
+
}) => void | BaseMessage;
|
147
|
+
}
|
148
|
+
/**
|
149
|
+
* 文件消息配置
|
150
|
+
*/
|
151
|
+
export interface IUploadMessageOption extends ISendMessageOptions {
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* 图片消息配置
|
155
|
+
*/
|
156
|
+
export interface IImageMessageOption extends IUploadMessageOption {
|
157
|
+
thumbnailConfig?: IThumbnailConfig;
|
158
|
+
}
|
159
|
+
/**
|
160
|
+
* 缩略图配置
|
161
|
+
*/
|
162
|
+
export interface IThumbnailConfig {
|
163
|
+
maxHeight?: number;
|
164
|
+
maxWidth?: number;
|
165
|
+
quality?: number;
|
166
|
+
scale?: number;
|
167
|
+
}
|
168
|
+
/**
|
169
|
+
* 撤回消息 option 参数
|
170
|
+
*/
|
171
|
+
export interface IRecallMessageOptions {
|
172
|
+
/**
|
173
|
+
* 消息的唯一id,客户端依赖此属性查找要撤回的消息
|
174
|
+
*/
|
175
|
+
messageUId: string;
|
176
|
+
/**
|
177
|
+
* 消息发送时间,服务端依赖此属性查找要撤回的消息
|
178
|
+
*/
|
179
|
+
sentTime: number;
|
180
|
+
/**
|
181
|
+
* 撤回消息携带用户信息
|
182
|
+
*/
|
183
|
+
user?: IUserProfile;
|
184
|
+
/**
|
185
|
+
* 是否发送静默消息
|
186
|
+
* @description
|
187
|
+
* 当值为 `true` 时,服务器将不会发送 Push 信息,移动端也不会弹出本地通知提醒
|
188
|
+
*/
|
189
|
+
disableNotification?: boolean;
|
190
|
+
/**
|
191
|
+
* 撤回消息携带扩展信息
|
192
|
+
*/
|
193
|
+
extra?: string;
|
194
|
+
/**
|
195
|
+
* 是否删除原始消息(在移动端会使用到),为 true 时移动端会不显示小灰条提示
|
196
|
+
*/
|
197
|
+
isDelete?: boolean;
|
198
|
+
}
|
199
|
+
/**
|
200
|
+
* 获取远程消息 option 参数
|
201
|
+
*/
|
202
|
+
export type GetHistoryMessageOption = {
|
203
|
+
/**
|
204
|
+
* 获取此时间之前的消息,0 为从当前时间拉取
|
205
|
+
*/
|
206
|
+
timestamp?: number;
|
207
|
+
/**
|
208
|
+
* 获取消息的数量,范围: 1-20
|
209
|
+
*/
|
210
|
+
count?: number;
|
211
|
+
/**
|
212
|
+
* 查询消息的方向
|
213
|
+
* * 0: 以 timestamp 为基准向前查询
|
214
|
+
* * 1: 以 timestamp 为基准向后查询
|
215
|
+
*/
|
216
|
+
order?: 0 | 1;
|
217
|
+
};
|
218
|
+
/**
|
219
|
+
* 获取远程消息回调结果
|
220
|
+
*/
|
221
|
+
export type GetHistoryMessageResult = {
|
222
|
+
list: IReceivedMessage[];
|
223
|
+
hasMore: boolean;
|
224
|
+
};
|
225
|
+
export type IDeleteMessageOptions = {
|
226
|
+
/**
|
227
|
+
* 消息 id
|
228
|
+
*/
|
229
|
+
messageUId: string;
|
230
|
+
/**
|
231
|
+
* 消息发送时间
|
232
|
+
*/
|
233
|
+
sentTime?: number;
|
234
|
+
/**
|
235
|
+
* 消息方向
|
236
|
+
* * 1: 发送
|
237
|
+
* * 2: 接收
|
238
|
+
*/
|
239
|
+
messageDirection?: MessageDirection;
|
240
|
+
};
|
241
|
+
export type IGetConversationListOptions = {
|
242
|
+
/**
|
243
|
+
* 会话数量
|
244
|
+
*/
|
245
|
+
count?: number;
|
246
|
+
/**
|
247
|
+
* 获取起始时间
|
248
|
+
* 默认值: 0
|
249
|
+
* order 为 0 startTime 默认值为当前时间,将返回最新的会话列表
|
250
|
+
* order 为 1 startTime 默认值为所有会话中最早的消息时间,将返回最早的会话列表数据
|
251
|
+
*/
|
252
|
+
startTime?: number;
|
253
|
+
/**
|
254
|
+
* 查询顺序
|
255
|
+
* 默认值: 0
|
256
|
+
* 0 获取 startTime 之前的
|
257
|
+
* 1 获取 startTime 之后的
|
258
|
+
*/
|
259
|
+
order?: 0 | 1;
|
260
|
+
};
|
261
|
+
/**
|
262
|
+
* 异步任务回调
|
263
|
+
*/
|
264
|
+
export interface IAsyncRes<T = any> {
|
265
|
+
/**
|
266
|
+
* Promise 执行结果
|
267
|
+
*/
|
268
|
+
code: ErrorCode;
|
269
|
+
/**
|
270
|
+
* 结果数据
|
271
|
+
*/
|
272
|
+
data?: T;
|
273
|
+
/**
|
274
|
+
* 错误消息
|
275
|
+
*/
|
276
|
+
msg?: string;
|
277
|
+
}
|
278
|
+
/**
|
279
|
+
* 异步任务结果定义
|
280
|
+
* @description
|
281
|
+
* 通过 `Promise.resolve` 来处理预期内的异常,进而通过 Uncatch Promise Error 暴露预期外的异常
|
282
|
+
*/
|
283
|
+
export type IPromiseResult<T> = Promise<IAsyncRes<T>>;
|