@nest-omni/core 4.1.3-2 → 4.1.3-3

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 (235) hide show
  1. package/audit/audit.module.d.ts +10 -0
  2. package/audit/audit.module.js +15 -0
  3. package/audit/controllers/audit.controller.d.ts +24 -0
  4. package/audit/controllers/audit.controller.js +24 -0
  5. package/audit/decorators/audit-controller.decorator.d.ts +8 -0
  6. package/audit/decorators/audit-controller.decorator.js +9 -0
  7. package/audit/decorators/audit-operation.decorator.d.ts +45 -0
  8. package/audit/decorators/audit-operation.decorator.js +49 -0
  9. package/audit/decorators/entity-audit.decorator.d.ts +8 -0
  10. package/audit/decorators/entity-audit.decorator.js +9 -0
  11. package/audit/dto/audit-log-query.dto.d.ts +3 -0
  12. package/audit/dto/audit-log-query.dto.js +3 -0
  13. package/audit/dto/begin-transaction.dto.d.ts +3 -0
  14. package/audit/dto/begin-transaction.dto.js +3 -0
  15. package/audit/dto/compare-entities.dto.d.ts +3 -0
  16. package/audit/dto/compare-entities.dto.js +3 -0
  17. package/audit/dto/pre-check-restore.dto.d.ts +3 -0
  18. package/audit/dto/pre-check-restore.dto.js +3 -0
  19. package/audit/dto/restore-entity.dto.d.ts +3 -0
  20. package/audit/dto/restore-entity.dto.js +3 -0
  21. package/audit/entities/entity-audit-log.entity.d.ts +3 -0
  22. package/audit/entities/entity-audit-log.entity.js +3 -0
  23. package/audit/entities/entity-transaction.entity.d.ts +3 -0
  24. package/audit/entities/entity-transaction.entity.js +3 -0
  25. package/audit/entities/manual-operation-log.entity.d.ts +4 -0
  26. package/audit/entities/manual-operation-log.entity.js +4 -0
  27. package/audit/entities/operation-template.entity.d.ts +4 -0
  28. package/audit/entities/operation-template.entity.js +4 -0
  29. package/audit/enums/audit.enums.d.ts +17 -2
  30. package/audit/enums/audit.enums.js +15 -0
  31. package/audit/index.js +10 -0
  32. package/audit/interceptors/audit.interceptor.d.ts +15 -0
  33. package/audit/interceptors/audit.interceptor.js +23 -1
  34. package/audit/interfaces/audit.interfaces.d.ts +42 -0
  35. package/audit/services/audit-context.service.d.ts +15 -0
  36. package/audit/services/audit-context.service.js +15 -0
  37. package/audit/services/audit-strategy.service.d.ts +6 -0
  38. package/audit/services/audit-strategy.service.js +13 -0
  39. package/audit/services/entity-audit.service.d.ts +57 -0
  40. package/audit/services/entity-audit.service.js +91 -0
  41. package/audit/services/manual-audit-log.service.d.ts +124 -0
  42. package/audit/services/manual-audit-log.service.js +138 -0
  43. package/audit/services/multi-database.service.d.ts +12 -0
  44. package/audit/services/multi-database.service.js +12 -0
  45. package/audit/services/operation-description.service.d.ts +59 -0
  46. package/audit/services/operation-description.service.js +76 -2
  47. package/audit/services/transaction-audit.service.d.ts +30 -0
  48. package/audit/services/transaction-audit.service.js +47 -0
  49. package/audit/subscribers/entity-audit.subscriber.d.ts +15 -0
  50. package/audit/subscribers/entity-audit.subscriber.js +29 -1
  51. package/cache/cache-metrics.service.d.ts +67 -0
  52. package/cache/cache-metrics.service.js +68 -4
  53. package/cache/cache-serialization.service.d.ts +31 -0
  54. package/cache/cache-serialization.service.js +25 -0
  55. package/cache/cache.constants.d.ts +9 -0
  56. package/cache/cache.constants.js +9 -0
  57. package/cache/cache.health.d.ts +26 -0
  58. package/cache/cache.health.js +30 -0
  59. package/cache/cache.module.d.ts +86 -0
  60. package/cache/cache.module.js +71 -0
  61. package/cache/cache.service.d.ts +140 -0
  62. package/cache/cache.service.js +157 -0
  63. package/cache/cache.warmup.service.d.ts +39 -0
  64. package/cache/cache.warmup.service.js +32 -0
  65. package/cache/decorators/cache-evict.decorator.d.ts +47 -0
  66. package/cache/decorators/cache-evict.decorator.js +56 -0
  67. package/cache/decorators/cache-put.decorator.d.ts +34 -0
  68. package/cache/decorators/cache-put.decorator.js +39 -0
  69. package/cache/decorators/cacheable.decorator.d.ts +40 -0
  70. package/cache/decorators/cacheable.decorator.js +55 -0
  71. package/cache/dependencies/callback.dependency.d.ts +33 -0
  72. package/cache/dependencies/callback.dependency.js +39 -1
  73. package/cache/dependencies/chain.dependency.d.ts +28 -0
  74. package/cache/dependencies/chain.dependency.js +34 -0
  75. package/cache/dependencies/db.dependency.d.ts +45 -0
  76. package/cache/dependencies/db.dependency.js +48 -1
  77. package/cache/dependencies/file.dependency.d.ts +32 -0
  78. package/cache/dependencies/file.dependency.js +34 -0
  79. package/cache/dependencies/tag.dependency.d.ts +36 -0
  80. package/cache/dependencies/tag.dependency.js +36 -0
  81. package/cache/dependencies/time.dependency.d.ts +43 -0
  82. package/cache/dependencies/time.dependency.js +43 -0
  83. package/cache/examples/basic-usage.d.ts +15 -0
  84. package/cache/examples/basic-usage.js +62 -8
  85. package/cache/index.js +9 -0
  86. package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
  87. package/cache/interfaces/cache-options.interface.d.ts +81 -0
  88. package/cache/interfaces/cache-options.interface.js +6 -0
  89. package/cache/interfaces/cache-provider.interface.d.ts +78 -0
  90. package/cache/providers/base-cache.provider.d.ts +14 -0
  91. package/cache/providers/base-cache.provider.js +16 -0
  92. package/cache/providers/cls-cache.provider.d.ts +20 -0
  93. package/cache/providers/cls-cache.provider.js +28 -0
  94. package/cache/providers/memory-cache.provider.d.ts +23 -0
  95. package/cache/providers/memory-cache.provider.js +26 -0
  96. package/cache/providers/redis-cache.provider.d.ts +26 -0
  97. package/cache/providers/redis-cache.provider.js +29 -0
  98. package/cache/utils/dependency-manager.util.d.ts +52 -0
  99. package/cache/utils/dependency-manager.util.js +59 -0
  100. package/cache/utils/key-generator.util.d.ts +42 -0
  101. package/cache/utils/key-generator.util.js +53 -1
  102. package/common/abstract.entity.d.ts +14 -0
  103. package/common/abstract.entity.js +14 -0
  104. package/common/boilerplate.polyfill.d.ts +142 -0
  105. package/common/boilerplate.polyfill.js +17 -0
  106. package/common/dto/dto-container.d.ts +16 -0
  107. package/common/dto/dto-container.js +20 -0
  108. package/common/dto/dto-decorators.d.ts +18 -0
  109. package/common/dto/dto-decorators.js +14 -0
  110. package/common/dto/dto-extensions.d.ts +11 -0
  111. package/common/dto/dto-extensions.js +9 -0
  112. package/common/dto/dto-service-accessor.d.ts +17 -0
  113. package/common/dto/dto-service-accessor.js +18 -0
  114. package/common/dto/dto-transformer.d.ts +12 -0
  115. package/common/dto/dto-transformer.js +9 -0
  116. package/common/dto/index.js +2 -0
  117. package/common/examples/paginate-and-map.example.d.ts +6 -0
  118. package/common/examples/paginate-and-map.example.js +26 -0
  119. package/common/utils.d.ts +15 -0
  120. package/common/utils.js +15 -0
  121. package/constants/language-code.js +1 -0
  122. package/decorators/field.decorators.js +8 -1
  123. package/decorators/property.decorators.js +1 -0
  124. package/decorators/public-route.decorator.js +1 -0
  125. package/decorators/transform.decorators.d.ts +27 -0
  126. package/decorators/transform.decorators.js +29 -0
  127. package/decorators/translate.decorator.js +1 -0
  128. package/decorators/user.decorator.js +1 -0
  129. package/decorators/validator.decorators.d.ts +8 -18
  130. package/decorators/validator.decorators.js +22 -190
  131. package/filters/constraint-errors.js +1 -0
  132. package/helpers/common.helper.d.ts +13 -0
  133. package/helpers/common.helper.js +13 -0
  134. package/http-client/config/http-client.config.d.ts +15 -0
  135. package/http-client/config/http-client.config.js +25 -9
  136. package/http-client/decorators/http-client.decorators.d.ts +63 -0
  137. package/http-client/decorators/http-client.decorators.js +71 -3
  138. package/http-client/entities/http-log.entity.d.ts +229 -0
  139. package/http-client/entities/http-log.entity.js +6 -1
  140. package/http-client/errors/http-client.errors.d.ts +57 -0
  141. package/http-client/errors/http-client.errors.js +58 -0
  142. package/http-client/examples/advanced-usage.example.d.ts +41 -0
  143. package/http-client/examples/advanced-usage.example.js +68 -24
  144. package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
  145. package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
  146. package/http-client/examples/basic-usage.example.d.ts +60 -0
  147. package/http-client/examples/basic-usage.example.js +60 -0
  148. package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
  149. package/http-client/examples/multi-api-configuration.example.js +76 -5
  150. package/http-client/http-client.module.d.ts +13 -0
  151. package/http-client/http-client.module.js +19 -0
  152. package/http-client/index.js +8 -0
  153. package/http-client/interfaces/api-client-config.interface.d.ts +125 -0
  154. package/http-client/interfaces/api-client-config.interface.js +3 -0
  155. package/http-client/interfaces/http-client-config.interface.d.ts +60 -0
  156. package/http-client/services/api-client-registry.service.d.ts +57 -0
  157. package/http-client/services/api-client-registry.service.js +84 -1
  158. package/http-client/services/cache.service.d.ts +52 -0
  159. package/http-client/services/cache.service.js +72 -3
  160. package/http-client/services/circuit-breaker.service.d.ts +46 -0
  161. package/http-client/services/circuit-breaker.service.js +52 -0
  162. package/http-client/services/http-client.service.d.ts +67 -0
  163. package/http-client/services/http-client.service.js +105 -4
  164. package/http-client/services/http-log-query.service.d.ts +83 -0
  165. package/http-client/services/http-log-query.service.js +122 -1
  166. package/http-client/services/http-replay.service.d.ts +101 -0
  167. package/http-client/services/http-replay.service.js +86 -0
  168. package/http-client/services/log-cleanup.service.d.ts +63 -0
  169. package/http-client/services/log-cleanup.service.js +54 -2
  170. package/http-client/services/logging.service.d.ts +40 -0
  171. package/http-client/services/logging.service.js +53 -0
  172. package/http-client/utils/call-stack-extractor.util.d.ts +37 -0
  173. package/http-client/utils/call-stack-extractor.util.js +48 -0
  174. package/http-client/utils/context-extractor.util.d.ts +49 -0
  175. package/http-client/utils/context-extractor.util.js +52 -0
  176. package/http-client/utils/curl-generator.util.d.ts +21 -0
  177. package/http-client/utils/curl-generator.util.js +44 -3
  178. package/http-client/utils/request-id.util.d.ts +18 -0
  179. package/http-client/utils/request-id.util.js +20 -0
  180. package/http-client/utils/retry-recorder.util.d.ts +42 -0
  181. package/http-client/utils/retry-recorder.util.js +44 -0
  182. package/index.js +8 -0
  183. package/interceptors/translation-interceptor.service.js +5 -0
  184. package/package.json +1 -1
  185. package/providers/context.provider.js +2 -0
  186. package/providers/generator.provider.d.ts +4 -0
  187. package/providers/generator.provider.js +4 -0
  188. package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
  189. package/redis-lock/examples/lock-strategy.examples.js +130 -15
  190. package/redis-lock/index.js +3 -0
  191. package/redis-lock/redis-lock.decorator.d.ts +101 -0
  192. package/redis-lock/redis-lock.decorator.js +120 -0
  193. package/redis-lock/redis-lock.module.d.ts +60 -0
  194. package/redis-lock/redis-lock.module.js +46 -0
  195. package/redis-lock/redis-lock.service.d.ts +251 -0
  196. package/redis-lock/redis-lock.service.js +219 -3
  197. package/setup/bootstrap.setup.js +20 -0
  198. package/setup/mode.setup.d.ts +44 -0
  199. package/setup/mode.setup.js +44 -0
  200. package/setup/schedule.decorator.d.ts +226 -0
  201. package/setup/schedule.decorator.js +214 -1
  202. package/setup/worker.decorator.d.ts +86 -0
  203. package/setup/worker.decorator.js +88 -0
  204. package/shared/serviceRegistryModule.js +5 -1
  205. package/shared/services/api-config.service.d.ts +3 -0
  206. package/shared/services/api-config.service.js +20 -9
  207. package/validator-json/decorators.d.ts +17 -0
  208. package/validator-json/decorators.js +17 -2
  209. package/validator-json/default.d.ts +6 -0
  210. package/validator-json/default.js +30 -2
  211. package/validator-json/defaultConverters.js +1 -0
  212. package/validator-json/options.d.ts +23 -0
  213. package/validators/common-validators.d.ts +143 -0
  214. package/validators/common-validators.js +249 -0
  215. package/validators/custom-validate.examples.d.ts +23 -0
  216. package/validators/custom-validate.examples.js +78 -6
  217. package/validators/custom-validate.validator.d.ts +107 -0
  218. package/validators/custom-validate.validator.js +84 -0
  219. package/validators/index.d.ts +1 -0
  220. package/validators/index.js +1 -0
  221. package/validators/is-exists.validator.d.ts +11 -0
  222. package/validators/is-exists.validator.js +22 -0
  223. package/validators/is-unique.validator.d.ts +11 -0
  224. package/validators/is-unique.validator.js +18 -0
  225. package/validators/skip-empty.validator.d.ts +5 -0
  226. package/validators/skip-empty.validator.js +5 -0
  227. package/vault/interfaces/vault-options.interface.d.ts +9 -0
  228. package/vault/vault-config.loader.d.ts +30 -0
  229. package/vault/vault-config.loader.js +48 -1
  230. package/vault/vault-config.service.d.ts +53 -0
  231. package/vault/vault-config.service.js +57 -0
  232. package/vault/vault.module.d.ts +4 -0
  233. package/vault/vault.module.js +4 -0
  234. package/decorators/examples/validation-decorators.example.d.ts +0 -69
  235. package/decorators/examples/validation-decorators.example.js +0 -331
@@ -1,7 +1,17 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
2
  import { AuditConfig } from './interfaces';
3
+ /**
4
+ * 审计模块
5
+ */
3
6
  export declare class AuditModule {
7
+ /**
8
+ * 注册审计模块
9
+ * @param config 审计配置
10
+ */
4
11
  static forRoot(config?: AuditConfig): DynamicModule;
12
+ /**
13
+ * 注册审计模块(异步)
14
+ */
5
15
  static forRootAsync(options: {
6
16
  imports?: any[];
7
17
  inject?: any[];
@@ -25,11 +25,19 @@ const services_1 = require("./services");
25
25
  const subscribers_1 = require("./subscribers");
26
26
  const interceptors_1 = require("./interceptors");
27
27
  const controllers_1 = require("./controllers");
28
+ /**
29
+ * 审计模块
30
+ */
28
31
  let AuditModule = AuditModule_1 = class AuditModule {
32
+ /**
33
+ * 注册审计模块
34
+ * @param config 审计配置
35
+ */
29
36
  static forRoot(config) {
30
37
  var _a, _b;
31
38
  const auditConnectionName = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.audit) || 'default';
32
39
  const monitoredConnections = ((_b = config === null || config === void 0 ? void 0 : config.connections) === null || _b === void 0 ? void 0 : _b.monitored) || ['default'];
40
+ // 创建多个订阅者提供者,每个监听的数据库连接一个
33
41
  const subscriberProviders = monitoredConnections.map((connectionName) => ({
34
42
  provide: `AUDIT_SUBSCRIBER_${connectionName}`,
35
43
  useFactory: (auditService, contextService, auditStrategy, dataSource) => {
@@ -43,6 +51,7 @@ let AuditModule = AuditModule_1 = class AuditModule {
43
51
  (0, typeorm_1.getDataSourceToken)(connectionName),
44
52
  ],
45
53
  }));
54
+ // 创建repository别名提供者,使service能够注入正确连接的repository
46
55
  const repositoryProviders = [
47
56
  {
48
57
  provide: (0, typeorm_1.getRepositoryToken)(entities_1.EntityAuditLogEntity),
@@ -69,6 +78,7 @@ let AuditModule = AuditModule_1 = class AuditModule {
69
78
  return {
70
79
  module: AuditModule_1,
71
80
  imports: [
81
+ // 审计日志存储到指定的数据库连接
72
82
  typeorm_1.TypeOrmModule.forFeature([entities_1.EntityAuditLogEntity, entities_1.EntityTransactionEntity], auditConnectionName),
73
83
  nestjs_cls_1.ClsModule.forRoot({
74
84
  global: true,
@@ -108,7 +118,11 @@ let AuditModule = AuditModule_1 = class AuditModule {
108
118
  ],
109
119
  };
110
120
  }
121
+ /**
122
+ * 注册审计模块(异步)
123
+ */
111
124
  static forRootAsync(options) {
125
+ // 创建repository别名提供者,使service能够注入正确连接的repository
112
126
  const repositoryProviders = [
113
127
  {
114
128
  provide: (0, typeorm_1.getRepositoryToken)(entities_1.EntityAuditLogEntity),
@@ -195,6 +209,7 @@ let AuditModule = AuditModule_1 = class AuditModule {
195
209
  const config = yield options.useFactory(...args);
196
210
  const monitoredConnections = ((_a = config === null || config === void 0 ? void 0 : config.connections) === null || _a === void 0 ? void 0 : _a.monitored) || ['default'];
197
211
  const auditConnectionName = ((_b = config === null || config === void 0 ? void 0 : config.connections) === null || _b === void 0 ? void 0 : _b.audit) || 'default';
212
+ // 动态注册 TypeORM 实体
198
213
  const typeOrmModule = typeorm_1.TypeOrmModule.forFeature([entities_1.EntityAuditLogEntity, entities_1.EntityTransactionEntity], auditConnectionName);
199
214
  return monitoredConnections;
200
215
  }),
@@ -4,17 +4,41 @@ import { AuditLogQueryDto, CompareEntitiesDto, RestoreEntityDto, PreCheckRestore
4
4
  import { EntityAuditLogEntity } from '../entities';
5
5
  import { EntityDifference, PreCheckResult, RestoreResult } from '../interfaces';
6
6
  import { PageDto } from '../../common/dto';
7
+ /**
8
+ * 审计控制器
9
+ */
7
10
  export declare class AuditController {
8
11
  private readonly entityAuditService;
9
12
  private readonly transactionAuditService;
10
13
  constructor(entityAuditService: EntityAuditService, transactionAuditService: TransactionAuditService);
14
+ /**
15
+ * 查询实体审计日志
16
+ */
11
17
  getAuditLogs(query: AuditLogQueryDto): Promise<PageDto<EntityAuditLogEntity>>;
18
+ /**
19
+ * 比较实体版本
20
+ */
12
21
  compareEntities(query: CompareEntitiesDto): Promise<EntityDifference>;
22
+ /**
23
+ * 预检查恢复操作
24
+ */
13
25
  preCheckRestore(preCheckDto: PreCheckRestoreDto): Promise<PreCheckResult>;
26
+ /**
27
+ * 恢复实体到指定版本
28
+ */
14
29
  restoreEntity(restoreDto: RestoreEntityDto): Promise<RestoreResult>;
30
+ /**
31
+ * 开始审计事务
32
+ */
15
33
  beginTransaction(beginTransactionDto: BeginTransactionDto): Promise<{
16
34
  transactionId: string;
17
35
  }>;
36
+ /**
37
+ * 提交审计事务
38
+ */
18
39
  commitTransaction(transactionId: string): Promise<void>;
40
+ /**
41
+ * 回滚审计事务
42
+ */
19
43
  rollbackTransaction(transactionId: string): Promise<void>;
20
44
  }
@@ -27,43 +27,67 @@ const swagger_1 = require("@nestjs/swagger");
27
27
  const entity_audit_service_1 = require("../services/entity-audit.service");
28
28
  const transaction_audit_service_1 = require("../services/transaction-audit.service");
29
29
  const dto_1 = require("../dto");
30
+ /**
31
+ * 审计控制器
32
+ */
30
33
  let AuditController = class AuditController {
31
34
  constructor(entityAuditService, transactionAuditService) {
32
35
  this.entityAuditService = entityAuditService;
33
36
  this.transactionAuditService = transactionAuditService;
34
37
  }
38
+ /**
39
+ * 查询实体审计日志
40
+ */
35
41
  getAuditLogs(query) {
36
42
  return __awaiter(this, void 0, void 0, function* () {
37
43
  return this.entityAuditService.getAuditLogs(query);
38
44
  });
39
45
  }
46
+ /**
47
+ * 比较实体版本
48
+ */
40
49
  compareEntities(query) {
41
50
  return __awaiter(this, void 0, void 0, function* () {
42
51
  var _a, _b;
43
52
  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
53
  });
45
54
  }
55
+ /**
56
+ * 预检查恢复操作
57
+ */
46
58
  preCheckRestore(preCheckDto) {
47
59
  return __awaiter(this, void 0, void 0, function* () {
48
60
  return this.entityAuditService.preCheckRestore(preCheckDto.entityType, preCheckDto.entityId, preCheckDto.auditLogId);
49
61
  });
50
62
  }
63
+ /**
64
+ * 恢复实体到指定版本
65
+ */
51
66
  restoreEntity(restoreDto) {
52
67
  return __awaiter(this, void 0, void 0, function* () {
53
68
  return this.entityAuditService.restoreEntity(restoreDto.entityType, restoreDto.entityId, restoreDto.auditLogId, restoreDto.options);
54
69
  });
55
70
  }
71
+ /**
72
+ * 开始审计事务
73
+ */
56
74
  beginTransaction(beginTransactionDto) {
57
75
  return __awaiter(this, void 0, void 0, function* () {
58
76
  const transactionId = yield this.transactionAuditService.beginTransaction(beginTransactionDto.description);
59
77
  return { transactionId };
60
78
  });
61
79
  }
80
+ /**
81
+ * 提交审计事务
82
+ */
62
83
  commitTransaction(transactionId) {
63
84
  return __awaiter(this, void 0, void 0, function* () {
64
85
  return this.transactionAuditService.commitTransaction(transactionId);
65
86
  });
66
87
  }
88
+ /**
89
+ * 回滚审计事务
90
+ */
67
91
  rollbackTransaction(transactionId) {
68
92
  return __awaiter(this, void 0, void 0, function* () {
69
93
  return this.transactionAuditService.rollbackTransaction(transactionId);
@@ -1,5 +1,13 @@
1
1
  import { ControllerAuditOptions, MethodAuditOptions } from '../interfaces';
2
2
  export declare const CONTROLLER_AUDIT_OPTIONS: unique symbol;
3
3
  export declare const METHOD_AUDIT_OPTIONS: unique symbol;
4
+ /**
5
+ * 控制器审计装饰器
6
+ * @param options 控制器审计选项
7
+ */
4
8
  export declare function EntityAuditController(options?: ControllerAuditOptions): ClassDecorator;
9
+ /**
10
+ * 方法审计装饰器
11
+ * @param options 方法审计选项
12
+ */
5
13
  export declare function AuditMethod(options?: MethodAuditOptions): MethodDecorator;
@@ -3,13 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.METHOD_AUDIT_OPTIONS = exports.CONTROLLER_AUDIT_OPTIONS = void 0;
4
4
  exports.EntityAuditController = EntityAuditController;
5
5
  exports.AuditMethod = AuditMethod;
6
+ // 元数据键
6
7
  exports.CONTROLLER_AUDIT_OPTIONS = Symbol('CONTROLLER_AUDIT_OPTIONS');
7
8
  exports.METHOD_AUDIT_OPTIONS = Symbol('METHOD_AUDIT_OPTIONS');
9
+ /**
10
+ * 控制器审计装饰器
11
+ * @param options 控制器审计选项
12
+ */
8
13
  function EntityAuditController(options) {
9
14
  return (target) => {
10
15
  Reflect.defineMetadata(exports.CONTROLLER_AUDIT_OPTIONS, options || {}, target);
11
16
  };
12
17
  }
18
+ /**
19
+ * 方法审计装饰器
20
+ * @param options 方法审计选项
21
+ */
13
22
  function AuditMethod(options) {
14
23
  return (target, propertyKey, descriptor) => {
15
24
  Reflect.defineMetadata(exports.METHOD_AUDIT_OPTIONS, options || {}, descriptor.value);
@@ -1,5 +1,50 @@
1
1
  import { AuditOperationOptions } from '../interfaces';
2
2
  export declare const AUDIT_OPERATION_OPTIONS: unique symbol;
3
+ /**
4
+ * 方法审计装饰器
5
+ *
6
+ * @description
7
+ * 用于手动记录业务操作的审计日志,支持:
8
+ * - 自定义操作模板
9
+ * - 动态描述参数
10
+ * - 回滚操作定义
11
+ * - 自动事务管理
12
+ *
13
+ * @param options 审计操作选项
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * @AuditLog({
18
+ * templateKey: 'user.approve',
19
+ * descriptionParams: (args, result) => ({
20
+ * username: args[0].username,
21
+ * approver: result.approver
22
+ * }),
23
+ * rollbackActions: (args, result) => [{
24
+ * type: RollbackActionType.UPDATE,
25
+ * action: 'reject',
26
+ * params: { userId: args[0].id },
27
+ * order: 1
28
+ * }],
29
+ * autoTransaction: true
30
+ * })
31
+ * async approveUser(user: User): Promise<ApprovalResult> {
32
+ * // 业务逻辑
33
+ * }
34
+ * ```
35
+ */
3
36
  export declare function AuditLog(options: AuditOperationOptions): MethodDecorator;
37
+ /**
38
+ * 获取方法的审计配置
39
+ * @param target 目标类或实例
40
+ * @param propertyKey 方法名
41
+ * @returns 审计操作选项
42
+ */
4
43
  export declare function getAuditOperationConfig(target: any, propertyKey: string | symbol): AuditOperationOptions | undefined;
44
+ /**
45
+ * 检查方法是否配置了审计
46
+ * @param target 目标类或实例
47
+ * @param propertyKey 方法名
48
+ * @returns 是否配置了审计
49
+ */
5
50
  export declare function hasAuditOperation(target: any, propertyKey: string | symbol): boolean;
@@ -4,20 +4,69 @@ exports.AUDIT_OPERATION_OPTIONS = void 0;
4
4
  exports.AuditLog = AuditLog;
5
5
  exports.getAuditOperationConfig = getAuditOperationConfig;
6
6
  exports.hasAuditOperation = hasAuditOperation;
7
+ // 元数据键
7
8
  exports.AUDIT_OPERATION_OPTIONS = Symbol('AUDIT_OPERATION_OPTIONS');
9
+ /**
10
+ * 方法审计装饰器
11
+ *
12
+ * @description
13
+ * 用于手动记录业务操作的审计日志,支持:
14
+ * - 自定义操作模板
15
+ * - 动态描述参数
16
+ * - 回滚操作定义
17
+ * - 自动事务管理
18
+ *
19
+ * @param options 审计操作选项
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * @AuditLog({
24
+ * templateKey: 'user.approve',
25
+ * descriptionParams: (args, result) => ({
26
+ * username: args[0].username,
27
+ * approver: result.approver
28
+ * }),
29
+ * rollbackActions: (args, result) => [{
30
+ * type: RollbackActionType.UPDATE,
31
+ * action: 'reject',
32
+ * params: { userId: args[0].id },
33
+ * order: 1
34
+ * }],
35
+ * autoTransaction: true
36
+ * })
37
+ * async approveUser(user: User): Promise<ApprovalResult> {
38
+ * // 业务逻辑
39
+ * }
40
+ * ```
41
+ */
8
42
  function AuditLog(options) {
9
43
  return (target, propertyKey, descriptor) => {
44
+ // 验证必需参数
10
45
  if (!options.templateKey) {
11
46
  throw new Error(`@AuditLog requires templateKey for method ${String(propertyKey)}`);
12
47
  }
48
+ // 存储元数据
13
49
  const methodMetadata = Object.assign(Object.assign({}, options), { methodName: String(propertyKey) });
14
50
  Reflect.defineMetadata(exports.AUDIT_OPERATION_OPTIONS, methodMetadata, target, propertyKey);
51
+ // 返回原始描述符,实际的拦截逻辑由 AuditInterceptor 处理
15
52
  return descriptor;
16
53
  };
17
54
  }
55
+ /**
56
+ * 获取方法的审计配置
57
+ * @param target 目标类或实例
58
+ * @param propertyKey 方法名
59
+ * @returns 审计操作选项
60
+ */
18
61
  function getAuditOperationConfig(target, propertyKey) {
19
62
  return Reflect.getMetadata(exports.AUDIT_OPERATION_OPTIONS, target, propertyKey);
20
63
  }
64
+ /**
65
+ * 检查方法是否配置了审计
66
+ * @param target 目标类或实例
67
+ * @param propertyKey 方法名
68
+ * @returns 是否配置了审计
69
+ */
21
70
  function hasAuditOperation(target, propertyKey) {
22
71
  return Reflect.hasMetadata(exports.AUDIT_OPERATION_OPTIONS, target, propertyKey);
23
72
  }
@@ -1,5 +1,13 @@
1
1
  import { EntityAuditConfig, FieldDisplayOptions } from '../interfaces';
2
2
  export declare const ENTITY_AUDIT_OPTIONS: unique symbol;
3
3
  export declare const FIELD_AUDIT_OPTIONS: unique symbol;
4
+ /**
5
+ * 实体审计装饰器
6
+ * @param options 审计配置选项
7
+ */
4
8
  export declare function EntityAudit(options?: EntityAuditConfig): ClassDecorator;
9
+ /**
10
+ * 字段审计装饰器
11
+ * @param options 字段显示选项
12
+ */
5
13
  export declare function AuditField(options?: FieldDisplayOptions): PropertyDecorator;
@@ -3,13 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FIELD_AUDIT_OPTIONS = exports.ENTITY_AUDIT_OPTIONS = void 0;
4
4
  exports.EntityAudit = EntityAudit;
5
5
  exports.AuditField = AuditField;
6
+ // 元数据键
6
7
  exports.ENTITY_AUDIT_OPTIONS = Symbol('ENTITY_AUDIT_OPTIONS');
7
8
  exports.FIELD_AUDIT_OPTIONS = Symbol('FIELD_AUDIT_OPTIONS');
9
+ /**
10
+ * 实体审计装饰器
11
+ * @param options 审计配置选项
12
+ */
8
13
  function EntityAudit(options) {
9
14
  return (target) => {
10
15
  Reflect.defineMetadata(exports.ENTITY_AUDIT_OPTIONS, options || {}, target);
11
16
  };
12
17
  }
18
+ /**
19
+ * 字段审计装饰器
20
+ * @param options 字段显示选项
21
+ */
13
22
  function AuditField(options) {
14
23
  return (target, propertyKey) => {
15
24
  const existingOptions = Reflect.getMetadata(exports.FIELD_AUDIT_OPTIONS, target.constructor) || {};
@@ -1,4 +1,7 @@
1
1
  import { AuditOperation } from '../enums';
2
+ /**
3
+ * 审计日志查询DTO
4
+ */
2
5
  export declare class AuditLogQueryDto {
3
6
  page?: number;
4
7
  limit?: number;
@@ -14,6 +14,9 @@ const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const class_transformer_1 = require("class-transformer");
16
16
  const enums_1 = require("../enums");
17
+ /**
18
+ * 审计日志查询DTO
19
+ */
17
20
  class AuditLogQueryDto {
18
21
  constructor() {
19
22
  this.page = 1;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * 开始事务DTO
3
+ */
1
4
  export declare class BeginTransactionDto {
2
5
  description: string;
3
6
  }
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BeginTransactionDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
+ /**
16
+ * 开始事务DTO
17
+ */
15
18
  class BeginTransactionDto {
16
19
  }
17
20
  exports.BeginTransactionDto = BeginTransactionDto;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * 比较实体DTO
3
+ */
1
4
  export declare class CompareEntitiesDto {
2
5
  entityType: string;
3
6
  entityId: string;
@@ -13,6 +13,9 @@ exports.CompareEntitiesDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const class_transformer_1 = require("class-transformer");
16
+ /**
17
+ * 比较实体DTO
18
+ */
16
19
  class CompareEntitiesDto {
17
20
  }
18
21
  exports.CompareEntitiesDto = CompareEntitiesDto;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * 预检查恢复DTO
3
+ */
1
4
  export declare class PreCheckRestoreDto {
2
5
  entityType: string;
3
6
  entityId: string;
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PreCheckRestoreDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
+ /**
16
+ * 预检查恢复DTO
17
+ */
15
18
  class PreCheckRestoreDto {
16
19
  }
17
20
  exports.PreCheckRestoreDto = PreCheckRestoreDto;
@@ -1,5 +1,8 @@
1
1
  import { RecoveryStrategy } from '../enums';
2
2
  import { RestoreOptions } from '../interfaces';
3
+ /**
4
+ * 恢复实体DTO
5
+ */
3
6
  export declare class RestoreEntityDto {
4
7
  entityType: string;
5
8
  entityId: string;
@@ -13,6 +13,9 @@ exports.RestoreEntityDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const enums_1 = require("../enums");
16
+ /**
17
+ * 恢复实体DTO
18
+ */
16
19
  class RestoreEntityDto {
17
20
  constructor() {
18
21
  this.strategy = enums_1.RecoveryStrategy.ENTITY_ONLY;
@@ -1,5 +1,8 @@
1
1
  import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
2
  import { AuditOperation } from '../enums';
3
+ /**
4
+ * 实体审计日志
5
+ */
3
6
  export declare class EntityAuditLogEntity extends AbstractUuidPrimaryEntity {
4
7
  entityType: string;
5
8
  entityId: string;
@@ -13,6 +13,9 @@ exports.EntityAuditLogEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const abstract_entity_1 = require("../../common/abstract.entity");
15
15
  const enums_1 = require("../enums");
16
+ /**
17
+ * 实体审计日志
18
+ */
16
19
  let EntityAuditLogEntity = class EntityAuditLogEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
20
  };
18
21
  exports.EntityAuditLogEntity = EntityAuditLogEntity;
@@ -1,5 +1,8 @@
1
1
  import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
2
  import { AuditOperation, TransactionStatus } from '../enums';
3
+ /**
4
+ * 实体事务
5
+ */
3
6
  export declare class EntityTransactionEntity extends AbstractUuidPrimaryEntity {
4
7
  description: string;
5
8
  status: TransactionStatus;
@@ -13,6 +13,9 @@ exports.EntityTransactionEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const abstract_entity_1 = require("../../common/abstract.entity");
15
15
  const enums_1 = require("../enums");
16
+ /**
17
+ * 实体事务
18
+ */
16
19
  let EntityTransactionEntity = class EntityTransactionEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
20
  };
18
21
  exports.EntityTransactionEntity = EntityTransactionEntity;
@@ -1,6 +1,10 @@
1
1
  import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
2
  import { EntityTransactionEntity } from './entity-transaction.entity';
3
3
  import { RollbackAction } from '../interfaces';
4
+ /**
5
+ * 手动操作记录表
6
+ * 用于记录跨实体的复杂业务操作
7
+ */
4
8
  export declare class ManualOperationLogEntity extends AbstractUuidPrimaryEntity {
5
9
  transactionId: string;
6
10
  operationTemplateKey: string;
@@ -13,6 +13,10 @@ exports.ManualOperationLogEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const abstract_entity_1 = require("../../common/abstract.entity");
15
15
  const entity_transaction_entity_1 = require("./entity-transaction.entity");
16
+ /**
17
+ * 手动操作记录表
18
+ * 用于记录跨实体的复杂业务操作
19
+ */
16
20
  let ManualOperationLogEntity = class ManualOperationLogEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
21
  };
18
22
  exports.ManualOperationLogEntity = ManualOperationLogEntity;
@@ -1,5 +1,9 @@
1
1
  import { AbstractUuidPrimaryEntity } from '../../common/abstract.entity';
2
2
  import { AuditOperation } from '../enums';
3
+ /**
4
+ * 操作模板配置表
5
+ * 用于存储多语言操作描述模板
6
+ */
3
7
  export declare class OperationTemplateEntity extends AbstractUuidPrimaryEntity {
4
8
  key: string;
5
9
  entityName: string;
@@ -13,6 +13,10 @@ exports.OperationTemplateEntity = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const abstract_entity_1 = require("../../common/abstract.entity");
15
15
  const enums_1 = require("../enums");
16
+ /**
17
+ * 操作模板配置表
18
+ * 用于存储多语言操作描述模板
19
+ */
16
20
  let OperationTemplateEntity = class OperationTemplateEntity extends abstract_entity_1.AbstractUuidPrimaryEntity {
17
21
  };
18
22
  exports.OperationTemplateEntity = OperationTemplateEntity;
@@ -1,24 +1,39 @@
1
+ /**
2
+ * 审计操作类型
3
+ */
1
4
  export declare enum AuditOperation {
2
5
  CREATE = "CREATE",
3
6
  UPDATE = "UPDATE",
4
7
  DELETE = "DELETE",
5
8
  RESTORE = "RESTORE"
6
9
  }
10
+ /**
11
+ * 事务状态
12
+ */
7
13
  export declare enum TransactionStatus {
8
14
  PENDING = "PENDING",
9
15
  COMMITTED = "COMMITTED",
10
16
  ROLLED_BACK = "ROLLED_BACK"
11
17
  }
18
+ /**
19
+ * 恢复策略
20
+ */
12
21
  export declare enum RecoveryStrategy {
13
22
  ENTITY_ONLY = "ENTITY_ONLY",
14
23
  TRANSACTION_RESTORE = "TRANSACTION_RESTORE",
15
24
  DEPENDENCY_GRAPH = "DEPENDENCY_GRAPH"
16
25
  }
26
+ /**
27
+ * 记录策略
28
+ */
17
29
  export declare enum RecordStrategy {
18
- FULL = "FULL",
19
- DIFF_ONLY = "DIFF_ONLY",
30
+ FULL = "FULL",// 记录完整变更
31
+ DIFF_ONLY = "DIFF_ONLY",// 仅记录差异
20
32
  DISABLED = "DISABLED"
21
33
  }
34
+ /**
35
+ * 脱敏策略
36
+ */
22
37
  export declare enum MaskingStrategy {
23
38
  NONE = "NONE",
24
39
  HASH = "HASH",
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MaskingStrategy = exports.RecordStrategy = exports.RecoveryStrategy = exports.TransactionStatus = exports.AuditOperation = void 0;
4
+ /**
5
+ * 审计操作类型
6
+ */
4
7
  var AuditOperation;
5
8
  (function (AuditOperation) {
6
9
  AuditOperation["CREATE"] = "CREATE";
@@ -8,24 +11,36 @@ var AuditOperation;
8
11
  AuditOperation["DELETE"] = "DELETE";
9
12
  AuditOperation["RESTORE"] = "RESTORE";
10
13
  })(AuditOperation || (exports.AuditOperation = AuditOperation = {}));
14
+ /**
15
+ * 事务状态
16
+ */
11
17
  var TransactionStatus;
12
18
  (function (TransactionStatus) {
13
19
  TransactionStatus["PENDING"] = "PENDING";
14
20
  TransactionStatus["COMMITTED"] = "COMMITTED";
15
21
  TransactionStatus["ROLLED_BACK"] = "ROLLED_BACK";
16
22
  })(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
23
+ /**
24
+ * 恢复策略
25
+ */
17
26
  var RecoveryStrategy;
18
27
  (function (RecoveryStrategy) {
19
28
  RecoveryStrategy["ENTITY_ONLY"] = "ENTITY_ONLY";
20
29
  RecoveryStrategy["TRANSACTION_RESTORE"] = "TRANSACTION_RESTORE";
21
30
  RecoveryStrategy["DEPENDENCY_GRAPH"] = "DEPENDENCY_GRAPH";
22
31
  })(RecoveryStrategy || (exports.RecoveryStrategy = RecoveryStrategy = {}));
32
+ /**
33
+ * 记录策略
34
+ */
23
35
  var RecordStrategy;
24
36
  (function (RecordStrategy) {
25
37
  RecordStrategy["FULL"] = "FULL";
26
38
  RecordStrategy["DIFF_ONLY"] = "DIFF_ONLY";
27
39
  RecordStrategy["DISABLED"] = "DISABLED";
28
40
  })(RecordStrategy || (exports.RecordStrategy = RecordStrategy = {}));
41
+ /**
42
+ * 脱敏策略
43
+ */
29
44
  var MaskingStrategy;
30
45
  (function (MaskingStrategy) {
31
46
  MaskingStrategy["NONE"] = "NONE";