@wzyjs/utils 0.3.8 → 0.3.10
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/ai/index.d.ts +3 -2
- package/dist/common/ai/text/index.d.ts +1 -0
- package/dist/common/ai/video/index.d.ts +1 -0
- package/dist/common/dayjs/index.d.ts +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/node/file/index.d.ts +63 -0
- package/dist/node/{mail.d.ts → mail/index.d.ts} +1 -1
- package/dist/node/oss/ali.d.ts +14 -0
- package/dist/node/oss/cloudflare.d.ts +20 -0
- package/dist/node/oss/index.d.ts +2 -0
- package/dist/node.cjs.js +339 -91
- package/dist/node.d.ts +4 -5
- package/dist/node.esm.js +335 -87
- package/dist/web.cjs.js +75 -11
- package/dist/web.esm.js +75 -12
- package/package.json +5 -4
- package/dist/node/file.d.ts +0 -2
- package/dist/node/oss.d.ts +0 -9
- /package/dist/common/ai/{keling → video/keling}/axios.d.ts +0 -0
- /package/dist/common/ai/{keling → video/keling}/index.d.ts +0 -0
- /package/dist/common/ai/{keling → video/keling}/utils.d.ts +0 -0
- /package/dist/node/{cron.d.ts → cron/index.d.ts} +0 -0
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './302';
|
|
2
|
-
export * from './
|
|
1
|
+
export * as ai302 from './302';
|
|
2
|
+
export * as video from './video';
|
|
3
|
+
export * as text from './text';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const complete: (apiUrl: string, model: string, token: string, messages: any[], json?: boolean) => Promise<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as keling from './keling';
|
|
@@ -15,7 +15,7 @@ export declare enum Timezone {
|
|
|
15
15
|
}
|
|
16
16
|
export declare const initChinaDayjs: () => typeof dayjs;
|
|
17
17
|
export declare const chinaDayjs: typeof dayjs;
|
|
18
|
-
export { Dayjs } from 'dayjs';
|
|
18
|
+
export type { Dayjs } from 'dayjs';
|
|
19
19
|
declare const _default: typeof dayjs & {
|
|
20
20
|
isBetween: typeof isBetween;
|
|
21
21
|
isSameOrAfter: typeof isSameOrAfter;
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './ai';
|
|
1
|
+
export * as ai from './ai';
|
|
2
2
|
export * from './base';
|
|
3
3
|
export * from './enum';
|
|
4
4
|
export * from './image';
|
|
5
|
-
export { default as dayjs, Dayjs, Timezone, initChinaDayjs, chinaDayjs } from './dayjs';
|
|
5
|
+
export { default as dayjs, type Dayjs, Timezone, initChinaDayjs, chinaDayjs } from './dayjs';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export declare const getMimeType: (fileName: string) => string;
|
|
2
|
+
export declare const replaceContentInFile: (filePath: string, targetContent: string, replacement: string) => Promise<void>;
|
|
3
|
+
export declare const downloadFile: (httpUrl: string, outputPath?: string) => Promise<string>;
|
|
4
|
+
/**
|
|
5
|
+
* 上传文件参数
|
|
6
|
+
*/
|
|
7
|
+
export interface UploadFileParams {
|
|
8
|
+
/**
|
|
9
|
+
* 文件来源类型
|
|
10
|
+
* - 'url': 远程文件 URL 地址
|
|
11
|
+
* - 'path': 本地文件路径
|
|
12
|
+
* - 'buffer': 文件 Buffer 对象
|
|
13
|
+
* - 'file': 浏览器 File 对象
|
|
14
|
+
*/
|
|
15
|
+
type: 'url' | 'path' | 'buffer' | 'file';
|
|
16
|
+
/**
|
|
17
|
+
* 文件内容
|
|
18
|
+
* - type='url' 时,为 string 类型的 URL
|
|
19
|
+
* - type='path' 时,为 string 类型的本地路径
|
|
20
|
+
* - type='buffer' 时,为 Buffer 对象
|
|
21
|
+
* - type='file' 时,为 File 对象
|
|
22
|
+
*/
|
|
23
|
+
file: string | Buffer | File;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 文件处理结果
|
|
27
|
+
*/
|
|
28
|
+
export interface UploadFileResult {
|
|
29
|
+
/** 文件内容 Buffer */
|
|
30
|
+
buffer: Buffer;
|
|
31
|
+
/** 原始文件名 */
|
|
32
|
+
originalName: string;
|
|
33
|
+
/** 生成的唯一文件名 */
|
|
34
|
+
finalFileName: string;
|
|
35
|
+
/** 文件内容的 MD5 哈希值 */
|
|
36
|
+
hash: string;
|
|
37
|
+
/** 文件的 MIME 类型 */
|
|
38
|
+
mimeType: string;
|
|
39
|
+
/** 文件大小(字节) */
|
|
40
|
+
size: number;
|
|
41
|
+
/** 文件扩展名(包含点,如 .png) */
|
|
42
|
+
ext: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 处理各种类型的文件输入,将其统一转换为标准的文件信息对象
|
|
46
|
+
*
|
|
47
|
+
* @description
|
|
48
|
+
* 该函数用于处理不同来源的文件(URL、本地路径、Buffer、File对象),
|
|
49
|
+
* 并返回包含文件Buffer、哈希值、MIME类型等信息的统一格式对象。
|
|
50
|
+
*
|
|
51
|
+
* @param params - 上传文件参数 {@link UploadFileParams}
|
|
52
|
+
* @returns 返回处理后的文件信息 {@link UploadFileResult}
|
|
53
|
+
* @throws 当参数类型不匹配或文件读取/下载失败时抛出错误
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // 处理 URL
|
|
57
|
+
* const result = await processFile({ type: 'url', file: 'https://example.com/image.png' });
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // 处理本地路径
|
|
61
|
+
* const result = await processFile({ type: 'path', file: '/tmp/image.png' });
|
|
62
|
+
*/
|
|
63
|
+
export declare const processFile: (params: UploadFileParams) => Promise<UploadFileResult>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface UploadFile {
|
|
2
|
+
buffer: Buffer;
|
|
3
|
+
fileName: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 上传文件到 OSS
|
|
7
|
+
* @param params - 上传参数
|
|
8
|
+
* @returns 上传后的文件信息 { url, name }
|
|
9
|
+
*/
|
|
10
|
+
export declare const uploadFileToOss: (params: UploadFile) => Promise<{
|
|
11
|
+
url: string;
|
|
12
|
+
objectKey: string;
|
|
13
|
+
}>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface UploadFile {
|
|
2
|
+
buffer: Buffer;
|
|
3
|
+
fileName: string;
|
|
4
|
+
mimeType: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 上传文件到 Cloudflare R2
|
|
8
|
+
* @param params - 上传参数
|
|
9
|
+
* @returns 上传后的文件信息 { url, name }
|
|
10
|
+
*/
|
|
11
|
+
export declare function uploadFile(params: UploadFile): Promise<{
|
|
12
|
+
url: string;
|
|
13
|
+
objectKey: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* 从 Cloudflare R2 删除文件
|
|
17
|
+
* @param objectKey - 文件在 S3 中的 Key
|
|
18
|
+
*/
|
|
19
|
+
export declare function deleteFile(objectKey: string): Promise<void>;
|
|
20
|
+
export {};
|