@bruch/max-client 0.1.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 (174) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +168 -0
  3. package/UPSTREAM.md +10 -0
  4. package/dist/api/account.d.ts +24 -0
  5. package/dist/api/account.d.ts.map +1 -0
  6. package/dist/api/auth.d.ts +57 -0
  7. package/dist/api/auth.d.ts.map +1 -0
  8. package/dist/api/bots.d.ts +8 -0
  9. package/dist/api/bots.d.ts.map +1 -0
  10. package/dist/api/chats.d.ts +41 -0
  11. package/dist/api/chats.d.ts.map +1 -0
  12. package/dist/api/facade.d.ts +19 -0
  13. package/dist/api/facade.d.ts.map +1 -0
  14. package/dist/api/index.d.ts +10 -0
  15. package/dist/api/index.d.ts.map +1 -0
  16. package/dist/api/messages.d.ts +35 -0
  17. package/dist/api/messages.d.ts.map +1 -0
  18. package/dist/api/response.d.ts +7 -0
  19. package/dist/api/response.d.ts.map +1 -0
  20. package/dist/api/runtime.d.ts +19 -0
  21. package/dist/api/runtime.d.ts.map +1 -0
  22. package/dist/api/uploads.d.ts +23 -0
  23. package/dist/api/uploads.d.ts.map +1 -0
  24. package/dist/api/users.d.ts +25 -0
  25. package/dist/api/users.d.ts.map +1 -0
  26. package/dist/app.d.ts +55 -0
  27. package/dist/app.d.ts.map +1 -0
  28. package/dist/auth/flows.d.ts +27 -0
  29. package/dist/auth/flows.d.ts.map +1 -0
  30. package/dist/auth/index.d.ts +3 -0
  31. package/dist/auth/index.d.ts.map +1 -0
  32. package/dist/auth/index.js +109 -0
  33. package/dist/auth/index.js.map +11 -0
  34. package/dist/auth/providers.d.ts +11 -0
  35. package/dist/auth/providers.d.ts.map +1 -0
  36. package/dist/client.d.ts +139 -0
  37. package/dist/client.d.ts.map +1 -0
  38. package/dist/config.d.ts +80 -0
  39. package/dist/config.d.ts.map +1 -0
  40. package/dist/connection/connection.d.ts +25 -0
  41. package/dist/connection/connection.d.ts.map +1 -0
  42. package/dist/connection/index.d.ts +4 -0
  43. package/dist/connection/index.d.ts.map +1 -0
  44. package/dist/connection/pending.d.ts +9 -0
  45. package/dist/connection/pending.d.ts.map +1 -0
  46. package/dist/connection/readers.d.ts +17 -0
  47. package/dist/connection/readers.d.ts.map +1 -0
  48. package/dist/dispatch/dispatcher.d.ts +16 -0
  49. package/dist/dispatch/dispatcher.d.ts.map +1 -0
  50. package/dist/dispatch/index.d.ts +3 -0
  51. package/dist/dispatch/index.d.ts.map +1 -0
  52. package/dist/dispatch/router.d.ts +64 -0
  53. package/dist/dispatch/router.d.ts.map +1 -0
  54. package/dist/errors.d.ts +24 -0
  55. package/dist/errors.d.ts.map +1 -0
  56. package/dist/files/file.d.ts +29 -0
  57. package/dist/files/file.d.ts.map +1 -0
  58. package/dist/files/index.d.ts +2 -0
  59. package/dist/files/index.d.ts.map +1 -0
  60. package/dist/files/index.js +95 -0
  61. package/dist/files/index.js.map +10 -0
  62. package/dist/formatting/index.d.ts +2 -0
  63. package/dist/formatting/index.d.ts.map +1 -0
  64. package/dist/formatting/markdown.d.ts +13 -0
  65. package/dist/formatting/markdown.d.ts.map +1 -0
  66. package/dist/index.d.ts +15 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +3967 -0
  69. package/dist/index.js.map +48 -0
  70. package/dist/logging.d.ts +10 -0
  71. package/dist/logging.d.ts.map +1 -0
  72. package/dist/protocol/compression.d.ts +8 -0
  73. package/dist/protocol/compression.d.ts.map +1 -0
  74. package/dist/protocol/enums.d.ts +175 -0
  75. package/dist/protocol/enums.d.ts.map +1 -0
  76. package/dist/protocol/index.d.ts +6 -0
  77. package/dist/protocol/index.d.ts.map +1 -0
  78. package/dist/protocol/index.js +438 -0
  79. package/dist/protocol/index.js.map +13 -0
  80. package/dist/protocol/tcp.d.ts +35 -0
  81. package/dist/protocol/tcp.d.ts.map +1 -0
  82. package/dist/protocol/types.d.ts +38 -0
  83. package/dist/protocol/types.d.ts.map +1 -0
  84. package/dist/protocol/websocket.d.ts +7 -0
  85. package/dist/protocol/websocket.d.ts.map +1 -0
  86. package/dist/session/index.d.ts +3 -0
  87. package/dist/session/index.d.ts.map +1 -0
  88. package/dist/session/index.js +179 -0
  89. package/dist/session/index.js.map +12 -0
  90. package/dist/session/store.d.ts +18 -0
  91. package/dist/session/store.d.ts.map +1 -0
  92. package/dist/session/types.d.ts +29 -0
  93. package/dist/session/types.d.ts.map +1 -0
  94. package/dist/telemetry/index.d.ts +4 -0
  95. package/dist/telemetry/index.d.ts.map +1 -0
  96. package/dist/telemetry/index.js +831 -0
  97. package/dist/telemetry/index.js.map +17 -0
  98. package/dist/telemetry/navigation.d.ts +41 -0
  99. package/dist/telemetry/navigation.d.ts.map +1 -0
  100. package/dist/telemetry/payloads.d.ts +30 -0
  101. package/dist/telemetry/payloads.d.ts.map +1 -0
  102. package/dist/telemetry/service.d.ts +53 -0
  103. package/dist/telemetry/service.d.ts.map +1 -0
  104. package/dist/transport/base.d.ts +18 -0
  105. package/dist/transport/base.d.ts.map +1 -0
  106. package/dist/transport/index.d.ts +4 -0
  107. package/dist/transport/index.d.ts.map +1 -0
  108. package/dist/transport/tcp.d.ts +28 -0
  109. package/dist/transport/tcp.d.ts.map +1 -0
  110. package/dist/transport/websocket.d.ts +14 -0
  111. package/dist/transport/websocket.d.ts.map +1 -0
  112. package/dist/types/attachments.d.ts +18 -0
  113. package/dist/types/attachments.d.ts.map +1 -0
  114. package/dist/types/index.d.ts +4 -0
  115. package/dist/types/index.d.ts.map +1 -0
  116. package/dist/types/index.js +376 -0
  117. package/dist/types/index.js.map +12 -0
  118. package/dist/types/models.d.ts +210 -0
  119. package/dist/types/models.d.ts.map +1 -0
  120. package/dist/types/utils.d.ts +10 -0
  121. package/dist/types/utils.d.ts.map +1 -0
  122. package/package.json +95 -0
  123. package/src/api/account.ts +93 -0
  124. package/src/api/auth.ts +312 -0
  125. package/src/api/bots.ts +21 -0
  126. package/src/api/chats.ts +234 -0
  127. package/src/api/facade.ts +28 -0
  128. package/src/api/index.ts +9 -0
  129. package/src/api/messages.ts +230 -0
  130. package/src/api/response.ts +24 -0
  131. package/src/api/runtime.ts +27 -0
  132. package/src/api/uploads.ts +91 -0
  133. package/src/api/users.ts +68 -0
  134. package/src/app.ts +271 -0
  135. package/src/auth/flows.ts +103 -0
  136. package/src/auth/index.ts +2 -0
  137. package/src/auth/providers.ts +30 -0
  138. package/src/client.ts +506 -0
  139. package/src/config.ts +161 -0
  140. package/src/connection/connection.ts +93 -0
  141. package/src/connection/index.ts +3 -0
  142. package/src/connection/pending.ts +49 -0
  143. package/src/connection/readers.ts +33 -0
  144. package/src/dispatch/dispatcher.ts +194 -0
  145. package/src/dispatch/index.ts +2 -0
  146. package/src/dispatch/router.ts +149 -0
  147. package/src/errors.ts +41 -0
  148. package/src/files/file.ts +92 -0
  149. package/src/files/index.ts +1 -0
  150. package/src/formatting/index.ts +1 -0
  151. package/src/formatting/markdown.ts +123 -0
  152. package/src/index.ts +15 -0
  153. package/src/logging.ts +67 -0
  154. package/src/protocol/compression.ts +69 -0
  155. package/src/protocol/enums.ts +175 -0
  156. package/src/protocol/index.ts +5 -0
  157. package/src/protocol/tcp.ts +139 -0
  158. package/src/protocol/types.ts +45 -0
  159. package/src/protocol/websocket.ts +47 -0
  160. package/src/session/index.ts +2 -0
  161. package/src/session/store.ts +154 -0
  162. package/src/session/types.ts +45 -0
  163. package/src/telemetry/index.ts +3 -0
  164. package/src/telemetry/navigation.ts +160 -0
  165. package/src/telemetry/payloads.ts +84 -0
  166. package/src/telemetry/service.ts +194 -0
  167. package/src/transport/base.ts +43 -0
  168. package/src/transport/index.ts +3 -0
  169. package/src/transport/tcp.ts +296 -0
  170. package/src/transport/websocket.ts +63 -0
  171. package/src/types/attachments.ts +24 -0
  172. package/src/types/index.ts +3 -0
  173. package/src/types/models.ts +461 -0
  174. package/src/types/utils.ts +45 -0
@@ -0,0 +1,376 @@
1
+ // @bun
2
+ // src/types/utils.ts
3
+ function toMaxId(value, field = "id") {
4
+ if (typeof value === "bigint")
5
+ return value;
6
+ if (typeof value === "string" && /^-?\d+$/.test(value))
7
+ return BigInt(value);
8
+ if (typeof value === "number" && Number.isSafeInteger(value))
9
+ return BigInt(value);
10
+ throw new TypeError(`${field} must be a lossless integer`);
11
+ }
12
+ function optionalMaxId(value, field = "id") {
13
+ return value === null || value === undefined ? null : toMaxId(value, field);
14
+ }
15
+ function asRecord(value, field = "payload") {
16
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
17
+ throw new TypeError(`${field} must be an object`);
18
+ }
19
+ return value;
20
+ }
21
+ function optionalRecord(value) {
22
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
23
+ }
24
+ function asString(value, fallback = "") {
25
+ return typeof value === "string" ? value : fallback;
26
+ }
27
+ function asNumber(value, fallback = 0) {
28
+ if (typeof value === "bigint") {
29
+ const number = Number(value);
30
+ return Number.isSafeInteger(number) ? number : fallback;
31
+ }
32
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
33
+ }
34
+ function asBoolean(value, fallback = false) {
35
+ return typeof value === "boolean" ? value : fallback;
36
+ }
37
+ function asArray(value) {
38
+ return Array.isArray(value) ? value : [];
39
+ }
40
+
41
+ // src/types/attachments.ts
42
+ var AttachmentType = {
43
+ PHOTO: "PHOTO",
44
+ VIDEO: "VIDEO",
45
+ FILE: "FILE",
46
+ CONTACT: "CONTACT",
47
+ STICKER: "STICKER",
48
+ AUDIO: "AUDIO",
49
+ CONTROL: "CONTROL",
50
+ INLINE_KEYBOARD: "INLINE_KEYBOARD",
51
+ SHARE: "SHARE",
52
+ CALL: "CALL"
53
+ };
54
+ function parseAttachment(value) {
55
+ const raw = asRecord(value, "attachment");
56
+ return { type: asString(raw.type ?? raw._type, "UNKNOWN"), raw };
57
+ }
58
+ // src/types/models.ts
59
+ var ChatType = {
60
+ DIALOG: "DIALOG",
61
+ CHAT: "CHAT",
62
+ CHANNEL: "CHANNEL"
63
+ };
64
+
65
+ class Message {
66
+ id;
67
+ chatId;
68
+ sender;
69
+ text;
70
+ time;
71
+ type;
72
+ cid;
73
+ attaches;
74
+ stats;
75
+ status;
76
+ reactionInfo;
77
+ options;
78
+ previousMessageId;
79
+ ttl;
80
+ unread;
81
+ mark;
82
+ elements;
83
+ raw;
84
+ actions = null;
85
+ constructor(payload) {
86
+ this.id = toMaxId(payload.id, "message.id");
87
+ this.chatId = optionalMaxId(payload.chatId, "message.chatId");
88
+ this.sender = optionalMaxId(payload.sender, "message.sender");
89
+ this.text = asString(payload.text);
90
+ this.time = asNumber(payload.time);
91
+ this.type = asString(payload.type);
92
+ this.cid = optionalMaxId(payload.cid, "message.cid");
93
+ this.attaches = asArray(payload.attaches).map(parseAttachment);
94
+ this.stats = optionalRecord(payload.stats);
95
+ this.status = typeof payload.status === "string" ? payload.status : null;
96
+ this.reactionInfo = parseReactionInfo(payload.reactionInfo);
97
+ this.options = typeof payload.options === "number" || optionalRecord(payload.options) !== null ? payload.options : null;
98
+ this.previousMessageId = optionalMaxId(payload.prevMessageId, "message.prevMessageId");
99
+ this.ttl = typeof payload.ttl === "boolean" ? payload.ttl : null;
100
+ this.unread = payload.unread === null || payload.unread === undefined ? null : asNumber(payload.unread);
101
+ this.mark = payload.mark === null || payload.mark === undefined ? null : asNumber(payload.mark);
102
+ this.elements = asArray(payload.elements).map((item) => asRecord(item, "element"));
103
+ this.raw = Object.freeze({ ...payload });
104
+ }
105
+ static fromPayload(value) {
106
+ return new Message(asRecord(value, "message"));
107
+ }
108
+ bind(actions) {
109
+ this.actions = actions;
110
+ return this;
111
+ }
112
+ async reply(text, options = {}) {
113
+ return await this.requireActions().sendMessage({
114
+ ...options,
115
+ chatId: this.requireChatId(),
116
+ text,
117
+ replyTo: this.id
118
+ });
119
+ }
120
+ async answer(text, options = {}) {
121
+ return await this.requireActions().sendMessage({
122
+ ...options,
123
+ chatId: this.requireChatId(),
124
+ text
125
+ });
126
+ }
127
+ async forward(chatId, notify = true) {
128
+ return await this.requireActions().forwardMessage({
129
+ chatId,
130
+ messageId: this.id,
131
+ sourceChatId: this.requireChatId(),
132
+ notify
133
+ });
134
+ }
135
+ async edit(text, attachments) {
136
+ return await this.requireActions().editMessage({
137
+ chatId: this.requireChatId(),
138
+ messageId: this.id,
139
+ text,
140
+ ...attachments !== undefined ? { attachments } : {}
141
+ });
142
+ }
143
+ async pin(notifyPin = true) {
144
+ return await this.requireActions().pinMessage({
145
+ chatId: this.requireChatId(),
146
+ messageId: this.id,
147
+ notifyPin
148
+ });
149
+ }
150
+ async delete(forMe = false) {
151
+ return await this.requireActions().deleteMessage({
152
+ chatId: this.requireChatId(),
153
+ messageIds: [this.id],
154
+ forMe
155
+ });
156
+ }
157
+ async read() {
158
+ return await this.requireActions().readMessage(this.id, this.requireChatId());
159
+ }
160
+ async react(reaction) {
161
+ return await this.requireActions().addReaction(this.requireChatId(), this.id, reaction);
162
+ }
163
+ async unreact() {
164
+ return await this.requireActions().removeReaction(this.requireChatId(), this.id);
165
+ }
166
+ async getReactions() {
167
+ return (await this.requireActions().getReactions(this.requireChatId(), [this.id]))?.get(this.id) ?? null;
168
+ }
169
+ requireActions() {
170
+ if (!this.actions)
171
+ throw new Error("Message is not bound to a client");
172
+ return this.actions;
173
+ }
174
+ requireChatId() {
175
+ if (this.chatId === null)
176
+ throw new Error("Message has no chatId");
177
+ return this.chatId;
178
+ }
179
+ }
180
+
181
+ class Chat {
182
+ id;
183
+ type;
184
+ status;
185
+ owner;
186
+ participants;
187
+ title;
188
+ lastMessage;
189
+ pinnedMessage;
190
+ lastEventTime;
191
+ link;
192
+ description;
193
+ raw;
194
+ messageActions = null;
195
+ chatActions = null;
196
+ constructor(payload) {
197
+ this.id = toMaxId(payload.id, "chat.id");
198
+ this.type = asString(payload.type);
199
+ this.status = asString(payload.status);
200
+ this.owner = optionalMaxId(payload.owner, "chat.owner") ?? 0n;
201
+ this.participants = parseParticipants(payload.participants);
202
+ this.title = typeof payload.title === "string" ? payload.title : null;
203
+ this.lastMessage = payload.lastMessage ? Message.fromPayload(payload.lastMessage) : null;
204
+ this.pinnedMessage = payload.pinnedMessage ? Message.fromPayload(payload.pinnedMessage) : null;
205
+ this.lastEventTime = asNumber(payload.lastEventTime);
206
+ this.link = typeof payload.link === "string" ? payload.link : null;
207
+ this.description = typeof payload.description === "string" ? payload.description : null;
208
+ this.raw = Object.freeze({ ...payload });
209
+ }
210
+ static fromPayload(value) {
211
+ return new Chat(asRecord(value, "chat"));
212
+ }
213
+ bind(messageActions, chatActions) {
214
+ this.messageActions = messageActions;
215
+ this.chatActions = chatActions;
216
+ this.lastMessage?.bind(messageActions);
217
+ this.pinnedMessage?.bind(messageActions);
218
+ return this;
219
+ }
220
+ async answer(text, options = {}) {
221
+ return await this.requireMessageActions().sendMessage({ ...options, chatId: this.id, text });
222
+ }
223
+ async history(options = {}) {
224
+ return await this.requireMessageActions().fetchHistory({ ...options, chatId: this.id });
225
+ }
226
+ async getMessage(messageId) {
227
+ return (await this.requireMessageActions().getMessages(this.id, [messageId]))[0] ?? null;
228
+ }
229
+ async getMessages(messageIds) {
230
+ return await this.requireMessageActions().getMessages(this.id, messageIds);
231
+ }
232
+ async leave() {
233
+ const actions = this.requireChatActions();
234
+ if (this.type === ChatType.CHANNEL)
235
+ await actions.leaveChannel(this.id);
236
+ else if (this.type === ChatType.CHAT)
237
+ await actions.leaveGroup(this.id);
238
+ else
239
+ throw new Error("Cannot leave a dialog");
240
+ }
241
+ async delete(forMe = true) {
242
+ return await this.requireChatActions().deleteChat(this.id, forMe);
243
+ }
244
+ async invite(userIds) {
245
+ return await this.requireChatActions().inviteUsersToGroup(this.id, userIds);
246
+ }
247
+ async removeUsers(userIds) {
248
+ return await this.requireChatActions().removeUsersFromGroup(this.id, userIds);
249
+ }
250
+ requireMessageActions() {
251
+ if (!this.messageActions)
252
+ throw new Error("Chat is not bound to a client");
253
+ return this.messageActions;
254
+ }
255
+ requireChatActions() {
256
+ if (!this.chatActions)
257
+ throw new Error("Chat is not bound to a client");
258
+ return this.chatActions;
259
+ }
260
+ }
261
+
262
+ class User {
263
+ id;
264
+ names;
265
+ phone;
266
+ status;
267
+ description;
268
+ gender;
269
+ link;
270
+ webApp;
271
+ raw;
272
+ actions = null;
273
+ constructor(payload) {
274
+ this.id = toMaxId(payload.id, "user.id");
275
+ this.names = asArray(payload.names).map((item) => {
276
+ const name = asRecord(item, "name");
277
+ return {
278
+ firstName: asString(name.firstName),
279
+ lastName: typeof name.lastName === "string" ? name.lastName : null,
280
+ ...typeof name.name === "string" ? { name: name.name } : {}
281
+ };
282
+ });
283
+ this.phone = optionalMaxId(payload.phone, "user.phone");
284
+ this.status = typeof payload.status === "string" ? payload.status : null;
285
+ this.description = typeof payload.description === "string" ? payload.description : null;
286
+ this.gender = typeof payload.gender === "string" || typeof payload.gender === "number" ? payload.gender : null;
287
+ this.link = typeof payload.link === "string" ? payload.link : null;
288
+ this.webApp = typeof payload.webApp === "string" ? payload.webApp : optionalRecord(payload.webApp);
289
+ this.raw = Object.freeze({ ...payload });
290
+ }
291
+ static fromPayload(value) {
292
+ return new User(asRecord(value, "user"));
293
+ }
294
+ bind(actions) {
295
+ this.actions = actions;
296
+ return this;
297
+ }
298
+ async addContact() {
299
+ return await this.requireActions().addContact(this.id);
300
+ }
301
+ async removeContact() {
302
+ return await this.requireActions().removeContact(this.id);
303
+ }
304
+ getChatId(userId) {
305
+ return this.requireActions().getChatId(userId, this.id);
306
+ }
307
+ requireActions() {
308
+ if (!this.actions)
309
+ throw new Error("User is not bound to a client");
310
+ return this.actions;
311
+ }
312
+ }
313
+
314
+ class Profile {
315
+ contact;
316
+ profileOptions;
317
+ raw;
318
+ constructor(payload) {
319
+ this.contact = User.fromPayload(payload.contact);
320
+ const rawOptions = payload.profileOptions ?? payload.options;
321
+ this.profileOptions = Array.isArray(rawOptions) ? rawOptions.map((item) => asNumber(item)) : null;
322
+ this.raw = Object.freeze({ ...payload });
323
+ }
324
+ static fromPayload(value) {
325
+ return new Profile(asRecord(value, "profile"));
326
+ }
327
+ }
328
+ function parseReactionInfo(value) {
329
+ if (value === null || value === undefined)
330
+ return null;
331
+ const payload = asRecord(value, "reactionInfo");
332
+ return {
333
+ totalCount: asNumber(payload.totalCount),
334
+ counters: asArray(payload.counters).map((item) => {
335
+ const counter = asRecord(item, "reactionCounter");
336
+ return { count: asNumber(counter.count), reaction: asString(counter.reaction) };
337
+ }),
338
+ yourReaction: typeof payload.yourReaction === "string" ? payload.yourReaction : null
339
+ };
340
+ }
341
+ function parseReadState(value) {
342
+ const payload = asRecord(value, "readState");
343
+ return { unread: asNumber(payload.unread), mark: asNumber(payload.mark) };
344
+ }
345
+ function parseParticipants(value) {
346
+ const result = new Map;
347
+ if (value instanceof Map) {
348
+ for (const [id, role] of value)
349
+ result.set(toMaxId(id), asNumber(role));
350
+ } else if (value !== null && typeof value === "object") {
351
+ for (const [id, role] of Object.entries(value))
352
+ result.set(toMaxId(id), asNumber(role));
353
+ }
354
+ return result;
355
+ }
356
+ export {
357
+ toMaxId,
358
+ parseReadState,
359
+ parseReactionInfo,
360
+ parseAttachment,
361
+ optionalRecord,
362
+ optionalMaxId,
363
+ asString,
364
+ asRecord,
365
+ asNumber,
366
+ asBoolean,
367
+ asArray,
368
+ User,
369
+ Profile,
370
+ Message,
371
+ ChatType,
372
+ Chat,
373
+ AttachmentType
374
+ };
375
+
376
+ //# debugId=1BCE9C92B9B3722A64756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types/utils.ts", "../src/types/attachments.ts", "../src/types/models.ts"],
4
+ "sourcesContent": [
5
+ "export type MaxId = bigint;\n\nexport function toMaxId(value: unknown, field = \"id\"): MaxId {\n if (typeof value === \"bigint\") return value;\n if (typeof value === \"string\" && /^-?\\d+$/.test(value)) return BigInt(value);\n if (typeof value === \"number\" && Number.isSafeInteger(value)) return BigInt(value);\n throw new TypeError(`${field} must be a lossless integer`);\n}\n\nexport function optionalMaxId(value: unknown, field = \"id\"): MaxId | null {\n return value === null || value === undefined ? null : toMaxId(value, field);\n}\n\nexport function asRecord(value: unknown, field = \"payload\"): Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(`${field} must be an object`);\n }\n return value as Record<string, unknown>;\n}\n\nexport function optionalRecord(value: unknown): Record<string, unknown> | null {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n}\n\nexport function asString(value: unknown, fallback = \"\"): string {\n return typeof value === \"string\" ? value : fallback;\n}\n\nexport function asNumber(value: unknown, fallback = 0): number {\n if (typeof value === \"bigint\") {\n const number = Number(value);\n return Number.isSafeInteger(number) ? number : fallback;\n }\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\nexport function asBoolean(value: unknown, fallback = false): boolean {\n return typeof value === \"boolean\" ? value : fallback;\n}\n\nexport function asArray(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [];\n}\n",
6
+ "import { asRecord, asString } from \"./utils.ts\";\n\nexport const AttachmentType = {\n PHOTO: \"PHOTO\",\n VIDEO: \"VIDEO\",\n FILE: \"FILE\",\n CONTACT: \"CONTACT\",\n STICKER: \"STICKER\",\n AUDIO: \"AUDIO\",\n CONTROL: \"CONTROL\",\n INLINE_KEYBOARD: \"INLINE_KEYBOARD\",\n SHARE: \"SHARE\",\n CALL: \"CALL\",\n} as const;\n\nexport interface Attachment {\n readonly type: string;\n readonly raw: Readonly<Record<string, unknown>>;\n}\n\nexport function parseAttachment(value: unknown): Attachment {\n const raw = asRecord(value, \"attachment\");\n return { type: asString(raw.type ?? raw._type, \"UNKNOWN\"), raw };\n}\n",
7
+ "import type { Attachment } from \"./attachments.ts\";\nimport { parseAttachment } from \"./attachments.ts\";\nimport {\n asArray,\n asNumber,\n asRecord,\n asString,\n optionalMaxId,\n optionalRecord,\n toMaxId,\n type MaxId,\n} from \"./utils.ts\";\n\nexport const ChatType = {\n DIALOG: \"DIALOG\",\n CHAT: \"CHAT\",\n CHANNEL: \"CHANNEL\",\n} as const;\n\nexport interface ReactionCounter {\n count: number;\n reaction: string;\n}\n\nexport interface ReactionInfo {\n totalCount: number;\n counters: ReactionCounter[];\n yourReaction: string | null;\n}\n\nexport interface ReadState {\n unread: number;\n mark: number;\n}\n\nexport interface MessageActions {\n sendMessage(options: SendMessageOptions): Promise<Message | null>;\n forwardMessage(options: ForwardMessageOptions): Promise<Message | null>;\n editMessage(options: EditMessageOptions): Promise<Message>;\n deleteMessage(options: { chatId: MaxId; messageIds: MaxId[]; forMe: boolean }): Promise<boolean>;\n pinMessage(options: { chatId: MaxId; messageId: MaxId; notifyPin: boolean }): Promise<boolean>;\n readMessage(messageId: MaxId, chatId: MaxId): Promise<ReadState>;\n addReaction(chatId: MaxId, messageId: MaxId, reaction: string): Promise<ReactionInfo | null>;\n removeReaction(chatId: MaxId, messageId: MaxId): Promise<ReactionInfo | null>;\n getReactions(chatId: MaxId, messageIds: MaxId[]): Promise<Map<MaxId, ReactionInfo> | null>;\n getMessages(chatId: MaxId, messageIds: MaxId[]): Promise<Message[]>;\n fetchHistory(options: HistoryOptions): Promise<Message[] | null>;\n}\n\nexport interface ChatActions {\n leaveGroup(chatId: MaxId): Promise<void>;\n leaveChannel(chatId: MaxId): Promise<void>;\n deleteChat(chatId: MaxId, forMe: boolean): Promise<boolean>;\n inviteUsersToGroup(chatId: MaxId, userIds: MaxId[]): Promise<Chat | null>;\n removeUsersFromGroup(chatId: MaxId, userIds: MaxId[]): Promise<Chat | null>;\n}\n\nexport interface UserActions {\n addContact(contactId: MaxId): Promise<User>;\n removeContact(contactId: MaxId): Promise<boolean>;\n getChatId(firstUserId: MaxId, secondUserId: MaxId): MaxId;\n}\n\nexport interface SendMessageOptions {\n chatId: MaxId;\n text: string;\n replyTo?: MaxId | null;\n attachments?: readonly unknown[] | null;\n notify?: boolean;\n}\n\nexport interface ForwardMessageOptions {\n chatId: MaxId;\n messageId: MaxId;\n sourceChatId?: MaxId | null;\n notify?: boolean;\n}\n\nexport interface EditMessageOptions {\n chatId: MaxId;\n messageId: MaxId;\n text: string;\n attachments?: readonly unknown[] | null;\n}\n\nexport interface HistoryOptions {\n chatId: MaxId;\n forward?: number;\n backward?: number;\n backwardTime?: number;\n forwardTime?: number;\n from?: number;\n itemType?: string;\n getChat?: boolean;\n getMessages?: boolean;\n interactive?: boolean;\n}\n\nexport class Message {\n readonly id: MaxId;\n chatId: MaxId | null;\n readonly sender: MaxId | null;\n readonly text: string;\n readonly time: number;\n readonly type: string;\n readonly cid: MaxId | null;\n readonly attaches: Attachment[];\n readonly stats: Record<string, unknown> | null;\n readonly status: string | null;\n readonly reactionInfo: ReactionInfo | null;\n readonly options: number | Record<string, unknown> | null;\n readonly previousMessageId: MaxId | null;\n readonly ttl: boolean | null;\n readonly unread: number | null;\n readonly mark: number | null;\n readonly elements: Record<string, unknown>[];\n readonly raw: Readonly<Record<string, unknown>>;\n private actions: MessageActions | null = null;\n\n private constructor(payload: Record<string, unknown>) {\n this.id = toMaxId(payload.id, \"message.id\");\n this.chatId = optionalMaxId(payload.chatId, \"message.chatId\");\n this.sender = optionalMaxId(payload.sender, \"message.sender\");\n this.text = asString(payload.text);\n this.time = asNumber(payload.time);\n this.type = asString(payload.type);\n this.cid = optionalMaxId(payload.cid, \"message.cid\");\n this.attaches = asArray(payload.attaches).map(parseAttachment);\n this.stats = optionalRecord(payload.stats);\n this.status = typeof payload.status === \"string\" ? payload.status : null;\n this.reactionInfo = parseReactionInfo(payload.reactionInfo);\n this.options =\n typeof payload.options === \"number\" || optionalRecord(payload.options) !== null\n ? (payload.options as number | Record<string, unknown>)\n : null;\n this.previousMessageId = optionalMaxId(payload.prevMessageId, \"message.prevMessageId\");\n this.ttl = typeof payload.ttl === \"boolean\" ? payload.ttl : null;\n this.unread =\n payload.unread === null || payload.unread === undefined ? null : asNumber(payload.unread);\n this.mark = payload.mark === null || payload.mark === undefined ? null : asNumber(payload.mark);\n this.elements = asArray(payload.elements).map((item) => asRecord(item, \"element\"));\n this.raw = Object.freeze({ ...payload });\n }\n\n static fromPayload(value: unknown): Message {\n return new Message(asRecord(value, \"message\"));\n }\n\n bind(actions: MessageActions): this {\n this.actions = actions;\n return this;\n }\n\n async reply(\n text: string,\n options: Omit<SendMessageOptions, \"chatId\" | \"text\" | \"replyTo\"> = {},\n ): Promise<Message | null> {\n return await this.requireActions().sendMessage({\n ...options,\n chatId: this.requireChatId(),\n text,\n replyTo: this.id,\n });\n }\n\n async answer(\n text: string,\n options: Omit<SendMessageOptions, \"chatId\" | \"text\"> = {},\n ): Promise<Message | null> {\n return await this.requireActions().sendMessage({\n ...options,\n chatId: this.requireChatId(),\n text,\n });\n }\n\n async forward(chatId: MaxId, notify = true): Promise<Message | null> {\n return await this.requireActions().forwardMessage({\n chatId,\n messageId: this.id,\n sourceChatId: this.requireChatId(),\n notify,\n });\n }\n\n async edit(text: string, attachments?: readonly unknown[] | null): Promise<Message> {\n return await this.requireActions().editMessage({\n chatId: this.requireChatId(),\n messageId: this.id,\n text,\n ...(attachments !== undefined ? { attachments } : {}),\n });\n }\n\n async pin(notifyPin = true): Promise<boolean> {\n return await this.requireActions().pinMessage({\n chatId: this.requireChatId(),\n messageId: this.id,\n notifyPin,\n });\n }\n\n async delete(forMe = false): Promise<boolean> {\n return await this.requireActions().deleteMessage({\n chatId: this.requireChatId(),\n messageIds: [this.id],\n forMe,\n });\n }\n\n async read(): Promise<ReadState> {\n return await this.requireActions().readMessage(this.id, this.requireChatId());\n }\n\n async react(reaction: string): Promise<ReactionInfo | null> {\n return await this.requireActions().addReaction(this.requireChatId(), this.id, reaction);\n }\n\n async unreact(): Promise<ReactionInfo | null> {\n return await this.requireActions().removeReaction(this.requireChatId(), this.id);\n }\n\n async getReactions(): Promise<ReactionInfo | null> {\n return (\n (await this.requireActions().getReactions(this.requireChatId(), [this.id]))?.get(this.id) ??\n null\n );\n }\n\n private requireActions(): MessageActions {\n if (!this.actions) throw new Error(\"Message is not bound to a client\");\n return this.actions;\n }\n\n private requireChatId(): MaxId {\n if (this.chatId === null) throw new Error(\"Message has no chatId\");\n return this.chatId;\n }\n}\n\nexport class Chat {\n readonly id: MaxId;\n readonly type: string;\n readonly status: string;\n readonly owner: MaxId;\n readonly participants: Map<MaxId, number>;\n readonly title: string | null;\n readonly lastMessage: Message | null;\n readonly pinnedMessage: Message | null;\n readonly lastEventTime: number;\n readonly link: string | null;\n readonly description: string | null;\n readonly raw: Readonly<Record<string, unknown>>;\n private messageActions: MessageActions | null = null;\n private chatActions: ChatActions | null = null;\n\n private constructor(payload: Record<string, unknown>) {\n this.id = toMaxId(payload.id, \"chat.id\");\n this.type = asString(payload.type);\n this.status = asString(payload.status);\n this.owner = optionalMaxId(payload.owner, \"chat.owner\") ?? 0n;\n this.participants = parseParticipants(payload.participants);\n this.title = typeof payload.title === \"string\" ? payload.title : null;\n this.lastMessage = payload.lastMessage ? Message.fromPayload(payload.lastMessage) : null;\n this.pinnedMessage = payload.pinnedMessage ? Message.fromPayload(payload.pinnedMessage) : null;\n this.lastEventTime = asNumber(payload.lastEventTime);\n this.link = typeof payload.link === \"string\" ? payload.link : null;\n this.description = typeof payload.description === \"string\" ? payload.description : null;\n this.raw = Object.freeze({ ...payload });\n }\n\n static fromPayload(value: unknown): Chat {\n return new Chat(asRecord(value, \"chat\"));\n }\n\n bind(messageActions: MessageActions, chatActions: ChatActions): this {\n this.messageActions = messageActions;\n this.chatActions = chatActions;\n this.lastMessage?.bind(messageActions);\n this.pinnedMessage?.bind(messageActions);\n return this;\n }\n\n async answer(\n text: string,\n options: Omit<SendMessageOptions, \"chatId\" | \"text\"> = {},\n ): Promise<Message | null> {\n return await this.requireMessageActions().sendMessage({ ...options, chatId: this.id, text });\n }\n\n async history(options: Omit<HistoryOptions, \"chatId\"> = {}): Promise<Message[] | null> {\n return await this.requireMessageActions().fetchHistory({ ...options, chatId: this.id });\n }\n\n async getMessage(messageId: MaxId): Promise<Message | null> {\n return (await this.requireMessageActions().getMessages(this.id, [messageId]))[0] ?? null;\n }\n\n async getMessages(messageIds: MaxId[]): Promise<Message[]> {\n return await this.requireMessageActions().getMessages(this.id, messageIds);\n }\n\n async leave(): Promise<void> {\n const actions = this.requireChatActions();\n if (this.type === ChatType.CHANNEL) await actions.leaveChannel(this.id);\n else if (this.type === ChatType.CHAT) await actions.leaveGroup(this.id);\n else throw new Error(\"Cannot leave a dialog\");\n }\n\n async delete(forMe = true): Promise<boolean> {\n return await this.requireChatActions().deleteChat(this.id, forMe);\n }\n\n async invite(userIds: MaxId[]): Promise<Chat | null> {\n return await this.requireChatActions().inviteUsersToGroup(this.id, userIds);\n }\n\n async removeUsers(userIds: MaxId[]): Promise<Chat | null> {\n return await this.requireChatActions().removeUsersFromGroup(this.id, userIds);\n }\n\n private requireMessageActions(): MessageActions {\n if (!this.messageActions) throw new Error(\"Chat is not bound to a client\");\n return this.messageActions;\n }\n private requireChatActions(): ChatActions {\n if (!this.chatActions) throw new Error(\"Chat is not bound to a client\");\n return this.chatActions;\n }\n}\n\nexport class User {\n readonly id: MaxId;\n readonly names: ReadonlyArray<{ firstName: string; lastName: string | null; name?: string }>;\n readonly phone: MaxId | null;\n readonly status: string | null;\n readonly description: string | null;\n readonly gender: string | number | null;\n readonly link: string | null;\n readonly webApp: Record<string, unknown> | string | null;\n readonly raw: Readonly<Record<string, unknown>>;\n private actions: UserActions | null = null;\n\n private constructor(payload: Record<string, unknown>) {\n this.id = toMaxId(payload.id, \"user.id\");\n this.names = asArray(payload.names).map((item) => {\n const name = asRecord(item, \"name\");\n return {\n firstName: asString(name.firstName),\n lastName: typeof name.lastName === \"string\" ? name.lastName : null,\n ...(typeof name.name === \"string\" ? { name: name.name } : {}),\n };\n });\n this.phone = optionalMaxId(payload.phone, \"user.phone\");\n this.status = typeof payload.status === \"string\" ? payload.status : null;\n this.description = typeof payload.description === \"string\" ? payload.description : null;\n this.gender =\n typeof payload.gender === \"string\" || typeof payload.gender === \"number\"\n ? payload.gender\n : null;\n this.link = typeof payload.link === \"string\" ? payload.link : null;\n this.webApp =\n typeof payload.webApp === \"string\" ? payload.webApp : optionalRecord(payload.webApp);\n this.raw = Object.freeze({ ...payload });\n }\n\n static fromPayload(value: unknown): User {\n return new User(asRecord(value, \"user\"));\n }\n bind(actions: UserActions): this {\n this.actions = actions;\n return this;\n }\n async addContact(): Promise<User> {\n return await this.requireActions().addContact(this.id);\n }\n async removeContact(): Promise<boolean> {\n return await this.requireActions().removeContact(this.id);\n }\n getChatId(userId: MaxId): MaxId {\n return this.requireActions().getChatId(userId, this.id);\n }\n private requireActions(): UserActions {\n if (!this.actions) throw new Error(\"User is not bound to a client\");\n return this.actions;\n }\n}\n\nexport class Profile {\n readonly contact: User;\n readonly profileOptions: number[] | null;\n readonly raw: Readonly<Record<string, unknown>>;\n private constructor(payload: Record<string, unknown>) {\n this.contact = User.fromPayload(payload.contact);\n const rawOptions = payload.profileOptions ?? payload.options;\n this.profileOptions = Array.isArray(rawOptions)\n ? rawOptions.map((item) => asNumber(item))\n : null;\n this.raw = Object.freeze({ ...payload });\n }\n static fromPayload(value: unknown): Profile {\n return new Profile(asRecord(value, \"profile\"));\n }\n}\n\nexport interface MessageDeleteEvent {\n chatId: MaxId;\n messageIds: MaxId[];\n chat?: Chat | null;\n message?: Message | null;\n ttl?: boolean;\n}\nexport interface MessageReadEvent {\n chatId: MaxId;\n userId: MaxId | null;\n mark: number;\n}\nexport interface TypingEvent {\n chatId: MaxId;\n userId: MaxId;\n typing: boolean;\n}\nexport interface PresenceEvent {\n userId: MaxId;\n online: boolean;\n lastSeen: number | null;\n raw: Readonly<Record<string, unknown>>;\n}\nexport interface ReactionUpdateEvent {\n chatId: MaxId;\n messageId: MaxId;\n reactionInfo: ReactionInfo | null;\n}\n\nexport function parseReactionInfo(value: unknown): ReactionInfo | null {\n if (value === null || value === undefined) return null;\n const payload = asRecord(value, \"reactionInfo\");\n return {\n totalCount: asNumber(payload.totalCount),\n counters: asArray(payload.counters).map((item) => {\n const counter = asRecord(item, \"reactionCounter\");\n return { count: asNumber(counter.count), reaction: asString(counter.reaction) };\n }),\n yourReaction: typeof payload.yourReaction === \"string\" ? payload.yourReaction : null,\n };\n}\n\nexport function parseReadState(value: unknown): ReadState {\n const payload = asRecord(value, \"readState\");\n return { unread: asNumber(payload.unread), mark: asNumber(payload.mark) };\n}\n\nfunction parseParticipants(value: unknown): Map<MaxId, number> {\n const result = new Map<MaxId, number>();\n if (value instanceof Map) {\n for (const [id, role] of value) result.set(toMaxId(id), asNumber(role));\n } else if (value !== null && typeof value === \"object\") {\n for (const [id, role] of Object.entries(value)) result.set(toMaxId(id), asNumber(role));\n }\n return result;\n}\n"
8
+ ],
9
+ "mappings": ";;AAEO,SAAS,OAAO,CAAC,OAAgB,QAAQ,MAAa;AAAA,EAC3D,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO;AAAA,EACtC,IAAI,OAAO,UAAU,YAAY,UAAU,KAAK,KAAK;AAAA,IAAG,OAAO,OAAO,KAAK;AAAA,EAC3E,IAAI,OAAO,UAAU,YAAY,OAAO,cAAc,KAAK;AAAA,IAAG,OAAO,OAAO,KAAK;AAAA,EACjF,MAAM,IAAI,UAAU,GAAG,kCAAkC;AAAA;AAGpD,SAAS,aAAa,CAAC,OAAgB,QAAQ,MAAoB;AAAA,EACxE,OAAO,UAAU,QAAQ,UAAU,YAAY,OAAO,QAAQ,OAAO,KAAK;AAAA;AAGrE,SAAS,QAAQ,CAAC,OAAgB,QAAQ,WAAoC;AAAA,EACnF,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AAAA,IACvE,MAAM,IAAI,UAAU,GAAG,yBAAyB;AAAA,EAClD;AAAA,EACA,OAAO;AAAA;AAGF,SAAS,cAAc,CAAC,OAAgD;AAAA,EAC7E,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD;AAAA;AAGC,SAAS,QAAQ,CAAC,OAAgB,WAAW,IAAY;AAAA,E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,IAAI,CAAC;AAAA,EACxE,EAAO,SAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAAA,IACtD,YAAY,IAAI,SAAS,OAAO,QAAQ,KAAK;AAAA,MAAG,OAAO,IAAI,QAAQ,EAAE,GAAG,SAAS,IAAI,CAAC;AAAA,EACxF;AAAA,EACA,OAAO;AAAA;",
10
+ "debugId": "1BCE9C92B9B3722A64756E2164756E21",
11
+ "names": []
12
+ }
@@ -0,0 +1,210 @@
1
+ import type { Attachment } from "./attachments.ts";
2
+ import { type MaxId } from "./utils.ts";
3
+ export declare const ChatType: {
4
+ readonly DIALOG: "DIALOG";
5
+ readonly CHAT: "CHAT";
6
+ readonly CHANNEL: "CHANNEL";
7
+ };
8
+ export interface ReactionCounter {
9
+ count: number;
10
+ reaction: string;
11
+ }
12
+ export interface ReactionInfo {
13
+ totalCount: number;
14
+ counters: ReactionCounter[];
15
+ yourReaction: string | null;
16
+ }
17
+ export interface ReadState {
18
+ unread: number;
19
+ mark: number;
20
+ }
21
+ export interface MessageActions {
22
+ sendMessage(options: SendMessageOptions): Promise<Message | null>;
23
+ forwardMessage(options: ForwardMessageOptions): Promise<Message | null>;
24
+ editMessage(options: EditMessageOptions): Promise<Message>;
25
+ deleteMessage(options: {
26
+ chatId: MaxId;
27
+ messageIds: MaxId[];
28
+ forMe: boolean;
29
+ }): Promise<boolean>;
30
+ pinMessage(options: {
31
+ chatId: MaxId;
32
+ messageId: MaxId;
33
+ notifyPin: boolean;
34
+ }): Promise<boolean>;
35
+ readMessage(messageId: MaxId, chatId: MaxId): Promise<ReadState>;
36
+ addReaction(chatId: MaxId, messageId: MaxId, reaction: string): Promise<ReactionInfo | null>;
37
+ removeReaction(chatId: MaxId, messageId: MaxId): Promise<ReactionInfo | null>;
38
+ getReactions(chatId: MaxId, messageIds: MaxId[]): Promise<Map<MaxId, ReactionInfo> | null>;
39
+ getMessages(chatId: MaxId, messageIds: MaxId[]): Promise<Message[]>;
40
+ fetchHistory(options: HistoryOptions): Promise<Message[] | null>;
41
+ }
42
+ export interface ChatActions {
43
+ leaveGroup(chatId: MaxId): Promise<void>;
44
+ leaveChannel(chatId: MaxId): Promise<void>;
45
+ deleteChat(chatId: MaxId, forMe: boolean): Promise<boolean>;
46
+ inviteUsersToGroup(chatId: MaxId, userIds: MaxId[]): Promise<Chat | null>;
47
+ removeUsersFromGroup(chatId: MaxId, userIds: MaxId[]): Promise<Chat | null>;
48
+ }
49
+ export interface UserActions {
50
+ addContact(contactId: MaxId): Promise<User>;
51
+ removeContact(contactId: MaxId): Promise<boolean>;
52
+ getChatId(firstUserId: MaxId, secondUserId: MaxId): MaxId;
53
+ }
54
+ export interface SendMessageOptions {
55
+ chatId: MaxId;
56
+ text: string;
57
+ replyTo?: MaxId | null;
58
+ attachments?: readonly unknown[] | null;
59
+ notify?: boolean;
60
+ }
61
+ export interface ForwardMessageOptions {
62
+ chatId: MaxId;
63
+ messageId: MaxId;
64
+ sourceChatId?: MaxId | null;
65
+ notify?: boolean;
66
+ }
67
+ export interface EditMessageOptions {
68
+ chatId: MaxId;
69
+ messageId: MaxId;
70
+ text: string;
71
+ attachments?: readonly unknown[] | null;
72
+ }
73
+ export interface HistoryOptions {
74
+ chatId: MaxId;
75
+ forward?: number;
76
+ backward?: number;
77
+ backwardTime?: number;
78
+ forwardTime?: number;
79
+ from?: number;
80
+ itemType?: string;
81
+ getChat?: boolean;
82
+ getMessages?: boolean;
83
+ interactive?: boolean;
84
+ }
85
+ export declare class Message {
86
+ readonly id: MaxId;
87
+ chatId: MaxId | null;
88
+ readonly sender: MaxId | null;
89
+ readonly text: string;
90
+ readonly time: number;
91
+ readonly type: string;
92
+ readonly cid: MaxId | null;
93
+ readonly attaches: Attachment[];
94
+ readonly stats: Record<string, unknown> | null;
95
+ readonly status: string | null;
96
+ readonly reactionInfo: ReactionInfo | null;
97
+ readonly options: number | Record<string, unknown> | null;
98
+ readonly previousMessageId: MaxId | null;
99
+ readonly ttl: boolean | null;
100
+ readonly unread: number | null;
101
+ readonly mark: number | null;
102
+ readonly elements: Record<string, unknown>[];
103
+ readonly raw: Readonly<Record<string, unknown>>;
104
+ private actions;
105
+ private constructor();
106
+ static fromPayload(value: unknown): Message;
107
+ bind(actions: MessageActions): this;
108
+ reply(text: string, options?: Omit<SendMessageOptions, "chatId" | "text" | "replyTo">): Promise<Message | null>;
109
+ answer(text: string, options?: Omit<SendMessageOptions, "chatId" | "text">): Promise<Message | null>;
110
+ forward(chatId: MaxId, notify?: boolean): Promise<Message | null>;
111
+ edit(text: string, attachments?: readonly unknown[] | null): Promise<Message>;
112
+ pin(notifyPin?: boolean): Promise<boolean>;
113
+ delete(forMe?: boolean): Promise<boolean>;
114
+ read(): Promise<ReadState>;
115
+ react(reaction: string): Promise<ReactionInfo | null>;
116
+ unreact(): Promise<ReactionInfo | null>;
117
+ getReactions(): Promise<ReactionInfo | null>;
118
+ private requireActions;
119
+ private requireChatId;
120
+ }
121
+ export declare class Chat {
122
+ readonly id: MaxId;
123
+ readonly type: string;
124
+ readonly status: string;
125
+ readonly owner: MaxId;
126
+ readonly participants: Map<MaxId, number>;
127
+ readonly title: string | null;
128
+ readonly lastMessage: Message | null;
129
+ readonly pinnedMessage: Message | null;
130
+ readonly lastEventTime: number;
131
+ readonly link: string | null;
132
+ readonly description: string | null;
133
+ readonly raw: Readonly<Record<string, unknown>>;
134
+ private messageActions;
135
+ private chatActions;
136
+ private constructor();
137
+ static fromPayload(value: unknown): Chat;
138
+ bind(messageActions: MessageActions, chatActions: ChatActions): this;
139
+ answer(text: string, options?: Omit<SendMessageOptions, "chatId" | "text">): Promise<Message | null>;
140
+ history(options?: Omit<HistoryOptions, "chatId">): Promise<Message[] | null>;
141
+ getMessage(messageId: MaxId): Promise<Message | null>;
142
+ getMessages(messageIds: MaxId[]): Promise<Message[]>;
143
+ leave(): Promise<void>;
144
+ delete(forMe?: boolean): Promise<boolean>;
145
+ invite(userIds: MaxId[]): Promise<Chat | null>;
146
+ removeUsers(userIds: MaxId[]): Promise<Chat | null>;
147
+ private requireMessageActions;
148
+ private requireChatActions;
149
+ }
150
+ export declare class User {
151
+ readonly id: MaxId;
152
+ readonly names: ReadonlyArray<{
153
+ firstName: string;
154
+ lastName: string | null;
155
+ name?: string;
156
+ }>;
157
+ readonly phone: MaxId | null;
158
+ readonly status: string | null;
159
+ readonly description: string | null;
160
+ readonly gender: string | number | null;
161
+ readonly link: string | null;
162
+ readonly webApp: Record<string, unknown> | string | null;
163
+ readonly raw: Readonly<Record<string, unknown>>;
164
+ private actions;
165
+ private constructor();
166
+ static fromPayload(value: unknown): User;
167
+ bind(actions: UserActions): this;
168
+ addContact(): Promise<User>;
169
+ removeContact(): Promise<boolean>;
170
+ getChatId(userId: MaxId): MaxId;
171
+ private requireActions;
172
+ }
173
+ export declare class Profile {
174
+ readonly contact: User;
175
+ readonly profileOptions: number[] | null;
176
+ readonly raw: Readonly<Record<string, unknown>>;
177
+ private constructor();
178
+ static fromPayload(value: unknown): Profile;
179
+ }
180
+ export interface MessageDeleteEvent {
181
+ chatId: MaxId;
182
+ messageIds: MaxId[];
183
+ chat?: Chat | null;
184
+ message?: Message | null;
185
+ ttl?: boolean;
186
+ }
187
+ export interface MessageReadEvent {
188
+ chatId: MaxId;
189
+ userId: MaxId | null;
190
+ mark: number;
191
+ }
192
+ export interface TypingEvent {
193
+ chatId: MaxId;
194
+ userId: MaxId;
195
+ typing: boolean;
196
+ }
197
+ export interface PresenceEvent {
198
+ userId: MaxId;
199
+ online: boolean;
200
+ lastSeen: number | null;
201
+ raw: Readonly<Record<string, unknown>>;
202
+ }
203
+ export interface ReactionUpdateEvent {
204
+ chatId: MaxId;
205
+ messageId: MaxId;
206
+ reactionInfo: ReactionInfo | null;
207
+ }
208
+ export declare function parseReactionInfo(value: unknown): ReactionInfo | null;
209
+ export declare function parseReadState(value: unknown): ReadState;
210
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/types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