@carllee1983/dbcli 1.56.0 → 1.58.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
@@ -410,8 +410,17 @@ export declare class AdapterFactory {
410
410
  * Used to wrap the execution result and metadata of data modification operations
411
411
  */
412
412
  export interface DataExecutionResult {
413
- /** Execution status: success or error */
414
- status: "success" | "error";
413
+ /**
414
+ * What became of the operation.
415
+ *
416
+ * `success` means the statement ran — `rows_affected` may still be 0 if it
417
+ * matched nothing. `cancelled` means a user declined at the confirmation.
418
+ * `dry_run` means it was previewed and deliberately not run. The last two
419
+ * were reported as `success` with `rows_affected: 0` until 2.0.0, which made
420
+ * them indistinguishable from a write that matched no rows and caused the
421
+ * audit log to record declined operations as writes that happened.
422
+ */
423
+ status: "success" | "error" | "cancelled" | "dry_run";
415
424
  /** Type of operation executed */
416
425
  operation: "insert" | "update" | "delete";
417
426
  /** Number of rows affected */
@@ -434,7 +443,53 @@ export interface DataExecutionOptions {
434
443
  force?: boolean;
435
444
  /** Verbose output */
436
445
  verbose?: boolean;
446
+ /**
447
+ * How to ask the caller's user whether to proceed.
448
+ *
449
+ * Core states what is about to happen; the caller decides how to present it
450
+ * and how to collect an answer. Required whenever a mutation would execute
451
+ * without `force`, and absent by design rather than defaulted: silently
452
+ * proceeding unconfirmed, or silently declining, are both worse than saying
453
+ * that nobody was available to ask.
454
+ */
455
+ confirm?: MutationConfirmer;
456
+ }
457
+ /**
458
+ * Everything a caller needs to describe a pending mutation to its user.
459
+ */
460
+ export interface MutationConfirmationRequest {
461
+ operation: DataExecutionResult["operation"];
462
+ /**
463
+ * Which engine will run it.
464
+ *
465
+ * Only presentation depends on this: a MongoDB shell line or a Redis command
466
+ * announced as "Generated SQL" would be a lie about what is being approved,
467
+ * and approving the wrong thing is the failure this whole prompt exists to
468
+ * prevent.
469
+ */
470
+ engine: "sql" | "mongodb" | "redis";
471
+ /** The parameterised statement that will run if confirmed */
472
+ sql: string;
473
+ /** Values bound to the statement's placeholders */
474
+ params: (string | number | boolean | null)[];
475
+ /**
476
+ * Whether this operation is irreversible.
477
+ *
478
+ * A flag rather than the warning sentence and the question themselves, which
479
+ * is what this carried first. The division is not "core cannot translate" —
480
+ * `permission-guard` translates the refusal it throws, and so does
481
+ * `blacklist-validator` — it is that core owns facts and the command layer
482
+ * owns presentation. Whether a delete can be undone is a fact. Which sentence
483
+ * a person is shown about it, in what tone, on which stream, is presentation,
484
+ * and a caller embedding the executor should be able to say it in its own
485
+ * product's voice rather than inheriting dbcli's.
486
+ */
487
+ destructive: boolean;
437
488
  }
489
+ /**
490
+ * Returns true to proceed, false to abandon the mutation.
491
+ */
492
+ export type MutationConfirmer = (request: MutationConfirmationRequest) => Promise<boolean>;
438
493
  interface SqlConnectionConfig {
439
494
  system: "postgresql" | "mysql" | "mariadb";
440
495
  host: string | {
@@ -843,6 +898,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
843
898
  }>
844
899
  ]>;
845
900
  }, "strip", z.ZodTypeAny, {
901
+ password: string | {
902
+ $env: string;
903
+ };
846
904
  system: "postgresql" | "mysql" | "mariadb";
847
905
  host: string | {
848
906
  $env: string;
@@ -853,9 +911,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
853
911
  user: string | {
854
912
  $env: string;
855
913
  };
856
- password: string | {
857
- $env: string;
858
- };
859
914
  database: string | {
860
915
  $env: string;
861
916
  };
@@ -968,6 +1023,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
968
1023
  tls: z.ZodOptional<z.ZodBoolean>;
969
1024
  srv: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
970
1025
  }, "strip", z.ZodTypeAny, {
1026
+ password: string | {
1027
+ $env: string;
1028
+ };
971
1029
  system: "mongodb";
972
1030
  host: string | {
973
1031
  $env: string;
@@ -978,9 +1036,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
978
1036
  user: string | {
979
1037
  $env: string;
980
1038
  };
981
- password: string | {
982
- $env: string;
983
- };
984
1039
  database: string | {
985
1040
  $env: string;
986
1041
  };
@@ -999,6 +1054,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
999
1054
  statementTimeout?: number | undefined;
1000
1055
  }, {
1001
1056
  system: "mongodb";
1057
+ password?: string | {
1058
+ $env: string;
1059
+ } | undefined;
1002
1060
  host?: string | {
1003
1061
  $env: string;
1004
1062
  } | undefined;
@@ -1008,9 +1066,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1008
1066
  user?: string | {
1009
1067
  $env: string;
1010
1068
  } | undefined;
1011
- password?: string | {
1012
- $env: string;
1013
- } | undefined;
1014
1069
  database?: string | {
1015
1070
  $env: string;
1016
1071
  } | undefined;
@@ -1083,6 +1138,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
1083
1138
  }>
1084
1139
  ]>>>;
1085
1140
  }, "strip", z.ZodTypeAny, {
1141
+ password: string | {
1142
+ $env: string;
1143
+ };
1086
1144
  system: "redis";
1087
1145
  host: string | {
1088
1146
  $env: string;
@@ -1093,9 +1151,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1093
1151
  user: string | {
1094
1152
  $env: string;
1095
1153
  };
1096
- password: string | {
1097
- $env: string;
1098
- };
1099
1154
  database: string | {
1100
1155
  $env: string;
1101
1156
  };
@@ -1109,10 +1164,10 @@ declare const DbcliConfigSchema: z.ZodObject<{
1109
1164
  port: number | {
1110
1165
  $env: string;
1111
1166
  };
1112
- user?: string | {
1167
+ password?: string | {
1113
1168
  $env: string;
1114
1169
  } | undefined;
1115
- password?: string | {
1170
+ user?: string | {
1116
1171
  $env: string;
1117
1172
  } | undefined;
1118
1173
  database?: string | {
@@ -1203,6 +1258,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
1203
1258
  caPath: z.ZodOptional<z.ZodString>;
1204
1259
  rejectUnauthorized: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1205
1260
  }, "strip", z.ZodTypeAny, {
1261
+ password: string | {
1262
+ $env: string;
1263
+ };
1206
1264
  system: "elasticsearch";
1207
1265
  host: string | {
1208
1266
  $env: string;
@@ -1213,9 +1271,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1213
1271
  user: string | {
1214
1272
  $env: string;
1215
1273
  };
1216
- password: string | {
1217
- $env: string;
1218
- };
1219
1274
  database: string | {
1220
1275
  $env: string;
1221
1276
  };
@@ -1233,6 +1288,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
1233
1288
  caPath?: string | undefined;
1234
1289
  }, {
1235
1290
  system: "elasticsearch";
1291
+ password?: string | {
1292
+ $env: string;
1293
+ } | undefined;
1236
1294
  host?: string | {
1237
1295
  $env: string;
1238
1296
  } | undefined;
@@ -1242,9 +1300,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1242
1300
  user?: string | {
1243
1301
  $env: string;
1244
1302
  } | undefined;
1245
- password?: string | {
1246
- $env: string;
1247
- } | undefined;
1248
1303
  database?: string | {
1249
1304
  $env: string;
1250
1305
  } | undefined;
@@ -1355,7 +1410,11 @@ declare const DbcliConfigSchema: z.ZodObject<{
1355
1410
  max_entries: number;
1356
1411
  };
1357
1412
  };
1413
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
1358
1414
  connection: {
1415
+ password: string | {
1416
+ $env: string;
1417
+ };
1359
1418
  system: "mongodb";
1360
1419
  host: string | {
1361
1420
  $env: string;
@@ -1366,9 +1425,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1366
1425
  user: string | {
1367
1426
  $env: string;
1368
1427
  };
1369
- password: string | {
1370
- $env: string;
1371
- };
1372
1428
  database: string | {
1373
1429
  $env: string;
1374
1430
  };
@@ -1386,6 +1442,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
1386
1442
  timeout?: number | undefined;
1387
1443
  statementTimeout?: number | undefined;
1388
1444
  } | {
1445
+ password: string | {
1446
+ $env: string;
1447
+ };
1389
1448
  system: "postgresql" | "mysql" | "mariadb";
1390
1449
  host: string | {
1391
1450
  $env: string;
@@ -1396,15 +1455,15 @@ declare const DbcliConfigSchema: z.ZodObject<{
1396
1455
  user: string | {
1397
1456
  $env: string;
1398
1457
  };
1399
- password: string | {
1400
- $env: string;
1401
- };
1402
1458
  database: string | {
1403
1459
  $env: string;
1404
1460
  };
1405
1461
  timeout?: number | undefined;
1406
1462
  statementTimeout?: number | undefined;
1407
1463
  } | {
1464
+ password: string | {
1465
+ $env: string;
1466
+ };
1408
1467
  system: "redis";
1409
1468
  host: string | {
1410
1469
  $env: string;
@@ -1415,15 +1474,15 @@ declare const DbcliConfigSchema: z.ZodObject<{
1415
1474
  user: string | {
1416
1475
  $env: string;
1417
1476
  };
1418
- password: string | {
1419
- $env: string;
1420
- };
1421
1477
  database: string | {
1422
1478
  $env: string;
1423
1479
  };
1424
1480
  timeout?: number | undefined;
1425
1481
  statementTimeout?: number | undefined;
1426
1482
  } | {
1483
+ password: string | {
1484
+ $env: string;
1485
+ };
1427
1486
  system: "elasticsearch";
1428
1487
  host: string | {
1429
1488
  $env: string;
@@ -1434,9 +1493,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1434
1493
  user: string | {
1435
1494
  $env: string;
1436
1495
  };
1437
- password: string | {
1438
- $env: string;
1439
- };
1440
1496
  database: string | {
1441
1497
  $env: string;
1442
1498
  };
@@ -1453,7 +1509,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1453
1509
  } | undefined;
1454
1510
  caPath?: string | undefined;
1455
1511
  };
1456
- permission: "admin" | "query-only" | "read-write" | "data-admin";
1457
1512
  metadata: {
1458
1513
  version: string;
1459
1514
  createdAt?: string | undefined;
@@ -1469,6 +1524,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
1469
1524
  }, {
1470
1525
  connection: {
1471
1526
  system: "mongodb";
1527
+ password?: string | {
1528
+ $env: string;
1529
+ } | undefined;
1472
1530
  host?: string | {
1473
1531
  $env: string;
1474
1532
  } | undefined;
@@ -1478,9 +1536,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1478
1536
  user?: string | {
1479
1537
  $env: string;
1480
1538
  } | undefined;
1481
- password?: string | {
1482
- $env: string;
1483
- } | undefined;
1484
1539
  database?: string | {
1485
1540
  $env: string;
1486
1541
  } | undefined;
@@ -1524,10 +1579,10 @@ declare const DbcliConfigSchema: z.ZodObject<{
1524
1579
  port: number | {
1525
1580
  $env: string;
1526
1581
  };
1527
- user?: string | {
1582
+ password?: string | {
1528
1583
  $env: string;
1529
1584
  } | undefined;
1530
- password?: string | {
1585
+ user?: string | {
1531
1586
  $env: string;
1532
1587
  } | undefined;
1533
1588
  database?: string | {
@@ -1537,6 +1592,9 @@ declare const DbcliConfigSchema: z.ZodObject<{
1537
1592
  statementTimeout?: number | undefined;
1538
1593
  } | {
1539
1594
  system: "elasticsearch";
1595
+ password?: string | {
1596
+ $env: string;
1597
+ } | undefined;
1540
1598
  host?: string | {
1541
1599
  $env: string;
1542
1600
  } | undefined;
@@ -1546,9 +1604,6 @@ declare const DbcliConfigSchema: z.ZodObject<{
1546
1604
  user?: string | {
1547
1605
  $env: string;
1548
1606
  } | undefined;
1549
- password?: string | {
1550
- $env: string;
1551
- } | undefined;
1552
1607
  database?: string | {
1553
1608
  $env: string;
1554
1609
  } | undefined;
@@ -1667,6 +1722,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1667
1722
  envFile: z.ZodOptional<z.ZodString>;
1668
1723
  environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1669
1724
  }, "strip", z.ZodTypeAny, {
1725
+ password: string | {
1726
+ $env: string;
1727
+ };
1670
1728
  system: "postgresql" | "mysql" | "mariadb";
1671
1729
  host: string | {
1672
1730
  $env: string;
@@ -1677,9 +1735,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1677
1735
  user: string | {
1678
1736
  $env: string;
1679
1737
  };
1680
- password: string | {
1681
- $env: string;
1682
- };
1683
1738
  database: string | {
1684
1739
  $env: string;
1685
1740
  };
@@ -1706,8 +1761,8 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1706
1761
  $env: string;
1707
1762
  } | undefined;
1708
1763
  timeout?: number | undefined;
1709
- statementTimeout?: number | undefined;
1710
1764
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1765
+ statementTimeout?: number | undefined;
1711
1766
  envFile?: string | undefined;
1712
1767
  environment?: string | undefined;
1713
1768
  }>,
@@ -1807,6 +1862,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1807
1862
  envFile: z.ZodOptional<z.ZodString>;
1808
1863
  environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1809
1864
  }, "strip", z.ZodTypeAny, {
1865
+ password: string | {
1866
+ $env: string;
1867
+ };
1810
1868
  system: "mongodb";
1811
1869
  host: string | {
1812
1870
  $env: string;
@@ -1817,9 +1875,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1817
1875
  user: string | {
1818
1876
  $env: string;
1819
1877
  };
1820
- password: string | {
1821
- $env: string;
1822
- };
1823
1878
  database: string | {
1824
1879
  $env: string;
1825
1880
  };
@@ -1841,6 +1896,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1841
1896
  environment?: string | undefined;
1842
1897
  }, {
1843
1898
  system: "mongodb";
1899
+ password?: string | {
1900
+ $env: string;
1901
+ } | undefined;
1844
1902
  host?: string | {
1845
1903
  $env: string;
1846
1904
  } | undefined;
@@ -1850,9 +1908,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1850
1908
  user?: string | {
1851
1909
  $env: string;
1852
1910
  } | undefined;
1853
- password?: string | {
1854
- $env: string;
1855
- } | undefined;
1856
1911
  database?: string | {
1857
1912
  $env: string;
1858
1913
  } | undefined;
@@ -1868,8 +1923,8 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1868
1923
  tls?: boolean | undefined;
1869
1924
  srv?: boolean | undefined;
1870
1925
  timeout?: number | undefined;
1871
- statementTimeout?: number | undefined;
1872
1926
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
1927
+ statementTimeout?: number | undefined;
1873
1928
  envFile?: string | undefined;
1874
1929
  environment?: string | undefined;
1875
1930
  }>,
@@ -1937,6 +1992,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1937
1992
  envFile: z.ZodOptional<z.ZodString>;
1938
1993
  environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
1939
1994
  }, "strip", z.ZodTypeAny, {
1995
+ password: string | {
1996
+ $env: string;
1997
+ };
1940
1998
  system: "redis";
1941
1999
  host: string | {
1942
2000
  $env: string;
@@ -1947,9 +2005,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1947
2005
  user: string | {
1948
2006
  $env: string;
1949
2007
  };
1950
- password: string | {
1951
- $env: string;
1952
- };
1953
2008
  database: string | {
1954
2009
  $env: string;
1955
2010
  };
@@ -1966,18 +2021,18 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1966
2021
  port: number | {
1967
2022
  $env: string;
1968
2023
  };
1969
- user?: string | {
2024
+ password?: string | {
1970
2025
  $env: string;
1971
2026
  } | undefined;
1972
- password?: string | {
2027
+ user?: string | {
1973
2028
  $env: string;
1974
2029
  } | undefined;
1975
2030
  database?: string | {
1976
2031
  $env: string;
1977
2032
  } | undefined;
1978
2033
  timeout?: number | undefined;
1979
- statementTimeout?: number | undefined;
1980
2034
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2035
+ statementTimeout?: number | undefined;
1981
2036
  envFile?: string | undefined;
1982
2037
  environment?: string | undefined;
1983
2038
  }>,
@@ -2072,6 +2127,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2072
2127
  envFile: z.ZodOptional<z.ZodString>;
2073
2128
  environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
2074
2129
  }, "strip", z.ZodTypeAny, {
2130
+ password: string | {
2131
+ $env: string;
2132
+ };
2075
2133
  system: "elasticsearch";
2076
2134
  host: string | {
2077
2135
  $env: string;
@@ -2082,15 +2140,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2082
2140
  user: string | {
2083
2141
  $env: string;
2084
2142
  };
2085
- password: string | {
2086
- $env: string;
2087
- };
2088
2143
  database: string | {
2089
2144
  $env: string;
2090
2145
  };
2091
2146
  rejectUnauthorized: boolean;
2092
- protocol: "http" | "https";
2093
2147
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2148
+ protocol: "http" | "https";
2094
2149
  timeout?: number | undefined;
2095
2150
  statementTimeout?: number | undefined;
2096
2151
  nodes?: string[] | undefined;
@@ -2105,6 +2160,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2105
2160
  environment?: string | undefined;
2106
2161
  }, {
2107
2162
  system: "elasticsearch";
2163
+ password?: string | {
2164
+ $env: string;
2165
+ } | undefined;
2108
2166
  host?: string | {
2109
2167
  $env: string;
2110
2168
  } | undefined;
@@ -2114,14 +2172,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2114
2172
  user?: string | {
2115
2173
  $env: string;
2116
2174
  } | undefined;
2117
- password?: string | {
2118
- $env: string;
2119
- } | undefined;
2120
2175
  database?: string | {
2121
2176
  $env: string;
2122
2177
  } | undefined;
2123
2178
  rejectUnauthorized?: boolean | undefined;
2124
2179
  timeout?: number | undefined;
2180
+ permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2125
2181
  statementTimeout?: number | undefined;
2126
2182
  protocol?: "http" | "https" | undefined;
2127
2183
  nodes?: string[] | undefined;
@@ -2132,11 +2188,13 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2132
2188
  $env: string;
2133
2189
  } | undefined;
2134
2190
  caPath?: string | undefined;
2135
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2136
2191
  envFile?: string | undefined;
2137
2192
  environment?: string | undefined;
2138
2193
  }>
2139
2194
  ]>>, Record<string, {
2195
+ password: string | {
2196
+ $env: string;
2197
+ };
2140
2198
  system: "postgresql" | "mysql" | "mariadb";
2141
2199
  host: string | {
2142
2200
  $env: string;
@@ -2147,9 +2205,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2147
2205
  user: string | {
2148
2206
  $env: string;
2149
2207
  };
2150
- password: string | {
2151
- $env: string;
2152
- };
2153
2208
  database: string | {
2154
2209
  $env: string;
2155
2210
  };
@@ -2159,6 +2214,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2159
2214
  envFile?: string | undefined;
2160
2215
  environment?: string | undefined;
2161
2216
  } | {
2217
+ password: string | {
2218
+ $env: string;
2219
+ };
2162
2220
  system: "mongodb";
2163
2221
  host: string | {
2164
2222
  $env: string;
@@ -2169,9 +2227,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2169
2227
  user: string | {
2170
2228
  $env: string;
2171
2229
  };
2172
- password: string | {
2173
- $env: string;
2174
- };
2175
2230
  database: string | {
2176
2231
  $env: string;
2177
2232
  };
@@ -2192,6 +2247,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2192
2247
  envFile?: string | undefined;
2193
2248
  environment?: string | undefined;
2194
2249
  } | {
2250
+ password: string | {
2251
+ $env: string;
2252
+ };
2195
2253
  system: "redis";
2196
2254
  host: string | {
2197
2255
  $env: string;
@@ -2202,9 +2260,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2202
2260
  user: string | {
2203
2261
  $env: string;
2204
2262
  };
2205
- password: string | {
2206
- $env: string;
2207
- };
2208
2263
  database: string | {
2209
2264
  $env: string;
2210
2265
  };
@@ -2214,6 +2269,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2214
2269
  envFile?: string | undefined;
2215
2270
  environment?: string | undefined;
2216
2271
  } | {
2272
+ password: string | {
2273
+ $env: string;
2274
+ };
2217
2275
  system: "elasticsearch";
2218
2276
  host: string | {
2219
2277
  $env: string;
@@ -2224,15 +2282,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2224
2282
  user: string | {
2225
2283
  $env: string;
2226
2284
  };
2227
- password: string | {
2228
- $env: string;
2229
- };
2230
2285
  database: string | {
2231
2286
  $env: string;
2232
2287
  };
2233
2288
  rejectUnauthorized: boolean;
2234
- protocol: "http" | "https";
2235
2289
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2290
+ protocol: "http" | "https";
2236
2291
  timeout?: number | undefined;
2237
2292
  statementTimeout?: number | undefined;
2238
2293
  nodes?: string[] | undefined;
@@ -2263,12 +2318,15 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2263
2318
  $env: string;
2264
2319
  } | undefined;
2265
2320
  timeout?: number | undefined;
2266
- statementTimeout?: number | undefined;
2267
2321
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2322
+ statementTimeout?: number | undefined;
2268
2323
  envFile?: string | undefined;
2269
2324
  environment?: string | undefined;
2270
2325
  } | {
2271
2326
  system: "mongodb";
2327
+ password?: string | {
2328
+ $env: string;
2329
+ } | undefined;
2272
2330
  host?: string | {
2273
2331
  $env: string;
2274
2332
  } | undefined;
@@ -2278,9 +2336,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2278
2336
  user?: string | {
2279
2337
  $env: string;
2280
2338
  } | undefined;
2281
- password?: string | {
2282
- $env: string;
2283
- } | undefined;
2284
2339
  database?: string | {
2285
2340
  $env: string;
2286
2341
  } | undefined;
@@ -2296,8 +2351,8 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2296
2351
  tls?: boolean | undefined;
2297
2352
  srv?: boolean | undefined;
2298
2353
  timeout?: number | undefined;
2299
- statementTimeout?: number | undefined;
2300
2354
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2355
+ statementTimeout?: number | undefined;
2301
2356
  envFile?: string | undefined;
2302
2357
  environment?: string | undefined;
2303
2358
  } | {
@@ -2308,22 +2363,25 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2308
2363
  port: number | {
2309
2364
  $env: string;
2310
2365
  };
2311
- user?: string | {
2366
+ password?: string | {
2312
2367
  $env: string;
2313
2368
  } | undefined;
2314
- password?: string | {
2369
+ user?: string | {
2315
2370
  $env: string;
2316
2371
  } | undefined;
2317
2372
  database?: string | {
2318
2373
  $env: string;
2319
2374
  } | undefined;
2320
2375
  timeout?: number | undefined;
2321
- statementTimeout?: number | undefined;
2322
2376
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2377
+ statementTimeout?: number | undefined;
2323
2378
  envFile?: string | undefined;
2324
2379
  environment?: string | undefined;
2325
2380
  } | {
2326
2381
  system: "elasticsearch";
2382
+ password?: string | {
2383
+ $env: string;
2384
+ } | undefined;
2327
2385
  host?: string | {
2328
2386
  $env: string;
2329
2387
  } | undefined;
@@ -2333,14 +2391,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2333
2391
  user?: string | {
2334
2392
  $env: string;
2335
2393
  } | undefined;
2336
- password?: string | {
2337
- $env: string;
2338
- } | undefined;
2339
2394
  database?: string | {
2340
2395
  $env: string;
2341
2396
  } | undefined;
2342
2397
  rejectUnauthorized?: boolean | undefined;
2343
2398
  timeout?: number | undefined;
2399
+ permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2344
2400
  statementTimeout?: number | undefined;
2345
2401
  protocol?: "http" | "https" | undefined;
2346
2402
  nodes?: string[] | undefined;
@@ -2351,7 +2407,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2351
2407
  $env: string;
2352
2408
  } | undefined;
2353
2409
  caPath?: string | undefined;
2354
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2355
2410
  envFile?: string | undefined;
2356
2411
  environment?: string | undefined;
2357
2412
  }>>;
@@ -2452,6 +2507,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2452
2507
  schemaTableCount?: number | undefined;
2453
2508
  };
2454
2509
  connections: Record<string, {
2510
+ password: string | {
2511
+ $env: string;
2512
+ };
2455
2513
  system: "postgresql" | "mysql" | "mariadb";
2456
2514
  host: string | {
2457
2515
  $env: string;
@@ -2462,9 +2520,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2462
2520
  user: string | {
2463
2521
  $env: string;
2464
2522
  };
2465
- password: string | {
2466
- $env: string;
2467
- };
2468
2523
  database: string | {
2469
2524
  $env: string;
2470
2525
  };
@@ -2474,6 +2529,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2474
2529
  envFile?: string | undefined;
2475
2530
  environment?: string | undefined;
2476
2531
  } | {
2532
+ password: string | {
2533
+ $env: string;
2534
+ };
2477
2535
  system: "mongodb";
2478
2536
  host: string | {
2479
2537
  $env: string;
@@ -2484,9 +2542,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2484
2542
  user: string | {
2485
2543
  $env: string;
2486
2544
  };
2487
- password: string | {
2488
- $env: string;
2489
- };
2490
2545
  database: string | {
2491
2546
  $env: string;
2492
2547
  };
@@ -2507,6 +2562,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2507
2562
  envFile?: string | undefined;
2508
2563
  environment?: string | undefined;
2509
2564
  } | {
2565
+ password: string | {
2566
+ $env: string;
2567
+ };
2510
2568
  system: "redis";
2511
2569
  host: string | {
2512
2570
  $env: string;
@@ -2517,9 +2575,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2517
2575
  user: string | {
2518
2576
  $env: string;
2519
2577
  };
2520
- password: string | {
2521
- $env: string;
2522
- };
2523
2578
  database: string | {
2524
2579
  $env: string;
2525
2580
  };
@@ -2529,6 +2584,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2529
2584
  envFile?: string | undefined;
2530
2585
  environment?: string | undefined;
2531
2586
  } | {
2587
+ password: string | {
2588
+ $env: string;
2589
+ };
2532
2590
  system: "elasticsearch";
2533
2591
  host: string | {
2534
2592
  $env: string;
@@ -2539,15 +2597,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2539
2597
  user: string | {
2540
2598
  $env: string;
2541
2599
  };
2542
- password: string | {
2543
- $env: string;
2544
- };
2545
2600
  database: string | {
2546
2601
  $env: string;
2547
2602
  };
2548
2603
  rejectUnauthorized: boolean;
2549
- protocol: "http" | "https";
2550
2604
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2605
+ protocol: "http" | "https";
2551
2606
  timeout?: number | undefined;
2552
2607
  statementTimeout?: number | undefined;
2553
2608
  nodes?: string[] | undefined;
@@ -2589,12 +2644,15 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2589
2644
  $env: string;
2590
2645
  } | undefined;
2591
2646
  timeout?: number | undefined;
2592
- statementTimeout?: number | undefined;
2593
2647
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2648
+ statementTimeout?: number | undefined;
2594
2649
  envFile?: string | undefined;
2595
2650
  environment?: string | undefined;
2596
2651
  } | {
2597
2652
  system: "mongodb";
2653
+ password?: string | {
2654
+ $env: string;
2655
+ } | undefined;
2598
2656
  host?: string | {
2599
2657
  $env: string;
2600
2658
  } | undefined;
@@ -2604,9 +2662,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2604
2662
  user?: string | {
2605
2663
  $env: string;
2606
2664
  } | undefined;
2607
- password?: string | {
2608
- $env: string;
2609
- } | undefined;
2610
2665
  database?: string | {
2611
2666
  $env: string;
2612
2667
  } | undefined;
@@ -2622,8 +2677,8 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2622
2677
  tls?: boolean | undefined;
2623
2678
  srv?: boolean | undefined;
2624
2679
  timeout?: number | undefined;
2625
- statementTimeout?: number | undefined;
2626
2680
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2681
+ statementTimeout?: number | undefined;
2627
2682
  envFile?: string | undefined;
2628
2683
  environment?: string | undefined;
2629
2684
  } | {
@@ -2634,22 +2689,25 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2634
2689
  port: number | {
2635
2690
  $env: string;
2636
2691
  };
2637
- user?: string | {
2692
+ password?: string | {
2638
2693
  $env: string;
2639
2694
  } | undefined;
2640
- password?: string | {
2695
+ user?: string | {
2641
2696
  $env: string;
2642
2697
  } | undefined;
2643
2698
  database?: string | {
2644
2699
  $env: string;
2645
2700
  } | undefined;
2646
2701
  timeout?: number | undefined;
2647
- statementTimeout?: number | undefined;
2648
2702
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2703
+ statementTimeout?: number | undefined;
2649
2704
  envFile?: string | undefined;
2650
2705
  environment?: string | undefined;
2651
2706
  } | {
2652
2707
  system: "elasticsearch";
2708
+ password?: string | {
2709
+ $env: string;
2710
+ } | undefined;
2653
2711
  host?: string | {
2654
2712
  $env: string;
2655
2713
  } | undefined;
@@ -2659,14 +2717,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2659
2717
  user?: string | {
2660
2718
  $env: string;
2661
2719
  } | undefined;
2662
- password?: string | {
2663
- $env: string;
2664
- } | undefined;
2665
2720
  database?: string | {
2666
2721
  $env: string;
2667
2722
  } | undefined;
2668
2723
  rejectUnauthorized?: boolean | undefined;
2669
2724
  timeout?: number | undefined;
2725
+ permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2670
2726
  statementTimeout?: number | undefined;
2671
2727
  protocol?: "http" | "https" | undefined;
2672
2728
  nodes?: string[] | undefined;
@@ -2677,7 +2733,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2677
2733
  $env: string;
2678
2734
  } | undefined;
2679
2735
  caPath?: string | undefined;
2680
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2681
2736
  envFile?: string | undefined;
2682
2737
  environment?: string | undefined;
2683
2738
  }>;
@@ -2728,6 +2783,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2728
2783
  schemaTableCount?: number | undefined;
2729
2784
  };
2730
2785
  connections: Record<string, {
2786
+ password: string | {
2787
+ $env: string;
2788
+ };
2731
2789
  system: "postgresql" | "mysql" | "mariadb";
2732
2790
  host: string | {
2733
2791
  $env: string;
@@ -2738,9 +2796,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2738
2796
  user: string | {
2739
2797
  $env: string;
2740
2798
  };
2741
- password: string | {
2742
- $env: string;
2743
- };
2744
2799
  database: string | {
2745
2800
  $env: string;
2746
2801
  };
@@ -2750,6 +2805,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2750
2805
  envFile?: string | undefined;
2751
2806
  environment?: string | undefined;
2752
2807
  } | {
2808
+ password: string | {
2809
+ $env: string;
2810
+ };
2753
2811
  system: "mongodb";
2754
2812
  host: string | {
2755
2813
  $env: string;
@@ -2760,9 +2818,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2760
2818
  user: string | {
2761
2819
  $env: string;
2762
2820
  };
2763
- password: string | {
2764
- $env: string;
2765
- };
2766
2821
  database: string | {
2767
2822
  $env: string;
2768
2823
  };
@@ -2783,6 +2838,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2783
2838
  envFile?: string | undefined;
2784
2839
  environment?: string | undefined;
2785
2840
  } | {
2841
+ password: string | {
2842
+ $env: string;
2843
+ };
2786
2844
  system: "redis";
2787
2845
  host: string | {
2788
2846
  $env: string;
@@ -2793,9 +2851,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2793
2851
  user: string | {
2794
2852
  $env: string;
2795
2853
  };
2796
- password: string | {
2797
- $env: string;
2798
- };
2799
2854
  database: string | {
2800
2855
  $env: string;
2801
2856
  };
@@ -2805,6 +2860,9 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2805
2860
  envFile?: string | undefined;
2806
2861
  environment?: string | undefined;
2807
2862
  } | {
2863
+ password: string | {
2864
+ $env: string;
2865
+ };
2808
2866
  system: "elasticsearch";
2809
2867
  host: string | {
2810
2868
  $env: string;
@@ -2815,15 +2873,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2815
2873
  user: string | {
2816
2874
  $env: string;
2817
2875
  };
2818
- password: string | {
2819
- $env: string;
2820
- };
2821
2876
  database: string | {
2822
2877
  $env: string;
2823
2878
  };
2824
2879
  rejectUnauthorized: boolean;
2825
- protocol: "http" | "https";
2826
2880
  permission: "admin" | "query-only" | "read-write" | "data-admin";
2881
+ protocol: "http" | "https";
2827
2882
  timeout?: number | undefined;
2828
2883
  statementTimeout?: number | undefined;
2829
2884
  nodes?: string[] | undefined;
@@ -2865,12 +2920,15 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2865
2920
  $env: string;
2866
2921
  } | undefined;
2867
2922
  timeout?: number | undefined;
2868
- statementTimeout?: number | undefined;
2869
2923
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2924
+ statementTimeout?: number | undefined;
2870
2925
  envFile?: string | undefined;
2871
2926
  environment?: string | undefined;
2872
2927
  } | {
2873
2928
  system: "mongodb";
2929
+ password?: string | {
2930
+ $env: string;
2931
+ } | undefined;
2874
2932
  host?: string | {
2875
2933
  $env: string;
2876
2934
  } | undefined;
@@ -2880,9 +2938,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2880
2938
  user?: string | {
2881
2939
  $env: string;
2882
2940
  } | undefined;
2883
- password?: string | {
2884
- $env: string;
2885
- } | undefined;
2886
2941
  database?: string | {
2887
2942
  $env: string;
2888
2943
  } | undefined;
@@ -2898,8 +2953,8 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2898
2953
  tls?: boolean | undefined;
2899
2954
  srv?: boolean | undefined;
2900
2955
  timeout?: number | undefined;
2901
- statementTimeout?: number | undefined;
2902
2956
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2957
+ statementTimeout?: number | undefined;
2903
2958
  envFile?: string | undefined;
2904
2959
  environment?: string | undefined;
2905
2960
  } | {
@@ -2910,22 +2965,25 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2910
2965
  port: number | {
2911
2966
  $env: string;
2912
2967
  };
2913
- user?: string | {
2968
+ password?: string | {
2914
2969
  $env: string;
2915
2970
  } | undefined;
2916
- password?: string | {
2971
+ user?: string | {
2917
2972
  $env: string;
2918
2973
  } | undefined;
2919
2974
  database?: string | {
2920
2975
  $env: string;
2921
2976
  } | undefined;
2922
2977
  timeout?: number | undefined;
2923
- statementTimeout?: number | undefined;
2924
2978
  permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2979
+ statementTimeout?: number | undefined;
2925
2980
  envFile?: string | undefined;
2926
2981
  environment?: string | undefined;
2927
2982
  } | {
2928
2983
  system: "elasticsearch";
2984
+ password?: string | {
2985
+ $env: string;
2986
+ } | undefined;
2929
2987
  host?: string | {
2930
2988
  $env: string;
2931
2989
  } | undefined;
@@ -2935,14 +2993,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2935
2993
  user?: string | {
2936
2994
  $env: string;
2937
2995
  } | undefined;
2938
- password?: string | {
2939
- $env: string;
2940
- } | undefined;
2941
2996
  database?: string | {
2942
2997
  $env: string;
2943
2998
  } | undefined;
2944
2999
  rejectUnauthorized?: boolean | undefined;
2945
3000
  timeout?: number | undefined;
3001
+ permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2946
3002
  statementTimeout?: number | undefined;
2947
3003
  protocol?: "http" | "https" | undefined;
2948
3004
  nodes?: string[] | undefined;
@@ -2953,7 +3009,6 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2953
3009
  $env: string;
2954
3010
  } | undefined;
2955
3011
  caPath?: string | undefined;
2956
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2957
3012
  envFile?: string | undefined;
2958
3013
  environment?: string | undefined;
2959
3014
  }>;
@@ -3105,7 +3160,7 @@ export declare class DataExecutor {
3105
3160
  private getQuoteChar;
3106
3161
  private checkBlacklist;
3107
3162
  private executeMutation;
3108
- private successResult;
3163
+ private outcomeResult;
3109
3164
  private handleMutationError;
3110
3165
  /**
3111
3166
  * Build a parameterized UPDATE SQL statement
@@ -3372,8 +3427,6 @@ export type SqlSystem = "postgresql" | "mysql" | "mariadb";
3372
3427
  * 且 loadEnvFile 不覆寫既有 key——若兩連線都用 DB_PASSWORD 會撞名取到對方的值。
3373
3428
  */
3374
3429
  export declare function envVarNameFor(connName: string, field: "password"): string;
3375
- /** 把 secret 寫進該連線的 envFile(KEY=VALUE);既有同名 key 就地覆寫,否則追加。 */
3376
- export declare function writeConnectionSecret(projectPath: string, connName: string, field: "password", value: string): Promise<void>;
3377
3430
  export interface ConnectionInput {
3378
3431
  name: string;
3379
3432
  system: SqlSystem;
@@ -3395,6 +3448,30 @@ export declare function migrateV1ToV2(v1: DbcliConfig$1): DbcliConfigV2;
3395
3448
  /** 新增或就地覆寫同名連線(immutable)。非機密欄存字面值,password 存 {$env} 參照 +
3396
3449
  * per-connection envFile。編輯時保留既有 permission;新建預設 'query-only'。 */
3397
3450
  export declare function upsertConnection(config: DbcliConfigV2, input: ConnectionInput): DbcliConfigV2;
3451
+ /**
3452
+ * 單一連線的密碼輪替:只動該連線的密碼,其餘設定原封不動。
3453
+ *
3454
+ * 密碼實際落在哪裡由 config 決定,不是靠命名規則猜的——
3455
+ * 連線若已用 `{ $env: NAME }`,就改寫 NAME 這個 key;若還是明文,
3456
+ * 先把 config 轉成 env 參照再寫檔,之後的輪替就不必再碰 config.json。
3457
+ */
3458
+ export interface PasswordTarget {
3459
+ /** 被更新的連線名稱 */
3460
+ connection: string;
3461
+ /** 密碼寫入的 env 檔(相對於 config storage 目錄) */
3462
+ envFile: string;
3463
+ /** 寫入的環境變數名稱 */
3464
+ varName: string;
3465
+ /** 這次是否需要把 config 裡的明文密碼轉成 $env 參照 */
3466
+ convertedToEnvRef: boolean;
3467
+ }
3468
+ /**
3469
+ * 查出「這條連線的密碼該寫到哪個 env 檔的哪個 key」,不寫入任何檔案。
3470
+ *
3471
+ * 驗證新密碼時得先知道 key 名稱才能注入,所以查詢與寫入分開。
3472
+ */
3473
+ export declare function resolvePasswordTarget(projectPath: string, connectionName?: string): Promise<PasswordTarget>;
3474
+ export declare function setConnectionPassword(projectPath: string, connectionName: string | undefined, password: string): Promise<PasswordTarget>;
3398
3475
  /**
3399
3476
  * Resolve the per-user dbcli root lazily so embedders and tests can provide an
3400
3477
  * isolated config home without reloading the module. `DBCLI_CONFIG_HOME` is a