mezon-js 2.10.37 → 2.10.39

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
@@ -1575,6 +1575,8 @@ export interface ApiMessageReaction {
1575
1575
  channel_label: string;
1576
1576
  /** The message that user react */
1577
1577
  message_id: string;
1578
+ //
1579
+ topic_id?: string;
1578
1580
  }
1579
1581
 
1580
1582
  export interface ApiListChannelAppsResponse {
package/dist/api.gen.d.ts CHANGED
@@ -914,6 +914,7 @@ export interface ApiMessageReaction {
914
914
  channel_label: string;
915
915
  /** The message that user react */
916
916
  message_id: string;
917
+ topic_id?: string;
917
918
  }
918
919
  export interface ApiListChannelAppsResponse {
919
920
  channel_apps?: Array<ApiChannelAppResponse>;
@@ -714,12 +714,14 @@ function b64DecodeUnicode(str) {
714
714
  return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
715
715
  }).join(""));
716
716
  }
717
- function safeJSONParse(jsonString) {
717
+ function safeJSONParse(jsonStr) {
718
718
  try {
719
- const parsedData = JSON.parse(jsonString);
719
+ const parsedData = JSON.parse(jsonStr);
720
720
  return parsedData;
721
721
  } catch (error) {
722
- console.error("Error parsing JSON:", jsonString, error);
722
+ if (jsonStr !== "") {
723
+ console.error("Error parsing JSON:", jsonStr, error);
724
+ }
723
725
  return null;
724
726
  }
725
727
  }
@@ -7783,7 +7785,7 @@ var _DefaultSocket = class _DefaultSocket {
7783
7785
  unfollowUsers(user_ids) {
7784
7786
  return this.send({ status_unfollow: { user_ids } });
7785
7787
  }
7786
- updateChatMessage(clan_id, channel_id, mode, is_public, message_id, content, mentions, attachments, hideEditted) {
7788
+ updateChatMessage(clan_id, channel_id, mode, is_public, message_id, content, mentions, attachments, hideEditted, topic_id) {
7787
7789
  return __async(this, null, function* () {
7788
7790
  const response = yield this.send({
7789
7791
  channel_message_update: {
@@ -7795,7 +7797,8 @@ var _DefaultSocket = class _DefaultSocket {
7795
7797
  attachments,
7796
7798
  mode,
7797
7799
  is_public,
7798
- hide_editted: hideEditted
7800
+ hide_editted: hideEditted,
7801
+ topic_id
7799
7802
  }
7800
7803
  });
7801
7804
  return response.channel_message_ack;
@@ -7826,7 +7829,7 @@ var _DefaultSocket = class _DefaultSocket {
7826
7829
  return response.channel_message_ack;
7827
7830
  });
7828
7831
  }
7829
- writeMessageReaction(id, clan_id, channel_id, mode, is_public, message_id, emoji_id, emoji, count, message_sender_id, action_delete) {
7832
+ writeMessageReaction(id, clan_id, channel_id, mode, is_public, message_id, emoji_id, emoji, count, message_sender_id, action_delete, topic_id) {
7830
7833
  return __async(this, null, function* () {
7831
7834
  const response = yield this.send({
7832
7835
  message_reaction_event: {
@@ -7840,7 +7843,8 @@ var _DefaultSocket = class _DefaultSocket {
7840
7843
  emoji,
7841
7844
  count,
7842
7845
  message_sender_id,
7843
- action: action_delete
7846
+ action: action_delete,
7847
+ topic_id
7844
7848
  }
7845
7849
  });
7846
7850
  return response.message_reaction_event;
@@ -7995,31 +7999,6 @@ var _DefaultSocket = class _DefaultSocket {
7995
7999
  return response.webrtc_signaling_fwd;
7996
8000
  });
7997
8001
  }
7998
- joinPTTChannel(clanId, channelId, dataType, jsonData) {
7999
- return __async(this, null, function* () {
8000
- const response = yield this.send({
8001
- join_ptt_channel: {
8002
- clan_id: clanId,
8003
- channel_id: channelId,
8004
- data_type: dataType,
8005
- json_data: jsonData
8006
- }
8007
- });
8008
- return response.join_ptt_channel;
8009
- });
8010
- }
8011
- talkPTTChannel(clanId, channelId, isTalk) {
8012
- return __async(this, null, function* () {
8013
- const response = yield this.send({
8014
- talk_ptt_channel: {
8015
- clan_id: clanId,
8016
- channel_id: channelId,
8017
- is_talk: isTalk
8018
- }
8019
- });
8020
- return response.talk_ptt_channel;
8021
- });
8022
- }
8023
8002
  pingPong() {
8024
8003
  return __async(this, null, function* () {
8025
8004
  if (!this.adapter.isOpen()) {
@@ -680,12 +680,14 @@ function b64DecodeUnicode(str) {
680
680
  return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
681
681
  }).join(""));
682
682
  }
683
- function safeJSONParse(jsonString) {
683
+ function safeJSONParse(jsonStr) {
684
684
  try {
685
- const parsedData = JSON.parse(jsonString);
685
+ const parsedData = JSON.parse(jsonStr);
686
686
  return parsedData;
687
687
  } catch (error) {
688
- console.error("Error parsing JSON:", jsonString, error);
688
+ if (jsonStr !== "") {
689
+ console.error("Error parsing JSON:", jsonStr, error);
690
+ }
689
691
  return null;
690
692
  }
691
693
  }
@@ -7749,7 +7751,7 @@ var _DefaultSocket = class _DefaultSocket {
7749
7751
  unfollowUsers(user_ids) {
7750
7752
  return this.send({ status_unfollow: { user_ids } });
7751
7753
  }
7752
- updateChatMessage(clan_id, channel_id, mode, is_public, message_id, content, mentions, attachments, hideEditted) {
7754
+ updateChatMessage(clan_id, channel_id, mode, is_public, message_id, content, mentions, attachments, hideEditted, topic_id) {
7753
7755
  return __async(this, null, function* () {
7754
7756
  const response = yield this.send({
7755
7757
  channel_message_update: {
@@ -7761,7 +7763,8 @@ var _DefaultSocket = class _DefaultSocket {
7761
7763
  attachments,
7762
7764
  mode,
7763
7765
  is_public,
7764
- hide_editted: hideEditted
7766
+ hide_editted: hideEditted,
7767
+ topic_id
7765
7768
  }
7766
7769
  });
7767
7770
  return response.channel_message_ack;
@@ -7792,7 +7795,7 @@ var _DefaultSocket = class _DefaultSocket {
7792
7795
  return response.channel_message_ack;
7793
7796
  });
7794
7797
  }
7795
- writeMessageReaction(id, clan_id, channel_id, mode, is_public, message_id, emoji_id, emoji, count, message_sender_id, action_delete) {
7798
+ writeMessageReaction(id, clan_id, channel_id, mode, is_public, message_id, emoji_id, emoji, count, message_sender_id, action_delete, topic_id) {
7796
7799
  return __async(this, null, function* () {
7797
7800
  const response = yield this.send({
7798
7801
  message_reaction_event: {
@@ -7806,7 +7809,8 @@ var _DefaultSocket = class _DefaultSocket {
7806
7809
  emoji,
7807
7810
  count,
7808
7811
  message_sender_id,
7809
- action: action_delete
7812
+ action: action_delete,
7813
+ topic_id
7810
7814
  }
7811
7815
  });
7812
7816
  return response.message_reaction_event;
@@ -7961,31 +7965,6 @@ var _DefaultSocket = class _DefaultSocket {
7961
7965
  return response.webrtc_signaling_fwd;
7962
7966
  });
7963
7967
  }
7964
- joinPTTChannel(clanId, channelId, dataType, jsonData) {
7965
- return __async(this, null, function* () {
7966
- const response = yield this.send({
7967
- join_ptt_channel: {
7968
- clan_id: clanId,
7969
- channel_id: channelId,
7970
- data_type: dataType,
7971
- json_data: jsonData
7972
- }
7973
- });
7974
- return response.join_ptt_channel;
7975
- });
7976
- }
7977
- talkPTTChannel(clanId, channelId, isTalk) {
7978
- return __async(this, null, function* () {
7979
- const response = yield this.send({
7980
- talk_ptt_channel: {
7981
- clan_id: clanId,
7982
- channel_id: channelId,
7983
- is_talk: isTalk
7984
- }
7985
- });
7986
- return response.talk_ptt_channel;
7987
- });
7988
- }
7989
7968
  pingPong() {
7990
7969
  return __async(this, null, function* () {
7991
7970
  if (!this.adapter.isOpen()) {
package/dist/socket.d.ts CHANGED
@@ -218,6 +218,7 @@ interface ChannelMessageUpdate {
218
218
  /** The mode payload. */
219
219
  mode: number;
220
220
  is_public: boolean;
221
+ topic_id?: string;
221
222
  };
222
223
  }
223
224
  /** Remove a message previously sent to a realtime chat channel. */
@@ -703,7 +704,7 @@ export interface Socket {
703
704
  /** Unfollow one or more users from their status updates. */
704
705
  unfollowUsers(user_ids: string[]): Promise<void>;
705
706
  /** Update a chat message on a chat channel in the server. */
706
- updateChatMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, hideEditted?: boolean): Promise<ChannelMessageAck>;
707
+ updateChatMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, hideEditted?: boolean, topic_id?: string): Promise<ChannelMessageAck>;
707
708
  /** Update the status for the current user online. */
708
709
  updateStatus(status?: string): Promise<void>;
709
710
  /** Send a chat message to a chat channel on the server. */
@@ -711,7 +712,7 @@ export interface Socket {
711
712
  /** Send message typing */
712
713
  writeMessageTyping(clan_id: string, channel_id: string, mode: number, is_public: boolean): Promise<MessageTypingEvent>;
713
714
  /** Send message reaction */
714
- writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<ApiMessageReaction>;
715
+ writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean, topic_id?: string): Promise<ApiMessageReaction>;
715
716
  /** Send last seen message */
716
717
  writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp_seconds: number): Promise<LastSeenMessageEvent>;
717
718
  /** Send last pin message */
@@ -722,8 +723,6 @@ export interface Socket {
722
723
  writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
723
724
  /** send voice leaved */
724
725
  writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
725
- joinPTTChannel(clanId: string, channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
726
- talkPTTChannel(clanId: string, channelId: string, isTalk: boolean): Promise<TalkPTTChannel>;
727
726
  setHeartbeatTimeoutMs(ms: number): void;
728
727
  getHeartbeatTimeoutMs(): number;
729
728
  checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
@@ -890,7 +889,7 @@ export declare class DefaultSocket implements Socket {
890
889
  onjoinpttchannel(join_ptt_channel: JoinPTTChannel): void;
891
890
  ontalkpttchannel(talk_ptt_channel: TalkPTTChannel): void;
892
891
  onsdtopicevent(sd_topic_event: SdTopicEvent): void;
893
- send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping | WebrtcSignalingFwd | IncomingCallPush | MessageButtonClicked | DropdownBoxSelected | JoinPTTChannel | TalkPTTChannel, sendTimeout?: number): Promise<any>;
892
+ send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping | WebrtcSignalingFwd | IncomingCallPush | MessageButtonClicked | DropdownBoxSelected, sendTimeout?: number): Promise<any>;
894
893
  followUsers(userIds: string[]): Promise<Status>;
895
894
  joinClanChat(clan_id: string): Promise<ClanJoin>;
896
895
  follower(): Promise<void>;
@@ -899,10 +898,10 @@ export declare class DefaultSocket implements Socket {
899
898
  removeChatMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, has_attachment?: boolean): Promise<ChannelMessageAck>;
900
899
  rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
901
900
  unfollowUsers(user_ids: string[]): Promise<void>;
902
- updateChatMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, hideEditted?: boolean): Promise<ChannelMessageAck>;
901
+ updateChatMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, hideEditted?: boolean, topic_id?: string): Promise<ChannelMessageAck>;
903
902
  updateStatus(status?: string): Promise<void>;
904
903
  writeChatMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>, anonymous_message?: boolean, mention_everyone?: Boolean, avatar?: string, code?: number, topic_id?: string): Promise<ChannelMessageAck>;
905
- writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<ApiMessageReaction>;
904
+ writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, emoji_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean, topic_id?: string): Promise<ApiMessageReaction>;
906
905
  writeMessageTyping(clan_id: string, channel_id: string, mode: number, is_public: boolean): Promise<MessageTypingEvent>;
907
906
  writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp_seconds: number): Promise<LastSeenMessageEvent>;
908
907
  writeLastPinMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, timestamp_seconds: number, operation: number): Promise<LastPinMessageEvent>;
@@ -914,8 +913,6 @@ export declare class DefaultSocket implements Socket {
914
913
  makeCallPush(receiver_id: string, json_data: string, channel_id: string, caller_id: string): Promise<IncomingCallPush>;
915
914
  handleDropdownBoxSelected(message_id: string, channel_id: string, selectbox_id: string, sender_id: string, user_id: string, value: Array<string>): Promise<DropdownBoxSelected>;
916
915
  handleMessageButtonClick(message_id: string, channel_id: string, button_id: string, sender_id: string, user_id: string, extra_data: string): Promise<MessageButtonClicked>;
917
- joinPTTChannel(clanId: string, channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
918
- talkPTTChannel(clanId: string, channelId: string, isTalk: boolean): Promise<TalkPTTChannel>;
919
916
  private pingPong;
920
917
  }
921
918
  export {};
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export declare function buildFetchOptions(method: string, options: any, bodyJson: string): any;
2
2
  export declare function b64EncodeUnicode(str: string): string;
3
3
  export declare function b64DecodeUnicode(str: string): string;
4
- export declare function safeJSONParse(jsonString: string): any;
4
+ export declare function safeJSONParse(jsonStr: string): any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.10.37",
4
+ "version": "2.10.39",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
package/socket.ts CHANGED
@@ -311,6 +311,8 @@ interface ChannelMessageUpdate {
311
311
  mode: number;
312
312
  // Is public
313
313
  is_public: boolean;
314
+ //
315
+ topic_id?: string;
314
316
  };
315
317
  }
316
318
 
@@ -1011,7 +1013,8 @@ export interface Socket {
1011
1013
  content: any,
1012
1014
  mentions?: Array<ApiMessageMention>,
1013
1015
  attachments?: Array<ApiMessageAttachment>,
1014
- hideEditted?: boolean
1016
+ hideEditted?: boolean,
1017
+ topic_id?: string
1015
1018
  ): Promise<ChannelMessageAck>;
1016
1019
 
1017
1020
  /** Update the status for the current user online. */
@@ -1054,7 +1057,8 @@ export interface Socket {
1054
1057
  emoji: string,
1055
1058
  count: number,
1056
1059
  message_sender_id: string,
1057
- action_delete: boolean
1060
+ action_delete: boolean,
1061
+ topic_id?: string
1058
1062
  ): Promise<ApiMessageReaction>;
1059
1063
 
1060
1064
  /** Send last seen message */
@@ -1102,19 +1106,6 @@ export interface Socket {
1102
1106
  voiceUserId: string
1103
1107
  ): Promise<VoiceLeavedEvent>;
1104
1108
 
1105
- joinPTTChannel(
1106
- clanId: string,
1107
- channelId: string,
1108
- dataType: number,
1109
- jsonData: string
1110
- ): Promise<JoinPTTChannel>;
1111
-
1112
- talkPTTChannel(
1113
- clanId: string,
1114
- channelId: string,
1115
- isTalk: boolean
1116
- ): Promise<TalkPTTChannel>;
1117
-
1118
1109
  /* Set the heartbeat timeout used by the socket to detect if it has lost connectivity to the server. */
1119
1110
  setHeartbeatTimeoutMs(ms: number): void;
1120
1111
 
@@ -1987,9 +1978,7 @@ export class DefaultSocket implements Socket {
1987
1978
  | WebrtcSignalingFwd
1988
1979
  | IncomingCallPush
1989
1980
  | MessageButtonClicked
1990
- | DropdownBoxSelected
1991
- | JoinPTTChannel
1992
- | TalkPTTChannel,
1981
+ | DropdownBoxSelected,
1993
1982
  sendTimeout = DefaultSocket.DefaultSendTimeoutMs
1994
1983
  ): Promise<any> {
1995
1984
  const untypedMessage = message as any;
@@ -2125,7 +2114,8 @@ export class DefaultSocket implements Socket {
2125
2114
  content: any,
2126
2115
  mentions?: Array<ApiMessageMention>,
2127
2116
  attachments?: Array<ApiMessageAttachment>,
2128
- hideEditted?: boolean
2117
+ hideEditted?: boolean,
2118
+ topic_id?: string
2129
2119
  ): Promise<ChannelMessageAck> {
2130
2120
  const response = await this.send({
2131
2121
  channel_message_update: {
@@ -2138,6 +2128,7 @@ export class DefaultSocket implements Socket {
2138
2128
  mode: mode,
2139
2129
  is_public: is_public,
2140
2130
  hide_editted: hideEditted,
2131
+ topic_id: topic_id,
2141
2132
  },
2142
2133
  });
2143
2134
  return response.channel_message_ack;
@@ -2193,7 +2184,8 @@ export class DefaultSocket implements Socket {
2193
2184
  emoji: string,
2194
2185
  count: number,
2195
2186
  message_sender_id: string,
2196
- action_delete: boolean
2187
+ action_delete: boolean,
2188
+ topic_id?: string
2197
2189
  ): Promise<ApiMessageReaction> {
2198
2190
  const response = await this.send({
2199
2191
  message_reaction_event: {
@@ -2208,6 +2200,7 @@ export class DefaultSocket implements Socket {
2208
2200
  count: count,
2209
2201
  message_sender_id: message_sender_id,
2210
2202
  action: action_delete,
2203
+ topic_id: topic_id,
2211
2204
  },
2212
2205
  });
2213
2206
  return response.message_reaction_event;
@@ -2415,38 +2408,6 @@ export class DefaultSocket implements Socket {
2415
2408
  return response.webrtc_signaling_fwd;
2416
2409
  }
2417
2410
 
2418
- async joinPTTChannel(
2419
- clanId: string,
2420
- channelId: string,
2421
- dataType: number,
2422
- jsonData: string
2423
- ): Promise<JoinPTTChannel> {
2424
- const response = await this.send({
2425
- join_ptt_channel: {
2426
- clan_id: clanId,
2427
- channel_id: channelId,
2428
- data_type: dataType,
2429
- json_data: jsonData,
2430
- },
2431
- });
2432
- return response.join_ptt_channel;
2433
- }
2434
-
2435
- async talkPTTChannel(
2436
- clanId: string,
2437
- channelId: string,
2438
- isTalk: boolean
2439
- ): Promise<TalkPTTChannel> {
2440
- const response = await this.send({
2441
- talk_ptt_channel: {
2442
- clan_id: clanId,
2443
- channel_id: channelId,
2444
- is_talk: isTalk,
2445
- },
2446
- });
2447
- return response.talk_ptt_channel;
2448
- }
2449
-
2450
2411
  private async pingPong(): Promise<void> {
2451
2412
  if (!this.adapter.isOpen()) {
2452
2413
  return;
package/utils.ts CHANGED
@@ -48,13 +48,14 @@ export function b64DecodeUnicode(str: string) {
48
48
  }).join(''));
49
49
  }
50
50
 
51
- export function safeJSONParse(jsonString: string) {
51
+ export function safeJSONParse(jsonStr: string) {
52
52
  try {
53
- const parsedData = JSON.parse(jsonString);
54
-
53
+ const parsedData = JSON.parse(jsonStr);
55
54
  return parsedData;
56
55
  } catch (error) {
57
- console.error('Error parsing JSON:', jsonString, error);
56
+ if (jsonStr !== "") {
57
+ console.error('Error parsing JSON:', jsonStr, error);
58
+ }
58
59
  return null; // Handle the error gracefully or throw an exception if necessary
59
60
  }
60
61
  }