@dbx-app/cli 0.4.5 → 0.4.6
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.js +14 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { buildSchemaContext, createBackend, DIRECT_QUERY_TYPES, BRIDGE_REQUIRED_TYPES, evaluateSqlSafety, formatSchemaContext, getDbxDiagnostics, isMainModule, postBridge,
|
|
3
|
+
import { buildSchemaContext, createBackend, DIRECT_QUERY_TYPES, BRIDGE_REQUIRED_TYPES, evaluateSqlSafety, formatSchemaContext, getDbxDiagnostics, isMainModule, postBridge, } from "@dbx-app/node-core";
|
|
4
4
|
import { connectionSummary, csvTable, errorPayload, formatCell, formatErrorMessage, mdTable } from "./cli-format.js";
|
|
5
5
|
class CliError extends Error {
|
|
6
6
|
code;
|
|
@@ -108,7 +108,7 @@ export async function runCli(argv, options = {}) {
|
|
|
108
108
|
}
|
|
109
109
|
const sqlArg = usesDefaultConnection ? args[1] : args[2];
|
|
110
110
|
const sql = flags.file ? await readFile(flags.file, "utf-8") : required(sqlArg, "SQL string or --file is required.");
|
|
111
|
-
const envSafety =
|
|
111
|
+
const envSafety = sqlSafetyFromCliEnv(env);
|
|
112
112
|
if (flags.allowDangerous && !flags.allowWrites && !envSafety.allowWrites) {
|
|
113
113
|
throw new CliError("INVALID_OPTION", "--allow-dangerous-sql requires --allow-writes.");
|
|
114
114
|
}
|
|
@@ -270,6 +270,18 @@ function parseDurationMs(value, option) {
|
|
|
270
270
|
return amount * 1000;
|
|
271
271
|
return amount * 60_000;
|
|
272
272
|
}
|
|
273
|
+
function parseBooleanEnv(value) {
|
|
274
|
+
if (value === undefined)
|
|
275
|
+
return false;
|
|
276
|
+
const normalized = value.trim().toLowerCase();
|
|
277
|
+
return normalized === "1" || normalized === "true";
|
|
278
|
+
}
|
|
279
|
+
function sqlSafetyFromCliEnv(env) {
|
|
280
|
+
return {
|
|
281
|
+
allowWrites: parseBooleanEnv(env.DBX_MCP_ALLOW_WRITES),
|
|
282
|
+
allowDangerous: parseBooleanEnv(env.DBX_MCP_ALLOW_DANGEROUS_SQL),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
273
285
|
function splitCsv(value) {
|
|
274
286
|
return (value ?? "")
|
|
275
287
|
.split(",")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbx-app/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Command line interface for DBX database connections, schema, and safe queries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/t8y2/dbx/tree/main/packages/cli",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@dbx-app/node-core": "^0.4.
|
|
34
|
+
"@dbx-app/node-core": "^0.4.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^22.15.21",
|