UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

32 lines (31 loc) 1.44 kB
import type { Brand, BrandsEndpointRequestParameters, BrandsEndpointResponseData, RpcHandler } from '../../types'; /** * Retrieves a list of brands. * * This function uses the Storefront cache (`cached()`) with a `getBrands` key prefix to improve performance. * Cached entries are returned if found; otherwise, data is fetched and cached. * * @param params The parameters for retrieving brands. * @param params.pagination The pagination settings. * @param params.pagination.page The desired page number. * @param params.pagination.perPage The number of brands per page (optional, capped at `MAX_PER_PAGE`). * @param context The RPC context. * * @returns The list of brands. It will return an `ErrorResponse` if the request fails. */ export declare const getBrands: RpcHandler<BrandsEndpointRequestParameters, BrandsEndpointResponseData>; /** * Retrieves a brand by its ID. * * This function uses the Storefront cache (`cached()`) with a `getBrandById-${brandId}` key prefix to improve performance. * Cached entries are returned if found; otherwise, data is fetched and cached. * * @param params The parameters for retrieving a brand by its ID. * @param params.brandId The ID of the brand to retrieve. * @param context The RPC context. * * @returns The brand. It will return an `ErrorResponse` alternatively If the request fails. */ export declare const getBrandById: RpcHandler<{ brandId: number; }, Brand>;