narou 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +78 -35
- package/dist/index.browser.cjs +87 -1230
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +31 -24
- package/dist/index.browser.d.mts +47 -0
- package/dist/index.browser.mjs +66 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.cjs +147 -1281
- package/dist/index.cjs.map +1 -1
- package/dist/index.common-8lS2K_1Y.mjs +1166 -0
- package/dist/index.common-8lS2K_1Y.mjs.map +1 -0
- package/dist/index.common-CYj0n0aU.cjs +1346 -0
- package/dist/index.common-CYj0n0aU.cjs.map +1 -0
- package/dist/index.d.cts +39 -23
- package/dist/index.d.mts +63 -0
- package/dist/index.mjs +128 -0
- package/dist/index.mjs.map +1 -0
- package/dist/user-search-BY6FdEe7.d.cts +1394 -0
- package/dist/user-search-Besgk-Hx.d.mts +1394 -0
- package/package.json +34 -45
- package/pnpm-lock.yaml +2523 -2175
- package/src/index.browser.ts +21 -5
- package/src/index.ts +16 -3
- package/src/narou-fetch.ts +4 -3
- package/src/narou-jsonp.ts +4 -2
- package/src/narou-search-results.ts +2 -1
- package/src/narou.ts +53 -13
- package/src/params.ts +2 -2
- package/src/ranking-history.ts +13 -4
- package/src/ranking.ts +99 -26
- package/src/search-builder-r18.ts +23 -6
- package/src/search-builder.ts +183 -76
- package/src/user-search.ts +9 -2
- package/src/util/date.ts +38 -0
- package/src/util/jsonp.ts +61 -6
- package/src/util/type.ts +23 -0
- package/src/util/unzipp.ts +9 -0
- package/dist/chunk-4VC3246A.js +0 -83
- package/dist/chunk-4VC3246A.js.map +0 -1
- package/dist/chunk-4ZP5YNWI.js +0 -1
- package/dist/chunk-4ZP5YNWI.js.map +0 -1
- package/dist/chunk-AZT2OXBZ.js +0 -26
- package/dist/chunk-AZT2OXBZ.js.map +0 -1
- package/dist/chunk-CDOBNSCL.js +0 -407
- package/dist/chunk-CDOBNSCL.js.map +0 -1
- package/dist/chunk-K22KVNAH.js +0 -94
- package/dist/chunk-K22KVNAH.js.map +0 -1
- package/dist/chunk-NVMUSXA5.js +0 -23
- package/dist/chunk-NVMUSXA5.js.map +0 -1
- package/dist/chunk-P7QOZBII.js +0 -386
- package/dist/chunk-P7QOZBII.js.map +0 -1
- package/dist/chunk-RITMMCZE.js +0 -37
- package/dist/chunk-RITMMCZE.js.map +0 -1
- package/dist/chunk-SNPBEVCY.js +0 -44
- package/dist/chunk-SNPBEVCY.js.map +0 -1
- package/dist/chunk-UN3W2CT3.js +0 -72
- package/dist/chunk-UN3W2CT3.js.map +0 -1
- package/dist/chunk-WYSPGQ3S.js +0 -44
- package/dist/chunk-WYSPGQ3S.js.map +0 -1
- package/dist/chunk-XAUB42TO.js +0 -15
- package/dist/chunk-XAUB42TO.js.map +0 -1
- package/dist/chunk-XVH2CU2Q.js +0 -39
- package/dist/chunk-XVH2CU2Q.js.map +0 -1
- package/dist/index.browser.d.ts +0 -40
- package/dist/index.browser.js +0 -125
- package/dist/index.browser.js.map +0 -1
- package/dist/index.common.cjs +0 -1058
- package/dist/index.common.cjs.map +0 -1
- package/dist/index.common.d.cts +0 -6
- package/dist/index.common.d.ts +0 -6
- package/dist/index.common.js +0 -75
- package/dist/index.common.js.map +0 -1
- package/dist/index.d.ts +0 -47
- package/dist/index.js +0 -130
- package/dist/index.js.map +0 -1
- package/dist/narou-CatW_TC9.d.cts +0 -301
- package/dist/narou-fH9osIoh.d.ts +0 -301
- package/dist/narou-fetch.cjs +0 -161
- package/dist/narou-fetch.cjs.map +0 -1
- package/dist/narou-fetch.d.cts +0 -20
- package/dist/narou-fetch.d.ts +0 -20
- package/dist/narou-fetch.js +0 -10
- package/dist/narou-fetch.js.map +0 -1
- package/dist/narou-jsonp.cjs +0 -159
- package/dist/narou-jsonp.cjs.map +0 -1
- package/dist/narou-jsonp.d.cts +0 -13
- package/dist/narou-jsonp.d.ts +0 -13
- package/dist/narou-jsonp.js +0 -10
- package/dist/narou-jsonp.js.map +0 -1
- package/dist/narou-ranking-results.cjs +0 -19
- package/dist/narou-ranking-results.cjs.map +0 -1
- package/dist/narou-ranking-results.d.cts +0 -4
- package/dist/narou-ranking-results.d.ts +0 -4
- package/dist/narou-ranking-results.js +0 -1
- package/dist/narou-ranking-results.js.map +0 -1
- package/dist/narou-search-results-D5yqPRZ7.d.ts +0 -727
- package/dist/narou-search-results-DWCJWTC5.d.cts +0 -727
- package/dist/narou-search-results.cjs +0 -62
- package/dist/narou-search-results.cjs.map +0 -1
- package/dist/narou-search-results.d.cts +0 -2
- package/dist/narou-search-results.d.ts +0 -2
- package/dist/narou-search-results.js +0 -11
- package/dist/narou-search-results.js.map +0 -1
- package/dist/narou.cjs +0 -109
- package/dist/narou.cjs.map +0 -1
- package/dist/narou.d.cts +0 -4
- package/dist/narou.d.ts +0 -4
- package/dist/narou.js +0 -8
- package/dist/narou.js.map +0 -1
- package/dist/params.cjs +0 -448
- package/dist/params.cjs.map +0 -1
- package/dist/params.d.cts +0 -2
- package/dist/params.d.ts +0 -2
- package/dist/params.js +0 -41
- package/dist/params.js.map +0 -1
- package/dist/ranking-history.cjs +0 -39
- package/dist/ranking-history.cjs.map +0 -1
- package/dist/ranking-history.d.cts +0 -17
- package/dist/ranking-history.d.ts +0 -17
- package/dist/ranking-history.js +0 -7
- package/dist/ranking-history.js.map +0 -1
- package/dist/ranking.cjs +0 -674
- package/dist/ranking.cjs.map +0 -1
- package/dist/ranking.d.cts +0 -47
- package/dist/ranking.d.ts +0 -47
- package/dist/ranking.js +0 -9
- package/dist/ranking.js.map +0 -1
- package/dist/search-builder-r18.cjs +0 -488
- package/dist/search-builder-r18.cjs.map +0 -1
- package/dist/search-builder-r18.d.cts +0 -32
- package/dist/search-builder-r18.d.ts +0 -32
- package/dist/search-builder-r18.js +0 -9
- package/dist/search-builder-r18.js.map +0 -1
- package/dist/search-builder.cjs +0 -525
- package/dist/search-builder.cjs.map +0 -1
- package/dist/search-builder.d.cts +0 -4
- package/dist/search-builder.d.ts +0 -4
- package/dist/search-builder.js +0 -12
- package/dist/search-builder.js.map +0 -1
- package/dist/user-search.cjs +0 -301
- package/dist/user-search.cjs.map +0 -1
- package/dist/user-search.d.cts +0 -66
- package/dist/user-search.d.ts +0 -66
- package/dist/user-search.js +0 -9
- package/dist/user-search.js.map +0 -1
- package/dist/util/jsonp.cjs +0 -63
- package/dist/util/jsonp.cjs.map +0 -1
- package/dist/util/jsonp.d.cts +0 -13
- package/dist/util/jsonp.d.ts +0 -13
- package/dist/util/jsonp.js +0 -7
- package/dist/util/jsonp.js.map +0 -1
- package/dist/util/type.cjs +0 -19
- package/dist/util/type.cjs.map +0 -1
- package/dist/util/type.d.cts +0 -4
- package/dist/util/type.d.ts +0 -4
- package/dist/util/type.js +0 -1
- package/dist/util/type.js.map +0 -1
- package/dist/util/unzipp.cjs +0 -47
- package/dist/util/unzipp.cjs.map +0 -1
- package/dist/util/unzipp.d.cts +0 -3
- package/dist/util/unzipp.d.ts +0 -3
- package/dist/util/unzipp.js +0 -7
- package/dist/util/unzipp.js.map +0 -1
package/dist/narou-fetch.cjs
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/narou-fetch.ts
|
|
21
|
-
var narou_fetch_exports = {};
|
|
22
|
-
__export(narou_fetch_exports, {
|
|
23
|
-
default: () => NarouNovelFetch
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(narou_fetch_exports);
|
|
26
|
-
|
|
27
|
-
// src/util/unzipp.ts
|
|
28
|
-
var import_zlib = require("zlib");
|
|
29
|
-
var import_util = require("util");
|
|
30
|
-
var gunzipAsync = (0, import_util.promisify)(import_zlib.gunzip);
|
|
31
|
-
var decoder = new TextDecoder();
|
|
32
|
-
async function unzipp(data) {
|
|
33
|
-
try {
|
|
34
|
-
const buffer = await gunzipAsync(data);
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(decoder.decode(buffer));
|
|
37
|
-
} catch {
|
|
38
|
-
throw decoder.decode(buffer);
|
|
39
|
-
}
|
|
40
|
-
} catch (e) {
|
|
41
|
-
if (typeof e === "string") throw e;
|
|
42
|
-
throw decoder.decode(data);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/narou-search-results.ts
|
|
47
|
-
var NarouSearchResults = class {
|
|
48
|
-
/**
|
|
49
|
-
* @constractor
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
constructor([header, ...result], params) {
|
|
53
|
-
const count = header.allcount;
|
|
54
|
-
const limit = params.lim ?? 20;
|
|
55
|
-
const start = params.st ?? 0;
|
|
56
|
-
this.allcount = count;
|
|
57
|
-
this.limit = limit;
|
|
58
|
-
this.start = start;
|
|
59
|
-
this.page = start / limit;
|
|
60
|
-
this.length = result.length;
|
|
61
|
-
this.values = result;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// src/narou.ts
|
|
66
|
-
var NarouNovel = class {
|
|
67
|
-
/**
|
|
68
|
-
* APIへの検索リクエストを実行する
|
|
69
|
-
* @param params クエリパラメータ
|
|
70
|
-
* @param endpoint APIエンドポイント
|
|
71
|
-
* @returns 検索結果
|
|
72
|
-
*/
|
|
73
|
-
async executeSearch(params, endpoint = "https://api.syosetu.com/novelapi/api/") {
|
|
74
|
-
return new NarouSearchResults(await this.execute(params, endpoint), params);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* 小説APIへの検索リクエストを実行する
|
|
78
|
-
* @param params クエリパラメータ
|
|
79
|
-
* @returns 検索結果
|
|
80
|
-
* @see https://dev.syosetu.com/man/api/
|
|
81
|
-
*/
|
|
82
|
-
async executeNovel(params) {
|
|
83
|
-
return await this.executeSearch(
|
|
84
|
-
params,
|
|
85
|
-
"https://api.syosetu.com/novelapi/api/"
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* R18小説APIへの検索リクエストを実行する
|
|
90
|
-
* @param params クエリパラメータ
|
|
91
|
-
* @returns 検索結果
|
|
92
|
-
* @see https://dev.syosetu.com/xman/api/
|
|
93
|
-
*/
|
|
94
|
-
async executeNovel18(params) {
|
|
95
|
-
return await this.executeSearch(
|
|
96
|
-
params,
|
|
97
|
-
"https://api.syosetu.com/novel18api/api/"
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* ランキングAPIへのリクエストを実行する
|
|
102
|
-
* @param params クエリパラメータ
|
|
103
|
-
* @returns ランキング結果
|
|
104
|
-
* @see https://dev.syosetu.com/man/rankapi/
|
|
105
|
-
*/
|
|
106
|
-
async executeRanking(params) {
|
|
107
|
-
return await this.execute(params, "https://api.syosetu.com/rank/rankget/");
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* 殿堂入りAPiへのリクエストを実行する
|
|
111
|
-
* @param params クエリパラメータ
|
|
112
|
-
* @returns ランキング履歴結果
|
|
113
|
-
* @see https://dev.syosetu.com/man/rankinapi/
|
|
114
|
-
*/
|
|
115
|
-
async executeRankingHistory(params) {
|
|
116
|
-
return await this.execute(params, "https://api.syosetu.com/rank/rankin/");
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* ユーザー検索APIへのリクエストを実行する
|
|
120
|
-
* @param params クエリパラメータ
|
|
121
|
-
* @returns 検索結果
|
|
122
|
-
* @see https://dev.syosetu.com/man/userapi/
|
|
123
|
-
*/
|
|
124
|
-
async executeUserSearch(params) {
|
|
125
|
-
return await this.execute(params, "https://api.syosetu.com/userapi/api/");
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// src/narou-fetch.ts
|
|
130
|
-
var NarouNovelFetch = class extends NarouNovel {
|
|
131
|
-
/**
|
|
132
|
-
* コンストラクタ
|
|
133
|
-
* @param fetch fetch関数(デフォルトはネイティブのfetch)
|
|
134
|
-
*/
|
|
135
|
-
constructor(fetch2) {
|
|
136
|
-
super();
|
|
137
|
-
this.fetch = fetch2;
|
|
138
|
-
}
|
|
139
|
-
async execute(params, endpoint) {
|
|
140
|
-
const query = { ...params, out: "json" };
|
|
141
|
-
if (query.gzip === void 0) {
|
|
142
|
-
query.gzip = 5;
|
|
143
|
-
}
|
|
144
|
-
if (query.gzip === 0) {
|
|
145
|
-
delete query.gzip;
|
|
146
|
-
}
|
|
147
|
-
const url = new URL(endpoint);
|
|
148
|
-
Object.entries(query).forEach(([key, value]) => {
|
|
149
|
-
if (value !== void 0) {
|
|
150
|
-
url.searchParams.append(key, value.toString());
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
const res = await (this.fetch ?? fetch)(url);
|
|
154
|
-
if (!query.gzip) {
|
|
155
|
-
return await res.json();
|
|
156
|
-
}
|
|
157
|
-
const buffer = await res.arrayBuffer();
|
|
158
|
-
return await unzipp(buffer);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
//# sourceMappingURL=narou-fetch.cjs.map
|
package/dist/narou-fetch.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/narou-fetch.ts","../src/util/unzipp.ts","../src/narou-search-results.ts","../src/narou.ts"],"sourcesContent":["import { unzipp } from \"./util/unzipp.js\";\nimport NarouNovel from \"./narou.js\";\nimport type { NarouParams } from \"./narou.js\";\n\ntype Fetch = typeof fetch;\n\n/**\n * なろう小説APIへのリクエストを実行する\n */\nexport default class NarouNovelFetch extends NarouNovel {\n /**\n * コンストラクタ\n * @param fetch fetch関数(デフォルトはネイティブのfetch)\n */\n constructor(private fetch?: Fetch) {\n super();\n }\n\n protected async execute<T>(\n params: NarouParams,\n endpoint: string\n ): Promise<T> {\n const query = { ...params, out: \"json\" };\n\n if (query.gzip === undefined) {\n query.gzip = 5;\n }\n if (query.gzip === 0) {\n delete query.gzip;\n }\n const url = new URL(endpoint);\n\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, value.toString());\n }\n });\n\n const res = await (this.fetch ?? fetch)(url);\n\n if (!query.gzip) {\n return (await res.json()) as T;\n }\n\n const buffer = await res.arrayBuffer();\n return await unzipp(buffer);\n }\n}\n","import { gunzip, InputType } from \"zlib\";\nimport { promisify } from \"util\";\n\nconst gunzipAsync = promisify<InputType, Buffer>(gunzip);\n\nconst decoder = new TextDecoder()\nexport async function unzipp(data: ArrayBuffer) {\n try {\n const buffer = await gunzipAsync(data);\n try {\n return JSON.parse(decoder.decode(buffer));\n } catch {\n throw decoder.decode(buffer);\n }\n } catch (e) {\n if (typeof e === \"string\") throw e;\n throw decoder.decode(data);\n }\n}\n","import type {\n BooleanNumber as BooleanNumber,\n Genre,\n R18Site,\n SearchParams,\n Fields,\n BigGenre,\n R18Fields,\n OptionalFields,\n UserFields,\n} from \"./params.js\";\n\n/**\n * なろう小説API検索結果\n */\nexport default class NarouSearchResults<T, TKey extends keyof T> {\n /**\n * 検索結果数\n */\n allcount: number;\n /**\n * 結果表示上限数\n */\n limit: number;\n /**\n * 結果表示開始数\n */\n start: number;\n /**\n * 結果表示の現在ページ(=start/limit)\n */\n page: number;\n /**\n * 今回取得できた検索結果の数\n */\n length: number;\n /**\n * 検索結果\n */\n values: readonly Pick<T, TKey>[];\n\n /**\n * @constractor\n * @private\n */\n constructor(\n [header, ...result]: [{ allcount: number }, ...Pick<T, TKey>[]],\n params: SearchParams\n ) {\n const count = header.allcount;\n const limit = params.lim ?? 20;\n const start = params.st ?? 0;\n\n this.allcount = count;\n this.limit = limit;\n this.start = start;\n this.page = start / limit;\n this.length = result.length;\n this.values = result;\n }\n}\n\n/**\n * 小説情報\n * @see https://dev.syosetu.com/man/api/#output\n * @see https://dev.syosetu.com/xman/api/#output\n */\nexport interface NarouSearchResult {\n /** 小説名 */\n title: string;\n /** Nコード */\n ncode: string;\n /** 作者のユーザID(数値) */\n userid: number;\n /** 作者名 */\n writer: string;\n /** 小説のあらすじ */\n story: string;\n /** 掲載サイト */\n nocgenre: R18Site;\n /** 大ジャンル */\n biggenre: BigGenre;\n /** ジャンル */\n genre: Genre;\n /** キーワード */\n keyword: string;\n /** 初回掲載日 YYYY-MM-DD HH:MM:SSの形式 */\n general_firstup: string;\n /** 最終掲載日 YYYY-MM-DD HH:MM:SSの形式 */\n general_lastup: string;\n /** 連載の場合は1、短編の場合は2 */\n novel_type: NovelType;\n /** 連載の場合は1、短編の場合は2 */\n noveltype: NovelType;\n /** 短編小説と完結済小説は0となっています。連載中は1です。 */\n end: End;\n /** 全掲載話数です。短編の場合は1です。 */\n general_all_no: number;\n /** 小説文字数です。スペースや改行は文字数としてカウントしません。 */\n length: number;\n /** 読了時間(分単位)です。読了時間は小説文字数÷500を切り上げした数値です。 */\n time: number;\n /** 長期連載中は1、それ以外は0です。 */\n isstop: BooleanNumber;\n /** 登録必須キーワードに「R15」が含まれる場合は1、それ以外は0です。 */\n isr15: BooleanNumber;\n /** 登録必須キーワードに「ボーイズラブ」が含まれる場合は1、それ以外は0です。 */\n isbl: BooleanNumber;\n /** 登録必須キーワードに「ガールズラブ」が含まれる場合は1、それ以外は0です。 */\n isgl: BooleanNumber;\n /** 登録必須キーワードに「残酷な描写あり」が含まれる場合は1、それ以外は0です。 */\n iszankoku: BooleanNumber;\n /** 登録必須キーワードに「異世界転生」が含まれる場合は1、それ以外は0です。 */\n istensei: BooleanNumber;\n /** 登録必須キーワードに「異世界転移」が含まれる場合は1、それ以外は0です。 */\n istenni: BooleanNumber;\n /** 総合得点(=(ブックマーク数×2)+評価点) */\n global_point: number;\n /**\n * 日間ポイント\n * ランキング集計時点から過去24時間以内で新たに登録されたブックマークや評価が対象\n */\n daily_point: number;\n /**\n * 週間ポイント\n * ランキング集計時点から過去7日以内で新たに登録されたブックマークや評価が対象\n */\n weekly_point: number;\n /**\n * 月間ポイント\n * ランキング集計時点から過去30日以内で新たに登録されたブックマークや評価が対象\n */\n monthly_point: number;\n /**\n * 四半期ポイント\n * ランキング集計時点から過去90日以内で新たに登録されたブックマークや評価が対象\n */\n quarter_point: number;\n /**\n * 年間ポイント\n * ランキング集計時点から過去365日以内で新たに登録されたブックマークや評価が対象\n */\n yearly_point: number;\n /** ブックマーク数 */\n fav_novel_cnt: number;\n /** 感想数 */\n impression_cnt: number;\n /** レビュー数 */\n review_cnt: number;\n /** 評価ポイント */\n all_point: number;\n /** 評価者数 */\n all_hyoka_cnt: number;\n /** 挿絵の数 */\n sasie_cnt: number;\n /**\n * 会話率\n * @see https://dev.syosetu.com/man/kaiwa/\n */\n kaiwaritu: number;\n /**\n * 小説の更新日時\n */\n novelupdated_at: string;\n /**\n * 最終更新日時\n * システム用で小説更新時とは関係ありません\n */\n updated_at: string;\n /** 週間ユニークユーザー数 */\n weekly_unique: number;\n}\n\n/**\n * ユーザ情報\n * @see https://dev.syosetu.com/man/userapi/#output\n */\nexport interface UserSearchResult {\n /** ユーザID */\n userid: number;\n /** ユーザ名 */\n name: string;\n /** ユーザ名のフリガナ */\n yomikata: string;\n /**\n * ユーザ名のフリガナの頭文字\n * ひらがな以外の場合はnullまたは空文字となります。\n */\n name1st: string;\n /** 小説投稿数 */\n novel_cnt: number;\n /** レビュー投稿数 */\n review_cnt: number;\n /**\n * 小説累計文字数\n * スペースや改行は文字数としてカウントしません。\n */\n novel_length: number;\n /**\n * 総合評価ポイントの合計\n * 投稿済小説でそれぞれ獲得した総合評価ポイントの合計です。\n */\n sum_global_point: number;\n}\n\n/**\n * noveltype/novel_typeの値ヘルパー\n */\nexport const NovelType = {\n /** 連載 */\n Rensai: 1,\n /** 短編 */\n Tanpen: 2,\n} as const;\nexport type NovelType = typeof NovelType[keyof typeof NovelType];\n\n/**\n * endの値ヘルパー\n */\nexport const End = {\n /** 短編小説と完結済小説 */\n KanketsuOrTanpen: 0,\n /** 連載中 */\n Rensai: 1,\n} as const;\nexport type End = typeof End[keyof typeof End];\n\nexport type SearchResultFields<T extends Fields> = {\n [K in keyof typeof Fields]: typeof Fields[K] extends T ? K : never;\n}[keyof typeof Fields];\n\nexport type SearchResultOptionalFields<T extends OptionalFields> = {\n [K in keyof typeof OptionalFields]: typeof OptionalFields[K] extends T\n ? K\n : never;\n}[keyof typeof OptionalFields];\n\nexport type SearchResultR18Fields<T extends R18Fields> = {\n [K in keyof typeof R18Fields]: typeof R18Fields[K] extends T ? K : never;\n}[keyof typeof R18Fields];\n\nexport type UserSearchResultFields<T extends UserFields> = {\n [K in keyof typeof UserFields]: typeof UserFields[K] extends T ? K : never;\n}[keyof typeof UserFields];\n\nexport type PickedNarouSearchResult<T extends keyof NarouSearchResult> = Pick<\n NarouSearchResult,\n T\n>;\n","import type { NarouRankingResult } from \"./narou-ranking-results.js\";\nimport NarouSearchResults from \"./narou-search-results.js\";\nimport type {\n NarouSearchResult,\n UserSearchResult,\n} from \"./narou-search-results.js\";\nimport type {\n RankingHistoryParams,\n RankingParams,\n SearchParams,\n UserSearchParams,\n} from \"./params.js\";\nimport type { RankingHistoryRawResult } from \"./ranking-history.js\";\n\n/**\n * なろう小説APIへのリクエストパラメータ\n */\nexport type NarouParams =\n | SearchParams\n | RankingParams\n | RankingHistoryParams\n | UserSearchParams;\n\n/**\n * なろう小説APIへのリクエストを実行する\n * @class NarouNovel\n * @private\n */\nexport default abstract class NarouNovel {\n /**\n * なろうAPIへのAPIリクエストを実行する\n * @param params クエリパラメータ\n * @param endpoint APIエンドポイント\n * @returns 実行結果\n */\n protected abstract execute<T>(\n params: NarouParams,\n endpoint: string\n ): Promise<T>;\n\n /**\n * APIへの検索リクエストを実行する\n * @param params クエリパラメータ\n * @param endpoint APIエンドポイント\n * @returns 検索結果\n */\n protected async executeSearch<T extends keyof NarouSearchResult>(\n params: SearchParams,\n endpoint = \"https://api.syosetu.com/novelapi/api/\"\n ): Promise<NarouSearchResults<NarouSearchResult, T>> {\n return new NarouSearchResults(await this.execute(params, endpoint), params);\n }\n\n /**\n * 小説APIへの検索リクエストを実行する\n * @param params クエリパラメータ\n * @returns 検索結果\n * @see https://dev.syosetu.com/man/api/\n */\n async executeNovel<T extends keyof NarouSearchResult>(\n params: SearchParams\n ): Promise<NarouSearchResults<NarouSearchResult, T>> {\n return await this.executeSearch(\n params,\n \"https://api.syosetu.com/novelapi/api/\"\n );\n }\n\n /**\n * R18小説APIへの検索リクエストを実行する\n * @param params クエリパラメータ\n * @returns 検索結果\n * @see https://dev.syosetu.com/xman/api/\n */\n async executeNovel18<T extends keyof NarouSearchResult>(\n params: SearchParams\n ): Promise<NarouSearchResults<NarouSearchResult, T>> {\n return await this.executeSearch(\n params,\n \"https://api.syosetu.com/novel18api/api/\"\n );\n }\n\n /**\n * ランキングAPIへのリクエストを実行する\n * @param params クエリパラメータ\n * @returns ランキング結果\n * @see https://dev.syosetu.com/man/rankapi/\n */\n async executeRanking(params: RankingParams): Promise<NarouRankingResult[]> {\n return await this.execute(params, \"https://api.syosetu.com/rank/rankget/\");\n }\n\n /**\n * 殿堂入りAPiへのリクエストを実行する\n * @param params クエリパラメータ\n * @returns ランキング履歴結果\n * @see https://dev.syosetu.com/man/rankinapi/\n */\n async executeRankingHistory(\n params: RankingHistoryParams\n ): Promise<RankingHistoryRawResult[]> {\n return await this.execute(params, \"https://api.syosetu.com/rank/rankin/\");\n }\n\n /**\n * ユーザー検索APIへのリクエストを実行する\n * @param params クエリパラメータ\n * @returns 検索結果\n * @see https://dev.syosetu.com/man/userapi/\n */\n async executeUserSearch<T extends keyof UserSearchResult>(\n params: UserSearchParams\n ): Promise<NarouSearchResults<UserSearchResult, T>> {\n return await this.execute(params, \"https://api.syosetu.com/userapi/api/\");\n }\n}\n"],"mappings":"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","names":["fetch"]}
|
package/dist/narou-fetch.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { N as NarouNovel, a as NarouParams } from './narou-CatW_TC9.cjs';
|
|
2
|
-
import './narou-search-results-DWCJWTC5.cjs';
|
|
3
|
-
import './util/type.cjs';
|
|
4
|
-
import './ranking-history.cjs';
|
|
5
|
-
|
|
6
|
-
type Fetch = typeof fetch;
|
|
7
|
-
/**
|
|
8
|
-
* なろう小説APIへのリクエストを実行する
|
|
9
|
-
*/
|
|
10
|
-
declare class NarouNovelFetch extends NarouNovel {
|
|
11
|
-
private fetch?;
|
|
12
|
-
/**
|
|
13
|
-
* コンストラクタ
|
|
14
|
-
* @param fetch fetch関数(デフォルトはネイティブのfetch)
|
|
15
|
-
*/
|
|
16
|
-
constructor(fetch?: Fetch | undefined);
|
|
17
|
-
protected execute<T>(params: NarouParams, endpoint: string): Promise<T>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { NarouNovelFetch as default };
|
package/dist/narou-fetch.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { N as NarouNovel, a as NarouParams } from './narou-fH9osIoh.js';
|
|
2
|
-
import './narou-search-results-D5yqPRZ7.js';
|
|
3
|
-
import './util/type.js';
|
|
4
|
-
import './ranking-history.js';
|
|
5
|
-
|
|
6
|
-
type Fetch = typeof fetch;
|
|
7
|
-
/**
|
|
8
|
-
* なろう小説APIへのリクエストを実行する
|
|
9
|
-
*/
|
|
10
|
-
declare class NarouNovelFetch extends NarouNovel {
|
|
11
|
-
private fetch?;
|
|
12
|
-
/**
|
|
13
|
-
* コンストラクタ
|
|
14
|
-
* @param fetch fetch関数(デフォルトはネイティブのfetch)
|
|
15
|
-
*/
|
|
16
|
-
constructor(fetch?: Fetch | undefined);
|
|
17
|
-
protected execute<T>(params: NarouParams, endpoint: string): Promise<T>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { NarouNovelFetch as default };
|
package/dist/narou-fetch.js
DELETED
package/dist/narou-fetch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/narou-jsonp.cjs
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/narou-jsonp.ts
|
|
21
|
-
var narou_jsonp_exports = {};
|
|
22
|
-
__export(narou_jsonp_exports, {
|
|
23
|
-
default: () => NarouNovelJsonp
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(narou_jsonp_exports);
|
|
26
|
-
|
|
27
|
-
// src/narou-search-results.ts
|
|
28
|
-
var NarouSearchResults = class {
|
|
29
|
-
/**
|
|
30
|
-
* @constractor
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
constructor([header, ...result], params) {
|
|
34
|
-
const count2 = header.allcount;
|
|
35
|
-
const limit = params.lim ?? 20;
|
|
36
|
-
const start = params.st ?? 0;
|
|
37
|
-
this.allcount = count2;
|
|
38
|
-
this.limit = limit;
|
|
39
|
-
this.start = start;
|
|
40
|
-
this.page = start / limit;
|
|
41
|
-
this.length = result.length;
|
|
42
|
-
this.values = result;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// src/narou.ts
|
|
47
|
-
var NarouNovel = class {
|
|
48
|
-
/**
|
|
49
|
-
* APIへの検索リクエストを実行する
|
|
50
|
-
* @param params クエリパラメータ
|
|
51
|
-
* @param endpoint APIエンドポイント
|
|
52
|
-
* @returns 検索結果
|
|
53
|
-
*/
|
|
54
|
-
async executeSearch(params, endpoint = "https://api.syosetu.com/novelapi/api/") {
|
|
55
|
-
return new NarouSearchResults(await this.execute(params, endpoint), params);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 小説APIへの検索リクエストを実行する
|
|
59
|
-
* @param params クエリパラメータ
|
|
60
|
-
* @returns 検索結果
|
|
61
|
-
* @see https://dev.syosetu.com/man/api/
|
|
62
|
-
*/
|
|
63
|
-
async executeNovel(params) {
|
|
64
|
-
return await this.executeSearch(
|
|
65
|
-
params,
|
|
66
|
-
"https://api.syosetu.com/novelapi/api/"
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* R18小説APIへの検索リクエストを実行する
|
|
71
|
-
* @param params クエリパラメータ
|
|
72
|
-
* @returns 検索結果
|
|
73
|
-
* @see https://dev.syosetu.com/xman/api/
|
|
74
|
-
*/
|
|
75
|
-
async executeNovel18(params) {
|
|
76
|
-
return await this.executeSearch(
|
|
77
|
-
params,
|
|
78
|
-
"https://api.syosetu.com/novel18api/api/"
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* ランキングAPIへのリクエストを実行する
|
|
83
|
-
* @param params クエリパラメータ
|
|
84
|
-
* @returns ランキング結果
|
|
85
|
-
* @see https://dev.syosetu.com/man/rankapi/
|
|
86
|
-
*/
|
|
87
|
-
async executeRanking(params) {
|
|
88
|
-
return await this.execute(params, "https://api.syosetu.com/rank/rankget/");
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* 殿堂入りAPiへのリクエストを実行する
|
|
92
|
-
* @param params クエリパラメータ
|
|
93
|
-
* @returns ランキング履歴結果
|
|
94
|
-
* @see https://dev.syosetu.com/man/rankinapi/
|
|
95
|
-
*/
|
|
96
|
-
async executeRankingHistory(params) {
|
|
97
|
-
return await this.execute(params, "https://api.syosetu.com/rank/rankin/");
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* ユーザー検索APIへのリクエストを実行する
|
|
101
|
-
* @param params クエリパラメータ
|
|
102
|
-
* @returns 検索結果
|
|
103
|
-
* @see https://dev.syosetu.com/man/userapi/
|
|
104
|
-
*/
|
|
105
|
-
async executeUserSearch(params) {
|
|
106
|
-
return await this.execute(params, "https://api.syosetu.com/userapi/api/");
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/util/jsonp.ts
|
|
111
|
-
var count = 0;
|
|
112
|
-
var noop = function() {
|
|
113
|
-
};
|
|
114
|
-
function jsonp(url, { prefix = "__jp", param = "callback", timeout = 15e3 } = {}) {
|
|
115
|
-
return new Promise(function(resolve, reject) {
|
|
116
|
-
const targetChild = document.getElementsByTagName("script").item(0);
|
|
117
|
-
const target = targetChild?.parentNode ?? document.head;
|
|
118
|
-
const id = `${prefix}${count++}`;
|
|
119
|
-
const cleanup = function() {
|
|
120
|
-
if (script && script.parentNode) {
|
|
121
|
-
script.parentNode.removeChild(script);
|
|
122
|
-
}
|
|
123
|
-
window[id] = noop;
|
|
124
|
-
if (timer) {
|
|
125
|
-
clearTimeout(timer);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const timer = timeout > 0 ? setTimeout(() => {
|
|
129
|
-
cleanup();
|
|
130
|
-
reject(new Error("Timeout"));
|
|
131
|
-
}, timeout) : void 0;
|
|
132
|
-
const callback = (data) => {
|
|
133
|
-
cleanup();
|
|
134
|
-
resolve(data);
|
|
135
|
-
};
|
|
136
|
-
window[id] = callback;
|
|
137
|
-
const script = document.createElement("script");
|
|
138
|
-
const urlObj = new URL(url);
|
|
139
|
-
urlObj.searchParams.set(param, id);
|
|
140
|
-
script.setAttribute("src", urlObj.toString());
|
|
141
|
-
target.insertBefore(script, targetChild);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// src/narou-jsonp.ts
|
|
146
|
-
var NarouNovelJsonp = class extends NarouNovel {
|
|
147
|
-
async execute(params, endpoint) {
|
|
148
|
-
const query = { ...params, out: "jsonp" };
|
|
149
|
-
query.gzip = 0;
|
|
150
|
-
const url = new URL(endpoint);
|
|
151
|
-
Object.entries(query).forEach(([key, value]) => {
|
|
152
|
-
if (value !== void 0) {
|
|
153
|
-
url.searchParams.append(key, value.toString());
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return await jsonp(url.toString());
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
//# sourceMappingURL=narou-jsonp.cjs.map
|
package/dist/narou-jsonp.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/narou-jsonp.ts","../src/narou-search-results.ts","../src/narou.ts","../src/util/jsonp.ts"],"sourcesContent":["import NarouNovel from \"./narou.js\";\nimport type { NarouParams } from \"./narou.js\";\nimport { jsonp } from \"./util/jsonp.js\";\n\n/**\n * なろう小説APIへのリクエストを実行する\n */\nexport default class NarouNovelJsonp extends NarouNovel {\n protected async execute<T>(\n params: NarouParams,\n endpoint: string\n ): Promise<T> {\n const query = { ...params, out: \"jsonp\" };\n query.gzip = 0;\n\n const url = new URL(endpoint);\n\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, value.toString());\n }\n });\n\n return await jsonp(url.toString());\n }\n}\n","import type {\n BooleanNumber as BooleanNumber,\n Genre,\n R18Site,\n SearchParams,\n Fields,\n BigGenre,\n R18Fields,\n OptionalFields,\n UserFields,\n} from \"./params.js\";\n\n/**\n * なろう小説API検索結果\n */\nexport default class NarouSearchResults<T, TKey extends keyof T> {\n /**\n * 検索結果数\n */\n allcount: number;\n /**\n * 結果表示上限数\n */\n limit: number;\n /**\n * 結果表示開始数\n */\n start: number;\n /**\n * 結果表示の現在ページ(=start/limit)\n */\n page: number;\n /**\n * 今回取得できた検索結果の数\n */\n length: number;\n /**\n * 検索結果\n */\n values: readonly Pick<T, TKey>[];\n\n /**\n * @constractor\n * @private\n */\n constructor(\n [header, ...result]: [{ allcount: number }, ...Pick<T, TKey>[]],\n params: SearchParams\n ) {\n const count = header.allcount;\n const limit = params.lim ?? 20;\n const start = params.st ?? 0;\n\n this.allcount = count;\n this.limit = limit;\n this.start = start;\n this.page = start / limit;\n this.length = result.length;\n this.values = result;\n }\n}\n\n/**\n * 小説情報\n * @see https://dev.syosetu.com/man/api/#output\n * @see https://dev.syosetu.com/xman/api/#output\n */\nexport interface NarouSearchResult {\n /** 小説名 */\n title: string;\n /** Nコード */\n ncode: string;\n /** 作者のユーザID(数値) */\n userid: number;\n /** 作者名 */\n writer: string;\n /** 小説のあらすじ */\n story: string;\n /** 掲載サイト */\n nocgenre: R18Site;\n /** 大ジャンル */\n biggenre: BigGenre;\n /** ジャンル */\n genre: Genre;\n /** キーワード */\n keyword: string;\n /** 初回掲載日 YYYY-MM-DD HH:MM:SSの形式 */\n general_firstup: string;\n /** 最終掲載日 YYYY-MM-DD HH:MM:SSの形式 */\n general_lastup: string;\n /** 連載の場合は1、短編の場合は2 */\n novel_type: NovelType;\n /** 連載の場合は1、短編の場合は2 */\n noveltype: NovelType;\n /** 短編小説と完結済小説は0となっています。連載中は1です。 */\n end: End;\n /** 全掲載話数です。短編の場合は1です。 */\n general_all_no: number;\n /** 小説文字数です。スペースや改行は文字数としてカウントしません。 */\n length: number;\n /** 読了時間(分単位)です。読了時間は小説文字数÷500を切り上げした数値です。 */\n time: number;\n /** 長期連載中は1、それ以外は0です。 */\n isstop: BooleanNumber;\n /** 登録必須キーワードに「R15」が含まれる場合は1、それ以外は0です。 */\n isr15: BooleanNumber;\n /** 登録必須キーワードに「ボーイズラブ」が含まれる場合は1、それ以外は0です。 */\n isbl: BooleanNumber;\n /** 登録必須キーワードに「ガールズラブ」が含まれる場合は1、それ以外は0です。 */\n isgl: BooleanNumber;\n /** 登録必須キーワードに「残酷な描写あり」が含まれる場合は1、それ以外は0です。 */\n iszankoku: BooleanNumber;\n /** 登録必須キーワードに「異世界転生」が含まれる場合は1、それ以外は0です。 */\n istensei: BooleanNumber;\n /** 登録必須キーワードに「異世界転移」が含まれる場合は1、それ以外は0です。 */\n istenni: BooleanNumber;\n /** 総合得点(=(ブックマーク数×2)+評価点) */\n global_point: number;\n /**\n * 日間ポイント\n * ランキング集計時点から過去24時間以内で新たに登録されたブックマークや評価が対象\n */\n daily_point: number;\n /**\n * 週間ポイント\n * ランキング集計時点から過去7日以内で新たに登録されたブックマークや評価が対象\n */\n weekly_point: number;\n /**\n * 月間ポイント\n * ランキング集計時点から過去30日以内で新たに登録されたブックマークや評価が対象\n */\n monthly_point: number;\n /**\n * 四半期ポイント\n * ランキング集計時点から過去90日以内で新たに登録されたブックマークや評価が対象\n */\n quarter_point: number;\n /**\n * 年間ポイント\n * ランキング集計時点から過去365日以内で新たに登録されたブックマークや評価が対象\n */\n yearly_point: number;\n /** ブックマーク数 */\n fav_novel_cnt: number;\n /** 感想数 */\n impression_cnt: number;\n /** レビュー数 */\n review_cnt: number;\n /** 評価ポイント */\n all_point: number;\n /** 評価者数 */\n all_hyoka_cnt: number;\n /** 挿絵の数 */\n sasie_cnt: number;\n /**\n * 会話率\n * @see https://dev.syosetu.com/man/kaiwa/\n */\n kaiwaritu: number;\n /**\n * 小説の更新日時\n */\n novelupdated_at: string;\n /**\n * 最終更新日時\n * システム用で小説更新時とは関係ありません\n */\n updated_at: string;\n /** 週間ユニークユーザー数 */\n weekly_unique: number;\n}\n\n/**\n * ユーザ情報\n * @see https://dev.syosetu.com/man/userapi/#output\n */\nexport interface UserSearchResult {\n /** ユーザID */\n userid: number;\n /** ユーザ名 */\n name: string;\n /** ユーザ名のフリガナ */\n yomikata: string;\n /**\n * ユーザ名のフリガナの頭文字\n * ひらがな以外の場合はnullまたは空文字となります。\n */\n name1st: string;\n /** 小説投稿数 */\n novel_cnt: number;\n /** レビュー投稿数 */\n review_cnt: number;\n /**\n * 小説累計文字数\n * スペースや改行は文字数としてカウントしません。\n */\n novel_length: number;\n /**\n * 総合評価ポイントの合計\n * 投稿済小説でそれぞれ獲得した総合評価ポイントの合計です。\n */\n sum_global_point: number;\n}\n\n/**\n * noveltype/novel_typeの値ヘルパー\n */\nexport const NovelType = {\n /** 連載 */\n Rensai: 1,\n /** 短編 */\n Tanpen: 2,\n} as const;\nexport type NovelType = typeof NovelType[keyof typeof NovelType];\n\n/**\n * endの値ヘルパー\n */\nexport const End = {\n /** 短編小説と完結済小説 */\n KanketsuOrTanpen: 0,\n /** 連載中 */\n Rensai: 1,\n} as const;\nexport type End = typeof End[keyof typeof End];\n\nexport type SearchResultFields<T extends Fields> = {\n [K in keyof typeof Fields]: typeof Fields[K] extends T ? K : never;\n}[keyof typeof Fields];\n\nexport type SearchResultOptionalFields<T extends OptionalFields> = {\n [K in keyof typeof OptionalFields]: typeof OptionalFields[K] extends T\n ? K\n : never;\n}[keyof typeof OptionalFields];\n\nexport type SearchResultR18Fields<T extends R18Fields> = {\n [K in keyof typeof R18Fields]: typeof R18Fields[K] extends T ? K : never;\n}[keyof typeof R18Fields];\n\nexport type UserSearchResultFields<T extends UserFields> = {\n [K in keyof typeof UserFields]: typeof UserFields[K] extends T ? K : never;\n}[keyof typeof UserFields];\n\nexport type PickedNarouSearchResult<T extends keyof NarouSearchResult> = Pick<\n NarouSearchResult,\n T\n>;\n","import type { NarouRankingResult } from \"./narou-ranking-results.js\";\nimport NarouSearchResults from \"./narou-search-results.js\";\nimport type {\n NarouSearchResult,\n UserSearchResult,\n} from \"./narou-search-results.js\";\nimport type {\n RankingHistoryParams,\n RankingParams,\n SearchParams,\n UserSearchParams,\n} from \"./params.js\";\nimport type { RankingHistoryRawResult } from \"./ranking-history.js\";\n\n/**\n * なろう小説APIへのリクエストパラメータ\n */\nexport type NarouParams =\n | SearchParams\n | RankingParams\n | RankingHistoryParams\n | UserSearchParams;\n\n/**\n * なろう小説APIへのリクエストを実行する\n * @class NarouNovel\n * @private\n */\nexport default abstract class NarouNovel {\n /**\n * なろうAPIへのAPIリクエストを実行する\n * @param params クエリパラメータ\n * @param endpoint APIエンドポイント\n * @returns 実行結果\n */\n protected abstract execute<T>(\n params: NarouParams,\n endpoint: string\n ): Promise<T>;\n\n /**\n * APIへの検索リクエストを実行する\n * @param params クエリパラメータ\n * @param endpoint APIエンドポイント\n * @returns 検索結果\n */\n protected async executeSearch<T extends keyof NarouSearchResult>(\n params: SearchParams,\n endpoint = \"https://api.syosetu.com/novelapi/api/\"\n ): Promise<NarouSearchResults<NarouSearchResult, T>> {\n return new NarouSearchResults(await this.execute(params, endpoint), params);\n }\n\n /**\n * 小説APIへの検索リクエストを実行する\n * @param params クエリパラメータ\n * @returns 検索結果\n * @see https://dev.syosetu.com/man/api/\n */\n async executeNovel<T extends keyof NarouSearchResult>(\n params: SearchParams\n ): Promise<NarouSearchResults<NarouSearchResult, T>> {\n return await this.executeSearch(\n params,\n \"https://api.syosetu.com/novelapi/api/\"\n );\n }\n\n /**\n * R18小説APIへの検索リクエストを実行する\n * @param params クエリパラメータ\n * @returns 検索結果\n * @see https://dev.syosetu.com/xman/api/\n */\n async executeNovel18<T extends keyof NarouSearchResult>(\n params: SearchParams\n ): Promise<NarouSearchResults<NarouSearchResult, T>> {\n return await this.executeSearch(\n params,\n \"https://api.syosetu.com/novel18api/api/\"\n );\n }\n\n /**\n * ランキングAPIへのリクエストを実行する\n * @param params クエリパラメータ\n * @returns ランキング結果\n * @see https://dev.syosetu.com/man/rankapi/\n */\n async executeRanking(params: RankingParams): Promise<NarouRankingResult[]> {\n return await this.execute(params, \"https://api.syosetu.com/rank/rankget/\");\n }\n\n /**\n * 殿堂入りAPiへのリクエストを実行する\n * @param params クエリパラメータ\n * @returns ランキング履歴結果\n * @see https://dev.syosetu.com/man/rankinapi/\n */\n async executeRankingHistory(\n params: RankingHistoryParams\n ): Promise<RankingHistoryRawResult[]> {\n return await this.execute(params, \"https://api.syosetu.com/rank/rankin/\");\n }\n\n /**\n * ユーザー検索APIへのリクエストを実行する\n * @param params クエリパラメータ\n * @returns 検索結果\n * @see https://dev.syosetu.com/man/userapi/\n */\n async executeUserSearch<T extends keyof UserSearchResult>(\n params: UserSearchParams\n ): Promise<NarouSearchResults<UserSearchResult, T>> {\n return await this.execute(params, \"https://api.syosetu.com/userapi/api/\");\n }\n}\n","/**\n * MIT license\n */\n\n// Callback index.\nlet count = 0;\n\ntype CallbackId<Prefix extends string = string> = `${Prefix}${number}`;\n\ndeclare global {\n interface Window {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: CallbackId]: (data: any) => void;\n }\n}\nexport type JsonpOption = {\n prefix?: string;\n param?: string;\n timeout?: number;\n};\n\n \nconst noop = function () {};\n\nexport function jsonp<T>(\n url: string,\n { prefix = \"__jp\", param = \"callback\", timeout = 15000 }: JsonpOption = {}\n): Promise<T> {\n return new Promise(function (resolve, reject) {\n const targetChild = document.getElementsByTagName(\"script\").item(0);\n const target = targetChild?.parentNode ?? document.head;\n\n const id: CallbackId = `${prefix}${count++}`;\n const cleanup = function () {\n // Remove the script tag.\n if (script && script.parentNode) {\n script.parentNode.removeChild(script);\n }\n\n window[id] = noop;\n\n if (timer) {\n clearTimeout(timer);\n }\n };\n\n const timer =\n timeout > 0\n ? setTimeout(() => {\n cleanup();\n reject(new Error(\"Timeout\"));\n }, timeout)\n : undefined;\n\n const callback = (data: T) => {\n cleanup();\n resolve(data);\n };\n window[id] = callback;\n\n // Create script.\n const script = document.createElement(\"script\");\n const urlObj = new URL(url);\n urlObj.searchParams.set(param, id);\n script.setAttribute(\"src\", urlObj.toString());\n target.insertBefore(script, targetChild);\n });\n}\n"],"mappings":"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","names":["count"]}
|
package/dist/narou-jsonp.d.cts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { N as NarouNovel, a as NarouParams } from './narou-CatW_TC9.cjs';
|
|
2
|
-
import './narou-search-results-DWCJWTC5.cjs';
|
|
3
|
-
import './util/type.cjs';
|
|
4
|
-
import './ranking-history.cjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* なろう小説APIへのリクエストを実行する
|
|
8
|
-
*/
|
|
9
|
-
declare class NarouNovelJsonp extends NarouNovel {
|
|
10
|
-
protected execute<T>(params: NarouParams, endpoint: string): Promise<T>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { NarouNovelJsonp as default };
|
package/dist/narou-jsonp.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { N as NarouNovel, a as NarouParams } from './narou-fH9osIoh.js';
|
|
2
|
-
import './narou-search-results-D5yqPRZ7.js';
|
|
3
|
-
import './util/type.js';
|
|
4
|
-
import './ranking-history.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* なろう小説APIへのリクエストを実行する
|
|
8
|
-
*/
|
|
9
|
-
declare class NarouNovelJsonp extends NarouNovel {
|
|
10
|
-
protected execute<T>(params: NarouParams, endpoint: string): Promise<T>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { NarouNovelJsonp as default };
|
package/dist/narou-jsonp.js
DELETED
package/dist/narou-jsonp.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __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/narou-ranking-results.ts
|
|
17
|
-
var narou_ranking_results_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(narou_ranking_results_exports);
|
|
19
|
-
//# sourceMappingURL=narou-ranking-results.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/narou-ranking-results.ts"],"sourcesContent":["import type { PickedNarouSearchResult } from \"./narou-search-results.js\";\nimport type { SearchResultFieldNames } from \"./params.js\";\nimport type { DefaultSearchResultFields } from \"./search-builder.js\";\n\n/**\n * ランキングAPIの結果\n * @see https://dev.syosetu.com/man/rankapi/#output\n */\nexport interface NarouRankingResult {\n /** Nコード */\n ncode: string;\n /** 順位 */\n rank: number;\n /** ポイント */\n pt: number;\n}\n\n/**\n * ランキングと小説情報をマージした結果\n */\nexport type RankingResult<\n T extends SearchResultFieldNames = DefaultSearchResultFields\n> = Partial<PickedNarouSearchResult<T>> & NarouRankingResult;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=narou-ranking-results.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|