@sanity/client 6.4.11 → 6.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.4.11",
3
+ "version": "6.5.0",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -72,7 +72,7 @@
72
72
  "test": "vitest",
73
73
  "type-check": "tsc --noEmit",
74
74
  "test:browser": "npm test -- --config ./vitest.browser.config.ts",
75
- "test:bun": "(cd runtimes/bun && bun wiptest)",
75
+ "test:bun": "bun test runtimes/bun",
76
76
  "test:deno": "deno test --allow-read --allow-net --allow-env --fail-fast --import-map=runtimes/deno/import_map.json runtimes/deno",
77
77
  "test:deno:update_import_map": "deno run --allow-read --allow-write runtimes/deno/update_import_map.ts",
78
78
  "posttest:deno:update_import_map": "npx prettier --write runtimes/deno/import_map.json",
@@ -95,39 +95,34 @@
95
95
  "rxjs": "^7.0.0"
96
96
  },
97
97
  "devDependencies": {
98
- "@edge-runtime/types": "^2.2.1",
99
- "@edge-runtime/vm": "^3.1.1",
100
- "@rollup/plugin-commonjs": "^25.0.4",
101
- "@rollup/plugin-node-resolve": "^15.2.1",
102
- "@sanity/pkg-utils": "^2.4.8",
103
- "@sanity/semantic-release-preset": "^4.1.4",
104
- "@types/node": "^20.5.9",
105
- "@typescript-eslint/eslint-plugin": "^6.6.0",
106
- "@typescript-eslint/parser": "^6.6.0",
107
- "@vitest/coverage-v8": "^0.34.3",
108
- "eslint": "^8.48.0",
98
+ "@edge-runtime/types": "^2.2.4",
99
+ "@edge-runtime/vm": "^3.1.4",
100
+ "@rollup/plugin-commonjs": "^25.0.5",
101
+ "@rollup/plugin-node-resolve": "^15.2.3",
102
+ "@sanity/pkg-utils": "^2.4.10",
103
+ "@types/node": "^20.8.4",
104
+ "@typescript-eslint/eslint-plugin": "^6.7.5",
105
+ "@typescript-eslint/parser": "^6.7.5",
106
+ "@vitest/coverage-v8": "^0.34.6",
107
+ "eslint": "^8.51.0",
109
108
  "eslint-config-prettier": "^9.0.0",
110
109
  "eslint-plugin-prettier": "^5.0.0",
111
110
  "eslint-plugin-simple-import-sort": "^10.0.0",
112
111
  "faucet": "^0.0.4",
113
- "happy-dom": "^10.11.2",
112
+ "happy-dom": "^12.9.1",
114
113
  "ls-engines": "^0.9.0",
115
114
  "nock": "^13.3.3",
116
115
  "prettier": "^3.0.3",
117
- "prettier-plugin-packagejson": "^2.4.5",
116
+ "prettier-plugin-packagejson": "^2.4.6",
118
117
  "rimraf": "^5.0.1",
119
- "rollup": "^3.29.0",
118
+ "rollup": "^3.29.4",
120
119
  "sse-channel": "^4.0.0",
121
- "terser": "^5.19.4",
120
+ "terser": "^5.21.0",
122
121
  "typescript": "^5.2.2",
123
- "vitest": "^0.34.3",
122
+ "vitest": "^0.34.6",
124
123
  "vitest-github-actions-reporter": "^0.10.0"
125
124
  },
126
125
  "engines": {
127
126
  "node": ">=14.18"
128
- },
129
- "publishConfig": {
130
- "access": "public",
131
- "provenance": true
132
127
  }
133
128
  }
@@ -314,7 +314,7 @@ export function _requestObservable<R>(
314
314
  ? [config.requestTagPrefix, options.tag].join('.')
315
315
  : options.tag || config.requestTagPrefix
316
316
 
317
- if (tag) {
317
+ if (tag && options.tag !== null) {
318
318
  options.query = {tag: validate.requestTag(tag), ...options.query}
319
319
  }
320
320
 
@@ -47,7 +47,10 @@ export class ObservableDatasetsClient {
47
47
  * Fetch a list of datasets for the configured project
48
48
  */
49
49
  list(): Observable<DatasetsResponse> {
50
- return _request<DatasetsResponse>(this.#client, this.#httpRequest, {uri: '/datasets'})
50
+ return _request<DatasetsResponse>(this.#client, this.#httpRequest, {
51
+ uri: '/datasets',
52
+ tag: null,
53
+ })
51
54
  }
52
55
  }
53
56
 
@@ -98,7 +101,7 @@ export class DatasetsClient {
98
101
  */
99
102
  list(): Promise<DatasetsResponse> {
100
103
  return lastValueFrom(
101
- _request<DatasetsResponse>(this.#client, this.#httpRequest, {uri: '/datasets'}),
104
+ _request<DatasetsResponse>(this.#client, this.#httpRequest, {uri: '/datasets', tag: null}),
102
105
  )
103
106
  }
104
107
  }
@@ -111,5 +114,10 @@ function _modify<R = unknown>(
111
114
  options?: {aclMode?: DatasetAclMode},
112
115
  ) {
113
116
  validate.dataset(name)
114
- return _request<R>(client, httpRequest, {method, uri: `/datasets/${name}`, body: options})
117
+ return _request<R>(client, httpRequest, {
118
+ method,
119
+ uri: `/datasets/${name}`,
120
+ body: options,
121
+ tag: null,
122
+ })
115
123
  }
@@ -219,15 +219,15 @@
219
219
  initMiddleware.forEach(request.use);
220
220
  return request;
221
221
  }
222
- var __defProp$5 = Object.defineProperty;
223
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, {
222
+ var __defProp$1 = Object.defineProperty;
223
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
224
224
  enumerable: true,
225
225
  configurable: true,
226
226
  writable: true,
227
227
  value
228
228
  }) : obj[key] = value;
229
- var __publicField$5 = (obj, key, value) => {
230
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
229
+ var __publicField$1 = (obj, key, value) => {
230
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
231
231
  return value;
232
232
  };
233
233
  var __accessCheck$7 = (obj, member, msg) => {
@@ -252,20 +252,20 @@
252
252
  /**
253
253
  * Public interface, interop with real XMLHttpRequest
254
254
  */
255
- __publicField$5(this, "onabort");
256
- __publicField$5(this, "onerror");
257
- __publicField$5(this, "onreadystatechange");
258
- __publicField$5(this, "ontimeout");
255
+ __publicField$1(this, "onabort");
256
+ __publicField$1(this, "onerror");
257
+ __publicField$1(this, "onreadystatechange");
258
+ __publicField$1(this, "ontimeout");
259
259
  /**
260
260
  * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
261
261
  */
262
- __publicField$5(this, "readyState", 0);
263
- __publicField$5(this, "response");
264
- __publicField$5(this, "responseText");
265
- __publicField$5(this, "responseType", "");
266
- __publicField$5(this, "status");
267
- __publicField$5(this, "statusText");
268
- __publicField$5(this, "withCredentials");
262
+ __publicField$1(this, "readyState", 0);
263
+ __publicField$1(this, "response");
264
+ __publicField$1(this, "responseText");
265
+ __publicField$1(this, "responseType", "");
266
+ __publicField$1(this, "status");
267
+ __publicField$1(this, "statusText");
268
+ __publicField$1(this, "withCredentials");
269
269
  /**
270
270
  * Private implementation details
271
271
  */
@@ -1365,21 +1365,21 @@
1365
1365
  }
1366
1366
  };
1367
1367
  }
1368
- var __defProp$4 = Object.defineProperty;
1369
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, {
1368
+ var __defProp = Object.defineProperty;
1369
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
1370
1370
  enumerable: true,
1371
1371
  configurable: true,
1372
1372
  writable: true,
1373
1373
  value
1374
1374
  }) : obj[key] = value;
1375
- var __publicField$4 = (obj, key, value) => {
1376
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1375
+ var __publicField = (obj, key, value) => {
1376
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1377
1377
  return value;
1378
1378
  };
1379
1379
  class Cancel {
1380
1380
  constructor(message) {
1381
- __publicField$4(this, "__CANCEL__", true);
1382
- __publicField$4(this, "message");
1381
+ __publicField(this, "__CANCEL__", true);
1382
+ __publicField(this, "message");
1383
1383
  this.message = message;
1384
1384
  }
1385
1385
  toString() {
@@ -1388,8 +1388,8 @@
1388
1388
  }
1389
1389
  const _CancelToken = class _CancelToken {
1390
1390
  constructor(executor) {
1391
- __publicField$4(this, "promise");
1392
- __publicField$4(this, "reason");
1391
+ __publicField(this, "promise");
1392
+ __publicField(this, "reason");
1393
1393
  if (typeof executor !== "function") {
1394
1394
  throw new TypeError("executor must be a function.");
1395
1395
  }
@@ -1406,7 +1406,7 @@
1406
1406
  });
1407
1407
  }
1408
1408
  };
1409
- __publicField$4(_CancelToken, "source", () => {
1409
+ __publicField(_CancelToken, "source", () => {
1410
1410
  let cancel;
1411
1411
  const token = new _CancelToken(can => {
1412
1412
  cancel = can;
@@ -2148,26 +2148,12 @@
2148
2148
  }
2149
2149
 
2150
2150
  var envMiddleware = [];
2151
- var __defProp$3 = Object.defineProperty;
2152
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, {
2153
- enumerable: true,
2154
- configurable: true,
2155
- writable: true,
2156
- value
2157
- }) : obj[key] = value;
2158
- var __publicField$3 = (obj, key, value) => {
2159
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
2160
- return value;
2161
- };
2162
2151
  const MAX_ITEMS_IN_ERROR_MESSAGE = 5;
2163
2152
  class ClientError extends Error {
2164
2153
  constructor(res) {
2165
2154
  const props = extractErrorProps(res);
2166
2155
  super(props.message);
2167
- __publicField$3(this, "response");
2168
- __publicField$3(this, "statusCode", 400);
2169
- __publicField$3(this, "responseBody");
2170
- __publicField$3(this, "details");
2156
+ this.statusCode = 400;
2171
2157
  Object.assign(this, props);
2172
2158
  }
2173
2159
  }
@@ -2175,10 +2161,7 @@
2175
2161
  constructor(res) {
2176
2162
  const props = extractErrorProps(res);
2177
2163
  super(props.message);
2178
- __publicField$3(this, "response");
2179
- __publicField$3(this, "statusCode", 500);
2180
- __publicField$3(this, "responseBody");
2181
- __publicField$3(this, "details");
2164
+ this.statusCode = 500;
2182
2165
  Object.assign(this, props);
2183
2166
  }
2184
2167
  }
@@ -2513,17 +2496,6 @@
2513
2496
  }
2514
2497
  return "?".concat(searchParams);
2515
2498
  };
2516
- var __defProp$2 = Object.defineProperty;
2517
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
2518
- enumerable: true,
2519
- configurable: true,
2520
- writable: true,
2521
- value
2522
- }) : obj[key] = value;
2523
- var __publicField$2 = (obj, key, value) => {
2524
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
2525
- return value;
2526
- };
2527
2499
  var __accessCheck$6 = (obj, member, msg) => {
2528
2500
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
2529
2501
  };
@@ -2544,8 +2516,6 @@
2544
2516
  class BasePatch {
2545
2517
  constructor(selection) {
2546
2518
  let operations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2547
- __publicField$2(this, "selection");
2548
- __publicField$2(this, "operations");
2549
2519
  this.selection = selection;
2550
2520
  this.operations = operations;
2551
2521
  }
@@ -2759,17 +2729,6 @@
2759
2729
  };
2760
2730
  _client2$5 = new WeakMap();
2761
2731
  let Patch = _Patch;
2762
- var __defProp$1 = Object.defineProperty;
2763
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
2764
- enumerable: true,
2765
- configurable: true,
2766
- writable: true,
2767
- value
2768
- }) : obj[key] = value;
2769
- var __publicField$1 = (obj, key, value) => {
2770
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2771
- return value;
2772
- };
2773
2732
  var __accessCheck$5 = (obj, member, msg) => {
2774
2733
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
2775
2734
  };
@@ -2794,8 +2753,6 @@
2794
2753
  constructor() {
2795
2754
  let operations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2796
2755
  let transactionId = arguments.length > 1 ? arguments[1] : undefined;
2797
- __publicField$1(this, "operations");
2798
- __publicField$1(this, "trxId");
2799
2756
  this.operations = operations;
2800
2757
  this.trxId = transactionId;
2801
2758
  }
@@ -3148,7 +3105,7 @@
3148
3105
  const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
3149
3106
  let useCdn = config.useCdn && canUseCdn;
3150
3107
  const tag = options.tag && config.requestTagPrefix ? [config.requestTagPrefix, options.tag].join(".") : options.tag || config.requestTagPrefix;
3151
- if (tag) {
3108
+ if (tag && options.tag !== null) {
3152
3109
  options.query = {
3153
3110
  tag: requestTag(tag),
3154
3111
  ...options.query
@@ -3535,7 +3492,8 @@
3535
3492
  */
3536
3493
  list() {
3537
3494
  return _request(__privateGet$3(this, _client$2), __privateGet$3(this, _httpRequest$3), {
3538
- uri: "/datasets"
3495
+ uri: "/datasets",
3496
+ tag: null
3539
3497
  });
3540
3498
  }
3541
3499
  }
@@ -3579,7 +3537,8 @@
3579
3537
  */
3580
3538
  list() {
3581
3539
  return lastValueFrom(_request(__privateGet$3(this, _client2$2), __privateGet$3(this, _httpRequest2$3), {
3582
- uri: "/datasets"
3540
+ uri: "/datasets",
3541
+ tag: null
3583
3542
  }));
3584
3543
  }
3585
3544
  }
@@ -3590,7 +3549,8 @@
3590
3549
  return _request(client, httpRequest, {
3591
3550
  method,
3592
3551
  uri: "/datasets/".concat(name),
3593
- body: options
3552
+ body: options,
3553
+ tag: null
3594
3554
  });
3595
3555
  }
3596
3556
  var __accessCheck$2 = (obj, member, msg) => {
@@ -3719,17 +3679,6 @@
3719
3679
  }
3720
3680
  _client2 = new WeakMap();
3721
3681
  _httpRequest2$1 = new WeakMap();
3722
- var __defProp = Object.defineProperty;
3723
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
3724
- enumerable: true,
3725
- configurable: true,
3726
- writable: true,
3727
- value
3728
- }) : obj[key] = value;
3729
- var __publicField = (obj, key, value) => {
3730
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3731
- return value;
3732
- };
3733
3682
  var __accessCheck = (obj, member, msg) => {
3734
3683
  if (!member.has(obj)) throw TypeError("Cannot " + msg);
3735
3684
  };
@@ -3750,10 +3699,6 @@
3750
3699
  const _ObservableSanityClient = class _ObservableSanityClient {
3751
3700
  constructor(httpRequest) {
3752
3701
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
3753
- __publicField(this, "assets");
3754
- __publicField(this, "datasets");
3755
- __publicField(this, "projects");
3756
- __publicField(this, "users");
3757
3702
  /**
3758
3703
  * Private properties
3759
3704
  */
@@ -3762,7 +3707,7 @@
3762
3707
  /**
3763
3708
  * Instance properties
3764
3709
  */
3765
- __publicField(this, "listen", _listen);
3710
+ this.listen = _listen;
3766
3711
  this.config(config);
3767
3712
  __privateSet(this, _httpRequest, httpRequest);
3768
3713
  this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest));
@@ -3890,14 +3835,6 @@
3890
3835
  const _SanityClient = class _SanityClient {
3891
3836
  constructor(httpRequest) {
3892
3837
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
3893
- __publicField(this, "assets");
3894
- __publicField(this, "datasets");
3895
- __publicField(this, "projects");
3896
- __publicField(this, "users");
3897
- /**
3898
- * Observable version of the Sanity client, with the same configuration as the promise-based one
3899
- */
3900
- __publicField(this, "observable");
3901
3838
  /**
3902
3839
  * Private properties
3903
3840
  */
@@ -3906,7 +3843,7 @@
3906
3843
  /**
3907
3844
  * Instance properties
3908
3845
  */
3909
- __publicField(this, "listen", _listen);
3846
+ this.listen = _listen;
3910
3847
  this.config(config);
3911
3848
  __privateSet(this, _httpRequest2, httpRequest);
3912
3849
  this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2));