@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.17.3-canary.7",
3
+ "version": "6.17.3",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -118,7 +118,7 @@
118
118
  },
119
119
  "dependencies": {
120
120
  "@sanity/eventsource": "^5.0.2",
121
- "get-it": "^8.4.28",
121
+ "get-it": "^8.4.29",
122
122
  "rxjs": "^7.0.0"
123
123
  },
124
124
  "devDependencies": {
@@ -126,7 +126,7 @@
126
126
  "@edge-runtime/vm": "^3.2.0",
127
127
  "@rollup/plugin-commonjs": "^25.0.7",
128
128
  "@rollup/plugin-node-resolve": "^15.2.3",
129
- "@sanity/pkg-utils": "^6.8.11",
129
+ "@sanity/pkg-utils": "^6.8.12",
130
130
  "@types/json-diff": "^1.0.3",
131
131
  "@types/node": "^20.8.8",
132
132
  "@typescript-eslint/eslint-plugin": "^7.8.0",
@@ -4,7 +4,6 @@ import {AssetsClient, ObservableAssetsClient} from './assets/AssetsClient'
4
4
  import {defaultConfig, initConfig} from './config'
5
5
  import * as dataMethods from './data/dataMethods'
6
6
  import {_listen} from './data/listen'
7
- import {LiveClient} from './data/live'
8
7
  import {ObservablePatch, Patch} from './data/patch'
9
8
  import {ObservableTransaction, Transaction} from './data/transaction'
10
9
  import {DatasetsClient, ObservableDatasetsClient} from './datasets/DatasetsClient'
@@ -44,7 +43,6 @@ export type {
44
43
  _listen,
45
44
  AssetsClient,
46
45
  DatasetsClient,
47
- LiveClient,
48
46
  ObservableAssetsClient,
49
47
  ObservableDatasetsClient,
50
48
  ObservableProjectsClient,
@@ -57,7 +55,6 @@ export type {
57
55
  export class ObservableSanityClient {
58
56
  assets: ObservableAssetsClient
59
57
  datasets: ObservableDatasetsClient
60
- live: LiveClient
61
58
  projects: ObservableProjectsClient
62
59
  users: ObservableUsersClient
63
60
 
@@ -79,7 +76,6 @@ export class ObservableSanityClient {
79
76
 
80
77
  this.assets = new ObservableAssetsClient(this, this.#httpRequest)
81
78
  this.datasets = new ObservableDatasetsClient(this, this.#httpRequest)
82
- this.live = new LiveClient(this)
83
79
  this.projects = new ObservableProjectsClient(this, this.#httpRequest)
84
80
  this.users = new ObservableUsersClient(this, this.#httpRequest)
85
81
  }
@@ -699,7 +695,6 @@ export class ObservableSanityClient {
699
695
  export class SanityClient {
700
696
  assets: AssetsClient
701
697
  datasets: DatasetsClient
702
- live: LiveClient
703
698
  projects: ProjectsClient
704
699
  users: UsersClient
705
700
 
@@ -726,7 +721,6 @@ export class SanityClient {
726
721
 
727
722
  this.assets = new AssetsClient(this, this.#httpRequest)
728
723
  this.datasets = new DatasetsClient(this, this.#httpRequest)
729
- this.live = new LiveClient(this)
730
724
  this.projects = new ProjectsClient(this, this.#httpRequest)
731
725
  this.users = new UsersClient(this, this.#httpRequest)
732
726
 
@@ -257,7 +257,7 @@ export function _dataRequest(
257
257
  const useGet = !isMutation && strQuery.length < getQuerySizeLimit
258
258
  const stringQuery = useGet ? strQuery : ''
259
259
  const returnFirst = options.returnFirst
260
- const {timeout, token, tag, headers, returnQuery, lastLiveEventId} = options
260
+ const {timeout, token, tag, headers, returnQuery} = options
261
261
 
262
262
  const uri = _getDataUrl(client, endpoint, stringQuery)
263
263
 
@@ -274,7 +274,6 @@ export function _dataRequest(
274
274
  returnQuery,
275
275
  perspective: options.perspective,
276
276
  resultSourceMap: options.resultSourceMap,
277
- lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
278
277
  canUseCdn: isQuery,
279
278
  signal: options.signal,
280
279
  fetch: options.fetch,
@@ -376,10 +375,6 @@ export function _requestObservable<R>(
376
375
  }
377
376
  }
378
377
 
379
- if (options.lastLiveEventId) {
380
- options.query = {...options.query, lastLiveEventId: options.lastLiveEventId}
381
- }
382
-
383
378
  if (options.returnQuery === false) {
384
379
  options.query = {returnQuery: 'false', ...options.query}
385
380
  }
@@ -171,10 +171,6 @@ export function _listen<R extends Record<string, Any> = Record<string, Any>>(
171
171
  .then((eventSource) => {
172
172
  if (eventSource) {
173
173
  es = eventSource
174
- // Handle race condition where the observer is unsubscribed before the EventSource is set up
175
- if (unsubscribed) {
176
- unsubscribe()
177
- }
178
174
  }
179
175
  })
180
176
  .catch((reason) => {
@@ -193,7 +189,7 @@ export function _listen<R extends Record<string, Any> = Record<string, Any>>(
193
189
  })
194
190
  }
195
191
 
196
- function parseEvent(event: MessageEvent) {
192
+ function parseEvent(event: Any) {
197
193
  try {
198
194
  const data = (event.data && JSON.parse(event.data)) || {}
199
195
  return Object.assign({type: event.type}, data)
package/src/types.ts CHANGED
@@ -306,7 +306,6 @@ export interface RequestObservableOptions extends Omit<RequestOptions, 'url'> {
306
306
  returnQuery?: boolean
307
307
  resultSourceMap?: boolean | 'withKeyArraySelector'
308
308
  perspective?: ClientPerspective
309
- lastLiveEventId?: string
310
309
  }
311
310
 
312
311
  /** @public */
@@ -480,8 +479,6 @@ export interface QueryParams {
480
479
  token?: never
481
480
  /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
482
481
  useCdn?: never
483
- /** @deprecated you're using a fetch option as a GROQ parameter, this is likely a mistake */
484
- lastLiveEventId?: never
485
482
  /* eslint-enable @typescript-eslint/no-explicit-any */
486
483
  }
487
484
 
@@ -746,8 +743,6 @@ export interface ResponseQueryOptions extends RequestOptions {
746
743
  // The `cache` and `next` options are specific to the Next.js App Router integration
747
744
  cache?: 'next' extends keyof RequestInit ? RequestInit['cache'] : never
748
745
  next?: ('next' extends keyof RequestInit ? RequestInit : never)['next']
749
- /** @alpha */
750
- lastLiveEventId?: string | string[] | null
751
746
  }
752
747
 
753
748
  /** @public */
@@ -790,8 +785,6 @@ export interface RawQueryResponse<R> {
790
785
  ms: number
791
786
  result: R
792
787
  resultSourceMap?: ContentSourceMap
793
- /** @alpha */
794
- syncTags?: SyncTag[]
795
788
  }
796
789
 
797
790
  /** @public */
@@ -1006,19 +999,6 @@ export interface ContentSourceMap {
1006
999
  paths: ContentSourceMapPaths
1007
1000
  }
1008
1001
 
1009
- /** @alpha */
1010
- export type SyncTag = `s1:${string}`
1011
- /** @alpha */
1012
- export interface LiveEventRestart {
1013
- type: 'restart'
1014
- }
1015
- /** @alpha */
1016
- export interface LiveEventMessage {
1017
- type: 'message'
1018
- id: string
1019
- tags: SyncTag[]
1020
- }
1021
-
1022
1002
  export type {
1023
1003
  ContentSourceMapParsedPath,
1024
1004
  ContentSourceMapParsedPathKeyedSegment,
@@ -166,45 +166,45 @@
166
166
  typeof result[key] > "u" ? result[key] = value : isArray$3(result[key]) ? result[key].push(value) : result[key] = [result[key], value];
167
167
  }
168
168
  return result;
169
- }, parseHeaders$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(parseHeaders), __defProp$5 = Object.defineProperty, __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$5 = (obj, key, value) => (__defNormalProp$5(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$8 = (obj, member, msg) => {
169
+ }, parseHeaders$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(parseHeaders), __defProp$5 = Object.defineProperty, __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$5 = (obj, key, value) => (__defNormalProp$5(obj, typeof key != "symbol" ? key + "" : key, value), value), __accessCheck$7 = (obj, member, msg) => {
170
170
  if (!member.has(obj))
171
171
  throw TypeError("Cannot " + msg);
172
- }, __privateGet$8 = (obj, member, getter) => (__accessCheck$8(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd$8 = (obj, member, value) => {
172
+ }, __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) => {
173
173
  if (member.has(obj))
174
174
  throw TypeError("Cannot add the same private member more than once");
175
175
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
176
- }, __privateSet$8 = (obj, member, value, setter) => (__accessCheck$8(obj, member, "write to private field"), member.set(obj, value), value), _method, _url, _resHeaders, _headers, _controller, _init, _useAbortSignal;
176
+ }, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value), _method, _url, _resHeaders, _headers, _controller, _init, _useAbortSignal;
177
177
  class FetchXhr {
178
178
  constructor() {
179
- __publicField$5(this, "onabort"), __publicField$5(this, "onerror"), __publicField$5(this, "onreadystatechange"), __publicField$5(this, "ontimeout"), __publicField$5(this, "readyState", 0), __publicField$5(this, "response"), __publicField$5(this, "responseText", ""), __publicField$5(this, "responseType", ""), __publicField$5(this, "status"), __publicField$5(this, "statusText"), __publicField$5(this, "withCredentials"), __privateAdd$8(this, _method, void 0), __privateAdd$8(this, _url, void 0), __privateAdd$8(this, _resHeaders, void 0), __privateAdd$8(this, _headers, {}), __privateAdd$8(this, _controller, void 0), __privateAdd$8(this, _init, {}), __privateAdd$8(this, _useAbortSignal, void 0);
179
+ __publicField$5(this, "onabort"), __publicField$5(this, "onerror"), __publicField$5(this, "onreadystatechange"), __publicField$5(this, "ontimeout"), __publicField$5(this, "readyState", 0), __publicField$5(this, "response"), __publicField$5(this, "responseText", ""), __publicField$5(this, "responseType", ""), __publicField$5(this, "status"), __publicField$5(this, "statusText"), __publicField$5(this, "withCredentials"), __privateAdd$7(this, _method, void 0), __privateAdd$7(this, _url, void 0), __privateAdd$7(this, _resHeaders, void 0), __privateAdd$7(this, _headers, {}), __privateAdd$7(this, _controller, void 0), __privateAdd$7(this, _init, {}), __privateAdd$7(this, _useAbortSignal, void 0);
180
180
  }
181
181
  // eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
182
182
  open(method, url, _async) {
183
183
  var _a;
184
- __privateSet$8(this, _method, method), __privateSet$8(this, _url, url), __privateSet$8(this, _resHeaders, ""), this.readyState = 1, (_a = this.onreadystatechange) == null || _a.call(this), __privateSet$8(this, _controller, void 0);
184
+ __privateSet$7(this, _method, method), __privateSet$7(this, _url, url), __privateSet$7(this, _resHeaders, ""), this.readyState = 1, (_a = this.onreadystatechange) == null || _a.call(this), __privateSet$7(this, _controller, void 0);
185
185
  }
186
186
  abort() {
187
- __privateGet$8(this, _controller) && __privateGet$8(this, _controller).abort();
187
+ __privateGet$7(this, _controller) && __privateGet$7(this, _controller).abort();
188
188
  }
189
189
  getAllResponseHeaders() {
190
- return __privateGet$8(this, _resHeaders);
190
+ return __privateGet$7(this, _resHeaders);
191
191
  }
192
192
  setRequestHeader(name, value) {
193
- __privateGet$8(this, _headers)[name] = value;
193
+ __privateGet$7(this, _headers)[name] = value;
194
194
  }
195
195
  // Allow setting extra fetch init options, needed for runtimes such as Vercel Edge to set `cache` and other options in React Server Components
196
196
  setInit(init, useAbortSignal = !0) {
197
- __privateSet$8(this, _init, init), __privateSet$8(this, _useAbortSignal, useAbortSignal);
197
+ __privateSet$7(this, _init, init), __privateSet$7(this, _useAbortSignal, useAbortSignal);
198
198
  }
199
199
  send(body) {
200
200
  const textBody = this.responseType !== "arraybuffer", options = {
201
- ...__privateGet$8(this, _init),
202
- method: __privateGet$8(this, _method),
203
- headers: __privateGet$8(this, _headers),
201
+ ...__privateGet$7(this, _init),
202
+ method: __privateGet$7(this, _method),
203
+ headers: __privateGet$7(this, _headers),
204
204
  body
205
205
  };
206
- typeof AbortController == "function" && __privateGet$8(this, _useAbortSignal) && (__privateSet$8(this, _controller, new AbortController()), typeof EventTarget < "u" && __privateGet$8(this, _controller).signal instanceof EventTarget && (options.signal = __privateGet$8(this, _controller).signal)), typeof document < "u" && (options.credentials = this.withCredentials ? "include" : "omit"), fetch(__privateGet$8(this, _url), options).then((res) => (res.headers.forEach((value, key) => {
207
- __privateSet$8(this, _resHeaders, __privateGet$8(this, _resHeaders) + `${key}: ${value}\r
206
+ typeof AbortController == "function" && __privateGet$7(this, _useAbortSignal) && (__privateSet$7(this, _controller, new AbortController()), typeof EventTarget < "u" && __privateGet$7(this, _controller).signal instanceof EventTarget && (options.signal = __privateGet$7(this, _controller).signal)), typeof document < "u" && (options.credentials = this.withCredentials ? "include" : "omit"), fetch(__privateGet$7(this, _url), options).then((res) => (res.headers.forEach((value, key) => {
207
+ __privateSet$7(this, _resHeaders, __privateGet$7(this, _resHeaders) + `${key}: ${value}\r
208
208
  `);
209
209
  }), this.status = res.status, this.statusText = res.statusText, this.readyState = 3, textBody ? res.text() : res.arrayBuffer())).then((resBody) => {
210
210
  var _a;
@@ -1956,14 +1956,14 @@ ${selectionOpts}`);
1956
1956
  );
1957
1957
  return tag;
1958
1958
  };
1959
- 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) => {
1959
+ 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) => {
1960
1960
  if (!member.has(obj))
1961
1961
  throw TypeError("Cannot " + msg);
1962
- }, __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) => {
1962
+ }, __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) => {
1963
1963
  if (member.has(obj))
1964
1964
  throw TypeError("Cannot add the same private member more than once");
1965
1965
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1966
- }, __privateSet$7 = (obj, member, value, setter) => (__accessCheck$7(obj, member, "write to private field"), member.set(obj, value), value);
1966
+ }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
1967
1967
  class BasePatch {
1968
1968
  constructor(selection, operations = {}) {
1969
1969
  __publicField$2(this, "selection"), __publicField$2(this, "operations"), this.selection = selection, this.operations = operations;
@@ -2097,58 +2097,58 @@ ${selectionOpts}`);
2097
2097
  return this._assign(op, props, !1);
2098
2098
  }
2099
2099
  }
2100
- var _client$6;
2100
+ var _client$5;
2101
2101
  const _ObservablePatch = class _ObservablePatch2 extends BasePatch {
2102
2102
  constructor(selection, operations, client) {
2103
- super(selection, operations), __privateAdd$7(this, _client$6, void 0), __privateSet$7(this, _client$6, client);
2103
+ super(selection, operations), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
2104
2104
  }
2105
2105
  /**
2106
2106
  * Clones the patch
2107
2107
  */
2108
2108
  clone() {
2109
- return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$7(this, _client$6));
2109
+ return new _ObservablePatch2(this.selection, { ...this.operations }, __privateGet$6(this, _client$5));
2110
2110
  }
2111
2111
  commit(options) {
2112
- if (!__privateGet$7(this, _client$6))
2112
+ if (!__privateGet$6(this, _client$5))
2113
2113
  throw new Error(
2114
2114
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2115
2115
  );
2116
2116
  const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
2117
- return __privateGet$7(this, _client$6).mutate({ patch: this.serialize() }, opts);
2117
+ return __privateGet$6(this, _client$5).mutate({ patch: this.serialize() }, opts);
2118
2118
  }
2119
2119
  };
2120
- _client$6 = /* @__PURE__ */ new WeakMap();
2120
+ _client$5 = /* @__PURE__ */ new WeakMap();
2121
2121
  let ObservablePatch = _ObservablePatch;
2122
2122
  var _client2$5;
2123
2123
  const _Patch = class _Patch2 extends BasePatch {
2124
2124
  constructor(selection, operations, client) {
2125
- super(selection, operations), __privateAdd$7(this, _client2$5, void 0), __privateSet$7(this, _client2$5, client);
2125
+ super(selection, operations), __privateAdd$6(this, _client2$5, void 0), __privateSet$6(this, _client2$5, client);
2126
2126
  }
2127
2127
  /**
2128
2128
  * Clones the patch
2129
2129
  */
2130
2130
  clone() {
2131
- return new _Patch2(this.selection, { ...this.operations }, __privateGet$7(this, _client2$5));
2131
+ return new _Patch2(this.selection, { ...this.operations }, __privateGet$6(this, _client2$5));
2132
2132
  }
2133
2133
  commit(options) {
2134
- if (!__privateGet$7(this, _client2$5))
2134
+ if (!__privateGet$6(this, _client2$5))
2135
2135
  throw new Error(
2136
2136
  "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2137
2137
  );
2138
2138
  const returnFirst = typeof this.selection == "string", opts = Object.assign({ returnFirst, returnDocuments: !0 }, options);
2139
- return __privateGet$7(this, _client2$5).mutate({ patch: this.serialize() }, opts);
2139
+ return __privateGet$6(this, _client2$5).mutate({ patch: this.serialize() }, opts);
2140
2140
  }
2141
2141
  };
2142
2142
  _client2$5 = /* @__PURE__ */ new WeakMap();
2143
2143
  let Patch = _Patch;
2144
- 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) => {
2144
+ 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) => {
2145
2145
  if (!member.has(obj))
2146
2146
  throw TypeError("Cannot " + msg);
2147
- }, __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) => {
2147
+ }, __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) => {
2148
2148
  if (member.has(obj))
2149
2149
  throw TypeError("Cannot add the same private member more than once");
2150
2150
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2151
- }, __privateSet$6 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
2151
+ }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
2152
2152
  const defaultMutateOptions = { returnDocuments: !1 };
2153
2153
  class BaseTransaction {
2154
2154
  constructor(operations = [], transactionId) {
@@ -2217,23 +2217,23 @@ ${selectionOpts}`);
2217
2217
  return this.operations.push(mut), this;
2218
2218
  }
2219
2219
  }
2220
- var _client$5;
2220
+ var _client$4;
2221
2221
  const _Transaction = class _Transaction2 extends BaseTransaction {
2222
2222
  constructor(operations, client, transactionId) {
2223
- super(operations, transactionId), __privateAdd$6(this, _client$5, void 0), __privateSet$6(this, _client$5, client);
2223
+ super(operations, transactionId), __privateAdd$5(this, _client$4, void 0), __privateSet$5(this, _client$4, client);
2224
2224
  }
2225
2225
  /**
2226
2226
  * Clones the transaction
2227
2227
  */
2228
2228
  clone() {
2229
- return new _Transaction2([...this.operations], __privateGet$6(this, _client$5), this.trxId);
2229
+ return new _Transaction2([...this.operations], __privateGet$5(this, _client$4), this.trxId);
2230
2230
  }
2231
2231
  commit(options) {
2232
- if (!__privateGet$6(this, _client$5))
2232
+ if (!__privateGet$5(this, _client$4))
2233
2233
  throw new Error(
2234
2234
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
2235
2235
  );
2236
- return __privateGet$6(this, _client$5).mutate(
2236
+ return __privateGet$5(this, _client$4).mutate(
2237
2237
  this.serialize(),
2238
2238
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
2239
2239
  );
@@ -2243,7 +2243,7 @@ ${selectionOpts}`);
2243
2243
  if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch)
2244
2244
  return this._add({ patch: patchOrDocumentId.serialize() });
2245
2245
  if (isBuilder) {
2246
- const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$6(this, _client$5)));
2246
+ const patch = patchOps(new Patch(patchOrDocumentId, {}, __privateGet$5(this, _client$4)));
2247
2247
  if (!(patch instanceof Patch))
2248
2248
  throw new Error("function passed to `patch()` must return the patch");
2249
2249
  return this._add({ patch: patch.serialize() });
@@ -2251,25 +2251,25 @@ ${selectionOpts}`);
2251
2251
  return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
2252
2252
  }
2253
2253
  };
2254
- _client$5 = /* @__PURE__ */ new WeakMap();
2254
+ _client$4 = /* @__PURE__ */ new WeakMap();
2255
2255
  let Transaction = _Transaction;
2256
2256
  var _client2$4;
2257
2257
  const _ObservableTransaction = class _ObservableTransaction2 extends BaseTransaction {
2258
2258
  constructor(operations, client, transactionId) {
2259
- super(operations, transactionId), __privateAdd$6(this, _client2$4, void 0), __privateSet$6(this, _client2$4, client);
2259
+ super(operations, transactionId), __privateAdd$5(this, _client2$4, void 0), __privateSet$5(this, _client2$4, client);
2260
2260
  }
2261
2261
  /**
2262
2262
  * Clones the transaction
2263
2263
  */
2264
2264
  clone() {
2265
- return new _ObservableTransaction2([...this.operations], __privateGet$6(this, _client2$4), this.trxId);
2265
+ return new _ObservableTransaction2([...this.operations], __privateGet$5(this, _client2$4), this.trxId);
2266
2266
  }
2267
2267
  commit(options) {
2268
- if (!__privateGet$6(this, _client2$4))
2268
+ if (!__privateGet$5(this, _client2$4))
2269
2269
  throw new Error(
2270
2270
  "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
2271
2271
  );
2272
- return __privateGet$6(this, _client2$4).mutate(
2272
+ return __privateGet$5(this, _client2$4).mutate(
2273
2273
  this.serialize(),
2274
2274
  Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
2275
2275
  );
@@ -2279,7 +2279,7 @@ ${selectionOpts}`);
2279
2279
  if (typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof ObservablePatch)
2280
2280
  return this._add({ patch: patchOrDocumentId.serialize() });
2281
2281
  if (isBuilder) {
2282
- const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$6(this, _client2$4)));
2282
+ const patch = patchOps(new ObservablePatch(patchOrDocumentId, {}, __privateGet$5(this, _client2$4)));
2283
2283
  if (!(patch instanceof ObservablePatch))
2284
2284
  throw new Error("function passed to `patch()` must return the patch");
2285
2285
  return this._add({ patch: patch.serialize() });
@@ -2487,7 +2487,7 @@ ${selectionOpts}`);
2487
2487
  return _dataRequest(client, httpRequest, "mutate", { mutations: muts, transactionId }, options);
2488
2488
  }
2489
2489
  function _dataRequest(client, httpRequest, endpoint, body, options = {}) {
2490
- 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 = {
2490
+ 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 = {
2491
2491
  method: useGet ? "GET" : "POST",
2492
2492
  uri,
2493
2493
  json: !0,
@@ -2500,7 +2500,6 @@ ${selectionOpts}`);
2500
2500
  returnQuery,
2501
2501
  perspective: options.perspective,
2502
2502
  resultSourceMap: options.resultSourceMap,
2503
- lastLiveEventId: Array.isArray(lastLiveEventId) ? lastLiveEventId[0] : lastLiveEventId,
2504
2503
  canUseCdn: isQuery,
2505
2504
  signal: options.signal,
2506
2505
  fetch: options.fetch,
@@ -2538,7 +2537,7 @@ ${selectionOpts}`);
2538
2537
  const resultSourceMap = (_b = options.resultSourceMap) != null ? _b : config.resultSourceMap;
2539
2538
  resultSourceMap !== void 0 && resultSourceMap !== !1 && (options.query = { resultSourceMap, ...options.query });
2540
2539
  const perspective = options.perspective || config.perspective;
2541
- 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 });
2540
+ 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 });
2542
2541
  }
2543
2542
  const reqOptions = requestOptions(
2544
2543
  config,
@@ -2585,30 +2584,30 @@ ${selectionOpts}`);
2585
2584
  const error = new Error((_b = signal == null ? void 0 : signal.reason) != null ? _b : "The operation was aborted.");
2586
2585
  return error.name = "AbortError", error;
2587
2586
  }
2588
- var __accessCheck$5 = (obj, member, msg) => {
2587
+ var __accessCheck$4 = (obj, member, msg) => {
2589
2588
  if (!member.has(obj))
2590
2589
  throw TypeError("Cannot " + msg);
2591
- }, __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) => {
2590
+ }, __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) => {
2592
2591
  if (member.has(obj))
2593
2592
  throw TypeError("Cannot add the same private member more than once");
2594
2593
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2595
- }, __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value), _client$4, _httpRequest$4;
2594
+ }, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value), _client$3, _httpRequest$4;
2596
2595
  class ObservableAssetsClient {
2597
2596
  constructor(client, httpRequest) {
2598
- __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);
2597
+ __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);
2599
2598
  }
2600
2599
  upload(assetType, body, options) {
2601
- return _upload(__privateGet$5(this, _client$4), __privateGet$5(this, _httpRequest$4), assetType, body, options);
2600
+ return _upload(__privateGet$4(this, _client$3), __privateGet$4(this, _httpRequest$4), assetType, body, options);
2602
2601
  }
2603
2602
  }
2604
- _client$4 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
2603
+ _client$3 = /* @__PURE__ */ new WeakMap(), _httpRequest$4 = /* @__PURE__ */ new WeakMap();
2605
2604
  var _client2$3, _httpRequest2$4;
2606
2605
  class AssetsClient {
2607
2606
  constructor(client, httpRequest) {
2608
- __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);
2607
+ __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);
2609
2608
  }
2610
2609
  upload(assetType, body, options) {
2611
- const observable2 = _upload(__privateGet$5(this, _client2$3), __privateGet$5(this, _httpRequest2$4), assetType, body, options);
2610
+ const observable2 = _upload(__privateGet$4(this, _client2$3), __privateGet$4(this, _httpRequest2$4), assetType, body, options);
2612
2611
  return lastValueFrom(
2613
2612
  observable2.pipe(
2614
2613
  filter((event) => event.type === "response"),
@@ -2678,7 +2677,7 @@ ${selectionOpts}`);
2678
2677
  observer.error(cooerceError(err));
2679
2678
  }
2680
2679
  function onMessage(evt) {
2681
- const event = parseEvent$1(evt);
2680
+ const event = parseEvent(evt);
2682
2681
  return event instanceof Error ? observer.error(event) : observer.next(event);
2683
2682
  }
2684
2683
  function onDisconnect() {
@@ -2691,15 +2690,15 @@ ${selectionOpts}`);
2691
2690
  shouldEmitReconnect && observer.next({ type: "reconnect" });
2692
2691
  }
2693
2692
  async function getEventSource() {
2694
- const { default: EventSource2 } = await Promise.resolve().then(function () { return browser$2; });
2693
+ const { default: EventSource } = await Promise.resolve().then(function () { return browser$2; });
2695
2694
  if (unsubscribed)
2696
2695
  return;
2697
- const evs = new EventSource2(uri, esOptions);
2696
+ const evs = new EventSource(uri, esOptions);
2698
2697
  return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
2699
2698
  }
2700
2699
  function open() {
2701
2700
  getEventSource().then((eventSource) => {
2702
- eventSource && (es = eventSource, unsubscribed && unsubscribe());
2701
+ eventSource && (es = eventSource);
2703
2702
  }).catch((reason) => {
2704
2703
  observer.error(reason), stop();
2705
2704
  });
@@ -2710,7 +2709,7 @@ ${selectionOpts}`);
2710
2709
  return stop;
2711
2710
  });
2712
2711
  }
2713
- function parseEvent$1(event) {
2712
+ function parseEvent(event) {
2714
2713
  try {
2715
2714
  const data = event.data && JSON.parse(event.data) || {};
2716
2715
  return Object.assign({ type: event.type }, data);
@@ -2721,86 +2720,12 @@ ${selectionOpts}`);
2721
2720
  function cooerceError(err) {
2722
2721
  if (err instanceof Error)
2723
2722
  return err;
2724
- const evt = parseEvent$1(err);
2723
+ const evt = parseEvent(err);
2725
2724
  return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
2726
2725
  }
2727
2726
  function extractErrorMessage(err) {
2728
2727
  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";
2729
2728
  }
2730
- var __accessCheck$4 = (obj, member, msg) => {
2731
- if (!member.has(obj))
2732
- throw TypeError("Cannot " + msg);
2733
- }, __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) => {
2734
- if (member.has(obj))
2735
- throw TypeError("Cannot add the same private member more than once");
2736
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2737
- }, __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value), _client$3;
2738
- class LiveClient {
2739
- constructor(client) {
2740
- __privateAdd$4(this, _client$3, void 0), __privateSet$4(this, _client$3, client);
2741
- }
2742
- events() {
2743
- const path = _getDataUrl(__privateGet$4(this, _client$3), "live/events"), url = new URL(__privateGet$4(this, _client$3).getUrl(path, !1)), listenFor = ["restart", "message"];
2744
- return new Observable((observer) => {
2745
- let es, reconnectTimer, stopped = !1, unsubscribed = !1;
2746
- open();
2747
- function onError(evt) {
2748
- if (!stopped) {
2749
- if ("data" in evt)
2750
- try {
2751
- const event = parseEvent(evt);
2752
- observer.error(new Error(event.message, { cause: event }));
2753
- } catch (err) {
2754
- observer.error(err);
2755
- }
2756
- es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100));
2757
- }
2758
- }
2759
- function onMessage(evt) {
2760
- const event = parseEvent(evt);
2761
- return event instanceof Error ? observer.error(event) : observer.next(event);
2762
- }
2763
- function unsubscribe() {
2764
- if (es) {
2765
- es.removeEventListener("error", onError);
2766
- for (const type of listenFor)
2767
- es.removeEventListener(type, onMessage);
2768
- es.close();
2769
- }
2770
- }
2771
- async function getEventSource() {
2772
- const EventSourceImplementation = typeof EventSource > "u" ? (await Promise.resolve().then(function () { return browser$2; })).default : EventSource;
2773
- if (unsubscribed)
2774
- return;
2775
- const evs = new EventSourceImplementation(url.toString());
2776
- evs.addEventListener("error", onError);
2777
- for (const type of listenFor)
2778
- evs.addEventListener(type, onMessage);
2779
- return evs;
2780
- }
2781
- function open() {
2782
- getEventSource().then((eventSource) => {
2783
- eventSource && (es = eventSource, unsubscribed && unsubscribe());
2784
- }).catch((reason) => {
2785
- observer.error(reason), stop();
2786
- });
2787
- }
2788
- function stop() {
2789
- stopped = !0, unsubscribe(), unsubscribed = !0;
2790
- }
2791
- return stop;
2792
- });
2793
- }
2794
- }
2795
- _client$3 = /* @__PURE__ */ new WeakMap();
2796
- function parseEvent(event) {
2797
- try {
2798
- const data = event.data && JSON.parse(event.data) || {};
2799
- return { type: event.type, id: event.lastEventId, ...data };
2800
- } catch (err) {
2801
- return err;
2802
- }
2803
- }
2804
2729
  var __accessCheck$3 = (obj, member, msg) => {
2805
2730
  if (!member.has(obj))
2806
2731
  throw TypeError("Cannot " + msg);
@@ -3005,7 +2930,7 @@ ${selectionOpts}`);
3005
2930
  }, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
3006
2931
  const _ObservableSanityClient = class _ObservableSanityClient2 {
3007
2932
  constructor(httpRequest, config = defaultConfig) {
3008
- __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));
2933
+ __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));
3009
2934
  }
3010
2935
  /**
3011
2936
  * Clone the client - returns a new instance
@@ -3134,7 +3059,7 @@ ${selectionOpts}`);
3134
3059
  var _clientConfig2, _httpRequest2;
3135
3060
  const _SanityClient = class _SanityClient2 {
3136
3061
  constructor(httpRequest, config = defaultConfig) {
3137
- __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);
3062
+ __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);
3138
3063
  }
3139
3064
  /**
3140
3065
  * Clone the client - returns a new instance