@wzyjs/utils 0.3.31 → 0.3.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/base/string.d.ts +1 -0
- package/dist/node/cors.d.ts +14 -0
- package/dist/node/crawl/fanqie/book/categories.d.ts +3 -0
- package/dist/node/crawl/fanqie/book/detail.d.ts +2 -0
- package/dist/node/crawl/fanqie/book/index.d.ts +5 -0
- package/dist/node/crawl/fanqie/book/library.d.ts +5 -0
- package/dist/node/crawl/fanqie/book/normalize.d.ts +22 -0
- package/dist/node/crawl/fanqie/book/search.d.ts +11 -0
- package/dist/node/crawl/fanqie/chapter/directory.d.ts +2 -0
- package/dist/node/crawl/fanqie/chapter/index.d.ts +1 -0
- package/dist/node/crawl/fanqie/content/index.d.ts +1 -0
- package/dist/node/crawl/fanqie/content/sidecar.d.ts +2 -0
- package/dist/node/crawl/fanqie/index.d.ts +4 -0
- package/dist/node/crawl/fanqie/types.d.ts +74 -0
- package/dist/node/crawl/fanqie/utils/book-source.d.ts +12 -0
- package/dist/node/crawl/fanqie/utils/consts.d.ts +40 -0
- package/dist/node/crawl/fanqie/utils/font-map.d.ts +2 -0
- package/dist/node/crawl/fanqie/utils/http.d.ts +1 -0
- package/dist/node/crawl/fanqie/utils/index.d.ts +2 -0
- package/dist/node/crawl/fanqie/utils/normalize.d.ts +2 -0
- package/dist/node/crawl/index.d.ts +1 -0
- package/dist/node/file/index.d.ts +16 -3
- package/dist/node.cjs.js +1126 -57
- package/dist/node.d.ts +2 -0
- package/dist/node.esm.js +1126 -57
- package/dist/web.cjs.js +7 -0
- package/dist/web.esm.js +7 -0
- package/package.json +4 -3
|
@@ -4,6 +4,7 @@ export declare const replaceByRules: (str: string, rules: [string, string][]) =>
|
|
|
4
4
|
export declare const replaceByVariables: (prompt: string, variables?: {
|
|
5
5
|
[key: string]: string;
|
|
6
6
|
}) => string;
|
|
7
|
+
export declare const getSafeCallbackPath: (value: string | null, fallback: string) => string;
|
|
7
8
|
export declare const getType: (value: any) => any;
|
|
8
9
|
export declare const safeJsonParse: <T = any>(value: unknown, fallback: T) => T;
|
|
9
10
|
export declare const isJsonObject: (str: string) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type CorsOptions = {
|
|
2
|
+
allowHeaders?: string[];
|
|
3
|
+
allowMethods?: string[];
|
|
4
|
+
maxAge?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const createCorsHeaders: (request: Request, options?: CorsOptions) => {
|
|
7
|
+
'Access-Control-Allow-Headers': string;
|
|
8
|
+
'Access-Control-Allow-Methods': string;
|
|
9
|
+
'Access-Control-Allow-Origin': string;
|
|
10
|
+
'Access-Control-Max-Age': string;
|
|
11
|
+
Vary: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const applyCorsHeaders: (request: Request, response: Response, options?: CorsOptions) => Response;
|
|
14
|
+
export declare const createCorsPreflightResponse: (request: Request, options?: CorsOptions) => Response;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FanqieLibraryCategories, ResolveFanqieLibraryCategoryParams } from '../types';
|
|
2
|
+
export declare const getFanqieLibraryFilters: (gender: -1 | 0 | 1) => Promise<FanqieLibraryCategories>;
|
|
3
|
+
export declare const resolveFanqieLibraryCategoryId: ({ gender, categoryGroup, categoryId, }: ResolveFanqieLibraryCategoryParams) => Promise<number>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FanqieBookItem, ListFanqieLibraryBooksParams } from '../types';
|
|
2
|
+
export declare const listFanqieLibraryBooks: ({ gender, categoryId, creationStatus, wordCount, sort, pageIndex, pageSize, }: ListFanqieLibraryBooksParams) => Promise<{
|
|
3
|
+
results: FanqieBookItem[];
|
|
4
|
+
total: number;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FanqieBookItem } from '../types';
|
|
2
|
+
interface FanqieBookSourcePayload {
|
|
3
|
+
book_name?: unknown;
|
|
4
|
+
book_id?: unknown;
|
|
5
|
+
author?: unknown;
|
|
6
|
+
score?: unknown;
|
|
7
|
+
thumb_url?: unknown;
|
|
8
|
+
abstract?: unknown;
|
|
9
|
+
category?: unknown;
|
|
10
|
+
tags?: unknown;
|
|
11
|
+
word_number?: unknown;
|
|
12
|
+
read_count?: unknown;
|
|
13
|
+
read_count_all?: unknown;
|
|
14
|
+
status?: unknown;
|
|
15
|
+
last_chapter_update_time?: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare const normalizeFanqieBookStatus: (value: unknown) => 0 | 1 | null;
|
|
18
|
+
export declare const normalizeFanqieBookTags: (value: unknown) => string[];
|
|
19
|
+
export declare const normalizeFanqieBookSearchItem: (payload: FanqieBookSourcePayload) => FanqieBookItem | null;
|
|
20
|
+
export declare const normalizeFanqieBookDetailItem: (fanqieBookId: string, payload: FanqieBookSourcePayload) => FanqieBookItem;
|
|
21
|
+
export declare const normalizeFanqieOfficialLibraryItem: (payload: any) => FanqieBookItem | null;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FanqieBookItem } from '../types';
|
|
2
|
+
export interface SearchFanqieBooksOptions {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
source?: string;
|
|
5
|
+
tab?: string;
|
|
6
|
+
page?: number;
|
|
7
|
+
disabledSources?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const normalizeFanqieSearchResults: (payload: unknown) => FanqieBookItem[];
|
|
10
|
+
export declare const createFanqieSearchUrl: (query: string, options?: SearchFanqieBooksOptions) => string;
|
|
11
|
+
export declare const searchFanqieBooks: (query: string, options?: SearchFanqieBooksOptions) => Promise<FanqieBookItem[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './directory';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sidecar';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { FanqieChapterContentItem, FanqieOfficialSidecarOptions } from '../types';
|
|
2
|
+
export declare const getFanqieChapterContents: (fanqieBookId: string, chapterIds: string[], sidecarOptions?: FanqieOfficialSidecarOptions) => Promise<Map<string, FanqieChapterContentItem>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface FanqieBookItem {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
author: string | null;
|
|
5
|
+
coverUrl: string | null;
|
|
6
|
+
description: string | null;
|
|
7
|
+
category: string | null;
|
|
8
|
+
tags: string[];
|
|
9
|
+
score?: string | null;
|
|
10
|
+
wordCount?: string | null;
|
|
11
|
+
readCount?: string | null;
|
|
12
|
+
readCountAll?: string | null;
|
|
13
|
+
creationStatus?: 0 | 1 | null;
|
|
14
|
+
lastChapterTime?: string | null;
|
|
15
|
+
rawTitle?: string | null;
|
|
16
|
+
rawAuthor?: string | null;
|
|
17
|
+
rawDescription?: string | null;
|
|
18
|
+
rawCategory?: string | null;
|
|
19
|
+
rawScore?: string | null;
|
|
20
|
+
rawWordCount?: string | null;
|
|
21
|
+
rawReadCount?: string | null;
|
|
22
|
+
rawReadCountAll?: string | null;
|
|
23
|
+
}
|
|
24
|
+
export type FanqieLibraryGender = -1 | 0 | 1;
|
|
25
|
+
export type FanqieLibraryCategoryGroupKey = 'topic' | 'role' | 'plot';
|
|
26
|
+
export type FanqieLibraryCategoryFilter = 'all' | FanqieLibraryCategoryGroupKey;
|
|
27
|
+
export type FanqieCreationStatus = -1 | 0 | 1;
|
|
28
|
+
export type FanqieWordCount = -1 | 0 | 1 | 2 | 3 | 4;
|
|
29
|
+
export type FanqieLibrarySort = 0 | 1;
|
|
30
|
+
export interface FanqieLibraryCategoryItem {
|
|
31
|
+
categoryId: number;
|
|
32
|
+
label: string;
|
|
33
|
+
name: string;
|
|
34
|
+
coverUrl: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface FanqieLibraryCategories {
|
|
37
|
+
topic: FanqieLibraryCategoryItem[];
|
|
38
|
+
role: FanqieLibraryCategoryItem[];
|
|
39
|
+
plot: FanqieLibraryCategoryItem[];
|
|
40
|
+
}
|
|
41
|
+
export interface ListFanqieLibraryBooksParams {
|
|
42
|
+
gender: FanqieLibraryGender;
|
|
43
|
+
categoryId: number;
|
|
44
|
+
creationStatus: FanqieCreationStatus;
|
|
45
|
+
wordCount: FanqieWordCount;
|
|
46
|
+
sort: FanqieLibrarySort;
|
|
47
|
+
pageIndex: number;
|
|
48
|
+
pageSize: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ResolveFanqieLibraryCategoryParams {
|
|
51
|
+
gender: FanqieLibraryGender;
|
|
52
|
+
categoryGroup: FanqieLibraryCategoryFilter;
|
|
53
|
+
categoryId?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface FanqieChapterDirectoryItem {
|
|
56
|
+
fanqieChapterId: string;
|
|
57
|
+
title: string;
|
|
58
|
+
chapterOrder: number;
|
|
59
|
+
volumeName: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface FanqieChapterContentItem {
|
|
62
|
+
title: string;
|
|
63
|
+
content: string;
|
|
64
|
+
chapterOrder: number | null;
|
|
65
|
+
}
|
|
66
|
+
export interface FanqieOfficialSidecarOptions {
|
|
67
|
+
baseUrl?: string;
|
|
68
|
+
container?: string;
|
|
69
|
+
password?: string;
|
|
70
|
+
jobTimeoutMs?: number;
|
|
71
|
+
jobPollIntervalMs?: number;
|
|
72
|
+
statusTimeoutMs?: number;
|
|
73
|
+
statusPollIntervalMs?: number;
|
|
74
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const getFanqieBookSourceBaseUrls: () => string[];
|
|
2
|
+
export declare const encodeFanqieBookSourceBookId: (fanqieBookId: string) => string;
|
|
3
|
+
export declare const decodeFanqieBookSourceBookId: (encodedBookId: unknown) => string;
|
|
4
|
+
export declare const createFanqieBookSourceUrl: (baseUrl: string, path: string, searchParams: Record<string, string>) => string;
|
|
5
|
+
export declare const requestFanqieBookSourceJson: <T>({ path, searchParams, init, baseUrl, errorPrefix, validate, }: {
|
|
6
|
+
path: string;
|
|
7
|
+
searchParams: Record<string, string>;
|
|
8
|
+
init?: RequestInit;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
errorPrefix: string;
|
|
11
|
+
validate?: (response: T) => void;
|
|
12
|
+
}) => Promise<T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const FANQIE_LIBRARY_LIST_URL = "https://fanqienovel.com/api/author/library/book_list/v0/";
|
|
2
|
+
export declare const FANQIE_LIBRARY_CATEGORY_URL = "https://fanqienovel.com/api/author/book/category_list/v0/";
|
|
3
|
+
export declare const FANQIE_BOOK_SOURCE_SEARCH_PATH = "/search";
|
|
4
|
+
export declare const FANQIE_BOOK_SOURCE_SEARCH_DEFAULT_SOURCE = "\u756A\u8304";
|
|
5
|
+
export declare const FANQIE_BOOK_SOURCE_SEARCH_DEFAULT_TAB = "\u5C0F\u8BF4";
|
|
6
|
+
export declare const FANQIE_BOOK_SOURCE_SEARCH_DEFAULT_DISABLED_SOURCES = "0";
|
|
7
|
+
export declare const FANQIE_BOOK_SOURCE_CATALOG_PATH = "/catalog";
|
|
8
|
+
export declare const FANQIE_BOOK_SOURCE_CATALOG_SOURCE = "\u756A\u8304";
|
|
9
|
+
export declare const FANQIE_BOOK_SOURCE_CATALOG_TAB = "\u5C0F\u8BF4";
|
|
10
|
+
export declare const FANQIE_BOOK_SOURCE_CATALOG_VARIABLE: {
|
|
11
|
+
custom: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const FANQIE_BOOK_SOURCE_DETAIL_PATH = "/detail";
|
|
14
|
+
export declare const FANQIE_BOOK_SOURCE_DETAIL_SOURCE = "\u756A\u8304";
|
|
15
|
+
export declare const FANQIE_BOOK_SOURCE_DETAIL_TAB = "\u5C0F\u8BF4";
|
|
16
|
+
export declare const FANQIE_BOOK_SOURCE_DETAIL_VARIABLE: {
|
|
17
|
+
custom: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const DEFAULT_FANQIE_BOOK_SOURCE_BASE_URLS: readonly ["https://api.langge.cf", "https://v2.czyl.cf", "http://219.154.201.122:5006"];
|
|
20
|
+
export declare const FANQIE_PAGE_HEADERS: {
|
|
21
|
+
'User-Agent': string;
|
|
22
|
+
Referer: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const FANQIE_BOOK_SOURCE_SEARCH_HEADERS: {
|
|
25
|
+
'user-agent': string;
|
|
26
|
+
};
|
|
27
|
+
export declare const FANQIE_BOOK_SOURCE_CATALOG_HEADERS: {
|
|
28
|
+
'content-type': string;
|
|
29
|
+
'user-agent': string;
|
|
30
|
+
};
|
|
31
|
+
export declare const FANQIE_BOOK_SOURCE_DETAIL_HEADERS: {
|
|
32
|
+
'content-type': string;
|
|
33
|
+
'user-agent': string;
|
|
34
|
+
};
|
|
35
|
+
export declare const DEFAULT_FANQIE_OFFICIAL_SIDECAR_BASE_URL = "http://127.0.0.1:18423";
|
|
36
|
+
export declare const DEFAULT_FANQIE_OFFICIAL_SIDECAR_CONTAINER = "tomato-novel-webui";
|
|
37
|
+
export declare const DEFAULT_FANQIE_OFFICIAL_SIDECAR_JOB_TIMEOUT_MS: number;
|
|
38
|
+
export declare const DEFAULT_FANQIE_OFFICIAL_SIDECAR_JOB_POLL_INTERVAL_MS = 1500;
|
|
39
|
+
export declare const DEFAULT_FANQIE_OFFICIAL_SIDECAR_STATUS_TIMEOUT_MS: number;
|
|
40
|
+
export declare const DEFAULT_FANQIE_OFFICIAL_SIDECAR_STATUS_POLL_INTERVAL_MS = 1000;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchFanqieJson: <T>(url: string, init?: RequestInit) => Promise<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as fanqie from './fanqie';
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
export declare const getExtFromFileName: (fileName?: string) => string;
|
|
2
|
+
export declare const getExtFromMimeType: (mimeType?: string) => string;
|
|
1
3
|
export declare const getMimeType: (fileName: string) => string;
|
|
4
|
+
export declare const normalizeDataUrlBase64: (value: string) => {
|
|
5
|
+
base64: string;
|
|
6
|
+
mimeType?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const parseBase64File: (input: {
|
|
9
|
+
fileBase64: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
}) => {
|
|
12
|
+
buffer: Buffer;
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
};
|
|
2
15
|
export declare const replaceContentInFile: (filePath: string, targetContent: string, replacement: string) => Promise<void>;
|
|
3
16
|
export declare const downloadFile: (httpUrl: string, outputPath?: string) => Promise<string>;
|
|
4
17
|
/**
|
|
5
|
-
*
|
|
18
|
+
* 描述 processFile 支持的文件来源和对应输入内容。
|
|
6
19
|
*/
|
|
7
20
|
export interface UploadFileParams {
|
|
8
21
|
/**
|
|
@@ -23,7 +36,7 @@ export interface UploadFileParams {
|
|
|
23
36
|
file: string | Buffer | File;
|
|
24
37
|
}
|
|
25
38
|
/**
|
|
26
|
-
*
|
|
39
|
+
* 描述 processFile 归一化后的文件元信息和内容。
|
|
27
40
|
*/
|
|
28
41
|
export interface UploadFileResult {
|
|
29
42
|
/** 文件内容 Buffer */
|
|
@@ -42,7 +55,7 @@ export interface UploadFileResult {
|
|
|
42
55
|
ext: string;
|
|
43
56
|
}
|
|
44
57
|
/**
|
|
45
|
-
*
|
|
58
|
+
* 处理各种类型的文件输入,将其统一转换为标准的文件信息对象。
|
|
46
59
|
*
|
|
47
60
|
* @description
|
|
48
61
|
* 该函数用于处理不同来源的文件(URL、本地路径、Buffer、File对象),
|