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
@@ -17,6 +17,7 @@ import type {
17
17
  GzipLevel,
18
18
  OptionalFields,
19
19
  ParamsBaseWithOrder,
20
+ DateParam,
20
21
  } from "./params.js";
21
22
  import { BooleanNumber, StopParam } from "./params.js";
22
23
  import type { Join } from "./util/type.js";
@@ -28,21 +29,37 @@ export type DefaultSearchResultFields = keyof Omit<
28
29
 
29
30
  export abstract class SearchBuilderBase<
30
31
  TParams extends ParamsBaseWithOrder<TOrder>,
31
- TOrder extends string
32
+ TOrder extends string,
32
33
  > {
33
34
  /**
34
35
  * constructor
35
36
  * @private
37
+ * @param params クエリパラメータ
38
+ * @param api NarouNovel インスタンス
36
39
  */
37
40
  constructor(
38
41
  protected params: TParams = {} as TParams,
39
42
  protected api: NarouNovel
40
- ) { }
43
+ ) {}
41
44
 
45
+ /**
46
+ * 配列から重複を除去する
47
+ * @protected
48
+ * @static
49
+ * @param array 配列
50
+ * @returns 重複を除去した配列
51
+ */
42
52
  protected static distinct<T>(array: readonly T[]): T[] {
43
53
  return Array.from(new Set(array));
44
54
  }
45
55
 
56
+ /**
57
+ * 配列をハイフン区切りの文字列に変換する
58
+ * @protected
59
+ * @static
60
+ * @param n 文字列または数値の配列、あるいは単一の文字列または数値
61
+ * @returns ハイフン区切りの文字列
62
+ */
46
63
  protected static array2string<T extends string | number>(
47
64
  n: T | readonly T[]
48
65
  ): Join<T> {
@@ -54,8 +71,9 @@ export abstract class SearchBuilderBase<
54
71
  }
55
72
 
56
73
  /**
57
- *
58
- * @return {SearchBuilder} this
74
+ * 取得件数を指定する (lim)
75
+ * @param num 取得件数 (1-500)
76
+ * @return {this}
59
77
  */
60
78
  limit(num: number): this {
61
79
  this.set({ lim: num } as TParams);
@@ -63,8 +81,9 @@ export abstract class SearchBuilderBase<
63
81
  }
64
82
 
65
83
  /**
66
- *
67
- * @return {SearchBuilder} this
84
+ * 取得開始位置を指定する (st)
85
+ * @param num 取得開始位置 (1-)
86
+ * @return {this}
68
87
  */
69
88
  start(num: number): this {
70
89
  this.set({ st: num } as TParams);
@@ -72,18 +91,20 @@ export abstract class SearchBuilderBase<
72
91
  }
73
92
 
74
93
  /**
75
- *
76
- * @return {SearchBuilder} this
94
+ * ページ番号と1ページあたりの件数で取得範囲を指定する
95
+ * @param no ページ番号 (0-)
96
+ * @param count 1ページあたりの件数 (デフォルト: 20)
97
+ * @return {this}
77
98
  */
78
99
  page(no: number, count = 20): this {
79
100
  return this.limit(count).start(no * count);
80
101
  }
81
102
 
82
103
  /**
83
- * 出力順序を指定する。指定しない場合は新着順となります。
84
- * old 古い順
104
+ * 出力順序を指定する (order)
105
+ * 指定しない場合は新着順となります。
85
106
  * @param {TOrder} order 出力順序
86
- * @return {SearchBuilder} this
107
+ * @return {this}
87
108
  */
88
109
  order(order: TOrder): this {
89
110
  this.set({ order: order } as TParams);
@@ -91,11 +112,11 @@ export abstract class SearchBuilderBase<
91
112
  }
92
113
 
93
114
  /**
94
- * gzip圧縮する。
115
+ * gzip圧縮レベルを指定する (gzip)
95
116
  *
96
117
  * 転送量上限を減らすためにも推奨
97
118
  * @param {GzipLevel} level gzip圧縮レベル(1~5)
98
- * @return {SearchBuilder} this
119
+ * @return {this}
99
120
  */
100
121
  gzip(level: GzipLevel): this {
101
122
  this.set({ gzip: level } as TParams);
@@ -104,8 +125,9 @@ export abstract class SearchBuilderBase<
104
125
 
105
126
  /**
106
127
  * クエリパラメータをセットする
107
- * @private
108
- * @return {SearchBuilder} this
128
+ * @protected
129
+ * @param obj セットするパラメータ
130
+ * @return {this}
109
131
  */
110
132
  protected set(obj: TParams): this {
111
133
  this.params = { ...this.params, ...obj };
@@ -114,6 +136,9 @@ export abstract class SearchBuilderBase<
114
136
 
115
137
  /**
116
138
  * クエリパラメータを削除する
139
+ * @protected
140
+ * @param key 削除するパラメータのキー
141
+ * @returns {this}
117
142
  */
118
143
  protected unset(key: keyof TParams): this {
119
144
  delete this.params[key];
@@ -122,11 +147,13 @@ export abstract class SearchBuilderBase<
122
147
  }
123
148
 
124
149
  export abstract class NovelSearchBuilderBase<
125
- T extends SearchResultFieldNames
150
+ T extends SearchResultFieldNames,
126
151
  > extends SearchBuilderBase<SearchParams, Order> {
127
152
  /**
128
- * a
129
- * @return {SearchBuilder} this
153
+ * 検索語を指定します (word)。
154
+ * 半角または全角スペースで区切るとAND抽出になります。部分一致でHITします。
155
+ * @param word 検索語
156
+ * @return {this}
130
157
  */
131
158
  word(word: string): this {
132
159
  this.set({ word: word });
@@ -134,8 +161,10 @@ export abstract class NovelSearchBuilderBase<
134
161
  }
135
162
 
136
163
  /**
137
- *
138
- * @return {SearchBuilder} this
164
+ * 除外したい単語を指定します (notword)。
165
+ * スペースで区切ることにより除外する単語を増やせます。部分一致で除外されます。
166
+ * @param word 除外語
167
+ * @return {this}
139
168
  */
140
169
  notWord(word: string): this {
141
170
  this.set({ notword: word });
@@ -143,8 +172,9 @@ export abstract class NovelSearchBuilderBase<
143
172
  }
144
173
 
145
174
  /**
146
- *
147
- * @return {SearchBuilder} this
175
+ * 検索対象を作品名に限定するかどうかを指定します (title)。
176
+ * @param bool trueの場合、作品名を検索対象とする (デフォルト: true)
177
+ * @return {this}
148
178
  */
149
179
  byTitle(bool = true): this {
150
180
  this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
@@ -152,8 +182,9 @@ export abstract class NovelSearchBuilderBase<
152
182
  }
153
183
 
154
184
  /**
155
- *
156
- * @return {SearchBuilder} this
185
+ * 検索対象をあらすじに限定するかどうかを指定します (ex)。
186
+ * @param bool trueの場合、あらすじを検索対象とする (デフォルト: true)
187
+ * @return {this}
157
188
  */
158
189
  byOutline(bool = true): this {
159
190
  this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
@@ -161,8 +192,9 @@ export abstract class NovelSearchBuilderBase<
161
192
  }
162
193
 
163
194
  /**
164
- *
165
- * @return {SearchBuilder} this
195
+ * 検索対象をキーワードに限定するかどうかを指定します (keyword)。
196
+ * @param bool trueの場合、キーワードを検索対象とする (デフォルト: true)
197
+ * @return {this}
166
198
  */
167
199
  byKeyword(bool = true): this {
168
200
  this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
@@ -170,8 +202,9 @@ export abstract class NovelSearchBuilderBase<
170
202
  }
171
203
 
172
204
  /**
173
- *
174
- * @return {SearchBuilder} this
205
+ * 検索対象を作者名に限定するかどうかを指定します (wname)。
206
+ * @param bool trueの場合、作者名を検索対象とする (デフォルト: true)
207
+ * @return {this}
175
208
  */
176
209
  byAuthor(bool = true): this {
177
210
  this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
@@ -179,8 +212,9 @@ export abstract class NovelSearchBuilderBase<
179
212
  }
180
213
 
181
214
  /**
182
- *
183
- * @return {SearchBuilder} this
215
+ * ボーイズラブ作品を抽出または除外します (isbl/notbl)。
216
+ * @param bool trueの場合、ボーイズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
217
+ * @return {this}
184
218
  */
185
219
  isBL(bool = true): this {
186
220
  if (bool) {
@@ -192,8 +226,9 @@ export abstract class NovelSearchBuilderBase<
192
226
  }
193
227
 
194
228
  /**
195
- *
196
- * @return {SearchBuilder} this
229
+ * ガールズラブ作品を抽出または除外します (isgl/notgl)。
230
+ * @param bool trueの場合、ガールズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
231
+ * @return {this}
197
232
  */
198
233
  isGL(bool = true): this {
199
234
  if (bool) {
@@ -205,8 +240,9 @@ export abstract class NovelSearchBuilderBase<
205
240
  }
206
241
 
207
242
  /**
208
- *
209
- * @return {SearchBuilder} this
243
+ * 残酷な描写あり作品を抽出または除外します (iszankoku/notzankoku)。
244
+ * @param bool trueの場合、残酷な描写あり作品を抽出する (デフォルト: true)。falseの場合、除外する。
245
+ * @return {this}
210
246
  */
211
247
  isZankoku(bool = true): this {
212
248
  if (bool) {
@@ -218,8 +254,9 @@ export abstract class NovelSearchBuilderBase<
218
254
  }
219
255
 
220
256
  /**
221
- *
222
- * @return {SearchBuilder} this
257
+ * 異世界転生作品を抽出または除外します (istensei/nottensei)。
258
+ * @param bool trueの場合、異世界転生作品を抽出する (デフォルト: true)。falseの場合、除外する。
259
+ * @return {this}
223
260
  */
224
261
  isTensei(bool = true): this {
225
262
  if (bool) {
@@ -231,8 +268,9 @@ export abstract class NovelSearchBuilderBase<
231
268
  }
232
269
 
233
270
  /**
234
- *
235
- * @return {SearchBuilder} this
271
+ * 異世界転移作品を抽出または除外します (istenni/nottenni)。
272
+ * @param bool trueの場合、異世界転移作品を抽出する (デフォルト: true)。falseの場合、除外する。
273
+ * @return {this}
236
274
  */
237
275
  isTenni(bool = true): this {
238
276
  if (bool) {
@@ -244,8 +282,8 @@ export abstract class NovelSearchBuilderBase<
244
282
  }
245
283
 
246
284
  /**
247
- *
248
- * @return {SearchBuilder} this
285
+ * 異世界転生または異世界転移作品を抽出します (istt)。
286
+ * @return {this}
249
287
  */
250
288
  isTT(): this {
251
289
  this.set({ istt: BooleanNumber.True });
@@ -253,8 +291,10 @@ export abstract class NovelSearchBuilderBase<
253
291
  }
254
292
 
255
293
  /**
256
- *
257
- * @return {SearchBuilder} this
294
+ * 抽出する作品の文字数を指定します (length)。
295
+ * 範囲指定する場合は、最小文字数と最大文字数をハイフン(-)記号で区切ってください。
296
+ * @param length 文字数、または[最小文字数, 最大文字数]
297
+ * @return {this}
258
298
  */
259
299
  length(length: number | readonly number[]): this {
260
300
  this.set({ length: NovelSearchBuilderBase.array2string(length) });
@@ -262,10 +302,17 @@ export abstract class NovelSearchBuilderBase<
262
302
  }
263
303
 
264
304
  /**
265
- *
266
- * @return {SearchBuilder} this
305
+ * 抽出する作品の会話率を%単位で指定します (kaiwaritu)。
306
+ * @param num 会話率(%)
307
+ * @return {this}
267
308
  */
268
309
  kaiwaritu(num: number): this;
310
+ /**
311
+ * 抽出する作品の会話率を%単位で範囲指定します (kaiwaritu)。
312
+ * @param min 最低会話率(%)
313
+ * @param max 最高会話率(%)
314
+ * @return {this}
315
+ */
269
316
  kaiwaritu(min: number, max: number): this;
270
317
 
271
318
  kaiwaritu(min: number, max?: number): this {
@@ -280,8 +327,9 @@ export abstract class NovelSearchBuilderBase<
280
327
  }
281
328
 
282
329
  /**
283
- *
284
- * @return {SearchBuilder} this
330
+ * 抽出する作品の挿絵数を指定します (sasie)。
331
+ * @param num 挿絵数、または[最小挿絵数, 最大挿絵数]
332
+ * @return {this}
285
333
  */
286
334
  sasie(num: number | readonly number[]): this {
287
335
  this.set({ sasie: NovelSearchBuilderBase.array2string(num) });
@@ -289,8 +337,9 @@ export abstract class NovelSearchBuilderBase<
289
337
  }
290
338
 
291
339
  /**
292
- *
293
- * @return {SearchBuilder} this
340
+ * 抽出する作品の予想読了時間を分単位で指定します (time)。
341
+ * @param num 読了時間(分)、または[最小読了時間, 最大読了時間]
342
+ * @return {this}
294
343
  */
295
344
  time(num: number | readonly number[]): this {
296
345
  this.set({ time: NovelSearchBuilderBase.array2string(num) });
@@ -298,8 +347,9 @@ export abstract class NovelSearchBuilderBase<
298
347
  }
299
348
 
300
349
  /**
301
- *
302
- * @return {SearchBuilder} this
350
+ * Nコードを指定して取得します (ncode)。
351
+ * @param ncodes Nコード、またはNコードの配列
352
+ * @return {this}
303
353
  */
304
354
  ncode(ncodes: string | readonly string[]): this {
305
355
  this.set({ ncode: NovelSearchBuilderBase.array2string(ncodes) });
@@ -307,8 +357,9 @@ export abstract class NovelSearchBuilderBase<
307
357
  }
308
358
 
309
359
  /**
310
- *
311
- * @return {SearchBuilder} this
360
+ * 抽出する小説タイプを指定します (type)。
361
+ * @param type 小説タイプ (t: 短編, r: 連載中, er: 完結済連載小説, ter: 短編と完結済連載小説, re: 連載中と完結済連載小説)
362
+ * @return {this}
312
363
  */
313
364
  type(type: NovelTypeParam): this {
314
365
  this.set({ type });
@@ -316,8 +367,10 @@ export abstract class NovelSearchBuilderBase<
316
367
  }
317
368
 
318
369
  /**
319
- *
320
- * @return {SearchBuilder} this
370
+ * 抽出する作品の文体を指定します (buntai)。
371
+ * 複数指定する場合はハイフン(-)で区切ってください。
372
+ * @param buntai 文体コード、または文体コードの配列
373
+ * @return {this}
321
374
  */
322
375
  buntai(buntai: BuntaiParam | readonly BuntaiParam[]): this {
323
376
  this.set({ buntai: NovelSearchBuilderBase.array2string(buntai) });
@@ -325,8 +378,9 @@ export abstract class NovelSearchBuilderBase<
325
378
  }
326
379
 
327
380
  /**
328
- *
329
- * @return {SearchBuilder} this
381
+ * 連載停止中作品に関する指定をします (stop)。
382
+ * @param bool trueの場合、長期連載停止中のみ取得する (デフォルト: true)。falseの場合、長期連載停止中を除外する。
383
+ * @return {this}
330
384
  */
331
385
  isStop(bool = true): this {
332
386
  this.set({ stop: bool ? StopParam.Stopping : StopParam.NoStopping });
@@ -334,20 +388,33 @@ export abstract class NovelSearchBuilderBase<
334
388
  }
335
389
 
336
390
  /**
337
- *
338
- * @return {SearchBuilder} this
391
+ * ピックアップ作品のみを取得します (ispickup)。
392
+ * @return {this}
339
393
  */
340
- isPickup(bool = true): this {
341
- this.set({ ispickup: bool ? BooleanNumber.True : BooleanNumber.False });
394
+ isPickup(): this {
395
+ this.set({ ispickup: BooleanNumber.True });
342
396
  return this;
343
397
  }
344
398
 
345
399
  /**
346
- *
347
- * @return {SearchBuilder} this
400
+ * 最終更新日時を指定します (lastup)。
401
+ * @param date 最終更新日時 (YYYYMMDDhhmmss形式またはUNIXタイムスタンプ)
402
+ * @return {this}
403
+ */
404
+ lastUpdate(date: DateParam): this;
405
+ /**
406
+ * 最終更新日時の範囲を指定します (lastup)。
407
+ * @param from 開始日時 (UNIXタイムスタンプ)
408
+ * @param to 終了日時 (UNIXタイムスタンプ)
409
+ * @return {this}
348
410
  */
349
- lastUpdate(date: string): this;
350
411
  lastUpdate(from: number, to: number): this;
412
+ /**
413
+ * 最終更新日時の範囲を指定します (lastup)。
414
+ * @param from 開始日時 (Dateオブジェクト)
415
+ * @param to 終了日時 (Dateオブジェクト)
416
+ * @return {this}
417
+ */
351
418
  lastUpdate(from: Date, to: Date): this;
352
419
 
353
420
  lastUpdate(x: string | number | Date, y?: number | Date): this {
@@ -356,7 +423,7 @@ export abstract class NovelSearchBuilderBase<
356
423
  date = x;
357
424
  } else if (x instanceof Date && y instanceof Date) {
358
425
  date = `${Math.floor(x.getTime() / 1000)}-${Math.floor(
359
- x.getTime() / 1000
426
+ y.getTime() / 1000
360
427
  )}`;
361
428
  } else {
362
429
  date = `${x}-${y}`;
@@ -366,6 +433,43 @@ export abstract class NovelSearchBuilderBase<
366
433
  return this;
367
434
  }
368
435
 
436
+ /**
437
+ * 作品の更新日時を指定します (lastupdate)。
438
+ * @param date 作品の更新日時 (YYYYMMDDhhmmss形式またはUNIXタイムスタンプ)
439
+ * @return {this}
440
+ */
441
+ lastNovelUpdate(date: DateParam): this;
442
+ /**
443
+ * 作品の更新日時の範囲を指定します (lastupdate)。
444
+ * @param from 開始日時 (UNIXタイムスタンプ)
445
+ * @param to 終了日時 (UNIXタイムスタンプ)
446
+ * @return {this}
447
+ */
448
+ lastNovelUpdate(from: number, to: number): this;
449
+ /**
450
+ * 作品の更新日時の範囲を指定します (lastupdate)。
451
+ * @param from 開始日時 (Dateオブジェクト)
452
+ * @param to 終了日時 (Dateオブジェクト)
453
+ * @return {this}
454
+ */
455
+ lastNovelUpdate(from: Date, to: Date): this;
456
+
457
+ lastNovelUpdate(x: string | number | Date, y?: number | Date): this {
458
+ let date: string;
459
+ if (typeof x == "string") {
460
+ date = x;
461
+ } else if (x instanceof Date && y instanceof Date) {
462
+ date = `${Math.floor(x.getTime() / 1000)}-${Math.floor(
463
+ y.getTime() / 1000
464
+ )}`;
465
+ } else {
466
+ date = `${x}-${y}`;
467
+ }
468
+
469
+ this.set({ lastupdate: date });
470
+ return this;
471
+ }
472
+
369
473
  /**
370
474
  * なろう小説APIへの検索リクエストを実行する
371
475
  * @returns {Promise<NarouSearchResults>} 検索結果
@@ -381,11 +485,13 @@ export abstract class NovelSearchBuilderBase<
381
485
  */
382
486
  export default class SearchBuilder<
383
487
  T extends keyof NarouSearchResult = DefaultSearchResultFields,
384
- TOpt extends keyof NarouSearchResult = never
488
+ TOpt extends keyof NarouSearchResult = never,
385
489
  > extends NovelSearchBuilderBase<T | TOpt> {
386
490
  /**
387
- *
388
- * @return {SearchBuilder} this
491
+ * 大ジャンルを指定して取得します (biggenre)。
492
+ * 複数指定する場合はハイフン(-)で区切ってください。
493
+ * @param genre 大ジャンルコード、または大ジャンルコードの配列
494
+ * @return {this}
389
495
  */
390
496
  bigGenre(genre: BigGenre | readonly BigGenre[]): this {
391
497
  this.set({ biggenre: SearchBuilder.array2string(genre) });
@@ -393,8 +499,10 @@ export default class SearchBuilder<
393
499
  }
394
500
 
395
501
  /**
396
- *
397
- * @return {SearchBuilder} this
502
+ * 除外したい大ジャンルを指定します (notbiggenre)。
503
+ * 複数指定する場合はハイフン(-)で区切ってください。
504
+ * @param genre 除外する大ジャンルコード、または大ジャンルコードの配列
505
+ * @return {this}
398
506
  */
399
507
  notBigGenre(genre: BigGenre | readonly BigGenre[]): this {
400
508
  this.set({ notbiggenre: SearchBuilder.array2string(genre) });
@@ -402,8 +510,10 @@ export default class SearchBuilder<
402
510
  }
403
511
 
404
512
  /**
405
- *
406
- * @return {SearchBuilder} this
513
+ * ジャンルを指定して取得します (genre)。
514
+ * 複数指定する場合はハイフン(-)で区切ってください。
515
+ * @param genre ジャンルコード、またはジャンルコードの配列
516
+ * @return {this}
407
517
  */
408
518
  genre(genre: Genre | readonly Genre[]): this {
409
519
  this.set({ genre: SearchBuilder.array2string(genre) });
@@ -411,8 +521,10 @@ export default class SearchBuilder<
411
521
  }
412
522
 
413
523
  /**
414
- *
415
- * @return {SearchBuilder} this
524
+ * 除外したいジャンルを指定します (notgenre)。
525
+ * 複数指定する場合はハイフン(-)で区切ってください。
526
+ * @param genre 除外するジャンルコード、またはジャンルコードの配列
527
+ * @return {this}
416
528
  */
417
529
  notGenre(genre: Genre | readonly Genre[]): this {
418
530
  this.set({ notgenre: SearchBuilder.array2string(genre) });
@@ -420,8 +532,10 @@ export default class SearchBuilder<
420
532
  }
421
533
 
422
534
  /**
423
- *
424
- * @return {SearchBuilder} this
535
+ * ユーザIDを指定して取得します (userid)。
536
+ * 複数指定する場合はハイフン(-)で区切ってください。
537
+ * @param ids ユーザID、またはユーザIDの配列
538
+ * @return {this}
425
539
  */
426
540
  userId(ids: number | readonly number[]): this {
427
541
  this.set({ userid: SearchBuilder.array2string(ids) });
@@ -429,8 +543,9 @@ export default class SearchBuilder<
429
543
  }
430
544
 
431
545
  /**
432
- *
433
- * @return {SearchBuilder} this
546
+ * R15作品を抽出または除外します (isr15/notr15)。
547
+ * @param bool trueの場合、R15作品を抽出する (デフォルト: true)。falseの場合、除外する。
548
+ * @return {this}
434
549
  */
435
550
  isR15(bool = true): this {
436
551
  if (bool) {
@@ -442,8 +557,11 @@ export default class SearchBuilder<
442
557
  }
443
558
 
444
559
  /**
445
- *
446
- * @return {SearchBuilder} this
560
+ * 出力する項目を個別に指定します (of)。
561
+ * 未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
562
+ * 複数項目を出力する場合はハイフン(-)記号で区切ってください。
563
+ * @param fields 出力するフィールド名、またはフィールド名の配列
564
+ * @return {SearchBuilder<SearchResultFields<TFields>, TOpt>} 型が更新されたビルダー
447
565
  */
448
566
  fields<TFields extends Fields>(
449
567
  fields: TFields | readonly TFields[]
@@ -453,6 +571,12 @@ export default class SearchBuilder<
453
571
  return this as any;
454
572
  }
455
573
 
574
+ /**
575
+ * 出力オプション項目を指定します (opt)。
576
+ * 複数項目を出力する場合はハイフン(-)記号で区切ってください。
577
+ * @param option 出力するオプションフィールド名、またはオプションフィールド名の配列
578
+ * @return {SearchBuilder<T, SearchResultOptionalFields<TFields>>} 型が更新されたビルダー
579
+ */
456
580
  opt<TFields extends OptionalFields>(
457
581
  option: TFields | readonly TFields[]
458
582
  ): SearchBuilder<T, SearchResultOptionalFields<TFields>> {
@@ -0,0 +1,38 @@
1
+ // 日付関連のユーティリティ関数
2
+
3
+ /**
4
+ * 文字列の日付(yyyyMMdd形式)をDateオブジェクトに変換する
5
+ * @param dateStr yyyyMMdd形式の日付文字列
6
+ * @returns Dateオブジェクト
7
+ */
8
+ export function parseDate(dateStr: string): Date {
9
+ const year = parseInt(dateStr.substring(0, 4), 10);
10
+ const month = parseInt(dateStr.substring(4, 6), 10) - 1; // JavaScriptの月は0から始まる
11
+ const day = parseInt(dateStr.substring(6, 8), 10);
12
+
13
+ return new Date(year, month, day, 0, 0, 0, 0);
14
+ }
15
+
16
+ /**
17
+ * 日付をyyyyMMdd形式の文字列に変換する
18
+ * @param date 日付
19
+ * @returns yyyyMMdd形式の文字列
20
+ */
21
+ export function formatDate(date: Date): string {
22
+ const year = date.getFullYear();
23
+ const month = String(date.getMonth() + 1).padStart(2, '0');
24
+ const day = String(date.getDate()).padStart(2, '0');
25
+ return `${year}${month}${day}`;
26
+ }
27
+
28
+ /**
29
+ * 指定された日数を加算した新しい日付を返す
30
+ * @param date 元の日付
31
+ * @param days 加算する日数
32
+ * @returns 新しい日付
33
+ */
34
+ export function addDays(date: Date, days: number): Date {
35
+ const result = new Date(date);
36
+ result.setDate(result.getDate() + days);
37
+ return result;
38
+ }