@lix-js/sdk 0.6.0 → 0.6.2

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.
Files changed (2) hide show
  1. package/README.md +10 -26
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -14,20 +14,14 @@ npm install @lix-js/sdk
14
14
  import { openLix, SqliteBackend } from "@lix-js/sdk";
15
15
 
16
16
  const lix = await openLix({
17
- backend: new SqliteBackend({ path: "app.lix" }),
17
+ backend: new SqliteBackend({ path: "app.lix" }),
18
18
  });
19
19
 
20
- await lix.execute(
21
- "INSERT INTO lix_key_value (key, value) VALUES ($1, $2)",
22
- ["hello", "world"],
23
- );
20
+ await lix.fs.writeFile("/hello.txt", new TextEncoder().encode("world"));
24
21
 
25
- const result = await lix.execute(
26
- "SELECT value FROM lix_key_value WHERE key = $1",
27
- ["hello"],
28
- );
22
+ const bytes = await lix.fs.readFile("/hello.txt");
29
23
 
30
- console.log(result.rows[0]?.get("value"));
24
+ console.log(bytes && new TextDecoder().decode(bytes));
31
25
 
32
26
  await lix.close();
33
27
  ```
@@ -39,10 +33,7 @@ const main = await lix.activeBranchId();
39
33
  const draft = await lix.createBranch({ name: "Draft" });
40
34
 
41
35
  await lix.switchBranch({ branchId: draft.id });
42
- await lix.execute(
43
- "INSERT INTO lix_key_value (key, value) VALUES ($1, $2)",
44
- ["status", "draft"],
45
- );
36
+ await lix.fs.writeFile("/status.txt", new TextEncoder().encode("draft"));
46
37
 
47
38
  await lix.switchBranch({ branchId: main });
48
39
  const preview = await lix.mergeBranchPreview({ sourceBranchId: draft.id });
@@ -55,18 +46,12 @@ const merge = await lix.mergeBranch({ sourceBranchId: draft.id });
55
46
  const tx = await lix.beginTransaction();
56
47
 
57
48
  try {
58
- await tx.execute(
59
- "INSERT INTO lix_key_value (key, value) VALUES ($1, $2)",
60
- ["a", "1"],
61
- );
62
- await tx.execute(
63
- "INSERT INTO lix_key_value (key, value) VALUES ($1, $2)",
64
- ["b", "2"],
65
- );
66
- await tx.commit();
49
+ await tx.fs.writeFile("/a.txt", new TextEncoder().encode("1"));
50
+ await tx.fs.writeFile("/b.txt", new TextEncoder().encode("2"));
51
+ await tx.commit();
67
52
  } catch (error) {
68
- await tx.rollback();
69
- throw error;
53
+ await tx.rollback();
54
+ throw error;
70
55
  }
71
56
  ```
72
57
 
@@ -76,6 +61,5 @@ try {
76
61
  - The SDK is Node/native only right now; it is not browser-compatible.
77
62
  - The package is ESM-only.
78
63
  - The native addon is built from Rust and loaded by the TypeScript wrapper.
79
- - The public API is promise-based, but the current native implementation performs local SQLite work synchronously under the hood.
80
64
  - SQL parameters use normal JavaScript values: `string`, finite `number`, `boolean`, `Uint8Array`, `null`, JSON-compatible arrays, and JSON-compatible plain objects.
81
65
  - Use `Value.integer(...)`, `Value.real(...)`, `Value.text(...)`, `Value.json(...)`, or `Value.blob(...)` only when you need to pass an explicit native Lix value.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lix-js/sdk",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "repository": {
@@ -26,10 +26,10 @@
26
26
  "typecheck": "tsc -p tsconfig.test.json --noEmit"
27
27
  },
28
28
  "optionalDependencies": {
29
- "@lix-js/sdk-darwin-arm64": "0.6.0",
30
- "@lix-js/sdk-linux-arm64": "0.6.0",
31
- "@lix-js/sdk-linux-x64": "0.6.0",
32
- "@lix-js/sdk-win32-x64": "0.6.0"
29
+ "@lix-js/sdk-darwin-arm64": "0.6.2",
30
+ "@lix-js/sdk-linux-arm64": "0.6.2",
31
+ "@lix-js/sdk-linux-x64": "0.6.2",
32
+ "@lix-js/sdk-win32-x64": "0.6.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^24.10.2",