@sanity/sdk 2.4.0 → 2.6.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.
Files changed (57) hide show
  1. package/dist/index.d.ts +346 -110
  2. package/dist/index.js +428 -136
  3. package/dist/index.js.map +1 -1
  4. package/package.json +10 -9
  5. package/src/_exports/index.ts +15 -3
  6. package/src/auth/authStore.test.ts +13 -13
  7. package/src/auth/refreshStampedToken.test.ts +16 -16
  8. package/src/auth/subscribeToStateAndFetchCurrentUser.test.ts +6 -6
  9. package/src/auth/subscribeToStorageEventsAndSetToken.test.ts +4 -4
  10. package/src/client/clientStore.test.ts +45 -43
  11. package/src/client/clientStore.ts +23 -9
  12. package/src/comlink/controller/actions/destroyController.test.ts +2 -2
  13. package/src/comlink/controller/actions/getOrCreateChannel.test.ts +6 -6
  14. package/src/comlink/controller/actions/getOrCreateController.test.ts +5 -5
  15. package/src/comlink/controller/actions/getOrCreateController.ts +1 -1
  16. package/src/comlink/controller/actions/releaseChannel.test.ts +3 -2
  17. package/src/comlink/controller/comlinkControllerStore.test.ts +4 -4
  18. package/src/comlink/node/actions/getOrCreateNode.test.ts +7 -7
  19. package/src/comlink/node/actions/releaseNode.test.ts +2 -2
  20. package/src/comlink/node/comlinkNodeStore.test.ts +4 -3
  21. package/src/config/loggingConfig.ts +149 -0
  22. package/src/config/sanityConfig.ts +47 -23
  23. package/src/document/actions.ts +11 -7
  24. package/src/document/applyDocumentActions.test.ts +9 -6
  25. package/src/document/applyDocumentActions.ts +9 -49
  26. package/src/document/documentStore.test.ts +128 -115
  27. package/src/document/documentStore.ts +40 -10
  28. package/src/document/permissions.test.ts +9 -9
  29. package/src/document/permissions.ts +17 -7
  30. package/src/document/processActions.test.ts +248 -0
  31. package/src/document/processActions.ts +173 -0
  32. package/src/document/reducers.ts +13 -6
  33. package/src/presence/presenceStore.ts +13 -7
  34. package/src/preview/previewStore.test.ts +10 -2
  35. package/src/preview/previewStore.ts +2 -1
  36. package/src/preview/subscribeToStateAndFetchBatches.test.ts +8 -5
  37. package/src/preview/subscribeToStateAndFetchBatches.ts +9 -3
  38. package/src/projection/projectionStore.test.ts +18 -2
  39. package/src/projection/projectionStore.ts +2 -1
  40. package/src/projection/subscribeToStateAndFetchBatches.test.ts +6 -5
  41. package/src/projection/subscribeToStateAndFetchBatches.ts +9 -3
  42. package/src/query/queryStore.ts +3 -1
  43. package/src/releases/getPerspectiveState.ts +2 -2
  44. package/src/releases/releasesStore.ts +10 -4
  45. package/src/store/createActionBinder.test.ts +8 -6
  46. package/src/store/createActionBinder.ts +54 -28
  47. package/src/store/createSanityInstance.test.ts +85 -1
  48. package/src/store/createSanityInstance.ts +53 -4
  49. package/src/store/createStateSourceAction.test.ts +12 -11
  50. package/src/store/createStateSourceAction.ts +6 -6
  51. package/src/store/createStoreInstance.test.ts +29 -16
  52. package/src/store/createStoreInstance.ts +6 -5
  53. package/src/store/defineStore.test.ts +1 -1
  54. package/src/store/defineStore.ts +12 -7
  55. package/src/utils/logger-usage-example.md +141 -0
  56. package/src/utils/logger.test.ts +757 -0
  57. package/src/utils/logger.ts +537 -0
@@ -28,7 +28,11 @@ import {
28
28
 
29
29
  import {getClientState} from '../client/clientStore'
30
30
  import {type DocumentHandle} from '../config/sanityConfig'
31
- import {bindActionByDataset, type StoreAction} from '../store/createActionBinder'
31
+ import {
32
+ bindActionByDataset,
33
+ type BoundDatasetKey,
34
+ type StoreAction,
35
+ } from '../store/createActionBinder'
32
36
  import {type SanityInstance} from '../store/createSanityInstance'
33
37
  import {createStateSourceAction, type StateSource} from '../store/createStateSourceAction'
34
38
  import {defineStore, type StoreContext} from '../store/defineStore'
@@ -103,7 +107,7 @@ export interface DocumentState {
103
107
  unverifiedRevisions?: {[TTransactionId in string]?: UnverifiedDocumentRevision}
104
108
  }
105
109
 
106
- export const documentStore = defineStore<DocumentStoreState>({
110
+ export const documentStore = defineStore<DocumentStoreState, BoundDatasetKey>({
107
111
  name: 'Document',
108
112
  getInitialState: (instance) => ({
109
113
  documentStates: {},
@@ -183,8 +187,21 @@ const _getDocumentState = bindActionByDataset(
183
187
  documentStore,
184
188
  createStateSourceAction({
185
189
  selector: ({state: {error, documentStates}}, options: DocumentOptions<string | undefined>) => {
186
- const {documentId, path} = options
190
+ const {documentId, path, liveEdit} = options
187
191
  if (error) throw error
192
+
193
+ if (liveEdit) {
194
+ // For liveEdit documents, only look at the single document
195
+ const document = documentStates[documentId]?.local
196
+ if (document === undefined) return undefined
197
+ if (!path) return document
198
+ const result = jsonMatch(document, path).next()
199
+ if (result.done) return undefined
200
+ const {value} = result.value
201
+ return value
202
+ }
203
+
204
+ // Standard draft/published logic
188
205
  const draftId = getDraftId(documentId)
189
206
  const publishedId = getPublishedId(documentId)
190
207
  const draft = documentStates[draftId]?.local
@@ -200,7 +217,7 @@ const _getDocumentState = bindActionByDataset(
200
217
  return value
201
218
  },
202
219
  onSubscribe: (context, options: DocumentOptions<string | undefined>) =>
203
- manageSubscriberIds(context, options.documentId),
220
+ manageSubscriberIds(context, options.documentId, {expandDraftPublished: !options.liveEdit}),
204
221
  }),
205
222
  )
206
223
 
@@ -246,6 +263,15 @@ export const getDocumentSyncStatus = bindActionByDataset(
246
263
  ) => {
247
264
  const documentId = typeof doc === 'string' ? doc : doc.documentId
248
265
  if (error) throw error
266
+
267
+ if (doc.liveEdit) {
268
+ // For liveEdit documents, only check the single document
269
+ const document = documents[documentId]
270
+ if (document === undefined) return undefined
271
+ return !queued.length && !applied.length && !outgoing
272
+ }
273
+
274
+ // Standard draft/published logic
249
275
  const draftId = getDraftId(documentId)
250
276
  const publishedId = getPublishedId(documentId)
251
277
 
@@ -259,16 +285,20 @@ export const getDocumentSyncStatus = bindActionByDataset(
259
285
  }),
260
286
  )
261
287
 
288
+ type PermissionsStateOptions = {
289
+ actions: DocumentAction[]
290
+ }
291
+
262
292
  /** @beta */
263
293
  export const getPermissionsState = bindActionByDataset(
264
294
  documentStore,
265
295
  createStateSourceAction({
266
296
  selector: calculatePermissions,
267
- onSubscribe: (context, actions) =>
297
+ onSubscribe: (context, {actions}: PermissionsStateOptions) =>
268
298
  manageSubscriberIds(context, getDocumentIdsFromActions(actions)),
269
299
  }) as StoreAction<
270
300
  DocumentStoreState,
271
- [DocumentAction | DocumentAction[]],
301
+ [PermissionsStateOptions],
272
302
  StateSource<ReturnType<typeof calculatePermissions>>
273
303
  >,
274
304
  )
@@ -276,9 +306,9 @@ export const getPermissionsState = bindActionByDataset(
276
306
  /** @beta */
277
307
  export const resolvePermissions = bindActionByDataset(
278
308
  documentStore,
279
- ({instance}, actions: DocumentAction | DocumentAction[]) => {
309
+ ({instance}, options: PermissionsStateOptions) => {
280
310
  return firstValueFrom(
281
- getPermissionsState(instance, actions).observable.pipe(filter((i) => i !== undefined)),
311
+ getPermissionsState(instance, options).observable.pipe(filter((i) => i !== undefined)),
282
312
  )
283
313
  },
284
314
  )
@@ -439,8 +469,8 @@ const subscribeToSubscriptionsAndListenToDocuments = (
439
469
  const subscribeToClientAndFetchDatasetAcl = ({
440
470
  instance,
441
471
  state,
442
- }: StoreContext<DocumentStoreState>) => {
443
- const {projectId, dataset} = instance.config
472
+ key: {projectId, dataset},
473
+ }: StoreContext<DocumentStoreState, BoundDatasetKey>) => {
444
474
  return getClientState(instance, {apiVersion: API_VERSION})
445
475
  .observable.pipe(
446
476
  switchMap((client) =>
@@ -75,7 +75,7 @@ describe('calculatePermissions', () => {
75
75
  const actions: DocumentAction[] = [
76
76
  {documentId: 'doc1', type: 'document.create', documentType: 'article'},
77
77
  ]
78
- const result = calculatePermissions({instance, state}, actions)
78
+ const result = calculatePermissions({instance, state}, {actions})
79
79
  expect(result).toEqual({allowed: true})
80
80
  })
81
81
 
@@ -91,7 +91,7 @@ describe('calculatePermissions', () => {
91
91
  const actions: DocumentAction[] = [
92
92
  {documentId: 'doc1', type: 'document.create', documentType: 'article'},
93
93
  ]
94
- expect(calculatePermissions({instance, state}, actions)).toBeUndefined()
94
+ expect(calculatePermissions({instance, state}, {actions})).toBeUndefined()
95
95
  })
96
96
 
97
97
  it('should catch PermissionActionError from processActions and return allowed false with a reason', () => {
@@ -107,7 +107,7 @@ describe('calculatePermissions', () => {
107
107
  const actions: DocumentAction[] = [
108
108
  {documentId: 'doc1', type: 'document.create', documentType: 'article'},
109
109
  ]
110
- const result = calculatePermissions({instance, state}, actions)
110
+ const result = calculatePermissions({instance, state}, {actions})
111
111
  expect(result).toBeDefined()
112
112
  expect(result?.allowed).toBe(false)
113
113
  expect(result?.reasons).toEqual(
@@ -135,7 +135,7 @@ describe('calculatePermissions', () => {
135
135
  const actions: DocumentAction[] = [
136
136
  {documentId: 'doc1', documentType: 'book', type: 'document.edit'},
137
137
  ]
138
- const result = calculatePermissions({instance, state}, actions)
138
+ const result = calculatePermissions({instance, state}, {actions})
139
139
  expect(result).toBeDefined()
140
140
  expect(result?.allowed).toBe(false)
141
141
  expect(result?.reasons).toEqual(
@@ -161,7 +161,7 @@ describe('calculatePermissions', () => {
161
161
  const actions: DocumentAction[] = [
162
162
  {documentId: 'doc1', documentType: 'book', type: 'document.edit'},
163
163
  ]
164
- const result = calculatePermissions({instance, state}, actions)
164
+ const result = calculatePermissions({instance, state}, {actions})
165
165
  expect(result).toBeDefined()
166
166
  expect(result?.allowed).toBe(false)
167
167
  expect(result?.reasons).toEqual(
@@ -185,7 +185,7 @@ describe('calculatePermissions', () => {
185
185
  const actions: DocumentAction[] = [
186
186
  {documentId: 'doc1', type: 'document.create', documentType: 'article'},
187
187
  ]
188
- expect(calculatePermissions({instance, state}, actions)).toBeUndefined()
188
+ expect(calculatePermissions({instance, state}, {actions})).toBeUndefined()
189
189
  })
190
190
 
191
191
  it('should catch ActionError from processActions and return a precondition error reason', () => {
@@ -200,7 +200,7 @@ describe('calculatePermissions', () => {
200
200
  const actions: DocumentAction[] = [
201
201
  {documentId: 'doc1', documentType: 'book', type: 'document.delete'},
202
202
  ]
203
- const result = calculatePermissions({instance, state}, actions)
203
+ const result = calculatePermissions({instance, state}, {actions})
204
204
  expect(result).toBeDefined()
205
205
  expect(result?.allowed).toBe(false)
206
206
  expect(result?.reasons).toEqual(
@@ -228,8 +228,8 @@ describe('calculatePermissions', () => {
228
228
  documentType: 'article',
229
229
  }
230
230
  // notice how the action is a copy
231
- const result1 = calculatePermissions({instance, state}, [{...action}])
232
- const result2 = calculatePermissions({instance, state}, [{...action}])
231
+ const result1 = calculatePermissions({instance, state}, {actions: [{...action}]})
232
+ const result2 = calculatePermissions({instance, state}, {actions: [{...action}]})
233
233
  expect(result1).toBe(result2)
234
234
  })
235
235
  })
@@ -58,15 +58,22 @@ const nullReplacer: object = {}
58
58
  const documentsSelector = createSelector(
59
59
  [
60
60
  ({state: {documentStates}}: SelectorContext<SyncTransactionState>) => documentStates,
61
- (_context: SelectorContext<SyncTransactionState>, actions: DocumentAction | DocumentAction[]) =>
61
+ (_context: SelectorContext<SyncTransactionState>, {actions}: {actions: DocumentAction[]}) =>
62
62
  actions,
63
63
  ],
64
64
  (documentStates, actions) => {
65
+ // Collect all document IDs needed for permission checks.
66
+ // Important: liveEdit documents don't have drafts, so we only fetch the single document to avoid waiting for non-existent draft documents.
65
67
  const documentIds = new Set(
66
- (Array.isArray(actions) ? actions : [actions])
67
- .map((i) => i.documentId)
68
- .filter((i) => typeof i === 'string')
69
- .flatMap((documentId) => [getPublishedId(documentId), getDraftId(documentId)]),
68
+ actions
69
+ .map((action) => {
70
+ if (typeof action.documentId !== 'string') return []
71
+ // For liveEdit documents, only fetch the single document
72
+ if (action.liveEdit) return [action.documentId]
73
+ // For standard documents, fetch both draft and published
74
+ return [getPublishedId(action.documentId), getDraftId(action.documentId)]
75
+ })
76
+ .flat(),
70
77
  )
71
78
 
72
79
  const documents: DocumentSet = {}
@@ -99,7 +106,7 @@ const documentsSelector = createSelector(
99
106
  const memoizedActionsSelector = createSelector(
100
107
  [
101
108
  documentsSelector,
102
- (_state: SelectorContext<SyncTransactionState>, actions: DocumentAction | DocumentAction[]) =>
109
+ (_state: SelectorContext<SyncTransactionState>, {actions}: {actions: DocumentAction[]}) =>
103
110
  actions,
104
111
  ],
105
112
  (documents, actions) => {
@@ -203,7 +210,10 @@ const _calculatePermissions = createSelector(
203
210
  // Check edit actions with no patches
204
211
  if (action.type === 'document.edit' && !action.patches?.length) {
205
212
  const docId = action.documentId
206
- const doc = documents[getDraftId(docId)] ?? documents[getPublishedId(docId)]
213
+ // For liveEdit documents, only check the single document
214
+ const doc = action.liveEdit
215
+ ? documents[docId]
216
+ : (documents[getDraftId(docId)] ?? documents[getPublishedId(docId)])
207
217
  if (!doc) {
208
218
  reasons.push({
209
219
  type: 'precondition',
@@ -29,6 +29,16 @@ const defaultGrants = {
29
29
  const transactionId = 'txn-123'
30
30
  const timestamp = '2025-02-02T00:00:00.000Z'
31
31
 
32
+ // Helper: Create a sample liveEdit document
33
+ const createLiveEditDoc = (id: string, title: string, rev: string = 'initial'): SanityDocument => ({
34
+ _id: id,
35
+ _type: 'liveArticle',
36
+ _createdAt: '2025-01-01T00:00:00.000Z',
37
+ _updatedAt: '2025-01-01T00:00:00.000Z',
38
+ _rev: rev,
39
+ title,
40
+ })
41
+
32
42
  describe('processActions', () => {
33
43
  describe('document.create', () => {
34
44
  it('should create a new draft document from a published document', () => {
@@ -845,4 +855,242 @@ describe('processActions', () => {
845
855
  ).toThrow(/Unknown action type: "document.unrecognizedAction"/)
846
856
  })
847
857
  })
858
+
859
+ describe('liveEdit documents', () => {
860
+ describe('document.create', () => {
861
+ it('should create a liveEdit document directly without draft logic', () => {
862
+ const base: DocumentSet = {}
863
+ const working: DocumentSet = {}
864
+ const actions: DocumentAction[] = [
865
+ {
866
+ documentId: 'live1',
867
+ type: 'document.create',
868
+ documentType: 'liveArticle',
869
+ liveEdit: true,
870
+ },
871
+ ]
872
+
873
+ const result = processActions({
874
+ actions,
875
+ transactionId,
876
+ base,
877
+ working,
878
+ timestamp,
879
+ grants: defaultGrants,
880
+ })
881
+
882
+ const doc = result.working['live1']
883
+ expect(doc).toBeDefined()
884
+ expect(doc?._id).toBe('live1')
885
+ expect(doc?._type).toBe('liveArticle')
886
+ expect(doc?._rev).toBe(transactionId)
887
+
888
+ // Should use document.create action, not version.create
889
+ expect(result.outgoingActions).toHaveLength(1)
890
+ const action = result.outgoingActions[0]
891
+ expect(action.actionType).toBe('sanity.action.document.create')
892
+ if ('attributes' in action && 'publishedId' in action) {
893
+ expect(action.publishedId).toBe('live1')
894
+ expect(action.attributes._id).toBe('live1')
895
+ expect(action.attributes._type).toBe('liveArticle')
896
+ } else {
897
+ throw new Error('Expected action to have attributes and publishedId')
898
+ }
899
+ })
900
+
901
+ it('should throw an error if liveEdit document already exists', () => {
902
+ const existingDoc = createLiveEditDoc('live1', 'Existing')
903
+ const base: DocumentSet = {live1: existingDoc}
904
+ const working: DocumentSet = {live1: existingDoc}
905
+ const actions: DocumentAction[] = [
906
+ {
907
+ documentId: 'live1',
908
+ type: 'document.create',
909
+ documentType: 'liveArticle',
910
+ liveEdit: true,
911
+ },
912
+ ]
913
+
914
+ expect(() =>
915
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
916
+ ).toThrow('This document already exists')
917
+ })
918
+ })
919
+
920
+ describe('document.edit', () => {
921
+ it('should edit a liveEdit document directly', () => {
922
+ const doc = createLiveEditDoc('live1', 'Original Title')
923
+ const base: DocumentSet = {live1: doc}
924
+ const working: DocumentSet = {live1: doc}
925
+ const actions: DocumentAction[] = [
926
+ {
927
+ documentId: 'live1',
928
+ type: 'document.edit',
929
+ documentType: 'liveArticle',
930
+ liveEdit: true,
931
+ patches: [{set: {title: 'Updated Title'}}],
932
+ },
933
+ ]
934
+
935
+ const result = processActions({
936
+ actions,
937
+ transactionId,
938
+ base,
939
+ working,
940
+ timestamp,
941
+ grants: defaultGrants,
942
+ })
943
+
944
+ const editedDoc = result.working['live1']
945
+ expect(editedDoc).toBeDefined()
946
+ expect(editedDoc?.['title']).toBe('Updated Title')
947
+ expect(editedDoc?._id).toBe('live1')
948
+
949
+ // Should use document.edit action with draftId prefixed (for server validation) but publishedId as the actual doc
950
+ expect(result.outgoingActions[0]).toMatchObject({
951
+ actionType: 'sanity.action.document.edit',
952
+ draftId: 'drafts.live1',
953
+ publishedId: 'live1',
954
+ })
955
+ })
956
+
957
+ it('should throw an error if liveEdit document does not exist', () => {
958
+ const base: DocumentSet = {}
959
+ const working: DocumentSet = {}
960
+ const actions: DocumentAction[] = [
961
+ {
962
+ documentId: 'live1',
963
+ type: 'document.edit',
964
+ documentType: 'liveArticle',
965
+ liveEdit: true,
966
+ patches: [{set: {title: 'New Title'}}],
967
+ },
968
+ ]
969
+
970
+ expect(() =>
971
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
972
+ ).toThrow('Cannot edit document because it does not exist')
973
+ })
974
+ })
975
+
976
+ describe('document.delete', () => {
977
+ it('should delete a liveEdit document directly', () => {
978
+ const doc = createLiveEditDoc('live1', 'To Delete')
979
+ const base: DocumentSet = {live1: doc}
980
+ const working: DocumentSet = {live1: doc}
981
+ const actions: DocumentAction[] = [
982
+ {
983
+ documentId: 'live1',
984
+ type: 'document.delete',
985
+ documentType: 'liveArticle',
986
+ liveEdit: true,
987
+ },
988
+ ]
989
+
990
+ const result = processActions({
991
+ actions,
992
+ transactionId,
993
+ base,
994
+ working,
995
+ timestamp,
996
+ grants: defaultGrants,
997
+ })
998
+
999
+ expect(result.working['live1']).toBeNull()
1000
+
1001
+ expect(result.outgoingActions).toEqual([
1002
+ {
1003
+ actionType: 'sanity.action.document.delete',
1004
+ publishedId: 'live1',
1005
+ },
1006
+ ])
1007
+ })
1008
+
1009
+ it('should throw an error if liveEdit document does not exist', () => {
1010
+ const base: DocumentSet = {}
1011
+ const working: DocumentSet = {}
1012
+ const actions: DocumentAction[] = [
1013
+ {
1014
+ documentId: 'live1',
1015
+ type: 'document.delete',
1016
+ documentType: 'liveArticle',
1017
+ liveEdit: true,
1018
+ },
1019
+ ]
1020
+
1021
+ expect(() =>
1022
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1023
+ ).toThrow('The document you are trying to delete does not exist')
1024
+ })
1025
+ })
1026
+
1027
+ describe('document.publish', () => {
1028
+ it('should throw an error for liveEdit documents', () => {
1029
+ const doc = createLiveEditDoc('live1', 'Title')
1030
+ const base: DocumentSet = {live1: doc}
1031
+ const working: DocumentSet = {live1: doc}
1032
+ const actions: DocumentAction[] = [
1033
+ {
1034
+ documentId: 'live1',
1035
+ type: 'document.publish',
1036
+ documentType: 'liveArticle',
1037
+ liveEdit: true,
1038
+ },
1039
+ ]
1040
+
1041
+ expect(() =>
1042
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1043
+ ).toThrow('Cannot publish liveEdit document')
1044
+ expect(() =>
1045
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1046
+ ).toThrow('LiveEdit documents do not support drafts or publishing')
1047
+ })
1048
+ })
1049
+
1050
+ describe('document.unpublish', () => {
1051
+ it('should throw an error for liveEdit documents', () => {
1052
+ const doc = createLiveEditDoc('live1', 'Title')
1053
+ const base: DocumentSet = {live1: doc}
1054
+ const working: DocumentSet = {live1: doc}
1055
+ const actions: DocumentAction[] = [
1056
+ {
1057
+ documentId: 'live1',
1058
+ type: 'document.unpublish',
1059
+ documentType: 'liveArticle',
1060
+ liveEdit: true,
1061
+ },
1062
+ ]
1063
+
1064
+ expect(() =>
1065
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1066
+ ).toThrow('Cannot unpublish liveEdit document')
1067
+ expect(() =>
1068
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1069
+ ).toThrow('LiveEdit documents do not support drafts or publishing')
1070
+ })
1071
+ })
1072
+
1073
+ describe('document.discard', () => {
1074
+ it('should throw an error for liveEdit documents', () => {
1075
+ const doc = createLiveEditDoc('live1', 'Title')
1076
+ const base: DocumentSet = {live1: doc}
1077
+ const working: DocumentSet = {live1: doc}
1078
+ const actions: DocumentAction[] = [
1079
+ {
1080
+ documentId: 'live1',
1081
+ type: 'document.discard',
1082
+ documentType: 'liveArticle',
1083
+ liveEdit: true,
1084
+ },
1085
+ ]
1086
+
1087
+ expect(() =>
1088
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1089
+ ).toThrow('Cannot discard changes for liveEdit document')
1090
+ expect(() =>
1091
+ processActions({actions, transactionId, base, working, timestamp, grants: defaultGrants}),
1092
+ ).toThrow('LiveEdit documents do not support drafts')
1093
+ })
1094
+ })
1095
+ })
848
1096
  })