UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

37 lines (36 loc) 1.85 kB
import type { BasketResponse, AddManyItemsBasketResponse } from '@scayle/storefront-api'; import type { BasketWithOptions, Product, RpcContext, Variant } from '../types'; /** * Checks if the access token is expired. * * @param accessToken The access token to validate. * * @returns The validated access token or undefined if the access token is not present or expired. */ export declare const getValidatedAccessToken: (accessToken?: string) => string | undefined; /** * Merges two baskets. Adds the items from the `fromBasketKey` basket to the `toBasketKey` basket * and then clears the `fromBasketKey` basket. Handles existing items by adding quantities. * * @param fromBasketKey The key of the source basket. * @param toBasketKey The key of the destination basket. * @param withOptions Options for retrieving basket data (including custom and order data). * @param context The RPC context. * * @returns The merged basket. */ export declare const mergeBaskets: (fromBasketKey: string, toBasketKey: string, withOptions: BasketWithOptions & { orderCustomData?: Record<string, unknown>; }, context: RpcContext) => Promise<BasketResponse<Product, Variant> | AddManyItemsBasketResponse<Product, Variant> | undefined>; /** * Merges two wishlists. Adds the items from the `fromWishlistKey` wishlist to the `toWishlistKey` wishlist * and then clears the `fromWishlistKey` wishlist. * * @param fromWishlistKey The key of the source wishlist. * @param toWishlistKey The key of the destination wishlist. * @param withOptions Options for retrieving wishlist data. * @param context The RPC context. * * @returns Nothing (resolves when the merge operation is complete). */ export declare const mergeWishlists: (fromWishlistKey: string, toWishlistKey: string, withOptions: BasketWithOptions, context: RpcContext) => Promise<void>;