@mtcute/core 0.22.2 → 0.23.0

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 (105) hide show
  1. package/client.cjs +1 -1
  2. package/client.js +1 -1
  3. package/highlevel/base.cjs +1 -0
  4. package/highlevel/base.js +1 -0
  5. package/highlevel/client.d.cts +7 -3
  6. package/highlevel/client.d.ts +7 -3
  7. package/highlevel/methods/auth/send-code.cjs +8 -2
  8. package/highlevel/methods/auth/send-code.d.cts +4 -2
  9. package/highlevel/methods/auth/send-code.d.ts +4 -2
  10. package/highlevel/methods/auth/send-code.js +8 -2
  11. package/highlevel/methods/auth/start.cjs +6 -1
  12. package/highlevel/methods/auth/start.d.cts +1 -1
  13. package/highlevel/methods/auth/start.d.ts +1 -1
  14. package/highlevel/methods/auth/start.js +6 -1
  15. package/highlevel/methods/chats/open-chat.cjs +1 -1
  16. package/highlevel/methods/chats/open-chat.js +1 -1
  17. package/highlevel/methods/dialogs/find-dialogs.cjs +3 -1
  18. package/highlevel/methods/dialogs/find-dialogs.js +3 -1
  19. package/highlevel/methods/dialogs/get-peer-dialogs.cjs +49 -11
  20. package/highlevel/methods/dialogs/get-peer-dialogs.d.cts +1 -1
  21. package/highlevel/methods/dialogs/get-peer-dialogs.d.ts +1 -1
  22. package/highlevel/methods/dialogs/get-peer-dialogs.js +49 -11
  23. package/highlevel/methods/files/normalize-input-file.d.cts +1 -0
  24. package/highlevel/methods/files/normalize-input-file.d.ts +1 -0
  25. package/highlevel/methods/files/normalize-input-media.cjs +13 -6
  26. package/highlevel/methods/files/normalize-input-media.d.cts +1 -0
  27. package/highlevel/methods/files/normalize-input-media.d.ts +1 -0
  28. package/highlevel/methods/files/normalize-input-media.js +13 -6
  29. package/highlevel/methods/files/upload-file.cjs +6 -3
  30. package/highlevel/methods/files/upload-file.d.cts +1 -0
  31. package/highlevel/methods/files/upload-file.d.ts +1 -0
  32. package/highlevel/methods/files/upload-file.js +6 -3
  33. package/highlevel/methods/messages/send-common.d.cts +1 -0
  34. package/highlevel/methods/messages/send-common.d.ts +1 -0
  35. package/highlevel/methods/messages/send-media-group.cjs +3 -2
  36. package/highlevel/methods/messages/send-media-group.js +3 -2
  37. package/highlevel/methods/messages/send-media.cjs +3 -2
  38. package/highlevel/methods/messages/send-media.js +3 -2
  39. package/highlevel/methods/messages/send-text.cjs +1 -1
  40. package/highlevel/methods/messages/send-text.js +1 -1
  41. package/highlevel/methods/users/resolve-peer-many.cjs +8 -43
  42. package/highlevel/methods/users/resolve-peer-many.js +9 -44
  43. package/highlevel/storage/service/peers.cjs +37 -9
  44. package/highlevel/storage/service/peers.d.cts +4 -0
  45. package/highlevel/storage/service/peers.d.ts +4 -0
  46. package/highlevel/storage/service/peers.js +38 -10
  47. package/highlevel/storage/storage.cjs +3 -0
  48. package/highlevel/storage/storage.d.cts +1 -0
  49. package/highlevel/storage/storage.d.ts +1 -0
  50. package/highlevel/storage/storage.js +3 -0
  51. package/highlevel/types/conversation.cjs +3 -4
  52. package/highlevel/types/conversation.js +3 -4
  53. package/highlevel/types/messages/message-action.cjs +11 -0
  54. package/highlevel/types/messages/message-action.d.cts +15 -1
  55. package/highlevel/types/messages/message-action.d.ts +15 -1
  56. package/highlevel/types/messages/message-action.js +11 -0
  57. package/highlevel/types/peers/full-user.cjs +8 -0
  58. package/highlevel/types/peers/full-user.d.cts +4 -0
  59. package/highlevel/types/peers/full-user.d.ts +4 -0
  60. package/highlevel/types/peers/full-user.js +8 -0
  61. package/highlevel/types/peers/peers-index.cjs +10 -0
  62. package/highlevel/types/peers/peers-index.d.cts +1 -0
  63. package/highlevel/types/peers/peers-index.d.ts +1 -0
  64. package/highlevel/types/peers/peers-index.js +10 -0
  65. package/highlevel/types/premium/business-connection.cjs +3 -3
  66. package/highlevel/types/premium/business-connection.d.cts +2 -2
  67. package/highlevel/types/premium/business-connection.d.ts +2 -2
  68. package/highlevel/types/premium/business-connection.js +3 -3
  69. package/highlevel/types/premium/saved-star-gift.cjs +2 -2
  70. package/highlevel/types/premium/saved-star-gift.d.cts +2 -2
  71. package/highlevel/types/premium/saved-star-gift.d.ts +2 -2
  72. package/highlevel/types/premium/saved-star-gift.js +2 -2
  73. package/highlevel/types/premium/stars-gift-unique.cjs +11 -1
  74. package/highlevel/types/premium/stars-gift-unique.d.cts +7 -1
  75. package/highlevel/types/premium/stars-gift-unique.d.ts +7 -1
  76. package/highlevel/types/premium/stars-gift-unique.js +11 -1
  77. package/highlevel/types/premium/stars-transaction.cjs +4 -0
  78. package/highlevel/types/premium/stars-transaction.d.cts +2 -0
  79. package/highlevel/types/premium/stars-transaction.d.ts +2 -0
  80. package/highlevel/types/premium/stars-transaction.js +4 -0
  81. package/highlevel/worker/storage.cjs +4 -0
  82. package/highlevel/worker/storage.d.cts +2 -0
  83. package/highlevel/worker/storage.d.ts +2 -0
  84. package/highlevel/worker/storage.js +4 -0
  85. package/index.cjs +8 -0
  86. package/index.js +8 -0
  87. package/network/middlewares/flood-waiter.cjs +18 -2
  88. package/network/middlewares/flood-waiter.d.cts +9 -2
  89. package/network/middlewares/flood-waiter.d.ts +9 -2
  90. package/network/middlewares/flood-waiter.js +18 -2
  91. package/network/network-manager.cjs +1 -1
  92. package/network/network-manager.d.cts +1 -1
  93. package/network/network-manager.d.ts +1 -1
  94. package/network/network-manager.js +1 -1
  95. package/network/session-connection.cjs +3 -1
  96. package/network/session-connection.js +3 -1
  97. package/package.json +7 -7
  98. package/storage/memory/index.cjs +4 -0
  99. package/storage/memory/index.d.cts +4 -0
  100. package/storage/memory/index.d.ts +4 -0
  101. package/storage/memory/index.js +4 -0
  102. package/utils/binary/compat.cjs +2 -0
  103. package/utils/binary/compat.js +2 -0
  104. package/utils/early-timer.cjs +7 -2
  105. package/utils/early-timer.js +7 -2
@@ -349,7 +349,7 @@ class Conversation {
349
349
  throw new errors.MtArgumentError("Provide message for which to wait for read for");
350
350
  }
351
351
  const [dialog] = await getPeerDialogs.getPeerDialogs(this.client, this._inputPeer);
352
- if (dialog.lastRead >= msgId) return;
352
+ if (!dialog || dialog.lastRead >= msgId) return;
353
353
  const promise = new utils.Deferred();
354
354
  let timer;
355
355
  if (timeout !== null) {
@@ -425,10 +425,9 @@ class Conversation {
425
425
  }
426
426
  _processRecentEdits() {
427
427
  if (!this._recentEdits.length) return;
428
- const iter = this._recentEdits[Symbol.iterator]();
429
428
  let it;
430
- while (!(it = iter.next()).done) {
431
- this._onEditMessage(it.value, true);
429
+ while (it = this._recentEdits.popFront()) {
430
+ this._onEditMessage(it, true);
432
431
  }
433
432
  }
434
433
  }
@@ -342,7 +342,7 @@ class Conversation {
342
342
  throw new MtArgumentError("Provide message for which to wait for read for");
343
343
  }
344
344
  const [dialog] = await getPeerDialogs(this.client, this._inputPeer);
345
- if (dialog.lastRead >= msgId) return;
345
+ if (!dialog || dialog.lastRead >= msgId) return;
346
346
  const promise = new Deferred();
347
347
  let timer;
348
348
  if (timeout !== null) {
@@ -418,10 +418,9 @@ class Conversation {
418
418
  }
419
419
  _processRecentEdits() {
420
420
  if (!this._recentEdits.length) return;
421
- const iter = this._recentEdits[Symbol.iterator]();
422
421
  let it;
423
- while (!(it = iter.next()).done) {
424
- this._onEditMessage(it.value, true);
422
+ while (it = this._recentEdits.popFront()) {
423
+ this._onEditMessage(it, true);
425
424
  }
426
425
  }
427
426
  }
@@ -321,6 +321,17 @@ function _messageActionFromTl(act) {
321
321
  toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
322
322
  savedId: act.savedId
323
323
  };
324
+ case "messageActionPaidMessagesPrice":
325
+ return {
326
+ type: "messages_paid",
327
+ stars: act.stars
328
+ };
329
+ case "messageActionPaidMessagesRefunded":
330
+ return {
331
+ type: "messages_refunded",
332
+ stars: act.stars,
333
+ count: act.count
334
+ };
324
335
  default:
325
336
  return null;
326
337
  }
@@ -430,6 +430,20 @@ export interface ActionStarGift {
430
430
  toId?: number;
431
431
  savedId?: Long;
432
432
  }
433
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | null;
433
+ /** Paid messages were paid for */
434
+ export interface ActionPaidMessagesPaid {
435
+ readonly type: 'messages_paid';
436
+ /** Amount of Telegram Stars paid */
437
+ stars: tl.Long;
438
+ }
439
+ /** Paid messages were refunded */
440
+ export interface ActionPaidMessagesRefunded {
441
+ readonly type: 'messages_refunded';
442
+ /** Amount of Telegram Stars refunded */
443
+ stars: tl.Long;
444
+ /** Count of messages refunded */
445
+ count: number;
446
+ }
447
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | null;
434
448
  /** @internal */
435
449
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
@@ -430,6 +430,20 @@ export interface ActionStarGift {
430
430
  toId?: number;
431
431
  savedId?: Long;
432
432
  }
433
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | null;
433
+ /** Paid messages were paid for */
434
+ export interface ActionPaidMessagesPaid {
435
+ readonly type: 'messages_paid';
436
+ /** Amount of Telegram Stars paid */
437
+ stars: tl.Long;
438
+ }
439
+ /** Paid messages were refunded */
440
+ export interface ActionPaidMessagesRefunded {
441
+ readonly type: 'messages_refunded';
442
+ /** Amount of Telegram Stars refunded */
443
+ stars: tl.Long;
444
+ /** Count of messages refunded */
445
+ count: number;
446
+ }
447
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | null;
434
448
  /** @internal */
435
449
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
@@ -314,6 +314,17 @@ function _messageActionFromTl(act) {
314
314
  toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
315
315
  savedId: act.savedId
316
316
  };
317
+ case "messageActionPaidMessagesPrice":
318
+ return {
319
+ type: "messages_paid",
320
+ stars: act.stars
321
+ };
322
+ case "messageActionPaidMessagesRefunded":
323
+ return {
324
+ type: "messages_refunded",
325
+ stars: act.stars,
326
+ count: act.count
327
+ };
317
328
  default:
318
329
  return null;
319
330
  }
@@ -194,6 +194,14 @@ class FullUser extends user.User {
194
194
  get ttlPeriod() {
195
195
  return this.full?.ttlPeriod ?? null;
196
196
  }
197
+ /** Whether the "Gifts" tab should be shown */
198
+ get showGifts() {
199
+ return this.full.displayGiftsButton;
200
+ }
201
+ /** Information about the user's gift receive settings */
202
+ get disallowedGifts() {
203
+ return this.full.disallowedGifts ?? null;
204
+ }
197
205
  /**
198
206
  * If this is a business account, information about the business.
199
207
  */
@@ -109,6 +109,10 @@ export declare class FullUser extends User {
109
109
  * TTL of all messages in this chat, in seconds
110
110
  */
111
111
  get ttlPeriod(): number | null;
112
+ /** Whether the "Gifts" tab should be shown */
113
+ get showGifts(): boolean;
114
+ /** Information about the user's gift receive settings */
115
+ get disallowedGifts(): tl.TypeDisallowedGiftsSettings | null;
112
116
  /**
113
117
  * If this is a business account, information about the business.
114
118
  */
@@ -109,6 +109,10 @@ export declare class FullUser extends User {
109
109
  * TTL of all messages in this chat, in seconds
110
110
  */
111
111
  get ttlPeriod(): number | null;
112
+ /** Whether the "Gifts" tab should be shown */
113
+ get showGifts(): boolean;
114
+ /** Information about the user's gift receive settings */
115
+ get disallowedGifts(): tl.TypeDisallowedGiftsSettings | null;
112
116
  /**
113
117
  * If this is a business account, information about the business.
114
118
  */
@@ -187,6 +187,14 @@ class FullUser extends User$2 {
187
187
  get ttlPeriod() {
188
188
  return this.full?.ttlPeriod ?? null;
189
189
  }
190
+ /** Whether the "Gifts" tab should be shown */
191
+ get showGifts() {
192
+ return this.full.displayGiftsButton;
193
+ }
194
+ /** Information about the user's gift receive settings */
195
+ get disallowedGifts() {
196
+ return this.full.disallowedGifts ?? null;
197
+ }
190
198
  /**
191
199
  * If this is a business account, information about the business.
192
200
  */
@@ -56,5 +56,15 @@ class PeersIndex {
56
56
  return this.chat(peer.channelId);
57
57
  }
58
58
  }
59
+ has(peer) {
60
+ switch (peer._) {
61
+ case "peerUser":
62
+ return this.users.has(peer.userId);
63
+ case "peerChat":
64
+ return this.chats.has(peer.chatId);
65
+ case "peerChannel":
66
+ return this.chats.has(peer.channelId);
67
+ }
68
+ }
59
69
  }
60
70
  exports.PeersIndex = PeersIndex;
@@ -12,4 +12,5 @@ export declare class PeersIndex {
12
12
  user(id: number): tl.TypeUser;
13
13
  chat(id: number): tl.TypeChat;
14
14
  get(peer: tl.TypePeer): tl.TypeUser | tl.TypeChat;
15
+ has(peer: tl.TypePeer): boolean;
15
16
  }
@@ -12,4 +12,5 @@ export declare class PeersIndex {
12
12
  user(id: number): tl.TypeUser;
13
13
  chat(id: number): tl.TypeChat;
14
14
  get(peer: tl.TypePeer): tl.TypeUser | tl.TypeChat;
15
+ has(peer: tl.TypePeer): boolean;
15
16
  }
@@ -49,6 +49,16 @@ class PeersIndex {
49
49
  return this.chat(peer.channelId);
50
50
  }
51
51
  }
52
+ has(peer) {
53
+ switch (peer._) {
54
+ case "peerUser":
55
+ return this.users.has(peer.userId);
56
+ case "peerChat":
57
+ return this.chats.has(peer.chatId);
58
+ case "peerChannel":
59
+ return this.chats.has(peer.channelId);
60
+ }
61
+ }
52
62
  }
53
63
  export {
54
64
  PeersIndex
@@ -29,9 +29,9 @@ class BusinessConnection {
29
29
  get date() {
30
30
  return new Date(this.raw.date * 1e3);
31
31
  }
32
- /** Whether the bot can reply on behalf of the user */
33
- get canReply() {
34
- return this.raw.canReply;
32
+ /** What can the connected bot do on behalf of the user */
33
+ get rights() {
34
+ return this.raw.rights ?? null;
35
35
  }
36
36
  /** Business account user that created the business connection */
37
37
  get user() {
@@ -16,8 +16,8 @@ export declare class BusinessConnection {
16
16
  get dcId(): number;
17
17
  /** Date when the connection was created */
18
18
  get date(): Date;
19
- /** Whether the bot can reply on behalf of the user */
20
- get canReply(): boolean;
19
+ /** What can the connected bot do on behalf of the user */
20
+ get rights(): tl.TypeBusinessBotRights | null;
21
21
  /** Business account user that created the business connection */
22
22
  get user(): User;
23
23
  }
@@ -16,8 +16,8 @@ export declare class BusinessConnection {
16
16
  get dcId(): number;
17
17
  /** Date when the connection was created */
18
18
  get date(): Date;
19
- /** Whether the bot can reply on behalf of the user */
20
- get canReply(): boolean;
19
+ /** What can the connected bot do on behalf of the user */
20
+ get rights(): tl.TypeBusinessBotRights | null;
21
21
  /** Business account user that created the business connection */
22
22
  get user(): User;
23
23
  }
@@ -22,9 +22,9 @@ class BusinessConnection {
22
22
  get date() {
23
23
  return new Date(this.raw.date * 1e3);
24
24
  }
25
- /** Whether the bot can reply on behalf of the user */
26
- get canReply() {
27
- return this.raw.canReply;
25
+ /** What can the connected bot do on behalf of the user */
26
+ get rights() {
27
+ return this.raw.rights ?? null;
28
28
  }
29
29
  /** Business account user that created the business connection */
30
30
  get user() {
@@ -62,11 +62,11 @@ class SavedStarGift {
62
62
  get savedId() {
63
63
  return this.raw.savedId ?? null;
64
64
  }
65
- /** Amount of stars the gift can be converted to by the recipient */
65
+ /** Amount of stars the gift can be converted to */
66
66
  get convertStars() {
67
67
  return this.raw.convertStars ?? null;
68
68
  }
69
- /** Amount of stars needed to upgrade the gift to a unique gift */
69
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
70
70
  get upgradeStars() {
71
71
  return this.raw.upgradeStars ?? null;
72
72
  }
@@ -30,9 +30,9 @@ export declare class SavedStarGift {
30
30
  get messageId(): number | null;
31
31
  /** ID of the saved gift */
32
32
  get savedId(): tl.Long | null;
33
- /** Amount of stars the gift can be converted to by the recipient */
33
+ /** Amount of stars the gift can be converted to */
34
34
  get convertStars(): tl.Long | null;
35
- /** Amount of stars needed to upgrade the gift to a unique gift */
35
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
36
36
  get upgradeStars(): tl.Long | null;
37
37
  /** Amount of stars needed to transfer the gift */
38
38
  get transferStars(): tl.Long | null;
@@ -30,9 +30,9 @@ export declare class SavedStarGift {
30
30
  get messageId(): number | null;
31
31
  /** ID of the saved gift */
32
32
  get savedId(): tl.Long | null;
33
- /** Amount of stars the gift can be converted to by the recipient */
33
+ /** Amount of stars the gift can be converted to */
34
34
  get convertStars(): tl.Long | null;
35
- /** Amount of stars needed to upgrade the gift to a unique gift */
35
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
36
36
  get upgradeStars(): tl.Long | null;
37
37
  /** Amount of stars needed to transfer the gift */
38
38
  get transferStars(): tl.Long | null;
@@ -55,11 +55,11 @@ class SavedStarGift {
55
55
  get savedId() {
56
56
  return this.raw.savedId ?? null;
57
57
  }
58
- /** Amount of stars the gift can be converted to by the recipient */
58
+ /** Amount of stars the gift can be converted to */
59
59
  get convertStars() {
60
60
  return this.raw.convertStars ?? null;
61
61
  }
62
- /** Amount of stars needed to upgrade the gift to a unique gift */
62
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
63
63
  get upgradeStars() {
64
64
  return this.raw.upgradeStars ?? null;
65
65
  }
@@ -6,6 +6,7 @@ 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 peerUtils = require("../../../utils/peer-utils.cjs");
9
10
  const inspectable = require("../../utils/inspectable.cjs");
10
11
  const memoize = require("../../utils/memoize.cjs");
11
12
  const documentUtils = require("../media/document-utils.cjs");
@@ -116,11 +117,20 @@ class StarGiftUnique {
116
117
  get slug() {
117
118
  return this.raw.slug;
118
119
  }
119
- /** ID of the peer who owns this gift, if available */
120
+ /**
121
+ * ID of the peer who owns this gift, if available
122
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
123
+ * > in which cases please use `tg.getPeer(ownerId)` manually
124
+ */
120
125
  get owner() {
121
126
  if (!this.raw.ownerId) return null;
127
+ if (!this._peers.has(this.raw.ownerId)) return null;
122
128
  return peer.parsePeer(this.raw.ownerId, this._peers);
123
129
  }
130
+ /** ID of the peer who owns this gift, if available */
131
+ get ownerId() {
132
+ return this.raw.ownerId ? peerUtils.getMarkedPeerId(this.raw.ownerId) : null;
133
+ }
124
134
  /** Name of the user who owns this gift, if available */
125
135
  get ownerName() {
126
136
  return this.raw.ownerName ?? null;
@@ -57,8 +57,14 @@ export declare class StarGiftUnique {
57
57
  get title(): string;
58
58
  /** Slug of the gift */
59
59
  get slug(): string;
60
- /** ID of the peer who owns this gift, if available */
60
+ /**
61
+ * ID of the peer who owns this gift, if available
62
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
63
+ * > in which cases please use `tg.getPeer(ownerId)` manually
64
+ */
61
65
  get owner(): Peer | null;
66
+ /** ID of the peer who owns this gift, if available */
67
+ get ownerId(): number | null;
62
68
  /** Name of the user who owns this gift, if available */
63
69
  get ownerName(): string | null;
64
70
  get availabilityIssued(): number;
@@ -57,8 +57,14 @@ export declare class StarGiftUnique {
57
57
  get title(): string;
58
58
  /** Slug of the gift */
59
59
  get slug(): string;
60
- /** ID of the peer who owns this gift, if available */
60
+ /**
61
+ * ID of the peer who owns this gift, if available
62
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
63
+ * > in which cases please use `tg.getPeer(ownerId)` manually
64
+ */
61
65
  get owner(): Peer | null;
66
+ /** ID of the peer who owns this gift, if available */
67
+ get ownerId(): number | null;
62
68
  /** Name of the user who owns this gift, if available */
63
69
  get ownerName(): string | null;
64
70
  get availabilityIssued(): number;
@@ -1,4 +1,5 @@
1
1
  import { assert } from "@fuman/utils";
2
+ import { getMarkedPeerId } from "../../../utils/peer-utils.js";
2
3
  import { makeInspectable } from "../../utils/inspectable.js";
3
4
  import { memoizeGetters } from "../../utils/memoize.js";
4
5
  import { parseDocument } from "../media/document-utils.js";
@@ -109,11 +110,20 @@ class StarGiftUnique {
109
110
  get slug() {
110
111
  return this.raw.slug;
111
112
  }
112
- /** ID of the peer who owns this gift, if available */
113
+ /**
114
+ * ID of the peer who owns this gift, if available
115
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
116
+ * > in which cases please use `tg.getPeer(ownerId)` manually
117
+ */
113
118
  get owner() {
114
119
  if (!this.raw.ownerId) return null;
120
+ if (!this._peers.has(this.raw.ownerId)) return null;
115
121
  return parsePeer(this.raw.ownerId, this._peers);
116
122
  }
123
+ /** ID of the peer who owns this gift, if available */
124
+ get ownerId() {
125
+ return this.raw.ownerId ? getMarkedPeerId(this.raw.ownerId) : null;
126
+ }
117
127
  /** Name of the user who owns this gift, if available */
118
128
  get ownerName() {
119
129
  return this.raw.ownerName ?? null;
@@ -177,6 +177,10 @@ class StarsTransaction {
177
177
  return { type: "unsupported" };
178
178
  }
179
179
  }
180
+ /** Whether this transaction was made by a business bot */
181
+ get viaBusinessBot() {
182
+ return this.raw.businessTransfer;
183
+ }
180
184
  }
181
185
  const StarsTransaction$1 = /* @__PURE__ */ inspectable.makeInspectable(StarsTransaction);
182
186
  const StarsTransaction$2 = /* @__PURE__ */ memoize.memoizeGetters(StarsTransaction$1, ["amount", "type"]);
@@ -160,4 +160,6 @@ export declare class StarsTransaction {
160
160
  get date(): Date;
161
161
  /** Type of this transaction */
162
162
  get type(): StarsTransactionType;
163
+ /** Whether this transaction was made by a business bot */
164
+ get viaBusinessBot(): boolean;
163
165
  }
@@ -160,4 +160,6 @@ export declare class StarsTransaction {
160
160
  get date(): Date;
161
161
  /** Type of this transaction */
162
162
  get type(): StarsTransactionType;
163
+ /** Whether this transaction was made by a business bot */
164
+ get viaBusinessBot(): boolean;
163
165
  }
@@ -170,6 +170,10 @@ class StarsTransaction {
170
170
  return { type: "unsupported" };
171
171
  }
172
172
  }
173
+ /** Whether this transaction was made by a business bot */
174
+ get viaBusinessBot() {
175
+ return this.raw.businessTransfer;
176
+ }
173
177
  }
174
178
  const StarsTransaction$1 = /* @__PURE__ */ makeInspectable(StarsTransaction);
175
179
  const StarsTransaction$2 = /* @__PURE__ */ memoizeGetters(StarsTransaction$1, ["amount", "type"]);
@@ -55,6 +55,7 @@ class PeersServiceProxy {
55
55
  this.getByUsername = bind("getByUsername");
56
56
  this.getCompleteById = bind("getCompleteById");
57
57
  this.getMinAccessHash = bind("getMinAccessHash");
58
+ this.close = bind("close");
58
59
  }
59
60
  updatePeersFrom;
60
61
  store;
@@ -63,6 +64,7 @@ class PeersServiceProxy {
63
64
  getByUsername;
64
65
  getCompleteById;
65
66
  getMinAccessHash;
67
+ close;
66
68
  }
67
69
  class TelegramStorageProxy {
68
70
  constructor(_invoker) {
@@ -71,10 +73,12 @@ class TelegramStorageProxy {
71
73
  this.self = new CurrentUserServiceProxy(this._invoker);
72
74
  this.peers = new PeersServiceProxy(this._invoker);
73
75
  this.clear = bind("clear");
76
+ this.close = bind("close");
74
77
  }
75
78
  self;
76
79
  peers;
77
80
  clear;
81
+ close;
78
82
  // todo - remove once we move these to updates manager
79
83
  updates = null;
80
84
  refMsgs = null;
@@ -26,6 +26,7 @@ declare class PeersServiceProxy implements PublicPart<PeersService> {
26
26
  readonly getByUsername: PeersService['getByUsername'];
27
27
  readonly getCompleteById: PeersService['getCompleteById'];
28
28
  readonly getMinAccessHash: PeersService['getMinAccessHash'];
29
+ readonly close: PeersService['close'];
29
30
  constructor(_invoker: WorkerInvoker);
30
31
  }
31
32
  export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
@@ -33,6 +34,7 @@ export declare class TelegramStorageProxy implements PublicPart<TelegramStorageM
33
34
  readonly self: CurrentUserServiceProxy;
34
35
  readonly peers: PeersServiceProxy;
35
36
  readonly clear: TelegramStorageManager['clear'];
37
+ readonly close: TelegramStorageManager['close'];
36
38
  constructor(_invoker: WorkerInvoker);
37
39
  readonly updates: never;
38
40
  readonly refMsgs: never;
@@ -26,6 +26,7 @@ declare class PeersServiceProxy implements PublicPart<PeersService> {
26
26
  readonly getByUsername: PeersService['getByUsername'];
27
27
  readonly getCompleteById: PeersService['getCompleteById'];
28
28
  readonly getMinAccessHash: PeersService['getMinAccessHash'];
29
+ readonly close: PeersService['close'];
29
30
  constructor(_invoker: WorkerInvoker);
30
31
  }
31
32
  export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
@@ -33,6 +34,7 @@ export declare class TelegramStorageProxy implements PublicPart<TelegramStorageM
33
34
  readonly self: CurrentUserServiceProxy;
34
35
  readonly peers: PeersServiceProxy;
35
36
  readonly clear: TelegramStorageManager['clear'];
37
+ readonly close: TelegramStorageManager['close'];
36
38
  constructor(_invoker: WorkerInvoker);
37
39
  readonly updates: never;
38
40
  readonly refMsgs: never;
@@ -48,6 +48,7 @@ class PeersServiceProxy {
48
48
  this.getByUsername = bind("getByUsername");
49
49
  this.getCompleteById = bind("getCompleteById");
50
50
  this.getMinAccessHash = bind("getMinAccessHash");
51
+ this.close = bind("close");
51
52
  }
52
53
  updatePeersFrom;
53
54
  store;
@@ -56,6 +57,7 @@ class PeersServiceProxy {
56
57
  getByUsername;
57
58
  getCompleteById;
58
59
  getMinAccessHash;
60
+ close;
59
61
  }
60
62
  class TelegramStorageProxy {
61
63
  constructor(_invoker) {
@@ -64,10 +66,12 @@ class TelegramStorageProxy {
64
66
  this.self = new CurrentUserServiceProxy(this._invoker);
65
67
  this.peers = new PeersServiceProxy(this._invoker);
66
68
  this.clear = bind("clear");
69
+ this.close = bind("close");
67
70
  }
68
71
  self;
69
72
  peers;
70
73
  clear;
74
+ close;
71
75
  // todo - remove once we move these to updates manager
72
76
  updates = null;
73
77
  refMsgs = null;
package/index.cjs CHANGED
@@ -144,6 +144,10 @@ const intermediate = require("./network/transports/intermediate.cjs");
144
144
  const obfuscated = require("./network/transports/obfuscated.cjs");
145
145
  const driver = require("./storage/driver.cjs");
146
146
  const driver$1 = require("./storage/memory/driver.cjs");
147
+ const authKeys = require("./storage/memory/repository/auth-keys.cjs");
148
+ const kv = require("./storage/memory/repository/kv.cjs");
149
+ const peers = require("./storage/memory/repository/peers.cjs");
150
+ const refMessages = require("./storage/memory/repository/ref-messages.cjs");
147
151
  const index$3 = require("./storage/memory/index.cjs");
148
152
  const driver$2 = require("./storage/sqlite/driver.cjs");
149
153
  const index$4 = require("./storage/sqlite/index.cjs");
@@ -325,6 +329,10 @@ exports.PaddedIntermediatePacketCodec = intermediate.PaddedIntermediatePacketCod
325
329
  exports.ObfuscatedPacketCodec = obfuscated.ObfuscatedPacketCodec;
326
330
  exports.BaseStorageDriver = driver.BaseStorageDriver;
327
331
  exports.MemoryStorageDriver = driver$1.MemoryStorageDriver;
332
+ exports.MemoryAuthKeysRepository = authKeys.MemoryAuthKeysRepository;
333
+ exports.MemoryKeyValueRepository = kv.MemoryKeyValueRepository;
334
+ exports.MemoryPeersRepository = peers.MemoryPeersRepository;
335
+ exports.MemoryRefMessagesRepository = refMessages.MemoryRefMessagesRepository;
328
336
  exports.MemoryStorage = index$3.MemoryStorage;
329
337
  exports.BaseSqliteStorageDriver = driver$2.BaseSqliteStorageDriver;
330
338
  exports.BaseSqliteStorage = index$4.BaseSqliteStorage;
package/index.js CHANGED
@@ -137,6 +137,10 @@ import { IntermediatePacketCodec, PaddedIntermediatePacketCodec } from "./networ
137
137
  import { ObfuscatedPacketCodec } from "./network/transports/obfuscated.js";
138
138
  import { BaseStorageDriver } from "./storage/driver.js";
139
139
  import { MemoryStorageDriver } from "./storage/memory/driver.js";
140
+ import { MemoryAuthKeysRepository } from "./storage/memory/repository/auth-keys.js";
141
+ import { MemoryKeyValueRepository } from "./storage/memory/repository/kv.js";
142
+ import { MemoryPeersRepository } from "./storage/memory/repository/peers.js";
143
+ import { MemoryRefMessagesRepository } from "./storage/memory/repository/ref-messages.js";
140
144
  import { MemoryStorage } from "./storage/memory/index.js";
141
145
  import { BaseSqliteStorageDriver } from "./storage/sqlite/driver.js";
142
146
  import { BaseSqliteStorage } from "./storage/sqlite/index.js";
@@ -219,6 +223,10 @@ export {
219
223
  default2 as Long,
220
224
  MASK_POSITION_POINT_TO_TL,
221
225
  MediaStory,
226
+ MemoryAuthKeysRepository,
227
+ MemoryKeyValueRepository,
228
+ MemoryPeersRepository,
229
+ MemoryRefMessagesRepository,
222
230
  MemoryStorage,
223
231
  MemoryStorageDriver,
224
232
  Message,