omni-sync-sdk 0.19.2 → 0.19.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
@@ -1338,6 +1338,16 @@ interface AddToCartDto {
1338
1338
  quantity: number;
1339
1339
  notes?: string;
1340
1340
  metadata?: Record<string, unknown>;
1341
+ /**
1342
+ * Optional product info for local cart (guest mode).
1343
+ * If provided, SDK uses this directly without fetching from API.
1344
+ * Recommended: pass this when you already have the product loaded.
1345
+ */
1346
+ productInfo?: {
1347
+ name: string;
1348
+ price: string;
1349
+ image?: string;
1350
+ };
1341
1351
  }
1342
1352
  interface UpdateCartItemDto {
1343
1353
  quantity: number;
package/dist/index.d.ts CHANGED
@@ -1338,6 +1338,16 @@ interface AddToCartDto {
1338
1338
  quantity: number;
1339
1339
  notes?: string;
1340
1340
  metadata?: Record<string, unknown>;
1341
+ /**
1342
+ * Optional product info for local cart (guest mode).
1343
+ * If provided, SDK uses this directly without fetching from API.
1344
+ * Recommended: pass this when you already have the product loaded.
1345
+ */
1346
+ productInfo?: {
1347
+ name: string;
1348
+ price: string;
1349
+ image?: string;
1350
+ };
1341
1351
  }
1342
1352
  interface UpdateCartItemDto {
1343
1353
  quantity: number;
package/dist/index.js CHANGED
@@ -1759,21 +1759,27 @@ var OmniSyncClient = class {
1759
1759
  let productName = "Unknown Product";
1760
1760
  let productPrice = "0";
1761
1761
  let productImage;
1762
- try {
1763
- const product = await this.getProduct(item.productId);
1764
- productName = product.name;
1765
- productPrice = product.salePrice || product.basePrice;
1766
- productImage = product.images?.[0]?.url;
1767
- if (item.variantId && product.variants) {
1768
- const variant = product.variants.find((v) => v.id === item.variantId);
1769
- if (variant) {
1770
- productPrice = variant.salePrice || variant.price || productPrice;
1771
- if (variant.image) {
1772
- productImage = typeof variant.image === "string" ? variant.image : variant.image.url;
1762
+ if (item.productInfo) {
1763
+ productName = item.productInfo.name;
1764
+ productPrice = item.productInfo.price;
1765
+ productImage = item.productInfo.image;
1766
+ } else {
1767
+ try {
1768
+ const product = await this.getProduct(item.productId);
1769
+ productName = product.name;
1770
+ productPrice = product.salePrice || product.basePrice;
1771
+ productImage = product.images?.[0]?.url;
1772
+ if (item.variantId && product.variants) {
1773
+ const variant = product.variants.find((v) => v.id === item.variantId);
1774
+ if (variant) {
1775
+ productPrice = variant.salePrice || variant.price || productPrice;
1776
+ if (variant.image) {
1777
+ productImage = typeof variant.image === "string" ? variant.image : variant.image.url;
1778
+ }
1773
1779
  }
1774
1780
  }
1781
+ } catch {
1775
1782
  }
1776
- } catch {
1777
1783
  }
1778
1784
  this.addToLocalCart({
1779
1785
  productId: item.productId,
package/dist/index.mjs CHANGED
@@ -1722,21 +1722,27 @@ var OmniSyncClient = class {
1722
1722
  let productName = "Unknown Product";
1723
1723
  let productPrice = "0";
1724
1724
  let productImage;
1725
- try {
1726
- const product = await this.getProduct(item.productId);
1727
- productName = product.name;
1728
- productPrice = product.salePrice || product.basePrice;
1729
- productImage = product.images?.[0]?.url;
1730
- if (item.variantId && product.variants) {
1731
- const variant = product.variants.find((v) => v.id === item.variantId);
1732
- if (variant) {
1733
- productPrice = variant.salePrice || variant.price || productPrice;
1734
- if (variant.image) {
1735
- productImage = typeof variant.image === "string" ? variant.image : variant.image.url;
1725
+ if (item.productInfo) {
1726
+ productName = item.productInfo.name;
1727
+ productPrice = item.productInfo.price;
1728
+ productImage = item.productInfo.image;
1729
+ } else {
1730
+ try {
1731
+ const product = await this.getProduct(item.productId);
1732
+ productName = product.name;
1733
+ productPrice = product.salePrice || product.basePrice;
1734
+ productImage = product.images?.[0]?.url;
1735
+ if (item.variantId && product.variants) {
1736
+ const variant = product.variants.find((v) => v.id === item.variantId);
1737
+ if (variant) {
1738
+ productPrice = variant.salePrice || variant.price || productPrice;
1739
+ if (variant.image) {
1740
+ productImage = typeof variant.image === "string" ? variant.image : variant.image.url;
1741
+ }
1736
1742
  }
1737
1743
  }
1744
+ } catch {
1738
1745
  }
1739
- } catch {
1740
1746
  }
1741
1747
  this.addToLocalCart({
1742
1748
  productId: item.productId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.19.2",
3
+ "version": "0.19.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",