easemob-websdk 4.23.0 → 4.24.1

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/Easemob-chat.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export interface EasemobChatStatic {
2
2
  connection: typeof EasemobChat.Connection;
3
3
  message: typeof EasemobChat.Message;
4
- image: EasemobChat.ImageModule;
5
4
  utils: EasemobChat.Utils;
6
5
  logger: EasemobChat.Logger;
7
6
  statusCode: EasemobChat.Code;
@@ -67,78 +66,6 @@ export declare namespace EasemobChat {
67
66
 
68
67
  type VoiceSourceFile = File | MiniProgramVoiceFile;
69
68
 
70
- interface ImageInfo {
71
- width: number;
72
- height: number;
73
- type?: string;
74
- }
75
-
76
- interface BigImageOptions {
77
- maxShortEdge: number;
78
- quality: number;
79
- }
80
-
81
- interface BigImageResult {
82
- file?: File;
83
- path?: string;
84
- width: number;
85
- height: number;
86
- size: number;
87
- type: string;
88
- }
89
-
90
- interface ImageProcessor {
91
- getImageInfo(source: File | string): Promise<ImageInfo>;
92
- generateBigImage(
93
- source: File | string,
94
- options: BigImageOptions
95
- ): Promise<BigImageResult | null>;
96
- computeMd5(source: File | string): Promise<string>;
97
- }
98
-
99
- interface MiniAppRuntime {
100
- getImageInfo(options: {
101
- src: string;
102
- success: (res: { width: number; height: number; type?: string }) => void;
103
- fail: (err: any) => void;
104
- }): void;
105
- compressImage?(options: {
106
- src: string;
107
- quality?: number;
108
- compressedWidth?: number;
109
- compressedHeight?: number;
110
- success?: (res: { tempFilePath: string }) => void;
111
- fail?: (err: any) => void;
112
- }): void;
113
- getFileSystemManager?(): {
114
- getFileInfo(options: {
115
- filePath: string;
116
- success: (res: { size: number }) => void;
117
- fail: (err: any) => void;
118
- }): void;
119
- readFile(options: {
120
- filePath: string;
121
- encoding?: string;
122
- success: (res: { data: ArrayBuffer | string }) => void;
123
- fail: (err: any) => void;
124
- }): void;
125
- };
126
- }
127
-
128
- interface ImageModule {
129
- DEFAULT_BIG_IMAGE_SHORT_EDGE: number;
130
- DEFAULT_BIG_IMAGE_QUALITY: number;
131
- webImageProcessor: ImageProcessor;
132
- resolveScaledSize: (
133
- width: number,
134
- height: number,
135
- maxShortEdge: number
136
- ) => { width: number; height: number };
137
- createMiniAppImageProcessor: (
138
- runtime: MiniAppRuntime
139
- ) => ImageProcessor;
140
- }
141
-
142
69
  type ExcludeAckMessageBody = Exclude<
143
70
  MessageBody,
144
71
  ReadMsgBody | DeliveryMsgBody | ChannelMsgBody
@@ -992,7 +919,74 @@ export declare namespace EasemobChat {
992
919
  isLast: boolean;
993
920
  }
994
921
 
995
- interface ServerConversations {
922
+ /**
923
+ * The multiple-keyword match type for server message search.
924
+ * `or` means any keyword can match, and `and` means all keywords must match.
925
+ */
926
+ type MessageSearchKeywordListMatchType = 'or' | 'and';
927
+
928
+ /**
929
+ * The search scope for server message search.
930
+ * `none` searches only the message body, `with` searches both body and extensions,
931
+ * and `only` searches only extension fields.
932
+ */
933
+ type MessageSearchScope = 'none' | 'with' | 'only';
934
+
935
+ /**
936
+ * A WebSDK message object mapped from one server-side search hit.
937
+ */
938
+ type ServerSearchMessage = ExcludeAckMessageBody & {
939
+ /** The conversation ID of the matched message. */
940
+ conversationId?: string;
941
+ /** Highlight fragments returned by the server. */
942
+ highlight?: string[];
943
+ /** Summary text returned by the server for quick display. */
944
+ text?: string;
945
+ };
946
+
947
+ /**
948
+ * The paged result returned by server-side message search.
949
+ */
950
+ interface ServerSearchMessagesResult {
951
+ /** The server search result messages. */
952
+ messages: ServerSearchMessage[];
953
+ /** The current page number. */
954
+ pageNum: number;
955
+ /** The requested page size echoed by the SDK. */
956
+ pageSize: number;
957
+ /** The total number of pages. */
958
+ totalPages: number;
959
+ /** Whether the current page is the last page. */
960
+ isLast: boolean;
961
+ /** The request trace id returned by the server. */
962
+ requestId?: string;
963
+ /** The server response timestamp in milliseconds. */
964
+ timestamp: number;
965
+ }
966
+
967
+ /**
968
+ * The options for server-side message search.
969
+ */
970
+ interface MessageSearchOption {
971
+ /** The keyword list for search. */
972
+ keywordList: string[];
973
+ /** The keyword list match type. The valid values are `or` and `and`. The default value is `or`. */
974
+ keywordListMatchType?: MessageSearchKeywordListMatchType;
975
+ /** The conversation ID for in-conversation search. */
976
+ conversationId?: string;
977
+ /** The conversation type for filtering. Must be used with conversationId. */
978
+ conversationType?: ChatType;
979
+ /** Message body type filters. */
980
+ msgTypes?: MessageType[];
981
+ /** The start timestamp for query. The unit is millisecond. */
982
+ startTime?: number;
983
+ /** The end timestamp for query. The unit is millisecond. */
984
+ endTime?: number;
985
+ /** The search scope. */
986
+ searchScope?: MessageSearchScope;
987
+ }
988
+
989
+ interface ServerConversations {
996
990
  /** The conversation list. */
997
991
  conversations: ConversationItem[];
998
992
  /** 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.*/
@@ -4713,8 +4707,28 @@ export declare namespace EasemobChat {
4713
4707
  }
4714
4708
  ): Promise<HistoryMessages>;
4715
4709
 
4716
- /**
4717
- * Unidirectionally deletes historical messages from the server.
4710
+ /**
4711
+ * Searches messages from the server.
4712
+ * This feature requires the "Message Search" service to be enabled in the Console.
4713
+ *
4714
+ * @param option The search option. See {@link MessageSearchOption}.
4715
+ * @param pageNum The page number for pagination, starting from 1.
4716
+ * @param pageSize The number of results per page (1-100, default 20).
4717
+ */
4718
+ searchMessages(
4719
+ this: Connection,
4720
+ params: {
4721
+ /** The search option. */
4722
+ option: MessageSearchOption;
4723
+ /** The page number for pagination, starting from 1. */
4724
+ pageNum?: number;
4725
+ /** The number of results per page. The range is 1 to 100. */
4726
+ pageSize?: number;
4727
+ }
4728
+ ): Promise<ServerSearchMessagesResult>;
4729
+
4730
+ /**
4731
+ * Unidirectionally deletes historical messages from the server.
4718
4732
  *
4719
4733
  * ```typescript
4720
4734
  * connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', time: Date.now()})
@@ -7825,22 +7839,37 @@ export declare namespace EasemobChat {
7825
7839
  }
7826
7840
 
7827
7841
  interface CreateImageMessageParameters {
7842
+ /** The conversation type. */
7828
7843
  chatType: ChatType;
7844
+ /** The recipient. */
7829
7845
  to: string;
7846
+ /** The sender, which can only be the current user and can not be changed. */
7830
7847
  from?: string;
7848
+ /** The image file source. */
7831
7849
  file: ImageFileSource;
7850
+ /** The image width. */
7832
7851
  width?: number;
7852
+ /** The image height. */
7833
7853
  height?: number;
7834
7854
  /** Whether to send the original image. Default is false. */
7835
7855
  isOriginalImage?: boolean;
7856
+ /** Message extension. */
7836
7857
  ext?: { [key: string]: any };
7858
+ /** Whether read receipts are required during a group session. */
7837
7859
  msgConfig?: { allowGroupAck: boolean };
7860
+ /** Whether the message is a thread message. */
7838
7861
  isChatThread?: boolean;
7862
+ /** Message priority. */
7839
7863
  priority?: MessagePriority;
7864
+ /** Whether the message is delivered only when the recipient(s) is/are online. */
7840
7865
  deliverOnlineOnly?: boolean;
7866
+ /** The list of message recipients. */
7841
7867
  receiverList?: string[];
7868
+ /** The callback of file upload error. */
7842
7869
  onFileUploadError?: (err: ErrorEvent) => void;
7870
+ /** The callback of file upload completion. */
7843
7871
  onFileUploadComplete?: (data: UploadFileResult) => void;
7872
+ /** The callback of file upload progress. */
7844
7873
  onFileUploadProgress?: (data: ProgressEvent) => void;
7845
7874
  }
7846
7875