easemob-websdk 5.1.3 → 5.2.0

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.
Files changed (81) hide show
  1. package/bundle/im-sdk-web.iife.js +1 -1
  2. package/cache/cache-types.d.ts +2 -2
  3. package/chat-client.d.ts +17 -2
  4. package/chunks/chat-manager-BB7wYWYG.js +2 -0
  5. package/chunks/chat-manager-auF_3s3R.cjs +1 -0
  6. package/chunks/common-Cg-lTASK.cjs +1 -0
  7. package/chunks/common-gbNWJrBc.js +1 -0
  8. package/chunks/{group-user-info-resolver-B-dyr__b.cjs → group-user-info-resolver-BNwtC7dY.cjs} +1 -1
  9. package/chunks/{group-user-info-resolver-D6AQAHEE.js → group-user-info-resolver-rs5Fnr0l.js} +1 -1
  10. package/chunks/index-BUNbI8gf.cjs +1 -0
  11. package/chunks/index-BxMCMoWN.js +1 -0
  12. package/chunks/index-C7fO2X0x.cjs +1 -0
  13. package/chunks/index-C_EMU0-3.js +1 -0
  14. package/chunks/index-CsqE2tfH.js +1 -0
  15. package/chunks/index-DeJuR3uW.cjs +1 -0
  16. package/chunks/index-Dknccp9Q.js +1 -0
  17. package/chunks/index-P1vnLSK2.cjs +1 -0
  18. package/chunks/multibody-content-BHb-Au8Q.js +1 -0
  19. package/chunks/multibody-content-BmdQukoX.cjs +1 -0
  20. package/chunks/{push-manager-CSIKhoPe.js → push-manager-BO3xq-7O.js} +1 -1
  21. package/chunks/{push-manager-D7RDsKuv.cjs → push-manager-DMI0G9v9.cjs} +1 -1
  22. package/chunks/reflection-proto-codec-B1apL0ws.js +1 -0
  23. package/chunks/reflection-proto-codec-CYglS_mx.cjs +1 -0
  24. package/chunks/session-list-query-DMe2GZ4v.cjs +1 -0
  25. package/chunks/session-list-query-Inseic9m.js +1 -0
  26. package/chunks/{user-info-DH3aE1gm.cjs → user-info-B5St7axd.cjs} +1 -1
  27. package/chunks/{user-info-7QzMa7bR.js → user-info-BkqJHgja.js} +1 -1
  28. package/core/index.d.ts +1 -1
  29. package/core/message/attachment-downloader.d.ts +4 -1
  30. package/core/message/message-sender.d.ts +19 -4
  31. package/core/message/prepare-text-translation.d.ts +7 -0
  32. package/index.cjs +1 -1
  33. package/index.d.ts +3 -2
  34. package/index.js +2 -2
  35. package/managers/chat/index.cjs +1 -1
  36. package/managers/chat/index.js +1 -1
  37. package/managers/chat-manager.d.ts +128 -7
  38. package/managers/chat-thread/index.cjs +1 -1
  39. package/managers/chat-thread/index.js +1 -1
  40. package/managers/chatroom/index.cjs +1 -1
  41. package/managers/chatroom/index.js +1 -1
  42. package/managers/contact/index.cjs +1 -1
  43. package/managers/contact/index.js +1 -1
  44. package/managers/group/index.cjs +1 -1
  45. package/managers/group/index.js +1 -1
  46. package/managers/presence/index.cjs +1 -1
  47. package/managers/presence/index.js +1 -1
  48. package/managers/push/index.cjs +1 -1
  49. package/managers/push/index.js +1 -1
  50. package/managers/user-info/index.cjs +1 -1
  51. package/managers/user-info/index.js +1 -1
  52. package/message/combine-payload-codec.d.ts +2 -2
  53. package/message/combine-payload-file.d.ts +11 -0
  54. package/message/create-message.d.ts +16 -4
  55. package/message/create-multibody-message.d.ts +31 -0
  56. package/message/message-snapshot.d.ts +2 -1
  57. package/message/multibody-content.d.ts +35 -0
  58. package/message/translations.d.ts +7 -0
  59. package/package.json +1 -1
  60. package/platform/image/miniapp-image-processor.d.ts +10 -6
  61. package/protocol/msync/codec.d.ts +3 -0
  62. package/protocol/msync/message-payload-decoder.d.ts +5 -1
  63. package/protocol/session-list/payload-decoder.d.ts +2 -2
  64. package/types/chat-manager.d.ts +2 -2
  65. package/types/conversation.d.ts +2 -2
  66. package/types/index.d.ts +33 -9
  67. package/types/message-create.d.ts +130 -2
  68. package/upload/attachment-uploader.d.ts +8 -0
  69. package/validators/message-create.d.ts +25 -2
  70. package/chunks/chat-manager-BI-6bEor.cjs +0 -1
  71. package/chunks/chat-manager-nXOTpJ01.js +0 -2
  72. package/chunks/common-DHQukb7J.js +0 -1
  73. package/chunks/common-tHGz9VBk.cjs +0 -1
  74. package/chunks/index-CneY58NJ.js +0 -1
  75. package/chunks/index-DJPAjXAp.cjs +0 -1
  76. package/chunks/index-DtWkVcfb.cjs +0 -1
  77. package/chunks/index-DxjmfFL7.js +0 -1
  78. package/chunks/reflection-proto-codec-7r8Sei3y.js +0 -1
  79. package/chunks/reflection-proto-codec-CwrIKT1L.cjs +0 -1
  80. package/chunks/session-list-query-C3iQvQxK.cjs +0 -1
  81. package/chunks/session-list-query-Cdpiw_IZ.js +0 -1
@@ -0,0 +1,35 @@
1
+ import type { CompatibleFile, MultiBody, Message, MessageBody, MessageType } from '../types';
2
+ declare const MULTIBODY_SEGMENT_TYPES: readonly ["text", "image", "file", "voice", "video", "location", "custom"];
3
+ export type MultiBodySegmentType = (typeof MULTIBODY_SEGMENT_TYPES)[number];
4
+ export declare const isMultiBodySegmentType: (type: string) => type is MultiBodySegmentType;
5
+ /** 复合消息附件缓存 key。冒号必须保留,避免本地 id 和分段下标粘在一起。 */
6
+ export declare const attachmentStoreKey: (msgLocalId: string, bodyIndex: number) => string;
7
+ /** 本地文件挂在分段对象本身上。组装时按这个对象取走,复制分段会把文件丢掉。 */
8
+ export declare const holdAttachmentFile: (body: object, file: CompatibleFile) => void;
9
+ export declare const takeAttachmentFile: (body: object) => CompatibleFile | undefined;
10
+ export declare const mapRestSegmentType: (type: string | undefined) => MessageType | null;
11
+ /** REST 合并段经常写成 txt/text,并用 subType 0 或合并启发字段标识。 */
12
+ export declare const isCombineRestSegment: (segment: Record<string, unknown>) => boolean;
13
+ /** 多段无法合成复合消息时只留第一段,并说明原因。第一段本身解不出来则仍丢弃。 */
14
+ export declare const keepFirstBody: <T>(segments: ReadonlyArray<T>, reason: string) => ReadonlyArray<T>;
15
+ export declare const composeSegments: (segments: ReadonlyArray<{
16
+ type: MessageType;
17
+ body: MessageBody;
18
+ } | null>) => {
19
+ type: MessageType;
20
+ body: MessageBody;
21
+ } | null;
22
+ export declare const resolvePublicMessageContent: (contents: ReadonlyArray<unknown>, decodeContent: (content: Record<string, unknown>) => {
23
+ type: MessageType;
24
+ body: MessageBody;
25
+ } | null) => {
26
+ type: MessageType;
27
+ body: MessageBody;
28
+ } | null;
29
+ export declare const isDownloadableSegmentType: (type: string) => type is "image" | "voice" | "video" | "file";
30
+ export declare const attachMultiBodyUploadDetails: (error: unknown, msgLocalId: string) => void;
31
+ export declare const isMultiBodyMessage: (message: Pick<Message, "type" | "body">) => message is Message & {
32
+ type: "multi_body";
33
+ body: MultiBody;
34
+ };
35
+ export {};
@@ -0,0 +1,7 @@
1
+ /** 消息译文的公开映射与现有消息协议数组之间的转换。 */
2
+ export declare const toProtocolTranslations: (translations: Readonly<Record<string, string>> | undefined) => ReadonlyArray<{
3
+ readonly code: string;
4
+ readonly text: string;
5
+ }>;
6
+ /** 非法译文不影响原文解析;重复语言采用最后一个合法条目。 */
7
+ export declare const readTranslations: (metaPayload: unknown) => Record<string, string> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easemob-websdk",
3
- "version": "5.1.3",
3
+ "version": "5.2.0",
4
4
  "description": "High-performance, type-safe, extensible instant messaging SDK",
5
5
  "homepage": "https://www.easemob.com/",
6
6
  "type": "module",
@@ -4,18 +4,21 @@ interface MiniAppReadFileSuccessResult {
4
4
  }
5
5
  interface MiniAppGetFileInfoSuccessResult {
6
6
  readonly size: number;
7
+ readonly digest?: string;
8
+ }
9
+ interface MiniAppGetFileInfoOptions {
10
+ readonly filePath: string;
11
+ readonly digestAlgorithm?: 'md5';
12
+ readonly success: (result: MiniAppGetFileInfoSuccessResult) => void;
13
+ readonly fail?: (error: unknown) => void;
7
14
  }
8
15
  interface MiniAppFileSystemManagerLike {
9
- readFile(options: {
16
+ readFile?(options: {
10
17
  readonly filePath: string;
11
18
  readonly success: (result: MiniAppReadFileSuccessResult) => void;
12
19
  readonly fail?: (error: unknown) => void;
13
20
  }): void;
14
- getFileInfo?(options: {
15
- readonly filePath: string;
16
- readonly success: (result: MiniAppGetFileInfoSuccessResult) => void;
17
- readonly fail?: (error: unknown) => void;
18
- }): void;
21
+ getFileInfo?(options: MiniAppGetFileInfoOptions): void;
19
22
  }
20
23
  interface MiniAppImageInfoResponse {
21
24
  readonly width: number;
@@ -40,6 +43,7 @@ export interface MiniAppImageRuntimeLike {
40
43
  readonly fail?: (error: unknown) => void;
41
44
  }): void;
42
45
  getFileSystemManager?(): MiniAppFileSystemManagerLike;
46
+ getFileInfo?(options: MiniAppGetFileInfoOptions): void;
43
47
  }
44
48
  export declare const createMiniAppImageProcessor: (runtime: MiniAppImageRuntimeLike) => ImageProcessor;
45
49
  export {};
@@ -149,9 +149,12 @@ export declare class MsyncCodec {
149
149
  private decodeMessage;
150
150
  private resolveMessageProfileVersionFields;
151
151
  private buildMessageMeta;
152
+ private buildMessageMetaFromBody;
153
+ private buildTranslationsMeta;
152
154
  private resolveProfileVersionTime;
153
155
  private isPublicMessageType;
154
156
  private resolveMessageIsOnline;
157
+ private buildContents;
155
158
  private buildContent;
156
159
  private decodeContent;
157
160
  private resolveChatType;
@@ -8,7 +8,7 @@ export declare class MessagePayloadDecoder {
8
8
  private readonly useCustomAttachmentUpload;
9
9
  constructor(userId: string, useCustomAttachmentUpload?: boolean);
10
10
  decodeMetadata(body: Record<string, unknown>, conversationType: ChatConversationType, direct: Message['direct'], fallbackMeta?: unknown): Omit<Partial<Message>, 'body'>;
11
- decodeContent(content: Record<string, unknown>): {
11
+ decodeContent(content: Record<string, unknown>, metaPayload?: unknown): {
12
12
  type: Message['type'];
13
13
  body: MessageBody;
14
14
  } | null;
@@ -24,6 +24,10 @@ export declare class MessagePayloadDecoder {
24
24
  resolveChatThreadOverview(metaPayload: unknown): ChatThreadOverview | undefined;
25
25
  resolveChatThreadOverviewLastMessage(rawLastMessage: unknown, chatThreadId: string): ChatThreadOverview['lastMessage'] | undefined;
26
26
  resolveThreadLastMessagePayload(rawLastMessage: Record<string, unknown>): Record<string, unknown> | null;
27
+ composeThreadBodies(bodies: ReadonlyArray<unknown>): {
28
+ type: Message['type'];
29
+ body: MessageBody;
30
+ } | null;
27
31
  mapThreadMessageType(rawType: string | undefined): Message['type'];
28
32
  normalizeThreadLastMessageBody(type: Message['type'], firstBody: Record<string, unknown> | null, rawLastMessage: Record<string, unknown>): MessageBody;
29
33
  readString(value: unknown): string | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { SessionMessageSnippet } from '../../types/conversation';
2
2
  export declare const decodeSessionListPayload: (payload?: Uint8Array) => {
3
- readonly body: Record<string, unknown>;
3
+ readonly body: Record<string, unknown> | ReadonlyArray<Record<string, unknown>>;
4
4
  readonly ext: Record<string, unknown>;
5
5
  };
6
6
  export declare const decodeSessionListPayloadRecord: (payload?: Uint8Array) => Record<string, unknown> | null;
@@ -10,4 +10,4 @@ export declare const mapSessionListPayload: (decoded: Record<string, unknown> |
10
10
  readonly from: string;
11
11
  readonly useCustomAttachmentUpload?: boolean;
12
12
  }) => Partial<SessionMessageSnippet>;
13
- export declare const decodeSessionListPayloadBody: (payload?: Uint8Array) => Record<string, unknown>;
13
+ export declare const decodeSessionListPayloadBody: (payload?: Uint8Array) => Record<string, unknown> | ReadonlyArray<Record<string, unknown>>;
@@ -63,7 +63,7 @@ export interface RecallMessageParams extends ConversationLocator {
63
63
  export interface UpdateMessageParams extends ConversationLocator {
64
64
  /** [zh-CN] 待编辑的消息 ID。 [en-US] ID of the message to edit. */
65
65
  messageId: string;
66
- /** [zh-CN] 编辑后的消息内容。当前仅支持文本消息和自定义消息。 [en-US] Updated message content. Currently, only text messages and custom messages are supported. */
66
+ /** [zh-CN] 编辑后的消息内容。文本消息可修改 `content` 和 `ext`;`body.targetLanguages` 非空时先翻译再编辑,译文写入 `body.translations`,翻译失败则抛出异常且不发送编辑。自定义消息可修改 `event`、`params` 和 `ext`;图片、语音、视频、文件、位置和合并消息仅可修改 `ext`。命令消息和复合消息不支持编辑。 [en-US] Updated message content. Text messages can change `content` and `ext`. Non-empty `body.targetLanguages` are translated before the edit and stored in `body.translations`; translation failure throws without sending the edit. Custom messages can change `event`, `params`, and `ext`. Image, voice, video, file, location, and combined messages can change `ext` only. Command and multi_body messages cannot be edited. */
67
67
  message: Pick<Message, 'type' | 'body' | 'ext'>;
68
68
  }
69
69
  /**
@@ -113,7 +113,7 @@ export interface MessageHistoryPage {
113
113
  * [en-US] Parameters for downloading a message attachment.
114
114
  */
115
115
  export interface DownloadAttachmentParams {
116
- /** [zh-CN] 需要下载附件的消息,通常为图片、语音、视频或文件消息。 [en-US] Message whose attachment is to be downloaded, typically an image, voice, video, or file message. */
116
+ /** [zh-CN] 需要下载附件的消息,通常为图片、语音、视频、文件或复合消息。复合消息会下载其中全部图片、语音、视频和文件。 [en-US] Message whose attachment is to be downloaded, typically an image, voice, video, file, or multi_body message. A multi_body message downloads every image, voice, video, and file segment. */
117
117
  message: Message;
118
118
  }
119
119
  /**
@@ -240,8 +240,8 @@ export interface SessionMessageSnippet extends Readonly<Partial<Omit<Message, 'b
240
240
  readonly userInfoUpdateTime?: number;
241
241
  /** [zh-CN] 群成员名片的版本时间戳(秒),仅群聊会话的最后一条消息可能存在此字段。 [en-US] The version timestamp (in seconds) of the Group member name card. This field may only exist for the last message in group chat conversations. */
242
242
  readonly namecardUpdateTime?: number;
243
- /** [zh-CN] 与 MessageBody 一致的消息正文,不包含 type;为兼容历史不完整摘要,保留对象类型。 [en-US] Message content matching MessageBody without type; an object type is retained for incomplete legacy snippets. */
244
- readonly body: Record<string, unknown>;
243
+ /** [zh-CN] 与 MessageBody 一致的消息正文。复合消息时这里直接是分段数组。 [en-US] Message content matching MessageBody. For a multi_body message, this is the segment array. */
244
+ readonly body: Record<string, unknown> | ReadonlyArray<Record<string, unknown>>;
245
245
  /** [zh-CN] 消息扩展字段,与 onMessage 的 ext 一致;旧缓存可能缺失。 [en-US] Message extension fields, matching onMessage ext; may be absent in legacy caches. */
246
246
  readonly ext?: Message['ext'];
247
247
  }
package/types/index.d.ts CHANGED
@@ -48,7 +48,7 @@ export type { Sender } from './sender';
48
48
  * [zh-CN] SDK 支持的消息类型。
49
49
  * [en-US] Message types supported by the SDK.
50
50
  */
51
- export type MessageType = 'text' | 'image' | 'file' | 'voice' | 'video' | 'location' | 'custom' | 'cmd' | 'combine';
51
+ export type MessageType = 'text' | 'image' | 'file' | 'voice' | 'video' | 'location' | 'custom' | 'cmd' | 'combine' | 'multi_body';
52
52
  /**
53
53
  * [zh-CN] 图片资源类型常量。
54
54
  * [en-US] Image resource type constants.
@@ -151,9 +151,9 @@ export type CompatibleFile = File | MiniAppFile | ReactNativeFile;
151
151
  export interface TextMessageBody {
152
152
  /** [zh-CN] 消息文本内容。 [en-US] Message text content. */
153
153
  content: string;
154
- /** [zh-CN] 目标翻译语言代码列表。 [en-US] Target translation language codes. */
154
+ /** [zh-CN] 发送前自动翻译的目标语言代码列表,不传或空数组不翻译。 [en-US] Target language codes for automatic translation before sending; omitted or empty arrays disable translation. */
155
155
  targetLanguages?: string[];
156
- /** [zh-CN] 语言代码到翻译文本的映射。 [en-US] Mapping from language codes to translated text. */
156
+ /** [zh-CN] 语言代码到译文的映射,由自动发送翻译或接收解码填充;主动翻译 API 仅返回结果。 [en-US] Language-to-text map populated by automatic translation on send or incoming decoding; the explicit translation API only returns results. */
157
157
  translations?: Record<string, string>;
158
158
  }
159
159
  /**
@@ -307,11 +307,35 @@ export interface CombineMessageBody {
307
307
  /** [zh-CN] 当前合并消息嵌套层级。 [en-US] Current nesting level of the combined message. */
308
308
  combineLevel: number;
309
309
  }
310
+ /**
311
+ * [zh-CN] 复合消息中的一段可组合内容。`type` 只出现在复合消息的分段上。
312
+ * [en-US] One segment inside a multi_body message. `type` exists only on these segments.
313
+ */
314
+ export type MultiBodySegment = ({
315
+ type: 'text';
316
+ } & TextMessageBody) | ({
317
+ type: 'image';
318
+ } & ImageMessageBody) | ({
319
+ type: 'file';
320
+ } & FileMessageBody) | ({
321
+ type: 'voice';
322
+ } & VoiceMessageBody) | ({
323
+ type: 'video';
324
+ } & VideoMessageBody) | ({
325
+ type: 'location';
326
+ } & LocationMessageBody) | ({
327
+ type: 'custom';
328
+ } & CustomMessageBody);
329
+ /**
330
+ * [zh-CN] 复合消息正文。分段按发送顺序排列,至少 2 段。
331
+ * [en-US] Body of a multi_body message. Segments stay in send order and there are at least two.
332
+ */
333
+ export type MultiBody = ReadonlyArray<MultiBodySegment>;
310
334
  /**
311
335
  * [zh-CN] 所有消息体的联合类型。
312
336
  * [en-US] Union of all message body types.
313
337
  */
314
- export type MessageBody = TextMessageBody | ImageMessageBody | FileMessageBody | VoiceMessageBody | VideoMessageBody | LocationMessageBody | CmdMessageBody | CustomMessageBody | CombineMessageBody;
338
+ export type MessageBody = TextMessageBody | ImageMessageBody | FileMessageBody | VoiceMessageBody | VideoMessageBody | LocationMessageBody | CmdMessageBody | CustomMessageBody | CombineMessageBody | MultiBody;
315
339
  /**
316
340
  * [zh-CN] 消息对象。
317
341
  * [en-US] Message object.
@@ -339,7 +363,7 @@ export interface Message {
339
363
  ext: Record<string, unknown>;
340
364
  /** [zh-CN] 消息时间戳,单位毫秒。 [en-US] Message timestamp in milliseconds. */
341
365
  timestamp: number;
342
- /** [zh-CN] 消息体。 [en-US] Message body. */
366
+ /** [zh-CN] 消息体。复合消息时这里直接是分段数组。 [en-US] Message body. For a multi_body message, this is the segment array. */
343
367
  body: MessageBody;
344
368
  /** [zh-CN] 消息方向。 [en-US] Message direction. */
345
369
  direct?: MessageDirect;
@@ -446,11 +470,11 @@ export interface StreamMessage extends Message {
446
470
  * [en-US] File upload progress.
447
471
  */
448
472
  export interface FileUploadProgress {
449
- /** [zh-CN] 已上传字节数。 [en-US] Number of uploaded bytes. */
473
+ /** [zh-CN] 已上传字节数。复合消息按全部附件文件大小合计。 [en-US] Number of uploaded bytes. MultiBody messages use the combined size of all attachments. */
450
474
  loaded: number;
451
- /** [zh-CN] 文件总字节数。 [en-US] Total number of bytes in the file. */
475
+ /** [zh-CN] 附件总字节数。复合消息是各附件文件大小之和。 [en-US] Total attachment size in bytes. MultiBody messages use the sum of every attachment file size. */
452
476
  total?: number;
453
- /** [zh-CN] 上传进度百分比。 [en-US] Upload progress as a percentage. */
477
+ /** [zh-CN] 相对全部附件总大小的上传百分比。 [en-US] Upload percentage relative to the total size of all attachments. */
454
478
  percent?: number;
455
479
  }
456
480
  /**
@@ -498,7 +522,7 @@ export interface SendMessageOptions {
498
522
  onFileUploadComplete?: (result: FileUploadResult) => void;
499
523
  /** [zh-CN] 附件上传失败回调。 [en-US] Triggered when the attachment upload fails. */
500
524
  onFileUploadError?: (error: Error) => void;
501
- /** [zh-CN] 附件上传取消回调。 [en-US] Triggered when the attachment upload is cancelled.*/
525
+ /** [zh-CN] 附件上传取消回调。 [en-US] Triggered when the attachment upload is cancelled. */
502
526
  onFileUploadCanceled?: () => void;
503
527
  }
504
528
  /**
@@ -2,7 +2,7 @@
2
2
  * [zh-CN] 创建消息方法的入参类型定义。
3
3
  * [en-US] Parameter type definitions for message creation APIs.
4
4
  */
5
- import type { ChatConversationType, CompatibleFile, Message, MessagePriority } from './index';
5
+ import type { ChatConversationType, CompatibleFile, MultiBodySegment, Message, MessagePriority } from './index';
6
6
  /**
7
7
  * [zh-CN] 创建消息的通用入参。
8
8
  * [en-US] Common parameters for creating messages.
@@ -36,7 +36,7 @@ export interface CreateMessageBaseParams {
36
36
  export interface CreateTextMessageParams extends CreateMessageBaseParams {
37
37
  /** [zh-CN] 文本消息内容。 [en-US] Text message content. */
38
38
  content: string;
39
- /** [zh-CN] 发送时需要翻译到的目标语言列表。 [en-US] List of target languages to translate the message into upon sending. */
39
+ /** [zh-CN] 发送前自动翻译的目标语言列表;不传或空数组不翻译,翻译失败不发送。 [en-US] Target languages for automatic translation before sending; omitted or empty arrays disable translation, and translation failure prevents sending. */
40
40
  targetLanguages?: string[];
41
41
  }
42
42
  /**
@@ -157,6 +157,134 @@ export interface CreateCustomMessageParams extends CreateMessageBaseParams {
157
157
  /** [zh-CN] 自定义参数。 [en-US] Custom parameters. */
158
158
  params?: Record<string, string>;
159
159
  }
160
+ /**
161
+ * [zh-CN] 创建文本分段的入参。
162
+ * [en-US] Parameters for creating a text segment.
163
+ */
164
+ export interface CreateTextMessageBodyParams {
165
+ /** [zh-CN] 文本内容,不能为空。 [en-US] Text content. An empty string is not allowed. */
166
+ content: string;
167
+ /** [zh-CN] 复合消息发送时不生效,这段文本不会被翻译。 [en-US] Has no effect when sending a multi_body message. This text segment is not translated. */
168
+ targetLanguages?: string[];
169
+ }
170
+ /**
171
+ * [zh-CN] 创建图片分段的入参。`data` 与 `originalUrl` 至少传一个。
172
+ * [en-US] Parameters for creating an image segment. Either `data` or `originalUrl` is required.
173
+ */
174
+ export interface CreateImageMessageBodyParams {
175
+ /** [zh-CN] 本地图片文件。传入后必须把返回的同一个分段对象放进复合消息。 [en-US] Local image file. The returned segment object must be passed unchanged into the multi_body message. */
176
+ data?: CompatibleFile;
177
+ /** [zh-CN] 远程原图地址。 [en-US] Remote original image URL. */
178
+ originalUrl?: string;
179
+ /** [zh-CN] 文件名。传 `data` 时可由 SDK 在发送前补齐。 [en-US] File name. The SDK can fill it before sending when `data` is provided. */
180
+ filename?: string;
181
+ /** [zh-CN] 文件 MIME 类型。 [en-US] MIME type. */
182
+ filetype?: string;
183
+ /** [zh-CN] 图片宽度,单位像素。 [en-US] Image width in pixels. */
184
+ width?: number;
185
+ /** [zh-CN] 图片高度,单位像素。 [en-US] Image height in pixels. */
186
+ height?: number;
187
+ /** [zh-CN] 是否为 GIF。 [en-US] Whether the image is a GIF. */
188
+ isGif?: boolean;
189
+ /** [zh-CN] 是否按原图语义发送。 [en-US] Whether to send the original image. */
190
+ isOriginalImage?: boolean;
191
+ /** [zh-CN] 文件大小,单位字节。 [en-US] File size in bytes. */
192
+ fileLength?: number;
193
+ /** [zh-CN] 缩略图地址。 [en-US] Thumbnail URL. */
194
+ thumbnailUrl?: string;
195
+ }
196
+ /**
197
+ * [zh-CN] 创建文件分段的入参。`data` 与 `originalUrl` 至少传一个。
198
+ * [en-US] Parameters for creating a file segment. Either `data` or `originalUrl` is required.
199
+ */
200
+ export interface CreateFileMessageBodyParams {
201
+ /** [zh-CN] 本地文件。 [en-US] Local file. */
202
+ data?: CompatibleFile;
203
+ /** [zh-CN] 远程文件地址。 [en-US] Remote file URL. */
204
+ originalUrl?: string;
205
+ /** [zh-CN] 文件名。 [en-US] File name. */
206
+ filename?: string;
207
+ /** [zh-CN] 文件 MIME 类型。 [en-US] MIME type. */
208
+ filetype?: string;
209
+ /** [zh-CN] 待发送文件大小,单位字节。 [en-US] File size in bytes. */
210
+ fileSize?: number;
211
+ /** [zh-CN] 文件长度,单位字节。 [en-US] File length in bytes. */
212
+ fileLength?: number;
213
+ }
214
+ /**
215
+ * [zh-CN] 创建语音分段的入参。`data` 与 `originalUrl` 至少传一个。
216
+ * [en-US] Parameters for creating a voice segment. Either `data` or `originalUrl` is required.
217
+ */
218
+ export interface CreateVoiceMessageBodyParams {
219
+ /** [zh-CN] 本地语音文件。 [en-US] Local voice file. */
220
+ data?: CompatibleFile;
221
+ /** [zh-CN] 远程语音地址。 [en-US] Remote voice URL. */
222
+ originalUrl?: string;
223
+ /** [zh-CN] 文件名。 [en-US] File name. */
224
+ filename?: string;
225
+ /** [zh-CN] 文件 MIME 类型。 [en-US] MIME type. */
226
+ filetype?: string;
227
+ /** [zh-CN] 语音时长,单位秒。 [en-US] Voice duration in seconds. */
228
+ duration: number;
229
+ /** [zh-CN] 文件大小,单位字节。 [en-US] File size in bytes. */
230
+ fileLength?: number;
231
+ }
232
+ /**
233
+ * [zh-CN] 创建视频分段的入参。`data` 与 `originalUrl` 至少传一个。
234
+ * [en-US] Parameters for creating a video segment. Either `data` or `originalUrl` is required.
235
+ */
236
+ export interface CreateVideoMessageBodyParams {
237
+ /** [zh-CN] 本地视频文件。 [en-US] Local video file. */
238
+ data?: CompatibleFile;
239
+ /** [zh-CN] 远程视频地址。 [en-US] Remote video URL. */
240
+ originalUrl?: string;
241
+ /** [zh-CN] 文件名。 [en-US] File name. */
242
+ filename?: string;
243
+ /** [zh-CN] 文件 MIME 类型。 [en-US] MIME type. */
244
+ filetype?: string;
245
+ /** [zh-CN] 视频时长,单位秒。 [en-US] Video duration in seconds. */
246
+ duration: number;
247
+ /** [zh-CN] 视频宽度,单位像素。 [en-US] Video width in pixels. */
248
+ width?: number;
249
+ /** [zh-CN] 视频高度,单位像素。 [en-US] Video height in pixels. */
250
+ height?: number;
251
+ /** [zh-CN] 文件大小,单位字节。 [en-US] File size in bytes. */
252
+ fileLength?: number;
253
+ /** [zh-CN] 视频缩略图地址。 [en-US] Video thumbnail URL. */
254
+ thumbnailUrl?: string;
255
+ }
256
+ /**
257
+ * [zh-CN] 创建位置分段的入参。
258
+ * [en-US] Parameters for creating a location segment.
259
+ */
260
+ export interface CreateLocationMessageBodyParams {
261
+ /** [zh-CN] 纬度。 [en-US] Latitude. */
262
+ latitude: number;
263
+ /** [zh-CN] 经度。 [en-US] Longitude. */
264
+ longitude: number;
265
+ /** [zh-CN] 地址描述。 [en-US] Address description. */
266
+ address?: string;
267
+ /** [zh-CN] 建筑名称。 [en-US] Building name. */
268
+ buildingName?: string;
269
+ }
270
+ /**
271
+ * [zh-CN] 创建自定义分段的入参。
272
+ * [en-US] Parameters for creating a custom segment.
273
+ */
274
+ export interface CreateCustomMessageBodyParams {
275
+ /** [zh-CN] 自定义事件名称。 [en-US] Custom event name. */
276
+ event: string;
277
+ /** [zh-CN] 自定义字符串参数。 [en-US] Custom string parameters. */
278
+ params?: Record<string, string>;
279
+ }
280
+ /**
281
+ * [zh-CN] 创建复合消息的入参。`bodies` 必须是分段工厂返回的对象,且为 2 到 20 段。
282
+ * [en-US] Parameters for creating a multi_body message. `bodies` must be the objects returned by segment factories and contain 2 to 20 segments.
283
+ */
284
+ export interface CreateMultiBodyMessageParams extends CreateMessageBaseParams {
285
+ /** [zh-CN] 有序分段,2 到 20 项。不能包含命令、合并、复合消息或流式内容。 [en-US] Ordered segments, from 2 to 20. Command, combined, multi_body, and stream content is not allowed. */
286
+ bodies: ReadonlyArray<MultiBodySegment>;
287
+ }
160
288
  /**
161
289
  * [zh-CN] 创建合并消息的入参。
162
290
  * [en-US] Parameters for creating a combined message.
@@ -11,6 +11,14 @@ export declare class AttachmentUploader {
11
11
  * 这里会串起 029 的主流程:解析本地文件、决定图片发送语义、按门槛做预检、命中则复用远端资源,未命中再进入实际上传。
12
12
  */
13
13
  prepareMessage(message: Message, options?: SendMessageOptions): Promise<Message>;
14
+ /**
15
+ * 按段串行准备复合消息的附件。文本、位置、自定义段跳过。
16
+ * 附件段的 msgLocalId 改成 `msgLocalId:bodyIndex`,才能取到组装时放入的文件。
17
+ * 任一段失败就整条不发送,已经传完的段不会单独提交。
18
+ */
19
+ private prepareMultiBodyMessage;
20
+ /** 失败回调补上复合消息的 msgLocalId。进度、完成和取消都不带分段序号。 */
21
+ private withSegmentCallbacks;
14
22
  private resolveUploadUrl;
15
23
  private hasUploadedRemoteResource;
16
24
  private prepareAttachmentUpload;
@@ -346,6 +346,29 @@ export declare const createCustomMessageSchema: z.ZodType<{
346
346
  isChatThread?: boolean | undefined;
347
347
  params?: Record<string, string> | undefined;
348
348
  }>;
349
+ export declare const createMessageEnvelopeSchema: z.ZodType<{
350
+ conversationId: string;
351
+ conversationType: "singleChat" | "groupChat" | "chatRoom";
352
+ ext?: Record<string, unknown> | undefined;
353
+ timestamp?: number | undefined;
354
+ receiverList?: [string, ...string[]] | undefined;
355
+ deliverOnlineOnly?: boolean | undefined;
356
+ webhookEnv?: string | undefined;
357
+ priority?: "normal" | "high" | "low" | undefined;
358
+ needReadReceipt?: boolean | undefined;
359
+ isChatThread?: boolean | undefined;
360
+ }, z.ZodTypeDef, {
361
+ conversationId: string;
362
+ conversationType: "singleChat" | "groupChat" | "chatRoom";
363
+ ext?: Record<string, unknown> | undefined;
364
+ timestamp?: number | undefined;
365
+ receiverList?: [string, ...string[]] | undefined;
366
+ deliverOnlineOnly?: boolean | undefined;
367
+ webhookEnv?: string | undefined;
368
+ priority?: "normal" | "high" | "low" | undefined;
369
+ needReadReceipt?: boolean | undefined;
370
+ isChatThread?: boolean | undefined;
371
+ }>;
349
372
  export declare const createCombineMessageSchema: z.ZodType<{
350
373
  conversationId: string;
351
374
  conversationType: "singleChat" | "groupChat" | "chatRoom";
@@ -369,7 +392,7 @@ export declare const createCombineMessageSchema: z.ZodType<{
369
392
  conversationId: z.ZodString;
370
393
  conversationType: z.ZodEnum<["singleChat", "groupChat", "chatRoom"]>;
371
394
  timestamp: z.ZodNumber;
372
- body: z.ZodRecord<z.ZodString, z.ZodUnknown>;
395
+ body: z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">]>;
373
396
  combineLevel: z.ZodOptional<z.ZodNumber>;
374
397
  }, z.ZodTypeAny, "passthrough">[];
375
398
  ext?: Record<string, unknown> | undefined;
@@ -404,7 +427,7 @@ export declare const createCombineMessageSchema: z.ZodType<{
404
427
  conversationId: z.ZodString;
405
428
  conversationType: z.ZodEnum<["singleChat", "groupChat", "chatRoom"]>;
406
429
  timestamp: z.ZodNumber;
407
- body: z.ZodRecord<z.ZodString, z.ZodUnknown>;
430
+ body: z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">]>;
408
431
  combineLevel: z.ZodOptional<z.ZodNumber>;
409
432
  }, z.ZodTypeAny, "passthrough">[];
410
433
  ext?: Record<string, unknown> | undefined;