import type { CollectionConfig, PendingMutation } from '@tanstack/db'; import { type CollectionCache, type MutationStorage, type SyncCollection } from '../../client/syncCollection'; import type { RowKey } from '../../engine/types'; export type TanStackRowKey = Extract; export type TanStackMutationCall = { name: string; args?: unknown; }; export type TanStackMutationMapper = string | ((mutation: PendingMutation) => TanStackMutationCall | undefined); export type SyncTanStackMutations = { insert?: TanStackMutationMapper; update?: TanStackMutationMapper; delete?: TanStackMutationMapper; }; export type SyncTanStackCollectionOptions = Omit, 'sync' | 'getKey' | 'onInsert' | 'onUpdate' | 'onDelete'> & { /** WebSocket URL of the Absolute Sync endpoint. */ url: string; /** Registered Absolute Sync collection name. */ collection: string; /** Query params forwarded to the server collection hydrate/match/authorize hooks. */ params?: unknown; /** Row identity shared by TanStack DB and Absolute Sync. */ getKey: (row: T) => TKey; webSocketImpl?: typeof WebSocket; reconnectMs?: number; maxReconnectMs?: number; storage?: MutationStorage; cache?: CollectionCache; onError?: (error: unknown) => void; /** * Optional mapping from TanStack mutations to registered Absolute Sync * mutation names. TanStack already applies optimistic writes, so forwarded * sync mutations intentionally do not add another optimistic overlay. */ mutations?: SyncTanStackMutations; /** Optional prebuilt Absolute Sync collection, useful when sharing lifecycle externally. */ syncCollection?: SyncCollection; }; export declare const createSyncTanStackCollectionOptions: (options: SyncTanStackCollectionOptions) => CollectionConfig; export { createSyncTanStackCollectionOptions as syncTanStackCollectionOptions };