@sanity/client 7.4.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +69 -2
- package/dist/index.browser.d.ts +69 -2
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -2
- package/dist/index.d.ts +69 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +69 -2
- package/dist/stega.browser.d.ts +69 -2
- package/dist/stega.d.cts +69 -2
- package/dist/stega.d.ts +69 -2
- package/package.json +2 -2
- package/src/agent/actions/transform.ts +78 -3
- package/src/data/encodeQueryString.ts +1 -1
- package/src/types.ts +2 -0
- package/umd/sanityClient.js +1 -1
- package/umd/sanityClient.min.js +1 -1
package/dist/stega.browser.d.cts
CHANGED
|
@@ -1866,6 +1866,24 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1866
1866
|
_id: string
|
|
1867
1867
|
} & SanityDocumentStub
|
|
1868
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
*
|
|
1871
|
+
* @see #TransformOperation
|
|
1872
|
+
* @beta
|
|
1873
|
+
*/
|
|
1874
|
+
export declare interface ImageDescriptionOperation {
|
|
1875
|
+
type: 'image-description'
|
|
1876
|
+
/**
|
|
1877
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
1878
|
+
*
|
|
1879
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1880
|
+
* - `['image']`
|
|
1881
|
+
* - `['wrapper', 'mainImage']`
|
|
1882
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1883
|
+
*/
|
|
1884
|
+
sourcePath?: AgentActionPath
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1869
1887
|
/** @public */
|
|
1870
1888
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1871
1889
|
apiHost: string
|
|
@@ -5764,6 +5782,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5764
5782
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5765
5783
|
TransformRequestBase & AgentActionSync
|
|
5766
5784
|
|
|
5785
|
+
/**
|
|
5786
|
+
*
|
|
5787
|
+
* ## `set` by default
|
|
5788
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5789
|
+
*
|
|
5790
|
+
* ## Image description
|
|
5791
|
+
*
|
|
5792
|
+
* ### Targeting image fields
|
|
5793
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5794
|
+
* with `operation: {type: 'image-description'}`.
|
|
5795
|
+
*
|
|
5796
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5797
|
+
*
|
|
5798
|
+
* Such targets must be a descendant field of an image object.
|
|
5799
|
+
*
|
|
5800
|
+
* For example:
|
|
5801
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5802
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5803
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5804
|
+
*
|
|
5805
|
+
* ### Targeting non-image fields
|
|
5806
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5807
|
+
* `sourcePath` must be an image or image asset field.
|
|
5808
|
+
*
|
|
5809
|
+
* For example:
|
|
5810
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5811
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5812
|
+
* - `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
|
+
*
|
|
5814
|
+
* @beta
|
|
5815
|
+
*/
|
|
5816
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5817
|
+
|
|
5767
5818
|
/** @beta */
|
|
5768
5819
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5769
5820
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5905,7 +5956,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5905
5956
|
target?: TransformTarget | TransformTarget[]
|
|
5906
5957
|
}
|
|
5907
5958
|
|
|
5908
|
-
/**
|
|
5959
|
+
/**
|
|
5960
|
+
* @see #TransformOperation
|
|
5961
|
+
* @beta
|
|
5962
|
+
* */
|
|
5909
5963
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5910
5964
|
/**
|
|
5911
5965
|
* Specifies a tailored instruction of this target.
|
|
@@ -5921,6 +5975,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5921
5975
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5922
5976
|
*/
|
|
5923
5977
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5978
|
+
/**
|
|
5979
|
+
* Default: `set`
|
|
5980
|
+
* @see #TransformOperation
|
|
5981
|
+
*/
|
|
5982
|
+
operation?: TransformOperation
|
|
5924
5983
|
}
|
|
5925
5984
|
|
|
5926
5985
|
/**
|
|
@@ -5946,7 +6005,10 @@ export declare type TransformTargetDocument =
|
|
|
5946
6005
|
_id: string
|
|
5947
6006
|
}
|
|
5948
6007
|
|
|
5949
|
-
/**
|
|
6008
|
+
/**
|
|
6009
|
+
* @see #TransformOperation
|
|
6010
|
+
* @beta
|
|
6011
|
+
* */
|
|
5950
6012
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5951
6013
|
/**
|
|
5952
6014
|
* Specifies a tailored instruction of this target.
|
|
@@ -5961,6 +6023,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5961
6023
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5962
6024
|
*/
|
|
5963
6025
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
6026
|
+
/**
|
|
6027
|
+
* Default: `set`
|
|
6028
|
+
* @see #TransformOperation
|
|
6029
|
+
*/
|
|
6030
|
+
operation?: TransformOperation
|
|
5964
6031
|
}
|
|
5965
6032
|
|
|
5966
6033
|
/** @beta */
|
package/dist/stega.browser.d.ts
CHANGED
|
@@ -1866,6 +1866,24 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1866
1866
|
_id: string
|
|
1867
1867
|
} & SanityDocumentStub
|
|
1868
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
*
|
|
1871
|
+
* @see #TransformOperation
|
|
1872
|
+
* @beta
|
|
1873
|
+
*/
|
|
1874
|
+
export declare interface ImageDescriptionOperation {
|
|
1875
|
+
type: 'image-description'
|
|
1876
|
+
/**
|
|
1877
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
1878
|
+
*
|
|
1879
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1880
|
+
* - `['image']`
|
|
1881
|
+
* - `['wrapper', 'mainImage']`
|
|
1882
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1883
|
+
*/
|
|
1884
|
+
sourcePath?: AgentActionPath
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1869
1887
|
/** @public */
|
|
1870
1888
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1871
1889
|
apiHost: string
|
|
@@ -5764,6 +5782,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5764
5782
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5765
5783
|
TransformRequestBase & AgentActionSync
|
|
5766
5784
|
|
|
5785
|
+
/**
|
|
5786
|
+
*
|
|
5787
|
+
* ## `set` by default
|
|
5788
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5789
|
+
*
|
|
5790
|
+
* ## Image description
|
|
5791
|
+
*
|
|
5792
|
+
* ### Targeting image fields
|
|
5793
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5794
|
+
* with `operation: {type: 'image-description'}`.
|
|
5795
|
+
*
|
|
5796
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5797
|
+
*
|
|
5798
|
+
* Such targets must be a descendant field of an image object.
|
|
5799
|
+
*
|
|
5800
|
+
* For example:
|
|
5801
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5802
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5803
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5804
|
+
*
|
|
5805
|
+
* ### Targeting non-image fields
|
|
5806
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5807
|
+
* `sourcePath` must be an image or image asset field.
|
|
5808
|
+
*
|
|
5809
|
+
* For example:
|
|
5810
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5811
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5812
|
+
* - `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
|
+
*
|
|
5814
|
+
* @beta
|
|
5815
|
+
*/
|
|
5816
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5817
|
+
|
|
5767
5818
|
/** @beta */
|
|
5768
5819
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5769
5820
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5905,7 +5956,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5905
5956
|
target?: TransformTarget | TransformTarget[]
|
|
5906
5957
|
}
|
|
5907
5958
|
|
|
5908
|
-
/**
|
|
5959
|
+
/**
|
|
5960
|
+
* @see #TransformOperation
|
|
5961
|
+
* @beta
|
|
5962
|
+
* */
|
|
5909
5963
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5910
5964
|
/**
|
|
5911
5965
|
* Specifies a tailored instruction of this target.
|
|
@@ -5921,6 +5975,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5921
5975
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5922
5976
|
*/
|
|
5923
5977
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5978
|
+
/**
|
|
5979
|
+
* Default: `set`
|
|
5980
|
+
* @see #TransformOperation
|
|
5981
|
+
*/
|
|
5982
|
+
operation?: TransformOperation
|
|
5924
5983
|
}
|
|
5925
5984
|
|
|
5926
5985
|
/**
|
|
@@ -5946,7 +6005,10 @@ export declare type TransformTargetDocument =
|
|
|
5946
6005
|
_id: string
|
|
5947
6006
|
}
|
|
5948
6007
|
|
|
5949
|
-
/**
|
|
6008
|
+
/**
|
|
6009
|
+
* @see #TransformOperation
|
|
6010
|
+
* @beta
|
|
6011
|
+
* */
|
|
5950
6012
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5951
6013
|
/**
|
|
5952
6014
|
* Specifies a tailored instruction of this target.
|
|
@@ -5961,6 +6023,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5961
6023
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5962
6024
|
*/
|
|
5963
6025
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
6026
|
+
/**
|
|
6027
|
+
* Default: `set`
|
|
6028
|
+
* @see #TransformOperation
|
|
6029
|
+
*/
|
|
6030
|
+
operation?: TransformOperation
|
|
5964
6031
|
}
|
|
5965
6032
|
|
|
5966
6033
|
/** @beta */
|
package/dist/stega.d.cts
CHANGED
|
@@ -1866,6 +1866,24 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1866
1866
|
_id: string
|
|
1867
1867
|
} & SanityDocumentStub
|
|
1868
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
*
|
|
1871
|
+
* @see #TransformOperation
|
|
1872
|
+
* @beta
|
|
1873
|
+
*/
|
|
1874
|
+
export declare interface ImageDescriptionOperation {
|
|
1875
|
+
type: 'image-description'
|
|
1876
|
+
/**
|
|
1877
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
1878
|
+
*
|
|
1879
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1880
|
+
* - `['image']`
|
|
1881
|
+
* - `['wrapper', 'mainImage']`
|
|
1882
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1883
|
+
*/
|
|
1884
|
+
sourcePath?: AgentActionPath
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1869
1887
|
/** @public */
|
|
1870
1888
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1871
1889
|
apiHost: string
|
|
@@ -5764,6 +5782,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5764
5782
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5765
5783
|
TransformRequestBase & AgentActionSync
|
|
5766
5784
|
|
|
5785
|
+
/**
|
|
5786
|
+
*
|
|
5787
|
+
* ## `set` by default
|
|
5788
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5789
|
+
*
|
|
5790
|
+
* ## Image description
|
|
5791
|
+
*
|
|
5792
|
+
* ### Targeting image fields
|
|
5793
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5794
|
+
* with `operation: {type: 'image-description'}`.
|
|
5795
|
+
*
|
|
5796
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5797
|
+
*
|
|
5798
|
+
* Such targets must be a descendant field of an image object.
|
|
5799
|
+
*
|
|
5800
|
+
* For example:
|
|
5801
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5802
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5803
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5804
|
+
*
|
|
5805
|
+
* ### Targeting non-image fields
|
|
5806
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5807
|
+
* `sourcePath` must be an image or image asset field.
|
|
5808
|
+
*
|
|
5809
|
+
* For example:
|
|
5810
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5811
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5812
|
+
* - `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
|
+
*
|
|
5814
|
+
* @beta
|
|
5815
|
+
*/
|
|
5816
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5817
|
+
|
|
5767
5818
|
/** @beta */
|
|
5768
5819
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5769
5820
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5905,7 +5956,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5905
5956
|
target?: TransformTarget | TransformTarget[]
|
|
5906
5957
|
}
|
|
5907
5958
|
|
|
5908
|
-
/**
|
|
5959
|
+
/**
|
|
5960
|
+
* @see #TransformOperation
|
|
5961
|
+
* @beta
|
|
5962
|
+
* */
|
|
5909
5963
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5910
5964
|
/**
|
|
5911
5965
|
* Specifies a tailored instruction of this target.
|
|
@@ -5921,6 +5975,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5921
5975
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5922
5976
|
*/
|
|
5923
5977
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5978
|
+
/**
|
|
5979
|
+
* Default: `set`
|
|
5980
|
+
* @see #TransformOperation
|
|
5981
|
+
*/
|
|
5982
|
+
operation?: TransformOperation
|
|
5924
5983
|
}
|
|
5925
5984
|
|
|
5926
5985
|
/**
|
|
@@ -5946,7 +6005,10 @@ export declare type TransformTargetDocument =
|
|
|
5946
6005
|
_id: string
|
|
5947
6006
|
}
|
|
5948
6007
|
|
|
5949
|
-
/**
|
|
6008
|
+
/**
|
|
6009
|
+
* @see #TransformOperation
|
|
6010
|
+
* @beta
|
|
6011
|
+
* */
|
|
5950
6012
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5951
6013
|
/**
|
|
5952
6014
|
* Specifies a tailored instruction of this target.
|
|
@@ -5961,6 +6023,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5961
6023
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5962
6024
|
*/
|
|
5963
6025
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
6026
|
+
/**
|
|
6027
|
+
* Default: `set`
|
|
6028
|
+
* @see #TransformOperation
|
|
6029
|
+
*/
|
|
6030
|
+
operation?: TransformOperation
|
|
5964
6031
|
}
|
|
5965
6032
|
|
|
5966
6033
|
/** @beta */
|
package/dist/stega.d.ts
CHANGED
|
@@ -1866,6 +1866,24 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1866
1866
|
_id: string
|
|
1867
1867
|
} & SanityDocumentStub
|
|
1868
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
*
|
|
1871
|
+
* @see #TransformOperation
|
|
1872
|
+
* @beta
|
|
1873
|
+
*/
|
|
1874
|
+
export declare interface ImageDescriptionOperation {
|
|
1875
|
+
type: 'image-description'
|
|
1876
|
+
/**
|
|
1877
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
1878
|
+
*
|
|
1879
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1880
|
+
* - `['image']`
|
|
1881
|
+
* - `['wrapper', 'mainImage']`
|
|
1882
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1883
|
+
*/
|
|
1884
|
+
sourcePath?: AgentActionPath
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1869
1887
|
/** @public */
|
|
1870
1888
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1871
1889
|
apiHost: string
|
|
@@ -5764,6 +5782,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5764
5782
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5765
5783
|
TransformRequestBase & AgentActionSync
|
|
5766
5784
|
|
|
5785
|
+
/**
|
|
5786
|
+
*
|
|
5787
|
+
* ## `set` by default
|
|
5788
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5789
|
+
*
|
|
5790
|
+
* ## Image description
|
|
5791
|
+
*
|
|
5792
|
+
* ### Targeting image fields
|
|
5793
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5794
|
+
* with `operation: {type: 'image-description'}`.
|
|
5795
|
+
*
|
|
5796
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5797
|
+
*
|
|
5798
|
+
* Such targets must be a descendant field of an image object.
|
|
5799
|
+
*
|
|
5800
|
+
* For example:
|
|
5801
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5802
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5803
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5804
|
+
*
|
|
5805
|
+
* ### Targeting non-image fields
|
|
5806
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5807
|
+
* `sourcePath` must be an image or image asset field.
|
|
5808
|
+
*
|
|
5809
|
+
* For example:
|
|
5810
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5811
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5812
|
+
* - `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
|
+
*
|
|
5814
|
+
* @beta
|
|
5815
|
+
*/
|
|
5816
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5817
|
+
|
|
5767
5818
|
/** @beta */
|
|
5768
5819
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5769
5820
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5905,7 +5956,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5905
5956
|
target?: TransformTarget | TransformTarget[]
|
|
5906
5957
|
}
|
|
5907
5958
|
|
|
5908
|
-
/**
|
|
5959
|
+
/**
|
|
5960
|
+
* @see #TransformOperation
|
|
5961
|
+
* @beta
|
|
5962
|
+
* */
|
|
5909
5963
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5910
5964
|
/**
|
|
5911
5965
|
* Specifies a tailored instruction of this target.
|
|
@@ -5921,6 +5975,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5921
5975
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5922
5976
|
*/
|
|
5923
5977
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5978
|
+
/**
|
|
5979
|
+
* Default: `set`
|
|
5980
|
+
* @see #TransformOperation
|
|
5981
|
+
*/
|
|
5982
|
+
operation?: TransformOperation
|
|
5924
5983
|
}
|
|
5925
5984
|
|
|
5926
5985
|
/**
|
|
@@ -5946,7 +6005,10 @@ export declare type TransformTargetDocument =
|
|
|
5946
6005
|
_id: string
|
|
5947
6006
|
}
|
|
5948
6007
|
|
|
5949
|
-
/**
|
|
6008
|
+
/**
|
|
6009
|
+
* @see #TransformOperation
|
|
6010
|
+
* @beta
|
|
6011
|
+
* */
|
|
5950
6012
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5951
6013
|
/**
|
|
5952
6014
|
* Specifies a tailored instruction of this target.
|
|
@@ -5961,6 +6023,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5961
6023
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5962
6024
|
*/
|
|
5963
6025
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
6026
|
+
/**
|
|
6027
|
+
* Default: `set`
|
|
6028
|
+
* @see #TransformOperation
|
|
6029
|
+
*/
|
|
6030
|
+
operation?: TransformOperation
|
|
5964
6031
|
}
|
|
5965
6032
|
|
|
5966
6033
|
/** @beta */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.0",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"typescript": "5.8.3",
|
|
165
165
|
"vitest": "3.1.1"
|
|
166
166
|
},
|
|
167
|
-
"packageManager": "npm@11.
|
|
167
|
+
"packageManager": "npm@11.4.1",
|
|
168
168
|
"engines": {
|
|
169
169
|
"node": ">=20"
|
|
170
170
|
}
|
|
@@ -2,7 +2,13 @@ import {type Observable} from 'rxjs'
|
|
|
2
2
|
|
|
3
3
|
import {_request} from '../../data/dataMethods'
|
|
4
4
|
import type {ObservableSanityClient, SanityClient} from '../../SanityClient'
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
AgentActionParams,
|
|
7
|
+
AgentActionPath,
|
|
8
|
+
Any,
|
|
9
|
+
HttpRequest,
|
|
10
|
+
IdentifiedSanityDocumentStub,
|
|
11
|
+
} from '../../types'
|
|
6
12
|
import {hasDataset} from '../../validators'
|
|
7
13
|
import type {
|
|
8
14
|
AgentActionAsync,
|
|
@@ -169,7 +175,61 @@ export type TransformTargetDocument =
|
|
|
169
175
|
| {operation: 'createIfNotExists'; _id: string}
|
|
170
176
|
| {operation: 'createOrReplace'; _id: string}
|
|
171
177
|
|
|
172
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
*
|
|
180
|
+
* @see #TransformOperation
|
|
181
|
+
* @beta
|
|
182
|
+
*/
|
|
183
|
+
export interface ImageDescriptionOperation {
|
|
184
|
+
type: 'image-description'
|
|
185
|
+
/**
|
|
186
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
187
|
+
*
|
|
188
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
189
|
+
* - `['image']`
|
|
190
|
+
* - `['wrapper', 'mainImage']`
|
|
191
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
192
|
+
*/
|
|
193
|
+
sourcePath?: AgentActionPath
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
* ## `set` by default
|
|
199
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
200
|
+
*
|
|
201
|
+
* ## Image description
|
|
202
|
+
*
|
|
203
|
+
* ### Targeting image fields
|
|
204
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
205
|
+
* with `operation: {type: 'image-description'}`.
|
|
206
|
+
*
|
|
207
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
208
|
+
*
|
|
209
|
+
* Such targets must be a descendant field of an image object.
|
|
210
|
+
*
|
|
211
|
+
* For example:
|
|
212
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
213
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
214
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
215
|
+
*
|
|
216
|
+
* ### Targeting non-image fields
|
|
217
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
218
|
+
* `sourcePath` must be an image or image asset field.
|
|
219
|
+
*
|
|
220
|
+
* For example:
|
|
221
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
222
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
223
|
+
* - `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
|
+
*
|
|
225
|
+
* @beta
|
|
226
|
+
*/
|
|
227
|
+
export type TransformOperation = 'set' | ImageDescriptionOperation
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @see #TransformOperation
|
|
231
|
+
* @beta
|
|
232
|
+
* */
|
|
173
233
|
export interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
174
234
|
/**
|
|
175
235
|
* Specifies a tailored instruction of this target.
|
|
@@ -185,9 +245,18 @@ export interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
|
185
245
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
186
246
|
*/
|
|
187
247
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Default: `set`
|
|
251
|
+
* @see #TransformOperation
|
|
252
|
+
*/
|
|
253
|
+
operation?: TransformOperation
|
|
188
254
|
}
|
|
189
255
|
|
|
190
|
-
/**
|
|
256
|
+
/**
|
|
257
|
+
* @see #TransformOperation
|
|
258
|
+
* @beta
|
|
259
|
+
* */
|
|
191
260
|
export interface TransformTarget extends AgentActionTarget {
|
|
192
261
|
/**
|
|
193
262
|
* Specifies a tailored instruction of this target.
|
|
@@ -204,6 +273,12 @@ export interface TransformTarget extends AgentActionTarget {
|
|
|
204
273
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
205
274
|
*/
|
|
206
275
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Default: `set`
|
|
279
|
+
* @see #TransformOperation
|
|
280
|
+
*/
|
|
281
|
+
operation?: TransformOperation
|
|
207
282
|
}
|
|
208
283
|
|
|
209
284
|
/** @beta */
|
|
@@ -18,7 +18,7 @@ export const encodeQueryString = ({
|
|
|
18
18
|
|
|
19
19
|
// Iterate params, the keys are prefixed with `$` and their values JSON stringified
|
|
20
20
|
for (const [key, value] of Object.entries(params)) {
|
|
21
|
-
searchParams.append(`$${key}`, JSON.stringify(value))
|
|
21
|
+
if (value !== undefined) searchParams.append(`$${key}`, JSON.stringify(value))
|
|
22
22
|
}
|
|
23
23
|
// Options are passed as-is
|
|
24
24
|
for (const [key, value] of Object.entries(opts)) {
|
package/src/types.ts
CHANGED
|
@@ -1635,7 +1635,9 @@ export type {
|
|
|
1635
1635
|
export type {PatchDocument, PatchOperation, PatchTarget} from './agent/actions/patch'
|
|
1636
1636
|
export type {PromptRequest} from './agent/actions/prompt'
|
|
1637
1637
|
export type {
|
|
1638
|
+
ImageDescriptionOperation,
|
|
1638
1639
|
TransformDocument,
|
|
1640
|
+
TransformOperation,
|
|
1639
1641
|
TransformTarget,
|
|
1640
1642
|
TransformTargetDocument,
|
|
1641
1643
|
TransformTargetInclude,
|
package/umd/sanityClient.js
CHANGED
|
@@ -2813,7 +2813,7 @@ ${selectionOpts}`);
|
|
|
2813
2813
|
const searchParams = new URLSearchParams(), { tag, includeMutations, returnQuery, ...opts } = options;
|
|
2814
2814
|
tag && searchParams.append("tag", tag), searchParams.append("query", query);
|
|
2815
2815
|
for (const [key, value] of Object.entries(params))
|
|
2816
|
-
searchParams.append(`$${key}`, JSON.stringify(value));
|
|
2816
|
+
value !== void 0 && searchParams.append(`$${key}`, JSON.stringify(value));
|
|
2817
2817
|
for (const [key, value] of Object.entries(opts))
|
|
2818
2818
|
value && searchParams.append(key, `${value}`);
|
|
2819
2819
|
return returnQuery === false && searchParams.append("returnQuery", "false"), includeMutations === false && searchParams.append("includeMutations", "false"), `?${searchParams}`;
|