@sanity-labs/client-fake-for-test 0.21.0 → 0.22.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/README.md +17 -0
- package/dist/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -65,6 +65,13 @@ export declare interface CallRecord {
|
|
|
65
65
|
dataset: string;
|
|
66
66
|
/** The resource the call targeted, on a `resource`-configured handle. */
|
|
67
67
|
resource?: TestClientResource;
|
|
68
|
+
/**
|
|
69
|
+
* The token of the handle that made the call, after `withConfig`
|
|
70
|
+
* overrides; absent on a handle without one.
|
|
71
|
+
*/
|
|
72
|
+
token?: string;
|
|
73
|
+
/** The `apiVersion` of the handle that made the call, as its `config()` reports it. */
|
|
74
|
+
apiVersion?: string;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
/** Outcome of a recorded call, reported once a (possibly async) result is known. */
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,13 @@ export declare interface CallRecord {
|
|
|
65
65
|
dataset: string;
|
|
66
66
|
/** The resource the call targeted, on a `resource`-configured handle. */
|
|
67
67
|
resource?: TestClientResource;
|
|
68
|
+
/**
|
|
69
|
+
* The token of the handle that made the call, after `withConfig`
|
|
70
|
+
* overrides; absent on a handle without one.
|
|
71
|
+
*/
|
|
72
|
+
token?: string;
|
|
73
|
+
/** The `apiVersion` of the handle that made the call, as its `config()` reports it. */
|
|
74
|
+
apiVersion?: string;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
/** Outcome of a recorded call, reported once a (possibly async) result is known. */
|
package/dist/index.js
CHANGED
|
@@ -1684,7 +1684,7 @@ function createTransaction(executor) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
const DEFAULT_API_HOST = "https://api.sanity.io", DEFAULT_API_VERSION = "1", DEFAULT_CDN_HOST = "apicdn.sanity.io", QUERY_SIZE_LIMIT = 11264;
|
|
1686
1686
|
function normalizeTagPrefix(prefix) {
|
|
1687
|
-
return prefix
|
|
1687
|
+
return prefix ? prefix.replace(/\.+$/, "") : void 0;
|
|
1688
1688
|
}
|
|
1689
1689
|
function normalizeApiVersion(apiVersion) {
|
|
1690
1690
|
const version = `${apiVersion}`.replace(/^v/, "");
|
|
@@ -2205,7 +2205,7 @@ function makeHandle(handleArgs) {
|
|
|
2205
2205
|
mutations,
|
|
2206
2206
|
...effectiveTag !== void 0 ? { tag: effectiveTag } : {}
|
|
2207
2207
|
});
|
|
2208
|
-
}, effectiveRequestTag = (tag) => requestTagPrefix
|
|
2208
|
+
}, effectiveRequestTag = (tag) => requestTagPrefix ? tag ? `${requestTagPrefix}.${tag}` : requestTagPrefix : tag, writeResult = (documents, results, transactionId, opts) => formatMutationResult(
|
|
2209
2209
|
documents,
|
|
2210
2210
|
results,
|
|
2211
2211
|
transactionId,
|
|
@@ -2633,8 +2633,12 @@ function makeHandle(handleArgs) {
|
|
|
2633
2633
|
resource: nextResource,
|
|
2634
2634
|
accessControl: rebinds ? config.accessControl : accessControl,
|
|
2635
2635
|
perspective: config.perspective ?? perspective,
|
|
2636
|
-
// `requestTagPrefix: undefined` unsets the prefix,
|
|
2637
|
-
|
|
2636
|
+
// `requestTagPrefix: undefined` unsets the prefix, and an inherited
|
|
2637
|
+
// one is normalized again, as `@sanity/client` re-runs `initConfig`
|
|
2638
|
+
// on the merged config (`SanityClient.ts:1417`, `config.ts:239-244`).
|
|
2639
|
+
requestTagPrefix: normalizeTagPrefix(
|
|
2640
|
+
"requestTagPrefix" in config ? config.requestTagPrefix : requestTagPrefix
|
|
2641
|
+
),
|
|
2638
2642
|
mutationGuard,
|
|
2639
2643
|
token: rebinds ? config.token : token,
|
|
2640
2644
|
useProjectHostname: config.useProjectHostname ?? useProjectHostname,
|
|
@@ -2686,7 +2690,9 @@ function makeHandle(handleArgs) {
|
|
|
2686
2690
|
args,
|
|
2687
2691
|
projectId,
|
|
2688
2692
|
dataset,
|
|
2689
|
-
...resource !== void 0 ? { resource } : {}
|
|
2693
|
+
...resource !== void 0 ? { resource } : {},
|
|
2694
|
+
...token !== void 0 ? { token } : {},
|
|
2695
|
+
apiVersion
|
|
2690
2696
|
}, tag = OPTIONS_ARG_POSITION[method] === void 0 ? void 0 : effectiveRequestTag(tagFromArgs(method, args));
|
|
2691
2697
|
return tag !== void 0 && (rec.tag = tag), backend.calls.push(rec), (outcome) => {
|
|
2692
2698
|
"error" in outcome ? rec.error = outcome.error : rec.result = outcome.result;
|