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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easemob-websdk",
3
- "version": "4.1.3",
3
+ "version": "4.1.4-beta",
4
4
  "description": "Easemob chat websdk",
5
5
  "main": "Easemob-chat",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -14,6 +14,10 @@ npm install easemob-websdk --save
14
14
 
15
15
  ```
16
16
  import EC from 'easemob-websdk'
17
+
18
+ 如需使用超级社区相关功能,需要按以下方式引入
19
+ import EC from 'easemob-websdk/circleSdk/Easemob-chat'
20
+
17
21
  ```
18
22
 
19
23
  3、初始化 SDK
@@ -0,0 +1,318 @@
1
+ import * as ServerTypes from '../types/serverApi';
2
+ import { AsyncResult, OperationResult } from '../types/common';
3
+ export interface Server {
4
+ /**
5
+ * Creates a server.
6
+ *
7
+ * ```typescript
8
+ * connection.createServer({name: 'serverName',icon: '',description: 'the description of the server',ext: 'ext',isPublic:true, backgroundUrl:""})
9
+ * ```
10
+ */
11
+ createServer(params: {
12
+ /** The server name. */
13
+ name: string;
14
+ /** The server icon. */
15
+ icon?: string;
16
+ /** The server description. */
17
+ description?: string;
18
+ /** The server extension field. */
19
+ ext?: string;
20
+ /**
21
+ * Whether it is a public server:
22
+ * - (Default) `true`: Public server. You can call the `getServers` method to search for a public server.
23
+ * - `false`: Private server.
24
+ */
25
+ isPublic?: boolean;
26
+ /** The background of the server. */
27
+ backgroundUrl?: string;
28
+ }): Promise<AsyncResult<ServerTypes.ServerInfo>>;
29
+
30
+ /**
31
+ * Destroys a server.
32
+ *
33
+ * Only the server owner can call this method.
34
+ *
35
+ * ```typescript
36
+ * connection.destroyServer({serverId: 'serverId'})
37
+ * ```
38
+ */
39
+ destroyServer(params: {
40
+ /** The ID of the server to destroy. */
41
+ serverId: string;
42
+ }): Promise<void>;
43
+ /**
44
+ * Modifies attributes of a server.
45
+ *
46
+ * Only the server owner and moderators can call this method.
47
+ *
48
+ * ```typescript
49
+ * connection.updateServer({serverId: 'serverId',name: 'name',icon: '',description: 'new description',isPublic: true, backgroundUrl: ''})
50
+ * ```
51
+ */
52
+ updateServer(params: {
53
+ /** The server ID. */
54
+ serverId: string;
55
+ /** The server name. */
56
+ name?: string;
57
+ /** The server icon URL.*/
58
+ icon?: string;
59
+ /** The description of the server. */
60
+ description?: string;
61
+ /** The custom server extension parameter in string format.*/
62
+ ext?: string;
63
+ /** Whether it is a public server.
64
+ * - (Default)`true`: Public server. You can call `getServers` to search for public servers.
65
+ * - `false`: Private server.
66
+ */
67
+ isPublic?: boolean;
68
+ /** The background of the server. */
69
+ backgroundUrl?: string;
70
+ }): Promise<AsyncResult<ServerTypes.ServerInfo>>;
71
+
72
+ /**
73
+ * Joins a server.
74
+ *
75
+ * ```typescript
76
+ * connection.joinServer({serverId: 'serverId'})
77
+ * ```
78
+ */
79
+ joinServer(params: {
80
+ /** The server ID. */
81
+ serverId: string;
82
+ }): Promise<AsyncResult<ServerTypes.ServerInfo>>;
83
+
84
+ /**
85
+ * Leaves a server.
86
+ *
87
+ * ```typescript
88
+ * connection.leaveServer({serverId: 'serverId'})
89
+ * ```
90
+ */
91
+ leaveServer(params: {
92
+ /** The server ID. */
93
+ serverId: string;
94
+ }): Promise<void>;
95
+
96
+ /**
97
+ * Removes a member from the server.
98
+ *
99
+ * The server owner can remove all members from the server. A server moderator can only remove common members from the server.
100
+ *
101
+ * ```typescript
102
+ * connection.removeServerMember({serverId: 'serverId',userId: 'userId})
103
+ * ```
104
+ */
105
+ removeServerMember(params: {
106
+ /** The server ID. */
107
+ serverId: string;
108
+ /** The user ID of the member to be removed from the server. */
109
+ userId: string;
110
+ }): Promise<void>;
111
+
112
+ /**
113
+ * Adds a list of tags for the server.
114
+ *
115
+ * A server can have 10 tags at most.
116
+ *
117
+ * ```typescript
118
+ * connection.addServerTags({serverId: 'serverId',tags: ['A', 'B']})
119
+ * ```
120
+ */
121
+ addServerTags(params: {
122
+ /** The server ID. */
123
+ serverId: string;
124
+ /** A name list of server tags to add. A server can have 10 tags at most. */
125
+ tags: string[];
126
+ }): Promise<AsyncResult<ServerTypes.ServerTagList>>;
127
+ /**
128
+ * Removes a list of server tags.
129
+ *
130
+ * ```typescript
131
+ * connection.removeServerTags({serverId: 'serverId',tagIds: ['1', '2']})
132
+ * ```
133
+ */
134
+ removeServerTags(params: {
135
+ /** The server ID. */
136
+ serverId: string;
137
+ /** A list of server tag IDs to remove. */
138
+ tagIds: string[];
139
+ }): Promise<void>;
140
+
141
+ /**
142
+ * Use the pagination to get the list of servers by the keyword.
143
+ *
144
+ * The method will return results only when the keyword is the complete server name or server tag name.
145
+ *
146
+ * ```typescript
147
+ * connection.getServers({keyword: 'keyword',type:'serverName'})
148
+ * ```
149
+ */
150
+ getServers(params: {
151
+ /** The keyword for search, which can be the server name or server tag name. This method does not support fuzzy search, and therefore you need to pass the complete server name or server tag name. */
152
+ keyword: string;
153
+ /** The number of servers that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
154
+ pageSize?: number;
155
+ /** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK retrieves servers in the chronological order of when they were created.*/
156
+ cursor?: string;
157
+ /** The search type.
158
+ * - (Default)`serverName`: Search by server name.
159
+ * - `tagName`:Search by tag name.
160
+ */
161
+ type?: 'serverName' | 'tagName';
162
+ }): Promise<AsyncResult<ServerTypes.ServerInfoList>>;
163
+
164
+ /**
165
+ * Uses the pagination to get a list of servers that the current user joined.
166
+ *
167
+ * ```typescript
168
+ * connection.getJoinedServers({pageSize: '10',cursor: ''})
169
+ * ```
170
+ */
171
+ getJoinedServers(params: {
172
+ /** The number of servers that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
173
+ pageSize?: number;
174
+ /** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK retrieves servers in the chronological order of when they were created.*/
175
+ cursor?: string;
176
+ }): Promise<AsyncResult<ServerTypes.ServerInfoList>>;
177
+
178
+ /**
179
+ * Gets details of a server.
180
+ *
181
+ * ```typescript
182
+ * connection.getServerDetail({serverId: 'serverId'})
183
+ * ```
184
+ */
185
+ getServerDetail(params: {
186
+ /** The server ID. */
187
+ serverId: string;
188
+ }): Promise<AsyncResult<ServerTypes.ServerInfo>>;
189
+ /**
190
+ * Uses the pagination to get the list of members in a server.
191
+ *
192
+ * ```typescript
193
+ * connection.getServerMembers({serverId: 'serverId',pageSize:20,cursor:'cursor'})
194
+ * ```
195
+ */
196
+ getServerMembers(params: {
197
+ /** The server ID. */
198
+ serverId: string;
199
+ /** The number of members that you expect to get on each page. The value range is [1,20] and the default value is `20`. */
200
+ pageSize?: number;
201
+ /** The position from which to start getting data. If you set `cursor` to an empty string at the first method call, the SDK retrieves members in the chronological order of when they joined the server.*/
202
+ cursor?: string;
203
+ }): Promise<AsyncResult<ServerTypes.ServerMemberData>>;
204
+
205
+ /**
206
+ * Sets a server member as a moderator.
207
+ *
208
+ * Only the server owner can call this method.
209
+ *
210
+ * ```typescript
211
+ * connection.setServerAdmin({serverId: 'serverId',userId:'userId'})
212
+ * ```
213
+ */
214
+ setServerAdmin(params: {
215
+ /** The server ID. */
216
+ /** 社区 ID。*/
217
+ serverId: string;
218
+ /** The user ID of the member set as a server moderator.*/
219
+ /** 要设置为社区管理员的用户 ID。*/
220
+ userId: string;
221
+ }): Promise<void>;
222
+
223
+ /**
224
+ * Removes the administrative privileges of a server moderator.
225
+ *
226
+ * Only the server owner can call this method.
227
+ *
228
+ * ```typescript
229
+ * connection.removeServerAdmin({serverId: 'serverId',userId:'userId'})
230
+ * ```
231
+ */
232
+ removeServerAdmin(params: {
233
+ /** The server ID. */
234
+ serverId: string;
235
+ /** The user ID of the server moderator whose administrative privileges are to be removed.*/
236
+ userId: string;
237
+ }): Promise<void>;
238
+
239
+ /**
240
+ * Invites a user to join the server.
241
+ *
242
+ * ```typescript
243
+ * connection.inviteUserToServer({serverId: 'serverId', userId: 'userId'})
244
+ * ```
245
+ */
246
+ inviteUserToServer(params: {
247
+ /** The server ID. */
248
+ serverId: string;
249
+ /** The user ID of the invitee. */
250
+ userId: string;
251
+ /** The welcome message for inviting the user to join the server.*/
252
+ message?: string;
253
+ }): Promise<void>;
254
+
255
+ /**
256
+ * Accepts the invitation to join the server.
257
+ *
258
+ * ```typescript
259
+ * connection.acceptServerInvite({serverId: 'serverId',inviter: 'uid')
260
+ * ```
261
+ */
262
+ acceptServerInvite(params: {
263
+ /** The server ID. */
264
+ serverId: string;
265
+ /** The user ID of the inviter.*/
266
+ inviter: string;
267
+ }): Promise<AsyncResult<ServerTypes.ServerInfo>>;
268
+
269
+ /**
270
+ * Declines the invitation to join the server.
271
+ *
272
+ * ```typescript
273
+ * connection.rejectServerInvite({serverId: 'serverId',inviter: 'uid')
274
+ * ```
275
+ */
276
+ rejectServerInvite(params: {
277
+ /** The server ID. */
278
+ serverId: string;
279
+ /** The user ID of the inviter. */
280
+ inviter: string;
281
+ }): Promise<void>;
282
+
283
+ /**
284
+ * Gets the server role of the current user.
285
+ *
286
+ * ```typescript
287
+ * connection.getServerRole({serverId: 'serverId'})
288
+ * ```
289
+ */
290
+ getServerRole(params: {
291
+ /** The server ID. */
292
+ serverId: string;
293
+ }): Promise<AsyncResult<ServerTypes.ServerRole>>;
294
+
295
+ /**
296
+ * Checks whether the current user is in the server.
297
+ *
298
+ * ```typescript
299
+ * connection.isInServer({serverId: 'serverId'})
300
+ * ```
301
+ */
302
+ isInServer(params: {
303
+ /** The server ID. */
304
+ serverId: string;
305
+ }): Promise<AsyncResult<OperationResult>>;
306
+
307
+ /**
308
+ * Gets the tag list of the current server.
309
+ *
310
+ * ```typescript
311
+ * connection.getServerTags({serverId: 'serverId'})
312
+ * ```
313
+ */
314
+ getServerTags(params: {
315
+ /** The server ID. */
316
+ serverId: string;
317
+ }): Promise<AsyncResult<ServerTypes.ServerTagList>>;
318
+ }
@@ -0,0 +1 @@
1
+ "use strict";!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()}(this,(function(){return(this.webpackChunkwebsdk=this.webpackChunkwebsdk||[]).push([[950],{8494:function(e,r,t){t.r(r),t.d(r,{acceptServerInvite:function(){return S},addServerTags:function(){return T},createServer:function(){return h},destroyServer:function(){return f},getJoinedServers:function(){return P},getServerDetail:function(){return E},getServerMembers:function(){return x},getServerRole:function(){return A},getServerTags:function(){return O},getServers:function(){return N},inviteUserToServer:function(){return w},isInServer:function(){return U},joinServer:function(){return m},leaveServer:function(){return g},rejectServerInvite:function(){return _},removeServerAdmin:function(){return k},removeServerMember:function(){return I},removeServerTags:function(){return j},setServerAdmin:function(){return b},updateServer:function(){return y}}),t(1539),t(8674),t(2526),t(1817),t(2165),t(6992),t(8783),t(3948),t(9554),t(4747),t(8309),t(9753),t(2222),t(6699);var n=t(5531),a=t(7252),c=t(4370),o=t(3246),i=t(7360),s=function(e,r,t,n){return new(t||(t=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 r;e.done?a(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,i)}s((n=n.apply(e,r||[])).next())}))},u=function(e,r){var t,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(t)throw new TypeError("Generator is already executing.");for(;o;)try{if(t=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=r.call(e,o)}catch(e){c=[6,e],n=0}finally{t=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,i])}}},d=a.Z.create({type:n.E.REST_PARAMS_STATUS,message:"appkey or token error"}),p=a.Z.create({type:n.E.REQUEST_UNKNOWN,message:"Request Unknown Error"});function l(e){var r=[];e.tags&&e.tags.forEach((function(e){r.push({tagId:e.server_tag_id,tagName:e.tag_name})}));var t=e.server_id,n=e.default_channel_id,a=e.custom,c=e.created,o=e.description,i=e.icon_url,s=e.name,u=e.owner,d=e.type,p={id:t,defaultChannelId:n,ext:a,created:c,description:o,icon:i,name:s,owner:u,backgroundUrl:e.background_url,isPublic:!d};return e.tags&&(p.tags=r),p}function v(e){try{if(Array.isArray(e.servers)){var r=e.servers,t=e.type,n=e.cursor,a=[];r.forEach((function(e){a.push(l(e))}));var c={list:a};return n&&(c.cursor=n),{type:t,data:c}}return{type:e.type,data:l(e.server)}}catch(r){return i.kg.error("unexpected server data: ".concat(e)),p}}function h(e){var r=e.name,t=e.icon,n=e.description,a=e.ext,s=e.isPublic,u=void 0===s||s,l=e.backgroundUrl;if(c.P6.checkDataType([{name:r,required:!0,type:"string"},{isPublic:u,required:!1,type:"boolean"},{icon:t,description:n,ext:a,backgroundUrl:l,required:!1,type:"string"}]),!o.XZ.call(this))return Promise.reject(d);var v=this.context,h=v.orgName,f=v.appName,y=v.accessToken,m=v.jid,g={owner:this.user,name:r,icon_url:t,description:n,custom:a,type:u?0:1,background_url:l},I={url:"".concat(this.apiUrl,"/").concat(h,"/").concat(f,"/circle/server?resource=").concat(m.clientResource),type:"POST",dataType:"json",data:JSON.stringify(g),headers:{Authorization:"Bearer "+y,"Content-Type":"application/json"}};return c.P6.ajax(I).then((function(e){try{var c={id:e.server_id,defaultChannelId:e.default_channel_id,tags:[],name:r,owner:g.owner,isPublic:u,backgroundUrl:l||"",icon:t||"",description:n||"",ext:a||""};return{type:e.type,data:c}}catch(r){return i.kg.error("unexpected server data: ".concat(e)),p}}))}function f(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p;return u(this,(function(u){switch(u.label){case 0:return r=e.serverId,c.P6.checkDataType([{serverId:r,required:!0,type:"string"}]),o.XZ.call(this)?(t=this.context,n=t.orgName,a=t.appName,i=t.accessToken,s=t.jid,p={url:"".concat(this.apiUrl,"/").concat(n,"/").concat(a,"/circle/server/").concat(r,"?resource=").concat(s.clientResource),type:"DELETE",dataType:"json",headers:{Authorization:"Bearer "+i,"Content-Type":"application/json"}},[4,c.P6.ajax(p)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function y(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l,h,f,y,m,g,I;return u(this,(function(u){switch(u.label){case 0:return r=e.serverId,t=e.name,n=e.icon,a=e.description,i=e.ext,s=e.isPublic,p=e.backgroundUrl,c.P6.checkDataType([{serverId:r,required:!0,type:"string"},{isPublic:s,required:!1,type:"boolean"},{name:t,icon:n,description:a,ext:i,backgroundUrl:p,required:!1,type:"string"}]),o.XZ.call(this)?(l=this.context,h=l.orgName,f=l.appName,y=l.accessToken,m=l.jid,g={name:t,icon_url:n,description:a,custom:i,background_url:p},void 0!==s&&(g.type=s?0:1),I={url:"".concat(this.apiUrl,"/").concat(h,"/").concat(f,"/circle/server/").concat(r,"?resource=").concat(m.clientResource),type:"PUT",dataType:"json",data:JSON.stringify(g),headers:{Authorization:"Bearer "+y,"Content-Type":"application/json"}},[4,c.P6.ajax(I)]):[2,Promise.reject(d)];case 1:return[2,v(u.sent())]}}))}))}function m(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=r.jid,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/join?userId=").concat(this.user,"&resource=").concat(i.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(s)]):[2,Promise.reject(d)];case 1:return[2,v(u.sent())]}}))}))}function g(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=r.jid,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/quit?resource=").concat(i.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(s)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function I(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));if("string"!=typeof e.userId||""===e.userId)throw Error("Invalid parameter userId: ".concat(e.userId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=r.jid,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/user/remove?userId=").concat(e.userId,"&resource=").concat(i.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(s)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function T(e){return s(this,void 0,void 0,(function(){var r,t,n,a,s;return u(this,(function(u){if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter name: ".concat(e.serverId));if(!Array.isArray(e.tags))throw Error("Invalid parameter tags: ".concat(e.tags));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/tag/add"),type:"POST",dataType:"json",data:JSON.stringify({tags:e.tags}),headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[2,c.P6.ajax(s).then((function(e){try{var r=[];return e.tags&&e.tags.length>0&&e.tags.forEach((function(e){r.push({tagId:e.server_tag_id,tagName:e.tag_name})})),{type:e.type,data:{tags:r}}}catch(r){return i.kg.error("unexpected server data: ".concat(e)),p}}))]):[2,Promise.reject(d)]}))}))}function j(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i;return u(this,(function(s){switch(s.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter name: ".concat(e.serverId));if(!Array.isArray(e.tagIds))throw Error("Invalid parameter tagIds: ".concat(e.tagIds));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/tag/remove"),type:"POST",dataType:"json",data:JSON.stringify({tagIds:e.tagIds}),headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(i)]):[2,Promise.reject(d)];case 1:return s.sent(),[2]}}))}))}function N(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l,h,f,y,m,g;return u(this,(function(u){switch(u.label){case 0:if(r=e.keyword,t=e.pageSize,n=void 0===t?20:t,a=e.cursor,i=void 0===a?"":a,s=e.type,p=void 0===s?"serverName":s,c.P6.checkDataType([{keyword:r,required:!0,type:"string"},{pageSize:n,required:!1,type:"number"},{cursor:i,required:!1,type:"string"}]),!["serverName","tagName"].includes(p))throw Error('"Invalid parameter type": '+e.type);return o.XZ.call(this)?(l=this.context,h=l.orgName,f=l.appName,y=l.accessToken,m="tagName"===p?1:0,g={url:"".concat(this.apiUrl,"/").concat(h,"/").concat(f,"/circle/server/search/").concat(e.keyword,"?type=").concat(m,"&limit=").concat(n,"&cursor=").concat(i),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+y,"Content-Type":"application/json"}},[4,c.P6.ajax(g)]):[2,Promise.reject(d)];case 1:return[2,v(u.sent())]}}))}))}function P(e){if(!o.XZ.call(this))return Promise.reject(d);var r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=e.pageSize,s=void 0===i?20:i,u=e.cursor,p=void 0===u?"":u;c.P6.checkDataType([{pageSize:s,required:!1,type:"number"},{cursor:p,required:!1,type:"string"}]);var l={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/list?userId=").concat(this.user,"&limit=").concat(s,"&cursor=").concat(p),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}};return c.P6.ajax(l).then((function(e){return v(e)}))}function E(e){if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));if(!o.XZ.call(this))return Promise.reject(d);var r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/by-id"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}};return c.P6.ajax(i).then((function(e){return v(e)}))}function x(e){var r=e.serverId,t=e.pageSize,n=void 0===t?20:t,a=e.cursor,s=void 0===a?"":a;if(c.P6.checkDataType([{serverId:r,required:!0,type:"string"},{pageSize:n,required:!1,type:"number"},{cursor:s,required:!1,type:"string"}]),!o.XZ.call(this))return Promise.reject(d);var u=this.context,l=u.orgName,v=u.appName,h=u.accessToken,f={url:"".concat(this.apiUrl,"/").concat(l,"/").concat(v,"/circle/server/").concat(e.serverId,"/users?limit=").concat(n,"&cursor=").concat(s),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+h,"Content-Type":"application/json"}};return c.P6.ajax(f).then((function(e){try{var r=[];return e.users&&e.users.forEach((function(e){r.push({userId:e.user_id,role:0===e.role?"owner":1===e.role?"moderator":"user"})})),{type:e.type,data:{list:r,cursor:(null==e?void 0:e.cursor)||""}}}catch(r){return i.kg.error("unexpected server data: ".concat(e)),p}}))}function b(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));if("string"!=typeof e.userId||""===e.userId)throw Error("Invalid parameter userId: ".concat(e.userId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=r.jid,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/user/role?userId=").concat(e.userId,"&role=1&resource=").concat(i.clientResource),type:"PUT",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(s)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function k(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));if("string"!=typeof e.userId||""===e.userId)throw Error("Invalid parameter userId: ".concat(e.userId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=r.jid,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/user/role?userId=").concat(e.userId,"&role=2&resource=").concat(i.clientResource),type:"PUT",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(s)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function w(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));if("string"!=typeof e.userId||""===e.userId)throw Error("Invalid parameter userId: ".concat(e.userId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i=r.jid,s={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/invite/join?userId=").concat(e.userId,"&welcome=").concat(e.message,"&resource=").concat(i.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(s)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function S(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l;return u(this,(function(u){switch(u.label){case 0:return r=e.serverId,t=e.inviter,c.P6.checkDataType([{serverId:r,inviter:t,required:!0,type:"string"}]),o.XZ.call(this)?(n=this.context,a=n.orgName,i=n.appName,s=n.accessToken,p=n.jid,l={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(i,"/circle/server/").concat(r,"/accept/invite?inviter=").concat(t,"&resource=").concat(p.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}},[4,c.P6.ajax(l)]):[2,Promise.reject(d)];case 1:return[2,v(u.sent())]}}))}))}function _(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l;return u(this,(function(u){switch(u.label){case 0:return r=e.serverId,t=e.inviter,c.P6.checkDataType([{serverId:r,inviter:t,required:!0,type:"string"}]),o.XZ.call(this)?(n=this.context,a=n.orgName,i=n.appName,s=n.accessToken,p=n.jid,l={url:"".concat(this.apiUrl,"/").concat(a,"/").concat(i,"/circle/server/").concat(r,"/decline/invite?inviter=").concat(t,"&resource=").concat(p.clientResource),type:"POST",dataType:"json",headers:{Authorization:"Bearer "+s,"Content-Type":"application/json"}},[4,c.P6.ajax(l)]):[2,Promise.reject(d)];case 1:return u.sent(),[2]}}))}))}function A(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/user/role?userId=").concat(this.user),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(i)]):[2,Promise.reject(d)];case 1:return s=u.sent(),p=s.type,l=s.role,[2,{type:p,data:{role:0===l?"owner":1===l?"moderator":"user"}}]}}))}))}function U(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/user/").concat(this.user),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(i)]):[2,Promise.reject(d)];case 1:return s=u.sent(),p=s.type,l=s.result,[2,{type:p,data:{result:l}}]}}))}))}function O(e){return s(this,void 0,void 0,(function(){var r,t,n,a,i,s,p,l,v;return u(this,(function(u){switch(u.label){case 0:if("string"!=typeof e.serverId||""===e.serverId)throw Error("Invalid parameter serverId: ".concat(e.serverId));return o.XZ.call(this)?(r=this.context,t=r.orgName,n=r.appName,a=r.accessToken,i={url:"".concat(this.apiUrl,"/").concat(t,"/").concat(n,"/circle/server/").concat(e.serverId,"/tag"),type:"GET",dataType:"json",headers:{Authorization:"Bearer "+a,"Content-Type":"application/json"}},[4,c.P6.ajax(i)]):[2,Promise.reject(d)];case 1:return s=u.sent(),p=s.type,l=s.tags,v=[],l&&l.forEach((function(e){v.push({tagId:e.server_tag_id,tagName:e.tag_name})})),[2,{type:p,data:{tags:v}}]}}))}))}},3246:function(e,r,t){t.d(r,{H7:function(){return u},XZ:function(){return i},_W:function(){return s}}),t(7941),t(9554),t(1539),t(4747),t(6699),t(2023);var n=t(5531),a=t(7252);function c(){var e=this.context.appName,r=this.context.orgName;return!(!e||!r)||(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 r=a.Z.create({type:n.E.WEBIM_CONNCTION_TOKEN_NOT_ASSIGN_ERROR,message:"token not assign error"});return this.onError&&this.onError(r),null===(e=this.eventHandler)||void 0===e||e.dispatch("onError",r),!1}return!0}function i(){return o.call(this)&&c.call(this)}function s(e){var r=e.data,t=e.type;return{data:{status:Object.keys(r.errorKeys).length>0?"fail":"success",errorKeys:r.errorKeys,successKeys:r.successKeys},type:t}}function u(e){var r=e.data,t=void 0;return Object.keys(r.errorKeys).length>0&&Object.keys(r.errorKeys).forEach((function(e){var c=r.errorKeys[e];t=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})})),t}}},function(e){return 8494,e(e.s=8494)}])}));
@@ -0,0 +1,50 @@
1
+ interface CategoryInfo {
2
+ /** The channel category ID. */
3
+ id: string;
4
+ /** The channel category name. */
5
+ name: string;
6
+ /** The server ID. */
7
+ serverId: string;
8
+ /** The UNIX timestamp when the channel category was created. The unit is millisecond. */
9
+ created?: number;
10
+ /** Whether it is the default channel category.
11
+ * - `false`: No.
12
+ * - `true`: Yes.
13
+ */
14
+ defaultCategory: boolean;
15
+ }
16
+
17
+ interface CategoryInfoListResult {
18
+ /** The channel category information list. */
19
+ list: CategoryInfo[];
20
+ /** 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 chronological order of when they are created.*/
21
+ cursor?: string;
22
+ }
23
+ type CategoryChangeType = 'create' | 'update' | 'destroy' | 'transferChannel';
24
+
25
+ interface CategoryChangeInfo {
26
+ /** The server ID. */
27
+ serverId: string;
28
+ /** The ID of the operated channel category. */
29
+ categoryId: string;
30
+ /** The operation type. */
31
+ operation: CategoryChangeType;
32
+ /** The operator. */
33
+ operator: string;
34
+ /** The UNIX timestamp when the event occurs. The unit is millisecond. */
35
+ timestamp: number;
36
+ /** The operated channel ID. */
37
+ channelId?: string;
38
+ /** The channel category name. */
39
+ categoryName?: string;
40
+ /** The ID of the channel category to which the channel is transferred. */
41
+ toCategoryId?: string;
42
+ /** The original channel category ID. */
43
+ fromCategoryId?: string;
44
+ }
45
+ export type {
46
+ CategoryInfo,
47
+ CategoryInfoListResult,
48
+ CategoryChangeInfo,
49
+ CategoryChangeType,
50
+ };
@@ -0,0 +1,162 @@
1
+ interface ChannelInfo {
2
+ /** The server ID. */
3
+ serverId: string;
4
+ /** The channel ID. */
5
+ channelId: string;
6
+ /** The channel name. */
7
+ name: string;
8
+ /** The channel description. */
9
+ description: string;
10
+ /** The UNIX timestamp when the server was created. The unit is millisecond. */
11
+ created?: number;
12
+ /** Whether it is the default channel.
13
+ * - `false`: No.
14
+ * - `true`: Yes.
15
+ */
16
+ defaultChannel: boolean;
17
+ /** The maximum number of users that the channel can have. */
18
+ maxusers: number;
19
+ /** The channel extension field. */
20
+ ext: string;
21
+ /** Whether it is a public channel.
22
+ * - `true`: Public channel.
23
+ * - `false`: Private channel.
24
+ */
25
+ isPublic: boolean;
26
+ /** The channel category. */
27
+ categoryId: string;
28
+ /** The channel type.
29
+ * - `0`: IM channel.
30
+ * - `1`: Voice chatroom channel. */
31
+ mode: number;
32
+ /** The name of the RTC channel. */
33
+ rtcChannelId?: string;
34
+ }
35
+
36
+ interface ChannelInfoListResult {
37
+ /** The channel information list. */
38
+ list: ChannelInfo[];
39
+ /** 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. */
40
+ cursor?: string;
41
+ }
42
+
43
+ interface ChannelMuteMemberItem {
44
+ /** The UNIX timestamp when the mute expires. */
45
+ expire: number;
46
+ /** The user ID of the muted member. */
47
+ userId: string;
48
+ }
49
+ interface ChannelMuteMemberListResult {
50
+ list: ChannelMuteMemberItem[];
51
+ }
52
+
53
+ interface ChannelMemberListResult {
54
+ /** The channel member list. */
55
+ list: ChannelMember[];
56
+ /** The position from which to start getting data.*/
57
+ cursor?: string;
58
+ }
59
+ type ChannelRole = 'owner' | 'moderator' | 'user';
60
+
61
+ interface ChannelMember {
62
+ /** The user ID of the channel member. */
63
+ userId: string;
64
+ /** The role of the member in the channel. */
65
+ role: ChannelRole;
66
+ }
67
+
68
+ type ChannelChangeType =
69
+ | 'create'
70
+ | 'destroy'
71
+ | 'update'
72
+ | 'memberAbsence'
73
+ | 'memberPresence'
74
+ | 'removed'
75
+ | 'muteMember'
76
+ | 'unmuteMember'
77
+ | 'inviteToJoin'
78
+ | 'acceptInvite'
79
+ | 'rejectInvite'
80
+ | 'directJoined';
81
+
82
+ type ChannelMultiDeviceEventType =
83
+ | 'channelCreate'
84
+ | 'channelDestroy'
85
+ | 'channelUpdate'
86
+ | 'channelJoin'
87
+ | 'channelLeave'
88
+ | 'channelRemoveMember'
89
+ | 'channelInviteUser'
90
+ | 'channelMuteMember'
91
+ | 'channelUnMuteMember'
92
+ | 'channelAcceptInvite'
93
+ | 'channelRejectInvite';
94
+
95
+ interface InviteChannelServerInfo {
96
+ /** The server ID. */
97
+ id: string;
98
+ /** The server icon. */
99
+ icon?: string;
100
+ /** The server name. */
101
+ name?: string;
102
+ /** The server description. */
103
+ description?: string;
104
+ }
105
+ interface ChannelChangeInfo {
106
+ /** The operation type. */
107
+ operation: ChannelChangeType | ChannelMultiDeviceEventType;
108
+ /** The channel ID. */
109
+ channelId: string;
110
+ /** The operator. */
111
+ operator: string;
112
+ /** The server ID. */
113
+ serverId?: string;
114
+ /** The channel name. */
115
+ name?: string;
116
+ /** Whether it is the default channel.
117
+ * - `false`: No.
118
+ * - `true`: Yes.
119
+ */
120
+ defaultChannel?: boolean;
121
+ /** The role of the member in the channel. */
122
+ serverRole?: ChannelRole;
123
+ /** The operated object. */
124
+ to: string;
125
+ /** The welcome message for inviting a user to join the channel. */
126
+ inviteMessage?: string;
127
+ /** Information of the server to which the channel belongs. */
128
+ serverInfo?: InviteChannelServerInfo;
129
+ /** The channel description. */
130
+ description?: string;
131
+ /** Whether it is a public channel.
132
+ * - `true`: Yes.
133
+ * - `false`: No.
134
+ */
135
+ isPublic?: boolean;
136
+ /** The channel extension field. */
137
+ ext?: string;
138
+ /** The channel category ID. */
139
+ categoryId?: string;
140
+ /** The maximum number of users that a channel can have. */
141
+ maxusers?: number;
142
+ /** The channel type:
143
+ * - `0`: IM channel.
144
+ * - `1`: Voice chatroom channel. */
145
+ mode?: number;
146
+ /** The name of the RTC channel. */
147
+ rtcChannelId?: string;
148
+ }
149
+
150
+ export type {
151
+ ChannelInfoListResult,
152
+ ChannelInfo,
153
+ ChannelMember,
154
+ ChannelMemberListResult,
155
+ ChannelMultiDeviceEventType,
156
+ InviteChannelServerInfo,
157
+ ChannelChangeType,
158
+ ChannelChangeInfo,
159
+ ChannelMuteMemberItem,
160
+ ChannelMuteMemberListResult,
161
+ ChannelRole,
162
+ };
package/types/common.d.ts CHANGED
@@ -45,6 +45,10 @@ interface EventData {
45
45
  [key: string]: string;
46
46
  };
47
47
  }
48
+ interface OperationResult {
49
+ result: boolean;
50
+ }
51
+
48
52
  export type {
49
53
  AsyncResult,
50
54
  UserId,
@@ -53,4 +57,5 @@ export type {
53
57
  ErrorEvent,
54
58
  Jid,
55
59
  EventData,
60
+ OperationResult,
56
61
  };
@@ -1,6 +1,5 @@
1
1
  import { Jid } from './common';
2
- import { MessagesType } from './message';
3
- import { LastMessage } from '../types/threadApi';
2
+ import { MessagesType, MessageBody } from './message';
4
3
  interface UpdateOwnUserInfoParams {
5
4
  /** The nickname. */
6
5
  nickname?: string;
@@ -85,7 +84,7 @@ interface ConversationList {
85
84
  /** The conversation ID. */
86
85
  channel_id: string;
87
86
  /** Overview of the latest news. */
88
- lastMessage: LastMessage;
87
+ lastMessage: MessageBody | Record<string, never>;
89
88
  /** The number of unread messages. */
90
89
  unread_num: number;
91
90
  }