@kedem/okdb 2.4.0 → 2.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kedem/okdb",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "A fast, type-oriented database — strong consistency and rich indexing at the core, with sync, vector embeddings, full-text search, and AI tooling built in. Designed for the AI era.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {
package/types/okdb.d.ts CHANGED
@@ -196,12 +196,28 @@ export declare class OKDB {
196
196
  * live from boot. Name must start with '$' and not be a built-in or `$ref`.
197
197
  */
198
198
  static registerViewReducer(name: string, reducer: import('./features/views').OKDBCustomReducer): void;
199
+ /**
200
+ * Copy a CLOSED store to `dstPath` (must not exist or be empty) as a distinct store: its first
201
+ * open gives it a fresh identity (new id, bus group, token secret, sync keypair; no sync
202
+ * membership; leases dropped) while every document, index, view, FTS index, time-machine
203
+ * history and processor cursor carries over — nothing is rebuilt. Throws STORE_IN_USE when
204
+ * the source is open (detected on Linux), CLONE_DEST_NOT_EMPTY, CLONE_DEST_OVERLAPS_SOURCE,
205
+ * STORE_NOT_FOUND. For a live store: `db.migrate.backup(dir)` then `OKDB.reidentify(dir)`.
206
+ */
207
+ static clone(srcPath: string, dstPath: string): Promise<{ path: string; files: number; bytes: number; ms: number }>;
208
+ /**
209
+ * Mark a closed copy of a store (cp, a restored backup) to take a fresh identity on its next
210
+ * open — the step `clone()` ends with. Idempotent; applied exactly once by the first open.
211
+ */
212
+ static reidentify(storePath: string): { path: string; pending: true; alreadyPending: boolean };
199
213
 
200
214
  constructor(dbPath: string, options?: OKDBOptions);
201
215
 
202
216
  readonly path: string;
203
217
  /** Instance identity (set at open()). */
204
218
  readonly id: string;
219
+ /** Identities this store had before it was cloned / re-identified, oldest first ([] for an original). */
220
+ readonly formerIds: string[];
205
221
  readonly options: OKDBOptions;
206
222
  readonly events: EventEmitter;
207
223
  /** The okdb package version (no env needs to be open). */
@@ -246,7 +262,11 @@ export declare class OKDB {
246
262
  readonly files: OKDBFiles;
247
263
 
248
264
  // ── Lifecycle ─────────────────────────────────────────────────────────────
265
+ /** Open the store. If it throws (any phase: env open, storage version check, a plugin's
266
+ * start(), …), everything it had opened is released before the error propagates and the
267
+ * instance is left `stopped`: close() is then a no-op, and a retry needs a NEW instance. */
249
268
  open(): Promise<void>;
269
+ /** Close the instance. A no-op on a stopped instance (after close() or a failed open()). */
250
270
  close(): Promise<void>;
251
271
  /** Resolved role flags. `engines`/`compaction` are fixed for the instance's lifetime;
252
272
  * `processors` reflects CURRENT participation (see processors.start/stop). */