import { CurrencyExchangeRates } from "crnc/x/interfaces.js"; import { Reader } from "./toolbox/pubsub.js"; import { ShopperComponent } from "./framework/shopper-component.js"; export type ShopperMock = null | "" | "mock" | "fail"; export interface ShopperConfig { mock: ShopperMock; currencies: string; baseCurrency: string; shopifyDomain: string; defaultQuantityMax: number; shopifyStorefrontAccessToken: string; } export interface PriceModelState { inputCurrency: string; outputCurrency: string; exchangeRates: CurrencyExchangeRates; } export type SetCurrency = (code: string) => void; export interface ShopperAssemblyOptions extends ShopperConfig { cartStorage: CartStorage; } export interface ShopperAssembly extends ShopperConfig { components: { [key: string]: typeof ShopperComponent; }; } export interface ShopperOptions extends ShopifyResults { catalog: CartItem[]; } export interface CartItem { product: Product; quantity: number; quantityMin: number; quantityMax: number; } export interface CartStorage { saveCart(catalog: CartItem[]): Promise; loadCart(catalog: CartItem[]): Promise; } export interface CurrencyStorage { save(code: string): Promise; load(): Promise; } export interface CartData { [productId: string]: { quantity: number; }; } export interface ShopperState { error: string; catalog: CartItem[]; checkedOut: boolean; checkoutInProgress: boolean; } export interface ShopperGetters { readonly itemsInCart: CartItem[]; readonly cartValue: number; readonly cartQuantity: number; getUnitValue(item: CartItem): number; getLineValue(item: CartItem): number; getLineComparedValue(item: CartItem): number; } export interface ShopperActions { addToCart(item: CartItem): Promise; clearCart(): Promise; setItemQuantity(item: CartItem, quantity: number): Promise; checkout(options: { checkoutInSameWindow: boolean; }): Promise; setError(message: string): Promise; setShopifyResults(results: ShopifyResults): Promise; } export interface ShopperModel { reader: Reader; getters: ShopperGetters; actions: ShopperActions; } export type ShopifyClient = any; export interface ShopifyAdapterOptions { domain: string; storefrontAccessToken: string; } export interface ShopifyResults { products: Product[]; collectionIds: string[]; } export interface ProductImage { alt: string; src: string; } export interface Product { id: string; value: number; title: string; available: boolean; description: string; collections: string[]; comparedValue: number; firstVariantId: string; image?: ProductImage; }