omni-sync-sdk 0.6.1 → 0.7.0

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/README.md CHANGED
@@ -212,6 +212,7 @@ interface Product {
212
212
  id: string;
213
213
  name: string;
214
214
  description?: string | null;
215
+ descriptionFormat?: 'text' | 'html' | 'markdown'; // Format of description content
215
216
  sku: string;
216
217
  basePrice: number;
217
218
  salePrice?: number | null;
@@ -249,6 +250,31 @@ interface InventoryInfo {
249
250
  }
250
251
  ```
251
252
 
253
+ #### Rendering Product Descriptions
254
+
255
+ **IMPORTANT**: Product descriptions may contain HTML (from Shopify/WooCommerce) or plain text. Always check `descriptionFormat` before rendering:
256
+
257
+ ```tsx
258
+ // Correct way to render product descriptions
259
+ {
260
+ product.description &&
261
+ (product.descriptionFormat === 'html' ? (
262
+ // HTML content from Shopify/WooCommerce - render as HTML
263
+ <div dangerouslySetInnerHTML={{ __html: product.description }} />
264
+ ) : (
265
+ // Plain text - render normally
266
+ <p>{product.description}</p>
267
+ ));
268
+ }
269
+ ```
270
+
271
+ | Source Platform | descriptionFormat | Rendering |
272
+ | --------------- | ----------------- | ----------------------------- |
273
+ | Shopify | `'html'` | Use `dangerouslySetInnerHTML` |
274
+ | WooCommerce | `'html'` | Use `dangerouslySetInnerHTML` |
275
+ | TikTok | `'text'` | Render as plain text |
276
+ | Manual entry | `'text'` | Render as plain text |
277
+
252
278
  ---
253
279
 
254
280
  ### Local Cart (Guest Users) - RECOMMENDED
@@ -472,6 +498,76 @@ interface GuestOrderResponse {
472
498
 
473
499
  ---
474
500
 
501
+ ### Tracked Guest Checkout (Optional)
502
+
503
+ By default, guest checkouts are stored only in localStorage until the order is placed. If you want the store admin to see checkout sessions and abandoned carts, you can enable **Guest Checkout Tracking** in the connection settings.
504
+
505
+ When enabled, checkout sessions are created on the server, allowing:
506
+ - Visibility of checkout sessions in admin dashboard
507
+ - Abandoned cart tracking
508
+ - Future: abandoned cart recovery emails
509
+
510
+ #### Check if Tracking is Available
511
+
512
+ ```typescript
513
+ // When customer goes to checkout page
514
+ const result = await omni.startGuestCheckout();
515
+
516
+ if (result.tracked) {
517
+ // Tracking is enabled - use tracked flow
518
+ console.log('Checkout session created:', result.checkoutId);
519
+ } else {
520
+ // Tracking not enabled - use regular flow
521
+ console.log('Using local-only checkout');
522
+ }
523
+ ```
524
+
525
+ #### Tracked Checkout Flow
526
+
527
+ ```typescript
528
+ // 1. Start tracked checkout (sends cart items to server)
529
+ const checkout = await omni.startGuestCheckout();
530
+
531
+ if (checkout.tracked) {
532
+ // 2. Update with shipping address
533
+ await omni.updateGuestCheckoutAddress(checkout.checkoutId, {
534
+ shippingAddress: {
535
+ firstName: 'John',
536
+ lastName: 'Doe',
537
+ line1: '123 Main St',
538
+ city: 'New York',
539
+ postalCode: '10001',
540
+ country: 'US',
541
+ },
542
+ });
543
+
544
+ // 3. Complete the checkout
545
+ const order = await omni.completeGuestCheckout(checkout.checkoutId);
546
+ console.log('Order created:', order.orderId);
547
+ } else {
548
+ // Fallback to regular guest checkout
549
+ const order = await omni.submitGuestOrder();
550
+ }
551
+ ```
552
+
553
+ #### Response Types
554
+
555
+ ```typescript
556
+ type GuestCheckoutStartResponse =
557
+ | {
558
+ tracked: true;
559
+ checkoutId: string;
560
+ cartId: string;
561
+ message: string;
562
+ }
563
+ | {
564
+ tracked: false;
565
+ message: string;
566
+ };
567
+ ```
568
+
569
+ ---
570
+
475
571
  ### Server Cart (Registered Users)
476
572
 
477
573
  For logged-in customers who want cart sync across devices.
@@ -980,8 +1076,13 @@ export default function ProductPage({ params }: { params: { id: string } }) {
980
1076
  ${product.salePrice || product.basePrice}
981
1077
  </p>
982
1078
 
1079
+ {/* Render description based on format (HTML from Shopify/WooCommerce, text otherwise) */}
983
1080
  {product.description && (
984
- <p className="mt-4 text-gray-600">{product.description}</p>
1081
+ product.descriptionFormat === 'html' ? (
1082
+ <div className="mt-4 text-gray-600" dangerouslySetInnerHTML={{ __html: product.description }} />
1083
+ ) : (
1084
+ <p className="mt-4 text-gray-600">{product.description}</p>
1085
+ )
985
1086
  )}
986
1087
 
987
1088
  {/* Variant Selection */}
@@ -1832,6 +1933,7 @@ When building a store, implement these pages:
1832
1933
  - Handle loading states and errors
1833
1934
  - Persist cart ID in localStorage
1834
1935
  - Persist customer token after login
1936
+ - **Check `descriptionFormat` and render HTML with `dangerouslySetInnerHTML` when format is `'html'`**
1835
1937
 
1836
1938
  ### DON'T:
1837
1939
 
@@ -1840,6 +1942,7 @@ When building a store, implement these pages:
1840
1942
  - Skip implementing required pages
1841
1943
  - Write `const products = [...]` - use the API!
1842
1944
  - Use `@apply group` in CSS - Tailwind doesn't allow 'group' in @apply. Use `className="group"` on the element instead
1945
+ - **Render `product.description` as plain text without checking `descriptionFormat` - HTML will show as raw tags!**
1843
1946
 
1844
1947
  ---
1845
1948
 
package/dist/index.d.mts CHANGED
@@ -640,6 +640,20 @@ interface GuestOrderResponse {
640
640
  total: number;
641
641
  message: string;
642
642
  }
643
+ /**
644
+ * Response from starting a tracked guest checkout session
645
+ * If tracking is enabled, returns checkoutId and cartId
646
+ * If tracking is not enabled, returns tracked: false
647
+ */
648
+ type GuestCheckoutStartResponse = {
649
+ tracked: true;
650
+ checkoutId: string;
651
+ cartId: string;
652
+ message: string;
653
+ } | {
654
+ tracked: false;
655
+ message: string;
656
+ };
643
657
  type CheckoutStatus = 'PENDING' | 'SHIPPING_SET' | 'PAYMENT_PENDING' | 'PAYMENT_PROCESSING' | 'COMPLETED' | 'FAILED' | 'EXPIRED';
644
658
  interface CheckoutAddress {
645
659
  firstName: string;
@@ -1989,6 +2003,55 @@ declare class OmniSyncClient {
1989
2003
  submitGuestOrder(options?: {
1990
2004
  clearCartOnSuccess?: boolean;
1991
2005
  }): Promise<GuestOrderResponse>;
2006
+ /**
2007
+ * Start a tracked guest checkout session (if enabled on connection)
2008
+ *
2009
+ * This creates Cart + Checkout records on the server so the store admin
2010
+ * can see checkout sessions and track abandoned carts.
2011
+ *
2012
+ * If tracking is not enabled for this connection, returns { tracked: false }.
2013
+ * If tracking is enabled, returns { tracked: true, checkoutId, cartId }.
2014
+ *
2015
+ * @example
2016
+ * ```typescript
2017
+ * // When customer goes to checkout page
2018
+ * const result = await omni.startGuestCheckout();
2019
+ *
2020
+ * if (result.tracked) {
2021
+ * // Store checkoutId for later use
2022
+ * console.log('Checkout tracked:', result.checkoutId);
2023
+ *
2024
+ * // Update checkout with address
2025
+ * await omni.updateGuestCheckout(result.checkoutId, {
2026
+ * shippingAddress: { ... },
2027
+ * });
2028
+ *
2029
+ * // Complete checkout
2030
+ * const order = await omni.completeGuestCheckout(result.checkoutId);
2031
+ * } else {
2032
+ * // Tracking not enabled, use regular submitGuestOrder
2033
+ * const order = await omni.submitGuestOrder();
2034
+ * }
2035
+ * ```
2036
+ */
2037
+ startGuestCheckout(): Promise<GuestCheckoutStartResponse>;
2038
+ /**
2039
+ * Update a tracked guest checkout with shipping/billing address
2040
+ * Use after startGuestCheckout() returns { tracked: true }
2041
+ */
2042
+ updateGuestCheckoutAddress(checkoutId: string, data: {
2043
+ shippingAddress?: SetShippingAddressDto;
2044
+ billingAddress?: SetBillingAddressDto;
2045
+ }): Promise<Checkout>;
2046
+ /**
2047
+ * Complete a tracked guest checkout - creates the order
2048
+ * Use after startGuestCheckout() and updateGuestCheckoutAddress()
2049
+ */
2050
+ completeGuestCheckout(checkoutId: string, options?: {
2051
+ clearCartOnSuccess?: boolean;
2052
+ }): Promise<{
2053
+ orderId: string;
2054
+ }>;
1992
2055
  /**
1993
2056
  * Create order from custom data (not from local cart)
1994
2057
  * Use this if you manage cart state yourself
@@ -2212,4 +2275,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
2212
2275
  */
2213
2276
  declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
2214
2277
 
2215
- export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
2278
+ export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -640,6 +640,20 @@ interface GuestOrderResponse {
640
640
  total: number;
641
641
  message: string;
642
642
  }
643
+ /**
644
+ * Response from starting a tracked guest checkout session
645
+ * If tracking is enabled, returns checkoutId and cartId
646
+ * If tracking is not enabled, returns tracked: false
647
+ */
648
+ type GuestCheckoutStartResponse = {
649
+ tracked: true;
650
+ checkoutId: string;
651
+ cartId: string;
652
+ message: string;
653
+ } | {
654
+ tracked: false;
655
+ message: string;
656
+ };
643
657
  type CheckoutStatus = 'PENDING' | 'SHIPPING_SET' | 'PAYMENT_PENDING' | 'PAYMENT_PROCESSING' | 'COMPLETED' | 'FAILED' | 'EXPIRED';
644
658
  interface CheckoutAddress {
645
659
  firstName: string;
@@ -1989,6 +2003,55 @@ declare class OmniSyncClient {
1989
2003
  submitGuestOrder(options?: {
1990
2004
  clearCartOnSuccess?: boolean;
1991
2005
  }): Promise<GuestOrderResponse>;
2006
+ /**
2007
+ * Start a tracked guest checkout session (if enabled on connection)
2008
+ *
2009
+ * This creates Cart + Checkout records on the server so the store admin
2010
+ * can see checkout sessions and track abandoned carts.
2011
+ *
2012
+ * If tracking is not enabled for this connection, returns { tracked: false }.
2013
+ * If tracking is enabled, returns { tracked: true, checkoutId, cartId }.
2014
+ *
2015
+ * @example
2016
+ * ```typescript
2017
+ * // When customer goes to checkout page
2018
+ * const result = await omni.startGuestCheckout();
2019
+ *
2020
+ * if (result.tracked) {
2021
+ * // Store checkoutId for later use
2022
+ * console.log('Checkout tracked:', result.checkoutId);
2023
+ *
2024
+ * // Update checkout with address
2025
+ * await omni.updateGuestCheckout(result.checkoutId, {
2026
+ * shippingAddress: { ... },
2027
+ * });
2028
+ *
2029
+ * // Complete checkout
2030
+ * const order = await omni.completeGuestCheckout(result.checkoutId);
2031
+ * } else {
2032
+ * // Tracking not enabled, use regular submitGuestOrder
2033
+ * const order = await omni.submitGuestOrder();
2034
+ * }
2035
+ * ```
2036
+ */
2037
+ startGuestCheckout(): Promise<GuestCheckoutStartResponse>;
2038
+ /**
2039
+ * Update a tracked guest checkout with shipping/billing address
2040
+ * Use after startGuestCheckout() returns { tracked: true }
2041
+ */
2042
+ updateGuestCheckoutAddress(checkoutId: string, data: {
2043
+ shippingAddress?: SetShippingAddressDto;
2044
+ billingAddress?: SetBillingAddressDto;
2045
+ }): Promise<Checkout>;
2046
+ /**
2047
+ * Complete a tracked guest checkout - creates the order
2048
+ * Use after startGuestCheckout() and updateGuestCheckoutAddress()
2049
+ */
2050
+ completeGuestCheckout(checkoutId: string, options?: {
2051
+ clearCartOnSuccess?: boolean;
2052
+ }): Promise<{
2053
+ orderId: string;
2054
+ }>;
1992
2055
  /**
1993
2056
  * Create order from custom data (not from local cart)
1994
2057
  * Use this if you manage cart state yourself
@@ -2212,4 +2275,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
2212
2275
  */
2213
2276
  declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
2214
2277
 
2215
- export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
2278
+ export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartItem, type CartStatus, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InventoryInfo, type InventorySyncStatus, type LocalCart, type LocalCartItem, type MergeCartsDto, type OmniSyncApiError, OmniSyncClient, type OmniSyncClientOptions, OmniSyncError, type Order, type OrderAddress, type OrderCustomer, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PlatformCouponCapabilities, type Product, type ProductAttributeInput, type ProductImage, type ProductQueryParams, type ProductVariant, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type SelectShippingMethodDto, type SendInvoiceDto, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingLine, type ShippingRate, type StoreInfo, type SyncJob, type UpdateAddressDto, type UpdateCartItemDto, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateInventoryDto, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateVariantDto, type UpdateVariantInventoryDto, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WebhookEvent, type WebhookEventType, createWebhookHandler, isCouponApplicableToProduct, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.js CHANGED
@@ -1751,6 +1751,97 @@ var OmniSyncClient = class {
1751
1751
  }
1752
1752
  return result;
1753
1753
  }
1754
+ /**
1755
+ * Start a tracked guest checkout session (if enabled on connection)
1756
+ *
1757
+ * This creates Cart + Checkout records on the server so the store admin
1758
+ * can see checkout sessions and track abandoned carts.
1759
+ *
1760
+ * If tracking is not enabled for this connection, returns { tracked: false }.
1761
+ * If tracking is enabled, returns { tracked: true, checkoutId, cartId }.
1762
+ *
1763
+ * @example
1764
+ * ```typescript
1765
+ * // When customer goes to checkout page
1766
+ * const result = await omni.startGuestCheckout();
1767
+ *
1768
+ * if (result.tracked) {
1769
+ * // Store checkoutId for later use
1770
+ * console.log('Checkout tracked:', result.checkoutId);
1771
+ *
1772
+ * // Update checkout with address
1773
+ * await omni.updateGuestCheckout(result.checkoutId, {
1774
+ * shippingAddress: { ... },
1775
+ * });
1776
+ *
1777
+ * // Complete checkout
1778
+ * const order = await omni.completeGuestCheckout(result.checkoutId);
1779
+ * } else {
1780
+ * // Tracking not enabled, use regular submitGuestOrder
1781
+ * const order = await omni.submitGuestOrder();
1782
+ * }
1783
+ * ```
1784
+ */
1785
+ async startGuestCheckout() {
1786
+ const cart = this.getLocalCart();
1787
+ if (cart.items.length === 0) {
1788
+ throw new OmniSyncError("Cart is empty", 400);
1789
+ }
1790
+ const response = await this.vibeCodedRequest(
1791
+ "POST",
1792
+ "/guest-checkout",
1793
+ {
1794
+ items: cart.items.map((item) => ({
1795
+ productId: item.productId,
1796
+ variantId: item.variantId,
1797
+ quantity: item.quantity
1798
+ })),
1799
+ customer: cart.customer
1800
+ }
1801
+ );
1802
+ return response;
1803
+ }
1804
+ /**
1805
+ * Update a tracked guest checkout with shipping/billing address
1806
+ * Use after startGuestCheckout() returns { tracked: true }
1807
+ */
1808
+ async updateGuestCheckoutAddress(checkoutId, data) {
1809
+ let checkout = null;
1810
+ if (data.shippingAddress) {
1811
+ const result = await this.vibeCodedRequest(
1812
+ "PATCH",
1813
+ `/checkout/${checkoutId}/shipping-address`,
1814
+ data.shippingAddress
1815
+ );
1816
+ checkout = result.checkout;
1817
+ }
1818
+ if (data.billingAddress) {
1819
+ checkout = await this.vibeCodedRequest(
1820
+ "PATCH",
1821
+ `/checkout/${checkoutId}/billing-address`,
1822
+ data.billingAddress
1823
+ );
1824
+ }
1825
+ if (!checkout) {
1826
+ throw new OmniSyncError("No address data provided", 400);
1827
+ }
1828
+ return checkout;
1829
+ }
1830
+ /**
1831
+ * Complete a tracked guest checkout - creates the order
1832
+ * Use after startGuestCheckout() and updateGuestCheckoutAddress()
1833
+ */
1834
+ async completeGuestCheckout(checkoutId, options) {
1835
+ const result = await this.vibeCodedRequest(
1836
+ "POST",
1837
+ `/checkout/${checkoutId}/complete`,
1838
+ {}
1839
+ );
1840
+ if (options?.clearCartOnSuccess !== false) {
1841
+ this.clearLocalCart();
1842
+ }
1843
+ return result;
1844
+ }
1754
1845
  /**
1755
1846
  * Create order from custom data (not from local cart)
1756
1847
  * Use this if you manage cart state yourself
package/dist/index.mjs CHANGED
@@ -1726,6 +1726,97 @@ var OmniSyncClient = class {
1726
1726
  }
1727
1727
  return result;
1728
1728
  }
1729
+ /**
1730
+ * Start a tracked guest checkout session (if enabled on connection)
1731
+ *
1732
+ * This creates Cart + Checkout records on the server so the store admin
1733
+ * can see checkout sessions and track abandoned carts.
1734
+ *
1735
+ * If tracking is not enabled for this connection, returns { tracked: false }.
1736
+ * If tracking is enabled, returns { tracked: true, checkoutId, cartId }.
1737
+ *
1738
+ * @example
1739
+ * ```typescript
1740
+ * // When customer goes to checkout page
1741
+ * const result = await omni.startGuestCheckout();
1742
+ *
1743
+ * if (result.tracked) {
1744
+ * // Store checkoutId for later use
1745
+ * console.log('Checkout tracked:', result.checkoutId);
1746
+ *
1747
+ * // Update checkout with address
1748
+ * await omni.updateGuestCheckout(result.checkoutId, {
1749
+ * shippingAddress: { ... },
1750
+ * });
1751
+ *
1752
+ * // Complete checkout
1753
+ * const order = await omni.completeGuestCheckout(result.checkoutId);
1754
+ * } else {
1755
+ * // Tracking not enabled, use regular submitGuestOrder
1756
+ * const order = await omni.submitGuestOrder();
1757
+ * }
1758
+ * ```
1759
+ */
1760
+ async startGuestCheckout() {
1761
+ const cart = this.getLocalCart();
1762
+ if (cart.items.length === 0) {
1763
+ throw new OmniSyncError("Cart is empty", 400);
1764
+ }
1765
+ const response = await this.vibeCodedRequest(
1766
+ "POST",
1767
+ "/guest-checkout",
1768
+ {
1769
+ items: cart.items.map((item) => ({
1770
+ productId: item.productId,
1771
+ variantId: item.variantId,
1772
+ quantity: item.quantity
1773
+ })),
1774
+ customer: cart.customer
1775
+ }
1776
+ );
1777
+ return response;
1778
+ }
1779
+ /**
1780
+ * Update a tracked guest checkout with shipping/billing address
1781
+ * Use after startGuestCheckout() returns { tracked: true }
1782
+ */
1783
+ async updateGuestCheckoutAddress(checkoutId, data) {
1784
+ let checkout = null;
1785
+ if (data.shippingAddress) {
1786
+ const result = await this.vibeCodedRequest(
1787
+ "PATCH",
1788
+ `/checkout/${checkoutId}/shipping-address`,
1789
+ data.shippingAddress
1790
+ );
1791
+ checkout = result.checkout;
1792
+ }
1793
+ if (data.billingAddress) {
1794
+ checkout = await this.vibeCodedRequest(
1795
+ "PATCH",
1796
+ `/checkout/${checkoutId}/billing-address`,
1797
+ data.billingAddress
1798
+ );
1799
+ }
1800
+ if (!checkout) {
1801
+ throw new OmniSyncError("No address data provided", 400);
1802
+ }
1803
+ return checkout;
1804
+ }
1805
+ /**
1806
+ * Complete a tracked guest checkout - creates the order
1807
+ * Use after startGuestCheckout() and updateGuestCheckoutAddress()
1808
+ */
1809
+ async completeGuestCheckout(checkoutId, options) {
1810
+ const result = await this.vibeCodedRequest(
1811
+ "POST",
1812
+ `/checkout/${checkoutId}/complete`,
1813
+ {}
1814
+ );
1815
+ if (options?.clearCartOnSuccess !== false) {
1816
+ this.clearLocalCart();
1817
+ }
1818
+ return result;
1819
+ }
1729
1820
  /**
1730
1821
  * Create order from custom data (not from local cart)
1731
1822
  * Use this if you manage cart state yourself
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-sync-sdk",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
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",