@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.cjs
CHANGED
|
@@ -1528,7 +1528,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1528
1528
|
return config.printNoDefaultExport(), createClient2(config$1);
|
|
1529
1529
|
};
|
|
1530
1530
|
}
|
|
1531
|
-
var name = "@sanity/client", version = "6.28.4
|
|
1531
|
+
var name = "@sanity/client", version = "6.28.4";
|
|
1532
1532
|
const middleware = [
|
|
1533
1533
|
middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1534
1534
|
middleware$1.headers({ "User-Agent": `${name} ${version}` }),
|
package/dist/index.js
CHANGED
|
@@ -1511,7 +1511,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1511
1511
|
return printNoDefaultExport(), createClient2(config);
|
|
1512
1512
|
};
|
|
1513
1513
|
}
|
|
1514
|
-
var name = "@sanity/client", version = "6.28.4
|
|
1514
|
+
var name = "@sanity/client", version = "6.28.4";
|
|
1515
1515
|
const middleware = [
|
|
1516
1516
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1517
1517
|
headers({ "User-Agent": `${name} ${version}` }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.28.4
|
|
3
|
+
"version": "6.28.4",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -125,39 +125,39 @@
|
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@edge-runtime/types": "^4.0.0",
|
|
127
127
|
"@edge-runtime/vm": "^5.0.0",
|
|
128
|
-
"@eslint/eslintrc": "^3.
|
|
129
|
-
"@eslint/js": "^9.
|
|
130
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
131
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
128
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
129
|
+
"@eslint/js": "^9.22.0",
|
|
130
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
131
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
132
132
|
"@sanity/client-latest": "npm:@sanity/client@latest",
|
|
133
|
-
"@sanity/pkg-utils": "^7.
|
|
133
|
+
"@sanity/pkg-utils": "^7.1.1",
|
|
134
134
|
"@types/json-diff": "^1.0.3",
|
|
135
135
|
"@types/node": "^22.9.0",
|
|
136
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
137
|
-
"@typescript-eslint/parser": "^8.
|
|
136
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
137
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
138
138
|
"@vercel/stega": "0.1.2",
|
|
139
|
-
"@vitest/coverage-v8": "3.0.
|
|
140
|
-
"eslint": "^9.
|
|
141
|
-
"eslint-config-prettier": "^10.
|
|
139
|
+
"@vitest/coverage-v8": "3.0.9",
|
|
140
|
+
"eslint": "^9.22.0",
|
|
141
|
+
"eslint-config-prettier": "^10.1.1",
|
|
142
142
|
"eslint-formatter-compact": "^8.40.0",
|
|
143
143
|
"eslint-plugin-prettier": "^5.2.3",
|
|
144
144
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
145
145
|
"faucet": "^0.0.4",
|
|
146
|
-
"globals": "^15.
|
|
146
|
+
"globals": "^15.15.0",
|
|
147
147
|
"happy-dom": "^12.10.3",
|
|
148
148
|
"json-diff": "^1.0.6",
|
|
149
149
|
"ls-engines": "^0.9.3",
|
|
150
|
-
"msw": "^2.7.
|
|
151
|
-
"next": "^15.
|
|
150
|
+
"msw": "^2.7.3",
|
|
151
|
+
"next": "^15.2.3",
|
|
152
152
|
"nock": "^13.5.6",
|
|
153
|
-
"prettier": "^3.5.
|
|
154
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
153
|
+
"prettier": "^3.5.3",
|
|
154
|
+
"prettier-plugin-packagejson": "^2.5.10",
|
|
155
155
|
"rimraf": "^5.0.7",
|
|
156
|
-
"rollup": "^4.
|
|
156
|
+
"rollup": "^4.36.0",
|
|
157
157
|
"sse-channel": "^4.0.0",
|
|
158
|
-
"terser": "^5.
|
|
159
|
-
"typescript": "5.
|
|
160
|
-
"vitest": "3.0.
|
|
158
|
+
"terser": "^5.39.0",
|
|
159
|
+
"typescript": "5.8.2",
|
|
160
|
+
"vitest": "3.0.9"
|
|
161
161
|
},
|
|
162
162
|
"packageManager": "npm@11.0.0",
|
|
163
163
|
"engines": {
|
package/src/config.ts
CHANGED
|
@@ -28,30 +28,15 @@ function validateApiVersion(apiVersion: string) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const VALID_PERSPECTIVE = /^[a-z0-9_]+$/i
|
|
32
|
-
|
|
33
31
|
/**
|
|
34
32
|
* @internal - it may have breaking changes in any release
|
|
35
33
|
*/
|
|
36
34
|
export function validateApiPerspective(
|
|
37
35
|
perspective: unknown,
|
|
38
36
|
): asserts perspective is ClientPerspective {
|
|
39
|
-
if (Array.isArray(perspective)) {
|
|
40
|
-
if (perspective.includes('raw')) {
|
|
41
|
-
throw new TypeError(
|
|
42
|
-
`Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives`,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const invalid = (Array.isArray(perspective) ? perspective : [perspective]).filter(
|
|
48
|
-
(perspectiveName) =>
|
|
49
|
-
typeof perspectiveName !== 'string' || !VALID_PERSPECTIVE.test(perspectiveName),
|
|
50
|
-
)
|
|
51
|
-
if (invalid.length > 0) {
|
|
52
|
-
const formatted = invalid.map((v) => JSON.stringify(v))
|
|
37
|
+
if (Array.isArray(perspective) && perspective.length > 1 && perspective.includes('raw')) {
|
|
53
38
|
throw new TypeError(
|
|
54
|
-
`Invalid API perspective value
|
|
39
|
+
`Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives`,
|
|
55
40
|
)
|
|
56
41
|
}
|
|
57
42
|
}
|
|
@@ -123,11 +108,9 @@ export const initConfig = (
|
|
|
123
108
|
const isLocalhost = isBrowser && isLocal(window.location.hostname)
|
|
124
109
|
|
|
125
110
|
const hasToken = Boolean(newConfig.token)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (withCredentials && hasToken) {
|
|
111
|
+
if (newConfig.withCredentials && hasToken) {
|
|
129
112
|
warnings.printCredentialedTokenWarning()
|
|
130
|
-
withCredentials = false
|
|
113
|
+
newConfig.withCredentials = false
|
|
131
114
|
}
|
|
132
115
|
|
|
133
116
|
if (isBrowser && isLocalhost && hasToken && newConfig.ignoreBrowserTokenWarning !== true) {
|
|
@@ -154,12 +137,12 @@ export const initConfig = (
|
|
|
154
137
|
newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, '')
|
|
155
138
|
newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost
|
|
156
139
|
|
|
157
|
-
if (newConfig.useCdn === true && withCredentials) {
|
|
140
|
+
if (newConfig.useCdn === true && newConfig.withCredentials) {
|
|
158
141
|
warnings.printCdnAndWithCredentialsWarning()
|
|
159
142
|
}
|
|
160
143
|
|
|
161
144
|
// If `useCdn` is undefined, we treat it as `true`
|
|
162
|
-
newConfig.useCdn = newConfig.useCdn !== false && !withCredentials
|
|
145
|
+
newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials
|
|
163
146
|
|
|
164
147
|
validateApiVersion(newConfig.apiVersion)
|
|
165
148
|
|
package/umd/sanityClient.js
CHANGED
|
@@ -2109,21 +2109,11 @@
|
|
|
2109
2109
|
if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
|
|
2110
2110
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
2111
2111
|
}
|
|
2112
|
-
const VALID_PERSPECTIVE = /^[a-z0-9_]+$/i;
|
|
2113
2112
|
function validateApiPerspective(perspective) {
|
|
2114
|
-
if (Array.isArray(perspective) && perspective.includes("raw"))
|
|
2113
|
+
if (Array.isArray(perspective) && perspective.length > 1 && perspective.includes("raw"))
|
|
2115
2114
|
throw new TypeError(
|
|
2116
2115
|
'Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives'
|
|
2117
2116
|
);
|
|
2118
|
-
const invalid = (Array.isArray(perspective) ? perspective : [perspective]).filter(
|
|
2119
|
-
(perspectiveName) => typeof perspectiveName != "string" || !VALID_PERSPECTIVE.test(perspectiveName)
|
|
2120
|
-
);
|
|
2121
|
-
if (invalid.length > 0) {
|
|
2122
|
-
const formatted = invalid.map((v) => JSON.stringify(v));
|
|
2123
|
-
throw new TypeError(
|
|
2124
|
-
`Invalid API perspective value${invalid.length === 1 ? "" : "s"}: ${formatted.join(", ")}, expected \`published\`, \`drafts\`, \`raw\` or a release identifier string`
|
|
2125
|
-
);
|
|
2126
|
-
}
|
|
2127
2117
|
}
|
|
2128
2118
|
const initConfig = (config, prevConfig) => {
|
|
2129
2119
|
const specifiedConfig = {
|
|
@@ -2162,8 +2152,7 @@
|
|
|
2162
2152
|
`stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
|
|
2163
2153
|
);
|
|
2164
2154
|
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname), hasToken = !!newConfig.token;
|
|
2165
|
-
|
|
2166
|
-
withCredentials && hasToken && (printCredentialedTokenWarning(), withCredentials = false), isBrowser && isLocalhost && hasToken && newConfig.ignoreBrowserTokenWarning !== true ? 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 === true && withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== false && !withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
2155
|
+
newConfig.withCredentials && hasToken && (printCredentialedTokenWarning(), newConfig.withCredentials = false), isBrowser && isLocalhost && hasToken && newConfig.ignoreBrowserTokenWarning !== true ? 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 === true && newConfig.withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
2167
2156
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
2168
2157
|
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;
|
|
2169
2158
|
};
|