mezon-js 2.8.87 → 2.8.89

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
@@ -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,6 +4906,8 @@ 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);
4909
+ } else if (message.clan_deleted_envet) {
4910
+ this.onclandeleted(message.clan_deleted_envet);
4880
4911
  } else if (message.channel_updated_event) {
4881
4912
  this.onchannelupdated(message.channel_updated_event);
4882
4913
  } else if (message.clan_profile_updated_event) {
@@ -4960,6 +4991,8 @@ var _DefaultSocket = class _DefaultSocket {
4960
4991
  this.onuserclanremoved(message.user_clan_removed_event);
4961
4992
  } else if (message.clan_event_created) {
4962
4993
  this.oneventcreated(message.clan_event_created);
4994
+ } else if (message.give_coffee_event) {
4995
+ this.oncoffeegiven(message.give_coffee_event);
4963
4996
  } else {
4964
4997
  if (this.verbose && window && window.console) {
4965
4998
  console.log("Unrecognized message received: %o", message);
@@ -5112,6 +5145,11 @@ var _DefaultSocket = class _DefaultSocket {
5112
5145
  console.log(channelDeleted);
5113
5146
  }
5114
5147
  }
5148
+ onclandeleted(clanDeleted) {
5149
+ if (this.verbose && window && window.console) {
5150
+ console.log(clanDeleted);
5151
+ }
5152
+ }
5115
5153
  onchannelupdated(channelUpdated) {
5116
5154
  if (this.verbose && window && window.console) {
5117
5155
  console.log(channelUpdated);
@@ -5152,6 +5190,11 @@ var _DefaultSocket = class _DefaultSocket {
5152
5190
  console.log(clan_event_created);
5153
5191
  }
5154
5192
  }
5193
+ oncoffeegiven(give_coffee_event) {
5194
+ if (this.verbose && window && window.console) {
5195
+ console.log(give_coffee_event);
5196
+ }
5197
+ }
5155
5198
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
5156
5199
  const untypedMessage = message;
5157
5200
  return new Promise((resolve, reject) => {
@@ -5325,13 +5368,13 @@ var _DefaultSocket = class _DefaultSocket {
5325
5368
  return response.role_list_event;
5326
5369
  });
5327
5370
  }
5328
- ListChannelByUserId() {
5371
+ listChannelByUserId() {
5329
5372
  return __async(this, null, function* () {
5330
5373
  const response = yield this.send({ channel_desc_list_event: {} });
5331
5374
  return response.channel_desc_list_event;
5332
5375
  });
5333
5376
  }
5334
- ListUserClansByUserId() {
5377
+ listUserClansByUserId() {
5335
5378
  return __async(this, null, function* () {
5336
5379
  const response = yield this.send({ all_user_clans: {} });
5337
5380
  return response.all_user_clans;
@@ -5343,7 +5386,7 @@ var _DefaultSocket = class _DefaultSocket {
5343
5386
  return response.hashtag_dm_list_event;
5344
5387
  });
5345
5388
  }
5346
- GetPermissionByRoleIdChannelId(role_id, channel_id) {
5389
+ getPermissionByRoleIdChannelId(role_id, channel_id) {
5347
5390
  return __async(this, null, function* () {
5348
5391
  const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
5349
5392
  return response.permission_role_channel_list_event;
@@ -5385,18 +5428,6 @@ var _DefaultSocket = class _DefaultSocket {
5385
5428
  return response.notification_channel_category_setting_event;
5386
5429
  });
5387
5430
  }
5388
- addUserEmojiUsage(add_user_emoji_usage_event) {
5389
- return __async(this, null, function* () {
5390
- const response = yield this.send({ add_user_emoji_usage_event: { add_user_emoji_usage_event } });
5391
- return response.add_user_emoji_usage_event;
5392
- });
5393
- }
5394
- getUserEmojiUsage(clanId) {
5395
- return __async(this, null, function* () {
5396
- const response = yield this.send({ get_user_emoji_usage_event: { clanId } });
5397
- return response.get_user_emoji_usage_event;
5398
- });
5399
- }
5400
5431
  pingPong() {
5401
5432
  return __async(this, null, function* () {
5402
5433
  if (!this.adapter.isOpen()) {
@@ -7239,4 +7270,14 @@ var Client = class {
7239
7270
  });
7240
7271
  });
7241
7272
  }
7273
+ givecoffee(session, request) {
7274
+ return __async(this, null, function* () {
7275
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7276
+ yield this.sessionRefresh(session);
7277
+ }
7278
+ return this.apiClient.giveMeACoffee(session.token, request).then((response) => {
7279
+ return response !== void 0;
7280
+ });
7281
+ });
7282
+ }
7242
7283
  };
@@ -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,6 +4877,8 @@ 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);
4880
+ } else if (message.clan_deleted_envet) {
4881
+ this.onclandeleted(message.clan_deleted_envet);
4851
4882
  } else if (message.channel_updated_event) {
4852
4883
  this.onchannelupdated(message.channel_updated_event);
4853
4884
  } else if (message.clan_profile_updated_event) {
@@ -4931,6 +4962,8 @@ var _DefaultSocket = class _DefaultSocket {
4931
4962
  this.onuserclanremoved(message.user_clan_removed_event);
4932
4963
  } else if (message.clan_event_created) {
4933
4964
  this.oneventcreated(message.clan_event_created);
4965
+ } else if (message.give_coffee_event) {
4966
+ this.oncoffeegiven(message.give_coffee_event);
4934
4967
  } else {
4935
4968
  if (this.verbose && window && window.console) {
4936
4969
  console.log("Unrecognized message received: %o", message);
@@ -5083,6 +5116,11 @@ var _DefaultSocket = class _DefaultSocket {
5083
5116
  console.log(channelDeleted);
5084
5117
  }
5085
5118
  }
5119
+ onclandeleted(clanDeleted) {
5120
+ if (this.verbose && window && window.console) {
5121
+ console.log(clanDeleted);
5122
+ }
5123
+ }
5086
5124
  onchannelupdated(channelUpdated) {
5087
5125
  if (this.verbose && window && window.console) {
5088
5126
  console.log(channelUpdated);
@@ -5123,6 +5161,11 @@ var _DefaultSocket = class _DefaultSocket {
5123
5161
  console.log(clan_event_created);
5124
5162
  }
5125
5163
  }
5164
+ oncoffeegiven(give_coffee_event) {
5165
+ if (this.verbose && window && window.console) {
5166
+ console.log(give_coffee_event);
5167
+ }
5168
+ }
5126
5169
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
5127
5170
  const untypedMessage = message;
5128
5171
  return new Promise((resolve, reject) => {
@@ -5296,13 +5339,13 @@ var _DefaultSocket = class _DefaultSocket {
5296
5339
  return response.role_list_event;
5297
5340
  });
5298
5341
  }
5299
- ListChannelByUserId() {
5342
+ listChannelByUserId() {
5300
5343
  return __async(this, null, function* () {
5301
5344
  const response = yield this.send({ channel_desc_list_event: {} });
5302
5345
  return response.channel_desc_list_event;
5303
5346
  });
5304
5347
  }
5305
- ListUserClansByUserId() {
5348
+ listUserClansByUserId() {
5306
5349
  return __async(this, null, function* () {
5307
5350
  const response = yield this.send({ all_user_clans: {} });
5308
5351
  return response.all_user_clans;
@@ -5314,7 +5357,7 @@ var _DefaultSocket = class _DefaultSocket {
5314
5357
  return response.hashtag_dm_list_event;
5315
5358
  });
5316
5359
  }
5317
- GetPermissionByRoleIdChannelId(role_id, channel_id) {
5360
+ getPermissionByRoleIdChannelId(role_id, channel_id) {
5318
5361
  return __async(this, null, function* () {
5319
5362
  const response = yield this.send({ permission_role_channel_list_event: { role_id, channel_id } });
5320
5363
  return response.permission_role_channel_list_event;
@@ -5356,18 +5399,6 @@ var _DefaultSocket = class _DefaultSocket {
5356
5399
  return response.notification_channel_category_setting_event;
5357
5400
  });
5358
5401
  }
5359
- addUserEmojiUsage(add_user_emoji_usage_event) {
5360
- return __async(this, null, function* () {
5361
- const response = yield this.send({ add_user_emoji_usage_event: { add_user_emoji_usage_event } });
5362
- return response.add_user_emoji_usage_event;
5363
- });
5364
- }
5365
- getUserEmojiUsage(clanId) {
5366
- return __async(this, null, function* () {
5367
- const response = yield this.send({ get_user_emoji_usage_event: { clanId } });
5368
- return response.get_user_emoji_usage_event;
5369
- });
5370
- }
5371
5402
  pingPong() {
5372
5403
  return __async(this, null, function* () {
5373
5404
  if (!this.adapter.isOpen()) {
@@ -7210,6 +7241,16 @@ var Client = class {
7210
7241
  });
7211
7242
  });
7212
7243
  }
7244
+ givecoffee(session, request) {
7245
+ return __async(this, null, function* () {
7246
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
7247
+ yield this.sessionRefresh(session);
7248
+ }
7249
+ return this.apiClient.giveMeACoffee(session.token, request).then((response) => {
7250
+ return response !== void 0;
7251
+ });
7252
+ });
7253
+ }
7213
7254
  };
7214
7255
  export {
7215
7256
  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,10 @@ export interface ChannelDeletedEvent {
310
310
  channel_id: string;
311
311
  deletor: string;
312
312
  }
313
+ export interface ClanDeletedEvent {
314
+ clan_id: string;
315
+ deletor: string;
316
+ }
313
317
  export interface PermissionRoleChannelListEvent {
314
318
  role_id?: string;
315
319
  channel_id?: string;
@@ -625,6 +629,7 @@ export interface Socket {
625
629
  onvoiceleaved: (voiceParticipant: VoiceLeavedEvent) => void;
626
630
  onchannelcreated: (channelCreated: ChannelCreatedEvent) => void;
627
631
  onchanneldeleted: (channelDeleted: ChannelDeletedEvent) => void;
632
+ onclandeleted: (clanDeleted: ClanDeletedEvent) => void;
628
633
  onchannelupdated: (channelUpdated: ChannelUpdatedEvent) => void;
629
634
  onclanprofileupdated: (clanprofile: ClanProfileUpdatedEvent) => void;
630
635
  onclanupdated: (clan: ClanUpdatedEvent) => void;
@@ -635,18 +640,17 @@ export interface Socket {
635
640
  listUserPermissionInChannel(clan_id: string, channel_id: string): Promise<UserPermissionInChannelListEvent>;
636
641
  listRoles(ClanId: string, Limit: number, State: number, Cursor: string): Promise<RoleListEvent>;
637
642
  listStickersByUserId(): Promise<StrickerListedEvent>;
638
- ListChannelByUserId(): Promise<ChannelDescListEvent>;
639
- ListUserClansByUserId(): Promise<AllUserClans>;
643
+ listChannelByUserId(): Promise<ChannelDescListEvent>;
644
+ listUserClansByUserId(): Promise<AllUserClans>;
640
645
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
641
646
  getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
642
647
  getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
643
648
  getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
644
649
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
645
- GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
650
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
646
651
  getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
647
652
  oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
648
- addUserEmojiUsage: (add_user_emoji_usage_event: AddUserEmojiUsageEvent) => void;
649
- getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent>;
653
+ oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
650
654
  }
651
655
  /** Reports an error received from a socket message. */
652
656
  export interface SocketError {
@@ -696,6 +700,7 @@ export declare class DefaultSocket implements Socket {
696
700
  onvoiceleaved(voiceParticipant: VoiceLeavedEvent): void;
697
701
  onchannelcreated(channelCreated: ChannelCreatedEvent): void;
698
702
  onchanneldeleted(channelDeleted: ChannelDeletedEvent): void;
703
+ onclandeleted(clanDeleted: ClanDeletedEvent): void;
699
704
  onchannelupdated(channelUpdated: ChannelUpdatedEvent): void;
700
705
  onclanprofileupdated(clanprofile: ClanProfileUpdatedEvent): void;
701
706
  onclanupdated(clan: ClanUpdatedEvent): void;
@@ -704,6 +709,7 @@ export declare class DefaultSocket implements Socket {
704
709
  onheartbeattimeout(): void;
705
710
  oncustomstatus(statusEvent: CustomStatusEvent): void;
706
711
  oneventcreated(clan_event_created: ApiCreateEventRequest): void;
712
+ oncoffeegiven(give_coffee_event: ApiGiveCoffeeEvent): void;
707
713
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
708
714
  followUsers(userIds: string[]): Promise<Status>;
709
715
  joinClanChat(clan_id: string): Promise<ClanJoin>;
@@ -726,18 +732,16 @@ export declare class DefaultSocket implements Socket {
726
732
  listClanEmojiByClanId(clan_id: string): Promise<EmojiListedEvent>;
727
733
  listUserPermissionInChannel(clan_id: string, channel_id: string): Promise<UserPermissionInChannelListEvent>;
728
734
  listRoles(ClanId: string, Limit: number, State: number, Cursor: string): Promise<RoleListEvent>;
729
- ListChannelByUserId(): Promise<ChannelDescListEvent>;
730
- ListUserClansByUserId(): Promise<AllUserClans>;
735
+ listChannelByUserId(): Promise<ChannelDescListEvent>;
736
+ listUserClansByUserId(): Promise<AllUserClans>;
731
737
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
732
- GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
738
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
733
739
  listStickersByUserId(): Promise<StrickerListedEvent>;
734
740
  getNotificationChannelSetting(channel_id: string): Promise<NotificationChannelSettingEvent>;
735
741
  getNotificationCategorySetting(category_id: string): Promise<NotificationCategorySettingEvent>;
736
742
  getNotificationClanSetting(clan_id: string): Promise<NotificationClanSettingEvent>;
737
743
  getNotificationReactMessage(channel_id: string): Promise<NotifiReactMessageEvent>;
738
744
  getNotificationChannelCategorySetting(clan_id: string): Promise<NotificationChannelCategorySettingEvent>;
739
- addUserEmojiUsage(add_user_emoji_usage_event: AddUserEmojiUsageEvent): Promise<any>;
740
- getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent>;
741
745
  private pingPong;
742
746
  }
743
747
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.8.87",
4
+ "version": "2.8.89",
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,13 @@ export interface ChannelDeletedEvent {
456
456
  deletor: string;
457
457
  }
458
458
 
459
+ export interface ClanDeletedEvent {
460
+ // clan id
461
+ clan_id: string;
462
+ // deletor
463
+ deletor: string;
464
+ }
465
+
459
466
  // A list of permission role channel.
460
467
  export interface PermissionRoleChannelListEvent {
461
468
  //
@@ -938,6 +945,9 @@ export interface Socket {
938
945
  // when channel is deleted
939
946
  onchanneldeleted: (channelDeleted: ChannelDeletedEvent) => void;
940
947
 
948
+ // when clan is deleted
949
+ onclandeleted: (clanDeleted: ClanDeletedEvent) => void;
950
+
941
951
  // when channel is updated
942
952
  onchannelupdated: (channelUpdated: ChannelUpdatedEvent) => void;
943
953
 
@@ -963,9 +973,9 @@ export interface Socket {
963
973
 
964
974
  listStickersByUserId(): Promise<StrickerListedEvent>;
965
975
 
966
- ListChannelByUserId(): Promise<ChannelDescListEvent>;
976
+ listChannelByUserId(): Promise<ChannelDescListEvent>;
967
977
 
968
- ListUserClansByUserId(): Promise<AllUserClans>;
978
+ listUserClansByUserId(): Promise<AllUserClans>;
969
979
 
970
980
  hashtagDMList(user_id: Array<string>, limit: number): Promise<HashtagDmListEvent>;
971
981
 
@@ -977,15 +987,13 @@ export interface Socket {
977
987
 
978
988
  getNotificationReactMessage(channel_id_req: string): Promise<NotifiReactMessageEvent>;
979
989
 
980
- GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
990
+ getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent>;
981
991
 
982
992
  getNotificationChannelCategorySetting(clan_id : string): Promise<NotificationChannelCategorySettingEvent>;
983
993
 
984
994
  oneventcreated: (clan_event_created: ApiCreateEventRequest) => void;
985
995
 
986
- addUserEmojiUsage: (add_user_emoji_usage_event: AddUserEmojiUsageEvent) => void;
987
-
988
- getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent>
996
+ oncoffeegiven: (give_coffee_event: ApiGiveCoffeeEvent) => void;
989
997
 
990
998
  }
991
999
 
@@ -1070,6 +1078,8 @@ export class DefaultSocket implements Socket {
1070
1078
  this.onchannelcreated(message.channel_created_event)
1071
1079
  } else if (message.channel_deleted_event) {
1072
1080
  this.onchanneldeleted(message.channel_deleted_event)
1081
+ } else if (message.clan_deleted_envet) {
1082
+ this.onclandeleted(message.clan_deleted_envet)
1073
1083
  } else if (message.channel_updated_event) {
1074
1084
  this.onchannelupdated(message.channel_updated_event)
1075
1085
  } else if (message.clan_profile_updated_event) {
@@ -1158,7 +1168,9 @@ export class DefaultSocket implements Socket {
1158
1168
  this.onuserclanremoved(<UserClanRemovedEvent>message.user_clan_removed_event);
1159
1169
  } else if(message.clan_event_created){
1160
1170
  this.oneventcreated(message.clan_event_created);
1161
- }else {
1171
+ } else if(message.give_coffee_event){
1172
+ this.oncoffeegiven(<ApiGiveCoffeeEvent>message.give_coffee_event);
1173
+ } else {
1162
1174
  if (this.verbose && window && window.console) {
1163
1175
  console.log("Unrecognized message received: %o", message);
1164
1176
  }
@@ -1339,6 +1351,12 @@ export class DefaultSocket implements Socket {
1339
1351
  }
1340
1352
  }
1341
1353
 
1354
+ onclandeleted(clanDeleted: ClanDeletedEvent) {
1355
+ if (this.verbose && window && window.console) {
1356
+ console.log(clanDeleted);
1357
+ }
1358
+ }
1359
+
1342
1360
  onchannelupdated(channelUpdated: ChannelUpdatedEvent) {
1343
1361
  if (this.verbose && window && window.console) {
1344
1362
  console.log(channelUpdated);
@@ -1386,6 +1404,12 @@ export class DefaultSocket implements Socket {
1386
1404
  console.log(clan_event_created);
1387
1405
  }
1388
1406
  }
1407
+
1408
+ oncoffeegiven(give_coffee_event: ApiGiveCoffeeEvent) {
1409
+ if (this.verbose && window && window.console) {
1410
+ console.log(give_coffee_event);
1411
+ }
1412
+ }
1389
1413
 
1390
1414
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent |
1391
1415
  ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout = DefaultSocket.DefaultSendTimeoutMs): Promise<any> {
@@ -1556,12 +1580,12 @@ export class DefaultSocket implements Socket {
1556
1580
  return response.role_list_event
1557
1581
  }
1558
1582
 
1559
- async ListChannelByUserId(): Promise<ChannelDescListEvent> {
1583
+ async listChannelByUserId(): Promise<ChannelDescListEvent> {
1560
1584
  const response = await this.send({channel_desc_list_event: {}});
1561
1585
  return response.channel_desc_list_event
1562
1586
  }
1563
1587
 
1564
- async ListUserClansByUserId(): Promise<AllUserClans> {
1588
+ async listUserClansByUserId(): Promise<AllUserClans> {
1565
1589
  const response = await this.send({all_user_clans: {}});
1566
1590
  return response.all_user_clans
1567
1591
  }
@@ -1571,7 +1595,7 @@ export class DefaultSocket implements Socket {
1571
1595
  return response.hashtag_dm_list_event
1572
1596
  }
1573
1597
 
1574
- async GetPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
1598
+ async getPermissionByRoleIdChannelId(role_id: string, channel_id: string): Promise<PermissionRoleChannelListEvent> {
1575
1599
  const response = await this.send({permission_role_channel_list_event: {role_id: role_id, channel_id: channel_id }});
1576
1600
  return response.permission_role_channel_list_event
1577
1601
  }
@@ -1606,16 +1630,6 @@ export class DefaultSocket implements Socket {
1606
1630
  return response.notification_channel_category_setting_event
1607
1631
  }
1608
1632
 
1609
- async addUserEmojiUsage(add_user_emoji_usage_event: AddUserEmojiUsageEvent) {
1610
- const response = await this.send({add_user_emoji_usage_event: {add_user_emoji_usage_event: add_user_emoji_usage_event}})
1611
- return response.add_user_emoji_usage_event
1612
- }
1613
-
1614
- async getUserEmojiUsage(clanId: string): Promise<GetUserEmojiUsageEvent> {
1615
- const response = await this.send({get_user_emoji_usage_event: {clanId: clanId}})
1616
- return response.get_user_emoji_usage_event
1617
- }
1618
-
1619
1633
  private async pingPong(): Promise<void> {
1620
1634
  if (!this.adapter.isOpen()) {
1621
1635
  return;