narou 1.1.0 → 2.0.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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -35
  3. package/dist/index.browser.cjs +87 -1230
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.d.cts +31 -24
  6. package/dist/index.browser.d.mts +47 -0
  7. package/dist/index.browser.mjs +66 -0
  8. package/dist/index.browser.mjs.map +1 -0
  9. package/dist/index.cjs +147 -1281
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.common-8lS2K_1Y.mjs +1166 -0
  12. package/dist/index.common-8lS2K_1Y.mjs.map +1 -0
  13. package/dist/index.common-CYj0n0aU.cjs +1346 -0
  14. package/dist/index.common-CYj0n0aU.cjs.map +1 -0
  15. package/dist/index.d.cts +39 -23
  16. package/dist/index.d.mts +63 -0
  17. package/dist/index.mjs +128 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/user-search-BY6FdEe7.d.cts +1394 -0
  20. package/dist/user-search-Besgk-Hx.d.mts +1394 -0
  21. package/package.json +34 -45
  22. package/pnpm-lock.yaml +2523 -2175
  23. package/src/index.browser.ts +21 -5
  24. package/src/index.ts +16 -3
  25. package/src/narou-fetch.ts +4 -3
  26. package/src/narou-jsonp.ts +4 -2
  27. package/src/narou-search-results.ts +2 -1
  28. package/src/narou.ts +53 -13
  29. package/src/params.ts +2 -2
  30. package/src/ranking-history.ts +13 -4
  31. package/src/ranking.ts +99 -26
  32. package/src/search-builder-r18.ts +23 -6
  33. package/src/search-builder.ts +183 -76
  34. package/src/user-search.ts +9 -2
  35. package/src/util/date.ts +38 -0
  36. package/src/util/jsonp.ts +61 -6
  37. package/src/util/type.ts +23 -0
  38. package/src/util/unzipp.ts +9 -0
  39. package/dist/chunk-4VC3246A.js +0 -83
  40. package/dist/chunk-4VC3246A.js.map +0 -1
  41. package/dist/chunk-4ZP5YNWI.js +0 -1
  42. package/dist/chunk-4ZP5YNWI.js.map +0 -1
  43. package/dist/chunk-AZT2OXBZ.js +0 -26
  44. package/dist/chunk-AZT2OXBZ.js.map +0 -1
  45. package/dist/chunk-CDOBNSCL.js +0 -407
  46. package/dist/chunk-CDOBNSCL.js.map +0 -1
  47. package/dist/chunk-K22KVNAH.js +0 -94
  48. package/dist/chunk-K22KVNAH.js.map +0 -1
  49. package/dist/chunk-NVMUSXA5.js +0 -23
  50. package/dist/chunk-NVMUSXA5.js.map +0 -1
  51. package/dist/chunk-P7QOZBII.js +0 -386
  52. package/dist/chunk-P7QOZBII.js.map +0 -1
  53. package/dist/chunk-RITMMCZE.js +0 -37
  54. package/dist/chunk-RITMMCZE.js.map +0 -1
  55. package/dist/chunk-SNPBEVCY.js +0 -44
  56. package/dist/chunk-SNPBEVCY.js.map +0 -1
  57. package/dist/chunk-UN3W2CT3.js +0 -72
  58. package/dist/chunk-UN3W2CT3.js.map +0 -1
  59. package/dist/chunk-WYSPGQ3S.js +0 -44
  60. package/dist/chunk-WYSPGQ3S.js.map +0 -1
  61. package/dist/chunk-XAUB42TO.js +0 -15
  62. package/dist/chunk-XAUB42TO.js.map +0 -1
  63. package/dist/chunk-XVH2CU2Q.js +0 -39
  64. package/dist/chunk-XVH2CU2Q.js.map +0 -1
  65. package/dist/index.browser.d.ts +0 -40
  66. package/dist/index.browser.js +0 -125
  67. package/dist/index.browser.js.map +0 -1
  68. package/dist/index.common.cjs +0 -1058
  69. package/dist/index.common.cjs.map +0 -1
  70. package/dist/index.common.d.cts +0 -6
  71. package/dist/index.common.d.ts +0 -6
  72. package/dist/index.common.js +0 -75
  73. package/dist/index.common.js.map +0 -1
  74. package/dist/index.d.ts +0 -47
  75. package/dist/index.js +0 -130
  76. package/dist/index.js.map +0 -1
  77. package/dist/narou-CatW_TC9.d.cts +0 -301
  78. package/dist/narou-fH9osIoh.d.ts +0 -301
  79. package/dist/narou-fetch.cjs +0 -161
  80. package/dist/narou-fetch.cjs.map +0 -1
  81. package/dist/narou-fetch.d.cts +0 -20
  82. package/dist/narou-fetch.d.ts +0 -20
  83. package/dist/narou-fetch.js +0 -10
  84. package/dist/narou-fetch.js.map +0 -1
  85. package/dist/narou-jsonp.cjs +0 -159
  86. package/dist/narou-jsonp.cjs.map +0 -1
  87. package/dist/narou-jsonp.d.cts +0 -13
  88. package/dist/narou-jsonp.d.ts +0 -13
  89. package/dist/narou-jsonp.js +0 -10
  90. package/dist/narou-jsonp.js.map +0 -1
  91. package/dist/narou-ranking-results.cjs +0 -19
  92. package/dist/narou-ranking-results.cjs.map +0 -1
  93. package/dist/narou-ranking-results.d.cts +0 -4
  94. package/dist/narou-ranking-results.d.ts +0 -4
  95. package/dist/narou-ranking-results.js +0 -1
  96. package/dist/narou-ranking-results.js.map +0 -1
  97. package/dist/narou-search-results-D5yqPRZ7.d.ts +0 -727
  98. package/dist/narou-search-results-DWCJWTC5.d.cts +0 -727
  99. package/dist/narou-search-results.cjs +0 -62
  100. package/dist/narou-search-results.cjs.map +0 -1
  101. package/dist/narou-search-results.d.cts +0 -2
  102. package/dist/narou-search-results.d.ts +0 -2
  103. package/dist/narou-search-results.js +0 -11
  104. package/dist/narou-search-results.js.map +0 -1
  105. package/dist/narou.cjs +0 -109
  106. package/dist/narou.cjs.map +0 -1
  107. package/dist/narou.d.cts +0 -4
  108. package/dist/narou.d.ts +0 -4
  109. package/dist/narou.js +0 -8
  110. package/dist/narou.js.map +0 -1
  111. package/dist/params.cjs +0 -448
  112. package/dist/params.cjs.map +0 -1
  113. package/dist/params.d.cts +0 -2
  114. package/dist/params.d.ts +0 -2
  115. package/dist/params.js +0 -41
  116. package/dist/params.js.map +0 -1
  117. package/dist/ranking-history.cjs +0 -39
  118. package/dist/ranking-history.cjs.map +0 -1
  119. package/dist/ranking-history.d.cts +0 -17
  120. package/dist/ranking-history.d.ts +0 -17
  121. package/dist/ranking-history.js +0 -7
  122. package/dist/ranking-history.js.map +0 -1
  123. package/dist/ranking.cjs +0 -674
  124. package/dist/ranking.cjs.map +0 -1
  125. package/dist/ranking.d.cts +0 -47
  126. package/dist/ranking.d.ts +0 -47
  127. package/dist/ranking.js +0 -9
  128. package/dist/ranking.js.map +0 -1
  129. package/dist/search-builder-r18.cjs +0 -488
  130. package/dist/search-builder-r18.cjs.map +0 -1
  131. package/dist/search-builder-r18.d.cts +0 -32
  132. package/dist/search-builder-r18.d.ts +0 -32
  133. package/dist/search-builder-r18.js +0 -9
  134. package/dist/search-builder-r18.js.map +0 -1
  135. package/dist/search-builder.cjs +0 -525
  136. package/dist/search-builder.cjs.map +0 -1
  137. package/dist/search-builder.d.cts +0 -4
  138. package/dist/search-builder.d.ts +0 -4
  139. package/dist/search-builder.js +0 -12
  140. package/dist/search-builder.js.map +0 -1
  141. package/dist/user-search.cjs +0 -301
  142. package/dist/user-search.cjs.map +0 -1
  143. package/dist/user-search.d.cts +0 -66
  144. package/dist/user-search.d.ts +0 -66
  145. package/dist/user-search.js +0 -9
  146. package/dist/user-search.js.map +0 -1
  147. package/dist/util/jsonp.cjs +0 -63
  148. package/dist/util/jsonp.cjs.map +0 -1
  149. package/dist/util/jsonp.d.cts +0 -13
  150. package/dist/util/jsonp.d.ts +0 -13
  151. package/dist/util/jsonp.js +0 -7
  152. package/dist/util/jsonp.js.map +0 -1
  153. package/dist/util/type.cjs +0 -19
  154. package/dist/util/type.cjs.map +0 -1
  155. package/dist/util/type.d.cts +0 -4
  156. package/dist/util/type.d.ts +0 -4
  157. package/dist/util/type.js +0 -1
  158. package/dist/util/type.js.map +0 -1
  159. package/dist/util/unzipp.cjs +0 -47
  160. package/dist/util/unzipp.cjs.map +0 -1
  161. package/dist/util/unzipp.d.cts +0 -3
  162. package/dist/util/unzipp.d.ts +0 -3
  163. package/dist/util/unzipp.js +0 -7
  164. package/dist/util/unzipp.js.map +0 -1
package/dist/ranking.cjs DELETED
@@ -1,674 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/ranking.ts
21
- var ranking_exports = {};
22
- __export(ranking_exports, {
23
- default: () => RankingBuilder
24
- });
25
- module.exports = __toCommonJS(ranking_exports);
26
-
27
- // src/params.ts
28
- var RankingType = {
29
- Daily: "d",
30
- Weekly: "w",
31
- Monthly: "m",
32
- Quarterly: "q"
33
- };
34
- var BooleanNumber = {
35
- True: 1,
36
- False: 0
37
- };
38
- var Fields = {
39
- /** 小説名 */
40
- title: "t",
41
- /** Nコード */
42
- ncode: "n",
43
- /** 作者のユーザID(数値) */
44
- userid: "u",
45
- /** 作者名 */
46
- writer: "w",
47
- /** 小説のあらすじ */
48
- story: "s",
49
- /** 大ジャンル */
50
- biggenre: "bg",
51
- /** ジャンル */
52
- genre: "g",
53
- /** キーワード */
54
- keyword: "k",
55
- /** 初回掲載日 */
56
- general_firstup: "gf",
57
- /** 最終掲載日 */
58
- general_lastup: "gl",
59
- /** 連載の場合は1、短編の場合は2 */
60
- noveltype: "nt",
61
- /** 短編小説と完結済小説は0となっています。連載中は1です。 */
62
- end: "e",
63
- /** 全掲載部分数 */
64
- general_all_no: "ga",
65
- /** 小説文字数 */
66
- length: "l",
67
- /** 読了時間(分単位) */
68
- time: "ti",
69
- /** 長期連載停止中 */
70
- isstop: "i",
71
- /** 登録必須キーワードに「R15」が含まれる場合は1、それ以外は0です。 */
72
- isr15: "isr",
73
- /** 登録必須キーワードに「ボーイズラブ」が含まれる場合は1、それ以外は0です。 */
74
- isbl: "ibl",
75
- /** 登録必須キーワードに「ガールズラブ」が含まれる場合は1、それ以外は0です。 */
76
- isgl: "igl",
77
- /** 登録必須キーワードに「残酷な描写あり」が含まれる場合は1、それ以外は0です。 */
78
- iszankoku: "izk",
79
- /** 登録必須キーワードに「異世界転生」が含まれる場合は1、それ以外は0です。 */
80
- istensei: "its",
81
- /** 登録必須キーワードに「異世界転移」が含まれる場合は1、それ以外は0です。 */
82
- istenni: "iti",
83
- /** 総合評価ポイント */
84
- global_point: "gp",
85
- /** 日間ポイント */
86
- daily_point: "dp",
87
- /** 週間ポイント */
88
- weekly_point: "wp",
89
- /** 月間ポイント */
90
- monthly_point: "mp",
91
- /** 四半期ポイント */
92
- quarter_point: "qp",
93
- /** 年間ポイント */
94
- yearly_point: "yp",
95
- /** ブックマーク数 */
96
- fav_novel_cnt: "f",
97
- /** 感想数 */
98
- impression_cnt: "imp",
99
- /** レビュー数 */
100
- review_cnt: "r",
101
- /** 評価ポイント */
102
- all_point: "a",
103
- /** 評価者数 */
104
- all_hyoka_cnt: "ah",
105
- /** 挿絵の数 */
106
- sasie_cnt: "sa",
107
- /** 会話率 */
108
- kaiwaritu: "ka",
109
- /** 小説の更新日時 */
110
- novelupdated_at: "nu",
111
- /**
112
- * 最終更新日時
113
- * システム用で小説更新時とは関係ありません
114
- */
115
- updated_at: "ua"
116
- };
117
- var R18Site = {
118
- /** ノクターンノベルズ(男性向け) */
119
- Nocturne: 1,
120
- /** ムーンライトノベルズ(女性向け) */
121
- MoonLight: 2,
122
- /** ムーンライトノベルズ(BL) */
123
- MoonLightBL: 3,
124
- /** ミッドナイトノベルズ(大人向け) */
125
- Midnight: 4
126
- };
127
- var R18SiteNotation = {
128
- [R18Site.Nocturne]: "\u30CE\u30AF\u30BF\u30FC\u30F3\u30CE\u30D9\u30EB\u30BA(\u7537\u6027\u5411\u3051)",
129
- [R18Site.MoonLight]: "\u30E0\u30FC\u30F3\u30E9\u30A4\u30C8\u30CE\u30D9\u30EB\u30BA(\u5973\u6027\u5411\u3051)",
130
- [R18Site.MoonLightBL]: "\u30E0\u30FC\u30F3\u30E9\u30A4\u30C8\u30CE\u30D9\u30EB\u30BA(BL)",
131
- [R18Site.Midnight]: "\u30DF\u30C3\u30C9\u30CA\u30A4\u30C8\u30CE\u30D9\u30EB\u30BA(\u5927\u4EBA\u5411\u3051)"
132
- };
133
- var BigGenre = {
134
- /** 恋愛 */
135
- Renai: 1,
136
- /** ファンタジー */
137
- Fantasy: 2,
138
- /** 文芸 */
139
- Bungei: 3,
140
- /** SF */
141
- Sf: 4,
142
- /** その他 */
143
- Sonota: 99,
144
- /** ノンジャンル */
145
- NonGenre: 98
146
- };
147
- var BigGenreNotation = {
148
- [BigGenre.Renai]: "\u604B\u611B",
149
- [BigGenre.Fantasy]: "\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC",
150
- [BigGenre.Bungei]: "\u6587\u82B8",
151
- [BigGenre.Sf]: "SF",
152
- [BigGenre.Sonota]: "\u305D\u306E\u4ED6",
153
- [BigGenre.NonGenre]: "\u30CE\u30F3\u30B8\u30E3\u30F3\u30EB"
154
- };
155
- var Genre = {
156
- /** 異世界〔恋愛〕*/
157
- RenaiIsekai: 101,
158
- /** 現実世界〔恋愛〕*/
159
- RenaiGenjitsusekai: 102,
160
- /** ハイファンタジー〔ファンタジー〕*/
161
- FantasyHigh: 201,
162
- /** ローファンタジー〔ファンタジー〕*/
163
- FantasyLow: 202,
164
- /** 純文学〔文芸〕*/
165
- BungeiJyunbungei: 301,
166
- /** ヒューマンドラマ〔文芸〕*/
167
- BungeiHumanDrama: 302,
168
- /** 歴史〔文芸〕*/
169
- BungeiHistory: 303,
170
- /** 推理〔文芸〕*/
171
- BungeiSuiri: 304,
172
- /** ホラー〔文芸〕*/
173
- BungeiHorror: 305,
174
- /** アクション〔文芸〕*/
175
- BungeiAction: 306,
176
- /** コメディー〔文芸〕*/
177
- BungeiComedy: 307,
178
- /** VRゲーム〔SF〕*/
179
- SfVrgame: 401,
180
- /** 宇宙〔SF〕*/
181
- SfSpace: 402,
182
- /** 空想科学〔SF〕*/
183
- SfKuusoukagaku: 403,
184
- /** パニック〔SF〕*/
185
- SfPanic: 404,
186
- /** 童話〔その他〕*/
187
- SonotaDouwa: 9901,
188
- /** 詩〔その他〕*/
189
- SonotaShi: 9902,
190
- /** エッセイ〔その他〕*/
191
- SonotaEssei: 9903,
192
- /** リプレイ〔その他〕*/
193
- SonotaReplay: 9904,
194
- /** その他〔その他〕 */
195
- SonotaSonota: 9999,
196
- /** ノンジャンル〔ノンジャンル〕*/
197
- NonGenre: 9801
198
- };
199
- var GenreNotation = {
200
- [Genre.RenaiIsekai]: "\u7570\u4E16\u754C\u3014\u604B\u611B\u3015",
201
- [Genre.RenaiGenjitsusekai]: "\u73FE\u5B9F\u4E16\u754C\u3014\u604B\u611B\u3015",
202
- [Genre.FantasyHigh]: "\u30CF\u30A4\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC\u3014\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC\u3015",
203
- [Genre.FantasyLow]: "\u30ED\u30FC\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC\u3014\u30D5\u30A1\u30F3\u30BF\u30B8\u30FC\u3015",
204
- [Genre.BungeiJyunbungei]: "\u7D14\u6587\u5B66\u3014\u6587\u82B8\u3015",
205
- [Genre.BungeiHumanDrama]: "\u30D2\u30E5\u30FC\u30DE\u30F3\u30C9\u30E9\u30DE\u3014\u6587\u82B8\u3015",
206
- [Genre.BungeiHistory]: "\u6B74\u53F2\u3014\u6587\u82B8\u3015",
207
- [Genre.BungeiSuiri]: "\u63A8\u7406\u3014\u6587\u82B8\u3015",
208
- [Genre.BungeiHorror]: "\u30DB\u30E9\u30FC\u3014\u6587\u82B8\u3015",
209
- [Genre.BungeiAction]: "\u30A2\u30AF\u30B7\u30E7\u30F3\u3014\u6587\u82B8\u3015",
210
- [Genre.BungeiComedy]: "\u30B3\u30E1\u30C7\u30A3\u30FC\u3014\u6587\u82B8\u3015",
211
- [Genre.SfVrgame]: "VR\u30B2\u30FC\u30E0\u3014SF\u3015",
212
- [Genre.SfSpace]: "\u5B87\u5B99\u3014SF\u3015",
213
- [Genre.SfKuusoukagaku]: "\u7A7A\u60F3\u79D1\u5B66\u3014SF\u3015",
214
- [Genre.SfPanic]: "\u30D1\u30CB\u30C3\u30AF\u3014SF\u3015",
215
- [Genre.SonotaDouwa]: "\u7AE5\u8A71\u3014\u305D\u306E\u4ED6\u3015",
216
- [Genre.SonotaShi]: "\u8A69\u3014\u305D\u306E\u4ED6\u3015",
217
- [Genre.SonotaEssei]: "\u30A8\u30C3\u30BB\u30A4\u3014\u305D\u306E\u4ED6\u3015",
218
- [Genre.SonotaReplay]: "\u30EA\u30D7\u30EC\u30A4\u3014\u305D\u306E\u4ED6\u3015",
219
- [Genre.SonotaSonota]: "\u305D\u306E\u4ED6\u3014\u305D\u306E\u4ED6\u3015",
220
- [Genre.NonGenre]: "\u30CE\u30F3\u30B8\u30E3\u30F3\u30EB\u3014\u30CE\u30F3\u30B8\u30E3\u30F3\u30EB\u3015"
221
- };
222
- var StopParam = {
223
- /** 長期連載停止中を除きます */
224
- NoStopping: 1,
225
- /** 長期連載停止中のみ取得します */
226
- Stopping: 2
227
- };
228
-
229
- // src/search-builder.ts
230
- var SearchBuilderBase = class {
231
- /**
232
- * constructor
233
- * @private
234
- */
235
- constructor(params = {}, api) {
236
- this.params = params;
237
- this.api = api;
238
- }
239
- static distinct(array) {
240
- return Array.from(new Set(array));
241
- }
242
- static array2string(n) {
243
- if (Array.isArray(n)) {
244
- return this.distinct(n).join("-");
245
- } else {
246
- return n.toString();
247
- }
248
- }
249
- /**
250
- *
251
- * @return {SearchBuilder} this
252
- */
253
- limit(num) {
254
- this.set({ lim: num });
255
- return this;
256
- }
257
- /**
258
- *
259
- * @return {SearchBuilder} this
260
- */
261
- start(num) {
262
- this.set({ st: num });
263
- return this;
264
- }
265
- /**
266
- *
267
- * @return {SearchBuilder} this
268
- */
269
- page(no, count = 20) {
270
- return this.limit(count).start(no * count);
271
- }
272
- /**
273
- * 出力順序を指定する。指定しない場合は新着順となります。
274
- * old 古い順
275
- * @param {TOrder} order 出力順序
276
- * @return {SearchBuilder} this
277
- */
278
- order(order) {
279
- this.set({ order });
280
- return this;
281
- }
282
- /**
283
- * gzip圧縮する。
284
- *
285
- * 転送量上限を減らすためにも推奨
286
- * @param {GzipLevel} level gzip圧縮レベル(1~5)
287
- * @return {SearchBuilder} this
288
- */
289
- gzip(level) {
290
- this.set({ gzip: level });
291
- return this;
292
- }
293
- /**
294
- * クエリパラメータをセットする
295
- * @private
296
- * @return {SearchBuilder} this
297
- */
298
- set(obj) {
299
- this.params = { ...this.params, ...obj };
300
- return this;
301
- }
302
- /**
303
- * クエリパラメータを削除する
304
- */
305
- unset(key) {
306
- delete this.params[key];
307
- return this;
308
- }
309
- };
310
- var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilderBase {
311
- /**
312
- * a
313
- * @return {SearchBuilder} this
314
- */
315
- word(word) {
316
- this.set({ word });
317
- return this;
318
- }
319
- /**
320
- *
321
- * @return {SearchBuilder} this
322
- */
323
- notWord(word) {
324
- this.set({ notword: word });
325
- return this;
326
- }
327
- /**
328
- *
329
- * @return {SearchBuilder} this
330
- */
331
- byTitle(bool = true) {
332
- this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
333
- return this;
334
- }
335
- /**
336
- *
337
- * @return {SearchBuilder} this
338
- */
339
- byOutline(bool = true) {
340
- this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
341
- return this;
342
- }
343
- /**
344
- *
345
- * @return {SearchBuilder} this
346
- */
347
- byKeyword(bool = true) {
348
- this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
349
- return this;
350
- }
351
- /**
352
- *
353
- * @return {SearchBuilder} this
354
- */
355
- byAuthor(bool = true) {
356
- this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
357
- return this;
358
- }
359
- /**
360
- *
361
- * @return {SearchBuilder} this
362
- */
363
- isBL(bool = true) {
364
- if (bool) {
365
- this.set({ isbl: BooleanNumber.True });
366
- } else {
367
- this.set({ notbl: BooleanNumber.True });
368
- }
369
- return this;
370
- }
371
- /**
372
- *
373
- * @return {SearchBuilder} this
374
- */
375
- isGL(bool = true) {
376
- if (bool) {
377
- this.set({ isgl: BooleanNumber.True });
378
- } else {
379
- this.set({ notgl: BooleanNumber.True });
380
- }
381
- return this;
382
- }
383
- /**
384
- *
385
- * @return {SearchBuilder} this
386
- */
387
- isZankoku(bool = true) {
388
- if (bool) {
389
- this.set({ iszankoku: BooleanNumber.True });
390
- } else {
391
- this.set({ notzankoku: BooleanNumber.True });
392
- }
393
- return this;
394
- }
395
- /**
396
- *
397
- * @return {SearchBuilder} this
398
- */
399
- isTensei(bool = true) {
400
- if (bool) {
401
- this.set({ istensei: BooleanNumber.True });
402
- } else {
403
- this.set({ nottensei: BooleanNumber.True });
404
- }
405
- return this;
406
- }
407
- /**
408
- *
409
- * @return {SearchBuilder} this
410
- */
411
- isTenni(bool = true) {
412
- if (bool) {
413
- this.set({ istenni: BooleanNumber.True });
414
- } else {
415
- this.set({ nottenni: BooleanNumber.True });
416
- }
417
- return this;
418
- }
419
- /**
420
- *
421
- * @return {SearchBuilder} this
422
- */
423
- isTT() {
424
- this.set({ istt: BooleanNumber.True });
425
- return this;
426
- }
427
- /**
428
- *
429
- * @return {SearchBuilder} this
430
- */
431
- length(length) {
432
- this.set({ length: _NovelSearchBuilderBase.array2string(length) });
433
- return this;
434
- }
435
- kaiwaritu(min, max) {
436
- let n;
437
- if (max != null) {
438
- n = `${min}-${max}`;
439
- } else {
440
- n = min;
441
- }
442
- this.set({ kaiwaritu: n });
443
- return this;
444
- }
445
- /**
446
- *
447
- * @return {SearchBuilder} this
448
- */
449
- sasie(num) {
450
- this.set({ sasie: _NovelSearchBuilderBase.array2string(num) });
451
- return this;
452
- }
453
- /**
454
- *
455
- * @return {SearchBuilder} this
456
- */
457
- time(num) {
458
- this.set({ time: _NovelSearchBuilderBase.array2string(num) });
459
- return this;
460
- }
461
- /**
462
- *
463
- * @return {SearchBuilder} this
464
- */
465
- ncode(ncodes) {
466
- this.set({ ncode: _NovelSearchBuilderBase.array2string(ncodes) });
467
- return this;
468
- }
469
- /**
470
- *
471
- * @return {SearchBuilder} this
472
- */
473
- type(type) {
474
- this.set({ type });
475
- return this;
476
- }
477
- /**
478
- *
479
- * @return {SearchBuilder} this
480
- */
481
- buntai(buntai) {
482
- this.set({ buntai: _NovelSearchBuilderBase.array2string(buntai) });
483
- return this;
484
- }
485
- /**
486
- *
487
- * @return {SearchBuilder} this
488
- */
489
- isStop(bool = true) {
490
- this.set({ stop: bool ? StopParam.Stopping : StopParam.NoStopping });
491
- return this;
492
- }
493
- /**
494
- *
495
- * @return {SearchBuilder} this
496
- */
497
- isPickup(bool = true) {
498
- this.set({ ispickup: bool ? BooleanNumber.True : BooleanNumber.False });
499
- return this;
500
- }
501
- lastUpdate(x, y) {
502
- let date;
503
- if (typeof x == "string") {
504
- date = x;
505
- } else if (x instanceof Date && y instanceof Date) {
506
- date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(
507
- y.getTime() / 1e3
508
- )}`;
509
- } else {
510
- date = `${x}-${y}`;
511
- }
512
- this.set({ lastup: date });
513
- return this;
514
- }
515
- lastNovelUpdate(x, y) {
516
- let date;
517
- if (typeof x == "string") {
518
- date = x;
519
- } else if (x instanceof Date && y instanceof Date) {
520
- date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(
521
- y.getTime() / 1e3
522
- )}`;
523
- } else {
524
- date = `${x}-${y}`;
525
- }
526
- this.set({ lastupdate: date });
527
- return this;
528
- }
529
- /**
530
- * なろう小説APIへの検索リクエストを実行する
531
- * @returns {Promise<NarouSearchResults>} 検索結果
532
- */
533
- execute() {
534
- return this.api.executeNovel(this.params);
535
- }
536
- };
537
- var SearchBuilder = class _SearchBuilder extends NovelSearchBuilderBase {
538
- /**
539
- *
540
- * @return {SearchBuilder} this
541
- */
542
- bigGenre(genre) {
543
- this.set({ biggenre: _SearchBuilder.array2string(genre) });
544
- return this;
545
- }
546
- /**
547
- *
548
- * @return {SearchBuilder} this
549
- */
550
- notBigGenre(genre) {
551
- this.set({ notbiggenre: _SearchBuilder.array2string(genre) });
552
- return this;
553
- }
554
- /**
555
- *
556
- * @return {SearchBuilder} this
557
- */
558
- genre(genre) {
559
- this.set({ genre: _SearchBuilder.array2string(genre) });
560
- return this;
561
- }
562
- /**
563
- *
564
- * @return {SearchBuilder} this
565
- */
566
- notGenre(genre) {
567
- this.set({ notgenre: _SearchBuilder.array2string(genre) });
568
- return this;
569
- }
570
- /**
571
- *
572
- * @return {SearchBuilder} this
573
- */
574
- userId(ids) {
575
- this.set({ userid: _SearchBuilder.array2string(ids) });
576
- return this;
577
- }
578
- /**
579
- *
580
- * @return {SearchBuilder} this
581
- */
582
- isR15(bool = true) {
583
- if (bool) {
584
- this.set({ isr15: 1 });
585
- } else {
586
- this.set({ notr15: 1 });
587
- }
588
- return this;
589
- }
590
- /**
591
- *
592
- * @return {SearchBuilder} this
593
- */
594
- fields(fields) {
595
- this.set({ of: _SearchBuilder.array2string(fields) });
596
- return this;
597
- }
598
- opt(option) {
599
- this.set({ opt: _SearchBuilder.array2string(option) });
600
- return this;
601
- }
602
- };
603
-
604
- // src/ranking.ts
605
- var import_date_fns = require("date-fns");
606
- var dateFormat = "yyyyMMdd";
607
- var RankingBuilder = class {
608
- /**
609
- * constructor
610
- * @private
611
- */
612
- constructor(params = {}, api) {
613
- this.params = params;
614
- this.api = api;
615
- this.date$ = (0, import_date_fns.addDays)(Date.now(), -1);
616
- this.type$ = RankingType.Daily;
617
- }
618
- date(date) {
619
- this.date$ = date;
620
- return this;
621
- }
622
- type(type) {
623
- this.type$ = type;
624
- return this;
625
- }
626
- /**
627
- * gzip圧縮する。
628
- *
629
- * 転送量上限を減らすためにも推奨
630
- * @param {GzipLevel} level gzip圧縮レベル(1~5)
631
- * @return {RankingBuilder} this
632
- */
633
- gzip(level) {
634
- this.set({ gzip: level });
635
- return this;
636
- }
637
- /**
638
- * クエリパラメータをセットする
639
- * @private
640
- * @return {RankingBuilder} this
641
- */
642
- set(obj) {
643
- Object.assign(this.params, obj);
644
- return this;
645
- }
646
- /**
647
- * なろう小説APIへのリクエストを実行する
648
- * @returns ランキング
649
- */
650
- execute() {
651
- const date = (0, import_date_fns.format)(this.date$, dateFormat);
652
- this.set({ rtype: `${date}-${this.type$}` });
653
- return this.api.executeRanking(this.params);
654
- }
655
- async executeWithFields(fields = [], opt) {
656
- const ranking = await this.execute();
657
- const fields$ = Array.isArray(fields) ? fields.length == 0 ? [] : [...fields, Fields.ncode] : [fields, Fields.ncode];
658
- const rankingNcodes = ranking.map(({ ncode }) => ncode);
659
- const builder = new SearchBuilder({}, this.api);
660
- builder.fields(fields$);
661
- if (opt) {
662
- builder.opt(opt);
663
- }
664
- builder.ncode(rankingNcodes);
665
- builder.limit(ranking.length);
666
- const result = await builder.execute();
667
- return ranking.map((r) => ({
668
- ...r,
669
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
670
- ...result.values.find((novel) => novel.ncode == r.ncode)
671
- }));
672
- }
673
- };
674
- //# sourceMappingURL=ranking.cjs.map