@sanity/client 8.5.0 → 8.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { _r as VideoSubtitleInfoPublic, dr as VideoPlaybackInfoSigned, fr as VideoPlaybackTokens, gr as VideoSubtitleInfo, hr as VideoRenditionInfoSigned, mr as VideoRenditionInfoPublic, or as VideoPlaybackInfo, pr as VideoRenditionInfo, vr as VideoSubtitleInfoSigned } from "./types-CtHEe8SF.js";
1
+ import { _r as VideoSubtitleInfoPublic, dr as VideoPlaybackInfoSigned, fr as VideoPlaybackTokens, gr as VideoSubtitleInfo, hr as VideoRenditionInfoSigned, mr as VideoRenditionInfoPublic, or as VideoPlaybackInfo, pr as VideoRenditionInfo, vr as VideoSubtitleInfoSigned } from "./types-B1XLvey7.js";
2
2
  /**
3
3
  * Check if the entire playback info response requires signed URLs
4
4
  * @public
@@ -1,5 +1,6 @@
1
1
  import { t as isRecord } from "./isRecord-Kfmt-nk-.js";
2
2
  import { createRequester, isHttpError } from "get-it";
3
+ import { anySignal } from "get-it/any-signal";
3
4
  import { isRetryableRequest, retry } from "get-it/middleware";
4
5
  import { Observable, from } from "rxjs";
5
6
  /**
@@ -275,7 +276,7 @@ function defineRequester(envOptions, config = {}) {
275
276
  if (typeof options.url != "string") throw TypeError("Request options must include a `url`");
276
277
  return executeRequest(requester, options);
277
278
  }, observable = (options) => new Observable((subscriber) => {
278
- let controller = new AbortController(), userSignal = options.signal, signal = userSignal ? AbortSignal.any([userSignal, controller.signal]) : controller.signal, subscription = from(promise({
279
+ let controller = new AbortController(), userSignal = options.signal, signal = userSignal ? anySignal([userSignal, controller.signal]) : controller.signal, subscription = from(promise({
279
280
  ...options,
280
281
  signal
281
282
  })).subscribe(subscriber);
@@ -370,4 +371,4 @@ function printWarnings(config) {
370
371
  }
371
372
  export { ServerError as a, isHttpError$1 as c, CorsOriginError as i, isQueryParseError as l, parseJsonText as n, formatQueryParseError as o, ClientError as r, httpResponseFromFetch as s, defineRequester as t, _defineProperty as u };
372
373
 
373
- //# sourceMappingURL=request-BhMuKj0D.js.map
374
+ //# sourceMappingURL=request-CYLhJzOA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-CYLhJzOA.js","names":["headersToRecord","isHttpError","isGetItHttpError"],"sources":["../src/util/codeFrame.ts","../src/http/errors.ts","../src/http/request.ts"],"sourcesContent":["/**\n * Inlined, modified version of the `codeFrameColumns` function from `@babel/code-frame`.\n * MIT-licensed - https://github.com/babel/babel/blob/main/LICENSE\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors.\n */\ntype Location = {\n column: number\n line: number\n}\n\ntype NodeLocation = {\n start: Location\n end?: Location\n}\n\ntype GroqLocation = {\n start: number\n end?: number\n}\n\n/**\n * RegExp to test for newlines.\n */\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/\n\n/**\n * Extract what lines should be marked and highlighted.\n */\n\ntype MarkerLines = Record<number, true | [number, number]>\n\n/**\n * Highlight a code frame with the given location and message.\n *\n * @param query - The query to be highlighted.\n * @param location - The location of the error in the code/query.\n * @param message - Message to be displayed inline (if possible) next to the highlighted\n * location in the code. If it can't be positioned inline, it will be placed above the\n * code frame.\n * @returns The highlighted code frame.\n */\nexport function codeFrame(query: string, location: GroqLocation, message?: string): string {\n const lines = query.split(NEWLINE)\n const loc = {\n start: columnToLine(location.start, lines),\n end: location.end ? columnToLine(location.end, lines) : undefined,\n }\n\n const {start, end, markerLines} = getMarkerLines(loc, lines)\n\n const numberMaxWidth = `${end}`.length\n\n return query\n .split(NEWLINE, end)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth)\n const gutter = ` ${paddedNumber} |`\n const hasMarker = markerLines[number]\n const lastMarkerLine = !markerLines[number + 1]\n if (!hasMarker) {\n return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`\n }\n\n let markerLine = ''\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\\t]/g, ' ')\n const numberOfMarkers = hasMarker[1] || 1\n\n markerLine = [\n '\\n ',\n gutter.replace(/\\d/g, ' '),\n ' ',\n markerSpacing,\n '^'.repeat(numberOfMarkers),\n ].join('')\n\n if (lastMarkerLine && message) {\n markerLine += ' ' + message\n }\n }\n return ['>', gutter, line.length > 0 ? ` ${line}` : '', markerLine].join('')\n })\n .join('\\n')\n}\n\nfunction getMarkerLines(\n loc: NodeLocation,\n source: Array<string>,\n): {\n start: number\n end: number\n markerLines: MarkerLines\n} {\n const startLoc: Location = {...loc.start}\n const endLoc: Location = {...startLoc, ...loc.end}\n const linesAbove = 2\n const linesBelow = 3\n const startLine = startLoc.line ?? -1\n const startColumn = startLoc.column ?? 0\n const endLine = endLoc.line\n const endColumn = endLoc.column\n\n let start = Math.max(startLine - (linesAbove + 1), 0)\n let end = Math.min(source.length, endLine + linesBelow)\n\n if (startLine === -1) {\n start = 0\n }\n\n if (endLine === -1) {\n end = source.length\n }\n\n const lineDiff = endLine - startLine\n const markerLines: MarkerLines = {}\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine\n\n if (!startColumn) {\n markerLines[lineNumber] = true\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1].length\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn]\n } else {\n const sourceLength = source[lineNumber - i].length\n\n markerLines[lineNumber] = [0, sourceLength]\n }\n }\n } else {\n if (startColumn === endColumn) {\n if (startColumn) {\n markerLines[startLine] = [startColumn, 0]\n } else {\n markerLines[startLine] = true\n }\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn]\n }\n }\n\n return {start, end, markerLines}\n}\n\nfunction columnToLine(column: number, lines: string[]): Location {\n let offset = 0\n\n for (let i = 0; i < lines.length; i++) {\n const lineLength = lines[i].length + 1 // assume '\\n' after each line\n\n if (offset + lineLength > column) {\n return {\n line: i + 1, // 1-based line\n column: column - offset, // 0-based column\n }\n }\n\n offset += lineLength\n }\n\n // Fallback: beyond last line\n return {\n line: lines.length,\n column: lines[lines.length - 1]?.length ?? 0,\n }\n}\n","import type {ActionError, Any, ErrorProps, MutationError, QueryParseError} from '../types'\nimport {codeFrame} from '../util/codeFrame'\nimport {isRecord} from '../util/isRecord'\n\nconst MAX_ITEMS_IN_ERROR_MESSAGE = 5\n\n/**\n * Canonical HTTP response shape used internally to build {@link ClientError}\n * and {@link ServerError}. Decouples the error layer from any particular\n * transport library — adapters in the HTTP layer (e.g. `httpResponseFromGetIt`)\n * project transport-specific response shapes into this stable form before\n * constructing errors.\n *\n * Matches the public {@link HttpError.response} shape so consumers see no\n * difference in error properties when the underlying transport changes.\n *\n * @internal\n */\nexport interface CanonicalHttpResponse {\n statusCode: number\n statusMessage: string | null\n headers: Record<string, string>\n body: unknown\n url: string\n method: string\n}\n\n/**\n * Adapter for buffered responses from get-it v9 (`BufferedResponse`-shaped).\n *\n * The URL and method aren't on the response itself in v9, so the request\n * options must be passed alongside.\n *\n * @internal\n */\nexport function httpResponseFromFetch(\n res: {\n status: number\n statusText: string\n headers: Headers\n body: unknown\n url: string\n },\n reqUrl: string,\n reqMethod: string,\n): CanonicalHttpResponse {\n return {\n statusCode: res.status,\n statusMessage: res.statusText || null,\n headers: headersToRecord(res.headers),\n body: res.body,\n url: res.url || reqUrl,\n method: reqMethod,\n }\n}\n\nfunction headersToRecord(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {}\n headers.forEach((value, key) => {\n out[key] = value\n })\n return out\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 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/**\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 function isHttpError(error: unknown): error is HttpError {\n if (!isRecord(error)) {\n return false\n }\n\n const response = error.response\n if (\n typeof error.statusCode !== 'number' ||\n typeof error.message !== 'string' ||\n !isRecord(response)\n ) {\n return false\n }\n\n if (\n typeof response.body === 'undefined' ||\n typeof response.url !== 'string' ||\n typeof response.method !== 'string' ||\n typeof response.headers !== 'object' ||\n typeof response.statusCode !== 'number'\n ) {\n return false\n }\n\n return true\n}\n\n/** @public */\nexport class ClientError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode'] = 400\n responseBody: ErrorProps['responseBody']\n traceId: ErrorProps['traceId']\n details: ErrorProps['details']\n\n constructor(res: Any, tag?: string) {\n const props = extractErrorProps(res, tag)\n super(props.message)\n Object.assign(this, props)\n }\n}\n\n/** @public */\nexport class ServerError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode'] = 500\n responseBody: ErrorProps['responseBody']\n traceId: ErrorProps['traceId']\n details: ErrorProps['details']\n\n constructor(res: Any) {\n const props = extractErrorProps(res)\n super(props.message)\n Object.assign(this, props)\n }\n}\n\nfunction extractErrorProps(res: Any, tag?: string): ErrorProps {\n const body = res.body\n const props = {\n response: res,\n statusCode: res.statusCode,\n responseBody: stringifyBody(body, res),\n traceId: extractTraceId(res),\n message: '',\n details: undefined as Any,\n }\n\n // Fall back early if we didn't get a JSON object returned as expected\n if (!isRecord(body)) {\n props.message = `${httpErrorMessage(res, body)}${formatTraceId(props.traceId)}`\n return props\n }\n\n const error = body.error\n\n // API/Boom style errors ({statusCode, error, message})\n if (typeof error === 'string' && typeof body.message === 'string') {\n props.message = `${error} - ${body.message}${formatTraceId(props.traceId)}`\n return props\n }\n\n // Content Lake errors with a `error` prop being an object\n if (typeof error !== 'object' || error === null) {\n if (typeof error === 'string') {\n props.message = `${error}${formatTraceId(props.traceId)}`\n } else if (typeof body.message === 'string') {\n props.message = `${body.message}${formatTraceId(props.traceId)}`\n } else {\n props.message = `${httpErrorMessage(res, body)}${formatTraceId(props.traceId)}`\n }\n return props\n }\n\n // Mutation errors (specifically)\n if (isMutationError(error) || isActionError(error)) {\n const allItems = error.items || []\n const items = allItems\n .slice(0, MAX_ITEMS_IN_ERROR_MESSAGE)\n .map((item) => item.error?.description)\n .filter(Boolean)\n let itemsStr = items.length ? `:\\n- ${items.join('\\n- ')}` : ''\n if (allItems.length > MAX_ITEMS_IN_ERROR_MESSAGE) {\n itemsStr += `\\n...and ${allItems.length - MAX_ITEMS_IN_ERROR_MESSAGE} more`\n }\n props.message = `${error.description}${formatTraceId(props.traceId)}${itemsStr}`\n props.details = body.error\n return props\n }\n\n // Query parse errors\n if (isQueryParseError(error)) {\n props.message = formatQueryParseError(error, tag, props.traceId)\n props.details = body.error\n return props\n }\n\n if ('description' in error && typeof error.description === 'string') {\n // Query/database errors ({error: {description, other, arb, props}})\n props.message = `${error.description}${formatTraceId(props.traceId)}`\n props.details = error\n return props\n }\n\n // Other, more arbitrary errors\n props.message = `${httpErrorMessage(res, body)}${formatTraceId(props.traceId)}`\n return props\n}\n\nfunction isMutationError(error: object): error is MutationError {\n return (\n 'type' in error &&\n error.type === 'mutationError' &&\n 'description' in error &&\n typeof error.description === 'string'\n )\n}\n\nfunction isActionError(error: object): error is ActionError {\n return (\n 'type' in error &&\n error.type === 'actionError' &&\n 'description' in error &&\n typeof error.description === 'string'\n )\n}\n\n/** @internal */\nexport function isQueryParseError(error: object): error is QueryParseError {\n return (\n isRecord(error) &&\n error.type === 'queryParseError' &&\n typeof error.query === 'string' &&\n typeof error.start === 'number' &&\n typeof error.end === 'number'\n )\n}\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 function formatQueryParseError(\n error: QueryParseError,\n tag?: string | null,\n traceId?: string,\n) {\n const {query, start, end, description} = error\n const withTraceId = traceId ? `\\n(traceId: ${traceId})` : ''\n\n if (!query || typeof start === 'undefined') {\n return `GROQ query parse error: ${description}${withTraceId}`\n }\n\n const withTag = tag ? `\\n\\nTag: ${tag}` : ''\n const framed = codeFrame(query, {start, end}, description)\n\n return `GROQ query parse error:\\n${framed}${withTag}${withTraceId}`\n}\n\nfunction httpErrorMessage(res: Any, body: unknown) {\n const details = typeof body === 'string' ? ` (${sliceWithEllipsis(body, 100)})` : ''\n const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : ''\n return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}${details}`\n}\n\n/**\n * Extract the traceId from the traceparent header on the response.\n *\n * The traceparent is on the format [version]-[traceId]-[parentId]-[traceFlags], but\n * when debugging end-user issues it's the traceId we need to be able to get hold of\n * the relevant traces.\n *\n * @see https://www.w3.org/TR/trace-context/\n * @returns The traceId for HTTP response\n */\nfunction extractTraceId(res: Any): string | undefined {\n const traceparent = res?.headers?.['traceparent']\n if (!traceparent) return\n\n return traceparent.split('-')[1]\n}\n\nfunction stringifyBody(body: Any, res: Any) {\n const contentType = (res.headers['content-type'] || '').toLowerCase()\n const isJson = contentType.indexOf('application/json') !== -1\n return isJson ? JSON.stringify(body, null, 2) : body\n}\n\nfunction formatTraceId(traceId: string | undefined): string {\n return traceId ? ` (traceId: ${traceId})` : ''\n}\n\nfunction sliceWithEllipsis(str: string, max: number) {\n return str.length > max ? `${str.slice(0, max)}…` : str\n}\n\n/** @public */\nexport class CorsOriginError extends Error {\n projectId?: string\n addOriginUrl?: URL\n\n constructor({projectId, credentials}: {projectId?: string; credentials?: boolean} = {}) {\n super('CorsOriginError')\n this.name = 'CorsOriginError'\n this.projectId = projectId\n\n // Only build a deep-link when we know which project the user needs to\n // configure - without `projectId` the management URL can't actually route\n // them anywhere useful.\n if (projectId && typeof location !== 'undefined') {\n const url = new URL(`https://sanity.io/manage/project/${projectId}/api`)\n const {origin} = location\n url.searchParams.set('cors', 'add')\n url.searchParams.set('origin', origin)\n if (credentials) {\n // Pre-selects the \"Allow credentials (token-based auth)\" toggle in\n // the Sanity management CORS form.\n url.searchParams.set('credentials', '')\n }\n this.addOriginUrl = url\n this.message = `The current origin is not allowed to connect to the Live Content API. Add it here: ${url}`\n } else if (projectId) {\n this.message = `The current origin is not allowed to connect to the Live Content API. Change your configuration here: https://sanity.io/manage/project/${projectId}/api`\n } else {\n this.message = `The current origin is not allowed to connect to the Live Content API.`\n }\n }\n}\n","import {\n createRequester,\n type FetchFunction,\n isHttpError as isGetItHttpError,\n type RequestOptions as FetchRequestOptions,\n type TransformMiddleware,\n type WrappingMiddleware,\n} from 'get-it'\nimport {anySignal} from 'get-it/any-signal'\nimport {isRetryableRequest, retry} from 'get-it/middleware'\nimport {from, Observable} from 'rxjs'\n\nimport type {Any} from '../types'\nimport {ClientError, httpResponseFromFetch, ServerError} from './errors'\n\n/**\n * Middleware accepted by the internal HTTP layer. Two flavors per get-it v9:\n * a flat-pipeline transform (`beforeRequest`/`afterResponse`) or a wrapping\n * middleware that surrounds the fetch chain.\n *\n * @internal\n */\nexport type LegacyMiddleware = TransformMiddleware | WrappingMiddleware\n\n/**\n * The shape this client's internal pipeline produces. Mirrors the historical\n * `ResponseEvent` from the get-it v8 multi-event observable, so all the existing\n * downstream code (`_requestObservable`, `_uploadObservable`,\n * `defineCreateClient`) keeps working without churn.\n *\n * @internal\n */\nexport interface ResponseEvent {\n type: 'response'\n body: unknown\n statusCode: number\n statusMessage: string | null\n headers: Record<string, string>\n url: string\n method: string\n}\n\n/**\n * Legacy \"requester\" type - the observable half of `defineRequester`'s\n * result. Returns a single-event Observable for compatibility with the rest\n * of the codebase.\n *\n * @internal\n */\nexport type LegacyRequester = (options: Any) => Observable<ResponseEvent>\n\n/**\n * Promise-based sibling of {@link LegacyRequester}. Resolves directly to the\n * single `ResponseEvent` the transport produces, skipping the RxJS wrapper.\n * Used by the promise-based client surface so it never constructs an\n * Observable.\n *\n * @internal\n */\nexport type PromiseRequester = (options: Any) => Promise<ResponseEvent>\n\n/**\n * Both forms of the transport, sharing a single underlying get-it requester\n * (so retry state and the one-shot warning de-duplication are shared between\n * the observable and promise paths).\n *\n * @internal\n */\nexport interface DualRequester {\n observable: LegacyRequester\n promise: PromiseRequester\n}\n\n/**\n * Options for tuning the HTTP request pipeline per-client.\n *\n * @internal\n */\nexport interface HttpRequestConfig {\n ignoreWarnings?: string | RegExp | Array<string | RegExp>\n maxRetries?: number\n retryDelay?: (attemptNumber: number) => number\n}\n\n/**\n * Build both the observable and promise transport forms from a single get-it\n * requester. The promise form is the primitive (`executeRequest` is already\n * promise-based); the observable form wraps it lazily so each subscription\n * starts its own request (cold), and unsubscribing aborts the in-flight\n * fetch — the same contract as the get-it v8 observable adapter.\n *\n * @internal\n */\nexport function defineRequester(\n envOptions: EnvironmentOptions,\n config: HttpRequestConfig = {},\n): DualRequester {\n // Framework-patched fetch implementations read extra `RequestInit` fields\n // for caching semantics — Next.js App Router's `cache` and `next` options in\n // particular. Legacy callers pass those via an object-valued `fetch` request\n // option (see `adaptToFetchOptions`, which stashes it in `meta.fetchInit`\n // since get-it v9's own `fetch` option only accepts a function). Merge them\n // into the init of whichever fetch implementation is effective for the\n // request: per-request/test-override fetch, the environment default, or the\n // global fetch.\n const applyFetchInit: WrappingMiddleware = (opts, next) => {\n const fetchInit = opts.meta?.fetchInit\n if (typeof fetchInit !== 'object' || fetchInit === null) return next(opts)\n const baseFetch: NonNullable<FetchRequestOptions['fetch']> =\n opts.fetch ?? envOptions.fetch ?? globalThis.fetch\n const fetchWithInit: typeof baseFetch = (input, init) =>\n baseFetch(input, {...fetchInit, ...init})\n return next({...opts, fetch: fetchWithInit})\n }\n\n const requester = createRequester({\n ...(envOptions.fetch ? {fetch: envOptions.fetch} : {}),\n headers: envOptions.headers,\n // Keep get-it's built-in 4xx/5xx → HttpError so the retry middleware can\n // see them; we translate to ClientError/ServerError after the retry loop\n // has exhausted in `executeRequest`.\n httpErrors: true,\n middleware: [\n retry({\n shouldRetry: shouldRetryRequest,\n maxRetries: config.maxRetries ?? 5,\n ...(config.retryDelay ? {retryDelay: config.retryDelay} : {}),\n }),\n ...envOptions.middleware,\n applyFetchInit,\n printWarnings(config),\n ],\n })\n\n const promise: PromiseRequester = (options: Any) => {\n // Options arrive fetch-shaped from `requestOptions` — the single\n // translation boundary between public option names and the transport.\n if (typeof options.url !== 'string') {\n throw new TypeError('Request options must include a `url`')\n }\n return executeRequest(requester, options)\n }\n\n const observable: LegacyRequester = (options: Any) =>\n new Observable<ResponseEvent>((subscriber) => {\n const controller = new AbortController()\n const userSignal: AbortSignal | undefined = options.signal\n const signal = userSignal ? anySignal([userSignal, controller.signal]) : controller.signal\n const subscription = from(promise({...options, signal})).subscribe(subscriber)\n return () => {\n subscription.unsubscribe()\n controller.abort()\n }\n })\n\n return {promise, observable}\n}\n\n/**\n * Options describing the environment-specific defaults (Node vs. browser).\n *\n * @internal\n */\nexport interface EnvironmentOptions {\n fetch?: FetchRequestOptions['fetch']\n headers?: Record<string, string>\n middleware: LegacyMiddleware[]\n /**\n * Resolves the environment's fetch implementation — the same transport\n * regular requests use (custom fetch variants, undici configuration,\n * env-proxy support and all), optionally configured for an explicit proxy\n * URL. Lets consumers of the resolved config (the EventSource fetch\n * resolver) avoid falling back to whatever `globalThis.fetch` happens to\n * be. The Node environment supplies get-it's undici-backed fetch; the\n * browser environment leaves it unset (the global fetch IS the\n * environment's fetch there).\n *\n * Looked up via the env rather than imported directly so that the Node-only\n * `get-it/node` (which transitively pulls in `undici`) never ends up in the\n * browser bundle, even via rollup's inlined dynamic imports.\n */\n resolveFetch?: (proxyUrl?: string) => FetchFunction\n}\n\nasync function executeRequest(\n requester: ReturnType<typeof createRequester>,\n fetchOptions: FetchRequestOptions,\n): Promise<ResponseEvent> {\n const url = fetchOptions.url\n const method = (fetchOptions.method ?? 'GET').toUpperCase()\n\n let response\n try {\n response = await requester(fetchOptions)\n } catch (err) {\n if (isGetItHttpError(err)) {\n // `err.body` is the response body as a string (get-it v9 stores the\n // already-decoded text), regardless of which response variant\n // `err.response` is.\n const errBodyText = typeof err.body === 'string' ? err.body : ''\n const errBody = parseJsonText(errBodyText, err.headers)\n const canonical = httpResponseFromFetch(\n {\n status: err.status,\n statusText: err.statusText,\n headers: err.headers,\n body: errBody,\n url: err.response.url ?? err.url,\n },\n url,\n method,\n )\n const tag = extractRequestTag(fetchOptions.query)\n if (canonical.statusCode >= 500) {\n throw new ServerError(canonical)\n }\n throw new ClientError(canonical, tag)\n }\n throw err\n }\n\n const body = parseJsonBody(response)\n return {\n type: 'response',\n body,\n statusCode: response.status,\n statusMessage: response.statusText || null,\n headers: headersToRecord(response.headers),\n url: response.url || url,\n method,\n }\n}\n\n/**\n * Extract the GROQ request tag (used for error messages) from the query.\n */\nfunction extractRequestTag(query: FetchRequestOptions['query']): string | undefined {\n if (!query) return undefined\n if (query instanceof URLSearchParams) return query.get('tag') ?? undefined\n const tag = query.tag\n return typeof tag === 'string' ? tag : undefined\n}\n\nfunction parseJsonBody(response: {headers: Headers; text(): string}): unknown {\n return parseJsonText(response.text(), response.headers)\n}\n\n/**\n * Parse a response body according to its `content-type`: JSON when the header\n * says so (falling back to the raw text on malformed JSON), text otherwise.\n * Shared with the browser XHR upload path so error bodies parse identically\n * on both transports.\n *\n * @internal\n */\nexport function parseJsonText(text: string, headers: Headers): unknown {\n const contentType = (headers.get('content-type') ?? '').toLowerCase()\n if (!text) return undefined\n if (contentType.includes('application/json')) {\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n return text\n}\n\nfunction headersToRecord(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {}\n headers.forEach((value, key) => {\n out[key] = value\n })\n return out\n}\n\nfunction shouldRetryRequest(err: unknown, attempt: number, options: FetchRequestOptions): boolean {\n // HTTP errors aren't usually retryable, but Content Lake gives us a few\n // status codes where retrying *is* the right move.\n if (isGetItHttpError(err)) {\n const isSafe = (options.method ?? 'GET') === 'GET' || options.method === 'HEAD'\n const isQuery = (options.url ?? '').includes('/data/query')\n const status = err.status\n const retryableStatus = status === 429 || status === 502 || status === 503\n if ((isSafe || isQuery) && retryableStatus) return true\n return false\n }\n\n return isRetryableRequest(err, attempt, options)\n}\n\nfunction printWarnings(config: HttpRequestConfig): TransformMiddleware {\n const seen: Record<string, boolean> = {}\n\n const shouldIgnore = (message: string): boolean => {\n if (config.ignoreWarnings === undefined) return false\n const patterns = Array.isArray(config.ignoreWarnings)\n ? config.ignoreWarnings\n : [config.ignoreWarnings]\n return patterns.some((pattern) =>\n typeof pattern === 'string' ? message.includes(pattern) : pattern.test(message),\n )\n }\n\n return {\n afterResponse(response) {\n const header = response.headers.get('x-sanity-warning')\n if (!header) return response\n // Multiple warnings can be comma-separated per HTTP header semantics.\n for (const msg of header.split(',').map((m) => m.trim())) {\n if (!msg || seen[msg] || shouldIgnore(msg)) continue\n seen[msg] = true\n // oxlint-disable-next-line no-console\n console.warn(msg)\n }\n return response\n },\n }\n}\n"],"mappings":";;;;;;;;AAwBA,MAAM,UAAU;;;;;;;;;;;AAkBhB,SAAgB,UAAU,OAAe,UAAwB,SAA0B;CACzF,IAAM,QAAQ,MAAM,MAAM,OAAO,GAM3B,EAAC,OAAO,KAAK,gBAAe,eAAe;EAJ/C,OAAO,aAAa,SAAS,OAAO,KAAK;EACzC,KAAK,SAAS,MAAM,aAAa,SAAS,KAAK,KAAK,IAAI,KAAA;CAGP,GAAG,KAAK,GAErD,iBAAiB,GAAG,MAAM;CAEhC,OAAO,MACJ,MAAM,SAAS,GAAG,CAAC,CACnB,MAAM,OAAO,GAAG,CAAC,CACjB,KAAK,MAAM,UAAU;EACpB,IAAM,SAAS,QAAQ,IAAI,OAErB,SAAS,IADM,IAAI,SAAS,MAAM,CAAC,cACX,EAAE,KAC1B,YAAY,YAAY,SACxB,iBAAiB,CAAC,YAAY,SAAS;EAC7C,IAAI,CAAC,WACH,OAAO,IAAI,SAAS,KAAK,SAAS,IAAI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,IAAI;GACF,OAAO,KAAK,MAAM,IAAI;EACxB,QAAQ;GACN,OAAO;EACT;EAEF,OAAO;CAFL;AAGJ;AAEA,SAAS,gBAAgB,SAA0C;CACjE,IAAM,MAA8B,CAAC;CAIrC,OAHA,QAAQ,SAAS,OAAO,QAAQ;EAC9B,IAAI,OAAO;CACb,CAAC,GACM;AACT;AAEA,SAAS,mBAAmB,KAAc,SAAiB,SAAuC;CAGhG,IAAIA,YAAiB,GAAG,GAAG;EACzB,IAAM,UAAU,QAAQ,UAAU,WAAW,SAAS,QAAQ,WAAW,QACnE,WAAW,QAAQ,OAAO,GAAA,CAAI,SAAS,aAAa,GACpD,SAAS,IAAI;EAGnB,OADA,IAAK,UAAU,aADS,WAAW,OAAO,WAAW,OAAO,WAAW;CAGzE;CAEA,OAAO,mBAAmB,KAAK,SAAS,OAAO;AACjD;AAEA,SAAS,cAAc,QAAgD;CACrE,IAAM,OAAgC,CAAC,GAEjC,gBAAgB,YAChB,OAAO,mBAAmB,KAAA,MACb,MAAM,QAAQ,OAAO,cAAc,IAChD,OAAO,iBACP,CAAC,OAAO,cAAc,EAAA,CACV,MAAM,YACpB,OAAO,WAAY,WAAW,QAAQ,SAAS,OAAO,IAAI,QAAQ,KAAK,OAAO,CAChF;CAGF,OAAO,EACL,cAAc,UAAU;EACtB,IAAM,SAAS,SAAS,QAAQ,IAAI,kBAAkB;EACtD,IAAI,CAAC,QAAQ,OAAO;EAEpB,KAAK,IAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC,GACjD,CAAC,OAAO,KAAK,QAAQ,aAAa,GAAG,MACzC,KAAK,OAAO,IAEZ,QAAQ,KAAK,GAAG;EAElB,OAAO;CACT,EACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { t as isRecord } from "./isRecord-Kfmt-nk-.js";
2
2
  import { createRequester, isHttpError } from "get-it";
3
+ import { anySignal } from "get-it/any-signal";
3
4
  import { isRetryableRequest, retry } from "get-it/middleware";
4
5
  import { Observable, from } from "rxjs";
5
6
  /**
@@ -257,7 +258,7 @@ function defineRequester(envOptions, config = {}) {
257
258
  if (typeof options.url != "string") throw TypeError("Request options must include a `url`");
258
259
  return executeRequest(requester, options);
259
260
  }, observable = (options) => new Observable((subscriber) => {
260
- let controller = new AbortController(), userSignal = options.signal, signal = userSignal ? AbortSignal.any([userSignal, controller.signal]) : controller.signal, subscription = from(promise({
261
+ let controller = new AbortController(), userSignal = options.signal, signal = userSignal ? anySignal([userSignal, controller.signal]) : controller.signal, subscription = from(promise({
261
262
  ...options,
262
263
  signal
263
264
  })).subscribe(subscriber);
@@ -352,4 +353,4 @@ function printWarnings(config) {
352
353
  }
353
354
  export { ServerError as a, isHttpError$1 as c, CorsOriginError as i, isQueryParseError as l, parseJsonText as n, formatQueryParseError as o, ClientError as r, httpResponseFromFetch as s, defineRequester as t };
354
355
 
355
- //# sourceMappingURL=request-SnMg7nUX.js.map
356
+ //# sourceMappingURL=request-DXOkY5MQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-DXOkY5MQ.js","names":["headersToRecord","isHttpError","isGetItHttpError"],"sources":["../src/util/codeFrame.ts","../src/http/errors.ts","../src/http/request.ts"],"sourcesContent":["/**\n * Inlined, modified version of the `codeFrameColumns` function from `@babel/code-frame`.\n * MIT-licensed - https://github.com/babel/babel/blob/main/LICENSE\n * Copyright (c) 2014-present Sebastian McKenzie and other contributors.\n */\ntype Location = {\n column: number\n line: number\n}\n\ntype NodeLocation = {\n start: Location\n end?: Location\n}\n\ntype GroqLocation = {\n start: number\n end?: number\n}\n\n/**\n * RegExp to test for newlines.\n */\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/\n\n/**\n * Extract what lines should be marked and highlighted.\n */\n\ntype MarkerLines = Record<number, true | [number, number]>\n\n/**\n * Highlight a code frame with the given location and message.\n *\n * @param query - The query to be highlighted.\n * @param location - The location of the error in the code/query.\n * @param message - Message to be displayed inline (if possible) next to the highlighted\n * location in the code. If it can't be positioned inline, it will be placed above the\n * code frame.\n * @returns The highlighted code frame.\n */\nexport function codeFrame(query: string, location: GroqLocation, message?: string): string {\n const lines = query.split(NEWLINE)\n const loc = {\n start: columnToLine(location.start, lines),\n end: location.end ? columnToLine(location.end, lines) : undefined,\n }\n\n const {start, end, markerLines} = getMarkerLines(loc, lines)\n\n const numberMaxWidth = `${end}`.length\n\n return query\n .split(NEWLINE, end)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth)\n const gutter = ` ${paddedNumber} |`\n const hasMarker = markerLines[number]\n const lastMarkerLine = !markerLines[number + 1]\n if (!hasMarker) {\n return ` ${gutter}${line.length > 0 ? ` ${line}` : ''}`\n }\n\n let markerLine = ''\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\\t]/g, ' ')\n const numberOfMarkers = hasMarker[1] || 1\n\n markerLine = [\n '\\n ',\n gutter.replace(/\\d/g, ' '),\n ' ',\n markerSpacing,\n '^'.repeat(numberOfMarkers),\n ].join('')\n\n if (lastMarkerLine && message) {\n markerLine += ' ' + message\n }\n }\n return ['>', gutter, line.length > 0 ? ` ${line}` : '', markerLine].join('')\n })\n .join('\\n')\n}\n\nfunction getMarkerLines(\n loc: NodeLocation,\n source: Array<string>,\n): {\n start: number\n end: number\n markerLines: MarkerLines\n} {\n const startLoc: Location = {...loc.start}\n const endLoc: Location = {...startLoc, ...loc.end}\n const linesAbove = 2\n const linesBelow = 3\n const startLine = startLoc.line ?? -1\n const startColumn = startLoc.column ?? 0\n const endLine = endLoc.line\n const endColumn = endLoc.column\n\n let start = Math.max(startLine - (linesAbove + 1), 0)\n let end = Math.min(source.length, endLine + linesBelow)\n\n if (startLine === -1) {\n start = 0\n }\n\n if (endLine === -1) {\n end = source.length\n }\n\n const lineDiff = endLine - startLine\n const markerLines: MarkerLines = {}\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine\n\n if (!startColumn) {\n markerLines[lineNumber] = true\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1].length\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn]\n } else {\n const sourceLength = source[lineNumber - i].length\n\n markerLines[lineNumber] = [0, sourceLength]\n }\n }\n } else {\n if (startColumn === endColumn) {\n if (startColumn) {\n markerLines[startLine] = [startColumn, 0]\n } else {\n markerLines[startLine] = true\n }\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn]\n }\n }\n\n return {start, end, markerLines}\n}\n\nfunction columnToLine(column: number, lines: string[]): Location {\n let offset = 0\n\n for (let i = 0; i < lines.length; i++) {\n const lineLength = lines[i].length + 1 // assume '\\n' after each line\n\n if (offset + lineLength > column) {\n return {\n line: i + 1, // 1-based line\n column: column - offset, // 0-based column\n }\n }\n\n offset += lineLength\n }\n\n // Fallback: beyond last line\n return {\n line: lines.length,\n column: lines[lines.length - 1]?.length ?? 0,\n }\n}\n","import type {ActionError, Any, ErrorProps, MutationError, QueryParseError} from '../types'\nimport {codeFrame} from '../util/codeFrame'\nimport {isRecord} from '../util/isRecord'\n\nconst MAX_ITEMS_IN_ERROR_MESSAGE = 5\n\n/**\n * Canonical HTTP response shape used internally to build {@link ClientError}\n * and {@link ServerError}. Decouples the error layer from any particular\n * transport library — adapters in the HTTP layer (e.g. `httpResponseFromGetIt`)\n * project transport-specific response shapes into this stable form before\n * constructing errors.\n *\n * Matches the public {@link HttpError.response} shape so consumers see no\n * difference in error properties when the underlying transport changes.\n *\n * @internal\n */\nexport interface CanonicalHttpResponse {\n statusCode: number\n statusMessage: string | null\n headers: Record<string, string>\n body: unknown\n url: string\n method: string\n}\n\n/**\n * Adapter for buffered responses from get-it v9 (`BufferedResponse`-shaped).\n *\n * The URL and method aren't on the response itself in v9, so the request\n * options must be passed alongside.\n *\n * @internal\n */\nexport function httpResponseFromFetch(\n res: {\n status: number\n statusText: string\n headers: Headers\n body: unknown\n url: string\n },\n reqUrl: string,\n reqMethod: string,\n): CanonicalHttpResponse {\n return {\n statusCode: res.status,\n statusMessage: res.statusText || null,\n headers: headersToRecord(res.headers),\n body: res.body,\n url: res.url || reqUrl,\n method: reqMethod,\n }\n}\n\nfunction headersToRecord(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {}\n headers.forEach((value, key) => {\n out[key] = value\n })\n return out\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 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/**\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 function isHttpError(error: unknown): error is HttpError {\n if (!isRecord(error)) {\n return false\n }\n\n const response = error.response\n if (\n typeof error.statusCode !== 'number' ||\n typeof error.message !== 'string' ||\n !isRecord(response)\n ) {\n return false\n }\n\n if (\n typeof response.body === 'undefined' ||\n typeof response.url !== 'string' ||\n typeof response.method !== 'string' ||\n typeof response.headers !== 'object' ||\n typeof response.statusCode !== 'number'\n ) {\n return false\n }\n\n return true\n}\n\n/** @public */\nexport class ClientError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode'] = 400\n responseBody: ErrorProps['responseBody']\n traceId: ErrorProps['traceId']\n details: ErrorProps['details']\n\n constructor(res: Any, tag?: string) {\n const props = extractErrorProps(res, tag)\n super(props.message)\n Object.assign(this, props)\n }\n}\n\n/** @public */\nexport class ServerError extends Error {\n response: ErrorProps['response']\n statusCode: ErrorProps['statusCode'] = 500\n responseBody: ErrorProps['responseBody']\n traceId: ErrorProps['traceId']\n details: ErrorProps['details']\n\n constructor(res: Any) {\n const props = extractErrorProps(res)\n super(props.message)\n Object.assign(this, props)\n }\n}\n\nfunction extractErrorProps(res: Any, tag?: string): ErrorProps {\n const body = res.body\n const props = {\n response: res,\n statusCode: res.statusCode,\n responseBody: stringifyBody(body, res),\n traceId: extractTraceId(res),\n message: '',\n details: undefined as Any,\n }\n\n // Fall back early if we didn't get a JSON object returned as expected\n if (!isRecord(body)) {\n props.message = `${httpErrorMessage(res, body)}${formatTraceId(props.traceId)}`\n return props\n }\n\n const error = body.error\n\n // API/Boom style errors ({statusCode, error, message})\n if (typeof error === 'string' && typeof body.message === 'string') {\n props.message = `${error} - ${body.message}${formatTraceId(props.traceId)}`\n return props\n }\n\n // Content Lake errors with a `error` prop being an object\n if (typeof error !== 'object' || error === null) {\n if (typeof error === 'string') {\n props.message = `${error}${formatTraceId(props.traceId)}`\n } else if (typeof body.message === 'string') {\n props.message = `${body.message}${formatTraceId(props.traceId)}`\n } else {\n props.message = `${httpErrorMessage(res, body)}${formatTraceId(props.traceId)}`\n }\n return props\n }\n\n // Mutation errors (specifically)\n if (isMutationError(error) || isActionError(error)) {\n const allItems = error.items || []\n const items = allItems\n .slice(0, MAX_ITEMS_IN_ERROR_MESSAGE)\n .map((item) => item.error?.description)\n .filter(Boolean)\n let itemsStr = items.length ? `:\\n- ${items.join('\\n- ')}` : ''\n if (allItems.length > MAX_ITEMS_IN_ERROR_MESSAGE) {\n itemsStr += `\\n...and ${allItems.length - MAX_ITEMS_IN_ERROR_MESSAGE} more`\n }\n props.message = `${error.description}${formatTraceId(props.traceId)}${itemsStr}`\n props.details = body.error\n return props\n }\n\n // Query parse errors\n if (isQueryParseError(error)) {\n props.message = formatQueryParseError(error, tag, props.traceId)\n props.details = body.error\n return props\n }\n\n if ('description' in error && typeof error.description === 'string') {\n // Query/database errors ({error: {description, other, arb, props}})\n props.message = `${error.description}${formatTraceId(props.traceId)}`\n props.details = error\n return props\n }\n\n // Other, more arbitrary errors\n props.message = `${httpErrorMessage(res, body)}${formatTraceId(props.traceId)}`\n return props\n}\n\nfunction isMutationError(error: object): error is MutationError {\n return (\n 'type' in error &&\n error.type === 'mutationError' &&\n 'description' in error &&\n typeof error.description === 'string'\n )\n}\n\nfunction isActionError(error: object): error is ActionError {\n return (\n 'type' in error &&\n error.type === 'actionError' &&\n 'description' in error &&\n typeof error.description === 'string'\n )\n}\n\n/** @internal */\nexport function isQueryParseError(error: object): error is QueryParseError {\n return (\n isRecord(error) &&\n error.type === 'queryParseError' &&\n typeof error.query === 'string' &&\n typeof error.start === 'number' &&\n typeof error.end === 'number'\n )\n}\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 function formatQueryParseError(\n error: QueryParseError,\n tag?: string | null,\n traceId?: string,\n) {\n const {query, start, end, description} = error\n const withTraceId = traceId ? `\\n(traceId: ${traceId})` : ''\n\n if (!query || typeof start === 'undefined') {\n return `GROQ query parse error: ${description}${withTraceId}`\n }\n\n const withTag = tag ? `\\n\\nTag: ${tag}` : ''\n const framed = codeFrame(query, {start, end}, description)\n\n return `GROQ query parse error:\\n${framed}${withTag}${withTraceId}`\n}\n\nfunction httpErrorMessage(res: Any, body: unknown) {\n const details = typeof body === 'string' ? ` (${sliceWithEllipsis(body, 100)})` : ''\n const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : ''\n return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}${details}`\n}\n\n/**\n * Extract the traceId from the traceparent header on the response.\n *\n * The traceparent is on the format [version]-[traceId]-[parentId]-[traceFlags], but\n * when debugging end-user issues it's the traceId we need to be able to get hold of\n * the relevant traces.\n *\n * @see https://www.w3.org/TR/trace-context/\n * @returns The traceId for HTTP response\n */\nfunction extractTraceId(res: Any): string | undefined {\n const traceparent = res?.headers?.['traceparent']\n if (!traceparent) return\n\n return traceparent.split('-')[1]\n}\n\nfunction stringifyBody(body: Any, res: Any) {\n const contentType = (res.headers['content-type'] || '').toLowerCase()\n const isJson = contentType.indexOf('application/json') !== -1\n return isJson ? JSON.stringify(body, null, 2) : body\n}\n\nfunction formatTraceId(traceId: string | undefined): string {\n return traceId ? ` (traceId: ${traceId})` : ''\n}\n\nfunction sliceWithEllipsis(str: string, max: number) {\n return str.length > max ? `${str.slice(0, max)}…` : str\n}\n\n/** @public */\nexport class CorsOriginError extends Error {\n projectId?: string\n addOriginUrl?: URL\n\n constructor({projectId, credentials}: {projectId?: string; credentials?: boolean} = {}) {\n super('CorsOriginError')\n this.name = 'CorsOriginError'\n this.projectId = projectId\n\n // Only build a deep-link when we know which project the user needs to\n // configure - without `projectId` the management URL can't actually route\n // them anywhere useful.\n if (projectId && typeof location !== 'undefined') {\n const url = new URL(`https://sanity.io/manage/project/${projectId}/api`)\n const {origin} = location\n url.searchParams.set('cors', 'add')\n url.searchParams.set('origin', origin)\n if (credentials) {\n // Pre-selects the \"Allow credentials (token-based auth)\" toggle in\n // the Sanity management CORS form.\n url.searchParams.set('credentials', '')\n }\n this.addOriginUrl = url\n this.message = `The current origin is not allowed to connect to the Live Content API. Add it here: ${url}`\n } else if (projectId) {\n this.message = `The current origin is not allowed to connect to the Live Content API. Change your configuration here: https://sanity.io/manage/project/${projectId}/api`\n } else {\n this.message = `The current origin is not allowed to connect to the Live Content API.`\n }\n }\n}\n","import {\n createRequester,\n type FetchFunction,\n isHttpError as isGetItHttpError,\n type RequestOptions as FetchRequestOptions,\n type TransformMiddleware,\n type WrappingMiddleware,\n} from 'get-it'\nimport {anySignal} from 'get-it/any-signal'\nimport {isRetryableRequest, retry} from 'get-it/middleware'\nimport {from, Observable} from 'rxjs'\n\nimport type {Any} from '../types'\nimport {ClientError, httpResponseFromFetch, ServerError} from './errors'\n\n/**\n * Middleware accepted by the internal HTTP layer. Two flavors per get-it v9:\n * a flat-pipeline transform (`beforeRequest`/`afterResponse`) or a wrapping\n * middleware that surrounds the fetch chain.\n *\n * @internal\n */\nexport type LegacyMiddleware = TransformMiddleware | WrappingMiddleware\n\n/**\n * The shape this client's internal pipeline produces. Mirrors the historical\n * `ResponseEvent` from the get-it v8 multi-event observable, so all the existing\n * downstream code (`_requestObservable`, `_uploadObservable`,\n * `defineCreateClient`) keeps working without churn.\n *\n * @internal\n */\nexport interface ResponseEvent {\n type: 'response'\n body: unknown\n statusCode: number\n statusMessage: string | null\n headers: Record<string, string>\n url: string\n method: string\n}\n\n/**\n * Legacy \"requester\" type - the observable half of `defineRequester`'s\n * result. Returns a single-event Observable for compatibility with the rest\n * of the codebase.\n *\n * @internal\n */\nexport type LegacyRequester = (options: Any) => Observable<ResponseEvent>\n\n/**\n * Promise-based sibling of {@link LegacyRequester}. Resolves directly to the\n * single `ResponseEvent` the transport produces, skipping the RxJS wrapper.\n * Used by the promise-based client surface so it never constructs an\n * Observable.\n *\n * @internal\n */\nexport type PromiseRequester = (options: Any) => Promise<ResponseEvent>\n\n/**\n * Both forms of the transport, sharing a single underlying get-it requester\n * (so retry state and the one-shot warning de-duplication are shared between\n * the observable and promise paths).\n *\n * @internal\n */\nexport interface DualRequester {\n observable: LegacyRequester\n promise: PromiseRequester\n}\n\n/**\n * Options for tuning the HTTP request pipeline per-client.\n *\n * @internal\n */\nexport interface HttpRequestConfig {\n ignoreWarnings?: string | RegExp | Array<string | RegExp>\n maxRetries?: number\n retryDelay?: (attemptNumber: number) => number\n}\n\n/**\n * Build both the observable and promise transport forms from a single get-it\n * requester. The promise form is the primitive (`executeRequest` is already\n * promise-based); the observable form wraps it lazily so each subscription\n * starts its own request (cold), and unsubscribing aborts the in-flight\n * fetch — the same contract as the get-it v8 observable adapter.\n *\n * @internal\n */\nexport function defineRequester(\n envOptions: EnvironmentOptions,\n config: HttpRequestConfig = {},\n): DualRequester {\n // Framework-patched fetch implementations read extra `RequestInit` fields\n // for caching semantics — Next.js App Router's `cache` and `next` options in\n // particular. Legacy callers pass those via an object-valued `fetch` request\n // option (see `adaptToFetchOptions`, which stashes it in `meta.fetchInit`\n // since get-it v9's own `fetch` option only accepts a function). Merge them\n // into the init of whichever fetch implementation is effective for the\n // request: per-request/test-override fetch, the environment default, or the\n // global fetch.\n const applyFetchInit: WrappingMiddleware = (opts, next) => {\n const fetchInit = opts.meta?.fetchInit\n if (typeof fetchInit !== 'object' || fetchInit === null) return next(opts)\n const baseFetch: NonNullable<FetchRequestOptions['fetch']> =\n opts.fetch ?? envOptions.fetch ?? globalThis.fetch\n const fetchWithInit: typeof baseFetch = (input, init) =>\n baseFetch(input, {...fetchInit, ...init})\n return next({...opts, fetch: fetchWithInit})\n }\n\n const requester = createRequester({\n ...(envOptions.fetch ? {fetch: envOptions.fetch} : {}),\n headers: envOptions.headers,\n // Keep get-it's built-in 4xx/5xx → HttpError so the retry middleware can\n // see them; we translate to ClientError/ServerError after the retry loop\n // has exhausted in `executeRequest`.\n httpErrors: true,\n middleware: [\n retry({\n shouldRetry: shouldRetryRequest,\n maxRetries: config.maxRetries ?? 5,\n ...(config.retryDelay ? {retryDelay: config.retryDelay} : {}),\n }),\n ...envOptions.middleware,\n applyFetchInit,\n printWarnings(config),\n ],\n })\n\n const promise: PromiseRequester = (options: Any) => {\n // Options arrive fetch-shaped from `requestOptions` — the single\n // translation boundary between public option names and the transport.\n if (typeof options.url !== 'string') {\n throw new TypeError('Request options must include a `url`')\n }\n return executeRequest(requester, options)\n }\n\n const observable: LegacyRequester = (options: Any) =>\n new Observable<ResponseEvent>((subscriber) => {\n const controller = new AbortController()\n const userSignal: AbortSignal | undefined = options.signal\n const signal = userSignal ? anySignal([userSignal, controller.signal]) : controller.signal\n const subscription = from(promise({...options, signal})).subscribe(subscriber)\n return () => {\n subscription.unsubscribe()\n controller.abort()\n }\n })\n\n return {promise, observable}\n}\n\n/**\n * Options describing the environment-specific defaults (Node vs. browser).\n *\n * @internal\n */\nexport interface EnvironmentOptions {\n fetch?: FetchRequestOptions['fetch']\n headers?: Record<string, string>\n middleware: LegacyMiddleware[]\n /**\n * Resolves the environment's fetch implementation — the same transport\n * regular requests use (custom fetch variants, undici configuration,\n * env-proxy support and all), optionally configured for an explicit proxy\n * URL. Lets consumers of the resolved config (the EventSource fetch\n * resolver) avoid falling back to whatever `globalThis.fetch` happens to\n * be. The Node environment supplies get-it's undici-backed fetch; the\n * browser environment leaves it unset (the global fetch IS the\n * environment's fetch there).\n *\n * Looked up via the env rather than imported directly so that the Node-only\n * `get-it/node` (which transitively pulls in `undici`) never ends up in the\n * browser bundle, even via rollup's inlined dynamic imports.\n */\n resolveFetch?: (proxyUrl?: string) => FetchFunction\n}\n\nasync function executeRequest(\n requester: ReturnType<typeof createRequester>,\n fetchOptions: FetchRequestOptions,\n): Promise<ResponseEvent> {\n const url = fetchOptions.url\n const method = (fetchOptions.method ?? 'GET').toUpperCase()\n\n let response\n try {\n response = await requester(fetchOptions)\n } catch (err) {\n if (isGetItHttpError(err)) {\n // `err.body` is the response body as a string (get-it v9 stores the\n // already-decoded text), regardless of which response variant\n // `err.response` is.\n const errBodyText = typeof err.body === 'string' ? err.body : ''\n const errBody = parseJsonText(errBodyText, err.headers)\n const canonical = httpResponseFromFetch(\n {\n status: err.status,\n statusText: err.statusText,\n headers: err.headers,\n body: errBody,\n url: err.response.url ?? err.url,\n },\n url,\n method,\n )\n const tag = extractRequestTag(fetchOptions.query)\n if (canonical.statusCode >= 500) {\n throw new ServerError(canonical)\n }\n throw new ClientError(canonical, tag)\n }\n throw err\n }\n\n const body = parseJsonBody(response)\n return {\n type: 'response',\n body,\n statusCode: response.status,\n statusMessage: response.statusText || null,\n headers: headersToRecord(response.headers),\n url: response.url || url,\n method,\n }\n}\n\n/**\n * Extract the GROQ request tag (used for error messages) from the query.\n */\nfunction extractRequestTag(query: FetchRequestOptions['query']): string | undefined {\n if (!query) return undefined\n if (query instanceof URLSearchParams) return query.get('tag') ?? undefined\n const tag = query.tag\n return typeof tag === 'string' ? tag : undefined\n}\n\nfunction parseJsonBody(response: {headers: Headers; text(): string}): unknown {\n return parseJsonText(response.text(), response.headers)\n}\n\n/**\n * Parse a response body according to its `content-type`: JSON when the header\n * says so (falling back to the raw text on malformed JSON), text otherwise.\n * Shared with the browser XHR upload path so error bodies parse identically\n * on both transports.\n *\n * @internal\n */\nexport function parseJsonText(text: string, headers: Headers): unknown {\n const contentType = (headers.get('content-type') ?? '').toLowerCase()\n if (!text) return undefined\n if (contentType.includes('application/json')) {\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n return text\n}\n\nfunction headersToRecord(headers: Headers): Record<string, string> {\n const out: Record<string, string> = {}\n headers.forEach((value, key) => {\n out[key] = value\n })\n return out\n}\n\nfunction shouldRetryRequest(err: unknown, attempt: number, options: FetchRequestOptions): boolean {\n // HTTP errors aren't usually retryable, but Content Lake gives us a few\n // status codes where retrying *is* the right move.\n if (isGetItHttpError(err)) {\n const isSafe = (options.method ?? 'GET') === 'GET' || options.method === 'HEAD'\n const isQuery = (options.url ?? '').includes('/data/query')\n const status = err.status\n const retryableStatus = status === 429 || status === 502 || status === 503\n if ((isSafe || isQuery) && retryableStatus) return true\n return false\n }\n\n return isRetryableRequest(err, attempt, options)\n}\n\nfunction printWarnings(config: HttpRequestConfig): TransformMiddleware {\n const seen: Record<string, boolean> = {}\n\n const shouldIgnore = (message: string): boolean => {\n if (config.ignoreWarnings === undefined) return false\n const patterns = Array.isArray(config.ignoreWarnings)\n ? config.ignoreWarnings\n : [config.ignoreWarnings]\n return patterns.some((pattern) =>\n typeof pattern === 'string' ? message.includes(pattern) : pattern.test(message),\n )\n }\n\n return {\n afterResponse(response) {\n const header = response.headers.get('x-sanity-warning')\n if (!header) return response\n // Multiple warnings can be comma-separated per HTTP header semantics.\n for (const msg of header.split(',').map((m) => m.trim())) {\n if (!msg || seen[msg] || shouldIgnore(msg)) continue\n seen[msg] = true\n // oxlint-disable-next-line no-console\n console.warn(msg)\n }\n return response\n },\n }\n}\n"],"mappings":";;;;;;;;AAwBA,MAAM,UAAU;;;;;;;;;;;AAkBhB,SAAgB,UAAU,OAAe,UAAwB,SAA0B;CACzF,IAA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get?: never;
2118
2118
  /**
2119
2119
  * Record a conversation
2120
- * @description Upserts the conversation telemetry for one thread. `threadId` identifies the conversation within your organization — reuse means the same conversation. Messages replace the stored transcript wholesale; `metadata` and model fields only overwrite when present. Last write per thread wins — retries are safe.
2120
+ * @description Upserts the conversation telemetry for one thread. `threadId` identifies the conversation within your organization — reuse means the same conversation. Messages replace the stored transcript wholesale; `metadata`, `sharing`, and model fields only overwrite when present. Last write per thread wins — retries are safe. `sharing` records your opt-in to share telemetry with Sanity: metadata-only metrics, or full transcripts.
2121
2121
  */
2122
2122
  put: operations['saveConversation'];
2123
2123
  post?: never;
@@ -2187,6 +2187,15 @@ interface components {
2187
2187
  /** Format: date-time */
2188
2188
  classifiedAt: string | null;
2189
2189
  classificationError: string | null;
2190
+ /**
2191
+ * @description ConversationSharing
2192
+ * @default null
2193
+ */
2194
+ sharing: {
2195
+ metrics?: boolean;
2196
+ conversations?: boolean;
2197
+ contact?: string;
2198
+ } | null;
2190
2199
  };
2191
2200
  /** @description A `sanity.context.entry` document, one outline node stored in the bound dataset. Not returned by any endpoint; published so GROQ reads against the dataset can be typed. The entries endpoints serve the validated wire view. */
2192
2201
  EntryDoc: {
@@ -2542,6 +2551,11 @@ interface operations {
2542
2551
  refreshInFlight: boolean;
2543
2552
  openIssueCount: number;
2544
2553
  instructionCount: number;
2554
+ /** @description Actor */
2555
+ createdBy: {
2556
+ id: string | null;
2557
+ displayName: string | null;
2558
+ } | null;
2545
2559
  /** Format: date-time */
2546
2560
  createdAt: string;
2547
2561
  /** Format: date-time */
@@ -2634,6 +2648,11 @@ interface operations {
2634
2648
  refreshInFlight: boolean;
2635
2649
  openIssueCount: number;
2636
2650
  instructionCount: number;
2651
+ /** @description Actor */
2652
+ createdBy: {
2653
+ id: string | null;
2654
+ displayName: string | null;
2655
+ } | null;
2637
2656
  /** Format: date-time */
2638
2657
  createdAt: string;
2639
2658
  /** Format: date-time */
@@ -2716,6 +2735,11 @@ interface operations {
2716
2735
  refreshInFlight: boolean;
2717
2736
  openIssueCount: number;
2718
2737
  instructionCount: number;
2738
+ /** @description Actor */
2739
+ createdBy: {
2740
+ id: string | null;
2741
+ displayName: string | null;
2742
+ } | null;
2719
2743
  /** Format: date-time */
2720
2744
  createdAt: string;
2721
2745
  /** Format: date-time */
@@ -2830,6 +2854,11 @@ interface operations {
2830
2854
  refreshInFlight: boolean;
2831
2855
  openIssueCount: number;
2832
2856
  instructionCount: number;
2857
+ /** @description Actor */
2858
+ createdBy: {
2859
+ id: string | null;
2860
+ displayName: string | null;
2861
+ } | null;
2833
2862
  /** Format: date-time */
2834
2863
  createdAt: string;
2835
2864
  /** Format: date-time */
@@ -3843,6 +3872,12 @@ interface operations {
3843
3872
  metadata?: {
3844
3873
  [key: string]: string | string[];
3845
3874
  };
3875
+ /** @description ConversationSharing */
3876
+ sharing?: {
3877
+ metrics?: boolean;
3878
+ conversations?: boolean;
3879
+ contact?: string;
3880
+ };
3846
3881
  };
3847
3882
  };
3848
3883
  };
@@ -3895,6 +3930,12 @@ interface operations {
3895
3930
  /** Format: date-time */
3896
3931
  classifiedAt: string | null;
3897
3932
  classificationError: string | null;
3933
+ /** @description ConversationSharing */
3934
+ sharing: {
3935
+ metrics?: boolean;
3936
+ conversations?: boolean;
3937
+ contact?: string;
3938
+ } | null;
3898
3939
  /** Format: date-time */
3899
3940
  createdAt: string;
3900
3941
  /** Format: date-time */
@@ -3976,6 +4017,12 @@ interface operations {
3976
4017
  /** Format: date-time */
3977
4018
  classifiedAt: string | null;
3978
4019
  classificationError: string | null;
4020
+ /** @description ConversationSharing */
4021
+ sharing: {
4022
+ metrics?: boolean;
4023
+ conversations?: boolean;
4024
+ contact?: string;
4025
+ } | null;
3979
4026
  /** Format: date-time */
3980
4027
  createdAt: string;
3981
4028
  /** Format: date-time */
@@ -9969,4 +10016,4 @@ interface MediaLibraryAssetDocument {
9969
10016
  rootDirectory?: Any$1;
9970
10017
  }
9971
10018
  export { DisconnectEvent as $, UploadClientConfig as $n, CollaborationCommentFieldValue as $r, QueryWithoutParams as $t, ContentSourceMapMappings as A, AgentActionPathSegment as Ai, SanityReference as An, ObservableProjectsClient as Ar, MediaLibraryAssetVersion as At, CreateVersionAction as B, TransactionAllDocumentIdsMutationOptions as Bn, ObservablePatchBuilder as Br, MutationSelection as Bt, ContentSourceMap$1 as C, PromptRequest as Ci, SanityDocument$1 as Cn, GenerateTarget as Cr, LiveEventGoAway as Ct, ContentSourceMapDocuments$1 as D, AgentActionParam as Di, SanityProject as Dn, SanityClient$1 as Dr, LiveEventWelcome as Dt, ContentSourceMapDocumentValueSource as E, PatchTarget as Ei, SanityImagePalette as En, ObservableSanityClient$1 as Er, LiveEventRestart as Et, ContentSourceMapValueMapping as F, GroqAgentActionParam as Fi, StackablePerspective as Fn, InvokeFunctionOptions as Fr, Mutation as Ft, DatasetResponse as G, UnarchiveReleaseAction as Gn, ObservablePatch as Gr, PatchOperations as Gt, DatasetAclMode as H, TransactionFirstDocumentIdMutationOptions as Hn, PatchBuilder as Hr, OpenEvent as Ht, CreateAction as I, StillImageFormat as In, InvokeFunctionRequest as Ir, MutationError as It, DeleteReleaseAction as J, UnpublishAction as Jn, types_d_exports as Jr, PublishReleaseAction as Jt, DatasetsResponse as K, UnfilteredResponseQueryOptions as Kn, Patch as Kr, PatchSelection as Kt, CreateReleaseAction as L, StoryboardTransformOptions as Ln, DatasetsClient as Lr, MutationErrorItem as Lt, ContentSourceMapRemoteDocument as M, ConstantAgentActionParam as Mi, ScheduleReleaseAction as Mn, MediaLibraryVideoClient as Mr, MediaLibraryVideoPlaybackTransformations as Mt, ContentSourceMapSource as N, DocumentAgentActionParam as Ni, SingleActionResult as Nn, ObservableMediaLibraryVideoClient as Nr, MultipleActionResult as Nt, ContentSourceMapLiteralSource as O, AgentActionParams as Oi, SanityProjectMember as On, ObservableUsersClient as Or, MediaLibraryAssetDocument as Ot, ContentSourceMapUnknownSource as P, FieldAgentActionParam as Pi, SingleMutationResult as Pn, InvokeFunctionEvent as Pr, MultipleMutationResult as Pt, DiscardVersionAction as Q, UploadBody as Qn, CollaborationCommentDocument as Qr, QueryParseError as Qt, CreateVariantAction as R, SyncTag as Rn, ObservableDatasetsClient as Rr, MutationEvent as Rt, ClientVariantConditions as S, TransformTargetInclude as Si, SanityAssetDocument as Sn, GenerateOperation as Sr, LiveEvent as St, ContentSourceMapDocumentBase as T, PatchOperation as Ti, SanityImageAssetDocument as Tn, GenerateTargetInclude as Tr, LiveEventReconnect as Tt, DatasetCreateOptions as U, TransactionFirstDocumentMutationOptions as Un, Transaction as Ur, PartialExcept as Ut, CurrentSanityUser as V, TransactionAllDocumentsMutationOptions as Vn, ObservableTransaction as Vr, MutationSelectionQueryParams as Vt, DatasetEditOptions as W, TransactionMutationOptions as Wn, BasePatch as Wr, PatchMutationOperation as Wt, DeleteVariantDefinitionAction as X, UnpublishVersionAction as Xn, ObservableCollaborationCommentsClient as Xr, QueryOptions as Xt, DeleteVariantAction as Y, UnpublishVariantAction as Yn, CollaborationCommentsClient as Yr, PublishVariantAction as Yt, DiscardAction as Z, UnscheduleReleaseAction as Zn, CollaborationCommentCreate as Zr, QueryParams as Zt, ChannelErrorEvent as _, ImageDescriptionOperation as _i, Requester as _n, VideoSubtitleInfoPublic as _r, InsertPatch as _t, AllDocumentsMutationOptions as a, CollaborationCommentStatus as ai, ReleaseCardinality as an, VersionAction as ar, EditableReleaseDocument as at, ClientReturn$1 as b, TransformTarget as bi, ResumableListenEventNames as bn, WelcomeEvent as br, ListenOptions as bt, Any$1 as c, CollaborationCommentsListenOptions as ci, ReleaseState as cn, VideoPlaybackInfoItemPublic as cr, ErrorProps as ct, AssetMetadataType as d, _listen as di, ReplaceVersionAction as dn, VideoPlaybackInfoSigned as dr, FirstDocumentMutationOptions as dt, CollaborationCommentMessage as ei, RawQueryResponse$1 as en, UploadEvent as er, EXPERIMENTAL_API_WARNING as et, AttributeSet as f, AssetsClient as fi, RequestHandler as fn, VideoPlaybackTokens as fr, FitMode as ft, BaseMutationOptions as g, TranslateTargetInclude as gi, RequestUrlOptions as gn, VideoSubtitleInfo as gr, InitializedClientConfig$1 as gt, BaseActionOptions as h, TranslateTarget as hi, RequestOptions$1 as hn, VideoRenditionInfoSigned as hr, ImportReleaseAction as ht, AllDocumentIdsMutationOptions as i, CollaborationCommentSelection as ii, ReleaseAction as in, VariantDefinitionAction as ir, EditVariantDefinitionAction as it, ContentSourceMapPaths as j, AgentActionTarget as ji, SanityUser as jn, ProjectsClient as jr, MediaLibraryPlaybackInfoOptions as jt, ContentSourceMapMapping as k, AgentActionPath as ki, SanityQueries as kn, UsersClient as kr, MediaLibraryAssetInstanceIdentifier as kt, ApiError as l, CollaborationCommentsRequestOptions as li, ReleaseType as ln, VideoPlaybackInfoItemSigned as lr, FilteredResponseQueryOptions as lt, AuthProviderResponse as m, TranslateDocument as mi, RequestObservableOptions as mn, VideoRenditionInfoPublic as mr, IdentifiedSanityDocumentStub as mt, ActionError as n, CollaborationCommentRange as ni, RawRequestOptions as nn, UploadResponseEvent as nr, EditReleaseAction as nt, AnimatedImageFormat as o, CollaborationCommentTarget as oi, ReleaseDocument as on, VideoPlaybackInfo as or, EmbeddingsSettings as ot, AuthProvider as p, ObservableAssetsClient as pi, RequestHandlerOptions as pn, VideoRenditionInfo as pr, HttpRequest as pt, DeleteAction as q, UnfilteredResponseWithoutQuery as qn, LiveClient as qr, PublishAction as qt, ActionErrorItem as r, CollaborationCommentReactionShortName as ri, ReconnectEvent as rn, VariantAction as rr, EditVariantAction as rt, AnimatedTransformOptions as s, CollaborationCommentUpdate as si, ReleaseId as sn, VideoPlaybackInfoItem as sr, EmbeddingsSettingsBody as st, Action as t, CollaborationCommentPortableTextBlock as ti, RawQuerylessQueryResponse as tn, UploadProgressEvent as tr, EditAction as tt, ArchiveReleaseAction as u, CollaborationCommentsWriteOptions as ui, ReplaceDraftAction as un, VideoPlaybackInfoPublic as ur, FirstDocumentIdMutationOptions as ut, ClientConfig$1 as v, TransformDocument as vi, ResetEvent as vn, VideoSubtitleInfoSigned as vr, ListenEvent as vt, ContentSourceMapDocument as w, PatchDocument as wi, SanityDocumentStub as wn, GenerateTargetDocument as wr, LiveEventMessage as wt, ClientVariant as x, TransformTargetDocument as xi, ResumableListenOptions as xn, GenerateInstruction as xr, ListenParams as xt, ClientPerspective$1 as y, TransformOperation as yi, ResponseQueryOptions as yn, WelcomeBackEvent as yr, ListenEventName as yt, CreateVariantDefinitionAction as z, ThumbnailTransformOptions as zn, BaseTransaction as zr, MutationOperation as zt };
9972
- //# sourceMappingURL=types-CtHEe8SF.d.ts.map
10019
+ //# sourceMappingURL=types-B1XLvey7.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "8.5.0",
3
+ "version": "8.6.1",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "api",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "eventsource": "^5.1.1",
53
- "get-it": "^9.5.2",
53
+ "get-it": "^9.5.4",
54
54
  "obug": "^2.1.4",
55
55
  "rxjs": "^7.8.2"
56
56
  },