@sanity/client 6.20.0 → 6.20.1
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.browser.cjs +5 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +5 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/config.ts +5 -0
- package/src/warnings.ts +5 -0
- package/umd/sanityClient.js +19 -21
- package/umd/sanityClient.min.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.20.
|
|
3
|
+
"version": "6.20.1",
|
|
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.6.
|
|
121
|
+
"get-it": "^8.6.1",
|
|
122
122
|
"rxjs": "^7.0.0"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
"@sanity/pkg-utils": "^6.9.3",
|
|
130
130
|
"@types/json-diff": "^1.0.3",
|
|
131
131
|
"@types/node": "^20.8.8",
|
|
132
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
133
|
-
"@typescript-eslint/parser": "^7.
|
|
132
|
+
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
|
133
|
+
"@typescript-eslint/parser": "^7.13.1",
|
|
134
134
|
"@vercel/stega": "0.1.2",
|
|
135
135
|
"@vitest/coverage-v8": "1.6.0",
|
|
136
136
|
"eslint": "^8.57.0",
|
|
@@ -140,10 +140,10 @@
|
|
|
140
140
|
"faucet": "^0.0.4",
|
|
141
141
|
"happy-dom": "^12.10.3",
|
|
142
142
|
"json-diff": "^1.0.6",
|
|
143
|
-
"ls-engines": "^0.9.
|
|
144
|
-
"next": "^14.2.
|
|
143
|
+
"ls-engines": "^0.9.2",
|
|
144
|
+
"next": "^14.2.4",
|
|
145
145
|
"nock": "^13.5.4",
|
|
146
|
-
"prettier": "^3.3.
|
|
146
|
+
"prettier": "^3.3.2",
|
|
147
147
|
"prettier-plugin-packagejson": "^2.5.0",
|
|
148
148
|
"rimraf": "^5.0.7",
|
|
149
149
|
"rollup": "^4.18.0",
|
package/src/config.ts
CHANGED
|
@@ -130,6 +130,11 @@ export const initConfig = (
|
|
|
130
130
|
|
|
131
131
|
newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, '')
|
|
132
132
|
newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost
|
|
133
|
+
|
|
134
|
+
if (newConfig.useCdn === true && newConfig.withCredentials) {
|
|
135
|
+
warnings.printCdnAndWithCredentialsWarning()
|
|
136
|
+
}
|
|
137
|
+
|
|
133
138
|
// If `useCdn` is undefined, we treat it as `true`
|
|
134
139
|
newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials
|
|
135
140
|
|
package/src/warnings.ts
CHANGED
|
@@ -6,6 +6,11 @@ const createWarningPrinter = (message: string[]) =>
|
|
|
6
6
|
// eslint-disable-next-line no-console
|
|
7
7
|
once((...args: Any[]) => console.warn(message.join(' '), ...args))
|
|
8
8
|
|
|
9
|
+
export const printCdnAndWithCredentialsWarning = createWarningPrinter([
|
|
10
|
+
`Because you set \`withCredentials\` to true, we will override your \`useCdn\``,
|
|
11
|
+
`setting to be false since (cookie-based) credentials are never set on the CDN`,
|
|
12
|
+
])
|
|
13
|
+
|
|
9
14
|
export const printCdnWarning = createWarningPrinter([
|
|
10
15
|
`Since you haven't set a value for \`useCdn\`, we will deliver content using our`,
|
|
11
16
|
`global, edge-cached API-CDN. If you wish to have content delivered faster, set`,
|
package/umd/sanityClient.js
CHANGED
|
@@ -166,17 +166,12 @@
|
|
|
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$4 = Object.defineProperty,
|
|
170
|
-
|
|
171
|
-
|
|
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) => {
|
|
173
|
-
if (member.has(obj))
|
|
174
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
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;
|
|
169
|
+
}, parseHeaders$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(parseHeaders), __defProp$4 = Object.defineProperty, __typeError = (msg) => {
|
|
170
|
+
throw TypeError(msg);
|
|
171
|
+
}, __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key != "symbol" ? key + "" : key, value), __accessCheck$8 = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __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) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __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;
|
|
177
172
|
class FetchXhr {
|
|
178
173
|
constructor() {
|
|
179
|
-
__publicField$4(this, "onabort"), __publicField$4(this, "onerror"), __publicField$4(this, "onreadystatechange"), __publicField$4(this, "ontimeout"), __publicField$4(this, "readyState", 0), __publicField$4(this, "response"), __publicField$4(this, "responseText", ""), __publicField$4(this, "responseType", ""), __publicField$4(this, "status"), __publicField$4(this, "statusText"), __publicField$4(this, "withCredentials"), __privateAdd$8(this, _method
|
|
174
|
+
__publicField$4(this, "onabort"), __publicField$4(this, "onerror"), __publicField$4(this, "onreadystatechange"), __publicField$4(this, "ontimeout"), __publicField$4(this, "readyState", 0), __publicField$4(this, "response"), __publicField$4(this, "responseText", ""), __publicField$4(this, "responseType", ""), __publicField$4(this, "status"), __publicField$4(this, "statusText"), __publicField$4(this, "withCredentials"), __privateAdd$8(this, _method), __privateAdd$8(this, _url), __privateAdd$8(this, _resHeaders), __privateAdd$8(this, _headers, {}), __privateAdd$8(this, _controller), __privateAdd$8(this, _init, {}), __privateAdd$8(this, _useAbortSignal);
|
|
180
175
|
}
|
|
181
176
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility
|
|
182
177
|
open(method, url, _async) {
|
|
@@ -203,10 +198,13 @@
|
|
|
203
198
|
headers: __privateGet$8(this, _headers),
|
|
204
199
|
body
|
|
205
200
|
};
|
|
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) =>
|
|
207
|
-
|
|
201
|
+
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) => {
|
|
202
|
+
var _a;
|
|
203
|
+
return res.headers.forEach((value, key) => {
|
|
204
|
+
__privateSet$8(this, _resHeaders, __privateGet$8(this, _resHeaders) + `${key}: ${value}\r
|
|
208
205
|
`);
|
|
209
|
-
|
|
206
|
+
}), this.status = res.status, this.statusText = res.statusText, this.readyState = 3, (_a = this.onreadystatechange) == null || _a.call(this), textBody ? res.text() : res.arrayBuffer();
|
|
207
|
+
}).then((resBody) => {
|
|
210
208
|
var _a;
|
|
211
209
|
typeof resBody == "string" ? this.responseText = resBody : this.response = resBody, this.readyState = 4, (_a = this.onreadystatechange) == null || _a.call(this);
|
|
212
210
|
}).catch((err) => {
|
|
@@ -307,8 +305,7 @@
|
|
|
307
305
|
|
|
308
306
|
var browser$3 = { exports: {} }, ms, hasRequiredMs;
|
|
309
307
|
function requireMs() {
|
|
310
|
-
if (hasRequiredMs)
|
|
311
|
-
return ms;
|
|
308
|
+
if (hasRequiredMs) return ms;
|
|
312
309
|
hasRequiredMs = 1;
|
|
313
310
|
var s = 1e3, m = s * 60, h = m * 60, d = h * 24, w = d * 7, y = d * 365.25;
|
|
314
311
|
ms = function(val, options) {
|
|
@@ -614,11 +611,9 @@
|
|
|
614
611
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
615
612
|
}
|
|
616
613
|
function isPlainObject$1(o) {
|
|
617
|
-
if (isObject(o) === !1)
|
|
618
|
-
return !1;
|
|
614
|
+
if (isObject(o) === !1) return !1;
|
|
619
615
|
const ctor = o.constructor;
|
|
620
|
-
if (ctor === void 0)
|
|
621
|
-
return !0;
|
|
616
|
+
if (ctor === void 0) return !0;
|
|
622
617
|
const prot = ctor.prototype;
|
|
623
618
|
return !(isObject(prot) === !1 || // eslint-disable-next-line no-prototype-builtins
|
|
624
619
|
prot.hasOwnProperty("isPrototypeOf") === !1);
|
|
@@ -697,7 +692,7 @@
|
|
|
697
692
|
}
|
|
698
693
|
};
|
|
699
694
|
}
|
|
700
|
-
var __defProp$1$1 = Object.defineProperty, __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1$1 = (obj, key, value) =>
|
|
695
|
+
var __defProp$1$1 = Object.defineProperty, __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$1$1 = (obj, key, value) => __defNormalProp$1$1(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
701
696
|
class Cancel {
|
|
702
697
|
constructor(message) {
|
|
703
698
|
__publicField$1$1(this, "__CANCEL__", !0), __publicField$1$1(this, "message"), this.message = message;
|
|
@@ -2303,7 +2298,10 @@ ${selectionOpts}`);
|
|
|
2303
2298
|
const createWarningPrinter = (message) => (
|
|
2304
2299
|
// eslint-disable-next-line no-console
|
|
2305
2300
|
once((...args) => console.warn(message.join(" "), ...args))
|
|
2306
|
-
),
|
|
2301
|
+
), printCdnAndWithCredentialsWarning = createWarningPrinter([
|
|
2302
|
+
"Because you set `withCredentials` to true, we will override your `useCdn`",
|
|
2303
|
+
"setting to be false since (cookie-based) credentials are never set on the CDN"
|
|
2304
|
+
]), printCdnWarning = createWarningPrinter([
|
|
2307
2305
|
"Since you haven't set a value for `useCdn`, we will deliver content using our",
|
|
2308
2306
|
"global, edge-cached API-CDN. If you wish to have content delivered faster, set",
|
|
2309
2307
|
"`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."
|
|
@@ -2381,7 +2379,7 @@ ${selectionOpts}`);
|
|
|
2381
2379
|
`stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
|
|
2382
2380
|
);
|
|
2383
2381
|
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
|
|
2384
|
-
isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== !0 ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn = newConfig.useCdn !== !1 && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
2382
|
+
isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== !0 ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn === !0 && newConfig.withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== !1 && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
2385
2383
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
2386
2384
|
return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig;
|
|
2387
2385
|
}, projectHeader = "X-Sanity-Project-ID";
|