mezon-js-protobuf 1.8.78 → 1.8.80

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js-protobuf",
3
- "version": "1.8.78",
3
+ "version": "1.8.80",
4
4
  "description": "Websocket adapter adding protocol buffer support to the Mezon Javascript client.",
5
5
  "main": "dist/mezon-js-protobuf.cjs.js",
6
6
  "module": "dist/mezon-js-protobuf.esm.mjs",
package/rtapi/realtime.ts CHANGED
@@ -90,7 +90,6 @@ import {
90
90
  WebhookListRequest,
91
91
  WebhookListResponse,
92
92
  } from "../api/api";
93
- import { Timestamp } from "../google/protobuf/timestamp";
94
93
  import { BoolValue, Int32Value, StringValue } from "../google/protobuf/wrappers";
95
94
 
96
95
  export const protobufPackage = "mezon.realtime";
@@ -672,13 +671,9 @@ export interface ChannelMessageAck {
672
671
  /** Username of the message sender. */
673
672
  username: string;
674
673
  /** The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was created. */
675
- create_time:
676
- | Date
677
- | undefined;
674
+ create_time_seconds: number;
678
675
  /** The UNIX time (for gRPC clients) or ISO string (for REST clients) when the message was last updated. */
679
- update_time:
680
- | Date
681
- | undefined;
676
+ update_time_seconds: number;
682
677
  /** True if the message was persisted to the channel's history, false otherwise. */
683
678
  persistent:
684
679
  | boolean
@@ -1168,9 +1163,7 @@ export interface ChannelCreatedEvent {
1168
1163
  /** channel private */
1169
1164
  channel_private: number;
1170
1165
  /** channel type */
1171
- channel_type:
1172
- | number
1173
- | undefined;
1166
+ channel_type: number;
1174
1167
  /** status */
1175
1168
  status: number;
1176
1169
  /** app id */
@@ -5614,8 +5607,8 @@ function createBaseChannelMessageAck(): ChannelMessageAck {
5614
5607
  message_id: "",
5615
5608
  code: 0,
5616
5609
  username: "",
5617
- create_time: undefined,
5618
- update_time: undefined,
5610
+ create_time_seconds: 0,
5611
+ update_time_seconds: 0,
5619
5612
  persistent: undefined,
5620
5613
  clan_logo: "",
5621
5614
  category_name: "",
@@ -5636,11 +5629,11 @@ export const ChannelMessageAck = {
5636
5629
  if (message.username !== "") {
5637
5630
  writer.uint32(34).string(message.username);
5638
5631
  }
5639
- if (message.create_time !== undefined) {
5640
- Timestamp.encode(toTimestamp(message.create_time), writer.uint32(42).fork()).ldelim();
5632
+ if (message.create_time_seconds !== 0) {
5633
+ writer.uint32(40).uint32(message.create_time_seconds);
5641
5634
  }
5642
- if (message.update_time !== undefined) {
5643
- Timestamp.encode(toTimestamp(message.update_time), writer.uint32(50).fork()).ldelim();
5635
+ if (message.update_time_seconds !== 0) {
5636
+ writer.uint32(48).uint32(message.update_time_seconds);
5644
5637
  }
5645
5638
  if (message.persistent !== undefined) {
5646
5639
  BoolValue.encode({ value: message.persistent! }, writer.uint32(58).fork()).ldelim();
@@ -5690,18 +5683,18 @@ export const ChannelMessageAck = {
5690
5683
  message.username = reader.string();
5691
5684
  continue;
5692
5685
  case 5:
5693
- if (tag !== 42) {
5686
+ if (tag !== 40) {
5694
5687
  break;
5695
5688
  }
5696
5689
 
5697
- message.create_time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
5690
+ message.create_time_seconds = reader.uint32();
5698
5691
  continue;
5699
5692
  case 6:
5700
- if (tag !== 50) {
5693
+ if (tag !== 48) {
5701
5694
  break;
5702
5695
  }
5703
5696
 
5704
- message.update_time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
5697
+ message.update_time_seconds = reader.uint32();
5705
5698
  continue;
5706
5699
  case 7:
5707
5700
  if (tag !== 58) {
@@ -5739,8 +5732,8 @@ export const ChannelMessageAck = {
5739
5732
  message_id: isSet(object.message_id) ? globalThis.String(object.message_id) : "",
5740
5733
  code: isSet(object.code) ? globalThis.Number(object.code) : 0,
5741
5734
  username: isSet(object.username) ? globalThis.String(object.username) : "",
5742
- create_time: isSet(object.create_time) ? fromJsonTimestamp(object.create_time) : undefined,
5743
- update_time: isSet(object.update_time) ? fromJsonTimestamp(object.update_time) : undefined,
5735
+ create_time_seconds: isSet(object.create_time_seconds) ? globalThis.Number(object.create_time_seconds) : 0,
5736
+ update_time_seconds: isSet(object.update_time_seconds) ? globalThis.Number(object.update_time_seconds) : 0,
5744
5737
  persistent: isSet(object.persistent) ? Boolean(object.persistent) : undefined,
5745
5738
  clan_logo: isSet(object.clan_logo) ? globalThis.String(object.clan_logo) : "",
5746
5739
  category_name: isSet(object.category_name) ? globalThis.String(object.category_name) : "",
@@ -5761,11 +5754,11 @@ export const ChannelMessageAck = {
5761
5754
  if (message.username !== "") {
5762
5755
  obj.username = message.username;
5763
5756
  }
5764
- if (message.create_time !== undefined) {
5765
- obj.create_time = message.create_time.toISOString();
5757
+ if (message.create_time_seconds !== 0) {
5758
+ obj.create_time_seconds = Math.round(message.create_time_seconds);
5766
5759
  }
5767
- if (message.update_time !== undefined) {
5768
- obj.update_time = message.update_time.toISOString();
5760
+ if (message.update_time_seconds !== 0) {
5761
+ obj.update_time_seconds = Math.round(message.update_time_seconds);
5769
5762
  }
5770
5763
  if (message.persistent !== undefined) {
5771
5764
  obj.persistent = message.persistent;
@@ -5788,8 +5781,8 @@ export const ChannelMessageAck = {
5788
5781
  message.message_id = object.message_id ?? "";
5789
5782
  message.code = object.code ?? 0;
5790
5783
  message.username = object.username ?? "";
5791
- message.create_time = object.create_time ?? undefined;
5792
- message.update_time = object.update_time ?? undefined;
5784
+ message.create_time_seconds = object.create_time_seconds ?? 0;
5785
+ message.update_time_seconds = object.update_time_seconds ?? 0;
5793
5786
  message.persistent = object.persistent ?? undefined;
5794
5787
  message.clan_logo = object.clan_logo ?? "";
5795
5788
  message.category_name = object.category_name ?? "";
@@ -9356,7 +9349,7 @@ function createBaseChannelCreatedEvent(): ChannelCreatedEvent {
9356
9349
  channel_id: "",
9357
9350
  channel_label: "",
9358
9351
  channel_private: 0,
9359
- channel_type: undefined,
9352
+ channel_type: 0,
9360
9353
  status: 0,
9361
9354
  app_id: "",
9362
9355
  clan_name: "",
@@ -9387,8 +9380,8 @@ export const ChannelCreatedEvent = {
9387
9380
  if (message.channel_private !== 0) {
9388
9381
  writer.uint32(56).int32(message.channel_private);
9389
9382
  }
9390
- if (message.channel_type !== undefined) {
9391
- Int32Value.encode({ value: message.channel_type! }, writer.uint32(66).fork()).ldelim();
9383
+ if (message.channel_type !== 0) {
9384
+ writer.uint32(64).int32(message.channel_type);
9392
9385
  }
9393
9386
  if (message.status !== 0) {
9394
9387
  writer.uint32(72).int32(message.status);
@@ -9462,11 +9455,11 @@ export const ChannelCreatedEvent = {
9462
9455
  message.channel_private = reader.int32();
9463
9456
  continue;
9464
9457
  case 8:
9465
- if (tag !== 66) {
9458
+ if (tag !== 64) {
9466
9459
  break;
9467
9460
  }
9468
9461
 
9469
- message.channel_type = Int32Value.decode(reader, reader.uint32()).value;
9462
+ message.channel_type = reader.int32();
9470
9463
  continue;
9471
9464
  case 9:
9472
9465
  if (tag !== 72) {
@@ -9514,7 +9507,7 @@ export const ChannelCreatedEvent = {
9514
9507
  channel_id: isSet(object.channel_id) ? globalThis.String(object.channel_id) : "",
9515
9508
  channel_label: isSet(object.channel_label) ? globalThis.String(object.channel_label) : "",
9516
9509
  channel_private: isSet(object.channel_private) ? globalThis.Number(object.channel_private) : 0,
9517
- channel_type: isSet(object.channel_type) ? Number(object.channel_type) : undefined,
9510
+ channel_type: isSet(object.channel_type) ? globalThis.Number(object.channel_type) : 0,
9518
9511
  status: isSet(object.status) ? globalThis.Number(object.status) : 0,
9519
9512
  app_id: isSet(object.app_id) ? globalThis.String(object.app_id) : "",
9520
9513
  clan_name: isSet(object.clan_name) ? globalThis.String(object.clan_name) : "",
@@ -9545,8 +9538,8 @@ export const ChannelCreatedEvent = {
9545
9538
  if (message.channel_private !== 0) {
9546
9539
  obj.channel_private = Math.round(message.channel_private);
9547
9540
  }
9548
- if (message.channel_type !== undefined) {
9549
- obj.channel_type = message.channel_type;
9541
+ if (message.channel_type !== 0) {
9542
+ obj.channel_type = Math.round(message.channel_type);
9550
9543
  }
9551
9544
  if (message.status !== 0) {
9552
9545
  obj.status = Math.round(message.status);
@@ -9575,7 +9568,7 @@ export const ChannelCreatedEvent = {
9575
9568
  message.channel_id = object.channel_id ?? "";
9576
9569
  message.channel_label = object.channel_label ?? "";
9577
9570
  message.channel_private = object.channel_private ?? 0;
9578
- message.channel_type = object.channel_type ?? undefined;
9571
+ message.channel_type = object.channel_type ?? 0;
9579
9572
  message.status = object.status ?? 0;
9580
9573
  message.app_id = object.app_id ?? "";
9581
9574
  message.clan_name = object.clan_name ?? "";
@@ -16665,28 +16658,6 @@ type KeysOfUnion<T> = T extends T ? keyof T : never;
16665
16658
  export type Exact<P, I extends P> = P extends Builtin ? P
16666
16659
  : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
16667
16660
 
16668
- function toTimestamp(date: Date): Timestamp {
16669
- const seconds = Math.trunc(date.getTime() / 1_000);
16670
- const nanos = (date.getTime() % 1_000) * 1_000_000;
16671
- return { seconds, nanos };
16672
- }
16673
-
16674
- function fromTimestamp(t: Timestamp): Date {
16675
- let millis = (t.seconds || 0) * 1_000;
16676
- millis += (t.nanos || 0) / 1_000_000;
16677
- return new globalThis.Date(millis);
16678
- }
16679
-
16680
- function fromJsonTimestamp(o: any): Date {
16681
- if (o instanceof globalThis.Date) {
16682
- return o;
16683
- } else if (typeof o === "string") {
16684
- return new globalThis.Date(o);
16685
- } else {
16686
- return fromTimestamp(Timestamp.fromJSON(o));
16687
- }
16688
- }
16689
-
16690
16661
  function isObject(value: any): boolean {
16691
16662
  return typeof value === "object" && value !== null;
16692
16663
  }
package/utils.ts CHANGED
@@ -27,14 +27,22 @@ export function decodeRefs(data: any) {
27
27
  export function decodeReactions(data: any) {
28
28
  const buffer: ArrayBuffer = data;
29
29
  const uintBuffer: Uint8Array = new Uint8Array(buffer);
30
- const noti = tsproto.MessageReactionList.decode(uintBuffer);
31
- return noti;
30
+ const reactions = tsproto.MessageReactionList.decode(uintBuffer);
31
+ return reactions;
32
32
  }
33
33
 
34
34
  export function decodeNotificationFcm(data: any) {
35
35
  const buffer: ArrayBuffer = data;
36
36
  const uintBuffer: Uint8Array = new Uint8Array(buffer);
37
- const noti = tsproto.DirectFcmProto.decode(uintBuffer);
37
+ const noti = tsproto.Notification.decode(uintBuffer);
38
38
 
39
39
  return noti;
40
40
  }
41
+
42
+ export function decodeNotificationContent(data: any) {
43
+ const uint8Array = new Uint8Array(data);
44
+ const decoder = new TextDecoder("utf-8");
45
+ const notiContent = decoder.decode(uint8Array);
46
+
47
+ return notiContent;
48
+ }