@sanity/client 3.3.0 → 4.0.0-alpha.esm.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
@@ -19,8 +19,8 @@ npm install -g @sanity/client
19
19
  ## API
20
20
 
21
21
  ```js
22
- const sanityClient = require('@sanity/client')
23
- const client = sanityClient({
22
+ import {createClient} from '@sanity/client'
23
+ const client = createClient({
24
24
  projectId: 'your-project-id',
25
25
  dataset: 'bikeshop',
26
26
  apiVersion: '2021-03-25', // use current UTC date - see "specifying API version"!
@@ -29,7 +29,7 @@ const client = sanityClient({
29
29
  })
30
30
  ```
31
31
 
32
- `const client = sanityClient(options)`
32
+ `const client = createClient(options)`
33
33
 
34
34
  Initializes a new Sanity Client. Required options are `projectId`, `dataset`, and `apiVersion`. Setting a value for `useCdn` is encouraged.
35
35
 
@@ -260,7 +260,7 @@ client
260
260
  The operations of appending and prepending to an array are so common that they have been given their own methods for better readability:
261
261
 
262
262
  ```js
263
- const {nanoid} = require('nanoid')
263
+ import {nanoid} from 'nanoid'
264
264
 
265
265
  client
266
266
  .patch('bike-123')
@@ -372,27 +372,27 @@ A `patch` can be performed inline on a `transaction`.
372
372
  Transactions and patches can also be built outside the scope of a client:
373
373
 
374
374
  ```js
375
- const sanityClient = require('@sanity/client')
376
- const client = sanityClient({
375
+ import {SanityClient} from '@sanity/client'
376
+ const client = new SanityClient({
377
377
  projectId: 'your-project-id',
378
378
  dataset: 'bikeshop',
379
379
  })
380
380
 
381
381
  // Patches:
382
- const patch = new sanityClient.Patch('<documentId>')
382
+ const patch = new SanityClient.Patch('<documentId>')
383
383
  client.mutate(patch.inc({count: 1}).unset(['visits']))
384
384
 
385
385
  // Transactions:
386
- const transaction = new sanityClient.Transaction()
386
+ const transaction = new SanityClient.Transaction()
387
387
  .create({_id: '123', name: 'FooBike'})
388
388
  .delete('someDocId')
389
389
 
390
390
  client.mutate(transaction)
391
391
  ```
392
392
 
393
- `const patch = new sanityClient.Patch(docId)`
393
+ `const patch = new SanityClient.Patch(docId)`
394
394
 
395
- `const transaction = new sanityClient.Transaction()`
395
+ `const transaction = new SanityClient.Transaction()`
396
396
 
397
397
  An important note on this approach is that you cannot call `commit()` on transactions or patches instantiated this way, instead you have to pass them to `client.mutate()`
398
398