omni-sync-sdk 0.20.2 → 0.20.3

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.d.mts CHANGED
@@ -4185,6 +4185,11 @@ declare class OmniSyncClient {
4185
4185
  * @internal
4186
4186
  */
4187
4187
  private getOrCreateCustomerCart;
4188
+ /**
4189
+ * Fetch the customer's existing cart from server
4190
+ * @internal
4191
+ */
4192
+ private fetchCustomerCart;
4188
4193
  /**
4189
4194
  * Smart add to cart - automatically uses localStorage or server based on auth state
4190
4195
  *
package/dist/index.d.ts CHANGED
@@ -4185,6 +4185,11 @@ declare class OmniSyncClient {
4185
4185
  * @internal
4186
4186
  */
4187
4187
  private getOrCreateCustomerCart;
4188
+ /**
4189
+ * Fetch the customer's existing cart from server
4190
+ * @internal
4191
+ */
4192
+ private fetchCustomerCart;
4188
4193
  /**
4189
4194
  * Smart add to cart - automatically uses localStorage or server based on auth state
4190
4195
  *
package/dist/index.js CHANGED
@@ -2032,6 +2032,14 @@ var OmniSyncClient = class {
2032
2032
  this.customerCartId = null;
2033
2033
  }
2034
2034
  }
2035
+ try {
2036
+ const cart2 = await this.fetchCustomerCart();
2037
+ if (cart2.status === "ACTIVE") {
2038
+ this.customerCartId = cart2.id;
2039
+ return cart2;
2040
+ }
2041
+ } catch {
2042
+ }
2035
2043
  const cart = await this.createCart();
2036
2044
  this.customerCartId = cart.id;
2037
2045
  if (this.customerToken) {
@@ -2042,6 +2050,22 @@ var OmniSyncClient = class {
2042
2050
  }
2043
2051
  return cart;
2044
2052
  }
2053
+ /**
2054
+ * Fetch the customer's existing cart from server
2055
+ * @internal
2056
+ */
2057
+ async fetchCustomerCart() {
2058
+ if (!this.customerToken) {
2059
+ throw new OmniSyncError("Customer token required", 401);
2060
+ }
2061
+ if (this.isVibeCodedMode()) {
2062
+ return this.vibeCodedRequest("GET", "/customers/me/cart");
2063
+ }
2064
+ if (this.storeId && !this.apiKey) {
2065
+ return this.storefrontRequest("GET", "/customers/me/cart");
2066
+ }
2067
+ throw new OmniSyncError("fetchCustomerCart requires vibe-coded or storefront mode", 400);
2068
+ }
2045
2069
  /**
2046
2070
  * Smart add to cart - automatically uses localStorage or server based on auth state
2047
2071
  *
package/dist/index.mjs CHANGED
@@ -1995,6 +1995,14 @@ var OmniSyncClient = class {
1995
1995
  this.customerCartId = null;
1996
1996
  }
1997
1997
  }
1998
+ try {
1999
+ const cart2 = await this.fetchCustomerCart();
2000
+ if (cart2.status === "ACTIVE") {
2001
+ this.customerCartId = cart2.id;
2002
+ return cart2;
2003
+ }
2004
+ } catch {
2005
+ }
1998
2006
  const cart = await this.createCart();
1999
2007
  this.customerCartId = cart.id;
2000
2008
  if (this.customerToken) {
@@ -2005,6 +2013,22 @@ var OmniSyncClient = class {
2005
2013
  }
2006
2014
  return cart;
2007
2015
  }
2016
+ /**
2017
+ * Fetch the customer's existing cart from server
2018
+ * @internal
2019
+ */
2020
+ async fetchCustomerCart() {
2021
+ if (!this.customerToken) {
2022
+ throw new OmniSyncError("Customer token required", 401);
2023
+ }
2024
+ if (this.isVibeCodedMode()) {
2025
+ return this.vibeCodedRequest("GET", "/customers/me/cart");
2026
+ }
2027
+ if (this.storeId && !this.apiKey) {
2028
+ return this.storefrontRequest("GET", "/customers/me/cart");
2029
+ }
2030
+ throw new OmniSyncError("fetchCustomerCart requires vibe-coded or storefront mode", 400);
2031
+ }
2008
2032
  /**
2009
2033
  * Smart add to cart - automatically uses localStorage or server based on auth state
2010
2034
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.20.2",
3
+ "version": "0.20.3",
4
4
  "description": "Official SDK for building e-commerce storefronts with OmniSync Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",