itd-api 0.0.6 → 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.
@@ -616,14 +616,18 @@ var RealtimeStatus = Object.freeze({
616
616
  Error: "error",
617
617
  Disconnected: "disconnected"
618
618
  });
619
- var WallAccess = Object.freeze({
620
- Everyone: "everyone"
621
- });
622
- var LikesVisibility = Object.freeze({
623
- Everyone: "everyone",
619
+ var AccessType = Object.freeze({
620
+ /** Никто. */
621
+ Nobody: "nobody",
624
622
  /** Только взаимные подписки. */
625
- Mutual: "mutual"
623
+ Mutual: "mutual",
624
+ /** Подписчики. */
625
+ Followers: "followers",
626
+ /** Все. */
627
+ Everyone: "everyone"
626
628
  });
629
+ var WallAccess = AccessType;
630
+ var LikesVisibility = AccessType;
627
631
  var NotificationType = Object.freeze({
628
632
  /** Реакция на пост. Старое имя — `like`. */
629
633
  PostReaction: "post_reaction",
@@ -652,6 +656,36 @@ var NotificationType = Object.freeze({
652
656
  /** Верификация отклонена. Приходит только по REST. */
653
657
  VerificationRejected: "verification_rejected"
654
658
  });
659
+ var InteractionType = Object.freeze({
660
+ /** Открытие фотографии. */
661
+ PhotoOpen: 1,
662
+ /** Прогресс просмотра видео. Несёт поля `pm`/`dm`. */
663
+ VideoProgress: 2
664
+ });
665
+ var ViewSource = Object.freeze({
666
+ FeedGlobal: 1,
667
+ FeedFollowing: 2,
668
+ FeedClan: 3,
669
+ Profile: 4,
670
+ Hashtag: 5,
671
+ PostPage: 6,
672
+ Link: 7,
673
+ Search: 8
674
+ });
675
+ var ViewReason = Object.freeze({
676
+ /** Пост ушёл из зоны видимости при обычной прокрутке. */
677
+ Normal: 0,
678
+ /** Потеря фокуса окна. */
679
+ Blur: 1,
680
+ /** Вкладка скрыта. */
681
+ Hidden: 2,
682
+ /** Уход со страницы (`pagehide`). */
683
+ PageHide: 3,
684
+ /** Элемент перестал наблюдаться. */
685
+ Unobserve: 4,
686
+ /** Достигнут порог времени просмотра. */
687
+ ThresholdMet: 5
688
+ });
655
689
  var ItdErrorCode = Object.freeze({
656
690
  BAD_REQUEST: "BAD_REQUEST",
657
691
  UNAUTHORIZED: "UNAUTHORIZED",
@@ -1716,7 +1750,7 @@ function normalizeBaseUrl(baseUrl) {
1716
1750
  // src/core/config.ts
1717
1751
  var DEFAULT_BASE_URL = "https://xn--d1ah4a.com";
1718
1752
  var DEFAULT_TIMEOUT = 3e4;
1719
- var LIBRARY_VERSION = "0.0.6";
1753
+ var LIBRARY_VERSION = "0.0.7";
1720
1754
  var DEFAULT_USER_AGENT = `Mozilla/5.0 (compatible; itd-api/${LIBRARY_VERSION}; +https://github.com/KiowDev/itd-api)`;
1721
1755
  var DEFAULT_RATE_LIMIT_DELAYS = Object.freeze([1e3, 5e3, 3e4, 6e4, 9e4]);
1722
1756
  function requirePositive(value, name) {
@@ -4243,49 +4277,6 @@ var PlatformResource = class extends BaseResource {
4243
4277
  });
4244
4278
  }
4245
4279
  };
4246
- var TelemetryResource = class extends BaseResource {
4247
- /**
4248
- * Отправляет время просмотра постов.
4249
- *
4250
- * @experimental Имена полей на проводе сжаты (`ai`, `v`, `s`), и их соответствие
4251
- * смыслу **не проверено** на реальных запросах. Может измениться без предупреждения.
4252
- */
4253
- dwell(entries, options = {}) {
4254
- return this.http.request({
4255
- method: "POST",
4256
- path: "/api/v1/i",
4257
- body: {
4258
- items: entries.map((entry) => ({
4259
- ai: entry.postId,
4260
- v: entry.duration,
4261
- ...entry.vs ? { s: entry.vs } : {}
4262
- }))
4263
- },
4264
- ...this.requestOptions(options)
4265
- });
4266
- }
4267
- /**
4268
- * Отправляет события взаимодействия с контентом.
4269
- *
4270
- * @experimental См. предупреждение у {@link TelemetryResource}.
4271
- */
4272
- interaction(entries, options = {}) {
4273
- return this.http.request({
4274
- method: "POST",
4275
- path: "/api/v1/x",
4276
- body: {
4277
- items: entries.map((entry) => ({
4278
- t: entry.type,
4279
- ...entry.value !== void 0 ? { v: entry.value } : {},
4280
- ...entry.postId ? { ai: entry.postId } : {},
4281
- ...entry.attachmentId ? { mi: entry.attachmentId } : {},
4282
- ...entry.vs ? { s: entry.vs } : {}
4283
- }))
4284
- },
4285
- ...this.requestOptions(options)
4286
- });
4287
- }
4288
- };
4289
4280
 
4290
4281
  // src/resources/notifications.ts
4291
4282
  var READ_BATCH_SIZE = 20;
@@ -4775,6 +4766,70 @@ var PostsResource = class extends BaseResource {
4775
4766
  }
4776
4767
  };
4777
4768
 
4769
+ // src/resources/telemetry.ts
4770
+ var TelemetryResource = class extends BaseResource {
4771
+ /** Идентификатор сессии телеметрии, общий для всех событий этого объекта. */
4772
+ #sessionId;
4773
+ /**
4774
+ * Идентификатор сессии телеметрии (`sid`).
4775
+ *
4776
+ * Создаётся лениво при первом обращении и далее неизменен.
4777
+ */
4778
+ get sessionId() {
4779
+ this.#sessionId ??= createDeviceId();
4780
+ return this.#sessionId;
4781
+ }
4782
+ /**
4783
+ * Отправляет события просмотра постов (`POST /api/v1/i`).
4784
+ *
4785
+ * @experimental См. предупреждение у {@link TelemetryResource}.
4786
+ */
4787
+ dwell(entries, options = {}) {
4788
+ return this.http.request({
4789
+ method: "POST",
4790
+ path: "/api/v1/i",
4791
+ body: {
4792
+ sid: options.sid ?? this.sessionId,
4793
+ e: entries.map((entry) => ({
4794
+ md: entry.durationMs ?? entry.exitAt - entry.enterAt,
4795
+ et: entry.enterAt,
4796
+ xt: entry.exitAt,
4797
+ r: entry.reason,
4798
+ v: entry.vs,
4799
+ ...entry.sourceContext !== void 0 ? { sc: entry.sourceContext } : {},
4800
+ ...entry.source !== void 0 ? { s: entry.source } : {},
4801
+ ...entry.repeat ? { b: 1 } : {}
4802
+ }))
4803
+ },
4804
+ ...this.requestOptions(options)
4805
+ });
4806
+ }
4807
+ /**
4808
+ * Отправляет события взаимодействия с контентом (`POST /api/v1/x`).
4809
+ *
4810
+ * @experimental См. предупреждение у {@link TelemetryResource}.
4811
+ */
4812
+ interaction(entries, options = {}) {
4813
+ return this.http.request({
4814
+ method: "POST",
4815
+ path: "/api/v1/x",
4816
+ body: {
4817
+ sid: options.sid ?? this.sessionId,
4818
+ e: entries.map((entry) => ({
4819
+ t: entry.type,
4820
+ v: entry.vs,
4821
+ ai: entry.postId,
4822
+ ...entry.mediaIndex !== void 0 ? { mi: entry.mediaIndex } : {},
4823
+ ...entry.source !== void 0 ? { s: entry.source } : {},
4824
+ ...entry.positionMs !== void 0 ? { pm: Math.round(entry.positionMs) } : {},
4825
+ ...entry.durationMs !== void 0 ? { dm: Math.round(entry.durationMs) } : {}
4826
+ }))
4827
+ },
4828
+ ...this.requestOptions(options)
4829
+ });
4830
+ }
4831
+ };
4832
+
4778
4833
  // src/resources/users.ts
4779
4834
  var UsersResource = class extends BaseResource {
4780
4835
  /** Загружает свой профиль — с подпиской и признаком подтверждённого телефона. */
@@ -5397,6 +5452,7 @@ exports.ALLOWED_MIME_TYPES = ALLOWED_MIME_TYPES;
5397
5452
  exports.AUDIO_MIME_TYPES = AUDIO_MIME_TYPES;
5398
5453
  exports.AUTH_FLAG_COOKIE = AUTH_FLAG_COOKIE;
5399
5454
  exports.AUTH_PATHS = AUTH_PATHS;
5455
+ exports.AccessType = AccessType;
5400
5456
  exports.AttachmentType = AttachmentType;
5401
5457
  exports.CommentSort = CommentSort;
5402
5458
  exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
@@ -5406,6 +5462,7 @@ exports.DEVICE_ID_HEADER = DEVICE_ID_HEADER;
5406
5462
  exports.DetectedRuntime = DetectedRuntime;
5407
5463
  exports.FeedTab = FeedTab;
5408
5464
  exports.IMAGE_MIME_TYPES = IMAGE_MIME_TYPES;
5465
+ exports.InteractionType = InteractionType;
5409
5466
  exports.ItdAbortError = ItdAbortError;
5410
5467
  exports.ItdApiError = ItdApiError;
5411
5468
  exports.ItdApiErrorKind = ItdApiErrorKind;
@@ -5450,6 +5507,8 @@ exports.SpanType = SpanType;
5450
5507
  exports.TURNSTILE_SITE_KEY = TURNSTILE_SITE_KEY;
5451
5508
  exports.UnauthorizedStreamError = UnauthorizedStreamError;
5452
5509
  exports.VIDEO_MIME_TYPES = VIDEO_MIME_TYPES;
5510
+ exports.ViewReason = ViewReason;
5511
+ exports.ViewSource = ViewSource;
5453
5512
  exports.WallAccess = WallAccess;
5454
5513
  exports.canonicalNotificationType = canonicalNotificationType;
5455
5514
  exports.comment = comment;
@@ -5477,5 +5536,5 @@ exports.readUnreadCountEvent = readUnreadCountEvent;
5477
5536
  exports.report = report;
5478
5537
  exports.resolveNotificationUrl = resolveNotificationUrl;
5479
5538
  exports.toDate = toDate;
5480
- //# sourceMappingURL=chunk-K7NBFQEE.cjs.map
5481
- //# sourceMappingURL=chunk-K7NBFQEE.cjs.map
5539
+ //# sourceMappingURL=chunk-3RNNZJZ4.cjs.map
5540
+ //# sourceMappingURL=chunk-3RNNZJZ4.cjs.map