@dofe/infra-shared-services 0.1.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.
Files changed (153) hide show
  1. package/dist/email/dto/email.dto.d.ts +70 -0
  2. package/dist/email/dto/email.dto.d.ts.map +1 -0
  3. package/dist/email/dto/email.dto.js +58 -0
  4. package/dist/email/dto/email.dto.js.map +1 -0
  5. package/dist/email/email.module.d.ts +3 -0
  6. package/dist/email/email.module.d.ts.map +1 -0
  7. package/dist/email/email.module.js +38 -0
  8. package/dist/email/email.module.js.map +1 -0
  9. package/dist/email/email.service.d.ts +61 -0
  10. package/dist/email/email.service.d.ts.map +1 -0
  11. package/dist/email/email.service.js +191 -0
  12. package/dist/email/email.service.js.map +1 -0
  13. package/dist/email/index.d.ts +5 -0
  14. package/dist/email/index.d.ts.map +1 -0
  15. package/dist/email/index.js +26 -0
  16. package/dist/email/index.js.map +1 -0
  17. package/dist/file-storage/bucket-resolver.d.ts +174 -0
  18. package/dist/file-storage/bucket-resolver.d.ts.map +1 -0
  19. package/dist/file-storage/bucket-resolver.js +270 -0
  20. package/dist/file-storage/bucket-resolver.js.map +1 -0
  21. package/dist/file-storage/file-storage.factory.d.ts +183 -0
  22. package/dist/file-storage/file-storage.factory.d.ts.map +1 -0
  23. package/dist/file-storage/file-storage.factory.js +300 -0
  24. package/dist/file-storage/file-storage.factory.js.map +1 -0
  25. package/dist/file-storage/file-storage.module.d.ts +49 -0
  26. package/dist/file-storage/file-storage.module.d.ts.map +1 -0
  27. package/dist/file-storage/file-storage.module.js +74 -0
  28. package/dist/file-storage/file-storage.module.js.map +1 -0
  29. package/dist/file-storage/file-storage.service.d.ts +381 -0
  30. package/dist/file-storage/file-storage.service.d.ts.map +1 -0
  31. package/dist/file-storage/file-storage.service.js +598 -0
  32. package/dist/file-storage/file-storage.service.js.map +1 -0
  33. package/dist/file-storage/index.d.ts +43 -0
  34. package/dist/file-storage/index.d.ts.map +1 -0
  35. package/dist/file-storage/index.js +65 -0
  36. package/dist/file-storage/index.js.map +1 -0
  37. package/dist/file-storage/types.d.ts +187 -0
  38. package/dist/file-storage/types.d.ts.map +1 -0
  39. package/dist/file-storage/types.js +21 -0
  40. package/dist/file-storage/types.js.map +1 -0
  41. package/dist/index.d.ts +20 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +35 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/ip-geo/continent-mapping.d.ts +31 -0
  46. package/dist/ip-geo/continent-mapping.d.ts.map +1 -0
  47. package/dist/ip-geo/continent-mapping.js +246 -0
  48. package/dist/ip-geo/continent-mapping.js.map +1 -0
  49. package/dist/ip-geo/index.d.ts +33 -0
  50. package/dist/ip-geo/index.d.ts.map +1 -0
  51. package/dist/ip-geo/index.js +41 -0
  52. package/dist/ip-geo/index.js.map +1 -0
  53. package/dist/ip-geo/ip-geo.module.d.ts +8 -0
  54. package/dist/ip-geo/ip-geo.module.d.ts.map +1 -0
  55. package/dist/ip-geo/ip-geo.module.js +34 -0
  56. package/dist/ip-geo/ip-geo.module.js.map +1 -0
  57. package/dist/ip-geo/ip-geo.service.d.ts +43 -0
  58. package/dist/ip-geo/ip-geo.service.d.ts.map +1 -0
  59. package/dist/ip-geo/ip-geo.service.js +153 -0
  60. package/dist/ip-geo/ip-geo.service.js.map +1 -0
  61. package/dist/ip-info/index.d.ts +7 -0
  62. package/dist/ip-info/index.d.ts.map +1 -0
  63. package/dist/ip-info/index.js +13 -0
  64. package/dist/ip-info/index.js.map +1 -0
  65. package/dist/ip-info/ip-info.client.d.ts +32 -0
  66. package/dist/ip-info/ip-info.client.d.ts.map +1 -0
  67. package/dist/ip-info/ip-info.client.js +73 -0
  68. package/dist/ip-info/ip-info.client.js.map +1 -0
  69. package/dist/ip-info/ip-info.module.d.ts +3 -0
  70. package/dist/ip-info/ip-info.module.d.ts.map +1 -0
  71. package/dist/ip-info/ip-info.module.js +45 -0
  72. package/dist/ip-info/ip-info.module.js.map +1 -0
  73. package/dist/ip-info/ip-info.service.d.ts +50 -0
  74. package/dist/ip-info/ip-info.service.d.ts.map +1 -0
  75. package/dist/ip-info/ip-info.service.js +177 -0
  76. package/dist/ip-info/ip-info.service.js.map +1 -0
  77. package/dist/ocr/index.d.ts +33 -0
  78. package/dist/ocr/index.d.ts.map +1 -0
  79. package/dist/ocr/index.js +53 -0
  80. package/dist/ocr/index.js.map +1 -0
  81. package/dist/ocr/ocr.module.d.ts +41 -0
  82. package/dist/ocr/ocr.module.d.ts.map +1 -0
  83. package/dist/ocr/ocr.module.js +61 -0
  84. package/dist/ocr/ocr.module.js.map +1 -0
  85. package/dist/ocr/ocr.service.d.ts +111 -0
  86. package/dist/ocr/ocr.service.d.ts.map +1 -0
  87. package/dist/ocr/ocr.service.js +214 -0
  88. package/dist/ocr/ocr.service.js.map +1 -0
  89. package/dist/sms/index.d.ts +5 -0
  90. package/dist/sms/index.d.ts.map +1 -0
  91. package/dist/sms/index.js +29 -0
  92. package/dist/sms/index.js.map +1 -0
  93. package/dist/sms/sms.factory.d.ts +140 -0
  94. package/dist/sms/sms.factory.d.ts.map +1 -0
  95. package/dist/sms/sms.factory.js +276 -0
  96. package/dist/sms/sms.factory.js.map +1 -0
  97. package/dist/sms/sms.module.d.ts +3 -0
  98. package/dist/sms/sms.module.d.ts.map +1 -0
  99. package/dist/sms/sms.module.js +38 -0
  100. package/dist/sms/sms.module.js.map +1 -0
  101. package/dist/sms/sms.service.d.ts +139 -0
  102. package/dist/sms/sms.service.d.ts.map +1 -0
  103. package/dist/sms/sms.service.js +278 -0
  104. package/dist/sms/sms.service.js.map +1 -0
  105. package/dist/sms/types.d.ts +204 -0
  106. package/dist/sms/types.d.ts.map +1 -0
  107. package/dist/sms/types.js +44 -0
  108. package/dist/sms/types.js.map +1 -0
  109. package/dist/streaming-asr/index.d.ts +45 -0
  110. package/dist/streaming-asr/index.d.ts.map +1 -0
  111. package/dist/streaming-asr/index.js +66 -0
  112. package/dist/streaming-asr/index.js.map +1 -0
  113. package/dist/streaming-asr/streaming-asr.module.d.ts +37 -0
  114. package/dist/streaming-asr/streaming-asr.module.d.ts.map +1 -0
  115. package/dist/streaming-asr/streaming-asr.module.js +59 -0
  116. package/dist/streaming-asr/streaming-asr.module.js.map +1 -0
  117. package/dist/streaming-asr/streaming-asr.service.d.ts +276 -0
  118. package/dist/streaming-asr/streaming-asr.service.d.ts.map +1 -0
  119. package/dist/streaming-asr/streaming-asr.service.js +1120 -0
  120. package/dist/streaming-asr/streaming-asr.service.js.map +1 -0
  121. package/dist/streaming-asr/types.d.ts +194 -0
  122. package/dist/streaming-asr/types.d.ts.map +1 -0
  123. package/dist/streaming-asr/types.js +8 -0
  124. package/dist/streaming-asr/types.js.map +1 -0
  125. package/dist/system-health/index.d.ts +7 -0
  126. package/dist/system-health/index.d.ts.map +1 -0
  127. package/dist/system-health/index.js +25 -0
  128. package/dist/system-health/index.js.map +1 -0
  129. package/dist/system-health/system-health.controller.d.ts +43 -0
  130. package/dist/system-health/system-health.controller.d.ts.map +1 -0
  131. package/dist/system-health/system-health.controller.js +86 -0
  132. package/dist/system-health/system-health.controller.js.map +1 -0
  133. package/dist/system-health/system-health.module.d.ts +3 -0
  134. package/dist/system-health/system-health.module.d.ts.map +1 -0
  135. package/dist/system-health/system-health.module.js +29 -0
  136. package/dist/system-health/system-health.module.js.map +1 -0
  137. package/dist/system-health/system-health.service.d.ts +14 -0
  138. package/dist/system-health/system-health.service.d.ts.map +1 -0
  139. package/dist/system-health/system-health.service.js +87 -0
  140. package/dist/system-health/system-health.service.js.map +1 -0
  141. package/dist/uploader/index.d.ts +3 -0
  142. package/dist/uploader/index.d.ts.map +1 -0
  143. package/dist/uploader/index.js +8 -0
  144. package/dist/uploader/index.js.map +1 -0
  145. package/dist/uploader/uploader.module.d.ts +3 -0
  146. package/dist/uploader/uploader.module.d.ts.map +1 -0
  147. package/dist/uploader/uploader.module.js +25 -0
  148. package/dist/uploader/uploader.module.js.map +1 -0
  149. package/dist/uploader/uploader.service.d.ts +86 -0
  150. package/dist/uploader/uploader.service.d.ts.map +1 -0
  151. package/dist/uploader/uploader.service.js +188 -0
  152. package/dist/uploader/uploader.service.js.map +1 -0
  153. package/package.json +51 -0
@@ -0,0 +1,598 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview 文件存储服务
4
+ *
5
+ * 本文件是文件存储服务的统一入口(Facade 模式),提供了简洁的 API 接口。
6
+ *
7
+ * 架构说明:
8
+ * ```
9
+ * ┌─────────────────────────────────────────────────────────────┐
10
+ * │ FileStorageService │
11
+ * │ (Facade 门面) │
12
+ * │ - 提供统一的文件操作 API │
13
+ * │ - 处理业务逻辑和参数验证 │
14
+ * └─────────────────────────────┬───────────────────────────────┘
15
+ * │
16
+ * ┌───────────────────┼───────────────────┐
17
+ * │ │ │
18
+ * ▼ ▼ ▼
19
+ * ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
20
+ * │ BucketResolver │ │ ClientFactory │ │ Storage Clients │
21
+ * │ (存储桶解析) │ │ (客户端工厂) │ │ (具体客户端) │
22
+ * └─────────────────┘ └─────────────────┘ └─────────────────┘
23
+ * ```
24
+ *
25
+ * @module file-storage/service
26
+ */
27
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
28
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ };
33
+ var __metadata = (this && this.__metadata) || function (k, v) {
34
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
35
+ };
36
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
37
+ return function (target, key) { decorator(target, key, paramIndex); }
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.FileStorageService = void 0;
41
+ const common_1 = require("@nestjs/common");
42
+ const nest_winston_1 = require("nest-winston");
43
+ const winston_1 = require("winston");
44
+ const infra_contracts_1 = require("@dofe/infra-contracts");
45
+ const infra_common_1 = require("@dofe/infra-common");
46
+ const file_storage_factory_1 = require("./file-storage.factory");
47
+ const bucket_resolver_1 = require("./bucket-resolver");
48
+ /**
49
+ * 文件存储服务
50
+ *
51
+ * @description 作为文件存储的统一门面,提供以下核心功能:
52
+ *
53
+ * **文件操作**
54
+ * - `uploadFile` - 上传文件
55
+ * - `deleteFile` / `batchDeleteFiles` - 删除文件
56
+ * - `copyFile` - 复制文件
57
+ * - `fetchToBucket` - 从 URL 抓取文件到存储桶
58
+ *
59
+ * **访问控制**
60
+ * - `uploadToken` / `uploadTokenWithCallback` - 获取上传凭证
61
+ * - `getPresignedUrl` - 获取预签名 URL
62
+ * - `getPrivateDownloadUrl` - 获取私有下载链接
63
+ *
64
+ * **分片上传**
65
+ * - `getMultipartUploadId` - 初始化分片上传
66
+ * - `completeMultipartUpload` - 完成分片上传
67
+ *
68
+ * **媒体处理**
69
+ * - `getSnapshot` - 视频截图
70
+ * - `getVideoInfo` / `getImageInfo` / `getAudioInfo` - 获取媒体信息
71
+ *
72
+ * @class FileStorageService
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // 注入服务
77
+ * @Injectable()
78
+ * class VideoService {
79
+ * constructor(private readonly fileStorage: FileStorageService) {}
80
+ *
81
+ * // 上传文件
82
+ * async upload(file: Buffer, key: string) {
83
+ * const client = await this.fileStorage.getFileClient('oss', 'my-bucket');
84
+ * await client.fileUploader(file, { key, bucket: 'my-bucket' });
85
+ * }
86
+ *
87
+ * // 获取私有下载链接
88
+ * async getDownloadUrl(key: string) {
89
+ * return await this.fileStorage.getPrivateDownloadUrl(
90
+ * 'oss', 'my-bucket', key, { expire: 3600 }
91
+ * );
92
+ * }
93
+ * }
94
+ * ```
95
+ */
96
+ let FileStorageService = class FileStorageService {
97
+ clientFactory;
98
+ bucketResolver;
99
+ logger;
100
+ /**
101
+ * 构造函数
102
+ *
103
+ * @param {FileStorageClientFactory} clientFactory - 客户端工厂
104
+ * @param {BucketResolver} bucketResolver - 存储桶解析器
105
+ * @param {Logger} logger - Winston 日志记录器
106
+ */
107
+ constructor(clientFactory, bucketResolver, logger) {
108
+ this.clientFactory = clientFactory;
109
+ this.bucketResolver = bucketResolver;
110
+ this.logger = logger;
111
+ }
112
+ // =========================================================================
113
+ // 客户端获取
114
+ // =========================================================================
115
+ /**
116
+ * 获取文件存储客户端
117
+ *
118
+ * @description 根据供应商和存储桶获取对应的存储客户端。
119
+ * 支持根据 IP 地址自动选择区域最优的存储桶。
120
+ *
121
+ * @param {FileBucketVendor} [vendor] - 存储供应商
122
+ * @param {string} [bucket] - 存储桶名称
123
+ * @param {string} [ip] - 客户端 IP(用于区域感知)
124
+ * @param {boolean} [isPublic] - 是否公开存储桶
125
+ * @param {string} [locale] - 区域设置
126
+ * @returns {Promise<FileStorageInterface>} 存储客户端
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * // 获取指定存储桶的客户端
131
+ * const client = await service.getFileClient('oss', 'my-bucket');
132
+ *
133
+ * // 根据 IP 自动选择最优存储桶
134
+ * const client = await service.getFileClient(undefined, undefined, '8.8.8.8');
135
+ * ```
136
+ */
137
+ async getFileClient(vendor, bucket, ip, isPublic, locale) {
138
+ const resolved = await this.bucketResolver.resolve({
139
+ vendor,
140
+ bucket,
141
+ ip,
142
+ isPublic,
143
+ locale,
144
+ });
145
+ const client = this.clientFactory.getClient(resolved.vendor, resolved.bucket);
146
+ if (!client) {
147
+ throw new Error(`File storage client not available for vendor: ${resolved.vendor}, bucket: ${resolved.bucket}`);
148
+ }
149
+ return client;
150
+ }
151
+ /**
152
+ * @deprecated 使用 getFileClient 代替
153
+ */
154
+ async getFileService(vendor, bucket, ip, isPublic, locale) {
155
+ return this.getFileClient(vendor, bucket, ip, isPublic, locale);
156
+ }
157
+ // =========================================================================
158
+ // 配置获取
159
+ // =========================================================================
160
+ /**
161
+ * 获取文件服务配置
162
+ *
163
+ * @param {FileBucketVendor} [vendor] - 存储供应商
164
+ * @param {string} [bucket] - 存储桶名称
165
+ * @param {string} [ip] - 客户端 IP
166
+ * @param {boolean} [isPublic] - 是否公开
167
+ * @param {string} [locale] - 区域设置
168
+ * @returns {Promise<PardxUploader.Config>} 存储桶配置
169
+ */
170
+ async getFileServiceConfig(vendor, bucket, ip, isPublic, locale) {
171
+ const client = await this.getFileClient(vendor, bucket, ip, isPublic, locale);
172
+ if (!client) {
173
+ throw new Error(`File service not available for vendor: ${vendor}, bucket: ${bucket}`);
174
+ }
175
+ return client.getConfig();
176
+ }
177
+ /**
178
+ * 根据存储桶获取供应商
179
+ *
180
+ * @param {string} bucket - 存储桶名称
181
+ * @param {FileBucketVendor} [vendor] - 默认供应商
182
+ * @returns {FileBucketVendor} 供应商类型
183
+ */
184
+ getFileVendorByBucket(bucket, vendor) {
185
+ return (this.bucketResolver.getVendorForBucket(bucket) ??
186
+ vendor ??
187
+ this.clientFactory.getDefaultVendor());
188
+ }
189
+ // =========================================================================
190
+ // 存储桶操作
191
+ // =========================================================================
192
+ /**
193
+ * 获取存储桶字符串
194
+ *
195
+ * @param {string} [bucket] - 存储桶名称
196
+ * @param {string} [ip] - 客户端 IP
197
+ * @param {boolean} [isPublic] - 是否公开
198
+ * @param {string} [locale] - 区域设置
199
+ * @param {FileBucketVendor} [vendor] - 存储供应商
200
+ * @returns {Promise<string>} 解析后的存储桶名称
201
+ */
202
+ async getBucketString(bucket, ip, isPublic, locale, vendor) {
203
+ const resolved = await this.bucketResolver.resolve({
204
+ bucket,
205
+ ip,
206
+ isPublic,
207
+ locale,
208
+ vendor,
209
+ });
210
+ return resolved.bucket;
211
+ }
212
+ /**
213
+ * 获取默认存储桶
214
+ *
215
+ * @param {boolean} [isPublic] - 是否公开
216
+ * @param {string} [ip] - 客户端 IP
217
+ * @param {string} [locale] - 区域设置
218
+ * @returns {Promise<string>} 默认存储桶名称
219
+ */
220
+ async getDefaultBucket(isPublic, ip, locale) {
221
+ return this.bucketResolver.resolveDefaultBucket(isPublic, ip, locale);
222
+ }
223
+ /**
224
+ * @deprecated 使用 getDefaultBucket 代替
225
+ */
226
+ async getDefauleBucket(isPublic, ip, locale) {
227
+ return this.getDefaultBucket(isPublic, ip, locale);
228
+ }
229
+ /**
230
+ * 检查存储桶是否有效
231
+ *
232
+ * @param {FileBucketVendor} vendor - 存储供应商
233
+ * @param {string} bucket - 存储桶名称
234
+ * @returns {boolean} 是否有效
235
+ */
236
+ checkBucketValidate(vendor, bucket) {
237
+ return this.bucketResolver.validateBucket(vendor, bucket);
238
+ }
239
+ /**
240
+ * 格式化新的文件键
241
+ *
242
+ * @param {string} root - 根路径
243
+ * @param {string} ext - 文件扩展名
244
+ * @param {string} [bucket] - 存储桶名称
245
+ * @param {string} [ip] - 客户端 IP
246
+ * @param {boolean} [isPublic] - 是否公开
247
+ * @param {string} [locale] - 区域设置
248
+ * @returns {Promise<string>} 生成的文件键
249
+ */
250
+ async formatNewKeyString(root, ext, bucket, ip, isPublic, locale) {
251
+ const finalBucket = await this.getBucketString(bucket, ip, isPublic, locale);
252
+ return this.bucketResolver.generateFileKey(root, ext, finalBucket);
253
+ }
254
+ // =========================================================================
255
+ // 文件操作
256
+ // =========================================================================
257
+ /**
258
+ * 复制文件
259
+ *
260
+ * @param {PardxApp.FileBase} source - 源文件信息
261
+ * @param {PardxApp.FileBase} destination - 目标文件信息
262
+ * @returns {Promise<void>}
263
+ */
264
+ async copyFile(source, destination) {
265
+ this.logger.info('Copying file', { source, destination });
266
+ const srcClient = await this.getFileClient(source.vendor, source.bucket);
267
+ const destClient = await this.getFileClient(destination.vendor, destination.bucket);
268
+ try {
269
+ const buffer = await srcClient.fileDownloader(source);
270
+ await destClient.fileUploader(buffer, destination);
271
+ this.logger.info('File copied successfully', {
272
+ source,
273
+ destination,
274
+ });
275
+ }
276
+ catch (error) {
277
+ this.logger.error('copyFile error', {
278
+ source,
279
+ destination,
280
+ error: error.message,
281
+ });
282
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.InternalServerError, {
283
+ message: 'copyFileToBucketError',
284
+ });
285
+ }
286
+ }
287
+ /**
288
+ * 上传文件
289
+ *
290
+ * @param {FileBucketVendor} vendor - 存储供应商
291
+ * @param {string} bucket - 存储桶名称
292
+ * @param {string} key - 文件键
293
+ * @param {string} filePath - 本地文件路径
294
+ * @returns {Promise<void>}
295
+ */
296
+ async uploadFile(vendor, bucket, key, filePath) {
297
+ const client = await this.getFileClient(vendor, bucket);
298
+ return client.uploadFile(filePath, key, bucket);
299
+ }
300
+ /**
301
+ * 上传 Base64 数据
302
+ *
303
+ * @param {FileBucketVendor} vendor - 存储供应商
304
+ * @param {string} bucket - 存储桶名称
305
+ * @param {string} key - 文件键
306
+ * @param {string} base64Data - Base64 编码的数据
307
+ * @returns {Promise<void>}
308
+ */
309
+ async fileDataUploader(vendor, bucket, key, base64Data) {
310
+ const client = await this.getFileClient(vendor, bucket);
311
+ return client.fileDataUploader(base64Data, key, bucket);
312
+ }
313
+ /**
314
+ * 上传 Buffer 数据
315
+ *
316
+ * @param {FileBucketVendor} vendor - 存储供应商
317
+ * @param {string} bucket - 存储桶名称
318
+ * @param {string} key - 文件键
319
+ * @param {Buffer} buffer - 文件数据
320
+ * @returns {Promise<void>}
321
+ */
322
+ async streamDownloader(vendor, bucket, key, buffer) {
323
+ const client = await this.getFileClient(vendor, bucket);
324
+ return client.fileUploader(buffer, { key, bucket });
325
+ }
326
+ /**
327
+ * 删除文件
328
+ *
329
+ * @param {FileBucketVendor} vendor - 存储供应商
330
+ * @param {string} bucket - 存储桶名称
331
+ * @param {string} fileKey - 文件键
332
+ * @returns {Promise<any>}
333
+ */
334
+ async deleteFile(vendor, bucket, fileKey) {
335
+ const client = await this.getFileClient(vendor, bucket);
336
+ return client.deleteFile(fileKey);
337
+ }
338
+ /**
339
+ * 批量删除文件
340
+ *
341
+ * @param {FileBucketVendor} vendor - 存储供应商
342
+ * @param {string} bucket - 存储桶名称
343
+ * @param {string[]} fileKeys - 文件键列表
344
+ * @returns {Promise<any>}
345
+ */
346
+ async batchDeleteFiles(vendor, bucket, fileKeys) {
347
+ const client = await this.getFileClient(vendor, bucket);
348
+ return client.batchDeleteFiles(fileKeys, bucket);
349
+ }
350
+ /**
351
+ * 获取文件信息
352
+ *
353
+ * @param {FileBucketVendor} vendor - 存储供应商
354
+ * @param {string} bucket - 存储桶名称
355
+ * @param {string} fileKey - 文件键
356
+ * @returns {Promise<any>}
357
+ */
358
+ async getFileInfo(vendor, bucket, fileKey) {
359
+ const client = await this.getFileClient(vendor, bucket);
360
+ return client.getFileInfo(fileKey);
361
+ }
362
+ /**
363
+ * 列出文件前缀
364
+ *
365
+ * @param {FileBucketVendor} vendor - 存储供应商
366
+ * @param {string} bucket - 存储桶名称
367
+ * @param {string} [prefix] - 前缀
368
+ * @param {number} [limit] - 限制数量
369
+ * @param {string} [delimiter] - 分隔符
370
+ * @param {any} [options] - 附加选项
371
+ * @returns {Promise<any>}
372
+ */
373
+ async listFilesPrefix(vendor, bucket, prefix, limit, delimiter, options) {
374
+ const client = await this.getFileClient(vendor, bucket);
375
+ return client.listFilesPrefix(prefix, limit, delimiter, bucket, options);
376
+ }
377
+ /**
378
+ * 从 URL 抓取文件到存储桶
379
+ *
380
+ * @param {FileBucketVendor} vendor - 存储供应商
381
+ * @param {string} bucket - 存储桶名称
382
+ * @param {string} fileKey - 目标文件键
383
+ * @param {string} resUrl - 源 URL
384
+ * @param {string} [ip] - 客户端 IP
385
+ * @returns {Promise<any>}
386
+ */
387
+ async fetchToBucket(vendor, bucket, fileKey, resUrl, ip) {
388
+ const client = await this.getFileClient(vendor, bucket, ip);
389
+ return client.fetchToBucket(resUrl, fileKey, bucket);
390
+ }
391
+ /**
392
+ * 设置文件内容处置
393
+ *
394
+ * @param {FileBucketVendor} vendor - 存储供应商
395
+ * @param {string} bucket - 存储桶名称
396
+ * @param {string} key - 文件键
397
+ * @returns {Promise<void>}
398
+ */
399
+ async setFileContentDisposition(vendor, bucket, key) {
400
+ const client = await this.getFileClient(vendor, bucket);
401
+ return client.setFileContentDisposition(key, bucket);
402
+ }
403
+ // =========================================================================
404
+ // 访问控制
405
+ // =========================================================================
406
+ /**
407
+ * 获取上传令牌
408
+ *
409
+ * @param {FileBucketVendor} [vendor] - 存储供应商
410
+ * @param {string} [bucket] - 存储桶名称
411
+ * @param {any} [options] - 附加选项
412
+ * @returns {Promise<string>} 上传令牌
413
+ */
414
+ async uploadToken(vendor, bucket, options) {
415
+ const client = await this.getFileClient(vendor, bucket);
416
+ return client.uploadToken(bucket, options);
417
+ }
418
+ /**
419
+ * 获取带回调的上传令牌
420
+ *
421
+ * @param {FileBucketVendor} vendor - 存储供应商
422
+ * @param {string} bucket - 存储桶名称
423
+ * @param {string} callbackAuthKey - 回调验证密钥
424
+ * @param {any} [options] - 附加选项
425
+ * @param {boolean} [needSplitPart] - 是否需要分片上传
426
+ * @returns {Promise<string>} 上传令牌
427
+ */
428
+ async uploadTokenWithCallback(vendor, bucket, callbackAuthKey, options, needSplitPart) {
429
+ const client = await this.getFileClient(vendor, bucket);
430
+ return client.uploadTokenWithCallback(callbackAuthKey, bucket, options, needSplitPart);
431
+ }
432
+ /**
433
+ * 获取预签名 URL
434
+ *
435
+ * @param {FileBucketVendor} vendor - 存储供应商
436
+ * @param {string} bucket - 存储桶名称
437
+ * @param {PresignedUrlOptions} [options] - 选项
438
+ * @returns {Promise<string>} 预签名 URL
439
+ */
440
+ async getPresignedUrl(vendor, bucket, options) {
441
+ const client = await this.getFileClient(vendor, bucket);
442
+ return client.getPresignedUrl(bucket, options?.uploadId, options?.key, options?.partNumber);
443
+ }
444
+ /**
445
+ * 获取私有下载 URL
446
+ *
447
+ * @param {FileBucketVendor} vendor - 存储供应商
448
+ * @param {string} bucket - 存储桶名称
449
+ * @param {string} fileKey - 文件键
450
+ * @param {PrivateDownloadOptions} [options] - 选项
451
+ * @returns {Promise<string>} 私有下载 URL
452
+ */
453
+ async getPrivateDownloadUrl(vendor, bucket, fileKey, options = {}) {
454
+ const { expire = 30, internal = false } = options;
455
+ if (!fileKey) {
456
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchKey);
457
+ }
458
+ if (!bucket || !this.checkBucketValidate(vendor, bucket)) {
459
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchBucket);
460
+ }
461
+ const client = await this.getFileClient(vendor, bucket);
462
+ return client.getPrivateDownloadUrl(fileKey, expire, internal, bucket);
463
+ }
464
+ // =========================================================================
465
+ // 分片上传
466
+ // =========================================================================
467
+ /**
468
+ * 获取分片上传 ID
469
+ *
470
+ * @param {FileBucketVendor} vendor - 存储供应商
471
+ * @param {string} bucket - 存储桶名称
472
+ * @param {string} key - 文件键
473
+ * @param {string} [ip] - 客户端 IP
474
+ * @returns {Promise<string>} 上传 ID
475
+ */
476
+ async getMultipartUploadId(vendor, bucket, key, ip) {
477
+ const client = await this.getFileClient(vendor, bucket, ip);
478
+ return client.getMultipartUploadId(key, bucket);
479
+ }
480
+ /**
481
+ * 完成分片上传
482
+ *
483
+ * @param {FileBucketVendor} vendor - 存储供应商
484
+ * @param {string} bucket - 存储桶名称
485
+ * @param {string} key - 文件键
486
+ * @param {string} uploadId - 上传 ID
487
+ * @param {MultipartPart[]} parts - 分片信息
488
+ * @returns {Promise<void>}
489
+ */
490
+ async completeMultipartUpload(vendor, bucket, key, uploadId, parts) {
491
+ if (!this.checkBucketValidate(vendor, bucket)) {
492
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchBucket);
493
+ }
494
+ const client = await this.getFileClient(vendor, bucket);
495
+ return client.completeMultipartUpload(uploadId, key, parts, bucket);
496
+ }
497
+ // =========================================================================
498
+ // 媒体处理
499
+ // =========================================================================
500
+ /**
501
+ * 获取视频截图
502
+ *
503
+ * @param {FileBucketVendor} vendor - 存储供应商
504
+ * @param {string} bucket - 存储桶名称
505
+ * @param {string} fileKey - 视频文件键
506
+ * @param {SnapshotOptions} [options] - 截图选项
507
+ * @returns {Promise<string>} 截图文件键
508
+ */
509
+ async getSnapshot(vendor, bucket, fileKey, options = {}) {
510
+ const { time = 0, width = 0, height = 0, format = 'jpg', internal = false, } = options;
511
+ if (!fileKey) {
512
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchKey);
513
+ }
514
+ if (!bucket || !this.checkBucketValidate(vendor, bucket)) {
515
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchBucket);
516
+ }
517
+ const client = await this.getFileClient(vendor, bucket);
518
+ if (!client.getSnapshot) {
519
+ throw new Error(`getSnapshot is not supported for vendor: ${vendor}, bucket: ${bucket}`);
520
+ }
521
+ return client.getSnapshot(fileKey, internal, bucket, time, width, height, format);
522
+ }
523
+ /**
524
+ * 获取视频信息
525
+ *
526
+ * @param {FileBucketVendor} vendor - 存储供应商
527
+ * @param {string} bucket - 存储桶名称
528
+ * @param {string} fileKey - 视频文件键
529
+ * @param {boolean} [internal] - 是否使用内部端点
530
+ * @returns {Promise<any>} 视频信息
531
+ */
532
+ async getVideoInfo(vendor, bucket, fileKey, internal = false) {
533
+ if (!fileKey) {
534
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchKey);
535
+ }
536
+ if (!bucket || !this.checkBucketValidate(vendor, bucket)) {
537
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchBucket);
538
+ }
539
+ const client = await this.getFileClient(vendor, bucket);
540
+ if (!client.getVideoInfo) {
541
+ throw new Error(`getVideoInfo is not supported for vendor: ${vendor}, bucket: ${bucket}`);
542
+ }
543
+ return client.getVideoInfo(fileKey, internal, bucket);
544
+ }
545
+ /**
546
+ * 获取图片信息
547
+ *
548
+ * @param {FileBucketVendor} vendor - 存储供应商
549
+ * @param {string} bucket - 存储桶名称
550
+ * @param {string} fileKey - 图片文件键
551
+ * @param {boolean} [internal] - 是否使用内部端点
552
+ * @returns {Promise<any>} 图片信息
553
+ */
554
+ async getImageInfo(vendor, bucket, fileKey, internal = false) {
555
+ if (!fileKey) {
556
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchKey);
557
+ }
558
+ if (!bucket || !this.checkBucketValidate(vendor, bucket)) {
559
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchBucket);
560
+ }
561
+ const client = await this.getFileClient(vendor, bucket);
562
+ if (!client.getImageInfo) {
563
+ throw new Error(`getImageInfo is not supported for vendor: ${vendor}, bucket: ${bucket}`);
564
+ }
565
+ return client.getImageInfo(fileKey, internal, bucket);
566
+ }
567
+ /**
568
+ * 获取音频信息
569
+ *
570
+ * @param {FileBucketVendor} vendor - 存储供应商
571
+ * @param {string} bucket - 存储桶名称
572
+ * @param {string} fileKey - 音频文件键
573
+ * @param {boolean} [internal] - 是否使用内部端点
574
+ * @returns {Promise<any>} 音频信息
575
+ */
576
+ async getAudioInfo(vendor, bucket, fileKey, internal = false) {
577
+ if (!fileKey) {
578
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchKey);
579
+ }
580
+ if (!bucket || !this.checkBucketValidate(vendor, bucket)) {
581
+ throw (0, infra_common_1.apiError)(infra_contracts_1.CommonErrorCode.S3NoSuchBucket);
582
+ }
583
+ const client = await this.getFileClient(vendor, bucket);
584
+ if (!client.getAudioInfo) {
585
+ throw new Error(`getAudioInfo is not supported for vendor: ${vendor}, bucket: ${bucket}`);
586
+ }
587
+ return client.getAudioInfo(fileKey, internal, bucket);
588
+ }
589
+ };
590
+ exports.FileStorageService = FileStorageService;
591
+ exports.FileStorageService = FileStorageService = __decorate([
592
+ (0, common_1.Injectable)(),
593
+ __param(2, (0, common_1.Inject)(nest_winston_1.WINSTON_MODULE_PROVIDER)),
594
+ __metadata("design:paramtypes", [file_storage_factory_1.FileStorageClientFactory,
595
+ bucket_resolver_1.BucketResolver,
596
+ winston_1.Logger])
597
+ ], FileStorageService);
598
+ //# sourceMappingURL=file-storage.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-storage.service.js","sourceRoot":"","sources":["../../src/file-storage/file-storage.service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;AAEH,2CAAoD;AACpD,+CAAuD;AACvD,qCAAiC;AAQjC,2DAAwD;AACxD,qDAA8C;AAE9C,iEAAkE;AAClE,uDAAmD;AAQnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IASV;IACA;IACiC;IAVpD;;;;;;OAMG;IACH,YACmB,aAAuC,EACvC,cAA8B,EACG,MAAc;QAF/C,kBAAa,GAAb,aAAa,CAA0B;QACvC,mBAAc,GAAd,cAAc,CAAgB;QACG,WAAM,GAAN,MAAM,CAAQ;IAC/D,CAAC;IAEJ,4EAA4E;IAC5E,QAAQ;IACR,4EAA4E;IAE5E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,aAAa,CACjB,MAAyB,EACzB,MAAe,EACf,EAAW,EACX,QAAkB,EAClB,MAAe;QAEf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YACjD,MAAM;YACN,MAAM;YACN,EAAE;YACF,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CACzC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,MAAM,CAChB,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,iDAAiD,QAAQ,CAAC,MAAM,aAAa,QAAQ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EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,6CAA6C,MAAM,aAAa,MAAM,EAAE,CACzE,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAChB,MAAwB,EACxB,MAAc,EACd,OAAe,EACf,WAAoB,KAAK;QAEzB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAA,uBAAQ,EAAC,iCAAe,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YACzD,MAAM,IAAA,uBAAQ,EAAC,iCAAe,CAAC,cAAc,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAExD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,6CAA6C,MAAM,aAAa,MAAM,EAAE,CACzE,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AA5uBY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAYR,WAAA,IAAA,eAAM,EAAC,sCAAuB,CAAC,CAAA;qCAFA,+CAAwB;QACvB,gCAAc;QACW,gBAAM;GAXvD,kBAAkB,CA4uB9B"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview 文件存储服务导出
3
+ *
4
+ * 本模块提供多云存储供应商文件存储能力的统一封装。
5
+ *
6
+ * 支持的存储供应商:
7
+ * - AWS S3 兼容存储
8
+ * - 阿里云 OSS
9
+ * - 火山引擎 TOS
10
+ * - UCloud US3
11
+ * - Google Cloud Storage
12
+ * - 七牛云存储
13
+ *
14
+ * @module file-storage
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // 导入模块
19
+ * import {
20
+ * FileStorageServiceModule,
21
+ * FileStorageService,
22
+ * } from '@dofe/infra-shared-services';
23
+ *
24
+ * // 在 NestJS 模块中使用
25
+ * @Module({
26
+ * imports: [FileStorageServiceModule],
27
+ * })
28
+ * export class MyModule {}
29
+ *
30
+ * // 在服务中注入使用
31
+ * @Injectable()
32
+ * class MyService {
33
+ * constructor(private readonly fileStorage: FileStorageService) {}
34
+ * }
35
+ * ```
36
+ */
37
+ export { FileStorageServiceModule } from './file-storage.module';
38
+ export * from './file-storage.service';
39
+ export * from './file-storage.factory';
40
+ export * from './bucket-resolver';
41
+ export * from './types';
42
+ export { PardxUploader, FileStorageInterface, } from '@dofe/infra-clients';
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file-storage/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,cAAc,wBAAwB,CAAC;AAGvC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}