narou 1.0.0 → 1.2.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.
Files changed (148) hide show
  1. package/README.md +7 -0
  2. package/dist/{chunk-RITMMCZE.js → chunk-3A5MHPWL.js} +1 -1
  3. package/dist/chunk-3A5MHPWL.js.map +1 -0
  4. package/dist/{chunk-6RIDVTFQ.js → chunk-5UDKQCPJ.js} +12 -2
  5. package/dist/chunk-5UDKQCPJ.js.map +1 -0
  6. package/dist/{chunk-UN3W2CT3.js → chunk-6BZWV4ZC.js} +6 -3
  7. package/dist/{chunk-UN3W2CT3.js.map → chunk-6BZWV4ZC.js.map} +1 -1
  8. package/dist/chunk-BQLSW236.js +117 -0
  9. package/dist/chunk-BQLSW236.js.map +1 -0
  10. package/dist/{chunk-DBCAWGIX.js → chunk-DEQICAN3.js} +2 -2
  11. package/dist/chunk-E2H3AJSQ.js +57 -0
  12. package/dist/chunk-E2H3AJSQ.js.map +1 -0
  13. package/dist/chunk-HOBLKBZ6.js +452 -0
  14. package/dist/chunk-HOBLKBZ6.js.map +1 -0
  15. package/dist/{chunk-TNDGN3EF.js → chunk-IPDEGCWU.js} +1 -1
  16. package/dist/chunk-IPDEGCWU.js.map +1 -0
  17. package/dist/{chunk-GAEL5UWA.js → chunk-LQLNWSWV.js} +4 -4
  18. package/dist/{chunk-GAEL5UWA.js.map → chunk-LQLNWSWV.js.map} +1 -1
  19. package/dist/{chunk-NP5NZV5Q.js → chunk-PLEM2AOH.js} +8 -5
  20. package/dist/chunk-PLEM2AOH.js.map +1 -0
  21. package/dist/chunk-RNHRR56W.js +25 -0
  22. package/dist/chunk-RNHRR56W.js.map +1 -0
  23. package/dist/{chunk-JMTNQTNC.js → chunk-VUZIISP2.js} +2 -3
  24. package/dist/chunk-VUZIISP2.js.map +1 -0
  25. package/dist/{chunk-XAUB42TO.js → chunk-VZVUANDN.js} +6 -4
  26. package/dist/chunk-VZVUANDN.js.map +1 -0
  27. package/dist/index.browser.cjs +245 -94
  28. package/dist/index.browser.cjs.map +1 -1
  29. package/dist/index.browser.d.cts +24 -9
  30. package/dist/index.browser.d.ts +24 -9
  31. package/dist/index.browser.js +16 -16
  32. package/dist/index.browser.js.map +1 -1
  33. package/dist/index.cjs +256 -103
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.common.cjs +241 -87
  36. package/dist/index.common.cjs.map +1 -1
  37. package/dist/index.common.d.cts +2 -2
  38. package/dist/index.common.d.ts +2 -2
  39. package/dist/index.common.js +11 -8
  40. package/dist/index.d.cts +15 -6
  41. package/dist/index.d.ts +15 -6
  42. package/dist/index.js +20 -20
  43. package/dist/index.js.map +1 -1
  44. package/dist/narou-DBa12V_l.d.ts +404 -0
  45. package/dist/narou-DCp4aGfA.d.cts +404 -0
  46. package/dist/narou-fetch.cjs +10 -5
  47. package/dist/narou-fetch.cjs.map +1 -1
  48. package/dist/narou-fetch.d.cts +4 -3
  49. package/dist/narou-fetch.d.ts +4 -3
  50. package/dist/narou-fetch.js +4 -4
  51. package/dist/narou-jsonp.cjs +5 -2
  52. package/dist/narou-jsonp.cjs.map +1 -1
  53. package/dist/narou-jsonp.d.cts +2 -2
  54. package/dist/narou-jsonp.d.ts +2 -2
  55. package/dist/narou-jsonp.js +4 -4
  56. package/dist/narou-ranking-results.d.cts +2 -2
  57. package/dist/narou-ranking-results.d.ts +2 -2
  58. package/dist/{narou-search-results-D_vbjc_I.d.cts → narou-search-results-C21hWrnL.d.cts} +30 -19
  59. package/dist/{narou-search-results-CvMcnYqe.d.ts → narou-search-results-DT0YdaBn.d.ts} +30 -19
  60. package/dist/narou-search-results.cjs.map +1 -1
  61. package/dist/narou-search-results.d.cts +1 -1
  62. package/dist/narou-search-results.d.ts +1 -1
  63. package/dist/narou-search-results.js +1 -1
  64. package/dist/narou.cjs +4 -1
  65. package/dist/narou.cjs.map +1 -1
  66. package/dist/narou.d.cts +2 -2
  67. package/dist/narou.d.ts +2 -2
  68. package/dist/narou.js +2 -2
  69. package/dist/params.cjs +12 -1
  70. package/dist/params.cjs.map +1 -1
  71. package/dist/params.d.cts +1 -1
  72. package/dist/params.d.ts +1 -1
  73. package/dist/params.js +3 -1
  74. package/dist/ranking-history.cjs +11 -3
  75. package/dist/ranking-history.cjs.map +1 -1
  76. package/dist/ranking-history.d.cts +12 -1
  77. package/dist/ranking-history.d.ts +12 -1
  78. package/dist/ranking-history.js +2 -1
  79. package/dist/ranking.cjs +201 -78
  80. package/dist/ranking.cjs.map +1 -1
  81. package/dist/ranking.d.cts +70 -9
  82. package/dist/ranking.d.ts +70 -9
  83. package/dist/ranking.js +4 -3
  84. package/dist/search-builder-r18.cjs +133 -60
  85. package/dist/search-builder-r18.cjs.map +1 -1
  86. package/dist/search-builder-r18.d.cts +19 -6
  87. package/dist/search-builder-r18.d.ts +19 -6
  88. package/dist/search-builder-r18.js +3 -3
  89. package/dist/search-builder.cjs +150 -70
  90. package/dist/search-builder.cjs.map +1 -1
  91. package/dist/search-builder.d.cts +2 -2
  92. package/dist/search-builder.d.ts +2 -2
  93. package/dist/search-builder.js +2 -2
  94. package/dist/user-search.cjs +37 -13
  95. package/dist/user-search.cjs.map +1 -1
  96. package/dist/user-search.d.cts +2 -2
  97. package/dist/user-search.d.ts +2 -2
  98. package/dist/user-search.js +3 -3
  99. package/dist/util/date.cjs +51 -0
  100. package/dist/util/date.cjs.map +1 -0
  101. package/dist/util/date.d.cts +21 -0
  102. package/dist/util/date.d.ts +21 -0
  103. package/dist/util/date.js +11 -0
  104. package/dist/util/date.js.map +1 -0
  105. package/dist/util/jsonp.cjs.map +1 -1
  106. package/dist/util/jsonp.d.cts +36 -0
  107. package/dist/util/jsonp.d.ts +36 -0
  108. package/dist/util/jsonp.js +1 -1
  109. package/dist/util/type.cjs.map +1 -1
  110. package/dist/util/type.d.cts +23 -0
  111. package/dist/util/type.d.ts +23 -0
  112. package/dist/util/unzipp.cjs +1 -2
  113. package/dist/util/unzipp.cjs.map +1 -1
  114. package/dist/util/unzipp.d.cts +9 -0
  115. package/dist/util/unzipp.d.ts +9 -0
  116. package/dist/util/unzipp.js +1 -1
  117. package/package.json +47 -46
  118. package/pnpm-lock.yaml +3041 -0
  119. package/src/index.browser.ts +21 -5
  120. package/src/index.ts +11 -2
  121. package/src/narou-fetch.ts +5 -2
  122. package/src/narou-jsonp.ts +1 -1
  123. package/src/narou-search-results.ts +2 -1
  124. package/src/narou.ts +4 -1
  125. package/src/params.ts +34 -18
  126. package/src/ranking-history.ts +13 -4
  127. package/src/ranking.ts +79 -15
  128. package/src/search-builder-r18.ts +17 -4
  129. package/src/search-builder.ts +203 -79
  130. package/src/util/date.ts +38 -0
  131. package/src/util/jsonp.ts +61 -6
  132. package/src/util/type.ts +23 -0
  133. package/src/util/unzipp.ts +9 -0
  134. package/dist/chunk-6RIDVTFQ.js.map +0 -1
  135. package/dist/chunk-JMTNQTNC.js.map +0 -1
  136. package/dist/chunk-NP5NZV5Q.js.map +0 -1
  137. package/dist/chunk-OJGRUQEQ.js +0 -372
  138. package/dist/chunk-OJGRUQEQ.js.map +0 -1
  139. package/dist/chunk-QQYQ4GQF.js +0 -83
  140. package/dist/chunk-QQYQ4GQF.js.map +0 -1
  141. package/dist/chunk-RITMMCZE.js.map +0 -1
  142. package/dist/chunk-TNDGN3EF.js.map +0 -1
  143. package/dist/chunk-XAUB42TO.js.map +0 -1
  144. package/dist/chunk-YJQXIVFD.js +0 -44
  145. package/dist/chunk-YJQXIVFD.js.map +0 -1
  146. package/dist/narou-CosGR0J9.d.cts +0 -298
  147. package/dist/narou-CutsOEgk.d.ts +0 -298
  148. /package/dist/{chunk-DBCAWGIX.js.map → chunk-DEQICAN3.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -18,12 +18,13 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  BigGenre: () => BigGenre,
24
24
  BigGenreNotation: () => BigGenreNotation,
25
25
  BooleanNumber: () => BooleanNumber,
26
26
  BuntaiParam: () => BuntaiParam,
27
+ DateParam: () => DateParam,
27
28
  End: () => End,
28
29
  Fields: () => Fields,
29
30
  Genre: () => Genre,
@@ -48,7 +49,7 @@ __export(src_exports, {
48
49
  StopParam: () => StopParam,
49
50
  UserFields: () => UserFields,
50
51
  UserOrder: () => UserOrder,
51
- default: () => src_default,
52
+ default: () => index_default,
52
53
  formatRankingHistory: () => formatRankingHistory,
53
54
  ranking: () => ranking,
54
55
  rankingHistory: () => rankingHistory,
@@ -56,7 +57,7 @@ __export(src_exports, {
56
57
  searchR18: () => searchR18,
57
58
  searchUser: () => searchUser
58
59
  });
59
- module.exports = __toCommonJS(src_exports);
60
+ module.exports = __toCommonJS(index_exports);
60
61
 
61
62
  // src/util/unzipp.ts
62
63
  var import_zlib = require("zlib");
@@ -72,8 +73,7 @@ async function unzipp(data) {
72
73
  throw decoder.decode(buffer);
73
74
  }
74
75
  } catch (e) {
75
- if (typeof e === "string")
76
- throw e;
76
+ if (typeof e === "string") throw e;
77
77
  throw decoder.decode(data);
78
78
  }
79
79
  }
@@ -169,7 +169,10 @@ var NarouNovel = class {
169
169
  * @see https://dev.syosetu.com/man/userapi/
170
170
  */
171
171
  async executeUserSearch(params) {
172
- return await this.execute(params, "https://api.syosetu.com/userapi/api/");
172
+ return new NarouSearchResults(
173
+ await this.execute(params, "https://api.syosetu.com/userapi/api/"),
174
+ params
175
+ );
173
176
  }
174
177
  };
175
178
 
@@ -188,14 +191,17 @@ var NarouNovelFetch = class extends NarouNovel {
188
191
  if (query.gzip === void 0) {
189
192
  query.gzip = 5;
190
193
  }
194
+ if (query.gzip === 0) {
195
+ delete query.gzip;
196
+ }
191
197
  const url = new URL(endpoint);
192
198
  Object.entries(query).forEach(([key, value]) => {
193
- if (value) {
199
+ if (value !== void 0) {
194
200
  url.searchParams.append(key, value.toString());
195
201
  }
196
202
  });
197
203
  const res = await (this.fetch ?? fetch)(url);
198
- if (query.gzip === 0) {
204
+ if (!query.gzip) {
199
205
  return await res.json();
200
206
  }
201
207
  const buffer = await res.arrayBuffer();
@@ -245,7 +251,7 @@ var NarouNovelJsonp = class extends NarouNovel {
245
251
  query.gzip = 0;
246
252
  const url = new URL(endpoint);
247
253
  Object.entries(query).forEach(([key, value]) => {
248
- if (value) {
254
+ if (value !== void 0) {
249
255
  url.searchParams.append(key, value.toString());
250
256
  }
251
257
  });
@@ -480,7 +486,9 @@ var Order = {
480
486
  /** 四半期ポイントの高い順 */
481
487
  QuarterPoint: "quarterpoint",
482
488
  /** 年間ポイントの高い順 */
483
- YearlyPoint: "yearlypoint"
489
+ YearlyPoint: "yearlypoint",
490
+ /** 初回掲載順 */
491
+ GeneralFirstUp: "generalfirstup"
484
492
  };
485
493
  var R18Site = {
486
494
  /** ノクターンノベルズ(男性向け) */
@@ -615,6 +623,13 @@ var NovelTypeParam = {
615
623
  /** 短編と完結済連載小説 */
616
624
  ShortAndRensai: "ter"
617
625
  };
626
+ var DateParam = {
627
+ ThisWeek: "thisweek",
628
+ LastWeek: "lastweek",
629
+ SevenDays: "sevenday",
630
+ ThisMonth: "thismonth",
631
+ LastMonth: "lastmonth"
632
+ };
618
633
  var UserOrder = {
619
634
  /** ユーザIDの新しい順 */
620
635
  New: "new",
@@ -635,14 +650,30 @@ var SearchBuilderBase = class {
635
650
  /**
636
651
  * constructor
637
652
  * @private
653
+ * @param params クエリパラメータ
654
+ * @param api NarouNovel インスタンス
638
655
  */
639
656
  constructor(params = {}, api) {
640
657
  this.params = params;
641
658
  this.api = api;
642
659
  }
660
+ /**
661
+ * 配列から重複を除去する
662
+ * @protected
663
+ * @static
664
+ * @param array 配列
665
+ * @returns 重複を除去した配列
666
+ */
643
667
  static distinct(array) {
644
668
  return Array.from(new Set(array));
645
669
  }
670
+ /**
671
+ * 配列をハイフン区切りの文字列に変換する
672
+ * @protected
673
+ * @static
674
+ * @param n 文字列または数値の配列、あるいは単一の文字列または数値
675
+ * @returns ハイフン区切りの文字列
676
+ */
646
677
  static array2string(n) {
647
678
  if (Array.isArray(n)) {
648
679
  return this.distinct(n).join("-");
@@ -651,44 +682,48 @@ var SearchBuilderBase = class {
651
682
  }
652
683
  }
653
684
  /**
654
- *
655
- * @return {SearchBuilder} this
685
+ * 取得件数を指定する (lim)
686
+ * @param num 取得件数 (1-500)
687
+ * @return {this}
656
688
  */
657
689
  limit(num) {
658
690
  this.set({ lim: num });
659
691
  return this;
660
692
  }
661
693
  /**
662
- *
663
- * @return {SearchBuilder} this
694
+ * 取得開始位置を指定する (st)
695
+ * @param num 取得開始位置 (1-)
696
+ * @return {this}
664
697
  */
665
698
  start(num) {
666
699
  this.set({ st: num });
667
700
  return this;
668
701
  }
669
702
  /**
670
- *
671
- * @return {SearchBuilder} this
703
+ * ページ番号と1ページあたりの件数で取得範囲を指定する
704
+ * @param no ページ番号 (0-)
705
+ * @param count 1ページあたりの件数 (デフォルト: 20)
706
+ * @return {this}
672
707
  */
673
708
  page(no, count2 = 20) {
674
709
  return this.limit(count2).start(no * count2);
675
710
  }
676
711
  /**
677
- * 出力順序を指定する。指定しない場合は新着順となります。
678
- * old 古い順
712
+ * 出力順序を指定する (order)
713
+ * 指定しない場合は新着順となります。
679
714
  * @param {TOrder} order 出力順序
680
- * @return {SearchBuilder} this
715
+ * @return {this}
681
716
  */
682
717
  order(order) {
683
718
  this.set({ order });
684
719
  return this;
685
720
  }
686
721
  /**
687
- * gzip圧縮する。
722
+ * gzip圧縮レベルを指定する (gzip)
688
723
  *
689
724
  * 転送量上限を減らすためにも推奨
690
725
  * @param {GzipLevel} level gzip圧縮レベル(1~5)
691
- * @return {SearchBuilder} this
726
+ * @return {this}
692
727
  */
693
728
  gzip(level) {
694
729
  this.set({ gzip: level });
@@ -696,8 +731,9 @@ var SearchBuilderBase = class {
696
731
  }
697
732
  /**
698
733
  * クエリパラメータをセットする
699
- * @private
700
- * @return {SearchBuilder} this
734
+ * @protected
735
+ * @param obj セットするパラメータ
736
+ * @return {this}
701
737
  */
702
738
  set(obj) {
703
739
  this.params = { ...this.params, ...obj };
@@ -705,6 +741,9 @@ var SearchBuilderBase = class {
705
741
  }
706
742
  /**
707
743
  * クエリパラメータを削除する
744
+ * @protected
745
+ * @param key 削除するパラメータのキー
746
+ * @returns {this}
708
747
  */
709
748
  unset(key) {
710
749
  delete this.params[key];
@@ -713,56 +752,65 @@ var SearchBuilderBase = class {
713
752
  };
714
753
  var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilderBase {
715
754
  /**
716
- * a
717
- * @return {SearchBuilder} this
755
+ * 検索語を指定します (word)。
756
+ * 半角または全角スペースで区切るとAND抽出になります。部分一致でHITします。
757
+ * @param word 検索語
758
+ * @return {this}
718
759
  */
719
760
  word(word) {
720
761
  this.set({ word });
721
762
  return this;
722
763
  }
723
764
  /**
724
- *
725
- * @return {SearchBuilder} this
765
+ * 除外したい単語を指定します (notword)。
766
+ * スペースで区切ることにより除外する単語を増やせます。部分一致で除外されます。
767
+ * @param word 除外語
768
+ * @return {this}
726
769
  */
727
770
  notWord(word) {
728
771
  this.set({ notword: word });
729
772
  return this;
730
773
  }
731
774
  /**
732
- *
733
- * @return {SearchBuilder} this
775
+ * 検索対象を作品名に限定するかどうかを指定します (title)。
776
+ * @param bool trueの場合、作品名を検索対象とする (デフォルト: true)
777
+ * @return {this}
734
778
  */
735
779
  byTitle(bool = true) {
736
780
  this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
737
781
  return this;
738
782
  }
739
783
  /**
740
- *
741
- * @return {SearchBuilder} this
784
+ * 検索対象をあらすじに限定するかどうかを指定します (ex)。
785
+ * @param bool trueの場合、あらすじを検索対象とする (デフォルト: true)
786
+ * @return {this}
742
787
  */
743
788
  byOutline(bool = true) {
744
789
  this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
745
790
  return this;
746
791
  }
747
792
  /**
748
- *
749
- * @return {SearchBuilder} this
793
+ * 検索対象をキーワードに限定するかどうかを指定します (keyword)。
794
+ * @param bool trueの場合、キーワードを検索対象とする (デフォルト: true)
795
+ * @return {this}
750
796
  */
751
797
  byKeyword(bool = true) {
752
798
  this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
753
799
  return this;
754
800
  }
755
801
  /**
756
- *
757
- * @return {SearchBuilder} this
802
+ * 検索対象を作者名に限定するかどうかを指定します (wname)。
803
+ * @param bool trueの場合、作者名を検索対象とする (デフォルト: true)
804
+ * @return {this}
758
805
  */
759
806
  byAuthor(bool = true) {
760
807
  this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
761
808
  return this;
762
809
  }
763
810
  /**
764
- *
765
- * @return {SearchBuilder} this
811
+ * ボーイズラブ作品を抽出または除外します (isbl/notbl)。
812
+ * @param bool trueの場合、ボーイズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
813
+ * @return {this}
766
814
  */
767
815
  isBL(bool = true) {
768
816
  if (bool) {
@@ -773,8 +821,9 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
773
821
  return this;
774
822
  }
775
823
  /**
776
- *
777
- * @return {SearchBuilder} this
824
+ * ガールズラブ作品を抽出または除外します (isgl/notgl)。
825
+ * @param bool trueの場合、ガールズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
826
+ * @return {this}
778
827
  */
779
828
  isGL(bool = true) {
780
829
  if (bool) {
@@ -785,8 +834,9 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
785
834
  return this;
786
835
  }
787
836
  /**
788
- *
789
- * @return {SearchBuilder} this
837
+ * 残酷な描写あり作品を抽出または除外します (iszankoku/notzankoku)。
838
+ * @param bool trueの場合、残酷な描写あり作品を抽出する (デフォルト: true)。falseの場合、除外する。
839
+ * @return {this}
790
840
  */
791
841
  isZankoku(bool = true) {
792
842
  if (bool) {
@@ -797,8 +847,9 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
797
847
  return this;
798
848
  }
799
849
  /**
800
- *
801
- * @return {SearchBuilder} this
850
+ * 異世界転生作品を抽出または除外します (istensei/nottensei)。
851
+ * @param bool trueの場合、異世界転生作品を抽出する (デフォルト: true)。falseの場合、除外する。
852
+ * @return {this}
802
853
  */
803
854
  isTensei(bool = true) {
804
855
  if (bool) {
@@ -809,8 +860,9 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
809
860
  return this;
810
861
  }
811
862
  /**
812
- *
813
- * @return {SearchBuilder} this
863
+ * 異世界転移作品を抽出または除外します (istenni/nottenni)。
864
+ * @param bool trueの場合、異世界転移作品を抽出する (デフォルト: true)。falseの場合、除外する。
865
+ * @return {this}
814
866
  */
815
867
  isTenni(bool = true) {
816
868
  if (bool) {
@@ -821,16 +873,18 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
821
873
  return this;
822
874
  }
823
875
  /**
824
- *
825
- * @return {SearchBuilder} this
876
+ * 異世界転生または異世界転移作品を抽出します (istt)。
877
+ * @return {this}
826
878
  */
827
879
  isTT() {
828
880
  this.set({ istt: BooleanNumber.True });
829
881
  return this;
830
882
  }
831
883
  /**
832
- *
833
- * @return {SearchBuilder} this
884
+ * 抽出する作品の文字数を指定します (length)。
885
+ * 範囲指定する場合は、最小文字数と最大文字数をハイフン(-)記号で区切ってください。
886
+ * @param length 文字数、または[最小文字数, 最大文字数]
887
+ * @return {this}
834
888
  */
835
889
  length(length) {
836
890
  this.set({ length: _NovelSearchBuilderBase.array2string(length) });
@@ -847,59 +901,66 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
847
901
  return this;
848
902
  }
849
903
  /**
850
- *
851
- * @return {SearchBuilder} this
904
+ * 抽出する作品の挿絵数を指定します (sasie)。
905
+ * @param num 挿絵数、または[最小挿絵数, 最大挿絵数]
906
+ * @return {this}
852
907
  */
853
908
  sasie(num) {
854
909
  this.set({ sasie: _NovelSearchBuilderBase.array2string(num) });
855
910
  return this;
856
911
  }
857
912
  /**
858
- *
859
- * @return {SearchBuilder} this
913
+ * 抽出する作品の予想読了時間を分単位で指定します (time)。
914
+ * @param num 読了時間(分)、または[最小読了時間, 最大読了時間]
915
+ * @return {this}
860
916
  */
861
917
  time(num) {
862
918
  this.set({ time: _NovelSearchBuilderBase.array2string(num) });
863
919
  return this;
864
920
  }
865
921
  /**
866
- *
867
- * @return {SearchBuilder} this
922
+ * Nコードを指定して取得します (ncode)。
923
+ * @param ncodes Nコード、またはNコードの配列
924
+ * @return {this}
868
925
  */
869
926
  ncode(ncodes) {
870
927
  this.set({ ncode: _NovelSearchBuilderBase.array2string(ncodes) });
871
928
  return this;
872
929
  }
873
930
  /**
874
- *
875
- * @return {SearchBuilder} this
931
+ * 抽出する小説タイプを指定します (type)。
932
+ * @param type 小説タイプ (t: 短編, r: 連載中, er: 完結済連載小説, ter: 短編と完結済連載小説, re: 連載中と完結済連載小説)
933
+ * @return {this}
876
934
  */
877
935
  type(type) {
878
936
  this.set({ type });
879
937
  return this;
880
938
  }
881
939
  /**
882
- *
883
- * @return {SearchBuilder} this
940
+ * 抽出する作品の文体を指定します (buntai)。
941
+ * 複数指定する場合はハイフン(-)で区切ってください。
942
+ * @param buntai 文体コード、または文体コードの配列
943
+ * @return {this}
884
944
  */
885
945
  buntai(buntai) {
886
946
  this.set({ buntai: _NovelSearchBuilderBase.array2string(buntai) });
887
947
  return this;
888
948
  }
889
949
  /**
890
- *
891
- * @return {SearchBuilder} this
950
+ * 連載停止中作品に関する指定をします (stop)。
951
+ * @param bool trueの場合、長期連載停止中のみ取得する (デフォルト: true)。falseの場合、長期連載停止中を除外する。
952
+ * @return {this}
892
953
  */
893
954
  isStop(bool = true) {
894
955
  this.set({ stop: bool ? StopParam.Stopping : StopParam.NoStopping });
895
956
  return this;
896
957
  }
897
958
  /**
898
- *
899
- * @return {SearchBuilder} this
959
+ * ピックアップ作品のみを取得します (ispickup)。
960
+ * @return {this}
900
961
  */
901
- isPickup(bool = true) {
902
- this.set({ ispickup: bool ? BooleanNumber.True : BooleanNumber.False });
962
+ isPickup() {
963
+ this.set({ ispickup: BooleanNumber.True });
903
964
  return this;
904
965
  }
905
966
  lastUpdate(x, y) {
@@ -908,7 +969,7 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
908
969
  date = x;
909
970
  } else if (x instanceof Date && y instanceof Date) {
910
971
  date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(
911
- x.getTime() / 1e3
972
+ y.getTime() / 1e3
912
973
  )}`;
913
974
  } else {
914
975
  date = `${x}-${y}`;
@@ -916,6 +977,20 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
916
977
  this.set({ lastup: date });
917
978
  return this;
918
979
  }
980
+ lastNovelUpdate(x, y) {
981
+ let date;
982
+ if (typeof x == "string") {
983
+ date = x;
984
+ } else if (x instanceof Date && y instanceof Date) {
985
+ date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(
986
+ y.getTime() / 1e3
987
+ )}`;
988
+ } else {
989
+ date = `${x}-${y}`;
990
+ }
991
+ this.set({ lastupdate: date });
992
+ return this;
993
+ }
919
994
  /**
920
995
  * なろう小説APIへの検索リクエストを実行する
921
996
  * @returns {Promise<NarouSearchResults>} 検索結果
@@ -926,48 +1001,59 @@ var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilder
926
1001
  };
927
1002
  var SearchBuilder = class _SearchBuilder extends NovelSearchBuilderBase {
928
1003
  /**
929
- *
930
- * @return {SearchBuilder} this
1004
+ * 大ジャンルを指定して取得します (biggenre)。
1005
+ * 複数指定する場合はハイフン(-)で区切ってください。
1006
+ * @param genre 大ジャンルコード、または大ジャンルコードの配列
1007
+ * @return {this}
931
1008
  */
932
1009
  bigGenre(genre) {
933
1010
  this.set({ biggenre: _SearchBuilder.array2string(genre) });
934
1011
  return this;
935
1012
  }
936
1013
  /**
937
- *
938
- * @return {SearchBuilder} this
1014
+ * 除外したい大ジャンルを指定します (notbiggenre)。
1015
+ * 複数指定する場合はハイフン(-)で区切ってください。
1016
+ * @param genre 除外する大ジャンルコード、または大ジャンルコードの配列
1017
+ * @return {this}
939
1018
  */
940
1019
  notBigGenre(genre) {
941
1020
  this.set({ notbiggenre: _SearchBuilder.array2string(genre) });
942
1021
  return this;
943
1022
  }
944
1023
  /**
945
- *
946
- * @return {SearchBuilder} this
1024
+ * ジャンルを指定して取得します (genre)。
1025
+ * 複数指定する場合はハイフン(-)で区切ってください。
1026
+ * @param genre ジャンルコード、またはジャンルコードの配列
1027
+ * @return {this}
947
1028
  */
948
1029
  genre(genre) {
949
1030
  this.set({ genre: _SearchBuilder.array2string(genre) });
950
1031
  return this;
951
1032
  }
952
1033
  /**
953
- *
954
- * @return {SearchBuilder} this
1034
+ * 除外したいジャンルを指定します (notgenre)。
1035
+ * 複数指定する場合はハイフン(-)で区切ってください。
1036
+ * @param genre 除外するジャンルコード、またはジャンルコードの配列
1037
+ * @return {this}
955
1038
  */
956
1039
  notGenre(genre) {
957
1040
  this.set({ notgenre: _SearchBuilder.array2string(genre) });
958
1041
  return this;
959
1042
  }
960
1043
  /**
961
- *
962
- * @return {SearchBuilder} this
1044
+ * ユーザIDを指定して取得します (userid)。
1045
+ * 複数指定する場合はハイフン(-)で区切ってください。
1046
+ * @param ids ユーザID、またはユーザIDの配列
1047
+ * @return {this}
963
1048
  */
964
1049
  userId(ids) {
965
1050
  this.set({ userid: _SearchBuilder.array2string(ids) });
966
1051
  return this;
967
1052
  }
968
1053
  /**
969
- *
970
- * @return {SearchBuilder} this
1054
+ * R15作品を抽出または除外します (isr15/notr15)。
1055
+ * @param bool trueの場合、R15作品を抽出する (デフォルト: true)。falseの場合、除外する。
1056
+ * @return {this}
971
1057
  */
972
1058
  isR15(bool = true) {
973
1059
  if (bool) {
@@ -978,37 +1064,82 @@ var SearchBuilder = class _SearchBuilder extends NovelSearchBuilderBase {
978
1064
  return this;
979
1065
  }
980
1066
  /**
981
- *
982
- * @return {SearchBuilder} this
1067
+ * 出力する項目を個別に指定します (of)。
1068
+ * 未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
1069
+ * 複数項目を出力する場合はハイフン(-)記号で区切ってください。
1070
+ * @param fields 出力するフィールド名、またはフィールド名の配列
1071
+ * @return {SearchBuilder<SearchResultFields<TFields>, TOpt>} 型が更新されたビルダー
983
1072
  */
984
1073
  fields(fields) {
985
1074
  this.set({ of: _SearchBuilder.array2string(fields) });
986
1075
  return this;
987
1076
  }
1077
+ /**
1078
+ * 出力オプション項目を指定します (opt)。
1079
+ * 複数項目を出力する場合はハイフン(-)記号で区切ってください。
1080
+ * @param option 出力するオプションフィールド名、またはオプションフィールド名の配列
1081
+ * @return {SearchBuilder<T, SearchResultOptionalFields<TFields>>} 型が更新されたビルダー
1082
+ */
988
1083
  opt(option) {
989
1084
  this.set({ opt: _SearchBuilder.array2string(option) });
990
1085
  return this;
991
1086
  }
992
1087
  };
993
1088
 
1089
+ // src/util/date.ts
1090
+ function parseDate(dateStr) {
1091
+ const year = parseInt(dateStr.substring(0, 4), 10);
1092
+ const month = parseInt(dateStr.substring(4, 6), 10) - 1;
1093
+ const day = parseInt(dateStr.substring(6, 8), 10);
1094
+ return new Date(year, month, day, 0, 0, 0, 0);
1095
+ }
1096
+ function formatDate(date) {
1097
+ const year = date.getFullYear();
1098
+ const month = String(date.getMonth() + 1).padStart(2, "0");
1099
+ const day = String(date.getDate()).padStart(2, "0");
1100
+ return `${year}${month}${day}`;
1101
+ }
1102
+ function addDays(date, days) {
1103
+ const result = new Date(date);
1104
+ result.setDate(result.getDate() + days);
1105
+ return result;
1106
+ }
1107
+
994
1108
  // src/ranking.ts
995
- var import_date_fns = require("date-fns");
996
- var dateFormat = "yyyyMMdd";
997
1109
  var RankingBuilder = class {
998
1110
  /**
999
1111
  * constructor
1112
+ * @param params - 初期クエリパラメータ
1113
+ * @param api - API実行クラスのインスタンス
1000
1114
  * @private
1001
1115
  */
1002
1116
  constructor(params = {}, api) {
1003
1117
  this.params = params;
1004
1118
  this.api = api;
1005
- this.date$ = (0, import_date_fns.addDays)(Date.now(), -1);
1119
+ this.date$ = addDays(/* @__PURE__ */ new Date(), -1);
1006
1120
  this.type$ = RankingType.Daily;
1007
1121
  }
1122
+ /**
1123
+ * ランキング集計対象の日付を指定します。
1124
+ *
1125
+ * - 日間: 任意の日付
1126
+ * - 週間: 火曜日の日付
1127
+ * - 月間・四半期: 1日の日付
1128
+ *
1129
+ * @param date 集計対象の日付
1130
+ * @returns {RankingBuilder} this
1131
+ * @see https://dev.syosetu.com/man/rankapi/
1132
+ */
1008
1133
  date(date) {
1009
1134
  this.date$ = date;
1010
1135
  return this;
1011
1136
  }
1137
+ /**
1138
+ * ランキング種別を指定します。
1139
+ * @param type ランキング種別
1140
+ * @returns {RankingBuilder} this
1141
+ * @see https://dev.syosetu.com/man/rankapi/
1142
+ */
1012
1143
  type(type) {
1013
1144
  this.type$ = type;
1014
1145
  return this;
@@ -1025,23 +1156,36 @@ var RankingBuilder = class {
1025
1156
  return this;
1026
1157
  }
1027
1158
  /**
1028
- * クエリパラメータをセットする
1159
+ * クエリパラメータを内部的にセットします。
1160
+ * @param obj - セットするパラメータオブジェクト
1161
+ * @returns {RankingBuilder} this
1029
1162
  * @private
1030
- * @return {RankingBuilder} this
1031
1163
  */
1032
1164
  set(obj) {
1033
1165
  Object.assign(this.params, obj);
1034
1166
  return this;
1035
1167
  }
1036
1168
  /**
1037
- * なろう小説APIへのリクエストを実行する
1038
- * @returns ランキング
1169
+ * 設定されたパラメータに基づき、なろう小説ランキングAPIへのリクエストを実行します。
1170
+ *
1171
+ * 返される結果には、Nコード、ポイント、順位が含まれます。
1172
+ * @returns {Promise<NarouRankingResult[]>} ランキング結果の配列
1173
+ * @see https://dev.syosetu.com/man/rankapi/#output
1039
1174
  */
1040
1175
  execute() {
1041
- const date = (0, import_date_fns.format)(this.date$, dateFormat);
1176
+ const date = formatDate(this.date$);
1042
1177
  this.set({ rtype: `${date}-${this.type$}` });
1043
1178
  return this.api.executeRanking(this.params);
1044
1179
  }
1180
+ /**
1181
+ * ランキングAPIを実行し、取得したNコードを元になろう小説APIで詳細情報を取得して結合します。
1182
+ *
1183
+ * @template TFields - 取得する小説情報のフィールド型
1184
+ * @template TOpt - オプショナルな取得フィールドの型
1185
+ * @param fields - 取得するフィールドの配列 (省略時はデフォルトフィールド)
1186
+ * @param opt - オプショナルな取得フィールド (`weekly` など)
1187
+ * @returns {Promise<RankingResult<SearchResultFields<TFields>>[]>} 詳細情報を含むランキング結果の配列
1188
+ */
1045
1189
  async executeWithFields(fields = [], opt) {
1046
1190
  const ranking2 = await this.execute();
1047
1191
  const fields$ = Array.isArray(fields) ? fields.length == 0 ? [] : [...fields, Fields.ncode] : [fields, Fields.ncode];
@@ -1063,12 +1207,10 @@ var RankingBuilder = class {
1063
1207
  };
1064
1208
 
1065
1209
  // src/ranking-history.ts
1066
- var import_date_fns2 = require("date-fns");
1067
- var dateFormat2 = "yyyyMMdd";
1068
1210
  function formatRankingHistory(rankin) {
1069
1211
  const { rtype, pt, rank } = rankin;
1070
1212
  const [_date, _type] = rtype.split("-");
1071
- const date = (0, import_date_fns2.parse)(_date, dateFormat2, /* @__PURE__ */ new Date());
1213
+ const date = parseDate(_date);
1072
1214
  const type = _type;
1073
1215
  return { type, date, pt, rank };
1074
1216
  }
@@ -1083,26 +1225,39 @@ var SearchBuilderR18 = class extends NovelSearchBuilderBase {
1083
1225
  execute() {
1084
1226
  return this.api.executeNovel18(this.params);
1085
1227
  }
1228
+ /**
1229
+ * 抽出するR18サイトを指定します (nocgenre)。
1230
+ * @param sites R18サイトコード、またはR18サイトコードの配列 (1: ノクターンノベルズ, 2: ムーンライトノベルズ(男性向け), 3: ムーンライトノベルズ(BL), 4: ミッドナイトノベルズ)
1231
+ * @return {this}
1232
+ */
1086
1233
  r18Site(sites) {
1087
1234
  this.set({ nocgenre: NovelSearchBuilderBase.array2string(sites) });
1088
1235
  return this;
1089
1236
  }
1090
1237
  /**
1091
- *
1092
- * @return {SearchBuilder} this
1238
+ * X-IDを指定して取得します (xid)。
1239
+ * @param ids X-ID、またはX-IDの配列
1240
+ * @return {this}
1093
1241
  */
1094
1242
  xid(ids) {
1095
1243
  this.set({ xid: NovelSearchBuilderBase.array2string(ids) });
1096
1244
  return this;
1097
1245
  }
1098
1246
  /**
1099
- *
1100
- * @return {SearchBuilder} this
1247
+ * 出力する項目を個別に指定します (of)。
1248
+ * 未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
1249
+ * @param fields 出力するR18フィールド名、またはR18フィールド名の配列
1250
+ * @return {SearchBuilderR18<SearchResultR18Fields<R18Fields>>} 型が更新されたビルダー
1101
1251
  */
1102
1252
  fields(fields) {
1103
1253
  this.set({ of: NovelSearchBuilderBase.array2string(fields) });
1104
1254
  return this;
1105
1255
  }
1256
+ /**
1257
+ * 出力オプション項目を指定します (opt)。
1258
+ * @param option 出力するオプションフィールド名、またはオプションフィールド名の配列
1259
+ * @return {SearchBuilderR18<T, SearchResultOptionalFields<TFields>>} 型が更新されたビルダー
1260
+ */
1106
1261
  opt(option) {
1107
1262
  this.set({ opt: NovelSearchBuilderBase.array2string(option) });
1108
1263
  return this;
@@ -1199,20 +1354,17 @@ var UserSearchBuilder = class _UserSearchBuilder extends SearchBuilderBase {
1199
1354
  var narouNovelFetch = new NarouNovelFetch();
1200
1355
  function search(word = "", api = narouNovelFetch) {
1201
1356
  const builder = new SearchBuilder({}, api);
1202
- if (word != "")
1203
- builder.word(word);
1357
+ if (word != "") builder.word(word);
1204
1358
  return builder;
1205
1359
  }
1206
1360
  function searchR18(word = "", api = narouNovelFetch) {
1207
1361
  const builder = new SearchBuilderR18({}, api);
1208
- if (word != "")
1209
- builder.word(word);
1362
+ if (word != "") builder.word(word);
1210
1363
  return builder;
1211
1364
  }
1212
1365
  function searchUser(word = "", api = narouNovelFetch) {
1213
1366
  const builder = new UserSearchBuilder({}, api);
1214
- if (word != "")
1215
- builder.word(word);
1367
+ if (word != "") builder.word(word);
1216
1368
  return builder;
1217
1369
  }
1218
1370
  function ranking(api = narouNovelFetch) {
@@ -1227,7 +1379,7 @@ async function rankingHistory(ncode, api = narouNovelFetch) {
1227
1379
  throw new Error(result);
1228
1380
  }
1229
1381
  }
1230
- var src_default = {
1382
+ var index_default = {
1231
1383
  search,
1232
1384
  searchR18,
1233
1385
  searchUser,
@@ -1240,6 +1392,7 @@ var src_default = {
1240
1392
  BigGenreNotation,
1241
1393
  BooleanNumber,
1242
1394
  BuntaiParam,
1395
+ DateParam,
1243
1396
  End,
1244
1397
  Fields,
1245
1398
  Genre,