@book000/pixivts 0.64.0-beta.1 → 0.64.0-beta.11

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` |
76
- | `novels` | `detail`, `text`, `related`, `search`, `ranking`, `recommended`, `series`, `bookmarkAdd`, `bookmarkDelete` |
77
- | `users` | `detail`, `search`, `illusts`, `novels`, `following`, `followAdd`, `followDelete`, `related`, `recommended`, `follower`, `mypixiv`, `list`, `bookmarkTagsIllust`, `editAiShowSettings` |
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`, `watchlist`, `markers` |
77
+ | `users` | `detail`, `detailV2`, `search`, `illusts`, `novels`, `following`, `followAdd`, `followDelete`, `related`, `recommended`, `follower`, `mypixiv`, `list`, `bookmarkTagsIllust`, `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
@@ -1076,10 +1076,40 @@ var IllustResource = class {
1076
1076
  startDate: params.startDate,
1077
1077
  endDate: params.endDate,
1078
1078
  searchAiType: params.searchAiType,
1079
+ includeTranslatedTagResults: params.includeTranslatedTagResults,
1080
+ mergePlainKeywordResults: params.mergePlainKeywordResults,
1081
+ includePotentialViolationWorks: params.includePotentialViolationWorks,
1082
+ contentType: params.contentType,
1079
1083
  offset: params.offset
1080
1084
  })), this.#http, (page) => page.illusts);
1081
1085
  }
1082
1086
  /**
1087
+ * Fetches the popular-preview illust search results (a single page of 30).
1088
+ * GET /v1/search/popular-preview/illust
1089
+ *
1090
+ * The endpoint returns no `next_url`, so the result is not paginated.
1091
+ *
1092
+ * @param params - Request parameters
1093
+ *
1094
+ * @example
1095
+ * ```ts
1096
+ * const result = await client.illusts.popularPreview({ word: 'cat' })
1097
+ * if (result.isOk) {
1098
+ * console.log(result.value.illusts.length)
1099
+ * }
1100
+ * ```
1101
+ */
1102
+ popularPreview(params) {
1103
+ return this.#http.get("/v1/search/popular-preview/illust", buildParams({
1104
+ word: params.word,
1105
+ searchTarget: params.searchTarget ?? "partial_match_for_tags",
1106
+ filter: params.filter ?? "for_ios",
1107
+ searchAiType: params.searchAiType,
1108
+ includeTranslatedTagResults: params.includeTranslatedTagResults,
1109
+ mergePlainKeywordResults: params.mergePlainKeywordResults
1110
+ }));
1111
+ }
1112
+ /**
1083
1113
  * Fetches the illust ranking.
1084
1114
  * GET /v1/illust/ranking
1085
1115
  *
@@ -1173,6 +1203,18 @@ var IllustResource = class {
1173
1203
  })), this.#http, (page) => page.comments);
1174
1204
  }
1175
1205
  /**
1206
+ * Fetches replies to a comment on an illust.
1207
+ * GET /v2/illust/comment/replies
1208
+ *
1209
+ * @param params - Request parameters
1210
+ */
1211
+ commentReplies(params) {
1212
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v2/illust/comment/replies", buildParams({
1213
+ commentId: params.commentId,
1214
+ offset: params.offset
1215
+ })), this.#http, (page) => page.comments);
1216
+ }
1217
+ /**
1176
1218
  * Fetches bookmark metadata (tags, visibility) for an illust.
1177
1219
  * GET /v2/illust/bookmark/detail
1178
1220
  *
@@ -1244,6 +1286,18 @@ function parseWebviewNovel(html) {
1244
1286
  }
1245
1287
  //#endregion
1246
1288
  //#region src/resources/novels.ts
1289
+ /**
1290
+ * Formats a view timestamp as ISO 8601 with milliseconds and the local UTC
1291
+ * offset of that instant. Strings are returned unchanged.
1292
+ */
1293
+ function formatViewedAt(value) {
1294
+ if (typeof value === "string") return value;
1295
+ const pad = (n, width = 2) => String(n).padStart(width, "0");
1296
+ const offsetMinutes = -value.getTimezoneOffset();
1297
+ const sign = offsetMinutes < 0 ? "-" : "+";
1298
+ const absOffset = Math.abs(offsetMinutes);
1299
+ 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)}`;
1300
+ }
1247
1301
  /** Methods for the novel API namespace. */
1248
1302
  var NovelResource = class {
1249
1303
  #http;
@@ -1327,10 +1381,47 @@ var NovelResource = class {
1327
1381
  startDate: params.startDate,
1328
1382
  endDate: params.endDate,
1329
1383
  searchAiType: params.searchAiType,
1384
+ includeTranslatedTagResults: params.includeTranslatedTagResults,
1385
+ mergePlainKeywordResults: params.mergePlainKeywordResults,
1386
+ includePotentialViolationWorks: params.includePotentialViolationWorks,
1330
1387
  offset: params.offset
1331
1388
  })), this.#http, (page) => page.novels);
1332
1389
  }
1333
1390
  /**
1391
+ * Fetches the popular-preview novel search results (a single page of 30).
1392
+ * GET /v1/search/popular-preview/novel
1393
+ *
1394
+ * The endpoint returns no `next_url`, so the result is not paginated.
1395
+ *
1396
+ * @param params - Request parameters
1397
+ *
1398
+ * @example
1399
+ * ```ts
1400
+ * const result = await client.novels.popularPreview({ word: 'fantasy' })
1401
+ * if (result.isOk) {
1402
+ * console.log(result.value.novels.length)
1403
+ * }
1404
+ * ```
1405
+ */
1406
+ popularPreview(params) {
1407
+ return this.#http.get("/v1/search/popular-preview/novel", buildParams({
1408
+ word: params.word,
1409
+ searchTarget: params.searchTarget ?? "partial_match_for_tags",
1410
+ searchAiType: params.searchAiType,
1411
+ includeTranslatedTagResults: params.includeTranslatedTagResults,
1412
+ mergePlainKeywordResults: params.mergePlainKeywordResults
1413
+ }));
1414
+ }
1415
+ /**
1416
+ * Fetches currently trending novel tags, each with a representative illust.
1417
+ * GET /v1/trending-tags/novel
1418
+ *
1419
+ * Takes no parameters: the endpoint ignores `filter`.
1420
+ */
1421
+ trendingTags() {
1422
+ return this.#http.get("/v1/trending-tags/novel");
1423
+ }
1424
+ /**
1334
1425
  * Fetches the novel ranking.
1335
1426
  * GET /v1/novel/ranking
1336
1427
  *
@@ -1346,18 +1437,27 @@ var NovelResource = class {
1346
1437
  }
1347
1438
  /**
1348
1439
  * Fetches recommended novels.
1349
- * GET /v1/novel/recommended
1440
+ * GET /v1/novel/recommended, or POST /v1/novel/recommended when
1441
+ * `params.viewed` is non-empty.
1350
1442
  *
1351
1443
  * @param params - Request parameters
1352
1444
  */
1353
1445
  recommended(params = {}) {
1354
- return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/novel/recommended", buildParams({
1446
+ const path = "/v1/novel/recommended";
1447
+ const query = {
1355
1448
  filter: params.filter ?? "for_ios",
1356
1449
  includeRankingNovels: true,
1357
1450
  includePrivacyPolicy: true,
1358
1451
  offset: params.offset,
1359
1452
  maxBookmarkIdForRecommend: params.maxBookmarkIdForRecommend
1360
- })), this.#http, (page) => page.novels);
1453
+ };
1454
+ const viewed = params.viewed ?? [];
1455
+ const first = viewed.length > 0 ? this.#http.post(path, buildParams({
1456
+ ...query,
1457
+ viewNovelIds: viewed.map((entry) => entry.id),
1458
+ viewNovelDatetimes: viewed.map((entry) => formatViewedAt(entry.viewedAt))
1459
+ }).toString()) : this.#http.get(path, buildParams(query));
1460
+ return PaginatedResultAsync.fromResultAsync(first, this.#http, (page) => page.novels);
1361
1461
  }
1362
1462
  /**
1363
1463
  * Fetches a novel series.
@@ -1372,6 +1472,24 @@ var NovelResource = class {
1372
1472
  })), this.#http, (page) => page.novels);
1373
1473
  }
1374
1474
  /**
1475
+ * Fetches the authenticated user's novel series watchlist.
1476
+ * GET /v1/watchlist/novel
1477
+ *
1478
+ * Takes no parameters; later pages follow the server-provided `next_url`.
1479
+ */
1480
+ watchlist() {
1481
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/watchlist/novel"), this.#http, (page) => page.series);
1482
+ }
1483
+ /**
1484
+ * Fetches the novels with a saved reading position (marker).
1485
+ * GET /v2/novel/markers
1486
+ *
1487
+ * Takes no parameters; later pages follow the server-provided `next_url`.
1488
+ */
1489
+ markers() {
1490
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v2/novel/markers"), this.#http, (page) => page.markedNovels);
1491
+ }
1492
+ /**
1375
1493
  * Adds a novel bookmark.
1376
1494
  * POST /v2/novel/bookmark/add
1377
1495
  *
@@ -1409,15 +1527,26 @@ var NovelResource = class {
1409
1527
  }
1410
1528
  /**
1411
1529
  * Fetches comments posted on a novel.
1412
- * GET /v1/novel/comments
1530
+ * GET /v3/novel/comments
1413
1531
  *
1414
1532
  * @param params - Request parameters
1415
1533
  */
1416
1534
  comments(params) {
1417
- return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/novel/comments", buildParams({
1535
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v3/novel/comments", buildParams({
1418
1536
  novelId: params.novelId,
1419
- offset: params.offset,
1420
- includeTotalComments: params.includeTotalComments
1537
+ offset: params.offset
1538
+ })), this.#http, (page) => page.comments);
1539
+ }
1540
+ /**
1541
+ * Fetches replies to a comment on a novel.
1542
+ * GET /v2/novel/comment/replies
1543
+ *
1544
+ * @param params - Request parameters
1545
+ */
1546
+ commentReplies(params) {
1547
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v2/novel/comment/replies", buildParams({
1548
+ commentId: params.commentId,
1549
+ offset: params.offset
1421
1550
  })), this.#http, (page) => page.comments);
1422
1551
  }
1423
1552
  /**
@@ -1514,6 +1643,9 @@ var UserResource = class {
1514
1643
  * Fetches detailed profile information for a user.
1515
1644
  * GET /v1/user/detail
1516
1645
  *
1646
+ * See {@link UserResource.detailV2} for the v2 endpoint, which exposes
1647
+ * additional fields (`disabledLinks`, `profile.badge`).
1648
+ *
1517
1649
  * @param params - Request parameters
1518
1650
  */
1519
1651
  detail(params) {
@@ -1523,6 +1655,24 @@ var UserResource = class {
1523
1655
  }));
1524
1656
  }
1525
1657
  /**
1658
+ * Fetches detailed profile information for a user using the v2 endpoint.
1659
+ * GET /v2/user/detail
1660
+ *
1661
+ * Unlike {@link UserResource.detail}, the response includes `disabledLinks`
1662
+ * and `profile.badge`, several profile values are `null` instead of empty
1663
+ * strings or `0`, and the v1-only fields (`profile.pawooUrl`,
1664
+ * `profile.totalIllustBookmarksPublic`, `profilePublicity.pawoo`,
1665
+ * `workspace.workspaceImageUrl`) are absent.
1666
+ *
1667
+ * @param params - Request parameters
1668
+ */
1669
+ detailV2(params) {
1670
+ return this.#http.get("/v2/user/detail", buildParams({
1671
+ userId: params.userId,
1672
+ filter: params.filter ?? "for_ios"
1673
+ }));
1674
+ }
1675
+ /**
1526
1676
  * Searches for users.
1527
1677
  * GET /v1/search/user
1528
1678
  *
@@ -1697,6 +1847,41 @@ var UserResource = class {
1697
1847
  const body = buildParams({ setting: params.setting });
1698
1848
  return this.#http.post("/v1/user/ai-show-settings/edit", body.toString());
1699
1849
  }
1850
+ /**
1851
+ * Fetches the authenticated user's AI-generated-work display setting.
1852
+ * GET /v1/user/ai-show-settings
1853
+ */
1854
+ aiShowSettings() {
1855
+ return this.#http.get("/v1/user/ai-show-settings");
1856
+ }
1857
+ /**
1858
+ * Fetches the authenticated user's restricted-mode setting.
1859
+ * GET /v1/user/restricted-mode-settings
1860
+ */
1861
+ restrictedModeSettings() {
1862
+ return this.#http.get("/v1/user/restricted-mode-settings");
1863
+ }
1864
+ /**
1865
+ * Fetches the authenticated user's mute list.
1866
+ * GET /v1/mute/list
1867
+ */
1868
+ muteList() {
1869
+ return this.#http.get("/v1/mute/list");
1870
+ }
1871
+ /**
1872
+ * Fetches the authenticated user's account state and profile.
1873
+ * GET /v1/user/me/state
1874
+ */
1875
+ meState() {
1876
+ return this.#http.get("/v1/user/me/state");
1877
+ }
1878
+ /**
1879
+ * Fetches whether the authenticated user has unread notifications.
1880
+ * GET /v1/notification/has-unread-notifications
1881
+ */
1882
+ hasUnreadNotifications() {
1883
+ return this.#http.get("/v1/notification/has-unread-notifications");
1884
+ }
1700
1885
  };
1701
1886
  //#endregion
1702
1887
  //#region src/resources/manga.ts
@@ -1720,6 +1905,15 @@ var MangaResource = class {
1720
1905
  offset: params.offset
1721
1906
  })), this.#http, (page) => page.illusts);
1722
1907
  }
1908
+ /**
1909
+ * Fetches the authenticated user's manga series watchlist.
1910
+ * GET /v1/watchlist/manga
1911
+ *
1912
+ * Takes no parameters; later pages follow the server-provided `next_url`.
1913
+ */
1914
+ watchlist() {
1915
+ return PaginatedResultAsync.fromResultAsync(this.#http.get("/v1/watchlist/manga"), this.#http, (page) => page.series);
1916
+ }
1723
1917
  };
1724
1918
  //#endregion
1725
1919
  //#region src/resources/ugoira.ts