@techsio/storefront-data
Version:
Medusa-first storefront data layer built on TanStack Query.
24 lines • 1.62 kB
TypeScript
import type { QueryClient } from "@tanstack/react-query";
import type { CartQueryKeys } from "../cart/types";
import type { QueryKey } from "./query-keys";
type CartLike = {
id: string;
region_id?: string | null;
};
export type ActiveCartQueryKeyMatcher = (queryKey: QueryKey, cartId: string) => boolean;
export type CartCacheSyncOptions = {
isActiveCartQueryKey?: ActiveCartQueryKeyMatcher;
};
export type CartUpdater<TCart extends CartLike> = (cart: TCart) => TCart;
export declare const createDefaultActiveCartQueryMatcher: (queryKeys: CartQueryKeys) => ActiveCartQueryKeyMatcher;
export declare function syncCartCaches<TCart extends CartLike>(queryClient: QueryClient, queryKeys: CartQueryKeys, cart: TCart, options?: CartCacheSyncOptions): void;
export declare function invalidateCartCaches(queryClient: QueryClient, queryKeys: CartQueryKeys, cartId: string, options?: CartCacheSyncOptions): void;
export declare function cancelCartCaches(queryClient: QueryClient, queryKeys: CartQueryKeys, cartId: string, options?: CartCacheSyncOptions): Promise<void>;
export type PatchCartCachesParams<TCart extends CartLike> = {
patch: CartUpdater<TCart>;
options?: CartCacheSyncOptions;
};
export declare function patchCartCaches<TCart extends CartLike>(queryClient: QueryClient, queryKeys: CartQueryKeys, cartId: string, params: PatchCartCachesParams<TCart>): void;
export declare function getCachedCartById<TCart extends CartLike>(queryClient: QueryClient, queryKeys: CartQueryKeys, cartId: string, options?: CartCacheSyncOptions): TCart | null;
export {};
//# sourceMappingURL=cart-cache-sync.d.ts.map