narou 0.7.7 → 0.8.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.
Files changed (102) hide show
  1. package/dist/index.browser.d.ts +35 -29
  2. package/dist/index.browser.d.ts.map +1 -1
  3. package/dist/index.browser.js +82 -122
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.common.d.ts +14 -9
  6. package/dist/index.common.d.ts.map +1 -1
  7. package/dist/index.common.js +34 -24
  8. package/dist/index.common.js.map +1 -1
  9. package/dist/index.d.ts +42 -30
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +90 -124
  12. package/dist/index.js.map +1 -1
  13. package/dist/narou-fetch.d.ts +12 -12
  14. package/dist/narou-fetch.js +45 -128
  15. package/dist/narou-fetch.js.map +1 -1
  16. package/dist/narou-jsonp.d.ts +9 -9
  17. package/dist/narou-jsonp.js +23 -100
  18. package/dist/narou-jsonp.js.map +1 -1
  19. package/dist/narou-ranking-results.d.ts +9 -9
  20. package/dist/narou-ranking-results.js +2 -2
  21. package/dist/narou-search-results.d.ts +130 -120
  22. package/dist/narou-search-results.d.ts.map +1 -1
  23. package/dist/narou-search-results.js +62 -65
  24. package/dist/narou-search-results.js.map +1 -1
  25. package/dist/narou.d.ts +25 -24
  26. package/dist/narou.d.ts.map +1 -1
  27. package/dist/narou.js +29 -104
  28. package/dist/narou.js.map +1 -1
  29. package/dist/params.d.ts +323 -282
  30. package/dist/params.d.ts.map +1 -1
  31. package/dist/params.js +246 -229
  32. package/dist/params.js.map +1 -1
  33. package/dist/ranking-history.d.ts +13 -13
  34. package/dist/ranking-history.js +13 -13
  35. package/dist/ranking-history.js.map +1 -1
  36. package/dist/ranking.d.ts +45 -45
  37. package/dist/ranking.js +86 -155
  38. package/dist/ranking.js.map +1 -1
  39. package/dist/search-builder-r18.d.ts +28 -28
  40. package/dist/search-builder-r18.d.ts.map +1 -1
  41. package/dist/search-builder-r18.js +44 -64
  42. package/dist/search-builder-r18.js.map +1 -1
  43. package/dist/search-builder.d.ts +219 -234
  44. package/dist/search-builder.d.ts.map +1 -1
  45. package/dist/search-builder.js +380 -440
  46. package/dist/search-builder.js.map +1 -1
  47. package/dist/user-search.d.ts +63 -0
  48. package/dist/user-search.d.ts.map +1 -0
  49. package/dist/user-search.js +94 -0
  50. package/dist/user-search.js.map +1 -0
  51. package/dist/util/jsonp.d.ts +16 -16
  52. package/dist/util/jsonp.js +45 -47
  53. package/dist/util/jsonp.js.map +1 -1
  54. package/dist/util/type.d.ts +3 -3
  55. package/dist/util/type.js +2 -2
  56. package/dist/util/unzipp.d.ts +3 -3
  57. package/dist/util/unzipp.js +11 -56
  58. package/dist/util/unzipp.js.map +1 -1
  59. package/dist.esm/index.browser.js +86 -0
  60. package/dist.esm/index.browser.js.map +1 -0
  61. package/dist.esm/index.common.js +38 -0
  62. package/dist.esm/index.common.js.map +1 -0
  63. package/dist.esm/index.js +94 -0
  64. package/dist.esm/index.js.map +1 -0
  65. package/dist.esm/narou-fetch.js +49 -0
  66. package/dist.esm/narou-fetch.js.map +1 -0
  67. package/dist.esm/narou-jsonp.js +27 -0
  68. package/dist.esm/narou-jsonp.js.map +1 -0
  69. package/dist.esm/narou-ranking-results.js +3 -0
  70. package/dist.esm/narou-ranking-results.js.map +1 -0
  71. package/dist.esm/narou-search-results.js +63 -0
  72. package/dist.esm/narou-search-results.js.map +1 -0
  73. package/dist.esm/narou.js +33 -0
  74. package/dist.esm/narou.js.map +1 -0
  75. package/dist.esm/params.js +247 -0
  76. package/dist.esm/params.js.map +1 -0
  77. package/dist.esm/ranking-history.js +14 -0
  78. package/dist.esm/ranking-history.js.map +1 -0
  79. package/dist.esm/ranking.js +90 -0
  80. package/dist.esm/ranking.js.map +1 -0
  81. package/dist.esm/search-builder-r18.js +45 -0
  82. package/dist.esm/search-builder-r18.js.map +1 -0
  83. package/dist.esm/search-builder.js +381 -0
  84. package/dist.esm/search-builder.js.map +1 -0
  85. package/dist.esm/user-search.js +94 -0
  86. package/dist.esm/user-search.js.map +1 -0
  87. package/dist.esm/util/jsonp.js +46 -0
  88. package/dist.esm/util/jsonp.js.map +1 -0
  89. package/dist.esm/util/type.js +3 -0
  90. package/dist.esm/util/type.js.map +1 -0
  91. package/dist.esm/util/unzipp.js +12 -0
  92. package/dist.esm/util/unzipp.js.map +1 -0
  93. package/package.json +18 -8
  94. package/src/index.browser.ts +12 -1
  95. package/src/index.common.ts +18 -29
  96. package/src/index.ts +20 -3
  97. package/src/narou-search-results.ts +20 -7
  98. package/src/narou.ts +26 -11
  99. package/src/params.ts +60 -15
  100. package/src/search-builder-r18.ts +9 -9
  101. package/src/search-builder.ts +96 -102
  102. package/src/user-search.ts +109 -0
@@ -1,441 +1,381 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.SearchBuilderBase = void 0;
30
- var params_1 = require("./params");
31
- var SearchBuilderBase = /** @class */ (function () {
32
- /**
33
- * constructor
34
- * @private
35
- */
36
- function SearchBuilderBase(params, api) {
37
- if (params === void 0) { params = {}; }
38
- this.params = params;
39
- this.api = api;
40
- }
41
- SearchBuilderBase.distinct = function (array) {
42
- return Array.from(new Set(array));
43
- };
44
- SearchBuilderBase.array2string = function (n) {
45
- if (Array.isArray(n)) {
46
- return this.distinct(n).join("-");
47
- }
48
- else {
49
- return n.toString();
50
- }
51
- };
52
- /**
53
- * a
54
- * @return {SearchBuilder} this
55
- */
56
- SearchBuilderBase.prototype.word = function (word) {
57
- this.set({ word: word });
58
- return this;
59
- };
60
- /**
61
- *
62
- * @return {SearchBuilder} this
63
- */
64
- SearchBuilderBase.prototype.notWord = function (word) {
65
- this.set({ notword: word });
66
- return this;
67
- };
68
- /**
69
- *
70
- * @return {SearchBuilder} this
71
- */
72
- SearchBuilderBase.prototype.byTitle = function (bool) {
73
- if (bool === void 0) { bool = true; }
74
- this.set({ title: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
75
- return this;
76
- };
77
- /**
78
- *
79
- * @return {SearchBuilder} this
80
- */
81
- SearchBuilderBase.prototype.byOutline = function (bool) {
82
- if (bool === void 0) { bool = true; }
83
- this.set({ ex: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
84
- return this;
85
- };
86
- /**
87
- *
88
- * @return {SearchBuilder} this
89
- */
90
- SearchBuilderBase.prototype.byKeyword = function (bool) {
91
- if (bool === void 0) { bool = true; }
92
- this.set({ keyword: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
93
- return this;
94
- };
95
- /**
96
- *
97
- * @return {SearchBuilder} this
98
- */
99
- SearchBuilderBase.prototype.byAuthor = function (bool) {
100
- if (bool === void 0) { bool = true; }
101
- this.set({ wname: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
102
- return this;
103
- };
104
- /**
105
- *
106
- * @return {SearchBuilder} this
107
- */
108
- SearchBuilderBase.prototype.isBL = function (bool) {
109
- if (bool === void 0) { bool = true; }
110
- if (bool) {
111
- this.set({ isbl: params_1.BooleanNumber.True });
112
- }
113
- else {
114
- this.set({ notbl: params_1.BooleanNumber.True });
115
- }
116
- return this;
117
- };
118
- /**
119
- *
120
- * @return {SearchBuilder} this
121
- */
122
- SearchBuilderBase.prototype.isGL = function (bool) {
123
- if (bool === void 0) { bool = true; }
124
- if (bool) {
125
- this.set({ isgl: params_1.BooleanNumber.True });
126
- }
127
- else {
128
- this.set({ notgl: params_1.BooleanNumber.True });
129
- }
130
- return this;
131
- };
132
- /**
133
- *
134
- * @return {SearchBuilder} this
135
- */
136
- SearchBuilderBase.prototype.isZankoku = function (bool) {
137
- if (bool === void 0) { bool = true; }
138
- if (bool) {
139
- this.set({ iszankoku: params_1.BooleanNumber.True });
140
- }
141
- else {
142
- this.set({ notzankoku: params_1.BooleanNumber.True });
143
- }
144
- return this;
145
- };
146
- /**
147
- *
148
- * @return {SearchBuilder} this
149
- */
150
- SearchBuilderBase.prototype.isTensei = function (bool) {
151
- if (bool === void 0) { bool = true; }
152
- if (bool) {
153
- this.set({ istensei: params_1.BooleanNumber.True });
154
- }
155
- else {
156
- this.set({ nottensei: params_1.BooleanNumber.True });
157
- }
158
- return this;
159
- };
160
- /**
161
- *
162
- * @return {SearchBuilder} this
163
- */
164
- SearchBuilderBase.prototype.isTenni = function (bool) {
165
- if (bool === void 0) { bool = true; }
166
- if (bool) {
167
- this.set({ istenni: params_1.BooleanNumber.True });
168
- }
169
- else {
170
- this.set({ nottenni: params_1.BooleanNumber.True });
171
- }
172
- return this;
173
- };
174
- /**
175
- *
176
- * @return {SearchBuilder} this
177
- */
178
- SearchBuilderBase.prototype.isTT = function () {
179
- this.set({ istt: params_1.BooleanNumber.True });
180
- return this;
181
- };
182
- /**
183
- *
184
- * @return {SearchBuilder} this
185
- */
186
- SearchBuilderBase.prototype.length = function (length) {
187
- this.set({ length: SearchBuilderBase.array2string(length) });
188
- return this;
189
- };
190
- SearchBuilderBase.prototype.kaiwaritu = function (min, max) {
191
- var n;
192
- if (max != null) {
193
- n = "".concat(min, "-").concat(max);
194
- }
195
- else {
196
- n = min;
197
- }
198
- this.set({ kaiwaritu: n });
199
- return this;
200
- };
201
- /**
202
- *
203
- * @return {SearchBuilder} this
204
- */
205
- SearchBuilderBase.prototype.sasie = function (num) {
206
- this.set({ sasie: SearchBuilderBase.array2string(num) });
207
- return this;
208
- };
209
- /**
210
- *
211
- * @return {SearchBuilder} this
212
- */
213
- SearchBuilderBase.prototype.time = function (num) {
214
- this.set({ time: SearchBuilderBase.array2string(num) });
215
- return this;
216
- };
217
- /**
218
- *
219
- * @return {SearchBuilder} this
220
- */
221
- SearchBuilderBase.prototype.ncode = function (ncodes) {
222
- this.set({ ncode: SearchBuilderBase.array2string(ncodes) });
223
- return this;
224
- };
225
- /**
226
- *
227
- * @return {SearchBuilder} this
228
- */
229
- SearchBuilderBase.prototype.type = function (type) {
230
- this.set({ type: type });
231
- return this;
232
- };
233
- /**
234
- *
235
- * @return {SearchBuilder} this
236
- */
237
- SearchBuilderBase.prototype.buntai = function (buntai) {
238
- this.set({ buntai: SearchBuilderBase.array2string(buntai) });
239
- return this;
240
- };
241
- /**
242
- *
243
- * @return {SearchBuilder} this
244
- */
245
- SearchBuilderBase.prototype.isStop = function (bool) {
246
- if (bool === void 0) { bool = true; }
247
- this.set({ stop: bool ? params_1.StopParam.Stopping : params_1.StopParam.NoStopping });
248
- return this;
249
- };
250
- /**
251
- *
252
- * @return {SearchBuilder} this
253
- */
254
- SearchBuilderBase.prototype.isPickup = function (bool) {
255
- if (bool === void 0) { bool = true; }
256
- this.set({ ispickup: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
257
- return this;
258
- };
259
- SearchBuilderBase.prototype.lastUpdate = function (x, y) {
260
- var date;
261
- if (typeof x == "string") {
262
- date = x;
263
- }
264
- else if (x instanceof Date && y instanceof Date) {
265
- date = "".concat(Math.floor(x.getTime() / 1000), "-").concat(Math.floor(x.getTime() / 1000));
266
- }
267
- else {
268
- date = "".concat(x, "-").concat(y);
269
- }
270
- this.set({ lastup: date });
271
- return this;
272
- };
273
- /**
274
- *
275
- * @return {SearchBuilder} this
276
- */
277
- SearchBuilderBase.prototype.limit = function (num) {
278
- this.set({ lim: num });
279
- return this;
280
- };
281
- /**
282
- *
283
- * @return {SearchBuilder} this
284
- */
285
- SearchBuilderBase.prototype.start = function (num) {
286
- this.set({ st: num });
287
- return this;
288
- };
289
- /**
290
- *
291
- * @return {SearchBuilder} this
292
- */
293
- SearchBuilderBase.prototype.page = function (no, count) {
294
- if (count === void 0) { count = 20; }
295
- return this.limit(count).start(no * count);
296
- };
297
- /**
298
- * 出力順序を指定する。指定しない場合は新着順となります。
299
- *
300
- * @description
301
- * allunique 閲覧者の多い順(未実装)
302
- * favnovelcnt ブックマーク数の多い順
303
- * reviewcnt レビュー数の多い順
304
- * hyoka 総合評価の高い順
305
- * hyokaasc 総合評価の低い順
306
- * impressioncnt 感想の多い順
307
- * hyokacnt 評価者数の多い順
308
- * hyokacntasc 評価者数の少ない順
309
- * weekly 週間ユニークユーザの多い順 毎週火曜日早朝リセット
310
- * (前週の日曜日から土曜日分)
311
- * lengthdesc 小説本文の文字数が多い順
312
- * lengthasc 小説本文の文字数が少ない順
313
- * ncodedesc Nコードが新しい順
314
- * old 古い順
315
- * @param {Order} order 出力順序
316
- * @return {SearchBuilder} this
317
- */
318
- SearchBuilderBase.prototype.order = function (order) {
319
- this.set({ order: order });
320
- return this;
321
- };
322
- /**
323
- * gzip圧縮する。
324
- *
325
- * 転送量上限を減らすためにも推奨
326
- * @param {GzipLevel} level gzip圧縮レベル(1~5)
327
- * @return {SearchBuilder} this
328
- */
329
- SearchBuilderBase.prototype.gzip = function (level) {
330
- this.set({ gzip: level });
331
- return this;
332
- };
333
- /**
334
- * クエリパラメータをセットする
335
- * @private
336
- * @return {SearchBuilder} this
337
- */
338
- SearchBuilderBase.prototype.set = function (obj) {
339
- this.params = __assign(__assign({}, this.params), obj);
340
- return this;
341
- };
342
- /**
343
- * クエリパラメータを削除する
344
- * @private
345
- * @return {SearchBuilder} this
346
- */
347
- SearchBuilderBase.prototype.unset = function (key) {
348
- delete this.params[key];
349
- return this;
350
- };
351
- /**
352
- * なろう小説APIへの検索リクエストを実行する
353
- * @returns {Promise<NarouSearchResults>} 検索結果
354
- */
355
- SearchBuilderBase.prototype.execute = function () {
356
- return this.api.executeNovel(this.params);
357
- };
358
- return SearchBuilderBase;
359
- }());
360
- exports.SearchBuilderBase = SearchBuilderBase;
361
- /**
362
- * 検索ヘルパー
363
- * @class SearchBuilder
364
- */
365
- var SearchBuilder = /** @class */ (function (_super) {
366
- __extends(SearchBuilder, _super);
367
- function SearchBuilder() {
368
- return _super !== null && _super.apply(this, arguments) || this;
369
- }
370
- /**
371
- *
372
- * @return {SearchBuilder} this
373
- */
374
- SearchBuilder.prototype.bigGenre = function (genre) {
375
- this.set({ biggenre: SearchBuilderBase.array2string(genre) });
376
- return this;
377
- };
378
- /**
379
- *
380
- * @return {SearchBuilder} this
381
- */
382
- SearchBuilder.prototype.notBigGenre = function (genre) {
383
- this.set({ notbiggenre: SearchBuilderBase.array2string(genre) });
384
- return this;
385
- };
386
- /**
387
- *
388
- * @return {SearchBuilder} this
389
- */
390
- SearchBuilder.prototype.genre = function (genre) {
391
- this.set({ genre: SearchBuilderBase.array2string(genre) });
392
- return this;
393
- };
394
- /**
395
- *
396
- * @return {SearchBuilder} this
397
- */
398
- SearchBuilder.prototype.notGenre = function (genre) {
399
- this.set({ notgenre: SearchBuilderBase.array2string(genre) });
400
- return this;
401
- };
402
- /**
403
- *
404
- * @return {SearchBuilder} this
405
- */
406
- SearchBuilder.prototype.userId = function (ids) {
407
- this.set({ userid: SearchBuilderBase.array2string(ids) });
408
- return this;
409
- };
410
- /**
411
- *
412
- * @return {SearchBuilder} this
413
- */
414
- SearchBuilder.prototype.isR15 = function (bool) {
415
- if (bool === void 0) { bool = true; }
416
- if (bool) {
417
- this.set({ isr15: 1 });
418
- }
419
- else {
420
- this.set({ notr15: 1 });
421
- }
422
- return this;
423
- };
424
- /**
425
- *
426
- * @return {SearchBuilder} this
427
- */
428
- SearchBuilder.prototype.fields = function (fields) {
429
- this.set({ of: SearchBuilderBase.array2string(fields) });
430
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
431
- return this;
432
- };
433
- SearchBuilder.prototype.opt = function (option) {
434
- this.set({ opt: SearchBuilderBase.array2string(option) });
435
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
436
- return this;
437
- };
438
- return SearchBuilder;
439
- }(SearchBuilderBase));
440
- exports.default = SearchBuilder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NovelSearchBuilderBase = exports.SearchBuilderBase = void 0;
4
+ const params_1 = require("./params");
5
+ class SearchBuilderBase {
6
+ /**
7
+ * constructor
8
+ * @private
9
+ */
10
+ constructor(params = {}, api) {
11
+ this.params = params;
12
+ this.api = api;
13
+ }
14
+ static distinct(array) {
15
+ return Array.from(new Set(array));
16
+ }
17
+ static array2string(n) {
18
+ if (Array.isArray(n)) {
19
+ return this.distinct(n).join("-");
20
+ }
21
+ else {
22
+ return n.toString();
23
+ }
24
+ }
25
+ /**
26
+ *
27
+ * @return {SearchBuilder} this
28
+ */
29
+ limit(num) {
30
+ this.set({ lim: num });
31
+ return this;
32
+ }
33
+ /**
34
+ *
35
+ * @return {SearchBuilder} this
36
+ */
37
+ start(num) {
38
+ this.set({ st: num });
39
+ return this;
40
+ }
41
+ /**
42
+ *
43
+ * @return {SearchBuilder} this
44
+ */
45
+ page(no, count = 20) {
46
+ return this.limit(count).start(no * count);
47
+ }
48
+ /**
49
+ * 出力順序を指定する。指定しない場合は新着順となります。
50
+ * old 古い順
51
+ * @param {TOrder} order 出力順序
52
+ * @return {SearchBuilder} this
53
+ */
54
+ order(order) {
55
+ this.set({ order: order });
56
+ return this;
57
+ }
58
+ /**
59
+ * gzip圧縮する。
60
+ *
61
+ * 転送量上限を減らすためにも推奨
62
+ * @param {GzipLevel} level gzip圧縮レベル(1~5)
63
+ * @return {SearchBuilder} this
64
+ */
65
+ gzip(level) {
66
+ this.set({ gzip: level });
67
+ return this;
68
+ }
69
+ /**
70
+ * クエリパラメータをセットする
71
+ * @private
72
+ * @return {SearchBuilder} this
73
+ */
74
+ set(obj) {
75
+ this.params = { ...this.params, ...obj };
76
+ return this;
77
+ }
78
+ /**
79
+ * クエリパラメータを削除する
80
+ */
81
+ unset(key) {
82
+ delete this.params[key];
83
+ return this;
84
+ }
85
+ }
86
+ exports.SearchBuilderBase = SearchBuilderBase;
87
+ class NovelSearchBuilderBase extends SearchBuilderBase {
88
+ /**
89
+ * a
90
+ * @return {SearchBuilder} this
91
+ */
92
+ word(word) {
93
+ this.set({ word: word });
94
+ return this;
95
+ }
96
+ /**
97
+ *
98
+ * @return {SearchBuilder} this
99
+ */
100
+ notWord(word) {
101
+ this.set({ notword: word });
102
+ return this;
103
+ }
104
+ /**
105
+ *
106
+ * @return {SearchBuilder} this
107
+ */
108
+ byTitle(bool = true) {
109
+ this.set({ title: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
110
+ return this;
111
+ }
112
+ /**
113
+ *
114
+ * @return {SearchBuilder} this
115
+ */
116
+ byOutline(bool = true) {
117
+ this.set({ ex: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
118
+ return this;
119
+ }
120
+ /**
121
+ *
122
+ * @return {SearchBuilder} this
123
+ */
124
+ byKeyword(bool = true) {
125
+ this.set({ keyword: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
126
+ return this;
127
+ }
128
+ /**
129
+ *
130
+ * @return {SearchBuilder} this
131
+ */
132
+ byAuthor(bool = true) {
133
+ this.set({ wname: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
134
+ return this;
135
+ }
136
+ /**
137
+ *
138
+ * @return {SearchBuilder} this
139
+ */
140
+ isBL(bool = true) {
141
+ if (bool) {
142
+ this.set({ isbl: params_1.BooleanNumber.True });
143
+ }
144
+ else {
145
+ this.set({ notbl: params_1.BooleanNumber.True });
146
+ }
147
+ return this;
148
+ }
149
+ /**
150
+ *
151
+ * @return {SearchBuilder} this
152
+ */
153
+ isGL(bool = true) {
154
+ if (bool) {
155
+ this.set({ isgl: params_1.BooleanNumber.True });
156
+ }
157
+ else {
158
+ this.set({ notgl: params_1.BooleanNumber.True });
159
+ }
160
+ return this;
161
+ }
162
+ /**
163
+ *
164
+ * @return {SearchBuilder} this
165
+ */
166
+ isZankoku(bool = true) {
167
+ if (bool) {
168
+ this.set({ iszankoku: params_1.BooleanNumber.True });
169
+ }
170
+ else {
171
+ this.set({ notzankoku: params_1.BooleanNumber.True });
172
+ }
173
+ return this;
174
+ }
175
+ /**
176
+ *
177
+ * @return {SearchBuilder} this
178
+ */
179
+ isTensei(bool = true) {
180
+ if (bool) {
181
+ this.set({ istensei: params_1.BooleanNumber.True });
182
+ }
183
+ else {
184
+ this.set({ nottensei: params_1.BooleanNumber.True });
185
+ }
186
+ return this;
187
+ }
188
+ /**
189
+ *
190
+ * @return {SearchBuilder} this
191
+ */
192
+ isTenni(bool = true) {
193
+ if (bool) {
194
+ this.set({ istenni: params_1.BooleanNumber.True });
195
+ }
196
+ else {
197
+ this.set({ nottenni: params_1.BooleanNumber.True });
198
+ }
199
+ return this;
200
+ }
201
+ /**
202
+ *
203
+ * @return {SearchBuilder} this
204
+ */
205
+ isTT() {
206
+ this.set({ istt: params_1.BooleanNumber.True });
207
+ return this;
208
+ }
209
+ /**
210
+ *
211
+ * @return {SearchBuilder} this
212
+ */
213
+ length(length) {
214
+ this.set({ length: NovelSearchBuilderBase.array2string(length) });
215
+ return this;
216
+ }
217
+ kaiwaritu(min, max) {
218
+ let n;
219
+ if (max != null) {
220
+ n = `${min}-${max}`;
221
+ }
222
+ else {
223
+ n = min;
224
+ }
225
+ this.set({ kaiwaritu: n });
226
+ return this;
227
+ }
228
+ /**
229
+ *
230
+ * @return {SearchBuilder} this
231
+ */
232
+ sasie(num) {
233
+ this.set({ sasie: NovelSearchBuilderBase.array2string(num) });
234
+ return this;
235
+ }
236
+ /**
237
+ *
238
+ * @return {SearchBuilder} this
239
+ */
240
+ time(num) {
241
+ this.set({ time: NovelSearchBuilderBase.array2string(num) });
242
+ return this;
243
+ }
244
+ /**
245
+ *
246
+ * @return {SearchBuilder} this
247
+ */
248
+ ncode(ncodes) {
249
+ this.set({ ncode: NovelSearchBuilderBase.array2string(ncodes) });
250
+ return this;
251
+ }
252
+ /**
253
+ *
254
+ * @return {SearchBuilder} this
255
+ */
256
+ type(type) {
257
+ this.set({ type });
258
+ return this;
259
+ }
260
+ /**
261
+ *
262
+ * @return {SearchBuilder} this
263
+ */
264
+ buntai(buntai) {
265
+ this.set({ buntai: NovelSearchBuilderBase.array2string(buntai) });
266
+ return this;
267
+ }
268
+ /**
269
+ *
270
+ * @return {SearchBuilder} this
271
+ */
272
+ isStop(bool = true) {
273
+ this.set({ stop: bool ? params_1.StopParam.Stopping : params_1.StopParam.NoStopping });
274
+ return this;
275
+ }
276
+ /**
277
+ *
278
+ * @return {SearchBuilder} this
279
+ */
280
+ isPickup(bool = true) {
281
+ this.set({ ispickup: bool ? params_1.BooleanNumber.True : params_1.BooleanNumber.False });
282
+ return this;
283
+ }
284
+ lastUpdate(x, y) {
285
+ let date;
286
+ if (typeof x == "string") {
287
+ date = x;
288
+ }
289
+ else if (x instanceof Date && y instanceof Date) {
290
+ date = `${Math.floor(x.getTime() / 1000)}-${Math.floor(x.getTime() / 1000)}`;
291
+ }
292
+ else {
293
+ date = `${x}-${y}`;
294
+ }
295
+ this.set({ lastup: date });
296
+ return this;
297
+ }
298
+ /**
299
+ * なろう小説APIへの検索リクエストを実行する
300
+ * @returns {Promise<NarouSearchResults>} 検索結果
301
+ */
302
+ execute() {
303
+ return this.api.executeNovel(this.params);
304
+ }
305
+ }
306
+ exports.NovelSearchBuilderBase = NovelSearchBuilderBase;
307
+ /**
308
+ * 検索ヘルパー
309
+ * @class SearchBuilder
310
+ */
311
+ class SearchBuilder extends NovelSearchBuilderBase {
312
+ /**
313
+ *
314
+ * @return {SearchBuilder} this
315
+ */
316
+ bigGenre(genre) {
317
+ this.set({ biggenre: SearchBuilder.array2string(genre) });
318
+ return this;
319
+ }
320
+ /**
321
+ *
322
+ * @return {SearchBuilder} this
323
+ */
324
+ notBigGenre(genre) {
325
+ this.set({ notbiggenre: SearchBuilder.array2string(genre) });
326
+ return this;
327
+ }
328
+ /**
329
+ *
330
+ * @return {SearchBuilder} this
331
+ */
332
+ genre(genre) {
333
+ this.set({ genre: SearchBuilder.array2string(genre) });
334
+ return this;
335
+ }
336
+ /**
337
+ *
338
+ * @return {SearchBuilder} this
339
+ */
340
+ notGenre(genre) {
341
+ this.set({ notgenre: SearchBuilder.array2string(genre) });
342
+ return this;
343
+ }
344
+ /**
345
+ *
346
+ * @return {SearchBuilder} this
347
+ */
348
+ userId(ids) {
349
+ this.set({ userid: SearchBuilder.array2string(ids) });
350
+ return this;
351
+ }
352
+ /**
353
+ *
354
+ * @return {SearchBuilder} this
355
+ */
356
+ isR15(bool = true) {
357
+ if (bool) {
358
+ this.set({ isr15: 1 });
359
+ }
360
+ else {
361
+ this.set({ notr15: 1 });
362
+ }
363
+ return this;
364
+ }
365
+ /**
366
+ *
367
+ * @return {SearchBuilder} this
368
+ */
369
+ fields(fields) {
370
+ this.set({ of: SearchBuilder.array2string(fields) });
371
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
372
+ return this;
373
+ }
374
+ opt(option) {
375
+ this.set({ opt: SearchBuilder.array2string(option) });
376
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
377
+ return this;
378
+ }
379
+ }
380
+ exports.default = SearchBuilder;
441
381
  //# sourceMappingURL=search-builder.js.map