@sanity/client 5.0.0-esm.8 → 5.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.
@@ -209,19 +209,19 @@
209
209
  initMiddleware.forEach(request.use);
210
210
  return request;
211
211
  }
212
- var __accessCheck$8 = (obj, member, msg) => {
212
+ var __accessCheck$7 = (obj, member, msg) => {
213
213
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
214
214
  };
215
- var __privateGet$8 = (obj, member, getter) => {
216
- __accessCheck$8(obj, member, "read from private field");
215
+ var __privateGet$7 = (obj, member, getter) => {
216
+ __accessCheck$7(obj, member, "read from private field");
217
217
  return getter ? getter.call(obj) : member.get(obj);
218
218
  };
219
- var __privateAdd$8 = (obj, member, value) => {
219
+ var __privateAdd$7 = (obj, member, value) => {
220
220
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
221
221
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
222
222
  };
223
- var __privateSet$8 = (obj, member, value, setter) => {
224
- __accessCheck$8(obj, member, "write to private field");
223
+ var __privateSet$7 = (obj, member, value, setter) => {
224
+ __accessCheck$7(obj, member, "write to private field");
225
225
  setter ? setter.call(obj, value) : member.set(obj, value);
226
226
  return value;
227
227
  };
@@ -235,50 +235,50 @@
235
235
  /**
236
236
  * Private implementation details
237
237
  */
238
- __privateAdd$8(this, _method, void 0);
239
- __privateAdd$8(this, _url, void 0);
240
- __privateAdd$8(this, _resHeaders, void 0);
241
- __privateAdd$8(this, _headers, {});
242
- __privateAdd$8(this, _controller, void 0);
238
+ __privateAdd$7(this, _method, void 0);
239
+ __privateAdd$7(this, _url, void 0);
240
+ __privateAdd$7(this, _resHeaders, void 0);
241
+ __privateAdd$7(this, _headers, {});
242
+ __privateAdd$7(this, _controller, void 0);
243
243
  }
244
244
  // eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
245
245
  open(method, url, _async) {
246
- __privateSet$8(this, _method, method);
247
- __privateSet$8(this, _url, url);
248
- __privateSet$8(this, _resHeaders, "");
246
+ __privateSet$7(this, _method, method);
247
+ __privateSet$7(this, _url, url);
248
+ __privateSet$7(this, _resHeaders, "");
249
249
  this.readyState = 1;
250
250
  this.onreadystatechange();
251
- __privateSet$8(this, _controller, void 0);
251
+ __privateSet$7(this, _controller, void 0);
252
252
  }
253
253
  abort() {
254
- if (__privateGet$8(this, _controller)) {
255
- __privateGet$8(this, _controller).abort();
254
+ if (__privateGet$7(this, _controller)) {
255
+ __privateGet$7(this, _controller).abort();
256
256
  }
257
257
  }
258
258
  getAllResponseHeaders() {
259
- return __privateGet$8(this, _resHeaders);
259
+ return __privateGet$7(this, _resHeaders);
260
260
  }
261
261
  setRequestHeader(name, value) {
262
- __privateGet$8(this, _headers)[name] = value;
262
+ __privateGet$7(this, _headers)[name] = value;
263
263
  }
264
264
  send(body) {
265
265
  const textBody = this.responseType !== "arraybuffer";
266
266
  const options = {
267
- method: __privateGet$8(this, _method),
268
- headers: __privateGet$8(this, _headers),
267
+ method: __privateGet$7(this, _method),
268
+ headers: __privateGet$7(this, _headers),
269
269
  signal: null,
270
270
  body
271
271
  };
272
272
  if (typeof AbortController === "function") {
273
- __privateSet$8(this, _controller, new AbortController());
274
- options.signal = __privateGet$8(this, _controller).signal;
273
+ __privateSet$7(this, _controller, new AbortController());
274
+ options.signal = __privateGet$7(this, _controller).signal;
275
275
  }
276
276
  if (typeof document !== "undefined") {
277
277
  options.credentials = this.withCredentials ? "include" : "omit";
278
278
  }
279
- fetch(__privateGet$8(this, _url), options).then(res => {
279
+ fetch(__privateGet$7(this, _url), options).then(res => {
280
280
  res.headers.forEach((value, key) => {
281
- __privateSet$8(this, _resHeaders, __privateGet$8(this, _resHeaders) + "".concat(key, ": ").concat(value, "\r\n"));
281
+ __privateSet$7(this, _resHeaders, __privateGet$7(this, _resHeaders) + "".concat(key, ": ").concat(value, "\r\n"));
282
282
  });
283
283
  this.status = res.status;
284
284
  this.statusText = res.statusText;
@@ -1166,67 +1166,6 @@
1166
1166
  };
1167
1167
  } (browser$1, browserExports));
1168
1168
 
1169
- var captureStackTrace$1 = Error.captureStackTrace || function (error) {
1170
- var container = new Error();
1171
-
1172
- Object.defineProperty(error, 'stack', {
1173
- configurable: true,
1174
- get: function getStack() {
1175
- var stack = container.stack;
1176
-
1177
- Object.defineProperty(this, 'stack', {
1178
- value: stack
1179
- });
1180
-
1181
- return stack;
1182
- }
1183
- });
1184
- };
1185
-
1186
- var captureStackTrace = captureStackTrace$1;
1187
-
1188
- function inherits(ctor, superCtor) {
1189
- ctor.super_ = superCtor;
1190
- ctor.prototype = Object.create(superCtor.prototype, {
1191
- constructor: {
1192
- value: ctor,
1193
- enumerable: false,
1194
- writable: true,
1195
- configurable: true
1196
- }
1197
- });
1198
- }
1199
-
1200
- var createErrorClass$1 = function createErrorClass(className, setup) {
1201
- if (typeof className !== 'string') {
1202
- throw new TypeError('Expected className to be a string');
1203
- }
1204
-
1205
- if (/[^0-9a-zA-Z_$]/.test(className)) {
1206
- throw new Error('className contains invalid characters');
1207
- }
1208
-
1209
- setup = setup || function (message) {
1210
- this.message = message;
1211
- };
1212
-
1213
- var ErrorClass = function () {
1214
- Object.defineProperty(this, 'name', {
1215
- configurable: true,
1216
- value: className,
1217
- writable: true
1218
- });
1219
-
1220
- captureStackTrace(this, this.constructor);
1221
-
1222
- setup.apply(this, arguments);
1223
- };
1224
-
1225
- inherits(ErrorClass, Error);
1226
-
1227
- return ErrorClass;
1228
- };
1229
-
1230
1169
  /*!
1231
1170
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
1232
1171
  *
@@ -1260,16 +1199,8 @@
1260
1199
  return true;
1261
1200
  }
1262
1201
 
1263
- createErrorClass$1("HttpError", function (res, ctx) {
1264
- const truncatedUrl = res.url.length > 400 ? "".concat(res.url.slice(0, 399), "\u2026") : res.url;
1265
- let msg = "".concat(res.method, "-request to ").concat(truncatedUrl, " resulted in ");
1266
- msg += "HTTP ".concat(res.statusCode, " ").concat(res.statusMessage);
1267
- this.message = msg.trim();
1268
- this.response = res;
1269
- this.request = ctx.options;
1270
- });
1202
+ const isBuffer = typeof Buffer === "undefined" ? () => false : obj => Buffer.isBuffer(obj);
1271
1203
  const serializeTypes = ["boolean", "string", "number"];
1272
- const isBuffer$1 = obj => !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
1273
1204
  function jsonRequest() {
1274
1205
  return {
1275
1206
  processOptions: options => {
@@ -1278,7 +1209,7 @@
1278
1209
  return options;
1279
1210
  }
1280
1211
  const isStream = typeof body.pipe === "function";
1281
- const shouldSerialize = !isStream && !isBuffer$1(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject(body));
1212
+ const shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject(body));
1282
1213
  if (!shouldSerialize) {
1283
1214
  return options;
1284
1215
  }
@@ -2118,163 +2049,6 @@
2118
2049
  });
2119
2050
  }
2120
2051
 
2121
- var makeErrorExports = {};
2122
- var makeError = {
2123
- get exports(){ return makeErrorExports; },
2124
- set exports(v){ makeErrorExports = v; },
2125
- };
2126
-
2127
- (function (module, exports) {
2128
-
2129
- // ===================================================================
2130
-
2131
- var construct = typeof Reflect !== "undefined" ? Reflect.construct : undefined;
2132
- var defineProperty = Object.defineProperty;
2133
-
2134
- // -------------------------------------------------------------------
2135
-
2136
- var captureStackTrace = Error.captureStackTrace;
2137
- if (captureStackTrace === undefined) {
2138
- captureStackTrace = function captureStackTrace(error) {
2139
- var container = new Error();
2140
-
2141
- defineProperty(error, "stack", {
2142
- configurable: true,
2143
- get: function getStack() {
2144
- var stack = container.stack;
2145
-
2146
- // Replace property with value for faster future accesses.
2147
- defineProperty(this, "stack", {
2148
- configurable: true,
2149
- value: stack,
2150
- writable: true,
2151
- });
2152
-
2153
- return stack;
2154
- },
2155
- set: function setStack(stack) {
2156
- defineProperty(error, "stack", {
2157
- configurable: true,
2158
- value: stack,
2159
- writable: true,
2160
- });
2161
- },
2162
- });
2163
- };
2164
- }
2165
-
2166
- // -------------------------------------------------------------------
2167
-
2168
- function BaseError(message) {
2169
- if (message !== undefined) {
2170
- defineProperty(this, "message", {
2171
- configurable: true,
2172
- value: message,
2173
- writable: true,
2174
- });
2175
- }
2176
-
2177
- var cname = this.constructor.name;
2178
- if (cname !== undefined && cname !== this.name) {
2179
- defineProperty(this, "name", {
2180
- configurable: true,
2181
- value: cname,
2182
- writable: true,
2183
- });
2184
- }
2185
-
2186
- captureStackTrace(this, this.constructor);
2187
- }
2188
-
2189
- BaseError.prototype = Object.create(Error.prototype, {
2190
- // See: https://github.com/JsCommunity/make-error/issues/4
2191
- constructor: {
2192
- configurable: true,
2193
- value: BaseError,
2194
- writable: true,
2195
- },
2196
- });
2197
-
2198
- // -------------------------------------------------------------------
2199
-
2200
- // Sets the name of a function if possible (depends of the JS engine).
2201
- var setFunctionName = (function() {
2202
- function setFunctionName(fn, name) {
2203
- return defineProperty(fn, "name", {
2204
- configurable: true,
2205
- value: name,
2206
- });
2207
- }
2208
- try {
2209
- var f = function() {};
2210
- setFunctionName(f, "foo");
2211
- if (f.name === "foo") {
2212
- return setFunctionName;
2213
- }
2214
- } catch (_) {}
2215
- })();
2216
-
2217
- // -------------------------------------------------------------------
2218
-
2219
- function makeError(constructor, super_) {
2220
- if (super_ == null || super_ === Error) {
2221
- super_ = BaseError;
2222
- } else if (typeof super_ !== "function") {
2223
- throw new TypeError("super_ should be a function");
2224
- }
2225
-
2226
- var name;
2227
- if (typeof constructor === "string") {
2228
- name = constructor;
2229
- constructor =
2230
- construct !== undefined
2231
- ? function() {
2232
- return construct(super_, arguments, this.constructor);
2233
- }
2234
- : function() {
2235
- super_.apply(this, arguments);
2236
- };
2237
-
2238
- // If the name can be set, do it once and for all.
2239
- if (setFunctionName !== undefined) {
2240
- setFunctionName(constructor, name);
2241
- name = undefined;
2242
- }
2243
- } else if (typeof constructor !== "function") {
2244
- throw new TypeError("constructor should be either a string or a function");
2245
- }
2246
-
2247
- // Also register the super constructor also as `constructor.super_` just
2248
- // like Node's `util.inherits()`.
2249
- //
2250
- // eslint-disable-next-line dot-notation
2251
- constructor.super_ = constructor["super"] = super_;
2252
-
2253
- var properties = {
2254
- constructor: {
2255
- configurable: true,
2256
- value: constructor,
2257
- writable: true,
2258
- },
2259
- };
2260
-
2261
- // If the name could not be set on the constructor, set it on the
2262
- // prototype.
2263
- if (name !== undefined) {
2264
- properties.name = {
2265
- configurable: true,
2266
- value: name,
2267
- writable: true,
2268
- };
2269
- }
2270
- constructor.prototype = Object.create(super_.prototype, properties);
2271
-
2272
- return constructor;
2273
- }
2274
- exports = module.exports = makeError;
2275
- exports.BaseError = BaseError;
2276
- } (makeError, makeErrorExports));
2277
-
2278
2052
  var eventsourceExports = {};
2279
2053
  var eventsource = {
2280
2054
  get exports(){ return eventsourceExports; },
@@ -3332,7 +3106,7 @@
3332
3106
  var browser = evs.EventSourcePolyfill;
3333
3107
 
3334
3108
  var envMiddleware = [];
3335
- class ClientError extends makeErrorExports.BaseError {
3109
+ class ClientError extends Error {
3336
3110
  constructor(res) {
3337
3111
  const props = extractErrorProps(res);
3338
3112
  super(props.message);
@@ -3340,7 +3114,7 @@
3340
3114
  Object.assign(this, props);
3341
3115
  }
3342
3116
  }
3343
- class ServerError extends makeErrorExports.BaseError {
3117
+ class ServerError extends Error {
3344
3118
  constructor(res) {
3345
3119
  const props = extractErrorProps(res);
3346
3120
  super(props.message);
@@ -3506,60 +3280,50 @@
3506
3280
  }
3507
3281
  return tag;
3508
3282
  };
3509
- const enc = encodeURIComponent;
3510
3283
  var encodeQueryString = _ref => {
3511
3284
  let {
3512
3285
  query,
3513
3286
  params = {},
3514
3287
  options = {}
3515
3288
  } = _ref;
3289
+ const searchParams = new URLSearchParams();
3516
3290
  const {
3517
3291
  tag,
3518
3292
  ...opts
3519
3293
  } = options;
3520
- const q = "query=".concat(enc(query));
3521
- const base = tag ? "?tag=".concat(enc(tag), "&").concat(q) : "?".concat(q);
3522
- const qString = Object.keys(params).reduce((qs, param) => "".concat(qs, "&").concat(enc("$".concat(param)), "=").concat(enc(JSON.stringify(params[param]))), base);
3523
- return Object.keys(opts).reduce((qs, option) => {
3524
- return options[option] ? "".concat(qs, "&").concat(enc(option), "=").concat(enc(options[option])) : qs;
3525
- }, qString);
3294
+ if (tag) searchParams.set("tag", tag);
3295
+ searchParams.set("query", query);
3296
+ for (const [key, value] of Object.entries(params)) {
3297
+ searchParams.set("$".concat(key), JSON.stringify(value));
3298
+ }
3299
+ for (const [key, value] of Object.entries(opts)) {
3300
+ if (value) searchParams.set(key, "".concat(value));
3301
+ }
3302
+ return "?".concat(searchParams);
3526
3303
  };
3527
- var __accessCheck$7 = (obj, member, msg) => {
3304
+ var __accessCheck$6 = (obj, member, msg) => {
3528
3305
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
3529
3306
  };
3530
- var __privateGet$7 = (obj, member, getter) => {
3531
- __accessCheck$7(obj, member, "read from private field");
3307
+ var __privateGet$6 = (obj, member, getter) => {
3308
+ __accessCheck$6(obj, member, "read from private field");
3532
3309
  return getter ? getter.call(obj) : member.get(obj);
3533
3310
  };
3534
- var __privateAdd$7 = (obj, member, value) => {
3311
+ var __privateAdd$6 = (obj, member, value) => {
3535
3312
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3536
3313
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3537
3314
  };
3538
- var __privateSet$7 = (obj, member, value, setter) => {
3539
- __accessCheck$7(obj, member, "write to private field");
3315
+ var __privateSet$6 = (obj, member, value, setter) => {
3316
+ __accessCheck$6(obj, member, "write to private field");
3540
3317
  setter ? setter.call(obj, value) : member.set(obj, value);
3541
3318
  return value;
3542
3319
  };
3543
- var _client$6, _client2$6;
3320
+ var _client$5, _client2$5;
3544
3321
  class BasePatch {
3545
3322
  constructor(selection) {
3546
3323
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3547
3324
  this.selection = selection;
3548
3325
  this.operations = operations;
3549
3326
  }
3550
- /**
3551
- * DEPRECATED: Don't use.
3552
- * The operation is added to the current patch, ready to be commited by `commit()`
3553
- *
3554
- * @deprecated - Don't use.
3555
- * @param attrs - Attributes to replace
3556
- */
3557
- replace(attrs) {
3558
- validateObject("replace", attrs);
3559
- return this._set("set", {
3560
- $: attrs
3561
- });
3562
- }
3563
3327
  /**
3564
3328
  * Sets the given attributes to the document. Does NOT merge objects.
3565
3329
  * The operation is added to the current patch, ready to be commited by `commit()`
@@ -3713,8 +3477,8 @@
3713
3477
  const _ObservablePatch = class extends BasePatch {
3714
3478
  constructor(selection, operations, client) {
3715
3479
  super(selection, operations);
3716
- __privateAdd$7(this, _client$6, void 0);
3717
- __privateSet$7(this, _client$6, client);
3480
+ __privateAdd$6(this, _client$5, void 0);
3481
+ __privateSet$6(this, _client$5, client);
3718
3482
  }
3719
3483
  /**
3720
3484
  * Clones the patch
@@ -3722,10 +3486,10 @@
3722
3486
  clone() {
3723
3487
  return new _ObservablePatch(this.selection, {
3724
3488
  ...this.operations
3725
- }, __privateGet$7(this, _client$6));
3489
+ }, __privateGet$6(this, _client$5));
3726
3490
  }
3727
3491
  commit(options) {
3728
- if (!__privateGet$7(this, _client$6)) {
3492
+ if (!__privateGet$6(this, _client$5)) {
3729
3493
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
3730
3494
  }
3731
3495
  const returnFirst = typeof this.selection === "string";
@@ -3733,18 +3497,18 @@
3733
3497
  returnFirst,
3734
3498
  returnDocuments: true
3735
3499
  }, options);
3736
- return __privateGet$7(this, _client$6).mutate({
3500
+ return __privateGet$6(this, _client$5).mutate({
3737
3501
  patch: this.serialize()
3738
3502
  }, opts);
3739
3503
  }
3740
3504
  };
3741
3505
  let ObservablePatch = _ObservablePatch;
3742
- _client$6 = new WeakMap();
3506
+ _client$5 = new WeakMap();
3743
3507
  const _Patch = class extends BasePatch {
3744
3508
  constructor(selection, operations, client) {
3745
3509
  super(selection, operations);
3746
- __privateAdd$7(this, _client2$6, void 0);
3747
- __privateSet$7(this, _client2$6, client);
3510
+ __privateAdd$6(this, _client2$5, void 0);
3511
+ __privateSet$6(this, _client2$5, client);
3748
3512
  }
3749
3513
  /**
3750
3514
  * Clones the patch
@@ -3752,10 +3516,10 @@
3752
3516
  clone() {
3753
3517
  return new _Patch(this.selection, {
3754
3518
  ...this.operations
3755
- }, __privateGet$7(this, _client2$6));
3519
+ }, __privateGet$6(this, _client2$5));
3756
3520
  }
3757
3521
  commit(options) {
3758
- if (!__privateGet$7(this, _client2$6)) {
3522
+ if (!__privateGet$6(this, _client2$5)) {
3759
3523
  throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");
3760
3524
  }
3761
3525
  const returnFirst = typeof this.selection === "string";
@@ -3763,30 +3527,30 @@
3763
3527
  returnFirst,
3764
3528
  returnDocuments: true
3765
3529
  }, options);
3766
- return __privateGet$7(this, _client2$6).mutate({
3530
+ return __privateGet$6(this, _client2$5).mutate({
3767
3531
  patch: this.serialize()
3768
3532
  }, opts);
3769
3533
  }
3770
3534
  };
3771
3535
  let Patch = _Patch;
3772
- _client2$6 = new WeakMap();
3773
- var __accessCheck$6 = (obj, member, msg) => {
3536
+ _client2$5 = new WeakMap();
3537
+ var __accessCheck$5 = (obj, member, msg) => {
3774
3538
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
3775
3539
  };
3776
- var __privateGet$6 = (obj, member, getter) => {
3777
- __accessCheck$6(obj, member, "read from private field");
3540
+ var __privateGet$5 = (obj, member, getter) => {
3541
+ __accessCheck$5(obj, member, "read from private field");
3778
3542
  return getter ? getter.call(obj) : member.get(obj);
3779
3543
  };
3780
- var __privateAdd$6 = (obj, member, value) => {
3544
+ var __privateAdd$5 = (obj, member, value) => {
3781
3545
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
3782
3546
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3783
3547
  };
3784
- var __privateSet$6 = (obj, member, value, setter) => {
3785
- __accessCheck$6(obj, member, "write to private field");
3548
+ var __privateSet$5 = (obj, member, value, setter) => {
3549
+ __accessCheck$5(obj, member, "write to private field");
3786
3550
  setter ? setter.call(obj, value) : member.set(obj, value);
3787
3551
  return value;
3788
3552
  };
3789
- var _client$5, _client2$5;
3553
+ var _client$4, _client2$4;
3790
3554
  const defaultMutateOptions = {
3791
3555
  returnDocuments: false
3792
3556
  };
@@ -3885,20 +3649,20 @@
3885
3649
  const _Transaction = class extends BaseTransaction {
3886
3650
  constructor(operations, client, transactionId) {
3887
3651
  super(operations, transactionId);
3888
- __privateAdd$6(this, _client$5, void 0);
3889
- __privateSet$6(this, _client$5, client);
3652
+ __privateAdd$5(this, _client$4, void 0);
3653
+ __privateSet$5(this, _client$4, client);
3890
3654
  }
3891
3655
  /**
3892
3656
  * Clones the transaction
3893
3657
  */
3894
3658
  clone() {
3895
- return new _Transaction([...this.operations], __privateGet$6(this, _client$5), this.trxId);
3659
+ return new _Transaction([...this.operations], __privateGet$5(this, _client$4), this.trxId);
3896
3660
  }
3897
3661
  commit(options) {
3898
- if (!__privateGet$6(this, _client$5)) {
3662
+ if (!__privateGet$5(this, _client$4)) {
3899
3663
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
3900
3664
  }
3901
- return __privateGet$6(this, _client$5).mutate(this.serialize(), Object.assign({
3665
+ return __privateGet$5(this, _client$4).mutate(this.serialize(), Object.assign({
3902
3666
  transactionId: this.trxId
3903
3667
  }, defaultMutateOptions, options || {}));
3904
3668
  }
@@ -3911,7 +3675,7 @@
3911
3675
  });
3912
3676
  }
3913
3677
  if (isBuilder) {
3914
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
3678
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
3915
3679
  if (!(patch instanceof Patch)) {
3916
3680
  throw new Error("function passed to `patch()` must return the patch");
3917
3681
  }
@@ -3928,24 +3692,24 @@
3928
3692
  }
3929
3693
  };
3930
3694
  let Transaction = _Transaction;
3931
- _client$5 = new WeakMap();
3695
+ _client$4 = new WeakMap();
3932
3696
  const _ObservableTransaction = class extends BaseTransaction {
3933
3697
  constructor(operations, client, transactionId) {
3934
3698
  super(operations, transactionId);
3935
- __privateAdd$6(this, _client2$5, void 0);
3936
- __privateSet$6(this, _client2$5, client);
3699
+ __privateAdd$5(this, _client2$4, void 0);
3700
+ __privateSet$5(this, _client2$4, client);
3937
3701
  }
3938
3702
  /**
3939
3703
  * Clones the transaction
3940
3704
  */
3941
3705
  clone() {
3942
- return new _ObservableTransaction([...this.operations], __privateGet$6(this, _client2$5), this.trxId);
3706
+ return new _ObservableTransaction([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
3943
3707
  }
3944
3708
  commit(options) {
3945
- if (!__privateGet$6(this, _client2$5)) {
3709
+ if (!__privateGet$5(this, _client2$4)) {
3946
3710
  throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");
3947
3711
  }
3948
- return __privateGet$6(this, _client2$5).mutate(this.serialize(), Object.assign({
3712
+ return __privateGet$5(this, _client2$4).mutate(this.serialize(), Object.assign({
3949
3713
  transactionId: this.trxId
3950
3714
  }, defaultMutateOptions, options || {}));
3951
3715
  }
@@ -3958,7 +3722,7 @@
3958
3722
  });
3959
3723
  }
3960
3724
  if (isBuilder) {
3961
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$5)));
3725
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
3962
3726
  if (!(patch instanceof ObservablePatch)) {
3963
3727
  throw new Error("function passed to `patch()` must return the patch");
3964
3728
  }
@@ -3975,7 +3739,7 @@
3975
3739
  }
3976
3740
  };
3977
3741
  let ObservableTransaction = _ObservableTransaction;
3978
- _client2$5 = new WeakMap();
3742
+ _client2$4 = new WeakMap();
3979
3743
  const excludeFalsey = (param, defValue) => {
3980
3744
  const value = typeof param === "undefined" ? defValue : param;
3981
3745
  return param === false ? void 0 : value;
@@ -4123,7 +3887,9 @@
4123
3887
  const reqOptions = getRequestOptions(config, Object.assign({}, options, {
4124
3888
  url: _getUrl(client, uri, useCdn)
4125
3889
  }));
4126
- return new Observable(subscriber => httpRequest(reqOptions, config.requester).subscribe(subscriber));
3890
+ return new Observable(subscriber =>
3891
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- the typings thinks it's optional because it's not required to specify it when calling createClient, but it's always defined in practice since SanityClient provides a default
3892
+ httpRequest(reqOptions, config.requester).subscribe(subscriber));
4127
3893
  }
4128
3894
  function _request(client, httpRequest, options) {
4129
3895
  const observable = _requestObservable(client, httpRequest, options).pipe(filter(event => event.type === "response"), map(event => event.body));
@@ -4145,50 +3911,50 @@
4145
3911
  const base = canUseCdn ? cdnUrl : url;
4146
3912
  return "".concat(base, "/").concat(uri.replace(/^\//, ""));
4147
3913
  }
4148
- var __accessCheck$5 = (obj, member, msg) => {
3914
+ var __accessCheck$4 = (obj, member, msg) => {
4149
3915
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
4150
3916
  };
4151
- var __privateGet$5 = (obj, member, getter) => {
4152
- __accessCheck$5(obj, member, "read from private field");
3917
+ var __privateGet$4 = (obj, member, getter) => {
3918
+ __accessCheck$4(obj, member, "read from private field");
4153
3919
  return getter ? getter.call(obj) : member.get(obj);
4154
3920
  };
4155
- var __privateAdd$5 = (obj, member, value) => {
3921
+ var __privateAdd$4 = (obj, member, value) => {
4156
3922
  if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
4157
3923
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4158
3924
  };
4159
- var __privateSet$5 = (obj, member, value, setter) => {
4160
- __accessCheck$5(obj, member, "write to private field");
3925
+ var __privateSet$4 = (obj, member, value, setter) => {
3926
+ __accessCheck$4(obj, member, "write to private field");
4161
3927
  setter ? setter.call(obj, value) : member.set(obj, value);
4162
3928
  return value;
4163
3929
  };
4164
- var _client$4, _httpRequest$5, _client2$4, _httpRequest2$5;
3930
+ var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
4165
3931
  class ObservableAssetsClient {
4166
3932
  constructor(client, httpRequest) {
4167
- __privateAdd$5(this, _client$4, void 0);
4168
- __privateAdd$5(this, _httpRequest$5, void 0);
4169
- __privateSet$5(this, _client$4, client);
4170
- __privateSet$5(this, _httpRequest$5, httpRequest);
3933
+ __privateAdd$4(this, _client$3, void 0);
3934
+ __privateAdd$4(this, _httpRequest$4, void 0);
3935
+ __privateSet$4(this, _client$3, client);
3936
+ __privateSet$4(this, _httpRequest$4, httpRequest);
4171
3937
  }
4172
3938
  upload(assetType, body, options) {
4173
- return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$5), assetType, body, options);
3939
+ return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
4174
3940
  }
4175
3941
  }
4176
- _client$4 = new WeakMap();
4177
- _httpRequest$5 = new WeakMap();
3942
+ _client$3 = new WeakMap();
3943
+ _httpRequest$4 = new WeakMap();
4178
3944
  class AssetsClient {
4179
3945
  constructor(client, httpRequest) {
4180
- __privateAdd$5(this, _client2$4, void 0);
4181
- __privateAdd$5(this, _httpRequest2$5, void 0);
4182
- __privateSet$5(this, _client2$4, client);
4183
- __privateSet$5(this, _httpRequest2$5, httpRequest);
3946
+ __privateAdd$4(this, _client2$3, void 0);
3947
+ __privateAdd$4(this, _httpRequest2$4, void 0);
3948
+ __privateSet$4(this, _client2$3, client);
3949
+ __privateSet$4(this, _httpRequest2$4, httpRequest);
4184
3950
  }
4185
3951
  upload(assetType, body, options) {
4186
- const observable = _upload(__privateGet$5(this, _client2$4), __privateGet$5(this, _httpRequest2$5), assetType, body, options);
3952
+ const observable = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
4187
3953
  return lastValueFrom(observable.pipe(filter(event => event.type === "response"), map(event => event.body.document)));
4188
3954
  }
4189
3955
  }
4190
- _client2$4 = new WeakMap();
4191
- _httpRequest2$5 = new WeakMap();
3956
+ _client2$3 = new WeakMap();
3957
+ _httpRequest2$4 = new WeakMap();
4192
3958
  function _upload(client, httpRequest, assetType, body) {
4193
3959
  let opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
4194
3960
  validateAssetType(assetType);
@@ -4242,78 +4008,7 @@
4242
4008
  contentType: file.type
4243
4009
  }, opts);
4244
4010
  }
4245
- var __accessCheck$4 = (obj, member, msg) => {
4246
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
4247
- };
4248
- var __privateGet$4 = (obj, member, getter) => {
4249
- __accessCheck$4(obj, member, "read from private field");
4250
- return getter ? getter.call(obj) : member.get(obj);
4251
- };
4252
- var __privateAdd$4 = (obj, member, value) => {
4253
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
4254
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
4255
- };
4256
- var __privateSet$4 = (obj, member, value, setter) => {
4257
- __accessCheck$4(obj, member, "write to private field");
4258
- setter ? setter.call(obj, value) : member.set(obj, value);
4259
- return value;
4260
- };
4261
- var _client$3, _httpRequest$4, _client2$3, _httpRequest2$4;
4262
- class ObservableAuthClient {
4263
- constructor(client, httpRequest) {
4264
- __privateAdd$4(this, _client$3, void 0);
4265
- __privateAdd$4(this, _httpRequest$4, void 0);
4266
- __privateSet$4(this, _client$3, client);
4267
- __privateSet$4(this, _httpRequest$4, httpRequest);
4268
- }
4269
- /**
4270
- * Fetch available login providers
4271
- */
4272
- getLoginProviders() {
4273
- return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
4274
- uri: "/auth/providers"
4275
- });
4276
- }
4277
- /**
4278
- * Revoke the configured session/token
4279
- */
4280
- logout() {
4281
- return _request(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), {
4282
- uri: "/auth/logout",
4283
- method: "POST"
4284
- });
4285
- }
4286
- }
4287
- _client$3 = new WeakMap();
4288
- _httpRequest$4 = new WeakMap();
4289
- class AuthClient {
4290
- constructor(client, httpRequest) {
4291
- __privateAdd$4(this, _client2$3, void 0);
4292
- __privateAdd$4(this, _httpRequest2$4, void 0);
4293
- __privateSet$4(this, _client2$3, client);
4294
- __privateSet$4(this, _httpRequest2$4, httpRequest);
4295
- }
4296
- /**
4297
- * Fetch available login providers
4298
- */
4299
- getLoginProviders() {
4300
- return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
4301
- uri: "/auth/providers"
4302
- }));
4303
- }
4304
- /**
4305
- * Revoke the configured session/token
4306
- */
4307
- logout() {
4308
- return lastValueFrom(_request(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), {
4309
- uri: "/auth/logout",
4310
- method: "POST"
4311
- }));
4312
- }
4313
- }
4314
- _client2$3 = new WeakMap();
4315
- _httpRequest2$4 = new WeakMap();
4316
- const BASE_URL = "https://docs.sanity.io/help/";
4011
+ const BASE_URL = "https://www.sanity.io/help/";
4317
4012
  function generateHelpUrl(slug) {
4318
4013
  return BASE_URL + slug;
4319
4014
  }
@@ -4337,7 +4032,7 @@
4337
4032
  }
4338
4033
  return console.warn(message.join(" "), ...args);
4339
4034
  });
4340
- const printCdnWarning = createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and", "cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"), "."), "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating", "the client."]);
4035
+ const printCdnWarning = createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and", "cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"), " "), "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating", "the client."]);
4341
4036
  const printBrowserTokenWarning = createWarningPrinter(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.", "See ".concat(generateHelpUrl("js-client-browser-token"), " for more information and how to hide this warning.")]);
4342
4037
  const printNoApiVersionSpecifiedWarning = createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.", "See ".concat(generateHelpUrl("js-client-api-version"))]);
4343
4038
  const defaultCdnHost = "apicdn.sanity.io";
@@ -4815,10 +4510,13 @@
4815
4510
  */
4816
4511
  __privateAdd(this, _clientConfig, void 0);
4817
4512
  __privateAdd(this, _httpRequest, void 0);
4513
+ /**
4514
+ * Instance properties
4515
+ */
4516
+ this.listen = _listen;
4818
4517
  this.config(config);
4819
4518
  __privateSet(this, _httpRequest, httpRequest);
4820
4519
  this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
4821
- this.auth = new ObservableAuthClient(this, __privateGet(this, _httpRequest));
4822
4520
  this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest));
4823
4521
  this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest));
4824
4522
  this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
@@ -4869,7 +4567,7 @@
4869
4567
  * Fetch multiple documents in one request.
4870
4568
  * Should be used sparingly - performing a query is usually a better option.
4871
4569
  * The order/position of documents is preserved based on the original array of IDs.
4872
- * If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
4570
+ * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
4873
4571
  *
4874
4572
  * @param ids - Document IDs to fetch
4875
4573
  * @param options - Request options
@@ -4937,7 +4635,6 @@
4937
4635
  this.config(config);
4938
4636
  __privateSet(this, _httpRequest2, httpRequest);
4939
4637
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));
4940
- this.auth = new AuthClient(this, __privateGet(this, _httpRequest2));
4941
4638
  this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2));
4942
4639
  this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2));
4943
4640
  this.users = new UsersClient(this, __privateGet(this, _httpRequest2));
@@ -4992,7 +4689,7 @@
4992
4689
  * Fetch multiple documents in one request.
4993
4690
  * Should be used sparingly - performing a query is usually a better option.
4994
4691
  * The order/position of documents is preserved based on the original array of IDs.
4995
- * If a any of the documents are missing, they will be replaced by a `null` entry in the returned array
4692
+ * If any of the documents are missing, they will be replaced by a `null` entry in the returned array
4996
4693
  *
4997
4694
  * @param ids - Document IDs to fetch
4998
4695
  * @param options - Request options