mezon-js 2.7.51 → 2.7.54

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
@@ -172,6 +172,14 @@ export interface ApiCategoryDescList {
172
172
  categorydesc?: Array<ApiCategoryDesc>;
173
173
  }
174
174
 
175
+ /** Update fields in a given channel. */
176
+ export interface ApiChangeChannelPrivateRequest {
177
+ //The ID of the channel to update.
178
+ channel_id?: string;
179
+ //
180
+ channel_private?: number;
181
+ }
182
+
175
183
  /** */
176
184
  export interface ApiChannelAttachment {
177
185
  //The UNIX time (for gRPC clients) or ISO string (for REST clients) when the group was created.
@@ -378,6 +386,16 @@ export interface ApiClanUserList {
378
386
  cursor?: string;
379
387
  }
380
388
 
389
+ /** A collection of zero or more friends of the user. */
390
+ export interface ApiCommonToUsersList {
391
+ //The Clan objects.
392
+ clandesc?: Array<ApiClanDesc>;
393
+ //Cursor for the next page of results, if any.
394
+ cursor?: string;
395
+ //The Friend objects.
396
+ friends?: Array<ApiFriend>;
397
+ }
398
+
381
399
  /** */
382
400
  export interface ApiCreateCategoryDescRequest {
383
401
  //
@@ -1193,6 +1211,8 @@ export interface ApiUser {
1193
1211
  google_id?: string;
1194
1212
  //The id of the user's account.
1195
1213
  id?: string;
1214
+ //
1215
+ join_time?: string;
1196
1216
  //The language expected to be a tag which follows the BCP-47 spec.
1197
1217
  lang_tag?: string;
1198
1218
  //The location set by the user.
@@ -3264,6 +3284,45 @@ export class MezonApi {
3264
3284
  ]);
3265
3285
  }
3266
3286
 
3287
+ /** List common friends for the current user. */
3288
+ listCommonToUsers(bearerToken: string,
3289
+ limit?:number,
3290
+ state?:number,
3291
+ cursor?:string,
3292
+ friendId?:string,
3293
+ options: any = {}): Promise<ApiCommonToUsersList> {
3294
+
3295
+ const urlPath = "/v2/commonfriend";
3296
+ const queryParams = new Map<string, any>();
3297
+ queryParams.set("limit", limit);
3298
+ queryParams.set("state", state);
3299
+ queryParams.set("cursor", cursor);
3300
+ queryParams.set("friend_id", friendId);
3301
+
3302
+ let bodyJson : string = "";
3303
+
3304
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3305
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3306
+ if (bearerToken) {
3307
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3308
+ }
3309
+
3310
+ return Promise.race([
3311
+ fetch(fullUrl, fetchOptions).then((response) => {
3312
+ if (response.status == 204) {
3313
+ return response;
3314
+ } else if (response.status >= 200 && response.status < 300) {
3315
+ return response.json();
3316
+ } else {
3317
+ throw response;
3318
+ }
3319
+ }),
3320
+ new Promise((_, reject) =>
3321
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
3322
+ ),
3323
+ ]);
3324
+ }
3325
+
3267
3326
  /** */
3268
3327
  createCategoryDesc(bearerToken: string,
3269
3328
  body:ApiCreateCategoryDescRequest,
@@ -3336,41 +3395,6 @@ export class MezonApi {
3336
3395
  ]);
3337
3396
  }
3338
3397
 
3339
- /** open direct message. */
3340
- openDirectMess(bearerToken: string,
3341
- body:ApiDeleteChannelDescRequest,
3342
- options: any = {}): Promise<any> {
3343
-
3344
- if (body === null || body === undefined) {
3345
- throw new Error("'body' is a required parameter but is null or undefined.");
3346
- }
3347
- const urlPath = "/v2/direct/open";
3348
- const queryParams = new Map<string, any>();
3349
-
3350
- let bodyJson : string = "";
3351
- bodyJson = JSON.stringify(body || {});
3352
-
3353
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3354
- const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
3355
- if (bearerToken) {
3356
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3357
- }
3358
-
3359
- return Promise.race([
3360
- fetch(fullUrl, fetchOptions).then((response) => {
3361
- if (response.status == 204) {
3362
- return response;
3363
- } else if (response.status >= 200 && response.status < 300) {
3364
- return response.json();
3365
- } else {
3366
- throw response;
3367
- }
3368
- }),
3369
- new Promise((_, reject) =>
3370
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3371
- ),
3372
- ]);
3373
- }
3374
3398
  /** regist fcm device token */
3375
3399
  registFCMDeviceToken(bearerToken: string,
3376
3400
  token?:string,
@@ -3444,6 +3468,42 @@ export class MezonApi {
3444
3468
  ]);
3445
3469
  }
3446
3470
 
3471
+ /** open direct message. */
3472
+ openDirectMess(bearerToken: string,
3473
+ body:ApiDeleteChannelDescRequest,
3474
+ options: any = {}): Promise<any> {
3475
+
3476
+ if (body === null || body === undefined) {
3477
+ throw new Error("'body' is a required parameter but is null or undefined.");
3478
+ }
3479
+ const urlPath = "/v2/direct/open";
3480
+ const queryParams = new Map<string, any>();
3481
+
3482
+ let bodyJson : string = "";
3483
+ bodyJson = JSON.stringify(body || {});
3484
+
3485
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3486
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
3487
+ if (bearerToken) {
3488
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3489
+ }
3490
+
3491
+ return Promise.race([
3492
+ fetch(fullUrl, fetchOptions).then((response) => {
3493
+ if (response.status == 204) {
3494
+ return response;
3495
+ } else if (response.status >= 200 && response.status < 300) {
3496
+ return response.json();
3497
+ } else {
3498
+ throw response;
3499
+ }
3500
+ }),
3501
+ new Promise((_, reject) =>
3502
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
3503
+ ),
3504
+ ]);
3505
+ }
3506
+
3447
3507
  /** Search message from elasticsearch service. */
3448
3508
  searchMessage(bearerToken: string,
3449
3509
  body:ApiSearchMessageRequest,
@@ -5442,6 +5502,42 @@ export class MezonApi {
5442
5502
  ]);
5443
5503
  }
5444
5504
 
5505
+ /** Update channel private. */
5506
+ updateChannelPrivate(bearerToken: string,
5507
+ body:ApiChangeChannelPrivateRequest,
5508
+ options: any = {}): Promise<any> {
5509
+
5510
+ if (body === null || body === undefined) {
5511
+ throw new Error("'body' is a required parameter but is null or undefined.");
5512
+ }
5513
+ const urlPath = "/v2/updatechannelprivate";
5514
+ const queryParams = new Map<string, any>();
5515
+
5516
+ let bodyJson : string = "";
5517
+ bodyJson = JSON.stringify(body || {});
5518
+
5519
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
5520
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
5521
+ if (bearerToken) {
5522
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
5523
+ }
5524
+
5525
+ return Promise.race([
5526
+ fetch(fullUrl, fetchOptions).then((response) => {
5527
+ if (response.status == 204) {
5528
+ return response;
5529
+ } else if (response.status >= 200 && response.status < 300) {
5530
+ return response.json();
5531
+ } else {
5532
+ throw response;
5533
+ }
5534
+ }),
5535
+ new Promise((_, reject) =>
5536
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
5537
+ ),
5538
+ ]);
5539
+ }
5540
+
5445
5541
  /** */
5446
5542
  updateUserProfileByClan(bearerToken: string,
5447
5543
  clanId:string,
package/client.ts CHANGED
@@ -93,6 +93,8 @@ import {
93
93
  ApiCreateWebhookRequest,
94
94
  ApiWebhookResponse,
95
95
  ApiDeleteChannelDescRequest,
96
+ ApiChangeChannelPrivateRequest,
97
+ ApiCommonToUsersList,
96
98
  } from "./api.gen";
97
99
 
98
100
  import { Session } from "./session";
@@ -1959,6 +1961,19 @@ export class Client {
1959
1961
 
1960
1962
  });
1961
1963
  }
1964
+
1965
+ /** */
1966
+ async listCommonToUsers(session: Session, userId?: string, state?: number, limit?: number, cursor?: string): Promise<ApiCommonToUsersList> {
1967
+ if (this.autoRefreshSession && session.refresh_token &&
1968
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
1969
+ await this.sessionRefresh(session);
1970
+ }
1971
+
1972
+ return this.apiClient.listCommonToUsers(session.token, limit, state, cursor, userId).then((response: ApiCommonToUsersList) => {
1973
+ return Promise.resolve(response);
1974
+
1975
+ });
1976
+ }
1962
1977
 
1963
1978
  /** Get permission of user in the clan */
1964
1979
  async GetPermissionOfUserInTheClan(session: Session, clanId:string): Promise<ApiPermissionList> {
@@ -2055,6 +2070,18 @@ async setMuteNotificationChannel(session: Session, request: ApiSetMuteNotificati
2055
2070
  });
2056
2071
  }
2057
2072
 
2073
+ /** update channel private*/
2074
+ async updateChannelPrivate(session: Session, request: ApiChangeChannelPrivateRequest): Promise<boolean> {
2075
+ if (this.autoRefreshSession && session.refresh_token &&
2076
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
2077
+ await this.sessionRefresh(session);
2078
+ }
2079
+
2080
+ return this.apiClient.updateChannelPrivate(session.token, request).then((response: any) => {
2081
+ return response !== undefined;
2082
+ });
2083
+ }
2084
+
2058
2085
  /** get default notification clan */
2059
2086
  async getNotificationChannel(session: Session, channelId: string): Promise<ApiNotificationUserChannel> {
2060
2087
  if (this.autoRefreshSession && session.refresh_token &&
package/dist/api.gen.d.ts CHANGED
@@ -99,6 +99,11 @@ export interface ApiCategoryDesc {
99
99
  export interface ApiCategoryDescList {
100
100
  categorydesc?: Array<ApiCategoryDesc>;
101
101
  }
102
+ /** Update fields in a given channel. */
103
+ export interface ApiChangeChannelPrivateRequest {
104
+ channel_id?: string;
105
+ channel_private?: number;
106
+ }
102
107
  /** */
103
108
  export interface ApiChannelAttachment {
104
109
  create_time?: string;
@@ -215,6 +220,12 @@ export interface ApiClanUserList {
215
220
  clan_users?: Array<ClanUserListClanUser>;
216
221
  cursor?: string;
217
222
  }
223
+ /** A collection of zero or more friends of the user. */
224
+ export interface ApiCommonToUsersList {
225
+ clandesc?: Array<ApiClanDesc>;
226
+ cursor?: string;
227
+ friends?: Array<ApiFriend>;
228
+ }
218
229
  /** */
219
230
  export interface ApiCreateCategoryDescRequest {
220
231
  category_name?: string;
@@ -689,6 +700,7 @@ export interface ApiUser {
689
700
  gamecenter_id?: string;
690
701
  google_id?: string;
691
702
  id?: string;
703
+ join_time?: string;
692
704
  lang_tag?: string;
693
705
  location?: string;
694
706
  metadata?: string;
@@ -852,16 +864,18 @@ export declare class MezonApi {
852
864
  getClanDescProfile(bearerToken: string, clanId: string, options?: any): Promise<ApiClanDescProfile>;
853
865
  /** Update fields in a given clan profile. */
854
866
  updateClanDescProfile(bearerToken: string, clanId: string, body: {}, options?: any): Promise<any>;
867
+ /** List common friends for the current user. */
868
+ listCommonToUsers(bearerToken: string, limit?: number, state?: number, cursor?: string, friendId?: string, options?: any): Promise<ApiCommonToUsersList>;
855
869
  /** */
856
870
  createCategoryDesc(bearerToken: string, body: ApiCreateCategoryDescRequest, options?: any): Promise<ApiCategoryDesc>;
857
871
  /** */
858
872
  deleteCategoryDesc(bearerToken: string, creatorId: string, options?: any): Promise<any>;
859
- /** open direct message. */
860
- openDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
861
873
  /** regist fcm device token */
862
874
  registFCMDeviceToken(bearerToken: string, token?: string, deviceId?: string, platform?: string, options?: any): Promise<any>;
863
875
  /** close direct message. */
864
876
  closeDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
877
+ /** open direct message. */
878
+ openDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
865
879
  /** Search message from elasticsearch service. */
866
880
  searchMessage(bearerToken: string, body: ApiSearchMessageRequest, options?: any): Promise<ApiSearchMessageResponse>;
867
881
  /** Submit an event for processing in the server's registered runtime custom events handler. */
@@ -972,6 +986,8 @@ export declare class MezonApi {
972
986
  listStorageObjects2(bearerToken: string, collection: string, userId: string, limit?: number, cursor?: string, options?: any): Promise<ApiStorageObjectList>;
973
987
  /** Update fields in a given category. */
974
988
  updateCategory(bearerToken: string, body: ApiUpdateCategoryDescRequest, options?: any): Promise<any>;
989
+ /** Update channel private. */
990
+ updateChannelPrivate(bearerToken: string, body: ApiChangeChannelPrivateRequest, options?: any): Promise<any>;
975
991
  /** */
976
992
  updateUserProfileByClan(bearerToken: string, clanId: string, body: {}, options?: any): Promise<any>;
977
993
  /** Upload attachment */
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, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiCreateWebhookRequest, ApiWebhookResponse, ApiDeleteChannelDescRequest } from "./api.gen";
16
+ import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiRoleList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiNotificationChannelCategoySettingsList, ApiNotificationSetting, ApiSetDefaultNotificationRequest, ApiNotificationUserChannel, ApiSetNotificationRequest, ApiNotifiReactMessage, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiCreateWebhookRequest, ApiWebhookResponse, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiCommonToUsersList } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -541,6 +541,8 @@ export declare class Client {
541
541
  createLinkInviteUser(session: Session, request: ApiLinkInviteUserRequest): Promise<ApiLinkInviteUser>;
542
542
  /** Get link invite user */
543
543
  getLinkInvite(session: Session, inviteId: string): Promise<ApiInviteUserRes>;
544
+ /** */
545
+ listCommonToUsers(session: Session, userId?: string, state?: number, limit?: number, cursor?: string): Promise<ApiCommonToUsersList>;
544
546
  /** Get permission of user in the clan */
545
547
  GetPermissionOfUserInTheClan(session: Session, clanId: string): Promise<ApiPermissionList>;
546
548
  /** invite user */
@@ -555,6 +557,8 @@ export declare class Client {
555
557
  setNotificationChannel(session: Session, request: ApiSetNotificationRequest): Promise<boolean>;
556
558
  /** Set notification channel*/
557
559
  setMuteNotificationChannel(session: Session, request: ApiSetMuteNotificationRequest): Promise<boolean>;
560
+ /** update channel private*/
561
+ updateChannelPrivate(session: Session, request: ApiChangeChannelPrivateRequest): Promise<boolean>;
558
562
  /** get default notification clan */
559
563
  getNotificationChannel(session: Session, channelId: string): Promise<ApiNotificationUserChannel>;
560
564
  /** Set default notification category*/
@@ -2189,6 +2189,35 @@ var MezonApi = class {
2189
2189
  )
2190
2190
  ]);
2191
2191
  }
2192
+ /** List common friends for the current user. */
2193
+ listCommonToUsers(bearerToken, limit, state, cursor, friendId, options = {}) {
2194
+ const urlPath = "/v2/commonfriend";
2195
+ const queryParams = /* @__PURE__ */ new Map();
2196
+ queryParams.set("limit", limit);
2197
+ queryParams.set("state", state);
2198
+ queryParams.set("cursor", cursor);
2199
+ queryParams.set("friend_id", friendId);
2200
+ let bodyJson = "";
2201
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2202
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
2203
+ if (bearerToken) {
2204
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2205
+ }
2206
+ return Promise.race([
2207
+ fetch(fullUrl, fetchOptions).then((response) => {
2208
+ if (response.status == 204) {
2209
+ return response;
2210
+ } else if (response.status >= 200 && response.status < 300) {
2211
+ return response.json();
2212
+ } else {
2213
+ throw response;
2214
+ }
2215
+ }),
2216
+ new Promise(
2217
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
2218
+ )
2219
+ ]);
2220
+ }
2192
2221
  /** */
2193
2222
  createCategoryDesc(bearerToken, body, options = {}) {
2194
2223
  if (body === null || body === void 0) {
@@ -2246,17 +2275,16 @@ var MezonApi = class {
2246
2275
  )
2247
2276
  ]);
2248
2277
  }
2249
- /** open direct message. */
2250
- openDirectMess(bearerToken, body, options = {}) {
2251
- if (body === null || body === void 0) {
2252
- throw new Error("'body' is a required parameter but is null or undefined.");
2253
- }
2254
- const urlPath = "/v2/direct/open";
2278
+ /** regist fcm device token */
2279
+ registFCMDeviceToken(bearerToken, token, deviceId, platform, options = {}) {
2280
+ const urlPath = "/v2/devicetoken";
2255
2281
  const queryParams = /* @__PURE__ */ new Map();
2282
+ queryParams.set("token", token);
2283
+ queryParams.set("device_id", deviceId);
2284
+ queryParams.set("platform", platform);
2256
2285
  let bodyJson = "";
2257
- bodyJson = JSON.stringify(body || {});
2258
2286
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2259
- const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
2287
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
2260
2288
  if (bearerToken) {
2261
2289
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2262
2290
  }
@@ -2275,16 +2303,17 @@ var MezonApi = class {
2275
2303
  )
2276
2304
  ]);
2277
2305
  }
2278
- /** regist fcm device token */
2279
- registFCMDeviceToken(bearerToken, token, deviceId, platform, options = {}) {
2280
- const urlPath = "/v2/devicetoken";
2306
+ /** close direct message. */
2307
+ closeDirectMess(bearerToken, body, options = {}) {
2308
+ if (body === null || body === void 0) {
2309
+ throw new Error("'body' is a required parameter but is null or undefined.");
2310
+ }
2311
+ const urlPath = "/v2/direct/close";
2281
2312
  const queryParams = /* @__PURE__ */ new Map();
2282
- queryParams.set("token", token);
2283
- queryParams.set("device_id", deviceId);
2284
- queryParams.set("platform", platform);
2285
2313
  let bodyJson = "";
2314
+ bodyJson = JSON.stringify(body || {});
2286
2315
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2287
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
2316
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
2288
2317
  if (bearerToken) {
2289
2318
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2290
2319
  }
@@ -2303,12 +2332,12 @@ var MezonApi = class {
2303
2332
  )
2304
2333
  ]);
2305
2334
  }
2306
- /** close direct message. */
2307
- closeDirectMess(bearerToken, body, options = {}) {
2335
+ /** open direct message. */
2336
+ openDirectMess(bearerToken, body, options = {}) {
2308
2337
  if (body === null || body === void 0) {
2309
2338
  throw new Error("'body' is a required parameter but is null or undefined.");
2310
2339
  }
2311
- const urlPath = "/v2/direct/close";
2340
+ const urlPath = "/v2/direct/open";
2312
2341
  const queryParams = /* @__PURE__ */ new Map();
2313
2342
  let bodyJson = "";
2314
2343
  bodyJson = JSON.stringify(body || {});
@@ -3901,6 +3930,35 @@ var MezonApi = class {
3901
3930
  )
3902
3931
  ]);
3903
3932
  }
3933
+ /** Update channel private. */
3934
+ updateChannelPrivate(bearerToken, body, options = {}) {
3935
+ if (body === null || body === void 0) {
3936
+ throw new Error("'body' is a required parameter but is null or undefined.");
3937
+ }
3938
+ const urlPath = "/v2/updatechannelprivate";
3939
+ const queryParams = /* @__PURE__ */ new Map();
3940
+ let bodyJson = "";
3941
+ bodyJson = JSON.stringify(body || {});
3942
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3943
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
3944
+ if (bearerToken) {
3945
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3946
+ }
3947
+ return Promise.race([
3948
+ fetch(fullUrl, fetchOptions).then((response) => {
3949
+ if (response.status == 204) {
3950
+ return response;
3951
+ } else if (response.status >= 200 && response.status < 300) {
3952
+ return response.json();
3953
+ } else {
3954
+ throw response;
3955
+ }
3956
+ }),
3957
+ new Promise(
3958
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3959
+ )
3960
+ ]);
3961
+ }
3904
3962
  /** */
3905
3963
  updateUserProfileByClan(bearerToken, clanId, body, options = {}) {
3906
3964
  if (clanId === null || clanId === void 0) {
@@ -5975,6 +6033,17 @@ var Client = class {
5975
6033
  });
5976
6034
  });
5977
6035
  }
6036
+ /** */
6037
+ listCommonToUsers(session, userId, state, limit, cursor) {
6038
+ return __async(this, null, function* () {
6039
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6040
+ yield this.sessionRefresh(session);
6041
+ }
6042
+ return this.apiClient.listCommonToUsers(session.token, limit, state, cursor, userId).then((response) => {
6043
+ return Promise.resolve(response);
6044
+ });
6045
+ });
6046
+ }
5978
6047
  /** Get permission of user in the clan */
5979
6048
  GetPermissionOfUserInTheClan(session, clanId) {
5980
6049
  return __async(this, null, function* () {
@@ -6061,6 +6130,17 @@ var Client = class {
6061
6130
  });
6062
6131
  });
6063
6132
  }
6133
+ /** update channel private*/
6134
+ updateChannelPrivate(session, request) {
6135
+ return __async(this, null, function* () {
6136
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6137
+ yield this.sessionRefresh(session);
6138
+ }
6139
+ return this.apiClient.updateChannelPrivate(session.token, request).then((response) => {
6140
+ return response !== void 0;
6141
+ });
6142
+ });
6143
+ }
6064
6144
  /** get default notification clan */
6065
6145
  getNotificationChannel(session, channelId) {
6066
6146
  return __async(this, null, function* () {
@@ -2160,6 +2160,35 @@ var MezonApi = class {
2160
2160
  )
2161
2161
  ]);
2162
2162
  }
2163
+ /** List common friends for the current user. */
2164
+ listCommonToUsers(bearerToken, limit, state, cursor, friendId, options = {}) {
2165
+ const urlPath = "/v2/commonfriend";
2166
+ const queryParams = /* @__PURE__ */ new Map();
2167
+ queryParams.set("limit", limit);
2168
+ queryParams.set("state", state);
2169
+ queryParams.set("cursor", cursor);
2170
+ queryParams.set("friend_id", friendId);
2171
+ let bodyJson = "";
2172
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2173
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
2174
+ if (bearerToken) {
2175
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2176
+ }
2177
+ return Promise.race([
2178
+ fetch(fullUrl, fetchOptions).then((response) => {
2179
+ if (response.status == 204) {
2180
+ return response;
2181
+ } else if (response.status >= 200 && response.status < 300) {
2182
+ return response.json();
2183
+ } else {
2184
+ throw response;
2185
+ }
2186
+ }),
2187
+ new Promise(
2188
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
2189
+ )
2190
+ ]);
2191
+ }
2163
2192
  /** */
2164
2193
  createCategoryDesc(bearerToken, body, options = {}) {
2165
2194
  if (body === null || body === void 0) {
@@ -2217,17 +2246,16 @@ var MezonApi = class {
2217
2246
  )
2218
2247
  ]);
2219
2248
  }
2220
- /** open direct message. */
2221
- openDirectMess(bearerToken, body, options = {}) {
2222
- if (body === null || body === void 0) {
2223
- throw new Error("'body' is a required parameter but is null or undefined.");
2224
- }
2225
- const urlPath = "/v2/direct/open";
2249
+ /** regist fcm device token */
2250
+ registFCMDeviceToken(bearerToken, token, deviceId, platform, options = {}) {
2251
+ const urlPath = "/v2/devicetoken";
2226
2252
  const queryParams = /* @__PURE__ */ new Map();
2253
+ queryParams.set("token", token);
2254
+ queryParams.set("device_id", deviceId);
2255
+ queryParams.set("platform", platform);
2227
2256
  let bodyJson = "";
2228
- bodyJson = JSON.stringify(body || {});
2229
2257
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2230
- const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
2258
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
2231
2259
  if (bearerToken) {
2232
2260
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2233
2261
  }
@@ -2246,16 +2274,17 @@ var MezonApi = class {
2246
2274
  )
2247
2275
  ]);
2248
2276
  }
2249
- /** regist fcm device token */
2250
- registFCMDeviceToken(bearerToken, token, deviceId, platform, options = {}) {
2251
- const urlPath = "/v2/devicetoken";
2277
+ /** close direct message. */
2278
+ closeDirectMess(bearerToken, body, options = {}) {
2279
+ if (body === null || body === void 0) {
2280
+ throw new Error("'body' is a required parameter but is null or undefined.");
2281
+ }
2282
+ const urlPath = "/v2/direct/close";
2252
2283
  const queryParams = /* @__PURE__ */ new Map();
2253
- queryParams.set("token", token);
2254
- queryParams.set("device_id", deviceId);
2255
- queryParams.set("platform", platform);
2256
2284
  let bodyJson = "";
2285
+ bodyJson = JSON.stringify(body || {});
2257
2286
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2258
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
2287
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
2259
2288
  if (bearerToken) {
2260
2289
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2261
2290
  }
@@ -2274,12 +2303,12 @@ var MezonApi = class {
2274
2303
  )
2275
2304
  ]);
2276
2305
  }
2277
- /** close direct message. */
2278
- closeDirectMess(bearerToken, body, options = {}) {
2306
+ /** open direct message. */
2307
+ openDirectMess(bearerToken, body, options = {}) {
2279
2308
  if (body === null || body === void 0) {
2280
2309
  throw new Error("'body' is a required parameter but is null or undefined.");
2281
2310
  }
2282
- const urlPath = "/v2/direct/close";
2311
+ const urlPath = "/v2/direct/open";
2283
2312
  const queryParams = /* @__PURE__ */ new Map();
2284
2313
  let bodyJson = "";
2285
2314
  bodyJson = JSON.stringify(body || {});
@@ -3872,6 +3901,35 @@ var MezonApi = class {
3872
3901
  )
3873
3902
  ]);
3874
3903
  }
3904
+ /** Update channel private. */
3905
+ updateChannelPrivate(bearerToken, body, options = {}) {
3906
+ if (body === null || body === void 0) {
3907
+ throw new Error("'body' is a required parameter but is null or undefined.");
3908
+ }
3909
+ const urlPath = "/v2/updatechannelprivate";
3910
+ const queryParams = /* @__PURE__ */ new Map();
3911
+ let bodyJson = "";
3912
+ bodyJson = JSON.stringify(body || {});
3913
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3914
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
3915
+ if (bearerToken) {
3916
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3917
+ }
3918
+ return Promise.race([
3919
+ fetch(fullUrl, fetchOptions).then((response) => {
3920
+ if (response.status == 204) {
3921
+ return response;
3922
+ } else if (response.status >= 200 && response.status < 300) {
3923
+ return response.json();
3924
+ } else {
3925
+ throw response;
3926
+ }
3927
+ }),
3928
+ new Promise(
3929
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3930
+ )
3931
+ ]);
3932
+ }
3875
3933
  /** */
3876
3934
  updateUserProfileByClan(bearerToken, clanId, body, options = {}) {
3877
3935
  if (clanId === null || clanId === void 0) {
@@ -5946,6 +6004,17 @@ var Client = class {
5946
6004
  });
5947
6005
  });
5948
6006
  }
6007
+ /** */
6008
+ listCommonToUsers(session, userId, state, limit, cursor) {
6009
+ return __async(this, null, function* () {
6010
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6011
+ yield this.sessionRefresh(session);
6012
+ }
6013
+ return this.apiClient.listCommonToUsers(session.token, limit, state, cursor, userId).then((response) => {
6014
+ return Promise.resolve(response);
6015
+ });
6016
+ });
6017
+ }
5949
6018
  /** Get permission of user in the clan */
5950
6019
  GetPermissionOfUserInTheClan(session, clanId) {
5951
6020
  return __async(this, null, function* () {
@@ -6032,6 +6101,17 @@ var Client = class {
6032
6101
  });
6033
6102
  });
6034
6103
  }
6104
+ /** update channel private*/
6105
+ updateChannelPrivate(session, request) {
6106
+ return __async(this, null, function* () {
6107
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
6108
+ yield this.sessionRefresh(session);
6109
+ }
6110
+ return this.apiClient.updateChannelPrivate(session.token, request).then((response) => {
6111
+ return response !== void 0;
6112
+ });
6113
+ });
6114
+ }
6035
6115
  /** get default notification clan */
6036
6116
  getNotificationChannel(session, channelId) {
6037
6117
  return __async(this, null, function* () {
package/dist/socket.d.ts CHANGED
@@ -287,6 +287,7 @@ export interface ChannelCreatedEvent {
287
287
  parrent_id: string;
288
288
  channel_id: string;
289
289
  channel_label: string;
290
+ channel_private: number;
290
291
  channel_type: number;
291
292
  status: number;
292
293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.7.51",
3
+ "version": "2.7.54",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -410,6 +410,8 @@ export interface ChannelCreatedEvent {
410
410
  channel_id: string;
411
411
  // channel label
412
412
  channel_label: string;
413
+ // channel private
414
+ channel_private: number;
413
415
  // channel type
414
416
  channel_type: number;
415
417
  // status