narou 1.2.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 (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -37
  3. package/dist/index.browser.cjs +87 -1359
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.d.cts +11 -19
  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 -1410
  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 +28 -21
  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 +28 -37
  22. package/pnpm-lock.yaml +1325 -1100
  23. package/src/index.ts +5 -1
  24. package/src/narou-fetch.ts +4 -3
  25. package/src/narou-jsonp.ts +4 -2
  26. package/src/narou.ts +50 -13
  27. package/src/params.ts +1 -1
  28. package/src/ranking.ts +20 -11
  29. package/src/search-builder-r18.ts +6 -2
  30. package/src/search-builder.ts +7 -3
  31. package/src/user-search.ts +9 -2
  32. package/dist/chunk-3A5MHPWL.js +0 -37
  33. package/dist/chunk-3A5MHPWL.js.map +0 -1
  34. package/dist/chunk-4ZP5YNWI.js +0 -1
  35. package/dist/chunk-4ZP5YNWI.js.map +0 -1
  36. package/dist/chunk-5UDKQCPJ.js +0 -407
  37. package/dist/chunk-5UDKQCPJ.js.map +0 -1
  38. package/dist/chunk-6BZWV4ZC.js +0 -75
  39. package/dist/chunk-6BZWV4ZC.js.map +0 -1
  40. package/dist/chunk-BQLSW236.js +0 -117
  41. package/dist/chunk-BQLSW236.js.map +0 -1
  42. package/dist/chunk-DEQICAN3.js +0 -94
  43. package/dist/chunk-DEQICAN3.js.map +0 -1
  44. package/dist/chunk-E2H3AJSQ.js +0 -57
  45. package/dist/chunk-E2H3AJSQ.js.map +0 -1
  46. package/dist/chunk-HOBLKBZ6.js +0 -452
  47. package/dist/chunk-HOBLKBZ6.js.map +0 -1
  48. package/dist/chunk-IPDEGCWU.js +0 -39
  49. package/dist/chunk-IPDEGCWU.js.map +0 -1
  50. package/dist/chunk-LQLNWSWV.js +0 -26
  51. package/dist/chunk-LQLNWSWV.js.map +0 -1
  52. package/dist/chunk-PLEM2AOH.js +0 -44
  53. package/dist/chunk-PLEM2AOH.js.map +0 -1
  54. package/dist/chunk-RNHRR56W.js +0 -25
  55. package/dist/chunk-RNHRR56W.js.map +0 -1
  56. package/dist/chunk-VUZIISP2.js +0 -23
  57. package/dist/chunk-VUZIISP2.js.map +0 -1
  58. package/dist/chunk-VZVUANDN.js +0 -17
  59. package/dist/chunk-VZVUANDN.js.map +0 -1
  60. package/dist/index.browser.d.ts +0 -55
  61. package/dist/index.browser.js +0 -126
  62. package/dist/index.browser.js.map +0 -1
  63. package/dist/index.common.cjs +0 -1187
  64. package/dist/index.common.cjs.map +0 -1
  65. package/dist/index.common.d.cts +0 -6
  66. package/dist/index.common.d.ts +0 -6
  67. package/dist/index.common.js +0 -76
  68. package/dist/index.common.js.map +0 -1
  69. package/dist/index.d.ts +0 -56
  70. package/dist/index.js +0 -131
  71. package/dist/index.js.map +0 -1
  72. package/dist/narou-DBa12V_l.d.ts +0 -404
  73. package/dist/narou-DCp4aGfA.d.cts +0 -404
  74. package/dist/narou-fetch.cjs +0 -164
  75. package/dist/narou-fetch.cjs.map +0 -1
  76. package/dist/narou-fetch.d.cts +0 -20
  77. package/dist/narou-fetch.d.ts +0 -20
  78. package/dist/narou-fetch.js +0 -10
  79. package/dist/narou-fetch.js.map +0 -1
  80. package/dist/narou-jsonp.cjs +0 -162
  81. package/dist/narou-jsonp.cjs.map +0 -1
  82. package/dist/narou-jsonp.d.cts +0 -13
  83. package/dist/narou-jsonp.d.ts +0 -13
  84. package/dist/narou-jsonp.js +0 -10
  85. package/dist/narou-jsonp.js.map +0 -1
  86. package/dist/narou-ranking-results.cjs +0 -19
  87. package/dist/narou-ranking-results.cjs.map +0 -1
  88. package/dist/narou-ranking-results.d.cts +0 -4
  89. package/dist/narou-ranking-results.d.ts +0 -4
  90. package/dist/narou-ranking-results.js +0 -1
  91. package/dist/narou-ranking-results.js.map +0 -1
  92. package/dist/narou-search-results-C21hWrnL.d.cts +0 -727
  93. package/dist/narou-search-results-DT0YdaBn.d.ts +0 -727
  94. package/dist/narou-search-results.cjs +0 -62
  95. package/dist/narou-search-results.cjs.map +0 -1
  96. package/dist/narou-search-results.d.cts +0 -2
  97. package/dist/narou-search-results.d.ts +0 -2
  98. package/dist/narou-search-results.js +0 -11
  99. package/dist/narou-search-results.js.map +0 -1
  100. package/dist/narou.cjs +0 -112
  101. package/dist/narou.cjs.map +0 -1
  102. package/dist/narou.d.cts +0 -4
  103. package/dist/narou.d.ts +0 -4
  104. package/dist/narou.js +0 -8
  105. package/dist/narou.js.map +0 -1
  106. package/dist/params.cjs +0 -448
  107. package/dist/params.cjs.map +0 -1
  108. package/dist/params.d.cts +0 -2
  109. package/dist/params.d.ts +0 -2
  110. package/dist/params.js +0 -41
  111. package/dist/params.js.map +0 -1
  112. package/dist/ranking-history.cjs +0 -47
  113. package/dist/ranking-history.cjs.map +0 -1
  114. package/dist/ranking-history.d.cts +0 -28
  115. package/dist/ranking-history.d.ts +0 -28
  116. package/dist/ranking-history.js +0 -8
  117. package/dist/ranking-history.js.map +0 -1
  118. package/dist/ranking.cjs +0 -783
  119. package/dist/ranking.cjs.map +0 -1
  120. package/dist/ranking.d.cts +0 -108
  121. package/dist/ranking.d.ts +0 -108
  122. package/dist/ranking.js +0 -10
  123. package/dist/ranking.js.map +0 -1
  124. package/dist/search-builder-r18.cjs +0 -547
  125. package/dist/search-builder-r18.cjs.map +0 -1
  126. package/dist/search-builder-r18.d.cts +0 -45
  127. package/dist/search-builder-r18.d.ts +0 -45
  128. package/dist/search-builder-r18.js +0 -9
  129. package/dist/search-builder-r18.js.map +0 -1
  130. package/dist/search-builder.cjs +0 -591
  131. package/dist/search-builder.cjs.map +0 -1
  132. package/dist/search-builder.d.cts +0 -4
  133. package/dist/search-builder.d.ts +0 -4
  134. package/dist/search-builder.js +0 -12
  135. package/dist/search-builder.js.map +0 -1
  136. package/dist/user-search.cjs +0 -325
  137. package/dist/user-search.cjs.map +0 -1
  138. package/dist/user-search.d.cts +0 -66
  139. package/dist/user-search.d.ts +0 -66
  140. package/dist/user-search.js +0 -9
  141. package/dist/user-search.js.map +0 -1
  142. package/dist/util/date.cjs +0 -51
  143. package/dist/util/date.cjs.map +0 -1
  144. package/dist/util/date.d.cts +0 -21
  145. package/dist/util/date.d.ts +0 -21
  146. package/dist/util/date.js +0 -11
  147. package/dist/util/date.js.map +0 -1
  148. package/dist/util/jsonp.cjs +0 -63
  149. package/dist/util/jsonp.cjs.map +0 -1
  150. package/dist/util/jsonp.d.cts +0 -49
  151. package/dist/util/jsonp.d.ts +0 -49
  152. package/dist/util/jsonp.js +0 -7
  153. package/dist/util/jsonp.js.map +0 -1
  154. package/dist/util/type.cjs +0 -19
  155. package/dist/util/type.cjs.map +0 -1
  156. package/dist/util/type.d.cts +0 -27
  157. package/dist/util/type.d.ts +0 -27
  158. package/dist/util/type.js +0 -1
  159. package/dist/util/type.js.map +0 -1
  160. package/dist/util/unzipp.cjs +0 -47
  161. package/dist/util/unzipp.cjs.map +0 -1
  162. package/dist/util/unzipp.d.cts +0 -12
  163. package/dist/util/unzipp.d.ts +0 -12
  164. package/dist/util/unzipp.js +0 -7
  165. package/dist/util/unzipp.js.map +0 -1
package/dist/ranking.cjs DELETED
@@ -1,783 +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
- * @param params クエリパラメータ
235
- * @param api NarouNovel インスタンス
236
- */
237
- constructor(params = {}, api) {
238
- this.params = params;
239
- this.api = api;
240
- }
241
- /**
242
- * 配列から重複を除去する
243
- * @protected
244
- * @static
245
- * @param array 配列
246
- * @returns 重複を除去した配列
247
- */
248
- static distinct(array) {
249
- return Array.from(new Set(array));
250
- }
251
- /**
252
- * 配列をハイフン区切りの文字列に変換する
253
- * @protected
254
- * @static
255
- * @param n 文字列または数値の配列、あるいは単一の文字列または数値
256
- * @returns ハイフン区切りの文字列
257
- */
258
- static array2string(n) {
259
- if (Array.isArray(n)) {
260
- return this.distinct(n).join("-");
261
- } else {
262
- return n.toString();
263
- }
264
- }
265
- /**
266
- * 取得件数を指定する (lim)
267
- * @param num 取得件数 (1-500)
268
- * @return {this}
269
- */
270
- limit(num) {
271
- this.set({ lim: num });
272
- return this;
273
- }
274
- /**
275
- * 取得開始位置を指定する (st)
276
- * @param num 取得開始位置 (1-)
277
- * @return {this}
278
- */
279
- start(num) {
280
- this.set({ st: num });
281
- return this;
282
- }
283
- /**
284
- * ページ番号と1ページあたりの件数で取得範囲を指定する
285
- * @param no ページ番号 (0-)
286
- * @param count 1ページあたりの件数 (デフォルト: 20)
287
- * @return {this}
288
- */
289
- page(no, count = 20) {
290
- return this.limit(count).start(no * count);
291
- }
292
- /**
293
- * 出力順序を指定する (order)
294
- * 指定しない場合は新着順となります。
295
- * @param {TOrder} order 出力順序
296
- * @return {this}
297
- */
298
- order(order) {
299
- this.set({ order });
300
- return this;
301
- }
302
- /**
303
- * gzip圧縮レベルを指定する (gzip)
304
- *
305
- * 転送量上限を減らすためにも推奨
306
- * @param {GzipLevel} level gzip圧縮レベル(1~5)
307
- * @return {this}
308
- */
309
- gzip(level) {
310
- this.set({ gzip: level });
311
- return this;
312
- }
313
- /**
314
- * クエリパラメータをセットする
315
- * @protected
316
- * @param obj セットするパラメータ
317
- * @return {this}
318
- */
319
- set(obj) {
320
- this.params = { ...this.params, ...obj };
321
- return this;
322
- }
323
- /**
324
- * クエリパラメータを削除する
325
- * @protected
326
- * @param key 削除するパラメータのキー
327
- * @returns {this}
328
- */
329
- unset(key) {
330
- delete this.params[key];
331
- return this;
332
- }
333
- };
334
- var NovelSearchBuilderBase = class _NovelSearchBuilderBase extends SearchBuilderBase {
335
- /**
336
- * 検索語を指定します (word)。
337
- * 半角または全角スペースで区切るとAND抽出になります。部分一致でHITします。
338
- * @param word 検索語
339
- * @return {this}
340
- */
341
- word(word) {
342
- this.set({ word });
343
- return this;
344
- }
345
- /**
346
- * 除外したい単語を指定します (notword)。
347
- * スペースで区切ることにより除外する単語を増やせます。部分一致で除外されます。
348
- * @param word 除外語
349
- * @return {this}
350
- */
351
- notWord(word) {
352
- this.set({ notword: word });
353
- return this;
354
- }
355
- /**
356
- * 検索対象を作品名に限定するかどうかを指定します (title)。
357
- * @param bool trueの場合、作品名を検索対象とする (デフォルト: true)
358
- * @return {this}
359
- */
360
- byTitle(bool = true) {
361
- this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
362
- return this;
363
- }
364
- /**
365
- * 検索対象をあらすじに限定するかどうかを指定します (ex)。
366
- * @param bool trueの場合、あらすじを検索対象とする (デフォルト: true)
367
- * @return {this}
368
- */
369
- byOutline(bool = true) {
370
- this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
371
- return this;
372
- }
373
- /**
374
- * 検索対象をキーワードに限定するかどうかを指定します (keyword)。
375
- * @param bool trueの場合、キーワードを検索対象とする (デフォルト: true)
376
- * @return {this}
377
- */
378
- byKeyword(bool = true) {
379
- this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
380
- return this;
381
- }
382
- /**
383
- * 検索対象を作者名に限定するかどうかを指定します (wname)。
384
- * @param bool trueの場合、作者名を検索対象とする (デフォルト: true)
385
- * @return {this}
386
- */
387
- byAuthor(bool = true) {
388
- this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
389
- return this;
390
- }
391
- /**
392
- * ボーイズラブ作品を抽出または除外します (isbl/notbl)。
393
- * @param bool trueの場合、ボーイズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
394
- * @return {this}
395
- */
396
- isBL(bool = true) {
397
- if (bool) {
398
- this.set({ isbl: BooleanNumber.True });
399
- } else {
400
- this.set({ notbl: BooleanNumber.True });
401
- }
402
- return this;
403
- }
404
- /**
405
- * ガールズラブ作品を抽出または除外します (isgl/notgl)。
406
- * @param bool trueの場合、ガールズラブ作品を抽出する (デフォルト: true)。falseの場合、除外する。
407
- * @return {this}
408
- */
409
- isGL(bool = true) {
410
- if (bool) {
411
- this.set({ isgl: BooleanNumber.True });
412
- } else {
413
- this.set({ notgl: BooleanNumber.True });
414
- }
415
- return this;
416
- }
417
- /**
418
- * 残酷な描写あり作品を抽出または除外します (iszankoku/notzankoku)。
419
- * @param bool trueの場合、残酷な描写あり作品を抽出する (デフォルト: true)。falseの場合、除外する。
420
- * @return {this}
421
- */
422
- isZankoku(bool = true) {
423
- if (bool) {
424
- this.set({ iszankoku: BooleanNumber.True });
425
- } else {
426
- this.set({ notzankoku: BooleanNumber.True });
427
- }
428
- return this;
429
- }
430
- /**
431
- * 異世界転生作品を抽出または除外します (istensei/nottensei)。
432
- * @param bool trueの場合、異世界転生作品を抽出する (デフォルト: true)。falseの場合、除外する。
433
- * @return {this}
434
- */
435
- isTensei(bool = true) {
436
- if (bool) {
437
- this.set({ istensei: BooleanNumber.True });
438
- } else {
439
- this.set({ nottensei: BooleanNumber.True });
440
- }
441
- return this;
442
- }
443
- /**
444
- * 異世界転移作品を抽出または除外します (istenni/nottenni)。
445
- * @param bool trueの場合、異世界転移作品を抽出する (デフォルト: true)。falseの場合、除外する。
446
- * @return {this}
447
- */
448
- isTenni(bool = true) {
449
- if (bool) {
450
- this.set({ istenni: BooleanNumber.True });
451
- } else {
452
- this.set({ nottenni: BooleanNumber.True });
453
- }
454
- return this;
455
- }
456
- /**
457
- * 異世界転生または異世界転移作品を抽出します (istt)。
458
- * @return {this}
459
- */
460
- isTT() {
461
- this.set({ istt: BooleanNumber.True });
462
- return this;
463
- }
464
- /**
465
- * 抽出する作品の文字数を指定します (length)。
466
- * 範囲指定する場合は、最小文字数と最大文字数をハイフン(-)記号で区切ってください。
467
- * @param length 文字数、または[最小文字数, 最大文字数]
468
- * @return {this}
469
- */
470
- length(length) {
471
- this.set({ length: _NovelSearchBuilderBase.array2string(length) });
472
- return this;
473
- }
474
- kaiwaritu(min, max) {
475
- let n;
476
- if (max != null) {
477
- n = `${min}-${max}`;
478
- } else {
479
- n = min;
480
- }
481
- this.set({ kaiwaritu: n });
482
- return this;
483
- }
484
- /**
485
- * 抽出する作品の挿絵数を指定します (sasie)。
486
- * @param num 挿絵数、または[最小挿絵数, 最大挿絵数]
487
- * @return {this}
488
- */
489
- sasie(num) {
490
- this.set({ sasie: _NovelSearchBuilderBase.array2string(num) });
491
- return this;
492
- }
493
- /**
494
- * 抽出する作品の予想読了時間を分単位で指定します (time)。
495
- * @param num 読了時間(分)、または[最小読了時間, 最大読了時間]
496
- * @return {this}
497
- */
498
- time(num) {
499
- this.set({ time: _NovelSearchBuilderBase.array2string(num) });
500
- return this;
501
- }
502
- /**
503
- * Nコードを指定して取得します (ncode)。
504
- * @param ncodes Nコード、またはNコードの配列
505
- * @return {this}
506
- */
507
- ncode(ncodes) {
508
- this.set({ ncode: _NovelSearchBuilderBase.array2string(ncodes) });
509
- return this;
510
- }
511
- /**
512
- * 抽出する小説タイプを指定します (type)。
513
- * @param type 小説タイプ (t: 短編, r: 連載中, er: 完結済連載小説, ter: 短編と完結済連載小説, re: 連載中と完結済連載小説)
514
- * @return {this}
515
- */
516
- type(type) {
517
- this.set({ type });
518
- return this;
519
- }
520
- /**
521
- * 抽出する作品の文体を指定します (buntai)。
522
- * 複数指定する場合はハイフン(-)で区切ってください。
523
- * @param buntai 文体コード、または文体コードの配列
524
- * @return {this}
525
- */
526
- buntai(buntai) {
527
- this.set({ buntai: _NovelSearchBuilderBase.array2string(buntai) });
528
- return this;
529
- }
530
- /**
531
- * 連載停止中作品に関する指定をします (stop)。
532
- * @param bool trueの場合、長期連載停止中のみ取得する (デフォルト: true)。falseの場合、長期連載停止中を除外する。
533
- * @return {this}
534
- */
535
- isStop(bool = true) {
536
- this.set({ stop: bool ? StopParam.Stopping : StopParam.NoStopping });
537
- return this;
538
- }
539
- /**
540
- * ピックアップ作品のみを取得します (ispickup)。
541
- * @return {this}
542
- */
543
- isPickup() {
544
- this.set({ ispickup: BooleanNumber.True });
545
- return this;
546
- }
547
- lastUpdate(x, y) {
548
- let date;
549
- if (typeof x == "string") {
550
- date = x;
551
- } else if (x instanceof Date && y instanceof Date) {
552
- date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(
553
- y.getTime() / 1e3
554
- )}`;
555
- } else {
556
- date = `${x}-${y}`;
557
- }
558
- this.set({ lastup: date });
559
- return this;
560
- }
561
- lastNovelUpdate(x, y) {
562
- let date;
563
- if (typeof x == "string") {
564
- date = x;
565
- } else if (x instanceof Date && y instanceof Date) {
566
- date = `${Math.floor(x.getTime() / 1e3)}-${Math.floor(
567
- y.getTime() / 1e3
568
- )}`;
569
- } else {
570
- date = `${x}-${y}`;
571
- }
572
- this.set({ lastupdate: date });
573
- return this;
574
- }
575
- /**
576
- * なろう小説APIへの検索リクエストを実行する
577
- * @returns {Promise<NarouSearchResults>} 検索結果
578
- */
579
- execute() {
580
- return this.api.executeNovel(this.params);
581
- }
582
- };
583
- var SearchBuilder = class _SearchBuilder extends NovelSearchBuilderBase {
584
- /**
585
- * 大ジャンルを指定して取得します (biggenre)。
586
- * 複数指定する場合はハイフン(-)で区切ってください。
587
- * @param genre 大ジャンルコード、または大ジャンルコードの配列
588
- * @return {this}
589
- */
590
- bigGenre(genre) {
591
- this.set({ biggenre: _SearchBuilder.array2string(genre) });
592
- return this;
593
- }
594
- /**
595
- * 除外したい大ジャンルを指定します (notbiggenre)。
596
- * 複数指定する場合はハイフン(-)で区切ってください。
597
- * @param genre 除外する大ジャンルコード、または大ジャンルコードの配列
598
- * @return {this}
599
- */
600
- notBigGenre(genre) {
601
- this.set({ notbiggenre: _SearchBuilder.array2string(genre) });
602
- return this;
603
- }
604
- /**
605
- * ジャンルを指定して取得します (genre)。
606
- * 複数指定する場合はハイフン(-)で区切ってください。
607
- * @param genre ジャンルコード、またはジャンルコードの配列
608
- * @return {this}
609
- */
610
- genre(genre) {
611
- this.set({ genre: _SearchBuilder.array2string(genre) });
612
- return this;
613
- }
614
- /**
615
- * 除外したいジャンルを指定します (notgenre)。
616
- * 複数指定する場合はハイフン(-)で区切ってください。
617
- * @param genre 除外するジャンルコード、またはジャンルコードの配列
618
- * @return {this}
619
- */
620
- notGenre(genre) {
621
- this.set({ notgenre: _SearchBuilder.array2string(genre) });
622
- return this;
623
- }
624
- /**
625
- * ユーザIDを指定して取得します (userid)。
626
- * 複数指定する場合はハイフン(-)で区切ってください。
627
- * @param ids ユーザID、またはユーザIDの配列
628
- * @return {this}
629
- */
630
- userId(ids) {
631
- this.set({ userid: _SearchBuilder.array2string(ids) });
632
- return this;
633
- }
634
- /**
635
- * R15作品を抽出または除外します (isr15/notr15)。
636
- * @param bool trueの場合、R15作品を抽出する (デフォルト: true)。falseの場合、除外する。
637
- * @return {this}
638
- */
639
- isR15(bool = true) {
640
- if (bool) {
641
- this.set({ isr15: 1 });
642
- } else {
643
- this.set({ notr15: 1 });
644
- }
645
- return this;
646
- }
647
- /**
648
- * 出力する項目を個別に指定します (of)。
649
- * 未指定時は全項目出力されます。転送量軽減のため、このパラメータの使用が推奨されます。
650
- * 複数項目を出力する場合はハイフン(-)記号で区切ってください。
651
- * @param fields 出力するフィールド名、またはフィールド名の配列
652
- * @return {SearchBuilder<SearchResultFields<TFields>, TOpt>} 型が更新されたビルダー
653
- */
654
- fields(fields) {
655
- this.set({ of: _SearchBuilder.array2string(fields) });
656
- return this;
657
- }
658
- /**
659
- * 出力オプション項目を指定します (opt)。
660
- * 複数項目を出力する場合はハイフン(-)記号で区切ってください。
661
- * @param option 出力するオプションフィールド名、またはオプションフィールド名の配列
662
- * @return {SearchBuilder<T, SearchResultOptionalFields<TFields>>} 型が更新されたビルダー
663
- */
664
- opt(option) {
665
- this.set({ opt: _SearchBuilder.array2string(option) });
666
- return this;
667
- }
668
- };
669
-
670
- // src/util/date.ts
671
- function formatDate(date) {
672
- const year = date.getFullYear();
673
- const month = String(date.getMonth() + 1).padStart(2, "0");
674
- const day = String(date.getDate()).padStart(2, "0");
675
- return `${year}${month}${day}`;
676
- }
677
- function addDays(date, days) {
678
- const result = new Date(date);
679
- result.setDate(result.getDate() + days);
680
- return result;
681
- }
682
-
683
- // src/ranking.ts
684
- var RankingBuilder = class {
685
- /**
686
- * constructor
687
- * @param params - 初期クエリパラメータ
688
- * @param api - API実行クラスのインスタンス
689
- * @private
690
- */
691
- constructor(params = {}, api) {
692
- this.params = params;
693
- this.api = api;
694
- this.date$ = addDays(/* @__PURE__ */ new Date(), -1);
695
- this.type$ = RankingType.Daily;
696
- }
697
- /**
698
- * ランキング集計対象の日付を指定します。
699
- *
700
- * - 日間: 任意の日付
701
- * - 週間: 火曜日の日付
702
- * - 月間・四半期: 1日の日付
703
- *
704
- * @param date 集計対象の日付
705
- * @returns {RankingBuilder} this
706
- * @see https://dev.syosetu.com/man/rankapi/
707
- */
708
- date(date) {
709
- this.date$ = date;
710
- return this;
711
- }
712
- /**
713
- * ランキング種別を指定します。
714
- * @param type ランキング種別
715
- * @returns {RankingBuilder} this
716
- * @see https://dev.syosetu.com/man/rankapi/
717
- */
718
- type(type) {
719
- this.type$ = type;
720
- return this;
721
- }
722
- /**
723
- * gzip圧縮する。
724
- *
725
- * 転送量上限を減らすためにも推奨
726
- * @param {GzipLevel} level gzip圧縮レベル(1~5)
727
- * @return {RankingBuilder} this
728
- */
729
- gzip(level) {
730
- this.set({ gzip: level });
731
- return this;
732
- }
733
- /**
734
- * クエリパラメータを内部的にセットします。
735
- * @param obj - セットするパラメータオブジェクト
736
- * @returns {RankingBuilder} this
737
- * @private
738
- */
739
- set(obj) {
740
- Object.assign(this.params, obj);
741
- return this;
742
- }
743
- /**
744
- * 設定されたパラメータに基づき、なろう小説ランキングAPIへのリクエストを実行します。
745
- *
746
- * 返される結果には、Nコード、ポイント、順位が含まれます。
747
- * @returns {Promise<NarouRankingResult[]>} ランキング結果の配列
748
- * @see https://dev.syosetu.com/man/rankapi/#output
749
- */
750
- execute() {
751
- const date = formatDate(this.date$);
752
- this.set({ rtype: `${date}-${this.type$}` });
753
- return this.api.executeRanking(this.params);
754
- }
755
- /**
756
- * ランキングAPIを実行し、取得したNコードを元になろう小説APIで詳細情報を取得して結合します。
757
- *
758
- * @template TFields - 取得する小説情報のフィールド型
759
- * @template TOpt - オプショナルな取得フィールドの型
760
- * @param fields - 取得するフィールドの配列 (省略時はデフォルトフィールド)
761
- * @param opt - オプショナルな取得フィールド (`weekly` など)
762
- * @returns {Promise<RankingResult<SearchResultFields<TFields>>[]>} 詳細情報を含むランキング結果の配列
763
- */
764
- async executeWithFields(fields = [], opt) {
765
- const ranking = await this.execute();
766
- const fields$ = Array.isArray(fields) ? fields.length == 0 ? [] : [...fields, Fields.ncode] : [fields, Fields.ncode];
767
- const rankingNcodes = ranking.map(({ ncode }) => ncode);
768
- const builder = new SearchBuilder({}, this.api);
769
- builder.fields(fields$);
770
- if (opt) {
771
- builder.opt(opt);
772
- }
773
- builder.ncode(rankingNcodes);
774
- builder.limit(ranking.length);
775
- const result = await builder.execute();
776
- return ranking.map((r) => ({
777
- ...r,
778
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
779
- ...result.values.find((novel) => novel.ncode == r.ncode)
780
- }));
781
- }
782
- };
783
- //# sourceMappingURL=ranking.cjs.map