@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/index.d.cts
CHANGED
|
@@ -1710,6 +1710,24 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1710
1710
|
_id: string
|
|
1711
1711
|
} & SanityDocumentStub
|
|
1712
1712
|
|
|
1713
|
+
/**
|
|
1714
|
+
*
|
|
1715
|
+
* @see #TransformOperation
|
|
1716
|
+
* @beta
|
|
1717
|
+
*/
|
|
1718
|
+
export declare interface 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
|
+
|
|
1713
1731
|
/** @public */
|
|
1714
1732
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1715
1733
|
apiHost: string
|
|
@@ -5510,6 +5528,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5510
5528
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5511
5529
|
TransformRequestBase & AgentActionSync
|
|
5512
5530
|
|
|
5531
|
+
/**
|
|
5532
|
+
*
|
|
5533
|
+
* ## `set` by default
|
|
5534
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5535
|
+
*
|
|
5536
|
+
* ## Image description
|
|
5537
|
+
*
|
|
5538
|
+
* ### Targeting image fields
|
|
5539
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5540
|
+
* with `operation: {type: 'image-description'}`.
|
|
5541
|
+
*
|
|
5542
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5543
|
+
*
|
|
5544
|
+
* Such targets must be a descendant field of an image object.
|
|
5545
|
+
*
|
|
5546
|
+
* For example:
|
|
5547
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5548
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5549
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5550
|
+
*
|
|
5551
|
+
* ### Targeting non-image fields
|
|
5552
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5553
|
+
* `sourcePath` must be an image or image asset field.
|
|
5554
|
+
*
|
|
5555
|
+
* For example:
|
|
5556
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5557
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5558
|
+
* - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5559
|
+
*
|
|
5560
|
+
* @beta
|
|
5561
|
+
*/
|
|
5562
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5563
|
+
|
|
5513
5564
|
/** @beta */
|
|
5514
5565
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5515
5566
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5651,7 +5702,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5651
5702
|
target?: TransformTarget | TransformTarget[]
|
|
5652
5703
|
}
|
|
5653
5704
|
|
|
5654
|
-
/**
|
|
5705
|
+
/**
|
|
5706
|
+
* @see #TransformOperation
|
|
5707
|
+
* @beta
|
|
5708
|
+
* */
|
|
5655
5709
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5656
5710
|
/**
|
|
5657
5711
|
* Specifies a tailored instruction of this target.
|
|
@@ -5667,6 +5721,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5667
5721
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5668
5722
|
*/
|
|
5669
5723
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5724
|
+
/**
|
|
5725
|
+
* Default: `set`
|
|
5726
|
+
* @see #TransformOperation
|
|
5727
|
+
*/
|
|
5728
|
+
operation?: TransformOperation
|
|
5670
5729
|
}
|
|
5671
5730
|
|
|
5672
5731
|
/**
|
|
@@ -5692,7 +5751,10 @@ export declare type TransformTargetDocument =
|
|
|
5692
5751
|
_id: string
|
|
5693
5752
|
}
|
|
5694
5753
|
|
|
5695
|
-
/**
|
|
5754
|
+
/**
|
|
5755
|
+
* @see #TransformOperation
|
|
5756
|
+
* @beta
|
|
5757
|
+
* */
|
|
5696
5758
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5697
5759
|
/**
|
|
5698
5760
|
* Specifies a tailored instruction of this target.
|
|
@@ -5707,6 +5769,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5707
5769
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5708
5770
|
*/
|
|
5709
5771
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5772
|
+
/**
|
|
5773
|
+
* Default: `set`
|
|
5774
|
+
* @see #TransformOperation
|
|
5775
|
+
*/
|
|
5776
|
+
operation?: TransformOperation
|
|
5710
5777
|
}
|
|
5711
5778
|
|
|
5712
5779
|
/** @beta */
|
package/dist/index.d.ts
CHANGED
|
@@ -1710,6 +1710,24 @@ export declare type IdentifiedSanityDocumentStub<
|
|
|
1710
1710
|
_id: string
|
|
1711
1711
|
} & SanityDocumentStub
|
|
1712
1712
|
|
|
1713
|
+
/**
|
|
1714
|
+
*
|
|
1715
|
+
* @see #TransformOperation
|
|
1716
|
+
* @beta
|
|
1717
|
+
*/
|
|
1718
|
+
export declare interface 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
|
+
|
|
1713
1731
|
/** @public */
|
|
1714
1732
|
export declare interface InitializedClientConfig extends ClientConfig {
|
|
1715
1733
|
apiHost: string
|
|
@@ -5510,6 +5528,39 @@ declare type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
|
5510
5528
|
declare type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
5511
5529
|
TransformRequestBase & AgentActionSync
|
|
5512
5530
|
|
|
5531
|
+
/**
|
|
5532
|
+
*
|
|
5533
|
+
* ## `set` by default
|
|
5534
|
+
* By default, Transform will change the value of every target field in place using a set operation.
|
|
5535
|
+
*
|
|
5536
|
+
* ## Image description
|
|
5537
|
+
*
|
|
5538
|
+
* ### Targeting image fields
|
|
5539
|
+
* Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
|
|
5540
|
+
* with `operation: {type: 'image-description'}`.
|
|
5541
|
+
*
|
|
5542
|
+
* Custom instructions for image description targets will be used to generate the description.
|
|
5543
|
+
*
|
|
5544
|
+
* Such targets must be a descendant field of an image object.
|
|
5545
|
+
*
|
|
5546
|
+
* For example:
|
|
5547
|
+
* - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
|
|
5548
|
+
* - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
|
|
5549
|
+
* - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5550
|
+
*
|
|
5551
|
+
* ### Targeting non-image fields
|
|
5552
|
+
* If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
|
|
5553
|
+
* `sourcePath` must be an image or image asset field.
|
|
5554
|
+
*
|
|
5555
|
+
* For example:
|
|
5556
|
+
* - `target: {path: ['description'], operation: operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
|
|
5557
|
+
* - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
5558
|
+
* - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
5559
|
+
*
|
|
5560
|
+
* @beta
|
|
5561
|
+
*/
|
|
5562
|
+
export declare type TransformOperation = 'set' | ImageDescriptionOperation
|
|
5563
|
+
|
|
5513
5564
|
/** @beta */
|
|
5514
5565
|
declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
5515
5566
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
@@ -5651,7 +5702,10 @@ declare interface TransformRequestBase extends AgentActionRequestBase {
|
|
|
5651
5702
|
target?: TransformTarget | TransformTarget[]
|
|
5652
5703
|
}
|
|
5653
5704
|
|
|
5654
|
-
/**
|
|
5705
|
+
/**
|
|
5706
|
+
* @see #TransformOperation
|
|
5707
|
+
* @beta
|
|
5708
|
+
* */
|
|
5655
5709
|
export declare interface TransformTarget extends AgentActionTarget {
|
|
5656
5710
|
/**
|
|
5657
5711
|
* Specifies a tailored instruction of this target.
|
|
@@ -5667,6 +5721,11 @@ export declare interface TransformTarget extends AgentActionTarget {
|
|
|
5667
5721
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5668
5722
|
*/
|
|
5669
5723
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5724
|
+
/**
|
|
5725
|
+
* Default: `set`
|
|
5726
|
+
* @see #TransformOperation
|
|
5727
|
+
*/
|
|
5728
|
+
operation?: TransformOperation
|
|
5670
5729
|
}
|
|
5671
5730
|
|
|
5672
5731
|
/**
|
|
@@ -5692,7 +5751,10 @@ export declare type TransformTargetDocument =
|
|
|
5692
5751
|
_id: string
|
|
5693
5752
|
}
|
|
5694
5753
|
|
|
5695
|
-
/**
|
|
5754
|
+
/**
|
|
5755
|
+
* @see #TransformOperation
|
|
5756
|
+
* @beta
|
|
5757
|
+
* */
|
|
5696
5758
|
export declare interface TransformTargetInclude extends AgentActionTargetInclude {
|
|
5697
5759
|
/**
|
|
5698
5760
|
* Specifies a tailored instruction of this target.
|
|
@@ -5707,6 +5769,11 @@ export declare interface TransformTargetInclude extends AgentActionTargetInclude
|
|
|
5707
5769
|
* Fields or array items not on the include list, are implicitly excluded.
|
|
5708
5770
|
*/
|
|
5709
5771
|
include?: (AgentActionPathSegment | TransformTargetInclude)[]
|
|
5772
|
+
/**
|
|
5773
|
+
* Default: `set`
|
|
5774
|
+
* @see #TransformOperation
|
|
5775
|
+
*/
|
|
5776
|
+
operation?: TransformOperation
|
|
5710
5777
|
}
|
|
5711
5778
|
|
|
5712
5779
|
/** @beta */
|
package/dist/index.js
CHANGED
|
@@ -671,7 +671,7 @@ const encodeQueryString = ({
|
|
|
671
671
|
const searchParams = new URLSearchParams(), { tag, includeMutations, returnQuery, ...opts } = options;
|
|
672
672
|
tag && searchParams.append("tag", tag), searchParams.append("query", query);
|
|
673
673
|
for (const [key, value] of Object.entries(params))
|
|
674
|
-
searchParams.append(`$${key}`, JSON.stringify(value));
|
|
674
|
+
value !== void 0 && searchParams.append(`$${key}`, JSON.stringify(value));
|
|
675
675
|
for (const [key, value] of Object.entries(opts))
|
|
676
676
|
value && searchParams.append(key, `${value}`);
|
|
677
677
|
return returnQuery === !1 && searchParams.append("returnQuery", "false"), includeMutations === !1 && searchParams.append("includeMutations", "false"), `?${searchParams}`;
|
|
@@ -2510,7 +2510,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2510
2510
|
return printNoDefaultExport(), createClient2(config);
|
|
2511
2511
|
};
|
|
2512
2512
|
}
|
|
2513
|
-
var name = "@sanity/client", version = "7.
|
|
2513
|
+
var name = "@sanity/client", version = "7.5.0";
|
|
2514
2514
|
const middleware = [
|
|
2515
2515
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2516
2516
|
headers({ "User-Agent": `${name} ${version}` }),
|