@sanity/client 7.4.1 → 7.5.0-live-cors.1

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 CHANGED
@@ -122,6 +122,7 @@ export async function updateDocumentTitle(_id, title) {
122
122
  - [Example: Using the async flag](#example-using-the-async-flag)
123
123
  - [Transforming Documents](#transforming-documents)
124
124
  - [Transforming images](#transforming-images)
125
+ - [Image descriptions](#image-descriptions)
125
126
  - [Example: Field-based transformation](#example-field-based-transformation)
126
127
  - [Translating Documents](#translating-documents)
127
128
  - [Example: Storing language in a field](#example-storing-language-in-a-field)
@@ -2111,6 +2112,32 @@ Image transform can have per-path instructions, just like any other target paths
2111
2112
 
2112
2113
  - `target: [{path: ['image', 'asset'], instruction: 'Make the sky blue' }`
2113
2114
 
2115
+ ##### Image descriptions
2116
+
2117
+ ## Image description
2118
+
2119
+ Images can be transformed to a textual description by targeting a `string`, `text` or Portable Text field (`array` with `block`)
2120
+ with `operation: {type: 'image-description'}`.
2121
+
2122
+ Custom instructions for image description targets will be used to generate the description.
2123
+
2124
+ ###### Targeting image fields
2125
+ If a target is a descendant field of an image object, no `sourcePath` is required in the operation:
2126
+
2127
+ For example:
2128
+ - `target: {path: ['image', 'description'], operation: {type: 'image-description'} }`
2129
+ - `target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image`
2130
+ - `target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }`
2131
+
2132
+ ###### Targeting non-image fields
2133
+ If the target image description lives outside an image object, use the `sourcePath` option to specify the path to the image field.
2134
+ `sourcePath` must be an image or image asset field.
2135
+
2136
+ For example:
2137
+ - `target: {path: ['description'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }`
2138
+ - `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
2139
+ - `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
2140
+
2114
2141
  ##### Example: Field-based transformation
2115
2142
 
2116
2143
  ```ts
@@ -1459,11 +1459,17 @@ class LiveClient {
1459
1459
  }
1460
1460
  return event;
1461
1461
  })
1462
- ), checkCors = fetchObservable(url, {
1462
+ );
1463
+ console.log("YES THIS IS THE CORS VERSION");
1464
+ const checkCors = fetchObservable(url, {
1463
1465
  method: "OPTIONS",
1464
1466
  mode: "cors",
1465
1467
  credentials: esOptions.withCredentials ? "include" : "omit",
1466
- headers: esOptions.headers
1468
+ headers: {
1469
+ ...esOptions.headers,
1470
+ "Access-Control-Request-Headers": "authorization"
1471
+ // for this preflight check, ensure we send what the browser would send if needed
1472
+ }
1467
1473
  }).pipe(
1468
1474
  rxjs.mergeMap(() => rxjs.EMPTY),
1469
1475
  rxjs.catchError(() => {