UNPKG

@techsio/storefront-data

Version:

Medusa-first storefront data layer built on TanStack Query.

44 lines • 2.85 kB
import type Medusa from "@medusajs/js-sdk"; import type { HttpTypes } from "@medusajs/types"; import type { ProductListBase, ProductListCartLike, ProductListCartResponse, ProductListItemBase, ProductListItemResponse, ProductListListResponse, ProductListListResult, ProductListResponse, ProductListService } from "./types"; type PlainQuery = Record<string, unknown>; export type MedusaProductListListInput = { handle?: string; type?: string; limit?: number; offset?: number; }; export type MedusaProductListDetailInput = { id?: string | null; }; export type MedusaProductListListHookInput = MedusaProductListListInput & { page?: number; customerId?: string | null; enabled?: boolean; }; export type MedusaProductListDetailHookInput = MedusaProductListDetailInput & { customerId?: string | null; enabled?: boolean; }; export type MedusaProductListListKeyInput = MedusaProductListListInput & { customerId?: string | null; }; export type MedusaProductListDetailKeyInput = MedusaProductListDetailInput & { customerId?: string | null; }; export type MedusaProductListServiceConfig<TProductList, TProductListItem, TCart extends ProductListCartLike, TListInput extends MedusaProductListListInput = MedusaProductListListInput> = { basePath?: string; defaultLimit?: number; defaultOffset?: number; normalizeListQuery?: (input: TListInput) => PlainQuery; transformProductList?: (list: ProductListBase<TProductListItem>) => TProductList; transformProductListItem?: (item: ProductListItemBase) => TProductListItem; transformCart?: (cart: HttpTypes.StoreCart) => TCart; }; export declare const normalizeProductListsResponse: <TProductList>(response: ProductListListResponse<TProductList>, fallbackLimit: number, fallbackOffset: number) => ProductListListResult<TProductList>; export declare const resolveProductListFromResponse: <TProductList>(response: ProductListResponse<TProductList>) => TProductList | null; export declare const resolveProductListItemFromResponse: <TProductList, TProductListItem>(response: ProductListItemResponse<TProductList, TProductListItem>) => TProductListItem | null; export declare const resolveProductListCartFromResponse: <TCart extends ProductListCartLike>(response: ProductListCartResponse<TCart>) => TCart | null; export declare function createMedusaProductListService<TProductList = ProductListBase<ProductListItemBase>, TProductListItem = ProductListItemBase, TCart extends ProductListCartLike = HttpTypes.StoreCart, TListInput extends MedusaProductListListInput = MedusaProductListListInput>(sdk: Medusa, config?: MedusaProductListServiceConfig<TProductList, TProductListItem, TCart, TListInput>): ProductListService<TProductList, TProductListItem, TCart, TListInput, MedusaProductListDetailInput>; export {}; //# sourceMappingURL=medusa-service.d.ts.map