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

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 (441) hide show
  1. package/audit/audit.module.d.ts +11 -0
  2. package/audit/audit.module.js +65 -1
  3. package/audit/controllers/audit.controller.d.ts +81 -1
  4. package/audit/controllers/audit.controller.js +67 -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 +38 -0
  10. package/audit/decorators/audit-operation.decorator.js +42 -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-action-query.dto.d.ts +13 -0
  16. package/audit/dto/audit-action-query.dto.js +77 -0
  17. package/audit/dto/audit-log-query.dto.d.ts +3 -0
  18. package/audit/dto/audit-log-query.dto.js +3 -0
  19. package/audit/dto/begin-transaction.dto.d.ts +3 -0
  20. package/audit/dto/begin-transaction.dto.js +3 -0
  21. package/audit/dto/compare-entities.dto.d.ts +3 -0
  22. package/audit/dto/compare-entities.dto.js +3 -0
  23. package/audit/dto/index.d.ts +1 -0
  24. package/audit/dto/index.js +1 -0
  25. package/audit/dto/pre-check-restore.dto.d.ts +3 -0
  26. package/audit/dto/pre-check-restore.dto.js +3 -0
  27. package/audit/dto/restore-entity.dto.d.ts +3 -0
  28. package/audit/dto/restore-entity.dto.js +3 -0
  29. package/audit/entities/audit-action-summary.entity.d.ts +23 -0
  30. package/audit/entities/audit-action-summary.entity.js +101 -0
  31. package/audit/entities/entity-audit-log.entity.d.ts +10 -2
  32. package/audit/entities/entity-audit-log.entity.js +48 -9
  33. package/audit/entities/entity-transaction.entity.d.ts +11 -2
  34. package/audit/entities/entity-transaction.entity.js +42 -3
  35. package/audit/entities/index.d.ts +3 -0
  36. package/audit/entities/index.js +3 -0
  37. package/audit/entities/manual-operation-log.entity.d.ts +4 -2
  38. package/audit/entities/manual-operation-log.entity.js +12 -9
  39. package/audit/entities/operation-template.entity.d.ts +4 -0
  40. package/audit/entities/operation-template.entity.js +4 -0
  41. package/audit/enums/audit.enums.d.ts +29 -6
  42. package/audit/enums/audit.enums.js +31 -7
  43. package/audit/examples/decorator-value-mapping.example.d.ts +70 -0
  44. package/audit/examples/decorator-value-mapping.example.js +414 -0
  45. package/audit/index.d.ts +5 -1
  46. package/audit/index.js +38 -1
  47. package/audit/interceptors/audit-action.interceptor.d.ts +38 -0
  48. package/audit/interceptors/audit-action.interceptor.js +215 -0
  49. package/audit/interceptors/audit.interceptor.d.ts +16 -0
  50. package/audit/interceptors/audit.interceptor.js +41 -11
  51. package/audit/interceptors/index.d.ts +1 -0
  52. package/audit/interceptors/index.js +1 -0
  53. package/audit/interfaces/audit.interfaces.d.ts +174 -4
  54. package/audit/services/audit-action.service.d.ts +141 -0
  55. package/audit/services/audit-action.service.js +244 -0
  56. package/audit/services/audit-context.service.d.ts +106 -0
  57. package/audit/services/audit-context.service.js +185 -0
  58. package/audit/services/audit-strategy.service.d.ts +6 -0
  59. package/audit/services/audit-strategy.service.js +13 -0
  60. package/audit/services/entity-audit.service.d.ts +273 -5
  61. package/audit/services/entity-audit.service.js +840 -60
  62. package/audit/services/index.d.ts +3 -0
  63. package/audit/services/index.js +3 -0
  64. package/audit/services/manual-audit-log.service.d.ts +133 -9
  65. package/audit/services/manual-audit-log.service.js +157 -42
  66. package/audit/services/multi-database.service.d.ts +9 -2
  67. package/audit/services/multi-database.service.js +9 -21
  68. package/audit/services/operation-description.service.d.ts +71 -2
  69. package/audit/services/operation-description.service.js +231 -20
  70. package/audit/services/transaction-audit.service.d.ts +30 -0
  71. package/audit/services/transaction-audit.service.js +53 -5
  72. package/audit/subscribers/entity-audit.subscriber.d.ts +20 -0
  73. package/audit/subscribers/entity-audit.subscriber.js +98 -6
  74. package/cache/cache-metrics.service.d.ts +67 -0
  75. package/cache/cache-metrics.service.js +68 -4
  76. package/cache/cache-serialization.service.d.ts +31 -0
  77. package/cache/cache-serialization.service.js +25 -0
  78. package/cache/cache.constants.d.ts +9 -0
  79. package/cache/cache.constants.js +9 -0
  80. package/cache/cache.health.d.ts +26 -0
  81. package/cache/cache.health.js +30 -0
  82. package/cache/cache.module.d.ts +87 -2
  83. package/cache/cache.module.js +84 -11
  84. package/cache/cache.service.d.ts +143 -3
  85. package/cache/cache.service.js +173 -4
  86. package/cache/cache.warmup.service.d.ts +39 -0
  87. package/cache/cache.warmup.service.js +32 -0
  88. package/cache/decorators/cache-evict.decorator.d.ts +47 -0
  89. package/cache/decorators/cache-evict.decorator.js +56 -0
  90. package/cache/decorators/cache-put.decorator.d.ts +34 -0
  91. package/cache/decorators/cache-put.decorator.js +39 -0
  92. package/cache/decorators/cacheable.decorator.d.ts +40 -0
  93. package/cache/decorators/cacheable.decorator.js +55 -0
  94. package/cache/dependencies/callback.dependency.d.ts +33 -0
  95. package/cache/dependencies/callback.dependency.js +39 -1
  96. package/cache/dependencies/chain.dependency.d.ts +28 -0
  97. package/cache/dependencies/chain.dependency.js +34 -0
  98. package/cache/dependencies/db.dependency.d.ts +83 -7
  99. package/cache/dependencies/db.dependency.js +89 -14
  100. package/cache/dependencies/file.dependency.d.ts +32 -0
  101. package/cache/dependencies/file.dependency.js +34 -0
  102. package/cache/dependencies/tag.dependency.d.ts +75 -4
  103. package/cache/dependencies/tag.dependency.js +145 -11
  104. package/cache/dependencies/time.dependency.d.ts +43 -0
  105. package/cache/dependencies/time.dependency.js +43 -0
  106. package/cache/entities/index.d.ts +1 -0
  107. package/cache/entities/index.js +17 -0
  108. package/cache/entities/typeorm-cache.entity.d.ts +71 -0
  109. package/cache/entities/typeorm-cache.entity.js +110 -0
  110. package/cache/examples/basic-usage.d.ts +15 -0
  111. package/cache/examples/basic-usage.js +62 -8
  112. package/cache/index.d.ts +2 -1
  113. package/cache/index.js +28 -2
  114. package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
  115. package/cache/interfaces/cache-options.interface.d.ts +89 -0
  116. package/cache/interfaces/cache-options.interface.js +6 -0
  117. package/cache/interfaces/cache-provider.interface.d.ts +78 -0
  118. package/cache/providers/base-cache.provider.d.ts +14 -0
  119. package/cache/providers/base-cache.provider.js +16 -0
  120. package/cache/providers/cls-cache.provider.d.ts +20 -0
  121. package/cache/providers/cls-cache.provider.js +28 -0
  122. package/cache/providers/index.d.ts +2 -1
  123. package/cache/providers/index.js +2 -1
  124. package/cache/providers/lrucache.provider.d.ts +76 -0
  125. package/cache/providers/lrucache.provider.js +226 -0
  126. package/cache/providers/redis-cache.provider.d.ts +26 -0
  127. package/cache/providers/redis-cache.provider.js +29 -0
  128. package/cache/providers/typeorm-cache.provider.d.ts +211 -0
  129. package/cache/providers/typeorm-cache.provider.js +483 -0
  130. package/cache/utils/dependency-manager.util.d.ts +52 -0
  131. package/cache/utils/dependency-manager.util.js +59 -0
  132. package/cache/utils/key-generator.util.d.ts +42 -0
  133. package/cache/utils/key-generator.util.js +53 -1
  134. package/common/abstract.entity.d.ts +14 -0
  135. package/common/abstract.entity.js +14 -0
  136. package/common/boilerplate.polyfill.d.ts +143 -0
  137. package/common/boilerplate.polyfill.js +35 -1
  138. package/common/dto/dto-container.d.ts +16 -0
  139. package/common/dto/dto-container.js +20 -0
  140. package/common/dto/dto-decorators.d.ts +18 -0
  141. package/common/dto/dto-decorators.js +14 -0
  142. package/common/dto/dto-extensions.d.ts +11 -0
  143. package/common/dto/dto-extensions.js +9 -0
  144. package/common/dto/dto-service-accessor.d.ts +17 -0
  145. package/common/dto/dto-service-accessor.js +18 -0
  146. package/common/dto/dto-transformer.d.ts +12 -0
  147. package/common/dto/dto-transformer.js +9 -0
  148. package/common/dto/index.js +2 -0
  149. package/common/examples/paginate-and-map.example.d.ts +6 -0
  150. package/common/examples/paginate-and-map.example.js +26 -0
  151. package/common/helpers/validation-metadata-helper.d.ts +55 -0
  152. package/common/helpers/validation-metadata-helper.js +60 -0
  153. package/common/index.d.ts +1 -0
  154. package/common/index.js +4 -0
  155. package/common/utils.d.ts +15 -0
  156. package/common/utils.js +15 -0
  157. package/constants/language-code.js +1 -0
  158. package/decorators/field.decorators.d.ts +72 -3
  159. package/decorators/field.decorators.js +155 -19
  160. package/decorators/property.decorators.js +1 -0
  161. package/decorators/public-route.decorator.js +1 -0
  162. package/decorators/transform.decorators.d.ts +27 -2
  163. package/decorators/transform.decorators.js +29 -23
  164. package/decorators/translate.decorator.js +1 -0
  165. package/decorators/user.decorator.js +1 -0
  166. package/decorators/validator.decorators.d.ts +8 -18
  167. package/decorators/validator.decorators.js +22 -190
  168. package/file-upload/controllers/file-access.controller.d.ts +23 -0
  169. package/file-upload/controllers/file-access.controller.js +128 -0
  170. package/file-upload/decorators/column.decorator.d.ts +151 -0
  171. package/file-upload/decorators/column.decorator.js +273 -0
  172. package/file-upload/decorators/csv-data.decorator.d.ts +30 -0
  173. package/file-upload/decorators/csv-data.decorator.js +85 -0
  174. package/file-upload/decorators/csv-import.decorator.d.ts +34 -0
  175. package/file-upload/decorators/csv-import.decorator.js +24 -0
  176. package/file-upload/decorators/examples/column-mapping.example.d.ts +76 -0
  177. package/file-upload/decorators/examples/column-mapping.example.js +122 -0
  178. package/file-upload/decorators/excel-data.decorator.d.ts +30 -0
  179. package/file-upload/decorators/excel-data.decorator.js +85 -0
  180. package/file-upload/decorators/file-upload.decorator.d.ts +83 -0
  181. package/file-upload/decorators/file-upload.decorator.js +172 -0
  182. package/file-upload/decorators/index.d.ts +5 -0
  183. package/file-upload/decorators/index.js +38 -0
  184. package/file-upload/decorators/process.decorator.d.ts +40 -0
  185. package/file-upload/decorators/process.decorator.js +52 -0
  186. package/file-upload/decorators/validate-data.decorator.d.ts +91 -0
  187. package/file-upload/decorators/validate-data.decorator.js +39 -0
  188. package/file-upload/dto/create-file.dto.d.ts +24 -0
  189. package/file-upload/dto/create-file.dto.js +112 -0
  190. package/file-upload/dto/find-files.dto.d.ts +15 -0
  191. package/file-upload/dto/find-files.dto.js +76 -0
  192. package/file-upload/dto/index.d.ts +4 -0
  193. package/file-upload/dto/index.js +20 -0
  194. package/file-upload/dto/pagination.dto.d.ts +7 -0
  195. package/file-upload/dto/pagination.dto.js +39 -0
  196. package/file-upload/dto/update-file.dto.d.ts +15 -0
  197. package/file-upload/dto/update-file.dto.js +67 -0
  198. package/file-upload/entities/file-metadata.entity.d.ts +25 -0
  199. package/file-upload/entities/file-metadata.entity.js +76 -0
  200. package/file-upload/entities/file.entity.d.ts +114 -0
  201. package/file-upload/entities/file.entity.js +350 -0
  202. package/file-upload/entities/index.d.ts +2 -0
  203. package/file-upload/entities/index.js +18 -0
  204. package/file-upload/enums/file-type.enum.d.ts +72 -0
  205. package/file-upload/enums/file-type.enum.js +212 -0
  206. package/file-upload/exceptions/file-upload.exception.d.ts +57 -0
  207. package/file-upload/exceptions/file-upload.exception.js +120 -0
  208. package/file-upload/exceptions/index.d.ts +1 -0
  209. package/file-upload/exceptions/index.js +17 -0
  210. package/file-upload/file-upload.module.d.ts +89 -0
  211. package/file-upload/file-upload.module.js +292 -0
  212. package/file-upload/index.d.ts +37 -0
  213. package/file-upload/index.js +77 -0
  214. package/file-upload/interceptors/file-upload.interceptor.d.ts +101 -0
  215. package/file-upload/interceptors/file-upload.interceptor.js +594 -0
  216. package/file-upload/interceptors/index.d.ts +1 -0
  217. package/file-upload/interceptors/index.js +17 -0
  218. package/file-upload/interfaces/custom-file-type.interface.d.ts +72 -0
  219. package/file-upload/interfaces/custom-file-type.interface.js +2 -0
  220. package/file-upload/interfaces/file-buffer.interface.d.ts +72 -0
  221. package/file-upload/interfaces/file-buffer.interface.js +2 -0
  222. package/file-upload/interfaces/file-entity.interface.d.ts +142 -0
  223. package/file-upload/interfaces/file-entity.interface.js +28 -0
  224. package/file-upload/interfaces/file-metadata.interface.d.ts +21 -0
  225. package/file-upload/interfaces/file-metadata.interface.js +2 -0
  226. package/file-upload/interfaces/file-processor.interface.d.ts +93 -0
  227. package/file-upload/interfaces/file-processor.interface.js +2 -0
  228. package/file-upload/interfaces/file-upload-options.interface.d.ts +74 -0
  229. package/file-upload/interfaces/file-upload-options.interface.js +5 -0
  230. package/file-upload/interfaces/index.d.ts +7 -0
  231. package/file-upload/interfaces/index.js +24 -0
  232. package/file-upload/interfaces/processor-options.interface.d.ts +102 -0
  233. package/file-upload/interfaces/processor-options.interface.js +2 -0
  234. package/file-upload/interfaces/storage-provider.interface.d.ts +239 -0
  235. package/file-upload/interfaces/storage-provider.interface.js +2 -0
  236. package/file-upload/interfaces/upload-options.interface.d.ts +19 -0
  237. package/file-upload/interfaces/upload-options.interface.js +2 -0
  238. package/file-upload/processors/csv.processor.d.ts +98 -0
  239. package/file-upload/processors/csv.processor.js +391 -0
  240. package/file-upload/processors/excel.processor.d.ts +130 -0
  241. package/file-upload/processors/excel.processor.js +547 -0
  242. package/file-upload/processors/image.processor.d.ts +199 -0
  243. package/file-upload/processors/image.processor.js +377 -0
  244. package/file-upload/providers/index.d.ts +2 -0
  245. package/file-upload/providers/index.js +18 -0
  246. package/file-upload/providers/local-storage.provider.d.ts +98 -0
  247. package/file-upload/providers/local-storage.provider.js +484 -0
  248. package/file-upload/providers/s3-storage.provider.d.ts +87 -0
  249. package/file-upload/providers/s3-storage.provider.js +455 -0
  250. package/file-upload/services/file-signature-validator.service.d.ts +118 -0
  251. package/file-upload/services/file-signature-validator.service.js +376 -0
  252. package/file-upload/services/file.service.d.ts +193 -0
  253. package/file-upload/services/file.service.js +638 -0
  254. package/file-upload/services/index.d.ts +4 -0
  255. package/file-upload/services/index.js +20 -0
  256. package/file-upload/services/malicious-file-detector.service.d.ts +300 -0
  257. package/file-upload/services/malicious-file-detector.service.js +1234 -0
  258. package/file-upload/services/mime-registry.service.d.ts +47 -0
  259. package/file-upload/services/mime-registry.service.js +167 -0
  260. package/file-upload/utils/checksum.util.d.ts +28 -0
  261. package/file-upload/utils/checksum.util.js +65 -0
  262. package/file-upload/utils/dynamic-import.util.d.ts +54 -0
  263. package/file-upload/utils/dynamic-import.util.js +156 -0
  264. package/file-upload/utils/filename.util.d.ts +59 -0
  265. package/file-upload/utils/filename.util.js +184 -0
  266. package/file-upload/utils/filepath.util.d.ts +70 -0
  267. package/file-upload/utils/filepath.util.js +152 -0
  268. package/file-upload/utils/index.d.ts +4 -0
  269. package/file-upload/utils/index.js +20 -0
  270. package/filters/bad-request.filter.js +19 -4
  271. package/filters/constraint-errors.js +1 -0
  272. package/helpers/common.helper.d.ts +13 -0
  273. package/helpers/common.helper.js +13 -0
  274. package/http-client/config/http-client.config.d.ts +20 -0
  275. package/http-client/config/http-client.config.js +48 -21
  276. package/http-client/decorators/http-client.decorators.d.ts +55 -14
  277. package/http-client/decorators/http-client.decorators.js +154 -78
  278. package/http-client/entities/http-log.entity.d.ts +217 -8
  279. package/http-client/entities/http-log.entity.js +7 -22
  280. package/http-client/errors/http-client.errors.d.ts +57 -0
  281. package/http-client/errors/http-client.errors.js +58 -0
  282. package/http-client/examples/advanced-usage.example.d.ts +40 -0
  283. package/http-client/examples/advanced-usage.example.js +53 -61
  284. package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
  285. package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
  286. package/http-client/examples/basic-usage.example.d.ts +60 -0
  287. package/http-client/examples/basic-usage.example.js +60 -0
  288. package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
  289. package/http-client/examples/multi-api-configuration.example.js +76 -5
  290. package/http-client/examples/proxy-from-environment.example.d.ts +133 -0
  291. package/http-client/examples/proxy-from-environment.example.js +409 -0
  292. package/http-client/http-client.module.d.ts +48 -2
  293. package/http-client/http-client.module.js +147 -68
  294. package/http-client/index.d.ts +1 -1
  295. package/http-client/index.js +8 -0
  296. package/http-client/interfaces/api-client-config.interface.d.ts +80 -45
  297. package/http-client/interfaces/api-client-config.interface.js +3 -0
  298. package/http-client/interfaces/http-client-config.interface.d.ts +109 -52
  299. package/http-client/services/api-client-registry.service.d.ts +50 -11
  300. package/http-client/services/api-client-registry.service.js +90 -250
  301. package/http-client/services/circuit-breaker.service.d.ts +115 -2
  302. package/http-client/services/circuit-breaker.service.js +237 -7
  303. package/http-client/services/http-client.service.d.ts +124 -14
  304. package/http-client/services/http-client.service.js +437 -148
  305. package/http-client/services/http-log-query.service.d.ts +83 -0
  306. package/http-client/services/http-log-query.service.js +121 -13
  307. package/http-client/services/http-replay.service.d.ts +101 -0
  308. package/http-client/services/http-replay.service.js +86 -0
  309. package/http-client/services/index.d.ts +0 -1
  310. package/http-client/services/index.js +0 -1
  311. package/http-client/services/log-cleanup.service.d.ts +63 -0
  312. package/http-client/services/log-cleanup.service.js +54 -2
  313. package/http-client/services/logging.service.d.ts +116 -7
  314. package/http-client/services/logging.service.js +349 -86
  315. package/http-client/utils/call-stack-extractor.util.d.ts +63 -0
  316. package/http-client/utils/call-stack-extractor.util.js +83 -0
  317. package/http-client/utils/context-extractor.util.d.ts +49 -0
  318. package/http-client/utils/context-extractor.util.js +54 -0
  319. package/http-client/utils/curl-generator.util.d.ts +21 -0
  320. package/http-client/utils/curl-generator.util.js +44 -3
  321. package/http-client/utils/index.d.ts +1 -0
  322. package/http-client/utils/index.js +1 -0
  323. package/http-client/utils/proxy-environment.util.d.ts +42 -0
  324. package/http-client/utils/proxy-environment.util.js +148 -0
  325. package/http-client/utils/request-id.util.d.ts +18 -0
  326. package/http-client/utils/request-id.util.js +20 -0
  327. package/http-client/utils/retry-recorder.util.d.ts +42 -0
  328. package/http-client/utils/retry-recorder.util.js +44 -0
  329. package/http-client/utils/security-validator.util.d.ts +118 -0
  330. package/http-client/utils/security-validator.util.js +352 -0
  331. package/index.d.ts +3 -1
  332. package/index.js +12 -1
  333. package/interceptors/translation-interceptor.service.js +5 -0
  334. package/ip-filter/constants.d.ts +21 -0
  335. package/ip-filter/constants.js +24 -0
  336. package/ip-filter/decorators/index.d.ts +1 -0
  337. package/ip-filter/decorators/index.js +17 -0
  338. package/ip-filter/decorators/ip-filter.decorator.d.ts +58 -0
  339. package/ip-filter/decorators/ip-filter.decorator.js +79 -0
  340. package/ip-filter/guards/index.d.ts +1 -0
  341. package/ip-filter/guards/index.js +17 -0
  342. package/ip-filter/guards/ip-filter.guard.d.ts +62 -0
  343. package/ip-filter/guards/ip-filter.guard.js +174 -0
  344. package/ip-filter/index.d.ts +7 -0
  345. package/ip-filter/index.js +23 -0
  346. package/ip-filter/interfaces/index.d.ts +4 -0
  347. package/ip-filter/interfaces/index.js +20 -0
  348. package/ip-filter/interfaces/ip-filter-async-options.interface.d.ts +15 -0
  349. package/ip-filter/interfaces/ip-filter-async-options.interface.js +2 -0
  350. package/ip-filter/interfaces/ip-filter-metadata.interface.d.ts +26 -0
  351. package/ip-filter/interfaces/ip-filter-metadata.interface.js +2 -0
  352. package/ip-filter/interfaces/ip-filter-options.interface.d.ts +34 -0
  353. package/ip-filter/interfaces/ip-filter-options.interface.js +2 -0
  354. package/ip-filter/interfaces/ip-rule.interface.d.ts +36 -0
  355. package/ip-filter/interfaces/ip-rule.interface.js +2 -0
  356. package/ip-filter/ip-filter.module.d.ts +55 -0
  357. package/ip-filter/ip-filter.module.js +105 -0
  358. package/ip-filter/services/index.d.ts +1 -0
  359. package/ip-filter/services/index.js +17 -0
  360. package/ip-filter/services/ip-filter.service.d.ts +92 -0
  361. package/ip-filter/services/ip-filter.service.js +238 -0
  362. package/ip-filter/utils/index.d.ts +1 -0
  363. package/ip-filter/utils/index.js +17 -0
  364. package/ip-filter/utils/ip-utils.d.ts +61 -0
  365. package/ip-filter/utils/ip-utils.js +162 -0
  366. package/package.json +32 -29
  367. package/providers/context.provider.d.ts +9 -0
  368. package/providers/context.provider.js +15 -0
  369. package/providers/generator.provider.d.ts +4 -0
  370. package/providers/generator.provider.js +4 -0
  371. package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
  372. package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
  373. package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
  374. package/redis-lock/examples/lock-strategy.examples.js +130 -15
  375. package/redis-lock/index.d.ts +2 -0
  376. package/redis-lock/index.js +8 -1
  377. package/redis-lock/lock-heartbeat.service.d.ts +80 -0
  378. package/redis-lock/lock-heartbeat.service.js +232 -0
  379. package/redis-lock/redis-lock.decorator.d.ts +101 -0
  380. package/redis-lock/redis-lock.decorator.js +120 -0
  381. package/redis-lock/redis-lock.module.d.ts +66 -0
  382. package/redis-lock/redis-lock.module.js +175 -70
  383. package/redis-lock/redis-lock.service.d.ts +282 -0
  384. package/redis-lock/redis-lock.service.js +343 -20
  385. package/setup/bootstrap.setup.d.ts +2 -1
  386. package/setup/bootstrap.setup.js +22 -1
  387. package/setup/index.d.ts +1 -0
  388. package/setup/index.js +1 -0
  389. package/setup/mode.setup.d.ts +44 -0
  390. package/setup/mode.setup.js +44 -0
  391. package/setup/run-in-mode.decorator.d.ts +56 -0
  392. package/setup/run-in-mode.decorator.js +92 -0
  393. package/setup/schedule.decorator.d.ts +227 -0
  394. package/setup/schedule.decorator.js +240 -12
  395. package/setup/worker.decorator.d.ts +86 -0
  396. package/setup/worker.decorator.js +97 -0
  397. package/shared/index.d.ts +1 -1
  398. package/shared/index.js +1 -1
  399. package/shared/{serviceRegistryModule.js → service-registry.module.js} +19 -18
  400. package/shared/services/api-config.service.d.ts +3 -0
  401. package/shared/services/api-config.service.js +21 -9
  402. package/shared/services/index.d.ts +0 -1
  403. package/shared/services/index.js +0 -1
  404. package/validator-json/decorators.d.ts +17 -0
  405. package/validator-json/decorators.js +17 -2
  406. package/validator-json/default.d.ts +6 -0
  407. package/validator-json/default.js +30 -2
  408. package/validator-json/defaultConverters.js +1 -0
  409. package/validator-json/options.d.ts +23 -0
  410. package/validators/common-validators.d.ts +143 -0
  411. package/validators/common-validators.js +249 -0
  412. package/validators/custom-validate.examples.d.ts +23 -0
  413. package/validators/custom-validate.examples.js +78 -6
  414. package/validators/custom-validate.validator.d.ts +108 -0
  415. package/validators/custom-validate.validator.js +85 -0
  416. package/validators/file-mimetype.validator.d.ts +0 -2
  417. package/validators/file-mimetype.validator.js +4 -6
  418. package/validators/index.d.ts +1 -0
  419. package/validators/index.js +1 -0
  420. package/validators/is-exists.validator.d.ts +26 -6
  421. package/validators/is-exists.validator.js +30 -7
  422. package/validators/is-unique.validator.d.ts +33 -7
  423. package/validators/is-unique.validator.js +59 -17
  424. package/validators/skip-empty.validator.d.ts +5 -0
  425. package/validators/skip-empty.validator.js +5 -0
  426. package/vault/interfaces/vault-options.interface.d.ts +9 -0
  427. package/vault/vault-config.loader.d.ts +30 -0
  428. package/vault/vault-config.loader.js +48 -1
  429. package/vault/vault-config.service.d.ts +53 -0
  430. package/vault/vault-config.service.js +57 -0
  431. package/vault/vault.module.d.ts +4 -0
  432. package/vault/vault.module.js +4 -0
  433. package/cache/providers/memory-cache.provider.d.ts +0 -26
  434. package/cache/providers/memory-cache.provider.js +0 -171
  435. package/decorators/examples/validation-decorators.example.d.ts +0 -69
  436. package/decorators/examples/validation-decorators.example.js +0 -331
  437. package/http-client/services/cache.service.d.ts +0 -24
  438. package/http-client/services/cache.service.js +0 -264
  439. package/shared/services/validator.service.d.ts +0 -3
  440. package/shared/services/validator.service.js +0 -20
  441. /package/shared/{serviceRegistryModule.d.ts → service-registry.module.d.ts} +0 -0
@@ -10,35 +10,105 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DbDependency = void 0;
13
+ const transaction_1 = require("@nest-omni/transaction");
14
+ /**
15
+ * Database-based cache dependency
16
+ *
17
+ * This dependency monitors database query results. When the query result changes,
18
+ * the cache becomes invalid.
19
+ *
20
+ * Common use case: Monitor MAX(updated_at) or COUNT(*) to detect data changes.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Invalidate cache when user data changes
25
+ * @Cacheable({
26
+ * key: (id) => `user:${id}:profile`,
27
+ * dependencies: [
28
+ * new DbDependency(
29
+ * 'SELECT updated_at FROM users WHERE id = ?',
30
+ * (id) => [id]
31
+ * )
32
+ * ]
33
+ * })
34
+ * async getUserProfile(id: string) { }
35
+ *
36
+ * // Invalidate when any user in tenant changes
37
+ * @Cacheable({
38
+ * key: (tenantId) => `users:list:${tenantId}`,
39
+ * dependencies: [
40
+ * new DbDependency(
41
+ * 'SELECT MAX(updated_at) FROM users WHERE tenant_id = ?',
42
+ * (tenantId) => [tenantId]
43
+ * )
44
+ * ]
45
+ * })
46
+ * async getUserList(tenantId: string) { }
47
+ *
48
+ * // Use specific data source
49
+ * @Cacheable({
50
+ * key: (id) => `product:${id}:details`,
51
+ * dependencies: [
52
+ * new DbDependency(
53
+ * 'SELECT updated_at FROM products WHERE id = ?',
54
+ * (id) => [id],
55
+ * { dataSourceName: 'readReplicas' }
56
+ * )
57
+ * ]
58
+ * })
59
+ * async getProductDetails(id: string) { }
60
+ *
61
+ * // With custom name and data source
62
+ * new DbDependency(
63
+ * 'SELECT COUNT(*) FROM events',
64
+ * [],
65
+ * { name: 'eventCount', dataSourceName: 'analytics' }
66
+ * )
67
+ * ```
68
+ */
13
69
  class DbDependency {
14
- constructor(sql, paramsFactory, name) {
70
+ constructor(sql, paramsFactory, options) {
15
71
  this.sql = sql;
16
72
  this.paramsFactory = paramsFactory;
17
- this.name = name;
73
+ this.options = options;
18
74
  if (!sql || typeof sql !== 'string') {
19
75
  throw new Error('DbDependency requires a valid SQL query');
20
76
  }
21
77
  }
22
- static setDataSource(dataSource) {
23
- this.dataSource = dataSource;
24
- }
25
- static getDataSource() {
26
- return this.dataSource;
78
+ /**
79
+ * Get DataSource for executing queries
80
+ * Priority: 1. Specific dataSourceName from options, 2. Default from getDataSourceByName, 3. Fallback
81
+ */
82
+ getDataSource() {
83
+ var _a;
84
+ // Try to get from getDataSourceByName first
85
+ const dsName = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.dataSourceName) || DbDependency.defaultDataSourceName;
86
+ const dataSource = (0, transaction_1.getDataSource)(dsName);
87
+ if (dataSource) {
88
+ return dataSource;
89
+ }
90
+ // Fallback to static dataSource for backward compatibility
91
+ if (DbDependency.fallbackDataSource) {
92
+ return DbDependency.fallbackDataSource;
93
+ }
94
+ throw new Error(`DbDependency requires DataSource '${dsName}' to be registered. ` +
95
+ `Use DataSourceUtil.registerDataSource('${dsName}', dataSource) ` +
96
+ `or DbDependency.setDataSource(dataSource) for fallback.`);
27
97
  }
28
98
  getKey() {
99
+ var _a;
29
100
  const queryHash = this.hashCode(this.sql);
30
- const name = this.name || 'db';
101
+ const name = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.name) || 'db';
31
102
  return `db:${name}:${queryHash}`;
32
103
  }
33
104
  getData() {
34
105
  return __awaiter(this, void 0, void 0, function* () {
35
106
  var _a;
36
- if (!DbDependency.dataSource) {
37
- throw new Error('DbDependency requires DataSource to be set. Call DbDependency.setDataSource(dataSource) during app initialization.');
38
- }
39
107
  try {
108
+ const dataSource = this.getDataSource();
40
109
  const params = ((_a = this.paramsFactory) === null || _a === void 0 ? void 0 : _a.call(this)) || [];
41
- const result = yield DbDependency.dataSource.query(this.sql, params);
110
+ const result = yield dataSource.query(this.sql, params);
111
+ // Serialize result for comparison
42
112
  return JSON.stringify(result);
43
113
  }
44
114
  catch (error) {
@@ -53,19 +123,24 @@ class DbDependency {
53
123
  return oldData !== currentData;
54
124
  }
55
125
  catch (_a) {
126
+ // If query fails, consider it changed to be safe
56
127
  return true;
57
128
  }
58
129
  });
59
130
  }
131
+ /**
132
+ * Simple hash code generation for strings
133
+ */
60
134
  hashCode(str) {
61
135
  let hash = 0;
62
136
  for (let i = 0; i < str.length; i++) {
63
137
  const char = str.charCodeAt(i);
64
138
  hash = (hash << 5) - hash + char;
65
- hash = hash & hash;
139
+ hash = hash & hash; // Convert to 32bit integer
66
140
  }
67
141
  return Math.abs(hash).toString(36);
68
142
  }
69
143
  }
70
144
  exports.DbDependency = DbDependency;
71
- DbDependency.dataSource = null;
145
+ DbDependency.fallbackDataSource = null;
146
+ DbDependency.defaultDataSourceName = 'default';
@@ -1,4 +1,33 @@
1
1
  import type { CacheDependency } from '../interfaces/cache-dependency.interface';
2
+ /**
3
+ * File-based cache dependency
4
+ *
5
+ * This dependency monitors file modification time. When the file is modified,
6
+ * the cache becomes invalid.
7
+ *
8
+ * Useful for configuration files, templates, or other file-based resources.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Cache template, invalidate when template file changes
13
+ * @Cacheable({
14
+ * key: (name) => `template:${name}`,
15
+ * dependencies: [
16
+ * new FileDependency((name) => `./templates/${name}.html`)
17
+ * ]
18
+ * })
19
+ * async getTemplate(name: string) { }
20
+ *
21
+ * // Cache config, invalidate when config file changes
22
+ * @Cacheable({
23
+ * key: 'app:config',
24
+ * dependencies: [
25
+ * new FileDependency('./config/app.json')
26
+ * ]
27
+ * })
28
+ * async getConfig() { }
29
+ * ```
30
+ */
2
31
  export declare class FileDependency implements CacheDependency {
3
32
  private readonly filePath;
4
33
  constructor(filePath: string | ((...args: any[]) => string));
@@ -13,5 +42,8 @@ export declare class FileDependency implements CacheDependency {
13
42
  mtime: number;
14
43
  size: number;
15
44
  } | null): Promise<boolean>;
45
+ /**
46
+ * Resolve the file path (handle dynamic paths)
47
+ */
16
48
  private resolveFilePath;
17
49
  }
@@ -11,6 +11,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FileDependency = void 0;
13
13
  const node_fs_1 = require("node:fs");
14
+ /**
15
+ * File-based cache dependency
16
+ *
17
+ * This dependency monitors file modification time. When the file is modified,
18
+ * the cache becomes invalid.
19
+ *
20
+ * Useful for configuration files, templates, or other file-based resources.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Cache template, invalidate when template file changes
25
+ * @Cacheable({
26
+ * key: (name) => `template:${name}`,
27
+ * dependencies: [
28
+ * new FileDependency((name) => `./templates/${name}.html`)
29
+ * ]
30
+ * })
31
+ * async getTemplate(name: string) { }
32
+ *
33
+ * // Cache config, invalidate when config file changes
34
+ * @Cacheable({
35
+ * key: 'app:config',
36
+ * dependencies: [
37
+ * new FileDependency('./config/app.json')
38
+ * ]
39
+ * })
40
+ * async getConfig() { }
41
+ * ```
42
+ */
14
43
  class FileDependency {
15
44
  constructor(filePath) {
16
45
  if (!filePath) {
@@ -42,15 +71,20 @@ class FileDependency {
42
71
  return __awaiter(this, void 0, void 0, function* () {
43
72
  try {
44
73
  const currentData = yield this.getData();
74
+ // File path changed or mtime changed or size changed
45
75
  return (currentData.path !== oldData.path ||
46
76
  currentData.mtime !== oldData.mtime ||
47
77
  currentData.size !== oldData.size);
48
78
  }
49
79
  catch (_a) {
80
+ // If we can't access file, consider it changed
50
81
  return true;
51
82
  }
52
83
  });
53
84
  }
85
+ /**
86
+ * Resolve the file path (handle dynamic paths)
87
+ */
54
88
  resolveFilePath() {
55
89
  return __awaiter(this, void 0, void 0, function* () {
56
90
  if (typeof this.filePath === 'function') {
@@ -1,14 +1,85 @@
1
1
  import type { CacheDependency } from '../interfaces/cache-dependency.interface';
2
+ import type Redis from 'ioredis';
3
+ /**
4
+ * Tag-based cache dependency
5
+ *
6
+ * This dependency allows you to invalidate multiple cache entries by tags.
7
+ * When a tag is invalidated, all cache entries depending on that tag become invalid.
8
+ *
9
+ * This is the most commonly used dependency type for managing related cache entries.
10
+ *
11
+ * **Distributed Support**: Tag versions are stored in Redis for multi-instance deployments.
12
+ * Falls back to in-memory storage if Redis is not available.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Cache user list with tag dependency
17
+ * @Cacheable({
18
+ * key: (tenantId) => `users:list:${tenantId}`,
19
+ * dependencies: [new TagDependency(['user-list', `tenant:${tenantId}`])]
20
+ * })
21
+ * async getUserList(tenantId: string) { }
22
+ *
23
+ * // When creating a new user, invalidate the tag
24
+ * await cacheService.invalidateTags(['user-list']);
25
+ * ```
26
+ */
2
27
  export declare class TagDependency implements CacheDependency {
3
28
  private readonly tags;
4
29
  private static readonly PREFIX;
30
+ private static readonly REDIS_KEY_PREFIX;
5
31
  private static tagVersions;
32
+ private static redis;
6
33
  constructor(tags: string[]);
7
- static getTagVersion(tag: string): number;
8
- static invalidateTag(tag: string): void;
9
- static invalidateTags(tags: string[]): void;
10
- static resetAllTags(): void;
34
+ /**
35
+ * Set Redis client for distributed tag version storage
36
+ * Called by CacheModule during initialization
37
+ *
38
+ * @param redis - Redis client instance
39
+ */
40
+ static setRedisClient(redis: Redis): void;
41
+ /**
42
+ * Get current version of a tag
43
+ * Prioritizes Redis, falls back to in-memory storage
44
+ *
45
+ * @param tag - Tag name
46
+ * @returns Current tag version
47
+ */
48
+ static getTagVersion(tag: string): Promise<number>;
49
+ /**
50
+ * Invalidate a tag (increment its version)
51
+ * Updates both Redis and in-memory storage
52
+ *
53
+ * @param tag - Tag name to invalidate
54
+ */
55
+ static invalidateTag(tag: string): Promise<void>;
56
+ /**
57
+ * Invalidate multiple tags
58
+ *
59
+ * @param tags - Array of tag names to invalidate
60
+ */
61
+ static invalidateTags(tags: string[]): Promise<void>;
62
+ /**
63
+ * Reset all tag versions (useful for testing)
64
+ * Clears both Redis and in-memory storage
65
+ */
66
+ static resetAllTags(): Promise<void>;
67
+ /**
68
+ * Get all tags and their versions
69
+ * Note: This only returns in-memory tags for backward compatibility
70
+ *
71
+ * @returns Map of tag names to versions
72
+ */
11
73
  static getAllTags(): Map<string, number>;
74
+ /**
75
+ * Get tag version (synchronous version for backward compatibility)
76
+ * Only reads from in-memory storage
77
+ *
78
+ * @deprecated Use getTagVersion(tag) instead for distributed support
79
+ * @param tag - Tag name
80
+ * @returns Current tag version from memory
81
+ */
82
+ static getTagVersionSync(tag: string): number;
12
83
  getKey(): string;
13
84
  getData(): Promise<Record<string, number>>;
14
85
  isChanged(oldData: Record<string, number>): Promise<boolean>;
@@ -10,6 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TagDependency = void 0;
13
+ /**
14
+ * Tag-based cache dependency
15
+ *
16
+ * This dependency allows you to invalidate multiple cache entries by tags.
17
+ * When a tag is invalidated, all cache entries depending on that tag become invalid.
18
+ *
19
+ * This is the most commonly used dependency type for managing related cache entries.
20
+ *
21
+ * **Distributed Support**: Tag versions are stored in Redis for multi-instance deployments.
22
+ * Falls back to in-memory storage if Redis is not available.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Cache user list with tag dependency
27
+ * @Cacheable({
28
+ * key: (tenantId) => `users:list:${tenantId}`,
29
+ * dependencies: [new TagDependency(['user-list', `tenant:${tenantId}`])]
30
+ * })
31
+ * async getUserList(tenantId: string) { }
32
+ *
33
+ * // When creating a new user, invalidate the tag
34
+ * await cacheService.invalidateTags(['user-list']);
35
+ * ```
36
+ */
13
37
  class TagDependency {
14
38
  constructor(tags) {
15
39
  this.tags = tags;
@@ -17,23 +41,129 @@ class TagDependency {
17
41
  throw new Error('TagDependency requires at least one tag');
18
42
  }
19
43
  }
44
+ /**
45
+ * Set Redis client for distributed tag version storage
46
+ * Called by CacheModule during initialization
47
+ *
48
+ * @param redis - Redis client instance
49
+ */
50
+ static setRedisClient(redis) {
51
+ TagDependency.redis = redis;
52
+ }
53
+ /**
54
+ * Get current version of a tag
55
+ * Prioritizes Redis, falls back to in-memory storage
56
+ *
57
+ * @param tag - Tag name
58
+ * @returns Current tag version
59
+ */
20
60
  static getTagVersion(tag) {
21
- return this.tagVersions.get(tag) || 0;
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ // Try to get from Redis first
63
+ if (TagDependency.redis) {
64
+ try {
65
+ const key = `${TagDependency.REDIS_KEY_PREFIX}:${tag}`;
66
+ const result = yield TagDependency.redis.get(key);
67
+ if (result !== null) {
68
+ const version = parseInt(result, 10);
69
+ // Cache in memory for faster access
70
+ TagDependency.tagVersions.set(tag, version);
71
+ return version;
72
+ }
73
+ }
74
+ catch (error) {
75
+ // Log warning but don't throw - fall back to memory
76
+ console.warn(`[TagDependency] Failed to get tag version from Redis: ${error instanceof Error ? error.message : String(error)}`);
77
+ }
78
+ }
79
+ // Fall back to in-memory storage
80
+ return TagDependency.tagVersions.get(tag) || 0;
81
+ });
22
82
  }
83
+ /**
84
+ * Invalidate a tag (increment its version)
85
+ * Updates both Redis and in-memory storage
86
+ *
87
+ * @param tag - Tag name to invalidate
88
+ */
23
89
  static invalidateTag(tag) {
24
- const currentVersion = this.tagVersions.get(tag) || 0;
25
- this.tagVersions.set(tag, currentVersion + 1);
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const currentVersion = TagDependency.tagVersions.get(tag) || 0;
92
+ const newVersion = currentVersion + 1;
93
+ // Update in-memory storage
94
+ TagDependency.tagVersions.set(tag, newVersion);
95
+ // Update Redis if available
96
+ if (TagDependency.redis) {
97
+ try {
98
+ const key = `${TagDependency.REDIS_KEY_PREFIX}:${tag}`;
99
+ yield TagDependency.redis.set(key, newVersion.toString());
100
+ }
101
+ catch (error) {
102
+ console.error(`[TagDependency] Failed to invalidate tag in Redis: ${error instanceof Error ? error.message : String(error)}`);
103
+ }
104
+ }
105
+ });
26
106
  }
107
+ /**
108
+ * Invalidate multiple tags
109
+ *
110
+ * @param tags - Array of tag names to invalidate
111
+ */
27
112
  static invalidateTags(tags) {
28
- for (const tag of tags) {
29
- this.invalidateTag(tag);
30
- }
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ yield Promise.all(tags.map((tag) => TagDependency.invalidateTag(tag)));
115
+ });
31
116
  }
117
+ /**
118
+ * Reset all tag versions (useful for testing)
119
+ * Clears both Redis and in-memory storage
120
+ */
32
121
  static resetAllTags() {
33
- this.tagVersions.clear();
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ // Clear in-memory storage
124
+ TagDependency.tagVersions.clear();
125
+ // Clear Redis storage
126
+ if (TagDependency.redis) {
127
+ try {
128
+ let cursor = '0';
129
+ const pattern = `${TagDependency.REDIS_KEY_PREFIX}:*`;
130
+ const keysToDelete = [];
131
+ // Use SCAN to find all tag version keys
132
+ do {
133
+ const [nextCursor, keys] = yield TagDependency.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
134
+ cursor = nextCursor;
135
+ keysToDelete.push(...keys);
136
+ } while (cursor !== '0');
137
+ // Delete all found keys
138
+ if (keysToDelete.length > 0) {
139
+ yield TagDependency.redis.del(...keysToDelete);
140
+ }
141
+ }
142
+ catch (error) {
143
+ console.error(`[TagDependency] Failed to reset tags in Redis: ${error instanceof Error ? error.message : String(error)}`);
144
+ }
145
+ }
146
+ });
34
147
  }
148
+ /**
149
+ * Get all tags and their versions
150
+ * Note: This only returns in-memory tags for backward compatibility
151
+ *
152
+ * @returns Map of tag names to versions
153
+ */
35
154
  static getAllTags() {
36
- return new Map(this.tagVersions);
155
+ return new Map(TagDependency.tagVersions);
156
+ }
157
+ /**
158
+ * Get tag version (synchronous version for backward compatibility)
159
+ * Only reads from in-memory storage
160
+ *
161
+ * @deprecated Use getTagVersion(tag) instead for distributed support
162
+ * @param tag - Tag name
163
+ * @returns Current tag version from memory
164
+ */
165
+ static getTagVersionSync(tag) {
166
+ return TagDependency.tagVersions.get(tag) || 0;
37
167
  }
38
168
  getKey() {
39
169
  return `tag:${this.tags.sort().join(',')}`;
@@ -42,7 +172,7 @@ class TagDependency {
42
172
  return __awaiter(this, void 0, void 0, function* () {
43
173
  const data = {};
44
174
  for (const tag of this.tags) {
45
- data[tag] = TagDependency.getTagVersion(tag);
175
+ data[tag] = yield TagDependency.getTagVersion(tag);
46
176
  }
47
177
  return data;
48
178
  });
@@ -53,7 +183,7 @@ class TagDependency {
53
183
  return true;
54
184
  }
55
185
  for (const tag of this.tags) {
56
- const currentVersion = TagDependency.getTagVersion(tag);
186
+ const currentVersion = yield TagDependency.getTagVersion(tag);
57
187
  const oldVersion = oldData[tag];
58
188
  if (currentVersion !== oldVersion) {
59
189
  return true;
@@ -65,11 +195,15 @@ class TagDependency {
65
195
  reset() {
66
196
  return __awaiter(this, void 0, void 0, function* () {
67
197
  for (const tag of this.tags) {
68
- TagDependency.invalidateTag(tag);
198
+ yield TagDependency.invalidateTag(tag);
69
199
  }
70
200
  });
71
201
  }
72
202
  }
73
203
  exports.TagDependency = TagDependency;
74
204
  TagDependency.PREFIX = 'cache:tag:';
205
+ TagDependency.REDIS_KEY_PREFIX = 'cache:tag:versions';
206
+ // In-memory fallback for when Redis is not available
75
207
  TagDependency.tagVersions = new Map();
208
+ // Redis client for distributed tag version storage
209
+ TagDependency.redis = null;
@@ -1,4 +1,38 @@
1
1
  import type { CacheDependency } from '../interfaces/cache-dependency.interface';
2
+ /**
3
+ * Time-based cache dependency
4
+ *
5
+ * This dependency invalidates cache after a specific duration.
6
+ * Unlike TTL which is checked on read, this is checked as a dependency.
7
+ *
8
+ * Useful for implementing complex time-based invalidation logic.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Cache for 5 minutes
13
+ * @Cacheable({
14
+ * key: 'daily:report',
15
+ * dependencies: [
16
+ * new TimeDependency(5 * 60 * 1000) // 5 minutes
17
+ * ]
18
+ * })
19
+ * async getDailyReport() { }
20
+ *
21
+ * // Cache until midnight
22
+ * @Cacheable({
23
+ * key: 'today:stats',
24
+ * dependencies: [
25
+ * new TimeDependency(() => {
26
+ * const now = new Date();
27
+ * const midnight = new Date(now);
28
+ * midnight.setHours(24, 0, 0, 0);
29
+ * return midnight.getTime() - now.getTime();
30
+ * })
31
+ * ]
32
+ * })
33
+ * async getTodayStats() { }
34
+ * ```
35
+ */
2
36
  export declare class TimeDependency implements CacheDependency {
3
37
  private readonly duration;
4
38
  private createdAt;
@@ -13,7 +47,16 @@ export declare class TimeDependency implements CacheDependency {
13
47
  duration: number;
14
48
  }): Promise<boolean>;
15
49
  reset(): Promise<void>;
50
+ /**
51
+ * Get remaining time in milliseconds
52
+ */
16
53
  getRemainingTime(): number;
54
+ /**
55
+ * Check if dependency has expired
56
+ */
17
57
  isExpired(): boolean;
58
+ /**
59
+ * Resolve duration value (handle dynamic duration)
60
+ */
18
61
  private resolveDuration;
19
62
  }
@@ -10,6 +10,40 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TimeDependency = void 0;
13
+ /**
14
+ * Time-based cache dependency
15
+ *
16
+ * This dependency invalidates cache after a specific duration.
17
+ * Unlike TTL which is checked on read, this is checked as a dependency.
18
+ *
19
+ * Useful for implementing complex time-based invalidation logic.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Cache for 5 minutes
24
+ * @Cacheable({
25
+ * key: 'daily:report',
26
+ * dependencies: [
27
+ * new TimeDependency(5 * 60 * 1000) // 5 minutes
28
+ * ]
29
+ * })
30
+ * async getDailyReport() { }
31
+ *
32
+ * // Cache until midnight
33
+ * @Cacheable({
34
+ * key: 'today:stats',
35
+ * dependencies: [
36
+ * new TimeDependency(() => {
37
+ * const now = new Date();
38
+ * const midnight = new Date(now);
39
+ * midnight.setHours(24, 0, 0, 0);
40
+ * return midnight.getTime() - now.getTime();
41
+ * })
42
+ * ]
43
+ * })
44
+ * async getTodayStats() { }
45
+ * ```
46
+ */
13
47
  class TimeDependency {
14
48
  constructor(duration) {
15
49
  if (typeof duration !== 'number' && typeof duration !== 'function') {
@@ -48,15 +82,24 @@ class TimeDependency {
48
82
  this.createdAt = Date.now();
49
83
  });
50
84
  }
85
+ /**
86
+ * Get remaining time in milliseconds
87
+ */
51
88
  getRemainingTime() {
52
89
  const duration = this.resolveDuration();
53
90
  const elapsed = Date.now() - this.createdAt;
54
91
  const remaining = duration - elapsed;
55
92
  return Math.max(0, remaining);
56
93
  }
94
+ /**
95
+ * Check if dependency has expired
96
+ */
57
97
  isExpired() {
58
98
  return this.getRemainingTime() === 0;
59
99
  }
100
+ /**
101
+ * Resolve duration value (handle dynamic duration)
102
+ */
60
103
  resolveDuration() {
61
104
  if (typeof this.duration === 'function') {
62
105
  const value = this.duration();
@@ -0,0 +1 @@
1
+ export * from './typeorm-cache.entity';
@@ -0,0 +1,17 @@
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("./typeorm-cache.entity"), exports);