UNPKG

@scayle/storefront-nuxt

Version:

Nuxt integration for the SCAYLE Commerce Engine and Storefront API

32 lines (31 loc) 2.23 kB
import type { RpcMethodParameters } from '@scayle/storefront-core'; import type { KeysOf, UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, UseRpcCacheKey } from '../core/useRpc.js'; import type { MaybeRefOrGetter } from 'vue'; /** * Retrieves data of the current active promotion data using the `getCurrentPromotions` RPC method. * * This function acts as a wrapper around the `useRpc` composable, * simplifying the process of fetching data. It internally calls `useRpc` * with the provided parameters and options, and it uses the default shared cache * implementation, getting data from Nuxt's payload or static data during hydration * or from async data otherwise. * * @see https://scayle.dev/en/api-guides/storefront-api/resources/promotions/list-promotions * @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/data-and-state#shared-state-and-caching * * @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCurrentPromotions'>`. * @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`. * @template DefaultT The default value to use if data is not available. Defaults to `null`. * * @param params An object containing parameters and options for the `getCurrentPromotions` RPC call. * @param params.params The parameters for the `getCurrentPromotions` RPC method. * @param params.options The options for the underlying `useRpc` call, controlling data handling and loading state. * @param key A unique key for this RPC call. Used internally by `useRpc` for caching and state management. * * @returns The result of the `useRpc` call, which includes the fetched data, * loading state, and any error information. */ export declare function useCurrentPromotions<DataT = NormalizedRpcResponse<'getCurrentPromotions'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{ params: MaybeRefOrGetter<RpcMethodParameters<'getCurrentPromotions'>>; options: UseRpcOptions<'getCurrentPromotions', DataT, PickKeys, DefaultT>; }>, key?: UseRpcCacheKey): UseRpcReturn<'getCurrentPromotions', DataT, PickKeys, DefaultT>;