@sanity/visual-editing
Version:
[](https://npm-stat.com/charts.html?package=@sanity/visual-editing) [](https://
1,250 lines (1,248 loc) • 264 kB
TypeScript
import {ActorRef} from 'xstate'
import {ActorRefFrom} from 'xstate'
import {ActorRefFromLogic} from 'xstate'
import {AnyActorLogic} from 'xstate'
import {AnyActorRef} from 'xstate'
import {AnyEventObject} from 'xstate'
import {ConditionalRequired} from 'xstate'
import {createSharedListener} from '@sanity/mutate/_unstable_machine'
import {DocumentMutatorMachineInput} from '@sanity/mutate/_unstable_machine'
import {DocumentSchema} from '@sanity/presentation-comlink'
import {EventObject} from 'xstate'
import {GetConcreteByKey} from 'xstate'
import {HistoryRefresh} from '@sanity/presentation-comlink'
import {HistoryUpdate} from '@sanity/presentation-comlink'
import {InputFrom} from 'xstate'
import {IsNotNever} from 'xstate'
import {MachineSnapshot} from 'xstate'
import {MetaObject} from 'xstate'
import {Mutation} from '@sanity/mutate'
import {Mutation as Mutation_2} from '@sanity/mutate/_unstable_machine'
import {MutationEvent} from '@sanity/client'
import {MutationGroup} from '@sanity/mutate/_unstable_machine'
import type {Node as Node_2} from '@sanity/comlink'
import {NodePatchList} from '@sanity/mutate'
import {NonReducibleUnknown} from 'xstate'
import {Observable} from 'rxjs'
import {ObservableActorLogic} from 'xstate'
import {PreviewSnapshot} from '@sanity/presentation-comlink'
import {PromiseActorLogic} from 'xstate'
import {RawPatch} from '@sanity/mutate/_unstable_machine'
import {ReconnectEvent} from '@sanity/client'
import {RequiredActorOptions} from 'xstate'
import {RequiredLogicInput} from 'xstate'
import {ResolvedSchemaTypeMap} from '@sanity/presentation-comlink'
import {SanityClient} from '@sanity/client'
import {SanityDocument} from '@sanity/client'
import {SanityDocumentBase} from '@sanity/mutate/_unstable_machine'
import {SanityNode} from '@sanity/presentation-comlink'
import {SanityStegaNode} from '@sanity/presentation-comlink'
import {SchemaArrayItem} from '@sanity/presentation-comlink'
import {SchemaArrayNode} from '@sanity/presentation-comlink'
import {SchemaBooleanNode} from '@sanity/presentation-comlink'
import {SchemaInlineNode} from '@sanity/presentation-comlink'
import {SchemaNode} from '@sanity/presentation-comlink'
import {SchemaNullNode} from '@sanity/presentation-comlink'
import {SchemaNumberNode} from '@sanity/presentation-comlink'
import {SchemaObjectField} from '@sanity/presentation-comlink'
import {SchemaObjectNode} from '@sanity/presentation-comlink'
import {SchemaStringNode} from '@sanity/presentation-comlink'
import {SchemaType} from '@sanity/presentation-comlink'
import {SchemaUnionNode} from '@sanity/presentation-comlink'
import {SchemaUnionNodeOptions} from '@sanity/presentation-comlink'
import {SchemaUnionOption} from '@sanity/presentation-comlink'
import {SchemaUnknownNode} from '@sanity/presentation-comlink'
import {Serializable} from '@sanity/presentation-comlink'
import {SerializableArray} from '@sanity/presentation-comlink'
import {SerializableObject} from '@sanity/presentation-comlink'
import {SerializablePrimitive} from '@sanity/presentation-comlink'
import {Snapshot} from 'xstate'
import {StateMachine} from 'xstate'
import {StateValue} from 'xstate'
import {Transaction} from '@sanity/mutate/_unstable_machine'
import {TypeSchema} from '@sanity/presentation-comlink'
import {UnresolvedPath} from '@sanity/presentation-comlink'
import {Values} from 'xstate'
import {VisualEditingControllerMsg} from '@sanity/presentation-comlink'
import {VisualEditingNodeMsg} from '@sanity/presentation-comlink'
import {WelcomeEvent} from '@sanity/client'
export declare let actor: MutatorActor | EmptyActor
export declare const createDatasetMutator: (comlink: VisualEditingNode) => 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: SanityDocumentBase
}
| {
type: 'mutation'
id: string
effects: {
apply: RawPatch
}
previousRev: string
resultRev: string
}
| {
type: 'rebased.local'
id: string
document: SanityDocumentBase
}
| {
type: 'rebased.remote'
id: string
document: 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]:
| ActorRefFromLogic<
StateMachine<
{
client: SanityClient
sharedListener?: ReturnType<typeof createSharedListener>
id: string
cache?: Map<string, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
},
| WelcomeEvent
| ReconnectEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
{
[x: string]:
| ActorRefFromLogic<
PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
>
| ActorRefFromLogic<
PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
>
| ActorRefFromLogic<
ObservableActorLogic<
WelcomeEvent | ReconnectEvent | MutationEvent,
{
listener: ReturnType<typeof createSharedListener>
id: string
},
EventObject
>
>
| undefined
getDocument?:
| ActorRefFromLogic<
PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
>
| undefined
submitTransactions?:
| ActorRefFromLogic<
PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
>
| undefined
},
Values<{
'fetch remote snapshot': {
src: 'fetch remote snapshot'
logic: PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
id: 'getDocument'
}
'submit mutations as transactions': {
src: 'submit mutations as transactions'
logic: PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
id: 'submitTransactions'
}
'server-sent events': {
src: 'server-sent events'
logic: ObservableActorLogic<
ReconnectEvent | WelcomeEvent | MutationEvent,
{
listener: ReturnType<typeof createSharedListener>
id: string
},
EventObject
>
id: string | undefined
}
}>,
Values<{
'assign error to context': {
type: 'assign error to context'
params: NonReducibleUnknown
}
'clear error from context': {
type: 'clear error from context'
params: NonReducibleUnknown
}
'connect to server-sent events': {
type: 'connect to server-sent events'
params: NonReducibleUnknown
}
'listen to server-sent events': {
type: 'listen to server-sent events'
params: NonReducibleUnknown
}
'stop listening to server-sent events': {
type: 'stop listening to server-sent events'
params: NonReducibleUnknown
}
'buffer remote mutation events': {
type: 'buffer remote mutation events'
params: NonReducibleUnknown
}
'restore stashed changes': {
type: 'restore stashed changes'
params: NonReducibleUnknown
}
'rebase fetched remote snapshot': {
type: 'rebase fetched remote snapshot'
params: NonReducibleUnknown
}
'apply mendoza patch': {
type: 'apply mendoza patch'
params: NonReducibleUnknown
}
'increment fetch attempts': {
type: 'increment fetch attempts'
params: NonReducibleUnknown
}
'reset fetch attempts': {
type: 'reset fetch attempts'
params: NonReducibleUnknown
}
'increment submit attempts': {
type: 'increment submit attempts'
params: NonReducibleUnknown
}
'reset submit attempts': {
type: 'reset submit attempts'
params: NonReducibleUnknown
}
'stage mutation': {
type: 'stage mutation'
params: NonReducibleUnknown
}
'stash mutation': {
type: 'stash mutation'
params: NonReducibleUnknown
}
'rebase local snapshot': {
type: 'rebase local snapshot'
params: NonReducibleUnknown
}
'send pristine event to parent': {
type: 'send pristine event to parent'
params: NonReducibleUnknown
}
'send sync event to parent': {
type: 'send sync event to parent'
params: NonReducibleUnknown
}
'send mutation event to parent': {
type: 'send mutation event to parent'
params: NonReducibleUnknown
}
}>,
never,
'fetchRemoteSnapshotTimeout' | 'submitTransactionsTimeout',
| 'disconnected'
| 'connecting'
| 'reconnecting'
| 'connectFailure'
| {
connected:
| 'loading'
| 'loadFailure'
| {
loaded: 'pristine' | 'dirty' | 'submitting' | 'submitFailure'
}
},
'error' | 'busy' | 'ready',
DocumentMutatorMachineInput,
NonReducibleUnknown,
EventObject,
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: PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
id: 'getDocument'
} extends infer T
? T extends {
src: 'fetch remote snapshot'
logic: PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
id: 'getDocument'
}
? T extends {
src: TSrc
}
? ConditionalRequired<
[
options?:
| ({
id?: T['id'] | undefined
systemId?: string
input?: InputFrom<T['logic']> | undefined
syncSnapshot?: boolean
} & {[K in RequiredActorOptions<T>]: unknown})
| undefined,
],
IsNotNever<RequiredActorOptions<T>>
>
: never
: never
: never)
| ({
src: 'submit mutations as transactions'
logic: PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
id: 'submitTransactions'
} extends infer T_1
? T_1 extends {
src: 'submit mutations as transactions'
logic: PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
id: 'submitTransactions'
}
? T_1 extends {
src: TSrc
}
? ConditionalRequired<
[
options?:
| ({
id?: T_1['id'] | undefined
systemId?: string
input?: InputFrom<T_1['logic']> | undefined
syncSnapshot?: boolean
} & {[K_1 in RequiredActorOptions<T_1>]: unknown})
| undefined,
],
IsNotNever<RequiredActorOptions<T_1>>
>
: never
: never
: never)
| ({
src: 'server-sent events'
logic: ObservableActorLogic<
ReconnectEvent | WelcomeEvent | MutationEvent,
{
listener: ReturnType<typeof createSharedListener>
id: string
},
EventObject
>
id: string | undefined
} extends infer T_2
? T_2 extends {
src: 'server-sent events'
logic: ObservableActorLogic<
ReconnectEvent | WelcomeEvent | MutationEvent,
{
listener: ReturnType<typeof createSharedListener>
id: string
},
EventObject
>
id: string | undefined
}
? T_2 extends {
src: TSrc
}
? ConditionalRequired<
[
options?:
| ({
id?: T_2['id'] | undefined
systemId?: string
input?: InputFrom<T_2['logic']> | undefined
syncSnapshot?: boolean
} & {[K_2 in RequiredActorOptions<T_2>]: unknown})
| undefined,
],
IsNotNever<RequiredActorOptions<T_2>>
>
: never
: never
: never)
): ActorRefFromLogic<
GetConcreteByKey<
Values<{
'fetch remote snapshot': {
src: 'fetch remote snapshot'
logic: PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
id: 'getDocument'
}
'submit mutations as transactions': {
src: 'submit mutations as transactions'
logic: PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
id: 'submitTransactions'
}
'server-sent events': {
src: 'server-sent events'
logic: ObservableActorLogic<
ReconnectEvent | WelcomeEvent | MutationEvent,
{
listener: ReturnType<typeof createSharedListener>
id: string
},
EventObject
>
id: string | undefined
}
}>,
'src',
TSrc
>['logic']
>
<TLogic extends AnyActorLogic>(
src: TLogic,
options?:
| {
id?: never
systemId?: string
input?: InputFrom<TLogic> | undefined
syncSnapshot?: boolean
}
| undefined,
): ActorRefFromLogic<TLogic>
}
input: DocumentMutatorMachineInput
self: ActorRef<
MachineSnapshot<
{
client: SanityClient
sharedListener?: ReturnType<typeof createSharedListener>
id: string
cache?: Map<string, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
},
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
Record<string, AnyActorRef | undefined>,
StateValue,
string,
unknown,
any,
any
>,
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
AnyEventObject
>
}) => {
client: SanityClient
sharedListener:
| Observable<ReconnectEvent | WelcomeEvent | MutationEvent>
| undefined
id: string
remote: undefined
local: undefined
mutationEvents: never[]
stagedChanges: never[]
stashedChanges: never[]
error: undefined
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
cache: Map<string, 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, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
}
event:
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
}
self: ActorRef<
MachineSnapshot<
{
client: SanityClient
sharedListener?: ReturnType<typeof createSharedListener>
id: string
cache?: Map<string, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
},
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
Record<string, AnyActorRef>,
StateValue,
string,
unknown,
any,
any
>,
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
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 createSharedListener>
id: string
cache?: Map<string, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
}
event:
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
}
self: ActorRef<
MachineSnapshot<
{
client: SanityClient
sharedListener?: ReturnType<typeof createSharedListener>
id: string
cache?: Map<string, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
},
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
Record<string, AnyActorRef>,
StateValue,
string,
unknown,
any,
any
>,
| ReconnectEvent
| WelcomeEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
AnyEventObject
>
}) => {
client: SanityClient
transactions: 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']
}
}
}
}
}
>
>
| undefined
},
{
src: 'documentMutatorMachine'
logic: StateMachine<
{
client: SanityClient
sharedListener?: ReturnType<typeof createSharedListener>
id: string
cache?: Map<string, SanityDocument<DocumentType> | null>
remote: SanityDocument<DocumentType> | null | undefined
local: SanityDocument<DocumentType> | null | undefined
mutationEvents: MutationEvent[]
stagedChanges: MutationGroup[]
stashedChanges: MutationGroup[]
error: unknown
fetchRemoteSnapshotAttempts: number
submitTransactionsAttempts: number
},
| WelcomeEvent
| ReconnectEvent
| MutationEvent
| {
type: 'error'
}
| {
type: 'retry'
}
| {
type: 'connect'
}
| {
type: 'reconnect'
}
| {
type: 'welcome'
}
| {
type: 'mutate'
mutations: Mutation_2[]
}
| {
type: 'submit'
}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
}
| {
type: 'xstate.done.actor.submitTransactions'
output: undefined
},
{
[x: string]:
| ActorRefFromLogic<
PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
>
| ActorRefFromLogic<
PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
>
| ActorRefFromLogic<
ObservableActorLogic<
WelcomeEvent | ReconnectEvent | MutationEvent,
{
listener: ReturnType<typeof createSharedListener>
id: string
},
EventObject
>
>
| undefined
getDocument?:
| ActorRefFromLogic<
PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
>
| undefined
submitTransactions?:
| ActorRefFromLogic<
PromiseActorLogic<
void,
{
client: SanityClient
transactions: Transaction[]
},
EventObject
>
>
| undefined
},
Values<{
'fetch remote snapshot': {
src: 'fetch remote snapshot'
logic: PromiseActorLogic<
void | SanityDocument<Record<string, any>> | undefined,
{
client: SanityClient
id: string
},
EventObject
>
id: 'getDocument'
}
'submit mutations as transactions': {
src: 'submit mutations as transa