Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): remove id from patch when using server actions #6751

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't aware we had turned it off, so turning it on again here

},
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
Loading