sanity-plugin-markdown 8.0.3 → 8.0.4-canary.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function")
9
+ for (let key of __getOwnPropNames(from))
10
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ return to;
12
+ };
13
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
14
+ // If the importer is in node compatibility mode or this is not an ESM
15
+ // file that has been converted to a CommonJS file using a Babel-
16
+ // compatible transform (i.e. "__esModule" has not been set), then set
17
+ // "default" to the CommonJS "module.exports" for node compatibility.
18
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
19
+ mod
20
+ ));
21
+ Object.defineProperty(exports, "__esModule", { value: !0 });
22
+ require("easymde/dist/easymde.min.css");
23
+ var sanity = require("sanity"), jsxRuntime = require("react/jsx-runtime"), compilerRuntime = require("react/compiler-runtime"), ui = require("@sanity/ui"), react = require("react"), styledComponents = require("styled-components");
24
+ const SimpleMdeReact = react.lazy(() => import("react-simplemde-editor")), MarkdownInputStyles = styledComponents.styled(ui.Box).withConfig({
25
+ displayName: "MarkdownInputStyles",
26
+ componentId: "sc-syau23-0"
27
+ })`& .CodeMirror.CodeMirror{color:${({
28
+ theme
29
+ }) => theme.sanity.color.card.enabled.fg};border-color:${({
30
+ theme
31
+ }) => theme.sanity.color.card.enabled.border};background-color:inherit;}& .cm-s-easymde .CodeMirror-cursor{border-color:${({
32
+ theme
33
+ }) => theme.sanity.color.card.enabled.fg};}& .editor-toolbar,.editor-preview-side{border-color:${({
34
+ theme
35
+ }) => theme.sanity.color.card.enabled.border};}& .CodeMirror-focused .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected{background-color:${({
36
+ theme
37
+ }) => theme.sanity.color.selectable?.primary?.hovered?.bg};}& .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected{background-color:${({
38
+ theme
39
+ }) => theme.sanity.color.card.enabled.bg};}& .editor-toolbar > *{color:${({
40
+ theme
41
+ }) => theme.sanity.color.card.enabled.fg};}& .editor-toolbar > .active,.editor-toolbar > button:hover,.editor-preview pre,.cm-s-easymde .cm-comment{background-color:${({
42
+ theme
43
+ }) => theme.sanity.color.card.enabled.bg};}& .editor-preview{background-color:${({
44
+ theme
45
+ }) => theme.sanity.color.card.enabled.bg};& h1,h2,h3,h4,h5,h6{font-size:revert;}& ul,li{list-style:revert;padding:revert;}& a{text-decoration:revert;}}`, defaultMdeTools = ["heading", "bold", "italic", "|", "quote", "unordered-list", "ordered-list", "|", "link", "image", "code", "|", "preview", "side-by-side"];
46
+ function MarkdownInput(props) {
47
+ const $ = compilerRuntime.c(29), {
48
+ value: t0,
49
+ onChange,
50
+ elementProps: t1,
51
+ reactMdeProps: t2,
52
+ schemaType,
53
+ focused
54
+ } = props, value = t0 === void 0 ? "" : t0, {
55
+ onBlur,
56
+ onFocus,
57
+ ref: elementRef
58
+ } = t1;
59
+ let t3;
60
+ $[0] !== t2 ? (t3 = t2 === void 0 ? {} : t2, $[0] = t2, $[1] = t3) : t3 = $[1];
61
+ let mdeCustomOptions, reactMdeProps;
62
+ $[2] !== t3 ? ({
63
+ options: mdeCustomOptions,
64
+ ...reactMdeProps
65
+ } = t3, $[2] = t3, $[3] = mdeCustomOptions, $[4] = reactMdeProps) : (mdeCustomOptions = $[3], reactMdeProps = $[4]);
66
+ let t4;
67
+ $[5] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = {
68
+ apiVersion: "2022-01-01"
69
+ }, $[5] = t4) : t4 = $[5];
70
+ const client = sanity.useClient(t4);
71
+ let t5;
72
+ $[6] !== schemaType.options ? (t5 = schemaType.options ?? {}, $[6] = schemaType.options, $[7] = t5) : t5 = $[7];
73
+ const {
74
+ imageUrl
75
+ } = t5, [shouldAutoFocus, setShouldAutoFocus] = react.useState(!1), ref = react.useRef(null);
76
+ let t6;
77
+ $[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = () => ref.current, $[8] = t6) : t6 = $[8], react.useImperativeHandle(elementRef, t6);
78
+ let t7;
79
+ $[9] !== client || $[10] !== imageUrl ? (t7 = (file, onSuccess, onError) => {
80
+ client.assets.upload("image", file).then((doc) => onSuccess(imageUrl ? imageUrl(doc) : `${doc.url}?w=450`)).catch((e) => {
81
+ console.error(e), onError(e.message);
82
+ });
83
+ }, $[9] = client, $[10] = imageUrl, $[11] = t7) : t7 = $[11];
84
+ const imageUpload = t7;
85
+ let t8;
86
+ $[12] !== imageUpload || $[13] !== mdeCustomOptions || $[14] !== shouldAutoFocus ? (t8 = {
87
+ spellChecker: !1,
88
+ sideBySideFullscreen: !1,
89
+ uploadImage: !0,
90
+ imageUploadFunction: imageUpload,
91
+ toolbar: defaultMdeTools,
92
+ status: !1,
93
+ ...mdeCustomOptions,
94
+ autofocus: shouldAutoFocus
95
+ }, $[12] = imageUpload, $[13] = mdeCustomOptions, $[14] = shouldAutoFocus, $[15] = t8) : t8 = $[15];
96
+ const mdeOptions = t8;
97
+ let t10, t9;
98
+ $[16] !== focused || $[17] !== shouldAutoFocus ? (t9 = () => {
99
+ const node = ref.current;
100
+ if (node) {
101
+ if (focused && !shouldAutoFocus) {
102
+ const raf = requestAnimationFrame(() => setShouldAutoFocus(!node.contains(document.activeElement)));
103
+ return () => cancelAnimationFrame(raf);
104
+ }
105
+ if (!focused && shouldAutoFocus) {
106
+ const raf_0 = requestAnimationFrame(() => setShouldAutoFocus(node.contains(document.activeElement)));
107
+ return () => cancelAnimationFrame(raf_0);
108
+ }
109
+ }
110
+ }, t10 = [focused, shouldAutoFocus], $[16] = focused, $[17] = shouldAutoFocus, $[18] = t10, $[19] = t9) : (t10 = $[18], t9 = $[19]), react.useEffect(t9, t10);
111
+ let t11;
112
+ $[20] !== onChange ? (t11 = (newValue) => {
113
+ onChange(sanity.PatchEvent.from(newValue ? sanity.set(newValue) : sanity.unset()));
114
+ }, $[20] = onChange, $[21] = t11) : t11 = $[21];
115
+ const handleChange = t11;
116
+ let t12;
117
+ return $[22] !== handleChange || $[23] !== mdeOptions || $[24] !== onBlur || $[25] !== onFocus || $[26] !== reactMdeProps || $[27] !== value ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(MarkdownInputStyles, { children: /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback, children: /* @__PURE__ */ jsxRuntime.jsx(SimpleMdeReact, { ...reactMdeProps, ref, value, onChange: handleChange, onBlur, onFocus, options: mdeOptions, spellCheck: !1 }) }) }), $[22] = handleChange, $[23] = mdeOptions, $[24] = onBlur, $[25] = onFocus, $[26] = reactMdeProps, $[27] = value, $[28] = t12) : t12 = $[28], t12;
118
+ }
119
+ const fallback = /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading editor..." }) }), markdownTypeName = "markdown", markdownSchemaType = sanity.defineType({
120
+ type: "string",
121
+ name: markdownTypeName,
122
+ title: "Markdown",
123
+ components: {
124
+ input: MarkdownInput
125
+ }
126
+ }), markdownSchema = sanity.definePlugin((config) => ({
127
+ name: "markdown-editor",
128
+ schema: {
129
+ types: [config && config.input ? {
130
+ ...markdownSchemaType,
131
+ components: {
132
+ input: config.input
133
+ }
134
+ } : markdownSchemaType]
135
+ }
136
+ }));
137
+ exports.MarkdownInput = MarkdownInput;
138
+ exports.defaultMdeTools = defaultMdeTools;
139
+ exports.markdownSchema = markdownSchema;
140
+ exports.markdownSchemaType = markdownSchemaType;
141
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/components/MarkdownInput.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["// dont import non-types here, it will break SSR on next\nimport type {SimpleMDEReactProps} from 'react-simplemde-editor'\n\nimport {Box, Text} from '@sanity/ui'\nimport type { Options as EasyMdeOptions} from 'easymde'\nimport {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport {PatchEvent, set, type StringInputProps, unset, useClient} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {MarkdownOptions} from '../schema'\n\nconst SimpleMdeReact = lazy(() => import('react-simplemde-editor'))\n\nconst MarkdownInputStyles = styled(Box)`\n & .CodeMirror.CodeMirror {\n color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n border-color: ${({theme}) => theme.sanity.color.card.enabled.border};\n background-color: inherit;\n }\n\n & .cm-s-easymde .CodeMirror-cursor {\n border-color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n }\n\n & .editor-toolbar,\n .editor-preview-side {\n border-color: ${({theme}) => theme.sanity.color.card.enabled.border};\n }\n\n & .CodeMirror-focused .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {\n background-color: ${({theme}) => theme.sanity.color.selectable?.primary?.hovered?.bg};\n }\n\n & .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n }\n\n & .editor-toolbar > * {\n color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n }\n\n & .editor-toolbar > .active,\n .editor-toolbar > button:hover,\n .editor-preview pre,\n .cm-s-easymde .cm-comment {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n }\n\n & .editor-preview {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n\n & h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: revert;\n }\n\n & ul,\n li {\n list-style: revert;\n padding: revert;\n }\n\n & a {\n text-decoration: revert;\n }\n }\n`\n\nexport interface MarkdownInputProps extends StringInputProps {\n /**\n * These are passed along directly to\n *\n * Note: MarkdownInput sets certain reactMdeProps.options by default.\n * These will be merged with any custom options.\n */\n reactMdeProps?: Omit<SimpleMDEReactProps, 'value' | 'onChange'>\n}\n\nexport const defaultMdeTools: EasyMdeOptions['toolbar'] = [\n 'heading',\n 'bold',\n 'italic',\n '|',\n 'quote',\n 'unordered-list',\n 'ordered-list',\n '|',\n 'link',\n 'image',\n 'code',\n '|',\n 'preview',\n 'side-by-side',\n]\n\nexport function MarkdownInput(props: MarkdownInputProps): React.JSX.Element {\n const {\n value = '',\n onChange,\n elementProps: {onBlur, onFocus, ref: elementRef},\n reactMdeProps: {options: mdeCustomOptions, ...reactMdeProps} = {},\n schemaType,\n focused,\n } = props\n const client = useClient({apiVersion: '2022-01-01'})\n // oxlint-disable-next-line no-unsafe-type-assertion\n const {imageUrl} = (schemaType.options as MarkdownOptions | undefined) ?? {}\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n\n // Forward ref to parent form state\n useImperativeHandle(elementRef, () => ref.current)\n\n const imageUpload = useCallback(\n (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => {\n client.assets\n .upload('image', file)\n .then((doc) => onSuccess(imageUrl ? imageUrl(doc) : `${doc.url}?w=450`))\n .catch((e) => {\n console.error(e)\n onError(e.message)\n })\n },\n [client, imageUrl],\n )\n\n const mdeOptions: EasyMdeOptions = useMemo(() => {\n return {\n spellChecker: false,\n sideBySideFullscreen: false,\n uploadImage: true,\n imageUploadFunction: imageUpload,\n toolbar: defaultMdeTools,\n status: false,\n ...mdeCustomOptions,\n autofocus: shouldAutoFocus,\n }\n }, [imageUpload, mdeCustomOptions, shouldAutoFocus])\n\n useEffect(() => {\n const node = ref.current\n if (!node) return undefined\n\n if (focused && !shouldAutoFocus) {\n // Do not set autofocus if the field already has focus\n const raf = requestAnimationFrame(() =>\n setShouldAutoFocus(!node.contains(document.activeElement)),\n )\n return () => cancelAnimationFrame(raf)\n }\n\n if (!focused && shouldAutoFocus) {\n // If `focused` is false, and the current active focus is no longer within the editor, reset autofocus state\n const raf = requestAnimationFrame(() =>\n setShouldAutoFocus(node.contains(document.activeElement)),\n )\n return () => cancelAnimationFrame(raf)\n }\n\n return undefined\n }, [focused, shouldAutoFocus])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n return (\n <MarkdownInputStyles>\n <Suspense fallback={fallback}>\n <SimpleMdeReact\n {...reactMdeProps}\n ref={ref}\n value={value}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n options={mdeOptions}\n spellCheck={false}\n />\n </Suspense>\n </MarkdownInputStyles>\n )\n}\n\nconst fallback = (\n <Box padding={3}>\n <Text>Loading editor...</Text>\n </Box>\n)\n","import type {SanityImageAssetDocument} from '@sanity/client'\n\nimport {defineType, type StringDefinition} from 'sanity'\n\nimport {MarkdownInput} from './components/MarkdownInput'\n\nexport const markdownTypeName = 'markdown'\n\nexport interface MarkdownOptions {\n /**\n * Used to create image url for any uploaded image.\n * The function will be invoked whenever an image is pasted or dragged into the\n * markdown editor, after upload completes.\n *\n * The default implementation uses\n * ```js\n * imageAsset => `${imageAsset.url}?w=450`\n * ```\n * ## Example\n * ```js\n * {\n * imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`\n * }\n * ```\n * @param imageAsset\n */\n imageUrl?: (imageAsset: SanityImageAssetDocument) => string\n}\n\n/**\n * @public\n */\nexport interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {\n type: typeof markdownTypeName\n options?: MarkdownOptions\n}\n\ndeclare module 'sanity' {\n // makes type: 'markdown' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n markdown: MarkdownDefinition\n }\n}\n\nexport const markdownSchemaType = defineType({\n type: 'string',\n name: markdownTypeName,\n title: 'Markdown',\n components: {input: MarkdownInput},\n})\n","import {definePlugin, type Plugin, type StringInputProps} from 'sanity'\n\nimport {markdownSchemaType} from './schema'\n\nexport interface MarkdownConfig {\n /**\n * When provided, will replace the default input component.\n *\n * Use this to customize MarkdownInput by wrapping it in a custom component,\n * and provide any custom props for https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor\n * via the `reactMdeProps` prop.\n *\n * ### Example\n *\n * ```tsx\n * // CustomMarkdownInput.tsx\n * import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'\n *\n * export function CustomMarkdownInput(props) {\n * const reactMdeProps: MarkdownInputProps['reactMdeProps'] =\n * useMemo(() => {\n * return {\n * options: {\n * toolbar: ['bold', 'italic'],\n * // more options available, see:\n * // https://github.com/Ionaru/easy-markdown-editor#options-list\n * },\n * // more props available, see:\n * // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor\n * }\n * }, [])\n *\n * return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />\n * }\n *\n * // studio.config.ts\n * markdownSchema({input: CustomMarkdownInput})\n * ```\n */\n input?: (props: StringInputProps) => React.ReactElement\n}\n\nexport const markdownSchema: Plugin<MarkdownConfig | void> = definePlugin(\n (config: MarkdownConfig | void) => {\n return {\n name: 'markdown-editor',\n schema: {\n types: [\n config && config.input\n ? {...markdownSchemaType, components: {input: config.input}}\n : markdownSchemaType,\n ],\n },\n }\n },\n)\n"],"names":["SimpleMdeReact","lazy","MarkdownInputStyles","styled","Box","withConfig","displayName","componentId","theme","sanity","color","card","enabled","fg","border","selectable","primary","hovered","bg","defaultMdeTools","MarkdownInput","props","$","_c","value","t0","onChange","elementProps","t1","reactMdeProps","t2","schemaType","focused","undefined","onBlur","onFocus","ref","elementRef","t3","mdeCustomOptions","options","t4","for","apiVersion","client","useClient","t5","imageUrl","shouldAutoFocus","setShouldAutoFocus","useState","useRef","t6","Symbol","current","useImperativeHandle","t7","file","onSuccess","onError","assets","upload","then","doc","url","catch","e","console","error","message","imageUpload","t8","spellChecker","sideBySideFullscreen","uploadImage","imageUploadFunction","toolbar","status","autofocus","mdeOptions","t10","t9","node","raf","requestAnimationFrame","contains","document","activeElement","cancelAnimationFrame","raf_0","useEffect","t11","newValue","PatchEvent","from","set","unset","handleChange","t12","jsx","Suspense","fallback","Text","markdownTypeName","markdownSchemaType","defineType","type","name","title","components","input","markdownSchema","definePlugin","config","schema","types"],"mappings":"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"}
@@ -0,0 +1,161 @@
1
+ import { Plugin, StringDefinition, StringInputProps } from "sanity";
2
+ import { SimpleMDEReactProps } from "react-simplemde-editor";
3
+ import { Options } from "easymde";
4
+ /**
5
+ * Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
6
+ * @internal
7
+ */
8
+ declare type Any = any;
9
+ /** @internal */
10
+ declare interface SanityAssetDocument extends SanityDocument {
11
+ url: string;
12
+ path: string;
13
+ size: number;
14
+ assetId: string;
15
+ mimeType: string;
16
+ sha1hash: string;
17
+ extension: string;
18
+ uploadId?: string;
19
+ originalFilename?: string;
20
+ }
21
+ /** @internal */
22
+ declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = { [P in keyof T]: T[P] } & {
23
+ _id: string;
24
+ _rev: string;
25
+ _type: string;
26
+ _createdAt: string;
27
+ _updatedAt: string;
28
+ /**
29
+ * Present when `perspective` is set to `previewDrafts`
30
+ */
31
+ _originalId?: string;
32
+ };
33
+ /** @internal */
34
+ declare interface SanityImageAssetDocument extends SanityAssetDocument {
35
+ metadata: {
36
+ _type: 'sanity.imageMetadata';
37
+ hasAlpha: boolean;
38
+ isOpaque: boolean;
39
+ lqip?: string;
40
+ blurHash?: string;
41
+ dimensions: {
42
+ _type: 'sanity.imageDimensions';
43
+ aspectRatio: number;
44
+ height: number;
45
+ width: number;
46
+ };
47
+ palette?: {
48
+ _type: 'sanity.imagePalette';
49
+ darkMuted?: SanityImagePalette;
50
+ darkVibrant?: SanityImagePalette;
51
+ dominant?: SanityImagePalette;
52
+ lightMuted?: SanityImagePalette;
53
+ lightVibrant?: SanityImagePalette;
54
+ muted?: SanityImagePalette;
55
+ vibrant?: SanityImagePalette;
56
+ };
57
+ image?: {
58
+ _type: 'sanity.imageExifTags';
59
+ [key: string]: Any;
60
+ };
61
+ exif?: {
62
+ _type: 'sanity.imageExifMetadata';
63
+ [key: string]: Any;
64
+ };
65
+ };
66
+ }
67
+ /** @internal */
68
+ declare interface SanityImagePalette {
69
+ background: string;
70
+ foreground: string;
71
+ population: number;
72
+ title: string;
73
+ }
74
+ declare const markdownTypeName = "markdown";
75
+ interface MarkdownOptions {
76
+ /**
77
+ * Used to create image url for any uploaded image.
78
+ * The function will be invoked whenever an image is pasted or dragged into the
79
+ * markdown editor, after upload completes.
80
+ *
81
+ * The default implementation uses
82
+ * ```js
83
+ * imageAsset => `${imageAsset.url}?w=450`
84
+ * ```
85
+ * ## Example
86
+ * ```js
87
+ * {
88
+ * imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`
89
+ * }
90
+ * ```
91
+ * @param imageAsset
92
+ */
93
+ imageUrl?: (imageAsset: SanityImageAssetDocument) => string;
94
+ }
95
+ /**
96
+ * @public
97
+ */
98
+ interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {
99
+ type: typeof markdownTypeName;
100
+ options?: MarkdownOptions;
101
+ }
102
+ declare module 'sanity' {
103
+ interface IntrinsicDefinitions {
104
+ markdown: MarkdownDefinition;
105
+ }
106
+ }
107
+ declare const markdownSchemaType: {
108
+ type: "string";
109
+ name: "markdown";
110
+ } & Omit<StringDefinition, "preview">;
111
+ interface MarkdownInputProps extends StringInputProps {
112
+ /**
113
+ * These are passed along directly to
114
+ *
115
+ * Note: MarkdownInput sets certain reactMdeProps.options by default.
116
+ * These will be merged with any custom options.
117
+ */
118
+ reactMdeProps?: Omit<SimpleMDEReactProps, 'value' | 'onChange'>;
119
+ }
120
+ declare const defaultMdeTools: Options['toolbar'];
121
+ declare function MarkdownInput(props: MarkdownInputProps): React.JSX.Element;
122
+ interface MarkdownConfig {
123
+ /**
124
+ * When provided, will replace the default input component.
125
+ *
126
+ * Use this to customize MarkdownInput by wrapping it in a custom component,
127
+ * and provide any custom props for https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
128
+ * via the `reactMdeProps` prop.
129
+ *
130
+ * ### Example
131
+ *
132
+ * ```tsx
133
+ * // CustomMarkdownInput.tsx
134
+ * import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'
135
+ *
136
+ * export function CustomMarkdownInput(props) {
137
+ * const reactMdeProps: MarkdownInputProps['reactMdeProps'] =
138
+ * useMemo(() => {
139
+ * return {
140
+ * options: {
141
+ * toolbar: ['bold', 'italic'],
142
+ * // more options available, see:
143
+ * // https://github.com/Ionaru/easy-markdown-editor#options-list
144
+ * },
145
+ * // more props available, see:
146
+ * // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
147
+ * }
148
+ * }, [])
149
+ *
150
+ * return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />
151
+ * }
152
+ *
153
+ * // studio.config.ts
154
+ * markdownSchema({input: CustomMarkdownInput})
155
+ * ```
156
+ */
157
+ input?: (props: StringInputProps) => React.ReactElement;
158
+ }
159
+ declare const markdownSchema: Plugin<MarkdownConfig | void>;
160
+ export { type MarkdownConfig, type MarkdownDefinition, MarkdownInput, type MarkdownInputProps, defaultMdeTools, markdownSchema, markdownSchemaType };
161
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":["ClientPerspective","ClientPerspective_2","ContentSourceMapDocuments","ContentSourceMapDocuments_2","ContentSourceMapParsedPath","ContentSourceMapParsedPathKeyedSegment","HttpContext","Observable","Requester","ResolveStudioUrl","StudioBaseRoute","StudioBaseUrl","StudioUrl","adapter","unstable__adapter","environment","unstable__environment","Action","CreateAction","ReplaceDraftAction","EditAction","DeleteAction","DiscardAction","PublishAction","UnpublishAction","VersionAction","ReleaseAction","ActionError","ActionErrorItem","AgentActionAsync","AgentActionParam","TParamConfig","ConstantAgentActionParam","FieldAgentActionParam","DocumentAgentActionParam","GroqAgentActionParam","AgentActionParams","Record","AgentActionPath","AgentActionPathSegment","AgentActionRequestBase","AgentActionSchema","AgentActionsClient","DocumentShape","SanityClient","HttpRequest","Any","GenerateInstruction","request","IdentifiedSanityDocumentStub","Promise","TransformDocument","TranslateDocument","PromptRequest","PatchDocument","AgentActionSync","AgentActionTarget","AgentActionTypeConfig","AgentActionTargetInclude","AllDocumentIdsMutationOptions","BaseMutationOptions","AllDocumentsMutationOptions","AnimatedImageFormat","AnimatedTransformOptions","AnyNonNullable","Exclude","ApiError","ArchiveReleaseAction","AssetMetadataType","AssetsClient","UploadBody","UploadClientConfig","SanityAssetDocument","SanityImageAssetDocument","AttributeSet","AuthProvider","AuthProviderResponse","BaseActionOptions","RequestOptions","BasePatch","PatchSelection","PatchOperations","PatchMutationOperation","BaseTransaction","R","Mutation","SanityDocumentStub","ChannelError","Error","ChannelErrorEvent","ClientConfig","ClientConfigResource","RegExp","Array","ResponseQueryOptions","StegaConfig","ClientError","ErrorProps","DeprecatedPreviewDrafts","StackablePerspective","ClientReturn","GroqString","Fallback","SanityQueries","connectEventSource","EventName","EventSourceInstance","ServerSentEvent","ConnectionFailedError","ContentSourceMap","ContentSourceMapMappings","ContentSourceMapPaths","ContentSourceMapDocument","ContentSourceMapDocumentBase","ContentSourceMapRemoteDocument","ContentSourceMapDocumentValueSource","ContentSourceMapLiteralSource","ContentSourceMapMapping","ContentSourceMapValueMapping","ContentSourceMapSource","ContentSourceMapUnknownSource","CorsOriginError","URL","projectId","createClient","CreateReleaseAction","ReleaseDocument","Partial","CreateVersionAction","CurrentSanityUser","DatasetAclMode","DatasetResponse","DatasetsClient","DatasetsResponse","DeleteReleaseAction","deprecatedCreateClient","default","DiscardVersionAction","DisconnectError","ErrorOptions","DisconnectEvent","DocIdParam","EditableReleaseDocument","PartialExcept","Omit","EditReleaseAction","EventSourceEvent","Name","globalThis","EventSource","InstanceType","EXPERIMENTAL_API_WARNING","FilterDefault","FilteredResponseQueryOptions","FirstDocumentIdMutationOptions","FirstDocumentMutationOptions","FitMode","formatQueryParseError","QueryParseError","GenerateAsyncInstruction","T","GenerateExistingDocumentRequest","GenerateTargetDocumentRequest","GenerateRequestBase","GenerateSyncInstruction","GenerateOperation","GenerateTarget","GenerateTargetInclude","GenerateTargetDocument","HttpError","ReturnType","HttpRequestEvent","ResponseEvent","ProgressEvent_2","P","ImageDescriptionOperation","ImportReleaseAction","InitializedClientConfig","InitializedStegaConfig","StegaConfigRequiredKeys","Pick","Required","InsertPatch","isHttpError","isQueryParseError","_listen","ObservableSanityClient","ListenParams","MutationEvent","Opts","ListenOptions","ListenEventFromOptions","ListenEvent","ReconnectEvent","WelcomeEvent","OpenEvent","ListenEventName","MapListenEventNamesToListenEvents","LiveClient","includeDrafts","_tag","LiveEvent","LiveEventRestart","LiveEventReconnect","LiveEventMessage","LiveEventWelcome","LiveEventGoAway","SyncTag","Logger","console","Events","MediaLibraryAssetInstanceIdentifier","SanityReference","MediaLibraryPlaybackInfoOptions","MediaLibraryVideoPlaybackTransformations","MediaLibraryVideoClient","VideoPlaybackInfo","ThumbnailTransformOptions","StoryboardTransformOptions","MessageError","MessageParseError","MultipleActionResult","MultipleMutationResult","MutationOperation","MutationSelection","MutationError","MutationErrorItem","SanityDocument","MutationSelectionQueryParams","ObservableAgentsActionClient","ObservableAssetsClient","ObservableDatasetsClient","ObservableMediaLibraryVideoClient","ObservablePatch","SingleMutationResult","ObservablePatchBuilder","ObservableProjectsClient","SanityProject","ObservableReleasesClient","releaseId","AbortSignal","SingleActionResult","patch","publishAt","RawQueryResponse","Q","G","ObservableUsersClient","QueryWithoutParams","QueryParams","UnfilteredResponseQueryOptions","UnfilteredResponseWithoutQuery","RawQuerylessQueryResponse","publishedId","ObservableTransaction","RawRequestOptions","TransactionFirstDocumentMutationOptions","TransactionAllDocumentsMutationOptions","TransactionFirstDocumentIdMutationOptions","TransactionAllDocumentIdsMutationOptions","SanityUser","K","Patch","PatchBuilder","PatchDocumentSync","PatchDocumentAsync","PatchExistingDocumentRequest","PatchTargetDocumentRequest","PatchRequestBase","PatchOperation","PatchTarget","ProgressEvent","ProjectsClient","PromptJsonResponse","PromptTextResponse","PromptRequestBase","PublishReleaseAction","QueryOptions","RequestInit","UnarchiveReleaseAction","ScheduleReleaseAction","UnscheduleReleaseAction","ReleaseCardinality","ReleaseState","ReleaseType","ReleaseId","ReleasesClient","ReplaceVersionAction","requester","RequestObservableOptions","UsersClient","Transaction","SanityImagePalette","SanityProjectMember","ServerError","Extract","StillImageFormat","TransactionMutationOptions","TransformDocumentSync","TransformDocumentAsync","TransformRequestBase","TransformOperation","TransformTargetDocument","TransformTarget","TransformTargetInclude","TranslateDocumentSync","TranslateDocumentAsync","TranslateRequestBase","TranslateLanguage","TranslateTarget","TranslateTargetInclude","UnpublishVersionAction","File","Blob","Buffer","NodeJS","ReadableStream","validateApiPerspective","VideoPlaybackInfoItem","VideoPlaybackInfoItemPublic","VideoPlaybackInfoItemSigned","VideoPlaybackInfoPublic","VideoPlaybackInfoSigned","VideoPlaybackTokens"],"sources":["../../../node_modules/.pnpm/@sanity+client@7.13.2_debug@4.4.3/node_modules/@sanity/client/dist/index.d.ts","../src/schema.ts","../src/components/MarkdownInput.tsx","../src/plugin.tsx"],"sourcesContent":["import type {ClientPerspective as ClientPerspective_2} from '@sanity/client'\nimport type {ContentSourceMapDocuments as ContentSourceMapDocuments_2} from '@sanity/client/csm'\nimport {ContentSourceMapParsedPath} from '@sanity/client/csm'\nimport {ContentSourceMapParsedPathKeyedSegment} from '@sanity/client/csm'\nimport type {HttpContext} from 'get-it'\nimport {Observable} from 'rxjs'\nimport {Requester} from 'get-it'\nimport type {ResolveStudioUrl} from '@sanity/client/csm'\nimport {StudioBaseRoute} from '@sanity/client/csm'\nimport {StudioBaseUrl} from '@sanity/client/csm'\nimport {StudioUrl} from '@sanity/client/csm'\nimport {adapter as unstable__adapter} from 'get-it'\nimport {environment as unstable__environment} from 'get-it'\n\n/** @public */\nexport declare type Action =\n | CreateAction\n | ReplaceDraftAction\n | EditAction\n | DeleteAction\n | DiscardAction\n | PublishAction\n | UnpublishAction\n | VersionAction\n | ReleaseAction\n\n/** @internal */\nexport declare interface ActionError {\n type: 'actionError'\n description: string\n items?: ActionErrorItem[]\n}\n\n/** @internal */\nexport declare interface ActionErrorItem {\n error: {\n type: string\n description: string\n value?: unknown\n }\n index: number\n}\n\n/** @beta */\ndeclare interface AgentActionAsync {\n /**\n * When async: true, requests responds with status 201 and \\{_id\\} as response body as soon as the request is validated.\n * The instruction operation will carry on in the background.\n *\n * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.\n *\n * async: true is incompatible with noWrite, as async: true does not return the resulting document\n */\n async: true\n}\n\n/** @beta */\nexport declare type AgentActionParam<\n TParamConfig extends {\n docIdRequired: boolean\n } = {\n docIdRequired: false\n },\n> =\n | string\n | ConstantAgentActionParam\n | FieldAgentActionParam<TParamConfig>\n | DocumentAgentActionParam<TParamConfig>\n | GroqAgentActionParam\n\n/** @beta */\nexport declare type AgentActionParams<\n TParamConfig extends {\n docIdRequired: boolean\n } = {\n docIdRequired: false\n },\n> = Record<string, AgentActionParam<TParamConfig>>\n\n/** @beta */\nexport declare type AgentActionPath = AgentActionPathSegment[]\n\n/** @beta */\nexport declare type AgentActionPathSegment =\n | string\n | {\n _key: string\n }\n\n/** @beta */\ndeclare interface AgentActionRequestBase extends AgentActionSchema {\n /**\n * When localeSettings is provided on the request, instruct can write to date and datetime fields.\n * Otherwise, such fields will be ignored.\n */\n localeSettings?: {\n /**\n * A valid Unicode BCP 47 locale identifier used to interpret and format\n * natural language inputs and date output. Examples include \"en-US\", \"fr-FR\", or \"ja-JP\".\n *\n * This affects how phrases like \"next Friday\" or \"in two weeks\" are parsed,\n * and how resulting dates are presented (e.g., 12-hour vs 24-hour format).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#getcanonicalocales\n */\n locale: string\n /**\n * A valid IANA time zone identifier used to resolve relative and absolute\n * date expressions to a specific point in time. Examples include\n * \"America/New_York\", \"Europe/Paris\", or \"Asia/Tokyo\".\n *\n * This ensures phrases like \"tomorrow at 9am\" are interpreted correctly\n * based on the user's local time.\n *\n * @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n */\n timeZone: string\n }\n /**\n * Controls how much variance the instructions will run with.\n *\n * Value must be in the range [0, 1] (inclusive).\n *\n * Defaults:\n * - generate: 0.3\n * - translate: 0\n * - transform: 0\n */\n temperature?: number\n}\n\n/** @beta */\ndeclare interface AgentActionSchema {\n /** schemaId as reported by sanity deploy / sanity schema store */\n schemaId: string\n /**\n * ### forcePublishedWrite: false (default)\n * By default, agent actions will never write to a published document.\n *\n * Instead, they will force the use of a draft ID (\"drafts.some-id\") instead of the published ID (\"some-id\"),\n * even when a published ID is provided.\n *\n * Actions will use state from an existing draft if it exists,\n * or use the published document to create a draft, if no draft exists.\n *\n * Successful responses contains the _id that was mutated by the action.\n *\n *\n * ### forcePublishedWrite: true\n *\n * When forcePublishedWrite: true an agent action will write to the exact id provided.\n * The action will also not fallback to published state for draft ids.\n *\n *\n * ### Versioned ids (releases)\n *\n * When an ID on the form \"versions.<release>.some-id\" is provided, agent actions will\n * always behave as if `forcePublishedWrite: true`.\n * That is, only the exact document state of the id provided is considered and mutated.\n * */\n forcePublishedWrite?: boolean\n /**\n * When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.\n *\n * By default, Generate will not output to conditional `readOnly` and `hidden` fields,\n * ie, they are considered to resolve to `readOnly: true` / `hidden: true`.\n *\n * `conditionalPaths` param allows setting the default conditional value for\n * `hidden` and `readOnly` to false,\n * or individually set `hidden` and `readOnly` state for individual document paths.\n *\n * Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to Generate,\n * and cannot be changed via conditionalPaths\n *\n * conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.\n *\n * Consider using `hidden: () => true` in schema config, if a field should be writeable only by Generate and never\n * visible in the studio – then make the field visible to the Generate using `conditionalPaths`.\n *\n * @see GenerateRequestBase#target\n */\n conditionalPaths?: {\n defaultReadOnly?: boolean\n defaultHidden?: boolean\n paths?: {\n /** path here is not a relative path: it must be the full document path, regardless of `path` param used in targets */\n path: AgentActionPath\n readOnly: boolean\n hidden: boolean\n }[]\n }\n}\n\n/** @public */\ndeclare class AgentActionsClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * Run an instruction to generate content in a target document.\n * @param request - instruction request\n */\n generate<DocumentShape extends Record<string, Any>>(\n request: GenerateInstruction<DocumentShape>,\n ): Promise<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n /**\n * Transform a target document based on a source.\n * @param request - translation request\n */\n transform<DocumentShape extends Record<string, Any>>(\n request: TransformDocument<DocumentShape>,\n ): Promise<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n /**\n * Translate a target document based on a source.\n * @param request - translation request\n */\n translate<DocumentShape extends Record<string, Any>>(\n request: TranslateDocument<DocumentShape>,\n ): Promise<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n /**\n * Run a raw instruction and return the result either as text or json\n * @param request - prompt request\n */\n prompt<const DocumentShape extends Record<string, Any>>(\n request: PromptRequest<DocumentShape>,\n ): Promise<(typeof request)['format'] extends 'json' ? DocumentShape : string>\n /**\n * Patch a document using a schema aware API.\n * Does not use an LLM, but uses the schema to ensure paths and values matches the schema.\n * @param request - instruction request\n */\n patch<DocumentShape extends Record<string, Any>>(\n request: PatchDocument<DocumentShape>,\n ): Promise<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n}\n\n/** @beta */\ndeclare interface AgentActionSync {\n /**\n * By default, noWrite: false.\n * Write enabled operations will mutate the target document, and emit AI presence in the studio.\n *\n * When noWrite: true, the api will not mutate any documents nor emit presence.\n * Ie, when true, no changes will be made to content-lake\n *\n * noWrite: true is incompatible with async: true,\n * as noWrite implies that you will use the return value of the operation\n */\n noWrite?: boolean\n /**\n * When async: true, requests responds with status 201 and \\{_id\\} as response body as soon as the request is validated.\n * The instruction operation will carry on in the background.\n *\n * When async: false (default), requests respond with status 200 and the document value after instruction has been applied.\n *\n * async: true is incompatible with noWrite: true, as async: true does not return the resulting document\n */\n async?: false\n}\n\n/**\n * @beta\n */\nexport declare interface AgentActionTarget {\n /**\n * Root target path.\n *\n * Use this to have the instruction only affect a part of the document.\n *\n * To further control the behavior of individual paths under the root, use `include`, `exclude`, `types.include`\n * and `types.exclude`.\n *\n * Example:\n *\n * `path: ['body', {_key: 'someKey'}, 'nestedObject']`\n *\n * Here, the instruction will only write to fields under the nestedObject.\n *\n * Default: [] = the document itself\n *\n * @see #AgentActionPathSegment\n * @see #AgentActionPath\n * */\n path?: AgentActionPathSegment | AgentActionPath\n /**\n * maxPathDepth controls how deep into the schema from the target root the instruction will affect.\n *\n * Depth is based on path segments:\n * - `title` has depth 1\n * - `array[_key=\"no\"].title` has depth 3\n *\n * Be careful not to set this too high in studios with recursive document schemas, as it could have\n * negative impact on performance; both for runtime and quality of responses.\n *\n * Default: 4\n */\n maxPathDepth?: number\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n * Fields or array items not on the exclude list, are implicitly included.\n */\n exclude?: AgentActionPathSegment[]\n /**\n * Types can be used to exclude array item types or all fields directly under the target path of a certain type.\n * If you do exclude: ['string'] all string fields under the target will be excluded, for instance.\n *\n * `types.include` and `types.exclude` are mutually exclusive.\n */\n types?: AgentActionTypeConfig\n}\n\n/** @beta */\ndeclare interface AgentActionTargetInclude {\n path: AgentActionPathSegment | AgentActionPath\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n * Fields or array items not on the exclude list, are implicitly included.\n */\n exclude?: AgentActionPathSegment[]\n /**\n * Types can be used to exclude array item types or all fields directly under the target path of a certain type.\n * If you do exclude: ['string'] all string fields under the target will be excluded, for instance.\n *\n * `types.include` and `types.exclude` are mutually exclusive.\n */\n types?: AgentActionTypeConfig\n}\n\n/** @beta */\ndeclare type AgentActionTypeConfig =\n | {\n include: string[]\n exclude?: never\n }\n | {\n exclude: string[]\n include?: never\n }\n\n/** @internal */\nexport declare type AllDocumentIdsMutationOptions = BaseMutationOptions & {\n returnFirst: false\n returnDocuments: false\n}\n\n/** @internal */\nexport declare type AllDocumentsMutationOptions = BaseMutationOptions & {\n returnFirst: false\n returnDocuments?: true\n}\n\n/**\n * Allowed animated image formats.\n * @public\n */\nexport declare type AnimatedImageFormat = 'gif' | 'webp'\n\n/**\n * Animated preview rendition options (e.g. GIF / animated WebP).\n * @public\n */\nexport declare interface AnimatedTransformOptions {\n /** Pixel width of the animated output. Max 640 px. */\n width?: number\n /** Pixel height of the animated output. Max 640 px. */\n height?: number\n /** Start time in seconds (inclusive). */\n start?: number\n /** End time in seconds. */\n end?: number\n /** Frames per second (1–30). */\n fps?: number\n /** Output animated format. */\n format?: AnimatedImageFormat\n}\n\n/**\n * Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future\n * @internal\n */\nexport declare type Any = any\n\ndeclare type AnyNonNullable = Exclude<any, null | undefined>\n\n/** @internal */\nexport declare interface ApiError {\n error: string\n message: string\n statusCode: number\n}\n\n/**\n * Archives an `active` release, and deletes all the release documents.\n *\n * @public\n */\nexport declare interface ArchiveReleaseAction {\n actionType: 'sanity.action.release.archive'\n releaseId: string\n}\n\n/** @public */\nexport declare type AssetMetadataType =\n | 'location'\n | 'exif'\n | 'image'\n | 'palette'\n | 'lqip'\n | 'blurhash'\n | 'none'\n\n/** @internal */\nexport declare class AssetsClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * Uploads a file asset to the configured dataset\n *\n * @param assetType - Asset type (file)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file',\n body: UploadBody,\n options?: UploadClientConfig,\n ): Promise<SanityAssetDocument>\n /**\n * Uploads an image asset to the configured dataset\n *\n * @param assetType - Asset type (image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'image',\n body: UploadBody,\n options?: UploadClientConfig,\n ): Promise<SanityImageAssetDocument>\n /**\n * Uploads a file or an image asset to the configured dataset\n *\n * @param assetType - Asset type (file/image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file' | 'image',\n body: UploadBody,\n options?: UploadClientConfig,\n ): Promise<SanityAssetDocument | SanityImageAssetDocument>\n}\n\n/** @internal */\nexport declare type AttributeSet = {\n [key: string]: Any\n}\n\n/** @internal */\nexport declare interface AuthProvider {\n name: string\n title: string\n url: string\n}\n\n/** @internal */\nexport declare type AuthProviderResponse = {\n providers: AuthProvider[]\n}\n\n/** @internal */\nexport declare type BaseActionOptions = RequestOptions & {\n transactionId?: string\n skipCrossDatasetReferenceValidation?: boolean\n dryRun?: boolean\n}\n\n/** @internal */\nexport declare type BaseMutationOptions = RequestOptions & {\n visibility?: 'sync' | 'async' | 'deferred'\n returnDocuments?: boolean\n returnFirst?: boolean\n dryRun?: boolean\n autoGenerateArrayKeys?: boolean\n skipCrossDatasetReferenceValidation?: boolean\n transactionId?: string\n}\n\n/** @internal */\nexport declare class BasePatch {\n protected selection: PatchSelection\n protected operations: PatchOperations\n constructor(selection: PatchSelection, operations?: PatchOperations)\n /**\n * Sets the given attributes to the document. Does NOT merge objects.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \\{\"nested.prop\": \"value\"\\}\n */\n set(attrs: AttributeSet): this\n /**\n * Sets the given attributes to the document if they are not currently set. Does NOT merge objects.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \\{\"nested.prop\": \"value\"\\}\n */\n setIfMissing(attrs: AttributeSet): this\n /**\n * Performs a \"diff-match-patch\" operation on the string attributes provided.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \\{\"nested.prop\": \"dmp\"\\}\n */\n diffMatchPatch(attrs: AttributeSet): this\n /**\n * Unsets the attribute paths provided.\n * The operation is added to the current patch, ready to be commited by `commit()`\n *\n * @param attrs - Attribute paths to unset.\n */\n unset(attrs: string[]): this\n /**\n * Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.\n *\n * @param attrs - Object of attribute paths to increment, values representing the number to increment by.\n */\n inc(attrs: {[key: string]: number}): this\n /**\n * Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist.\n *\n * @param attrs - Object of attribute paths to decrement, values representing the number to decrement by.\n */\n dec(attrs: {[key: string]: number}): this\n /**\n * Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression.\n *\n * @param at - Location to insert at, relative to the given selector, or 'replace' the matched path\n * @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key==\"abc123\"]`\n * @param items - Array of items to insert/replace\n */\n insert(at: 'before' | 'after' | 'replace', selector: string, items: Any[]): this\n /**\n * Append the given items to the array at the given JSONPath\n *\n * @param selector - Attribute/path to append to, eg `comments` or `person.hobbies`\n * @param items - Array of items to append to the array\n */\n append(selector: string, items: Any[]): this\n /**\n * Prepend the given items to the array at the given JSONPath\n *\n * @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies`\n * @param items - Array of items to prepend to the array\n */\n prepend(selector: string, items: Any[]): this\n /**\n * Change the contents of an array by removing existing elements and/or adding new elements.\n *\n * @param selector - Attribute or JSONPath expression for array\n * @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x\n * @param deleteCount - An integer indicating the number of old array elements to remove.\n * @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array.\n */\n splice(selector: string, start: number, deleteCount?: number, items?: Any[]): this\n /**\n * Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value\n *\n * @param rev - Revision to lock the patch to\n */\n ifRevisionId(rev: string): this\n /**\n * Return a plain JSON representation of the patch\n */\n serialize(): PatchMutationOperation\n /**\n * Return a plain JSON representation of the patch\n */\n toJSON(): PatchMutationOperation\n /**\n * Clears the patch of all operations\n */\n reset(): this\n protected _assign(op: keyof PatchOperations, props: Any, merge?: boolean): this\n protected _set(op: keyof PatchOperations, props: Any): this\n}\n\n/** @internal */\nexport declare class BaseTransaction {\n protected operations: Mutation[]\n protected trxId?: string\n constructor(operations?: Mutation[], transactionId?: string)\n /**\n * Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param doc - Document to create. Requires a `_type` property.\n */\n create<R extends Record<string, Any> = Record<string, Any>>(doc: SanityDocumentStub<R>): this\n /**\n * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties.\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n doc: IdentifiedSanityDocumentStub<R>,\n ): this\n /**\n * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param doc - Document to create or replace. Requires `_id` and `_type` properties.\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n doc: IdentifiedSanityDocumentStub<R>,\n ): this\n /**\n * Deletes the document with the given document ID\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param documentId - Document ID to delete\n */\n delete(documentId: string): this\n /**\n * Gets the current transaction ID, if any\n */\n transactionId(): string | undefined\n /**\n * Set the ID of this transaction.\n *\n * @param id - Transaction ID\n */\n transactionId(id: string): this\n /**\n * Return a plain JSON representation of the transaction\n */\n serialize(): Mutation[]\n /**\n * Return a plain JSON representation of the transaction\n */\n toJSON(): Mutation[]\n /**\n * Clears the transaction of all operations\n */\n reset(): this\n protected _add(mut: Mutation): this\n}\n\n/**\n * @public\n * The server sent a `channelError` message. Usually indicative of a bad or malformed request\n */\nexport declare class ChannelError extends Error {\n readonly name = 'ChannelError'\n readonly data?: unknown\n constructor(message: string, data: unknown)\n}\n\n/**\n * An error occurred. This is different from a network-level error (which will be emitted as 'error').\n * Possible causes are things such as malformed filters, non-existant datasets or similar.\n *\n * @public\n */\nexport declare type ChannelErrorEvent = {\n type: 'channelError'\n message: string\n}\n\n/** @public */\nexport declare interface ClientConfig {\n projectId?: string\n dataset?: string\n /** @defaultValue true */\n useCdn?: boolean\n token?: string\n /** @internal */\n '~experimental_resource'?: ClientConfigResource\n /**\n * What perspective to use for the client. See {@link https://www.sanity.io/docs/perspectives|perspective documentation}\n * @remarks\n * As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}\n * @defaultValue 'published'\n */\n perspective?: ClientPerspective\n apiHost?: string\n /**\n @remarks\n * As of API version `v2025-02-19`, the default perspective has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}\n */\n apiVersion?: string\n proxy?: string\n /**\n * Optional request tag prefix for all request tags\n */\n requestTagPrefix?: string\n /**\n * Optional default headers to include with all requests\n *\n * @remarks request-specific headers will override any default headers with the same name.\n */\n headers?: Record<string, string>\n ignoreBrowserTokenWarning?: boolean\n /**\n * Ignore specific warning messages from the client.\n *\n * @remarks\n * - String values perform substring matching (not exact matching) against warning messages\n * - RegExp values are tested against the full warning message\n * - Array values allow multiple patterns to be specified\n *\n * @example\n * ```typescript\n * // Ignore warnings containing \"experimental\"\n * ignoreWarnings: 'experimental'\n *\n * // Ignore multiple warning types\n * ignoreWarnings: ['experimental', 'deprecated']\n *\n * // Use regex for exact matching\n * ignoreWarnings: /^This is an experimental API version$/\n *\n * // Mix strings and regex patterns\n * ignoreWarnings: ['rate limit', /^deprecated/i]\n * ```\n */\n ignoreWarnings?: string | RegExp | Array<string | RegExp>\n withCredentials?: boolean\n allowReconfigure?: boolean\n timeout?: number\n /** Number of retries for requests. Defaults to 5. */\n maxRetries?: number\n /**\n * The amount of time, in milliseconds, to wait before retrying, given an attemptNumber (starting at 0).\n *\n * Defaults to exponential back-off, starting at 100ms, doubling for each attempt, together with random\n * jitter between 0 and 100 milliseconds. More specifically the following algorithm is used:\n *\n * Delay = 100 * 2^attemptNumber + randomNumberBetween0and100\n */\n retryDelay?: (attemptNumber: number) => number\n /**\n * @deprecated Don't use\n */\n useProjectHostname?: boolean\n /**\n * @deprecated Don't use\n */\n requester?: Requester\n /**\n * Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`\n */\n resultSourceMap?: boolean | 'withKeyArraySelector'\n /**\n *@deprecated set `cache` and `next` options on `client.fetch` instead\n */\n fetch?:\n | {\n cache?: ResponseQueryOptions['cache']\n next?: ResponseQueryOptions['next']\n }\n | boolean\n /**\n * Options for how, if enabled, Content Source Maps are encoded into query results using steganography\n */\n stega?: StegaConfig | boolean\n /**\n * Lineage token for recursion control\n */\n lineage?: string\n}\n\ndeclare type ClientConfigResource =\n | {\n type: 'canvas'\n id: string\n }\n | {\n type: 'media-library'\n id: string\n }\n | {\n type: 'dataset'\n id: string\n }\n | {\n type: 'dashboard'\n id: string\n }\n\n/** @public */\nexport declare class ClientError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode']\n responseBody: ErrorProps['responseBody']\n details: ErrorProps['details']\n constructor(res: Any, context?: HttpContext)\n}\n\n/** @public */\nexport declare type ClientPerspective =\n | DeprecatedPreviewDrafts\n | 'published'\n | 'drafts'\n | 'raw'\n | StackablePerspective[]\n\n/** @public */\nexport declare type ClientReturn<\n GroqString extends string,\n Fallback = Any,\n> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback\n\n/**\n * Sanity API specific EventSource handler shared between the listen and live APIs\n *\n * Since the `EventSource` API is not provided by all environments, this function enables custom initialization of the EventSource instance\n * for runtimes that requires polyfilling or custom setup logic (e.g. custom HTTP headers)\n * via the passed `initEventSource` function which must return an EventSource instance.\n *\n * Possible errors to be thrown on the returned observable are:\n * - {@link MessageError}\n * - {@link MessageParseError}\n * - {@link ChannelError}\n * - {@link DisconnectError}\n * - {@link ConnectionFailedError}\n *\n * @param initEventSource - A function that returns an EventSource instance or an Observable that resolves to an EventSource instance\n * @param events - an array of named events from the API to listen for.\n *\n * @internal\n */\nexport declare function connectEventSource<EventName extends string>(\n initEventSource: () => EventSourceInstance | Observable<EventSourceInstance>,\n events: EventName[],\n): Observable<ServerSentEvent<EventName>>\n\n/**\n * @public\n * Thrown if the EventSource connection could not be established.\n * Note that ConnectionFailedErrors are rare, and disconnects will normally be handled by the EventSource instance itself and emitted as `reconnect` events.\n */\nexport declare class ConnectionFailedError extends Error {\n readonly name = 'ConnectionFailedError'\n}\n\n/**\n * Include a string in the instruction: do not have to escape $ signs in the string.\n *\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nGenerate the full article.',\n * instructionParams: {\n * topic: {\n * type: 'constant',\n * value: 'Grapefruit'\n * },\n * },\n * })\n * ```\n *\n * `type: 'constant'` can also be provided directly as a string, as a shorthand:\n *\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nGenerate the full article.',\n * instructionParams: {\n * topic: 'Grapefruit'\n * },\n * })\n * ```\n *\n * @beta\n * */\nexport declare interface ConstantAgentActionParam {\n type: 'constant'\n value: string\n}\n\n/** @public */\nexport declare interface ContentSourceMap {\n mappings: ContentSourceMapMappings\n documents: ContentSourceMapDocuments\n paths: ContentSourceMapPaths\n}\n\n/** @public */\nexport declare interface ContentSourceMapDocument extends ContentSourceMapDocumentBase {\n _projectId?: undefined\n _dataset?: undefined\n}\n\n/** @public */\nexport declare interface ContentSourceMapDocumentBase {\n _id: string\n _type: string\n}\n\n/** @public */\nexport declare type ContentSourceMapDocuments = (\n | ContentSourceMapDocument\n | ContentSourceMapRemoteDocument\n)[]\n\n/**\n * DocumentValueSource is a path to a value within a document\n * @public\n */\nexport declare interface ContentSourceMapDocumentValueSource {\n type: 'documentValue'\n document: number\n path: number\n}\n\n/**\n * When a value is not from a source, its a literal\n * @public\n */\nexport declare interface ContentSourceMapLiteralSource {\n type: 'literal'\n}\n\n/** @public */\nexport declare type ContentSourceMapMapping = ContentSourceMapValueMapping\n\n/** @public */\nexport declare type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>\n\nexport {ContentSourceMapParsedPath}\n\nexport {ContentSourceMapParsedPathKeyedSegment}\n\n/** @public */\nexport declare type ContentSourceMapPaths = string[]\n\n/** @public */\nexport declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocumentBase {\n _projectId: string\n _dataset: string\n}\n\n/** @public */\nexport declare type ContentSourceMapSource =\n | ContentSourceMapDocumentValueSource\n | ContentSourceMapLiteralSource\n | ContentSourceMapUnknownSource\n\n/**\n * When a field source is unknown\n * @public\n */\nexport declare interface ContentSourceMapUnknownSource {\n type: 'unknown'\n}\n\n/**\n * ValueMapping is a mapping when for value that is from a single source value\n * It may refer to a field within a document or a literal value\n * @public\n */\nexport declare interface ContentSourceMapValueMapping {\n type: 'value'\n source: ContentSourceMapSource\n}\n\n/** @public */\nexport declare class CorsOriginError extends Error {\n projectId: string\n addOriginUrl?: URL\n constructor({projectId}: {projectId: string})\n}\n\n/**\n * Creates a new draft document. The published version of the document must not already exist.\n * If the draft version of the document already exists the action will fail by default, but\n * this can be adjusted to instead leave the existing document in place.\n *\n * @public\n */\nexport declare type CreateAction = {\n actionType: 'sanity.action.document.create'\n /**\n * ID of the published document to create a draft for.\n */\n publishedId: string\n /**\n * Document to create. Requires a `_type` property.\n */\n attributes: IdentifiedSanityDocumentStub\n /**\n * ifExists controls what to do if the draft already exists\n */\n ifExists: 'fail' | 'ignore'\n}\n\n/**\n * @remarks\n * As of API version `v2025-02-19`, the default perspective used by the client has changed from `raw` to `published`. {@link https://www.sanity.io/changelog/676aaa9d-2da6-44fb-abe5-580f28047c10|Changelog}\n * @public\n */\nexport declare const createClient: (config: ClientConfig) => SanityClient\n\n/**\n * Creates a new release under the given id, with metadata.\n *\n * @public\n */\nexport declare interface CreateReleaseAction {\n actionType: 'sanity.action.release.create'\n releaseId: string\n metadata?: Partial<ReleaseDocument['metadata']>\n}\n\n/**\n * Creates a new version of an existing document.\n *\n * If the `document` is provided, the version is created from the document\n * attached to the release as given by `document._id`\n *\n * If the `baseId` and `versionId` are provided, the version is created from the base document\n * and the version is attached to the release as given by `publishedId` and `versionId`\n *\n * @public\n */\nexport declare type CreateVersionAction = {\n actionType: 'sanity.action.document.version.create'\n publishedId: string\n} & (\n | {\n document: IdentifiedSanityDocumentStub\n }\n | {\n baseId: string\n versionId: string\n ifBaseRevisionId?: string\n }\n)\n\n/** @public */\nexport declare interface CurrentSanityUser {\n id: string\n name: string\n email: string\n profileImage: string | null\n role: string\n provider: string\n}\n\n/** @public */\nexport declare type DatasetAclMode = 'public' | 'private' | 'custom'\n\n/** @public */\nexport declare type DatasetResponse = {\n datasetName: string\n aclMode: DatasetAclMode\n}\n\n/** @internal */\nexport declare class DatasetsClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * Create a new dataset with the given name\n *\n * @param name - Name of the dataset to create\n * @param options - Options for the dataset\n */\n create(\n name: string,\n options?: {\n aclMode?: DatasetAclMode\n },\n ): Promise<DatasetResponse>\n /**\n * Edit a dataset with the given name\n *\n * @param name - Name of the dataset to edit\n * @param options - New options for the dataset\n */\n edit(\n name: string,\n options?: {\n aclMode?: DatasetAclMode\n },\n ): Promise<DatasetResponse>\n /**\n * Delete a dataset with the given name\n *\n * @param name - Name of the dataset to delete\n */\n delete(name: string): Promise<{\n deleted: true\n }>\n /**\n * Fetch a list of datasets for the configured project\n */\n list(): Promise<DatasetsResponse>\n}\n\n/** @public */\nexport declare type DatasetsResponse = {\n name: string\n aclMode: DatasetAclMode\n createdAt: string\n createdByUserId: string\n addonFor: string | null\n datasetProfile: string\n features: string[]\n tags: string[]\n}[]\n\n/**\n * Deletes the published version of a document and optionally some (likely all known) draft versions.\n * If any draft version exists that is not specified for deletion this is an error.\n * If the purge flag is set then the document history is also deleted.\n *\n * @public\n */\nexport declare type DeleteAction = {\n actionType: 'sanity.action.document.delete'\n /**\n * Published document ID to delete\n */\n publishedId: string\n /**\n * Draft document ID to delete\n */\n includeDrafts: string[]\n /**\n * Delete document history\n */\n purge?: boolean\n}\n\n/**\n * Deletes a `archived` or `published` release, and all the release documents versions.\n *\n * @public\n */\nexport declare interface DeleteReleaseAction {\n actionType: 'sanity.action.release.delete'\n releaseId: string\n}\n\n/**\n * @public\n * @deprecated Use the named export `createClient` instead of the `default` export\n */\ndeclare const deprecatedCreateClient: (config: ClientConfig) => SanityClient\nexport default deprecatedCreateClient\n\n/**\n * @deprecated use 'drafts' instead\n */\ndeclare type DeprecatedPreviewDrafts = 'previewDrafts'\n\n/**\n * Delete the draft version of a document.\n * It is an error if it does not exist. If the purge flag is set, the document history is also deleted.\n *\n * @public\n * @deprecated Use {@link DiscardVersionAction} instead\n */\nexport declare type DiscardAction = {\n actionType: 'sanity.action.document.discard'\n /**\n * Draft document ID to delete\n */\n draftId: string\n /**\n * Delete document history\n */\n purge?: boolean\n}\n\n/**\n * Delete a version of a document.\n *\n * @public\n */\nexport declare interface DiscardVersionAction {\n actionType: 'sanity.action.document.version.discard'\n versionId: string\n purge?: boolean\n}\n\n/**\n * The listener has been told to explicitly disconnect.\n * This is a rare situation, but may occur if the API knows reconnect attempts will fail,\n * eg in the case of a deleted dataset, a blocked project or similar events.\n * @public\n */\nexport declare class DisconnectError extends Error {\n readonly name = 'DisconnectError'\n readonly reason?: string\n constructor(message: string, reason?: string, options?: ErrorOptions)\n}\n\n/**\n * The listener has been told to explicitly disconnect and not reconnect.\n * This is a rare situation, but may occur if the API knows reconnect attempts will fail,\n * eg in the case of a deleted dataset, a blocked project or similar events.\n *\n * Note that this is not treated as an error on the observable, but will complete the observable.\n *\n * @public\n */\nexport declare type DisconnectEvent = {\n type: 'disconnect'\n reason: string\n}\n\ndeclare type DocIdParam<\n TParamConfig extends {\n docIdRequired: boolean\n } = {\n docIdRequired: false\n },\n> = TParamConfig['docIdRequired'] extends true\n ? {\n documentId: string\n }\n : {\n /**\n * If omitted, implicitly uses the documentId of the instruction target\n */\n documentId?: string\n }\n\n/**\n *\n * Includes a LLM-friendly version of the document in the instruction\n *\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following document value:\\n $document \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * document: {\n * type: 'document',\n * },\n * },\n * target: {path: 'keywords' }\n * })\n * ```\n *\n * @beta\n * */\nexport declare type DocumentAgentActionParam<\n TParamConfig extends {\n docIdRequired: boolean\n } = {\n docIdRequired: false\n },\n> = {\n type: 'document'\n} & DocIdParam<TParamConfig>\n\n/** @internal */\nexport declare type EditableReleaseDocument = Omit<\n PartialExcept<ReleaseDocument, '_id'>,\n 'metadata' | '_type'\n> & {\n _id: string\n metadata: Partial<ReleaseDocument['metadata']>\n}\n\n/**\n * Modifies an existing draft document.\n * It applies the given patch to the document referenced by draftId.\n * If there is no such document then one is created using the current state of the published version and then that is updated accordingly.\n *\n * @public\n */\nexport declare type EditAction = {\n actionType: 'sanity.action.document.edit'\n /**\n * Draft document ID to edit\n */\n draftId: string\n /**\n * Published document ID to create draft from, if draft does not exist\n */\n publishedId: string\n /**\n * Patch operations to apply\n */\n patch: PatchOperations\n}\n\n/**\n * Edits an existing release, updating the metadata.\n *\n * @public\n */\nexport declare interface EditReleaseAction {\n actionType: 'sanity.action.release.edit'\n releaseId: string\n patch: PatchOperations\n}\n\n/** @public */\nexport declare interface ErrorProps {\n message: string\n response: Any\n statusCode: number\n responseBody: Any\n details: Any\n}\n\n/**\n * @internal\n */\nexport declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name>\n\n/**\n * @internal\n */\nexport declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>\n\n/**\n * A string constant containing the experimental API version warning message.\n * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.\n *\n * @example\n * ```typescript\n * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'\n *\n * const client = createClient({\n * projectId: 'your-project-id',\n * dataset: 'production',\n * apiVersion: 'vX', // experimental version\n * ignoreWarnings: EXPERIMENTAL_API_WARNING\n * })\n * ```\n *\n * @public\n */\nexport declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'\n\n/**\n *\n *\n * Includes a LLM-friendly version of the field value in the instruction\n *\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following field value:\\n $pte \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * pte: {\n * type: 'field',\n * path: ['pteField'],\n * },\n * },\n * target: {path: 'keywords' }\n * })\n *\n * ```\n *\n * @beta\n * */\nexport declare type FieldAgentActionParam<\n TParamConfig extends {\n docIdRequired: boolean\n } = {\n docIdRequired: false\n },\n> = {\n type: 'field'\n /**\n * Examples: 'title', ['array', \\{_key: 'arrayItemKey'\\}, 'field']\n */\n path: AgentActionPathSegment | AgentActionPath\n} & DocIdParam<TParamConfig>\n\n/** @public */\nexport declare type FilterDefault = (props: {\n /**\n * The path to the value in the source document, for example if you queried for a document like this:\n * `*[_type == \"author\"][0]{\"slug\": slug.current}`\n * Then the `sourcePath` for `result.slug` would be `['slug', 'current']`.\n *\n */\n sourcePath: ContentSourceMapParsedPath\n /**\n * If `sourcePath` alone isn't enough to tell you if it's safe to contain stega strings, then you can use `sourceDocument`\n * for additional metadata.\n * It'll always have a `_type` property, which can be used to trace it to the Studio Schema that were used initially.\n * It also has `_id` to help you debug and look at the whole document when troubleshooting.\n * Finally, if the document origins in a Cross Dataset Reference you'll also have `_projectId` and `_dataset` properties to help you trace it.\n */\n sourceDocument: ContentSourceMapDocuments_2[number]\n /**\n * If you don't colocate your Studio Schemas with your GROQ queries it might be hard to make sense of `sourcePath`,\n * as it operates on the original shape of a document.\n * In that case `resultPath` can be used, as it mirrors the path to the value in the result.\n * For example in a query like this:\n * `*[_type == \"author\"][0]{\"slug\": slug.current}`\n * The `resultPath` for `result.slug` would be `['slug']`, while `sourcePath` will be `['slug', 'current']`.\n */\n resultPath: ContentSourceMapParsedPath\n /**\n * You can also use your own string validation logic to determine if it's safe.\n */\n value: string\n /**\n * If you want to keep the default filtering behavior, but only override it for a specific path, you can use `filterDefault` to do that.\n * For example, here all \"icon\" documents in a Page Builder skips encoding:\n * ```ts\n {\n filter: (props) => {\n switch (props.sourceDocument._type) {\n case 'icon':\n return false\n default:\n return props.filterDefault(props)\n }\n }\n }\n * ```\n */\n filterDefault: FilterDefault\n}) => boolean\n\n/** @public */\nexport declare interface FilteredResponseQueryOptions extends ResponseQueryOptions {\n filterResponse?: true\n}\n\n/** @internal */\nexport declare type FirstDocumentIdMutationOptions = BaseMutationOptions & {\n returnFirst?: true\n returnDocuments: false\n}\n\n/** @internal */\nexport declare type FirstDocumentMutationOptions = BaseMutationOptions & {\n returnFirst?: true\n returnDocuments?: true\n}\n\n/**\n * Fit / resize modes accepted for thumbnail params.\n * @public\n */\nexport declare type FitMode = 'preserve' | 'stretch' | 'crop' | 'smartcrop' | 'pad'\n\n/**\n * Formats a GROQ query parse error into a human-readable string.\n *\n * @param error - The error object containing details about the parse error.\n * @param tag - An optional tag to include in the error message.\n * @returns A formatted error message string.\n * @public\n */\nexport declare function formatQueryParseError(error: QueryParseError, tag?: string | null): string\n\n/** @beta */\ndeclare type GenerateAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (\n | GenerateExistingDocumentRequest\n | GenerateTargetDocumentRequest<T>\n) &\n GenerateRequestBase &\n AgentActionAsync\n\n/**\n * Instruction for an existing document.\n * @beta\n */\ndeclare interface GenerateExistingDocumentRequest {\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n documentId: string\n targetDocument?: never\n}\n\n/** @beta */\nexport declare type GenerateInstruction<T extends Record<string, Any> = Record<string, Any>> =\n | GenerateSyncInstruction<T>\n | GenerateAsyncInstruction<T>\n\n/** @beta */\nexport declare type GenerateOperation = 'set' | 'append' | 'mixed'\n\n/** @beta */\ndeclare interface GenerateRequestBase extends AgentActionRequestBase {\n /** schemaId as reported by sanity deploy / sanity schema store */\n schemaId: string\n /**\n * Instruct the LLM how it should generate content. Be as specific and detailed as needed.\n *\n * The LLM only has access to information in the instruction, plus the target schema.\n *\n * String template with support for $variable from `instructionParams`.\n * */\n instruction: string\n /**\n * param values for the string template, keys are the variable name, ie if the template has \"$variable\", one key must be \"variable\"\n *\n * ### Examples\n *\n * #### Constant\n *\n * ##### Shorthand\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nGenerate the full article.',\n * instructionParams: {\n * topic: 'Grapefruit'\n * },\n * })\n * ```\n * ##### Object-form\n *\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nGenerate the full article.',\n * instructionParams: {\n * topic: {\n * type: 'constant',\n * value: 'Grapefruit'\n * },\n * },\n * })\n * ```\n * #### Field\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following field value:\\n $pte \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * pte: {\n * type: 'field',\n * path: ['pteField'],\n * },\n * },\n * target: {path: 'keywords' }\n * })\n * ```\n * #### Document\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following document value:\\n $document \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * document: {\n * type: 'document',\n * },\n * },\n * target: {path: 'keywords' }\n * })\n * ```\n *\n * #### GROQ\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following list of titles:\\n $list \\n ---\\nGenerate a similar title.',\n * instructionParams: {\n * list: {\n * type: 'groq',\n * query: '* [_type==$type].title',\n * params: {type: 'article'}\n * },\n * },\n * target: {path: 'title' }\n * })\n * ```\n * */\n instructionParams?: AgentActionParams\n /**\n * Target defines which parts of the document will be affected by the instruction.\n * It can be an array, so multiple parts of the document can be separately configured in detail.\n *\n * Omitting target implies that the document itself is the root.\n *\n * Notes:\n * - instruction can only affect fields up to `maxPathDepth`\n * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.\n * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)\n *\n * ## Generating images\n *\n * Generate will generate images the same was as AI Assist, for images that have been configured using\n * [AI Assist schema options](https://github.com/sanity-io/assist/tree/main/plugin#image-generation).\n *\n * To generate images _without_ changing the schema, directly target an image asset path.\n *\n * For example, all the following will generate an image into the provided asset:\n * * `target: {path: ['image', 'asset'] }`\n * * `target: {path: 'image', include: ['asset'] }`\n *\n * Image generation can be combined with regular content targets:\n * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`\n *\n * Since Generate happens in a single LLM pass, the image will be contextually related to other generated content.\n * @see AgentActionRequestBase#conditionalPaths\n */\n target?: GenerateTarget | GenerateTarget[]\n}\n\n/** @beta */\ndeclare type GenerateSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (\n | GenerateExistingDocumentRequest\n | GenerateTargetDocumentRequest<T>\n) &\n GenerateRequestBase &\n AgentActionSync\n\n/** @beta */\nexport declare interface GenerateTarget extends AgentActionTarget {\n /**\n * Sets the default operation for all paths in the target.\n * Generate runs in `'mixed'` operation mode by default:\n * Changes are set in all non-array fields, and append to all array fields.\n *\n * ### Operation types\n * - `'set'` – an *overwriting* operation, and replaces the full field value.\n * - `'append'`:\n * – array fields: appends new items to the end of the array,\n * - string fields: '\"existing content\" \"new content\"'\n * - text fields: '\"existing content\"\\\\n\"new content\"'\n * - number fields: existing + new\n * - other field types not mentioned will set instead (dates, url)\n * - `'mixed'` – (default) sets non-array fields, and appends to array fields\n *\n * The default operation can be overridden on a per-path basis using `include`.\n *\n * Nested fields inherit the operation specified by their parent and falls back to the\n * top level target operation if not otherwise specified.\n *\n * Use `include` to change the `operation` of individual fields or items.\n *\n * #### Appending in the middle of arrays\n * `target: {path: ['array'], operation: 'append'}` will append the output of the instruction to the end of the array.\n *\n * To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append'}`.\n * Here, the output of the instruction will be appended after the array item with key `'appendAfterKey'`.\n *\n * @see #AgentActionTargetInclude.operation\n * @see #include\n * @see #AgentActionTargetInclude.include\n * @see #AgentActionSchema.forcePublishedWrite\n */\n operation?: GenerateOperation\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n *\n * When `include` is specified, only segments explicitly listed will be included.\n *\n * Fields or array items not on the include list, are implicitly excluded.\n */\n include?: (AgentActionPathSegment | GenerateTargetInclude)[]\n}\n\n/** @beta */\nexport declare type GenerateTargetDocument<T extends Record<string, Any> = Record<string, Any>> =\n | {\n operation: 'edit'\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n _id: string\n }\n | {\n operation: 'create'\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n _id?: string\n _type: string\n initialValues?: T\n }\n | {\n operation: 'createIfNotExists'\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n _id: string\n _type: string\n initialValues?: T\n }\n | {\n operation: 'createOrReplace'\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n _id: string\n _type: string\n initialValues?: T\n }\n\n/**\n * Instruction to create a new document\n * @beta\n */\ndeclare interface GenerateTargetDocumentRequest<\n T extends Record<string, Any> = Record<string, Any>,\n> {\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n targetDocument: GenerateTargetDocument<T>\n documentId?: never\n}\n\n/** @beta */\nexport declare interface GenerateTargetInclude extends AgentActionTargetInclude {\n /**\n * Sets the operation for this path, and all its children.\n * This overrides any operation set parents or the root target.\n * @see #GenerateTarget.operation\n * @see #include\n */\n operation?: GenerateOperation\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n *\n * When `include` is specified, only segments explicitly listed will be included.\n *\n * Fields or array items not on the include list, are implicitly excluded.\n */\n include?: (AgentActionPathSegment | GenerateTargetInclude)[]\n}\n\n/**\n * Includes a LLM-friendly version of GROQ query result in the instruction\n *\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following list of titles:\\n $list \\n ---\\nGenerate a similar title.',\n * instructionParams: {\n * list: {\n * type: 'groq',\n * query: '* [_type==$type].title',\n * params: {type: 'article'}\n * },\n * },\n * target: {path: 'title' }\n * })\n * ```\n * @beta\n * */\nexport declare interface GroqAgentActionParam {\n type: 'groq'\n query: string\n params?: Record<string, string>\n perspective?: ClientPerspective_2\n}\n\n/**\n * Shared properties for HTTP errors (eg both ClientError and ServerError)\n * Use `isHttpError` for type narrowing and accessing response properties.\n *\n * @public\n */\nexport declare interface HttpError {\n statusCode: number\n message: string\n response: {\n body: unknown\n url: string\n method: string\n headers: Record<string, string>\n statusCode: number\n statusMessage: string | null\n }\n}\n\n/** @public */\nexport declare type HttpRequest = {\n (options: RequestOptions, requester: Requester): ReturnType<Requester>\n}\n\n/** @public */\nexport declare type HttpRequestEvent<T = unknown> = ResponseEvent<T> | ProgressEvent_2\n\n/** @public */\nexport declare type IdentifiedSanityDocumentStub<\n T extends Record<string, Any> = Record<string, Any>,\n> = {\n [P in keyof T]: T[P]\n} & {\n _id: string\n} & SanityDocumentStub\n\n/**\n *\n * @see #TransformOperation\n * @beta\n */\nexport declare type ImageDescriptionOperation = {\n type: 'image-description'\n /**\n * When omitted, parent image value will be inferred from the arget path.\n *\n * When specified, the `sourcePath` should be a path to an image (or image asset) field:\n * - `['image']`\n * - `['wrapper', 'mainImage']`\n * - `['heroImage', 'asset'] // the asset segment is optional, but supported`\n */\n sourcePath?: AgentActionPath\n} & (\n | {\n /**\n * When omitted, parent image value will be inferred from the target path.\n *\n * When specified, the `sourcePath` should be a path to an image (or image asset) field:\n * - `['image']`\n * - `['wrapper', 'mainImage']`\n * - `['heroImage', 'asset'] // the asset segment is optional, but supported`\n *\n * Incompatible with `imageUrl`\n *\n */\n sourcePath?: AgentActionPath\n imageUrl?: never\n }\n | {\n /**\n * When specified, the image source to be described will be fetched from the URL.\n *\n * Incompatible with `sourcePath`\n */\n imageUrl?: `https://${string}`\n sourcePath?: never\n }\n)\n\n/** @public */\nexport declare type ImportReleaseAction =\n | {\n actionType: 'sanity.action.release.import'\n attributes: IdentifiedSanityDocumentStub\n releaseId: string\n ifExists: 'fail' | 'ignore' | 'replace'\n }\n | {\n actionType: 'sanity.action.release.import'\n document: IdentifiedSanityDocumentStub\n releaseId: string\n ifExists: 'fail' | 'ignore' | 'replace'\n }\n\n/** @public */\nexport declare interface InitializedClientConfig extends ClientConfig {\n apiHost: string\n apiVersion: string\n useProjectHostname: boolean\n useCdn: boolean\n /**\n * @deprecated Internal, don't use\n */\n isDefaultApi: boolean\n /**\n * @deprecated Internal, don't use\n */\n url: string\n /**\n * @deprecated Internal, don't use\n */\n cdnUrl: string\n /**\n * The fully initialized stega config, can be used to check if stega is enabled\n */\n stega: InitializedStegaConfig\n /**\n * Default headers to include with all requests\n *\n * @remarks request-specific headers will override any default headers with the same name.\n */\n headers?: Record<string, string>\n}\n\n/** @public */\nexport declare type InitializedStegaConfig = Omit<StegaConfig, StegaConfigRequiredKeys> &\n Required<Pick<StegaConfig, StegaConfigRequiredKeys>>\n\n/** @internal */\nexport declare type InsertPatch =\n | {\n before: string\n items: Any[]\n }\n | {\n after: string\n items: Any[]\n }\n | {\n replace: string\n items: Any[]\n }\n\n/**\n * Checks if the provided error is an HTTP error.\n *\n * @param error - The error to check.\n * @returns `true` if the error is an HTTP error, `false` otherwise.\n * @public\n */\nexport declare function isHttpError(error: unknown): error is HttpError\n\n/** @internal */\nexport declare function isQueryParseError(error: object): error is QueryParseError\n\n/**\n * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.\n *\n * @param query - GROQ-filter to listen to changes for\n * @param params - Optional query parameters\n * @param options - Optional listener options\n * @public\n */\nexport declare function _listen<R extends Record<string, Any> = Record<string, Any>>(\n this: SanityClient | ObservableSanityClient,\n query: string,\n params?: ListenParams,\n): Observable<MutationEvent<R>>\n\n/**\n * Set up a listener that will be notified when mutations occur on documents matching the provided query/filter.\n *\n * @param query - GROQ-filter to listen to changes for\n * @param params - Optional query parameters\n * @param options - Optional listener options\n * @public\n */\nexport declare function _listen<\n R extends Record<string, Any> = Record<string, Any>,\n Opts extends ListenOptions = ListenOptions,\n>(\n this: SanityClient | ObservableSanityClient,\n query: string,\n params?: ListenParams,\n options?: Opts,\n): Observable<ListenEventFromOptions<R, Opts>>\n\n/** @public */\nexport declare type ListenEvent<R extends Record<string, Any>> =\n | MutationEvent<R>\n | ReconnectEvent\n | WelcomeEvent\n | OpenEvent\n\n/**\n * Maps a ListenOptions object and returns the Listen events opted for, e.g:\n * ```\n * type Test = ListenEventFromOptions<Doc, {events: ['welcome', 'mutation']}>\n * // ^? WelcomeEvent | MutationEvent<Doc>\n * ```\n *\n * @public\n */\ndeclare type ListenEventFromOptions<\n R extends Record<string, Any> = Record<string, Any>,\n Opts extends ListenOptions | undefined = undefined,\n> = Opts extends ListenOptions\n ? Opts['events'] extends ListenEventName[]\n ? MapListenEventNamesToListenEvents<R, Opts['events']>\n : ListenEvent<R>\n : MutationEvent<R>\n\n/** @public */\nexport declare type ListenEventName =\n /** A mutation was performed */\n | 'mutation'\n /** The listener has been (re)established */\n | 'welcome'\n /** The listener has been disconnected, and a reconnect attempt is scheduled */\n | 'reconnect'\n /**\n * The listener connection has been established\n * note: it's usually a better option to use the 'welcome' event\n */\n | 'open'\n\n/** @public */\nexport declare interface ListenOptions {\n /**\n * Whether or not to include the resulting document in addition to the mutations performed.\n * If you do not need the actual document, set this to `false` to reduce bandwidth usage.\n * The result will be available on the `.result` property of the events.\n * @defaultValue `true`\n */\n includeResult?: boolean\n /**\n * Whether or not to include the mutations that was performed.\n * If you do not need the mutations, set this to `false` to reduce bandwidth usage.\n * @defaultValue `true`\n */\n includeMutations?: boolean\n /**\n * Whether or not to include the document as it looked before the mutation event.\n * The previous revision will be available on the `.previous` property of the events,\n * and may be `null` in the case of a new document.\n * @defaultValue `false`\n */\n includePreviousRevision?: boolean\n includeAllVersions?: boolean\n /**\n * Whether events should be sent as soon as a transaction has been committed (`transaction`, default),\n * or only after they are available for queries (query). Note that this is on a best-effort basis,\n * and listeners with `query` may in certain cases (notably with deferred transactions) receive events\n * that are not yet visible to queries.\n *\n * @defaultValue `'transaction'`\n */\n visibility?: 'transaction' | 'query'\n /**\n * Array of event names to include in the observable. By default, only mutation events are included.\n *\n * @defaultValue `['mutation']`\n */\n events?: ListenEventName[]\n /**\n * Format of \"effects\", eg the resulting changes of a mutation.\n * Currently only `mendoza` is supported, and (if set) will include `apply` and `revert` arrays\n * in the mutation events under the `effects` property.\n *\n * See {@link https://github.com/sanity-io/mendoza | The mendoza docs} for more info\n *\n * @defaultValue `undefined`\n */\n effectFormat?: 'mendoza'\n /**\n * Optional request tag for the listener. Use to identify the request in logs.\n *\n * @defaultValue `undefined`\n */\n tag?: string\n}\n\n/** @public */\nexport declare type ListenParams = {\n [key: string]: Any\n}\n\n/**\n * @public\n */\nexport declare class LiveClient {\n #private\n constructor(client: SanityClient | ObservableSanityClient)\n /**\n * Requires `apiVersion` to be `2021-03-25` or later.\n */\n events({\n includeDrafts,\n tag: _tag,\n }?: {\n includeDrafts?: boolean\n /**\n * Optional request tag for the listener. Use to identify the request in logs.\n *\n * @defaultValue `undefined`\n */\n tag?: string\n }): Observable<LiveEvent>\n}\n\n/** @public */\nexport declare type LiveEvent =\n | LiveEventRestart\n | LiveEventReconnect\n | LiveEventMessage\n | LiveEventWelcome\n | LiveEventGoAway\n\n/**\n * The `id` field is the position at which the connection was rejected or closed.\n * The `reason` field will specify why the connection rejected/closed.\n * @public\n */\nexport declare interface LiveEventGoAway {\n type: 'goaway'\n id: string\n reason: string\n}\n\n/** @public */\nexport declare interface LiveEventMessage {\n type: 'message'\n id: string\n tags: SyncTag[]\n}\n\n/** @public */\nexport declare interface LiveEventReconnect {\n type: 'reconnect'\n}\n\n/** @public */\nexport declare interface LiveEventRestart {\n type: 'restart'\n id: string\n}\n\n/** @public */\nexport declare interface LiveEventWelcome {\n type: 'welcome'\n}\n\n/** @public */\nexport declare type Logger =\n | typeof console\n | Partial<\n Pick<typeof console, 'debug' | 'error' | 'groupCollapsed' | 'groupEnd' | 'log' | 'table'>\n >\n\n/**\n * Maps an array of listen events names to their corresponding listen event type, e.g:\n * ```\n * type Test = MapListenEventNamesToListenEvents<Doc, ['welcome']>\n * // ^? WelcomeEvent\n * ```\n *\n * @public\n */\ndeclare type MapListenEventNamesToListenEvents<\n R extends Record<string, Any> = Record<string, Any>,\n Events extends ListenEventName[] = ListenEventName[],\n> = Events extends (infer E)[]\n ? E extends 'welcome'\n ? WelcomeEvent\n : E extends 'mutation'\n ? MutationEvent<R>\n : E extends 'reconnect'\n ? ReconnectEvent\n : E extends 'open'\n ? OpenEvent\n : never\n : never\n\n/** @public */\nexport declare type MediaLibraryAssetInstanceIdentifier = string | SanityReference\n\n/**\n * Options for requesting playback info (URLs + optional tokens) for a Media Library video asset.\n *\n * Removed: generic fallback parameters (width, height, fit, format). Supply per‑transformation values instead.\n * Animated transformations intentionally exclude any fit option (not supported by Mux).\n *\n * includeTokens is a client-side flag (not sent to the server) controlling whether\n * returned tokens should be appended to URLs when consumed.\n * @public\n */\nexport declare interface MediaLibraryPlaybackInfoOptions {\n /** Explicit per-video transformation options (thumbnail, animated, storyboard). */\n transformations?: MediaLibraryVideoPlaybackTransformations\n /** Expiration hint for secured/signed URLs (string or number, number will be stringified). */\n expiration?: string | number\n}\n\n/** @internal */\nexport declare class MediaLibraryVideoClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * Get video playback information for a media library asset\n *\n * @param assetIdentifier - Asset instance identifier (GDR, video-prefixed ID, or container ID)\n * @param options - Options for transformations and expiration\n */\n getPlaybackInfo(\n assetIdentifier: MediaLibraryAssetInstanceIdentifier,\n options?: MediaLibraryPlaybackInfoOptions,\n ): Promise<VideoPlaybackInfo>\n}\n\n/**\n * Video-specific playback transformation option groups.\n * Only explicitly provided values are serialized into query parameters.\n * @public\n */\nexport declare interface MediaLibraryVideoPlaybackTransformations {\n /** Static thumbnail (single frame) options. */\n thumbnail?: ThumbnailTransformOptions\n /** Animated preview options (GIF / animated WebP). */\n animated?: AnimatedTransformOptions\n /** Storyboard (contact sheet) options. */\n storyboard?: StoryboardTransformOptions\n}\n\n/**\n * @public\n * The server sent an `error`-event to tell the client that an unexpected error has happened.\n */\nexport declare class MessageError extends Error {\n readonly name = 'MessageError'\n readonly data?: unknown\n constructor(message: string, data: unknown, options?: ErrorOptions)\n}\n\n/**\n * @public\n * An error occurred while parsing the message sent by the server as JSON. Should normally not happen.\n */\nexport declare class MessageParseError extends Error {\n readonly name = 'MessageParseError'\n}\n\n/** @internal */\nexport declare interface MultipleActionResult {\n transactionId: string\n}\n\n/** @internal */\nexport declare interface MultipleMutationResult {\n transactionId: string\n documentIds: string[]\n results: {\n id: string\n operation: MutationOperation\n }[]\n}\n\n/** @public */\nexport declare type Mutation<R extends Record<string, Any> = Record<string, Any>> =\n | {\n create: SanityDocumentStub<R>\n }\n | {\n createOrReplace: IdentifiedSanityDocumentStub<R>\n }\n | {\n createIfNotExists: IdentifiedSanityDocumentStub<R>\n }\n | {\n delete: MutationSelection\n }\n | {\n patch: PatchMutationOperation\n }\n\n/** @internal */\nexport declare interface MutationError {\n type: 'mutationError'\n description: string\n items?: MutationErrorItem[]\n}\n\n/** @internal */\nexport declare interface MutationErrorItem {\n error: {\n type: string\n description: string\n value?: unknown\n }\n}\n\n/**\n * A mutation was performed. Note that when updating multiple documents in a transaction,\n * each document affected will get a separate mutation event.\n *\n * @public\n */\nexport declare type MutationEvent<R extends Record<string, Any> = Record<string, Any>> = {\n type: 'mutation'\n /**\n * The ID of the document that was affected\n */\n documentId: string\n /**\n * A unique ID for this event\n */\n eventId: string\n /**\n * The user ID of the user that performed the mutation\n */\n identity: string\n /**\n * An array of mutations that were performed. Note that this can differ slightly from the\n * mutations sent to the server, as the server may perform some mutations automatically.\n */\n mutations: Mutation[]\n /**\n * The revision ID of the document before the mutation was performed\n */\n previousRev?: string\n /**\n * The revision ID of the document after the mutation was performed\n */\n resultRev?: string\n /**\n * The document as it looked after the mutation was performed. This is only included if\n * the listener was configured with `includeResult: true`.\n */\n result?: SanityDocument<R>\n /**\n * The document as it looked before the mutation was performed. This is only included if\n * the listener was configured with `includePreviousRevision: true`.\n */\n previous?: SanityDocument<R> | null\n /**\n * The effects of the mutation, if the listener was configured with `effectFormat: 'mendoza'`.\n * Object with `apply` and `revert` arrays, see {@link https://github.com/sanity-io/mendoza}.\n */\n effects?: {\n apply: unknown[]\n revert: unknown[]\n }\n /**\n * A timestamp for when the mutation was performed\n */\n timestamp: string\n /**\n * The transaction ID for the mutation\n */\n transactionId: string\n /**\n * The type of transition the document went through.\n *\n * - `update` means the document was previously part of the subscribed set of documents,\n * and still is.\n * - `appear` means the document was not previously part of the subscribed set of documents,\n * but is now. This can happen both on create or if updating to a state where it now matches\n * the filter provided to the listener.\n * - `disappear` means the document was previously part of the subscribed set of documents,\n * but is no longer. This can happen both on delete or if updating to a state where it no\n * longer matches the filter provided to the listener.\n */\n transition: 'update' | 'appear' | 'disappear'\n /**\n * Whether the change that triggered this event is visible to queries (query) or only to\n * subsequent transactions (transaction). The listener client can specify a preferred visibility\n * through the `visibility` parameter on the listener, but this is only on a best-effort basis,\n * and may yet not be accurate.\n */\n visibility: 'query' | 'transaction'\n /**\n * The total number of events that will be sent for this transaction.\n * Note that this may differ from the amount of _documents_ affected by the transaction, as this\n * number only includes the documents that matches the given filter.\n *\n * This can be useful if you need to perform changes to all matched documents atomically,\n * eg you would wait for `transactionTotalEvents` events with the same `transactionId` before\n * applying the changes locally.\n */\n transactionTotalEvents: number\n /**\n * The index of this event within the transaction. Note that events may be delivered out of order,\n * and that the index is zero-based.\n */\n transactionCurrentEvent: number\n}\n\n/** @internal */\nexport declare type MutationOperation = 'create' | 'delete' | 'update' | 'none'\n\n/** @internal */\nexport declare type MutationSelection =\n | {\n query: string\n params?: MutationSelectionQueryParams\n }\n | {\n id: string | string[]\n }\n\n/** @internal */\nexport declare type MutationSelectionQueryParams = {\n [key: string]: Any\n}\n\n/** @public */\ndeclare class ObservableAgentsActionClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * Run an instruction to generate content in a target document.\n * @param request - instruction request\n */\n generate<DocumentShape extends Record<string, Any>>(\n request: GenerateInstruction<DocumentShape>,\n ): Observable<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n /**\n * Transform a target document based on a source.\n * @param request - translation request\n */\n transform<DocumentShape extends Record<string, Any>>(\n request: TransformDocument<DocumentShape>,\n ): Observable<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n /**\n * Translate a target document based on a source.\n * @param request - translation request\n */\n translate<DocumentShape extends Record<string, Any>>(\n request: TranslateDocument<DocumentShape>,\n ): Observable<\n (typeof request)['async'] extends true\n ? {\n _id: string\n }\n : IdentifiedSanityDocumentStub & DocumentShape\n >\n}\n\n/** @internal */\nexport declare class ObservableAssetsClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * Uploads a file asset to the configured dataset\n *\n * @param assetType - Asset type (file)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file',\n body: UploadBody,\n options?: UploadClientConfig,\n ): Observable<\n HttpRequestEvent<{\n document: SanityAssetDocument\n }>\n >\n /**\n * Uploads an image asset to the configured dataset\n *\n * @param assetType - Asset type (image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'image',\n body: UploadBody,\n options?: UploadClientConfig,\n ): Observable<\n HttpRequestEvent<{\n document: SanityImageAssetDocument\n }>\n >\n /**\n * Uploads a file or an image asset to the configured dataset\n *\n * @param assetType - Asset type (file/image)\n * @param body - Asset content - can be a browser File instance, a Blob, a Node.js Buffer instance or a Node.js ReadableStream.\n * @param options - Options to use for the upload\n */\n upload(\n assetType: 'file' | 'image',\n body: UploadBody,\n options?: UploadClientConfig,\n ): Observable<\n HttpRequestEvent<{\n document: SanityAssetDocument | SanityImageAssetDocument\n }>\n >\n}\n\n/** @internal */\nexport declare class ObservableDatasetsClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * Create a new dataset with the given name\n *\n * @param name - Name of the dataset to create\n * @param options - Options for the dataset\n */\n create(\n name: string,\n options?: {\n aclMode?: DatasetAclMode\n },\n ): Observable<DatasetResponse>\n /**\n * Edit a dataset with the given name\n *\n * @param name - Name of the dataset to edit\n * @param options - New options for the dataset\n */\n edit(\n name: string,\n options?: {\n aclMode?: DatasetAclMode\n },\n ): Observable<DatasetResponse>\n /**\n * Delete a dataset with the given name\n *\n * @param name - Name of the dataset to delete\n */\n delete(name: string): Observable<{\n deleted: true\n }>\n /**\n * Fetch a list of datasets for the configured project\n */\n list(): Observable<DatasetsResponse>\n}\n\n/** @internal */\nexport declare class ObservableMediaLibraryVideoClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * Get video playback information for a media library asset\n *\n * @param assetIdentifier - Asset instance identifier (GDR, video-prefixed ID, or container ID)\n * @param options - Options for transformations and expiration\n */\n getPlaybackInfo(\n assetIdentifier: MediaLibraryAssetInstanceIdentifier,\n options?: MediaLibraryPlaybackInfoOptions,\n ): Observable<VideoPlaybackInfo>\n}\n\n/** @public */\nexport declare class ObservablePatch extends BasePatch {\n #private\n constructor(\n selection: PatchSelection,\n operations?: PatchOperations,\n client?: ObservableSanityClient,\n )\n /**\n * Clones the patch\n */\n clone(): ObservablePatch\n /**\n * Commit the patch, returning an observable that produces the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any> = Record<string, Any>>(\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Commit the patch, returning an observable that produces an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any> = Record<string, Any>>(\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Commit the patch, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>\n /**\n * Commit the patch, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>\n /**\n * Commit the patch, returning an observable that produces the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any> = Record<string, Any>>(\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n}\n\n/** @public */\nexport declare type ObservablePatchBuilder = (patch: ObservablePatch) => ObservablePatch\n\n/** @internal */\nexport declare class ObservableProjectsClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * Fetch a list of projects the authenticated user has access to.\n *\n * @param options - Options for the list request\n * - `includeMembers` - Whether to include members in the response (default: true)\n * - `organizationId` - ID of the organization to fetch projects for\n */\n list(options?: {includeMembers?: true; organizationId?: string}): Observable<SanityProject[]>\n list(options?: {\n includeMembers?: false\n organizationId?: string\n }): Observable<Omit<SanityProject, 'members'>[]>\n /**\n * Fetch a project by project ID\n *\n * @param projectId - ID of the project to fetch\n */\n getById(projectId: string): Observable<SanityProject>\n}\n\n/** @public */\ndeclare class ObservableReleasesClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * @public\n *\n * Retrieve a release by id.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to retrieve.\n * @param options - Additional query options including abort signal and query tag.\n * @returns An observable that resolves to the release document {@link ReleaseDocument}.\n *\n * @example Retrieving a release by id\n * ```ts\n * client.observable.releases.get({releaseId: 'my-release'}).pipe(\n * tap((release) => console.log(release)),\n * // {\n * // _id: '_.releases.my-release',\n * // name: 'my-release'\n * // _type: 'system.release',\n * // metadata: {releaseType: 'asap'},\n * // _createdAt: '2021-01-01T00:00:00.000Z',\n * // ...\n * // }\n * ).subscribe()\n * ```\n */\n get(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: {\n signal?: AbortSignal\n tag?: string\n },\n ): Observable<ReleaseDocument | undefined>\n /**\n * @public\n *\n * Creates a new release under the given id, with metadata.\n *\n * @remarks\n * * If no releaseId is provided, a release id will be generated.\n * * If no metadata is provided, then an `undecided` releaseType will be used.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to create.\n * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId` and the release id and metadata.\n *\n * @example Creating a release with a custom id and metadata\n * ```ts\n * const releaseId = 'my-release'\n * const metadata: ReleaseDocument['metadata'] = {\n * releaseType: 'asap',\n * }\n *\n * client.observable.releases.create({releaseId, metadata}).pipe(\n * tap(({transactionId, releaseId, metadata}) => console.log(transactionId, releaseId, metadata)),\n * // {\n * // transactionId: 'transaction-id',\n * // releaseId: 'my-release',\n * // metadata: {releaseType: 'asap'},\n * // }\n * ).subscribe()\n * ```\n *\n * @example Creating a release with generated id and metadata\n * ```ts\n * client.observable.releases.create().pipe(\n * tap(({metadata}) => console.log(metadata)),\n * // {\n * // metadata: {releaseType: 'undecided'},\n * // }\n * ).subscribe()\n * ```\n *\n * @example Creating a release using a custom transaction id\n * ```ts\n * client.observable.releases.create({transactionId: 'my-transaction-id'}).pipe(\n * tap(({transactionId, metadata}) => console.log(transactionId, metadata)),\n * // {\n * // transactionId: 'my-transaction-id',\n * // metadata: {releaseType: 'undecided'},\n * // }\n * ).subscribe()\n * ```\n */\n create(options: BaseActionOptions): Observable<\n SingleActionResult & {\n releaseId: string\n metadata: ReleaseDocument['metadata']\n }\n >\n create(\n release: {\n releaseId?: string\n metadata?: Partial<ReleaseDocument['metadata']>\n },\n options?: BaseActionOptions,\n ): Observable<\n SingleActionResult & {\n releaseId: string\n metadata: ReleaseDocument['metadata']\n }\n >\n /**\n * @public\n *\n * Edits an existing release, updating the metadata.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to edit.\n * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n edit(\n {\n releaseId,\n patch,\n }: {\n releaseId: string\n patch: PatchOperations\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * Publishes all documents in a release at once. For larger releases the effect of the publish\n * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`\n * documents and creation of the corresponding published documents with the new content may\n * take some time.\n *\n * During this period both the source and target documents are locked and cannot be\n * modified through any other means.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to publish.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n publish(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * An archive action removes an active release. The documents that comprise the release\n * are deleted and therefore no longer queryable.\n *\n * While the documents remain in retention the last version can still be accessed using document history endpoint.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to archive.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n archive(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * An unarchive action restores an archived release and all documents\n * with the content they had just prior to archiving.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to unarchive.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n unarchive(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * A schedule action queues a release for publishing at the given future time.\n * The release is locked such that no documents in the release can be modified and\n * no documents that it references can be deleted as this would make the publish fail.\n * At the given time, the same logic as for the publish action is triggered.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to schedule.\n * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n schedule(\n {\n releaseId,\n publishAt,\n }: {\n releaseId: string\n publishAt: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * An unschedule action stops a release from being published.\n * The documents in the release are considered unlocked and can be edited again.\n * This may fail if another release is scheduled to be published after this one and\n * has a reference to a document created by this one.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to unschedule.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n unschedule(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * A delete action removes a published or archived release.\n * The backing system document will be removed from the dataset.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to delete.\n * @param options - Additional action options.\n * @returns An observable that resolves to the `transactionId`.\n */\n delete(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult>\n /**\n * @public\n *\n * Fetch the documents in a release by release id.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to fetch documents for.\n * @param options - Additional mutation options {@link BaseMutationOptions}.\n * @returns An observable that resolves to the documents in the release.\n */\n fetchDocuments(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseMutationOptions,\n ): Observable<RawQueryResponse<SanityDocument[]>>\n}\n\n/** @public */\nexport declare class ObservableSanityClient {\n #private\n assets: ObservableAssetsClient\n datasets: ObservableDatasetsClient\n live: LiveClient\n mediaLibrary: {\n video: ObservableMediaLibraryVideoClient\n }\n projects: ObservableProjectsClient\n users: ObservableUsersClient\n agent: {\n action: ObservableAgentsActionClient\n }\n releases: ObservableReleasesClient\n /**\n * Instance properties\n */\n listen: typeof _listen\n constructor(httpRequest: HttpRequest, config?: ClientConfig)\n /**\n * Clone the client - returns a new instance\n */\n clone(): ObservableSanityClient\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientConfig>): this\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientConfig>): ObservableSanityClient\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams = QueryWithoutParams,\n const G extends string = string,\n >(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Optional request options\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams | QueryParams = QueryParams,\n const G extends string = string,\n >(\n query: G,\n params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,\n options?: FilteredResponseQueryOptions,\n ): Observable<ClientReturn<G, R>>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams | QueryParams = QueryParams,\n const G extends string = string,\n >(\n query: string,\n params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,\n options: UnfilteredResponseQueryOptions,\n ): Observable<RawQueryResponse<ClientReturn<G, R>>>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams | QueryParams = QueryParams,\n const G extends string = string,\n >(\n query: G,\n params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,\n options: UnfilteredResponseWithoutQuery,\n ): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>\n /**\n * Fetch a single document with the given ID.\n *\n * @param id - Document ID to fetch\n * @param options - Request options\n */\n getDocument<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options: {\n signal?: AbortSignal\n tag?: string\n releaseId?: string\n includeAllVersions: true\n },\n ): Observable<SanityDocument<R>[]>\n /**\n * Fetch a single document with the given ID.\n *\n * @param id - Document ID to fetch\n * @param options - Request options\n */\n getDocument<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options?: {\n signal?: AbortSignal\n tag?: string\n releaseId?: string\n includeAllVersions?: false\n },\n ): Observable<SanityDocument<R> | undefined>\n /**\n * Fetch multiple documents in one request.\n * Should be used sparingly - performing a query is usually a better option.\n * The order/position of documents is preserved based on the original array of IDs.\n * If any of the documents are missing, they will be replaced by a `null` entry in the returned array\n *\n * @param ids - Document IDs to fetch\n * @param options - Request options\n */\n getDocuments<R extends Record<string, Any> = Record<string, Any>>(\n ids: string[],\n options?: {\n tag?: string\n },\n ): Observable<(SanityDocument<R> | null)[]>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: FirstDocumentIdMutationOptions,\n ): Observable<SingleMutationResult>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: AllDocumentIdsMutationOptions,\n ): Observable<MultipleMutationResult>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentIdMutationOptions,\n ): Observable<SingleMutationResult>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentIdsMutationOptions,\n ): Observable<MultipleMutationResult>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to an array containing the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentIdMutationOptions,\n ): Observable<SingleMutationResult>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to a mutation result object containing the created document ID.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentIdsMutationOptions,\n ): Observable<MultipleMutationResult>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns an observable that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * @public\n *\n * Creates a new version of a published document.\n *\n * @remarks\n * * Requires a document with a `_type` property.\n * * Creating a version with no `releaseId` will create a new draft version of the published document.\n * * If the `document._id` is defined, it should be a draft or release version ID that matches the version ID generated from `publishedId` and `releaseId`.\n * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.\n * * To create a version of an unpublished document, use the `client.create` method.\n *\n * @category Versions\n *\n * @param params - Version action parameters:\n * - `document` - The document to create as a new version (must include `_type`).\n * - `publishedId` - The ID of the published document being versioned.\n * - `releaseId` - The ID of the release to create the version for.\n * @param options - Additional action options.\n * @returns an observable that resolves to the `transactionId`.\n *\n * @example Creating a new version of a published document with a generated version ID\n * ```ts\n * client.observable.createVersion({\n * // The document does not need to include an `_id` property since it will be generated from `publishedId` and `releaseId`\n * document: {_type: 'myDocument', title: 'My Document'},\n * publishedId: 'myDocument',\n * releaseId: 'myRelease',\n * })\n *\n * // The following document will be created:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n * @example Creating a new version of a published document with a specified version ID\n * ```ts\n * client.observable.createVersion({\n * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},\n * // `publishedId` and `releaseId` are not required since `document._id` has been specified\n * })\n *\n * // The following document will be created:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n * @example Creating a new draft version of a published document\n * ```ts\n * client.observable.createVersion({\n * document: {_type: 'myDocument', title: 'My Document'},\n * publishedId: 'myDocument',\n * })\n *\n * // The following document will be created:\n * // {\n * // _id: 'drafts.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n */\n createVersion<R extends Record<string, Any>>(\n args: {\n document: SanityDocumentStub<R>\n publishedId: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n createVersion<R extends Record<string, Any>>(\n args: {\n document: IdentifiedSanityDocumentStub<R>\n publishedId?: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n createVersion(\n args: {\n baseId: string\n releaseId?: string\n publishedId: string\n ifBaseRevisionId?: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to an array containing the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: FirstDocumentIdMutationOptions): Observable<SingleMutationResult>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: AllDocumentIdsMutationOptions): Observable<MultipleMutationResult>\n /**\n * Deletes a document with the given document ID.\n * Returns an observable that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n selection: MutationSelection,\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to an array containing the deleted documents.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n selection: MutationSelection,\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to a mutation result object containing the ID of the first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: FirstDocumentIdMutationOptions,\n ): Observable<SingleMutationResult>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to a mutation result object containing the document IDs that were deleted.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: AllDocumentIdsMutationOptions,\n ): Observable<MultipleMutationResult>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns an observable that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n selection: MutationSelection,\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * @public\n *\n * Deletes the draft or release version of a document.\n *\n * @remarks\n * * Discarding a version with no `releaseId` will discard the draft version of the published document.\n * * If the draft or release version does not exist, any error will throw.\n *\n * @param params - Version action parameters:\n * - `releaseId` - The ID of the release to discard the document from.\n * - `publishedId` - The published ID of the document to discard.\n * @param purge - if `true` the document history is also discarded.\n * @param options - Additional action options.\n * @returns an observable that resolves to the `transactionId`.\n *\n * @example Discarding a release version of a document\n * ```ts\n * client.observable.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})\n * // The document with the ID `versions.myRelease.myDocument` will be discarded.\n * ```\n *\n * @example Discarding a draft version of a document\n * ```ts\n * client.observable.discardVersion({publishedId: 'myDocument'})\n * // The document with the ID `drafts.myDocument` will be discarded.\n * ```\n */\n discardVersion(\n {\n releaseId,\n publishedId,\n }: {\n releaseId?: string\n publishedId: string\n },\n purge?: boolean,\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n /**\n * @public\n *\n * Replaces an existing version document.\n *\n * @remarks\n * * Requires a document with a `_type` property.\n * * If the `document._id` is defined, it should be a draft or release version ID that matches the version ID generated from `publishedId` and `releaseId`.\n * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.\n * * Replacing a version with no `releaseId` will replace the draft version of the published document.\n * * At least one of the **version** or **published** documents must exist.\n *\n * @param params - Version action parameters:\n * - `document` - The new document to replace the version with.\n * - `releaseId` - The ID of the release where the document version is replaced.\n * - `publishedId` - The ID of the published document to replace.\n * @param options - Additional action options.\n * @returns an observable that resolves to the `transactionId`.\n *\n * @example Replacing a release version of a published document with a generated version ID\n * ```ts\n * client.observable.replaceVersion({\n * document: {_type: 'myDocument', title: 'My Document'},\n * publishedId: 'myDocument',\n * releaseId: 'myRelease',\n * })\n *\n * // The following document will be patched:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n * @example Replacing a release version of a published document with a specified version ID\n * ```ts\n * client.observable.replaceVersion({\n * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},\n * // `publishedId` and `releaseId` are not required since `document._id` has been specified\n * })\n *\n * // The following document will be patched:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n * @example Replacing a draft version of a published document\n * ```ts\n * client.observable.replaceVersion({\n * document: {_type: 'myDocument', title: 'My Document'},\n * publishedId: 'myDocument',\n * })\n *\n * // The following document will be patched:\n * // {\n * // _id: 'drafts.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n */\n replaceVersion<R extends Record<string, Any>>(\n args: {\n document: SanityDocumentStub<R>\n publishedId: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n replaceVersion<R extends Record<string, Any>>(\n args: {\n document: IdentifiedSanityDocumentStub<R>\n publishedId?: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n /**\n * @public\n *\n * Used to indicate when a document within a release should be unpublished when\n * the release is run.\n *\n * @remarks\n * * If the published document does not exist, an error will be thrown.\n *\n * @param params - Version action parameters:\n * - `releaseId` - The ID of the release to unpublish the document from.\n * - `publishedId` - The published ID of the document to unpublish.\n * @param options - Additional action options.\n * @returns an observable that resolves to the `transactionId`.\n *\n * @example Unpublishing a release version of a published document\n * ```ts\n * client.observable.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})\n * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.\n * ```\n */\n unpublishVersion(\n {\n releaseId,\n publishedId,\n }: {\n releaseId: string\n publishedId: string\n },\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,\n options: FirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Perform mutation operations against the configured dataset.\n * Returns an observable that resolves to an array of the mutated documents.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,\n options: AllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to a mutation result object containing the document ID of the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,\n options: FirstDocumentIdMutationOptions,\n ): Observable<SingleMutationResult>\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to a mutation result object containing the mutated document IDs.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,\n options: AllDocumentIdsMutationOptions,\n ): Observable<MultipleMutationResult>\n /**\n * Perform mutation operations against the configured dataset\n * Returns an observable that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | ObservablePatch | ObservableTransaction,\n options?: BaseMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param documentId - Document ID to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n * @returns Patch instance - call `.commit()` to perform the operations defined\n */\n patch(documentId: string, operations?: PatchOperations): ObservablePatch\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param documentIds - Array of document IDs to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n * @returns Patch instance - call `.commit()` to perform the operations defined\n */\n patch(documentIds: string[], operations?: PatchOperations): ObservablePatch\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param selection - An object with `query` and optional `params`, defining which document(s) to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n * @returns Patch instance - call `.commit()` to perform the operations defined\n */\n patch(selection: MutationSelection, operations?: PatchOperations): ObservablePatch\n /**\n * Create a new transaction of mutations\n *\n * @param operations - Optional array of mutation operations to initialize the transaction instance with\n */\n transaction<R extends Record<string, Any> = Record<string, Any>>(\n operations?: Mutation<R>[],\n ): ObservableTransaction\n /**\n * Perform action operations against the configured dataset\n *\n * @param operations - Action operation(s) to execute\n * @param options - Action options\n */\n action(\n operations: Action | Action[],\n options?: BaseActionOptions,\n ): Observable<SingleActionResult | MultipleActionResult>\n /**\n * Perform an HTTP request against the Sanity API\n *\n * @param options - Request options\n */\n request<R = Any>(options: RawRequestOptions): Observable<R>\n /**\n * Get a Sanity API URL for the URI provided\n *\n * @param uri - URI/path to build URL for\n * @param canUseCdn - Whether or not to allow using the API CDN for this route\n */\n getUrl(uri: string, canUseCdn?: boolean): string\n /**\n * Get a Sanity API URL for the data operation and path provided\n *\n * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)\n * @param path - Path to append after the operation\n */\n getDataUrl(operation: string, path?: string): string\n}\n\n/** @public */\nexport declare class ObservableTransaction extends BaseTransaction {\n #private\n constructor(operations?: Mutation[], client?: ObservableSanityClient, transactionId?: string)\n /**\n * Clones the transaction\n */\n clone(): ObservableTransaction\n /**\n * Commit the transaction, returning an observable that produces the first mutated document\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any>>(\n options: TransactionFirstDocumentMutationOptions,\n ): Observable<SanityDocument<R>>\n /**\n * Commit the transaction, returning an observable that produces an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any>>(\n options: TransactionAllDocumentsMutationOptions,\n ): Observable<SanityDocument<R>[]>\n /**\n * Commit the transaction, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionFirstDocumentIdMutationOptions): Observable<SingleMutationResult>\n /**\n * Commit the transaction, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionAllDocumentIdsMutationOptions): Observable<MultipleMutationResult>\n /**\n * Commit the transaction, returning an observable that produces a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options?: BaseMutationOptions): Observable<MultipleMutationResult>\n /**\n * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param documentId - Document ID to perform the patch operation on\n * @param patchOps - Operations to perform, or a builder function\n */\n patch(documentId: string, patchOps?: ObservablePatchBuilder | PatchOperations): this\n /**\n * Adds the given patch instance to the transaction.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param patch - ObservablePatch to execute\n */\n patch(patch: ObservablePatch): this\n}\n\n/** @public */\nexport declare class ObservableUsersClient {\n #private\n constructor(client: ObservableSanityClient, httpRequest: HttpRequest)\n /**\n * Fetch a user by user ID\n *\n * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.\n */\n getById<T extends 'me' | string>(\n id: T,\n ): Observable<T extends 'me' ? CurrentSanityUser : SanityUser>\n}\n\n/**\n * The listener connection has been established\n * note: it's usually a better option to use the 'welcome' event\n * @public\n */\nexport declare type OpenEvent = {\n type: 'open'\n}\n\n/** @internal */\nexport declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>\n\n/** @public */\nexport declare class Patch extends BasePatch {\n #private\n constructor(selection: PatchSelection, operations?: PatchOperations, client?: SanityClient)\n /**\n * Clones the patch\n */\n clone(): Patch\n /**\n * Commit the patch, returning a promise that resolves to the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any> = Record<string, Any>>(\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Commit the patch, returning a promise that resolves to an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any> = Record<string, Any>>(\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Commit the patch, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>\n /**\n * Commit the patch, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>\n /**\n * Commit the patch, returning a promise that resolves to the first patched document\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any> = Record<string, Any>>(\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n}\n\n/** @public */\nexport declare type PatchBuilder = (patch: Patch) => Patch\n\n/** @beta */\nexport declare type PatchDocument<T extends Record<string, Any> = Record<string, Any>> =\n | PatchDocumentSync<T>\n | PatchDocumentAsync<T>\n\n/** @beta */\ndeclare type PatchDocumentAsync<T extends Record<string, Any> = Record<string, Any>> = (\n | PatchExistingDocumentRequest\n | PatchTargetDocumentRequest<T>\n) &\n PatchRequestBase &\n AgentActionAsync\n\n/** @beta */\ndeclare type PatchDocumentSync<T extends Record<string, Any> = Record<string, Any>> = (\n | PatchExistingDocumentRequest\n | PatchTargetDocumentRequest<T>\n) &\n PatchRequestBase &\n AgentActionSync\n\n/**\n * Patches an existing document\n * @beta\n */\ndeclare interface PatchExistingDocumentRequest {\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n documentId: string\n targetDocument?: never\n}\n\n/** @internal */\nexport declare type PatchMutationOperation = PatchOperations & MutationSelection\n\n/** @beta */\nexport declare type PatchOperation = 'set' | 'append' | 'mixed' | 'unset'\n\n/** @internal */\nexport declare interface PatchOperations {\n set?: {\n [key: string]: Any\n }\n setIfMissing?: {\n [key: string]: Any\n }\n diffMatchPatch?: {\n [key: string]: Any\n }\n unset?: string[]\n inc?: {\n [key: string]: number\n }\n dec?: {\n [key: string]: number\n }\n insert?: InsertPatch\n ifRevisionID?: string\n}\n\n/** @beta */\ndeclare interface PatchRequestBase extends AgentActionSchema {\n /**\n * Target defines which parts of the document will be affected by the instruction.\n * It can be an array, so multiple parts of the document can be separately configured in detail.\n *\n * Omitting target implies that the document itself is the root.\n *\n * Notes:\n * - instruction can only affect fields up to `maxPathDepth`\n * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.\n * It is therefore an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)\n *\n * @see AgentActionRequestBase#conditionalPaths\n */\n target: PatchTarget | PatchTarget[]\n}\n\n/** @internal */\nexport declare type PatchSelection = string | string[] | MutationSelection\n\n/** @beta */\nexport declare type PatchTarget = {\n /**\n * Determines how the target path will be patched.\n *\n * ### Operation types\n * - `'set'` – an *overwriting* operation: sets the full field value for primitive targets, and merges the provided value with existing values for objects\n * - `'append'`:\n * – array fields: appends new items to the end of the array,\n * - string fields: '\"existing content\" \"new content\"'\n * - text fields: '\"existing content\"\\\\n\"new content\"'\n * - number fields: existing + new\n * - other field types not mentioned will set instead (dates, url)\n * - `'mixed'` – sets non-array fields, and appends to array fields\n * - `'unset'` – removes whatever value is on the target path\n *\n * All operations except unset requires a `value`.\n *\n * #### Appending in the middle of arrays\n * To append to an array, use the 'append' operation, and provide an array value with one or more array items.\n *\n * `target: {path: ['array'], operation: 'append', value: [{_type: 'item' _key: 'a'}]}` will append the items in the value to the existing array.\n *\n * To insert in the middle of the array, use `target: {path: ['array', {_key: 'appendAfterKey'}], operation: 'append', value: [{_type: 'item' _key: 'a'}]}`.\n * Here, `{_type: 'item' _key: 'a'}` will be appended after the array item with key `'appendAfterKey'`\n *\n * It is optional to provide a _key for inserted array items; if one isn't provided, it will be generated.\n */\n operation: PatchOperation\n path: AgentActionPathSegment | AgentActionPath\n} & (\n | {\n operation: 'unset'\n value?: never\n }\n | {\n operation: Exclude<PatchOperation, 'unset'>\n value: AnyNonNullable\n }\n)\n\n/**\n * Create a new document, then patch it\n * @beta\n */\ndeclare interface PatchTargetDocumentRequest<T extends Record<string, Any> = Record<string, Any>> {\n /**\n * @see #AgentActionSchema.forcePublishedWrite\n */\n targetDocument: GenerateTargetDocument<T>\n documentId?: never\n}\n\n/** @public */\ndeclare interface ProgressEvent_2 {\n type: 'progress'\n stage: 'upload' | 'download'\n percent: number\n total?: number\n loaded?: number\n lengthComputable: boolean\n}\nexport {ProgressEvent_2 as ProgressEvent}\n\n/** @internal */\nexport declare class ProjectsClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * Fetch a list of projects the authenticated user has access to.\n *\n * @param options - Options for the list request\n * - `includeMembers` - Whether to include members in the response (default: true)\n * - `organizationId` - ID of the organization to fetch projects for\n */\n list(options?: {includeMembers?: true; organizationId?: string}): Promise<SanityProject[]>\n list(options?: {\n includeMembers?: false\n organizationId?: string\n }): Promise<Omit<SanityProject, 'members'>[]>\n /**\n * Fetch a project by project ID\n *\n * @param projectId - ID of the project to fetch\n */\n getById(projectId: string): Promise<SanityProject>\n}\n\n/**\n * @beta\n */\ndeclare interface PromptJsonResponse<T extends Record<string, Any> = Record<string, Any>> {\n /**\n *\n * When format is 'json', the response will be json according to the instruction.\n * Note: In addition to setting this to 'json', `instruction` MUST include the word 'JSON', or 'json' for this to work.\n */\n format: 'json'\n}\n\n/** @beta */\nexport declare type PromptRequest<T extends Record<string, Any> = Record<string, Any>> = (\n | PromptTextResponse\n | PromptJsonResponse<T>\n) &\n PromptRequestBase\n\n/** @beta */\ndeclare interface PromptRequestBase {\n /**\n * Instruct the LLM how it should generate content. Be as specific and detailed as needed.\n *\n * The LLM only has access to information in the instruction, plus the target schema.\n *\n * String template with support for $variable from `instructionParams`.\n * */\n instruction: string\n /**\n * param values for the string template, keys are the variable name, ie if the template has \"$variable\", one key must be \"variable\"\n *\n * ### Examples\n *\n * #### Constant\n *\n * ##### Shorthand\n * ```ts\n * client.agent.action.prompt({\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nReturns some facts about it',\n * instructionParams: {\n * topic: 'Grapefruit'\n * },\n * })\n * ```\n * ##### Object-form\n *\n * ```ts\n * client.agent.action.prompt({\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nReturns some facts about it.',\n * instructionParams: {\n * topic: {\n * type: 'constant',\n * value: 'Grapefruit'\n * },\n * },\n * })\n * ```\n * #### Field\n * ```ts\n * client.agent.action.prompt({\n * instruction: 'Give the following field value:\\n $pte \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * pte: {\n * type: 'field',\n * path: ['pteField'],\n * documentId: 'someSanityDocId'\n * },\n * },\n * })\n * ```\n * #### Document\n * ```ts\n * client.agent.action.prompt({\n * json: true,\n * instruction: 'Given the following document:$document\\nCreate a JSON string[] array with keywords describing it.',\n * instructionParams: {\n * document: {\n * type: 'document',\n * documentId: 'someSanityDocId'\n * },\n * },\n * })\n * ```\n *\n * #### GROQ\n * ```ts\n * client.agent.action.prompt({\n * instruction: 'Return the best title amongst these: $titles.',\n * instructionParams: {\n * titles: {\n * type: 'groq',\n * query: '* [_type==$type].title',\n * params: {type: 'article'}\n * },\n * },\n * })\n * ```\n * */\n instructionParams?: AgentActionParams<{\n docIdRequired: true\n }>\n /**\n * Controls how much variance the instructions will run with.\n *\n * Value must be in the range [0, 1] (inclusive).\n *\n * Default: 0.3\n */\n temperature?: number\n}\n\ndeclare interface PromptTextResponse {\n /**\n * When format is 'string', the response will be a raw text response to the instruction.\n */\n format?: 'string'\n}\n\n/**\n * Publishes a draft document.\n * If a published version of the document already exists this is replaced by the current draft document.\n * In either case the draft document is deleted.\n * The optional revision id parameters can be used for optimistic locking to ensure\n * that the draft and/or published versions of the document have not been changed by another client.\n *\n * @public\n */\nexport declare type PublishAction = {\n actionType: 'sanity.action.document.publish'\n /**\n * Draft document ID to publish\n */\n draftId: string\n /**\n * Draft revision ID to match\n */\n ifDraftRevisionId?: string\n /**\n * Published document ID to replace\n */\n publishedId: string\n /**\n * Published revision ID to match\n */\n ifPublishedRevisionId?: string\n}\n\n/**\n * Publishes all documents in a release at once.\n *\n * @public\n */\nexport declare interface PublishReleaseAction {\n actionType: 'sanity.action.release.publish'\n releaseId: string\n}\n\n/** @public */\nexport declare type QueryOptions =\n | FilteredResponseQueryOptions\n | UnfilteredResponseQueryOptions\n | UnfilteredResponseWithoutQuery\n\n/** @public */\nexport declare interface QueryParams {\n [key: string]: any\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n body?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n cache?: 'next' extends keyof RequestInit ? never : any\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n filterResponse?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n headers?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n method?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n next?: 'next' extends keyof RequestInit ? never : any\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n perspective?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n query?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n resultSourceMap?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n returnQuery?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n signal?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n stega?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n tag?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n timeout?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n token?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n useCdn?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n lastLiveEventId?: never\n /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */\n cacheMode?: never\n}\n\n/**\n * Returned from the Content Lake API when a query is malformed, usually with a start\n * and end column to indicate where the error occurred, but not always. Can we used to\n * provide a more structured error message to the user.\n *\n * This will be located under the response `error` property.\n *\n * @public\n */\nexport declare interface QueryParseError {\n type: 'queryParseError'\n description: string\n start?: number\n end?: number\n query?: string\n}\n\n/**\n * This type can be used with `client.fetch` to indicate that the query has no GROQ parameters.\n * @public\n */\nexport declare type QueryWithoutParams = Record<string, never> | undefined\n\n/** @public */\nexport declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>\n\n/** @public */\nexport declare interface RawQueryResponse<R> {\n query: string\n ms: number\n result: R\n resultSourceMap?: ContentSourceMap\n /** Requires `apiVersion` to be `2021-03-25` or later. */\n syncTags?: SyncTag[]\n}\n\n/** @internal */\nexport declare interface RawRequestOptions {\n url?: string\n uri?: string\n method?: string\n token?: string\n json?: boolean\n tag?: string\n useGlobalApi?: boolean\n withCredentials?: boolean\n query?: {\n [key: string]: string | string[]\n }\n headers?: {\n [key: string]: string\n }\n timeout?: number\n proxy?: string\n body?: Any\n maxRedirects?: number\n signal?: AbortSignal\n}\n\n/**\n * The listener has been disconnected, and a reconnect attempt is scheduled.\n *\n * @public\n */\nexport declare type ReconnectEvent = {\n type: 'reconnect'\n}\n\n/** @public */\nexport declare type ReleaseAction =\n | CreateReleaseAction\n | EditReleaseAction\n | PublishReleaseAction\n | ArchiveReleaseAction\n | UnarchiveReleaseAction\n | ScheduleReleaseAction\n | UnscheduleReleaseAction\n | DeleteReleaseAction\n | ImportReleaseAction\n\n/** @public */\nexport declare type ReleaseCardinality = 'many' | 'one' | undefined\n\n/** @internal */\nexport declare interface ReleaseDocument extends SanityDocument {\n /**\n * typically\n * `_.releases.<name>`\n */\n _id: string\n /**\n * where a release has _id `_.releases.foo`, the name is `foo`\n */\n name: string\n _type: 'system.release'\n _createdAt: string\n _updatedAt: string\n _rev: string\n state: ReleaseState\n error?: {\n message: string\n }\n finalDocumentStates?: {\n /** Document ID */\n id: string\n }[]\n /**\n * If defined, it takes precedence over the intendedPublishAt, the state should be 'scheduled'\n */\n publishAt?: string\n /**\n * If defined, it provides the time the release was actually published\n */\n publishedAt?: string\n metadata: {\n title?: string\n description?: string\n intendedPublishAt?: string\n releaseType: ReleaseType\n cardinality?: ReleaseCardinality\n }\n}\n\n/**\n * @public\n * @deprecated – The `r`-prefix is not required, use `string` instead\n */\nexport declare type ReleaseId = `r${string}`\n\n/** @public */\ndeclare class ReleasesClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * @public\n *\n * Retrieve a release by id.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to retrieve.\n * @param options - Additional query options including abort signal and query tag.\n * @returns A promise that resolves to the release document {@link ReleaseDocument}.\n *\n * @example Retrieving a release by id\n * ```ts\n * const release = await client.releases.get({releaseId: 'my-release'})\n * console.log(release)\n * // {\n * // _id: '_.releases.my-release',\n * // name: 'my-release'\n * // _type: 'system.release',\n * // metadata: {releaseType: 'asap'},\n * // _createdAt: '2021-01-01T00:00:00.000Z',\n * // ...\n * // }\n * ```\n */\n get(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: {\n signal?: AbortSignal\n tag?: string\n },\n ): Promise<ReleaseDocument | undefined>\n /**\n * @public\n *\n * Creates a new release under the given id, with metadata.\n *\n * @remarks\n * * If no releaseId is provided, a release id will be generated.\n * * If no metadata is provided, then an `undecided` releaseType will be used.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to create.\n * - `metadata` - The metadata to associate with the release {@link ReleaseDocument}.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId` and the release id and metadata.\n *\n * @example Creating a release with a custom id and metadata\n * ```ts\n * const releaseId = 'my-release'\n * const releaseMetadata: ReleaseDocument['metadata'] = {\n * releaseType: 'asap',\n * }\n *\n * const result =\n * await client.releases.create({releaseId, metadata: releaseMetadata})\n * console.log(result)\n * // {\n * // transactionId: 'transaction-id',\n * // releaseId: 'my-release',\n * // metadata: {releaseType: 'asap'},\n * // }\n * ```\n *\n * @example Creating a release with generated id and metadata\n * ```ts\n * const {metadata} = await client.releases.create()\n * console.log(metadata.releaseType) // 'undecided'\n * ```\n *\n * @example Creating a release with a custom transaction id\n * ```ts\n * const {transactionId, metadata} = await client.releases.create({transactionId: 'my-transaction-id'})\n * console.log(metadata.releaseType) // 'undecided'\n * console.log(transactionId) // 'my-transaction-id'\n * ```\n */\n create(options: BaseActionOptions): Promise<\n SingleActionResult & {\n releaseId: string\n metadata: ReleaseDocument['metadata']\n }\n >\n create(\n release: {\n releaseId?: string\n metadata?: Partial<ReleaseDocument['metadata']>\n },\n options?: BaseActionOptions,\n ): Promise<\n SingleActionResult & {\n releaseId: string\n metadata: ReleaseDocument['metadata']\n }\n >\n /**\n * @public\n *\n * Edits an existing release, updating the metadata.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to edit.\n * - `patch` - The patch operation to apply on the release metadata {@link PatchMutationOperation}.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n edit(\n {\n releaseId,\n patch,\n }: {\n releaseId: string\n patch: PatchOperations\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * Publishes all documents in a release at once. For larger releases the effect of the publish\n * will be visible immediately when querying but the removal of the `versions.<releasesId>.*`\n * documents and creation of the corresponding published documents with the new content may\n * take some time.\n *\n * During this period both the source and target documents are locked and cannot be\n * modified through any other means.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to publish.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n publish(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * An archive action removes an active release. The documents that comprise the release\n * are deleted and therefore no longer queryable.\n *\n * While the documents remain in retention the last version can still be accessed using document history endpoint.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to archive.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n archive(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * An unarchive action restores an archived release and all documents\n * with the content they had just prior to archiving.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to unarchive.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n unarchive(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * A schedule action queues a release for publishing at the given future time.\n * The release is locked such that no documents in the release can be modified and\n * no documents that it references can be deleted as this would make the publish fail.\n * At the given time, the same logic as for the publish action is triggered.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to schedule.\n * - `publishAt` - The serialised date and time to publish the release. If the `publishAt` is in the past, the release will be published immediately.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n schedule(\n {\n releaseId,\n publishAt,\n }: {\n releaseId: string\n publishAt: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * An unschedule action stops a release from being published.\n * The documents in the release are considered unlocked and can be edited again.\n * This may fail if another release is scheduled to be published after this one and\n * has a reference to a document created by this one.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to unschedule.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n unschedule(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * A delete action removes a published or archived release.\n * The backing system document will be removed from the dataset.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to delete.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n */\n delete(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult>\n /**\n * @public\n *\n * Fetch the documents in a release by release id.\n *\n * @category Releases\n *\n * @param params - Release action parameters:\n * - `releaseId` - The id of the release to fetch documents for.\n * @param options - Additional mutation options {@link BaseMutationOptions}.\n * @returns A promise that resolves to the documents in the release.\n */\n fetchDocuments(\n {\n releaseId,\n }: {\n releaseId: string\n },\n options?: BaseMutationOptions,\n ): Promise<RawQueryResponse<SanityDocument[]>>\n}\n\n/** @beta */\nexport declare type ReleaseState =\n | 'active'\n | 'archiving'\n | 'unarchiving'\n | 'archived'\n | 'published'\n | 'publishing'\n | 'scheduled'\n | 'scheduling'\n\n/** @internal */\nexport declare type ReleaseType = 'asap' | 'scheduled' | 'undecided'\n\n/**\n * Replaces an existing draft document.\n * At least one of the draft or published versions of the document must exist.\n *\n * @public\n * @deprecated Use {@link ReplaceVersionAction} instead\n */\nexport declare type ReplaceDraftAction = {\n actionType: 'sanity.action.document.replaceDraft'\n /**\n * Published document ID to create draft from, if draft does not exist\n */\n publishedId: string\n /**\n * Document to create if it does not already exist. Requires `_id` and `_type` properties.\n */\n attributes: IdentifiedSanityDocumentStub\n}\n\n/**\n * Replace an existing version of a document.\n *\n * @public\n */\nexport declare interface ReplaceVersionAction {\n actionType: 'sanity.action.document.version.replace'\n document: IdentifiedSanityDocumentStub\n}\n\n/** @public */\nexport declare const requester: Requester\n\n/** @internal */\nexport declare interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {\n url?: string\n uri?: string\n canUseCdn?: boolean\n useCdn?: boolean\n tag?: string\n returnQuery?: boolean\n resultSourceMap?: boolean | 'withKeyArraySelector'\n perspective?: ClientPerspective\n lastLiveEventId?: string\n cacheMode?: 'noStale'\n}\n\n/** @public */\nexport declare interface RequestOptions {\n timeout?: number\n token?: string\n tag?: string\n headers?: Record<string, string>\n method?: string\n query?: Any\n body?: Any\n signal?: AbortSignal\n}\n\nexport {ResolveStudioUrl}\n\n/** @public */\nexport declare interface ResponseEvent<T = unknown> {\n type: 'response'\n body: T\n url: string\n method: string\n statusCode: number\n statusMessage?: string\n headers: Record<string, string>\n}\n\n/** @public */\nexport declare interface ResponseQueryOptions extends RequestOptions {\n perspective?: ClientPerspective\n resultSourceMap?: boolean | 'withKeyArraySelector'\n returnQuery?: boolean\n useCdn?: boolean\n stega?: boolean | StegaConfig\n cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never\n next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']\n lastLiveEventId?: string | string[] | null\n /**\n * When set to `noStale`, APICDN will not return a cached response if the content is stale.\n * Tradeoff between latency and freshness of content.\n *\n * Only to be used with live content queries and when useCdn is true.\n */\n cacheMode?: 'noStale'\n}\n\n/** @internal */\nexport declare interface SanityAssetDocument extends SanityDocument {\n url: string\n path: string\n size: number\n assetId: string\n mimeType: string\n sha1hash: string\n extension: string\n uploadId?: string\n originalFilename?: string\n}\n\n/** @public */\nexport declare class SanityClient {\n #private\n assets: AssetsClient\n datasets: DatasetsClient\n live: LiveClient\n mediaLibrary: {\n video: MediaLibraryVideoClient\n }\n projects: ProjectsClient\n users: UsersClient\n agent: {\n action: AgentActionsClient\n }\n releases: ReleasesClient\n /**\n * Observable version of the Sanity client, with the same configuration as the promise-based one\n */\n observable: ObservableSanityClient\n /**\n * Instance properties\n */\n listen: typeof _listen\n constructor(httpRequest: HttpRequest, config?: ClientConfig)\n /**\n * Clone the client - returns a new instance\n */\n clone(): SanityClient\n /**\n * Returns the current client configuration\n */\n config(): InitializedClientConfig\n /**\n * Reconfigure the client. Note that this _mutates_ the current client.\n */\n config(newConfig?: Partial<ClientConfig>): this\n /**\n * Clone the client with a new (partial) configuration.\n *\n * @param newConfig - New client configuration properties, shallowly merged with existing configuration\n */\n withConfig(newConfig?: Partial<ClientConfig>): SanityClient\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams = QueryWithoutParams,\n const G extends string = string,\n >(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Optional request options\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams | QueryParams = QueryParams,\n const G extends string = string,\n >(\n query: G,\n params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,\n options?: FilteredResponseQueryOptions,\n ): Promise<ClientReturn<G, R>>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams | QueryParams = QueryParams,\n const G extends string = string,\n >(\n query: G,\n params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,\n options: UnfilteredResponseQueryOptions,\n ): Promise<RawQueryResponse<ClientReturn<G, R>>>\n /**\n * Perform a GROQ-query against the configured dataset.\n *\n * @param query - GROQ-query to perform\n * @param params - Optional query parameters\n * @param options - Request options\n */\n fetch<\n R = Any,\n Q extends QueryWithoutParams | QueryParams = QueryParams,\n const G extends string = string,\n >(\n query: G,\n params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,\n options: UnfilteredResponseWithoutQuery,\n ): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>\n /**\n * Fetch a single document with the given ID.\n *\n * @param id - Document ID to fetch\n * @param options - Request options\n */\n getDocument<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options: {\n signal?: AbortSignal\n tag?: string\n releaseId?: string\n includeAllVersions: true\n },\n ): Promise<SanityDocument<R>[]>\n /**\n * Fetch a single document with the given ID.\n *\n * @param id - Document ID to fetch\n * @param options - Request options\n */\n getDocument<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options?: {\n signal?: AbortSignal\n tag?: string\n releaseId?: string\n includeAllVersions?: false\n },\n ): Promise<SanityDocument<R> | undefined>\n /**\n * Fetch multiple documents in one request.\n * Should be used sparingly - performing a query is usually a better option.\n * The order/position of documents is preserved based on the original array of IDs.\n * If any of the documents are missing, they will be replaced by a `null` entry in the returned array\n *\n * @param ids - Document IDs to fetch\n * @param options - Request options\n */\n getDocuments<R extends Record<string, Any> = Record<string, Any>>(\n ids: string[],\n options?: {\n signal?: AbortSignal\n tag?: string\n },\n ): Promise<(SanityDocument<R> | null)[]>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: FirstDocumentIdMutationOptions,\n ): Promise<SingleMutationResult>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options: AllDocumentIdsMutationOptions,\n ): Promise<MultipleMutationResult>\n /**\n * Create a document. Requires a `_type` property. If no `_id` is provided, it will be generated by the database.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n create<R extends Record<string, Any> = Record<string, Any>>(\n document: SanityDocumentStub<R>,\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to an array containing the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentIdMutationOptions,\n ): Promise<SingleMutationResult>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentIdsMutationOptions,\n ): Promise<MultipleMutationResult>\n /**\n * Create a document if no document with the same ID already exists.\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to create\n * @param options - Mutation options\n */\n createIfNotExists<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to an array containing the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to a mutation result object containing the ID of the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: FirstDocumentIdMutationOptions,\n ): Promise<SingleMutationResult>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to a mutation result object containing the created document ID.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options: AllDocumentIdsMutationOptions,\n ): Promise<MultipleMutationResult>\n /**\n * Create a document if it does not exist, or replace a document with the same document ID\n * Returns a promise that resolves to the created document.\n *\n * @param document - Document to either create or replace\n * @param options - Mutation options\n */\n createOrReplace<R extends Record<string, Any> = Record<string, Any>>(\n document: IdentifiedSanityDocumentStub<R>,\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * @public\n *\n * Creates a new version of a published document.\n *\n * @remarks\n * * The preferred approach is to use `baseId` to refer to the existing published document, but it is also possible to provide a complete `document` instead.\n * * If `document` is provided, it must have a `_type` property.\n * * Creating a version with no `releaseId` will create a new draft version of the published document.\n * * If the `document._id` is defined, it should be a draft or release version ID that matches the version ID generated from `publishedId` and `releaseId`.\n * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.\n * * To create a version of an unpublished document, use the `client.create` method.\n *\n * @category Versions\n *\n * @param params - Version action parameters:\n * - `baseId` - The ID of the published document from which to create a new version from.\n * - `ifBaseRevisionId` - If `baseId` is provided, this ensures the `baseId`'s revision Id is as expected before creating the new version from it.\n * - `document` - The document to create as a new version (must include `_type`).\n * - `publishedId` - The ID of the published document being versioned.\n * - `releaseId` - The ID of the release to create the version for.\n * @param options - Additional action options.\n * @returns A promise that resolves to the `transactionId`.\n *\n * @example Creating a new version of a published document\n * ```ts\n * const transactionId = await client.createVersion({\n * baseId: 'myDocument',\n * publishedId: 'myDocument',\n * releaseId: 'myRelease',\n * })\n *\n * // The following document will be created:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n *\n * @example Creating a new draft version of a published document\n * ```ts\n * const transactionId = await client.createVersion({\n * baseId: 'myDocument',\n * publishedId: 'myDocument',\n * })\n *\n * // The following document will be created:\n * // {\n * // _id: 'drafts.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n */\n createVersion<R extends Record<string, Any>>(\n args: {\n document: SanityDocumentStub<R>\n publishedId: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n createVersion<R extends Record<string, Any>>(\n args: {\n document: IdentifiedSanityDocumentStub<R>\n publishedId?: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n createVersion(\n args: {\n publishedId: string\n baseId: string\n releaseId?: string\n ifBaseRevisionId?: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to an array containing the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: FirstDocumentIdMutationOptions): Promise<SingleMutationResult>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to a mutation result object containing the deleted document ID.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete(id: string, options: AllDocumentIdsMutationOptions): Promise<MultipleMutationResult>\n /**\n * Deletes a document with the given document ID.\n * Returns a promise that resolves to the deleted document.\n *\n * @param id - Document ID to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n id: string,\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n selection: MutationSelection,\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to an array containing the deleted documents.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n selection: MutationSelection,\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to a mutation result object containing the ID of the first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: FirstDocumentIdMutationOptions,\n ): Promise<SingleMutationResult>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to a mutation result object containing the document IDs that were deleted.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete(\n selection: MutationSelection,\n options: AllDocumentIdsMutationOptions,\n ): Promise<MultipleMutationResult>\n /**\n * Deletes one or more documents matching the given query or document ID.\n * Returns a promise that resolves to first deleted document.\n *\n * @param selection - An object with either an `id` or `query` key defining what to delete\n * @param options - Options for the mutation\n */\n delete<R extends Record<string, Any> = Record<string, Any>>(\n selection: MutationSelection,\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * @public\n *\n * Deletes the draft or release version of a document.\n *\n * @remarks\n * * Discarding a version with no `releaseId` will discard the draft version of the published document.\n * * If the draft or release version does not exist, any error will throw.\n *\n * @param params - Version action parameters:\n * - `releaseId` - The ID of the release to discard the document from.\n * - `publishedId` - The published ID of the document to discard.\n * @param purge - if `true` the document history is also discarded.\n * @param options - Additional action options.\n * @returns a promise that resolves to the `transactionId`.\n *\n * @example Discarding a release version of a document\n * ```ts\n * client.discardVersion({publishedId: 'myDocument', releaseId: 'myRelease'})\n * // The document with the ID `versions.myRelease.myDocument` will be discarded.\n * ```\n *\n * @example Discarding a draft version of a document\n * ```ts\n * client.discardVersion({publishedId: 'myDocument'})\n * // The document with the ID `drafts.myDocument` will be discarded.\n * ```\n */\n discardVersion(\n {\n releaseId,\n publishedId,\n }: {\n releaseId?: string\n publishedId: string\n },\n purge?: boolean,\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n /**\n * @public\n *\n * Replaces an existing version document.\n *\n * @remarks\n * * Requires a document with a `_type` property.\n * * If the `document._id` is defined, it should be a draft or release version ID that matches the version ID generated from `publishedId` and `releaseId`.\n * * If the `document._id` is not defined, it will be generated from `publishedId` and `releaseId`.\n * * Replacing a version with no `releaseId` will replace the draft version of the published document.\n * * At least one of the **version** or **published** documents must exist.\n *\n * @param params - Version action parameters:\n * - `document` - The new document to replace the version with.\n * - `releaseId` - The ID of the release where the document version is replaced.\n * - `publishedId` - The ID of the published document to replace.\n * @param options - Additional action options.\n * @returns a promise that resolves to the `transactionId`.\n *\n * @example Replacing a release version of a published document with a generated version ID\n * ```ts\n * await client.replaceVersion({\n * document: {_type: 'myDocument', title: 'My Document'},\n * publishedId: 'myDocument',\n * releaseId: 'myRelease',\n * })\n *\n * // The following document will be patched:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n * @example Replacing a release version of a published document with a specified version ID\n * ```ts\n * await client.replaceVersion({\n * document: {_type: 'myDocument', _id: 'versions.myRelease.myDocument', title: 'My Document'},\n * // `publishedId` and `releaseId` are not required since `document._id` has been specified\n * })\n *\n * // The following document will be patched:\n * // {\n * // _id: 'versions.myRelease.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n *\n * @example Replacing a draft version of a published document\n * ```ts\n * await client.replaceVersion({\n * document: {_type: 'myDocument', title: 'My Document'},\n * publishedId: 'myDocument',\n * })\n *\n * // The following document will be patched:\n * // {\n * // _id: 'drafts.myDocument',\n * // _type: 'myDocument',\n * // title: 'My Document',\n * // }\n * ```\n */\n replaceVersion<R extends Record<string, Any>>(\n args: {\n document: SanityDocumentStub<R>\n publishedId: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n replaceVersion<R extends Record<string, Any>>(\n args: {\n document: IdentifiedSanityDocumentStub<R>\n publishedId?: string\n releaseId?: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n /**\n * @public\n *\n * Used to indicate when a document within a release should be unpublished when\n * the release is run.\n *\n * @remarks\n * * If the published document does not exist, an error will be thrown.\n *\n * @param params - Version action parameters:\n * - `releaseId` - The ID of the release to unpublish the document from.\n * - `publishedId` - The published ID of the document to unpublish.\n * @param options - Additional action options.\n * @returns a promise that resolves to the `transactionId`.\n *\n * @example Unpublishing a release version of a published document\n * ```ts\n * await client.unpublishVersion({publishedId: 'myDocument', releaseId: 'myRelease'})\n * // The document with the ID `versions.myRelease.myDocument` will be unpublished. when `myRelease` is run.\n * ```\n */\n unpublishVersion(\n {\n releaseId,\n publishedId,\n }: {\n releaseId: string\n publishedId: string\n },\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | Patch | Transaction,\n options: FirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Perform mutation operations against the configured dataset.\n * Returns a promise that resolves to an array of the mutated documents.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | Patch | Transaction,\n options: AllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to a mutation result object containing the document ID of the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | Patch | Transaction,\n options: FirstDocumentIdMutationOptions,\n ): Promise<SingleMutationResult>\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to a mutation result object containing the mutated document IDs.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | Patch | Transaction,\n options: AllDocumentIdsMutationOptions,\n ): Promise<MultipleMutationResult>\n /**\n * Perform mutation operations against the configured dataset\n * Returns a promise that resolves to the first mutated document.\n *\n * @param operations - Mutation operations to execute\n * @param options - Mutation options\n */\n mutate<R extends Record<string, Any> = Record<string, Any>>(\n operations: Mutation<R>[] | Patch | Transaction,\n options?: BaseMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param documentId - Document ID to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n * @returns Patch instance - call `.commit()` to perform the operations defined\n */\n patch(documentId: string, operations?: PatchOperations): Patch\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param documentIds - Array of document IDs to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n * @returns Patch instance - call `.commit()` to perform the operations defined\n */\n patch(documentIds: string[], operations?: PatchOperations): Patch\n /**\n * Create a new buildable patch of operations to perform\n *\n * @param selection - An object with `query` and optional `params`, defining which document(s) to patch\n * @param operations - Optional object of patch operations to initialize the patch instance with\n * @returns Patch instance - call `.commit()` to perform the operations defined\n */\n patch(selection: MutationSelection, operations?: PatchOperations): Patch\n /**\n * Create a new transaction of mutations\n *\n * @param operations - Optional array of mutation operations to initialize the transaction instance with\n */\n transaction<R extends Record<string, Any> = Record<string, Any>>(\n operations?: Mutation<R>[],\n ): Transaction\n /**\n * Perform action operations against the configured dataset\n * Returns a promise that resolves to the transaction result\n *\n * @param operations - Action operation(s) to execute\n * @param options - Action options\n */\n action(\n operations: Action | Action[],\n options?: BaseActionOptions,\n ): Promise<SingleActionResult | MultipleActionResult>\n /**\n * Perform a request against the Sanity API\n * NOTE: Only use this for Sanity API endpoints, not for your own APIs!\n *\n * @param options - Request options\n * @returns Promise resolving to the response body\n */\n request<R = Any>(options: RawRequestOptions): Promise<R>\n /**\n * Perform an HTTP request a `/data` sub-endpoint\n * NOTE: Considered internal, thus marked as deprecated. Use `request` instead.\n *\n * @deprecated - Use `request()` or your own HTTP library instead\n * @param endpoint - Endpoint to hit (mutate, query etc)\n * @param body - Request body\n * @param options - Request options\n * @internal\n */\n dataRequest(endpoint: string, body: unknown, options?: BaseMutationOptions): Promise<Any>\n /**\n * Get a Sanity API URL for the URI provided\n *\n * @param uri - URI/path to build URL for\n * @param canUseCdn - Whether or not to allow using the API CDN for this route\n */\n getUrl(uri: string, canUseCdn?: boolean): string\n /**\n * Get a Sanity API URL for the data operation and path provided\n *\n * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar)\n * @param path - Path to append after the operation\n */\n getDataUrl(operation: string, path?: string): string\n}\n\n/** @internal */\nexport declare type SanityDocument<T extends Record<string, Any> = Record<string, Any>> = {\n [P in keyof T]: T[P]\n} & {\n _id: string\n _rev: string\n _type: string\n _createdAt: string\n _updatedAt: string\n /**\n * Present when `perspective` is set to `previewDrafts`\n */\n _originalId?: string\n}\n\n/** @public */\nexport declare type SanityDocumentStub<T extends Record<string, Any> = Record<string, Any>> = {\n [P in keyof T]: T[P]\n} & {\n _type: string\n}\n\n/** @internal */\nexport declare interface SanityImageAssetDocument extends SanityAssetDocument {\n metadata: {\n _type: 'sanity.imageMetadata'\n hasAlpha: boolean\n isOpaque: boolean\n lqip?: string\n blurHash?: string\n dimensions: {\n _type: 'sanity.imageDimensions'\n aspectRatio: number\n height: number\n width: number\n }\n palette?: {\n _type: 'sanity.imagePalette'\n darkMuted?: SanityImagePalette\n darkVibrant?: SanityImagePalette\n dominant?: SanityImagePalette\n lightMuted?: SanityImagePalette\n lightVibrant?: SanityImagePalette\n muted?: SanityImagePalette\n vibrant?: SanityImagePalette\n }\n image?: {\n _type: 'sanity.imageExifTags'\n [key: string]: Any\n }\n exif?: {\n _type: 'sanity.imageExifMetadata'\n [key: string]: Any\n }\n }\n}\n\n/** @internal */\nexport declare interface SanityImagePalette {\n background: string\n foreground: string\n population: number\n title: string\n}\n\n/** @public */\nexport declare interface SanityProject {\n id: string\n displayName: string\n /**\n * @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications\n * @see https://www.sanity.io/help/studio-host-user-applications\n */\n studioHost: string | null\n organizationId: string | null\n isBlocked: boolean\n isDisabled: boolean\n isDisabledByUser: boolean\n createdAt: string\n pendingInvites?: number\n maxRetentionDays?: number\n members: SanityProjectMember[]\n metadata: {\n cliInitializedAt?: string\n color?: string\n /**\n * @deprecated Use the `/user-applications` endpoint instead, which lists all deployed studios/applications\n * @see https://www.sanity.io/help/studio-host-user-applications\n */\n externalStudioHost?: string\n }\n}\n\n/** @public */\nexport declare interface SanityProjectMember {\n id: string\n role: string\n isRobot: boolean\n isCurrentUser: boolean\n}\n\n/** @public */\nexport declare interface SanityQueries {}\n\n/** @internal */\nexport declare interface SanityReference {\n _ref: string\n}\n\n/** @public */\nexport declare interface SanityUser {\n id: string\n projectId: string\n displayName: string\n familyName: string | null\n givenName: string | null\n middleName: string | null\n imageUrl: string | null\n createdAt: string\n updatedAt: string\n isCurrentUser: boolean\n}\n\n/**\n * Queues release for publishing at the given future time.\n *\n * @public\n */\nexport declare interface ScheduleReleaseAction {\n actionType: 'sanity.action.release.schedule'\n releaseId: string\n publishAt: string\n}\n\n/** @public */\nexport declare class ServerError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode']\n responseBody: ErrorProps['responseBody']\n details: ErrorProps['details']\n constructor(res: Any)\n}\n\n/**\n * @public\n */\nexport declare interface ServerSentEvent<Name extends string> {\n type: Name\n id?: string\n data?: unknown\n}\n\n/** @internal */\nexport declare interface SingleActionResult {\n transactionId: string\n}\n\n/** @internal */\nexport declare interface SingleMutationResult {\n transactionId: string\n documentId: string\n results: {\n id: string\n operation: MutationOperation\n }[]\n}\n\n/** @public */\nexport declare type StackablePerspective = ('published' | 'drafts' | string) & {}\n\n/** @public */\nexport declare interface StegaConfig {\n /**\n * Enable or disable stega encoded strings in query results\n * ```ts\n {\n enabled: process.env.VERCEL_ENV !== 'production'\n }\n * ```\n * @defaultValue `false`\n */\n enabled?: boolean\n /**\n * Where the Studio is hosted.\n * If it's embedded in the app, use the base path for example `/studio`.\n * Otherwise provide the full URL to where the Studio is hosted, for example: `https://blog.sanity.studio`.\n *\n */\n studioUrl?: StudioUrl | ResolveStudioUrl\n filter?: FilterDefault\n /**\n * Specify a `console.log` compatible logger to see debug logs, which keys are encoded and which are not.\n */\n logger?: Logger\n /**\n * Set to `true` to omit cross dataset reference specific data from encoded strings\n */\n omitCrossDatasetReferenceData?: boolean\n}\n\n/** @public */\nexport declare type StegaConfigRequiredKeys = Extract<keyof StegaConfig, 'enabled'>\n\n/**\n * Allowed still image formats (thumbnail + storyboard).\n * @public\n */\nexport declare type StillImageFormat = 'jpg' | 'png' | 'webp'\n\n/**\n * Storyboard (contact sheet) options.\n * @public\n */\nexport declare interface StoryboardTransformOptions {\n /** Output image format for the storyboard. */\n format?: StillImageFormat\n}\n\nexport {StudioBaseRoute}\n\nexport {StudioBaseUrl}\n\nexport {StudioUrl}\n\n/** @public */\nexport declare type SyncTag = `s1:${string}`\n\n/**\n * Thumbnail rendition (single frame) options.\n * @public\n */\nexport declare interface ThumbnailTransformOptions {\n /** Pixel width of the thumbnail frame. */\n width?: number\n /** Pixel height of the thumbnail frame. */\n height?: number\n /** Timestamp (seconds) from which to grab the frame. */\n time?: number\n /** Resize / fit mode applied to the extracted frame. */\n fit?: FitMode\n /** Output image format. */\n format?: StillImageFormat\n}\n\n/** @public */\nexport declare class Transaction extends BaseTransaction {\n #private\n constructor(operations?: Mutation[], client?: SanityClient, transactionId?: string)\n /**\n * Clones the transaction\n */\n clone(): Transaction\n /**\n * Commit the transaction, returning a promise that resolves to the first mutated document\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any>>(\n options: TransactionFirstDocumentMutationOptions,\n ): Promise<SanityDocument<R>>\n /**\n * Commit the transaction, returning a promise that resolves to an array of the mutated documents\n *\n * @param options - Options for the mutation operation\n */\n commit<R extends Record<string, Any>>(\n options: TransactionAllDocumentsMutationOptions,\n ): Promise<SanityDocument<R>[]>\n /**\n * Commit the transaction, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionFirstDocumentIdMutationOptions): Promise<SingleMutationResult>\n /**\n * Commit the transaction, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options: TransactionAllDocumentIdsMutationOptions): Promise<MultipleMutationResult>\n /**\n * Commit the transaction, returning a promise that resolves to a mutation result object\n *\n * @param options - Options for the mutation operation\n */\n commit(options?: BaseMutationOptions): Promise<MultipleMutationResult>\n /**\n * Performs a patch on the given document ID. Can either be a builder function or an object of patch operations.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param documentId - Document ID to perform the patch operation on\n * @param patchOps - Operations to perform, or a builder function\n */\n patch(documentId: string, patchOps?: PatchBuilder | PatchOperations): this\n /**\n * Performs a patch on the given selection. Can either be a builder function or an object of patch operations.\n *\n * @param selection - An object with `query` and optional `params`, defining which document(s) to patch\n * @param patchOps - Operations to perform, or a builder function\n */\n patch(patch: MutationSelection, patchOps?: PatchBuilder | PatchOperations): this\n /**\n * Adds the given patch instance to the transaction.\n * The operation is added to the current transaction, ready to be commited by `commit()`\n *\n * @param patch - Patch to execute\n */\n patch(patch: Patch): this\n}\n\n/** @internal */\nexport declare type TransactionAllDocumentIdsMutationOptions = BaseMutationOptions & {\n returnFirst?: false\n returnDocuments?: false\n}\n\n/** @internal */\nexport declare type TransactionAllDocumentsMutationOptions = BaseMutationOptions & {\n returnFirst?: false\n returnDocuments: true\n}\n\n/** @internal */\nexport declare type TransactionFirstDocumentIdMutationOptions = BaseMutationOptions & {\n returnFirst: true\n returnDocuments?: false\n}\n\n/** @internal */\nexport declare type TransactionFirstDocumentMutationOptions = BaseMutationOptions & {\n returnFirst: true\n returnDocuments: true\n}\n\n/** @internal */\nexport declare type TransactionMutationOptions =\n | TransactionFirstDocumentMutationOptions\n | TransactionFirstDocumentIdMutationOptions\n | TransactionAllDocumentsMutationOptions\n | TransactionAllDocumentIdsMutationOptions\n\n/** @beta */\nexport declare type TransformDocument<T extends Record<string, Any> = Record<string, Any>> =\n | TransformDocumentSync<T>\n | TransformDocumentAsync\n\n/** @beta */\ndeclare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync\n\n/** @beta */\ndeclare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =\n TransformRequestBase & AgentActionSync\n\n/**\n *\n * ## `set` by default\n * By default, Transform will change the value of every target field in place using a set operation.\n *\n * ## Image description\n *\n * ### Targeting image fields\n * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)\n * with `operation: {type: 'image-description'}`.\n *\n * Custom instructions for image description targets will be used to generate the description.\n *\n * Such targets must be a descendant field of an image object.\n *\n * For example:\n * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`\n * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`\n * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`\n *\n * ### Targeting non-image fields\n * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.\n * `sourcePath` must be an image or image asset field.\n *\n * For example:\n * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`\n * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`\n * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`\n *\n * ### Targeting images outside the document (URL)\n * If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.\n *\n * Example:\n * - `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`\n * @beta\n */\nexport declare type TransformOperation = 'set' | ImageDescriptionOperation\n\n/** @beta */\ndeclare interface TransformRequestBase extends AgentActionRequestBase {\n /** schemaId as reported by sanity deploy / sanity schema store */\n schemaId: string\n /**\n * The source document the transformation will use as input.\n *\n * @see #AgentActionSchema.forcePublishedWrite\n */\n documentId: string\n /**\n * The source document's content is first copied to the target,\n * then it is transformed according to the instruction.\n *\n * When omitted, the source document (documentId) is also the target document.\n *\n * @see #AgentActionSchema.forcePublishedWrite\n */\n targetDocument?: TransformTargetDocument\n /**\n * Instruct the LLM how to transform the input to th output.\n *\n * String template with support for $variable from `instructionParams`.\n *\n * Capped to 2000 characters, after variables has been injected.\n * */\n instruction: string\n /**\n *\n * param values for the string template, keys are the variable name, ie if the template has \"$variable\", one key must be \"variable\"\n *\n * ### Examples\n *\n * #### Constant\n *\n * ##### Shorthand\n * ```ts\n * client.agent.action.generate({\n * schemaId,\n * documentId,\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nGenerate the full article.',\n * instructionParams: {\n * topic: 'Grapefruit'\n * },\n * })\n * ```\n * ##### Object-form\n *\n * ```ts\n * client.agent.action.transform({\n * schemaId,\n * documentId,\n * instruction: 'Give the following topic:\\n $topic \\n ---\\nGenerate the full article.',\n * instructionParams: {\n * topic: {\n * type: 'constant',\n * value: 'Grapefruit'\n * },\n * },\n * })\n * ```\n * #### Field\n * ```ts\n * client.agent.action.transform({\n * schemaId,\n * documentId,\n * instruction: 'Give the following field value:\\n $pte \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * pte: {\n * type: 'field',\n * path: ['pteField'],\n * },\n * },\n * target: {path: 'keywords' }\n * })\n * ```\n * #### Document\n * ```ts\n * client.agent.action.transform({\n * schemaId,\n * documentId,\n * instruction: 'Give the following document value:\\n $document \\n ---\\nGenerate keywords.',\n * instructionParams: {\n * document: {\n * type: 'document',\n * },\n * },\n * target: {path: 'keywords' }\n * })\n * ```\n *\n * #### GROQ\n * ```ts\n * client.agent.action.transform({\n * schemaId,\n * documentId,\n * instruction: 'Give the following list of titles:\\n $list \\n ---\\nGenerate a similar title.',\n * instructionParams: {\n * list: {\n * type: 'groq',\n * query: '* [_type==$type].title',\n * params: {type: 'article'}\n * },\n * },\n * target: {path: 'title'}\n * })\n * ```\n * */\n instructionParams?: AgentActionParams\n /**\n * Target defines which parts of the document will be affected by the instruction.\n * It can be an array, so multiple parts of the document can be separately configured in detail.\n *\n * Omitting target implies that the document itself is the root.\n *\n * Notes:\n * - instruction can only affect fields up to `maxPathDepth`\n * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.\n * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)\n *\n * Default max depth for transform: 12\n *\n * ## Transforming images\n *\n * To transform an existing image, directly target an image asset path.\n *\n * For example, all the following will transform the image into the provided asset:\n * * `target: {path: ['image', 'asset'] }`\n * * `target: {path: 'image', include: ['asset'] }`\n *\n * Image transform can be combined with regular content targets:\n * * `target: [{path: ['image', 'asset'] }, {include: ['title', 'description']}]`\n *\n * Image transform can have per-path instructions, just like any other target paths:\n * * `target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }`\n *\n * @see AgentActionRequestBase#conditionalPaths\n */\n target?: TransformTarget | TransformTarget[]\n}\n\n/**\n * @see #TransformOperation\n * @beta\n * */\nexport declare interface TransformTarget extends AgentActionTarget {\n /**\n * Specifies a tailored instruction of this target.\n *\n * String template with support for $variable from `instructionParams`.\n * */\n instruction?: string\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n *\n * When `include` is specified, only segments explicitly listed will be included.\n *\n * Fields or array items not on the include list, are implicitly excluded.\n */\n include?: (AgentActionPathSegment | TransformTargetInclude)[]\n /**\n * Default: `set`\n * @see #TransformOperation\n */\n operation?: TransformOperation\n}\n\n/**\n * @see #AgentActionSchema.forcePublishedWrite\n *\n * @beta\n */\nexport declare type TransformTargetDocument =\n | {\n operation: 'edit'\n _id: string\n }\n | {\n operation: 'create'\n _id?: string\n }\n | {\n operation: 'createIfNotExists'\n _id: string\n }\n | {\n operation: 'createOrReplace'\n _id: string\n }\n\n/**\n * @see #TransformOperation\n * @beta\n * */\nexport declare interface TransformTargetInclude extends AgentActionTargetInclude {\n /**\n * Specifies a tailored instruction of this target.\n *\n * String template with support for $variable from `instructionParams`. */\n instruction?: string\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n *\n * When `include` is specified, only segments explicitly listed will be included.\n *\n * Fields or array items not on the include list, are implicitly excluded.\n */\n include?: (AgentActionPathSegment | TransformTargetInclude)[]\n /**\n * Default: `set`\n * @see #TransformOperation\n */\n operation?: TransformOperation\n}\n\n/** @beta */\nexport declare type TranslateDocument<T extends Record<string, Any> = Record<string, Any>> =\n | TranslateDocumentSync<T>\n | TranslateDocumentAsync\n\n/** @beta */\ndeclare type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync\n\n/** @beta */\ndeclare type TranslateDocumentSync<T extends Record<string, Any> = Record<string, Any>> =\n TranslateRequestBase & AgentActionSync\n\n/** @beta */\ndeclare interface TranslateLanguage {\n /**\n * Language code\n */\n id: string\n /**\n * While optional, it is recommended to provide a language title\n */\n title?: string\n}\n\n/** @beta */\ndeclare interface TranslateRequestBase extends AgentActionRequestBase {\n /** schemaId as reported by sanity deploy / sanity schema store */\n schemaId: string\n /**\n * The source document the transformation will use as input.\n * @see #AgentActionSchema.forcePublishedWrite\n */\n documentId: string\n /**\n * The target document will first get content copied over from the source,\n * then it is translated according to the instruction.\n *\n * When omitted, the source document (documentId) is also the target document.\n *\n * @see #AgentActionSchema.forcePublishedWrite\n */\n targetDocument?: TransformTargetDocument\n /**\n * While optional, it is recommended\n */\n fromLanguage?: TranslateLanguage\n toLanguage: TranslateLanguage\n /**\n * `styleGuide` can be used to tailor how the translation should be preformed.\n *\n * String template using $variable from styleGuideParams.\n *\n * Capped to 2000 characters, after variables has been injected.\n *\n * @see #protectedPhrases\n */\n styleGuide?: string\n /** param values for the string template, keys are the variable name, ie if the template has \"$variable\", one key must be \"variable\" */\n styleGuideParams?: AgentActionParams\n /**\n * When the input string contains any phrase from `protectedPhrases`, the LLM will be instructed not\n * to translate them.\n *\n * It is recommended to use `protectedPhrases` instead of `styleGuide` for deny-list words and phrases,\n * since it keeps token cost low, resulting in faster responses, and limits how much information the LLM\n * has to process, since only phrases that are actually in the input string will be included in the final prompt.\n */\n protectedPhrases?: string[]\n /**\n * When specified, the `toLanguage.id` will be stored in the specified path in the target document.\n *\n * The file _can_ be hidden: true (unlike other fields in the target, which will be ignored)\n */\n languageFieldPath?: AgentActionPathSegment | AgentActionPath\n /**\n * Target defines which parts of the document will be affected by the instruction.\n * It can be an array, so multiple parts of the document can be separately configured in detail.\n *\n * Omitting target implies that the document itself is the root.\n *\n * Notes:\n * - instruction can only affect fields up to `maxPathDepth`\n * - when multiple targets are provided, they will be coalesced into a single target sharing a common target root.\n * It is therefor an error to provide conflicting include/exclude across targets (ie, include title in one, and exclude it in another)\n *\n * @see AgentActionRequestBase#conditionalPaths\n */\n target?: TranslateTarget | TranslateTarget[]\n}\n\n/** @beta */\nexport declare interface TranslateTarget extends AgentActionTarget {\n /** String template using $variable from styleGuideParams. */\n styleGuide?: string\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n *\n * When `include` is specified, only segments explicitly listed will be included.\n *\n * Fields or array items not on the include list, are implicitly excluded.\n */\n include?: (AgentActionPathSegment | TranslateTargetInclude)[]\n}\n\n/** @beta */\nexport declare interface TranslateTargetInclude extends AgentActionTargetInclude {\n /** String template using $variable from styleGuideParams. */\n styleGuide?: string\n /**\n * By default, all children up to `target.maxPathDepth` are included.\n *\n * When `include` is specified, only segments explicitly listed will be included.\n *\n * Fields or array items not on the include list, are implicitly excluded.\n */\n include?: (AgentActionPathSegment | TranslateTargetInclude)[]\n}\n\n/**\n * Unarchived an `archived` release, and restores all the release documents.\n *\n * @public\n */\nexport declare interface UnarchiveReleaseAction {\n actionType: 'sanity.action.release.unarchive'\n releaseId: string\n}\n\n/** @public */\nexport declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {\n filterResponse: false\n /**\n * When `filterResponse` is `false`, `returnQuery` also defaults to `true` for\n * backwards compatibility (on the client side, not from the content lake API).\n * Can also explicitly be set to `true`.\n */\n returnQuery?: true\n}\n\n/**\n * When using `filterResponse: false`, but you do not wish to receive back the query from\n * the content lake API.\n *\n * @public\n */\nexport declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {\n filterResponse: false\n returnQuery: false\n}\n\n/**\n * Retract a published document.\n * If there is no draft version then this is created from the published version.\n * In either case the published version is deleted.\n *\n * @public\n */\nexport declare type UnpublishAction = {\n actionType: 'sanity.action.document.unpublish'\n /**\n * Draft document ID to replace the published document with\n */\n draftId: string\n /**\n * Published document ID to delete\n */\n publishedId: string\n}\n\n/**\n * Identify that a version of a document should be unpublished when\n * the release that version is contained within is published.\n *\n * @public\n */\nexport declare interface UnpublishVersionAction {\n actionType: 'sanity.action.document.version.unpublish'\n versionId: string\n publishedId: string\n}\n\n/**\n * Unschedules a `scheduled` release, stopping it from being published.\n *\n * @public\n */\nexport declare interface UnscheduleReleaseAction {\n actionType: 'sanity.action.release.unschedule'\n releaseId: string\n}\n\nexport {unstable__adapter}\n\nexport {unstable__environment}\n\n/** @public */\nexport declare type UploadBody = File | Blob | Buffer | NodeJS.ReadableStream\n\n/** @public */\nexport declare interface UploadClientConfig {\n /**\n * Optional request tag for the upload\n */\n tag?: string\n /**\n * Whether or not to preserve the original filename (default: true)\n */\n preserveFilename?: boolean\n /**\n * Filename for this file (optional)\n */\n filename?: string\n /**\n * Milliseconds to wait before timing the request out\n */\n timeout?: number\n /**\n * Mime type of the file\n */\n contentType?: string\n /**\n * Array of metadata parts to extract from asset\n */\n extract?: AssetMetadataType[]\n /**\n * Optional freeform label for the asset. Generally not used.\n */\n label?: string\n /**\n * Optional title for the asset\n */\n title?: string\n /**\n * Optional description for the asset\n */\n description?: string\n /**\n * The credit to person(s) and/or organization(s) required by the supplier of the asset to be used when published\n */\n creditLine?: string\n /**\n * Source data (when the asset is from an external service)\n */\n source?: {\n /**\n * The (u)id of the asset within the source, i.e. 'i-f323r1E'\n */\n id: string\n /**\n * The name of the source, i.e. 'unsplash'\n */\n name: string\n /**\n * A url to where to find the asset, or get more info about it in the source\n */\n url?: string\n }\n}\n\n/** @public */\nexport declare class UsersClient {\n #private\n constructor(client: SanityClient, httpRequest: HttpRequest)\n /**\n * Fetch a user by user ID\n *\n * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned.\n */\n getById<T extends 'me' | string>(id: T): Promise<T extends 'me' ? CurrentSanityUser : SanityUser>\n}\n\n/**\n * @internal - it may have breaking changes in any release\n */\nexport declare function validateApiPerspective(\n perspective: unknown,\n): asserts perspective is ClientPerspective\n\n/** @public */\nexport declare type VersionAction =\n | CreateVersionAction\n | DiscardVersionAction\n | ReplaceVersionAction\n | UnpublishVersionAction\n\n/** @public */\nexport declare interface VideoPlaybackInfo<\n T extends VideoPlaybackInfoItem = VideoPlaybackInfoItem,\n> {\n id: string\n thumbnail: T\n animated: T\n storyboard: T\n stream: T\n duration: number\n aspectRatio: number\n}\n\n/** @public */\nexport declare type VideoPlaybackInfoItem =\n | VideoPlaybackInfoItemPublic\n | VideoPlaybackInfoItemSigned\n\n/** @public */\nexport declare interface VideoPlaybackInfoItemPublic {\n url: string\n}\n\n/** @public */\nexport declare interface VideoPlaybackInfoItemSigned extends VideoPlaybackInfoItemPublic {\n token: string\n}\n\n/** @public */\nexport declare type VideoPlaybackInfoPublic = VideoPlaybackInfo<VideoPlaybackInfoItemPublic>\n\n/** @public */\nexport declare type VideoPlaybackInfoSigned = VideoPlaybackInfo<VideoPlaybackInfoItemSigned>\n\n/** @public */\nexport declare interface VideoPlaybackTokens {\n stream?: string\n thumbnail?: string\n storyboard?: string\n animated?: string\n}\n\n/**\n * The listener has been established, and will start receiving events.\n * Note that this is also emitted upon _reconnection_.\n *\n * @public\n */\nexport declare type WelcomeEvent = {\n type: 'welcome'\n listenerName: string\n}\n\nexport {}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;aAmZoB8C,GAAAA;;kBAsvIK0B,mBAAAA,SAA4B2J;;;;;;;;;;;;aAyxBjCA,yBAAyB9L,eAAeS,OAAOT,eAAeS,sBACpEkH,IAAIA,EAAEc;;;;;;;;;;;;kBAqBKrG,wBAAAA,SAAiCD;;;;;;;;;;;;;;;kBAexC4N;oBACEA;iBACHA;mBACEA;qBACEA;cACPA;gBACEA;;;;qBAIKtP;;;;qBAIAA;;;;;kBAMIsP,kBAAAA;;;;;;cCr9KZ,gBAAA;UAEI,eAAA;ED2YGtP;AAsvIpB;AAyxBA;;;;;;;;;AAsBA;;;;;;EAoBcsP,QAAAA,CAAAA,EAAAA,CAAAA,UAAAA,ECl7KY,wBDk7KZA,EAAAA,GAAAA,MAAAA;;;;;AApB+D,UCx5K5D,kBAAA,SAA2B,IDw5KiC,CCx5K5B,gBDw5K4B,EAAA,MAAA,GAAA,QAAA,GAAA,SAAA,CAAA,CAAA;EAmCpDA,IAAAA,EAAAA,OC17KV,gBD07K4B;YCz7K/B;AA5BZ;AAEA,eAAiB,QAAe,CAAA;EAwBf,UAAA,oBAAmB,CAAA;IAAa,QAAA,EAQnC,kBARmC;EAClC;;AAD6B,cAY/B,kBAZ+B,EAAA;EAAI,IAAA,EAAA,QAAA;EAG/C,IAAA,EAAA,UAAA;CAAA,GAcC,IAdD,CAcC,gBAdD,EAAA,SAAA,CAAA;UC8CgB,kBAAA,SAA2B;EFkUxBtP;AAsvIpB;AAyxBA;;;;EAAmET,aAAAA,CAAAA,EE10KjD,IF00KiDA,CE10K5C,mBF00K4CA,EAAAA,OAAAA,GAAAA,UAAAA,CAAAA;;AACjD2H,cEx0KL,eFw0KKA,EEx0KY,OFw0KZA,CAAAA,SAAAA,CAAAA;AAAEc,iBEvzKJ,aAAA,CFuzKIA,KAAAA,EEvzKiB,kBFuzKjBA,CAAAA,EEvzKsC,KAAA,CAAM,GAAA,CAAI,OFuzKhDA;UG/5KH,cAAA;;;AH+YjB;AAsvIA;AAyxBA;;;;;;;;;AAsBA;;;;;;;;;;;;AAmCA;;ACr9KA;AAEA;AAwBA;;;;;EAAgD,KAAA,CAAA,EAAA,CAAA,KAAA,EEO9B,gBFP8B,EAAA,GEOT,KAAA,CAAM,YFPG;AAG/C;AAAA,cEOY,cFPZ,EEO4B,MFP5B,CEOmC,cFPnC,GAAA,IAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"indexNext.js","sources":["../src/components/MarkdownInput.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["// dont import non-types here, it will break SSR on next\nimport type {SimpleMDEReactProps} from 'react-simplemde-editor'\n\nimport {Box, Text} from '@sanity/ui'\nimport {type Options as EasyMdeOptions} from 'easymde'\nimport {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport {PatchEvent, set, type StringInputProps, unset, useClient} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {MarkdownOptions} from '../schema'\n\nconst SimpleMdeReact = lazy(() => import('react-simplemde-editor'))\n\nconst MarkdownInputStyles = styled(Box)`\n & .CodeMirror.CodeMirror {\n color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n border-color: ${({theme}) => theme.sanity.color.card.enabled.border};\n background-color: inherit;\n }\n\n & .cm-s-easymde .CodeMirror-cursor {\n border-color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n }\n\n & .editor-toolbar,\n .editor-preview-side {\n border-color: ${({theme}) => theme.sanity.color.card.enabled.border};\n }\n\n & .CodeMirror-focused .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {\n background-color: ${({theme}) => theme.sanity.color.selectable?.primary?.hovered?.bg};\n }\n\n & .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n }\n\n & .editor-toolbar > * {\n color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n }\n\n & .editor-toolbar > .active,\n .editor-toolbar > button:hover,\n .editor-preview pre,\n .cm-s-easymde .cm-comment {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n }\n\n & .editor-preview {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n\n & h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: revert;\n }\n\n & ul,\n li {\n list-style: revert;\n padding: revert;\n }\n\n & a {\n text-decoration: revert;\n }\n }\n`\n\nexport interface MarkdownInputProps extends StringInputProps {\n /**\n * These are passed along directly to\n *\n * Note: MarkdownInput sets certain reactMdeProps.options by default.\n * These will be merged with any custom options.\n */\n reactMdeProps?: Omit<SimpleMDEReactProps, 'value' | 'onChange'>\n}\n\nexport const defaultMdeTools: EasyMdeOptions['toolbar'] = [\n 'heading',\n 'bold',\n 'italic',\n '|',\n 'quote',\n 'unordered-list',\n 'ordered-list',\n '|',\n 'link',\n 'image',\n 'code',\n '|',\n 'preview',\n 'side-by-side',\n]\n\nexport function MarkdownInput(props: MarkdownInputProps): React.JSX.Element {\n const {\n value = '',\n onChange,\n elementProps: {onBlur, onFocus, ref: elementRef},\n reactMdeProps: {options: mdeCustomOptions, ...reactMdeProps} = {},\n schemaType,\n focused,\n } = props\n const client = useClient({apiVersion: '2022-01-01'})\n // oxlint-disable-next-line no-unsafe-type-assertion\n const {imageUrl} = (schemaType.options as MarkdownOptions | undefined) ?? {}\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n\n // Forward ref to parent form state\n useImperativeHandle(elementRef, () => ref.current)\n\n const imageUpload = useCallback(\n (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => {\n client.assets\n .upload('image', file)\n .then((doc) => onSuccess(imageUrl ? imageUrl(doc) : `${doc.url}?w=450`))\n .catch((e) => {\n console.error(e)\n onError(e.message)\n })\n },\n [client, imageUrl],\n )\n\n const mdeOptions: EasyMdeOptions = useMemo(() => {\n return {\n spellChecker: false,\n sideBySideFullscreen: false,\n uploadImage: true,\n imageUploadFunction: imageUpload,\n toolbar: defaultMdeTools,\n status: false,\n ...mdeCustomOptions,\n autofocus: shouldAutoFocus,\n }\n }, [imageUpload, mdeCustomOptions, shouldAutoFocus])\n\n useEffect(() => {\n const node = ref.current\n if (!node) return undefined\n\n if (focused && !shouldAutoFocus) {\n // Do not set autofocus if the field already has focus\n const raf = requestAnimationFrame(() =>\n setShouldAutoFocus(!node.contains(document.activeElement)),\n )\n return () => cancelAnimationFrame(raf)\n }\n\n if (!focused && shouldAutoFocus) {\n // If `focused` is false, and the current active focus is no longer within the editor, reset autofocus state\n const raf = requestAnimationFrame(() =>\n setShouldAutoFocus(node.contains(document.activeElement)),\n )\n return () => cancelAnimationFrame(raf)\n }\n\n return undefined\n }, [focused, shouldAutoFocus])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n return (\n <MarkdownInputStyles>\n <Suspense fallback={fallback}>\n <SimpleMdeReact\n {...reactMdeProps}\n ref={ref}\n value={value}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n options={mdeOptions}\n spellCheck={false}\n />\n </Suspense>\n </MarkdownInputStyles>\n )\n}\n\nconst fallback = (\n <Box padding={3}>\n <Text>Loading editor...</Text>\n </Box>\n)\n","import type {SanityImageAssetDocument} from '@sanity/client'\n\nimport {defineType, type StringDefinition} from 'sanity'\n\nimport {MarkdownInput} from './components/MarkdownInput'\n\nexport const markdownTypeName = 'markdown'\n\nexport interface MarkdownOptions {\n /**\n * Used to create image url for any uploaded image.\n * The function will be invoked whenever an image is pasted or dragged into the\n * markdown editor, after upload completes.\n *\n * The default implementation uses\n * ```js\n * imageAsset => `${imageAsset.url}?w=450`\n * ```\n * ## Example\n * ```js\n * {\n * imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`\n * }\n * ```\n * @param imageAsset\n */\n imageUrl?: (imageAsset: SanityImageAssetDocument) => string\n}\n\n/**\n * @public\n */\nexport interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {\n type: typeof markdownTypeName\n options?: MarkdownOptions\n}\n\ndeclare module 'sanity' {\n // makes type: 'markdown' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n markdown: MarkdownDefinition\n }\n}\n\nexport const markdownSchemaType = defineType({\n type: 'string',\n name: markdownTypeName,\n title: 'Markdown',\n components: {input: MarkdownInput},\n})\n","import {definePlugin, type Plugin, type StringInputProps} from 'sanity'\n\nimport {markdownSchemaType} from './schema'\n\nexport interface MarkdownConfig {\n /**\n * When provided, will replace the default input component.\n *\n * Use this to customize MarkdownInput by wrapping it in a custom component,\n * and provide any custom props for https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor\n * via the `reactMdeProps` prop.\n *\n * ### Example\n *\n * ```tsx\n * // CustomMarkdownInput.tsx\n * import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'\n *\n * export function CustomMarkdownInput(props) {\n * const reactMdeProps: MarkdownInputProps['reactMdeProps'] =\n * useMemo(() => {\n * return {\n * options: {\n * toolbar: ['bold', 'italic'],\n * // more options available, see:\n * // https://github.com/Ionaru/easy-markdown-editor#options-list\n * },\n * // more props available, see:\n * // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor\n * }\n * }, [])\n *\n * return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />\n * }\n *\n * // studio.config.ts\n * markdownSchema({input: CustomMarkdownInput})\n * ```\n */\n input?: (props: StringInputProps) => React.ReactElement\n}\n\nexport const markdownSchema: Plugin<MarkdownConfig | void> = definePlugin(\n (config: MarkdownConfig | void) => {\n return {\n name: 'markdown-editor',\n schema: {\n types: [\n config && config.input\n ? {...markdownSchemaType, components: {input: config.input}}\n : markdownSchemaType,\n ],\n },\n }\n },\n)\n"],"names":["SimpleMdeReact","lazy","MarkdownInputStyles","styled","Box","withConfig","displayName","componentId","theme","sanity","color","card","enabled","fg","border","selectable","primary","hovered","bg","defaultMdeTools","MarkdownInput","props","$","_c","value","t0","onChange","elementProps","t1","reactMdeProps","t2","schemaType","focused","undefined","onBlur","onFocus","ref","elementRef","t3","mdeCustomOptions","options","t4","for","apiVersion","client","useClient","t5","imageUrl","shouldAutoFocus","setShouldAutoFocus","useState","useRef","t6","Symbol","current","useImperativeHandle","t7","file","onSuccess","onError","assets","upload","then","doc","url","catch","e","console","error","message","imageUpload","t8","spellChecker","sideBySideFullscreen","uploadImage","imageUploadFunction","toolbar","status","autofocus","mdeOptions","t10","t9","node","raf","requestAnimationFrame","contains","document","activeElement","cancelAnimationFrame","raf_0","useEffect","t11","newValue","PatchEvent","from","set","unset","handleChange","t12","fallback","markdownTypeName","markdownSchemaType","defineType","type","name","title","components","input","markdownSchema","definePlugin","config","schema","types"],"mappings":"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"}
1
+ {"version":3,"file":"indexNext.js","sources":["../src/components/MarkdownInput.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["// dont import non-types here, it will break SSR on next\nimport type {SimpleMDEReactProps} from 'react-simplemde-editor'\n\nimport {Box, Text} from '@sanity/ui'\nimport type { Options as EasyMdeOptions} from 'easymde'\nimport {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport {PatchEvent, set, type StringInputProps, unset, useClient} from 'sanity'\nimport {styled} from 'styled-components'\n\nimport type {MarkdownOptions} from '../schema'\n\nconst SimpleMdeReact = lazy(() => import('react-simplemde-editor'))\n\nconst MarkdownInputStyles = styled(Box)`\n & .CodeMirror.CodeMirror {\n color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n border-color: ${({theme}) => theme.sanity.color.card.enabled.border};\n background-color: inherit;\n }\n\n & .cm-s-easymde .CodeMirror-cursor {\n border-color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n }\n\n & .editor-toolbar,\n .editor-preview-side {\n border-color: ${({theme}) => theme.sanity.color.card.enabled.border};\n }\n\n & .CodeMirror-focused .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {\n background-color: ${({theme}) => theme.sanity.color.selectable?.primary?.hovered?.bg};\n }\n\n & .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n }\n\n & .editor-toolbar > * {\n color: ${({theme}) => theme.sanity.color.card.enabled.fg};\n }\n\n & .editor-toolbar > .active,\n .editor-toolbar > button:hover,\n .editor-preview pre,\n .cm-s-easymde .cm-comment {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n }\n\n & .editor-preview {\n background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};\n\n & h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: revert;\n }\n\n & ul,\n li {\n list-style: revert;\n padding: revert;\n }\n\n & a {\n text-decoration: revert;\n }\n }\n`\n\nexport interface MarkdownInputProps extends StringInputProps {\n /**\n * These are passed along directly to\n *\n * Note: MarkdownInput sets certain reactMdeProps.options by default.\n * These will be merged with any custom options.\n */\n reactMdeProps?: Omit<SimpleMDEReactProps, 'value' | 'onChange'>\n}\n\nexport const defaultMdeTools: EasyMdeOptions['toolbar'] = [\n 'heading',\n 'bold',\n 'italic',\n '|',\n 'quote',\n 'unordered-list',\n 'ordered-list',\n '|',\n 'link',\n 'image',\n 'code',\n '|',\n 'preview',\n 'side-by-side',\n]\n\nexport function MarkdownInput(props: MarkdownInputProps): React.JSX.Element {\n const {\n value = '',\n onChange,\n elementProps: {onBlur, onFocus, ref: elementRef},\n reactMdeProps: {options: mdeCustomOptions, ...reactMdeProps} = {},\n schemaType,\n focused,\n } = props\n const client = useClient({apiVersion: '2022-01-01'})\n // oxlint-disable-next-line no-unsafe-type-assertion\n const {imageUrl} = (schemaType.options as MarkdownOptions | undefined) ?? {}\n const [shouldAutoFocus, setShouldAutoFocus] = useState(false)\n const ref = useRef<HTMLDivElement>(null)\n\n // Forward ref to parent form state\n useImperativeHandle(elementRef, () => ref.current)\n\n const imageUpload = useCallback(\n (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => {\n client.assets\n .upload('image', file)\n .then((doc) => onSuccess(imageUrl ? imageUrl(doc) : `${doc.url}?w=450`))\n .catch((e) => {\n console.error(e)\n onError(e.message)\n })\n },\n [client, imageUrl],\n )\n\n const mdeOptions: EasyMdeOptions = useMemo(() => {\n return {\n spellChecker: false,\n sideBySideFullscreen: false,\n uploadImage: true,\n imageUploadFunction: imageUpload,\n toolbar: defaultMdeTools,\n status: false,\n ...mdeCustomOptions,\n autofocus: shouldAutoFocus,\n }\n }, [imageUpload, mdeCustomOptions, shouldAutoFocus])\n\n useEffect(() => {\n const node = ref.current\n if (!node) return undefined\n\n if (focused && !shouldAutoFocus) {\n // Do not set autofocus if the field already has focus\n const raf = requestAnimationFrame(() =>\n setShouldAutoFocus(!node.contains(document.activeElement)),\n )\n return () => cancelAnimationFrame(raf)\n }\n\n if (!focused && shouldAutoFocus) {\n // If `focused` is false, and the current active focus is no longer within the editor, reset autofocus state\n const raf = requestAnimationFrame(() =>\n setShouldAutoFocus(node.contains(document.activeElement)),\n )\n return () => cancelAnimationFrame(raf)\n }\n\n return undefined\n }, [focused, shouldAutoFocus])\n\n const handleChange = useCallback(\n (newValue: string) => {\n onChange(PatchEvent.from(newValue ? set(newValue) : unset()))\n },\n [onChange],\n )\n\n return (\n <MarkdownInputStyles>\n <Suspense fallback={fallback}>\n <SimpleMdeReact\n {...reactMdeProps}\n ref={ref}\n value={value}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n options={mdeOptions}\n spellCheck={false}\n />\n </Suspense>\n </MarkdownInputStyles>\n )\n}\n\nconst fallback = (\n <Box padding={3}>\n <Text>Loading editor...</Text>\n </Box>\n)\n","import type {SanityImageAssetDocument} from '@sanity/client'\n\nimport {defineType, type StringDefinition} from 'sanity'\n\nimport {MarkdownInput} from './components/MarkdownInput'\n\nexport const markdownTypeName = 'markdown'\n\nexport interface MarkdownOptions {\n /**\n * Used to create image url for any uploaded image.\n * The function will be invoked whenever an image is pasted or dragged into the\n * markdown editor, after upload completes.\n *\n * The default implementation uses\n * ```js\n * imageAsset => `${imageAsset.url}?w=450`\n * ```\n * ## Example\n * ```js\n * {\n * imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`\n * }\n * ```\n * @param imageAsset\n */\n imageUrl?: (imageAsset: SanityImageAssetDocument) => string\n}\n\n/**\n * @public\n */\nexport interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {\n type: typeof markdownTypeName\n options?: MarkdownOptions\n}\n\ndeclare module 'sanity' {\n // makes type: 'markdown' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n markdown: MarkdownDefinition\n }\n}\n\nexport const markdownSchemaType = defineType({\n type: 'string',\n name: markdownTypeName,\n title: 'Markdown',\n components: {input: MarkdownInput},\n})\n","import {definePlugin, type Plugin, type StringInputProps} from 'sanity'\n\nimport {markdownSchemaType} from './schema'\n\nexport interface MarkdownConfig {\n /**\n * When provided, will replace the default input component.\n *\n * Use this to customize MarkdownInput by wrapping it in a custom component,\n * and provide any custom props for https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor\n * via the `reactMdeProps` prop.\n *\n * ### Example\n *\n * ```tsx\n * // CustomMarkdownInput.tsx\n * import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'\n *\n * export function CustomMarkdownInput(props) {\n * const reactMdeProps: MarkdownInputProps['reactMdeProps'] =\n * useMemo(() => {\n * return {\n * options: {\n * toolbar: ['bold', 'italic'],\n * // more options available, see:\n * // https://github.com/Ionaru/easy-markdown-editor#options-list\n * },\n * // more props available, see:\n * // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor\n * }\n * }, [])\n *\n * return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />\n * }\n *\n * // studio.config.ts\n * markdownSchema({input: CustomMarkdownInput})\n * ```\n */\n input?: (props: StringInputProps) => React.ReactElement\n}\n\nexport const markdownSchema: Plugin<MarkdownConfig | void> = definePlugin(\n (config: MarkdownConfig | void) => {\n return {\n name: 'markdown-editor',\n schema: {\n types: [\n config && config.input\n ? {...markdownSchemaType, components: {input: config.input}}\n : markdownSchemaType,\n ],\n },\n }\n },\n)\n"],"names":["SimpleMdeReact","lazy","MarkdownInputStyles","styled","Box","withConfig","displayName","componentId","theme","sanity","color","card","enabled","fg","border","selectable","primary","hovered","bg","defaultMdeTools","MarkdownInput","props","$","_c","value","t0","onChange","elementProps","t1","reactMdeProps","t2","schemaType","focused","undefined","onBlur","onFocus","ref","elementRef","t3","mdeCustomOptions","options","t4","for","apiVersion","client","useClient","t5","imageUrl","shouldAutoFocus","setShouldAutoFocus","useState","useRef","t6","Symbol","current","useImperativeHandle","t7","file","onSuccess","onError","assets","upload","then","doc","url","catch","e","console","error","message","imageUpload","t8","spellChecker","sideBySideFullscreen","uploadImage","imageUploadFunction","toolbar","status","autofocus","mdeOptions","t10","t9","node","raf","requestAnimationFrame","contains","document","activeElement","cancelAnimationFrame","raf_0","useEffect","t11","newValue","PatchEvent","from","set","unset","handleChange","t12","fallback","markdownTypeName","markdownSchemaType","defineType","type","name","title","components","input","markdownSchema","definePlugin","config","schema","types"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-plugin-markdown",
3
- "version": "8.0.3",
3
+ "version": "8.0.4-canary.0",
4
4
  "description": "Markdown fields in Sanity Studio. Supports Github flavored Markdown and image uploads.",
5
5
  "keywords": [
6
6
  "github flavored markdown",
@@ -26,7 +26,10 @@
26
26
  "type": "module",
27
27
  "types": "./dist/index.d.ts",
28
28
  "exports": {
29
- ".": "./dist/index.js",
29
+ ".": {
30
+ "require": "./dist/index.cjs",
31
+ "default": "./dist/index.js"
32
+ },
30
33
  "./next": "./dist/indexNext.js",
31
34
  "./package.json": "./package.json"
32
35
  },
@@ -46,8 +49,8 @@
46
49
  "sanity": "^5.1.0",
47
50
  "styled-components": "^6.1.19",
48
51
  "@repo/eslint-config": "0.0.0",
49
- "@repo/package.config": "0.0.0",
50
- "@repo/tsconfig": "0.0.0"
52
+ "@repo/tsconfig": "0.0.0",
53
+ "@repo/package.config": "0.0.0"
51
54
  },
52
55
  "peerDependencies": {
53
56
  "easymde": "^2.18",