@sanity/client 5.0.0-esm.3 → 5.0.0-esm.4

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
@@ -1,26 +1,93 @@
1
- # @sanity/client
1
+ # @sanity/client<!-- omit in toc -->
2
2
 
3
+ [![npm stat](https://img.shields.io/npm/dm/@sanity/client.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@sanity/client)
3
4
  [![npm version](https://img.shields.io/npm/v/@sanity/client.svg?style=flat-square)](https://www.npmjs.com/package/@sanity/client)
4
-
5
- Javascript client for Sanity. Works in node.js and modern browsers (older browsers need a [Promise polyfill](https://www.sanity.io/help/js-client-promise-polyfill)).
5
+ [![gzip size][gzip-badge]][unpkg-dist]
6
+ [![size][size-badge]][unpkg-dist]
7
+
8
+ Javascript client for Sanity. Works in [Node.js](https://nodejs.org/en/), [Bun], [Deno], [Edge Runtime] and [modern browsers].
9
+
10
+ ## Table of contents<!-- omit in toc -->
11
+
12
+ - [Requirements](#requirements)
13
+ - [Installation](#installation)
14
+ - [API](#api)
15
+ - [Creating a client instance](#creating-a-client-instance)
16
+ - [ESM](#esm)
17
+ - [CommonJS](#commonjs)
18
+ - [TypeScript](#typescript)
19
+ - [Bun](#bun)
20
+ - [Specifying API version](#specifying-api-version)
21
+ - [Performing queries](#performing-queries)
22
+ - [Listening to queries](#listening-to-queries)
23
+ - [Fetch a single document](#fetch-a-single-document)
24
+ - [Fetch multiple documents in one go](#fetch-multiple-documents-in-one-go)
25
+ - [Creating documents](#creating-documents)
26
+ - [Creating/replacing documents](#creatingreplacing-documents)
27
+ - [Creating if not already present](#creating-if-not-already-present)
28
+ - [Patch/update a document](#patchupdate-a-document)
29
+ - [Setting a field only if not already present](#setting-a-field-only-if-not-already-present)
30
+ - [Removing/unsetting fields](#removingunsetting-fields)
31
+ - [Incrementing/decrementing numbers](#incrementingdecrementing-numbers)
32
+ - [Patch a document only if revision matches](#patch-a-document-only-if-revision-matches)
33
+ - [Adding elements to an array](#adding-elements-to-an-array)
34
+ - [Appending/prepending elements to an array](#appendingprepending-elements-to-an-array)
35
+ - [Deleting an element from an array](#deleting-an-element-from-an-array)
36
+ - [Delete documents](#delete-documents)
37
+ - [Multiple mutations in a transaction](#multiple-mutations-in-a-transaction)
38
+ - [Clientless patches \& transactions](#clientless-patches--transactions)
39
+ - [Uploading assets](#uploading-assets)
40
+ - [Examples: Uploading assets from Node.js](#examples-uploading-assets-from-nodejs)
41
+ - [Examples: Uploading assets from the Browser](#examples-uploading-assets-from-the-browser)
42
+ - [Examples: Specify image metadata to extract](#examples-specify-image-metadata-to-extract)
43
+ - [Deleting an asset](#deleting-an-asset)
44
+ - [Mutation options](#mutation-options)
45
+ - [Get client configuration](#get-client-configuration)
46
+ - [Set client configuration](#set-client-configuration)
47
+ - [Migrate](#migrate)
48
+ - [From `v4`](#from-v4)
49
+ - [No longer shipping `ES5`](#no-longer-shipping-es5)
50
+ - [Node.js `v12` no longer supported](#nodejs-v12-no-longer-supported)
51
+ - [The `default` export is replaced with the named export `createClient`](#the-default-export-is-replaced-with-the-named-export-createclient)
52
+ - [`client.assets.delete` is removed](#clientassetsdelete-is-removed)
53
+ - [`client.assets.getImageUrl` is removed, replace with `@sanity/image-url`](#clientassetsgetimageurl-is-removed-replace-with-sanityimage-url)
54
+ - [`SanityClient` static properties moved to named exports](#sanityclient-static-properties-moved-to-named-exports)
55
+ - [`client.clientConfig` is removed, replace with `client.config()`](#clientclientconfig-is-removed-replace-with-clientconfig)
56
+ - [`client.getUrl()` is removed](#clientgeturl-is-removed)
57
+ - [`client.getDataUrl()` is removed](#clientgetdataurl-is-removed)
58
+ - [`client.isPromiseAPI()` is removed, replace with `instanceof` check](#clientispromiseapi-is-removed-replace-with-instanceof-check)
59
+ - [`client.observable.isObservableAPI()` is removed, replace with `instanceof` check](#clientobservableisobservableapi-is-removed-replace-with-instanceof-check)
60
+ - [`client._requestObservable` is removed, replace with `client.observable.request`](#client_requestobservable-is-removed-replace-with-clientobservablerequest)
61
+ - [`client._dataRequest` is removed, replace with `client.dataRequest`](#client_datarequest-is-removed-replace-with-clientdatarequest)
62
+ - [`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)
63
+ - [Release new version](#release-new-version)
64
+ - [License](#license)
6
65
 
7
66
  ## Requirements
8
67
 
9
- Sanity Client requires the JavaScript runtime to have a global ES6-compliant `Promise` available. If your runtime environment doesn't provide a spec compliant `Promise` implementation, we recommend using [native-promise-only](https://www.npmjs.com/package/native-promise-only), [es6-promise](https://www.npmjs.com/package/es6-promise) or another [spec-compliant](https://promisesaplus.com/implementations) implementation. See [this article](https://www.sanity.io/help/js-client-promise-polyfill) for more information.
68
+ Sanity Client transpiles syntax for [modern browsers]. The JavaScript runtime must support ES6 features such as [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes), [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters), [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) and more. For ES5 environments you'll need to transpile `@sanity/client` and its `dependencies` with your own bundler, and have a global ES6-compliant `Promise` available. If your runtime environment doesn't provide a spec compliant `Promise` implementation, we recommend using [native-promise-only](https://www.npmjs.com/package/native-promise-only), [es6-promise](https://www.npmjs.com/package/es6-promise) or another [spec-compliant](https://promisesaplus.com/implementations) implementation. See [this article](https://www.sanity.io/help/js-client-promise-polyfill) for more information.
10
69
 
11
70
  ## Installation
12
71
 
13
72
  The client can be installed from npm:
14
73
 
15
74
  ```
16
- npm install -g @sanity/client
75
+ npm install @sanity/client
17
76
  ```
18
77
 
19
78
  ## API
20
79
 
80
+ ### Creating a client instance
81
+
82
+ `const client = createClient(options)`
83
+
84
+ Initializes a new Sanity Client. Required options are `projectId`, `dataset`, and `apiVersion`. Setting a value for `useCdn` is encouraged.
85
+
86
+ #### [ESM](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/)
87
+
21
88
  ```js
22
- const sanityClient = require('@sanity/client')
23
- const client = sanityClient({
89
+ import {createClient} from '@sanity/client'
90
+ const client = createClient({
24
91
  projectId: 'your-project-id',
25
92
  dataset: 'bikeshop',
26
93
  apiVersion: '2021-03-25', // use current UTC date - see "specifying API version"!
@@ -31,9 +98,56 @@ const client = sanityClient({
31
98
  export default client
32
99
  ```
33
100
 
34
- `const client = sanityClient(options)`
101
+ #### [CommonJS](https://nodejs.org/api/modules.html#modules-commonjs-modules)
35
102
 
36
- Initializes a new Sanity Client. Required options are `projectId`, `dataset`, and `apiVersion`. Setting a value for `useCdn` is encouraged.
103
+ ```js
104
+ const {createClient} = require('@sanity/client')
105
+ const client = createClient({
106
+ projectId: 'your-project-id',
107
+ dataset: 'bikeshop',
108
+ apiVersion: '2021-03-25', // use current UTC date - see "specifying API version"!
109
+ token: 'sanity-auth-token', // or leave blank for unauthenticated usage
110
+ useCdn: true, // `false` if you want to ensure fresh data
111
+ })
112
+
113
+ module.exports = client
114
+ ```
115
+
116
+ #### [TypeScript](https://www.typescriptlang.org/)
117
+
118
+ ```ts
119
+ import {createClient, type ClientConfig} from '@sanity/client'
120
+
121
+ const client: ClientConfig = {
122
+ projectId: 'your-project-id',
123
+ dataset: 'bikeshop',
124
+ apiVersion: '2021-03-25', // use current UTC date - see "specifying API version"!
125
+ token: 'sanity-auth-token', // or leave blank for unauthenticated usage
126
+ useCdn: true, // `false` if you want to ensure fresh data
127
+ }
128
+
129
+ export default createClient(config)
130
+ ```
131
+
132
+ #### [Bun]
133
+
134
+ ```bash
135
+ bun
136
+ ```
137
+
138
+ ```ts
139
+ import {createClient, type ClientConfig} from '@sanity/client'
140
+
141
+ const client: ClientConfig = {
142
+ projectId: 'your-project-id',
143
+ dataset: 'bikeshop',
144
+ apiVersion: '2021-03-25', // use current UTC date - see "specifying API version"!
145
+ token: 'sanity-auth-token', // or leave blank for unauthenticated usage
146
+ useCdn: true, // `false` if you want to ensure fresh data
147
+ }
148
+
149
+ export default createClient(config)
150
+ ```
37
151
 
38
152
  ### Specifying API version
39
153
 
@@ -372,27 +486,25 @@ A `patch` can be performed inline on a `transaction`.
372
486
  Transactions and patches can also be built outside the scope of a client:
373
487
 
374
488
  ```js
375
- const sanityClient = require('@sanity/client')
376
- const client = sanityClient({
489
+ import {createClient, Patch, Transaction} from '@sanity/client'
490
+ const client = createClient({
377
491
  projectId: 'your-project-id',
378
492
  dataset: 'bikeshop',
379
493
  })
380
494
 
381
495
  // Patches:
382
- const patch = new sanityClient.Patch('<documentId>')
496
+ const patch = new Patch('<documentId>')
383
497
  client.mutate(patch.inc({count: 1}).unset(['visits']))
384
498
 
385
499
  // Transactions:
386
- const transaction = new sanityClient.Transaction()
387
- .create({_id: '123', name: 'FooBike'})
388
- .delete('someDocId')
500
+ const transaction = new Transaction().create({_id: '123', name: 'FooBike'}).delete('someDocId')
389
501
 
390
502
  client.mutate(transaction)
391
503
  ```
392
504
 
393
- `const patch = new sanityClient.Patch(docId)`
505
+ `const patch = new Patch(docId)`
394
506
 
395
- `const transaction = new sanityClient.Transaction()`
507
+ `const transaction = new Transaction()`
396
508
 
397
509
  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
510
 
@@ -531,6 +643,311 @@ client.config({dataset: 'newDataset'})
531
643
 
532
644
  Set client configuration. Required options are `projectId` and `dataset`.
533
645
 
646
+ ## Migrate
647
+
648
+ ### From `v4`
649
+
650
+ #### No longer shipping `ES5`
651
+
652
+ The target is changed to [modern browsers] that supports `ES6` `class`, `{...rest}` syntax and more. You may need to update your bundler to a recent major version. Or you could configure your bundler to transpile `@sanity/client`, and `get-it`, which is the engine that powers `@sanity/client` and uses the same output target.
653
+
654
+ ---
655
+
656
+ #### Node.js `v12` no longer supported
657
+
658
+ Upgrade to the [LTS release, or one of the Maintenance releases](https://github.com/nodejs/release#release-schedule).
659
+
660
+ ---
661
+
662
+ #### The `default` export is replaced with the named export `createClient`
663
+
664
+ Before:
665
+
666
+ ```ts
667
+ import createClient from '@sanity/client'
668
+ const client = createClient()
669
+ ```
670
+
671
+ ```ts
672
+ import SanityClient from '@sanity/client'
673
+ const client = new SanityClient()
674
+ ```
675
+
676
+ After:
677
+
678
+ ```ts
679
+ import {createClient} from '@sanity/client'
680
+ const client = createClient()
681
+ ```
682
+
683
+ ---
684
+
685
+ #### `client.assets.delete` is removed
686
+
687
+ Before:
688
+
689
+ ```ts
690
+ client.assets.delete('image', 'abc123_foobar-123x123-png')
691
+ client.assets.delete('image', 'image-abc123_foobar-123x123-png')
692
+ client.assets.delete({_id: 'image-abc123_foobar-123x123-png'})
693
+ ```
694
+
695
+ After:
696
+
697
+ ```ts
698
+ client.delete('image-abc123_foobar-123x123-png')
699
+ ```
700
+
701
+ ---
702
+
703
+ #### `client.assets.getImageUrl` is removed, replace with [`@sanity/image-url`](https://github.com/sanity-io/image-url)
704
+
705
+ Before:
706
+
707
+ ```ts
708
+ import {createClient} from '@sanity/client'
709
+ const client = createClient({projectId: 'abc123', dataset: 'foo'})
710
+
711
+ client.assets.getImageUrl('image-abc123_foobar-123x123-png')
712
+ client.assets.getImageUrl('image-abc123_foobar-123x123-png', {auto: 'format'})
713
+ client.assets.getImageUrl({_ref: 'image-abc123_foobar-123x123-png'})
714
+ client.assets.getImageUrl({_ref: 'image-abc123_foobar-123x123-png'}, {auto: 'format'})
715
+ ```
716
+
717
+ After:
718
+
719
+ ```bash
720
+ npm install @sanity/image-url
721
+ ```
722
+
723
+ ```ts
724
+ import imageUrlBuilder from '@sanity/image-url'
725
+ const builder = imageUrlBuilder({projectId: 'abc123', dataset: 'foo'})
726
+ const urlFor = (source) => builder.image(source)
727
+
728
+ urlFor('image-abc123_foobar-123x123-png').url()
729
+ urlFor('image-abc123_foobar-123x123-png').auto('format').url()
730
+ urlFor({_ref: 'image-abc123_foobar-123x123-png'}).url()
731
+ urlFor({_ref: 'image-abc123_foobar-123x123-png'}).auto('format').url()
732
+ ```
733
+
734
+ #### `SanityClient` static properties moved to named exports
735
+
736
+ Before:
737
+
738
+ ```ts
739
+ import SanityClient from '@sanity/client'
740
+
741
+ const {Patch, Transaction, ClientError, ServerError, requester} = SanityClient
742
+ ```
743
+
744
+ After:
745
+
746
+ ```ts
747
+ import {Patch, Transaction, ClientError, ServerError, requester} from '@sanity/client'
748
+ ```
749
+
750
+ ---
751
+
752
+ #### `client.clientConfig` is removed, replace with `client.config()`
753
+
754
+ Before:
755
+
756
+ ```ts
757
+ import createClient from '@sanity/client'
758
+ const client = createClient()
759
+
760
+ console.log(client.clientConfig.projectId)
761
+ ```
762
+
763
+ After:
764
+
765
+ ```ts
766
+ import {createClient} from '@sanity/client'
767
+ const client = createClient()
768
+
769
+ console.log(client.config().projectId)
770
+ ```
771
+
772
+ ---
773
+
774
+ #### `client.getUrl()` is removed
775
+
776
+ Before:
777
+
778
+ ```ts
779
+ import createClient from '@sanity/client'
780
+ const client = createClient({projectId: 'abc123'})
781
+
782
+ console.log(client.getUrl('/foo/bar') === 'https://abc123.api.sanity.io/v1/foo/bar')
783
+ console.log(client.getUrl('/foo/bar', true) === 'https://abc123.apicdn.sanity.io/v1/foo/bar')
784
+ ```
785
+
786
+ After:
787
+
788
+ ```ts
789
+ import {createClient} from '@sanity/client'
790
+ const client = createClient({projectId: 'abc123'})
791
+
792
+ const getUrl = (uri: string, useCdn = false) => {
793
+ const config = client.config()
794
+ const base = useCdn ? config.cdnUrl : config.url
795
+ return `${base}/${uri.replace(/^\//, '')}`
796
+ }
797
+
798
+ console.log(getUrl('/foo/bar') === 'https://abc123.api.sanity.io/v1/foo/bar')
799
+ console.log(getUrl('/foo/bar', true) === 'https://abc123.apicdn.sanity.io/v1/foo/bar')
800
+ ```
801
+
802
+ ---
803
+
804
+ #### `client.getDataUrl()` is removed
805
+
806
+ Before:
807
+
808
+ ```ts
809
+ import createClient from '@sanity/client'
810
+ const client = createClient({dataset: 'bikeshop'})
811
+
812
+ console.log(client.getDataUrl('doc') === '/data/doc/bikeshop')
813
+ console.log(client.getDataUrl('doc', 'bike-123') === '/data/doc/bikeshop/bike-123')
814
+ ```
815
+
816
+ After:
817
+
818
+ ```ts
819
+ import {createClient} from '@sanity/client'
820
+ const client = createClient({dataset: 'bikeshop'})
821
+
822
+ const getDataUrl = (operation: string, path?: string) => {
823
+ const {dataset} = client.config()
824
+ const baseUri = `/${operation}/${dataset}`
825
+ const uri = path ? `${baseUri}/${path}` : baseUri
826
+ return `/data${uri}`.replace(/\/($|\?)/, '$1')
827
+ }
828
+
829
+ console.log(getDataUrl('doc') === '/data/doc/bikeshop')
830
+ console.log(getDataUrl('doc', 'bike-123') === '/data/doc/bikeshop/bike-123')
831
+ ```
832
+
833
+ ---
834
+
835
+ #### `client.isPromiseAPI()` is removed, replace with `instanceof` check
836
+
837
+ Before:
838
+
839
+ ```ts
840
+ import createClient from '@sanity/client'
841
+ const client = createClient()
842
+
843
+ console.log(client.isPromiseAPI())
844
+ console.log(client.clientConfig.isPromiseAPI)
845
+ console.log(client.config().isPromiseAPI)
846
+ ```
847
+
848
+ After:
849
+
850
+ ```ts
851
+ import {createClient, SanityClient} from '@sanity/client'
852
+ const client = createClient()
853
+
854
+ console.log(client instanceof SanityClient)
855
+ ```
856
+
857
+ ---
858
+
859
+ #### `client.observable.isObservableAPI()` is removed, replace with `instanceof` check
860
+
861
+ Before:
862
+
863
+ ```ts
864
+ import createClient from '@sanity/client'
865
+ const client = createClient()
866
+
867
+ console.log(client.observable.isObservableAPI())
868
+ ```
869
+
870
+ After:
871
+
872
+ ```ts
873
+ import {createClient, ObservableSanityClient} from '@sanity/client'
874
+ const client = createClient()
875
+
876
+ console.log(client.observable instanceof ObservableSanityClient)
877
+ ```
878
+
879
+ ---
880
+
881
+ #### `client._requestObservable` is removed, replace with `client.observable.request`
882
+
883
+ Before:
884
+
885
+ ```ts
886
+ import createClient from '@sanity/client'
887
+ const client = createClient()
888
+
889
+ client._requestObservable({uri: '/ping'}).subscribe()
890
+ ```
891
+
892
+ After:
893
+
894
+ ```ts
895
+ import {createClient} from '@sanity/client'
896
+ const client = createClient()
897
+
898
+ client.observable.request({uri: '/ping'}).subscribe()
899
+ ```
900
+
901
+ ---
902
+
903
+ #### `client._dataRequest` is removed, replace with `client.dataRequest`
904
+
905
+ Before:
906
+
907
+ ```ts
908
+ import createClient from '@sanity/client'
909
+ const client = createClient()
910
+
911
+ client._dataRequest(endpoint, body, options)
912
+ ```
913
+
914
+ After:
915
+
916
+ ```ts
917
+ import {createClient} from '@sanity/client'
918
+ const client = createClient()
919
+
920
+ client.dataRequest(endpoint, body, options)
921
+ ```
922
+
923
+ ---
924
+
925
+ #### `client._create_` is removed, replace with one of `client.create`, `client.createIfNotExists` or `client.createOrReplace`
926
+
927
+ Before:
928
+
929
+ ```ts
930
+ import createClient from '@sanity/client'
931
+ const client = createClient()
932
+
933
+ client._create(doc, 'create', options)
934
+ client._create(doc, 'createIfNotExists', options)
935
+ client._create(doc, 'createOrReplace', options)
936
+ ```
937
+
938
+ After:
939
+
940
+ ```ts
941
+ import {createClient} from '@sanity/client'
942
+ const client = createClient()
943
+
944
+ client.create(doc, options)
945
+ client.createIfNotExists(doc, options)
946
+ client.createOrReplace(doc, options)
947
+ ```
948
+
949
+ ---
950
+
534
951
  ## Release new version
535
952
 
536
953
  Run ["CI & Release" workflow](https://github.com/sanity-io/client/actions/workflows/ci.yml).
@@ -541,3 +958,11 @@ Semantic release will only release on configured branches, so it is safe to run
541
958
  ## License
542
959
 
543
960
  MIT © [Sanity.io](https://www.sanity.io/)
961
+
962
+ [modern browsers]: https://browsersl.ist/#q=%3E+0.2%25+and+supports+es6-module+and+supports+es6-module-dynamic-import+and+not+dead+and+not+IE+11
963
+ [Deno]: https://deno.land/
964
+ [Edge Runtime]: https://edge-runtime.vercel.sh/
965
+ [Bun]: https://bun.sh/
966
+ [gzip-badge]: https://img.shields.io/bundlephobia/minzip/@sanity/client?label=gzip%20size&style=flat-square
967
+ [size-badge]: https://img.shields.io/bundlephobia/min/@sanity/client?label=size&style=flat-square
968
+ [unpkg-dist]: https://unpkg.com/@sanity/client/umd/
@@ -1285,7 +1285,8 @@ var __privateSet = (obj, member, value, setter) => {
1285
1285
  };
1286
1286
  var _clientConfig, _httpRequest, _clientConfig2, _httpRequest2;
1287
1287
  const _ObservableSanityClient = class {
1288
- constructor(httpRequest, config) {
1288
+ constructor(httpRequest) {
1289
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1289
1290
  __privateAdd(this, _clientConfig, void 0);
1290
1291
  __privateAdd(this, _httpRequest, void 0);
1291
1292
  this.config(config);
@@ -1356,11 +1357,11 @@ let ObservableSanityClient = _ObservableSanityClient;
1356
1357
  _clientConfig = new WeakMap();
1357
1358
  _httpRequest = new WeakMap();
1358
1359
  const _SanityClient = class {
1359
- constructor(httpRequest, config) {
1360
+ constructor(httpRequest) {
1361
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
1360
1362
  __privateAdd(this, _clientConfig2, void 0);
1361
1363
  __privateAdd(this, _httpRequest2, void 0);
1362
1364
  this.listen = _listen;
1363
- this.observable = new ObservableSanityClient(httpRequest, config);
1364
1365
  this.config(config);
1365
1366
  __privateSet(this, _httpRequest2, httpRequest);
1366
1367
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
@@ -1368,6 +1369,7 @@ const _SanityClient = class {
1368
1369
  this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
1369
1370
  this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
1370
1371
  this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
1372
+ this.observable = new ObservableSanityClient(httpRequest, config);
1371
1373
  }
1372
1374
  clone() {
1373
1375
  return new _SanityClient(__privateGet(this, _httpRequest2), this.config());
@@ -1381,7 +1383,9 @@ const _SanityClient = class {
1381
1383
  if (__privateGet(this, _clientConfig2) && __privateGet(this, _clientConfig2).allowReconfigure === false) {
1382
1384
  throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");
1383
1385
  }
1384
- this.observable.config(newConfig);
1386
+ if (this.observable) {
1387
+ this.observable.config(newConfig);
1388
+ }
1385
1389
  __privateSet(this, _clientConfig2, initConfig(newConfig, __privateGet(this, _clientConfig2) || {}));
1386
1390
  return this;
1387
1391
  }
@@ -1434,9 +1438,7 @@ _clientConfig2 = new WeakMap();
1434
1438
  _httpRequest2 = new WeakMap();
1435
1439
  const httpRequest = defineHttpRequest(envMiddleware);
1436
1440
  const requester = httpRequest.defaultRequester;
1437
- function createClient(config) {
1438
- return new SanityClient(httpRequest, config);
1439
- }
1441
+ const createClient = config => new SanityClient(httpRequest, config);
1440
1442
  exports.BasePatch = BasePatch;
1441
1443
  exports.BaseTransaction = BaseTransaction;
1442
1444
  exports.ClientError = ClientError;