@sanity/client 7.4.1 → 7.5.0-agent-actions.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.
@@ -1866,6 +1866,47 @@ export declare type IdentifiedSanityDocumentStub<
1866
1866
  _id: string
1867
1867
  } & SanityDocumentStub
1868
1868
 
1869
+ /**
1870
+ *
1871
+ * @see #TransformOperation
1872
+ * @beta
1873
+ */
1874
+ export declare type 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
+ | {
1887
+ /**
1888
+ * When omitted, parent image value will be inferred from the target path.
1889
+ *
1890
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1891
+ * - `['image']`
1892
+ * - `['wrapper', 'mainImage']`
1893
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1894
+ *
1895
+ * Incompatible with `imageUrl`
1896
+ *
1897
+ */
1898
+ sourcePath?: AgentActionPath
1899
+ }
1900
+ | {
1901
+ /**
1902
+ * When specified, the image source for the description will be fetched from the URL over https.
1903
+ *
1904
+ * Incompatible with `sourcePath`
1905
+ */
1906
+ imageUrl?: `https://${string}`
1907
+ }
1908
+ )
1909
+
1869
1910
  /** @public */
1870
1911
  export declare interface InitializedClientConfig extends ClientConfig {
1871
1912
  apiHost: string
@@ -5764,6 +5805,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
5764
5805
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
5765
5806
  TransformRequestBase & AgentActionSync
5766
5807
 
5808
+ /**
5809
+ *
5810
+ * ## `set` by default
5811
+ * By default, Transform will change the value of every target field in place using a set operation.
5812
+ *
5813
+ * ## Image description
5814
+ *
5815
+ * ### Targeting image fields
5816
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5817
+ * with `operation: {type: 'image-description'}`.
5818
+ *
5819
+ * Custom instructions for image description targets will be used to generate the description.
5820
+ *
5821
+ * Such targets must be a descendant field of an image object.
5822
+ *
5823
+ * For example:
5824
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5825
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5826
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5827
+ *
5828
+ * ### Targeting non-image fields
5829
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5830
+ * `sourcePath` must be an image or image asset field.
5831
+ *
5832
+ * For example:
5833
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5834
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5835
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5836
+ *
5837
+ * @beta
5838
+ */
5839
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5840
+
5767
5841
  /** @beta */
5768
5842
  declare interface TransformRequestBase extends AgentActionRequestBase {
5769
5843
  /** schemaId as reported by sanity deploy / sanity schema store */
@@ -5905,7 +5979,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
5905
5979
  target?: TransformTarget | TransformTarget[]
5906
5980
  }
5907
5981
 
5908
- /** @beta */
5982
+ /**
5983
+ * @see #TransformOperation
5984
+ * @beta
5985
+ * */
5909
5986
  export declare interface TransformTarget extends AgentActionTarget {
5910
5987
  /**
5911
5988
  * Specifies a tailored instruction of this target.
@@ -5921,6 +5998,11 @@ export declare interface TransformTarget extends AgentActionTarget {
5921
5998
  * Fields or array items not on the include list, are implicitly excluded.
5922
5999
  */
5923
6000
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6001
+ /**
6002
+ * Default: `set`
6003
+ * @see #TransformOperation
6004
+ */
6005
+ operation?: TransformOperation
5924
6006
  }
5925
6007
 
5926
6008
  /**
@@ -5946,7 +6028,10 @@ export declare type TransformTargetDocument =
5946
6028
  _id: string
5947
6029
  }
5948
6030
 
5949
- /** @beta */
6031
+ /**
6032
+ * @see #TransformOperation
6033
+ * @beta
6034
+ * */
5950
6035
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
5951
6036
  /**
5952
6037
  * Specifies a tailored instruction of this target.
@@ -5961,6 +6046,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
5961
6046
  * Fields or array items not on the include list, are implicitly excluded.
5962
6047
  */
5963
6048
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6049
+ /**
6050
+ * Default: `set`
6051
+ * @see #TransformOperation
6052
+ */
6053
+ operation?: TransformOperation
5964
6054
  }
5965
6055
 
5966
6056
  /** @beta */
@@ -1866,6 +1866,47 @@ export declare type IdentifiedSanityDocumentStub<
1866
1866
  _id: string
1867
1867
  } & SanityDocumentStub
1868
1868
 
1869
+ /**
1870
+ *
1871
+ * @see #TransformOperation
1872
+ * @beta
1873
+ */
1874
+ export declare type 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
+ | {
1887
+ /**
1888
+ * When omitted, parent image value will be inferred from the target path.
1889
+ *
1890
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1891
+ * - `['image']`
1892
+ * - `['wrapper', 'mainImage']`
1893
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1894
+ *
1895
+ * Incompatible with `imageUrl`
1896
+ *
1897
+ */
1898
+ sourcePath?: AgentActionPath
1899
+ }
1900
+ | {
1901
+ /**
1902
+ * When specified, the image source for the description will be fetched from the URL over https.
1903
+ *
1904
+ * Incompatible with `sourcePath`
1905
+ */
1906
+ imageUrl?: `https://${string}`
1907
+ }
1908
+ )
1909
+
1869
1910
  /** @public */
1870
1911
  export declare interface InitializedClientConfig extends ClientConfig {
1871
1912
  apiHost: string
@@ -5764,6 +5805,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
5764
5805
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
5765
5806
  TransformRequestBase & AgentActionSync
5766
5807
 
5808
+ /**
5809
+ *
5810
+ * ## `set` by default
5811
+ * By default, Transform will change the value of every target field in place using a set operation.
5812
+ *
5813
+ * ## Image description
5814
+ *
5815
+ * ### Targeting image fields
5816
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5817
+ * with `operation: {type: 'image-description'}`.
5818
+ *
5819
+ * Custom instructions for image description targets will be used to generate the description.
5820
+ *
5821
+ * Such targets must be a descendant field of an image object.
5822
+ *
5823
+ * For example:
5824
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5825
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5826
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5827
+ *
5828
+ * ### Targeting non-image fields
5829
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5830
+ * `sourcePath` must be an image or image asset field.
5831
+ *
5832
+ * For example:
5833
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5834
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5835
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5836
+ *
5837
+ * @beta
5838
+ */
5839
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5840
+
5767
5841
  /** @beta */
5768
5842
  declare interface TransformRequestBase extends AgentActionRequestBase {
5769
5843
  /** schemaId as reported by sanity deploy / sanity schema store */
@@ -5905,7 +5979,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
5905
5979
  target?: TransformTarget | TransformTarget[]
5906
5980
  }
5907
5981
 
5908
- /** @beta */
5982
+ /**
5983
+ * @see #TransformOperation
5984
+ * @beta
5985
+ * */
5909
5986
  export declare interface TransformTarget extends AgentActionTarget {
5910
5987
  /**
5911
5988
  * Specifies a tailored instruction of this target.
@@ -5921,6 +5998,11 @@ export declare interface TransformTarget extends AgentActionTarget {
5921
5998
  * Fields or array items not on the include list, are implicitly excluded.
5922
5999
  */
5923
6000
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6001
+ /**
6002
+ * Default: `set`
6003
+ * @see #TransformOperation
6004
+ */
6005
+ operation?: TransformOperation
5924
6006
  }
5925
6007
 
5926
6008
  /**
@@ -5946,7 +6028,10 @@ export declare type TransformTargetDocument =
5946
6028
  _id: string
5947
6029
  }
5948
6030
 
5949
- /** @beta */
6031
+ /**
6032
+ * @see #TransformOperation
6033
+ * @beta
6034
+ * */
5950
6035
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
5951
6036
  /**
5952
6037
  * Specifies a tailored instruction of this target.
@@ -5961,6 +6046,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
5961
6046
  * Fields or array items not on the include list, are implicitly excluded.
5962
6047
  */
5963
6048
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6049
+ /**
6050
+ * Default: `set`
6051
+ * @see #TransformOperation
6052
+ */
6053
+ operation?: TransformOperation
5964
6054
  }
5965
6055
 
5966
6056
  /** @beta */
package/dist/stega.d.cts CHANGED
@@ -1866,6 +1866,47 @@ export declare type IdentifiedSanityDocumentStub<
1866
1866
  _id: string
1867
1867
  } & SanityDocumentStub
1868
1868
 
1869
+ /**
1870
+ *
1871
+ * @see #TransformOperation
1872
+ * @beta
1873
+ */
1874
+ export declare type 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
+ | {
1887
+ /**
1888
+ * When omitted, parent image value will be inferred from the target path.
1889
+ *
1890
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1891
+ * - `['image']`
1892
+ * - `['wrapper', 'mainImage']`
1893
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1894
+ *
1895
+ * Incompatible with `imageUrl`
1896
+ *
1897
+ */
1898
+ sourcePath?: AgentActionPath
1899
+ }
1900
+ | {
1901
+ /**
1902
+ * When specified, the image source for the description will be fetched from the URL over https.
1903
+ *
1904
+ * Incompatible with `sourcePath`
1905
+ */
1906
+ imageUrl?: `https://${string}`
1907
+ }
1908
+ )
1909
+
1869
1910
  /** @public */
1870
1911
  export declare interface InitializedClientConfig extends ClientConfig {
1871
1912
  apiHost: string
@@ -5764,6 +5805,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
5764
5805
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
5765
5806
  TransformRequestBase & AgentActionSync
5766
5807
 
5808
+ /**
5809
+ *
5810
+ * ## `set` by default
5811
+ * By default, Transform will change the value of every target field in place using a set operation.
5812
+ *
5813
+ * ## Image description
5814
+ *
5815
+ * ### Targeting image fields
5816
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5817
+ * with `operation: {type: 'image-description'}`.
5818
+ *
5819
+ * Custom instructions for image description targets will be used to generate the description.
5820
+ *
5821
+ * Such targets must be a descendant field of an image object.
5822
+ *
5823
+ * For example:
5824
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5825
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5826
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5827
+ *
5828
+ * ### Targeting non-image fields
5829
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5830
+ * `sourcePath` must be an image or image asset field.
5831
+ *
5832
+ * For example:
5833
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5834
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5835
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5836
+ *
5837
+ * @beta
5838
+ */
5839
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5840
+
5767
5841
  /** @beta */
5768
5842
  declare interface TransformRequestBase extends AgentActionRequestBase {
5769
5843
  /** schemaId as reported by sanity deploy / sanity schema store */
@@ -5905,7 +5979,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
5905
5979
  target?: TransformTarget | TransformTarget[]
5906
5980
  }
5907
5981
 
5908
- /** @beta */
5982
+ /**
5983
+ * @see #TransformOperation
5984
+ * @beta
5985
+ * */
5909
5986
  export declare interface TransformTarget extends AgentActionTarget {
5910
5987
  /**
5911
5988
  * Specifies a tailored instruction of this target.
@@ -5921,6 +5998,11 @@ export declare interface TransformTarget extends AgentActionTarget {
5921
5998
  * Fields or array items not on the include list, are implicitly excluded.
5922
5999
  */
5923
6000
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6001
+ /**
6002
+ * Default: `set`
6003
+ * @see #TransformOperation
6004
+ */
6005
+ operation?: TransformOperation
5924
6006
  }
5925
6007
 
5926
6008
  /**
@@ -5946,7 +6028,10 @@ export declare type TransformTargetDocument =
5946
6028
  _id: string
5947
6029
  }
5948
6030
 
5949
- /** @beta */
6031
+ /**
6032
+ * @see #TransformOperation
6033
+ * @beta
6034
+ * */
5950
6035
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
5951
6036
  /**
5952
6037
  * Specifies a tailored instruction of this target.
@@ -5961,6 +6046,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
5961
6046
  * Fields or array items not on the include list, are implicitly excluded.
5962
6047
  */
5963
6048
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6049
+ /**
6050
+ * Default: `set`
6051
+ * @see #TransformOperation
6052
+ */
6053
+ operation?: TransformOperation
5964
6054
  }
5965
6055
 
5966
6056
  /** @beta */
package/dist/stega.d.ts CHANGED
@@ -1866,6 +1866,47 @@ export declare type IdentifiedSanityDocumentStub<
1866
1866
  _id: string
1867
1867
  } & SanityDocumentStub
1868
1868
 
1869
+ /**
1870
+ *
1871
+ * @see #TransformOperation
1872
+ * @beta
1873
+ */
1874
+ export declare type 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
+ | {
1887
+ /**
1888
+ * When omitted, parent image value will be inferred from the target path.
1889
+ *
1890
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1891
+ * - `['image']`
1892
+ * - `['wrapper', 'mainImage']`
1893
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1894
+ *
1895
+ * Incompatible with `imageUrl`
1896
+ *
1897
+ */
1898
+ sourcePath?: AgentActionPath
1899
+ }
1900
+ | {
1901
+ /**
1902
+ * When specified, the image source for the description will be fetched from the URL over https.
1903
+ *
1904
+ * Incompatible with `sourcePath`
1905
+ */
1906
+ imageUrl?: `https://${string}`
1907
+ }
1908
+ )
1909
+
1869
1910
  /** @public */
1870
1911
  export declare interface InitializedClientConfig extends ClientConfig {
1871
1912
  apiHost: string
@@ -5764,6 +5805,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
5764
5805
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
5765
5806
  TransformRequestBase & AgentActionSync
5766
5807
 
5808
+ /**
5809
+ *
5810
+ * ## `set` by default
5811
+ * By default, Transform will change the value of every target field in place using a set operation.
5812
+ *
5813
+ * ## Image description
5814
+ *
5815
+ * ### Targeting image fields
5816
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5817
+ * with `operation: {type: 'image-description'}`.
5818
+ *
5819
+ * Custom instructions for image description targets will be used to generate the description.
5820
+ *
5821
+ * Such targets must be a descendant field of an image object.
5822
+ *
5823
+ * For example:
5824
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5825
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5826
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5827
+ *
5828
+ * ### Targeting non-image fields
5829
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5830
+ * `sourcePath` must be an image or image asset field.
5831
+ *
5832
+ * For example:
5833
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5834
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5835
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5836
+ *
5837
+ * @beta
5838
+ */
5839
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5840
+
5767
5841
  /** @beta */
5768
5842
  declare interface TransformRequestBase extends AgentActionRequestBase {
5769
5843
  /** schemaId as reported by sanity deploy / sanity schema store */
@@ -5905,7 +5979,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
5905
5979
  target?: TransformTarget | TransformTarget[]
5906
5980
  }
5907
5981
 
5908
- /** @beta */
5982
+ /**
5983
+ * @see #TransformOperation
5984
+ * @beta
5985
+ * */
5909
5986
  export declare interface TransformTarget extends AgentActionTarget {
5910
5987
  /**
5911
5988
  * Specifies a tailored instruction of this target.
@@ -5921,6 +5998,11 @@ export declare interface TransformTarget extends AgentActionTarget {
5921
5998
  * Fields or array items not on the include list, are implicitly excluded.
5922
5999
  */
5923
6000
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6001
+ /**
6002
+ * Default: `set`
6003
+ * @see #TransformOperation
6004
+ */
6005
+ operation?: TransformOperation
5924
6006
  }
5925
6007
 
5926
6008
  /**
@@ -5946,7 +6028,10 @@ export declare type TransformTargetDocument =
5946
6028
  _id: string
5947
6029
  }
5948
6030
 
5949
- /** @beta */
6031
+ /**
6032
+ * @see #TransformOperation
6033
+ * @beta
6034
+ * */
5950
6035
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
5951
6036
  /**
5952
6037
  * Specifies a tailored instruction of this target.
@@ -5961,6 +6046,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
5961
6046
  * Fields or array items not on the include list, are implicitly excluded.
5962
6047
  */
5963
6048
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
6049
+ /**
6050
+ * Default: `set`
6051
+ * @see #TransformOperation
6052
+ */
6053
+ operation?: TransformOperation
5964
6054
  }
5965
6055
 
5966
6056
  /** @beta */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "7.4.1",
3
+ "version": "7.5.0-agent-actions.0",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -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 {AgentActionParams, Any, HttpRequest, IdentifiedSanityDocumentStub} from '../../types'
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,84 @@ export type TransformTargetDocument =
169
175
  | {operation: 'createIfNotExists'; _id: string}
170
176
  | {operation: 'createOrReplace'; _id: string}
171
177
 
172
- /** @beta */
178
+ /**
179
+ *
180
+ * @see #TransformOperation
181
+ * @beta
182
+ */
183
+ export type 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
+ * 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
+ }
209
+ | {
210
+ /**
211
+ * When specified, the image source for the description will be fetched from the URL over https.
212
+ *
213
+ * Incompatible with `sourcePath`
214
+ */
215
+ imageUrl?: `https://${string}`
216
+ }
217
+ )
218
+
219
+ /**
220
+ *
221
+ * ## `set` by default
222
+ * By default, Transform will change the value of every target field in place using a set operation.
223
+ *
224
+ * ## Image description
225
+ *
226
+ * ### Targeting image fields
227
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
228
+ * with `operation: {type: 'image-description'}`.
229
+ *
230
+ * Custom instructions for image description targets will be used to generate the description.
231
+ *
232
+ * Such targets must be a descendant field of an image object.
233
+ *
234
+ * For example:
235
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
236
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
237
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
238
+ *
239
+ * ### Targeting non-image fields
240
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
241
+ * `sourcePath` must be an image or image asset field.
242
+ *
243
+ * For example:
244
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
245
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
246
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
247
+ *
248
+ * @beta
249
+ */
250
+ export type TransformOperation = 'set' | ImageDescriptionOperation
251
+
252
+ /**
253
+ * @see #TransformOperation
254
+ * @beta
255
+ * */
173
256
  export interface TransformTargetInclude extends AgentActionTargetInclude {
174
257
  /**
175
258
  * Specifies a tailored instruction of this target.
@@ -185,9 +268,18 @@ export interface TransformTargetInclude extends AgentActionTargetInclude {
185
268
  * Fields or array items not on the include list, are implicitly excluded.
186
269
  */
187
270
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
271
+
272
+ /**
273
+ * Default: `set`
274
+ * @see #TransformOperation
275
+ */
276
+ operation?: TransformOperation
188
277
  }
189
278
 
190
- /** @beta */
279
+ /**
280
+ * @see #TransformOperation
281
+ * @beta
282
+ * */
191
283
  export interface TransformTarget extends AgentActionTarget {
192
284
  /**
193
285
  * Specifies a tailored instruction of this target.
@@ -204,6 +296,12 @@ export interface TransformTarget extends AgentActionTarget {
204
296
  * Fields or array items not on the include list, are implicitly excluded.
205
297
  */
206
298
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
299
+
300
+ /**
301
+ * Default: `set`
302
+ * @see #TransformOperation
303
+ */
304
+ operation?: TransformOperation
207
305
  }
208
306
 
209
307
  /** @beta */
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,