@nest-omni/core 4.1.3-2 → 4.1.3-20
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 +10 -0
- package/audit/audit.module.js +63 -1
- package/audit/controllers/audit.controller.d.ts +88 -0
- package/audit/controllers/audit.controller.js +74 -0
- package/audit/decorators/audit-action.decorator.d.ts +74 -0
- package/audit/decorators/audit-action.decorator.js +42 -0
- package/audit/decorators/audit-controller.decorator.d.ts +9 -1
- package/audit/decorators/audit-controller.decorator.js +11 -2
- package/audit/decorators/audit-operation.decorator.d.ts +45 -0
- package/audit/decorators/audit-operation.decorator.js +49 -0
- package/audit/decorators/entity-audit.decorator.d.ts +85 -1
- package/audit/decorators/entity-audit.decorator.js +153 -3
- package/audit/decorators/index.d.ts +2 -0
- package/audit/decorators/index.js +2 -0
- package/audit/dto/audit-log-query.dto.d.ts +3 -0
- package/audit/dto/audit-log-query.dto.js +3 -0
- package/audit/dto/begin-transaction.dto.d.ts +3 -0
- package/audit/dto/begin-transaction.dto.js +3 -0
- package/audit/dto/compare-entities.dto.d.ts +3 -0
- package/audit/dto/compare-entities.dto.js +3 -0
- package/audit/dto/pre-check-restore.dto.d.ts +3 -0
- package/audit/dto/pre-check-restore.dto.js +3 -0
- package/audit/dto/restore-entity.dto.d.ts +3 -0
- package/audit/dto/restore-entity.dto.js +3 -0
- package/audit/entities/audit-action-summary.entity.d.ts +23 -0
- package/audit/entities/audit-action-summary.entity.js +101 -0
- package/audit/entities/entity-audit-log.entity.d.ts +11 -0
- package/audit/entities/entity-audit-log.entity.js +57 -2
- package/audit/entities/entity-transaction.entity.d.ts +11 -2
- package/audit/entities/entity-transaction.entity.js +42 -3
- package/audit/entities/index.d.ts +3 -0
- package/audit/entities/index.js +3 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -0
- package/audit/entities/manual-operation-log.entity.js +12 -1
- package/audit/entities/operation-template.entity.d.ts +4 -0
- package/audit/entities/operation-template.entity.js +4 -0
- package/audit/enums/audit.enums.d.ts +37 -6
- package/audit/enums/audit.enums.js +40 -7
- package/audit/index.d.ts +4 -1
- package/audit/index.js +34 -1
- package/audit/interceptors/audit-action.interceptor.d.ts +38 -0
- package/audit/interceptors/audit-action.interceptor.js +215 -0
- package/audit/interceptors/audit.interceptor.d.ts +15 -0
- package/audit/interceptors/audit.interceptor.js +23 -1
- package/audit/interceptors/index.d.ts +1 -0
- package/audit/interceptors/index.js +1 -0
- package/audit/interfaces/audit.interfaces.d.ts +187 -2
- package/audit/services/audit-action.service.d.ts +141 -0
- package/audit/services/audit-action.service.js +244 -0
- package/audit/services/audit-context.service.d.ts +97 -0
- package/audit/services/audit-context.service.js +185 -0
- package/audit/services/audit-strategy.service.d.ts +6 -0
- package/audit/services/audit-strategy.service.js +13 -0
- package/audit/services/entity-audit.service.d.ts +230 -3
- package/audit/services/entity-audit.service.js +607 -14
- package/audit/services/index.d.ts +3 -0
- package/audit/services/index.js +3 -0
- package/audit/services/manual-audit-log.service.d.ts +134 -9
- package/audit/services/manual-audit-log.service.js +157 -40
- package/audit/services/multi-database.service.d.ts +9 -2
- package/audit/services/multi-database.service.js +9 -21
- package/audit/services/operation-description.service.d.ts +71 -2
- package/audit/services/operation-description.service.js +231 -20
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +53 -5
- package/audit/subscribers/entity-audit.subscriber.d.ts +19 -0
- package/audit/subscribers/entity-audit.subscriber.js +76 -1
- package/cache/cache-metrics.service.d.ts +67 -0
- package/cache/cache-metrics.service.js +68 -4
- package/cache/cache-serialization.service.d.ts +31 -0
- package/cache/cache-serialization.service.js +25 -0
- package/cache/cache.constants.d.ts +9 -0
- package/cache/cache.constants.js +9 -0
- package/cache/cache.health.d.ts +26 -0
- package/cache/cache.health.js +30 -0
- package/cache/cache.module.d.ts +82 -2
- package/cache/cache.module.js +76 -5
- package/cache/cache.service.d.ts +140 -0
- package/cache/cache.service.js +169 -0
- package/cache/cache.warmup.service.d.ts +39 -0
- package/cache/cache.warmup.service.js +32 -0
- package/cache/decorators/cache-evict.decorator.d.ts +47 -0
- package/cache/decorators/cache-evict.decorator.js +56 -0
- package/cache/decorators/cache-put.decorator.d.ts +34 -0
- package/cache/decorators/cache-put.decorator.js +39 -0
- package/cache/decorators/cacheable.decorator.d.ts +40 -0
- package/cache/decorators/cacheable.decorator.js +55 -0
- package/cache/dependencies/callback.dependency.d.ts +33 -0
- package/cache/dependencies/callback.dependency.js +39 -1
- package/cache/dependencies/chain.dependency.d.ts +28 -0
- package/cache/dependencies/chain.dependency.js +34 -0
- package/cache/dependencies/db.dependency.d.ts +83 -7
- package/cache/dependencies/db.dependency.js +89 -14
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +75 -4
- package/cache/dependencies/tag.dependency.js +145 -11
- package/cache/dependencies/time.dependency.d.ts +43 -0
- package/cache/dependencies/time.dependency.js +43 -0
- package/cache/examples/basic-usage.d.ts +15 -0
- package/cache/examples/basic-usage.js +62 -8
- package/cache/index.js +9 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
- package/cache/interfaces/cache-options.interface.d.ts +89 -0
- package/cache/interfaces/cache-options.interface.js +6 -0
- package/cache/interfaces/cache-provider.interface.d.ts +78 -0
- package/cache/providers/base-cache.provider.d.ts +14 -0
- package/cache/providers/base-cache.provider.js +16 -0
- package/cache/providers/cls-cache.provider.d.ts +20 -0
- package/cache/providers/cls-cache.provider.js +28 -0
- package/cache/providers/memory-cache.provider.d.ts +43 -0
- package/cache/providers/memory-cache.provider.js +66 -0
- package/cache/providers/redis-cache.provider.d.ts +26 -0
- package/cache/providers/redis-cache.provider.js +29 -0
- package/cache/utils/dependency-manager.util.d.ts +52 -0
- package/cache/utils/dependency-manager.util.js +59 -0
- package/cache/utils/key-generator.util.d.ts +42 -0
- package/cache/utils/key-generator.util.js +53 -1
- package/common/abstract.entity.d.ts +14 -0
- package/common/abstract.entity.js +14 -0
- package/common/boilerplate.polyfill.d.ts +142 -0
- package/common/boilerplate.polyfill.js +18 -1
- package/common/dto/dto-container.d.ts +16 -0
- package/common/dto/dto-container.js +20 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +14 -0
- package/common/dto/dto-extensions.d.ts +11 -0
- package/common/dto/dto-extensions.js +9 -0
- package/common/dto/dto-service-accessor.d.ts +17 -0
- package/common/dto/dto-service-accessor.js +18 -0
- package/common/dto/dto-transformer.d.ts +12 -0
- package/common/dto/dto-transformer.js +9 -0
- package/common/dto/index.js +2 -0
- package/common/examples/paginate-and-map.example.d.ts +6 -0
- package/common/examples/paginate-and-map.example.js +26 -0
- package/common/utils.d.ts +15 -0
- package/common/utils.js +15 -0
- package/constants/language-code.js +1 -0
- package/decorators/field.decorators.d.ts +1 -1
- package/decorators/field.decorators.js +8 -1
- package/decorators/property.decorators.js +1 -0
- package/decorators/public-route.decorator.js +1 -0
- package/decorators/transform.decorators.d.ts +27 -0
- package/decorators/transform.decorators.js +29 -0
- package/decorators/translate.decorator.js +1 -0
- package/decorators/user.decorator.js +1 -0
- package/decorators/validator.decorators.d.ts +8 -18
- package/decorators/validator.decorators.js +22 -190
- package/file-upload/controllers/file-access.controller.d.ts +23 -0
- package/file-upload/controllers/file-access.controller.js +128 -0
- package/file-upload/decorators/column.decorator.d.ts +151 -0
- package/file-upload/decorators/column.decorator.js +273 -0
- package/file-upload/decorators/csv-data.decorator.d.ts +30 -0
- package/file-upload/decorators/csv-data.decorator.js +85 -0
- package/file-upload/decorators/csv-import.decorator.d.ts +34 -0
- package/file-upload/decorators/csv-import.decorator.js +24 -0
- package/file-upload/decorators/examples/column-mapping.example.d.ts +76 -0
- package/file-upload/decorators/examples/column-mapping.example.js +122 -0
- package/file-upload/decorators/excel-data.decorator.d.ts +30 -0
- package/file-upload/decorators/excel-data.decorator.js +85 -0
- package/file-upload/decorators/file-upload.decorator.d.ts +83 -0
- package/file-upload/decorators/file-upload.decorator.js +172 -0
- package/file-upload/decorators/index.d.ts +5 -0
- package/file-upload/decorators/index.js +38 -0
- package/file-upload/decorators/process.decorator.d.ts +40 -0
- package/file-upload/decorators/process.decorator.js +52 -0
- package/file-upload/decorators/validate-data.decorator.d.ts +91 -0
- package/file-upload/decorators/validate-data.decorator.js +39 -0
- package/file-upload/dto/create-file.dto.d.ts +24 -0
- package/file-upload/dto/create-file.dto.js +112 -0
- package/file-upload/dto/find-files.dto.d.ts +15 -0
- package/file-upload/dto/find-files.dto.js +76 -0
- package/file-upload/dto/index.d.ts +4 -0
- package/file-upload/dto/index.js +20 -0
- package/file-upload/dto/pagination.dto.d.ts +7 -0
- package/file-upload/dto/pagination.dto.js +39 -0
- package/file-upload/dto/update-file.dto.d.ts +15 -0
- package/file-upload/dto/update-file.dto.js +67 -0
- package/file-upload/entities/file-metadata.entity.d.ts +25 -0
- package/file-upload/entities/file-metadata.entity.js +76 -0
- package/file-upload/entities/file.entity.d.ts +114 -0
- package/file-upload/entities/file.entity.js +350 -0
- package/file-upload/entities/index.d.ts +2 -0
- package/file-upload/entities/index.js +18 -0
- package/file-upload/enums/file-type.enum.d.ts +72 -0
- package/file-upload/enums/file-type.enum.js +212 -0
- package/file-upload/exceptions/file-upload.exception.d.ts +57 -0
- package/file-upload/exceptions/file-upload.exception.js +120 -0
- package/file-upload/exceptions/index.d.ts +1 -0
- package/file-upload/exceptions/index.js +17 -0
- package/file-upload/file-upload.module.d.ts +89 -0
- package/file-upload/file-upload.module.js +292 -0
- package/file-upload/index.d.ts +37 -0
- package/file-upload/index.js +77 -0
- package/file-upload/interceptors/file-upload.interceptor.d.ts +101 -0
- package/file-upload/interceptors/file-upload.interceptor.js +594 -0
- package/file-upload/interceptors/index.d.ts +1 -0
- package/file-upload/interceptors/index.js +17 -0
- package/file-upload/interfaces/custom-file-type.interface.d.ts +72 -0
- package/file-upload/interfaces/custom-file-type.interface.js +2 -0
- package/file-upload/interfaces/file-buffer.interface.d.ts +72 -0
- package/file-upload/interfaces/file-buffer.interface.js +2 -0
- package/file-upload/interfaces/file-entity.interface.d.ts +142 -0
- package/file-upload/interfaces/file-entity.interface.js +28 -0
- package/file-upload/interfaces/file-metadata.interface.d.ts +21 -0
- package/file-upload/interfaces/file-metadata.interface.js +2 -0
- package/file-upload/interfaces/file-processor.interface.d.ts +93 -0
- package/file-upload/interfaces/file-processor.interface.js +2 -0
- package/file-upload/interfaces/file-upload-options.interface.d.ts +74 -0
- package/file-upload/interfaces/file-upload-options.interface.js +5 -0
- package/file-upload/interfaces/index.d.ts +7 -0
- package/file-upload/interfaces/index.js +24 -0
- package/file-upload/interfaces/processor-options.interface.d.ts +102 -0
- package/file-upload/interfaces/processor-options.interface.js +2 -0
- package/file-upload/interfaces/storage-provider.interface.d.ts +239 -0
- package/file-upload/interfaces/storage-provider.interface.js +2 -0
- package/file-upload/interfaces/upload-options.interface.d.ts +19 -0
- package/file-upload/interfaces/upload-options.interface.js +2 -0
- package/file-upload/processors/csv.processor.d.ts +98 -0
- package/file-upload/processors/csv.processor.js +391 -0
- package/file-upload/processors/excel.processor.d.ts +130 -0
- package/file-upload/processors/excel.processor.js +547 -0
- package/file-upload/processors/image.processor.d.ts +199 -0
- package/file-upload/processors/image.processor.js +377 -0
- package/file-upload/providers/index.d.ts +2 -0
- package/file-upload/providers/index.js +18 -0
- package/file-upload/providers/local-storage.provider.d.ts +98 -0
- package/file-upload/providers/local-storage.provider.js +484 -0
- package/file-upload/providers/s3-storage.provider.d.ts +87 -0
- package/file-upload/providers/s3-storage.provider.js +455 -0
- package/file-upload/services/file-signature-validator.service.d.ts +118 -0
- package/file-upload/services/file-signature-validator.service.js +376 -0
- package/file-upload/services/file.service.d.ts +193 -0
- package/file-upload/services/file.service.js +638 -0
- package/file-upload/services/index.d.ts +4 -0
- package/file-upload/services/index.js +20 -0
- package/file-upload/services/malicious-file-detector.service.d.ts +300 -0
- package/file-upload/services/malicious-file-detector.service.js +1234 -0
- package/file-upload/services/mime-registry.service.d.ts +47 -0
- package/file-upload/services/mime-registry.service.js +167 -0
- package/file-upload/utils/checksum.util.d.ts +28 -0
- package/file-upload/utils/checksum.util.js +65 -0
- package/file-upload/utils/dynamic-import.util.d.ts +54 -0
- package/file-upload/utils/dynamic-import.util.js +156 -0
- package/file-upload/utils/filename.util.d.ts +59 -0
- package/file-upload/utils/filename.util.js +184 -0
- package/file-upload/utils/filepath.util.d.ts +70 -0
- package/file-upload/utils/filepath.util.js +152 -0
- package/file-upload/utils/index.d.ts +4 -0
- package/file-upload/utils/index.js +20 -0
- package/filters/constraint-errors.js +1 -0
- package/helpers/common.helper.d.ts +13 -0
- package/helpers/common.helper.js +13 -0
- package/http-client/config/http-client.config.d.ts +20 -0
- package/http-client/config/http-client.config.js +48 -21
- package/http-client/decorators/http-client.decorators.d.ts +55 -14
- package/http-client/decorators/http-client.decorators.js +154 -78
- package/http-client/entities/http-log.entity.d.ts +217 -8
- package/http-client/entities/http-log.entity.js +7 -22
- package/http-client/errors/http-client.errors.d.ts +57 -0
- package/http-client/errors/http-client.errors.js +58 -0
- package/http-client/examples/advanced-usage.example.d.ts +40 -0
- package/http-client/examples/advanced-usage.example.js +53 -61
- package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
- package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
- package/http-client/examples/basic-usage.example.d.ts +60 -0
- package/http-client/examples/basic-usage.example.js +60 -0
- package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
- package/http-client/examples/multi-api-configuration.example.js +76 -5
- package/http-client/examples/proxy-from-environment.example.d.ts +133 -0
- package/http-client/examples/proxy-from-environment.example.js +409 -0
- package/http-client/http-client.module.d.ts +48 -2
- package/http-client/http-client.module.js +147 -68
- package/http-client/index.d.ts +1 -1
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +80 -45
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +109 -52
- package/http-client/services/api-client-registry.service.d.ts +50 -11
- package/http-client/services/api-client-registry.service.js +90 -250
- package/http-client/services/circuit-breaker.service.d.ts +115 -2
- package/http-client/services/circuit-breaker.service.js +237 -7
- package/http-client/services/http-client.service.d.ts +124 -14
- package/http-client/services/http-client.service.js +437 -148
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +121 -13
- package/http-client/services/http-replay.service.d.ts +101 -0
- package/http-client/services/http-replay.service.js +86 -0
- package/http-client/services/index.d.ts +0 -1
- package/http-client/services/index.js +0 -1
- package/http-client/services/log-cleanup.service.d.ts +63 -0
- package/http-client/services/log-cleanup.service.js +54 -2
- package/http-client/services/logging.service.d.ts +116 -7
- package/http-client/services/logging.service.js +349 -86
- package/http-client/utils/call-stack-extractor.util.d.ts +63 -0
- package/http-client/utils/call-stack-extractor.util.js +83 -0
- package/http-client/utils/context-extractor.util.d.ts +49 -0
- package/http-client/utils/context-extractor.util.js +52 -0
- package/http-client/utils/curl-generator.util.d.ts +21 -0
- package/http-client/utils/curl-generator.util.js +44 -3
- package/http-client/utils/index.d.ts +1 -0
- package/http-client/utils/index.js +1 -0
- package/http-client/utils/proxy-environment.util.d.ts +42 -0
- package/http-client/utils/proxy-environment.util.js +148 -0
- package/http-client/utils/request-id.util.d.ts +18 -0
- package/http-client/utils/request-id.util.js +20 -0
- package/http-client/utils/retry-recorder.util.d.ts +42 -0
- package/http-client/utils/retry-recorder.util.js +44 -0
- package/http-client/utils/security-validator.util.d.ts +118 -0
- package/http-client/utils/security-validator.util.js +352 -0
- package/index.d.ts +3 -1
- package/index.js +12 -1
- package/interceptors/translation-interceptor.service.js +5 -0
- package/package.json +11 -7
- package/providers/context.provider.js +2 -0
- package/providers/generator.provider.d.ts +4 -0
- package/providers/generator.provider.js +4 -0
- package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
- package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
- package/redis-lock/examples/lock-strategy.examples.js +130 -15
- package/redis-lock/index.d.ts +2 -0
- package/redis-lock/index.js +8 -1
- package/redis-lock/lock-heartbeat.service.d.ts +80 -0
- package/redis-lock/lock-heartbeat.service.js +232 -0
- package/redis-lock/redis-lock.decorator.d.ts +101 -0
- package/redis-lock/redis-lock.decorator.js +120 -0
- package/redis-lock/redis-lock.module.d.ts +66 -0
- package/redis-lock/redis-lock.module.js +175 -70
- package/redis-lock/redis-lock.service.d.ts +282 -0
- package/redis-lock/redis-lock.service.js +343 -20
- package/setup/bootstrap.setup.d.ts +1 -0
- package/setup/bootstrap.setup.js +21 -0
- package/setup/index.d.ts +1 -0
- package/setup/index.js +1 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/run-in-mode.decorator.d.ts +56 -0
- package/setup/run-in-mode.decorator.js +92 -0
- package/setup/schedule.decorator.d.ts +227 -0
- package/setup/schedule.decorator.js +240 -12
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +97 -0
- package/shared/index.d.ts +1 -1
- package/shared/index.js +1 -1
- package/shared/{serviceRegistryModule.js → service-registry.module.js} +19 -17
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +21 -9
- package/shared/services/index.d.ts +0 -1
- package/shared/services/index.js +0 -1
- package/validator-json/decorators.d.ts +17 -0
- package/validator-json/decorators.js +17 -2
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +30 -2
- package/validator-json/defaultConverters.js +1 -0
- package/validator-json/options.d.ts +23 -0
- package/validators/common-validators.d.ts +143 -0
- package/validators/common-validators.js +249 -0
- package/validators/custom-validate.examples.d.ts +23 -0
- package/validators/custom-validate.examples.js +78 -6
- package/validators/custom-validate.validator.d.ts +108 -0
- package/validators/custom-validate.validator.js +85 -0
- package/validators/file-mimetype.validator.d.ts +0 -2
- package/validators/file-mimetype.validator.js +4 -6
- package/validators/index.d.ts +1 -0
- package/validators/index.js +1 -0
- package/validators/is-exists.validator.d.ts +26 -6
- package/validators/is-exists.validator.js +30 -7
- package/validators/is-unique.validator.d.ts +33 -7
- package/validators/is-unique.validator.js +59 -17
- package/validators/skip-empty.validator.d.ts +5 -0
- package/validators/skip-empty.validator.js +5 -0
- package/vault/interfaces/vault-options.interface.d.ts +9 -0
- package/vault/vault-config.loader.d.ts +30 -0
- package/vault/vault-config.loader.js +48 -1
- package/vault/vault-config.service.d.ts +53 -0
- package/vault/vault-config.service.js +57 -0
- package/vault/vault.module.d.ts +4 -0
- package/vault/vault.module.js +4 -0
- package/decorators/examples/validation-decorators.example.d.ts +0 -69
- package/decorators/examples/validation-decorators.example.js +0 -331
- package/http-client/services/cache.service.d.ts +0 -24
- package/http-client/services/cache.service.js +0 -264
- package/shared/services/validator.service.d.ts +0 -3
- package/shared/services/validator.service.js +0 -20
- /package/shared/{serviceRegistryModule.d.ts → service-registry.module.d.ts} +0 -0
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm';
|
|
2
2
|
import { HttpLogEntity, HttpLogQueryOptions, HttpLogStats } from '../entities/http-log.entity';
|
|
3
|
+
/**
|
|
4
|
+
* HTTP日志查询服务
|
|
5
|
+
*/
|
|
3
6
|
export declare class HttpLogQueryService {
|
|
4
7
|
private readonly dataSource?;
|
|
5
8
|
private readonly logger;
|
|
6
9
|
private logRepository;
|
|
7
10
|
constructor(dataSource?: DataSource);
|
|
11
|
+
/**
|
|
12
|
+
* 查询HTTP日志
|
|
13
|
+
*/
|
|
8
14
|
findLogs(options?: HttpLogQueryOptions): Promise<{
|
|
9
15
|
logs: HttpLogEntity[];
|
|
10
16
|
total: number;
|
|
@@ -12,8 +18,17 @@ export declare class HttpLogQueryService {
|
|
|
12
18
|
limit: number;
|
|
13
19
|
totalPages: number;
|
|
14
20
|
}>;
|
|
21
|
+
/**
|
|
22
|
+
* 根据ID查询单条日志
|
|
23
|
+
*/
|
|
15
24
|
findLogById(id: string, includeDetails?: boolean): Promise<HttpLogEntity | null>;
|
|
25
|
+
/**
|
|
26
|
+
* 根据请求ID查询日志
|
|
27
|
+
*/
|
|
16
28
|
findLogByRequestId(requestId: string): Promise<HttpLogEntity | null>;
|
|
29
|
+
/**
|
|
30
|
+
* 查询错误日志
|
|
31
|
+
*/
|
|
17
32
|
findErrorLogs(options?: {
|
|
18
33
|
startDate?: Date;
|
|
19
34
|
endDate?: Date;
|
|
@@ -25,6 +40,9 @@ export declare class HttpLogQueryService {
|
|
|
25
40
|
logs: HttpLogEntity[];
|
|
26
41
|
total: number;
|
|
27
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* 查询慢请求日志
|
|
45
|
+
*/
|
|
28
46
|
findSlowRequests(minResponseTime?: number, options?: {
|
|
29
47
|
page?: number;
|
|
30
48
|
limit?: number;
|
|
@@ -32,6 +50,9 @@ export declare class HttpLogQueryService {
|
|
|
32
50
|
logs: HttpLogEntity[];
|
|
33
51
|
total: number;
|
|
34
52
|
}>;
|
|
53
|
+
/**
|
|
54
|
+
* 查询重试日志
|
|
55
|
+
*/
|
|
35
56
|
findRetryLogs(options?: {
|
|
36
57
|
minRetries?: number;
|
|
37
58
|
page?: number;
|
|
@@ -40,6 +61,9 @@ export declare class HttpLogQueryService {
|
|
|
40
61
|
logs: HttpLogEntity[];
|
|
41
62
|
total: number;
|
|
42
63
|
}>;
|
|
64
|
+
/**
|
|
65
|
+
* 获取统计信息
|
|
66
|
+
*/
|
|
43
67
|
getStats(options?: {
|
|
44
68
|
startDate?: Date;
|
|
45
69
|
endDate?: Date;
|
|
@@ -47,30 +71,89 @@ export declare class HttpLogQueryService {
|
|
|
47
71
|
serviceName?: string;
|
|
48
72
|
groupBy?: 'hour' | 'day' | 'week';
|
|
49
73
|
}): Promise<HttpLogStats>;
|
|
74
|
+
/**
|
|
75
|
+
* 删除旧日志
|
|
76
|
+
*/
|
|
50
77
|
deleteOldLogs(daysToKeep?: number): Promise<number>;
|
|
78
|
+
/**
|
|
79
|
+
* 清空所有日志
|
|
80
|
+
*/
|
|
51
81
|
clearAllLogs(): Promise<number>;
|
|
82
|
+
/**
|
|
83
|
+
* 根据日志ID生成curl命令
|
|
84
|
+
* @param logId 日志ID
|
|
85
|
+
* @returns curl命令字符串
|
|
86
|
+
*/
|
|
52
87
|
generateCurlFromLog(logId: string): Promise<string | null>;
|
|
88
|
+
/**
|
|
89
|
+
* 根据请求ID生成curl命令
|
|
90
|
+
* @param requestId 请求ID
|
|
91
|
+
* @returns curl命令字符串
|
|
92
|
+
*/
|
|
53
93
|
generateCurlFromRequestId(requestId: string): Promise<string | null>;
|
|
94
|
+
/**
|
|
95
|
+
* 根据日志生成可重放的请求配置
|
|
96
|
+
* @param logId 日志ID
|
|
97
|
+
* @returns 请求配置对象
|
|
98
|
+
*/
|
|
54
99
|
generateReplayConfigFromLog(logId: string): Promise<any | null>;
|
|
100
|
+
/**
|
|
101
|
+
* 根据请求ID生成可重放的请求配置
|
|
102
|
+
* @param requestId 请求ID
|
|
103
|
+
* @returns 请求配置对象
|
|
104
|
+
*/
|
|
55
105
|
generateReplayConfigFromRequestId(requestId: string): Promise<any | null>;
|
|
106
|
+
/**
|
|
107
|
+
* 批量生成curl命令
|
|
108
|
+
* @param options 查询选项
|
|
109
|
+
* @returns curl命令数组
|
|
110
|
+
*/
|
|
56
111
|
generateBatchCurlCommands(options?: HttpLogQueryOptions): Promise<Array<{
|
|
57
112
|
logId: string;
|
|
58
113
|
requestId?: string;
|
|
59
114
|
curlCommand: string;
|
|
60
115
|
}>>;
|
|
116
|
+
/**
|
|
117
|
+
* 获取日志的完整重放信息
|
|
118
|
+
* @param logId 日志ID
|
|
119
|
+
* @returns 包含curl命令和重放配置的对象
|
|
120
|
+
*/
|
|
61
121
|
getLogReplayInfo(logId: string): Promise<{
|
|
62
122
|
log: HttpLogEntity;
|
|
63
123
|
curlCommand: string | null;
|
|
64
124
|
replayConfig: any | null;
|
|
65
125
|
} | null>;
|
|
126
|
+
/**
|
|
127
|
+
* 根据请求ID获取日志的完整重放信息
|
|
128
|
+
* @param requestId 请求ID
|
|
129
|
+
* @returns 包含curl命令和重放配置的对象
|
|
130
|
+
*/
|
|
66
131
|
getLogReplayInfoByRequestId(requestId: string): Promise<{
|
|
67
132
|
log: HttpLogEntity;
|
|
68
133
|
curlCommand: string | null;
|
|
69
134
|
replayConfig: any | null;
|
|
70
135
|
} | null>;
|
|
136
|
+
/**
|
|
137
|
+
* 初始化仓库
|
|
138
|
+
*/
|
|
71
139
|
private initializeRepository;
|
|
140
|
+
/**
|
|
141
|
+
* 计算响应时间百分位数
|
|
142
|
+
*/
|
|
72
143
|
private calculatePercentiles;
|
|
144
|
+
/**
|
|
145
|
+
* 格式化统计结果
|
|
146
|
+
*/
|
|
73
147
|
private formatStats;
|
|
148
|
+
/**
|
|
149
|
+
* 构建查询
|
|
150
|
+
*/
|
|
74
151
|
private buildQuery;
|
|
152
|
+
/**
|
|
153
|
+
* 清理敏感信息用于生成curl命令
|
|
154
|
+
* 移除或替换敏感的请求头和认证信息
|
|
155
|
+
* @param headers 原始请求头
|
|
156
|
+
* @returns 清理后的请求头
|
|
157
|
+
*/
|
|
75
158
|
private sanitizeHeadersForCurl;
|
|
76
159
|
}
|
|
@@ -24,6 +24,9 @@ const common_1 = require("@nestjs/common");
|
|
|
24
24
|
const typeorm_1 = require("typeorm");
|
|
25
25
|
const http_log_entity_1 = require("../entities/http-log.entity");
|
|
26
26
|
const curl_generator_util_1 = require("../utils/curl-generator.util");
|
|
27
|
+
/**
|
|
28
|
+
* HTTP日志查询服务
|
|
29
|
+
*/
|
|
27
30
|
let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
28
31
|
constructor(dataSource) {
|
|
29
32
|
this.dataSource = dataSource;
|
|
@@ -31,6 +34,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
31
34
|
this.logRepository = null;
|
|
32
35
|
this.initializeRepository();
|
|
33
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* 查询HTTP日志
|
|
39
|
+
*/
|
|
34
40
|
findLogs() {
|
|
35
41
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
36
42
|
if (!this.logRepository) {
|
|
@@ -38,9 +44,12 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
38
44
|
}
|
|
39
45
|
const { page = 1, limit = 50, sortBy = 'createdAt', sortOrder = 'DESC', includeDetails = false, } = options;
|
|
40
46
|
const queryBuilder = this.buildQuery(options, includeDetails);
|
|
47
|
+
// 分页
|
|
41
48
|
const offset = (page - 1) * limit;
|
|
42
49
|
queryBuilder.skip(offset).take(limit);
|
|
50
|
+
// 排序
|
|
43
51
|
queryBuilder.orderBy(`log.${sortBy}`, sortOrder);
|
|
52
|
+
// 执行查询
|
|
44
53
|
const [logs, total] = yield queryBuilder.getManyAndCount();
|
|
45
54
|
return {
|
|
46
55
|
logs,
|
|
@@ -51,6 +60,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
51
60
|
};
|
|
52
61
|
});
|
|
53
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* 根据ID查询单条日志
|
|
65
|
+
*/
|
|
54
66
|
findLogById(id_1) {
|
|
55
67
|
return __awaiter(this, arguments, void 0, function* (id, includeDetails = false) {
|
|
56
68
|
if (!this.logRepository) {
|
|
@@ -63,6 +75,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
63
75
|
return queryBuilder.where('log.id = :id', { id }).getOne();
|
|
64
76
|
});
|
|
65
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* 根据请求ID查询日志
|
|
80
|
+
*/
|
|
66
81
|
findLogByRequestId(requestId) {
|
|
67
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
83
|
if (!this.logRepository) {
|
|
@@ -74,12 +89,18 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
74
89
|
});
|
|
75
90
|
});
|
|
76
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* 查询错误日志
|
|
94
|
+
*/
|
|
77
95
|
findErrorLogs() {
|
|
78
96
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
79
97
|
const queryOptions = Object.assign(Object.assign({}, options), { success: false });
|
|
80
98
|
return this.findLogs(queryOptions);
|
|
81
99
|
});
|
|
82
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* 查询慢请求日志
|
|
103
|
+
*/
|
|
83
104
|
findSlowRequests() {
|
|
84
105
|
return __awaiter(this, arguments, void 0, function* (minResponseTime = 5000, options = {}) {
|
|
85
106
|
if (!this.logRepository) {
|
|
@@ -97,6 +118,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
97
118
|
return { logs, total };
|
|
98
119
|
});
|
|
99
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* 查询重试日志
|
|
123
|
+
*/
|
|
100
124
|
findRetryLogs() {
|
|
101
125
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
102
126
|
if (!this.logRepository) {
|
|
@@ -115,12 +139,16 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
115
139
|
return { logs, total };
|
|
116
140
|
});
|
|
117
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* 获取统计信息
|
|
144
|
+
*/
|
|
118
145
|
getStats() {
|
|
119
146
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
120
147
|
if (!this.logRepository) {
|
|
121
148
|
throw new Error('HTTP log repository not available');
|
|
122
149
|
}
|
|
123
150
|
const { startDate, endDate, userId, serviceName } = options;
|
|
151
|
+
// 基础查询构建器
|
|
124
152
|
const baseQuery = this.logRepository.createQueryBuilder('log');
|
|
125
153
|
if (startDate) {
|
|
126
154
|
baseQuery.andWhere('log.createdAt >= :startDate', { startDate });
|
|
@@ -134,6 +162,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
134
162
|
if (serviceName) {
|
|
135
163
|
baseQuery.andWhere('log.serviceName = :serviceName', { serviceName });
|
|
136
164
|
}
|
|
165
|
+
// 总体统计
|
|
137
166
|
const [total, successful, failed] = yield Promise.all([
|
|
138
167
|
baseQuery.getCount(),
|
|
139
168
|
baseQuery
|
|
@@ -145,36 +174,43 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
145
174
|
.andWhere('log.success = :success', { success: false })
|
|
146
175
|
.getCount(),
|
|
147
176
|
]);
|
|
177
|
+
// 响应时间统计
|
|
148
178
|
const responseTimeStats = yield baseQuery
|
|
149
179
|
.select('AVG(log.responseTime)', 'avg')
|
|
150
180
|
.addSelect('MIN(log.responseTime)', 'min')
|
|
151
181
|
.addSelect('MAX(log.responseTime)', 'max')
|
|
152
182
|
.getRawOne();
|
|
183
|
+
// 按HTTP方法统计
|
|
153
184
|
const httpMethodStats = yield baseQuery
|
|
154
185
|
.select('log.method', 'method')
|
|
155
186
|
.addSelect('COUNT(*)', 'count')
|
|
156
187
|
.groupBy('log.method')
|
|
157
188
|
.getRawMany();
|
|
189
|
+
// 按状态码统计
|
|
158
190
|
const statusStats = yield baseQuery
|
|
159
191
|
.select('log.statusCode', 'statusCode')
|
|
160
192
|
.addSelect('COUNT(*)', 'count')
|
|
161
193
|
.groupBy('log.statusCode')
|
|
162
194
|
.getRawMany();
|
|
195
|
+
// 按服务统计
|
|
163
196
|
const serviceStats = yield baseQuery
|
|
164
197
|
.select('log.serviceName', 'serviceName')
|
|
165
198
|
.addSelect('COUNT(*)', 'count')
|
|
166
199
|
.groupBy('log.serviceName')
|
|
167
200
|
.getRawMany();
|
|
201
|
+
// 按操作统计
|
|
168
202
|
const operationStats = yield baseQuery
|
|
169
203
|
.select('log.operationName', 'operationName')
|
|
170
204
|
.addSelect('COUNT(*)', 'count')
|
|
171
205
|
.groupBy('log.operationName')
|
|
172
206
|
.getRawMany();
|
|
207
|
+
// 按来源统计
|
|
173
208
|
const sourceStats = yield baseQuery
|
|
174
209
|
.select('log.source', 'source')
|
|
175
210
|
.addSelect('COUNT(*)', 'count')
|
|
176
211
|
.groupBy('log.source')
|
|
177
212
|
.getRawMany();
|
|
213
|
+
// 错误统计
|
|
178
214
|
const errorStats = yield baseQuery
|
|
179
215
|
.clone()
|
|
180
216
|
.where('log.success = :success', { success: false })
|
|
@@ -182,17 +218,14 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
182
218
|
.addSelect('COUNT(*)', 'count')
|
|
183
219
|
.groupBy('log.errorCode')
|
|
184
220
|
.getRawMany();
|
|
221
|
+
// 重试统计
|
|
185
222
|
const retryStats = yield baseQuery
|
|
186
223
|
.select('AVG(log.attemptCount)', 'avgAttempts')
|
|
187
224
|
.addSelect('MAX(log.attemptCount)', 'maxAttempts')
|
|
188
225
|
.addSelect('SUM(log.attemptCount - 1)', 'totalRetries')
|
|
189
226
|
.addSelect('COUNT(*)', 'totalRequests')
|
|
190
227
|
.getRawOne();
|
|
191
|
-
|
|
192
|
-
.select('SUM(CASE WHEN log.cacheHit = true THEN 1 ELSE 0 END)', 'cacheHits')
|
|
193
|
-
.addSelect('SUM(CASE WHEN log.cacheHit = false OR log.cacheHit IS NULL THEN 1 ELSE 0 END)', 'cacheMisses')
|
|
194
|
-
.addSelect('COUNT(*)', 'total')
|
|
195
|
-
.getRawOne();
|
|
228
|
+
// 百分位数计算(简化版)
|
|
196
229
|
const percentiles = yield this.calculatePercentiles(baseQuery);
|
|
197
230
|
return {
|
|
198
231
|
totalRequests: total,
|
|
@@ -220,16 +253,12 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
220
253
|
: 0,
|
|
221
254
|
retryRate: total > 0 ? (((retryStats === null || retryStats === void 0 ? void 0 : retryStats.totalRetries) || 0) / total) * 100 : 0,
|
|
222
255
|
},
|
|
223
|
-
cacheStats: {
|
|
224
|
-
cacheHits: (cacheStats === null || cacheStats === void 0 ? void 0 : cacheStats.cacheHits) || 0,
|
|
225
|
-
cacheMisses: (cacheStats === null || cacheStats === void 0 ? void 0 : cacheStats.cacheMisses) || 0,
|
|
226
|
-
cacheHitRate: (cacheStats === null || cacheStats === void 0 ? void 0 : cacheStats.total) > 0
|
|
227
|
-
? (((cacheStats === null || cacheStats === void 0 ? void 0 : cacheStats.cacheHits) || 0) / cacheStats.total) * 100
|
|
228
|
-
: 0,
|
|
229
|
-
},
|
|
230
256
|
};
|
|
231
257
|
});
|
|
232
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* 删除旧日志
|
|
261
|
+
*/
|
|
233
262
|
deleteOldLogs() {
|
|
234
263
|
return __awaiter(this, arguments, void 0, function* (daysToKeep = 30) {
|
|
235
264
|
if (!this.logRepository) {
|
|
@@ -246,6 +275,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
246
275
|
return result.affected || 0;
|
|
247
276
|
});
|
|
248
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* 清空所有日志
|
|
280
|
+
*/
|
|
249
281
|
clearAllLogs() {
|
|
250
282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
283
|
if (!this.logRepository) {
|
|
@@ -253,9 +285,14 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
253
285
|
}
|
|
254
286
|
yield this.logRepository.clear();
|
|
255
287
|
this.logger.warn('Cleared all HTTP logs');
|
|
256
|
-
return 0;
|
|
288
|
+
return 0; // Cannot get affected count from clear()
|
|
257
289
|
});
|
|
258
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* 根据日志ID生成curl命令
|
|
293
|
+
* @param logId 日志ID
|
|
294
|
+
* @returns curl命令字符串
|
|
295
|
+
*/
|
|
259
296
|
generateCurlFromLog(logId) {
|
|
260
297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
298
|
if (!this.logRepository) {
|
|
@@ -269,7 +306,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
269
306
|
return null;
|
|
270
307
|
}
|
|
271
308
|
try {
|
|
309
|
+
// 清理敏感信息
|
|
272
310
|
const sanitizedHeaders = this.sanitizeHeadersForCurl(log.headers || {});
|
|
311
|
+
// 构建请求配置
|
|
273
312
|
const requestConfig = {
|
|
274
313
|
method: log.method,
|
|
275
314
|
url: log.url,
|
|
@@ -277,6 +316,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
277
316
|
data: log.body,
|
|
278
317
|
params: log.params,
|
|
279
318
|
};
|
|
319
|
+
// 使用CurlGenerator生成curl命令
|
|
280
320
|
const curlCommand = curl_generator_util_1.CurlGenerator.generateCurlCommand(requestConfig);
|
|
281
321
|
this.logger.log(`Generated curl command for log ${logId}`);
|
|
282
322
|
return curlCommand;
|
|
@@ -287,6 +327,11 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
287
327
|
}
|
|
288
328
|
});
|
|
289
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* 根据请求ID生成curl命令
|
|
332
|
+
* @param requestId 请求ID
|
|
333
|
+
* @returns curl命令字符串
|
|
334
|
+
*/
|
|
290
335
|
generateCurlFromRequestId(requestId) {
|
|
291
336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
337
|
if (!this.logRepository) {
|
|
@@ -303,6 +348,11 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
303
348
|
return this.generateCurlFromLog(log.id);
|
|
304
349
|
});
|
|
305
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* 根据日志生成可重放的请求配置
|
|
353
|
+
* @param logId 日志ID
|
|
354
|
+
* @returns 请求配置对象
|
|
355
|
+
*/
|
|
306
356
|
generateReplayConfigFromLog(logId) {
|
|
307
357
|
return __awaiter(this, void 0, void 0, function* () {
|
|
308
358
|
if (!this.logRepository) {
|
|
@@ -316,6 +366,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
316
366
|
return null;
|
|
317
367
|
}
|
|
318
368
|
try {
|
|
369
|
+
// 构建重放配置
|
|
319
370
|
const replayConfig = {
|
|
320
371
|
method: log.method,
|
|
321
372
|
url: log.url,
|
|
@@ -326,6 +377,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
326
377
|
: log.body
|
|
327
378
|
: undefined,
|
|
328
379
|
params: log.params || {},
|
|
380
|
+
// 添加重放标记
|
|
329
381
|
metadata: {
|
|
330
382
|
originalLogId: log.id,
|
|
331
383
|
originalRequestId: log.requestId,
|
|
@@ -342,6 +394,11 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
342
394
|
}
|
|
343
395
|
});
|
|
344
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* 根据请求ID生成可重放的请求配置
|
|
399
|
+
* @param requestId 请求ID
|
|
400
|
+
* @returns 请求配置对象
|
|
401
|
+
*/
|
|
345
402
|
generateReplayConfigFromRequestId(requestId) {
|
|
346
403
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
404
|
if (!this.logRepository) {
|
|
@@ -358,11 +415,17 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
358
415
|
return this.generateReplayConfigFromLog(log.id);
|
|
359
416
|
});
|
|
360
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* 批量生成curl命令
|
|
420
|
+
* @param options 查询选项
|
|
421
|
+
* @returns curl命令数组
|
|
422
|
+
*/
|
|
361
423
|
generateBatchCurlCommands() {
|
|
362
424
|
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
363
425
|
if (!this.logRepository) {
|
|
364
426
|
throw new Error('HTTP log repository not available');
|
|
365
427
|
}
|
|
428
|
+
// 限制返回数量以避免过大的响应
|
|
366
429
|
const limitedOptions = Object.assign(Object.assign({}, options), { limit: Math.min(options.limit || 10, 50) });
|
|
367
430
|
const result = yield this.findLogs(limitedOptions);
|
|
368
431
|
const curlCommands = [];
|
|
@@ -385,6 +448,11 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
385
448
|
return curlCommands;
|
|
386
449
|
});
|
|
387
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* 获取日志的完整重放信息
|
|
453
|
+
* @param logId 日志ID
|
|
454
|
+
* @returns 包含curl命令和重放配置的对象
|
|
455
|
+
*/
|
|
388
456
|
getLogReplayInfo(logId) {
|
|
389
457
|
return __awaiter(this, void 0, void 0, function* () {
|
|
390
458
|
if (!this.logRepository) {
|
|
@@ -405,6 +473,11 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
405
473
|
};
|
|
406
474
|
});
|
|
407
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* 根据请求ID获取日志的完整重放信息
|
|
478
|
+
* @param requestId 请求ID
|
|
479
|
+
* @returns 包含curl命令和重放配置的对象
|
|
480
|
+
*/
|
|
408
481
|
getLogReplayInfoByRequestId(requestId) {
|
|
409
482
|
return __awaiter(this, void 0, void 0, function* () {
|
|
410
483
|
const log = yield this.findLogByRequestId(requestId);
|
|
@@ -414,6 +487,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
414
487
|
return this.getLogReplayInfo(log.id);
|
|
415
488
|
});
|
|
416
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* 初始化仓库
|
|
492
|
+
*/
|
|
417
493
|
initializeRepository() {
|
|
418
494
|
if (this.dataSource) {
|
|
419
495
|
try {
|
|
@@ -425,9 +501,13 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
425
501
|
}
|
|
426
502
|
}
|
|
427
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* 计算响应时间百分位数
|
|
506
|
+
*/
|
|
428
507
|
calculatePercentiles(queryBuilder) {
|
|
429
508
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
509
|
try {
|
|
510
|
+
// 获取所有响应时间
|
|
431
511
|
const results = yield queryBuilder
|
|
432
512
|
.select('log.responseTime', 'responseTime')
|
|
433
513
|
.where('log.responseTime IS NOT NULL')
|
|
@@ -456,6 +536,9 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
456
536
|
}
|
|
457
537
|
});
|
|
458
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* 格式化统计结果
|
|
541
|
+
*/
|
|
459
542
|
formatStats(stats, keyField, valueField) {
|
|
460
543
|
return stats.reduce((acc, item) => {
|
|
461
544
|
const key = item[keyField] || 'unknown';
|
|
@@ -464,14 +547,19 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
464
547
|
return acc;
|
|
465
548
|
}, {});
|
|
466
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* 构建查询
|
|
552
|
+
*/
|
|
467
553
|
buildQuery(options, includeDetails = false) {
|
|
468
554
|
if (!this.logRepository) {
|
|
469
555
|
throw new Error('HTTP log repository not available');
|
|
470
556
|
}
|
|
471
557
|
const queryBuilder = this.logRepository.createQueryBuilder('log');
|
|
558
|
+
// 关联查询重试记录
|
|
472
559
|
if (includeDetails) {
|
|
473
560
|
queryBuilder.leftJoinAndSelect('log.retryRecords', 'retryRecords');
|
|
474
561
|
}
|
|
562
|
+
// 基础条件
|
|
475
563
|
if (options.requestId) {
|
|
476
564
|
queryBuilder.andWhere('log.requestId = :requestId', {
|
|
477
565
|
requestId: options.requestId,
|
|
@@ -480,6 +568,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
480
568
|
if (options.userId) {
|
|
481
569
|
queryBuilder.andWhere('log.userId = :userId', { userId: options.userId });
|
|
482
570
|
}
|
|
571
|
+
// 方法过滤
|
|
483
572
|
if (options.method) {
|
|
484
573
|
if (Array.isArray(options.method)) {
|
|
485
574
|
queryBuilder.andWhere('log.method IN (:...methods)', {
|
|
@@ -492,9 +581,11 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
492
581
|
});
|
|
493
582
|
}
|
|
494
583
|
}
|
|
584
|
+
// URL过滤
|
|
495
585
|
if (options.url) {
|
|
496
586
|
queryBuilder.andWhere('log.url LIKE :url', { url: `%${options.url}%` });
|
|
497
587
|
}
|
|
588
|
+
// 状态码过滤
|
|
498
589
|
if (options.statusCode) {
|
|
499
590
|
if (Array.isArray(options.statusCode)) {
|
|
500
591
|
queryBuilder.andWhere('log.statusCode IN (:...statusCodes)', {
|
|
@@ -507,39 +598,47 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
507
598
|
});
|
|
508
599
|
}
|
|
509
600
|
}
|
|
601
|
+
// 成功状态过滤
|
|
510
602
|
if (options.success !== undefined) {
|
|
511
603
|
queryBuilder.andWhere('log.success = :success', {
|
|
512
604
|
success: options.success,
|
|
513
605
|
});
|
|
514
606
|
}
|
|
607
|
+
// 服务名称过滤
|
|
515
608
|
if (options.serviceName) {
|
|
516
609
|
queryBuilder.andWhere('log.serviceName = :serviceName', {
|
|
517
610
|
serviceName: options.serviceName,
|
|
518
611
|
});
|
|
519
612
|
}
|
|
613
|
+
// 操作名称过滤
|
|
520
614
|
if (options.operationName) {
|
|
521
615
|
queryBuilder.andWhere('log.operationName = :operationName', {
|
|
522
616
|
operationName: options.operationName,
|
|
523
617
|
});
|
|
524
618
|
}
|
|
619
|
+
// 客户端IP过滤
|
|
525
620
|
if (options.clientIp) {
|
|
526
621
|
queryBuilder.andWhere('log.clientIp = :clientIp', {
|
|
527
622
|
clientIp: options.clientIp,
|
|
528
623
|
});
|
|
529
624
|
}
|
|
625
|
+
// 来源过滤
|
|
530
626
|
if (options.source) {
|
|
531
627
|
queryBuilder.andWhere('log.source = :source', { source: options.source });
|
|
532
628
|
}
|
|
629
|
+
// 标签过滤
|
|
533
630
|
if (options.tags && options.tags.length > 0) {
|
|
534
631
|
queryBuilder.andWhere('JSON_CONTAINS(log.tags, :tags)', {
|
|
535
632
|
tags: JSON.stringify(options.tags),
|
|
536
633
|
});
|
|
537
634
|
}
|
|
635
|
+
// 错误代码过滤
|
|
538
636
|
if (options.errorCode) {
|
|
539
637
|
queryBuilder.andWhere('log.errorCode = :errorCode', {
|
|
540
638
|
errorCode: options.errorCode,
|
|
541
639
|
});
|
|
542
640
|
}
|
|
641
|
+
// 响应时间范围过滤
|
|
543
642
|
if (options.minResponseTime) {
|
|
544
643
|
queryBuilder.andWhere('log.responseTime >= :minResponseTime', {
|
|
545
644
|
minResponseTime: options.minResponseTime,
|
|
@@ -550,6 +649,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
550
649
|
maxResponseTime: options.maxResponseTime,
|
|
551
650
|
});
|
|
552
651
|
}
|
|
652
|
+
// 时间范围过滤
|
|
553
653
|
if (options.startDate) {
|
|
554
654
|
queryBuilder.andWhere('log.createdAt >= :startDate', {
|
|
555
655
|
startDate: options.startDate,
|
|
@@ -560,11 +660,18 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
560
660
|
endDate: options.endDate,
|
|
561
661
|
});
|
|
562
662
|
}
|
|
663
|
+
// 关键词搜索
|
|
563
664
|
if (options.keyword) {
|
|
564
665
|
queryBuilder.andWhere('(log.url LIKE :keyword OR log.errorMessage LIKE :keyword OR log.body LIKE :keyword)', { keyword: `%${options.keyword}%` });
|
|
565
666
|
}
|
|
566
667
|
return queryBuilder;
|
|
567
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* 清理敏感信息用于生成curl命令
|
|
671
|
+
* 移除或替换敏感的请求头和认证信息
|
|
672
|
+
* @param headers 原始请求头
|
|
673
|
+
* @returns 清理后的请求头
|
|
674
|
+
*/
|
|
568
675
|
sanitizeHeadersForCurl(headers) {
|
|
569
676
|
const sensitiveHeaders = [
|
|
570
677
|
'authorization',
|
|
@@ -577,6 +684,7 @@ let HttpLogQueryService = HttpLogQueryService_1 = class HttpLogQueryService {
|
|
|
577
684
|
const sanitized = Object.assign({}, headers);
|
|
578
685
|
for (const header of sensitiveHeaders) {
|
|
579
686
|
if (sanitized[header]) {
|
|
687
|
+
// 保留头部但替换值为占位符
|
|
580
688
|
sanitized[header] = '***REDACTED***';
|
|
581
689
|
}
|
|
582
690
|
}
|