mezon-js 2.9.14 → 2.9.15

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/api.gen.ts CHANGED
@@ -394,6 +394,12 @@ export interface ApiAllUsersAddChannelResponse {
394
394
  user_ids?: Array<string>;
395
395
  }
396
396
 
397
+ /** */
398
+ export interface ApiAllUserClans {
399
+ //
400
+ users?: Array<ApiUser>;
401
+ }
402
+
397
403
  /** App information. */
398
404
  export interface ApiApp {
399
405
  //
@@ -1579,6 +1585,20 @@ export interface ApiRoleList {
1579
1585
  roles?: Array<ApiRole>;
1580
1586
  }
1581
1587
 
1588
+ /** */
1589
+ export interface ApiRoleListEventResponse {
1590
+ //
1591
+ clan_id?: string;
1592
+ //
1593
+ cursor?: string;
1594
+ //
1595
+ limit?: string;
1596
+ //
1597
+ roles?: ApiRoleList;
1598
+ //
1599
+ state?: string;
1600
+ }
1601
+
1582
1602
  /** */
1583
1603
  export interface ApiRoleUserList {
1584
1604
  //Cursor for the next page of results, if any.
@@ -6435,6 +6455,45 @@ export class MezonApi {
6435
6455
  ]);
6436
6456
  }
6437
6457
 
6458
+ /** ListRoles */
6459
+ listRoles(bearerToken: string,
6460
+ clanId?:string,
6461
+ limit?:string,
6462
+ state?:string,
6463
+ cursor?:string,
6464
+ options: any = {}): Promise<ApiRoleListEventResponse> {
6465
+
6466
+ const urlPath = "/v2/roles";
6467
+ const queryParams = new Map<string, any>();
6468
+ queryParams.set("clan_id", clanId);
6469
+ queryParams.set("limit", limit);
6470
+ queryParams.set("state", state);
6471
+ queryParams.set("cursor", cursor);
6472
+
6473
+ let bodyJson : string = "";
6474
+
6475
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6476
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
6477
+ if (bearerToken) {
6478
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6479
+ }
6480
+
6481
+ return Promise.race([
6482
+ fetch(fullUrl, fetchOptions).then((response) => {
6483
+ if (response.status == 204) {
6484
+ return response;
6485
+ } else if (response.status >= 200 && response.status < 300) {
6486
+ return response.json();
6487
+ } else {
6488
+ throw response;
6489
+ }
6490
+ }),
6491
+ new Promise((_, reject) =>
6492
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6493
+ ),
6494
+ ]);
6495
+ }
6496
+
6438
6497
  /** Create a new role for clan. */
6439
6498
  createRole(bearerToken: string,
6440
6499
  body:ApiCreateRoleRequest,
@@ -7498,6 +7557,37 @@ export class MezonApi {
7498
7557
  ]);
7499
7558
  }
7500
7559
 
7560
+ /** ListUserClansByUserId */
7561
+ listUserClansByUserId(bearerToken: string,
7562
+ options: any = {}): Promise<ApiAllUserClans> {
7563
+
7564
+ const urlPath = "/v2/users/clans";
7565
+ const queryParams = new Map<string, any>();
7566
+
7567
+ let bodyJson : string = "";
7568
+
7569
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
7570
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
7571
+ if (bearerToken) {
7572
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
7573
+ }
7574
+
7575
+ return Promise.race([
7576
+ fetch(fullUrl, fetchOptions).then((response) => {
7577
+ if (response.status == 204) {
7578
+ return response;
7579
+ } else if (response.status >= 200 && response.status < 300) {
7580
+ return response.json();
7581
+ } else {
7582
+ throw response;
7583
+ }
7584
+ }),
7585
+ new Promise((_, reject) =>
7586
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
7587
+ ),
7588
+ ]);
7589
+ }
7590
+
7501
7591
  /** create webhook */
7502
7592
  generateWebhook(bearerToken: string,
7503
7593
  body:ApiWebhookCreateRequest,
package/client.ts CHANGED
@@ -116,6 +116,8 @@ import {
116
116
  ApiEmojiListedResponse,
117
117
  ApiStickerListedResponse,
118
118
  ApiAllUsersAddChannelResponse,
119
+ ApiRoleListEventResponse,
120
+ ApiAllUserClans,
119
121
  } from "./api.gen";
120
122
 
121
123
  import { Session } from "./session";
@@ -3706,7 +3708,7 @@ export class Client {
3706
3708
  async hashtagDMList(
3707
3709
  session: Session,
3708
3710
  userId: Array<string>,
3709
- limit:number
3711
+ limit: number
3710
3712
  ): Promise<ApiHashtagDmList> {
3711
3713
  if (
3712
3714
  this.autoRefreshSession &&
@@ -3723,9 +3725,7 @@ export class Client {
3723
3725
  });
3724
3726
  }
3725
3727
 
3726
- async listChannelByUserId(
3727
- session: Session
3728
- ): Promise<ApiChannelDescList> {
3728
+ async listChannelByUserId(session: Session): Promise<ApiChannelDescList> {
3729
3729
  if (
3730
3730
  this.autoRefreshSession &&
3731
3731
  session.refresh_token &&
@@ -3741,8 +3741,11 @@ export class Client {
3741
3741
  });
3742
3742
  }
3743
3743
 
3744
-
3745
- async listUsersAddChannelByChannelId(session: Session, channel_id : string, limit : number): Promise<ApiAllUsersAddChannelResponse> {
3744
+ async listUsersAddChannelByChannelId(
3745
+ session: Session,
3746
+ channel_id: string,
3747
+ limit: number
3748
+ ): Promise<ApiAllUsersAddChannelResponse> {
3746
3749
  if (
3747
3750
  this.autoRefreshSession &&
3748
3751
  session.refresh_token &&
@@ -3758,7 +3761,9 @@ export class Client {
3758
3761
  });
3759
3762
  }
3760
3763
 
3761
- async getListEmojisByUserId(session: Session): Promise<ApiEmojiListedResponse> {
3764
+ async getListEmojisByUserId(
3765
+ session: Session
3766
+ ): Promise<ApiEmojiListedResponse> {
3762
3767
  if (
3763
3768
  this.autoRefreshSession &&
3764
3769
  session.refresh_token &&
@@ -3774,8 +3779,9 @@ export class Client {
3774
3779
  });
3775
3780
  }
3776
3781
 
3777
-
3778
- async getListStickersByUserId(session: Session): Promise<ApiStickerListedResponse> {
3782
+ async getListStickersByUserId(
3783
+ session: Session
3784
+ ): Promise<ApiStickerListedResponse> {
3779
3785
  if (
3780
3786
  this.autoRefreshSession &&
3781
3787
  session.refresh_token &&
@@ -3790,4 +3796,47 @@ export class Client {
3790
3796
  return Promise.resolve(response);
3791
3797
  });
3792
3798
  }
3799
+
3800
+ async listUserClansByUserId(session: Session): Promise<ApiAllUserClans> {
3801
+ if (
3802
+ this.autoRefreshSession &&
3803
+ session.refresh_token &&
3804
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3805
+ ) {
3806
+ await this.sessionRefresh(session);
3807
+ }
3808
+
3809
+ return this.apiClient
3810
+ .listUserClansByUserId(session.token)
3811
+ .then((response: ApiAllUserClans) => {
3812
+ return Promise.resolve(response);
3813
+ });
3814
+ }
3815
+
3816
+ async listRoles(
3817
+ session: Session,
3818
+ clanId?: string,
3819
+ limit?: string,
3820
+ state?: string,
3821
+ cursor?: string
3822
+ ): Promise<ApiRoleListEventResponse> {
3823
+ if (
3824
+ this.autoRefreshSession &&
3825
+ session.refresh_token &&
3826
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3827
+ ) {
3828
+ await this.sessionRefresh(session);
3829
+ }
3830
+
3831
+ return this.apiClient
3832
+ .listRoles(session.token, clanId, limit, state, cursor)
3833
+ .then((response: ApiRoleListEventResponse) => {
3834
+ var result: ApiRoleListEventResponse = {
3835
+ clan_id: clanId,
3836
+ roles: response.roles,
3837
+ };
3838
+
3839
+ return Promise.resolve(result);
3840
+ });
3841
+ }
3793
3842
  }
package/dist/api.gen.d.ts CHANGED
@@ -230,6 +230,10 @@ export interface ApiAllUsersAddChannelResponse {
230
230
  limit?: number;
231
231
  user_ids?: Array<string>;
232
232
  }
233
+ /** */
234
+ export interface ApiAllUserClans {
235
+ users?: Array<ApiUser>;
236
+ }
233
237
  /** App information. */
234
238
  export interface ApiApp {
235
239
  about?: string;
@@ -914,6 +918,14 @@ export interface ApiRoleList {
914
918
  roles?: Array<ApiRole>;
915
919
  }
916
920
  /** */
921
+ export interface ApiRoleListEventResponse {
922
+ clan_id?: string;
923
+ cursor?: string;
924
+ limit?: string;
925
+ roles?: ApiRoleList;
926
+ state?: string;
927
+ }
928
+ /** */
917
929
  export interface ApiRoleUserList {
918
930
  cursor?: string;
919
931
  role_users?: Array<RoleUserListRoleUser>;
@@ -1416,6 +1428,8 @@ export declare class MezonApi {
1416
1428
  changeChannelCategory(bearerToken: string, newCategoryId: string, body: MezonChangeChannelCategoryBody, options?: any): Promise<any>;
1417
1429
  /** Update a role when Delete a role by ID. */
1418
1430
  deleteRoleChannelDesc(bearerToken: string, body: ApiDeleteRoleRequest, options?: any): Promise<any>;
1431
+ /** ListRoles */
1432
+ listRoles(bearerToken: string, clanId?: string, limit?: string, state?: string, cursor?: string, options?: any): Promise<ApiRoleListEventResponse>;
1419
1433
  /** Create a new role for clan. */
1420
1434
  createRole(bearerToken: string, body: ApiCreateRoleRequest, options?: any): Promise<ApiRole>;
1421
1435
  /** Update a role when Delete a role by ID. */
@@ -1472,6 +1486,8 @@ export declare class MezonApi {
1472
1486
  getUsers(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, facebookIds?: Array<string>, options?: any): Promise<ApiUsers>;
1473
1487
  /** */
1474
1488
  updateUser(bearerToken: string, body: ApiUpdateUsersRequest, options?: any): Promise<any>;
1489
+ /** ListUserClansByUserId */
1490
+ listUserClansByUserId(bearerToken: string, options?: any): Promise<ApiAllUserClans>;
1475
1491
  /** create webhook */
1476
1492
  generateWebhook(bearerToken: string, body: ApiWebhookCreateRequest, options?: any): Promise<any>;
1477
1493
  /** update webhook name by id */
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, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse } 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, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -570,4 +570,6 @@ export declare class Client {
570
570
  listUsersAddChannelByChannelId(session: Session, channel_id: string, limit: number): Promise<ApiAllUsersAddChannelResponse>;
571
571
  getListEmojisByUserId(session: Session): Promise<ApiEmojiListedResponse>;
572
572
  getListStickersByUserId(session: Session): Promise<ApiStickerListedResponse>;
573
+ listUserClansByUserId(session: Session): Promise<ApiAllUserClans>;
574
+ listRoles(session: Session, clanId?: string, limit?: string, state?: string, cursor?: string): Promise<ApiRoleListEventResponse>;
573
575
  }
@@ -4141,6 +4141,35 @@ var MezonApi = class {
4141
4141
  )
4142
4142
  ]);
4143
4143
  }
4144
+ /** ListRoles */
4145
+ listRoles(bearerToken, clanId, limit, state, cursor, options = {}) {
4146
+ const urlPath = "/v2/roles";
4147
+ const queryParams = /* @__PURE__ */ new Map();
4148
+ queryParams.set("clan_id", clanId);
4149
+ queryParams.set("limit", limit);
4150
+ queryParams.set("state", state);
4151
+ queryParams.set("cursor", cursor);
4152
+ let bodyJson = "";
4153
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4154
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4155
+ if (bearerToken) {
4156
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4157
+ }
4158
+ return Promise.race([
4159
+ fetch(fullUrl, fetchOptions).then((response) => {
4160
+ if (response.status == 204) {
4161
+ return response;
4162
+ } else if (response.status >= 200 && response.status < 300) {
4163
+ return response.json();
4164
+ } else {
4165
+ throw response;
4166
+ }
4167
+ }),
4168
+ new Promise(
4169
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4170
+ )
4171
+ ]);
4172
+ }
4144
4173
  /** Create a new role for clan. */
4145
4174
  createRole(bearerToken, body, options = {}) {
4146
4175
  if (body === null || body === void 0) {
@@ -4971,6 +5000,31 @@ var MezonApi = class {
4971
5000
  )
4972
5001
  ]);
4973
5002
  }
5003
+ /** ListUserClansByUserId */
5004
+ listUserClansByUserId(bearerToken, options = {}) {
5005
+ const urlPath = "/v2/users/clans";
5006
+ const queryParams = /* @__PURE__ */ new Map();
5007
+ let bodyJson = "";
5008
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
5009
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
5010
+ if (bearerToken) {
5011
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
5012
+ }
5013
+ return Promise.race([
5014
+ fetch(fullUrl, fetchOptions).then((response) => {
5015
+ if (response.status == 204) {
5016
+ return response;
5017
+ } else if (response.status >= 200 && response.status < 300) {
5018
+ return response.json();
5019
+ } else {
5020
+ throw response;
5021
+ }
5022
+ }),
5023
+ new Promise(
5024
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
5025
+ )
5026
+ ]);
5027
+ }
4974
5028
  /** create webhook */
4975
5029
  generateWebhook(bearerToken, body, options = {}) {
4976
5030
  if (body === null || body === void 0) {
@@ -5422,6 +5476,8 @@ var _DefaultSocket = class _DefaultSocket {
5422
5476
  this.onstreamingchanneljoined(message.streaming_joined_event);
5423
5477
  } else if (message.streaming_leaved_event) {
5424
5478
  this.onstreamingchannelleaved(message.streaming_leaved_event);
5479
+ } else if (message.set_permission_channel_event) {
5480
+ this.onsetpermissionchannel(message.set_permission_channel_event);
5425
5481
  } else {
5426
5482
  if (this.verbose && window && window.console) {
5427
5483
  console.log("Unrecognized message received: %o", message);
@@ -5674,6 +5730,11 @@ var _DefaultSocket = class _DefaultSocket {
5674
5730
  console.log(streaming_leaved_event);
5675
5731
  }
5676
5732
  }
5733
+ onsetpermissionchannel(set_permission_channel_event) {
5734
+ if (this.verbose && window && window.console) {
5735
+ console.log(set_permission_channel_event);
5736
+ }
5737
+ }
5677
5738
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
5678
5739
  const untypedMessage = message;
5679
5740
  return new Promise((resolve, reject) => {
@@ -7947,4 +8008,28 @@ var Client = class {
7947
8008
  });
7948
8009
  });
7949
8010
  }
8011
+ listUserClansByUserId(session) {
8012
+ return __async(this, null, function* () {
8013
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
8014
+ yield this.sessionRefresh(session);
8015
+ }
8016
+ return this.apiClient.listUserClansByUserId(session.token).then((response) => {
8017
+ return Promise.resolve(response);
8018
+ });
8019
+ });
8020
+ }
8021
+ listRoles(session, clanId, limit, state, cursor) {
8022
+ return __async(this, null, function* () {
8023
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
8024
+ yield this.sessionRefresh(session);
8025
+ }
8026
+ return this.apiClient.listRoles(session.token, clanId, limit, state, cursor).then((response) => {
8027
+ var result = {
8028
+ clan_id: clanId,
8029
+ roles: response.roles
8030
+ };
8031
+ return Promise.resolve(result);
8032
+ });
8033
+ });
8034
+ }
7950
8035
  };
@@ -4112,6 +4112,35 @@ var MezonApi = class {
4112
4112
  )
4113
4113
  ]);
4114
4114
  }
4115
+ /** ListRoles */
4116
+ listRoles(bearerToken, clanId, limit, state, cursor, options = {}) {
4117
+ const urlPath = "/v2/roles";
4118
+ const queryParams = /* @__PURE__ */ new Map();
4119
+ queryParams.set("clan_id", clanId);
4120
+ queryParams.set("limit", limit);
4121
+ queryParams.set("state", state);
4122
+ queryParams.set("cursor", cursor);
4123
+ let bodyJson = "";
4124
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4125
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4126
+ if (bearerToken) {
4127
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4128
+ }
4129
+ return Promise.race([
4130
+ fetch(fullUrl, fetchOptions).then((response) => {
4131
+ if (response.status == 204) {
4132
+ return response;
4133
+ } else if (response.status >= 200 && response.status < 300) {
4134
+ return response.json();
4135
+ } else {
4136
+ throw response;
4137
+ }
4138
+ }),
4139
+ new Promise(
4140
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4141
+ )
4142
+ ]);
4143
+ }
4115
4144
  /** Create a new role for clan. */
4116
4145
  createRole(bearerToken, body, options = {}) {
4117
4146
  if (body === null || body === void 0) {
@@ -4942,6 +4971,31 @@ var MezonApi = class {
4942
4971
  )
4943
4972
  ]);
4944
4973
  }
4974
+ /** ListUserClansByUserId */
4975
+ listUserClansByUserId(bearerToken, options = {}) {
4976
+ const urlPath = "/v2/users/clans";
4977
+ const queryParams = /* @__PURE__ */ new Map();
4978
+ let bodyJson = "";
4979
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4980
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
4981
+ if (bearerToken) {
4982
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4983
+ }
4984
+ return Promise.race([
4985
+ fetch(fullUrl, fetchOptions).then((response) => {
4986
+ if (response.status == 204) {
4987
+ return response;
4988
+ } else if (response.status >= 200 && response.status < 300) {
4989
+ return response.json();
4990
+ } else {
4991
+ throw response;
4992
+ }
4993
+ }),
4994
+ new Promise(
4995
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4996
+ )
4997
+ ]);
4998
+ }
4945
4999
  /** create webhook */
4946
5000
  generateWebhook(bearerToken, body, options = {}) {
4947
5001
  if (body === null || body === void 0) {
@@ -5393,6 +5447,8 @@ var _DefaultSocket = class _DefaultSocket {
5393
5447
  this.onstreamingchanneljoined(message.streaming_joined_event);
5394
5448
  } else if (message.streaming_leaved_event) {
5395
5449
  this.onstreamingchannelleaved(message.streaming_leaved_event);
5450
+ } else if (message.set_permission_channel_event) {
5451
+ this.onsetpermissionchannel(message.set_permission_channel_event);
5396
5452
  } else {
5397
5453
  if (this.verbose && window && window.console) {
5398
5454
  console.log("Unrecognized message received: %o", message);
@@ -5645,6 +5701,11 @@ var _DefaultSocket = class _DefaultSocket {
5645
5701
  console.log(streaming_leaved_event);
5646
5702
  }
5647
5703
  }
5704
+ onsetpermissionchannel(set_permission_channel_event) {
5705
+ if (this.verbose && window && window.console) {
5706
+ console.log(set_permission_channel_event);
5707
+ }
5708
+ }
5648
5709
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
5649
5710
  const untypedMessage = message;
5650
5711
  return new Promise((resolve, reject) => {
@@ -7918,6 +7979,30 @@ var Client = class {
7918
7979
  });
7919
7980
  });
7920
7981
  }
7982
+ listUserClansByUserId(session) {
7983
+ return __async(this, null, function* () {
7984
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7985
+ yield this.sessionRefresh(session);
7986
+ }
7987
+ return this.apiClient.listUserClansByUserId(session.token).then((response) => {
7988
+ return Promise.resolve(response);
7989
+ });
7990
+ });
7991
+ }
7992
+ listRoles(session, clanId, limit, state, cursor) {
7993
+ return __async(this, null, function* () {
7994
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7995
+ yield this.sessionRefresh(session);
7996
+ }
7997
+ return this.apiClient.listRoles(session.token, clanId, limit, state, cursor).then((response) => {
7998
+ var result = {
7999
+ clan_id: clanId,
8000
+ roles: response.roles
8001
+ };
8002
+ return Promise.resolve(result);
8003
+ });
8004
+ });
8005
+ }
7921
8006
  };
7922
8007
  export {
7923
8008
  ChannelStreamMode,
package/dist/socket.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 { ApiChannelDescList, ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiHashtagDmList, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotificationChannelCategorySettingList, ApiPermissionList, ApiRole, ApiRoleList, ApiRpc, ApiUser } from "./api.gen";
16
+ import { ApiChannelDescList, ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiHashtagDmList, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotificationChannelCategorySettingList, ApiPermissionList, ApiPermissionUpdate, ApiRole, ApiRoleList, ApiRpc, ApiUser } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { ChannelMessage, Notification } from "./client";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -644,6 +644,16 @@ export interface StreamingEndedEvent {
644
644
  /** channel id */
645
645
  channel_id: string;
646
646
  }
647
+ export interface SetPermissionChannelEvent {
648
+ /** Role ID */
649
+ role_id: string;
650
+ /** User ID */
651
+ user_id: string;
652
+ /** Channel ID */
653
+ channel_id: string;
654
+ /** List permission update */
655
+ permission_updates: ApiPermissionUpdate[];
656
+ }
647
657
  /** A socket connection to Mezon server. */
648
658
  export interface Socket {
649
659
  /** Connection is Open */
@@ -765,6 +775,7 @@ export interface Socket {
765
775
  onstreamingchannelended: (streaming_ended_event: StreamingEndedEvent) => void;
766
776
  onstreamingchanneljoined: (streaming_joined_event: StreamingJoinedEvent) => void;
767
777
  onstreamingchannelleaved: (streaming_leaved_event: StreamingLeavedEvent) => void;
778
+ onsetpermissionchannel: (set_permission_channel_event: SetPermissionChannelEvent) => void;
768
779
  }
769
780
  /** Reports an error received from a socket message. */
770
781
  export interface SocketError {
@@ -834,6 +845,7 @@ export declare class DefaultSocket implements Socket {
834
845
  onstreamingchannelended(streaming_ended_event: StreamingEndedEvent): void;
835
846
  onstreamingchanneljoined(streaming_joined_event: StreamingJoinedEvent): void;
836
847
  onstreamingchannelleaved(streaming_leaved_event: StreamingLeavedEvent): void;
848
+ onsetpermissionchannel(set_permission_channel_event: SetPermissionChannelEvent): void;
837
849
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
838
850
  followUsers(userIds: string[]): Promise<Status>;
839
851
  joinClanChat(clan_id: string): Promise<ClanJoin>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.9.14",
4
+ "version": "2.9.15",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
package/socket.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { ApiChannelDescList, ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiHashtagDmList, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiNotificationChannelCategorySettingList, ApiPermissionList, ApiRole, ApiRoleList, ApiRpc, ApiUser} from "./api.gen";
17
+ import { ApiChannelDescList, ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiHashtagDmList, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiNotificationChannelCategorySettingList, ApiPermissionList, ApiPermissionUpdate, ApiRole, ApiRoleList, ApiRpc, ApiUser} from "./api.gen";
18
18
  import {Session} from "./session";
19
19
  import {ChannelMessage, Notification} from "./client";
20
20
  import {WebSocketAdapter, WebSocketAdapterText} from "./web_socket_adapter"
@@ -938,6 +938,17 @@ export interface StreamingEndedEvent {
938
938
  channel_id: string;
939
939
  }
940
940
 
941
+ export interface SetPermissionChannelEvent {
942
+ /** Role ID */
943
+ role_id: string;
944
+ /** User ID */
945
+ user_id: string;
946
+ /** Channel ID */
947
+ channel_id: string;
948
+ /** List permission update */
949
+ permission_updates: ApiPermissionUpdate[];
950
+ }
951
+
941
952
  /** A socket connection to Mezon server. */
942
953
  export interface Socket {
943
954
  /** Connection is Open */
@@ -1120,7 +1131,7 @@ export interface Socket {
1120
1131
  listUserClansByUserId(): Promise<AllUserClans>;
1121
1132
 
1122
1133
  listUsersAddChannelByChannelId(channelId: string, limit: number): Promise<AllUsersAddChannelEvent>;
1123
-
1134
+
1124
1135
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
1125
1136
 
1126
1137
  getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
@@ -1132,7 +1143,7 @@ export interface Socket {
1132
1143
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
1133
1144
 
1134
1145
  getPermissionByRoleIdChannelId(role_id: string, channel_id: string, user_id: string): Promise<PermissionRoleChannelListEvent>;
1135
-
1146
+
1136
1147
  getNotificationChannelCategorySetting(clan_id : string): Promise<NotificationChannelCategorySettingEvent>;
1137
1148
 
1138
1149
  oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
@@ -1151,6 +1162,7 @@ export interface Socket {
1151
1162
 
1152
1163
  onstreamingchannelleaved: (streaming_leaved_event: StreamingLeavedEvent) => void;
1153
1164
 
1165
+ onsetpermissionchannel: (set_permission_channel_event: SetPermissionChannelEvent) => void;
1154
1166
  }
1155
1167
 
1156
1168
  /** Reports an error received from a socket message. */
@@ -1346,7 +1358,9 @@ export class DefaultSocket implements Socket {
1346
1358
  this.onstreamingchanneljoined(<StreamingJoinedEvent>message.streaming_joined_event);
1347
1359
  } else if(message.streaming_leaved_event){
1348
1360
  this.onstreamingchannelleaved(<StreamingLeavedEvent>message.streaming_leaved_event);
1349
- } else {
1361
+ } else if(message.set_permission_channel_event){
1362
+ this.onsetpermissionchannel(<SetPermissionChannelEvent>message.set_permission_channel_event);
1363
+ }else {
1350
1364
  if (this.verbose && window && window.console) {
1351
1365
  console.log("Unrecognized message received: %o", message);
1352
1366
  }
@@ -1648,6 +1662,12 @@ export class DefaultSocket implements Socket {
1648
1662
  }
1649
1663
  }
1650
1664
 
1665
+ onsetpermissionchannel(set_permission_channel_event: SetPermissionChannelEvent){
1666
+ if (this.verbose && window && window.console) {
1667
+ console.log(set_permission_channel_event);
1668
+ }
1669
+ }
1670
+
1651
1671
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent |
1652
1672
  ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout = DefaultSocket.DefaultSendTimeoutMs): Promise<any> {
1653
1673
  const untypedMessage = message as any;