@sanity/client 6.7.1-pink-lizard.5 → 6.7.1
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/README.md +2 -79
- package/dist/index.browser.cjs +1868 -13
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1858 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1888 -13
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1878 -3
- package/dist/index.js.map +1 -1
- package/package.json +8 -48
- package/src/config.ts +0 -6
- package/umd/sanityClient.js +1 -5
- package/umd/sanityClient.min.js +1 -1
- package/dist/_chunks/browserMiddleware-Oa7zKwEN.js +0 -1862
- package/dist/_chunks/browserMiddleware-Oa7zKwEN.js.map +0 -1
- package/dist/_chunks/browserMiddleware-zle5A-pb.cjs +0 -1877
- package/dist/_chunks/browserMiddleware-zle5A-pb.cjs.map +0 -1
- package/dist/_chunks/createEditLink-FiifjNgi.cjs +0 -222
- package/dist/_chunks/createEditLink-FiifjNgi.cjs.map +0 -1
- package/dist/_chunks/createEditLink-f3l2nngi.js +0 -212
- package/dist/_chunks/createEditLink-f3l2nngi.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-wK08wpEf.js +0 -1882
- package/dist/_chunks/nodeMiddleware-wK08wpEf.js.map +0 -1
- package/dist/_chunks/nodeMiddleware-yNosyZrr.cjs +0 -1897
- package/dist/_chunks/nodeMiddleware-yNosyZrr.cjs.map +0 -1
- package/dist/csm.cjs +0 -71
- package/dist/csm.cjs.map +0 -1
- package/dist/csm.d.ts +0 -248
- package/dist/csm.js +0 -58
- package/dist/csm.js.map +0 -1
- package/dist/stega.browser.cjs +0 -629
- package/dist/stega.browser.cjs.map +0 -1
- package/dist/stega.browser.js +0 -598
- package/dist/stega.browser.js.map +0 -1
- package/dist/stega.cjs +0 -424
- package/dist/stega.cjs.js +0 -21
- package/dist/stega.cjs.map +0 -1
- package/dist/stega.d.ts +0 -2872
- package/dist/stega.js +0 -393
- package/dist/stega.js.map +0 -1
- package/src/csm/applySourceDocuments.test.ts +0 -820
- package/src/csm/applySourceDocuments.ts +0 -87
- package/src/csm/createEditLink.ts +0 -75
- package/src/csm/getPublishedId.ts +0 -12
- package/src/csm/index.ts +0 -9
- package/src/csm/isArray.ts +0 -3
- package/src/csm/isRecord.ts +0 -3
- package/src/csm/jsonpath.test.ts +0 -33
- package/src/csm/jsonpath.ts +0 -93
- package/src/csm/resolveMapping.ts +0 -41
- package/src/csm/resolvedKeyedSourcePath.ts +0 -23
- package/src/csm/simplifyPath.ts +0 -20
- package/src/csm/types.ts +0 -72
- package/src/csm/walkMap.ts +0 -30
- package/src/stega/SanityStegaClient.ts +0 -244
- package/src/stega/config.ts +0 -56
- package/src/stega/encodeIntoResult.test.ts +0 -268
- package/src/stega/encodeIntoResult.ts +0 -59
- package/src/stega/filterDefault.ts +0 -49
- package/src/stega/index.browser.ts +0 -19
- package/src/stega/index.ts +0 -19
- package/src/stega/shared.ts +0 -4
- package/src/stega/stegaEncodeSourceMap.ts +0 -128
- package/src/stega/types.ts +0 -139
package/README.md
CHANGED
|
@@ -610,6 +610,8 @@ Content Source Maps annotate fragments in your query results with metadata about
|
|
|
610
610
|
>
|
|
611
611
|
> [Content Source Maps][content-source-maps-intro] are available [as an API][content-source-maps] for select [Sanity enterprise customers][enterprise-cta]. [Contact our sales team for more information.][sales-cta]
|
|
612
612
|
|
|
613
|
+
A high level API using Content Source Maps for [Visual editing][visual-editing] is also available in [`@sanity/preview-kit/client`][preview-kit-client]. It offers both a turn-key solution and a flexible API for custom experiences.
|
|
614
|
+
|
|
613
615
|
Read the [Content Source Maps introduction][content-source-maps-intro] before diving in, and keep the [Content Source Maps reference][content-source-maps] handy.
|
|
614
616
|
|
|
615
617
|
Enabling Content Source Maps is a two-step process:
|
|
@@ -654,85 +656,6 @@ function useContentSourceMap(resultSourceMap: ContentSourceMapping): unknown {
|
|
|
654
656
|
useContentSourceMap(resultSourceMap)
|
|
655
657
|
```
|
|
656
658
|
|
|
657
|
-
#### Creating Studio edit intent links
|
|
658
|
-
|
|
659
|
-
```ts
|
|
660
|
-
import {createEditLink} from '@sanity/client/csm'
|
|
661
|
-
|
|
662
|
-
const editLink = createEditLink({
|
|
663
|
-
studioUrl: (sourceDocument: ContentSourceMapDocuments[number], sourcePath: PathSegment[]) =>
|
|
664
|
-
StudioUrl,
|
|
665
|
-
resultSourceMap: ContentSourceMapping,
|
|
666
|
-
resultPath: StudioPath,
|
|
667
|
-
})
|
|
668
|
-
```
|
|
669
|
-
|
|
670
|
-
In general, fetch a single post
|
|
671
|
-
|
|
672
|
-
With arrays, and keyed array items.
|
|
673
|
-
|
|
674
|
-
#### Using [Visual editing][visual-editing] with steganography
|
|
675
|
-
|
|
676
|
-
A turnkey integration with [Visual editing][visual-editing] is available in [`@sanity/client/stega`]. It creates edit intent links for all the string values in your query result, using [steganography](https://npmjs.com/package/@vercel/stega) under the hood.
|
|
677
|
-
|
|
678
|
-
```ts
|
|
679
|
-
import {createClient} from '@sanity/client/stega'
|
|
680
|
-
|
|
681
|
-
const client = createClient({
|
|
682
|
-
// ...base config options
|
|
683
|
-
stega: {
|
|
684
|
-
// Required: for encoded metadata from Content Source Maps
|
|
685
|
-
enabled: process.env.VERCEL_ENV !== 'production',
|
|
686
|
-
// Required: when "enabled" is true
|
|
687
|
-
// Set it to relative or absolute URL of your Sanity Studio
|
|
688
|
-
studioUrl: '/studio', // or 'https://your-project-name.sanity.studio'
|
|
689
|
-
studioUrl: (sourceDocument: {_id, _type, _projectId, _dataset}) => select workspace if cross dataset reference
|
|
690
|
-
|
|
691
|
-
// Optional, control what fields have stega payloads
|
|
692
|
-
filter: (props) => {
|
|
693
|
-
// {"name": title}
|
|
694
|
-
const {resultPath, sourcePath, resultPath} = props
|
|
695
|
-
if (props.sourcePath[0] === 'externalurl') {
|
|
696
|
-
return false
|
|
697
|
-
}
|
|
698
|
-
// The default behavior is packaged into `filterDefault`, allowing you enable encoding fields that are skipped by default
|
|
699
|
-
return props.filterDefault(props)
|
|
700
|
-
},
|
|
701
|
-
|
|
702
|
-
// Optional, logs what's encoded and what isn't
|
|
703
|
-
logger: console,
|
|
704
|
-
},
|
|
705
|
-
})
|
|
706
|
-
|
|
707
|
-
// Disable on demand
|
|
708
|
-
client.config({stega: {enabled: false}})
|
|
709
|
-
|
|
710
|
-
// New client with different stega settings
|
|
711
|
-
const debugClient = client.withConfig({
|
|
712
|
-
stega: {studioUrl: 'https://your-project-name.sanity.studio'},
|
|
713
|
-
})
|
|
714
|
-
|
|
715
|
-
import {createQueryStore} from '@sanity/react-loader'
|
|
716
|
-
import {createClient} from '@sanity/client/stega'
|
|
717
|
-
|
|
718
|
-
const studioUrl = '/studio'
|
|
719
|
-
|
|
720
|
-
const client = createClient({
|
|
721
|
-
projectId,
|
|
722
|
-
dataset,
|
|
723
|
-
useCdn: true,
|
|
724
|
-
apiVersion: '2023-11-01',
|
|
725
|
-
stega: {
|
|
726
|
-
studioUrl,
|
|
727
|
-
}
|
|
728
|
-
})
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
const {useQuery, useLiveMode} = createQueryStore({client, studioUrl})
|
|
732
|
-
|
|
733
|
-
useLiveMode({client: client.withConfig({stega: {enabled: true}})})
|
|
734
|
-
```
|
|
735
|
-
|
|
736
659
|
### Listening to queries
|
|
737
660
|
|
|
738
661
|
```js
|