Read the negentropy sync guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.
SyncOptions
interface SyncOptions {
tables?: readonly string[];
initial?: boolean;
reconnect?: boolean;
timeout?: number;
onError?: (error: NostrbaseError) => void;
}
SyncPullOptions
interface SyncPullOptions {
signal?: AbortSignal;
relays?: readonly string[];
/** Disable reconciliation and request normal events directly. */
strategy?: "auto" | "query";
}
SyncRelayResult
interface SyncRelayResult extends RelayResult {
strategy: "negentropy" | "query" | "mixed";
fallbackReason?: string;
received: number;
}
SyncMeta
interface SyncMeta extends ResultMeta {
sync: SyncRelayResult[];
}
SyncResult
interface SyncResult extends Result<NostrEvent[]> {
meta?: SyncMeta;
}
NostrbaseSync
/** Pull-only reconciliation. Cached events belonging to other authors are never published. */
declare class NostrbaseSync {}
constructor
constructor(host: SyncHost, options?: SyncOptions);
registerTable
registerTable(table: string, initial?: boolean): void;
table
table(table: string, options?: SyncPullOptions): Promise<SyncResult>;
pull
pull(input?: Filter | Filter[], options?: SyncPullOptions): Promise<SyncResult>;
start
/** Opt-in startup/reconnect recovery. This does not replace live subscriptions. */
start(): void;
close
close(): void;
Supporting declarations
These types appear in public signatures but are not package exports.
SyncHost
interface SyncHost {
namespace: string;
relays: string[];
pool: RelayPool;
eventStore: EventStore;
transport: Transport;
timeout: number;
ready(): Promise<void>;
assertOpen(): void;
signal(signal?: AbortSignal): AbortSignal;
ingest(event: NostrEvent): boolean;
}