@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/README.md +27 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +92 -2
- package/dist/index.browser.d.ts +92 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -2
- package/dist/index.d.ts +92 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +92 -2
- package/dist/stega.browser.d.ts +92 -2
- package/dist/stega.d.cts +92 -2
- package/dist/stega.d.ts +92 -2
- package/package.json +1 -1
- package/src/agent/actions/transform.ts +101 -3
- package/src/types.ts +2 -0
package/dist/index.browser.d.cts
CHANGED
|
@@ -1706,6 +1706,47 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1706
1706
|
_id: string
|
|
1707
1707
|
} & SanityDocumentStub
|
|
1708
1708
|
|
|
1709
|
+
/**
|
|
1710
|
+
*
|
|
1711
|
+
* @see #TransformOperation
|
|
1712
|
+
* @beta
|
|
1713
|
+
*/
|
|
1714
|
+
export declare type ImageDescriptionOperation = {
|
|
1715
|
+
type: 'image-description'
|
|
1716
|
+
/**
|
|
1717
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
1718
|
+
*
|
|
1719
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1720
|
+
* - `['image']`
|
|
1721
|
+
* - `['wrapper', 'mainImage']`
|
|
1722
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1723
|
+
*/
|
|
1724
|
+
sourcePath?: AgentActionPath
|
|
1725
|
+
} & (
|
|
1726
|
+
| {
|
|
1727
|
+
/**
|
|
1728
|
+
* When omitted, parent image value will be inferred from the target path.
|
|
1729
|
+
*
|
|
1730
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1731
|
+
* - `['image']`
|
|
1732
|
+
* - `['wrapper', 'mainImage']`
|
|
1733
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1734
|
+
*
|
|
1735
|
+
* Incompatible with `imageUrl`
|
|
1736
|
+
*
|
|
1737
|
+
*/
|
|
1738
|
+
sourcePath?: AgentActionPath
|
|
1739
|
+
}
|
|
1740
|
+
| {
|
|
1741
|
+
/**
|
|
1742
|
+
* When specified, the image source for the description will be fetched from the URL over https.
|
|
1743
|
+
*
|
|
1744
|
+
* Incompatible with `sourcePath`
|
|
1745
|
+
*/
|
|
1746
|
+
imageUrl?: `https://${string}`
|
|
1747
|
+
}
|
|
1748
|
+
)
|
|
1749
|
+
|
|
1709
1750
|
/** @public */
|
|
1710
1751
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1711
1752
|
apiHost: string
|
|
@@ -5506,6 +5547,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5506
5547
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5507
5548
|
TransformRequestBase & AgentActionSync
|
|
5508
5549
|
|
|
5550
|
+
/**
|
|
5551
|
+
*
|
|
5552
|
+
* ## `set` by default
|
|
5553
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5554
|
+
*
|
|
5555
|
+
* ## Image description
|
|
5556
|
+
*
|
|
5557
|
+
* ### Targeting image fields
|
|
5558
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5559
|
+
* with `operation: {type: 'image-description'}`.
|
|
5560
|
+
*
|
|
5561
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5562
|
+
*
|
|
5563
|
+
* Such targets must be a descendant field of an image object.
|
|
5564
|
+
*
|
|
5565
|
+
* For example:
|
|
5566
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5567
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5568
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5569
|
+
*
|
|
5570
|
+
* ### Targeting non-image fields
|
|
5571
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5572
|
+
* `sourcePath` must be an image or image asset field.
|
|
5573
|
+
*
|
|
5574
|
+
* For example:
|
|
5575
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5576
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5577
|
+
* - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5578
|
+
*
|
|
5579
|
+
* @beta
|
|
5580
|
+
*/
|
|
5581
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5582
|
+
|
|
5509
5583
|
/** @beta */
|
|
5510
5584
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5511
5585
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5647,7 +5721,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5647
5721
|
target?: TransformTarget | TransformTarget[]
|
|
5648
5722
|
}
|
|
5649
5723
|
|
|
5650
|
-
/**
|
|
5724
|
+
/**
|
|
5725
|
+
* @see #TransformOperation
|
|
5726
|
+
* @beta
|
|
5727
|
+
* */
|
|
5651
5728
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5652
5729
|
/**
|
|
5653
5730
|
* Specifies a tailored instruction of this target.
|
|
@@ -5663,6 +5740,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5663
5740
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5664
5741
|
*/
|
|
5665
5742
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5743
|
+
/**
|
|
5744
|
+
* Default: `set`
|
|
5745
|
+
* @see #TransformOperation
|
|
5746
|
+
*/
|
|
5747
|
+
operation?: TransformOperation
|
|
5666
5748
|
}
|
|
5667
5749
|
|
|
5668
5750
|
/**
|
|
@@ -5688,7 +5770,10 @@ export declare type TransformTargetDocument =
|
|
|
5688
5770
|
_id: string
|
|
5689
5771
|
}
|
|
5690
5772
|
|
|
5691
|
-
/**
|
|
5773
|
+
/**
|
|
5774
|
+
* @see #TransformOperation
|
|
5775
|
+
* @beta
|
|
5776
|
+
* */
|
|
5692
5777
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5693
5778
|
/**
|
|
5694
5779
|
* Specifies a tailored instruction of this target.
|
|
@@ -5703,6 +5788,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5703
5788
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5704
5789
|
*/
|
|
5705
5790
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5791
|
+
/**
|
|
5792
|
+
* Default: `set`
|
|
5793
|
+
* @see #TransformOperation
|
|
5794
|
+
*/
|
|
5795
|
+
operation?: TransformOperation
|
|
5706
5796
|
}
|
|
5707
5797
|
|
|
5708
5798
|
/** @beta */
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1706,6 +1706,47 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1706
1706
|
_id: string
|
|
1707
1707
|
} & SanityDocumentStub
|
|
1708
1708
|
|
|
1709
|
+
/**
|
|
1710
|
+
*
|
|
1711
|
+
* @see #TransformOperation
|
|
1712
|
+
* @beta
|
|
1713
|
+
*/
|
|
1714
|
+
export declare type ImageDescriptionOperation = {
|
|
1715
|
+
type: 'image-description'
|
|
1716
|
+
/**
|
|
1717
|
+
* When omitted, parent image value will be inferred from the arget path.
|
|
1718
|
+
*
|
|
1719
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1720
|
+
* - `['image']`
|
|
1721
|
+
* - `['wrapper', 'mainImage']`
|
|
1722
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1723
|
+
*/
|
|
1724
|
+
sourcePath?: AgentActionPath
|
|
1725
|
+
} & (
|
|
1726
|
+
| {
|
|
1727
|
+
/**
|
|
1728
|
+
* When omitted, parent image value will be inferred from the target path.
|
|
1729
|
+
*
|
|
1730
|
+
* When specified, the `sourcePath` should be a path to an image (or image asset) field:
|
|
1731
|
+
* - `['image']`
|
|
1732
|
+
* - `['wrapper', 'mainImage']`
|
|
1733
|
+
* - `['heroImage', 'asset'] // the asset segment is optional, but supported`
|
|
1734
|
+
*
|
|
1735
|
+
* Incompatible with `imageUrl`
|
|
1736
|
+
*
|
|
1737
|
+
*/
|
|
1738
|
+
sourcePath?: AgentActionPath
|
|
1739
|
+
}
|
|
1740
|
+
| {
|
|
1741
|
+
/**
|
|
1742
|
+
* When specified, the image source for the description will be fetched from the URL over https.
|
|
1743
|
+
*
|
|
1744
|
+
* Incompatible with `sourcePath`
|
|
1745
|
+
*/
|
|
1746
|
+
imageUrl?: `https://${string}`
|
|
1747
|
+
}
|
|
1748
|
+
)
|
|
1749
|
+
|
|
1709
1750
|
/** @public */
|
|
1710
1751
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1711
1752
|
apiHost: string
|
|
@@ -5506,6 +5547,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5506
5547
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5507
5548
|
TransformRequestBase & AgentActionSync
|
|
5508
5549
|
|
|
5550
|
+
/**
|
|
5551
|
+
*
|
|
5552
|
+
* ## `set` by default
|
|
5553
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5554
|
+
*
|
|
5555
|
+
* ## Image description
|
|
5556
|
+
*
|
|
5557
|
+
* ### Targeting image fields
|
|
5558
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5559
|
+
* with `operation: {type: 'image-description'}`.
|
|
5560
|
+
*
|
|
5561
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5562
|
+
*
|
|
5563
|
+
* Such targets must be a descendant field of an image object.
|
|
5564
|
+
*
|
|
5565
|
+
* For example:
|
|
5566
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5567
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5568
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5569
|
+
*
|
|
5570
|
+
* ### Targeting non-image fields
|
|
5571
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5572
|
+
* `sourcePath` must be an image or image asset field.
|
|
5573
|
+
*
|
|
5574
|
+
* For example:
|
|
5575
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5576
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5577
|
+
* - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5578
|
+
*
|
|
5579
|
+
* @beta
|
|
5580
|
+
*/
|
|
5581
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5582
|
+
|
|
5509
5583
|
/** @beta */
|
|
5510
5584
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5511
5585
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5647,7 +5721,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5647
5721
|
target?: TransformTarget | TransformTarget[]
|
|
5648
5722
|
}
|
|
5649
5723
|
|
|
5650
|
-
/**
|
|
5724
|
+
/**
|
|
5725
|
+
* @see #TransformOperation
|
|
5726
|
+
* @beta
|
|
5727
|
+
* */
|
|
5651
5728
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5652
5729
|
/**
|
|
5653
5730
|
* Specifies a tailored instruction of this target.
|
|
@@ -5663,6 +5740,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5663
5740
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5664
5741
|
*/
|
|
5665
5742
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5743
|
+
/**
|
|
5744
|
+
* Default: `set`
|
|
5745
|
+
* @see #TransformOperation
|
|
5746
|
+
*/
|
|
5747
|
+
operation?: TransformOperation
|
|
5666
5748
|
}
|
|
5667
5749
|
|
|
5668
5750
|
/**
|
|
@@ -5688,7 +5770,10 @@ export declare type TransformTargetDocument =
|
|
|
5688
5770
|
_id: string
|
|
5689
5771
|
}
|
|
5690
5772
|
|
|
5691
|
-
/**
|
|
5773
|
+
/**
|
|
5774
|
+
* @see #TransformOperation
|
|
5775
|
+
* @beta
|
|
5776
|
+
* */
|
|
5692
5777
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5693
5778
|
/**
|
|
5694
5779
|
* Specifies a tailored instruction of this target.
|
|
@@ -5703,6 +5788,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5703
5788
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5704
5789
|
*/
|
|
5705
5790
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5791
|
+
/**
|
|
5792
|
+
* Default: `set`
|
|
5793
|
+
* @see #TransformOperation
|
|
5794
|
+
*/
|
|
5795
|
+
operation?: TransformOperation
|
|
5706
5796
|
}
|
|
5707
5797
|
|
|
5708
5798
|
/** @beta */
|