import { CalculatedMeasure, DataSource } from '@sisense/sdk-data'; import { HookEnableParam } from '../../shared/hooks/types'; /** * Params of the {@link useGetSharedFormula} hook * * Can consist either of an oid or a name/dataSource pair */ export interface UseGetSharedFormulaParams extends HookEnableParam { /** * Formula identifier */ oid?: string; /** * Formula name */ name?: string; /** * Data source - e.g. `Sample ECommerce` */ dataSource?: DataSource; } /** * Parameters for {@link useGetSharedFormula} hook. */ export interface GetSharedFormulaParams extends UseGetSharedFormulaParams, HookEnableParam { /** * Dashboard identifier */ dashboardOid: string; } /** * States of a shared formula load. */ export type SharedFormulaState = SharedFormulaLoadingState | SharedFormulaErrorState | SharedFormulaSuccessState; /** * State of a shared formula loading. */ export type SharedFormulaLoadingState = { /** Whether the shared formula is loading */ isLoading: true; /** Whether the shared formula load has failed */ isError: false; /** Whether the shared formula load has succeeded */ isSuccess: false; /** The error if any occurred */ error: undefined; /** The result shared formula if the load has succeeded */ formula: CalculatedMeasure | null; /** The status of the shared formula load */ status: 'loading'; }; /** * State of a shared formula load that has failed. */ export type SharedFormulaErrorState = { /** Whether the shared formula is loading */ isLoading: false; /** Whether the shared formula load has failed */ isError: true; /** Whether the shared formula load has succeeded */ isSuccess: false; /** The error if any occurred */ error: Error; /** The result shared formula if the load has succeeded */ formula: undefined; /** The status of the shared formula load */ status: 'error'; }; /** * State of a shared formula load that has succeeded. */ export type SharedFormulaSuccessState = { /** Whether the shared formula is loading */ isLoading: false; /** Whether the shared formula load has failed */ isError: false; /** Whether the shared formula load has succeeded */ isSuccess: true; /** The error if any occurred */ error: undefined; /** The result shared formula if the load has succeeded */ formula: CalculatedMeasure | null; /** The status of the shared formula load */ status: 'success'; }; /** * Fetch a [shared formula](https://docs.sisense.com/main/SisenseLinux/shared-formulas.htm) from the a Fusion instance. * * The formula can be identified either by `oid` or by name and data source pair. * * When the retrieval is successful but the shared formula is not found, the resulting `formula` is `null`. When the retrieval is not successful the resulting `formula` is `undefined`. * * @example * An example of retrieving a shared formula by oid: ```tsx const { formula, isLoading, isError } = useGetSharedFormula({ oid: 'd61c337b-fabc-4e9e-b4cc-a30116857153' }) ``` * @example * An example of retrieving a shared formula by name and data source: ```tsx const { formula, isLoading, isError } = useGetSharedFormula({ name: 'My Shared Formula', datasource: DM.DataSource }) ``` * @returns Formula load state that contains the status of the execution, the result formula, or the error if any * @group Fusion Assets * @fusionEmbed */ export declare const useGetSharedFormula: (params: UseGetSharedFormulaParams) => SharedFormulaState; /** * {@link useGetSharedFormula} without tracking to be used inside other hooks or components in Compose SDK. * * @param params - {@link UseGetSharedFormulaParams} * @internal */ export declare function useGetSharedFormulaInternal(params: UseGetSharedFormulaParams): SharedFormulaState;