import type { Zero } from '../../../zero-client/src/client/zero.ts'; import type { Schema } from '../../../zero-schema/src/builder/schema-builder.ts'; export interface BatchOp { type: 'upsert' | 'delete'; table: string; row?: Record; pkValue?: unknown; } export type ConvexBatchCrudFn = (ops: BatchOp[], orgId: string, lmid?: { clientGroupID: string; clientID: string; mutationID: number; }) => Promise>; /** Query response includes row data + LMID map from zeroClients table */ export type ConvexQueryResult = Record & { lastMutationIDChanges?: Record; }; export type ConvexQueryFn = () => Promise; export interface ConvexSyncAdapterOptions { zero: Zero; orgId: string; /** * Tables owned by this adapter. Tables omitted from a query result are left * untouched; tables present with an empty array are authoritatively cleared. */ tables: readonly string[]; /** Primary-key field for every table in `tables`. */ primaryKeys: Readonly>; convexBatchCrud: ConvexBatchCrudFn; convexQuery: ConvexQueryFn; } /** * ConvexSyncAdapter — bridges Zero (Replicache) with Convex backend. * * KEY INSIGHT from Zero cache server analysis: * Replicache snapshots are built incrementally on top of the PREVIOUS snapshot. * When a poke confirms mutations via lastMutationIDChanges, those mutations * are dropped from the replay chain. If the patch doesn't include the data * those mutations produced, that data VANISHES. * * Therefore: every poke that confirms mutations MUST include the full current * state via all {op: "put"} rows. This ensures the snapshot is always a * complete replacement from Convex truth. */ export declare class ConvexSyncAdapter { #private; constructor(options: ConvexSyncAdapterOptions); init(): Promise; destroy(): void; /** * Called by Convex subscription when data changes (from any client). * * Uses LMID-change detection instead of a pending flag: * - If server LMIDs contain new confirmations → FULL patch (safe for rebase) * - If only row data changed → diff patch (efficient) * - If nothing changed → skip entirely */ syncFromConvexData(data: ConvexQueryResult): Promise; } //# sourceMappingURL=convex.d.ts.map