@nest-omni/core 4.1.3-2 → 4.1.3-20

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 (386) hide show
  1. package/audit/audit.module.d.ts +10 -0
  2. package/audit/audit.module.js +63 -1
  3. package/audit/controllers/audit.controller.d.ts +88 -0
  4. package/audit/controllers/audit.controller.js +74 -0
  5. package/audit/decorators/audit-action.decorator.d.ts +74 -0
  6. package/audit/decorators/audit-action.decorator.js +42 -0
  7. package/audit/decorators/audit-controller.decorator.d.ts +9 -1
  8. package/audit/decorators/audit-controller.decorator.js +11 -2
  9. package/audit/decorators/audit-operation.decorator.d.ts +45 -0
  10. package/audit/decorators/audit-operation.decorator.js +49 -0
  11. package/audit/decorators/entity-audit.decorator.d.ts +85 -1
  12. package/audit/decorators/entity-audit.decorator.js +153 -3
  13. package/audit/decorators/index.d.ts +2 -0
  14. package/audit/decorators/index.js +2 -0
  15. package/audit/dto/audit-log-query.dto.d.ts +3 -0
  16. package/audit/dto/audit-log-query.dto.js +3 -0
  17. package/audit/dto/begin-transaction.dto.d.ts +3 -0
  18. package/audit/dto/begin-transaction.dto.js +3 -0
  19. package/audit/dto/compare-entities.dto.d.ts +3 -0
  20. package/audit/dto/compare-entities.dto.js +3 -0
  21. package/audit/dto/pre-check-restore.dto.d.ts +3 -0
  22. package/audit/dto/pre-check-restore.dto.js +3 -0
  23. package/audit/dto/restore-entity.dto.d.ts +3 -0
  24. package/audit/dto/restore-entity.dto.js +3 -0
  25. package/audit/entities/audit-action-summary.entity.d.ts +23 -0
  26. package/audit/entities/audit-action-summary.entity.js +101 -0
  27. package/audit/entities/entity-audit-log.entity.d.ts +11 -0
  28. package/audit/entities/entity-audit-log.entity.js +57 -2
  29. package/audit/entities/entity-transaction.entity.d.ts +11 -2
  30. package/audit/entities/entity-transaction.entity.js +42 -3
  31. package/audit/entities/index.d.ts +3 -0
  32. package/audit/entities/index.js +3 -0
  33. package/audit/entities/manual-operation-log.entity.d.ts +4 -0
  34. package/audit/entities/manual-operation-log.entity.js +12 -1
  35. package/audit/entities/operation-template.entity.d.ts +4 -0
  36. package/audit/entities/operation-template.entity.js +4 -0
  37. package/audit/enums/audit.enums.d.ts +37 -6
  38. package/audit/enums/audit.enums.js +40 -7
  39. package/audit/index.d.ts +4 -1
  40. package/audit/index.js +34 -1
  41. package/audit/interceptors/audit-action.interceptor.d.ts +38 -0
  42. package/audit/interceptors/audit-action.interceptor.js +215 -0
  43. package/audit/interceptors/audit.interceptor.d.ts +15 -0
  44. package/audit/interceptors/audit.interceptor.js +23 -1
  45. package/audit/interceptors/index.d.ts +1 -0
  46. package/audit/interceptors/index.js +1 -0
  47. package/audit/interfaces/audit.interfaces.d.ts +187 -2
  48. package/audit/services/audit-action.service.d.ts +141 -0
  49. package/audit/services/audit-action.service.js +244 -0
  50. package/audit/services/audit-context.service.d.ts +97 -0
  51. package/audit/services/audit-context.service.js +185 -0
  52. package/audit/services/audit-strategy.service.d.ts +6 -0
  53. package/audit/services/audit-strategy.service.js +13 -0
  54. package/audit/services/entity-audit.service.d.ts +230 -3
  55. package/audit/services/entity-audit.service.js +607 -14
  56. package/audit/services/index.d.ts +3 -0
  57. package/audit/services/index.js +3 -0
  58. package/audit/services/manual-audit-log.service.d.ts +134 -9
  59. package/audit/services/manual-audit-log.service.js +157 -40
  60. package/audit/services/multi-database.service.d.ts +9 -2
  61. package/audit/services/multi-database.service.js +9 -21
  62. package/audit/services/operation-description.service.d.ts +71 -2
  63. package/audit/services/operation-description.service.js +231 -20
  64. package/audit/services/transaction-audit.service.d.ts +30 -0
  65. package/audit/services/transaction-audit.service.js +53 -5
  66. package/audit/subscribers/entity-audit.subscriber.d.ts +19 -0
  67. package/audit/subscribers/entity-audit.subscriber.js +76 -1
  68. package/cache/cache-metrics.service.d.ts +67 -0
  69. package/cache/cache-metrics.service.js +68 -4
  70. package/cache/cache-serialization.service.d.ts +31 -0
  71. package/cache/cache-serialization.service.js +25 -0
  72. package/cache/cache.constants.d.ts +9 -0
  73. package/cache/cache.constants.js +9 -0
  74. package/cache/cache.health.d.ts +26 -0
  75. package/cache/cache.health.js +30 -0
  76. package/cache/cache.module.d.ts +82 -2
  77. package/cache/cache.module.js +76 -5
  78. package/cache/cache.service.d.ts +140 -0
  79. package/cache/cache.service.js +169 -0
  80. package/cache/cache.warmup.service.d.ts +39 -0
  81. package/cache/cache.warmup.service.js +32 -0
  82. package/cache/decorators/cache-evict.decorator.d.ts +47 -0
  83. package/cache/decorators/cache-evict.decorator.js +56 -0
  84. package/cache/decorators/cache-put.decorator.d.ts +34 -0
  85. package/cache/decorators/cache-put.decorator.js +39 -0
  86. package/cache/decorators/cacheable.decorator.d.ts +40 -0
  87. package/cache/decorators/cacheable.decorator.js +55 -0
  88. package/cache/dependencies/callback.dependency.d.ts +33 -0
  89. package/cache/dependencies/callback.dependency.js +39 -1
  90. package/cache/dependencies/chain.dependency.d.ts +28 -0
  91. package/cache/dependencies/chain.dependency.js +34 -0
  92. package/cache/dependencies/db.dependency.d.ts +83 -7
  93. package/cache/dependencies/db.dependency.js +89 -14
  94. package/cache/dependencies/file.dependency.d.ts +32 -0
  95. package/cache/dependencies/file.dependency.js +34 -0
  96. package/cache/dependencies/tag.dependency.d.ts +75 -4
  97. package/cache/dependencies/tag.dependency.js +145 -11
  98. package/cache/dependencies/time.dependency.d.ts +43 -0
  99. package/cache/dependencies/time.dependency.js +43 -0
  100. package/cache/examples/basic-usage.d.ts +15 -0
  101. package/cache/examples/basic-usage.js +62 -8
  102. package/cache/index.js +9 -0
  103. package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
  104. package/cache/interfaces/cache-options.interface.d.ts +89 -0
  105. package/cache/interfaces/cache-options.interface.js +6 -0
  106. package/cache/interfaces/cache-provider.interface.d.ts +78 -0
  107. package/cache/providers/base-cache.provider.d.ts +14 -0
  108. package/cache/providers/base-cache.provider.js +16 -0
  109. package/cache/providers/cls-cache.provider.d.ts +20 -0
  110. package/cache/providers/cls-cache.provider.js +28 -0
  111. package/cache/providers/memory-cache.provider.d.ts +43 -0
  112. package/cache/providers/memory-cache.provider.js +66 -0
  113. package/cache/providers/redis-cache.provider.d.ts +26 -0
  114. package/cache/providers/redis-cache.provider.js +29 -0
  115. package/cache/utils/dependency-manager.util.d.ts +52 -0
  116. package/cache/utils/dependency-manager.util.js +59 -0
  117. package/cache/utils/key-generator.util.d.ts +42 -0
  118. package/cache/utils/key-generator.util.js +53 -1
  119. package/common/abstract.entity.d.ts +14 -0
  120. package/common/abstract.entity.js +14 -0
  121. package/common/boilerplate.polyfill.d.ts +142 -0
  122. package/common/boilerplate.polyfill.js +18 -1
  123. package/common/dto/dto-container.d.ts +16 -0
  124. package/common/dto/dto-container.js +20 -0
  125. package/common/dto/dto-decorators.d.ts +18 -0
  126. package/common/dto/dto-decorators.js +14 -0
  127. package/common/dto/dto-extensions.d.ts +11 -0
  128. package/common/dto/dto-extensions.js +9 -0
  129. package/common/dto/dto-service-accessor.d.ts +17 -0
  130. package/common/dto/dto-service-accessor.js +18 -0
  131. package/common/dto/dto-transformer.d.ts +12 -0
  132. package/common/dto/dto-transformer.js +9 -0
  133. package/common/dto/index.js +2 -0
  134. package/common/examples/paginate-and-map.example.d.ts +6 -0
  135. package/common/examples/paginate-and-map.example.js +26 -0
  136. package/common/utils.d.ts +15 -0
  137. package/common/utils.js +15 -0
  138. package/constants/language-code.js +1 -0
  139. package/decorators/field.decorators.d.ts +1 -1
  140. package/decorators/field.decorators.js +8 -1
  141. package/decorators/property.decorators.js +1 -0
  142. package/decorators/public-route.decorator.js +1 -0
  143. package/decorators/transform.decorators.d.ts +27 -0
  144. package/decorators/transform.decorators.js +29 -0
  145. package/decorators/translate.decorator.js +1 -0
  146. package/decorators/user.decorator.js +1 -0
  147. package/decorators/validator.decorators.d.ts +8 -18
  148. package/decorators/validator.decorators.js +22 -190
  149. package/file-upload/controllers/file-access.controller.d.ts +23 -0
  150. package/file-upload/controllers/file-access.controller.js +128 -0
  151. package/file-upload/decorators/column.decorator.d.ts +151 -0
  152. package/file-upload/decorators/column.decorator.js +273 -0
  153. package/file-upload/decorators/csv-data.decorator.d.ts +30 -0
  154. package/file-upload/decorators/csv-data.decorator.js +85 -0
  155. package/file-upload/decorators/csv-import.decorator.d.ts +34 -0
  156. package/file-upload/decorators/csv-import.decorator.js +24 -0
  157. package/file-upload/decorators/examples/column-mapping.example.d.ts +76 -0
  158. package/file-upload/decorators/examples/column-mapping.example.js +122 -0
  159. package/file-upload/decorators/excel-data.decorator.d.ts +30 -0
  160. package/file-upload/decorators/excel-data.decorator.js +85 -0
  161. package/file-upload/decorators/file-upload.decorator.d.ts +83 -0
  162. package/file-upload/decorators/file-upload.decorator.js +172 -0
  163. package/file-upload/decorators/index.d.ts +5 -0
  164. package/file-upload/decorators/index.js +38 -0
  165. package/file-upload/decorators/process.decorator.d.ts +40 -0
  166. package/file-upload/decorators/process.decorator.js +52 -0
  167. package/file-upload/decorators/validate-data.decorator.d.ts +91 -0
  168. package/file-upload/decorators/validate-data.decorator.js +39 -0
  169. package/file-upload/dto/create-file.dto.d.ts +24 -0
  170. package/file-upload/dto/create-file.dto.js +112 -0
  171. package/file-upload/dto/find-files.dto.d.ts +15 -0
  172. package/file-upload/dto/find-files.dto.js +76 -0
  173. package/file-upload/dto/index.d.ts +4 -0
  174. package/file-upload/dto/index.js +20 -0
  175. package/file-upload/dto/pagination.dto.d.ts +7 -0
  176. package/file-upload/dto/pagination.dto.js +39 -0
  177. package/file-upload/dto/update-file.dto.d.ts +15 -0
  178. package/file-upload/dto/update-file.dto.js +67 -0
  179. package/file-upload/entities/file-metadata.entity.d.ts +25 -0
  180. package/file-upload/entities/file-metadata.entity.js +76 -0
  181. package/file-upload/entities/file.entity.d.ts +114 -0
  182. package/file-upload/entities/file.entity.js +350 -0
  183. package/file-upload/entities/index.d.ts +2 -0
  184. package/file-upload/entities/index.js +18 -0
  185. package/file-upload/enums/file-type.enum.d.ts +72 -0
  186. package/file-upload/enums/file-type.enum.js +212 -0
  187. package/file-upload/exceptions/file-upload.exception.d.ts +57 -0
  188. package/file-upload/exceptions/file-upload.exception.js +120 -0
  189. package/file-upload/exceptions/index.d.ts +1 -0
  190. package/file-upload/exceptions/index.js +17 -0
  191. package/file-upload/file-upload.module.d.ts +89 -0
  192. package/file-upload/file-upload.module.js +292 -0
  193. package/file-upload/index.d.ts +37 -0
  194. package/file-upload/index.js +77 -0
  195. package/file-upload/interceptors/file-upload.interceptor.d.ts +101 -0
  196. package/file-upload/interceptors/file-upload.interceptor.js +594 -0
  197. package/file-upload/interceptors/index.d.ts +1 -0
  198. package/file-upload/interceptors/index.js +17 -0
  199. package/file-upload/interfaces/custom-file-type.interface.d.ts +72 -0
  200. package/file-upload/interfaces/custom-file-type.interface.js +2 -0
  201. package/file-upload/interfaces/file-buffer.interface.d.ts +72 -0
  202. package/file-upload/interfaces/file-buffer.interface.js +2 -0
  203. package/file-upload/interfaces/file-entity.interface.d.ts +142 -0
  204. package/file-upload/interfaces/file-entity.interface.js +28 -0
  205. package/file-upload/interfaces/file-metadata.interface.d.ts +21 -0
  206. package/file-upload/interfaces/file-metadata.interface.js +2 -0
  207. package/file-upload/interfaces/file-processor.interface.d.ts +93 -0
  208. package/file-upload/interfaces/file-processor.interface.js +2 -0
  209. package/file-upload/interfaces/file-upload-options.interface.d.ts +74 -0
  210. package/file-upload/interfaces/file-upload-options.interface.js +5 -0
  211. package/file-upload/interfaces/index.d.ts +7 -0
  212. package/file-upload/interfaces/index.js +24 -0
  213. package/file-upload/interfaces/processor-options.interface.d.ts +102 -0
  214. package/file-upload/interfaces/processor-options.interface.js +2 -0
  215. package/file-upload/interfaces/storage-provider.interface.d.ts +239 -0
  216. package/file-upload/interfaces/storage-provider.interface.js +2 -0
  217. package/file-upload/interfaces/upload-options.interface.d.ts +19 -0
  218. package/file-upload/interfaces/upload-options.interface.js +2 -0
  219. package/file-upload/processors/csv.processor.d.ts +98 -0
  220. package/file-upload/processors/csv.processor.js +391 -0
  221. package/file-upload/processors/excel.processor.d.ts +130 -0
  222. package/file-upload/processors/excel.processor.js +547 -0
  223. package/file-upload/processors/image.processor.d.ts +199 -0
  224. package/file-upload/processors/image.processor.js +377 -0
  225. package/file-upload/providers/index.d.ts +2 -0
  226. package/file-upload/providers/index.js +18 -0
  227. package/file-upload/providers/local-storage.provider.d.ts +98 -0
  228. package/file-upload/providers/local-storage.provider.js +484 -0
  229. package/file-upload/providers/s3-storage.provider.d.ts +87 -0
  230. package/file-upload/providers/s3-storage.provider.js +455 -0
  231. package/file-upload/services/file-signature-validator.service.d.ts +118 -0
  232. package/file-upload/services/file-signature-validator.service.js +376 -0
  233. package/file-upload/services/file.service.d.ts +193 -0
  234. package/file-upload/services/file.service.js +638 -0
  235. package/file-upload/services/index.d.ts +4 -0
  236. package/file-upload/services/index.js +20 -0
  237. package/file-upload/services/malicious-file-detector.service.d.ts +300 -0
  238. package/file-upload/services/malicious-file-detector.service.js +1234 -0
  239. package/file-upload/services/mime-registry.service.d.ts +47 -0
  240. package/file-upload/services/mime-registry.service.js +167 -0
  241. package/file-upload/utils/checksum.util.d.ts +28 -0
  242. package/file-upload/utils/checksum.util.js +65 -0
  243. package/file-upload/utils/dynamic-import.util.d.ts +54 -0
  244. package/file-upload/utils/dynamic-import.util.js +156 -0
  245. package/file-upload/utils/filename.util.d.ts +59 -0
  246. package/file-upload/utils/filename.util.js +184 -0
  247. package/file-upload/utils/filepath.util.d.ts +70 -0
  248. package/file-upload/utils/filepath.util.js +152 -0
  249. package/file-upload/utils/index.d.ts +4 -0
  250. package/file-upload/utils/index.js +20 -0
  251. package/filters/constraint-errors.js +1 -0
  252. package/helpers/common.helper.d.ts +13 -0
  253. package/helpers/common.helper.js +13 -0
  254. package/http-client/config/http-client.config.d.ts +20 -0
  255. package/http-client/config/http-client.config.js +48 -21
  256. package/http-client/decorators/http-client.decorators.d.ts +55 -14
  257. package/http-client/decorators/http-client.decorators.js +154 -78
  258. package/http-client/entities/http-log.entity.d.ts +217 -8
  259. package/http-client/entities/http-log.entity.js +7 -22
  260. package/http-client/errors/http-client.errors.d.ts +57 -0
  261. package/http-client/errors/http-client.errors.js +58 -0
  262. package/http-client/examples/advanced-usage.example.d.ts +40 -0
  263. package/http-client/examples/advanced-usage.example.js +53 -61
  264. package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
  265. package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
  266. package/http-client/examples/basic-usage.example.d.ts +60 -0
  267. package/http-client/examples/basic-usage.example.js +60 -0
  268. package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
  269. package/http-client/examples/multi-api-configuration.example.js +76 -5
  270. package/http-client/examples/proxy-from-environment.example.d.ts +133 -0
  271. package/http-client/examples/proxy-from-environment.example.js +409 -0
  272. package/http-client/http-client.module.d.ts +48 -2
  273. package/http-client/http-client.module.js +147 -68
  274. package/http-client/index.d.ts +1 -1
  275. package/http-client/index.js +8 -0
  276. package/http-client/interfaces/api-client-config.interface.d.ts +80 -45
  277. package/http-client/interfaces/api-client-config.interface.js +3 -0
  278. package/http-client/interfaces/http-client-config.interface.d.ts +109 -52
  279. package/http-client/services/api-client-registry.service.d.ts +50 -11
  280. package/http-client/services/api-client-registry.service.js +90 -250
  281. package/http-client/services/circuit-breaker.service.d.ts +115 -2
  282. package/http-client/services/circuit-breaker.service.js +237 -7
  283. package/http-client/services/http-client.service.d.ts +124 -14
  284. package/http-client/services/http-client.service.js +437 -148
  285. package/http-client/services/http-log-query.service.d.ts +83 -0
  286. package/http-client/services/http-log-query.service.js +121 -13
  287. package/http-client/services/http-replay.service.d.ts +101 -0
  288. package/http-client/services/http-replay.service.js +86 -0
  289. package/http-client/services/index.d.ts +0 -1
  290. package/http-client/services/index.js +0 -1
  291. package/http-client/services/log-cleanup.service.d.ts +63 -0
  292. package/http-client/services/log-cleanup.service.js +54 -2
  293. package/http-client/services/logging.service.d.ts +116 -7
  294. package/http-client/services/logging.service.js +349 -86
  295. package/http-client/utils/call-stack-extractor.util.d.ts +63 -0
  296. package/http-client/utils/call-stack-extractor.util.js +83 -0
  297. package/http-client/utils/context-extractor.util.d.ts +49 -0
  298. package/http-client/utils/context-extractor.util.js +52 -0
  299. package/http-client/utils/curl-generator.util.d.ts +21 -0
  300. package/http-client/utils/curl-generator.util.js +44 -3
  301. package/http-client/utils/index.d.ts +1 -0
  302. package/http-client/utils/index.js +1 -0
  303. package/http-client/utils/proxy-environment.util.d.ts +42 -0
  304. package/http-client/utils/proxy-environment.util.js +148 -0
  305. package/http-client/utils/request-id.util.d.ts +18 -0
  306. package/http-client/utils/request-id.util.js +20 -0
  307. package/http-client/utils/retry-recorder.util.d.ts +42 -0
  308. package/http-client/utils/retry-recorder.util.js +44 -0
  309. package/http-client/utils/security-validator.util.d.ts +118 -0
  310. package/http-client/utils/security-validator.util.js +352 -0
  311. package/index.d.ts +3 -1
  312. package/index.js +12 -1
  313. package/interceptors/translation-interceptor.service.js +5 -0
  314. package/package.json +11 -7
  315. package/providers/context.provider.js +2 -0
  316. package/providers/generator.provider.d.ts +4 -0
  317. package/providers/generator.provider.js +4 -0
  318. package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
  319. package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
  320. package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
  321. package/redis-lock/examples/lock-strategy.examples.js +130 -15
  322. package/redis-lock/index.d.ts +2 -0
  323. package/redis-lock/index.js +8 -1
  324. package/redis-lock/lock-heartbeat.service.d.ts +80 -0
  325. package/redis-lock/lock-heartbeat.service.js +232 -0
  326. package/redis-lock/redis-lock.decorator.d.ts +101 -0
  327. package/redis-lock/redis-lock.decorator.js +120 -0
  328. package/redis-lock/redis-lock.module.d.ts +66 -0
  329. package/redis-lock/redis-lock.module.js +175 -70
  330. package/redis-lock/redis-lock.service.d.ts +282 -0
  331. package/redis-lock/redis-lock.service.js +343 -20
  332. package/setup/bootstrap.setup.d.ts +1 -0
  333. package/setup/bootstrap.setup.js +21 -0
  334. package/setup/index.d.ts +1 -0
  335. package/setup/index.js +1 -0
  336. package/setup/mode.setup.d.ts +44 -0
  337. package/setup/mode.setup.js +44 -0
  338. package/setup/run-in-mode.decorator.d.ts +56 -0
  339. package/setup/run-in-mode.decorator.js +92 -0
  340. package/setup/schedule.decorator.d.ts +227 -0
  341. package/setup/schedule.decorator.js +240 -12
  342. package/setup/worker.decorator.d.ts +86 -0
  343. package/setup/worker.decorator.js +97 -0
  344. package/shared/index.d.ts +1 -1
  345. package/shared/index.js +1 -1
  346. package/shared/{serviceRegistryModule.js → service-registry.module.js} +19 -17
  347. package/shared/services/api-config.service.d.ts +3 -0
  348. package/shared/services/api-config.service.js +21 -9
  349. package/shared/services/index.d.ts +0 -1
  350. package/shared/services/index.js +0 -1
  351. package/validator-json/decorators.d.ts +17 -0
  352. package/validator-json/decorators.js +17 -2
  353. package/validator-json/default.d.ts +6 -0
  354. package/validator-json/default.js +30 -2
  355. package/validator-json/defaultConverters.js +1 -0
  356. package/validator-json/options.d.ts +23 -0
  357. package/validators/common-validators.d.ts +143 -0
  358. package/validators/common-validators.js +249 -0
  359. package/validators/custom-validate.examples.d.ts +23 -0
  360. package/validators/custom-validate.examples.js +78 -6
  361. package/validators/custom-validate.validator.d.ts +108 -0
  362. package/validators/custom-validate.validator.js +85 -0
  363. package/validators/file-mimetype.validator.d.ts +0 -2
  364. package/validators/file-mimetype.validator.js +4 -6
  365. package/validators/index.d.ts +1 -0
  366. package/validators/index.js +1 -0
  367. package/validators/is-exists.validator.d.ts +26 -6
  368. package/validators/is-exists.validator.js +30 -7
  369. package/validators/is-unique.validator.d.ts +33 -7
  370. package/validators/is-unique.validator.js +59 -17
  371. package/validators/skip-empty.validator.d.ts +5 -0
  372. package/validators/skip-empty.validator.js +5 -0
  373. package/vault/interfaces/vault-options.interface.d.ts +9 -0
  374. package/vault/vault-config.loader.d.ts +30 -0
  375. package/vault/vault-config.loader.js +48 -1
  376. package/vault/vault-config.service.d.ts +53 -0
  377. package/vault/vault-config.service.js +57 -0
  378. package/vault/vault.module.d.ts +4 -0
  379. package/vault/vault.module.js +4 -0
  380. package/decorators/examples/validation-decorators.example.d.ts +0 -69
  381. package/decorators/examples/validation-decorators.example.js +0 -331
  382. package/http-client/services/cache.service.d.ts +0 -24
  383. package/http-client/services/cache.service.js +0 -264
  384. package/shared/services/validator.service.d.ts +0 -3
  385. package/shared/services/validator.service.js +0 -20
  386. /package/shared/{serviceRegistryModule.d.ts → service-registry.module.d.ts} +0 -0
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileNameUtil = void 0;
4
+ const path = require("path");
5
+ /**
6
+ * 文件名处理工具类
7
+ * 统一管理文件名的编码、清理、截取等操作
8
+ */
9
+ class FileNameUtil {
10
+ /**
11
+ * 解码并标准化文件名
12
+ * 1. Multer 默认使用 Latin1 解码,需要转换为 UTF-8
13
+ * 2. 移除特殊字符和控制字符
14
+ * 3. 截取超长文件名到指定长度
15
+ *
16
+ * @param filename 原始文件名
17
+ * @param maxLength 最大长度(默认 100 字符)
18
+ * @returns 处理后的文件名
19
+ */
20
+ static decodeAndNormalize(filename, maxLength = 100) {
21
+ if (!filename) {
22
+ return 'unknown';
23
+ }
24
+ let decoded;
25
+ // 尝试从 Latin1 转换(这是 Multer 的常见情况)
26
+ try {
27
+ const buffer = Buffer.from(filename, 'latin1');
28
+ decoded = buffer.toString('utf8');
29
+ // 检查转换结果是否包含 UTF-8 替换字符(表示可能有乱码)
30
+ if (!decoded.includes('\uFFFD') && this.hasValidCharacters(decoded)) {
31
+ // 转换成功且看起来有效
32
+ }
33
+ else {
34
+ // 可能不是 Latin1 编码,保持原始字符串
35
+ decoded = filename;
36
+ }
37
+ }
38
+ catch (_a) {
39
+ // 转换失败,保持原始字符串
40
+ decoded = filename;
41
+ }
42
+ // 移除不可见控制字符(但保留换行符)
43
+ decoded = decoded.replace(/[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F-\x9F]/g, '');
44
+ // 移除常见乱码字符(替换符)
45
+ decoded = decoded.replace(/\uFFFD/g, '');
46
+ // 移除前后空格
47
+ decoded = decoded.trim();
48
+ // 截取长度(按字符数,不是字节数)
49
+ if (decoded.length > maxLength) {
50
+ return this.truncateWithExtension(decoded, maxLength);
51
+ }
52
+ return decoded;
53
+ }
54
+ /**
55
+ * 智能截取文件名(保留扩展名)
56
+ *
57
+ * @param filename 文件名
58
+ * @param maxLength 最大长度
59
+ * @returns 截取后的文件名
60
+ */
61
+ static truncateWithExtension(filename, maxLength) {
62
+ // 如果文件名长度不超过限制,直接返回
63
+ if (filename.length <= maxLength) {
64
+ return filename;
65
+ }
66
+ // 保留文件扩展名
67
+ const extMatch = filename.match(/\.[^.]+$/);
68
+ const ext = extMatch ? extMatch[0] : '';
69
+ const nameWithoutExt = ext ? filename.slice(0, -ext.length) : filename;
70
+ // 如果没有扩展名,直接截断到指定长度
71
+ if (!ext) {
72
+ return filename.slice(0, maxLength);
73
+ }
74
+ // 计算可用的文件名长度
75
+ const availableLength = maxLength - ext.length - 3; // 预留 3 个字符用于 "..."
76
+ if (availableLength > 0) {
77
+ return nameWithoutExt.slice(0, availableLength) + '...' + ext;
78
+ }
79
+ else {
80
+ // 如果扩展名本身就超过限制,直接截取
81
+ return filename.slice(0, maxLength);
82
+ }
83
+ }
84
+ /**
85
+ * 清理文件名(移除危险字符)
86
+ * 移除路径遍历、路径分隔符、控制字符等
87
+ *
88
+ * @param filename 文件名
89
+ * @returns 清理后的文件名
90
+ */
91
+ static sanitize(filename) {
92
+ // 移除路径遍历字符
93
+ let sanitized = filename.replace(/\.\./g, '');
94
+ // 移除路径分隔符
95
+ sanitized = sanitized.replace(/[\/\\]/g, '');
96
+ // 移除控制字符
97
+ sanitized = sanitized.replace(/[\x00-\x1f\x80-\x9f]/g, '');
98
+ // 保留空格,只替换其他特殊字符
99
+ sanitized = sanitized.replace(/[^a-zA-Z0-9.\-_\s\u4e00-\u9fa5]/g, '_');
100
+ // 移除前导/尾随空格和点
101
+ sanitized = sanitized
102
+ .trim()
103
+ .replace(/^\.+|\.+$/g, '')
104
+ .replace(/^_+|_+$/g, '');
105
+ return sanitized;
106
+ }
107
+ /**
108
+ * 清理并保留原始文件名结构
109
+ * 先解码 UTF-8,再清理危险字符
110
+ *
111
+ * @param filename 文件名
112
+ * @returns 清理后的文件名
113
+ */
114
+ static sanitizeOriginal(filename) {
115
+ // 1. 解码 UTF-8
116
+ const decoded = this.decodeAndNormalize(filename);
117
+ // 2. 移除路径遍历字符
118
+ let sanitized = decoded.replace(/\.\./g, '');
119
+ sanitized = sanitized.replace(/[\/\\]/g, '');
120
+ // 3. 移除控制字符
121
+ sanitized = sanitized.replace(/[\x00-\x1f\x80-\x9f]/g, '');
122
+ // 4. 移除前导/尾随空格和点
123
+ sanitized = sanitized.trim().replace(/^\.+|\.+$/g, '');
124
+ return sanitized;
125
+ }
126
+ /**
127
+ * 提取文件扩展名
128
+ *
129
+ * @param filename 文件名
130
+ * @returns 扩展名(包含点)或空字符串
131
+ */
132
+ static extractExtension(filename) {
133
+ const lastDotIndex = filename.lastIndexOf('.');
134
+ // 如果没有点、点是第一个字符(隐藏文件)、或点是最后一个字符
135
+ if (lastDotIndex === -1 ||
136
+ lastDotIndex === 0 ||
137
+ lastDotIndex === filename.length - 1) {
138
+ return '';
139
+ }
140
+ return filename.substring(lastDotIndex);
141
+ }
142
+ /**
143
+ * 获取不包含扩展名的文件名
144
+ *
145
+ * @param filename 文件名
146
+ * @returns 不包含扩展名的文件名
147
+ */
148
+ static getBaseName(filename) {
149
+ return path.basename(filename, this.extractExtension(filename));
150
+ }
151
+ /**
152
+ * 检查字符串是否包含有效的字符
153
+ */
154
+ static hasValidCharacters(str) {
155
+ // 如果字符串太短,无法判断
156
+ if (str.length === 0)
157
+ return true;
158
+ // 计算有效字符的比例
159
+ let validCount = 0;
160
+ for (let i = 0; i < str.length; i++) {
161
+ const char = str[i];
162
+ const code = char.charCodeAt(0);
163
+ // ASCII 可打印字符
164
+ if (code >= 0x20 && code <= 0x7e) {
165
+ validCount++;
166
+ }
167
+ // 基本拉丁字母扩展
168
+ else if (code >= 0xa0 && code <= 0xff) {
169
+ validCount++;
170
+ }
171
+ // 中文、日文、韩文等 CJK 字符
172
+ else if (code >= 0x4e00 && code <= 0x9fff) {
173
+ validCount++;
174
+ }
175
+ // 其他 Unicode 字符
176
+ else if (code > 0xff) {
177
+ validCount++;
178
+ }
179
+ }
180
+ // 如果超过 70% 的字符是有效的,认为是有效的字符串
181
+ return validCount / str.length > 0.7;
182
+ }
183
+ }
184
+ exports.FileNameUtil = FileNameUtil;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 文件路径处理工具类
3
+ * 统一管理文件上传路径、相对路径转换等操作
4
+ */
5
+ export declare class FilePathUtil {
6
+ /**
7
+ * 获取上传根目录
8
+ * 优先使用环境变量 FILE_UPLOAD_PATH,否则使用 process.cwd()/uploads
9
+ *
10
+ * @returns 上传根目录的绝对路径
11
+ */
12
+ static getUploadDir(): string;
13
+ /**
14
+ * 生成日期子目录格式 (YYYY/MM/DD)
15
+ *
16
+ * @returns 日期子目录路径
17
+ */
18
+ static getDateSubdirectory(): string;
19
+ /**
20
+ * 获取完整的上传目录(包含日期子目录)
21
+ *
22
+ * @returns 完整的上传目录路径
23
+ */
24
+ static getFullUploadPath(): string;
25
+ /**
26
+ * 将绝对路径转换为相对路径(相对于上传根目录)
27
+ * 例如: /Users/.../uploads/2025/11/30/xxx.txt -> 2025/11/30/xxx.txt
28
+ *
29
+ * @param absolutePath 绝对路径
30
+ * @returns 相对路径
31
+ */
32
+ static toRelativePath(absolutePath: string): string;
33
+ /**
34
+ * 将相对路径转换为绝对路径(物理路径)
35
+ * 例如: 2025/11/30/xxx.txt -> /Users/.../uploads/2025/11/30/xxx.txt
36
+ *
37
+ * @param relativePath 相对路径
38
+ * @returns 绝对路径
39
+ */
40
+ static toAbsolutePath(relativePath: string): string;
41
+ /**
42
+ * 规范化路径(统一使用正斜杠)
43
+ *
44
+ * @param filePath 文件路径
45
+ * @returns 规范化后的路径
46
+ */
47
+ static normalize(filePath: string): string;
48
+ /**
49
+ * 检查路径是否为绝对路径
50
+ *
51
+ * @param filePath 文件路径
52
+ * @returns 是否为绝对路径
53
+ */
54
+ static isAbsolute(filePath: string): boolean;
55
+ /**
56
+ * 检查文件是否存在
57
+ *
58
+ * @param filePath 文件路径(绝对或相对)
59
+ * @returns 文件是否存在
60
+ */
61
+ static exists(filePath: string): boolean;
62
+ /**
63
+ * 获取文件的物理路径(用于文件系统访问)
64
+ *
65
+ * @param relativePath 相对路径
66
+ * @param storageProvider 存储提供商
67
+ * @returns 物理路径或相对路径(对象存储)
68
+ */
69
+ static getPhysicalPath(relativePath: string, storageProvider?: string): string;
70
+ }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilePathUtil = void 0;
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+ /**
7
+ * 文件路径处理工具类
8
+ * 统一管理文件上传路径、相对路径转换等操作
9
+ */
10
+ class FilePathUtil {
11
+ /**
12
+ * 获取上传根目录
13
+ * 优先使用环境变量 FILE_UPLOAD_PATH,否则使用 process.cwd()/uploads
14
+ *
15
+ * @returns 上传根目录的绝对路径
16
+ */
17
+ static getUploadDir() {
18
+ const uploadPath = process.env.FILE_UPLOAD_PATH || path.join(process.cwd(), 'uploads');
19
+ // 确保目录存在
20
+ if (!fs.existsSync(uploadPath)) {
21
+ fs.mkdirSync(uploadPath, { recursive: true });
22
+ }
23
+ return uploadPath;
24
+ }
25
+ /**
26
+ * 生成日期子目录格式 (YYYY/MM/DD)
27
+ *
28
+ * @returns 日期子目录路径
29
+ */
30
+ static getDateSubdirectory() {
31
+ const now = new Date();
32
+ const year = now.getFullYear();
33
+ const month = String(now.getMonth() + 1).padStart(2, '0');
34
+ const day = String(now.getDate()).padStart(2, '0');
35
+ return path.join(String(year), month, day);
36
+ }
37
+ /**
38
+ * 获取完整的上传目录(包含日期子目录)
39
+ *
40
+ * @returns 完整的上传目录路径
41
+ */
42
+ static getFullUploadPath() {
43
+ const basePath = this.getUploadDir();
44
+ const subDir = this.getDateSubdirectory();
45
+ const fullPath = path.join(basePath, subDir);
46
+ // 确保目录存在
47
+ if (!fs.existsSync(fullPath)) {
48
+ fs.mkdirSync(fullPath, { recursive: true });
49
+ }
50
+ return fullPath;
51
+ }
52
+ /**
53
+ * 将绝对路径转换为相对路径(相对于上传根目录)
54
+ * 例如: /Users/.../uploads/2025/11/30/xxx.txt -> 2025/11/30/xxx.txt
55
+ *
56
+ * @param absolutePath 绝对路径
57
+ * @returns 相对路径
58
+ */
59
+ static toRelativePath(absolutePath) {
60
+ if (!absolutePath) {
61
+ return '';
62
+ }
63
+ const uploadDir = this.getUploadDir();
64
+ // 方法1: 使用 startsWith 精确匹配
65
+ if (absolutePath.startsWith(uploadDir)) {
66
+ return absolutePath.substring(uploadDir.length).replace(/^[\/\\]+/, '');
67
+ }
68
+ // 方法2: 兼容处理 - 如果包含 /uploads/,从该位置开始截取
69
+ if (absolutePath.includes('/uploads/')) {
70
+ const uploadIndex = absolutePath.indexOf('/uploads/');
71
+ return absolutePath.substring(uploadIndex + '/uploads/'.length);
72
+ }
73
+ // 方法3: 兼容 Windows 路径
74
+ if (absolutePath.includes('\\uploads\\')) {
75
+ const uploadIndex = absolutePath.indexOf('\\uploads\\');
76
+ return absolutePath
77
+ .substring(uploadIndex + '\\uploads\\'.length)
78
+ .replace(/\\/g, '/');
79
+ }
80
+ // 如果都不匹配,返回原路径
81
+ return absolutePath;
82
+ }
83
+ /**
84
+ * 将相对路径转换为绝对路径(物理路径)
85
+ * 例如: 2025/11/30/xxx.txt -> /Users/.../uploads/2025/11/30/xxx.txt
86
+ *
87
+ * @param relativePath 相对路径
88
+ * @returns 绝对路径
89
+ */
90
+ static toAbsolutePath(relativePath) {
91
+ if (!relativePath) {
92
+ return '';
93
+ }
94
+ const uploadDir = this.getUploadDir();
95
+ return path.join(uploadDir, relativePath);
96
+ }
97
+ /**
98
+ * 规范化路径(统一使用正斜杠)
99
+ *
100
+ * @param filePath 文件路径
101
+ * @returns 规范化后的路径
102
+ */
103
+ static normalize(filePath) {
104
+ return filePath.replace(/\\/g, '/');
105
+ }
106
+ /**
107
+ * 检查路径是否为绝对路径
108
+ *
109
+ * @param filePath 文件路径
110
+ * @returns 是否为绝对路径
111
+ */
112
+ static isAbsolute(filePath) {
113
+ return path.isAbsolute(filePath);
114
+ }
115
+ /**
116
+ * 检查文件是否存在
117
+ *
118
+ * @param filePath 文件路径(绝对或相对)
119
+ * @returns 文件是否存在
120
+ */
121
+ static exists(filePath) {
122
+ const absolutePath = this.isAbsolute(filePath)
123
+ ? filePath
124
+ : this.toAbsolutePath(filePath);
125
+ return fs.existsSync(absolutePath);
126
+ }
127
+ /**
128
+ * 获取文件的物理路径(用于文件系统访问)
129
+ *
130
+ * @param relativePath 相对路径
131
+ * @param storageProvider 存储提供商
132
+ * @returns 物理路径或相对路径(对象存储)
133
+ */
134
+ static getPhysicalPath(relativePath, storageProvider = 'local') {
135
+ if (!relativePath) {
136
+ return '';
137
+ }
138
+ switch (storageProvider) {
139
+ case 'local':
140
+ return this.toAbsolutePath(relativePath);
141
+ case 's3':
142
+ case 'oss':
143
+ case 'minio':
144
+ case 'cdn':
145
+ // 对象存储返回相对路径,由存储服务处理
146
+ return relativePath;
147
+ default:
148
+ return relativePath;
149
+ }
150
+ }
151
+ }
152
+ exports.FilePathUtil = FilePathUtil;
@@ -0,0 +1,4 @@
1
+ export * from './dynamic-import.util';
2
+ export * from './checksum.util';
3
+ export * from './filename.util';
4
+ export * from './filepath.util';
@@ -0,0 +1,20 @@
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("./dynamic-import.util"), exports);
18
+ __exportStar(require("./checksum.util"), exports);
19
+ __exportStar(require("./filename.util"), exports);
20
+ __exportStar(require("./filepath.util"), exports);
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/naming-convention */
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.constraintErrors = void 0;
4
5
  exports.constraintErrors = {
@@ -1,3 +1,16 @@
1
+ /**
2
+ * 将枚举值转换成数组
3
+ * @param Enum 枚举
4
+ */
1
5
  export declare function enumToArray<E>(Enum: any): E[];
6
+ /**
7
+ * 生成随机字符串
8
+ * @param {number} length 生成长度
9
+ * @param {string} charSet 指定字符集
10
+ * @returns {string} 生成字符串
11
+ */
2
12
  export declare const randomString: (length?: number, charSet?: string) => string;
13
+ /**
14
+ * 获取服务部署 IP 地址
15
+ */
3
16
  export declare function getIPAdress(): string;
@@ -4,11 +4,21 @@ exports.randomString = void 0;
4
4
  exports.enumToArray = enumToArray;
5
5
  exports.getIPAdress = getIPAdress;
6
6
  const os_1 = require("os");
7
+ /**
8
+ * 将枚举值转换成数组
9
+ * @param Enum 枚举
10
+ */
7
11
  function enumToArray(Enum) {
8
12
  return Object.keys(Enum)
9
13
  .filter((key) => typeof Enum[key] === 'number')
10
14
  .map((key) => Enum[key]);
11
15
  }
16
+ /**
17
+ * 生成随机字符串
18
+ * @param {number} length 生成长度
19
+ * @param {string} charSet 指定字符集
20
+ * @returns {string} 生成字符串
21
+ */
12
22
  const randomString = (length = 8, charSet) => {
13
23
  charSet =
14
24
  charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@@ -20,6 +30,9 @@ const randomString = (length = 8, charSet) => {
20
30
  return randomString;
21
31
  };
22
32
  exports.randomString = randomString;
33
+ /**
34
+ * 获取服务部署 IP 地址
35
+ */
23
36
  function getIPAdress() {
24
37
  const interfaces = (0, os_1.networkInterfaces)();
25
38
  for (const devName in interfaces) {
@@ -1,6 +1,26 @@
1
1
  import { HttpClientConfig } from '../interfaces/http-client-config.interface';
2
+ /**
3
+ * 深度合并配置
4
+ * 将用户配置与默认配置合并,用户配置会覆盖默认配置
5
+ */
6
+ export declare function mergeHttpClientConfig(userConfig?: Partial<HttpClientConfig>, defaultConfig?: Partial<HttpClientConfig>): HttpClientConfig;
7
+ /**
8
+ * HTTP客户端默认配置
9
+ */
2
10
  export declare const DEFAULT_HTTP_CLIENT_CONFIG: Partial<HttpClientConfig>;
11
+ /**
12
+ * 开发环境配置
13
+ */
3
14
  export declare const DEVELOPMENT_HTTP_CLIENT_CONFIG: Partial<HttpClientConfig>;
15
+ /**
16
+ * 生产环境配置
17
+ */
4
18
  export declare const PRODUCTION_HTTP_CLIENT_CONFIG: Partial<HttpClientConfig>;
19
+ /**
20
+ * 测试环境配置
21
+ */
5
22
  export declare const TEST_HTTP_CLIENT_CONFIG: Partial<HttpClientConfig>;
23
+ /**
24
+ * 根据环境获取配置
25
+ */
6
26
  export declare function getHttpClientConfig(env?: string): Partial<HttpClientConfig>;
@@ -1,8 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TEST_HTTP_CLIENT_CONFIG = exports.PRODUCTION_HTTP_CLIENT_CONFIG = exports.DEVELOPMENT_HTTP_CLIENT_CONFIG = exports.DEFAULT_HTTP_CLIENT_CONFIG = void 0;
4
+ exports.mergeHttpClientConfig = mergeHttpClientConfig;
4
5
  exports.getHttpClientConfig = getHttpClientConfig;
5
- const cache_options_interface_1 = require("../../cache/interfaces/cache-options.interface");
6
+ /**
7
+ * 深度合并对象
8
+ * 用于合并用户配置和默认配置
9
+ */
10
+ function deepMerge(target, source) {
11
+ const result = Object.assign({}, target);
12
+ for (const key in source) {
13
+ if (source[key] instanceof Object && key in target && !Array.isArray(source[key])) {
14
+ result[key] = deepMerge(target[key], source[key]);
15
+ }
16
+ else {
17
+ result[key] = source[key];
18
+ }
19
+ }
20
+ return result;
21
+ }
22
+ /**
23
+ * 深度合并配置
24
+ * 将用户配置与默认配置合并,用户配置会覆盖默认配置
25
+ */
26
+ function mergeHttpClientConfig(userConfig = {}, defaultConfig = exports.DEFAULT_HTTP_CLIENT_CONFIG) {
27
+ return deepMerge(defaultConfig, userConfig);
28
+ }
29
+ /**
30
+ * HTTP客户端默认配置
31
+ */
6
32
  exports.DEFAULT_HTTP_CLIENT_CONFIG = {
7
33
  timeout: 30000,
8
34
  retry: {
@@ -10,10 +36,11 @@ exports.DEFAULT_HTTP_CLIENT_CONFIG = {
10
36
  retries: 3,
11
37
  retryDelay: (retryCount) => Math.pow(2, retryCount) * 1000,
12
38
  retryCondition: (error) => {
39
+ // 默认重试条件:网络错误、超时、5xx错误、429错误
13
40
  if (!error.response)
14
- return true;
41
+ return true; // 网络错误
15
42
  const status = error.response.status;
16
- return status >= 500 || status === 429;
43
+ return status >= 500 || status === 429; // 服务器错误或限流
17
44
  },
18
45
  shouldResetTimeout: true,
19
46
  },
@@ -25,51 +52,51 @@ exports.DEFAULT_HTTP_CLIENT_CONFIG = {
25
52
  minimumThroughputThreshold: 10,
26
53
  countHalfOpenCalls: false,
27
54
  },
28
- cache: {
29
- enabled: true,
30
- defaultTtl: 300000,
31
- cacheableMethods: ['GET', 'HEAD'],
32
- cacheableStatusCodes: [200, 201, 304],
33
- options: {
34
- layers: [cache_options_interface_1.CacheLayer.CLS, cache_options_interface_1.CacheLayer.MEMORY, cache_options_interface_1.CacheLayer.REDIS],
35
- },
36
- },
37
55
  logging: {
38
56
  enabled: true,
39
57
  logRequests: true,
40
58
  logResponses: true,
41
59
  logErrors: true,
42
- logHeaders: false,
60
+ logHeaders: false, // 默认不记录头信息(安全考虑)
43
61
  logBody: true,
44
62
  maxBodyLength: 1000,
45
63
  sanitizeHeaders: ['authorization', 'apikey', 'password', 'token', 'cookie'],
46
64
  logLevel: 'info',
47
65
  databaseLogging: {
48
- enabled: false,
66
+ enabled: false, // 默认不启用数据库日志
49
67
  dataSource: 'default',
50
- tableName: 'http_logs',
51
68
  },
52
69
  },
53
70
  logCleanup: {
54
- enabled: false,
71
+ enabled: false, // 默认不启用日志清理
55
72
  retentionDays: 30,
56
73
  maxRecords: 100000,
57
74
  batchSize: 1000,
58
- schedule: '0 2 * * *',
75
+ schedule: '0 2 * * *', // 每天凌晨2点
59
76
  strategy: 'retention',
60
77
  },
61
78
  };
79
+ /**
80
+ * 开发环境配置
81
+ */
62
82
  exports.DEVELOPMENT_HTTP_CLIENT_CONFIG = Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG), { logging: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.logging), { enabled: true, logHeaders: true, logBody: true, logLevel: 'debug', databaseLogging: {
63
- enabled: true,
83
+ enabled: true, // 开发环境启用数据库日志
64
84
  dataSource: 'default',
65
- tableName: 'http_logs',
66
85
  } }), logCleanup: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.logCleanup), { enabled: false }) });
86
+ /**
87
+ * 生产环境配置
88
+ */
67
89
  exports.PRODUCTION_HTTP_CLIENT_CONFIG = Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG), { timeout: 60000, retry: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.retry), { retries: 5 }), circuitBreaker: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.circuitBreaker), { failureThreshold: 3, recoveryTimeoutMs: 120000 }), logging: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.logging), { enabled: true, logHeaders: false, logBody: false, logLevel: 'warn', databaseLogging: {
68
- enabled: true,
90
+ enabled: true, // 生产环境启用数据库日志
69
91
  dataSource: 'default',
70
- tableName: 'http_logs',
71
92
  } }), logCleanup: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.logCleanup), { enabled: true, retentionDays: 7, maxRecords: 50000, schedule: '0 3 * * *' }) });
93
+ /**
94
+ * 测试环境配置
95
+ */
72
96
  exports.TEST_HTTP_CLIENT_CONFIG = Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG), { timeout: 10000, retry: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.retry), { retries: 1 }), circuitBreaker: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.circuitBreaker), { failureThreshold: 10, recoveryTimeoutMs: 5000 }), logging: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.logging), { enabled: false }), logCleanup: Object.assign(Object.assign({}, exports.DEFAULT_HTTP_CLIENT_CONFIG.logCleanup), { enabled: false }) });
97
+ /**
98
+ * 根据环境获取配置
99
+ */
73
100
  function getHttpClientConfig(env) {
74
101
  switch (env === null || env === void 0 ? void 0 : env.toLowerCase()) {
75
102
  case 'development':