@imessaging/core 0.8.14 → 0.8.16
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 +1 -1
- package/src/index.ts +3 -0
- package/src/types.ts +34 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export {
|
|
|
12
12
|
type TextFormat,
|
|
13
13
|
} from "./markup";
|
|
14
14
|
export { MemoryCursorStore } from "./memory-cursor-store";
|
|
15
|
+
export { PartialSendError } from "./types";
|
|
15
16
|
export { MemoryPeerStore } from "./memory-peer-store";
|
|
16
17
|
export { createPeerKey } from "./peer-key";
|
|
17
18
|
export {
|
|
@@ -71,11 +72,13 @@ export type {
|
|
|
71
72
|
OutboundButton,
|
|
72
73
|
OutboundDocument,
|
|
73
74
|
OutboundMessage,
|
|
75
|
+
OutboundVideo,
|
|
74
76
|
ReactionTransport,
|
|
75
77
|
ResolvedPeer,
|
|
76
78
|
SelfAccount,
|
|
77
79
|
SelfAwareTransport,
|
|
78
80
|
SendResult,
|
|
81
|
+
SentPart,
|
|
79
82
|
TelegramPeerStore,
|
|
80
83
|
TelegramRecipient,
|
|
81
84
|
TransportStatus,
|
package/src/types.ts
CHANGED
|
@@ -77,11 +77,21 @@ export function isTelegramRecipient(recipient: MessageRecipient): recipient is T
|
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/** Вложение: байты в памяти (`data`) или файл на диске (`path`) — ровно одно из двух. */
|
|
80
81
|
export type OutboundDocument = {
|
|
81
|
-
data: Uint8Array;
|
|
82
82
|
filename: string;
|
|
83
83
|
caption?: string;
|
|
84
84
|
mimeType?: string;
|
|
85
|
+
/** Видео: канал покажет плеер, а не файл. Размеры и длительность в секундах — снять ffprobe. */
|
|
86
|
+
video?: OutboundVideo;
|
|
87
|
+
} & ({ data: Uint8Array; path?: never } | { path: string; data?: never });
|
|
88
|
+
|
|
89
|
+
export type OutboundVideo = {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
duration: number;
|
|
93
|
+
/** Можно смотреть до полной загрузки (mp4 с moov в начале). */
|
|
94
|
+
supportsStreaming?: boolean;
|
|
85
95
|
};
|
|
86
96
|
|
|
87
97
|
export type OutboundButton = {
|
|
@@ -96,6 +106,8 @@ export type OutboundMessage = {
|
|
|
96
106
|
replyToMessageId?: number;
|
|
97
107
|
threadId?: number;
|
|
98
108
|
documents?: OutboundDocument[];
|
|
109
|
+
/** telegram-mtproto: текст — подпись первого вложения вместо его `caption`. Пустой `text` — только вложения. */
|
|
110
|
+
textAsCaption?: boolean;
|
|
99
111
|
buttons?: OutboundButton[][];
|
|
100
112
|
/**
|
|
101
113
|
* Снять постоянную клавиатуру (ReplyKeyboardMarkup) у собеседника. Действует без `buttons`;
|
|
@@ -119,8 +131,27 @@ export type SendResult = {
|
|
|
119
131
|
recipientId: string;
|
|
120
132
|
/** Получатель — взаимный контакт учётки. Нет — канал не прислал пользователя в ответе на отправку. */
|
|
121
133
|
mutualContact?: boolean;
|
|
134
|
+
/** Все отправленные сообщения по порядку. Нет — транспорт их не перечисляет. */
|
|
135
|
+
parts?: SentPart[];
|
|
122
136
|
};
|
|
123
137
|
|
|
138
|
+
/** Одно отправленное сообщение. `media: false` у вложения — канал принял сообщение без файла. */
|
|
139
|
+
export type SentPart = { messageId: string; kind: "text" | "document"; media: boolean };
|
|
140
|
+
|
|
141
|
+
/** Отправка оборвалась, когда часть уже в чате: `parts` — что ушло, повтор целиком задвоит. */
|
|
142
|
+
export class PartialSendError extends Error {
|
|
143
|
+
constructor(
|
|
144
|
+
readonly parts: SentPart[],
|
|
145
|
+
cause: unknown,
|
|
146
|
+
) {
|
|
147
|
+
super(
|
|
148
|
+
`Отправлено частично (${parts.length}): ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
149
|
+
{ cause },
|
|
150
|
+
);
|
|
151
|
+
this.name = "PartialSendError";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
124
155
|
/**
|
|
125
156
|
* Правка уже отправленного сообщения.
|
|
126
157
|
*
|
|
@@ -425,6 +456,8 @@ export type MessageDraft = {
|
|
|
425
456
|
format?: TextFormat;
|
|
426
457
|
/** Черновик ответом на это сообщение. */
|
|
427
458
|
replyToMessageId?: string;
|
|
459
|
+
/** Тема форума: черновик ложится в неё, а не в общий чат. */
|
|
460
|
+
threadId?: number;
|
|
428
461
|
};
|
|
429
462
|
|
|
430
463
|
export interface DraftTransport extends MessageTransport {
|