@elyracode/db-tools 0.9.56 → 0.9.57

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.57] - 2026-11-10
4
+
3
5
  ## [0.9.56] - 2026-11-01
4
6
 
5
7
  ## [0.9.55] - 2026-10-21
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
4
3
  import type * as ClickHouse from "@clickhouse/client";
4
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
5
5
  import type * as MySql from "mysql2/promise";
6
6
  import { Type } from "typebox";
7
7
 
@@ -87,9 +87,7 @@ export default function (elyra: ExtensionAPI) {
87
87
  "By default, only SELECT queries are allowed (set ELYRA_DB_ALLOW_WRITES=true to allow writes).",
88
88
  parameters: Type.Object({
89
89
  sql: Type.String({ description: "The SQL query to execute" }),
90
- database: Type.Optional(
91
- Type.String({ description: "Override the default database (optional)" }),
92
- ),
90
+ database: Type.Optional(Type.String({ description: "Override the default database (optional)" })),
93
91
  }),
94
92
  execute: async (_toolCallId, params): Promise<AgentToolResult<QueryDetails>> => {
95
93
  const config = getMysqlConfig(params.database);
@@ -163,9 +161,7 @@ export default function (elyra: ExtensionAPI) {
163
161
  "Use get_database_schema first to understand the database structure. By default, only SELECT queries are allowed.",
164
162
  parameters: Type.Object({
165
163
  sql: Type.String({ description: "The SQL query to execute" }),
166
- database: Type.Optional(
167
- Type.String({ description: "Override the default database (optional)" }),
168
- ),
164
+ database: Type.Optional(Type.String({ description: "Override the default database (optional)" })),
169
165
  }),
170
166
  execute: async (_toolCallId, params): Promise<AgentToolResult<QueryDetails>> => {
171
167
  const config = getClickHouseConfig(params.database);
@@ -238,37 +234,45 @@ export default function (elyra: ExtensionAPI) {
238
234
  parameters: Type.Object({
239
235
  sql: Type.String({ description: "The SQL query to execute" }),
240
236
  db_path: Type.Optional(
241
- Type.String({ description: "Path to the SQLite database file (default: auto-detect from .env or database/database.sqlite)" }),
237
+ Type.String({
238
+ description:
239
+ "Path to the SQLite database file (default: auto-detect from .env or database/database.sqlite)",
240
+ }),
242
241
  ),
243
242
  }),
244
243
  execute: async (_toolCallId, params): Promise<AgentToolResult<QueryDetails>> => {
245
244
  const dbPath = resolveSqlitePath(params.db_path);
246
245
  if (!dbPath) {
247
246
  return {
248
- content: [{
249
- type: "text",
250
- text: "SQLite database not found. Provide db_path or set DB_CONNECTION=sqlite in .env.",
251
- }],
247
+ content: [
248
+ {
249
+ type: "text",
250
+ text: "SQLite database not found. Provide db_path or set DB_CONNECTION=sqlite in .env.",
251
+ },
252
+ ],
252
253
  details: {},
253
254
  };
254
255
  }
255
256
 
256
257
  if (!isReadOnly(params.sql) && !isWriteEnabled()) {
257
258
  return {
258
- content: [{
259
- type: "text",
260
- text: `Blocked: Only SELECT queries are allowed in read-only mode. Set ELYRA_DB_ALLOW_WRITES=true to enable writes.\n\nQuery: ${params.sql}`,
261
- }],
259
+ content: [
260
+ {
261
+ type: "text",
262
+ text: `Blocked: Only SELECT queries are allowed in read-only mode. Set ELYRA_DB_ALLOW_WRITES=true to enable writes.\n\nQuery: ${params.sql}`,
263
+ },
264
+ ],
262
265
  details: {},
263
266
  };
264
267
  }
265
268
 
266
269
  try {
267
270
  const { execSync } = await import("node:child_process");
268
- const result = execSync(
269
- `sqlite3 -json "${dbPath}" "${params.sql.replace(/"/g, '\\"')}"`,
270
- { timeout: 30000, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
271
- );
271
+ const result = execSync(`sqlite3 -json "${dbPath}" "${params.sql.replace(/"/g, '\\"')}"`, {
272
+ timeout: 30000,
273
+ encoding: "utf-8",
274
+ stdio: ["pipe", "pipe", "pipe"],
275
+ });
272
276
 
273
277
  const trimmed = result.trim();
274
278
  if (!trimmed) {
@@ -278,9 +282,10 @@ export default function (elyra: ExtensionAPI) {
278
282
  };
279
283
  }
280
284
 
281
- const truncated = trimmed.length > 50000
282
- ? `${trimmed.slice(0, 50000)}\n\n... (truncated, ${trimmed.length} chars total)`
283
- : trimmed;
285
+ const truncated =
286
+ trimmed.length > 50000
287
+ ? `${trimmed.slice(0, 50000)}\n\n... (truncated, ${trimmed.length} chars total)`
288
+ : trimmed;
284
289
 
285
290
  return {
286
291
  content: [{ type: "text", text: truncated }],
@@ -308,13 +313,10 @@ export default function (elyra: ExtensionAPI) {
308
313
  engine: Type.Union([Type.Literal("mysql"), Type.Literal("clickhouse"), Type.Literal("sqlite")], {
309
314
  description: "Which database engine to query",
310
315
  }),
311
- database: Type.Optional(
312
- Type.String({ description: "Override the default database (optional)" }),
313
- ),
316
+ database: Type.Optional(Type.String({ description: "Override the default database (optional)" })),
314
317
  table: Type.Optional(
315
318
  Type.String({
316
- description:
317
- "Get detailed schema for a specific table (optional, omit for overview of all tables)",
319
+ description: "Get detailed schema for a specific table (optional, omit for overview of all tables)",
318
320
  }),
319
321
  ),
320
322
  }),
@@ -441,7 +443,7 @@ const ENV_KEY_MAP: Array<[string, string]> = [
441
443
  ];
442
444
 
443
445
  /** Load .env from the project root and map keys to ELYRA_ equivalents */
444
- function loadEnvFile(elyra: ExtensionAPI): void {
446
+ function loadEnvFile(_elyra: ExtensionAPI): void {
445
447
  try {
446
448
  const cwd = process.cwd();
447
449
  const envPath = join(cwd, ".env");
@@ -642,19 +644,21 @@ function getSqliteSchema(
642
644
  const { execSync } = require("node:child_process");
643
645
 
644
646
  if (table) {
645
- const columns = execSync(
646
- `sqlite3 -json "${dbPath}" "PRAGMA table_info('${table}')"`,
647
- { timeout: 10000, encoding: "utf-8" },
648
- );
649
- const indexes = execSync(
650
- `sqlite3 -json "${dbPath}" "PRAGMA index_list('${table}')"`,
651
- { timeout: 10000, encoding: "utf-8" },
652
- );
647
+ const columns = execSync(`sqlite3 -json "${dbPath}" "PRAGMA table_info('${table}')"`, {
648
+ timeout: 10000,
649
+ encoding: "utf-8",
650
+ });
651
+ const indexes = execSync(`sqlite3 -json "${dbPath}" "PRAGMA index_list('${table}')"`, {
652
+ timeout: 10000,
653
+ encoding: "utf-8",
654
+ });
653
655
  return {
654
- content: [{
655
- type: "text",
656
- text: `Table: ${table}\n\nColumns:\n${columns.trim()}\n\nIndexes:\n${indexes.trim()}`,
657
- }],
656
+ content: [
657
+ {
658
+ type: "text",
659
+ text: `Table: ${table}\n\nColumns:\n${columns.trim()}\n\nIndexes:\n${indexes.trim()}`,
660
+ },
661
+ ],
658
662
  details: {},
659
663
  };
660
664
  }
@@ -664,10 +668,12 @@ function getSqliteSchema(
664
668
  { timeout: 10000, encoding: "utf-8" },
665
669
  );
666
670
  return {
667
- content: [{
668
- type: "text",
669
- text: `Database: ${dbPath}\n\nTables:\n${tables.trim()}`,
670
- }],
671
+ content: [
672
+ {
673
+ type: "text",
674
+ text: `Database: ${dbPath}\n\nTables:\n${tables.trim()}`,
675
+ },
676
+ ],
671
677
  details: {},
672
678
  };
673
679
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/db-tools",
3
- "version": "0.9.56",
3
+ "version": "0.9.57",
4
4
  "description": "Database tools for Elyra - query MySQL and ClickHouse with schema awareness and safety guardrails",
5
5
  "type": "module",
6
6
  "keywords": [