@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.
package/dist/index.d.cts CHANGED
@@ -1710,6 +1710,47 @@ export declare type IdentifiedSanityDocumentStub<
1710
1710
  _id: string
1711
1711
  } & SanityDocumentStub
1712
1712
 
1713
+ /**
1714
+ *
1715
+ * @see #TransformOperation
1716
+ * @beta
1717
+ */
1718
+ export declare type ImageDescriptionOperation = {
1719
+ type: 'image-description'
1720
+ /**
1721
+ * When omitted, parent image value will be inferred from the arget path.
1722
+ *
1723
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1724
+ * - `['image']`
1725
+ * - `['wrapper', 'mainImage']`
1726
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1727
+ */
1728
+ sourcePath?: AgentActionPath
1729
+ } & (
1730
+ | {
1731
+ /**
1732
+ * When omitted, parent image value will be inferred from the target path.
1733
+ *
1734
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1735
+ * - `['image']`
1736
+ * - `['wrapper', 'mainImage']`
1737
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1738
+ *
1739
+ * Incompatible with `imageUrl`
1740
+ *
1741
+ */
1742
+ sourcePath?: AgentActionPath
1743
+ }
1744
+ | {
1745
+ /**
1746
+ * When specified, the image source for the description will be fetched from the URL over https.
1747
+ *
1748
+ * Incompatible with `sourcePath`
1749
+ */
1750
+ imageUrl?: `https://${string}`
1751
+ }
1752
+ )
1753
+
1713
1754
  /** @public */
1714
1755
  export declare interface InitializedClientConfig extends ClientConfig {
1715
1756
  apiHost: string
@@ -5510,6 +5551,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
5510
5551
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
5511
5552
  TransformRequestBase & AgentActionSync
5512
5553
 
5554
+ /**
5555
+ *
5556
+ * ## `set` by default
5557
+ * By default, Transform will change the value of every target field in place using a set operation.
5558
+ *
5559
+ * ## Image description
5560
+ *
5561
+ * ### Targeting image fields
5562
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5563
+ * with `operation: {type: 'image-description'}`.
5564
+ *
5565
+ * Custom instructions for image description targets will be used to generate the description.
5566
+ *
5567
+ * Such targets must be a descendant field of an image object.
5568
+ *
5569
+ * For example:
5570
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5571
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5572
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5573
+ *
5574
+ * ### Targeting non-image fields
5575
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5576
+ * `sourcePath` must be an image or image asset field.
5577
+ *
5578
+ * For example:
5579
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5580
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5581
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5582
+ *
5583
+ * @beta
5584
+ */
5585
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5586
+
5513
5587
  /** @beta */
5514
5588
  declare interface TransformRequestBase extends AgentActionRequestBase {
5515
5589
  /** schemaId as reported by sanity deploy / sanity schema store */
@@ -5651,7 +5725,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
5651
5725
  target?: TransformTarget | TransformTarget[]
5652
5726
  }
5653
5727
 
5654
- /** @beta */
5728
+ /**
5729
+ * @see #TransformOperation
5730
+ * @beta
5731
+ * */
5655
5732
  export declare interface TransformTarget extends AgentActionTarget {
5656
5733
  /**
5657
5734
  * Specifies a tailored instruction of this target.
@@ -5667,6 +5744,11 @@ export declare interface TransformTarget extends AgentActionTarget {
5667
5744
  * Fields or array items not on the include list, are implicitly excluded.
5668
5745
  */
5669
5746
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5747
+ /**
5748
+ * Default: `set`
5749
+ * @see #TransformOperation
5750
+ */
5751
+ operation?: TransformOperation
5670
5752
  }
5671
5753
 
5672
5754
  /**
@@ -5692,7 +5774,10 @@ export declare type TransformTargetDocument =
5692
5774
  _id: string
5693
5775
  }
5694
5776
 
5695
- /** @beta */
5777
+ /**
5778
+ * @see #TransformOperation
5779
+ * @beta
5780
+ * */
5696
5781
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
5697
5782
  /**
5698
5783
  * Specifies a tailored instruction of this target.
@@ -5707,6 +5792,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
5707
5792
  * Fields or array items not on the include list, are implicitly excluded.
5708
5793
  */
5709
5794
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5795
+ /**
5796
+ * Default: `set`
5797
+ * @see #TransformOperation
5798
+ */
5799
+ operation?: TransformOperation
5710
5800
  }
5711
5801
 
5712
5802
  /** @beta */
package/dist/index.d.ts CHANGED
@@ -1710,6 +1710,47 @@ export declare type IdentifiedSanityDocumentStub<
1710
1710
  _id: string
1711
1711
  } & SanityDocumentStub
1712
1712
 
1713
+ /**
1714
+ *
1715
+ * @see #TransformOperation
1716
+ * @beta
1717
+ */
1718
+ export declare type ImageDescriptionOperation = {
1719
+ type: 'image-description'
1720
+ /**
1721
+ * When omitted, parent image value will be inferred from the arget path.
1722
+ *
1723
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1724
+ * - `['image']`
1725
+ * - `['wrapper', 'mainImage']`
1726
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1727
+ */
1728
+ sourcePath?: AgentActionPath
1729
+ } & (
1730
+ | {
1731
+ /**
1732
+ * When omitted, parent image value will be inferred from the target path.
1733
+ *
1734
+ * When specified, the `sourcePath` should be a path to an image (or image asset) field:
1735
+ * - `['image']`
1736
+ * - `['wrapper', 'mainImage']`
1737
+ * - `['heroImage', 'asset'] // the asset segment is optional, but supported`
1738
+ *
1739
+ * Incompatible with `imageUrl`
1740
+ *
1741
+ */
1742
+ sourcePath?: AgentActionPath
1743
+ }
1744
+ | {
1745
+ /**
1746
+ * When specified, the image source for the description will be fetched from the URL over https.
1747
+ *
1748
+ * Incompatible with `sourcePath`
1749
+ */
1750
+ imageUrl?: `https://${string}`
1751
+ }
1752
+ )
1753
+
1713
1754
  /** @public */
1714
1755
  export declare interface InitializedClientConfig extends ClientConfig {
1715
1756
  apiHost: string
@@ -5510,6 +5551,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
5510
5551
  declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
5511
5552
  TransformRequestBase & AgentActionSync
5512
5553
 
5554
+ /**
5555
+ *
5556
+ * ## `set` by default
5557
+ * By default, Transform will change the value of every target field in place using a set operation.
5558
+ *
5559
+ * ## Image description
5560
+ *
5561
+ * ### Targeting image fields
5562
+ * Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
5563
+ * with `operation: {type: 'image-description'}`.
5564
+ *
5565
+ * Custom instructions for image description targets will be used to generate the description.
5566
+ *
5567
+ * Such targets must be a descendant field of an image object.
5568
+ *
5569
+ * For example:
5570
+ * - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
5571
+ * - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
5572
+ * - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
5573
+ *
5574
+ * ### Targeting non-image fields
5575
+ * If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
5576
+ * `sourcePath` must be an image or image asset field.
5577
+ *
5578
+ * For example:
5579
+ * - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
5580
+ * - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
5581
+ * - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
5582
+ *
5583
+ * @beta
5584
+ */
5585
+ export declare type TransformOperation = 'set' | ImageDescriptionOperation
5586
+
5513
5587
  /** @beta */
5514
5588
  declare interface TransformRequestBase extends AgentActionRequestBase {
5515
5589
  /** schemaId as reported by sanity deploy / sanity schema store */
@@ -5651,7 +5725,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
5651
5725
  target?: TransformTarget | TransformTarget[]
5652
5726
  }
5653
5727
 
5654
- /** @beta */
5728
+ /**
5729
+ * @see #TransformOperation
5730
+ * @beta
5731
+ * */
5655
5732
  export declare interface TransformTarget extends AgentActionTarget {
5656
5733
  /**
5657
5734
  * Specifies a tailored instruction of this target.
@@ -5667,6 +5744,11 @@ export declare interface TransformTarget extends AgentActionTarget {
5667
5744
  * Fields or array items not on the include list, are implicitly excluded.
5668
5745
  */
5669
5746
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5747
+ /**
5748
+ * Default: `set`
5749
+ * @see #TransformOperation
5750
+ */
5751
+ operation?: TransformOperation
5670
5752
  }
5671
5753
 
5672
5754
  /**
@@ -5692,7 +5774,10 @@ export declare type TransformTargetDocument =
5692
5774
  _id: string
5693
5775
  }
5694
5776
 
5695
- /** @beta */
5777
+ /**
5778
+ * @see #TransformOperation
5779
+ * @beta
5780
+ * */
5696
5781
  export declare interface TransformTargetInclude extends AgentActionTargetInclude {
5697
5782
  /**
5698
5783
  * Specifies a tailored instruction of this target.
@@ -5707,6 +5792,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
5707
5792
  * Fields or array items not on the include list, are implicitly excluded.
5708
5793
  */
5709
5794
  include?: (AgentActionPathSegment | TransformTargetInclude)[]
5795
+ /**
5796
+ * Default: `set`
5797
+ * @see #TransformOperation
5798
+ */
5799
+ operation?: TransformOperation
5710
5800
  }
5711
5801
 
5712
5802
  /** @beta */
package/dist/index.js CHANGED
@@ -2510,7 +2510,7 @@ function defineDeprecatedCreateClient(createClient2) {
2510
2510
  return printNoDefaultExport(), createClient2(config);
2511
2511
  };
2512
2512
  }
2513
- var name = "@sanity/client", version = "7.4.1";
2513
+ var name = "@sanity/client", version = "7.5.0-agent-actions.0";
2514
2514
  const middleware = [
2515
2515
  debug({ verbose: !0, namespace: "sanity:client" }),
2516
2516
  headers({ "User-Agent": `${name} ${version}` }),