sa2kit 1.1.0 → 1.2.1

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.
@@ -1,261 +1,5 @@
1
1
  import { EventEmitter } from 'events';
2
-
3
- /**
4
- * 通用文件服务类型定义
5
- *
6
- * 定义了文件存储、上传、下载等核心接口和类型
7
- */
8
- /** 文件存储类型 */
9
- type StorageType$1 = 'local' | 'aliyun-oss' | 'aws-s3' | 'qcloud-cos';
10
- /** CDN提供者类型 */
11
- type CDNType$1 = 'none' | 'aliyun-cdn' | 'aws-cloudfront' | 'qcloud-cdn';
12
- /** 文件处理类型 */
13
- type ProcessorType$1 = 'image' | 'audio' | 'video' | 'document';
14
- /** 文件上传状态 */
15
- type UploadStatus = 'pending' | 'uploading' | 'processing' | 'completed' | 'failed';
16
- /** 访问权限类型 */
17
- type AccessPermission = 'public' | 'private' | 'authenticated' | 'owner-only';
18
- /** 文件元数据基础接口 */
19
- interface FileMetadata {
20
- /** 文件ID */
21
- id: string;
22
- /** 原始文件名 */
23
- originalName: string;
24
- /** 存储文件名 */
25
- storageName: string;
26
- /** 文件大小(字节) */
27
- size: number;
28
- /** MIME类型 */
29
- mimeType: string;
30
- /** 文件扩展名 */
31
- extension: string;
32
- /** 文件哈希值 */
33
- hash?: string;
34
- /** 上传时间 */
35
- uploadTime: Date;
36
- /** 访问权限 */
37
- permission: AccessPermission;
38
- /** 上传者ID */
39
- uploaderId: string;
40
- /** 模块标识 */
41
- moduleId: string;
42
- /** 业务标识 */
43
- businessId?: string;
44
- /** 存储提供者 */
45
- storageProvider: StorageType$1;
46
- /** 存储路径 */
47
- storagePath: string;
48
- /** CDN URL */
49
- cdnUrl?: string;
50
- /** 访问次数 */
51
- accessCount: number;
52
- /** 最后访问时间 */
53
- lastAccessTime?: Date;
54
- /** 过期时间 */
55
- expiresAt?: Date;
56
- /** 自定义元数据 */
57
- metadata?: Record<string, any>;
58
- }
59
- /** 上传文件信息(客户端使用) */
60
- interface UploadFileInfo$1 {
61
- /** 文件对象 */
62
- file: File;
63
- /** 模块标识 */
64
- moduleId: string;
65
- /** 业务标识 */
66
- businessId?: string;
67
- /** 访问权限 */
68
- permission?: AccessPermission;
69
- /** 自定义存储路径 */
70
- customPath?: string;
71
- /** 自定义元数据 */
72
- metadata?: Record<string, any>;
73
- /** 是否需要处理 */
74
- needsProcessing?: boolean;
75
- /** 处理选项 */
76
- processingOptions?: ProcessingOptions$1;
77
- }
78
- /** 文件处理选项基础接口 */
79
- interface ProcessingOptions$1 {
80
- /** 处理器类型 */
81
- type: ProcessorType$1;
82
- /** 处理参数 */
83
- params?: Record<string, any>;
84
- }
85
- /** 图片处理选项 */
86
- interface ImageProcessingOptions extends ProcessingOptions$1 {
87
- type: 'image';
88
- /** 压缩质量 0-100 */
89
- quality?: number;
90
- /** 目标宽度 */
91
- width?: number;
92
- /** 目标高度 */
93
- height?: number;
94
- /** 格式转换 */
95
- format?: 'jpeg' | 'png' | 'webp' | 'avif';
96
- /** 是否添加水印 */
97
- watermark?: boolean;
98
- /** 水印配置 */
99
- watermarkOptions?: {
100
- text?: string;
101
- image?: string;
102
- position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
103
- opacity?: number;
104
- };
105
- }
106
- /** 音频处理选项 */
107
- interface AudioProcessingOptions extends ProcessingOptions$1 {
108
- type: 'audio';
109
- /** 比特率 */
110
- bitrate?: number;
111
- /** 格式转换 */
112
- format?: 'mp3' | 'wav' | 'ogg' | 'aac';
113
- /** 采样率 */
114
- sampleRate?: number;
115
- /** 声道数 */
116
- channels?: number;
117
- }
118
- /** 视频处理选项 */
119
- interface VideoProcessingOptions extends ProcessingOptions$1 {
120
- type: 'video';
121
- /** 视频质量 */
122
- quality?: number;
123
- /** 格式转换 */
124
- format?: 'mp4' | 'avi' | 'mov' | 'webm';
125
- /** 生成缩略图 */
126
- generateThumbnail?: boolean;
127
- /** 缩略图时间点(秒) */
128
- thumbnailTime?: number;
129
- }
130
- /** 上传进度 */
131
- interface UploadProgress {
132
- /** 文件ID */
133
- fileId: string;
134
- /** 上传状态 */
135
- status: UploadStatus;
136
- /** 进度百分比(0-100) */
137
- progress: number;
138
- /** 已上传字节数 */
139
- uploadedBytes: number;
140
- /** 总字节数 */
141
- totalBytes: number;
142
- /** 上传速度(字节/秒) */
143
- speed: number;
144
- /** 剩余时间(秒) */
145
- remainingTime: number;
146
- /** 错误信息 */
147
- error?: string;
148
- }
149
- /** 上传结果 */
150
- interface UploadResult {
151
- /** 是否成功 */
152
- success: boolean;
153
- /** 文件元数据 */
154
- file?: FileMetadata;
155
- /** 文件访问URL */
156
- url?: string;
157
- /** 错误信息 */
158
- error?: string;
159
- }
160
- /** 文件查询选项 */
161
- interface FileQueryOptions$1 {
162
- /** 模块标识 */
163
- moduleId?: string;
164
- /** 业务标识 */
165
- businessId?: string;
166
- /** 上传者ID */
167
- uploaderId?: string;
168
- /** MIME类型过滤 */
169
- mimeType?: string;
170
- /** 最小文件大小 */
171
- minSize?: number;
172
- /** 最大文件大小 */
173
- maxSize?: number;
174
- /** 开始时间 */
175
- startTime?: Date;
176
- /** 结束时间 */
177
- endTime?: Date;
178
- /** 搜索关键词 */
179
- keyword?: string;
180
- /** 标签 */
181
- tags?: string[];
182
- /** 排序字段 */
183
- sortBy?: string;
184
- /** 排序方向 */
185
- sortOrder?: 'asc' | 'desc';
186
- /** 页码 */
187
- page?: number;
188
- /** 每页数量 */
189
- pageSize?: number;
190
- }
191
- /** 分页结果 */
192
- interface PaginatedResult$1<T> {
193
- /** 数据项 */
194
- items: T[];
195
- /** 总数 */
196
- total: number;
197
- /** 当前页码 */
198
- page: number;
199
- /** 每页数量 */
200
- pageSize: number;
201
- /** 总页数 */
202
- totalPages: number;
203
- /** 是否有下一页 */
204
- hasNext: boolean;
205
- /** 是否有上一页 */
206
- hasPrev: boolean;
207
- }
208
- /** 批量操作结果 */
209
- interface BatchOperationResult {
210
- /** 成功数量 */
211
- successCount: number;
212
- /** 失败数量 */
213
- failureCount: number;
214
- /** 失败详情 */
215
- failures: Array<{
216
- fileId: string;
217
- error: string;
218
- }>;
219
- }
220
- /** 文件事件类型 */
221
- type FileEventType$1 = 'upload:start' | 'upload:progress' | 'upload:complete' | 'upload:error' | 'download:start' | 'download:complete' | 'download:error' | 'delete:complete' | 'processing:start' | 'processing:complete' | 'processing:error';
222
- /** 文件事件 */
223
- interface FileEvent$1 {
224
- /** 事件类型 */
225
- type: FileEventType$1;
226
- /** 文件ID */
227
- fileId: string;
228
- /** 事件时间 */
229
- timestamp: Date;
230
- /** 事件数据 */
231
- data?: Record<string, any>;
232
- /** 错误信息 */
233
- error?: string;
234
- }
235
- /** 文件事件监听器 */
236
- type FileEventListener$1 = (event: FileEvent$1) => void | Promise<void>;
237
- /** 文件服务基础异常 */
238
- declare class FileServiceError$1 extends Error {
239
- readonly code: string;
240
- readonly details?: Record<string, any> | undefined;
241
- constructor(message: string, code: string, details?: Record<string, any> | undefined);
242
- }
243
- /** 文件上传错误 */
244
- declare class FileUploadError$1 extends FileServiceError$1 {
245
- constructor(message: string, details?: Record<string, any>);
246
- }
247
- /** 文件处理错误 */
248
- declare class FileProcessingError$1 extends FileServiceError$1 {
249
- constructor(message: string, details?: Record<string, any>);
250
- }
251
- /** 存储提供者错误 */
252
- declare class StorageProviderError$1 extends FileServiceError$1 {
253
- constructor(message: string, details?: Record<string, any>);
254
- }
255
- /** CDN提供者错误 */
256
- declare class CDNProviderError$1 extends FileServiceError$1 {
257
- constructor(message: string, details?: Record<string, any>);
258
- }
2
+ import { S as StorageType$1, C as CDNType$1, F as FileMetadata, A as AccessPermission, U as UploadStatus, P as ProcessorType$1, a as UploadFileInfo$1, b as ProcessingOptions$1, c as UploadProgress, d as FileEventListener$1 } from './types-Dg-U_chI.js';
259
3
 
260
4
  /**
261
5
  * UniversalFile Server 端类型定义
@@ -724,4 +468,4 @@ declare class UniversalFileService extends EventEmitter {
724
468
  private emitFileEvent;
725
469
  }
726
470
 
727
- export { type FileEventType as $, type AccessPermission as A, type BatchOperationResult as B, CDNProviderError$1 as C, type IFileProcessor as D, type ProcessorType as E, type FileMetadata as F, type ProcessingOptions as G, type ProcessingResult as H, type ImageProcessingOptions as I, type IFileMetadataRepository as J, type AliyunOSSConfig as K, type AliyunCDNConfig as L, type LocalStorageConfig as M, type FileServicePersistenceConfig as N, type CacheConfig as O, type PaginatedResult$1 as P, type StorageMetadata as Q, type CDNStats as R, StorageProviderError$1 as S, type ProcessorInfo as T, type UploadFileInfo$1 as U, type VideoProcessingOptions as V, type FileRecord as W, type FileQueryOptions as X, type PaginatedResult as Y, type FileEvent as Z, type FileEventListener as _, type UploadProgress as a, FileServiceError as a0, FileUploadError as a1, FileProcessingError as a2, StorageProviderError as a3, CDNProviderError as a4, type FileQueryOptions$1 as b, UniversalFileService as c, type ProcessingOptions$1 as d, FileServiceError$1 as e, FileUploadError$1 as f, FileProcessingError$1 as g, type StorageType$1 as h, type CDNType$1 as i, type ProcessorType$1 as j, type UploadStatus as k, type AudioProcessingOptions as l, type UploadResult as m, type FileEventType$1 as n, type FileEvent$1 as o, type FileEventListener$1 as p, type UniversalFileServiceConfig as q, type StorageConfig as r, type IStorageProvider as s, type StorageType as t, type UploadFileInfo as u, type StorageResult as v, type ICDNProvider as w, type CDNType as x, type CDNConfig as y, type CDNResult as z };
471
+ export { type AliyunOSSConfig as A, CDNProviderError as B, type CDNType as C, type FileServicePersistenceConfig as F, type IStorageProvider as I, type LocalStorageConfig as L, type ProcessorType as P, type StorageConfig as S, UniversalFileService as U, type UniversalFileServiceConfig as a, type StorageType as b, type UploadFileInfo as c, type StorageResult as d, type ICDNProvider as e, type CDNConfig as f, type CDNResult as g, type IFileProcessor as h, type ProcessingOptions as i, type ProcessingResult as j, type IFileMetadataRepository as k, type AliyunCDNConfig as l, type CacheConfig as m, type StorageMetadata as n, type CDNStats as o, type ProcessorInfo as p, type FileRecord as q, type FileQueryOptions as r, type PaginatedResult as s, type FileEvent as t, type FileEventListener as u, type FileEventType as v, FileServiceError as w, FileUploadError as x, FileProcessingError as y, StorageProviderError as z };
@@ -1,261 +1,5 @@
1
1
  import { EventEmitter } from 'events';
2
-
3
- /**
4
- * 通用文件服务类型定义
5
- *
6
- * 定义了文件存储、上传、下载等核心接口和类型
7
- */
8
- /** 文件存储类型 */
9
- type StorageType$1 = 'local' | 'aliyun-oss' | 'aws-s3' | 'qcloud-cos';
10
- /** CDN提供者类型 */
11
- type CDNType$1 = 'none' | 'aliyun-cdn' | 'aws-cloudfront' | 'qcloud-cdn';
12
- /** 文件处理类型 */
13
- type ProcessorType$1 = 'image' | 'audio' | 'video' | 'document';
14
- /** 文件上传状态 */
15
- type UploadStatus = 'pending' | 'uploading' | 'processing' | 'completed' | 'failed';
16
- /** 访问权限类型 */
17
- type AccessPermission = 'public' | 'private' | 'authenticated' | 'owner-only';
18
- /** 文件元数据基础接口 */
19
- interface FileMetadata {
20
- /** 文件ID */
21
- id: string;
22
- /** 原始文件名 */
23
- originalName: string;
24
- /** 存储文件名 */
25
- storageName: string;
26
- /** 文件大小(字节) */
27
- size: number;
28
- /** MIME类型 */
29
- mimeType: string;
30
- /** 文件扩展名 */
31
- extension: string;
32
- /** 文件哈希值 */
33
- hash?: string;
34
- /** 上传时间 */
35
- uploadTime: Date;
36
- /** 访问权限 */
37
- permission: AccessPermission;
38
- /** 上传者ID */
39
- uploaderId: string;
40
- /** 模块标识 */
41
- moduleId: string;
42
- /** 业务标识 */
43
- businessId?: string;
44
- /** 存储提供者 */
45
- storageProvider: StorageType$1;
46
- /** 存储路径 */
47
- storagePath: string;
48
- /** CDN URL */
49
- cdnUrl?: string;
50
- /** 访问次数 */
51
- accessCount: number;
52
- /** 最后访问时间 */
53
- lastAccessTime?: Date;
54
- /** 过期时间 */
55
- expiresAt?: Date;
56
- /** 自定义元数据 */
57
- metadata?: Record<string, any>;
58
- }
59
- /** 上传文件信息(客户端使用) */
60
- interface UploadFileInfo$1 {
61
- /** 文件对象 */
62
- file: File;
63
- /** 模块标识 */
64
- moduleId: string;
65
- /** 业务标识 */
66
- businessId?: string;
67
- /** 访问权限 */
68
- permission?: AccessPermission;
69
- /** 自定义存储路径 */
70
- customPath?: string;
71
- /** 自定义元数据 */
72
- metadata?: Record<string, any>;
73
- /** 是否需要处理 */
74
- needsProcessing?: boolean;
75
- /** 处理选项 */
76
- processingOptions?: ProcessingOptions$1;
77
- }
78
- /** 文件处理选项基础接口 */
79
- interface ProcessingOptions$1 {
80
- /** 处理器类型 */
81
- type: ProcessorType$1;
82
- /** 处理参数 */
83
- params?: Record<string, any>;
84
- }
85
- /** 图片处理选项 */
86
- interface ImageProcessingOptions extends ProcessingOptions$1 {
87
- type: 'image';
88
- /** 压缩质量 0-100 */
89
- quality?: number;
90
- /** 目标宽度 */
91
- width?: number;
92
- /** 目标高度 */
93
- height?: number;
94
- /** 格式转换 */
95
- format?: 'jpeg' | 'png' | 'webp' | 'avif';
96
- /** 是否添加水印 */
97
- watermark?: boolean;
98
- /** 水印配置 */
99
- watermarkOptions?: {
100
- text?: string;
101
- image?: string;
102
- position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
103
- opacity?: number;
104
- };
105
- }
106
- /** 音频处理选项 */
107
- interface AudioProcessingOptions extends ProcessingOptions$1 {
108
- type: 'audio';
109
- /** 比特率 */
110
- bitrate?: number;
111
- /** 格式转换 */
112
- format?: 'mp3' | 'wav' | 'ogg' | 'aac';
113
- /** 采样率 */
114
- sampleRate?: number;
115
- /** 声道数 */
116
- channels?: number;
117
- }
118
- /** 视频处理选项 */
119
- interface VideoProcessingOptions extends ProcessingOptions$1 {
120
- type: 'video';
121
- /** 视频质量 */
122
- quality?: number;
123
- /** 格式转换 */
124
- format?: 'mp4' | 'avi' | 'mov' | 'webm';
125
- /** 生成缩略图 */
126
- generateThumbnail?: boolean;
127
- /** 缩略图时间点(秒) */
128
- thumbnailTime?: number;
129
- }
130
- /** 上传进度 */
131
- interface UploadProgress {
132
- /** 文件ID */
133
- fileId: string;
134
- /** 上传状态 */
135
- status: UploadStatus;
136
- /** 进度百分比(0-100) */
137
- progress: number;
138
- /** 已上传字节数 */
139
- uploadedBytes: number;
140
- /** 总字节数 */
141
- totalBytes: number;
142
- /** 上传速度(字节/秒) */
143
- speed: number;
144
- /** 剩余时间(秒) */
145
- remainingTime: number;
146
- /** 错误信息 */
147
- error?: string;
148
- }
149
- /** 上传结果 */
150
- interface UploadResult {
151
- /** 是否成功 */
152
- success: boolean;
153
- /** 文件元数据 */
154
- file?: FileMetadata;
155
- /** 文件访问URL */
156
- url?: string;
157
- /** 错误信息 */
158
- error?: string;
159
- }
160
- /** 文件查询选项 */
161
- interface FileQueryOptions$1 {
162
- /** 模块标识 */
163
- moduleId?: string;
164
- /** 业务标识 */
165
- businessId?: string;
166
- /** 上传者ID */
167
- uploaderId?: string;
168
- /** MIME类型过滤 */
169
- mimeType?: string;
170
- /** 最小文件大小 */
171
- minSize?: number;
172
- /** 最大文件大小 */
173
- maxSize?: number;
174
- /** 开始时间 */
175
- startTime?: Date;
176
- /** 结束时间 */
177
- endTime?: Date;
178
- /** 搜索关键词 */
179
- keyword?: string;
180
- /** 标签 */
181
- tags?: string[];
182
- /** 排序字段 */
183
- sortBy?: string;
184
- /** 排序方向 */
185
- sortOrder?: 'asc' | 'desc';
186
- /** 页码 */
187
- page?: number;
188
- /** 每页数量 */
189
- pageSize?: number;
190
- }
191
- /** 分页结果 */
192
- interface PaginatedResult$1<T> {
193
- /** 数据项 */
194
- items: T[];
195
- /** 总数 */
196
- total: number;
197
- /** 当前页码 */
198
- page: number;
199
- /** 每页数量 */
200
- pageSize: number;
201
- /** 总页数 */
202
- totalPages: number;
203
- /** 是否有下一页 */
204
- hasNext: boolean;
205
- /** 是否有上一页 */
206
- hasPrev: boolean;
207
- }
208
- /** 批量操作结果 */
209
- interface BatchOperationResult {
210
- /** 成功数量 */
211
- successCount: number;
212
- /** 失败数量 */
213
- failureCount: number;
214
- /** 失败详情 */
215
- failures: Array<{
216
- fileId: string;
217
- error: string;
218
- }>;
219
- }
220
- /** 文件事件类型 */
221
- type FileEventType$1 = 'upload:start' | 'upload:progress' | 'upload:complete' | 'upload:error' | 'download:start' | 'download:complete' | 'download:error' | 'delete:complete' | 'processing:start' | 'processing:complete' | 'processing:error';
222
- /** 文件事件 */
223
- interface FileEvent$1 {
224
- /** 事件类型 */
225
- type: FileEventType$1;
226
- /** 文件ID */
227
- fileId: string;
228
- /** 事件时间 */
229
- timestamp: Date;
230
- /** 事件数据 */
231
- data?: Record<string, any>;
232
- /** 错误信息 */
233
- error?: string;
234
- }
235
- /** 文件事件监听器 */
236
- type FileEventListener$1 = (event: FileEvent$1) => void | Promise<void>;
237
- /** 文件服务基础异常 */
238
- declare class FileServiceError$1 extends Error {
239
- readonly code: string;
240
- readonly details?: Record<string, any> | undefined;
241
- constructor(message: string, code: string, details?: Record<string, any> | undefined);
242
- }
243
- /** 文件上传错误 */
244
- declare class FileUploadError$1 extends FileServiceError$1 {
245
- constructor(message: string, details?: Record<string, any>);
246
- }
247
- /** 文件处理错误 */
248
- declare class FileProcessingError$1 extends FileServiceError$1 {
249
- constructor(message: string, details?: Record<string, any>);
250
- }
251
- /** 存储提供者错误 */
252
- declare class StorageProviderError$1 extends FileServiceError$1 {
253
- constructor(message: string, details?: Record<string, any>);
254
- }
255
- /** CDN提供者错误 */
256
- declare class CDNProviderError$1 extends FileServiceError$1 {
257
- constructor(message: string, details?: Record<string, any>);
258
- }
2
+ import { S as StorageType$1, C as CDNType$1, F as FileMetadata, A as AccessPermission, U as UploadStatus, P as ProcessorType$1, a as UploadFileInfo$1, b as ProcessingOptions$1, c as UploadProgress, d as FileEventListener$1 } from './types-Dg-U_chI.mjs';
259
3
 
260
4
  /**
261
5
  * UniversalFile Server 端类型定义
@@ -724,4 +468,4 @@ declare class UniversalFileService extends EventEmitter {
724
468
  private emitFileEvent;
725
469
  }
726
470
 
727
- export { type FileEventType as $, type AccessPermission as A, type BatchOperationResult as B, CDNProviderError$1 as C, type IFileProcessor as D, type ProcessorType as E, type FileMetadata as F, type ProcessingOptions as G, type ProcessingResult as H, type ImageProcessingOptions as I, type IFileMetadataRepository as J, type AliyunOSSConfig as K, type AliyunCDNConfig as L, type LocalStorageConfig as M, type FileServicePersistenceConfig as N, type CacheConfig as O, type PaginatedResult$1 as P, type StorageMetadata as Q, type CDNStats as R, StorageProviderError$1 as S, type ProcessorInfo as T, type UploadFileInfo$1 as U, type VideoProcessingOptions as V, type FileRecord as W, type FileQueryOptions as X, type PaginatedResult as Y, type FileEvent as Z, type FileEventListener as _, type UploadProgress as a, FileServiceError as a0, FileUploadError as a1, FileProcessingError as a2, StorageProviderError as a3, CDNProviderError as a4, type FileQueryOptions$1 as b, UniversalFileService as c, type ProcessingOptions$1 as d, FileServiceError$1 as e, FileUploadError$1 as f, FileProcessingError$1 as g, type StorageType$1 as h, type CDNType$1 as i, type ProcessorType$1 as j, type UploadStatus as k, type AudioProcessingOptions as l, type UploadResult as m, type FileEventType$1 as n, type FileEvent$1 as o, type FileEventListener$1 as p, type UniversalFileServiceConfig as q, type StorageConfig as r, type IStorageProvider as s, type StorageType as t, type UploadFileInfo as u, type StorageResult as v, type ICDNProvider as w, type CDNType as x, type CDNConfig as y, type CDNResult as z };
471
+ export { type AliyunOSSConfig as A, CDNProviderError as B, type CDNType as C, type FileServicePersistenceConfig as F, type IStorageProvider as I, type LocalStorageConfig as L, type ProcessorType as P, type StorageConfig as S, UniversalFileService as U, type UniversalFileServiceConfig as a, type StorageType as b, type UploadFileInfo as c, type StorageResult as d, type ICDNProvider as e, type CDNConfig as f, type CDNResult as g, type IFileProcessor as h, type ProcessingOptions as i, type ProcessingResult as j, type IFileMetadataRepository as k, type AliyunCDNConfig as l, type CacheConfig as m, type StorageMetadata as n, type CDNStats as o, type ProcessorInfo as p, type FileRecord as q, type FileQueryOptions as r, type PaginatedResult as s, type FileEvent as t, type FileEventListener as u, type FileEventType as v, FileServiceError as w, FileUploadError as x, FileProcessingError as y, StorageProviderError as z };