mezon-js 2.9.22 → 2.9.23

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -1226,6 +1226,16 @@ export interface ApiMessageDeleted {
1226
1226
  message_id?: string;
1227
1227
  }
1228
1228
 
1229
+ /** */
1230
+ export interface ApiMarkAsReadRequest {
1231
+ //
1232
+ category_id?: string;
1233
+ //
1234
+ channel_id?: string;
1235
+ //
1236
+ clan_id?: string;
1237
+ }
1238
+
1229
1239
  /** */
1230
1240
  export interface ApiMessageMention {
1231
1241
  //The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was created.
@@ -6100,6 +6110,42 @@ export class MezonApi {
6100
6110
  ]);
6101
6111
  }
6102
6112
 
6113
+ /** Mark as read */
6114
+ markAsRead(bearerToken: string,
6115
+ body:ApiMarkAsReadRequest,
6116
+ options: any = {}): Promise<any> {
6117
+
6118
+ if (body === null || body === undefined) {
6119
+ throw new Error("'body' is a required parameter but is null or undefined.");
6120
+ }
6121
+ const urlPath = "/v2/markasread";
6122
+ const queryParams = new Map<string, any>();
6123
+
6124
+ let bodyJson : string = "";
6125
+ bodyJson = JSON.stringify(body || {});
6126
+
6127
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6128
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
6129
+ if (bearerToken) {
6130
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6131
+ }
6132
+
6133
+ return Promise.race([
6134
+ fetch(fullUrl, fetchOptions).then((response) => {
6135
+ if (response.status == 204) {
6136
+ return response;
6137
+ } else if (response.status >= 200 && response.status < 300) {
6138
+ return response.json();
6139
+ } else {
6140
+ throw response;
6141
+ }
6142
+ }),
6143
+ new Promise((_, reject) =>
6144
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
6145
+ ),
6146
+ ]);
6147
+ }
6148
+
6103
6149
  /** set mute notification user channel. */
6104
6150
  setMuteNotificationCategory(
6105
6151
  bearerToken: string,
package/client.ts CHANGED
@@ -120,6 +120,7 @@ import {
120
120
  ApiAllUserClans,
121
121
  ApiUserPermissionInChannelListResponse,
122
122
  ApiPermissionRoleChannelListEventResponse,
123
+ ApiMarkAsReadRequest,
123
124
  } from "./api.gen";
124
125
 
125
126
  import { Session } from "./session";
@@ -3899,4 +3900,23 @@ export class Client {
3899
3900
  return Promise.resolve(result);
3900
3901
  });
3901
3902
  }
3903
+
3904
+ async markAsRead(
3905
+ session: Session,
3906
+ request: ApiMarkAsReadRequest
3907
+ ): Promise<any> {
3908
+ if (
3909
+ this.autoRefreshSession &&
3910
+ session.refresh_token &&
3911
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3912
+ ) {
3913
+ await this.sessionRefresh(session);
3914
+ }
3915
+
3916
+ return this.apiClient
3917
+ .markAsRead(session.token, request)
3918
+ .then((response: any) => {
3919
+ return Promise.resolve(response);
3920
+ });
3921
+ }
3902
3922
  }
package/dist/api.gen.d.ts CHANGED
@@ -710,6 +710,12 @@ export interface ApiMessageDeleted {
710
710
  message_id?: string;
711
711
  }
712
712
  /** */
713
+ export interface ApiMarkAsReadRequest {
714
+ category_id?: string;
715
+ channel_id?: string;
716
+ clan_id?: string;
717
+ }
718
+ /** */
713
719
  export interface ApiMessageMention {
714
720
  create_time?: string;
715
721
  id?: string;
@@ -1416,6 +1422,8 @@ export declare class MezonApi {
1416
1422
  inviteUser(bearerToken: string, inviteId: string, options?: any): Promise<ApiInviteUserRes>;
1417
1423
  /** List HashtagDMList */
1418
1424
  listChannelByUserId(bearerToken: string, options?: any): Promise<ApiChannelDescList>;
1425
+ /** Mark as read */
1426
+ markAsRead(bearerToken: string, body: ApiMarkAsReadRequest, options?: any): Promise<any>;
1419
1427
  /** set mute notification user channel. */
1420
1428
  setMuteNotificationCategory(bearerToken: string, body: ApiSetMuteNotificationRequest, options?: any): Promise<any>;
1421
1429
  /** set mute notification user channel. */
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, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse } 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, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -576,4 +576,5 @@ export declare class Client {
576
576
  listRoles(session: Session, clanId?: string, limit?: string, state?: string, cursor?: string): Promise<ApiRoleListEventResponse>;
577
577
  listUserPermissionInChannel(session: Session, clanId?: string, channelId?: string): Promise<ApiUserPermissionInChannelListResponse>;
578
578
  getPermissionByRoleIdChannelId(session: Session, roleId?: string, channelId?: string, userId?: string): Promise<ApiPermissionRoleChannelListEventResponse>;
579
+ markAsRead(session: Session, request: ApiMarkAsReadRequest): Promise<any>;
579
580
  }
@@ -3824,6 +3824,35 @@ var MezonApi = class {
3824
3824
  )
3825
3825
  ]);
3826
3826
  }
3827
+ /** Mark as read */
3828
+ markAsRead(bearerToken, body, options = {}) {
3829
+ if (body === null || body === void 0) {
3830
+ throw new Error("'body' is a required parameter but is null or undefined.");
3831
+ }
3832
+ const urlPath = "/v2/markasread";
3833
+ const queryParams = /* @__PURE__ */ new Map();
3834
+ let bodyJson = "";
3835
+ bodyJson = JSON.stringify(body || {});
3836
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3837
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3838
+ if (bearerToken) {
3839
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3840
+ }
3841
+ return Promise.race([
3842
+ fetch(fullUrl, fetchOptions).then((response) => {
3843
+ if (response.status == 204) {
3844
+ return response;
3845
+ } else if (response.status >= 200 && response.status < 300) {
3846
+ return response.json();
3847
+ } else {
3848
+ throw response;
3849
+ }
3850
+ }),
3851
+ new Promise(
3852
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3853
+ )
3854
+ ]);
3855
+ }
3827
3856
  /** set mute notification user channel. */
3828
3857
  setMuteNotificationCategory(bearerToken, body, options = {}) {
3829
3858
  if (body === null || body === void 0) {
@@ -8511,4 +8540,14 @@ var Client = class {
8511
8540
  });
8512
8541
  });
8513
8542
  }
8543
+ markAsRead(session, request) {
8544
+ return __async(this, null, function* () {
8545
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
8546
+ yield this.sessionRefresh(session);
8547
+ }
8548
+ return this.apiClient.markAsRead(session.token, request).then((response) => {
8549
+ return Promise.resolve(response);
8550
+ });
8551
+ });
8552
+ }
8514
8553
  };
@@ -3795,6 +3795,35 @@ var MezonApi = class {
3795
3795
  )
3796
3796
  ]);
3797
3797
  }
3798
+ /** Mark as read */
3799
+ markAsRead(bearerToken, body, options = {}) {
3800
+ if (body === null || body === void 0) {
3801
+ throw new Error("'body' is a required parameter but is null or undefined.");
3802
+ }
3803
+ const urlPath = "/v2/markasread";
3804
+ const queryParams = /* @__PURE__ */ new Map();
3805
+ let bodyJson = "";
3806
+ bodyJson = JSON.stringify(body || {});
3807
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3808
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3809
+ if (bearerToken) {
3810
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3811
+ }
3812
+ return Promise.race([
3813
+ fetch(fullUrl, fetchOptions).then((response) => {
3814
+ if (response.status == 204) {
3815
+ return response;
3816
+ } else if (response.status >= 200 && response.status < 300) {
3817
+ return response.json();
3818
+ } else {
3819
+ throw response;
3820
+ }
3821
+ }),
3822
+ new Promise(
3823
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3824
+ )
3825
+ ]);
3826
+ }
3798
3827
  /** set mute notification user channel. */
3799
3828
  setMuteNotificationCategory(bearerToken, body, options = {}) {
3800
3829
  if (body === null || body === void 0) {
@@ -8482,6 +8511,16 @@ var Client = class {
8482
8511
  });
8483
8512
  });
8484
8513
  }
8514
+ markAsRead(session, request) {
8515
+ return __async(this, null, function* () {
8516
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
8517
+ yield this.sessionRefresh(session);
8518
+ }
8519
+ return this.apiClient.markAsRead(session.token, request).then((response) => {
8520
+ return Promise.resolve(response);
8521
+ });
8522
+ });
8523
+ }
8485
8524
  };
8486
8525
  export {
8487
8526
  ChannelStreamMode,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.9.22",
4
+ "version": "2.9.23",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"