@sanity/client 6.4.7-canary.0 → 6.4.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 +38 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -9
- package/src/types.ts +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ export async function updateDocumentTitle(_id, title) {
|
|
|
58
58
|
- [ESM](#esm)
|
|
59
59
|
- [CommonJS](#commonjs)
|
|
60
60
|
- [TypeScript](#typescript)
|
|
61
|
+
- [Next.js App Router](#nextjs-app-router)
|
|
61
62
|
- [Bun](#bun)
|
|
62
63
|
- [Deno](#deno)
|
|
63
64
|
- [Edge Runtime](#edge-runtime)
|
|
@@ -201,6 +202,43 @@ console.log(`Number of documents: ${data}`)
|
|
|
201
202
|
|
|
202
203
|
Another alternative is [groqd].
|
|
203
204
|
|
|
205
|
+
#### [Next.js App Router](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#fetching-data-on-the-server-with-fetch)
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
import {createClient} from '@sanity/client'
|
|
209
|
+
|
|
210
|
+
const client = createClient({
|
|
211
|
+
projectId: 'your-project-id',
|
|
212
|
+
dataset: 'your-dataset-name',
|
|
213
|
+
useCdn: true, // set to `false` to bypass the edge cache
|
|
214
|
+
apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
export default async function ReactServerComponent() {
|
|
218
|
+
const data = await client.fetch<number>(
|
|
219
|
+
`count(*[_type == "page"])`,
|
|
220
|
+
{},
|
|
221
|
+
{
|
|
222
|
+
// You can set any of the `cache` and `next` options as you would on a standard `fetch` call
|
|
223
|
+
cache: 'force-cache',
|
|
224
|
+
next: {tags: ['pages']},
|
|
225
|
+
},
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return <h1>Number of pages: {data}</h1>
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The `cache` and `next` options are documented in the [Next.js documentation](https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options).
|
|
233
|
+
Since [request memoization](https://nextjs.org/docs/app/building-your-application/caching#request-memoization) is supported it's unnecessary to use [the `React.cache`](https://nextjs.org/docs/app/building-your-application/caching#react-cache-function) API.
|
|
234
|
+
To [opt-out of memoization](https://nextjs.org/docs/app/building-your-application/caching#opting-out), set the `signal` property:
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
const {signal} = new AbortController()
|
|
238
|
+
// By passing `signal` this request will not be memoized and `now()` will execute for every React Server Component that runs this query
|
|
239
|
+
const data = await client.fetch<number>(`{"dynamic": now()}`, {}, {signal})
|
|
240
|
+
```
|
|
241
|
+
|
|
204
242
|
#### [Bun]
|
|
205
243
|
|
|
206
244
|
```bash
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ var getIt = require('get-it');
|
|
|
8
8
|
var rxjs = require('rxjs');
|
|
9
9
|
var operators = require('rxjs/operators');
|
|
10
10
|
var name = "@sanity/client";
|
|
11
|
-
var version = "6.4.
|
|
11
|
+
var version = "6.4.8";
|
|
12
12
|
const middleware = [middleware$1.debug({
|
|
13
13
|
verbose: true,
|
|
14
14
|
namespace: "sanity:client"
|
package/dist/index.d.ts
CHANGED
|
@@ -317,7 +317,7 @@ export declare interface ClientConfig {
|
|
|
317
317
|
*/
|
|
318
318
|
resultSourceMap?: boolean
|
|
319
319
|
/**
|
|
320
|
-
|
|
320
|
+
*@deprecated set `cache` and `next` options on `client.fetch` instead
|
|
321
321
|
*/
|
|
322
322
|
fetch?: RequestFetchOptions | boolean
|
|
323
323
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { adapter as unstable__adapter, environment as unstable__environment } fr
|
|
|
4
4
|
import { Observable, lastValueFrom } from 'rxjs';
|
|
5
5
|
import { map, filter } from 'rxjs/operators';
|
|
6
6
|
var name = "@sanity/client";
|
|
7
|
-
var version = "6.4.
|
|
7
|
+
var version = "6.4.8";
|
|
8
8
|
const middleware = [debug({
|
|
9
9
|
verbose: true,
|
|
10
10
|
namespace: "sanity:client"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.8",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -93,36 +93,36 @@
|
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@sanity/eventsource": "^5.0.0",
|
|
96
|
-
"get-it": "8.4.
|
|
96
|
+
"get-it": "^8.4.3",
|
|
97
97
|
"rxjs": "^7.0.0"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@edge-runtime/types": "^2.1.5",
|
|
101
101
|
"@edge-runtime/vm": "^3.0.4",
|
|
102
102
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
103
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
104
|
-
"@sanity/pkg-utils": "^2.4.
|
|
103
|
+
"@rollup/plugin-node-resolve": "^15.2.0",
|
|
104
|
+
"@sanity/pkg-utils": "^2.4.6",
|
|
105
105
|
"@sanity/semantic-release-preset": "^4.1.3",
|
|
106
106
|
"@types/node": "^20.5.0",
|
|
107
107
|
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
|
108
108
|
"@typescript-eslint/parser": "^6.4.0",
|
|
109
|
-
"@vitest/coverage-v8": "^0.34.
|
|
109
|
+
"@vitest/coverage-v8": "^0.34.2",
|
|
110
110
|
"eslint": "^8.47.0",
|
|
111
111
|
"eslint-config-prettier": "^9.0.0",
|
|
112
112
|
"eslint-plugin-prettier": "^5.0.0",
|
|
113
113
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
114
114
|
"faucet": "^0.0.4",
|
|
115
|
-
"happy-dom": "^10.
|
|
115
|
+
"happy-dom": "^10.10.2",
|
|
116
116
|
"ls-engines": "^0.9.0",
|
|
117
|
-
"nock": "^13.3.
|
|
118
|
-
"prettier": "^3.0.
|
|
117
|
+
"nock": "^13.3.3",
|
|
118
|
+
"prettier": "^3.0.2",
|
|
119
119
|
"prettier-plugin-packagejson": "^2.4.5",
|
|
120
120
|
"rimraf": "^5.0.1",
|
|
121
121
|
"rollup": "^3.28.0",
|
|
122
122
|
"sse-channel": "^4.0.0",
|
|
123
123
|
"terser": "^5.19.2",
|
|
124
124
|
"typescript": "^5.1.6",
|
|
125
|
-
"vitest": "^0.34.
|
|
125
|
+
"vitest": "^0.34.2",
|
|
126
126
|
"vitest-github-actions-reporter": "^0.10.0"
|
|
127
127
|
},
|
|
128
128
|
"engines": {
|
package/src/types.ts
CHANGED
|
@@ -86,7 +86,7 @@ export interface ClientConfig {
|
|
|
86
86
|
*/
|
|
87
87
|
resultSourceMap?: boolean
|
|
88
88
|
/**
|
|
89
|
-
|
|
89
|
+
*@deprecated set `cache` and `next` options on `client.fetch` instead
|
|
90
90
|
*/
|
|
91
91
|
fetch?: RequestFetchOptions | boolean
|
|
92
92
|
}
|