import { DataSource } from '@sisense/sdk-data'; import { ChartWidgetProps } from '../../../domains/widgets/components/chart-widget/types'; import type { PivotTableWidgetProps } from '../../../domains/widgets/components/pivot-table-widget/types'; import type { WidgetProps, WithCommonWidgetProps } from '../../../domains/widgets/components/widget/types'; import type { NarrativeRequest } from '../../../infra/api/narrative/narrative-api-types.js'; import type { NarrativeQueryParams } from './build-narrative-request.js'; /** * Converts ChartWidgetProps to {@link NarrativeQueryParams} by extracting dimensions and measures * from the chart data options. * * @param props - ChartWidgetProps to convert * @param defaultDataSource - Optional default data source to use if props.dataSource is undefined * @param verbosity - Optional verbosity for narrative text * @param ignoreTrendAndForecast - When `true`, omits trend/forecast companion measures from the narrative JAQL * @returns Params ready for {@link prepareNarrativeRequest} * @throws If neither `props.dataSource` nor `defaultDataSource` is set * @internal */ export declare function convertChartWidgetPropsToNarrativeParams(props: ChartWidgetProps, defaultDataSource?: DataSource, verbosity?: 'Low' | 'High', ignoreTrendAndForecast?: boolean): NarrativeQueryParams; /** * Builds a narrative API request from pivot widget props using the same JAQL as pivot query * execution ({@link getPivotJaqlQueryPayload}). * * @param props - Pivot widget props (`widgetType: 'pivot'`) * @param defaultDataSource - Used when `props.dataSource` is undefined * @param verbosity - Optional verbosity for narrative text * @param ignoreTrendAndForecast - When `true`, omits trend/forecast from pivot value columns in the narrative JAQL * @returns Request ready for `getNarrative` * @throws If data source cannot be resolved, or pivot query description is invalid * @internal */ export declare function convertPivotWidgetPropsToNarrativeRequest(props: WithCommonWidgetProps, defaultDataSource?: DataSource, verbosity?: 'Low' | 'High', ignoreTrendAndForecast?: boolean): NarrativeRequest; /** * @deprecated Use {@link convertChartWidgetPropsToNarrativeParams}. Same function; kept for legacy `getNlgInsightsFromWidget`. */ export declare const convertChartWidgetPropsToUseGetNlgInsightsParams: typeof convertChartWidgetPropsToNarrativeParams; /** * Error message for imperative callers (e.g. {@link getNlgInsightsFromWidget}) when chart or pivot * props omit `dataSource` and no `defaultDataSource` is passed. * * @internal */ export declare const MISSING_DATASOURCE_NLG_ERROR = "dataSource is required. Provide it on the widget props or as defaultDataSource parameter."; export type WidgetNarrativeRequestPair = { supported: boolean; narrativeRequest: NarrativeRequest | undefined; /** * Same request with trend/forecast stripped. `undefined` when `ignoreTrendAndForecast` is * already `true` (primary already stripped), when the widget type is unsupported, or when * the fallback conversion itself fails. */ narrativeFallbackRequest: NarrativeRequest | undefined; /** * When `supported` is `false`, `true` means chart/pivot had no resolved data source (props and * `defaultDataSource` were both unset); conversion was skipped. */ missingDataSource?: boolean; }; /** * Builds a primary narrative request and, when useful, a fallback request with trend/forecast * stripped — both from the same widget props in a single call. * * @param props - Chart or pivot widget props * @param defaultDataSource - Used when `props.dataSource` is undefined * @param verbosity - Optional verbosity for narrative text * @param ignoreTrendAndForecast - When `true`, the primary request already omits trend/forecast * and no fallback is needed * @returns `{ supported, narrativeRequest, narrativeFallbackRequest }`. `supported` is `false` * when the widget type is unsupported, when no data source can be resolved for chart/pivot, or * when the primary conversion fails. * @example Chart or pivot widget props * ```ts * const { supported, narrativeRequest, narrativeFallbackRequest } = * buildWidgetNarrativeRequests( * widgetProps, // `WithCommonWidgetProps` or pivot equivalent * defaultDataSource, * 'High', * false, * ); * ``` * On success, `supported` is `true` and `narrativeRequest` / `narrativeFallbackRequest` hold the * primary and trend-stripped NLG payloads; otherwise `supported` is `false` and requests are * `undefined` (and `missingDataSource` may be set when no source could be resolved). * @internal */ export declare function buildWidgetNarrativeRequests(props: WidgetProps, defaultDataSource?: DataSource, verbosity?: 'Low' | 'High', ignoreTrendAndForecast?: boolean): WidgetNarrativeRequestPair;