import type { NoydbStore, NoydbPodStore } from '../kernel/types.js'; export interface WrapPodStoreOptions { /** * When `true` (default), every `put()` and `delete()` flushes the full * vault snapshot to the bundle backend. Set to `false` for bulk operations * and call `store.flush(vaultId)` manually. */ autoFlush?: boolean; } export interface WrappedPodNoydbStore extends NoydbStore { /** Manually flush the in-memory snapshot to the bundle backend. */ flush(vaultId: string): Promise; /** * Run a batch of mutations without flushing until the callback completes. * A single flush is performed at the end. */ batch(vaultId: string, fn: () => Promise): Promise; } /** * Convert a `NoydbPodStore` (blob-oriented read/write with OCC) into the * standard six-method `NoydbStore` interface expected by `createNoydb({ store })`. * * Bundle stores operate on the entire vault as a single serialised unit — * ideal for backends like Google Drive, WebDAV, or iCloud Drive that work * best with whole-file I/O rather than per-record KV operations. * * ## Optimistic concurrency * * The wrapper tracks the `version` token from the last `readBundle` and * passes it as `expectedVersion` on every flush. On * `PodVersionConflictError`, it re-reads, merges the remote snapshot * (last-write-wins per record key), and retries (max 3 attempts). * * ## Flush modes * * By default, flushes on every mutation (O(vault size) per write). Options: * - `autoFlush: false` + explicit `store.flush(vaultId)` calls * - `store.batch(vaultId, async () => { ... })` — defers flush until end * - Pair with `syncPolicy: { push: { mode: 'debounce' } }` from */ export declare function wrapPodStore(bundle: NoydbPodStore, options?: WrapPodStoreOptions): WrappedPodNoydbStore; /** * Type-safe factory helper for `NoydbPodStore` implementations, * analogous to `createStore` for KV stores. */ export declare function createPodStore(factory: (options: TOptions) => NoydbPodStore): (options: TOptions) => NoydbPodStore; /** @deprecated Use wrapPodStore. */ export declare const wrapBundleStore: typeof wrapPodStore; /** @deprecated Use createPodStore. */ export declare const createBundleStore: typeof createPodStore; /** @deprecated Use WrappedPodNoydbStore. */ export type WrappedBundleNoydbStore = WrappedPodNoydbStore; /** @deprecated Use WrapPodStoreOptions. */ export type WrapBundleStoreOptions = WrapPodStoreOptions;