@imessaging/core 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imessaging/core",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Core messaging transport contracts and Telegram peer storage",
5
5
  "keywords": [
6
6
  "messaging",
package/src/index.ts CHANGED
@@ -23,6 +23,8 @@ export type {
23
23
  EditableMessageTransport,
24
24
  EditResult,
25
25
  EmailRecipient,
26
+ HeadhunterRecipient,
27
+ MaxRecipient,
26
28
  MessageRecipient,
27
29
  MessageTransport,
28
30
  OutboundButton,
package/src/types.ts CHANGED
@@ -25,7 +25,24 @@ export type EmailRecipient = {
25
25
  name?: string;
26
26
  };
27
27
 
28
- export type MessageRecipient = UsernameRecipient | TelegramIdRecipient | EmailRecipient;
28
+ /** Чат MAX. `chatId` выдаёт API MAX; это не номер телефона пользователя. */
29
+ export type MaxRecipient = {
30
+ type: "max";
31
+ chatId: string;
32
+ };
33
+
34
+ /** Диалог (отклик) HeadHunter, в который работодатель уже может написать. */
35
+ export type HeadhunterRecipient = {
36
+ type: "headhunter";
37
+ negotiationId: string;
38
+ };
39
+
40
+ export type MessageRecipient =
41
+ | UsernameRecipient
42
+ | TelegramIdRecipient
43
+ | EmailRecipient
44
+ | MaxRecipient
45
+ | HeadhunterRecipient;
29
46
 
30
47
  /** Получатель, адресуемый в Telegram. Сужение для транспортов, которые кроме него ничего не умеют. */
31
48
  export type TelegramRecipient = UsernameRecipient | TelegramIdRecipient;
@@ -37,7 +54,12 @@ export type TelegramRecipient = UsernameRecipient | TelegramIdRecipient;
37
54
  * по местам использования `recipient.id` и в каждом будет своей.
38
55
  */
39
56
  export function isTelegramRecipient(recipient: MessageRecipient): recipient is TelegramRecipient {
40
- return recipient.type !== "email";
57
+ return (
58
+ recipient.type === "username" ||
59
+ recipient.type === "user" ||
60
+ recipient.type === "group" ||
61
+ recipient.type === "channel"
62
+ );
41
63
  }
42
64
 
43
65
  export type OutboundDocument = {
@@ -214,6 +236,24 @@ export type IncomingMessage = {
214
236
  attachments: IncomingAttachment[];
215
237
  replyToMessageId?: string;
216
238
  threadId?: number;
239
+ /**
240
+ * Откуда сообщение переслано. Есть только у форварда.
241
+ *
242
+ * Нужно не для истории: в канале-агрегаторе лежат ЧУЖИЕ сообщения, и владелец вакансии —
243
+ * канал-источник, а не тот, в котором она оказалась. Без этого поля продукт приписал бы её
244
+ * агрегатору, то есть не тому заказчику.
245
+ *
246
+ * `chatId` может отсутствовать: автор форварда вправе скрыть источник — тогда известно только
247
+ * имя (`title`), а иногда и его нет.
248
+ */
249
+ forwardedFrom?: {
250
+ chatId?: string;
251
+ chatType?: IncomingMessage["chatType"];
252
+ /** Как назван источник в самом форварде: имя канала или человека. */
253
+ title?: string;
254
+ /** Номер сообщения в источнике, если он известен. */
255
+ messageId?: string;
256
+ };
217
257
  };
218
258
 
219
259
  /**