@nest-omni/core 4.1.3-20 → 4.1.3-22

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 (98) hide show
  1. package/audit/audit.module.d.ts +1 -0
  2. package/audit/audit.module.js +5 -3
  3. package/audit/controllers/audit.controller.d.ts +3 -11
  4. package/audit/controllers/audit.controller.js +12 -19
  5. package/audit/decorators/audit-operation.decorator.d.ts +0 -7
  6. package/audit/decorators/audit-operation.decorator.js +0 -7
  7. package/audit/dto/audit-action-query.dto.d.ts +13 -0
  8. package/audit/dto/audit-action-query.dto.js +77 -0
  9. package/audit/dto/index.d.ts +1 -0
  10. package/audit/dto/index.js +1 -0
  11. package/audit/entities/entity-audit-log.entity.d.ts +1 -4
  12. package/audit/entities/entity-audit-log.entity.js +1 -17
  13. package/audit/entities/manual-operation-log.entity.d.ts +0 -2
  14. package/audit/entities/manual-operation-log.entity.js +0 -8
  15. package/audit/enums/audit.enums.d.ts +0 -8
  16. package/audit/enums/audit.enums.js +1 -10
  17. package/audit/examples/decorator-value-mapping.example.d.ts +70 -0
  18. package/audit/examples/decorator-value-mapping.example.js +414 -0
  19. package/audit/index.d.ts +1 -0
  20. package/audit/index.js +5 -1
  21. package/audit/interceptors/audit.interceptor.d.ts +1 -0
  22. package/audit/interceptors/audit.interceptor.js +19 -11
  23. package/audit/interfaces/audit.interfaces.d.ts +2 -17
  24. package/audit/services/audit-context.service.d.ts +9 -0
  25. package/audit/services/entity-audit.service.d.ts +65 -24
  26. package/audit/services/entity-audit.service.js +280 -93
  27. package/audit/services/manual-audit-log.service.d.ts +0 -1
  28. package/audit/services/manual-audit-log.service.js +1 -3
  29. package/audit/subscribers/entity-audit.subscriber.d.ts +1 -0
  30. package/audit/subscribers/entity-audit.subscriber.js +22 -5
  31. package/cache/cache.module.d.ts +7 -2
  32. package/cache/cache.module.js +9 -7
  33. package/cache/cache.service.d.ts +4 -4
  34. package/cache/cache.service.js +5 -5
  35. package/cache/entities/index.d.ts +1 -0
  36. package/cache/entities/index.js +17 -0
  37. package/cache/entities/typeorm-cache.entity.d.ts +71 -0
  38. package/cache/entities/typeorm-cache.entity.js +110 -0
  39. package/cache/index.d.ts +2 -1
  40. package/cache/index.js +19 -2
  41. package/cache/providers/index.d.ts +2 -1
  42. package/cache/providers/index.js +2 -1
  43. package/cache/providers/lrucache.provider.d.ts +76 -0
  44. package/cache/providers/lrucache.provider.js +226 -0
  45. package/cache/providers/typeorm-cache.provider.d.ts +211 -0
  46. package/cache/providers/typeorm-cache.provider.js +483 -0
  47. package/common/boilerplate.polyfill.d.ts +1 -0
  48. package/common/boilerplate.polyfill.js +17 -0
  49. package/common/helpers/validation-metadata-helper.d.ts +55 -0
  50. package/common/helpers/validation-metadata-helper.js +60 -0
  51. package/common/index.d.ts +1 -0
  52. package/common/index.js +4 -0
  53. package/decorators/field.decorators.d.ts +71 -2
  54. package/decorators/field.decorators.js +147 -18
  55. package/decorators/transform.decorators.d.ts +0 -2
  56. package/decorators/transform.decorators.js +0 -23
  57. package/filters/bad-request.filter.js +19 -4
  58. package/http-client/utils/context-extractor.util.js +2 -0
  59. package/ip-filter/constants.d.ts +21 -0
  60. package/ip-filter/constants.js +24 -0
  61. package/ip-filter/decorators/index.d.ts +1 -0
  62. package/ip-filter/decorators/index.js +17 -0
  63. package/ip-filter/decorators/ip-filter.decorator.d.ts +58 -0
  64. package/ip-filter/decorators/ip-filter.decorator.js +79 -0
  65. package/ip-filter/guards/index.d.ts +1 -0
  66. package/ip-filter/guards/index.js +17 -0
  67. package/ip-filter/guards/ip-filter.guard.d.ts +62 -0
  68. package/ip-filter/guards/ip-filter.guard.js +174 -0
  69. package/ip-filter/index.d.ts +7 -0
  70. package/ip-filter/index.js +23 -0
  71. package/ip-filter/interfaces/index.d.ts +4 -0
  72. package/ip-filter/interfaces/index.js +20 -0
  73. package/ip-filter/interfaces/ip-filter-async-options.interface.d.ts +15 -0
  74. package/ip-filter/interfaces/ip-filter-async-options.interface.js +2 -0
  75. package/ip-filter/interfaces/ip-filter-metadata.interface.d.ts +26 -0
  76. package/ip-filter/interfaces/ip-filter-metadata.interface.js +2 -0
  77. package/ip-filter/interfaces/ip-filter-options.interface.d.ts +34 -0
  78. package/ip-filter/interfaces/ip-filter-options.interface.js +2 -0
  79. package/ip-filter/interfaces/ip-rule.interface.d.ts +36 -0
  80. package/ip-filter/interfaces/ip-rule.interface.js +2 -0
  81. package/ip-filter/ip-filter.module.d.ts +55 -0
  82. package/ip-filter/ip-filter.module.js +105 -0
  83. package/ip-filter/services/index.d.ts +1 -0
  84. package/ip-filter/services/index.js +17 -0
  85. package/ip-filter/services/ip-filter.service.d.ts +92 -0
  86. package/ip-filter/services/ip-filter.service.js +238 -0
  87. package/ip-filter/utils/index.d.ts +1 -0
  88. package/ip-filter/utils/index.js +17 -0
  89. package/ip-filter/utils/ip-utils.d.ts +61 -0
  90. package/ip-filter/utils/ip-utils.js +162 -0
  91. package/package.json +23 -24
  92. package/providers/context.provider.d.ts +9 -0
  93. package/providers/context.provider.js +13 -0
  94. package/setup/bootstrap.setup.d.ts +1 -1
  95. package/setup/bootstrap.setup.js +1 -1
  96. package/shared/service-registry.module.js +0 -1
  97. package/cache/providers/memory-cache.provider.d.ts +0 -69
  98. package/cache/providers/memory-cache.provider.js +0 -237
@@ -1,11 +1,35 @@
1
1
  import { Repository, EntityManager } from 'typeorm';
2
2
  import { EntityAuditLogEntity, EntityTransactionEntity, ManualOperationLogEntity, AuditActionSummaryEntity } from '../entities';
3
3
  import { AuditOperation } from '../enums';
4
- import { AuditConfig, IAuditStrategy, EntityDifference, RestoreOptions, RestoreResult, PreCheckResult, ManualOperationData, ChangeDetail, RollbackAction } from '../interfaces';
4
+ import { AuditConfig, IAuditStrategy, EntityDifference, RestoreOptions, RestoreResult, PreCheckResult, ManualOperationData, ChangeDetail } from '../interfaces';
5
5
  import { AuditContextService } from './audit-context.service';
6
6
  import { MultiDatabaseService } from './multi-database.service';
7
+ import { OperationDescriptionService } from './operation-description.service';
7
8
  import { PageDto } from '../../common/dto';
8
9
  import { AuditLogQueryDto } from '../dto';
10
+ /**
11
+ * 审计配置常量
12
+ */
13
+ export declare const AUDIT_CONSTANTS: {
14
+ /** 深度比较的最大深度限制 */
15
+ readonly MAX_DIFF_DEPTH: 5;
16
+ /** 深度比较的最大键数量限制 */
17
+ readonly MAX_KEYS: 100;
18
+ /** 描述的最大长度 */
19
+ readonly MAX_DESCRIPTION_LENGTH: 1000;
20
+ /** 哈希截断长度 */
21
+ readonly HASH_TRUNCATE_LENGTH: 64;
22
+ /** 部分掩码显示的字符数 */
23
+ readonly PARTIAL_MASK_CHARS: 2;
24
+ };
25
+ /**
26
+ * 注册实体类到注册表
27
+ */
28
+ export declare function registerEntityClass(entityType: string, entityClass: any): void;
29
+ /**
30
+ * 获取实体类
31
+ */
32
+ export declare function getEntityClass(entityType: string): any | undefined;
9
33
  /**
10
34
  * 实体审计服务
11
35
  */
@@ -19,8 +43,9 @@ export declare class EntityAuditService {
19
43
  private readonly auditStrategy;
20
44
  private readonly config?;
21
45
  private readonly actionSummaryRepository?;
46
+ private readonly descriptionService?;
22
47
  private readonly auditConnectionName;
23
- constructor(auditLogRepository: Repository<EntityAuditLogEntity>, transactionRepository: Repository<EntityTransactionEntity>, manualOperationRepository: Repository<ManualOperationLogEntity>, entityManager: EntityManager, contextService: AuditContextService, multiDbService: MultiDatabaseService, auditStrategy?: IAuditStrategy, config?: AuditConfig, auditConnectionName?: string, actionSummaryRepository?: Repository<AuditActionSummaryEntity>);
48
+ constructor(auditLogRepository: Repository<EntityAuditLogEntity>, transactionRepository: Repository<EntityTransactionEntity>, manualOperationRepository: Repository<ManualOperationLogEntity>, entityManager: EntityManager, contextService: AuditContextService, multiDbService: MultiDatabaseService, auditStrategy?: IAuditStrategy, config?: AuditConfig, auditConnectionName?: string, actionSummaryRepository?: Repository<AuditActionSummaryEntity>, descriptionService?: OperationDescriptionService);
24
49
  /**
25
50
  * 记录实体变更
26
51
  */
@@ -42,13 +67,13 @@ export declare class EntityAuditService {
42
67
  */
43
68
  restoreEntity(entityType: string, entityId: string, auditLogId: string, options?: RestoreOptions): Promise<RestoreResult>;
44
69
  /**
45
- * 计算变更字段
70
+ * 计算变更字段(支持嵌套路径)
46
71
  */
47
72
  private calculateChangedFields;
48
73
  /**
49
- * 计算变更字段路径
74
+ * 生成字段级别的变更详情(前后对比,支持嵌套路径和装饰器值映射)
50
75
  */
51
- private calculateChangedFieldPaths;
76
+ private generateChangeDetails;
52
77
  /**
53
78
  * 深度比较对象
54
79
  */
@@ -81,10 +106,6 @@ export declare class EntityAuditService {
81
106
  * 部分掩码值
82
107
  */
83
108
  private partialMaskValue;
84
- /**
85
- * 生成哈希链
86
- */
87
- private generateHashChain;
88
109
  /**
89
110
  * 生成描述(支持多语言)
90
111
  * @param operation 操作类型
@@ -94,6 +115,10 @@ export declare class EntityAuditService {
94
115
  * @param language 语言(默认中文)
95
116
  * @param entityClass 实体类(可选,用于获取实体标签)
96
117
  */
118
+ /**
119
+ * 使用模板生成描述(优先使用 OperationDescriptionService)
120
+ */
121
+ private generateDescriptionFromTemplate;
97
122
  private generateDescription;
98
123
  /**
99
124
  * 检测冲突
@@ -114,7 +139,6 @@ export declare class EntityAuditService {
114
139
  operationTemplateKey?: string;
115
140
  descriptionParams?: Record<string, any>;
116
141
  changeDetails?: ChangeDetail[];
117
- rollbackActions?: RollbackAction[];
118
142
  metadata?: Record<string, any>;
119
143
  }): Promise<EntityAuditLogEntity | null>;
120
144
  /**
@@ -179,11 +203,14 @@ export declare class EntityAuditService {
179
203
  endTime?: Date;
180
204
  page?: number;
181
205
  limit?: number;
206
+ keyword?: string;
182
207
  }): Promise<PageDto<AuditActionSummaryEntity>>;
183
208
  /**
184
209
  * 查询单个审计动作的详细信息(包含关联的实体变更)
210
+ * @param actionId 动作ID
211
+ * @param language 语言代码 (zh/en/ja),默认 zh
185
212
  */
186
- getAuditActionDetail(actionId: string): Promise<{
213
+ getAuditActionDetail(actionId: string, language?: string): Promise<{
187
214
  summary: {
188
215
  id: string;
189
216
  actionName: string;
@@ -216,15 +243,7 @@ export declare class EntityAuditService {
216
243
  createdAt: Date;
217
244
  oldValue: Record<string, any>;
218
245
  newValue: Record<string, any>;
219
- fieldChanges: {
220
- field: string;
221
- fieldLabel: string;
222
- oldValue: any;
223
- newValue: any;
224
- changeType: "added" | "removed" | "modified" | "unchanged";
225
- displayOldValue?: string;
226
- displayNewValue?: string;
227
- }[];
246
+ changeDetails: ChangeDetail[];
228
247
  changedFieldsCount: number;
229
248
  changedFields: string[];
230
249
  }[];
@@ -240,6 +259,32 @@ export declare class EntityAuditService {
240
259
  }[];
241
260
  };
242
261
  }>;
262
+ /**
263
+ * 生成本地化的描述文本
264
+ */
265
+ private generateLocalizedDescription;
266
+ /**
267
+ * 替换模板中的占位符
268
+ * @param template 模板字符串,如 "创建了产品 {name},价格 ¥{price}"
269
+ * @param params 参数对象,如 { name: "iPhone", price: 999 }
270
+ * @returns 替换后的字符串
271
+ */
272
+ private replaceTemplatePlaceholders;
273
+ /**
274
+ * 获取嵌套对象的值
275
+ * @param obj 对象
276
+ * @param path 路径,如 "user.name" 或 "user.profile.age"
277
+ * @returns 值或 undefined
278
+ */
279
+ private getNestedValue;
280
+ /**
281
+ * 本地化 changeDetails(根据语言转换 fieldLabel 和 displayValue)
282
+ */
283
+ private localizeChangeDetails;
284
+ /**
285
+ * 获取操作标签(支持多语言)
286
+ */
287
+ private getOperationLabel;
243
288
  /**
244
289
  * 分析字段变化(支持多语言)
245
290
  * @param oldValue 旧值
@@ -253,10 +298,6 @@ export declare class EntityAuditService {
253
298
  * 格式化显示值
254
299
  */
255
300
  private formatDisplayValue;
256
- /**
257
- * 获取操作标签
258
- */
259
- private getOperationLabel;
260
301
  /**
261
302
  * 按字段分组统计
262
303
  */