@sanity/client 6.7.1-pink-lizard.4 → 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.
Files changed (65) hide show
  1. package/README.md +2 -79
  2. package/dist/index.browser.cjs +1868 -13
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +1858 -3
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.cjs +1888 -13
  7. package/dist/index.cjs.js +2 -2
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +1878 -3
  10. package/dist/index.js.map +1 -1
  11. package/package.json +8 -48
  12. package/src/config.ts +0 -6
  13. package/umd/sanityClient.js +1 -5
  14. package/umd/sanityClient.min.js +1 -1
  15. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js +0 -1862
  16. package/dist/_chunks/browserMiddleware-Oa7zKwEN.js.map +0 -1
  17. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs +0 -1877
  18. package/dist/_chunks/browserMiddleware-zle5A-pb.cjs.map +0 -1
  19. package/dist/_chunks/createEditLink-_BA4GZaY.cjs +0 -222
  20. package/dist/_chunks/createEditLink-_BA4GZaY.cjs.map +0 -1
  21. package/dist/_chunks/createEditLink-tWkBWOk4.js +0 -212
  22. package/dist/_chunks/createEditLink-tWkBWOk4.js.map +0 -1
  23. package/dist/_chunks/nodeMiddleware-_lHo6xcC.js +0 -1882
  24. package/dist/_chunks/nodeMiddleware-_lHo6xcC.js.map +0 -1
  25. package/dist/_chunks/nodeMiddleware-qVoQZE_z.cjs +0 -1897
  26. package/dist/_chunks/nodeMiddleware-qVoQZE_z.cjs.map +0 -1
  27. package/dist/csm.cjs +0 -71
  28. package/dist/csm.cjs.map +0 -1
  29. package/dist/csm.d.ts +0 -248
  30. package/dist/csm.js +0 -58
  31. package/dist/csm.js.map +0 -1
  32. package/dist/stega.browser.cjs +0 -629
  33. package/dist/stega.browser.cjs.map +0 -1
  34. package/dist/stega.browser.js +0 -598
  35. package/dist/stega.browser.js.map +0 -1
  36. package/dist/stega.cjs +0 -424
  37. package/dist/stega.cjs.js +0 -21
  38. package/dist/stega.cjs.map +0 -1
  39. package/dist/stega.d.ts +0 -2872
  40. package/dist/stega.js +0 -393
  41. package/dist/stega.js.map +0 -1
  42. package/src/csm/applySourceDocuments.test.ts +0 -820
  43. package/src/csm/applySourceDocuments.ts +0 -87
  44. package/src/csm/createEditLink.ts +0 -75
  45. package/src/csm/getPublishedId.ts +0 -12
  46. package/src/csm/index.ts +0 -9
  47. package/src/csm/isArray.ts +0 -3
  48. package/src/csm/isRecord.ts +0 -3
  49. package/src/csm/jsonpath.test.ts +0 -33
  50. package/src/csm/jsonpath.ts +0 -93
  51. package/src/csm/resolveMapping.ts +0 -41
  52. package/src/csm/resolvedKeyedSourcePath.ts +0 -23
  53. package/src/csm/simplifyPath.ts +0 -20
  54. package/src/csm/types.ts +0 -72
  55. package/src/csm/walkMap.ts +0 -30
  56. package/src/stega/SanityStegaClient.ts +0 -244
  57. package/src/stega/config.ts +0 -56
  58. package/src/stega/encodeIntoResult.test.ts +0 -268
  59. package/src/stega/encodeIntoResult.ts +0 -59
  60. package/src/stega/filterDefault.ts +0 -49
  61. package/src/stega/index.browser.ts +0 -19
  62. package/src/stega/index.ts +0 -19
  63. package/src/stega/shared.ts +0 -4
  64. package/src/stega/stegaEncodeSourceMap.ts +0 -128
  65. 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