@elyracode/db-tools 0.9.47 → 0.9.49

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 ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## [0.9.49] - 2026-10-10
4
+
5
+ ### Changed
6
+ - The MySQL and ClickHouse drivers load on the first query instead of at extension load, which removes about 25 ms from every Elyra startup, including sessions that never touch a database
@@ -1,10 +1,20 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import type { ExtensionAPI } from "@elyracode/coding-agent";
4
- import { createClient } from "@clickhouse/client";
5
- import mysql2 from "mysql2/promise";
4
+ import type * as ClickHouse from "@clickhouse/client";
5
+ import type * as MySql from "mysql2/promise";
6
6
  import { Type } from "typebox";
7
7
 
8
+ /**
9
+ * Database drivers load on the first query. Importing mysql2 and the ClickHouse client at
10
+ * extension load added about 20 ms to every Elyra startup, including sessions that never
11
+ * touch a database (measured 2026-10-10).
12
+ */
13
+ let mysqlDriver: Promise<typeof MySql> | undefined;
14
+ let clickhouseDriver: Promise<typeof ClickHouse> | undefined;
15
+ const loadMysql = (): Promise<typeof MySql> => (mysqlDriver ??= import("mysql2/promise"));
16
+ const loadClickHouse = (): Promise<typeof ClickHouse> => (clickhouseDriver ??= import("@clickhouse/client"));
17
+
8
18
  export default function (elyra: ExtensionAPI) {
9
19
  // ── Load .env ──
10
20
  // Reads the project's .env file (if it exists) and maps common Laravel/Docker
@@ -60,7 +70,7 @@ export default function (elyra: ExtensionAPI) {
60
70
  }
61
71
 
62
72
  try {
63
- const connection = await mysql2.createConnection({
73
+ const connection = await (await loadMysql()).createConnection({
64
74
  host: config.host,
65
75
  port: config.port,
66
76
  user: config.user,
@@ -137,7 +147,7 @@ export default function (elyra: ExtensionAPI) {
137
147
 
138
148
  try {
139
149
  const protocol = config.https ? "https" : "http";
140
- const client = createClient({
150
+ const client = (await loadClickHouse()).createClient({
141
151
  url: `${protocol}://${config.host}:${config.port}`,
142
152
  username: config.user,
143
153
  password: config.password,
@@ -424,7 +434,7 @@ async function getMysqlSchema(
424
434
  }
425
435
 
426
436
  try {
427
- const connection = await mysql2.createConnection({
437
+ const connection = await (await loadMysql()).createConnection({
428
438
  host: config.host,
429
439
  port: config.port,
430
440
  user: config.user,
@@ -498,7 +508,7 @@ async function getClickHouseSchema(
498
508
 
499
509
  try {
500
510
  const protocol = config.https ? "https" : "http";
501
- const client = createClient({
511
+ const client = (await loadClickHouse()).createClient({
502
512
  url: `${protocol}://${config.host}:${config.port}`,
503
513
  username: config.user,
504
514
  password: config.password,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/db-tools",
3
- "version": "0.9.47",
3
+ "version": "0.9.49",
4
4
  "description": "Database tools for Elyra - query MySQL and ClickHouse with schema awareness and safety guardrails",
5
5
  "type": "module",
6
6
  "keywords": [