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'; import { type CompleteWidgetNarrativeConfig } from './widget-narrative-config.js'; /** * Converts ChartWidgetProps to {@link NarrativeQueryParams} by extracting dimensions and measures * from the chart data options. * * @param props - ChartWidgetProps to convert. `config.narrative` supplies {@link WidgetNarrativeConfig}. Defaults are calculated via {@link getCompleteWidgetNarrativeConfig} * @param defaultDataSource - Optional default data source to use if props.dataSource is undefined * @returns Params ready for {@link prepareNarrativeRequest} * @throws If neither `props.dataSource` nor `defaultDataSource` is set * @internal */ export declare function convertChartWidgetPropsToNarrativeParams(props: ChartWidgetProps, defaultDataSource?: DataSource): 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'`); `config.narrative` supplies * {@link WidgetNarrativeConfig} via {@link getWidgetNarrativeConfigFromWidgetProps} * @param defaultDataSource - Used when `props.dataSource` is undefined * @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): NarrativeRequest; /** * @deprecated Use {@link convertChartWidgetPropsToNarrativeParams} for {@link NarrativeQueryParams}, * or {@link convertWidgetPropsToNarrativeParams} for a ready {@link NarrativeRequest}. */ export declare const convertChartWidgetPropsToUseGetNlgInsightsParams: typeof convertChartWidgetPropsToNarrativeParams; /** * Builds a {@link NarrativeRequest} from chart or pivot widget props (including `id` / `widgetType`). * * @param props - Chart or pivot {@link WidgetProps} * @param defaultDataSource - Used when `props.dataSource` is undefined * @returns Request ready for {@link getNarrative} * @throws If widget type is not chart or pivot, data source cannot be resolved, or conversion fails * @internal */ export declare function convertWidgetPropsToNarrativeParams(props: WithCommonWidgetProps | WithCommonWidgetProps, defaultDataSource?: DataSource): NarrativeRequest; /** * Completes widget narrative options from chart/pivot `WidgetProps` for NLG (`config.narrative`). * * @param props - Widget props (chart, pivot, or other) * @returns Complete narrative defaults for non-chart/pivot types * @internal */ export declare function getCompleteWidgetNarrativeConfigFromWidgetProps(props: WidgetProps): CompleteWidgetNarrativeConfig; /** * Error message for imperative callers (e.g. {@link getNlgInsightsFromWidget}) when chart or pivot widget * props omit `dataSource`, no defaultDataSource can be resolved from app context, and no defaultDataSource is provided. * * @internal */ export declare const MISSING_DATASOURCE_NLG_ERROR = "dataSource is required. Provide it on the widget props, defaultDataSource parameter or via SisenseContextProvider."; export type WidgetNarrativeRequestPair = { supported: boolean; narrativeRequest: NarrativeRequest | undefined; /** * Same request with trend/forecast stripped. `undefined` when `includeTrendAndForecast` is * already `false` (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. * @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. * @remarks {@link WidgetNarrativeConfig} are derived from `props.config?.narrative` * via {@link getWidgetNarrativeConfigFromWidgetProps} and {@link getCompleteWidgetNarrativeConfig}. * @internal */ export declare function buildWidgetNarrativeRequests(props: WidgetProps, defaultDataSource?: DataSource): WidgetNarrativeRequestPair;