@sanity/client 7.11.0 → 7.11.1-allow-live.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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getIt } from "get-it";
2
2
  import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from "get-it/middleware";
4
- import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY, map as map$1, firstValueFrom } from "rxjs";
4
+ import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, map as map$1, firstValueFrom } from "rxjs";
5
5
  import { isRecord } from "./_chunks-es/isRecord.js";
6
6
  import { stegaClean } from "./_chunks-es/stegaClean.js";
7
7
  import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
@@ -1263,7 +1263,6 @@ class LiveClient {
1263
1263
  includeDrafts = !1,
1264
1264
  tag: _tag
1265
1265
  } = {}) {
1266
- resourceGuard("live", this.#client.config());
1267
1266
  const {
1268
1267
  projectId,
1269
1268
  apiVersion: _apiVersion,
@@ -1296,26 +1295,31 @@ class LiveClient {
1296
1295
  "welcome",
1297
1296
  "reconnect",
1298
1297
  "goaway"
1299
- ]).pipe(
1300
- reconnectOnConnectionFailure(),
1301
- map((event) => {
1302
- if (event.type === "message") {
1303
- const { data, ...rest } = event;
1304
- return { ...rest, tags: data.tags };
1305
- }
1306
- return event;
1307
- })
1308
- ), checkCors = fetchObservable(url, {
1298
+ ]), checkCors = fetchObservable(url, {
1309
1299
  method: "OPTIONS",
1310
1300
  mode: "cors",
1311
1301
  credentials: esOptions.withCredentials ? "include" : "omit",
1312
1302
  headers: esOptions.headers
1313
1303
  }).pipe(
1314
- mergeMap(() => EMPTY),
1315
1304
  catchError(() => {
1316
1305
  throw new CorsOriginError({ projectId });
1317
1306
  })
1318
- ), observable2 = concat(checkCors, events).pipe(
1307
+ ), observable2 = events.pipe(
1308
+ reconnectOnConnectionFailure(),
1309
+ mergeMap((event) => event.type === "reconnect" ? checkCors.pipe(mergeMap(() => of(event))) : of(event)),
1310
+ catchError((err) => checkCors.pipe(
1311
+ mergeMap(() => {
1312
+ throw err;
1313
+ })
1314
+ )),
1315
+ map((event) => {
1316
+ if (event.type === "message") {
1317
+ const { data, ...rest } = event;
1318
+ return { ...rest, tags: data.tags };
1319
+ }
1320
+ return event;
1321
+ })
1322
+ ).pipe(
1319
1323
  finalize$1(() => eventsCache.delete(key)),
1320
1324
  shareReplayLatest({
1321
1325
  predicate: (event) => event.type === "welcome"
@@ -2664,7 +2668,7 @@ function defineDeprecatedCreateClient(createClient2) {
2664
2668
  return printNoDefaultExport(), createClient2(config);
2665
2669
  };
2666
2670
  }
2667
- var name = "@sanity/client", version = "7.11.0";
2671
+ var name = "@sanity/client", version = "7.11.1-allow-live.0";
2668
2672
  const middleware = [
2669
2673
  debug({ verbose: !0, namespace: "sanity:client" }),
2670
2674
  headers({ "User-Agent": `${name} ${version}` }),