sim-sdk-web 1.0.16 → 1.0.18

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.
@@ -1,15 +1,31 @@
1
1
  import { RequestApi } from '../constant/api';
2
- import { AllowType, ApplicationHandleResult, GroupJoinSource, GroupMemberRole, GroupStatus, GroupType, GroupVerificationType, MessageReceiveOptType, MessageType, OnlineState, Platform, Relationship, SessionType, SSE_RESPONSE_TYPE } from './enum';
2
+ import { AllowType, ApplicationHandleResult, GROUP_TYPE, GroupJoinSource, GroupMemberRole, GroupStatus, GroupType, GroupVerificationType, MessageReceiveOptType, MessageType, MSG_TYPE, Relationship } from './enum';
3
3
  import { HttpMethod } from '../utils/request';
4
+ import { MessageService } from '../api/message';
5
+ import { ConversationService } from '../api/conversation';
6
+ import { GroupService } from '../api/group';
7
+ import { UserService } from '../api/user';
8
+ export type ServiceTypes = {
9
+ user: UserService;
10
+ message: MessageService;
11
+ conversation: ConversationService;
12
+ group: GroupService;
13
+ };
14
+ export declare enum ServiceName {
15
+ MESSAGE = "message",
16
+ CONVERSATION = "conversation",
17
+ GROUP = "group",
18
+ USER = "user"
19
+ }
4
20
  export interface Request {
5
21
  url: RequestApi;
6
22
  username?: string;
7
23
  data: Record<string, any> | undefined;
8
24
  method: HttpMethod;
9
25
  }
10
- export interface SseResponse {
11
- type: SSE_RESPONSE_TYPE;
12
- content: MessageReceiveOptType[];
26
+ export interface SseData {
27
+ ev: number;
28
+ dt: string;
13
29
  }
14
30
  export interface ServerResponse<T = unknown> {
15
31
  type?: MessageType;
@@ -26,13 +42,6 @@ export type Pagination = {
26
42
  offset: number;
27
43
  count: number;
28
44
  };
29
- export type MessageEntity = {
30
- type: string;
31
- offset: number;
32
- length: number;
33
- url?: string;
34
- info?: string;
35
- };
36
45
  export type PicBaseInfo = {
37
46
  uuid: string;
38
47
  type: string;
@@ -206,7 +215,7 @@ export type MessageItem = {
206
215
  userId: number;
207
216
  send: number;
208
217
  to: number;
209
- msgType: number;
218
+ msgType: MSG_TYPE;
210
219
  text?: string;
211
220
  link?: string;
212
221
  snapshot?: string;
@@ -223,7 +232,7 @@ export interface GroupInfoVO {
223
232
  /**
224
233
  * 聊天群类型: 0:一对一私聊 ,1:群聊,2:客服聊天
225
234
  */
226
- groupType: number;
235
+ groupType: GROUP_TYPE;
227
236
  createTime: number;
228
237
  updateTime: number;
229
238
  /**
@@ -292,207 +301,4 @@ export interface HistoryMessageResponse {
292
301
  avatarMap: AvatarMap;
293
302
  userId: number | null;
294
303
  }
295
- export type TextElem = {
296
- content: string;
297
- };
298
- export type CardElem = {
299
- userId: string;
300
- nickname: string;
301
- faceURL: string;
302
- ex: string;
303
- };
304
- export type AtTextElem = {
305
- text: string;
306
- atUserList: string[];
307
- atUsersInfo?: AtUsersInfoItem[];
308
- quoteMessage?: MessageItem;
309
- isAtSelf?: boolean;
310
- };
311
- export type NotificationElem = {
312
- detail: string;
313
- };
314
- export type AdvancedTextElem = {
315
- text: string;
316
- messageEntityList: MessageEntity[];
317
- };
318
- export type TypingElem = {
319
- msgTips: string;
320
- };
321
- export type CustomElem = {
322
- data: string;
323
- description: string;
324
- extension: string;
325
- };
326
- export type FileElem = {
327
- filePath: string;
328
- uuid: string;
329
- sourceUrl: string;
330
- fileName: string;
331
- fileSize: number;
332
- };
333
- export type FaceElem = {
334
- index: number;
335
- data: string;
336
- };
337
- export type LocationElem = {
338
- description: string;
339
- longitude: number;
340
- latitude: number;
341
- };
342
- export type MergeElem = {
343
- title: string;
344
- abstractList: string[];
345
- multiMessage: MessageItem[];
346
- messageEntityList: MessageEntity[];
347
- };
348
- export type OfflinePush = {
349
- title: string;
350
- desc: string;
351
- ex: string;
352
- iOSPushSound: string;
353
- iOSBadgeCount: boolean;
354
- };
355
- export type PictureElem = {
356
- sourcePath: string;
357
- sourcePicture: Picture;
358
- bigPicture: Picture;
359
- snapshotPicture: Picture;
360
- };
361
- export type AttachedInfoElem = {
362
- groupHasReadInfo: GroupHasReadInfo;
363
- isPrivateChat: boolean;
364
- isEncryption: boolean;
365
- inEncryptStatus: boolean;
366
- burnDuration: number;
367
- hasReadTime: number;
368
- notSenderNotificationPush: boolean;
369
- messageEntityList: MessageEntity[];
370
- uploadProgress: UploadProgress;
371
- };
372
- export type UploadProgress = {
373
- total: number;
374
- save: number;
375
- current: number;
376
- };
377
- export type GroupHasReadInfo = {
378
- hasReadCount: number;
379
- unreadCount: number;
380
- hasReadUserIDList: string[];
381
- groupMemberCount: number;
382
- };
383
- export type Picture = {
384
- uuid: string;
385
- type: string;
386
- size: number;
387
- width: number;
388
- height: number;
389
- url: string;
390
- };
391
- export type QuoteElem = {
392
- text: string;
393
- quoteMessage: MessageItem;
394
- };
395
- export type SoundElem = {
396
- uuid: string;
397
- soundPath: string;
398
- sourceUrl: string;
399
- dataSize: number;
400
- duration: number;
401
- };
402
- export type VideoElem = {
403
- videoPath: string;
404
- videoUUID: string;
405
- videoUrl: string;
406
- videoType: string;
407
- videoSize: number;
408
- duration: number;
409
- snapshotPath: string;
410
- snapshotUUID: string;
411
- snapshotSize: number;
412
- snapshotUrl: string;
413
- snapshotWidth: number;
414
- snapshotHeight: number;
415
- };
416
- export type AdvancedRevokeContent = {
417
- clientMsgID: string;
418
- revokeTime: number;
419
- revokerID: string;
420
- revokerNickname: string;
421
- revokerRole: number;
422
- seq: number;
423
- sessionType: SessionType;
424
- sourceMessageSendID: string;
425
- sourceMessageSendTime: number;
426
- sourceMessageSenderNickname: string;
427
- };
428
- export type RevokedInfo = {
429
- revokerID: string;
430
- revokerRole: number;
431
- clientMsgID: string;
432
- revokerNickname: string;
433
- revokeTime: number;
434
- sourceMessageSendTime: number;
435
- sourceMessageSendID: string;
436
- sourceMessageSenderNickname: string;
437
- sessionType: number;
438
- seq: number;
439
- ex: string;
440
- };
441
- export type ReceiptInfo = {
442
- userId: string;
443
- groupID: string;
444
- msgIDList: string[];
445
- readTime: number;
446
- msgFrom: number;
447
- contentType: MessageType;
448
- sessionType: SessionType;
449
- };
450
- export type SearchMessageResult = {
451
- totalCount: number;
452
- searchResultItems?: SearchMessageResultItem[];
453
- findResultItems?: SearchMessageResultItem[];
454
- };
455
- export type SearchMessageResultItem = {
456
- conversationID: string;
457
- messageCount: number;
458
- conversationType: SessionType;
459
- showName: string;
460
- faceURL: string;
461
- messageList: MessageItem[];
462
- };
463
- export type AdvancedGetMessageResult = {
464
- isEnd: boolean;
465
- lastMinSeq: number;
466
- errCode: number;
467
- errMsg: string;
468
- messageList: MessageItem[];
469
- };
470
- export type RtcInvite = {
471
- inviterUserID: string;
472
- inviteeUserIDList: string[];
473
- customData?: string;
474
- groupID: string;
475
- roomID: string;
476
- timeout: number;
477
- mediaType: string;
478
- sessionType: number;
479
- platformID: number;
480
- initiateTime?: number;
481
- busyLineUserIDList?: string[];
482
- };
483
- export type UserOnlineState = {
484
- platformIDs?: Platform[];
485
- status: OnlineState;
486
- userId: string;
487
- };
488
- export type GroupMessageReceiptInfo = {
489
- conversationID: string;
490
- groupMessageReadInfo: GroupMessageReadInfo[];
491
- };
492
- export type GroupMessageReadInfo = {
493
- clientMsgID: string;
494
- hasReadCount: number;
495
- unreadCount: number;
496
- readMembers: GroupMemberItem[];
497
- };
498
304
  export {};
@@ -126,11 +126,11 @@ export declare enum GroupMessageReaderFilter {
126
126
  Readed = 0,
127
127
  UnRead = 1
128
128
  }
129
- export declare const GROUP_TYPE: {
130
- ONE_ON_ONE: number;
131
- GROUP_CHAT: number;
132
- CUSTOMER_SERVICE: number;
133
- };
129
+ export declare enum GROUP_TYPE {
130
+ ONE_ON_ONE = 0,
131
+ GROUP_CHAT = 1,
132
+ CUSTOMER_SERVICE = 2
133
+ }
134
134
  export declare enum MSG_TYPE {
135
135
  TEXT = 0,
136
136
  IMAGE = 1,
@@ -1,4 +1,4 @@
1
- import type { AtUsersInfoItem, GroupItem, MessageItem, OfflinePush, PicBaseInfo, SelfUserInfo } from './entity';
1
+ import type { AtUsersInfoItem, GroupItem, MessageItem, PicBaseInfo, SelfUserInfo } from './entity';
2
2
  import type { GroupJoinSource, GroupMemberFilter, GroupMemberRole, MessageReceiveOptType, MessageType } from './enum';
3
3
  export type LoginParams = {
4
4
  apiAddr: string;
@@ -200,13 +200,6 @@ export type FaceMessageParams = {
200
200
  index: number;
201
201
  data: string;
202
202
  };
203
- export type SendMsgParams = {
204
- recvID: string;
205
- groupID: string;
206
- offlinePushInfo?: OfflinePush;
207
- message: MessageItem;
208
- isOnlineOnly?: boolean;
209
- };
210
203
  export type TypingUpdateParams = {
211
204
  recvID: string;
212
205
  msgTip: string;
@@ -0,0 +1,37 @@
1
+ import { SseData } from '../types/entity';
2
+ interface SseOptions {
3
+ url: string;
4
+ token: string;
5
+ retryInterval?: number;
6
+ maxRetries?: number;
7
+ onMessage?: (response: SseData) => void;
8
+ onReconnectSuccess?: () => void;
9
+ }
10
+ declare class SseClient {
11
+ private url;
12
+ private token;
13
+ private eventSource;
14
+ private reconnectAttempts;
15
+ private maxReconnectAttempts;
16
+ private reconnectTimeout;
17
+ private reconnectTimer;
18
+ private handlers;
19
+ private connected;
20
+ private onMessageCallback?;
21
+ private onReconnectSuccessCallback?;
22
+ constructor(options: SseOptions);
23
+ private removeAllEventListeners;
24
+ subscribe(type: string, handler: Function): void;
25
+ connect(): Promise<string>;
26
+ private onOpen;
27
+ private handleMessage;
28
+ private onMessage;
29
+ private onError;
30
+ private handleReconnect;
31
+ private cleanup;
32
+ unsubscribe(): void;
33
+ destroySse(): void;
34
+ close(): void;
35
+ isConnected(): boolean;
36
+ }
37
+ export default SseClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-sdk-web",
3
- "version": "v1.0.16",
3
+ "version": "v1.0.18",
4
4
  "description": "Sim SDK for Web",
5
5
  "source": "src/index.ts",
6
6
  "main": "lib/index.js",
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "license": "Apache-2.0",
35
35
  "devDependencies": {
36
- "@types/eventsource": "^1.1.15",
36
+ "@types/event-source-polyfill": "^1.0.5",
37
37
  "@typescript-eslint/parser": "^6.9.1",
38
38
  "microbundle": "^0.15.1",
39
39
  "prettier": "^3.0.3",
@@ -42,6 +42,6 @@
42
42
  "typescript": "^5.2.2"
43
43
  },
44
44
  "dependencies": {
45
- "eventsource": "^2.0.2"
45
+ "event-source-polyfill": "^1.0.31"
46
46
  }
47
47
  }
@@ -1,27 +0,0 @@
1
- import type { SseResponse } from '../types/entity';
2
- interface SseOptions {
3
- url: string;
4
- authorizationToken: string;
5
- retryInterval?: number;
6
- maxRetries?: number;
7
- onMessage: (response: SseResponse) => void;
8
- onReconnectSuccess: () => void;
9
- }
10
- declare class SseManager {
11
- private url;
12
- private authorizationToken;
13
- private retryInterval;
14
- private maxRetries;
15
- private reconnectAttempts;
16
- private eventSource;
17
- private connected;
18
- private onMessage;
19
- private onReconnectSuccess;
20
- constructor(options: SseOptions);
21
- connect: () => Promise<string>;
22
- private handleMessage;
23
- private reconnect;
24
- close(): void;
25
- isConnected(): boolean;
26
- }
27
- export default SseManager;