UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

55 lines (54 loc) 1.86 kB
import type { FieldSet, GroupSet } from '../types'; /** * Flattens each object within a FieldSet. * * @param fieldSet The FieldSet to flatten. * * @returns An array of flattened objects. */ export declare const flattenFieldSet: (fieldSet: FieldSet) => FieldSet[number]; interface FlattenedMaterialComposition { materialGroupName?: string; values: { value: string | number; unit: string; material: string; }[]; } /** * Transforms an array of material compositions into a flattened structure. * * @param materialCompositions The material compositions to flatten. * * @returns An array of flattened material compositions. * * @deprecated Logic for flattening material compositions should be handled within the Storefront project itself. */ export declare const getFlattenedMaterialComposition: (materialCompositions: Array<{ fieldSet: FieldSet; groupSet: GroupSet; }>) => FlattenedMaterialComposition[]; /** * Flattens an attribute group into a generic array. * * @param attributeGroup The attribute group to flatten. * * @returns A generically typed array of flattened attributes. */ export declare const getFlattenedAdvancedAttribute: <T>(attributeGroup: Array<{ fieldSet: FieldSet; groupSet: GroupSet; }>) => T[]; /** * Flattens variant cross-selling data into a generic array. This function uses the `getFlattenedAdvancedAttribute` internally. * * @param variantCrosssellings The variant cross-selling data to flatten. * @returns A generically typed array of flattened variant cross-selling data. * * @deprecated Logic for flattening variant crosssellings should be handled within the Storefront project itself. */ export declare const getFlattenedVariantCrosssellings: <T>(variantCrosssellings: Array<{ fieldSet: FieldSet; groupSet: GroupSet; }>) => T[]; export {};