import type { HttpClient } from '@sisense/sdk-rest-client'; import type { DashboardProps } from '../../../domains/dashboarding/types.js'; import { type DashboardNarrativeByIdOptions, type DashboardNarrativeQuery, type DashboardNarrativeRequestOptions, type DashboardNarrativeTriggerType } from '../../../infra/api/narrative/dashboard-narrative-endpoints.js'; import type { NarrativeData } from '../components/narrative/types.js'; type DashboardForNarrative = Pick; /** * Options of {@link getNarrativeFromDashboard}. * @sisenseInternal */ export type GetNarrativeFromDashboardOptions = { /** * Whether the dashboard filters are applied to each widget's query, as the dashboard applies * them when it renders. Defaults to `true`. */ includeFilters?: boolean; /** The control that asked for the narrative, for the service's usage tracking. */ triggerType?: DashboardNarrativeTriggerType; }; /** * Why {@link getNarrativeFromDashboard} produced no narrative, besides a failed request: * - `no-data`: no widget yields a query, or the widgets returned no data. * - `invalid-response`: the service answered with something that is not a narrative. * @internal */ export type NarrativeFromDashboardErrorCode = 'no-data' | 'invalid-response'; /** * Tells whether a failure of {@link requestDashboardNarrative} means there was no data to narrate. * @param error - The rejection. * @returns `true` for a `'no-data'` error. * @internal */ export declare function isNoDataNarrativeError(error: unknown): boolean; /** * Generates the narrative of a dashboard: a saved one by its id, or one that is not saved by its * widgets' queries, at most {@link DASHBOARD_NARRATIVE_MAX_QUERIES} of them. A server-side failure * is retried once. * @param httpClient - HttpClient of the Sisense app. * @param source - The saved dashboard's id, or the props of a dashboard that is not saved. A * widget of the latter with no `dataSource` of its own falls back to `dashboard.defaultDataSource` * only — not to the app's default data source, as a narrative widget would — and is left out * when the dashboard has none. * @param options - Filters and usage tracking. * @returns The narrative, and how many widgets it leaves out. * @throws The request error, with its HTTP `status`. Otherwise an `Error` with a `code`: * `'no-data'` when no widget yields a query or the widgets returned no data, * `'invalid-response'` when the response is not a narrative. * @example * ```ts * const { narrative, excludedWidgetCount } = await getNarrativeFromDashboard( * app.httpClient, * { dashboardId: 'dashboard-oid' }, * { includeFilters: false }, * ); * console.log(narrative.overview, narrative.insights); * ``` * @group Generative AI * @sisenseInternal */ export declare function getNarrativeFromDashboard(httpClient: HttpClient, source: { dashboardId: string; } | { dashboard: DashboardForNarrative; }, options?: GetNarrativeFromDashboardOptions): Promise; /** * A dashboard narrative and how many widgets it leaves out. * @sisenseInternal */ export type DashboardNarrativeResult = { narrative: NarrativeData; excludedWidgetCount: number; }; /** * What {@link requestDashboardNarrative} narrates: a saved dashboard by its id, or widget queries. * @internal */ export type DashboardNarrativeTarget = (Pick & { dashboardId: string; }) | { queries: readonly DashboardNarrativeQuery[]; /** Widgets the queries leave out, counted into `excludedWidgetCount`. */ omittedWidgetCount?: number; }; /** * Requests a dashboard narrative — the one request path of {@link getNarrativeFromDashboard} and * the narrative widget. Sends at most {@link DASHBOARD_NARRATIVE_MAX_QUERIES} queries, retries a * server-side failure once and maps the response to the view model. * @param httpClient - HttpClient of the Sisense app. * @param target - The saved dashboard, or the widget queries, not yet capped. * @param options - Cache lookup and usage tracking. * @returns The narrative, and how many widgets it leaves out. * @throws The request error, with its HTTP `status`. Otherwise an `Error` with a `code`: * `'no-data'` when there is no query, the widgets returned no data or — for a `cacheOnly` * request — the cache holds no narrative; `'invalid-response'` when the response is not a * narrative. * @internal */ export declare function requestDashboardNarrative(httpClient: HttpClient, target: DashboardNarrativeTarget, options: DashboardNarrativeRequestOptions): Promise; export {};