@dbx-app/cli 0.4.4 → 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 +15 -4
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
4
|
-
import { buildSchemaContext, createBackend, DIRECT_QUERY_TYPES, BRIDGE_REQUIRED_TYPES, evaluateSqlSafety, formatSchemaContext, getDbxDiagnostics, postBridge, sqlSafetyFromEnv, } from "@dbx-app/node-core";
|
|
3
|
+
import { buildSchemaContext, createBackend, DIRECT_QUERY_TYPES, BRIDGE_REQUIRED_TYPES, evaluateSqlSafety, formatSchemaContext, getDbxDiagnostics, isMainModule, postBridge, } from "@dbx-app/node-core";
|
|
5
4
|
import { connectionSummary, csvTable, errorPayload, formatCell, formatErrorMessage, mdTable } from "./cli-format.js";
|
|
6
5
|
class CliError extends Error {
|
|
7
6
|
code;
|
|
@@ -109,7 +108,7 @@ export async function runCli(argv, options = {}) {
|
|
|
109
108
|
}
|
|
110
109
|
const sqlArg = usesDefaultConnection ? args[1] : args[2];
|
|
111
110
|
const sql = flags.file ? await readFile(flags.file, "utf-8") : required(sqlArg, "SQL string or --file is required.");
|
|
112
|
-
const envSafety =
|
|
111
|
+
const envSafety = sqlSafetyFromCliEnv(env);
|
|
113
112
|
if (flags.allowDangerous && !flags.allowWrites && !envSafety.allowWrites) {
|
|
114
113
|
throw new CliError("INVALID_OPTION", "--allow-dangerous-sql requires --allow-writes.");
|
|
115
114
|
}
|
|
@@ -271,6 +270,18 @@ function parseDurationMs(value, option) {
|
|
|
271
270
|
return amount * 1000;
|
|
272
271
|
return amount * 60_000;
|
|
273
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
|
+
}
|
|
274
285
|
function splitCsv(value) {
|
|
275
286
|
return (value ?? "")
|
|
276
287
|
.split(",")
|
|
@@ -342,7 +353,7 @@ async function main() {
|
|
|
342
353
|
process.stderr.write(result.stderr);
|
|
343
354
|
process.exitCode = result.exitCode;
|
|
344
355
|
}
|
|
345
|
-
if (
|
|
356
|
+
if (isMainModule(import.meta.url, process.argv[1])) {
|
|
346
357
|
main().catch((error) => {
|
|
347
358
|
console.error(error instanceof Error ? error.message : String(error));
|
|
348
359
|
process.exitCode = 1;
|
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",
|