@sanity/client 7.2.1 → 7.3.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.
@@ -627,6 +627,12 @@ export declare interface ClientConfig {
627
627
  * Optional request tag prefix for all request tags
628
628
  */
629
629
  requestTagPrefix?: string
630
+ /**
631
+ * Optional default headers to include with all requests
632
+ *
633
+ * @remarks request-specific headers will override any default headers with the same name.
634
+ */
635
+ headers?: Record<string, string>
630
636
  ignoreBrowserTokenWarning?: boolean
631
637
  withCredentials?: boolean
632
638
  allowReconfigure?: boolean
@@ -1593,6 +1599,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
1593
1599
  * The fully initialized stega config, can be used to check if stega is enabled
1594
1600
  */
1595
1601
  stega: InitializedStegaConfig
1602
+ /**
1603
+ * Default headers to include with all requests
1604
+ *
1605
+ * @remarks request-specific headers will override any default headers with the same name.
1606
+ */
1607
+ headers?: Record<string, string>
1596
1608
  }
1597
1609
 
1598
1610
  /** @public */
@@ -627,6 +627,12 @@ export declare interface ClientConfig {
627
627
  * Optional request tag prefix for all request tags
628
628
  */
629
629
  requestTagPrefix?: string
630
+ /**
631
+ * Optional default headers to include with all requests
632
+ *
633
+ * @remarks request-specific headers will override any default headers with the same name.
634
+ */
635
+ headers?: Record<string, string>
630
636
  ignoreBrowserTokenWarning?: boolean
631
637
  withCredentials?: boolean
632
638
  allowReconfigure?: boolean
@@ -1593,6 +1599,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
1593
1599
  * The fully initialized stega config, can be used to check if stega is enabled
1594
1600
  */
1595
1601
  stega: InitializedStegaConfig
1602
+ /**
1603
+ * Default headers to include with all requests
1604
+ *
1605
+ * @remarks request-specific headers will override any default headers with the same name.
1606
+ */
1607
+ headers?: Record<string, string>
1596
1608
  }
1597
1609
 
1598
1610
  /** @public */
@@ -724,7 +724,9 @@ class ObservableTransaction extends BaseTransaction {
724
724
  }
725
725
  const projectHeader = "X-Sanity-Project-ID";
726
726
  function requestOptions(config, overrides = {}) {
727
- const headers = {}, token = overrides.token || config.token;
727
+ const headers = {};
728
+ config.headers && Object.assign(headers, config.headers);
729
+ const token = overrides.token || config.token;
728
730
  token && (headers.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config.useProjectHostname && config.projectId && (headers[projectHeader] = config.projectId);
729
731
  const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
730
732
  return Object.assign({}, overrides, {