@book000/pixivts 0.57.1 → 0.58.1
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/dist/index.cjs +214 -31
- package/dist/index.d.cts +252 -46
- package/dist/index.d.ts +252 -46
- package/dist/index.js +205 -32
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -447,11 +447,70 @@ declare class PaginatedResultAsync<TPage extends PagedResponse, TItem> extends R
|
|
|
447
447
|
declare function failedPaginated<TPage extends PagedResponse, TItem>(error: PixivError, http: HttpClient, getItems: (page: TPage) => TItem[]): PaginatedResultAsync<TPage, TItem>;
|
|
448
448
|
|
|
449
449
|
/**
|
|
450
|
-
*
|
|
450
|
+
* Typed cursor parameters extracted from a pixiv `next_url`.
|
|
451
451
|
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
452
|
+
* Different endpoints use different cursor fields; only the fields present
|
|
453
|
+
* in the URL will be defined.
|
|
454
|
+
*
|
|
455
|
+
* | Field | Endpoint(s) |
|
|
456
|
+
* |---|---|
|
|
457
|
+
* | `maxBookmarkId` | `GET /v1/user/bookmarks/illust` |
|
|
458
|
+
* | `maxBookmarkIdForRecommend` | `GET /v1/illust/recommended`, `GET /v1/novel/recommended` |
|
|
459
|
+
* | `minBookmarkIdForRecentIllust` | `GET /v1/illust/recommended` |
|
|
460
|
+
* | `offset` | search, ranking, recommended, user lists, … |
|
|
461
|
+
* | `lastOrder` | `GET /v2/novel/series` |
|
|
462
|
+
*/
|
|
463
|
+
interface ParsedNextUrl {
|
|
464
|
+
/** Cursor for `GET /v1/user/bookmarks/illust`. */
|
|
465
|
+
maxBookmarkId?: number;
|
|
466
|
+
/** Cursor for `GET /v1/illust/recommended` and `GET /v1/novel/recommended`. */
|
|
467
|
+
maxBookmarkIdForRecommend?: number;
|
|
468
|
+
/** Secondary cursor for `GET /v1/illust/recommended`. */
|
|
469
|
+
minBookmarkIdForRecentIllust?: number;
|
|
470
|
+
/** Zero-based offset for general list endpoints. */
|
|
471
|
+
offset?: number;
|
|
472
|
+
/** Cursor for `GET /v2/novel/series`. */
|
|
473
|
+
lastOrder?: number;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Parses a pixiv `next_url` into a typed cursor object.
|
|
477
|
+
*
|
|
478
|
+
* Pass the `next_url` field from any paginated response to extract the
|
|
479
|
+
* cursor parameters needed to resume pagination from a saved position.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* const page = await client.users.bookmarks.illusts({ userId: client.userId })
|
|
484
|
+
* if (page.isOk && page.value.next_url) {
|
|
485
|
+
* const cursor = parseNextUrl(page.value.next_url)
|
|
486
|
+
* // Resume later:
|
|
487
|
+
* const next = await client.users.bookmarks.illusts({
|
|
488
|
+
* userId: client.userId,
|
|
489
|
+
* maxBookmarkId: cursor.maxBookmarkId,
|
|
490
|
+
* })
|
|
491
|
+
* }
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* @param url - The `next_url` string returned by a pixiv list endpoint
|
|
495
|
+
* @returns Typed cursor parameters; fields absent in the URL are `undefined`
|
|
496
|
+
*/
|
|
497
|
+
declare function parseNextUrl(url: string): ParsedNextUrl;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Public option constants for @book000/pixivts.
|
|
501
|
+
*
|
|
502
|
+
* Each option is exported as a runtime `const` object for enum-like access
|
|
503
|
+
* (e.g. `BookmarkRestrict.PUBLIC`). Plain string literals are also accepted
|
|
504
|
+
* wherever these values are used as parameters.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* // Enum-like usage
|
|
509
|
+
* await client.illusts.bookmarkAdd({ illustId: 123, restrict: BookmarkRestrict.PUBLIC })
|
|
510
|
+
*
|
|
511
|
+
* // Plain string literal — also valid
|
|
512
|
+
* await client.illusts.bookmarkAdd({ illustId: 123, restrict: 'public' })
|
|
513
|
+
* ```
|
|
455
514
|
*/
|
|
456
515
|
/**
|
|
457
516
|
* Search match target for illust / novel searches.
|
|
@@ -461,7 +520,12 @@ declare function failedPaginated<TPage extends PagedResponse, TItem>(error: Pixi
|
|
|
461
520
|
* - `title_and_caption` — title or caption contains the word
|
|
462
521
|
* - `keyword` — general keyword search (novel only)
|
|
463
522
|
*/
|
|
464
|
-
|
|
523
|
+
declare const SearchTarget: {
|
|
524
|
+
readonly PARTIAL_MATCH_FOR_TAGS: "partial_match_for_tags";
|
|
525
|
+
readonly EXACT_MATCH_FOR_TAGS: "exact_match_for_tags";
|
|
526
|
+
readonly TITLE_AND_CAPTION: "title_and_caption";
|
|
527
|
+
readonly KEYWORD: "keyword";
|
|
528
|
+
};
|
|
465
529
|
/**
|
|
466
530
|
* Sort order for search results.
|
|
467
531
|
*
|
|
@@ -469,7 +533,11 @@ type SearchTarget = 'partial_match_for_tags' | 'exact_match_for_tags' | 'title_a
|
|
|
469
533
|
* - `date_asc` — oldest first
|
|
470
534
|
* - `popular_desc` — most bookmarks first (premium only)
|
|
471
535
|
*/
|
|
472
|
-
|
|
536
|
+
declare const SearchSort: {
|
|
537
|
+
readonly DATE_DESC: "date_desc";
|
|
538
|
+
readonly DATE_ASC: "date_asc";
|
|
539
|
+
readonly POPULAR_DESC: "popular_desc";
|
|
540
|
+
};
|
|
473
541
|
/**
|
|
474
542
|
* Date range filter for search results.
|
|
475
543
|
*
|
|
@@ -477,47 +545,86 @@ type SearchSort = 'date_desc' | 'date_asc' | 'popular_desc';
|
|
|
477
545
|
* - `within_last_week` — past 7 days
|
|
478
546
|
* - `within_last_month` — past 30 days
|
|
479
547
|
*/
|
|
480
|
-
|
|
548
|
+
declare const SearchDuration: {
|
|
549
|
+
readonly WITHIN_LAST_DAY: "within_last_day";
|
|
550
|
+
readonly WITHIN_LAST_WEEK: "within_last_week";
|
|
551
|
+
readonly WITHIN_LAST_MONTH: "within_last_month";
|
|
552
|
+
};
|
|
481
553
|
/**
|
|
482
554
|
* Ranking mode for illust rankings.
|
|
483
555
|
*
|
|
484
556
|
* R-18 modes require a premium account with R-18 content enabled.
|
|
485
557
|
*/
|
|
486
|
-
|
|
558
|
+
declare const RankingMode: {
|
|
559
|
+
readonly DAY: "day";
|
|
560
|
+
readonly DAY_MALE: "day_male";
|
|
561
|
+
readonly DAY_FEMALE: "day_female";
|
|
562
|
+
readonly WEEK_ORIGINAL: "week_original";
|
|
563
|
+
readonly WEEK_ROOKIE: "week_rookie";
|
|
564
|
+
readonly WEEK: "week";
|
|
565
|
+
readonly MONTH: "month";
|
|
566
|
+
readonly DAY_AI: "day_ai";
|
|
567
|
+
readonly DAY_R18: "day_r18";
|
|
568
|
+
readonly WEEK_R18: "week_r18";
|
|
569
|
+
readonly DAY_MALE_R18: "day_male_r18";
|
|
570
|
+
readonly DAY_FEMALE_R18: "day_female_r18";
|
|
571
|
+
readonly DAY_R18_AI: "day_r18_ai";
|
|
572
|
+
};
|
|
487
573
|
/**
|
|
488
574
|
* Ranking mode for novel rankings.
|
|
489
575
|
*
|
|
490
576
|
* R-18 modes require a premium account with R-18 content enabled.
|
|
491
577
|
*/
|
|
492
|
-
|
|
578
|
+
declare const NovelRankingMode: {
|
|
579
|
+
readonly DAY: "day";
|
|
580
|
+
readonly WEEK: "week";
|
|
581
|
+
readonly DAY_MALE: "day_male";
|
|
582
|
+
readonly DAY_FEMALE: "day_female";
|
|
583
|
+
readonly WEEK_ROOKIE: "week_rookie";
|
|
584
|
+
readonly DAY_R18: "day_r18";
|
|
585
|
+
readonly WEEK_R18: "week_r18";
|
|
586
|
+
readonly DAY_R18_AI: "day_r18_ai";
|
|
587
|
+
};
|
|
493
588
|
/**
|
|
494
589
|
* Visibility restriction for bookmarks.
|
|
495
590
|
*
|
|
496
591
|
* - `public` — publicly visible (default)
|
|
497
592
|
* - `private` — visible only to the owner
|
|
498
593
|
*/
|
|
499
|
-
|
|
594
|
+
declare const BookmarkRestrict: {
|
|
595
|
+
readonly PUBLIC: "public";
|
|
596
|
+
readonly PRIVATE: "private";
|
|
597
|
+
};
|
|
500
598
|
/**
|
|
501
599
|
* Visibility restriction for follows.
|
|
502
600
|
*
|
|
503
601
|
* - `public` — publicly visible (default)
|
|
504
602
|
* - `private` — visible only to the owner
|
|
505
603
|
*/
|
|
506
|
-
|
|
604
|
+
declare const FollowRestrict: {
|
|
605
|
+
readonly PUBLIC: "public";
|
|
606
|
+
readonly PRIVATE: "private";
|
|
607
|
+
};
|
|
507
608
|
/**
|
|
508
609
|
* OS filter used to request works compatible with the given platform.
|
|
509
610
|
*
|
|
510
611
|
* - `for_ios` — iOS-compatible works (default)
|
|
511
612
|
* - `for_android` — Android-compatible works
|
|
512
613
|
*/
|
|
513
|
-
|
|
614
|
+
declare const OSFilter: {
|
|
615
|
+
readonly FOR_IOS: "for_ios";
|
|
616
|
+
readonly FOR_ANDROID: "for_android";
|
|
617
|
+
};
|
|
514
618
|
/**
|
|
515
619
|
* Work type filter for user illust listings.
|
|
516
620
|
*
|
|
517
621
|
* - `illust` — illustrations only
|
|
518
622
|
* - `manga` — manga only
|
|
519
623
|
*/
|
|
520
|
-
|
|
624
|
+
declare const UserIllustType: {
|
|
625
|
+
readonly ILLUST: "illust";
|
|
626
|
+
readonly MANGA: "manga";
|
|
627
|
+
};
|
|
521
628
|
|
|
522
629
|
/**
|
|
523
630
|
* Public types for @book000/pixivts.
|
|
@@ -1106,7 +1213,7 @@ interface IllustDetailParams {
|
|
|
1106
1213
|
/** ID of the illust to fetch. */
|
|
1107
1214
|
illustId: number;
|
|
1108
1215
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1109
|
-
filter?: OSFilter;
|
|
1216
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1110
1217
|
}
|
|
1111
1218
|
/** Parameters for fetching related illusts. */
|
|
1112
1219
|
interface IllustRelatedParams {
|
|
@@ -1115,24 +1222,24 @@ interface IllustRelatedParams {
|
|
|
1115
1222
|
/** Additional seed illust IDs to influence recommendations. */
|
|
1116
1223
|
seedIllustIds?: number[];
|
|
1117
1224
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1118
|
-
filter?: OSFilter;
|
|
1225
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1119
1226
|
}
|
|
1120
1227
|
/** Parameters for searching illusts. */
|
|
1121
1228
|
interface IllustSearchParams {
|
|
1122
1229
|
/** Search keyword. */
|
|
1123
1230
|
word: string;
|
|
1124
1231
|
/** How to match the keyword against works (default: `"partial_match_for_tags"`). */
|
|
1125
|
-
searchTarget?: SearchTarget;
|
|
1232
|
+
searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
|
|
1126
1233
|
/** Sort order for results (default: `"date_desc"`). */
|
|
1127
|
-
sort?: SearchSort;
|
|
1234
|
+
sort?: (typeof SearchSort)[keyof typeof SearchSort];
|
|
1128
1235
|
/** Date range preset filter (omit for no restriction). */
|
|
1129
|
-
duration?: SearchDuration;
|
|
1236
|
+
duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
|
|
1130
1237
|
/** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
|
|
1131
1238
|
startDate?: string;
|
|
1132
1239
|
/** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
|
|
1133
1240
|
endDate?: string;
|
|
1134
1241
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1135
|
-
filter?: OSFilter;
|
|
1242
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1136
1243
|
/** AI-generated content filter: `0` = hide AI works, `1` = show only AI works. */
|
|
1137
1244
|
searchAiType?: 0 | 1;
|
|
1138
1245
|
/** Zero-based offset for pagination. */
|
|
@@ -1141,9 +1248,9 @@ interface IllustSearchParams {
|
|
|
1141
1248
|
/** Parameters for fetching the illust ranking. */
|
|
1142
1249
|
interface IllustRankingParams {
|
|
1143
1250
|
/** Ranking category (default: `"day"`). */
|
|
1144
|
-
mode?: RankingMode;
|
|
1251
|
+
mode?: (typeof RankingMode)[keyof typeof RankingMode];
|
|
1145
1252
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1146
|
-
filter?: OSFilter;
|
|
1253
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1147
1254
|
/** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
|
|
1148
1255
|
date?: string;
|
|
1149
1256
|
/** Zero-based offset for pagination. */
|
|
@@ -1152,23 +1259,33 @@ interface IllustRankingParams {
|
|
|
1152
1259
|
/** Parameters for fetching recommended illusts. */
|
|
1153
1260
|
interface IllustRecommendedParams {
|
|
1154
1261
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1155
|
-
filter?: OSFilter;
|
|
1262
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1156
1263
|
/** Zero-based offset for pagination. */
|
|
1157
1264
|
offset?: number;
|
|
1265
|
+
/**
|
|
1266
|
+
* Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
|
|
1267
|
+
* extracted from a previous page's `next_url` via {@link parseNextUrl}.
|
|
1268
|
+
*/
|
|
1269
|
+
maxBookmarkIdForRecommend?: number;
|
|
1270
|
+
/**
|
|
1271
|
+
* Secondary cursor for resuming pagination: the `minBookmarkIdForRecentIllust`
|
|
1272
|
+
* value extracted from a previous page's `next_url` via {@link parseNextUrl}.
|
|
1273
|
+
*/
|
|
1274
|
+
minBookmarkIdForRecentIllust?: number;
|
|
1158
1275
|
}
|
|
1159
1276
|
/** Parameters for fetching an illust series. */
|
|
1160
1277
|
interface IllustSeriesParams {
|
|
1161
1278
|
/** ID of the illust series to fetch. */
|
|
1162
1279
|
illustSeriesId: number;
|
|
1163
1280
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1164
|
-
filter?: OSFilter;
|
|
1281
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1165
1282
|
}
|
|
1166
1283
|
/** Parameters for adding an illust bookmark. */
|
|
1167
1284
|
interface IllustBookmarkAddParams {
|
|
1168
1285
|
/** ID of the illust to bookmark. */
|
|
1169
1286
|
illustId: number;
|
|
1170
1287
|
/** Bookmark visibility (default: `"public"`). */
|
|
1171
|
-
restrict?: BookmarkRestrict;
|
|
1288
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1172
1289
|
/** Tags to attach to the bookmark. */
|
|
1173
1290
|
tags?: string[];
|
|
1174
1291
|
}
|
|
@@ -1186,6 +1303,16 @@ declare class IllustResource {
|
|
|
1186
1303
|
* GET /v1/illust/detail
|
|
1187
1304
|
*
|
|
1188
1305
|
* @param params - Request parameters
|
|
1306
|
+
*
|
|
1307
|
+
* @example
|
|
1308
|
+
* ```ts
|
|
1309
|
+
* const result = await client.illusts.detail({ illustId: 12345 })
|
|
1310
|
+
* if (result.isOk) {
|
|
1311
|
+
* console.log(result.value.illust.title)
|
|
1312
|
+
* } else {
|
|
1313
|
+
* console.error(result.error)
|
|
1314
|
+
* }
|
|
1315
|
+
* ```
|
|
1189
1316
|
*/
|
|
1190
1317
|
detail(params: IllustDetailParams): ResultAsync<IllustDetailResponse, PixivError>;
|
|
1191
1318
|
/**
|
|
@@ -1200,6 +1327,20 @@ declare class IllustResource {
|
|
|
1200
1327
|
* GET /v1/search/illust
|
|
1201
1328
|
*
|
|
1202
1329
|
* @param params - Request parameters
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* ```ts
|
|
1333
|
+
* // Iterate all results across pages
|
|
1334
|
+
* for await (const illust of client.illusts.search({ word: 'cat' }).items()) {
|
|
1335
|
+
* console.log(illust.title)
|
|
1336
|
+
* }
|
|
1337
|
+
*
|
|
1338
|
+
* // Fetch only the first page
|
|
1339
|
+
* const page = await client.illusts.search({ word: 'cat' })
|
|
1340
|
+
* if (page.isOk) {
|
|
1341
|
+
* console.log(page.value.illusts.length)
|
|
1342
|
+
* }
|
|
1343
|
+
* ```
|
|
1203
1344
|
*/
|
|
1204
1345
|
search(params: IllustSearchParams): PaginatedResultAsync<IllustListPage, IllustListPage['illusts'][number]>;
|
|
1205
1346
|
/**
|
|
@@ -1263,13 +1404,13 @@ interface NovelSearchParams {
|
|
|
1263
1404
|
/** Search keyword. */
|
|
1264
1405
|
word: string;
|
|
1265
1406
|
/** How to match the keyword against works (default: `"partial_match_for_tags"`). */
|
|
1266
|
-
searchTarget?: SearchTarget;
|
|
1407
|
+
searchTarget?: (typeof SearchTarget)[keyof typeof SearchTarget];
|
|
1267
1408
|
/** Sort order for results (default: `"date_desc"`). */
|
|
1268
|
-
sort?: SearchSort;
|
|
1409
|
+
sort?: (typeof SearchSort)[keyof typeof SearchSort];
|
|
1269
1410
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1270
|
-
filter?: OSFilter;
|
|
1411
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1271
1412
|
/** Date range preset filter (omit for no restriction). */
|
|
1272
|
-
duration?: SearchDuration;
|
|
1413
|
+
duration?: (typeof SearchDuration)[keyof typeof SearchDuration];
|
|
1273
1414
|
/** Start date for a custom date range (YYYY-MM-DD; requires `endDate`). */
|
|
1274
1415
|
startDate?: string;
|
|
1275
1416
|
/** End date for a custom date range (YYYY-MM-DD; requires `startDate`). */
|
|
@@ -1282,9 +1423,9 @@ interface NovelSearchParams {
|
|
|
1282
1423
|
/** Parameters for fetching the novel ranking. */
|
|
1283
1424
|
interface NovelRankingParams {
|
|
1284
1425
|
/** Ranking category (default: `"day"`). */
|
|
1285
|
-
mode?: NovelRankingMode;
|
|
1426
|
+
mode?: (typeof NovelRankingMode)[keyof typeof NovelRankingMode];
|
|
1286
1427
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1287
|
-
filter?: OSFilter;
|
|
1428
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1288
1429
|
/** Specific date to fetch rankings for (YYYY-MM-DD; omit for the latest). */
|
|
1289
1430
|
date?: string;
|
|
1290
1431
|
/** Zero-based offset for pagination. */
|
|
@@ -1293,9 +1434,14 @@ interface NovelRankingParams {
|
|
|
1293
1434
|
/** Parameters for fetching recommended novels. */
|
|
1294
1435
|
interface NovelRecommendedParams {
|
|
1295
1436
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1296
|
-
filter?: OSFilter;
|
|
1437
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1297
1438
|
/** Zero-based offset for pagination. */
|
|
1298
1439
|
offset?: number;
|
|
1440
|
+
/**
|
|
1441
|
+
* Cursor for resuming pagination: the `maxBookmarkIdForRecommend` value
|
|
1442
|
+
* extracted from a previous page's `next_url` via {@link parseNextUrl}.
|
|
1443
|
+
*/
|
|
1444
|
+
maxBookmarkIdForRecommend?: number;
|
|
1299
1445
|
}
|
|
1300
1446
|
/** Parameters for fetching a novel series. */
|
|
1301
1447
|
interface NovelSeriesParams {
|
|
@@ -1309,7 +1455,7 @@ interface NovelBookmarkAddParams {
|
|
|
1309
1455
|
/** ID of the novel to bookmark. */
|
|
1310
1456
|
novelId: number;
|
|
1311
1457
|
/** Bookmark visibility (default: `"public"`). */
|
|
1312
|
-
restrict?: BookmarkRestrict;
|
|
1458
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1313
1459
|
/** Tags to attach to the bookmark. */
|
|
1314
1460
|
tags?: string[];
|
|
1315
1461
|
}
|
|
@@ -1327,6 +1473,16 @@ declare class NovelResource {
|
|
|
1327
1473
|
* GET /v2/novel/detail
|
|
1328
1474
|
*
|
|
1329
1475
|
* @param params - Request parameters
|
|
1476
|
+
*
|
|
1477
|
+
* @example
|
|
1478
|
+
* ```ts
|
|
1479
|
+
* const result = await client.novels.detail({ novelId: 67890 })
|
|
1480
|
+
* if (result.isOk) {
|
|
1481
|
+
* console.log(result.value.novel.title)
|
|
1482
|
+
* } else {
|
|
1483
|
+
* console.error(result.error)
|
|
1484
|
+
* }
|
|
1485
|
+
* ```
|
|
1330
1486
|
*/
|
|
1331
1487
|
detail(params: NovelDetailParams): ResultAsync<NovelDetailResponse, PixivError>;
|
|
1332
1488
|
/**
|
|
@@ -1351,6 +1507,20 @@ declare class NovelResource {
|
|
|
1351
1507
|
* GET /v1/search/novel
|
|
1352
1508
|
*
|
|
1353
1509
|
* @param params - Request parameters
|
|
1510
|
+
*
|
|
1511
|
+
* @example
|
|
1512
|
+
* ```ts
|
|
1513
|
+
* // Iterate all results across pages
|
|
1514
|
+
* for await (const novel of client.novels.search({ word: 'fantasy' }).items()) {
|
|
1515
|
+
* console.log(novel.title)
|
|
1516
|
+
* }
|
|
1517
|
+
*
|
|
1518
|
+
* // Fetch only the first page
|
|
1519
|
+
* const page = await client.novels.search({ word: 'fantasy' })
|
|
1520
|
+
* if (page.isOk) {
|
|
1521
|
+
* console.log(page.value.novels.length)
|
|
1522
|
+
* }
|
|
1523
|
+
* ```
|
|
1354
1524
|
*/
|
|
1355
1525
|
search(params: NovelSearchParams): PaginatedResultAsync<NovelListPage, PixivNovelItem>;
|
|
1356
1526
|
/**
|
|
@@ -1399,9 +1569,9 @@ interface UserBookmarksIllustParams {
|
|
|
1399
1569
|
/** ID of the user whose bookmarks to fetch. */
|
|
1400
1570
|
userId: number;
|
|
1401
1571
|
/** Visibility of the bookmarks to return (default: `"public"`). */
|
|
1402
|
-
restrict?: BookmarkRestrict;
|
|
1572
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1403
1573
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1404
|
-
filter?: OSFilter;
|
|
1574
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1405
1575
|
/** Limit results to bookmarks with this tag. */
|
|
1406
1576
|
tag?: string;
|
|
1407
1577
|
/** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
|
|
@@ -1414,9 +1584,9 @@ interface UserBookmarksNovelParams {
|
|
|
1414
1584
|
/** ID of the user whose bookmarks to fetch. */
|
|
1415
1585
|
userId: number;
|
|
1416
1586
|
/** Visibility of the bookmarks to return (default: `"public"`). */
|
|
1417
|
-
restrict?: BookmarkRestrict;
|
|
1587
|
+
restrict?: (typeof BookmarkRestrict)[keyof typeof BookmarkRestrict];
|
|
1418
1588
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1419
|
-
filter?: OSFilter;
|
|
1589
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1420
1590
|
/** Limit results to bookmarks with this tag. */
|
|
1421
1591
|
tag?: string;
|
|
1422
1592
|
/** Fetch bookmarks older than this bookmark ID (cursor-based pagination). */
|
|
@@ -1429,16 +1599,16 @@ interface UserDetailParams {
|
|
|
1429
1599
|
/** ID of the user to fetch. */
|
|
1430
1600
|
userId: number;
|
|
1431
1601
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1432
|
-
filter?: OSFilter;
|
|
1602
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1433
1603
|
}
|
|
1434
1604
|
/** Parameters for fetching a user's illusts. */
|
|
1435
1605
|
interface UserIllustsParams {
|
|
1436
1606
|
/** ID of the user whose illusts to fetch. */
|
|
1437
1607
|
userId: number;
|
|
1438
1608
|
/** Work type to filter by (omit to return both illusts and manga). */
|
|
1439
|
-
type?: UserIllustType;
|
|
1609
|
+
type?: (typeof UserIllustType)[keyof typeof UserIllustType];
|
|
1440
1610
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1441
|
-
filter?: OSFilter;
|
|
1611
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1442
1612
|
/** Zero-based offset for pagination. */
|
|
1443
1613
|
offset?: number;
|
|
1444
1614
|
}
|
|
@@ -1447,7 +1617,7 @@ interface UserNovelsParams {
|
|
|
1447
1617
|
/** ID of the user whose novels to fetch. */
|
|
1448
1618
|
userId: number;
|
|
1449
1619
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1450
|
-
filter?: OSFilter;
|
|
1620
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1451
1621
|
/** Zero-based offset for pagination. */
|
|
1452
1622
|
offset?: number;
|
|
1453
1623
|
}
|
|
@@ -1456,7 +1626,7 @@ interface UserFollowingParams {
|
|
|
1456
1626
|
/** ID of the user whose following list to fetch. */
|
|
1457
1627
|
userId: number;
|
|
1458
1628
|
/** Visibility of the follows to return (default: `"public"`). */
|
|
1459
|
-
restrict?: FollowRestrict;
|
|
1629
|
+
restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
|
|
1460
1630
|
/** Zero-based offset for pagination. */
|
|
1461
1631
|
offset?: number;
|
|
1462
1632
|
}
|
|
@@ -1465,7 +1635,7 @@ interface UserFollowAddParams {
|
|
|
1465
1635
|
/** ID of the user to follow. */
|
|
1466
1636
|
userId: number;
|
|
1467
1637
|
/** Visibility of the follow (default: `"public"`). */
|
|
1468
|
-
restrict?: FollowRestrict;
|
|
1638
|
+
restrict?: (typeof FollowRestrict)[keyof typeof FollowRestrict];
|
|
1469
1639
|
}
|
|
1470
1640
|
/** Parameters for unfollowing a user. */
|
|
1471
1641
|
interface UserFollowDeleteParams {
|
|
@@ -1481,6 +1651,25 @@ declare class UserBookmarksResource {
|
|
|
1481
1651
|
* GET /v1/user/bookmarks/illust
|
|
1482
1652
|
*
|
|
1483
1653
|
* @param params - Request parameters
|
|
1654
|
+
*
|
|
1655
|
+
* @example
|
|
1656
|
+
* ```ts
|
|
1657
|
+
* // Iterate all bookmarked illusts across pages
|
|
1658
|
+
* for await (const illust of client.users.bookmarks.illusts({ userId: client.userId }).items()) {
|
|
1659
|
+
* console.log(illust.title)
|
|
1660
|
+
* }
|
|
1661
|
+
*
|
|
1662
|
+
* // Resume from a saved cursor
|
|
1663
|
+
* import { parseNextUrl } from '@book000/pixivts'
|
|
1664
|
+
* const page = await client.users.bookmarks.illusts({ userId: client.userId })
|
|
1665
|
+
* if (page.isOk && page.value.next_url) {
|
|
1666
|
+
* const cursor = parseNextUrl(page.value.next_url)
|
|
1667
|
+
* const next = await client.users.bookmarks.illusts({
|
|
1668
|
+
* userId: client.userId,
|
|
1669
|
+
* maxBookmarkId: cursor.maxBookmarkId,
|
|
1670
|
+
* })
|
|
1671
|
+
* }
|
|
1672
|
+
* ```
|
|
1484
1673
|
*/
|
|
1485
1674
|
illusts(params: UserBookmarksIllustParams): PaginatedResultAsync<UserBookmarksIllustPage, PixivIllustItem>;
|
|
1486
1675
|
/**
|
|
@@ -1488,6 +1677,14 @@ declare class UserBookmarksResource {
|
|
|
1488
1677
|
* GET /v1/user/bookmarks/novel
|
|
1489
1678
|
*
|
|
1490
1679
|
* @param params - Request parameters
|
|
1680
|
+
*
|
|
1681
|
+
* @example
|
|
1682
|
+
* ```ts
|
|
1683
|
+
* // Iterate all bookmarked novels across pages
|
|
1684
|
+
* for await (const novel of client.users.bookmarks.novels({ userId: client.userId }).items()) {
|
|
1685
|
+
* console.log(novel.title)
|
|
1686
|
+
* }
|
|
1687
|
+
* ```
|
|
1491
1688
|
*/
|
|
1492
1689
|
novels(params: UserBookmarksNovelParams): PaginatedResultAsync<UserBookmarksNovelPage, PixivNovelItem>;
|
|
1493
1690
|
}
|
|
@@ -1548,7 +1745,7 @@ declare class UserResource {
|
|
|
1548
1745
|
/** Parameters for fetching recommended manga. */
|
|
1549
1746
|
interface MangaRecommendedParams {
|
|
1550
1747
|
/** OS filter to apply (default: `"for_ios"`). */
|
|
1551
|
-
filter?: OSFilter;
|
|
1748
|
+
filter?: (typeof OSFilter)[keyof typeof OSFilter];
|
|
1552
1749
|
/** Zero-based offset for pagination. */
|
|
1553
1750
|
offset?: number;
|
|
1554
1751
|
}
|
|
@@ -1646,11 +1843,20 @@ declare class PixivClient {
|
|
|
1646
1843
|
readonly images: ImageResource;
|
|
1647
1844
|
private constructor();
|
|
1648
1845
|
/**
|
|
1649
|
-
* Numeric user ID of the authenticated account
|
|
1846
|
+
* Numeric user ID of the authenticated account.
|
|
1650
1847
|
*
|
|
1651
1848
|
* Available immediately after {@link PixivClient.of} resolves.
|
|
1849
|
+
* The pixiv OAuth endpoint returns the ID as a string; this getter
|
|
1850
|
+
* normalises it to `number` for consistency with resource method params
|
|
1851
|
+
* (e.g. `UserBookmarksIllustParams.userId`).
|
|
1852
|
+
*
|
|
1853
|
+
* @example
|
|
1854
|
+
* ```ts
|
|
1855
|
+
* const client = await PixivClient.of(refreshToken)
|
|
1856
|
+
* const bookmarks = await client.users.bookmarks.illusts({ userId: client.userId })
|
|
1857
|
+
* ```
|
|
1652
1858
|
*/
|
|
1653
|
-
get userId():
|
|
1859
|
+
get userId(): number;
|
|
1654
1860
|
/**
|
|
1655
1861
|
* Creates a PixivClient by refreshing the given token.
|
|
1656
1862
|
*
|
|
@@ -1661,4 +1867,4 @@ declare class PixivClient {
|
|
|
1661
1867
|
static of(refreshToken: string, options?: PixivClientOptions): Promise<PixivClient>;
|
|
1662
1868
|
}
|
|
1663
1869
|
|
|
1664
|
-
export {
|
|
1870
|
+
export { BookmarkRestrict, type ErrResult, FollowRestrict, type Frame, type HttpMethod, type IllustBookmarkAddParams, type IllustBookmarkDeleteParams, type IllustDetailParams, type IllustDetailResponse, type IllustListPage, type IllustRankingParams, type IllustRecommendedPage, type IllustRecommendedParams, type IllustRelatedParams, type IllustSearchParams, type IllustSeriesDetail, type IllustSeriesPage, type IllustSeriesParams, type ImageUrls, type MangaRecommendedPage, type MetaPages, type MetaSinglePage, type NovelBookmarkAddParams, type NovelBookmarkDeleteParams, type NovelDetailParams, type NovelDetailResponse, type NovelListPage, NovelRankingMode, type NovelRankingParams, type NovelRecommendedPage, type NovelRecommendedParams, type NovelRelatedParams, type NovelSearchParams, type NovelSeriesDetail, type NovelSeriesPage, type NovelSeriesParams, type NovelTextParams, OSFilter, type OkResult, type PagedResponse, PaginatedResultAsync, type ParsedNextUrl, type PixivApiErrorBody, PixivClient, type PixivClientOptions, type PixivError, PixivFetchError, type PixivIllustItem, type PixivNovelItem, type PixivUgoiraItem, type PixivUser, type PixivUserItem, type PixivUserPreviewItem, type PixivUserProfile, type PixivUserProfilePublicity, type PixivUserProfileWorkspace, type PrivacyPolicy, type ProfileImageUrls, RankingMode, type ResponseInterceptor, type ResponseRecord, type Result, ResultAsync, SearchDuration, SearchSort, SearchTarget, type Series, type Tag, type UgoiraMetadataResponse, type UserBookmarksIllustPage, type UserBookmarksIllustParams, type UserBookmarksNovelPage, type UserBookmarksNovelParams, type UserDetailParams, type UserDetailResponse, type UserFollowAddParams, type UserFollowDeleteParams, type UserFollowingPage, type UserFollowingParams, UserIllustType, type UserIllustsPage, type UserIllustsParams, type UserNovelsPage, type UserNovelsParams, type ZipUrls, apiError, authFailedError, err, failedPaginated, networkError, ok, parseNextUrl, rateLimitError };
|