@hakodb/client 0.6.1 → 0.6.3

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.
@@ -1,13 +1,13 @@
1
- {
2
- "name": "hako-example-node",
3
- "private": true,
4
- "version": "0.1.0",
5
- "type": "module",
6
- "description": "HakoDB Node.js example using the TypeScript SDK (koffi FFI)",
7
- "scripts": {
8
- "start": "tsx index.ts"
9
- },
10
- "devDependencies": {
11
- "tsx": "^4.19.0"
12
- }
13
- }
1
+ {
2
+ "name": "hako-example-node",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "description": "HakoDB Node.js example using the TypeScript SDK (koffi FFI)",
7
+ "scripts": {
8
+ "start": "tsx index.ts"
9
+ },
10
+ "devDependencies": {
11
+ "tsx": "^4.19.0"
12
+ }
13
+ }
@@ -1,70 +1,70 @@
1
- /**
2
- * Soft-delete / sweeper / restore smoke (core 0.20.0 FFI sync).
3
- *
4
- * node --import tsx examples/node/softdel.ts
5
- */
6
- import path from "node:path";
7
- import fs from "node:fs";
8
- import os from "node:os";
9
- import { fileURLToPath } from "node:url";
10
- import { HakoClient } from "../../src/index.ts";
11
-
12
- const repoRoot = path.resolve(
13
- path.dirname(fileURLToPath(import.meta.url)),
14
- "..", ".."
15
- );
16
- const libraryPath = path.join(repoRoot, "native", "hakodb.dll");
17
-
18
- async function main(): Promise<void> {
19
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "hako-softdel-"));
20
- const db = await HakoClient.open(path.join(dir, "smoke.db"), { libraryPath });
21
- try {
22
- await db.set("users", "u1", { name: "Alice", age: 32 });
23
-
24
- // Default delete is soft since core 0.20.0.
25
- await db.delete("users", "u1");
26
- if ((await db.get("users", "u1")).exists) {
27
- throw new Error("deleted doc must be invisible");
28
- }
29
-
30
- const avail = await db.restoreAvailable();
31
- if (!Array.isArray(avail) || avail.length !== 1 || avail[0].col !== "users" || avail[0].id !== "u1") {
32
- throw new Error("restoreAvailable mismatch: " + JSON.stringify(avail));
33
- }
34
-
35
- await db.restore("users", "u1");
36
- if (!(await db.get("users", "u1")).exists) {
37
- throw new Error("restore should bring the doc back");
38
- }
39
- if ((await db.restoreAvailable()).length !== 0) {
40
- throw new Error("record should be consumed after restore");
41
- }
42
-
43
- // Force parity: legacy shape retains nothing.
44
- await db.set("users", "u2", { name: "Bob" });
45
- await db.deleteEx("users", "u2", true);
46
- if ((await db.restoreAvailable()).length !== 0) {
47
- throw new Error("force delete must not retain");
48
- }
49
-
50
- // deleteQueue shares the shape; nothing is due in a fresh engine.
51
- const queue = await db.deleteQueue();
52
- if (!Array.isArray(queue) || queue.length !== 0) {
53
- throw new Error("deleteQueue mismatch: " + JSON.stringify(queue));
54
- }
55
-
56
- // Escape hatch works regardless of maintenance mode.
57
- const swept = await db.sweepNow();
58
- if (swept < 0) throw new Error("sweepNow failed: " + swept);
59
-
60
- console.log("soft-delete smoke OK (sweepNow=" + swept + ")");
61
- } finally {
62
- await db.close();
63
- fs.rmSync(dir, { recursive: true, force: true });
64
- }
65
- }
66
-
67
- main().catch((err) => {
68
- console.error(err);
69
- process.exit(1);
70
- });
1
+ /**
2
+ * Soft-delete / sweeper / restore smoke (core 0.20.0 FFI sync).
3
+ *
4
+ * node --import tsx examples/node/softdel.ts
5
+ */
6
+ import path from "node:path";
7
+ import fs from "node:fs";
8
+ import os from "node:os";
9
+ import { fileURLToPath } from "node:url";
10
+ import { HakoClient } from "../../src/index.ts";
11
+
12
+ const repoRoot = path.resolve(
13
+ path.dirname(fileURLToPath(import.meta.url)),
14
+ "..", ".."
15
+ );
16
+ const libraryPath = path.join(repoRoot, "native", "hakodb.dll");
17
+
18
+ async function main(): Promise<void> {
19
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "hako-softdel-"));
20
+ const db = await HakoClient.open(path.join(dir, "smoke.db"), { libraryPath });
21
+ try {
22
+ await db.set("users", "u1", { name: "Alice", age: 32 });
23
+
24
+ // Default delete is soft since core 0.20.0.
25
+ await db.delete("users", "u1");
26
+ if ((await db.get("users", "u1")).exists) {
27
+ throw new Error("deleted doc must be invisible");
28
+ }
29
+
30
+ const avail = await db.restoreAvailable();
31
+ if (!Array.isArray(avail) || avail.length !== 1 || avail[0].col !== "users" || avail[0].id !== "u1") {
32
+ throw new Error("restoreAvailable mismatch: " + JSON.stringify(avail));
33
+ }
34
+
35
+ await db.restore("users", "u1");
36
+ if (!(await db.get("users", "u1")).exists) {
37
+ throw new Error("restore should bring the doc back");
38
+ }
39
+ if ((await db.restoreAvailable()).length !== 0) {
40
+ throw new Error("record should be consumed after restore");
41
+ }
42
+
43
+ // Force parity: legacy shape retains nothing.
44
+ await db.set("users", "u2", { name: "Bob" });
45
+ await db.deleteEx("users", "u2", true);
46
+ if ((await db.restoreAvailable()).length !== 0) {
47
+ throw new Error("force delete must not retain");
48
+ }
49
+
50
+ // deleteQueue shares the shape; nothing is due in a fresh engine.
51
+ const queue = await db.deleteQueue();
52
+ if (!Array.isArray(queue) || queue.length !== 0) {
53
+ throw new Error("deleteQueue mismatch: " + JSON.stringify(queue));
54
+ }
55
+
56
+ // Escape hatch works regardless of maintenance mode.
57
+ const swept = await db.sweepNow();
58
+ if (swept < 0) throw new Error("sweepNow failed: " + swept);
59
+
60
+ console.log("soft-delete smoke OK (sweepNow=" + swept + ")");
61
+ } finally {
62
+ await db.close();
63
+ fs.rmSync(dir, { recursive: true, force: true });
64
+ }
65
+ }
66
+
67
+ main().catch((err) => {
68
+ console.error(err);
69
+ process.exit(1);
70
+ });
package/package.json CHANGED
@@ -1,34 +1,38 @@
1
- {
2
- "name": "@hakodb/client",
3
- "version": "0.6.1",
4
- "description": "High-level HakoDB JavaScript/TypeScript client for Node.js and Bun",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "src/index.ts",
8
- "types": "src/index.ts",
9
- "exports": {
10
- ".": "./src/index.ts",
11
- "./native": "./src/client.ts"
12
- },
13
- "keywords": [
14
- "hakodb",
15
- "embedded",
16
- "database",
17
- "ffi",
18
- "vector-search"
19
- ],
20
- "engines": {
21
- "node": ">=18"
22
- },
23
- "dependencies": {
24
- "@msgpack/msgpack": "^3.1.3",
25
- "koffi": "^2.8.0"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^26.1.2",
29
- "typescript": "^7.0.2"
30
- },
31
- "scripts": {
32
- "test": "tsc --noEmit -p tsconfig.json"
33
- }
34
- }
1
+ {
2
+ "name": "@hakodb/client",
3
+ "version": "0.6.3",
4
+ "description": "High-level HakoDB JavaScript/TypeScript client for Node.js and Bun",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/hakodb/hakojs.git"
8
+ },
9
+ "license": "MIT",
10
+ "type": "module",
11
+ "main": "src/index.ts",
12
+ "types": "src/index.ts",
13
+ "exports": {
14
+ ".": "./src/index.ts",
15
+ "./native": "./src/client.ts"
16
+ },
17
+ "keywords": [
18
+ "hakodb",
19
+ "embedded",
20
+ "database",
21
+ "ffi",
22
+ "vector-search"
23
+ ],
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
27
+ "dependencies": {
28
+ "@msgpack/msgpack": "^3.1.3",
29
+ "koffi": "^2.8.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^26.1.2",
33
+ "typescript": "^7.0.2"
34
+ },
35
+ "scripts": {
36
+ "test": "tsc --noEmit -p tsconfig.json"
37
+ }
38
+ }
package/src/bun-ffi.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- declare module 'bun:ffi' {
2
- export const dlopen: any;
3
- export const FFIType: any;
4
- export const CString: any;
5
- export const JSCallback: any;
6
- }
1
+ declare module 'bun:ffi' {
2
+ export const dlopen: any;
3
+ export const FFIType: any;
4
+ export const CString: any;
5
+ export const JSCallback: any;
6
+ }