narou 0.6.0 → 0.7.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.
- package/dist/index.browser.d.ts +30 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +123 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.common.d.ts +10 -0
- package/dist/index.common.d.ts.map +1 -0
- package/dist/index.common.js +23 -0
- package/dist/index.common.js.map +1 -0
- package/dist/index.d.ts +2 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -17
- package/dist/index.js.map +1 -1
- package/dist/narou-ranking-results.d.ts +4 -3
- package/dist/narou-ranking-results.d.ts.map +1 -1
- package/dist/narou-search-results.d.ts +49 -19
- package/dist/narou-search-results.d.ts.map +1 -1
- package/dist/narou-search-results.js +16 -2
- package/dist/narou-search-results.js.map +1 -1
- package/dist/narou.d.ts +4 -4
- package/dist/narou.d.ts.map +1 -1
- package/dist/narou.js.map +1 -1
- package/dist/params.d.ts +223 -171
- package/dist/params.d.ts.map +1 -1
- package/dist/params.js +206 -150
- package/dist/params.js.map +1 -1
- package/dist/ranking-history.d.ts +2 -2
- package/dist/ranking-history.d.ts.map +1 -1
- package/dist/ranking.d.ts +13 -15
- package/dist/ranking.d.ts.map +1 -1
- package/dist/ranking.js +9 -23
- package/dist/ranking.js.map +1 -1
- package/dist/search-builder-r18.d.ts +12 -6
- package/dist/search-builder-r18.d.ts.map +1 -1
- package/dist/search-builder-r18.js +13 -18
- package/dist/search-builder-r18.js.map +1 -1
- package/dist/search-builder.d.ts +53 -47
- package/dist/search-builder.d.ts.map +1 -1
- package/dist/search-builder.js +164 -140
- package/dist/search-builder.js.map +1 -1
- package/dist/util/jsonp.d.ts.map +1 -1
- package/dist/util/jsonp.js +2 -1
- package/dist/util/jsonp.js.map +1 -1
- package/dist/util/type.d.ts +4 -0
- package/dist/util/type.d.ts.map +1 -0
- package/dist/util/type.js +3 -0
- package/dist/util/type.js.map +1 -0
- package/dist/util/url.d.ts +1 -1
- package/dist.es2015/index.browser.js +50 -0
- package/dist.es2015/index.browser.js.map +1 -0
- package/dist.es2015/index.common.js +6 -0
- package/dist.es2015/index.common.js.map +1 -0
- package/dist.es2015/index.js +7 -9
- package/dist.es2015/index.js.map +1 -1
- package/dist.es2015/narou-search-results.js +14 -1
- package/dist.es2015/narou-search-results.js.map +1 -1
- package/dist.es2015/narou.js.map +1 -1
- package/dist.es2015/params.js +204 -149
- package/dist.es2015/params.js.map +1 -1
- package/dist.es2015/ranking.js +6 -18
- package/dist.es2015/ranking.js.map +1 -1
- package/dist.es2015/search-builder-r18.js +14 -19
- package/dist.es2015/search-builder-r18.js.map +1 -1
- package/dist.es2015/search-builder.js +104 -101
- package/dist.es2015/search-builder.js.map +1 -1
- package/dist.es2015/util/jsonp.js +1 -0
- package/dist.es2015/util/jsonp.js.map +1 -1
- package/dist.es2015/util/type.js +2 -0
- package/dist.es2015/util/type.js.map +1 -0
- package/dist.esm/index.browser.js +102 -0
- package/dist.esm/index.browser.js.map +1 -0
- package/dist.esm/index.common.js +6 -0
- package/dist.esm/index.common.js.map +1 -0
- package/dist.esm/index.js +7 -6
- package/dist.esm/index.js.map +1 -1
- package/dist.esm/narou-search-results.js +14 -1
- package/dist.esm/narou-search-results.js.map +1 -1
- package/dist.esm/narou.js.map +1 -1
- package/dist.esm/params.js +205 -149
- package/dist.esm/params.js.map +1 -1
- package/dist.esm/ranking.js +6 -19
- package/dist.esm/ranking.js.map +1 -1
- package/dist.esm/search-builder-r18.js +14 -19
- package/dist.esm/search-builder-r18.js.map +1 -1
- package/dist.esm/search-builder.js +163 -140
- package/dist.esm/search-builder.js.map +1 -1
- package/dist.esm/util/jsonp.js +2 -1
- package/dist.esm/util/jsonp.js.map +1 -1
- package/dist.esm/util/type.js +2 -0
- package/dist.esm/util/type.js.map +1 -0
- package/package.json +22 -46
- package/src/index.browser.ts +63 -0
- package/src/index.common.ts +31 -0
- package/src/index.ts +12 -20
- package/src/narou-ranking-results.ts +6 -2
- package/src/narou-search-results.ts +70 -20
- package/src/narou.ts +13 -6
- package/src/params.ts +277 -175
- package/src/ranking-history.ts +2 -2
- package/src/ranking.ts +50 -26
- package/src/search-builder-r18.ts +30 -20
- package/src/search-builder.ts +149 -128
- package/src/util/jsonp.ts +3 -0
- package/src/util/type.ts +3 -0
- package/package-lock.json +0 -3328
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { SearchBuilderBase } from "./search-builder";
|
|
2
|
+
import NarouSearchResults, {
|
|
3
|
+
NarouSearchResult,
|
|
4
|
+
SearchResultR18Fields,
|
|
5
|
+
} from "./narou-search-results";
|
|
6
|
+
import { R18Site, SearchResultFieldNames, R18Fields } from "./params";
|
|
7
|
+
|
|
8
|
+
export type DefaultR18SearchResultFields = keyof Omit<
|
|
9
|
+
NarouSearchResult,
|
|
10
|
+
"weekly_unique" | "noveltype" | "biggenre" | "genre" | "isr15" | "id"
|
|
11
|
+
>;
|
|
4
12
|
|
|
5
13
|
/**
|
|
6
14
|
* 18禁API検索ヘルパー
|
|
7
15
|
* @class SearchBuilderR18
|
|
8
16
|
*/
|
|
9
|
-
export default class SearchBuilderR18
|
|
17
|
+
export default class SearchBuilderR18<
|
|
18
|
+
T extends SearchResultFieldNames = DefaultR18SearchResultFields
|
|
19
|
+
> extends SearchBuilderBase<T> {
|
|
10
20
|
/**
|
|
11
21
|
* なろう小説APIへの検索リクエストを実行する
|
|
12
22
|
* @override
|
|
13
|
-
* @returns {Promise<
|
|
23
|
+
* @returns {Promise<NarouSearchResults>} 検索結果
|
|
14
24
|
*/
|
|
15
|
-
execute(): Promise<
|
|
25
|
+
execute(): Promise<NarouSearchResults<T>> {
|
|
16
26
|
return this.api.executeNovel18(this.params);
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
r18Site(sites: R18Site | R18Site[]) {
|
|
20
|
-
|
|
21
|
-
if (Array.isArray(sites)) {
|
|
22
|
-
nocgenre = (<string[]>(<any>sites)).join("-");
|
|
23
|
-
} else {
|
|
24
|
-
nocgenre = sites;
|
|
25
|
-
}
|
|
26
|
-
this.set({ nocgenre });
|
|
30
|
+
this.set({ nocgenre: SearchBuilderBase.array2string(sites) });
|
|
27
31
|
return this;
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -32,13 +36,19 @@ export default class SearchBuilderR18 extends SearchBuilder {
|
|
|
32
36
|
* @return {SearchBuilder} this
|
|
33
37
|
*/
|
|
34
38
|
xid(ids: number | number[]) {
|
|
35
|
-
|
|
36
|
-
if (Array.isArray(ids)) {
|
|
37
|
-
xid = (<string[]>(<any>ids)).join("-");
|
|
38
|
-
} else {
|
|
39
|
-
xid = ids;
|
|
40
|
-
}
|
|
41
|
-
this.set({ xid });
|
|
39
|
+
this.set({ xid: SearchBuilderBase.array2string(ids) });
|
|
42
40
|
return this;
|
|
43
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @return {SearchBuilder} this
|
|
46
|
+
*/
|
|
47
|
+
fields<TFields extends R18Fields>(
|
|
48
|
+
fields: TFields | TFields[]
|
|
49
|
+
): SearchBuilderR18<SearchResultR18Fields<R18Fields>> {
|
|
50
|
+
this.set({ of: SearchBuilderBase.array2string(fields) });
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
return this as any;
|
|
53
|
+
}
|
|
44
54
|
}
|
package/src/search-builder.ts
CHANGED
|
@@ -1,30 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import api from "./narou";
|
|
3
|
-
import NarouNovelFetch from "./narou-fetch";
|
|
4
|
-
import INarouSearchResults from "./narou-search-results";
|
|
5
|
-
import { BigGenre, Genre } from "./params";
|
|
1
|
+
import NarouNovel from "./narou";
|
|
6
2
|
import {
|
|
3
|
+
NarouSearchResult,
|
|
4
|
+
SearchResultFields,
|
|
5
|
+
SerachResultOptionalFields,
|
|
6
|
+
} from "./narou-search-results";
|
|
7
|
+
import NarouSearchResults from "./narou-search-results";
|
|
8
|
+
import {
|
|
9
|
+
BigGenre,
|
|
10
|
+
BooleanNumber,
|
|
11
|
+
SearchResultFieldNames,
|
|
12
|
+
Genre,
|
|
13
|
+
Stop,
|
|
7
14
|
SearchParams,
|
|
8
15
|
Fields,
|
|
9
16
|
Order,
|
|
10
17
|
Buntai,
|
|
11
18
|
NovelType,
|
|
12
19
|
GzipLevel,
|
|
20
|
+
OptionalFields,
|
|
13
21
|
} from "./params";
|
|
22
|
+
import { Join } from "./util/type";
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
export type DefaultSearchResultFields = keyof Omit<
|
|
25
|
+
NarouSearchResult,
|
|
26
|
+
"weekly_unique" | "noveltype" | "nocgenre" | "xid"
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
export abstract class SearchBuilderBase<T extends SearchResultFieldNames> {
|
|
20
30
|
/**
|
|
21
31
|
* constructor
|
|
22
32
|
* @private
|
|
23
33
|
*/
|
|
24
|
-
constructor(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
constructor(protected params: SearchParams = {}, protected api: NarouNovel) {}
|
|
35
|
+
|
|
36
|
+
static distinct<T>(array: T[]): T[] {
|
|
37
|
+
return Array.from(new Set(array));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static array2string<T extends string | number>(n: T | readonly T[]): Join<T> {
|
|
41
|
+
if (Array.isArray(n)) {
|
|
42
|
+
return this.distinct(n).join("-") as Join<T>;
|
|
43
|
+
} else {
|
|
44
|
+
return n.toString() as Join<T>;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
28
47
|
|
|
29
48
|
/**
|
|
30
49
|
* a
|
|
@@ -48,62 +67,8 @@ export default class SearchBuilder {
|
|
|
48
67
|
*
|
|
49
68
|
* @return {SearchBuilder} this
|
|
50
69
|
*/
|
|
51
|
-
byTitle(bool
|
|
52
|
-
this.set({ title: bool ?
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @return {SearchBuilder} this
|
|
59
|
-
*/
|
|
60
|
-
byOutline(bool: boolean = true): this {
|
|
61
|
-
this.set({ ex: bool ? 1 : 0 });
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
* @return {SearchBuilder} this
|
|
68
|
-
*/
|
|
69
|
-
byKeyword(bool: boolean = true): this {
|
|
70
|
-
this.set({ keyword: bool ? 1 : 0 });
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @return {SearchBuilder} this
|
|
77
|
-
*/
|
|
78
|
-
byAuthor(bool: boolean = true): this {
|
|
79
|
-
this.set({ wname: bool ? 1 : 0 });
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* @return {SearchBuilder} this
|
|
86
|
-
*/
|
|
87
|
-
bigGenre(genre: BigGenre | BigGenre[]): this {
|
|
88
|
-
this.set({ biggenre: array2string(genre) });
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @return {SearchBuilder} this
|
|
95
|
-
*/
|
|
96
|
-
notBigGenre(genre: BigGenre | BigGenre[]): this {
|
|
97
|
-
this.set({ notbiggenre: array2string(genre) });
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @return {SearchBuilder} this
|
|
104
|
-
*/
|
|
105
|
-
genre(genre: Genre | Genre[]): this {
|
|
106
|
-
this.set({ genre: array2string(genre) });
|
|
70
|
+
byTitle(bool = true): this {
|
|
71
|
+
this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
107
72
|
return this;
|
|
108
73
|
}
|
|
109
74
|
|
|
@@ -111,8 +76,8 @@ export default class SearchBuilder {
|
|
|
111
76
|
*
|
|
112
77
|
* @return {SearchBuilder} this
|
|
113
78
|
*/
|
|
114
|
-
|
|
115
|
-
this.set({
|
|
79
|
+
byOutline(bool = true): this {
|
|
80
|
+
this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
116
81
|
return this;
|
|
117
82
|
}
|
|
118
83
|
|
|
@@ -120,8 +85,8 @@ export default class SearchBuilder {
|
|
|
120
85
|
*
|
|
121
86
|
* @return {SearchBuilder} this
|
|
122
87
|
*/
|
|
123
|
-
|
|
124
|
-
this.set({
|
|
88
|
+
byKeyword(bool = true): this {
|
|
89
|
+
this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
125
90
|
return this;
|
|
126
91
|
}
|
|
127
92
|
|
|
@@ -129,12 +94,8 @@ export default class SearchBuilder {
|
|
|
129
94
|
*
|
|
130
95
|
* @return {SearchBuilder} this
|
|
131
96
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.set({ isr15: 1 });
|
|
135
|
-
} else {
|
|
136
|
-
this.set({ notr15: 1 });
|
|
137
|
-
}
|
|
97
|
+
byAuthor(bool = true): this {
|
|
98
|
+
this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
138
99
|
return this;
|
|
139
100
|
}
|
|
140
101
|
|
|
@@ -142,11 +103,11 @@ export default class SearchBuilder {
|
|
|
142
103
|
*
|
|
143
104
|
* @return {SearchBuilder} this
|
|
144
105
|
*/
|
|
145
|
-
isBL(bool
|
|
106
|
+
isBL(bool = true): this {
|
|
146
107
|
if (bool) {
|
|
147
|
-
this.set({ isbl:
|
|
108
|
+
this.set({ isbl: BooleanNumber.True });
|
|
148
109
|
} else {
|
|
149
|
-
this.set({ notbl:
|
|
110
|
+
this.set({ notbl: BooleanNumber.True });
|
|
150
111
|
}
|
|
151
112
|
return this;
|
|
152
113
|
}
|
|
@@ -155,11 +116,11 @@ export default class SearchBuilder {
|
|
|
155
116
|
*
|
|
156
117
|
* @return {SearchBuilder} this
|
|
157
118
|
*/
|
|
158
|
-
isGL(bool
|
|
119
|
+
isGL(bool = true): this {
|
|
159
120
|
if (bool) {
|
|
160
|
-
this.set({ isgl:
|
|
121
|
+
this.set({ isgl: BooleanNumber.True });
|
|
161
122
|
} else {
|
|
162
|
-
this.set({ notgl:
|
|
123
|
+
this.set({ notgl: BooleanNumber.True });
|
|
163
124
|
}
|
|
164
125
|
return this;
|
|
165
126
|
}
|
|
@@ -168,11 +129,11 @@ export default class SearchBuilder {
|
|
|
168
129
|
*
|
|
169
130
|
* @return {SearchBuilder} this
|
|
170
131
|
*/
|
|
171
|
-
isZankoku(bool
|
|
132
|
+
isZankoku(bool = true): this {
|
|
172
133
|
if (bool) {
|
|
173
|
-
this.set({ iszankoku:
|
|
134
|
+
this.set({ iszankoku: BooleanNumber.True });
|
|
174
135
|
} else {
|
|
175
|
-
this.set({ notzankoku:
|
|
136
|
+
this.set({ notzankoku: BooleanNumber.True });
|
|
176
137
|
}
|
|
177
138
|
return this;
|
|
178
139
|
}
|
|
@@ -181,11 +142,11 @@ export default class SearchBuilder {
|
|
|
181
142
|
*
|
|
182
143
|
* @return {SearchBuilder} this
|
|
183
144
|
*/
|
|
184
|
-
isTensei(bool
|
|
145
|
+
isTensei(bool = true): this {
|
|
185
146
|
if (bool) {
|
|
186
|
-
this.set({ istensei:
|
|
147
|
+
this.set({ istensei: BooleanNumber.True });
|
|
187
148
|
} else {
|
|
188
|
-
this.set({ nottensei:
|
|
149
|
+
this.set({ nottensei: BooleanNumber.True });
|
|
189
150
|
}
|
|
190
151
|
return this;
|
|
191
152
|
}
|
|
@@ -194,11 +155,11 @@ export default class SearchBuilder {
|
|
|
194
155
|
*
|
|
195
156
|
* @return {SearchBuilder} this
|
|
196
157
|
*/
|
|
197
|
-
isTenni(bool
|
|
158
|
+
isTenni(bool = true): this {
|
|
198
159
|
if (bool) {
|
|
199
|
-
this.set({ istenni:
|
|
160
|
+
this.set({ istenni: BooleanNumber.True });
|
|
200
161
|
} else {
|
|
201
|
-
this.set({ nottenni:
|
|
162
|
+
this.set({ nottenni: BooleanNumber.True });
|
|
202
163
|
}
|
|
203
164
|
return this;
|
|
204
165
|
}
|
|
@@ -208,7 +169,7 @@ export default class SearchBuilder {
|
|
|
208
169
|
* @return {SearchBuilder} this
|
|
209
170
|
*/
|
|
210
171
|
isTT(): this {
|
|
211
|
-
this.set({ istt:
|
|
172
|
+
this.set({ istt: BooleanNumber.True });
|
|
212
173
|
return this;
|
|
213
174
|
}
|
|
214
175
|
|
|
@@ -217,7 +178,7 @@ export default class SearchBuilder {
|
|
|
217
178
|
* @return {SearchBuilder} this
|
|
218
179
|
*/
|
|
219
180
|
length(length: number | number[]): this {
|
|
220
|
-
this.set({ length: array2string(length) });
|
|
181
|
+
this.set({ length: SearchBuilderBase.array2string(length) });
|
|
221
182
|
return this;
|
|
222
183
|
}
|
|
223
184
|
|
|
@@ -244,7 +205,7 @@ export default class SearchBuilder {
|
|
|
244
205
|
* @return {SearchBuilder} this
|
|
245
206
|
*/
|
|
246
207
|
sasie(num: number | number[]): this {
|
|
247
|
-
this.set({ sasie: array2string(num) });
|
|
208
|
+
this.set({ sasie: SearchBuilderBase.array2string(num) });
|
|
248
209
|
return this;
|
|
249
210
|
}
|
|
250
211
|
|
|
@@ -253,7 +214,7 @@ export default class SearchBuilder {
|
|
|
253
214
|
* @return {SearchBuilder} this
|
|
254
215
|
*/
|
|
255
216
|
time(num: number | number[]): this {
|
|
256
|
-
this.set({ time: array2string(num) });
|
|
217
|
+
this.set({ time: SearchBuilderBase.array2string(num) });
|
|
257
218
|
return this;
|
|
258
219
|
}
|
|
259
220
|
|
|
@@ -262,7 +223,7 @@ export default class SearchBuilder {
|
|
|
262
223
|
* @return {SearchBuilder} this
|
|
263
224
|
*/
|
|
264
225
|
ncode(ncodes: string | string[]): this {
|
|
265
|
-
this.set({ ncode: array2string(ncodes) });
|
|
226
|
+
this.set({ ncode: SearchBuilderBase.array2string(ncodes) });
|
|
266
227
|
return this;
|
|
267
228
|
}
|
|
268
229
|
|
|
@@ -280,7 +241,7 @@ export default class SearchBuilder {
|
|
|
280
241
|
* @return {SearchBuilder} this
|
|
281
242
|
*/
|
|
282
243
|
buntai(buntai: Buntai | Buntai[]): this {
|
|
283
|
-
this.set({ buntai: array2string(buntai) });
|
|
244
|
+
this.set({ buntai: SearchBuilderBase.array2string(buntai) });
|
|
284
245
|
return this;
|
|
285
246
|
}
|
|
286
247
|
|
|
@@ -288,8 +249,8 @@ export default class SearchBuilder {
|
|
|
288
249
|
*
|
|
289
250
|
* @return {SearchBuilder} this
|
|
290
251
|
*/
|
|
291
|
-
isStop(bool
|
|
292
|
-
this.set({ stop: bool ?
|
|
252
|
+
isStop(bool = true): this {
|
|
253
|
+
this.set({ stop: bool ? Stop.Stopping : Stop.NoStopping });
|
|
293
254
|
return this;
|
|
294
255
|
}
|
|
295
256
|
|
|
@@ -297,8 +258,8 @@ export default class SearchBuilder {
|
|
|
297
258
|
*
|
|
298
259
|
* @return {SearchBuilder} this
|
|
299
260
|
*/
|
|
300
|
-
isPickup(bool
|
|
301
|
-
this.set({ ispickup: bool ?
|
|
261
|
+
isPickup(bool = true): this {
|
|
262
|
+
this.set({ ispickup: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
302
263
|
return this;
|
|
303
264
|
}
|
|
304
265
|
|
|
@@ -326,15 +287,6 @@ export default class SearchBuilder {
|
|
|
326
287
|
return this;
|
|
327
288
|
}
|
|
328
289
|
|
|
329
|
-
/**
|
|
330
|
-
*
|
|
331
|
-
* @return {SearchBuilder} this
|
|
332
|
-
*/
|
|
333
|
-
fields(fields: Fields | Fields[]): this {
|
|
334
|
-
this.set({ of: array2string(fields) });
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
290
|
/**
|
|
339
291
|
*
|
|
340
292
|
* @return {SearchBuilder} this
|
|
@@ -357,14 +309,10 @@ export default class SearchBuilder {
|
|
|
357
309
|
*
|
|
358
310
|
* @return {SearchBuilder} this
|
|
359
311
|
*/
|
|
360
|
-
page(no: number, count
|
|
312
|
+
page(no: number, count = 20): this {
|
|
361
313
|
return this.limit(count).start(no * count);
|
|
362
314
|
}
|
|
363
315
|
|
|
364
|
-
opt(option: "weekly" | undefined): this {
|
|
365
|
-
return this.set({ opt: option });
|
|
366
|
-
}
|
|
367
|
-
|
|
368
316
|
/**
|
|
369
317
|
* 出力順序を指定する。指定しない場合は新着順となります。
|
|
370
318
|
*
|
|
@@ -427,19 +375,92 @@ export default class SearchBuilder {
|
|
|
427
375
|
* なろう小説APIへの検索リクエストを実行する
|
|
428
376
|
* @returns {Promise<NarouSearchResults>} 検索結果
|
|
429
377
|
*/
|
|
430
|
-
execute(): Promise<
|
|
378
|
+
execute(): Promise<NarouSearchResults<T>> {
|
|
431
379
|
return this.api.executeNovel(this.params);
|
|
432
380
|
}
|
|
433
381
|
}
|
|
434
382
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
383
|
+
/**
|
|
384
|
+
* 検索ヘルパー
|
|
385
|
+
* @class SearchBuilder
|
|
386
|
+
*/
|
|
387
|
+
export default class SearchBuilder<
|
|
388
|
+
T extends keyof NarouSearchResult = DefaultSearchResultFields,
|
|
389
|
+
TOpt extends keyof NarouSearchResult = never
|
|
390
|
+
> extends SearchBuilderBase<T | TOpt> {
|
|
391
|
+
/**
|
|
392
|
+
*
|
|
393
|
+
* @return {SearchBuilder} this
|
|
394
|
+
*/
|
|
395
|
+
bigGenre(genre: BigGenre | BigGenre[]): this {
|
|
396
|
+
this.set({ biggenre: SearchBuilderBase.array2string(genre) });
|
|
397
|
+
return this;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
*
|
|
402
|
+
* @return {SearchBuilder} this
|
|
403
|
+
*/
|
|
404
|
+
notBigGenre(genre: BigGenre | BigGenre[]): this {
|
|
405
|
+
this.set({ notbiggenre: SearchBuilderBase.array2string(genre) });
|
|
406
|
+
return this;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
*
|
|
411
|
+
* @return {SearchBuilder} this
|
|
412
|
+
*/
|
|
413
|
+
genre(genre: Genre | Genre[]): this {
|
|
414
|
+
this.set({ genre: SearchBuilderBase.array2string(genre) });
|
|
415
|
+
return this;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
*
|
|
420
|
+
* @return {SearchBuilder} this
|
|
421
|
+
*/
|
|
422
|
+
notGenre(genre: Genre | Genre[]): this {
|
|
423
|
+
this.set({ notgenre: SearchBuilderBase.array2string(genre) });
|
|
424
|
+
return this;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
*
|
|
429
|
+
* @return {SearchBuilder} this
|
|
430
|
+
*/
|
|
431
|
+
userId(ids: number | number[]): this {
|
|
432
|
+
this.set({ userid: SearchBuilderBase.array2string(ids) });
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
*
|
|
438
|
+
* @return {SearchBuilder} this
|
|
439
|
+
*/
|
|
440
|
+
isR15(bool = true): this {
|
|
441
|
+
if (bool) {
|
|
442
|
+
this.set({ isr15: 1 });
|
|
443
|
+
} else {
|
|
444
|
+
this.set({ notr15: 1 });
|
|
445
|
+
}
|
|
446
|
+
return this;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
*
|
|
451
|
+
* @return {SearchBuilder} this
|
|
452
|
+
*/
|
|
453
|
+
fields<TFields extends Fields>(
|
|
454
|
+
fields: TFields | readonly TFields[]
|
|
455
|
+
): SearchBuilder<SearchResultFields<TFields>, TOpt> {
|
|
456
|
+
this.set({ of: SearchBuilderBase.array2string(fields) });
|
|
457
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
458
|
+
return this as any;
|
|
459
|
+
}
|
|
438
460
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return n.toString();
|
|
461
|
+
opt<TFields extends OptionalFields>(
|
|
462
|
+
option: TFields | TFields[]
|
|
463
|
+
): SearchBuilder<T, SerachResultOptionalFields<TFields>> {
|
|
464
|
+
return this.set({ opt: SearchBuilderBase.array2string(option) }) as any;
|
|
444
465
|
}
|
|
445
466
|
}
|
package/src/util/jsonp.ts
CHANGED
|
@@ -10,6 +10,7 @@ type CallbackId<Prefix extends string = string> = `${Prefix}${number}`;
|
|
|
10
10
|
|
|
11
11
|
declare global {
|
|
12
12
|
interface Window {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
14
|
[key: CallbackId]: (data: any) => void;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -18,6 +19,8 @@ export type JsonpOption = {
|
|
|
18
19
|
param?: string;
|
|
19
20
|
timeout?: number;
|
|
20
21
|
};
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
21
24
|
const noop = function () {};
|
|
22
25
|
|
|
23
26
|
export function jsonp<T>(
|
package/src/util/type.ts
ADDED