@sanity/client 6.17.3-canary.7 → 6.17.3

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.
@@ -775,27 +775,6 @@ export declare type ListenParams = {
775
775
  [key: string]: Any
776
776
  }
777
777
 
778
- /**
779
- * @alpha
780
- */
781
- export declare class LiveClient {
782
- #private
783
- constructor(client: SanityClient | ObservableSanityClient)
784
- events(): Observable<LiveEventMessage | LiveEventRestart>
785
- }
786
-
787
- /** @alpha */
788
- export declare interface LiveEventMessage {
789
- type: 'message'
790
- id: string
791
- tags: SyncTag[]
792
- }
793
-
794
- /** @alpha */
795
- export declare interface LiveEventRestart {
796
- type: 'restart'
797
- }
798
-
799
778
  /** @public */
800
779
  export declare type Logger =
801
780
  | typeof console
@@ -1138,7 +1117,6 @@ export declare class ObservableSanityClient {
1138
1117
  #private
1139
1118
  assets: ObservableAssetsClient
1140
1119
  datasets: ObservableDatasetsClient
1141
- live: LiveClient
1142
1120
  projects: ObservableProjectsClient
1143
1121
  users: ObservableUsersClient
1144
1122
  /**
@@ -1836,8 +1814,6 @@ export declare interface QueryParams {
1836
1814
  token?: never
1837
1815
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1838
1816
  useCdn?: never
1839
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1840
- lastLiveEventId?: never
1841
1817
  }
1842
1818
 
1843
1819
  /**
@@ -1855,8 +1831,6 @@ export declare interface RawQueryResponse<R> {
1855
1831
  ms: number
1856
1832
  result: R
1857
1833
  resultSourceMap?: ContentSourceMap
1858
- /** @alpha */
1859
- syncTags?: SyncTag[]
1860
1834
  }
1861
1835
 
1862
1836
  /** @internal */
@@ -1903,7 +1877,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
1903
1877
  returnQuery?: boolean
1904
1878
  resultSourceMap?: boolean | 'withKeyArraySelector'
1905
1879
  perspective?: ClientPerspective
1906
- lastLiveEventId?: string
1907
1880
  }
1908
1881
 
1909
1882
  /** @public */
@@ -1940,8 +1913,6 @@ export declare interface ResponseQueryOptions extends RequestOptions {
1940
1913
  stega?: boolean | StegaConfig
1941
1914
  cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
1942
1915
  next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
1943
- /** @alpha */
1944
- lastLiveEventId?: string | string[] | null
1945
1916
  }
1946
1917
 
1947
1918
  /** @internal */
@@ -1962,7 +1933,6 @@ export declare class SanityClient {
1962
1933
  #private
1963
1934
  assets: AssetsClient
1964
1935
  datasets: DatasetsClient
1965
- live: LiveClient
1966
1936
  projects: ProjectsClient
1967
1937
  users: UsersClient
1968
1938
  /**
@@ -2625,9 +2595,6 @@ export {StudioBaseUrl}
2625
2595
 
2626
2596
  export {StudioUrl}
2627
2597
 
2628
- /** @alpha */
2629
- export declare type SyncTag = `s1:${string}`
2630
-
2631
2598
  /** @public */
2632
2599
  export declare class Transaction extends BaseTransaction {
2633
2600
  #private
@@ -775,27 +775,6 @@ export declare type ListenParams = {
775
775
  [key: string]: Any
776
776
  }
777
777
 
778
- /**
779
- * @alpha
780
- */
781
- export declare class LiveClient {
782
- #private
783
- constructor(client: SanityClient | ObservableSanityClient)
784
- events(): Observable<LiveEventMessage | LiveEventRestart>
785
- }
786
-
787
- /** @alpha */
788
- export declare interface LiveEventMessage {
789
- type: 'message'
790
- id: string
791
- tags: SyncTag[]
792
- }
793
-
794
- /** @alpha */
795
- export declare interface LiveEventRestart {
796
- type: 'restart'
797
- }
798
-
799
778
  /** @public */
800
779
  export declare type Logger =
801
780
  | typeof console
@@ -1138,7 +1117,6 @@ export declare class ObservableSanityClient {
1138
1117
  #private
1139
1118
  assets: ObservableAssetsClient
1140
1119
  datasets: ObservableDatasetsClient
1141
- live: LiveClient
1142
1120
  projects: ObservableProjectsClient
1143
1121
  users: ObservableUsersClient
1144
1122
  /**
@@ -1836,8 +1814,6 @@ export declare interface QueryParams {
1836
1814
  token?: never
1837
1815
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1838
1816
  useCdn?: never
1839
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
1840
- lastLiveEventId?: never
1841
1817
  }
1842
1818
 
1843
1819
  /**
@@ -1855,8 +1831,6 @@ export declare interface RawQueryResponse<R> {
1855
1831
  ms: number
1856
1832
  result: R
1857
1833
  resultSourceMap?: ContentSourceMap
1858
- /** @alpha */
1859
- syncTags?: SyncTag[]
1860
1834
  }
1861
1835
 
1862
1836
  /** @internal */
@@ -1903,7 +1877,6 @@ export declare interface RequestObservableOptions extends Omit<RequestOptions, '
1903
1877
  returnQuery?: boolean
1904
1878
  resultSourceMap?: boolean | 'withKeyArraySelector'
1905
1879
  perspective?: ClientPerspective
1906
- lastLiveEventId?: string
1907
1880
  }
1908
1881
 
1909
1882
  /** @public */
@@ -1940,8 +1913,6 @@ export declare interface ResponseQueryOptions extends RequestOptions {
1940
1913
  stega?: boolean | StegaConfig
1941
1914
  cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
1942
1915
  next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
1943
- /** @alpha */
1944
- lastLiveEventId?: string | string[] | null
1945
1916
  }
1946
1917
 
1947
1918
  /** @internal */
@@ -1962,7 +1933,6 @@ export declare class SanityClient {
1962
1933
  #private
1963
1934
  assets: AssetsClient
1964
1935
  datasets: DatasetsClient
1965
- live: LiveClient
1966
1936
  projects: ProjectsClient
1967
1937
  users: UsersClient
1968
1938
  /**
@@ -2625,9 +2595,6 @@ export {StudioBaseUrl}
2625
2595
 
2626
2596
  export {StudioUrl}
2627
2597
 
2628
- /** @alpha */
2629
- export declare type SyncTag = `s1:${string}`
2630
-
2631
2598
  /** @public */
2632
2599
  export declare class Transaction extends BaseTransaction {
2633
2600
  #private
@@ -144,14 +144,14 @@ const VALID_ASSET_TYPES = ["image", "file"], VALID_INSERT_LOCATIONS = ["before",
144
144
  );
145
145
  return tag;
146
146
  };
147
- var __defProp$2 = Object.defineProperty, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$2 = (obj, key, value) => (__defNormalProp$2(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$7 = (obj, member, msg) => {
147
+ var __defProp$2 = Object.defineProperty, __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$2 = (obj, key, value) => (__defNormalProp$2(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$6 = (obj, member, msg) => {
148
148
  if (!member.has(obj))
149
149
  throw TypeError("Cannot " + msg);
150
- }, __privateGet$7 = (obj, member, getter) => (__accessCheck$7(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$7 = (obj, member, value) => {
150
+ }, __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$6 = (obj, member, value) => {
151
151
  if (member.has(obj))
152
152
  throw TypeError("Cannot add the same private member more than once");
153
153
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
154
- }, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
154
+ }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
155
155
  class BasePatch {
156
156
  constructor(selection, operations = {}) {
157
157
  __publicField$2(this, "selection"), __publicField$2(this, "operations"), this.selection = selection, this.operations = operations;
@@ -285,58 +285,58 @@ class BasePatch {
285
285
  return this._assign(op, props, !1);
286
286
  }
287
287
  }
288
- var _client$6;
288
+ var _client$5;
289
289
  const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
290
290
  constructor(selection, operations, client) {
291
- super(selection, operations), __privateAdd$7(this, _client$6, void 0), __privateSet$7(this, _client$6, client);
291
+ super(selection, operations), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
292
292
  }
293
293
  /**
294
294
  * Clones the patch
295
295
  */
296
296
  clone() {
297
- return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$7(this, _client$6));
297
+ return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
298
298
  }
299
299
  commit(options) {
300
- if (!__privateGet$7(this, _client$6))
300
+ if (!__privateGet$6(this, _client$5))
301
301
  throw new Error(
302
302
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
303
303
  );
304
304
  const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
305
- return __privateGet$7(this, _client$6).mutate({ patch: this.serialize() }, opts);
305
+ return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
306
306
  }
307
307
  };
308
- _client$6 = /* @__PURE__ */ new WeakMap();
308
+ _client$5 = /* @__PURE__ */ new WeakMap();
309
309
  let ObservablePatch = _ObservablePatch;
310
310
  var _client2$5;
311
311
  const _Patch = class _Patch2 extends BasePatch {
312
312
  constructor(selection, operations, client) {
313
- super(selection, operations), __privateAdd$7(this, _client2$5, void 0), __privateSet$7(this, _client2$5, client);
313
+ super(selection, operations), __privateAdd$6(this, _client2$5, void 0), __privateSet$6(this, _client2$5, client);
314
314
  }
315
315
  /**
316
316
  * Clones the patch
317
317
  */
318
318
  clone() {
319
- return new _Patch2(this.selection, { ...this.operations }, __privateGet$7(this, _client2$5));
319
+ return new _Patch2(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
320
320
  }
321
321
  commit(options) {
322
- if (!__privateGet$7(this, _client2$5))
322
+ if (!__privateGet$6(this, _client2$5))
323
323
  throw new Error(
324
324
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
325
325
  );
326
326
  const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
327
- return __privateGet$7(this, _client2$5).mutate({ patch: this.serialize() }, opts);
327
+ return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
328
328
  }
329
329
  };
330
330
  _client2$5 = /* @__PURE__ */ new WeakMap();
331
331
  let Patch = _Patch;
332
- var __defProp$1 = Object.defineProperty, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1 = (obj, key, value) => (__defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$6 = (obj, member, msg) => {
332
+ var __defProp$1 = Object.defineProperty, __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1 = (obj, key, value) => (__defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$5 = (obj, member, msg) => {
333
333
  if (!member.has(obj))
334
334
  throw TypeError("Cannot " + msg);
335
- }, __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$6 = (obj, member, value) => {
335
+ }, __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$5 = (obj, member, value) => {
336
336
  if (member.has(obj))
337
337
  throw TypeError("Cannot add the same private member more than once");
338
338
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
339
- }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
339
+ }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
340
340
  const defaultMutateOptions = { returnDocuments: !1 };
341
341
  class BaseTransaction {
342
342
  constructor(operations = [], transactionId) {
@@ -405,23 +405,23 @@ class BaseTransaction {
405
405
  return this.operations.push(mut), this;
406
406
  }
407
407
  }
408
- var _client$5;
408
+ var _client$4;
409
409
  const _Transaction = class _Transaction2 extends BaseTransaction {
410
410
  constructor(operations, client, transactionId) {
411
- super(operations, transactionId), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
411
+ super(operations, transactionId), __privateAdd$5(this, _client$4, void 0), __privateSet$5(this, _client$4, client);
412
412
  }
413
413
  /**
414
414
  * Clones the transaction
415
415
  */
416
416
  clone() {
417
- return new _Transaction2([...this.operations], __privateGet$6(this, _client$5), this.trxId);
417
+ return new _Transaction2([...this.operations], __privateGet$5(this, _client$4), this.trxId);
418
418
  }
419
419
  commit(options) {
420
- if (!__privateGet$6(this, _client$5))
420
+ if (!__privateGet$5(this, _client$4))
421
421
  throw new Error(
422
422
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
423
423
  );
424
- return __privateGet$6(this, _client$5).mutate(
424
+ return __privateGet$5(this, _client$4).mutate(
425
425
  this.serialize(),
426
426
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
427
427
  );
@@ -431,7 +431,7 @@ const _Transaction = class _Transaction2 extends BaseTransaction {
431
431
  if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
432
432
  return this._add({ patch: patchOrDocumentId.serialize() });
433
433
  if (isBuilder) {
434
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
434
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
435
435
  if (!(patch instanceof Patch))
436
436
  throw new Error("function passed to `patch()` must return the patch");
437
437
  return this._add({ patch: patch.serialize() });
@@ -439,25 +439,25 @@ const _Transaction = class _Transaction2 extends BaseTransaction {
439
439
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
440
440
  }
441
441
  };
442
- _client$5 = /* @__PURE__ */ new WeakMap();
442
+ _client$4 = /* @__PURE__ */ new WeakMap();
443
443
  let Transaction = _Transaction;
444
444
  var _client2$4;
445
445
  const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
446
446
  constructor(operations, client, transactionId) {
447
- super(operations, transactionId), __privateAdd$6(this, _client2$4, void 0), __privateSet$6(this, _client2$4, client);
447
+ super(operations, transactionId), __privateAdd$5(this, _client2$4, void 0), __privateSet$5(this, _client2$4, client);
448
448
  }
449
449
  /**
450
450
  * Clones the transaction
451
451
  */
452
452
  clone() {
453
- return new _ObservableTransaction2([...this.operations], __privateGet$6(this, _client2$4), this.trxId);
453
+ return new _ObservableTransaction2([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
454
454
  }
455
455
  commit(options) {
456
- if (!__privateGet$6(this, _client2$4))
456
+ if (!__privateGet$5(this, _client2$4))
457
457
  throw new Error(
458
458
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
459
459
  );
460
- return __privateGet$6(this, _client2$4).mutate(
460
+ return __privateGet$5(this, _client2$4).mutate(
461
461
  this.serialize(),
462
462
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
463
463
  );
@@ -467,7 +467,7 @@ const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransac
467
467
  if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
468
468
  return this._add({ patch: patchOrDocumentId.serialize() });
469
469
  if (isBuilder) {
470
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$4)));
470
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
471
471
  if (!(patch instanceof ObservablePatch))
472
472
  throw new Error("function passed to `patch()` must return the patch");
473
473
  return this._add({ patch: patch.serialize() });
@@ -675,7 +675,7 @@ function _mutate(client, httpRequest, mutations, options) {
675
675
  return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
676
676
  }
677
677
  function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
678
- const isMutation = endpoint === "mutate", isQuery = endpoint === "query", strQuery = isMutation ? "" : encodeQueryString(body), useGet = !isMutation && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers, returnQuery, lastLiveEventId } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
678
+ const isMutation = endpoint === "mutate", isQuery = endpoint === "query", strQuery = isMutation ? "" : encodeQueryString(body), useGet = !isMutation && strQuery.length < getQuerySizeLimit, stringQuery = useGet ? strQuery : "", returnFirst = options.returnFirst, { timeout, token, tag, headers, returnQuery } = options, uri = _getDataUrl(client, endpoint, stringQuery), reqOptions = {
679
679
  method: useGet ? "GET" : "POST",
680
680
  uri,
681
681
  json: !0,
@@ -688,7 +688,6 @@ function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
688
688
  returnQuery,
689
689
  perspective: options.perspective,
690
690
  resultSourceMap: options.resultSourceMap,
691
- lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
692
691
  canUseCdn: isQuery,
693
692
  signal: options.signal,
694
693
  fetch: options.fetch,
@@ -726,7 +725,7 @@ function _requestObservable(client, httpRequest, options) {
726
725
  const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
727
726
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
728
727
  const perspective = options.perspective || config.perspective;
729
- typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.lastLiveEventId && (options.query = { ...options.query, lastLiveEventId: options.lastLiveEventId }), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
728
+ typeof perspective == "string" && perspective !== "raw" && (validateApiPerspective(perspective), options.query = { perspective, ...options.query }, perspective === "previewDrafts" && useCdn && (useCdn = !1, printCdnPreviewDraftsWarning())), options.returnQuery === !1 && (options.query = { returnQuery: "false", ...options.query });
730
729
  }
731
730
  const reqOptions = requestOptions(
732
731
  config,
@@ -773,30 +772,30 @@ function _createAbortError(signal) {
773
772
  const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
774
773
  return error.name = "AbortError", error;
775
774
  }
776
- var __accessCheck$5 = (obj, member, msg) => {
775
+ var __accessCheck$4 = (obj, member, msg) => {
777
776
  if (!member.has(obj))
778
777
  throw TypeError("Cannot " + msg);
779
- }, __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$5 = (obj, member, value) => {
778
+ }, __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$4 = (obj, member, value) => {
780
779
  if (member.has(obj))
781
780
  throw TypeError("Cannot add the same private member more than once");
782
781
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
783
- }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
782
+ }, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value), _client$3, _httpRequest$4;
784
783
  class ObservableAssetsClient {
785
784
  constructor(client, httpRequest) {
786
- __privateAdd$5(this, _client$4, void 0), __privateAdd$5(this, _httpRequest$4, void 0), __privateSet$5(this, _client$4, client), __privateSet$5(this, _httpRequest$4, httpRequest);
785
+ __privateAdd$4(this, _client$3, void 0), __privateAdd$4(this, _httpRequest$4, void 0), __privateSet$4(this, _client$3, client), __privateSet$4(this, _httpRequest$4, httpRequest);
787
786
  }
788
787
  upload(assetType, body, options) {
789
- return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$4), assetType, body, options);
788
+ return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
790
789
  }
791
790
  }
792
- _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
791
+ _client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
793
792
  var _client2$3, _httpRequest2$4;
794
793
  class AssetsClient {
795
794
  constructor(client, httpRequest) {
796
- __privateAdd$5(this, _client2$3, void 0), __privateAdd$5(this, _httpRequest2$4, void 0), __privateSet$5(this, _client2$3, client), __privateSet$5(this, _httpRequest2$4, httpRequest);
795
+ __privateAdd$4(this, _client2$3, void 0), __privateAdd$4(this, _httpRequest2$4, void 0), __privateSet$4(this, _client2$3, client), __privateSet$4(this, _httpRequest2$4, httpRequest);
797
796
  }
798
797
  upload(assetType, body, options) {
799
- const observable2 = _upload(__privateGet$5(this, _client2$3), __privateGet$5(this, _httpRequest2$4), assetType, body, options);
798
+ const observable2 = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
800
799
  return lastValueFrom(
801
800
  observable2.pipe(
802
801
  filter((event) => event.type === "response"),
@@ -866,7 +865,7 @@ function _listen(query, params, opts = {}) {
866
865
  observer.error(cooerceError(err));
867
866
  }
868
867
  function onMessage(evt) {
869
- const event = parseEvent$1(evt);
868
+ const event = parseEvent(evt);
870
869
  return event instanceof Error ? observer.error(event) : observer.next(event);
871
870
  }
872
871
  function onDisconnect() {
@@ -879,15 +878,15 @@ function _listen(query, params, opts = {}) {
879
878
  shouldEmitReconnect && observer.next({ type: "reconnect" });
880
879
  }
881
880
  async function getEventSource() {
882
- const { default: EventSource2 } = await import("@sanity/eventsource");
881
+ const { default: EventSource } = await import("@sanity/eventsource");
883
882
  if (unsubscribed)
884
883
  return;
885
- const evs = new EventSource2(uri, esOptions);
884
+ const evs = new EventSource(uri, esOptions);
886
885
  return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
887
886
  }
888
887
  function open() {
889
888
  getEventSource().then((eventSource) => {
890
- eventSource && (es = eventSource, unsubscribed && unsubscribe());
889
+ eventSource && (es = eventSource);
891
890
  }).catch((reason) => {
892
891
  observer.error(reason), stop();
893
892
  });
@@ -898,7 +897,7 @@ function _listen(query, params, opts = {}) {
898
897
  return stop;
899
898
  });
900
899
  }
901
- function parseEvent$1(event) {
900
+ function parseEvent(event) {
902
901
  try {
903
902
  const data = event.data && JSON.parse(event.data) || {};
904
903
  return Object.assign({ type: event.type }, data);
@@ -909,86 +908,12 @@ function parseEvent$1(event) {
909
908
  function cooerceError(err) {
910
909
  if (err instanceof Error)
911
910
  return err;
912
- const evt = parseEvent$1(err);
911
+ const evt = parseEvent(err);
913
912
  return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
914
913
  }
915
914
  function extractErrorMessage(err) {
916
915
  return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
917
916
  }
918
- var __accessCheck$4 = (obj, member, msg) => {
919
- if (!member.has(obj))
920
- throw TypeError("Cannot " + msg);
921
- }, __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$4 = (obj, member, value) => {
922
- if (member.has(obj))
923
- throw TypeError("Cannot add the same private member more than once");
924
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
925
- }, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value), _client$3;
926
- class LiveClient {
927
- constructor(client) {
928
- __privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
929
- }
930
- events() {
931
- const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
932
- return new Observable((observer) => {
933
- let es, reconnectTimer, stopped = !1, unsubscribed = !1;
934
- open();
935
- function onError(evt) {
936
- if (!stopped) {
937
- if ("data" in evt)
938
- try {
939
- const event = parseEvent(evt);
940
- observer.error(new Error(event.message, { cause: event }));
941
- } catch (err) {
942
- observer.error(err);
943
- }
944
- es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100));
945
- }
946
- }
947
- function onMessage(evt) {
948
- const event = parseEvent(evt);
949
- return event instanceof Error ? observer.error(event) : observer.next(event);
950
- }
951
- function unsubscribe() {
952
- if (es) {
953
- es.removeEventListener("error", onError);
954
- for (const type of listenFor)
955
- es.removeEventListener(type, onMessage);
956
- es.close();
957
- }
958
- }
959
- async function getEventSource() {
960
- const EventSourceImplementation = typeof EventSource > "u" ? (await import("@sanity/eventsource")).default : EventSource;
961
- if (unsubscribed)
962
- return;
963
- const evs = new EventSourceImplementation(url.toString());
964
- evs.addEventListener("error", onError);
965
- for (const type of listenFor)
966
- evs.addEventListener(type, onMessage);
967
- return evs;
968
- }
969
- function open() {
970
- getEventSource().then((eventSource) => {
971
- eventSource && (es = eventSource, unsubscribed && unsubscribe());
972
- }).catch((reason) => {
973
- observer.error(reason), stop();
974
- });
975
- }
976
- function stop() {
977
- stopped = !0, unsubscribe(), unsubscribed = !0;
978
- }
979
- return stop;
980
- });
981
- }
982
- }
983
- _client$3 = /* @__PURE__ */ new WeakMap();
984
- function parseEvent(event) {
985
- try {
986
- const data = event.data && JSON.parse(event.data) || {};
987
- return { type: event.type, id: event.lastEventId, ...data };
988
- } catch (err) {
989
- return err;
990
- }
991
- }
992
917
  var __accessCheck$3 = (obj, member, msg) => {
993
918
  if (!member.has(obj))
994
919
  throw TypeError("Cannot " + msg);
@@ -1193,7 +1118,7 @@ var __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => ke
1193
1118
  }, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
1194
1119
  const _ObservableSanityClient = class _ObservableSanityClient2 {
1195
1120
  constructor(httpRequest, config = defaultConfig) {
1196
- __publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "live"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
1121
+ __publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
1197
1122
  }
1198
1123
  /**
1199
1124
  * Clone the client - returns a new instance
@@ -1322,7 +1247,7 @@ let ObservableSanityClient = _ObservableSanityClient;
1322
1247
  var _clientConfig2, _httpRequest2;
1323
1248
  const _SanityClient = class _SanityClient2 {
1324
1249
  constructor(httpRequest, config = defaultConfig) {
1325
- __publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "live"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
1250
+ __publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
1326
1251
  }
1327
1252
  /**
1328
1253
  * Clone the client - returns a new instance