@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
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { CircuitBreakerConfig,
|
|
2
|
+
import { CircuitBreakerConfig, HttpClientConfig, RetryConfig } from '../interfaces/http-client-config.interface';
|
|
3
3
|
export declare const HTTP_CLIENT_OPTIONS_KEY = "http_client_options";
|
|
4
4
|
export declare const RETRY_OPTIONS_KEY = "http_retry_options";
|
|
5
5
|
export declare const CIRCUIT_BREAKER_OPTIONS_KEY = "http_circuit_breaker_options";
|
|
6
|
-
export declare const CACHE_OPTIONS_KEY = "http_cache_options";
|
|
7
6
|
export declare const LOGGING_OPTIONS_KEY = "http_logging_options";
|
|
8
7
|
export declare const TIMEOUT_OPTIONS_KEY = "http_timeout_options";
|
|
9
8
|
export declare const PROXY_OPTIONS_KEY = "http_proxy_options";
|
|
@@ -18,6 +17,7 @@ export declare const HttpClient: (options?: HttpClientConfig) => (target: any) =
|
|
|
18
17
|
* 基于axios-retry库
|
|
19
18
|
*/
|
|
20
19
|
export declare const HttpRetry: (options?: {
|
|
20
|
+
enabled?: boolean;
|
|
21
21
|
retries?: number;
|
|
22
22
|
retryDelay?: (retryCount: number) => number;
|
|
23
23
|
retryCondition?: (error: any) => boolean;
|
|
@@ -34,24 +34,6 @@ export declare const HttpCircuitBreaker: (options?: {
|
|
|
34
34
|
monitoringPeriodMs?: number;
|
|
35
35
|
minimumThroughputThreshold?: number;
|
|
36
36
|
}) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
37
|
-
/**
|
|
38
|
-
* HTTP缓存装饰器
|
|
39
|
-
* 集成现有的三层缓存架构
|
|
40
|
-
*/
|
|
41
|
-
export declare const HttpCacheable: (options?: {
|
|
42
|
-
/** 缓存TTL(毫秒) */
|
|
43
|
-
ttl?: number;
|
|
44
|
-
/** 缓存键 */
|
|
45
|
-
key?: string | ((...args: any[]) => string);
|
|
46
|
-
/** 缓存层 */
|
|
47
|
-
layers?: Array<"cls" | "memory" | "redis">;
|
|
48
|
-
/** 缓存条件 */
|
|
49
|
-
condition?: (...args: any[]) => boolean | Promise<boolean>;
|
|
50
|
-
/** 除非条件 */
|
|
51
|
-
unless?: string | ((result: any, args: any[]) => boolean);
|
|
52
|
-
/** 命名空间 */
|
|
53
|
-
namespace?: string;
|
|
54
|
-
}) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
55
37
|
/**
|
|
56
38
|
* 请求日志装饰器
|
|
57
39
|
* 类似Spring Boot的@LogRequest注解
|
|
@@ -59,7 +41,7 @@ export declare const HttpCacheable: (options?: {
|
|
|
59
41
|
export declare const HttpLogRequest: (options?: {
|
|
60
42
|
logHeaders?: boolean;
|
|
61
43
|
logBody?: boolean;
|
|
62
|
-
|
|
44
|
+
sanitize?: string[];
|
|
63
45
|
databaseLog?: boolean;
|
|
64
46
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
65
47
|
serviceClass?: string;
|
|
@@ -75,8 +57,10 @@ export declare const HttpTimeout: (timeoutMs: number) => (target: any, propertyK
|
|
|
75
57
|
* 代理装饰器
|
|
76
58
|
*/
|
|
77
59
|
export declare const HttpUseProxy: (options: {
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
fromEnvironment?: boolean;
|
|
62
|
+
host?: string;
|
|
63
|
+
port?: number;
|
|
80
64
|
protocol?: "http" | "https";
|
|
81
65
|
auth?: {
|
|
82
66
|
username: string;
|
|
@@ -95,10 +79,6 @@ export declare class HttpDecoratorUtils {
|
|
|
95
79
|
* 获取方法上的熔断器配置
|
|
96
80
|
*/
|
|
97
81
|
static getCircuitBreakerOptions(target: any, propertyKey: string): CircuitBreakerConfig | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* 获取方法上的缓存配置
|
|
100
|
-
*/
|
|
101
|
-
static getCacheOptions(target: any, propertyKey: string): HttpCacheConfig | undefined;
|
|
102
82
|
/**
|
|
103
83
|
* 获取方法上的日志配置
|
|
104
84
|
*/
|
|
@@ -125,7 +105,6 @@ export declare class HttpDecoratorUtils {
|
|
|
125
105
|
static getAllDecoratorConfigs(target: any, propertyKey: string): {
|
|
126
106
|
retry?: RetryConfig;
|
|
127
107
|
circuitBreaker?: CircuitBreakerConfig;
|
|
128
|
-
cache?: HttpCacheConfig;
|
|
129
108
|
logging?: any;
|
|
130
109
|
timeout?: number;
|
|
131
110
|
proxy?: any;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpDecoratorUtils = exports.HttpUseProxy = exports.HttpTimeout = exports.HttpLogRequest = exports.
|
|
3
|
+
exports.HttpDecoratorUtils = exports.HttpUseProxy = exports.HttpTimeout = exports.HttpLogRequest = exports.HttpCircuitBreaker = exports.HttpRetry = exports.HttpClient = exports.CALL_INFO_KEY = exports.PROXY_OPTIONS_KEY = exports.TIMEOUT_OPTIONS_KEY = exports.LOGGING_OPTIONS_KEY = exports.CIRCUIT_BREAKER_OPTIONS_KEY = exports.RETRY_OPTIONS_KEY = exports.HTTP_CLIENT_OPTIONS_KEY = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const cache_options_interface_1 = require("../../cache/interfaces/cache-options.interface");
|
|
7
6
|
const call_stack_extractor_util_1 = require("../utils/call-stack-extractor.util");
|
|
8
7
|
// 装饰器元数据键
|
|
9
8
|
exports.HTTP_CLIENT_OPTIONS_KEY = 'http_client_options';
|
|
10
9
|
exports.RETRY_OPTIONS_KEY = 'http_retry_options';
|
|
11
10
|
exports.CIRCUIT_BREAKER_OPTIONS_KEY = 'http_circuit_breaker_options';
|
|
12
|
-
exports.CACHE_OPTIONS_KEY = 'http_cache_options';
|
|
13
11
|
exports.LOGGING_OPTIONS_KEY = 'http_logging_options';
|
|
14
12
|
exports.TIMEOUT_OPTIONS_KEY = 'http_timeout_options';
|
|
15
13
|
exports.PROXY_OPTIONS_KEY = 'http_proxy_options';
|
|
@@ -30,22 +28,42 @@ exports.HttpClient = HttpClient;
|
|
|
30
28
|
*/
|
|
31
29
|
const HttpRetry = (options = {}) => {
|
|
32
30
|
return (target, propertyKey, descriptor) => {
|
|
33
|
-
const retryOptions = {
|
|
34
|
-
enabled: true,
|
|
35
|
-
retries: options.retries || 3,
|
|
36
|
-
retryDelay: options.retryDelay || ((retryCount) => Math.pow(2, retryCount) * 1000),
|
|
37
|
-
retryCondition: options.retryCondition ||
|
|
31
|
+
const retryOptions = Object.assign(Object.assign({}, (options.enabled !== undefined && { enabled: options.enabled })), { retries: options.retries || 3, retryDelay: options.retryDelay || ((retryCount) => Math.pow(2, retryCount) * 1000), retryCondition: options.retryCondition ||
|
|
38
32
|
((error) => {
|
|
39
33
|
// 默认重试条件:网络错误、超时、5xx错误、429错误
|
|
40
34
|
if (!error.response)
|
|
41
35
|
return true; // 网络错误
|
|
42
36
|
const status = error.response.status;
|
|
43
37
|
return status >= 500 || status === 429; // 5xx错误或429限流
|
|
44
|
-
}),
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
}), shouldResetTimeout: options.shouldResetTimeout !== false, onRetry: options.onRetry });
|
|
39
|
+
// Wrap the method to pass decorator context to HTTP client
|
|
40
|
+
const originalMethod = descriptor.value;
|
|
41
|
+
const wrappedMethod = function (...args) {
|
|
42
|
+
// Set decorator context (reference counting prevents overwriting)
|
|
43
|
+
call_stack_extractor_util_1.CallStackExtractor.setDecoratorContext({
|
|
44
|
+
target,
|
|
45
|
+
propertyKey,
|
|
46
|
+
});
|
|
47
|
+
// 获取原始方法的返回值
|
|
48
|
+
const result = originalMethod.apply(this, args);
|
|
49
|
+
// 如果是 Promise,等待其完成后再清除上下文
|
|
50
|
+
if (result && typeof result.then === 'function') {
|
|
51
|
+
return result.finally(() => {
|
|
52
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// 同步方法,立即清除上下文
|
|
56
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
57
|
+
return result;
|
|
47
58
|
};
|
|
48
|
-
|
|
59
|
+
// Copy metadata from original to wrapped method
|
|
60
|
+
const metadataKeys = Reflect.getMetadataKeys(originalMethod);
|
|
61
|
+
for (const key of metadataKeys) {
|
|
62
|
+
Reflect.defineMetadata(key, Reflect.getMetadata(key, originalMethod), wrappedMethod);
|
|
63
|
+
}
|
|
64
|
+
// Store the retry options on the wrapped method
|
|
65
|
+
(0, common_1.SetMetadata)(`${exports.RETRY_OPTIONS_KEY}_${propertyKey}`, retryOptions)(wrappedMethod);
|
|
66
|
+
descriptor.value = wrappedMethod;
|
|
49
67
|
return descriptor;
|
|
50
68
|
};
|
|
51
69
|
};
|
|
@@ -64,74 +82,46 @@ const HttpCircuitBreaker = (options = {}) => {
|
|
|
64
82
|
minimumThroughputThreshold: options.minimumThroughputThreshold || 10,
|
|
65
83
|
countHalfOpenCalls: true,
|
|
66
84
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
layers: (_a = options.layers) === null || _a === void 0 ? void 0 : _a.map((layer) => {
|
|
89
|
-
switch (layer) {
|
|
90
|
-
case 'cls':
|
|
91
|
-
return cache_options_interface_1.CacheLayer.CLS;
|
|
92
|
-
case 'memory':
|
|
93
|
-
return cache_options_interface_1.CacheLayer.MEMORY;
|
|
94
|
-
case 'redis':
|
|
95
|
-
return cache_options_interface_1.CacheLayer.REDIS;
|
|
96
|
-
default:
|
|
97
|
-
return cache_options_interface_1.CacheLayer.MEMORY;
|
|
98
|
-
}
|
|
99
|
-
}),
|
|
100
|
-
condition: options.condition,
|
|
101
|
-
prefix: options.namespace,
|
|
102
|
-
},
|
|
103
|
-
cacheableMethods: ['get'],
|
|
104
|
-
cacheableStatusCodes: [200, 201, 202, 204, 301, 302, 304],
|
|
105
|
-
};
|
|
106
|
-
// 处理unless条件
|
|
107
|
-
if (options.unless) {
|
|
108
|
-
const originalMethod = descriptor.value;
|
|
109
|
-
descriptor.value = function (...args) {
|
|
110
|
-
const result = originalMethod.apply(this, args);
|
|
111
|
-
if (typeof options.unless === 'string') {
|
|
112
|
-
// 如果是字符串,作为表达式求值
|
|
113
|
-
if (evalInContext(options.unless, { result, args })) {
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
85
|
+
// Wrap the method to pass decorator context to HTTP client
|
|
86
|
+
const originalMethod = descriptor.value;
|
|
87
|
+
const wrappedMethod = function (...args) {
|
|
88
|
+
var _a;
|
|
89
|
+
// Store decorator context in async local storage or call stack
|
|
90
|
+
// Only set if not already set by another decorator
|
|
91
|
+
if (!call_stack_extractor_util_1.CallStackExtractor.getDecoratorContext()) {
|
|
92
|
+
call_stack_extractor_util_1.CallStackExtractor.setDecoratorContext({
|
|
93
|
+
target,
|
|
94
|
+
propertyKey,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// 获取原始方法的返回值
|
|
98
|
+
const result = originalMethod.apply(this, args);
|
|
99
|
+
// 如果是 Promise,等待其完成后再清除上下文
|
|
100
|
+
if (result && typeof result.then === 'function') {
|
|
101
|
+
// 只有在最外层装饰器时才清除上下文
|
|
102
|
+
if (!call_stack_extractor_util_1.CallStackExtractor.getDecoratorContext() || ((_a = call_stack_extractor_util_1.CallStackExtractor.getDecoratorContext()) === null || _a === void 0 ? void 0 : _a.target) === target) {
|
|
103
|
+
return result.finally(() => {
|
|
104
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
105
|
+
});
|
|
116
106
|
}
|
|
117
|
-
else if (typeof options.unless === 'function') {
|
|
118
|
-
// 如果是函数,直接调用
|
|
119
|
-
if (options.unless(result, args)) {
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// 正常缓存
|
|
124
|
-
(0, common_1.SetMetadata)(`${exports.CACHE_OPTIONS_KEY}_${propertyKey}`, cacheOptions)(originalMethod);
|
|
125
107
|
return result;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
108
|
+
}
|
|
109
|
+
// 同步方法,立即清除上下文
|
|
110
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
// Copy metadata from original to wrapped method
|
|
114
|
+
const metadataKeys = Reflect.getMetadataKeys(originalMethod);
|
|
115
|
+
for (const key of metadataKeys) {
|
|
116
|
+
Reflect.defineMetadata(key, Reflect.getMetadata(key, originalMethod), wrappedMethod);
|
|
130
117
|
}
|
|
118
|
+
// Store the circuit breaker options on the wrapped method
|
|
119
|
+
(0, common_1.SetMetadata)(`${exports.CIRCUIT_BREAKER_OPTIONS_KEY}_${propertyKey}`, circuitBreakerOptions)(wrappedMethod);
|
|
120
|
+
descriptor.value = wrappedMethod;
|
|
131
121
|
return descriptor;
|
|
132
122
|
};
|
|
133
123
|
};
|
|
134
|
-
exports.
|
|
124
|
+
exports.HttpCircuitBreaker = HttpCircuitBreaker;
|
|
135
125
|
/**
|
|
136
126
|
* 请求日志装饰器
|
|
137
127
|
* 类似Spring Boot的@LogRequest注解
|
|
@@ -142,7 +132,7 @@ const HttpLogRequest = (options = {}) => {
|
|
|
142
132
|
const loggingOptions = {
|
|
143
133
|
logHeaders: (_a = options.logHeaders) !== null && _a !== void 0 ? _a : true,
|
|
144
134
|
logBody: (_b = options.logBody) !== null && _b !== void 0 ? _b : true,
|
|
145
|
-
|
|
135
|
+
sanitize: options.sanitize || [
|
|
146
136
|
'authorization',
|
|
147
137
|
'apikey',
|
|
148
138
|
'password',
|
|
@@ -161,8 +151,35 @@ const HttpLogRequest = (options = {}) => {
|
|
|
161
151
|
methodName: options.methodName || decoratorInfo.methodName,
|
|
162
152
|
operationName: options.operationName || decoratorInfo.operationName,
|
|
163
153
|
};
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
// Wrap the method to pass decorator context to HTTP client
|
|
155
|
+
const originalMethod = descriptor.value;
|
|
156
|
+
const wrappedMethod = function (...args) {
|
|
157
|
+
// Set decorator context (reference counting prevents overwriting)
|
|
158
|
+
call_stack_extractor_util_1.CallStackExtractor.setDecoratorContext({
|
|
159
|
+
target,
|
|
160
|
+
propertyKey,
|
|
161
|
+
});
|
|
162
|
+
// 获取原始方法的返回值
|
|
163
|
+
const result = originalMethod.apply(this, args);
|
|
164
|
+
// 如果是 Promise,等待其完成后再清除上下文
|
|
165
|
+
if (result && typeof result.then === 'function') {
|
|
166
|
+
return result.finally(() => {
|
|
167
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// 同步方法,立即清除上下文
|
|
171
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
172
|
+
return result;
|
|
173
|
+
};
|
|
174
|
+
// Copy metadata from original to wrapped method
|
|
175
|
+
const metadataKeys = Reflect.getMetadataKeys(originalMethod);
|
|
176
|
+
for (const key of metadataKeys) {
|
|
177
|
+
Reflect.defineMetadata(key, Reflect.getMetadata(key, originalMethod), wrappedMethod);
|
|
178
|
+
}
|
|
179
|
+
// Store the logging options on the wrapped method
|
|
180
|
+
(0, common_1.SetMetadata)(`${exports.LOGGING_OPTIONS_KEY}_${propertyKey}`, loggingOptions)(wrappedMethod);
|
|
181
|
+
(0, common_1.SetMetadata)(`${exports.CALL_INFO_KEY}_${propertyKey}`, callInfo)(wrappedMethod);
|
|
182
|
+
descriptor.value = wrappedMethod;
|
|
166
183
|
return descriptor;
|
|
167
184
|
};
|
|
168
185
|
};
|
|
@@ -173,7 +190,34 @@ exports.HttpLogRequest = HttpLogRequest;
|
|
|
173
190
|
*/
|
|
174
191
|
const HttpTimeout = (timeoutMs) => {
|
|
175
192
|
return (target, propertyKey, descriptor) => {
|
|
176
|
-
|
|
193
|
+
// Wrap the method to pass decorator context to HTTP client
|
|
194
|
+
const originalMethod = descriptor.value;
|
|
195
|
+
const wrappedMethod = function (...args) {
|
|
196
|
+
// Set decorator context (reference counting prevents overwriting)
|
|
197
|
+
call_stack_extractor_util_1.CallStackExtractor.setDecoratorContext({
|
|
198
|
+
target,
|
|
199
|
+
propertyKey,
|
|
200
|
+
});
|
|
201
|
+
// 获取原始方法的返回值
|
|
202
|
+
const result = originalMethod.apply(this, args);
|
|
203
|
+
// 如果是 Promise,等待其完成后再清除上下文
|
|
204
|
+
if (result && typeof result.then === 'function') {
|
|
205
|
+
return result.finally(() => {
|
|
206
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// 同步方法,立即清除上下文
|
|
210
|
+
call_stack_extractor_util_1.CallStackExtractor.clearDecoratorContext();
|
|
211
|
+
return result;
|
|
212
|
+
};
|
|
213
|
+
// Copy metadata from original to wrapped method
|
|
214
|
+
const metadataKeys = Reflect.getMetadataKeys(originalMethod);
|
|
215
|
+
for (const key of metadataKeys) {
|
|
216
|
+
Reflect.defineMetadata(key, Reflect.getMetadata(key, originalMethod), wrappedMethod);
|
|
217
|
+
}
|
|
218
|
+
// Store the timeout options on the wrapped method
|
|
219
|
+
(0, common_1.SetMetadata)(`${exports.TIMEOUT_OPTIONS_KEY}_${propertyKey}`, timeoutMs)(wrappedMethod);
|
|
220
|
+
descriptor.value = wrappedMethod;
|
|
177
221
|
return descriptor;
|
|
178
222
|
};
|
|
179
223
|
};
|
|
@@ -183,7 +227,8 @@ exports.HttpTimeout = HttpTimeout;
|
|
|
183
227
|
*/
|
|
184
228
|
const HttpUseProxy = (options) => {
|
|
185
229
|
return (target, propertyKey, descriptor) => {
|
|
186
|
-
|
|
230
|
+
const proxyConfig = Object.assign({ enabled: options.enabled !== false }, options);
|
|
231
|
+
(0, common_1.SetMetadata)(`${exports.PROXY_OPTIONS_KEY}_${propertyKey}`, proxyConfig)(descriptor.value);
|
|
187
232
|
return descriptor;
|
|
188
233
|
};
|
|
189
234
|
};
|
|
@@ -204,12 +249,6 @@ class HttpDecoratorUtils {
|
|
|
204
249
|
static getCircuitBreakerOptions(target, propertyKey) {
|
|
205
250
|
return Reflect.getMetadata(`${exports.CIRCUIT_BREAKER_OPTIONS_KEY}_${propertyKey}`, target[propertyKey]);
|
|
206
251
|
}
|
|
207
|
-
/**
|
|
208
|
-
* 获取方法上的缓存配置
|
|
209
|
-
*/
|
|
210
|
-
static getCacheOptions(target, propertyKey) {
|
|
211
|
-
return Reflect.getMetadata(`${exports.CACHE_OPTIONS_KEY}_${propertyKey}`, target[propertyKey]);
|
|
212
|
-
}
|
|
213
252
|
/**
|
|
214
253
|
* 获取方法上的日志配置
|
|
215
254
|
*/
|
|
@@ -247,7 +286,6 @@ class HttpDecoratorUtils {
|
|
|
247
286
|
return {
|
|
248
287
|
retry: this.getRetryOptions(target, propertyKey),
|
|
249
288
|
circuitBreaker: this.getCircuitBreakerOptions(target, propertyKey),
|
|
250
|
-
cache: this.getCacheOptions(target, propertyKey),
|
|
251
289
|
logging: this.getLoggingOptions(target, propertyKey),
|
|
252
290
|
timeout: this.getTimeoutOptions(target, propertyKey),
|
|
253
291
|
proxy: this.getProxyOptions(target, propertyKey),
|
|
@@ -257,16 +295,3 @@ class HttpDecoratorUtils {
|
|
|
257
295
|
}
|
|
258
296
|
}
|
|
259
297
|
exports.HttpDecoratorUtils = HttpDecoratorUtils;
|
|
260
|
-
/**
|
|
261
|
-
* 在上下文中执行表达式
|
|
262
|
-
*/
|
|
263
|
-
function evalInContext(expression, context) {
|
|
264
|
-
try {
|
|
265
|
-
// 创建一个安全的执行环境
|
|
266
|
-
const func = new Function(...Object.keys(context), `return ${expression}`);
|
|
267
|
-
return func(...Object.values(context));
|
|
268
|
-
}
|
|
269
|
-
catch (error) {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
@@ -68,14 +68,6 @@ export declare class HttpLogEntity extends AbstractUuidPrimaryEntity {
|
|
|
68
68
|
* 响应体内容
|
|
69
69
|
*/
|
|
70
70
|
responseBody?: string;
|
|
71
|
-
/**
|
|
72
|
-
* 响应大小(字节)
|
|
73
|
-
*/
|
|
74
|
-
responseSize?: number;
|
|
75
|
-
/**
|
|
76
|
-
* 请求大小(字节)
|
|
77
|
-
*/
|
|
78
|
-
requestSize?: number;
|
|
79
71
|
/**
|
|
80
72
|
* 服务名称(用于微服务环境)
|
|
81
73
|
*/
|
|
@@ -104,10 +96,6 @@ export declare class HttpLogEntity extends AbstractUuidPrimaryEntity {
|
|
|
104
96
|
* 重试记录(JSON格式)
|
|
105
97
|
*/
|
|
106
98
|
retryRecords?: RetryRecord[];
|
|
107
|
-
/**
|
|
108
|
-
* 缓存命中状态
|
|
109
|
-
*/
|
|
110
|
-
cacheHit?: boolean;
|
|
111
99
|
/**
|
|
112
100
|
* 熔断器状态
|
|
113
101
|
*/
|
|
@@ -316,12 +304,4 @@ export interface HttpLogStats {
|
|
|
316
304
|
maxRetries: number;
|
|
317
305
|
retryRate: number;
|
|
318
306
|
};
|
|
319
|
-
/**
|
|
320
|
-
* 缓存统计
|
|
321
|
-
*/
|
|
322
|
-
cacheStats: {
|
|
323
|
-
cacheHits: number;
|
|
324
|
-
cacheMisses: number;
|
|
325
|
-
cacheHitRate: number;
|
|
326
|
-
};
|
|
327
307
|
}
|
|
@@ -21,22 +21,18 @@ let HttpLogEntity = class HttpLogEntity extends common_1.AbstractUuidPrimaryEnti
|
|
|
21
21
|
exports.HttpLogEntity = HttpLogEntity;
|
|
22
22
|
__decorate([
|
|
23
23
|
(0, typeorm_1.Column)({ type: 'varchar', length: 36, nullable: true }),
|
|
24
|
-
(0, typeorm_1.Index)(),
|
|
25
24
|
__metadata("design:type", String)
|
|
26
25
|
], HttpLogEntity.prototype, "requestId", void 0);
|
|
27
26
|
__decorate([
|
|
28
27
|
(0, typeorm_1.Column)({ type: 'varchar', length: 36, nullable: true }),
|
|
29
|
-
(0, typeorm_1.Index)(),
|
|
30
28
|
__metadata("design:type", String)
|
|
31
29
|
], HttpLogEntity.prototype, "userId", void 0);
|
|
32
30
|
__decorate([
|
|
33
31
|
(0, typeorm_1.Column)({ type: 'varchar', length: 10 }),
|
|
34
|
-
(0, typeorm_1.Index)(),
|
|
35
32
|
__metadata("design:type", String)
|
|
36
33
|
], HttpLogEntity.prototype, "method", void 0);
|
|
37
34
|
__decorate([
|
|
38
|
-
(0, typeorm_1.Column)({ type: '
|
|
39
|
-
(0, typeorm_1.Index)(),
|
|
35
|
+
(0, typeorm_1.Column)({ type: 'varchar' }),
|
|
40
36
|
__metadata("design:type", String)
|
|
41
37
|
], HttpLogEntity.prototype, "url", void 0);
|
|
42
38
|
__decorate([
|
|
@@ -53,7 +49,6 @@ __decorate([
|
|
|
53
49
|
], HttpLogEntity.prototype, "params", void 0);
|
|
54
50
|
__decorate([
|
|
55
51
|
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
56
|
-
(0, typeorm_1.Index)(),
|
|
57
52
|
__metadata("design:type", Number)
|
|
58
53
|
], HttpLogEntity.prototype, "statusCode", void 0);
|
|
59
54
|
__decorate([
|
|
@@ -66,7 +61,6 @@ __decorate([
|
|
|
66
61
|
], HttpLogEntity.prototype, "attemptCount", void 0);
|
|
67
62
|
__decorate([
|
|
68
63
|
(0, typeorm_1.Column)({ type: 'boolean', default: false }),
|
|
69
|
-
(0, typeorm_1.Index)(),
|
|
70
64
|
__metadata("design:type", Boolean)
|
|
71
65
|
], HttpLogEntity.prototype, "success", void 0);
|
|
72
66
|
__decorate([
|
|
@@ -89,21 +83,12 @@ __decorate([
|
|
|
89
83
|
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
90
84
|
__metadata("design:type", String)
|
|
91
85
|
], HttpLogEntity.prototype, "responseBody", void 0);
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
94
|
-
__metadata("design:type", Number)
|
|
95
|
-
], HttpLogEntity.prototype, "responseSize", void 0);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
98
|
-
__metadata("design:type", Number)
|
|
99
|
-
], HttpLogEntity.prototype, "requestSize", void 0);
|
|
100
86
|
__decorate([
|
|
101
87
|
(0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }),
|
|
102
88
|
__metadata("design:type", String)
|
|
103
89
|
], HttpLogEntity.prototype, "serviceName", void 0);
|
|
104
90
|
__decorate([
|
|
105
91
|
(0, typeorm_1.Column)({ type: 'varchar', length: 200, nullable: true }),
|
|
106
|
-
(0, typeorm_1.Index)(),
|
|
107
92
|
__metadata("design:type", String)
|
|
108
93
|
], HttpLogEntity.prototype, "operationName", void 0);
|
|
109
94
|
__decorate([
|
|
@@ -127,10 +112,6 @@ __decorate([
|
|
|
127
112
|
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
128
113
|
__metadata("design:type", Array)
|
|
129
114
|
], HttpLogEntity.prototype, "retryRecords", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
(0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
|
|
132
|
-
__metadata("design:type", Boolean)
|
|
133
|
-
], HttpLogEntity.prototype, "cacheHit", void 0);
|
|
134
115
|
__decorate([
|
|
135
116
|
(0, typeorm_1.Column)({ type: 'varchar', length: 20, nullable: true }),
|
|
136
117
|
__metadata("design:type", String)
|
|
@@ -140,7 +121,6 @@ exports.HttpLogEntity = HttpLogEntity = __decorate([
|
|
|
140
121
|
(0, typeorm_1.Index)(['requestId']),
|
|
141
122
|
(0, typeorm_1.Index)(['userId']),
|
|
142
123
|
(0, typeorm_1.Index)(['method']),
|
|
143
|
-
(0, typeorm_1.Index)(['url']),
|
|
144
124
|
(0, typeorm_1.Index)(['statusCode']),
|
|
145
125
|
(0, typeorm_1.Index)(['success']),
|
|
146
126
|
(0, typeorm_1.Index)(['createdAt']),
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { HttpClientService } from '../services/http-client.service';
|
|
2
2
|
/**
|
|
3
3
|
* 高级使用示例 - GitHub API客户端
|
|
4
|
-
* 集成现有的三层缓存架构
|
|
5
4
|
*/
|
|
6
5
|
export declare class GitHubHttpService {
|
|
7
6
|
private httpClient;
|
|
8
7
|
constructor(httpClient: HttpClientService);
|
|
9
8
|
/**
|
|
10
|
-
* 获取用户信息 -
|
|
9
|
+
* 获取用户信息 - 带重试、熔断器和日志
|
|
11
10
|
*/
|
|
12
11
|
getUser(username: string): Promise<any>;
|
|
13
12
|
/**
|
|
14
|
-
* 搜索仓库 -
|
|
13
|
+
* 搜索仓库 - 带重试
|
|
15
14
|
*/
|
|
16
15
|
searchRepositories(query: string, sort?: string, order?: string): Promise<any>;
|
|
17
16
|
/**
|
|
@@ -31,7 +30,7 @@ export declare class GitHubHttpService {
|
|
|
31
30
|
*/
|
|
32
31
|
getMultipleUsers(usernames: string[]): Promise<any[]>;
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* 获取仓库详情
|
|
35
34
|
*/
|
|
36
35
|
getRepositoryDetails(owner: string, repo: string, options?: {
|
|
37
36
|
public?: boolean;
|
|
@@ -49,7 +48,7 @@ export declare class PaymentHttpService {
|
|
|
49
48
|
*/
|
|
50
49
|
createPayment(paymentData: any, apiKey: string): Promise<any>;
|
|
51
50
|
/**
|
|
52
|
-
* 查询支付状态
|
|
51
|
+
* 查询支付状态
|
|
53
52
|
*/
|
|
54
53
|
getPaymentStatus(paymentId: string, apiKey: string): Promise<any>;
|
|
55
54
|
/**
|