@sanity/client 6.16.0 → 6.17.1-canary.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.
@@ -933,6 +933,57 @@ function cooerceError(err) {
933
933
  function extractErrorMessage(err) {
934
934
  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";
935
935
  }
936
+ function _syncTags(opts = {}) {
937
+ const path = _getDataUrl(this, "sync-tags"), url = new URL(this.getUrl(path, !0));
938
+ return opts.pos && url.searchParams.append("start", opts.pos), new rxjs.Observable((observer) => {
939
+ const controller = new AbortController(), { signal } = controller;
940
+ return fetch(url, { signal }).then(async (res) => {
941
+ if (!res.body)
942
+ throw new TypeError("Response body is not readable");
943
+ const reader = res.body.pipeThrough(new TextDecoderStream()).pipeThrough(splitStream(`
944
+ `)).pipeThrough(parseJSON()).getReader(), results = {
945
+ [Symbol.asyncIterator]() {
946
+ return {
947
+ next: () => reader.read()
948
+ };
949
+ }
950
+ };
951
+ for await (const chunk of results) {
952
+ if (signal.aborted)
953
+ break;
954
+ if (chunk.type === "error") {
955
+ observer.error(chunk);
956
+ break;
957
+ }
958
+ observer.next(chunk);
959
+ }
960
+ }).catch((err) => {
961
+ (err == null ? void 0 : err.name) !== "TimeoutError" && (err == null ? void 0 : err.name) !== "AbortError" && observer.error(err);
962
+ }), () => {
963
+ controller.abort();
964
+ };
965
+ });
966
+ }
967
+ function splitStream(splitOn) {
968
+ let buffer = "";
969
+ return new TransformStream({
970
+ transform(chunk, controller) {
971
+ buffer += chunk;
972
+ const parts = buffer.split(splitOn);
973
+ parts.slice(0, -1).forEach((part) => controller.enqueue(part)), buffer = parts[parts.length - 1];
974
+ },
975
+ flush(controller) {
976
+ buffer && controller.enqueue(buffer);
977
+ }
978
+ });
979
+ }
980
+ function parseJSON() {
981
+ return new TransformStream({
982
+ transform(chunk, controller) {
983
+ chunk && controller.enqueue(JSON.parse(chunk));
984
+ }
985
+ });
986
+ }
936
987
  var __accessCheck$3 = (obj, member, msg) => {
937
988
  if (!member.has(obj))
938
989
  throw TypeError("Cannot " + msg);
@@ -1137,7 +1188,7 @@ var __defProp2 = Object.defineProperty, __defNormalProp = (obj, key, value) => k
1137
1188
  }, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
1138
1189
  const _ObservableSanityClient = class _ObservableSanityClient2 {
1139
1190
  constructor(httpRequest, config = defaultConfig) {
1140
- __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));
1191
+ __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), __publicField(this, "syncTags", _syncTags), 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));
1141
1192
  }
1142
1193
  /**
1143
1194
  * Clone the client - returns a new instance
@@ -1266,7 +1317,7 @@ let ObservableSanityClient = _ObservableSanityClient;
1266
1317
  var _clientConfig2, _httpRequest2;
1267
1318
  const _SanityClient = class _SanityClient2 {
1268
1319
  constructor(httpRequest, config = defaultConfig) {
1269
- __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);
1320
+ __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), __publicField(this, "syncTags", _syncTags), 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);
1270
1321
  }
1271
1322
  /**
1272
1323
  * Clone the client - returns a new instance