@sanity/client 3.3.3-esm.1 → 3.3.3-esm.6

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.
@@ -1,22 +1,118 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
2
10
  var __commonJS = (cb, mod) => function __require() {
3
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
12
  };
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
5
30
 
6
- // src/util/observable.js
7
- import { Observable } from "rxjs/internal/Observable";
8
- import { filter } from "rxjs/internal/operators/filter";
9
- import { map } from "rxjs/internal/operators/map";
10
- var require_observable = __commonJS({
11
- "src/util/observable.js"(exports, module) {
12
- module.exports = {
13
- Observable,
14
- filter,
15
- map
31
+ // node_modules/object-assign/index.js
32
+ var require_object_assign = __commonJS({
33
+ "node_modules/object-assign/index.js"(exports, module) {
34
+ "use strict";
35
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
36
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
37
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
38
+ function toObject(val) {
39
+ if (val === null || val === void 0) {
40
+ throw new TypeError("Object.assign cannot be called with null or undefined");
41
+ }
42
+ return Object(val);
43
+ }
44
+ function shouldUseNative() {
45
+ try {
46
+ if (!Object.assign) {
47
+ return false;
48
+ }
49
+ var test1 = new String("abc");
50
+ test1[5] = "de";
51
+ if (Object.getOwnPropertyNames(test1)[0] === "5") {
52
+ return false;
53
+ }
54
+ var test2 = {};
55
+ for (var i = 0; i < 10; i++) {
56
+ test2["_" + String.fromCharCode(i)] = i;
57
+ }
58
+ var order2 = Object.getOwnPropertyNames(test2).map(function(n) {
59
+ return test2[n];
60
+ });
61
+ if (order2.join("") !== "0123456789") {
62
+ return false;
63
+ }
64
+ var test3 = {};
65
+ "abcdefghijklmnopqrst".split("").forEach(function(letter) {
66
+ test3[letter] = letter;
67
+ });
68
+ if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
69
+ return false;
70
+ }
71
+ return true;
72
+ } catch (err) {
73
+ return false;
74
+ }
75
+ }
76
+ module.exports = shouldUseNative() ? Object.assign : function(target, source) {
77
+ var from;
78
+ var to = toObject(target);
79
+ var symbols;
80
+ for (var s = 1; s < arguments.length; s++) {
81
+ from = Object(arguments[s]);
82
+ for (var key in from) {
83
+ if (hasOwnProperty.call(from, key)) {
84
+ to[key] = from[key];
85
+ }
86
+ }
87
+ if (getOwnPropertySymbols) {
88
+ symbols = getOwnPropertySymbols(from);
89
+ for (var i = 0; i < symbols.length; i++) {
90
+ if (propIsEnumerable.call(from, symbols[i])) {
91
+ to[symbols[i]] = from[symbols[i]];
92
+ }
93
+ }
94
+ }
95
+ }
96
+ return to;
16
97
  };
17
98
  }
18
99
  });
19
100
 
101
+ // src/util/observable-modern.js
102
+ var observable_modern_exports = {};
103
+ __export(observable_modern_exports, {
104
+ Observable: () => Observable,
105
+ filter: () => filter,
106
+ map: () => map
107
+ });
108
+ import { Observable } from "rxjs-v7/internal/Observable";
109
+ import { filter } from "rxjs-v7/internal/operators/filter";
110
+ import { map } from "rxjs-v7/internal/operators/map";
111
+ var init_observable_modern = __esm({
112
+ "src/util/observable-modern.js"() {
113
+ }
114
+ });
115
+
20
116
  // src/util/getSelection.js
21
117
  var require_getSelection = __commonJS({
22
118
  "src/util/getSelection.js"(exports, module) {
@@ -108,52 +204,51 @@ var require_validators = __commonJS({
108
204
  });
109
205
 
110
206
  // src/data/patch.js
111
- import assign from "object-assign";
112
207
  var require_patch = __commonJS({
113
208
  "src/data/patch.js"(exports, module) {
114
209
  var getSelection = require_getSelection();
115
- var validate = require_validators();
116
- var validateObject = validate.validateObject;
117
- var validateInsert = validate.validateInsert;
210
+ var validate2 = require_validators();
211
+ var validateObject = validate2.validateObject;
212
+ var validateInsert = validate2.validateInsert;
118
213
  function Patch(selection, operations = {}, client = null) {
119
214
  this.selection = selection;
120
- this.operations = assign({}, operations);
215
+ this.operations = Object.assign({}, operations);
121
216
  this.client = client;
122
217
  }
123
- assign(Patch.prototype, {
218
+ Object.assign(Patch.prototype, {
124
219
  clone() {
125
- return new Patch(this.selection, assign({}, this.operations), this.client);
220
+ return new Patch(this.selection, Object.assign({}, this.operations), this.client);
126
221
  },
127
222
  set(props) {
128
- return this._assign("set", props);
223
+ return this.assign("set", props);
129
224
  },
130
225
  diffMatchPatch(props) {
131
226
  validateObject("diffMatchPatch", props);
132
- return this._assign("diffMatchPatch", props);
227
+ return this.assign("diffMatchPatch", props);
133
228
  },
134
229
  unset(attrs) {
135
230
  if (!Array.isArray(attrs)) {
136
231
  throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
137
232
  }
138
- this.operations = assign({}, this.operations, { unset: attrs });
233
+ this.operations = Object.assign({}, this.operations, { unset: attrs });
139
234
  return this;
140
235
  },
141
236
  setIfMissing(props) {
142
- return this._assign("setIfMissing", props);
237
+ return this.assign("setIfMissing", props);
143
238
  },
144
239
  replace(props) {
145
240
  validateObject("replace", props);
146
241
  return this._set("set", { $: props });
147
242
  },
148
243
  inc(props) {
149
- return this._assign("inc", props);
244
+ return this.assign("inc", props);
150
245
  },
151
246
  dec(props) {
152
- return this._assign("dec", props);
247
+ return this.assign("dec", props);
153
248
  },
154
249
  insert(at, selector, items) {
155
250
  validateInsert(at, selector, items);
156
- return this._assign("insert", { [at]: selector, items });
251
+ return this.assign("insert", { [at]: selector, items });
157
252
  },
158
253
  append(selector, items) {
159
254
  return this.insert("after", `${selector}[-1]`, items);
@@ -174,7 +269,7 @@ var require_patch = __commonJS({
174
269
  return this;
175
270
  },
176
271
  serialize() {
177
- return assign(getSelection(this.selection), this.operations);
272
+ return Object.assign(getSelection(this.selection), this.operations);
178
273
  },
179
274
  toJSON() {
180
275
  return this.serialize();
@@ -186,7 +281,7 @@ var require_patch = __commonJS({
186
281
  );
187
282
  }
188
283
  const returnFirst = typeof this.selection === "string";
189
- const opts = assign({ returnFirst, returnDocuments: true }, options);
284
+ const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
190
285
  return this.client.mutate({ patch: this.serialize() }, opts);
191
286
  },
192
287
  reset() {
@@ -194,12 +289,12 @@ var require_patch = __commonJS({
194
289
  return this;
195
290
  },
196
291
  _set(op, props) {
197
- return this._assign(op, props, false);
292
+ return this.assign(op, props, false);
198
293
  },
199
- _assign(op, props, merge = true) {
294
+ assign(op, props, merge = true) {
200
295
  validateObject(op, props);
201
- this.operations = assign({}, this.operations, {
202
- [op]: assign({}, merge && this.operations[op] || {}, props)
296
+ this.operations = Object.assign({}, this.operations, {
297
+ [op]: Object.assign({}, merge && this.operations[op] || {}, props)
203
298
  });
204
299
  return this;
205
300
  }
@@ -209,7 +304,6 @@ var require_patch = __commonJS({
209
304
  });
210
305
 
211
306
  // src/data/transaction.js
212
- import assign2 from "object-assign";
213
307
  var require_transaction = __commonJS({
214
308
  "src/data/transaction.js"(exports, module) {
215
309
  var validators = require_validators();
@@ -220,7 +314,7 @@ var require_transaction = __commonJS({
220
314
  this.operations = operations;
221
315
  this.client = client;
222
316
  }
223
- assign2(Transaction.prototype, {
317
+ Object.assign(Transaction.prototype, {
224
318
  clone() {
225
319
  return new Transaction(this.operations.slice(0), this.client, this.trxId);
226
320
  },
@@ -257,7 +351,7 @@ var require_transaction = __commonJS({
257
351
  }
258
352
  return this._add({ patch: patch.serialize() });
259
353
  }
260
- return this._add({ patch: assign2({ id: documentId }, patchOps) });
354
+ return this._add({ patch: Object.assign({ id: documentId }, patchOps) });
261
355
  },
262
356
  transactionId(id) {
263
357
  if (!id) {
@@ -280,7 +374,7 @@ var require_transaction = __commonJS({
280
374
  }
281
375
  return this.client.mutate(
282
376
  this.serialize(),
283
- assign2({ transactionId: this.trxId }, defaultMutateOptions, options || {})
377
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
284
378
  );
285
379
  },
286
380
  reset() {
@@ -339,11 +433,10 @@ var require_defaults = __commonJS({
339
433
  });
340
434
 
341
435
  // src/data/listen.js
342
- import assign3 from "object-assign";
343
436
  import polyfilledEventSource from "@sanity/eventsource";
344
437
  var require_listen = __commonJS({
345
438
  "src/data/listen.js"(exports, module) {
346
- var { Observable: Observable2 } = require_observable();
439
+ var { Observable: Observable2 } = (init_observable_modern(), __toCommonJS(observable_modern_exports));
347
440
  var pick = require_pick();
348
441
  var defaults = require_defaults();
349
442
  var encodeQueryString = require_encodeQueryString();
@@ -443,7 +536,7 @@ var require_listen = __commonJS({
443
536
  function parseEvent(event) {
444
537
  try {
445
538
  const data = event.data && JSON.parse(event.data) || {};
446
- return assign3({ type: event.type }, data);
539
+ return Object.assign({ type: event.type }, data);
447
540
  } catch (err) {
448
541
  return err;
449
542
  }
@@ -468,10 +561,9 @@ var require_listen = __commonJS({
468
561
  });
469
562
 
470
563
  // src/data/dataMethods.js
471
- import assign4 from "object-assign";
472
564
  var require_dataMethods = __commonJS({
473
565
  "src/data/dataMethods.js"(exports, module) {
474
- var { map: map2, filter: filter2 } = require_observable();
566
+ var { map: map2, filter: filter2 } = (init_observable_modern(), __toCommonJS(observable_modern_exports));
475
567
  var validators = require_validators();
476
568
  var getSelection = require_getSelection();
477
569
  var encodeQueryString = require_encodeQueryString();
@@ -607,7 +699,7 @@ var require_dataMethods = __commonJS({
607
699
  },
608
700
  _create(doc, op, options = {}) {
609
701
  const mutation = { [op]: doc };
610
- const opts = assign4({ returnFirst: true, returnDocuments: true }, options);
702
+ const opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
611
703
  return this.dataRequest("mutate", { mutations: [mutation] }, opts);
612
704
  }
613
705
  };
@@ -615,14 +707,13 @@ var require_dataMethods = __commonJS({
615
707
  });
616
708
 
617
709
  // src/datasets/datasetsClient.js
618
- import assign5 from "object-assign";
619
710
  var require_datasetsClient = __commonJS({
620
711
  "src/datasets/datasetsClient.js"(exports, module) {
621
- var validate = require_validators();
712
+ var validate2 = require_validators();
622
713
  function DatasetsClient(client) {
623
714
  this.request = client.request.bind(client);
624
715
  }
625
- assign5(DatasetsClient.prototype, {
716
+ Object.assign(DatasetsClient.prototype, {
626
717
  create(name, options) {
627
718
  return this._modify("PUT", name, options);
628
719
  },
@@ -636,7 +727,7 @@ var require_datasetsClient = __commonJS({
636
727
  return this.request({ uri: "/datasets" });
637
728
  },
638
729
  _modify(method, name, body) {
639
- validate.dataset(name);
730
+ validate2.dataset(name);
640
731
  return this.request({ method, uri: `/datasets/${name}`, body });
641
732
  }
642
733
  });
@@ -645,13 +736,12 @@ var require_datasetsClient = __commonJS({
645
736
  });
646
737
 
647
738
  // src/projects/projectsClient.js
648
- import assign6 from "object-assign";
649
739
  var require_projectsClient = __commonJS({
650
740
  "src/projects/projectsClient.js"(exports, module) {
651
741
  function ProjectsClient(client) {
652
742
  this.client = client;
653
743
  }
654
- assign6(ProjectsClient.prototype, {
744
+ Object.assign(ProjectsClient.prototype, {
655
745
  list() {
656
746
  return this.client.request({ uri: "/projects" });
657
747
  },
@@ -679,10 +769,9 @@ var require_queryString = __commonJS({
679
769
  });
680
770
 
681
771
  // src/assets/assetsClient.js
682
- import assign7 from "object-assign";
683
772
  var require_assetsClient = __commonJS({
684
773
  "src/assets/assetsClient.js"(exports, module) {
685
- var { map: map2, filter: filter2 } = require_observable();
774
+ var { map: map2, filter: filter2 } = (init_observable_modern(), __toCommonJS(observable_modern_exports));
686
775
  var queryString = require_queryString();
687
776
  var validators = require_validators();
688
777
  function AssetsClient(client) {
@@ -692,7 +781,7 @@ var require_assetsClient = __commonJS({
692
781
  if (typeof window === "undefined" || !(file instanceof window.File)) {
693
782
  return opts;
694
783
  }
695
- return assign7(
784
+ return Object.assign(
696
785
  {
697
786
  filename: opts.preserveFilename === false ? void 0 : file.name,
698
787
  contentType: file.type
@@ -700,7 +789,7 @@ var require_assetsClient = __commonJS({
700
789
  opts
701
790
  );
702
791
  }
703
- assign7(AssetsClient.prototype, {
792
+ Object.assign(AssetsClient.prototype, {
704
793
  upload(assetType, body, opts = {}) {
705
794
  validators.validateAssetType(assetType);
706
795
  let meta = opts.extract || void 0;
@@ -773,13 +862,12 @@ var require_assetsClient = __commonJS({
773
862
  });
774
863
 
775
864
  // src/users/usersClient.js
776
- import assign8 from "object-assign";
777
865
  var require_usersClient = __commonJS({
778
866
  "src/users/usersClient.js"(exports, module) {
779
867
  function UsersClient(client) {
780
868
  this.client = client;
781
869
  }
782
- assign8(UsersClient.prototype, {
870
+ Object.assign(UsersClient.prototype, {
783
871
  getById(id) {
784
872
  return this.client.request({ uri: `/users/${id}` });
785
873
  }
@@ -789,13 +877,12 @@ var require_usersClient = __commonJS({
789
877
  });
790
878
 
791
879
  // src/auth/authClient.js
792
- import assign9 from "object-assign";
793
880
  var require_authClient = __commonJS({
794
881
  "src/auth/authClient.js"(exports, module) {
795
882
  function AuthClient(client) {
796
883
  this.client = client;
797
884
  }
798
- assign9(AuthClient.prototype, {
885
+ Object.assign(AuthClient.prototype, {
799
886
  getLoginProviders() {
800
887
  return this.client.request({ uri: "/auth/providers" });
801
888
  },
@@ -809,18 +896,17 @@ var require_authClient = __commonJS({
809
896
 
810
897
  // src/http/errors.js
811
898
  import makeError from "make-error";
812
- import assign10 from "object-assign";
813
899
  var require_errors = __commonJS({
814
900
  "src/http/errors.js"(exports) {
815
901
  function ClientError(res) {
816
902
  const props = extractErrorProps(res);
817
903
  ClientError.super.call(this, props.message);
818
- assign10(this, props);
904
+ Object.assign(this, props);
819
905
  }
820
906
  function ServerError(res) {
821
907
  const props = extractErrorProps(res);
822
908
  ServerError.super.call(this, props.message);
823
- assign10(this, props);
909
+ Object.assign(this, props);
824
910
  }
825
911
  function extractErrorProps(res) {
826
912
  const body = res.body;
@@ -866,14 +952,10 @@ var require_browserMiddleware = __commonJS({
866
952
 
867
953
  // src/http/request.js
868
954
  import getIt from "get-it";
869
- import assign11 from "object-assign";
870
- import observable from "get-it/lib/middleware/observable";
871
- import jsonRequest from "get-it/lib/middleware/jsonRequest";
872
- import jsonResponse from "get-it/lib/middleware/jsonResponse";
873
- import progress from "get-it/lib/middleware/progress";
955
+ import { observable, jsonRequest, jsonResponse, progress } from "get-it/middleware";
874
956
  var require_request = __commonJS({
875
957
  "src/http/request.js"(exports, module) {
876
- var { Observable: Observable2 } = require_observable();
958
+ var { Observable: Observable2 } = (init_observable_modern(), __toCommonJS(observable_modern_exports));
877
959
  var { ClientError, ServerError } = require_errors();
878
960
  var httpError = {
879
961
  onResponse: (res) => {
@@ -888,12 +970,12 @@ var require_request = __commonJS({
888
970
  var printWarnings = {
889
971
  onResponse: (res) => {
890
972
  const warn = res.headers["x-sanity-warning"];
891
- const warnings = Array.isArray(warn) ? warn : [warn];
892
- warnings.filter(Boolean).forEach((msg) => console.warn(msg));
973
+ const warnings2 = Array.isArray(warn) ? warn : [warn];
974
+ warnings2.filter(Boolean).forEach((msg) => console.warn(msg));
893
975
  return res;
894
976
  }
895
977
  };
896
- var envSpecific = require_browserMiddleware();
978
+ var envSpecific = typeof EdgeRuntime === "string" ? require_browserMiddleware() : require_browserMiddleware();
897
979
  var middleware = envSpecific.concat([
898
980
  printWarnings,
899
981
  jsonRequest(),
@@ -904,7 +986,7 @@ var require_request = __commonJS({
904
986
  ]);
905
987
  var request = getIt(middleware);
906
988
  function httpRequest(options, requester = request) {
907
- return requester(assign11({ maxRedirects: 0 }, options));
989
+ return requester(Object.assign({ maxRedirects: 0 }, options));
908
990
  }
909
991
  httpRequest.defaultRequester = request;
910
992
  httpRequest.ClientError = ClientError;
@@ -914,7 +996,6 @@ var require_request = __commonJS({
914
996
  });
915
997
 
916
998
  // src/http/requestOptions.js
917
- import assign12 from "object-assign";
918
999
  var require_requestOptions = __commonJS({
919
1000
  "src/http/requestOptions.js"(exports, module) {
920
1001
  var projectHeader = "X-Sanity-Project-ID";
@@ -931,8 +1012,8 @@ var require_requestOptions = __commonJS({
931
1012
  typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
932
1013
  );
933
1014
  const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
934
- return assign12({}, overrides, {
935
- headers: assign12({}, headers, overrides.headers || {}),
1015
+ return Object.assign({}, overrides, {
1016
+ headers: Object.assign({}, headers, overrides.headers || {}),
936
1017
  timeout: typeof timeout === "undefined" ? 5 * 60 * 1e3 : timeout,
937
1018
  proxy: overrides.proxy || config.proxy,
938
1019
  json: true,
@@ -943,12 +1024,17 @@ var require_requestOptions = __commonJS({
943
1024
  });
944
1025
 
945
1026
  // src/generateHelpUrl.js
946
- var require_generateHelpUrl = __commonJS({
947
- "src/generateHelpUrl.js"(exports, module) {
948
- var BASE_URL = "https://docs.sanity.io/help/";
949
- module.exports = function generateHelpUrl(slug) {
950
- return BASE_URL + slug;
951
- };
1027
+ var generateHelpUrl_exports = {};
1028
+ __export(generateHelpUrl_exports, {
1029
+ default: () => generateHelpUrl
1030
+ });
1031
+ function generateHelpUrl(slug) {
1032
+ return BASE_URL + slug;
1033
+ }
1034
+ var BASE_URL;
1035
+ var init_generateHelpUrl = __esm({
1036
+ "src/generateHelpUrl.js"() {
1037
+ BASE_URL = "https://docs.sanity.io/help/";
952
1038
  }
953
1039
  });
954
1040
 
@@ -973,51 +1059,66 @@ var require_once = __commonJS({
973
1059
  // src/warnings.js
974
1060
  var require_warnings = __commonJS({
975
1061
  "src/warnings.js"(exports) {
976
- var generateHelpUrl = require_generateHelpUrl();
1062
+ var generateHelpUrl2 = (init_generateHelpUrl(), __toCommonJS(generateHelpUrl_exports));
977
1063
  var once = require_once();
978
1064
  var createWarningPrinter = (message) => once((...args) => console.warn(message.join(" "), ...args));
979
1065
  exports.printCdnWarning = createWarningPrinter([
980
1066
  "You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and",
981
- `cheaper. Think about it! For more info, see ${generateHelpUrl("js-client-cdn-configuration")}.`,
1067
+ `cheaper. Think about it! For more info, see ${generateHelpUrl2("js-client-cdn-configuration")}.`,
982
1068
  "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating",
983
1069
  "the client."
984
1070
  ]);
985
1071
  exports.printBrowserTokenWarning = createWarningPrinter([
986
1072
  "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
987
- `See ${generateHelpUrl(
1073
+ `See ${generateHelpUrl2(
988
1074
  "js-client-browser-token"
989
1075
  )} for more information and how to hide this warning.`
990
1076
  ]);
991
1077
  exports.printNoApiVersionSpecifiedWarning = createWarningPrinter([
992
1078
  "Using the Sanity client without specifying an API version is deprecated.",
993
- `See ${generateHelpUrl("js-client-api-version")}`
1079
+ `See ${generateHelpUrl2("js-client-api-version")}`
994
1080
  ]);
995
1081
  }
996
1082
  });
997
1083
 
998
1084
  // src/config.js
999
- import assign13 from "object-assign";
1000
- var require_config = __commonJS({
1001
- "src/config.js"(exports) {
1002
- var generateHelpUrl = require_generateHelpUrl();
1003
- var validate = require_validators();
1004
- var warnings = require_warnings();
1005
- var defaultCdnHost = "apicdn.sanity.io";
1006
- var defaultConfig = {
1085
+ var config_exports = {};
1086
+ __export(config_exports, {
1087
+ defaultConfig: () => defaultConfig,
1088
+ initConfig: () => initConfig,
1089
+ validateApiVersion: () => validateApiVersion
1090
+ });
1091
+ var import_validators, import_warnings, defaultCdnHost, defaultConfig, LOCALHOSTS, isLocal, validateApiVersion, initConfig;
1092
+ var init_config = __esm({
1093
+ "src/config.js"() {
1094
+ init_generateHelpUrl();
1095
+ import_validators = __toESM(require_validators());
1096
+ import_warnings = __toESM(require_warnings());
1097
+ defaultCdnHost = "apicdn.sanity.io";
1098
+ defaultConfig = {
1007
1099
  apiHost: "https://api.sanity.io",
1008
1100
  apiVersion: "1",
1009
1101
  useProjectHostname: true,
1010
1102
  isPromiseAPI: true
1011
1103
  };
1012
- var LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
1013
- var isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
1014
- exports.defaultConfig = defaultConfig;
1015
- exports.initConfig = (config, prevConfig) => {
1016
- const specifiedConfig = assign13({}, prevConfig, config);
1104
+ LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
1105
+ isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
1106
+ validateApiVersion = function validateApiVersion2(apiVersion) {
1107
+ if (apiVersion === "1" || apiVersion === "X") {
1108
+ return;
1109
+ }
1110
+ const apiDate = new Date(apiVersion);
1111
+ const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
1112
+ if (!apiVersionValid) {
1113
+ throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
1114
+ }
1115
+ };
1116
+ initConfig = (config, prevConfig) => {
1117
+ const specifiedConfig = Object.assign({}, prevConfig, config);
1017
1118
  if (!specifiedConfig.apiVersion) {
1018
- warnings.printNoApiVersionSpecifiedWarning();
1119
+ import_warnings.default.printNoApiVersionSpecifiedWarning();
1019
1120
  }
1020
- const newConfig = assign13({}, defaultConfig, specifiedConfig);
1121
+ const newConfig = Object.assign({}, defaultConfig, specifiedConfig);
1021
1122
  const projectBased = newConfig.useProjectHostname;
1022
1123
  if (typeof Promise === "undefined") {
1023
1124
  const helpUrl = generateHelpUrl("js-client-promise-polyfill");
@@ -1029,23 +1130,23 @@ var require_config = __commonJS({
1029
1130
  const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
1030
1131
  const isLocalhost = isBrowser && isLocal(window.location.hostname);
1031
1132
  if (isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true) {
1032
- warnings.printBrowserTokenWarning();
1133
+ import_warnings.default.printBrowserTokenWarning();
1033
1134
  } else if (typeof newConfig.useCdn === "undefined") {
1034
- warnings.printCdnWarning();
1135
+ import_warnings.default.printCdnWarning();
1035
1136
  }
1036
1137
  if (projectBased) {
1037
- validate.projectId(newConfig.projectId);
1138
+ import_validators.default.projectId(newConfig.projectId);
1038
1139
  }
1039
1140
  if (newConfig.dataset) {
1040
- validate.dataset(newConfig.dataset);
1141
+ import_validators.default.dataset(newConfig.dataset);
1041
1142
  }
1042
1143
  if ("requestTagPrefix" in newConfig) {
1043
- newConfig.requestTagPrefix = newConfig.requestTagPrefix ? validate.requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0;
1144
+ newConfig.requestTagPrefix = newConfig.requestTagPrefix ? import_validators.default.requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0;
1044
1145
  }
1045
1146
  newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, "");
1046
1147
  newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost;
1047
1148
  newConfig.useCdn = Boolean(newConfig.useCdn) && !newConfig.withCredentials;
1048
- exports.validateApiVersion(newConfig.apiVersion);
1149
+ validateApiVersion(newConfig.apiVersion);
1049
1150
  const hostParts = newConfig.apiHost.split("://", 2);
1050
1151
  const protocol = hostParts[0];
1051
1152
  const host = hostParts[1];
@@ -1059,24 +1160,14 @@ var require_config = __commonJS({
1059
1160
  }
1060
1161
  return newConfig;
1061
1162
  };
1062
- exports.validateApiVersion = function validateApiVersion(apiVersion) {
1063
- if (apiVersion === "1" || apiVersion === "X") {
1064
- return;
1065
- }
1066
- const apiDate = new Date(apiVersion);
1067
- const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
1068
- if (!apiVersionValid) {
1069
- throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
1070
- }
1071
- };
1072
1163
  }
1073
1164
  });
1074
1165
 
1075
1166
  // src/sanityClient.js
1076
- import assign14 from "object-assign";
1077
1167
  var require_sanityClient = __commonJS({
1078
1168
  "src/sanityClient.js"(exports, module) {
1079
- var { Observable: Observable2, map: map2, filter: filter2 } = require_observable();
1169
+ var import_object_assign = __toESM(require_object_assign());
1170
+ var { Observable: Observable2, map: map2, filter: filter2 } = (init_observable_modern(), __toCommonJS(observable_modern_exports));
1080
1171
  var Patch = require_patch();
1081
1172
  var Transaction = require_transaction();
1082
1173
  var dataMethods = require_dataMethods();
@@ -1087,10 +1178,10 @@ var require_sanityClient = __commonJS({
1087
1178
  var AuthClient = require_authClient();
1088
1179
  var httpRequest = require_request();
1089
1180
  var getRequestOptions = require_requestOptions();
1090
- var { defaultConfig, initConfig } = require_config();
1091
- var validate = require_validators();
1181
+ var { defaultConfig: defaultConfig2, initConfig: initConfig2 } = (init_config(), __toCommonJS(config_exports));
1182
+ var validate2 = require_validators();
1092
1183
  var toPromise = (observable2) => observable2.toPromise();
1093
- function SanityClient(config = defaultConfig) {
1184
+ function SanityClient(config = defaultConfig2) {
1094
1185
  if (!(this instanceof SanityClient)) {
1095
1186
  return new SanityClient(config);
1096
1187
  }
@@ -1101,24 +1192,24 @@ var require_sanityClient = __commonJS({
1101
1192
  this.users = new UsersClient(this);
1102
1193
  this.auth = new AuthClient(this);
1103
1194
  if (this.clientConfig.isPromiseAPI) {
1104
- const observableConfig = assign14({}, this.clientConfig, { isPromiseAPI: false });
1195
+ const observableConfig = Object.assign({}, this.clientConfig, { isPromiseAPI: false });
1105
1196
  this.observable = new SanityClient(observableConfig);
1106
1197
  }
1107
1198
  }
1108
- assign14(SanityClient.prototype, dataMethods);
1109
- assign14(SanityClient.prototype, {
1199
+ Object.assign(SanityClient.prototype, dataMethods);
1200
+ Object.assign(SanityClient.prototype, {
1110
1201
  clone() {
1111
1202
  return new SanityClient(this.config());
1112
1203
  },
1113
1204
  config(newConfig) {
1114
1205
  if (typeof newConfig === "undefined") {
1115
- return assign14({}, this.clientConfig);
1206
+ return Object.assign({}, this.clientConfig);
1116
1207
  }
1117
1208
  if (this.observable) {
1118
- const observableConfig = assign14({}, newConfig, { isPromiseAPI: false });
1209
+ const observableConfig = Object.assign({}, newConfig, { isPromiseAPI: false });
1119
1210
  this.observable.config(observableConfig);
1120
1211
  }
1121
- this.clientConfig = initConfig(newConfig, this.clientConfig || {});
1212
+ this.clientConfig = initConfig2(newConfig, this.clientConfig || {});
1122
1213
  return this;
1123
1214
  },
1124
1215
  withConfig(newConfig) {
@@ -1137,11 +1228,11 @@ var require_sanityClient = __commonJS({
1137
1228
  const useCdn = this.clientConfig.useCdn && canUseCdn;
1138
1229
  const tag = options.tag && this.clientConfig.requestTagPrefix ? [this.clientConfig.requestTagPrefix, options.tag].join(".") : options.tag || this.clientConfig.requestTagPrefix;
1139
1230
  if (tag) {
1140
- options.query = { tag: validate.requestTag(tag), ...options.query };
1231
+ options.query = { tag: validate2.requestTag(tag), ...options.query };
1141
1232
  }
1142
1233
  const reqOptions = getRequestOptions(
1143
1234
  this.clientConfig,
1144
- assign14({}, options, {
1235
+ Object.assign({}, options, {
1145
1236
  url: this.getUrl(uri, useCdn)
1146
1237
  })
1147
1238
  );
@@ -1166,4 +1257,9 @@ var require_sanityClient = __commonJS({
1166
1257
  }
1167
1258
  });
1168
1259
  export default require_sanityClient();
1260
+ /*
1261
+ object-assign
1262
+ (c) Sindre Sorhus
1263
+ @license MIT
1264
+ */
1169
1265
  //# sourceMappingURL=sanityClient.browser.mjs.map