import { BaseListener, BaseObserverInterface, Disposable } from '../../../utils/BaseObserver.js'; import { CrudBatch } from './CrudBatch.js'; import { CrudEntry, OpId } from './CrudEntry.js'; import { SyncDataBatch } from './SyncDataBatch.js'; export interface BucketDescription { name: string; priority: number; } export interface Checkpoint { last_op_id: OpId; buckets: BucketChecksum[]; write_checkpoint?: string; streams?: any[]; } export interface BucketState { bucket: string; op_id: string; } export interface ChecksumCache { checksums: Map; lastOpId: OpId; } export interface SyncLocalDatabaseResult { ready: boolean; checkpointValid: boolean; checkpointFailures?: string[]; } export type SavedProgress = { atLast: number; sinceLast: number; }; export type BucketOperationProgress = Record; export interface BucketChecksum { bucket: string; priority?: number; /** * 32-bit unsigned hash. */ checksum: number; /** * Count of operations - informational only. */ count?: number; /** * The JavaScript client does not use this field, which is why it's defined to be `any`. We rely on the structure of * this interface to pass custom `BucketChecksum`s to the Rust client in unit tests, which so all fields need to be * present. */ subscriptions?: any; } export declare enum PSInternalTable { DATA = "ps_data", CRUD = "ps_crud", BUCKETS = "ps_buckets", OPLOG = "ps_oplog", UNTYPED = "ps_untyped" } export declare enum PowerSyncControlCommand { PROCESS_TEXT_LINE = "line_text", PROCESS_BSON_LINE = "line_binary", STOP = "stop", START = "start", NOTIFY_TOKEN_REFRESHED = "refreshed_token", NOTIFY_CRUD_UPLOAD_COMPLETED = "completed_upload", UPDATE_SUBSCRIPTIONS = "update_subscriptions" } export interface BucketStorageListener extends BaseListener { crudUpdate: () => void; } export interface BucketStorageAdapter extends BaseObserverInterface, Disposable { init(): Promise; saveSyncData(batch: SyncDataBatch, fixedKeyFormat?: boolean): Promise; removeBuckets(buckets: string[]): Promise; setTargetCheckpoint(checkpoint: Checkpoint): Promise; startSession(): void; getBucketStates(): Promise; getBucketOperationProgress(): Promise; hasMigratedSubkeys(): Promise; migrateToFixedSubkeys(): Promise; syncLocalDatabase(checkpoint: Checkpoint, priority?: number): Promise<{ checkpointValid: boolean; ready: boolean; failures?: any[]; }>; nextCrudItem(): Promise; hasCrud(): Promise; getCrudBatch(limit?: number): Promise; hasCompletedSync(): Promise; updateLocalTarget(cb: () => Promise): Promise; getMaxOpId(): string; /** * Get an unique client id. */ getClientId(): Promise; /** * Invokes the `powersync_control` function for the sync client. */ control(op: PowerSyncControlCommand, payload: string | Uint8Array | null): Promise; }