@nest-omni/core 3.1.2-8 → 4.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 (94) hide show
  1. package/audit/audit.module.d.ts +10 -0
  2. package/audit/audit.module.js +231 -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 +5 -0
  10. package/audit/decorators/audit-operation.decorator.js +23 -0
  11. package/audit/decorators/entity-audit.decorator.d.ts +5 -0
  12. package/audit/decorators/entity-audit.decorator.js +19 -0
  13. package/audit/decorators/index.d.ts +2 -0
  14. package/audit/decorators/index.js +18 -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 +18 -0
  28. package/audit/entities/entity-audit-log.entity.js +81 -0
  29. package/audit/entities/entity-transaction.entity.d.ts +14 -0
  30. package/audit/entities/entity-transaction.entity.js +51 -0
  31. package/audit/entities/index.d.ts +2 -0
  32. package/audit/entities/index.js +18 -0
  33. package/audit/entities/manual-operation-log.entity.d.ts +15 -0
  34. package/audit/entities/manual-operation-log.entity.js +82 -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 +27 -0
  38. package/audit/enums/audit.enums.js +35 -0
  39. package/audit/enums/index.d.ts +1 -0
  40. package/audit/enums/index.js +17 -0
  41. package/audit/index.d.ts +10 -0
  42. package/audit/index.js +26 -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 +119 -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 +37 -0
  56. package/audit/services/entity-audit.service.js +484 -0
  57. package/audit/services/index.d.ts +5 -0
  58. package/audit/services/index.js +21 -0
  59. package/audit/services/manual-audit-log.service.d.ts +29 -0
  60. package/audit/services/manual-audit-log.service.js +184 -0
  61. package/audit/services/multi-database.service.d.ts +10 -0
  62. package/audit/services/multi-database.service.js +59 -0
  63. package/audit/services/operation-description.service.d.ts +21 -0
  64. package/audit/services/operation-description.service.js +213 -0
  65. package/audit/services/transaction-audit.service.d.ts +22 -0
  66. package/audit/services/transaction-audit.service.js +201 -0
  67. package/audit/subscribers/entity-audit.subscriber.d.ts +14 -0
  68. package/audit/subscribers/entity-audit.subscriber.js +136 -0
  69. package/audit/subscribers/index.d.ts +1 -0
  70. package/audit/subscribers/index.js +17 -0
  71. package/common/abstract.entity.js +1 -1
  72. package/http-client/examples/advanced-usage.example.js +14 -1
  73. package/http-client/examples/auth-with-waiting-lock.example.d.ts +17 -0
  74. package/http-client/examples/auth-with-waiting-lock.example.js +336 -0
  75. package/http-client/examples/basic-usage.example.d.ts +1 -9
  76. package/http-client/examples/basic-usage.example.js +4 -14
  77. package/http-client/examples/multi-api-configuration.example.js +4 -4
  78. package/http-client/http-client.module.js +7 -4
  79. package/http-client/services/api-client-registry.service.d.ts +2 -1
  80. package/http-client/services/api-client-registry.service.js +2 -1
  81. package/http-client/services/http-client.service.d.ts +18 -1
  82. package/http-client/services/http-client.service.js +123 -3
  83. package/http-client/services/http-log-query.service.d.ts +20 -0
  84. package/http-client/services/http-log-query.service.js +176 -0
  85. package/http-client/services/http-replay.service.d.ts +58 -0
  86. package/http-client/services/http-replay.service.js +266 -0
  87. package/http-client/services/log-cleanup.service.js +2 -2
  88. package/http-client/services/logging.service.js +1 -1
  89. package/http-client/utils/request-id.util.d.ts +4 -0
  90. package/http-client/utils/request-id.util.js +34 -0
  91. package/index.d.ts +1 -0
  92. package/index.js +1 -0
  93. package/package.json +1 -1
  94. package/setup/bootstrap.setup.js +5 -1
@@ -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,18 @@
1
+ import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
+ import { AuditOperation } from '../enums';
3
+ export declare class EntityAuditLogEntity extends AbstractUuidPrimaryEntity {
4
+ entityType: string;
5
+ entityId: string;
6
+ operation: AuditOperation;
7
+ oldValue: Record<string, any>;
8
+ newValue: Record<string, any>;
9
+ changedFields: string[];
10
+ changedFieldPaths: string;
11
+ userId: string;
12
+ username: string;
13
+ requestId: string;
14
+ requestIp: string;
15
+ userAgent: string;
16
+ description: string;
17
+ hashChain: Record<string, any>;
18
+ }
@@ -0,0 +1,81 @@
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
+ exports.EntityAuditLogEntity = EntityAuditLogEntity = __decorate([
76
+ (0, typeorm_1.Entity)('entity_audit_log'),
77
+ (0, typeorm_1.Index)('idx_entity_relation', ['entityType', 'entityId']),
78
+ (0, typeorm_1.Index)('idx_operation', ['operation']),
79
+ (0, typeorm_1.Index)('idx_user', ['userId']),
80
+ (0, typeorm_1.Index)('idx_created_at', ['createdAt'])
81
+ ], EntityAuditLogEntity);
@@ -0,0 +1,14 @@
1
+ import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
+ import { AuditOperation, TransactionStatus } from '../enums';
3
+ export declare class EntityTransactionEntity extends AbstractUuidPrimaryEntity {
4
+ description: string;
5
+ status: TransactionStatus;
6
+ entities: Array<{
7
+ entityType: string;
8
+ entityId: string;
9
+ operation: AuditOperation;
10
+ }>;
11
+ userId: string;
12
+ username: string;
13
+ dependencyGraph: Record<string, any>;
14
+ }
@@ -0,0 +1,51 @@
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
+ exports.EntityTransactionEntity = EntityTransactionEntity = __decorate([
47
+ (0, typeorm_1.Entity)('entity_transaction'),
48
+ (0, typeorm_1.Index)('idx_status', ['status']),
49
+ (0, typeorm_1.Index)('idx_user', ['userId']),
50
+ (0, typeorm_1.Index)('idx_created_at', ['createdAt'])
51
+ ], EntityTransactionEntity);
@@ -0,0 +1,2 @@
1
+ export * from './entity-audit-log.entity';
2
+ export * from './entity-transaction.entity';
@@ -0,0 +1,18 @@
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);
@@ -0,0 +1,15 @@
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
+ directDescription: string | Record<string, string>;
9
+ inlineTemplate: Record<string, string>;
10
+ userId: string;
11
+ username: string;
12
+ requestIp: string;
13
+ rollbackActions: RollbackAction[];
14
+ transaction: EntityTransactionEntity;
15
+ }
@@ -0,0 +1,82 @@
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)({ nullable: true, comment: '关联的事务ID' }),
21
+ __metadata("design:type", String)
22
+ ], ManualOperationLogEntity.prototype, "transactionId", void 0);
23
+ __decorate([
24
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作模板键(模板键模式)' }),
25
+ __metadata("design:type", String)
26
+ ], ManualOperationLogEntity.prototype, "operationTemplateKey", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.Column)({
29
+ type: 'json',
30
+ nullable: true,
31
+ comment: '描述参数,用于填充模板占位符',
32
+ }),
33
+ __metadata("design:type", Object)
34
+ ], ManualOperationLogEntity.prototype, "descriptionParams", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)({
37
+ type: 'json',
38
+ nullable: true,
39
+ comment: '直接描述(直接描述模式),可以是字符串或多语言对象',
40
+ }),
41
+ __metadata("design:type", Object)
42
+ ], ManualOperationLogEntity.prototype, "directDescription", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({
45
+ type: 'json',
46
+ nullable: true,
47
+ comment: '内联模板(内联模板模式),多语言模板对象',
48
+ }),
49
+ __metadata("design:type", Object)
50
+ ], ManualOperationLogEntity.prototype, "inlineTemplate", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户ID' }),
53
+ __metadata("design:type", String)
54
+ ], ManualOperationLogEntity.prototype, "userId", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作用户名' }),
57
+ __metadata("design:type", String)
58
+ ], ManualOperationLogEntity.prototype, "username", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({ nullable: true, comment: '操作IP' }),
61
+ __metadata("design:type", String)
62
+ ], ManualOperationLogEntity.prototype, "requestIp", void 0);
63
+ __decorate([
64
+ (0, typeorm_1.Column)({
65
+ type: 'json',
66
+ nullable: true,
67
+ comment: '回滚操作列表',
68
+ }),
69
+ __metadata("design:type", Array)
70
+ ], ManualOperationLogEntity.prototype, "rollbackActions", void 0);
71
+ __decorate([
72
+ (0, typeorm_1.ManyToOne)('EntityTransactionEntity', { onDelete: 'CASCADE' }),
73
+ (0, typeorm_1.JoinColumn)({ name: 'transactionId' }),
74
+ __metadata("design:type", entity_transaction_entity_1.EntityTransactionEntity)
75
+ ], ManualOperationLogEntity.prototype, "transaction", void 0);
76
+ exports.ManualOperationLogEntity = ManualOperationLogEntity = __decorate([
77
+ (0, typeorm_1.Entity)('manual_operation_log'),
78
+ (0, typeorm_1.Index)('idx_transaction', ['transactionId']),
79
+ (0, typeorm_1.Index)('idx_template_key', ['operationTemplateKey']),
80
+ (0, typeorm_1.Index)('idx_user', ['userId']),
81
+ (0, typeorm_1.Index)('idx_created_at', ['createdAt'])
82
+ ], ManualOperationLogEntity);
@@ -0,0 +1,11 @@
1
+ import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
+ import { AuditOperation } from '../enums';
3
+ export declare class OperationTemplateEntity extends AbstractUuidPrimaryEntity {
4
+ key: string;
5
+ entityName: string;
6
+ operation: AuditOperation;
7
+ nameTemplates: Record<string, string>;
8
+ descriptionTemplates: Record<string, string>;
9
+ fieldLabels: Record<string, Record<string, string>>;
10
+ valueDisplays: Record<string, Record<string, Record<string, string>>>;
11
+ }
@@ -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.OperationTemplateEntity = 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 OperationTemplateEntity = class OperationTemplateEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
+ };
18
+ exports.OperationTemplateEntity = OperationTemplateEntity;
19
+ __decorate([
20
+ (0, typeorm_1.Column)({ unique: true, comment: '模板键,唯一标识' }),
21
+ __metadata("design:type", String)
22
+ ], OperationTemplateEntity.prototype, "key", void 0);
23
+ __decorate([
24
+ (0, typeorm_1.Column)({ comment: '实体类名,* 表示通用模板' }),
25
+ __metadata("design:type", String)
26
+ ], OperationTemplateEntity.prototype, "entityName", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.Column)({ type: 'enum', enum: enums_1.AuditOperation, comment: '操作类型' }),
29
+ __metadata("design:type", String)
30
+ ], OperationTemplateEntity.prototype, "operation", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.Column)({
33
+ type: 'json',
34
+ comment: '多语言操作名称模板 { zh: "创建用户", en: "Create User" }',
35
+ }),
36
+ __metadata("design:type", Object)
37
+ ], OperationTemplateEntity.prototype, "nameTemplates", void 0);
38
+ __decorate([
39
+ (0, typeorm_1.Column)({
40
+ type: 'json',
41
+ comment: '多语言操作描述模板 { zh: "创建了用户 {name}", en: "Created user {name}" }',
42
+ }),
43
+ __metadata("design:type", Object)
44
+ ], OperationTemplateEntity.prototype, "descriptionTemplates", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.Column)({
47
+ type: 'json',
48
+ nullable: true,
49
+ comment: '字段标签映射 { name: { zh: "姓名", en: "Name" } }',
50
+ }),
51
+ __metadata("design:type", Object)
52
+ ], OperationTemplateEntity.prototype, "fieldLabels", void 0);
53
+ __decorate([
54
+ (0, typeorm_1.Column)({
55
+ type: 'json',
56
+ nullable: true,
57
+ comment: '值显示映射 { status: { active: { zh: "激活", en: "Active" } } }',
58
+ }),
59
+ __metadata("design:type", Object)
60
+ ], OperationTemplateEntity.prototype, "valueDisplays", void 0);
61
+ exports.OperationTemplateEntity = OperationTemplateEntity = __decorate([
62
+ (0, typeorm_1.Entity)('operation_template'),
63
+ (0, typeorm_1.Index)('idx_template_key', ['key'], { unique: true }),
64
+ (0, typeorm_1.Index)('idx_entity_operation', ['entityName', 'operation'])
65
+ ], OperationTemplateEntity);
@@ -0,0 +1,27 @@
1
+ export declare enum AuditOperation {
2
+ CREATE = "CREATE",
3
+ UPDATE = "UPDATE",
4
+ DELETE = "DELETE",
5
+ RESTORE = "RESTORE"
6
+ }
7
+ export declare enum TransactionStatus {
8
+ PENDING = "PENDING",
9
+ COMMITTED = "COMMITTED",
10
+ ROLLED_BACK = "ROLLED_BACK"
11
+ }
12
+ export declare enum RecoveryStrategy {
13
+ ENTITY_ONLY = "ENTITY_ONLY",
14
+ TRANSACTION_RESTORE = "TRANSACTION_RESTORE",
15
+ DEPENDENCY_GRAPH = "DEPENDENCY_GRAPH"
16
+ }
17
+ export declare enum RecordStrategy {
18
+ FULL = "FULL",
19
+ DIFF_ONLY = "DIFF_ONLY",
20
+ DISABLED = "DISABLED"
21
+ }
22
+ export declare enum MaskingStrategy {
23
+ NONE = "NONE",
24
+ HASH = "HASH",
25
+ MASK = "MASK",
26
+ PARTIAL = "PARTIAL"
27
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MaskingStrategy = exports.RecordStrategy = exports.RecoveryStrategy = exports.TransactionStatus = exports.AuditOperation = void 0;
4
+ var AuditOperation;
5
+ (function (AuditOperation) {
6
+ AuditOperation["CREATE"] = "CREATE";
7
+ AuditOperation["UPDATE"] = "UPDATE";
8
+ AuditOperation["DELETE"] = "DELETE";
9
+ AuditOperation["RESTORE"] = "RESTORE";
10
+ })(AuditOperation || (exports.AuditOperation = AuditOperation = {}));
11
+ var TransactionStatus;
12
+ (function (TransactionStatus) {
13
+ TransactionStatus["PENDING"] = "PENDING";
14
+ TransactionStatus["COMMITTED"] = "COMMITTED";
15
+ TransactionStatus["ROLLED_BACK"] = "ROLLED_BACK";
16
+ })(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
17
+ var RecoveryStrategy;
18
+ (function (RecoveryStrategy) {
19
+ RecoveryStrategy["ENTITY_ONLY"] = "ENTITY_ONLY";
20
+ RecoveryStrategy["TRANSACTION_RESTORE"] = "TRANSACTION_RESTORE";
21
+ RecoveryStrategy["DEPENDENCY_GRAPH"] = "DEPENDENCY_GRAPH";
22
+ })(RecoveryStrategy || (exports.RecoveryStrategy = RecoveryStrategy = {}));
23
+ var RecordStrategy;
24
+ (function (RecordStrategy) {
25
+ RecordStrategy["FULL"] = "FULL";
26
+ RecordStrategy["DIFF_ONLY"] = "DIFF_ONLY";
27
+ RecordStrategy["DISABLED"] = "DISABLED";
28
+ })(RecordStrategy || (exports.RecordStrategy = RecordStrategy = {}));
29
+ var MaskingStrategy;
30
+ (function (MaskingStrategy) {
31
+ MaskingStrategy["NONE"] = "NONE";
32
+ MaskingStrategy["HASH"] = "HASH";
33
+ MaskingStrategy["MASK"] = "MASK";
34
+ MaskingStrategy["PARTIAL"] = "PARTIAL";
35
+ })(MaskingStrategy || (exports.MaskingStrategy = MaskingStrategy = {}));
@@ -0,0 +1 @@
1
+ export * from './audit.enums';