itd-api 0.0.5 → 0.0.7
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/README.md +107 -1
- package/dist/{chunk-YM2YUO4D.cjs → chunk-3RNNZJZ4.cjs} +290 -55
- package/dist/chunk-3RNNZJZ4.cjs.map +1 -0
- package/dist/{chunk-RUPF4X5L.js → chunk-CG4SERVM.js} +286 -56
- package/dist/chunk-CG4SERVM.js.map +1 -0
- package/dist/{index-Dv0LXpMf.d.cts → index-DNFPX_Z1.d.cts} +348 -62
- package/dist/{index-Dv0LXpMf.d.ts → index-DNFPX_Z1.d.ts} +348 -62
- package/dist/index.cjs +104 -84
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.cjs +103 -83
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/package.json +5 -4
- package/dist/chunk-RUPF4X5L.js.map +0 -1
- package/dist/chunk-YM2YUO4D.cjs.map +0 -1
|
@@ -97,6 +97,39 @@ declare const AttachmentType: Readonly<{
|
|
|
97
97
|
readonly Audio: "audio";
|
|
98
98
|
}>;
|
|
99
99
|
type AttachmentType = (typeof AttachmentType)[keyof typeof AttachmentType];
|
|
100
|
+
/**
|
|
101
|
+
* Тип фрагмента разметки в тексте поста или комментария.
|
|
102
|
+
*
|
|
103
|
+
* Первые два сервер расставляет сам при разборе текста, остальные приходят от редактора.
|
|
104
|
+
* Тип открытый: набор может пополниться.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* await itd.posts.update(postId, {
|
|
109
|
+
* content: 'жирное слово',
|
|
110
|
+
* spans: [{ type: SpanType.Bold, offset: 0, length: 6 }],
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare const SpanType: Readonly<{
|
|
115
|
+
/** Хэштег. Название без решётки лежит в `tag`. */
|
|
116
|
+
readonly Hashtag: "hashtag";
|
|
117
|
+
/** Упоминание. Имя пользователя лежит в `tag`. */
|
|
118
|
+
readonly Mention: "mention";
|
|
119
|
+
/** Ссылка. Адрес лежит в `url`, а не в `tag`. */
|
|
120
|
+
readonly Link: "link";
|
|
121
|
+
readonly Bold: "bold";
|
|
122
|
+
readonly Italic: "italic";
|
|
123
|
+
readonly Underline: "underline";
|
|
124
|
+
/** Зачёркнутый. */
|
|
125
|
+
readonly Strike: "strike";
|
|
126
|
+
/** Спойлер: текст скрыт до нажатия. */
|
|
127
|
+
readonly Spoiler: "spoiler";
|
|
128
|
+
/** Моноширинный. */
|
|
129
|
+
readonly Monospace: "monospace";
|
|
130
|
+
readonly Quote: "quote";
|
|
131
|
+
}>;
|
|
132
|
+
type SpanType = Loose<(typeof SpanType)[keyof typeof SpanType]>;
|
|
100
133
|
/** На что подаётся жалоба. */
|
|
101
134
|
declare const ReportTargetType: Readonly<{
|
|
102
135
|
readonly Post: "post";
|
|
@@ -123,22 +156,46 @@ declare const RealtimeStatus: Readonly<{
|
|
|
123
156
|
}>;
|
|
124
157
|
type RealtimeStatus = (typeof RealtimeStatus)[keyof typeof RealtimeStatus];
|
|
125
158
|
/**
|
|
126
|
-
*
|
|
159
|
+
* Уровень доступа к разделу профиля.
|
|
127
160
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
161
|
+
* Общий набор значений для полей `wallAccess` и `likesVisibility` настроек приватности.
|
|
162
|
+
* Тип открытый: сервер может прислать значение вне этого перечня.
|
|
130
163
|
*/
|
|
164
|
+
declare const AccessType: Readonly<{
|
|
165
|
+
/** Никто. */
|
|
166
|
+
readonly Nobody: "nobody";
|
|
167
|
+
/** Только взаимные подписки. */
|
|
168
|
+
readonly Mutual: "mutual";
|
|
169
|
+
/** Подписчики. */
|
|
170
|
+
readonly Followers: "followers";
|
|
171
|
+
/** Все. */
|
|
172
|
+
readonly Everyone: "everyone";
|
|
173
|
+
}>;
|
|
174
|
+
type AccessType = Loose<(typeof AccessType)[keyof typeof AccessType]>;
|
|
175
|
+
/** Кто может писать на стену профиля. Псевдоним {@link AccessType}. */
|
|
131
176
|
declare const WallAccess: Readonly<{
|
|
177
|
+
/** Никто. */
|
|
178
|
+
readonly Nobody: "nobody";
|
|
179
|
+
/** Только взаимные подписки. */
|
|
180
|
+
readonly Mutual: "mutual";
|
|
181
|
+
/** Подписчики. */
|
|
182
|
+
readonly Followers: "followers";
|
|
183
|
+
/** Все. */
|
|
132
184
|
readonly Everyone: "everyone";
|
|
133
185
|
}>;
|
|
134
|
-
type WallAccess =
|
|
135
|
-
/** Кто видит реакции пользователя.
|
|
186
|
+
type WallAccess = AccessType;
|
|
187
|
+
/** Кто видит реакции пользователя. Псевдоним {@link AccessType}. */
|
|
136
188
|
declare const LikesVisibility: Readonly<{
|
|
137
|
-
|
|
189
|
+
/** Никто. */
|
|
190
|
+
readonly Nobody: "nobody";
|
|
138
191
|
/** Только взаимные подписки. */
|
|
139
192
|
readonly Mutual: "mutual";
|
|
193
|
+
/** Подписчики. */
|
|
194
|
+
readonly Followers: "followers";
|
|
195
|
+
/** Все. */
|
|
196
|
+
readonly Everyone: "everyone";
|
|
140
197
|
}>;
|
|
141
|
-
type LikesVisibility =
|
|
198
|
+
type LikesVisibility = AccessType;
|
|
142
199
|
/**
|
|
143
200
|
* Канонический тип уведомления (новое поколение имён).
|
|
144
201
|
*
|
|
@@ -175,6 +232,55 @@ declare const NotificationType: Readonly<{
|
|
|
175
232
|
readonly VerificationRejected: "verification_rejected";
|
|
176
233
|
}>;
|
|
177
234
|
type NotificationType = Loose<(typeof NotificationType)[keyof typeof NotificationType]>;
|
|
235
|
+
/**
|
|
236
|
+
* Тип взаимодействия с контентом в телеметрии (`POST /api/v1/x`, поле `t`).
|
|
237
|
+
*
|
|
238
|
+
* Кодируется числом.
|
|
239
|
+
*/
|
|
240
|
+
declare const InteractionType: Readonly<{
|
|
241
|
+
/** Открытие фотографии. */
|
|
242
|
+
readonly PhotoOpen: 1;
|
|
243
|
+
/** Прогресс просмотра видео. Несёт поля `pm`/`dm`. */
|
|
244
|
+
readonly VideoProgress: 2;
|
|
245
|
+
}>;
|
|
246
|
+
type InteractionType = (typeof InteractionType)[keyof typeof InteractionType];
|
|
247
|
+
/**
|
|
248
|
+
* Источник показа поста в телеметрии (поле `s`).
|
|
249
|
+
*
|
|
250
|
+
* Кодируется числом. Поле применимо к источникам `PostPage` и `Link`; для лент источник
|
|
251
|
+
* передаётся контекстом `sc`.
|
|
252
|
+
*/
|
|
253
|
+
declare const ViewSource: Readonly<{
|
|
254
|
+
readonly FeedGlobal: 1;
|
|
255
|
+
readonly FeedFollowing: 2;
|
|
256
|
+
readonly FeedClan: 3;
|
|
257
|
+
readonly Profile: 4;
|
|
258
|
+
readonly Hashtag: 5;
|
|
259
|
+
readonly PostPage: 6;
|
|
260
|
+
readonly Link: 7;
|
|
261
|
+
readonly Search: 8;
|
|
262
|
+
}>;
|
|
263
|
+
type ViewSource = (typeof ViewSource)[keyof typeof ViewSource];
|
|
264
|
+
/**
|
|
265
|
+
* Причина завершения просмотра поста в телеметрии (`POST /api/v1/i`, поле `r`).
|
|
266
|
+
*
|
|
267
|
+
* Кодируется числом.
|
|
268
|
+
*/
|
|
269
|
+
declare const ViewReason: Readonly<{
|
|
270
|
+
/** Пост ушёл из зоны видимости при обычной прокрутке. */
|
|
271
|
+
readonly Normal: 0;
|
|
272
|
+
/** Потеря фокуса окна. */
|
|
273
|
+
readonly Blur: 1;
|
|
274
|
+
/** Вкладка скрыта. */
|
|
275
|
+
readonly Hidden: 2;
|
|
276
|
+
/** Уход со страницы (`pagehide`). */
|
|
277
|
+
readonly PageHide: 3;
|
|
278
|
+
/** Элемент перестал наблюдаться. */
|
|
279
|
+
readonly Unobserve: 4;
|
|
280
|
+
/** Достигнут порог времени просмотра. */
|
|
281
|
+
readonly ThresholdMet: 5;
|
|
282
|
+
}>;
|
|
283
|
+
type ViewReason = (typeof ViewReason)[keyof typeof ViewReason];
|
|
178
284
|
/**
|
|
179
285
|
* Строковые коды ошибок из поля `code`.
|
|
180
286
|
*
|
|
@@ -264,14 +370,16 @@ type UserRef = string;
|
|
|
264
370
|
* поэтому при работе с эмодзи проверяйте результат.
|
|
265
371
|
*/
|
|
266
372
|
interface Span {
|
|
267
|
-
/** Тип
|
|
268
|
-
type:
|
|
373
|
+
/** Тип фрагмента — см. {@link SpanType}. */
|
|
374
|
+
type: SpanType;
|
|
269
375
|
/** Смещение от начала текста. */
|
|
270
376
|
offset: number;
|
|
271
377
|
/** Длина фрагмента. */
|
|
272
378
|
length: number;
|
|
273
|
-
/**
|
|
379
|
+
/** Имя хэштега без решётки либо имя пользователя. */
|
|
274
380
|
tag?: string;
|
|
381
|
+
/** Адрес ссылки. Только у `link`: у него вместо `tag` отдельное поле. */
|
|
382
|
+
url?: string;
|
|
275
383
|
}
|
|
276
384
|
/**
|
|
277
385
|
* Значок-«пин» в профиле — награда или отметка платформы.
|
|
@@ -1439,7 +1547,7 @@ declare const DEFAULT_TIMEOUT = 30000;
|
|
|
1439
1547
|
/**
|
|
1440
1548
|
* Версия библиотеки — попадает в `User-Agent`.
|
|
1441
1549
|
*/
|
|
1442
|
-
declare const LIBRARY_VERSION = "0.0.
|
|
1550
|
+
declare const LIBRARY_VERSION = "0.0.7";
|
|
1443
1551
|
/**
|
|
1444
1552
|
* `User-Agent` по умолчанию.
|
|
1445
1553
|
*
|
|
@@ -1450,7 +1558,7 @@ declare const LIBRARY_VERSION = "0.0.5";
|
|
|
1450
1558
|
* В браузере заголовок не выставляется — `User-Agent` там запрещён к изменению, и среда
|
|
1451
1559
|
* молча его игнорирует.
|
|
1452
1560
|
*/
|
|
1453
|
-
declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; itd-api/0.0.
|
|
1561
|
+
declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; itd-api/0.0.7; +https://github.com/KiowDev/itd-api)";
|
|
1454
1562
|
/**
|
|
1455
1563
|
* Настройки повторов со всеми значениями по умолчанию.
|
|
1456
1564
|
*
|
|
@@ -1610,6 +1718,108 @@ declare class Emitter<Events> {
|
|
|
1610
1718
|
removeAllListeners(): void;
|
|
1611
1719
|
}
|
|
1612
1720
|
|
|
1721
|
+
/**
|
|
1722
|
+
* Обёртка вокруг запроса.
|
|
1723
|
+
*
|
|
1724
|
+
* Получает описание запроса и продолжение цепочки. Может изменить запрос перед отправкой,
|
|
1725
|
+
* посмотреть и подменить разобранный ответ или вовсе не вызывать `next` и вернуть своё.
|
|
1726
|
+
*
|
|
1727
|
+
* @param request что уходит на сервер; изменять сам объект не нужно — передайте копию в `next`
|
|
1728
|
+
* @param next продолжение: либо следующая обёртка, либо настоящий запрос
|
|
1729
|
+
* @returns тело ответа в том виде, в каком его получит вызывающий код
|
|
1730
|
+
*
|
|
1731
|
+
* @example Дописать заголовок ко всем запросам
|
|
1732
|
+
* ```ts
|
|
1733
|
+
* const transformer: Transformer = (request, next) =>
|
|
1734
|
+
* next({ ...request, headers: { ...request.headers, 'X-Trace': trace() } });
|
|
1735
|
+
* ```
|
|
1736
|
+
*/
|
|
1737
|
+
type Transformer = (request: RawRequestOptions, next: (request: RawRequestOptions) => Promise<unknown>) => Promise<unknown>;
|
|
1738
|
+
/** Что плагин получает при подключении. */
|
|
1739
|
+
interface PluginContext {
|
|
1740
|
+
/** Базовый URL клиента — например чтобы разобрать абсолютные ссылки из ответа. */
|
|
1741
|
+
baseUrl: string;
|
|
1742
|
+
/** Отладочный вывод клиента, если он включён. */
|
|
1743
|
+
logger: Logger | undefined;
|
|
1744
|
+
/** Добавляет обёртку запроса. Подключённые раньше оказываются снаружи. */
|
|
1745
|
+
use(transformer: Transformer): void;
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Плагин клиента.
|
|
1749
|
+
*
|
|
1750
|
+
* Подключается через `itd.use(plugin)` и работает на уровне транспорта: видит запрос
|
|
1751
|
+
* до отправки и разобранный ответ. Библиотека не знает, что именно делает плагин, —
|
|
1752
|
+
* ей достаточно списка обёрток и имён опций, которые он читает.
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
* ```ts
|
|
1756
|
+
* const logging: ItdPlugin = {
|
|
1757
|
+
* name: 'logging',
|
|
1758
|
+
* install({ use, logger }) {
|
|
1759
|
+
* use(async (request, next) => {
|
|
1760
|
+
* logger?.info(`${request.method} ${request.path}`);
|
|
1761
|
+
* return next(request);
|
|
1762
|
+
* });
|
|
1763
|
+
* },
|
|
1764
|
+
* };
|
|
1765
|
+
*
|
|
1766
|
+
* itd.use(logging);
|
|
1767
|
+
* ```
|
|
1768
|
+
*/
|
|
1769
|
+
interface ItdPlugin {
|
|
1770
|
+
/** Имя плагина. Должно быть уникальным: повторное подключение — ошибка. */
|
|
1771
|
+
name: string;
|
|
1772
|
+
/**
|
|
1773
|
+
* Имена опций запроса, которые плагин читает у методов ресурсов.
|
|
1774
|
+
*
|
|
1775
|
+
* Библиотека этих опций не понимает и ничего с ними не делает — только доносит
|
|
1776
|
+
* от вызова метода до обёртки нетронутыми. Без такого списка чужие поля отсеиваются,
|
|
1777
|
+
* чтобы случайная опечатка в параметрах не уезжала на сервер.
|
|
1778
|
+
*
|
|
1779
|
+
* Имена полей самого запроса (`path`, `body`, `headers`, `signal` и прочие из
|
|
1780
|
+
* `RawRequestOptions`) заявить нельзя: подключение такого плагина завершится ошибкой.
|
|
1781
|
+
*
|
|
1782
|
+
* Типы для них плагин объявляет сам, дополняя `RequestOptions`:
|
|
1783
|
+
* ```ts
|
|
1784
|
+
* declare module 'itd-api' {
|
|
1785
|
+
* interface RequestOptions { encrypt?: string | undefined }
|
|
1786
|
+
* }
|
|
1787
|
+
* ```
|
|
1788
|
+
*/
|
|
1789
|
+
optionKeys?: readonly string[];
|
|
1790
|
+
/** Вызывается один раз при подключении. */
|
|
1791
|
+
install(context: PluginContext): void;
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Список подключённых плагинов и собранная из них цепочка обёрток.
|
|
1795
|
+
*
|
|
1796
|
+
* Живёт в клиенте, а работает в транспорте: {@link HttpClient} прогоняет через `run`
|
|
1797
|
+
* каждый запрос, если плагины есть.
|
|
1798
|
+
*/
|
|
1799
|
+
declare class PluginRegistry {
|
|
1800
|
+
#private;
|
|
1801
|
+
/** Сколько обёрток подключено. Ноль означает, что запрос идёт прежним путём. */
|
|
1802
|
+
get size(): number;
|
|
1803
|
+
/** Имена опций запроса, заявленные плагинами. */
|
|
1804
|
+
get optionKeys(): ReadonlySet<string>;
|
|
1805
|
+
/**
|
|
1806
|
+
* Подключает плагин.
|
|
1807
|
+
*
|
|
1808
|
+
* @throws {ItdConfigError} если плагин задан неверно, уже подключён или заявил занятое
|
|
1809
|
+
* имя опции
|
|
1810
|
+
*/
|
|
1811
|
+
add(plugin: ItdPlugin, context: Omit<PluginContext, 'use'>): void;
|
|
1812
|
+
/**
|
|
1813
|
+
* Прогоняет запрос через цепочку обёрток.
|
|
1814
|
+
*
|
|
1815
|
+
* Цепочка собирается на каждый запрос заново: плагин можно подключить в любой момент,
|
|
1816
|
+
* а обёрток единицы — экономить тут не на чем.
|
|
1817
|
+
*
|
|
1818
|
+
* @param execute настоящий запрос, вызывается самой внутренней обёрткой
|
|
1819
|
+
*/
|
|
1820
|
+
run(request: RawRequestOptions, execute: (request: RawRequestOptions) => Promise<unknown>): Promise<unknown>;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1613
1823
|
/**
|
|
1614
1824
|
* Подключаемые части конвейера.
|
|
1615
1825
|
*
|
|
@@ -1666,6 +1876,15 @@ declare class HttpClient {
|
|
|
1666
1876
|
constructor(config: ResolvedConfig, collaborators?: HttpCollaborators);
|
|
1667
1877
|
/** Базовый URL, к которому обращается клиент. */
|
|
1668
1878
|
get baseUrl(): string;
|
|
1879
|
+
/**
|
|
1880
|
+
* Имена опций запроса, заявленные плагинами.
|
|
1881
|
+
*
|
|
1882
|
+
* Читается ресурсами: они переносят в транспорт только известные поля, а чужие,
|
|
1883
|
+
* если их никто не заявил, отсеивают.
|
|
1884
|
+
*/
|
|
1885
|
+
get pluginOptionKeys(): ReadonlySet<string>;
|
|
1886
|
+
/** Подключает список плагинов. Реестр общий с клиентом и пополняется через `itd.use()`. */
|
|
1887
|
+
usePlugins(plugins: PluginRegistry): void;
|
|
1669
1888
|
/**
|
|
1670
1889
|
* Подключает недостающие части конвейера.
|
|
1671
1890
|
*
|
|
@@ -2196,7 +2415,14 @@ declare class BaseResource {
|
|
|
2196
2415
|
/** @internal */
|
|
2197
2416
|
protected readonly http: HttpClient;
|
|
2198
2417
|
constructor(http: HttpClient);
|
|
2199
|
-
/**
|
|
2418
|
+
/**
|
|
2419
|
+
* Переносит общие поля опций запроса в параметры транспорта.
|
|
2420
|
+
*
|
|
2421
|
+
* Поля перечислены поимённо, а не скопированы целиком: параметры методов наследуют
|
|
2422
|
+
* {@link RequestOptions} и приносят с собой `limit`, `cursor` и прочее, чему в описании
|
|
2423
|
+
* запроса делать нечего. Исключение — опции, заявленные плагинами: их библиотека
|
|
2424
|
+
* не понимает, но обязана донести до обёрток нетронутыми.
|
|
2425
|
+
*/
|
|
2200
2426
|
protected requestOptions(options: RequestOptions | undefined): Partial<RequestOptions>;
|
|
2201
2427
|
/**
|
|
2202
2428
|
* Собирает перебор страниц.
|
|
@@ -2680,54 +2906,6 @@ declare class PlatformResource extends BaseResource {
|
|
|
2680
2906
|
/** Загружает баннер текущего события — виджет «портал». */
|
|
2681
2907
|
portal(options?: RequestOptions): Promise<Portal>;
|
|
2682
2908
|
}
|
|
2683
|
-
/** Запись о времени просмотра поста. */
|
|
2684
|
-
interface DwellEntry {
|
|
2685
|
-
/** Идентификатор поста. */
|
|
2686
|
-
postId: string;
|
|
2687
|
-
/** Сколько миллисекунд пост был виден. */
|
|
2688
|
-
duration: number;
|
|
2689
|
-
/** Служебная метка показа из поля `vs` объекта поста. */
|
|
2690
|
-
vs?: string;
|
|
2691
|
-
}
|
|
2692
|
-
/** Запись о взаимодействии с контентом. */
|
|
2693
|
-
interface InteractionEntry {
|
|
2694
|
-
/** Тип взаимодействия: `photo_open`, `video_progress` и подобные. */
|
|
2695
|
-
type: string;
|
|
2696
|
-
/** Значение, смысл которого зависит от типа: доля просмотра, номер кадра. */
|
|
2697
|
-
value?: number;
|
|
2698
|
-
/** Идентификатор поста. */
|
|
2699
|
-
postId?: string;
|
|
2700
|
-
/** Идентификатор вложения. */
|
|
2701
|
-
attachmentId?: string;
|
|
2702
|
-
/** Служебная метка показа. */
|
|
2703
|
-
vs?: string;
|
|
2704
|
-
}
|
|
2705
|
-
/**
|
|
2706
|
-
* Телеметрия просмотров.
|
|
2707
|
-
*
|
|
2708
|
-
* @experimental Эндпоинты `/api/v1/i` и `/api/v1/x` нигде не описаны, а схема их полей
|
|
2709
|
-
* не проверена на реальных запросах и может измениться без предупреждения.
|
|
2710
|
-
*
|
|
2711
|
-
* **Библиотека никогда не отправляет телеметрию сама.** Эти методы нужны только тем,
|
|
2712
|
-
* кто пишет собственный клиент платформы; всем остальным их вызывать не требуется.
|
|
2713
|
-
*
|
|
2714
|
-
* Доступна как `itd.telemetry`.
|
|
2715
|
-
*/
|
|
2716
|
-
declare class TelemetryResource extends BaseResource {
|
|
2717
|
-
/**
|
|
2718
|
-
* Отправляет время просмотра постов.
|
|
2719
|
-
*
|
|
2720
|
-
* @experimental Имена полей на проводе сжаты (`ai`, `v`, `s`), и их соответствие
|
|
2721
|
-
* смыслу **не проверено** на реальных запросах. Может измениться без предупреждения.
|
|
2722
|
-
*/
|
|
2723
|
-
dwell(entries: DwellEntry[], options?: RequestOptions): Promise<unknown>;
|
|
2724
|
-
/**
|
|
2725
|
-
* Отправляет события взаимодействия с контентом.
|
|
2726
|
-
*
|
|
2727
|
-
* @experimental См. предупреждение у {@link TelemetryResource}.
|
|
2728
|
-
*/
|
|
2729
|
-
interaction(entries: InteractionEntry[], options?: RequestOptions): Promise<unknown>;
|
|
2730
|
-
}
|
|
2731
2909
|
|
|
2732
2910
|
/** Параметры запроса списка уведомлений. */
|
|
2733
2911
|
interface NotificationListParams extends RequestOptions {
|
|
@@ -2968,6 +3146,96 @@ declare class PostsResource extends BaseResource {
|
|
|
2968
3146
|
voiceComment(postId: string, audio: FileInput, options?: RequestOptions): Promise<Comment>;
|
|
2969
3147
|
}
|
|
2970
3148
|
|
|
3149
|
+
/**
|
|
3150
|
+
* Общие опции запроса телеметрии.
|
|
3151
|
+
*
|
|
3152
|
+
* Помимо {@link RequestOptions} позволяет задать `sid` — идентификатор сессии телеметрии.
|
|
3153
|
+
* По умолчанию он заводится один на объект {@link TelemetryResource}.
|
|
3154
|
+
*/
|
|
3155
|
+
interface TelemetryOptions extends RequestOptions {
|
|
3156
|
+
/** Переопределяет идентификатор сессии телеметрии (`sid`) для этого запроса. */
|
|
3157
|
+
sid?: string;
|
|
3158
|
+
}
|
|
3159
|
+
/**
|
|
3160
|
+
* Событие просмотра поста для {@link TelemetryResource.dwell}.
|
|
3161
|
+
*
|
|
3162
|
+
* Пост определяется меткой показа `vs` и, при наличии, контекстом источника `sc`; поля
|
|
3163
|
+
* `postId` эндпоинт `/api/v1/i` не принимает.
|
|
3164
|
+
*/
|
|
3165
|
+
interface DwellEntry {
|
|
3166
|
+
/** Метка показа — поле `vs` объекта поста. Уходит в поле `v`. */
|
|
3167
|
+
vs: string;
|
|
3168
|
+
/** Время появления поста в зоне видимости, epoch-мс. Поле `et`. */
|
|
3169
|
+
enterAt: number;
|
|
3170
|
+
/** Время ухода из зоны видимости, epoch-мс. Поле `xt`. */
|
|
3171
|
+
exitAt: number;
|
|
3172
|
+
/** Причина завершения просмотра. Поле `r`. */
|
|
3173
|
+
reason: ViewReason;
|
|
3174
|
+
/**
|
|
3175
|
+
* Длительность просмотра в мс. Поле `md`.
|
|
3176
|
+
*
|
|
3177
|
+
* Если не задано, вычисляется как `exitAt − enterAt`.
|
|
3178
|
+
*/
|
|
3179
|
+
durationMs?: number;
|
|
3180
|
+
/** Контекст источника показа. Поле `sc`. */
|
|
3181
|
+
sourceContext?: string;
|
|
3182
|
+
/** Источник показа. Применим к `PostPage`/`Link`. Поле `s`. */
|
|
3183
|
+
source?: ViewSource;
|
|
3184
|
+
/** Повторный просмотр: пост уже встречался в этой сессии. Уходит как `b: 1`. */
|
|
3185
|
+
repeat?: boolean;
|
|
3186
|
+
}
|
|
3187
|
+
/** Событие взаимодействия с контентом для {@link TelemetryResource.interaction}. */
|
|
3188
|
+
interface InteractionEntry {
|
|
3189
|
+
/** Тип взаимодействия. Поле `t`. */
|
|
3190
|
+
type: InteractionType;
|
|
3191
|
+
/** Метка показа — поле `vs` объекта поста. Поле `v`. */
|
|
3192
|
+
vs: string;
|
|
3193
|
+
/** Идентификатор поста. Поле `ai`. */
|
|
3194
|
+
postId: string;
|
|
3195
|
+
/** Индекс вложения (с нуля) — для {@link InteractionType.PhotoOpen}. Поле `mi`. */
|
|
3196
|
+
mediaIndex?: number;
|
|
3197
|
+
/** Источник показа. Поле `s`. */
|
|
3198
|
+
source?: ViewSource;
|
|
3199
|
+
/** Просмотрено мс — для {@link InteractionType.VideoProgress}. Поле `pm`. */
|
|
3200
|
+
positionMs?: number;
|
|
3201
|
+
/** Длительность видео в мс — для {@link InteractionType.VideoProgress}. Поле `dm`. */
|
|
3202
|
+
durationMs?: number;
|
|
3203
|
+
}
|
|
3204
|
+
/**
|
|
3205
|
+
* Телеметрия просмотров.
|
|
3206
|
+
*
|
|
3207
|
+
* @experimental Недокументированные эндпоинты `/api/v1/i` (просмотры) и `/api/v1/x`
|
|
3208
|
+
* (взаимодействия); формат полей может измениться без предупреждения.
|
|
3209
|
+
*
|
|
3210
|
+
* Методы не вызываются автоматически — телеметрия отправляется только явным вызовом.
|
|
3211
|
+
*
|
|
3212
|
+
* Оба эндпоинта принимают конверт `{ sid, e }`, где `sid` — идентификатор сессии
|
|
3213
|
+
* телеметрии: по умолчанию один на объект, переопределяется опцией `sid`.
|
|
3214
|
+
*
|
|
3215
|
+
* Доступна как `itd.telemetry`.
|
|
3216
|
+
*/
|
|
3217
|
+
declare class TelemetryResource extends BaseResource {
|
|
3218
|
+
#private;
|
|
3219
|
+
/**
|
|
3220
|
+
* Идентификатор сессии телеметрии (`sid`).
|
|
3221
|
+
*
|
|
3222
|
+
* Создаётся лениво при первом обращении и далее неизменен.
|
|
3223
|
+
*/
|
|
3224
|
+
get sessionId(): string;
|
|
3225
|
+
/**
|
|
3226
|
+
* Отправляет события просмотра постов (`POST /api/v1/i`).
|
|
3227
|
+
*
|
|
3228
|
+
* @experimental См. предупреждение у {@link TelemetryResource}.
|
|
3229
|
+
*/
|
|
3230
|
+
dwell(entries: DwellEntry[], options?: TelemetryOptions): Promise<unknown>;
|
|
3231
|
+
/**
|
|
3232
|
+
* Отправляет события взаимодействия с контентом (`POST /api/v1/x`).
|
|
3233
|
+
*
|
|
3234
|
+
* @experimental См. предупреждение у {@link TelemetryResource}.
|
|
3235
|
+
*/
|
|
3236
|
+
interaction(entries: InteractionEntry[], options?: TelemetryOptions): Promise<unknown>;
|
|
3237
|
+
}
|
|
3238
|
+
|
|
2971
3239
|
/**
|
|
2972
3240
|
* Параметры списков пользователей.
|
|
2973
3241
|
*
|
|
@@ -3181,6 +3449,24 @@ declare class ItdClient {
|
|
|
3181
3449
|
* ```
|
|
3182
3450
|
*/
|
|
3183
3451
|
request<T = unknown>(options: RawRequestOptions): Promise<T>;
|
|
3452
|
+
/**
|
|
3453
|
+
* Подключает плагин.
|
|
3454
|
+
*
|
|
3455
|
+
* Плагин работает на уровне транспорта: видит запрос до отправки и разобранный ответ,
|
|
3456
|
+
* поэтому одна обёртка охватывает сразу все методы клиента. Подключать можно в любой
|
|
3457
|
+
* момент, но обычно это делают сразу после создания клиента.
|
|
3458
|
+
*
|
|
3459
|
+
* @throws {ItdConfigError} если плагин задан неверно или уже подключён
|
|
3460
|
+
*
|
|
3461
|
+
* @example
|
|
3462
|
+
* ```ts
|
|
3463
|
+
* import { crypt } from 'itd-api-crypto';
|
|
3464
|
+
*
|
|
3465
|
+
* itd.use(crypt());
|
|
3466
|
+
* await itd.posts.create({ content: 'секрет' }, { encrypt: 'invis' });
|
|
3467
|
+
* ```
|
|
3468
|
+
*/
|
|
3469
|
+
use(plugin: ItdPlugin): this;
|
|
3184
3470
|
/**
|
|
3185
3471
|
* Подписывается на события авторизации.
|
|
3186
3472
|
*
|
|
@@ -3611,4 +3897,4 @@ interface SseTransportOptions {
|
|
|
3611
3897
|
idleTimeout?: number;
|
|
3612
3898
|
}
|
|
3613
3899
|
|
|
3614
|
-
export {
|
|
3900
|
+
export { HashtagsResource as $, ALLOWED_MIME_TYPES as A, type BuilderInput as B, type CaptchaCredentials as C, type CreateCommentInput as D, type CreatePollInput as E, type FileReader as F, type CreatePostInput as G, type CreateReportInput as H, type ItdSession as I, type Credentials as J, type CredentialsAuth as K, DEFAULT_BASE_URL as L, DEFAULT_TIMEOUT as M, DEFAULT_USER_AGENT as N, DEVICE_ID_HEADER as O, DetectedRuntime as P, type DwellEntry as Q, type ErrorContextHook as R, type FeedParams as S, type TokenStorage as T, FeedTab as U, type FileInput as V, FilesResource as W, type FollowResult as X, type ForgotPasswordInput as Y, type Hashtag as Z, type HashtagPostsParams as _, ItdClient as a, type PostInput as a$, IMAGE_MIME_TYPES as a0, type ImageMimeType as a1, type InteractionEntry as a2, InteractionType as a3, type IsoDate as a4, ItdAbortError as a5, ItdApiError as a6, type ItdApiErrorInit as a7, ItdApiErrorKind as a8, ItdAuthError as a9, type MyProfile as aA, NOTIFICATION_TYPE_ALIASES as aB, type Notification as aC, type NotificationEvent as aD, type NotificationListParams as aE, type NotificationSettings as aF, NotificationType as aG, NotificationsResource as aH, OAuthProvider as aI, type Page as aJ, type PageState as aK, PaginationMode as aL, Paginator as aM, type PaymentMethod as aN, type Pin as aO, type PinPostResult as aP, type PinsResult as aQ, PlatformResource as aR, type PluginContext as aS, type Poll as aT, PollBuilder as aU, type PollInput as aV, type PollOption as aW, type PollTransportOptions as aX, type Portal as aY, type Post as aZ, PostBuilder as a_, type ItdBuilder as aa, ItdConfigError as ab, ItdConflictError as ac, ItdError as ad, ItdErrorCode as ae, ItdErrorKind as af, type ItdFieldErrors as ag, ItdForbiddenError as ah, ItdNetworkError as ai, ItdNotFoundError as aj, ItdPhoneVerificationError as ak, type ItdPlugin as al, ItdRateLimitError as am, ItdRealtime as an, ItdServerError as ao, ItdTimeoutError as ap, ItdValidationError as aq, LIBRARY_VERSION as ar, type LikeResult as as, LikesVisibility as at, type Listener as au, LocalStorageTokenStorage as av, type Logger as aw, type Loose as ax, MAX_RECONNECT_ATTEMPTS as ay, MemoryTokenStorage as az, type ItdClientOptions as b, VerificationResource as b$, type PostStats as b0, PostsResource as b1, type PrivacySettings as b2, type Profile as b3, type PublicProfile as b4, RECONNECT_BACKOFF as b5, RECONNECT_JITTER as b6, REFRESH_COOKIE as b7, REFRESH_COOKIE_PATH as b8, type RateLimitOptions as b9, SignInStatus as bA, type Span as bB, SpanType as bC, type SseTransportOptions as bD, type Subscription as bE, SubscriptionResource as bF, type SubscriptionState as bG, TURNSTILE_SITE_KEY as bH, type TelemetryOptions as bI, TelemetryResource as bJ, type Transformer as bK, type TransportContext as bL, type TransportEvent as bM, UnauthorizedStreamError as bN, type Unsubscribe as bO, type UpdateNotificationSettingsInput as bP, type UpdatePrivacyInput as bQ, type UpdateProfileInput as bR, type UploadOptions as bS, type UploadedFile as bT, type UserId as bU, type UserListParams as bV, type UserPostsParams as bW, type UserRef as bX, type UserSummary as bY, UsersResource as bZ, VIDEO_MIME_TYPES as b_, type RawRequestOptions as ba, type RealtimeEvents as bb, type RealtimeOptions as bc, RealtimeStatus as bd, type RealtimeTransport as be, RealtimeTransportKind as bf, type ReconnectOptions as bg, type RepliesParams as bh, type Report as bi, ReportBuilder as bj, type ReportInput as bk, ReportReason as bl, ReportTargetType as bm, ReportsResource as bn, type RequestContext as bo, type RequestOptions as bp, type ResetPasswordInput as bq, type ResponseContext as br, type RetryContext as bs, type RetryOptions as bt, RuntimeMode as bu, STREAM_PATH as bv, SearchResource as bw, type SearchResult as bx, type Session as by, type SignInResult as bz, AUDIO_MIME_TYPES as c, type VerificationStatus as c0, type VideoMimeType as c1, ViewReason as c2, ViewSource as c3, WallAccess as c4, canonicalNotificationType as c5, comment as c6, createTokenStorage as c7, formatNotificationText as c8, isBuilder as c9, isItdApiError as ca, isItdAuthError as cb, isItdConflictError as cc, isItdError as cd, isItdForbiddenError as ce, isItdNotFoundError as cf, isItdPhoneVerificationError as cg, isItdRateLimitError as ch, isItdServerError as ci, isItdValidationError as cj, isKnownNotificationType as ck, isMyProfile as cl, normalizeNotification as cm, poll as cn, post as co, readNotificationEvent as cp, readUnreadCountEvent as cq, report as cr, resolveNotificationUrl as cs, toDate as ct, createClient as cu, AUTH_FLAG_COOKIE as d, AUTH_PATHS as e, AccessType as f, type Actor as g, type AllowedMimeType as h, type Announcement as i, type AnnouncementButton as j, type Attachment as k, AttachmentType as l, type AudioMimeType as m, type AuthInput as n, AuthResource as o, type Author as p, type ChangelogEntry as q, type Clan as r, type ClientHooks as s, type Comment as t, CommentBuilder as u, type CommentInput as v, type CommentReplyTo as w, CommentSort as x, type CommentsParams as y, CommentsResource as z };
|