narou 0.8.1 → 0.9.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 (162) hide show
  1. package/dist/chunk-3UZPHZZH.js +43 -0
  2. package/dist/chunk-46WN4HIZ.js +25 -0
  3. package/dist/chunk-55V5YY6H.js +71 -0
  4. package/dist/chunk-5OZA6DNS.js +14 -0
  5. package/dist/chunk-67BSHN66.js +82 -0
  6. package/dist/chunk-6SHYBHWX.js +0 -0
  7. package/dist/chunk-AIRK7Y7G.js +0 -0
  8. package/dist/chunk-C54MSVRN.js +3064 -0
  9. package/dist/chunk-EQL67JCA.js +38 -0
  10. package/dist/chunk-IKR7OZGM.js +49 -0
  11. package/dist/chunk-IVQKYEQQ.js +371 -0
  12. package/dist/chunk-JFVJBECE.js +36 -0
  13. package/dist/chunk-JS5XPNGB.js +93 -0
  14. package/dist/chunk-OVGZ6RWT.js +23 -0
  15. package/dist/chunk-U3H4E2XZ.js +396 -0
  16. package/dist/index.browser.cjs +1221 -0
  17. package/dist/index.browser.d.cts +40 -0
  18. package/dist/index.browser.d.ts +20 -16
  19. package/dist/index.browser.js +116 -72
  20. package/dist/index.cjs +4305 -0
  21. package/dist/index.common.cjs +1032 -0
  22. package/dist/index.common.d.cts +6 -0
  23. package/dist/index.common.d.ts +6 -15
  24. package/dist/index.common.js +73 -34
  25. package/dist/index.d.cts +47 -0
  26. package/dist/index.d.ts +21 -17
  27. package/dist/index.js +121 -80
  28. package/dist/narou-61329eea.d.ts +298 -0
  29. package/dist/narou-98ededc8.d.ts +298 -0
  30. package/dist/narou-fetch.cjs +3190 -0
  31. package/dist/narou-fetch.d.cts +16 -0
  32. package/dist/narou-fetch.d.ts +10 -7
  33. package/dist/narou-fetch.js +10 -46
  34. package/dist/narou-jsonp.cjs +158 -0
  35. package/dist/narou-jsonp.d.cts +13 -0
  36. package/dist/narou-jsonp.d.ts +8 -5
  37. package/dist/narou-jsonp.js +10 -24
  38. package/dist/narou-ranking-results.cjs +18 -0
  39. package/dist/narou-ranking-results.d.cts +4 -0
  40. package/dist/narou-ranking-results.d.ts +4 -10
  41. package/dist/narou-ranking-results.js +1 -3
  42. package/dist/narou-search-results-6727b1ce.d.ts +716 -0
  43. package/dist/narou-search-results-b7c10db0.d.ts +716 -0
  44. package/dist/narou-search-results.cjs +61 -0
  45. package/dist/narou-search-results.d.cts +2 -0
  46. package/dist/narou-search-results.d.ts +2 -131
  47. package/dist/narou-search-results.js +10 -62
  48. package/dist/narou.cjs +108 -0
  49. package/dist/narou.d.cts +4 -0
  50. package/dist/narou.d.ts +4 -26
  51. package/dist/narou.js +8 -30
  52. package/dist/params.cjs +436 -0
  53. package/dist/params.d.cts +2 -0
  54. package/dist/params.d.ts +2 -324
  55. package/dist/params.js +38 -246
  56. package/dist/ranking-history.cjs +38 -0
  57. package/dist/ranking-history.d.cts +17 -0
  58. package/dist/ranking-history.d.ts +8 -5
  59. package/dist/ranking-history.js +7 -14
  60. package/dist/ranking.cjs +659 -0
  61. package/dist/ranking.d.cts +47 -0
  62. package/dist/ranking.d.ts +8 -7
  63. package/dist/ranking.js +9 -87
  64. package/dist/search-builder-r18.cjs +473 -0
  65. package/dist/search-builder-r18.d.cts +32 -0
  66. package/dist/search-builder-r18.d.ts +9 -6
  67. package/dist/search-builder-r18.js +9 -45
  68. package/dist/search-builder.cjs +510 -0
  69. package/dist/search-builder.d.cts +4 -0
  70. package/dist/search-builder.d.ts +4 -220
  71. package/dist/search-builder.js +12 -381
  72. package/dist/user-search.cjs +300 -0
  73. package/{dist.esm/user-search.js → dist/user-search.d.cts} +18 -46
  74. package/dist/user-search.d.ts +8 -5
  75. package/dist/user-search.js +9 -94
  76. package/dist/util/jsonp.cjs +62 -0
  77. package/dist/util/jsonp.d.cts +13 -0
  78. package/dist/util/jsonp.d.ts +4 -8
  79. package/dist/util/jsonp.js +7 -46
  80. package/dist/util/type.cjs +18 -0
  81. package/dist/util/type.d.cts +4 -0
  82. package/dist/util/type.d.ts +4 -4
  83. package/dist/util/type.js +0 -3
  84. package/dist/util/unzipp.cjs +47 -0
  85. package/dist/util/unzipp.d.cts +3 -0
  86. package/dist/util/unzipp.d.ts +3 -4
  87. package/dist/util/unzipp.js +7 -12
  88. package/package.json +35 -33
  89. package/src/narou-fetch.ts +6 -16
  90. package/src/narou-jsonp.ts +0 -2
  91. package/src/narou-ranking-results.ts +10 -0
  92. package/src/narou-search-results.ts +118 -63
  93. package/src/narou.ts +42 -3
  94. package/src/params.ts +220 -61
  95. package/src/util/unzipp.ts +13 -3
  96. package/dist/index.browser.d.ts.map +0 -1
  97. package/dist/index.browser.js.map +0 -1
  98. package/dist/index.common.d.ts.map +0 -1
  99. package/dist/index.common.js.map +0 -1
  100. package/dist/index.d.ts.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/narou-fetch.d.ts.map +0 -1
  103. package/dist/narou-fetch.js.map +0 -1
  104. package/dist/narou-jsonp.d.ts.map +0 -1
  105. package/dist/narou-jsonp.js.map +0 -1
  106. package/dist/narou-ranking-results.d.ts.map +0 -1
  107. package/dist/narou-ranking-results.js.map +0 -1
  108. package/dist/narou-search-results.d.ts.map +0 -1
  109. package/dist/narou-search-results.js.map +0 -1
  110. package/dist/narou.d.ts.map +0 -1
  111. package/dist/narou.js.map +0 -1
  112. package/dist/params.d.ts.map +0 -1
  113. package/dist/params.js.map +0 -1
  114. package/dist/ranking-history.d.ts.map +0 -1
  115. package/dist/ranking-history.js.map +0 -1
  116. package/dist/ranking.d.ts.map +0 -1
  117. package/dist/ranking.js.map +0 -1
  118. package/dist/search-builder-r18.d.ts.map +0 -1
  119. package/dist/search-builder-r18.js.map +0 -1
  120. package/dist/search-builder.d.ts.map +0 -1
  121. package/dist/search-builder.js.map +0 -1
  122. package/dist/user-search.d.ts.map +0 -1
  123. package/dist/user-search.js.map +0 -1
  124. package/dist/util/jsonp.d.ts.map +0 -1
  125. package/dist/util/jsonp.js.map +0 -1
  126. package/dist/util/type.d.ts.map +0 -1
  127. package/dist/util/type.js.map +0 -1
  128. package/dist/util/unzipp.d.ts.map +0 -1
  129. package/dist/util/unzipp.js.map +0 -1
  130. package/dist.esm/index.browser.js +0 -86
  131. package/dist.esm/index.browser.js.map +0 -1
  132. package/dist.esm/index.common.js +0 -38
  133. package/dist.esm/index.common.js.map +0 -1
  134. package/dist.esm/index.js +0 -94
  135. package/dist.esm/index.js.map +0 -1
  136. package/dist.esm/narou-fetch.js +0 -49
  137. package/dist.esm/narou-fetch.js.map +0 -1
  138. package/dist.esm/narou-jsonp.js +0 -27
  139. package/dist.esm/narou-jsonp.js.map +0 -1
  140. package/dist.esm/narou-ranking-results.js +0 -3
  141. package/dist.esm/narou-ranking-results.js.map +0 -1
  142. package/dist.esm/narou-search-results.js +0 -63
  143. package/dist.esm/narou-search-results.js.map +0 -1
  144. package/dist.esm/narou.js +0 -33
  145. package/dist.esm/narou.js.map +0 -1
  146. package/dist.esm/params.js +0 -247
  147. package/dist.esm/params.js.map +0 -1
  148. package/dist.esm/ranking-history.js +0 -14
  149. package/dist.esm/ranking-history.js.map +0 -1
  150. package/dist.esm/ranking.js +0 -90
  151. package/dist.esm/ranking.js.map +0 -1
  152. package/dist.esm/search-builder-r18.js +0 -45
  153. package/dist.esm/search-builder-r18.js.map +0 -1
  154. package/dist.esm/search-builder.js +0 -381
  155. package/dist.esm/search-builder.js.map +0 -1
  156. package/dist.esm/user-search.js.map +0 -1
  157. package/dist.esm/util/jsonp.js +0 -46
  158. package/dist.esm/util/jsonp.js.map +0 -1
  159. package/dist.esm/util/type.js +0 -3
  160. package/dist.esm/util/type.js.map +0 -1
  161. package/dist.esm/util/unzipp.js +0 -12
  162. package/dist.esm/util/unzipp.js.map +0 -1
@@ -1,46 +1,7 @@
1
- "use strict";
2
- /**
3
- * MIT license
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.jsonp = void 0;
7
- // Callback index.
8
- let count = 0;
9
- // eslint-disable-next-line @typescript-eslint/no-empty-function
10
- const noop = function () { };
11
- function jsonp(url, { prefix = "__jp", param = "callback", timeout = 15000 } = {}) {
12
- return new Promise(function (resolve, reject) {
13
- const targetChild = document.getElementsByTagName("script").item(0);
14
- const target = targetChild?.parentNode ?? document.head;
15
- const id = `${prefix}${count++}`;
16
- const cleanup = function () {
17
- // Remove the script tag.
18
- if (script && script.parentNode) {
19
- script.parentNode.removeChild(script);
20
- }
21
- window[id] = noop;
22
- if (timer) {
23
- clearTimeout(timer);
24
- }
25
- };
26
- const timer = timeout > 0
27
- ? setTimeout(() => {
28
- cleanup();
29
- reject(new Error("Timeout"));
30
- }, timeout)
31
- : undefined;
32
- const callback = (data) => {
33
- cleanup();
34
- resolve(data);
35
- };
36
- window[id] = callback;
37
- // Create script.
38
- const script = document.createElement("script");
39
- const urlObj = new URL(url);
40
- urlObj.searchParams.set(param, id);
41
- script.setAttribute("src", urlObj.toString());
42
- target.insertBefore(script, targetChild);
43
- });
44
- }
45
- exports.jsonp = jsonp;
46
- //# sourceMappingURL=jsonp.js.map
1
+ import {
2
+ jsonp
3
+ } from "../chunk-EQL67JCA.js";
4
+ import "../chunk-IKR7OZGM.js";
5
+ export {
6
+ jsonp
7
+ };
@@ -0,0 +1,18 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/util/type.ts
17
+ var type_exports = {};
18
+ module.exports = __toCommonJS(type_exports);
@@ -0,0 +1,4 @@
1
+ type Stringable = string | number | bigint | boolean | null | undefined;
2
+ type Join<T extends Stringable> = `${T}-${T}` | `${T}`;
3
+
4
+ export { Join };
@@ -1,4 +1,4 @@
1
- declare type Stringable = string | number | bigint | boolean | null | undefined;
2
- export declare type Join<T extends Stringable> = `${T}-${T}` | `${T}`;
3
- export {};
4
- //# sourceMappingURL=type.d.ts.map
1
+ type Stringable = string | number | bigint | boolean | null | undefined;
2
+ type Join<T extends Stringable> = `${T}-${T}` | `${T}`;
3
+
4
+ export { Join };
package/dist/util/type.js CHANGED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=type.js.map
@@ -0,0 +1,47 @@
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/util/unzipp.ts
21
+ var unzipp_exports = {};
22
+ __export(unzipp_exports, {
23
+ unzipp: () => unzipp
24
+ });
25
+ module.exports = __toCommonJS(unzipp_exports);
26
+ var import_zlib = require("zlib");
27
+ var import_util = require("util");
28
+ var gunzipAsync = (0, import_util.promisify)(import_zlib.gunzip);
29
+ var decoder = new TextDecoder();
30
+ async function unzipp(data) {
31
+ try {
32
+ const buffer = await gunzipAsync(data);
33
+ try {
34
+ return JSON.parse(decoder.decode(buffer));
35
+ } catch {
36
+ throw decoder.decode(buffer);
37
+ }
38
+ } catch (e) {
39
+ if (typeof e === "string")
40
+ throw e;
41
+ throw decoder.decode(data);
42
+ }
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ unzipp
47
+ });
@@ -0,0 +1,3 @@
1
+ declare function unzipp(data: ArrayBuffer): Promise<any>;
2
+
3
+ export { unzipp };
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
- import { InputType } from "zlib";
3
- export declare function unzipp(data: InputType): Promise<any>;
4
- //# sourceMappingURL=unzipp.d.ts.map
1
+ declare function unzipp(data: ArrayBuffer): Promise<any>;
2
+
3
+ export { unzipp };
@@ -1,12 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unzipp = void 0;
4
- const zlib_1 = require("zlib");
5
- const util_1 = require("util");
6
- const gunzipAsync = (0, util_1.promisify)(zlib_1.gunzip);
7
- async function unzipp(data) {
8
- const buffer = await gunzipAsync(data);
9
- return JSON.parse(buffer.toString());
10
- }
11
- exports.unzipp = unzipp;
12
- //# sourceMappingURL=unzipp.js.map
1
+ import {
2
+ unzipp
3
+ } from "../chunk-OVGZ6RWT.js";
4
+ import "../chunk-IKR7OZGM.js";
5
+ export {
6
+ unzipp
7
+ };
package/package.json CHANGED
@@ -1,30 +1,35 @@
1
1
  {
2
2
  "name": "narou",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Narou API Wrapper",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
- "types": "src/index.ts",
7
+ "types": "dist/index.d.ts",
8
+ "module": "dist/index.mjs",
7
9
  "exports": {
8
10
  ".": {
9
11
  "browser": {
10
12
  "require": "./dist/index.browser.js",
11
- "import": "./dist.esm/index.browser.js"
13
+ "import": "./dist/index.browser.mjs",
14
+ "types": "./dist/index.browser.d.ts"
12
15
  },
13
16
  "node": {
14
17
  "require": "./dist/index.js",
15
- "import": "./dist.esm/index.js"
18
+ "import": "./dist/index.mjs",
19
+ "types": "./dist/index.d.ts"
16
20
  }
17
21
  }
18
22
  },
19
- "engines": {
20
- "node": ">=16.0.0"
21
- },
22
23
  "files": [
23
24
  "dist",
24
- "dist.*",
25
25
  "src",
26
- "package-lock.json"
26
+ "package.json",
27
+ "package-lock.json",
28
+ "README.md"
27
29
  ],
30
+ "engines": {
31
+ "node": ">=16.0.0"
32
+ },
28
33
  "author": "deflis <deflis@gmail.com>",
29
34
  "license": "MIT",
30
35
  "repository": {
@@ -32,42 +37,39 @@
32
37
  "url": "https://github.com/deflis/node-narou.git"
33
38
  },
34
39
  "dependencies": {
35
- "date-fns": "^2.16.1"
40
+ "date-fns": "^2.30.0"
36
41
  },
37
42
  "devDependencies": {
38
- "@types/jest": "^28.1.5",
39
- "@types/node": "^13.5.0",
40
- "@types/node-fetch": "^2.5.7",
41
- "@typescript-eslint/eslint-plugin": "^5.30.6",
42
- "@typescript-eslint/parser": "^5.30.6",
43
- "eslint": "^8.19.0",
44
- "eslint-config-prettier": "^8.5.0",
45
- "eslint-plugin-prettier": "^4.2.1",
46
- "jest": "^28.1.3",
47
- "node-fetch": "^2.6.1",
48
- "npm-run-all": "^4.1.4",
49
- "prettier": "^2.7.1",
50
- "ts-jest": "^28.0.6",
51
- "typescript": "^4.7.4"
43
+ "@types/jest": "^29.5.8",
44
+ "@types/node": "^20.9.0",
45
+ "@types/node-fetch": "^2.6.9",
46
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
47
+ "@typescript-eslint/parser": "^6.10.0",
48
+ "eslint": "^8.53.0",
49
+ "eslint-config-prettier": "^9.0.0",
50
+ "eslint-plugin-prettier": "^5.0.1",
51
+ "jest": "^29.7.0",
52
+ "node-fetch": "^2.7.0",
53
+ "npm-run-all": "^4.1.5",
54
+ "prettier": "^3.0.3",
55
+ "ts-jest": "^29.1.1",
56
+ "tsup": "^7.2.0",
57
+ "typescript": "^5.2.2"
52
58
  },
53
59
  "optionalDependencies": {
54
60
  "node-fetch": "^2.6.7"
55
61
  },
56
62
  "scripts": {
57
- "build": "npm-run-all check clean build:tsc",
58
- "build:tsc": "npm-run-all --parallel build:tsc:*",
59
- "build:tsc:cjs": "tsc -p ./tsconfig.cjs.json",
60
- "build:tsc:esm": "tsc -p ./tsconfig.esm.json",
63
+ "build": "npm-run-all check build:tsc",
64
+ "build:tsc": "tsup ./src",
61
65
  "check": "npm-run-all --parallel check:lint check:build test",
62
66
  "check:lint": "eslint src/** test/**",
63
67
  "check:build": "tsc --noEmit",
64
- "prepare": "npm-run-all format build",
68
+ "prepack": "npm-run-all format build",
65
69
  "format": "eslint --fix src/** test/**",
66
70
  "test": "jest",
67
- "clean": "npx rimraf dist dist.*",
68
- "docs": "npm-run-all docs:clean docs:typedoc docs:nojekyll",
71
+ "docs": "npm-run-all docs:clean docs:typedoc",
69
72
  "docs:clean": "npx rimraf docs",
70
- "docs:typedoc": "npx typedoc --out ./docs src/index.ts",
71
- "docs:nojekyll": "npx touch ./docs/.nojekyll"
73
+ "docs:typedoc": "npx typedoc --out ./docs src/index.ts"
72
74
  }
73
75
  }
@@ -1,15 +1,13 @@
1
- import nodeFetch from "node-fetch";
2
-
3
1
  import { unzipp } from "./util/unzipp";
4
2
  import NarouNovel, { NarouParams } from "./narou";
5
3
 
4
+ type Fetch = typeof fetch;
5
+
6
6
  /**
7
7
  * なろう小説APIへのリクエストを実行する
8
- * @class NarouNovel
9
- * @private
10
8
  */
11
9
  export default class NarouNovelFetch extends NarouNovel {
12
- constructor(private fetch = nodeFetch) {
10
+ constructor(private fetch: Fetch = require('node-fetch')) {
13
11
  super();
14
12
  }
15
13
 
@@ -33,18 +31,10 @@ export default class NarouNovelFetch extends NarouNovel {
33
31
  const res = await this.fetch(url);
34
32
 
35
33
  if (query.gzip === 0) {
36
- return await res.json();
34
+ return (await res.json()) as T;
37
35
  }
38
36
 
39
- const buffer = await res.buffer();
40
- try {
41
- return await unzipp(buffer);
42
- } catch {
43
- try {
44
- throw JSON.stringify(buffer.toString());
45
- } catch {
46
- throw buffer.toString();
47
- }
48
- }
37
+ const buffer = await res.arrayBuffer();
38
+ return await unzipp(buffer);
49
39
  }
50
40
  }
@@ -3,8 +3,6 @@ import { jsonp } from "./util/jsonp";
3
3
 
4
4
  /**
5
5
  * なろう小説APIへのリクエストを実行する
6
- * @class NarouNovel
7
- * @private
8
6
  */
9
7
  export default class NarouNovelJsonp extends NarouNovel {
10
8
  protected async execute<T>(
@@ -2,12 +2,22 @@ import { PickedNarouSearchResult } from "./narou-search-results";
2
2
  import { SearchResultFieldNames } from "./params";
3
3
  import { DefaultSearchResultFields } from "./search-builder";
4
4
 
5
+ /**
6
+ * ランキングAPIの結果
7
+ * @see https://dev.syosetu.com/man/rankapi/#output
8
+ */
5
9
  export interface NarouRankingResult {
10
+ /** Nコード */
6
11
  ncode: string;
12
+ /** 順位 */
7
13
  rank: number;
14
+ /** ポイント */
8
15
  pt: number;
9
16
  }
10
17
 
18
+ /**
19
+ * ランキングと小説情報をマージした結果
20
+ */
11
21
  export type RankingResult<
12
22
  T extends SearchResultFieldNames = DefaultSearchResultFields
13
23
  > = Partial<PickedNarouSearchResult<T>> & NarouRankingResult;
@@ -12,14 +12,31 @@ import {
12
12
 
13
13
  /**
14
14
  * なろう小説API検索結果
15
- * @class NarouSearchResults
16
15
  */
17
16
  export default class NarouSearchResults<T, TKey extends keyof T> {
17
+ /**
18
+ * 検索結果数
19
+ */
18
20
  allcount: number;
21
+ /**
22
+ * 結果表示上限数
23
+ */
19
24
  limit: number;
25
+ /**
26
+ * 結果表示開始数
27
+ */
20
28
  start: number;
29
+ /**
30
+ * 結果表示の現在ページ(=start/limit)
31
+ */
21
32
  page: number;
33
+ /**
34
+ * 今回取得できた検索結果の数
35
+ */
22
36
  length: number;
37
+ /**
38
+ * 検索結果
39
+ */
23
40
  values: readonly Pick<T, TKey>[];
24
41
 
25
42
  /**
@@ -34,138 +51,176 @@ export default class NarouSearchResults<T, TKey extends keyof T> {
34
51
  const limit = params.lim ?? 20;
35
52
  const start = params.st ?? 0;
36
53
 
37
- /**
38
- * 検索結果数
39
- * @type {number}
40
- */
41
54
  this.allcount = count;
42
- /**
43
- * 結果表示上限数
44
- * @type {number}
45
- */
46
55
  this.limit = limit;
47
- /**
48
- * 結果表示開始数
49
- * @type {number}
50
- */
51
56
  this.start = start;
52
- /**
53
- * 結果表示ページ数
54
- * @type {number}
55
- */
56
57
  this.page = start / limit;
57
- /**
58
- * 結果数
59
- * @type {number}
60
- */
61
58
  this.length = result.length;
62
- /**
63
- * 検索結果
64
- * @type {PickedNarouSearchResult<T>[]}
65
- */
66
59
  this.values = result;
67
60
  }
68
61
  }
69
62
 
70
63
  /**
71
- * @typedef {Object} NarouSearchResult
72
- * @property {number} title 小説名
73
- * @property {string} ncode Nコード
74
- * @property {number} userid 作者のユーザID(数値)
75
- * @property {string} writer 作者名
76
- * @property {string} story 小説のあらすじ
77
- * @property {number} genre ジャンル
78
- * @property {string} keyword キーワード
79
- * @property {string} general_firstup 初回掲載日 YYYY-MM-DD HH:MM:SSの形式
80
- * @property {string} general_lastup 最終掲載日 YYYY-MM-DD HH:MM:SSの形式
81
- * @property {number} noveltype 連載の場合は1、短編の場合は2
82
- * @property {number} end 短編小説と完結済小説は0となっています。連載中は1です。
83
- * @property {number} general_all_no 全掲載話数です。短編の場合は1です。
84
- * @property {number} length 全掲載話数です。短編の場合は1です。
85
- * @property {number} time 読了時間(分単位)です。読了時間は小説文字数÷500を切り上げした数値です。
86
- * @property {number} isstop 長期連載中は1、それ以外は0です。
87
- * @property {number} pc_or_k 1はケータイのみ、2はPCのみ、3はPCとケータイで投稿された作品です。対象は投稿と次話投稿時のみで、どの端末で執筆されたかを表すものではありません。
88
- * @property {number} global_point 総合得点(=(ブックマーク数×2)+評価点)
89
- * @property {number} fav_novel_cnt ブックマーク数
90
- * @property {number} review_cnt レビュー数
91
- * @property {number} all_point 評価点
92
- * @property {number} all_hyoka_cnt 評価者数
93
- * @property {number} sasie_cnt 挿絵の数
94
- * @property {number} kaiwaritu 会話率
95
- * @property {number} novelupdated_at 小説の更新日時
96
- * @property {number} updated_at 最終更新日時(注意:システム用で小説更新時とは関係ありません)
64
+ * 小説情報
65
+ * @see https://dev.syosetu.com/man/api/#output
66
+ * @see https://dev.syosetu.com/xman/api/#output
97
67
  */
98
-
99
68
  export interface NarouSearchResult {
69
+ /** 小説名 */
100
70
  title: string;
71
+ /** Nコード */
101
72
  ncode: string;
73
+ /** 作者のユーザID(数値) */
102
74
  userid: number;
75
+ /** 作者名 */
103
76
  writer: string;
77
+ /** 小説のあらすじ */
104
78
  story: string;
79
+ /** 掲載サイト */
105
80
  nocgenre: R18Site;
81
+ /** 大ジャンル */
106
82
  biggenre: BigGenre;
83
+ /** ジャンル */
107
84
  genre: Genre;
85
+ /** キーワード */
108
86
  keyword: string;
87
+ /** 初回掲載日 YYYY-MM-DD HH:MM:SSの形式 */
109
88
  general_firstup: string;
89
+ /** 最終掲載日 YYYY-MM-DD HH:MM:SSの形式 */
110
90
  general_lastup: string;
111
- novel_type: number;
91
+ /** 連載の場合は1、短編の場合は2 */
92
+ novel_type: NovelType;
93
+ /** 連載の場合は1、短編の場合は2 */
112
94
  noveltype: NovelType;
95
+ /** 短編小説と完結済小説は0となっています。連載中は1です。 */
113
96
  end: End;
97
+ /** 全掲載話数です。短編の場合は1です。 */
114
98
  general_all_no: number;
99
+ /** 小説文字数です。スペースや改行は文字数としてカウントしません。 */
115
100
  length: number;
101
+ /** 読了時間(分単位)です。読了時間は小説文字数÷500を切り上げした数値です。 */
116
102
  time: number;
103
+ /** 長期連載中は1、それ以外は0です。 */
117
104
  isstop: BooleanNumber;
105
+ /** 登録必須キーワードに「R15」が含まれる場合は1、それ以外は0です。 */
118
106
  isr15: BooleanNumber;
107
+ /** 登録必須キーワードに「ボーイズラブ」が含まれる場合は1、それ以外は0です。 */
119
108
  isbl: BooleanNumber;
109
+ /** 登録必須キーワードに「ガールズラブ」が含まれる場合は1、それ以外は0です。 */
120
110
  isgl: BooleanNumber;
111
+ /** 登録必須キーワードに「残酷な描写あり」が含まれる場合は1、それ以外は0です。 */
121
112
  iszankoku: BooleanNumber;
113
+ /** 登録必須キーワードに「異世界転生」が含まれる場合は1、それ以外は0です。 */
122
114
  istensei: BooleanNumber;
115
+ /** 登録必須キーワードに「異世界転移」が含まれる場合は1、それ以外は0です。 */
123
116
  istenni: BooleanNumber;
124
- pc_or_k: PcOrK;
117
+ /** 総合得点(=(ブックマーク数×2)+評価点) */
125
118
  global_point: number;
119
+ /**
120
+ * 日間ポイント
121
+ * ランキング集計時点から過去24時間以内で新たに登録されたブックマークや評価が対象
122
+ */
126
123
  daily_point: number;
124
+ /**
125
+ * 週間ポイント
126
+ * ランキング集計時点から過去7日以内で新たに登録されたブックマークや評価が対象
127
+ */
127
128
  weekly_point: number;
129
+ /**
130
+ * 月間ポイント
131
+ * ランキング集計時点から過去30日以内で新たに登録されたブックマークや評価が対象
132
+ */
128
133
  monthly_point: number;
134
+ /**
135
+ * 四半期ポイント
136
+ * ランキング集計時点から過去90日以内で新たに登録されたブックマークや評価が対象
137
+ */
129
138
  quarter_point: number;
139
+ /**
140
+ * 年間ポイント
141
+ * ランキング集計時点から過去365日以内で新たに登録されたブックマークや評価が対象
142
+ */
130
143
  yearly_point: number;
144
+ /** ブックマーク数 */
131
145
  fav_novel_cnt: number;
146
+ /** 感想数 */
132
147
  impression_cnt: number;
148
+ /** レビュー数 */
133
149
  review_cnt: number;
150
+ /** 評価ポイント */
134
151
  all_point: number;
152
+ /** 評価者数 */
135
153
  all_hyoka_cnt: number;
154
+ /** 挿絵の数 */
136
155
  sasie_cnt: number;
156
+ /**
157
+ * 会話率
158
+ * @see https://dev.syosetu.com/man/kaiwa/
159
+ */
137
160
  kaiwaritu: number;
161
+ /**
162
+ * 小説の更新日時
163
+ */
138
164
  novelupdated_at: string;
165
+ /**
166
+ * 最終更新日時
167
+ * システム用で小説更新時とは関係ありません
168
+ */
139
169
  updated_at: string;
170
+ /** 週間ユニークユーザー数 */
140
171
  weekly_unique: number;
141
172
  }
142
173
 
174
+ /**
175
+ * ユーザ情報
176
+ * @see https://dev.syosetu.com/man/userapi/#output
177
+ */
143
178
  export interface UserSearchResult {
179
+ /** ユーザID */
144
180
  userid: number;
181
+ /** ユーザ名 */
145
182
  name: string;
183
+ /** ユーザ名のフリガナ */
146
184
  yomikata: string;
185
+ /**
186
+ * ユーザ名のフリガナの頭文字
187
+ * ひらがな以外の場合はnullまたは空文字となります。
188
+ */
147
189
  name1st: string;
190
+ /** 小説投稿数 */
148
191
  novel_cnt: number;
192
+ /** レビュー投稿数 */
149
193
  review_cnt: number;
194
+ /**
195
+ * 小説累計文字数
196
+ * スペースや改行は文字数としてカウントしません。
197
+ */
150
198
  novel_length: number;
199
+ /**
200
+ * 総合評価ポイントの合計
201
+ * 投稿済小説でそれぞれ獲得した総合評価ポイントの合計です。
202
+ */
151
203
  sum_global_point: number;
152
204
  }
153
205
 
154
- export const PcOrK = {
155
- Ketai: 1,
156
- Pc: 2,
157
- PcAndKetai: 3,
158
- } as const;
159
- export type PcOrK = typeof PcOrK[keyof typeof PcOrK];
160
-
206
+ /**
207
+ * noveltype/novel_typeの値ヘルパー
208
+ */
161
209
  export const NovelType = {
210
+ /** 連載 */
162
211
  Rensai: 1,
212
+ /** 短編 */
163
213
  Tanpen: 2,
164
214
  } as const;
165
215
  export type NovelType = typeof NovelType[keyof typeof NovelType];
166
216
 
217
+ /**
218
+ * endの値ヘルパー
219
+ */
167
220
  export const End = {
221
+ /** 短編小説と完結済小説 */
168
222
  KanketsuOrTanpen: 0,
223
+ /** 連載中 */
169
224
  Rensai: 1,
170
225
  } as const;
171
226
  export type End = typeof End[keyof typeof End];
@@ -176,8 +231,8 @@ export type SearchResultFields<T extends Fields> = {
176
231
 
177
232
  export type SearchResultOptionalFields<T extends OptionalFields> = {
178
233
  [K in keyof typeof OptionalFields]: typeof OptionalFields[K] extends T
179
- ? K
180
- : never;
234
+ ? K
235
+ : never;
181
236
  }[keyof typeof OptionalFields];
182
237
 
183
238
  export type SearchResultR18Fields<T extends R18Fields> = {