@sanity/client 6.25.0-alpha.0 → 6.25.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/dist/_chunks-cjs/resolveEditInfo.cjs +1 -2
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaClean.cjs +1 -2
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +1 -2
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js +1 -2
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaClean.js +1 -2
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -2
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.cjs +1 -2
- package/dist/csm.cjs.map +1 -1
- package/dist/csm.d.cts +99 -34
- package/dist/csm.d.ts +99 -34
- package/dist/csm.js +1 -2
- package/dist/csm.js.map +1 -1
- package/dist/index.browser.cjs +31 -20
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +11 -4
- package/dist/index.browser.d.ts +11 -4
- package/dist/index.browser.js +31 -20
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +32 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +32 -21
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +3419 -96
- package/dist/stega.browser.d.ts +3419 -96
- package/dist/stega.d.cts +3419 -96
- package/dist/stega.d.ts +3419 -96
- package/package.json +8 -8
- package/src/data/transaction.ts +26 -1
- package/src/defineCreateClient.ts +5 -3
- package/src/http/request.ts +15 -8
- package/src/types.ts +1 -0
- package/umd/sanityClient.js +156 -161
- package/umd/sanityClient.min.js +2 -2
package/dist/index.browser.cjs
CHANGED
|
@@ -97,17 +97,23 @@ const httpError = {
|
|
|
97
97
|
throw new ClientError(res);
|
|
98
98
|
return res;
|
|
99
99
|
}
|
|
100
|
-
}, printWarnings = {
|
|
101
|
-
onResponse: (res) => {
|
|
102
|
-
const warn = res.headers["x-sanity-warning"];
|
|
103
|
-
return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
|
|
104
|
-
}
|
|
105
100
|
};
|
|
101
|
+
function printWarnings() {
|
|
102
|
+
const seen = {};
|
|
103
|
+
return {
|
|
104
|
+
onResponse: (res) => {
|
|
105
|
+
const warn = res.headers["x-sanity-warning"], warnings = Array.isArray(warn) ? warn : [warn];
|
|
106
|
+
for (const msg of warnings)
|
|
107
|
+
!msg || seen[msg] || (seen[msg] = !0, console.warn(msg));
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
106
112
|
function defineHttpRequest(envMiddleware2) {
|
|
107
113
|
return getIt.getIt([
|
|
108
114
|
middleware.retry({ shouldRetry }),
|
|
109
115
|
...envMiddleware2,
|
|
110
|
-
printWarnings,
|
|
116
|
+
printWarnings(),
|
|
111
117
|
middleware.jsonRequest(),
|
|
112
118
|
middleware.jsonResponse(),
|
|
113
119
|
middleware.progress(),
|
|
@@ -116,8 +122,7 @@ function defineHttpRequest(envMiddleware2) {
|
|
|
116
122
|
]);
|
|
117
123
|
}
|
|
118
124
|
function shouldRetry(err, attempt, options) {
|
|
119
|
-
if (options.maxRetries === 0)
|
|
120
|
-
return !1;
|
|
125
|
+
if (options.maxRetries === 0) return !1;
|
|
121
126
|
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
122
127
|
return (isSafe || isQuery) && isRetriableResponse ? !0 : middleware.retry.shouldRetry(err, attempt, options);
|
|
123
128
|
}
|
|
@@ -659,8 +664,8 @@ class Transaction extends BaseTransaction {
|
|
|
659
664
|
);
|
|
660
665
|
}
|
|
661
666
|
patch(patchOrDocumentId, patchOps) {
|
|
662
|
-
const isBuilder = typeof patchOps == "function";
|
|
663
|
-
if (
|
|
667
|
+
const isBuilder = typeof patchOps == "function", isPatch = typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch, isMutationSelection = typeof patchOrDocumentId == "object" && ("query" in patchOrDocumentId || "id" in patchOrDocumentId);
|
|
668
|
+
if (isPatch)
|
|
664
669
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
665
670
|
if (isBuilder) {
|
|
666
671
|
const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client));
|
|
@@ -668,6 +673,10 @@ class Transaction extends BaseTransaction {
|
|
|
668
673
|
throw new Error("function passed to `patch()` must return the patch");
|
|
669
674
|
return this._add({ patch: patch.serialize() });
|
|
670
675
|
}
|
|
676
|
+
if (isMutationSelection) {
|
|
677
|
+
const patch = new Patch(patchOrDocumentId, patchOps || {}, this.#client);
|
|
678
|
+
return this._add({ patch: patch.serialize() });
|
|
679
|
+
}
|
|
671
680
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
672
681
|
}
|
|
673
682
|
}
|
|
@@ -1617,16 +1626,18 @@ class SanityClient {
|
|
|
1617
1626
|
}
|
|
1618
1627
|
}
|
|
1619
1628
|
function defineCreateClientExports(envMiddleware2, ClassConstructor) {
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1629
|
+
return { requester: defineHttpRequest(envMiddleware2), createClient: (config) => {
|
|
1630
|
+
const clientRequester = defineHttpRequest(envMiddleware2);
|
|
1631
|
+
return new ClassConstructor(
|
|
1632
|
+
(options, requester2) => (requester2 || clientRequester)({
|
|
1633
|
+
maxRedirects: 0,
|
|
1634
|
+
maxRetries: config.maxRetries,
|
|
1635
|
+
retryDelay: config.retryDelay,
|
|
1636
|
+
...options
|
|
1637
|
+
}),
|
|
1638
|
+
config
|
|
1639
|
+
);
|
|
1640
|
+
} };
|
|
1630
1641
|
}
|
|
1631
1642
|
function defineDeprecatedCreateClient(createClient2) {
|
|
1632
1643
|
return function(config) {
|