@sanity/client 6.20.2 → 6.21.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/README.md +2 -0
- package/dist/index.browser.cjs +3 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +66 -25
- package/dist/index.browser.d.ts +66 -25
- package/dist/index.browser.js +3 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -25
- package/dist/index.d.ts +66 -25
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/SanityClient.ts +60 -29
- package/src/data/encodeQueryString.ts +4 -1
- package/src/data/listen.ts +1 -0
- package/src/types.ts +16 -0
- package/umd/sanityClient.js +3 -2
- package/umd/sanityClient.min.js +1 -1
package/README.md
CHANGED
|
@@ -851,6 +851,8 @@ By default, the emitted update event will also contain a `result` property, whic
|
|
|
851
851
|
|
|
852
852
|
Likewise, you can also have the client return the document _before_ the mutation was applied, by setting `includePreviousRevision` to `true` in the options, which will include a `previous` property in each emitted object.
|
|
853
853
|
|
|
854
|
+
If it's not relevant to know what mutations that was applied, you can also set `includeMutation` to `false` in the options, which will save some additional bandwidth by omitting the `mutation` property from the received events.
|
|
855
|
+
|
|
854
856
|
### Fetch a single document
|
|
855
857
|
|
|
856
858
|
This will fetch a document from the [Doc endpoint](https://www.sanity.io/docs/http-doc). This endpoint cuts through any caching/indexing middleware that may involve delayed processing. As it is less scalable/performant than the other query mechanisms, it should be used sparingly. Performing a query is usually a better option.
|
package/dist/index.browser.cjs
CHANGED
|
@@ -609,13 +609,13 @@ const encodeQueryString = ({
|
|
|
609
609
|
params = {},
|
|
610
610
|
options = {}
|
|
611
611
|
}) => {
|
|
612
|
-
const searchParams = new URLSearchParams(), { tag, returnQuery, ...opts } = options;
|
|
612
|
+
const searchParams = new URLSearchParams(), { tag, includeMutations, returnQuery, ...opts } = options;
|
|
613
613
|
tag && searchParams.append("tag", tag), searchParams.append("query", query);
|
|
614
614
|
for (const [key, value] of Object.entries(params))
|
|
615
615
|
searchParams.append(`$${key}`, JSON.stringify(value));
|
|
616
616
|
for (const [key, value] of Object.entries(opts))
|
|
617
617
|
value && searchParams.append(key, `${value}`);
|
|
618
|
-
return returnQuery === !1 && searchParams.append("returnQuery", "false"), `?${searchParams}`;
|
|
618
|
+
return returnQuery === !1 && searchParams.append("returnQuery", "false"), includeMutations === !1 && searchParams.append("includeMutations", "false"), `?${searchParams}`;
|
|
619
619
|
}, excludeFalsey = (param, defValue) => param === !1 ? void 0 : typeof param > "u" ? defValue : param, getMutationQuery = (options = {}) => ({
|
|
620
620
|
dryRun: options.dryRun,
|
|
621
621
|
returnIds: !0,
|
|
@@ -876,6 +876,7 @@ var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj
|
|
|
876
876
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), MAX_URL_LENGTH = 14800, possibleOptions = [
|
|
877
877
|
"includePreviousRevision",
|
|
878
878
|
"includeResult",
|
|
879
|
+
"includeMutations",
|
|
879
880
|
"visibility",
|
|
880
881
|
"effectFormat",
|
|
881
882
|
"tag"
|