@nest-omni/core 4.1.3-10 → 4.1.3-12
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/audit/audit.module.js +42 -2
- package/audit/controllers/audit.controller.d.ts +64 -0
- package/audit/controllers/audit.controller.js +50 -0
- package/audit/decorators/audit-action.decorator.d.ts +74 -0
- package/audit/decorators/audit-action.decorator.js +42 -0
- package/audit/decorators/audit-controller.decorator.d.ts +1 -1
- package/audit/decorators/audit-controller.decorator.js +2 -2
- package/audit/decorators/entity-audit.decorator.d.ts +78 -2
- package/audit/decorators/entity-audit.decorator.js +145 -4
- package/audit/decorators/index.d.ts +2 -0
- package/audit/decorators/index.js +2 -0
- package/audit/entities/audit-action-summary.entity.d.ts +23 -0
- package/audit/entities/audit-action-summary.entity.js +101 -0
- package/audit/entities/entity-audit-log.entity.d.ts +8 -0
- package/audit/entities/entity-audit-log.entity.js +54 -2
- package/audit/entities/entity-transaction.entity.d.ts +8 -2
- package/audit/entities/entity-transaction.entity.js +39 -3
- package/audit/entities/index.d.ts +3 -0
- package/audit/entities/index.js +3 -0
- package/audit/entities/manual-operation-log.entity.js +8 -1
- package/audit/enums/audit.enums.d.ts +22 -6
- package/audit/enums/audit.enums.js +27 -9
- package/audit/index.d.ts +4 -1
- package/audit/index.js +25 -2
- package/audit/interceptors/audit-action.interceptor.d.ts +38 -0
- package/audit/interceptors/audit-action.interceptor.js +215 -0
- package/audit/interceptors/index.d.ts +1 -0
- package/audit/interceptors/index.js +1 -0
- package/audit/interfaces/audit.interfaces.d.ts +145 -2
- package/audit/services/audit-action.service.d.ts +141 -0
- package/audit/services/audit-action.service.js +244 -0
- package/audit/services/audit-context.service.d.ts +82 -0
- package/audit/services/audit-context.service.js +170 -0
- package/audit/services/entity-audit.service.d.ts +174 -4
- package/audit/services/entity-audit.service.js +515 -14
- package/audit/services/index.d.ts +3 -0
- package/audit/services/index.js +3 -0
- package/audit/services/manual-audit-log.service.d.ts +24 -23
- package/audit/services/manual-audit-log.service.js +32 -53
- package/audit/services/operation-description.service.d.ts +13 -3
- package/audit/services/operation-description.service.js +161 -24
- package/audit/services/transaction-audit.service.js +3 -3
- package/audit/subscribers/entity-audit.subscriber.d.ts +4 -0
- package/audit/subscribers/entity-audit.subscriber.js +47 -0
- package/file-upload/controllers/file-access.controller.d.ts +23 -0
- package/file-upload/controllers/file-access.controller.js +128 -0
- package/file-upload/decorators/csv-data.decorator.d.ts +44 -0
- package/file-upload/decorators/csv-data.decorator.js +131 -0
- package/file-upload/decorators/excel-data.decorator.d.ts +44 -0
- package/file-upload/decorators/excel-data.decorator.js +125 -0
- package/file-upload/decorators/file-upload.decorator.d.ts +83 -0
- package/file-upload/decorators/file-upload.decorator.js +172 -0
- package/file-upload/decorators/index.d.ts +4 -0
- package/file-upload/decorators/index.js +20 -0
- package/file-upload/decorators/process.decorator.d.ts +40 -0
- package/file-upload/decorators/process.decorator.js +52 -0
- package/file-upload/dto/create-file.dto.d.ts +24 -0
- package/file-upload/dto/create-file.dto.js +112 -0
- package/file-upload/dto/find-files.dto.d.ts +15 -0
- package/file-upload/dto/find-files.dto.js +76 -0
- package/file-upload/dto/index.d.ts +4 -0
- package/file-upload/dto/index.js +20 -0
- package/file-upload/dto/pagination.dto.d.ts +7 -0
- package/file-upload/dto/pagination.dto.js +39 -0
- package/file-upload/dto/update-file.dto.d.ts +16 -0
- package/file-upload/dto/update-file.dto.js +71 -0
- package/file-upload/entities/file-metadata.entity.d.ts +22 -0
- package/file-upload/entities/file-metadata.entity.js +84 -0
- package/file-upload/entities/file.entity.d.ts +129 -0
- package/file-upload/entities/file.entity.js +384 -0
- package/file-upload/entities/index.d.ts +2 -0
- package/file-upload/entities/index.js +18 -0
- package/file-upload/enums/file-type.enum.d.ts +72 -0
- package/file-upload/enums/file-type.enum.js +212 -0
- package/file-upload/exceptions/file-upload.exception.d.ts +57 -0
- package/file-upload/exceptions/file-upload.exception.js +120 -0
- package/file-upload/exceptions/index.d.ts +1 -0
- package/file-upload/exceptions/index.js +17 -0
- package/file-upload/file-upload.module.d.ts +89 -0
- package/file-upload/file-upload.module.js +264 -0
- package/file-upload/index.d.ts +26 -0
- package/file-upload/index.js +59 -0
- package/file-upload/interceptors/file-upload.interceptor.d.ts +48 -0
- package/file-upload/interceptors/file-upload.interceptor.js +434 -0
- package/file-upload/interceptors/index.d.ts +1 -0
- package/file-upload/interceptors/index.js +17 -0
- package/file-upload/interfaces/custom-file-type.interface.d.ts +72 -0
- package/file-upload/interfaces/custom-file-type.interface.js +2 -0
- package/file-upload/interfaces/file-buffer.interface.d.ts +72 -0
- package/file-upload/interfaces/file-buffer.interface.js +2 -0
- package/file-upload/interfaces/file-entity.interface.d.ts +142 -0
- package/file-upload/interfaces/file-entity.interface.js +28 -0
- package/file-upload/interfaces/file-metadata.interface.d.ts +21 -0
- package/file-upload/interfaces/file-metadata.interface.js +2 -0
- package/file-upload/interfaces/file-upload-options.interface.d.ts +117 -0
- package/file-upload/interfaces/file-upload-options.interface.js +2 -0
- package/file-upload/interfaces/index.d.ts +7 -0
- package/file-upload/interfaces/index.js +24 -0
- package/file-upload/interfaces/storage-provider.interface.d.ts +239 -0
- package/file-upload/interfaces/storage-provider.interface.js +2 -0
- package/file-upload/interfaces/upload-options.interface.d.ts +19 -0
- package/file-upload/interfaces/upload-options.interface.js +2 -0
- package/file-upload/providers/index.d.ts +2 -0
- package/file-upload/providers/index.js +18 -0
- package/file-upload/providers/local-storage.provider.d.ts +98 -0
- package/file-upload/providers/local-storage.provider.js +484 -0
- package/file-upload/providers/s3-storage.provider.d.ts +87 -0
- package/file-upload/providers/s3-storage.provider.js +455 -0
- package/file-upload/services/file-signature-validator.service.d.ts +118 -0
- package/file-upload/services/file-signature-validator.service.js +376 -0
- package/file-upload/services/file.service.d.ts +190 -0
- package/file-upload/services/file.service.js +609 -0
- package/file-upload/services/index.d.ts +4 -0
- package/file-upload/services/index.js +20 -0
- package/file-upload/services/malicious-file-detector.service.d.ts +274 -0
- package/file-upload/services/malicious-file-detector.service.js +1035 -0
- package/file-upload/services/mime-registry.service.d.ts +47 -0
- package/file-upload/services/mime-registry.service.js +167 -0
- package/file-upload/utils/checksum.util.d.ts +28 -0
- package/file-upload/utils/checksum.util.js +65 -0
- package/file-upload/utils/dynamic-import.util.d.ts +50 -0
- package/file-upload/utils/dynamic-import.util.js +144 -0
- package/file-upload/utils/filename.util.d.ts +59 -0
- package/file-upload/utils/filename.util.js +184 -0
- package/file-upload/utils/filepath.util.d.ts +70 -0
- package/file-upload/utils/filepath.util.js +152 -0
- package/file-upload/utils/index.d.ts +4 -0
- package/file-upload/utils/index.js +20 -0
- package/http-client/http-client.module.js +1 -5
- package/index.d.ts +3 -1
- package/index.js +4 -1
- package/package.json +4 -5
- package/redis-lock/lock-heartbeat.service.d.ts +2 -2
- package/redis-lock/lock-heartbeat.service.js +4 -4
- package/redis-lock/redis-lock.service.d.ts +18 -0
- package/redis-lock/redis-lock.service.js +38 -8
- package/setup/bootstrap.setup.d.ts +1 -0
- package/setup/bootstrap.setup.js +1 -0
- package/setup/schedule.decorator.js +18 -8
- package/shared/index.d.ts +1 -1
- package/shared/index.js +1 -1
- package/shared/{serviceRegistryModule.js → service-registry.module.js} +9 -16
- package/shared/services/index.d.ts +0 -1
- package/shared/services/index.js +0 -1
- package/transaction/__tests__/mocks.d.ts +9 -0
- package/transaction/__tests__/mocks.js +33 -0
- package/transaction/base-service-transaction.d.ts +99 -0
- package/transaction/base-service-transaction.js +286 -0
- package/transaction/cls-compatibility.service.d.ts +55 -0
- package/transaction/cls-compatibility.service.js +127 -0
- package/transaction/data-source-registry.d.ts +91 -0
- package/transaction/data-source-registry.js +349 -0
- package/transaction/database-adapter.d.ts +44 -0
- package/transaction/database-adapter.js +240 -0
- package/transaction/decorators/entity-datasource.decorator.d.ts +62 -0
- package/transaction/decorators/entity-datasource.decorator.js +105 -0
- package/transaction/index.d.ts +14 -0
- package/transaction/index.js +57 -0
- package/transaction/logging-transactional.interceptor.d.ts +18 -0
- package/transaction/logging-transactional.interceptor.js +163 -0
- package/transaction/transaction-context.service.d.ts +137 -0
- package/transaction/transaction-context.service.js +411 -0
- package/transaction/transaction-manager.d.ts +230 -0
- package/transaction/transaction-manager.js +1001 -0
- package/transaction/transaction-synchronization.d.ts +171 -0
- package/transaction/transaction-synchronization.js +380 -0
- package/transaction/transaction.errors.d.ts +91 -0
- package/transaction/transaction.errors.js +206 -0
- package/transaction/transaction.module.d.ts +30 -0
- package/transaction/transaction.module.js +98 -0
- package/transaction/transactional.decorator.d.ts +82 -0
- package/transaction/transactional.decorator.js +319 -0
- package/transaction/typeorm-module-wrapper.d.ts +96 -0
- package/transaction/typeorm-module-wrapper.js +197 -0
- package/validators/file-mimetype.validator.d.ts +0 -2
- package/validators/file-mimetype.validator.js +4 -6
- package/validators/is-exists.validator.d.ts +2 -5
- package/validators/is-exists.validator.js +4 -6
- package/validators/is-unique.validator.d.ts +2 -5
- package/validators/is-unique.validator.js +6 -11
- package/shared/services/validator.service.d.ts +0 -3
- package/shared/services/validator.service.js +0 -20
- /package/shared/{serviceRegistryModule.d.ts → service-registry.module.d.ts} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/** 文件状态枚举 */
|
|
2
|
+
export declare enum FileStatus {
|
|
3
|
+
UPLOADING = "uploading",
|
|
4
|
+
PROCESSING = "processing",
|
|
5
|
+
READY = "ready",
|
|
6
|
+
FAILED = "failed",
|
|
7
|
+
DELETED = "deleted",
|
|
8
|
+
QUARANTINED = "quarantined"
|
|
9
|
+
}
|
|
10
|
+
export interface FileEntity {
|
|
11
|
+
/** 唯一标识符 */
|
|
12
|
+
id: string;
|
|
13
|
+
/** 原始文件名 */
|
|
14
|
+
originalName: string;
|
|
15
|
+
/** 存储的文件名(经过安全处理) */
|
|
16
|
+
fileName: string;
|
|
17
|
+
/** MIME类型 */
|
|
18
|
+
mimeType: string;
|
|
19
|
+
/** 文件大小(字节) */
|
|
20
|
+
size: number;
|
|
21
|
+
/** 文件哈希值(SHA-256) */
|
|
22
|
+
hash: string;
|
|
23
|
+
/** 使用的存储提供者 */
|
|
24
|
+
storage: string;
|
|
25
|
+
/** 存储路径/键 */
|
|
26
|
+
path: string;
|
|
27
|
+
/** 公开访问URL(如果可公开访问) */
|
|
28
|
+
url?: string;
|
|
29
|
+
/** 文件元数据 */
|
|
30
|
+
metadata?: FileEntityMetadata;
|
|
31
|
+
/** 上传者ID */
|
|
32
|
+
uploadedBy?: string;
|
|
33
|
+
/** 上传时间 */
|
|
34
|
+
uploadedAt: Date;
|
|
35
|
+
/** 文件状态 */
|
|
36
|
+
status: FileStatus;
|
|
37
|
+
/** 是否已删除(软删除) */
|
|
38
|
+
isDeleted?: boolean;
|
|
39
|
+
/** 删除时间 */
|
|
40
|
+
deletedAt?: Date;
|
|
41
|
+
/** 文件版本号 */
|
|
42
|
+
version?: number;
|
|
43
|
+
/** 标签 */
|
|
44
|
+
tags?: string[];
|
|
45
|
+
/** 父级文件ID(用于版本管理) */
|
|
46
|
+
parentFileId?: string;
|
|
47
|
+
/** 所属文件集合ID */
|
|
48
|
+
collectionId?: string;
|
|
49
|
+
/** 访问次数 */
|
|
50
|
+
accessCount?: number;
|
|
51
|
+
/** 最后访问时间 */
|
|
52
|
+
lastAccessedAt?: Date;
|
|
53
|
+
/** 过期时间 */
|
|
54
|
+
expiresAt?: Date;
|
|
55
|
+
/** 存储提供商返回的额外信息 */
|
|
56
|
+
providerMetadata?: Record<string, any>;
|
|
57
|
+
}
|
|
58
|
+
/** 文件实体元数据 */
|
|
59
|
+
export interface FileEntityMetadata {
|
|
60
|
+
/** 文件类型分类 */
|
|
61
|
+
category?: FileCategory;
|
|
62
|
+
/** 文件扩展名 */
|
|
63
|
+
extension?: string;
|
|
64
|
+
/** 文件编码 */
|
|
65
|
+
encoding?: string;
|
|
66
|
+
/** 宽度(适用于图片/视频) */
|
|
67
|
+
width?: number;
|
|
68
|
+
/** 高度(适用于图片/视频) */
|
|
69
|
+
height?: number;
|
|
70
|
+
/** 持续时间(适用于音频/视频) */
|
|
71
|
+
duration?: number;
|
|
72
|
+
/** 页数(适用于文档) */
|
|
73
|
+
pages?: number;
|
|
74
|
+
/** DPI(适用于图片) */
|
|
75
|
+
dpi?: number;
|
|
76
|
+
/** 色彩模式(适用于图片) */
|
|
77
|
+
colorMode?: string;
|
|
78
|
+
/** 压缩率 */
|
|
79
|
+
compressionRatio?: number;
|
|
80
|
+
/** EXIF信息(适用于图片) */
|
|
81
|
+
exif?: Record<string, any>;
|
|
82
|
+
/** 自定义元数据 */
|
|
83
|
+
custom?: Record<string, any>;
|
|
84
|
+
}
|
|
85
|
+
/** 文件分类 */
|
|
86
|
+
export declare enum FileCategory {
|
|
87
|
+
IMAGE = "image",
|
|
88
|
+
VIDEO = "video",
|
|
89
|
+
AUDIO = "audio",
|
|
90
|
+
DOCUMENT = "document",
|
|
91
|
+
SPREADSHEET = "spreadsheet",
|
|
92
|
+
PRESENTATION = "presentation",
|
|
93
|
+
ARCHIVE = "archive",
|
|
94
|
+
CODE = "code",
|
|
95
|
+
TEXT = "text",
|
|
96
|
+
BINARY = "binary",
|
|
97
|
+
OTHER = "other"
|
|
98
|
+
}
|
|
99
|
+
/** 文件集合 */
|
|
100
|
+
export interface FileCollection {
|
|
101
|
+
/** 集合ID */
|
|
102
|
+
id: string;
|
|
103
|
+
/** 集合名称 */
|
|
104
|
+
name: string;
|
|
105
|
+
/** 集合描述 */
|
|
106
|
+
description?: string;
|
|
107
|
+
/** 包含的文件列表 */
|
|
108
|
+
files?: FileEntity[];
|
|
109
|
+
/** 集合所有者 */
|
|
110
|
+
ownerId?: string;
|
|
111
|
+
/** 创建时间 */
|
|
112
|
+
createdAt?: Date;
|
|
113
|
+
/** 更新时间 */
|
|
114
|
+
updatedAt?: Date;
|
|
115
|
+
/** 是否公开 */
|
|
116
|
+
isPublic?: boolean;
|
|
117
|
+
/** 访问密码 */
|
|
118
|
+
password?: string;
|
|
119
|
+
/** 下载限制 */
|
|
120
|
+
downloadLimit?: number;
|
|
121
|
+
/** 过期时间 */
|
|
122
|
+
expiresAt?: Date;
|
|
123
|
+
/** 集合配置 */
|
|
124
|
+
settings?: CollectionSettings;
|
|
125
|
+
}
|
|
126
|
+
/** 集合设置 */
|
|
127
|
+
export interface CollectionSettings {
|
|
128
|
+
/** 是否允许添加文件 */
|
|
129
|
+
allowAddFiles?: boolean;
|
|
130
|
+
/** 是否允许删除文件 */
|
|
131
|
+
allowDeleteFiles?: boolean;
|
|
132
|
+
/** 是否允许下载 */
|
|
133
|
+
allowDownload?: boolean;
|
|
134
|
+
/** 是否需要密码访问 */
|
|
135
|
+
requirePassword?: boolean;
|
|
136
|
+
/** 生成ZIP包 */
|
|
137
|
+
generateZip?: boolean;
|
|
138
|
+
/** 最大文件数 */
|
|
139
|
+
maxFiles?: number;
|
|
140
|
+
/** 最大总大小 */
|
|
141
|
+
maxTotalSize?: number;
|
|
142
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileCategory = exports.FileStatus = void 0;
|
|
4
|
+
/** 文件状态枚举 */
|
|
5
|
+
var FileStatus;
|
|
6
|
+
(function (FileStatus) {
|
|
7
|
+
FileStatus["UPLOADING"] = "uploading";
|
|
8
|
+
FileStatus["PROCESSING"] = "processing";
|
|
9
|
+
FileStatus["READY"] = "ready";
|
|
10
|
+
FileStatus["FAILED"] = "failed";
|
|
11
|
+
FileStatus["DELETED"] = "deleted";
|
|
12
|
+
FileStatus["QUARANTINED"] = "quarantined";
|
|
13
|
+
})(FileStatus || (exports.FileStatus = FileStatus = {}));
|
|
14
|
+
/** 文件分类 */
|
|
15
|
+
var FileCategory;
|
|
16
|
+
(function (FileCategory) {
|
|
17
|
+
FileCategory["IMAGE"] = "image";
|
|
18
|
+
FileCategory["VIDEO"] = "video";
|
|
19
|
+
FileCategory["AUDIO"] = "audio";
|
|
20
|
+
FileCategory["DOCUMENT"] = "document";
|
|
21
|
+
FileCategory["SPREADSHEET"] = "spreadsheet";
|
|
22
|
+
FileCategory["PRESENTATION"] = "presentation";
|
|
23
|
+
FileCategory["ARCHIVE"] = "archive";
|
|
24
|
+
FileCategory["CODE"] = "code";
|
|
25
|
+
FileCategory["TEXT"] = "text";
|
|
26
|
+
FileCategory["BINARY"] = "binary";
|
|
27
|
+
FileCategory["OTHER"] = "other";
|
|
28
|
+
})(FileCategory || (exports.FileCategory = FileCategory = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** 文件元数据接口 */
|
|
2
|
+
export interface FileMetadata {
|
|
3
|
+
/** 文件大小 */
|
|
4
|
+
size: number;
|
|
5
|
+
/** MIME类型 */
|
|
6
|
+
mimeType: string;
|
|
7
|
+
/** 最后修改时间 */
|
|
8
|
+
lastModified: Date;
|
|
9
|
+
/** ETag */
|
|
10
|
+
etag?: string;
|
|
11
|
+
/** 文件扩展名 */
|
|
12
|
+
extension?: string;
|
|
13
|
+
/** 文件编码 */
|
|
14
|
+
encoding?: string;
|
|
15
|
+
/** 宽度(像素)- 适用于图片、视频 */
|
|
16
|
+
width?: number;
|
|
17
|
+
/** 高度(像素)- 适用于图片、视频 */
|
|
18
|
+
height?: number;
|
|
19
|
+
/** 自定义元数据 */
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { FileType } from '../enums/file-type.enum';
|
|
2
|
+
import { Request } from 'express';
|
|
3
|
+
/**
|
|
4
|
+
* 文件上传选项
|
|
5
|
+
*/
|
|
6
|
+
export interface FileUploadOptions {
|
|
7
|
+
/** 文件大小限制(字节),默认 10MB */
|
|
8
|
+
maxSize?: number;
|
|
9
|
+
/** 允许的文件类型(FileType 枚举或 MIME 类型) */
|
|
10
|
+
types?: Array<FileType | string>;
|
|
11
|
+
/** 允许的扩展名 */
|
|
12
|
+
exts?: string[];
|
|
13
|
+
/** 需要认证 */
|
|
14
|
+
auth?: boolean;
|
|
15
|
+
/** 需要文件所有权 */
|
|
16
|
+
ownership?: boolean;
|
|
17
|
+
/** 公开访问 */
|
|
18
|
+
public?: boolean;
|
|
19
|
+
/** 病毒扫描: true=强制, false=禁用, 'auto'=智能(默认) */
|
|
20
|
+
scan?: boolean | 'auto';
|
|
21
|
+
/** 文件名清理,默认 true */
|
|
22
|
+
sanitize?: boolean;
|
|
23
|
+
/** 保留原始文件名(默认 false,使用 UUID)*/
|
|
24
|
+
preserveOriginalName?: boolean;
|
|
25
|
+
/** 是否启用文件签名验证(默认 true) */
|
|
26
|
+
validateSignature?: boolean;
|
|
27
|
+
/** 是否启用恶意文件检测 */
|
|
28
|
+
maliciousCheck?: boolean;
|
|
29
|
+
image?: {
|
|
30
|
+
/** 调整大小 */
|
|
31
|
+
resize?: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
|
|
35
|
+
};
|
|
36
|
+
/** 压缩质量 0-100 */
|
|
37
|
+
quality?: number;
|
|
38
|
+
/** 输出格式 */
|
|
39
|
+
format?: 'jpeg' | 'png' | 'webp';
|
|
40
|
+
/** 水印文字 */
|
|
41
|
+
watermark?: string;
|
|
42
|
+
/** 生成缩略图 */
|
|
43
|
+
thumbnail?: boolean;
|
|
44
|
+
};
|
|
45
|
+
processor?: string | {
|
|
46
|
+
name: string;
|
|
47
|
+
options?: any;
|
|
48
|
+
};
|
|
49
|
+
/** 存储提供者: 'local' | 's3' | 'oss' | 'minio' */
|
|
50
|
+
storage?: string;
|
|
51
|
+
/** 自定义存储路径 */
|
|
52
|
+
path?: string;
|
|
53
|
+
/** 上传前钩子 */
|
|
54
|
+
before?: (file: Express.Multer.File, context: UploadContext) => Promise<void>;
|
|
55
|
+
/** 上传后钩子 */
|
|
56
|
+
after?: (file: Express.Multer.File, context: UploadContext) => Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 上传上下文
|
|
60
|
+
*/
|
|
61
|
+
export interface UploadContext {
|
|
62
|
+
/** 共享数据 */
|
|
63
|
+
shared: Record<string, any>;
|
|
64
|
+
/** 获取处理器 */
|
|
65
|
+
getProcessor(name: string): IFileProcessor | null;
|
|
66
|
+
/** 保存文件元数据 */
|
|
67
|
+
saveMetadata(fileId: string, metadata: any): Promise<void>;
|
|
68
|
+
/** 获取当前用户 */
|
|
69
|
+
getUser(): any;
|
|
70
|
+
/** 获取请求对象 */
|
|
71
|
+
getRequest(): Request;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 文件处理器接口
|
|
75
|
+
*/
|
|
76
|
+
export interface IFileProcessor {
|
|
77
|
+
/** 处理器名称 */
|
|
78
|
+
name: string;
|
|
79
|
+
/** 支持的文件类型 */
|
|
80
|
+
supports: Array<FileType | string>;
|
|
81
|
+
/** 处理文件 */
|
|
82
|
+
process(file: Express.Multer.File, options?: any): Promise<any>;
|
|
83
|
+
/** 验证文件(可选) */
|
|
84
|
+
validate?(file: Express.Multer.File): Promise<boolean>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Excel 数据配置
|
|
88
|
+
*/
|
|
89
|
+
export interface ExcelDataOptions {
|
|
90
|
+
/** 工作表索引,默认 0 */
|
|
91
|
+
sheetIndex?: number;
|
|
92
|
+
/** 开始行,默认 1(跳过表头) */
|
|
93
|
+
startRow?: number;
|
|
94
|
+
/** 最大行数 */
|
|
95
|
+
maxRows?: number;
|
|
96
|
+
/** 解析前验证 */
|
|
97
|
+
validateBeforeParse?: boolean;
|
|
98
|
+
/** 遇到错误停止 */
|
|
99
|
+
stopOnError?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* CSV 数据配置
|
|
103
|
+
*/
|
|
104
|
+
export interface CsvDataOptions {
|
|
105
|
+
/** 分隔符,默认 ',' */
|
|
106
|
+
delimiter?: ',' | ';' | '\t' | string;
|
|
107
|
+
/** 引号字符,默认 '"' */
|
|
108
|
+
quote?: string;
|
|
109
|
+
/** 转义字符,默认 '"' */
|
|
110
|
+
escape?: string;
|
|
111
|
+
/** 跳过空行 */
|
|
112
|
+
skipEmptyLines?: boolean;
|
|
113
|
+
/** 跳过表头 */
|
|
114
|
+
skipHeader?: boolean;
|
|
115
|
+
/** 编码,默认 'utf8' */
|
|
116
|
+
encoding?: 'utf8' | 'gbk' | 'gb2312' | string;
|
|
117
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './file-entity.interface';
|
|
2
|
+
export * from './storage-provider.interface';
|
|
3
|
+
export * from './file-buffer.interface';
|
|
4
|
+
export * from './file-metadata.interface';
|
|
5
|
+
export * from './upload-options.interface';
|
|
6
|
+
export * from './file-upload-options.interface';
|
|
7
|
+
export * from './custom-file-type.interface';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Core interfaces
|
|
18
|
+
__exportStar(require("./file-entity.interface"), exports);
|
|
19
|
+
__exportStar(require("./storage-provider.interface"), exports);
|
|
20
|
+
__exportStar(require("./file-buffer.interface"), exports);
|
|
21
|
+
__exportStar(require("./file-metadata.interface"), exports);
|
|
22
|
+
__exportStar(require("./upload-options.interface"), exports);
|
|
23
|
+
__exportStar(require("./file-upload-options.interface"), exports);
|
|
24
|
+
__exportStar(require("./custom-file-type.interface"), exports);
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { FileBuffer } from './file-buffer.interface';
|
|
2
|
+
import { UploadOptions } from './upload-options.interface';
|
|
3
|
+
import { FileMetadata } from './file-metadata.interface';
|
|
4
|
+
/** 存储提供者接口 */
|
|
5
|
+
export interface IStorageProvider {
|
|
6
|
+
/** 提供者名称 */
|
|
7
|
+
name: string;
|
|
8
|
+
/** 上传文件 */
|
|
9
|
+
upload(file: FileBuffer, options: UploadOptions): Promise<UploadResult>;
|
|
10
|
+
/** 下载文件 */
|
|
11
|
+
download(path: string): Promise<FileBuffer>;
|
|
12
|
+
/** 删除文件 */
|
|
13
|
+
delete(path: string): Promise<void>;
|
|
14
|
+
/** 批量删除 */
|
|
15
|
+
deleteBatch(paths: string[]): Promise<BatchDeleteResult>;
|
|
16
|
+
/** 检查文件是否存在 */
|
|
17
|
+
exists(path: string): Promise<boolean>;
|
|
18
|
+
/** 获取文件元数据 */
|
|
19
|
+
getMetadata(path: string): Promise<FileMetadata>;
|
|
20
|
+
/** 获取预签名URL */
|
|
21
|
+
getSignedUrl(path: string, expiresIn?: number): Promise<string>;
|
|
22
|
+
/** 获取预签名上传URL(用于客户端直传) */
|
|
23
|
+
getSignedUploadUrl(path: string, expiresIn?: number, contentType?: string): Promise<PreSignedUploadInfo>;
|
|
24
|
+
/** 复制文件 */
|
|
25
|
+
copy(sourcePath: string, destinationPath: string): Promise<CopyResult>;
|
|
26
|
+
/** 移动文件 */
|
|
27
|
+
move(sourcePath: string, destinationPath: string): Promise<MoveResult>;
|
|
28
|
+
/** 列出文件 */
|
|
29
|
+
list(prefix?: string, limit?: number): Promise<ListResult>;
|
|
30
|
+
/** 初始化存储配置 */
|
|
31
|
+
initialize(): Promise<void>;
|
|
32
|
+
/** 健康检查 */
|
|
33
|
+
healthCheck(): Promise<HealthStatus>;
|
|
34
|
+
}
|
|
35
|
+
/** 上传结果 */
|
|
36
|
+
export interface UploadResult {
|
|
37
|
+
/** 文件路径/键 */
|
|
38
|
+
key: string;
|
|
39
|
+
/** 访问URL */
|
|
40
|
+
url?: string;
|
|
41
|
+
/** ETag */
|
|
42
|
+
etag?: string;
|
|
43
|
+
/** 版本ID(如果支持) */
|
|
44
|
+
versionId?: string;
|
|
45
|
+
/** 文件大小 */
|
|
46
|
+
size: number;
|
|
47
|
+
/** 上传时间 */
|
|
48
|
+
uploadedAt: Date;
|
|
49
|
+
/** 额外元数据 */
|
|
50
|
+
metadata?: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
/** 批量删除结果 */
|
|
53
|
+
export interface BatchDeleteResult {
|
|
54
|
+
/** 成功删除的文件列表 */
|
|
55
|
+
deleted: string[];
|
|
56
|
+
/** 删除失败的文件列表 */
|
|
57
|
+
failed: Array<{
|
|
58
|
+
path: string;
|
|
59
|
+
error: string;
|
|
60
|
+
}>;
|
|
61
|
+
/** 总数 */
|
|
62
|
+
total: number;
|
|
63
|
+
}
|
|
64
|
+
/** 复制结果 */
|
|
65
|
+
export interface CopyResult {
|
|
66
|
+
/** 目标路径 */
|
|
67
|
+
destinationPath: string;
|
|
68
|
+
/** 文件大小 */
|
|
69
|
+
size: number;
|
|
70
|
+
/** 复制时间 */
|
|
71
|
+
copiedAt: Date;
|
|
72
|
+
/** ETag */
|
|
73
|
+
etag?: string;
|
|
74
|
+
}
|
|
75
|
+
/** 移动结果 */
|
|
76
|
+
export interface MoveResult {
|
|
77
|
+
/** 目标路径 */
|
|
78
|
+
destinationPath: string;
|
|
79
|
+
/** 文件大小 */
|
|
80
|
+
size: number;
|
|
81
|
+
/** 移动时间 */
|
|
82
|
+
movedAt: Date;
|
|
83
|
+
/** ETag */
|
|
84
|
+
etag?: string;
|
|
85
|
+
}
|
|
86
|
+
/** 列表结果 */
|
|
87
|
+
export interface ListResult {
|
|
88
|
+
/** 文件列表 */
|
|
89
|
+
files: Array<{
|
|
90
|
+
key: string;
|
|
91
|
+
size: number;
|
|
92
|
+
lastModified: Date;
|
|
93
|
+
etag?: string;
|
|
94
|
+
}>;
|
|
95
|
+
/** 是否还有更多文件 */
|
|
96
|
+
hasMore: boolean;
|
|
97
|
+
/** 下一个标记 */
|
|
98
|
+
nextMarker?: string;
|
|
99
|
+
/** 总数(如果支持) */
|
|
100
|
+
totalCount?: number;
|
|
101
|
+
}
|
|
102
|
+
/** 预签名上传信息 */
|
|
103
|
+
export interface PreSignedUploadInfo {
|
|
104
|
+
/** 上传URL */
|
|
105
|
+
url: string;
|
|
106
|
+
/** HTTP方法 */
|
|
107
|
+
method: 'PUT' | 'POST';
|
|
108
|
+
/** 需要的头部 */
|
|
109
|
+
headers: Record<string, string>;
|
|
110
|
+
/** 表单字段(如果使用POST) */
|
|
111
|
+
fields?: Record<string, string>;
|
|
112
|
+
/** 过期时间 */
|
|
113
|
+
expiresAt: Date;
|
|
114
|
+
}
|
|
115
|
+
/** 健康状态 */
|
|
116
|
+
export interface HealthStatus {
|
|
117
|
+
/** 是否健康 */
|
|
118
|
+
healthy: boolean;
|
|
119
|
+
/** 响应时间(毫秒) */
|
|
120
|
+
responseTime: number;
|
|
121
|
+
/** 错误信息 */
|
|
122
|
+
error?: string;
|
|
123
|
+
/** 额外信息 */
|
|
124
|
+
details?: Record<string, any>;
|
|
125
|
+
}
|
|
126
|
+
/** 本地存储选项 */
|
|
127
|
+
export interface LocalStorageOptions {
|
|
128
|
+
/** 上传根目录 */
|
|
129
|
+
uploadPath: string;
|
|
130
|
+
/** 基础URL */
|
|
131
|
+
baseUrl?: string;
|
|
132
|
+
/** 是否创建子目录 */
|
|
133
|
+
createSubdirectories?: boolean;
|
|
134
|
+
/** 子目录格式(date: YYYY/MM/DD, hash: AB/CD/EF) */
|
|
135
|
+
subdirectoryFormat?: 'none' | 'date' | 'hash';
|
|
136
|
+
/** 最大文件大小 */
|
|
137
|
+
maxSize?: number;
|
|
138
|
+
/** 文件权限 */
|
|
139
|
+
fileMode?: string;
|
|
140
|
+
/** 目录权限 */
|
|
141
|
+
dirMode?: string;
|
|
142
|
+
}
|
|
143
|
+
/** S3存储选项 */
|
|
144
|
+
export interface S3StorageOptions {
|
|
145
|
+
/** AWS访问密钥ID */
|
|
146
|
+
accessKeyId: string;
|
|
147
|
+
/** AWS秘密访问密钥 */
|
|
148
|
+
secretAccessKey: string;
|
|
149
|
+
/** AWS区域 */
|
|
150
|
+
region: string;
|
|
151
|
+
/** S3存储桶名称 */
|
|
152
|
+
bucket: string;
|
|
153
|
+
/** 自定义端点 */
|
|
154
|
+
endpoint?: string;
|
|
155
|
+
/** ACL(访问控制列表) */
|
|
156
|
+
acl?: string;
|
|
157
|
+
/** 服务器端加密 */
|
|
158
|
+
serverSideEncryption?: string;
|
|
159
|
+
/** 存储类别 */
|
|
160
|
+
storageClass?: string;
|
|
161
|
+
/** 是否启用CDN */
|
|
162
|
+
cdnEnabled?: boolean;
|
|
163
|
+
/** CDN域名 */
|
|
164
|
+
cdnDomain?: string;
|
|
165
|
+
/** 是否使用路径样式访问 */
|
|
166
|
+
forcePathStyle?: boolean;
|
|
167
|
+
/** 签名版本 */
|
|
168
|
+
signatureVersion?: string;
|
|
169
|
+
}
|
|
170
|
+
/** OSS存储选项 */
|
|
171
|
+
export interface OSSStorageOptions {
|
|
172
|
+
/** Access Key ID */
|
|
173
|
+
accessKeyId: string;
|
|
174
|
+
/** Access Key Secret */
|
|
175
|
+
accessKeySecret: string;
|
|
176
|
+
/** OSS区域 */
|
|
177
|
+
region: string;
|
|
178
|
+
/** OSS Bucket名称 */
|
|
179
|
+
bucket: string;
|
|
180
|
+
/** 内网域名 */
|
|
181
|
+
internalEndpoint?: string;
|
|
182
|
+
/** 外网域名 */
|
|
183
|
+
externalEndpoint?: string;
|
|
184
|
+
/** 安全令牌(STS) */
|
|
185
|
+
securityToken?: string;
|
|
186
|
+
/** 访问权限 */
|
|
187
|
+
acl?: string;
|
|
188
|
+
/** 服务器端加密 */
|
|
189
|
+
serverSideEncryption?: string;
|
|
190
|
+
/** 是否启用CDN */
|
|
191
|
+
cdnEnabled?: boolean;
|
|
192
|
+
/** CDN加速域名 */
|
|
193
|
+
cdnDomain?: string;
|
|
194
|
+
}
|
|
195
|
+
/** MinIO存储选项 */
|
|
196
|
+
export interface MinIOStorageOptions {
|
|
197
|
+
/** 端点URL */
|
|
198
|
+
endPoint: string;
|
|
199
|
+
/** 端口 */
|
|
200
|
+
port: number;
|
|
201
|
+
/** 是否使用SSL */
|
|
202
|
+
useSSL: boolean;
|
|
203
|
+
/** Access Key */
|
|
204
|
+
accessKey: string;
|
|
205
|
+
/** Secret Key */
|
|
206
|
+
secretKey: string;
|
|
207
|
+
/** Bucket名称 */
|
|
208
|
+
bucket: string;
|
|
209
|
+
/** Region */
|
|
210
|
+
region?: string;
|
|
211
|
+
/** 是否启用CDN */
|
|
212
|
+
cdnEnabled?: boolean;
|
|
213
|
+
/** CDN域名 */
|
|
214
|
+
cdnDomain?: string;
|
|
215
|
+
}
|
|
216
|
+
/** 存储配置 */
|
|
217
|
+
export interface StorageConfig {
|
|
218
|
+
/** 存储提供者类型 */
|
|
219
|
+
provider: 'local' | 's3' | 'oss' | 'minio';
|
|
220
|
+
/** 提供者特定配置 */
|
|
221
|
+
options: LocalStorageOptions | S3StorageOptions | OSSStorageOptions | MinIOStorageOptions;
|
|
222
|
+
/** 是否启用备份 */
|
|
223
|
+
backup?: {
|
|
224
|
+
enabled: boolean;
|
|
225
|
+
provider: StorageConfig['provider'];
|
|
226
|
+
options: StorageConfig['options'];
|
|
227
|
+
};
|
|
228
|
+
/** 是否启用镜像 */
|
|
229
|
+
mirror?: {
|
|
230
|
+
enabled: boolean;
|
|
231
|
+
providers: Array<StorageConfig>;
|
|
232
|
+
};
|
|
233
|
+
/** 缓存配置 */
|
|
234
|
+
cache?: {
|
|
235
|
+
enabled: boolean;
|
|
236
|
+
ttl: number;
|
|
237
|
+
maxSize: number;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** 上传选项 */
|
|
2
|
+
export interface UploadOptions {
|
|
3
|
+
/** 文件存储路径前缀 */
|
|
4
|
+
path?: string;
|
|
5
|
+
/** 自定义文件名 */
|
|
6
|
+
filename?: string;
|
|
7
|
+
/** 文件访问权限 */
|
|
8
|
+
acl?: 'public-read' | 'private' | 'public-read-write' | 'authenticated-read';
|
|
9
|
+
/** 文件标签 */
|
|
10
|
+
tags?: string[];
|
|
11
|
+
/** 元数据 */
|
|
12
|
+
metadata?: Record<string, string>;
|
|
13
|
+
/** 是否覆盖已存在的文件 */
|
|
14
|
+
overwrite?: boolean;
|
|
15
|
+
/** 用户ID */
|
|
16
|
+
userId?: string;
|
|
17
|
+
/** 自定义选项 */
|
|
18
|
+
custom?: Record<string, any>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./local-storage.provider"), exports);
|
|
18
|
+
__exportStar(require("./s3-storage.provider"), exports);
|