@mtcute/core 0.19.10 → 0.20.1

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 (107) hide show
  1. package/client.cjs +20 -0
  2. package/client.js +20 -0
  3. package/highlevel/client.d.cts +64 -9
  4. package/highlevel/client.d.ts +64 -9
  5. package/highlevel/methods/files/normalize-input-media.cjs +12 -2
  6. package/highlevel/methods/files/normalize-input-media.js +12 -2
  7. package/highlevel/methods/messages/forward-messages.cjs +4 -2
  8. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  9. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  10. package/highlevel/methods/messages/forward-messages.js +4 -2
  11. package/highlevel/methods/premium/_normalize-input-star-gift.cjs +23 -0
  12. package/highlevel/methods/premium/_normalize-input-star-gift.d.cts +4 -0
  13. package/highlevel/methods/premium/_normalize-input-star-gift.d.ts +4 -0
  14. package/highlevel/methods/premium/_normalize-input-star-gift.js +18 -0
  15. package/highlevel/methods/premium/accept-star-gift.cjs +4 -3
  16. package/highlevel/methods/premium/accept-star-gift.d.cts +3 -3
  17. package/highlevel/methods/premium/accept-star-gift.d.ts +3 -3
  18. package/highlevel/methods/premium/accept-star-gift.js +4 -3
  19. package/highlevel/methods/premium/get-saved-star-gifts-by-id.cjs +21 -0
  20. package/highlevel/methods/premium/get-saved-star-gifts-by-id.d.cts +6 -0
  21. package/highlevel/methods/premium/get-saved-star-gifts-by-id.d.ts +6 -0
  22. package/highlevel/methods/premium/get-saved-star-gifts-by-id.js +16 -0
  23. package/highlevel/methods/premium/get-saved-star-gifts.cjs +32 -0
  24. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +28 -0
  25. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +28 -0
  26. package/highlevel/methods/premium/get-saved-star-gifts.js +27 -0
  27. package/highlevel/methods/premium/get-star-gift-withdrawal-url.cjs +23 -0
  28. package/highlevel/methods/premium/get-star-gift-withdrawal-url.d.cts +8 -0
  29. package/highlevel/methods/premium/get-star-gift-withdrawal-url.d.ts +8 -0
  30. package/highlevel/methods/premium/get-star-gift-withdrawal-url.js +18 -0
  31. package/highlevel/methods/premium/get-star-gifts.cjs +4 -13
  32. package/highlevel/methods/premium/get-star-gifts.d.cts +3 -2
  33. package/highlevel/methods/premium/get-star-gifts.d.ts +3 -2
  34. package/highlevel/methods/premium/get-star-gifts.js +4 -13
  35. package/highlevel/methods/premium/iter-saved-star-gifts.cjs +33 -0
  36. package/highlevel/methods/premium/iter-saved-star-gifts.d.cts +27 -0
  37. package/highlevel/methods/premium/iter-saved-star-gifts.d.ts +27 -0
  38. package/highlevel/methods/premium/iter-saved-star-gifts.js +28 -0
  39. package/highlevel/methods/premium/send-star-gift.cjs +2 -2
  40. package/highlevel/methods/premium/send-star-gift.d.cts +2 -2
  41. package/highlevel/methods/premium/send-star-gift.d.ts +2 -2
  42. package/highlevel/methods/premium/send-star-gift.js +3 -3
  43. package/highlevel/methods/premium/transfer-star-gift.cjs +4 -4
  44. package/highlevel/methods/premium/transfer-star-gift.d.cts +3 -3
  45. package/highlevel/methods/premium/transfer-star-gift.d.ts +3 -3
  46. package/highlevel/methods/premium/transfer-star-gift.js +5 -5
  47. package/highlevel/methods/premium/upgrade-star-gift.cjs +3 -3
  48. package/highlevel/methods/premium/upgrade-star-gift.d.cts +2 -2
  49. package/highlevel/methods/premium/upgrade-star-gift.d.ts +2 -2
  50. package/highlevel/methods/premium/upgrade-star-gift.js +3 -3
  51. package/highlevel/methods/users/set-emoji-status.cjs +8 -1
  52. package/highlevel/methods/users/set-emoji-status.d.cts +2 -0
  53. package/highlevel/methods/users/set-emoji-status.d.ts +2 -0
  54. package/highlevel/methods/users/set-emoji-status.js +8 -1
  55. package/highlevel/methods.d.cts +5 -0
  56. package/highlevel/methods.d.ts +5 -0
  57. package/highlevel/types/media/input-media/types.d.cts +4 -0
  58. package/highlevel/types/media/input-media/types.d.ts +4 -0
  59. package/highlevel/types/media/video.cjs +8 -0
  60. package/highlevel/types/media/video.d.cts +3 -0
  61. package/highlevel/types/media/video.d.ts +3 -0
  62. package/highlevel/types/media/video.js +8 -0
  63. package/highlevel/types/messages/message-action.cjs +22 -1
  64. package/highlevel/types/messages/message-action.d.cts +4 -0
  65. package/highlevel/types/messages/message-action.d.ts +4 -0
  66. package/highlevel/types/messages/message-action.js +22 -1
  67. package/highlevel/types/peers/chat.cjs +3 -1
  68. package/highlevel/types/peers/chat.js +3 -1
  69. package/highlevel/types/peers/full-chat.cjs +8 -0
  70. package/highlevel/types/peers/full-chat.d.cts +4 -0
  71. package/highlevel/types/peers/full-chat.d.ts +4 -0
  72. package/highlevel/types/peers/full-chat.js +8 -0
  73. package/highlevel/types/peers/user.cjs +3 -1
  74. package/highlevel/types/peers/user.js +3 -1
  75. package/highlevel/types/premium/index.d.cts +1 -0
  76. package/highlevel/types/premium/index.d.ts +1 -0
  77. package/highlevel/types/premium/saved-star-gift.cjs +81 -0
  78. package/highlevel/types/premium/saved-star-gift.d.cts +42 -0
  79. package/highlevel/types/premium/saved-star-gift.d.ts +42 -0
  80. package/highlevel/types/premium/saved-star-gift.js +76 -0
  81. package/highlevel/types/premium/stars-gift-unique.cjs +9 -5
  82. package/highlevel/types/premium/stars-gift-unique.d.cts +7 -5
  83. package/highlevel/types/premium/stars-gift-unique.d.ts +7 -5
  84. package/highlevel/types/premium/stars-gift-unique.js +9 -5
  85. package/highlevel/types/premium/stars-gift.cjs +0 -66
  86. package/highlevel/types/premium/stars-gift.d.cts +12 -40
  87. package/highlevel/types/premium/stars-gift.d.ts +12 -40
  88. package/highlevel/types/premium/stars-gift.js +1 -67
  89. package/highlevel/types/reactions/emoji-status.cjs +38 -1
  90. package/highlevel/types/reactions/emoji-status.d.cts +23 -2
  91. package/highlevel/types/reactions/emoji-status.d.ts +23 -2
  92. package/highlevel/types/reactions/emoji-status.js +39 -2
  93. package/index.cjs +4 -1
  94. package/index.js +5 -2
  95. package/methods.cjs +10 -0
  96. package/methods.js +10 -0
  97. package/network/middlewares/bundle.cjs +4 -0
  98. package/network/middlewares/bundle.d.cts +2 -0
  99. package/network/middlewares/bundle.d.ts +2 -0
  100. package/network/middlewares/bundle.js +4 -0
  101. package/network/middlewares/internal-errors.cjs +3 -1
  102. package/network/middlewares/internal-errors.d.cts +4 -0
  103. package/network/middlewares/internal-errors.d.ts +4 -0
  104. package/network/middlewares/internal-errors.js +3 -1
  105. package/network/network-manager.cjs +1 -1
  106. package/network/network-manager.js +1 -1
  107. package/package.json +2 -2
@@ -1,13 +1,13 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { Message } from '../../types/messages/message.js';
2
+ import { InputStarGift } from '../../types/index.js';
3
3
  /**
4
4
  * Accept, hide or convert a star gift.
5
5
  *
6
6
  * @returns Whether the action was successful
7
7
  */
8
8
  export declare function acceptStarGift(client: ITelegramClient, params: {
9
- /** ID of the message containing the gift */
10
- message: number | Message;
9
+ /** Input star gift to accept */
10
+ gift: InputStarGift;
11
11
  /**
12
12
  * Action to perform on the gift.
13
13
  * - `save` - save the gift to your profile
@@ -1,14 +1,15 @@
1
+ import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
1
2
  async function acceptStarGift(client, params) {
2
3
  const { action } = params;
3
- const message = typeof params.message === "number" ? params.message : params.message.id;
4
+ const inputStarGift = await _normalizeInputStarGift(client, params.gift);
4
5
  return client.call(
5
6
  action === "convert" ? {
6
7
  _: "payments.convertStarGift",
7
- msgId: message
8
+ stargift: inputStarGift
8
9
  } : {
9
10
  _: "payments.saveStarGift",
10
11
  unsave: action === "hide",
11
- msgId: message
12
+ stargift: inputStarGift
12
13
  }
13
14
  );
14
15
  }
@@ -0,0 +1,21 @@
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 utils = require("@fuman/utils");
9
+ const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
10
+ const savedStarGift = require("../../types/premium/saved-star-gift.cjs");
11
+ const peersIndex = require("../../types/peers/peers-index.cjs");
12
+ async function getSavedStarGiftsById(client, gifts) {
13
+ if (!Array.isArray(gifts)) gifts = [gifts];
14
+ const res = await client.call({
15
+ _: "payments.getSavedStarGift",
16
+ stargift: await utils.parallelMap(gifts, (it) => _normalizeInputStarGift._normalizeInputStarGift(client, it), { limit: 10 })
17
+ });
18
+ const peers = peersIndex.PeersIndex.from(res);
19
+ return res.gifts.map((it) => new savedStarGift.SavedStarGift(it, peers));
20
+ }
21
+ exports.getSavedStarGiftsById = getSavedStarGiftsById;
@@ -0,0 +1,6 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/premium/stars-gift.js';
3
+ import { MaybeArray } from '@fuman/utils';
4
+ import { SavedStarGift } from '../../types/index.js';
5
+ /** Get one or more saved star gifts by their IDs */
6
+ export declare function getSavedStarGiftsById(client: ITelegramClient, gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
@@ -0,0 +1,6 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/premium/stars-gift.js';
3
+ import { MaybeArray } from '@fuman/utils';
4
+ import { SavedStarGift } from '../../types/index.js';
5
+ /** Get one or more saved star gifts by their IDs */
6
+ export declare function getSavedStarGiftsById(client: ITelegramClient, gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
@@ -0,0 +1,16 @@
1
+ import { parallelMap } from "@fuman/utils";
2
+ import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
3
+ import { SavedStarGift as SavedStarGift$2 } from "../../types/premium/saved-star-gift.js";
4
+ import { PeersIndex } from "../../types/peers/peers-index.js";
5
+ async function getSavedStarGiftsById(client, gifts) {
6
+ if (!Array.isArray(gifts)) gifts = [gifts];
7
+ const res = await client.call({
8
+ _: "payments.getSavedStarGift",
9
+ stargift: await parallelMap(gifts, (it) => _normalizeInputStarGift(client, it), { limit: 10 })
10
+ });
11
+ const peers = PeersIndex.from(res);
12
+ return res.gifts.map((it) => new SavedStarGift$2(it, peers));
13
+ }
14
+ export {
15
+ getSavedStarGiftsById
16
+ };
@@ -0,0 +1,32 @@
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 savedStarGift = require("../../types/premium/saved-star-gift.cjs");
9
+ const miscUtils = require("../../utils/misc-utils.cjs");
10
+ const resolvePeer = require("../users/resolve-peer.cjs");
11
+ const peersIndex = require("../../types/peers/peers-index.cjs");
12
+ async function getSavedStarGifts(client, params) {
13
+ const res = await client.call({
14
+ _: "payments.getSavedStarGifts",
15
+ peer: await resolvePeer.resolvePeer(client, params.owner),
16
+ excludeUnsaved: params.excludeHidden,
17
+ excludeSaved: params.excludePublic,
18
+ excludeUnlimited: params.excludeUnlimited,
19
+ excludeLimited: params.excludeLimited,
20
+ excludeUnique: params.excludeUnique,
21
+ sortByValue: params.sortByValue,
22
+ offset: params.offset ?? "",
23
+ limit: params.limit ?? 100
24
+ });
25
+ const peers = peersIndex.PeersIndex.from(res);
26
+ return miscUtils.makeArrayPaginated(
27
+ res.gifts.map((it) => new savedStarGift.SavedStarGift(it, peers)),
28
+ res.count,
29
+ res.nextOffset
30
+ );
31
+ }
32
+ exports.getSavedStarGifts = getSavedStarGifts;
@@ -0,0 +1,28 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { ArrayPaginated, InputPeerLike } from '../../types/index.js';
3
+ import { SavedStarGift } from '../../types/premium/saved-star-gift.js';
4
+ /**
5
+ * Get a list of saved star gifts of a user/channel
6
+ *
7
+ * Note that filters currently only work for channels
8
+ */
9
+ export declare function getSavedStarGifts(client: ITelegramClient, params: {
10
+ /** Peer to get saved gifts from */
11
+ owner: InputPeerLike;
12
+ /** Whether to exclude hidden gifts */
13
+ excludeHidden?: boolean;
14
+ /** Whether to exclude publicly visible gifts */
15
+ excludePublic?: boolean;
16
+ /** Whether to exclude gifts with unlimited availability */
17
+ excludeUnlimited?: boolean;
18
+ /** Whether to exclude gifts with limited availability */
19
+ excludeLimited?: boolean;
20
+ /** Whether to exclude unique gifts */
21
+ excludeUnique?: boolean;
22
+ /** Whether to sort by value */
23
+ sortByValue?: boolean;
24
+ /** Offset for pagination */
25
+ offset?: string;
26
+ /** Limit for pagination */
27
+ limit?: number;
28
+ }): Promise<ArrayPaginated<SavedStarGift, string>>;
@@ -0,0 +1,28 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { ArrayPaginated, InputPeerLike } from '../../types/index.js';
3
+ import { SavedStarGift } from '../../types/premium/saved-star-gift.js';
4
+ /**
5
+ * Get a list of saved star gifts of a user/channel
6
+ *
7
+ * Note that filters currently only work for channels
8
+ */
9
+ export declare function getSavedStarGifts(client: ITelegramClient, params: {
10
+ /** Peer to get saved gifts from */
11
+ owner: InputPeerLike;
12
+ /** Whether to exclude hidden gifts */
13
+ excludeHidden?: boolean;
14
+ /** Whether to exclude publicly visible gifts */
15
+ excludePublic?: boolean;
16
+ /** Whether to exclude gifts with unlimited availability */
17
+ excludeUnlimited?: boolean;
18
+ /** Whether to exclude gifts with limited availability */
19
+ excludeLimited?: boolean;
20
+ /** Whether to exclude unique gifts */
21
+ excludeUnique?: boolean;
22
+ /** Whether to sort by value */
23
+ sortByValue?: boolean;
24
+ /** Offset for pagination */
25
+ offset?: string;
26
+ /** Limit for pagination */
27
+ limit?: number;
28
+ }): Promise<ArrayPaginated<SavedStarGift, string>>;
@@ -0,0 +1,27 @@
1
+ import { SavedStarGift as SavedStarGift$2 } from "../../types/premium/saved-star-gift.js";
2
+ import { makeArrayPaginated } from "../../utils/misc-utils.js";
3
+ import { resolvePeer } from "../users/resolve-peer.js";
4
+ import { PeersIndex } from "../../types/peers/peers-index.js";
5
+ async function getSavedStarGifts(client, params) {
6
+ const res = await client.call({
7
+ _: "payments.getSavedStarGifts",
8
+ peer: await resolvePeer(client, params.owner),
9
+ excludeUnsaved: params.excludeHidden,
10
+ excludeSaved: params.excludePublic,
11
+ excludeUnlimited: params.excludeUnlimited,
12
+ excludeLimited: params.excludeLimited,
13
+ excludeUnique: params.excludeUnique,
14
+ sortByValue: params.sortByValue,
15
+ offset: params.offset ?? "",
16
+ limit: params.limit ?? 100
17
+ });
18
+ const peers = PeersIndex.from(res);
19
+ return makeArrayPaginated(
20
+ res.gifts.map((it) => new SavedStarGift$2(it, peers)),
21
+ res.count,
22
+ res.nextOffset
23
+ );
24
+ }
25
+ export {
26
+ getSavedStarGifts
27
+ };
@@ -0,0 +1,23 @@
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 _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
9
+ async function getStarGiftWithdrawalUrl(client, params) {
10
+ const password = await client.computeSrpParams(
11
+ await client.call({
12
+ _: "account.getPassword"
13
+ }),
14
+ params.password
15
+ );
16
+ const res = await client.call({
17
+ _: "payments.getStarGiftWithdrawalUrl",
18
+ stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, params.gift),
19
+ password
20
+ });
21
+ return res.url;
22
+ }
23
+ exports.getStarGiftWithdrawalUrl = getStarGiftWithdrawalUrl;
@@ -0,0 +1,8 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/index.js';
3
+ export declare function getStarGiftWithdrawalUrl(client: ITelegramClient, params: {
4
+ /** The star gift to withdraw */
5
+ gift: InputStarGift;
6
+ /** 2FA password */
7
+ password: string;
8
+ }): Promise<string>;
@@ -0,0 +1,8 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/index.js';
3
+ export declare function getStarGiftWithdrawalUrl(client: ITelegramClient, params: {
4
+ /** The star gift to withdraw */
5
+ gift: InputStarGift;
6
+ /** 2FA password */
7
+ password: string;
8
+ }): Promise<string>;
@@ -0,0 +1,18 @@
1
+ import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
2
+ async function getStarGiftWithdrawalUrl(client, params) {
3
+ const password = await client.computeSrpParams(
4
+ await client.call({
5
+ _: "account.getPassword"
6
+ }),
7
+ params.password
8
+ );
9
+ const res = await client.call({
10
+ _: "payments.getStarGiftWithdrawalUrl",
11
+ stargift: await _normalizeInputStarGift(client, params.gift),
12
+ password
13
+ });
14
+ return res.url;
15
+ }
16
+ export {
17
+ getStarGiftWithdrawalUrl
18
+ };
@@ -5,20 +5,11 @@ 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 peersIndex = require("../../types/peers/peers-index.cjs");
9
- const starsGift = require("../../types/premium/stars-gift.cjs");
10
- const miscUtils = require("../../utils/misc-utils.cjs");
11
- const resolvePeer = require("../users/resolve-peer.cjs");
8
+ const getSavedStarGifts = require("./get-saved-star-gifts.cjs");
12
9
  async function getStarGifts(client, userId, params) {
13
- const { offset = "", limit = 100 } = params ?? {};
14
- const res = await client.call({
15
- _: "payments.getUserStarGifts",
16
- userId: await resolvePeer.resolveUser(client, userId),
17
- offset,
18
- limit
10
+ return getSavedStarGifts.getSavedStarGifts(client, {
11
+ owner: userId,
12
+ ...params
19
13
  });
20
- const peers = peersIndex.PeersIndex.from(res);
21
- const gifts = res.gifts.map((gift) => new starsGift.UserStarGift(gift, peers));
22
- return miscUtils.makeArrayPaginated(gifts, res.count, res.nextOffset);
23
14
  }
24
15
  exports.getStarGifts = getStarGifts;
@@ -1,11 +1,12 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
+ import { SavedStarGift } from '../../types/index.js';
2
3
  import { InputPeerLike } from '../../types/peers/peer.js';
3
4
  import { ArrayPaginated } from '../../types/utils.js';
4
- import { UserStarGift } from '../../types/premium/stars-gift.js';
5
5
  /**
6
6
  * Get a list of gifts sent to a user.
7
7
  *
8
8
  * @param userId User whose gifts to fetch
9
+ * @deprecated Use {@link getSavedStarGifts} instead
9
10
  * @returns Gifts sent to the user
10
11
  */
11
12
  export declare function getStarGifts(client: ITelegramClient, userId: InputPeerLike, params?: {
@@ -19,4 +20,4 @@ export declare function getStarGifts(client: ITelegramClient, userId: InputPeerL
19
20
  * @default 100
20
21
  */
21
22
  limit?: number;
22
- }): Promise<ArrayPaginated<UserStarGift, string>>;
23
+ }): Promise<ArrayPaginated<SavedStarGift, string>>;
@@ -1,11 +1,12 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
+ import { SavedStarGift } from '../../types/index.js';
2
3
  import { InputPeerLike } from '../../types/peers/peer.js';
3
4
  import { ArrayPaginated } from '../../types/utils.js';
4
- import { UserStarGift } from '../../types/premium/stars-gift.js';
5
5
  /**
6
6
  * Get a list of gifts sent to a user.
7
7
  *
8
8
  * @param userId User whose gifts to fetch
9
+ * @deprecated Use {@link getSavedStarGifts} instead
9
10
  * @returns Gifts sent to the user
10
11
  */
11
12
  export declare function getStarGifts(client: ITelegramClient, userId: InputPeerLike, params?: {
@@ -19,4 +20,4 @@ export declare function getStarGifts(client: ITelegramClient, userId: InputPeerL
19
20
  * @default 100
20
21
  */
21
22
  limit?: number;
22
- }): Promise<ArrayPaginated<UserStarGift, string>>;
23
+ }): Promise<ArrayPaginated<SavedStarGift, string>>;
@@ -1,18 +1,9 @@
1
- import { PeersIndex } from "../../types/peers/peers-index.js";
2
- import { UserStarGift as UserStarGift$2 } from "../../types/premium/stars-gift.js";
3
- import { makeArrayPaginated } from "../../utils/misc-utils.js";
4
- import { resolveUser } from "../users/resolve-peer.js";
1
+ import { getSavedStarGifts } from "./get-saved-star-gifts.js";
5
2
  async function getStarGifts(client, userId, params) {
6
- const { offset = "", limit = 100 } = params ?? {};
7
- const res = await client.call({
8
- _: "payments.getUserStarGifts",
9
- userId: await resolveUser(client, userId),
10
- offset,
11
- limit
3
+ return getSavedStarGifts(client, {
4
+ owner: userId,
5
+ ...params
12
6
  });
13
- const peers = PeersIndex.from(res);
14
- const gifts = res.gifts.map((gift) => new UserStarGift$2(gift, peers));
15
- return makeArrayPaginated(gifts, res.count, res.nextOffset);
16
7
  }
17
8
  export {
18
9
  getStarGifts
@@ -0,0 +1,33 @@
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 savedStarGift = require("../../types/premium/saved-star-gift.cjs");
9
+ const resolvePeer = require("../users/resolve-peer.cjs");
10
+ const peersIndex = require("../../types/peers/peers-index.cjs");
11
+ async function* iterSavedStarGifts(client, params) {
12
+ const owner = await resolvePeer.resolvePeer(client, params.owner);
13
+ let offset = "";
14
+ while (true) {
15
+ const res = await client.call({
16
+ _: "payments.getSavedStarGifts",
17
+ peer: owner,
18
+ excludeUnsaved: params.excludeUnsaved,
19
+ excludeSaved: params.excludeSaved,
20
+ excludeUnlimited: params.excludeUnlimited,
21
+ excludeLimited: params.excludeLimited,
22
+ excludeUnique: params.excludeUnique,
23
+ sortByValue: params.sortByValue,
24
+ offset,
25
+ limit: params.limit ?? 100
26
+ });
27
+ const peers = peersIndex.PeersIndex.from(res);
28
+ yield* res.gifts.map((it) => new savedStarGift.SavedStarGift(it, peers));
29
+ if (!res.nextOffset) break;
30
+ offset = res.nextOffset;
31
+ }
32
+ }
33
+ exports.iterSavedStarGifts = iterSavedStarGifts;
@@ -0,0 +1,27 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/index.js';
3
+ import { SavedStarGift } from '../../types/premium/saved-star-gift.js';
4
+ /**
5
+ * Iterate over saved star gifts of a user,
6
+ * wrapper over {@link getSavedStarGifts}
7
+ */
8
+ export declare function iterSavedStarGifts(client: ITelegramClient, params: {
9
+ /** Peer to get saved gifts from */
10
+ owner: InputPeerLike;
11
+ /** Whether to exclude unsaved gifts */
12
+ excludeUnsaved?: boolean;
13
+ /** Whether to exclude saved gifts */
14
+ excludeSaved?: boolean;
15
+ /** Whether to exclude gifts with unlimited availability */
16
+ excludeUnlimited?: boolean;
17
+ /** Whether to exclude gifts with limited availability */
18
+ excludeLimited?: boolean;
19
+ /** Whether to exclude unique gifts */
20
+ excludeUnique?: boolean;
21
+ /** Whether to sort by value */
22
+ sortByValue?: boolean;
23
+ /** Offset for pagination */
24
+ offset?: string;
25
+ /** Limit for pagination */
26
+ limit?: number;
27
+ }): AsyncIterableIterator<SavedStarGift>;
@@ -0,0 +1,27 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/index.js';
3
+ import { SavedStarGift } from '../../types/premium/saved-star-gift.js';
4
+ /**
5
+ * Iterate over saved star gifts of a user,
6
+ * wrapper over {@link getSavedStarGifts}
7
+ */
8
+ export declare function iterSavedStarGifts(client: ITelegramClient, params: {
9
+ /** Peer to get saved gifts from */
10
+ owner: InputPeerLike;
11
+ /** Whether to exclude unsaved gifts */
12
+ excludeUnsaved?: boolean;
13
+ /** Whether to exclude saved gifts */
14
+ excludeSaved?: boolean;
15
+ /** Whether to exclude gifts with unlimited availability */
16
+ excludeUnlimited?: boolean;
17
+ /** Whether to exclude gifts with limited availability */
18
+ excludeLimited?: boolean;
19
+ /** Whether to exclude unique gifts */
20
+ excludeUnique?: boolean;
21
+ /** Whether to sort by value */
22
+ sortByValue?: boolean;
23
+ /** Offset for pagination */
24
+ offset?: string;
25
+ /** Limit for pagination */
26
+ limit?: number;
27
+ }): AsyncIterableIterator<SavedStarGift>;
@@ -0,0 +1,28 @@
1
+ import { SavedStarGift as SavedStarGift$2 } from "../../types/premium/saved-star-gift.js";
2
+ import { resolvePeer } from "../users/resolve-peer.js";
3
+ import { PeersIndex } from "../../types/peers/peers-index.js";
4
+ async function* iterSavedStarGifts(client, params) {
5
+ const owner = await resolvePeer(client, params.owner);
6
+ let offset = "";
7
+ while (true) {
8
+ const res = await client.call({
9
+ _: "payments.getSavedStarGifts",
10
+ peer: owner,
11
+ excludeUnsaved: params.excludeUnsaved,
12
+ excludeSaved: params.excludeSaved,
13
+ excludeUnlimited: params.excludeUnlimited,
14
+ excludeLimited: params.excludeLimited,
15
+ excludeUnique: params.excludeUnique,
16
+ sortByValue: params.sortByValue,
17
+ offset,
18
+ limit: params.limit ?? 100
19
+ });
20
+ const peers = PeersIndex.from(res);
21
+ yield* res.gifts.map((it) => new SavedStarGift$2(it, peers));
22
+ if (!res.nextOffset) break;
23
+ offset = res.nextOffset;
24
+ }
25
+ }
26
+ export {
27
+ iterSavedStarGifts
28
+ };
@@ -12,7 +12,7 @@ const findInUpdate = require("../messages/find-in-update.cjs");
12
12
  const resolvePeer = require("../users/resolve-peer.cjs");
13
13
  async function sendStarGift(client, params) {
14
14
  const {
15
- userId,
15
+ peerId,
16
16
  gift,
17
17
  anonymous,
18
18
  message,
@@ -22,7 +22,7 @@ async function sendStarGift(client, params) {
22
22
  const invoice = {
23
23
  _: "inputInvoiceStarGift",
24
24
  hideName: anonymous,
25
- userId: await resolvePeer.resolveUser(client, userId),
25
+ peer: await resolvePeer.resolvePeer(client, peerId),
26
26
  giftId: Long.isLong(gift) ? gift : gift.id,
27
27
  message: message ? entities.inputTextToTl(message) : void 0,
28
28
  includeUpgrade: withUpgrade
@@ -15,8 +15,8 @@ import { InputText } from '../../types/misc/entities.js';
15
15
  * @returns Service message about the sent gift
16
16
  */
17
17
  export declare function sendStarGift(client: ITelegramClient, params: {
18
- /** ID of the user to send the gift to */
19
- userId: InputPeerLike;
18
+ /** ID of the peer to send the gift to */
19
+ peerId: InputPeerLike;
20
20
  /** ID of the gift to send */
21
21
  gift: Long | StarGift;
22
22
  /**
@@ -15,8 +15,8 @@ import { InputText } from '../../types/misc/entities.js';
15
15
  * @returns Service message about the sent gift
16
16
  */
17
17
  export declare function sendStarGift(client: ITelegramClient, params: {
18
- /** ID of the user to send the gift to */
19
- userId: InputPeerLike;
18
+ /** ID of the peer to send the gift to */
19
+ peerId: InputPeerLike;
20
20
  /** ID of the gift to send */
21
21
  gift: Long | StarGift;
22
22
  /**
@@ -2,10 +2,10 @@ import Long from "long";
2
2
  import { assertTypeIs } from "../../../utils/type-assertions.js";
3
3
  import { inputTextToTl } from "../../types/misc/entities.js";
4
4
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
5
- import { resolveUser } from "../users/resolve-peer.js";
5
+ import { resolvePeer } from "../users/resolve-peer.js";
6
6
  async function sendStarGift(client, params) {
7
7
  const {
8
- userId,
8
+ peerId,
9
9
  gift,
10
10
  anonymous,
11
11
  message,
@@ -15,7 +15,7 @@ async function sendStarGift(client, params) {
15
15
  const invoice = {
16
16
  _: "inputInvoiceStarGift",
17
17
  hideName: anonymous,
18
- userId: await resolveUser(client, userId),
18
+ peer: await resolvePeer(client, peerId),
19
19
  giftId: Long.isLong(gift) ? gift : gift.id,
20
20
  message: message ? inputTextToTl(message) : void 0,
21
21
  includeUpgrade: withUpgrade
@@ -8,13 +8,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const typeAssertions = require("../../../utils/type-assertions.cjs");
9
9
  const findInUpdate = require("../messages/find-in-update.cjs");
10
10
  const resolvePeer = require("../users/resolve-peer.cjs");
11
+ const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
11
12
  async function transferStarGift(client, params) {
12
- const { message, recepient, shouldDispatch } = params;
13
- const msgId = typeof message === "number" ? message : message.id;
13
+ const { gift, recepient, shouldDispatch } = params;
14
14
  const invoice = {
15
15
  _: "inputInvoiceStarGiftTransfer",
16
- msgId,
17
- toId: await resolvePeer.resolveUser(client, recepient)
16
+ stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, gift),
17
+ toId: await resolvePeer.resolvePeer(client, recepient)
18
18
  };
19
19
  const form = await client.call({
20
20
  _: "payments.getPaymentForm",
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike } from '../../types/index.js';
2
+ import { InputPeerLike, InputStarGift } from '../../types/index.js';
3
3
  import { Message } from '../../types/messages/message.js';
4
4
  /**
5
5
  * Transfer a unique star gift.
@@ -12,8 +12,8 @@ import { Message } from '../../types/messages/message.js';
12
12
  * @returns Service message about the transferred gift
13
13
  */
14
14
  export declare function transferStarGift(client: ITelegramClient, params: {
15
- /** ID of the message containing the gift */
16
- message: number | Message;
15
+ /** Star gift to transfer */
16
+ gift: InputStarGift;
17
17
  /** ID of the user to transfer the gift to */
18
18
  recepient: InputPeerLike;
19
19
  /**
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike } from '../../types/index.js';
2
+ import { InputPeerLike, InputStarGift } from '../../types/index.js';
3
3
  import { Message } from '../../types/messages/message.js';
4
4
  /**
5
5
  * Transfer a unique star gift.
@@ -12,8 +12,8 @@ import { Message } from '../../types/messages/message.js';
12
12
  * @returns Service message about the transferred gift
13
13
  */
14
14
  export declare function transferStarGift(client: ITelegramClient, params: {
15
- /** ID of the message containing the gift */
16
- message: number | Message;
15
+ /** Star gift to transfer */
16
+ gift: InputStarGift;
17
17
  /** ID of the user to transfer the gift to */
18
18
  recepient: InputPeerLike;
19
19
  /**
@@ -1,13 +1,13 @@
1
1
  import { assertTypeIs } from "../../../utils/type-assertions.js";
2
2
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
- import { resolveUser } from "../users/resolve-peer.js";
3
+ import { resolvePeer } from "../users/resolve-peer.js";
4
+ import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
4
5
  async function transferStarGift(client, params) {
5
- const { message, recepient, shouldDispatch } = params;
6
- const msgId = typeof message === "number" ? message : message.id;
6
+ const { gift, recepient, shouldDispatch } = params;
7
7
  const invoice = {
8
8
  _: "inputInvoiceStarGiftTransfer",
9
- msgId,
10
- toId: await resolveUser(client, recepient)
9
+ stargift: await _normalizeInputStarGift(client, gift),
10
+ toId: await resolvePeer(client, recepient)
11
11
  };
12
12
  const form = await client.call({
13
13
  _: "payments.getPaymentForm",