easemob-websdk 4.13.0 → 4.15.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easemob-websdk",
3
- "version": "4.13.0",
3
+ "version": "4.15.0",
4
4
  "description": "Easemob chat web sdk",
5
5
  "main": "Easemob-chat",
6
6
  "scripts": {
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.websdk=r():e.websdk=r()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[962],{3770:function(e,r,t){t.r(r),t.d(r,{getPresenceStatus:function(){return h},getSubscribedPresenceList:function(){return p},getSubscribedPresencelist:function(){return f},publishPresence:function(){return i},subscribePresence:function(){return u},unsubscribePresence:function(){return l}}),t(1539),t(8674),t(2526),t(1817),t(2165),t(6992),t(8783),t(3948),t(2222),t(9753);var n=t(4024),s=t(3246),a=t(7360),o=function(e,r,t,n){return new(t||(t=Promise))((function(s,a){function o(e){try{i(n.next(e))}catch(e){a(e)}}function c(e){try{i(n.throw(e))}catch(e){a(e)}}function i(e){var r;e.done?s(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,c)}i((n=n.apply(e,r||[])).next())}))},c=function(e,r){var t,n,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=r.call(e,o)}catch(e){a=[6,e],n=0}finally{t=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};function i(e){return o(this,void 0,void 0,(function(){var r,t,o,i,u,l,p,f,h;return c(this,(function(c){switch(c.label){case 0:if("string"!=typeof e.description)throw Error('Invalid parameter: "description"');return(r=s.XZ.call(this).error)?[2,Promise.reject(r)]:(t=this.context,o=t.accessToken,i=t.orgName,u=t.appName,l=t.userId,p=this.context.jid.clientResource,f={ext:e.description},h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(u,"/users/").concat(l,"/presence/").concat(p,"/1"),type:"POST",dataType:"json",data:JSON.stringify(f),headers:{Authorization:"Bearer "+o,"Content-Type":"application/json"},success:e.success,error:e.error},a.kg.debug("Call publishPresence:",e),[4,n.hj.call(this,h)]);case 1:return c.sent(),[2]}}))}))}function u(e){if(!Array.isArray(e.usernames))throw Error('Invalid parameter: "usernames"');if(!e.usernames.length)throw Error('"usernames" can not be empty');if("number"!=typeof e.expiry)throw Error('Invalid parameter: "expiry"');var r=s.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,o=t.orgName,c=t.appName,i=t.userId,u=t.accessToken,l={usernames:e.usernames},p={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(c,"/users/").concat(i,"/presence/").concat(e.expiry),type:"POST",dataType:"json",data:JSON.stringify(l),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call subscribePresence:",e),n.hj.call(this,p).then((function(e){return e.data={result:null==e?void 0:e.result},e}))}function l(e){return o(this,void 0,void 0,(function(){var r,t,o,i,u,l,p;return c(this,(function(c){switch(c.label){case 0:if(!Array.isArray(e.usernames))throw Error('Invalid parameter: "usernames"');if(!e.usernames.length)throw Error('"usernames" can not be empty');return(r=s.XZ.call(this).error)?[2,Promise.reject(r)]:(t=this.context,o=t.orgName,i=t.appName,u=t.userId,l=t.accessToken,p={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/users/").concat(u,"/presence"),type:"DELETE",dataType:"json",data:JSON.stringify(e.usernames),headers:{Authorization:"Bearer "+l,"Content-Type":"application/json"},success:e.success,error:e.error},a.kg.debug("Call unsubscribePresence:",e),[4,n.hj.call(this,p)]);case 1:return c.sent(),[2]}}))}))}function p(e){if("number"!=typeof e.pageNum||"number"!=typeof e.pageSize)throw Error('Invalid parameter: "pageNum or pageSize"');if(e.pageNum<0||e.pageSize<0)throw Error('"pageNum" should >= 0 and "pageSize" should >= 0');var r=s.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,o=t.orgName,c=t.appName,i=t.userId,u=t.accessToken,l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(c,"/users/").concat(i,"/presence/sublist?pageNum=").concat(e.pageNum,"&pageSize=").concat(e.pageSize),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getSubscribedPresenceList:",e),n.hj.call(this,l).then((function(e){return e.data={result:null==e?void 0:e.result},e}))}var f=p;function h(e){if(!Array.isArray(e.usernames))throw Error('Invalid parameter: "usernames"');if(!e.usernames.length)throw Error('"usernames" can not be empty');var r=s.XZ.call(this).error;if(r)return Promise.reject(r);var t={usernames:e.usernames},o=this.context,c=o.orgName,i=o.appName,u=o.userId,l=o.accessToken,p={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(i,"/users/").concat(u,"/presence"),type:"POST",dataType:"json",data:JSON.stringify(t),headers:{Authorization:"Bearer "+l,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getPresenceStatus:",e),n.hj.call(this,p).then((function(e){return e.data={result:null==e?void 0:e.result},e}))}}},function(e){return 3770,e(e.s=3770)}])}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.websdk=r():e.websdk=r()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[962],{3770:function(e,r,t){t.r(r),t.d(r,{getPresenceStatus:function(){return h},getSubscribedPresenceList:function(){return p},getSubscribedPresencelist:function(){return f},publishPresence:function(){return i},subscribePresence:function(){return u},unsubscribePresence:function(){return l}}),t(1539),t(8674),t(2526),t(1817),t(2165),t(6992),t(8783),t(3948),t(2222),t(9753);var n=t(4024),s=t(3246),a=t(7360),o=function(e,r,t,n){return new(t||(t=Promise))((function(s,a){function o(e){try{i(n.next(e))}catch(e){a(e)}}function c(e){try{i(n.throw(e))}catch(e){a(e)}}function i(e){var r;e.done?s(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,c)}i((n=n.apply(e,r||[])).next())}))},c=function(e,r){var t,n,s,a,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=r.call(e,o)}catch(e){a=[6,e],n=0}finally{t=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};function i(e){return o(this,void 0,void 0,(function(){var r,t,o,i,u,l,p,f,h;return c(this,(function(c){switch(c.label){case 0:if("string"!=typeof e.description)throw Error('Invalid parameter: "description"');return(r=s.XZ.call(this).error)?[2,Promise.reject(r)]:(t=this.context,o=t.accessToken,i=t.orgName,u=t.appName,l=t.userId,p=this.context.jid.clientResource,f={ext:e.description},h={url:"".concat(this.apiUrl,"/").concat(i,"/").concat(u,"/users/").concat(l,"/presence/").concat(p,"/1"),type:"POST",dataType:"json",data:JSON.stringify(f),headers:{Authorization:"Bearer "+o,"Content-Type":"application/json"},success:e.success,error:e.error},a.kg.debug("Call publishPresence:",e),[4,n.hj.call(this,h)]);case 1:return c.sent(),[2]}}))}))}function u(e){if(!Array.isArray(e.usernames))throw Error('Invalid parameter: "usernames"');if(!e.usernames.length)throw Error('"usernames" can not be empty');if("number"!=typeof e.expiry)throw Error('Invalid parameter: "expiry"');var r=s.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,o=t.orgName,c=t.appName,i=t.userId,u=t.accessToken,l={usernames:e.usernames},p={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(c,"/users/").concat(i,"/presence/").concat(e.expiry),type:"POST",dataType:"json",data:JSON.stringify(l),headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call subscribePresence:",e),n.hj.call(this,p).then((function(e){return e.data={result:null==e?void 0:e.result},e}))}function l(e){return o(this,void 0,void 0,(function(){var r,t,o,i,u,l,p;return c(this,(function(c){switch(c.label){case 0:if(!Array.isArray(e.usernames))throw Error('Invalid parameter: "usernames"');if(!e.usernames.length)throw Error('"usernames" can not be empty');return(r=s.XZ.call(this).error)?[2,Promise.reject(r)]:(t=this.context,o=t.orgName,i=t.appName,u=t.userId,l=t.accessToken,p={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/users/").concat(u,"/presence"),type:"DELETE",dataType:"json",data:JSON.stringify(e.usernames),headers:{Authorization:"Bearer "+l,"Content-Type":"application/json"},success:e.success,error:e.error},a.kg.debug("Call unsubscribePresence:",e),[4,n.hj.call(this,p)]);case 1:return c.sent(),[2]}}))}))}function p(e){if("number"!=typeof e.pageNum||"number"!=typeof e.pageSize)throw Error('Invalid parameter: "pageNum or pageSize"');if(e.pageNum<0||e.pageSize<0)throw Error('"pageNum" should >= 0 and "pageSize" should >= 0');var r=s.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,o=t.orgName,c=t.appName,i=t.userId,u=t.accessToken,l={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(c,"/users/").concat(i,"/presence/sublist?pageNum=").concat(e.pageNum,"&pageSize=").concat(e.pageSize),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+u,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getSubscribedPresenceList:",e),n.hj.call(this,l).then((function(e){return e.data={result:null==e?void 0:e.result},e}))}var f=p;function h(e){if(!Array.isArray(e.usernames))throw Error('Invalid parameter: "usernames"');if(!e.usernames.length)throw Error('"usernames" can not be empty');var r=s.XZ.call(this).error;if(r)return Promise.reject(r);var t={usernames:e.usernames},o=this.context,c=o.orgName,i=o.appName,u=o.userId,l=o.accessToken,p={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(i,"/users/").concat(u,"/presence"),type:"POST",dataType:"json",data:JSON.stringify(t),headers:{Authorization:"Bearer "+l,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getPresenceStatus:",e),n.hj.call(this,p).then((function(e){return e.data={result:null==e?void 0:e.result},e}))}}},function(e){return e(e.s=3770)}])}));
package/readme.md ADDED
@@ -0,0 +1,59 @@
1
+ # 环信 IM SDK 介绍
2
+
3
+ sdk 提供完整的即时消息功能开发功能,屏蔽/封装并阻止其内部复杂的细节,并提供相对简单和简洁的 API 接口,以方便第三方应用程序快速集成 PC/mobile Web 应用程序的即时消息功能
4
+
5
+ ## 可以通过以下方式引用 WebSDK:
6
+
7
+ 1. 安装
8
+
9
+ ```bash
10
+ npm install easemob-websdk --save
11
+ ```
12
+
13
+ 2. 引入 SDK。
14
+
15
+ ```
16
+ import EC from 'easemob-websdk'
17
+ ```
18
+
19
+ 3、初始化 SDK
20
+
21
+ ```javascript
22
+ const conn = new EC.connection({
23
+ appKey: '<your app key>',
24
+ });
25
+ ```
26
+
27
+ 4、登录环信服务
28
+
29
+ ```javascript
30
+ const options = {
31
+ user: 'username',
32
+ accessToken: 'accessToken',
33
+ };
34
+ conn.open(options);
35
+ ```
36
+
37
+ 5、发送消息
38
+
39
+ ```javascript
40
+ let option = {
41
+ chatType: 'singleChat', // 会话类型,设置为单聊。
42
+ type: 'txt', // 消息类型。
43
+ to: 'userID', // 消息接收方(用户 ID)。
44
+ msg: 'message content', // 消息内容。
45
+ };
46
+ let msg = EC.message.create(option);
47
+ conn.send(msg)
48
+ .then(() => {
49
+ console.log('send private text Success');
50
+ })
51
+ .catch((e) => {
52
+ console.log('Send private text error');
53
+ });
54
+ ```
55
+
56
+ ## 参考文档
57
+
58
+ - [Easemob Chat SDK 产品概述](https://doc.easemob.com/product/introduction.html)
59
+ - [Easemob Chat SDK API 参考](https://doc.easemob.com/document/web/integration.html)
package/silent/silent.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.websdk=r():e.websdk=r()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[883],{1735:function(e,r,t){t.r(r),t.d(r,{clearRemindTypeForConversation:function(){return u},getPushPerformLanguage:function(){return f},getSilentModeForAll:function(){return s},getSilentModeForConversation:function(){return p},getSilentModeForConversations:function(){return l},getSilentModeRemindTypeConversations:function(){return h},setPushPerformLanguage:function(){return d},setSilentModeForAll:function(){return i},setSilentModeForConversation:function(){return c}}),t(7941),t(1539),t(8674),t(2222),t(9753),t(9554),t(4747),t(9600),t(1249);var o=t(4024),n=t(3246),a=t(7360);function i(e){if(!(e.options instanceof Object))throw Error('Invalid parameter: "options"');var r=e.options.paramType;if("number"!=typeof r||r<0||r>2)throw Error('Invalid parameter: "options of paramType"');if(0===r){if("string"!=typeof e.options.remindType)throw Error('Invalid parameter: "options of remindType"')}else if(1===r){if("number"!=typeof e.options.duration)throw Error('Invalid parameter: "options of duration"')}else if(2===r){var t=e.options,i=t.startTime,s=t.endTime;if(!(i instanceof Object&&Object.keys(i).length))throw Error('Invalid parameter: "options of startTime"');if(!i.hours||"number"!=typeof i.hours||!i.minutes||"number"!=typeof i.minutes)throw Error('Invalid parameter: "options of startTime of hours or minutes"');if(!(s instanceof Object&&Object.keys(s).length))throw Error('Invalid parameter: "options of endTime"');if(!s.hours||"number"!=typeof s.hours||!s.minutes||"number"!=typeof s.minutes)throw Error('Invalid parameter: "options of endTime of hours or minutes"')}var c=n.XZ.call(this).error;if(c)return Promise.reject(c);var u=this.context,p=u.accessToken,l=u.orgName,d=u.appName,f=u.userId,h=u.jid,m={};switch(r){case 0:m={type:e.options.remindType};break;case 1:m={ignoreDuration:e.options.duration};break;case 2:var y=e.options;i=y.startTime,s=y.endTime,m={ignoreInterval:"".concat(i.hours,":").concat(i.minutes,"-").concat(s.hours,":").concat(s.minutes)}}var g={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/users/").concat(f,"/notification/user/").concat(f,"?resource=").concat(h.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(m),headers:{Authorization:"Bearer "+p,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call setSilentModeForAll:",e),o.hj.call(this,g)}function s(e){var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/user/").concat(u),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:null==e?void 0:e.success,error:null==e?void 0:e.error};return a.kg.debug("Call getSilentModeForAll:",e),o.hj.call(this,p)}function c(e){if("string"!=typeof e.conversationId||!e.conversationId)throw Error('Invalid parameter: "conversationId"');if("string"!=typeof e.type||!e.type)throw Error('Invalid parameter: "type"');if(!(e.options instanceof Object))throw Error('Invalid parameter: "options"');var r=e.options.paramType;if("number"!=typeof r||r<0||r>2)throw Error('Invalid parameter: "options of paramType"');if(0===r){if("string"!=typeof e.options.remindType)throw Error('Invalid parameter: "options of remindType"')}else if(1===r){if("number"!=typeof e.options.duration)throw Error('Invalid parameter: "options of duration"')}else if(2===r){var t=e.options,i=t.startTime,s=t.endTime;if(!(i instanceof Object&&Object.keys(i).length))throw Error('Invalid parameter: "options of startTime"');if(!i.hours||"number"!=typeof i.hours||!i.minutes||"number"!=typeof i.minutes)throw Error('Invalid parameter: "options of startTime of hours or minutes"');if(!(s instanceof Object&&Object.keys(s).length))throw Error('Invalid parameter: "options of endTime"');if(!s.hours||"number"!=typeof s.hours||!s.minutes||"number"!=typeof s.minutes)throw Error('Invalid parameter: "options of endTime of hours or minutes"')}var c=n.XZ.call(this).error;if(c)return Promise.reject(c);var u=this.context,p=u.accessToken,l=u.orgName,d=u.appName,f=u.userId,h=u.jid,m="chatgroup",y={};switch(r){case 0:y={type:e.options.remindType};break;case 1:y={ignoreDuration:e.options.duration};break;case 2:var g=e.options;i=g.startTime,s=g.endTime,y={ignoreInterval:"".concat(i.hours,":").concat(i.minutes,"-").concat(s.hours,":").concat(s.minutes)}}"singleChat"===e.type&&(m="user");var v={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/users/").concat(f,"/notification/").concat(m,"/").concat(e.conversationId,"?resource=").concat(h.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(y),headers:{Authorization:"Bearer "+p,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call setSilentModeForConversation:",e),o.hj.call(this,v)}function u(e){if("string"!=typeof e.conversationId||!e.conversationId)throw Error('Invalid parameter: "conversationId"');if("string"!=typeof e.type||!e.type)throw Error('Invalid parameter: "type"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p=t.jid,l="chatgroup";"singleChat"===e.type&&(l="user");var d={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/").concat(l,"/").concat(e.conversationId,"?resource=").concat(p.clientResource),type:"PUT",dataType:"json",data:JSON.stringify({type:"DEFAULT"}),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call clearRemindTypeForConversation:",e),o.hj.call(this,d)}function p(e){if("string"!=typeof e.conversationId||!e.conversationId)throw Error('Invalid parameter: "conversationId"');if("string"!=typeof e.type||!e.type)throw Error('Invalid parameter: "type"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p="chatgroup";"singleChat"===e.type&&(p="user");var l={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/").concat(p,"/").concat(e.conversationId),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getSilentModeForConversation:",e),o.hj.call(this,l)}function l(e){if(!Array.isArray(e.conversationList))throw Error('Invalid parameter: "conversationList"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p=[],l=[];e.conversationList.forEach((function(e){"singleChat"===e.type?p.push(e.id):l.push(e.id)}));var d=p.length?p.join(","):"",f=l.length?l.join(","):"",h={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification?user=").concat(d,"&group=").concat(f),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getSilentModeForConversations:",e),o.hj.call(this,h)}function d(e){if("string"!=typeof e.language||!e.language)throw Error('Invalid parameter: "language"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t={translationLanguage:e.language},i=this.context,s=i.accessToken,c=i.orgName,u=i.appName,p=i.userId,l={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/users/").concat(p,"/notification/language"),type:"PUT",dataType:"json",data:JSON.stringify(t),headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call setPushPerformLanguage:",e),o.hj.call(this,l)}function f(e){var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/language"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:null==e?void 0:e.success,error:null==e?void 0:e.error};return a.kg.debug("Call getPushPerformLanguage:",e),o.hj.call(this,p)}function h(e){var r=n.XZ.call(this).error;if(r)return Promise.reject(r);if("number"!=typeof e.pageSize)throw Error('Invalid parameter: "pageSize"');var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p={limit:e.pageSize||10,cursor:e.cursor};e.cursor||delete p.cursor;var l={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/mute/type"),type:"GET",dataType:"json",data:p,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return a.kg.debug("Call getSilentModeRemindTypeConversations:",e),o.hj.call(this,l).then((function(e){return e.data?{data:{conversations:e.data.map((function(e){return"user"in e?{conversationId:e.user,type:"singleChat",remindType:e.value}:{conversationId:e.group,type:"groupChat",remindType:e.value}})),cursor:e.cursor},type:e.type}:e}))}}},function(e){return 1735,e(e.s=1735)}])}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.websdk=r():e.websdk=r()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[883],{1735:function(e,r,t){t.r(r),t.d(r,{clearRemindTypeForConversation:function(){return u},getPushPerformLanguage:function(){return f},getSilentModeForAll:function(){return s},getSilentModeForConversation:function(){return p},getSilentModeForConversations:function(){return l},getSilentModeRemindTypeConversations:function(){return h},setPushPerformLanguage:function(){return d},setSilentModeForAll:function(){return i},setSilentModeForConversation:function(){return c}}),t(7941),t(1539),t(8674),t(2222),t(9753),t(9554),t(4747),t(9600),t(1249);var o=t(4024),n=t(3246),a=t(7360);function i(e){if(!(e.options instanceof Object))throw Error('Invalid parameter: "options"');var r=e.options.paramType;if("number"!=typeof r||r<0||r>2)throw Error('Invalid parameter: "options of paramType"');if(0===r){if("string"!=typeof e.options.remindType)throw Error('Invalid parameter: "options of remindType"')}else if(1===r){if("number"!=typeof e.options.duration)throw Error('Invalid parameter: "options of duration"')}else if(2===r){var t=e.options,i=t.startTime,s=t.endTime;if(!(i instanceof Object&&Object.keys(i).length))throw Error('Invalid parameter: "options of startTime"');if(!i.hours||"number"!=typeof i.hours||!i.minutes||"number"!=typeof i.minutes)throw Error('Invalid parameter: "options of startTime of hours or minutes"');if(!(s instanceof Object&&Object.keys(s).length))throw Error('Invalid parameter: "options of endTime"');if(!s.hours||"number"!=typeof s.hours||!s.minutes||"number"!=typeof s.minutes)throw Error('Invalid parameter: "options of endTime of hours or minutes"')}var c=n.XZ.call(this).error;if(c)return Promise.reject(c);var u=this.context,p=u.accessToken,l=u.orgName,d=u.appName,f=u.userId,h=u.jid,m={};switch(r){case 0:m={type:e.options.remindType};break;case 1:m={ignoreDuration:e.options.duration};break;case 2:var y=e.options;i=y.startTime,s=y.endTime,m={ignoreInterval:"".concat(i.hours,":").concat(i.minutes,"-").concat(s.hours,":").concat(s.minutes)}}var g={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/users/").concat(f,"/notification/user/").concat(f,"?resource=").concat(h.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(m),headers:{Authorization:"Bearer "+p,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call setSilentModeForAll:",e),o.hj.call(this,g)}function s(e){var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/user/").concat(u),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:null==e?void 0:e.success,error:null==e?void 0:e.error};return a.kg.debug("Call getSilentModeForAll:",e),o.hj.call(this,p)}function c(e){if("string"!=typeof e.conversationId||!e.conversationId)throw Error('Invalid parameter: "conversationId"');if("string"!=typeof e.type||!e.type)throw Error('Invalid parameter: "type"');if(!(e.options instanceof Object))throw Error('Invalid parameter: "options"');var r=e.options.paramType;if("number"!=typeof r||r<0||r>2)throw Error('Invalid parameter: "options of paramType"');if(0===r){if("string"!=typeof e.options.remindType)throw Error('Invalid parameter: "options of remindType"')}else if(1===r){if("number"!=typeof e.options.duration)throw Error('Invalid parameter: "options of duration"')}else if(2===r){var t=e.options,i=t.startTime,s=t.endTime;if(!(i instanceof Object&&Object.keys(i).length))throw Error('Invalid parameter: "options of startTime"');if(!i.hours||"number"!=typeof i.hours||!i.minutes||"number"!=typeof i.minutes)throw Error('Invalid parameter: "options of startTime of hours or minutes"');if(!(s instanceof Object&&Object.keys(s).length))throw Error('Invalid parameter: "options of endTime"');if(!s.hours||"number"!=typeof s.hours||!s.minutes||"number"!=typeof s.minutes)throw Error('Invalid parameter: "options of endTime of hours or minutes"')}var c=n.XZ.call(this).error;if(c)return Promise.reject(c);var u=this.context,p=u.accessToken,l=u.orgName,d=u.appName,f=u.userId,h=u.jid,m="chatgroup",y={};switch(r){case 0:y={type:e.options.remindType};break;case 1:y={ignoreDuration:e.options.duration};break;case 2:var g=e.options;i=g.startTime,s=g.endTime,y={ignoreInterval:"".concat(i.hours,":").concat(i.minutes,"-").concat(s.hours,":").concat(s.minutes)}}"singleChat"===e.type&&(m="user");var v={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(d,"/users/").concat(f,"/notification/").concat(m,"/").concat(e.conversationId,"?resource=").concat(h.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(y),headers:{Authorization:"Bearer "+p,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call setSilentModeForConversation:",e),o.hj.call(this,v)}function u(e){if("string"!=typeof e.conversationId||!e.conversationId)throw Error('Invalid parameter: "conversationId"');if("string"!=typeof e.type||!e.type)throw Error('Invalid parameter: "type"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p=t.jid,l="chatgroup";"singleChat"===e.type&&(l="user");var d={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/").concat(l,"/").concat(e.conversationId,"?resource=").concat(p.clientResource),type:"PUT",dataType:"json",data:JSON.stringify({type:"DEFAULT"}),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call clearRemindTypeForConversation:",e),o.hj.call(this,d)}function p(e){if("string"!=typeof e.conversationId||!e.conversationId)throw Error('Invalid parameter: "conversationId"');if("string"!=typeof e.type||!e.type)throw Error('Invalid parameter: "type"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p="chatgroup";"singleChat"===e.type&&(p="user");var l={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/").concat(p,"/").concat(e.conversationId),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getSilentModeForConversation:",e),o.hj.call(this,l)}function l(e){if(!Array.isArray(e.conversationList))throw Error('Invalid parameter: "conversationList"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p=[],l=[];e.conversationList.forEach((function(e){"singleChat"===e.type?p.push(e.id):l.push(e.id)}));var d=p.length?p.join(","):"",f=l.length?l.join(","):"",h={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification?user=").concat(d,"&group=").concat(f),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call getSilentModeForConversations:",e),o.hj.call(this,h)}function d(e){if("string"!=typeof e.language||!e.language)throw Error('Invalid parameter: "language"');var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t={translationLanguage:e.language},i=this.context,s=i.accessToken,c=i.orgName,u=i.appName,p=i.userId,l={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(u,"/users/").concat(p,"/notification/language"),type:"PUT",dataType:"json",data:JSON.stringify(t),headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"},success:e.success,error:e.error};return a.kg.debug("Call setPushPerformLanguage:",e),o.hj.call(this,l)}function f(e){var r=n.XZ.call(this).error;if(r)return Promise.reject(r);var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/language"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"},success:null==e?void 0:e.success,error:null==e?void 0:e.error};return a.kg.debug("Call getPushPerformLanguage:",e),o.hj.call(this,p)}function h(e){var r=n.XZ.call(this).error;if(r)return Promise.reject(r);if("number"!=typeof e.pageSize)throw Error('Invalid parameter: "pageSize"');var t=this.context,i=t.accessToken,s=t.orgName,c=t.appName,u=t.userId,p={limit:e.pageSize||10,cursor:e.cursor};e.cursor||delete p.cursor;var l={url:"".concat(this.apiUrl,"/").concat(s,"/").concat(c,"/users/").concat(u,"/notification/mute/type"),type:"GET",dataType:"json",data:p,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return a.kg.debug("Call getSilentModeRemindTypeConversations:",e),o.hj.call(this,l).then((function(e){return e.data?{data:{conversations:e.data.map((function(e){return"user"in e?{conversationId:e.user,type:"singleChat",remindType:e.value}:{conversationId:e.group,type:"groupChat",remindType:e.value}})),cursor:e.cursor},type:e.type}:e}))}}},function(e){return e(e.s=1735)}])}));
package/status.d.ts CHANGED
@@ -79,6 +79,10 @@ declare enum Code {
79
79
  * Note: You can send messages to strangers by default. This error occurs only when you enable the function of allowing to send messages only to your contacts.
80
80
  */
81
81
  USER_NOT_FRIEND = 221,
82
+ /** No permission to download file. */
83
+ WEBIM_DOWNLOADFILE_ERROR_NO_PERMISSION = 222,
84
+ /** The file has expired. */
85
+ WEBIM_DOWNLOADFILE_ERROR_EXPIRED = 223,
82
86
  /** The server is busy. */
83
87
  SERVER_BUSY = 500,
84
88
  /** The message content contains illegal or sensitive words. */
package/thread/thread.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[90],{7384:function(e,t,a){a.r(t),a.d(t,{changeChatThreadName:function(){return l},createChatThread:function(){return s},destroyChatThread:function(){return u},getChatThreadDetail:function(){return y},getChatThreadLastMessage:function(){return T},getChatThreadMembers:function(){return p},getChatThreads:function(){return I},getJoinedChatThreads:function(){return m},joinChatThread:function(){return h},leaveChatThread:function(){return d},removeChatThreadMember:function(){return f}}),a(1539),a(8674),a(2526),a(1817),a(2165),a(6992),a(8783),a(3948),a(8309),a(2222),a(9554),a(4747),a(9753);var r=a(4024),n=a(3246),c=a(4363),o=function(e,t,a,r){return new(a||(a=Promise))((function(n,c){function o(e){try{s(r.next(e))}catch(e){c(e)}}function i(e){try{s(r.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(o,i)}s((r=r.apply(e,t||[])).next())}))},i=function(e,t){var a,r,n,c,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return c={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(c){return function(i){return function(c){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,r&&(n=2&c[0]?r.return:c[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,c[1])).done)return n;switch(r=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){o.label=c[1];break}if(6===c[0]&&o.label<n[1]){o.label=n[1],n=c;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(c);break}n[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{a=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,i])}}};function s(e){if("string"!=typeof e.name||""===e.name)throw Error("Invalid parameter name: ".concat(e.name));if("string"!=typeof e.messageId||""===e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.parentId||""===e.parentId)throw Error("Invalid parameter parentId: ".concat(e.parentId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={name:e.name,msg_id:e.messageId,group_id:e.parentId,owner:this.user},d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread?resource=").concat(s.clientResource),type:"POST",dataType:"json",data:JSON.stringify(h),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,d).then((function(e){var t=e.data.thread_id;return e.data={chatThreadId:t},e}))}function h(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/user/").concat(this.user,"/join?resource=").concat(s.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h).then((function(e){var t=e.data.detail;return t.messageId=t.msgId,t.parentId=t.groupId,delete t.msgId,delete t.groupId,e}))}function d(e){return o(this,void 0,void 0,(function(){var t,a,c,o,s,h,d;return i(this,(function(i){switch(i.label){case 0:if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));return(t=n.XZ.call(this).error)?[2,Promise.reject(t)]:(a=this.context,c=a.orgName,o=a.appName,s=a.accessToken,h=a.jid,d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/user/").concat(this.user,"/quit?resource=").concat(h.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}},[4,r.hj.call(this,d)]);case 1:return i.sent(),[2]}}))}))}function u(e){return o(this,void 0,void 0,(function(){var t,a,c,o,s,h,d;return i(this,(function(i){switch(i.label){case 0:if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));return(t=n.XZ.call(this).error)?[2,Promise.reject(t)]:(a=this.context,c=a.orgName,o=a.appName,s=a.accessToken,h=a.jid,d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"?resource=").concat(h.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}},[4,r.hj.call(this,d)]);case 1:return i.sent(),[2]}}))}))}function l(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));if("string"!=typeof e.name||""===e.name)throw Error("Invalid parameter name: ".concat(e.name));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={name:e.name},d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"?resource=").concat(s.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(h),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,d)}function p(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={limit:e.pageSize||20,cursor:e.cursor||""},h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/users"),type:"GET",dataType:"json",data:s,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h)}function f(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));if("string"!=typeof e.username||""===e.username)throw Error("Invalid parameter username: ".concat(e.username));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/users/").concat(e.username,"?resource=").concat(s.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h)}function m(e){var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={limit:e.pageSize||20,cursor:e.cursor||""},h={url:e.parentId?"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/threads/chatgroups/").concat(e.parentId,"/user/").concat(this.user):"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/threads/user/").concat(this.user),type:"GET",dataType:"json",data:s,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h).then((function(e){var t=e.entities;return null==t||t.forEach((function(e){e.parentId=e.groupId,e.messageId=e.msgId,delete e.groupId,delete e.msgId})),e}))}function I(e){if("string"!=typeof e.parentId||""===e.parentId)throw Error("Invalid parameter parentId: ".concat(e.parentId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={cursor:e.cursor||"",limit:e.pageSize||20},h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/threads/chatgroups/").concat(e.parentId),type:"GET",dataType:"json",data:s,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h).then((function(e){var t=e.entities;return null==t||t.forEach((function(e){e.parentId=e.groupId,e.messageId=e.msgId,delete e.groupId,delete e.msgId})),e}))}function T(e){var t=this;if(!Array.isArray(e.chatThreadIds))throw Error("Invalid parameter chatThreadIds: ".concat(e.chatThreadIds));var a=n.XZ.call(this).error;if(a)return Promise.reject(a);var c=this.context,o=c.orgName,i=c.appName,s=c.accessToken,h={threadIds:e.chatThreadIds},d={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/thread/message"),type:"POST",dataType:"json",data:JSON.stringify(h),headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}};return r.hj.call(this,d).then((function(e){return g.call(t,e)}))}function g(e){var t=this,a=e.entities;return null==a||a.forEach((function(e){e.chatThreadId=e.thread_id,e.last_message&&"{}"!==JSON.stringify(e.last_message)?e.lastMessage=c.w.call(t,e.last_message):e.lastMessage=e.last_message,delete e.thread_id,delete e.last_message})),e}function y(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,s).then((function(e){return e.data.affiliationsCount=e.data.affiliations_count,e.data.messageId=e.data.msgId,e.data.parentId=e.data.groupId,delete e.data.affiliations_count,delete e.data.msgId,delete e.data.groupId,e}))}}},function(e){return 7384,e(e.s=7384)}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[90],{7384:function(e,t,a){a.r(t),a.d(t,{changeChatThreadName:function(){return l},createChatThread:function(){return s},destroyChatThread:function(){return u},getChatThreadDetail:function(){return y},getChatThreadLastMessage:function(){return T},getChatThreadMembers:function(){return p},getChatThreads:function(){return I},getJoinedChatThreads:function(){return m},joinChatThread:function(){return h},leaveChatThread:function(){return d},removeChatThreadMember:function(){return f}}),a(1539),a(8674),a(2526),a(1817),a(2165),a(6992),a(8783),a(3948),a(8309),a(2222),a(9554),a(4747),a(9753);var r=a(4024),n=a(3246),c=a(4363),o=function(e,t,a,r){return new(a||(a=Promise))((function(n,c){function o(e){try{s(r.next(e))}catch(e){c(e)}}function i(e){try{s(r.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(o,i)}s((r=r.apply(e,t||[])).next())}))},i=function(e,t){var a,r,n,c,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return c={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(c){return function(i){return function(c){if(a)throw new TypeError("Generator is already executing.");for(;o;)try{if(a=1,r&&(n=2&c[0]?r.return:c[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,c[1])).done)return n;switch(r=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((n=(n=o.trys).length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){o.label=c[1];break}if(6===c[0]&&o.label<n[1]){o.label=n[1],n=c;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(c);break}n[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{a=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,i])}}};function s(e){if("string"!=typeof e.name||""===e.name)throw Error("Invalid parameter name: ".concat(e.name));if("string"!=typeof e.messageId||""===e.messageId)throw Error("Invalid parameter messageId: ".concat(e.messageId));if("string"!=typeof e.parentId||""===e.parentId)throw Error("Invalid parameter parentId: ".concat(e.parentId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={name:e.name,msg_id:e.messageId,group_id:e.parentId,owner:this.user},d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread?resource=").concat(s.clientResource),type:"POST",dataType:"json",data:JSON.stringify(h),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,d).then((function(e){var t=e.data.thread_id;return e.data={chatThreadId:t},e}))}function h(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/user/").concat(this.user,"/join?resource=").concat(s.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h).then((function(e){var t=e.data.detail;return t.messageId=t.msgId,t.parentId=t.groupId,delete t.msgId,delete t.groupId,e}))}function d(e){return o(this,void 0,void 0,(function(){var t,a,c,o,s,h,d;return i(this,(function(i){switch(i.label){case 0:if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));return(t=n.XZ.call(this).error)?[2,Promise.reject(t)]:(a=this.context,c=a.orgName,o=a.appName,s=a.accessToken,h=a.jid,d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/user/").concat(this.user,"/quit?resource=").concat(h.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}},[4,r.hj.call(this,d)]);case 1:return i.sent(),[2]}}))}))}function u(e){return o(this,void 0,void 0,(function(){var t,a,c,o,s,h,d;return i(this,(function(i){switch(i.label){case 0:if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));return(t=n.XZ.call(this).error)?[2,Promise.reject(t)]:(a=this.context,c=a.orgName,o=a.appName,s=a.accessToken,h=a.jid,d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"?resource=").concat(h.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}},[4,r.hj.call(this,d)]);case 1:return i.sent(),[2]}}))}))}function l(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));if("string"!=typeof e.name||""===e.name)throw Error("Invalid parameter name: ".concat(e.name));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={name:e.name},d={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"?resource=").concat(s.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(h),headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,d)}function p(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={limit:e.pageSize||20,cursor:e.cursor||""},h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/users"),type:"GET",dataType:"json",data:s,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h)}function f(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));if("string"!=typeof e.username||""===e.username)throw Error("Invalid parameter username: ".concat(e.username));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s=a.jid,h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId,"/users/").concat(e.username,"?resource=").concat(s.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h)}function m(e){var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={limit:e.pageSize||20,cursor:e.cursor||""},h={url:e.parentId?"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/threads/chatgroups/").concat(e.parentId,"/user/").concat(this.user):"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/threads/user/").concat(this.user),type:"GET",dataType:"json",data:s,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h).then((function(e){var t=e.entities;return null==t||t.forEach((function(e){e.parentId=e.groupId,e.messageId=e.msgId,delete e.groupId,delete e.msgId})),e}))}function I(e){if("string"!=typeof e.parentId||""===e.parentId)throw Error("Invalid parameter parentId: ".concat(e.parentId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={cursor:e.cursor||"",limit:e.pageSize||20},h={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/threads/chatgroups/").concat(e.parentId),type:"GET",dataType:"json",data:s,headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,h).then((function(e){var t=e.entities;return null==t||t.forEach((function(e){e.parentId=e.groupId,e.messageId=e.msgId,delete e.groupId,delete e.msgId})),e}))}function T(e){var t=this;if(!Array.isArray(e.chatThreadIds))throw Error("Invalid parameter chatThreadIds: ".concat(e.chatThreadIds));var a=n.XZ.call(this).error;if(a)return Promise.reject(a);var c=this.context,o=c.orgName,i=c.appName,s=c.accessToken,h={threadIds:e.chatThreadIds},d={url:"".concat(this.apiUrl,"/").concat(o,"/").concat(i,"/thread/message"),type:"POST",dataType:"json",data:JSON.stringify(h),headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}};return r.hj.call(this,d).then((function(e){return g.call(t,e)}))}function g(e){var t=this,a=e.entities;return null==a||a.forEach((function(e){e.chatThreadId=e.thread_id,e.last_message&&"{}"!==JSON.stringify(e.last_message)?e.lastMessage=c.w.call(t,e.last_message):e.lastMessage=e.last_message,delete e.thread_id,delete e.last_message})),e}function y(e){if("string"!=typeof e.chatThreadId||""===e.chatThreadId)throw Error("Invalid parameter chatThreadId: ".concat(e.chatThreadId));var t=n.XZ.call(this).error;if(t)return Promise.reject(t);var a=this.context,c=a.orgName,o=a.appName,i=a.accessToken,s={url:"".concat(this.apiUrl,"/").concat(c,"/").concat(o,"/thread/").concat(e.chatThreadId),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}};return r.hj.call(this,s).then((function(e){return e.data.affiliationsCount=e.data.affiliations_count,e.data.messageId=e.data.msgId,e.data.parentId=e.data.groupId,delete e.data.affiliations_count,delete e.data.msgId,delete e.data.groupId,e}))}}},function(e){return e(e.s=7384)}])}));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[33],{70:function(e,t,r){r.r(t),r.d(t,{getSupportedLanguages:function(){return o},translateMessage:function(){return c}}),r(1539),r(8674),r(2222),r(9753);var a=r(3246),n=r(7360),s=r(4024);function o(){var e=a.XZ.call(this).error;if(e)return Promise.reject(e);var t=this.context,r=t.orgName,o=t.appName,c=t.accessToken,u={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(o,"/users/").concat(this.user,"/translate/support/language"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+c}};return n.kg.debug("Call getSupportedLanguages"),s.hj.call(this,u)}function c(e){if("string"!=typeof e.text||""===e.text)throw Error('Invalid parameter: "text"');if(!Array.isArray(e.languages))throw Error('Invalid parameter: "language"');var t=a.XZ.call(this).error;if(t)return Promise.reject(t);var r=this.context,o=r.orgName,c=r.appName,u=r.accessToken,i="".concat(this.apiUrl,"/").concat(o,"/").concat(c,"/users/").concat(this.user,"/translate"),l={text:e.text,to:e.languages},p={url:i,dataType:"json",type:"POST",data:JSON.stringify(l),headers:{Authorization:"Bearer "+u}};return n.kg.debug("Call translateMessage"),s.hj.call(this,p)}}},function(e){return 70,e(e.s=70)}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.websdk=t():e.websdk=t()}(self,(function(){return(self.webpackChunkwebsdk=self.webpackChunkwebsdk||[]).push([[33],{70:function(e,t,r){r.r(t),r.d(t,{getSupportedLanguages:function(){return o},translateMessage:function(){return c}}),r(1539),r(8674),r(2222),r(9753);var a=r(3246),n=r(7360),s=r(4024);function o(){var e=a.XZ.call(this).error;if(e)return Promise.reject(e);var t=this.context,r=t.orgName,o=t.appName,c=t.accessToken,u={url:"".concat(this.apiUrl,"/").concat(r,"/").concat(o,"/users/").concat(this.user,"/translate/support/language"),dataType:"json",type:"GET",headers:{Authorization:"Bearer "+c}};return n.kg.debug("Call getSupportedLanguages"),s.hj.call(this,u)}function c(e){if("string"!=typeof e.text||""===e.text)throw Error('Invalid parameter: "text"');if(!Array.isArray(e.languages))throw Error('Invalid parameter: "language"');var t=a.XZ.call(this).error;if(t)return Promise.reject(t);var r=this.context,o=r.orgName,c=r.appName,u=r.accessToken,i="".concat(this.apiUrl,"/").concat(o,"/").concat(c,"/users/").concat(this.user,"/translate"),l={text:e.text,to:e.languages},p={url:i,dataType:"json",type:"POST",data:JSON.stringify(l),headers:{Authorization:"Bearer "+u}};return n.kg.debug("Call translateMessage"),s.hj.call(this,p)}}},function(e){return e(e.s=70)}])}));
package/types/common.d.ts CHANGED
@@ -38,7 +38,7 @@ interface EventData {
38
38
  /** The ID of a group or chatroom. */
39
39
  id: string;
40
40
  /** Message sender. */
41
- from: string;
41
+ from?: string;
42
42
  /** The modified group info. */
43
43
  detail?: GroupModifyInfo;
44
44
  /** The name of a group or chatroom. */
@@ -57,6 +57,8 @@ interface EventData {
57
57
  announcement?: string;
58
58
  /** Expiration time for user mute. */
59
59
  muteTimestamp?: { [key: string]: number };
60
+ /** User IDs of group members. */
61
+ members?: Array<string>;
60
62
  }
61
63
 
62
64
  interface AttributeRespData {
@@ -200,8 +200,10 @@ export interface GroupEvent {
200
200
  * removeMember: Occurs when you are removed from a group or added to block list. Only the removed person receives this event.<br/>
201
201
  * unblockMember: Occurs when being removed from the block list. Only the removed person receives this event.<br/>
202
202
  * updateInfo: Occurs when modifying group. <br/>
203
- * memberPresence: Occurs when someone joined the group. <br/>
204
- * memberAbsence: Occurs when someone leaved the group. <br/>
203
+ * memberPresence: Occurs when a user joined the group. <br/>
204
+ * membersPresence: Occurs when more than one user joined the group. <br/>
205
+ * memberAbsence: Occurs when a user leaved the group.<br/>
206
+ * membersAbsence: Occurs when more than one user leaved the group. <br/>
205
207
  * directJoined: Occurs when you are directly pulled into the group and no consent is required. <br/>
206
208
  * changeOwner: Occurs when transferring group. Only new and old group owners can receive this event. <br/>
207
209
  * setAdmin: Occurs when being set as administrator. Only the person who is set to administrator can receive this event.<br/>
@@ -232,7 +234,9 @@ export interface GroupEvent {
232
234
  | 'unblockMember'
233
235
  | 'updateInfo'
234
236
  | 'memberPresence'
237
+ | 'membersPresence'
235
238
  | 'memberAbsence'
239
+ | 'membersAbsence'
236
240
  | 'directJoined'
237
241
  | 'changeOwner'
238
242
  | 'setAdmin'
@@ -342,7 +346,7 @@ interface EventHandlerType {
342
346
  onContactDeleted?: (msg: ContactMsgBody) => void;
343
347
  /** The callback to added a contact. */
344
348
  onContactAdded?: (msg: ContactMsgBody) => void;
345
- /** The callback whose token is about to expire. */
349
+ /** Occurs when the token is about to expire. This event is triggered from when 20% of the validity period is left.*/
346
350
  onTokenWillExpire?: () => void;
347
351
  /** The callback whose token has expired. */
348
352
  onTokenExpired?: () => void;
@@ -75,6 +75,8 @@ interface GroupDetailInfo {
75
75
  public: boolean;
76
76
  /** Whether the member is on the blocklist. -`true`: Yes; -`false`: No. */
77
77
  shieldgroup: boolean;
78
+ /** The group avatar. */
79
+ avatar: string;
78
80
  }
79
81
  interface ModifyGroupResult {
80
82
  /** Whether the group description is modified successfully. -`true`: Yes; -`false`: No. */
@@ -87,6 +89,8 @@ interface ModifyGroupResult {
87
89
  membersonly?: boolean;
88
90
  /** Whether allowing a group member to invite others is modified successfully. -`true`: Yes; -`false`: No.*/
89
91
  allowinvites?: boolean;
92
+ /** Whether the group avatar is changed successfully. -`true`: Yes; -`false`: No. */
93
+ avatar?: boolean;
90
94
  }
91
95
  declare type GroupMember =
92
96
  | {
@@ -257,12 +261,21 @@ interface GroupModifyInfo {
257
261
  ext?: string;
258
262
  /** Last Modified Timestamp. */
259
263
  lastModified?: number;
264
+ /** The group avatar. */
265
+ avatar?: string;
260
266
  }
261
267
 
262
268
  declare type MemberAttributes = Record<string, string>;
263
269
 
264
270
  declare type GetGroupMembersAttributesResult = Record<UserId, MemberAttributes>;
265
271
 
272
+ type GroupMemberRole = 'owner' | 'admin' | 'member';
273
+ interface FetchedGroupMember {
274
+ role: GroupMemberRole;
275
+ userId: UserId;
276
+ joinedTime: number;
277
+ }
278
+
266
279
  export type {
267
280
  GroupRequestResult,
268
281
  BaseGroupInfo,
@@ -289,4 +302,5 @@ export type {
289
302
  GroupModifyInfo,
290
303
  MemberAttributes,
291
304
  GetGroupMembersAttributesResult,
305
+ FetchedGroupMember,
292
306
  };