@sisense/sdk-ui 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/ai/ai-context-provider.d.ts +1 -0
  2. package/dist/ai/api/chat-rest-api.d.ts +3 -0
  3. package/dist/ai/api/errors.d.ts +2 -1
  4. package/dist/ai/api/types.d.ts +10 -10
  5. package/dist/ai/chat-config.d.ts +10 -3
  6. package/dist/ai/chat-intro-blurb.d.ts +4 -0
  7. package/dist/ai/chatbot.d.ts +1 -0
  8. package/dist/ai/get-nlg-query-result.d.ts +3 -3
  9. package/dist/ai/index.d.ts +2 -0
  10. package/dist/ai/messages/feedback-wrapper.d.ts +2 -1
  11. package/dist/ai/messages/insights-message.d.ts +6 -1
  12. package/dist/ai/messages/message-list-resolver.d.ts +1 -2
  13. package/dist/ai/messages/message-resolver.d.ts +1 -3
  14. package/dist/ai/messages/nlq-message-group.d.ts +10 -0
  15. package/dist/ai/suggestions/index.d.ts +1 -1
  16. package/dist/ai/suggestions/suggestion-list.d.ts +1 -1
  17. package/dist/ai/suggestions/suggestions-with-intro.d.ts +2 -2
  18. package/dist/ai/translators/code-templates.d.ts +11 -0
  19. package/dist/ai/translators/generate-code.d.ts +9 -0
  20. package/dist/ai/translators/index.d.ts +4 -0
  21. package/dist/ai/translators/model-translator.d.ts +50 -0
  22. package/dist/ai/translators/query-translator.d.ts +122 -0
  23. package/dist/ai/translators/translate-props-to-code.d.ts +8 -0
  24. package/dist/ai/translators/types.d.ts +105 -0
  25. package/dist/ai/translators/use-get-data-source.d.ts +12 -0
  26. package/dist/ai/translators/utils.d.ts +2 -0
  27. package/dist/ai/use-chat-session.d.ts +9 -3
  28. package/dist/ai/use-get-nlg-query-result.d.ts +6 -6
  29. package/dist/ai/use-get-query-recommendations.d.ts +1 -0
  30. package/dist/ai.js +7077 -1734
  31. package/dist/area-chart.d.ts +1 -0
  32. package/dist/areamap-chart.d.ts +1 -0
  33. package/dist/bar-chart.d.ts +3 -0
  34. package/dist/boxplot-chart.d.ts +1 -0
  35. package/dist/boxplot-utils.d.ts +1 -0
  36. package/dist/chart/chart.d.ts +1 -0
  37. package/dist/chart-options-processor/translations/tooltip-utils.d.ts +1 -0
  38. package/dist/column-chart.d.ts +4 -0
  39. package/dist/common/components/loading-indicator.d.ts +2 -0
  40. package/dist/dashboard-widget/dashboard-widget.d.ts +1 -0
  41. package/dist/dashboard-widget/translate-widget-data-options.d.ts +5 -0
  42. package/dist/dashboard-widget/translate-widget-filters.d.ts +1 -0
  43. package/dist/dashboard-widget/types.d.ts +3 -2
  44. package/dist/filters/components/criteria-filter-tile/criteria-filter-tile.d.ts +1 -0
  45. package/dist/filters/components/date-filter/date-range-filter-tile/date-range-filter-tile.d.ts +1 -0
  46. package/dist/filters/components/date-filter/relative-date-filter-tile/relative-date-filter-tile.d.ts +1 -0
  47. package/dist/filters/components/member-filter-tile/member-filter-tile.d.ts +1 -0
  48. package/dist/formulas/use-get-shared-formula.d.ts +1 -0
  49. package/dist/funnel-chart.d.ts +1 -0
  50. package/dist/index.d.ts +4 -0
  51. package/dist/index.js +6719 -37723
  52. package/dist/indicator-chart.d.ts +1 -0
  53. package/dist/line-chart.d.ts +1 -0
  54. package/dist/models/dashboard/get-dashboard-models.d.ts +1 -3
  55. package/dist/models/dashboard/translate-dashboard.d.ts +1 -1
  56. package/dist/models/dashboard/types.d.ts +17 -0
  57. package/dist/models/dashboard/use-get-dashboard-model.d.ts +1 -0
  58. package/dist/models/dashboard/use-get-dashboard-models.d.ts +1 -0
  59. package/dist/models/widget/use-get-widget-model.d.ts +1 -0
  60. package/dist/models/widget/widget-model.d.ts +10 -1
  61. package/dist/pie-chart.d.ts +1 -0
  62. package/dist/pivot-table/pivot-table.d.ts +1 -0
  63. package/dist/polar-chart.d.ts +1 -0
  64. package/dist/props.d.ts +2 -2
  65. package/dist/query-execution/execute-query-by-widget-id.d.ts +1 -0
  66. package/dist/query-execution/execute-query.d.ts +1 -0
  67. package/dist/query-execution/use-execute-csv-query.d.ts +1 -0
  68. package/dist/query-execution/use-execute-pivot-query.d.ts +1 -0
  69. package/dist/query-execution/use-execute-query-by-widget-id.d.ts +1 -0
  70. package/dist/query-execution/use-execute-query.d.ts +1 -0
  71. package/dist/scatter-chart.d.ts +1 -0
  72. package/dist/scattermap-chart.d.ts +1 -0
  73. package/dist/sisense-context/sisense-context-provider.d.ts +1 -0
  74. package/dist/sunburst-chart.d.ts +1 -0
  75. package/dist/table/table.d.ts +1 -0
  76. package/dist/theme-provider/theme-provider.d.ts +7 -0
  77. package/dist/treemap-chart.d.ts +1 -0
  78. package/dist/types.d.ts +2 -2
  79. package/dist/widgets/chart-widget.d.ts +1 -0
  80. package/dist/widgets/common/context-menu.d.ts +5 -0
  81. package/dist/widgets/common/drilldown-breadcrumbs/drilldown-breadcrumbs.d.ts +5 -0
  82. package/dist/widgets/drilldown-widget.d.ts +1 -0
  83. package/dist/with-tracking-e2a077f9.js +109112 -0
  84. package/package.json +13 -8
  85. package/dist/chart-data-processor/utils.d.ts +0 -10
  86. package/dist/utils/not-available-value.d.ts +0 -3
  87. package/dist/with-tracking-0799ec25.js +0 -78081
@@ -27,6 +27,7 @@ export type AiContextProviderProps = {
27
27
  * );
28
28
  * }
29
29
  * ```
30
+ * @group Generative AI
30
31
  * @beta
31
32
  */
32
33
  export default function AiContextProvider({ children, config }: AiContextProviderProps): JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { HttpClient } from '@sisense/sdk-rest-client';
2
2
  import type { Chat, ChatRequest, ChatResponse, ChatWithoutHistory, DataModel, GetNlgQueryResultRequest, GetNlgQueryResultResponse, LlmConfig, Perspective, QueryRecommendationConfig, QueryRecommendationResponse, SendFeedbackRequest } from './types';
3
+ import { DataSourceField } from '@sisense/sdk-query-client';
3
4
  export declare class ChatRestApi {
4
5
  private httpClient;
5
6
  constructor(httpClient: HttpClient);
@@ -14,11 +15,13 @@ export declare class ChatRestApi {
14
15
  private postChat;
15
16
  private deleteChatHistory;
16
17
  private sendFeedback;
18
+ private getDataSourceFields;
17
19
  ai: {
18
20
  getNlgQueryResult: (request: GetNlgQueryResultRequest) => Promise<GetNlgQueryResultResponse>;
19
21
  getQueryRecommendations: (contextTitle: string, config: QueryRecommendationConfig) => Promise<QueryRecommendationResponse>;
20
22
  setLlmConfig: (config: LlmConfig) => Promise<unknown>;
21
23
  sendFeedback: (request: SendFeedbackRequest) => Promise<unknown>;
24
+ getDataSourceFields: (dataSource: string) => Promise<DataSourceField[]>;
22
25
  chat: {
23
26
  getAll: () => Promise<ChatWithoutHistory[]>;
24
27
  getById: (chatId: string) => Promise<Chat>;
@@ -1 +1,2 @@
1
- export declare const UNKNOWN_ERROR = "Oh snap, something went wrong. Please try again later or try asking a different question.";
1
+ export declare const UNEXPECTED_ERROR = "Oh snap, something went wrong. Please try again later.";
2
+ export declare const UNEXPECTED_CHAT_RESPONSE_ERROR = "Oh snap, something went wrong. Please try again later or try asking a different question.";
@@ -1,4 +1,4 @@
1
- import { MetadataItem } from '@sisense/sdk-query-client';
1
+ import { JaqlQueryPayload, MetadataItem } from '@sisense/sdk-query-client';
2
2
  import { ChartDataOptions } from '../../types';
3
3
  export interface ChatContext {
4
4
  id: string;
@@ -61,7 +61,7 @@ export type AllPossibleChartOptionKeys = KeysOfUnion<ChartDataOptions>;
61
61
  export type AxesMappingKey = Exclude<AllPossibleChartOptionKeys, 'seriesToColorMap'>;
62
62
  export type AxesMapping = Partial<Record<AxesMappingKey, Array<{
63
63
  name: string;
64
- type: string;
64
+ type?: string;
65
65
  }>>>;
66
66
  export interface ChartRecommendations {
67
67
  chartFamily: string;
@@ -103,14 +103,7 @@ export interface Perspective {
103
103
  isDefault: boolean;
104
104
  }
105
105
  export interface GetNlgQueryResultRequest {
106
- jaql: {
107
- /** The data source that the JAQL metadata targets - e.g. `Sample ECommerce` */
108
- datasource: {
109
- title: string;
110
- };
111
- /** The metadata that composes the JAQL to be analyzed */
112
- metadata: object[];
113
- };
106
+ jaql: Pick<JaqlQueryPayload, 'datasource' | 'metadata' | 'filterRelations'>;
114
107
  }
115
108
  export interface GetNlgQueryResultResponse {
116
109
  data?: {
@@ -124,4 +117,11 @@ export interface SendFeedbackRequest {
124
117
  sourceId: string;
125
118
  rating: -1 | 1;
126
119
  }
120
+ /**
121
+ * The chat mode to use for a chat session
122
+ *
123
+ * analyze: Enable business users to uncover data insights
124
+ * develop: Enable developers to build queries and charts for embedded analytics
125
+ */
126
+ export type ChatMode = 'analyze' | 'develop';
127
127
  export {};
@@ -1,9 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
+ import { ChatMode } from '../ai/api/types';
2
3
  export interface ChatConfig {
3
4
  /**
4
- * Boolean flag to show or hide suggested questions following a chat response
5
- *
6
- * If not specified, the default value is `false`
5
+ * Boolean flag to show or hide suggested questions following a chat response. Currently
6
+ * follow-up questions are still under development and are not validated. Therefore, follow-up
7
+ * questions are disabled by default.
7
8
  */
8
9
  enableFollowupQuestions: boolean;
9
10
  /**
@@ -18,6 +19,12 @@ export interface ChatConfig {
18
19
  * If specified, the data topic selector screen will not be shown.
19
20
  */
20
21
  defaultContextTitle?: string;
22
+ /**
23
+ * The chat mode to use for a chat session.
24
+ *
25
+ * @internal
26
+ */
27
+ chatMode?: ChatMode;
21
28
  }
22
29
  export declare const DEFAULTS: Readonly<ChatConfig>;
23
30
  export type ChatConfigProviderProps = {
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export default function ChatIntroBlurb(props: {
3
+ title: string;
4
+ }): JSX.Element;
@@ -44,6 +44,7 @@ export type ChatbotProps = {
44
44
  * }
45
45
  * ```
46
46
  * @param props - {@link ChatbotProps}
47
+ * @group Generative AI
47
48
  * @beta
48
49
  */
49
50
  export declare const Chatbot: import("react").FunctionComponent<ChatbotProps>;
@@ -6,9 +6,8 @@ import { UseGetNlgQueryResultParams } from './use-get-nlg-query-result';
6
6
  export interface GetNlgQueryResultProps extends Omit<UseGetNlgQueryResultParams, 'enabled'> {
7
7
  }
8
8
  /**
9
- * React component that fetches and displays a collapsible analysis of the provided JAQL using natural language generation (NLG).
10
- *
11
- * This takes the same props as {@link useGetNlgQueryResult} and makes the same API call but presents the result in a collapsible container.
9
+ * React component that fetches and displays a collapsible analysis of the provided query using natural language generation (NLG).
10
+ * Specifying a query is similar to providing parameters to a {@link useExecuteQuery} hook, using dimensions, measures, and filters.
12
11
  *
13
12
  * ::: warning Note
14
13
  * This component is currently under private beta for selected customers and is subject to change as we make fixes and improvements.
@@ -24,6 +23,7 @@ export interface GetNlgQueryResultProps extends Omit<UseGetNlgQueryResultParams,
24
23
  * ```
25
24
  * @param props - {@link GetNlgQueryResultProps}
26
25
  * @returns Collapsible container wrapping a text summary
26
+ * @group Generative AI
27
27
  * @beta
28
28
  */
29
29
  declare const _default: import("react").FunctionComponent<GetNlgQueryResultProps>;
@@ -2,6 +2,8 @@ export { default as AiContextProvider, type AiContextProviderProps } from './ai-
2
2
  export { type ChatConfig } from './chat-config';
3
3
  export { useGetNlgQueryResult, type UseGetNlgQueryResultParams, type UseGetNlgQueryResultState, } from './use-get-nlg-query-result';
4
4
  export { useGetQueryRecommendations, type UseGetQueryRecommendationsParams, type UseGetQueryRecommendationsState, } from './use-get-query-recommendations';
5
+ export { useChatSession, type UseChatSessionResult } from './use-chat-session';
5
6
  export type { GetNlgQueryResultRequest, QueryRecommendationResponse, QueryRecommendation, NlqResponseData, ChartRecommendations, AxesMapping, AxesMappingKey, AllPossibleChartOptionKeys, KeysOfUnion, } from './api/types';
6
7
  export { Chatbot, type ChatbotProps } from './chatbot';
7
8
  export { default as GetNlgQueryResult, type GetNlgQueryResultProps } from './get-nlg-query-result';
9
+ export * from './translators';
@@ -3,7 +3,8 @@ type FeedbackWrapperProps = {
3
3
  sourceId: string;
4
4
  data: object;
5
5
  type: string;
6
+ rightFooter?: ReactNode;
6
7
  children: ReactNode;
7
8
  };
8
- export default function FeedbackWrapper({ sourceId, data, type, children }: FeedbackWrapperProps): JSX.Element;
9
+ export default function FeedbackWrapper({ sourceId, data, type, rightFooter, children, }: FeedbackWrapperProps): JSX.Element;
9
10
  export {};
@@ -1,7 +1,12 @@
1
1
  /// <reference types="react" />
2
+ export declare function InsightsButton({ onClick, disabled, }: {
3
+ onClick?: () => void;
4
+ disabled?: boolean;
5
+ }): JSX.Element;
2
6
  type InsightsMessageProps = {
3
7
  dataSource: string;
4
8
  metadata: object[];
9
+ visible?: boolean;
5
10
  };
6
- export default function InsightsMessage({ dataSource, metadata }: InsightsMessageProps): JSX.Element;
11
+ export default function InsightsMessage({ dataSource, metadata, visible, }: InsightsMessageProps): JSX.Element | null;
7
12
  export {};
@@ -2,6 +2,5 @@
2
2
  import { ChatMessage } from '../api/types';
3
3
  export type MessageListResolverProps = {
4
4
  messages: ChatMessage[];
5
- sendMessage?: (message: string) => void;
6
5
  };
7
- export default function MessageListResolver({ messages, sendMessage, }: MessageListResolverProps): JSX.Element;
6
+ export default function MessageListResolver({ messages }: MessageListResolverProps): JSX.Element;
@@ -2,9 +2,7 @@
2
2
  import { ChatMessage } from '../api/types';
3
3
  type MessageResolverProps = {
4
4
  message: ChatMessage;
5
- sendMessage?: (message: string) => void;
6
- allowFollowupQuestions?: boolean;
7
5
  };
8
- declare function MessageResolver({ message, allowFollowupQuestions, sendMessage, }: MessageResolverProps): JSX.Element;
6
+ declare function MessageResolver({ message }: MessageResolverProps): JSX.Element;
9
7
  declare const _default: import("react").MemoExoticComponent<typeof MessageResolver>;
10
8
  export default _default;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { NlqResponseData } from '../api/types';
3
+ /**
4
+ * Renders a NLQ response as a series of chat messages/buttons.
5
+ *
6
+ * @internal
7
+ */
8
+ export default function NlqMessageGroup({ data }: {
9
+ data: NlqResponseData;
10
+ }): JSX.Element;
@@ -1,4 +1,4 @@
1
1
  export { default as SuggestionItem } from './suggestion-item';
2
2
  export { default as SuggestionList } from './suggestion-list';
3
- export { default as SuggestionListWithIntro } from './suggestions-with-intro';
4
3
  export { default as SuggestionListSkeleton } from './suggestion-list-skeleton';
4
+ export { default as SuggestionsWithIntro } from './suggestions-with-intro';
@@ -3,5 +3,5 @@ type Props = {
3
3
  questions: string[];
4
4
  onSelection: (question: string) => void;
5
5
  };
6
- export default function SuggestionList(props: Props): JSX.Element;
6
+ export default function SuggestionList({ questions, onSelection }: Props): JSX.Element;
7
7
  export {};
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  type Props = {
3
3
  questions: string[];
4
- title: string;
4
+ isLoading: boolean;
5
5
  onSelection: (question: string) => void;
6
6
  };
7
- export default function SuggestionsWithIntro(props: Props): JSX.Element;
7
+ export default function SuggestionsWithIntro({ questions, isLoading, onSelection }: Props): JSX.Element | null;
8
8
  export {};
@@ -0,0 +1,11 @@
1
+ import { CodeTemplates } from '../../ai/translators/types';
2
+ /**
3
+ * Code templates for different UI frameworks.
4
+ *
5
+ * A code template is made up of other code templates and placeholders.
6
+ * This allows a code template to be reused in other code templates.
7
+ * For example, a chart widget template can be reused in a dashboard template.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare const CODE_TEMPLATES: CodeTemplates;
@@ -0,0 +1,9 @@
1
+ import { CodeTemplateKey, UiFramework } from '../../ai/translators/types';
2
+ /**
3
+ * Generates code from a template with the given data and UI framework.
4
+ *
5
+ * @param templateKey - the key of the template to use
6
+ * @param data - the data to populate the template with
7
+ * @param uiFramework - the UI framework for the generated code
8
+ */
9
+ export declare const generateCode: (templateKey: CodeTemplateKey, data: Record<string, string>, uiFramework?: UiFramework) => string;
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export { useGetDataSource } from './use-get-data-source';
3
+ export { ModelTranslator } from './model-translator';
4
+ export { QueryTranslator } from './query-translator';
@@ -0,0 +1,50 @@
1
+ import { ExpandedQueryModel, ChartWidgetModel, UiFramework } from '../../ai/translators/types';
2
+ /**
3
+ * A class that translates expanded query model to CSDK chart model and code.
4
+ *
5
+ * @internal
6
+ */
7
+ export declare class ModelTranslator {
8
+ queryModel: ExpandedQueryModel;
9
+ constructor(queryModel: ExpandedQueryModel);
10
+ /**
11
+ * Gets chart recommendations or default to table.
12
+ *
13
+ * @param chart - chart recommendations
14
+ * @returns chart recommendations or default to table
15
+ */
16
+ private getChartRecommendationsOrDefault;
17
+ /**
18
+ * Gets filters from metadata.
19
+ *
20
+ * @param metadata - metadata items
21
+ */
22
+ private getFilters;
23
+ /**
24
+ * Splits metadata into columns and filters.
25
+ *
26
+ * @param metadata - metadata items
27
+ */
28
+ private splitMetadata;
29
+ /**
30
+ * Converts query model to chart.
31
+ *
32
+ * TODO Refactor Chatbot to use this method to render the chart
33
+ */
34
+ toChart(): ChartWidgetModel | undefined;
35
+ private stringifyDataSource;
36
+ private stringifyChartType;
37
+ private stringifyFilters;
38
+ private stringifyDataOptions;
39
+ private stringifyExtraImports;
40
+ private getChartWidgetCode;
41
+ private getTableWidgetCode;
42
+ /**
43
+ * Converts chart widget model to CSDK code.
44
+ *
45
+ * @param chartWidgetModel - chart widget model
46
+ * @param uiFramework - UI framework
47
+ * @returns CSDK code string of the UI framework
48
+ */
49
+ toCode(chartWidgetModel: ChartWidgetModel, uiFramework?: UiFramework): string;
50
+ }
@@ -0,0 +1,122 @@
1
+ import { ExpandedQueryModel, SimpleQueryModel, SimpleChartRecommendations } from '../../ai/translators/types';
2
+ import { DataSourceField, MetadataItem, MetadataItemJaql } from '@sisense/sdk-query-client';
3
+ import { ChartRecommendations } from '../../ai';
4
+ /**
5
+ * A class that translates ExpandedQueryModel (Raw JAQL+Chart Recommendations)
6
+ * to SimpleQueryModel (Simple JAQL+Simple Chart Options) and vice versa.
7
+ *
8
+ * It also provides methods to stringify query models to YAML strings
9
+ * and parse YAML strings to query models.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare class QueryTranslator {
14
+ private readonly contextTitle;
15
+ private indexedFields;
16
+ /**
17
+ * Constructor for QueryTranslator.
18
+ *
19
+ * @param contextTitle - The context title
20
+ * @param fields - The data source fields
21
+ */
22
+ constructor(contextTitle: string, fields: DataSourceField[]);
23
+ /**
24
+ * Concatenates Aggregation Types.
25
+ */
26
+ private concatAggTypes;
27
+ /**
28
+ * Simplifies Aggregation Formula defined in MetadataItemJaql returned from chat response.
29
+ *
30
+ * @param aggFormula - The Aggregation Formula to simplify
31
+ * @returns The equivalent measure
32
+ * @privateRemarks
33
+ * See unit tests for examples of aggregation formulas and their equivalent measures.
34
+ */
35
+ simplifyAggFormula(aggFormula: MetadataItemJaql): MetadataItemJaql;
36
+ /**
37
+ * Simplifies MetadataItemJaql.
38
+ *
39
+ * @param item - The MetadataItemJaql to simplify
40
+ * @returns The simplified MetadataItemJaql
41
+ */
42
+ simplifyMetadataItemJaql(item: MetadataItemJaql): MetadataItemJaql;
43
+ /**
44
+ * Simplifies MetadataItem.
45
+ *
46
+ * @param item - The MetadataItem to simplify
47
+ * @returns The simplified MetadataItem
48
+ */
49
+ simplifyMetadataItem(item: MetadataItem): MetadataItem;
50
+ /**
51
+ * Simplifies Chart Recommendations.
52
+ *
53
+ * @param chartRecommendations - The Chart Recommendations to simplify
54
+ * @returns The simplified chart data options
55
+ */
56
+ simplifyChartRecommendations(chartRecommendations: ChartRecommendations | {}): SimpleChartRecommendations | {};
57
+ /**
58
+ * Returns the query title with the chart type.
59
+ *
60
+ * @param queryTitle - The query title
61
+ * @param chartRecommendations - The chart recommendations
62
+ * @returns The query title with the chart type
63
+ */
64
+ getQueryTitleWithChartType(queryTitle: string, chartRecommendations: {} | ChartRecommendations): string;
65
+ /**
66
+ * Takes a ExpandedQueryModel (e.g., from chat response) and translates it to SimpleQueryModel.
67
+ *
68
+ * @param expandedQueryModel - The Expanded Query model to simplify
69
+ * @returns The simplified query model
70
+ */
71
+ translateToSimple(expandedQueryModel: ExpandedQueryModel): SimpleQueryModel;
72
+ /**
73
+ * Stringifies a simple query model to YAML string.
74
+ *
75
+ * @param simpleQueryModel - The Simple Query model to convert
76
+ * @returns The YAML string representing the simple query model
77
+ */
78
+ stringifySimple(simpleQueryModel: SimpleQueryModel): string;
79
+ /**
80
+ * Parses a YAML string to Simple Query Model.
81
+ *
82
+ * @param simpleQueryYaml - The YAML string to parse
83
+ * @returns The Simple Query Model
84
+ */
85
+ parseSimple(simpleQueryYaml: string): SimpleQueryModel;
86
+ /**
87
+ * Derives chart family from chart type.
88
+ *
89
+ * @param chartType - chart type
90
+ * @returns chart family
91
+ */
92
+ private deriveChartFamily;
93
+ /**
94
+ * Expands Chart Recommendations.
95
+ *
96
+ * @param chartRecommendations - The Chart Recommendations to expand
97
+ * @returns The expanded chart recommendations
98
+ */
99
+ expandChartRecommendations(chartRecommendations: SimpleChartRecommendations | {}): ChartRecommendations | {};
100
+ /**
101
+ * Expands MetadataItemJaql by adding table, column, datatype, and title
102
+ * if they are missing from the item.
103
+ *
104
+ * @param item - The MetadataItemJaql to expand
105
+ * @returns The expanded MetadataItemJaql
106
+ */
107
+ expandMetadataItemJaql(item: MetadataItemJaql): MetadataItemJaql;
108
+ /**
109
+ * Expands MetadataItem
110
+ *
111
+ * @param item - The MetadataItem to expand
112
+ * @returns The expanded MetadataItem
113
+ */
114
+ expandMetadataItem(item: MetadataItem): MetadataItem;
115
+ /**
116
+ * Translates a Simple Query Model to Expanded Query Model.
117
+ *
118
+ * @param simpleQueryModel - The Simple Query model to convert
119
+ * @returns The Expanded Query Model
120
+ */
121
+ translateToExpanded(simpleQueryModel: SimpleQueryModel): ExpandedQueryModel;
122
+ }
@@ -0,0 +1,8 @@
1
+ export type MembersFilterJaql = {
2
+ members: string[];
3
+ };
4
+ export type FromNotEqualFilterJaql = {
5
+ fromNotEqual: number;
6
+ };
7
+ export type FilterJaql = MembersFilterJaql | FromNotEqualFilterJaql;
8
+ export declare const stringifyProps: (props: object, indent?: number, wrapInQuotes?: boolean) => string;
@@ -0,0 +1,105 @@
1
+ import { MetadataItem } from '@sisense/sdk-query-client';
2
+ import { AxesMapping, NlqResponseData } from '../../ai';
3
+ import { ChartType, TableType } from '../../types';
4
+ import { WidgetModel } from '../../models';
5
+ /**
6
+ * Expanded Query Model that is based on NlqResponseData.
7
+ * It contains expanded JAQL and chart recommendations returned from the chat response.
8
+ *
9
+ * @internal
10
+ */
11
+ export type ExpandedQueryModel = Pick<NlqResponseData, 'jaql' | 'chartRecommendations' | 'queryTitle'>;
12
+ /**
13
+ * Expanded Query Model
14
+ *
15
+ * Used as a default value for ExpandedQueryModel
16
+ *
17
+ * @internal
18
+ */
19
+ export declare const EMPTY_EXPANDED_QUERY_MODEL: ExpandedQueryModel;
20
+ /**
21
+ * Simple Chart Recommendations
22
+ *
23
+ * @internal
24
+ */
25
+ export interface SimpleChartRecommendations {
26
+ chartType: string;
27
+ dataOptions: AxesMapping;
28
+ }
29
+ /**
30
+ * Simple Query Model that is a simplified version of ExpandedQueryModel.
31
+ *
32
+ * It removes any JAQL syntax or information that already exists in the schema.
33
+ * Also, any parameters that have a default do not need to be specified.
34
+ *
35
+ * Users manipulates this model via the query in YAML format.
36
+ *
37
+ * ModelTranslator is responsible for translating this query model to SimpleWidgetModel.
38
+ *
39
+ * @internal
40
+ */
41
+ export interface SimpleQueryModel {
42
+ /**
43
+ * The data model or perspective title.
44
+ */
45
+ model: string;
46
+ metadata: MetadataItem[];
47
+ chart: SimpleChartRecommendations | {};
48
+ /**
49
+ * Title of the query
50
+ */
51
+ queryTitle: string;
52
+ }
53
+ /**
54
+ * Empty Simple Query Model
55
+ *
56
+ * Used as a default value for SimpleQueryModel
57
+ *
58
+ * @internal
59
+ */
60
+ export declare const EMPTY_SIMPLE_QUERY_MODEL: SimpleQueryModel;
61
+ /**
62
+ * All Chart Types including Table
63
+ * Note: Table will be re-united with ChartType in a future MR
64
+ *
65
+ * @internal
66
+ */
67
+ export type AllChartType = ChartType | TableType;
68
+ /**
69
+ * Chart Widget Model
70
+ *
71
+ * This model serves two purposes:
72
+ *
73
+ * (1) For rendering a chart or table widget in the Query Composer.
74
+ * (2) For reverse engineered (translated) to CSDK code
75
+ *
76
+ * Naming TBD
77
+ *
78
+ * @internal
79
+ */
80
+ export type ChartWidgetModel = Pick<WidgetModel, 'getChartWidgetProps' | 'getTableWidgetProps'> & {
81
+ chartType: AllChartType;
82
+ queryTitle: string;
83
+ };
84
+ /**
85
+ * UI Framework
86
+ *
87
+ * @internal
88
+ */
89
+ export type UiFramework = 'react' | 'vue' | 'angular';
90
+ /**
91
+ * Code Template Key
92
+ *
93
+ * @internal
94
+ */
95
+ export type CodeTemplateKey = 'baseChartTmpl' | 'chartTmpl' | 'chartWidgetTmpl' | 'tableWidgetTmpl';
96
+ /**
97
+ * Code Templates
98
+ *
99
+ * @internal
100
+ */
101
+ export type CodeTemplates = {
102
+ [key in UiFramework]: {
103
+ [key in CodeTemplateKey]: string;
104
+ };
105
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Gets the fields of a data source.
3
+ *
4
+ * Alternative hook implementation of QueryApiDispatcher.getDataSourceFields
5
+ *
6
+ * @param dataSource - The data source to get the fields for
7
+ * @internal
8
+ */
9
+ export declare const useGetDataSource: (dataSource: string | undefined) => {
10
+ data: import("@sisense/sdk-query-client").DataSourceField[] | undefined;
11
+ isLoading: boolean;
12
+ };
@@ -0,0 +1,2 @@
1
+ export declare function toKebabCase(str: string): string;
2
+ export declare function capitalizeFirstLetter(str: string): string;
@@ -1,11 +1,18 @@
1
- import type { ChatMessage } from './api/types';
2
- interface UseChatSessionResult {
1
+ import type { ChatMessage, NlqMessage, NlqResponseData } from './api/types';
2
+ /**
3
+ * Result of the useChatSession hook.
4
+ *
5
+ * @internal
6
+ */
7
+ export interface UseChatSessionResult {
3
8
  chatId: string | undefined;
4
9
  history: ChatMessage[];
10
+ lastNlqResponse: NlqResponseData | null;
5
11
  sendMessage: (message: string) => void;
6
12
  isAwaitingResponse: boolean;
7
13
  isLoading: boolean;
8
14
  }
15
+ export declare const isNlqMessage: (message: ChatMessage | null | undefined) => message is NlqMessage;
9
16
  /**
10
17
  * React hook that returns a chat session object for the given data model or
11
18
  * perspective.
@@ -19,4 +26,3 @@ interface UseChatSessionResult {
19
26
  * @internal
20
27
  */
21
28
  export declare const useChatSession: (contextTitle: string) => UseChatSessionResult;
22
- export {};
@@ -1,4 +1,4 @@
1
- import { Attribute, Filter, Measure } from '@sisense/sdk-data';
1
+ import { Attribute, DataSource, Filter, FilterRelations, Measure } from '@sisense/sdk-data';
2
2
  import { GetNlgQueryResultRequest } from './api/types';
3
3
  import { GetNlgQueryResultProps } from './get-nlg-query-result';
4
4
  /**
@@ -6,13 +6,13 @@ import { GetNlgQueryResultProps } from './get-nlg-query-result';
6
6
  */
7
7
  export interface UseGetNlgQueryResultParams {
8
8
  /** The data source that the query targets - e.g. `Sample ECommerce` */
9
- dataSource: string;
9
+ dataSource: DataSource;
10
10
  /** Dimensions of the query */
11
11
  dimensions?: Attribute[];
12
12
  /** Measures of the query */
13
13
  measures?: Measure[];
14
14
  /** Filters of the query */
15
- filters?: Filter[];
15
+ filters?: Filter[] | FilterRelations;
16
16
  /**
17
17
  * Boolean flag to enable/disable API call by default
18
18
  *
@@ -42,9 +42,8 @@ export interface UseGetNlgQueryResultState {
42
42
  */
43
43
  export declare const useGetNlgQueryResultInternal: (params: GetNlgQueryResultProps | GetNlgQueryResultRequest, enabled?: boolean) => UseGetNlgQueryResultState;
44
44
  /**
45
- * React hook that fetches an analysis of the provided JAQL using natural language generation (NLG).
46
- *
47
- * Note that in the example below, this hook expects `metadata` to be in standard JAQL syntax.
45
+ * React hook that fetches an analysis of the provided query using natural language generation (NLG).
46
+ * Specifying a query is similar to providing parameters to a {@link useExecuteQuery} hook, using dimensions, measures, and filters.
48
47
  *
49
48
  * ::: warning Note
50
49
  * This hook is currently under private beta for selected customers and is subject to change as we make fixes and improvements.
@@ -66,6 +65,7 @@ export declare const useGetNlgQueryResultInternal: (params: GetNlgQueryResultPro
66
65
  * ```
67
66
  * @param params - {@link UseGetNlgQueryResultParams}
68
67
  * @returns Response object containing a text summary
68
+ * @group Generative AI
69
69
  * @beta
70
70
  */
71
71
  export declare const useGetNlgQueryResult: (params: UseGetNlgQueryResultParams) => UseGetNlgQueryResultState;
@@ -59,6 +59,7 @@ export declare const useGetQueryRecommendationsInternal: (params: UseGetQueryRec
59
59
  * ```
60
60
  * @param params - {@link UseGetQueryRecommendationsParams}
61
61
  * @returns An array of objects, each containing recommended question text and its corresponding JAQL
62
+ * @group Generative AI
62
63
  * @beta
63
64
  */
64
65
  export declare const useGetQueryRecommendations: (params: UseGetQueryRecommendationsParams) => UseGetQueryRecommendationsState;