@dbcube/core 5.2.6 → 5.2.8
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/index.cjs +87 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +87 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,18 @@ export interface DatabaseConnectionConfig {
|
|
|
19
19
|
DATABASE: string;
|
|
20
20
|
/** Port (not used by SQLite) */
|
|
21
21
|
PORT?: number | string;
|
|
22
|
+
/**
|
|
23
|
+
* Full connection string. When set, it overrides HOST/USER/PASSWORD/PORT and
|
|
24
|
+
* enables TLS for cloud databases:
|
|
25
|
+
* postgresql://user:pass@host:5432/db?sslmode=require (Supabase/Neon/RDS)
|
|
26
|
+
* mysql://user:pass@host:3306/db?ssl-mode=REQUIRED (PlanetScale/Aiven)
|
|
27
|
+
* mongodb+srv://user:pass@cluster.mongodb.net/db (Atlas)
|
|
28
|
+
* For MongoDB also set DATABASE to select the database.
|
|
29
|
+
* For Turso/libSQL use type "sqlite" + URL "libsql://your-db.turso.io" + AUTH_TOKEN.
|
|
30
|
+
*/
|
|
31
|
+
URL?: string;
|
|
32
|
+
/** Auth token for Turso/libSQL (type "sqlite" with a libsql:// URL). */
|
|
33
|
+
AUTH_TOKEN?: string;
|
|
22
34
|
}
|
|
23
35
|
/**
|
|
24
36
|
* Connection-pool tuning. Every field is optional — engine defaults apply
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,18 @@ export interface DatabaseConnectionConfig {
|
|
|
19
19
|
DATABASE: string;
|
|
20
20
|
/** Port (not used by SQLite) */
|
|
21
21
|
PORT?: number | string;
|
|
22
|
+
/**
|
|
23
|
+
* Full connection string. When set, it overrides HOST/USER/PASSWORD/PORT and
|
|
24
|
+
* enables TLS for cloud databases:
|
|
25
|
+
* postgresql://user:pass@host:5432/db?sslmode=require (Supabase/Neon/RDS)
|
|
26
|
+
* mysql://user:pass@host:3306/db?ssl-mode=REQUIRED (PlanetScale/Aiven)
|
|
27
|
+
* mongodb+srv://user:pass@cluster.mongodb.net/db (Atlas)
|
|
28
|
+
* For MongoDB also set DATABASE to select the database.
|
|
29
|
+
* For Turso/libSQL use type "sqlite" + URL "libsql://your-db.turso.io" + AUTH_TOKEN.
|
|
30
|
+
*/
|
|
31
|
+
URL?: string;
|
|
32
|
+
/** Auth token for Turso/libSQL (type "sqlite" with a libsql:// URL). */
|
|
33
|
+
AUTH_TOKEN?: string;
|
|
22
34
|
}
|
|
23
35
|
/**
|
|
24
36
|
* Connection-pool tuning. Every field is optional — engine defaults apply
|
package/dist/index.js
CHANGED
|
@@ -1120,16 +1120,34 @@ var Engine = class {
|
|
|
1120
1120
|
let args = [];
|
|
1121
1121
|
const motor = this.config.type === "postgres" ? "postgresql" : this.config.type;
|
|
1122
1122
|
if (this.config.type == "sqlite") {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1123
|
+
if (this.config.config.URL != null && this.config.config.URL !== "") {
|
|
1124
|
+
args = [
|
|
1125
|
+
"--id",
|
|
1126
|
+
"dbcube-" + this.name,
|
|
1127
|
+
"--database-ref",
|
|
1128
|
+
this.name,
|
|
1129
|
+
"--database",
|
|
1130
|
+
this.config.config.DATABASE ?? "",
|
|
1131
|
+
"--motor",
|
|
1132
|
+
motor,
|
|
1133
|
+
"--url",
|
|
1134
|
+
this.config.config.URL
|
|
1135
|
+
];
|
|
1136
|
+
if (this.config.config.AUTH_TOKEN != null && this.config.config.AUTH_TOKEN !== "") {
|
|
1137
|
+
args.push("--auth-token", this.config.config.AUTH_TOKEN);
|
|
1138
|
+
}
|
|
1139
|
+
} else {
|
|
1140
|
+
args = [
|
|
1141
|
+
"--id",
|
|
1142
|
+
"dbcube-" + this.name,
|
|
1143
|
+
"--database-ref",
|
|
1144
|
+
this.name,
|
|
1145
|
+
"--database",
|
|
1146
|
+
this.config.config.DATABASE + ".db",
|
|
1147
|
+
"--motor",
|
|
1148
|
+
motor
|
|
1149
|
+
];
|
|
1150
|
+
}
|
|
1133
1151
|
} else {
|
|
1134
1152
|
args = [
|
|
1135
1153
|
"--id",
|
|
@@ -1137,19 +1155,20 @@ var Engine = class {
|
|
|
1137
1155
|
"--database-ref",
|
|
1138
1156
|
this.name,
|
|
1139
1157
|
"--database",
|
|
1140
|
-
this.config.config.DATABASE,
|
|
1141
|
-
"--host",
|
|
1142
|
-
this.config.config.HOST,
|
|
1143
|
-
"--port",
|
|
1144
|
-
String(this.config.config.PORT),
|
|
1158
|
+
this.config.config.DATABASE ?? "",
|
|
1145
1159
|
"--motor",
|
|
1146
1160
|
motor
|
|
1147
1161
|
];
|
|
1148
|
-
if (this.config.config.
|
|
1149
|
-
args.push("--
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1162
|
+
if (this.config.config.URL != null && this.config.config.URL !== "") {
|
|
1163
|
+
args.push("--url", this.config.config.URL);
|
|
1164
|
+
} else {
|
|
1165
|
+
args.push("--host", this.config.config.HOST, "--port", String(this.config.config.PORT));
|
|
1166
|
+
if (this.config.config.USER != null && this.config.config.USER !== "") {
|
|
1167
|
+
args.push("--user", this.config.config.USER);
|
|
1168
|
+
}
|
|
1169
|
+
if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
|
|
1170
|
+
args.push("--password", this.config.config.PASSWORD);
|
|
1171
|
+
}
|
|
1153
1172
|
}
|
|
1154
1173
|
}
|
|
1155
1174
|
return args;
|
|
@@ -1466,14 +1485,21 @@ var EmbeddedEngine = class {
|
|
|
1466
1485
|
const be = loadBackend();
|
|
1467
1486
|
if (!be) throw new Error("embedded engine not available");
|
|
1468
1487
|
const motor = config.type === "postgres" ? "postgresql" : config.type;
|
|
1488
|
+
const isTurso = config.type === "sqlite" && !!config.config.URL;
|
|
1489
|
+
const database = config.type === "sqlite" && !isTurso ? `${config.config.DATABASE}.db` : config.config.DATABASE;
|
|
1469
1490
|
const cfg = {
|
|
1470
1491
|
databaseRef: connectionId,
|
|
1471
1492
|
motor,
|
|
1472
|
-
database
|
|
1493
|
+
database,
|
|
1473
1494
|
host: config.config.HOST,
|
|
1474
1495
|
port: config.config.PORT != null ? Number(config.config.PORT) : void 0,
|
|
1475
1496
|
user: config.config.USER,
|
|
1476
1497
|
password: config.config.PASSWORD,
|
|
1498
|
+
// Connection string (Supabase/PlanetScale/Atlas/Turso). Si está
|
|
1499
|
+
// presente, el engine la usa y aplica TLS.
|
|
1500
|
+
url: config.config.URL,
|
|
1501
|
+
// Auth token de Turso/libSQL.
|
|
1502
|
+
authToken: config.config.AUTH_TOKEN,
|
|
1477
1503
|
maxConnections: config.pool?.maxConnections,
|
|
1478
1504
|
minConnections: config.pool?.minConnections,
|
|
1479
1505
|
acquireTimeoutMs: config.pool?.acquireTimeoutMs,
|
|
@@ -1552,7 +1578,7 @@ var QueryEngine = class {
|
|
|
1552
1578
|
this.config = explicitConfig ?? this.setConfig(name);
|
|
1553
1579
|
this.arguments = this.setArguments();
|
|
1554
1580
|
this.timeout = this.config?.daemon?.requestTimeoutMs ?? timeout;
|
|
1555
|
-
this.connectionId = `${name}_query_engine_${this.config.type}_${this.config.config.DATABASE}_${this.config.config.HOST || "localhost"}`;
|
|
1581
|
+
this.connectionId = `${name}_query_engine_${this.config.type}_${this.config.config.DATABASE ?? ""}_${this.config.config.HOST || this.config.config.URL || "localhost"}`;
|
|
1556
1582
|
this.tcpPort = this.generatePort();
|
|
1557
1583
|
}
|
|
1558
1584
|
generatePort() {
|
|
@@ -1586,16 +1612,34 @@ var QueryEngine = class {
|
|
|
1586
1612
|
let args = [];
|
|
1587
1613
|
const motor = this.config.type === "postgres" ? "postgresql" : this.config.type;
|
|
1588
1614
|
if (this.config.type == "sqlite") {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1615
|
+
if (this.config.config.URL != null && this.config.config.URL !== "") {
|
|
1616
|
+
args = [
|
|
1617
|
+
"--id",
|
|
1618
|
+
"dbcube-" + this.name,
|
|
1619
|
+
"--database-ref",
|
|
1620
|
+
this.name,
|
|
1621
|
+
"--database",
|
|
1622
|
+
this.config.config.DATABASE ?? "",
|
|
1623
|
+
"--motor",
|
|
1624
|
+
motor,
|
|
1625
|
+
"--url",
|
|
1626
|
+
this.config.config.URL
|
|
1627
|
+
];
|
|
1628
|
+
if (this.config.config.AUTH_TOKEN != null && this.config.config.AUTH_TOKEN !== "") {
|
|
1629
|
+
args.push("--auth-token", this.config.config.AUTH_TOKEN);
|
|
1630
|
+
}
|
|
1631
|
+
} else {
|
|
1632
|
+
args = [
|
|
1633
|
+
"--id",
|
|
1634
|
+
"dbcube-" + this.name,
|
|
1635
|
+
"--database-ref",
|
|
1636
|
+
this.name,
|
|
1637
|
+
"--database",
|
|
1638
|
+
this.config.config.DATABASE + ".db",
|
|
1639
|
+
"--motor",
|
|
1640
|
+
motor
|
|
1641
|
+
];
|
|
1642
|
+
}
|
|
1599
1643
|
} else {
|
|
1600
1644
|
args = [
|
|
1601
1645
|
"--id",
|
|
@@ -1603,19 +1647,20 @@ var QueryEngine = class {
|
|
|
1603
1647
|
"--database-ref",
|
|
1604
1648
|
this.name,
|
|
1605
1649
|
"--database",
|
|
1606
|
-
this.config.config.DATABASE,
|
|
1607
|
-
"--host",
|
|
1608
|
-
this.config.config.HOST,
|
|
1609
|
-
"--port",
|
|
1610
|
-
String(this.config.config.PORT),
|
|
1650
|
+
this.config.config.DATABASE ?? "",
|
|
1611
1651
|
"--motor",
|
|
1612
1652
|
motor
|
|
1613
1653
|
];
|
|
1614
|
-
if (this.config.config.
|
|
1615
|
-
args.push("--
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1654
|
+
if (this.config.config.URL != null && this.config.config.URL !== "") {
|
|
1655
|
+
args.push("--url", this.config.config.URL);
|
|
1656
|
+
} else {
|
|
1657
|
+
args.push("--host", this.config.config.HOST, "--port", String(this.config.config.PORT));
|
|
1658
|
+
if (this.config.config.USER != null && this.config.config.USER !== "") {
|
|
1659
|
+
args.push("--user", this.config.config.USER);
|
|
1660
|
+
}
|
|
1661
|
+
if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
|
|
1662
|
+
args.push("--password", this.config.config.PASSWORD);
|
|
1663
|
+
}
|
|
1619
1664
|
}
|
|
1620
1665
|
}
|
|
1621
1666
|
const pool = this.config.pool ?? {};
|