mezon-js 2.8.88 → 2.8.91

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -940,6 +940,22 @@ export interface ApiFriendList {
940
940
  friends?: Array<ApiFriend>;
941
941
  }
942
942
 
943
+ /** */
944
+ export interface ApiGiveCoffeeEvent {
945
+ //
946
+ channel_id?: string;
947
+ //
948
+ clan_id?: string;
949
+ //
950
+ message_ref_id?: string;
951
+ //
952
+ receiver_id?: string;
953
+ //
954
+ sender_id?: string;
955
+ //
956
+ token_count?: number;
957
+ }
958
+
943
959
  /** Add link invite users to. */
944
960
  export interface ApiInviteUserRes {
945
961
  //id channel to add link to.
@@ -4961,6 +4977,42 @@ export class MezonApi {
4961
4977
  ]);
4962
4978
  }
4963
4979
 
4980
+ /** Give a coffee */
4981
+ giveMeACoffee(bearerToken: string,
4982
+ body:ApiGiveCoffeeEvent,
4983
+ options: any = {}): Promise<any> {
4984
+
4985
+ if (body === null || body === undefined) {
4986
+ throw new Error("'body' is a required parameter but is null or undefined.");
4987
+ }
4988
+ const urlPath = "/v2/givecoffee";
4989
+ const queryParams = new Map<string, any>();
4990
+
4991
+ let bodyJson : string = "";
4992
+ bodyJson = JSON.stringify(body || {});
4993
+
4994
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
4995
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
4996
+ if (bearerToken) {
4997
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
4998
+ }
4999
+
5000
+ return Promise.race([
5001
+ fetch(fullUrl, fetchOptions).then((response) => {
5002
+ if (response.status == 204) {
5003
+ return response;
5004
+ } else if (response.status >= 200 && response.status < 300) {
5005
+ return response.json();
5006
+ } else {
5007
+ throw response;
5008
+ }
5009
+ }),
5010
+ new Promise((_, reject) =>
5011
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
5012
+ ),
5013
+ ]);
5014
+ }
5015
+
4964
5016
  /** Add users to a channel. */
4965
5017
  createLinkInviteUser(bearerToken: string,
4966
5018
  body:ApiLinkInviteUserRequest,
package/client.ts CHANGED
@@ -101,6 +101,7 @@ import {
101
101
  ApiSystemMessageRequest,
102
102
  MezonUpdateSystemMessageBody,
103
103
  ApiUpdateCategoryOrderRequest,
104
+ ApiGiveCoffeeEvent,
104
105
  } from "./api.gen";
105
106
 
106
107
  import { Session } from "./session";
@@ -3412,6 +3413,7 @@ export class Client {
3412
3413
  return Promise.resolve(response);
3413
3414
  });
3414
3415
  }
3416
+
3415
3417
  async updateCategoryOrder(
3416
3418
  session: Session,
3417
3419
  request: ApiUpdateCategoryOrderRequest
@@ -3430,6 +3432,7 @@ export class Client {
3430
3432
  return Promise.resolve(response);
3431
3433
  });
3432
3434
  }
3435
+
3433
3436
  async deleteCategoryOrder(session: Session, clanId: string): Promise<any> {
3434
3437
  if (
3435
3438
  this.autoRefreshSession &&
@@ -3445,4 +3448,20 @@ export class Client {
3445
3448
  return Promise.resolve(response);
3446
3449
  });
3447
3450
  }
3451
+
3452
+ async givecoffee(session: Session, request: ApiGiveCoffeeEvent) {
3453
+ if (
3454
+ this.autoRefreshSession &&
3455
+ session.refresh_token &&
3456
+ session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
3457
+ ) {
3458
+ await this.sessionRefresh(session);
3459
+ }
3460
+
3461
+ return this.apiClient
3462
+ .giveMeACoffee(session.token, request)
3463
+ .then((response: ApiAppList) => {
3464
+ return response !== undefined;
3465
+ });
3466
+ }
3448
3467
  }
package/dist/api.gen.d.ts CHANGED
@@ -539,6 +539,15 @@ export interface ApiFriendList {
539
539
  cursor?: string;
540
540
  friends?: Array<ApiFriend>;
541
541
  }
542
+ /** */
543
+ export interface ApiGiveCoffeeEvent {
544
+ channel_id?: string;
545
+ clan_id?: string;
546
+ message_ref_id?: string;
547
+ receiver_id?: string;
548
+ sender_id?: string;
549
+ token_count?: number;
550
+ }
542
551
  /** Add link invite users to. */
543
552
  export interface ApiInviteUserRes {
544
553
  channel_id?: string;
@@ -1176,6 +1185,8 @@ export declare class MezonApi {
1176
1185
  importSteamFriends(bearerToken: string, account: ApiAccountSteam, reset?: boolean, options?: any): Promise<any>;
1177
1186
  /** */
1178
1187
  getUserProfileOnClan(bearerToken: string, clanId: string, options?: any): Promise<ApiClanProfile>;
1188
+ /** Give a coffee */
1189
+ giveMeACoffee(bearerToken: string, body: ApiGiveCoffeeEvent, options?: any): Promise<any>;
1179
1190
  /** Add users to a channel. */
1180
1191
  createLinkInviteUser(bearerToken: string, body: ApiLinkInviteUserRequest, options?: any): Promise<ApiLinkInviteUser>;
1181
1192
  /** Add users to a 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 } 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 } from "./api.gen";
17
17
  import { Session } from "./session";
18
18
  import { Socket } from "./socket";
19
19
  import { WebSocketAdapter } from "./web_socket_adapter";
@@ -550,4 +550,5 @@ export declare class Client {
550
550
  deleteSystemMessage(session: Session, clanId: string): Promise<any>;
551
551
  updateCategoryOrder(session: Session, request: ApiUpdateCategoryOrderRequest): Promise<any>;
552
552
  deleteCategoryOrder(session: Session, clanId: string): Promise<any>;
553
+ givecoffee(session: Session, request: ApiGiveCoffeeEvent): Promise<boolean>;
553
554
  }
@@ -3206,6 +3206,35 @@ var MezonApi = class {
3206
3206
  )
3207
3207
  ]);
3208
3208
  }
3209
+ /** Give a coffee */
3210
+ giveMeACoffee(bearerToken, body, options = {}) {
3211
+ if (body === null || body === void 0) {
3212
+ throw new Error("'body' is a required parameter but is null or undefined.");
3213
+ }
3214
+ const urlPath = "/v2/givecoffee";
3215
+ const queryParams = /* @__PURE__ */ new Map();
3216
+ let bodyJson = "";
3217
+ bodyJson = JSON.stringify(body || {});
3218
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3219
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3220
+ if (bearerToken) {
3221
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3222
+ }
3223
+ return Promise.race([
3224
+ fetch(fullUrl, fetchOptions).then((response) => {
3225
+ if (response.status == 204) {
3226
+ return response;
3227
+ } else if (response.status >= 200 && response.status < 300) {
3228
+ return response.json();
3229
+ } else {
3230
+ throw response;
3231
+ }
3232
+ }),
3233
+ new Promise(
3234
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3235
+ )
3236
+ ]);
3237
+ }
3209
3238
  /** Add users to a channel. */
3210
3239
  createLinkInviteUser(bearerToken, body, options = {}) {
3211
3240
  if (body === null || body === void 0) {
@@ -4877,8 +4906,14 @@ var _DefaultSocket = class _DefaultSocket {
4877
4906
  this.onchannelcreated(message.channel_created_event);
4878
4907
  } else if (message.channel_deleted_event) {
4879
4908
  this.onchanneldeleted(message.channel_deleted_event);
4880
- } else if (message.clan_deleted_envet) {
4881
- this.onclandeleted(message.clan_deleted_envet);
4909
+ } else if (message.clan_deleted_event) {
4910
+ this.onclandeleted(message.clan_deleted_event);
4911
+ } else if (message.sticker_create_event) {
4912
+ this.onstickercreated(message.sticker_create_event);
4913
+ } else if (message.sticker_update_event) {
4914
+ this.onstickerupdated(message.sticker_update_event);
4915
+ } else if (message.sticker_delete_event) {
4916
+ this.onstickerdeleted(message.sticker_delete_event);
4882
4917
  } else if (message.channel_updated_event) {
4883
4918
  this.onchannelupdated(message.channel_updated_event);
4884
4919
  } else if (message.clan_profile_updated_event) {
@@ -4962,6 +4997,8 @@ var _DefaultSocket = class _DefaultSocket {
4962
4997
  this.onuserclanremoved(message.user_clan_removed_event);
4963
4998
  } else if (message.clan_event_created) {
4964
4999
  this.oneventcreated(message.clan_event_created);
5000
+ } else if (message.give_coffee_event) {
5001
+ this.oncoffeegiven(message.give_coffee_event);
4965
5002
  } else {
4966
5003
  if (this.verbose && window && window.console) {
4967
5004
  console.log("Unrecognized message received: %o", message);
@@ -5119,6 +5156,21 @@ var _DefaultSocket = class _DefaultSocket {
5119
5156
  console.log(clanDeleted);
5120
5157
  }
5121
5158
  }
5159
+ onstickercreated(stickerCreated) {
5160
+ if (this.verbose && window && window.console) {
5161
+ console.log(stickerCreated);
5162
+ }
5163
+ }
5164
+ onstickerdeleted(stickerDeleted) {
5165
+ if (this.verbose && window && window.console) {
5166
+ console.log(stickerDeleted);
5167
+ }
5168
+ }
5169
+ onstickerupdated(stickerUpdated) {
5170
+ if (this.verbose && window && window.console) {
5171
+ console.log(stickerUpdated);
5172
+ }
5173
+ }
5122
5174
  onchannelupdated(channelUpdated) {
5123
5175
  if (this.verbose && window && window.console) {
5124
5176
  console.log(channelUpdated);
@@ -5159,6 +5211,11 @@ var _DefaultSocket = class _DefaultSocket {
5159
5211
  console.log(clan_event_created);
5160
5212
  }
5161
5213
  }
5214
+ oncoffeegiven(give_coffee_event) {
5215
+ if (this.verbose && window && window.console) {
5216
+ console.log(give_coffee_event);
5217
+ }
5218
+ }
5162
5219
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
5163
5220
  const untypedMessage = message;
5164
5221
  return new Promise((resolve, reject) => {
@@ -5332,13 +5389,13 @@ var _DefaultSocket = class _DefaultSocket {
5332
5389
  return response.role_list_event;
5333
5390
  });
5334
5391
  }
5335
- ListChannelByUserId() {
5392
+ listChannelByUserId() {
5336
5393
  return __async(this, null, function* () {
5337
5394
  const response = yield this.send({ channel_desc_list_event: {} });
5338
5395
  return response.channel_desc_list_event;
5339
5396
  });
5340
5397
  }
5341
- ListUserClansByUserId() {
5398
+ listUserClansByUserId() {
5342
5399
  return __async(this, null, function* () {
5343
5400
  const response = yield this.send({ all_user_clans: {} });
5344
5401
  return response.all_user_clans;
@@ -5350,7 +5407,7 @@ var _DefaultSocket = class _DefaultSocket {
5350
5407
  return response.hashtag_dm_list_event;
5351
5408
  });
5352
5409
  }
5353
- GetPermissionByRoleIdChannelId(role_id, channel_id) {
5410
+ getPermissionByRoleIdChannelId(role_id, channel_id) {
5354
5411
  return __async(this, null, function* () {
5355
5412
  const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
5356
5413
  return response.permission_role_channel_list_event;
@@ -5392,18 +5449,6 @@ var _DefaultSocket = class _DefaultSocket {
5392
5449
  return response.notification_channel_category_setting_event;
5393
5450
  });
5394
5451
  }
5395
- addUserEmojiUsage(add_user_emoji_usage_event) {
5396
- return __async(this, null, function* () {
5397
- const response = yield this.send({ add_user_emoji_usage_event: { add_user_emoji_usage_event } });
5398
- return response.add_user_emoji_usage_event;
5399
- });
5400
- }
5401
- getUserEmojiUsage(clanId) {
5402
- return __async(this, null, function* () {
5403
- const response = yield this.send({ get_user_emoji_usage_event: { clanId } });
5404
- return response.get_user_emoji_usage_event;
5405
- });
5406
- }
5407
5452
  pingPong() {
5408
5453
  return __async(this, null, function* () {
5409
5454
  if (!this.adapter.isOpen()) {
@@ -7246,4 +7291,14 @@ var Client = class {
7246
7291
  });
7247
7292
  });
7248
7293
  }
7294
+ givecoffee(session, request) {
7295
+ return __async(this, null, function* () {
7296
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7297
+ yield this.sessionRefresh(session);
7298
+ }
7299
+ return this.apiClient.giveMeACoffee(session.token, request).then((response) => {
7300
+ return response !== void 0;
7301
+ });
7302
+ });
7303
+ }
7249
7304
  };
@@ -3177,6 +3177,35 @@ var MezonApi = class {
3177
3177
  )
3178
3178
  ]);
3179
3179
  }
3180
+ /** Give a coffee */
3181
+ giveMeACoffee(bearerToken, body, options = {}) {
3182
+ if (body === null || body === void 0) {
3183
+ throw new Error("'body' is a required parameter but is null or undefined.");
3184
+ }
3185
+ const urlPath = "/v2/givecoffee";
3186
+ const queryParams = /* @__PURE__ */ new Map();
3187
+ let bodyJson = "";
3188
+ bodyJson = JSON.stringify(body || {});
3189
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3190
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3191
+ if (bearerToken) {
3192
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3193
+ }
3194
+ return Promise.race([
3195
+ fetch(fullUrl, fetchOptions).then((response) => {
3196
+ if (response.status == 204) {
3197
+ return response;
3198
+ } else if (response.status >= 200 && response.status < 300) {
3199
+ return response.json();
3200
+ } else {
3201
+ throw response;
3202
+ }
3203
+ }),
3204
+ new Promise(
3205
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
3206
+ )
3207
+ ]);
3208
+ }
3180
3209
  /** Add users to a channel. */
3181
3210
  createLinkInviteUser(bearerToken, body, options = {}) {
3182
3211
  if (body === null || body === void 0) {
@@ -4848,8 +4877,14 @@ var _DefaultSocket = class _DefaultSocket {
4848
4877
  this.onchannelcreated(message.channel_created_event);
4849
4878
  } else if (message.channel_deleted_event) {
4850
4879
  this.onchanneldeleted(message.channel_deleted_event);
4851
- } else if (message.clan_deleted_envet) {
4852
- this.onclandeleted(message.clan_deleted_envet);
4880
+ } else if (message.clan_deleted_event) {
4881
+ this.onclandeleted(message.clan_deleted_event);
4882
+ } else if (message.sticker_create_event) {
4883
+ this.onstickercreated(message.sticker_create_event);
4884
+ } else if (message.sticker_update_event) {
4885
+ this.onstickerupdated(message.sticker_update_event);
4886
+ } else if (message.sticker_delete_event) {
4887
+ this.onstickerdeleted(message.sticker_delete_event);
4853
4888
  } else if (message.channel_updated_event) {
4854
4889
  this.onchannelupdated(message.channel_updated_event);
4855
4890
  } else if (message.clan_profile_updated_event) {
@@ -4933,6 +4968,8 @@ var _DefaultSocket = class _DefaultSocket {
4933
4968
  this.onuserclanremoved(message.user_clan_removed_event);
4934
4969
  } else if (message.clan_event_created) {
4935
4970
  this.oneventcreated(message.clan_event_created);
4971
+ } else if (message.give_coffee_event) {
4972
+ this.oncoffeegiven(message.give_coffee_event);
4936
4973
  } else {
4937
4974
  if (this.verbose && window && window.console) {
4938
4975
  console.log("Unrecognized message received: %o", message);
@@ -5090,6 +5127,21 @@ var _DefaultSocket = class _DefaultSocket {
5090
5127
  console.log(clanDeleted);
5091
5128
  }
5092
5129
  }
5130
+ onstickercreated(stickerCreated) {
5131
+ if (this.verbose && window && window.console) {
5132
+ console.log(stickerCreated);
5133
+ }
5134
+ }
5135
+ onstickerdeleted(stickerDeleted) {
5136
+ if (this.verbose && window && window.console) {
5137
+ console.log(stickerDeleted);
5138
+ }
5139
+ }
5140
+ onstickerupdated(stickerUpdated) {
5141
+ if (this.verbose && window && window.console) {
5142
+ console.log(stickerUpdated);
5143
+ }
5144
+ }
5093
5145
  onchannelupdated(channelUpdated) {
5094
5146
  if (this.verbose && window && window.console) {
5095
5147
  console.log(channelUpdated);
@@ -5130,6 +5182,11 @@ var _DefaultSocket = class _DefaultSocket {
5130
5182
  console.log(clan_event_created);
5131
5183
  }
5132
5184
  }
5185
+ oncoffeegiven(give_coffee_event) {
5186
+ if (this.verbose && window && window.console) {
5187
+ console.log(give_coffee_event);
5188
+ }
5189
+ }
5133
5190
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
5134
5191
  const untypedMessage = message;
5135
5192
  return new Promise((resolve, reject) => {
@@ -5303,13 +5360,13 @@ var _DefaultSocket = class _DefaultSocket {
5303
5360
  return response.role_list_event;
5304
5361
  });
5305
5362
  }
5306
- ListChannelByUserId() {
5363
+ listChannelByUserId() {
5307
5364
  return __async(this, null, function* () {
5308
5365
  const response = yield this.send({ channel_desc_list_event: {} });
5309
5366
  return response.channel_desc_list_event;
5310
5367
  });
5311
5368
  }
5312
- ListUserClansByUserId() {
5369
+ listUserClansByUserId() {
5313
5370
  return __async(this, null, function* () {
5314
5371
  const response = yield this.send({ all_user_clans: {} });
5315
5372
  return response.all_user_clans;
@@ -5321,7 +5378,7 @@ var _DefaultSocket = class _DefaultSocket {
5321
5378
  return response.hashtag_dm_list_event;
5322
5379
  });
5323
5380
  }
5324
- GetPermissionByRoleIdChannelId(role_id, channel_id) {
5381
+ getPermissionByRoleIdChannelId(role_id, channel_id) {
5325
5382
  return __async(this, null, function* () {
5326
5383
  const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
5327
5384
  return response.permission_role_channel_list_event;
@@ -5363,18 +5420,6 @@ var _DefaultSocket = class _DefaultSocket {
5363
5420
  return response.notification_channel_category_setting_event;
5364
5421
  });
5365
5422
  }
5366
- addUserEmojiUsage(add_user_emoji_usage_event) {
5367
- return __async(this, null, function* () {
5368
- const response = yield this.send({ add_user_emoji_usage_event: { add_user_emoji_usage_event } });
5369
- return response.add_user_emoji_usage_event;
5370
- });
5371
- }
5372
- getUserEmojiUsage(clanId) {
5373
- return __async(this, null, function* () {
5374
- const response = yield this.send({ get_user_emoji_usage_event: { clanId } });
5375
- return response.get_user_emoji_usage_event;
5376
- });
5377
- }
5378
5423
  pingPong() {
5379
5424
  return __async(this, null, function* () {
5380
5425
  if (!this.adapter.isOpen()) {
@@ -7217,6 +7262,16 @@ var Client = class {
7217
7262
  });
7218
7263
  });
7219
7264
  }
7265
+ givecoffee(session, request) {
7266
+ return __async(this, null, function* () {
7267
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7268
+ yield this.sessionRefresh(session);
7269
+ }
7270
+ return this.apiClient.giveMeACoffee(session.token, request).then((response) => {
7271
+ return response !== void 0;
7272
+ });
7273
+ });
7274
+ }
7220
7275
  };
7221
7276
  export {
7222
7277
  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 { ApiChannelMessageHeader, ApiCreateEventRequest, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiPermissionList, ApiRoleList, ApiRpc, ApiUser } from "./api.gen";
16
+ import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiPermissionList, 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";
@@ -310,6 +310,25 @@ export interface ChannelDeletedEvent {
310
310
  channel_id: string;
311
311
  deletor: string;
312
312
  }
313
+ export interface StickerCreateEvent {
314
+ clan_id: string;
315
+ source: string;
316
+ shortname: string;
317
+ category: string;
318
+ creator_id: string;
319
+ sticker_id: string;
320
+ logo: string;
321
+ clan_name: string;
322
+ }
323
+ export interface StickerUpdateEvent {
324
+ shortname: string;
325
+ sticker_id: string;
326
+ user_id: string;
327
+ }
328
+ export interface StickerDeleteEvent {
329
+ sticker_id: string;
330
+ user_id: string;
331
+ }
313
332
  export interface ClanDeletedEvent {
314
333
  clan_id: string;
315
334
  deletor: string;
@@ -629,6 +648,9 @@ export interface Socket {
629
648
  onvoiceleaved: (voiceParticipant: VoiceLeavedEvent) => void;
630
649
  onchannelcreated: (channelCreated: ChannelCreatedEvent) => void;
631
650
  onchanneldeleted: (channelDeleted: ChannelDeletedEvent) => void;
651
+ onstickercreated: (stickerCreated: StickerCreateEvent) => void;
652
+ onstickerupdated: (stickerUpdated: StickerUpdateEvent) => void;
653
+ onstickerdeleted: (stickerDeleted: StickerDeleteEvent) => void;
632
654
  onclandeleted: (clanDeleted: ClanDeletedEvent) => void;
633
655
  onchannelupdated: (channelUpdated: ChannelUpdatedEvent) => void;
634
656
  onclanprofileupdated: (clanprofile: ClanProfileUpdatedEvent) => void;
@@ -640,18 +662,17 @@ export interface Socket {
640
662
  listUserPermissionInChannel(clan_id: string, channel_id: string): Promise<UserPermissionInChannelListEvent>;
641
663
  listRoles(ClanId: string, Limit: number, State: number, Cursor: string): Promise<RoleListEvent>;
642
664
  listStickersByUserId(): Promise<StrickerListedEvent>;
643
- ListChannelByUserId(): Promise<ChannelDescListEvent>;
644
- ListUserClansByUserId(): Promise<AllUserClans>;
665
+ listChannelByUserId(): Promise<ChannelDescListEvent>;
666
+ listUserClansByUserId(): Promise<AllUserClans>;
645
667
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
646
668
  getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
647
669
  getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
648
670
  getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
649
671
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
650
- GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
672
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
651
673
  getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
652
674
  oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
653
- addUserEmojiUsage: (add_user_emoji_usage_event: AddUserEmojiUsageEvent) => void;
654
- getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent>;
675
+ oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
655
676
  }
656
677
  /** Reports an error received from a socket message. */
657
678
  export interface SocketError {
@@ -702,6 +723,9 @@ export declare class DefaultSocket implements Socket {
702
723
  onchannelcreated(channelCreated: ChannelCreatedEvent): void;
703
724
  onchanneldeleted(channelDeleted: ChannelDeletedEvent): void;
704
725
  onclandeleted(clanDeleted: ClanDeletedEvent): void;
726
+ onstickercreated(stickerCreated: StickerCreateEvent): void;
727
+ onstickerdeleted(stickerDeleted: StickerDeleteEvent): void;
728
+ onstickerupdated(stickerUpdated: StickerUpdateEvent): void;
705
729
  onchannelupdated(channelUpdated: ChannelUpdatedEvent): void;
706
730
  onclanprofileupdated(clanprofile: ClanProfileUpdatedEvent): void;
707
731
  onclanupdated(clan: ClanUpdatedEvent): void;
@@ -710,6 +734,7 @@ export declare class DefaultSocket implements Socket {
710
734
  onheartbeattimeout(): void;
711
735
  oncustomstatus(statusEvent: CustomStatusEvent): void;
712
736
  oneventcreated(clan_event_created: ApiCreateEventRequest): void;
737
+ oncoffeegiven(give_coffee_event: ApiGiveCoffeeEvent): void;
713
738
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
714
739
  followUsers(userIds: string[]): Promise<Status>;
715
740
  joinClanChat(clan_id: string): Promise<ClanJoin>;
@@ -732,18 +757,16 @@ export declare class DefaultSocket implements Socket {
732
757
  listClanEmojiByClanId(clan_id: string): Promise<EmojiListedEvent>;
733
758
  listUserPermissionInChannel(clan_id: string, channel_id: string): Promise<UserPermissionInChannelListEvent>;
734
759
  listRoles(ClanId: string, Limit: number, State: number, Cursor: string): Promise<RoleListEvent>;
735
- ListChannelByUserId(): Promise<ChannelDescListEvent>;
736
- ListUserClansByUserId(): Promise<AllUserClans>;
760
+ listChannelByUserId(): Promise<ChannelDescListEvent>;
761
+ listUserClansByUserId(): Promise<AllUserClans>;
737
762
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
738
- GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
763
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
739
764
  listStickersByUserId(): Promise<StrickerListedEvent>;
740
765
  getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
741
766
  getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
742
767
  getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
743
768
  getNotificationReactMessage(channel_id: string): Promise<NotifiReactMessageEvent>;
744
769
  getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
745
- addUserEmojiUsage(add_user_emoji_usage_event: AddUserEmojiUsageEvent): Promise<any>;
746
- getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent>;
747
770
  private pingPong;
748
771
  }
749
772
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.8.88",
4
+ "version": "2.8.91",
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 { ApiChannelMessageHeader, ApiCreateEventRequest, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiPermissionList, ApiRoleList, ApiRpc, ApiUser} from "./api.gen";
17
+ import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiPermissionList, 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"
@@ -456,6 +456,41 @@ export interface ChannelDeletedEvent {
456
456
  deletor: string;
457
457
  }
458
458
 
459
+ export interface StickerCreateEvent {
460
+ // clan id
461
+ clan_id: string;
462
+ // source
463
+ source: string;
464
+ // shortname
465
+ shortname: string;
466
+ // category
467
+ category: string;
468
+ // creator_id
469
+ creator_id: string;
470
+ // sticker id
471
+ sticker_id: string;
472
+ // logo
473
+ logo: string;
474
+ // clan name
475
+ clan_name: string
476
+ }
477
+
478
+ export interface StickerUpdateEvent {
479
+ // shortname
480
+ shortname: string;
481
+ // sticker id
482
+ sticker_id: string;
483
+ // user id update
484
+ user_id: string;
485
+ }
486
+
487
+ export interface StickerDeleteEvent {
488
+ // sticker id
489
+ sticker_id: string;
490
+ // user id delete
491
+ user_id: string;
492
+ }
493
+
459
494
  export interface ClanDeletedEvent {
460
495
  // clan id
461
496
  clan_id: string;
@@ -945,6 +980,15 @@ export interface Socket {
945
980
  // when channel is deleted
946
981
  onchanneldeleted: (channelDeleted: ChannelDeletedEvent) => void;
947
982
 
983
+ // when sticker is created
984
+ onstickercreated: (stickerCreated: StickerCreateEvent) => void;
985
+
986
+ // when sticker is updated
987
+ onstickerupdated: (stickerUpdated: StickerUpdateEvent) => void;
988
+
989
+ // when sticker is deleted
990
+ onstickerdeleted: (stickerDeleted: StickerDeleteEvent) => void;
991
+
948
992
  // when clan is deleted
949
993
  onclandeleted: (clanDeleted: ClanDeletedEvent) => void;
950
994
 
@@ -973,9 +1017,9 @@ export interface Socket {
973
1017
 
974
1018
  listStickersByUserId(): Promise<StrickerListedEvent>;
975
1019
 
976
- ListChannelByUserId(): Promise<ChannelDescListEvent>;
1020
+ listChannelByUserId(): Promise<ChannelDescListEvent>;
977
1021
 
978
- ListUserClansByUserId(): Promise<AllUserClans>;
1022
+ listUserClansByUserId(): Promise<AllUserClans>;
979
1023
 
980
1024
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
981
1025
 
@@ -987,15 +1031,13 @@ export interface Socket {
987
1031
 
988
1032
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
989
1033
 
990
- GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
1034
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
991
1035
 
992
1036
  getNotificationChannelCategorySetting(clan_id : string): Promise<NotificationChannelCategorySettingEvent>;
993
1037
 
994
1038
  oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
995
1039
 
996
- addUserEmojiUsage: (add_user_emoji_usage_event: AddUserEmojiUsageEvent) => void;
997
-
998
- getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent>
1040
+ oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
999
1041
 
1000
1042
  }
1001
1043
 
@@ -1080,8 +1122,14 @@ export class DefaultSocket implements Socket {
1080
1122
  this.onchannelcreated(message.channel_created_event)
1081
1123
  } else if (message.channel_deleted_event) {
1082
1124
  this.onchanneldeleted(message.channel_deleted_event)
1083
- } else if (message.clan_deleted_envet) {
1084
- this.onclandeleted(message.clan_deleted_envet)
1125
+ } else if (message.clan_deleted_event) {
1126
+ this.onclandeleted(message.clan_deleted_event)
1127
+ } else if (message.sticker_create_event) {
1128
+ this.onstickercreated(message.sticker_create_event)
1129
+ } else if (message.sticker_update_event) {
1130
+ this.onstickerupdated(message.sticker_update_event)
1131
+ } else if (message.sticker_delete_event) {
1132
+ this.onstickerdeleted(message.sticker_delete_event)
1085
1133
  } else if (message.channel_updated_event) {
1086
1134
  this.onchannelupdated(message.channel_updated_event)
1087
1135
  } else if (message.clan_profile_updated_event) {
@@ -1170,7 +1218,9 @@ export class DefaultSocket implements Socket {
1170
1218
  this.onuserclanremoved(<UserClanRemovedEvent>message.user_clan_removed_event);
1171
1219
  } else if(message.clan_event_created){
1172
1220
  this.oneventcreated(message.clan_event_created);
1173
- }else {
1221
+ } else if(message.give_coffee_event){
1222
+ this.oncoffeegiven(<ApiGiveCoffeeEvent>message.give_coffee_event);
1223
+ } else {
1174
1224
  if (this.verbose && window && window.console) {
1175
1225
  console.log("Unrecognized message received: %o", message);
1176
1226
  }
@@ -1357,6 +1407,25 @@ export class DefaultSocket implements Socket {
1357
1407
  }
1358
1408
  }
1359
1409
 
1410
+ onstickercreated(stickerCreated: StickerCreateEvent) {
1411
+ if (this.verbose && window && window.console) {
1412
+ console.log(stickerCreated);
1413
+ }
1414
+ }
1415
+
1416
+ onstickerdeleted(stickerDeleted: StickerDeleteEvent) {
1417
+ if (this.verbose && window && window.console) {
1418
+ console.log(stickerDeleted);
1419
+ }
1420
+ }
1421
+
1422
+ onstickerupdated(stickerUpdated: StickerUpdateEvent) {
1423
+ if (this.verbose && window && window.console) {
1424
+ console.log(stickerUpdated);
1425
+ }
1426
+ }
1427
+
1428
+
1360
1429
  onchannelupdated(channelUpdated: ChannelUpdatedEvent) {
1361
1430
  if (this.verbose && window && window.console) {
1362
1431
  console.log(channelUpdated);
@@ -1404,6 +1473,12 @@ export class DefaultSocket implements Socket {
1404
1473
  console.log(clan_event_created);
1405
1474
  }
1406
1475
  }
1476
+
1477
+ oncoffeegiven(give_coffee_event: ApiGiveCoffeeEvent) {
1478
+ if (this.verbose && window && window.console) {
1479
+ console.log(give_coffee_event);
1480
+ }
1481
+ }
1407
1482
 
1408
1483
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent |
1409
1484
  ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout = DefaultSocket.DefaultSendTimeoutMs): Promise<any> {
@@ -1574,12 +1649,12 @@ export class DefaultSocket implements Socket {
1574
1649
  return response.role_list_event
1575
1650
  }
1576
1651
 
1577
- async ListChannelByUserId(): Promise<ChannelDescListEvent> {
1652
+ async listChannelByUserId(): Promise<ChannelDescListEvent> {
1578
1653
  const response = await this.send({channel_desc_list_event: {}});
1579
1654
  return response.channel_desc_list_event
1580
1655
  }
1581
1656
 
1582
- async ListUserClansByUserId(): Promise<AllUserClans> {
1657
+ async listUserClansByUserId(): Promise<AllUserClans> {
1583
1658
  const response = await this.send({all_user_clans: {}});
1584
1659
  return response.all_user_clans
1585
1660
  }
@@ -1589,7 +1664,7 @@ export class DefaultSocket implements Socket {
1589
1664
  return response.hashtag_dm_list_event
1590
1665
  }
1591
1666
 
1592
- async GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
1667
+ async getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
1593
1668
  const response = await this.send({permission_role_channel_list_event: {role_id: role_id, channel_id: channel_id }});
1594
1669
  return response.permission_role_channel_list_event
1595
1670
  }
@@ -1624,16 +1699,6 @@ export class DefaultSocket implements Socket {
1624
1699
  return response.notification_channel_category_setting_event
1625
1700
  }
1626
1701
 
1627
- async addUserEmojiUsage(add_user_emoji_usage_event: AddUserEmojiUsageEvent) {
1628
- const response = await this.send({add_user_emoji_usage_event: {add_user_emoji_usage_event: add_user_emoji_usage_event}})
1629
- return response.add_user_emoji_usage_event
1630
- }
1631
-
1632
- async getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent> {
1633
- const response = await this.send({get_user_emoji_usage_event: {clanId: clanId}})
1634
- return response.get_user_emoji_usage_event
1635
- }
1636
-
1637
1702
  private async pingPong(): Promise<void> {
1638
1703
  if (!this.adapter.isOpen()) {
1639
1704
  return;