UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

47 lines (46 loc) 2.18 kB
import type { PromotionsParams, PromotionsResponseData, RpcHandler } from '../../types'; /** * Retrieves promotions based on provided parameters. * * This function uses the Storefront cache (`cached()`) with a `getPromotions` key prefix to improve performance. * Cached entries are returned if found; otherwise, data is fetched and cached. * * @param params The parameters for retrieving promotions. * @param params.pagination Pagination settings. * @param params.pagination.page Page number. * @param params.pagination.perPage Number of items per page. * @param context The RPC context. * * @returns A Promise that resolves with the promotion data. * It will return an `ErrorResponse` if the The Storefront API request fails. */ export declare const getPromotions: RpcHandler<Omit<PromotionsParams, 'ids'>, PromotionsResponseData>; /** * Retrieves currently active promotions. * * This function uses the Storefront cache (`cached()`) with a `getPromotions` key prefix to improve performance. * Cached entries are returned if found; otherwise, data is fetched and cached. * * @param params The parameters for retrieving promotions. * @param params.pagination Pagination settings. * @param params.pagination.page Page number. * @param params.pagination.perPage Number of items per page. * @param context The RPC context. * * @returns A Promise that resolves with the current promotion data. * It will return an `ErrorResponse` if the The Storefront API request fails. */ export declare const getCurrentPromotions: RpcHandler<Omit<PromotionsParams, 'ids' | 'activeAt'>, PromotionsResponseData>; /** * Retrieves promotions by their IDs. * * This function uses the Storefront cache (`cached()`) with a `getByIds-promotions` key prefix to improve performance. * Cached entries are returned if found; otherwise, data is fetched and cached. * * @param ids An array of promotion IDs. * @param context The RPC context. * * @returns A Promise that resolves with the promotion data. * It will return an `ErrorResponse` if the The Storefront API request fails. */ export declare const getPromotionsByIds: RpcHandler<string[], PromotionsResponseData>;