@carllee1983/dbcli 1.44.1 → 1.45.0

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/dist/core.d.ts CHANGED
@@ -1436,6 +1436,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1436
1436
  "admin"
1437
1437
  ]>>;
1438
1438
  envFile: z.ZodOptional<z.ZodString>;
1439
+ environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1439
1440
  }, "strip", z.ZodTypeAny, {
1440
1441
  password: string | {
1441
1442
  $env: string;
@@ -1455,6 +1456,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1455
1456
  };
1456
1457
  permission: "admin" | "query-only" | "read-write" | "data-admin";
1457
1458
  envFile?: string | undefined;
1459
+ environment?: string | undefined;
1458
1460
  }, {
1459
1461
  user: string | {
1460
1462
  $env: string;
@@ -1474,6 +1476,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1474
1476
  } | undefined;
1475
1477
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1476
1478
  envFile?: string | undefined;
1479
+ environment?: string | undefined;
1477
1480
  }>,
1478
1481
  z.ZodObject<{
1479
1482
  system: z.ZodLiteral<"mongodb">;
@@ -1545,6 +1548,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1545
1548
  "admin"
1546
1549
  ]>>;
1547
1550
  envFile: z.ZodOptional<z.ZodString>;
1551
+ environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1548
1552
  }, "strip", z.ZodTypeAny, {
1549
1553
  password: string | {
1550
1554
  $env: string;
@@ -1567,6 +1571,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1567
1571
  $env: string;
1568
1572
  } | undefined;
1569
1573
  envFile?: string | undefined;
1574
+ environment?: string | undefined;
1570
1575
  }, {
1571
1576
  system: "mongodb";
1572
1577
  password?: string | {
@@ -1589,6 +1594,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1589
1594
  } | undefined;
1590
1595
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1591
1596
  envFile?: string | undefined;
1597
+ environment?: string | undefined;
1592
1598
  }>,
1593
1599
  z.ZodObject<{
1594
1600
  system: z.ZodLiteral<"redis">;
@@ -1650,6 +1656,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1650
1656
  "admin"
1651
1657
  ]>>;
1652
1658
  envFile: z.ZodOptional<z.ZodString>;
1659
+ environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1653
1660
  }, "strip", z.ZodTypeAny, {
1654
1661
  password: string | {
1655
1662
  $env: string;
@@ -1669,6 +1676,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1669
1676
  };
1670
1677
  permission: "admin" | "query-only" | "read-write" | "data-admin";
1671
1678
  envFile?: string | undefined;
1679
+ environment?: string | undefined;
1672
1680
  }, {
1673
1681
  system: "redis";
1674
1682
  host: string | {
@@ -1688,6 +1696,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1688
1696
  } | undefined;
1689
1697
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1690
1698
  envFile?: string | undefined;
1699
+ environment?: string | undefined;
1691
1700
  }>,
1692
1701
  z.ZodObject<{
1693
1702
  system: z.ZodLiteral<"elasticsearch">;
@@ -1776,6 +1785,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1776
1785
  "admin"
1777
1786
  ]>>;
1778
1787
  envFile: z.ZodOptional<z.ZodString>;
1788
+ environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1779
1789
  }, "strip", z.ZodTypeAny, {
1780
1790
  password: string | {
1781
1791
  $env: string;
@@ -1805,6 +1815,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1805
1815
  } | undefined;
1806
1816
  caPath?: string | undefined;
1807
1817
  envFile?: string | undefined;
1818
+ environment?: string | undefined;
1808
1819
  }, {
1809
1820
  system: "elasticsearch";
1810
1821
  password?: string | {
@@ -1834,6 +1845,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1834
1845
  caPath?: string | undefined;
1835
1846
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1836
1847
  envFile?: string | undefined;
1848
+ environment?: string | undefined;
1837
1849
  }>
1838
1850
  ]>>, Record<string, {
1839
1851
  password: string | {
@@ -1854,6 +1866,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1854
1866
  };
1855
1867
  permission: "admin" | "query-only" | "read-write" | "data-admin";
1856
1868
  envFile?: string | undefined;
1869
+ environment?: string | undefined;
1857
1870
  } | {
1858
1871
  password: string | {
1859
1872
  $env: string;
@@ -1876,6 +1889,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1876
1889
  $env: string;
1877
1890
  } | undefined;
1878
1891
  envFile?: string | undefined;
1892
+ environment?: string | undefined;
1879
1893
  } | {
1880
1894
  password: string | {
1881
1895
  $env: string;
@@ -1895,6 +1909,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1895
1909
  };
1896
1910
  permission: "admin" | "query-only" | "read-write" | "data-admin";
1897
1911
  envFile?: string | undefined;
1912
+ environment?: string | undefined;
1898
1913
  } | {
1899
1914
  password: string | {
1900
1915
  $env: string;
@@ -1924,6 +1939,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1924
1939
  } | undefined;
1925
1940
  caPath?: string | undefined;
1926
1941
  envFile?: string | undefined;
1942
+ environment?: string | undefined;
1927
1943
  }>, Record<string, {
1928
1944
  user: string | {
1929
1945
  $env: string;
@@ -1943,6 +1959,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1943
1959
  } | undefined;
1944
1960
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1945
1961
  envFile?: string | undefined;
1962
+ environment?: string | undefined;
1946
1963
  } | {
1947
1964
  system: "mongodb";
1948
1965
  password?: string | {
@@ -1965,6 +1982,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1965
1982
  } | undefined;
1966
1983
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1967
1984
  envFile?: string | undefined;
1985
+ environment?: string | undefined;
1968
1986
  } | {
1969
1987
  system: "redis";
1970
1988
  host: string | {
@@ -1984,6 +2002,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1984
2002
  } | undefined;
1985
2003
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1986
2004
  envFile?: string | undefined;
2005
+ environment?: string | undefined;
1987
2006
  } | {
1988
2007
  system: "elasticsearch";
1989
2008
  password?: string | {
@@ -2013,6 +2032,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2013
2032
  caPath?: string | undefined;
2014
2033
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2015
2034
  envFile?: string | undefined;
2035
+ environment?: string | undefined;
2016
2036
  }>>;
2017
2037
  schema: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
2018
2038
  schemas: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>;
@@ -2129,6 +2149,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2129
2149
  };
2130
2150
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2131
2151
  envFile?: string | undefined;
2152
+ environment?: string | undefined;
2132
2153
  } | {
2133
2154
  password: string | {
2134
2155
  $env: string;
@@ -2151,6 +2172,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2151
2172
  $env: string;
2152
2173
  } | undefined;
2153
2174
  envFile?: string | undefined;
2175
+ environment?: string | undefined;
2154
2176
  } | {
2155
2177
  password: string | {
2156
2178
  $env: string;
@@ -2170,6 +2192,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2170
2192
  };
2171
2193
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2172
2194
  envFile?: string | undefined;
2195
+ environment?: string | undefined;
2173
2196
  } | {
2174
2197
  password: string | {
2175
2198
  $env: string;
@@ -2199,6 +2222,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2199
2222
  } | undefined;
2200
2223
  caPath?: string | undefined;
2201
2224
  envFile?: string | undefined;
2225
+ environment?: string | undefined;
2202
2226
  }>;
2203
2227
  schemas: Record<string, Record<string, any>>;
2204
2228
  redis?: {
@@ -2229,6 +2253,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2229
2253
  } | undefined;
2230
2254
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2231
2255
  envFile?: string | undefined;
2256
+ environment?: string | undefined;
2232
2257
  } | {
2233
2258
  system: "mongodb";
2234
2259
  password?: string | {
@@ -2251,6 +2276,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2251
2276
  } | undefined;
2252
2277
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2253
2278
  envFile?: string | undefined;
2279
+ environment?: string | undefined;
2254
2280
  } | {
2255
2281
  system: "redis";
2256
2282
  host: string | {
@@ -2270,6 +2296,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2270
2296
  } | undefined;
2271
2297
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2272
2298
  envFile?: string | undefined;
2299
+ environment?: string | undefined;
2273
2300
  } | {
2274
2301
  system: "elasticsearch";
2275
2302
  password?: string | {
@@ -2299,6 +2326,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2299
2326
  caPath?: string | undefined;
2300
2327
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2301
2328
  envFile?: string | undefined;
2329
+ environment?: string | undefined;
2302
2330
  }>;
2303
2331
  redis?: {
2304
2332
  mask?: {
@@ -2365,6 +2393,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2365
2393
  };
2366
2394
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2367
2395
  envFile?: string | undefined;
2396
+ environment?: string | undefined;
2368
2397
  } | {
2369
2398
  password: string | {
2370
2399
  $env: string;
@@ -2387,6 +2416,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2387
2416
  $env: string;
2388
2417
  } | undefined;
2389
2418
  envFile?: string | undefined;
2419
+ environment?: string | undefined;
2390
2420
  } | {
2391
2421
  password: string | {
2392
2422
  $env: string;
@@ -2406,6 +2436,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2406
2436
  };
2407
2437
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2408
2438
  envFile?: string | undefined;
2439
+ environment?: string | undefined;
2409
2440
  } | {
2410
2441
  password: string | {
2411
2442
  $env: string;
@@ -2435,6 +2466,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2435
2466
  } | undefined;
2436
2467
  caPath?: string | undefined;
2437
2468
  envFile?: string | undefined;
2469
+ environment?: string | undefined;
2438
2470
  }>;
2439
2471
  schemas: Record<string, Record<string, any>>;
2440
2472
  redis?: {
@@ -2465,6 +2497,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2465
2497
  } | undefined;
2466
2498
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2467
2499
  envFile?: string | undefined;
2500
+ environment?: string | undefined;
2468
2501
  } | {
2469
2502
  system: "mongodb";
2470
2503
  password?: string | {
@@ -2487,6 +2520,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2487
2520
  } | undefined;
2488
2521
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2489
2522
  envFile?: string | undefined;
2523
+ environment?: string | undefined;
2490
2524
  } | {
2491
2525
  system: "redis";
2492
2526
  host: string | {
@@ -2506,6 +2540,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2506
2540
  } | undefined;
2507
2541
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2508
2542
  envFile?: string | undefined;
2543
+ environment?: string | undefined;
2509
2544
  } | {
2510
2545
  system: "elasticsearch";
2511
2546
  password?: string | {
@@ -2535,6 +2570,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2535
2570
  caPath?: string | undefined;
2536
2571
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2537
2572
  envFile?: string | undefined;
2573
+ environment?: string | undefined;
2538
2574
  }>;
2539
2575
  redis?: {
2540
2576
  mask?: {
@@ -2892,6 +2928,7 @@ export interface ResolvedConnection {
2892
2928
  };
2893
2929
  permission: "query-only" | "read-write" | "data-admin" | "admin";
2894
2930
  envFile?: string;
2931
+ environment?: string;
2895
2932
  }
2896
2933
  /**
2897
2934
  * Resolve a named connection from v2 config
@@ -2906,9 +2943,7 @@ export declare function loadConnectionEnv(resolved: ResolvedConnection, basePath
2906
2943
  */
2907
2944
  export declare function readV2Config(path: string): Promise<DbcliConfigV2>;
2908
2945
  /**
2909
- * Write a v2 config to disk atomically (temp file + rename).
2910
- * Writing to a temp file then renaming over the target is an atomic operation
2911
- * on the same filesystem, so a crash mid-write can never leave a corrupt config.
2946
+ * Write a v2 config and its integrity records as one recoverable publication.
2912
2947
  */
2913
2948
  export declare function writeV2Config(path: string, config: DbcliConfigV2): Promise<void>;
2914
2949
  /**
@@ -2960,6 +2995,12 @@ export declare function migrateV1ToV2(v1: DbcliConfig$1): DbcliConfigV2;
2960
2995
  /** 新增或就地覆寫同名連線(immutable)。非機密欄存字面值,password 存 {$env} 參照 +
2961
2996
  * per-connection envFile。編輯時保留既有 permission;新建預設 'query-only'。 */
2962
2997
  export declare function upsertConnection(config: DbcliConfigV2, input: ConnectionInput): DbcliConfigV2;
2998
+ /**
2999
+ * Resolve the per-user dbcli root lazily so embedders and tests can provide an
3000
+ * isolated config home without reloading the module. `DBCLI_CONFIG_HOME` is a
3001
+ * dbcli-specific override; otherwise preserve the existing `~/.config` path.
3002
+ */
3003
+ export declare function getDbcliConfigHome(): string;
2963
3004
  interface ProjectConfigBinding {
2964
3005
  version: 3;
2965
3006
  binding: {
@@ -2969,6 +3010,10 @@ interface ProjectConfigBinding {
2969
3010
  createdAt: string;
2970
3011
  };
2971
3012
  }
3013
+ /** Canonical user-global configuration directory (`~/.config/dbcli`). */
3014
+ export declare function getGlobalConfigPath(): string;
3015
+ /** Whether a path points at the canonical user-global configuration directory. */
3016
+ export declare function isGlobalConfigPath(path: string): boolean;
2972
3017
  export declare function getProjectStoragePath(projectPath: string): string;
2973
3018
  export declare function resolveConfigStoragePath(path: string): Promise<string>;
2974
3019
  export declare function writeProjectBinding(projectPath: string, storagePath?: string): Promise<ProjectConfigBinding>;