@loradb/lora-node 0.2.0 → 0.3.0

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.ts CHANGED
@@ -14,6 +14,18 @@
14
14
  import type { LoraParams, LoraValue, QueryResult } from "./types.js";
15
15
  declare const NativeDatabase: typeof import("./native.js").Database;
16
16
  export * from "./types.js";
17
+ /**
18
+ * Metadata returned by `saveSnapshot` / `loadSnapshot`. Mirrors the Rust
19
+ * `SnapshotMeta` struct and matches the shape used by every other binding
20
+ * (Python, WASM, Go, FFI) so snapshots can be described in the same way
21
+ * regardless of language.
22
+ */
23
+ export interface SnapshotMeta {
24
+ formatVersion: number;
25
+ nodeCount: number;
26
+ relationshipCount: number;
27
+ walLsn: number | null;
28
+ }
17
29
  /**
18
30
  * In-memory Lora graph database instance.
19
31
  *
@@ -41,6 +53,22 @@ declare class DatabaseImpl {
41
53
  nodeCount(): Promise<number>;
42
54
  /** Number of relationships currently in the graph. */
43
55
  relationshipCount(): Promise<number>;
56
+ /**
57
+ * Save the graph to a snapshot file. Writes atomically via a `.tmp` +
58
+ * rename dance — the target path is only replaced once the full payload
59
+ * has been written and fsync'd.
60
+ *
61
+ * Synchronous in the native layer (point-in-time consistency requires
62
+ * holding the store mutex for the duration of the save); the returned
63
+ * Promise resolves immediately once the save returns.
64
+ */
65
+ saveSnapshot(path: string): Promise<SnapshotMeta>;
66
+ /**
67
+ * Replace the current graph state with a snapshot loaded from `path`.
68
+ * Concurrent `execute()` calls block on the store mutex until the load
69
+ * completes.
70
+ */
71
+ loadSnapshot(path: string): Promise<SnapshotMeta>;
44
72
  }
45
73
  /**
46
74
  * Public type for a LoraDB instance.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACZ,MAAM,YAAY,C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;gBAGJ,KAAK,EAAE,YAAY,CAAC,OAAO,cAAc,CAAC;IAItD;;;;OAIG;IACG,OAAO,CACX,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/D,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAS9D,sEAAsE;IAChE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,8CAA8C;IACxC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,sDAAsD;IAChD,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C;;;;;;;;OAQG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAQvD;;;;OAIG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAOxD;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAExD"}
package/dist/index.js CHANGED
@@ -80,6 +80,36 @@ class DatabaseImpl {
80
80
  async relationshipCount() {
81
81
  return this.#inner.relationshipCount();
82
82
  }
83
+ /**
84
+ * Save the graph to a snapshot file. Writes atomically via a `.tmp` +
85
+ * rename dance — the target path is only replaced once the full payload
86
+ * has been written and fsync'd.
87
+ *
88
+ * Synchronous in the native layer (point-in-time consistency requires
89
+ * holding the store mutex for the duration of the save); the returned
90
+ * Promise resolves immediately once the save returns.
91
+ */
92
+ async saveSnapshot(path) {
93
+ try {
94
+ return this.#inner.saveSnapshot(path);
95
+ }
96
+ catch (err) {
97
+ throw (0, types_js_1.wrapError)(err);
98
+ }
99
+ }
100
+ /**
101
+ * Replace the current graph state with a snapshot loaded from `path`.
102
+ * Concurrent `execute()` calls block on the store mutex until the load
103
+ * completes.
104
+ */
105
+ async loadSnapshot(path) {
106
+ try {
107
+ return this.#inner.loadSnapshot(path);
108
+ }
109
+ catch (err) {
110
+ throw (0, types_js_1.wrapError)(err);
111
+ }
112
+ }
83
113
  }
84
114
  /**
85
115
  * Create and initialize a new in-memory LoraDB instance.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;AAsGH,wCAEC;AAjGD,yCAAuC;AAEvC,6DAA6D;AAC7D,wDAAwD;AACxD,4DAAiC;AAEjC,MAAM,cAAc,GAA0C,mBAAM,CAAC,QAAQ,CAAC;AAE9E,6CAA2B;AAE3B;;;;;;;;;;;GAWG;AACH,MAAM,YAAY;IACP,MAAM,CAAsC;IAErD,YAAY,KAA0C;QACpD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAEX,KAAa,EAAE,MAAmB;QAClC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC;YAC7D,OAAO,GAAqB,CAAC;QAC/B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,8CAA8C;IAC9C,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,sDAAsD;IACtD,KAAK,CAAC,iBAAiB;QACrB,O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;;;;OAQG;IACH,KAAK,CAAC,YAAY,CAAC,IAAY;QAC7B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAiB,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,IAAY;QAC7B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAiB,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAgBD;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,cAAc;IAClC,OAAO,IAAI,YAAY,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;AAChD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loradb/lora-node",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Node.js / TypeScript bindings for the Lora in-memory graph database",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "LoraDB, Inc.",
@@ -89,10 +89,10 @@
89
89
  "vitest": "^2.1.1"
90
90
  },
91
91
  "optionalDependencies": {
92
- "@loradb/lora-node-linux-x64-gnu": "0.2.0",
93
- "@loradb/lora-node-linux-arm64-gnu": "0.2.0",
94
- "@loradb/lora-node-darwin-x64": "0.2.0",
95
- "@loradb/lora-node-darwin-arm64": "0.2.0",
96
- "@loradb/lora-node-win32-x64-msvc": "0.2.0"
92
+ "@loradb/lora-node-linux-x64-gnu": "0.3.0",
93
+ "@loradb/lora-node-linux-arm64-gnu": "0.3.0",
94
+ "@loradb/lora-node-darwin-x64": "0.3.0",
95
+ "@loradb/lora-node-darwin-arm64": "0.3.0",
96
+ "@loradb/lora-node-win32-x64-msvc": "0.3.0"
97
97
  }
98
98
  }
package/ts/native.d.ts CHANGED
@@ -11,6 +11,13 @@ export interface NativeQueryResult {
11
11
  rows: Array<Record<string, unknown>>;
12
12
  }
13
13
 
14
+ export interface NativeSnapshotMeta {
15
+ formatVersion: number;
16
+ nodeCount: number;
17
+ relationshipCount: number;
18
+ walLsn: number | null;
19
+ }
20
+
14
21
  export declare class Database {
15
22
  constructor();
16
23
  /** Non-blocking: runs on the libuv threadpool, returns a Promise. */
@@ -21,4 +28,8 @@ export declare class Database {
21
28
  clear(): void;
22
29
  nodeCount(): number;
23
30
  relationshipCount(): number;
31
+ /** Atomic save. Synchronous under the store mutex. */
32
+ saveSnapshot(path: string): NativeSnapshotMeta;
33
+ /** Replace the current graph with the snapshot at `path`. */
34
+ loadSnapshot(path: string): NativeSnapshotMeta;
24
35
  }