@nest-omni/core 3.1.2-8 → 3.1.2-9

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.
Files changed (91) hide show
  1. package/audit/audit.module.d.ts +10 -0
  2. package/audit/audit.module.js +254 -0
  3. package/audit/controllers/audit.controller.d.ts +20 -0
  4. package/audit/controllers/audit.controller.js +142 -0
  5. package/audit/controllers/index.d.ts +1 -0
  6. package/audit/controllers/index.js +17 -0
  7. package/audit/decorators/audit-controller.decorator.d.ts +5 -0
  8. package/audit/decorators/audit-controller.decorator.js +17 -0
  9. package/audit/decorators/audit-operation.decorator.d.ts +7 -0
  10. package/audit/decorators/audit-operation.decorator.js +25 -0
  11. package/audit/decorators/entity-audit.decorator.d.ts +10 -0
  12. package/audit/decorators/entity-audit.decorator.js +70 -0
  13. package/audit/decorators/index.d.ts +3 -0
  14. package/audit/decorators/index.js +19 -0
  15. package/audit/dto/audit-log-query.dto.d.ts +14 -0
  16. package/audit/dto/audit-log-query.dto.js +95 -0
  17. package/audit/dto/begin-transaction.dto.d.ts +3 -0
  18. package/audit/dto/begin-transaction.dto.js +22 -0
  19. package/audit/dto/compare-entities.dto.d.ts +6 -0
  20. package/audit/dto/compare-entities.dto.js +44 -0
  21. package/audit/dto/index.d.ts +5 -0
  22. package/audit/dto/index.js +21 -0
  23. package/audit/dto/pre-check-restore.dto.d.ts +5 -0
  24. package/audit/dto/pre-check-restore.dto.js +32 -0
  25. package/audit/dto/restore-entity.dto.d.ts +9 -0
  26. package/audit/dto/restore-entity.dto.js +53 -0
  27. package/audit/entities/entity-audit-log.entity.d.ts +23 -0
  28. package/audit/entities/entity-audit-log.entity.js +110 -0
  29. package/audit/entities/entity-transaction.entity.d.ts +21 -0
  30. package/audit/entities/entity-transaction.entity.js +80 -0
  31. package/audit/entities/index.d.ts +4 -0
  32. package/audit/entities/index.js +20 -0
  33. package/audit/entities/manual-operation-log.entity.d.ts +13 -0
  34. package/audit/entities/manual-operation-log.entity.js +65 -0
  35. package/audit/entities/operation-template.entity.d.ts +11 -0
  36. package/audit/entities/operation-template.entity.js +65 -0
  37. package/audit/enums/audit.enums.d.ts +42 -0
  38. package/audit/enums/audit.enums.js +53 -0
  39. package/audit/enums/index.d.ts +1 -0
  40. package/audit/enums/index.js +17 -0
  41. package/audit/index.d.ts +12 -0
  42. package/audit/index.js +48 -0
  43. package/audit/interceptors/audit.interceptor.d.ts +12 -0
  44. package/audit/interceptors/audit.interceptor.js +95 -0
  45. package/audit/interceptors/index.d.ts +1 -0
  46. package/audit/interceptors/index.js +17 -0
  47. package/audit/interfaces/audit.interfaces.d.ts +180 -0
  48. package/audit/interfaces/audit.interfaces.js +2 -0
  49. package/audit/interfaces/index.d.ts +1 -0
  50. package/audit/interfaces/index.js +17 -0
  51. package/audit/services/audit-context.service.d.ts +10 -0
  52. package/audit/services/audit-context.service.js +55 -0
  53. package/audit/services/audit-strategy.service.d.ts +19 -0
  54. package/audit/services/audit-strategy.service.js +89 -0
  55. package/audit/services/entity-audit.service.d.ts +65 -0
  56. package/audit/services/entity-audit.service.js +626 -0
  57. package/audit/services/index.d.ts +6 -0
  58. package/audit/services/index.js +22 -0
  59. package/audit/services/multi-database.service.d.ts +10 -0
  60. package/audit/services/multi-database.service.js +59 -0
  61. package/audit/services/operation-description.service.d.ts +21 -0
  62. package/audit/services/operation-description.service.js +213 -0
  63. package/audit/services/transaction-audit.service.d.ts +22 -0
  64. package/audit/services/transaction-audit.service.js +201 -0
  65. package/audit/subscribers/entity-audit.subscriber.d.ts +14 -0
  66. package/audit/subscribers/entity-audit.subscriber.js +136 -0
  67. package/audit/subscribers/index.d.ts +1 -0
  68. package/audit/subscribers/index.js +17 -0
  69. package/http-client/examples/advanced-usage.example.js +14 -1
  70. package/http-client/examples/auth-with-waiting-lock.example.d.ts +17 -0
  71. package/http-client/examples/auth-with-waiting-lock.example.js +336 -0
  72. package/http-client/examples/basic-usage.example.d.ts +1 -9
  73. package/http-client/examples/basic-usage.example.js +4 -14
  74. package/http-client/examples/multi-api-configuration.example.js +4 -4
  75. package/http-client/http-client.module.js +7 -4
  76. package/http-client/services/api-client-registry.service.d.ts +2 -1
  77. package/http-client/services/api-client-registry.service.js +2 -1
  78. package/http-client/services/http-client.service.d.ts +18 -1
  79. package/http-client/services/http-client.service.js +123 -3
  80. package/http-client/services/http-log-query.service.d.ts +20 -0
  81. package/http-client/services/http-log-query.service.js +176 -0
  82. package/http-client/services/http-replay.service.d.ts +58 -0
  83. package/http-client/services/http-replay.service.js +266 -0
  84. package/http-client/services/log-cleanup.service.js +2 -2
  85. package/http-client/services/logging.service.js +1 -1
  86. package/http-client/utils/request-id.util.d.ts +4 -0
  87. package/http-client/utils/request-id.util.js +34 -0
  88. package/index.d.ts +1 -0
  89. package/index.js +1 -0
  90. package/package.json +1 -1
  91. package/setup/bootstrap.setup.js +5 -1
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuditLogQueryDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ const enums_1 = require("../enums");
17
+ class AuditLogQueryDto {
18
+ constructor() {
19
+ this.page = 1;
20
+ this.limit = 20;
21
+ this.sortBy = 'createdAt';
22
+ this.sortOrder = 'DESC';
23
+ }
24
+ }
25
+ exports.AuditLogQueryDto = AuditLogQueryDto;
26
+ __decorate([
27
+ (0, swagger_1.ApiPropertyOptional)({ description: '页码', default: 1 }),
28
+ (0, class_validator_1.IsOptional)(),
29
+ (0, class_transformer_1.Type)(() => Number),
30
+ (0, class_validator_1.Min)(1),
31
+ __metadata("design:type", Number)
32
+ ], AuditLogQueryDto.prototype, "page", void 0);
33
+ __decorate([
34
+ (0, swagger_1.ApiPropertyOptional)({ description: '每页数量', default: 20 }),
35
+ (0, class_validator_1.IsOptional)(),
36
+ (0, class_transformer_1.Type)(() => Number),
37
+ (0, class_validator_1.Min)(1),
38
+ (0, class_validator_1.Max)(100),
39
+ __metadata("design:type", Number)
40
+ ], AuditLogQueryDto.prototype, "limit", void 0);
41
+ __decorate([
42
+ (0, swagger_1.ApiPropertyOptional)({ description: '实体类型' }),
43
+ (0, class_validator_1.IsOptional)(),
44
+ (0, class_validator_1.IsString)(),
45
+ __metadata("design:type", String)
46
+ ], AuditLogQueryDto.prototype, "entityType", void 0);
47
+ __decorate([
48
+ (0, swagger_1.ApiPropertyOptional)({ description: '实体ID' }),
49
+ (0, class_validator_1.IsOptional)(),
50
+ (0, class_validator_1.IsString)(),
51
+ __metadata("design:type", String)
52
+ ], AuditLogQueryDto.prototype, "entityId", void 0);
53
+ __decorate([
54
+ (0, swagger_1.ApiPropertyOptional)({ description: '操作类型', enum: enums_1.AuditOperation }),
55
+ (0, class_validator_1.IsOptional)(),
56
+ (0, class_validator_1.IsEnum)(enums_1.AuditOperation),
57
+ __metadata("design:type", String)
58
+ ], AuditLogQueryDto.prototype, "operation", void 0);
59
+ __decorate([
60
+ (0, swagger_1.ApiPropertyOptional)({ description: '用户ID' }),
61
+ (0, class_validator_1.IsOptional)(),
62
+ (0, class_validator_1.IsString)(),
63
+ __metadata("design:type", String)
64
+ ], AuditLogQueryDto.prototype, "userId", void 0);
65
+ __decorate([
66
+ (0, swagger_1.ApiPropertyOptional)({ description: '开始日期' }),
67
+ (0, class_validator_1.IsOptional)(),
68
+ (0, class_validator_1.IsDateString)(),
69
+ __metadata("design:type", String)
70
+ ], AuditLogQueryDto.prototype, "startDate", void 0);
71
+ __decorate([
72
+ (0, swagger_1.ApiPropertyOptional)({ description: '结束日期' }),
73
+ (0, class_validator_1.IsOptional)(),
74
+ (0, class_validator_1.IsDateString)(),
75
+ __metadata("design:type", String)
76
+ ], AuditLogQueryDto.prototype, "endDate", void 0);
77
+ __decorate([
78
+ (0, swagger_1.ApiPropertyOptional)({ description: '搜索关键词' }),
79
+ (0, class_validator_1.IsOptional)(),
80
+ (0, class_validator_1.IsString)(),
81
+ __metadata("design:type", String)
82
+ ], AuditLogQueryDto.prototype, "search", void 0);
83
+ __decorate([
84
+ (0, swagger_1.ApiPropertyOptional)({ description: '排序字段', default: 'createdAt' }),
85
+ (0, class_validator_1.IsOptional)(),
86
+ (0, class_validator_1.IsString)(),
87
+ __metadata("design:type", String)
88
+ ], AuditLogQueryDto.prototype, "sortBy", void 0);
89
+ __decorate([
90
+ (0, swagger_1.ApiPropertyOptional)({ description: '排序方向', default: 'DESC' }),
91
+ (0, class_validator_1.IsOptional)(),
92
+ (0, class_validator_1.IsString)(),
93
+ (0, class_validator_1.IsIn)(['ASC', 'DESC']),
94
+ __metadata("design:type", String)
95
+ ], AuditLogQueryDto.prototype, "sortOrder", void 0);
@@ -0,0 +1,3 @@
1
+ export declare class BeginTransactionDto {
2
+ description: string;
3
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BeginTransactionDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ class BeginTransactionDto {
16
+ }
17
+ exports.BeginTransactionDto = BeginTransactionDto;
18
+ __decorate([
19
+ (0, swagger_1.ApiProperty)({ description: '事务描述' }),
20
+ (0, class_validator_1.IsString)(),
21
+ __metadata("design:type", String)
22
+ ], BeginTransactionDto.prototype, "description", void 0);
@@ -0,0 +1,6 @@
1
+ export declare class CompareEntitiesDto {
2
+ entityType: string;
3
+ entityId: string;
4
+ fromVersion?: number;
5
+ toVersion?: number;
6
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CompareEntitiesDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ class CompareEntitiesDto {
17
+ }
18
+ exports.CompareEntitiesDto = CompareEntitiesDto;
19
+ __decorate([
20
+ (0, swagger_1.ApiProperty)({ description: '实体类型' }),
21
+ (0, class_validator_1.IsString)(),
22
+ __metadata("design:type", String)
23
+ ], CompareEntitiesDto.prototype, "entityType", void 0);
24
+ __decorate([
25
+ (0, swagger_1.ApiProperty)({ description: '实体ID' }),
26
+ (0, class_validator_1.IsString)(),
27
+ __metadata("design:type", String)
28
+ ], CompareEntitiesDto.prototype, "entityId", void 0);
29
+ __decorate([
30
+ (0, swagger_1.ApiPropertyOptional)({ description: '起始版本' }),
31
+ (0, class_validator_1.IsOptional)(),
32
+ (0, class_transformer_1.Type)(() => Number),
33
+ (0, class_validator_1.IsInt)(),
34
+ (0, class_validator_1.Min)(1),
35
+ __metadata("design:type", Number)
36
+ ], CompareEntitiesDto.prototype, "fromVersion", void 0);
37
+ __decorate([
38
+ (0, swagger_1.ApiPropertyOptional)({ description: '结束版本' }),
39
+ (0, class_validator_1.IsOptional)(),
40
+ (0, class_transformer_1.Type)(() => Number),
41
+ (0, class_validator_1.IsInt)(),
42
+ (0, class_validator_1.Min)(1),
43
+ __metadata("design:type", Number)
44
+ ], CompareEntitiesDto.prototype, "toVersion", void 0);
@@ -0,0 +1,5 @@
1
+ export * from './audit-log-query.dto';
2
+ export * from './compare-entities.dto';
3
+ export * from './restore-entity.dto';
4
+ export * from './pre-check-restore.dto';
5
+ export * from './begin-transaction.dto';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./audit-log-query.dto"), exports);
18
+ __exportStar(require("./compare-entities.dto"), exports);
19
+ __exportStar(require("./restore-entity.dto"), exports);
20
+ __exportStar(require("./pre-check-restore.dto"), exports);
21
+ __exportStar(require("./begin-transaction.dto"), exports);
@@ -0,0 +1,5 @@
1
+ export declare class PreCheckRestoreDto {
2
+ entityType: string;
3
+ entityId: string;
4
+ auditLogId: string;
5
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PreCheckRestoreDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ class PreCheckRestoreDto {
16
+ }
17
+ exports.PreCheckRestoreDto = PreCheckRestoreDto;
18
+ __decorate([
19
+ (0, swagger_1.ApiProperty)({ description: '实体类型' }),
20
+ (0, class_validator_1.IsString)(),
21
+ __metadata("design:type", String)
22
+ ], PreCheckRestoreDto.prototype, "entityType", void 0);
23
+ __decorate([
24
+ (0, swagger_1.ApiProperty)({ description: '实体ID' }),
25
+ (0, class_validator_1.IsString)(),
26
+ __metadata("design:type", String)
27
+ ], PreCheckRestoreDto.prototype, "entityId", void 0);
28
+ __decorate([
29
+ (0, swagger_1.ApiProperty)({ description: '审计日志ID' }),
30
+ (0, class_validator_1.IsString)(),
31
+ __metadata("design:type", String)
32
+ ], PreCheckRestoreDto.prototype, "auditLogId", void 0);
@@ -0,0 +1,9 @@
1
+ import { RecoveryStrategy } from '../enums';
2
+ import { RestoreOptions } from '../interfaces';
3
+ export declare class RestoreEntityDto {
4
+ entityType: string;
5
+ entityId: string;
6
+ auditLogId: string;
7
+ strategy?: RecoveryStrategy;
8
+ options?: RestoreOptions;
9
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RestoreEntityDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const enums_1 = require("../enums");
16
+ class RestoreEntityDto {
17
+ constructor() {
18
+ this.strategy = enums_1.RecoveryStrategy.ENTITY_ONLY;
19
+ this.options = {};
20
+ }
21
+ }
22
+ exports.RestoreEntityDto = RestoreEntityDto;
23
+ __decorate([
24
+ (0, swagger_1.ApiProperty)({ description: '实体类型' }),
25
+ (0, class_validator_1.IsString)(),
26
+ __metadata("design:type", String)
27
+ ], RestoreEntityDto.prototype, "entityType", void 0);
28
+ __decorate([
29
+ (0, swagger_1.ApiProperty)({ description: '实体ID' }),
30
+ (0, class_validator_1.IsString)(),
31
+ __metadata("design:type", String)
32
+ ], RestoreEntityDto.prototype, "entityId", void 0);
33
+ __decorate([
34
+ (0, swagger_1.ApiProperty)({ description: '审计日志ID' }),
35
+ (0, class_validator_1.IsString)(),
36
+ __metadata("design:type", String)
37
+ ], RestoreEntityDto.prototype, "auditLogId", void 0);
38
+ __decorate([
39
+ (0, swagger_1.ApiPropertyOptional)({
40
+ description: '恢复策略',
41
+ enum: enums_1.RecoveryStrategy,
42
+ default: enums_1.RecoveryStrategy.ENTITY_ONLY,
43
+ }),
44
+ (0, class_validator_1.IsOptional)(),
45
+ (0, class_validator_1.IsEnum)(enums_1.RecoveryStrategy),
46
+ __metadata("design:type", String)
47
+ ], RestoreEntityDto.prototype, "strategy", void 0);
48
+ __decorate([
49
+ (0, swagger_1.ApiPropertyOptional)({ description: '恢复选项' }),
50
+ (0, class_validator_1.IsOptional)(),
51
+ (0, class_validator_1.IsObject)(),
52
+ __metadata("design:type", Object)
53
+ ], RestoreEntityDto.prototype, "options", void 0);
@@ -0,0 +1,23 @@
1
+ import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
+ import { AuditOperation } from '../enums';
3
+ import { ChangeDetail, RollbackAction } from '../interfaces';
4
+ export declare class EntityAuditLogEntity extends AbstractUuidPrimaryEntity {
5
+ entityType: string;
6
+ entityId: string;
7
+ operation: AuditOperation;
8
+ oldValue: Record<string, any>;
9
+ newValue: Record<string, any>;
10
+ changedFields: string[];
11
+ changedFieldPaths: string;
12
+ userId: string;
13
+ username: string;
14
+ requestId: string;
15
+ requestIp: string;
16
+ userAgent: string;
17
+ description: string;
18
+ hashChain: Record<string, any>;
19
+ operationTemplateKey: string;
20
+ descriptionParams: Record<string, any>;
21
+ changeDetails: ChangeDetail[];
22
+ rollbackActions: RollbackAction[];
23
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntityAuditLogEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const abstract_entity_1 = require("../../common/abstract.entity");
15
+ const enums_1 = require("../enums");
16
+ let EntityAuditLogEntity = class EntityAuditLogEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
+ };
18
+ exports.EntityAuditLogEntity = EntityAuditLogEntity;
19
+ __decorate([
20
+ (0, typeorm_1.Column)({ comment: '实体类型' }),
21
+ __metadata("design:type", String)
22
+ ], EntityAuditLogEntity.prototype, "entityType", void 0);
23
+ __decorate([
24
+ (0, typeorm_1.Column)({ comment: '实体ID' }),
25
+ __metadata("design:type", String)
26
+ ], EntityAuditLogEntity.prototype, "entityId", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.Column)({ type: 'enum', enum: enums_1.AuditOperation, comment: '操作类型' }),
29
+ __metadata("design:type", String)
30
+ ], EntityAuditLogEntity.prototype, "operation", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '变更前的值' }),
33
+ __metadata("design:type", Object)
34
+ ], EntityAuditLogEntity.prototype, "oldValue", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '变更后的值' }),
37
+ __metadata("design:type", Object)
38
+ ], EntityAuditLogEntity.prototype, "newValue", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '变更的字段' }),
41
+ __metadata("design:type", Array)
42
+ ], EntityAuditLogEntity.prototype, "changedFields", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({ type: 'text', nullable: true, comment: '变更字段路径' }),
45
+ __metadata("design:type", String)
46
+ ], EntityAuditLogEntity.prototype, "changedFieldPaths", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户ID' }),
49
+ __metadata("design:type", String)
50
+ ], EntityAuditLogEntity.prototype, "userId", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户名' }),
53
+ __metadata("design:type", String)
54
+ ], EntityAuditLogEntity.prototype, "username", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ nullable: true, comment: '请求ID' }),
57
+ __metadata("design:type", String)
58
+ ], EntityAuditLogEntity.prototype, "requestId", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ nullable: true, comment: '请求IP' }),
61
+ __metadata("design:type", String)
62
+ ], EntityAuditLogEntity.prototype, "requestIp", void 0);
63
+ __decorate([
64
+ (0, typeorm_1.Column)({ type: 'text', nullable: true, comment: '用户代理' }),
65
+ __metadata("design:type", String)
66
+ ], EntityAuditLogEntity.prototype, "userAgent", void 0);
67
+ __decorate([
68
+ (0, typeorm_1.Column)({ type: 'text', nullable: true, comment: '操作描述' }),
69
+ __metadata("design:type", String)
70
+ ], EntityAuditLogEntity.prototype, "description", void 0);
71
+ __decorate([
72
+ (0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '哈希链' }),
73
+ __metadata("design:type", Object)
74
+ ], EntityAuditLogEntity.prototype, "hashChain", void 0);
75
+ __decorate([
76
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作模板键,用于动态生成描述' }),
77
+ __metadata("design:type", String)
78
+ ], EntityAuditLogEntity.prototype, "operationTemplateKey", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({
81
+ type: 'json',
82
+ nullable: true,
83
+ comment: '描述参数,用于填充模板占位符',
84
+ }),
85
+ __metadata("design:type", Object)
86
+ ], EntityAuditLogEntity.prototype, "descriptionParams", void 0);
87
+ __decorate([
88
+ (0, typeorm_1.Column)({
89
+ type: 'json',
90
+ nullable: true,
91
+ comment: '结构化变更详情列表(包含多语言支持)',
92
+ }),
93
+ __metadata("design:type", Array)
94
+ ], EntityAuditLogEntity.prototype, "changeDetails", void 0);
95
+ __decorate([
96
+ (0, typeorm_1.Column)({
97
+ type: 'json',
98
+ nullable: true,
99
+ comment: '回滚操作列表',
100
+ }),
101
+ __metadata("design:type", Array)
102
+ ], EntityAuditLogEntity.prototype, "rollbackActions", void 0);
103
+ exports.EntityAuditLogEntity = EntityAuditLogEntity = __decorate([
104
+ (0, typeorm_1.Entity)('entity_audit_log'),
105
+ (0, typeorm_1.Index)('idx_entity_relation', ['entityType', 'entityId']),
106
+ (0, typeorm_1.Index)('idx_operation', ['operation']),
107
+ (0, typeorm_1.Index)('idx_user', ['userId']),
108
+ (0, typeorm_1.Index)('idx_created_at', ['createdAt']),
109
+ (0, typeorm_1.Index)('idx_template_key', ['operationTemplateKey'])
110
+ ], EntityAuditLogEntity);
@@ -0,0 +1,21 @@
1
+ import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
+ import { AuditOperation, TransactionStatus } from '../enums';
3
+ import { ManualOperationLogEntity } from './manual-operation-log.entity';
4
+ export declare class EntityTransactionEntity extends AbstractUuidPrimaryEntity {
5
+ description: string;
6
+ status: TransactionStatus;
7
+ entities: Array<{
8
+ entityType: string;
9
+ entityId: string;
10
+ operation: AuditOperation;
11
+ }>;
12
+ userId: string;
13
+ username: string;
14
+ dependencyGraph: Record<string, any>;
15
+ operationTemplateKey: string;
16
+ descriptionParams: Record<string, any>;
17
+ requestIp: string;
18
+ metadata: Record<string, any>;
19
+ completedAt: Date;
20
+ manualOperations: ManualOperationLogEntity[];
21
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntityTransactionEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const abstract_entity_1 = require("../../common/abstract.entity");
15
+ const enums_1 = require("../enums");
16
+ let EntityTransactionEntity = class EntityTransactionEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
+ };
18
+ exports.EntityTransactionEntity = EntityTransactionEntity;
19
+ __decorate([
20
+ (0, typeorm_1.Column)({ comment: '事务描述' }),
21
+ __metadata("design:type", String)
22
+ ], EntityTransactionEntity.prototype, "description", void 0);
23
+ __decorate([
24
+ (0, typeorm_1.Column)({ type: 'enum', enum: enums_1.TransactionStatus, comment: '事务状态' }),
25
+ __metadata("design:type", String)
26
+ ], EntityTransactionEntity.prototype, "status", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.Column)({
29
+ type: 'json',
30
+ comment: '涉及的实体',
31
+ }),
32
+ __metadata("design:type", Array)
33
+ ], EntityTransactionEntity.prototype, "entities", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户ID' }),
36
+ __metadata("design:type", String)
37
+ ], EntityTransactionEntity.prototype, "userId", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户名' }),
40
+ __metadata("design:type", String)
41
+ ], EntityTransactionEntity.prototype, "username", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '依赖图' }),
44
+ __metadata("design:type", Object)
45
+ ], EntityTransactionEntity.prototype, "dependencyGraph", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作模板键(事务级别)' }),
48
+ __metadata("design:type", String)
49
+ ], EntityTransactionEntity.prototype, "operationTemplateKey", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.Column)({
52
+ type: 'json',
53
+ nullable: true,
54
+ comment: '描述参数,用于填充事务级别的模板占位符',
55
+ }),
56
+ __metadata("design:type", Object)
57
+ ], EntityTransactionEntity.prototype, "descriptionParams", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.Column)({ nullable: true, comment: '请求IP' }),
60
+ __metadata("design:type", String)
61
+ ], EntityTransactionEntity.prototype, "requestIp", void 0);
62
+ __decorate([
63
+ (0, typeorm_1.Column)({ type: 'json', nullable: true, comment: '事务元数据' }),
64
+ __metadata("design:type", Object)
65
+ ], EntityTransactionEntity.prototype, "metadata", void 0);
66
+ __decorate([
67
+ (0, typeorm_1.Column)({ type: 'timestamp', nullable: true, comment: '完成时间' }),
68
+ __metadata("design:type", Date)
69
+ ], EntityTransactionEntity.prototype, "completedAt", void 0);
70
+ __decorate([
71
+ (0, typeorm_1.OneToMany)('ManualOperationLogEntity', (log) => log.transaction),
72
+ __metadata("design:type", Array)
73
+ ], EntityTransactionEntity.prototype, "manualOperations", void 0);
74
+ exports.EntityTransactionEntity = EntityTransactionEntity = __decorate([
75
+ (0, typeorm_1.Entity)('entity_transaction'),
76
+ (0, typeorm_1.Index)('idx_status', ['status']),
77
+ (0, typeorm_1.Index)('idx_user', ['userId']),
78
+ (0, typeorm_1.Index)('idx_created_at', ['createdAt']),
79
+ (0, typeorm_1.Index)('idx_template_key', ['operationTemplateKey'])
80
+ ], EntityTransactionEntity);
@@ -0,0 +1,4 @@
1
+ export * from './entity-audit-log.entity';
2
+ export * from './entity-transaction.entity';
3
+ export * from './operation-template.entity';
4
+ export * from './manual-operation-log.entity';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./entity-audit-log.entity"), exports);
18
+ __exportStar(require("./entity-transaction.entity"), exports);
19
+ __exportStar(require("./operation-template.entity"), exports);
20
+ __exportStar(require("./manual-operation-log.entity"), exports);
@@ -0,0 +1,13 @@
1
+ import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
+ import { EntityTransactionEntity } from './entity-transaction.entity';
3
+ import { RollbackAction } from '../interfaces';
4
+ export declare class ManualOperationLogEntity extends AbstractUuidPrimaryEntity {
5
+ transactionId: string;
6
+ operationTemplateKey: string;
7
+ descriptionParams: Record<string, any>;
8
+ userId: string;
9
+ username: string;
10
+ requestIp: string;
11
+ rollbackActions: RollbackAction[];
12
+ transaction: EntityTransactionEntity;
13
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ManualOperationLogEntity = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const abstract_entity_1 = require("../../common/abstract.entity");
15
+ const entity_transaction_entity_1 = require("./entity-transaction.entity");
16
+ let ManualOperationLogEntity = class ManualOperationLogEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
+ };
18
+ exports.ManualOperationLogEntity = ManualOperationLogEntity;
19
+ __decorate([
20
+ (0, typeorm_1.Column)({ comment: '关联的事务ID' }),
21
+ __metadata("design:type", String)
22
+ ], ManualOperationLogEntity.prototype, "transactionId", void 0);
23
+ __decorate([
24
+ (0, typeorm_1.Column)({ comment: '操作模板键' }),
25
+ __metadata("design:type", String)
26
+ ], ManualOperationLogEntity.prototype, "operationTemplateKey", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.Column)({
29
+ type: 'json',
30
+ comment: '描述参数,用于填充模板占位符',
31
+ }),
32
+ __metadata("design:type", Object)
33
+ ], ManualOperationLogEntity.prototype, "descriptionParams", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户ID' }),
36
+ __metadata("design:type", String)
37
+ ], ManualOperationLogEntity.prototype, "userId", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户名' }),
40
+ __metadata("design:type", String)
41
+ ], ManualOperationLogEntity.prototype, "username", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作IP' }),
44
+ __metadata("design:type", String)
45
+ ], ManualOperationLogEntity.prototype, "requestIp", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)({
48
+ type: 'json',
49
+ nullable: true,
50
+ comment: '回滚操作列表',
51
+ }),
52
+ __metadata("design:type", Array)
53
+ ], ManualOperationLogEntity.prototype, "rollbackActions", void 0);
54
+ __decorate([
55
+ (0, typeorm_1.ManyToOne)('EntityTransactionEntity', { onDelete: 'CASCADE' }),
56
+ (0, typeorm_1.JoinColumn)({ name: 'transactionId' }),
57
+ __metadata("design:type", entity_transaction_entity_1.EntityTransactionEntity)
58
+ ], ManualOperationLogEntity.prototype, "transaction", void 0);
59
+ exports.ManualOperationLogEntity = ManualOperationLogEntity = __decorate([
60
+ (0, typeorm_1.Entity)('manual_operation_log'),
61
+ (0, typeorm_1.Index)('idx_transaction', ['transactionId']),
62
+ (0, typeorm_1.Index)('idx_template_key', ['operationTemplateKey']),
63
+ (0, typeorm_1.Index)('idx_user', ['userId']),
64
+ (0, typeorm_1.Index)('idx_created_at', ['createdAt'])
65
+ ], ManualOperationLogEntity);