import type * as SqlClient from '@effect/sql/SqlClient'; import * as Effect from 'effect/Effect'; import { Context } from '@dxos/context'; import type { SpaceId } from '@dxos/keys'; import { type FeedProtocol } from '@dxos/protocols'; import type { SqlTransaction } from '@dxos/sql-sqlite'; import type { FeedStore } from './feed-store'; /** Default timeout for feed sync RPCs awaiting an edge response. */ export declare const DEFAULT_SYNC_RPC_TIMEOUT_MS = 30000; type ProtocolMessage = FeedProtocol.ProtocolMessage; type QueryRequestMessage = Extract; type AppendRequestMessage = Extract; type RequestMessage = QueryRequestMessage | AppendRequestMessage; export type SyncClientOptions = { /** This client's peer id. Set as senderPeerId on all requests. */ peerId: string; /** The server's peer id. Set as recipientPeerId on all requests. */ serverPeerId?: string; feedStore: FeedStore; /** Send a protocol message to the server. Returns Effect. */ sendMessage: (ctx: Context, message: RequestMessage) => Effect.Effect; /** * Max time to wait for a matching protocol response after sending a request, in milliseconds. * @default {@link DEFAULT_SYNC_RPC_TIMEOUT_MS} */ rpcTimeoutMs?: number; }; /** * Client-side sync: pull/push by sending protocol messages and handling responses. * Sets senderPeerId = peerId and recipientPeerId = serverPeerId on all requests. * Uses a map of requestId -> Deferred to match responses to in-flight requests. * handleMessage completes the Deferred for the requestId (if any) and removes the handler; no handler = noop. */ export declare class SyncClient { #private; constructor(options: SyncClientOptions); /** * Receive a message from the server. If a handler is registered for the message's requestId, complete it and remove; else noop. */ handleMessage(message: ProtocolMessage): Effect.Effect; pull(ctx: Context, opts: { spaceId: SpaceId; feedNamespace: string; limit?: number; }): Effect.Effect<{ done: boolean; }, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>; /** * Probes remote for blocks after the last pulled position without mutating local storage. * Returns the number of blocks in the first batch (0 when caught up with remote). */ peekPull(ctx: Context, opts: { spaceId: SpaceId; feedNamespace: string; limit?: number; }): Effect.Effect<{ blocksToPull: number; }, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>; push(ctx: Context, opts: { spaceId: SpaceId; feedNamespace: string; limit?: number; }): Effect.Effect<{ done: boolean; }, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>; } export {}; //# sourceMappingURL=sync-client.d.ts.map