arky-sdk 0.3.71 → 0.3.73

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 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.66";
1675
+ var SDK_VERSION = "0.3.73";
1676
1676
  var SUPPORTED_FRAMEWORKS = [
1677
1677
  "astro",
1678
1678
  "react",
@@ -1680,11 +1680,8 @@ 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
- console.log(
1686
- `[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}, locale: ${locale}`
1687
- );
1688
1685
  const httpClient = createHttpClient(config);
1689
1686
  const apiConfig = {
1690
1687
  httpClient,
@@ -1697,6 +1694,21 @@ function createArkySDK(config) {
1697
1694
  };
1698
1695
  const userApi = createUserApi(apiConfig);
1699
1696
  const autoGuest = config.autoGuest !== void 0 ? config.autoGuest : true;
1697
+ if (autoGuest) {
1698
+ try {
1699
+ const tokens = await config.getToken();
1700
+ if (!tokens.accessToken && !tokens.refreshToken) {
1701
+ const result = await httpClient.post("/v1/users/login", {
1702
+ provider: "GUEST"
1703
+ });
1704
+ const token = result.accessToken || result.token || "";
1705
+ if (token) {
1706
+ config.setToken(result);
1707
+ }
1708
+ }
1709
+ } catch (error) {
1710
+ }
1711
+ }
1700
1712
  const sdk = {
1701
1713
  user: userApi,
1702
1714
  business: createBusinessApi(apiConfig),
@@ -1725,6 +1737,8 @@ function createArkySDK(config) {
1725
1737
  isAuthenticated: config.isAuthenticated || (() => false),
1726
1738
  logout: config.logout,
1727
1739
  setToken: config.setToken,
1740
+ // Top-level block utilities for convenience
1741
+ extractBlockValues,
1728
1742
  utils: {
1729
1743
  // Block utilities
1730
1744
  getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock),
@@ -1761,30 +1775,6 @@ function createArkySDK(config) {
1761
1775
  injectSvgIntoElement
1762
1776
  }
1763
1777
  };
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
1778
  return sdk;
1789
1779
  }
1790
1780