@sanity-labs/client-fake-for-test 0.9.0 → 0.9.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/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -166,6 +166,8 @@ export declare interface CreateTestClientOptions {
|
|
|
166
166
|
* tests stay green.
|
|
167
167
|
*/
|
|
168
168
|
perspective?: Perspective;
|
|
169
|
+
/** Prefix composed with request tags and used alone for untagged requests. */
|
|
170
|
+
requestTagPrefix?: string;
|
|
169
171
|
/**
|
|
170
172
|
* Which API host the root handle models: the project host (default
|
|
171
173
|
* `true`) or the global host (`false`) — same flag as the real
|
|
@@ -873,6 +875,7 @@ export declare interface TestClient {
|
|
|
873
875
|
projectId: string;
|
|
874
876
|
dataset: string;
|
|
875
877
|
perspective: Perspective;
|
|
878
|
+
requestTagPrefix?: string;
|
|
876
879
|
token?: string;
|
|
877
880
|
useProjectHostname: boolean;
|
|
878
881
|
};
|
|
@@ -887,6 +890,8 @@ export declare interface TestClient {
|
|
|
887
890
|
projectId: string;
|
|
888
891
|
dataset: string;
|
|
889
892
|
perspective: Perspective;
|
|
893
|
+
/** Prefix composed with request tags and used alone for untagged requests. */
|
|
894
|
+
requestTagPrefix: string;
|
|
890
895
|
/**
|
|
891
896
|
* Model the global API host (`false`) instead of the project host
|
|
892
897
|
* (default `true`). A global-hosted sibling's `/users/me` serves the
|
package/dist/index.d.ts
CHANGED
|
@@ -166,6 +166,8 @@ export declare interface CreateTestClientOptions {
|
|
|
166
166
|
* tests stay green.
|
|
167
167
|
*/
|
|
168
168
|
perspective?: Perspective;
|
|
169
|
+
/** Prefix composed with request tags and used alone for untagged requests. */
|
|
170
|
+
requestTagPrefix?: string;
|
|
169
171
|
/**
|
|
170
172
|
* Which API host the root handle models: the project host (default
|
|
171
173
|
* `true`) or the global host (`false`) — same flag as the real
|
|
@@ -873,6 +875,7 @@ export declare interface TestClient {
|
|
|
873
875
|
projectId: string;
|
|
874
876
|
dataset: string;
|
|
875
877
|
perspective: Perspective;
|
|
878
|
+
requestTagPrefix?: string;
|
|
876
879
|
token?: string;
|
|
877
880
|
useProjectHostname: boolean;
|
|
878
881
|
};
|
|
@@ -887,6 +890,8 @@ export declare interface TestClient {
|
|
|
887
890
|
projectId: string;
|
|
888
891
|
dataset: string;
|
|
889
892
|
perspective: Perspective;
|
|
893
|
+
/** Prefix composed with request tags and used alone for untagged requests. */
|
|
894
|
+
requestTagPrefix: string;
|
|
890
895
|
/**
|
|
891
896
|
* Model the global API host (`false`) instead of the project host
|
|
892
897
|
* (default `true`). A global-hosted sibling's `/users/me` serves the
|
package/dist/index.js
CHANGED
|
@@ -1014,6 +1014,7 @@ function createTestClient(options = {}) {
|
|
|
1014
1014
|
dataset: defaultDataset,
|
|
1015
1015
|
accessControl: options.accessControl,
|
|
1016
1016
|
perspective: options.perspective ?? "raw",
|
|
1017
|
+
requestTagPrefix: options.requestTagPrefix,
|
|
1017
1018
|
mutationGuard: options.mutationGuard,
|
|
1018
1019
|
token: options.token,
|
|
1019
1020
|
useProjectHostname: options.useProjectHostname ?? !0
|
|
@@ -1076,6 +1077,7 @@ function makeHandle(handleArgs) {
|
|
|
1076
1077
|
dataset,
|
|
1077
1078
|
accessControl,
|
|
1078
1079
|
perspective,
|
|
1080
|
+
requestTagPrefix,
|
|
1079
1081
|
mutationGuard,
|
|
1080
1082
|
token,
|
|
1081
1083
|
useProjectHostname
|
|
@@ -1099,14 +1101,15 @@ function makeHandle(handleArgs) {
|
|
|
1099
1101
|
let s = registry.get(key);
|
|
1100
1102
|
return s === void 0 && (s = createTestStore(), registry.set(key, s)), s;
|
|
1101
1103
|
})(), concurrentEditKey = (id) => registryKey(projectId, dataset) + " " + id, record = (transactionId, mutations, tag) => {
|
|
1104
|
+
const effectiveTag = effectiveRequestTag(tag);
|
|
1102
1105
|
backend.log.push({
|
|
1103
1106
|
transactionId,
|
|
1104
1107
|
projectId,
|
|
1105
1108
|
dataset,
|
|
1106
1109
|
mutations,
|
|
1107
|
-
...
|
|
1110
|
+
...effectiveTag !== void 0 ? { tag: effectiveTag } : {}
|
|
1108
1111
|
});
|
|
1109
|
-
}, writeResult = (documents, results, transactionId, opts) => formatMutationResult(
|
|
1112
|
+
}, effectiveRequestTag = (tag) => requestTagPrefix === void 0 ? tag : tag ? `${requestTagPrefix}.${tag}` : requestTagPrefix, writeResult = (documents, results, transactionId, opts) => formatMutationResult(
|
|
1110
1113
|
documents,
|
|
1111
1114
|
results,
|
|
1112
1115
|
transactionId,
|
|
@@ -1422,6 +1425,7 @@ function makeHandle(handleArgs) {
|
|
|
1422
1425
|
projectId,
|
|
1423
1426
|
dataset,
|
|
1424
1427
|
perspective,
|
|
1428
|
+
...requestTagPrefix !== void 0 ? { requestTagPrefix } : {},
|
|
1425
1429
|
...token !== void 0 ? { token } : {},
|
|
1426
1430
|
useProjectHostname
|
|
1427
1431
|
}),
|
|
@@ -1434,6 +1438,7 @@ function makeHandle(handleArgs) {
|
|
|
1434
1438
|
dataset: config.dataset ?? dataset,
|
|
1435
1439
|
accessControl: rebinds ? config.accessControl : accessControl,
|
|
1436
1440
|
perspective: config.perspective ?? perspective,
|
|
1441
|
+
requestTagPrefix: config.requestTagPrefix ?? requestTagPrefix,
|
|
1437
1442
|
mutationGuard,
|
|
1438
1443
|
token: rebinds ? config.token : token,
|
|
1439
1444
|
useProjectHostname: config.useProjectHostname ?? useProjectHostname
|
|
@@ -1471,7 +1476,7 @@ function makeHandle(handleArgs) {
|
|
|
1471
1476
|
return wrapWithGuards(client, {
|
|
1472
1477
|
getStub: (name) => backend.stubs.get(name),
|
|
1473
1478
|
onCall: (method, args) => {
|
|
1474
|
-
const rec = { method, args, projectId, dataset }, tag = tagFromArgs(method, args);
|
|
1479
|
+
const rec = { method, args, projectId, dataset }, tag = OPTIONS_ARG_POSITION[method] === void 0 ? void 0 : effectiveRequestTag(tagFromArgs(method, args));
|
|
1475
1480
|
return tag !== void 0 && (rec.tag = tag), backend.calls.push(rec), (outcome) => {
|
|
1476
1481
|
"error" in outcome ? rec.error = outcome.error : rec.result = outcome.result;
|
|
1477
1482
|
};
|