@sanity/client 7.5.0 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
692
692
  */
693
693
  headers?: Record<string, string>
694
694
  ignoreBrowserTokenWarning?: boolean
695
+ /**
696
+ * Ignore specific warning messages from the client.
697
+ *
698
+ * @remarks
699
+ * - String values perform substring matching (not exact matching) against warning messages
700
+ * - RegExp values are tested against the full warning message
701
+ * - Array values allow multiple patterns to be specified
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * // Ignore warnings containing "experimental"
706
+ * ignoreWarnings: 'experimental'
707
+ *
708
+ * // Ignore multiple warning types
709
+ * ignoreWarnings: ['experimental', 'deprecated']
710
+ *
711
+ * // Use regex for exact matching
712
+ * ignoreWarnings: /^This is an experimental API version$/
713
+ *
714
+ * // Mix strings and regex patterns
715
+ * ignoreWarnings: ['rate limit', /^deprecated/i]
716
+ * ```
717
+ */
718
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
695
719
  withCredentials?: boolean
696
720
  allowReconfigure?: boolean
697
721
  timeout?: number
@@ -1385,6 +1409,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1385
1409
  */
1386
1410
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1387
1411
 
1412
+ /**
1413
+ * A string constant containing the experimental API version warning message.
1414
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1419
+ *
1420
+ * const client = createClient({
1421
+ * projectId: 'your-project-id',
1422
+ * dataset: 'production',
1423
+ * apiVersion: 'vX', // experimental version
1424
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1425
+ * })
1426
+ * ```
1427
+ *
1428
+ * @public
1429
+ */
1430
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1431
+
1388
1432
  /**
1389
1433
  *
1390
1434
  *
@@ -1849,6 +1893,25 @@ export declare interface GroqAgentActionParam {
1849
1893
  params?: Record<string, string>
1850
1894
  }
1851
1895
 
1896
+ /**
1897
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1898
+ * Use `isHttpError` for type narrowing and accessing response properties.
1899
+ *
1900
+ * @public
1901
+ */
1902
+ export declare interface HttpError {
1903
+ statusCode: number
1904
+ message: string
1905
+ response: {
1906
+ body: unknown
1907
+ url: string
1908
+ method: string
1909
+ headers: Record<string, string>
1910
+ statusCode: number
1911
+ statusMessage: string | null
1912
+ }
1913
+ }
1914
+
1852
1915
  /** @public */
1853
1916
  export declare type HttpRequest = {
1854
1917
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1871,7 +1934,7 @@ export declare type IdentifiedSanityDocumentStub<
1871
1934
  * @see #TransformOperation
1872
1935
  * @beta
1873
1936
  */
1874
- export declare interface ImageDescriptionOperation {
1937
+ export declare type ImageDescriptionOperation = {
1875
1938
  type: 'image-description'
1876
1939
  /**
1877
1940
  * When omitted, parent image value will be inferred from the arget path.
@@ -1882,7 +1945,32 @@ export declare interface ImageDescriptionOperation {
1882
1945
  * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1883
1946
  */
1884
1947
  sourcePath?: AgentActionPath
1885
- }
1948
+ } & (
1949
+ | {
1950
+ /**
1951
+ * When omitted, parent image value will be inferred from the target path.
1952
+ *
1953
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1954
+ * - `['image']`
1955
+ * - `['wrapper', 'mainImage']`
1956
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1957
+ *
1958
+ * Incompatible with `imageUrl`
1959
+ *
1960
+ */
1961
+ sourcePath?: AgentActionPath
1962
+ imageUrl?: never
1963
+ }
1964
+ | {
1965
+ /**
1966
+ * When specified, the image source to be described will be fetched from the URL.
1967
+ *
1968
+ * Incompatible with `sourcePath`
1969
+ */
1970
+ imageUrl?: `https://${string}`
1971
+ sourcePath?: never
1972
+ }
1973
+ )
1886
1974
 
1887
1975
  /** @public */
1888
1976
  export declare interface InitializedClientConfig extends ClientConfig {
@@ -1943,6 +2031,15 @@ export declare type InsertPatch =
1943
2031
  items: Any[]
1944
2032
  }
1945
2033
 
2034
+ /**
2035
+ * Checks if the provided error is an HTTP error.
2036
+ *
2037
+ * @param error - The error to check.
2038
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
2039
+ * @public
2040
+ */
2041
+ export declare function isHttpError(error: unknown): error is HttpError
2042
+
1946
2043
  /** @internal */
1947
2044
  export declare function isQueryParseError(error: object): error is QueryParseError
1948
2045
 
@@ -5811,6 +5908,11 @@ declare type TransformDocumentSync<T extends Record<string, Any> = Record<string
5811
5908
  * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5812
5909
  * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5813
5910
  *
5911
+ * ### Targeting images outside the document (URL)
5912
+ * If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.
5913
+ *
5914
+ * Example:
5915
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`
5814
5916
  * @beta
5815
5917
  */
5816
5918
  export declare type TransformOperation = 'set' | ImageDescriptionOperation
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
692
692
  */
693
693
  headers?: Record<string, string>
694
694
  ignoreBrowserTokenWarning?: boolean
695
+ /**
696
+ * Ignore specific warning messages from the client.
697
+ *
698
+ * @remarks
699
+ * - String values perform substring matching (not exact matching) against warning messages
700
+ * - RegExp values are tested against the full warning message
701
+ * - Array values allow multiple patterns to be specified
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * // Ignore warnings containing "experimental"
706
+ * ignoreWarnings: 'experimental'
707
+ *
708
+ * // Ignore multiple warning types
709
+ * ignoreWarnings: ['experimental', 'deprecated']
710
+ *
711
+ * // Use regex for exact matching
712
+ * ignoreWarnings: /^This is an experimental API version$/
713
+ *
714
+ * // Mix strings and regex patterns
715
+ * ignoreWarnings: ['rate limit', /^deprecated/i]
716
+ * ```
717
+ */
718
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
695
719
  withCredentials?: boolean
696
720
  allowReconfigure?: boolean
697
721
  timeout?: number
@@ -1385,6 +1409,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1385
1409
  */
1386
1410
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1387
1411
 
1412
+ /**
1413
+ * A string constant containing the experimental API version warning message.
1414
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1419
+ *
1420
+ * const client = createClient({
1421
+ * projectId: 'your-project-id',
1422
+ * dataset: 'production',
1423
+ * apiVersion: 'vX', // experimental version
1424
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1425
+ * })
1426
+ * ```
1427
+ *
1428
+ * @public
1429
+ */
1430
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1431
+
1388
1432
  /**
1389
1433
  *
1390
1434
  *
@@ -1849,6 +1893,25 @@ export declare interface GroqAgentActionParam {
1849
1893
  params?: Record<string, string>
1850
1894
  }
1851
1895
 
1896
+ /**
1897
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1898
+ * Use `isHttpError` for type narrowing and accessing response properties.
1899
+ *
1900
+ * @public
1901
+ */
1902
+ export declare interface HttpError {
1903
+ statusCode: number
1904
+ message: string
1905
+ response: {
1906
+ body: unknown
1907
+ url: string
1908
+ method: string
1909
+ headers: Record<string, string>
1910
+ statusCode: number
1911
+ statusMessage: string | null
1912
+ }
1913
+ }
1914
+
1852
1915
  /** @public */
1853
1916
  export declare type HttpRequest = {
1854
1917
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1871,7 +1934,7 @@ export declare type IdentifiedSanityDocumentStub<
1871
1934
  * @see #TransformOperation
1872
1935
  * @beta
1873
1936
  */
1874
- export declare interface ImageDescriptionOperation {
1937
+ export declare type ImageDescriptionOperation = {
1875
1938
  type: 'image-description'
1876
1939
  /**
1877
1940
  * When omitted, parent image value will be inferred from the arget path.
@@ -1882,7 +1945,32 @@ export declare interface ImageDescriptionOperation {
1882
1945
  * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1883
1946
  */
1884
1947
  sourcePath?: AgentActionPath
1885
- }
1948
+ } & (
1949
+ | {
1950
+ /**
1951
+ * When omitted, parent image value will be inferred from the target path.
1952
+ *
1953
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1954
+ * - `['image']`
1955
+ * - `['wrapper', 'mainImage']`
1956
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1957
+ *
1958
+ * Incompatible with `imageUrl`
1959
+ *
1960
+ */
1961
+ sourcePath?: AgentActionPath
1962
+ imageUrl?: never
1963
+ }
1964
+ | {
1965
+ /**
1966
+ * When specified, the image source to be described will be fetched from the URL.
1967
+ *
1968
+ * Incompatible with `sourcePath`
1969
+ */
1970
+ imageUrl?: `https://${string}`
1971
+ sourcePath?: never
1972
+ }
1973
+ )
1886
1974
 
1887
1975
  /** @public */
1888
1976
  export declare interface InitializedClientConfig extends ClientConfig {
@@ -1943,6 +2031,15 @@ export declare type InsertPatch =
1943
2031
  items: Any[]
1944
2032
  }
1945
2033
 
2034
+ /**
2035
+ * Checks if the provided error is an HTTP error.
2036
+ *
2037
+ * @param error - The error to check.
2038
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
2039
+ * @public
2040
+ */
2041
+ export declare function isHttpError(error: unknown): error is HttpError
2042
+
1946
2043
  /** @internal */
1947
2044
  export declare function isQueryParseError(error: object): error is QueryParseError
1948
2045
 
@@ -5811,6 +5908,11 @@ declare type TransformDocumentSync<T extends Record<string, Any> = Record<string
5811
5908
  * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5812
5909
  * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5813
5910
  *
5911
+ * ### Targeting images outside the document (URL)
5912
+ * If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.
5913
+ *
5914
+ * Example:
5915
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`
5814
5916
  * @beta
5815
5917
  */
5816
5918
  export declare type TransformOperation = 'set' | ImageDescriptionOperation
package/dist/stega.d.cts CHANGED
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
692
692
  */
693
693
  headers?: Record<string, string>
694
694
  ignoreBrowserTokenWarning?: boolean
695
+ /**
696
+ * Ignore specific warning messages from the client.
697
+ *
698
+ * @remarks
699
+ * - String values perform substring matching (not exact matching) against warning messages
700
+ * - RegExp values are tested against the full warning message
701
+ * - Array values allow multiple patterns to be specified
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * // Ignore warnings containing "experimental"
706
+ * ignoreWarnings: 'experimental'
707
+ *
708
+ * // Ignore multiple warning types
709
+ * ignoreWarnings: ['experimental', 'deprecated']
710
+ *
711
+ * // Use regex for exact matching
712
+ * ignoreWarnings: /^This is an experimental API version$/
713
+ *
714
+ * // Mix strings and regex patterns
715
+ * ignoreWarnings: ['rate limit', /^deprecated/i]
716
+ * ```
717
+ */
718
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
695
719
  withCredentials?: boolean
696
720
  allowReconfigure?: boolean
697
721
  timeout?: number
@@ -1385,6 +1409,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1385
1409
  */
1386
1410
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1387
1411
 
1412
+ /**
1413
+ * A string constant containing the experimental API version warning message.
1414
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1419
+ *
1420
+ * const client = createClient({
1421
+ * projectId: 'your-project-id',
1422
+ * dataset: 'production',
1423
+ * apiVersion: 'vX', // experimental version
1424
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1425
+ * })
1426
+ * ```
1427
+ *
1428
+ * @public
1429
+ */
1430
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1431
+
1388
1432
  /**
1389
1433
  *
1390
1434
  *
@@ -1849,6 +1893,25 @@ export declare interface GroqAgentActionParam {
1849
1893
  params?: Record<string, string>
1850
1894
  }
1851
1895
 
1896
+ /**
1897
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1898
+ * Use `isHttpError` for type narrowing and accessing response properties.
1899
+ *
1900
+ * @public
1901
+ */
1902
+ export declare interface HttpError {
1903
+ statusCode: number
1904
+ message: string
1905
+ response: {
1906
+ body: unknown
1907
+ url: string
1908
+ method: string
1909
+ headers: Record<string, string>
1910
+ statusCode: number
1911
+ statusMessage: string | null
1912
+ }
1913
+ }
1914
+
1852
1915
  /** @public */
1853
1916
  export declare type HttpRequest = {
1854
1917
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1871,7 +1934,7 @@ export declare type IdentifiedSanityDocumentStub<
1871
1934
  * @see #TransformOperation
1872
1935
  * @beta
1873
1936
  */
1874
- export declare interface ImageDescriptionOperation {
1937
+ export declare type ImageDescriptionOperation = {
1875
1938
  type: 'image-description'
1876
1939
  /**
1877
1940
  * When omitted, parent image value will be inferred from the arget path.
@@ -1882,7 +1945,32 @@ export declare interface ImageDescriptionOperation {
1882
1945
  * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1883
1946
  */
1884
1947
  sourcePath?: AgentActionPath
1885
- }
1948
+ } & (
1949
+ | {
1950
+ /**
1951
+ * When omitted, parent image value will be inferred from the target path.
1952
+ *
1953
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1954
+ * - `['image']`
1955
+ * - `['wrapper', 'mainImage']`
1956
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1957
+ *
1958
+ * Incompatible with `imageUrl`
1959
+ *
1960
+ */
1961
+ sourcePath?: AgentActionPath
1962
+ imageUrl?: never
1963
+ }
1964
+ | {
1965
+ /**
1966
+ * When specified, the image source to be described will be fetched from the URL.
1967
+ *
1968
+ * Incompatible with `sourcePath`
1969
+ */
1970
+ imageUrl?: `https://${string}`
1971
+ sourcePath?: never
1972
+ }
1973
+ )
1886
1974
 
1887
1975
  /** @public */
1888
1976
  export declare interface InitializedClientConfig extends ClientConfig {
@@ -1943,6 +2031,15 @@ export declare type InsertPatch =
1943
2031
  items: Any[]
1944
2032
  }
1945
2033
 
2034
+ /**
2035
+ * Checks if the provided error is an HTTP error.
2036
+ *
2037
+ * @param error - The error to check.
2038
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
2039
+ * @public
2040
+ */
2041
+ export declare function isHttpError(error: unknown): error is HttpError
2042
+
1946
2043
  /** @internal */
1947
2044
  export declare function isQueryParseError(error: object): error is QueryParseError
1948
2045
 
@@ -5811,6 +5908,11 @@ declare type TransformDocumentSync<T extends Record<string, Any> = Record<string
5811
5908
  * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5812
5909
  * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5813
5910
  *
5911
+ * ### Targeting images outside the document (URL)
5912
+ * If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.
5913
+ *
5914
+ * Example:
5915
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`
5814
5916
  * @beta
5815
5917
  */
5816
5918
  export declare type TransformOperation = 'set' | ImageDescriptionOperation
package/dist/stega.d.ts CHANGED
@@ -692,6 +692,30 @@ export declare interface ClientConfig {
692
692
  */
693
693
  headers?: Record<string, string>
694
694
  ignoreBrowserTokenWarning?: boolean
695
+ /**
696
+ * Ignore specific warning messages from the client.
697
+ *
698
+ * @remarks
699
+ * - String values perform substring matching (not exact matching) against warning messages
700
+ * - RegExp values are tested against the full warning message
701
+ * - Array values allow multiple patterns to be specified
702
+ *
703
+ * @example
704
+ * ```typescript
705
+ * // Ignore warnings containing "experimental"
706
+ * ignoreWarnings: 'experimental'
707
+ *
708
+ * // Ignore multiple warning types
709
+ * ignoreWarnings: ['experimental', 'deprecated']
710
+ *
711
+ * // Use regex for exact matching
712
+ * ignoreWarnings: /^This is an experimental API version$/
713
+ *
714
+ * // Mix strings and regex patterns
715
+ * ignoreWarnings: ['rate limit', /^deprecated/i]
716
+ * ```
717
+ */
718
+ ignoreWarnings?: string | RegExp | Array<string | RegExp>
695
719
  withCredentials?: boolean
696
720
  allowReconfigure?: boolean
697
721
  timeout?: number
@@ -1385,6 +1409,26 @@ export declare type EventSourceEvent<Name extends string> = ServerSentEvent<Name
1385
1409
  */
1386
1410
  export declare type EventSourceInstance = InstanceType<typeof globalThis.EventSource>
1387
1411
 
1412
+ /**
1413
+ * A string constant containing the experimental API version warning message.
1414
+ * Use this with the `ignoreWarnings` option to suppress warnings when using experimental API versions.
1415
+ *
1416
+ * @example
1417
+ * ```typescript
1418
+ * import { createClient, EXPERIMENTAL_API_WARNING } from '@sanity/client'
1419
+ *
1420
+ * const client = createClient({
1421
+ * projectId: 'your-project-id',
1422
+ * dataset: 'production',
1423
+ * apiVersion: 'vX', // experimental version
1424
+ * ignoreWarnings: EXPERIMENTAL_API_WARNING
1425
+ * })
1426
+ * ```
1427
+ *
1428
+ * @public
1429
+ */
1430
+ export declare const EXPERIMENTAL_API_WARNING = 'This is an experimental API version'
1431
+
1388
1432
  /**
1389
1433
  *
1390
1434
  *
@@ -1849,6 +1893,25 @@ export declare interface GroqAgentActionParam {
1849
1893
  params?: Record<string, string>
1850
1894
  }
1851
1895
 
1896
+ /**
1897
+ * Shared properties for HTTP errors (eg both ClientError and ServerError)
1898
+ * Use `isHttpError` for type narrowing and accessing response properties.
1899
+ *
1900
+ * @public
1901
+ */
1902
+ export declare interface HttpError {
1903
+ statusCode: number
1904
+ message: string
1905
+ response: {
1906
+ body: unknown
1907
+ url: string
1908
+ method: string
1909
+ headers: Record<string, string>
1910
+ statusCode: number
1911
+ statusMessage: string | null
1912
+ }
1913
+ }
1914
+
1852
1915
  /** @public */
1853
1916
  export declare type HttpRequest = {
1854
1917
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
@@ -1871,7 +1934,7 @@ export declare type IdentifiedSanityDocumentStub<
1871
1934
  * @see #TransformOperation
1872
1935
  * @beta
1873
1936
  */
1874
- export declare interface ImageDescriptionOperation {
1937
+ export declare type ImageDescriptionOperation = {
1875
1938
  type: 'image-description'
1876
1939
  /**
1877
1940
  * When omitted, parent image value will be inferred from the arget path.
@@ -1882,7 +1945,32 @@ export declare interface ImageDescriptionOperation {
1882
1945
  * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1883
1946
  */
1884
1947
  sourcePath?: AgentActionPath
1885
- }
1948
+ } & (
1949
+ | {
1950
+ /**
1951
+ * When omitted, parent image value will be inferred from the target path.
1952
+ *
1953
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1954
+ * - `['image']`
1955
+ * - `['wrapper', 'mainImage']`
1956
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1957
+ *
1958
+ * Incompatible with `imageUrl`
1959
+ *
1960
+ */
1961
+ sourcePath?: AgentActionPath
1962
+ imageUrl?: never
1963
+ }
1964
+ | {
1965
+ /**
1966
+ * When specified, the image source to be described will be fetched from the URL.
1967
+ *
1968
+ * Incompatible with `sourcePath`
1969
+ */
1970
+ imageUrl?: `https://${string}`
1971
+ sourcePath?: never
1972
+ }
1973
+ )
1886
1974
 
1887
1975
  /** @public */
1888
1976
  export declare interface InitializedClientConfig extends ClientConfig {
@@ -1943,6 +2031,15 @@ export declare type InsertPatch =
1943
2031
  items: Any[]
1944
2032
  }
1945
2033
 
2034
+ /**
2035
+ * Checks if the provided error is an HTTP error.
2036
+ *
2037
+ * @param error - The error to check.
2038
+ * @returns `true` if the error is an HTTP error, `false` otherwise.
2039
+ * @public
2040
+ */
2041
+ export declare function isHttpError(error: unknown): error is HttpError
2042
+
1946
2043
  /** @internal */
1947
2044
  export declare function isQueryParseError(error: object): error is QueryParseError
1948
2045
 
@@ -5811,6 +5908,11 @@ declare type TransformDocumentSync<T extends Record<string, Any> = Record<string
5811
5908
  * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5812
5909
  * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5813
5910
  *
5911
+ * ### Targeting images outside the document (URL)
5912
+ * If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.
5913
+ *
5914
+ * Example:
5915
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`
5814
5916
  * @beta
5815
5917
  */
5816
5918
  export declare type TransformOperation = 'set' | ImageDescriptionOperation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "7.5.0",
3
+ "version": "7.7.0",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -180,7 +180,7 @@ export type TransformTargetDocument =
180
180
  * @see #TransformOperation
181
181
  * @beta
182
182
  */
183
- export interface ImageDescriptionOperation {
183
+ export type ImageDescriptionOperation = {
184
184
  type: 'image-description'
185
185
  /**
186
186
  * When omitted, parent image value will be inferred from the arget path.
@@ -191,7 +191,32 @@ export interface ImageDescriptionOperation {
191
191
  * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
192
192
  */
193
193
  sourcePath?: AgentActionPath
194
- }
194
+ } & (
195
+ | {
196
+ /**
197
+ * When omitted, parent image value will be inferred from the target path.
198
+ *
199
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
200
+ * - `['image']`
201
+ * - `['wrapper', 'mainImage']`
202
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
203
+ *
204
+ * Incompatible with `imageUrl`
205
+ *
206
+ */
207
+ sourcePath?: AgentActionPath
208
+ imageUrl?: never
209
+ }
210
+ | {
211
+ /**
212
+ * When specified, the image source to be described will be fetched from the URL.
213
+ *
214
+ * Incompatible with `sourcePath`
215
+ */
216
+ imageUrl?: `https://${string}`
217
+ sourcePath?: never
218
+ }
219
+ )
195
220
 
196
221
  /**
197
222
  *
@@ -222,6 +247,11 @@ export interface ImageDescriptionOperation {
222
247
  * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
223
248
  * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
224
249
  *
250
+ * ### Targeting images outside the document (URL)
251
+ * If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.
252
+ *
253
+ * Example:
254
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`
225
255
  * @beta
226
256
  */
227
257
  export type TransformOperation = 'set' | ImageDescriptionOperation
@@ -21,6 +21,8 @@ export {
21
21
  ClientError,
22
22
  CorsOriginError,
23
23
  formatQueryParseError,
24
+ type HttpError,
25
+ isHttpError,
24
26
  isQueryParseError,
25
27
  ServerError,
26
28
  } from './http/errors'
@@ -45,7 +47,9 @@ export default function defineCreateClientExports<
45
47
  const defaultRequester = defineHttpRequest(envMiddleware)
46
48
 
47
49
  const createClient = (config: ClientConfigType) => {
48
- const clientRequester = defineHttpRequest(envMiddleware)
50
+ const clientRequester = defineHttpRequest(envMiddleware, {
51
+ ignoreWarnings: config.ignoreWarnings,
52
+ })
49
53
  return new ClassConstructor(
50
54
  (options, requester) =>
51
55
  (requester || clientRequester)({