@carllee1983/dbcli 3.0.0 → 6.0.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
@@ -255,123 +255,12 @@ export interface DatabaseAdapter {
255
255
  */
256
256
  getServerVersion(): Promise<string>;
257
257
  }
258
- interface QueryableAdapter {
259
- /**
260
- * Establish connection and verify credentials
261
- * Throws ConnectionError with categorized error type on failure
262
- * @throws {ConnectionError} If connection fails (server down, auth failed, timeout, etc.)
263
- */
264
- connect(): Promise<void>;
265
- /**
266
- * Close connection and release resources
267
- * Should never throw; safe to call multiple times
268
- * Handles cleanup gracefully even if already disconnected
269
- */
270
- disconnect(): Promise<void>;
271
- /**
272
- * Execute arbitrary query with parameterized values
273
- * Accepts JSON query strings for MongoDB operations
274
- * @param query Query string (JSON format for MongoDB)
275
- * @param params Array of parameter values in order
276
- * @param options Optional execution controls (e.g. result-cardinality limit)
277
- * @returns Execution result containing rows and metadata
278
- * @throws {ConnectionError} If query execution fails
279
- */
280
- execute<T>(query: string, params?: unknown[], options?: {
281
- limit?: number;
282
- noLimit?: boolean;
283
- projection?: Record<string, 0 | 1>;
284
- }): Promise<ExecutionResult<T>>;
285
- /**
286
- * List all collections in the connected database
287
- * Includes metadata such as document count
288
- * @param options Optional filter for system indices
289
- * @returns Array of collection info with basic information
290
- * @throws {ConnectionError} If query fails
291
- */
292
- listCollections(options?: {
293
- includeSystem?: boolean;
294
- /** Redis: 取樣上限。列 key 沒有 catalog 可查,只能掃,所以上限是必要的。 */
295
- limit?: number;
296
- }): Promise<{
297
- name: string;
298
- documentCount?: number;
299
- }[]>;
300
- /**
301
- * Redis-only: 取樣 key 名稱並回報是否觸及取樣上限。
302
- *
303
- * 宣告在介面上而不是讓呼叫端 double-cast:`dbcli list` 與 shell 補全都需要
304
- * `truncated` 才能誠實顯示「只看了前 N 個」,而那個資訊 listCollections
305
- * 的形狀裝不下。其他引擎有 catalog 可查,不需要取樣。
306
- */
307
- sampleKeyNames?(limit: number): Promise<{
308
- names: string[];
309
- truncated: boolean;
310
- }>;
311
- /**
312
- * SQL-compatible collection listing for shared command surfaces.
313
- * @param options Optional filter for system indices
314
- */
315
- listTables?(options?: {
316
- includeSystem?: boolean;
317
- }): Promise<TableSchema[]>;
318
- /**
319
- * SQL-compatible schema lookup for shared command surfaces.
320
- * @param tableName Name of collection/table to inspect
321
- * @param options Optional adapter-specific knobs (e.g. mongo `sampleSize`).
322
- */
323
- getTableSchema?(tableName: string, options?: {
324
- sampleSize?: number;
325
- sampleMethod?: "random" | "natural";
326
- }): Promise<TableSchema>;
327
- /**
328
- * Test connection with lightweight probe query
329
- * Executes a ping or equivalent to verify connection is alive
330
- * @returns true if connection successful
331
- * @throws {ConnectionError} If connection test fails
332
- */
333
- testConnection(): Promise<boolean>;
334
- /**
335
- * Get the database server version string
336
- * @returns Raw version string from the server
337
- * @throws {ConnectionError} If not connected or query fails
338
- */
339
- getServerVersion(): Promise<string>;
340
- /**
341
- * Insert a single document/row
342
- * @param collection Collection or table name
343
- * @param data Data object to insert
344
- * @returns Execution result
345
- */
346
- insert(collection: string, data: Record<string, unknown>): Promise<ExecutionResult<unknown>>;
347
- /**
348
- * Update documents/rows matching filter
349
- * @param collection Collection or table name
350
- * @param filter Filter object
351
- * @param update Update operations (e.g. {$set: ...})
352
- * @returns Execution result
353
- */
354
- update(collection: string, filter: Record<string, unknown>, update: Record<string, unknown>): Promise<ExecutionResult<unknown>>;
355
- /**
356
- * Delete documents/rows matching filter
357
- * @param collection Collection or table name
358
- * @param filter Filter object
359
- * @returns Execution result
360
- */
361
- delete(collection: string, filter: Record<string, unknown>): Promise<ExecutionResult<unknown>>;
362
- }
363
258
  interface BlacklistConfig {
364
259
  /** Table names to block all operations on */
365
260
  tables: string[];
366
261
  /** Column names to omit per table: { tableName: [col1, col2] } */
367
262
  columns: Record<string, string[]>;
368
263
  }
369
- interface RedisMaskRule {
370
- /** Redis-native glob (e.g. "user:*"). */
371
- keyPattern: string;
372
- /** Hash field names to mask. Absent/empty → mask the whole value. */
373
- fields?: string[];
374
- }
375
264
  interface BlacklistState {
376
265
  /** Set of lowercase table names for O(1) case-insensitive lookup */
377
266
  tables: Set<string>;
@@ -386,21 +275,6 @@ export declare class BlacklistError extends Error {
386
275
  readonly operation: string;
387
276
  constructor(message: string, tableName: string, operation: string);
388
277
  }
389
- /**
390
- * Factory for creating database adapters
391
- * Implements factory pattern to route to correct adapter based on system type
392
- * Enables system-aware instantiation without coupling CLI commands to specific drivers
393
- */
394
- export declare class AdapterFactory {
395
- static createSqlAdapter(rawOptions: SqlConnectionOptions): DatabaseAdapter;
396
- static createQueryableAdapter(rawOptions: QueryableConnectionOptions): QueryableAdapter;
397
- static createAdapter(options: SqlConnectionOptions): DatabaseAdapter;
398
- static createAdapter(options: QueryableConnectionOptions): QueryableAdapter;
399
- static createAdapter(options: ConnectionOptions): DatabaseAdapter | QueryableAdapter;
400
- static createMongoDBAdapter(options: ConnectionOptions): QueryableAdapter;
401
- static createRedisAdapter(rawOptions: ConnectionOptions, blacklistRules?: string[], maskRules?: RedisMaskRule[]): QueryableAdapter;
402
- static createElasticsearchAdapter(options: ConnectionOptions): QueryableAdapter;
403
- }
404
278
  /**
405
279
  * Type definitions for data modification operations
406
280
  * Defines results and options for data modification (INSERT, UPDATE, DELETE) operations
@@ -666,10 +540,6 @@ declare const SQL_DIALECTS: readonly [
666
540
  "mariadb"
667
541
  ];
668
542
  type SqlDialect = (typeof SQL_DIALECTS)[number];
669
- /**
670
- * Manager class for loading and querying blacklist rules.
671
- * Instantiate once per CLI invocation.
672
- */
673
543
  export declare class BlacklistManager {
674
544
  private config;
675
545
  private state;
@@ -677,28 +547,49 @@ export declare class BlacklistManager {
677
547
  constructor(config: DbcliConfig, overrideEnvValue?: string);
678
548
  /**
679
549
  * Deserialize config.blacklist JSON into efficient Set/Map structures.
680
- * Case-insensitive table names (stored as lowercase).
681
- * Case-sensitive column names.
550
+ * Case-insensitive table names (stored as lowercase). Column entries are
551
+ * stored as written and folded where they are compared — see ADR-0018.
682
552
  *
683
553
  * @returns BlacklistState with Set<string> for tables, Map<string, Set<string>> for columns
684
554
  */
685
555
  loadBlacklist(): BlacklistState;
686
556
  /**
687
557
  * Check if a table is blacklisted.
688
- * Case-insensitive comparison.
558
+ *
559
+ * Case-insensitive, and each entry is a glob: `secrets*` covers
560
+ * `secrets_2026`. The same array is already a glob for Redis keys and
561
+ * Elasticsearch index expressions, and one config file gets one answer
562
+ * (ADR-0019 Decision 4). `report\*` escapes back to a literal name.
689
563
  *
690
564
  * @param tableName Table name to check
691
565
  * @returns true if the table is blacklisted
692
566
  */
693
567
  isTableBlacklisted(tableName: string): boolean;
568
+ /**
569
+ * Table entries carrying glob metacharacters.
570
+ *
571
+ * Computed with `state` rather than lazily: `getState()` hands the same `Set`
572
+ * out, and a lazy cache filled after someone added to it would leave `Set.has`
573
+ * seeing the new entry and the glob scan not — fail-open, and silently.
574
+ * Nothing mutates it today; the point is that nothing can start to.
575
+ */
576
+ private readonly wildcardTables;
694
577
  /**
695
578
  * Check if a specific column in a table is blacklisted.
696
- * Table name is case-insensitive; column name is case-sensitive.
579
+ * Both are case-insensitive on their first segment. A column entry's later
580
+ * segments are nested object keys and keep their case (ADR-0018).
697
581
  *
698
582
  * @param tableName Table name
699
583
  * @param columnName Column name
700
584
  * @returns true if the column is blacklisted
701
585
  */
586
+ /**
587
+ * The rules for a table, found by the reference as written and by its last
588
+ * segment. `extractTableReferences` keeps a qualified name whole, so a rule
589
+ * under `public.users` did not apply to `SELECT * FROM users` and the reverse
590
+ * was equally true. ADR-0018 Decision 3.
591
+ */
592
+ private columnRulesFor;
702
593
  isColumnBlacklisted(tableName: string, columnName: string): boolean;
703
594
  /**
704
595
  * Get all blacklisted column names for a specific table.
@@ -1340,18 +1231,47 @@ declare const DbcliConfigSchema: z.ZodObject<{
1340
1231
  schemaLastUpdated?: string | undefined;
1341
1232
  schemaTableCount?: number | undefined;
1342
1233
  }>>>;
1343
- blacklist: z.ZodDefault<z.ZodOptional<z.ZodObject<{
1234
+ blacklist: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodObject<{
1344
1235
  tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1345
1236
  columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1346
- }, "strip", z.ZodTypeAny, {
1347
- columns: Record<string, string[]>;
1237
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
1238
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1239
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1240
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
1241
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1242
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1243
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
1244
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1245
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1246
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
1247
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1248
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1249
+ }, z.ZodTypeAny, "passthrough">>, {
1348
1250
  tables: string[];
1349
- }, {
1350
- columns?: Record<string, string[]> | undefined;
1351
- tables?: string[] | undefined;
1352
- }>>>;
1353
- audit: z.ZodDefault<z.ZodOptional<z.ZodObject<{
1251
+ columns: Record<string, string[]>;
1252
+ }, z.objectInputType<{
1253
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1254
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1255
+ }, z.ZodTypeAny, "passthrough">>>>;
1256
+ audit: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
1354
1257
  enabled: z.ZodDefault<z.ZodBoolean>;
1258
+ /**
1259
+ * 稽核寫不出來就不要動資料庫。
1260
+ *
1261
+ * audit 一直是 best-effort:磁碟滿、目錄不可寫、lock budget 耗盡時,操作
1262
+ * 照樣執行而紀錄不存在,只有一行 stderr 警告(一個 process 只印一次,
1263
+ * 管線模式通常看不到)。對多數使用者這是對的取捨——遺失一列紀錄不該讓
1264
+ * 工具停擺。但把稽核當成控制本身的人(ES shell 的 permission 就是這種
1265
+ * 情形)需要能表達相反的取捨,而先前連表達都表達不了。
1266
+ *
1267
+ * 強制點是「效果發生前」的稽核寫入(`writeAuditEntryBeforeEffect`):
1268
+ * ES shell 送出請求前的那一列,與 SQL 的 gate decision。效果已經發生之後
1269
+ * 才寫的紀錄不在範圍內——那時拒絕擋不回任何東西,只會把一次成功的操作
1270
+ * 回報成失敗。
1271
+ *
1272
+ * 預設關閉:這改的是既有行為,開啟與否是使用者的判斷。
1273
+ */
1274
+ strict: z.ZodDefault<z.ZodBoolean>;
1355
1275
  rotation: z.ZodDefault<z.ZodOptional<z.ZodObject<{
1356
1276
  max_bytes: z.ZodDefault<z.ZodNumber>;
1357
1277
  max_entries: z.ZodDefault<z.ZodNumber>;
@@ -1363,12 +1283,28 @@ declare const DbcliConfigSchema: z.ZodObject<{
1363
1283
  max_entries?: number | undefined;
1364
1284
  }>>>;
1365
1285
  }, "strip", z.ZodTypeAny, {
1286
+ strict: boolean;
1366
1287
  enabled: boolean;
1367
1288
  rotation: {
1368
1289
  max_bytes: number;
1369
1290
  max_entries: number;
1370
1291
  };
1371
1292
  }, {
1293
+ strict?: boolean | undefined;
1294
+ enabled?: boolean | undefined;
1295
+ rotation?: {
1296
+ max_bytes?: number | undefined;
1297
+ max_entries?: number | undefined;
1298
+ } | undefined;
1299
+ }>, {
1300
+ strict: boolean;
1301
+ enabled: boolean;
1302
+ rotation: {
1303
+ max_bytes: number;
1304
+ max_entries: number;
1305
+ };
1306
+ }, {
1307
+ strict?: boolean | undefined;
1372
1308
  enabled?: boolean | undefined;
1373
1309
  rotation?: {
1374
1310
  max_bytes?: number | undefined;
@@ -1400,10 +1336,11 @@ declare const DbcliConfigSchema: z.ZodObject<{
1400
1336
  }, "strip", z.ZodTypeAny, {
1401
1337
  schema: Record<string, any>;
1402
1338
  blacklist: {
1403
- columns: Record<string, string[]>;
1404
1339
  tables: string[];
1340
+ columns: Record<string, string[]>;
1405
1341
  };
1406
1342
  audit: {
1343
+ strict: boolean;
1407
1344
  enabled: boolean;
1408
1345
  rotation: {
1409
1346
  max_bytes: number;
@@ -1627,11 +1564,12 @@ declare const DbcliConfigSchema: z.ZodObject<{
1627
1564
  }[] | undefined;
1628
1565
  } | undefined;
1629
1566
  schema?: Record<string, any> | undefined;
1630
- blacklist?: {
1631
- columns?: Record<string, string[]> | undefined;
1632
- tables?: string[] | undefined;
1633
- } | undefined;
1567
+ blacklist?: z.objectInputType<{
1568
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1569
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1570
+ }, z.ZodTypeAny, "passthrough"> | undefined;
1634
1571
  audit?: {
1572
+ strict?: boolean | undefined;
1635
1573
  enabled?: boolean | undefined;
1636
1574
  rotation?: {
1637
1575
  max_bytes?: number | undefined;
@@ -1653,7 +1591,7 @@ type DbcliConfig$1 = z.infer<typeof DbcliConfigSchema>;
1653
1591
  declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1654
1592
  version: z.ZodLiteral<2>;
1655
1593
  default: z.ZodString;
1656
- connections: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[
1594
+ connections: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodUnion<[
1657
1595
  z.ZodObject<{
1658
1596
  timeout: z.ZodOptional<z.ZodNumber>;
1659
1597
  statementTimeout: z.ZodOptional<z.ZodNumber>;
@@ -2191,7 +2129,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2191
2129
  envFile?: string | undefined;
2192
2130
  environment?: string | undefined;
2193
2131
  }>
2194
- ]>>, Record<string, {
2132
+ ]>, {
2195
2133
  password: string | {
2196
2134
  $env: string;
2197
2135
  };
@@ -2300,7 +2238,10 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2300
2238
  caPath?: string | undefined;
2301
2239
  envFile?: string | undefined;
2302
2240
  environment?: string | undefined;
2303
- }>, Record<string, {
2241
+ }, unknown>>, Record<string, {
2242
+ password: string | {
2243
+ $env: string;
2244
+ };
2304
2245
  system: "postgresql" | "mysql" | "mariadb";
2305
2246
  host: string | {
2306
2247
  $env: string;
@@ -2314,31 +2255,30 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2314
2255
  database: string | {
2315
2256
  $env: string;
2316
2257
  };
2317
- password?: string | {
2318
- $env: string;
2319
- } | undefined;
2258
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2320
2259
  timeout?: number | undefined;
2321
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2322
2260
  statementTimeout?: number | undefined;
2323
2261
  envFile?: string | undefined;
2324
2262
  environment?: string | undefined;
2325
2263
  } | {
2326
- system: "mongodb";
2327
- password?: string | {
2264
+ password: string | {
2328
2265
  $env: string;
2329
- } | undefined;
2330
- host?: string | {
2266
+ };
2267
+ system: "mongodb";
2268
+ host: string | {
2331
2269
  $env: string;
2332
- } | undefined;
2333
- port?: number | {
2270
+ };
2271
+ port: number | {
2334
2272
  $env: string;
2335
- } | undefined;
2336
- user?: string | {
2273
+ };
2274
+ user: string | {
2337
2275
  $env: string;
2338
- } | undefined;
2339
- database?: string | {
2276
+ };
2277
+ database: string | {
2340
2278
  $env: string;
2341
- } | undefined;
2279
+ };
2280
+ srv: boolean;
2281
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2342
2282
  uri?: string | {
2343
2283
  $env: string;
2344
2284
  } | undefined;
@@ -2349,13 +2289,14 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2349
2289
  $env: string;
2350
2290
  } | undefined;
2351
2291
  tls?: boolean | undefined;
2352
- srv?: boolean | undefined;
2353
2292
  timeout?: number | undefined;
2354
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2355
2293
  statementTimeout?: number | undefined;
2356
2294
  envFile?: string | undefined;
2357
2295
  environment?: string | undefined;
2358
2296
  } | {
2297
+ password: string | {
2298
+ $env: string;
2299
+ };
2359
2300
  system: "redis";
2360
2301
  host: string | {
2361
2302
  $env: string;
@@ -2363,42 +2304,39 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2363
2304
  port: number | {
2364
2305
  $env: string;
2365
2306
  };
2366
- password?: string | {
2367
- $env: string;
2368
- } | undefined;
2369
- user?: string | {
2307
+ user: string | {
2370
2308
  $env: string;
2371
- } | undefined;
2372
- database?: string | {
2309
+ };
2310
+ database: string | {
2373
2311
  $env: string;
2374
- } | undefined;
2312
+ };
2313
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2375
2314
  timeout?: number | undefined;
2376
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2377
2315
  statementTimeout?: number | undefined;
2378
2316
  envFile?: string | undefined;
2379
2317
  environment?: string | undefined;
2380
2318
  } | {
2381
- system: "elasticsearch";
2382
- password?: string | {
2319
+ password: string | {
2383
2320
  $env: string;
2384
- } | undefined;
2385
- host?: string | {
2321
+ };
2322
+ system: "elasticsearch";
2323
+ host: string | {
2386
2324
  $env: string;
2387
- } | undefined;
2388
- port?: number | {
2325
+ };
2326
+ port: number | {
2389
2327
  $env: string;
2390
- } | undefined;
2391
- user?: string | {
2328
+ };
2329
+ user: string | {
2392
2330
  $env: string;
2393
- } | undefined;
2394
- database?: string | {
2331
+ };
2332
+ database: string | {
2395
2333
  $env: string;
2396
- } | undefined;
2397
- rejectUnauthorized?: boolean | undefined;
2334
+ };
2335
+ rejectUnauthorized: boolean;
2336
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2337
+ protocol: "http" | "https";
2398
2338
  timeout?: number | undefined;
2399
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2400
2339
  statementTimeout?: number | undefined;
2401
- protocol?: "http" | "https" | undefined;
2402
2340
  nodes?: string[] | undefined;
2403
2341
  cloudId?: string | {
2404
2342
  $env: string;
@@ -2409,7 +2347,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2409
2347
  caPath?: string | undefined;
2410
2348
  envFile?: string | undefined;
2411
2349
  environment?: string | undefined;
2412
- }>>;
2350
+ }>, Record<string, unknown>>;
2413
2351
  schema: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
2414
2352
  schemas: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>;
2415
2353
  metadata: z.ZodDefault<z.ZodOptional<z.ZodObject<{
@@ -2428,18 +2366,47 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2428
2366
  schemaLastUpdated?: string | undefined;
2429
2367
  schemaTableCount?: number | undefined;
2430
2368
  }>>>;
2431
- blacklist: z.ZodDefault<z.ZodOptional<z.ZodObject<{
2369
+ blacklist: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodObject<{
2432
2370
  tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2433
2371
  columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2434
- }, "strip", z.ZodTypeAny, {
2435
- columns: Record<string, string[]>;
2372
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
2373
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2374
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2375
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
2376
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2377
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2378
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
2379
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2380
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2381
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
2382
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2383
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2384
+ }, z.ZodTypeAny, "passthrough">>, {
2436
2385
  tables: string[];
2437
- }, {
2438
- columns?: Record<string, string[]> | undefined;
2439
- tables?: string[] | undefined;
2440
- }>>>;
2441
- audit: z.ZodDefault<z.ZodOptional<z.ZodObject<{
2386
+ columns: Record<string, string[]>;
2387
+ }, z.objectInputType<{
2388
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2389
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2390
+ }, z.ZodTypeAny, "passthrough">>>>;
2391
+ audit: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
2442
2392
  enabled: z.ZodDefault<z.ZodBoolean>;
2393
+ /**
2394
+ * 稽核寫不出來就不要動資料庫。
2395
+ *
2396
+ * audit 一直是 best-effort:磁碟滿、目錄不可寫、lock budget 耗盡時,操作
2397
+ * 照樣執行而紀錄不存在,只有一行 stderr 警告(一個 process 只印一次,
2398
+ * 管線模式通常看不到)。對多數使用者這是對的取捨——遺失一列紀錄不該讓
2399
+ * 工具停擺。但把稽核當成控制本身的人(ES shell 的 permission 就是這種
2400
+ * 情形)需要能表達相反的取捨,而先前連表達都表達不了。
2401
+ *
2402
+ * 強制點是「效果發生前」的稽核寫入(`writeAuditEntryBeforeEffect`):
2403
+ * ES shell 送出請求前的那一列,與 SQL 的 gate decision。效果已經發生之後
2404
+ * 才寫的紀錄不在範圍內——那時拒絕擋不回任何東西,只會把一次成功的操作
2405
+ * 回報成失敗。
2406
+ *
2407
+ * 預設關閉:這改的是既有行為,開啟與否是使用者的判斷。
2408
+ */
2409
+ strict: z.ZodDefault<z.ZodBoolean>;
2443
2410
  rotation: z.ZodDefault<z.ZodOptional<z.ZodObject<{
2444
2411
  max_bytes: z.ZodDefault<z.ZodNumber>;
2445
2412
  max_entries: z.ZodDefault<z.ZodNumber>;
@@ -2451,12 +2418,28 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2451
2418
  max_entries?: number | undefined;
2452
2419
  }>>>;
2453
2420
  }, "strip", z.ZodTypeAny, {
2421
+ strict: boolean;
2422
+ enabled: boolean;
2423
+ rotation: {
2424
+ max_bytes: number;
2425
+ max_entries: number;
2426
+ };
2427
+ }, {
2428
+ strict?: boolean | undefined;
2429
+ enabled?: boolean | undefined;
2430
+ rotation?: {
2431
+ max_bytes?: number | undefined;
2432
+ max_entries?: number | undefined;
2433
+ } | undefined;
2434
+ }>, {
2435
+ strict: boolean;
2454
2436
  enabled: boolean;
2455
2437
  rotation: {
2456
2438
  max_bytes: number;
2457
2439
  max_entries: number;
2458
2440
  };
2459
2441
  }, {
2442
+ strict?: boolean | undefined;
2460
2443
  enabled?: boolean | undefined;
2461
2444
  rotation?: {
2462
2445
  max_bytes?: number | undefined;
@@ -2488,10 +2471,11 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2488
2471
  }, "strip", z.ZodTypeAny, {
2489
2472
  schema: Record<string, any>;
2490
2473
  blacklist: {
2491
- columns: Record<string, string[]>;
2492
2474
  tables: string[];
2475
+ columns: Record<string, string[]>;
2493
2476
  };
2494
2477
  audit: {
2478
+ strict: boolean;
2495
2479
  enabled: boolean;
2496
2480
  rotation: {
2497
2481
  max_bytes: number;
@@ -2626,116 +2610,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2626
2610
  }, {
2627
2611
  version: 2;
2628
2612
  default: string;
2629
- connections: Record<string, {
2630
- system: "postgresql" | "mysql" | "mariadb";
2631
- host: string | {
2632
- $env: string;
2633
- };
2634
- port: number | {
2635
- $env: string;
2636
- };
2637
- user: string | {
2638
- $env: string;
2639
- };
2640
- database: string | {
2641
- $env: string;
2642
- };
2643
- password?: string | {
2644
- $env: string;
2645
- } | undefined;
2646
- timeout?: number | undefined;
2647
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2648
- statementTimeout?: number | undefined;
2649
- envFile?: string | undefined;
2650
- environment?: string | undefined;
2651
- } | {
2652
- system: "mongodb";
2653
- password?: string | {
2654
- $env: string;
2655
- } | undefined;
2656
- host?: string | {
2657
- $env: string;
2658
- } | undefined;
2659
- port?: number | {
2660
- $env: string;
2661
- } | undefined;
2662
- user?: string | {
2663
- $env: string;
2664
- } | undefined;
2665
- database?: string | {
2666
- $env: string;
2667
- } | undefined;
2668
- uri?: string | {
2669
- $env: string;
2670
- } | undefined;
2671
- authSource?: string | {
2672
- $env: string;
2673
- } | undefined;
2674
- replicaSet?: string | {
2675
- $env: string;
2676
- } | undefined;
2677
- tls?: boolean | undefined;
2678
- srv?: boolean | undefined;
2679
- timeout?: number | undefined;
2680
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2681
- statementTimeout?: number | undefined;
2682
- envFile?: string | undefined;
2683
- environment?: string | undefined;
2684
- } | {
2685
- system: "redis";
2686
- host: string | {
2687
- $env: string;
2688
- };
2689
- port: number | {
2690
- $env: string;
2691
- };
2692
- password?: string | {
2693
- $env: string;
2694
- } | undefined;
2695
- user?: string | {
2696
- $env: string;
2697
- } | undefined;
2698
- database?: string | {
2699
- $env: string;
2700
- } | undefined;
2701
- timeout?: number | undefined;
2702
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2703
- statementTimeout?: number | undefined;
2704
- envFile?: string | undefined;
2705
- environment?: string | undefined;
2706
- } | {
2707
- system: "elasticsearch";
2708
- password?: string | {
2709
- $env: string;
2710
- } | undefined;
2711
- host?: string | {
2712
- $env: string;
2713
- } | undefined;
2714
- port?: number | {
2715
- $env: string;
2716
- } | undefined;
2717
- user?: string | {
2718
- $env: string;
2719
- } | undefined;
2720
- database?: string | {
2721
- $env: string;
2722
- } | undefined;
2723
- rejectUnauthorized?: boolean | undefined;
2724
- timeout?: number | undefined;
2725
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2726
- statementTimeout?: number | undefined;
2727
- protocol?: "http" | "https" | undefined;
2728
- nodes?: string[] | undefined;
2729
- cloudId?: string | {
2730
- $env: string;
2731
- } | undefined;
2732
- apiKey?: string | {
2733
- $env: string;
2734
- } | undefined;
2735
- caPath?: string | undefined;
2736
- envFile?: string | undefined;
2737
- environment?: string | undefined;
2738
- }>;
2613
+ connections: Record<string, unknown>;
2739
2614
  redis?: {
2740
2615
  mask?: {
2741
2616
  keyPattern: string;
@@ -2743,11 +2618,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2743
2618
  }[] | undefined;
2744
2619
  } | undefined;
2745
2620
  schema?: Record<string, any> | undefined;
2746
- blacklist?: {
2747
- columns?: Record<string, string[]> | undefined;
2748
- tables?: string[] | undefined;
2749
- } | undefined;
2621
+ blacklist?: z.objectInputType<{
2622
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2623
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2624
+ }, z.ZodTypeAny, "passthrough"> | undefined;
2750
2625
  audit?: {
2626
+ strict?: boolean | undefined;
2751
2627
  enabled?: boolean | undefined;
2752
2628
  rotation?: {
2753
2629
  max_bytes?: number | undefined;
@@ -2764,10 +2640,11 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2764
2640
  }>, {
2765
2641
  schema: Record<string, any>;
2766
2642
  blacklist: {
2767
- columns: Record<string, string[]>;
2768
2643
  tables: string[];
2644
+ columns: Record<string, string[]>;
2769
2645
  };
2770
2646
  audit: {
2647
+ strict: boolean;
2771
2648
  enabled: boolean;
2772
2649
  rotation: {
2773
2650
  max_bytes: number;
@@ -2902,116 +2779,7 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2902
2779
  }, {
2903
2780
  version: 2;
2904
2781
  default: string;
2905
- connections: Record<string, {
2906
- system: "postgresql" | "mysql" | "mariadb";
2907
- host: string | {
2908
- $env: string;
2909
- };
2910
- port: number | {
2911
- $env: string;
2912
- };
2913
- user: string | {
2914
- $env: string;
2915
- };
2916
- database: string | {
2917
- $env: string;
2918
- };
2919
- password?: string | {
2920
- $env: string;
2921
- } | undefined;
2922
- timeout?: number | undefined;
2923
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2924
- statementTimeout?: number | undefined;
2925
- envFile?: string | undefined;
2926
- environment?: string | undefined;
2927
- } | {
2928
- system: "mongodb";
2929
- password?: string | {
2930
- $env: string;
2931
- } | undefined;
2932
- host?: string | {
2933
- $env: string;
2934
- } | undefined;
2935
- port?: number | {
2936
- $env: string;
2937
- } | undefined;
2938
- user?: string | {
2939
- $env: string;
2940
- } | undefined;
2941
- database?: string | {
2942
- $env: string;
2943
- } | undefined;
2944
- uri?: string | {
2945
- $env: string;
2946
- } | undefined;
2947
- authSource?: string | {
2948
- $env: string;
2949
- } | undefined;
2950
- replicaSet?: string | {
2951
- $env: string;
2952
- } | undefined;
2953
- tls?: boolean | undefined;
2954
- srv?: boolean | undefined;
2955
- timeout?: number | undefined;
2956
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2957
- statementTimeout?: number | undefined;
2958
- envFile?: string | undefined;
2959
- environment?: string | undefined;
2960
- } | {
2961
- system: "redis";
2962
- host: string | {
2963
- $env: string;
2964
- };
2965
- port: number | {
2966
- $env: string;
2967
- };
2968
- password?: string | {
2969
- $env: string;
2970
- } | undefined;
2971
- user?: string | {
2972
- $env: string;
2973
- } | undefined;
2974
- database?: string | {
2975
- $env: string;
2976
- } | undefined;
2977
- timeout?: number | undefined;
2978
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2979
- statementTimeout?: number | undefined;
2980
- envFile?: string | undefined;
2981
- environment?: string | undefined;
2982
- } | {
2983
- system: "elasticsearch";
2984
- password?: string | {
2985
- $env: string;
2986
- } | undefined;
2987
- host?: string | {
2988
- $env: string;
2989
- } | undefined;
2990
- port?: number | {
2991
- $env: string;
2992
- } | undefined;
2993
- user?: string | {
2994
- $env: string;
2995
- } | undefined;
2996
- database?: string | {
2997
- $env: string;
2998
- } | undefined;
2999
- rejectUnauthorized?: boolean | undefined;
3000
- timeout?: number | undefined;
3001
- permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
3002
- statementTimeout?: number | undefined;
3003
- protocol?: "http" | "https" | undefined;
3004
- nodes?: string[] | undefined;
3005
- cloudId?: string | {
3006
- $env: string;
3007
- } | undefined;
3008
- apiKey?: string | {
3009
- $env: string;
3010
- } | undefined;
3011
- caPath?: string | undefined;
3012
- envFile?: string | undefined;
3013
- environment?: string | undefined;
3014
- }>;
2782
+ connections: Record<string, unknown>;
3015
2783
  redis?: {
3016
2784
  mask?: {
3017
2785
  keyPattern: string;
@@ -3019,11 +2787,12 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
3019
2787
  }[] | undefined;
3020
2788
  } | undefined;
3021
2789
  schema?: Record<string, any> | undefined;
3022
- blacklist?: {
3023
- columns?: Record<string, string[]> | undefined;
3024
- tables?: string[] | undefined;
3025
- } | undefined;
2790
+ blacklist?: z.objectInputType<{
2791
+ tables: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
2792
+ columns: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2793
+ }, z.ZodTypeAny, "passthrough"> | undefined;
3026
2794
  audit?: {
2795
+ strict?: boolean | undefined;
3027
2796
  enabled?: boolean | undefined;
3028
2797
  rotation?: {
3029
2798
  max_bytes?: number | undefined;