@h-ai/reldb 0.1.0-alpha.18 → 0.1.0-alpha.19

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.
package/README.md CHANGED
@@ -49,6 +49,8 @@ const user = await userCrud.findById(1)
49
49
  await reldb.close()
50
50
  ```
51
51
 
52
+ `reldb.config` 返回的是**脱敏后的配置快照**:数据库 `password` 与 URL 内嵌凭证会自动隐藏,便于排查状态但不应用于回放原始连接信息。
53
+
52
54
  ## 配置
53
55
 
54
56
  支持连接字符串(`url`)或分字段(`host/port/database/user/password`)。
package/dist/index.d.ts CHANGED
@@ -1026,7 +1026,7 @@ interface ReldbFunctions {
1026
1026
  readonly crud: CrudManager;
1027
1027
  /** 事务管理器 */
1028
1028
  readonly tx: TxManager;
1029
- /** 当前数据库配置(未初始化时为 null) */
1029
+ /** 当前数据库脱敏配置快照(未初始化时为 null) */
1030
1030
  readonly config: ReldbConfig | null;
1031
1031
  /** 是否已初始化 */
1032
1032
  readonly isInitialized: boolean;
package/dist/index.js CHANGED
@@ -399,12 +399,13 @@ var BaseReldbCrudRepository = class {
399
399
  */
400
400
  mapRow(row) {
401
401
  const result = {};
402
+ const resultRecord = result;
402
403
  for (const field of this.fields) {
403
404
  if (!field.select) {
404
405
  continue;
405
406
  }
406
407
  const value = this.fromDbValue(row[field.columnName], field.def);
407
- result[field.fieldName] = value;
408
+ resultRecord[field.fieldName] = value;
408
409
  }
409
410
  return result;
410
411
  }
@@ -2490,6 +2491,9 @@ function createSqliteProvider() {
2490
2491
 
2491
2492
  // src/reldb-main.ts
2492
2493
  var logger5 = core.logger.child({ module: "reldb", scope: "main" });
2494
+ function sanitizeReldbConfig(config) {
2495
+ return core.sanitize.sanitizeSensitiveFields(config);
2496
+ }
2493
2497
  var currentProvider = null;
2494
2498
  var currentConfig = null;
2495
2499
  var currentJsonOps = null;
@@ -2593,9 +2597,9 @@ var reldb = {
2593
2597
  get tx() {
2594
2598
  return currentProvider?.tx ?? notInitializedTx;
2595
2599
  },
2596
- /** 获取当前配置(未初始化时为 null) */
2600
+ /** 获取当前脱敏后的配置快照(未初始化时为 null) */
2597
2601
  get config() {
2598
- return currentConfig;
2602
+ return currentConfig ? sanitizeReldbConfig(currentConfig) : null;
2599
2603
  },
2600
2604
  /** 检查是否已初始化 */
2601
2605
  get isInitialized() {