easemob-websdk 4.24.1 → 5.0.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 (324) hide show
  1. package/README.md +95 -39
  2. package/bundle/im-sdk-web.iife.js +1 -0
  3. package/cache/cache-crypto.d.ts +26 -0
  4. package/cache/cache-eviction.d.ts +16 -0
  5. package/cache/cache-keys.d.ts +23 -0
  6. package/cache/cache-manager.d.ts +254 -0
  7. package/cache/cache-metadata.d.ts +14 -0
  8. package/cache/cache-store.d.ts +19 -0
  9. package/cache/cache-types.d.ts +225 -0
  10. package/cache/cache-utils.d.ts +7 -0
  11. package/cache/contact-cache.d.ts +35 -0
  12. package/cache/conversation-cache.d.ts +21 -0
  13. package/cache/group-namecard-cache.d.ts +20 -0
  14. package/cache/index.d.ts +24 -0
  15. package/cache/joined-group-preview-cache.d.ts +12 -0
  16. package/cache/session-list-cache.d.ts +10 -0
  17. package/cache/user-info-cache.d.ts +16 -0
  18. package/chat-client.d.ts +558 -0
  19. package/chunks/cache-utils-BwRPIZ7n.js +1 -0
  20. package/chunks/cache-utils-CKbcYPlM.cjs +1 -0
  21. package/chunks/chat-manager-ChdK26ck.cjs +1 -0
  22. package/chunks/chat-manager-DH8a6Qj9.js +2 -0
  23. package/chunks/common-CfAlncj9.cjs +1 -0
  24. package/chunks/common-DN_g4O3n.js +1 -0
  25. package/chunks/event-system-COBJFEIq.cjs +1 -0
  26. package/chunks/event-system-D6IJA0C4.js +1 -0
  27. package/chunks/group-user-info-resolver-C5pdiqox.cjs +1 -0
  28. package/chunks/group-user-info-resolver-FNRqDg18.js +1 -0
  29. package/chunks/index-BKg4EGcI.cjs +1 -0
  30. package/chunks/index-CK3GHdGU.cjs +1 -0
  31. package/chunks/index-CjofwvEQ.js +1 -0
  32. package/chunks/index-uKWbjx-u.js +1 -0
  33. package/chunks/profile-version-DLMz8lqW.js +1 -0
  34. package/chunks/profile-version-njNs7R5-.cjs +1 -0
  35. package/chunks/reflection-proto-codec-64ocOTHU.js +1 -0
  36. package/chunks/reflection-proto-codec-BnQFQdZC.cjs +1 -0
  37. package/chunks/session-list-query-B6dh-b4Y.cjs +1 -0
  38. package/chunks/session-list-query-Dnp2HbpW.js +1 -0
  39. package/chunks/user-info-BfRwS4ZA.js +1 -0
  40. package/chunks/user-info-icpL0Eaw.cjs +1 -0
  41. package/config/cache.d.ts +12 -0
  42. package/config/timeouts.d.ts +34 -0
  43. package/core/connection/connection-manager.d.ts +228 -0
  44. package/core/connection/connection-retry.d.ts +47 -0
  45. package/core/connection/heartbeat.d.ts +68 -0
  46. package/core/contact-sync/contact-roster-event-sidecar.d.ts +3 -0
  47. package/core/contact-sync/roster-sync-client.d.ts +21 -0
  48. package/core/contact-sync/roster-sync-controller.d.ts +20 -0
  49. package/core/contact-sync/roster-sync-session.d.ts +28 -0
  50. package/core/contact-sync/roster-sync-types.d.ts +74 -0
  51. package/core/events/event-hub.d.ts +13 -0
  52. package/core/group-sync/group-sync-client.d.ts +19 -0
  53. package/core/group-sync/group-sync-controller.d.ts +11 -0
  54. package/core/group-sync/group-sync-merge.d.ts +3 -0
  55. package/core/group-sync/group-sync-normalizer.d.ts +4 -0
  56. package/core/group-sync/group-sync-session.d.ts +17 -0
  57. package/core/group-sync/group-sync-types.d.ts +24 -0
  58. package/core/group-sync/index.d.ts +4 -0
  59. package/core/index.d.ts +95 -0
  60. package/core/message/attachment-downloader.d.ts +7 -0
  61. package/core/message/chatroom-operation-types.d.ts +6 -0
  62. package/core/message/combine-message-downloader.d.ts +7 -0
  63. package/core/message/message-action-types.d.ts +22 -0
  64. package/core/message/message-deduplicator.d.ts +11 -0
  65. package/core/message/message-receiver.d.ts +65 -0
  66. package/core/message/message-retry.d.ts +33 -0
  67. package/core/message/message-sender.d.ts +63 -0
  68. package/core/message/profile-sync/group-namecard-hydration-queue.d.ts +33 -0
  69. package/core/message/profile-sync/group-namecard-hydrator.d.ts +8 -0
  70. package/core/message/profile-sync/latest-message-version-projector.d.ts +3 -0
  71. package/core/message/profile-sync/profile-version-sidecar.d.ts +9 -0
  72. package/core/message/profile-sync/profile-version.d.ts +3 -0
  73. package/core/message/profile-sync/user-info-hydration-queue.d.ts +29 -0
  74. package/core/message/profile-sync/user-info-hydrator.d.ts +8 -0
  75. package/core/message/stream-message-cache.d.ts +38 -0
  76. package/core/message/stream-message-handler.d.ts +22 -0
  77. package/core/session-list-sync/session-list-query.d.ts +26 -0
  78. package/core/session-list-sync/session-list-sync-controller.d.ts +17 -0
  79. package/core/session-list-sync/session-list-sync-merge.d.ts +17 -0
  80. package/core/session-list-sync/session-list-sync-normalizer.d.ts +6 -0
  81. package/core/session-list-sync/session-list-sync-runner.d.ts +13 -0
  82. package/core/session-list-sync/session-list-sync-session.d.ts +26 -0
  83. package/core/session-list-sync/session-list-sync-types.d.ts +24 -0
  84. package/core/sync/shared-sync-websocket-session.d.ts +61 -0
  85. package/core/user-info/group-user-info-resolver.d.ts +40 -0
  86. package/data-report/bridge.d.ts +11 -0
  87. package/data-report/constants.d.ts +25 -0
  88. package/data-report/data-reporter.d.ts +21 -0
  89. package/data-report/event-queue.d.ts +38 -0
  90. package/data-report/index.d.ts +3 -0
  91. package/data-report/network-type.d.ts +1 -0
  92. package/data-report/operation-map.d.ts +8 -0
  93. package/data-report/transport.d.ts +17 -0
  94. package/data-report/types.d.ts +61 -0
  95. package/index.cjs +1 -0
  96. package/index.d.ts +134 -0
  97. package/index.js +3 -0
  98. package/managers/chat/index.cjs +1 -0
  99. package/managers/chat/index.d.ts +1 -0
  100. package/managers/chat/index.js +1 -0
  101. package/managers/chat-manager.d.ts +880 -0
  102. package/managers/chat-thread/chat-thread.d.ts +126 -0
  103. package/managers/chat-thread/index.cjs +1 -0
  104. package/managers/chat-thread/index.d.ts +2 -0
  105. package/managers/chat-thread/index.js +1 -0
  106. package/managers/chat-thread-manager.d.ts +257 -0
  107. package/managers/chatroom/chatroom-event-mapper.d.ts +17 -0
  108. package/managers/chatroom/chatroom-event-user-info-resolver.d.ts +15 -0
  109. package/managers/chatroom/chatroom-normalizers.d.ts +23 -0
  110. package/managers/chatroom/chatroom.d.ts +403 -0
  111. package/managers/chatroom/index.cjs +1 -0
  112. package/managers/chatroom/index.d.ts +2 -0
  113. package/managers/chatroom/index.js +1 -0
  114. package/managers/chatroom-manager.d.ts +604 -0
  115. package/managers/contact/contact-user-info-resolver.d.ts +15 -0
  116. package/managers/contact/index.cjs +1 -0
  117. package/managers/contact/index.d.ts +1 -0
  118. package/managers/contact/index.js +1 -0
  119. package/managers/contact-manager.d.ts +215 -0
  120. package/managers/group/group-event-mapper.d.ts +18 -0
  121. package/managers/group/group-event-user-info-resolver.d.ts +15 -0
  122. package/managers/group/group-normalizers.d.ts +15 -0
  123. package/managers/group/group.d.ts +504 -0
  124. package/managers/group/index.cjs +1 -0
  125. package/managers/group/index.d.ts +2 -0
  126. package/managers/group/index.js +1 -0
  127. package/managers/group/internal/group-event-sync.d.ts +13 -0
  128. package/managers/group/internal/group-repository.d.ts +31 -0
  129. package/managers/group/internal/group-snapshot-mapper.d.ts +6 -0
  130. package/managers/group/internal/internal-group.d.ts +24 -0
  131. package/managers/group-manager.d.ts +371 -0
  132. package/managers/presence/index.cjs +1 -0
  133. package/managers/presence/index.d.ts +1 -0
  134. package/managers/presence/index.js +1 -0
  135. package/managers/presence-manager.d.ts +201 -0
  136. package/managers/push/index.cjs +1 -0
  137. package/managers/push/index.d.ts +1 -0
  138. package/managers/push/index.js +1 -0
  139. package/managers/push-manager.d.ts +205 -0
  140. package/managers/user-info/index.cjs +1 -0
  141. package/managers/user-info/index.d.ts +4 -0
  142. package/managers/user-info/index.js +1 -0
  143. package/managers/user-info/user-info-notify-normalizer.d.ts +2 -0
  144. package/managers/user-info/user-info-runtime-store.d.ts +28 -0
  145. package/managers/user-info-manager.d.ts +196 -0
  146. package/message/combine-compatible-text-sidecar.d.ts +4 -0
  147. package/message/combine-message-constraints.d.ts +7 -0
  148. package/message/combine-payload-codec.d.ts +17 -0
  149. package/message/create-message.d.ts +64 -0
  150. package/package.json +64 -16
  151. package/platform/capability-validator.d.ts +7 -0
  152. package/platform/env.d.ts +68 -0
  153. package/platform/factory.d.ts +7 -0
  154. package/platform/image/miniapp-image-processor.d.ts +45 -0
  155. package/platform/image/web-image-processor.d.ts +2 -0
  156. package/platform/index.d.ts +17 -0
  157. package/platform/miniapp/miniapp-adapter.d.ts +3 -0
  158. package/platform/proto/proto-adapter.d.ts +17 -0
  159. package/platform/proto/reflection-proto-codec.d.ts +8 -0
  160. package/platform/proto/static-proto-adapter.d.ts +8 -0
  161. package/platform/request/web-request-adapter.d.ts +9 -0
  162. package/platform/runtime/connection-event-normalizer.d.ts +14 -0
  163. package/platform/runtime/runtime-event-bridge.d.ts +23 -0
  164. package/platform/runtime/web-runtime-adapter.d.ts +26 -0
  165. package/platform/socket/web-socket-adapter.d.ts +8 -0
  166. package/platform/types.d.ts +472 -0
  167. package/platform/upload/react-native-upload-adapter.d.ts +14 -0
  168. package/platform/upload/upload-error-mapper.d.ts +7 -0
  169. package/platform/upload/upload-source.d.ts +20 -0
  170. package/platform/upload/web-upload-adapter.d.ts +10 -0
  171. package/protocol/joined-groups/codec.d.ts +11 -0
  172. package/protocol/joined-groups/gateway.d.ts +2 -0
  173. package/protocol/joined-groups/index.d.ts +2 -0
  174. package/protocol/joined-groups/proto.d.ts +174 -0
  175. package/protocol/joined-groups/types.d.ts +65 -0
  176. package/protocol/msync/codec.d.ts +191 -0
  177. package/protocol/msync/context.d.ts +40 -0
  178. package/protocol/msync/lz4-compressor/index.d.ts +40 -0
  179. package/protocol/msync/lz4-compressor/utils.d.ts +27 -0
  180. package/protocol/msync/multi-device-normalizer.d.ts +75 -0
  181. package/protocol/msync/proto.d.ts +1306 -0
  182. package/protocol/msync/root.d.ts +5 -0
  183. package/protocol/msync/types.d.ts +96 -0
  184. package/protocol/msync/utils.d.ts +26 -0
  185. package/protocol/protobuf/decoder.d.ts +44 -0
  186. package/protocol/protobuf/encoder.d.ts +23 -0
  187. package/protocol/protobuf/types.d.ts +53 -0
  188. package/protocol/roster/codec.d.ts +9 -0
  189. package/protocol/roster/proto.d.ts +205 -0
  190. package/protocol/roster/root.d.ts +5 -0
  191. package/protocol/roster/types.d.ts +83 -0
  192. package/protocol/session-list/codec.d.ts +11 -0
  193. package/protocol/session-list/gateway.d.ts +19 -0
  194. package/protocol/session-list/payload-decoder.d.ts +1 -0
  195. package/protocol/session-list/proto.d.ts +207 -0
  196. package/protocol/session-list/types.d.ts +83 -0
  197. package/rest/chat-management.d.ts +26 -0
  198. package/rest/chat-thread-management.d.ts +14 -0
  199. package/rest/chatroom-management.d.ts +40 -0
  200. package/rest/client.d.ts +86 -0
  201. package/rest/contact-management.d.ts +27 -0
  202. package/rest/contact-metadata.d.ts +11 -0
  203. package/rest/conversation-management.d.ts +11 -0
  204. package/rest/dns-config.d.ts +20 -0
  205. package/rest/error-map-types.d.ts +32 -0
  206. package/rest/error-maps/chat.d.ts +888 -0
  207. package/rest/error-maps/chatroom.d.ts +592 -0
  208. package/rest/error-maps/common.d.ts +208 -0
  209. package/rest/error-maps/contact.d.ts +185 -0
  210. package/rest/error-maps/core.d.ts +21 -0
  211. package/rest/error-maps/group.d.ts +500 -0
  212. package/rest/error-maps/index.d.ts +9 -0
  213. package/rest/error-maps/presence.d.ts +62 -0
  214. package/rest/error-maps/push.d.ts +158 -0
  215. package/rest/error-maps/thread.d.ts +538 -0
  216. package/rest/error-maps/user-info.d.ts +289 -0
  217. package/rest/errors.d.ts +23 -0
  218. package/rest/group-management.d.ts +55 -0
  219. package/rest/rtc-token.d.ts +14 -0
  220. package/rest/speech-helpers.d.ts +24 -0
  221. package/rest/user-info-subscription.d.ts +10 -0
  222. package/rest/user-info.d.ts +34 -0
  223. package/types/chat-client.d.ts +226 -0
  224. package/types/chat-manager.d.ts +641 -0
  225. package/types/chat-thread.d.ts +311 -0
  226. package/types/chatroom.d.ts +1258 -0
  227. package/types/connection.d.ts +111 -0
  228. package/types/contact.d.ts +149 -0
  229. package/types/conversation.d.ts +270 -0
  230. package/types/event-system.d.ts +721 -0
  231. package/types/group.d.ts +980 -0
  232. package/types/index.d.ts +577 -44
  233. package/types/manager.d.ts +99 -0
  234. package/types/message-conversation.d.ts +22 -0
  235. package/types/message-create.d.ts +173 -0
  236. package/types/multi-device.d.ts +275 -0
  237. package/types/presence.d.ts +101 -0
  238. package/types/push.d.ts +296 -0
  239. package/types/sender.d.ts +12 -0
  240. package/types/sync-data.d.ts +54 -0
  241. package/types/user-info.d.ts +178 -0
  242. package/upload/attachment-file-store.d.ts +11 -0
  243. package/upload/attachment-uploader.d.ts +36 -0
  244. package/upload/constants.d.ts +8 -0
  245. package/upload/index.d.ts +2 -0
  246. package/upload/multipart-upload.d.ts +14 -0
  247. package/upload/simple-upload.d.ts +3 -0
  248. package/upload/types.d.ts +79 -0
  249. package/upload/utils.d.ts +71 -0
  250. package/utils/env.d.ts +4 -0
  251. package/utils/error-codes.d.ts +2 -0
  252. package/utils/error-codes.generated.d.ts +145 -0
  253. package/utils/error-sanitizer.d.ts +8 -0
  254. package/utils/errors.d.ts +139 -0
  255. package/utils/log-reporter.d.ts +61 -0
  256. package/utils/log-sanitizer.d.ts +6 -0
  257. package/utils/logger.d.ts +48 -0
  258. package/utils/md5.d.ts +1 -0
  259. package/utils/message-id.d.ts +12 -0
  260. package/utils/provision-error-mapping.d.ts +21 -0
  261. package/utils/retry.d.ts +26 -0
  262. package/utils/runtime-global.d.ts +4 -0
  263. package/utils/trace-id.d.ts +5 -0
  264. package/utils/utf8.d.ts +2 -0
  265. package/validators/chat-client.d.ts +787 -0
  266. package/validators/message-create.d.ts +419 -0
  267. package/validators/search-messages.d.ts +127 -0
  268. package/validators/validator.d.ts +49 -0
  269. package/version.d.ts +2 -0
  270. package/Easemob-chat.d.ts +0 -8457
  271. package/Easemob-chat.js +0 -2
  272. package/chatroom/chatroom.d.ts +0 -649
  273. package/chatroom/chatroom.js +0 -1
  274. package/contact/contact.d.ts +0 -726
  275. package/contact/contact.js +0 -1
  276. package/group/group.d.ts +0 -848
  277. package/group/group.js +0 -1
  278. package/localCache/localCache.d.ts +0 -59
  279. package/localCache/localCache.js +0 -1
  280. package/message/audio.d.ts +0 -183
  281. package/message/channel.d.ts +0 -82
  282. package/message/cmd.d.ts +0 -146
  283. package/message/combine.d.ts +0 -132
  284. package/message/custom.d.ts +0 -135
  285. package/message/delivery.d.ts +0 -77
  286. package/message/file.d.ts +0 -173
  287. package/message/img.d.ts +0 -200
  288. package/message/index.d.ts +0 -211
  289. package/message/location.d.ts +0 -134
  290. package/message/read.d.ts +0 -85
  291. package/message/text.d.ts +0 -149
  292. package/message/video.d.ts +0 -180
  293. package/miniCore/miniCore.d.ts +0 -217
  294. package/miniCore/miniCore.js +0 -2
  295. package/miniProgram/Easemob-chat.js +0 -2
  296. package/miniProgram/miniProgram.zip +0 -0
  297. package/presence/presence.d.ts +0 -69
  298. package/presence/presence.js +0 -1
  299. package/silent/silent.d.ts +0 -128
  300. package/silent/silent.js +0 -1
  301. package/status.d.ts +0 -184
  302. package/thread/thread.d.ts +0 -159
  303. package/thread/thread.js +0 -1
  304. package/translation/translation.d.ts +0 -30
  305. package/translation/translation.js +0 -1
  306. package/types/chatRoomApi.d.ts +0 -226
  307. package/types/common.d.ts +0 -89
  308. package/types/engineCore.d.ts +0 -194
  309. package/types/error.d.ts +0 -13
  310. package/types/eventHandler.d.ts +0 -437
  311. package/types/groupApi.d.ts +0 -306
  312. package/types/indexApi.d.ts +0 -366
  313. package/types/localCache.d.ts +0 -53
  314. package/types/message.d.ts +0 -959
  315. package/types/presenceApi.d.ts +0 -61
  316. package/types/reactionApi.d.ts +0 -74
  317. package/types/restApis.d.ts +0 -6
  318. package/types/silentModeApi.d.ts +0 -109
  319. package/types/threadApi.d.ts +0 -175
  320. package/types/translation.d.ts +0 -25
  321. package/types/utils.d.ts +0 -90
  322. package/uniApp/Easemob-chat.js +0 -2
  323. package/uniApp/uniApp.zip +0 -0
  324. package/websdk.zip +0 -0
@@ -0,0 +1,79 @@
1
+ import type { ChatConversationType, FileUploadProgress, FileUploadResult, ImageType, Message, MessageType, SendMessageOptions, CombineMessageBody, FileMessageBody, ImageMessageBody, VideoMessageBody, VoiceMessageBody } from '../types';
2
+ import type { ImageProcessor, NormalizedUploadSource, RequestAdapter } from '../platform';
3
+ import type { DataReportOperationHandle } from '../data-report/types';
4
+ export type AttachmentMessageType = Extract<MessageType, 'image' | 'video' | 'voice' | 'file' | 'combine'>;
5
+ export type ImagePolicyReason = 'explicit-original' | 'default-large' | 'gif-force-origin' | 'large-fallback-origin';
6
+ export type ImageCandidateSourceKind = 'origin' | 'big';
7
+ export type AttachmentPrecheckThresholdType = 'image-origin' | 'image-big' | 'attachment';
8
+ export type AttachmentMessageBody = ImageMessageBody | VideoMessageBody | VoiceMessageBody | FileMessageBody | CombineMessageBody;
9
+ export interface UploadConfig {
10
+ restBaseUrl: string;
11
+ token: string;
12
+ appKey: string;
13
+ useCustomAttachmentUpload?: boolean;
14
+ enableMd5Check?: boolean;
15
+ enableMultipartUpload?: boolean;
16
+ requestAdapter?: RequestAdapter;
17
+ imageProcessor?: ImageProcessor;
18
+ }
19
+ export interface UploadRequest {
20
+ message: Message;
21
+ file: Blob;
22
+ conversationId: string;
23
+ conversationType: ChatConversationType;
24
+ messageType: AttachmentMessageType;
25
+ imageType?: ImageType;
26
+ md5?: string;
27
+ width?: number;
28
+ height?: number;
29
+ fileName: string;
30
+ fileType: string;
31
+ fileSize: number;
32
+ thumbnailWidth?: number;
33
+ thumbnailHeight?: number;
34
+ callbacks?: SendMessageOptions;
35
+ config: UploadConfig;
36
+ dataReportOperation?: DataReportOperationHandle;
37
+ }
38
+ export interface UploadResponseEntity {
39
+ uuid?: string;
40
+ uri?: string;
41
+ exists?: boolean;
42
+ type?: string;
43
+ ['exists-type']?: 'origin' | 'large';
44
+ ['share-secret']?: string;
45
+ ['file-metadata']?: Record<string, unknown>;
46
+ }
47
+ export interface UploadResponsePayload {
48
+ entities?: UploadResponseEntity[];
49
+ uri?: string;
50
+ }
51
+ export interface ImageSendPolicy {
52
+ readonly resolvedImageType: ImageType;
53
+ readonly reason: ImagePolicyReason;
54
+ }
55
+ export interface ResolvedImageCandidate {
56
+ readonly imagePolicy: ImageSendPolicy;
57
+ readonly sourceKind: ImageCandidateSourceKind;
58
+ readonly fileInfo: NormalizedUploadSource;
59
+ readonly width: number;
60
+ readonly height: number;
61
+ readonly localUrl?: string;
62
+ readonly md5?: string;
63
+ }
64
+ export interface AttachmentPrecheckDecision {
65
+ readonly shouldPrecheck: boolean;
66
+ readonly thresholdType: AttachmentPrecheckThresholdType;
67
+ readonly thresholdBytes: number;
68
+ readonly actualBytes: number;
69
+ readonly reason: 'below-threshold' | 'threshold-exceeded';
70
+ }
71
+ export interface AttachmentPrecheckResult {
72
+ readonly uuid?: string;
73
+ readonly exists: boolean;
74
+ readonly existsType?: ImageType;
75
+ readonly shareSecret?: string;
76
+ readonly hit: boolean;
77
+ }
78
+ export type UploadProgressEvent = FileUploadProgress;
79
+ export type UploadResult = FileUploadResult;
@@ -0,0 +1,71 @@
1
+ import { type NormalizedUploadSource } from '../platform/upload/upload-source';
2
+ import type { CompatibleFile, ImageMessageBody, ImageType } from '../types';
3
+ import type { AttachmentMessageBody, AttachmentMessageType, AttachmentPrecheckDecision, AttachmentPrecheckResult, AttachmentPrecheckThresholdType, ImageSendPolicy, UploadResponsePayload } from './types';
4
+ export type ProtocolImageType = 1 | 2;
5
+ export declare const IMAGE_TYPE_ORIGINAL: ImageType;
6
+ export declare const IMAGE_TYPE_LARGE: ImageType;
7
+ export declare const PROTOCOL_IMAGE_TYPE_ORIGINAL: ProtocolImageType;
8
+ export declare const PROTOCOL_IMAGE_TYPE_LARGE: ProtocolImageType;
9
+ export declare const IMAGE_PRECHECK_ORIGINAL_THRESHOLD: number;
10
+ export declare const ATTACHMENT_PRECHECK_THRESHOLD: number;
11
+ export declare const isRemoteUrl: (url: string) => boolean;
12
+ export declare const isLocalUrl: (url: string) => boolean;
13
+ export declare const shouldUploadByUrl: (url: string | undefined, hasData: boolean) => boolean;
14
+ export declare const parseAppKey: (appKey: string) => {
15
+ orgName: string;
16
+ appName: string;
17
+ };
18
+ export declare const toUploadChatType: (conversationType: string) => string;
19
+ export declare const appendUrlQueryParams: (url: string, params: Record<string, string | number | undefined>) => string;
20
+ export declare const appendAttachUrlParams: (url: string, secret?: string) => string;
21
+ export declare const resolveImageSendPolicy: (body: ImageMessageBody) => ImageSendPolicy;
22
+ export declare const resolvePrecheckThresholdType: (messageType: AttachmentMessageType, imageType?: ImageType) => AttachmentPrecheckThresholdType;
23
+ export declare const resolvePrecheckThresholdBytes: (thresholdType: AttachmentPrecheckThresholdType) => number;
24
+ export declare const buildAttachmentPrecheckDecision: (options: {
25
+ messageType: AttachmentMessageType;
26
+ fileSize: number;
27
+ imageType?: ImageType;
28
+ }) => AttachmentPrecheckDecision;
29
+ export declare const isAttachmentPrecheckHit: (result: {
30
+ exists: boolean;
31
+ uuid?: string;
32
+ shareSecret?: string;
33
+ }) => boolean;
34
+ export declare const parseAttachmentPrecheckResult: (payload: UploadResponsePayload) => AttachmentPrecheckResult;
35
+ export declare const deriveImageUrls: (remotePath: string, options?: {
36
+ deriveVariants?: boolean;
37
+ }) => {
38
+ originalImageUrl?: string;
39
+ bigImageUrl?: string;
40
+ thumbnailUrl?: string;
41
+ };
42
+ export declare const toUploadImageType: (imageType: ImageType | undefined) => "origin" | "large";
43
+ export declare const toProtocolImageType: (imageType: ImageType | undefined) => ProtocolImageType;
44
+ export declare const fromProtocolImageType: (imageType: unknown) => ImageType;
45
+ export declare const buildUploadResult: (options: {
46
+ response: UploadResponsePayload;
47
+ restBaseUrl: string;
48
+ orgName: string;
49
+ appName: string;
50
+ fileType: string;
51
+ fileName: string;
52
+ fallbackSize: number;
53
+ messageType: AttachmentMessageType;
54
+ imageType?: ImageType;
55
+ width?: number;
56
+ height?: number;
57
+ useCustomAttachmentUpload?: boolean;
58
+ }) => {
59
+ url?: string;
60
+ isOriginalImage?: boolean;
61
+ originalImageUrl?: string;
62
+ bigImageUrl?: string;
63
+ secret?: string;
64
+ fileLength?: number;
65
+ filetype?: string;
66
+ filename?: string;
67
+ thumbnailUrl?: string;
68
+ width?: number;
69
+ height?: number;
70
+ };
71
+ export declare const normalizeAttachmentFile: (file: CompatibleFile | undefined, body: AttachmentMessageBody) => NormalizedUploadSource;
package/utils/env.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 运行时环境判断
3
+ */
4
+ export declare const isUniAppRuntime: () => boolean;
@@ -0,0 +1,2 @@
1
+ export { ERROR_CODES } from './error-codes.generated';
2
+ export type { ErrorCode } from './error-codes.generated';
@@ -0,0 +1,145 @@
1
+ export declare const ERROR_CODES: {
2
+ readonly VALIDATION_REQUIRED: number;
3
+ readonly VALIDATION_INVALID_FORMAT: number;
4
+ readonly VALIDATION_UNKNOWN: number;
5
+ readonly AUTH_ALREADY_LOGIN: number;
6
+ readonly AUTH_NOT_LOGIN: number;
7
+ readonly AUTH_UNAUTHORIZED: number;
8
+ readonly AUTH_FORBIDDEN: number;
9
+ readonly AUTH_TOKEN_EXPIRED: number;
10
+ readonly AUTH_BIND_ANOTHER_DEVICE: number;
11
+ readonly AUTH_LOGIN_TOO_MANY_DEVICES: number;
12
+ readonly AUTH_USER_MUTED: number;
13
+ readonly CONNECTION_TIMEOUT: number;
14
+ readonly CONNECTION_WEBSOCKET_ERROR: number;
15
+ readonly CONNECTION_NOT_CREATED: number;
16
+ readonly CONNECTION_CLOSED_BEFORE_READY: number;
17
+ readonly CONNECTION_CANCELLED: number;
18
+ readonly CONNECTION_PROVISION_TIMEOUT: number;
19
+ readonly CONNECTION_PROVISION_REJECTED: number;
20
+ readonly CONNECTION_PROVISION_CLOSED: number;
21
+ readonly CONNECTION_DNSLIST_FAILED: number;
22
+ readonly STORAGE_OPERATION_FAILED: number;
23
+ readonly MESSAGE_NOT_CONNECTED: number;
24
+ readonly MESSAGE_ACK_TIMEOUT: number;
25
+ readonly MESSAGE_SEND_FAILED: number;
26
+ readonly MESSAGE_SENDER_DESTROYED: number;
27
+ readonly MESSAGE_ENCODE_FAILED: number;
28
+ readonly MESSAGE_DECODE_FAILED: number;
29
+ readonly MESSAGE_ACK_MISSING: number;
30
+ readonly MESSAGE_BLOCKED_BY_RECIPIENT: number;
31
+ readonly OPERATION_UNSUPPORTED: number;
32
+ readonly SERVER_BUSY: number;
33
+ readonly ATTACHMENT_NOT_FOUND: number;
34
+ readonly ATTACHMENT_INVALID: number;
35
+ readonly ATTACHMENT_EXPIRED: number;
36
+ readonly MESSAGE_INCLUDE_ILLEGAL_CONTENT: number;
37
+ readonly MESSAGE_SEND_TRAFFIC_LIMIT: number;
38
+ readonly MESSAGE_RECALL_TIME_LIMIT: number;
39
+ readonly SERVICE_NOT_ENABLED: number;
40
+ readonly MESSAGE_EXPIRED: number;
41
+ readonly MESSAGE_ILLEGAL_WHITELIST: number;
42
+ readonly MESSAGE_EXTERNAL_LOGIC_BLOCKED: number;
43
+ readonly MESSAGE_CURRENT_LIMITING: number;
44
+ readonly MESSAGE_SIZE_LIMIT: number;
45
+ readonly MESSAGE_EDIT_FAILED: number;
46
+ readonly INVALID_CONVERSATION: number;
47
+ readonly USER_LOGIN_ANOTHER_DEVICE: number;
48
+ readonly USER_REMOVED: number;
49
+ readonly USER_KICKED_BY_CHANGE_PASSWORD: number;
50
+ readonly USER_KICKED_BY_OTHER_DEVICE: number;
51
+ readonly USER_ALREADY_LOGIN_ANOTHER: number;
52
+ readonly USER_MUTED_BY_ADMIN: number;
53
+ readonly USER_DEVICE_CHANGED: number;
54
+ readonly USER_NOT_ON_ROSTER: number;
55
+ readonly SERVER_SERVING_DISABLED: number;
56
+ readonly FILE_DOWNLOAD_FAILED: number;
57
+ readonly FILE_TOO_LARGE: number;
58
+ readonly FILE_CONTENT_IMPROPER: number;
59
+ readonly THIRD_MODERATION_FAILED: number;
60
+ readonly THIRD_DEFAULT_FAILED: number;
61
+ readonly STREAM_SEND_NOT_SUPPORTED: number;
62
+ readonly STREAM_CHUNK_INVALID: number;
63
+ readonly STREAM_TIMEOUT_BY_SERVER: number;
64
+ readonly STREAM_STATE_CONFLICT: number;
65
+ readonly COMBINE_INVALID_INPUT: number;
66
+ readonly COMBINE_LEVEL_EXCEEDED: number;
67
+ readonly COMBINE_ITEM_LIMIT_EXCEEDED: number;
68
+ readonly COMBINE_ENCODE_FAILED: number;
69
+ readonly COMBINE_UPLOAD_FAILED: number;
70
+ readonly COMBINE_DOWNLOAD_FAILED: number;
71
+ readonly COMBINE_PARSE_FAILED: number;
72
+ readonly REST_NETWORK_ERROR: number;
73
+ readonly REST_TIMEOUT: number;
74
+ readonly REST_HTTP_ERROR: number;
75
+ readonly REST_BUSINESS_UNKNOWN: number;
76
+ readonly PUSH_TOKEN_UPLOAD_FAILED: number;
77
+ readonly PUSH_SILENT_MODE_OPERATION_FAILED: number;
78
+ readonly PUSH_LANGUAGE_OPERATION_FAILED: number;
79
+ readonly USER_INFO_SUBSCRIPTION_LIMIT_EXCEEDED: number;
80
+ readonly USER_INFO_SUBSCRIPTION_TARGET_LIMIT_EXCEEDED: number;
81
+ readonly USERINFO_USERCOUNT_EXCEED: number;
82
+ readonly USERINFO_DATALENGTH_EXCEED: number;
83
+ readonly CONTACT_ADD_USER_NOT_FOUND: number;
84
+ readonly CONTACT_ADD_ALREADY_FRIEND: number;
85
+ readonly CONTACT_ADD_BLOCKED_BY_USER: number;
86
+ readonly CONTACT_SET_REMARK_NOT_FRIEND: number;
87
+ readonly CONTACT_REACH_LIMIT: number;
88
+ readonly CONTACT_REACH_LIMIT_PEER: number;
89
+ readonly CONTACT_BLOCKLIST_USER_NOT_FOUND: number;
90
+ readonly GROUP_INVALID_ID: number;
91
+ readonly GROUP_ALREADY_JOINED: number;
92
+ readonly GROUP_NOT_JOINED: number;
93
+ readonly GROUP_PERMISSION_DENIED: number;
94
+ readonly GROUP_MEMBERS_FULL: number;
95
+ readonly GROUP_SHARED_FILE_INVALID_ID: number;
96
+ readonly GROUP_NOT_EXIST: number;
97
+ readonly GROUP_DISABLED: number;
98
+ readonly GROUP_NAME_VIOLATION: number;
99
+ readonly GROUP_MEMBER_ATTRIBUTES_REACH_LIMIT: number;
100
+ readonly GROUP_MEMBER_ATTRIBUTES_UPDATE_FAILED: number;
101
+ readonly GROUP_MEMBER_ATTRIBUTES_KEY_REACH_LIMIT: number;
102
+ readonly GROUP_MEMBER_ATTRIBUTES_VALUE_REACH_LIMIT: number;
103
+ readonly GROUP_USER_IN_BLOCKLIST: number;
104
+ readonly CHATROOM_INVALID_ID: number;
105
+ readonly CHATROOM_NOT_JOINED: number;
106
+ readonly CHATROOM_PERMISSION_DENIED: number;
107
+ readonly CHATROOM_MEMBERS_FULL: number;
108
+ readonly CHATROOM_NOT_EXIST: number;
109
+ readonly CHATROOM_OWNER_NOT_ALLOW_LEAVE: number;
110
+ readonly CHATROOM_USER_IN_BLOCKLIST: number;
111
+ readonly CONTACT_SYNC_METADATA_FAILED: number;
112
+ readonly CONTACT_SYNC_SOCKET_FAILED: number;
113
+ readonly CONTACT_SYNC_CURSOR_INVALID: number;
114
+ readonly CONTACT_SYNC_PROTO_DECODE_FAILED: number;
115
+ readonly CONTACT_SYNC_CANCELLED: number;
116
+ readonly SESSION_LIST_SOCKET_FAILED: number;
117
+ readonly SESSION_LIST_PROTO_DECODE_FAILED: number;
118
+ readonly SESSION_LIST_REQUEST_INVALID: number;
119
+ readonly SESSION_LIST_FETCH_FAILED: number;
120
+ readonly SESSION_LIST_SERVICE_DISABLED: number;
121
+ readonly SESSION_LIST_CANCELLED: number;
122
+ readonly PRESENCE_PARAM_LENGTH_EXCEED: number;
123
+ readonly PRESENCE_CANNOT_SUBSCRIBE_YOURSELF: number;
124
+ readonly TRANSLATE_PARAM_INVALID: number;
125
+ readonly TRANSLATE_SERVICE_NOT_ENABLED: number;
126
+ readonly TRANSLATE_USAGE_LIMIT: number;
127
+ readonly TRANSLATE_FAILED: number;
128
+ readonly VOICE_TO_TEXT_FILE_INVALID: number;
129
+ readonly VOICE_TO_TEXT_FILE_DURATION_TOO_LONG: number;
130
+ readonly VOICE_TO_TEXT_FAILED: number;
131
+ readonly VOICE_TO_TEXT_FILE_NOT_FOUND: number;
132
+ readonly VOICE_TO_TEXT_FILE_TOO_LARGE: number;
133
+ readonly REACTION_REACH_LIMIT: number;
134
+ readonly REACTION_ALREADY_OPERATED: number;
135
+ readonly REACTION_OPERATION_ILLEGAL: number;
136
+ readonly UPLOAD_REQUIRED_FIELD_MISSING: number;
137
+ readonly UPLOAD_INVALID_APPKEY: number;
138
+ readonly UPLOAD_SIZE_EXCEEDED: number;
139
+ readonly UPLOAD_REQUEST_FAILED: number;
140
+ readonly UPLOAD_TIMEOUT: number;
141
+ readonly UPLOAD_ABORTED: number;
142
+ readonly SERVICE_LIMIT_EXCEEDED: number;
143
+ readonly UNKNOWN: number;
144
+ };
145
+ export type ErrorCode = number;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 从公开错误详情中的 URL 删除凭据、查询参数值和 Fragment。
3
+ */
4
+ export declare const sanitizeErrorUrl: (url: string) => string;
5
+ /**
6
+ * 对错误详情中的 URL 字段执行统一脱敏。
7
+ */
8
+ export declare const sanitizeErrorDetails: (details: Record<string, unknown>) => Record<string, unknown>;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * 错误处理类
3
+ *
4
+ * 统一的错误类型和错误码定义
5
+ */
6
+ import { type ErrorCode } from './error-codes';
7
+ /**
8
+ * [zh-CN] SDK 错误附加详情。
9
+ *
10
+ * [en-US] Additional details attached to an SDK error.
11
+ */
12
+ export type ErrorDetails = Record<string, unknown>;
13
+ /**
14
+ * [zh-CN] SDK 错误上下文。
15
+ *
16
+ * [en-US] Context associated with an SDK error.
17
+ */
18
+ export interface ErrorContext {
19
+ /**
20
+ * [zh-CN] 用于诊断错误的结构化附加信息。
21
+ *
22
+ * [en-US] Structured additional information for diagnosing the error.
23
+ */
24
+ details?: ErrorDetails;
25
+ }
26
+ /**
27
+ * SDK 错误类
28
+ */
29
+ export declare class SDKError extends Error {
30
+ readonly code: ErrorCode;
31
+ readonly details?: ErrorDetails;
32
+ constructor(message: string, code?: ErrorCode, context?: ErrorContext);
33
+ /**
34
+ * 转换为 JSON
35
+ */
36
+ toJSON(): Record<string, unknown>;
37
+ }
38
+ /**
39
+ * 网络错误
40
+ */
41
+ export declare class NetworkError extends SDKError {
42
+ constructor(message: string, context?: ErrorContext & {
43
+ code?: ErrorCode;
44
+ });
45
+ }
46
+ /**
47
+ * 连接错误
48
+ */
49
+ export declare class ConnectionError extends SDKError {
50
+ constructor(message: string, context?: ErrorContext & {
51
+ code?: ErrorCode;
52
+ });
53
+ }
54
+ /**
55
+ * 认证错误
56
+ */
57
+ export declare class AuthenticationError extends SDKError {
58
+ constructor(message: string, context?: ErrorContext & {
59
+ code?: ErrorCode;
60
+ });
61
+ }
62
+ /**
63
+ * 验证错误
64
+ */
65
+ export declare class ValidationError extends SDKError {
66
+ constructor(message: string, context?: ErrorContext & {
67
+ code?: ErrorCode;
68
+ });
69
+ }
70
+ /**
71
+ * 消息发送错误
72
+ */
73
+ export declare class MessageSendError extends SDKError {
74
+ constructor(message: string, context?: ErrorContext & {
75
+ code?: ErrorCode;
76
+ });
77
+ }
78
+ /**
79
+ * 消息接收错误
80
+ */
81
+ export declare class MessageReceiveError extends SDKError {
82
+ constructor(message: string, context?: ErrorContext & {
83
+ code?: ErrorCode;
84
+ });
85
+ }
86
+ /**
87
+ * 存储错误
88
+ */
89
+ export declare class StorageError extends SDKError {
90
+ constructor(message: string, context?: ErrorContext & {
91
+ code?: ErrorCode;
92
+ });
93
+ }
94
+ export declare class RestTransportError extends SDKError {
95
+ constructor(message: string, context?: ErrorContext & {
96
+ code?: ErrorCode;
97
+ });
98
+ }
99
+ export declare class RestBusinessError extends SDKError {
100
+ constructor(message: string, context?: ErrorContext & {
101
+ code?: ErrorCode;
102
+ });
103
+ }
104
+ /**
105
+ * 上传错误
106
+ */
107
+ export declare class UploadError extends SDKError {
108
+ constructor(message: string, context?: ErrorContext & {
109
+ code?: ErrorCode;
110
+ });
111
+ }
112
+ /**
113
+ * [zh-CN] 判断未知值是否为 SDK 错误。
114
+ *
115
+ * 除当前模块创建的实例外,该方法也支持识别 iframe、微前端或重复安装的
116
+ * SDK 副本所创建的结构兼容错误。
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * try {
121
+ * await client.login({ userId: 'u1', token: 'token' });
122
+ * } catch (error: unknown) {
123
+ * if (isSDKError(error)) {
124
+ * console.error(error.toJSON());
125
+ * }
126
+ * }
127
+ * ```
128
+ *
129
+ * @param error [zh-CN] 需要判断的未知值。[en-US] The unknown value to inspect.
130
+ * @returns [zh-CN] 值为 SDK 错误时返回 `true`,并将类型收窄为 `SDKError`。
131
+ * [en-US] Returns `true` when the value is an SDK error and narrows it to `SDKError`.
132
+ * @throws [zh-CN] 此函数不会抛出错误。[en-US] This function does not throw errors.
133
+ *
134
+ * [en-US] Checks whether an unknown value is an SDK error.
135
+ *
136
+ * In addition to instances created by this module, this function recognizes structurally
137
+ * compatible errors created in iframes, micro-frontends, or duplicate SDK copies.
138
+ */
139
+ export declare function isSDKError(error: unknown): error is SDKError;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * 日志上报器
3
+ *
4
+ * 支持缓存、分片与定时上报
5
+ */
6
+ import type { LogLevel } from '../types';
7
+ import type { RequestAdapter } from '../platform/types';
8
+ export interface LogReporterContext {
9
+ restBaseUrl?: string;
10
+ appKey?: string;
11
+ userId?: string;
12
+ token?: string;
13
+ resource?: string;
14
+ requestAdapter?: RequestAdapter;
15
+ }
16
+ export interface LogEntry {
17
+ timestamp: string;
18
+ level: LogLevel;
19
+ message: string;
20
+ args: ReadonlyArray<unknown>;
21
+ }
22
+ export interface LogReporterOptions {
23
+ reportIntervalMs?: number;
24
+ reportTimeoutMs?: number;
25
+ chunkDelayMs?: number;
26
+ maxChunkBytes?: number;
27
+ maxBufferBytes?: number;
28
+ }
29
+ export type LogReportState = 'unknown' | 'enabled' | 'disabled';
30
+ export declare class LogReporter {
31
+ private state;
32
+ private reportIntervalMs;
33
+ private readonly reportTimeoutMs;
34
+ private readonly chunkDelayMs;
35
+ private readonly maxChunkBytes;
36
+ private readonly maxBufferBytes;
37
+ private timerId;
38
+ private reporting;
39
+ private context;
40
+ private buffer;
41
+ private bufferBytes;
42
+ constructor(options?: LogReporterOptions);
43
+ setEnabled(enabled: boolean): void;
44
+ setState(state: LogReportState): void;
45
+ updateContext(context: Partial<LogReporterContext>): void;
46
+ updateReportInterval(reportIntervalMs: number | undefined): void;
47
+ append(entry: LogEntry): void;
48
+ reportNow(): Promise<void>;
49
+ stop(): void;
50
+ private clearBuffer;
51
+ private start;
52
+ private normalizeReportInterval;
53
+ private canReport;
54
+ private formatEntry;
55
+ private pushBuffer;
56
+ private consumeBuffer;
57
+ private requeueChunk;
58
+ private reportLogs;
59
+ private reportChunk;
60
+ }
61
+ export declare const logReporter: LogReporter;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 日志脱敏工具
3
+ *
4
+ * 对敏感字段进行掩码处理,遵循最小必要原则
5
+ */
6
+ export declare const sanitizeLogArgs: (args: ReadonlyArray<unknown>) => ReadonlyArray<unknown>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 日志工具
3
+ *
4
+ * 支持结构化日志,多级别日志控制
5
+ */
6
+ import { type LogReporterContext, type LogReportState } from './log-reporter';
7
+ import type { LogLevel } from '../types';
8
+ export interface Logger {
9
+ debug(message: string, ...args: unknown[]): void;
10
+ warn(message: string, ...args: unknown[]): void;
11
+ error(message: string, ...args: unknown[]): void;
12
+ }
13
+ /**
14
+ * 设置全局日志级别
15
+ */
16
+ export declare function setLogLevel(level: LogLevel): void;
17
+ /**
18
+ * 设置自定义日志器
19
+ */
20
+ export declare function setLogger(logger: Logger): void;
21
+ /**
22
+ * 获取当前日志器
23
+ */
24
+ export declare function getLogger(): Logger;
25
+ /**
26
+ * 设置日志上报开关
27
+ */
28
+ export declare function setLogReportEnabled(enabled: boolean): void;
29
+ /** 设置 DNS 驱动的日志上报三态。 */
30
+ export declare function setLogReportState(state: LogReportState): void;
31
+ /**
32
+ * 更新日志上报上下文
33
+ */
34
+ export declare function updateLogReportContext(context: Partial<LogReporterContext>): void;
35
+ /** 按毫秒更新 DNS 下发的日志上报间隔;缺失时恢复默认 5 分钟。 */
36
+ export declare function setLogReportInterval(reportIntervalMs: number | undefined): void;
37
+ /**
38
+ * 立即触发日志上报
39
+ */
40
+ export declare function reportLogsNow(): Promise<void>;
41
+ /**
42
+ * 停止日志上报定时器
43
+ */
44
+ export declare function stopLogReporter(): void;
45
+ /**
46
+ * 导出日志方法
47
+ */
48
+ export declare const logger: Logger;
package/utils/md5.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const computeMd5Hex: (bytes: Uint8Array) => string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 消息本地 ID 与本地 URL 生成工具
3
+ */
4
+ import type { CompatibleFile } from '../types';
5
+ /**
6
+ * 生成本地可用的文件 URL
7
+ */
8
+ export declare const createLocalFileUrl: (file: CompatibleFile) => string | undefined;
9
+ /**
10
+ * 生成本地消息 ID
11
+ */
12
+ export declare const generateMsgLocalId: () => string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Provision 错误码到 EMError 的映射
3
+ */
4
+ import { type ErrorCode } from './error-codes';
5
+ /**
6
+ * Provision 错误解析结果
7
+ */
8
+ export interface ProvisionErrorResolution {
9
+ readonly code: ErrorCode;
10
+ readonly retryable: boolean;
11
+ }
12
+ /** 消息发送错误解析结果 */
13
+ export interface MessageSendErrorResolution extends ProvisionErrorResolution {
14
+ readonly message: string;
15
+ }
16
+ export declare const resolveProvisionError: (statusCode: number | undefined, reason?: string) => ProvisionErrorResolution;
17
+ export declare const resolveProvisionErrorCode: (statusCode: number | undefined, reason?: string) => ErrorCode;
18
+ /**
19
+ * 将消息 ACK 的状态码和原因解析为面向调用方的具体错误。
20
+ */
21
+ export declare const resolveMessageSendError: (statusCode: number | undefined, reason?: string) => MessageSendErrorResolution;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 重试工具
3
+ *
4
+ * 支持指数退避策略
5
+ */
6
+ export interface RetryOptions {
7
+ maxAttempts?: number;
8
+ initialDelay?: number;
9
+ maxDelay?: number;
10
+ backoffMultiplier?: number;
11
+ jitter?: boolean;
12
+ }
13
+ /**
14
+ * 重试函数
15
+ *
16
+ * @param fn 要重试的函数
17
+ * @param options 重试选项
18
+ * @returns Promise,成功时返回函数结果,失败时抛出最后一个错误
19
+ */
20
+ export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
21
+ /**
22
+ * 重试函数(带条件判断)
23
+ *
24
+ * 只有满足条件的错误才会重试
25
+ */
26
+ export declare function retryWithCondition<T>(fn: () => Promise<T>, shouldRetry: (error: unknown) => boolean, options?: RetryOptions): Promise<T>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 统一获取跨运行时可用的全局对象。
3
+ */
4
+ export declare const getRuntimeGlobal: <TGlobal extends object>(runtimeInput?: TGlobal) => TGlobal;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 生成链路追踪 ID(时间戳 + 随机数)
3
+ */
4
+ export declare const createTraceId: () => string;
5
+ export declare const REQUEST_ID_HEADER = "X-Request-Id";
@@ -0,0 +1,2 @@
1
+ export declare const encodeUtf8: (value: string) => Uint8Array;
2
+ export declare const decodeUtf8: (bytes: Uint8Array) => string;