easemob-websdk 4.5.1 → 4.6.0-beta

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/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Changes to easemob chat
2
2
 
3
3
 
4
+ # 4.6.0 (April 2, 2024)
5
+
6
+ - Adds pin message feature.
7
+ - pinMessage
8
+ - unpinMessage
9
+ - getServerPinnedMessages
10
+ - Adds `onMessagePinEvent` callback to handle the message pin event.
11
+ - `onModifiedMessage` support custom message.
12
+ - `getHistoryMessages` support get chat room history message.
13
+ - Support custom chat room ID.
14
+ - Optimize token login failed error code for make the reason more clearly.
15
+ - Fix the message field `onlineState` status error.
16
+
4
17
  # 4.5.1 (Feb 21, 2024)
5
18
 
6
19
  - Format the attachment file url.
package/Easemob-chat.d.ts CHANGED
@@ -74,6 +74,9 @@ export declare namespace EasemobChat {
74
74
  /** The modified message. */
75
75
  type ModifiedMsg = TextMsgBody;
76
76
 
77
+ /** Messages supported by the `onModifiedMessage` event. */
78
+ type ModifiedEventMessage = TextMsgBody | CustomMsgBody;
79
+
77
80
  interface ModifyMsgResult extends SendMsgResult {
78
81
  /** The modified message. */
79
82
  message: ModifiedMsg;
@@ -822,6 +825,22 @@ export declare namespace EasemobChat {
822
825
  /** The position from which to start getting data for the next query. If the number of returned data entries is smaller than that specified in the request, the cursor is `'undefined'`, which indicates that the current page is the last page; otherwise, the SDK returns the specific cursor position which indicates where to start getting data for the next query.*/
823
826
  cursor: string;
824
827
  }
828
+
829
+ interface PinnedMessageInfo {
830
+ /** The pinned message. */
831
+ message: MessagesType;
832
+ /** When the message is pinned. The unit is millisecond. */
833
+ pinTime: number;
834
+ /** The user ID of the operator that pins the message. */
835
+ operatorId: UserId;
836
+ }
837
+ interface CursorPinnedMessagesResult {
838
+ /** The position from which to start getting data for the next query. If the number of returned data entries is smaller than that specified in the request, the cursor is an empty string (''), which indicates that the current page is the last page; otherwise, the SDK returns the specific cursor position which indicates where to start getting data for the next query.*/
839
+ cursor: string;
840
+ /** The list of pinned messages. */
841
+ list: PinnedMessageInfo[];
842
+ }
843
+
825
844
  interface ConversationItem {
826
845
  /** The conversation ID. */
827
846
  conversationId: string;
@@ -1511,7 +1530,7 @@ export declare namespace EasemobChat {
1511
1530
  open(parameters: {
1512
1531
  /** The User ID. */
1513
1532
  user: string;
1514
- /** The password. */
1533
+ /** The password. It is recommended to use `accessToken` params. */
1515
1534
  pwd?: string;
1516
1535
  /** Token required to connect to the message service. */
1517
1536
  accessToken?: string;
@@ -1798,7 +1817,7 @@ export declare namespace EasemobChat {
1798
1817
  success?: (res: AsyncResult<BaseMembers[]>) => void;
1799
1818
  error?: (error: ErrorEvent) => void;
1800
1819
  }
1801
- ): Promise<AsyncResult<{ member: string }[]>>;
1820
+ ): Promise<AsyncResult<BaseMembers[]>>;
1802
1821
 
1803
1822
  /**
1804
1823
  * Lists all chat room members with pagination.
@@ -4251,18 +4270,19 @@ export declare namespace EasemobChat {
4251
4270
  getHistoryMessages(
4252
4271
  this: Connection,
4253
4272
  options: {
4254
- /** The user ID of the other party or the group ID. */
4273
+ /** The user ID of the other party or the group ID or chat room ID. */
4255
4274
  targetId: string;
4256
4275
  /** The starting message ID for this query. The default value is -1, which means to start retrieving from the latest message. */
4257
4276
  cursor?: number | string | null;
4258
4277
  /** The number of messages to retrieve each time. The default value is 20,The maximum value is 50. */
4259
4278
  pageSize?: number;
4260
- /** The chat type for SDK:
4279
+ /**
4280
+ * The chat type for SDK:
4261
4281
  * - `singleChat`: one-to-one chat;
4262
4282
  * - `groupChat`: group chat;
4263
- * - (Default)`singleChat`: No.
4283
+ * - `chatRoom`: chat room chat.
4264
4284
  */
4265
- chatType?: 'singleChat' | 'groupChat';
4285
+ chatType: 'singleChat' | 'groupChat' | 'chatRoom';
4266
4286
  /** Whether to select pull history messages in positive order(Pull message from the oldest to the latest).
4267
4287
  * - `up`: means searching from the newer messages to the older messages.
4268
4288
  * - `down`: means searching from the older messages to the newer messages.
@@ -5010,7 +5030,7 @@ export declare namespace EasemobChat {
5010
5030
  ): Promise<void>;
5011
5031
 
5012
5032
  /**
5013
- * Get the list of filter conversations from the server with pagination.
5033
+ * Gets the conversations from the server with pagination according to the conversation filter.
5014
5034
  *
5015
5035
  * ```typescript
5016
5036
  * connection.getServerConversationsByFilter({pageSize:10, cursor: '',filter: {mark: 0})
@@ -5019,11 +5039,13 @@ export declare namespace EasemobChat {
5019
5039
  getServerConversationsByFilter(
5020
5040
  this: Connection,
5021
5041
  params: {
5022
- /** The number of conversations that you expect to get on each page. The value range is [1,10] and the default value is `10`. */
5042
+ /** The number of conversations to retrieve on each page. The value range is [1,10] and the default value is `10`. */
5023
5043
  pageSize?: number;
5024
5044
  /** The position from which to start getting data. */
5025
5045
  cursor?: string;
5046
+ /** The conversation filter options. */
5026
5047
  filter: {
5048
+ /** The conversation mark for query. */
5027
5049
  mark: MarkType;
5028
5050
  };
5029
5051
  }
@@ -5049,6 +5071,72 @@ export declare namespace EasemobChat {
5049
5071
  */
5050
5072
  deleteAllMessagesAndConversations(this: Connection): Promise<void>;
5051
5073
 
5074
+ /**
5075
+ * Pins a message.
5076
+ *
5077
+ * connection.pinMessage({
5078
+ * conversationId: 'conversationId',
5079
+ * conversationType: 'groupChat',
5080
+ * messageId: 'messageId'
5081
+ * })
5082
+ */
5083
+ pinMessage(
5084
+ this: Connection,
5085
+ params: {
5086
+ /** The conversation ID. */
5087
+ conversationId: string;
5088
+ /** The conversation type. */
5089
+ conversationType: 'groupChat' | 'chatRoom';
5090
+ /** The ID of the message to be pinned. */
5091
+ messageId: string;
5092
+ }
5093
+ ): Promise<void>;
5094
+
5095
+ /**
5096
+ * Unpins a message.
5097
+ *
5098
+ * connection.unpinMessage({
5099
+ * conversationId: 'conversationId',
5100
+ * conversationType: 'groupChat',
5101
+ * messageId: 'messageId'
5102
+ * })
5103
+ */
5104
+ unpinMessage(
5105
+ this: Connection,
5106
+ params: {
5107
+ /** The conversation ID. */
5108
+ conversationId: string;
5109
+ /** The conversation type. */
5110
+ conversationType: 'groupChat' | 'chatRoom';
5111
+ /** The ID of the message to be unpinned. */
5112
+ messageId: string;
5113
+ }
5114
+ ): Promise<void>;
5115
+
5116
+ /**
5117
+ * Gets the pinned messages in a conversation with pagination.
5118
+ *
5119
+ * connection.getServerPinnedMessages({
5120
+ * conversationId: 'conversationId',
5121
+ * conversationType: 'groupChat',
5122
+ * pageSize: 20,
5123
+ * cursor: ''
5124
+ * })
5125
+ */
5126
+ getServerPinnedMessages(
5127
+ this: Connection,
5128
+ params: {
5129
+ /** The conversation ID. */
5130
+ conversationId: string;
5131
+ /** The conversation type. */
5132
+ conversationType: 'groupChat' | 'chatRoom';
5133
+ /** The number of pinned messages to retrieve on each page. The value range is [1,50] and the default value is `10`. */
5134
+ pageSize?: number;
5135
+ /** The position from which to start getting data. For the first call of the method, an empty string ('') is passed in and the SDK returns the list of pinned messages in the descending order of when they are pinned. */
5136
+ cursor?: string;
5137
+ }
5138
+ ): Promise<AsyncResult<CursorPinnedMessagesResult>>;
5139
+
5052
5140
  /**
5053
5141
  * Set the DND Settings for the current login user.
5054
5142
  *
@@ -5498,7 +5586,6 @@ export declare namespace EasemobChat {
5498
5586
  type Event =
5499
5587
  | 'onOpened'
5500
5588
  | 'onPresence'
5501
- | 'onMessage'
5502
5589
  | 'onTextMessage'
5503
5590
  | 'onImageMessage'
5504
5591
  | 'onAudioMessage'
@@ -5534,7 +5621,8 @@ export declare namespace EasemobChat {
5534
5621
  | 'onChatThreadChange'
5535
5622
  | 'onMultiDeviceEvent'
5536
5623
  | 'onGroupEvent'
5537
- | 'onChatroomEvent';
5624
+ | 'onChatroomEvent'
5625
+ | 'onMessagePinEvent';
5538
5626
 
5539
5627
  interface GroupEvent {
5540
5628
  /** The type of operation. <br/>
@@ -5664,6 +5752,24 @@ export declare namespace EasemobChat {
5664
5752
  memberCount?: number;
5665
5753
  }
5666
5754
 
5755
+ interface MessagePinEvent {
5756
+ /** The conversation type. */
5757
+ conversationType: 'groupChat' | 'chatRoom';
5758
+ /** The conversation ID. */
5759
+ conversationId: string;
5760
+ /** The ID of the message that is pinned or unpinned. */
5761
+ messageId: string;
5762
+ /** The user ID of the operator that pins or unpins the message */
5763
+ operatorId: UserId;
5764
+ /** When the message is pinned or unpinned. */
5765
+ time: number;
5766
+ /** The operation type. <br/>
5767
+ * pin: A message is pinned.<br/>
5768
+ * unpin: A message is unpinned.<br/>
5769
+ */
5770
+ operation: 'pin' | 'unpin';
5771
+ }
5772
+
5667
5773
  interface EventHandlerType {
5668
5774
  /** @deprecated Use { onConnected } instead. */
5669
5775
  onOpened?: (msg: any) => void;
@@ -5703,7 +5809,7 @@ export declare namespace EasemobChat {
5703
5809
  /** The callback to receive a session read ack. */
5704
5810
  onChannelMessage?: (msg: ChannelMsgBody) => void;
5705
5811
  /** Occurs when the message content is modified. */
5706
- onModifiedMessage?: (msg: ModifiedMsg) => void;
5812
+ onModifiedMessage?: (msg: ModifiedEventMessage) => void;
5707
5813
  /** The callback to receive error. */
5708
5814
  onError?: (error: ErrorEvent) => void;
5709
5815
  /** The callback for network disconnection. */
@@ -5748,6 +5854,8 @@ export declare namespace EasemobChat {
5748
5854
  onGroupEvent?: (eventData: GroupEvent) => void;
5749
5855
  /** The callback to receive a chatroom event. */
5750
5856
  onChatroomEvent?: (eventData: ChatroomEvent) => void;
5857
+ /** The callback to receive a pin message event. */
5858
+ onMessagePinEvent?: (eventData: MessagePinEvent) => void;
5751
5859
  }
5752
5860
 
5753
5861
  interface HandlerData {
@@ -5861,8 +5969,8 @@ export declare namespace EasemobChat {
5861
5969
  interface Config {
5862
5970
  useCache: boolean;
5863
5971
  maxCache: number;
5864
- color: string;
5865
- background: string;
5972
+ color?: string;
5973
+ background?: string;
5866
5974
  }
5867
5975
 
5868
5976
  /**
@@ -5879,6 +5987,9 @@ export declare namespace EasemobChat {
5879
5987
  config: Config;
5880
5988
  logBytes: number;
5881
5989
  constructor(name: string, defaultLevel: Level, factory?: any);
5990
+ /**
5991
+ * set Logger config.
5992
+ */
5882
5993
  setConfig(cofig: Config): void;
5883
5994
  /**
5884
5995
  * get current log level
@@ -5889,8 +6000,8 @@ export declare namespace EasemobChat {
5889
6000
  */
5890
6001
  setLevel(
5891
6002
  level: Level,
5892
- persist: boolean,
5893
- name: string
6003
+ persist?: boolean,
6004
+ name?: string
5894
6005
  ): 'No console available for logging' | undefined;
5895
6006
  setDefaultLevel(level: Level): void;
5896
6007
  /**
@@ -5909,6 +6020,17 @@ export declare namespace EasemobChat {
5909
6020
  * down load logs
5910
6021
  */
5911
6022
  download(): void;
6023
+ /**
6024
+ * The logs callback function.
6025
+ */
6026
+ onLog(data: {
6027
+ /** The time when logs are printed. */
6028
+ time: string;
6029
+ /** The log level. */
6030
+ level: string;
6031
+ /** The log content. */
6032
+ logs: any[];
6033
+ }): void;
5912
6034
  }
5913
6035
 
5914
6036
  // --- for Message ---
@@ -6575,6 +6697,8 @@ export declare namespace EasemobChat {
6575
6697
  deliverOnlineOnly?: boolean;
6576
6698
  /** The list of message recipients. */
6577
6699
  receiverList?: string[];
6700
+ /** Message modified info. */
6701
+ modifiedInfo?: ModifiedMsgInfo;
6578
6702
  }
6579
6703
 
6580
6704
  interface CreateCustomMsgParameters {