@nest-omni/core 4.1.3-3 → 4.1.3-30
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 +1 -0
- package/audit/audit.module.js +51 -2
- package/audit/controllers/audit.controller.d.ts +57 -1
- package/audit/controllers/audit.controller.js +43 -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 +1 -1
- package/audit/decorators/audit-controller.decorator.js +2 -2
- package/audit/decorators/audit-operation.decorator.d.ts +0 -7
- package/audit/decorators/audit-operation.decorator.js +0 -7
- package/audit/decorators/entity-audit.decorator.d.ts +78 -2
- package/audit/decorators/entity-audit.decorator.js +145 -4
- 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/index.d.ts +1 -0
- package/audit/dto/index.js +1 -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 +7 -2
- package/audit/entities/entity-audit-log.entity.js +45 -9
- package/audit/entities/entity-transaction.entity.d.ts +8 -2
- package/audit/entities/entity-transaction.entity.js +39 -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 +0 -2
- package/audit/entities/manual-operation-log.entity.js +8 -9
- package/audit/enums/audit.enums.d.ts +14 -6
- package/audit/enums/audit.enums.js +18 -9
- 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 +29 -2
- package/audit/interceptors/audit-action.interceptor.d.ts +39 -0
- package/audit/interceptors/audit-action.interceptor.js +217 -0
- package/audit/interceptors/audit.interceptor.d.ts +1 -0
- package/audit/interceptors/audit.interceptor.js +19 -11
- package/audit/interceptors/index.d.ts +1 -0
- package/audit/interceptors/index.js +1 -0
- package/audit/interfaces/audit.interfaces.d.ts +132 -4
- package/audit/services/audit-action.service.d.ts +142 -0
- package/audit/services/audit-action.service.js +246 -0
- package/audit/services/audit-context.service.d.ts +91 -0
- package/audit/services/audit-context.service.js +170 -0
- package/audit/services/entity-audit.service.d.ts +220 -9
- package/audit/services/entity-audit.service.js +761 -72
- package/audit/services/index.d.ts +3 -0
- package/audit/services/index.js +3 -0
- package/audit/services/manual-audit-log.service.d.ts +23 -23
- package/audit/services/manual-audit-log.service.js +34 -57
- package/audit/services/multi-database.service.d.ts +0 -5
- package/audit/services/multi-database.service.js +0 -24
- package/audit/services/operation-description.service.d.ts +14 -3
- package/audit/services/operation-description.service.js +165 -26
- package/audit/services/transaction-audit.service.d.ts +1 -0
- package/audit/services/transaction-audit.service.js +12 -9
- package/audit/subscribers/entity-audit.subscriber.d.ts +5 -0
- package/audit/subscribers/entity-audit.subscriber.js +69 -5
- package/cache/cache.module.d.ts +7 -8
- package/cache/cache.module.js +15 -13
- package/cache/cache.service.d.ts +6 -4
- package/cache/cache.service.js +24 -12
- package/cache/decorators/cache-put.decorator.js +5 -4
- package/cache/dependencies/callback.dependency.js +9 -0
- package/cache/dependencies/db.dependency.d.ts +43 -12
- package/cache/dependencies/db.dependency.js +46 -18
- package/cache/dependencies/tag.dependency.d.ts +31 -4
- package/cache/dependencies/tag.dependency.js +100 -11
- 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/index.d.ts +2 -1
- package/cache/index.js +19 -2
- package/cache/interfaces/cache-options.interface.d.ts +8 -0
- package/cache/providers/index.d.ts +2 -1
- package/cache/providers/index.js +2 -1
- package/cache/providers/lrucache.provider.d.ts +77 -0
- package/cache/providers/lrucache.provider.js +228 -0
- package/cache/providers/redis-cache.provider.d.ts +1 -0
- package/cache/providers/redis-cache.provider.js +8 -6
- package/cache/providers/typeorm-cache.provider.d.ts +211 -0
- package/cache/providers/typeorm-cache.provider.js +483 -0
- package/common/boilerplate.polyfill.d.ts +1 -0
- package/common/boilerplate.polyfill.js +18 -1
- package/common/helpers/validation-metadata-helper.d.ts +112 -0
- package/common/helpers/validation-metadata-helper.js +164 -0
- package/common/index.d.ts +1 -0
- package/common/index.js +4 -0
- package/decorators/examples/field-i18n.example.d.ts +294 -0
- package/decorators/examples/field-i18n.example.js +478 -0
- package/decorators/field.decorators.d.ts +95 -3
- package/decorators/field.decorators.js +152 -18
- package/decorators/transform.decorators.d.ts +0 -2
- package/decorators/transform.decorators.js +0 -23
- package/decorators/translate.decorator.d.ts +26 -0
- package/decorators/translate.decorator.js +26 -1
- package/email-log/email-log.constants.d.ts +8 -0
- package/email-log/email-log.constants.js +11 -0
- package/email-log/email-log.module.d.ts +47 -0
- package/email-log/email-log.module.js +140 -0
- package/email-log/index.d.ts +11 -0
- package/email-log/index.js +48 -0
- package/email-log/interfaces/email-log-options.interface.d.ts +61 -0
- package/email-log/interfaces/email-log-options.interface.js +134 -0
- package/email-log/interfaces/email-log-transport.interface.d.ts +20 -0
- package/email-log/interfaces/email-log-transport.interface.js +2 -0
- package/email-log/interfaces/index.d.ts +2 -0
- package/email-log/interfaces/index.js +18 -0
- package/email-log/providers/email-provider.d.ts +42 -0
- package/email-log/providers/email-provider.js +127 -0
- package/email-log/providers/index.d.ts +1 -0
- package/email-log/providers/index.js +17 -0
- package/email-log/services/email-log-alert.service.d.ts +46 -0
- package/email-log/services/email-log-alert.service.js +162 -0
- package/email-log/services/email-log-formatter.service.d.ts +78 -0
- package/email-log/services/email-log-formatter.service.js +442 -0
- package/email-log/services/email-log-logger.service.d.ts +85 -0
- package/email-log/services/email-log-logger.service.js +168 -0
- package/email-log/services/email-log-rate-limiter.service.d.ts +42 -0
- package/email-log/services/email-log-rate-limiter.service.js +110 -0
- package/email-log/services/email-log-transport.service.d.ts +80 -0
- package/email-log/services/email-log-transport.service.js +271 -0
- package/email-log/services/index.d.ts +5 -0
- package/email-log/services/index.js +21 -0
- package/email-log/transports/index.d.ts +1 -0
- package/email-log/transports/index.js +17 -0
- package/email-log/transports/pino-email.transport.d.ts +56 -0
- package/email-log/transports/pino-email.transport.js +188 -0
- package/email-log/utils/index.d.ts +2 -0
- package/email-log/utils/index.js +18 -0
- package/email-log/utils/log-level.helper.d.ts +46 -0
- package/email-log/utils/log-level.helper.js +74 -0
- package/email-log/utils/pino-transport.utils.d.ts +135 -0
- package/email-log/utils/pino-transport.utils.js +238 -0
- 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.d.ts +9 -0
- package/filters/bad-request.filter.js +57 -16
- package/http-client/config/http-client.config.d.ts +5 -0
- package/http-client/config/http-client.config.js +27 -14
- package/http-client/decorators/http-client.decorators.d.ts +7 -28
- package/http-client/decorators/http-client.decorators.js +124 -99
- package/http-client/entities/http-log.entity.d.ts +0 -20
- package/http-client/entities/http-log.entity.js +1 -21
- package/http-client/examples/advanced-usage.example.d.ts +4 -5
- package/http-client/examples/advanced-usage.example.js +7 -59
- package/http-client/examples/axios-config-extended.example.d.ts +17 -0
- package/http-client/examples/axios-config-extended.example.js +311 -0
- package/http-client/examples/flexible-response-example.d.ts +28 -0
- package/http-client/examples/flexible-response-example.js +120 -0
- package/http-client/examples/index.d.ts +2 -0
- package/http-client/examples/index.js +2 -0
- 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/examples/ssl-certificate.example.d.ts +47 -0
- package/http-client/examples/ssl-certificate.example.js +432 -0
- package/http-client/http-client.module.d.ts +43 -2
- package/http-client/http-client.module.js +150 -90
- package/http-client/index.d.ts +1 -1
- package/http-client/interfaces/api-client-config.interface.d.ts +24 -103
- package/http-client/interfaces/http-client-config.interface.d.ts +137 -62
- package/http-client/services/api-client-registry.service.d.ts +8 -21
- package/http-client/services/api-client-registry.service.js +31 -282
- package/http-client/services/circuit-breaker.service.d.ts +69 -2
- package/http-client/services/circuit-breaker.service.js +185 -7
- package/http-client/services/http-client.service.d.ts +85 -23
- package/http-client/services/http-client.service.js +512 -168
- package/http-client/services/http-log-query.service.js +0 -13
- package/http-client/services/index.d.ts +0 -1
- package/http-client/services/index.js +0 -1
- package/http-client/services/logging.service.d.ts +69 -16
- package/http-client/services/logging.service.js +290 -170
- package/http-client/utils/call-stack-extractor.util.d.ts +26 -0
- package/http-client/utils/call-stack-extractor.util.js +35 -0
- package/http-client/utils/context-extractor.util.d.ts +2 -0
- package/http-client/utils/context-extractor.util.js +17 -3
- package/http-client/utils/curl-generator.util.js +2 -5
- package/http-client/utils/index.d.ts +2 -0
- package/http-client/utils/index.js +2 -0
- package/http-client/utils/proxy-environment.util.d.ts +42 -0
- package/http-client/utils/proxy-environment.util.js +154 -0
- package/http-client/utils/retry-recorder.util.d.ts +0 -4
- package/http-client/utils/retry-recorder.util.js +2 -27
- package/http-client/utils/sanitize.util.d.ts +58 -0
- package/http-client/utils/sanitize.util.js +188 -0
- package/http-client/utils/security-validator.util.d.ts +118 -0
- package/http-client/utils/security-validator.util.js +354 -0
- package/index.d.ts +4 -1
- package/index.js +6 -1
- package/interceptors/translation-interceptor.service.d.ts +7 -0
- package/interceptors/translation-interceptor.service.js +40 -8
- 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 +34 -29
- package/providers/context.provider.d.ts +9 -0
- package/providers/context.provider.js +13 -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/index.d.ts +2 -0
- package/redis-lock/index.js +5 -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.module.d.ts +6 -0
- package/redis-lock/redis-lock.module.js +136 -77
- package/redis-lock/redis-lock.service.d.ts +31 -0
- package/redis-lock/redis-lock.service.js +124 -17
- package/setup/bootstrap.setup.d.ts +2 -1
- package/setup/bootstrap.setup.js +3 -2
- package/setup/index.d.ts +1 -0
- package/setup/index.js +1 -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 +1 -0
- package/setup/schedule.decorator.js +28 -13
- package/setup/worker.decorator.js +10 -1
- package/shared/index.d.ts +1 -1
- package/shared/index.js +1 -1
- package/shared/{serviceRegistryModule.js → service-registry.module.js} +28 -17
- package/shared/services/api-config.service.d.ts +41 -0
- package/shared/services/api-config.service.js +166 -8
- package/shared/services/index.d.ts +0 -1
- package/shared/services/index.js +0 -1
- package/validators/custom-validate.validator.d.ts +1 -0
- package/validators/custom-validate.validator.js +1 -0
- package/validators/file-mimetype.validator.d.ts +0 -2
- package/validators/file-mimetype.validator.js +4 -6
- package/validators/is-exists.validator.d.ts +15 -6
- package/validators/is-exists.validator.js +8 -7
- package/validators/is-unique.validator.d.ts +22 -7
- package/validators/is-unique.validator.js +41 -17
- package/vault/vault-config.service.js +1 -1
- package/cache/providers/memory-cache.provider.d.ts +0 -49
- package/cache/providers/memory-cache.provider.js +0 -197
- package/http-client/services/cache.service.d.ts +0 -76
- package/http-client/services/cache.service.js +0 -333
- 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
|
@@ -19,8 +19,6 @@ exports.EnumFieldOptional = EnumFieldOptional;
|
|
|
19
19
|
exports.ClassFieldOptional = ClassFieldOptional;
|
|
20
20
|
exports.EmailField = EmailField;
|
|
21
21
|
exports.EmailFieldOptional = EmailFieldOptional;
|
|
22
|
-
exports.PhoneField = PhoneField;
|
|
23
|
-
exports.PhoneFieldOptional = PhoneFieldOptional;
|
|
24
22
|
exports.UUIDField = UUIDField;
|
|
25
23
|
exports.UUIDFieldOptional = UUIDFieldOptional;
|
|
26
24
|
exports.URLField = URLField;
|
|
@@ -37,6 +35,8 @@ exports.TimeZoneField = TimeZoneField;
|
|
|
37
35
|
exports.TimeZoneFieldOptional = TimeZoneFieldOptional;
|
|
38
36
|
exports.LocaleField = LocaleField;
|
|
39
37
|
exports.LocaleFieldOptional = LocaleFieldOptional;
|
|
38
|
+
exports.Field = Field;
|
|
39
|
+
exports.FieldOptional = FieldOptional;
|
|
40
40
|
const common_1 = require("@nestjs/common");
|
|
41
41
|
const swagger_1 = require("@nestjs/swagger");
|
|
42
42
|
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
@@ -46,6 +46,67 @@ const constants_1 = require("../constants");
|
|
|
46
46
|
const property_decorators_1 = require("./property.decorators");
|
|
47
47
|
const transform_decorators_1 = require("./transform.decorators");
|
|
48
48
|
const validator_decorators_1 = require("./validator.decorators");
|
|
49
|
+
// ========================================
|
|
50
|
+
// Unified Field Options Integration
|
|
51
|
+
// ========================================
|
|
52
|
+
const validation_metadata_helper_1 = require("../common/helpers/validation-metadata-helper");
|
|
53
|
+
// ========================================
|
|
54
|
+
// Helper: Apply Audit Metadata from Unified Options
|
|
55
|
+
// ========================================
|
|
56
|
+
/**
|
|
57
|
+
* 应用审计元数据装饰器
|
|
58
|
+
*
|
|
59
|
+
* 将字段元数据存储到 Reflect metadata,供审计日志系统使用
|
|
60
|
+
*/
|
|
61
|
+
function applyAuditMetadata(options) {
|
|
62
|
+
return (target, propertyKey) => {
|
|
63
|
+
// 只有当有相关元数据时才存储
|
|
64
|
+
if (options.fieldLabel ||
|
|
65
|
+
options.fieldI18n ||
|
|
66
|
+
options.fieldDescription ||
|
|
67
|
+
options.valueLabels ||
|
|
68
|
+
options.displayFormatter ||
|
|
69
|
+
options.sensitive) {
|
|
70
|
+
const constructor = target.constructor;
|
|
71
|
+
const AUDIT_FIELD_OPTIONS_KEY = 'FIELD_AUDIT_OPTIONS';
|
|
72
|
+
// 获取现有的审计元数据
|
|
73
|
+
const existingOptions = Reflect.getMetadata(AUDIT_FIELD_OPTIONS_KEY, constructor) || {};
|
|
74
|
+
// 合并元数据(优先使用 fieldLabel,如果没有则使用 fieldI18n)
|
|
75
|
+
const label = options.fieldLabel || options.fieldI18n;
|
|
76
|
+
// 合并元数据
|
|
77
|
+
existingOptions[propertyKey] = {
|
|
78
|
+
label,
|
|
79
|
+
i18nKey: options.fieldI18n,
|
|
80
|
+
description: options.fieldDescription,
|
|
81
|
+
example: options.fieldExample,
|
|
82
|
+
valueLabels: options.valueLabels,
|
|
83
|
+
formatter: options.displayFormatter,
|
|
84
|
+
sensitive: options.sensitive,
|
|
85
|
+
};
|
|
86
|
+
// 存储回 Reflect
|
|
87
|
+
Reflect.defineMetadata(AUDIT_FIELD_OPTIONS_KEY, existingOptions, constructor);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 应用验证元数据装饰器
|
|
93
|
+
*
|
|
94
|
+
* 存储验证元数据到 Reflect metadata,供验证错误过滤器使用
|
|
95
|
+
* 生成友好的多语言错误消息
|
|
96
|
+
*/
|
|
97
|
+
function applyValidationMetadata(options) {
|
|
98
|
+
return (target, propertyKey) => {
|
|
99
|
+
// 只有当有相关元数据时才存储
|
|
100
|
+
if (options.fieldLabel || options.fieldI18n) {
|
|
101
|
+
(0, validation_metadata_helper_1.setValidationMetadata)(target.constructor, String(propertyKey), {
|
|
102
|
+
fieldName: String(propertyKey),
|
|
103
|
+
i18nKey: options.fieldI18n,
|
|
104
|
+
label: options.fieldLabel,
|
|
105
|
+
description: options.fieldDescription,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
49
110
|
function NumberField(options = {}) {
|
|
50
111
|
const decorators = [(0, class_transformer_1.Type)(() => Number)];
|
|
51
112
|
if (options.nullable) {
|
|
@@ -95,6 +156,10 @@ function NumberField(options = {}) {
|
|
|
95
156
|
message: (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_POSITIVE'),
|
|
96
157
|
}));
|
|
97
158
|
}
|
|
159
|
+
// 应用审计元数据(如果有)
|
|
160
|
+
decorators.push(applyAuditMetadata(options));
|
|
161
|
+
// 应用验证元数据(用于友好的错误消息)
|
|
162
|
+
decorators.push(applyValidationMetadata(options));
|
|
98
163
|
return (0, common_1.applyDecorators)(...decorators);
|
|
99
164
|
}
|
|
100
165
|
function NumberFieldOptional(options = {}) {
|
|
@@ -138,6 +203,10 @@ function StringField(options = {}) {
|
|
|
138
203
|
if (options.toUpperCase) {
|
|
139
204
|
decorators.push((0, transform_decorators_1.ToUpperCase)());
|
|
140
205
|
}
|
|
206
|
+
// 应用审计元数据(如果有)
|
|
207
|
+
decorators.push(applyAuditMetadata(options));
|
|
208
|
+
// 应用验证元数据(用于友好的错误消息)
|
|
209
|
+
decorators.push(applyValidationMetadata(options));
|
|
141
210
|
return (0, common_1.applyDecorators)(...decorators);
|
|
142
211
|
}
|
|
143
212
|
function StringFieldOptional(options = {}) {
|
|
@@ -172,6 +241,10 @@ function BooleanField(options = {}) {
|
|
|
172
241
|
if (options.swagger !== false) {
|
|
173
242
|
decorators.push((0, swagger_1.ApiProperty)(Object.assign({ type: Boolean }, options)));
|
|
174
243
|
}
|
|
244
|
+
// 应用审计元数据(如果有)
|
|
245
|
+
decorators.push(applyAuditMetadata(options));
|
|
246
|
+
// 应用验证元数据(用于友好的错误消息)
|
|
247
|
+
decorators.push(applyValidationMetadata(options));
|
|
175
248
|
return (0, common_1.applyDecorators)(...decorators);
|
|
176
249
|
}
|
|
177
250
|
function BooleanFieldOptional(options = {}) {
|
|
@@ -245,6 +318,10 @@ function EnumField(getEnum, options = {}) {
|
|
|
245
318
|
if (options.swagger !== false) {
|
|
246
319
|
decorators.push((0, property_decorators_1.ApiEnumProperty)(getEnum, Object.assign(Object.assign({}, options), { isArray: options.each })));
|
|
247
320
|
}
|
|
321
|
+
// 应用审计元数据(如果有)
|
|
322
|
+
decorators.push(applyAuditMetadata(options));
|
|
323
|
+
// 应用验证元数据(用于友好的错误消息)
|
|
324
|
+
decorators.push(applyValidationMetadata(options));
|
|
248
325
|
return (0, common_1.applyDecorators)(...decorators);
|
|
249
326
|
}
|
|
250
327
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -303,22 +380,6 @@ function EmailField(options = {}) {
|
|
|
303
380
|
function EmailFieldOptional(options = {}) {
|
|
304
381
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), EmailField(Object.assign({ required: false }, options)));
|
|
305
382
|
}
|
|
306
|
-
function PhoneField(options = {}) {
|
|
307
|
-
const decorators = [(0, validator_decorators_1.IsPhoneNumber)(), (0, transform_decorators_1.PhoneNumberSerializer)()];
|
|
308
|
-
if (options.nullable) {
|
|
309
|
-
decorators.push((0, validator_decorators_1.IsNullable)());
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
decorators.push((0, class_validator_1.NotEquals)(null));
|
|
313
|
-
}
|
|
314
|
-
if (options.swagger !== false) {
|
|
315
|
-
decorators.push((0, swagger_1.ApiProperty)(Object.assign({ type: String }, options)));
|
|
316
|
-
}
|
|
317
|
-
return (0, common_1.applyDecorators)(...decorators);
|
|
318
|
-
}
|
|
319
|
-
function PhoneFieldOptional(options = {}) {
|
|
320
|
-
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), PhoneField(Object.assign({ required: false }, options)));
|
|
321
|
-
}
|
|
322
383
|
function UUIDField(options = {}) {
|
|
323
384
|
const decorators = [
|
|
324
385
|
(0, class_transformer_1.Type)(() => String),
|
|
@@ -417,6 +478,10 @@ function DateField(options = {}) {
|
|
|
417
478
|
const swaggerOptions = Object.assign({ type: Date, example: (_a = options.example) !== null && _a !== void 0 ? _a : new Date() }, options);
|
|
418
479
|
decorators.push((0, swagger_1.ApiProperty)(swaggerOptions));
|
|
419
480
|
}
|
|
481
|
+
// 应用审计元数据(如果有)
|
|
482
|
+
decorators.push(applyAuditMetadata(options));
|
|
483
|
+
// 应用验证元数据(用于友好的错误消息)
|
|
484
|
+
decorators.push(applyValidationMetadata(options));
|
|
420
485
|
return (0, common_1.applyDecorators)(...decorators);
|
|
421
486
|
}
|
|
422
487
|
function DateFieldOptional(options = {}) {
|
|
@@ -504,3 +569,72 @@ function LocaleField(options = {}) {
|
|
|
504
569
|
function LocaleFieldOptional(options = {}) {
|
|
505
570
|
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), LocaleField(Object.assign({ required: false }, options)));
|
|
506
571
|
}
|
|
572
|
+
// ========================================
|
|
573
|
+
// @Field - 元数据专用装饰器
|
|
574
|
+
// ========================================
|
|
575
|
+
/**
|
|
576
|
+
* @Field 装饰器
|
|
577
|
+
*
|
|
578
|
+
* 用于只需要元数据(Swagger、审计、UI配置)而不需要验证的字段
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* // 只需要 Swagger 文档和审计元数据,不需要验证
|
|
582
|
+
* @Field({
|
|
583
|
+
* label: { zh: '备注', en: 'Remarks' },
|
|
584
|
+
* description: { zh: '用户备注信息', en: 'User remarks' },
|
|
585
|
+
* ui: { showInList: true, showInDetail: true },
|
|
586
|
+
* })
|
|
587
|
+
* remarks: string;
|
|
588
|
+
*/
|
|
589
|
+
function Field(options = {}) {
|
|
590
|
+
const decorators = [];
|
|
591
|
+
// 标准化选项
|
|
592
|
+
// 添加类型转换(仅用于序列化)
|
|
593
|
+
const fieldType = options.type || 'string';
|
|
594
|
+
switch (fieldType) {
|
|
595
|
+
case 'number':
|
|
596
|
+
decorators.push((0, class_transformer_1.Type)(() => Number));
|
|
597
|
+
break;
|
|
598
|
+
case 'boolean':
|
|
599
|
+
decorators.push((0, class_transformer_1.Type)(() => Boolean));
|
|
600
|
+
break;
|
|
601
|
+
case 'object':
|
|
602
|
+
decorators.push((0, class_transformer_1.Type)(() => Object));
|
|
603
|
+
break;
|
|
604
|
+
case 'array':
|
|
605
|
+
decorators.push((0, class_transformer_1.Type)(() => Array));
|
|
606
|
+
if (options.each)
|
|
607
|
+
decorators.push((0, transform_decorators_1.ToArray)());
|
|
608
|
+
break;
|
|
609
|
+
case 'string':
|
|
610
|
+
default:
|
|
611
|
+
decorators.push((0, class_transformer_1.Type)(() => String));
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
// Swagger 文档
|
|
615
|
+
if (options.swagger !== false) {
|
|
616
|
+
const swaggerType = fieldType === 'array'
|
|
617
|
+
? String
|
|
618
|
+
: fieldType === 'object'
|
|
619
|
+
? Object
|
|
620
|
+
: fieldType === 'boolean'
|
|
621
|
+
? Boolean
|
|
622
|
+
: fieldType === 'number'
|
|
623
|
+
? Number
|
|
624
|
+
: String;
|
|
625
|
+
decorators.push((0, swagger_1.ApiProperty)(Object.assign({ type: swaggerType, isArray: fieldType === 'array' || options.each }, options)));
|
|
626
|
+
}
|
|
627
|
+
// 应用审计元数据
|
|
628
|
+
decorators.push(applyAuditMetadata(options));
|
|
629
|
+
// 应用验证元数据(用于错误消息)
|
|
630
|
+
decorators.push(applyValidationMetadata(options));
|
|
631
|
+
return (0, common_1.applyDecorators)(...decorators);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* @FieldOptional 装饰器
|
|
635
|
+
*
|
|
636
|
+
* 可选的元数据专用字段
|
|
637
|
+
*/
|
|
638
|
+
function FieldOptional(options = {}) {
|
|
639
|
+
return (0, common_1.applyDecorators)((0, validator_decorators_1.IsEmptyable)(), Field(Object.assign({ required: false }, options)));
|
|
640
|
+
}
|
|
@@ -31,5 +31,3 @@ export declare function ToInt(): PropertyDecorator;
|
|
|
31
31
|
export declare function ToArray(): PropertyDecorator;
|
|
32
32
|
export declare function ToLowerCase(): PropertyDecorator;
|
|
33
33
|
export declare function ToUpperCase(): PropertyDecorator;
|
|
34
|
-
export declare function S3UrlParser(): PropertyDecorator;
|
|
35
|
-
export declare function PhoneNumberSerializer(): PropertyDecorator;
|
|
@@ -6,12 +6,8 @@ exports.ToInt = ToInt;
|
|
|
6
6
|
exports.ToArray = ToArray;
|
|
7
7
|
exports.ToLowerCase = ToLowerCase;
|
|
8
8
|
exports.ToUpperCase = ToUpperCase;
|
|
9
|
-
exports.S3UrlParser = S3UrlParser;
|
|
10
|
-
exports.PhoneNumberSerializer = PhoneNumberSerializer;
|
|
11
9
|
const class_transformer_1 = require("class-transformer");
|
|
12
|
-
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
13
10
|
const lodash_1 = require("lodash");
|
|
14
|
-
const providers_1 = require("../providers");
|
|
15
11
|
/**
|
|
16
12
|
* @description trim spaces from start and end, replace multiple spaces with one.
|
|
17
13
|
* @example
|
|
@@ -108,22 +104,3 @@ function ToUpperCase() {
|
|
|
108
104
|
toClassOnly: true,
|
|
109
105
|
});
|
|
110
106
|
}
|
|
111
|
-
function S3UrlParser() {
|
|
112
|
-
return (0, class_transformer_1.Transform)((params) => {
|
|
113
|
-
const key = params.value;
|
|
114
|
-
switch (params.type) {
|
|
115
|
-
case class_transformer_1.TransformationType.CLASS_TO_PLAIN: {
|
|
116
|
-
return providers_1.GeneratorProvider.getS3PublicUrl(key);
|
|
117
|
-
}
|
|
118
|
-
case class_transformer_1.TransformationType.PLAIN_TO_CLASS: {
|
|
119
|
-
return providers_1.GeneratorProvider.getS3Key(key);
|
|
120
|
-
}
|
|
121
|
-
default: {
|
|
122
|
-
return key;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function PhoneNumberSerializer() {
|
|
128
|
-
return (0, class_transformer_1.Transform)((params) => (0, libphonenumber_js_1.parsePhoneNumber)(params.value).number);
|
|
129
|
-
}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import type { ITranslationDecoratorInterface } from '../interfaces';
|
|
2
2
|
export declare const STATIC_TRANSLATION_DECORATOR_KEY = "custom:static-translate";
|
|
3
3
|
export declare const DYNAMIC_TRANSLATION_DECORATOR_KEY = "custom:dynamic-translate";
|
|
4
|
+
/**
|
|
5
|
+
* 静态翻译装饰器
|
|
6
|
+
* 用于标记 DTO 字段需要进行翻译
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class UserDto {
|
|
11
|
+
* @StaticTranslate({ translationKey: 'user.status' })
|
|
12
|
+
* status: string;
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param data 翻译配置选项
|
|
17
|
+
*/
|
|
4
18
|
export declare function StaticTranslate(data?: ITranslationDecoratorInterface): PropertyDecorator;
|
|
19
|
+
/**
|
|
20
|
+
* 动态翻译装饰器
|
|
21
|
+
* 用于标记 DTO 字段需要动态翻译(从数据库获取翻译值)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* class ProductDto {
|
|
26
|
+
* @DynamicTranslate()
|
|
27
|
+
* name: string;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
5
31
|
export declare function DynamicTranslate(): PropertyDecorator;
|
|
@@ -5,12 +5,37 @@ exports.StaticTranslate = StaticTranslate;
|
|
|
5
5
|
exports.DynamicTranslate = DynamicTranslate;
|
|
6
6
|
exports.STATIC_TRANSLATION_DECORATOR_KEY = 'custom:static-translate';
|
|
7
7
|
exports.DYNAMIC_TRANSLATION_DECORATOR_KEY = 'custom:dynamic-translate';
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 静态翻译装饰器
|
|
10
|
+
* 用于标记 DTO 字段需要进行翻译
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* class UserDto {
|
|
15
|
+
* @StaticTranslate({ translationKey: 'user.status' })
|
|
16
|
+
* status: string;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param data 翻译配置选项
|
|
21
|
+
*/
|
|
9
22
|
function StaticTranslate(data = {}) {
|
|
10
23
|
return (target, key) => {
|
|
11
24
|
Reflect.defineMetadata(exports.STATIC_TRANSLATION_DECORATOR_KEY, data, target, key);
|
|
12
25
|
};
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* 动态翻译装饰器
|
|
29
|
+
* 用于标记 DTO 字段需要动态翻译(从数据库获取翻译值)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* class ProductDto {
|
|
34
|
+
* @DynamicTranslate()
|
|
35
|
+
* name: string;
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
14
39
|
function DynamicTranslate() {
|
|
15
40
|
return (target, key) => {
|
|
16
41
|
Reflect.defineMetadata(exports.DYNAMIC_TRANSLATION_DECORATOR_KEY, {}, target, key);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email log module dependency injection tokens
|
|
3
|
+
*/
|
|
4
|
+
export declare const EMAIL_LOG_OPTIONS: unique symbol;
|
|
5
|
+
export declare const EMAIL_LOG_TRANSPORT: unique symbol;
|
|
6
|
+
export declare const EMAIL_LOG_RATE_LIMITER: unique symbol;
|
|
7
|
+
export declare const EMAIL_LOG_FORMATTER: unique symbol;
|
|
8
|
+
export declare const EMAIL_LOG_ALERT: unique symbol;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Email log module dependency injection tokens
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EMAIL_LOG_ALERT = exports.EMAIL_LOG_FORMATTER = exports.EMAIL_LOG_RATE_LIMITER = exports.EMAIL_LOG_TRANSPORT = exports.EMAIL_LOG_OPTIONS = void 0;
|
|
7
|
+
exports.EMAIL_LOG_OPTIONS = Symbol('EMAIL_LOG_OPTIONS');
|
|
8
|
+
exports.EMAIL_LOG_TRANSPORT = Symbol('EMAIL_LOG_TRANSPORT');
|
|
9
|
+
exports.EMAIL_LOG_RATE_LIMITER = Symbol('EMAIL_LOG_RATE_LIMITER');
|
|
10
|
+
exports.EMAIL_LOG_FORMATTER = Symbol('EMAIL_LOG_FORMATTER');
|
|
11
|
+
exports.EMAIL_LOG_ALERT = Symbol('EMAIL_LOG_ALERT');
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { EmailLogOptions } from './interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Email log module for Pino transport
|
|
5
|
+
*
|
|
6
|
+
* Follows CacheModule pattern:
|
|
7
|
+
* - forRoot() and forRootAsync() static methods
|
|
8
|
+
* - Global module decorator
|
|
9
|
+
* - Async factory with dependency injection
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // In service-registry.module.ts
|
|
14
|
+
* if (process.env.EMAIL_LOG_ENABLED) {
|
|
15
|
+
* modules.push(
|
|
16
|
+
* EmailLogModule.forRootAsync({
|
|
17
|
+
* inject: [ApiConfigService],
|
|
18
|
+
* useFactory: (config: ApiConfigService) => ({
|
|
19
|
+
* enabled: true,
|
|
20
|
+
* to: config.getString('EMAIL_LOG_TO').split(','),
|
|
21
|
+
* from: config.getString('EMAIL_LOG_FROM'),
|
|
22
|
+
* smtpHost: config.getString('EMAIL_LOG_SMTP_HOST'),
|
|
23
|
+
* level: config.getString('EMAIL_LOG_LEVEL', 'error'),
|
|
24
|
+
* }),
|
|
25
|
+
* }),
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class EmailLogModule {
|
|
31
|
+
/**
|
|
32
|
+
* Register email log module with options
|
|
33
|
+
*/
|
|
34
|
+
static forRoot(options: EmailLogOptions): DynamicModule;
|
|
35
|
+
/**
|
|
36
|
+
* Register email log module asynchronously
|
|
37
|
+
*/
|
|
38
|
+
static forRootAsync(asyncOptions: {
|
|
39
|
+
inject?: any[];
|
|
40
|
+
useFactory: ((...args: any[]) => Promise<EmailLogOptions>) | ((...args: any[]) => EmailLogOptions);
|
|
41
|
+
isGlobal?: boolean;
|
|
42
|
+
}): DynamicModule;
|
|
43
|
+
/**
|
|
44
|
+
* Create providers for the module
|
|
45
|
+
*/
|
|
46
|
+
private static createProviders;
|
|
47
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var EmailLogModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EmailLogModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const email_log_transport_service_1 = require("./services/email-log-transport.service");
|
|
13
|
+
const email_log_formatter_service_1 = require("./services/email-log-formatter.service");
|
|
14
|
+
const email_log_rate_limiter_service_1 = require("./services/email-log-rate-limiter.service");
|
|
15
|
+
const email_log_alert_service_1 = require("./services/email-log-alert.service");
|
|
16
|
+
const email_log_constants_1 = require("./email-log.constants");
|
|
17
|
+
/**
|
|
18
|
+
* Email log module for Pino transport
|
|
19
|
+
*
|
|
20
|
+
* Follows CacheModule pattern:
|
|
21
|
+
* - forRoot() and forRootAsync() static methods
|
|
22
|
+
* - Global module decorator
|
|
23
|
+
* - Async factory with dependency injection
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // In service-registry.module.ts
|
|
28
|
+
* if (process.env.EMAIL_LOG_ENABLED) {
|
|
29
|
+
* modules.push(
|
|
30
|
+
* EmailLogModule.forRootAsync({
|
|
31
|
+
* inject: [ApiConfigService],
|
|
32
|
+
* useFactory: (config: ApiConfigService) => ({
|
|
33
|
+
* enabled: true,
|
|
34
|
+
* to: config.getString('EMAIL_LOG_TO').split(','),
|
|
35
|
+
* from: config.getString('EMAIL_LOG_FROM'),
|
|
36
|
+
* smtpHost: config.getString('EMAIL_LOG_SMTP_HOST'),
|
|
37
|
+
* level: config.getString('EMAIL_LOG_LEVEL', 'error'),
|
|
38
|
+
* }),
|
|
39
|
+
* }),
|
|
40
|
+
* );
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
let EmailLogModule = EmailLogModule_1 = class EmailLogModule {
|
|
45
|
+
/**
|
|
46
|
+
* Register email log module with options
|
|
47
|
+
*/
|
|
48
|
+
static forRoot(options) {
|
|
49
|
+
return {
|
|
50
|
+
module: EmailLogModule_1,
|
|
51
|
+
providers: this.createProviders(options),
|
|
52
|
+
exports: [
|
|
53
|
+
email_log_constants_1.EMAIL_LOG_TRANSPORT,
|
|
54
|
+
email_log_constants_1.EMAIL_LOG_ALERT,
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Register email log module asynchronously
|
|
60
|
+
*/
|
|
61
|
+
static forRootAsync(asyncOptions) {
|
|
62
|
+
const optionsProvider = {
|
|
63
|
+
provide: email_log_constants_1.EMAIL_LOG_OPTIONS,
|
|
64
|
+
useFactory: asyncOptions.useFactory,
|
|
65
|
+
inject: asyncOptions.inject || [],
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
module: EmailLogModule_1,
|
|
69
|
+
imports: [],
|
|
70
|
+
providers: [
|
|
71
|
+
optionsProvider,
|
|
72
|
+
// Rate limiter service (must be first as other services depend on it)
|
|
73
|
+
{
|
|
74
|
+
provide: email_log_constants_1.EMAIL_LOG_RATE_LIMITER,
|
|
75
|
+
useFactory: (options) => {
|
|
76
|
+
return new email_log_rate_limiter_service_1.EmailLogRateLimiterService(options.rateLimitMaxEmails || 10, options.rateLimitWindowMs || 60000, options.rateLimitBurstSize || 3);
|
|
77
|
+
},
|
|
78
|
+
inject: [email_log_constants_1.EMAIL_LOG_OPTIONS],
|
|
79
|
+
},
|
|
80
|
+
// Formatter service
|
|
81
|
+
{
|
|
82
|
+
provide: email_log_constants_1.EMAIL_LOG_FORMATTER,
|
|
83
|
+
useClass: email_log_formatter_service_1.EmailLogFormatterService,
|
|
84
|
+
},
|
|
85
|
+
// Transport service (depends on rate limiter and formatter)
|
|
86
|
+
{
|
|
87
|
+
provide: email_log_constants_1.EMAIL_LOG_TRANSPORT,
|
|
88
|
+
useClass: email_log_transport_service_1.EmailLogTransportService,
|
|
89
|
+
},
|
|
90
|
+
// Alert service (also depends on rate limiter and formatter)
|
|
91
|
+
{
|
|
92
|
+
provide: email_log_constants_1.EMAIL_LOG_ALERT,
|
|
93
|
+
useClass: email_log_alert_service_1.EmailLogAlertService,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
exports: [
|
|
97
|
+
email_log_constants_1.EMAIL_LOG_TRANSPORT,
|
|
98
|
+
email_log_constants_1.EMAIL_LOG_ALERT,
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create providers for the module
|
|
104
|
+
*/
|
|
105
|
+
static createProviders(options) {
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
provide: email_log_constants_1.EMAIL_LOG_OPTIONS,
|
|
109
|
+
useValue: options,
|
|
110
|
+
},
|
|
111
|
+
// Rate limiter service
|
|
112
|
+
{
|
|
113
|
+
provide: email_log_constants_1.EMAIL_LOG_RATE_LIMITER,
|
|
114
|
+
useFactory: () => {
|
|
115
|
+
return new email_log_rate_limiter_service_1.EmailLogRateLimiterService(options.rateLimitMaxEmails || 10, options.rateLimitWindowMs || 60000, options.rateLimitBurstSize || 3);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
// Formatter service
|
|
119
|
+
{
|
|
120
|
+
provide: email_log_constants_1.EMAIL_LOG_FORMATTER,
|
|
121
|
+
useClass: email_log_formatter_service_1.EmailLogFormatterService,
|
|
122
|
+
},
|
|
123
|
+
// Transport service
|
|
124
|
+
{
|
|
125
|
+
provide: email_log_constants_1.EMAIL_LOG_TRANSPORT,
|
|
126
|
+
useClass: email_log_transport_service_1.EmailLogTransportService,
|
|
127
|
+
},
|
|
128
|
+
// Alert service
|
|
129
|
+
{
|
|
130
|
+
provide: email_log_constants_1.EMAIL_LOG_ALERT,
|
|
131
|
+
useClass: email_log_alert_service_1.EmailLogAlertService,
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
exports.EmailLogModule = EmailLogModule;
|
|
137
|
+
exports.EmailLogModule = EmailLogModule = EmailLogModule_1 = __decorate([
|
|
138
|
+
(0, common_1.Global)(),
|
|
139
|
+
(0, common_1.Module)({})
|
|
140
|
+
], EmailLogModule);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { EmailLogModule } from './email-log.module';
|
|
2
|
+
export { EmailLogTransportService } from './services/email-log-transport.service';
|
|
3
|
+
export { EmailLogFormatterService } from './services/email-log-formatter.service';
|
|
4
|
+
export { EmailLogRateLimiterService } from './services/email-log-rate-limiter.service';
|
|
5
|
+
export { EmailLogAlertService } from './services/email-log-alert.service';
|
|
6
|
+
export { EmailLogLogger, createEmailLogger } from './services/email-log-logger.service';
|
|
7
|
+
export { PinoEmailTransport, createPinoEmailTransport } from './transports';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
export { EmailLogOptions } from './interfaces/email-log-options.interface';
|
|
10
|
+
export type { IEmailLogTransport } from './interfaces/email-log-transport.interface';
|
|
11
|
+
export { EMAIL_LOG_OPTIONS, EMAIL_LOG_TRANSPORT, EMAIL_LOG_RATE_LIMITER, EMAIL_LOG_FORMATTER, EMAIL_LOG_ALERT, } from './email-log.constants';
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
exports.EMAIL_LOG_ALERT = exports.EMAIL_LOG_FORMATTER = exports.EMAIL_LOG_RATE_LIMITER = exports.EMAIL_LOG_TRANSPORT = exports.EMAIL_LOG_OPTIONS = exports.EmailLogOptions = exports.createPinoEmailTransport = exports.PinoEmailTransport = exports.createEmailLogger = exports.EmailLogLogger = exports.EmailLogAlertService = exports.EmailLogRateLimiterService = exports.EmailLogFormatterService = exports.EmailLogTransportService = exports.EmailLogModule = void 0;
|
|
18
|
+
// Module
|
|
19
|
+
var email_log_module_1 = require("./email-log.module");
|
|
20
|
+
Object.defineProperty(exports, "EmailLogModule", { enumerable: true, get: function () { return email_log_module_1.EmailLogModule; } });
|
|
21
|
+
// Services
|
|
22
|
+
var email_log_transport_service_1 = require("./services/email-log-transport.service");
|
|
23
|
+
Object.defineProperty(exports, "EmailLogTransportService", { enumerable: true, get: function () { return email_log_transport_service_1.EmailLogTransportService; } });
|
|
24
|
+
var email_log_formatter_service_1 = require("./services/email-log-formatter.service");
|
|
25
|
+
Object.defineProperty(exports, "EmailLogFormatterService", { enumerable: true, get: function () { return email_log_formatter_service_1.EmailLogFormatterService; } });
|
|
26
|
+
var email_log_rate_limiter_service_1 = require("./services/email-log-rate-limiter.service");
|
|
27
|
+
Object.defineProperty(exports, "EmailLogRateLimiterService", { enumerable: true, get: function () { return email_log_rate_limiter_service_1.EmailLogRateLimiterService; } });
|
|
28
|
+
var email_log_alert_service_1 = require("./services/email-log-alert.service");
|
|
29
|
+
Object.defineProperty(exports, "EmailLogAlertService", { enumerable: true, get: function () { return email_log_alert_service_1.EmailLogAlertService; } });
|
|
30
|
+
var email_log_logger_service_1 = require("./services/email-log-logger.service");
|
|
31
|
+
Object.defineProperty(exports, "EmailLogLogger", { enumerable: true, get: function () { return email_log_logger_service_1.EmailLogLogger; } });
|
|
32
|
+
Object.defineProperty(exports, "createEmailLogger", { enumerable: true, get: function () { return email_log_logger_service_1.createEmailLogger; } });
|
|
33
|
+
// Transports (for direct Pino usage)
|
|
34
|
+
var transports_1 = require("./transports");
|
|
35
|
+
Object.defineProperty(exports, "PinoEmailTransport", { enumerable: true, get: function () { return transports_1.PinoEmailTransport; } });
|
|
36
|
+
Object.defineProperty(exports, "createPinoEmailTransport", { enumerable: true, get: function () { return transports_1.createPinoEmailTransport; } });
|
|
37
|
+
// Utils
|
|
38
|
+
__exportStar(require("./utils"), exports);
|
|
39
|
+
// Interfaces
|
|
40
|
+
var email_log_options_interface_1 = require("./interfaces/email-log-options.interface");
|
|
41
|
+
Object.defineProperty(exports, "EmailLogOptions", { enumerable: true, get: function () { return email_log_options_interface_1.EmailLogOptions; } });
|
|
42
|
+
// Constants
|
|
43
|
+
var email_log_constants_1 = require("./email-log.constants");
|
|
44
|
+
Object.defineProperty(exports, "EMAIL_LOG_OPTIONS", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_OPTIONS; } });
|
|
45
|
+
Object.defineProperty(exports, "EMAIL_LOG_TRANSPORT", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_TRANSPORT; } });
|
|
46
|
+
Object.defineProperty(exports, "EMAIL_LOG_RATE_LIMITER", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_RATE_LIMITER; } });
|
|
47
|
+
Object.defineProperty(exports, "EMAIL_LOG_FORMATTER", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_FORMATTER; } });
|
|
48
|
+
Object.defineProperty(exports, "EMAIL_LOG_ALERT", { enumerable: true, get: function () { return email_log_constants_1.EMAIL_LOG_ALERT; } });
|