UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

21 lines (20 loc) 1.01 kB
import type { Query } from '../index'; import type { SortingValueKey, SortValue } from '../types/sapi/sorting'; /** * Retrieves a subset of sorting values based on the provided keys. * Filters out invalid keys and returns an object mapping valid keys to their sorting configurations. * * @param options An array of sorting value keys to include in the result. Defaults to all available keys. * * @returns An object mapping valid sorting keys to their configurations. */ export declare const getSortingValues: (options?: SortingValueKey[]) => Record<SortingValueKey, SortValue>; /** * Retrieves the sorting configuration based on the provided query. * * @param query The sort query parameter. * @param defaultSort The default sorting key to use if the query is not recognized. Defaults to 'dateNewest'. * * @returns The sorting configuration object corresponding to the query or the default sort. */ export declare const getSortByValue: (query: Query, defaultSort?: SortingValueKey) => SortValue;