import type { Product, ProductVariant } from "../types"; import type { ProductFieldsFragment, ProductVariantDataFieldsFragment } from "./types/storefront.generated"; import type { HasMetafieldsIdentifier } from "./types/storefront.types"; /** * Shared metafield normalization used by both the single-product loader * (`load-product.ts`) and the batched loader (`load-products-by-ids.ts`). * * The Storefront API returns metafields as a flat array of * `{ namespace, key, value }`; the SDK's `Product`/`ProductVariant` types * expose them as a nested `{ [namespace]: { [key]: value } }` map. These * helpers convert between the two and seed the map with every requested * namespace so consumers can index without existence checks. */ export declare const uniqueNamespaces: (identifiers: ReadonlyArray) => string[]; export declare const withNormalizedVariantMetafields: (raw: ProductVariantDataFieldsFragment, variantNamespaces: string[]) => ProductVariant; /** * `variant` is a query-level alias (`variantBySelectedOptions`) that only the * single-product query selects, so it's optional here to keep this helper * reusable by the batched loader, whose product nodes don't include it. */ type RawProductFields = ProductFieldsFragment & { variant?: ProductVariantDataFieldsFragment | null; }; export declare const withNormalizedProductMetafields: (raw: RawProductFields | null, productNamespaces: string[], variantNamespaces: string[]) => Product | null; export {};