@sanity/visual-editing
Version:
[](https://npm-stat.com/charts.html?package=@sanity/visual-editing) [](https://
1,203 lines • 91.5 kB
TypeScript
import { it as VisualEditingNode } from "./types.js";
import * as _sanity_mutate__unstable_machine168 from "@sanity/mutate/_unstable_machine";
import { DocumentMutatorMachineInput, createSharedListener } from "@sanity/mutate/_unstable_machine";
import * as _sanity_client424 from "@sanity/client";
import { SanityClient, SanityDocument } from "@sanity/client";
import * as xstate525 from "xstate";
import { ActorRefFrom } from "xstate";
import * as rxjs4 from "rxjs";
import { Mutation, NodePatchList } from "@sanity/mutate";
declare const createDocumentMutator: (comlink: VisualEditingNode) => xstate525.StateMachine<{
client: SanityClient;
sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, {
[x: string]: xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>> | xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>> | xstate525.ActorRefFromLogic<xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
}, xstate525.EventObject>> | undefined;
getDocument?: xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>> | undefined;
submitTransactions?: xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>> | undefined;
}, xstate525.Values<{
'fetch remote snapshot': {
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
};
'submit mutations as transactions': {
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
};
'server-sent events': {
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
};
}>, xstate525.Values<{
'assign error to context': {
type: "assign error to context";
params: xstate525.NonReducibleUnknown;
};
'clear error from context': {
type: "clear error from context";
params: xstate525.NonReducibleUnknown;
};
'connect to server-sent events': {
type: "connect to server-sent events";
params: xstate525.NonReducibleUnknown;
};
'listen to server-sent events': {
type: "listen to server-sent events";
params: xstate525.NonReducibleUnknown;
};
'stop listening to server-sent events': {
type: "stop listening to server-sent events";
params: xstate525.NonReducibleUnknown;
};
'buffer remote mutation events': {
type: "buffer remote mutation events";
params: xstate525.NonReducibleUnknown;
};
'restore stashed changes': {
type: "restore stashed changes";
params: xstate525.NonReducibleUnknown;
};
'rebase fetched remote snapshot': {
type: "rebase fetched remote snapshot";
params: xstate525.NonReducibleUnknown;
};
'apply mendoza patch': {
type: "apply mendoza patch";
params: xstate525.NonReducibleUnknown;
};
'increment fetch attempts': {
type: "increment fetch attempts";
params: xstate525.NonReducibleUnknown;
};
'reset fetch attempts': {
type: "reset fetch attempts";
params: xstate525.NonReducibleUnknown;
};
'increment submit attempts': {
type: "increment submit attempts";
params: xstate525.NonReducibleUnknown;
};
'reset submit attempts': {
type: "reset submit attempts";
params: xstate525.NonReducibleUnknown;
};
'stage mutation': {
type: "stage mutation";
params: xstate525.NonReducibleUnknown;
};
'stash mutation': {
type: "stash mutation";
params: xstate525.NonReducibleUnknown;
};
'rebase local snapshot': {
type: "rebase local snapshot";
params: xstate525.NonReducibleUnknown;
};
'send pristine event to parent': {
type: "send pristine event to parent";
params: xstate525.NonReducibleUnknown;
};
'send sync event to parent': {
type: "send sync event to parent";
params: xstate525.NonReducibleUnknown;
};
'send mutation event to parent': {
type: "send mutation event to parent";
params: xstate525.NonReducibleUnknown;
};
}>, never, "fetchRemoteSnapshotTimeout" | "submitTransactionsTimeout", "disconnected" | "connecting" | "reconnecting" | "connectFailure" | {
connected: "loading" | "loadFailure" | {
loaded: "pristine" | "dirty" | "submitting" | "submitFailure";
};
}, "error" | "busy" | "ready", _sanity_mutate__unstable_machine168.DocumentMutatorMachineInput, xstate525.NonReducibleUnknown, xstate525.EventObject, xstate525.MetaObject, {
readonly id: "document-mutator";
readonly context: ({
input
}: {
spawn: {
<TSrc extends "fetch remote snapshot" | "submit mutations as transactions" | "server-sent events">(logic: TSrc, ...[options]: ({
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
} extends infer T ? T extends {
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
} ? T extends {
src: TSrc;
} ? xstate525.ConditionalRequired<[options?: ({
id?: T["id"] | undefined;
systemId?: string;
input?: xstate525.InputFrom<T["logic"]> | undefined;
syncSnapshot?: boolean;
} & { [K in xstate525.RequiredActorOptions<T>]: unknown }) | undefined], xstate525.IsNotNever<xstate525.RequiredActorOptions<T>>> : never : never : never) | ({
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
} extends infer T_1 ? T_1 extends {
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
} ? T_1 extends {
src: TSrc;
} ? xstate525.ConditionalRequired<[options?: ({
id?: T_1["id"] | undefined;
systemId?: string;
input?: xstate525.InputFrom<T_1["logic"]> | undefined;
syncSnapshot?: boolean;
} & { [K_1 in xstate525.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate525.IsNotNever<xstate525.RequiredActorOptions<T_1>>> : never : never : never) | ({
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
} extends infer T_2 ? T_2 extends {
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
} ? T_2 extends {
src: TSrc;
} ? xstate525.ConditionalRequired<[options?: ({
id?: T_2["id"] | undefined;
systemId?: string;
input?: xstate525.InputFrom<T_2["logic"]> | undefined;
syncSnapshot?: boolean;
} & { [K_2 in xstate525.RequiredActorOptions<T_2>]: unknown }) | undefined], xstate525.IsNotNever<xstate525.RequiredActorOptions<T_2>>> : never : never : never)): xstate525.ActorRefFromLogic<xstate525.GetConcreteByKey<xstate525.Values<{
"fetch remote snapshot": {
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
};
"submit mutations as transactions": {
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
};
"server-sent events": {
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
};
}>, "src", TSrc>["logic"]>;
<TLogic extends xstate525.AnyActorLogic>(src: TLogic, options?: {
id?: never;
systemId?: string;
input?: xstate525.InputFrom<TLogic> | undefined;
syncSnapshot?: boolean;
} | undefined): xstate525.ActorRefFromLogic<TLogic>;
};
input: _sanity_mutate__unstable_machine168.DocumentMutatorMachineInput;
self: xstate525.ActorRef<xstate525.MachineSnapshot<{
client: SanityClient;
sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, Record<string, xstate525.AnyActorRef | undefined>, xstate525.StateValue, string, unknown, any, any>, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, xstate525.AnyEventObject>;
}) => {
client: SanityClient;
sharedListener: rxjs4.Observable<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent> | undefined;
id: string;
remote: undefined;
local: undefined;
mutationEvents: never[];
stagedChanges: never[];
stashedChanges: never[];
error: undefined;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
cache: Map<string, _sanity_client424.SanityDocument<DocumentType> | null> | undefined;
};
readonly entry: readonly ["connect to server-sent events"];
readonly on: {
readonly mutate: {
readonly actions: readonly ["rebase local snapshot", "stage mutation"];
};
};
readonly initial: "disconnected";
readonly states: {
readonly disconnected: {
readonly on: {
readonly connect: {
readonly target: "connecting";
readonly actions: readonly ["listen to server-sent events"];
};
};
};
readonly connecting: {
readonly on: {
readonly welcome: "connected";
readonly reconnect: "reconnecting";
readonly error: "connectFailure";
};
readonly tags: readonly ["busy"];
};
readonly connectFailure: {
readonly on: {
readonly connect: {
readonly target: "connecting";
readonly actions: readonly ["listen to server-sent events"];
};
};
readonly entry: readonly ["stop listening to server-sent events", "assign error to context"];
readonly exit: readonly ["clear error from context"];
readonly tags: readonly ["error"];
};
readonly reconnecting: {
readonly on: {
readonly welcome: {
readonly target: "connected";
};
readonly error: {
readonly target: "connectFailure";
};
};
readonly tags: readonly ["busy", "error"];
};
readonly connected: {
readonly on: {
readonly mutation: {
readonly actions: readonly ["buffer remote mutation events"];
};
readonly reconnect: "reconnecting";
};
readonly entry: readonly ["clear error from context"];
readonly initial: "loading";
readonly states: {
readonly loading: {
readonly invoke: {
readonly src: "fetch remote snapshot";
readonly id: "getDocument";
readonly input: ({
context
}: {
context: {
client: SanityClient;
sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
};
event: _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
};
self: xstate525.ActorRef<xstate525.MachineSnapshot<{
client: SanityClient;
sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, Record<string, xstate525.AnyActorRef>, xstate525.StateValue, string, unknown, any, any>, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, xstate525.AnyEventObject>;
}) => {
client: SanityClient;
id: string;
};
readonly onError: {
readonly target: "loadFailure";
};
readonly onDone: {
readonly target: "loaded";
readonly actions: readonly ["rebase fetched remote snapshot", "reset fetch attempts"];
};
};
readonly tags: readonly ["busy"];
};
readonly loaded: {
readonly entry: readonly ["send sync event to parent"];
readonly on: {
readonly mutation: {
readonly actions: readonly ["apply mendoza patch", "send mutation event to parent"];
};
};
readonly initial: "pristine";
readonly states: {
readonly pristine: {
readonly on: {
readonly mutate: {
readonly actions: readonly ["rebase local snapshot", "stage mutation"];
readonly target: "dirty";
};
};
readonly tags: readonly ["ready"];
};
readonly dirty: {
readonly on: {
readonly submit: "submitting";
};
readonly tags: readonly ["ready"];
};
readonly submitting: {
readonly on: {
readonly mutate: {
readonly actions: readonly ["rebase local snapshot", "stash mutation"];
};
};
readonly invoke: {
readonly src: "submit mutations as transactions";
readonly id: "submitTransactions";
readonly input: ({
context
}: {
context: {
client: SanityClient;
sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
};
event: _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
};
self: xstate525.ActorRef<xstate525.MachineSnapshot<{
client: SanityClient;
sharedListener?: ReturnType<typeof _sanity_mutate__unstable_machine168.createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, Record<string, xstate525.AnyActorRef>, xstate525.StateValue, string, unknown, any, any>, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, xstate525.AnyEventObject>;
}) => {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
};
readonly onError: {
readonly target: "submitFailure";
};
readonly onDone: {
readonly target: "pristine";
readonly actions: readonly ["restore stashed changes", "reset submit attempts", "send pristine event to parent"];
};
};
readonly tags: readonly ["busy", "ready"];
};
readonly submitFailure: {
readonly exit: readonly ["clear error from context"];
readonly after: {
readonly submitTransactionsTimeout: {
readonly actions: readonly ["increment submit attempts"];
readonly target: "submitting";
};
};
readonly on: {
readonly retry: "submitting";
};
readonly tags: readonly ["error", "ready"];
};
};
};
readonly loadFailure: {
readonly exit: readonly ["clear error from context"];
readonly after: {
readonly fetchRemoteSnapshotTimeout: {
readonly actions: readonly ["increment fetch attempts"];
readonly target: "loading";
};
};
readonly on: {
readonly retry: "loading";
};
readonly tags: readonly ["error"];
};
};
};
};
}>;
interface DatasetMutatorMachineInput extends Omit<DocumentMutatorMachineInput, 'id'> {
client: SanityClient;
/** A shared listener can be provided, if not it'll be created using `client.listen()` */
sharedListener?: ReturnType<typeof createSharedListener>;
}
declare const createDatasetMutator: (comlink: VisualEditingNode) => xstate525.StateMachine<{
client: SanityClient;
/** A shared listener can be provided, if not it'll be created using `client.listen()` */
sharedListener?: ReturnType<typeof createSharedListener>;
documents: Record<string, ActorRefFrom<ReturnType<typeof createDocumentMutator>>>;
}, {
type: "sync";
id: string;
document: _sanity_mutate__unstable_machine168.SanityDocumentBase;
} | {
type: "mutation";
id: string;
effects: {
apply: _sanity_mutate__unstable_machine168.RawPatch;
};
previousRev: string;
resultRev: string;
} | {
type: "rebased.local";
id: string;
document: _sanity_mutate__unstable_machine168.SanityDocumentBase;
} | {
type: "rebased.remote";
id: string;
document: _sanity_mutate__unstable_machine168.SanityDocumentBase;
} | {
type: "pristine";
id: string;
} | {
type: "observe";
documentId: string;
} | {
type: "unobserve";
documentId: string;
} | {
type: "add document actor";
documentId: string;
} | {
type: "stop document actor";
documentId: string;
}, {
[x: string]: xstate525.ActorRefFromLogic<xstate525.StateMachine<{
client: SanityClient;
sharedListener?: ReturnType<typeof createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, {
[x: string]: xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>> | xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>> | xstate525.ActorRefFromLogic<xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof createSharedListener>;
id: string;
}, xstate525.EventObject>> | undefined;
getDocument?: xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>> | undefined;
submitTransactions?: xstate525.ActorRefFromLogic<xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>> | undefined;
}, xstate525.Values<{
'fetch remote snapshot': {
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
};
'submit mutations as transactions': {
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
};
'server-sent events': {
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
};
}>, xstate525.Values<{
'assign error to context': {
type: "assign error to context";
params: xstate525.NonReducibleUnknown;
};
'clear error from context': {
type: "clear error from context";
params: xstate525.NonReducibleUnknown;
};
'connect to server-sent events': {
type: "connect to server-sent events";
params: xstate525.NonReducibleUnknown;
};
'listen to server-sent events': {
type: "listen to server-sent events";
params: xstate525.NonReducibleUnknown;
};
'stop listening to server-sent events': {
type: "stop listening to server-sent events";
params: xstate525.NonReducibleUnknown;
};
'buffer remote mutation events': {
type: "buffer remote mutation events";
params: xstate525.NonReducibleUnknown;
};
'restore stashed changes': {
type: "restore stashed changes";
params: xstate525.NonReducibleUnknown;
};
'rebase fetched remote snapshot': {
type: "rebase fetched remote snapshot";
params: xstate525.NonReducibleUnknown;
};
'apply mendoza patch': {
type: "apply mendoza patch";
params: xstate525.NonReducibleUnknown;
};
'increment fetch attempts': {
type: "increment fetch attempts";
params: xstate525.NonReducibleUnknown;
};
'reset fetch attempts': {
type: "reset fetch attempts";
params: xstate525.NonReducibleUnknown;
};
'increment submit attempts': {
type: "increment submit attempts";
params: xstate525.NonReducibleUnknown;
};
'reset submit attempts': {
type: "reset submit attempts";
params: xstate525.NonReducibleUnknown;
};
'stage mutation': {
type: "stage mutation";
params: xstate525.NonReducibleUnknown;
};
'stash mutation': {
type: "stash mutation";
params: xstate525.NonReducibleUnknown;
};
'rebase local snapshot': {
type: "rebase local snapshot";
params: xstate525.NonReducibleUnknown;
};
'send pristine event to parent': {
type: "send pristine event to parent";
params: xstate525.NonReducibleUnknown;
};
'send sync event to parent': {
type: "send sync event to parent";
params: xstate525.NonReducibleUnknown;
};
'send mutation event to parent': {
type: "send mutation event to parent";
params: xstate525.NonReducibleUnknown;
};
}>, never, "fetchRemoteSnapshotTimeout" | "submitTransactionsTimeout", "disconnected" | "connecting" | "reconnecting" | "connectFailure" | {
connected: "loading" | "loadFailure" | {
loaded: "pristine" | "dirty" | "submitting" | "submitFailure";
};
}, "error" | "busy" | "ready", DocumentMutatorMachineInput, xstate525.NonReducibleUnknown, xstate525.EventObject, xstate525.MetaObject, {
readonly id: "document-mutator";
readonly context: ({
input
}: {
spawn: {
<TSrc extends "fetch remote snapshot" | "submit mutations as transactions" | "server-sent events">(logic: TSrc, ...[options]: ({
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
} extends infer T ? T extends {
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
} ? T extends {
src: TSrc;
} ? xstate525.ConditionalRequired<[options?: ({
id?: T["id"] | undefined;
systemId?: string;
input?: xstate525.InputFrom<T["logic"]> | undefined;
syncSnapshot?: boolean;
} & { [K in xstate525.RequiredActorOptions<T>]: unknown }) | undefined], xstate525.IsNotNever<xstate525.RequiredActorOptions<T>>> : never : never : never) | ({
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
} extends infer T_1 ? T_1 extends {
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
} ? T_1 extends {
src: TSrc;
} ? xstate525.ConditionalRequired<[options?: ({
id?: T_1["id"] | undefined;
systemId?: string;
input?: xstate525.InputFrom<T_1["logic"]> | undefined;
syncSnapshot?: boolean;
} & { [K_1 in xstate525.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate525.IsNotNever<xstate525.RequiredActorOptions<T_1>>> : never : never : never) | ({
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
} extends infer T_2 ? T_2 extends {
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
} ? T_2 extends {
src: TSrc;
} ? xstate525.ConditionalRequired<[options?: ({
id?: T_2["id"] | undefined;
systemId?: string;
input?: xstate525.InputFrom<T_2["logic"]> | undefined;
syncSnapshot?: boolean;
} & { [K_2 in xstate525.RequiredActorOptions<T_2>]: unknown }) | undefined], xstate525.IsNotNever<xstate525.RequiredActorOptions<T_2>>> : never : never : never)): xstate525.ActorRefFromLogic<xstate525.GetConcreteByKey<xstate525.Values<{
"fetch remote snapshot": {
src: "fetch remote snapshot";
logic: xstate525.PromiseActorLogic<void | _sanity_client424.SanityDocument<Record<string, any>> | undefined, {
client: SanityClient;
id: string;
}, xstate525.EventObject>;
id: "getDocument";
};
"submit mutations as transactions": {
src: "submit mutations as transactions";
logic: xstate525.PromiseActorLogic<void, {
client: SanityClient;
transactions: _sanity_mutate__unstable_machine168.Transaction[];
}, xstate525.EventObject>;
id: "submitTransactions";
};
"server-sent events": {
src: "server-sent events";
logic: xstate525.ObservableActorLogic<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent, {
listener: ReturnType<typeof createSharedListener>;
id: string;
}, xstate525.EventObject>;
id: string | undefined;
};
}>, "src", TSrc>["logic"]>;
<TLogic extends xstate525.AnyActorLogic>(src: TLogic, options?: {
id?: never;
systemId?: string;
input?: xstate525.InputFrom<TLogic> | undefined;
syncSnapshot?: boolean;
} | undefined): xstate525.ActorRefFromLogic<TLogic>;
};
input: DocumentMutatorMachineInput;
self: xstate525.ActorRef<xstate525.MachineSnapshot<{
client: SanityClient;
sharedListener?: ReturnType<typeof createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, Record<string, xstate525.AnyActorRef | undefined>, xstate525.StateValue, string, unknown, any, any>, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, xstate525.AnyEventObject>;
}) => {
client: SanityClient;
sharedListener: rxjs4.Observable<_sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent> | undefined;
id: string;
remote: undefined;
local: undefined;
mutationEvents: never[];
stagedChanges: never[];
stashedChanges: never[];
error: undefined;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
cache: Map<string, _sanity_client424.SanityDocument<DocumentType> | null> | undefined;
};
readonly entry: readonly ["connect to server-sent events"];
readonly on: {
readonly mutate: {
readonly actions: readonly ["rebase local snapshot", "stage mutation"];
};
};
readonly initial: "disconnected";
readonly states: {
readonly disconnected: {
readonly on: {
readonly connect: {
readonly target: "connecting";
readonly actions: readonly ["listen to server-sent events"];
};
};
};
readonly connecting: {
readonly on: {
readonly welcome: "connected";
readonly reconnect: "reconnecting";
readonly error: "connectFailure";
};
readonly tags: readonly ["busy"];
};
readonly connectFailure: {
readonly on: {
readonly connect: {
readonly target: "connecting";
readonly actions: readonly ["listen to server-sent events"];
};
};
readonly entry: readonly ["stop listening to server-sent events", "assign error to context"];
readonly exit: readonly ["clear error from context"];
readonly tags: readonly ["error"];
};
readonly reconnecting: {
readonly on: {
readonly welcome: {
readonly target: "connected";
};
readonly error: {
readonly target: "connectFailure";
};
};
readonly tags: readonly ["busy", "error"];
};
readonly connected: {
readonly on: {
readonly mutation: {
readonly actions: readonly ["buffer remote mutation events"];
};
readonly reconnect: "reconnecting";
};
readonly entry: readonly ["clear error from context"];
readonly initial: "loading";
readonly states: {
readonly loading: {
readonly invoke: {
readonly src: "fetch remote snapshot";
readonly id: "getDocument";
readonly input: ({
context
}: {
context: {
client: SanityClient;
sharedListener?: ReturnType<typeof createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
};
event: _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
};
self: xstate525.ActorRef<xstate525.MachineSnapshot<{
client: SanityClient;
sharedListener?: ReturnType<typeof createSharedListener>;
id: string;
cache?: Map<string, _sanity_client424.SanityDocument<DocumentType> | null>;
remote: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
local: _sanity_client424.SanityDocument<DocumentType> | null | undefined;
mutationEvents: _sanity_client424.MutationEvent[];
stagedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
stashedChanges: _sanity_mutate__unstable_machine168.MutationGroup[];
error: unknown;
fetchRemoteSnapshotAttempts: number;
submitTransactionsAttempts: number;
}, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "reconnect";
} | {
type: "welcome";
} | {
type: "mutate";
mutations: _sanity_mutate__unstable_machine168.Mutation[];
} | {
type: "submit";
} | {
type: "xstate.done.actor.getDocument";
output: _sanity_client424.SanityDocument<DocumentType>;
} | {
type: "xstate.done.actor.submitTransactions";
output: undefined;
}, Record<string, xstate525.AnyActorRef>, xstate525.StateValue, string, unknown, any, any>, _sanity_client424.ReconnectEvent | _sanity_client424.WelcomeEvent | _sanity_client424.MutationEvent | {
type: "error";
} | {
type: "retry";
} | {
type: "connect";
} | {
type: "rec