Skip to content

Commit

Permalink
fix(core): remove id from patch when using server actions (#6751)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed May 23, 2024
1 parent cca14f3 commit 7b90cad
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dev/test-studio/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export default defineConfig([
basePath: '/test',
icon: SanityMonogram,
// eslint-disable-next-line camelcase
__internal_serverDocumentActions: {},
__internal_serverDocumentActions: {
enabled: true,
},
scheduledPublishing: {
enabled: true,
inputDateTimeFormat: 'MM/dd/yy h:mm a',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface HttpEditAction {
actionType: 'sanity.action.document.edit'
draftId: string
publishedId: string
patch: PatchMutation['patch']
patch: Omit<PatchMutation['patch'], 'id'>
}

export type HttpAction = HttpCreateAction | HttpDeleteAction | HttpEditAction
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ describe('checkoutPair -- server actions', () => {
draftId: 'draftId',
publishedId: 'publishedId',
patch: {
id: 'draftId',
set: {
title: 'new title',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {type SanityClient} from '@sanity/client'
import {type Mutation} from '@sanity/mutator'
import {type SanityDocument} from '@sanity/types'
import {omit} from 'lodash'
import {EMPTY, from, merge, type Observable, Subject} from 'rxjs'
import {filter, map, mergeMap, share, take, tap} from 'rxjs/operators'

Expand Down Expand Up @@ -121,7 +122,7 @@ function toActions(idPair: IdPair, mutationParams: Mutation['params']) {
actionType: 'sanity.action.document.edit',
draftId: idPair.draftId,
publishedId: idPair.publishedId,
patch: mutations.patch,
patch: omit(mutations.patch, 'id'),
}
}
throw new Error('Todo: implement')
Expand Down

0 comments on commit 7b90cad

Please sign in to comment.