@sanity/sdk 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-es/version.js +1 -1
- package/dist/index.d.ts +69 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +282 -52
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/_exports/index.ts +2 -0
- package/src/document/actions.ts +36 -0
- package/src/document/documentStore.concurrency.test.ts +1015 -0
- package/src/document/documentStore.test.ts +143 -1
- package/src/document/documentStore.ts +8 -1
- package/src/document/events.ts +32 -0
- package/src/document/listen.test.ts +56 -0
- package/src/document/listen.ts +73 -20
- package/src/document/listenerEventOperators.test.ts +311 -0
- package/src/document/listenerEventOperators.ts +217 -0
- package/src/document/patchOperations.test.ts +49 -2
- package/src/document/patchOperations.ts +50 -0
- package/src/document/processActions/edit.ts +26 -14
- package/src/document/processActions/shared.ts +165 -8
- package/src/document/processActions.test.ts +330 -1
- package/src/document/reducers.test.ts +519 -0
- package/src/document/reducers.ts +99 -3
- package/src/document/sharedListener.test.ts +2 -1
- package/src/document/sharedListener.ts +12 -1
|
@@ -49,7 +49,8 @@ describe('createSharedListener', () => {
|
|
|
49
49
|
'*',
|
|
50
50
|
{},
|
|
51
51
|
{
|
|
52
|
-
events: ['mutation', 'welcome', 'reconnect'],
|
|
52
|
+
events: ['mutation', 'welcome', 'welcomeback', 'reconnect', 'reset'],
|
|
53
|
+
enableResume: true,
|
|
53
54
|
includeResult: false,
|
|
54
55
|
includeAllVersions: true,
|
|
55
56
|
tag: 'document-listener',
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import {getClientState} from '../client/clientStore'
|
|
17
17
|
import {type DocumentResource} from '../config/sanityConfig'
|
|
18
18
|
import {type SanityInstance} from '../store/createSanityInstance'
|
|
19
|
+
import {dedupeListenerEvents, groupTransactionEvents} from './listenerEventOperators'
|
|
19
20
|
|
|
20
21
|
const API_VERSION = 'v2025-05-06'
|
|
21
22
|
|
|
@@ -41,7 +42,12 @@ export function createSharedListener(
|
|
|
41
42
|
'*',
|
|
42
43
|
{},
|
|
43
44
|
{
|
|
44
|
-
|
|
45
|
+
// with `enableResume`, a reconnect replays the events missed while
|
|
46
|
+
// offline (emitting `welcomeback`) instead of forcing a refetch of
|
|
47
|
+
// every subscribed document. when the backend cannot resume, it
|
|
48
|
+
// emits `welcome` or `reset`, both of which trigger a refetch
|
|
49
|
+
events: ['mutation', 'welcome', 'welcomeback', 'reconnect', 'reset'],
|
|
50
|
+
enableResume: true,
|
|
45
51
|
includeResult: false,
|
|
46
52
|
// the document store handles version documents, so we need to include all versions
|
|
47
53
|
includeAllVersions: true,
|
|
@@ -53,6 +59,11 @@ export function createSharedListener(
|
|
|
53
59
|
},
|
|
54
60
|
),
|
|
55
61
|
),
|
|
62
|
+
// resumed events are delivered at-least-once, so drop replayed duplicates
|
|
63
|
+
dedupeListenerEvents(),
|
|
64
|
+
// hold multi-document transactions (e.g. publish) until complete so
|
|
65
|
+
// per-document processing never observes half a transaction
|
|
66
|
+
groupTransactionEvents(),
|
|
56
67
|
takeUntil(dispose$),
|
|
57
68
|
share(),
|
|
58
69
|
)
|