@nest-omni/core 4.1.3-3 → 4.1.3-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +175 -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
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 字段装饰器 i18n 翻译使用示例
|
|
4
|
+
*
|
|
5
|
+
* 本示例演示如何使用 fieldI18n 选项通过 i18n key 进行多语言转换
|
|
6
|
+
*
|
|
7
|
+
* 注意:此示例文件仅供参考,展示如何使用 fieldI18n 选项。
|
|
8
|
+
* 如果使用 TypeScript 5+ 的新装饰器语法,需要确保 tsconfig.json 中
|
|
9
|
+
* "experimentalDecorators" 设置为 true。
|
|
10
|
+
*/
|
|
11
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
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;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
};
|
|
17
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.RegisterUserDto = exports.MixedDto = exports.PureLabelDto = exports.PureI18nDto = exports.UpdateUserDto = exports.CreateProductDto = exports.CreateUserDto = void 0;
|
|
22
|
+
const field_decorators_1 = require("../field.decorators");
|
|
23
|
+
// ============================================
|
|
24
|
+
// 步骤 1: 配置 i18n 翻译函数
|
|
25
|
+
// ============================================
|
|
26
|
+
/**
|
|
27
|
+
* 在应用启动时(如 app.module.ts 或 main.ts)配置 i18n 翻译函数
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // app.module.ts
|
|
31
|
+
* import { setI18nTranslate } from '@your-lib/core';
|
|
32
|
+
*
|
|
33
|
+
*@Module({
|
|
34
|
+
* imports: [
|
|
35
|
+
* ConfigModule.forRoot(),
|
|
36
|
+
* I18nModule.forRoot({
|
|
37
|
+
* fallbackLanguage: 'en',
|
|
38
|
+
* loader: TranslationsLoader({
|
|
39
|
+
* config: {
|
|
40
|
+
* defaultLanguage: 'zh',
|
|
41
|
+
* languages: ['zh', 'en'],
|
|
42
|
+
* types: ['validation', 'field'],
|
|
43
|
+
* },
|
|
44
|
+
* }),
|
|
45
|
+
* }),
|
|
46
|
+
* ],
|
|
47
|
+
* providers: [AppService],
|
|
48
|
+
* })
|
|
49
|
+
* export class AppModule implements OnModuleInit {
|
|
50
|
+
* constructor(private readonly i18n: I18nService) {}
|
|
51
|
+
*
|
|
52
|
+
* async onModuleInit() {
|
|
53
|
+
* // 设置全局 i18n 翻译函数
|
|
54
|
+
* setI18nTranslate((key, options) => this.i18n.translate(key, options));
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
// ============================================
|
|
59
|
+
// 步骤 2: 在翻译文件中定义字段标签
|
|
60
|
+
// ============================================
|
|
61
|
+
/**
|
|
62
|
+
* 翻译文件结构示例 (src/i18n/zh.json):
|
|
63
|
+
*
|
|
64
|
+
* {
|
|
65
|
+
* "field": {
|
|
66
|
+
* "user": {
|
|
67
|
+
* "username": "用户名",
|
|
68
|
+
* "email": "邮箱",
|
|
69
|
+
* "phone": "手机号",
|
|
70
|
+
* "role": "角色",
|
|
71
|
+
* "status": "状态",
|
|
72
|
+
* "description": "个人简介"
|
|
73
|
+
* },
|
|
74
|
+
* "product": {
|
|
75
|
+
* "name": "产品名称",
|
|
76
|
+
* "price": "价格",
|
|
77
|
+
* "stock": "库存",
|
|
78
|
+
* "status": "产品状态"
|
|
79
|
+
* }
|
|
80
|
+
* },
|
|
81
|
+
* "field.value": {
|
|
82
|
+
* "user.role": {
|
|
83
|
+
* "user": "普通用户",
|
|
84
|
+
* "admin": "管理员",
|
|
85
|
+
* "vip": "VIP用户"
|
|
86
|
+
* },
|
|
87
|
+
* "user.status": {
|
|
88
|
+
* "active": "正常",
|
|
89
|
+
* "inactive": "未激活",
|
|
90
|
+
* "suspended": "已暂停"
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* 翻译文件结构示例 (src/i18n/en.json):
|
|
96
|
+
*
|
|
97
|
+
* {
|
|
98
|
+
* "field": {
|
|
99
|
+
* "user": {
|
|
100
|
+
* "username": "Username",
|
|
101
|
+
* "email": "Email",
|
|
102
|
+
* "phone": "Phone Number",
|
|
103
|
+
* "role": "Role",
|
|
104
|
+
* "status": "Status",
|
|
105
|
+
* "description": "Bio"
|
|
106
|
+
* },
|
|
107
|
+
* "product": {
|
|
108
|
+
* "name": "Product Name",
|
|
109
|
+
* "price": "Price",
|
|
110
|
+
* "stock": "Stock",
|
|
111
|
+
* "status": "Product Status"
|
|
112
|
+
* }
|
|
113
|
+
* },
|
|
114
|
+
* "field.value": {
|
|
115
|
+
* "user.role": {
|
|
116
|
+
* "user": "User",
|
|
117
|
+
* "admin": "Administrator",
|
|
118
|
+
* "vip": "VIP User"
|
|
119
|
+
* },
|
|
120
|
+
* "user.status": {
|
|
121
|
+
* "active": "Active",
|
|
122
|
+
* "inactive": "Inactive",
|
|
123
|
+
* "suspended": "Suspended"
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
*/
|
|
128
|
+
// ============================================
|
|
129
|
+
// 步骤 3: 在 DTO 中使用 fieldI18n
|
|
130
|
+
// ============================================
|
|
131
|
+
/**
|
|
132
|
+
* 用户 DTO - 使用 i18n key
|
|
133
|
+
*/
|
|
134
|
+
class CreateUserDto {
|
|
135
|
+
}
|
|
136
|
+
exports.CreateUserDto = CreateUserDto;
|
|
137
|
+
__decorate([
|
|
138
|
+
(0, field_decorators_1.StringField)({
|
|
139
|
+
minLength: 3,
|
|
140
|
+
maxLength: 20,
|
|
141
|
+
fieldI18n: 'field.user.username',
|
|
142
|
+
// 注意: 如果同时提供 fieldI18n 和 fieldLabel,fieldLabel 优先级更高
|
|
143
|
+
// fieldLabel: { zh: '用户名', en: 'Username' },
|
|
144
|
+
}),
|
|
145
|
+
__metadata("design:type", String)
|
|
146
|
+
], CreateUserDto.prototype, "username", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
(0, field_decorators_1.StringField)({
|
|
149
|
+
fieldI18n: 'field.user.email',
|
|
150
|
+
}),
|
|
151
|
+
__metadata("design:type", String)
|
|
152
|
+
], CreateUserDto.prototype, "email", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, field_decorators_1.StringFieldOptional)({
|
|
155
|
+
maxLength: 11,
|
|
156
|
+
fieldI18n: 'field.user.phone',
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", String)
|
|
159
|
+
], CreateUserDto.prototype, "phone", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, field_decorators_1.StringFieldOptional)({
|
|
162
|
+
maxLength: 500,
|
|
163
|
+
fieldI18n: 'field.user.description',
|
|
164
|
+
}),
|
|
165
|
+
__metadata("design:type", String)
|
|
166
|
+
], CreateUserDto.prototype, "description", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, field_decorators_1.BooleanFieldOptional)({
|
|
169
|
+
fieldI18n: 'field.user.emailVerified',
|
|
170
|
+
valueLabels: {
|
|
171
|
+
// valueLabels 也支持 i18n key
|
|
172
|
+
true: 'field.user.emailVerified.yes',
|
|
173
|
+
false: 'field.user.emailVerified.no',
|
|
174
|
+
// 或者直接使用多语言对象
|
|
175
|
+
// true: { zh: '已验证', en: 'Verified' },
|
|
176
|
+
// false: { zh: '未验证', en: 'Not Verified' },
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
__metadata("design:type", Boolean)
|
|
180
|
+
], CreateUserDto.prototype, "emailVerified", void 0);
|
|
181
|
+
/**
|
|
182
|
+
* 产品 DTO - 使用 i18n key
|
|
183
|
+
*/
|
|
184
|
+
class CreateProductDto {
|
|
185
|
+
}
|
|
186
|
+
exports.CreateProductDto = CreateProductDto;
|
|
187
|
+
__decorate([
|
|
188
|
+
(0, field_decorators_1.StringField)({
|
|
189
|
+
minLength: 1,
|
|
190
|
+
maxLength: 200,
|
|
191
|
+
fieldI18n: 'field.product.name',
|
|
192
|
+
}),
|
|
193
|
+
__metadata("design:type", String)
|
|
194
|
+
], CreateProductDto.prototype, "name", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
(0, field_decorators_1.NumberField)({
|
|
197
|
+
min: 0,
|
|
198
|
+
fieldI18n: 'field.product.price',
|
|
199
|
+
}),
|
|
200
|
+
__metadata("design:type", Number)
|
|
201
|
+
], CreateProductDto.prototype, "price", void 0);
|
|
202
|
+
__decorate([
|
|
203
|
+
(0, field_decorators_1.NumberField)({
|
|
204
|
+
min: 0,
|
|
205
|
+
fieldI18n: 'field.product.stock',
|
|
206
|
+
}),
|
|
207
|
+
__metadata("design:type", Number)
|
|
208
|
+
], CreateProductDto.prototype, "stock", void 0);
|
|
209
|
+
// ============================================
|
|
210
|
+
// 步骤 4: 枚举字段的 i18n 使用
|
|
211
|
+
// ============================================
|
|
212
|
+
var UserRole;
|
|
213
|
+
(function (UserRole) {
|
|
214
|
+
UserRole["USER"] = "user";
|
|
215
|
+
UserRole["ADMIN"] = "admin";
|
|
216
|
+
UserRole["VIP"] = "vip";
|
|
217
|
+
})(UserRole || (UserRole = {}));
|
|
218
|
+
var UserStatus;
|
|
219
|
+
(function (UserStatus) {
|
|
220
|
+
UserStatus["ACTIVE"] = "active";
|
|
221
|
+
UserStatus["INACTIVE"] = "inactive";
|
|
222
|
+
UserStatus["SUSPENDED"] = "suspended";
|
|
223
|
+
})(UserStatus || (UserStatus = {}));
|
|
224
|
+
/**
|
|
225
|
+
* 用户更新 DTO - 枚举字段使用 i18n
|
|
226
|
+
*/
|
|
227
|
+
class UpdateUserDto {
|
|
228
|
+
}
|
|
229
|
+
exports.UpdateUserDto = UpdateUserDto;
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, field_decorators_1.EnumField)(() => UserRole, {
|
|
232
|
+
fieldI18n: 'field.user.role',
|
|
233
|
+
valueLabels: {
|
|
234
|
+
// 使用 i18n key 指向枚举值的翻译
|
|
235
|
+
[UserRole.USER]: 'field.value.user.role.user',
|
|
236
|
+
[UserRole.ADMIN]: 'field.value.user.role.admin',
|
|
237
|
+
[UserRole.VIP]: 'field.value.user.role.vip',
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
__metadata("design:type", String)
|
|
241
|
+
], UpdateUserDto.prototype, "role", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
(0, field_decorators_1.EnumField)(() => UserStatus, {
|
|
244
|
+
fieldI18n: 'field.user.status',
|
|
245
|
+
valueLabels: {
|
|
246
|
+
[UserStatus.ACTIVE]: 'field.value.user.status.active',
|
|
247
|
+
[UserStatus.INACTIVE]: 'field.value.user.status.inactive',
|
|
248
|
+
[UserStatus.SUSPENDED]: 'field.value.user.status.suspended',
|
|
249
|
+
},
|
|
250
|
+
}),
|
|
251
|
+
__metadata("design:type", String)
|
|
252
|
+
], UpdateUserDto.prototype, "status", void 0);
|
|
253
|
+
// ============================================
|
|
254
|
+
// 步骤 5: 在验证错误过滤器中使用 i18n
|
|
255
|
+
// ============================================
|
|
256
|
+
/**
|
|
257
|
+
* 验证错误过滤器示例
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* import { getValidationMetadata, getFieldLabelForValidation } from '@your-lib/core';
|
|
261
|
+
*
|
|
262
|
+
* @Catch(ValidationError)
|
|
263
|
+
* export class ValidationErrorFilter implements ExceptionFilter {
|
|
264
|
+
* catch(exception: ValidationError, host: ArgumentsHost) {
|
|
265
|
+
* const ctx = host.switchToHttp();
|
|
266
|
+
* const response = ctx.getResponse<Response>();
|
|
267
|
+
* const request = ctx.getRequest<Request>();
|
|
268
|
+
* const language = request.headers['accept-language'] || 'zh';
|
|
269
|
+
*
|
|
270
|
+
* const errors = exception.errors.map(error => {
|
|
271
|
+
* const metadata = getValidationMetadata(error.target.constructor, error.property);
|
|
272
|
+
* const fieldLabel = getFieldLabelForValidation(metadata, language);
|
|
273
|
+
*
|
|
274
|
+
* // 如果 fieldLabel 是 i18n key,需要翻译
|
|
275
|
+
* const displayLabel = fieldLabel.includes('.')
|
|
276
|
+
* ? this.i18n.translate(fieldLabel, { lang: language })
|
|
277
|
+
* : fieldLabel;
|
|
278
|
+
*
|
|
279
|
+
* return {
|
|
280
|
+
* field: error.property,
|
|
281
|
+
* fieldLabel: displayLabel,
|
|
282
|
+
* constraints: error.constraints,
|
|
283
|
+
* };
|
|
284
|
+
* });
|
|
285
|
+
*
|
|
286
|
+
* response.status(400).json({
|
|
287
|
+
* statusCode: 400,
|
|
288
|
+
* message: 'Validation failed',
|
|
289
|
+
* errors,
|
|
290
|
+
* });
|
|
291
|
+
* }
|
|
292
|
+
* }
|
|
293
|
+
*/
|
|
294
|
+
// ============================================
|
|
295
|
+
// 步骤 6: 在审计日志中使用 i18n
|
|
296
|
+
// ============================================
|
|
297
|
+
/**
|
|
298
|
+
* 审计日志服务示例
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* import { getAuditMetadata } from '@your-lib/core';
|
|
302
|
+
*
|
|
303
|
+
* @Injectable()
|
|
304
|
+
* export class AuditService {
|
|
305
|
+
* constructor(private readonly i18n: I18nService) {}
|
|
306
|
+
*
|
|
307
|
+
* async logFieldChange(
|
|
308
|
+
* entity: any,
|
|
309
|
+
* field: string,
|
|
310
|
+
* oldValue: any,
|
|
311
|
+
* newValue: any,
|
|
312
|
+
* language: string = 'zh',
|
|
313
|
+
* ) {
|
|
314
|
+
* const metadata = getAuditMetadata(entity.constructor, field);
|
|
315
|
+
*
|
|
316
|
+
* // 翻译字段标签
|
|
317
|
+
* let fieldLabel = metadata?.label || field;
|
|
318
|
+
* if (typeof fieldLabel === 'string' && fieldLabel.includes('.')) {
|
|
319
|
+
* fieldLabel = await this.i18n.translate(fieldLabel, { lang: language });
|
|
320
|
+
* } else if (typeof fieldLabel === 'object') {
|
|
321
|
+
* fieldLabel = fieldLabel[language] || fieldLabel.zh || fieldLabel.en;
|
|
322
|
+
* }
|
|
323
|
+
*
|
|
324
|
+
* // 翻译枚举值
|
|
325
|
+
* const valueLabels = metadata?.valueLabels;
|
|
326
|
+
* const displayOldValue = valueLabels?.[oldValue]
|
|
327
|
+
* ? await this.translateValueLabel(valueLabels[oldValue], language)
|
|
328
|
+
* : oldValue;
|
|
329
|
+
* const displayNewValue = valueLabels?.[newValue]
|
|
330
|
+
* ? await this.translateValueLabel(valueLabels[newValue], language)
|
|
331
|
+
* : newValue;
|
|
332
|
+
*
|
|
333
|
+
* return {
|
|
334
|
+
* fieldLabel,
|
|
335
|
+
* oldValue,
|
|
336
|
+
* newValue,
|
|
337
|
+
* displayOldValue,
|
|
338
|
+
* displayNewValue,
|
|
339
|
+
* };
|
|
340
|
+
* }
|
|
341
|
+
*
|
|
342
|
+
* private async translateValueLabel(
|
|
343
|
+
* label: string | { [lang: string]: string },
|
|
344
|
+
* language: string,
|
|
345
|
+
* ): Promise<string> {
|
|
346
|
+
* if (typeof label === 'string' && label.includes('.')) {
|
|
347
|
+
* return await this.i18n.translate(label, { lang: language });
|
|
348
|
+
* }
|
|
349
|
+
* if (typeof label === 'object') {
|
|
350
|
+
* return label[language] || label.zh || label.en || '';
|
|
351
|
+
* }
|
|
352
|
+
* return label;
|
|
353
|
+
* }
|
|
354
|
+
* }
|
|
355
|
+
*/
|
|
356
|
+
// ============================================
|
|
357
|
+
// 使用场景对比
|
|
358
|
+
// ============================================
|
|
359
|
+
/**
|
|
360
|
+
* 场景 1: 纯 i18n key 方式(推荐)
|
|
361
|
+
*
|
|
362
|
+
* 优点:
|
|
363
|
+
* - 翻译集中管理,易于维护
|
|
364
|
+
* - 支持动态切换语言
|
|
365
|
+
* - 翻译可以复用
|
|
366
|
+
* - 适合大型项目和国际化需求
|
|
367
|
+
*
|
|
368
|
+
* 缺点:
|
|
369
|
+
* - 需要额外的翻译文件配置
|
|
370
|
+
* - 增加了一定的复杂度
|
|
371
|
+
*/
|
|
372
|
+
class PureI18nDto {
|
|
373
|
+
}
|
|
374
|
+
exports.PureI18nDto = PureI18nDto;
|
|
375
|
+
__decorate([
|
|
376
|
+
(0, field_decorators_1.StringField)({
|
|
377
|
+
minLength: 3,
|
|
378
|
+
maxLength: 20,
|
|
379
|
+
fieldI18n: 'field.user.username',
|
|
380
|
+
}),
|
|
381
|
+
__metadata("design:type", String)
|
|
382
|
+
], PureI18nDto.prototype, "username", void 0);
|
|
383
|
+
/**
|
|
384
|
+
* 场景 2: 纯多语言对象方式
|
|
385
|
+
*
|
|
386
|
+
* 优点:
|
|
387
|
+
* - 简单直接,无需额外配置
|
|
388
|
+
* - 适合小型项目或固定语言场景
|
|
389
|
+
* - 翻译就在代码中,查看方便
|
|
390
|
+
*
|
|
391
|
+
* 缺点:
|
|
392
|
+
* - 翻译分散在各个 DTO 中,难以统一管理
|
|
393
|
+
* - 不易于动态切换语言
|
|
394
|
+
* - 翻译无法复用
|
|
395
|
+
*/
|
|
396
|
+
class PureLabelDto {
|
|
397
|
+
}
|
|
398
|
+
exports.PureLabelDto = PureLabelDto;
|
|
399
|
+
__decorate([
|
|
400
|
+
(0, field_decorators_1.StringField)({
|
|
401
|
+
minLength: 3,
|
|
402
|
+
maxLength: 20,
|
|
403
|
+
fieldLabel: { zh: '用户名', en: 'Username' },
|
|
404
|
+
}),
|
|
405
|
+
__metadata("design:type", String)
|
|
406
|
+
], PureLabelDto.prototype, "username", void 0);
|
|
407
|
+
/**
|
|
408
|
+
* 场景 3: 混合方式(fieldLabel 优先)
|
|
409
|
+
*
|
|
410
|
+
* 优点:
|
|
411
|
+
* - 灵活性最高
|
|
412
|
+
* - 可以为特定字段覆盖 i18n 翻译
|
|
413
|
+
*
|
|
414
|
+
* 缺点:
|
|
415
|
+
* - 可能造成混淆
|
|
416
|
+
* - 建议统一使用一种方式
|
|
417
|
+
*/
|
|
418
|
+
class MixedDto {
|
|
419
|
+
}
|
|
420
|
+
exports.MixedDto = MixedDto;
|
|
421
|
+
__decorate([
|
|
422
|
+
(0, field_decorators_1.StringField)({
|
|
423
|
+
minLength: 3,
|
|
424
|
+
maxLength: 20,
|
|
425
|
+
fieldI18n: 'field.user.username', // 会被 fieldLabel 覆盖
|
|
426
|
+
fieldLabel: { zh: '用户名(自定义)', en: 'Username (Custom)' },
|
|
427
|
+
}),
|
|
428
|
+
__metadata("design:type", String)
|
|
429
|
+
], MixedDto.prototype, "username", void 0);
|
|
430
|
+
// ============================================
|
|
431
|
+
// 完整示例:用户注册 DTO
|
|
432
|
+
// ============================================
|
|
433
|
+
class RegisterUserDto {
|
|
434
|
+
}
|
|
435
|
+
exports.RegisterUserDto = RegisterUserDto;
|
|
436
|
+
__decorate([
|
|
437
|
+
(0, field_decorators_1.StringField)({
|
|
438
|
+
minLength: 3,
|
|
439
|
+
maxLength: 20,
|
|
440
|
+
fieldI18n: 'field.user.username',
|
|
441
|
+
fieldDescription: {
|
|
442
|
+
zh: '用于登录的唯一用户名',
|
|
443
|
+
en: 'Unique username for login',
|
|
444
|
+
},
|
|
445
|
+
}),
|
|
446
|
+
__metadata("design:type", String)
|
|
447
|
+
], RegisterUserDto.prototype, "username", void 0);
|
|
448
|
+
__decorate([
|
|
449
|
+
(0, field_decorators_1.StringField)({
|
|
450
|
+
fieldI18n: 'field.user.email',
|
|
451
|
+
}),
|
|
452
|
+
__metadata("design:type", String)
|
|
453
|
+
], RegisterUserDto.prototype, "email", void 0);
|
|
454
|
+
__decorate([
|
|
455
|
+
(0, field_decorators_1.StringField)({
|
|
456
|
+
minLength: 6,
|
|
457
|
+
fieldI18n: 'field.user.password',
|
|
458
|
+
}),
|
|
459
|
+
__metadata("design:type", String)
|
|
460
|
+
], RegisterUserDto.prototype, "password", void 0);
|
|
461
|
+
__decorate([
|
|
462
|
+
(0, field_decorators_1.StringFieldOptional)({
|
|
463
|
+
minLength: 11,
|
|
464
|
+
maxLength: 11,
|
|
465
|
+
fieldI18n: 'field.user.phone',
|
|
466
|
+
}),
|
|
467
|
+
__metadata("design:type", String)
|
|
468
|
+
], RegisterUserDto.prototype, "phone", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
(0, field_decorators_1.BooleanFieldOptional)({
|
|
471
|
+
fieldI18n: 'field.user.agreeTerms',
|
|
472
|
+
valueLabels: {
|
|
473
|
+
true: { zh: '同意', en: 'Agreed' },
|
|
474
|
+
false: { zh: '未同意', en: 'Not Agreed' },
|
|
475
|
+
},
|
|
476
|
+
}),
|
|
477
|
+
__metadata("design:type", Boolean)
|
|
478
|
+
], RegisterUserDto.prototype, "agreeTerms", void 0);
|
|
@@ -7,6 +7,75 @@ interface IFieldOptions {
|
|
|
7
7
|
nullable?: boolean;
|
|
8
8
|
group?: string[];
|
|
9
9
|
message?: string;
|
|
10
|
+
skipValidation?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* i18n 翻译键
|
|
13
|
+
* 用于通过 i18n key 进行多语言转换
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // 使用 i18n key
|
|
17
|
+
* @StringField({
|
|
18
|
+
* fieldI18n: 'user.username',
|
|
19
|
+
* })
|
|
20
|
+
* username: string;
|
|
21
|
+
*
|
|
22
|
+
* // 翻译文件中定义:
|
|
23
|
+
* // {
|
|
24
|
+
* // "user": {
|
|
25
|
+
* // "username": "用户名" // 或 "Username" for English
|
|
26
|
+
* // }
|
|
27
|
+
* // }
|
|
28
|
+
*/
|
|
29
|
+
fieldI18n?: string;
|
|
30
|
+
/**
|
|
31
|
+
* 字段标签(多语言)
|
|
32
|
+
* 用于审计日志、验证错误消息、UI 显示等
|
|
33
|
+
* 注意:如果同时提供了 fieldI18n 和 fieldLabel,fieldLabel 优先级更高
|
|
34
|
+
*/
|
|
35
|
+
fieldLabel?: string | {
|
|
36
|
+
zh?: string;
|
|
37
|
+
en?: string;
|
|
38
|
+
[lang: string]: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 字段描述(多语言)
|
|
42
|
+
* 用于 API 文档、审计日志等
|
|
43
|
+
* 支持两种形式:
|
|
44
|
+
* 1. i18n key: "user.username.description"
|
|
45
|
+
* 2. 直接多语言对象: { zh: '...', en: '...' }
|
|
46
|
+
*/
|
|
47
|
+
fieldDescription?: string | {
|
|
48
|
+
zh?: string;
|
|
49
|
+
en?: string;
|
|
50
|
+
[lang: string]: string | undefined;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 示例值
|
|
54
|
+
* 用于 API 文档
|
|
55
|
+
*/
|
|
56
|
+
fieldExample?: any;
|
|
57
|
+
/**
|
|
58
|
+
* 值标签映射(多语言)
|
|
59
|
+
* 用于枚举、布尔值的友好显示(审计日志、UI)
|
|
60
|
+
*/
|
|
61
|
+
valueLabels?: {
|
|
62
|
+
[value: string]: string | {
|
|
63
|
+
zh?: string;
|
|
64
|
+
en?: string;
|
|
65
|
+
[lang: string]: string | undefined;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 格式化函数
|
|
70
|
+
* 用于自定义显示格式(审计日志)
|
|
71
|
+
* 注意:命名为 displayFormatter 避免与 ApiPropertyOptions.format 冲突
|
|
72
|
+
*/
|
|
73
|
+
displayFormatter?: (value: any, language?: string) => string;
|
|
74
|
+
/**
|
|
75
|
+
* 是否敏感字段
|
|
76
|
+
* 用于审计日志脱敏
|
|
77
|
+
*/
|
|
78
|
+
sensitive?: boolean;
|
|
10
79
|
}
|
|
11
80
|
interface INumberFieldOptions extends IFieldOptions {
|
|
12
81
|
min?: number;
|
|
@@ -58,8 +127,6 @@ export declare function EnumFieldOptional<TEnum extends object>(getEnum: () => T
|
|
|
58
127
|
export declare function ClassFieldOptional<TClass extends object>(getClass: () => TClass, options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IClassFieldOptions): PropertyDecorator;
|
|
59
128
|
export declare function EmailField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions & IEmailFieldOptions): PropertyDecorator;
|
|
60
129
|
export declare function EmailFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions & IEmailFieldOptions): PropertyDecorator;
|
|
61
|
-
export declare function PhoneField(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions): PropertyDecorator;
|
|
62
|
-
export declare function PhoneFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IFieldOptions): PropertyDecorator;
|
|
63
130
|
export declare function UUIDField(options?: Omit<ApiPropertyOptions, 'type' | 'format' | 'isArray'> & IFieldOptions): PropertyDecorator;
|
|
64
131
|
export declare function UUIDFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required' | 'isArray'> & IFieldOptions): PropertyDecorator;
|
|
65
132
|
export declare function URLField(options?: Omit<ApiPropertyOptions, 'type'> & IURLFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
@@ -69,11 +136,36 @@ export declare function FQDNFieldOptional(options?: Omit<ApiPropertyOptions, 'ty
|
|
|
69
136
|
export declare function DateField(options?: Omit<ApiPropertyOptions, 'type'> & IDateFieldOptions): PropertyDecorator;
|
|
70
137
|
export declare function DateFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IDateFieldOptions): PropertyDecorator;
|
|
71
138
|
export declare function IpFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IIPFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
72
|
-
export declare function IpField(options
|
|
139
|
+
export declare function IpField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions & IIPFieldOptions): PropertyDecorator;
|
|
73
140
|
export declare function ObjectField(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions): PropertyDecorator;
|
|
74
141
|
export declare function ObjectFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions): PropertyDecorator;
|
|
75
142
|
export declare function TimeZoneField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
76
143
|
export declare function TimeZoneFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
77
144
|
export declare function LocaleField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
78
145
|
export declare function LocaleFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
146
|
+
/**
|
|
147
|
+
* @Field 装饰器
|
|
148
|
+
*
|
|
149
|
+
* 用于只需要元数据(Swagger、审计、UI配置)而不需要验证的字段
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // 只需要 Swagger 文档和审计元数据,不需要验证
|
|
153
|
+
* @Field({
|
|
154
|
+
* label: { zh: '备注', en: 'Remarks' },
|
|
155
|
+
* description: { zh: '用户备注信息', en: 'User remarks' },
|
|
156
|
+
* ui: { showInList: true, showInDetail: true },
|
|
157
|
+
* })
|
|
158
|
+
* remarks: string;
|
|
159
|
+
*/
|
|
160
|
+
export declare function Field(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions & {
|
|
161
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
162
|
+
}): PropertyDecorator;
|
|
163
|
+
/**
|
|
164
|
+
* @FieldOptional 装饰器
|
|
165
|
+
*
|
|
166
|
+
* 可选的元数据专用字段
|
|
167
|
+
*/
|
|
168
|
+
export declare function FieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IFieldOptions & {
|
|
169
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
170
|
+
}): PropertyDecorator;
|
|
79
171
|
export {};
|