@carllee1983/dbcli 8.0.0 → 9.1.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/cli.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@carllee1983/dbcli",
6
- version: "8.0.0",
6
+ version: "9.1.0",
7
7
  description: "Database CLI for AI agents",
8
8
  type: "module",
9
9
  publishConfig: {
@@ -84,15 +84,15 @@ var package_default = {
84
84
  "services:check": "bun run scripts/check-test-services.ts",
85
85
  "docs:check": "bun run scripts/check-user-docs.ts",
86
86
  "contract:check": "bun run scripts/check-cli-contract.ts",
87
- "skill:check": "bun run scripts/check-skill-parity.ts",
88
87
  "platform:check": "bun run scripts/check-platform-parity.ts",
89
88
  "agent-core:check": "bun run scripts/check-agent-core-purity.ts",
90
89
  "core-stdout:check": "bun run scripts/check-core-no-stdout.ts",
91
90
  "plan:check": "bun run scripts/check-plan-acceptance.ts",
92
91
  "forgeflow:check": "bun run scripts/check-forgeflow-adoption.ts && bun run scripts/check-forgeflow-handoff.ts",
92
+ "forgeflow:contract": "bun run scripts/check-forgeflow-contract.ts",
93
93
  typecheck: "tsc --noEmit --pretty false",
94
94
  "typecheck:tests": "tsc --noEmit --pretty false -p tsconfig.tests.json",
95
- "test:perf": "bun test ./tests/perf/*.bench.ts",
95
+ "test:perf": "bun test --timeout 30000 ./tests/perf/*.bench.ts",
96
96
  lint: "eslint src tests scripts --ext .ts --max-warnings=0",
97
97
  "format:check": "prettier --check .",
98
98
  format: "prettier --write .",
package/dist/core.d.ts CHANGED
@@ -6,8 +6,8 @@ import { z } from 'zod';
6
6
  * Database adapter type definitions and interfaces
7
7
  * Defines the contract that all database adapters must implement
8
8
  */
9
- export type DatabaseSystem = "postgresql" | "mysql" | "mariadb" | "mongodb" | "redis" | "elasticsearch";
10
- type SqlDatabaseSystem = Extract<DatabaseSystem, "postgresql" | "mysql" | "mariadb">;
9
+ export type DatabaseSystem = "postgresql" | "mysql" | "mariadb" | "sqlite" | "mongodb" | "redis" | "elasticsearch";
10
+ type SqlDatabaseSystem = Extract<DatabaseSystem, "postgresql" | "mysql" | "mariadb" | "sqlite">;
11
11
  type SqlExecutionMode = "normal" | "native-read-only";
12
12
  type QueryableDatabaseSystem = Exclude<DatabaseSystem, SqlDatabaseSystem>;
13
13
  /**
@@ -26,6 +26,8 @@ export interface ConnectionOptions {
26
26
  password: string;
27
27
  /** Database name */
28
28
  database: string;
29
+ /** SQLite database file path (required for SQLite connections, absent otherwise) */
30
+ file?: string;
29
31
  /** MongoDB connection URI (optional, for MongoDB connections) */
30
32
  uri?: string;
31
33
  /** MongoDB auth database — used when building URI from host/port/user/password (default: 'admin') */
@@ -389,6 +391,27 @@ interface SqlConnectionConfig {
389
391
  $env: string;
390
392
  };
391
393
  }
394
+ interface SqliteConnectionConfig {
395
+ system: "sqlite";
396
+ file: string | {
397
+ $env: string;
398
+ };
399
+ host: string | {
400
+ $env: string;
401
+ };
402
+ port: number | {
403
+ $env: string;
404
+ };
405
+ user: string | {
406
+ $env: string;
407
+ };
408
+ password: string | {
409
+ $env: string;
410
+ };
411
+ database: string | {
412
+ $env: string;
413
+ };
414
+ }
392
415
  interface MongoDBConnectionConfig {
393
416
  system: "mongodb";
394
417
  uri?: string | {
@@ -467,7 +490,7 @@ interface ElasticsearchConnectionConfig {
467
490
  caPath?: string;
468
491
  rejectUnauthorized?: boolean;
469
492
  }
470
- type ConnectionConfig = SqlConnectionConfig | MongoDBConnectionConfig | RedisConnectionConfig | ElasticsearchConnectionConfig;
493
+ type ConnectionConfig = SqlConnectionConfig | SqliteConnectionConfig | MongoDBConnectionConfig | RedisConnectionConfig | ElasticsearchConnectionConfig;
471
494
  /**
472
495
  * Permission level (coarse-grained access control)
473
496
  */
@@ -544,7 +567,8 @@ export interface QueryResult<T> {
544
567
  declare const SQL_DIALECTS: readonly [
545
568
  "postgresql",
546
569
  "mysql",
547
- "mariadb"
570
+ "mariadb",
571
+ "sqlite"
548
572
  ];
549
573
  type SqlDialect = (typeof SQL_DIALECTS)[number];
550
574
  export declare class BlacklistManager {
@@ -635,9 +659,40 @@ export declare class BlacklistManager {
635
659
  */
636
660
  getState(): BlacklistState;
637
661
  }
662
+ interface MaskingCost {
663
+ /** Rows walked to collect the column names present. */
664
+ readonly rowsScanned: number;
665
+ /** Own property names read during that pass. */
666
+ readonly keysScanned: number;
667
+ /** Blacklist rules considered against the result. */
668
+ readonly ruleEvaluations: number;
669
+ /** Rules whose dotted path had to be split into segments. */
670
+ readonly pathSplits: number;
671
+ /**
672
+ * Rows a literal dotted rule descended into.
673
+ *
674
+ * The regression this exists for: deciding once for the whole result set
675
+ * whether recursion is needed puts every row on this path, where deciding per
676
+ * rule leaves it at zero for a rule whose head is never an object.
677
+ */
678
+ readonly nestedProbeRows: number;
679
+ /** Rows the nested wildcard walk descended into. */
680
+ readonly nestedGlobRows: number;
681
+ /**
682
+ * Nested wildcard *rules* found to match.
683
+ *
684
+ * The regression this exists for: collecting matched keys instead of matched
685
+ * rules made the removal pass rebuild each record once per key per row — 200
686
+ * rows of 20 row-specific keys measured 1.8s. One rule that hits a different
687
+ * key in every row is one entry here, not one per row.
688
+ */
689
+ readonly nestedGlobMatches: number;
690
+ }
638
691
  interface FilterColumnsResult {
639
692
  filteredRows: Record<string, unknown>[];
640
693
  omittedColumns: string[];
694
+ /** See {@link MaskingCost}. */
695
+ cost: MaskingCost;
641
696
  /**
642
697
  * Whether a caller-supplied field path is covered by what was omitted.
643
698
  *
@@ -852,6 +907,119 @@ declare const DbcliConfigSchema: z.ZodObject<{
852
907
  timeout?: number | undefined;
853
908
  statementTimeout?: number | undefined;
854
909
  }>,
910
+ z.ZodObject<{
911
+ timeout: z.ZodOptional<z.ZodNumber>;
912
+ statementTimeout: z.ZodOptional<z.ZodNumber>;
913
+ system: z.ZodLiteral<"sqlite">;
914
+ file: z.ZodEffects<z.ZodUnion<[
915
+ z.ZodString,
916
+ z.ZodObject<{
917
+ $env: z.ZodString;
918
+ }, "strict", z.ZodTypeAny, {
919
+ $env: string;
920
+ }, {
921
+ $env: string;
922
+ }>
923
+ ]>, string | {
924
+ $env: string;
925
+ }, string | {
926
+ $env: string;
927
+ }>;
928
+ host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
929
+ z.ZodString,
930
+ z.ZodObject<{
931
+ $env: z.ZodString;
932
+ }, "strict", z.ZodTypeAny, {
933
+ $env: string;
934
+ }, {
935
+ $env: string;
936
+ }>
937
+ ]>>>;
938
+ port: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
939
+ z.ZodNumber,
940
+ z.ZodObject<{
941
+ $env: z.ZodString;
942
+ }, "strict", z.ZodTypeAny, {
943
+ $env: string;
944
+ }, {
945
+ $env: string;
946
+ }>
947
+ ]>>>;
948
+ user: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
949
+ z.ZodString,
950
+ z.ZodObject<{
951
+ $env: z.ZodString;
952
+ }, "strict", z.ZodTypeAny, {
953
+ $env: string;
954
+ }, {
955
+ $env: string;
956
+ }>
957
+ ]>>>;
958
+ password: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
959
+ z.ZodString,
960
+ z.ZodObject<{
961
+ $env: z.ZodString;
962
+ }, "strict", z.ZodTypeAny, {
963
+ $env: string;
964
+ }, {
965
+ $env: string;
966
+ }>
967
+ ]>>>;
968
+ database: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
969
+ z.ZodString,
970
+ z.ZodObject<{
971
+ $env: z.ZodString;
972
+ }, "strict", z.ZodTypeAny, {
973
+ $env: string;
974
+ }, {
975
+ $env: string;
976
+ }>
977
+ ]>>>;
978
+ }, "strip", z.ZodTypeAny, {
979
+ password: string | {
980
+ $env: string;
981
+ };
982
+ system: "sqlite";
983
+ host: string | {
984
+ $env: string;
985
+ };
986
+ port: number | {
987
+ $env: string;
988
+ };
989
+ user: string | {
990
+ $env: string;
991
+ };
992
+ database: string | {
993
+ $env: string;
994
+ };
995
+ file: string | {
996
+ $env: string;
997
+ };
998
+ timeout?: number | undefined;
999
+ statementTimeout?: number | undefined;
1000
+ }, {
1001
+ system: "sqlite";
1002
+ file: string | {
1003
+ $env: string;
1004
+ };
1005
+ password?: string | {
1006
+ $env: string;
1007
+ } | undefined;
1008
+ host?: string | {
1009
+ $env: string;
1010
+ } | undefined;
1011
+ port?: number | {
1012
+ $env: string;
1013
+ } | undefined;
1014
+ user?: string | {
1015
+ $env: string;
1016
+ } | undefined;
1017
+ database?: string | {
1018
+ $env: string;
1019
+ } | undefined;
1020
+ timeout?: number | undefined;
1021
+ statementTimeout?: number | undefined;
1022
+ }>,
855
1023
  z.ZodObject<{
856
1024
  timeout: z.ZodOptional<z.ZodNumber>;
857
1025
  statementTimeout: z.ZodOptional<z.ZodNumber>;
@@ -1422,6 +1590,28 @@ declare const DbcliConfigSchema: z.ZodObject<{
1422
1590
  };
1423
1591
  timeout?: number | undefined;
1424
1592
  statementTimeout?: number | undefined;
1593
+ } | {
1594
+ password: string | {
1595
+ $env: string;
1596
+ };
1597
+ system: "sqlite";
1598
+ host: string | {
1599
+ $env: string;
1600
+ };
1601
+ port: number | {
1602
+ $env: string;
1603
+ };
1604
+ user: string | {
1605
+ $env: string;
1606
+ };
1607
+ database: string | {
1608
+ $env: string;
1609
+ };
1610
+ file: string | {
1611
+ $env: string;
1612
+ };
1613
+ timeout?: number | undefined;
1614
+ statementTimeout?: number | undefined;
1425
1615
  } | {
1426
1616
  password: string | {
1427
1617
  $env: string;
@@ -1533,6 +1723,28 @@ declare const DbcliConfigSchema: z.ZodObject<{
1533
1723
  } | undefined;
1534
1724
  timeout?: number | undefined;
1535
1725
  statementTimeout?: number | undefined;
1726
+ } | {
1727
+ system: "sqlite";
1728
+ file: string | {
1729
+ $env: string;
1730
+ };
1731
+ password?: string | {
1732
+ $env: string;
1733
+ } | undefined;
1734
+ host?: string | {
1735
+ $env: string;
1736
+ } | undefined;
1737
+ port?: number | {
1738
+ $env: string;
1739
+ } | undefined;
1740
+ user?: string | {
1741
+ $env: string;
1742
+ } | undefined;
1743
+ database?: string | {
1744
+ $env: string;
1745
+ } | undefined;
1746
+ timeout?: number | undefined;
1747
+ statementTimeout?: number | undefined;
1536
1748
  } | {
1537
1749
  system: "redis";
1538
1750
  host: string | {
@@ -1729,6 +1941,134 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
1729
1941
  envFile?: string | undefined;
1730
1942
  environment?: string | undefined;
1731
1943
  }>,
1944
+ z.ZodObject<{
1945
+ timeout: z.ZodOptional<z.ZodNumber>;
1946
+ statementTimeout: z.ZodOptional<z.ZodNumber>;
1947
+ system: z.ZodLiteral<"sqlite">;
1948
+ file: z.ZodEffects<z.ZodUnion<[
1949
+ z.ZodString,
1950
+ z.ZodObject<{
1951
+ $env: z.ZodString;
1952
+ }, "strict", z.ZodTypeAny, {
1953
+ $env: string;
1954
+ }, {
1955
+ $env: string;
1956
+ }>
1957
+ ]>, string | {
1958
+ $env: string;
1959
+ }, string | {
1960
+ $env: string;
1961
+ }>;
1962
+ host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
1963
+ z.ZodString,
1964
+ z.ZodObject<{
1965
+ $env: z.ZodString;
1966
+ }, "strict", z.ZodTypeAny, {
1967
+ $env: string;
1968
+ }, {
1969
+ $env: string;
1970
+ }>
1971
+ ]>>>;
1972
+ port: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
1973
+ z.ZodNumber,
1974
+ z.ZodObject<{
1975
+ $env: z.ZodString;
1976
+ }, "strict", z.ZodTypeAny, {
1977
+ $env: string;
1978
+ }, {
1979
+ $env: string;
1980
+ }>
1981
+ ]>>>;
1982
+ user: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
1983
+ z.ZodString,
1984
+ z.ZodObject<{
1985
+ $env: z.ZodString;
1986
+ }, "strict", z.ZodTypeAny, {
1987
+ $env: string;
1988
+ }, {
1989
+ $env: string;
1990
+ }>
1991
+ ]>>>;
1992
+ password: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
1993
+ z.ZodString,
1994
+ z.ZodObject<{
1995
+ $env: z.ZodString;
1996
+ }, "strict", z.ZodTypeAny, {
1997
+ $env: string;
1998
+ }, {
1999
+ $env: string;
2000
+ }>
2001
+ ]>>>;
2002
+ database: z.ZodDefault<z.ZodOptional<z.ZodUnion<[
2003
+ z.ZodString,
2004
+ z.ZodObject<{
2005
+ $env: z.ZodString;
2006
+ }, "strict", z.ZodTypeAny, {
2007
+ $env: string;
2008
+ }, {
2009
+ $env: string;
2010
+ }>
2011
+ ]>>>;
2012
+ } & {
2013
+ permission: z.ZodDefault<z.ZodEnum<[
2014
+ "query-only",
2015
+ "read-write",
2016
+ "data-admin",
2017
+ "admin"
2018
+ ]>>;
2019
+ envFile: z.ZodOptional<z.ZodString>;
2020
+ environment: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
2021
+ }, "strip", z.ZodTypeAny, {
2022
+ password: string | {
2023
+ $env: string;
2024
+ };
2025
+ system: "sqlite";
2026
+ host: string | {
2027
+ $env: string;
2028
+ };
2029
+ port: number | {
2030
+ $env: string;
2031
+ };
2032
+ user: string | {
2033
+ $env: string;
2034
+ };
2035
+ database: string | {
2036
+ $env: string;
2037
+ };
2038
+ file: string | {
2039
+ $env: string;
2040
+ };
2041
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2042
+ timeout?: number | undefined;
2043
+ statementTimeout?: number | undefined;
2044
+ envFile?: string | undefined;
2045
+ environment?: string | undefined;
2046
+ }, {
2047
+ system: "sqlite";
2048
+ file: string | {
2049
+ $env: string;
2050
+ };
2051
+ password?: string | {
2052
+ $env: string;
2053
+ } | undefined;
2054
+ host?: string | {
2055
+ $env: string;
2056
+ } | undefined;
2057
+ port?: number | {
2058
+ $env: string;
2059
+ } | undefined;
2060
+ user?: string | {
2061
+ $env: string;
2062
+ } | undefined;
2063
+ database?: string | {
2064
+ $env: string;
2065
+ } | undefined;
2066
+ timeout?: number | undefined;
2067
+ permission?: "admin" | "query-only" | "read-write" | "data-admin" | undefined;
2068
+ statementTimeout?: number | undefined;
2069
+ envFile?: string | undefined;
2070
+ environment?: string | undefined;
2071
+ }>,
1732
2072
  z.ZodObject<{
1733
2073
  timeout: z.ZodOptional<z.ZodNumber>;
1734
2074
  statementTimeout: z.ZodOptional<z.ZodNumber>;
@@ -2176,6 +2516,31 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2176
2516
  statementTimeout?: number | undefined;
2177
2517
  envFile?: string | undefined;
2178
2518
  environment?: string | undefined;
2519
+ } | {
2520
+ password: string | {
2521
+ $env: string;
2522
+ };
2523
+ system: "sqlite";
2524
+ host: string | {
2525
+ $env: string;
2526
+ };
2527
+ port: number | {
2528
+ $env: string;
2529
+ };
2530
+ user: string | {
2531
+ $env: string;
2532
+ };
2533
+ database: string | {
2534
+ $env: string;
2535
+ };
2536
+ file: string | {
2537
+ $env: string;
2538
+ };
2539
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2540
+ timeout?: number | undefined;
2541
+ statementTimeout?: number | undefined;
2542
+ envFile?: string | undefined;
2543
+ environment?: string | undefined;
2179
2544
  } | {
2180
2545
  password: string | {
2181
2546
  $env: string;
@@ -2285,6 +2650,31 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2285
2650
  statementTimeout?: number | undefined;
2286
2651
  envFile?: string | undefined;
2287
2652
  environment?: string | undefined;
2653
+ } | {
2654
+ password: string | {
2655
+ $env: string;
2656
+ };
2657
+ system: "sqlite";
2658
+ host: string | {
2659
+ $env: string;
2660
+ };
2661
+ port: number | {
2662
+ $env: string;
2663
+ };
2664
+ user: string | {
2665
+ $env: string;
2666
+ };
2667
+ database: string | {
2668
+ $env: string;
2669
+ };
2670
+ file: string | {
2671
+ $env: string;
2672
+ };
2673
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2674
+ timeout?: number | undefined;
2675
+ statementTimeout?: number | undefined;
2676
+ envFile?: string | undefined;
2677
+ environment?: string | undefined;
2288
2678
  } | {
2289
2679
  password: string | {
2290
2680
  $env: string;
@@ -2537,6 +2927,31 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2537
2927
  statementTimeout?: number | undefined;
2538
2928
  envFile?: string | undefined;
2539
2929
  environment?: string | undefined;
2930
+ } | {
2931
+ password: string | {
2932
+ $env: string;
2933
+ };
2934
+ system: "sqlite";
2935
+ host: string | {
2936
+ $env: string;
2937
+ };
2938
+ port: number | {
2939
+ $env: string;
2940
+ };
2941
+ user: string | {
2942
+ $env: string;
2943
+ };
2944
+ database: string | {
2945
+ $env: string;
2946
+ };
2947
+ file: string | {
2948
+ $env: string;
2949
+ };
2950
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
2951
+ timeout?: number | undefined;
2952
+ statementTimeout?: number | undefined;
2953
+ envFile?: string | undefined;
2954
+ environment?: string | undefined;
2540
2955
  } | {
2541
2956
  password: string | {
2542
2957
  $env: string;
@@ -2706,6 +3121,31 @@ declare const DbcliConfigV2Schema: z.ZodEffects<z.ZodObject<{
2706
3121
  statementTimeout?: number | undefined;
2707
3122
  envFile?: string | undefined;
2708
3123
  environment?: string | undefined;
3124
+ } | {
3125
+ password: string | {
3126
+ $env: string;
3127
+ };
3128
+ system: "sqlite";
3129
+ host: string | {
3130
+ $env: string;
3131
+ };
3132
+ port: number | {
3133
+ $env: string;
3134
+ };
3135
+ user: string | {
3136
+ $env: string;
3137
+ };
3138
+ database: string | {
3139
+ $env: string;
3140
+ };
3141
+ file: string | {
3142
+ $env: string;
3143
+ };
3144
+ permission: "admin" | "query-only" | "read-write" | "data-admin";
3145
+ timeout?: number | undefined;
3146
+ statementTimeout?: number | undefined;
3147
+ envFile?: string | undefined;
3148
+ environment?: string | undefined;
2709
3149
  } | {
2710
3150
  password: string | {
2711
3151
  $env: string;
@@ -2893,7 +3333,7 @@ export declare class DataExecutor {
2893
3333
  private permission;
2894
3334
  private dbSystem;
2895
3335
  private blacklistValidator?;
2896
- constructor(adapter: DatabaseAdapter, permission: Permission, dbSystem?: "postgresql" | "mysql", blacklistValidator?: BlacklistValidator | undefined);
3336
+ constructor(adapter: DatabaseAdapter, permission: Permission, dbSystem?: SqlDatabaseSystem, blacklistValidator?: BlacklistValidator | undefined);
2897
3337
  /**
2898
3338
  * Build a parameterized INSERT SQL statement
2899
3339
  * Returns {sql, params} form to prevent SQL injection
@@ -3145,7 +3585,10 @@ export declare function detectConfigVersion(raw: unknown): 1 | 2;
3145
3585
  export interface ResolvedConnection {
3146
3586
  name: string;
3147
3587
  connection: {
3148
- system: "postgresql" | "mysql" | "mariadb" | "mongodb" | "redis" | "elasticsearch";
3588
+ system: DatabaseSystem;
3589
+ file?: string | {
3590
+ $env: string;
3591
+ };
3149
3592
  host: string | {
3150
3593
  $env: string;
3151
3594
  };
@@ -3213,6 +3656,9 @@ export declare function listConnections(config: DbcliConfigV2): Array<{
3213
3656
  uri?: string | {
3214
3657
  $env: string;
3215
3658
  };
3659
+ file?: string | {
3660
+ $env: string;
3661
+ };
3216
3662
  isDefault: boolean;
3217
3663
  }>;
3218
3664
  export type SqlSystem = "postgresql" | "mysql" | "mariadb";