mezon-js 2.14.7 → 2.14.8

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/api.ts CHANGED
@@ -3614,10 +3614,10 @@ export interface Message2InboxRequest {
3614
3614
  clan_id: string;
3615
3615
  avatar: string;
3616
3616
  content: string;
3617
- mentions: Uint8Array;
3618
- attachments: Uint8Array;
3619
- reactions: Uint8Array;
3620
- references: Uint8Array;
3617
+ mentions: MessageMention[];
3618
+ attachments: MessageAttachment[];
3619
+ reactions: MessageReaction[];
3620
+ references: MessageRef[];
3621
3621
  }
3622
3622
 
3623
3623
  /** Send an email with password to the server. Used with authenticate/link/unlink. */
@@ -37306,10 +37306,10 @@ function createBaseMessage2InboxRequest(): Message2InboxRequest {
37306
37306
  clan_id: "",
37307
37307
  avatar: "",
37308
37308
  content: "",
37309
- mentions: new Uint8Array(0),
37310
- attachments: new Uint8Array(0),
37311
- reactions: new Uint8Array(0),
37312
- references: new Uint8Array(0),
37309
+ mentions: [],
37310
+ attachments: [],
37311
+ reactions: [],
37312
+ references: [],
37313
37313
  };
37314
37314
  }
37315
37315
 
@@ -37330,17 +37330,17 @@ export const Message2InboxRequest = {
37330
37330
  if (message.content !== "") {
37331
37331
  writer.uint32(42).string(message.content);
37332
37332
  }
37333
- if (message.mentions.length !== 0) {
37334
- writer.uint32(50).bytes(message.mentions);
37333
+ for (const v of message.mentions) {
37334
+ MessageMention.encode(v!, writer.uint32(50).fork()).ldelim();
37335
37335
  }
37336
- if (message.attachments.length !== 0) {
37337
- writer.uint32(58).bytes(message.attachments);
37336
+ for (const v of message.attachments) {
37337
+ MessageAttachment.encode(v!, writer.uint32(58).fork()).ldelim();
37338
37338
  }
37339
- if (message.reactions.length !== 0) {
37340
- writer.uint32(66).bytes(message.reactions);
37339
+ for (const v of message.reactions) {
37340
+ MessageReaction.encode(v!, writer.uint32(66).fork()).ldelim();
37341
37341
  }
37342
- if (message.references.length !== 0) {
37343
- writer.uint32(74).bytes(message.references);
37342
+ for (const v of message.references) {
37343
+ MessageRef.encode(v!, writer.uint32(74).fork()).ldelim();
37344
37344
  }
37345
37345
  return writer;
37346
37346
  },
@@ -37392,28 +37392,28 @@ export const Message2InboxRequest = {
37392
37392
  break;
37393
37393
  }
37394
37394
 
37395
- message.mentions = reader.bytes();
37395
+ message.mentions.push(MessageMention.decode(reader, reader.uint32()));
37396
37396
  continue;
37397
37397
  case 7:
37398
37398
  if (tag !== 58) {
37399
37399
  break;
37400
37400
  }
37401
37401
 
37402
- message.attachments = reader.bytes();
37402
+ message.attachments.push(MessageAttachment.decode(reader, reader.uint32()));
37403
37403
  continue;
37404
37404
  case 8:
37405
37405
  if (tag !== 66) {
37406
37406
  break;
37407
37407
  }
37408
37408
 
37409
- message.reactions = reader.bytes();
37409
+ message.reactions.push(MessageReaction.decode(reader, reader.uint32()));
37410
37410
  continue;
37411
37411
  case 9:
37412
37412
  if (tag !== 74) {
37413
37413
  break;
37414
37414
  }
37415
37415
 
37416
- message.references = reader.bytes();
37416
+ message.references.push(MessageRef.decode(reader, reader.uint32()));
37417
37417
  continue;
37418
37418
  }
37419
37419
  if ((tag & 7) === 4 || tag === 0) {
@@ -37431,10 +37431,18 @@ export const Message2InboxRequest = {
37431
37431
  clan_id: isSet(object.clan_id) ? globalThis.String(object.clan_id) : "",
37432
37432
  avatar: isSet(object.avatar) ? globalThis.String(object.avatar) : "",
37433
37433
  content: isSet(object.content) ? globalThis.String(object.content) : "",
37434
- mentions: isSet(object.mentions) ? bytesFromBase64(object.mentions) : new Uint8Array(0),
37435
- attachments: isSet(object.attachments) ? bytesFromBase64(object.attachments) : new Uint8Array(0),
37436
- reactions: isSet(object.reactions) ? bytesFromBase64(object.reactions) : new Uint8Array(0),
37437
- references: isSet(object.references) ? bytesFromBase64(object.references) : new Uint8Array(0),
37434
+ mentions: globalThis.Array.isArray(object?.mentions)
37435
+ ? object.mentions.map((e: any) => MessageMention.fromJSON(e))
37436
+ : [],
37437
+ attachments: globalThis.Array.isArray(object?.attachments)
37438
+ ? object.attachments.map((e: any) => MessageAttachment.fromJSON(e))
37439
+ : [],
37440
+ reactions: globalThis.Array.isArray(object?.reactions)
37441
+ ? object.reactions.map((e: any) => MessageReaction.fromJSON(e))
37442
+ : [],
37443
+ references: globalThis.Array.isArray(object?.references)
37444
+ ? object.references.map((e: any) => MessageRef.fromJSON(e))
37445
+ : [],
37438
37446
  };
37439
37447
  },
37440
37448
 
@@ -37455,17 +37463,17 @@ export const Message2InboxRequest = {
37455
37463
  if (message.content !== "") {
37456
37464
  obj.content = message.content;
37457
37465
  }
37458
- if (message.mentions.length !== 0) {
37459
- obj.mentions = base64FromBytes(message.mentions);
37466
+ if (message.mentions?.length) {
37467
+ obj.mentions = message.mentions.map((e) => MessageMention.toJSON(e));
37460
37468
  }
37461
- if (message.attachments.length !== 0) {
37462
- obj.attachments = base64FromBytes(message.attachments);
37469
+ if (message.attachments?.length) {
37470
+ obj.attachments = message.attachments.map((e) => MessageAttachment.toJSON(e));
37463
37471
  }
37464
- if (message.reactions.length !== 0) {
37465
- obj.reactions = base64FromBytes(message.reactions);
37472
+ if (message.reactions?.length) {
37473
+ obj.reactions = message.reactions.map((e) => MessageReaction.toJSON(e));
37466
37474
  }
37467
- if (message.references.length !== 0) {
37468
- obj.references = base64FromBytes(message.references);
37475
+ if (message.references?.length) {
37476
+ obj.references = message.references.map((e) => MessageRef.toJSON(e));
37469
37477
  }
37470
37478
  return obj;
37471
37479
  },
@@ -37480,10 +37488,10 @@ export const Message2InboxRequest = {
37480
37488
  message.clan_id = object.clan_id ?? "";
37481
37489
  message.avatar = object.avatar ?? "";
37482
37490
  message.content = object.content ?? "";
37483
- message.mentions = object.mentions ?? new Uint8Array(0);
37484
- message.attachments = object.attachments ?? new Uint8Array(0);
37485
- message.reactions = object.reactions ?? new Uint8Array(0);
37486
- message.references = object.references ?? new Uint8Array(0);
37491
+ message.mentions = object.mentions?.map((e) => MessageMention.fromPartial(e)) || [];
37492
+ message.attachments = object.attachments?.map((e) => MessageAttachment.fromPartial(e)) || [];
37493
+ message.reactions = object.reactions?.map((e) => MessageReaction.fromPartial(e)) || [];
37494
+ message.references = object.references?.map((e) => MessageRef.fromPartial(e)) || [];
37487
37495
  return message;
37488
37496
  },
37489
37497
  };
package/api.gen.ts CHANGED
@@ -1623,10 +1623,14 @@ export interface ApiMessage2InboxRequest {
1623
1623
  content?: string;
1624
1624
  //
1625
1625
  message_id?: string;
1626
- mentions: Uint8Array;
1627
- attachments: Uint8Array;
1628
- reactions: Uint8Array;
1629
- references: Uint8Array;
1626
+ //
1627
+ reactions?: Array<ApiMessageReaction>;
1628
+ //
1629
+ mentions?: Array<ApiMessageMention>;
1630
+ //
1631
+ attachments?: Array<ApiMessageAttachment>;
1632
+ //
1633
+ references?: Array<ApiMessageRef>;
1630
1634
  }
1631
1635
 
1632
1636
  /** */
@@ -3539,6 +3543,7 @@ export class MezonApi {
3539
3543
  ),
3540
3544
  ]);
3541
3545
  }
3546
+
3542
3547
  checkLoginRequest(
3543
3548
  basicAuthUsername: string,
3544
3549
  basicAuthPassword: string,
@@ -3613,13 +3618,13 @@ export class MezonApi {
3613
3618
  if (response.status == 204) {
3614
3619
  return response;
3615
3620
  } else if (response.status >= 200 && response.status < 300) {
3616
- return response.json();
3621
+ return response;
3617
3622
  } else {
3618
3623
  throw response;
3619
3624
  }
3620
3625
  }),
3621
- new Promise((_, reject) =>
3622
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3626
+ new Promise<never>((_, reject) =>
3627
+ setTimeout(() => reject(new Error("Request timed out.")), this.timeoutMs)
3623
3628
  ),
3624
3629
  ]);
3625
3630
  }
@@ -3652,17 +3657,18 @@ export class MezonApi {
3652
3657
  fetchOptions.headers["Content-Type"] = "application/json";
3653
3658
 
3654
3659
  return Promise.race([
3655
- fetch(fullUrl, fetchOptions).then((response) => {
3660
+ fetch(fullUrl, fetchOptions).then(async (response) => {
3656
3661
  if (response.status == 204) {
3657
3662
  return response;
3658
3663
  } else if (response.status >= 200 && response.status < 300) {
3659
- return response.json();
3664
+ const buffer = await response.arrayBuffer();
3665
+ return tsproto.Session.decode(new Uint8Array(buffer)) as unknown as ApiLoginIDResponse;
3660
3666
  } else {
3661
3667
  throw response;
3662
3668
  }
3663
3669
  }),
3664
- new Promise((_, reject) =>
3665
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3670
+ new Promise<never>((_, reject) =>
3671
+ setTimeout(() => reject(new Error("Request timed out.")), this.timeoutMs)
3666
3672
  ),
3667
3673
  ]);
3668
3674
  }
@@ -3692,17 +3698,18 @@ export class MezonApi {
3692
3698
  fetchOptions.headers["Content-Type"] = "application/json";
3693
3699
 
3694
3700
  return Promise.race([
3695
- fetch(fullUrl, fetchOptions).then((response) => {
3701
+ fetch(fullUrl, fetchOptions).then(async (response) => {
3696
3702
  if (response.status == 204) {
3697
3703
  return response;
3698
3704
  } else if (response.status >= 200 && response.status < 300) {
3699
- return response.json();
3705
+ const buffer = await response.arrayBuffer();
3706
+ return tsproto.Session.decode(new Uint8Array(buffer)) as unknown as ApiLinkAccountConfirmRequest;
3700
3707
  } else {
3701
3708
  throw response;
3702
3709
  }
3703
3710
  }),
3704
- new Promise((_, reject) =>
3705
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3711
+ new Promise<never>((_, reject) =>
3712
+ setTimeout(() => reject(new Error("Request timed out.")), this.timeoutMs)
3706
3713
  ),
3707
3714
  ]);
3708
3715
  }
@@ -3732,17 +3739,18 @@ export class MezonApi {
3732
3739
  fetchOptions.headers["Content-Type"] = "application/json";
3733
3740
 
3734
3741
  return Promise.race([
3735
- fetch(fullUrl, fetchOptions).then((response) => {
3742
+ fetch(fullUrl, fetchOptions).then(async (response) => {
3736
3743
  if (response.status == 204) {
3737
3744
  return response;
3738
3745
  } else if (response.status >= 200 && response.status < 300) {
3739
- return response.json();
3746
+ const buffer = await response.arrayBuffer();
3747
+ return tsproto.Session.decode(new Uint8Array(buffer)) as unknown as ApiLinkAccountConfirmRequest;
3740
3748
  } else {
3741
3749
  throw response;
3742
3750
  }
3743
3751
  }),
3744
- new Promise((_, reject) =>
3745
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3752
+ new Promise<never>((_, reject) =>
3753
+ setTimeout(() => reject(new Error("Request timed out.")), this.timeoutMs)
3746
3754
  ),
3747
3755
  ]);
3748
3756
  }
@@ -3846,14 +3854,19 @@ export class MezonApi {
3846
3854
  "'body' is a required parameter but is null or undefined."
3847
3855
  );
3848
3856
  }
3849
- const urlPath = "/v2/account/link/email";
3857
+ const urlPath = "/mezon.api.Mezon/LinkEmail";
3850
3858
  const queryParams = new Map<string, any>();
3851
3859
 
3852
- let bodyJson: string = "";
3853
- bodyJson = JSON.stringify(body || {});
3860
+ const bodyWriter = tsproto.UpdateAccountRequest.encode(
3861
+ tsproto.UpdateAccountRequest.fromPartial({
3862
+ email: body.email
3863
+ })
3864
+ );
3865
+ const encodedBody = bodyWriter.finish();
3854
3866
 
3855
3867
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3856
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3868
+ const fetchOptions = buildFetchOptions("POST", options, '');
3869
+ fetchOptions.body = encodedBody
3857
3870
  if (bearerToken) {
3858
3871
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3859
3872
  }
@@ -3875,39 +3888,42 @@ export class MezonApi {
3875
3888
  }
3876
3889
 
3877
3890
  /** Add a mezon ID to the social profiles on the current user's account. */
3878
- linkMezon(bearerToken: string,
3879
- body:ApiAccountMezon,
3880
- options: any = {}): Promise<ApiLinkAccountConfirmRequest> {
3881
-
3882
- if (body === null || body === undefined) {
3883
- throw new Error("'body' is a required parameter but is null or undefined.");
3884
- }
3885
- const urlPath = "/v2/account/link/mezon";
3886
- const queryParams = new Map<string, any>();
3887
-
3888
- let bodyJson : string = "";
3889
- bodyJson = JSON.stringify(body || {});
3890
-
3891
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3892
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3893
- if (bearerToken) {
3894
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3895
- }
3896
-
3897
- return Promise.race([
3898
- fetch(fullUrl, fetchOptions).then((response) => {
3899
- if (response.status == 204) {
3900
- return response;
3901
- } else if (response.status >= 200 && response.status < 300) {
3902
- return response.json();
3903
- } else {
3904
- throw response;
3905
- }
3906
- }),
3907
- new Promise((_, reject) =>
3908
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3909
- ),
3910
- ]);
3891
+ linkSMS(bearerToken: string,
3892
+ body:ApiLinkAccountMezon,
3893
+ options: any = {}): Promise<ApiLinkAccountConfirmRequest> {
3894
+
3895
+ if (body === null || body === undefined) {
3896
+ throw new Error("'body' is a required parameter but is null or undefined.");
3897
+ }
3898
+ const urlPath = "/mezon.api.Mezon/LinkSMS";
3899
+ const queryParams = new Map<string, any>();
3900
+
3901
+ const bodyWriter = tsproto.AccountMezon.encode(
3902
+ tsproto.AccountMezon.fromPartial(body)
3903
+ );
3904
+ const encodedBody = bodyWriter.finish();
3905
+
3906
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3907
+ const fetchOptions = buildFetchOptions("POST", options, '');
3908
+ fetchOptions.body = encodedBody;
3909
+ if (bearerToken) {
3910
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3911
+ }
3912
+
3913
+ return Promise.race([
3914
+ fetch(fullUrl, fetchOptions).then((response) => {
3915
+ if (response.status == 204) {
3916
+ return response;
3917
+ } else if (response.status >= 200 && response.status < 300) {
3918
+ return response.json();
3919
+ } else {
3920
+ throw response;
3921
+ }
3922
+ }),
3923
+ new Promise((_, reject) =>
3924
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
3925
+ ),
3926
+ ]);
3911
3927
  }
3912
3928
 
3913
3929
  /** */
@@ -3918,14 +3934,17 @@ export class MezonApi {
3918
3934
  if (body === null || body === undefined) {
3919
3935
  throw new Error("'body' is a required parameter but is null or undefined.");
3920
3936
  }
3921
- const urlPath = "/v2/account/link/confirm";
3937
+ const urlPath = "/mezon.api.Mezon/ConfirmLinkMezonOTP";
3922
3938
  const queryParams = new Map<string, any>();
3923
3939
 
3924
- let bodyJson : string = "";
3925
- bodyJson = JSON.stringify(body || {});
3940
+ const bodyWriter = tsproto.LinkAccountConfirmRequest.encode(
3941
+ tsproto.LinkAccountConfirmRequest.fromPartial(body)
3942
+ );
3943
+ const encodedBody = bodyWriter.finish();
3926
3944
 
3927
3945
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3928
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3946
+ const fetchOptions = buildFetchOptions("POST", options, '');
3947
+ fetchOptions.body = encodedBody;
3929
3948
  if (bearerToken) {
3930
3949
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3931
3950
  }
@@ -6524,14 +6543,21 @@ export class MezonApi {
6524
6543
  "'body' is a required parameter but is null or undefined."
6525
6544
  );
6526
6545
  }
6527
- const urlPath = "/v2/event";
6546
+ const urlPath = "/mezon.api.Mezon/CreateEvent";
6528
6547
  const queryParams = new Map<string, any>();
6529
6548
 
6530
- let bodyJson: string = "";
6531
- bodyJson = JSON.stringify(body || {});
6549
+ const bodyWriter = tsproto.Event.encode(
6550
+ tsproto.Event.fromPartial({
6551
+ external: body.external,
6552
+ name: body.name,
6553
+ properties: body.properties
6554
+ })
6555
+ );
6556
+ const encodedBody = bodyWriter.finish();
6532
6557
 
6533
6558
  const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
6534
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
6559
+ const fetchOptions = buildFetchOptions("POST", options, '');
6560
+ fetchOptions.body = encodedBody
6535
6561
  if (bearerToken) {
6536
6562
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
6537
6563
  }
@@ -6541,7 +6567,7 @@ export class MezonApi {
6541
6567
  if (response.status == 204) {
6542
6568
  return response;
6543
6569
  } else if (response.status >= 200 && response.status < 300) {
6544
- return response.json();
6570
+ return response;
6545
6571
  } else {
6546
6572
  throw response;
6547
6573
  }
@@ -8884,60 +8910,6 @@ export class MezonApi {
8884
8910
  ),
8885
8911
  ]);
8886
8912
  }
8887
-
8888
- /** Execute a Lua function on the server. */
8889
- rpcFunc(
8890
- bearerToken: string,
8891
- basicAuthUsername: string,
8892
- basicAuthPassword: string,
8893
- id: string,
8894
- payload: string,
8895
- httpKey?: string,
8896
- options: any = {}
8897
- ): Promise<ApiRpc> {
8898
- if (id === null || id === undefined) {
8899
- throw new Error("'id' is a required parameter but is null or undefined.");
8900
- }
8901
- if (payload === null || payload === undefined) {
8902
- throw new Error(
8903
- "'payload' is a required parameter but is null or undefined."
8904
- );
8905
- }
8906
- const urlPath = "/v2/rpc/{id}".replace(
8907
- "{id}",
8908
- encodeURIComponent(String(id))
8909
- );
8910
- const queryParams = new Map<string, any>();
8911
- queryParams.set("http_key", httpKey);
8912
-
8913
- let bodyJson: string = "";
8914
- bodyJson = JSON.stringify(payload || {});
8915
-
8916
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
8917
- const fetchOptions = buildFetchOptions("POST", options, bodyJson);
8918
- if (bearerToken) {
8919
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
8920
- }
8921
- if (basicAuthUsername) {
8922
- fetchOptions.headers["Authorization"] =
8923
- "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
8924
- }
8925
-
8926
- return Promise.race([
8927
- fetch(fullUrl, fetchOptions).then((response) => {
8928
- if (response.status == 204) {
8929
- return response;
8930
- } else if (response.status >= 200 && response.status < 300) {
8931
- return response.json();
8932
- } else {
8933
- throw response;
8934
- }
8935
- }),
8936
- new Promise((_, reject) =>
8937
- setTimeout(reject, this.timeoutMs, "Request timed out.")
8938
- ),
8939
- ]);
8940
- }
8941
8913
 
8942
8914
  /** */
8943
8915
  searchThread(bearerToken: string,
package/client.ts CHANGED
@@ -1848,7 +1848,7 @@ export class Client {
1848
1848
  }
1849
1849
 
1850
1850
  /** Add a custom ID to the social profiles on the current user's account. */
1851
- async linkMezon(
1851
+ async linkSMS(
1852
1852
  session: Session,
1853
1853
  request: ApiLinkAccountMezon
1854
1854
  ): Promise<ApiLinkAccountConfirmRequest> {
@@ -1861,7 +1861,7 @@ export class Client {
1861
1861
  }
1862
1862
 
1863
1863
  return this.apiClient
1864
- .linkMezon(session.token, request)
1864
+ .linkSMS(session.token, request)
1865
1865
  .then((response: ApiLinkAccountConfirmRequest) => {
1866
1866
  return Promise.resolve(response);
1867
1867
  });
@@ -1996,40 +1996,6 @@ export class Client {
1996
1996
  });
1997
1997
  }
1998
1998
 
1999
- /** Execute an RPC function on the server. */
2000
- async rpc(
2001
- session: Session,
2002
- basicAuthUsername: string,
2003
- basicAuthPassword: string,
2004
- id: string,
2005
- input: object
2006
- ): Promise<RpcResponse> {
2007
- if (
2008
- this.autoRefreshSession &&
2009
- session.refresh_token &&
2010
- session.isexpired(Date.now() / 1000)
2011
- ) {
2012
- await this.sessionRefresh(session);
2013
- }
2014
-
2015
- return this.apiClient
2016
- .rpcFunc(
2017
- session.token,
2018
- basicAuthUsername,
2019
- basicAuthPassword,
2020
- id,
2021
- JSON.stringify(input)
2022
- )
2023
- .then((response: ApiRpc) => {
2024
- return Promise.resolve({
2025
- id: response.id,
2026
- payload: !response.payload
2027
- ? undefined
2028
- : safeJSONParse(response.payload),
2029
- });
2030
- });
2031
- }
2032
-
2033
1999
  /** Execute an RPC function on the server. */
2034
2000
  async rpcHttpKey(
2035
2001
  httpKey: string,