@dbcube/core 5.2.7 → 5.2.9

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.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
@@ -461,7 +473,7 @@ export interface ComputedFieldConfig {
461
473
  created_at: string;
462
474
  updated_at: string;
463
475
  }
464
- type DatabaseType$1 = "mysql" | "sqlite" | "postgres" | "mongodb";
476
+ type DatabaseType$1 = "mysql" | "sqlite" | "postgres" | "postgresql" | "mongodb";
465
477
  export declare class ComputedFieldProcessor {
466
478
  static getComputedFields(name: string): Promise<any[]>;
467
479
  /**
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
@@ -461,7 +473,7 @@ export interface ComputedFieldConfig {
461
473
  created_at: string;
462
474
  updated_at: string;
463
475
  }
464
- type DatabaseType$1 = "mysql" | "sqlite" | "postgres" | "mongodb";
476
+ type DatabaseType$1 = "mysql" | "sqlite" | "postgres" | "postgresql" | "mongodb";
465
477
  export declare class ComputedFieldProcessor {
466
478
  static getComputedFields(name: string): Promise<any[]>;
467
479
  /**
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
- args = [
1124
- "--id",
1125
- "dbcube-" + this.name,
1126
- "--database-ref",
1127
- this.name,
1128
- "--database",
1129
- this.config.config.DATABASE + ".db",
1130
- "--motor",
1131
- motor
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.USER != null && this.config.config.USER !== "") {
1149
- args.push("--user", this.config.config.USER);
1150
- }
1151
- if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
1152
- args.push("--password", this.config.config.PASSWORD);
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: config.type === "sqlite" ? `${config.config.DATABASE}.db` : config.config.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
- args = [
1590
- "--id",
1591
- "dbcube-" + this.name,
1592
- "--database-ref",
1593
- this.name,
1594
- "--database",
1595
- this.config.config.DATABASE + ".db",
1596
- "--motor",
1597
- motor
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.USER != null && this.config.config.USER !== "") {
1615
- args.push("--user", this.config.config.USER);
1616
- }
1617
- if (this.config.config.PASSWORD != null && this.config.config.PASSWORD !== "") {
1618
- args.push("--password", this.config.config.PASSWORD);
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 ?? {};
@@ -2930,6 +2975,7 @@ var TableProcessor = class {
2930
2975
  case "mysql":
2931
2976
  return generateMySQLQueries(nowColumns, oldColumns, tableName);
2932
2977
  case "postgres":
2978
+ case "postgresql":
2933
2979
  return generatePostgreSQLQueries(nowColumns, oldColumns, tableName);
2934
2980
  case "sqlite":
2935
2981
  return generateSQLiteQueries(nowSchema, oldSchema, tableName);