@sanity/client 6.15.7 → 6.15.8
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 +49 -5
- package/dist/_chunks-cjs/nodeMiddleware.cjs +1 -1
- package/dist/_chunks-es/nodeMiddleware.js +1 -1
- package/dist/index.browser.d.cts +3 -0
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/stega.browser.d.cts +3 -0
- package/dist/stega.browser.d.ts +3 -0
- package/dist/stega.d.cts +3 -0
- package/dist/stega.d.ts +3 -0
- package/package.json +8 -8
- package/src/types.ts +4 -0
package/README.md
CHANGED
|
@@ -65,11 +65,14 @@ export async function updateDocumentTitle(_id, title) {
|
|
|
65
65
|
- [Browser ESM CDN](#browser-esm-cdn)
|
|
66
66
|
- [UMD](#umd)
|
|
67
67
|
- [Specifying API version](#specifying-api-version)
|
|
68
|
+
- [Request tags](#request-tags)
|
|
68
69
|
- [Performing queries](#performing-queries)
|
|
69
70
|
- [Using perspectives](#using-perspectives)
|
|
70
71
|
- [`published`](#published)
|
|
71
72
|
- [`previewDrafts`](#previewdrafts)
|
|
72
73
|
- [Fetching Content Source Maps](#fetching-content-source-maps)
|
|
74
|
+
- [Using Visual editing with steganography](#using-visual-editing-with-steganography)
|
|
75
|
+
- [Creating Studio edit intent links](#creating-studio-edit-intent-links)
|
|
73
76
|
- [Listening to queries](#listening-to-queries)
|
|
74
77
|
- [Fetch a single document](#fetch-a-single-document)
|
|
75
78
|
- [Fetch multiple documents in one go](#fetch-multiple-documents-in-one-go)
|
|
@@ -94,13 +97,28 @@ export async function updateDocumentTitle(_id, title) {
|
|
|
94
97
|
- [Deleting an asset](#deleting-an-asset)
|
|
95
98
|
- [Mutation options](#mutation-options)
|
|
96
99
|
- [Aborting a request](#aborting-a-request)
|
|
100
|
+
- [1. Abort a request by passing an AbortSignal with the request options](#1-abort-a-request-by-passing-an-abortsignal-with-the-request-options)
|
|
101
|
+
- [2. Cancel a request by unsubscribing from the Observable](#2-cancel-a-request-by-unsubscribing-from-the-observable)
|
|
97
102
|
- [Get client configuration](#get-client-configuration)
|
|
98
103
|
- [Set client configuration](#set-client-configuration)
|
|
99
|
-
- [Release new version](#release-new-version)
|
|
100
104
|
- [License](#license)
|
|
101
|
-
- [
|
|
102
|
-
- [
|
|
103
|
-
|
|
105
|
+
- [From `v5`](#from-v5)
|
|
106
|
+
- [The default `useCdn` is changed to `true`](#the-default-usecdn-is-changed-to-true)
|
|
107
|
+
- [From `v4`](#from-v4)
|
|
108
|
+
- [No longer shipping `ES5`](#no-longer-shipping-es5)
|
|
109
|
+
- [Node.js `v12` no longer supported](#nodejs-v12-no-longer-supported)
|
|
110
|
+
- [The `default` export is replaced with the named export `createClient`](#the-default-export-is-replaced-with-the-named-export-createclient)
|
|
111
|
+
- [`client.assets.delete` is removed](#clientassetsdelete-is-removed)
|
|
112
|
+
- [`client.assets.getImageUrl` is removed, replace with `@sanity/image-url`](#clientassetsgetimageurl-is-removed-replace-with-sanityimage-url)
|
|
113
|
+
- [`SanityClient` static properties moved to named exports](#sanityclient-static-properties-moved-to-named-exports)
|
|
114
|
+
- [`client.clientConfig` is removed, replace with `client.config()`](#clientclientconfig-is-removed-replace-with-clientconfig)
|
|
115
|
+
- [`client.isPromiseAPI()` is removed, replace with an `instanceof` check](#clientispromiseapi-is-removed-replace-with-an-instanceof-check)
|
|
116
|
+
- [`client.observable.isObservableAPI()` is removed, replace with an `instanceof` check](#clientobservableisobservableapi-is-removed-replace-with-an-instanceof-check)
|
|
117
|
+
- [`client._requestObservable` is removed, replace with `client.observable.request`](#client_requestobservable-is-removed-replace-with-clientobservablerequest)
|
|
118
|
+
- [`client._dataRequest` is removed, replace with `client.dataRequest`](#client_datarequest-is-removed-replace-with-clientdatarequest)
|
|
119
|
+
- [`client._create_` is removed, replace with one of `client.create`, `client.createIfNotExists` or `client.createOrReplace`](#client_create_-is-removed-replace-with-one-of-clientcreate-clientcreateifnotexists-or-clientcreateorreplace)
|
|
120
|
+
- [`client.patch.replace` is removed, replace with `client.createOrReplace`](#clientpatchreplace-is-removed-replace-with-clientcreateorreplace)
|
|
121
|
+
- [`client.auth` is removed, replace with `client.request`](#clientauth-is-removed-replace-with-clientrequest)
|
|
104
122
|
|
|
105
123
|
## Requirements
|
|
106
124
|
|
|
@@ -428,6 +446,31 @@ In general, unless you know what API version you want to use, you'll want to sta
|
|
|
428
446
|
|
|
429
447
|
In future versions, specifying an API version will be required. For now (to maintain backwards compatiblity) not specifying a version will trigger a deprecation warning and fall back to using `v1`.
|
|
430
448
|
|
|
449
|
+
### Request tags
|
|
450
|
+
|
|
451
|
+
Request tags are values assigned to API and CDN requests that can be used to filter and aggregate log data within [request logs][request-logs] from your Sanity Content Lake.
|
|
452
|
+
|
|
453
|
+
Sanity Client has out-of-the-box support for tagging every API and CDN request on two levels:
|
|
454
|
+
|
|
455
|
+
- Globally: Using the `requestTagPrefix` client configuration parameter
|
|
456
|
+
- Per Request: Pass the tag option to the SDK’s Request method.
|
|
457
|
+
|
|
458
|
+
The following example will result in a query with `tag=website.landing-page`:
|
|
459
|
+
|
|
460
|
+
```ts
|
|
461
|
+
const client = createClient({
|
|
462
|
+
projectId: '<project>',
|
|
463
|
+
dataset: '<dataset>',
|
|
464
|
+
useCdn: true,
|
|
465
|
+
apiVersion: '2024-01-24',
|
|
466
|
+
requestTagPrefix: 'website', // Added to every request
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
const posts = await client.fetch('*[_type == "post"]', {
|
|
470
|
+
tag: `index-page`, // Appended to requestTagPrefix for this individual request
|
|
471
|
+
})
|
|
472
|
+
```
|
|
473
|
+
|
|
431
474
|
### Performing queries
|
|
432
475
|
|
|
433
476
|
```js
|
|
@@ -640,7 +683,7 @@ Enabling Content Source Maps is a two-step process:
|
|
|
640
683
|
console.log(resultSourceMap)
|
|
641
684
|
```
|
|
642
685
|
|
|
643
|
-
If your `apiVersion` is `2021-03-25` or later, the `resultSourceMap` property will always exist in the response after enabling it. If there is no source map, `resultSourceMap` is an empty object.
|
|
686
|
+
If your `apiVersion` is `2021-03-25` or later, the `resultSourceMap` property will always exist in the response after enabling it. If there is no source map, `resultSourceMap` is an empty object.
|
|
644
687
|
This is the corresponding TypeScript definition:
|
|
645
688
|
|
|
646
689
|
```ts
|
|
@@ -1608,3 +1651,4 @@ await client.request<void>({uri: '/auth/logout', method: 'POST'})
|
|
|
1608
1651
|
[visual-editing]: https://www.sanity.io/docs/vercel-visual-editing?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
|
|
1609
1652
|
[content-source-maps]: https://www.sanity.io/docs/content-source-maps?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
|
|
1610
1653
|
[content-source-maps-intro]: https://www.sanity.io/blog/content-source-maps-announce?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
|
|
1654
|
+
[request-logs]: https://www.sanity.io/docs/request-logs?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
|
|
@@ -1474,7 +1474,7 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
|
1474
1474
|
config
|
|
1475
1475
|
) };
|
|
1476
1476
|
}
|
|
1477
|
-
var name = "@sanity/client", version = "6.15.
|
|
1477
|
+
var name = "@sanity/client", version = "6.15.8";
|
|
1478
1478
|
const middleware = [
|
|
1479
1479
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1480
1480
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|
|
@@ -1455,7 +1455,7 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
|
|
|
1455
1455
|
config
|
|
1456
1456
|
) };
|
|
1457
1457
|
}
|
|
1458
|
-
var name = "@sanity/client", version = "6.15.
|
|
1458
|
+
var name = "@sanity/client", version = "6.15.8";
|
|
1459
1459
|
const middleware = [
|
|
1460
1460
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1461
1461
|
headers({ "User-Agent": `${name} ${version}` }),
|
package/dist/index.browser.d.cts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/index.d.cts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/index.d.ts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/stega.browser.d.cts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/stega.browser.d.ts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/stega.d.cts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/dist/stega.d.ts
CHANGED
|
@@ -293,6 +293,9 @@ export declare interface ClientConfig {
|
|
|
293
293
|
apiHost?: string
|
|
294
294
|
apiVersion?: string
|
|
295
295
|
proxy?: string
|
|
296
|
+
/**
|
|
297
|
+
* Optional request tag prefix for all request tags
|
|
298
|
+
*/
|
|
296
299
|
requestTagPrefix?: string
|
|
297
300
|
ignoreBrowserTokenWarning?: boolean
|
|
298
301
|
withCredentials?: boolean
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.15.
|
|
3
|
+
"version": "6.15.8",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"dependencies": {
|
|
123
123
|
"@sanity/eventsource": "^5.0.0",
|
|
124
124
|
"@vercel/stega": "0.1.0",
|
|
125
|
-
"get-it": "^8.4.
|
|
125
|
+
"get-it": "^8.4.17",
|
|
126
126
|
"rxjs": "^7.0.0"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
@@ -130,11 +130,11 @@
|
|
|
130
130
|
"@edge-runtime/vm": "^3.2.0",
|
|
131
131
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
132
132
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
133
|
-
"@sanity/pkg-utils": "^5.1.
|
|
133
|
+
"@sanity/pkg-utils": "^5.1.6",
|
|
134
134
|
"@types/json-diff": "^1.0.3",
|
|
135
135
|
"@types/node": "^20.8.8",
|
|
136
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
137
|
-
"@typescript-eslint/parser": "^7.
|
|
136
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
137
|
+
"@typescript-eslint/parser": "^7.5.0",
|
|
138
138
|
"@vitest/coverage-v8": "1.4.0",
|
|
139
139
|
"eslint": "^8.57.0",
|
|
140
140
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -147,11 +147,11 @@
|
|
|
147
147
|
"next": "^14.1.4",
|
|
148
148
|
"nock": "^13.5.4",
|
|
149
149
|
"prettier": "^3.2.5",
|
|
150
|
-
"prettier-plugin-packagejson": "^2.4.
|
|
150
|
+
"prettier-plugin-packagejson": "^2.4.14",
|
|
151
151
|
"rimraf": "^5.0.1",
|
|
152
|
-
"rollup": "^4.13.
|
|
152
|
+
"rollup": "^4.13.2",
|
|
153
153
|
"sse-channel": "^4.0.0",
|
|
154
|
-
"terser": "^5.
|
|
154
|
+
"terser": "^5.30.1",
|
|
155
155
|
"typescript": "5.4.2",
|
|
156
156
|
"vitest": "1.4.0",
|
|
157
157
|
"vitest-github-actions-reporter": "0.11.1"
|
package/src/types.ts
CHANGED
|
@@ -45,6 +45,10 @@ export interface ClientConfig {
|
|
|
45
45
|
apiHost?: string
|
|
46
46
|
apiVersion?: string
|
|
47
47
|
proxy?: string
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Optional request tag prefix for all request tags
|
|
51
|
+
*/
|
|
48
52
|
requestTagPrefix?: string
|
|
49
53
|
ignoreBrowserTokenWarning?: boolean
|
|
50
54
|
withCredentials?: boolean
|