narou 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/index.browser.d.ts +35 -35
  2. package/dist/index.browser.js +82 -82
  3. package/dist/index.common.d.ts +14 -14
  4. package/dist/index.common.js +34 -34
  5. package/dist/index.d.ts +42 -42
  6. package/dist/index.js +90 -90
  7. package/dist/narou-fetch.d.ts +12 -12
  8. package/dist/narou-fetch.js +45 -45
  9. package/dist/narou-jsonp.d.ts +9 -9
  10. package/dist/narou-jsonp.js +23 -23
  11. package/dist/narou-ranking-results.d.ts +9 -9
  12. package/dist/narou-ranking-results.js +2 -2
  13. package/dist/narou-search-results.d.ts +130 -130
  14. package/dist/narou-search-results.js +62 -62
  15. package/dist/narou.d.ts +25 -25
  16. package/dist/narou.js +29 -29
  17. package/dist/params.d.ts +323 -323
  18. package/dist/params.js +246 -246
  19. package/dist/ranking-history.d.ts +13 -13
  20. package/dist/ranking-history.js +13 -13
  21. package/dist/ranking.d.ts +45 -45
  22. package/dist/ranking.js +86 -86
  23. package/dist/search-builder-r18.d.ts +28 -28
  24. package/dist/search-builder-r18.js +44 -44
  25. package/dist/search-builder.d.ts +219 -219
  26. package/dist/search-builder.js +380 -380
  27. package/dist/user-search.d.ts +62 -62
  28. package/dist/user-search.js +93 -93
  29. package/dist/util/jsonp.d.ts +16 -16
  30. package/dist/util/jsonp.js +45 -45
  31. package/dist/util/type.d.ts +3 -3
  32. package/dist/util/type.js +2 -2
  33. package/dist/util/unzipp.d.ts +3 -3
  34. package/dist/util/unzipp.js +11 -11
  35. package/dist.esm/index.browser.js +86 -0
  36. package/dist.esm/index.browser.js.map +1 -0
  37. package/dist.esm/index.common.js +38 -0
  38. package/dist.esm/index.common.js.map +1 -0
  39. package/dist.esm/index.js +94 -0
  40. package/dist.esm/index.js.map +1 -0
  41. package/dist.esm/narou-fetch.js +49 -0
  42. package/dist.esm/narou-fetch.js.map +1 -0
  43. package/dist.esm/narou-jsonp.js +27 -0
  44. package/dist.esm/narou-jsonp.js.map +1 -0
  45. package/dist.esm/narou-ranking-results.js +3 -0
  46. package/dist.esm/narou-ranking-results.js.map +1 -0
  47. package/dist.esm/narou-search-results.js +63 -0
  48. package/dist.esm/narou-search-results.js.map +1 -0
  49. package/dist.esm/narou.js +33 -0
  50. package/dist.esm/narou.js.map +1 -0
  51. package/dist.esm/params.js +247 -0
  52. package/dist.esm/params.js.map +1 -0
  53. package/dist.esm/ranking-history.js +14 -0
  54. package/dist.esm/ranking-history.js.map +1 -0
  55. package/dist.esm/ranking.js +90 -0
  56. package/dist.esm/ranking.js.map +1 -0
  57. package/dist.esm/search-builder-r18.js +45 -0
  58. package/dist.esm/search-builder-r18.js.map +1 -0
  59. package/dist.esm/search-builder.js +381 -0
  60. package/dist.esm/search-builder.js.map +1 -0
  61. package/dist.esm/user-search.js +94 -0
  62. package/dist.esm/user-search.js.map +1 -0
  63. package/dist.esm/util/jsonp.js +46 -0
  64. package/dist.esm/util/jsonp.js.map +1 -0
  65. package/dist.esm/util/type.js +3 -0
  66. package/dist.esm/util/type.js.map +1 -0
  67. package/dist.esm/util/unzipp.js +12 -0
  68. package/dist.esm/util/unzipp.js.map +1 -0
  69. package/package.json +1 -1
  70. package/src/user-search.ts +109 -109
@@ -1,46 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const node_fetch_1 = require("node-fetch");
4
- const unzipp_1 = require("./util/unzipp");
5
- const narou_1 = require("./narou");
6
- /**
7
- * なろう小説APIへのリクエストを実行する
8
- * @class NarouNovel
9
- * @private
10
- */
11
- class NarouNovelFetch extends narou_1.default {
12
- constructor(fetch = node_fetch_1.default) {
13
- super();
14
- this.fetch = fetch;
15
- }
16
- async execute(params, endpoint) {
17
- const query = { ...params, out: "json" };
18
- if (query.gzip === undefined) {
19
- query.gzip = 5;
20
- }
21
- const url = new URL(endpoint);
22
- Object.entries(query).forEach(([key, value]) => {
23
- if (value) {
24
- url.searchParams.append(key, value.toString());
25
- }
26
- });
27
- const res = await this.fetch(url);
28
- if (query.gzip === 0) {
29
- return await res.json();
30
- }
31
- const buffer = await res.buffer();
32
- try {
33
- return await (0, unzipp_1.unzipp)(buffer);
34
- }
35
- catch {
36
- try {
37
- throw JSON.stringify(buffer.toString());
38
- }
39
- catch {
40
- throw buffer.toString();
41
- }
42
- }
43
- }
44
- }
45
- exports.default = NarouNovelFetch;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_fetch_1 = require("node-fetch");
4
+ const unzipp_1 = require("./util/unzipp");
5
+ const narou_1 = require("./narou");
6
+ /**
7
+ * なろう小説APIへのリクエストを実行する
8
+ * @class NarouNovel
9
+ * @private
10
+ */
11
+ class NarouNovelFetch extends narou_1.default {
12
+ constructor(fetch = node_fetch_1.default) {
13
+ super();
14
+ this.fetch = fetch;
15
+ }
16
+ async execute(params, endpoint) {
17
+ const query = { ...params, out: "json" };
18
+ if (query.gzip === undefined) {
19
+ query.gzip = 5;
20
+ }
21
+ const url = new URL(endpoint);
22
+ Object.entries(query).forEach(([key, value]) => {
23
+ if (value) {
24
+ url.searchParams.append(key, value.toString());
25
+ }
26
+ });
27
+ const res = await this.fetch(url);
28
+ if (query.gzip === 0) {
29
+ return await res.json();
30
+ }
31
+ const buffer = await res.buffer();
32
+ try {
33
+ return await (0, unzipp_1.unzipp)(buffer);
34
+ }
35
+ catch {
36
+ try {
37
+ throw JSON.stringify(buffer.toString());
38
+ }
39
+ catch {
40
+ throw buffer.toString();
41
+ }
42
+ }
43
+ }
44
+ }
45
+ exports.default = NarouNovelFetch;
46
46
  //# sourceMappingURL=narou-fetch.js.map
@@ -1,10 +1,10 @@
1
- import NarouNovel, { NarouParams } from "./narou";
2
- /**
3
- * なろう小説APIへのリクエストを実行する
4
- * @class NarouNovel
5
- * @private
6
- */
7
- export default class NarouNovelJsonp extends NarouNovel {
8
- protected execute<T>(params: NarouParams, endpoint: string): Promise<T>;
9
- }
1
+ import NarouNovel, { NarouParams } from "./narou";
2
+ /**
3
+ * なろう小説APIへのリクエストを実行する
4
+ * @class NarouNovel
5
+ * @private
6
+ */
7
+ export default class NarouNovelJsonp extends NarouNovel {
8
+ protected execute<T>(params: NarouParams, endpoint: string): Promise<T>;
9
+ }
10
10
  //# sourceMappingURL=narou-jsonp.d.ts.map
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const narou_1 = require("./narou");
4
- const jsonp_1 = require("./util/jsonp");
5
- /**
6
- * なろう小説APIへのリクエストを実行する
7
- * @class NarouNovel
8
- * @private
9
- */
10
- class NarouNovelJsonp extends narou_1.default {
11
- async execute(params, endpoint) {
12
- const query = { ...params, out: "jsonp" };
13
- query.gzip = 0;
14
- const url = new URL(endpoint);
15
- Object.entries(query).forEach(([key, value]) => {
16
- if (value) {
17
- url.searchParams.append(key, value.toString());
18
- }
19
- });
20
- return await (0, jsonp_1.jsonp)(url.toString());
21
- }
22
- }
23
- exports.default = NarouNovelJsonp;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const narou_1 = require("./narou");
4
+ const jsonp_1 = require("./util/jsonp");
5
+ /**
6
+ * なろう小説APIへのリクエストを実行する
7
+ * @class NarouNovel
8
+ * @private
9
+ */
10
+ class NarouNovelJsonp extends narou_1.default {
11
+ async execute(params, endpoint) {
12
+ const query = { ...params, out: "jsonp" };
13
+ query.gzip = 0;
14
+ const url = new URL(endpoint);
15
+ Object.entries(query).forEach(([key, value]) => {
16
+ if (value) {
17
+ url.searchParams.append(key, value.toString());
18
+ }
19
+ });
20
+ return await (0, jsonp_1.jsonp)(url.toString());
21
+ }
22
+ }
23
+ exports.default = NarouNovelJsonp;
24
24
  //# sourceMappingURL=narou-jsonp.js.map
@@ -1,10 +1,10 @@
1
- import { PickedNarouSearchResult } from "./narou-search-results";
2
- import { SearchResultFieldNames } from "./params";
3
- import { DefaultSearchResultFields } from "./search-builder";
4
- export interface NarouRankingResult {
5
- ncode: string;
6
- rank: number;
7
- pt: number;
8
- }
9
- export declare type RankingResult<T extends SearchResultFieldNames = DefaultSearchResultFields> = Partial<PickedNarouSearchResult<T>> & NarouRankingResult;
1
+ import { PickedNarouSearchResult } from "./narou-search-results";
2
+ import { SearchResultFieldNames } from "./params";
3
+ import { DefaultSearchResultFields } from "./search-builder";
4
+ export interface NarouRankingResult {
5
+ ncode: string;
6
+ rank: number;
7
+ pt: number;
8
+ }
9
+ export declare type RankingResult<T extends SearchResultFieldNames = DefaultSearchResultFields> = Partial<PickedNarouSearchResult<T>> & NarouRankingResult;
10
10
  //# sourceMappingURL=narou-ranking-results.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=narou-ranking-results.js.map
@@ -1,131 +1,131 @@
1
- import { BooleanNumber as BooleanNumber, Genre, R18Site, SearchParams, Fields, BigGenre, R18Fields, OptionalFields, UserFields } from "./params";
2
- /**
3
- * なろう小説API検索結果
4
- * @class NarouSearchResults
5
- */
6
- export default class NarouSearchResults<T, TKey extends keyof T> {
7
- allcount: number;
8
- limit: number;
9
- start: number;
10
- page: number;
11
- length: number;
12
- values: readonly Pick<T, TKey>[];
13
- /**
14
- * @constractor
15
- * @private
16
- */
17
- constructor([header, ...result]: [{
18
- allcount: number;
19
- }, ...Pick<T, TKey>[]], params: SearchParams);
20
- }
21
- /**
22
- * @typedef {Object} NarouSearchResult
23
- * @property {number} title 小説名
24
- * @property {string} ncode Nコード
25
- * @property {number} userid 作者のユーザID(数値)
26
- * @property {string} writer 作者名
27
- * @property {string} story 小説のあらすじ
28
- * @property {number} genre ジャンル
29
- * @property {string} keyword キーワード
30
- * @property {string} general_firstup 初回掲載日 YYYY-MM-DD HH:MM:SSの形式
31
- * @property {string} general_lastup 最終掲載日 YYYY-MM-DD HH:MM:SSの形式
32
- * @property {number} noveltype 連載の場合は1、短編の場合は2
33
- * @property {number} end 短編小説と完結済小説は0となっています。連載中は1です。
34
- * @property {number} general_all_no 全掲載話数です。短編の場合は1です。
35
- * @property {number} length 全掲載話数です。短編の場合は1です。
36
- * @property {number} time 読了時間(分単位)です。読了時間は小説文字数÷500を切り上げした数値です。
37
- * @property {number} isstop 長期連載中は1、それ以外は0です。
38
- * @property {number} pc_or_k 1はケータイのみ、2はPCのみ、3はPCとケータイで投稿された作品です。対象は投稿と次話投稿時のみで、どの端末で執筆されたかを表すものではありません。
39
- * @property {number} global_point 総合得点(=(ブックマーク数×2)+評価点)
40
- * @property {number} fav_novel_cnt ブックマーク数
41
- * @property {number} review_cnt レビュー数
42
- * @property {number} all_point 評価点
43
- * @property {number} all_hyoka_cnt 評価者数
44
- * @property {number} sasie_cnt 挿絵の数
45
- * @property {number} kaiwaritu 会話率
46
- * @property {number} novelupdated_at 小説の更新日時
47
- * @property {number} updated_at 最終更新日時(注意:システム用で小説更新時とは関係ありません)
48
- */
49
- export interface NarouSearchResult {
50
- title: string;
51
- ncode: string;
52
- userid: number;
53
- writer: string;
54
- story: string;
55
- nocgenre: R18Site;
56
- biggenre: BigGenre;
57
- genre: Genre;
58
- keyword: string;
59
- general_firstup: string;
60
- general_lastup: string;
61
- novel_type: number;
62
- noveltype: NovelType;
63
- end: End;
64
- general_all_no: number;
65
- length: number;
66
- time: number;
67
- isstop: BooleanNumber;
68
- isr15: BooleanNumber;
69
- isbl: BooleanNumber;
70
- isgl: BooleanNumber;
71
- iszankoku: BooleanNumber;
72
- istensei: BooleanNumber;
73
- istenni: BooleanNumber;
74
- pc_or_k: PcOrK;
75
- global_point: number;
76
- daily_point: number;
77
- weekly_point: number;
78
- monthly_point: number;
79
- quarter_point: number;
80
- yearly_point: number;
81
- fav_novel_cnt: number;
82
- impression_cnt: number;
83
- review_cnt: number;
84
- all_point: number;
85
- all_hyoka_cnt: number;
86
- sasie_cnt: number;
87
- kaiwaritu: number;
88
- novelupdated_at: string;
89
- updated_at: string;
90
- weekly_unique: number;
91
- }
92
- export interface UserSearchResult {
93
- userid: number;
94
- name: string;
95
- yomikata: string;
96
- name1st: string;
97
- novel_cnt: number;
98
- review_cnt: number;
99
- novel_length: number;
100
- sum_global_point: number;
101
- }
102
- export declare const PcOrK: {
103
- readonly Ketai: 1;
104
- readonly Pc: 2;
105
- readonly PcAndKetai: 3;
106
- };
107
- export declare type PcOrK = typeof PcOrK[keyof typeof PcOrK];
108
- export declare const NovelType: {
109
- readonly Rensai: 1;
110
- readonly Tanpen: 2;
111
- };
112
- export declare type NovelType = typeof NovelType[keyof typeof NovelType];
113
- export declare const End: {
114
- readonly KanketsuOrTanpen: 0;
115
- readonly Rensai: 1;
116
- };
117
- export declare type End = typeof End[keyof typeof End];
118
- export declare type SearchResultFields<T extends Fields> = {
119
- [K in keyof typeof Fields]: typeof Fields[K] extends T ? K : never;
120
- }[keyof typeof Fields];
121
- export declare type SearchResultOptionalFields<T extends OptionalFields> = {
122
- [K in keyof typeof OptionalFields]: typeof OptionalFields[K] extends T ? K : never;
123
- }[keyof typeof OptionalFields];
124
- export declare type SearchResultR18Fields<T extends R18Fields> = {
125
- [K in keyof typeof R18Fields]: typeof R18Fields[K] extends T ? K : never;
126
- }[keyof typeof R18Fields];
127
- export declare type UserSearchResultFields<T extends UserFields> = {
128
- [K in keyof typeof UserFields]: typeof UserFields[K] extends T ? K : never;
129
- }[keyof typeof UserFields];
130
- export declare type PickedNarouSearchResult<T extends keyof NarouSearchResult> = Pick<NarouSearchResult, T>;
1
+ import { BooleanNumber as BooleanNumber, Genre, R18Site, SearchParams, Fields, BigGenre, R18Fields, OptionalFields, UserFields } from "./params";
2
+ /**
3
+ * なろう小説API検索結果
4
+ * @class NarouSearchResults
5
+ */
6
+ export default class NarouSearchResults<T, TKey extends keyof T> {
7
+ allcount: number;
8
+ limit: number;
9
+ start: number;
10
+ page: number;
11
+ length: number;
12
+ values: readonly Pick<T, TKey>[];
13
+ /**
14
+ * @constractor
15
+ * @private
16
+ */
17
+ constructor([header, ...result]: [{
18
+ allcount: number;
19
+ }, ...Pick<T, TKey>[]], params: SearchParams);
20
+ }
21
+ /**
22
+ * @typedef {Object} NarouSearchResult
23
+ * @property {number} title 小説名
24
+ * @property {string} ncode Nコード
25
+ * @property {number} userid 作者のユーザID(数値)
26
+ * @property {string} writer 作者名
27
+ * @property {string} story 小説のあらすじ
28
+ * @property {number} genre ジャンル
29
+ * @property {string} keyword キーワード
30
+ * @property {string} general_firstup 初回掲載日 YYYY-MM-DD HH:MM:SSの形式
31
+ * @property {string} general_lastup 最終掲載日 YYYY-MM-DD HH:MM:SSの形式
32
+ * @property {number} noveltype 連載の場合は1、短編の場合は2
33
+ * @property {number} end 短編小説と完結済小説は0となっています。連載中は1です。
34
+ * @property {number} general_all_no 全掲載話数です。短編の場合は1です。
35
+ * @property {number} length 全掲載話数です。短編の場合は1です。
36
+ * @property {number} time 読了時間(分単位)です。読了時間は小説文字数÷500を切り上げした数値です。
37
+ * @property {number} isstop 長期連載中は1、それ以外は0です。
38
+ * @property {number} pc_or_k 1はケータイのみ、2はPCのみ、3はPCとケータイで投稿された作品です。対象は投稿と次話投稿時のみで、どの端末で執筆されたかを表すものではありません。
39
+ * @property {number} global_point 総合得点(=(ブックマーク数×2)+評価点)
40
+ * @property {number} fav_novel_cnt ブックマーク数
41
+ * @property {number} review_cnt レビュー数
42
+ * @property {number} all_point 評価点
43
+ * @property {number} all_hyoka_cnt 評価者数
44
+ * @property {number} sasie_cnt 挿絵の数
45
+ * @property {number} kaiwaritu 会話率
46
+ * @property {number} novelupdated_at 小説の更新日時
47
+ * @property {number} updated_at 最終更新日時(注意:システム用で小説更新時とは関係ありません)
48
+ */
49
+ export interface NarouSearchResult {
50
+ title: string;
51
+ ncode: string;
52
+ userid: number;
53
+ writer: string;
54
+ story: string;
55
+ nocgenre: R18Site;
56
+ biggenre: BigGenre;
57
+ genre: Genre;
58
+ keyword: string;
59
+ general_firstup: string;
60
+ general_lastup: string;
61
+ novel_type: number;
62
+ noveltype: NovelType;
63
+ end: End;
64
+ general_all_no: number;
65
+ length: number;
66
+ time: number;
67
+ isstop: BooleanNumber;
68
+ isr15: BooleanNumber;
69
+ isbl: BooleanNumber;
70
+ isgl: BooleanNumber;
71
+ iszankoku: BooleanNumber;
72
+ istensei: BooleanNumber;
73
+ istenni: BooleanNumber;
74
+ pc_or_k: PcOrK;
75
+ global_point: number;
76
+ daily_point: number;
77
+ weekly_point: number;
78
+ monthly_point: number;
79
+ quarter_point: number;
80
+ yearly_point: number;
81
+ fav_novel_cnt: number;
82
+ impression_cnt: number;
83
+ review_cnt: number;
84
+ all_point: number;
85
+ all_hyoka_cnt: number;
86
+ sasie_cnt: number;
87
+ kaiwaritu: number;
88
+ novelupdated_at: string;
89
+ updated_at: string;
90
+ weekly_unique: number;
91
+ }
92
+ export interface UserSearchResult {
93
+ userid: number;
94
+ name: string;
95
+ yomikata: string;
96
+ name1st: string;
97
+ novel_cnt: number;
98
+ review_cnt: number;
99
+ novel_length: number;
100
+ sum_global_point: number;
101
+ }
102
+ export declare const PcOrK: {
103
+ readonly Ketai: 1;
104
+ readonly Pc: 2;
105
+ readonly PcAndKetai: 3;
106
+ };
107
+ export declare type PcOrK = typeof PcOrK[keyof typeof PcOrK];
108
+ export declare const NovelType: {
109
+ readonly Rensai: 1;
110
+ readonly Tanpen: 2;
111
+ };
112
+ export declare type NovelType = typeof NovelType[keyof typeof NovelType];
113
+ export declare const End: {
114
+ readonly KanketsuOrTanpen: 0;
115
+ readonly Rensai: 1;
116
+ };
117
+ export declare type End = typeof End[keyof typeof End];
118
+ export declare type SearchResultFields<T extends Fields> = {
119
+ [K in keyof typeof Fields]: typeof Fields[K] extends T ? K : never;
120
+ }[keyof typeof Fields];
121
+ export declare type SearchResultOptionalFields<T extends OptionalFields> = {
122
+ [K in keyof typeof OptionalFields]: typeof OptionalFields[K] extends T ? K : never;
123
+ }[keyof typeof OptionalFields];
124
+ export declare type SearchResultR18Fields<T extends R18Fields> = {
125
+ [K in keyof typeof R18Fields]: typeof R18Fields[K] extends T ? K : never;
126
+ }[keyof typeof R18Fields];
127
+ export declare type UserSearchResultFields<T extends UserFields> = {
128
+ [K in keyof typeof UserFields]: typeof UserFields[K] extends T ? K : never;
129
+ }[keyof typeof UserFields];
130
+ export declare type PickedNarouSearchResult<T extends keyof NarouSearchResult> = Pick<NarouSearchResult, T>;
131
131
  //# sourceMappingURL=narou-search-results.d.ts.map
@@ -1,63 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.End = exports.NovelType = exports.PcOrK = void 0;
4
- /**
5
- * なろう小説API検索結果
6
- * @class NarouSearchResults
7
- */
8
- class NarouSearchResults {
9
- /**
10
- * @constractor
11
- * @private
12
- */
13
- constructor([header, ...result], params) {
14
- const count = header.allcount;
15
- const limit = params.lim ?? 20;
16
- const start = params.st ?? 0;
17
- /**
18
- * 検索結果数
19
- * @type {number}
20
- */
21
- this.allcount = count;
22
- /**
23
- * 結果表示上限数
24
- * @type {number}
25
- */
26
- this.limit = limit;
27
- /**
28
- * 結果表示開始数
29
- * @type {number}
30
- */
31
- this.start = start;
32
- /**
33
- * 結果表示ページ数
34
- * @type {number}
35
- */
36
- this.page = start / limit;
37
- /**
38
- * 結果数
39
- * @type {number}
40
- */
41
- this.length = result.length;
42
- /**
43
- * 検索結果
44
- * @type {PickedNarouSearchResult<T>[]}
45
- */
46
- this.values = result;
47
- }
48
- }
49
- exports.default = NarouSearchResults;
50
- exports.PcOrK = {
51
- Ketai: 1,
52
- Pc: 2,
53
- PcAndKetai: 3,
54
- };
55
- exports.NovelType = {
56
- Rensai: 1,
57
- Tanpen: 2,
58
- };
59
- exports.End = {
60
- KanketsuOrTanpen: 0,
61
- Rensai: 1,
62
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.End = exports.NovelType = exports.PcOrK = void 0;
4
+ /**
5
+ * なろう小説API検索結果
6
+ * @class NarouSearchResults
7
+ */
8
+ class NarouSearchResults {
9
+ /**
10
+ * @constractor
11
+ * @private
12
+ */
13
+ constructor([header, ...result], params) {
14
+ const count = header.allcount;
15
+ const limit = params.lim ?? 20;
16
+ const start = params.st ?? 0;
17
+ /**
18
+ * 検索結果数
19
+ * @type {number}
20
+ */
21
+ this.allcount = count;
22
+ /**
23
+ * 結果表示上限数
24
+ * @type {number}
25
+ */
26
+ this.limit = limit;
27
+ /**
28
+ * 結果表示開始数
29
+ * @type {number}
30
+ */
31
+ this.start = start;
32
+ /**
33
+ * 結果表示ページ数
34
+ * @type {number}
35
+ */
36
+ this.page = start / limit;
37
+ /**
38
+ * 結果数
39
+ * @type {number}
40
+ */
41
+ this.length = result.length;
42
+ /**
43
+ * 検索結果
44
+ * @type {PickedNarouSearchResult<T>[]}
45
+ */
46
+ this.values = result;
47
+ }
48
+ }
49
+ exports.default = NarouSearchResults;
50
+ exports.PcOrK = {
51
+ Ketai: 1,
52
+ Pc: 2,
53
+ PcAndKetai: 3,
54
+ };
55
+ exports.NovelType = {
56
+ Rensai: 1,
57
+ Tanpen: 2,
58
+ };
59
+ exports.End = {
60
+ KanketsuOrTanpen: 0,
61
+ Rensai: 1,
62
+ };
63
63
  //# sourceMappingURL=narou-search-results.js.map
package/dist/narou.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { NarouRankingResult } from "./narou-ranking-results";
2
- import NarouSearchResults, { NarouSearchResult, UserSearchResult } from "./narou-search-results";
3
- import { RankingHistoryParams, RankingParams, SearchParams, UserSearchParams } from "./params";
4
- import { RankingHistoryRawResult } from "./ranking-history";
5
- export declare type NarouParams = SearchParams | RankingParams | RankingHistoryParams | UserSearchParams;
6
- /**
7
- * なろう小説APIへのリクエストを実行する
8
- * @class NarouNovel
9
- * @private
10
- */
11
- export default abstract class NarouNovel {
12
- /**
13
- * なろう小説APIへの検索リクエストを実行する
14
- * @param params クエリパラメータ
15
- * @param endpoint APIエンドポイント
16
- * @returns {Promise<NarouSearchResults>} 検索結果
17
- */
18
- protected abstract execute<T>(params: NarouParams, endpoint: string): Promise<T>;
19
- executeSearch<T extends keyof NarouSearchResult>(params: SearchParams, endpoint?: string): Promise<NarouSearchResults<NarouSearchResult, T>>;
20
- executeNovel<T extends keyof NarouSearchResult>(params: SearchParams): Promise<NarouSearchResults<NarouSearchResult, T>>;
21
- executeNovel18<T extends keyof NarouSearchResult>(params: SearchParams): Promise<NarouSearchResults<NarouSearchResult, T>>;
22
- executeRanking(params: RankingParams): Promise<NarouRankingResult[]>;
23
- executeRankingHistory(params: RankingHistoryParams): Promise<RankingHistoryRawResult[]>;
24
- executeUserSearch<T extends keyof UserSearchResult>(params: UserSearchParams): Promise<NarouSearchResults<UserSearchResult, T>>;
25
- }
1
+ import { NarouRankingResult } from "./narou-ranking-results";
2
+ import NarouSearchResults, { NarouSearchResult, UserSearchResult } from "./narou-search-results";
3
+ import { RankingHistoryParams, RankingParams, SearchParams, UserSearchParams } from "./params";
4
+ import { RankingHistoryRawResult } from "./ranking-history";
5
+ export declare type NarouParams = SearchParams | RankingParams | RankingHistoryParams | UserSearchParams;
6
+ /**
7
+ * なろう小説APIへのリクエストを実行する
8
+ * @class NarouNovel
9
+ * @private
10
+ */
11
+ export default abstract class NarouNovel {
12
+ /**
13
+ * なろう小説APIへの検索リクエストを実行する
14
+ * @param params クエリパラメータ
15
+ * @param endpoint APIエンドポイント
16
+ * @returns {Promise<NarouSearchResults>} 検索結果
17
+ */
18
+ protected abstract execute<T>(params: NarouParams, endpoint: string): Promise<T>;
19
+ executeSearch<T extends keyof NarouSearchResult>(params: SearchParams, endpoint?: string): Promise<NarouSearchResults<NarouSearchResult, T>>;
20
+ executeNovel<T extends keyof NarouSearchResult>(params: SearchParams): Promise<NarouSearchResults<NarouSearchResult, T>>;
21
+ executeNovel18<T extends keyof NarouSearchResult>(params: SearchParams): Promise<NarouSearchResults<NarouSearchResult, T>>;
22
+ executeRanking(params: RankingParams): Promise<NarouRankingResult[]>;
23
+ executeRankingHistory(params: RankingHistoryParams): Promise<RankingHistoryRawResult[]>;
24
+ executeUserSearch<T extends keyof UserSearchResult>(params: UserSearchParams): Promise<NarouSearchResults<UserSearchResult, T>>;
25
+ }
26
26
  //# sourceMappingURL=narou.d.ts.map