arky-sdk 0.3.71 → 0.3.72
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 +26 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1672,7 +1672,7 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
|
|
1674
1674
|
// src/index.ts
|
|
1675
|
-
var SDK_VERSION = "0.3.
|
|
1675
|
+
var SDK_VERSION = "0.3.72";
|
|
1676
1676
|
var SUPPORTED_FRAMEWORKS = [
|
|
1677
1677
|
"astro",
|
|
1678
1678
|
"react",
|
|
@@ -1680,7 +1680,7 @@ var SUPPORTED_FRAMEWORKS = [
|
|
|
1680
1680
|
"svelte",
|
|
1681
1681
|
"vanilla"
|
|
1682
1682
|
];
|
|
1683
|
-
function createArkySDK(config) {
|
|
1683
|
+
async function createArkySDK(config) {
|
|
1684
1684
|
const locale = config.locale || "en";
|
|
1685
1685
|
console.log(
|
|
1686
1686
|
`[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}, locale: ${locale}`
|
|
@@ -1697,6 +1697,28 @@ function createArkySDK(config) {
|
|
|
1697
1697
|
};
|
|
1698
1698
|
const userApi = createUserApi(apiConfig);
|
|
1699
1699
|
const autoGuest = config.autoGuest !== void 0 ? config.autoGuest : true;
|
|
1700
|
+
if (autoGuest) {
|
|
1701
|
+
try {
|
|
1702
|
+
const tokens = await config.getToken();
|
|
1703
|
+
if (!tokens.accessToken && !tokens.refreshToken) {
|
|
1704
|
+
const result = await httpClient.post("/v1/users/login", {
|
|
1705
|
+
provider: "GUEST"
|
|
1706
|
+
});
|
|
1707
|
+
const token = result.accessToken || result.token || "";
|
|
1708
|
+
if (token) {
|
|
1709
|
+
config.setToken(result);
|
|
1710
|
+
}
|
|
1711
|
+
console.log(
|
|
1712
|
+
"[SDK Init] Created guest token:",
|
|
1713
|
+
token ? "Success" : "Failed"
|
|
1714
|
+
);
|
|
1715
|
+
} else {
|
|
1716
|
+
console.log("[SDK Init] Using existing token from storage");
|
|
1717
|
+
}
|
|
1718
|
+
} catch (error) {
|
|
1719
|
+
console.error("[SDK Init] Failed to initialize auth:", error);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1700
1722
|
const sdk = {
|
|
1701
1723
|
user: userApi,
|
|
1702
1724
|
business: createBusinessApi(apiConfig),
|
|
@@ -1725,6 +1747,8 @@ function createArkySDK(config) {
|
|
|
1725
1747
|
isAuthenticated: config.isAuthenticated || (() => false),
|
|
1726
1748
|
logout: config.logout,
|
|
1727
1749
|
setToken: config.setToken,
|
|
1750
|
+
// Top-level block utilities for convenience
|
|
1751
|
+
extractBlockValues,
|
|
1728
1752
|
utils: {
|
|
1729
1753
|
// Block utilities
|
|
1730
1754
|
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
|
|
@@ -1761,30 +1785,6 @@ function createArkySDK(config) {
|
|
|
1761
1785
|
injectSvgIntoElement
|
|
1762
1786
|
}
|
|
1763
1787
|
};
|
|
1764
|
-
if (autoGuest) {
|
|
1765
|
-
Promise.resolve().then(async () => {
|
|
1766
|
-
try {
|
|
1767
|
-
const tokens = await config.getToken();
|
|
1768
|
-
if (!tokens.accessToken && !tokens.refreshToken) {
|
|
1769
|
-
const result = await httpClient.post("/v1/users/login", {
|
|
1770
|
-
provider: "GUEST"
|
|
1771
|
-
});
|
|
1772
|
-
const token = result.accessToken || result.token || "";
|
|
1773
|
-
if (token) {
|
|
1774
|
-
config.setToken(result);
|
|
1775
|
-
}
|
|
1776
|
-
console.log(
|
|
1777
|
-
"[SDK Init] Created guest token:",
|
|
1778
|
-
token ? "Success" : "Failed"
|
|
1779
|
-
);
|
|
1780
|
-
} else {
|
|
1781
|
-
console.log("[SDK Init] Using existing token from storage");
|
|
1782
|
-
}
|
|
1783
|
-
} catch (error) {
|
|
1784
|
-
console.error("[SDK Init] Failed to initialize auth:", error);
|
|
1785
|
-
}
|
|
1786
|
-
});
|
|
1787
|
-
}
|
|
1788
1788
|
return sdk;
|
|
1789
1789
|
}
|
|
1790
1790
|
|