import type { WidgetProps } from '../../../domains/widgets/components/widget/types'; import type { DashboardNarrativeTriggerType } from '../../../infra/api/narrative/dashboard-narrative-endpoints.js'; import type { NarrativeState } from '../components/narrative/types.js'; /** * Parameters of {@link useNarrativeWidgetState}. * @internal */ export type UseNarrativeWidgetStateParams = { /** Widgets the narrative describes, in layout order. Not sent when `dashboardId` is set. */ widgets?: readonly WidgetProps[]; /** Saved dashboard to narrate; when non-empty, it is requested by id instead of by queries. */ dashboardId?: string; /** The dashboard is open in shared mode (co-authoring). Only sent with `dashboardId`. */ sharedMode?: boolean; /** The dashboard is open through Admin Access. Only sent with `dashboardId`. */ adminAccess?: boolean; /** * Generates once, as soon as the Sisense app is available, without waiting for `generate`. * Without it, the service's cache is looked up once instead, and nothing is generated. */ generateOnMount?: boolean; /** Sent as the generation's `triggerType` with `generateOnMount`. Defaults to `'export'`. */ generateOnMountTriggerType?: DashboardNarrativeTriggerType; /** Called each time a generation requested through `generate` ends with a narrative. */ onGenerated?: () => void; }; /** * Result of {@link useNarrativeWidgetState}. * @internal */ export type UseNarrativeWidgetStateResult = { /** What the widget renders. */ state: NarrativeState; /** Requests a narrative for the current widgets. */ generate: () => void; }; /** * Drives the dashboard narrative state machine: idle until `generate` is called (or, with * `generateOnMount`, until the Sisense app is available), then loading, then ready with the * narrative or one of the error kinds. * * Without `generateOnMount`, the service's cache is looked up once the Sisense app is available: * loading from mount until the lookup settles, then ready with a cached narrative, or idle when * the cache holds none or the lookup fails. Outside a Sisense context nothing is looked up. * * With a `dashboardId` the saved dashboard is requested by id; otherwise the widgets' queries * are sent. `no-data` when no widget yields a query (queries only); `failed` when the request * fails or the body is not a narrative. A retryable failure is retried once before it is * reported. Depends on {@link useSisenseContext} and a `QueryClientProvider` ancestor. * @param params - Dashboard id or widgets, and whether to generate on mount. * @returns The state to render and the generate action. * @internal */ export declare function useNarrativeWidgetState(params: UseNarrativeWidgetStateParams): UseNarrativeWidgetStateResult;