@happyvertical/sql 0.112.3 → 0.113.1
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/AGENT.md +18 -0
- package/README.md +103 -2
- package/dist/chunks/{duckdb-DCV4JFWK.js → duckdb-aMJ05d68.js} +11 -4
- package/dist/chunks/duckdb-aMJ05d68.js.map +1 -0
- package/dist/chunks/{postgres-dialect-CaNhva-C.js → postgres-dialect-C8GwYO-9.js} +14 -3
- package/dist/chunks/postgres-dialect-C8GwYO-9.js.map +1 -0
- package/dist/chunks/{query-Dz0TZ0pY.js → query-CcLSVKOo.js} +3 -46
- package/dist/chunks/query-CcLSVKOo.js.map +1 -0
- package/dist/chunks/{sqlite-nNhv0FMq.js → sqlite-DAzuB3Hb.js} +18 -11
- package/dist/chunks/sqlite-DAzuB3Hb.js.map +1 -0
- package/dist/chunks/sqlite-engine-ByvkAlrK.js +205 -0
- package/dist/chunks/sqlite-engine-ByvkAlrK.js.map +1 -0
- package/dist/chunks/{sqlite-native-CZGNm9zh.js → sqlite-native-Dj0hF4qn.js} +13 -6
- package/dist/chunks/sqlite-native-Dj0hF4qn.js.map +1 -0
- package/dist/chunks/{schema-manager-psLzQ2yh.js → types-DihIt7ez.js} +73 -2
- package/dist/chunks/types-DihIt7ez.js.map +1 -0
- package/dist/duckdb.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -12
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/pglite.d.ts.map +1 -1
- package/dist/pglite.js +9 -2
- package/dist/pglite.js.map +1 -1
- package/dist/postgres.d.ts.map +1 -1
- package/dist/query.js +3 -3
- package/dist/shared/reopen.d.ts +7 -0
- package/dist/shared/reopen.d.ts.map +1 -0
- package/dist/shared/sqlite-engine.d.ts +32 -0
- package/dist/shared/sqlite-engine.d.ts.map +1 -0
- package/dist/shared/types.d.ts +91 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/sqlite-native.d.ts.map +1 -1
- package/dist/sqlite.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/duckdb-DCV4JFWK.js.map +0 -1
- package/dist/chunks/postgres-dialect-CaNhva-C.js.map +0 -1
- package/dist/chunks/query-Dz0TZ0pY.js.map +0 -1
- package/dist/chunks/schema-manager-psLzQ2yh.js.map +0 -1
- package/dist/chunks/sqlite-connection-cache-BycfrYfi.js +0 -70
- package/dist/chunks/sqlite-connection-cache-BycfrYfi.js.map +0 -1
- package/dist/chunks/sqlite-nNhv0FMq.js.map +0 -1
- package/dist/chunks/sqlite-native-CZGNm9zh.js.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as createTransactionLock, d as validateDatabaseCacheOptions } from "./postgres-dialect-CaNhva-C.js";
|
|
1
|
+
import { D as validateIndexName, E as validateColumnNames, O as validatePlainColumnName, S as quoteSqliteColumnName, T as validateColumnName, a as buildAdapterWhere, g as generateCreateIndexStatement, h as generateAddColumnStatement, i as DatabaseSchemaManager, k as validateTableName, p as wrapDatabaseError, r as resolveSchemas, s as formatDbError, u as resolveInsertColumns } from "./types-DihIt7ez.js";
|
|
2
|
+
import { c as createTransactionLock, f as validateDatabaseCacheOptions } from "./postgres-dialect-C8GwYO-9.js";
|
|
4
3
|
import { t as redactDatabaseUrl } from "./redact-database-url-CfMDvSdy.js";
|
|
5
|
-
import {
|
|
4
|
+
import { i as getCachedSqliteDatabase, n as remoteSqliteUrl, r as trackSqliteFile, t as createSqliteReopenOptions } from "./sqlite-engine-ByvkAlrK.js";
|
|
6
5
|
import { DatabaseError } from "@happyvertical/utils";
|
|
7
6
|
import { execFile } from "node:child_process";
|
|
8
7
|
import { lstat, open, unlink } from "node:fs/promises";
|
|
@@ -853,8 +852,7 @@ async function guardRemoteTransaction(tx) {
|
|
|
853
852
|
};
|
|
854
853
|
}
|
|
855
854
|
function remoteLibSqlUrl(url) {
|
|
856
|
-
|
|
857
|
-
return /^(?:https?|libsql):/i.test(normalized) ? normalized : void 0;
|
|
855
|
+
return remoteSqliteUrl(url);
|
|
858
856
|
}
|
|
859
857
|
/**
|
|
860
858
|
* Orders secure adapter calls at public invocation time.
|
|
@@ -1433,19 +1431,20 @@ async function getDatabase(options = {}) {
|
|
|
1433
1431
|
if (secureOptions.custody !== "trusted-parent") throw new DatabaseError("Secure SQLite acquisition requires trusted-parent custody", { hint: "Set custody: 'trusted-parent' only when the application controls the database parent directory." });
|
|
1434
1432
|
if (options.authToken || options.encryptionKey) throw new DatabaseError("Secure SQLite acquisition does not support LibSQL authentication or encryption options", { hint: "Remove authToken/encryptionKey for a local secure file, or disable secureFile to use LibSQL features." });
|
|
1435
1433
|
if (hasNativeSqliteCapabilities(options)) throw new DatabaseError("Secure SQLite acquisition cannot be combined with native SQLite capabilities", { hint: "Use either secureFile custody or optional native capabilities for a connection, not both." });
|
|
1436
|
-
return getCachedSqliteDatabase("secure", options, () => createDatabase(options, url, () => createSecureSqliteClient(url, {
|
|
1434
|
+
return getCachedSqliteDatabase("secure", options, () => createDatabase(options, url, "node-sqlite", () => createSecureSqliteClient(url, {
|
|
1437
1435
|
custody: secureOptions.custody,
|
|
1438
1436
|
root: secureOptions.root,
|
|
1439
1437
|
windowsCustody: secureOptions.windowsCustody
|
|
1440
1438
|
})));
|
|
1441
1439
|
}
|
|
1442
|
-
if (hasNativeSqliteCapabilities(options)) return (await import("./sqlite-native-
|
|
1443
|
-
return getCachedSqliteDatabase("libsql", options, () => createDatabase(options, url));
|
|
1440
|
+
if (hasNativeSqliteCapabilities(options)) return (await import("./sqlite-native-Dj0hF4qn.js")).getNativeSqliteDatabase(options);
|
|
1441
|
+
return getCachedSqliteDatabase("libsql", options, () => createDatabase(options, url, "libsql"));
|
|
1444
1442
|
}
|
|
1445
|
-
async function createDatabase(options, url, clientFactory = () => createLibSQLClient(options)) {
|
|
1443
|
+
async function createDatabase(options, url, engine, clientFactory = () => createLibSQLClient(options)) {
|
|
1446
1444
|
return (async () => {
|
|
1447
1445
|
const connectionLock = createTransactionLock("sqlite", options.transactionQueueTimeout);
|
|
1448
1446
|
const client = await clientFactory();
|
|
1447
|
+
const reopenOptions = createSqliteReopenOptions(engine, options, url);
|
|
1449
1448
|
const remote = remoteLibSqlUrl(url) !== void 0;
|
|
1450
1449
|
const reservesTransaction = remote || client.transactionReservation === "exclusive";
|
|
1451
1450
|
const prepareStatement = (statement) => {
|
|
@@ -1484,6 +1483,7 @@ async function createDatabase(options, url, clientFactory = () => createLibSQLCl
|
|
|
1484
1483
|
}
|
|
1485
1484
|
throw error;
|
|
1486
1485
|
}
|
|
1486
|
+
const releaseFile = trackSqliteFile(url, engine);
|
|
1487
1487
|
/**
|
|
1488
1488
|
* Serializes a value for SQLite storage
|
|
1489
1489
|
* Converts objects and arrays to JSON strings
|
|
@@ -2248,6 +2248,8 @@ async function createDatabase(options, url, clientFactory = () => createLibSQLCl
|
|
|
2248
2248
|
return {
|
|
2249
2249
|
database: {
|
|
2250
2250
|
url,
|
|
2251
|
+
engine,
|
|
2252
|
+
reopenOptions,
|
|
2251
2253
|
client: reservesTransaction ? scopedClient : transactionClient,
|
|
2252
2254
|
insert: scopedInsert,
|
|
2253
2255
|
get: scopedGet,
|
|
@@ -2541,6 +2543,8 @@ async function createDatabase(options, url, clientFactory = () => createLibSQLCl
|
|
|
2541
2543
|
const schemaManager = new DatabaseSchemaManager();
|
|
2542
2544
|
const currentDb = {
|
|
2543
2545
|
url,
|
|
2546
|
+
engine,
|
|
2547
|
+
reopenOptions,
|
|
2544
2548
|
client,
|
|
2545
2549
|
query,
|
|
2546
2550
|
insert,
|
|
@@ -2692,9 +2696,12 @@ async function createDatabase(options, url, clientFactory = () => createLibSQLCl
|
|
|
2692
2696
|
if (closed) return;
|
|
2693
2697
|
await client.close();
|
|
2694
2698
|
closed = true;
|
|
2699
|
+
releaseFile();
|
|
2695
2700
|
};
|
|
2696
2701
|
const db = {
|
|
2697
2702
|
url,
|
|
2703
|
+
engine,
|
|
2704
|
+
reopenOptions,
|
|
2698
2705
|
client,
|
|
2699
2706
|
query,
|
|
2700
2707
|
insert,
|
|
@@ -2860,4 +2867,4 @@ async function createDatabase(options, url, clientFactory = () => createLibSQLCl
|
|
|
2860
2867
|
//#endregion
|
|
2861
2868
|
export { getDatabase };
|
|
2862
2869
|
|
|
2863
|
-
//# sourceMappingURL=sqlite-
|
|
2870
|
+
//# sourceMappingURL=sqlite-DAzuB3Hb.js.map
|