UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

31 lines (30 loc) 1.66 kB
import type { SearchV2ResolveEndpointParameters, SearchV2ResolveEndpointResponseData, SearchV2SuggestionsEndpointParameters, SearchV2SuggestionsEndpointResponseData } from '../../types/sapi/search'; import type { RpcHandler } from '../../types'; /** * Fetches search suggestions for a given term. * * @param option The parameters for the request. * @param option.term The term to search for. * @param option.with An object describing which data the returned suggestions should contain. * @param option.categoryId The category ID to search within. * @param context The RPC context. * * @returns A promise that resolves to a list of search suggestions. * It will return an `ErrorResponse` if the request fails. */ export declare const getSearchSuggestions: RpcHandler<SearchV2SuggestionsEndpointParameters, SearchV2SuggestionsEndpointResponseData>; /** * Resolves a search query and returns the resolved entity. * * This function uses the Storefront cache (`cached()`) with a `resolve-${term}` key prefix to improve performance. * Cached entries are returned if found; otherwise, data is fetched and cached. * * @param option The parameters for the search query. * @param option.term The search query to resolve. * @param option.with An object describing which data the returned result should contain. * @param option.categoryId The category ID for which the search should be performed. * @param context The RPC context. * * @returns A promise that resolves to the resolved entity or null if no entity is found. */ export declare const resolveSearch: RpcHandler<SearchV2ResolveEndpointParameters, SearchV2ResolveEndpointResponseData | null>;