@aigne/sqlite 0.4.5-beta → 0.4.6-beta
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 +9 -0
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.node.d.ts +5 -1
- package/lib/cjs/index.node.js +22 -3
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.node.d.ts +5 -1
- package/lib/esm/index.node.js +22 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.6-beta](https://github.com/AIGNE-io/aigne-framework/compare/sqlite-v0.4.5...sqlite-v0.4.6-beta) (2025-11-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **sqlite:** improve WAL checkpoint and database cleanup ([#751](https://github.com/AIGNE-io/aigne-framework/issues/751)) ([85c7884](https://github.com/AIGNE-io/aigne-framework/commit/85c78849a8d2637349786c696d6eaa01f8c70fcf))
|
|
9
|
+
|
|
10
|
+
## [0.4.5](https://github.com/AIGNE-io/aigne-framework/compare/sqlite-v0.4.5-beta...sqlite-v0.4.5) (2025-11-15)
|
|
11
|
+
|
|
3
12
|
## [0.4.5-beta](https://github.com/AIGNE-io/aigne-framework/compare/sqlite-v0.4.4...sqlite-v0.4.5-beta) (2025-11-15)
|
|
4
13
|
|
|
5
14
|
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export interface InitDatabaseOptions {
|
|
|
3
3
|
url?: string;
|
|
4
4
|
wal?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare function initDatabase(options?: InitDatabaseOptions): Promise<import("drizzle-orm/
|
|
6
|
+
export declare function initDatabase(options?: InitDatabaseOptions): Promise<import("drizzle-orm/sqlite-proxy/driver.js").SqliteRemoteDatabase<Record<string, never>>>;
|
package/lib/cjs/index.node.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type LibSQLDatabase } from "drizzle-orm/libsql";
|
|
2
2
|
import type { InitDatabaseOptions } from "./index.js";
|
|
3
3
|
export * from "./reexport.js";
|
|
4
|
-
export declare function initDatabase({ url, wal, }?: InitDatabaseOptions
|
|
4
|
+
export declare function initDatabase({ url, wal, walAutocheckpoint, }?: InitDatabaseOptions & {
|
|
5
|
+
walAutocheckpoint?: number;
|
|
6
|
+
}): Promise<LibSQLDatabase & {
|
|
7
|
+
vacuum?: () => Promise<void>;
|
|
8
|
+
}>;
|
package/lib/cjs/index.node.js
CHANGED
|
@@ -21,20 +21,28 @@ const client_1 = require("@libsql/client");
|
|
|
21
21
|
const libsql_1 = require("drizzle-orm/libsql");
|
|
22
22
|
const retry_js_1 = require("./retry.js");
|
|
23
23
|
__exportStar(require("./reexport.js"), exports);
|
|
24
|
-
async function initDatabase({ url = ":memory:", wal = false, } = {}) {
|
|
24
|
+
async function initDatabase({ url = ":memory:", wal = false, walAutocheckpoint = 5000, } = {}) {
|
|
25
25
|
let db;
|
|
26
|
+
let client;
|
|
26
27
|
if (/^file:.*/.test(url)) {
|
|
27
28
|
const path = url.replace(/^file:(\/\/)?/, "");
|
|
28
29
|
await (0, promises_1.mkdir)((0, node_path_1.dirname)(path), { recursive: true });
|
|
29
30
|
}
|
|
30
31
|
if (wal) {
|
|
31
|
-
|
|
32
|
+
client = (0, client_1.createClient)({ url });
|
|
32
33
|
await client.execute(`\
|
|
33
34
|
PRAGMA journal_mode = WAL;
|
|
34
35
|
PRAGMA synchronous = normal;
|
|
35
|
-
PRAGMA wal_autocheckpoint =
|
|
36
|
+
PRAGMA wal_autocheckpoint = ${walAutocheckpoint};
|
|
36
37
|
PRAGMA busy_timeout = 5000;
|
|
37
38
|
`);
|
|
39
|
+
try {
|
|
40
|
+
await client.execute(`PRAGMA auto_vacuum = FULL;`);
|
|
41
|
+
await client.execute(`VACUUM;`);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.warn("auto_vacuum failed", e);
|
|
45
|
+
}
|
|
38
46
|
db = (0, libsql_1.drizzle)(client);
|
|
39
47
|
}
|
|
40
48
|
else {
|
|
@@ -49,5 +57,16 @@ PRAGMA busy_timeout = 5000;
|
|
|
49
57
|
"count",
|
|
50
58
|
]);
|
|
51
59
|
}
|
|
60
|
+
db.clean = async () => {
|
|
61
|
+
if (wal && client && typeof client.execute === "function") {
|
|
62
|
+
try {
|
|
63
|
+
await client.execute("PRAGMA wal_checkpoint(TRUNCATE);");
|
|
64
|
+
await client.execute(`VACUUM;`);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error("wal checkpoint failed", e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
52
71
|
return db;
|
|
53
72
|
}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export interface InitDatabaseOptions {
|
|
|
3
3
|
url?: string;
|
|
4
4
|
wal?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare function initDatabase(options?: InitDatabaseOptions): Promise<import("drizzle-orm/
|
|
6
|
+
export declare function initDatabase(options?: InitDatabaseOptions): Promise<import("drizzle-orm/sqlite-proxy").SqliteRemoteDatabase<Record<string, never>>>;
|
package/lib/esm/index.node.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type LibSQLDatabase } from "drizzle-orm/libsql";
|
|
2
2
|
import type { InitDatabaseOptions } from "./index.js";
|
|
3
3
|
export * from "./reexport.js";
|
|
4
|
-
export declare function initDatabase({ url, wal, }?: InitDatabaseOptions
|
|
4
|
+
export declare function initDatabase({ url, wal, walAutocheckpoint, }?: InitDatabaseOptions & {
|
|
5
|
+
walAutocheckpoint?: number;
|
|
6
|
+
}): Promise<LibSQLDatabase & {
|
|
7
|
+
vacuum?: () => Promise<void>;
|
|
8
|
+
}>;
|
package/lib/esm/index.node.js
CHANGED
|
@@ -4,20 +4,28 @@ import { createClient } from "@libsql/client";
|
|
|
4
4
|
import { drizzle } from "drizzle-orm/libsql";
|
|
5
5
|
import { withRetry } from "./retry.js";
|
|
6
6
|
export * from "./reexport.js";
|
|
7
|
-
export async function initDatabase({ url = ":memory:", wal = false, } = {}) {
|
|
7
|
+
export async function initDatabase({ url = ":memory:", wal = false, walAutocheckpoint = 5000, } = {}) {
|
|
8
8
|
let db;
|
|
9
|
+
let client;
|
|
9
10
|
if (/^file:.*/.test(url)) {
|
|
10
11
|
const path = url.replace(/^file:(\/\/)?/, "");
|
|
11
12
|
await mkdir(dirname(path), { recursive: true });
|
|
12
13
|
}
|
|
13
14
|
if (wal) {
|
|
14
|
-
|
|
15
|
+
client = createClient({ url });
|
|
15
16
|
await client.execute(`\
|
|
16
17
|
PRAGMA journal_mode = WAL;
|
|
17
18
|
PRAGMA synchronous = normal;
|
|
18
|
-
PRAGMA wal_autocheckpoint =
|
|
19
|
+
PRAGMA wal_autocheckpoint = ${walAutocheckpoint};
|
|
19
20
|
PRAGMA busy_timeout = 5000;
|
|
20
21
|
`);
|
|
22
|
+
try {
|
|
23
|
+
await client.execute(`PRAGMA auto_vacuum = FULL;`);
|
|
24
|
+
await client.execute(`VACUUM;`);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
console.warn("auto_vacuum failed", e);
|
|
28
|
+
}
|
|
21
29
|
db = drizzle(client);
|
|
22
30
|
}
|
|
23
31
|
else {
|
|
@@ -32,5 +40,16 @@ PRAGMA busy_timeout = 5000;
|
|
|
32
40
|
"count",
|
|
33
41
|
]);
|
|
34
42
|
}
|
|
43
|
+
db.clean = async () => {
|
|
44
|
+
if (wal && client && typeof client.execute === "function") {
|
|
45
|
+
try {
|
|
46
|
+
await client.execute("PRAGMA wal_checkpoint(TRUNCATE);");
|
|
47
|
+
await client.execute(`VACUUM;`);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
console.error("wal checkpoint failed", e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
35
54
|
return db;
|
|
36
55
|
}
|