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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/common-CfAlncj9.cjs"),t=require("../../chunks/session-list-query-B6dh-b4Y.cjs"),n=e.mergeRuntimeErrorMaps(e.COMMON_ERROR_MAP,{common:{},apis:{setGlobalSilentMode:{range:"110,1501",localErrors:{setGlobalSilentMode:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,httpStatus:400,retryable:!1}}},setConversationSilentMode:{range:"110,1501",localErrors:{setConversationSilentMode:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,httpStatus:400,retryable:!1}}},setPushLanguage:{range:"110,1502",localErrors:{setPushLanguage:{validation_invalid:{code:110,retryable:!1}}},errors:{PUSH_LANGUAGE_OPERATION_FAILED:{code:1502,httpStatus:400,retryable:!1}}},uploadPushToken:{range:"110,1500",localErrors:{uploadPushToken:{validation_invalid:{code:110,retryable:!1}}},errors:{TOKEN_UPLOAD_FAILED:{code:1500,httpStatus:400,retryable:!0}}},getGlobalSilentMode:{range:"1501",errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},getConversationSilentMode:{range:"110,1501",localErrors:{getConversationSilentMode:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},clearConversationRemindType:{range:"110,1501",localErrors:{clearConversationRemindType:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},getConversationSilentModes:{range:"110,1501",localErrors:{getConversationSilentModes:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},getConversationListByRemindType:{range:"110",localErrors:{getConversationListByRemindType:{validation_invalid:{code:110,retryable:!1}}},errors:{}},getPushLanguage:{range:"1502",errors:{PUSH_LANGUAGE_OPERATION_FAILED:{code:1502,retryable:!1}}}}}),r=["singleChat","groupChat"],o=["ALL","AT","NONE","DEFAULT"],i=["ALL","AT","NONE"],a=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=class{constructor(){this.client=null,this.restClient=null,this.restBaseUrl=null,this.restToken=null}bind(e,t){this.client=e}async uploadPushToken(t){return this.runOperation(async()=>{this.validateUploadPushTokenParams(t);const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=`/${o}/${i}/users/${n.userId}`;e.logger.debug("Call uploadPushToken",{deviceId:t.deviceId,notifierName:t.notifierName}),await r.request(a,{method:"PUT",body:{device_id:t.deviceId,device_token:t.deviceToken,notifier_name:t.notifierName},operation:"uploadPushToken"})})}async setGlobalSilentMode(t){return this.runOperation(async()=>{this.validateRuleInput(t.rule,"rule");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=`/${o}/${i}/users/${n.userId}/notification/user/${n.userId}?resource=${encodeURIComponent(n.clientResource)}`,s=this.buildSilentModePayload(t.rule);e.logger.debug("Call setGlobalSilentMode",{mode:t.rule.mode});const l=await r.request(a,{method:"PUT",body:s,operation:"setGlobalSilentMode"});return{scope:"global",rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(l),t.rule)}})}async getGlobalSilentMode(t={}){return this.runOperation(async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),{orgName:r,appName:o}=this.parseAppKey(t.appKey),i=`/${r}/${o}/users/${t.userId}/notification/user/${t.userId}`;e.logger.debug("Call getGlobalSilentMode");const a=await n.request(i,{method:"GET",operation:"getGlobalSilentMode"});return{scope:"global",rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(a))}})}async setConversationSilentMode(t){return this.runOperation(async()=>{this.validateConversationId(t.conversationId,"conversationId"),this.validateConversationType(t.conversationType,"conversationType"),this.validateRuleInput(t.rule,"rule");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=this.mapConversationTypeToPath(t.conversationType),s=`/${o}/${i}/users/${n.userId}/notification/${a}/${encodeURIComponent(t.conversationId)}?resource=${encodeURIComponent(n.clientResource)}`,l=this.buildSilentModePayload(t.rule);e.logger.debug("Call setConversationSilentMode",{conversationId:t.conversationId,conversationType:t.conversationType,mode:t.rule.mode});const u=await r.request(s,{method:"PUT",body:l,operation:"setConversationSilentMode"});return{conversationId:t.conversationId,conversationType:t.conversationType,rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(u),t.rule)}})}async getConversationSilentMode(t){return this.runOperation(async()=>{this.validateConversationId(t.conversationId,"conversationId"),this.validateConversationType(t.conversationType,"conversationType");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=this.mapConversationTypeToPath(t.conversationType),s=`/${o}/${i}/users/${n.userId}/notification/${a}/${encodeURIComponent(t.conversationId)}`;e.logger.debug("Call getConversationSilentMode",{conversationId:t.conversationId,conversationType:t.conversationType});const l=await r.request(s,{method:"GET",operation:"getConversationSilentMode"});return{conversationId:t.conversationId,conversationType:t.conversationType,rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(l))}})}async clearConversationRemindType(t){return this.runOperation(async()=>{this.validateConversationId(t.conversationId,"conversationId"),this.validateConversationType(t.conversationType,"conversationType");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=this.mapConversationTypeToPath(t.conversationType),s=`/${o}/${i}/users/${n.userId}/notification/${a}/${encodeURIComponent(t.conversationId)}?resource=${encodeURIComponent(n.clientResource)}`;e.logger.debug("Call clearConversationRemindType",{conversationId:t.conversationId,conversationType:t.conversationType});const l=await r.request(s,{method:"PUT",body:{type:"DEFAULT"},operation:"clearConversationRemindType"});return{conversationId:t.conversationId,conversationType:t.conversationType,rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(l),{remindType:"DEFAULT"})}})}async getConversationSilentModes(t){return this.runOperation(async()=>{this.validateConversationList(t.conversationList,"conversationList");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=t.conversationList.filter(e=>"singleChat"===e.conversationType).map(e=>encodeURIComponent(e.conversationId)).join(","),s=t.conversationList.filter(e=>"groupChat"===e.conversationType).map(e=>encodeURIComponent(e.conversationId)).join(","),l=`/${o}/${i}/users/${n.userId}/notification?user=${a}&group=${s}`;e.logger.debug("Call getConversationSilentModes",{count:t.conversationList.length});const u=await r.request(l,{method:"GET",operation:"getConversationSilentModes"}),d=this.resolveConversationRuleMap(u,"user"),p=this.resolveConversationRuleMap(u,"group");return{conversations:t.conversationList.map(e=>{const t="singleChat"===e.conversationType?d[e.conversationId]:p[e.conversationId];return{conversationId:e.conversationId,conversationType:e.conversationType,rule:this.normalizeRuleView(t)}})}})}async setPushLanguage(t){await this.runOperation(async()=>{this.validateLanguage(t.language,"language");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=`/${o}/${i}/users/${n.userId}/notification/language`;e.logger.debug("Call setPushLanguage",{language:t.language}),await r.request(a,{method:"PUT",body:{translationLanguage:t.language},operation:"setPushLanguage"})})}async getPushLanguage(t={}){return this.runOperation(async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),{orgName:r,appName:o}=this.parseAppKey(t.appKey),i=`/${r}/${o}/users/${t.userId}/notification/language`;e.logger.debug("Call getPushLanguage");const a=await n.request(i,{method:"GET",operation:"getPushLanguage"});return{language:this.resolvePushLanguage(a,"")}})}getConversationListByRemindType(n){return this.runOperation(()=>{e.logger.debug("Call getConversationListByRemindType",{pageSize:n.pageSize,hasCursor:Boolean(n.cursor)});const r=this.getClientOrThrow(),o=t.queryMutedConversationsFromSessionList({items:r.getCacheManager()?.loadSessionList()??[],pageSize:n.pageSize,cursor:n.cursor});return Promise.resolve(o)})}async runOperation(e){try{return await e()}catch(t){throw this.normalizeSdkError(t)}}normalizeSdkError(t){return t instanceof e.SDKError?t:t instanceof Error?new e.SDKError(`PushManager operation failed: ${t.message}`,e.ERROR_CODES.UNKNOWN):new e.SDKError("PushManager operation failed",e.ERROR_CODES.UNKNOWN)}getRestContextOrThrow(){if(!this.client)throw this.buildValidationError("PushManager is not bound to client",[{path:"pushManager.client",message:"PushManager is not bound to client",rule:"required"}]);return this.client.getRestContext()}getRestClient(t){return this.restClient&&this.restBaseUrl===t.restBaseUrl&&this.restToken===t.token||(this.restClient=new e.RestClient(t.restBaseUrl,{errorMap:n,requestAdapter:this.getClientOrThrow().getRequestAdapter?.(),includeRequestId:!0}),this.restClient.setAuthToken(t.token),this.restBaseUrl=t.restBaseUrl,this.restToken=t.token),this.restClient}getClientOrThrow(){if(!this.client)throw new e.SDKError("PushManager is not bound to client",e.ERROR_CODES.VALIDATION_REQUIRED);return this.client}parseAppKey(e){const t=e.split("#");if(2!==t.length||!t[0]||!t[1])throw this.buildValidationError("Invalid appKey format",[{path:"appKey",message:'appKey must be in format "org#app"',rule:"invalid_format"}]);return{orgName:t[0],appName:t[1]}}validateUploadPushTokenParams(e){this.validateNonEmptyString(e.deviceId,"deviceId"),this.validateNonEmptyString(e.deviceToken,"deviceToken"),this.validateNonEmptyString(e.notifierName,"notifierName")}validateConversationId(e,t){this.validateNonEmptyString(e,t)}validateConversationType(e,t){if("string"!=typeof e||!r.includes(e))throw this.buildValidationError("Conversation type is not supported",[{path:t,message:"Only singleChat and groupChat are supported",rule:"invalid_format"}])}validateConversationList(e,t){if(!Array.isArray(e)||0===e.length)throw this.buildValidationError("conversationList must be a non-empty array",[{path:t,message:"conversationList must be a non-empty array",rule:"required"}]);if(e.length>20)throw this.buildValidationError("conversationList length must be <= 20",[{path:t,message:"conversationList length exceeds 20",rule:"range"}]);e.forEach((e,n)=>{this.validateConversationId(e.conversationId,`${t}[${n}].conversationId`),this.validateConversationType(e.conversationType,`${t}[${n}].conversationType`)})}validateLanguage(e,t){this.validateNonEmptyString(e,t)}validateNonEmptyString(e,t){if("string"!=typeof e||0===e.trim().length)throw this.buildValidationError(`${t} must be a non-empty string`,[{path:t,message:`${t} must be a non-empty string`,rule:"invalid_format"}])}validateRuleInput(e,t){if(!a(e))throw this.buildValidationError(`${t} must be an object`,[{path:t,message:`${t} must be an object`,rule:"invalid_format"}]);switch(e.mode){case"REMIND_TYPE":if(!i.includes(e.remindType))throw this.buildValidationError("rule.remindType is invalid",[{path:`${t}.remindType`,message:"remindType must be one of ALL/AT/NONE",rule:"invalid_format"}]);this.ensureNoConflictFields(e,t,["mode","remindType"]);break;case"DURATION":if(!Number.isInteger(e.duration)||e.duration<=0)throw this.buildValidationError("rule.duration must be a positive integer",[{path:`${t}.duration`,message:"duration must be a positive integer",rule:"range"}]);this.ensureNoConflictFields(e,t,["mode","duration"]);break;case"INTERVAL":this.validateTimePoint(e.startTime,`${t}.startTime`),this.validateTimePoint(e.endTime,`${t}.endTime`),this.ensureNoConflictFields(e,t,["mode","startTime","endTime"]);break;default:throw this.buildValidationError("rule.mode is invalid",[{path:`${t}.mode`,message:"mode must be one of REMIND_TYPE/DURATION/INTERVAL",rule:"invalid_format"}])}}ensureNoConflictFields(e,t,n){const r=Object.keys(e).find(e=>!n.includes(e));if(r)throw this.buildValidationError("Silent mode rule contains conflicting fields",[{path:`${t}.${r}`,message:`${r} is not allowed when mode is ${e.mode}`,rule:"conflict"}])}validateTimePoint(e,t){if(!a(e))throw this.buildValidationError(`${t} must be an object`,[{path:t,message:`${t} must be an object`,rule:"invalid_format"}]);if(!Number.isInteger(e.hours)||e.hours<0||e.hours>23)throw this.buildValidationError("hours must be between 0 and 23",[{path:`${t}.hours`,message:"hours must be between 0 and 23",rule:"range"}]);if(!Number.isInteger(e.minutes)||e.minutes<0||e.minutes>59)throw this.buildValidationError("minutes must be between 0 and 59",[{path:`${t}.minutes`,message:"minutes must be between 0 and 59",rule:"range"}])}buildSilentModePayload(e){switch(e.mode){case"REMIND_TYPE":return{type:e.remindType};case"DURATION":return{ignoreDuration:6e4*e.duration};case"INTERVAL":return{ignoreInterval:`${this.formatIntervalSegment(e.startTime)}-${this.formatIntervalSegment(e.endTime)}`}}}normalizeRuleView(e,t){const n=this.parseRuleView(e);return n?t?{...this.toRuleViewFromFallback(t),...n}:n:t?this.toRuleViewFromFallback(t):{}}parseRuleView(e){if(!a(e))return null;const t={},n=this.normalizeRemindType(e.type);null!==n&&(t.remindType=n);const r=e.ignoreDuration;"number"==typeof r&&Number.isInteger(r)&&r>0&&(t.expireTimestamp=r);const o=e.ignoreInterval;if("string"==typeof o){const e=this.parseInterval(o);e&&(t.silentModeStartTime=e.startTime,t.silentModeEndTime=e.endTime)}return void 0!==t.remindType||void 0!==t.expireTimestamp||void 0!==t.silentModeStartTime&&void 0!==t.silentModeEndTime?t:null}parseInterval(e){const t=e.match(/^(\d{1,2}):(\d{1,2})-(\d{1,2}):(\d{1,2})$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),i=Number(t[4]);return Number.isInteger(n)&&Number.isInteger(r)&&Number.isInteger(o)&&Number.isInteger(i)?n<0||n>23||o<0||o>23||r<0||r>59||i<0||i>59?null:{startTime:{hours:n,minutes:r},endTime:{hours:o,minutes:i}}:null}toRuleViewFromFallback(e){if("mode"in e)switch(e.mode){case"REMIND_TYPE":return{remindType:e.remindType};case"DURATION":return{};case"INTERVAL":return{silentModeStartTime:e.startTime,silentModeEndTime:e.endTime}}return e}formatIntervalSegment(e){return`${String(e.hours).padStart(2,"0")}:${String(e.minutes).padStart(2,"0")}`}resolveConversationRuleMap(e,t){if(a(e.data)){const n=e.data[t];if(a(n))return n}const n=e[t];return a(n)?n:{}}resolveSilentModeRuleSource(e){if(!a(e))return e;if(null!==this.parseRuleView(e))return e;const t=e.data;return a(t)&&null!==this.parseRuleView(t)?t:e}normalizeRemindType(e){return"string"!=typeof e?null:"MENTION_ONLY"===e?"AT":o.includes(e)?e:null}resolvePushLanguage(e,t){if("string"==typeof e.translationLanguage&&e.translationLanguage.length>0)return e.translationLanguage;if("string"==typeof e.language&&e.language.length>0)return e.language;if(a(e.data)){const t=e.data.translationLanguage;if("string"==typeof t&&t.length>0)return t;const n=e.data.language;if("string"==typeof n&&n.length>0)return n}return t}mapConversationTypeToPath(e){return"singleChat"===e?"user":"chatgroup"}buildValidationError(t,n){return new e.ValidationError(t,{code:e.ERROR_CODES.VALIDATION_INVALID_FORMAT,details:{fields:n}})}};s.key="pushManager";let l=s;exports.PushManager=l;
@@ -0,0 +1 @@
1
+ export { PushManager } from '../push-manager';
@@ -0,0 +1 @@
1
+ import{l as e,S as t,E as n,f as r,V as o,m as i,h as a}from"../../chunks/common-DN_g4O3n.js";import{q as s}from"../../chunks/session-list-query-Dnp2HbpW.js";const l=i(a,{common:{},apis:{setGlobalSilentMode:{range:"110,1501",localErrors:{setGlobalSilentMode:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,httpStatus:400,retryable:!1}}},setConversationSilentMode:{range:"110,1501",localErrors:{setConversationSilentMode:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,httpStatus:400,retryable:!1}}},setPushLanguage:{range:"110,1502",localErrors:{setPushLanguage:{validation_invalid:{code:110,retryable:!1}}},errors:{PUSH_LANGUAGE_OPERATION_FAILED:{code:1502,httpStatus:400,retryable:!1}}},uploadPushToken:{range:"110,1500",localErrors:{uploadPushToken:{validation_invalid:{code:110,retryable:!1}}},errors:{TOKEN_UPLOAD_FAILED:{code:1500,httpStatus:400,retryable:!0}}},getGlobalSilentMode:{range:"1501",errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},getConversationSilentMode:{range:"110,1501",localErrors:{getConversationSilentMode:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},clearConversationRemindType:{range:"110,1501",localErrors:{clearConversationRemindType:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},getConversationSilentModes:{range:"110,1501",localErrors:{getConversationSilentModes:{validation_invalid:{code:110,retryable:!1}}},errors:{SILENT_MODE_OPERATION_FAILED:{code:1501,retryable:!1}}},getConversationListByRemindType:{range:"110",localErrors:{getConversationListByRemindType:{validation_invalid:{code:110,retryable:!1}}},errors:{}},getPushLanguage:{range:"1502",errors:{PUSH_LANGUAGE_OPERATION_FAILED:{code:1502,retryable:!1}}}}}),u=["singleChat","groupChat"],d=["ALL","AT","NONE","DEFAULT"],p=["ALL","AT","NONE"],c=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),h=class{constructor(){this.client=null,this.restClient=null,this.restBaseUrl=null,this.restToken=null}bind(e,t){this.client=e}async uploadPushToken(t){return this.runOperation(async()=>{this.validateUploadPushTokenParams(t);const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=`/${o}/${i}/users/${n.userId}`;e.debug("Call uploadPushToken",{deviceId:t.deviceId,notifierName:t.notifierName}),await r.request(a,{method:"PUT",body:{device_id:t.deviceId,device_token:t.deviceToken,notifier_name:t.notifierName},operation:"uploadPushToken"})})}async setGlobalSilentMode(t){return this.runOperation(async()=>{this.validateRuleInput(t.rule,"rule");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=`/${o}/${i}/users/${n.userId}/notification/user/${n.userId}?resource=${encodeURIComponent(n.clientResource)}`,s=this.buildSilentModePayload(t.rule);e.debug("Call setGlobalSilentMode",{mode:t.rule.mode});const l=await r.request(a,{method:"PUT",body:s,operation:"setGlobalSilentMode"});return{scope:"global",rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(l),t.rule)}})}async getGlobalSilentMode(t={}){return this.runOperation(async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),{orgName:r,appName:o}=this.parseAppKey(t.appKey),i=`/${r}/${o}/users/${t.userId}/notification/user/${t.userId}`;e.debug("Call getGlobalSilentMode");const a=await n.request(i,{method:"GET",operation:"getGlobalSilentMode"});return{scope:"global",rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(a))}})}async setConversationSilentMode(t){return this.runOperation(async()=>{this.validateConversationId(t.conversationId,"conversationId"),this.validateConversationType(t.conversationType,"conversationType"),this.validateRuleInput(t.rule,"rule");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=this.mapConversationTypeToPath(t.conversationType),s=`/${o}/${i}/users/${n.userId}/notification/${a}/${encodeURIComponent(t.conversationId)}?resource=${encodeURIComponent(n.clientResource)}`,l=this.buildSilentModePayload(t.rule);e.debug("Call setConversationSilentMode",{conversationId:t.conversationId,conversationType:t.conversationType,mode:t.rule.mode});const u=await r.request(s,{method:"PUT",body:l,operation:"setConversationSilentMode"});return{conversationId:t.conversationId,conversationType:t.conversationType,rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(u),t.rule)}})}async getConversationSilentMode(t){return this.runOperation(async()=>{this.validateConversationId(t.conversationId,"conversationId"),this.validateConversationType(t.conversationType,"conversationType");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=this.mapConversationTypeToPath(t.conversationType),s=`/${o}/${i}/users/${n.userId}/notification/${a}/${encodeURIComponent(t.conversationId)}`;e.debug("Call getConversationSilentMode",{conversationId:t.conversationId,conversationType:t.conversationType});const l=await r.request(s,{method:"GET",operation:"getConversationSilentMode"});return{conversationId:t.conversationId,conversationType:t.conversationType,rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(l))}})}async clearConversationRemindType(t){return this.runOperation(async()=>{this.validateConversationId(t.conversationId,"conversationId"),this.validateConversationType(t.conversationType,"conversationType");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=this.mapConversationTypeToPath(t.conversationType),s=`/${o}/${i}/users/${n.userId}/notification/${a}/${encodeURIComponent(t.conversationId)}?resource=${encodeURIComponent(n.clientResource)}`;e.debug("Call clearConversationRemindType",{conversationId:t.conversationId,conversationType:t.conversationType});const l=await r.request(s,{method:"PUT",body:{type:"DEFAULT"},operation:"clearConversationRemindType"});return{conversationId:t.conversationId,conversationType:t.conversationType,rule:this.normalizeRuleView(this.resolveSilentModeRuleSource(l),{remindType:"DEFAULT"})}})}async getConversationSilentModes(t){return this.runOperation(async()=>{this.validateConversationList(t.conversationList,"conversationList");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=t.conversationList.filter(e=>"singleChat"===e.conversationType).map(e=>encodeURIComponent(e.conversationId)).join(","),s=t.conversationList.filter(e=>"groupChat"===e.conversationType).map(e=>encodeURIComponent(e.conversationId)).join(","),l=`/${o}/${i}/users/${n.userId}/notification?user=${a}&group=${s}`;e.debug("Call getConversationSilentModes",{count:t.conversationList.length});const u=await r.request(l,{method:"GET",operation:"getConversationSilentModes"}),d=this.resolveConversationRuleMap(u,"user"),p=this.resolveConversationRuleMap(u,"group");return{conversations:t.conversationList.map(e=>{const t="singleChat"===e.conversationType?d[e.conversationId]:p[e.conversationId];return{conversationId:e.conversationId,conversationType:e.conversationType,rule:this.normalizeRuleView(t)}})}})}async setPushLanguage(t){await this.runOperation(async()=>{this.validateLanguage(t.language,"language");const n=this.getRestContextOrThrow(),r=this.getRestClient(n),{orgName:o,appName:i}=this.parseAppKey(n.appKey),a=`/${o}/${i}/users/${n.userId}/notification/language`;e.debug("Call setPushLanguage",{language:t.language}),await r.request(a,{method:"PUT",body:{translationLanguage:t.language},operation:"setPushLanguage"})})}async getPushLanguage(t={}){return this.runOperation(async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),{orgName:r,appName:o}=this.parseAppKey(t.appKey),i=`/${r}/${o}/users/${t.userId}/notification/language`;e.debug("Call getPushLanguage");const a=await n.request(i,{method:"GET",operation:"getPushLanguage"});return{language:this.resolvePushLanguage(a,"")}})}getConversationListByRemindType(t){return this.runOperation(()=>{e.debug("Call getConversationListByRemindType",{pageSize:t.pageSize,hasCursor:Boolean(t.cursor)});const n=this.getClientOrThrow(),r=s({items:n.getCacheManager()?.loadSessionList()??[],pageSize:t.pageSize,cursor:t.cursor});return Promise.resolve(r)})}async runOperation(e){try{return await e()}catch(t){throw this.normalizeSdkError(t)}}normalizeSdkError(e){return e instanceof t?e:e instanceof Error?new t(`PushManager operation failed: ${e.message}`,n.UNKNOWN):new t("PushManager operation failed",n.UNKNOWN)}getRestContextOrThrow(){if(!this.client)throw this.buildValidationError("PushManager is not bound to client",[{path:"pushManager.client",message:"PushManager is not bound to client",rule:"required"}]);return this.client.getRestContext()}getRestClient(e){return this.restClient&&this.restBaseUrl===e.restBaseUrl&&this.restToken===e.token||(this.restClient=new r(e.restBaseUrl,{errorMap:l,requestAdapter:this.getClientOrThrow().getRequestAdapter?.(),includeRequestId:!0}),this.restClient.setAuthToken(e.token),this.restBaseUrl=e.restBaseUrl,this.restToken=e.token),this.restClient}getClientOrThrow(){if(!this.client)throw new t("PushManager is not bound to client",n.VALIDATION_REQUIRED);return this.client}parseAppKey(e){const t=e.split("#");if(2!==t.length||!t[0]||!t[1])throw this.buildValidationError("Invalid appKey format",[{path:"appKey",message:'appKey must be in format "org#app"',rule:"invalid_format"}]);return{orgName:t[0],appName:t[1]}}validateUploadPushTokenParams(e){this.validateNonEmptyString(e.deviceId,"deviceId"),this.validateNonEmptyString(e.deviceToken,"deviceToken"),this.validateNonEmptyString(e.notifierName,"notifierName")}validateConversationId(e,t){this.validateNonEmptyString(e,t)}validateConversationType(e,t){if("string"!=typeof e||!u.includes(e))throw this.buildValidationError("Conversation type is not supported",[{path:t,message:"Only singleChat and groupChat are supported",rule:"invalid_format"}])}validateConversationList(e,t){if(!Array.isArray(e)||0===e.length)throw this.buildValidationError("conversationList must be a non-empty array",[{path:t,message:"conversationList must be a non-empty array",rule:"required"}]);if(e.length>20)throw this.buildValidationError("conversationList length must be <= 20",[{path:t,message:"conversationList length exceeds 20",rule:"range"}]);e.forEach((e,n)=>{this.validateConversationId(e.conversationId,`${t}[${n}].conversationId`),this.validateConversationType(e.conversationType,`${t}[${n}].conversationType`)})}validateLanguage(e,t){this.validateNonEmptyString(e,t)}validateNonEmptyString(e,t){if("string"!=typeof e||0===e.trim().length)throw this.buildValidationError(`${t} must be a non-empty string`,[{path:t,message:`${t} must be a non-empty string`,rule:"invalid_format"}])}validateRuleInput(e,t){if(!c(e))throw this.buildValidationError(`${t} must be an object`,[{path:t,message:`${t} must be an object`,rule:"invalid_format"}]);switch(e.mode){case"REMIND_TYPE":if(!p.includes(e.remindType))throw this.buildValidationError("rule.remindType is invalid",[{path:`${t}.remindType`,message:"remindType must be one of ALL/AT/NONE",rule:"invalid_format"}]);this.ensureNoConflictFields(e,t,["mode","remindType"]);break;case"DURATION":if(!Number.isInteger(e.duration)||e.duration<=0)throw this.buildValidationError("rule.duration must be a positive integer",[{path:`${t}.duration`,message:"duration must be a positive integer",rule:"range"}]);this.ensureNoConflictFields(e,t,["mode","duration"]);break;case"INTERVAL":this.validateTimePoint(e.startTime,`${t}.startTime`),this.validateTimePoint(e.endTime,`${t}.endTime`),this.ensureNoConflictFields(e,t,["mode","startTime","endTime"]);break;default:throw this.buildValidationError("rule.mode is invalid",[{path:`${t}.mode`,message:"mode must be one of REMIND_TYPE/DURATION/INTERVAL",rule:"invalid_format"}])}}ensureNoConflictFields(e,t,n){const r=Object.keys(e).find(e=>!n.includes(e));if(r)throw this.buildValidationError("Silent mode rule contains conflicting fields",[{path:`${t}.${r}`,message:`${r} is not allowed when mode is ${e.mode}`,rule:"conflict"}])}validateTimePoint(e,t){if(!c(e))throw this.buildValidationError(`${t} must be an object`,[{path:t,message:`${t} must be an object`,rule:"invalid_format"}]);if(!Number.isInteger(e.hours)||e.hours<0||e.hours>23)throw this.buildValidationError("hours must be between 0 and 23",[{path:`${t}.hours`,message:"hours must be between 0 and 23",rule:"range"}]);if(!Number.isInteger(e.minutes)||e.minutes<0||e.minutes>59)throw this.buildValidationError("minutes must be between 0 and 59",[{path:`${t}.minutes`,message:"minutes must be between 0 and 59",rule:"range"}])}buildSilentModePayload(e){switch(e.mode){case"REMIND_TYPE":return{type:e.remindType};case"DURATION":return{ignoreDuration:6e4*e.duration};case"INTERVAL":return{ignoreInterval:`${this.formatIntervalSegment(e.startTime)}-${this.formatIntervalSegment(e.endTime)}`}}}normalizeRuleView(e,t){const n=this.parseRuleView(e);return n?t?{...this.toRuleViewFromFallback(t),...n}:n:t?this.toRuleViewFromFallback(t):{}}parseRuleView(e){if(!c(e))return null;const t={},n=this.normalizeRemindType(e.type);null!==n&&(t.remindType=n);const r=e.ignoreDuration;"number"==typeof r&&Number.isInteger(r)&&r>0&&(t.expireTimestamp=r);const o=e.ignoreInterval;if("string"==typeof o){const e=this.parseInterval(o);e&&(t.silentModeStartTime=e.startTime,t.silentModeEndTime=e.endTime)}return void 0!==t.remindType||void 0!==t.expireTimestamp||void 0!==t.silentModeStartTime&&void 0!==t.silentModeEndTime?t:null}parseInterval(e){const t=e.match(/^(\d{1,2}):(\d{1,2})-(\d{1,2}):(\d{1,2})$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),i=Number(t[4]);return Number.isInteger(n)&&Number.isInteger(r)&&Number.isInteger(o)&&Number.isInteger(i)?n<0||n>23||o<0||o>23||r<0||r>59||i<0||i>59?null:{startTime:{hours:n,minutes:r},endTime:{hours:o,minutes:i}}:null}toRuleViewFromFallback(e){if("mode"in e)switch(e.mode){case"REMIND_TYPE":return{remindType:e.remindType};case"DURATION":return{};case"INTERVAL":return{silentModeStartTime:e.startTime,silentModeEndTime:e.endTime}}return e}formatIntervalSegment(e){return`${String(e.hours).padStart(2,"0")}:${String(e.minutes).padStart(2,"0")}`}resolveConversationRuleMap(e,t){if(c(e.data)){const n=e.data[t];if(c(n))return n}const n=e[t];return c(n)?n:{}}resolveSilentModeRuleSource(e){if(!c(e))return e;if(null!==this.parseRuleView(e))return e;const t=e.data;return c(t)&&null!==this.parseRuleView(t)?t:e}normalizeRemindType(e){return"string"!=typeof e?null:"MENTION_ONLY"===e?"AT":d.includes(e)?e:null}resolvePushLanguage(e,t){if("string"==typeof e.translationLanguage&&e.translationLanguage.length>0)return e.translationLanguage;if("string"==typeof e.language&&e.language.length>0)return e.language;if(c(e.data)){const t=e.data.translationLanguage;if("string"==typeof t&&t.length>0)return t;const n=e.data.language;if("string"==typeof n&&n.length>0)return n}return t}mapConversationTypeToPath(e){return"singleChat"===e?"user":"chatgroup"}buildValidationError(e,t){return new o(e,{code:n.VALIDATION_INVALID_FORMAT,details:{fields:t}})}};h.key="pushManager";let g=h;export{g as PushManager};
@@ -0,0 +1,205 @@
1
+ /**
2
+ * PushManager 管理器
3
+ */
4
+ import type { ChatClient } from '../chat-client';
5
+ import type { ManagerBase, ManagerEventContext } from '../types/manager';
6
+ import type { BatchConversationSilentModeResponse, ClearConversationRemindTypeParams, ConversationSilentModeResponse, GetConversationListByRemindTypeParams, GetConversationSilentModeParams, GetConversationSilentModesParams, GetGlobalSilentModeParams, GetPushLanguageParams, GlobalSilentModeResponse, MutedConversationPageResponse, PushLanguageResponse, SetConversationSilentModeParams, SetGlobalSilentModeParams, SetPushLanguageParams, UploadPushTokenParams } from '../types/push';
7
+ /**
8
+ * PushManager 负责 push token、免打扰与语言偏好管理
9
+ */
10
+ export declare class PushManager implements ManagerBase<ChatClient> {
11
+ /** @internal SDK 内部管理器注册键,不对外文档暴露。 */
12
+ static readonly key: "pushManager";
13
+ private client;
14
+ private restClient;
15
+ private restBaseUrl;
16
+ private restToken;
17
+ /**
18
+ * @internal
19
+ * [zh-CN] 绑定 PushManager 到 ChatClient,通常由 SDK 内部在 `client.pushManager` 初始化阶段调用。 [en-US] Binds PushManager to ChatClient and is usually called internally when `client.pushManager` is initialized.
20
+ *
21
+ * @param client - [zh-CN] 已初始化的 ChatClient 实例。 [en-US] Initialized ChatClient instance.
22
+ * @param _context - [zh-CN] 预留的管理器上下文(当前未使用)。 [en-US] Reserved manager context (unused for now).
23
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
24
+ */
25
+ bind(client: ChatClient, _context?: ManagerEventContext): void;
26
+ /**
27
+ * [zh-CN] 上传或覆盖设备 Push Token。成功时仅表示请求完成,不返回业务数据。 [en-US] Uploads or replaces the device push token. On success it only resolves and returns no business payload.
28
+ *
29
+ * @example [zh-CN] 调用示例(上传设备 token) [en-US] Usage example (upload device token)
30
+ * ```ts
31
+ * await client.pushManager.uploadPushToken({
32
+ * deviceId: 'web-device-001',
33
+ * deviceToken: 'token-from-push-provider',
34
+ * notifierName: 'FCM',
35
+ * });
36
+ * ```
37
+ *
38
+ * @param params - [zh-CN] 上传参数,包含设备标识、设备 token 与推送通道标识。 [en-US] Upload parameters including device id, device token, and notifier name.
39
+ * @returns {Promise<void>} [zh-CN] 成功时 resolve,无返回值。 [en-US] Resolves on success with no return value.
40
+ */
41
+ uploadPushToken(params: UploadPushTokenParams): Promise<void>;
42
+ /**
43
+ * [zh-CN] 设置 App 级(全局)免打扰规则,支持提醒类型、持续时长、时间区间三种模式。 [en-US] Sets app-level (global) silent mode rule, supporting remind type, duration, and interval modes.
44
+ *
45
+ * @example [zh-CN] 调用示例(设置全局提醒类型) [en-US] Usage example (set global remind type)
46
+ * ```ts
47
+ * const result = await client.pushManager.setGlobalSilentMode({
48
+ * rule: { mode: 'REMIND_TYPE', remindType: 'AT' },
49
+ * });
50
+ * console.log(result.rule.remindType);
51
+ * ```
52
+ *
53
+ * @param params - [zh-CN] 全局免打扰设置参数。 [en-US] Parameters for setting global silent mode.
54
+ * @returns {Promise<GlobalSilentModeResponse>} [zh-CN] 返回全局规则快照。 [en-US] Returns the global silent mode snapshot.
55
+ */
56
+ setGlobalSilentMode(params: SetGlobalSilentModeParams): Promise<GlobalSilentModeResponse>;
57
+ /**
58
+ * [zh-CN] 查询 App 级(全局)免打扰规则。 [en-US] Gets the app-level (global) silent mode rule.
59
+ *
60
+ * @example [zh-CN] 调用示例(查询全局规则) [en-US] Usage example (get global rule)
61
+ * ```ts
62
+ * const result = await client.pushManager.getGlobalSilentMode();
63
+ * console.log(result.rule);
64
+ * ```
65
+ *
66
+ * @param params - [zh-CN] 查询参数(当前无字段)。 [en-US] Query parameters (currently empty).
67
+ * @returns {Promise<GlobalSilentModeResponse>} [zh-CN] 返回全局规则快照。 [en-US] Returns the global silent mode snapshot.
68
+ */
69
+ getGlobalSilentMode(params?: GetGlobalSilentModeParams): Promise<GlobalSilentModeResponse>;
70
+ /**
71
+ * [zh-CN] 设置单会话免打扰规则,仅支持单聊与群聊。 [en-US] Sets silent mode rule for a specific conversation, supporting only single chat and group chat.
72
+ *
73
+ * @example [zh-CN] 调用示例(设置会话时长免打扰) [en-US] Usage example (set conversation duration mode)
74
+ * ```ts
75
+ * const result = await client.pushManager.setConversationSilentMode({
76
+ * conversationId: 'group_123',
77
+ * conversationType: 'groupChat',
78
+ * rule: { mode: 'DURATION', duration: 60 },
79
+ * });
80
+ * console.log(result.rule.expireTimestamp);
81
+ * ```
82
+ *
83
+ * @param params - [zh-CN] 会话维度的免打扰设置参数。 [en-US] Conversation-level silent mode parameters.
84
+ * @returns {Promise<ConversationSilentModeResponse>} [zh-CN] 返回目标会话与规则快照。 [en-US] Returns target conversation with its rule snapshot.
85
+ */
86
+ setConversationSilentMode(params: SetConversationSilentModeParams): Promise<ConversationSilentModeResponse>;
87
+ /**
88
+ * [zh-CN] 查询单会话免打扰规则。 [en-US] Gets silent mode rule for a specific conversation.
89
+ *
90
+ * @example [zh-CN] 调用示例(查询会话规则) [en-US] Usage example (get conversation rule)
91
+ * ```ts
92
+ * const result = await client.pushManager.getConversationSilentMode({
93
+ * conversationId: 'user_001',
94
+ * conversationType: 'singleChat',
95
+ * });
96
+ * console.log(result.rule.remindType);
97
+ * ```
98
+ *
99
+ * @param params - [zh-CN] 会话查询参数。 [en-US] Conversation query parameters.
100
+ * @returns {Promise<ConversationSilentModeResponse>} [zh-CN] 返回目标会话的规则快照。 [en-US] Returns rule snapshot of the target conversation.
101
+ */
102
+ getConversationSilentMode(params: GetConversationSilentModeParams): Promise<ConversationSilentModeResponse>;
103
+ /**
104
+ * [zh-CN] 清除会话提醒类型配置,恢复服务端默认提醒策略。 [en-US] Clears conversation remind type and restores server-side default remind policy.
105
+ *
106
+ * @example [zh-CN] 调用示例(清除会话提醒类型) [en-US] Usage example (clear conversation remind type)
107
+ * ```ts
108
+ * const result = await client.pushManager.clearConversationRemindType({
109
+ * conversationId: 'group_123',
110
+ * conversationType: 'groupChat',
111
+ * });
112
+ * console.log(result.rule.remindType);
113
+ * ```
114
+ *
115
+ * @param params - [zh-CN] 清除会话提醒类型所需参数。 [en-US] Parameters required to clear conversation remind type.
116
+ * @returns {Promise<ConversationSilentModeResponse>} [zh-CN] 返回清除后的会话规则快照。 [en-US] Returns conversation rule snapshot after clearing.
117
+ */
118
+ clearConversationRemindType(params: ClearConversationRemindTypeParams): Promise<ConversationSilentModeResponse>;
119
+ /**
120
+ * [zh-CN] 批量查询多个会话的免打扰规则,单次最多 20 条。 [en-US] Batch queries silent mode rules for multiple conversations, up to 20 items per request.
121
+ *
122
+ * @example [zh-CN] 调用示例(批量查询) [en-US] Usage example (batch query)
123
+ * ```ts
124
+ * const result = await client.pushManager.getConversationSilentModes({
125
+ * conversationList: [
126
+ * { conversationId: 'user_001', conversationType: 'singleChat' },
127
+ * { conversationId: 'group_123', conversationType: 'groupChat' },
128
+ * ],
129
+ * });
130
+ * console.log(result.conversations);
131
+ * ```
132
+ *
133
+ * @param params - [zh-CN] 批量查询参数。 [en-US] Batch query parameters.
134
+ * @returns {Promise<BatchConversationSilentModeResponse>} [zh-CN] 返回与输入顺序对齐的会话规则列表。 [en-US] Returns conversation rules aligned with the input order.
135
+ */
136
+ getConversationSilentModes(params: GetConversationSilentModesParams): Promise<BatchConversationSilentModeResponse>;
137
+ /**
138
+ * [zh-CN] 设置推送翻译语言。 [en-US] Sets push notification translation language.
139
+ *
140
+ * @example [zh-CN] 调用示例(设置推送语言) [en-US] Usage example (set push language)
141
+ * ```ts
142
+ * await client.pushManager.setPushLanguage({ language: 'zh-Hans' });
143
+ * ```
144
+ *
145
+ * @param params - [zh-CN] 语言设置参数。 [en-US] Language setting parameters.
146
+ * @returns {Promise<void>} [zh-CN] 成功时 resolve,无返回值。 [en-US] Resolves on success with no return value.
147
+ */
148
+ setPushLanguage(params: SetPushLanguageParams): Promise<void>;
149
+ /**
150
+ * [zh-CN] 查询当前推送翻译语言。 [en-US] Gets current push notification translation language.
151
+ *
152
+ * @example [zh-CN] 调用示例(查询推送语言) [en-US] Usage example (get push language)
153
+ * ```ts
154
+ * const result = await client.pushManager.getPushLanguage();
155
+ * console.log(result.language);
156
+ * ```
157
+ *
158
+ * @param params - [zh-CN] 查询参数(当前无字段)。 [en-US] Query parameters (currently empty).
159
+ * @returns {Promise<PushLanguageResponse>} [zh-CN] 返回当前语言值。 [en-US] Returns the current language value.
160
+ */
161
+ getPushLanguage(params?: GetPushLanguageParams): Promise<PushLanguageResponse>;
162
+ /**
163
+ * [zh-CN] 分页查询已设置提醒类型的会话列表。 [en-US] Paginates conversations that have explicit remind type settings.
164
+ *
165
+ * @example [zh-CN] 调用示例(分页查询) [en-US] Usage example (pagination query)
166
+ * ```ts
167
+ * const result = await client.pushManager.getConversationListByRemindType({
168
+ * pageSize: 20,
169
+ * cursor: '',
170
+ * });
171
+ * console.log(result.conversations, result.cursor);
172
+ * ```
173
+ *
174
+ * @param params - [zh-CN] 分页参数,包含页大小与可选游标。 [en-US] Paging parameters including page size and optional cursor.
175
+ * @returns {Promise<MutedConversationPageResponse>} [zh-CN] 返回会话列表与下一页游标。 [en-US] Returns conversation list and next cursor.
176
+ */
177
+ getConversationListByRemindType(params: GetConversationListByRemindTypeParams): Promise<MutedConversationPageResponse>;
178
+ private runOperation;
179
+ private normalizeSdkError;
180
+ private getRestContextOrThrow;
181
+ private getRestClient;
182
+ private getClientOrThrow;
183
+ private parseAppKey;
184
+ private validateUploadPushTokenParams;
185
+ private validateConversationId;
186
+ private validateConversationType;
187
+ private validateConversationList;
188
+ private validateLanguage;
189
+ private validateNonEmptyString;
190
+ private validateRuleInput;
191
+ private ensureNoConflictFields;
192
+ private validateTimePoint;
193
+ private buildSilentModePayload;
194
+ private normalizeRuleView;
195
+ private parseRuleView;
196
+ private parseInterval;
197
+ private toRuleViewFromFallback;
198
+ private formatIntervalSegment;
199
+ private resolveConversationRuleMap;
200
+ private resolveSilentModeRuleSource;
201
+ private normalizeRemindType;
202
+ private resolvePushLanguage;
203
+ private mapConversationTypeToPath;
204
+ private buildValidationError;
205
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/cache-utils-CKbcYPlM.cjs"),t=require("../../chunks/profile-version-njNs7R5-.cjs"),r=require("../../chunks/common-CfAlncj9.cjs"),s=require("../../chunks/user-info-icpL0Eaw.cjs"),n=require("../../chunks/event-system-COBJFEIq.cjs"),a=e=>{const{orgName:t,appName:s}=r.parseAppKey(e.appKey);return`/${t}/${s}/user/${encodeURIComponent(e.userId)}/metadata/subscription`},o=(e,t="params.userIds")=>s.normalizeUserInfoTargetIds(e,t),i=e=>{const t=o(e);if(t.length>100)throw((e,t,s,n=r.ERROR_CODES.VALIDATION_INVALID_FORMAT)=>new r.ValidationError(e,{code:n,details:{fields:[{path:t,message:e,rule:s}]}}))("params.userIds must contain at most 100 unique users","params.userIds","range",r.ERROR_CODES.SERVICE_LIMIT_EXCEEDED);return{usernames:t}},d=(e,t)=>{const r=(e=>o(e))(t);return`${a(e)}?usernames=${r.map(e=>encodeURIComponent(e)).join(",")}`},u=(e,t)=>{switch(e){case"nickname":return"string"==typeof t?{nickname:t}:null;case"avatarurl":case"avatarUrl":return"string"==typeof t?{avatarUrl:t}:null;case"mail":return"string"==typeof t?{mail:t}:null;case"phone":return"string"==typeof t?{phone:t}:null;case"gender":return"string"==typeof t||"number"==typeof t||"boolean"==typeof t?{gender:t}:null;case"sign":return"string"==typeof t?{sign:t}:null;case"birth":return"string"==typeof t?{birth:t}:null;case"ext":return"string"==typeof t?{ext:t}:null;default:return null}},l=["nickname","avatarUrl","mail","phone","gender","sign","birth","ext"],c=r.mergeRuntimeErrorMaps(r.COMMON_ERROR_MAP,{common:{},apis:{updateOwnUserInfo:{range:"4,110,204,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{data_length_exceed:{code:901,httpStatus:403,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfo:{range:"4,110,204,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{data_length_exceed:{code:901,httpStatus:403,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfoByAttribute:{range:"4,110,204,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{data_length_exceed:{code:901,httpStatus:403,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},getUserInfoByUserId:{range:"4,110,204,900",localErrors:{getUserInfoByUserId:{validation_invalid:{code:110,retryable:!1}}},errors:{usercount_exceed:{code:900,httpStatus:400,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},getUserInfoByAttribute:{range:"4,110,204,900",localErrors:{getUserInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{usercount_exceed:{code:900,httpStatus:400,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},subscribeUsersInfo:{range:"4,202,210,303,1600,1601",errors:{unauthorized:{code:202,httpStatus:401,retryable:!0},forbidden:{code:210,httpStatus:403,aliases:["operation forbidden"],matchField:"error_description",matchPattern:"metadata subscription not allow",retryable:!1},subscriber_limit_exceeded:{code:1600,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscription count exceeds limit",retryable:!1},target_limit_exceeded:{code:1601,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscribed count exceeds limit",retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0},server_unknown_error:{code:303,httpStatus:500,retryable:!0}}},unsubscribeUsersInfo:{range:"4,202,210,303,1600,1601",errors:{unauthorized:{code:202,httpStatus:401,retryable:!0},forbidden:{code:210,httpStatus:403,aliases:["operation forbidden"],matchField:"error_description",matchPattern:"metadata subscription not allow",retryable:!1},subscriber_limit_exceeded:{code:1600,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscription count exceeds limit",retryable:!1},target_limit_exceeded:{code:1601,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscribed count exceeds limit",retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0},server_unknown_error:{code:303,httpStatus:500,retryable:!0}}},getSubscribedUsers:{range:"4,202,210,303,1600,1601",errors:{unauthorized:{code:202,httpStatus:401,retryable:!0},forbidden:{code:210,httpStatus:403,aliases:["operation forbidden"],matchField:"error_description",matchPattern:"metadata subscription not allow",retryable:!1},subscriber_limit_exceeded:{code:1600,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscription count exceeds limit",retryable:!1},target_limit_exceeded:{code:1601,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscribed count exceeds limit",retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0},server_unknown_error:{code:303,httpStatus:500,retryable:!0}}}}}),p=class{constructor(){this.capabilities=["userInfo:read","rawNotify:userInfo"],this.client=null,this.eventContext=null,this.restClient=null,this.restBaseUrl=null,this.restToken=null}bind(e,t){this.client=e,this.eventContext=t??null}addEventHandler(e,t){this.eventContext?.addEventHandler(e,t)}removeEventHandler(e){this.eventContext?.removeEventHandler(e)}handleRawNotify(e){if("userInfo"!==e.type)return;const t=this.client,s=t?.getCacheManager();if(!t||!s||!t.getCurrentUserId())return;const a=e.payload,o=(e=>{const t={};for(const[r,s]of Object.entries(e.metadata)){const e=u(r,s);e&&Object.assign(t,e)}return{userId:e.userId,attributes:t,lastModified:e.lastModified,source:"subscribe_metadata_updated"===e.notifyType?"subscription":"contact_metadata_updated"===e.notifyType?"contact":"own"}})(a);if(!o)return;const i=s.applyUserInfoNotifyPatch(o);if(!i.applied)return void r.logger.debug("User-info notify ignored",{userId:o.userId,notifyType:a.notifyType,reason:i.reason,lastModified:o.lastModified});if(s.updateUserInfoSummaryFromRuntime(o.userId),t.refreshConversationDisplayFromUserInfos?.([{userId:o.userId,lastModified:o.lastModified}]),"subscription"===o.source)return void this.eventContext?.dispatch?.("onUserInfoUpdated",[i.record.profile]);if("own"===o.source)return void this.eventContext?.dispatch?.("onOwnInfoUpdated",i.record.profile);const d=t.getContactSnapshot()?.items.find(e=>e.userId===o.userId);this.eventContext?.dispatch?.(n.ContactEventName.CONTACT_INFO_UPDATED,{userInfo:i.record.profile,contact:d})}async getUserInfoByUserId(e){return this.runOperation("getUserInfoByUserId",async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),a=s.buildFetchUserInfoByUserIdRequest(s.normalizeUserInfoTargetIds(e.userIds,"params.userIds")),o=s.buildUserInfoFetchEndpoint(t);r.logger.debug("UserInfoManager getUserInfoByUserId",{userIds:a.targets});const i=await n.request(o,{method:"POST",body:a,operation:"getUserInfoByUserId"}),d=this.normalizeFetchEnvelope(i,a.targets);return this.writeCache(d),d.map(e=>e.profile)})}async getUserInfoByAttribute(e){return this.runOperation("getUserInfoByAttribute",async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),a=s.buildFetchUserInfoByAttributeRequest(s.normalizeUserInfoTargetIds(e.userIds,"params.userIds"),s.normalizeUserInfoAttributes(e.attributes,"params.attributes")),o=s.buildUserInfoFetchEndpoint(t);r.logger.debug("UserInfoManager getUserInfoByAttribute",{userIds:a.targets,attributes:a.properties});const i=await n.request(o,{method:"POST",body:a,operation:"getUserInfoByAttribute"}),d=this.normalizeFetchEnvelope(i,a.targets);return this.writeCache(d),d.map(e=>e.profile)})}async subscribeUsersInfo(e){return this.runOperation("subscribeUsersInfo",async()=>{const t=this.getRestContextOrThrow(),s=this.getRestClient(t),n=(e=>a(e))(t),o=i(e.userIds);r.logger.debug("UserInfoManager subscribeUsersInfo",{userIds:o.usernames}),await s.request(n,{method:"POST",body:o,operation:"subscribeUsersInfo"})})}async unsubscribeUsersInfo(e){return this.runOperation("unsubscribeUsersInfo",async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),a=d(t,e.userIds);r.logger.debug("UserInfoManager unsubscribeUsersInfo",{userIds:s.normalizeUserInfoTargetIds(e.userIds,"params.userIds")}),await n.request(a,{method:"DELETE",operation:"unsubscribeUsersInfo"})})}async getSubscribedUsers(){return this.runOperation("getSubscribedUsers",async()=>{const e=this.getRestContextOrThrow(),t=this.getRestClient(e),s=(e=>a(e))(e);r.logger.debug("UserInfoManager getSubscribedUsers",{userId:e.userId});const n=(e=>{const t=e&&"object"==typeof e?e:null;if(!t||!Array.isArray(t.data))return[];const r=[],s=new Set;for(const n of t.data){if("string"!=typeof n)continue;const e=n.trim();e&&!s.has(e)&&(s.add(e),r.push(e))}return r})(await t.request(s,{method:"GET",operation:"getSubscribedUsers"}));return 0===n.length?[]:await this.getUserInfoByUserId({userIds:n})})}async updateOwnInfo(e){return this.runOperation("updateOwnInfo",async()=>{const t=this.getRestContextOrThrow(),n=this.getRestClient(t),a=s.buildUpdateOwnInfoFormBody(e),o=s.buildUserInfoUpdateEndpoint(t);r.logger.debug("UserInfoManager updateOwnInfo",{userId:t.userId,fields:this.getUpdatedFieldNames(e)});const i=await n.request(o,{method:"PUT",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a,operation:"updateOwnInfo"}),d=this.normalizeUpdateEnvelope(i,t.userId,this.buildFallbackProfile(t.userId,e));return this.writeCache([d]),this.dispatchSelfUpdate(d.profile),d.profile})}async updateOwnInfoByAttribute(e,t){return this.runOperation("updateOwnInfoByAttribute",async()=>{const n=this.getRestContextOrThrow(),a=this.getRestClient(n),o=s.buildUpdateOwnInfoByAttributeFormBody(e,t),i=s.buildUserInfoUpdateEndpoint(n);r.logger.debug("UserInfoManager updateOwnInfoByAttribute",{userId:n.userId,attribute:e});const d=await a.request(i,{method:"PUT",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o,operation:"updateOwnInfoByAttribute"}),u=this.normalizeUpdateEnvelope(d,n.userId,{userId:n.userId,[e]:t});return this.writeCache([u]),this.dispatchSelfUpdate(u.profile),u.profile})}async runOperation(e,t){try{return await t()}catch(r){throw this.normalizeOperationError(e,r)}}normalizeOperationError(e,t){return t instanceof r.SDKError?t:(r.logger.warn("UserInfoManager operation failed",{operation:e,message:t instanceof Error?t.message:String(t)}),new r.SDKError(`${e} failed`))}getRestContextOrThrow(){if(this.client)return this.client.getRestContext();throw new r.ValidationError("UserInfoManager is not bound to client",{code:r.ERROR_CODES.VALIDATION_REQUIRED,details:{fields:[{path:"userInfoManager.client",message:"client is required",rule:"required"}]}})}getRestClient(e){return this.restClient&&this.restBaseUrl===e.restBaseUrl&&this.restToken===e.token||(this.restClient=new r.RestClient(e.restBaseUrl,{errorMap:c,requestAdapter:this.client?.getRequestAdapter?.(),includeRequestId:!0}),this.restClient.setAuthToken(e.token),this.restBaseUrl=e.restBaseUrl,this.restToken=e.token),this.restClient}normalizeFetchEnvelope(e,t){return s.normalizeUserInfoFetchRecords(e,t)}normalizeUpdateEnvelope(t,r,s){const n=e.isRecord(t)?t:null,a=(n&&e.isRecord(n.data)?n.data:null)??(n&&this.looksLikeUserInfoAttributes(n)?n:null),o=n&&"number"==typeof n.lastModified?n.lastModified:void 0;return{profile:a?this.toUserInfo(r,a):{userId:r,...s??{}},lastModified:o}}toUserInfo(e,t){const r={userId:e};return"string"==typeof t.nickname&&(r.nickname=t.nickname),"string"==typeof t.avatarurl?r.avatarUrl=t.avatarurl:"string"==typeof t.avatarUrl&&(r.avatarUrl=t.avatarUrl),"string"==typeof t.mail&&(r.mail=t.mail),"string"==typeof t.phone&&(r.phone=t.phone),"string"!=typeof t.gender&&"number"!=typeof t.gender&&"boolean"!=typeof t.gender||(r.gender=t.gender),"string"==typeof t.sign&&(r.sign=t.sign),"string"==typeof t.birth&&(r.birth=t.birth),"string"==typeof t.ext&&(r.ext=t.ext),r}looksLikeUserInfoAttributes(t){return!!e.isRecord(t)&&("nickname"in t||"avatarurl"in t||"avatarUrl"in t||"mail"in t||"phone"in t||"gender"in t||"sign"in t||"birth"in t||"ext"in t)}buildFallbackProfile(e,t){const r={userId:e},s=r;for(const n of l)n in t&&(s[n]=t[n]);return r}getUpdatedFieldNames(e){return l.filter(t=>t in e)}projectToSummary(e){const r=Date.now(),s=t.normalizeProfileVersionFromTimestamp(e.lastModified);return{userId:e.profile.userId,nickname:e.profile.nickname,avatarUrl:e.profile.avatarUrl,sign:e.profile.sign,ext:e.profile.ext,userInfoUpdateTime:s,lastSyncAt:r,lastAccess:r,lastUpdate:e.lastModified??r}}writeCache(e){if(!this.client||0===e.length)return;const t=this.client.getCacheManager();t&&("function"==typeof t.upsertRuntimeUserInfos&&t.upsertRuntimeUserInfos(e.map(e=>({profile:e.profile,lastModified:e.lastModified,source:e.profile.userId===this.client?.getRestContext().userId?"update":"fetch"}))),t.setUserInfoSummaries(e.map(e=>this.projectToSummary(e))))}dispatchSelfUpdate(e){this.client?.dispatchOwnInfoUpdated?.(e)}};p.key="userInfoManager";let f=p;exports.UserInfoManager=f;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 用户信息管理器导出
3
+ */
4
+ export { UserInfoManager } from '../user-info-manager';
@@ -0,0 +1 @@
1
+ import{i as e}from"../../chunks/cache-utils-BwRPIZ7n.js";import{a as t}from"../../chunks/profile-version-DLMz8lqW.js";import{p as r,E as s,V as n,l as a,S as o,f as i,m as d,h as u}from"../../chunks/common-DN_g4O3n.js";import{c as l,b as c,a as p,d as h,e as f,f as b,g as m,h as y,i as I}from"../../chunks/user-info-BfRwS4ZA.js";import{a as g}from"../../chunks/event-system-D6IJA0C4.js";const U=e=>{const{orgName:t,appName:s}=r(e.appKey);return`/${t}/${s}/user/${encodeURIComponent(e.userId)}/metadata/subscription`},_=(e,t="params.userIds")=>l(e,t),w=e=>{const t=_(e);if(t.length>100)throw((e,t,r,a=s.VALIDATION_INVALID_FORMAT)=>new n(e,{code:a,details:{fields:[{path:t,message:e,rule:r}]}}))("params.userIds must contain at most 100 unique users","params.userIds","range",s.SERVICE_LIMIT_EXCEEDED);return{usernames:t}},v=(e,t)=>{const r=(e=>_(e))(t);return`${U(e)}?usernames=${r.map(e=>encodeURIComponent(e)).join(",")}`},S=(e,t)=>{switch(e){case"nickname":return"string"==typeof t?{nickname:t}:null;case"avatarurl":case"avatarUrl":return"string"==typeof t?{avatarUrl:t}:null;case"mail":return"string"==typeof t?{mail:t}:null;case"phone":return"string"==typeof t?{phone:t}:null;case"gender":return"string"==typeof t||"number"==typeof t||"boolean"==typeof t?{gender:t}:null;case"sign":return"string"==typeof t?{sign:t}:null;case"birth":return"string"==typeof t?{birth:t}:null;case"ext":return"string"==typeof t?{ext:t}:null;default:return null}},C=["nickname","avatarUrl","mail","phone","gender","sign","birth","ext"],O=d(u,{common:{},apis:{updateOwnUserInfo:{range:"4,110,204,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{data_length_exceed:{code:901,httpStatus:403,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfo:{range:"4,110,204,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{data_length_exceed:{code:901,httpStatus:403,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfoByAttribute:{range:"4,110,204,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{data_length_exceed:{code:901,httpStatus:403,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},getUserInfoByUserId:{range:"4,110,204,900",localErrors:{getUserInfoByUserId:{validation_invalid:{code:110,retryable:!1}}},errors:{usercount_exceed:{code:900,httpStatus:400,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},getUserInfoByAttribute:{range:"4,110,204,900",localErrors:{getUserInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{usercount_exceed:{code:900,httpStatus:400,retryable:!1},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},subscribeUsersInfo:{range:"4,202,210,303,1600,1601",errors:{unauthorized:{code:202,httpStatus:401,retryable:!0},forbidden:{code:210,httpStatus:403,aliases:["operation forbidden"],matchField:"error_description",matchPattern:"metadata subscription not allow",retryable:!1},subscriber_limit_exceeded:{code:1600,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscription count exceeds limit",retryable:!1},target_limit_exceeded:{code:1601,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscribed count exceeds limit",retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0},server_unknown_error:{code:303,httpStatus:500,retryable:!0}}},unsubscribeUsersInfo:{range:"4,202,210,303,1600,1601",errors:{unauthorized:{code:202,httpStatus:401,retryable:!0},forbidden:{code:210,httpStatus:403,aliases:["operation forbidden"],matchField:"error_description",matchPattern:"metadata subscription not allow",retryable:!1},subscriber_limit_exceeded:{code:1600,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscription count exceeds limit",retryable:!1},target_limit_exceeded:{code:1601,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscribed count exceeds limit",retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0},server_unknown_error:{code:303,httpStatus:500,retryable:!0}}},getSubscribedUsers:{range:"4,202,210,303,1600,1601",errors:{unauthorized:{code:202,httpStatus:401,retryable:!0},forbidden:{code:210,httpStatus:403,aliases:["operation forbidden"],matchField:"error_description",matchPattern:"metadata subscription not allow",retryable:!1},subscriber_limit_exceeded:{code:1600,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscription count exceeds limit",retryable:!1},target_limit_exceeded:{code:1601,httpStatus:400,matchField:"error_description",matchPattern:"metadata subscribed count exceeds limit",retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0},server_unknown_error:{code:303,httpStatus:500,retryable:!0}}}}}),x=class{constructor(){this.capabilities=["userInfo:read","rawNotify:userInfo"],this.client=null,this.eventContext=null,this.restClient=null,this.restBaseUrl=null,this.restToken=null}bind(e,t){this.client=e,this.eventContext=t??null}addEventHandler(e,t){this.eventContext?.addEventHandler(e,t)}removeEventHandler(e){this.eventContext?.removeEventHandler(e)}handleRawNotify(e){if("userInfo"!==e.type)return;const t=this.client,r=t?.getCacheManager();if(!t||!r||!t.getCurrentUserId())return;const s=e.payload,n=(e=>{const t={};for(const[r,s]of Object.entries(e.metadata)){const e=S(r,s);e&&Object.assign(t,e)}return{userId:e.userId,attributes:t,lastModified:e.lastModified,source:"subscribe_metadata_updated"===e.notifyType?"subscription":"contact_metadata_updated"===e.notifyType?"contact":"own"}})(s);if(!n)return;const o=r.applyUserInfoNotifyPatch(n);if(!o.applied)return void a.debug("User-info notify ignored",{userId:n.userId,notifyType:s.notifyType,reason:o.reason,lastModified:n.lastModified});if(r.updateUserInfoSummaryFromRuntime(n.userId),t.refreshConversationDisplayFromUserInfos?.([{userId:n.userId,lastModified:n.lastModified}]),"subscription"===n.source)return void this.eventContext?.dispatch?.("onUserInfoUpdated",[o.record.profile]);if("own"===n.source)return void this.eventContext?.dispatch?.("onOwnInfoUpdated",o.record.profile);const i=t.getContactSnapshot()?.items.find(e=>e.userId===n.userId);this.eventContext?.dispatch?.(g.CONTACT_INFO_UPDATED,{userInfo:o.record.profile,contact:i})}async getUserInfoByUserId(e){return this.runOperation("getUserInfoByUserId",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=c(l(e.userIds,"params.userIds")),n=p(t);a.debug("UserInfoManager getUserInfoByUserId",{userIds:s.targets});const o=await r.request(n,{method:"POST",body:s,operation:"getUserInfoByUserId"}),i=this.normalizeFetchEnvelope(o,s.targets);return this.writeCache(i),i.map(e=>e.profile)})}async getUserInfoByAttribute(e){return this.runOperation("getUserInfoByAttribute",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=h(l(e.userIds,"params.userIds"),f(e.attributes,"params.attributes")),n=p(t);a.debug("UserInfoManager getUserInfoByAttribute",{userIds:s.targets,attributes:s.properties});const o=await r.request(n,{method:"POST",body:s,operation:"getUserInfoByAttribute"}),i=this.normalizeFetchEnvelope(o,s.targets);return this.writeCache(i),i.map(e=>e.profile)})}async subscribeUsersInfo(e){return this.runOperation("subscribeUsersInfo",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=(e=>U(e))(t),n=w(e.userIds);a.debug("UserInfoManager subscribeUsersInfo",{userIds:n.usernames}),await r.request(s,{method:"POST",body:n,operation:"subscribeUsersInfo"})})}async unsubscribeUsersInfo(e){return this.runOperation("unsubscribeUsersInfo",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=v(t,e.userIds);a.debug("UserInfoManager unsubscribeUsersInfo",{userIds:l(e.userIds,"params.userIds")}),await r.request(s,{method:"DELETE",operation:"unsubscribeUsersInfo"})})}async getSubscribedUsers(){return this.runOperation("getSubscribedUsers",async()=>{const e=this.getRestContextOrThrow(),t=this.getRestClient(e),r=(e=>U(e))(e);a.debug("UserInfoManager getSubscribedUsers",{userId:e.userId});const s=(e=>{const t=e&&"object"==typeof e?e:null;if(!t||!Array.isArray(t.data))return[];const r=[],s=/* @__PURE__ */new Set;for(const n of t.data){if("string"!=typeof n)continue;const e=n.trim();e&&!s.has(e)&&(s.add(e),r.push(e))}return r})(await t.request(r,{method:"GET",operation:"getSubscribedUsers"}));return 0===s.length?[]:await this.getUserInfoByUserId({userIds:s})})}async updateOwnInfo(e){return this.runOperation("updateOwnInfo",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=b(e),n=m(t);a.debug("UserInfoManager updateOwnInfo",{userId:t.userId,fields:this.getUpdatedFieldNames(e)});const o=await r.request(n,{method:"PUT",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s,operation:"updateOwnInfo"}),i=this.normalizeUpdateEnvelope(o,t.userId,this.buildFallbackProfile(t.userId,e));return this.writeCache([i]),this.dispatchSelfUpdate(i.profile),i.profile})}async updateOwnInfoByAttribute(e,t){return this.runOperation("updateOwnInfoByAttribute",async()=>{const r=this.getRestContextOrThrow(),s=this.getRestClient(r),n=y(e,t),o=m(r);a.debug("UserInfoManager updateOwnInfoByAttribute",{userId:r.userId,attribute:e});const i=await s.request(o,{method:"PUT",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n,operation:"updateOwnInfoByAttribute"}),d=this.normalizeUpdateEnvelope(i,r.userId,{userId:r.userId,[e]:t});return this.writeCache([d]),this.dispatchSelfUpdate(d.profile),d.profile})}async runOperation(e,t){try{return await t()}catch(r){throw this.normalizeOperationError(e,r)}}normalizeOperationError(e,t){return t instanceof o?t:(a.warn("UserInfoManager operation failed",{operation:e,message:t instanceof Error?t.message:String(t)}),new o(`${e} failed`))}getRestContextOrThrow(){if(this.client)return this.client.getRestContext();throw new n("UserInfoManager is not bound to client",{code:s.VALIDATION_REQUIRED,details:{fields:[{path:"userInfoManager.client",message:"client is required",rule:"required"}]}})}getRestClient(e){return this.restClient&&this.restBaseUrl===e.restBaseUrl&&this.restToken===e.token||(this.restClient=new i(e.restBaseUrl,{errorMap:O,requestAdapter:this.client?.getRequestAdapter?.(),includeRequestId:!0}),this.restClient.setAuthToken(e.token),this.restBaseUrl=e.restBaseUrl,this.restToken=e.token),this.restClient}normalizeFetchEnvelope(e,t){return I(e,t)}normalizeUpdateEnvelope(t,r,s){const n=e(t)?t:null,a=(n&&e(n.data)?n.data:null)??(n&&this.looksLikeUserInfoAttributes(n)?n:null),o=n&&"number"==typeof n.lastModified?n.lastModified:void 0;return{profile:a?this.toUserInfo(r,a):{userId:r,...s??{}},lastModified:o}}toUserInfo(e,t){const r={userId:e};return"string"==typeof t.nickname&&(r.nickname=t.nickname),"string"==typeof t.avatarurl?r.avatarUrl=t.avatarurl:"string"==typeof t.avatarUrl&&(r.avatarUrl=t.avatarUrl),"string"==typeof t.mail&&(r.mail=t.mail),"string"==typeof t.phone&&(r.phone=t.phone),"string"!=typeof t.gender&&"number"!=typeof t.gender&&"boolean"!=typeof t.gender||(r.gender=t.gender),"string"==typeof t.sign&&(r.sign=t.sign),"string"==typeof t.birth&&(r.birth=t.birth),"string"==typeof t.ext&&(r.ext=t.ext),r}looksLikeUserInfoAttributes(t){return!!e(t)&&("nickname"in t||"avatarurl"in t||"avatarUrl"in t||"mail"in t||"phone"in t||"gender"in t||"sign"in t||"birth"in t||"ext"in t)}buildFallbackProfile(e,t){const r={userId:e},s=r;for(const n of C)n in t&&(s[n]=t[n]);return r}getUpdatedFieldNames(e){return C.filter(t=>t in e)}projectToSummary(e){const r=Date.now(),s=t(e.lastModified);return{userId:e.profile.userId,nickname:e.profile.nickname,avatarUrl:e.profile.avatarUrl,sign:e.profile.sign,ext:e.profile.ext,userInfoUpdateTime:s,lastSyncAt:r,lastAccess:r,lastUpdate:e.lastModified??r}}writeCache(e){if(!this.client||0===e.length)return;const t=this.client.getCacheManager();t&&("function"==typeof t.upsertRuntimeUserInfos&&t.upsertRuntimeUserInfos(e.map(e=>({profile:e.profile,lastModified:e.lastModified,source:e.profile.userId===this.client?.getRestContext().userId?"update":"fetch"}))),t.setUserInfoSummaries(e.map(e=>this.projectToSummary(e))))}dispatchSelfUpdate(e){this.client?.dispatchOwnInfoUpdated?.(e)}};x.key="userInfoManager";let T=x;export{T as UserInfoManager};
@@ -0,0 +1,2 @@
1
+ import type { UserInfoNotifyPatch, UserInfoRawNotifyEvent } from '../../types/user-info';
2
+ export declare const normalizeUserInfoNotify: (event: UserInfoRawNotifyEvent) => UserInfoNotifyPatch | null;
@@ -0,0 +1,28 @@
1
+ import type { UserInfoSummary } from '../../cache/cache-types';
2
+ import type { UserInfo, UserInfoNotifyPatch } from '../../types/user-info';
3
+ export type UserInfoRuntimeSource = 'fetch' | 'update' | 'subscription_notify' | 'contact_notify' | 'own_notify';
4
+ export interface UserInfoRuntimeRecord {
5
+ readonly profile: UserInfo;
6
+ readonly lastModified: number;
7
+ readonly lastAccess: number;
8
+ readonly source: UserInfoRuntimeSource;
9
+ }
10
+ export interface UserInfoRuntimeUpsertRecord {
11
+ readonly profile: UserInfo;
12
+ readonly lastModified?: number;
13
+ readonly source: UserInfoRuntimeSource;
14
+ }
15
+ export interface UserInfoRuntimeMergeResult {
16
+ readonly applied: boolean;
17
+ readonly reason: 'applied' | 'stale' | 'duplicate';
18
+ readonly record: UserInfoRuntimeRecord;
19
+ }
20
+ export declare const buildUserInfoFromSummary: (summary: UserInfoSummary) => UserInfo;
21
+ export declare const projectUserInfoToSummary: (record: UserInfoRuntimeRecord) => UserInfoSummary;
22
+ export declare class UserInfoRuntimeStore {
23
+ private readonly records;
24
+ clear(): void;
25
+ get(userId: string, updateAccess?: boolean, now?: number): UserInfoRuntimeRecord | null;
26
+ setAll(records: ReadonlyArray<UserInfoRuntimeUpsertRecord>, now?: number): void;
27
+ applyPatch(patch: UserInfoNotifyPatch, fallbackProfile?: Partial<UserInfo>, now?: number): UserInfoRuntimeMergeResult;
28
+ }
@@ -0,0 +1,196 @@
1
+ /**
2
+ * [zh-CN] UserInfoManager 对外管理器实现,负责用户资料查询、更新与缓存桥接。
3
+ * [en-US] Public UserInfoManager implementation for profile fetch, update, and cache projection.
4
+ */
5
+ import type { ChatClient } from '../chat-client';
6
+ import type { EventHandlerId, UserInfoEventHandlerMap } from '../types/event-system';
7
+ import type { ManagerBase, ManagerEventContext, RawNotifyEvent } from '../types/manager';
8
+ import type { FetchUserInfoByAttributeParams, FetchUserInfoByUserIdParams, SubscribeUsersInfoParams, UnsubscribeUsersInfoParams, UpdateOwnInfoParams, UserInfoAttribute, UserInfo } from '../types/user-info';
9
+ export declare class UserInfoManager implements ManagerBase<ChatClient> {
10
+ /** @internal SDK 内部管理器注册键,不对外文档暴露。 */
11
+ static readonly key: "userInfoManager";
12
+ readonly capabilities: readonly ["userInfo:read", "rawNotify:userInfo"];
13
+ private client;
14
+ private eventContext;
15
+ private restClient;
16
+ private restBaseUrl;
17
+ private restToken;
18
+ /**
19
+ * @internal
20
+ * [zh-CN] 绑定 UserInfoManager 到 ChatClient,通常由 SDK 在 `client.userInfoManager` 初始化阶段调用。
21
+ * [en-US] Binds UserInfoManager to ChatClient and is usually called internally during `client.userInfoManager` initialization.
22
+ *
23
+ * @param client - [zh-CN] 已初始化的 ChatClient 实例。 [en-US] Initialized ChatClient instance.
24
+ * @param context - [zh-CN] Manager 事件上下文。 [en-US] Manager event context.
25
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
26
+ */
27
+ bind(client: ChatClient, context?: ManagerEventContext): void;
28
+ /**
29
+ * [zh-CN] 注册用户资料事件处理器,用于接收当前用户资料更新和订阅用户资料变更通知。
30
+ * [en-US] Registers user profile event handlers for current-user updates and subscribed profile changes.
31
+ *
32
+ * @example [zh-CN] 调用示例(注册事件处理器) [en-US] Usage example (register event handlers)
33
+ * ```ts
34
+ * client.userInfoManager.addEventHandler('profile-listener', {
35
+ * onOwnInfoUpdated: profile => {
36
+ * console.log(profile.nickname);
37
+ * },
38
+ * onUserInfoUpdated: users => {
39
+ * console.log(users.map(user => user.userId));
40
+ * },
41
+ * });
42
+ * ```
43
+ *
44
+ * @param id - [zh-CN] 事件处理器 ID,同一个 ID 再次注册会覆盖旧处理器。 [en-US] Event handler ID; registering the same ID again replaces the previous handler.
45
+ * @param handlers - [zh-CN] 用户资料事件处理器集合。 [en-US] User profile event handler map.
46
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
47
+ */
48
+ addEventHandler(id: EventHandlerId, handlers: UserInfoEventHandlerMap): void;
49
+ /**
50
+ * [zh-CN] 移除指定 ID 的用户资料事件处理器,停止接收对应事件回调。
51
+ * [en-US] Removes the user profile event handler with the specified ID and stops its callbacks.
52
+ *
53
+ * @example [zh-CN] 调用示例(移除事件处理器) [en-US] Usage example (remove an event handler)
54
+ * ```ts
55
+ * client.userInfoManager.removeEventHandler('profile-listener');
56
+ * ```
57
+ *
58
+ * @param id - [zh-CN] 注册时传入的事件处理器 ID。 [en-US] Event handler ID used during registration.
59
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
60
+ */
61
+ removeEventHandler(id: EventHandlerId): void;
62
+ /**
63
+ * @internal
64
+ * [zh-CN] 处理 SDK 内部转发的用户资料原始 notify。
65
+ * [en-US] Handles raw user-info notifies forwarded internally by the SDK.
66
+ *
67
+ * @param event - [zh-CN] 用户资料原始通知事件。 [en-US] Raw user-info notify event.
68
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
69
+ */
70
+ handleRawNotify(event: RawNotifyEvent): void;
71
+ /**
72
+ * [zh-CN] 按用户 ID 查询用户资料属性;未指定属性时查询 SDK 默认资料字段。
73
+ * [en-US] Fetches user profile attributes by user IDs; when no attribute projection is provided, SDK default profile fields are returned.
74
+ *
75
+ * @example [zh-CN] 调用示例(按用户 ID 查询) [en-US] Usage example (fetch by user IDs)
76
+ * ```ts
77
+ * const users = await client.userInfoManager.getUserInfoByUserId({
78
+ * userIds: ['alice', 'bob'],
79
+ * });
80
+ * console.log(users[0]?.avatarUrl);
81
+ * ```
82
+ *
83
+ * @param params - [zh-CN] 包含 `userIds` 与可选成功/失败回调的参数对象。 [en-US] Parameter object containing `userIds` and optional success/error callbacks.
84
+ * @returns {Promise<ReadonlyArray<UserInfo>>} [zh-CN] 返回标准化后的用户资料数组,仅包含服务端命中的用户。 [en-US] Returns normalized user profiles and only includes users returned by the server.
85
+ */
86
+ getUserInfoByUserId(params: FetchUserInfoByUserIdParams): Promise<ReadonlyArray<UserInfo>>;
87
+ /**
88
+ * [zh-CN] 按用户 ID 和指定属性集查询用户资料,适合只读取昵称、头像等部分字段。
89
+ * [en-US] Fetches selected user profile attributes by user IDs, useful when only fields such as nickname or avatar are needed.
90
+ *
91
+ * @example [zh-CN] 调用示例(按属性集查询) [en-US] Usage example (fetch by attribute projection)
92
+ * ```ts
93
+ * const users = await client.userInfoManager.getUserInfoByAttribute({
94
+ * userIds: ['alice'],
95
+ * attributes: ['nickname', 'avatarUrl'],
96
+ * });
97
+ * console.log(users[0]?.nickname);
98
+ * ```
99
+ *
100
+ * @param params - [zh-CN] 包含 `userIds`、`attributes` 与可选回调的参数对象。 [en-US] Parameter object containing `userIds`, `attributes`, and optional callbacks.
101
+ * @returns {Promise<ReadonlyArray<UserInfo>>} [zh-CN] 返回标准化后的用户资料数组。 [en-US] Returns normalized user profiles.
102
+ */
103
+ getUserInfoByAttribute(params: FetchUserInfoByAttributeParams): Promise<ReadonlyArray<UserInfo>>;
104
+ /**
105
+ * [zh-CN] 订阅指定陌生人用户的资料变化;订阅成功后可通过用户资料事件处理器接收变更通知。
106
+ * [en-US] Subscribes to profile change notifications of target strangers; after subscription, changes can be received through user profile event handlers.
107
+ *
108
+ * @example [zh-CN] 调用示例(订阅资料变化) [en-US] Usage example (subscribe to profile changes)
109
+ * ```ts
110
+ * await client.userInfoManager.subscribeUsersInfo({
111
+ * userIds: ['alice', 'bob'],
112
+ * });
113
+ * ```
114
+ *
115
+ * @param params - [zh-CN] 包含 `userIds` 与可选回调的参数对象。 [en-US] Parameter object containing `userIds` and optional callbacks.
116
+ * @returns {Promise<void>} [zh-CN] 成功时无返回值。 [en-US] Resolves with no payload on success.
117
+ */
118
+ subscribeUsersInfo(params: SubscribeUsersInfoParams): Promise<void>;
119
+ /**
120
+ * [zh-CN] 取消订阅指定陌生人用户的资料变化;取消后不再接收这些用户的资料变更通知。
121
+ * [en-US] Unsubscribes from profile change notifications of target strangers; after removal, their profile changes are no longer delivered.
122
+ *
123
+ * @example [zh-CN] 调用示例(取消订阅资料变化) [en-US] Usage example (unsubscribe from profile changes)
124
+ * ```ts
125
+ * await client.userInfoManager.unsubscribeUsersInfo({
126
+ * userIds: ['alice'],
127
+ * });
128
+ * ```
129
+ *
130
+ * @param params - [zh-CN] 包含 `userIds` 与可选回调的参数对象。 [en-US] Parameter object containing `userIds` and optional callbacks.
131
+ * @returns {Promise<void>} [zh-CN] 成功时无返回值。 [en-US] Resolves with no payload on success.
132
+ */
133
+ unsubscribeUsersInfo(params: UnsubscribeUsersInfoParams): Promise<void>;
134
+ /**
135
+ * [zh-CN] 查询当前用户已订阅资料变化的陌生人列表,并返回这些用户的标准化资料。
136
+ * [en-US] Gets the strangers whose profile changes are subscribed by the current user and returns their normalized profiles.
137
+ *
138
+ * @example [zh-CN] 调用示例(查询已订阅用户) [en-US] Usage example (list subscribed users)
139
+ * ```ts
140
+ * const users = await client.userInfoManager.getSubscribedUsers();
141
+ * console.log(users.map(user => user.userId));
142
+ * ```
143
+ *
144
+ * @param this - [zh-CN] 无需传入参数。 [en-US] No parameter is required.
145
+ * @returns {Promise<ReadonlyArray<UserInfo>>} [zh-CN] 返回标准化后的用户资料数组。 [en-US] Returns normalized subscribed user profiles.
146
+ */
147
+ getSubscribedUsers(): Promise<ReadonlyArray<UserInfo>>;
148
+ /**
149
+ * [zh-CN] 更新当前登录用户的一个或多个资料属性,例如昵称、头像、邮箱、手机号、签名或扩展字段。
150
+ * [en-US] Updates one or more profile attributes of the currently logged-in user, such as nickname, avatar, email, phone, signature, or extension data.
151
+ *
152
+ * @example [zh-CN] 调用示例(整对象更新) [en-US] Usage example (patch current profile)
153
+ * ```ts
154
+ * const profile = await client.userInfoManager.updateOwnInfo({
155
+ * nickname: 'Alice',
156
+ * avatarUrl: 'https://example.com/avatar.png',
157
+ * });
158
+ * console.log(profile.userId, profile.nickname);
159
+ * ```
160
+ *
161
+ * @param params - [zh-CN] 至少包含一个可更新字段的参数对象。 [en-US] Patch parameter object that must contain at least one updatable field.
162
+ * @returns {Promise<UserInfo>} [zh-CN] 返回标准化后的当前用户资料。 [en-US] Returns the normalized current user profile.
163
+ */
164
+ updateOwnInfo(params: UpdateOwnInfoParams): Promise<UserInfo>;
165
+ /**
166
+ * [zh-CN] 更新当前登录用户的单个资料属性,适合只修改昵称、头像等一个字段的场景。
167
+ * [en-US] Updates one profile attribute of the currently logged-in user, suitable when only one field such as nickname or avatar needs to change.
168
+ *
169
+ * @example [zh-CN] 调用示例(单属性更新) [en-US] Usage example (single-attribute update)
170
+ * ```ts
171
+ * const profile = await client.userInfoManager.updateOwnInfoByAttribute(
172
+ * 'avatarUrl',
173
+ * 'https://example.com/avatar.png'
174
+ * );
175
+ * console.log(profile.avatarUrl);
176
+ * ```
177
+ *
178
+ * @param attribute - [zh-CN] 需要更新的资料属性。 [en-US] The profile attribute to update.
179
+ * @param value - [zh-CN] 属性值;空字符串、`false`、`0` 都是合法值。 [en-US] Attribute value; empty string, `false`, and `0` are valid.
180
+ * @returns {Promise<UserInfo>} [zh-CN] 返回标准化后的当前用户资料。 [en-US] Returns the normalized current user profile.
181
+ */
182
+ updateOwnInfoByAttribute(attribute: UserInfoAttribute, value: string | number | boolean): Promise<UserInfo>;
183
+ private runOperation;
184
+ private normalizeOperationError;
185
+ private getRestContextOrThrow;
186
+ private getRestClient;
187
+ private normalizeFetchEnvelope;
188
+ private normalizeUpdateEnvelope;
189
+ private toUserInfo;
190
+ private looksLikeUserInfoAttributes;
191
+ private buildFallbackProfile;
192
+ private getUpdatedFieldNames;
193
+ private projectToSummary;
194
+ private writeCache;
195
+ private dispatchSelfUpdate;
196
+ }
@@ -0,0 +1,4 @@
1
+ import type { Message } from '../types';
2
+ export declare const setCombineCompatibleTextSidecar: (message: Message, compatibleText: string | undefined) => void;
3
+ export declare const getCombineCompatibleTextSidecar: (message: Message) => string | undefined;
4
+ export declare const copyCombineCompatibleTextSidecar: (source: Message, target: Message) => void;
@@ -0,0 +1,7 @@
1
+ import type { Message } from '../types';
2
+ export declare const MAX_COMBINE_MESSAGE_COUNT = 300;
3
+ export declare const MAX_COMBINE_LEVEL = 10;
4
+ export declare const ensureCombineItemLimit: (count: number, max?: number) => void;
5
+ export declare const validateCombineMessageList: (messageList: ReadonlyArray<Message>) => void;
6
+ export declare const calculateCombineLevel: (messageList: ReadonlyArray<Message>) => number;
7
+ export declare const ensureCombineLevel: (combineLevel: number) => void;
@@ -0,0 +1,17 @@
1
+ import type { ChatConversationType, Message, MessageType, Sender } from '../types';
2
+ /** 合并消息解码后的子消息结构(内部类型) */
3
+ interface CombineMessageItem {
4
+ msgServerId?: string;
5
+ msgLocalId?: string;
6
+ type: MessageType;
7
+ sender: Sender;
8
+ conversationId: string;
9
+ conversationType: ChatConversationType;
10
+ timestamp: number;
11
+ body: Record<string, unknown>;
12
+ ext?: Record<string, unknown>;
13
+ combineLevel?: number;
14
+ }
15
+ export declare const encodeCombineMessageList: (messageList: ReadonlyArray<Message>) => Uint8Array;
16
+ export declare const decodeCombineMessageList: (payload: Uint8Array) => ReadonlyArray<CombineMessageItem>;
17
+ export {};