@sanity/client 7.11.2 → 7.12.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/index.d.cts CHANGED
@@ -787,6 +787,10 @@ export declare interface ClientConfig {
787
787
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
788
788
  */
789
789
  stega?: StegaConfig | boolean
790
+ /**
791
+ * Lineage token for recursion control
792
+ */
793
+ lineage?: string
790
794
  }
791
795
 
792
796
  declare type ClientConfigResource =
package/dist/index.d.ts CHANGED
@@ -787,6 +787,10 @@ export declare interface ClientConfig {
787
787
  * Options for how, if enabled, Content Source Maps are encoded into query results using steganography
788
788
  */
789
789
  stega?: StegaConfig | boolean
790
+ /**
791
+ * Lineage token for recursion control
792
+ */
793
+ lineage?: string
790
794
  }
791
795
 
792
796
  declare type ClientConfigResource =
package/dist/index.js CHANGED
@@ -2658,6 +2658,7 @@ function defineCreateClientExports(envMiddleware, ClassConstructor) {
2658
2658
  maxRedirects: 0,
2659
2659
  maxRetries: config.maxRetries,
2660
2660
  retryDelay: config.retryDelay,
2661
+ lineage: config.lineage,
2661
2662
  ...options
2662
2663
  }),
2663
2664
  config
@@ -2669,10 +2670,19 @@ function defineDeprecatedCreateClient(createClient2) {
2669
2670
  return printNoDefaultExport(), createClient2(config);
2670
2671
  };
2671
2672
  }
2672
- var name = "@sanity/client", version = "7.11.2";
2673
+ var name = "@sanity/client", version = "7.12.0";
2673
2674
  const middleware = [
2674
2675
  debug({ verbose: !0, namespace: "sanity:client" }),
2675
2676
  headers({ "User-Agent": `${name} ${version}` }),
2677
+ // Lineage is used for recursion control/tracing and can be passed either through
2678
+ // client constructor or through environent variable.
2679
+ // Not used in browser environments.
2680
+ {
2681
+ processOptions(opts) {
2682
+ const lineage = typeof process < "u" && process.env.X_SANITY_LINEAGE || opts.lineage;
2683
+ return lineage && (opts.headers = opts.headers || {}, opts.headers["x-sanity-lineage"] = lineage), opts;
2684
+ }
2685
+ },
2676
2686
  // Enable keep-alive, and in addition limit the number of sockets that can be opened.
2677
2687
  // This avoids opening too many connections to the server if someone tries to execute
2678
2688
  // a bunch of requests in parallel. It's recommended to have a concurrency limit