@sanity/client 6.13.0 → 6.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/_chunks/{browserMiddleware-Cfl3LrrI.js → browserMiddleware-C0hQLS9X.js} +8 -14
  2. package/dist/_chunks/browserMiddleware-C0hQLS9X.js.map +1 -0
  3. package/dist/_chunks/{browserMiddleware-Dp4wx9CK.cjs → browserMiddleware-e8tcYvdt.cjs} +8 -14
  4. package/dist/_chunks/browserMiddleware-e8tcYvdt.cjs.map +1 -0
  5. package/dist/_chunks/{nodeMiddleware-yTxugO4Q.cjs → nodeMiddleware-BhRfWf0W.cjs} +9 -15
  6. package/dist/_chunks/nodeMiddleware-BhRfWf0W.cjs.map +1 -0
  7. package/dist/_chunks/{nodeMiddleware-BN5UYAym.js → nodeMiddleware-D2afPgJS.js} +9 -15
  8. package/dist/_chunks/nodeMiddleware-D2afPgJS.js.map +1 -0
  9. package/dist/_chunks/{stegaEncodeSourceMap-MOb3TLiL.js → stegaEncodeSourceMap-B3BX9g4D.js} +2 -2
  10. package/dist/_chunks/{stegaEncodeSourceMap-MOb3TLiL.js.map → stegaEncodeSourceMap-B3BX9g4D.js.map} +1 -1
  11. package/dist/_chunks/{stegaEncodeSourceMap-DO8ipgJw.js → stegaEncodeSourceMap-BfR5oD3Z.js} +2 -2
  12. package/dist/_chunks/{stegaEncodeSourceMap-DO8ipgJw.js.map → stegaEncodeSourceMap-BfR5oD3Z.js.map} +1 -1
  13. package/dist/_chunks/{stegaEncodeSourceMap-DGdRCWlF.cjs → stegaEncodeSourceMap-Ji8dgoO-.cjs} +2 -2
  14. package/dist/_chunks/{stegaEncodeSourceMap-DGdRCWlF.cjs.map → stegaEncodeSourceMap-Ji8dgoO-.cjs.map} +1 -1
  15. package/dist/_chunks/{stegaEncodeSourceMap-D6fHf69f.cjs → stegaEncodeSourceMap-YSe0h4rd.cjs} +2 -2
  16. package/dist/_chunks/{stegaEncodeSourceMap-D6fHf69f.cjs.map → stegaEncodeSourceMap-YSe0h4rd.cjs.map} +1 -1
  17. package/dist/index.browser.cjs +1 -1
  18. package/dist/index.browser.js +2 -2
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.ts +1 -51
  21. package/dist/index.js +2 -2
  22. package/dist/stega.browser.cjs +2 -2
  23. package/dist/stega.browser.js +3 -3
  24. package/dist/stega.cjs +2 -2
  25. package/dist/stega.d.ts +1 -51
  26. package/dist/stega.js +3 -3
  27. package/package.json +1 -1
  28. package/src/SanityClient.ts +0 -26
  29. package/src/data/dataMethods.ts +1 -12
  30. package/src/data/encodeQueryString.ts +1 -4
  31. package/src/types.ts +1 -28
  32. package/src/util/getSelection.ts +5 -1
  33. package/umd/sanityClient.js +8 -14
  34. package/umd/sanityClient.min.js +3 -3
  35. package/dist/_chunks/browserMiddleware-Cfl3LrrI.js.map +0 -1
  36. package/dist/_chunks/browserMiddleware-Dp4wx9CK.cjs.map +0 -1
  37. package/dist/_chunks/nodeMiddleware-BN5UYAym.js.map +0 -1
  38. package/dist/_chunks/nodeMiddleware-yTxugO4Q.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"stegaEncodeSourceMap-D6fHf69f.cjs","sources":["../../src/stega/encodeIntoResult.ts","../../src/stega/filterDefault.ts","../../src/stega/stegaEncodeSourceMap.ts"],"sourcesContent":["import {parseJsonPath} from '../csm/jsonPath'\nimport {resolveMapping} from '../csm/resolveMapping'\nimport type {ContentSourceMap} from '../csm/types'\nimport {walkMap} from '../csm/walkMap'\nimport type {Encoder} from './types'\n\n/**\n * @internal\n */\nexport function encodeIntoResult<Result>(\n result: Result,\n csm: ContentSourceMap,\n encoder: Encoder,\n): Result {\n return walkMap(result, (value, path) => {\n // Only map strings, we could extend this in the future to support other types like integers...\n if (typeof value !== 'string') {\n return value\n }\n\n const resolveMappingResult = resolveMapping(path, csm)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, matchedPath} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = csm.documents[mapping.source.document!]\n const sourcePath = csm.paths[mapping.source.path]\n\n const matchPathSegments = parseJsonPath(matchedPath)\n const sourcePathSegments = parseJsonPath(sourcePath)\n const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length))\n\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value,\n })\n }) as Result\n}\n","import type {FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath, value}) => {\n // Skips encoding on URL or Date strings, similar to the `skip: 'auto'` parameter in vercelStegaCombine()\n if (isValidDate(value) || isValidURL(value)) {\n return false\n }\n\n const endPath = sourcePath.at(-1)\n // Never encode slugs\n if (sourcePath.at(-2) === 'slug' && endPath === 'current') {\n return false\n }\n\n // Skip underscored keys, needs better heuristics but it works for now\n if (typeof endPath === 'string' && endPath.startsWith('_')) {\n return false\n }\n\n /**\n * Best effort infer Portable Text paths that should not be encoded.\n * Nothing is for certain, and the below implementation may cause paths that aren't Portable Text and otherwise be safe to encode to be skipped.\n * However, that's ok as userland can always opt-in with the `encodeSourceMapAtPath` option and mark known safe paths as such, which will override this heuristic.\n */\n // If the path ends in marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16\n if (typeof endPath === 'number' && sourcePath.at(-2) === 'marks') {\n return false\n }\n // Or if it's [number].markDefs[number].href it's likely a PortableTextLink: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L163\n if (\n endPath === 'href' &&\n typeof sourcePath.at(-2) === 'number' &&\n sourcePath.at(-3) === 'markDefs'\n ) {\n return false\n }\n // Otherwise we have to deal with special properties of PortableTextBlock, and we can't confidently know if it's actually a `_type: 'block'` array item or not.\n // All we know is that if it is indeed a block, and we encode the strings on these keys it'll for sure break the PortableText rendering and thus we skip encoding.\n // https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58\n if (endPath === 'style' || endPath === 'listItem') {\n return false\n }\n\n // Don't encode into anything that is suggested it'll render for SEO in meta tags\n if (\n sourcePath.some(\n (path) => path === 'meta' || path === 'metadata' || path === 'openGraph' || path === 'seo',\n )\n ) {\n return false\n }\n\n // Finally, we ignore a bunch of paths that are typically used for page building\n if (typeof endPath === 'string' && denylist.has(endPath)) {\n return false\n }\n\n return true\n}\n\nconst denylist = new Set([\n 'color',\n 'colour',\n 'currency',\n 'email',\n 'format',\n 'gid',\n 'hex',\n 'href',\n 'hsl',\n 'hsla',\n 'icon',\n 'id',\n 'index',\n 'key',\n 'language',\n 'layout',\n 'link',\n 'linkAction',\n 'locale',\n 'lqip',\n 'page',\n 'path',\n 'ref',\n 'rgb',\n 'rgba',\n 'route',\n 'secret',\n 'slug',\n 'status',\n 'tag',\n 'template',\n 'theme',\n 'type',\n 'unit',\n 'url',\n 'username',\n 'variant',\n 'website',\n])\n\nfunction isValidDate(dateString: string) {\n return /^\\d{4}-\\d{2}-\\d{2}/.test(dateString) ? Boolean(Date.parse(dateString)) : false\n}\n\nfunction isValidURL(url: string) {\n try {\n new URL(url, url.startsWith('/') ? 'https://acme.com' : undefined)\n } catch {\n return false\n }\n return true\n}\n","import {vercelStegaCombine} from '@vercel/stega'\n\nimport {createEditUrl} from '../csm/createEditUrl'\nimport {jsonPathToStudioPath} from '../csm/jsonPath'\nimport {resolveStudioBaseRoute} from '../csm/resolveEditInfo'\nimport {reKeySegment, toString as studioPathToString} from '../csm/studioPath'\nimport {encodeIntoResult} from './encodeIntoResult'\nimport {filterDefault} from './filterDefault'\nimport {ContentSourceMap, ContentSourceMapParsedPath, InitializedStegaConfig} from './types'\n\nconst TRUNCATE_LENGTH = 20\n\n/**\n * Uses `@vercel/stega` to embed edit info JSON into strings in your query result.\n * The JSON payloads are added using invisible characters so they don't show up visually.\n * The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.\n * @public\n */\nexport function stegaEncodeSourceMap<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n config: InitializedStegaConfig,\n): Result {\n const {filter, logger, enabled} = config\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\"\n logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n if (!resultSourceMap) {\n logger?.error?.('[@sanity/client]: Missing Content Source Map from response body', {\n result,\n resultSourceMap,\n config,\n })\n return result\n }\n\n if (!config.studioUrl) {\n const msg = 'config.studioUrl must be defined'\n logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n const report: Record<'encoded' | 'skipped', {path: string; length: number; value: string}[]> = {\n encoded: [],\n skipped: [],\n }\n\n const resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({sourcePath, sourceDocument, resultPath, value}) => {\n // Allow userland to control when to opt-out of encoding\n if (\n (typeof filter === 'function'\n ? filter({sourcePath, resultPath, filterDefault, sourceDocument, value})\n : filterDefault({sourcePath, resultPath, filterDefault, sourceDocument, value})) === false\n ) {\n if (logger) {\n report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${\n value.length > TRUNCATE_LENGTH ? '...' : ''\n }`,\n length: value.length,\n })\n }\n return value\n }\n\n if (logger) {\n report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? '...' : ''}`,\n length: value.length,\n })\n }\n\n const {baseUrl, workspace, tool} = resolveStudioBaseRoute(\n typeof config.studioUrl === 'function'\n ? config.studioUrl(sourceDocument)\n : config.studioUrl!,\n )\n if (!baseUrl) return value\n const {_id: id, _type: type} = sourceDocument\n\n return vercelStegaCombine(\n value,\n {\n origin: 'sanity.io',\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n }),\n },\n // We use custom logic to determine if we should skip encoding\n false,\n )\n },\n )\n\n if (logger) {\n const isSkipping = report.skipped.length\n const isEncoding = report.encoded.length\n if (isSkipping || isEncoding) {\n ;(logger?.groupCollapsed || logger.log)?.('[@sanity/client]: Encoding source map into result')\n logger.log?.(\n `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,\n )\n }\n if (report.encoded.length > 0) {\n logger?.log?.(`[@sanity/client]: Table of encoded paths`)\n ;(logger?.table || logger.log)?.(report.encoded)\n }\n if (report.skipped.length > 0) {\n const skipped = new Set<string>()\n for (const {path} of report.skipped) {\n skipped.add(path.replace(reKeySegment, '0').replace(/\\[\\d+\\]/g, '[]'))\n }\n logger?.log?.(`[@sanity/client]: List of skipped paths`, [...skipped.values()])\n }\n\n if (isSkipping || isEncoding) {\n logger?.groupEnd?.()\n }\n }\n\n return resultWithStega\n}\n\nfunction prettyPathForLogging(path: ContentSourceMapParsedPath): string {\n return studioPathToString(jsonPathToStudioPath(path))\n}\n"],"names":["walkMap","resolveMapping","parseJsonPath","resolveStudioBaseRoute","vercelStegaCombine","createEditUrl","reKeySegment","studioPathToString","jsonPathToStudioPath"],"mappings":";;;;;AASgB,SAAA,gBAAA,CACd,MACA,EAAA,GAAA,EACA,OACQ,EAAA;AACR,EAAA,OAAOA,uBAAQ,CAAA,MAAA,EAAQ,CAAC,KAAA,EAAO,IAAS,KAAA;AAEtC,IAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,oBAAA,GAAuBC,8BAAe,CAAA,IAAA,EAAM,GAAG,CAAA,CAAA;AACrD,IAAA,IAAI,CAAC,oBAAsB,EAAA;AACzB,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,EAAC,OAAS,EAAA,WAAA,EAA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4rd.cjs","sources":["../../src/stega/encodeIntoResult.ts","../../src/stega/filterDefault.ts","../../src/stega/stegaEncodeSourceMap.ts"],"sourcesContent":["import {parseJsonPath} from '../csm/jsonPath'\nimport {resolveMapping} from '../csm/resolveMapping'\nimport type {ContentSourceMap} from '../csm/types'\nimport {walkMap} from '../csm/walkMap'\nimport type {Encoder} from './types'\n\n/**\n * @internal\n */\nexport function encodeIntoResult<Result>(\n result: Result,\n csm: ContentSourceMap,\n encoder: Encoder,\n): Result {\n return walkMap(result, (value, path) => {\n // Only map strings, we could extend this in the future to support other types like integers...\n if (typeof value !== 'string') {\n return value\n }\n\n const resolveMappingResult = resolveMapping(path, csm)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, matchedPath} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = csm.documents[mapping.source.document!]\n const sourcePath = csm.paths[mapping.source.path]\n\n const matchPathSegments = parseJsonPath(matchedPath)\n const sourcePathSegments = parseJsonPath(sourcePath)\n const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length))\n\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value,\n })\n }) as Result\n}\n","import type {FilterDefault} from './types'\n\nexport const filterDefault: FilterDefault = ({sourcePath, value}) => {\n // Skips encoding on URL or Date strings, similar to the `skip: 'auto'` parameter in vercelStegaCombine()\n if (isValidDate(value) || isValidURL(value)) {\n return false\n }\n\n const endPath = sourcePath.at(-1)\n // Never encode slugs\n if (sourcePath.at(-2) === 'slug' && endPath === 'current') {\n return false\n }\n\n // Skip underscored keys, needs better heuristics but it works for now\n if (typeof endPath === 'string' && endPath.startsWith('_')) {\n return false\n }\n\n /**\n * Best effort infer Portable Text paths that should not be encoded.\n * Nothing is for certain, and the below implementation may cause paths that aren't Portable Text and otherwise be safe to encode to be skipped.\n * However, that's ok as userland can always opt-in with the `encodeSourceMapAtPath` option and mark known safe paths as such, which will override this heuristic.\n */\n // If the path ends in marks[number] it's likely a PortableTextSpan: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#LL154C16-L154C16\n if (typeof endPath === 'number' && sourcePath.at(-2) === 'marks') {\n return false\n }\n // Or if it's [number].markDefs[number].href it's likely a PortableTextLink: https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L163\n if (\n endPath === 'href' &&\n typeof sourcePath.at(-2) === 'number' &&\n sourcePath.at(-3) === 'markDefs'\n ) {\n return false\n }\n // Otherwise we have to deal with special properties of PortableTextBlock, and we can't confidently know if it's actually a `_type: 'block'` array item or not.\n // All we know is that if it is indeed a block, and we encode the strings on these keys it'll for sure break the PortableText rendering and thus we skip encoding.\n // https://github.com/portabletext/types/blob/e54eb24f136d8efd51a46c6a190e7c46e79b5380/src/portableText.ts#L48-L58\n if (endPath === 'style' || endPath === 'listItem') {\n return false\n }\n\n // Don't encode into anything that is suggested it'll render for SEO in meta tags\n if (\n sourcePath.some(\n (path) => path === 'meta' || path === 'metadata' || path === 'openGraph' || path === 'seo',\n )\n ) {\n return false\n }\n\n // Finally, we ignore a bunch of paths that are typically used for page building\n if (typeof endPath === 'string' && denylist.has(endPath)) {\n return false\n }\n\n return true\n}\n\nconst denylist = new Set([\n 'color',\n 'colour',\n 'currency',\n 'email',\n 'format',\n 'gid',\n 'hex',\n 'href',\n 'hsl',\n 'hsla',\n 'icon',\n 'id',\n 'index',\n 'key',\n 'language',\n 'layout',\n 'link',\n 'linkAction',\n 'locale',\n 'lqip',\n 'page',\n 'path',\n 'ref',\n 'rgb',\n 'rgba',\n 'route',\n 'secret',\n 'slug',\n 'status',\n 'tag',\n 'template',\n 'theme',\n 'type',\n 'unit',\n 'url',\n 'username',\n 'variant',\n 'website',\n])\n\nfunction isValidDate(dateString: string) {\n return /^\\d{4}-\\d{2}-\\d{2}/.test(dateString) ? Boolean(Date.parse(dateString)) : false\n}\n\nfunction isValidURL(url: string) {\n try {\n new URL(url, url.startsWith('/') ? 'https://acme.com' : undefined)\n } catch {\n return false\n }\n return true\n}\n","import {vercelStegaCombine} from '@vercel/stega'\n\nimport {createEditUrl} from '../csm/createEditUrl'\nimport {jsonPathToStudioPath} from '../csm/jsonPath'\nimport {resolveStudioBaseRoute} from '../csm/resolveEditInfo'\nimport {reKeySegment, toString as studioPathToString} from '../csm/studioPath'\nimport {encodeIntoResult} from './encodeIntoResult'\nimport {filterDefault} from './filterDefault'\nimport {ContentSourceMap, ContentSourceMapParsedPath, InitializedStegaConfig} from './types'\n\nconst TRUNCATE_LENGTH = 20\n\n/**\n * Uses `@vercel/stega` to embed edit info JSON into strings in your query result.\n * The JSON payloads are added using invisible characters so they don't show up visually.\n * The edit info is generated from the Content Source Map (CSM) that is returned from Sanity for the query.\n * @public\n */\nexport function stegaEncodeSourceMap<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n config: InitializedStegaConfig,\n): Result {\n const {filter, logger, enabled} = config\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\"\n logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n if (!resultSourceMap) {\n logger?.error?.('[@sanity/client]: Missing Content Source Map from response body', {\n result,\n resultSourceMap,\n config,\n })\n return result\n }\n\n if (!config.studioUrl) {\n const msg = 'config.studioUrl must be defined'\n logger?.error?.(`[@sanity/client]: ${msg}`, {result, resultSourceMap, config})\n throw new TypeError(msg)\n }\n\n const report: Record<'encoded' | 'skipped', {path: string; length: number; value: string}[]> = {\n encoded: [],\n skipped: [],\n }\n\n const resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({sourcePath, sourceDocument, resultPath, value}) => {\n // Allow userland to control when to opt-out of encoding\n if (\n (typeof filter === 'function'\n ? filter({sourcePath, resultPath, filterDefault, sourceDocument, value})\n : filterDefault({sourcePath, resultPath, filterDefault, sourceDocument, value})) === false\n ) {\n if (logger) {\n report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${\n value.length > TRUNCATE_LENGTH ? '...' : ''\n }`,\n length: value.length,\n })\n }\n return value\n }\n\n if (logger) {\n report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? '...' : ''}`,\n length: value.length,\n })\n }\n\n const {baseUrl, workspace, tool} = resolveStudioBaseRoute(\n typeof config.studioUrl === 'function'\n ? config.studioUrl(sourceDocument)\n : config.studioUrl!,\n )\n if (!baseUrl) return value\n const {_id: id, _type: type} = sourceDocument\n\n return vercelStegaCombine(\n value,\n {\n origin: 'sanity.io',\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n }),\n },\n // We use custom logic to determine if we should skip encoding\n false,\n )\n },\n )\n\n if (logger) {\n const isSkipping = report.skipped.length\n const isEncoding = report.encoded.length\n if (isSkipping || isEncoding) {\n ;(logger?.groupCollapsed || logger.log)?.('[@sanity/client]: Encoding source map into result')\n logger.log?.(\n `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`,\n )\n }\n if (report.encoded.length > 0) {\n logger?.log?.(`[@sanity/client]: Table of encoded paths`)\n ;(logger?.table || logger.log)?.(report.encoded)\n }\n if (report.skipped.length > 0) {\n const skipped = new Set<string>()\n for (const {path} of report.skipped) {\n skipped.add(path.replace(reKeySegment, '0').replace(/\\[\\d+\\]/g, '[]'))\n }\n logger?.log?.(`[@sanity/client]: List of skipped paths`, [...skipped.values()])\n }\n\n if (isSkipping || isEncoding) {\n logger?.groupEnd?.()\n }\n }\n\n return resultWithStega\n}\n\nfunction prettyPathForLogging(path: ContentSourceMapParsedPath): string {\n return studioPathToString(jsonPathToStudioPath(path))\n}\n"],"names":["walkMap","resolveMapping","parseJsonPath","resolveStudioBaseRoute","vercelStegaCombine","createE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Q,CAAA,CAAA,CAAA;AAAA,KAC/E;AAEA,IAAA,IAAI,cAAc,UAAY,EAAA;AAC5B,MAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAQ,QAAR,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,MAAA,CAAA,CAAA;AAAA,KACF;AAAA,GACF;AAEA,EAAO,OAAA,eAAA,CAAA;AACT,CAAA;AAEA,SAAS,qBAAqB,IAA0C,EAAA;AACtE,EAAO,OAAAC,wBAAA,CAAmBC,oCAAqB,CAAA,IAAI,CAAC,CAAA,CAAA;AACtD;;;;;;;;;;;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var browserMiddleware = require('./_chunks/browserMiddleware-Dp4wx9CK.cjs');
5
+ var browserMiddleware = require('./_chunks/browserMiddleware-e8tcYvdt.cjs');
6
6
  var getIt = require('get-it');
7
7
 
8
8
  function defineDeprecatedCreateClient(createClient) {
@@ -1,5 +1,5 @@
1
- import { printNoDefaultExport, defineCreateClientExports, SanityClient, envMiddleware } from './_chunks/browserMiddleware-Cfl3LrrI.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/browserMiddleware-Cfl3LrrI.js';
1
+ import { printNoDefaultExport, defineCreateClientExports, SanityClient, envMiddleware } from './_chunks/browserMiddleware-C0hQLS9X.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/browserMiddleware-C0hQLS9X.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
4
 
5
5
  function defineDeprecatedCreateClient(createClient) {
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nodeMiddleware = require('./_chunks/nodeMiddleware-yTxugO4Q.cjs');
5
+ var nodeMiddleware = require('./_chunks/nodeMiddleware-BhRfWf0W.cjs');
6
6
  var getIt = require('get-it');
7
7
 
8
8
  function defineDeprecatedCreateClient(createClient) {
package/dist/index.d.ts CHANGED
@@ -1169,18 +1169,6 @@ export declare class ObservableSanityClient {
1169
1169
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1170
1170
  options: UnfilteredResponseQueryOptions,
1171
1171
  ): Observable<RawQueryResponse<R>>
1172
- /**
1173
- * Perform a GROQ-query against the configured dataset.
1174
- *
1175
- * @param query - GROQ-query to perform
1176
- * @param params - Optional query parameters
1177
- * @param options - Request options
1178
- */
1179
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
1180
- query: string,
1181
- params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1182
- options: UnfilteredResponseWithoutQuery,
1183
- ): Observable<RawQuerylessQueryResponse<R>>
1184
1172
  /**
1185
1173
  * Fetch a single document with the given ID.
1186
1174
  *
@@ -1768,10 +1756,7 @@ export declare class ProjectsClient {
1768
1756
  }
1769
1757
 
1770
1758
  /** @public */
1771
- export declare type QueryOptions =
1772
- | FilteredResponseQueryOptions
1773
- | UnfilteredResponseQueryOptions
1774
- | UnfilteredResponseWithoutQuery
1759
+ export declare type QueryOptions = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
1775
1760
 
1776
1761
  /** @public */
1777
1762
  export declare interface QueryParams {
@@ -1795,8 +1780,6 @@ export declare interface QueryParams {
1795
1780
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1796
1781
  resultSourceMap?: never
1797
1782
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1798
- returnQuery?: never
1799
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1800
1783
  signal?: never
1801
1784
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1802
1785
  stega?: never
@@ -1816,9 +1799,6 @@ export declare interface QueryParams {
1816
1799
  */
1817
1800
  export declare type QueryWithoutParams = Record<string, never> | undefined
1818
1801
 
1819
- /** @public */
1820
- export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
1821
-
1822
1802
  /** @public */
1823
1803
  export declare interface RawQueryResponse<R> {
1824
1804
  query: string
@@ -1904,7 +1884,6 @@ export declare interface ResponseEvent<T = unknown> {
1904
1884
  export declare interface ResponseQueryOptions extends RequestOptions {
1905
1885
  perspective?: ClientPerspective
1906
1886
  resultSourceMap?: boolean | 'withKeyArraySelector'
1907
- returnQuery?: boolean
1908
1887
  useCdn?: boolean
1909
1888
  stega?: boolean | StegaConfig
1910
1889
  cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
@@ -1991,18 +1970,6 @@ export declare class SanityClient {
1991
1970
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1992
1971
  options: UnfilteredResponseQueryOptions,
1993
1972
  ): Promise<RawQueryResponse<R>>
1994
- /**
1995
- * Perform a GROQ-query against the configured dataset.
1996
- *
1997
- * @param query - GROQ-query to perform
1998
- * @param params - Optional query parameters
1999
- * @param options - Request options
2000
- */
2001
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
2002
- query: string,
2003
- params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
2004
- options: UnfilteredResponseWithoutQuery,
2005
- ): Promise<RawQuerylessQueryResponse<R>>
2006
1973
  /**
2007
1974
  * Fetch a single document with the given ID.
2008
1975
  *
@@ -2690,23 +2657,6 @@ export declare type TransactionMutationOptions =
2690
2657
  /** @public */
2691
2658
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
2692
2659
  filterResponse: false
2693
- /**
2694
- * When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
2695
- * backwards compatibility (on the client side, not from the content lake API).
2696
- * Can also explicitly be set to `true`.
2697
- */
2698
- returnQuery?: true
2699
- }
2700
-
2701
- /**
2702
- * When using `filterResponse: false`, but you do not wish to receive back the query from
2703
- * the content lake API.
2704
- *
2705
- * @public
2706
- */
2707
- export declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
2708
- filterResponse: false
2709
- returnQuery: false
2710
2660
  }
2711
2661
 
2712
2662
  export {unstable__adapter}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { printNoDefaultExport, defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-BN5UYAym.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-BN5UYAym.js';
1
+ import { printNoDefaultExport, defineCreateClientExports, SanityClient, middleware } from './_chunks/nodeMiddleware-D2afPgJS.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableSanityClient, ObservableTransaction, Patch, ServerError, Transaction } from './_chunks/nodeMiddleware-D2afPgJS.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
4
 
5
5
  function defineDeprecatedCreateClient(createClient) {
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var browserMiddleware = require('./_chunks/browserMiddleware-Dp4wx9CK.cjs');
5
+ var browserMiddleware = require('./_chunks/browserMiddleware-e8tcYvdt.cjs');
6
6
  var getIt = require('get-it');
7
- var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-DGdRCWlF.cjs');
7
+ var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-Ji8dgoO-.cjs');
8
8
 
9
9
  class SanityStegaClient extends browserMiddleware.SanityClient {
10
10
  }
@@ -1,7 +1,7 @@
1
- import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-Cfl3LrrI.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-Cfl3LrrI.js';
1
+ import { SanityClient, ObservableSanityClient, defineCreateClientExports, envMiddleware } from './_chunks/browserMiddleware-C0hQLS9X.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/browserMiddleware-C0hQLS9X.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
- export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-DO8ipgJw.js';
4
+ export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-BfR5oD3Z.js';
5
5
 
6
6
  class SanityStegaClient extends SanityClient {
7
7
  }
package/dist/stega.cjs CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nodeMiddleware = require('./_chunks/nodeMiddleware-yTxugO4Q.cjs');
5
+ var nodeMiddleware = require('./_chunks/nodeMiddleware-BhRfWf0W.cjs');
6
6
  var getIt = require('get-it');
7
- var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-D6fHf69f.cjs');
7
+ var stegaEncodeSourceMap = require('./_chunks/stegaEncodeSourceMap-YSe0h4rd.cjs');
8
8
 
9
9
  class SanityStegaClient extends nodeMiddleware.SanityClient {
10
10
  }
package/dist/stega.d.ts CHANGED
@@ -1198,18 +1198,6 @@ export declare class ObservableSanityClient {
1198
1198
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1199
1199
  options: UnfilteredResponseQueryOptions,
1200
1200
  ): Observable<RawQueryResponse<R>>
1201
- /**
1202
- * Perform a GROQ-query against the configured dataset.
1203
- *
1204
- * @param query - GROQ-query to perform
1205
- * @param params - Optional query parameters
1206
- * @param options - Request options
1207
- */
1208
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
1209
- query: string,
1210
- params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
1211
- options: UnfilteredResponseWithoutQuery,
1212
- ): Observable<RawQuerylessQueryResponse<R>>
1213
1201
  /**
1214
1202
  * Fetch a single document with the given ID.
1215
1203
  *
@@ -1803,10 +1791,7 @@ export declare class ProjectsClient {
1803
1791
  }
1804
1792
 
1805
1793
  /** @public */
1806
- export declare type QueryOptions =
1807
- | FilteredResponseQueryOptions
1808
- | UnfilteredResponseQueryOptions
1809
- | UnfilteredResponseWithoutQuery
1794
+ export declare type QueryOptions = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
1810
1795
 
1811
1796
  /** @public */
1812
1797
  export declare interface QueryParams {
@@ -1830,8 +1815,6 @@ export declare interface QueryParams {
1830
1815
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1831
1816
  resultSourceMap?: never
1832
1817
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1833
- returnQuery?: never
1834
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1835
1818
  signal?: never
1836
1819
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1837
1820
  stega?: never
@@ -1851,9 +1834,6 @@ export declare interface QueryParams {
1851
1834
  */
1852
1835
  export declare type QueryWithoutParams = Record<string, never> | undefined
1853
1836
 
1854
- /** @public */
1855
- export declare type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
1856
-
1857
1837
  /** @public */
1858
1838
  export declare interface RawQueryResponse<R> {
1859
1839
  query: string
@@ -1939,7 +1919,6 @@ export declare interface ResponseEvent<T = unknown> {
1939
1919
  export declare interface ResponseQueryOptions extends RequestOptions {
1940
1920
  perspective?: ClientPerspective
1941
1921
  resultSourceMap?: boolean | 'withKeyArraySelector'
1942
- returnQuery?: boolean
1943
1922
  useCdn?: boolean
1944
1923
  stega?: boolean | StegaConfig
1945
1924
  cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
@@ -2026,18 +2005,6 @@ export declare class SanityClient {
2026
2005
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
2027
2006
  options: UnfilteredResponseQueryOptions,
2028
2007
  ): Promise<RawQueryResponse<R>>
2029
- /**
2030
- * Perform a GROQ-query against the configured dataset.
2031
- *
2032
- * @param query - GROQ-query to perform
2033
- * @param params - Optional query parameters
2034
- * @param options - Request options
2035
- */
2036
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
2037
- query: string,
2038
- params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
2039
- options: UnfilteredResponseWithoutQuery,
2040
- ): Promise<RawQuerylessQueryResponse<R>>
2041
2008
  /**
2042
2009
  * Fetch a single document with the given ID.
2043
2010
  *
@@ -2743,23 +2710,6 @@ export declare type TransactionMutationOptions =
2743
2710
  /** @public */
2744
2711
  export declare interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
2745
2712
  filterResponse: false
2746
- /**
2747
- * When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
2748
- * backwards compatibility (on the client side, not from the content lake API).
2749
- * Can also explicitly be set to `true`.
2750
- */
2751
- returnQuery?: true
2752
- }
2753
-
2754
- /**
2755
- * When using `filterResponse: false`, but you do not wish to receive back the query from
2756
- * the content lake API.
2757
- *
2758
- * @public
2759
- */
2760
- export declare interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
2761
- filterResponse: false
2762
- returnQuery: false
2763
2713
  }
2764
2714
 
2765
2715
  export {unstable__adapter}
package/dist/stega.js CHANGED
@@ -1,7 +1,7 @@
1
- import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-BN5UYAym.js';
2
- export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-BN5UYAym.js';
1
+ import { SanityClient, ObservableSanityClient, defineCreateClientExports, middleware } from './_chunks/nodeMiddleware-D2afPgJS.js';
2
+ export { BasePatch, BaseTransaction, ClientError, ObservablePatch, ObservableTransaction, Patch, ServerError, Transaction, vercelStegaCleanAll } from './_chunks/nodeMiddleware-D2afPgJS.js';
3
3
  export { adapter as unstable__adapter, environment as unstable__environment } from 'get-it';
4
- export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-MOb3TLiL.js';
4
+ export { encodeIntoResult, stegaEncodeSourceMap } from './_chunks/stegaEncodeSourceMap-B3BX9g4D.js';
5
5
 
6
6
  class SanityStegaClient extends SanityClient {
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.13.0",
3
+ "version": "6.13.2",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -28,14 +28,12 @@ import type {
28
28
  QueryOptions,
29
29
  QueryParams,
30
30
  QueryWithoutParams,
31
- RawQuerylessQueryResponse,
32
31
  RawQueryResponse,
33
32
  RawRequestOptions,
34
33
  SanityDocument,
35
34
  SanityDocumentStub,
36
35
  SingleMutationResult,
37
36
  UnfilteredResponseQueryOptions,
38
- UnfilteredResponseWithoutQuery,
39
37
  } from './types'
40
38
  import {ObservableUsersClient, UsersClient} from './users/UsersClient'
41
39
 
@@ -162,18 +160,6 @@ export class ObservableSanityClient {
162
160
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
163
161
  options: UnfilteredResponseQueryOptions,
164
162
  ): Observable<RawQueryResponse<R>>
165
- /**
166
- * Perform a GROQ-query against the configured dataset.
167
- *
168
- * @param query - GROQ-query to perform
169
- * @param params - Optional query parameters
170
- * @param options - Request options
171
- */
172
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
173
- query: string,
174
- params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
175
- options: UnfilteredResponseWithoutQuery,
176
- ): Observable<RawQuerylessQueryResponse<R>>
177
163
  fetch<R, Q>(
178
164
  query: string,
179
165
  params?: Q,
@@ -813,18 +799,6 @@ export class SanityClient {
813
799
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
814
800
  options: UnfilteredResponseQueryOptions,
815
801
  ): Promise<RawQueryResponse<R>>
816
- /**
817
- * Perform a GROQ-query against the configured dataset.
818
- *
819
- * @param query - GROQ-query to perform
820
- * @param params - Optional query parameters
821
- * @param options - Request options
822
- */
823
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
824
- query: string,
825
- params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
826
- options: UnfilteredResponseWithoutQuery,
827
- ): Promise<RawQuerylessQueryResponse<R>>
828
802
  fetch<R, Q>(query: string, params?: Q, options?: QueryOptions): Promise<RawQueryResponse<R> | R> {
829
803
  return lastValueFrom(
830
804
  dataMethods._fetch<R, Q>(
@@ -80,11 +80,6 @@ export function _fetch<R, Q>(
80
80
  const params = stega.enabled ? vercelStegaCleanAll(_params) : _params
81
81
  const mapResponse =
82
82
  options.filterResponse === false ? (res: Any) => res : (res: Any) => res.result
83
-
84
- // Default to not returning the query, unless `filterResponse` is `false`,
85
- // or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy
86
- const returnQuery = options.filterResponse === false && options.returnQuery !== false
87
-
88
83
  const {cache, next, ...opts} = {
89
84
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
90
85
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
@@ -98,13 +93,7 @@ export function _fetch<R, Q>(
98
93
  ? {...opts, fetch: {cache, next}}
99
94
  : opts
100
95
 
101
- const $request = _dataRequest(
102
- client,
103
- httpRequest,
104
- 'query',
105
- {query, params, options: {returnQuery}},
106
- reqOpts,
107
- )
96
+ const $request = _dataRequest(client, httpRequest, 'query', {query, params}, reqOpts)
108
97
  return stega.enabled
109
98
  ? $request.pipe(
110
99
  combineLatestWith(
@@ -11,7 +11,7 @@ export const encodeQueryString = ({
11
11
  }) => {
12
12
  const searchParams = new URLSearchParams()
13
13
  // We generally want tag at the start of the query string
14
- const {tag, returnQuery, ...opts} = options
14
+ const {tag, ...opts} = options
15
15
  // We're using `append` instead of `set` to support React Native: https://github.com/facebook/react-native/blob/1982c4722fcc51aa87e34cf562672ee4aff540f1/packages/react-native/Libraries/Blob/URL.js#L86-L88
16
16
  if (tag) searchParams.append('tag', tag)
17
17
  searchParams.append('query', query)
@@ -26,8 +26,5 @@ export const encodeQueryString = ({
26
26
  if (value) searchParams.append(key, `${value}`)
27
27
  }
28
28
 
29
- // `returnQuery` is default `true`, so needs an explicit `false` handling
30
- if (returnQuery === false) searchParams.append('returnQuery', 'false')
31
-
32
29
  return `?${searchParams}`
33
30
  }
package/src/types.ts CHANGED
@@ -452,8 +452,6 @@ export interface QueryParams {
452
452
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
453
453
  resultSourceMap?: never
454
454
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
455
- returnQuery?: never
456
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
457
455
  signal?: never
458
456
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
459
457
  stega?: never
@@ -723,7 +721,6 @@ export interface ListenOptions {
723
721
  export interface ResponseQueryOptions extends RequestOptions {
724
722
  perspective?: ClientPerspective
725
723
  resultSourceMap?: boolean | 'withKeyArraySelector'
726
- returnQuery?: boolean
727
724
  useCdn?: boolean
728
725
  stega?: boolean | StegaConfig
729
726
  // The `cache` and `next` options are specific to the Next.js App Router integration
@@ -739,31 +736,10 @@ export interface FilteredResponseQueryOptions extends ResponseQueryOptions {
739
736
  /** @public */
740
737
  export interface UnfilteredResponseQueryOptions extends ResponseQueryOptions {
741
738
  filterResponse: false
742
-
743
- /**
744
- * When `filterResponse` is `false`, `returnQuery` also defaults to `true` for
745
- * backwards compatibility (on the client side, not from the content lake API).
746
- * Can also explicitly be set to `true`.
747
- */
748
- returnQuery?: true
749
- }
750
-
751
- /**
752
- * When using `filterResponse: false`, but you do not wish to receive back the query from
753
- * the content lake API.
754
- *
755
- * @public
756
- */
757
- export interface UnfilteredResponseWithoutQuery extends ResponseQueryOptions {
758
- filterResponse: false
759
- returnQuery: false
760
739
  }
761
740
 
762
741
  /** @public */
763
- export type QueryOptions =
764
- | FilteredResponseQueryOptions
765
- | UnfilteredResponseQueryOptions
766
- | UnfilteredResponseWithoutQuery
742
+ export type QueryOptions = FilteredResponseQueryOptions | UnfilteredResponseQueryOptions
767
743
 
768
744
  /** @public */
769
745
  export interface RawQueryResponse<R> {
@@ -773,9 +749,6 @@ export interface RawQueryResponse<R> {
773
749
  resultSourceMap?: ContentSourceMap
774
750
  }
775
751
 
776
- /** @public */
777
- export type RawQuerylessQueryResponse<R> = Omit<RawQueryResponse<R>, 'query'>
778
-
779
752
  /** @internal */
780
753
  export type BaseMutationOptions = RequestOptions & {
781
754
  visibility?: 'sync' | 'async' | 'deferred'
@@ -1,10 +1,14 @@
1
1
  import type {MutationSelection} from '../types'
2
2
 
3
3
  export function getSelection(sel: unknown): MutationSelection {
4
- if (typeof sel === 'string' || Array.isArray(sel)) {
4
+ if (typeof sel === 'string') {
5
5
  return {id: sel}
6
6
  }
7
7
 
8
+ if (Array.isArray(sel)) {
9
+ return {query: '*[_id in $ids]', params: {ids: sel}}
10
+ }
11
+
8
12
  if (typeof sel === 'object' && sel !== null && 'query' in sel && typeof sel.query === 'string') {
9
13
  return 'params' in sel && typeof sel.params === 'object' && sel.params !== null
10
14
  ? {query: sel.query, params: sel.params}
@@ -2726,9 +2726,12 @@
2726
2726
  }
2727
2727
 
2728
2728
  function getSelection(sel) {
2729
- if (typeof sel === "string" || Array.isArray(sel)) {
2729
+ if (typeof sel === "string") {
2730
2730
  return { id: sel };
2731
2731
  }
2732
+ if (Array.isArray(sel)) {
2733
+ return { query: "*[_id in $ids]", params: { ids: sel } };
2734
+ }
2732
2735
  if (typeof sel === "object" && sel !== null && "query" in sel && typeof sel.query === "string") {
2733
2736
  return "params" in sel && typeof sel.params === "object" && sel.params !== null ? { query: sel.query, params: sel.params } : { query: sel.query };
2734
2737
  }
@@ -3406,7 +3409,7 @@
3406
3409
  options = {}
3407
3410
  }) => {
3408
3411
  const searchParams = new URLSearchParams();
3409
- const { tag, returnQuery, ...opts } = options;
3412
+ const { tag, ...opts } = options;
3410
3413
  if (tag)
3411
3414
  searchParams.append("tag", tag);
3412
3415
  searchParams.append("query", query);
@@ -3417,8 +3420,6 @@
3417
3420
  if (value)
3418
3421
  searchParams.append(key, "".concat(value));
3419
3422
  }
3420
- if (returnQuery === false)
3421
- searchParams.append("returnQuery", "false");
3422
3423
  return "?".concat(searchParams);
3423
3424
  };
3424
3425
 
@@ -3450,7 +3451,6 @@
3450
3451
  } : _stega;
3451
3452
  const params = stega.enabled ? vercelStegaCleanAll(_params) : _params;
3452
3453
  const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
3453
- const returnQuery = options.filterResponse === false && options.returnQuery !== false;
3454
3454
  const { cache, next, ...opts } = {
3455
3455
  // Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
3456
3456
  // This is necessary in React Server Components to avoid opting out of Request Memoization.
@@ -3460,17 +3460,11 @@
3460
3460
  ...options
3461
3461
  };
3462
3462
  const reqOpts = typeof cache !== "undefined" || typeof next !== "undefined" ? { ...opts, fetch: { cache, next } } : opts;
3463
- const $request = _dataRequest(
3464
- client,
3465
- httpRequest,
3466
- "query",
3467
- { query, params, options: { returnQuery } },
3468
- reqOpts
3469
- );
3463
+ const $request = _dataRequest(client, httpRequest, "query", { query, params }, reqOpts);
3470
3464
  return stega.enabled ? $request.pipe(
3471
3465
  combineLatestWith(
3472
3466
  from(
3473
- Promise.resolve().then(function () { return stegaEncodeSourceMapDO8ipgJw; }).then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
3467
+ Promise.resolve().then(function () { return stegaEncodeSourceMapBfR5oD3Z; }).then(function (n) { return n.stegaEncodeSourceMap$1; }).then(
3474
3468
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
3475
3469
  )
3476
3470
  )
@@ -4996,7 +4990,7 @@
4996
4990
  stegaEncodeSourceMap: stegaEncodeSourceMap
4997
4991
  });
4998
4992
 
4999
- var stegaEncodeSourceMapDO8ipgJw = /*#__PURE__*/Object.freeze({
4993
+ var stegaEncodeSourceMapBfR5oD3Z = /*#__PURE__*/Object.freeze({
5000
4994
  __proto__: null,
5001
4995
  encodeIntoResult: encodeIntoResult,
5002
4996
  stegaEncodeSourceMap: stegaEncodeSourceMap,