@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 CHANGED
@@ -1162,16 +1162,34 @@ var Engine = class {
1162
1162
  let args = [];
1163
1163
  const motor = this.config.type === "postgres" ? "postgresql" : this.config.type;
1164
1164
  if (this.config.type == "sqlite") {
1165
- args = [
1166
- "--id",
1167
- "dbcube-" + this.name,
1168
- "--database-ref",
1169
- this.name,
1170
- "--database",
1171
- this.config.config.DATABASE + ".db",
1172
- "--motor",
1173
- motor
1174
- ];
1165
+ if (this.config.config.URL != null && this.config.config.URL !== "") {
1166
+ args = [
1167
+ "--id",
1168
+ "dbcube-" + this.name,
1169
+ "--database-ref",
1170
+ this.name,
1171
+ "--database",
1172
+ this.config.config.DATABASE ?? "",
1173
+ "--motor",
1174
+ motor,
1175
+ "--url",
1176
+ this.config.config.URL
1177
+ ];
1178
+ if (this.config.config.AUTH_TOKEN != null && this.config.config.AUTH_TOKEN !== "") {
1179
+ args.push("--auth-token", this.config.config.AUTH_TOKEN);
1180
+ }
1181
+ } else {
1182
+ args = [
1183
+ "--id",
1184
+ "dbcube-" + this.name,
1185
+ "--database-ref",
1186
+ this.name,
1187
+ "--database",
1188
+ this.config.config.DATABASE + ".db",
1189
+ "--motor",
1190
+ motor
1191
+ ];
1192
+ }
1175
1193
  } else {
1176
1194
  args = [
1177
1195
  "--id",
@@ -1179,19 +1197,20 @@ var Engine = class {
1179
1197
  "--database-ref",
1180
1198
  this.name,
1181
1199
  "--database",
1182
- this.config.config.DATABASE,
1183
- "--host",
1184
- this.config.config.HOST,
1185
- "--port",
1186
- String(this.config.config.PORT),
1200
+ this.config.config.DATABASE ?? "",
1187
1201
  "--motor",
1188
1202
  motor
1189
1203
  ];
1190
- if (this.config.config.USER != null && this.config.config.USER !== "") {
1191
- args.push("--user", this.config.config.USER);
1192
- }
1193
- if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
1194
- args.push("--password", this.config.config.PASSWORD);
1204
+ if (this.config.config.URL != null && this.config.config.URL !== "") {
1205
+ args.push("--url", this.config.config.URL);
1206
+ } else {
1207
+ args.push("--host", this.config.config.HOST, "--port", String(this.config.config.PORT));
1208
+ if (this.config.config.USER != null && this.config.config.USER !== "") {
1209
+ args.push("--user", this.config.config.USER);
1210
+ }
1211
+ if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
1212
+ args.push("--password", this.config.config.PASSWORD);
1213
+ }
1195
1214
  }
1196
1215
  }
1197
1216
  return args;
@@ -1508,14 +1527,21 @@ var EmbeddedEngine = class {
1508
1527
  const be = loadBackend();
1509
1528
  if (!be) throw new Error("embedded engine not available");
1510
1529
  const motor = config.type === "postgres" ? "postgresql" : config.type;
1530
+ const isTurso = config.type === "sqlite" && !!config.config.URL;
1531
+ const database = config.type === "sqlite" && !isTurso ? `${config.config.DATABASE}.db` : config.config.DATABASE;
1511
1532
  const cfg = {
1512
1533
  databaseRef: connectionId,
1513
1534
  motor,
1514
- database: config.type === "sqlite" ? `${config.config.DATABASE}.db` : config.config.DATABASE,
1535
+ database,
1515
1536
  host: config.config.HOST,
1516
1537
  port: config.config.PORT != null ? Number(config.config.PORT) : void 0,
1517
1538
  user: config.config.USER,
1518
1539
  password: config.config.PASSWORD,
1540
+ // Connection string (Supabase/PlanetScale/Atlas/Turso). Si está
1541
+ // presente, el engine la usa y aplica TLS.
1542
+ url: config.config.URL,
1543
+ // Auth token de Turso/libSQL.
1544
+ authToken: config.config.AUTH_TOKEN,
1519
1545
  maxConnections: config.pool?.maxConnections,
1520
1546
  minConnections: config.pool?.minConnections,
1521
1547
  acquireTimeoutMs: config.pool?.acquireTimeoutMs,
@@ -1594,7 +1620,7 @@ var QueryEngine = class {
1594
1620
  this.config = explicitConfig ?? this.setConfig(name);
1595
1621
  this.arguments = this.setArguments();
1596
1622
  this.timeout = this.config?.daemon?.requestTimeoutMs ?? timeout;
1597
- this.connectionId = `${name}_query_engine_${this.config.type}_${this.config.config.DATABASE}_${this.config.config.HOST || "localhost"}`;
1623
+ this.connectionId = `${name}_query_engine_${this.config.type}_${this.config.config.DATABASE ?? ""}_${this.config.config.HOST || this.config.config.URL || "localhost"}`;
1598
1624
  this.tcpPort = this.generatePort();
1599
1625
  }
1600
1626
  generatePort() {
@@ -1628,16 +1654,34 @@ var QueryEngine = class {
1628
1654
  let args = [];
1629
1655
  const motor = this.config.type === "postgres" ? "postgresql" : this.config.type;
1630
1656
  if (this.config.type == "sqlite") {
1631
- args = [
1632
- "--id",
1633
- "dbcube-" + this.name,
1634
- "--database-ref",
1635
- this.name,
1636
- "--database",
1637
- this.config.config.DATABASE + ".db",
1638
- "--motor",
1639
- motor
1640
- ];
1657
+ if (this.config.config.URL != null && this.config.config.URL !== "") {
1658
+ args = [
1659
+ "--id",
1660
+ "dbcube-" + this.name,
1661
+ "--database-ref",
1662
+ this.name,
1663
+ "--database",
1664
+ this.config.config.DATABASE ?? "",
1665
+ "--motor",
1666
+ motor,
1667
+ "--url",
1668
+ this.config.config.URL
1669
+ ];
1670
+ if (this.config.config.AUTH_TOKEN != null && this.config.config.AUTH_TOKEN !== "") {
1671
+ args.push("--auth-token", this.config.config.AUTH_TOKEN);
1672
+ }
1673
+ } else {
1674
+ args = [
1675
+ "--id",
1676
+ "dbcube-" + this.name,
1677
+ "--database-ref",
1678
+ this.name,
1679
+ "--database",
1680
+ this.config.config.DATABASE + ".db",
1681
+ "--motor",
1682
+ motor
1683
+ ];
1684
+ }
1641
1685
  } else {
1642
1686
  args = [
1643
1687
  "--id",
@@ -1645,19 +1689,20 @@ var QueryEngine = class {
1645
1689
  "--database-ref",
1646
1690
  this.name,
1647
1691
  "--database",
1648
- this.config.config.DATABASE,
1649
- "--host",
1650
- this.config.config.HOST,
1651
- "--port",
1652
- String(this.config.config.PORT),
1692
+ this.config.config.DATABASE ?? "",
1653
1693
  "--motor",
1654
1694
  motor
1655
1695
  ];
1656
- if (this.config.config.USER != null && this.config.config.USER !== "") {
1657
- args.push("--user", this.config.config.USER);
1658
- }
1659
- if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
1660
- args.push("--password", this.config.config.PASSWORD);
1696
+ if (this.config.config.URL != null && this.config.config.URL !== "") {
1697
+ args.push("--url", this.config.config.URL);
1698
+ } else {
1699
+ args.push("--host", this.config.config.HOST, "--port", String(this.config.config.PORT));
1700
+ if (this.config.config.USER != null && this.config.config.USER !== "") {
1701
+ args.push("--user", this.config.config.USER);
1702
+ }
1703
+ if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
1704
+ args.push("--password", this.config.config.PASSWORD);
1705
+ }
1661
1706
  }
1662
1707
  }
1663
1708
  const pool = this.config.pool ?? {};