@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.
- package/audit/audit.module.d.ts +11 -0
- package/audit/audit.module.js +65 -1
- package/audit/controllers/audit.controller.d.ts +81 -1
- package/audit/controllers/audit.controller.js +67 -0
- package/audit/decorators/audit-action.decorator.d.ts +74 -0
- package/audit/decorators/audit-action.decorator.js +42 -0
- package/audit/decorators/audit-controller.decorator.d.ts +9 -1
- package/audit/decorators/audit-controller.decorator.js +11 -2
- package/audit/decorators/audit-operation.decorator.d.ts +38 -0
- package/audit/decorators/audit-operation.decorator.js +42 -0
- package/audit/decorators/entity-audit.decorator.d.ts +85 -1
- package/audit/decorators/entity-audit.decorator.js +153 -3
- package/audit/decorators/index.d.ts +2 -0
- package/audit/decorators/index.js +2 -0
- package/audit/dto/audit-action-query.dto.d.ts +13 -0
- package/audit/dto/audit-action-query.dto.js +77 -0
- package/audit/dto/audit-log-query.dto.d.ts +3 -0
- package/audit/dto/audit-log-query.dto.js +3 -0
- package/audit/dto/begin-transaction.dto.d.ts +3 -0
- package/audit/dto/begin-transaction.dto.js +3 -0
- package/audit/dto/compare-entities.dto.d.ts +3 -0
- package/audit/dto/compare-entities.dto.js +3 -0
- package/audit/dto/index.d.ts +1 -0
- package/audit/dto/index.js +1 -0
- package/audit/dto/pre-check-restore.dto.d.ts +3 -0
- package/audit/dto/pre-check-restore.dto.js +3 -0
- package/audit/dto/restore-entity.dto.d.ts +3 -0
- package/audit/dto/restore-entity.dto.js +3 -0
- package/audit/entities/audit-action-summary.entity.d.ts +23 -0
- package/audit/entities/audit-action-summary.entity.js +101 -0
- package/audit/entities/entity-audit-log.entity.d.ts +10 -2
- package/audit/entities/entity-audit-log.entity.js +48 -9
- package/audit/entities/entity-transaction.entity.d.ts +11 -2
- package/audit/entities/entity-transaction.entity.js +42 -3
- package/audit/entities/index.d.ts +3 -0
- package/audit/entities/index.js +3 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -2
- package/audit/entities/manual-operation-log.entity.js +12 -9
- package/audit/entities/operation-template.entity.d.ts +4 -0
- package/audit/entities/operation-template.entity.js +4 -0
- package/audit/enums/audit.enums.d.ts +29 -6
- package/audit/enums/audit.enums.js +31 -7
- package/audit/examples/decorator-value-mapping.example.d.ts +70 -0
- package/audit/examples/decorator-value-mapping.example.js +414 -0
- package/audit/index.d.ts +5 -1
- package/audit/index.js +38 -1
- package/audit/interceptors/audit-action.interceptor.d.ts +38 -0
- package/audit/interceptors/audit-action.interceptor.js +215 -0
- package/audit/interceptors/audit.interceptor.d.ts +16 -0
- package/audit/interceptors/audit.interceptor.js +41 -11
- package/audit/interceptors/index.d.ts +1 -0
- package/audit/interceptors/index.js +1 -0
- package/audit/interfaces/audit.interfaces.d.ts +174 -4
- package/audit/services/audit-action.service.d.ts +141 -0
- package/audit/services/audit-action.service.js +244 -0
- package/audit/services/audit-context.service.d.ts +106 -0
- package/audit/services/audit-context.service.js +185 -0
- package/audit/services/audit-strategy.service.d.ts +6 -0
- package/audit/services/audit-strategy.service.js +13 -0
- package/audit/services/entity-audit.service.d.ts +273 -5
- package/audit/services/entity-audit.service.js +840 -60
- package/audit/services/index.d.ts +3 -0
- package/audit/services/index.js +3 -0
- package/audit/services/manual-audit-log.service.d.ts +133 -9
- package/audit/services/manual-audit-log.service.js +157 -42
- package/audit/services/multi-database.service.d.ts +9 -2
- package/audit/services/multi-database.service.js +9 -21
- package/audit/services/operation-description.service.d.ts +71 -2
- package/audit/services/operation-description.service.js +231 -20
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +53 -5
- package/audit/subscribers/entity-audit.subscriber.d.ts +20 -0
- package/audit/subscribers/entity-audit.subscriber.js +98 -6
- package/cache/cache-metrics.service.d.ts +67 -0
- package/cache/cache-metrics.service.js +68 -4
- package/cache/cache-serialization.service.d.ts +31 -0
- package/cache/cache-serialization.service.js +25 -0
- package/cache/cache.constants.d.ts +9 -0
- package/cache/cache.constants.js +9 -0
- package/cache/cache.health.d.ts +26 -0
- package/cache/cache.health.js +30 -0
- package/cache/cache.module.d.ts +87 -2
- package/cache/cache.module.js +84 -11
- package/cache/cache.service.d.ts +143 -3
- package/cache/cache.service.js +173 -4
- package/cache/cache.warmup.service.d.ts +39 -0
- package/cache/cache.warmup.service.js +32 -0
- package/cache/decorators/cache-evict.decorator.d.ts +47 -0
- package/cache/decorators/cache-evict.decorator.js +56 -0
- package/cache/decorators/cache-put.decorator.d.ts +34 -0
- package/cache/decorators/cache-put.decorator.js +39 -0
- package/cache/decorators/cacheable.decorator.d.ts +40 -0
- package/cache/decorators/cacheable.decorator.js +55 -0
- package/cache/dependencies/callback.dependency.d.ts +33 -0
- package/cache/dependencies/callback.dependency.js +39 -1
- package/cache/dependencies/chain.dependency.d.ts +28 -0
- package/cache/dependencies/chain.dependency.js +34 -0
- package/cache/dependencies/db.dependency.d.ts +83 -7
- package/cache/dependencies/db.dependency.js +89 -14
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +75 -4
- package/cache/dependencies/tag.dependency.js +145 -11
- package/cache/dependencies/time.dependency.d.ts +43 -0
- package/cache/dependencies/time.dependency.js +43 -0
- package/cache/entities/index.d.ts +1 -0
- package/cache/entities/index.js +17 -0
- package/cache/entities/typeorm-cache.entity.d.ts +71 -0
- package/cache/entities/typeorm-cache.entity.js +110 -0
- package/cache/examples/basic-usage.d.ts +15 -0
- package/cache/examples/basic-usage.js +62 -8
- package/cache/index.d.ts +2 -1
- package/cache/index.js +28 -2
- package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
- package/cache/interfaces/cache-options.interface.d.ts +89 -0
- package/cache/interfaces/cache-options.interface.js +6 -0
- package/cache/interfaces/cache-provider.interface.d.ts +78 -0
- package/cache/providers/base-cache.provider.d.ts +14 -0
- package/cache/providers/base-cache.provider.js +16 -0
- package/cache/providers/cls-cache.provider.d.ts +20 -0
- package/cache/providers/cls-cache.provider.js +28 -0
- package/cache/providers/index.d.ts +2 -1
- package/cache/providers/index.js +2 -1
- package/cache/providers/lrucache.provider.d.ts +76 -0
- package/cache/providers/lrucache.provider.js +226 -0
- package/cache/providers/redis-cache.provider.d.ts +26 -0
- package/cache/providers/redis-cache.provider.js +29 -0
- package/cache/providers/typeorm-cache.provider.d.ts +211 -0
- package/cache/providers/typeorm-cache.provider.js +483 -0
- package/cache/utils/dependency-manager.util.d.ts +52 -0
- package/cache/utils/dependency-manager.util.js +59 -0
- package/cache/utils/key-generator.util.d.ts +42 -0
- package/cache/utils/key-generator.util.js +53 -1
- package/common/abstract.entity.d.ts +14 -0
- package/common/abstract.entity.js +14 -0
- package/common/boilerplate.polyfill.d.ts +143 -0
- package/common/boilerplate.polyfill.js +35 -1
- package/common/dto/dto-container.d.ts +16 -0
- package/common/dto/dto-container.js +20 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +14 -0
- package/common/dto/dto-extensions.d.ts +11 -0
- package/common/dto/dto-extensions.js +9 -0
- package/common/dto/dto-service-accessor.d.ts +17 -0
- package/common/dto/dto-service-accessor.js +18 -0
- package/common/dto/dto-transformer.d.ts +12 -0
- package/common/dto/dto-transformer.js +9 -0
- package/common/dto/index.js +2 -0
- package/common/examples/paginate-and-map.example.d.ts +6 -0
- package/common/examples/paginate-and-map.example.js +26 -0
- package/common/helpers/validation-metadata-helper.d.ts +55 -0
- package/common/helpers/validation-metadata-helper.js +60 -0
- package/common/index.d.ts +1 -0
- package/common/index.js +4 -0
- package/common/utils.d.ts +15 -0
- package/common/utils.js +15 -0
- package/constants/language-code.js +1 -0
- package/decorators/field.decorators.d.ts +72 -3
- package/decorators/field.decorators.js +155 -19
- package/decorators/property.decorators.js +1 -0
- package/decorators/public-route.decorator.js +1 -0
- package/decorators/transform.decorators.d.ts +27 -2
- package/decorators/transform.decorators.js +29 -23
- package/decorators/translate.decorator.js +1 -0
- package/decorators/user.decorator.js +1 -0
- package/decorators/validator.decorators.d.ts +8 -18
- package/decorators/validator.decorators.js +22 -190
- package/file-upload/controllers/file-access.controller.d.ts +23 -0
- package/file-upload/controllers/file-access.controller.js +128 -0
- package/file-upload/decorators/column.decorator.d.ts +151 -0
- package/file-upload/decorators/column.decorator.js +273 -0
- package/file-upload/decorators/csv-data.decorator.d.ts +30 -0
- package/file-upload/decorators/csv-data.decorator.js +85 -0
- package/file-upload/decorators/csv-import.decorator.d.ts +34 -0
- package/file-upload/decorators/csv-import.decorator.js +24 -0
- package/file-upload/decorators/examples/column-mapping.example.d.ts +76 -0
- package/file-upload/decorators/examples/column-mapping.example.js +122 -0
- package/file-upload/decorators/excel-data.decorator.d.ts +30 -0
- package/file-upload/decorators/excel-data.decorator.js +85 -0
- package/file-upload/decorators/file-upload.decorator.d.ts +83 -0
- package/file-upload/decorators/file-upload.decorator.js +172 -0
- package/file-upload/decorators/index.d.ts +5 -0
- package/file-upload/decorators/index.js +38 -0
- package/file-upload/decorators/process.decorator.d.ts +40 -0
- package/file-upload/decorators/process.decorator.js +52 -0
- package/file-upload/decorators/validate-data.decorator.d.ts +91 -0
- package/file-upload/decorators/validate-data.decorator.js +39 -0
- package/file-upload/dto/create-file.dto.d.ts +24 -0
- package/file-upload/dto/create-file.dto.js +112 -0
- package/file-upload/dto/find-files.dto.d.ts +15 -0
- package/file-upload/dto/find-files.dto.js +76 -0
- package/file-upload/dto/index.d.ts +4 -0
- package/file-upload/dto/index.js +20 -0
- package/file-upload/dto/pagination.dto.d.ts +7 -0
- package/file-upload/dto/pagination.dto.js +39 -0
- package/file-upload/dto/update-file.dto.d.ts +15 -0
- package/file-upload/dto/update-file.dto.js +67 -0
- package/file-upload/entities/file-metadata.entity.d.ts +25 -0
- package/file-upload/entities/file-metadata.entity.js +76 -0
- package/file-upload/entities/file.entity.d.ts +114 -0
- package/file-upload/entities/file.entity.js +350 -0
- package/file-upload/entities/index.d.ts +2 -0
- package/file-upload/entities/index.js +18 -0
- package/file-upload/enums/file-type.enum.d.ts +72 -0
- package/file-upload/enums/file-type.enum.js +212 -0
- package/file-upload/exceptions/file-upload.exception.d.ts +57 -0
- package/file-upload/exceptions/file-upload.exception.js +120 -0
- package/file-upload/exceptions/index.d.ts +1 -0
- package/file-upload/exceptions/index.js +17 -0
- package/file-upload/file-upload.module.d.ts +89 -0
- package/file-upload/file-upload.module.js +292 -0
- package/file-upload/index.d.ts +37 -0
- package/file-upload/index.js +77 -0
- package/file-upload/interceptors/file-upload.interceptor.d.ts +101 -0
- package/file-upload/interceptors/file-upload.interceptor.js +594 -0
- package/file-upload/interceptors/index.d.ts +1 -0
- package/file-upload/interceptors/index.js +17 -0
- package/file-upload/interfaces/custom-file-type.interface.d.ts +72 -0
- package/file-upload/interfaces/custom-file-type.interface.js +2 -0
- package/file-upload/interfaces/file-buffer.interface.d.ts +72 -0
- package/file-upload/interfaces/file-buffer.interface.js +2 -0
- package/file-upload/interfaces/file-entity.interface.d.ts +142 -0
- package/file-upload/interfaces/file-entity.interface.js +28 -0
- package/file-upload/interfaces/file-metadata.interface.d.ts +21 -0
- package/file-upload/interfaces/file-metadata.interface.js +2 -0
- package/file-upload/interfaces/file-processor.interface.d.ts +93 -0
- package/file-upload/interfaces/file-processor.interface.js +2 -0
- package/file-upload/interfaces/file-upload-options.interface.d.ts +74 -0
- package/file-upload/interfaces/file-upload-options.interface.js +5 -0
- package/file-upload/interfaces/index.d.ts +7 -0
- package/file-upload/interfaces/index.js +24 -0
- package/file-upload/interfaces/processor-options.interface.d.ts +102 -0
- package/file-upload/interfaces/processor-options.interface.js +2 -0
- package/file-upload/interfaces/storage-provider.interface.d.ts +239 -0
- package/file-upload/interfaces/storage-provider.interface.js +2 -0
- package/file-upload/interfaces/upload-options.interface.d.ts +19 -0
- package/file-upload/interfaces/upload-options.interface.js +2 -0
- package/file-upload/processors/csv.processor.d.ts +98 -0
- package/file-upload/processors/csv.processor.js +391 -0
- package/file-upload/processors/excel.processor.d.ts +130 -0
- package/file-upload/processors/excel.processor.js +547 -0
- package/file-upload/processors/image.processor.d.ts +199 -0
- package/file-upload/processors/image.processor.js +377 -0
- package/file-upload/providers/index.d.ts +2 -0
- package/file-upload/providers/index.js +18 -0
- package/file-upload/providers/local-storage.provider.d.ts +98 -0
- package/file-upload/providers/local-storage.provider.js +484 -0
- package/file-upload/providers/s3-storage.provider.d.ts +87 -0
- package/file-upload/providers/s3-storage.provider.js +455 -0
- package/file-upload/services/file-signature-validator.service.d.ts +118 -0
- package/file-upload/services/file-signature-validator.service.js +376 -0
- package/file-upload/services/file.service.d.ts +193 -0
- package/file-upload/services/file.service.js +638 -0
- package/file-upload/services/index.d.ts +4 -0
- package/file-upload/services/index.js +20 -0
- package/file-upload/services/malicious-file-detector.service.d.ts +300 -0
- package/file-upload/services/malicious-file-detector.service.js +1234 -0
- package/file-upload/services/mime-registry.service.d.ts +47 -0
- package/file-upload/services/mime-registry.service.js +167 -0
- package/file-upload/utils/checksum.util.d.ts +28 -0
- package/file-upload/utils/checksum.util.js +65 -0
- package/file-upload/utils/dynamic-import.util.d.ts +54 -0
- package/file-upload/utils/dynamic-import.util.js +156 -0
- package/file-upload/utils/filename.util.d.ts +59 -0
- package/file-upload/utils/filename.util.js +184 -0
- package/file-upload/utils/filepath.util.d.ts +70 -0
- package/file-upload/utils/filepath.util.js +152 -0
- package/file-upload/utils/index.d.ts +4 -0
- package/file-upload/utils/index.js +20 -0
- package/filters/bad-request.filter.js +19 -4
- package/filters/constraint-errors.js +1 -0
- package/helpers/common.helper.d.ts +13 -0
- package/helpers/common.helper.js +13 -0
- package/http-client/config/http-client.config.d.ts +20 -0
- package/http-client/config/http-client.config.js +48 -21
- package/http-client/decorators/http-client.decorators.d.ts +55 -14
- package/http-client/decorators/http-client.decorators.js +154 -78
- package/http-client/entities/http-log.entity.d.ts +217 -8
- package/http-client/entities/http-log.entity.js +7 -22
- package/http-client/errors/http-client.errors.d.ts +57 -0
- package/http-client/errors/http-client.errors.js +58 -0
- package/http-client/examples/advanced-usage.example.d.ts +40 -0
- package/http-client/examples/advanced-usage.example.js +53 -61
- package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
- package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
- package/http-client/examples/basic-usage.example.d.ts +60 -0
- package/http-client/examples/basic-usage.example.js +60 -0
- package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
- package/http-client/examples/multi-api-configuration.example.js +76 -5
- package/http-client/examples/proxy-from-environment.example.d.ts +133 -0
- package/http-client/examples/proxy-from-environment.example.js +409 -0
- package/http-client/http-client.module.d.ts +48 -2
- package/http-client/http-client.module.js +147 -68
- package/http-client/index.d.ts +1 -1
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +80 -45
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +109 -52
- package/http-client/services/api-client-registry.service.d.ts +50 -11
- package/http-client/services/api-client-registry.service.js +90 -250
- package/http-client/services/circuit-breaker.service.d.ts +115 -2
- package/http-client/services/circuit-breaker.service.js +237 -7
- package/http-client/services/http-client.service.d.ts +124 -14
- package/http-client/services/http-client.service.js +437 -148
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +121 -13
- package/http-client/services/http-replay.service.d.ts +101 -0
- package/http-client/services/http-replay.service.js +86 -0
- package/http-client/services/index.d.ts +0 -1
- package/http-client/services/index.js +0 -1
- package/http-client/services/log-cleanup.service.d.ts +63 -0
- package/http-client/services/log-cleanup.service.js +54 -2
- package/http-client/services/logging.service.d.ts +116 -7
- package/http-client/services/logging.service.js +349 -86
- package/http-client/utils/call-stack-extractor.util.d.ts +63 -0
- package/http-client/utils/call-stack-extractor.util.js +83 -0
- package/http-client/utils/context-extractor.util.d.ts +49 -0
- package/http-client/utils/context-extractor.util.js +54 -0
- package/http-client/utils/curl-generator.util.d.ts +21 -0
- package/http-client/utils/curl-generator.util.js +44 -3
- package/http-client/utils/index.d.ts +1 -0
- package/http-client/utils/index.js +1 -0
- package/http-client/utils/proxy-environment.util.d.ts +42 -0
- package/http-client/utils/proxy-environment.util.js +148 -0
- package/http-client/utils/request-id.util.d.ts +18 -0
- package/http-client/utils/request-id.util.js +20 -0
- package/http-client/utils/retry-recorder.util.d.ts +42 -0
- package/http-client/utils/retry-recorder.util.js +44 -0
- package/http-client/utils/security-validator.util.d.ts +118 -0
- package/http-client/utils/security-validator.util.js +352 -0
- package/index.d.ts +3 -1
- package/index.js +12 -1
- package/interceptors/translation-interceptor.service.js +5 -0
- package/ip-filter/constants.d.ts +21 -0
- package/ip-filter/constants.js +24 -0
- package/ip-filter/decorators/index.d.ts +1 -0
- package/ip-filter/decorators/index.js +17 -0
- package/ip-filter/decorators/ip-filter.decorator.d.ts +58 -0
- package/ip-filter/decorators/ip-filter.decorator.js +79 -0
- package/ip-filter/guards/index.d.ts +1 -0
- package/ip-filter/guards/index.js +17 -0
- package/ip-filter/guards/ip-filter.guard.d.ts +62 -0
- package/ip-filter/guards/ip-filter.guard.js +174 -0
- package/ip-filter/index.d.ts +7 -0
- package/ip-filter/index.js +23 -0
- package/ip-filter/interfaces/index.d.ts +4 -0
- package/ip-filter/interfaces/index.js +20 -0
- package/ip-filter/interfaces/ip-filter-async-options.interface.d.ts +15 -0
- package/ip-filter/interfaces/ip-filter-async-options.interface.js +2 -0
- package/ip-filter/interfaces/ip-filter-metadata.interface.d.ts +26 -0
- package/ip-filter/interfaces/ip-filter-metadata.interface.js +2 -0
- package/ip-filter/interfaces/ip-filter-options.interface.d.ts +34 -0
- package/ip-filter/interfaces/ip-filter-options.interface.js +2 -0
- package/ip-filter/interfaces/ip-rule.interface.d.ts +36 -0
- package/ip-filter/interfaces/ip-rule.interface.js +2 -0
- package/ip-filter/ip-filter.module.d.ts +55 -0
- package/ip-filter/ip-filter.module.js +105 -0
- package/ip-filter/services/index.d.ts +1 -0
- package/ip-filter/services/index.js +17 -0
- package/ip-filter/services/ip-filter.service.d.ts +92 -0
- package/ip-filter/services/ip-filter.service.js +238 -0
- package/ip-filter/utils/index.d.ts +1 -0
- package/ip-filter/utils/index.js +17 -0
- package/ip-filter/utils/ip-utils.d.ts +61 -0
- package/ip-filter/utils/ip-utils.js +162 -0
- package/package.json +32 -29
- package/providers/context.provider.d.ts +9 -0
- package/providers/context.provider.js +15 -0
- package/providers/generator.provider.d.ts +4 -0
- package/providers/generator.provider.js +4 -0
- package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
- package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
- package/redis-lock/examples/lock-strategy.examples.js +130 -15
- package/redis-lock/index.d.ts +2 -0
- package/redis-lock/index.js +8 -1
- package/redis-lock/lock-heartbeat.service.d.ts +80 -0
- package/redis-lock/lock-heartbeat.service.js +232 -0
- package/redis-lock/redis-lock.decorator.d.ts +101 -0
- package/redis-lock/redis-lock.decorator.js +120 -0
- package/redis-lock/redis-lock.module.d.ts +66 -0
- package/redis-lock/redis-lock.module.js +175 -70
- package/redis-lock/redis-lock.service.d.ts +282 -0
- package/redis-lock/redis-lock.service.js +343 -20
- package/setup/bootstrap.setup.d.ts +2 -1
- package/setup/bootstrap.setup.js +22 -1
- package/setup/index.d.ts +1 -0
- package/setup/index.js +1 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/run-in-mode.decorator.d.ts +56 -0
- package/setup/run-in-mode.decorator.js +92 -0
- package/setup/schedule.decorator.d.ts +227 -0
- package/setup/schedule.decorator.js +240 -12
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +97 -0
- package/shared/index.d.ts +1 -1
- package/shared/index.js +1 -1
- package/shared/{serviceRegistryModule.js → service-registry.module.js} +19 -18
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +21 -9
- package/shared/services/index.d.ts +0 -1
- package/shared/services/index.js +0 -1
- package/validator-json/decorators.d.ts +17 -0
- package/validator-json/decorators.js +17 -2
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +30 -2
- package/validator-json/defaultConverters.js +1 -0
- package/validator-json/options.d.ts +23 -0
- package/validators/common-validators.d.ts +143 -0
- package/validators/common-validators.js +249 -0
- package/validators/custom-validate.examples.d.ts +23 -0
- package/validators/custom-validate.examples.js +78 -6
- package/validators/custom-validate.validator.d.ts +108 -0
- package/validators/custom-validate.validator.js +85 -0
- package/validators/file-mimetype.validator.d.ts +0 -2
- package/validators/file-mimetype.validator.js +4 -6
- package/validators/index.d.ts +1 -0
- package/validators/index.js +1 -0
- package/validators/is-exists.validator.d.ts +26 -6
- package/validators/is-exists.validator.js +30 -7
- package/validators/is-unique.validator.d.ts +33 -7
- package/validators/is-unique.validator.js +59 -17
- package/validators/skip-empty.validator.d.ts +5 -0
- package/validators/skip-empty.validator.js +5 -0
- package/vault/interfaces/vault-options.interface.d.ts +9 -0
- package/vault/vault-config.loader.d.ts +30 -0
- package/vault/vault-config.loader.js +48 -1
- package/vault/vault-config.service.d.ts +53 -0
- package/vault/vault-config.service.js +57 -0
- package/vault/vault.module.d.ts +4 -0
- package/vault/vault.module.js +4 -0
- package/cache/providers/memory-cache.provider.d.ts +0 -26
- package/cache/providers/memory-cache.provider.js +0 -171
- package/decorators/examples/validation-decorators.example.d.ts +0 -69
- package/decorators/examples/validation-decorators.example.js +0 -331
- package/http-client/services/cache.service.d.ts +0 -24
- package/http-client/services/cache.service.js +0 -264
- package/shared/services/validator.service.d.ts +0 -3
- package/shared/services/validator.service.js +0 -20
- /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,
|
|
70
|
+
constructor(sql, paramsFactory, options) {
|
|
15
71
|
this.sql = sql;
|
|
16
72
|
this.paramsFactory = paramsFactory;
|
|
17
|
-
this.
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
|
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(
|
|
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);
|