import { type SchemaDefinition } from '@coveo/bueno'; import type { UnknownAction } from '@reduxjs/toolkit'; import type { CommerceEngine } from '../../../../app/commerce-engine/commerce-engine.js'; import { stateKey } from '../../../../app/state-key.js'; import type { Parameters } from '../../../../features/commerce/parameters/parameters-actions.js'; import { type Controller } from '../../../controller/headless-controller.js'; import type { FetchProductsActionCreator } from '../common.js'; export interface ParameterManagerProps { /** * The initial state that should be applied to the `ParameterManager` sub-controller. */ initialState?: ParameterManagerInitialState; /** * Whether the controller's state should exclude the default parameters returned by the Commerce API, and only include * the parameters that were set explicitly set through dispatched actions. * * Defaults to `false`. */ excludeDefaultParameters?: boolean; } export interface CoreParameterManagerProps extends ParameterManagerProps { /** * The definition of the parameters. */ parametersDefinition: SchemaDefinition>; /** * The selector to retrieve the active parameters from the state. */ activeParametersSelector: (state: CommerceEngine[typeof stateKey]) => T; /** * The action to dispatch to update the parameters in the state. */ restoreActionCreator: (parameters: T) => UnknownAction; /** * The action to dispatch to fetch more results. */ fetchProductsActionCreator: FetchProductsActionCreator; } export interface ParameterManagerInitialState { /** * The parameters affecting the response. */ parameters: T; } /** * The `ParameterManager` sub-controller allows restoring parameters that affect the results (for example, from the URL). * * @group Sub-controllers * @category ParameterManager */ export interface ParameterManager extends Controller { /** * Updates the parameters in the state with the specified parameters and fetches results. Unspecified keys are reset to their initial values. * * @param parameters - The parameters to synchronize. */ synchronize(parameters: T): void; /** * The state relevant to the `ParameterManager` sub-controller. */ state: ParameterManagerState; } /** * The state of the `ParameterManager` sub-controller. * * @group Sub-controllers * @category ParameterManager */ export interface ParameterManagerState { /** * The parameters affecting the response. */ parameters: T; } /** * @internal * Creates a `ParameterManager` sub-controller instance. * * @param engine - The headless commerce engine. * @param props - The configurable `ParameterManager` properties. * @returns A `ParameterManager` sub-controller instance. */ export declare function buildCoreParameterManager(engine: CommerceEngine, props: CoreParameterManagerProps): ParameterManager;