import type { WriteEvent, WriteEventOperation } from "@relayfile/core"; import { RelayFileClient } from "./client.js"; import { type RelayFileSyncSocket, type RelayFileSyncTokenProvider } from "./sync.js"; export type OnWriteHandler = (event: WriteEvent) => void | Promise; export interface OnWriteHandlerError { pattern: string; path: string; error: unknown; retryable: false; } export type OnWriteClient = RelayFileClient & { recordHandlerError?(error: OnWriteHandlerError): void | Promise; }; export interface OnWriteOptions { client?: OnWriteClient; workspaceId?: string; operations?: WriteEventOperation[]; signal?: AbortSignal; baseUrl?: string; /** * Optional WebSocket auth override. Accepts the same `string | () => * string | Promise` shape as the underlying sync. * * If omitted, onWrite auto-derives WS auth from `client.getToken()` — the * same JWT the REST API is using — and re-resolves it on every reconnect * so token rotation propagates without restart. **Most callers should * leave this unset.** Passing a literal string is back-compat for older * code; passing a factory is the right shape for production. */ token?: RelayFileSyncTokenProvider; webSocketFactory?: (url: string) => RelayFileSyncSocket; pingIntervalMs?: number; pongTimeoutMs?: number; /** * Notification hook fired when the underlying sync degrades to HTTP * polling because the WebSocket failed to open. Useful for surfacing a * "live updates paused" banner. The SDK also `console.warn`s and emits * an `error` regardless. */ onPollingFallback?: (info: { reason: string; cause?: unknown; }) => void; } export declare function pathMatches(pattern: string, path: string): boolean; export declare function onWrite(pattern: string, handler: OnWriteHandler, options?: OnWriteOptions): () => void;