@sanity/client 5.4.3-dev.3 → 6.0.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 CHANGED
@@ -27,7 +27,7 @@ export const client = createClient({
27
27
  projectId: 'your-project-id',
28
28
  dataset: 'your-dataset-name',
29
29
  useCdn: true, // set to `false` to bypass the edge cache
30
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
30
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
31
31
  // token: process.env.SANITY_SECRET_TOKEN // Only if you want to update content with the client
32
32
  })
33
33
 
@@ -65,7 +65,6 @@ export async function updateDocumentTitle(_id, title) {
65
65
  - [UMD](#umd)
66
66
  - [Specifying API version](#specifying-api-version)
67
67
  - [Performing queries](#performing-queries)
68
- - [Get started with Content Source Maps](#get-started-with-content-source-maps)
69
68
  - [Listening to queries](#listening-to-queries)
70
69
  - [Fetch a single document](#fetch-a-single-document)
71
70
  - [Fetch multiple documents in one go](#fetch-multiple-documents-in-one-go)
@@ -133,7 +132,7 @@ const client = createClient({
133
132
  projectId: 'your-project-id',
134
133
  dataset: 'your-dataset-name',
135
134
  useCdn: true, // set to `false` to bypass the edge cache
136
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
135
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
137
136
  })
138
137
 
139
138
  const data = await client.fetch(`count(*)`)
@@ -149,7 +148,7 @@ const client = createClient({
149
148
  projectId: 'your-project-id',
150
149
  dataset: 'your-dataset-name',
151
150
  useCdn: true, // set to `false` to bypass the edge cache
152
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
151
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
153
152
  })
154
153
 
155
154
  client
@@ -167,7 +166,7 @@ const config: ClientConfig = {
167
166
  projectId: 'your-project-id',
168
167
  dataset: 'your-dataset-name',
169
168
  useCdn: true, // set to `false` to bypass the edge cache
170
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
169
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
171
170
  }
172
171
  const client = createClient(config)
173
172
 
@@ -187,7 +186,7 @@ const client = createClient({
187
186
  projectId: 'your-project-id',
188
187
  dataset: 'your-dataset-name',
189
188
  useCdn: true, // set to `false` to bypass the edge cache
190
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
189
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
191
190
  })
192
191
 
193
192
  const schema = z.number()
@@ -214,7 +213,7 @@ const client = createClient({
214
213
  projectId: 'your-project-id',
215
214
  dataset: 'your-dataset-name',
216
215
  useCdn: true, // set to `false` to bypass the edge cache
217
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
216
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
218
217
  })
219
218
 
220
219
  const data = await client.fetch<number>(`count(*)`)
@@ -242,7 +241,7 @@ const client = createClient({
242
241
  projectId: 'your-project-id',
243
242
  dataset: 'your-dataset-name',
244
243
  useCdn: true, // set to `false` to bypass the edge cache
245
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
244
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
246
245
  })
247
246
 
248
247
  const data = await client.fetch<number>(`count(*)`)
@@ -275,7 +274,7 @@ export default async function handler(req: NextRequest) {
275
274
  projectId: 'your-project-id',
276
275
  dataset: 'your-dataset-name',
277
276
  useCdn: true, // set to `false` to bypass the edge cache
278
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
277
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
279
278
  })
280
279
 
281
280
  const count = await client.fetch<number>(`count(*)`)
@@ -306,7 +305,7 @@ Using [esm.sh] you can either load the client using a `<script type="module">` t
306
305
  projectId: 'your-project-id',
307
306
  dataset: 'your-dataset-name',
308
307
  useCdn: true, // set to `false` to bypass the edge cache
309
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
308
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
310
309
  })
311
310
 
312
311
  const data = await client.fetch(`count(*)`)
@@ -325,7 +324,7 @@ const client = createClient({
325
324
  projectId: 'your-project-id',
326
325
  dataset: 'your-dataset-name',
327
326
  useCdn: true, // set to `false` to bypass the edge cache
328
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
327
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
329
328
  })
330
329
 
331
330
  const data = await client.fetch(`count(*)`)
@@ -347,7 +346,7 @@ Loading the UMD script creates a `SanityClient` global that have the same export
347
346
  projectId: 'your-project-id',
348
347
  dataset: 'your-dataset-name',
349
348
  useCdn: true, // set to `false` to bypass the edge cache
350
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
349
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
351
350
  })
352
351
 
353
352
  client.fetch(`count(*)`).then((data) => console.log(`Number of documents: ${data}`))
@@ -368,7 +367,7 @@ The `require-unpkg` library lets you consume `npm` packages from `unpkg.com` sim
368
367
  projectId: 'your-project-id',
369
368
  dataset: 'your-dataset-name',
370
369
  useCdn: true, // set to `false` to bypass the edge cache
371
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
370
+ apiVersion: '2022-01-12', // use current date (YYYY-MM-DD) to target the latest API version
372
371
  })
373
372
 
374
373
  const data = await client.fetch(`count(*)`)
@@ -405,58 +404,6 @@ client.fetch(query, params).then((bikes) => {
405
404
 
406
405
  Perform a query using the given parameters (if any).
407
406
 
408
- ### Get started with Content Source Maps
409
-
410
- > **Note**
411
- >
412
- > [Content Source Maps][content-source-maps-intro] are available [as an API][content-source-maps] for select [Sanity enterprise customers][enterprise-cta]. [Contact our sales team for more information.][sales-cta]
413
-
414
- [Visual editing][visual-editing] is available in [`@sanity/preview-kit/client`][preview-kit-client]. It offers both a turn-key solution and a flexible API for custom experiences.
415
-
416
- This guide is for developers who want to build custom use cases beyond, or in addition to, [visual editing][visual-editing]. Read the [Content Source Maps introduction][content-source-maps-intro] before diving in, and keep the [Content Source Maps reference][content-source-maps] handy.
417
-
418
- Enabling Content Source Maps is a two-step process:
419
-
420
- 1. Update your client configuration with `resultSourceMap`.
421
-
422
- ```js
423
- import {createClient} from '@sanity/client'
424
-
425
- const client = createClient({
426
- projectId: 'your-project-id',
427
- dataset: 'your-dataset-name',
428
- useCdn: true, // set to `false` to bypass the edge cache
429
- apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
430
- resultSourceMap: true, // tells the API to start sending source maps, if available
431
- })
432
- ```
433
-
434
- 2. On `client.fetch` calls add `{filterResponse: false}` to return the full response on queries.
435
-
436
- ```js
437
- // Before
438
- // const result = await client.fetch(query, params)
439
-
440
- // After adding `filterResponse: false`
441
- const {result, resultSourceMap} = await client.fetch(query, params, {filterResponse: false})
442
- // Build something cool with the source map
443
- console.log(resultSourceMap)
444
- ```
445
-
446
- Once enabled, the `resultSourceMap` property will always exist on the response, given your `apiVersion` is recent enough. If there is no source map, it will be an empty object. There's also a TypeScript definition for it:
447
-
448
- ```ts
449
- import type {ContentSourceMapping} from '@sanity/client'
450
-
451
- const {result, resultSourceMap} = await client.fetch(query, params, {filterResponse: false})
452
-
453
- function useContentSourceMap(resultSourceMap: ContentSourceMapping): unknown {
454
- // Sky's the limit
455
- }
456
-
457
- useContentSourceMap(resultSourceMap)
458
- ```
459
-
460
407
  ### Listening to queries
461
408
 
462
409
  ```js
@@ -1295,9 +1242,3 @@ await client.request<void>({uri: '/auth/logout', method: 'POST'})
1295
1242
  [groqd]: https://github.com/FormidableLabs/groqd#readme
1296
1243
  [AbortSignal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
1297
1244
  [AbortController]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
1298
- [visual-editing]: https://www.sanity.io/docs/vercel-visual-editing?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
1299
- [content-source-maps]: https://www.sanity.io/docs/content-source-maps?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
1300
- [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
1301
- [preview-kit-client]: https://github.com/sanity-io/preview-kit#sanitypreview-kitclient
1302
- [sales-cta]: https://www.sanity.io/contact/sales?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
1303
- [enterprise-cta]: https://www.sanity.io/enterprise?utm_source=github.com&utm_medium=referral&utm_campaign=may-vercel-launch
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 = "5.4.3-dev.3";
11
+ var version = "6.0.0";
12
12
  const middleware = [middleware$1.debug({
13
13
  verbose: true,
14
14
  namespace: "sanity:client"
package/dist/index.d.ts CHANGED
@@ -331,13 +331,14 @@ export declare interface ContentSourceMap {
331
331
 
332
332
  /** @public */
333
333
  export declare interface ContentSourceMapDocument {
334
- _projectId: string
335
- _dataset: string
336
334
  _id: string
337
335
  }
338
336
 
339
337
  /** @public */
340
- export declare type ContentSourceMapDocuments = ContentSourceMapDocument[]
338
+ export declare type ContentSourceMapDocuments = (
339
+ | ContentSourceMapDocument
340
+ | ContentSourceMapRemoteDocument
341
+ )[]
341
342
 
342
343
  /**
343
344
  * DocumentValueSource is a path to a value within a document
@@ -366,6 +367,12 @@ export declare type ContentSourceMapMappings = Record<string, ContentSourceMapMa
366
367
  /** @public */
367
368
  export declare type ContentSourceMapPaths = string[]
368
369
 
370
+ /** @public */
371
+ export declare interface ContentSourceMapRemoteDocument extends ContentSourceMapDocument {
372
+ _projectId: string
373
+ _dataset: string
374
+ }
375
+
369
376
  /** @public */
370
377
  export declare type ContentSourceMapSource =
371
378
  | ContentSourceMapDocumentValueSource
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 = "5.4.3-dev.3";
7
+ var version = "6.0.0";
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": "5.4.3-dev.3",
3
+ "version": "6.0.0",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -1,11 +1,7 @@
1
1
  // deno-lint-ignore-file no-empty-interface
2
- // eslint-disable-next-line no-warning-comments
3
- // @TODO the types in this file should be split into their own files, that's why the file is named `_legacy`
4
2
 
5
3
  import type {Requester} from 'get-it'
6
4
 
7
- import type {ContentSourceMap} from './resultSourceMap'
8
-
9
5
  /**
10
6
  * Used to tag types that is set to `any` as a temporary measure, but should be replaced with proper typings in the future
11
7
  * @internal
@@ -623,3 +619,76 @@ export interface MutationErrorItem {
623
619
  value?: unknown
624
620
  }
625
621
  }
622
+
623
+ /**
624
+ * DocumentValueSource is a path to a value within a document
625
+ * @public
626
+ */
627
+ export interface ContentSourceMapDocumentValueSource {
628
+ type: 'documentValue'
629
+ // index location of the document
630
+ document: number
631
+ // index location of the path
632
+ path: number
633
+ }
634
+ /**
635
+ * When a value is not from a source, its a literal
636
+ * @public
637
+ */
638
+ export interface ContentSourceMapLiteralSource {
639
+ type: 'literal'
640
+ }
641
+ /**
642
+ * When a field source is unknown
643
+ * @public
644
+ */
645
+ export interface ContentSourceMapUnknownSource {
646
+ type: 'unknown'
647
+ }
648
+ /** @public */
649
+ export type ContentSourceMapSource =
650
+ | ContentSourceMapDocumentValueSource
651
+ | ContentSourceMapLiteralSource
652
+ | ContentSourceMapUnknownSource
653
+ /**
654
+ * ValueMapping is a mapping when for value that is from a single source value
655
+ * It may refer to a field within a document or a literal value
656
+ * @public
657
+ */
658
+ export interface ContentSourceMapValueMapping {
659
+ type: 'value'
660
+ // source of the value
661
+ source: ContentSourceMapSource
662
+ }
663
+ /** @public */
664
+ export type ContentSourceMapMapping = ContentSourceMapValueMapping
665
+
666
+ /** @public */
667
+ export type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
668
+
669
+ /** @public */
670
+ export interface ContentSourceMapDocument {
671
+ _id: string
672
+ }
673
+
674
+ /** @public */
675
+ export interface ContentSourceMapRemoteDocument extends ContentSourceMapDocument {
676
+ _projectId: string
677
+ _dataset: string
678
+ }
679
+
680
+ /** @public */
681
+ export type ContentSourceMapDocuments = (
682
+ | ContentSourceMapDocument
683
+ | ContentSourceMapRemoteDocument
684
+ )[]
685
+
686
+ /** @public */
687
+ export type ContentSourceMapPaths = string[]
688
+
689
+ /** @public */
690
+ export interface ContentSourceMap {
691
+ mappings: ContentSourceMapMappings
692
+ documents: ContentSourceMapDocuments
693
+ paths: ContentSourceMapPaths
694
+ }
@@ -1,2 +0,0 @@
1
- export type * from './_legacy'
2
- export type * from './resultSourceMap'
@@ -1,65 +0,0 @@
1
- /**
2
- * DocumentValueSource is a path to a value within a document
3
- * @public
4
- */
5
- export interface ContentSourceMapDocumentValueSource {
6
- type: 'documentValue'
7
- // index location of the document
8
- document: number
9
- // index location of the path
10
- path: number
11
- }
12
- /**
13
- * When a value is not from a source, its a literal
14
- * @public
15
- */
16
- export interface ContentSourceMapLiteralSource {
17
- type: 'literal'
18
- }
19
- /**
20
- * When a field source is unknown
21
- * @public
22
- */
23
- export interface ContentSourceMapUnknownSource {
24
- type: 'unknown'
25
- }
26
- /** @public */
27
- export type ContentSourceMapSource =
28
- | ContentSourceMapDocumentValueSource
29
- | ContentSourceMapLiteralSource
30
- | ContentSourceMapUnknownSource
31
- /**
32
- * ValueMapping is a mapping when for value that is from a single source value
33
- * It may refer to a field within a document or a literal value
34
- * @public
35
- */
36
- export interface ContentSourceMapValueMapping {
37
- type: 'value'
38
- // source of the value
39
- source: ContentSourceMapSource
40
- }
41
- /** @public */
42
- export type ContentSourceMapMapping = ContentSourceMapValueMapping
43
-
44
- /** @public */
45
- export type ContentSourceMapMappings = Record<string, ContentSourceMapMapping>
46
-
47
- /** @public */
48
- export interface ContentSourceMapDocument {
49
- _projectId: string
50
- _dataset: string
51
- _id: string
52
- }
53
-
54
- /** @public */
55
- export type ContentSourceMapDocuments = ContentSourceMapDocument[]
56
-
57
- /** @public */
58
- export type ContentSourceMapPaths = string[]
59
-
60
- /** @public */
61
- export interface ContentSourceMap {
62
- mappings: ContentSourceMapMappings
63
- documents: ContentSourceMapDocuments
64
- paths: ContentSourceMapPaths
65
- }