import { it as VisualEditingNode } from "./types.js"; import { SanityClient, SanityDocument } from "@sanity/client"; import { DocumentMutatorMachineInput, createSharedListener } from "@sanity/mutate/_unstable_machine"; import { AnyStateMachine } from "xstate"; import { Mutation, NodePatchList } from "@sanity/mutate"; interface DatasetMutatorMachineInput extends Omit { client: SanityClient; /** A shared listener can be provided, if not it'll be created using `client.listen()` */ sharedListener?: ReturnType; } declare const createDatasetMutator: (comlink: VisualEditingNode) => AnyStateMachine; type Path = K extends string ? T[K] extends Record ? `${K}.${Path}` | K : K : never; type PathValue = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue : never : P extends keyof T ? T[P] : never; type DocumentsMutate = (documentId: string, mutations: Mutation[], options?: { commit?: boolean | { debounce: number; }; }) => void; type DocumentsGet = >(documentId: string) => OptimisticDocument; type OptimisticDocumentPatches = Record> = ((context: { draftId: string; publishedId: string; /** * @deprecated - use `getSnapshot` instead */ snapshot: SanityDocument | undefined; getSnapshot: () => Promise | null>; }) => Promise | NodePatchList) | NodePatchList; type OptimisticDocument = Record> = { /** * The document ID */ id: string; /** * Commits any locally applied mutations to the remote document */ commit: () => void; /** * @deprecated - use `getSnapshot` instead */ get: { (): SanityDocument | undefined;

>(path: P): PathValue | undefined; }; /** * Returns a promise that resolves to the current document snapshot */ getSnapshot: () => Promise | null>; /** * Applies the given patches to the document */ patch: (patches: OptimisticDocumentPatches, options?: { commit?: boolean | { debounce: number; }; }) => void; }; type OptimisticReducerAction = { document: T; id: string; originalId: string; type: 'appear' | 'mutate' | 'disappear'; }; type OptimisticReducer = (state: T, action: OptimisticReducerAction) => T; export { OptimisticReducer as a, PathValue as c, OptimisticDocumentPatches as i, DatasetMutatorMachineInput as l, DocumentsMutate as n, OptimisticReducerAction as o, OptimisticDocument as r, Path as s, DocumentsGet as t, createDatasetMutator as u }; //# sourceMappingURL=types2.d.ts.map