@nest-omni/core 4.1.3-1 → 4.1.3-11
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 +39 -1
- package/audit/controllers/audit.controller.d.ts +24 -0
- package/audit/controllers/audit.controller.js +24 -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 +76 -1
- package/audit/decorators/entity-audit.decorator.js +135 -3
- package/audit/decorators/index.d.ts +1 -0
- package/audit/decorators/index.js +1 -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/entity-audit-log.entity.d.ts +8 -0
- package/audit/entities/entity-audit-log.entity.js +33 -1
- package/audit/entities/entity-transaction.entity.d.ts +10 -0
- package/audit/entities/entity-transaction.entity.js +33 -1
- package/audit/entities/index.d.ts +2 -0
- package/audit/entities/index.js +2 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -0
- package/audit/entities/manual-operation-log.entity.js +4 -0
- 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 +45 -5
- package/audit/enums/audit.enums.js +47 -4
- package/audit/index.d.ts +3 -1
- package/audit/index.js +30 -1
- package/audit/interceptors/audit.interceptor.d.ts +15 -0
- package/audit/interceptors/audit.interceptor.js +23 -1
- package/audit/interfaces/audit.interfaces.d.ts +182 -2
- package/audit/services/audit-context.service.d.ts +15 -0
- package/audit/services/audit-context.service.js +15 -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 +129 -3
- package/audit/services/entity-audit.service.js +301 -6
- package/audit/services/index.d.ts +2 -0
- package/audit/services/index.js +2 -0
- package/audit/services/manual-audit-log.service.d.ts +124 -0
- package/audit/services/manual-audit-log.service.js +138 -0
- package/audit/services/multi-database.service.d.ts +12 -0
- package/audit/services/multi-database.service.js +12 -0
- package/audit/services/operation-description.service.d.ts +59 -0
- package/audit/services/operation-description.service.js +76 -2
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +47 -0
- package/audit/subscribers/entity-audit.subscriber.d.ts +15 -0
- package/audit/subscribers/entity-audit.subscriber.js +29 -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 +86 -0
- package/cache/cache.module.js +71 -0
- package/cache/cache.service.d.ts +140 -0
- package/cache/cache.service.js +157 -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 +45 -0
- package/cache/dependencies/db.dependency.js +48 -1
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +36 -0
- package/cache/dependencies/tag.dependency.js +36 -0
- 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 +81 -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 +23 -0
- package/cache/providers/memory-cache.provider.js +26 -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 -4
- package/common/boilerplate.polyfill.js +24 -100
- 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.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/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 +15 -0
- package/http-client/config/http-client.config.js +25 -9
- package/http-client/decorators/http-client.decorators.d.ts +63 -0
- package/http-client/decorators/http-client.decorators.js +71 -3
- package/http-client/entities/http-log.entity.d.ts +229 -0
- package/http-client/entities/http-log.entity.js +6 -1
- 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 +41 -0
- package/http-client/examples/advanced-usage.example.js +68 -24
- 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/http-client.module.d.ts +13 -0
- package/http-client/http-client.module.js +20 -5
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +125 -0
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +60 -0
- package/http-client/services/api-client-registry.service.d.ts +57 -0
- package/http-client/services/api-client-registry.service.js +84 -1
- package/http-client/services/cache.service.d.ts +52 -0
- package/http-client/services/cache.service.js +72 -3
- package/http-client/services/circuit-breaker.service.d.ts +46 -0
- package/http-client/services/circuit-breaker.service.js +52 -0
- package/http-client/services/http-client.service.d.ts +67 -0
- package/http-client/services/http-client.service.js +105 -4
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +122 -1
- 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/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 +40 -0
- package/http-client/services/logging.service.js +53 -0
- package/http-client/utils/call-stack-extractor.util.d.ts +37 -0
- package/http-client/utils/call-stack-extractor.util.js +48 -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/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/i18n/en_US/validation.json +2 -1
- package/i18n/zh_CN/validation.json +2 -1
- package/index.js +8 -0
- package/interceptors/translation-interceptor.service.js +5 -0
- package/package.json +1 -1
- 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 +78 -0
- package/redis-lock/lock-heartbeat.service.js +222 -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 +278 -0
- package/redis-lock/redis-lock.service.js +282 -12
- package/setup/bootstrap.setup.js +20 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/schedule.decorator.d.ts +227 -0
- package/setup/schedule.decorator.js +235 -12
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +88 -0
- package/shared/serviceRegistryModule.js +27 -14
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +20 -9
- 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 +96 -0
- package/validators/custom-validate.examples.js +400 -0
- package/validators/custom-validate.validator.d.ts +134 -0
- package/validators/custom-validate.validator.js +214 -0
- package/validators/index.d.ts +2 -0
- package/validators/index.js +2 -0
- package/validators/is-exists.validator.d.ts +18 -4
- package/validators/is-exists.validator.js +67 -6
- package/validators/is-unique.validator.d.ts +32 -5
- package/validators/is-unique.validator.js +99 -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
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.BeginTransactionDto = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* 开始事务DTO
|
|
17
|
+
*/
|
|
15
18
|
class BeginTransactionDto {
|
|
16
19
|
}
|
|
17
20
|
exports.BeginTransactionDto = BeginTransactionDto;
|
|
@@ -13,6 +13,9 @@ exports.CompareEntitiesDto = void 0;
|
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const class_transformer_1 = require("class-transformer");
|
|
16
|
+
/**
|
|
17
|
+
* 比较实体DTO
|
|
18
|
+
*/
|
|
16
19
|
class CompareEntitiesDto {
|
|
17
20
|
}
|
|
18
21
|
exports.CompareEntitiesDto = CompareEntitiesDto;
|
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PreCheckRestoreDto = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* 预检查恢复DTO
|
|
17
|
+
*/
|
|
15
18
|
class PreCheckRestoreDto {
|
|
16
19
|
}
|
|
17
20
|
exports.PreCheckRestoreDto = PreCheckRestoreDto;
|
|
@@ -13,6 +13,9 @@ exports.RestoreEntityDto = void 0;
|
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const enums_1 = require("../enums");
|
|
16
|
+
/**
|
|
17
|
+
* 恢复实体DTO
|
|
18
|
+
*/
|
|
16
19
|
class RestoreEntityDto {
|
|
17
20
|
constructor() {
|
|
18
21
|
this.strategy = enums_1.RecoveryStrategy.ENTITY_ONLY;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
|
|
2
2
|
import { AuditOperation } from '../enums';
|
|
3
|
+
import { ChangeDetail, RollbackAction } from '../interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* 实体审计日志
|
|
6
|
+
*/
|
|
3
7
|
export declare class EntityAuditLogEntity extends AbstractUuidPrimaryEntity {
|
|
4
8
|
entityType: string;
|
|
5
9
|
entityId: string;
|
|
@@ -15,4 +19,8 @@ export declare class EntityAuditLogEntity extends AbstractUuidPrimaryEntity {
|
|
|
15
19
|
userAgent: string;
|
|
16
20
|
description: string;
|
|
17
21
|
hashChain: Record<string, any>;
|
|
22
|
+
operationTemplateKey: string;
|
|
23
|
+
descriptionParams: Record<string, any>;
|
|
24
|
+
changeDetails: ChangeDetail[];
|
|
25
|
+
rollbackActions: RollbackAction[];
|
|
18
26
|
}
|
|
@@ -13,6 +13,9 @@ exports.EntityAuditLogEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const abstract_entity_1 = require("../../common/abstract.entity");
|
|
15
15
|
const enums_1 = require("../enums");
|
|
16
|
+
/**
|
|
17
|
+
* 实体审计日志
|
|
18
|
+
*/
|
|
16
19
|
let EntityAuditLogEntity = class EntityAuditLogEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
|
|
17
20
|
};
|
|
18
21
|
exports.EntityAuditLogEntity = EntityAuditLogEntity;
|
|
@@ -72,10 +75,39 @@ __decorate([
|
|
|
72
75
|
(0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '哈希链' }),
|
|
73
76
|
__metadata("design:type", Object)
|
|
74
77
|
], EntityAuditLogEntity.prototype, "hashChain", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ nullable: true, comment: '操作模板键,用于动态生成描述' }),
|
|
80
|
+
__metadata("design:type", String)
|
|
81
|
+
], EntityAuditLogEntity.prototype, "operationTemplateKey", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({
|
|
84
|
+
type: 'json',
|
|
85
|
+
nullable: true,
|
|
86
|
+
comment: '描述参数,用于填充模板占位符',
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], EntityAuditLogEntity.prototype, "descriptionParams", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typeorm_1.Column)({
|
|
92
|
+
type: 'json',
|
|
93
|
+
nullable: true,
|
|
94
|
+
comment: '结构化变更详情列表(包含多语言支持)',
|
|
95
|
+
}),
|
|
96
|
+
__metadata("design:type", Array)
|
|
97
|
+
], EntityAuditLogEntity.prototype, "changeDetails", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, typeorm_1.Column)({
|
|
100
|
+
type: 'json',
|
|
101
|
+
nullable: true,
|
|
102
|
+
comment: '回滚操作列表',
|
|
103
|
+
}),
|
|
104
|
+
__metadata("design:type", Array)
|
|
105
|
+
], EntityAuditLogEntity.prototype, "rollbackActions", void 0);
|
|
75
106
|
exports.EntityAuditLogEntity = EntityAuditLogEntity = __decorate([
|
|
76
107
|
(0, typeorm_1.Entity)('entity_audit_log'),
|
|
77
108
|
(0, typeorm_1.Index)('idx_entity_relation', ['entityType', 'entityId']),
|
|
78
109
|
(0, typeorm_1.Index)('idx_operation', ['operation']),
|
|
79
110
|
(0, typeorm_1.Index)('idx_user', ['userId']),
|
|
80
|
-
(0, typeorm_1.Index)('idx_created_at', ['createdAt'])
|
|
111
|
+
(0, typeorm_1.Index)('idx_created_at', ['createdAt']),
|
|
112
|
+
(0, typeorm_1.Index)('idx_template_key', ['operationTemplateKey'])
|
|
81
113
|
], EntityAuditLogEntity);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
|
|
2
2
|
import { AuditOperation, TransactionStatus } from '../enums';
|
|
3
|
+
import { ManualOperationLogEntity } from './manual-operation-log.entity';
|
|
4
|
+
/**
|
|
5
|
+
* 实体事务
|
|
6
|
+
*/
|
|
3
7
|
export declare class EntityTransactionEntity extends AbstractUuidPrimaryEntity {
|
|
4
8
|
description: string;
|
|
5
9
|
status: TransactionStatus;
|
|
@@ -11,4 +15,10 @@ export declare class EntityTransactionEntity extends AbstractUuidPrimaryEntity {
|
|
|
11
15
|
userId: string;
|
|
12
16
|
username: string;
|
|
13
17
|
dependencyGraph: Record<string, any>;
|
|
18
|
+
operationTemplateKey: string;
|
|
19
|
+
descriptionParams: Record<string, any>;
|
|
20
|
+
requestIp: string;
|
|
21
|
+
metadata: Record<string, any>;
|
|
22
|
+
completedAt: Date;
|
|
23
|
+
manualOperations: ManualOperationLogEntity[];
|
|
14
24
|
}
|
|
@@ -13,6 +13,9 @@ exports.EntityTransactionEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const abstract_entity_1 = require("../../common/abstract.entity");
|
|
15
15
|
const enums_1 = require("../enums");
|
|
16
|
+
/**
|
|
17
|
+
* 实体事务
|
|
18
|
+
*/
|
|
16
19
|
let EntityTransactionEntity = class EntityTransactionEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
|
|
17
20
|
};
|
|
18
21
|
exports.EntityTransactionEntity = EntityTransactionEntity;
|
|
@@ -43,9 +46,38 @@ __decorate([
|
|
|
43
46
|
(0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '依赖图' }),
|
|
44
47
|
__metadata("design:type", Object)
|
|
45
48
|
], EntityTransactionEntity.prototype, "dependencyGraph", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ nullable: true, comment: '操作模板键(事务级别)' }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], EntityTransactionEntity.prototype, "operationTemplateKey", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({
|
|
55
|
+
type: 'json',
|
|
56
|
+
nullable: true,
|
|
57
|
+
comment: '描述参数,用于填充事务级别的模板占位符',
|
|
58
|
+
}),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], EntityTransactionEntity.prototype, "descriptionParams", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.Column)({ nullable: true, comment: '请求IP' }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], EntityTransactionEntity.prototype, "requestIp", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '事务元数据' }),
|
|
67
|
+
__metadata("design:type", Object)
|
|
68
|
+
], EntityTransactionEntity.prototype, "metadata", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true, comment: '完成时间' }),
|
|
71
|
+
__metadata("design:type", Date)
|
|
72
|
+
], EntityTransactionEntity.prototype, "completedAt", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.OneToMany)('ManualOperationLogEntity', (log) => log.transaction),
|
|
75
|
+
__metadata("design:type", Array)
|
|
76
|
+
], EntityTransactionEntity.prototype, "manualOperations", void 0);
|
|
46
77
|
exports.EntityTransactionEntity = EntityTransactionEntity = __decorate([
|
|
47
78
|
(0, typeorm_1.Entity)('entity_transaction'),
|
|
48
79
|
(0, typeorm_1.Index)('idx_status', ['status']),
|
|
49
80
|
(0, typeorm_1.Index)('idx_user', ['userId']),
|
|
50
|
-
(0, typeorm_1.Index)('idx_created_at', ['createdAt'])
|
|
81
|
+
(0, typeorm_1.Index)('idx_created_at', ['createdAt']),
|
|
82
|
+
(0, typeorm_1.Index)('idx_template_key', ['operationTemplateKey'])
|
|
51
83
|
], EntityTransactionEntity);
|
package/audit/entities/index.js
CHANGED
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./entity-audit-log.entity"), exports);
|
|
18
18
|
__exportStar(require("./entity-transaction.entity"), exports);
|
|
19
|
+
__exportStar(require("./operation-template.entity"), exports);
|
|
20
|
+
__exportStar(require("./manual-operation-log.entity"), exports);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
|
|
2
2
|
import { EntityTransactionEntity } from './entity-transaction.entity';
|
|
3
3
|
import { RollbackAction } from '../interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* 手动操作记录表
|
|
6
|
+
* 用于记录跨实体的复杂业务操作
|
|
7
|
+
*/
|
|
4
8
|
export declare class ManualOperationLogEntity extends AbstractUuidPrimaryEntity {
|
|
5
9
|
transactionId: string;
|
|
6
10
|
operationTemplateKey: string;
|
|
@@ -13,6 +13,10 @@ exports.ManualOperationLogEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const abstract_entity_1 = require("../../common/abstract.entity");
|
|
15
15
|
const entity_transaction_entity_1 = require("./entity-transaction.entity");
|
|
16
|
+
/**
|
|
17
|
+
* 手动操作记录表
|
|
18
|
+
* 用于记录跨实体的复杂业务操作
|
|
19
|
+
*/
|
|
16
20
|
let ManualOperationLogEntity = class ManualOperationLogEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
|
|
17
21
|
};
|
|
18
22
|
exports.ManualOperationLogEntity = ManualOperationLogEntity;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
|
|
2
2
|
import { AuditOperation } from '../enums';
|
|
3
|
+
/**
|
|
4
|
+
* 操作模板配置表
|
|
5
|
+
* 用于存储多语言操作描述模板
|
|
6
|
+
*/
|
|
3
7
|
export declare class OperationTemplateEntity extends AbstractUuidPrimaryEntity {
|
|
4
8
|
key: string;
|
|
5
9
|
entityName: string;
|
|
@@ -13,6 +13,10 @@ exports.OperationTemplateEntity = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const abstract_entity_1 = require("../../common/abstract.entity");
|
|
15
15
|
const enums_1 = require("../enums");
|
|
16
|
+
/**
|
|
17
|
+
* 操作模板配置表
|
|
18
|
+
* 用于存储多语言操作描述模板
|
|
19
|
+
*/
|
|
16
20
|
let OperationTemplateEntity = class OperationTemplateEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
|
|
17
21
|
};
|
|
18
22
|
exports.OperationTemplateEntity = OperationTemplateEntity;
|
|
@@ -1,27 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 操作类型(设计文档标准命名)
|
|
3
|
+
*/
|
|
4
|
+
export declare enum OperationType {
|
|
5
|
+
CREATE = "create",
|
|
6
|
+
UPDATE = "update",
|
|
7
|
+
DELETE = "delete"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 审计操作类型(兼容性别名,映射到 OperationType)
|
|
11
|
+
* @deprecated 请使用 OperationType
|
|
12
|
+
*/
|
|
1
13
|
export declare enum AuditOperation {
|
|
2
14
|
CREATE = "CREATE",
|
|
3
15
|
UPDATE = "UPDATE",
|
|
4
16
|
DELETE = "DELETE",
|
|
5
17
|
RESTORE = "RESTORE"
|
|
6
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* 事务状态(设计文档标准命名)
|
|
21
|
+
*/
|
|
7
22
|
export declare enum TransactionStatus {
|
|
8
|
-
PENDING = "
|
|
9
|
-
COMMITTED = "
|
|
10
|
-
ROLLED_BACK = "
|
|
23
|
+
PENDING = "pending",
|
|
24
|
+
COMMITTED = "committed",
|
|
25
|
+
ROLLED_BACK = "rolled_back"
|
|
11
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* 恢复策略
|
|
29
|
+
*/
|
|
12
30
|
export declare enum RecoveryStrategy {
|
|
13
31
|
ENTITY_ONLY = "ENTITY_ONLY",
|
|
14
32
|
TRANSACTION_RESTORE = "TRANSACTION_RESTORE",
|
|
15
33
|
DEPENDENCY_GRAPH = "DEPENDENCY_GRAPH"
|
|
16
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* 记录策略
|
|
37
|
+
*/
|
|
17
38
|
export declare enum RecordStrategy {
|
|
18
|
-
FULL = "FULL"
|
|
19
|
-
DIFF_ONLY = "DIFF_ONLY"
|
|
39
|
+
FULL = "FULL",// 记录完整变更
|
|
40
|
+
DIFF_ONLY = "DIFF_ONLY",// 仅记录差异
|
|
20
41
|
DISABLED = "DISABLED"
|
|
21
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 脱敏策略
|
|
45
|
+
*/
|
|
22
46
|
export declare enum MaskingStrategy {
|
|
23
47
|
NONE = "NONE",
|
|
24
48
|
HASH = "HASH",
|
|
25
49
|
MASK = "MASK",
|
|
26
50
|
PARTIAL = "PARTIAL"
|
|
27
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* 回滚操作类型(设计文档标准命名)
|
|
54
|
+
*/
|
|
55
|
+
export declare enum RollbackActionType {
|
|
56
|
+
ENTITY = "entity",// 实体回滚(删除/恢复)
|
|
57
|
+
FILE = "file",// 文件回滚(删除上传的文件)
|
|
58
|
+
CUSTOM = "custom"
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 变更类型(设计文档标准命名)
|
|
62
|
+
*/
|
|
63
|
+
export declare enum ChangeType {
|
|
64
|
+
ADDED = "added",// 新增字段
|
|
65
|
+
REMOVED = "removed",// 删除字段
|
|
66
|
+
MODIFIED = "modified"
|
|
67
|
+
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MaskingStrategy = exports.RecordStrategy = exports.RecoveryStrategy = exports.TransactionStatus = exports.AuditOperation = void 0;
|
|
3
|
+
exports.ChangeType = exports.RollbackActionType = exports.MaskingStrategy = exports.RecordStrategy = exports.RecoveryStrategy = exports.TransactionStatus = exports.AuditOperation = exports.OperationType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 操作类型(设计文档标准命名)
|
|
6
|
+
*/
|
|
7
|
+
var OperationType;
|
|
8
|
+
(function (OperationType) {
|
|
9
|
+
OperationType["CREATE"] = "create";
|
|
10
|
+
OperationType["UPDATE"] = "update";
|
|
11
|
+
OperationType["DELETE"] = "delete";
|
|
12
|
+
})(OperationType || (exports.OperationType = OperationType = {}));
|
|
13
|
+
/**
|
|
14
|
+
* 审计操作类型(兼容性别名,映射到 OperationType)
|
|
15
|
+
* @deprecated 请使用 OperationType
|
|
16
|
+
*/
|
|
4
17
|
var AuditOperation;
|
|
5
18
|
(function (AuditOperation) {
|
|
6
19
|
AuditOperation["CREATE"] = "CREATE";
|
|
@@ -8,24 +21,36 @@ var AuditOperation;
|
|
|
8
21
|
AuditOperation["DELETE"] = "DELETE";
|
|
9
22
|
AuditOperation["RESTORE"] = "RESTORE";
|
|
10
23
|
})(AuditOperation || (exports.AuditOperation = AuditOperation = {}));
|
|
24
|
+
/**
|
|
25
|
+
* 事务状态(设计文档标准命名)
|
|
26
|
+
*/
|
|
11
27
|
var TransactionStatus;
|
|
12
28
|
(function (TransactionStatus) {
|
|
13
|
-
TransactionStatus["PENDING"] = "
|
|
14
|
-
TransactionStatus["COMMITTED"] = "
|
|
15
|
-
TransactionStatus["ROLLED_BACK"] = "
|
|
29
|
+
TransactionStatus["PENDING"] = "pending";
|
|
30
|
+
TransactionStatus["COMMITTED"] = "committed";
|
|
31
|
+
TransactionStatus["ROLLED_BACK"] = "rolled_back";
|
|
16
32
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
|
33
|
+
/**
|
|
34
|
+
* 恢复策略
|
|
35
|
+
*/
|
|
17
36
|
var RecoveryStrategy;
|
|
18
37
|
(function (RecoveryStrategy) {
|
|
19
38
|
RecoveryStrategy["ENTITY_ONLY"] = "ENTITY_ONLY";
|
|
20
39
|
RecoveryStrategy["TRANSACTION_RESTORE"] = "TRANSACTION_RESTORE";
|
|
21
40
|
RecoveryStrategy["DEPENDENCY_GRAPH"] = "DEPENDENCY_GRAPH";
|
|
22
41
|
})(RecoveryStrategy || (exports.RecoveryStrategy = RecoveryStrategy = {}));
|
|
42
|
+
/**
|
|
43
|
+
* 记录策略
|
|
44
|
+
*/
|
|
23
45
|
var RecordStrategy;
|
|
24
46
|
(function (RecordStrategy) {
|
|
25
47
|
RecordStrategy["FULL"] = "FULL";
|
|
26
48
|
RecordStrategy["DIFF_ONLY"] = "DIFF_ONLY";
|
|
27
49
|
RecordStrategy["DISABLED"] = "DISABLED";
|
|
28
50
|
})(RecordStrategy || (exports.RecordStrategy = RecordStrategy = {}));
|
|
51
|
+
/**
|
|
52
|
+
* 脱敏策略
|
|
53
|
+
*/
|
|
29
54
|
var MaskingStrategy;
|
|
30
55
|
(function (MaskingStrategy) {
|
|
31
56
|
MaskingStrategy["NONE"] = "NONE";
|
|
@@ -33,3 +58,21 @@ var MaskingStrategy;
|
|
|
33
58
|
MaskingStrategy["MASK"] = "MASK";
|
|
34
59
|
MaskingStrategy["PARTIAL"] = "PARTIAL";
|
|
35
60
|
})(MaskingStrategy || (exports.MaskingStrategy = MaskingStrategy = {}));
|
|
61
|
+
/**
|
|
62
|
+
* 回滚操作类型(设计文档标准命名)
|
|
63
|
+
*/
|
|
64
|
+
var RollbackActionType;
|
|
65
|
+
(function (RollbackActionType) {
|
|
66
|
+
RollbackActionType["ENTITY"] = "entity";
|
|
67
|
+
RollbackActionType["FILE"] = "file";
|
|
68
|
+
RollbackActionType["CUSTOM"] = "custom";
|
|
69
|
+
})(RollbackActionType || (exports.RollbackActionType = RollbackActionType = {}));
|
|
70
|
+
/**
|
|
71
|
+
* 变更类型(设计文档标准命名)
|
|
72
|
+
*/
|
|
73
|
+
var ChangeType;
|
|
74
|
+
(function (ChangeType) {
|
|
75
|
+
ChangeType["ADDED"] = "added";
|
|
76
|
+
ChangeType["REMOVED"] = "removed";
|
|
77
|
+
ChangeType["MODIFIED"] = "modified";
|
|
78
|
+
})(ChangeType || (exports.ChangeType = ChangeType = {}));
|
package/audit/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ export * from './entities';
|
|
|
2
2
|
export * from './enums';
|
|
3
3
|
export * from './interfaces';
|
|
4
4
|
export * from './dto';
|
|
5
|
-
export
|
|
5
|
+
export { AuditEntity, AuditField, getEntityAuditConfig, getFieldAuditConfig, getFieldLabel, getFieldValueLabel, ENTITY_AUDIT_OPTIONS, FIELD_AUDIT_OPTIONS, } from './decorators/entity-audit.decorator';
|
|
6
|
+
export { AuditController, AuditMethod, CONTROLLER_AUDIT_OPTIONS, METHOD_AUDIT_OPTIONS, } from './decorators/audit-controller.decorator';
|
|
7
|
+
export { AuditLog, getAuditOperationConfig, hasAuditOperation, AUDIT_OPERATION_OPTIONS, } from './decorators/audit-operation.decorator';
|
|
6
8
|
export * from './services';
|
|
7
9
|
export * from './subscribers';
|
|
8
10
|
export * from './interceptors';
|
package/audit/index.js
CHANGED
|
@@ -14,13 +14,42 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AUDIT_OPERATION_OPTIONS = exports.hasAuditOperation = exports.getAuditOperationConfig = exports.AuditLog = exports.METHOD_AUDIT_OPTIONS = exports.CONTROLLER_AUDIT_OPTIONS = exports.AuditMethod = exports.AuditController = exports.FIELD_AUDIT_OPTIONS = exports.ENTITY_AUDIT_OPTIONS = exports.getFieldValueLabel = exports.getFieldLabel = exports.getFieldAuditConfig = exports.getEntityAuditConfig = exports.AuditField = exports.AuditEntity = void 0;
|
|
18
|
+
// Entities
|
|
17
19
|
__exportStar(require("./entities"), exports);
|
|
20
|
+
// Enums
|
|
18
21
|
__exportStar(require("./enums"), exports);
|
|
22
|
+
// Interfaces
|
|
19
23
|
__exportStar(require("./interfaces"), exports);
|
|
24
|
+
// DTO
|
|
20
25
|
__exportStar(require("./dto"), exports);
|
|
21
|
-
|
|
26
|
+
// Decorators - explicit exports
|
|
27
|
+
var entity_audit_decorator_1 = require("./decorators/entity-audit.decorator");
|
|
28
|
+
Object.defineProperty(exports, "AuditEntity", { enumerable: true, get: function () { return entity_audit_decorator_1.AuditEntity; } });
|
|
29
|
+
Object.defineProperty(exports, "AuditField", { enumerable: true, get: function () { return entity_audit_decorator_1.AuditField; } });
|
|
30
|
+
Object.defineProperty(exports, "getEntityAuditConfig", { enumerable: true, get: function () { return entity_audit_decorator_1.getEntityAuditConfig; } });
|
|
31
|
+
Object.defineProperty(exports, "getFieldAuditConfig", { enumerable: true, get: function () { return entity_audit_decorator_1.getFieldAuditConfig; } });
|
|
32
|
+
Object.defineProperty(exports, "getFieldLabel", { enumerable: true, get: function () { return entity_audit_decorator_1.getFieldLabel; } });
|
|
33
|
+
Object.defineProperty(exports, "getFieldValueLabel", { enumerable: true, get: function () { return entity_audit_decorator_1.getFieldValueLabel; } });
|
|
34
|
+
Object.defineProperty(exports, "ENTITY_AUDIT_OPTIONS", { enumerable: true, get: function () { return entity_audit_decorator_1.ENTITY_AUDIT_OPTIONS; } });
|
|
35
|
+
Object.defineProperty(exports, "FIELD_AUDIT_OPTIONS", { enumerable: true, get: function () { return entity_audit_decorator_1.FIELD_AUDIT_OPTIONS; } });
|
|
36
|
+
var audit_controller_decorator_1 = require("./decorators/audit-controller.decorator");
|
|
37
|
+
Object.defineProperty(exports, "AuditController", { enumerable: true, get: function () { return audit_controller_decorator_1.AuditController; } });
|
|
38
|
+
Object.defineProperty(exports, "AuditMethod", { enumerable: true, get: function () { return audit_controller_decorator_1.AuditMethod; } });
|
|
39
|
+
Object.defineProperty(exports, "CONTROLLER_AUDIT_OPTIONS", { enumerable: true, get: function () { return audit_controller_decorator_1.CONTROLLER_AUDIT_OPTIONS; } });
|
|
40
|
+
Object.defineProperty(exports, "METHOD_AUDIT_OPTIONS", { enumerable: true, get: function () { return audit_controller_decorator_1.METHOD_AUDIT_OPTIONS; } });
|
|
41
|
+
var audit_operation_decorator_1 = require("./decorators/audit-operation.decorator");
|
|
42
|
+
Object.defineProperty(exports, "AuditLog", { enumerable: true, get: function () { return audit_operation_decorator_1.AuditLog; } });
|
|
43
|
+
Object.defineProperty(exports, "getAuditOperationConfig", { enumerable: true, get: function () { return audit_operation_decorator_1.getAuditOperationConfig; } });
|
|
44
|
+
Object.defineProperty(exports, "hasAuditOperation", { enumerable: true, get: function () { return audit_operation_decorator_1.hasAuditOperation; } });
|
|
45
|
+
Object.defineProperty(exports, "AUDIT_OPERATION_OPTIONS", { enumerable: true, get: function () { return audit_operation_decorator_1.AUDIT_OPERATION_OPTIONS; } });
|
|
46
|
+
// Services
|
|
22
47
|
__exportStar(require("./services"), exports);
|
|
48
|
+
// Subscribers
|
|
23
49
|
__exportStar(require("./subscribers"), exports);
|
|
50
|
+
// Interceptors
|
|
24
51
|
__exportStar(require("./interceptors"), exports);
|
|
52
|
+
// Controllers
|
|
25
53
|
__exportStar(require("./controllers"), exports);
|
|
54
|
+
// Module
|
|
26
55
|
__exportStar(require("./audit.module"), exports);
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { AuditContextService } from '../services/audit-context.service';
|
|
4
|
+
/**
|
|
5
|
+
* 审计拦截器
|
|
6
|
+
*/
|
|
4
7
|
export declare class AuditInterceptor implements NestInterceptor {
|
|
5
8
|
private readonly contextService;
|
|
6
9
|
constructor(contextService: AuditContextService);
|
|
7
10
|
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 设置请求上下文
|
|
13
|
+
*/
|
|
8
14
|
private setRequestContext;
|
|
15
|
+
/**
|
|
16
|
+
* 处理错误
|
|
17
|
+
*/
|
|
9
18
|
private handleError;
|
|
19
|
+
/**
|
|
20
|
+
* 检查是否启用了审计
|
|
21
|
+
*/
|
|
10
22
|
private isAuditEnabled;
|
|
23
|
+
/**
|
|
24
|
+
* 生成请求ID
|
|
25
|
+
*/
|
|
11
26
|
private generateRequestId;
|
|
12
27
|
}
|
|
@@ -24,6 +24,9 @@ const operators_1 = require("rxjs/operators");
|
|
|
24
24
|
const crypto_1 = require("crypto");
|
|
25
25
|
const audit_context_service_1 = require("../services/audit-context.service");
|
|
26
26
|
const decorators_1 = require("../decorators");
|
|
27
|
+
/**
|
|
28
|
+
* 审计拦截器
|
|
29
|
+
*/
|
|
27
30
|
let AuditInterceptor = class AuditInterceptor {
|
|
28
31
|
constructor(contextService) {
|
|
29
32
|
this.contextService = contextService;
|
|
@@ -32,16 +35,23 @@ let AuditInterceptor = class AuditInterceptor {
|
|
|
32
35
|
const request = context.switchToHttp().getRequest();
|
|
33
36
|
const handler = context.getHandler();
|
|
34
37
|
const controller = context.getClass();
|
|
38
|
+
// 检查是否启用了审计
|
|
35
39
|
if (!this.isAuditEnabled(controller, handler)) {
|
|
36
40
|
return next.handle();
|
|
37
41
|
}
|
|
42
|
+
// 设置请求上下文
|
|
38
43
|
this.setRequestContext(request);
|
|
39
44
|
return next.handle().pipe((0, operators_1.tap)(() => {
|
|
45
|
+
// 在响应后执行的操作
|
|
40
46
|
}), (0, operators_1.catchError)((error) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
// 处理错误情况
|
|
41
48
|
yield this.handleError(error, request);
|
|
42
49
|
throw error;
|
|
43
50
|
})));
|
|
44
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* 设置请求上下文
|
|
54
|
+
*/
|
|
45
55
|
setRequestContext(request) {
|
|
46
56
|
var _a, _b, _c;
|
|
47
57
|
const user = request.user || {};
|
|
@@ -55,8 +65,12 @@ let AuditInterceptor = class AuditInterceptor {
|
|
|
55
65
|
};
|
|
56
66
|
this.contextService.setContext(auditContext);
|
|
57
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* 处理错误
|
|
70
|
+
*/
|
|
58
71
|
handleError(error, request) {
|
|
59
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
// 记录错误信息到上下文
|
|
60
74
|
this.contextService.setContext({
|
|
61
75
|
metadata: {
|
|
62
76
|
error: {
|
|
@@ -68,12 +82,17 @@ let AuditInterceptor = class AuditInterceptor {
|
|
|
68
82
|
});
|
|
69
83
|
});
|
|
70
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* 检查是否启用了审计
|
|
87
|
+
*/
|
|
71
88
|
isAuditEnabled(controller, handler) {
|
|
72
89
|
try {
|
|
90
|
+
// 检查控制器级别设置
|
|
73
91
|
const controllerMetadata = Reflect.getMetadata(decorators_1.CONTROLLER_AUDIT_OPTIONS, controller);
|
|
74
92
|
if (controllerMetadata && controllerMetadata.enabled === false) {
|
|
75
93
|
return false;
|
|
76
94
|
}
|
|
95
|
+
// 检查方法级别设置
|
|
77
96
|
const handlerMetadata = Reflect.getMetadata(decorators_1.METHOD_AUDIT_OPTIONS, handler);
|
|
78
97
|
if (handlerMetadata && handlerMetadata.enabled === false) {
|
|
79
98
|
return false;
|
|
@@ -81,9 +100,12 @@ let AuditInterceptor = class AuditInterceptor {
|
|
|
81
100
|
return true;
|
|
82
101
|
}
|
|
83
102
|
catch (error) {
|
|
84
|
-
return true;
|
|
103
|
+
return true; // 默认启用
|
|
85
104
|
}
|
|
86
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* 生成请求ID
|
|
108
|
+
*/
|
|
87
109
|
generateRequestId() {
|
|
88
110
|
return (0, crypto_1.randomBytes)(16).toString('hex');
|
|
89
111
|
}
|