import type { JsDb } from './feltdb.js'; import { type FreshnessCapability, type Revision } from './freshness.js'; import type { AtomicTransactionRequest, AtomicTransactionResult } from './transaction.js'; import type { AuthorityQueryRequest } from './http-db.js'; interface JsResult { success: boolean; data?: string; error?: string; } interface ChangeRecord { sequence?: number; collection: string; key: string; type: 'put' | 'delete'; timestamp: number; id: string; origin: string; value?: unknown; } type ChangeListener = (collection: string) => void; /** Durable browser runtime. Every mutation resolves only after its IndexedDB transaction commits. */ export declare class IndexedDbJsDb implements JsDb { private readonly database; private readonly channel?; private sequence; private readonly origin; private readonly peers; private readonly changeListeners; private changeCursor; private changePollGeneration; private changePollRunning; private changePollTimer?; private changeChannelListening; private changeCoordinatorReady; private pendingChangeAnnouncements; private readonly announcedChangeSequences; constructor(namespace: string); private open; private splitKey; private mutate; insert(key: string, value: string): Promise; update(key: string, value: string): Promise; delete(key: string): Promise; /** * Commit several operations atomically and durably. * * Reads, precondition checks, and writes all happen inside a single * IndexedDB readwrite transaction, which is the browser's own atomic commit * boundary. If any step fails the transaction aborts and nothing is written, * and the promise resolves only after the transaction has committed. */ commit_transaction(request: AtomicTransactionRequest): Promise; cas(params: { key: string; expectedVersion: number; value: string; }): Promise<{ updated: boolean; currentVersion: number; }>; get(key: string): Promise; query(collection: string): Promise; /** * Browser bounded-query fallback. IndexedDB schema indexes are static, so a * dynamically declared FeltDB index is not claimed here until it has a * durable object-store representation. The fallback stays correct and its * plan truthfully reports a full scan. */ authority_query>(query: AuthorityQueryRequest): Promise & { stats: import("./embedded-query.js").EmbeddedQueryStats; }>; explain_query(query: AuthorityQueryRequest): { plan: string; reason: string; order: string; limit: number; cursor: boolean; }; rebuild_indexes(): void; private request; subscribe_changes(callback: ChangeListener, collection?: string): () => void; private readonly receiveChangeMessage; private deliverChangeAnnouncement; private announceLocalChange; private rememberAnnouncedSequence; private notifyChangeListeners; private startChangeCoordinator; private latestChangeSequence; private pollChanges; private stopChangeCoordinator; close(): void; get_capability_records(capability: string): Promise; execute_op(): JsResult; sync_info(): JsResult; add_peer(): JsResult; add_sync_peer(peerId: string): JsResult; remove_sync_peer(peerId: string): JsResult; get_pending_for_peer(): JsResult; acknowledge_peer_operations(): JsResult; instance_id(): string; get_sequence(): number; /** * IndexedDB is the serialization authority for this database. * * The `changes` store is `autoIncrement`, so its key is assigned by the * storage engine inside the same readwrite transaction that writes the record, * and the browser serializes readwrite transactions on an object store across * tabs. A second tab's commit therefore advances the same durable counter, * with no coordination code of our own. * * Note what is *not* used here: `this.sequence` counts what this handle wrote * and would miss every other tab. The durable key is the authoritative value. */ freshness(): FreshnessCapability; /** * The highest durable `changes` key. * * Read from the store rather than from memory so a write committed by another * tab is included. An empty store is revision 0, which is a real value: it * means nothing has been committed, and a cache built at 0 is still current. */ revision(): Promise; audit_events(): Promise; export_operations(sinceSequence: number): Promise; apply_remote_operations(operations: ChangeRecord[]): Promise<{ applied: number; ignored: number; }>; } export {}; //# sourceMappingURL=indexeddb-db.d.ts.map