omni-sync-sdk 0.4.1 → 0.6.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 +531 -115
- package/dist/index.d.mts +247 -2
- package/dist/index.d.ts +247 -2
- package/dist/index.js +333 -1
- package/dist/index.mjs +333 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -537,6 +537,108 @@ interface MergeCartsDto {
|
|
|
537
537
|
sourceSessionToken: string;
|
|
538
538
|
targetCustomerId: string;
|
|
539
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Local cart item stored in localStorage/cookies
|
|
542
|
+
* Used for guest checkout without server-side cart
|
|
543
|
+
*/
|
|
544
|
+
interface LocalCartItem {
|
|
545
|
+
productId: string;
|
|
546
|
+
variantId?: string;
|
|
547
|
+
quantity: number;
|
|
548
|
+
name?: string;
|
|
549
|
+
sku?: string;
|
|
550
|
+
price?: string;
|
|
551
|
+
image?: string;
|
|
552
|
+
addedAt: string;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Local cart stored in localStorage/cookies
|
|
556
|
+
* Complete client-side cart for guest users
|
|
557
|
+
*/
|
|
558
|
+
interface LocalCart {
|
|
559
|
+
items: LocalCartItem[];
|
|
560
|
+
couponCode?: string;
|
|
561
|
+
customer?: {
|
|
562
|
+
email: string;
|
|
563
|
+
firstName?: string;
|
|
564
|
+
lastName?: string;
|
|
565
|
+
phone?: string;
|
|
566
|
+
};
|
|
567
|
+
shippingAddress?: {
|
|
568
|
+
firstName: string;
|
|
569
|
+
lastName: string;
|
|
570
|
+
line1: string;
|
|
571
|
+
line2?: string;
|
|
572
|
+
city: string;
|
|
573
|
+
region?: string;
|
|
574
|
+
postalCode: string;
|
|
575
|
+
country: string;
|
|
576
|
+
phone?: string;
|
|
577
|
+
};
|
|
578
|
+
billingAddress?: {
|
|
579
|
+
firstName: string;
|
|
580
|
+
lastName: string;
|
|
581
|
+
line1: string;
|
|
582
|
+
line2?: string;
|
|
583
|
+
city: string;
|
|
584
|
+
region?: string;
|
|
585
|
+
postalCode: string;
|
|
586
|
+
country: string;
|
|
587
|
+
phone?: string;
|
|
588
|
+
};
|
|
589
|
+
notes?: string;
|
|
590
|
+
updatedAt: string;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* DTO for creating order directly (guest checkout)
|
|
594
|
+
*/
|
|
595
|
+
interface CreateGuestOrderDto {
|
|
596
|
+
items: Array<{
|
|
597
|
+
productId: string;
|
|
598
|
+
variantId?: string;
|
|
599
|
+
quantity: number;
|
|
600
|
+
}>;
|
|
601
|
+
customer: {
|
|
602
|
+
email: string;
|
|
603
|
+
firstName?: string;
|
|
604
|
+
lastName?: string;
|
|
605
|
+
phone?: string;
|
|
606
|
+
};
|
|
607
|
+
shippingAddress: {
|
|
608
|
+
firstName: string;
|
|
609
|
+
lastName: string;
|
|
610
|
+
line1: string;
|
|
611
|
+
line2?: string;
|
|
612
|
+
city: string;
|
|
613
|
+
region?: string;
|
|
614
|
+
postalCode: string;
|
|
615
|
+
country: string;
|
|
616
|
+
phone?: string;
|
|
617
|
+
};
|
|
618
|
+
billingAddress?: {
|
|
619
|
+
firstName: string;
|
|
620
|
+
lastName: string;
|
|
621
|
+
line1: string;
|
|
622
|
+
line2?: string;
|
|
623
|
+
city: string;
|
|
624
|
+
region?: string;
|
|
625
|
+
postalCode: string;
|
|
626
|
+
country: string;
|
|
627
|
+
phone?: string;
|
|
628
|
+
};
|
|
629
|
+
couponCode?: string;
|
|
630
|
+
notes?: string;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Response from guest order creation
|
|
634
|
+
*/
|
|
635
|
+
interface GuestOrderResponse {
|
|
636
|
+
orderId: string;
|
|
637
|
+
orderNumber: string;
|
|
638
|
+
status: string;
|
|
639
|
+
total: number;
|
|
640
|
+
message: string;
|
|
641
|
+
}
|
|
540
642
|
type CheckoutStatus = 'PENDING' | 'SHIPPING_SET' | 'PAYMENT_PENDING' | 'PAYMENT_PROCESSING' | 'COMPLETED' | 'FAILED' | 'EXPIRED';
|
|
541
643
|
interface CheckoutAddress {
|
|
542
644
|
firstName: string;
|
|
@@ -1556,7 +1658,7 @@ declare class OmniSyncClient {
|
|
|
1556
1658
|
* await omni.clearCart('cart_123');
|
|
1557
1659
|
* ```
|
|
1558
1660
|
*/
|
|
1559
|
-
clearCart(cartId: string): Promise<
|
|
1661
|
+
clearCart(cartId: string): Promise<Cart>;
|
|
1560
1662
|
/**
|
|
1561
1663
|
* Apply a coupon to the cart
|
|
1562
1664
|
*
|
|
@@ -1700,6 +1802,149 @@ declare class OmniSyncClient {
|
|
|
1700
1802
|
* ```
|
|
1701
1803
|
*/
|
|
1702
1804
|
completeCheckout(checkoutId: string): Promise<CompleteCheckoutResponse>;
|
|
1805
|
+
private readonly LOCAL_CART_KEY;
|
|
1806
|
+
/**
|
|
1807
|
+
* Check if localStorage is available (browser environment)
|
|
1808
|
+
*/
|
|
1809
|
+
private isLocalStorageAvailable;
|
|
1810
|
+
/**
|
|
1811
|
+
* Get local cart from localStorage
|
|
1812
|
+
* Returns empty cart if none exists
|
|
1813
|
+
*
|
|
1814
|
+
* @example
|
|
1815
|
+
* ```typescript
|
|
1816
|
+
* const cart = omni.getLocalCart();
|
|
1817
|
+
* console.log('Items in cart:', cart.items.length);
|
|
1818
|
+
* ```
|
|
1819
|
+
*/
|
|
1820
|
+
getLocalCart(): LocalCart;
|
|
1821
|
+
/**
|
|
1822
|
+
* Save local cart to localStorage
|
|
1823
|
+
*/
|
|
1824
|
+
private saveLocalCart;
|
|
1825
|
+
/**
|
|
1826
|
+
* Add item to local cart (NO API call)
|
|
1827
|
+
* If item already exists, updates quantity
|
|
1828
|
+
*
|
|
1829
|
+
* @example
|
|
1830
|
+
* ```typescript
|
|
1831
|
+
* omni.addToLocalCart({
|
|
1832
|
+
* productId: 'prod_123',
|
|
1833
|
+
* quantity: 2,
|
|
1834
|
+
* name: 'Cool Shirt',
|
|
1835
|
+
* price: '29.99',
|
|
1836
|
+
* });
|
|
1837
|
+
* ```
|
|
1838
|
+
*/
|
|
1839
|
+
addToLocalCart(item: Omit<LocalCartItem, 'addedAt'>): LocalCart;
|
|
1840
|
+
/**
|
|
1841
|
+
* Update item quantity in local cart
|
|
1842
|
+
* Set quantity to 0 to remove item
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* ```typescript
|
|
1846
|
+
* omni.updateLocalCartItem('prod_123', 3); // Set quantity to 3
|
|
1847
|
+
* omni.updateLocalCartItem('prod_123', 0); // Remove item
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
updateLocalCartItem(productId: string, quantity: number, variantId?: string): LocalCart;
|
|
1851
|
+
/**
|
|
1852
|
+
* Remove item from local cart
|
|
1853
|
+
*
|
|
1854
|
+
* @example
|
|
1855
|
+
* ```typescript
|
|
1856
|
+
* omni.removeFromLocalCart('prod_123');
|
|
1857
|
+
* omni.removeFromLocalCart('prod_456', 'variant_789');
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
removeFromLocalCart(productId: string, variantId?: string): LocalCart;
|
|
1861
|
+
/**
|
|
1862
|
+
* Clear all items from local cart
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ```typescript
|
|
1866
|
+
* omni.clearLocalCart();
|
|
1867
|
+
* ```
|
|
1868
|
+
*/
|
|
1869
|
+
clearLocalCart(): LocalCart;
|
|
1870
|
+
/**
|
|
1871
|
+
* Set customer info on local cart
|
|
1872
|
+
*
|
|
1873
|
+
* @example
|
|
1874
|
+
* ```typescript
|
|
1875
|
+
* omni.setLocalCartCustomer({
|
|
1876
|
+
* email: 'john@example.com',
|
|
1877
|
+
* firstName: 'John',
|
|
1878
|
+
* lastName: 'Doe',
|
|
1879
|
+
* });
|
|
1880
|
+
* ```
|
|
1881
|
+
*/
|
|
1882
|
+
setLocalCartCustomer(customer: LocalCart['customer']): LocalCart;
|
|
1883
|
+
/**
|
|
1884
|
+
* Set shipping address on local cart
|
|
1885
|
+
*
|
|
1886
|
+
* @example
|
|
1887
|
+
* ```typescript
|
|
1888
|
+
* omni.setLocalCartShippingAddress({
|
|
1889
|
+
* firstName: 'John',
|
|
1890
|
+
* lastName: 'Doe',
|
|
1891
|
+
* line1: '123 Main St',
|
|
1892
|
+
* city: 'Tel Aviv',
|
|
1893
|
+
* postalCode: '6100000',
|
|
1894
|
+
* country: 'IL',
|
|
1895
|
+
* });
|
|
1896
|
+
* ```
|
|
1897
|
+
*/
|
|
1898
|
+
setLocalCartShippingAddress(address: LocalCart['shippingAddress']): LocalCart;
|
|
1899
|
+
/**
|
|
1900
|
+
* Set billing address on local cart
|
|
1901
|
+
*/
|
|
1902
|
+
setLocalCartBillingAddress(address: LocalCart['billingAddress']): LocalCart;
|
|
1903
|
+
/**
|
|
1904
|
+
* Set coupon code on local cart
|
|
1905
|
+
*/
|
|
1906
|
+
setLocalCartCoupon(couponCode: string | undefined): LocalCart;
|
|
1907
|
+
/**
|
|
1908
|
+
* Get total items count in local cart
|
|
1909
|
+
*/
|
|
1910
|
+
getLocalCartItemCount(): number;
|
|
1911
|
+
/**
|
|
1912
|
+
* Create order directly from local cart (guest checkout)
|
|
1913
|
+
* This is the main checkout method for vibe-coded sites!
|
|
1914
|
+
* Sends cart data to server and creates order in ONE API call.
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* ```typescript
|
|
1918
|
+
* // Build up the local cart first
|
|
1919
|
+
* omni.addToLocalCart({ productId: 'prod_123', quantity: 2 });
|
|
1920
|
+
* omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
|
|
1921
|
+
* omni.setLocalCartShippingAddress({ ... });
|
|
1922
|
+
*
|
|
1923
|
+
* // Then submit the order
|
|
1924
|
+
* const result = await omni.submitGuestOrder();
|
|
1925
|
+
* console.log('Order created:', result.orderId);
|
|
1926
|
+
*
|
|
1927
|
+
* // Clear cart after successful order
|
|
1928
|
+
* omni.clearLocalCart();
|
|
1929
|
+
* ```
|
|
1930
|
+
*/
|
|
1931
|
+
submitGuestOrder(options?: {
|
|
1932
|
+
clearCartOnSuccess?: boolean;
|
|
1933
|
+
}): Promise<GuestOrderResponse>;
|
|
1934
|
+
/**
|
|
1935
|
+
* Create order from custom data (not from local cart)
|
|
1936
|
+
* Use this if you manage cart state yourself
|
|
1937
|
+
*
|
|
1938
|
+
* @example
|
|
1939
|
+
* ```typescript
|
|
1940
|
+
* const result = await omni.createGuestOrder({
|
|
1941
|
+
* items: [{ productId: 'prod_123', quantity: 2 }],
|
|
1942
|
+
* customer: { email: 'john@example.com' },
|
|
1943
|
+
* shippingAddress: { firstName: 'John', ... },
|
|
1944
|
+
* });
|
|
1945
|
+
* ```
|
|
1946
|
+
*/
|
|
1947
|
+
createGuestOrder(data: CreateGuestOrderDto): Promise<GuestOrderResponse>;
|
|
1703
1948
|
/**
|
|
1704
1949
|
* Get the current customer's profile (requires customerToken)
|
|
1705
1950
|
* Only available in storefront mode
|
|
@@ -1823,4 +2068,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
1823
2068
|
*/
|
|
1824
2069
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
1825
2070
|
|
|
1826
|
-
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 CreateCustomerDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type InventoryInfo, type InventorySyncStatus, 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 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 };
|
|
2071
|
+
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 CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, 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 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
|
@@ -537,6 +537,108 @@ interface MergeCartsDto {
|
|
|
537
537
|
sourceSessionToken: string;
|
|
538
538
|
targetCustomerId: string;
|
|
539
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Local cart item stored in localStorage/cookies
|
|
542
|
+
* Used for guest checkout without server-side cart
|
|
543
|
+
*/
|
|
544
|
+
interface LocalCartItem {
|
|
545
|
+
productId: string;
|
|
546
|
+
variantId?: string;
|
|
547
|
+
quantity: number;
|
|
548
|
+
name?: string;
|
|
549
|
+
sku?: string;
|
|
550
|
+
price?: string;
|
|
551
|
+
image?: string;
|
|
552
|
+
addedAt: string;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Local cart stored in localStorage/cookies
|
|
556
|
+
* Complete client-side cart for guest users
|
|
557
|
+
*/
|
|
558
|
+
interface LocalCart {
|
|
559
|
+
items: LocalCartItem[];
|
|
560
|
+
couponCode?: string;
|
|
561
|
+
customer?: {
|
|
562
|
+
email: string;
|
|
563
|
+
firstName?: string;
|
|
564
|
+
lastName?: string;
|
|
565
|
+
phone?: string;
|
|
566
|
+
};
|
|
567
|
+
shippingAddress?: {
|
|
568
|
+
firstName: string;
|
|
569
|
+
lastName: string;
|
|
570
|
+
line1: string;
|
|
571
|
+
line2?: string;
|
|
572
|
+
city: string;
|
|
573
|
+
region?: string;
|
|
574
|
+
postalCode: string;
|
|
575
|
+
country: string;
|
|
576
|
+
phone?: string;
|
|
577
|
+
};
|
|
578
|
+
billingAddress?: {
|
|
579
|
+
firstName: string;
|
|
580
|
+
lastName: string;
|
|
581
|
+
line1: string;
|
|
582
|
+
line2?: string;
|
|
583
|
+
city: string;
|
|
584
|
+
region?: string;
|
|
585
|
+
postalCode: string;
|
|
586
|
+
country: string;
|
|
587
|
+
phone?: string;
|
|
588
|
+
};
|
|
589
|
+
notes?: string;
|
|
590
|
+
updatedAt: string;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* DTO for creating order directly (guest checkout)
|
|
594
|
+
*/
|
|
595
|
+
interface CreateGuestOrderDto {
|
|
596
|
+
items: Array<{
|
|
597
|
+
productId: string;
|
|
598
|
+
variantId?: string;
|
|
599
|
+
quantity: number;
|
|
600
|
+
}>;
|
|
601
|
+
customer: {
|
|
602
|
+
email: string;
|
|
603
|
+
firstName?: string;
|
|
604
|
+
lastName?: string;
|
|
605
|
+
phone?: string;
|
|
606
|
+
};
|
|
607
|
+
shippingAddress: {
|
|
608
|
+
firstName: string;
|
|
609
|
+
lastName: string;
|
|
610
|
+
line1: string;
|
|
611
|
+
line2?: string;
|
|
612
|
+
city: string;
|
|
613
|
+
region?: string;
|
|
614
|
+
postalCode: string;
|
|
615
|
+
country: string;
|
|
616
|
+
phone?: string;
|
|
617
|
+
};
|
|
618
|
+
billingAddress?: {
|
|
619
|
+
firstName: string;
|
|
620
|
+
lastName: string;
|
|
621
|
+
line1: string;
|
|
622
|
+
line2?: string;
|
|
623
|
+
city: string;
|
|
624
|
+
region?: string;
|
|
625
|
+
postalCode: string;
|
|
626
|
+
country: string;
|
|
627
|
+
phone?: string;
|
|
628
|
+
};
|
|
629
|
+
couponCode?: string;
|
|
630
|
+
notes?: string;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Response from guest order creation
|
|
634
|
+
*/
|
|
635
|
+
interface GuestOrderResponse {
|
|
636
|
+
orderId: string;
|
|
637
|
+
orderNumber: string;
|
|
638
|
+
status: string;
|
|
639
|
+
total: number;
|
|
640
|
+
message: string;
|
|
641
|
+
}
|
|
540
642
|
type CheckoutStatus = 'PENDING' | 'SHIPPING_SET' | 'PAYMENT_PENDING' | 'PAYMENT_PROCESSING' | 'COMPLETED' | 'FAILED' | 'EXPIRED';
|
|
541
643
|
interface CheckoutAddress {
|
|
542
644
|
firstName: string;
|
|
@@ -1556,7 +1658,7 @@ declare class OmniSyncClient {
|
|
|
1556
1658
|
* await omni.clearCart('cart_123');
|
|
1557
1659
|
* ```
|
|
1558
1660
|
*/
|
|
1559
|
-
clearCart(cartId: string): Promise<
|
|
1661
|
+
clearCart(cartId: string): Promise<Cart>;
|
|
1560
1662
|
/**
|
|
1561
1663
|
* Apply a coupon to the cart
|
|
1562
1664
|
*
|
|
@@ -1700,6 +1802,149 @@ declare class OmniSyncClient {
|
|
|
1700
1802
|
* ```
|
|
1701
1803
|
*/
|
|
1702
1804
|
completeCheckout(checkoutId: string): Promise<CompleteCheckoutResponse>;
|
|
1805
|
+
private readonly LOCAL_CART_KEY;
|
|
1806
|
+
/**
|
|
1807
|
+
* Check if localStorage is available (browser environment)
|
|
1808
|
+
*/
|
|
1809
|
+
private isLocalStorageAvailable;
|
|
1810
|
+
/**
|
|
1811
|
+
* Get local cart from localStorage
|
|
1812
|
+
* Returns empty cart if none exists
|
|
1813
|
+
*
|
|
1814
|
+
* @example
|
|
1815
|
+
* ```typescript
|
|
1816
|
+
* const cart = omni.getLocalCart();
|
|
1817
|
+
* console.log('Items in cart:', cart.items.length);
|
|
1818
|
+
* ```
|
|
1819
|
+
*/
|
|
1820
|
+
getLocalCart(): LocalCart;
|
|
1821
|
+
/**
|
|
1822
|
+
* Save local cart to localStorage
|
|
1823
|
+
*/
|
|
1824
|
+
private saveLocalCart;
|
|
1825
|
+
/**
|
|
1826
|
+
* Add item to local cart (NO API call)
|
|
1827
|
+
* If item already exists, updates quantity
|
|
1828
|
+
*
|
|
1829
|
+
* @example
|
|
1830
|
+
* ```typescript
|
|
1831
|
+
* omni.addToLocalCart({
|
|
1832
|
+
* productId: 'prod_123',
|
|
1833
|
+
* quantity: 2,
|
|
1834
|
+
* name: 'Cool Shirt',
|
|
1835
|
+
* price: '29.99',
|
|
1836
|
+
* });
|
|
1837
|
+
* ```
|
|
1838
|
+
*/
|
|
1839
|
+
addToLocalCart(item: Omit<LocalCartItem, 'addedAt'>): LocalCart;
|
|
1840
|
+
/**
|
|
1841
|
+
* Update item quantity in local cart
|
|
1842
|
+
* Set quantity to 0 to remove item
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* ```typescript
|
|
1846
|
+
* omni.updateLocalCartItem('prod_123', 3); // Set quantity to 3
|
|
1847
|
+
* omni.updateLocalCartItem('prod_123', 0); // Remove item
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
updateLocalCartItem(productId: string, quantity: number, variantId?: string): LocalCart;
|
|
1851
|
+
/**
|
|
1852
|
+
* Remove item from local cart
|
|
1853
|
+
*
|
|
1854
|
+
* @example
|
|
1855
|
+
* ```typescript
|
|
1856
|
+
* omni.removeFromLocalCart('prod_123');
|
|
1857
|
+
* omni.removeFromLocalCart('prod_456', 'variant_789');
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
removeFromLocalCart(productId: string, variantId?: string): LocalCart;
|
|
1861
|
+
/**
|
|
1862
|
+
* Clear all items from local cart
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ```typescript
|
|
1866
|
+
* omni.clearLocalCart();
|
|
1867
|
+
* ```
|
|
1868
|
+
*/
|
|
1869
|
+
clearLocalCart(): LocalCart;
|
|
1870
|
+
/**
|
|
1871
|
+
* Set customer info on local cart
|
|
1872
|
+
*
|
|
1873
|
+
* @example
|
|
1874
|
+
* ```typescript
|
|
1875
|
+
* omni.setLocalCartCustomer({
|
|
1876
|
+
* email: 'john@example.com',
|
|
1877
|
+
* firstName: 'John',
|
|
1878
|
+
* lastName: 'Doe',
|
|
1879
|
+
* });
|
|
1880
|
+
* ```
|
|
1881
|
+
*/
|
|
1882
|
+
setLocalCartCustomer(customer: LocalCart['customer']): LocalCart;
|
|
1883
|
+
/**
|
|
1884
|
+
* Set shipping address on local cart
|
|
1885
|
+
*
|
|
1886
|
+
* @example
|
|
1887
|
+
* ```typescript
|
|
1888
|
+
* omni.setLocalCartShippingAddress({
|
|
1889
|
+
* firstName: 'John',
|
|
1890
|
+
* lastName: 'Doe',
|
|
1891
|
+
* line1: '123 Main St',
|
|
1892
|
+
* city: 'Tel Aviv',
|
|
1893
|
+
* postalCode: '6100000',
|
|
1894
|
+
* country: 'IL',
|
|
1895
|
+
* });
|
|
1896
|
+
* ```
|
|
1897
|
+
*/
|
|
1898
|
+
setLocalCartShippingAddress(address: LocalCart['shippingAddress']): LocalCart;
|
|
1899
|
+
/**
|
|
1900
|
+
* Set billing address on local cart
|
|
1901
|
+
*/
|
|
1902
|
+
setLocalCartBillingAddress(address: LocalCart['billingAddress']): LocalCart;
|
|
1903
|
+
/**
|
|
1904
|
+
* Set coupon code on local cart
|
|
1905
|
+
*/
|
|
1906
|
+
setLocalCartCoupon(couponCode: string | undefined): LocalCart;
|
|
1907
|
+
/**
|
|
1908
|
+
* Get total items count in local cart
|
|
1909
|
+
*/
|
|
1910
|
+
getLocalCartItemCount(): number;
|
|
1911
|
+
/**
|
|
1912
|
+
* Create order directly from local cart (guest checkout)
|
|
1913
|
+
* This is the main checkout method for vibe-coded sites!
|
|
1914
|
+
* Sends cart data to server and creates order in ONE API call.
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* ```typescript
|
|
1918
|
+
* // Build up the local cart first
|
|
1919
|
+
* omni.addToLocalCart({ productId: 'prod_123', quantity: 2 });
|
|
1920
|
+
* omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
|
|
1921
|
+
* omni.setLocalCartShippingAddress({ ... });
|
|
1922
|
+
*
|
|
1923
|
+
* // Then submit the order
|
|
1924
|
+
* const result = await omni.submitGuestOrder();
|
|
1925
|
+
* console.log('Order created:', result.orderId);
|
|
1926
|
+
*
|
|
1927
|
+
* // Clear cart after successful order
|
|
1928
|
+
* omni.clearLocalCart();
|
|
1929
|
+
* ```
|
|
1930
|
+
*/
|
|
1931
|
+
submitGuestOrder(options?: {
|
|
1932
|
+
clearCartOnSuccess?: boolean;
|
|
1933
|
+
}): Promise<GuestOrderResponse>;
|
|
1934
|
+
/**
|
|
1935
|
+
* Create order from custom data (not from local cart)
|
|
1936
|
+
* Use this if you manage cart state yourself
|
|
1937
|
+
*
|
|
1938
|
+
* @example
|
|
1939
|
+
* ```typescript
|
|
1940
|
+
* const result = await omni.createGuestOrder({
|
|
1941
|
+
* items: [{ productId: 'prod_123', quantity: 2 }],
|
|
1942
|
+
* customer: { email: 'john@example.com' },
|
|
1943
|
+
* shippingAddress: { firstName: 'John', ... },
|
|
1944
|
+
* });
|
|
1945
|
+
* ```
|
|
1946
|
+
*/
|
|
1947
|
+
createGuestOrder(data: CreateGuestOrderDto): Promise<GuestOrderResponse>;
|
|
1703
1948
|
/**
|
|
1704
1949
|
* Get the current customer's profile (requires customerToken)
|
|
1705
1950
|
* Only available in storefront mode
|
|
@@ -1823,4 +2068,4 @@ declare function isWebhookEventType(event: WebhookEvent, type: WebhookEventType)
|
|
|
1823
2068
|
*/
|
|
1824
2069
|
declare function createWebhookHandler(handlers: Partial<Record<WebhookEventType, (event: WebhookEvent) => Promise<void>>>): (payload: unknown) => Promise<void>;
|
|
1825
2070
|
|
|
1826
|
-
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 CreateCustomerDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerProfile, type CustomerQueryParams, type DraftLineItem, type EditInventoryDto, type FulfillOrderDto, type InventoryInfo, type InventorySyncStatus, 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 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 };
|
|
2071
|
+
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 CreateCustomerDto, type CreateGuestOrderDto, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateVariantDto, 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 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 };
|