omni-sync-sdk 0.22.2 → 0.22.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.
@@ -543,13 +543,16 @@ result.checkoutId (guest checkout) // ⚠️ Check result.tracked first! It's
543
543
  - **`GuestCheckoutStartResponse`** is a union type — always check `result.tracked` before accessing `result.checkoutId`
544
544
  - **`WaitForOrderResult`** has `result.status.orderNumber`, NOT `result.orderNumber`. But `completeGuestCheckout()` returns `GuestOrderResponse` which DOES have `result.orderNumber` directly.
545
545
  - **⚠️ HYDRATION: Never use `useState(omni.getLocalCart())`** in Next.js — causes hydration mismatch! Server has no localStorage (empty cart) but client does (real cart). Always start with empty state and load in `useEffect`:
546
+
546
547
  ```typescript
547
548
  // ❌ WRONG — hydration mismatch!
548
549
  const [cart, setCart] = useState(omni.getLocalCart());
549
550
 
550
551
  // ✅ CORRECT — load after hydration
551
552
  const [cart, setCart] = useState<LocalCart>({ items: [], updatedAt: '' });
552
- useEffect(() => { setCart(omni.getLocalCart()); }, []);
553
+ useEffect(() => {
554
+ setCart(omni.getLocalCart());
555
+ }, []);
553
556
  ```
554
557
 
555
558
  ---
package/LICENSE ADDED
File without changes
package/dist/index.d.mts CHANGED
@@ -158,7 +158,11 @@ interface Product {
158
158
  images?: ProductImage[];
159
159
  inventory?: InventoryInfo | null;
160
160
  variants?: ProductVariant[];
161
- /** Categories as objects with id and name */
161
+ /**
162
+ * Categories as objects with `id` and `name`.
163
+ * NOT string[] - each category is `{ id: string; name: string }`.
164
+ * Access: `product.categories?.map(cat => cat.name)`
165
+ */
162
166
  categories?: Array<{
163
167
  id: string;
164
168
  name: string;
@@ -643,10 +647,17 @@ interface ProductQueryParams {
643
647
  /**
644
648
  * Product suggestion for autocomplete
645
649
  */
650
+ /**
651
+ * Product suggestion for search autocomplete.
652
+ *
653
+ * **Note:** `slug` can be `null` - don't use it as a React key, use `id` instead.
654
+ */
646
655
  interface ProductSuggestion {
647
656
  id: string;
648
657
  name: string;
658
+ /** Can be null! Do NOT use as React key. Use `id` instead. */
649
659
  slug: string | null;
660
+ /** Can be null if product has no images */
650
661
  image: string | null;
651
662
  /** Effective price as string (salePrice if on sale, otherwise basePrice). */
652
663
  price: string;
@@ -657,7 +668,9 @@ interface ProductSuggestion {
657
668
  type: 'SIMPLE' | 'VARIABLE';
658
669
  }
659
670
  /**
660
- * Category suggestion for autocomplete
671
+ * Category suggestion for autocomplete.
672
+ *
673
+ * **Note:** This type has NO `slug` field - only `id`, `name`, `productCount`.
661
674
  */
662
675
  interface CategorySuggestion {
663
676
  id: string;
@@ -747,6 +760,10 @@ interface Order {
747
760
  platform?: string;
748
761
  createdAt: string;
749
762
  }
763
+ /**
764
+ * Order status values are **lowercase**.
765
+ * Do NOT use uppercase values like 'COMPLETED' or 'CANCELLED'.
766
+ */
750
767
  type OrderStatus = 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';
751
768
  interface OrderCustomer {
752
769
  email: string;
@@ -769,6 +786,24 @@ interface OrderAddress {
769
786
  country: string;
770
787
  phone?: string;
771
788
  }
789
+ /**
790
+ * Order line item. **This is a flat structure** - unlike CartItem/CheckoutLineItem.
791
+ *
792
+ * **Common mistakes:**
793
+ * - This type has NO `id` field. Use `productId` + index as React key.
794
+ * - Access `item.name` directly (NOT `item.product.name` like CartItem).
795
+ * - Access `item.price` directly (NOT `item.unitPrice` like CartItem).
796
+ *
797
+ * @example
798
+ * ```typescript
799
+ * order.items.map((item, index) => (
800
+ * <div key={`${item.productId}-${index}`}>
801
+ * <span>{item.name}</span>
802
+ * <span>{item.price}</span>
803
+ * </div>
804
+ * ))
805
+ * ```
806
+ */
772
807
  interface OrderItem {
773
808
  productId: string;
774
809
  variantId?: string;
@@ -779,6 +814,8 @@ interface OrderItem {
779
814
  /**
780
815
  * Price per unit as string (e.g., "29.99").
781
816
  * Use parseFloat() for calculations.
817
+ *
818
+ * **Note:** This is `price`, not `unitPrice` (unlike CartItem/CheckoutLineItem).
782
819
  */
783
820
  price: string;
784
821
  /** Product image URL (flat, not nested under product object) */
@@ -1393,8 +1430,24 @@ interface LocalCartItem {
1393
1430
  addedAt: string;
1394
1431
  }
1395
1432
  /**
1396
- * Local cart stored in localStorage/cookies
1397
- * Complete client-side cart for guest users
1433
+ * Local cart stored in localStorage/cookies.
1434
+ * Complete client-side cart for guest users.
1435
+ *
1436
+ * **Initialization:** You can initialize with just `{ items: [] }`.
1437
+ * All other fields are optional.
1438
+ *
1439
+ * **Note:** This is NOT the same as the server `Cart` type.
1440
+ * - `getCartTotals()` does NOT work with LocalCart (use manual calculation)
1441
+ * - Calculate total: `cart.items.reduce((sum, item) => sum + parseFloat(item.price || '0') * item.quantity, 0)`
1442
+ *
1443
+ * @example
1444
+ * ```typescript
1445
+ * // Simple initialization
1446
+ * const [cart, setCart] = useState<LocalCart>({ items: [] });
1447
+ *
1448
+ * // Or with null initial state
1449
+ * const [cart, setCart] = useState<LocalCart | null>(null);
1450
+ * ```
1398
1451
  */
1399
1452
  interface LocalCart {
1400
1453
  items: LocalCartItem[];
@@ -1428,7 +1481,8 @@ interface LocalCart {
1428
1481
  phone?: string;
1429
1482
  };
1430
1483
  notes?: string;
1431
- updatedAt: string;
1484
+ /** Last update timestamp. Optional - auto-set when you don't provide it. */
1485
+ updatedAt?: string;
1432
1486
  }
1433
1487
  /**
1434
1488
  * DTO for creating order directly (guest checkout)
@@ -1485,6 +1539,25 @@ interface GuestOrderResponse {
1485
1539
  * If tracking is enabled, returns checkoutId and cartId
1486
1540
  * If tracking is not enabled, returns tracked: false
1487
1541
  */
1542
+ /**
1543
+ * Response from starting guest checkout. **This is a discriminated union.**
1544
+ *
1545
+ * You MUST check `result.tracked` before accessing `checkoutId`:
1546
+ * - `tracked: true` → has `checkoutId` and `cartId`
1547
+ * - `tracked: false` → only has `message` (no checkoutId!)
1548
+ *
1549
+ * @example
1550
+ * ```typescript
1551
+ * const result = await omni.startGuestCheckout(cart);
1552
+ * if (result.tracked) {
1553
+ * // Safe to access checkoutId and cartId
1554
+ * console.log(result.checkoutId, result.cartId);
1555
+ * } else {
1556
+ * // Untracked checkout - no checkoutId available
1557
+ * console.log(result.message);
1558
+ * }
1559
+ * ```
1560
+ */
1488
1561
  type GuestCheckoutStartResponse = {
1489
1562
  tracked: true;
1490
1563
  checkoutId: string;
@@ -2167,13 +2240,18 @@ interface CustomApiTestResult {
2167
2240
  error?: string;
2168
2241
  }
2169
2242
  /**
2170
- * Payment provider configuration.
2243
+ * Payment provider configuration (returned by `getPaymentProviders()`).
2171
2244
  * Contains only public information safe to expose in frontend.
2245
+ *
2246
+ * **Note:** `provider` is a flexible `string` (not an enum).
2247
+ * Common values: `'stripe'`, `'paypal'`.
2248
+ *
2249
+ * **Alias:** `PaymentProvider` is the same type (use either name).
2172
2250
  */
2173
2251
  interface PaymentProviderConfig {
2174
2252
  /** Provider ID (use this when creating payment intents) */
2175
2253
  id: string;
2176
- /** Payment provider type: 'stripe', 'paypal' */
2254
+ /** Payment provider type: 'stripe', 'paypal' (flexible string, not enum) */
2177
2255
  provider: string;
2178
2256
  /** Display name for the provider */
2179
2257
  name: string;
@@ -2188,7 +2266,10 @@ interface PaymentProviderConfig {
2188
2266
  /** Whether this is the default provider */
2189
2267
  isDefault: boolean;
2190
2268
  }
2191
- /** Alias for PaymentProviderConfig for convenience */
2269
+ /**
2270
+ * Alias for `PaymentProviderConfig`.
2271
+ * Both types are identical - use whichever name you prefer.
2272
+ */
2192
2273
  type PaymentProvider = PaymentProviderConfig;
2193
2274
  /**
2194
2275
  * All available payment providers for a store.
@@ -2303,12 +2384,31 @@ interface WaitForOrderOptions {
2303
2384
  onPollAttempt?: (attempt: number, status: PaymentStatus) => void;
2304
2385
  }
2305
2386
  /**
2306
- * Result from waitForOrder method.
2387
+ * Result from `waitForOrder()` method.
2388
+ *
2389
+ * **Important:** `status` is a `PaymentStatus` object, NOT a string.
2390
+ * Access order number via `result.status.orderNumber`.
2391
+ *
2392
+ * For `completeGuestCheckout()`, use `GuestOrderResponse` instead
2393
+ * which has `result.orderNumber` directly.
2394
+ *
2395
+ * @example
2396
+ * ```typescript
2397
+ * const result = await omni.waitForOrder(checkoutId);
2398
+ * if (result.success) {
2399
+ * const orderNumber = result.status.orderNumber; // e.g., "ORD-20260201-0001"
2400
+ * const orderId = result.status.orderId;
2401
+ * }
2402
+ * ```
2307
2403
  */
2308
2404
  interface WaitForOrderResult {
2309
2405
  /** Whether the order was created within the timeout */
2310
2406
  success: boolean;
2311
- /** Final payment status */
2407
+ /**
2408
+ * Final payment status object.
2409
+ * Access order number: `result.status.orderNumber`
2410
+ * Access order ID: `result.status.orderId`
2411
+ */
2312
2412
  status: PaymentStatus;
2313
2413
  /** Number of poll attempts made */
2314
2414
  attempts: number;
@@ -4272,15 +4372,19 @@ declare class OmniSyncClient {
4272
4372
  */
4273
4373
  removeCoupon(cartId: string): Promise<Cart>;
4274
4374
  /**
4275
- * Link a cart to the currently logged-in customer
4276
- * Use this after customer logs in to associate their guest cart with their account
4277
- * Requires customer token to be set via setCustomerToken()
4375
+ * Link a cart to the currently logged-in customer.
4376
+ * Use this after customer logs in to associate their guest cart with their account.
4377
+ * Requires customer token to be set via setCustomerToken().
4378
+ *
4379
+ * **Important:** `cartId` is required - this is NOT a no-arg method.
4380
+ *
4381
+ * @param cartId - The cart ID to link (e.g., from a guest cart)
4278
4382
  *
4279
4383
  * @example
4280
4384
  * ```typescript
4281
4385
  * // After customer logs in
4282
4386
  * omni.setCustomerToken(authResponse.token);
4283
- * const cart = await omni.linkCart('cart_123');
4387
+ * const cart = await omni.linkCart('cart_123'); // cartId is REQUIRED
4284
4388
  * // Cart is now linked to the customer
4285
4389
  * ```
4286
4390
  */
package/dist/index.d.ts CHANGED
@@ -158,7 +158,11 @@ interface Product {
158
158
  images?: ProductImage[];
159
159
  inventory?: InventoryInfo | null;
160
160
  variants?: ProductVariant[];
161
- /** Categories as objects with id and name */
161
+ /**
162
+ * Categories as objects with `id` and `name`.
163
+ * NOT string[] - each category is `{ id: string; name: string }`.
164
+ * Access: `product.categories?.map(cat => cat.name)`
165
+ */
162
166
  categories?: Array<{
163
167
  id: string;
164
168
  name: string;
@@ -643,10 +647,17 @@ interface ProductQueryParams {
643
647
  /**
644
648
  * Product suggestion for autocomplete
645
649
  */
650
+ /**
651
+ * Product suggestion for search autocomplete.
652
+ *
653
+ * **Note:** `slug` can be `null` - don't use it as a React key, use `id` instead.
654
+ */
646
655
  interface ProductSuggestion {
647
656
  id: string;
648
657
  name: string;
658
+ /** Can be null! Do NOT use as React key. Use `id` instead. */
649
659
  slug: string | null;
660
+ /** Can be null if product has no images */
650
661
  image: string | null;
651
662
  /** Effective price as string (salePrice if on sale, otherwise basePrice). */
652
663
  price: string;
@@ -657,7 +668,9 @@ interface ProductSuggestion {
657
668
  type: 'SIMPLE' | 'VARIABLE';
658
669
  }
659
670
  /**
660
- * Category suggestion for autocomplete
671
+ * Category suggestion for autocomplete.
672
+ *
673
+ * **Note:** This type has NO `slug` field - only `id`, `name`, `productCount`.
661
674
  */
662
675
  interface CategorySuggestion {
663
676
  id: string;
@@ -747,6 +760,10 @@ interface Order {
747
760
  platform?: string;
748
761
  createdAt: string;
749
762
  }
763
+ /**
764
+ * Order status values are **lowercase**.
765
+ * Do NOT use uppercase values like 'COMPLETED' or 'CANCELLED'.
766
+ */
750
767
  type OrderStatus = 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'refunded';
751
768
  interface OrderCustomer {
752
769
  email: string;
@@ -769,6 +786,24 @@ interface OrderAddress {
769
786
  country: string;
770
787
  phone?: string;
771
788
  }
789
+ /**
790
+ * Order line item. **This is a flat structure** - unlike CartItem/CheckoutLineItem.
791
+ *
792
+ * **Common mistakes:**
793
+ * - This type has NO `id` field. Use `productId` + index as React key.
794
+ * - Access `item.name` directly (NOT `item.product.name` like CartItem).
795
+ * - Access `item.price` directly (NOT `item.unitPrice` like CartItem).
796
+ *
797
+ * @example
798
+ * ```typescript
799
+ * order.items.map((item, index) => (
800
+ * <div key={`${item.productId}-${index}`}>
801
+ * <span>{item.name}</span>
802
+ * <span>{item.price}</span>
803
+ * </div>
804
+ * ))
805
+ * ```
806
+ */
772
807
  interface OrderItem {
773
808
  productId: string;
774
809
  variantId?: string;
@@ -779,6 +814,8 @@ interface OrderItem {
779
814
  /**
780
815
  * Price per unit as string (e.g., "29.99").
781
816
  * Use parseFloat() for calculations.
817
+ *
818
+ * **Note:** This is `price`, not `unitPrice` (unlike CartItem/CheckoutLineItem).
782
819
  */
783
820
  price: string;
784
821
  /** Product image URL (flat, not nested under product object) */
@@ -1393,8 +1430,24 @@ interface LocalCartItem {
1393
1430
  addedAt: string;
1394
1431
  }
1395
1432
  /**
1396
- * Local cart stored in localStorage/cookies
1397
- * Complete client-side cart for guest users
1433
+ * Local cart stored in localStorage/cookies.
1434
+ * Complete client-side cart for guest users.
1435
+ *
1436
+ * **Initialization:** You can initialize with just `{ items: [] }`.
1437
+ * All other fields are optional.
1438
+ *
1439
+ * **Note:** This is NOT the same as the server `Cart` type.
1440
+ * - `getCartTotals()` does NOT work with LocalCart (use manual calculation)
1441
+ * - Calculate total: `cart.items.reduce((sum, item) => sum + parseFloat(item.price || '0') * item.quantity, 0)`
1442
+ *
1443
+ * @example
1444
+ * ```typescript
1445
+ * // Simple initialization
1446
+ * const [cart, setCart] = useState<LocalCart>({ items: [] });
1447
+ *
1448
+ * // Or with null initial state
1449
+ * const [cart, setCart] = useState<LocalCart | null>(null);
1450
+ * ```
1398
1451
  */
1399
1452
  interface LocalCart {
1400
1453
  items: LocalCartItem[];
@@ -1428,7 +1481,8 @@ interface LocalCart {
1428
1481
  phone?: string;
1429
1482
  };
1430
1483
  notes?: string;
1431
- updatedAt: string;
1484
+ /** Last update timestamp. Optional - auto-set when you don't provide it. */
1485
+ updatedAt?: string;
1432
1486
  }
1433
1487
  /**
1434
1488
  * DTO for creating order directly (guest checkout)
@@ -1485,6 +1539,25 @@ interface GuestOrderResponse {
1485
1539
  * If tracking is enabled, returns checkoutId and cartId
1486
1540
  * If tracking is not enabled, returns tracked: false
1487
1541
  */
1542
+ /**
1543
+ * Response from starting guest checkout. **This is a discriminated union.**
1544
+ *
1545
+ * You MUST check `result.tracked` before accessing `checkoutId`:
1546
+ * - `tracked: true` → has `checkoutId` and `cartId`
1547
+ * - `tracked: false` → only has `message` (no checkoutId!)
1548
+ *
1549
+ * @example
1550
+ * ```typescript
1551
+ * const result = await omni.startGuestCheckout(cart);
1552
+ * if (result.tracked) {
1553
+ * // Safe to access checkoutId and cartId
1554
+ * console.log(result.checkoutId, result.cartId);
1555
+ * } else {
1556
+ * // Untracked checkout - no checkoutId available
1557
+ * console.log(result.message);
1558
+ * }
1559
+ * ```
1560
+ */
1488
1561
  type GuestCheckoutStartResponse = {
1489
1562
  tracked: true;
1490
1563
  checkoutId: string;
@@ -2167,13 +2240,18 @@ interface CustomApiTestResult {
2167
2240
  error?: string;
2168
2241
  }
2169
2242
  /**
2170
- * Payment provider configuration.
2243
+ * Payment provider configuration (returned by `getPaymentProviders()`).
2171
2244
  * Contains only public information safe to expose in frontend.
2245
+ *
2246
+ * **Note:** `provider` is a flexible `string` (not an enum).
2247
+ * Common values: `'stripe'`, `'paypal'`.
2248
+ *
2249
+ * **Alias:** `PaymentProvider` is the same type (use either name).
2172
2250
  */
2173
2251
  interface PaymentProviderConfig {
2174
2252
  /** Provider ID (use this when creating payment intents) */
2175
2253
  id: string;
2176
- /** Payment provider type: 'stripe', 'paypal' */
2254
+ /** Payment provider type: 'stripe', 'paypal' (flexible string, not enum) */
2177
2255
  provider: string;
2178
2256
  /** Display name for the provider */
2179
2257
  name: string;
@@ -2188,7 +2266,10 @@ interface PaymentProviderConfig {
2188
2266
  /** Whether this is the default provider */
2189
2267
  isDefault: boolean;
2190
2268
  }
2191
- /** Alias for PaymentProviderConfig for convenience */
2269
+ /**
2270
+ * Alias for `PaymentProviderConfig`.
2271
+ * Both types are identical - use whichever name you prefer.
2272
+ */
2192
2273
  type PaymentProvider = PaymentProviderConfig;
2193
2274
  /**
2194
2275
  * All available payment providers for a store.
@@ -2303,12 +2384,31 @@ interface WaitForOrderOptions {
2303
2384
  onPollAttempt?: (attempt: number, status: PaymentStatus) => void;
2304
2385
  }
2305
2386
  /**
2306
- * Result from waitForOrder method.
2387
+ * Result from `waitForOrder()` method.
2388
+ *
2389
+ * **Important:** `status` is a `PaymentStatus` object, NOT a string.
2390
+ * Access order number via `result.status.orderNumber`.
2391
+ *
2392
+ * For `completeGuestCheckout()`, use `GuestOrderResponse` instead
2393
+ * which has `result.orderNumber` directly.
2394
+ *
2395
+ * @example
2396
+ * ```typescript
2397
+ * const result = await omni.waitForOrder(checkoutId);
2398
+ * if (result.success) {
2399
+ * const orderNumber = result.status.orderNumber; // e.g., "ORD-20260201-0001"
2400
+ * const orderId = result.status.orderId;
2401
+ * }
2402
+ * ```
2307
2403
  */
2308
2404
  interface WaitForOrderResult {
2309
2405
  /** Whether the order was created within the timeout */
2310
2406
  success: boolean;
2311
- /** Final payment status */
2407
+ /**
2408
+ * Final payment status object.
2409
+ * Access order number: `result.status.orderNumber`
2410
+ * Access order ID: `result.status.orderId`
2411
+ */
2312
2412
  status: PaymentStatus;
2313
2413
  /** Number of poll attempts made */
2314
2414
  attempts: number;
@@ -4272,15 +4372,19 @@ declare class OmniSyncClient {
4272
4372
  */
4273
4373
  removeCoupon(cartId: string): Promise<Cart>;
4274
4374
  /**
4275
- * Link a cart to the currently logged-in customer
4276
- * Use this after customer logs in to associate their guest cart with their account
4277
- * Requires customer token to be set via setCustomerToken()
4375
+ * Link a cart to the currently logged-in customer.
4376
+ * Use this after customer logs in to associate their guest cart with their account.
4377
+ * Requires customer token to be set via setCustomerToken().
4378
+ *
4379
+ * **Important:** `cartId` is required - this is NOT a no-arg method.
4380
+ *
4381
+ * @param cartId - The cart ID to link (e.g., from a guest cart)
4278
4382
  *
4279
4383
  * @example
4280
4384
  * ```typescript
4281
4385
  * // After customer logs in
4282
4386
  * omni.setCustomerToken(authResponse.token);
4283
- * const cart = await omni.linkCart('cart_123');
4387
+ * const cart = await omni.linkCart('cart_123'); // cartId is REQUIRED
4284
4388
  * // Cart is now linked to the customer
4285
4389
  * ```
4286
4390
  */
package/dist/index.js CHANGED
@@ -1960,15 +1960,19 @@ var OmniSyncClient = class {
1960
1960
  return this.adminRequest("DELETE", `/api/v1/cart/${cartId}/coupon`);
1961
1961
  }
1962
1962
  /**
1963
- * Link a cart to the currently logged-in customer
1964
- * Use this after customer logs in to associate their guest cart with their account
1965
- * Requires customer token to be set via setCustomerToken()
1963
+ * Link a cart to the currently logged-in customer.
1964
+ * Use this after customer logs in to associate their guest cart with their account.
1965
+ * Requires customer token to be set via setCustomerToken().
1966
+ *
1967
+ * **Important:** `cartId` is required - this is NOT a no-arg method.
1968
+ *
1969
+ * @param cartId - The cart ID to link (e.g., from a guest cart)
1966
1970
  *
1967
1971
  * @example
1968
1972
  * ```typescript
1969
1973
  * // After customer logs in
1970
1974
  * omni.setCustomerToken(authResponse.token);
1971
- * const cart = await omni.linkCart('cart_123');
1975
+ * const cart = await omni.linkCart('cart_123'); // cartId is REQUIRED
1972
1976
  * // Cart is now linked to the customer
1973
1977
  * ```
1974
1978
  */
@@ -2848,8 +2852,8 @@ var OmniSyncClient = class {
2848
2852
  })),
2849
2853
  itemCount: localCart.items.reduce((sum, i) => sum + i.quantity, 0),
2850
2854
  expiresAt: null,
2851
- createdAt: localCart.updatedAt,
2852
- updatedAt: localCart.updatedAt
2855
+ createdAt: localCart.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
2856
+ updatedAt: localCart.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
2853
2857
  };
2854
2858
  }
2855
2859
  /**
package/dist/index.mjs CHANGED
@@ -1920,15 +1920,19 @@ var OmniSyncClient = class {
1920
1920
  return this.adminRequest("DELETE", `/api/v1/cart/${cartId}/coupon`);
1921
1921
  }
1922
1922
  /**
1923
- * Link a cart to the currently logged-in customer
1924
- * Use this after customer logs in to associate their guest cart with their account
1925
- * Requires customer token to be set via setCustomerToken()
1923
+ * Link a cart to the currently logged-in customer.
1924
+ * Use this after customer logs in to associate their guest cart with their account.
1925
+ * Requires customer token to be set via setCustomerToken().
1926
+ *
1927
+ * **Important:** `cartId` is required - this is NOT a no-arg method.
1928
+ *
1929
+ * @param cartId - The cart ID to link (e.g., from a guest cart)
1926
1930
  *
1927
1931
  * @example
1928
1932
  * ```typescript
1929
1933
  * // After customer logs in
1930
1934
  * omni.setCustomerToken(authResponse.token);
1931
- * const cart = await omni.linkCart('cart_123');
1935
+ * const cart = await omni.linkCart('cart_123'); // cartId is REQUIRED
1932
1936
  * // Cart is now linked to the customer
1933
1937
  * ```
1934
1938
  */
@@ -2808,8 +2812,8 @@ var OmniSyncClient = class {
2808
2812
  })),
2809
2813
  itemCount: localCart.items.reduce((sum, i) => sum + i.quantity, 0),
2810
2814
  expiresAt: null,
2811
- createdAt: localCart.updatedAt,
2812
- updatedAt: localCart.updatedAt
2815
+ createdAt: localCart.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
2816
+ updatedAt: localCart.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
2813
2817
  };
2814
2818
  }
2815
2819
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.22.2",
3
+ "version": "0.22.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",
@@ -17,14 +17,6 @@
17
17
  "README.md",
18
18
  "AI_BUILDER_PROMPT.md"
19
19
  ],
20
- "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts",
22
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
23
- "lint": "eslint \"src/**/*.ts\"",
24
- "test": "vitest run",
25
- "test:watch": "vitest",
26
- "prepublishOnly": "pnpm build"
27
- },
28
20
  "keywords": [
29
21
  "omni-sync",
30
22
  "e-commerce",
@@ -73,5 +65,12 @@
73
65
  "typescript": {
74
66
  "optional": true
75
67
  }
68
+ },
69
+ "scripts": {
70
+ "build": "tsup src/index.ts --format cjs,esm --dts",
71
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
72
+ "lint": "eslint \"src/**/*.ts\"",
73
+ "test": "vitest run",
74
+ "test:watch": "vitest"
76
75
  }
77
- }
76
+ }