@mtcute/core 0.23.1 → 0.23.3

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.
Files changed (85) hide show
  1. package/client.cjs +12 -0
  2. package/client.js +12 -0
  3. package/highlevel/client.d.cts +44 -5
  4. package/highlevel/client.d.ts +44 -5
  5. package/highlevel/methods/chats/get-chat-event-log.cjs +5 -3
  6. package/highlevel/methods/chats/get-chat-event-log.js +3 -1
  7. package/highlevel/methods/premium/_normalize-input-star-gift.cjs +6 -0
  8. package/highlevel/methods/premium/_normalize-input-star-gift.js +6 -0
  9. package/highlevel/methods/premium/buy-resale-gift.cjs +30 -0
  10. package/highlevel/methods/premium/buy-resale-gift.d.cts +13 -0
  11. package/highlevel/methods/premium/buy-resale-gift.d.ts +13 -0
  12. package/highlevel/methods/premium/buy-resale-gift.js +25 -0
  13. package/highlevel/methods/premium/get-resale-star-gifts.cjs +107 -0
  14. package/highlevel/methods/premium/get-resale-star-gifts.d.cts +45 -0
  15. package/highlevel/methods/premium/get-resale-star-gifts.d.ts +45 -0
  16. package/highlevel/methods/premium/get-resale-star-gifts.js +102 -0
  17. package/highlevel/methods/premium/get-unique-star-gift.cjs +1 -1
  18. package/highlevel/methods/premium/get-unique-star-gift.js +1 -1
  19. package/highlevel/methods/premium/set-gift-resale-price.cjs +19 -0
  20. package/highlevel/methods/premium/set-gift-resale-price.d.cts +9 -0
  21. package/highlevel/methods/premium/set-gift-resale-price.d.ts +9 -0
  22. package/highlevel/methods/premium/set-gift-resale-price.js +14 -0
  23. package/highlevel/methods/premium/transfer-star-gift.cjs +26 -11
  24. package/highlevel/methods/premium/transfer-star-gift.js +26 -11
  25. package/highlevel/methods/premium/upgrade-star-gift.cjs +26 -11
  26. package/highlevel/methods/premium/upgrade-star-gift.js +26 -11
  27. package/highlevel/methods.d.cts +4 -0
  28. package/highlevel/methods.d.ts +4 -0
  29. package/highlevel/types/messages/message-action.cjs +8 -2
  30. package/highlevel/types/messages/message-action.d.cts +6 -0
  31. package/highlevel/types/messages/message-action.d.ts +6 -0
  32. package/highlevel/types/messages/message-action.js +8 -2
  33. package/highlevel/types/peers/chat-event/actions.cjs +49 -1
  34. package/highlevel/types/peers/chat-event/actions.d.cts +60 -2
  35. package/highlevel/types/peers/chat-event/actions.d.ts +60 -2
  36. package/highlevel/types/peers/chat-event/actions.js +49 -1
  37. package/highlevel/types/peers/chat-event/filters.cjs +9 -0
  38. package/highlevel/types/peers/chat-event/filters.js +9 -0
  39. package/highlevel/types/peers/chat-event/index.cjs +3 -2
  40. package/highlevel/types/peers/chat-event/index.d.cts +2 -1
  41. package/highlevel/types/peers/chat-event/index.d.ts +2 -1
  42. package/highlevel/types/peers/chat-event/index.js +3 -2
  43. package/highlevel/types/peers/chat.cjs +5 -4
  44. package/highlevel/types/peers/chat.d.cts +2 -0
  45. package/highlevel/types/peers/chat.d.ts +2 -0
  46. package/highlevel/types/peers/chat.js +5 -4
  47. package/highlevel/types/peers/user.cjs +1 -4
  48. package/highlevel/types/peers/user.js +1 -4
  49. package/highlevel/types/premium/saved-star-gift.cjs +8 -0
  50. package/highlevel/types/premium/saved-star-gift.d.cts +4 -0
  51. package/highlevel/types/premium/saved-star-gift.d.ts +4 -0
  52. package/highlevel/types/premium/saved-star-gift.js +8 -0
  53. package/highlevel/types/premium/stars-gift-unique.cjs +11 -1
  54. package/highlevel/types/premium/stars-gift-unique.d.cts +4 -0
  55. package/highlevel/types/premium/stars-gift-unique.d.ts +4 -0
  56. package/highlevel/types/premium/stars-gift-unique.js +11 -1
  57. package/highlevel/types/premium/stars-gift.cjs +11 -1
  58. package/highlevel/types/premium/stars-gift.d.cts +8 -1
  59. package/highlevel/types/premium/stars-gift.d.ts +8 -1
  60. package/highlevel/types/premium/stars-gift.js +11 -1
  61. package/highlevel/types/premium/stars-transaction.cjs +6 -0
  62. package/highlevel/types/premium/stars-transaction.d.cts +7 -0
  63. package/highlevel/types/premium/stars-transaction.d.ts +7 -0
  64. package/highlevel/types/premium/stars-transaction.js +6 -0
  65. package/highlevel/types/reactions/emoji-status.cjs +6 -0
  66. package/highlevel/types/reactions/emoji-status.d.cts +1 -0
  67. package/highlevel/types/reactions/emoji-status.d.ts +1 -0
  68. package/highlevel/types/reactions/emoji-status.js +6 -0
  69. package/highlevel/types/utils.d.cts +4 -0
  70. package/highlevel/types/utils.d.ts +4 -0
  71. package/highlevel/utils/misc-utils.cjs +8 -0
  72. package/highlevel/utils/misc-utils.d.cts +2 -1
  73. package/highlevel/utils/misc-utils.d.ts +2 -1
  74. package/highlevel/utils/misc-utils.js +8 -0
  75. package/methods.cjs +6 -0
  76. package/methods.js +6 -0
  77. package/network/network-manager.cjs +1 -1
  78. package/network/network-manager.js +1 -1
  79. package/network/session-connection.cjs +10 -5
  80. package/network/session-connection.js +10 -5
  81. package/package.json +2 -2
  82. package/utils/binary/compat.cjs +9 -0
  83. package/utils/binary/compat.js +9 -0
  84. package/utils.cjs +1 -0
  85. package/utils.js +2 -1
@@ -0,0 +1,45 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { ITelegramClient } from '../../client.types.js';
3
+ import { ArrayPaginatedWithMeta, StarGiftUnique, StarGiftUniqueAttribute, StarGiftUniqueBackdrop } from '../../types/index.js';
4
+ import { MaybeArray } from '@fuman/utils';
5
+ import { default as Long } from 'long';
6
+ import { LongMap } from '../../../utils/long-utils.js';
7
+ export interface InputStarGiftAttributeIds {
8
+ model?: MaybeArray<Long>;
9
+ pattern?: MaybeArray<Long>;
10
+ backdrop?: MaybeArray<number>;
11
+ }
12
+ export declare function _normalizeResaleAttributes(attrs: tl.TypeStarGiftAttributeId[] | InputStarGiftAttributeIds): tl.TypeStarGiftAttributeId[];
13
+ export interface ResaleStarGiftsMeta {
14
+ attributes: {
15
+ model: LongMap<StarGiftUniqueAttribute>;
16
+ pattern: LongMap<StarGiftUniqueAttribute>;
17
+ backdrop: Map<number, StarGiftUniqueBackdrop>;
18
+ };
19
+ attributesHash: tl.Long;
20
+ counters: tl.RawStarGiftAttributeCounter[];
21
+ }
22
+ /**
23
+ * Get a list of star gifts up for resale
24
+ */
25
+ export declare function getResaleOptions(client: ITelegramClient, params: {
26
+ /** ID of the gift to get resale options for */
27
+ giftId: tl.Long;
28
+ /**
29
+ * Sorting attribute
30
+ *
31
+ * - `price`: Sort by price
32
+ * - `num`: Sort by its unique number
33
+ */
34
+ sort?: 'price' | 'num';
35
+ /**
36
+ * Hash of the `attributes` field, as returned by the server in the first response
37
+ */
38
+ attributesHash?: Long;
39
+ /** Attributes to filter for */
40
+ attributes?: tl.TypeStarGiftAttributeId[] | InputStarGiftAttributeIds;
41
+ /** Offset for pagination */
42
+ offset?: string;
43
+ /** Limit for pagination */
44
+ limit?: number;
45
+ }): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
@@ -0,0 +1,102 @@
1
+ import { assert } from "@fuman/utils";
2
+ import Long from "long";
3
+ import { LongMap } from "../../../utils/long-utils.js";
4
+ import { makeArrayPaginatedWithMeta } from "../../utils/misc-utils.js";
5
+ import { StarGiftUniqueAttribute as StarGiftUniqueAttribute$2, StarGiftUniqueBackdrop as StarGiftUniqueBackdrop$1, StarGiftUnique as StarGiftUnique$2 } from "../../types/premium/stars-gift-unique.js";
6
+ import { PeersIndex } from "../../types/peers/peers-index.js";
7
+ function _normalizeResaleAttributes(attrs) {
8
+ if (Array.isArray(attrs)) {
9
+ return attrs;
10
+ }
11
+ const res = [];
12
+ if (attrs.model) {
13
+ if (Array.isArray(attrs.model)) {
14
+ for (const id of attrs.model) {
15
+ res.push({
16
+ _: "starGiftAttributeIdModel",
17
+ documentId: id
18
+ });
19
+ }
20
+ } else {
21
+ res.push({
22
+ _: "starGiftAttributeIdModel",
23
+ documentId: attrs.model
24
+ });
25
+ }
26
+ }
27
+ if (attrs.pattern) {
28
+ if (Array.isArray(attrs.pattern)) {
29
+ for (const id of attrs.pattern) {
30
+ res.push({
31
+ _: "starGiftAttributeIdPattern",
32
+ documentId: id
33
+ });
34
+ }
35
+ } else {
36
+ res.push({
37
+ _: "starGiftAttributeIdPattern",
38
+ documentId: attrs.pattern
39
+ });
40
+ }
41
+ }
42
+ if (attrs.backdrop) {
43
+ if (Array.isArray(attrs.backdrop)) {
44
+ for (const id of attrs.backdrop) {
45
+ res.push({
46
+ _: "starGiftAttributeIdBackdrop",
47
+ backdropId: id
48
+ });
49
+ }
50
+ } else {
51
+ res.push({
52
+ _: "starGiftAttributeIdBackdrop",
53
+ backdropId: attrs.backdrop
54
+ });
55
+ }
56
+ }
57
+ return res;
58
+ }
59
+ async function getResaleOptions(client, params) {
60
+ const res = await client.call({
61
+ _: "payments.getResaleStarGifts",
62
+ sortByNum: params.sort === "num",
63
+ sortByPrice: params.sort === "price",
64
+ attributesHash: params.attributesHash,
65
+ giftId: params.giftId,
66
+ attributes: params.attributes ? _normalizeResaleAttributes(params.attributes) : void 0,
67
+ offset: params.offset ?? "",
68
+ limit: params.limit ?? 100
69
+ });
70
+ const peers = PeersIndex.from(res);
71
+ const attributes = {
72
+ model: new LongMap(),
73
+ pattern: new LongMap(),
74
+ backdrop: /* @__PURE__ */ new Map()
75
+ };
76
+ for (const attr of res.attributes ?? []) {
77
+ if (attr._ === "starGiftAttributeModel") {
78
+ attributes.model.set(attr.document.id, new StarGiftUniqueAttribute$2(attr));
79
+ } else if (attr._ === "starGiftAttributePattern") {
80
+ attributes.pattern.set(attr.document.id, new StarGiftUniqueAttribute$2(attr));
81
+ } else if (attr._ === "starGiftAttributeBackdrop") {
82
+ attributes.backdrop.set(attr.backdropId, new StarGiftUniqueBackdrop$1(attr));
83
+ }
84
+ }
85
+ return makeArrayPaginatedWithMeta(
86
+ res.gifts.map((it) => {
87
+ assert(it._ === "starGiftUnique");
88
+ return new StarGiftUnique$2(it, peers);
89
+ }),
90
+ res.count,
91
+ {
92
+ attributes,
93
+ attributesHash: res.attributesHash ?? params.attributesHash ?? Long.ZERO,
94
+ counters: res.counters ?? []
95
+ },
96
+ res.nextOffset
97
+ );
98
+ }
99
+ export {
100
+ _normalizeResaleAttributes,
101
+ getResaleOptions
102
+ };
@@ -6,8 +6,8 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const utils = require("@fuman/utils");
9
- const starsGiftUnique = require("../../types/premium/stars-gift-unique.cjs");
10
9
  const peersIndex = require("../../types/peers/peers-index.cjs");
10
+ const starsGiftUnique = require("../../types/premium/stars-gift-unique.cjs");
11
11
  async function getUniqueStarGift(client, slug) {
12
12
  const res = await client.call({
13
13
  _: "payments.getUniqueStarGift",
@@ -1,6 +1,6 @@
1
1
  import { assert } from "@fuman/utils";
2
- import { StarGiftUnique as StarGiftUnique$2 } from "../../types/premium/stars-gift-unique.js";
3
2
  import { PeersIndex } from "../../types/peers/peers-index.js";
3
+ import { StarGiftUnique as StarGiftUnique$2 } from "../../types/premium/stars-gift-unique.js";
4
4
  async function getUniqueStarGift(client, slug) {
5
5
  const res = await client.call({
6
6
  _: "payments.getUniqueStarGift",
@@ -0,0 +1,19 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const Long = require("long");
9
+ const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
10
+ async function setResaleStarGiftPrice(client, params) {
11
+ const { gift, price } = params;
12
+ const r = await client.call({
13
+ _: "payments.updateStarGiftPrice",
14
+ stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, gift),
15
+ resellStars: price === null ? Long.ZERO : Long.fromNumber(price)
16
+ });
17
+ client.handleClientUpdate(r);
18
+ }
19
+ exports.setResaleStarGiftPrice = setResaleStarGiftPrice;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/index.js';
3
+ /** Set resale price for an owned star gift */
4
+ export declare function setResaleStarGiftPrice(client: ITelegramClient, params: {
5
+ /** Star gift to update the price of */
6
+ gift: InputStarGift;
7
+ /** New price of the gift (in stars), or `null` to unlist */
8
+ price: number | null;
9
+ }): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/index.js';
3
+ /** Set resale price for an owned star gift */
4
+ export declare function setResaleStarGiftPrice(client: ITelegramClient, params: {
5
+ /** Star gift to update the price of */
6
+ gift: InputStarGift;
7
+ /** New price of the gift (in stars), or `null` to unlist */
8
+ price: number | null;
9
+ }): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import Long from "long";
2
+ import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
3
+ async function setResaleStarGiftPrice(client, params) {
4
+ const { gift, price } = params;
5
+ const r = await client.call({
6
+ _: "payments.updateStarGiftPrice",
7
+ stargift: await _normalizeInputStarGift(client, gift),
8
+ resellStars: price === null ? Long.ZERO : Long.fromNumber(price)
9
+ });
10
+ client.handleClientUpdate(r);
11
+ }
12
+ export {
13
+ setResaleStarGiftPrice
14
+ };
@@ -5,6 +5,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const tl = require("@mtcute/tl");
8
9
  const typeAssertions = require("../../../utils/type-assertions.cjs");
9
10
  const findInUpdate = require("../messages/find-in-update.cjs");
10
11
  const resolvePeer = require("../users/resolve-peer.cjs");
@@ -16,16 +17,30 @@ async function transferStarGift(client, params) {
16
17
  stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, gift),
17
18
  toId: await resolvePeer.resolvePeer(client, recepient)
18
19
  };
19
- const form = await client.call({
20
- _: "payments.getPaymentForm",
21
- invoice
22
- });
23
- const res = await client.call({
24
- _: "payments.sendStarsForm",
25
- invoice,
26
- formId: form.formId
27
- });
28
- typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
29
- return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
20
+ let updates;
21
+ try {
22
+ const form = await client.call({
23
+ _: "payments.getPaymentForm",
24
+ invoice
25
+ });
26
+ const res = await client.call({
27
+ _: "payments.sendStarsForm",
28
+ invoice,
29
+ formId: form.formId
30
+ });
31
+ typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
32
+ updates = res.updates;
33
+ } catch (e) {
34
+ if (tl.tl.RpcError.is(e, "NO_PAYMENT_NEEDED")) {
35
+ updates = await client.call({
36
+ _: "payments.transferStarGift",
37
+ stargift: invoice.stargift,
38
+ toId: invoice.toId
39
+ });
40
+ } else {
41
+ throw e;
42
+ }
43
+ }
44
+ return findInUpdate._findMessageInUpdate(client, updates, false, !shouldDispatch, true);
30
45
  }
31
46
  exports.transferStarGift = transferStarGift;
@@ -1,3 +1,4 @@
1
+ import { tl } from "@mtcute/tl";
1
2
  import { assertTypeIs } from "../../../utils/type-assertions.js";
2
3
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
4
  import { resolvePeer } from "../users/resolve-peer.js";
@@ -9,17 +10,31 @@ async function transferStarGift(client, params) {
9
10
  stargift: await _normalizeInputStarGift(client, gift),
10
11
  toId: await resolvePeer(client, recepient)
11
12
  };
12
- const form = await client.call({
13
- _: "payments.getPaymentForm",
14
- invoice
15
- });
16
- const res = await client.call({
17
- _: "payments.sendStarsForm",
18
- invoice,
19
- formId: form.formId
20
- });
21
- assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
22
- return _findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
13
+ let updates;
14
+ try {
15
+ const form = await client.call({
16
+ _: "payments.getPaymentForm",
17
+ invoice
18
+ });
19
+ const res = await client.call({
20
+ _: "payments.sendStarsForm",
21
+ invoice,
22
+ formId: form.formId
23
+ });
24
+ assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
25
+ updates = res.updates;
26
+ } catch (e) {
27
+ if (tl.RpcError.is(e, "NO_PAYMENT_NEEDED")) {
28
+ updates = await client.call({
29
+ _: "payments.transferStarGift",
30
+ stargift: invoice.stargift,
31
+ toId: invoice.toId
32
+ });
33
+ } else {
34
+ throw e;
35
+ }
36
+ }
37
+ return _findMessageInUpdate(client, updates, false, !shouldDispatch, true);
23
38
  }
24
39
  export {
25
40
  transferStarGift
@@ -5,6 +5,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const tl = require("@mtcute/tl");
8
9
  const typeAssertions = require("../../../utils/type-assertions.cjs");
9
10
  const findInUpdate = require("../messages/find-in-update.cjs");
10
11
  const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
@@ -15,16 +16,30 @@ async function upgradeStarGift(client, params) {
15
16
  stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, gift),
16
17
  keepOriginalDetails
17
18
  };
18
- const form = await client.call({
19
- _: "payments.getPaymentForm",
20
- invoice
21
- });
22
- const res = await client.call({
23
- _: "payments.sendStarsForm",
24
- invoice,
25
- formId: form.formId
26
- });
27
- typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
28
- return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
19
+ let updates;
20
+ try {
21
+ const form = await client.call({
22
+ _: "payments.getPaymentForm",
23
+ invoice
24
+ });
25
+ const res = await client.call({
26
+ _: "payments.sendStarsForm",
27
+ invoice,
28
+ formId: form.formId
29
+ });
30
+ typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
31
+ updates = res.updates;
32
+ } catch (e) {
33
+ if (tl.tl.RpcError.is(e, "NO_PAYMENT_NEEDED")) {
34
+ updates = await client.call({
35
+ _: "payments.upgradeStarGift",
36
+ stargift: invoice.stargift,
37
+ keepOriginalDetails: invoice.keepOriginalDetails
38
+ });
39
+ } else {
40
+ throw e;
41
+ }
42
+ }
43
+ return findInUpdate._findMessageInUpdate(client, updates, false, !shouldDispatch, true);
29
44
  }
30
45
  exports.upgradeStarGift = upgradeStarGift;
@@ -1,3 +1,4 @@
1
+ import { tl } from "@mtcute/tl";
1
2
  import { assertTypeIs } from "../../../utils/type-assertions.js";
2
3
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
4
  import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
@@ -8,17 +9,31 @@ async function upgradeStarGift(client, params) {
8
9
  stargift: await _normalizeInputStarGift(client, gift),
9
10
  keepOriginalDetails
10
11
  };
11
- const form = await client.call({
12
- _: "payments.getPaymentForm",
13
- invoice
14
- });
15
- const res = await client.call({
16
- _: "payments.sendStarsForm",
17
- invoice,
18
- formId: form.formId
19
- });
20
- assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
21
- return _findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
12
+ let updates;
13
+ try {
14
+ const form = await client.call({
15
+ _: "payments.getPaymentForm",
16
+ invoice
17
+ });
18
+ const res = await client.call({
19
+ _: "payments.sendStarsForm",
20
+ invoice,
21
+ formId: form.formId
22
+ });
23
+ assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
24
+ updates = res.updates;
25
+ } catch (e) {
26
+ if (tl.RpcError.is(e, "NO_PAYMENT_NEEDED")) {
27
+ updates = await client.call({
28
+ _: "payments.upgradeStarGift",
29
+ stargift: invoice.stargift,
30
+ keepOriginalDetails: invoice.keepOriginalDetails
31
+ });
32
+ } else {
33
+ throw e;
34
+ }
35
+ }
36
+ return _findMessageInUpdate(client, updates, false, !shouldDispatch, true);
22
37
  }
23
38
  export {
24
39
  upgradeStarGift
@@ -213,6 +213,7 @@ export { removeCloudPassword } from './methods/password/remove-cloud-password.js
213
213
  export { _normalizeInputStarGift } from './methods/premium/_normalize-input-star-gift.js';
214
214
  export { acceptStarGift } from './methods/premium/accept-star-gift.js';
215
215
  export { applyBoost } from './methods/premium/apply-boost.js';
216
+ export { buyResaleGift } from './methods/premium/buy-resale-gift.js';
216
217
  export { canApplyBoost } from './methods/premium/can-apply-boost.js';
217
218
  export type { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
218
219
  export { createBusinessChatLink } from './methods/premium/create-business-chat-link.js';
@@ -223,6 +224,8 @@ export { getBoosts } from './methods/premium/get-boosts.js';
223
224
  export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
224
225
  export { getBusinessConnection } from './methods/premium/get-business-connection.js';
225
226
  export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
227
+ export { getResaleOptions } from './methods/premium/get-resale-star-gifts.js';
228
+ export type { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
226
229
  export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
227
230
  export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
228
231
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
@@ -236,6 +239,7 @@ export { togglePinnedStarGifts } from './methods/premium/pin-star-gift.js';
236
239
  export { sendStarGift } from './methods/premium/send-star-gift.js';
237
240
  export { setBusinessIntro } from './methods/premium/set-business-intro.js';
238
241
  export { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js';
242
+ export { setResaleStarGiftPrice } from './methods/premium/set-gift-resale-price.js';
239
243
  export { transferStarGift } from './methods/premium/transfer-star-gift.js';
240
244
  export { upgradeStarGift } from './methods/premium/upgrade-star-gift.js';
241
245
  export { addStickerToSet } from './methods/stickers/add-sticker-to-set.js';
@@ -213,6 +213,7 @@ export { removeCloudPassword } from './methods/password/remove-cloud-password.js
213
213
  export { _normalizeInputStarGift } from './methods/premium/_normalize-input-star-gift.js';
214
214
  export { acceptStarGift } from './methods/premium/accept-star-gift.js';
215
215
  export { applyBoost } from './methods/premium/apply-boost.js';
216
+ export { buyResaleGift } from './methods/premium/buy-resale-gift.js';
216
217
  export { canApplyBoost } from './methods/premium/can-apply-boost.js';
217
218
  export type { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
218
219
  export { createBusinessChatLink } from './methods/premium/create-business-chat-link.js';
@@ -223,6 +224,8 @@ export { getBoosts } from './methods/premium/get-boosts.js';
223
224
  export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
224
225
  export { getBusinessConnection } from './methods/premium/get-business-connection.js';
225
226
  export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
227
+ export { getResaleOptions } from './methods/premium/get-resale-star-gifts.js';
228
+ export type { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
226
229
  export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
227
230
  export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
228
231
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
@@ -236,6 +239,7 @@ export { togglePinnedStarGifts } from './methods/premium/pin-star-gift.js';
236
239
  export { sendStarGift } from './methods/premium/send-star-gift.js';
237
240
  export { setBusinessIntro } from './methods/premium/set-business-intro.js';
238
241
  export { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js';
242
+ export { setResaleStarGiftPrice } from './methods/premium/set-gift-resale-price.js';
239
243
  export { transferStarGift } from './methods/premium/transfer-star-gift.js';
240
244
  export { upgradeStarGift } from './methods/premium/upgrade-star-gift.js';
241
245
  export { addStickerToSet } from './methods/stickers/add-sticker-to-set.js';
@@ -5,6 +5,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const utils = require("@fuman/utils");
8
9
  const Long = require("long");
9
10
  const peerUtils = require("../../../utils/peer-utils.cjs");
10
11
  const photo = require("../media/photo.cjs");
@@ -286,6 +287,7 @@ function _messageActionFromTl(act) {
286
287
  giveawayMessageId: act.giveawayMsgId
287
288
  };
288
289
  case "messageActionStarGift":
290
+ utils.assert(act.gift._ === "starGift");
289
291
  return {
290
292
  type: "stars_gift",
291
293
  nameHidden: act.nameHidden,
@@ -293,7 +295,7 @@ function _messageActionFromTl(act) {
293
295
  converted: act.converted,
294
296
  convertStars: act.convertStars ?? Long.ZERO,
295
297
  refunded: act.refunded,
296
- gift: act.gift._ === "starGift" ? new starsGift.StarGift(act.gift) : new starsGiftUnique.StarGiftUnique(act.gift, this._peers),
298
+ gift: new starsGift.StarGift(act.gift),
297
299
  message: act.message ?? null,
298
300
  canUpgrade: act.canUpgrade,
299
301
  upgraded: act.upgraded,
@@ -304,6 +306,7 @@ function _messageActionFromTl(act) {
304
306
  savedId: act.savedId
305
307
  };
306
308
  case "messageActionStarGiftUnique":
309
+ utils.assert(act.gift._ === "starGiftUnique");
307
310
  return {
308
311
  type: "stars_gift",
309
312
  nameHidden: false,
@@ -311,12 +314,15 @@ function _messageActionFromTl(act) {
311
314
  converted: false,
312
315
  convertStars: Long.ZERO,
313
316
  refunded: act.refunded,
314
- gift: act.gift._ === "starGift" ? new starsGift.StarGift(act.gift) : new starsGiftUnique.StarGiftUnique(act.gift, this._peers),
317
+ gift: new starsGiftUnique.StarGiftUnique(act.gift, this._peers),
315
318
  message: null,
316
319
  canUpgrade: false,
317
320
  upgraded: true,
318
321
  upgradeStars: Long.ZERO,
319
322
  upgradeMsgId: null,
323
+ canTransferSince: act.canTransferAt ? new Date(act.canTransferAt * 1e3) : void 0,
324
+ resaleStars: act.resaleStars,
325
+ canResellAt: act.canResellAt ? new Date(act.canResellAt * 1e3) : void 0,
320
326
  fromId: act.fromId ? peerUtils.getMarkedPeerId(act.fromId) : void 0,
321
327
  toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
322
328
  savedId: act.savedId
@@ -422,6 +422,12 @@ export interface ActionStarGift {
422
422
  upgradeStars: tl.Long;
423
423
  /** If the gift was upgraded, ID of the message where this happened */
424
424
  upgradeMsgId: number | null;
425
+ /** If the gift can be transferred, date when it can be re-sold */
426
+ canTransferSince?: Date;
427
+ /** Number of stars this gift is up for resell for */
428
+ resaleStars?: tl.Long;
429
+ /** If the gift can be re-sold, date when it will become available */
430
+ canResellAt?: Date;
425
431
  /** The gift itself */
426
432
  gift: StarGift | StarGiftUnique;
427
433
  /** Message attached to the gift */
@@ -422,6 +422,12 @@ export interface ActionStarGift {
422
422
  upgradeStars: tl.Long;
423
423
  /** If the gift was upgraded, ID of the message where this happened */
424
424
  upgradeMsgId: number | null;
425
+ /** If the gift can be transferred, date when it can be re-sold */
426
+ canTransferSince?: Date;
427
+ /** Number of stars this gift is up for resell for */
428
+ resaleStars?: tl.Long;
429
+ /** If the gift can be re-sold, date when it will become available */
430
+ canResellAt?: Date;
425
431
  /** The gift itself */
426
432
  gift: StarGift | StarGiftUnique;
427
433
  /** Message attached to the gift */
@@ -1,3 +1,4 @@
1
+ import { assert } from "@fuman/utils";
1
2
  import Long from "long";
2
3
  import { getMarkedPeerId } from "../../../utils/peer-utils.js";
3
4
  import { Photo as Photo$2 } from "../media/photo.js";
@@ -279,6 +280,7 @@ function _messageActionFromTl(act) {
279
280
  giveawayMessageId: act.giveawayMsgId
280
281
  };
281
282
  case "messageActionStarGift":
283
+ assert(act.gift._ === "starGift");
282
284
  return {
283
285
  type: "stars_gift",
284
286
  nameHidden: act.nameHidden,
@@ -286,7 +288,7 @@ function _messageActionFromTl(act) {
286
288
  converted: act.converted,
287
289
  convertStars: act.convertStars ?? Long.ZERO,
288
290
  refunded: act.refunded,
289
- gift: act.gift._ === "starGift" ? new StarGift$2(act.gift) : new StarGiftUnique$2(act.gift, this._peers),
291
+ gift: new StarGift$2(act.gift),
290
292
  message: act.message ?? null,
291
293
  canUpgrade: act.canUpgrade,
292
294
  upgraded: act.upgraded,
@@ -297,6 +299,7 @@ function _messageActionFromTl(act) {
297
299
  savedId: act.savedId
298
300
  };
299
301
  case "messageActionStarGiftUnique":
302
+ assert(act.gift._ === "starGiftUnique");
300
303
  return {
301
304
  type: "stars_gift",
302
305
  nameHidden: false,
@@ -304,12 +307,15 @@ function _messageActionFromTl(act) {
304
307
  converted: false,
305
308
  convertStars: Long.ZERO,
306
309
  refunded: act.refunded,
307
- gift: act.gift._ === "starGift" ? new StarGift$2(act.gift) : new StarGiftUnique$2(act.gift, this._peers),
310
+ gift: new StarGiftUnique$2(act.gift, this._peers),
308
311
  message: null,
309
312
  canUpgrade: false,
310
313
  upgraded: true,
311
314
  upgradeStars: Long.ZERO,
312
315
  upgradeMsgId: null,
316
+ canTransferSince: act.canTransferAt ? new Date(act.canTransferAt * 1e3) : void 0,
317
+ resaleStars: act.resaleStars,
318
+ canResellAt: act.canResellAt ? new Date(act.canResellAt * 1e3) : void 0,
313
319
  fromId: act.fromId ? getMarkedPeerId(act.fromId) : void 0,
314
320
  toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
315
321
  savedId: act.savedId