@sanity/client 7.2.2 → 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.
- package/README.md +4 -0
- package/dist/index.browser.cjs +3 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +12 -0
- package/dist/index.browser.d.ts +12 -0
- package/dist/index.browser.js +3 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +12 -0
- package/dist/stega.browser.d.ts +12 -0
- package/dist/stega.d.cts +12 -0
- package/dist/stega.d.ts +12 -0
- package/package.json +1 -1
- package/src/http/requestOptions.ts +4 -0
- package/src/types.ts +14 -0
- package/umd/sanityClient.js +3 -1
- package/umd/sanityClient.min.js +1 -1
package/dist/stega.browser.d.cts
CHANGED
|
@@ -621,6 +621,12 @@ export declare interface ClientConfig {
|
|
|
621
621
|
* Optional request tag prefix for all request tags
|
|
622
622
|
*/
|
|
623
623
|
requestTagPrefix?: string
|
|
624
|
+
/**
|
|
625
|
+
* Optional default headers to include with all requests
|
|
626
|
+
*
|
|
627
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
628
|
+
*/
|
|
629
|
+
headers?: Record<string, string>
|
|
624
630
|
ignoreBrowserTokenWarning?: boolean
|
|
625
631
|
withCredentials?: boolean
|
|
626
632
|
allowReconfigure?: boolean
|
|
@@ -1753,6 +1759,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
1753
1759
|
* The fully initialized stega config, can be used to check if stega is enabled
|
|
1754
1760
|
*/
|
|
1755
1761
|
stega: InitializedStegaConfig
|
|
1762
|
+
/**
|
|
1763
|
+
* Default headers to include with all requests
|
|
1764
|
+
*
|
|
1765
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
1766
|
+
*/
|
|
1767
|
+
headers?: Record<string, string>
|
|
1756
1768
|
}
|
|
1757
1769
|
|
|
1758
1770
|
/**
|
package/dist/stega.browser.d.ts
CHANGED
|
@@ -621,6 +621,12 @@ export declare interface ClientConfig {
|
|
|
621
621
|
* Optional request tag prefix for all request tags
|
|
622
622
|
*/
|
|
623
623
|
requestTagPrefix?: string
|
|
624
|
+
/**
|
|
625
|
+
* Optional default headers to include with all requests
|
|
626
|
+
*
|
|
627
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
628
|
+
*/
|
|
629
|
+
headers?: Record<string, string>
|
|
624
630
|
ignoreBrowserTokenWarning?: boolean
|
|
625
631
|
withCredentials?: boolean
|
|
626
632
|
allowReconfigure?: boolean
|
|
@@ -1753,6 +1759,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
1753
1759
|
* The fully initialized stega config, can be used to check if stega is enabled
|
|
1754
1760
|
*/
|
|
1755
1761
|
stega: InitializedStegaConfig
|
|
1762
|
+
/**
|
|
1763
|
+
* Default headers to include with all requests
|
|
1764
|
+
*
|
|
1765
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
1766
|
+
*/
|
|
1767
|
+
headers?: Record<string, string>
|
|
1756
1768
|
}
|
|
1757
1769
|
|
|
1758
1770
|
/**
|
package/dist/stega.d.cts
CHANGED
|
@@ -621,6 +621,12 @@ export declare interface ClientConfig {
|
|
|
621
621
|
* Optional request tag prefix for all request tags
|
|
622
622
|
*/
|
|
623
623
|
requestTagPrefix?: string
|
|
624
|
+
/**
|
|
625
|
+
* Optional default headers to include with all requests
|
|
626
|
+
*
|
|
627
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
628
|
+
*/
|
|
629
|
+
headers?: Record<string, string>
|
|
624
630
|
ignoreBrowserTokenWarning?: boolean
|
|
625
631
|
withCredentials?: boolean
|
|
626
632
|
allowReconfigure?: boolean
|
|
@@ -1753,6 +1759,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
1753
1759
|
* The fully initialized stega config, can be used to check if stega is enabled
|
|
1754
1760
|
*/
|
|
1755
1761
|
stega: InitializedStegaConfig
|
|
1762
|
+
/**
|
|
1763
|
+
* Default headers to include with all requests
|
|
1764
|
+
*
|
|
1765
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
1766
|
+
*/
|
|
1767
|
+
headers?: Record<string, string>
|
|
1756
1768
|
}
|
|
1757
1769
|
|
|
1758
1770
|
/**
|
package/dist/stega.d.ts
CHANGED
|
@@ -621,6 +621,12 @@ export declare interface ClientConfig {
|
|
|
621
621
|
* Optional request tag prefix for all request tags
|
|
622
622
|
*/
|
|
623
623
|
requestTagPrefix?: string
|
|
624
|
+
/**
|
|
625
|
+
* Optional default headers to include with all requests
|
|
626
|
+
*
|
|
627
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
628
|
+
*/
|
|
629
|
+
headers?: Record<string, string>
|
|
624
630
|
ignoreBrowserTokenWarning?: boolean
|
|
625
631
|
withCredentials?: boolean
|
|
626
632
|
allowReconfigure?: boolean
|
|
@@ -1753,6 +1759,12 @@ export declare interface InitializedClientConfig extends ClientConfig {
|
|
|
1753
1759
|
* The fully initialized stega config, can be used to check if stega is enabled
|
|
1754
1760
|
*/
|
|
1755
1761
|
stega: InitializedStegaConfig
|
|
1762
|
+
/**
|
|
1763
|
+
* Default headers to include with all requests
|
|
1764
|
+
*
|
|
1765
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
1766
|
+
*/
|
|
1767
|
+
headers?: Record<string, string>
|
|
1756
1768
|
}
|
|
1757
1769
|
|
|
1758
1770
|
/**
|
package/package.json
CHANGED
|
@@ -7,6 +7,10 @@ const projectHeader = 'X-Sanity-Project-ID'
|
|
|
7
7
|
export function requestOptions(config: Any, overrides: Any = {}): Omit<RequestOptions, 'url'> {
|
|
8
8
|
const headers: Any = {}
|
|
9
9
|
|
|
10
|
+
if (config.headers) {
|
|
11
|
+
Object.assign(headers, config.headers)
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
const token = overrides.token || config.token
|
|
11
15
|
if (token) {
|
|
12
16
|
headers.Authorization = `Bearer ${token}`
|
package/src/types.ts
CHANGED
|
@@ -102,6 +102,14 @@ export interface ClientConfig {
|
|
|
102
102
|
* Optional request tag prefix for all request tags
|
|
103
103
|
*/
|
|
104
104
|
requestTagPrefix?: string
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Optional default headers to include with all requests
|
|
108
|
+
*
|
|
109
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
110
|
+
*/
|
|
111
|
+
headers?: Record<string, string>
|
|
112
|
+
|
|
105
113
|
ignoreBrowserTokenWarning?: boolean
|
|
106
114
|
withCredentials?: boolean
|
|
107
115
|
allowReconfigure?: boolean
|
|
@@ -173,6 +181,12 @@ export interface InitializedClientConfig extends ClientConfig {
|
|
|
173
181
|
* The fully initialized stega config, can be used to check if stega is enabled
|
|
174
182
|
*/
|
|
175
183
|
stega: InitializedStegaConfig
|
|
184
|
+
/**
|
|
185
|
+
* Default headers to include with all requests
|
|
186
|
+
*
|
|
187
|
+
* @remarks request-specific headers will override any default headers with the same name.
|
|
188
|
+
*/
|
|
189
|
+
headers?: Record<string, string>
|
|
176
190
|
}
|
|
177
191
|
|
|
178
192
|
/** @public */
|
package/umd/sanityClient.js
CHANGED
|
@@ -2695,7 +2695,9 @@ ${selectionOpts}`);
|
|
|
2695
2695
|
}
|
|
2696
2696
|
const projectHeader = "X-Sanity-Project-ID";
|
|
2697
2697
|
function requestOptions(config, overrides = {}) {
|
|
2698
|
-
const headers = {}
|
|
2698
|
+
const headers = {};
|
|
2699
|
+
config.headers && Object.assign(headers, config.headers);
|
|
2700
|
+
const token = overrides.token || config.token;
|
|
2699
2701
|
token && (headers.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config.useProjectHostname && config.projectId && (headers[projectHeader] = config.projectId);
|
|
2700
2702
|
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
|
|
2701
2703
|
return Object.assign({}, overrides, {
|