@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 CHANGED
@@ -1016,6 +1016,7 @@ function createTestClient(options = {}) {
1016
1016
  dataset: defaultDataset,
1017
1017
  accessControl: options.accessControl,
1018
1018
  perspective: options.perspective ?? "raw",
1019
+ requestTagPrefix: options.requestTagPrefix,
1019
1020
  mutationGuard: options.mutationGuard,
1020
1021
  token: options.token,
1021
1022
  useProjectHostname: options.useProjectHostname ?? !0
@@ -1078,6 +1079,7 @@ function makeHandle(handleArgs) {
1078
1079
  dataset,
1079
1080
  accessControl,
1080
1081
  perspective,
1082
+ requestTagPrefix,
1081
1083
  mutationGuard,
1082
1084
  token,
1083
1085
  useProjectHostname
@@ -1101,14 +1103,15 @@ function makeHandle(handleArgs) {
1101
1103
  let s = registry.get(key);
1102
1104
  return s === void 0 && (s = createTestStore(), registry.set(key, s)), s;
1103
1105
  })(), concurrentEditKey = (id) => registryKey(projectId, dataset) + " " + id, record = (transactionId, mutations, tag) => {
1106
+ const effectiveTag = effectiveRequestTag(tag);
1104
1107
  backend.log.push({
1105
1108
  transactionId,
1106
1109
  projectId,
1107
1110
  dataset,
1108
1111
  mutations,
1109
- ...tag !== void 0 ? { tag } : {}
1112
+ ...effectiveTag !== void 0 ? { tag: effectiveTag } : {}
1110
1113
  });
1111
- }, writeResult = (documents, results, transactionId, opts) => formatMutationResult(
1114
+ }, effectiveRequestTag = (tag) => requestTagPrefix === void 0 ? tag : tag ? `${requestTagPrefix}.${tag}` : requestTagPrefix, writeResult = (documents, results, transactionId, opts) => formatMutationResult(
1112
1115
  documents,
1113
1116
  results,
1114
1117
  transactionId,
@@ -1424,6 +1427,7 @@ function makeHandle(handleArgs) {
1424
1427
  projectId,
1425
1428
  dataset,
1426
1429
  perspective,
1430
+ ...requestTagPrefix !== void 0 ? { requestTagPrefix } : {},
1427
1431
  ...token !== void 0 ? { token } : {},
1428
1432
  useProjectHostname
1429
1433
  }),
@@ -1436,6 +1440,7 @@ function makeHandle(handleArgs) {
1436
1440
  dataset: config.dataset ?? dataset,
1437
1441
  accessControl: rebinds ? config.accessControl : accessControl,
1438
1442
  perspective: config.perspective ?? perspective,
1443
+ requestTagPrefix: config.requestTagPrefix ?? requestTagPrefix,
1439
1444
  mutationGuard,
1440
1445
  token: rebinds ? config.token : token,
1441
1446
  useProjectHostname: config.useProjectHostname ?? useProjectHostname
@@ -1473,7 +1478,7 @@ function makeHandle(handleArgs) {
1473
1478
  return wrapWithGuards(client, {
1474
1479
  getStub: (name) => backend.stubs.get(name),
1475
1480
  onCall: (method, args) => {
1476
- const rec = { method, args, projectId, dataset }, tag = tagFromArgs(method, args);
1481
+ const rec = { method, args, projectId, dataset }, tag = OPTIONS_ARG_POSITION[method] === void 0 ? void 0 : effectiveRequestTag(tagFromArgs(method, args));
1477
1482
  return tag !== void 0 && (rec.tag = tag), backend.calls.push(rec), (outcome) => {
1478
1483
  "error" in outcome ? rec.error = outcome.error : rec.result = outcome.result;
1479
1484
  };