integrate-sdk 0.5.0 → 0.5.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/react.js +20 -1
- package/dist/src/react/hooks.d.ts +10 -0
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1891,10 +1891,29 @@ function useIntegrateTokens(client) {
|
|
|
1891
1891
|
"x-integrate-tokens": JSON.stringify(tokens)
|
|
1892
1892
|
};
|
|
1893
1893
|
}, [tokens]);
|
|
1894
|
+
const fetchWithHeaders = import_react.useCallback(async (input, init) => {
|
|
1895
|
+
const mergedHeaders = new Headers(init?.headers);
|
|
1896
|
+
if (headers["x-integrate-tokens"]) {
|
|
1897
|
+
mergedHeaders.set("x-integrate-tokens", headers["x-integrate-tokens"]);
|
|
1898
|
+
}
|
|
1899
|
+
return fetch(input, {
|
|
1900
|
+
...init,
|
|
1901
|
+
headers: mergedHeaders
|
|
1902
|
+
});
|
|
1903
|
+
}, [headers]);
|
|
1904
|
+
const mergeHeaders = import_react.useCallback((existingHeaders) => {
|
|
1905
|
+
const merged = new Headers(existingHeaders);
|
|
1906
|
+
if (headers["x-integrate-tokens"]) {
|
|
1907
|
+
merged.set("x-integrate-tokens", headers["x-integrate-tokens"]);
|
|
1908
|
+
}
|
|
1909
|
+
return merged;
|
|
1910
|
+
}, [headers]);
|
|
1894
1911
|
return {
|
|
1895
1912
|
tokens,
|
|
1896
1913
|
headers,
|
|
1897
|
-
isLoading
|
|
1914
|
+
isLoading,
|
|
1915
|
+
fetch: fetchWithHeaders,
|
|
1916
|
+
mergeHeaders
|
|
1898
1917
|
};
|
|
1899
1918
|
}
|
|
1900
1919
|
export {
|
|
@@ -22,6 +22,16 @@ export interface UseIntegrateTokensResult {
|
|
|
22
22
|
* Whether tokens are currently being loaded
|
|
23
23
|
*/
|
|
24
24
|
isLoading: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Custom fetch function with integrate tokens automatically included
|
|
27
|
+
* Use this with libraries that accept a custom fetch function (like Vercel AI SDK's useChat)
|
|
28
|
+
*/
|
|
29
|
+
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to merge integrate headers with existing headers
|
|
32
|
+
* Useful for manual fetch calls where you need to combine headers
|
|
33
|
+
*/
|
|
34
|
+
mergeHeaders: (existingHeaders?: HeadersInit) => Headers;
|
|
25
35
|
}
|
|
26
36
|
/**
|
|
27
37
|
* React hook to access integrate-sdk provider tokens and headers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3E;;;OAGG;IACH,YAAY,EAAE,CAAC,eAAe,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GACrB,wBAAwB,CA+G1B"}
|