@scayle/storefront-nuxt
Version:
Nuxt integration for the SCAYLE Commerce Engine and Storefront API
32 lines (31 loc) • 2.13 kB
TypeScript
import type { RpcMethodParameters, Order } from '@scayle/storefront-core';
import type { AsyncDataOptions } from 'nuxt/app';
import type { KeysOf, ExtendedAsyncData, UseRpcCacheKey } from '../core/useRpc.js';
import type { MaybeRefOrGetter } from 'vue';
/**
* Retrieves order data by ID using the `getOrderById` 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.
* It allows for flexible typing of the `product` and `variant` properties within the order items.
*
* @see https://scayle.dev/en/api-guides/customer-account-api/resources/order/get-order
*
* @template P The type of the `product` property within the order items. Defaults to an object with any keys.
* @template V The type of the `variant` property within the order items. Defaults to an object with any keys.
* @template DataT The type of the transformed data. Defaults to `Order<P, V>`.
* @template PickKeys Keys of the `DataT` type that will be present. This defaults to all keys of DataT.
* @template DefaultT The default return type. Useful for showing loading skeletons. Defaults to `null`.
*
* @param params An object containing parameters and options for the `getOrderById` RPC call.
* @param params.params The parameters for the `getOrderById` 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 An extended async data object containing the order data.
*/
export declare function useOrder<P = Record<string, unknown>, V = Record<string, unknown>, DataT = Order<P, V>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: {
params?: MaybeRefOrGetter<RpcMethodParameters<'getOrderById'>>;
options?: AsyncDataOptions<Order<P, V>, DataT, PickKeys, DefaultT>;
}, key?: UseRpcCacheKey): ExtendedAsyncData<Order<P, V>, unknown, DataT, PickKeys, DefaultT>;