import type { RxChangeEvent } from 'rxdb/plugins/core'; import { type SyncedDoc } from '../sync/index.js'; import { type WasCollectionConfig, type WasSyncConfig } from '../config.js'; import type { LocalStore } from './localStore.js'; import type { WasRemoteStore } from './wasRemoteStore.js'; /** * Whether a replication error signals expired/revoked storage access. Every WAS * request the replication makes funnels through the sync port, which maps a * `401` / `403` to a typed {@link WasSyncAuthError} at the boundary. RxDB then * wraps that thrown error inside an RxError (nested under `cause` / `errors` / * `parameters.errors`), so this walks the error graph looking for a * `WasSyncAuthError` rather than re-extracting raw status codes. RxDB's * wrapping serializes the handler's thrown error to plain JSON (name, message, * stack -- `errorToPlainJson`), so the walk matches the serialized `name` * alongside a live instance; an instance only ever appears when a caller hands * the port error over directly. * * @param err {unknown} * @returns {boolean} */ export declare function isAuthError(err: unknown): boolean; /** * A per-session controller around background replication. */ export declare class SyncController { #private; constructor({ collections, sync }: { collections: WasCollectionConfig[]; sync?: WasSyncConfig; }); /** * Starts background replication for every entity collection covered by the * grant set. Idempotent (a no-op if already running). * * @param options {object} * @param options.remoteStore {WasRemoteStore} * @param options.localStore {LocalStore} * @param [options.onRemoteChange] {(collectionKey: string, event) => void} * fired per RxDB change (pull or conflict-resolved push) for reactive * per-doc store patching * @param [options.onAuthError] {() => void} fired when a replication error * carries a 401/403 (storage access expired/revoked) * @returns {Promise} */ start({ remoteStore, localStore, onRemoteChange, onAuthError }: { remoteStore: WasRemoteStore; localStore: LocalStore; onRemoteChange?: (collectionKey: string, event: RxChangeEvent) => void; onAuthError?: () => void; }): Promise; /** * Triggers an immediate replication cycle on every running collection, rather * than waiting for RxDB's next scheduled tick. Fire-and-forget. * * @returns {void} */ reSync(): void; /** * Stops replication and releases resources (the database is owned by the * caller). Idempotent. * * @returns {Promise} */ stop(): Promise; } //# sourceMappingURL=syncController.d.ts.map