@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,10 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { AuditConfig } from './interfaces';
3
+ export declare class AuditModule {
4
+ static forRoot(config?: AuditConfig): DynamicModule;
5
+ static forRootAsync(options: {
6
+ imports?: any[];
7
+ inject?: any[];
8
+ useFactory: (...args: any[]) => Promise<AuditConfig> | AuditConfig;
9
+ }): DynamicModule;
10
+ }
@@ -0,0 +1,231 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ var AuditModule_1;
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.AuditModule = void 0;
20
+ const common_1 = require("@nestjs/common");
21
+ const typeorm_1 = require("@nestjs/typeorm");
22
+ const nestjs_cls_1 = require("nestjs-cls");
23
+ const entities_1 = require("./entities");
24
+ const services_1 = require("./services");
25
+ const subscribers_1 = require("./subscribers");
26
+ const interceptors_1 = require("./interceptors");
27
+ const controllers_1 = require("./controllers");
28
+ let AuditModule = AuditModule_1 = class AuditModule {
29
+ static forRoot(config) {
30
+ var _a, _b;
31
+ const auditConnectionName = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.audit) || 'default';
32
+ const monitoredConnections = ((_b = config === null || config === void 0 ? void 0 : config.connections) === null || _b === void 0 ? void 0 : _b.monitored) || ['default'];
33
+ const subscriberProviders = monitoredConnections.map((connectionName) => ({
34
+ provide: `AUDIT_SUBSCRIBER_${connectionName}`,
35
+ useFactory: (auditService, contextService, auditStrategy, dataSource) => {
36
+ const subscriber = new subscribers_1.EntityAuditSubscriber(auditService, contextService, auditStrategy, dataSource);
37
+ return subscriber;
38
+ },
39
+ inject: [
40
+ services_1.EntityAuditService,
41
+ services_1.AuditContextService,
42
+ services_1.DefaultAuditStrategy,
43
+ (0, typeorm_1.getDataSourceToken)(connectionName),
44
+ ],
45
+ }));
46
+ const repositoryProviders = [
47
+ {
48
+ provide: (0, typeorm_1.getRepositoryToken)(entities_1.EntityAuditLogEntity),
49
+ useFactory: (dataSource) => {
50
+ return dataSource.getRepository(entities_1.EntityAuditLogEntity);
51
+ },
52
+ inject: [(0, typeorm_1.getDataSourceToken)(auditConnectionName)],
53
+ },
54
+ {
55
+ provide: (0, typeorm_1.getRepositoryToken)(entities_1.EntityTransactionEntity),
56
+ useFactory: (dataSource) => {
57
+ return dataSource.getRepository(entities_1.EntityTransactionEntity);
58
+ },
59
+ inject: [(0, typeorm_1.getDataSourceToken)(auditConnectionName)],
60
+ },
61
+ {
62
+ provide: 'AUDIT_ENTITY_MANAGER',
63
+ useFactory: (dataSource) => {
64
+ return dataSource.manager;
65
+ },
66
+ inject: [(0, typeorm_1.getDataSourceToken)(auditConnectionName)],
67
+ },
68
+ ];
69
+ return {
70
+ module: AuditModule_1,
71
+ imports: [
72
+ typeorm_1.TypeOrmModule.forFeature([entities_1.EntityAuditLogEntity, entities_1.EntityTransactionEntity], auditConnectionName),
73
+ nestjs_cls_1.ClsModule.forRoot({
74
+ global: true,
75
+ middleware: { mount: true },
76
+ }),
77
+ ],
78
+ controllers: [controllers_1.AuditController],
79
+ providers: [
80
+ {
81
+ provide: 'AUDIT_CONFIG',
82
+ useValue: config || {},
83
+ },
84
+ {
85
+ provide: 'AUDIT_STRATEGY',
86
+ useClass: services_1.DefaultAuditStrategy,
87
+ },
88
+ {
89
+ provide: 'AUDIT_CONNECTION_NAME',
90
+ useValue: auditConnectionName,
91
+ },
92
+ services_1.AuditContextService,
93
+ services_1.DefaultAuditStrategy,
94
+ services_1.MultiDatabaseService,
95
+ ...repositoryProviders,
96
+ services_1.EntityAuditService,
97
+ services_1.TransactionAuditService,
98
+ interceptors_1.AuditInterceptor,
99
+ ...subscriberProviders,
100
+ ],
101
+ exports: [
102
+ services_1.AuditContextService,
103
+ services_1.DefaultAuditStrategy,
104
+ services_1.MultiDatabaseService,
105
+ services_1.EntityAuditService,
106
+ services_1.TransactionAuditService,
107
+ interceptors_1.AuditInterceptor,
108
+ ],
109
+ };
110
+ }
111
+ static forRootAsync(options) {
112
+ const repositoryProviders = [
113
+ {
114
+ provide: (0, typeorm_1.getRepositoryToken)(entities_1.EntityAuditLogEntity),
115
+ useFactory: (dataSource, ...args) => __awaiter(this, void 0, void 0, function* () {
116
+ var _a;
117
+ const config = yield options.useFactory(...args);
118
+ const auditConnectionName = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.audit) || 'default';
119
+ return dataSource.getRepository(entities_1.EntityAuditLogEntity);
120
+ }),
121
+ inject: [
122
+ {
123
+ token: (0, typeorm_1.getDataSourceToken)(),
124
+ optional: false,
125
+ },
126
+ ...(options.inject || []),
127
+ ],
128
+ },
129
+ {
130
+ provide: (0, typeorm_1.getRepositoryToken)(entities_1.EntityTransactionEntity),
131
+ useFactory: (dataSource, ...args) => __awaiter(this, void 0, void 0, function* () {
132
+ var _a;
133
+ const config = yield options.useFactory(...args);
134
+ const auditConnectionName = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.audit) || 'default';
135
+ return dataSource.getRepository(entities_1.EntityTransactionEntity);
136
+ }),
137
+ inject: [
138
+ {
139
+ token: (0, typeorm_1.getDataSourceToken)(),
140
+ optional: false,
141
+ },
142
+ ...(options.inject || []),
143
+ ],
144
+ },
145
+ {
146
+ provide: 'AUDIT_ENTITY_MANAGER',
147
+ useFactory: (dataSource, ...args) => __awaiter(this, void 0, void 0, function* () {
148
+ var _a;
149
+ const config = yield options.useFactory(...args);
150
+ const auditConnectionName = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.audit) || 'default';
151
+ return dataSource.manager;
152
+ }),
153
+ inject: [
154
+ {
155
+ token: (0, typeorm_1.getDataSourceToken)(),
156
+ optional: false,
157
+ },
158
+ ...(options.inject || []),
159
+ ],
160
+ },
161
+ ];
162
+ return {
163
+ module: AuditModule_1,
164
+ imports: [
165
+ nestjs_cls_1.ClsModule.forRoot({
166
+ global: true,
167
+ middleware: { mount: true },
168
+ }),
169
+ ...(options.imports || []),
170
+ ],
171
+ controllers: [controllers_1.AuditController],
172
+ providers: [
173
+ {
174
+ provide: 'AUDIT_CONFIG',
175
+ useFactory: options.useFactory,
176
+ inject: options.inject || [],
177
+ },
178
+ {
179
+ provide: 'AUDIT_STRATEGY',
180
+ useClass: services_1.DefaultAuditStrategy,
181
+ },
182
+ {
183
+ provide: 'AUDIT_CONNECTION_NAME',
184
+ useFactory: (...args) => __awaiter(this, void 0, void 0, function* () {
185
+ var _a;
186
+ const config = yield options.useFactory(...args);
187
+ return ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.audit) || 'default';
188
+ }),
189
+ inject: options.inject || [],
190
+ },
191
+ {
192
+ provide: 'AUDIT_SUBSCRIBERS',
193
+ useFactory: (auditService, contextService, auditStrategy, ...args) => __awaiter(this, void 0, void 0, function* () {
194
+ var _a, _b;
195
+ const config = yield options.useFactory(...args);
196
+ const monitoredConnections = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.monitored) || ['default'];
197
+ const auditConnectionName = ((_b = config === null || config === void 0 ? void 0 : config.connections) === null || _b === void 0 ? void 0 : _b.audit) || 'default';
198
+ const typeOrmModule = typeorm_1.TypeOrmModule.forFeature([entities_1.EntityAuditLogEntity, entities_1.EntityTransactionEntity], auditConnectionName);
199
+ return monitoredConnections;
200
+ }),
201
+ inject: [
202
+ services_1.EntityAuditService,
203
+ services_1.AuditContextService,
204
+ services_1.DefaultAuditStrategy,
205
+ ...(options.inject || []),
206
+ ],
207
+ },
208
+ services_1.AuditContextService,
209
+ services_1.DefaultAuditStrategy,
210
+ services_1.MultiDatabaseService,
211
+ ...repositoryProviders,
212
+ services_1.EntityAuditService,
213
+ services_1.TransactionAuditService,
214
+ interceptors_1.AuditInterceptor,
215
+ ],
216
+ exports: [
217
+ services_1.AuditContextService,
218
+ services_1.DefaultAuditStrategy,
219
+ services_1.MultiDatabaseService,
220
+ services_1.EntityAuditService,
221
+ services_1.TransactionAuditService,
222
+ interceptors_1.AuditInterceptor,
223
+ ],
224
+ };
225
+ }
226
+ };
227
+ exports.AuditModule = AuditModule;
228
+ exports.AuditModule = AuditModule = AuditModule_1 = __decorate([
229
+ (0, common_1.Global)(),
230
+ (0, common_1.Module)({})
231
+ ], AuditModule);
@@ -0,0 +1,20 @@
1
+ import { EntityAuditService } from '../services/entity-audit.service';
2
+ import { TransactionAuditService } from '../services/transaction-audit.service';
3
+ import { AuditLogQueryDto, CompareEntitiesDto, RestoreEntityDto, PreCheckRestoreDto, BeginTransactionDto } from '../dto';
4
+ import { EntityAuditLogEntity } from '../entities';
5
+ import { EntityDifference, PreCheckResult, RestoreResult } from '../interfaces';
6
+ import { PageDto } from '../../common/dto';
7
+ export declare class AuditController {
8
+ private readonly entityAuditService;
9
+ private readonly transactionAuditService;
10
+ constructor(entityAuditService: EntityAuditService, transactionAuditService: TransactionAuditService);
11
+ getAuditLogs(query: AuditLogQueryDto): Promise<PageDto<EntityAuditLogEntity>>;
12
+ compareEntities(query: CompareEntitiesDto): Promise<EntityDifference>;
13
+ preCheckRestore(preCheckDto: PreCheckRestoreDto): Promise<PreCheckResult>;
14
+ restoreEntity(restoreDto: RestoreEntityDto): Promise<RestoreResult>;
15
+ beginTransaction(beginTransactionDto: BeginTransactionDto): Promise<{
16
+ transactionId: string;
17
+ }>;
18
+ commitTransaction(transactionId: string): Promise<void>;
19
+ rollbackTransaction(transactionId: string): Promise<void>;
20
+ }
@@ -0,0 +1,142 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.AuditController = void 0;
25
+ const common_1 = require("@nestjs/common");
26
+ const swagger_1 = require("@nestjs/swagger");
27
+ const entity_audit_service_1 = require("../services/entity-audit.service");
28
+ const transaction_audit_service_1 = require("../services/transaction-audit.service");
29
+ const dto_1 = require("../dto");
30
+ let AuditController = class AuditController {
31
+ constructor(entityAuditService, transactionAuditService) {
32
+ this.entityAuditService = entityAuditService;
33
+ this.transactionAuditService = transactionAuditService;
34
+ }
35
+ getAuditLogs(query) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ return this.entityAuditService.getAuditLogs(query);
38
+ });
39
+ }
40
+ compareEntities(query) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ var _a, _b;
43
+ return this.entityAuditService.compareEntities(query.entityType, query.entityId, (_a = query.fromVersion) === null || _a === void 0 ? void 0 : _a.toString(), (_b = query.toVersion) === null || _b === void 0 ? void 0 : _b.toString());
44
+ });
45
+ }
46
+ preCheckRestore(preCheckDto) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ return this.entityAuditService.preCheckRestore(preCheckDto.entityType, preCheckDto.entityId, preCheckDto.auditLogId);
49
+ });
50
+ }
51
+ restoreEntity(restoreDto) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ return this.entityAuditService.restoreEntity(restoreDto.entityType, restoreDto.entityId, restoreDto.auditLogId, restoreDto.options);
54
+ });
55
+ }
56
+ beginTransaction(beginTransactionDto) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const transactionId = yield this.transactionAuditService.beginTransaction(beginTransactionDto.description);
59
+ return { transactionId };
60
+ });
61
+ }
62
+ commitTransaction(transactionId) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ return this.transactionAuditService.commitTransaction(transactionId);
65
+ });
66
+ }
67
+ rollbackTransaction(transactionId) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return this.transactionAuditService.rollbackTransaction(transactionId);
70
+ });
71
+ }
72
+ };
73
+ exports.AuditController = AuditController;
74
+ __decorate([
75
+ (0, common_1.Get)('logs'),
76
+ (0, swagger_1.ApiOperation)({ summary: '查询实体审计日志' }),
77
+ (0, swagger_1.ApiResponse)({ status: 200, description: '成功返回审计日志列表' }),
78
+ __param(0, (0, common_1.Query)()),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", [dto_1.AuditLogQueryDto]),
81
+ __metadata("design:returntype", Promise)
82
+ ], AuditController.prototype, "getAuditLogs", null);
83
+ __decorate([
84
+ (0, common_1.Get)('compare'),
85
+ (0, swagger_1.ApiOperation)({ summary: '比较实体版本' }),
86
+ (0, swagger_1.ApiResponse)({ status: 200, description: '成功返回比较结果' }),
87
+ __param(0, (0, common_1.Query)()),
88
+ __metadata("design:type", Function),
89
+ __metadata("design:paramtypes", [dto_1.CompareEntitiesDto]),
90
+ __metadata("design:returntype", Promise)
91
+ ], AuditController.prototype, "compareEntities", null);
92
+ __decorate([
93
+ (0, common_1.Post)('restore/precheck'),
94
+ (0, swagger_1.ApiOperation)({ summary: '预检查恢复操作' }),
95
+ (0, swagger_1.ApiResponse)({ status: 200, description: '成功返回预检查结果' }),
96
+ __param(0, (0, common_1.Body)()),
97
+ __metadata("design:type", Function),
98
+ __metadata("design:paramtypes", [dto_1.PreCheckRestoreDto]),
99
+ __metadata("design:returntype", Promise)
100
+ ], AuditController.prototype, "preCheckRestore", null);
101
+ __decorate([
102
+ (0, common_1.Post)('restore'),
103
+ (0, swagger_1.ApiOperation)({ summary: '恢复实体到指定版本' }),
104
+ (0, swagger_1.ApiResponse)({ status: 200, description: '成功恢复实体' }),
105
+ __param(0, (0, common_1.Body)()),
106
+ __metadata("design:type", Function),
107
+ __metadata("design:paramtypes", [dto_1.RestoreEntityDto]),
108
+ __metadata("design:returntype", Promise)
109
+ ], AuditController.prototype, "restoreEntity", null);
110
+ __decorate([
111
+ (0, common_1.Post)('transactions'),
112
+ (0, swagger_1.ApiOperation)({ summary: '开始审计事务' }),
113
+ (0, swagger_1.ApiResponse)({ status: 201, description: '成功创建事务' }),
114
+ __param(0, (0, common_1.Body)()),
115
+ __metadata("design:type", Function),
116
+ __metadata("design:paramtypes", [dto_1.BeginTransactionDto]),
117
+ __metadata("design:returntype", Promise)
118
+ ], AuditController.prototype, "beginTransaction", null);
119
+ __decorate([
120
+ (0, common_1.Post)('transactions/:transactionId/commit'),
121
+ (0, swagger_1.ApiOperation)({ summary: '提交审计事务' }),
122
+ (0, swagger_1.ApiResponse)({ status: 200, description: '成功提交事务' }),
123
+ __param(0, (0, common_1.Param)('transactionId')),
124
+ __metadata("design:type", Function),
125
+ __metadata("design:paramtypes", [String]),
126
+ __metadata("design:returntype", Promise)
127
+ ], AuditController.prototype, "commitTransaction", null);
128
+ __decorate([
129
+ (0, common_1.Post)('transactions/:transactionId/rollback'),
130
+ (0, swagger_1.ApiOperation)({ summary: '回滚审计事务' }),
131
+ (0, swagger_1.ApiResponse)({ status: 200, description: '成功回滚事务' }),
132
+ __param(0, (0, common_1.Param)('transactionId')),
133
+ __metadata("design:type", Function),
134
+ __metadata("design:paramtypes", [String]),
135
+ __metadata("design:returntype", Promise)
136
+ ], AuditController.prototype, "rollbackTransaction", null);
137
+ exports.AuditController = AuditController = __decorate([
138
+ (0, common_1.Controller)('audit'),
139
+ (0, swagger_1.ApiTags)('audit'),
140
+ __metadata("design:paramtypes", [entity_audit_service_1.EntityAuditService,
141
+ transaction_audit_service_1.TransactionAuditService])
142
+ ], AuditController);
@@ -0,0 +1 @@
1
+ export * from './audit.controller';
@@ -0,0 +1,17 @@
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.controller"), exports);
@@ -0,0 +1,5 @@
1
+ import { ControllerAuditOptions, MethodAuditOptions } from '../interfaces';
2
+ export declare const CONTROLLER_AUDIT_OPTIONS: unique symbol;
3
+ export declare const METHOD_AUDIT_OPTIONS: unique symbol;
4
+ export declare function EntityAuditController(options?: ControllerAuditOptions): ClassDecorator;
5
+ export declare function AuditMethod(options?: MethodAuditOptions): MethodDecorator;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METHOD_AUDIT_OPTIONS = exports.CONTROLLER_AUDIT_OPTIONS = void 0;
4
+ exports.EntityAuditController = EntityAuditController;
5
+ exports.AuditMethod = AuditMethod;
6
+ exports.CONTROLLER_AUDIT_OPTIONS = Symbol('CONTROLLER_AUDIT_OPTIONS');
7
+ exports.METHOD_AUDIT_OPTIONS = Symbol('METHOD_AUDIT_OPTIONS');
8
+ function EntityAuditController(options) {
9
+ return (target) => {
10
+ Reflect.defineMetadata(exports.CONTROLLER_AUDIT_OPTIONS, options || {}, target);
11
+ };
12
+ }
13
+ function AuditMethod(options) {
14
+ return (target, propertyKey, descriptor) => {
15
+ Reflect.defineMetadata(exports.METHOD_AUDIT_OPTIONS, options || {}, descriptor.value);
16
+ };
17
+ }
@@ -0,0 +1,5 @@
1
+ import { AuditOperationOptions } from '../interfaces';
2
+ export declare const AUDIT_OPERATION_OPTIONS: unique symbol;
3
+ export declare function AuditLog(options: AuditOperationOptions): MethodDecorator;
4
+ export declare function getAuditOperationConfig(target: any, propertyKey: string | symbol): AuditOperationOptions | undefined;
5
+ export declare function hasAuditOperation(target: any, propertyKey: string | symbol): boolean;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUDIT_OPERATION_OPTIONS = void 0;
4
+ exports.AuditLog = AuditLog;
5
+ exports.getAuditOperationConfig = getAuditOperationConfig;
6
+ exports.hasAuditOperation = hasAuditOperation;
7
+ exports.AUDIT_OPERATION_OPTIONS = Symbol('AUDIT_OPERATION_OPTIONS');
8
+ function AuditLog(options) {
9
+ return (target, propertyKey, descriptor) => {
10
+ if (!options.templateKey) {
11
+ throw new Error(`@AuditLog requires templateKey for method ${String(propertyKey)}`);
12
+ }
13
+ const methodMetadata = Object.assign(Object.assign({}, options), { methodName: String(propertyKey) });
14
+ Reflect.defineMetadata(exports.AUDIT_OPERATION_OPTIONS, methodMetadata, target, propertyKey);
15
+ return descriptor;
16
+ };
17
+ }
18
+ function getAuditOperationConfig(target, propertyKey) {
19
+ return Reflect.getMetadata(exports.AUDIT_OPERATION_OPTIONS, target, propertyKey);
20
+ }
21
+ function hasAuditOperation(target, propertyKey) {
22
+ return Reflect.hasMetadata(exports.AUDIT_OPERATION_OPTIONS, target, propertyKey);
23
+ }
@@ -0,0 +1,5 @@
1
+ import { EntityAuditConfig, FieldDisplayOptions } from '../interfaces';
2
+ export declare const ENTITY_AUDIT_OPTIONS: unique symbol;
3
+ export declare const FIELD_AUDIT_OPTIONS: unique symbol;
4
+ export declare function EntityAudit(options?: EntityAuditConfig): ClassDecorator;
5
+ export declare function AuditField(options?: FieldDisplayOptions): PropertyDecorator;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FIELD_AUDIT_OPTIONS = exports.ENTITY_AUDIT_OPTIONS = void 0;
4
+ exports.EntityAudit = EntityAudit;
5
+ exports.AuditField = AuditField;
6
+ exports.ENTITY_AUDIT_OPTIONS = Symbol('ENTITY_AUDIT_OPTIONS');
7
+ exports.FIELD_AUDIT_OPTIONS = Symbol('FIELD_AUDIT_OPTIONS');
8
+ function EntityAudit(options) {
9
+ return (target) => {
10
+ Reflect.defineMetadata(exports.ENTITY_AUDIT_OPTIONS, options || {}, target);
11
+ };
12
+ }
13
+ function AuditField(options) {
14
+ return (target, propertyKey) => {
15
+ const existingOptions = Reflect.getMetadata(exports.FIELD_AUDIT_OPTIONS, target.constructor) || {};
16
+ existingOptions[propertyKey] = options || {};
17
+ Reflect.defineMetadata(exports.FIELD_AUDIT_OPTIONS, existingOptions, target.constructor);
18
+ };
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './entity-audit.decorator';
2
+ export * from './audit-controller.decorator';
@@ -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.decorator"), exports);
18
+ __exportStar(require("./audit-controller.decorator"), exports);
@@ -0,0 +1,14 @@
1
+ import { AuditOperation } from '../enums';
2
+ export declare class AuditLogQueryDto {
3
+ page?: number;
4
+ limit?: number;
5
+ entityType?: string;
6
+ entityId?: string;
7
+ operation?: AuditOperation;
8
+ userId?: string;
9
+ startDate?: string;
10
+ endDate?: string;
11
+ search?: string;
12
+ sortBy?: string;
13
+ sortOrder?: 'ASC' | 'DESC';
14
+ }
@@ -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
+ }