mezon-js 2.7.71 → 2.7.73

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -484,16 +484,6 @@ export interface ApiClanDescProfile {
484
484
  profile_theme?: string;
485
485
  }
486
486
 
487
- /** */
488
- export interface ApiClanEmoji {
489
- //
490
- category?: string;
491
- //
492
- shortname?: string;
493
- //
494
- src?: string;
495
- }
496
-
497
487
  /** */
498
488
  export interface ApiClanEmojiCreateRequest {
499
489
  //
@@ -509,7 +499,21 @@ export interface ApiClanEmojiCreateRequest {
509
499
  /** */
510
500
  export interface ApiClanEmojiList {
511
501
  //
512
- emoji_list?: Array<ApiClanEmoji>;
502
+ emoji_list?: Array<ApiClanEmojiListResponse>;
503
+ }
504
+
505
+ /** */
506
+ export interface ApiClanEmojiListResponse {
507
+ //
508
+ category?: string;
509
+ //
510
+ creator_id?: string;
511
+ //
512
+ id?: string;
513
+ //
514
+ shortname?: string;
515
+ //
516
+ src?: string;
513
517
  }
514
518
 
515
519
  /** Get clan profile. */
@@ -3704,38 +3708,7 @@ export class MezonApi {
3704
3708
  ]);
3705
3709
  }
3706
3710
 
3707
- /** Get permission list */
3708
- listClanEmoji(bearerToken: string,
3709
- options: any = {}): Promise<ApiClanEmojiList> {
3710
-
3711
- const urlPath = "/v2/emoji";
3712
- const queryParams = new Map<string, any>();
3713
-
3714
- let bodyJson : string = "";
3715
-
3716
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3717
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3718
- if (bearerToken) {
3719
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3720
- }
3721
-
3722
- return Promise.race([
3723
- fetch(fullUrl, fetchOptions).then((response) => {
3724
- if (response.status == 204) {
3725
- return response;
3726
- } else if (response.status >= 200 && response.status < 300) {
3727
- return response.json();
3728
- } else {
3729
- throw response;
3730
- }
3731
- }),
3732
- new Promise((_, reject) =>
3733
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3734
- ),
3735
- ]);
3736
- }
3737
-
3738
- /** Post permission Emoji /v2/emoji/create */
3711
+ /** Post clan Emoji /v2/emoji/create */
3739
3712
  createClanEmoji(bearerToken: string,
3740
3713
  body:ApiClanEmojiCreateRequest,
3741
3714
  options: any = {}): Promise<any> {
package/dist/api.gen.d.ts CHANGED
@@ -277,12 +277,6 @@ export interface ApiClanDescProfile {
277
277
  profile_theme?: string;
278
278
  }
279
279
  /** */
280
- export interface ApiClanEmoji {
281
- category?: string;
282
- shortname?: string;
283
- src?: string;
284
- }
285
- /** */
286
280
  export interface ApiClanEmojiCreateRequest {
287
281
  category?: string;
288
282
  clan_id?: string;
@@ -291,7 +285,15 @@ export interface ApiClanEmojiCreateRequest {
291
285
  }
292
286
  /** */
293
287
  export interface ApiClanEmojiList {
294
- emoji_list?: Array<ApiClanEmoji>;
288
+ emoji_list?: Array<ApiClanEmojiListResponse>;
289
+ }
290
+ /** */
291
+ export interface ApiClanEmojiListResponse {
292
+ category?: string;
293
+ creator_id?: string;
294
+ id?: string;
295
+ shortname?: string;
296
+ src?: string;
295
297
  }
296
298
  /** Get clan profile. */
297
299
  export interface ApiClanProfile {
@@ -976,9 +978,7 @@ export declare class MezonApi {
976
978
  closeDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
977
979
  /** open direct message. */
978
980
  openDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
979
- /** Get permission list */
980
- listClanEmoji(bearerToken: string, options?: any): Promise<ApiClanEmojiList>;
981
- /** Post permission Emoji /v2/emoji/create */
981
+ /** Post clan Emoji /v2/emoji/create */
982
982
  createClanEmoji(bearerToken: string, body: ApiClanEmojiCreateRequest, options?: any): Promise<any>;
983
983
  /** Get emoji list by clan id */
984
984
  listClanEmojiByClanId(bearerToken: string, clanId: string, options?: any): Promise<ApiClanEmojiList>;
@@ -2387,32 +2387,7 @@ var MezonApi = class {
2387
2387
  )
2388
2388
  ]);
2389
2389
  }
2390
- /** Get permission list */
2391
- listClanEmoji(bearerToken, options = {}) {
2392
- const urlPath = "/v2/emoji";
2393
- const queryParams = /* @__PURE__ */ new Map();
2394
- let bodyJson = "";
2395
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2396
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
2397
- if (bearerToken) {
2398
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2399
- }
2400
- return Promise.race([
2401
- fetch(fullUrl, fetchOptions).then((response) => {
2402
- if (response.status == 204) {
2403
- return response;
2404
- } else if (response.status >= 200 && response.status < 300) {
2405
- return response.json();
2406
- } else {
2407
- throw response;
2408
- }
2409
- }),
2410
- new Promise(
2411
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
2412
- )
2413
- ]);
2414
- }
2415
- /** Post permission Emoji /v2/emoji/create */
2390
+ /** Post clan Emoji /v2/emoji/create */
2416
2391
  createClanEmoji(bearerToken, body, options = {}) {
2417
2392
  if (body === null || body === void 0) {
2418
2393
  throw new Error("'body' is a required parameter but is null or undefined.");
@@ -4538,6 +4513,10 @@ var _DefaultSocket = class _DefaultSocket {
4538
4513
  this.onchannelpresence(message.channel_presence_event);
4539
4514
  } else if (message.last_pin_message_event) {
4540
4515
  this.onpinmessage(message.last_pin_message_event);
4516
+ } else if (message.custom_status_event) {
4517
+ this.oncustomstatus(message.custom_status_event);
4518
+ } else if (message.user_channel_added_event) {
4519
+ this.onuserchanneladded(message.user_channel_added_event);
4541
4520
  } else {
4542
4521
  if (this.verbose && window && window.console) {
4543
4522
  console.log("Unrecognized message received: %o", message);
@@ -4620,6 +4599,11 @@ var _DefaultSocket = class _DefaultSocket {
4620
4599
  console.log(channelPresence);
4621
4600
  }
4622
4601
  }
4602
+ onuserchanneladded(user) {
4603
+ if (this.verbose && window && window.console) {
4604
+ console.log(user);
4605
+ }
4606
+ }
4623
4607
  onnotification(notification) {
4624
4608
  if (this.verbose && window && window.console) {
4625
4609
  console.log(notification);
@@ -4685,6 +4669,11 @@ var _DefaultSocket = class _DefaultSocket {
4685
4669
  console.log("Heartbeat timeout.");
4686
4670
  }
4687
4671
  }
4672
+ oncustomstatus(statusEvent) {
4673
+ if (this.verbose && window && window.console) {
4674
+ console.log(statusEvent);
4675
+ }
4676
+ }
4688
4677
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
4689
4678
  const untypedMessage = message;
4690
4679
  return new Promise((resolve, reject) => {
@@ -4836,6 +4825,12 @@ var _DefaultSocket = class _DefaultSocket {
4836
4825
  return response.voice_leaved_event;
4837
4826
  });
4838
4827
  }
4828
+ writeCustomStatus(clan_id, status) {
4829
+ return __async(this, null, function* () {
4830
+ const response = yield this.send({ custom_status_event: { clan_id, status } });
4831
+ return response.last_pin_message_event;
4832
+ });
4833
+ }
4839
4834
  pingPong() {
4840
4835
  return __async(this, null, function* () {
4841
4836
  if (!this.adapter.isOpen()) {
@@ -2358,32 +2358,7 @@ var MezonApi = class {
2358
2358
  )
2359
2359
  ]);
2360
2360
  }
2361
- /** Get permission list */
2362
- listClanEmoji(bearerToken, options = {}) {
2363
- const urlPath = "/v2/emoji";
2364
- const queryParams = /* @__PURE__ */ new Map();
2365
- let bodyJson = "";
2366
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2367
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
2368
- if (bearerToken) {
2369
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2370
- }
2371
- return Promise.race([
2372
- fetch(fullUrl, fetchOptions).then((response) => {
2373
- if (response.status == 204) {
2374
- return response;
2375
- } else if (response.status >= 200 && response.status < 300) {
2376
- return response.json();
2377
- } else {
2378
- throw response;
2379
- }
2380
- }),
2381
- new Promise(
2382
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
2383
- )
2384
- ]);
2385
- }
2386
- /** Post permission Emoji /v2/emoji/create */
2361
+ /** Post clan Emoji /v2/emoji/create */
2387
2362
  createClanEmoji(bearerToken, body, options = {}) {
2388
2363
  if (body === null || body === void 0) {
2389
2364
  throw new Error("'body' is a required parameter but is null or undefined.");
@@ -4509,6 +4484,10 @@ var _DefaultSocket = class _DefaultSocket {
4509
4484
  this.onchannelpresence(message.channel_presence_event);
4510
4485
  } else if (message.last_pin_message_event) {
4511
4486
  this.onpinmessage(message.last_pin_message_event);
4487
+ } else if (message.custom_status_event) {
4488
+ this.oncustomstatus(message.custom_status_event);
4489
+ } else if (message.user_channel_added_event) {
4490
+ this.onuserchanneladded(message.user_channel_added_event);
4512
4491
  } else {
4513
4492
  if (this.verbose && window && window.console) {
4514
4493
  console.log("Unrecognized message received: %o", message);
@@ -4591,6 +4570,11 @@ var _DefaultSocket = class _DefaultSocket {
4591
4570
  console.log(channelPresence);
4592
4571
  }
4593
4572
  }
4573
+ onuserchanneladded(user) {
4574
+ if (this.verbose && window && window.console) {
4575
+ console.log(user);
4576
+ }
4577
+ }
4594
4578
  onnotification(notification) {
4595
4579
  if (this.verbose && window && window.console) {
4596
4580
  console.log(notification);
@@ -4656,6 +4640,11 @@ var _DefaultSocket = class _DefaultSocket {
4656
4640
  console.log("Heartbeat timeout.");
4657
4641
  }
4658
4642
  }
4643
+ oncustomstatus(statusEvent) {
4644
+ if (this.verbose && window && window.console) {
4645
+ console.log(statusEvent);
4646
+ }
4647
+ }
4659
4648
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
4660
4649
  const untypedMessage = message;
4661
4650
  return new Promise((resolve, reject) => {
@@ -4807,6 +4796,12 @@ var _DefaultSocket = class _DefaultSocket {
4807
4796
  return response.voice_leaved_event;
4808
4797
  });
4809
4798
  }
4799
+ writeCustomStatus(clan_id, status) {
4800
+ return __async(this, null, function* () {
4801
+ const response = yield this.send({ custom_status_event: { clan_id, status } });
4802
+ return response.last_pin_message_event;
4803
+ });
4804
+ }
4810
4805
  pingPong() {
4811
4806
  return __async(this, null, function* () {
4812
4807
  if (!this.adapter.isOpen()) {
package/dist/socket.d.ts CHANGED
@@ -71,6 +71,14 @@ interface ChannelLeave {
71
71
  channel_label: string;
72
72
  };
73
73
  }
74
+ /** UserChannelAddedEvent */
75
+ export interface UserChannelAddedEvent {
76
+ channel_id: string;
77
+ user_id: string;
78
+ username: string;
79
+ avatar: string;
80
+ status: string;
81
+ }
74
82
  /** Last seen message by user */
75
83
  export interface LastPinMessageEvent {
76
84
  /** The channel this message belongs to. */
@@ -285,6 +293,12 @@ export interface VoiceJoinedEvent {
285
293
  voice_channel_id: string;
286
294
  last_screenshot: string;
287
295
  }
296
+ export interface CustomStatusEvent {
297
+ clan_id: string;
298
+ user_id: string;
299
+ username: string;
300
+ status: string;
301
+ }
288
302
  export interface ChannelUpdatedEvent {
289
303
  clan_id: string;
290
304
  category_id: string;
@@ -440,6 +454,7 @@ export interface Socket {
440
454
  * In any case, be aware that `onclose` will still fire if there is a heartbeat timeout in a potentially delayed manner.
441
455
  */
442
456
  onheartbeattimeout: () => void;
457
+ oncustomstatus: (statusEvent: CustomStatusEvent) => void;
443
458
  /** Receive channel message. */
444
459
  onchannelmessage: (channelMessage: ChannelMessageEvent) => void;
445
460
  /** Receive typing event */
@@ -450,6 +465,8 @@ export interface Socket {
450
465
  onchannelpresence: (channelPresence: ChannelPresenceEvent) => void;
451
466
  /** pin message event */
452
467
  onpinmessage: (pin: LastPinMessageEvent) => void;
468
+ /** Receive added user event */
469
+ onuserchanneladded: (user: UserChannelAddedEvent) => void;
453
470
  onvoicestarted: (voice: VoiceStartedEvent) => void;
454
471
  onvoiceended: (voice: VoiceEndedEvent) => void;
455
472
  onvoicejoined: (voiceParticipant: VoiceJoinedEvent) => void;
@@ -493,6 +510,7 @@ export declare class DefaultSocket implements Socket {
493
510
  onmessagereaction(messagereaction: MessageReactionEvent): void;
494
511
  onchannelmessage(channelMessage: ChannelMessageEvent): void;
495
512
  onchannelpresence(channelPresence: ChannelPresenceEvent): void;
513
+ onuserchanneladded(user: UserChannelAddedEvent): void;
496
514
  onnotification(notification: Notification): void;
497
515
  onstatuspresence(statusPresence: StatusPresenceEvent): void;
498
516
  onpinmessage(pin: LastPinMessageEvent): void;
@@ -506,6 +524,7 @@ export declare class DefaultSocket implements Socket {
506
524
  onstreampresence(streamPresence: StreamPresenceEvent): void;
507
525
  onstreamdata(streamData: StreamData): void;
508
526
  onheartbeattimeout(): void;
527
+ oncustomstatus(statusEvent: CustomStatusEvent): void;
509
528
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
510
529
  followUsers(userIds: string[]): Promise<Status>;
511
530
  joinClanChat(clan_id: string): Promise<ClanJoin>;
@@ -525,6 +544,7 @@ export declare class DefaultSocket implements Socket {
525
544
  writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number): Promise<LastPinMessageEvent>;
526
545
  writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
527
546
  writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
547
+ writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent>;
528
548
  private pingPong;
529
549
  }
530
550
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.7.71",
3
+ "version": "2.7.73",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -88,6 +88,20 @@ interface ChannelLeave {
88
88
  };
89
89
  }
90
90
 
91
+ /** UserChannelAddedEvent */
92
+ export interface UserChannelAddedEvent {
93
+ // the channel id
94
+ channel_id: string;
95
+ // the user_id
96
+ user_id: string;
97
+ // the username
98
+ username: string;
99
+ // the avatar
100
+ avatar: string;
101
+ // the custom status
102
+ status: string;
103
+ }
104
+
91
105
  /** Last seen message by user */
92
106
  export interface LastPinMessageEvent {
93
107
  /** The channel this message belongs to. */
@@ -395,6 +409,16 @@ export interface VoiceJoinedEvent {
395
409
  last_screenshot: string;
396
410
  }
397
411
 
412
+ export interface CustomStatusEvent {
413
+ // the clan id
414
+ clan_id: string;
415
+ // the user id
416
+ user_id: string;
417
+ // username
418
+ username: string;
419
+ // the status
420
+ status: string;
421
+ }
398
422
 
399
423
  export interface ChannelUpdatedEvent {
400
424
  // clan id
@@ -606,6 +630,8 @@ export interface Socket {
606
630
  */
607
631
  onheartbeattimeout: () => void;
608
632
 
633
+ oncustomstatus: (statusEvent: CustomStatusEvent) => void;
634
+
609
635
  /** Receive channel message. */
610
636
  onchannelmessage: (channelMessage: ChannelMessageEvent) => void;
611
637
 
@@ -620,6 +646,9 @@ export interface Socket {
620
646
 
621
647
  /** pin message event */
622
648
  onpinmessage: (pin: LastPinMessageEvent) => void;
649
+
650
+ /** Receive added user event */
651
+ onuserchanneladded: (user: UserChannelAddedEvent) => void;
623
652
 
624
653
  // when someone start the voice room
625
654
  onvoicestarted: (voice: VoiceStartedEvent) => void;
@@ -774,6 +803,10 @@ export class DefaultSocket implements Socket {
774
803
  this.onchannelpresence(<ChannelPresenceEvent>message.channel_presence_event);
775
804
  } else if (message.last_pin_message_event) {
776
805
  this.onpinmessage(<LastPinMessageEvent>message.last_pin_message_event);
806
+ } else if (message.custom_status_event) {
807
+ this.oncustomstatus(<CustomStatusEvent>message.custom_status_event);
808
+ } else if (message.user_channel_added_event) {
809
+ this.onuserchanneladded(<UserChannelAddedEvent>message.user_channel_added_event);
777
810
  } else {
778
811
  if (this.verbose && window && window.console) {
779
812
  console.log("Unrecognized message received: %o", message);
@@ -871,6 +904,12 @@ export class DefaultSocket implements Socket {
871
904
  }
872
905
  }
873
906
 
907
+ onuserchanneladded(user: UserChannelAddedEvent) {
908
+ if (this.verbose && window && window.console) {
909
+ console.log(user);
910
+ }
911
+ }
912
+
874
913
  onnotification(notification: Notification) {
875
914
  if (this.verbose && window && window.console) {
876
915
  console.log(notification);
@@ -949,6 +988,12 @@ export class DefaultSocket implements Socket {
949
988
  }
950
989
  }
951
990
 
991
+ oncustomstatus(statusEvent: CustomStatusEvent) {
992
+ if (this.verbose && window && window.console) {
993
+ console.log(statusEvent);
994
+ }
995
+ }
996
+
952
997
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate |
953
998
  ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout = DefaultSocket.DefaultSendTimeoutMs): Promise<any> {
954
999
  const untypedMessage = message as any;
@@ -1101,6 +1146,11 @@ export class DefaultSocket implements Socket {
1101
1146
  return response.voice_leaved_event
1102
1147
  }
1103
1148
 
1149
+ async writeCustomStatus(clan_id: string, status: string) : Promise<CustomStatusEvent> {
1150
+ const response = await this.send({custom_status_event: {clan_id: clan_id, status: status}});
1151
+ return response.last_pin_message_event
1152
+ }
1153
+
1104
1154
  private async pingPong() : Promise<void> {
1105
1155
  if (!this.adapter.isOpen()) {
1106
1156
  return;