narou 0.6.2 → 0.7.2
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.map +1 -1
- package/dist/index.browser.js +5 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.common.d.ts +7 -5
- package/dist/index.common.d.ts.map +1 -1
- package/dist/index.common.js +11 -3
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- 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 +225 -173
- 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 +10 -12
- package/dist/ranking.d.ts.map +1 -1
- package/dist/ranking.js +7 -19
- package/dist/ranking.js.map +1 -1
- package/dist/search-builder-r18.d.ts +13 -6
- package/dist/search-builder-r18.d.ts.map +1 -1
- package/dist/search-builder-r18.js +18 -18
- package/dist/search-builder-r18.js.map +1 -1
- package/dist/search-builder.d.ts +54 -48
- package/dist/search-builder.d.ts.map +1 -1
- package/dist/search-builder.js +166 -138
- 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.map +1 -1
- package/dist.es2015/index.common.js +4 -3
- package/dist.es2015/index.common.js.map +1 -1
- 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 +3 -14
- package/dist.es2015/ranking.js.map +1 -1
- package/dist.es2015/search-builder-r18.js +19 -19
- package/dist.es2015/search-builder-r18.js.map +1 -1
- package/dist.es2015/search-builder.js +105 -99
- 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.map +1 -1
- package/dist.esm/index.common.js +4 -3
- package/dist.esm/index.common.js.map +1 -1
- 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 +4 -15
- package/dist.esm/ranking.js.map +1 -1
- package/dist.esm/search-builder-r18.js +19 -19
- package/dist.esm/search-builder-r18.js.map +1 -1
- package/dist.esm/search-builder.js +165 -138
- 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 +23 -46
- package/src/index.browser.ts +2 -2
- package/src/index.common.ts +20 -4
- package/src/index.ts +2 -2
- 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 +279 -177
- package/src/ranking-history.ts +2 -2
- package/src/ranking.ts +47 -23
- package/src/search-builder-r18.ts +45 -20
- package/src/search-builder.ts +154 -128
- package/src/util/jsonp.ts +3 -0
- package/src/util/type.ts +3 -0
- package/package-lock.json +0 -3328
|
@@ -1,29 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { SearchBuilderBase } from "./search-builder";
|
|
2
|
+
import NarouSearchResults, {
|
|
3
|
+
NarouSearchResult,
|
|
4
|
+
SearchResultR18Fields,
|
|
5
|
+
SerachResultOptionalFields,
|
|
6
|
+
} from "./narou-search-results";
|
|
7
|
+
import {
|
|
8
|
+
R18Site,
|
|
9
|
+
SearchResultFieldNames,
|
|
10
|
+
R18Fields,
|
|
11
|
+
OptionalFields,
|
|
12
|
+
} from "./params";
|
|
13
|
+
|
|
14
|
+
export type DefaultR18SearchResultFields = keyof Omit<
|
|
15
|
+
NarouSearchResult,
|
|
16
|
+
"weekly_unique" | "noveltype" | "biggenre" | "genre" | "isr15" | "id"
|
|
17
|
+
>;
|
|
4
18
|
|
|
5
19
|
/**
|
|
6
20
|
* 18禁API検索ヘルパー
|
|
7
21
|
* @class SearchBuilderR18
|
|
8
22
|
*/
|
|
9
|
-
export default class SearchBuilderR18
|
|
23
|
+
export default class SearchBuilderR18<
|
|
24
|
+
T extends SearchResultFieldNames = DefaultR18SearchResultFields,
|
|
25
|
+
TOpt extends keyof NarouSearchResult = never
|
|
26
|
+
> extends SearchBuilderBase<T | TOpt> {
|
|
10
27
|
/**
|
|
11
28
|
* なろう小説APIへの検索リクエストを実行する
|
|
12
29
|
* @override
|
|
13
|
-
* @returns {Promise<
|
|
30
|
+
* @returns {Promise<NarouSearchResults>} 検索結果
|
|
14
31
|
*/
|
|
15
|
-
execute(): Promise<
|
|
32
|
+
execute(): Promise<NarouSearchResults<T | TOpt>> {
|
|
16
33
|
return this.api.executeNovel18(this.params);
|
|
17
34
|
}
|
|
18
35
|
|
|
19
36
|
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 });
|
|
37
|
+
this.set({ nocgenre: SearchBuilderBase.array2string(sites) });
|
|
27
38
|
return this;
|
|
28
39
|
}
|
|
29
40
|
|
|
@@ -32,13 +43,27 @@ export default class SearchBuilderR18 extends SearchBuilder {
|
|
|
32
43
|
* @return {SearchBuilder} this
|
|
33
44
|
*/
|
|
34
45
|
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 });
|
|
46
|
+
this.set({ xid: SearchBuilderBase.array2string(ids) });
|
|
42
47
|
return this;
|
|
43
48
|
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @return {SearchBuilder} this
|
|
53
|
+
*/
|
|
54
|
+
fields<TFields extends R18Fields>(
|
|
55
|
+
fields: TFields | TFields[]
|
|
56
|
+
): SearchBuilderR18<SearchResultR18Fields<R18Fields>> {
|
|
57
|
+
this.set({ of: SearchBuilderBase.array2string(fields) });
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
return this as any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
opt<TFields extends OptionalFields>(
|
|
63
|
+
option: TFields | TFields[]
|
|
64
|
+
): SearchBuilderR18<T, SerachResultOptionalFields<TFields>> {
|
|
65
|
+
this.set({ opt: SearchBuilderBase.array2string(option) });
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
return this as any;
|
|
68
|
+
}
|
|
44
69
|
}
|
package/src/search-builder.ts
CHANGED
|
@@ -1,28 +1,50 @@
|
|
|
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
|
+
StopParam,
|
|
7
14
|
SearchParams,
|
|
8
15
|
Fields,
|
|
9
16
|
Order,
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
BuntaiParam,
|
|
18
|
+
NovelTypeParam,
|
|
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
34
|
constructor(protected params: SearchParams = {}, protected api: NarouNovel) {}
|
|
25
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
|
+
}
|
|
47
|
+
|
|
26
48
|
/**
|
|
27
49
|
* a
|
|
28
50
|
* @return {SearchBuilder} this
|
|
@@ -45,62 +67,8 @@ export default class SearchBuilder {
|
|
|
45
67
|
*
|
|
46
68
|
* @return {SearchBuilder} this
|
|
47
69
|
*/
|
|
48
|
-
byTitle(bool
|
|
49
|
-
this.set({ title: bool ?
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @return {SearchBuilder} this
|
|
56
|
-
*/
|
|
57
|
-
byOutline(bool: boolean = true): this {
|
|
58
|
-
this.set({ ex: bool ? 1 : 0 });
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* @return {SearchBuilder} this
|
|
65
|
-
*/
|
|
66
|
-
byKeyword(bool: boolean = true): this {
|
|
67
|
-
this.set({ keyword: bool ? 1 : 0 });
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @return {SearchBuilder} this
|
|
74
|
-
*/
|
|
75
|
-
byAuthor(bool: boolean = true): this {
|
|
76
|
-
this.set({ wname: bool ? 1 : 0 });
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @return {SearchBuilder} this
|
|
83
|
-
*/
|
|
84
|
-
bigGenre(genre: BigGenre | BigGenre[]): this {
|
|
85
|
-
this.set({ biggenre: array2string(genre) });
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* @return {SearchBuilder} this
|
|
92
|
-
*/
|
|
93
|
-
notBigGenre(genre: BigGenre | BigGenre[]): this {
|
|
94
|
-
this.set({ notbiggenre: array2string(genre) });
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
* @return {SearchBuilder} this
|
|
101
|
-
*/
|
|
102
|
-
genre(genre: Genre | Genre[]): this {
|
|
103
|
-
this.set({ genre: array2string(genre) });
|
|
70
|
+
byTitle(bool = true): this {
|
|
71
|
+
this.set({ title: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
104
72
|
return this;
|
|
105
73
|
}
|
|
106
74
|
|
|
@@ -108,8 +76,8 @@ export default class SearchBuilder {
|
|
|
108
76
|
*
|
|
109
77
|
* @return {SearchBuilder} this
|
|
110
78
|
*/
|
|
111
|
-
|
|
112
|
-
this.set({
|
|
79
|
+
byOutline(bool = true): this {
|
|
80
|
+
this.set({ ex: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
113
81
|
return this;
|
|
114
82
|
}
|
|
115
83
|
|
|
@@ -117,8 +85,8 @@ export default class SearchBuilder {
|
|
|
117
85
|
*
|
|
118
86
|
* @return {SearchBuilder} this
|
|
119
87
|
*/
|
|
120
|
-
|
|
121
|
-
this.set({
|
|
88
|
+
byKeyword(bool = true): this {
|
|
89
|
+
this.set({ keyword: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
122
90
|
return this;
|
|
123
91
|
}
|
|
124
92
|
|
|
@@ -126,12 +94,8 @@ export default class SearchBuilder {
|
|
|
126
94
|
*
|
|
127
95
|
* @return {SearchBuilder} this
|
|
128
96
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.set({ isr15: 1 });
|
|
132
|
-
} else {
|
|
133
|
-
this.set({ notr15: 1 });
|
|
134
|
-
}
|
|
97
|
+
byAuthor(bool = true): this {
|
|
98
|
+
this.set({ wname: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
135
99
|
return this;
|
|
136
100
|
}
|
|
137
101
|
|
|
@@ -139,11 +103,11 @@ export default class SearchBuilder {
|
|
|
139
103
|
*
|
|
140
104
|
* @return {SearchBuilder} this
|
|
141
105
|
*/
|
|
142
|
-
isBL(bool
|
|
106
|
+
isBL(bool = true): this {
|
|
143
107
|
if (bool) {
|
|
144
|
-
this.set({ isbl:
|
|
108
|
+
this.set({ isbl: BooleanNumber.True });
|
|
145
109
|
} else {
|
|
146
|
-
this.set({ notbl:
|
|
110
|
+
this.set({ notbl: BooleanNumber.True });
|
|
147
111
|
}
|
|
148
112
|
return this;
|
|
149
113
|
}
|
|
@@ -152,11 +116,11 @@ export default class SearchBuilder {
|
|
|
152
116
|
*
|
|
153
117
|
* @return {SearchBuilder} this
|
|
154
118
|
*/
|
|
155
|
-
isGL(bool
|
|
119
|
+
isGL(bool = true): this {
|
|
156
120
|
if (bool) {
|
|
157
|
-
this.set({ isgl:
|
|
121
|
+
this.set({ isgl: BooleanNumber.True });
|
|
158
122
|
} else {
|
|
159
|
-
this.set({ notgl:
|
|
123
|
+
this.set({ notgl: BooleanNumber.True });
|
|
160
124
|
}
|
|
161
125
|
return this;
|
|
162
126
|
}
|
|
@@ -165,11 +129,11 @@ export default class SearchBuilder {
|
|
|
165
129
|
*
|
|
166
130
|
* @return {SearchBuilder} this
|
|
167
131
|
*/
|
|
168
|
-
isZankoku(bool
|
|
132
|
+
isZankoku(bool = true): this {
|
|
169
133
|
if (bool) {
|
|
170
|
-
this.set({ iszankoku:
|
|
134
|
+
this.set({ iszankoku: BooleanNumber.True });
|
|
171
135
|
} else {
|
|
172
|
-
this.set({ notzankoku:
|
|
136
|
+
this.set({ notzankoku: BooleanNumber.True });
|
|
173
137
|
}
|
|
174
138
|
return this;
|
|
175
139
|
}
|
|
@@ -178,11 +142,11 @@ export default class SearchBuilder {
|
|
|
178
142
|
*
|
|
179
143
|
* @return {SearchBuilder} this
|
|
180
144
|
*/
|
|
181
|
-
isTensei(bool
|
|
145
|
+
isTensei(bool = true): this {
|
|
182
146
|
if (bool) {
|
|
183
|
-
this.set({ istensei:
|
|
147
|
+
this.set({ istensei: BooleanNumber.True });
|
|
184
148
|
} else {
|
|
185
|
-
this.set({ nottensei:
|
|
149
|
+
this.set({ nottensei: BooleanNumber.True });
|
|
186
150
|
}
|
|
187
151
|
return this;
|
|
188
152
|
}
|
|
@@ -191,11 +155,11 @@ export default class SearchBuilder {
|
|
|
191
155
|
*
|
|
192
156
|
* @return {SearchBuilder} this
|
|
193
157
|
*/
|
|
194
|
-
isTenni(bool
|
|
158
|
+
isTenni(bool = true): this {
|
|
195
159
|
if (bool) {
|
|
196
|
-
this.set({ istenni:
|
|
160
|
+
this.set({ istenni: BooleanNumber.True });
|
|
197
161
|
} else {
|
|
198
|
-
this.set({ nottenni:
|
|
162
|
+
this.set({ nottenni: BooleanNumber.True });
|
|
199
163
|
}
|
|
200
164
|
return this;
|
|
201
165
|
}
|
|
@@ -205,7 +169,7 @@ export default class SearchBuilder {
|
|
|
205
169
|
* @return {SearchBuilder} this
|
|
206
170
|
*/
|
|
207
171
|
isTT(): this {
|
|
208
|
-
this.set({ istt:
|
|
172
|
+
this.set({ istt: BooleanNumber.True });
|
|
209
173
|
return this;
|
|
210
174
|
}
|
|
211
175
|
|
|
@@ -214,7 +178,7 @@ export default class SearchBuilder {
|
|
|
214
178
|
* @return {SearchBuilder} this
|
|
215
179
|
*/
|
|
216
180
|
length(length: number | number[]): this {
|
|
217
|
-
this.set({ length: array2string(length) });
|
|
181
|
+
this.set({ length: SearchBuilderBase.array2string(length) });
|
|
218
182
|
return this;
|
|
219
183
|
}
|
|
220
184
|
|
|
@@ -241,7 +205,7 @@ export default class SearchBuilder {
|
|
|
241
205
|
* @return {SearchBuilder} this
|
|
242
206
|
*/
|
|
243
207
|
sasie(num: number | number[]): this {
|
|
244
|
-
this.set({ sasie: array2string(num) });
|
|
208
|
+
this.set({ sasie: SearchBuilderBase.array2string(num) });
|
|
245
209
|
return this;
|
|
246
210
|
}
|
|
247
211
|
|
|
@@ -250,7 +214,7 @@ export default class SearchBuilder {
|
|
|
250
214
|
* @return {SearchBuilder} this
|
|
251
215
|
*/
|
|
252
216
|
time(num: number | number[]): this {
|
|
253
|
-
this.set({ time: array2string(num) });
|
|
217
|
+
this.set({ time: SearchBuilderBase.array2string(num) });
|
|
254
218
|
return this;
|
|
255
219
|
}
|
|
256
220
|
|
|
@@ -259,7 +223,7 @@ export default class SearchBuilder {
|
|
|
259
223
|
* @return {SearchBuilder} this
|
|
260
224
|
*/
|
|
261
225
|
ncode(ncodes: string | string[]): this {
|
|
262
|
-
this.set({ ncode: array2string(ncodes) });
|
|
226
|
+
this.set({ ncode: SearchBuilderBase.array2string(ncodes) });
|
|
263
227
|
return this;
|
|
264
228
|
}
|
|
265
229
|
|
|
@@ -267,7 +231,7 @@ export default class SearchBuilder {
|
|
|
267
231
|
*
|
|
268
232
|
* @return {SearchBuilder} this
|
|
269
233
|
*/
|
|
270
|
-
type(type:
|
|
234
|
+
type(type: NovelTypeParam): this {
|
|
271
235
|
this.set({ type });
|
|
272
236
|
return this;
|
|
273
237
|
}
|
|
@@ -276,8 +240,8 @@ export default class SearchBuilder {
|
|
|
276
240
|
*
|
|
277
241
|
* @return {SearchBuilder} this
|
|
278
242
|
*/
|
|
279
|
-
buntai(buntai:
|
|
280
|
-
this.set({ buntai: array2string(buntai) });
|
|
243
|
+
buntai(buntai: BuntaiParam | BuntaiParam[]): this {
|
|
244
|
+
this.set({ buntai: SearchBuilderBase.array2string(buntai) });
|
|
281
245
|
return this;
|
|
282
246
|
}
|
|
283
247
|
|
|
@@ -285,8 +249,8 @@ export default class SearchBuilder {
|
|
|
285
249
|
*
|
|
286
250
|
* @return {SearchBuilder} this
|
|
287
251
|
*/
|
|
288
|
-
isStop(bool
|
|
289
|
-
this.set({ stop: bool ?
|
|
252
|
+
isStop(bool = true): this {
|
|
253
|
+
this.set({ stop: bool ? StopParam.Stopping : StopParam.NoStopping });
|
|
290
254
|
return this;
|
|
291
255
|
}
|
|
292
256
|
|
|
@@ -294,8 +258,8 @@ export default class SearchBuilder {
|
|
|
294
258
|
*
|
|
295
259
|
* @return {SearchBuilder} this
|
|
296
260
|
*/
|
|
297
|
-
isPickup(bool
|
|
298
|
-
this.set({ ispickup: bool ?
|
|
261
|
+
isPickup(bool = true): this {
|
|
262
|
+
this.set({ ispickup: bool ? BooleanNumber.True : BooleanNumber.False });
|
|
299
263
|
return this;
|
|
300
264
|
}
|
|
301
265
|
|
|
@@ -323,15 +287,6 @@ export default class SearchBuilder {
|
|
|
323
287
|
return this;
|
|
324
288
|
}
|
|
325
289
|
|
|
326
|
-
/**
|
|
327
|
-
*
|
|
328
|
-
* @return {SearchBuilder} this
|
|
329
|
-
*/
|
|
330
|
-
fields(fields: Fields | Fields[]): this {
|
|
331
|
-
this.set({ of: array2string(fields) });
|
|
332
|
-
return this;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
290
|
/**
|
|
336
291
|
*
|
|
337
292
|
* @return {SearchBuilder} this
|
|
@@ -354,14 +309,10 @@ export default class SearchBuilder {
|
|
|
354
309
|
*
|
|
355
310
|
* @return {SearchBuilder} this
|
|
356
311
|
*/
|
|
357
|
-
page(no: number, count
|
|
312
|
+
page(no: number, count = 20): this {
|
|
358
313
|
return this.limit(count).start(no * count);
|
|
359
314
|
}
|
|
360
315
|
|
|
361
|
-
opt(option: "weekly" | undefined): this {
|
|
362
|
-
return this.set({ opt: option });
|
|
363
|
-
}
|
|
364
|
-
|
|
365
316
|
/**
|
|
366
317
|
* 出力順序を指定する。指定しない場合は新着順となります。
|
|
367
318
|
*
|
|
@@ -424,19 +375,94 @@ export default class SearchBuilder {
|
|
|
424
375
|
* なろう小説APIへの検索リクエストを実行する
|
|
425
376
|
* @returns {Promise<NarouSearchResults>} 検索結果
|
|
426
377
|
*/
|
|
427
|
-
execute(): Promise<
|
|
378
|
+
execute(): Promise<NarouSearchResults<T>> {
|
|
428
379
|
return this.api.executeNovel(this.params);
|
|
429
380
|
}
|
|
430
381
|
}
|
|
431
382
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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
|
+
}
|
|
435
460
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
461
|
+
opt<TFields extends OptionalFields>(
|
|
462
|
+
option: TFields | TFields[]
|
|
463
|
+
): SearchBuilder<T, SerachResultOptionalFields<TFields>> {
|
|
464
|
+
this.set({ opt: SearchBuilderBase.array2string(option) });
|
|
465
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
466
|
+
return this as any;
|
|
441
467
|
}
|
|
442
468
|
}
|
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