mezon-js 2.9.2 → 2.9.5

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -1638,6 +1638,8 @@ export interface ApiUpdateRoleChannelRequest {
1638
1638
  permission_update?: Array<ApiPermissionUpdate>;
1639
1639
  //The ID of the role to update.
1640
1640
  role_id?: string;
1641
+ //
1642
+ user_id?: string;
1641
1643
  }
1642
1644
 
1643
1645
  /** Fetch a batch of zero or more users from the server. */
@@ -5635,41 +5637,6 @@ export class MezonApi {
5635
5637
  ]);
5636
5638
  }
5637
5639
 
5638
- /** */
5639
- getPermissionOfUserInTheClan(bearerToken: string,
5640
- clanId:string,
5641
- options: any = {}): Promise<ApiPermissionList> {
5642
-
5643
- if (clanId === null || clanId === undefined) {
5644
- throw new Error("'clanId' is a required parameter but is null or undefined.");
5645
- }
5646
- const urlPath = "/v2/permissionuserinclan/{clanId}"
5647
- .replace("{clanId}", encodeURIComponent(String(clanId)));
5648
- const queryParams = new Map<string, any>();
5649
-
5650
- let bodyJson : string = "";
5651
-
5652
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
5653
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
5654
- if (bearerToken) {
5655
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
5656
- }
5657
-
5658
- return Promise.race([
5659
- fetch(fullUrl, fetchOptions).then((response) => {
5660
- if (response.status == 204) {
5661
- return response;
5662
- } else if (response.status >= 200 && response.status < 300) {
5663
- return response.json();
5664
- } else {
5665
- throw response;
5666
- }
5667
- }),
5668
- new Promise((_, reject) =>
5669
- setTimeout(reject, this.timeoutMs, "Request timed out.")
5670
- ),
5671
- ]);
5672
- }
5673
5640
 
5674
5641
  /** */
5675
5642
  deletePinMessage(bearerToken: string,
@@ -6119,6 +6086,44 @@ export class MezonApi {
6119
6086
  ]);
6120
6087
  }
6121
6088
 
6089
+ /** */
6090
+ getRoleOfUserInTheClan(bearerToken: string,
6091
+ clanId:string,
6092
+ channelId?:string,
6093
+ options: any = {}): Promise<ApiRoleList> {
6094
+
6095
+ if (clanId === null || clanId === undefined) {
6096
+ throw new Error("'clanId' is a required parameter but is null or undefined.");
6097
+ }
6098
+ const urlPath = "/v2/roleuserinclan/{clanId}"
6099
+ .replace("{clanId}", encodeURIComponent(String(clanId)));
6100
+ const queryParams = new Map<string, any>();
6101
+ queryParams.set("channel_id", channelId);
6102
+
6103
+ let bodyJson : string = "";
6104
+
6105
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6106
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
6107
+ if (bearerToken) {
6108
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6109
+ }
6110
+
6111
+ return Promise.race([
6112
+ fetch(fullUrl, fetchOptions).then((response) => {
6113
+ if (response.status == 204) {
6114
+ return response;
6115
+ } else if (response.status >= 200 && response.status < 300) {
6116
+ return response.json();
6117
+ } else {
6118
+ throw response;
6119
+ }
6120
+ }),
6121
+ new Promise((_, reject) =>
6122
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6123
+ ),
6124
+ ]);
6125
+ }
6126
+
6122
6127
  /** Execute a Lua function on the server. */
6123
6128
  rpcFunc2(bearerToken: string,basicAuthUsername: string,
6124
6129
  basicAuthPassword: string,
package/client.ts CHANGED
@@ -106,6 +106,7 @@ import {
106
106
  ApiStreamingChannelUserList,
107
107
  ApiRegisterStreamingChannelRequest,
108
108
  ApiRegisterStreamingChannelResponse,
109
+ ApiRoleList,
109
110
  } from "./api.gen";
110
111
 
111
112
  import { Session } from "./session";
@@ -2700,10 +2701,10 @@ export class Client {
2700
2701
  }
2701
2702
 
2702
2703
  /** Get permission of user in the clan */
2703
- async getPermissionOfUserInTheClan(
2704
+ async GetRoleOfUserInTheClan(
2704
2705
  session: Session,
2705
2706
  clanId: string
2706
- ): Promise<ApiPermissionList> {
2707
+ ): Promise<ApiRoleList> {
2707
2708
  if (
2708
2709
  this.autoRefreshSession &&
2709
2710
  session.refresh_token &&
@@ -2713,8 +2714,8 @@ export class Client {
2713
2714
  }
2714
2715
 
2715
2716
  return this.apiClient
2716
- .getPermissionOfUserInTheClan(session.token, clanId)
2717
- .then((response: ApiPermissionList) => {
2717
+ .getRoleOfUserInTheClan(session.token, clanId)
2718
+ .then((response: ApiRoleList) => {
2718
2719
  return Promise.resolve(response);
2719
2720
  });
2720
2721
  }
package/dist/api.gen.d.ts CHANGED
@@ -949,6 +949,7 @@ export interface ApiUpdateRoleChannelRequest {
949
949
  max_permission_id: string;
950
950
  permission_update?: Array<ApiPermissionUpdate>;
951
951
  role_id?: string;
952
+ user_id?: string;
952
953
  }
953
954
  /** Fetch a batch of zero or more users from the server. */
954
955
  export interface ApiUpdateUsersRequest {
@@ -1257,8 +1258,6 @@ export declare class MezonApi {
1257
1258
  /** Get permission list */
1258
1259
  getListPermission(bearerToken: string, options?: any): Promise<ApiPermissionList>;
1259
1260
  /** */
1260
- getPermissionOfUserInTheClan(bearerToken: string, clanId: string, options?: any): Promise<ApiPermissionList>;
1261
- /** */
1262
1261
  deletePinMessage(bearerToken: string, messageId?: string, options?: any): Promise<any>;
1263
1262
  /** */
1264
1263
  getPinMessagesList(bearerToken: string, channelId?: string, options?: any): Promise<ApiPinMessagesList>;
@@ -1282,6 +1281,8 @@ export declare class MezonApi {
1282
1281
  listRolePermissions(bearerToken: string, roleId: string, options?: any): Promise<ApiPermissionList>;
1283
1282
  /** List role permissions */
1284
1283
  listRoleUsers(bearerToken: string, roleId: string, limit?: number, cursor?: string, options?: any): Promise<ApiRoleUserList>;
1284
+ /** */
1285
+ getRoleOfUserInTheClan(bearerToken: string, clanId: string, channelId?: string, options?: any): Promise<ApiRoleList>;
1285
1286
  /** Execute a Lua function on the server. */
1286
1287
  rpcFunc2(bearerToken: string, basicAuthUsername: string, basicAuthPassword: string, id: string, payload?: string, httpKey?: string, options?: any): Promise<ApiRpc>;
1287
1288
  /** Execute a Lua function on the server. */
package/dist/client.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest } from "./api.gen";
16
+ import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -500,7 +500,7 @@ export declare class Client {
500
500
  /** Get link invite user */
501
501
  getLinkInvite(session: Session, inviteId: string): Promise<ApiInviteUserRes>;
502
502
  /** Get permission of user in the clan */
503
- getPermissionOfUserInTheClan(session: Session, clanId: string): Promise<ApiPermissionList>;
503
+ GetRoleOfUserInTheClan(session: Session, clanId: string): Promise<ApiRoleList>;
504
504
  /** invite user */
505
505
  inviteUser(session: Session, inviteId: string): Promise<ApiInviteUserRes>;
506
506
  /** Set default notification clan*/
@@ -3681,34 +3681,6 @@ var MezonApi = class {
3681
3681
  ]);
3682
3682
  }
3683
3683
  /** */
3684
- getPermissionOfUserInTheClan(bearerToken, clanId, options = {}) {
3685
- if (clanId === null || clanId === void 0) {
3686
- throw new Error("'clanId' is a required parameter but is null or undefined.");
3687
- }
3688
- const urlPath = "/v2/permissionuserinclan/{clanId}".replace("{clanId}", encodeURIComponent(String(clanId)));
3689
- const queryParams = /* @__PURE__ */ new Map();
3690
- let bodyJson = "";
3691
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3692
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3693
- if (bearerToken) {
3694
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3695
- }
3696
- return Promise.race([
3697
- fetch(fullUrl, fetchOptions).then((response) => {
3698
- if (response.status == 204) {
3699
- return response;
3700
- } else if (response.status >= 200 && response.status < 300) {
3701
- return response.json();
3702
- } else {
3703
- throw response;
3704
- }
3705
- }),
3706
- new Promise(
3707
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3708
- )
3709
- ]);
3710
- }
3711
- /** */
3712
3684
  deletePinMessage(bearerToken, messageId, options = {}) {
3713
3685
  const urlPath = "/v2/pinmessage/delete";
3714
3686
  const queryParams = /* @__PURE__ */ new Map();
@@ -4060,6 +4032,35 @@ var MezonApi = class {
4060
4032
  )
4061
4033
  ]);
4062
4034
  }
4035
+ /** */
4036
+ getRoleOfUserInTheClan(bearerToken, clanId, channelId, options = {}) {
4037
+ if (clanId === null || clanId === void 0) {
4038
+ throw new Error("'clanId' is a required parameter but is null or undefined.");
4039
+ }
4040
+ const urlPath = "/v2/roleuserinclan/{clanId}".replace("{clanId}", encodeURIComponent(String(clanId)));
4041
+ const queryParams = /* @__PURE__ */ new Map();
4042
+ queryParams.set("channel_id", channelId);
4043
+ let bodyJson = "";
4044
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4045
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4046
+ if (bearerToken) {
4047
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4048
+ }
4049
+ return Promise.race([
4050
+ fetch(fullUrl, fetchOptions).then((response) => {
4051
+ if (response.status == 204) {
4052
+ return response;
4053
+ } else if (response.status >= 200 && response.status < 300) {
4054
+ return response.json();
4055
+ } else {
4056
+ throw response;
4057
+ }
4058
+ }),
4059
+ new Promise(
4060
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4061
+ )
4062
+ ]);
4063
+ }
4063
4064
  /** Execute a Lua function on the server. */
4064
4065
  rpcFunc2(bearerToken, basicAuthUsername, basicAuthPassword, id, payload, httpKey, options = {}) {
4065
4066
  if (id === null || id === void 0) {
@@ -4916,12 +4917,18 @@ var WebSocketAdapterText = class {
4916
4917
  var _a;
4917
4918
  return ((_a = this._socket) == null ? void 0 : _a.readyState) == WebSocket.OPEN;
4918
4919
  }
4919
- connect(scheme, host, port, createStatus, token) {
4920
+ connect(scheme, host, port, createStatus, token, signal) {
4921
+ if (signal) {
4922
+ signal.addEventListener("abort", () => {
4923
+ this.close();
4924
+ });
4925
+ }
4920
4926
  const url = `${scheme}${host}:${port}/ws?lang=en&status=${encodeURIComponent(createStatus.toString())}&token=${encodeURIComponent(token)}`;
4921
4927
  this._socket = new WebSocket(url);
4922
4928
  }
4923
4929
  close() {
4924
- this._socket.close();
4930
+ var _a;
4931
+ (_a = this._socket) == null ? void 0 : _a.close();
4925
4932
  this._socket = void 0;
4926
4933
  }
4927
4934
  send(msg) {
@@ -4959,12 +4966,12 @@ var _DefaultSocket = class _DefaultSocket {
4959
4966
  isOpen() {
4960
4967
  return this.adapter.isOpen();
4961
4968
  }
4962
- connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs) {
4969
+ connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs, signal) {
4963
4970
  if (this.adapter.isOpen()) {
4964
4971
  return Promise.resolve(session);
4965
4972
  }
4966
4973
  const scheme = this.useSSL ? "wss://" : "ws://";
4967
- this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
4974
+ this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
4968
4975
  this.adapter.onClose = (evt) => {
4969
4976
  this.ondisconnect(evt);
4970
4977
  };
@@ -5549,9 +5556,9 @@ var _DefaultSocket = class _DefaultSocket {
5549
5556
  return response.hashtag_dm_list_event;
5550
5557
  });
5551
5558
  }
5552
- getPermissionByRoleIdChannelId(role_id, channel_id) {
5559
+ getPermissionByRoleIdChannelId(role_id, channel_id, user_id) {
5553
5560
  return __async(this, null, function* () {
5554
- const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
5561
+ const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id, user_id } });
5555
5562
  return response.permission_role_channel_list_event;
5556
5563
  });
5557
5564
  }
@@ -7009,12 +7016,12 @@ var Client = class {
7009
7016
  });
7010
7017
  }
7011
7018
  /** Get permission of user in the clan */
7012
- getPermissionOfUserInTheClan(session, clanId) {
7019
+ GetRoleOfUserInTheClan(session, clanId) {
7013
7020
  return __async(this, null, function* () {
7014
7021
  if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7015
7022
  yield this.sessionRefresh(session);
7016
7023
  }
7017
- return this.apiClient.getPermissionOfUserInTheClan(session.token, clanId).then((response) => {
7024
+ return this.apiClient.getRoleOfUserInTheClan(session.token, clanId).then((response) => {
7018
7025
  return Promise.resolve(response);
7019
7026
  });
7020
7027
  });
@@ -3652,34 +3652,6 @@ var MezonApi = class {
3652
3652
  ]);
3653
3653
  }
3654
3654
  /** */
3655
- getPermissionOfUserInTheClan(bearerToken, clanId, options = {}) {
3656
- if (clanId === null || clanId === void 0) {
3657
- throw new Error("'clanId' is a required parameter but is null or undefined.");
3658
- }
3659
- const urlPath = "/v2/permissionuserinclan/{clanId}".replace("{clanId}", encodeURIComponent(String(clanId)));
3660
- const queryParams = /* @__PURE__ */ new Map();
3661
- let bodyJson = "";
3662
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3663
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3664
- if (bearerToken) {
3665
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3666
- }
3667
- return Promise.race([
3668
- fetch(fullUrl, fetchOptions).then((response) => {
3669
- if (response.status == 204) {
3670
- return response;
3671
- } else if (response.status >= 200 && response.status < 300) {
3672
- return response.json();
3673
- } else {
3674
- throw response;
3675
- }
3676
- }),
3677
- new Promise(
3678
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3679
- )
3680
- ]);
3681
- }
3682
- /** */
3683
3655
  deletePinMessage(bearerToken, messageId, options = {}) {
3684
3656
  const urlPath = "/v2/pinmessage/delete";
3685
3657
  const queryParams = /* @__PURE__ */ new Map();
@@ -4031,6 +4003,35 @@ var MezonApi = class {
4031
4003
  )
4032
4004
  ]);
4033
4005
  }
4006
+ /** */
4007
+ getRoleOfUserInTheClan(bearerToken, clanId, channelId, options = {}) {
4008
+ if (clanId === null || clanId === void 0) {
4009
+ throw new Error("'clanId' is a required parameter but is null or undefined.");
4010
+ }
4011
+ const urlPath = "/v2/roleuserinclan/{clanId}".replace("{clanId}", encodeURIComponent(String(clanId)));
4012
+ const queryParams = /* @__PURE__ */ new Map();
4013
+ queryParams.set("channel_id", channelId);
4014
+ let bodyJson = "";
4015
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4016
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4017
+ if (bearerToken) {
4018
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4019
+ }
4020
+ return Promise.race([
4021
+ fetch(fullUrl, fetchOptions).then((response) => {
4022
+ if (response.status == 204) {
4023
+ return response;
4024
+ } else if (response.status >= 200 && response.status < 300) {
4025
+ return response.json();
4026
+ } else {
4027
+ throw response;
4028
+ }
4029
+ }),
4030
+ new Promise(
4031
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4032
+ )
4033
+ ]);
4034
+ }
4034
4035
  /** Execute a Lua function on the server. */
4035
4036
  rpcFunc2(bearerToken, basicAuthUsername, basicAuthPassword, id, payload, httpKey, options = {}) {
4036
4037
  if (id === null || id === void 0) {
@@ -4887,12 +4888,18 @@ var WebSocketAdapterText = class {
4887
4888
  var _a;
4888
4889
  return ((_a = this._socket) == null ? void 0 : _a.readyState) == WebSocket.OPEN;
4889
4890
  }
4890
- connect(scheme, host, port, createStatus, token) {
4891
+ connect(scheme, host, port, createStatus, token, signal) {
4892
+ if (signal) {
4893
+ signal.addEventListener("abort", () => {
4894
+ this.close();
4895
+ });
4896
+ }
4891
4897
  const url = `${scheme}${host}:${port}/ws?lang=en&status=${encodeURIComponent(createStatus.toString())}&token=${encodeURIComponent(token)}`;
4892
4898
  this._socket = new WebSocket(url);
4893
4899
  }
4894
4900
  close() {
4895
- this._socket.close();
4901
+ var _a;
4902
+ (_a = this._socket) == null ? void 0 : _a.close();
4896
4903
  this._socket = void 0;
4897
4904
  }
4898
4905
  send(msg) {
@@ -4930,12 +4937,12 @@ var _DefaultSocket = class _DefaultSocket {
4930
4937
  isOpen() {
4931
4938
  return this.adapter.isOpen();
4932
4939
  }
4933
- connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs) {
4940
+ connect(session, createStatus = false, connectTimeoutMs = _DefaultSocket.DefaultConnectTimeoutMs, signal) {
4934
4941
  if (this.adapter.isOpen()) {
4935
4942
  return Promise.resolve(session);
4936
4943
  }
4937
4944
  const scheme = this.useSSL ? "wss://" : "ws://";
4938
- this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
4945
+ this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
4939
4946
  this.adapter.onClose = (evt) => {
4940
4947
  this.ondisconnect(evt);
4941
4948
  };
@@ -5520,9 +5527,9 @@ var _DefaultSocket = class _DefaultSocket {
5520
5527
  return response.hashtag_dm_list_event;
5521
5528
  });
5522
5529
  }
5523
- getPermissionByRoleIdChannelId(role_id, channel_id) {
5530
+ getPermissionByRoleIdChannelId(role_id, channel_id, user_id) {
5524
5531
  return __async(this, null, function* () {
5525
- const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
5532
+ const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id, user_id } });
5526
5533
  return response.permission_role_channel_list_event;
5527
5534
  });
5528
5535
  }
@@ -6980,12 +6987,12 @@ var Client = class {
6980
6987
  });
6981
6988
  }
6982
6989
  /** Get permission of user in the clan */
6983
- getPermissionOfUserInTheClan(session, clanId) {
6990
+ GetRoleOfUserInTheClan(session, clanId) {
6984
6991
  return __async(this, null, function* () {
6985
6992
  if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6986
6993
  yield this.sessionRefresh(session);
6987
6994
  }
6988
- return this.apiClient.getPermissionOfUserInTheClan(session.token, clanId).then((response) => {
6995
+ return this.apiClient.getRoleOfUserInTheClan(session.token, clanId).then((response) => {
6989
6996
  return Promise.resolve(response);
6990
6997
  });
6991
6998
  });
package/dist/socket.d.ts CHANGED
@@ -560,6 +560,7 @@ export interface NotificationChannelCategorySetting {
560
560
  channel_category_label: string;
561
561
  notification_setting_type: number;
562
562
  channel_category_title: string;
563
+ action: number;
563
564
  }
564
565
  export interface NotificationChannelCategorySettingEvent {
565
566
  clan_id?: string;
@@ -642,7 +643,7 @@ export interface Socket {
642
643
  /** Connection is Open */
643
644
  isOpen(): boolean;
644
645
  /** Connect to the server. */
645
- connect(session: Session, createStatus: boolean): Promise<Session>;
646
+ connect(session: Session, createStatus: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
646
647
  /** Disconnect from the server. */
647
648
  disconnect(fireDisconnectEvent: boolean): void;
648
649
  /** Subscribe to one or more users for their status updates. */
@@ -748,7 +749,7 @@ export interface Socket {
748
749
  getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
749
750
  getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
750
751
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
751
- getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
752
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
752
753
  getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
753
754
  oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
754
755
  oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
@@ -783,7 +784,7 @@ export declare class DefaultSocket implements Socket {
783
784
  constructor(host: string, port: string, useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter, sendTimeoutMs?: number);
784
785
  generatecid(): string;
785
786
  isOpen(): boolean;
786
- connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number): Promise<Session>;
787
+ connect(session: Session, createStatus?: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
787
788
  disconnect(fireDisconnectEvent?: boolean): void;
788
789
  setHeartbeatTimeoutMs(ms: number): void;
789
790
  getHeartbeatTimeoutMs(): number;
@@ -853,7 +854,7 @@ export declare class DefaultSocket implements Socket {
853
854
  listUserClansByUserId(): Promise<AllUserClans>;
854
855
  listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent>;
855
856
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
856
- getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
857
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
857
858
  listStickersByUserId(): Promise<StrickerListedEvent>;
858
859
  getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
859
860
  getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
@@ -35,7 +35,7 @@ export interface WebSocketAdapter {
35
35
  onOpen: SocketOpenHandler | null;
36
36
  isOpen(): boolean;
37
37
  close(): void;
38
- connect(scheme: string, host: string, port: string, createStatus: boolean, token: string): void;
38
+ connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void;
39
39
  send(message: any): void;
40
40
  }
41
41
  /**
@@ -77,7 +77,7 @@ export declare class WebSocketAdapterText implements WebSocketAdapter {
77
77
  get onOpen(): SocketOpenHandler | null;
78
78
  set onOpen(value: SocketOpenHandler | null);
79
79
  isOpen(): boolean;
80
- connect(scheme: string, host: string, port: string, createStatus: boolean, token: string): void;
80
+ connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void;
81
81
  close(): void;
82
82
  send(msg: any): void;
83
83
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.9.2",
4
+ "version": "2.9.5",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
package/socket.ts CHANGED
@@ -842,6 +842,8 @@ export interface NotificationChannelCategorySetting {
842
842
  notification_setting_type :number;
843
843
  //
844
844
  channel_category_title : string;
845
+ //
846
+ action: number
845
847
  }
846
848
 
847
849
  export interface NotificationChannelCategorySettingEvent {
@@ -935,7 +937,7 @@ export interface Socket {
935
937
  isOpen(): boolean;
936
938
 
937
939
  /** Connect to the server. */
938
- connect(session: Session, createStatus: boolean): Promise<Session>;
940
+ connect(session: Session, createStatus: boolean, connectTimeoutMs?: number, signal?: AbortSignal): Promise<Session>;
939
941
 
940
942
  /** Disconnect from the server. */
941
943
  disconnect(fireDisconnectEvent: boolean): void;
@@ -1122,7 +1124,7 @@ export interface Socket {
1122
1124
 
1123
1125
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
1124
1126
 
1125
- getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
1127
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
1126
1128
 
1127
1129
  getNotificationChannelCategorySetting(clan_id : string): Promise<NotificationChannelCategorySettingEvent>;
1128
1130
 
@@ -1185,13 +1187,13 @@ export class DefaultSocket implements Socket {
1185
1187
  return this.adapter.isOpen();
1186
1188
  }
1187
1189
 
1188
- connect(session: Session, createStatus: boolean = false, connectTimeoutMs: number = DefaultSocket.DefaultConnectTimeoutMs): Promise<Session> {
1190
+ connect(session: Session, createStatus: boolean = false, connectTimeoutMs: number = DefaultSocket.DefaultConnectTimeoutMs, signal?: AbortSignal): Promise<Session> {
1189
1191
  if (this.adapter.isOpen()) {
1190
1192
  return Promise.resolve(session);
1191
1193
  }
1192
1194
 
1193
1195
  const scheme = (this.useSSL) ? "wss://" : "ws://";
1194
- this.adapter.connect(scheme, this.host, this.port, createStatus, session.token);
1196
+ this.adapter.connect(scheme, this.host, this.port, createStatus, session.token, signal);
1195
1197
 
1196
1198
  this.adapter.onClose = (evt: Event) => {
1197
1199
  this.ondisconnect(evt);
@@ -1828,8 +1830,8 @@ export class DefaultSocket implements Socket {
1828
1830
  return response.hashtag_dm_list_event
1829
1831
  }
1830
1832
 
1831
- async getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
1832
- const response = await this.send({permission_role_channel_list_event: {role_id: role_id, channel_id: channel_id }});
1833
+ async getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent> {
1834
+ const response = await this.send({permission_role_channel_list_event: {role_id: role_id, channel_id: channel_id, user_id: user_id }});
1833
1835
  return response.permission_role_channel_list_event
1834
1836
  }
1835
1837
 
@@ -25,34 +25,34 @@ export interface WebSocketAdapter {
25
25
  /**
26
26
  * Dispatched when the web socket closes.
27
27
  */
28
- onClose : SocketCloseHandler | null;
28
+ onClose: SocketCloseHandler | null;
29
29
 
30
30
  /**
31
31
  * Dispatched when the web socket receives an error.
32
32
  */
33
- onError : SocketErrorHandler | null;
33
+ onError: SocketErrorHandler | null;
34
34
 
35
35
  /**
36
36
  * Dispatched when the web socket receives a normal message.
37
37
  */
38
- onMessage : SocketMessageHandler | null;
38
+ onMessage: SocketMessageHandler | null;
39
39
 
40
40
  /**
41
41
  * Dispatched when the web socket opens.
42
42
  */
43
- onOpen : SocketOpenHandler | null;
43
+ onOpen: SocketOpenHandler | null;
44
44
 
45
45
  isOpen(): boolean;
46
- close() : void;
47
- connect(scheme: string, host: string, port : string, createStatus: boolean, token : string) : void;
48
- send(message: any) : void;
46
+ close(): void;
47
+ connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void;
48
+ send(message: any): void;
49
49
  }
50
50
 
51
51
  /**
52
52
  * SocketCloseHandler defines a lambda that handles WebSocket close events.
53
53
  */
54
54
  export interface SocketCloseHandler {
55
- (this : WebSocket, evt: CloseEvent): void;
55
+ (this: WebSocket, evt: CloseEvent): void;
56
56
  }
57
57
 
58
58
  /**
@@ -60,7 +60,7 @@ export interface SocketCloseHandler {
60
60
  * that indicate an error.
61
61
  */
62
62
  export interface SocketErrorHandler {
63
- (this : WebSocket, evt: Event): void;
63
+ (this: WebSocket, evt: Event): void;
64
64
  }
65
65
 
66
66
  /**
@@ -74,7 +74,7 @@ export interface SocketMessageHandler {
74
74
  * SocketOpenHandler defines a lambda that handles WebSocket open events.
75
75
  */
76
76
  export interface SocketOpenHandler {
77
- (this : WebSocket, evt : Event) : void
77
+ (this: WebSocket, evt: Event): void
78
78
  }
79
79
 
80
80
  /**
@@ -107,7 +107,6 @@ export class WebSocketAdapterText implements WebSocketAdapter {
107
107
  if (value) {
108
108
  this._socket!.onmessage = (evt: MessageEvent) => {
109
109
  const message: any = JSON.parse(evt.data);
110
-
111
110
  if (message.party_data && message.party_data.data) {
112
111
  message.party_data.data = new Uint8Array(decode(message.party_data.data));
113
112
  }
@@ -132,13 +131,18 @@ export class WebSocketAdapterText implements WebSocketAdapter {
132
131
  return this._socket?.readyState == WebSocket.OPEN;
133
132
  }
134
133
 
135
- connect(scheme: string, host: string, port: string, createStatus: boolean, token: string): void {
134
+ connect(scheme: string, host: string, port: string, createStatus: boolean, token: string, signal?: AbortSignal): void {
135
+ if (signal) {
136
+ signal.addEventListener('abort', () => {
137
+ this.close();
138
+ });
139
+ }
136
140
  const url = `${scheme}${host}:${port}/ws?lang=en&status=${encodeURIComponent(createStatus.toString())}&token=${encodeURIComponent(token)}`;
137
141
  this._socket = new WebSocket(url);
138
142
  }
139
143
 
140
144
  close() {
141
- this._socket!.close();
145
+ this._socket?.close();
142
146
  this._socket = undefined;
143
147
  }
144
148