export interface AjaxConfig { storeDomain: string; fetch?: (input: string | URL | Request, init?: RequestInit) => Promise; responseInterceptor?: (response: Response, request: Request) => Promise | void; /** * Called as a request is dispatched, before any response exists. Returning a * function marks that request as in flight; the returned function is called * once its response has been fully processed, or once the request has failed, * so a consumer can hold state for the whole round trip. */ requestInterceptor?: (request: Request) => (() => void) | void; } export interface CartLineItem { id: number; properties: Record | null; quantity: number; variant_id: number; key: string; title: string; price: number; original_price: number; discounted_price: number; line_price: number; original_line_price: number; total_discount: number; discounts: any[]; sku: string; grams: number; vendor: string; taxable: boolean; product_id: number; gift_card: boolean; final_price: number; final_line_price: number; url: string; image: string; handle: string; requires_shipping: boolean; product_type: string; product_title: string; product_description: string; variant_title: string; variant_options: string[]; line_level_discount_allocations: any[]; } export interface Cart { token: string; note: string | null; attributes: Record; original_total_price: number; total_price: number; total_discount: number; total_weight: number; item_count: number; items: CartLineItem[]; requires_shipping: boolean; currency: string; items_subtotal_price: number; cart_level_discount_applications: any[]; } export interface AjaxProduct { id: number; handle: string; options: AjaxProductOption[]; } export interface AjaxProductOption { name: string; position: number; values: string[]; } export interface AddToCartItem { id: string | number; quantity: number; } export interface AddToCartRequest { items: AddToCartItem[]; } export interface AddToCartResponse { items: CartLineItem[]; } export interface CartChangeItem { product_id: number; variant_id: number; id: string; image: string; price: string; presentment_price: number; quantity: number; title: string; product_title: string; variant_title: string; vendor: string; product_type: string; sku: string; url: string; untranslated_product_title: string; untranslated_variant_title: string; view_key: string; } export interface CartChangeResponse extends Cart { items_added?: CartChangeItem[]; items_removed?: CartChangeItem[]; discount_codes: any[]; } export interface CartError { message: string; status: string; description: string; } export declare class AjaxApiClient { private readonly config; private readonly cache; constructor(config: AjaxConfig); patchFetch(): void; /** * Some themes drive their cart AJAX with XMLHttpRequest instead of fetch * (jQuery `.ajax()`, older cart-drawer implementations, etc). `patchFetch` * never observes those calls, so cart-line removals on those themes never * publish `cart-change`/`cart-update` — see SWI-2624. This mirrors * `patchFetch`, synthesizing a Fetch API Request/Response pair from the * XHR so it can go through the same `responseInterceptor`. */ patchXhr(): void; private getFetchRequest; fetch(input: string | URL | Request, init?: RequestInit): Promise; private request; fetchCart(): Promise; fetchProduct(handle: string): Promise; addToCart(request: AddToCartRequest): Promise; updateCartAttributes(attributes: Record): Promise; clearCache(): Promise; }