mezon-js 2.7.42 → 2.7.44

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
@@ -224,6 +224,8 @@ export interface ApiChannelDescription {
224
224
  channel_private?: number;
225
225
  //
226
226
  clan_id?: string;
227
+ //
228
+ count_mess_unread?: number;
227
229
  //creator ID.
228
230
  creator_id?: string;
229
231
  //
@@ -476,6 +478,16 @@ export interface ApiCreateRoleRequest {
476
478
  title?: string;
477
479
  }
478
480
 
481
+ /** */
482
+ export interface ApiCreateWebhookRequest {
483
+ //
484
+ channel_id?: string;
485
+ //
486
+ clan_id?: string;
487
+ //
488
+ hook_name?: string;
489
+ }
490
+
479
491
  /** */
480
492
  export interface ApiDeleteEventRequest {
481
493
  //The id of a event.
@@ -1215,6 +1227,16 @@ export interface ApiVoiceChannelUserList {
1215
1227
  voice_channel_users?: Array<ApiVoiceChannelUser>;
1216
1228
  }
1217
1229
 
1230
+ /** */
1231
+ export interface ApiWebhookResponse {
1232
+ //
1233
+ channel_id?: string;
1234
+ //
1235
+ hook_name?: string;
1236
+ //
1237
+ hook_url?: string;
1238
+ }
1239
+
1218
1240
  /** The object to store. */
1219
1241
  export interface ApiWriteStorageObject {
1220
1242
  //The collection to store the object.
@@ -5491,6 +5513,42 @@ export class MezonApi {
5491
5513
  ]);
5492
5514
  }
5493
5515
 
5516
+ /** Create webhook */
5517
+ createWebhookLink(bearerToken: string,
5518
+ body:ApiCreateWebhookRequest,
5519
+ options: any = {}): Promise<ApiWebhookResponse> {
5520
+
5521
+ if (body === null || body === undefined) {
5522
+ throw new Error("'body' is a required parameter but is null or undefined.");
5523
+ }
5524
+ const urlPath = "/v2/webhook/create";
5525
+ const queryParams = new Map<string, any>();
5526
+
5527
+ let bodyJson : string = "";
5528
+ bodyJson = JSON.stringify(body || {});
5529
+
5530
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
5531
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
5532
+ if (bearerToken) {
5533
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
5534
+ }
5535
+
5536
+ return Promise.race([
5537
+ fetch(fullUrl, fetchOptions).then((response) => {
5538
+ if (response.status == 204) {
5539
+ return response;
5540
+ } else if (response.status >= 200 && response.status < 300) {
5541
+ return response.json();
5542
+ } else {
5543
+ throw response;
5544
+ }
5545
+ }),
5546
+ new Promise((_, reject) =>
5547
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
5548
+ ),
5549
+ ]);
5550
+ }
5551
+
5494
5552
  buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>) {
5495
5553
  let fullPath = basePath + fragment + "?";
5496
5554
 
package/client.ts CHANGED
@@ -90,6 +90,8 @@ import {
90
90
  ApiSearchMessageResponse,
91
91
  ApiPinMessageRequest,
92
92
  ApiPinMessagesList,
93
+ ApiCreateWebhookRequest,
94
+ ApiWebhookResponse,
93
95
  } from "./api.gen";
94
96
 
95
97
  import { Session } from "./session";
@@ -768,6 +770,18 @@ export class Client {
768
770
  });
769
771
  }
770
772
 
773
+ /** Create a new event for clan. */
774
+ async createWebhook(session: Session, request: ApiCreateWebhookRequest): Promise<ApiWebhookResponse> {
775
+ if (this.autoRefreshSession && session.refresh_token &&
776
+ session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
777
+ await this.sessionRefresh(session);
778
+ }
779
+
780
+ return this.apiClient.createWebhookLink(session.token, request).then((response: ApiWebhookResponse) => {
781
+ return Promise.resolve(response);
782
+ });
783
+ }
784
+
771
785
  /** add role for channel. */
772
786
  async addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean> {
773
787
  if (this.autoRefreshSession && session.refresh_token &&
package/dist/api.gen.d.ts CHANGED
@@ -129,6 +129,7 @@ export interface ApiChannelDescription {
129
129
  channel_label?: string;
130
130
  channel_private?: number;
131
131
  clan_id?: string;
132
+ count_mess_unread?: number;
132
133
  creator_id?: string;
133
134
  last_seen_message?: ApiChannelMessageHeader;
134
135
  last_sent_message?: ApiChannelMessageHeader;
@@ -271,6 +272,12 @@ export interface ApiCreateRoleRequest {
271
272
  title?: string;
272
273
  }
273
274
  /** */
275
+ export interface ApiCreateWebhookRequest {
276
+ channel_id?: string;
277
+ clan_id?: string;
278
+ hook_name?: string;
279
+ }
280
+ /** */
274
281
  export interface ApiDeleteEventRequest {
275
282
  event_id?: string;
276
283
  }
@@ -701,6 +708,12 @@ export interface ApiVoiceChannelUser {
701
708
  export interface ApiVoiceChannelUserList {
702
709
  voice_channel_users?: Array<ApiVoiceChannelUser>;
703
710
  }
711
+ /** */
712
+ export interface ApiWebhookResponse {
713
+ channel_id?: string;
714
+ hook_name?: string;
715
+ hook_url?: string;
716
+ }
704
717
  /** The object to store. */
705
718
  export interface ApiWriteStorageObject {
706
719
  collection?: string;
@@ -958,5 +971,7 @@ export declare class MezonApi {
958
971
  getUsers(bearerToken: string, ids?: Array<string>, usernames?: Array<string>, facebookIds?: Array<string>, options?: any): Promise<ApiUsers>;
959
972
  /** */
960
973
  updateUser(bearerToken: string, body: ApiUpdateUsersRequest, options?: any): Promise<any>;
974
+ /** Create webhook */
975
+ createWebhookLink(bearerToken: string, body: ApiCreateWebhookRequest, options?: any): Promise<ApiWebhookResponse>;
961
976
  buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>): string;
962
977
  }
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 } 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 } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -396,6 +396,8 @@ export declare class Client {
396
396
  createRole(session: Session, request: ApiCreateRoleRequest): Promise<ApiRole>;
397
397
  /** Create a new event for clan. */
398
398
  createEvent(session: Session, request: ApiCreateEventRequest): Promise<ApiEventManagement>;
399
+ /** Create a new event for clan. */
400
+ createWebhook(session: Session, request: ApiCreateWebhookRequest): Promise<ApiWebhookResponse>;
399
401
  /** add role for channel. */
400
402
  addRolesChannelDesc(session: Session, request: ApiAddRoleChannelDescRequest): Promise<boolean>;
401
403
  /** Update action role when delete role */
@@ -3978,6 +3978,35 @@ var MezonApi = class {
3978
3978
  )
3979
3979
  ]);
3980
3980
  }
3981
+ /** Create webhook */
3982
+ createWebhookLink(bearerToken, body, options = {}) {
3983
+ if (body === null || body === void 0) {
3984
+ throw new Error("'body' is a required parameter but is null or undefined.");
3985
+ }
3986
+ const urlPath = "/v2/webhook/create";
3987
+ const queryParams = /* @__PURE__ */ new Map();
3988
+ let bodyJson = "";
3989
+ bodyJson = JSON.stringify(body || {});
3990
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3991
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3992
+ if (bearerToken) {
3993
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3994
+ }
3995
+ return Promise.race([
3996
+ fetch(fullUrl, fetchOptions).then((response) => {
3997
+ if (response.status == 204) {
3998
+ return response;
3999
+ } else if (response.status >= 200 && response.status < 300) {
4000
+ return response.json();
4001
+ } else {
4002
+ throw response;
4003
+ }
4004
+ }),
4005
+ new Promise(
4006
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
4007
+ )
4008
+ ]);
4009
+ }
3981
4010
  buildFullUrl(basePath, fragment, queryParams) {
3982
4011
  let fullPath = basePath + fragment + "?";
3983
4012
  for (let [k, v] of queryParams) {
@@ -4912,6 +4941,17 @@ var Client = class {
4912
4941
  });
4913
4942
  });
4914
4943
  }
4944
+ /** Create a new event for clan. */
4945
+ createWebhook(session, request) {
4946
+ return __async(this, null, function* () {
4947
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
4948
+ yield this.sessionRefresh(session);
4949
+ }
4950
+ return this.apiClient.createWebhookLink(session.token, request).then((response) => {
4951
+ return Promise.resolve(response);
4952
+ });
4953
+ });
4954
+ }
4915
4955
  /** add role for channel. */
4916
4956
  addRolesChannelDesc(session, request) {
4917
4957
  return __async(this, null, function* () {
@@ -3949,6 +3949,35 @@ var MezonApi = class {
3949
3949
  )
3950
3950
  ]);
3951
3951
  }
3952
+ /** Create webhook */
3953
+ createWebhookLink(bearerToken, body, options = {}) {
3954
+ if (body === null || body === void 0) {
3955
+ throw new Error("'body' is a required parameter but is null or undefined.");
3956
+ }
3957
+ const urlPath = "/v2/webhook/create";
3958
+ const queryParams = /* @__PURE__ */ new Map();
3959
+ let bodyJson = "";
3960
+ bodyJson = JSON.stringify(body || {});
3961
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3962
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3963
+ if (bearerToken) {
3964
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3965
+ }
3966
+ return Promise.race([
3967
+ fetch(fullUrl, fetchOptions).then((response) => {
3968
+ if (response.status == 204) {
3969
+ return response;
3970
+ } else if (response.status >= 200 && response.status < 300) {
3971
+ return response.json();
3972
+ } else {
3973
+ throw response;
3974
+ }
3975
+ }),
3976
+ new Promise(
3977
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3978
+ )
3979
+ ]);
3980
+ }
3952
3981
  buildFullUrl(basePath, fragment, queryParams) {
3953
3982
  let fullPath = basePath + fragment + "?";
3954
3983
  for (let [k, v] of queryParams) {
@@ -4883,6 +4912,17 @@ var Client = class {
4883
4912
  });
4884
4913
  });
4885
4914
  }
4915
+ /** Create a new event for clan. */
4916
+ createWebhook(session, request) {
4917
+ return __async(this, null, function* () {
4918
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
4919
+ yield this.sessionRefresh(session);
4920
+ }
4921
+ return this.apiClient.createWebhookLink(session.token, request).then((response) => {
4922
+ return Promise.resolve(response);
4923
+ });
4924
+ });
4925
+ }
4886
4926
  /** add role for channel. */
4887
4927
  addRolesChannelDesc(session, request) {
4888
4928
  return __async(this, null, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.7.42",
3
+ "version": "2.7.44",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },