easemob-websdk 4.1.3 → 4.1.4-beta
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/Easemob-chat.d.ts +1 -1
- package/Easemob-chat.js +1 -1
- package/category/category.d.ts +121 -0
- package/category/category.js +1 -0
- package/channel/channel.d.ts +346 -0
- package/channel/channel.js +1 -0
- package/circleSdk/Easemob-chat.d.ts +7899 -0
- package/circleSdk/Easemob-chat.js +1 -0
- package/package.json +1 -1
- package/readme.md +4 -0
- package/server/server.d.ts +318 -0
- package/server/server.js +1 -0
- package/types/categoryApi.d.ts +50 -0
- package/types/channelApi.d.ts +162 -0
- package/types/common.d.ts +5 -0
- package/types/indexApi.d.ts +2 -3
- package/types/serverApi.d.ts +123 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as CategoryTypes from '../types/categoryApi';
|
|
2
|
+
import * as ChannelTypes from '../types/channelApi';
|
|
3
|
+
import { AsyncResult } from '../types/common';
|
|
4
|
+
export interface Category {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a channel category.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* connection.createCategory({serverId: 'serverId', name: "name"})
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
createCategory(params: {
|
|
13
|
+
/** The server ID. */
|
|
14
|
+
serverId: string;
|
|
15
|
+
/** The channel category name. */
|
|
16
|
+
name: string;
|
|
17
|
+
}): Promise<AsyncResult<CategoryTypes.CategoryInfo>>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Updates a channel category.
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* connection.updateCategory({serverId: 'serverId',categoryId: 'categoryId', name: "name"})
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
updateCategory(params: {
|
|
27
|
+
/** The server ID. */
|
|
28
|
+
serverId: string;
|
|
29
|
+
/** The channel category ID. */
|
|
30
|
+
categoryId: string;
|
|
31
|
+
/** The new channel category name. With this method, you can only change the channel category name. */
|
|
32
|
+
name: string;
|
|
33
|
+
}): Promise<AsyncResult<CategoryTypes.CategoryInfo>>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Gets the channel category list.
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* connection.getCategorylist({serverId: 'serverId',pageSize:20,cursor:''})
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
getCategorylist(params: {
|
|
43
|
+
/** The server ID. */
|
|
44
|
+
serverId: string;
|
|
45
|
+
/** The number of channel categories that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
|
|
46
|
+
pageSize?: number;
|
|
47
|
+
/** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK retrieves channel categories in the descending order of the time when they are created.*/
|
|
48
|
+
cursor?: string;
|
|
49
|
+
}): Promise<AsyncResult<CategoryTypes.CategoryInfoListResult>>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Deletes a channel category.
|
|
53
|
+
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
* connection.deleteCategory({serverId: 'serverId', categoryId: 'categoryId'})
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
deleteCategory(params: {
|
|
59
|
+
/** The server ID. */
|
|
60
|
+
serverId: string;
|
|
61
|
+
/** The channel category ID. */
|
|
62
|
+
categoryId: string;
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Gets the list of public channels in the current category with pagination.
|
|
67
|
+
*
|
|
68
|
+
* ```typescript
|
|
69
|
+
* connection.getCategoryPublicChannels({serverId: 'serverId', categoryId: "categoryId",pagesize:20,cursor:''})
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
getCategoryPublicChannels(params: {
|
|
73
|
+
/** The server ID. */
|
|
74
|
+
serverId: string;
|
|
75
|
+
/** The channel category ID. */
|
|
76
|
+
categoryId: string;
|
|
77
|
+
/** The number of channels that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
|
|
78
|
+
pageSize?: number;
|
|
79
|
+
/** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK retrieves channels in the descending order of the time when they are created.*/
|
|
80
|
+
cursor?: string;
|
|
81
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfoListResult>>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Gets the list of private channels in the current category with pagination.
|
|
85
|
+
*
|
|
86
|
+
*
|
|
87
|
+
* ```typescript
|
|
88
|
+
* connection.getCategoryPrivateChannels({serverId: 'serverId', categoryId: "categoryId",pagesize:20,cursor:''})
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
92
|
+
getCategoryPrivateChannels(params: {
|
|
93
|
+
/** The server ID. */
|
|
94
|
+
serverId: string;
|
|
95
|
+
/** The channel category ID. */
|
|
96
|
+
categoryId: string;
|
|
97
|
+
/** The number of channel that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
|
|
98
|
+
pageSize?: number;
|
|
99
|
+
/** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK retrieves channels in the descending order of the time when they are created.*/
|
|
100
|
+
cursor?: string;
|
|
101
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfoListResult>>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Transfers a channel to another category.
|
|
105
|
+
*
|
|
106
|
+
* ```typescript
|
|
107
|
+
* connection.transferChannel({serverId: 'serverId',channelId:'channelId', newCategoryId: 'newCategoryId'})
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
transferChannel(params: {
|
|
111
|
+
/** The server ID. */
|
|
112
|
+
serverId: string;
|
|
113
|
+
/** The ID to the channel that is to be transferred to another category. */
|
|
114
|
+
channelId: string;
|
|
115
|
+
/** ID of the target channel group.
|
|
116
|
+
*
|
|
117
|
+
* If no value is passed, the channel will be transferred to the default channel category of the server by default.
|
|
118
|
+
*/
|
|
119
|
+
newCategoryId?: string;
|
|
120
|
+
}): Promise<void>;
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!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()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[369],{5391:function(e,t,r){r.r(t),r.d(t,{createCategory:function(){return g},deleteCategory:function(){return m},getCategoryPrivateChannels:function(){return I},getCategoryPublicChannels:function(){return k},getCategorylist:function(){return v},transferChannel:function(){return b},updateCategory:function(){return f}}),r(1539),r(8674),r(2526),r(1817),r(2165),r(6992),r(8783),r(3948),r(8309),r(2222),r(1249);var n=r(3246),a=r(5531),c=r(7252),o=r(7360),i=r(4370),s=function(e,t,r,n){return new(r||(r=Promise))((function(a,c){function o(e){try{s(n.next(e))}catch(e){c(e)}}function i(e){try{s(n.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,i)}s((n=n.apply(e,t||[])).next())}))},u=function(e,t){var r,n,a,c,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,n=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,i])}}},l=c.Z.create({type:a.E.REST_PARAMS_STATUS,message:"appkey or token error"}),d=c.Z.create({type:a.E.REQUEST_UNKNOWN,message:"Request Unknown Error"}),p=function(e){var t=e.url,r=void 0===t?"":t,n=e.type,a=void 0===n?"POST":n,c=e.dataType,o=void 0===c?"json":c,i=e.data,s=void 0===i?"":i,u=e.token,l=void 0===u?"":u;return{url:r,type:a,dataType:o,data:s?JSON.stringify(s):null,headers:{Authorization:"Bearer ".concat(l),"Content-Type":"application/json"}}};function y(e){try{var t=e.name,r=e.created,n=e.server_id;return{id:e.channel_category_id,name:t,serverId:n,created:r,defaultCategory:0!==e.default_channel_category}}catch(t){throw o.kg.error("unexpected channel category data: ".concat(e)),d}}var h=function(e){try{var t=e.channel_id,r=e.created,n=e.custom,a=e.default_channel,c=e.description,i=e.type,s=e.name,u=e.server_id,l=e.channel_category_id,p=e.mode,y={serverId:u,channelId:t,name:s,description:c,created:r,defaultChannel:0!==a,ext:n,isPublic:!i,categoryId:l,mode:p,maxusers:e.max_users};return 1===p&&(y.rtcChannelId=e.rtc_name),y}catch(t){throw o.kg.error("unexpected channel data: ".concat(e)),d}};function g(e){return s(this,void 0,void 0,(function(){var t,r,a,c,s,d,y,h,g,f;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,r=e.name,i.P6.checkDataType([{serverId:t,name:r,required:!0,type:"string"}]),n.XZ.call(this)?(a=this.context,c=a.orgName,s=a.appName,d=a.accessToken,y=a.jid,h="".concat(this.apiUrl,"/").concat(c,"/").concat(s,"/circle/channel/category?resource=").concat(y.clientResource),g=p({url:h,token:d,data:{server_id:t,name:r},type:"POST"}),o.kg.debug("Call createCategory",e),[4,i.P6.ajax(g)]):[2,Promise.reject(l)];case 1:return f=u.sent(),[2,{data:{serverId:t,id:f.channel_category_id,name:r,defaultCategory:!1},type:f.type}]}}))}))}function f(e){var t=e.serverId,r=e.categoryId,a=e.name;if(i.P6.checkDataType([{serverId:t,categoryId:r,name:a,required:!0,type:"string"}]),!n.XZ.call(this))return Promise.reject(l);var c=this.context,s=c.orgName,u=c.appName,d=c.accessToken,h=c.jid,g="".concat(this.apiUrl,"/").concat(s,"/").concat(u,"/circle/channel/category/").concat(r,"?resource=").concat(h.clientResource),f=p({url:g,token:d,data:{server_id:t,name:a},type:"PUT"});return o.kg.debug("Call updateCategory",e),i.P6.ajax(f).then((function(e){return{data:y(e.channelCategory),type:e.type}}))}function v(e){var t=e.serverId,r=e.pageSize,a=void 0===r?20:r,c=e.cursor,s=void 0===c?"":c;if(i.P6.checkDataType([{serverId:t,required:!0,type:"string"},{cursor:s,type:"string"},{pageSize:a,type:"number"}]),!n.XZ.call(this))return Promise.reject(l);var u=this.context,d=u.orgName,h=u.appName,g=u.accessToken,f="".concat(this.apiUrl,"/").concat(d,"/").concat(h,"/circle/channel/category/list?serverId=").concat(t,"&limit=").concat(a,"&cursor=").concat(s),v=p({url:f,token:g,type:"GET"});return o.kg.debug("Call getCategorylist",e),i.P6.ajax(v).then((function(e){var t={list:e.channelCategoryList.map((function(e){return y(e)}))};return e.cursor&&(t.cursor=e.cursor),{data:t,type:e.type}}))}function m(e){return s(this,void 0,void 0,(function(){var t,r,a,c,s,d,y,h,g;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,r=e.categoryId,i.P6.checkDataType([{serverId:t,categoryId:r,required:!0,type:"string"}]),n.XZ.call(this)?(a=this.context,c=a.orgName,s=a.appName,d=a.accessToken,y=a.jid,h="".concat(this.apiUrl,"/").concat(c,"/").concat(s,"/circle/channel/category/").concat(r,"?serverId=").concat(t,"&resource=").concat(y.clientResource),g=p({url:h,token:d,type:"DELETE"}),o.kg.debug("Call deleteCategory",e),[4,i.P6.ajax(g)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function k(e){var t=e.serverId,r=e.categoryId,a=e.pageSize,c=void 0===a?20:a,s=e.cursor,u=void 0===s?"":s;if(i.P6.checkDataType([{serverId:t,categoryId:r,required:!0,type:"string"},{cursor:u,type:"string"},{pageSize:c,type:"number"}]),!n.XZ.call(this))return Promise.reject(l);var d=this.context,y=d.orgName,g=d.appName,f=d.accessToken,v="".concat(this.apiUrl,"/").concat(y,"/").concat(g,"/circle/channel/category/").concat(r,"/public/member/list?serverId=").concat(t,"&limit=").concat(c,"&cursor=").concat(u),m=p({url:v,token:f,type:"GET"});return o.kg.debug("Call getCategoryPublicChannels",e),i.P6.ajax(m).then((function(e){var t={list:e.channels.map((function(e){return h(e)}))};return e.cursor&&(t.cursor=e.cursor),{data:t,type:e.type}}))}function I(e){var t=e.serverId,r=e.categoryId,a=e.pageSize,c=void 0===a?20:a,s=e.cursor,u=void 0===s?"":s;if(i.P6.checkDataType([{serverId:t,categoryId:r,required:!0,type:"string"},{cursor:u,type:"string"},{pageSize:c,type:"number"}]),!n.XZ.call(this))return Promise.reject(l);var d=this.context,y=d.orgName,g=d.appName,f=d.accessToken,v="".concat(this.apiUrl,"/").concat(y,"/").concat(g,"/circle/channel/category/").concat(r,"/private/member/list?serverId=").concat(t,"&limit=").concat(c,"&cursor=").concat(u),m=p({url:v,token:f,type:"GET"});return o.kg.debug("Call getCategoryPrivateChannels",e),i.P6.ajax(m).then((function(e){var t={list:e.channels.map((function(e){return h(e)}))};return e.cursor&&(t.cursor=e.cursor),{data:t,type:e.type}}))}function b(e){return s(this,void 0,void 0,(function(){var t,r,a,c,s,d,y,h,g,f;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,r=e.channelId,a=e.newCategoryId,i.P6.checkDataType([{serverId:t,channelId:r,required:!0,type:"string"},{newCategoryId:a,required:!1,type:"string"}]),n.XZ.call(this)?(c=this.context,s=c.orgName,d=c.appName,y=c.accessToken,h=c.jid,g="".concat(this.apiUrl,"/").concat(s,"/").concat(d,"/circle/channel/category/member/transfer?serverId=").concat(t,"&channelCategoryId=").concat(a,"&channelId=").concat(r,"&resource=").concat(h.clientResource),f=p({url:g,token:y,type:"POST"}),o.kg.debug("Call transferChannel",e),[4,i.P6.ajax(f)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}},3246:function(e,t,r){r.d(t,{H7:function(){return u},XZ:function(){return i},_W:function(){return s}}),r(7941),r(9554),r(1539),r(4747),r(6699),r(2023);var n=r(5531),a=r(7252);function c(){var e=this.context.appName,t=this.context.orgName;return!(!e||!t)||(this.onError&&this.onError({type:n.E.WEBIM_CONNCTION_AUTH_ERROR,message:"appName or orgName is illegal"}),!1)}function o(){var e;if(!this.context.accessToken){var t=a.Z.create({type:n.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(t),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",t),!1}return!0}function i(){return o.call(this)&&c.call(this)}function s(e){var t=e.data,r=e.type;return{data:{status:Object.keys(t.errorKeys).length>0?"fail":"success",errorKeys:t.errorKeys,successKeys:t.successKeys},type:r}}function u(e){var t=e.data,r=void 0;return Object.keys(t.errorKeys).length>0&&Object.keys(t.errorKeys).forEach((function(e){var c=t.errorKeys[e];r=c.includes("is not part of you")?a.Z.create({type:n.E.NO_PERMISSION,message:c}):c.includes("size of metadata for this single chatroom exceeds the user defined limit")||c.includes("total size of chatroom metadata for this app exceeds the user defined limit")||c.includes("is exceeding maximum limit")?a.Z.create({type:n.E.MAX_LIMIT,message:c}):c.includes("is not Legal")?a.Z.create({type:n.E.REQUEST_PARAMETER_ERROR,message:c}):c.includes("Failed to update userMetadata. Concurrent updates not allowed")?a.Z.create({type:n.E.OPERATION_NOT_ALLOWED,message:c}):a.Z.create({type:n.E.WEBIM_CONNCTION_AJAX_ERROR,message:c})})),r}}},function(e){return 5391,e(e.s=5391)}])}));
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import * as ChannelTypes from '../types/channelApi';
|
|
2
|
+
import { AsyncResult, OperationResult } from '../types/common';
|
|
3
|
+
export interface Channel {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a channel.
|
|
6
|
+
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* connection.createChannel({
|
|
9
|
+
* serverId: 'serverID',
|
|
10
|
+
* isPublic: true,
|
|
11
|
+
* name: 'channelName',
|
|
12
|
+
* description: 'this is my channel',
|
|
13
|
+
* ext: 'ext',
|
|
14
|
+
* categoryId?: 'categoryId',
|
|
15
|
+
* mode?: 1,
|
|
16
|
+
* maxusers: 8,
|
|
17
|
+
* rtcChannelId: 'rtcChannelId',
|
|
18
|
+
})
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
createChannel(params: {
|
|
22
|
+
/** The server ID. */
|
|
23
|
+
serverId: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether it is a public channel.
|
|
26
|
+
* - (Default)`true`: Public channel. Users can call the 'getPublicChannels' method to query public channels.
|
|
27
|
+
* - `false`: Private channel.
|
|
28
|
+
*/
|
|
29
|
+
isPublic?: boolean;
|
|
30
|
+
/** The channel name. */
|
|
31
|
+
name: string;
|
|
32
|
+
/** The channel description. */
|
|
33
|
+
description?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The maximum number of users that the channel can have.
|
|
36
|
+
*
|
|
37
|
+
* The default value varies with the channel type:
|
|
38
|
+
* - IM channel: 2000
|
|
39
|
+
* - Voice chatroom channel: 8
|
|
40
|
+
*/
|
|
41
|
+
maxusers?: number;
|
|
42
|
+
/** The channel extension field. */
|
|
43
|
+
ext?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The channel category ID.
|
|
46
|
+
*
|
|
47
|
+
* If this parameter is not set, the created channel will be added to the default channel category of the server by default.
|
|
48
|
+
*/
|
|
49
|
+
categoryId?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The channel type.
|
|
52
|
+
* - (Default) `0`: IM channel
|
|
53
|
+
* - `1`: Voice chatroom channel */
|
|
54
|
+
mode?: number;
|
|
55
|
+
/** The RTC channel name. */
|
|
56
|
+
rtcChannelId?: string;
|
|
57
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfo>>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Deletes a channel.
|
|
61
|
+
*
|
|
62
|
+
* Only the server owner can call this method.
|
|
63
|
+
*
|
|
64
|
+
* ```typescript
|
|
65
|
+
* connection.destroyChannel({serverId: 'serverId', channelId: 'channelId'})
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
destroyChannel(params: {
|
|
69
|
+
/** The server ID. */
|
|
70
|
+
serverId: string;
|
|
71
|
+
/** The channel ID. */
|
|
72
|
+
channelId: string;
|
|
73
|
+
}): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Modifies attributes of a channel.
|
|
76
|
+
*
|
|
77
|
+
* Only the server owner and moderators can call this method.
|
|
78
|
+
*
|
|
79
|
+
* ```typescript
|
|
80
|
+
* connection.updateChannel({
|
|
81
|
+
* serverId: 'serverId',
|
|
82
|
+
* channelId: 'channelId',
|
|
83
|
+
* name: 'the channel name',
|
|
84
|
+
* description: 'the channel description',
|
|
85
|
+
* maxusers: 8,
|
|
86
|
+
* isPublic:true,
|
|
87
|
+
* rtcChannelId 'rtcChannelId',
|
|
88
|
+
* })
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
updateChannel(params: {
|
|
93
|
+
/** The server ID. */
|
|
94
|
+
serverId: string;
|
|
95
|
+
/** The channel ID. */
|
|
96
|
+
channelId: string;
|
|
97
|
+
/** The channel name. */
|
|
98
|
+
name?: string;
|
|
99
|
+
/** The channel description. */
|
|
100
|
+
description?: string;
|
|
101
|
+
/** The maximum number of users that a channel can have. */
|
|
102
|
+
maxusers?: number;
|
|
103
|
+
/** The channel extension field. */
|
|
104
|
+
ext?: string;
|
|
105
|
+
/** Whether it is a public channel.
|
|
106
|
+
* - (Default) `true`: Yes. You can call the `getPublicChannels` method to query public channels.
|
|
107
|
+
* - `false`: No.
|
|
108
|
+
*/
|
|
109
|
+
isPublic?: boolean;
|
|
110
|
+
/** The RTC channel name. */
|
|
111
|
+
rtcChannelId?: string;
|
|
112
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfo>>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Gets the details of a channel.
|
|
116
|
+
*
|
|
117
|
+
* ```typescript
|
|
118
|
+
* connection.getChannelDetail({serverId: 'serverId', channelId: 'channelId'})
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
getChannelDetail(params: {
|
|
123
|
+
/** The server ID. */
|
|
124
|
+
serverId: string;
|
|
125
|
+
/** The channel ID. */
|
|
126
|
+
channelId: string;
|
|
127
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfo>>;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Joins the channel.
|
|
131
|
+
*
|
|
132
|
+
* ```typescript
|
|
133
|
+
* connection.joinChannel({serverId: 'serverId', channelId: 'channelId'})
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
joinChannel(params: {
|
|
138
|
+
/** The server ID. */
|
|
139
|
+
serverId: string;
|
|
140
|
+
/** The channel ID. */
|
|
141
|
+
channelId: string;
|
|
142
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfo>>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Leaves a channel.
|
|
146
|
+
*
|
|
147
|
+
* ```typescript
|
|
148
|
+
* connection.leaveChannel({serverId: 'serverId', channelId: 'channelId'})
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
leaveChannel(params: {
|
|
153
|
+
/** The server ID. */
|
|
154
|
+
serverId: string;
|
|
155
|
+
/** The channel ID. */
|
|
156
|
+
channelId: string;
|
|
157
|
+
}): Promise<void>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Removes a member from the channel.
|
|
161
|
+
*
|
|
162
|
+
* The server owner can remove all members from a channel. A server moderator can only remove common members from a channel.
|
|
163
|
+
*
|
|
164
|
+
* ```typescript
|
|
165
|
+
* connection.removeChannelMember({serverId: 'serverId', channelId: 'channelId',userId: 'userId'})
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
*/
|
|
169
|
+
removeChannelMember(params: {
|
|
170
|
+
/** The server ID. */
|
|
171
|
+
serverId: string;
|
|
172
|
+
/** The channel ID. */
|
|
173
|
+
channelId: string;
|
|
174
|
+
/** The user ID of the member to be removed from the channel. */
|
|
175
|
+
userId: string;
|
|
176
|
+
}): Promise<void>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Gets the list of private channels with pagination.
|
|
180
|
+
*
|
|
181
|
+
* ```typescript
|
|
182
|
+
* connection.getPrivateChannels({serverId:'serverId',pageSize: 10,cursor: ''})
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
*/
|
|
186
|
+
getPrivateChannels(params: {
|
|
187
|
+
/** The server ID. */
|
|
188
|
+
serverId: string;
|
|
189
|
+
/** The number of private channels that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
|
|
190
|
+
pageSize?: number;
|
|
191
|
+
/** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK gets channels in the chronological order of when they were created.*/
|
|
192
|
+
cursor?: string;
|
|
193
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfoListResult>>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Gets the list of public channels in a server with pagination.
|
|
197
|
+
*
|
|
198
|
+
* ```typescript
|
|
199
|
+
* connection.getPublicChannels({serverId:'serverId',pageSize: 10,cursor: ''})
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
*/
|
|
203
|
+
getPublicChannels(params: {
|
|
204
|
+
/** The server ID. */
|
|
205
|
+
serverId: string;
|
|
206
|
+
/** The number of public channels that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
|
|
207
|
+
pageSize?: number;
|
|
208
|
+
/** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK gets channels in the chronological order of when they were created.*/
|
|
209
|
+
cursor?: string;
|
|
210
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfoListResult>>;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets the member list of a channel with pagination.
|
|
214
|
+
*
|
|
215
|
+
* ```typescript
|
|
216
|
+
* connection.getChannelMembers({serverId:'serverId', channelId: 'channelId', pageSize: 10,cursor: ''})
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
*/
|
|
220
|
+
getChannelMembers(params: {
|
|
221
|
+
/** The server ID. */
|
|
222
|
+
serverId: string;
|
|
223
|
+
/** The channel ID. */
|
|
224
|
+
channelId: string;
|
|
225
|
+
/** The number of members that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
|
|
226
|
+
pageSize?: number;
|
|
227
|
+
/** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK gets members in the chronological order of when they were created.*/
|
|
228
|
+
cursor?: string;
|
|
229
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelMemberListResult>>;
|
|
230
|
+
/**
|
|
231
|
+
* Invites users to join a channel.
|
|
232
|
+
*
|
|
233
|
+
* ```typescript
|
|
234
|
+
* connection.inviteUserToChannel({serverId: 'serverId',channelId: 'channelId',userId: 'userId'})
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
inviteUserToChannel(params: {
|
|
238
|
+
/** The server ID. */
|
|
239
|
+
serverId: string;
|
|
240
|
+
/** The channel ID. */
|
|
241
|
+
channelId: string;
|
|
242
|
+
/** The user ID of the invitee. */
|
|
243
|
+
userId: string;
|
|
244
|
+
/** The welcome message for inviting a user to join the channel. */
|
|
245
|
+
inviteMessage?: string;
|
|
246
|
+
}): Promise<void>;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Accepts an invitation to join a channel.
|
|
250
|
+
*
|
|
251
|
+
* ```typescript
|
|
252
|
+
* connection.acceptChannelInvite({serverId: 'serverId',channelId: 'channelId',inviter:'inviter'})
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
acceptChannelInvite(params: {
|
|
256
|
+
/** The server ID. */
|
|
257
|
+
serverId: string;
|
|
258
|
+
/** The channel ID. */
|
|
259
|
+
channelId: string;
|
|
260
|
+
/** The user ID of the inviter. */
|
|
261
|
+
inviter: string;
|
|
262
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelInfo>>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Declines an invitation to join a channel.
|
|
266
|
+
*
|
|
267
|
+
* ```typescript
|
|
268
|
+
* connection.rejectChannelInvite({serverId: 'serverId',channelId: 'channelId'})
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
rejectChannelInvite(params: {
|
|
272
|
+
/** The server ID. */
|
|
273
|
+
serverId: string;
|
|
274
|
+
/** The channel ID. */
|
|
275
|
+
channelId: string;
|
|
276
|
+
/** The user ID of the inviter. */
|
|
277
|
+
inviter: string;
|
|
278
|
+
}): Promise<void>;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Mutes a member in the channel.
|
|
282
|
+
*
|
|
283
|
+
* Only the server owner and moderators can call this method.
|
|
284
|
+
*
|
|
285
|
+
* ```typescript
|
|
286
|
+
* connection.muteChannelMember({serverId: 'serverId',channelId: 'channelId',userId: 'userId'})
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
muteChannelMember(params: {
|
|
290
|
+
/** The server ID. */
|
|
291
|
+
serverId: string;
|
|
292
|
+
/** The channel ID. */
|
|
293
|
+
channelId: string;
|
|
294
|
+
/** The user ID of the member to mute. */
|
|
295
|
+
userId: string;
|
|
296
|
+
/** The mute duration in milliseconds. The value `-1` indicates that the member is muted permanently.*/
|
|
297
|
+
duration: number;
|
|
298
|
+
}): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Unmutes a member in the channel.
|
|
301
|
+
*
|
|
302
|
+
* Only the server owner and moderators can call this method.
|
|
303
|
+
*
|
|
304
|
+
* ```typescript
|
|
305
|
+
* connection.muteChannelMember({serverId: 'serverId',channelId: 'channelId',userId: 'userId'})
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
unmuteChannelMember(params: {
|
|
309
|
+
/** The server ID. */
|
|
310
|
+
serverId: string;
|
|
311
|
+
/** The channel ID. */
|
|
312
|
+
channelId: string;
|
|
313
|
+
/** The user ID of the member to unmute. */
|
|
314
|
+
userId: string;
|
|
315
|
+
}): Promise<void>;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Gets the list of muted members in a channel.
|
|
319
|
+
*
|
|
320
|
+
* Only the server owner and moderator can call this method.
|
|
321
|
+
*
|
|
322
|
+
* ```typescript
|
|
323
|
+
* connection.getChannelMutelist({channelId: 'channelId'})
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
getChannelMutelist(params: {
|
|
327
|
+
/** The server ID. */
|
|
328
|
+
serverId: string;
|
|
329
|
+
/** The channel ID. */
|
|
330
|
+
channelId: string;
|
|
331
|
+
}): Promise<AsyncResult<ChannelTypes.ChannelMuteMemberListResult>>;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Checks whether the current user is in the channel.
|
|
335
|
+
*
|
|
336
|
+
* ```typescript
|
|
337
|
+
* connection.isInChannel({serverId: 'serverId', channelId: "channelId"})
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
isInChannel(params: {
|
|
341
|
+
/** The server ID. */
|
|
342
|
+
serverId: string;
|
|
343
|
+
/** The channel ID. */
|
|
344
|
+
channelId: string;
|
|
345
|
+
}): Promise<AsyncResult<OperationResult>>;
|
|
346
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!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()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[325],{2890:function(e,t,n){n.r(t),n.d(t,{acceptChannelInvite:function(){return C},createChannel:function(){return v},destroyChannel:function(){return m},getChannelDetail:function(){return f},getChannelMembers:function(){return T},getChannelMutelist:function(){return _},getPrivateChannels:function(){return P},getPublicChannels:function(){return b},inviteUserToChannel:function(){return x},isInChannel:function(){return O},joinChannel:function(){return I},leaveChannel:function(){return g},muteChannelMember:function(){return N},rejectChannelInvite:function(){return j},removeChannelMember:function(){return k},unmuteChannelMember:function(){return E},updateChannel:function(){return y}}),n(1539),n(8674),n(2526),n(1817),n(2165),n(6992),n(8783),n(3948),n(8309),n(6699),n(2222),n(1249);var r=n(3246),c=n(5531),a=n(7252),o=n(7360),i=n(4370),s=function(e,t,n,r){return new(n||(n=Promise))((function(c,a){function o(e){try{s(r.next(e))}catch(e){a(e)}}function i(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?c(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,i)}s((r=r.apply(e,t||[])).next())}))},u=function(e,t){var n,r,c,a,o={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(c=2&a[0]?r.return:a[0]?r.throw||((c=r.return)&&c.call(r),0):r.next)&&!(c=c.call(r,a[1])).done)return c;switch(r=0,c&&(a=[2&a[0],c.value]),a[0]){case 0:case 1:c=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((c=(c=o.trys).length>0&&c[c.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!c||a[1]>c[0]&&a[1]<c[3])){o.label=a[1];break}if(6===a[0]&&o.label<c[1]){o.label=c[1],c=a;break}if(c&&o.label<c[2]){o.label=c[2],o.ops.push(a);break}c[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=c=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}},l=a.Z.create({type:c.E.REST_PARAMS_STATUS,message:"appkey or token error"}),d=a.Z.create({type:c.E.REQUEST_UNKNOWN,message:"Request Unknown Error"}),h=function(e){try{var t=e.channel_id,n=e.created,r=e.custom,c=e.default_channel,a=e.description,i=e.type,s=e.name,u=e.server_id,l=e.channel_category_id,h=e.mode,p={serverId:u,channelId:t,name:s,description:a,created:n,defaultChannel:0!==c,ext:r,isPublic:!i,categoryId:l,mode:h,maxusers:e.max_users};return 1===h&&(p.rtcChannelId=e.rtc_name),p}catch(t){throw o.kg.error("unexpected channel data: ".concat(e)),d}},p=function(e){var t=e.url,n=void 0===t?"":t,r=e.type,c=void 0===r?"POST":r,a=e.dataType,o=void 0===a?"json":a,i=e.data,s=void 0===i?"":i,u=e.token,l=void 0===u?"":u;return{url:n,type:c,dataType:o,data:s?JSON.stringify(s):null,headers:{Authorization:"Bearer ".concat(l),"Content-Type":"application/json"}}};function v(e){if(!r.XZ.call(this))return Promise.reject(l);var t=e.serverId,n=e.isPublic,c=void 0===n||n,a=e.name,s=e.description,u=e.ext,d=e.categoryId,v=e.mode,m=void 0===v?0:v,y=e.maxusers,f=e.rtcChannelId;if(i.P6.checkDataType([{serverId:t,name:a,required:!0,type:"string"},{isPublic:c,required:!1,type:"boolean"},{description:s,ext:u,categoryId:d,rtcChannelId:f,required:!1,type:"string"},{mode:m,maxusers:y,required:!1,type:"number"}]),![0,1].includes(m))throw Error('"Invalid parameter mode": '+m);var I=this.context,g=I.orgName,k=I.appName,P=I.accessToken,b=I.jid,T={server_id:t,owner:this.user,name:a,type:c?0:1,description:s,custom:u,channel_category_id:d,mode:m,maxusers:y,rtc_name:f},x="".concat(this.apiUrl,"/").concat(g,"/").concat(k,"/circle/channel?resource=").concat(b.clientResource),C=p({url:x,data:T,token:P,type:"POST"});return o.kg.debug("Call createChannel","params",e),i.P6.ajax(C).then((function(e){return{data:h(e.channel),type:e.code}}))}function m(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,n=e.channelId,i.P6.checkDataType([{serverId:t,channelId:n,required:!0,type:"string"}]),r.XZ.call(this)?(c=this.context,a=c.orgName,s=c.appName,d=c.accessToken,h=c.jid,v="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(n,"?serverId=").concat(t,"&resource=").concat(h.clientResource),m=p({url:v,token:d,type:"DELETE"}),o.kg.debug("Call destroyChannel",e),[4,i.P6.ajax(m)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function y(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,v,m,y,f,I,g,k,P,b,T;return u(this,(function(u){return t=e.serverId,n=e.channelId,c=e.name,a=e.description,s=e.ext,d=e.maxusers,v=e.isPublic,m=e.rtcChannelId,i.P6.checkDataType([{serverId:t,channelId:n,required:!0,type:"string"},{name:c,description:a,ext:s,rtcChannelId:m,type:"string"},{isPublic:v,ext:s,type:"boolean"},{maxusers:d,ext:s,type:"number"}]),r.XZ.call(this)?(y=this.context,f=y.orgName,I=y.appName,g=y.accessToken,k=y.jid,P="".concat(this.apiUrl,"/").concat(f,"/").concat(I,"/circle/channel/").concat(n,"?serverId=").concat(t,"&resource=").concat(k.clientResource),b={name:c,description:a,custom:s,max_users:d,rtc_name:m},void 0!==v&&(b.type=v?0:1),T=p({url:P,token:g,data:b,type:"PUT"}),o.kg.debug("Call updateChannel",e),[2,i.P6.ajax(T).then((function(e){return{data:h(e.channel),type:e.type}}))]):[2,Promise.reject(l)]}))}))}function f(e){var t=e.serverId,n=e.channelId;if(i.P6.checkDataType([{serverId:t,channelId:n,required:!0,type:"string"}]),!r.XZ.call(this))return Promise.reject(l);var c=this.context,a=c.orgName,s=c.appName,u=c.accessToken,d="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(n,"?serverId=").concat(t),v=p({url:d,token:u,type:"GET"});return o.kg.debug("Call getChannelDetail",e),i.P6.ajax(v).then((function(e){return{data:h(e.channel),type:e.type}}))}function I(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,v,m,y;return u(this,(function(u){return t=e.channelId,n=e.serverId,i.P6.checkDataType([{serverId:n,channelId:t,required:!0,type:"string"}]),r.XZ.call(this)?(c=this.context,a=c.orgName,s=c.appName,d=c.accessToken,v=c.jid,m="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(t,"/join?userId=").concat(this.user,"&serverId=").concat(n,"&resource=").concat(v.clientResource),y=p({url:m,token:d,type:"POST"}),o.kg.debug("Call joinChannel",e),[2,i.P6.ajax(y).then((function(e){return{data:h(e.channel),type:e.type}}))]):[2,Promise.reject(l)]}))}))}function g(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m;return u(this,(function(u){switch(u.label){case 0:return t=e.channelId,n=e.serverId,i.P6.checkDataType([{serverId:n,channelId:t,required:!0,type:"string"}]),r.XZ.call(this)?(c=this.context,a=c.orgName,s=c.appName,d=c.accessToken,h=c.jid,v="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(t,"/user/quit?userId=").concat(this.user,"&serverId=").concat(n,"&resource=").concat(h.clientResource),m=p({url:v,token:d,type:"POST"}),o.kg.debug("Call leaveChannel",e),[4,i.P6.ajax(m)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function k(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m,y;return u(this,(function(u){switch(u.label){case 0:return t=e.channelId,n=e.serverId,c=e.userId,i.P6.checkDataType([{serverId:n,channelId:t,userId:c,required:!0,type:"string"}]),r.XZ.call(this)?(a=this.context,s=a.orgName,d=a.appName,h=a.accessToken,v=a.jid,m="".concat(this.apiUrl,"/").concat(s,"/").concat(d,"/circle/channel/").concat(t,"/user/remove?userId=").concat(c,"&serverId=").concat(n,"&resource=").concat(v.clientResource),y=p({url:m,token:h,type:"POST"}),o.kg.debug("Call removeChannelMember",e),[4,i.P6.ajax(y)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function P(e){var t=e.serverId,n=e.pageSize,c=void 0===n?20:n,a=e.cursor,s=void 0===a?"":a;if(i.P6.checkDataType([{serverId:t,required:!0,type:"string"},{cursor:s,type:"string"},{pageSize:c,type:"number"}]),!r.XZ.call(this))return Promise.reject(l);var u=this.context,d=u.orgName,v=u.appName,m=u.accessToken,y="".concat(this.apiUrl,"/").concat(d,"/").concat(v,"/circle/channel/private?userId=").concat(this.user,"&serverId=").concat(t,"&limit=").concat(c,"&cursor=").concat(s),f=p({url:y,token:m,type:"GET"});return o.kg.debug("Call getPrivateChannels",e),i.P6.ajax(f).then((function(e){var t={list:e.channels.map((function(e){return h(e)}))};return e.cursor&&(t.cursor=e.cursor),{data:t,type:e.type}}))}function b(e){var t=e.serverId,n=e.pageSize,c=void 0===n?20:n,a=e.cursor,s=void 0===a?"":a;if(i.P6.checkDataType([{serverId:t,required:!0,type:"string"},{cursor:s,type:"string"},{pageSize:c,required:!1,type:"number"}]),!r.XZ.call(this))return Promise.reject(l);var u=this.context,d=u.orgName,v=u.appName,m=u.accessToken,y="".concat(this.apiUrl,"/").concat(d,"/").concat(v,"/circle/channel/public?serverId=").concat(t,"&limit=").concat(c,"&cursor=").concat(s),f=p({url:y,token:m,type:"GET"});return o.kg.debug("Call getPublicChannels",e),i.P6.ajax(f).then((function(e){var t={list:e.channels.map((function(e){return h(e)}))};return e.cursor&&(t.cursor=e.cursor),{data:t,type:e.type}}))}function T(e){var t=e.serverId,n=e.channelId,c=e.pageSize,a=void 0===c?20:c,s=e.cursor,u=void 0===s?"":s;if(i.P6.checkDataType([{serverId:t,channelId:n,required:!0,type:"string"},{cursor:u,type:"string"},{pageSize:a,required:!1,type:"number"}]),!r.XZ.call(this))return Promise.reject(l);var d=this.context,h=d.orgName,v=d.appName,m=d.accessToken,y="".concat(this.apiUrl,"/").concat(h,"/").concat(v,"/circle/channel/").concat(n,"/users?serverId=").concat(t,"&limit=").concat(a,"&cursor=").concat(u),f=p({url:y,token:m,type:"GET"});return o.kg.debug("Call getChannelMembers",e),i.P6.ajax(f).then((function(e){var t={list:e.users.map((function(e){return{role:0===e.role?"owner":1===e.role?"moderator":"user",userId:e.user_id}}))};return e.cursor&&(t.cursor=e.cursor),{data:t,type:e.type}}))}function x(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m,y,f,I;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,n=e.channelId,c=e.userId,a=e.inviteMessage,s=void 0===a?"":a,i.P6.checkDataType([{serverId:t,channelId:n,userId:c,required:!0,type:"string"}]),r.XZ.call(this)?(d=this.context,h=d.orgName,v=d.appName,m=d.accessToken,y=d.jid,f="".concat(this.apiUrl,"/").concat(h,"/").concat(v,"/circle/channel/").concat(n,"/invite/join?serverId=").concat(t,"&userId=").concat(c,"&welcome=").concat(s,"&resource=").concat(y.clientResource),I=p({url:f,token:m,type:"POST"}),o.kg.debug("Call inviteUserToChannel",e),[4,i.P6.ajax(I)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function C(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,v,m,y;return u(this,(function(u){return t=e.serverId,n=e.channelId,i.P6.checkDataType([{serverId:t,channelId:n,required:!0,type:"string"}]),r.XZ.call(this)?(c=this.context,a=c.orgName,s=c.appName,d=c.accessToken,v=c.jid,m="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(n,"/accept/invite?inviter=").concat(e.inviter,"&serverId=").concat(t,"&resource=").concat(v.clientResource),y=p({url:m,token:d,type:"POST"}),o.kg.debug("Call acceptChannelInvite",e),[2,i.P6.ajax(y).then((function(e){return{data:h(e.channel),type:e.type}}))]):[2,Promise.reject(l)]}))}))}function j(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,n=e.channelId,i.P6.checkDataType([{serverId:t,channelId:n,required:!0,type:"string"}]),r.XZ.call(this)?(c=this.context,a=c.orgName,s=c.appName,d=c.accessToken,h=c.jid,v="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(n,"/decline/invite?inviter=").concat(e.inviter,"&serverId=").concat(t,"&resource=").concat(h.clientResource),m=p({url:v,token:d,type:"POST"}),o.kg.debug("Call rejectChannelInvite",e),[4,i.P6.ajax(m)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function N(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m,y,f;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,n=e.channelId,c=e.userId,a=e.duration,i.P6.checkDataType([{serverId:t,channelId:n,userId:c,required:!0,type:"string"},{duration:a,required:!0,type:"number"}]),r.XZ.call(this)?(s=this.context,d=s.orgName,h=s.appName,v=s.accessToken,m=s.jid,y="".concat(this.apiUrl,"/").concat(d,"/").concat(h,"/circle/channel/").concat(n,"/user/mute?resource=").concat(m.clientResource),f=p({url:y,data:{server_id:t,user_id:c,duration:a},token:v,type:"POST"}),o.kg.debug("Call muteChannelMember",e),[4,i.P6.ajax(f)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function E(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v,m,y;return u(this,(function(u){switch(u.label){case 0:return t=e.serverId,n=e.channelId,c=e.userId,i.P6.checkDataType([{serverId:t,channelId:n,userId:c,required:!0,type:"string"}]),r.XZ.call(this)?(a=this.context,s=a.orgName,d=a.appName,h=a.accessToken,v=a.jid,m="".concat(this.apiUrl,"/").concat(s,"/").concat(d,"/circle/channel/").concat(n,"/user/mute?serverId=").concat(t,"&userId=").concat(c,"&resource=").concat(v.clientResource),y=p({url:m,token:h,type:"DELETE"}),o.kg.debug("Call unmuteChannelMember",e),[4,i.P6.ajax(y)]):[2,Promise.reject(l)];case 1:return u.sent(),[2]}}))}))}function _(e){var t=e.channelId,n=e.serverId;if(i.P6.checkDataType([{channelId:t,required:!0,type:"string"}]),!r.XZ.call(this))return Promise.reject(l);var c=this.context,a=c.orgName,s=c.appName,u=c.accessToken,d="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(t,"/user/mute/list?serverId=").concat(n),h=p({url:d,token:u,type:"GET"});return o.kg.debug("Call getChannelMutelist",e),i.P6.ajax(h).then((function(e){return{data:{list:e.mute_users.map((function(e){return{expire:e.expire,userId:e.user}}))},type:e.type}}))}function O(e){return s(this,void 0,void 0,(function(){var t,n,c,a,s,d,h,v;return u(this,(function(u){return t=e.channelId,n=e.serverId,i.P6.checkDataType([{serverId:n,channelId:t,required:!0,type:"string"}]),r.XZ.call(this)?(c=this.context,a=c.orgName,s=c.appName,d=c.accessToken,h="".concat(this.apiUrl,"/").concat(a,"/").concat(s,"/circle/channel/").concat(t,"/user/").concat(this.user,"?serverId=").concat(n),v=p({url:h,token:d,type:"GET"}),o.kg.debug("Call isInChannel",e),[2,i.P6.ajax(v).then((function(e){return{data:{result:e.result},type:e.type}}))]):[2,Promise.reject(l)]}))}))}},3246:function(e,t,n){n.d(t,{H7:function(){return u},XZ:function(){return i},_W:function(){return s}}),n(7941),n(9554),n(1539),n(4747),n(6699),n(2023);var r=n(5531),c=n(7252);function a(){var e=this.context.appName,t=this.context.orgName;return!(!e||!t)||(this.onError&&this.onError({type:r.E.WEBIM_CONNCTION_AUTH_ERROR,message:"appName or orgName is illegal"}),!1)}function o(){var e;if(!this.context.accessToken){var t=c.Z.create({type:r.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(t),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",t),!1}return!0}function i(){return o.call(this)&&a.call(this)}function s(e){var t=e.data,n=e.type;return{data:{status:Object.keys(t.errorKeys).length>0?"fail":"success",errorKeys:t.errorKeys,successKeys:t.successKeys},type:n}}function u(e){var t=e.data,n=void 0;return Object.keys(t.errorKeys).length>0&&Object.keys(t.errorKeys).forEach((function(e){var a=t.errorKeys[e];n=a.includes("is not part of you")?c.Z.create({type:r.E.NO_PERMISSION,message:a}):a.includes("size of metadata for this single chatroom exceeds the user defined limit")||a.includes("total size of chatroom metadata for this app exceeds the user defined limit")||a.includes("is exceeding maximum limit")?c.Z.create({type:r.E.MAX_LIMIT,message:a}):a.includes("is not Legal")?c.Z.create({type:r.E.REQUEST_PARAMETER_ERROR,message:a}):a.includes("Failed to update userMetadata. Concurrent updates not allowed")?c.Z.create({type:r.E.OPERATION_NOT_ALLOWED,message:a}):c.Z.create({type:r.E.WEBIM_CONNCTION_AJAX_ERROR,message:a})})),n}}},function(e){return 2890,e(e.s=2890)}])}));
|