@mtkruto/node 0.1.500 → 0.1.700

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 (179) hide show
  1. package/esm/3_types.d.ts +6 -1
  2. package/esm/3_types.js +6 -1
  3. package/esm/4_errors.js +2 -4
  4. package/esm/5_client.d.ts +1 -1
  5. package/esm/5_client.js +1 -1
  6. package/esm/client/0_params.d.ts +33 -7
  7. package/esm/client/0_storage_operations.d.ts +182 -0
  8. package/esm/client/0_storage_operations.js +611 -0
  9. package/esm/client/1_composer.d.ts +2 -0
  10. package/esm/client/1_composer.js +28 -0
  11. package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
  12. package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
  13. package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
  14. package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  15. package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
  16. package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
  17. package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  18. package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
  19. package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
  20. package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  21. package/esm/client/3_video_chat_manager.d.ts +43 -0
  22. package/esm/client/3_video_chat_manager.js +194 -0
  23. package/esm/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  24. package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  25. package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
  26. package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
  27. package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  28. package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  29. package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  30. package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
  31. package/esm/client/{4_client.js → 5_client.js} +172 -73
  32. package/esm/connection/0_connection.d.ts +6 -15
  33. package/esm/connection/0_connection.js +1 -38
  34. package/esm/connection/1_connection_web_socket.d.ts +3 -2
  35. package/esm/connection/1_connection_web_socket.js +7 -3
  36. package/esm/mod.d.ts +1 -1
  37. package/esm/mod.js +1 -1
  38. package/esm/storage/0_storage.d.ts +9 -145
  39. package/esm/storage/0_storage.js +1 -526
  40. package/esm/storage/2_storage_indexed_db.d.ts +3 -2
  41. package/esm/storage/2_storage_indexed_db.js +9 -8
  42. package/esm/storage/2_storage_local_storage.d.ts +3 -2
  43. package/esm/storage/2_storage_local_storage.js +5 -4
  44. package/esm/storage/2_storage_memory.d.ts +4 -4
  45. package/esm/storage/2_storage_memory.js +12 -19
  46. package/esm/storage/2_storage_session_storage.d.ts +2 -1
  47. package/esm/storage/2_storage_session_storage.js +5 -4
  48. package/esm/tl/3_utilities.d.ts +1 -1
  49. package/esm/tl/3_utilities.js +3 -3
  50. package/esm/types/0_birthday.d.ts +27 -0
  51. package/esm/types/0_birthday.js +26 -0
  52. package/esm/types/0_giveaway_parameters.d.ts +1 -1
  53. package/esm/types/0_id.d.ts +1 -1
  54. package/esm/types/0_live_stream_channel.d.ts +30 -0
  55. package/esm/types/0_live_stream_channel.js +26 -0
  56. package/esm/types/0_opening_hours.d.ts +25 -0
  57. package/esm/types/0_opening_hours.js +25 -0
  58. package/esm/types/0_video_chat.d.ts +60 -0
  59. package/esm/types/0_video_chat.js +53 -0
  60. package/esm/types/1_chat_p.d.ts +4 -0
  61. package/esm/types/1_chat_p.js +1 -0
  62. package/esm/types/2_business_connection.d.ts +6 -0
  63. package/esm/types/2_chat.d.ts +62 -0
  64. package/esm/types/2_chat.js +66 -0
  65. package/esm/types/2_inactive_chat.d.ts +1 -1
  66. package/esm/types/2_invite_link.d.ts +1 -1
  67. package/esm/types/2_message_reaction_count.d.ts +1 -1
  68. package/esm/types/2_message_reactions.d.ts +1 -1
  69. package/esm/types/3_chat_member_updated.d.ts +1 -1
  70. package/esm/types/4_message.d.ts +3 -3
  71. package/esm/types/5_chat_list_item.d.ts +35 -0
  72. package/esm/types/5_chat_list_item.js +86 -0
  73. package/esm/types/6_update.d.ts +14 -5
  74. package/esm/types/_file_id.d.ts +1 -0
  75. package/esm/utilities/0_bigint.d.ts +1 -0
  76. package/esm/utilities/0_bigint.js +7 -3
  77. package/package.json +1 -1
  78. package/script/3_types.d.ts +6 -1
  79. package/script/3_types.js +6 -1
  80. package/script/4_errors.js +2 -4
  81. package/script/5_client.d.ts +1 -1
  82. package/script/5_client.js +1 -1
  83. package/script/client/0_params.d.ts +33 -7
  84. package/script/client/0_storage_operations.d.ts +182 -0
  85. package/script/client/0_storage_operations.js +615 -0
  86. package/script/client/1_composer.d.ts +2 -0
  87. package/script/client/1_composer.js +28 -0
  88. package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
  89. package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
  90. package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
  91. package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  92. package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
  93. package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
  94. package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  95. package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
  96. package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
  97. package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  98. package/script/client/3_video_chat_manager.d.ts +43 -0
  99. package/script/client/3_video_chat_manager.js +198 -0
  100. package/script/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  101. package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  102. package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
  103. package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
  104. package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  105. package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  106. package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  107. package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
  108. package/script/client/{4_client.js → 5_client.js} +192 -93
  109. package/script/connection/0_connection.d.ts +6 -15
  110. package/script/connection/0_connection.js +0 -41
  111. package/script/connection/1_connection_web_socket.d.ts +3 -2
  112. package/script/connection/1_connection_web_socket.js +7 -3
  113. package/script/mod.d.ts +1 -1
  114. package/script/mod.js +1 -1
  115. package/script/storage/0_storage.d.ts +9 -145
  116. package/script/storage/0_storage.js +0 -528
  117. package/script/storage/2_storage_indexed_db.d.ts +3 -2
  118. package/script/storage/2_storage_indexed_db.js +9 -8
  119. package/script/storage/2_storage_local_storage.d.ts +3 -2
  120. package/script/storage/2_storage_local_storage.js +5 -4
  121. package/script/storage/2_storage_memory.d.ts +4 -4
  122. package/script/storage/2_storage_memory.js +12 -19
  123. package/script/storage/2_storage_session_storage.d.ts +2 -1
  124. package/script/storage/2_storage_session_storage.js +5 -4
  125. package/script/tl/3_utilities.d.ts +1 -1
  126. package/script/tl/3_utilities.js +3 -3
  127. package/script/types/0_birthday.d.ts +27 -0
  128. package/script/types/0_birthday.js +30 -0
  129. package/script/types/0_giveaway_parameters.d.ts +1 -1
  130. package/script/types/0_id.d.ts +1 -1
  131. package/script/types/0_live_stream_channel.d.ts +30 -0
  132. package/script/types/0_live_stream_channel.js +30 -0
  133. package/script/types/0_opening_hours.d.ts +25 -0
  134. package/script/types/0_opening_hours.js +29 -0
  135. package/script/types/0_video_chat.d.ts +60 -0
  136. package/script/types/0_video_chat.js +57 -0
  137. package/script/types/1_chat_p.d.ts +4 -0
  138. package/script/types/1_chat_p.js +1 -0
  139. package/script/types/2_business_connection.d.ts +6 -0
  140. package/script/types/2_chat.d.ts +62 -0
  141. package/script/types/2_chat.js +70 -0
  142. package/script/types/2_inactive_chat.d.ts +1 -1
  143. package/script/types/2_invite_link.d.ts +1 -1
  144. package/script/types/2_message_reaction_count.d.ts +1 -1
  145. package/script/types/2_message_reactions.d.ts +1 -1
  146. package/script/types/3_chat_member_updated.d.ts +1 -1
  147. package/script/types/4_message.d.ts +3 -3
  148. package/script/types/5_chat_list_item.d.ts +35 -0
  149. package/script/types/5_chat_list_item.js +94 -0
  150. package/script/types/6_update.d.ts +14 -5
  151. package/script/types/_file_id.d.ts +1 -0
  152. package/script/utilities/0_bigint.d.ts +1 -0
  153. package/script/utilities/0_bigint.js +7 -3
  154. package/esm/types/5_chat.d.ts +0 -59
  155. package/esm/types/5_chat.js +0 -126
  156. package/script/types/5_chat.d.ts +0 -59
  157. package/script/types/5_chat.js +0 -134
  158. /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  159. /package/esm/{3_storage.js → 2_storage.js} +0 -0
  160. /package/esm/client/{0_types.js → 1_types.js} +0 -0
  161. /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  162. /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  163. /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  164. /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  165. /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  166. /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  167. /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  168. /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
  169. /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  170. /package/script/{3_storage.js → 2_storage.js} +0 -0
  171. /package/script/client/{0_types.js → 1_types.js} +0 -0
  172. /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  173. /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  174. /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  175. /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  176. /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  177. /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  178. /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  179. /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
package/esm/3_types.d.ts CHANGED
@@ -20,6 +20,7 @@
20
20
  export * from "./types/_file_id.js";
21
21
  export * from "./types/_getters.js";
22
22
  export * from "./types/0_authorization_state.js";
23
+ export * from "./types/0_birthday.js";
23
24
  export * from "./types/0_bot_command.js";
24
25
  export * from "./types/0_callback_query_answer.js";
25
26
  export * from "./types/0_callback_query_question.js";
@@ -35,6 +36,7 @@ export * from "./types/0_giveaway_parameters.js";
35
36
  export * from "./types/0_id.js";
36
37
  export * from "./types/0_keyboard_button_poll_type.js";
37
38
  export * from "./types/0_link_preview.js";
39
+ export * from "./types/0_live_stream_channel.js";
38
40
  export * from "./types/0_location.js";
39
41
  export * from "./types/0_login_url.js";
40
42
  export * from "./types/0_mask_position.js";
@@ -43,6 +45,7 @@ export * from "./types/0_message_reference.js";
43
45
  export * from "./types/0_message_search_filter.js";
44
46
  export * from "./types/0_mini_app_info.js";
45
47
  export * from "./types/0_network_statistics_entry.js";
48
+ export * from "./types/0_opening_hours.js";
46
49
  export * from "./types/0_parse_mode.js";
47
50
  export * from "./types/0_poll_option.js";
48
51
  export * from "./types/0_price_tag.js";
@@ -51,6 +54,7 @@ export * from "./types/0_restriction_reason.js";
51
54
  export * from "./types/0_self_destruct_option.js";
52
55
  export * from "./types/0_story_reference.js";
53
56
  export * from "./types/0_thumbnail.js";
57
+ export * from "./types/0_video_chat.js";
54
58
  export * from "./types/0_voice.js";
55
59
  export * from "./types/1_animation.js";
56
60
  export * from "./types/1_audio.js";
@@ -96,6 +100,7 @@ export * from "./types/3_story.js";
96
100
  export * from "./types/4_inline_query_result.js";
97
101
  export * from "./types/4_message.js";
98
102
  export * from "./types/5_callback_query.js";
99
- export * from "./types/5_chat.js";
103
+ export * from "./types/5_chat_list_item.js";
104
+ export * from "./types/2_chat.js";
100
105
  export * from "./types/5_inline_query_answer.js";
101
106
  export * from "./types/6_update.js";
package/esm/3_types.js CHANGED
@@ -20,6 +20,7 @@
20
20
  export * from "./types/_file_id.js";
21
21
  export * from "./types/_getters.js";
22
22
  export * from "./types/0_authorization_state.js";
23
+ export * from "./types/0_birthday.js";
23
24
  export * from "./types/0_bot_command.js";
24
25
  export * from "./types/0_callback_query_answer.js";
25
26
  export * from "./types/0_callback_query_question.js";
@@ -35,6 +36,7 @@ export * from "./types/0_giveaway_parameters.js";
35
36
  export * from "./types/0_id.js";
36
37
  export * from "./types/0_keyboard_button_poll_type.js";
37
38
  export * from "./types/0_link_preview.js";
39
+ export * from "./types/0_live_stream_channel.js";
38
40
  export * from "./types/0_location.js";
39
41
  export * from "./types/0_login_url.js";
40
42
  export * from "./types/0_mask_position.js";
@@ -43,6 +45,7 @@ export * from "./types/0_message_reference.js";
43
45
  export * from "./types/0_message_search_filter.js";
44
46
  export * from "./types/0_mini_app_info.js";
45
47
  export * from "./types/0_network_statistics_entry.js";
48
+ export * from "./types/0_opening_hours.js";
46
49
  export * from "./types/0_parse_mode.js";
47
50
  export * from "./types/0_poll_option.js";
48
51
  export * from "./types/0_price_tag.js";
@@ -51,6 +54,7 @@ export * from "./types/0_restriction_reason.js";
51
54
  export * from "./types/0_self_destruct_option.js";
52
55
  export * from "./types/0_story_reference.js";
53
56
  export * from "./types/0_thumbnail.js";
57
+ export * from "./types/0_video_chat.js";
54
58
  export * from "./types/0_voice.js";
55
59
  export * from "./types/1_animation.js";
56
60
  export * from "./types/1_audio.js";
@@ -96,6 +100,7 @@ export * from "./types/3_story.js";
96
100
  export * from "./types/4_inline_query_result.js";
97
101
  export * from "./types/4_message.js";
98
102
  export * from "./types/5_callback_query.js";
99
- export * from "./types/5_chat.js";
103
+ export * from "./types/5_chat_list_item.js";
104
+ export * from "./types/2_chat.js";
100
105
  export * from "./types/5_inline_query_answer.js";
101
106
  export * from "./types/6_update.js";
package/esm/4_errors.js CHANGED
@@ -73,10 +73,8 @@ export function upgradeInstance(error, call) {
73
73
  return new v({ ...error, call });
74
74
  }
75
75
  }
76
- for (const [k, v] of Object.entries(map)) {
77
- if (error.error_message == k) {
78
- return new v({ ...error, call });
79
- }
76
+ if (error.error_message in map) {
77
+ return new map[error.error_message]({ ...error, call });
80
78
  }
81
79
  return error;
82
80
  }
package/esm/5_client.d.ts CHANGED
@@ -20,4 +20,4 @@
20
20
  export * from "./client/0_params.js";
21
21
  export * from "./client/1_client_encrypted.js";
22
22
  export * from "./client/1_client_plain.js";
23
- export * from "./client/4_client.js";
23
+ export * from "./client/5_client.js";
package/esm/5_client.js CHANGED
@@ -20,4 +20,4 @@
20
20
  export * from "./client/0_params.js";
21
21
  export * from "./client/1_client_encrypted.js";
22
22
  export * from "./client/1_client_plain.js";
23
- export * from "./client/4_client.js";
23
+ export * from "./client/5_client.js";
@@ -18,7 +18,7 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { MaybePromise } from "../1_utilities.js";
21
- import { BotCommandScope, Chat, ChatMemberRights, FileSource, ID, InlineQueryResultButton, LinkPreview, Message, MessageEntity, MessageSearchFilter, ParseMode, ReplyMarkup, ReplyQuote, SelfDestructOption, StoryInteractiveArea, StoryPrivacy } from "../3_types.js";
21
+ import { BotCommandScope, ChatListItem, ChatMemberRights, FileSource, ID, InlineQueryResultButton, LinkPreview, Message, MessageEntity, MessageSearchFilter, ParseMode, ReplyMarkup, ReplyQuote, SelfDestructOption, StoryInteractiveArea, StoryPrivacy } from "../3_types.js";
22
22
  export interface AnswerCallbackQueryParams {
23
23
  /** A text to be shown to the user. */
24
24
  text?: string;
@@ -29,11 +29,15 @@ export interface AnswerCallbackQueryParams {
29
29
  /** TTL of answer caches in seconds. */
30
30
  cacheTime?: number;
31
31
  }
32
- export interface AuthorizeUserParams<S = string> {
32
+ export interface SignInParamsUser<S = string> {
33
33
  phone: S | (() => MaybePromise<S>);
34
34
  code: S | (() => MaybePromise<S>);
35
35
  password: S | ((hint: string | null) => MaybePromise<S>);
36
36
  }
37
+ export interface SignInParamsBot {
38
+ botToken: string;
39
+ }
40
+ export type SignInParams = SignInParamsUser | SignInParamsBot;
37
41
  export interface _BusinessConnectionIdCommon {
38
42
  businessConnectionId?: string;
39
43
  }
@@ -48,7 +52,7 @@ export interface _SendCommon extends _BusinessConnectionIdCommon {
48
52
  replyQuote?: ReplyQuote;
49
53
  /** The identifier of a thread to send the message to. */
50
54
  messageThreadId?: number;
51
- /** The identifier of the chat to send the message on behalf of. User-only. */
55
+ /** The identifier of a chat to send the message on behalf of. User-only. */
52
56
  sendAs?: ID;
53
57
  /** The reply markup of the message. Bot-only. */
54
58
  replyMarkup?: ReplyMarkup;
@@ -276,7 +280,7 @@ export interface GetChatsParams {
276
280
  /** The chat list to get the chats from. Defaults to main. */
277
281
  from?: "main" | "archived";
278
282
  /** The last chat to get chats after. */
279
- after?: Chat;
283
+ after?: ChatListItem;
280
284
  /** The maximum number of results to return. Must be in the range of 1-100. Defaults to 100. */
281
285
  limit?: number;
282
286
  }
@@ -287,7 +291,7 @@ export interface PinMessageParams {
287
291
  disableNotification?: boolean;
288
292
  }
289
293
  export interface BanChatMemberParams {
290
- /** A point of time in the future to automatically withdraw the ban. */
294
+ /** A point in time within the future in which the ban will be reverted. */
291
295
  untilDate?: Date;
292
296
  /** Whether to delete all of the user's messages. */
293
297
  deleteMessages?: boolean;
@@ -295,7 +299,7 @@ export interface BanChatMemberParams {
295
299
  export interface SetChatMemberRightsParams {
296
300
  /** The member's new rights. All fields default to `true` if the chat's default member rights allow. This means that this method is the same as unbanChatMember if this parameter is not provided or all of its fields are `true`. */
297
301
  rights?: ChatMemberRights;
298
- /** A point of time in the future to automatically withdraw the restrictions. */
302
+ /** A point in time within the future in which the restriction will be reverted. */
299
303
  untilDate?: Date;
300
304
  }
301
305
  export interface CreateStoryParams extends _CaptionCommon, _UploadCommon {
@@ -325,7 +329,7 @@ export interface SearchMessagesParams {
325
329
  export interface CreateInviteLinkParams {
326
330
  /** An optional title to be attached to the link that can only be seen by admins. */
327
331
  title?: string;
328
- /** The point of time in which the invite link must no longer work. */
332
+ /** A point in time within the future in which the invite link will be invalidated. */
329
333
  expireAt?: Date;
330
334
  /** The times the invite link can be used. Cannot be specified while `requireApproval` is `true`. */
331
335
  limit?: number;
@@ -359,3 +363,25 @@ export interface SendInlineQueryParams {
359
363
  query?: string;
360
364
  offset?: string;
361
365
  }
366
+ export interface StartVideoChatParams {
367
+ /** The video chat's title. */
368
+ title?: string;
369
+ /** Whether this is going to be a live stream. */
370
+ liveStream?: boolean;
371
+ }
372
+ export interface ScheduleVideoChatParams extends StartVideoChatParams {
373
+ }
374
+ export interface JoinVideoChatParams {
375
+ /** The identifier of a chat to join the video chat on behalf of. */
376
+ joinAs?: ID;
377
+ /** Invite hash. */
378
+ inviteHash?: string;
379
+ /** Whether to enable audio. Enabled by default. */
380
+ audio?: boolean;
381
+ /** Whether to enable video. Enabled by default. */
382
+ video?: boolean;
383
+ }
384
+ export interface DownloadLiveStreamChunkParams {
385
+ /** Video quality. */
386
+ quality?: "low" | "medium" | "high";
387
+ }
@@ -0,0 +1,182 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { MaybePromise } from "../1_utilities.js";
21
+ import { AnyEntity, enums, ReadObject, TLObject, types } from "../2_tl.js";
22
+ import { DC } from "../3_transport.js";
23
+ import { Storage, StorageKeyPart } from "../2_storage.js";
24
+ export declare const K: {
25
+ connection: {
26
+ P: (string: string) => string;
27
+ apiId: () => StorageKeyPart[];
28
+ };
29
+ session: {
30
+ P: (string: string) => string;
31
+ serverSalt: () => StorageKeyPart[];
32
+ };
33
+ auth: {
34
+ P: (string: string) => string;
35
+ dc: () => StorageKeyPart[];
36
+ key: () => StorageKeyPart[];
37
+ accountId: () => StorageKeyPart[];
38
+ accountType: () => StorageKeyPart[];
39
+ };
40
+ updates: {
41
+ P: (string: string) => string;
42
+ state: () => StorageKeyPart[];
43
+ all: () => StorageKeyPart[];
44
+ updates: (boxId: bigint) => StorageKeyPart[];
45
+ update: (boxId: bigint, id: bigint) => StorageKeyPart[];
46
+ channelPts: (channelId: bigint) => StorageKeyPart[];
47
+ };
48
+ cache: {
49
+ P: (string: string) => string;
50
+ usernames: () => StorageKeyPart[];
51
+ username: (v: string) => StorageKeyPart[];
52
+ peers: () => StorageKeyPart[];
53
+ peer: (id: number) => StorageKeyPart[];
54
+ stickerSetNames: () => StorageKeyPart[];
55
+ stickerSetName: (id: bigint, accessHash: bigint) => StorageKeyPart[];
56
+ files: () => StorageKeyPart[];
57
+ file: (fileId: bigint) => StorageKeyPart[];
58
+ fileParts: () => StorageKeyPart[];
59
+ filePart: (fileId: bigint, n: number) => StorageKeyPart[];
60
+ customEmojiDocuments: () => StorageKeyPart[];
61
+ customEmojiDocument: (id: bigint) => StorageKeyPart[];
62
+ businessConnections: () => StorageKeyPart[];
63
+ businessConnection: (id: string) => StorageKeyPart[];
64
+ inlineQueryAnswers: () => StorageKeyPart[];
65
+ inlineQueryAnswer: (userId: number, chatId: number, query: string, offset: string) => StorageKeyPart[];
66
+ callbackQueryAnswers: () => StorageKeyPart[];
67
+ callbackQueryAnswer: (chatId: number, messageId: number, question: string) => StorageKeyPart[];
68
+ fullChats: () => StorageKeyPart[];
69
+ fullChat: (chatId: number) => StorageKeyPart[];
70
+ groupCalls: () => StorageKeyPart[];
71
+ groupCall: (id: bigint) => StorageKeyPart[];
72
+ groupCallAccessHashes: () => StorageKeyPart[];
73
+ groupCallAccessHash: (id: bigint) => StorageKeyPart[];
74
+ };
75
+ messages: {
76
+ P: (string: string) => string;
77
+ messages: (chatId: number) => StorageKeyPart[];
78
+ message: (chatId: number, messageId: number) => StorageKeyPart[];
79
+ allMessageRefs: () => StorageKeyPart[];
80
+ messageRef: (messageId: number) => StorageKeyPart[];
81
+ };
82
+ chatlists: {
83
+ P: (string: string) => string;
84
+ hasAllChats: (listId: number) => StorageKeyPart[];
85
+ chats: (listId: number) => StorageKeyPart[];
86
+ chat: (listId: number, chatId: number) => StorageKeyPart[];
87
+ pinnedChats: (listId: number) => StorageKeyPart[];
88
+ };
89
+ };
90
+ export declare class StorageOperations {
91
+ #private;
92
+ constructor(storage: Storage);
93
+ get provider(): Storage;
94
+ get supportsFiles(): boolean;
95
+ initialize(): Promise<void>;
96
+ set(...args: Parameters<Storage["set"]>): ReturnType<Storage["set"]>;
97
+ incr(...args: Parameters<Storage["incr"]>): ReturnType<Storage["incr"]>;
98
+ get<T>(...args: Parameters<Storage["get"]>): ReturnType<Storage["get"]>;
99
+ getMany<T>(...args: Parameters<Storage["getMany"]>): ReturnType<Storage["getMany"]>;
100
+ setDc(dc: DC | null): Promise<void>;
101
+ getDc(): MaybePromise<DC | null>;
102
+ getAuthKey(): Promise<Uint8Array | null>;
103
+ setAuthKey(authKey: Uint8Array | null): Promise<void>;
104
+ get authKeyId(): bigint | null;
105
+ exportAuthString(apiId_?: number | null): Promise<string>;
106
+ importAuthString(string: string): Promise<void>;
107
+ getChannelAccessHash(id: number): Promise<bigint | null>;
108
+ getUserAccessHash(id: number): Promise<bigint | null>;
109
+ updateUsernames(id: number, usernames: string[]): Promise<void>;
110
+ getUsername(username: string): Promise<[number, Date] | null>;
111
+ setTlObject(key: readonly StorageKeyPart[], value: TLObject | null): Promise<void>;
112
+ getTlObject(keyOrBuffer: TLObject | Uint8Array | readonly StorageKeyPart[]): Promise<ReadObject | null>;
113
+ setState(state: enums.updates.State): Promise<void>;
114
+ getState(): Promise<enums.updates.State | null>;
115
+ setMessage(chatId: number, messageId: number, message: enums.Message | null): Promise<void>;
116
+ deleteMessages(): Promise<void>;
117
+ getMessageChat(messageId: number): MaybePromise<number | null>;
118
+ getMessage(chatId: number, messageId: number): Promise<enums.Message | null>;
119
+ getLastMessage(chatId: number): Promise<enums.Message | null>;
120
+ setChannelPts(channelId: bigint, pts: number): Promise<void>;
121
+ getChannelPts(channelId: bigint): MaybePromise<number | null>;
122
+ setEntity(entity: AnyEntity): Promise<void>;
123
+ getEntity(key: number): Promise<ReadObject | null>;
124
+ setAccountId(accountId: number): Promise<void>;
125
+ getAccountId(): Promise<number | null>;
126
+ setAccountType(type: "user" | "bot"): Promise<void>;
127
+ getAccountType(): Promise<"user" | "bot" | null>;
128
+ updateStickerSetName(id: bigint, accessHash: bigint, name: string): Promise<void>;
129
+ getStickerSetName(id: bigint, accessHash: bigint): MaybePromise<[string, Date] | null>;
130
+ setServerSalt(serverSalt: bigint): Promise<void>;
131
+ getServerSalt(): MaybePromise<bigint | null>;
132
+ setChat(listId: number, chatId: number, pinned: number, topMessageId: number, topMessageDate: Date): Promise<void>;
133
+ getChats(listId: number): Promise<{
134
+ chatId: number;
135
+ pinned: number;
136
+ topMessageId: number;
137
+ topMessageDate: Date;
138
+ }[]>;
139
+ removeChats(listId: number): Promise<void>;
140
+ setHasAllChats(listId: number, hasAllChats: boolean): Promise<void>;
141
+ hasAllChats(listId: number): Promise<boolean>;
142
+ setPinnedChats(listId: number, chatIds: number[] | null): Promise<void>;
143
+ getPinnedChats(listId: number): Promise<number[] | null>;
144
+ getHistory(chatId: number, offsetId: number, limit: number): Promise<enums.Message[]>;
145
+ getFile(id: bigint): Promise<[number, number] | null>;
146
+ iterFileParts(id: bigint, partCount: number, offset: number): AsyncGenerator<Uint8Array>;
147
+ saveFilePart(id: bigint, index: number, bytes: Uint8Array): Promise<void>;
148
+ setFilePartCount(id: bigint, partCount: number, chunkSize: number): Promise<void>;
149
+ setCustomEmojiDocument(id: bigint, document: types.Document): Promise<void>;
150
+ getCustomEmojiDocument(id: bigint): Promise<[types.Document, Date] | null>;
151
+ setBusinessConnection(id: string, connection: types.BotBusinessConnection | null): Promise<void>;
152
+ getBusinessConnection(id: string): Promise<types.BotBusinessConnection | null>;
153
+ setInlineQueryAnswer(userId: number, chatId: number, query: string, offset: string, results: types.messages.BotResults, date: Date): Promise<void>;
154
+ getInlineQueryAnswer(userId: number, chatId: number, query: string, offset: string): Promise<[types.messages.BotResults, Date] | null>;
155
+ setCallbackQueryAnswer(chatId: number, messageId: number, question: string, answer: types.messages.BotCallbackAnswer): Promise<void>;
156
+ getCallbackQueryAnswer(chatId: number, messageId: number, question: string): Promise<[types.messages.BotCallbackAnswer, Date] | null>;
157
+ setFullChat(chatId: number, fullChat: types.UserFull | types.ChannelFull | types.ChatFull | null): Promise<void>;
158
+ getFullChat(chatId: number): Promise<types.UserFull | types.ChannelFull | types.ChatFull | null>;
159
+ setGroupCall(id: bigint, groupCall: types.GroupCall | null): Promise<void>;
160
+ getGroupCall(id: bigint): Promise<types.GroupCall | null>;
161
+ setGroupCallAccessHash(id: bigint, accessHash: bigint | null): Promise<void>;
162
+ getGroupCallAccessHash(id: bigint): Promise<bigint | null>;
163
+ setUpdate(boxId: bigint, update: enums.Update): Promise<void>;
164
+ deleteUpdates(): Promise<void>;
165
+ getFirstUpdate(boxId: bigint): Promise<[readonly StorageKeyPart[], enums.Update] | null>;
166
+ assertUser(source: string): Promise<void>;
167
+ assertBot(source: string): Promise<void>;
168
+ deleteFiles(): Promise<void>;
169
+ deleteCustomEmojiDocuments(): Promise<void>;
170
+ deleteBusinessConnections(): Promise<void>;
171
+ deleteInlineQueryAnswers(): Promise<void>;
172
+ deleteCallbackQueryAnswers(): Promise<void>;
173
+ deleteFullChats(): Promise<void>;
174
+ deleteGroupCalls(): Promise<void>;
175
+ deleteStickerSetNames(): Promise<void>;
176
+ deletePeers(): Promise<void>;
177
+ deleteUsernames(): Promise<void>;
178
+ clear(): Promise<void>;
179
+ setApiId(apiId: number): Promise<void>;
180
+ getApiId(): Promise<number | null>;
181
+ reset(): Promise<void>;
182
+ }