import { HookEnableParam } from '../../../shared/hooks/types'; import { GetHierarchyModelsOptions } from './get-hierarchy-models'; import { HierarchyModel } from './hierarchy-model'; /** * Parameters for {@link useGetHierarchyModels} hook. */ export interface GetHierarchyModelsParams extends GetHierarchyModelsOptions, HookEnableParam { } /** * States of hierarchy models load. */ export type HierarchyModelsState = HierarchyModelsLoadingState | HierarchyModelsErrorState | HierarchyModelsSuccessState; /** * State of hierarchy models that is loading. */ export type HierarchyModelsLoadingState = { /** Whether the hierarchy models is loading */ isLoading: true; /** Whether the hierarchy models load has failed */ isError: false; /** Whether the hierarchy models load has succeeded */ isSuccess: false; /** Error, if one occurred */ error: undefined; /** Hierarchy models, if the load succeeded */ hierarchies: HierarchyModel[] | undefined; /** Loading status */ status: 'loading'; }; /** * State of a hierarchy models load that has failed. */ export type HierarchyModelsErrorState = { /** Whether the hierarchy models is loading */ isLoading: false; /** Whether the hierarchy models load has failed */ isError: true; /** Whether the hierarchy models load has succeeded */ isSuccess: false; /** Error, if one occurred */ error: Error; /** Hierarchy models, if the load succeeded */ hierarchies: undefined; /** Loading status */ status: 'error'; }; /** * State of a hierarchy models load that has succeeded. */ export type HierarchyModelsSuccessState = { /** Whether the hierarchy models is loading */ isLoading: false; /** Whether the hierarchy models load has failed */ isError: false; /** Whether the hierarchy models load has succeeded */ isSuccess: true; /** Error, if one occurred */ error: undefined; /** Hierarchy models, if the load succeeded */ hierarchies: HierarchyModel[]; /** Loading status */ status: 'success'; }; /** * React hook that retrieves existing hierarchy models from a Fusion instance. * * @example * Retrieve the hierarchy models and render their counts. ```tsx const { hierarchies, isLoading, isError } = useGetHierarchyModels({ dataSource: DM.DataSource, dimension: DM.Commerce.AgeRange, }); if (isLoading) { return
Loading...
; } if (isError) { return
Error
; } if (hierarchies) { return
{`Total Hierarchies: ${hierarchies.length}`}
; } return null; ``` * @returns Load state that contains the status of the execution, the result hierarchy models, or the error if one has occurred * @group Fusion Assets * @fusionEmbed */ export declare const useGetHierarchyModels: (params: GetHierarchyModelsParams) => HierarchyModelsState; /** * {@link useGetHierarchyModels} without tracking to be used inside other hooks or components in Compose SDK. * * @param params - Parameters of the hierarchies to be retrieved * @internal */ export declare function useGetHierarchyModelsInternal(params: GetHierarchyModelsParams): HierarchyModelsState;