@nest-omni/core 4.1.3-3 → 4.1.3-31

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 (370) hide show
  1. package/audit/audit.module.d.ts +1 -0
  2. package/audit/audit.module.js +51 -2
  3. package/audit/controllers/audit.controller.d.ts +57 -1
  4. package/audit/controllers/audit.controller.js +43 -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 +1 -1
  8. package/audit/decorators/audit-controller.decorator.js +2 -2
  9. package/audit/decorators/audit-operation.decorator.d.ts +0 -7
  10. package/audit/decorators/audit-operation.decorator.js +0 -7
  11. package/audit/decorators/entity-audit.decorator.d.ts +78 -2
  12. package/audit/decorators/entity-audit.decorator.js +145 -4
  13. package/audit/decorators/index.d.ts +2 -0
  14. package/audit/decorators/index.js +2 -0
  15. package/audit/dto/audit-action-query.dto.d.ts +13 -0
  16. package/audit/dto/audit-action-query.dto.js +77 -0
  17. package/audit/dto/index.d.ts +1 -0
  18. package/audit/dto/index.js +1 -0
  19. package/audit/entities/audit-action-summary.entity.d.ts +23 -0
  20. package/audit/entities/audit-action-summary.entity.js +101 -0
  21. package/audit/entities/entity-audit-log.entity.d.ts +7 -2
  22. package/audit/entities/entity-audit-log.entity.js +45 -9
  23. package/audit/entities/entity-transaction.entity.d.ts +8 -2
  24. package/audit/entities/entity-transaction.entity.js +39 -3
  25. package/audit/entities/index.d.ts +3 -0
  26. package/audit/entities/index.js +3 -0
  27. package/audit/entities/manual-operation-log.entity.d.ts +0 -2
  28. package/audit/entities/manual-operation-log.entity.js +8 -9
  29. package/audit/enums/audit.enums.d.ts +14 -6
  30. package/audit/enums/audit.enums.js +18 -9
  31. package/audit/examples/decorator-value-mapping.example.d.ts +70 -0
  32. package/audit/examples/decorator-value-mapping.example.js +414 -0
  33. package/audit/index.d.ts +5 -1
  34. package/audit/index.js +29 -2
  35. package/audit/interceptors/audit-action.interceptor.d.ts +39 -0
  36. package/audit/interceptors/audit-action.interceptor.js +217 -0
  37. package/audit/interceptors/audit.interceptor.d.ts +1 -0
  38. package/audit/interceptors/audit.interceptor.js +19 -11
  39. package/audit/interceptors/index.d.ts +1 -0
  40. package/audit/interceptors/index.js +1 -0
  41. package/audit/interfaces/audit.interfaces.d.ts +132 -4
  42. package/audit/services/audit-action.service.d.ts +142 -0
  43. package/audit/services/audit-action.service.js +246 -0
  44. package/audit/services/audit-context.service.d.ts +91 -0
  45. package/audit/services/audit-context.service.js +170 -0
  46. package/audit/services/entity-audit.service.d.ts +220 -9
  47. package/audit/services/entity-audit.service.js +761 -72
  48. package/audit/services/index.d.ts +3 -0
  49. package/audit/services/index.js +3 -0
  50. package/audit/services/manual-audit-log.service.d.ts +23 -23
  51. package/audit/services/manual-audit-log.service.js +34 -57
  52. package/audit/services/multi-database.service.d.ts +0 -5
  53. package/audit/services/multi-database.service.js +0 -24
  54. package/audit/services/operation-description.service.d.ts +14 -3
  55. package/audit/services/operation-description.service.js +165 -26
  56. package/audit/services/transaction-audit.service.d.ts +1 -0
  57. package/audit/services/transaction-audit.service.js +12 -9
  58. package/audit/subscribers/entity-audit.subscriber.d.ts +5 -0
  59. package/audit/subscribers/entity-audit.subscriber.js +69 -5
  60. package/cache/cache.module.d.ts +7 -8
  61. package/cache/cache.module.js +15 -13
  62. package/cache/cache.service.d.ts +6 -4
  63. package/cache/cache.service.js +24 -12
  64. package/cache/decorators/cache-put.decorator.js +5 -4
  65. package/cache/dependencies/callback.dependency.js +9 -0
  66. package/cache/dependencies/db.dependency.d.ts +43 -12
  67. package/cache/dependencies/db.dependency.js +46 -18
  68. package/cache/dependencies/tag.dependency.d.ts +31 -4
  69. package/cache/dependencies/tag.dependency.js +100 -11
  70. package/cache/entities/index.d.ts +1 -0
  71. package/cache/entities/index.js +17 -0
  72. package/cache/entities/typeorm-cache.entity.d.ts +71 -0
  73. package/cache/entities/typeorm-cache.entity.js +110 -0
  74. package/cache/index.d.ts +2 -1
  75. package/cache/index.js +19 -2
  76. package/cache/interfaces/cache-options.interface.d.ts +8 -0
  77. package/cache/providers/index.d.ts +2 -1
  78. package/cache/providers/index.js +2 -1
  79. package/cache/providers/lrucache.provider.d.ts +77 -0
  80. package/cache/providers/lrucache.provider.js +228 -0
  81. package/cache/providers/redis-cache.provider.d.ts +1 -0
  82. package/cache/providers/redis-cache.provider.js +8 -6
  83. package/cache/providers/typeorm-cache.provider.d.ts +211 -0
  84. package/cache/providers/typeorm-cache.provider.js +483 -0
  85. package/common/boilerplate.polyfill.d.ts +1 -0
  86. package/common/boilerplate.polyfill.js +18 -1
  87. package/common/helpers/validation-metadata-helper.d.ts +112 -0
  88. package/common/helpers/validation-metadata-helper.js +164 -0
  89. package/common/index.d.ts +1 -0
  90. package/common/index.js +4 -0
  91. package/decorators/examples/field-i18n.example.d.ts +294 -0
  92. package/decorators/examples/field-i18n.example.js +478 -0
  93. package/decorators/field.decorators.d.ts +95 -3
  94. package/decorators/field.decorators.js +152 -18
  95. package/decorators/transform.decorators.d.ts +0 -2
  96. package/decorators/transform.decorators.js +0 -23
  97. package/decorators/translate.decorator.d.ts +26 -0
  98. package/decorators/translate.decorator.js +26 -1
  99. package/email-log/email-log.constants.d.ts +8 -0
  100. package/email-log/email-log.constants.js +11 -0
  101. package/email-log/email-log.module.d.ts +47 -0
  102. package/email-log/email-log.module.js +140 -0
  103. package/email-log/index.d.ts +11 -0
  104. package/email-log/index.js +48 -0
  105. package/email-log/interfaces/email-log-options.interface.d.ts +61 -0
  106. package/email-log/interfaces/email-log-options.interface.js +134 -0
  107. package/email-log/interfaces/email-log-transport.interface.d.ts +20 -0
  108. package/email-log/interfaces/email-log-transport.interface.js +2 -0
  109. package/email-log/interfaces/index.d.ts +2 -0
  110. package/email-log/interfaces/index.js +18 -0
  111. package/email-log/providers/email-provider.d.ts +42 -0
  112. package/email-log/providers/email-provider.js +127 -0
  113. package/email-log/providers/index.d.ts +1 -0
  114. package/email-log/providers/index.js +17 -0
  115. package/email-log/services/email-log-alert.service.d.ts +46 -0
  116. package/email-log/services/email-log-alert.service.js +162 -0
  117. package/email-log/services/email-log-formatter.service.d.ts +78 -0
  118. package/email-log/services/email-log-formatter.service.js +442 -0
  119. package/email-log/services/email-log-logger.service.d.ts +85 -0
  120. package/email-log/services/email-log-logger.service.js +168 -0
  121. package/email-log/services/email-log-rate-limiter.service.d.ts +42 -0
  122. package/email-log/services/email-log-rate-limiter.service.js +110 -0
  123. package/email-log/services/email-log-transport.service.d.ts +80 -0
  124. package/email-log/services/email-log-transport.service.js +271 -0
  125. package/email-log/services/index.d.ts +5 -0
  126. package/email-log/services/index.js +21 -0
  127. package/email-log/transports/index.d.ts +1 -0
  128. package/email-log/transports/index.js +17 -0
  129. package/email-log/transports/pino-email.transport.d.ts +56 -0
  130. package/email-log/transports/pino-email.transport.js +188 -0
  131. package/email-log/utils/index.d.ts +2 -0
  132. package/email-log/utils/index.js +18 -0
  133. package/email-log/utils/log-level.helper.d.ts +46 -0
  134. package/email-log/utils/log-level.helper.js +74 -0
  135. package/email-log/utils/pino-transport.utils.d.ts +135 -0
  136. package/email-log/utils/pino-transport.utils.js +238 -0
  137. package/file-upload/controllers/file-access.controller.d.ts +23 -0
  138. package/file-upload/controllers/file-access.controller.js +128 -0
  139. package/file-upload/decorators/column.decorator.d.ts +151 -0
  140. package/file-upload/decorators/column.decorator.js +273 -0
  141. package/file-upload/decorators/csv-data.decorator.d.ts +30 -0
  142. package/file-upload/decorators/csv-data.decorator.js +85 -0
  143. package/file-upload/decorators/csv-import.decorator.d.ts +34 -0
  144. package/file-upload/decorators/csv-import.decorator.js +24 -0
  145. package/file-upload/decorators/examples/column-mapping.example.d.ts +76 -0
  146. package/file-upload/decorators/examples/column-mapping.example.js +122 -0
  147. package/file-upload/decorators/excel-data.decorator.d.ts +30 -0
  148. package/file-upload/decorators/excel-data.decorator.js +85 -0
  149. package/file-upload/decorators/file-upload.decorator.d.ts +83 -0
  150. package/file-upload/decorators/file-upload.decorator.js +172 -0
  151. package/file-upload/decorators/index.d.ts +5 -0
  152. package/file-upload/decorators/index.js +38 -0
  153. package/file-upload/decorators/process.decorator.d.ts +40 -0
  154. package/file-upload/decorators/process.decorator.js +52 -0
  155. package/file-upload/decorators/validate-data.decorator.d.ts +91 -0
  156. package/file-upload/decorators/validate-data.decorator.js +39 -0
  157. package/file-upload/dto/create-file.dto.d.ts +24 -0
  158. package/file-upload/dto/create-file.dto.js +112 -0
  159. package/file-upload/dto/find-files.dto.d.ts +15 -0
  160. package/file-upload/dto/find-files.dto.js +76 -0
  161. package/file-upload/dto/index.d.ts +4 -0
  162. package/file-upload/dto/index.js +20 -0
  163. package/file-upload/dto/pagination.dto.d.ts +7 -0
  164. package/file-upload/dto/pagination.dto.js +39 -0
  165. package/file-upload/dto/update-file.dto.d.ts +15 -0
  166. package/file-upload/dto/update-file.dto.js +67 -0
  167. package/file-upload/entities/file-metadata.entity.d.ts +25 -0
  168. package/file-upload/entities/file-metadata.entity.js +76 -0
  169. package/file-upload/entities/file.entity.d.ts +114 -0
  170. package/file-upload/entities/file.entity.js +350 -0
  171. package/file-upload/entities/index.d.ts +2 -0
  172. package/file-upload/entities/index.js +18 -0
  173. package/file-upload/enums/file-type.enum.d.ts +72 -0
  174. package/file-upload/enums/file-type.enum.js +212 -0
  175. package/file-upload/exceptions/file-upload.exception.d.ts +57 -0
  176. package/file-upload/exceptions/file-upload.exception.js +120 -0
  177. package/file-upload/exceptions/index.d.ts +1 -0
  178. package/file-upload/exceptions/index.js +17 -0
  179. package/file-upload/file-upload.module.d.ts +89 -0
  180. package/file-upload/file-upload.module.js +292 -0
  181. package/file-upload/index.d.ts +37 -0
  182. package/file-upload/index.js +77 -0
  183. package/file-upload/interceptors/file-upload.interceptor.d.ts +101 -0
  184. package/file-upload/interceptors/file-upload.interceptor.js +594 -0
  185. package/file-upload/interceptors/index.d.ts +1 -0
  186. package/file-upload/interceptors/index.js +17 -0
  187. package/file-upload/interfaces/custom-file-type.interface.d.ts +72 -0
  188. package/file-upload/interfaces/custom-file-type.interface.js +2 -0
  189. package/file-upload/interfaces/file-buffer.interface.d.ts +72 -0
  190. package/file-upload/interfaces/file-buffer.interface.js +2 -0
  191. package/file-upload/interfaces/file-entity.interface.d.ts +142 -0
  192. package/file-upload/interfaces/file-entity.interface.js +28 -0
  193. package/file-upload/interfaces/file-metadata.interface.d.ts +21 -0
  194. package/file-upload/interfaces/file-metadata.interface.js +2 -0
  195. package/file-upload/interfaces/file-processor.interface.d.ts +93 -0
  196. package/file-upload/interfaces/file-processor.interface.js +2 -0
  197. package/file-upload/interfaces/file-upload-options.interface.d.ts +74 -0
  198. package/file-upload/interfaces/file-upload-options.interface.js +5 -0
  199. package/file-upload/interfaces/index.d.ts +7 -0
  200. package/file-upload/interfaces/index.js +24 -0
  201. package/file-upload/interfaces/processor-options.interface.d.ts +102 -0
  202. package/file-upload/interfaces/processor-options.interface.js +2 -0
  203. package/file-upload/interfaces/storage-provider.interface.d.ts +239 -0
  204. package/file-upload/interfaces/storage-provider.interface.js +2 -0
  205. package/file-upload/interfaces/upload-options.interface.d.ts +19 -0
  206. package/file-upload/interfaces/upload-options.interface.js +2 -0
  207. package/file-upload/processors/csv.processor.d.ts +98 -0
  208. package/file-upload/processors/csv.processor.js +391 -0
  209. package/file-upload/processors/excel.processor.d.ts +130 -0
  210. package/file-upload/processors/excel.processor.js +547 -0
  211. package/file-upload/processors/image.processor.d.ts +199 -0
  212. package/file-upload/processors/image.processor.js +377 -0
  213. package/file-upload/providers/index.d.ts +2 -0
  214. package/file-upload/providers/index.js +18 -0
  215. package/file-upload/providers/local-storage.provider.d.ts +98 -0
  216. package/file-upload/providers/local-storage.provider.js +484 -0
  217. package/file-upload/providers/s3-storage.provider.d.ts +87 -0
  218. package/file-upload/providers/s3-storage.provider.js +455 -0
  219. package/file-upload/services/file-signature-validator.service.d.ts +118 -0
  220. package/file-upload/services/file-signature-validator.service.js +376 -0
  221. package/file-upload/services/file.service.d.ts +193 -0
  222. package/file-upload/services/file.service.js +638 -0
  223. package/file-upload/services/index.d.ts +4 -0
  224. package/file-upload/services/index.js +20 -0
  225. package/file-upload/services/malicious-file-detector.service.d.ts +300 -0
  226. package/file-upload/services/malicious-file-detector.service.js +1234 -0
  227. package/file-upload/services/mime-registry.service.d.ts +47 -0
  228. package/file-upload/services/mime-registry.service.js +167 -0
  229. package/file-upload/utils/checksum.util.d.ts +28 -0
  230. package/file-upload/utils/checksum.util.js +65 -0
  231. package/file-upload/utils/dynamic-import.util.d.ts +54 -0
  232. package/file-upload/utils/dynamic-import.util.js +156 -0
  233. package/file-upload/utils/filename.util.d.ts +59 -0
  234. package/file-upload/utils/filename.util.js +184 -0
  235. package/file-upload/utils/filepath.util.d.ts +70 -0
  236. package/file-upload/utils/filepath.util.js +152 -0
  237. package/file-upload/utils/index.d.ts +4 -0
  238. package/file-upload/utils/index.js +20 -0
  239. package/filters/bad-request.filter.d.ts +9 -0
  240. package/filters/bad-request.filter.js +57 -16
  241. package/http-client/config/http-client.config.d.ts +5 -0
  242. package/http-client/config/http-client.config.js +27 -14
  243. package/http-client/decorators/http-client.decorators.d.ts +7 -28
  244. package/http-client/decorators/http-client.decorators.js +124 -99
  245. package/http-client/entities/http-log.entity.d.ts +0 -20
  246. package/http-client/entities/http-log.entity.js +1 -21
  247. package/http-client/examples/advanced-usage.example.d.ts +4 -5
  248. package/http-client/examples/advanced-usage.example.js +7 -59
  249. package/http-client/examples/axios-config-extended.example.d.ts +17 -0
  250. package/http-client/examples/axios-config-extended.example.js +311 -0
  251. package/http-client/examples/flexible-response-example.d.ts +28 -0
  252. package/http-client/examples/flexible-response-example.js +120 -0
  253. package/http-client/examples/index.d.ts +2 -0
  254. package/http-client/examples/index.js +2 -0
  255. package/http-client/examples/proxy-from-environment.example.d.ts +133 -0
  256. package/http-client/examples/proxy-from-environment.example.js +409 -0
  257. package/http-client/examples/ssl-certificate.example.d.ts +47 -0
  258. package/http-client/examples/ssl-certificate.example.js +432 -0
  259. package/http-client/http-client.module.d.ts +43 -2
  260. package/http-client/http-client.module.js +150 -90
  261. package/http-client/index.d.ts +1 -1
  262. package/http-client/interfaces/api-client-config.interface.d.ts +24 -103
  263. package/http-client/interfaces/http-client-config.interface.d.ts +137 -62
  264. package/http-client/services/api-client-registry.service.d.ts +8 -21
  265. package/http-client/services/api-client-registry.service.js +31 -282
  266. package/http-client/services/circuit-breaker.service.d.ts +69 -2
  267. package/http-client/services/circuit-breaker.service.js +185 -7
  268. package/http-client/services/http-client.service.d.ts +85 -23
  269. package/http-client/services/http-client.service.js +512 -168
  270. package/http-client/services/http-log-query.service.js +0 -13
  271. package/http-client/services/index.d.ts +0 -1
  272. package/http-client/services/index.js +0 -1
  273. package/http-client/services/logging.service.d.ts +69 -16
  274. package/http-client/services/logging.service.js +290 -170
  275. package/http-client/utils/call-stack-extractor.util.d.ts +26 -0
  276. package/http-client/utils/call-stack-extractor.util.js +35 -0
  277. package/http-client/utils/context-extractor.util.d.ts +2 -0
  278. package/http-client/utils/context-extractor.util.js +17 -3
  279. package/http-client/utils/curl-generator.util.js +2 -5
  280. package/http-client/utils/index.d.ts +2 -0
  281. package/http-client/utils/index.js +2 -0
  282. package/http-client/utils/proxy-environment.util.d.ts +42 -0
  283. package/http-client/utils/proxy-environment.util.js +154 -0
  284. package/http-client/utils/retry-recorder.util.d.ts +0 -4
  285. package/http-client/utils/retry-recorder.util.js +2 -27
  286. package/http-client/utils/sanitize.util.d.ts +58 -0
  287. package/http-client/utils/sanitize.util.js +188 -0
  288. package/http-client/utils/security-validator.util.d.ts +118 -0
  289. package/http-client/utils/security-validator.util.js +354 -0
  290. package/index.d.ts +4 -1
  291. package/index.js +6 -1
  292. package/interceptors/translation-interceptor.service.d.ts +7 -0
  293. package/interceptors/translation-interceptor.service.js +40 -8
  294. package/ip-filter/constants.d.ts +21 -0
  295. package/ip-filter/constants.js +24 -0
  296. package/ip-filter/decorators/index.d.ts +1 -0
  297. package/ip-filter/decorators/index.js +17 -0
  298. package/ip-filter/decorators/ip-filter.decorator.d.ts +58 -0
  299. package/ip-filter/decorators/ip-filter.decorator.js +79 -0
  300. package/ip-filter/guards/index.d.ts +1 -0
  301. package/ip-filter/guards/index.js +17 -0
  302. package/ip-filter/guards/ip-filter.guard.d.ts +62 -0
  303. package/ip-filter/guards/ip-filter.guard.js +174 -0
  304. package/ip-filter/index.d.ts +7 -0
  305. package/ip-filter/index.js +23 -0
  306. package/ip-filter/interfaces/index.d.ts +4 -0
  307. package/ip-filter/interfaces/index.js +20 -0
  308. package/ip-filter/interfaces/ip-filter-async-options.interface.d.ts +15 -0
  309. package/ip-filter/interfaces/ip-filter-async-options.interface.js +2 -0
  310. package/ip-filter/interfaces/ip-filter-metadata.interface.d.ts +26 -0
  311. package/ip-filter/interfaces/ip-filter-metadata.interface.js +2 -0
  312. package/ip-filter/interfaces/ip-filter-options.interface.d.ts +34 -0
  313. package/ip-filter/interfaces/ip-filter-options.interface.js +2 -0
  314. package/ip-filter/interfaces/ip-rule.interface.d.ts +36 -0
  315. package/ip-filter/interfaces/ip-rule.interface.js +2 -0
  316. package/ip-filter/ip-filter.module.d.ts +55 -0
  317. package/ip-filter/ip-filter.module.js +105 -0
  318. package/ip-filter/services/index.d.ts +1 -0
  319. package/ip-filter/services/index.js +17 -0
  320. package/ip-filter/services/ip-filter.service.d.ts +92 -0
  321. package/ip-filter/services/ip-filter.service.js +238 -0
  322. package/ip-filter/utils/index.d.ts +1 -0
  323. package/ip-filter/utils/index.js +17 -0
  324. package/ip-filter/utils/ip-utils.d.ts +61 -0
  325. package/ip-filter/utils/ip-utils.js +162 -0
  326. package/package.json +34 -29
  327. package/providers/context.provider.d.ts +9 -0
  328. package/providers/context.provider.js +13 -0
  329. package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
  330. package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
  331. package/redis-lock/index.d.ts +2 -0
  332. package/redis-lock/index.js +5 -1
  333. package/redis-lock/lock-heartbeat.service.d.ts +80 -0
  334. package/redis-lock/lock-heartbeat.service.js +232 -0
  335. package/redis-lock/redis-lock.module.d.ts +6 -0
  336. package/redis-lock/redis-lock.module.js +136 -77
  337. package/redis-lock/redis-lock.service.d.ts +31 -0
  338. package/redis-lock/redis-lock.service.js +124 -17
  339. package/setup/bootstrap.setup.d.ts +2 -1
  340. package/setup/bootstrap.setup.js +3 -2
  341. package/setup/index.d.ts +1 -0
  342. package/setup/index.js +1 -0
  343. package/setup/run-in-mode.decorator.d.ts +56 -0
  344. package/setup/run-in-mode.decorator.js +92 -0
  345. package/setup/schedule.decorator.d.ts +1 -0
  346. package/setup/schedule.decorator.js +28 -13
  347. package/setup/worker.decorator.js +10 -1
  348. package/shared/index.d.ts +1 -1
  349. package/shared/index.js +1 -1
  350. package/shared/{serviceRegistryModule.js → service-registry.module.js} +28 -17
  351. package/shared/services/api-config.service.d.ts +41 -0
  352. package/shared/services/api-config.service.js +175 -8
  353. package/shared/services/index.d.ts +0 -1
  354. package/shared/services/index.js +0 -1
  355. package/validators/custom-validate.validator.d.ts +1 -0
  356. package/validators/custom-validate.validator.js +1 -0
  357. package/validators/file-mimetype.validator.d.ts +0 -2
  358. package/validators/file-mimetype.validator.js +4 -6
  359. package/validators/is-exists.validator.d.ts +15 -6
  360. package/validators/is-exists.validator.js +8 -7
  361. package/validators/is-unique.validator.d.ts +22 -7
  362. package/validators/is-unique.validator.js +41 -17
  363. package/vault/vault-config.service.js +1 -1
  364. package/cache/providers/memory-cache.provider.d.ts +0 -49
  365. package/cache/providers/memory-cache.provider.js +0 -197
  366. package/http-client/services/cache.service.d.ts +0 -76
  367. package/http-client/services/cache.service.js +0 -333
  368. package/shared/services/validator.service.d.ts +0 -3
  369. package/shared/services/validator.service.js +0 -20
  370. /package/shared/{serviceRegistryModule.d.ts → service-registry.module.d.ts} +0 -0
@@ -20,24 +20,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  step((generator = generator.apply(thisArg, _arguments || [])).next());
21
21
  });
22
22
  };
23
+ var OperationDescriptionService_1;
23
24
  Object.defineProperty(exports, "__esModule", { value: true });
24
25
  exports.OperationDescriptionService = void 0;
25
26
  const common_1 = require("@nestjs/common");
26
27
  const typeorm_1 = require("@nestjs/typeorm");
27
28
  const typeorm_2 = require("typeorm");
28
29
  const entities_1 = require("../entities");
30
+ const cache_1 = require("../../cache");
29
31
  /**
30
32
  * 操作描述服务
31
33
  * 负责根据模板和参数动态生成多语言描述
32
34
  */
33
- let OperationDescriptionService = class OperationDescriptionService {
34
- constructor(templateRepository, transactionRepository, auditLogRepository, manualOperationRepository) {
35
+ let OperationDescriptionService = OperationDescriptionService_1 = class OperationDescriptionService {
36
+ constructor(templateRepository, transactionRepository, auditLogRepository, manualOperationRepository, cacheService) {
35
37
  this.templateRepository = templateRepository;
36
38
  this.transactionRepository = transactionRepository;
37
39
  this.auditLogRepository = auditLogRepository;
38
40
  this.manualOperationRepository = manualOperationRepository;
39
- // 模板缓存
40
- this.templateCache = new Map();
41
+ this.cacheService = cacheService;
42
+ this.logger = new common_1.Logger(OperationDescriptionService_1.name);
43
+ // 缓存命名空间
44
+ this.CACHE_NAMESPACE = 'audit:template';
45
+ // 缓存TTL(30分钟)
46
+ this.CACHE_TTL = 30 * 60 * 1000;
41
47
  }
42
48
  /**
43
49
  * 动态生成操作名称
@@ -182,14 +188,123 @@ let OperationDescriptionService = class OperationDescriptionService {
182
188
  */
183
189
  batchGetTransactionDescriptions(transactionIds_1) {
184
190
  return __awaiter(this, arguments, void 0, function* (transactionIds, language = 'zh') {
191
+ if (transactionIds.length === 0) {
192
+ return {};
193
+ }
194
+ // 批量查询事务信息
195
+ const transactions = yield this.transactionRepository
196
+ .createQueryBuilder('tx')
197
+ .whereInIds(transactionIds)
198
+ .getMany();
199
+ // 批量查询审计日志
200
+ const auditLogs = yield this.auditLogRepository
201
+ .createQueryBuilder('log')
202
+ .where('log.requestId IN (:...transactionIds)', { transactionIds })
203
+ .orderBy('log.createdAt', 'ASC')
204
+ .getMany();
205
+ // 批量查询手动操作记录
206
+ const manualOperations = yield this.manualOperationRepository
207
+ .createQueryBuilder('op')
208
+ .where('op.transactionId IN (:...transactionIds)', { transactionIds })
209
+ .orderBy('op.createdAt', 'ASC')
210
+ .getMany();
211
+ // 收集所有需要的模板键
212
+ const templateKeys = new Set();
213
+ transactions.forEach(tx => {
214
+ if (tx.operationTemplateKey)
215
+ templateKeys.add(tx.operationTemplateKey);
216
+ });
217
+ auditLogs.forEach(log => {
218
+ if (log.operationTemplateKey)
219
+ templateKeys.add(log.operationTemplateKey);
220
+ });
221
+ manualOperations.forEach(op => {
222
+ if (op.operationTemplateKey)
223
+ templateKeys.add(op.operationTemplateKey);
224
+ });
225
+ // 批量预加载模板
226
+ if (templateKeys.size > 0) {
227
+ yield this.preloadTemplates(Array.from(templateKeys));
228
+ }
229
+ // 按事务ID分组
230
+ const logsByTxId = new Map();
231
+ const opsByTxId = new Map();
232
+ auditLogs.forEach(log => {
233
+ const txId = log.requestId;
234
+ if (!logsByTxId.has(txId))
235
+ logsByTxId.set(txId, []);
236
+ logsByTxId.get(txId).push(log);
237
+ });
238
+ manualOperations.forEach(op => {
239
+ const txId = op.transactionId;
240
+ if (!opsByTxId.has(txId))
241
+ opsByTxId.set(txId, []);
242
+ opsByTxId.get(txId).push(op);
243
+ });
244
+ // 构建结果
185
245
  const results = {};
186
- for (const transactionId of transactionIds) {
246
+ for (const transaction of transactions) {
187
247
  try {
188
- results[transactionId] = yield this.getTransactionDescription(transactionId, language);
248
+ const txLogs = logsByTxId.get(transaction.id) || [];
249
+ const txOps = opsByTxId.get(transaction.id) || [];
250
+ // 生成操作名称和描述
251
+ let operationName;
252
+ let description;
253
+ if (transaction.operationTemplateKey) {
254
+ operationName = yield this.generateOperationName(transaction.operationTemplateKey, language);
255
+ description = yield this.generateDescription(transaction.operationTemplateKey, transaction.descriptionParams || {}, language);
256
+ }
257
+ else {
258
+ const firstLog = txLogs[0];
259
+ if (firstLog && firstLog.operationTemplateKey) {
260
+ operationName = yield this.generateOperationName(firstLog.operationTemplateKey, language);
261
+ description = yield this.generateDescription(firstLog.operationTemplateKey, firstLog.descriptionParams || {}, language);
262
+ }
263
+ else {
264
+ operationName = 'Unknown Operation';
265
+ description = transaction.description || 'Unknown operation';
266
+ }
267
+ }
268
+ // 生成变更详情
269
+ const changes = [];
270
+ // 添加实体变更
271
+ for (const log of txLogs) {
272
+ const changeDescription = log.operationTemplateKey
273
+ ? yield this.generateDescription(log.operationTemplateKey, log.descriptionParams || {}, language)
274
+ : log.description || '';
275
+ const changeDetails = log.changeDetails
276
+ ? yield this.generateChangeDetails(log.changeDetails, language)
277
+ : [];
278
+ changes.push({
279
+ entityName: log.entityType,
280
+ entityId: log.entityId,
281
+ operation: log.operation,
282
+ description: changeDescription,
283
+ details: changeDetails,
284
+ createdAt: log.createdAt,
285
+ });
286
+ }
287
+ // 添加手动操作
288
+ for (const manualOp of txOps) {
289
+ const opName = yield this.generateOperationName(manualOp.operationTemplateKey, language);
290
+ const opDescription = yield this.generateDescription(manualOp.operationTemplateKey, manualOp.descriptionParams, language);
291
+ changes.push({
292
+ type: 'manual',
293
+ description: `${opName}: ${opDescription}`,
294
+ details: manualOp.descriptionParams,
295
+ createdAt: manualOp.createdAt,
296
+ });
297
+ }
298
+ // 按时间排序
299
+ changes.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
300
+ results[transaction.id] = {
301
+ operationName,
302
+ description,
303
+ changes,
304
+ };
189
305
  }
190
306
  catch (error) {
191
- // 忽略错误,继续处理其他事务
192
- console.error(`Failed to get description for transaction ${transactionId}:`, error);
307
+ this.logger.error(`Failed to get description for transaction ${transaction.id}: ${error.message}`, error.stack);
193
308
  }
194
309
  }
195
310
  return results;
@@ -230,32 +345,48 @@ let OperationDescriptionService = class OperationDescriptionService {
230
345
  return String(value);
231
346
  }
232
347
  /**
233
- * 获取操作模板(带缓存)
348
+ * 获取操作模板(使用统一缓存服务)
234
349
  * @param templateKey 模板键
235
350
  * @returns 操作模板
236
351
  */
237
352
  getOperationTemplate(templateKey) {
238
353
  return __awaiter(this, void 0, void 0, function* () {
239
- // 检查缓存
240
- if (this.templateCache.has(templateKey)) {
241
- return this.templateCache.get(templateKey);
242
- }
243
- // 从数据库查询
244
- const template = yield this.templateRepository.findOne({
245
- where: { key: templateKey },
354
+ // 使用统一缓存服务的 getOrSet 方法
355
+ return this.cacheService.getOrSet(templateKey, () => __awaiter(this, void 0, void 0, function* () {
356
+ // 从数据库查询
357
+ const template = yield this.templateRepository.findOne({
358
+ where: { key: templateKey },
359
+ });
360
+ return template;
361
+ }), {
362
+ namespace: this.CACHE_NAMESPACE,
363
+ ttl: this.CACHE_TTL,
364
+ // 只使用内存缓存层,避免序列化开销
365
+ layers: [cache_1.CacheLayer.MEMORY],
246
366
  });
247
- if (template) {
248
- // 缓存模板
249
- this.templateCache.set(templateKey, template);
367
+ });
368
+ }
369
+ /**
370
+ * 获取模板字符串(仅返回模板文本,不填充参数)
371
+ * @param templateKey 模板键
372
+ * @param language 语言
373
+ * @returns 模板字符串
374
+ */
375
+ getTemplate(templateKey_1) {
376
+ return __awaiter(this, arguments, void 0, function* (templateKey, language = 'zh') {
377
+ const template = yield this.getOperationTemplate(templateKey);
378
+ if (!template) {
379
+ return null;
250
380
  }
251
- return template;
381
+ return template.descriptionTemplates[language] || template.descriptionTemplates['zh'] || null;
252
382
  });
253
383
  }
254
384
  /**
255
385
  * 清除模板缓存
256
386
  */
257
387
  clearTemplateCache() {
258
- this.templateCache.clear();
388
+ // 使用统一缓存服务清除
389
+ this.cacheService.deletePattern(`${this.CACHE_NAMESPACE}:*`, [cache_1.CacheLayer.MEMORY]);
259
390
  }
260
391
  /**
261
392
  * 预加载模板到缓存
@@ -267,14 +398,21 @@ let OperationDescriptionService = class OperationDescriptionService {
267
398
  .createQueryBuilder('template')
268
399
  .where('template.key IN (:...keys)', { keys: templateKeys })
269
400
  .getMany();
270
- for (const template of templates) {
271
- this.templateCache.set(template.key, template);
272
- }
401
+ // 批量设置到缓存
402
+ const cacheItems = templates.map(template => ({
403
+ key: template.key,
404
+ value: template,
405
+ }));
406
+ yield this.cacheService.mset(cacheItems, {
407
+ namespace: this.CACHE_NAMESPACE,
408
+ ttl: this.CACHE_TTL,
409
+ layers: [cache_1.CacheLayer.MEMORY],
410
+ });
273
411
  });
274
412
  }
275
413
  };
276
414
  exports.OperationDescriptionService = OperationDescriptionService;
277
- exports.OperationDescriptionService = OperationDescriptionService = __decorate([
415
+ exports.OperationDescriptionService = OperationDescriptionService = OperationDescriptionService_1 = __decorate([
278
416
  (0, common_1.Injectable)(),
279
417
  __param(0, (0, typeorm_1.InjectRepository)(entities_1.OperationTemplateEntity)),
280
418
  __param(1, (0, typeorm_1.InjectRepository)(entities_1.EntityTransactionEntity)),
@@ -283,5 +421,6 @@ exports.OperationDescriptionService = OperationDescriptionService = __decorate([
283
421
  __metadata("design:paramtypes", [typeorm_2.Repository,
284
422
  typeorm_2.Repository,
285
423
  typeorm_2.Repository,
286
- typeorm_2.Repository])
424
+ typeorm_2.Repository,
425
+ cache_1.CacheService])
287
426
  ], OperationDescriptionService);
@@ -12,6 +12,7 @@ export declare class TransactionAuditService {
12
12
  private readonly contextService;
13
13
  private readonly auditService;
14
14
  private readonly multiDbService;
15
+ private readonly logger;
15
16
  constructor(transactionRepository: Repository<EntityTransactionEntity>, contextService: AuditContextService, auditService: EntityAuditService, multiDbService: MultiDatabaseService);
16
17
  /**
17
18
  * 开始事务
@@ -20,6 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  step((generator = generator.apply(thisArg, _arguments || [])).next());
21
21
  });
22
22
  };
23
+ var TransactionAuditService_1;
23
24
  Object.defineProperty(exports, "__esModule", { value: true });
24
25
  exports.TransactionAuditService = void 0;
25
26
  const common_1 = require("@nestjs/common");
@@ -30,15 +31,17 @@ const enums_1 = require("../enums");
30
31
  const audit_context_service_1 = require("./audit-context.service");
31
32
  const entity_audit_service_1 = require("./entity-audit.service");
32
33
  const multi_database_service_1 = require("./multi-database.service");
34
+ const transaction_1 = require("@nest-omni/transaction");
33
35
  /**
34
36
  * 事务审计服务
35
37
  */
36
- let TransactionAuditService = class TransactionAuditService {
38
+ let TransactionAuditService = TransactionAuditService_1 = class TransactionAuditService {
37
39
  constructor(transactionRepository, contextService, auditService, multiDbService) {
38
40
  this.transactionRepository = transactionRepository;
39
41
  this.contextService = contextService;
40
42
  this.auditService = auditService;
41
43
  this.multiDbService = multiDbService;
44
+ this.logger = new common_1.Logger(TransactionAuditService_1.name);
42
45
  }
43
46
  /**
44
47
  * 开始事务
@@ -48,7 +51,7 @@ let TransactionAuditService = class TransactionAuditService {
48
51
  const context = yield this.contextService.getCurrentContext();
49
52
  const transaction = this.transactionRepository.create({
50
53
  description,
51
- status: enums_1.TransactionStatus.PENDING,
54
+ status: enums_1.AuditTransactionStatus.PENDING,
52
55
  entities: [],
53
56
  userId: context.userId,
54
57
  username: context.username,
@@ -72,7 +75,7 @@ let TransactionAuditService = class TransactionAuditService {
72
75
  if (!transaction) {
73
76
  throw new Error(`Transaction not found: ${transactionId}`);
74
77
  }
75
- transaction.status = enums_1.TransactionStatus.COMMITTED;
78
+ transaction.status = enums_1.AuditTransactionStatus.COMMITTED;
76
79
  yield this.transactionRepository.save(transaction);
77
80
  });
78
81
  }
@@ -89,7 +92,7 @@ let TransactionAuditService = class TransactionAuditService {
89
92
  }
90
93
  // 执行回滚操作
91
94
  yield this.performRollback(transaction);
92
- transaction.status = enums_1.TransactionStatus.ROLLED_BACK;
95
+ transaction.status = enums_1.AuditTransactionStatus.ROLLED_BACK;
93
96
  yield this.transactionRepository.save(transaction);
94
97
  });
95
98
  }
@@ -140,7 +143,7 @@ let TransactionAuditService = class TransactionAuditService {
140
143
  let connectionFound = false;
141
144
  for (const connectionName of monitoredConnections) {
142
145
  try {
143
- const dataSource = yield this.multiDbService.getDataSource(connectionName);
146
+ const dataSource = (0, transaction_1.getDataSource)(connectionName);
144
147
  const metadata = dataSource.getMetadata(entity.entityType);
145
148
  if (metadata) {
146
149
  if (!grouped[connectionName]) {
@@ -173,7 +176,7 @@ let TransactionAuditService = class TransactionAuditService {
173
176
  */
174
177
  rollbackEntitiesInConnection(connectionName, entities) {
175
178
  return __awaiter(this, void 0, void 0, function* () {
176
- const dataSource = yield this.multiDbService.getDataSource(connectionName);
179
+ const dataSource = (0, transaction_1.getDataSource)(connectionName);
177
180
  // 使用事务执行回滚
178
181
  yield dataSource.transaction((manager) => __awaiter(this, void 0, void 0, function* () {
179
182
  for (const entity of entities) {
@@ -181,7 +184,7 @@ let TransactionAuditService = class TransactionAuditService {
181
184
  yield this.rollbackSingleEntity(manager, entity, connectionName);
182
185
  }
183
186
  catch (error) {
184
- console.error(`Failed to rollback entity ${entity.entityType}:${entity.entityId} in connection ${connectionName}:`, error);
187
+ this.logger.error(`Failed to rollback entity ${entity.entityType}:${entity.entityId} in connection ${connectionName}: ${error.message}`, error.stack);
185
188
  throw error;
186
189
  }
187
190
  }
@@ -222,7 +225,7 @@ let TransactionAuditService = class TransactionAuditService {
222
225
  }
223
226
  break;
224
227
  default:
225
- console.warn(`Unknown operation type: ${entity.operation}`);
228
+ this.logger.warn(`Unknown operation type: ${entity.operation}`);
226
229
  }
227
230
  });
228
231
  }
@@ -238,7 +241,7 @@ let TransactionAuditService = class TransactionAuditService {
238
241
  }
239
242
  };
240
243
  exports.TransactionAuditService = TransactionAuditService;
241
- exports.TransactionAuditService = TransactionAuditService = __decorate([
244
+ exports.TransactionAuditService = TransactionAuditService = TransactionAuditService_1 = __decorate([
242
245
  (0, common_1.Injectable)(),
243
246
  __param(0, (0, typeorm_1.InjectRepository)(entities_1.EntityTransactionEntity)),
244
247
  __metadata("design:paramtypes", [typeorm_2.Repository,
@@ -9,6 +9,7 @@ export declare class EntityAuditSubscriber implements EntitySubscriberInterface<
9
9
  private readonly entityAuditService;
10
10
  private readonly contextService;
11
11
  private readonly auditStrategy;
12
+ private readonly logger;
12
13
  constructor(entityAuditService: EntityAuditService, contextService: AuditContextService, auditStrategy: DefaultAuditStrategy, dataSource: DataSource);
13
14
  /**
14
15
  * 在实体插入后记录审计日志
@@ -22,6 +23,10 @@ export declare class EntityAuditSubscriber implements EntitySubscriberInterface<
22
23
  * 在实体删除前记录审计日志
23
24
  */
24
25
  beforeRemove(event: RemoveEvent<any>): Promise<void>;
26
+ /**
27
+ * 计算变更字段
28
+ */
29
+ private calculateChangedFields;
25
30
  /**
26
31
  * 检查是否启用了审计
27
32
  */
@@ -17,6 +17,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18
18
  });
19
19
  };
20
+ var EntityAuditSubscriber_1;
20
21
  Object.defineProperty(exports, "__esModule", { value: true });
21
22
  exports.EntityAuditSubscriber = void 0;
22
23
  const common_1 = require("@nestjs/common");
@@ -29,11 +30,12 @@ const decorators_1 = require("../decorators");
29
30
  /**
30
31
  * 实体审计订阅者
31
32
  */
32
- let EntityAuditSubscriber = class EntityAuditSubscriber {
33
+ let EntityAuditSubscriber = EntityAuditSubscriber_1 = class EntityAuditSubscriber {
33
34
  constructor(entityAuditService, contextService, auditStrategy, dataSource) {
34
35
  this.entityAuditService = entityAuditService;
35
36
  this.contextService = contextService;
36
37
  this.auditStrategy = auditStrategy;
38
+ this.logger = new common_1.Logger(EntityAuditSubscriber_1.name);
37
39
  dataSource.subscribers.push(this);
38
40
  }
39
41
  /**
@@ -46,6 +48,11 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
46
48
  return;
47
49
  const entityType = entity.constructor.name;
48
50
  const entityId = entity.id;
51
+ // 空值安全检查:确保实体 ID 存在
52
+ if (!entityId) {
53
+ this.logger.warn(`Entity ID is missing for ${entityType}, skipping audit`);
54
+ return;
55
+ }
49
56
  // 检查是否启用了审计
50
57
  if (!this.isAuditEnabled(entity)) {
51
58
  return;
@@ -57,15 +64,25 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
57
64
  try {
58
65
  // 获取上下文信息
59
66
  const context = yield this.contextService.getCurrentContext();
67
+ const actionContext = this.contextService.getCurrentActionContext();
68
+ // 记录到审计动作上下文
69
+ if (actionContext) {
70
+ this.contextService.recordEntityChangeInAction(entityType, entityId, enums_1.AuditOperation.CREATE);
71
+ // 记录详细的实体变更数据
72
+ this.contextService.recordDetailedEntityChange(entityType, entityId, enums_1.AuditOperation.CREATE, {}, entity, Object.keys(entity));
73
+ }
60
74
  // 记录审计日志
61
75
  yield this.entityAuditService.logEntityChange(entityType, entityId, enums_1.AuditOperation.CREATE, {}, entity, {
62
76
  requestId: context.requestId,
63
77
  requestIp: context.requestIp,
64
78
  userAgent: context.userAgent,
79
+ auditActionId: actionContext === null || actionContext === void 0 ? void 0 : actionContext.actionId,
80
+ auditActionName: actionContext === null || actionContext === void 0 ? void 0 : actionContext.actionName,
81
+ sequenceInAction: (actionContext === null || actionContext === void 0 ? void 0 : actionContext.entityChanges.length) || 0,
65
82
  });
66
83
  }
67
84
  catch (error) {
68
- console.error('Failed to log audit for insert:', error);
85
+ this.logger.error('Failed to log audit for insert:', error);
69
86
  }
70
87
  });
71
88
  }
@@ -80,6 +97,11 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
80
97
  return;
81
98
  const entityType = entity.constructor.name;
82
99
  const entityId = entity.id;
100
+ // 空值安全检查:确保实体 ID 存在
101
+ if (!entityId) {
102
+ this.logger.warn(`Entity ID is missing for ${entityType}, skipping audit`);
103
+ return;
104
+ }
83
105
  // 检查是否启用了审计
84
106
  if (!this.isAuditEnabled(entity)) {
85
107
  return;
@@ -91,15 +113,26 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
91
113
  try {
92
114
  // 获取上下文信息
93
115
  const context = yield this.contextService.getCurrentContext();
116
+ const actionContext = this.contextService.getCurrentActionContext();
117
+ // 记录到审计动作上下文
118
+ if (actionContext) {
119
+ this.contextService.recordEntityChangeInAction(entityType, entityId, enums_1.AuditOperation.UPDATE);
120
+ // 记录详细的实体变更数据
121
+ const changedFields = this.calculateChangedFields(databaseEntity || {}, entity);
122
+ this.contextService.recordDetailedEntityChange(entityType, entityId, enums_1.AuditOperation.UPDATE, databaseEntity || {}, entity, changedFields);
123
+ }
94
124
  // 记录审计日志
95
125
  yield this.entityAuditService.logEntityChange(entityType, entityId, enums_1.AuditOperation.UPDATE, databaseEntity || {}, entity, {
96
126
  requestId: context.requestId,
97
127
  requestIp: context.requestIp,
98
128
  userAgent: context.userAgent,
129
+ auditActionId: actionContext === null || actionContext === void 0 ? void 0 : actionContext.actionId,
130
+ auditActionName: actionContext === null || actionContext === void 0 ? void 0 : actionContext.actionName,
131
+ sequenceInAction: (actionContext === null || actionContext === void 0 ? void 0 : actionContext.entityChanges.length) || 0,
99
132
  });
100
133
  }
101
134
  catch (error) {
102
- console.error('Failed to log audit for update:', error);
135
+ this.logger.error('Failed to log audit for update:', error);
103
136
  }
104
137
  });
105
138
  }
@@ -113,6 +146,11 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
113
146
  return;
114
147
  const entityType = entity.constructor.name;
115
148
  const entityId = entity.id;
149
+ // 空值安全检查:确保实体 ID 存在
150
+ if (!entityId) {
151
+ this.logger.warn(`Entity ID is missing for ${entityType}, skipping audit`);
152
+ return;
153
+ }
116
154
  // 检查是否启用了审计
117
155
  if (!this.isAuditEnabled(entity)) {
118
156
  return;
@@ -124,18 +162,44 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
124
162
  try {
125
163
  // 获取上下文信息
126
164
  const context = yield this.contextService.getCurrentContext();
165
+ const actionContext = this.contextService.getCurrentActionContext();
166
+ // 记录到审计动作上下文
167
+ if (actionContext) {
168
+ this.contextService.recordEntityChangeInAction(entityType, entityId, enums_1.AuditOperation.DELETE);
169
+ // 记录详细的实体变更数据
170
+ this.contextService.recordDetailedEntityChange(entityType, entityId, enums_1.AuditOperation.DELETE, entity, {}, Object.keys(entity));
171
+ }
127
172
  // 记录审计日志
128
173
  yield this.entityAuditService.logEntityChange(entityType, entityId, enums_1.AuditOperation.DELETE, entity, {}, {
129
174
  requestId: context.requestId,
130
175
  requestIp: context.requestIp,
131
176
  userAgent: context.userAgent,
177
+ auditActionId: actionContext === null || actionContext === void 0 ? void 0 : actionContext.actionId,
178
+ auditActionName: actionContext === null || actionContext === void 0 ? void 0 : actionContext.actionName,
179
+ sequenceInAction: (actionContext === null || actionContext === void 0 ? void 0 : actionContext.entityChanges.length) || 0,
132
180
  });
133
181
  }
134
182
  catch (error) {
135
- console.error('Failed to log audit for delete:', error);
183
+ this.logger.error('Failed to log audit for delete:', error);
136
184
  }
137
185
  });
138
186
  }
187
+ /**
188
+ * 计算变更字段
189
+ */
190
+ calculateChangedFields(oldValue, newValue) {
191
+ const changedFields = [];
192
+ const allKeys = new Set([
193
+ ...Object.keys(oldValue || {}),
194
+ ...Object.keys(newValue || {}),
195
+ ]);
196
+ for (const key of allKeys) {
197
+ if (JSON.stringify(oldValue[key]) !== JSON.stringify(newValue[key])) {
198
+ changedFields.push(key);
199
+ }
200
+ }
201
+ return changedFields;
202
+ }
139
203
  /**
140
204
  * 检查是否启用了审计
141
205
  */
@@ -154,7 +218,7 @@ let EntityAuditSubscriber = class EntityAuditSubscriber {
154
218
  }
155
219
  };
156
220
  exports.EntityAuditSubscriber = EntityAuditSubscriber;
157
- exports.EntityAuditSubscriber = EntityAuditSubscriber = __decorate([
221
+ exports.EntityAuditSubscriber = EntityAuditSubscriber = EntityAuditSubscriber_1 = __decorate([
158
222
  (0, common_1.Injectable)(),
159
223
  (0, typeorm_1.EventSubscriber)(),
160
224
  __metadata("design:paramtypes", [entity_audit_service_1.EntityAuditService,
@@ -1,5 +1,4 @@
1
1
  import { DynamicModule, OnModuleInit } from '@nestjs/common';
2
- import type { DataSource } from 'typeorm';
3
2
  import type { Redis } from 'ioredis';
4
3
  import { CacheService } from './cache.service';
5
4
  /**
@@ -21,18 +20,18 @@ export interface CacheModuleOptions {
21
20
  */
22
21
  redisClient?: Redis;
23
22
  /**
24
- * TypeORM DataSource for DbDependency
25
- * If not provided, DbDependency will throw error when used
26
- */
27
- dataSource?: DataSource;
28
- /**
29
- * Default TTL for memory cache in milliseconds
23
+ * Default TTL for LRU cache in milliseconds
30
24
  */
31
25
  memoryTtl?: number;
32
26
  /**
33
- * Namespace for memory cache
27
+ * Namespace for LRU cache
34
28
  */
35
29
  memoryNamespace?: string;
30
+ /**
31
+ * Max size for LRU cache
32
+ * @default 500
33
+ */
34
+ lruMaxSize?: number;
36
35
  /**
37
36
  * Enable compression for cache values
38
37
  * @default false
@@ -80,10 +80,10 @@ let CacheModule = CacheModule_1 = class CacheModule {
80
80
  * Register cache module with options
81
81
  */
82
82
  static forRoot(options = {}) {
83
- const { isGlobal = true, redisClient, dataSource, memoryTtl, memoryNamespace, enableCompression = false, compressionThreshold = 1024, } = options;
84
- // Set DataSource for DbDependency if provided
85
- if (dataSource) {
86
- dependencies_1.DbDependency.setDataSource(dataSource);
83
+ const { isGlobal = true, redisClient, memoryTtl, memoryNamespace, lruMaxSize = 500, enableCompression = false, compressionThreshold = 1024, } = options;
84
+ // Set Redis client for TagDependency for distributed tag support
85
+ if (redisClient) {
86
+ dependencies_1.TagDependency.setRedisClient(redisClient);
87
87
  }
88
88
  return {
89
89
  module: CacheModule_1,
@@ -92,10 +92,11 @@ let CacheModule = CacheModule_1 = class CacheModule {
92
92
  // Providers
93
93
  providers_1.ClsCacheProvider,
94
94
  {
95
- provide: providers_1.MemoryCacheProvider,
96
- useValue: new providers_1.MemoryCacheProvider({
95
+ provide: providers_1.LRUCacheProvider,
96
+ useValue: new providers_1.LRUCacheProvider({
97
+ maxSize: lruMaxSize,
97
98
  ttl: memoryTtl,
98
- namespace: memoryNamespace,
99
+ namespace: memoryNamespace || 'cache:lru',
99
100
  }),
100
101
  },
101
102
  // Redis client provider (optional)
@@ -159,15 +160,16 @@ let CacheModule = CacheModule_1 = class CacheModule {
159
160
  // Providers
160
161
  providers_1.ClsCacheProvider,
161
162
  {
162
- provide: providers_1.MemoryCacheProvider,
163
+ provide: providers_1.LRUCacheProvider,
163
164
  useFactory: (moduleOptions) => {
164
- // Set DataSource for DbDependency if provided
165
- if (moduleOptions.dataSource) {
166
- dependencies_1.DbDependency.setDataSource(moduleOptions.dataSource);
165
+ // Set Redis client for TagDependency for distributed tag support
166
+ if (moduleOptions.redisClient) {
167
+ dependencies_1.TagDependency.setRedisClient(moduleOptions.redisClient);
167
168
  }
168
- return new providers_1.MemoryCacheProvider({
169
+ return new providers_1.LRUCacheProvider({
170
+ maxSize: moduleOptions.lruMaxSize || 500,
169
171
  ttl: moduleOptions.memoryTtl,
170
- namespace: moduleOptions.memoryNamespace,
172
+ namespace: moduleOptions.memoryNamespace || 'cache:lru',
171
173
  });
172
174
  },
173
175
  inject: ['CACHE_MODULE_OPTIONS'],