easemob-websdk 5.1.0 → 5.1.2

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 (100) hide show
  1. package/bundle/im-sdk-web.iife.js +1 -1
  2. package/chat-client.d.ts +42 -8
  3. package/chunks/{chat-manager-D_KF5qM1.cjs → chat-manager-BFd2Z4oY.cjs} +1 -1
  4. package/chunks/{chat-manager-DCqgMxLm.js → chat-manager-CId_M_e5.js} +1 -1
  5. package/chunks/common-BvlDAw4a.js +1 -0
  6. package/chunks/common-tHGz9VBk.cjs +1 -0
  7. package/chunks/event-system-B62vbKqG.js +1 -0
  8. package/chunks/{event-system-COBJFEIq.cjs → event-system-TYhmgy4K.cjs} +1 -1
  9. package/chunks/group-user-info-resolver-B-dyr__b.cjs +1 -0
  10. package/chunks/group-user-info-resolver-DMccCqez.js +1 -0
  11. package/chunks/index-BBFJYOM8.js +1 -0
  12. package/chunks/{index-Dvvh1nf6.cjs → index-DJPAjXAp.cjs} +1 -1
  13. package/chunks/index-DtWkVcfb.cjs +1 -0
  14. package/chunks/index-l_BUKi77.js +1 -0
  15. package/chunks/light-BcQg8h2W.cjs +1 -0
  16. package/chunks/light-DImBnNes.js +1 -0
  17. package/chunks/{reflection-proto-codec-CjRraw85.js → reflection-proto-codec-7r8Sei3y.js} +1 -1
  18. package/chunks/{reflection-proto-codec-BerStgkC.cjs → reflection-proto-codec-CwrIKT1L.cjs} +1 -1
  19. package/chunks/{session-list-query-rynxSxtv.js → session-list-query-Cvr6rlme.js} +1 -1
  20. package/chunks/{session-list-query-C4OQMvPf.cjs → session-list-query-Dslj2k3t.cjs} +1 -1
  21. package/chunks/{user-info-DfbCp80h.js → user-info-AlshAvdy.js} +1 -1
  22. package/chunks/{user-info-DsDDTJrw.cjs → user-info-DH3aE1gm.cjs} +1 -1
  23. package/config/timeouts.d.ts +11 -0
  24. package/core/connection/connection-manager.d.ts +18 -1
  25. package/core/connection/login-deadline.d.ts +22 -0
  26. package/core/events/event-hub.d.ts +1 -0
  27. package/core/index.d.ts +8 -1
  28. package/core/message/attachment-downloader.d.ts +1 -1
  29. package/core/session-list-sync/session-list-sync-controller.d.ts +5 -0
  30. package/index.cjs +1 -1
  31. package/index.d.ts +11 -9
  32. package/index.js +2 -2
  33. package/log.d.ts +27 -0
  34. package/managers/chat/index.cjs +1 -1
  35. package/managers/chat/index.js +1 -1
  36. package/managers/chat-thread/index.cjs +1 -1
  37. package/managers/chat-thread/index.js +1 -1
  38. package/managers/chatroom/chatroom.d.ts +1 -1
  39. package/managers/chatroom/index.cjs +1 -1
  40. package/managers/chatroom/index.js +1 -1
  41. package/managers/chatroom-manager.d.ts +6 -1
  42. package/managers/contact/index.cjs +1 -1
  43. package/managers/contact/index.js +1 -1
  44. package/managers/group/index.cjs +1 -1
  45. package/managers/group/index.js +1 -1
  46. package/managers/presence/index.cjs +1 -1
  47. package/managers/presence/index.js +1 -1
  48. package/managers/push/index.cjs +1 -1
  49. package/managers/push/index.d.ts +2 -0
  50. package/managers/push/index.js +1 -1
  51. package/managers/push/native-push-controller.d.ts +62 -0
  52. package/managers/push/native-push-normalizer.d.ts +15 -0
  53. package/managers/push-manager.d.ts +63 -4
  54. package/managers/user-info/index.cjs +1 -1
  55. package/managers/user-info/index.js +1 -1
  56. package/managers/user-info-manager.d.ts +3 -2
  57. package/message/combine-payload-codec.d.ts +2 -1
  58. package/package.json +1 -1
  59. package/platform/index.d.ts +1 -1
  60. package/platform/request/default-request-adapter.d.ts +7 -0
  61. package/platform/socket/default-socket-adapter.d.ts +6 -0
  62. package/platform/types.d.ts +22 -2
  63. package/platform/upload/legacy-multipart-upload.d.ts +14 -0
  64. package/platform/upload/legacy-simple-upload.d.ts +3 -0
  65. package/protocol/msync/codec.d.ts +5 -0
  66. package/rest/client.d.ts +0 -4
  67. package/rest/contact-management.d.ts +1 -0
  68. package/rest/dns-config.d.ts +6 -1
  69. package/rest/error-maps/chatroom.d.ts +6 -0
  70. package/rest/error-maps/common.d.ts +3 -0
  71. package/rest/error-maps/contact.d.ts +8 -3
  72. package/rest/error-maps/push.d.ts +13 -1
  73. package/rest/error-maps/user-info.d.ts +51 -3
  74. package/rest/service-url.d.ts +6 -0
  75. package/types/chat-client.d.ts +16 -9
  76. package/types/chatroom.d.ts +3 -34
  77. package/types/event-system.d.ts +52 -1
  78. package/types/index.d.ts +5 -7
  79. package/types/log.d.ts +19 -0
  80. package/types/manager.d.ts +31 -0
  81. package/types/push.d.ts +77 -0
  82. package/upload/attachment-uploader.d.ts +1 -5
  83. package/upload/multipart-upload.d.ts +4 -14
  84. package/upload/simple-upload.d.ts +4 -3
  85. package/upload/types.d.ts +2 -1
  86. package/utils/error-codes.generated.d.ts +1 -0
  87. package/utils/log-reporter.d.ts +1 -7
  88. package/utils/logger.d.ts +28 -2
  89. package/validators/chat-client.d.ts +22 -50
  90. package/validators/message-create.d.ts +18 -18
  91. package/chunks/common-BIpcR2uQ.cjs +0 -1
  92. package/chunks/common-D_DfwSd3.js +0 -1
  93. package/chunks/event-system-D6IJA0C4.js +0 -1
  94. package/chunks/group-user-info-resolver-Ds35Z1Uf.cjs +0 -1
  95. package/chunks/group-user-info-resolver-lEtRdWli.js +0 -1
  96. package/chunks/index-BmwQgZ3E.js +0 -1
  97. package/chunks/index-BsIqq7LU.cjs +0 -1
  98. package/chunks/index-CFMcR5a_.js +0 -1
  99. package/chunks/light-Dg9A1Xmd.js +0 -1
  100. package/chunks/light-dJjIln5b.cjs +0 -1
@@ -0,0 +1,62 @@
1
+ import { PushEventName } from '../../types/event-system';
2
+ import type { ManagerSessionContext, ManagerSessionEndContext } from '../../types/manager';
3
+ import type { PushTokenBoundEvent, PushTokenOperationFailedEvent, SetNativePushOptions } from '../../types/push';
4
+ interface NativePushControllerDependencies {
5
+ readonly requestToken: (params: {
6
+ readonly deviceId: string;
7
+ readonly deviceToken: string;
8
+ readonly notifierName: string;
9
+ readonly timeout?: number;
10
+ }) => Promise<void>;
11
+ readonly dispatch: (eventName: typeof PushEventName.TOKEN_BOUND, payload: PushTokenBoundEvent) => void;
12
+ readonly dispatchFailure: (eventName: typeof PushEventName.TOKEN_BIND_FAILED | typeof PushEventName.TOKEN_REMOVE_FAILED, payload: PushTokenOperationFailedEvent) => void;
13
+ }
14
+ export declare class NativePushController {
15
+ private readonly dependencies;
16
+ private config;
17
+ private session;
18
+ private state;
19
+ private disabledByUser;
20
+ private registrationVersion;
21
+ private binding;
22
+ private lastAttemptedBinding;
23
+ private successfulKey;
24
+ private exhaustedKey;
25
+ private activeBindingKey;
26
+ private pendingCandidate;
27
+ private bindingPromise;
28
+ private lastBindingError;
29
+ private lastRemovalError;
30
+ private removalPromise;
31
+ private manualRemovalInProgress;
32
+ private sessionEndingGeneration;
33
+ private pluginRegistered;
34
+ private readonly delays;
35
+ constructor(dependencies: NativePushControllerDependencies);
36
+ configure(options: SetNativePushOptions): void;
37
+ onSessionReady(context: ManagerSessionContext): void;
38
+ onSessionEnding(context: ManagerSessionEndContext): Promise<void>;
39
+ resetSessionRuntime(): void;
40
+ removePushToken(): Promise<void>;
41
+ private startRegistration;
42
+ private enqueueBinding;
43
+ private drainBindingQueue;
44
+ private bindWithRetry;
45
+ private performManualRemoval;
46
+ private removeWithRetry;
47
+ private disableByUser;
48
+ private clearSessionRuntime;
49
+ private invalidateRegistration;
50
+ private cancelDelays;
51
+ private collectRemovalTargets;
52
+ private resumePendingBinding;
53
+ private isSessionGenerationActive;
54
+ private safeUnregister;
55
+ private isRegistrationActive;
56
+ private createBindingKey;
57
+ private wait;
58
+ private isRetryable;
59
+ private toSdkError;
60
+ private emitFailure;
61
+ }
62
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { NativePushCertificates, NativePushChannel, NativePushPlugin, NativePushTokenResult, NativePushTypeCode, SetNativePushOptions } from '../../types/push';
2
+ export interface NormalizedNativePushConfig {
3
+ readonly plugin: NativePushPlugin;
4
+ readonly certificates: Readonly<NativePushCertificates>;
5
+ readonly signature: string;
6
+ }
7
+ export interface NormalizedNativePushToken {
8
+ readonly token: string;
9
+ readonly channel: Exclude<NativePushChannel, 'normal'>;
10
+ readonly notifierName: string;
11
+ }
12
+ export declare const nativePushChannelFromCode: (code: NativePushTypeCode) => NativePushChannel;
13
+ export declare const normalizeNativePushOptions: (options: SetNativePushOptions) => NormalizedNativePushConfig;
14
+ export declare const isNativePushTokenResult: (value: unknown) => value is NativePushTokenResult;
15
+ export declare const normalizeNativePushToken: (value: unknown, config: NormalizedNativePushConfig) => NormalizedNativePushToken | null;
@@ -2,8 +2,9 @@
2
2
  * PushManager 管理器
3
3
  */
4
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';
5
+ import type { PushEventHandlerMap, EventHandlerId } from '../types/event-system';
6
+ import type { ManagerBase, ManagerEventContext, ManagerSessionContext, ManagerSessionEndContext } from '../types/manager';
7
+ import type { BatchConversationSilentModeResponse, ClearConversationRemindTypeParams, ConversationSilentModeResponse, GetConversationListByRemindTypeParams, GetConversationSilentModeParams, GetConversationSilentModesParams, GetGlobalSilentModeParams, GetPushLanguageParams, GlobalSilentModeResponse, MutedConversationPageResponse, PushLanguageResponse, SetConversationSilentModeParams, SetGlobalSilentModeParams, SetPushLanguageParams, SetNativePushOptions, UploadPushTokenParams } from '../types/push';
7
8
  /**
8
9
  * PushManager 负责 push token、免打扰与语言偏好管理
9
10
  */
@@ -14,15 +15,72 @@ export declare class PushManager implements ManagerBase<ChatClient> {
14
15
  private restClient;
15
16
  private restBaseUrl;
16
17
  private restToken;
18
+ private eventContext;
19
+ private readonly nativePushController;
17
20
  /**
18
21
  * @internal
19
22
  * [zh-CN] 绑定 PushManager 到 ChatClient,通常由 SDK 内部在 `client.pushManager` 初始化阶段调用。 [en-US] Binds PushManager to ChatClient and is usually called internally when `client.pushManager` is initialized.
20
23
  *
21
24
  * @param client - [zh-CN] 已初始化的 ChatClient 实例。 [en-US] Initialized ChatClient instance.
22
- * @param _context - [zh-CN] 预留的管理器上下文(当前未使用)。 [en-US] Reserved manager context (unused for now).
25
+ * @param context - [zh-CN] 管理器事件上下文,用于注册和派发脱敏诊断事件。 [en-US] Manager event context used to register and dispatch sanitized diagnostic events.
23
26
  * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
24
27
  */
25
- bind(client: ChatClient, _context?: ManagerEventContext): void;
28
+ bind(client: ChatClient, context?: ManagerEventContext<PushEventHandlerMap>): void;
29
+ /** @internal [zh-CN] 当前 IM 会话就绪时启动原生 Token 注册。 [en-US] Starts native token registration when the IM session becomes ready. */
30
+ onSessionReady(context: ManagerSessionContext): void;
31
+ /** @internal [zh-CN] 当前 IM 会话结束前尝试解绑原生 Token。 [en-US] Attempts to remove the native token before the IM session ends. */
32
+ onSessionEnding(context: ManagerSessionEndContext): Promise<void>;
33
+ /** @internal [zh-CN] 清理当前会话的原生推送运行时状态。 [en-US] Clears native push runtime state for the current session. */
34
+ resetSessionRuntime(): void;
35
+ /**
36
+ * [zh-CN] 配置 uni-app UTS 原生推送插件与环信证书。配置同步完成,Token 注册和绑定在后台执行。
37
+ * [en-US] Configures the uni-app UTS native push plugin and Easemob certificates. Configuration is synchronous; token registration and binding run in the background.
38
+ *
39
+ * @example [zh-CN] 配置 UTS 插件 [en-US] Configure a UTS plugin
40
+ * ```ts
41
+ * client.pushManager.setNativePush({
42
+ * plugin: { onRegister, unRegister },
43
+ * certificates: { fcm: 'fcm-certificate', apns: 'apns-certificate' },
44
+ * });
45
+ * ```
46
+ * @param options - [zh-CN] 插件函数对象和至少一个通道证书名称。 [en-US] Plugin function object and at least one channel certificate name.
47
+ * @returns {void} [zh-CN] 无返回值;绑定结果通过 PushManager 事件通知。 [en-US] Returns nothing; binding results are delivered through PushManager events.
48
+ */
49
+ setNativePush(options: SetNativePushOptions): void;
50
+ /**
51
+ * [zh-CN] 移除当前设备的原生 Push Token。成功后插件保持停用,需再次调用 `setNativePush()` 才会启用。
52
+ * [en-US] Removes the native push token for the current device. The plugin remains disabled until `setNativePush()` is called again.
53
+ *
54
+ * @example [zh-CN] 关闭当前设备离线推送 [en-US] Disable offline push for the current device
55
+ * ```ts
56
+ * await client.pushManager.removePushToken();
57
+ * ```
58
+ * @returns {Promise<void>} [zh-CN] 服务端解绑成功或当前无已知绑定时 resolve。 [en-US] Resolves after server removal succeeds or when no binding is known.
59
+ */
60
+ removePushToken(): Promise<void>;
61
+ /**
62
+ * [zh-CN] 注册 PushManager 事件处理器。
63
+ * [en-US] Registers PushManager event handlers.
64
+ * @example
65
+ * ```ts
66
+ * client.pushManager.addEventHandler('push', { onPushTokenBound: console.log });
67
+ * ```
68
+ * @param id - [zh-CN] 处理器唯一 ID。 [en-US] Unique handler ID.
69
+ * @param handlers - [zh-CN] 原生推送事件处理器。 [en-US] Native push event handlers.
70
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
71
+ */
72
+ addEventHandler(id: EventHandlerId, handlers: PushEventHandlerMap): void;
73
+ /**
74
+ * [zh-CN] 移除 PushManager 事件处理器。
75
+ * [en-US] Removes PushManager event handlers.
76
+ * @example
77
+ * ```ts
78
+ * client.pushManager.removeEventHandler('push');
79
+ * ```
80
+ * @param id - [zh-CN] 处理器唯一 ID。 [en-US] Unique handler ID.
81
+ * @returns {void} [zh-CN] 无返回值。 [en-US] Returns nothing.
82
+ */
83
+ removeEventHandler(id: EventHandlerId): void;
26
84
  /**
27
85
  * [zh-CN] 上传或覆盖设备 Push Token。成功时仅表示请求完成,不返回业务数据。 [en-US] Uploads or replaces the device push token. On success it only resolves and returns no business payload.
28
86
  *
@@ -39,6 +97,7 @@ export declare class PushManager implements ManagerBase<ChatClient> {
39
97
  * @returns {Promise<void>} [zh-CN] 成功时 resolve,无返回值。 [en-US] Resolves on success with no return value.
40
98
  */
41
99
  uploadPushToken(params: UploadPushTokenParams): Promise<void>;
100
+ private requestNativePushToken;
42
101
  /**
43
102
  * [zh-CN] 设置 App 级(全局)免打扰规则,支持提醒类型、持续时长、时间区间三种模式。 [en-US] Sets app-level (global) silent mode rule, supporting remind type, duration, and interval modes.
44
103
  *
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/cache-utils-gowrxNr8.cjs"),t=require("../../chunks/profile-version-njNs7R5-.cjs"),r=require("../../chunks/common-BIpcR2uQ.cjs"),s=require("../../chunks/user-info-DsDDTJrw.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/cache-utils-gowrxNr8.cjs"),t=require("../../chunks/profile-version-njNs7R5-.cjs"),r=require("../../chunks/common-tHGz9VBk.cjs"),s=require("../../chunks/user-info-DH3aE1gm.cjs"),n=require("../../chunks/event-system-TYhmgy4K.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}},c=["nickname","avatarUrl","mail","phone","gender","sign","birth","ext"],l=r.mergeRuntimeErrorMaps(r.COMMON_ERROR_MAP,{common:{},apis:{updateOwnUserInfo:{range:"4,110,204,303,505,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{service_not_enabled:{code:505,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"user metadata service not allow"},data_length_exceed:{code:901,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"exceeds"},concurrent_update_conflict:{code:303,httpStatus:409,retryable:!0,matchField:"desc",matchPattern:"Concurrent"},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfo:{range:"4,110,204,303,505,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{service_not_enabled:{code:505,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"user metadata service not allow"},data_length_exceed:{code:901,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"exceeds"},concurrent_update_conflict:{code:303,httpStatus:409,retryable:!0,matchField:"desc",matchPattern:"Concurrent"},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfoByAttribute:{range:"4,110,204,303,505,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{service_not_enabled:{code:505,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"user metadata service not allow"},data_length_exceed:{code:901,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"exceeds"},concurrent_update_conflict:{code:303,httpStatus:409,retryable:!0,matchField:"desc",matchPattern:"Concurrent"},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),this.completeFetchedProfiles(d,a.targets)})}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),this.completeFetchedProfiles(d,a.targets)})}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:l,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)}completeFetchedProfiles(e,t){const r=new Map(e.map(e=>[e.profile.userId,e.profile]));return t.map(e=>r.get(e)??{userId:e})}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 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.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 h=p;exports.UserInfoManager=h;
@@ -1 +1 @@
1
- import{i as e}from"../../chunks/cache-utils-B99glc0H.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,i as u}from"../../chunks/common-D_DfwSd3.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-DfbCp80h.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};
1
+ import{i as e}from"../../chunks/cache-utils-B99glc0H.js";import{a as t}from"../../chunks/profile-version-DLMz8lqW.js";import{p as r,E as s,V as a,l as n,S as o,h as i,m as d,j as u}from"../../chunks/common-BvlDAw4a.js";import{c,b as l,a as p,d as h,e as f,f as m,g as b,h as y,i as I}from"../../chunks/user-info-AlshAvdy.js";import{a as g}from"../../chunks/event-system-B62vbKqG.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")=>c(e,t),w=e=>{const t=_(e);if(t.length>100)throw((e,t,r,n=s.VALIDATION_INVALID_FORMAT)=>new a(e,{code:n,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"],x=d(u,{common:{},apis:{updateOwnUserInfo:{range:"4,110,204,303,505,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{service_not_enabled:{code:505,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"user metadata service not allow"},data_length_exceed:{code:901,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"exceeds"},concurrent_update_conflict:{code:303,httpStatus:409,retryable:!0,matchField:"desc",matchPattern:"Concurrent"},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfo:{range:"4,110,204,303,505,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{service_not_enabled:{code:505,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"user metadata service not allow"},data_length_exceed:{code:901,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"exceeds"},concurrent_update_conflict:{code:303,httpStatus:409,retryable:!0,matchField:"desc",matchPattern:"Concurrent"},resource_not_found:{code:204,httpStatus:404,retryable:!1},rate_limit:{code:4,httpStatus:429,retryable:!0}}},updateOwnInfoByAttribute:{range:"4,110,204,303,505,901",localErrors:{updateOwnInfo:{validation_invalid:{code:110,retryable:!1}},updateOwnInfoByAttribute:{validation_invalid:{code:110,retryable:!1}}},errors:{service_not_enabled:{code:505,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"user metadata service not allow"},data_length_exceed:{code:901,httpStatus:403,retryable:!1,matchField:"desc",matchPattern:"exceeds"},concurrent_update_conflict:{code:303,httpStatus:409,retryable:!0,matchField:"desc",matchPattern:"Concurrent"},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}}}}}),O=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,a=(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(!a)return;const o=r.applyUserInfoNotifyPatch(a);if(!o.applied)return void n.debug("User-info notify ignored",{userId:a.userId,notifyType:s.notifyType,reason:o.reason,lastModified:a.lastModified});if(r.updateUserInfoSummaryFromRuntime(a.userId),t.refreshConversationDisplayFromUserInfos?.([{userId:a.userId,lastModified:a.lastModified}]),"subscription"===a.source)return void this.eventContext?.dispatch?.("onUserInfoUpdated",[o.record.profile]);if("own"===a.source)return void this.eventContext?.dispatch?.("onOwnInfoUpdated",o.record.profile);const i=t.getContactSnapshot()?.items.find(e=>e.userId===a.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=l(c(e.userIds,"params.userIds")),a=p(t);n.debug("UserInfoManager getUserInfoByUserId",{userIds:s.targets});const o=await r.request(a,{method:"POST",body:s,operation:"getUserInfoByUserId"}),i=this.normalizeFetchEnvelope(o,s.targets);return this.writeCache(i),this.completeFetchedProfiles(i,s.targets)})}async getUserInfoByAttribute(e){return this.runOperation("getUserInfoByAttribute",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=h(c(e.userIds,"params.userIds"),f(e.attributes,"params.attributes")),a=p(t);n.debug("UserInfoManager getUserInfoByAttribute",{userIds:s.targets,attributes:s.properties});const o=await r.request(a,{method:"POST",body:s,operation:"getUserInfoByAttribute"}),i=this.normalizeFetchEnvelope(o,s.targets);return this.writeCache(i),this.completeFetchedProfiles(i,s.targets)})}async subscribeUsersInfo(e){return this.runOperation("subscribeUsersInfo",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=(e=>U(e))(t),a=w(e.userIds);n.debug("UserInfoManager subscribeUsersInfo",{userIds:a.usernames}),await r.request(s,{method:"POST",body:a,operation:"subscribeUsersInfo"})})}async unsubscribeUsersInfo(e){return this.runOperation("unsubscribeUsersInfo",async()=>{const t=this.getRestContextOrThrow(),r=this.getRestClient(t),s=v(t,e.userIds);n.debug("UserInfoManager unsubscribeUsersInfo",{userIds:c(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);n.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 a of t.data){if("string"!=typeof a)continue;const e=a.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=m(e),a=b(t);n.debug("UserInfoManager updateOwnInfo",{userId:t.userId,fields:this.getUpdatedFieldNames(e)});const o=await r.request(a,{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),a=y(e,t),o=b(r);n.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:a,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:(n.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 a("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:x,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)}completeFetchedProfiles(e,t){const r=new Map(e.map(e=>[e.profile.userId,e.profile]));return t.map(e=>r.get(e)??{userId:e})}normalizeUpdateEnvelope(t,r,s){const a=e(t)?t:null,n=(a&&e(a.data)?a.data:null)??(a&&this.looksLikeUserInfoAttributes(a)?a:null),o=a&&"number"==typeof a.lastModified?a.lastModified:void 0;return{profile:n?this.toUserInfo(r,n):{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 a of C)a in t&&(s[a]=t[a]);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)}};O.key="userInfoManager";let T=O;export{T as UserInfoManager};
@@ -81,7 +81,7 @@ export declare class UserInfoManager implements ManagerBase<ChatClient> {
81
81
  * ```
82
82
  *
83
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.
84
+ * @returns {Promise<ReadonlyArray<UserInfo>>} [zh-CN] 按请求顺序返回标准化后的用户资料数组;未设置资料的用户返回仅包含 `userId` 的对象。 [en-US] Returns normalized user profiles in request order; users without profile metadata are represented by an object containing only `userId`.
85
85
  */
86
86
  getUserInfoByUserId(params: FetchUserInfoByUserIdParams): Promise<ReadonlyArray<UserInfo>>;
87
87
  /**
@@ -98,7 +98,7 @@ export declare class UserInfoManager implements ManagerBase<ChatClient> {
98
98
  * ```
99
99
  *
100
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.
101
+ * @returns {Promise<ReadonlyArray<UserInfo>>} [zh-CN] 按请求顺序返回标准化后的用户资料数组;未设置所查询属性的用户返回仅包含 `userId` 的对象。 [en-US] Returns normalized user profiles in request order; users without the requested attributes are represented by an object containing only `userId`.
102
102
  */
103
103
  getUserInfoByAttribute(params: FetchUserInfoByAttributeParams): Promise<ReadonlyArray<UserInfo>>;
104
104
  /**
@@ -185,6 +185,7 @@ export declare class UserInfoManager implements ManagerBase<ChatClient> {
185
185
  private getRestContextOrThrow;
186
186
  private getRestClient;
187
187
  private normalizeFetchEnvelope;
188
+ private completeFetchedProfiles;
188
189
  private normalizeUpdateEnvelope;
189
190
  private toUserInfo;
190
191
  private looksLikeUserInfoAttributes;
@@ -12,6 +12,7 @@ interface CombineMessageItem {
12
12
  ext?: Record<string, unknown>;
13
13
  combineLevel?: number;
14
14
  }
15
- export declare const encodeCombineMessageList: (messageList: ReadonlyArray<Message>) => Uint8Array;
15
+ type CombineMessageItemEncoder = (item: Message, index: number) => Uint8Array;
16
+ export declare const encodeCombineMessageList: (messageList: ReadonlyArray<Message>, encodeItem: CombineMessageItemEncoder) => Uint8Array;
16
17
  export declare const decodeCombineMessageList: (payload: Uint8Array) => ReadonlyArray<CombineMessageItem>;
17
18
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easemob-websdk",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "High-performance, type-safe, extensible instant messaging SDK",
5
5
  "homepage": "https://www.easemob.com/",
6
6
  "type": "module",
@@ -11,7 +11,7 @@ export { createStaticProtoAdapter, getStaticProtoRoot } from './proto/static-pro
11
11
  export { ProtoCodecRegistry } from './proto/proto-adapter';
12
12
  export { isPlatformUploadError, mapUploadAdapterError } from './upload/upload-error-mapper';
13
13
  export { normalizeUploadSource } from './upload/upload-source';
14
- export type { CreatePlatformAdapterOptions, HttpMethod, PlatformAdapter, PlatformAdapterError, PlatformAdapterOverrides, PlatformAdapterOverridesResolver, PlatformAdapterProfile, PlatformCapability, PlatformFactoryResult, GeneratedImageResult, PlatformErrorCode, PlatformErrorStage, ImageGenerateOptions, ImageInfoResult, ImageProcessor, ProtoAdapter, RequestAdapter, RequestConfig, RequestResponse, RuntimeAdapter, RuntimePlatform, SocketAdapter, SocketConnectConfig, SocketLike, SocketMessageData, SocketReadyState, SocketSendData, StorageAdapter, UploadAdapter, UploadConfig, UploadProgress, UploadResult, UploadSource, UploadSourceType, } from './types';
14
+ export type { CreatePlatformAdapterOptions, HttpMethod, PlatformAdapter, PlatformAdapterError, PlatformAdapterOverrides, PlatformAdapterOverridesResolver, PlatformAdapterProfile, PlatformCapability, PlatformFactoryResult, GeneratedImageResult, PlatformErrorCode, PlatformErrorStage, ImageGenerateOptions, ImageInfoResult, ImageProcessor, ProtoAdapter, RequestAdapter, RequestConfig, RequestResponse, RuntimeAdapter, RuntimePlatform, SocketAdapter, SocketConnectConfig, SocketLike, SocketMessageData, SocketReadyState, SocketSendData, StorageAdapter, TransportAdapter, UploadAdapter, UploadConfig, UploadProgress, UploadResult, UploadSource, UploadSourceType, } from './types';
15
15
  export type { ProtoTypeCodec } from './proto/proto-adapter';
16
16
  export type { NormalizedUploadSource } from './upload/upload-source';
17
17
  export { PLATFORM_ERROR_CODE, PLATFORM_ERROR_STAGE, RUNTIME_PLATFORMS, SOCKET_READY_STATE, createPlatformError, } from './types';
@@ -0,0 +1,7 @@
1
+ import { type RequestAdapter } from '../types';
2
+ /**
3
+ * [zh-CN] 创建一次性捕获全局 fetch 的浏览器兼容请求适配器。
4
+ * [en-US] Creates a browser-compatibility request adapter that captures global fetch once.
5
+ */
6
+ export declare const createDefaultWebRequestAdapter: () => RequestAdapter;
7
+ export declare const resolveRequestAdapter: (requestAdapter?: RequestAdapter) => RequestAdapter;
@@ -0,0 +1,6 @@
1
+ import { type SocketAdapter } from '../types';
2
+ /**
3
+ * [zh-CN] 解析显式 SocketAdapter;仅为旧的独立内部构造入口保留浏览器默认兼容能力。
4
+ * [en-US] Resolves an explicit SocketAdapter while retaining browser-default compatibility for legacy standalone internal construction.
5
+ */
6
+ export declare const resolveSocketAdapter: (socketAdapter?: SocketAdapter) => SocketAdapter;
@@ -126,9 +126,11 @@ export interface RequestConfig {
126
126
  export interface RequestResponse<TData> {
127
127
  /** [zh-CN] HTTP 状态码。 [en-US] HTTP status code. */
128
128
  readonly status: number;
129
+ /** [zh-CN] HTTP 状态文本;宿主无法提供时可省略。 [en-US] HTTP status text; may be omitted when unavailable from the host. */
130
+ readonly statusText?: string;
129
131
  /** [zh-CN] 响应头。 [en-US] Response headers. */
130
132
  readonly headers: Record<string, string>;
131
- /** [zh-CN] 响应数据。 [en-US] Response data. */
133
+ /** [zh-CN] 响应数据;空正文或无法解析的 JSON 必须作为响应保留,不得改报网络错误。 [en-US] Response data; an empty body or malformed JSON must remain a response instead of being reclassified as a network failure. */
132
134
  readonly data: TData;
133
135
  }
134
136
  /**
@@ -241,12 +243,16 @@ export interface UploadProgress {
241
243
  export interface UploadConfig {
242
244
  /** [zh-CN] 上传 URL。 [en-US] Upload URL. */
243
245
  readonly url: string;
246
+ /** [zh-CN] HTTP 方法,默认 POST。 [en-US] HTTP method; defaults to POST. */
247
+ readonly method?: HttpMethod;
244
248
  /** [zh-CN] 上传请求头。 [en-US] Upload request headers. */
245
249
  readonly headers?: Record<string, string>;
246
250
  /** [zh-CN] 待上传资源。 [en-US] Resource to upload. */
247
251
  readonly source: UploadSource;
248
252
  /** [zh-CN] 附加表单字段。 [en-US] Additional form fields. */
249
253
  readonly fields?: Record<string, string>;
254
+ /** [zh-CN] 文件表单字段名,默认 file。 [en-US] File form field name; defaults to file. */
255
+ readonly fileFieldName?: string;
250
256
  /** [zh-CN] 上传超时时间,单位毫秒。 [en-US] Upload timeout in milliseconds. */
251
257
  readonly timeoutMs?: number;
252
258
  /** [zh-CN] 上传取消信号。 [en-US] Upload cancellation signal. */
@@ -269,7 +275,7 @@ export interface UploadResult {
269
275
  * [en-US] Cross-platform file upload adapter.
270
276
  */
271
277
  export interface UploadAdapter {
272
- /** [zh-CN] 上传文件。 [en-US] Uploads a file. */
278
+ /** [zh-CN] 按 method、fileFieldName、取消、超时和进度契约上传文件或分片。 [en-US] Uploads a file or chunk while honoring method, fileFieldName, cancellation, timeout, and progress semantics. */
273
279
  upload(config: UploadConfig): Promise<UploadResult>;
274
280
  }
275
281
  /**
@@ -340,6 +346,18 @@ export interface SocketAdapter {
340
346
  /** [zh-CN] 建立 Socket 连接。 [en-US] Establishes a socket connection. */
341
347
  connect(config: SocketConnectConfig): Promise<SocketLike>;
342
348
  }
349
+ /**
350
+ * [zh-CN] SDK 使用的原子网络传输适配器;三个能力必须完整提供,缺失时初始化失败且不会回退到全局网络对象。
351
+ * [en-US] Atomic network transport adapter used by the SDK; all three capabilities are required, and a missing capability fails initialization without falling back to network globals.
352
+ */
353
+ export interface TransportAdapter {
354
+ /** [zh-CN] HTTP 请求适配器。 [en-US] HTTP request adapter. */
355
+ readonly request: RequestAdapter;
356
+ /** [zh-CN] 文件上传适配器。 [en-US] File upload adapter. */
357
+ readonly upload: UploadAdapter;
358
+ /** [zh-CN] Socket 适配器。 [en-US] Socket adapter. */
359
+ readonly socket: SocketAdapter;
360
+ }
343
361
  /**
344
362
  * [zh-CN] 宿主运行时能力适配器。
345
363
  * [en-US] Host runtime capability adapter.
@@ -462,6 +480,8 @@ export interface CreatePlatformAdapterOptions {
462
480
  readonly prefer?: RuntimePlatform;
463
481
  /** [zh-CN] 显式运行时对象,用于非标准打包器或宿主;缺省时 SDK 自动收集全局能力。 [en-US] Explicit runtime object for non-standard bundlers or hosts; SDK collects global capabilities when omitted. */
464
482
  readonly runtimeInput?: object;
483
+ /** [zh-CN] 原子网络传输适配器;提供后 request、upload、socket 必须完整且全部来自该实例,否则初始化失败。 [en-US] Atomic network transport adapter; when provided, request, upload, and socket must all be complete and come from this instance, otherwise initialization fails. */
484
+ readonly transportAdapter?: TransportAdapter;
465
485
  /** [zh-CN] 可选适配器覆盖;未提供的能力继续使用 SDK 默认实现。 [en-US] Optional adapter overrides; omitted capabilities continue to use SDK defaults. */
466
486
  readonly overrides?: PlatformAdapterOverrides | PlatformAdapterOverridesResolver;
467
487
  }
@@ -0,0 +1,14 @@
1
+ import type { UploadRequest } from '../../upload/types';
2
+ import { buildUploadResult } from '../../upload/utils';
3
+ import type { RequestAdapter } from '../types';
4
+ import type { DataReportOperationHandle } from '../../data-report/types';
5
+ export declare const multipartUpload: (request: UploadRequest) => Promise<ReturnType<typeof buildUploadResult>>;
6
+ export declare const multipartAbort: (options: {
7
+ restBaseUrl: string;
8
+ orgName: string;
9
+ appName: string;
10
+ token: string;
11
+ uuid: string;
12
+ requestAdapter?: RequestAdapter;
13
+ dataReportOperation?: DataReportOperationHandle;
14
+ }) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { UploadRequest } from '../../upload/types';
2
+ import { buildUploadResult } from '../../upload/utils';
3
+ export declare const simpleUpload: (request: UploadRequest) => Promise<ReturnType<typeof buildUploadResult>>;
@@ -115,6 +115,11 @@ export declare class MsyncCodec {
115
115
  * 编码聊天消息(文本/命令/自定义)
116
116
  */
117
117
  encodeChatMessage(message: Message, protocolId: string): Uint8Array;
118
+ /**
119
+ * 编码合并消息文件中的单条 Meta,保持与旧 Web SDK 的合并消息格式兼容。
120
+ */
121
+ encodeCombineMessageMeta(message: Message): Uint8Array;
122
+ private buildChatMeta;
118
123
  encodeActionMessage(action: MessageActionRequest, protocolId: string): Uint8Array;
119
124
  encodeChatRoomOperation(request: ChatRoomOperationRequest, protocolId: string): Uint8Array;
120
125
  decodeServerMessageMeta(metaPayload: Uint8Array): Message | null;
package/rest/client.d.ts CHANGED
@@ -58,10 +58,6 @@ export declare class RestClient {
58
58
  * 发送请求
59
59
  */
60
60
  request<T>(endpoint: string, config?: RequestConfig): Promise<T>;
61
- /**
62
- * 处理错误响应
63
- */
64
- private handleErrorResponse;
65
61
  private handleErrorPayload;
66
62
  /**
67
63
  * GET 请求
@@ -10,6 +10,7 @@ interface ContactListPage {
10
10
  readonly cursor: string;
11
11
  readonly contacts: ReadonlyArray<Contact>;
12
12
  }
13
+ export declare const ADD_CONTACT_SELF_ERROR_MESSAGE = "User ID is invalid: cannot add yourself as a contact";
13
14
  export declare const dedupeUserIds: (userIds: ReadonlyArray<string>) => ReadonlyArray<string>;
14
15
  export declare const normalizeBlocklistEntries: (payload: unknown) => ReadonlyArray<UserInfo>;
15
16
  export declare const normalizeBlocklistAddResult: (payload: unknown) => BlocklistAddResult;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * dnsconfig 请求与解析
3
3
  */
4
+ import { ConnectionError } from '../utils/errors';
4
5
  import type { DnsConfig } from '../types/chat-client';
5
6
  import type { RequestAdapter } from '../platform/types';
6
7
  export declare const DEFAULT_DNS_CONFIG_URLS: string[];
@@ -8,7 +9,6 @@ export interface DnsConfigResult {
8
9
  appKey: string;
9
10
  websocketUrl: string;
10
11
  websocketUrls: string[];
11
- syncWebsocketUrls: string[];
12
12
  baseUrl: string;
13
13
  restBaseUrl: string;
14
14
  dnsConfig: DnsConfig;
@@ -20,9 +20,14 @@ type DnsConfigIdentity = {
20
20
  readonly appId: string;
21
21
  readonly appKey?: never;
22
22
  };
23
+ interface DnsLoginDeadline {
24
+ remainingMs(): number;
25
+ createTimeoutError(): ConnectionError;
26
+ }
23
27
  export declare function resolveDnsConfig(options: DnsConfigIdentity & {
24
28
  baseUrls?: string[];
25
29
  pageProtocol?: 'http' | 'https';
26
30
  requestAdapter?: RequestAdapter;
31
+ loginDeadline?: DnsLoginDeadline;
27
32
  }): Promise<DnsConfigResult>;
28
33
  export {};
@@ -10,8 +10,10 @@ export declare const CHATROOM_ERROR_MAP: {
10
10
  readonly errors: {
11
11
  readonly resource_not_found: {
12
12
  readonly code: 705;
13
+ readonly runtimeMessage: "Chat room does not exist";
13
14
  readonly httpStatus: 404;
14
15
  readonly retryable: false;
16
+ readonly aliases: readonly ["service_resource_not_found"];
15
17
  };
16
18
  };
17
19
  };
@@ -99,8 +101,10 @@ export declare const CHATROOM_ERROR_MAP: {
99
101
  readonly errors: {
100
102
  readonly resource_not_found: {
101
103
  readonly code: 705;
104
+ readonly runtimeMessage: "Chat room does not exist";
102
105
  readonly httpStatus: 404;
103
106
  readonly retryable: false;
107
+ readonly aliases: readonly ["service_resource_not_found"];
104
108
  };
105
109
  };
106
110
  };
@@ -269,8 +273,10 @@ export declare const CHATROOM_ERROR_MAP: {
269
273
  readonly errors: {
270
274
  readonly resource_not_found: {
271
275
  readonly code: 705;
276
+ readonly runtimeMessage: "Chat room does not exist";
272
277
  readonly httpStatus: 404;
273
278
  readonly retryable: false;
279
+ readonly aliases: readonly ["30005"];
274
280
  };
275
281
  };
276
282
  };
@@ -49,6 +49,9 @@ export declare const COMMON_ERROR_MAP: {
49
49
  readonly TIMEOUT: {
50
50
  readonly code: 301;
51
51
  };
52
+ readonly LOGIN_TIMEOUT: {
53
+ readonly code: 301;
54
+ };
52
55
  readonly WEBSOCKET_ERROR: {
53
56
  readonly code: 300;
54
57
  };