@sanity/client 6.28.4-beta.0 → 6.28.4
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/_chunks-cjs/config.cjs +2 -13
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +2 -13
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +2 -13
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +2 -13
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +20 -20
- package/src/config.ts +6 -23
- package/umd/sanityClient.js +2 -13
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -201,21 +201,11 @@ function validateApiVersion(apiVersion) {
|
|
|
201
201
|
if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
|
|
202
202
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
203
203
|
}
|
|
204
|
-
const VALID_PERSPECTIVE = /^[a-z0-9_]+$/i;
|
|
205
204
|
function validateApiPerspective(perspective) {
|
|
206
|
-
if (Array.isArray(perspective) && perspective.includes("raw"))
|
|
205
|
+
if (Array.isArray(perspective) && perspective.length > 1 && perspective.includes("raw"))
|
|
207
206
|
throw new TypeError(
|
|
208
207
|
'Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives'
|
|
209
208
|
);
|
|
210
|
-
const invalid = (Array.isArray(perspective) ? perspective : [perspective]).filter(
|
|
211
|
-
(perspectiveName) => typeof perspectiveName != "string" || !VALID_PERSPECTIVE.test(perspectiveName)
|
|
212
|
-
);
|
|
213
|
-
if (invalid.length > 0) {
|
|
214
|
-
const formatted = invalid.map((v) => JSON.stringify(v));
|
|
215
|
-
throw new TypeError(
|
|
216
|
-
`Invalid API perspective value${invalid.length === 1 ? "" : "s"}: ${formatted.join(", ")}, expected \`published\`, \`drafts\`, \`raw\` or a release identifier string`
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
209
|
}
|
|
220
210
|
const initConfig = (config, prevConfig) => {
|
|
221
211
|
const specifiedConfig = {
|
|
@@ -254,8 +244,7 @@ const initConfig = (config, prevConfig) => {
|
|
|
254
244
|
`stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
|
|
255
245
|
);
|
|
256
246
|
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname), hasToken = !!newConfig.token;
|
|
257
|
-
|
|
258
|
-
withCredentials && hasToken && (printCredentialedTokenWarning(), withCredentials = !1), isBrowser && isLocalhost && hasToken && 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 && withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== !1 && !withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
247
|
+
newConfig.withCredentials && hasToken && (printCredentialedTokenWarning(), newConfig.withCredentials = !1), isBrowser && isLocalhost && hasToken && 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);
|
|
259
248
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
260
249
|
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;
|
|
261
250
|
};
|