@book000/pixivts 0.64.0-beta.8 → 0.64.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.
package/README.md CHANGED
@@ -72,11 +72,11 @@ Creates a `PixivClient` by exchanging the given refresh token for an access toke
72
72
 
73
73
  | Namespace | Methods |
74
74
  |---|---|
75
- | `illusts` | `detail`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete`, `trendingTags`, `popularPreview` |
76
- | `novels` | `detail`, `text`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete`, `trendingTags`, `popularPreview` |
77
- | `users` | `detail`, `detailV2`, `search`, `illusts`, `novels`, `following`, `followAdd`, `followDelete`, `related`, `recommended`, `follower`, `mypixiv`, `list`, `bookmarkTagsIllust`, `editAiShowSettings` |
75
+ | `illusts` | `detail`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete`, `mypixiv`, `trendingTags`, `popularPreview` |
76
+ | `novels` | `detail`, `text`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete`, `bookmarkUsers`, `mypixiv`, `trendingTags`, `popularPreview`, `watchlist`, `markers` |
77
+ | `users` | `detail`, `detailV2`, `search`, `illusts`, `novels`, `following`, `followAdd`, `followDelete`, `related`, `recommended`, `follower`, `mypixiv`, `list`, `bookmarkTagsIllust`, `bookmarkTagsNovel`, `followDetail`, `editAiShowSettings`, `aiShowSettings`, `restrictedModeSettings`, `muteList`, `meState`, `hasUnreadNotifications` |
78
78
  | `users.bookmarks` | `illusts`, `novels` |
79
- | `manga` | `recommended` |
79
+ | `manga` | `recommended`, `watchlist` |
80
80
  | `ugoira` | `metadata` |
81
81
  | `spotlight` | `articles` |
82
82
  | `images` | `fetch` |
package/dist/index.cjs CHANGED
@@ -1191,6 +1191,16 @@ var IllustResource = class {
1191
1191
  })), this.#http, (page) => page.illusts);
1192
1192
  }
1193
1193
  /**
1194
+ * Fetches illusts posted by the authenticated account's mypixiv (mutual
1195
+ * follow) users.
1196
+ * GET /v2/illust/mypixiv
1197
+ *
1198
+ * @param params - Request parameters
1199
+ */
1200
+ mypixiv(params = {}) {
1201
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v2/illust/mypixiv", buildParams({ offset: params.offset })), this.#http, (page) => page.illusts);
1202
+ }
1203
+ /**
1194
1204
  * Fetches comments posted on an illust.
1195
1205
  * GET /v3/illust/comments
1196
1206
  *
@@ -1286,6 +1296,18 @@ function parseWebviewNovel(html) {
1286
1296
  }
1287
1297
  //#endregion
1288
1298
  //#region src/resources/novels.ts
1299
+ /**
1300
+ * Formats a view timestamp as ISO 8601 with milliseconds and the local UTC
1301
+ * offset of that instant. Strings are returned unchanged.
1302
+ */
1303
+ function formatViewedAt(value) {
1304
+ if (typeof value === "string") return value;
1305
+ const pad = (n, width = 2) => String(n).padStart(width, "0");
1306
+ const offsetMinutes = -value.getTimezoneOffset();
1307
+ const sign = offsetMinutes < 0 ? "-" : "+";
1308
+ const absOffset = Math.abs(offsetMinutes);
1309
+ return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}T${pad(value.getHours())}:${pad(value.getMinutes())}:${pad(value.getSeconds())}.${pad(value.getMilliseconds(), 3)}${sign}${pad(Math.floor(absOffset / 60))}:${pad(absOffset % 60)}`;
1310
+ }
1289
1311
  /** Methods for the novel API namespace. */
1290
1312
  var NovelResource = class {
1291
1313
  #http;
@@ -1425,18 +1447,27 @@ var NovelResource = class {
1425
1447
  }
1426
1448
  /**
1427
1449
  * Fetches recommended novels.
1428
- * GET /v1/novel/recommended
1450
+ * GET /v1/novel/recommended, or POST /v1/novel/recommended when
1451
+ * `params.viewed` is non-empty.
1429
1452
  *
1430
1453
  * @param params - Request parameters
1431
1454
  */
1432
1455
  recommended(params = {}) {
1433
- return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/novel/recommended", buildParams({
1456
+ const path = "/v1/novel/recommended";
1457
+ const query = {
1434
1458
  filter: params.filter ?? "for_ios",
1435
1459
  includeRankingNovels: true,
1436
1460
  includePrivacyPolicy: true,
1437
1461
  offset: params.offset,
1438
1462
  maxBookmarkIdForRecommend: params.maxBookmarkIdForRecommend
1439
- })), this.#http, (page) => page.novels);
1463
+ };
1464
+ const viewed = params.viewed ?? [];
1465
+ const first = viewed.length > 0 ? this.#http.post(path, buildParams({
1466
+ ...query,
1467
+ viewNovelIds: viewed.map((entry) => entry.id),
1468
+ viewNovelDatetimes: viewed.map((entry) => formatViewedAt(entry.viewedAt))
1469
+ }).toString()) : this.#http.get(path, buildParams(query));
1470
+ return PaginatedResultAsync.fromResultAsync(first, this.#http, (page) => page.novels);
1440
1471
  }
1441
1472
  /**
1442
1473
  * Fetches a novel series.
@@ -1451,6 +1482,24 @@ var NovelResource = class {
1451
1482
  })), this.#http, (page) => page.novels);
1452
1483
  }
1453
1484
  /**
1485
+ * Fetches the authenticated user's novel series watchlist.
1486
+ * GET /v1/watchlist/novel
1487
+ *
1488
+ * Takes no parameters; later pages follow the server-provided `next_url`.
1489
+ */
1490
+ watchlist() {
1491
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/watchlist/novel"), this.#http, (page) => page.series);
1492
+ }
1493
+ /**
1494
+ * Fetches the novels with a saved reading position (marker).
1495
+ * GET /v2/novel/markers
1496
+ *
1497
+ * Takes no parameters; later pages follow the server-provided `next_url`.
1498
+ */
1499
+ markers() {
1500
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v2/novel/markers"), this.#http, (page) => page.markedNovels);
1501
+ }
1502
+ /**
1454
1503
  * Adds a novel bookmark.
1455
1504
  * POST /v2/novel/bookmark/add
1456
1505
  *
@@ -1475,6 +1524,18 @@ var NovelResource = class {
1475
1524
  return this.#http.post("/v1/novel/bookmark/delete", body.toString());
1476
1525
  }
1477
1526
  /**
1527
+ * Fetches the users who bookmarked a novel.
1528
+ * GET /v1/novel/bookmark/users
1529
+ *
1530
+ * @param params - Request parameters
1531
+ */
1532
+ bookmarkUsers(params) {
1533
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/novel/bookmark/users", buildParams({
1534
+ novelId: params.novelId,
1535
+ offset: params.offset
1536
+ })), this.#http, (page) => page.users);
1537
+ }
1538
+ /**
1478
1539
  * Fetches novels posted by users the authenticated account follows.
1479
1540
  * GET /v1/novel/follow
1480
1541
  *
@@ -1487,6 +1548,19 @@ var NovelResource = class {
1487
1548
  })), this.#http, (page) => page.novels);
1488
1549
  }
1489
1550
  /**
1551
+ * Fetches novels posted by the authenticated account's mypixiv (mutual
1552
+ * follow) users.
1553
+ * GET /v1/novel/mypixiv
1554
+ *
1555
+ * The endpoint ignores `offset`. Paginate with `maxNovelId`, or follow
1556
+ * `next_url` via `.pages()` / `.items()`.
1557
+ *
1558
+ * @param params - Request parameters
1559
+ */
1560
+ mypixiv(params = {}) {
1561
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/novel/mypixiv", buildParams({ maxNovelId: params.maxNovelId })), this.#http, (page) => page.novels);
1562
+ }
1563
+ /**
1490
1564
  * Fetches comments posted on a novel.
1491
1565
  * GET /v3/novel/comments
1492
1566
  *
@@ -1799,6 +1873,28 @@ var UserResource = class {
1799
1873
  })), this.#http, (page) => page.bookmarkTags);
1800
1874
  }
1801
1875
  /**
1876
+ * Fetches a user's novel bookmark tags, with the number of bookmarks under each tag.
1877
+ * GET /v1/user/bookmark-tags/novel
1878
+ *
1879
+ * @param params - Request parameters
1880
+ */
1881
+ bookmarkTagsNovel(params) {
1882
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/user/bookmark-tags/novel", buildParams({
1883
+ userId: params.userId,
1884
+ restrict: params.restrict ?? "public",
1885
+ offset: params.offset
1886
+ })), this.#http, (page) => page.bookmarkTags);
1887
+ }
1888
+ /**
1889
+ * Fetches whether the authenticated user follows a user, and with which visibility.
1890
+ * GET /v1/user/follow/detail
1891
+ *
1892
+ * @param params - Request parameters
1893
+ */
1894
+ followDetail(params) {
1895
+ return this.#http.get("/v1/user/follow/detail", buildParams({ userId: params.userId }));
1896
+ }
1897
+ /**
1802
1898
  * Edits the authenticated user's AI-generated-work display setting.
1803
1899
  * POST /v1/user/ai-show-settings/edit
1804
1900
  *
@@ -1808,6 +1904,41 @@ var UserResource = class {
1808
1904
  const body = buildParams({ setting: params.setting });
1809
1905
  return this.#http.post("/v1/user/ai-show-settings/edit", body.toString());
1810
1906
  }
1907
+ /**
1908
+ * Fetches the authenticated user's AI-generated-work display setting.
1909
+ * GET /v1/user/ai-show-settings
1910
+ */
1911
+ aiShowSettings() {
1912
+ return this.#http.get("/v1/user/ai-show-settings");
1913
+ }
1914
+ /**
1915
+ * Fetches the authenticated user's restricted-mode setting.
1916
+ * GET /v1/user/restricted-mode-settings
1917
+ */
1918
+ restrictedModeSettings() {
1919
+ return this.#http.get("/v1/user/restricted-mode-settings");
1920
+ }
1921
+ /**
1922
+ * Fetches the authenticated user's mute list.
1923
+ * GET /v1/mute/list
1924
+ */
1925
+ muteList() {
1926
+ return this.#http.get("/v1/mute/list");
1927
+ }
1928
+ /**
1929
+ * Fetches the authenticated user's account state and profile.
1930
+ * GET /v1/user/me/state
1931
+ */
1932
+ meState() {
1933
+ return this.#http.get("/v1/user/me/state");
1934
+ }
1935
+ /**
1936
+ * Fetches whether the authenticated user has unread notifications.
1937
+ * GET /v1/notification/has-unread-notifications
1938
+ */
1939
+ hasUnreadNotifications() {
1940
+ return this.#http.get("/v1/notification/has-unread-notifications");
1941
+ }
1811
1942
  };
1812
1943
  //#endregion
1813
1944
  //#region src/resources/manga.ts
@@ -1831,6 +1962,15 @@ var MangaResource = class {
1831
1962
  offset: params.offset
1832
1963
  })), this.#http, (page) => page.illusts);
1833
1964
  }
1965
+ /**
1966
+ * Fetches the authenticated user's manga series watchlist.
1967
+ * GET /v1/watchlist/manga
1968
+ *
1969
+ * Takes no parameters; later pages follow the server-provided `next_url`.
1970
+ */
1971
+ watchlist() {
1972
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/watchlist/manga"), this.#http, (page) => page.series);
1973
+ }
1834
1974
  };
1835
1975
  //#endregion
1836
1976
  //#region src/resources/ugoira.ts