import type { BaseFacetSearchResult } from '../../../../api/search/facet-search/base/base-facet-search-response.js'; import type { CategoryFacetSearchResult } from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; import type { CommerceEngine } from '../../../../app/commerce-engine/commerce-engine.js'; import type { CategoryFacet, CategoryFacetState } from '../../../../controllers/commerce/core/facets/category/headless-commerce-category-facet.js'; import type { DateFacet, DateFacetState, DateFacetValue } from '../../../../controllers/commerce/core/facets/date/headless-commerce-date-facet.js'; import type { FacetGenerator as CSRFacetGenerator, MappedGeneratedFacetController } from '../../../../controllers/commerce/core/facets/generator/headless-commerce-facet-generator.js'; import type { CategoryFacetValue, CoreCommerceFacet, FacetType } from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet.js'; import type { LocationFacet, LocationFacetState } from '../../../../controllers/commerce/core/facets/location/headless-commerce-location-facet.js'; import type { NumericFacet, NumericFacetState, NumericFacetValue } from '../../../../controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.js'; import type { RegularFacet, RegularFacetState } from '../../../../controllers/commerce/core/facets/regular/headless-commerce-regular-facet.js'; import type { LocationFacetValue, RegularFacetValue } from '../../../../features/commerce/facets/facet-set/interfaces/response.js'; import { SolutionType } from '../../types/controller-constants.js'; import type { ControllerDefinitionOption, SubControllerDefinitionWithoutProps } from '../../types/controller-definitions.js'; export type { BaseFacetSearchResult, CategoryFacet, CategoryFacetSearchResult, CategoryFacetState, CategoryFacetValue, CoreCommerceFacet, DateFacet, DateFacetState, DateFacetValue, LocationFacet, LocationFacetState, LocationFacetValue, MappedGeneratedFacetController, NumericFacet, NumericFacetState, NumericFacetValue, RegularFacet, RegularFacetState, RegularFacetValue, }; export type FacetGeneratorState = MappedFacetStates; export type MappedFacetStates = Array; export type { FacetType }; export type MappedFacetState = { [T in FacetType]: T extends 'numericalRange' ? NumericFacetState : T extends 'regular' ? RegularFacetState : T extends 'dateRange' ? DateFacetState : T extends 'hierarchical' ? CategoryFacetState : T extends 'location' ? LocationFacetState : never; }; /** * @group Definers */ export declare function defineFacetGenerator(options?: TOptions): SubControllerDefinitionWithoutProps; /** * The `FacetGenerator` headless sub-controller creates commerce facet sub-controllers from the Commerce API search or * product listing response. * * Commerce facets are not requested by the implementer, but rather pre-configured through the Coveo Merchandising Hub * (CMH). The implementer is only responsible for leveraging the facet controllers created by this sub-controller to * properly render facets in their application. */ export interface FacetGenerator extends Omit { /** * The state of each every facet returned by the Commerce API. * * In a server-side rendering (SSR) scenario, use this state to render the facet UI components before the * facet controller is hydrated on the client side. * * Once the facet generator controller has been hydrated, use the `getFacetController` method to retrieve * the individual facet controllers and subscribe to their respective states. */ state: FacetGeneratorState; /** * Builds a facet controller for the specified facet ID. * * @param facetId The unique identifier of the facet. * @param facetType The type of facet to build. * @returns A facet controller of the specified type, or `undefined` if the facet does not exist in the state. */ getFacetController: (facetId: string, facetType: T) => MappedGeneratedFacetController[T] | undefined; } export interface FacetGeneratorOptions { props: FacetGeneratorProps; } interface FacetGeneratorProps { solutionType: SolutionType; } /** * Creates a `FacetGenerator` sub-controller for server-side rendering purposes (SSR). * * @param engine - The SSR commerce engine. * @param options - The facet generator options used internally. * @returns A `FacetGenerator` sub-controller. */ export declare function buildFacetGenerator(engine: CommerceEngine, options: FacetGeneratorOptions): FacetGenerator;