import { QueryClient } from '@tanstack/query-core'; import { ChangeMessage, Collection } from '@tanstack/db'; export type SyncOperation = { type: `insert`; data: TInsertInput | Array; } | { type: `update`; data: Partial | Array>; } | { type: `delete`; key: TKey | Array; } | { type: `upsert`; data: Partial | Array>; }; export interface SyncContext { collection: Collection; queryClient: QueryClient; queryKey: Array; getKey: (item: TRow) => TKey; /** * Begin a new sync transaction. * @param options.immediate - When true, the transaction will be processed immediately * even if there are persisting user transactions. Used by manual write operations. */ begin: (options?: { immediate?: boolean; }) => void; write: (message: Omit, `key`>) => void; commit: () => void; /** * Optional function to update the query cache with the latest synced data. * Handles both direct array caches and wrapped response formats (when `select` is used). * If not provided, falls back to directly setting the cache with the raw array. */ updateCacheData?: (items: Array) => void; } export declare function performWriteOperations(operations: SyncOperation | Array>, ctx: SyncContext): void; export declare function createWriteUtils(getContext: () => SyncContext | null): { writeInsert(data: TInsertInput | Array): void; writeUpdate(data: Partial | Array>): void; writeDelete(key: TKey | Array): void; writeUpsert(data: Partial | Array>): void; writeBatch(callback: () => void): void; };